diff --git a/assets/index-34662bc3.js b/assets/index-34662bc3.js deleted file mode 100644 index dc6a5eb..0000000 --- a/assets/index-34662bc3.js +++ /dev/null @@ -1,15 +0,0 @@ -var em=Object.defineProperty;var tm=(t,e,n)=>e in t?em(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ge=(t,e,n)=>(tm(t,typeof e!="symbol"?e+"":e,n),n),ll=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var i=(t,e,n)=>(ll(t,e,"read from private field"),n?n.call(t):e.get(t)),D=(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)},z=(t,e,n,r)=>(ll(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);var _e=(t,e,n)=>(ll(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"]'))r(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const p of l.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&r(p)}).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 r(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function rf(t,e){const n=Object.create(null),r=t.split(",");for(let a=0;a!!n[a.toLowerCase()]:a=>!!n[a]}function sf(t){if(Se(t)){const e={};for(let n=0;n{if(n){const r=n.split(rm);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function of(t){let e="";if(kt(t))e=t;else if(Se(t))for(let n=0;nkt(t)?t:t==null?"":Se(t)||ft(t)&&(t.toString===td||!Ie(t.toString))?JSON.stringify(t,Xh,2):String(t),Xh=(t,e)=>e&&e.__v_isRef?Xh(t,e.value):Vs(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((n,[r,a])=>(n[`${r} =>`]=a,n),{})}:Zh(e)?{[`Set(${e.size})`]:[...e.values()]}:ft(e)&&!Se(e)&&!nd(e)?String(e):e,at={},js=[],rr=()=>{},cm=()=>!1,lm=/^on[^a-z]/,$c=t=>lm.test(t),af=t=>t.startsWith("onUpdate:"),Gt=Object.assign,uf=(t,e)=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)},fm=Object.prototype.hasOwnProperty,Me=(t,e)=>fm.call(t,e),Se=Array.isArray,Vs=t=>Qc(t)==="[object Map]",Zh=t=>Qc(t)==="[object Set]",Ie=t=>typeof t=="function",kt=t=>typeof t=="string",cf=t=>typeof t=="symbol",ft=t=>t!==null&&typeof t=="object",ed=t=>ft(t)&&Ie(t.then)&&Ie(t.catch),td=Object.prototype.toString,Qc=t=>td.call(t),hm=t=>Qc(t).slice(8,-1),nd=t=>Qc(t)==="[object Object]",lf=t=>kt(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Au=rf(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),jc=t=>{const e=Object.create(null);return n=>e[n]||(e[n]=t(n))},dm=/-(\w)/g,No=jc(t=>t.replace(dm,(e,n)=>n?n.toUpperCase():"")),pm=/\B([A-Z])/g,Co=jc(t=>t.replace(pm,"-$1").toLowerCase()),rd=jc(t=>t.charAt(0).toUpperCase()+t.slice(1)),fl=jc(t=>t?`on${rd(t)}`:""),ma=(t,e)=>!Object.is(t,e),hl=(t,e)=>{for(let n=0;n{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})},mm=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let zf;const ym=()=>zf||(zf=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});let Vn;class wm{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=Vn,!e&&Vn&&(this.index=(Vn.scopes||(Vn.scopes=[])).push(this)-1)}get active(){return this._active}run(e){if(this._active){const n=Vn;try{return Vn=this,e()}finally{Vn=n}}}on(){Vn=this}off(){Vn=this.parent}stop(e){if(this._active){let n,r;for(n=0,r=this.effects.length;n{const e=new Set(t);return e.w=0,e.n=0,e},id=t=>(t.w&li)>0,sd=t=>(t.n&li)>0,Nm=({deps:t})=>{if(t.length)for(let e=0;e{const{deps:e}=t;if(e.length){let n=0;for(let r=0;r{(A==="length"||A>=v)&&w.push(d)})}else switch(n!==void 0&&w.push(p.get(n)),e){case"add":Se(t)?lf(n)&&w.push(p.get("length")):(w.push(p.get(as)),Vs(t)&&w.push(p.get(Cl)));break;case"delete":Se(t)||(w.push(p.get(as)),Vs(t)&&w.push(p.get(Cl)));break;case"set":Vs(t)&&w.push(p.get(as));break}if(w.length===1)w[0]&&ql(w[0]);else{const v=[];for(const d of w)d&&v.push(...d);ql(ff(v))}}function ql(t,e){const n=Se(t)?t:[...t];for(const r of n)r.computed&&Kf(r);for(const r of n)r.computed||Kf(r)}function Kf(t,e){(t!==er||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const _m=rf("__proto__,__v_isRef,__isVue"),ud=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(cf)),xm=df(),Om=df(!1,!0),Em=df(!0),Jf=Cm();function Cm(){const t={};return["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...n){const r=Be(this);for(let l=0,p=this.length;l{t[e]=function(...n){qo();const r=Be(this)[e].apply(this,n);return So(),r}}),t}function qm(t){const e=Be(this);return yn(e,"has",t),e.hasOwnProperty(t)}function df(t=!1,e=!1){return function(r,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?Qm:dd:e?hd:fd).get(r))return r;const p=Se(r);if(!t){if(p&&Me(Jf,a))return Reflect.get(Jf,a,l);if(a==="hasOwnProperty")return qm}const w=Reflect.get(r,a,l);return(cf(a)?ud.has(a):_m(a))||(t||yn(r,"get",a),e)?w:Jt(w)?p&&lf(a)?w:w.value:ft(w)?t?pd(w):yf(w):w}}const Sm=cd(),Am=cd(!0);function cd(t=!1){return function(n,r,a,l){let p=n[r];if(vo(p)&&Jt(p)&&!Jt(a))return!1;if(!t&&(!$u(a)&&!vo(a)&&(p=Be(p),a=Be(a)),!Se(n)&&Jt(p)&&!Jt(a)))return p.value=a,!0;const w=Se(n)&&lf(r)?Number(r)t,Vc=t=>Reflect.getPrototypeOf(t);function Nu(t,e,n=!1,r=!1){t=t.__v_raw;const a=Be(t),l=Be(e);n||(e!==l&&yn(a,"get",e),yn(a,"get",l));const{has:p}=Vc(a),w=r?pf:n?gf:ya;if(p.call(a,e))return w(t.get(e));if(p.call(a,l))return w(t.get(l));t!==a&&t.get(e)}function vu(t,e=!1){const n=this.__v_raw,r=Be(n),a=Be(t);return e||(t!==a&&yn(r,"has",t),yn(r,"has",a)),t===a?n.has(t):n.has(t)||n.has(a)}function _u(t,e=!1){return t=t.__v_raw,!e&&yn(Be(t),"iterate",as),Reflect.get(t,"size",t)}function Gf(t){t=Be(t);const e=Be(this);return Vc(e).has.call(e,t)||(e.add(t),Tr(e,"add",t,t)),this}function Yf(t,e){e=Be(e);const n=Be(this),{has:r,get:a}=Vc(n);let l=r.call(n,t);l||(t=Be(t),l=r.call(n,t));const p=a.call(n,t);return n.set(t,e),l?ma(e,p)&&Tr(n,"set",t,e):Tr(n,"add",t,e),this}function Xf(t){const e=Be(this),{has:n,get:r}=Vc(e);let a=n.call(e,t);a||(t=Be(t),a=n.call(e,t)),r&&r.call(e,t);const l=e.delete(t);return a&&Tr(e,"delete",t,void 0),l}function Zf(){const t=Be(this),e=t.size!==0,n=t.clear();return e&&Tr(t,"clear",void 0,void 0),n}function xu(t,e){return function(r,a){const l=this,p=l.__v_raw,w=Be(p),v=e?pf:t?gf:ya;return!t&&yn(w,"iterate",as),p.forEach((d,A)=>r.call(a,v(d),v(A),l))}}function Ou(t,e,n){return function(...r){const a=this.__v_raw,l=Be(a),p=Vs(l),w=t==="entries"||t===Symbol.iterator&&p,v=t==="keys"&&p,d=a[t](...r),A=n?pf:e?gf:ya;return!e&&yn(l,"iterate",v?Cl:as),{next(){const{value:B,done:F}=d.next();return F?{value:B,done:F}:{value:w?[A(B[0]),A(B[1])]:A(B),done:F}},[Symbol.iterator](){return this}}}}function jr(t){return function(...e){return t==="delete"?!1:this}}function Dm(){const t={get(l){return Nu(this,l)},get size(){return _u(this)},has:vu,add:Gf,set:Yf,delete:Xf,clear:Zf,forEach:xu(!1,!1)},e={get(l){return Nu(this,l,!1,!0)},get size(){return _u(this)},has:vu,add:Gf,set:Yf,delete:Xf,clear:Zf,forEach:xu(!1,!0)},n={get(l){return Nu(this,l,!0)},get size(){return _u(this,!0)},has(l){return vu.call(this,l,!0)},add:jr("add"),set:jr("set"),delete:jr("delete"),clear:jr("clear"),forEach:xu(!0,!1)},r={get(l){return Nu(this,l,!0,!0)},get size(){return _u(this,!0)},has(l){return vu.call(this,l,!0)},add:jr("add"),set:jr("set"),delete:jr("delete"),clear:jr("clear"),forEach:xu(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(l=>{t[l]=Ou(l,!1,!1),n[l]=Ou(l,!0,!1),e[l]=Ou(l,!1,!0),r[l]=Ou(l,!0,!0)}),[t,n,e,r]}const[Lm,Pm,Mm,Bm]=Dm();function mf(t,e){const n=e?t?Bm:Mm:t?Pm:Lm;return(r,a,l)=>a==="__v_isReactive"?!t:a==="__v_isReadonly"?t:a==="__v_raw"?r:Reflect.get(Me(n,a)&&a in r?n:r,a,l)}const Fm={get:mf(!1,!1)},Um={get:mf(!1,!0)},$m={get:mf(!0,!1)},fd=new WeakMap,hd=new WeakMap,dd=new WeakMap,Qm=new WeakMap;function jm(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Vm(t){return t.__v_skip||!Object.isExtensible(t)?0:jm(hm(t))}function yf(t){return vo(t)?t:wf(t,!1,ld,Fm,fd)}function zm(t){return wf(t,!1,Rm,Um,hd)}function pd(t){return wf(t,!0,Wm,$m,dd)}function wf(t,e,n,r,a){if(!ft(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const l=a.get(t);if(l)return l;const p=Vm(t);if(p===0)return t;const w=new Proxy(t,p===2?r:n);return a.set(t,w),w}function zs(t){return vo(t)?zs(t.__v_raw):!!(t&&t.__v_isReactive)}function vo(t){return!!(t&&t.__v_isReadonly)}function $u(t){return!!(t&&t.__v_isShallow)}function md(t){return zs(t)||vo(t)}function Be(t){const e=t&&t.__v_raw;return e?Be(e):t}function yd(t){return Uu(t,"__v_skip",!0),t}const ya=t=>ft(t)?yf(t):t,gf=t=>ft(t)?pd(t):t;function wd(t){ai&&er&&(t=Be(t),ad(t.dep||(t.dep=ff())))}function gd(t,e){t=Be(t);const n=t.dep;n&&ql(n)}function Jt(t){return!!(t&&t.__v_isRef===!0)}function Hm(t){return Km(t,!1)}function Km(t,e){return Jt(t)?t:new Jm(t,e)}class Jm{constructor(e,n){this.__v_isShallow=n,this.dep=void 0,this.__v_isRef=!0,this._rawValue=n?e:Be(e),this._value=n?e:ya(e)}get value(){return wd(this),this._value}set value(e){const n=this.__v_isShallow||$u(e)||vo(e);e=n?e:Be(e),ma(e,this._rawValue)&&(this._rawValue=e,this._value=n?e:ya(e),gd(this))}}function bd(t){return Jt(t)?t.value:t}const Gm={get:(t,e,n)=>bd(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const a=t[e];return Jt(a)&&!Jt(n)?(a.value=n,!0):Reflect.set(t,e,n,r)}};function Nd(t){return zs(t)?t:new Proxy(t,Gm)}var vd;class Ym{constructor(e,n,r,a){this._setter=n,this.dep=void 0,this.__v_isRef=!0,this[vd]=!1,this._dirty=!0,this.effect=new hf(e,()=>{this._dirty||(this._dirty=!0,gd(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!a,this.__v_isReadonly=r}get value(){const e=Be(this);return wd(e),(e._dirty||!e._cacheable)&&(e._dirty=!1,e._value=e.effect.run()),e._value}set value(e){this._setter(e)}}vd="__v_isReadonly";function Xm(t,e,n=!1){let r,a;const l=Ie(t);return l?(r=t,a=rr):(r=t.get,a=t.set),new Ym(r,a,l||!a,n)}function ui(t,e,n,r){let a;try{a=r?t(...r):t()}catch(l){zc(l,e,n)}return a}function Rn(t,e,n,r){if(Ie(t)){const l=ui(t,e,n,r);return l&&ed(l)&&l.catch(p=>{zc(p,e,n)}),l}const a=[];for(let l=0;l>>1;ga(Kt[r])yr&&Kt.splice(e,1)}function ry(t){Se(t)?Hs.push(...t):(!xr||!xr.includes(t,t.allowRecurse?Mi+1:Mi))&&Hs.push(t),xd()}function eh(t,e=wa?yr+1:0){for(;ega(n)-ga(r)),Mi=0;Mit.id==null?1/0:t.id,iy=(t,e)=>{const n=ga(t)-ga(e);if(n===0){if(t.pre&&!e.pre)return-1;if(e.pre&&!t.pre)return 1}return n};function Ed(t){Sl=!1,wa=!0,Kt.sort(iy);const e=rr;try{for(yr=0;yrkt(Y)?Y.trim():Y)),B&&(a=n.map(mm))}let w,v=r[w=fl(e)]||r[w=fl(No(e))];!v&&l&&(v=r[w=fl(Co(e))]),v&&Rn(v,t,6,a);const d=r[w+"Once"];if(d){if(!t.emitted)t.emitted={};else if(t.emitted[w])return;t.emitted[w]=!0,Rn(d,t,6,a)}}function Cd(t,e,n=!1){const r=e.emitsCache,a=r.get(t);if(a!==void 0)return a;const l=t.emits;let p={},w=!1;if(!Ie(t)){const v=d=>{const A=Cd(d,e,!0);A&&(w=!0,Gt(p,A))};!n&&e.mixins.length&&e.mixins.forEach(v),t.extends&&v(t.extends),t.mixins&&t.mixins.forEach(v)}return!l&&!w?(ft(t)&&r.set(t,null),null):(Se(l)?l.forEach(v=>p[v]=null):Gt(p,l),ft(t)&&r.set(t,p),p)}function Hc(t,e){return!t||!$c(e)?!1:(e=e.slice(2).replace(/Once$/,""),Me(t,e[0].toLowerCase()+e.slice(1))||Me(t,Co(e))||Me(t,e))}let tr=null,qd=null;function Qu(t){const e=tr;return tr=t,qd=t&&t.type.__scopeId||null,e}function oy(t,e=tr,n){if(!e||t._n)return t;const r=(...a)=>{r._d&&ch(-1);const l=Qu(e);let p;try{p=t(...a)}finally{Qu(l),r._d&&ch(1)}return p};return r._n=!0,r._c=!0,r._d=!0,r}function dl(t){const{type:e,vnode:n,proxy:r,withProxy:a,props:l,propsOptions:[p],slots:w,attrs:v,emit:d,render:A,renderCache:B,data:F,setupState:Y,ctx:X,inheritAttrs:b}=t;let E,N;const q=Qu(t);try{if(n.shapeFlag&4){const ne=a||r;E=pr(A.call(ne,ne,B,l,Y,F,X)),N=v}else{const ne=e;E=pr(ne.length>1?ne(l,{attrs:v,slots:w,emit:d}):ne(l,null)),N=e.props?v:ay(v)}}catch(ne){sa.length=0,zc(ne,t,1),E=us(Ar)}let T=E;if(N&&b!==!1){const ne=Object.keys(N),{shapeFlag:ye}=T;ne.length&&ye&7&&(p&&ne.some(af)&&(N=uy(N,p)),T=fi(T,N))}return n.dirs&&(T=fi(T),T.dirs=T.dirs?T.dirs.concat(n.dirs):n.dirs),n.transition&&(T.transition=n.transition),E=T,Qu(q),E}const ay=t=>{let e;for(const n in t)(n==="class"||n==="style"||$c(n))&&((e||(e={}))[n]=t[n]);return e},uy=(t,e)=>{const n={};for(const r in t)(!af(r)||!(r.slice(9)in e))&&(n[r]=t[r]);return n};function cy(t,e,n){const{props:r,children:a,component:l}=t,{props:p,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 r?th(r,p,d):!!p;if(v&8){const A=e.dynamicProps;for(let B=0;Bt.__isSuspense;function hy(t,e){e&&e.pendingBranch?Se(t)?e.effects.push(...t):e.effects.push(t):ry(t)}function dy(t,e){if(xt){let n=xt.provides;const r=xt.parent&&xt.parent.provides;r===n&&(n=xt.provides=Object.create(r)),n[t]=e}}function Iu(t,e,n=!1){const r=xt||tr;if(r){const a=r.parent==null?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides;if(a&&t in a)return a[t];if(arguments.length>1)return n&&Ie(e)?e.call(r.proxy):e}}const Eu={};function pl(t,e,n){return Sd(t,e,n)}function Sd(t,e,{immediate:n,deep:r,flush:a,onTrack:l,onTrigger:p}=at){const w=bm()===(xt==null?void 0:xt.scope)?xt:null;let v,d=!1,A=!1;if(Jt(t)?(v=()=>t.value,d=$u(t)):zs(t)?(v=()=>t,r=!0):Se(t)?(A=!0,d=t.some(T=>zs(T)||$u(T)),v=()=>t.map(T=>{if(Jt(T))return T.value;if(zs(T))return Ls(T);if(Ie(T))return ui(T,w,2)})):Ie(t)?e?v=()=>ui(t,w,2):v=()=>{if(!(w&&w.isUnmounted))return B&&B(),Rn(t,w,3,[F])}:v=rr,e&&r){const T=v;v=()=>Ls(T())}let B,F=T=>{B=N.onStop=()=>{ui(T,w,4)}},Y;if(va)if(F=rr,e?n&&Rn(e,w,3,[v(),A?[]:void 0,F]):v(),a==="sync"){const T=hw();Y=T.__watcherHandles||(T.__watcherHandles=[])}else return rr;let X=A?new Array(t.length).fill(Eu):Eu;const b=()=>{if(N.active)if(e){const T=N.run();(r||d||(A?T.some((ne,ye)=>ma(ne,X[ye])):ma(T,X)))&&(B&&B(),Rn(e,w,3,[T,X===Eu?void 0:A&&X[0]===Eu?[]:X,F]),X=T)}else N.run()};b.allowRecurse=!!e;let E;a==="sync"?E=b:a==="post"?E=()=>ln(b,w&&w.suspense):(b.pre=!0,w&&(b.id=w.uid),E=()=>Nf(b));const N=new hf(v,E);e?n?b():X=N.run():a==="post"?ln(N.run.bind(N),w&&w.suspense):N.run();const q=()=>{N.stop(),w&&w.scope&&uf(w.scope.effects,N)};return Y&&Y.push(q),q}function py(t,e,n){const r=this.proxy,a=kt(t)?t.includes(".")?Ad(r,t):()=>r[t]:t.bind(r,r);let l;Ie(e)?l=e:(l=e.handler,n=e);const p=xt;_o(this);const w=Sd(a,l.bind(r),n);return p?_o(p):cs(),w}function Ad(t,e){const n=e.split(".");return()=>{let r=t;for(let a=0;a{Ls(n,e)});else if(nd(t))for(const n in t)Ls(t[n],e);return t}function my(){const t={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return Wd(()=>{t.isMounted=!0}),Rd(()=>{t.isUnmounting=!0}),t}const kn=[Function,Array],yy={name:"BaseTransition",props:{mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:kn,onEnter:kn,onAfterEnter:kn,onEnterCancelled:kn,onBeforeLeave:kn,onLeave:kn,onAfterLeave:kn,onLeaveCancelled:kn,onBeforeAppear:kn,onAppear:kn,onAfterAppear:kn,onAppearCancelled:kn},setup(t,{slots:e}){const n=iw(),r=my();let a;return()=>{const l=e.default&&Td(e.default(),!0);if(!l||!l.length)return;let p=l[0];if(l.length>1){for(const b of l)if(b.type!==Ar){p=b;break}}const w=Be(t),{mode:v}=w;if(r.isLeaving)return ml(p);const d=nh(p);if(!d)return ml(p);const A=Al(d,w,r,n);Il(d,A);const B=n.subTree,F=B&&nh(B);let Y=!1;const{getTransitionKey:X}=d.type;if(X){const b=X();a===void 0?a=b:b!==a&&(a=b,Y=!0)}if(F&&F.type!==Ar&&(!Bi(d,F)||Y)){const b=Al(F,w,r,n);if(Il(F,b),v==="out-in")return r.isLeaving=!0,b.afterLeave=()=>{r.isLeaving=!1,n.update.active!==!1&&n.update()},ml(p);v==="in-out"&&d.type!==Ar&&(b.delayLeave=(E,N,q)=>{const T=Id(r,F);T[String(F.key)]=F,E._leaveCb=()=>{N(),E._leaveCb=void 0,delete A.delayedLeave},A.delayedLeave=q})}return p}}},wy=yy;function Id(t,e){const{leavingVNodes:n}=t;let r=n.get(e.type);return r||(r=Object.create(null),n.set(e.type,r)),r}function Al(t,e,n,r){const{appear:a,mode:l,persisted:p=!1,onBeforeEnter:w,onEnter:v,onAfterEnter:d,onEnterCancelled:A,onBeforeLeave:B,onLeave:F,onAfterLeave:Y,onLeaveCancelled:X,onBeforeAppear:b,onAppear:E,onAfterAppear:N,onAppearCancelled:q}=e,T=String(t.key),ne=Id(n,t),ye=(Ne,Ze)=>{Ne&&Rn(Ne,r,9,Ze)},ae=(Ne,Ze)=>{const He=Ze[1];ye(Ne,Ze),Se(Ne)?Ne.every(Ot=>Ot.length<=1)&&He():Ne.length<=1&&He()},be={mode:l,persisted:p,beforeEnter(Ne){let Ze=w;if(!n.isMounted)if(a)Ze=b||w;else return;Ne._leaveCb&&Ne._leaveCb(!0);const He=ne[T];He&&Bi(t,He)&&He.el._leaveCb&&He.el._leaveCb(),ye(Ze,[Ne])},enter(Ne){let Ze=v,He=d,Ot=A;if(!n.isMounted)if(a)Ze=E||v,He=N||d,Ot=q||A;else return;let Et=!1;const Qe=Ne._enterCb=$t=>{Et||(Et=!0,$t?ye(Ot,[Ne]):ye(He,[Ne]),be.delayedLeave&&be.delayedLeave(),Ne._enterCb=void 0)};Ze?ae(Ze,[Ne,Qe]):Qe()},leave(Ne,Ze){const He=String(t.key);if(Ne._enterCb&&Ne._enterCb(!0),n.isUnmounting)return Ze();ye(B,[Ne]);let Ot=!1;const Et=Ne._leaveCb=Qe=>{Ot||(Ot=!0,Ze(),Qe?ye(X,[Ne]):ye(Y,[Ne]),Ne._leaveCb=void 0,ne[He]===t&&delete ne[He])};ne[He]=t,F?ae(F,[Ne,Et]):Et()},clone(Ne){return Al(Ne,e,n,r)}};return be}function ml(t){if(Kc(t))return t=fi(t),t.children=null,t}function nh(t){return Kc(t)?t.children?t.children[0]:void 0:t}function Il(t,e){t.shapeFlag&6&&t.component?Il(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 Td(t,e=!1,n){let r=[],a=0;for(let l=0;l1)for(let l=0;l!!t.type.__asyncLoader,Kc=t=>t.type.__isKeepAlive;function by(t,e){kd(t,"a",e)}function Ny(t,e){kd(t,"da",e)}function kd(t,e,n=xt){const r=t.__wdc||(t.__wdc=()=>{let a=n;for(;a;){if(a.isDeactivated)return;a=a.parent}return t()});if(Jc(e,r,n),n){let a=n.parent;for(;a&&a.parent;)Kc(a.parent.vnode)&&vy(r,e,n,a),a=a.parent}}function vy(t,e,n,r){const a=Jc(e,t,r,!0);Dd(()=>{uf(r[e],a)},n)}function Jc(t,e,n=xt,r=!1){if(n){const a=n[t]||(n[t]=[]),l=e.__weh||(e.__weh=(...p)=>{if(n.isUnmounted)return;qo(),_o(n);const w=Rn(e,n,t,p);return cs(),So(),w});return r?a.unshift(l):a.push(l),l}}const Rr=t=>(e,n=xt)=>(!va||t==="sp")&&Jc(t,(...r)=>e(...r),n),_y=Rr("bm"),Wd=Rr("m"),xy=Rr("bu"),Oy=Rr("u"),Rd=Rr("bum"),Dd=Rr("um"),Ey=Rr("sp"),Cy=Rr("rtg"),qy=Rr("rtc");function Sy(t,e=xt){Jc("ec",t,e)}function Ri(t,e,n,r){const a=t.dirs,l=e&&e.dirs;for(let p=0;pt?Vd(t)?Of(t)||t.proxy:Tl(t.parent):null,ia=Gt(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=>Tl(t.parent),$root:t=>Tl(t.root),$emit:t=>t.emit,$options:t=>vf(t),$forceUpdate:t=>t.f||(t.f=()=>Nf(t.update)),$nextTick:t=>t.n||(t.n=ey.bind(t.proxy)),$watch:t=>py.bind(t)}),yl=(t,e)=>t!==at&&!t.__isScriptSetup&&Me(t,e),Iy={get({_:t},e){const{ctx:n,setupState:r,data:a,props:l,accessCache:p,type:w,appContext:v}=t;let d;if(e[0]!=="$"){const Y=p[e];if(Y!==void 0)switch(Y){case 1:return r[e];case 2:return a[e];case 4:return n[e];case 3:return l[e]}else{if(yl(r,e))return p[e]=1,r[e];if(a!==at&&Me(a,e))return p[e]=2,a[e];if((d=t.propsOptions[0])&&Me(d,e))return p[e]=3,l[e];if(n!==at&&Me(n,e))return p[e]=4,n[e];kl&&(p[e]=0)}}const A=ia[e];let B,F;if(A)return e==="$attrs"&&yn(t,"get",e),A(t);if((B=w.__cssModules)&&(B=B[e]))return B;if(n!==at&&Me(n,e))return p[e]=4,n[e];if(F=v.config.globalProperties,Me(F,e))return F[e]},set({_:t},e,n){const{data:r,setupState:a,ctx:l}=t;return yl(a,e)?(a[e]=n,!0):r!==at&&Me(r,e)?(r[e]=n,!0):Me(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(l[e]=n,!0)},has({_:{data:t,setupState:e,accessCache:n,ctx:r,appContext:a,propsOptions:l}},p){let w;return!!n[p]||t!==at&&Me(t,p)||yl(e,p)||(w=l[0])&&Me(w,p)||Me(r,p)||Me(ia,p)||Me(a.config.globalProperties,p)},defineProperty(t,e,n){return n.get!=null?t._.accessCache[e]=0:Me(n,"value")&&this.set(t,e,n.value,null),Reflect.defineProperty(t,e,n)}};let kl=!0;function Ty(t){const e=vf(t),n=t.proxy,r=t.ctx;kl=!1,e.beforeCreate&&rh(e.beforeCreate,t,"bc");const{data:a,computed:l,methods:p,watch:w,provide:v,inject:d,created:A,beforeMount:B,mounted:F,beforeUpdate:Y,updated:X,activated:b,deactivated:E,beforeDestroy:N,beforeUnmount:q,destroyed:T,unmounted:ne,render:ye,renderTracked:ae,renderTriggered:be,errorCaptured:Ne,serverPrefetch:Ze,expose:He,inheritAttrs:Ot,components:Et,directives:Qe,filters:$t}=e;if(d&&ky(d,r,null,t.appContext.config.unwrapInjectedRef),p)for(const pe in p){const qe=p[pe];Ie(qe)&&(r[pe]=qe.bind(n))}if(a){const pe=a.call(n,n);ft(pe)&&(t.data=yf(pe))}if(kl=!0,l)for(const pe in l){const qe=l[pe],st=Ie(qe)?qe.bind(n,n):Ie(qe.get)?qe.get.bind(n,n):rr,de=!Ie(qe)&&Ie(qe.set)?qe.set.bind(n):rr,ke=lw({get:st,set:de});Object.defineProperty(r,pe,{enumerable:!0,configurable:!0,get:()=>ke.value,set:Wt=>ke.value=Wt})}if(w)for(const pe in w)Ld(w[pe],r,n,pe);if(v){const pe=Ie(v)?v.call(n):v;Reflect.ownKeys(pe).forEach(qe=>{dy(qe,pe[qe])})}A&&rh(A,t,"c");function ht(pe,qe){Se(qe)?qe.forEach(st=>pe(st.bind(n))):qe&&pe(qe.bind(n))}if(ht(_y,B),ht(Wd,F),ht(xy,Y),ht(Oy,X),ht(by,b),ht(Ny,E),ht(Sy,Ne),ht(qy,ae),ht(Cy,be),ht(Rd,q),ht(Dd,ne),ht(Ey,Ze),Se(He))if(He.length){const pe=t.exposed||(t.exposed={});He.forEach(qe=>{Object.defineProperty(pe,qe,{get:()=>n[qe],set:st=>n[qe]=st})})}else t.exposed||(t.exposed={});ye&&t.render===rr&&(t.render=ye),Ot!=null&&(t.inheritAttrs=Ot),Et&&(t.components=Et),Qe&&(t.directives=Qe)}function ky(t,e,n=rr,r=!1){Se(t)&&(t=Wl(t));for(const a in t){const l=t[a];let p;ft(l)?"default"in l?p=Iu(l.from||a,l.default,!0):p=Iu(l.from||a):p=Iu(l),Jt(p)&&r?Object.defineProperty(e,a,{enumerable:!0,configurable:!0,get:()=>p.value,set:w=>p.value=w}):e[a]=p}}function rh(t,e,n){Rn(Se(t)?t.map(r=>r.bind(e.proxy)):t.bind(e.proxy),e,n)}function Ld(t,e,n,r){const a=r.includes(".")?Ad(n,r):()=>n[r];if(kt(t)){const l=e[t];Ie(l)&&pl(a,l)}else if(Ie(t))pl(a,t.bind(n));else if(ft(t))if(Se(t))t.forEach(l=>Ld(l,e,n,r));else{const l=Ie(t.handler)?t.handler.bind(n):e[t.handler];Ie(l)&&pl(a,l,t)}}function vf(t){const e=t.type,{mixins:n,extends:r}=e,{mixins:a,optionsCache:l,config:{optionMergeStrategies:p}}=t.appContext,w=l.get(e);let v;return w?v=w:!a.length&&!n&&!r?v=e:(v={},a.length&&a.forEach(d=>ju(v,d,p,!0)),ju(v,e,p)),ft(e)&&l.set(e,v),v}function ju(t,e,n,r=!1){const{mixins:a,extends:l}=e;l&&ju(t,l,n,!0),a&&a.forEach(p=>ju(t,p,n,!0));for(const p in e)if(!(r&&p==="expose")){const w=Wy[p]||n&&n[p];t[p]=w?w(t[p],e[p]):e[p]}return t}const Wy={data:ih,props:Pi,emits:Pi,methods:Pi,computed:Pi,beforeCreate:Xt,created:Xt,beforeMount:Xt,mounted:Xt,beforeUpdate:Xt,updated:Xt,beforeDestroy:Xt,beforeUnmount:Xt,destroyed:Xt,unmounted:Xt,activated:Xt,deactivated:Xt,errorCaptured:Xt,serverPrefetch:Xt,components:Pi,directives:Pi,watch:Dy,provide:ih,inject:Ry};function ih(t,e){return e?t?function(){return Gt(Ie(t)?t.call(this,this):t,Ie(e)?e.call(this,this):e)}:e:t}function Ry(t,e){return Pi(Wl(t),Wl(e))}function Wl(t){if(Se(t)){const e={};for(let n=0;n0)&&!(p&16)){if(p&8){const A=t.vnode.dynamicProps;for(let B=0;B{v=!0;const[F,Y]=Md(B,e,!0);Gt(p,F),Y&&w.push(...Y)};!n&&e.mixins.length&&e.mixins.forEach(A),t.extends&&A(t.extends),t.mixins&&t.mixins.forEach(A)}if(!l&&!v)return ft(t)&&r.set(t,js),js;if(Se(l))for(let A=0;A-1,Y[1]=b<0||X-1||Me(Y,"default"))&&w.push(B)}}}const d=[p,w];return ft(t)&&r.set(t,d),d}function sh(t){return t[0]!=="$"}function oh(t){const e=t&&t.toString().match(/^\s*(function|class) (\w+)/);return e?e[2]:t===null?"null":""}function ah(t,e){return oh(t)===oh(e)}function uh(t,e){return Se(e)?e.findIndex(n=>ah(n,t)):Ie(e)&&ah(e,t)?0:-1}const Bd=t=>t[0]==="_"||t==="$stable",_f=t=>Se(t)?t.map(pr):[pr(t)],My=(t,e,n)=>{if(e._n)return e;const r=oy((...a)=>_f(e(...a)),n);return r._c=!1,r},Fd=(t,e,n)=>{const r=t._ctx;for(const a in t){if(Bd(a))continue;const l=t[a];if(Ie(l))e[a]=My(a,l,r);else if(l!=null){const p=_f(l);e[a]=()=>p}}},Ud=(t,e)=>{const n=_f(e);t.slots.default=()=>n},By=(t,e)=>{if(t.vnode.shapeFlag&32){const n=e._;n?(t.slots=Be(e),Uu(e,"_",n)):Fd(e,t.slots={})}else t.slots={},e&&Ud(t,e);Uu(t.slots,Yc,1)},Fy=(t,e,n)=>{const{vnode:r,slots:a}=t;let l=!0,p=at;if(r.shapeFlag&32){const w=e._;w?n&&w===1?l=!1:(Gt(a,e),!n&&w===1&&delete a._):(l=!e.$stable,Fd(e,a)),p=e}else e&&(Ud(t,e),p={default:1});if(l)for(const w in a)!Bd(w)&&!(w in p)&&delete a[w]};function $d(){return{app:null,config:{isNativeTag:cm,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 Uy=0;function $y(t,e){return function(r,a=null){Ie(r)||(r=Object.assign({},r)),a!=null&&!ft(a)&&(a=null);const l=$d(),p=new Set;let w=!1;const v=l.app={_uid:Uy++,_component:r,_props:a,_container:null,_context:l,_instance:null,version:dw,get config(){return l.config},set config(d){},use(d,...A){return p.has(d)||(d&&Ie(d.install)?(p.add(d),d.install(v,...A)):Ie(d)&&(p.add(d),d(v,...A))),v},mixin(d){return l.mixins.includes(d)||l.mixins.push(d),v},component(d,A){return A?(l.components[d]=A,v):l.components[d]},directive(d,A){return A?(l.directives[d]=A,v):l.directives[d]},mount(d,A,B){if(!w){const F=us(r,a);return F.appContext=l,A&&e?e(F,d):t(F,d,B),w=!0,v._container=d,d.__vue_app__=v,Of(F.component)||F.component.proxy}},unmount(){w&&(t(null,v._container),delete v._container.__vue_app__)},provide(d,A){return l.provides[d]=A,v}};return v}}function Dl(t,e,n,r,a=!1){if(Se(t)){t.forEach((F,Y)=>Dl(F,e&&(Se(e)?e[Y]:e),n,r,a));return}if(Tu(r)&&!a)return;const l=r.shapeFlag&4?Of(r.component)||r.component.proxy:r.el,p=a?null:l,{i:w,r:v}=t,d=e&&e.r,A=w.refs===at?w.refs={}:w.refs,B=w.setupState;if(d!=null&&d!==v&&(kt(d)?(A[d]=null,Me(B,d)&&(B[d]=null)):Jt(d)&&(d.value=null)),Ie(v))ui(v,w,12,[p,A]);else{const F=kt(v),Y=Jt(v);if(F||Y){const X=()=>{if(t.f){const b=F?Me(B,v)?B[v]:A[v]:v.value;a?Se(b)&&uf(b,l):Se(b)?b.includes(l)||b.push(l):F?(A[v]=[l],Me(B,v)&&(B[v]=A[v])):(v.value=[l],t.k&&(A[t.k]=v.value))}else F?(A[v]=p,Me(B,v)&&(B[v]=p)):Y&&(v.value=p,t.k&&(A[t.k]=p))};p?(X.id=-1,ln(X,n)):X()}}}const ln=hy;function Qy(t){return jy(t)}function jy(t,e){const n=ym();n.__VUE__=!0;const{insert:r,remove:a,patchProp:l,createElement:p,createText:w,createComment:v,setText:d,setElementText:A,parentNode:B,nextSibling:F,setScopeId:Y=rr,insertStaticContent:X}=t,b=(x,C,W,P=null,H=null,ee=null,$=!1,V=null,re=!!C.dynamicChildren)=>{if(x===C)return;x&&!Bi(x,C)&&(P=fe(x),Wt(x,H,ee,!0),x=null),C.patchFlag===-2&&(re=!1,C.dynamicChildren=null);const{type:K,ref:ce,shapeFlag:oe}=C;switch(K){case Gc:E(x,C,W,P);break;case Ar:N(x,C,W,P);break;case wl:x==null&&q(C,W,P,$);break;case Zn:Et(x,C,W,P,H,ee,$,V,re);break;default:oe&1?ye(x,C,W,P,H,ee,$,V,re):oe&6?Qe(x,C,W,P,H,ee,$,V,re):(oe&64||oe&128)&&K.process(x,C,W,P,H,ee,$,V,re,Mn)}ce!=null&&H&&Dl(ce,x&&x.ref,ee,C||x,!C)},E=(x,C,W,P)=>{if(x==null)r(C.el=w(C.children),W,P);else{const H=C.el=x.el;C.children!==x.children&&d(H,C.children)}},N=(x,C,W,P)=>{x==null?r(C.el=v(C.children||""),W,P):C.el=x.el},q=(x,C,W,P)=>{[x.el,x.anchor]=X(x.children,C,W,P,x.el,x.anchor)},T=({el:x,anchor:C},W,P)=>{let H;for(;x&&x!==C;)H=F(x),r(x,W,P),x=H;r(C,W,P)},ne=({el:x,anchor:C})=>{let W;for(;x&&x!==C;)W=F(x),a(x),x=W;a(C)},ye=(x,C,W,P,H,ee,$,V,re)=>{$=$||C.type==="svg",x==null?ae(C,W,P,H,ee,$,V,re):Ze(x,C,H,ee,$,V,re)},ae=(x,C,W,P,H,ee,$,V)=>{let re,K;const{type:ce,props:oe,shapeFlag:ue,transition:me,dirs:Oe}=x;if(re=x.el=p(x.type,ee,oe&&oe.is,oe),ue&8?A(re,x.children):ue&16&&Ne(x.children,re,null,P,H,ee&&ce!=="foreignObject",$,V),Oe&&Ri(x,null,P,"created"),be(re,x,x.scopeId,$,P),oe){for(const De in oe)De!=="value"&&!Au(De)&&l(re,De,null,oe[De],ee,x.children,P,H,sn);"value"in oe&&l(re,"value",null,oe.value),(K=oe.onVnodeBeforeMount)&&ur(K,P,x)}Oe&&Ri(x,null,P,"beforeMount");const je=(!H||H&&!H.pendingBranch)&&me&&!me.persisted;je&&me.beforeEnter(re),r(re,C,W),((K=oe&&oe.onVnodeMounted)||je||Oe)&&ln(()=>{K&&ur(K,P,x),je&&me.enter(re),Oe&&Ri(x,null,P,"mounted")},H)},be=(x,C,W,P,H)=>{if(W&&Y(x,W),P)for(let ee=0;ee{for(let K=re;K{const V=C.el=x.el;let{patchFlag:re,dynamicChildren:K,dirs:ce}=C;re|=x.patchFlag&16;const oe=x.props||at,ue=C.props||at;let me;W&&Di(W,!1),(me=ue.onVnodeBeforeUpdate)&&ur(me,W,C,x),ce&&Ri(C,x,W,"beforeUpdate"),W&&Di(W,!0);const Oe=H&&C.type!=="foreignObject";if(K?He(x.dynamicChildren,K,V,W,P,Oe,ee):$||qe(x,C,V,null,W,P,Oe,ee,!1),re>0){if(re&16)Ot(V,C,oe,ue,W,P,H);else if(re&2&&oe.class!==ue.class&&l(V,"class",null,ue.class,H),re&4&&l(V,"style",oe.style,ue.style,H),re&8){const je=C.dynamicProps;for(let De=0;De{me&&ur(me,W,C,x),ce&&Ri(C,x,W,"updated")},P)},He=(x,C,W,P,H,ee,$)=>{for(let V=0;V{if(W!==P){if(W!==at)for(const V in W)!Au(V)&&!(V in P)&&l(x,V,W[V],null,$,C.children,H,ee,sn);for(const V in P){if(Au(V))continue;const re=P[V],K=W[V];re!==K&&V!=="value"&&l(x,V,K,re,$,C.children,H,ee,sn)}"value"in P&&l(x,"value",W.value,P.value)}},Et=(x,C,W,P,H,ee,$,V,re)=>{const K=C.el=x?x.el:w(""),ce=C.anchor=x?x.anchor:w("");let{patchFlag:oe,dynamicChildren:ue,slotScopeIds:me}=C;me&&(V=V?V.concat(me):me),x==null?(r(K,W,P),r(ce,W,P),Ne(C.children,W,ce,H,ee,$,V,re)):oe>0&&oe&64&&ue&&x.dynamicChildren?(He(x.dynamicChildren,ue,W,H,ee,$,V),(C.key!=null||H&&C===H.subTree)&&Qd(x,C,!0)):qe(x,C,W,ce,H,ee,$,V,re)},Qe=(x,C,W,P,H,ee,$,V,re)=>{C.slotScopeIds=V,x==null?C.shapeFlag&512?H.ctx.activate(C,W,P,$,re):$t(C,W,P,H,ee,$,re):rn(x,C,re)},$t=(x,C,W,P,H,ee,$)=>{const V=x.component=rw(x,P,H);if(Kc(x)&&(V.ctx.renderer=Mn),sw(V),V.asyncDep){if(H&&H.registerDep(V,ht),!x.el){const re=V.subTree=us(Ar);N(null,re,C,W)}return}ht(V,x,C,W,H,ee,$)},rn=(x,C,W)=>{const P=C.component=x.component;if(cy(x,C,W))if(P.asyncDep&&!P.asyncResolved){pe(P,C,W);return}else P.next=C,ny(P.update),P.update();else C.el=x.el,P.vnode=C},ht=(x,C,W,P,H,ee,$)=>{const V=()=>{if(x.isMounted){let{next:ce,bu:oe,u:ue,parent:me,vnode:Oe}=x,je=ce,De;Di(x,!1),ce?(ce.el=Oe.el,pe(x,ce,$)):ce=Oe,oe&&hl(oe),(De=ce.props&&ce.props.onVnodeBeforeUpdate)&&ur(De,me,ce,Oe),Di(x,!0);const rt=dl(x),he=x.subTree;x.subTree=rt,b(he,rt,B(he.el),fe(he),x,H,ee),ce.el=rt.el,je===null&&ly(x,rt.el),ue&&ln(ue,H),(De=ce.props&&ce.props.onVnodeUpdated)&&ln(()=>ur(De,me,ce,Oe),H)}else{let ce;const{el:oe,props:ue}=C,{bm:me,m:Oe,parent:je}=x,De=Tu(C);if(Di(x,!1),me&&hl(me),!De&&(ce=ue&&ue.onVnodeBeforeMount)&&ur(ce,je,C),Di(x,!0),oe&&Ke){const rt=()=>{x.subTree=dl(x),Ke(oe,x.subTree,x,H,null)};De?C.type.__asyncLoader().then(()=>!x.isUnmounted&&rt()):rt()}else{const rt=x.subTree=dl(x);b(null,rt,W,P,x,H,ee),C.el=rt.el}if(Oe&&ln(Oe,H),!De&&(ce=ue&&ue.onVnodeMounted)){const rt=C;ln(()=>ur(ce,je,rt),H)}(C.shapeFlag&256||je&&Tu(je.vnode)&&je.vnode.shapeFlag&256)&&x.a&&ln(x.a,H),x.isMounted=!0,C=W=P=null}},re=x.effect=new hf(V,()=>Nf(K),x.scope),K=x.update=()=>re.run();K.id=x.uid,Di(x,!0),K()},pe=(x,C,W)=>{C.component=x;const P=x.vnode.props;x.vnode=C,x.next=null,Py(x,C.props,P,W),Fy(x,C.children,W),qo(),eh(),So()},qe=(x,C,W,P,H,ee,$,V,re=!1)=>{const K=x&&x.children,ce=x?x.shapeFlag:0,oe=C.children,{patchFlag:ue,shapeFlag:me}=C;if(ue>0){if(ue&128){de(K,oe,W,P,H,ee,$,V,re);return}else if(ue&256){st(K,oe,W,P,H,ee,$,V,re);return}}me&8?(ce&16&&sn(K,H,ee),oe!==K&&A(W,oe)):ce&16?me&16?de(K,oe,W,P,H,ee,$,V,re):sn(K,H,ee,!0):(ce&8&&A(W,""),me&16&&Ne(oe,W,P,H,ee,$,V,re))},st=(x,C,W,P,H,ee,$,V,re)=>{x=x||js,C=C||js;const K=x.length,ce=C.length,oe=Math.min(K,ce);let ue;for(ue=0;uece?sn(x,H,ee,!0,!1,oe):Ne(C,W,P,H,ee,$,V,re,oe)},de=(x,C,W,P,H,ee,$,V,re)=>{let K=0;const ce=C.length;let oe=x.length-1,ue=ce-1;for(;K<=oe&&K<=ue;){const me=x[K],Oe=C[K]=re?Hr(C[K]):pr(C[K]);if(Bi(me,Oe))b(me,Oe,W,null,H,ee,$,V,re);else break;K++}for(;K<=oe&&K<=ue;){const me=x[oe],Oe=C[ue]=re?Hr(C[ue]):pr(C[ue]);if(Bi(me,Oe))b(me,Oe,W,null,H,ee,$,V,re);else break;oe--,ue--}if(K>oe){if(K<=ue){const me=ue+1,Oe=meue)for(;K<=oe;)Wt(x[K],H,ee,!0),K++;else{const me=K,Oe=K,je=new Map;for(K=Oe;K<=ue;K++){const le=C[K]=re?Hr(C[K]):pr(C[K]);le.key!=null&&je.set(le.key,K)}let De,rt=0;const he=ue-Oe+1;let gn=!1,mi=0;const jt=new Array(he);for(K=0;K=he){Wt(le,H,ee,!0);continue}let Rt;if(le.key!=null)Rt=je.get(le.key);else for(De=Oe;De<=ue;De++)if(jt[De-Oe]===0&&Bi(le,C[De])){Rt=De;break}Rt===void 0?Wt(le,H,ee,!0):(jt[Rt-Oe]=K+1,Rt>=mi?mi=Rt:gn=!0,b(le,C[Rt],W,null,H,ee,$,V,re),rt++)}const ps=gn?Vy(jt):js;for(De=ps.length-1,K=he-1;K>=0;K--){const le=Oe+K,Rt=C[le],te=le+1{const{el:ee,type:$,transition:V,children:re,shapeFlag:K}=x;if(K&6){ke(x.component.subTree,C,W,P);return}if(K&128){x.suspense.move(C,W,P);return}if(K&64){$.move(x,C,W,Mn);return}if($===Zn){r(ee,C,W);for(let oe=0;oeV.enter(ee),H);else{const{leave:oe,delayLeave:ue,afterLeave:me}=V,Oe=()=>r(ee,C,W),je=()=>{oe(ee,()=>{Oe(),me&&me()})};ue?ue(ee,Oe,je):je()}else r(ee,C,W)},Wt=(x,C,W,P=!1,H=!1)=>{const{type:ee,props:$,ref:V,children:re,dynamicChildren:K,shapeFlag:ce,patchFlag:oe,dirs:ue}=x;if(V!=null&&Dl(V,null,W,x,!0),ce&256){C.ctx.deactivate(x);return}const me=ce&1&&ue,Oe=!Tu(x);let je;if(Oe&&(je=$&&$.onVnodeBeforeUnmount)&&ur(je,C,x),ce&6)wn(x.component,W,P);else{if(ce&128){x.suspense.unmount(W,P);return}me&&Ri(x,null,C,"beforeUnmount"),ce&64?x.type.remove(x,C,W,H,Mn,P):K&&(ee!==Zn||oe>0&&oe&64)?sn(K,C,W,!1,!0):(ee===Zn&&oe&384||!H&&ce&16)&&sn(re,C,W),P&&br(x)}(Oe&&(je=$&&$.onVnodeUnmounted)||me)&&ln(()=>{je&&ur(je,C,x),me&&Ri(x,null,C,"unmounted")},W)},br=x=>{const{type:C,el:W,anchor:P,transition:H}=x;if(C===Zn){ds(W,P);return}if(C===wl){ne(x);return}const ee=()=>{a(W),H&&!H.persisted&&H.afterLeave&&H.afterLeave()};if(x.shapeFlag&1&&H&&!H.persisted){const{leave:$,delayLeave:V}=H,re=()=>$(W,ee);V?V(x.el,ee,re):re()}else ee()},ds=(x,C)=>{let W;for(;x!==C;)W=F(x),a(x),x=W;a(C)},wn=(x,C,W)=>{const{bum:P,scope:H,update:ee,subTree:$,um:V}=x;P&&hl(P),H.stop(),ee&&(ee.active=!1,Wt($,x,C,W)),V&&ln(V,C),ln(()=>{x.isUnmounted=!0},C),C&&C.pendingBranch&&!C.isUnmounted&&x.asyncDep&&!x.asyncResolved&&x.suspenseId===C.pendingId&&(C.deps--,C.deps===0&&C.resolve())},sn=(x,C,W,P=!1,H=!1,ee=0)=>{for(let $=ee;$x.shapeFlag&6?fe(x.component.subTree):x.shapeFlag&128?x.suspense.next():F(x.anchor||x.el),Pe=(x,C,W)=>{x==null?C._vnode&&Wt(C._vnode,null,null,!0):b(C._vnode||null,x,C,null,null,null,W),eh(),Od(),C._vnode=x},Mn={p:b,um:Wt,m:ke,r:br,mt:$t,mc:Ne,pc:qe,pbc:He,n:fe,o:t};let Qt,Ke;return e&&([Qt,Ke]=e(Mn)),{render:Pe,hydrate:Qt,createApp:$y(Pe,Qt)}}function Di({effect:t,update:e},n){t.allowRecurse=e.allowRecurse=n}function Qd(t,e,n=!1){const r=t.children,a=e.children;if(Se(r)&&Se(a))for(let l=0;l>1,t[n[w]]0&&(e[r]=n[l-1]),n[l]=r)}}for(l=n.length,p=n[l-1];l-- >0;)n[l]=p,p=e[p];return n}const zy=t=>t.__isTeleport,Zn=Symbol(void 0),Gc=Symbol(void 0),Ar=Symbol(void 0),wl=Symbol(void 0),sa=[];let nr=null;function Hy(t=!1){sa.push(nr=t?null:[])}function Ky(){sa.pop(),nr=sa[sa.length-1]||null}let ba=1;function ch(t){ba+=t}function Jy(t){return t.dynamicChildren=ba>0?nr||js:null,Ky(),ba>0&&nr&&nr.push(t),t}function Gy(t,e,n,r,a,l){return Jy(_t(t,e,n,r,a,l,!0))}function Yy(t){return t?t.__v_isVNode===!0:!1}function Bi(t,e){return t.type===e.type&&t.key===e.key}const Yc="__vInternal",jd=({key:t})=>t??null,ku=({ref:t,ref_key:e,ref_for:n})=>t!=null?kt(t)||Jt(t)||Ie(t)?{i:tr,r:t,k:e,f:!!n}:t:null;function _t(t,e=null,n=null,r=0,a=null,l=t===Zn?0:1,p=!1,w=!1){const v={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&jd(e),ref:e&&ku(e),scopeId:qd,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:r,dynamicProps:a,dynamicChildren:null,appContext:null,ctx:tr};return w?(xf(v,n),l&128&&t.normalize(v)):n&&(v.shapeFlag|=kt(n)?8:16),ba>0&&!p&&nr&&(v.patchFlag>0||l&6)&&v.patchFlag!==32&&nr.push(v),v}const us=Xy;function Xy(t,e=null,n=null,r=0,a=null,l=!1){if((!t||t===Ay)&&(t=Ar),Yy(t)){const w=fi(t,e,!0);return n&&xf(w,n),ba>0&&!l&&nr&&(w.shapeFlag&6?nr[nr.indexOf(t)]=w:nr.push(w)),w.patchFlag|=-2,w}if(cw(t)&&(t=t.__vccOpts),e){e=Zy(e);let{class:w,style:v}=e;w&&!kt(w)&&(e.class=of(w)),ft(v)&&(md(v)&&!Se(v)&&(v=Gt({},v)),e.style=sf(v))}const p=kt(t)?1:fy(t)?128:zy(t)?64:ft(t)?4:Ie(t)?2:0;return _t(t,e,n,r,a,p,l,!0)}function Zy(t){return t?md(t)||Yc in t?Gt({},t):t:null}function fi(t,e,n=!1){const{props:r,ref:a,patchFlag:l,children:p}=t,w=e?ew(r||{},e):r;return{__v_isVNode:!0,__v_skip:!0,type:t.type,props:w,key:w&&jd(w),ref:e&&e.ref?n&&a?Se(a)?a.concat(ku(e)):[a,ku(e)]:ku(e):a,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:p,target:t.target,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==Zn?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&&fi(t.ssContent),ssFallback:t.ssFallback&&fi(t.ssFallback),el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce}}function Na(t=" ",e=0){return us(Gc,null,t,e)}function pr(t){return t==null||typeof t=="boolean"?us(Ar):Se(t)?us(Zn,null,t.slice()):typeof t=="object"?Hr(t):us(Gc,null,String(t))}function Hr(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:fi(t)}function xf(t,e){let n=0;const{shapeFlag:r}=t;if(e==null)e=null;else if(Se(e))n=16;else if(typeof e=="object")if(r&65){const a=e.default;a&&(a._c&&(a._d=!1),xf(t,a()),a._c&&(a._d=!0));return}else{n=32;const a=e._;!a&&!(Yc in e)?e._ctx=tr:a===3&&tr&&(tr.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Ie(e)?(e={default:e,_ctx:tr},n=32):(e=String(e),r&64?(n=16,e=[Na(e)]):n=8);t.children=e,t.shapeFlag|=n}function ew(...t){const e={};for(let n=0;nxt||tr,_o=t=>{xt=t,t.scope.on()},cs=()=>{xt&&xt.scope.off(),xt=null};function Vd(t){return t.vnode.shapeFlag&4}let va=!1;function sw(t,e=!1){va=e;const{props:n,children:r}=t.vnode,a=Vd(t);Ly(t,n,a,e),By(t,r);const l=a?ow(t,e):void 0;return va=!1,l}function ow(t,e){const n=t.type;t.accessCache=Object.create(null),t.proxy=yd(new Proxy(t.ctx,Iy));const{setup:r}=n;if(r){const a=t.setupContext=r.length>1?uw(t):null;_o(t),qo();const l=ui(r,t,0,[t.props,a]);if(So(),cs(),ed(l)){if(l.then(cs,cs),e)return l.then(p=>{lh(t,p,e)}).catch(p=>{zc(p,t,0)});t.asyncDep=l}else lh(t,l,e)}else zd(t,e)}function lh(t,e,n){Ie(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:ft(e)&&(t.setupState=Nd(e)),zd(t,n)}let fh;function zd(t,e,n){const r=t.type;if(!t.render){if(!e&&fh&&!r.render){const a=r.template||vf(t).template;if(a){const{isCustomElement:l,compilerOptions:p}=t.appContext.config,{delimiters:w,compilerOptions:v}=r,d=Gt(Gt({isCustomElement:l,delimiters:w},p),v);r.render=fh(a,d)}}t.render=r.render||rr}_o(t),qo(),Ty(t),So(),cs()}function aw(t){return new Proxy(t.attrs,{get(e,n){return yn(t,"get","$attrs"),e[n]}})}function uw(t){const e=r=>{t.exposed=r||{}};let n;return{get attrs(){return n||(n=aw(t))},slots:t.slots,emit:t.emit,expose:e}}function Of(t){if(t.exposed)return t.exposeProxy||(t.exposeProxy=new Proxy(Nd(yd(t.exposed)),{get(e,n){if(n in e)return e[n];if(n in ia)return ia[n](t)},has(e,n){return n in e||n in ia}}))}function cw(t){return Ie(t)&&"__vccOpts"in t}const lw=(t,e)=>Xm(t,e,va),fw=Symbol(""),hw=()=>Iu(fw),dw="3.2.47",pw="http://www.w3.org/2000/svg",Fi=typeof document<"u"?document:null,hh=Fi&&Fi.createElement("template"),mw={insert:(t,e,n)=>{e.insertBefore(t,n||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,n,r)=>{const a=e?Fi.createElementNS(pw,t):Fi.createElement(t,n?{is:n}:void 0);return t==="select"&&r&&r.multiple!=null&&a.setAttribute("multiple",r.multiple),a},createText:t=>Fi.createTextNode(t),createComment:t=>Fi.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Fi.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,n,r,a,l){const p=n?n.previousSibling:e.lastChild;if(a&&(a===l||a.nextSibling))for(;e.insertBefore(a.cloneNode(!0),n),!(a===l||!(a=a.nextSibling)););else{hh.innerHTML=r?`${t}`:t;const w=hh.content;if(r){const v=w.firstChild;for(;v.firstChild;)w.appendChild(v.firstChild);w.removeChild(v)}e.insertBefore(w,n)}return[p?p.nextSibling:e.firstChild,n?n.previousSibling:e.lastChild]}};function yw(t,e,n){const r=t._vtc;r&&(e=(e?[e,...r]:[...r]).join(" ")),e==null?t.removeAttribute("class"):n?t.setAttribute("class",e):t.className=e}function ww(t,e,n){const r=t.style,a=kt(n);if(n&&!a){if(e&&!kt(e))for(const l in e)n[l]==null&&Ll(r,l,"");for(const l in n)Ll(r,l,n[l])}else{const l=r.display;a?e!==n&&(r.cssText=n):e&&t.removeAttribute("style"),"_vod"in t&&(r.display=l)}}const dh=/\s*!important$/;function Ll(t,e,n){if(Se(n))n.forEach(r=>Ll(t,e,r));else if(n==null&&(n=""),e.startsWith("--"))t.setProperty(e,n);else{const r=gw(t,e);dh.test(n)?t.setProperty(Co(r),n.replace(dh,""),"important"):t[r]=n}}const ph=["Webkit","Moz","ms"],gl={};function gw(t,e){const n=gl[e];if(n)return n;let r=No(e);if(r!=="filter"&&r in t)return gl[e]=r;r=rd(r);for(let a=0;abl||(Ew.then(()=>bl=0),bl=Date.now());function qw(t,e){const n=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=n.attached)return;Rn(Sw(r,n.value),e,5,[r])};return n.value=t,n.attached=Cw(),n}function Sw(t,e){if(Se(e)){const n=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{n.call(t),t._stopped=!0},e.map(r=>a=>!a._stopped&&r&&r(a))}else return e}const wh=/^on[a-z]/,Aw=(t,e,n,r,a=!1,l,p,w,v)=>{e==="class"?yw(t,r,a):e==="style"?ww(t,n,r):$c(e)?af(e)||xw(t,e,n,r,p):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Iw(t,e,r,a))?Nw(t,e,r,l,p,w,v):(e==="true-value"?t._trueValue=r:e==="false-value"&&(t._falseValue=r),bw(t,e,r,a))};function Iw(t,e,n,r){return r?!!(e==="innerHTML"||e==="textContent"||e in t&&wh.test(e)&&Ie(n)):e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA"||wh.test(e)&&kt(n)?!1:e in t}const Tw={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};wy.props;const kw=Gt({patchProp:Aw},mw);let gh;function Ww(){return gh||(gh=Qy(kw))}const Rw=(...t)=>{const e=Ww().createApp(...t),{mount:n}=e;return e.mount=r=>{const a=Dw(r);if(!a)return;const l=e._component;!Ie(l)&&!l.render&&!l.template&&(l.template=a.innerHTML),a.innerHTML="";const p=n(a,!1,a instanceof SVGElement);return a instanceof Element&&(a.removeAttribute("v-cloak"),a.setAttribute("data-v-app","")),p},e};function Dw(t){return kt(t)?document.querySelector(t):t}function Ks(t){return typeof t>"u"||t===void 0}function Dn(t){return typeof t=="string"}function Lw(t){return typeof t=="number"}function Hd(t){return typeof t=="boolean"}function Kd(t){return t===null}function Pw(t){return t instanceof Date}function Mw(t){return typeof t=="bigint"}function Ln(t){return typeof t=="function"}function wr(t){return typeof t=="object"&&t!==null}function m(t){return Object.freeze(t)}function Xa(t){return Array.isArray(t)}function xo(t){return t}const vt=m({is(t){return t.kind==="AlterTableNode"},create(t){return m({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return m({...t,...e})},cloneWithColumnAlteration(t,e){return m({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),ct=m({is(t){return t.kind==="IdentifierNode"},create(t){return m({kind:"IdentifierNode",name:t})}}),Vr=m({is(t){return t.kind==="CreateIndexNode"},create(t){return m({kind:"CreateIndexNode",name:ct.create(t)})},cloneWith(t,e){return m({...t,...e})},cloneWithColumns(t,e){return m({...t,columns:[...t.columns||[],...e]})}}),Jd=m({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return m({kind:"CreateSchemaNode",schema:ct.create(t),...e})},cloneWith(t,e){return m({...t,...e})}}),Bw=["preserve rows","delete rows","drop"],jn=m({is(t){return t.kind==="CreateTableNode"},create(t){return m({kind:"CreateTableNode",table:t,columns:m([])})},cloneWithColumn(t,e){return m({...t,columns:m([...t.columns,e])})},cloneWithConstraint(t,e){return m({...t,constraints:t.constraints?m([...t.constraints,e]):m([e])})},cloneWithFrontModifier(t,e){return m({...t,frontModifiers:t.frontModifiers?m([...t.frontModifiers,e]):m([e])})},cloneWithEndModifier(t,e){return m({...t,endModifiers:t.endModifiers?m([...t.endModifiers,e]):m([e])})},cloneWith(t,e){return m({...t,...e})}}),hi=m({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return m({kind:"SchemableIdentifierNode",identifier:ct.create(t)})},createWithSchema(t,e){return m({kind:"SchemableIdentifierNode",schema:ct.create(t),identifier:ct.create(e)})}}),Wu=m({is(t){return t.kind==="DropIndexNode"},create(t,e){return m({kind:"DropIndexNode",name:hi.create(t),...e})},cloneWith(t,e){return m({...t,...e})}}),Pl=m({is(t){return t.kind==="DropSchemaNode"},create(t,e){return m({kind:"DropSchemaNode",schema:ct.create(t),...e})},cloneWith(t,e){return m({...t,...e})}}),Ml=m({is(t){return t.kind==="DropTableNode"},create(t,e){return m({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return m({...t,...e})}}),pi=m({is(t){return t.kind==="AliasNode"},create(t,e){return m({kind:"AliasNode",node:t,alias:e})}}),ci=m({is(t){return t.kind==="TableNode"},create(t){return m({kind:"TableNode",table:hi.create(t)})},createWithSchema(t,e){return m({kind:"TableNode",table:hi.createWithSchema(t,e)})}});function Pn(t){return wr(t)&&Ln(t.toOperationNode)}function Ef(t){return wr(t)&&"expressionType"in t&&Pn(t)}function Fw(t){return wr(t)&&"expression"in t&&Dn(t.alias)&&Pn(t)}const vr=m({is(t){return t.kind==="SelectModifierNode"},create(t){return m({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return m({kind:"SelectModifierNode",rawModifier:t})}}),ls=m({is(t){return t.kind==="AndNode"},create(t,e){return m({kind:"AndNode",left:t,right:e})}}),fs=m({is(t){return t.kind==="OrNode"},create(t,e){return m({kind:"OrNode",left:t,right:e})}}),Nl=m({is(t){return t.kind==="OnNode"},create(t){return m({kind:"OnNode",on:t})},cloneWithOperation(t,e,n){return m({...t,on:e==="And"?ls.create(t.on,n):fs.create(t.on,n)})}}),oa=m({is(t){return t.kind==="JoinNode"},create(t,e){return m({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,n){return m({kind:"JoinNode",joinType:t,table:e,on:Nl.create(n)})},cloneWithOn(t,e){return m({...t,on:t.on?Nl.cloneWithOperation(t.on,"And",e):Nl.create(e)})}}),Cf=m({is(t){return t.kind==="BinaryOperationNode"},create(t,e,n){return m({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:n})}}),Gd=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp"],Uw=["+","-","*","/","%","^","&","|","#","<<",">>"],Yd=["->","->>"],Xd=[...Gd,...Uw,"&&","||"],$w=["exists","not exists"],Qw=["not","-",...$w],jw=[...Xd,...Yd,...Qw],_a=m({is(t){return t.kind==="OperatorNode"},create(t){return m({kind:"OperatorNode",operator:t})}});function Vw(t){return Dn(t)&&Xd.includes(t)}function zw(t){return Dn(t)&&Gd.includes(t)}function bh(t){return Dn(t)&&Yd.includes(t)}const yt=m({is(t){return t.kind==="ColumnNode"},create(t){return m({kind:"ColumnNode",column:ct.create(t)})}}),qf=m({is(t){return t.kind==="SelectAllNode"},create(){return m({kind:"SelectAllNode"})}}),Xc=m({is(t){return t.kind==="ReferenceNode"},create(t,e){return m({kind:"ReferenceNode",table:e,column:t})},createSelectAll(t){return m({kind:"ReferenceNode",table:t,column:qf.create()})}}),Hw=m({is(t){return t.kind==="OrderByItemNode"},create(t,e){return m({kind:"OrderByItemNode",orderBy:t,direction:e})}}),tn=m({is(t){return t.kind==="RawNode"},create(t,e){return m({kind:"RawNode",sqlFragments:m(t),parameters:m(e)})},createWithSql(t){return tn.create([t],[])},createWithChild(t){return tn.create(["",""],[t])},createWithChildren(t){return tn.create(new Array(t.length+1).fill(""),t)}});function Kw(t){return t==="asc"||t==="desc"}function Zc(t,e){return Hw.create(Jw(t),Gw(e))}function Jw(t){return kr(t)}function Gw(t){if(t)return t==="asc"||t==="desc"?tn.createWithSql(t):t.toOperationNode()}const Bl=m({is(t){return t.kind==="JSONReferenceNode"},create(t,e){return m({kind:"JSONReferenceNode",reference:t,traversal:e})},cloneWithTraversal(t,e){return m({...t,traversal:e})}}),Zd=m({is(t){return t.kind==="JSONOperatorChainNode"},create(t){return m({kind:"JSONOperatorChainNode",operator:t,values:m([])})},cloneWithValue(t,e){return m({...t,values:m([...t.values,e])})}}),Fl=m({is(t){return t.kind==="JSONPathNode"},create(t){return m({kind:"JSONPathNode",inOperator:t,pathLegs:m([])})},cloneWithLeg(t,e){return m({...t,pathLegs:m([...t.pathLegs,e])})}});function ep(t){return Dn(t)?hs(t):t.toOperationNode()}function xa(t){return Xa(t)?t.map(e=>kr(e)):[kr(t)]}function kr(t){return rl(t)?nl(t):ep(t)}function Yw(t,e){const n=hs(t);if(bh(e))return Bl.create(n,Zd.create(_a.create(e)));const r=e.slice(0,-1);if(bh(r))return Bl.create(n,Fl.create(_a.create(r)));throw new Error(`Invalid JSON operator: ${e}`)}function hs(t){const e=".";if(!t.includes(e))return Xc.create(yt.create(t));const n=t.split(e).map(Sf);if(n.length===3)return Zw(n);if(n.length===2)return eg(n);throw new Error(`invalid column reference ${t}`)}function Xw(t){const e=" as ";if(t.includes(e)){const[n,r]=t.split(e).map(Sf);return pi.create(hs(n),ct.create(r))}else return hs(t)}function tp(t){return yt.create(t)}function Nh(t){const e=" ";if(t.includes(e)){const[n,r]=t.split(e).map(Sf);if(!Kw(r))throw new Error(`invalid order direction "${r}" next to "${n}"`);return Zc(n,r)}else return tp(t)}function Zw(t){const[e,n,r]=t;return Xc.create(yt.create(r),ci.createWithSchema(e,n))}function eg(t){const[e,n]=t;return Xc.create(yt.create(n),ci.create(e))}function Sf(t){return t.trim()}const np=m({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return m({kind:"PrimitiveValueListNode",values:m([...t])})}}),Af=m({is(t){return t.kind==="ValueListNode"},create(t){return m({kind:"ValueListNode",values:m(t)})}}),ir=m({is(t){return t.kind==="ValueNode"},create(t){return m({kind:"ValueNode",value:t})},createImmediate(t){return m({kind:"ValueNode",value:t,immediate:!0})}});function rp(t){return Xa(t)?tg(t):Ir(t)}function Ir(t){return rl(t)?nl(t):ir.create(t)}function tg(t){return t.some(rl)?Af.create(t.map(e=>Ir(e))):np.create(t)}function nn(t){if(t.length>1&&!op(t[1]))throw new Error(`invalid comparison operator ${JSON.stringify(t[1])}`);return ip(t)}function ip(t){if(t.length===3)return Ru(t[0],t[1],t[2]);if(t.length===1)return og(t[0]);throw new Error(`invalid arguments: ${JSON.stringify(t)}`)}function Ru(t,e,n){if(!sp(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return rg(e)&&ig(n)?sg(t,e,n):Cf.create(kr(t),If(e),rp(n))}function Wr(t,e,n){if(!op(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return ng(t,e,n)}function ng(t,e,n){if(!sp(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Cf.create(kr(t),If(e),kr(n))}function sp(t){return Vw(t)||Ef(t)}function op(t){return zw(t)||Ef(t)}function rg(t){return t==="is"||t==="is not"}function ig(t){return Kd(t)||Hd(t)}function sg(t,e,n){return Cf.create(kr(t),If(e),ir.createImmediate(n))}function If(t){if(Dn(t)&&jw.includes(t))return _a.create(t);if(Pn(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function og(t){return Ln(t)?t(Lf()).toOperationNode():Pn(t)?t.toOperationNode():ir.create(t)}const Oo=m({is(t){return t.kind==="OrderByNode"},create(t){return m({kind:"OrderByNode",items:m([t])})},cloneWithItem(t,e){return m({...t,items:m([...t.items,e])})}}),vh=m({is(t){return t.kind==="PartitionByNode"},create(t){return m({kind:"PartitionByNode",items:m(t)})},cloneWithItems(t,e){return m({...t,items:m([...t.items,...e])})}}),Ul=m({is(t){return t.kind==="OverNode"},create(){return m({kind:"OverNode"})},cloneWithOrderByItem(t,e){return m({...t,orderBy:t.orderBy?Oo.cloneWithItem(t.orderBy,e):Oo.create(e)})},cloneWithPartitionByItems(t,e){return m({...t,partitionBy:t.partitionBy?vh.cloneWithItems(t.partitionBy,e):vh.create(e)})}}),Vu=m({is(t){return t.kind==="FromNode"},create(t){return m({kind:"FromNode",froms:m(t)})},cloneWithFroms(t,e){return m({...t,froms:m([...t.froms,...e])})}}),_h=m({is(t){return t.kind==="GroupByNode"},create(t){return m({kind:"GroupByNode",items:m(t)})},cloneWithItems(t,e){return m({...t,items:m([...t.items,...e])})}}),xh=m({is(t){return t.kind==="HavingNode"},create(t){return m({kind:"HavingNode",having:t})},cloneWithOperation(t,e,n){return m({...t,having:e==="And"?ls.create(t.having,n):fs.create(t.having,n)})}}),Fe=m({is(t){return t.kind==="SelectQueryNode"},create(t,e){return m({kind:"SelectQueryNode",from:Vu.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return m({...t,selections:t.selections?m([...t.selections,...e]):m(e)})},cloneWithDistinctOn(t,e){return m({...t,distinctOn:t.distinctOn?m([...t.distinctOn,...e]):m(e)})},cloneWithFrontModifier(t,e){return m({...t,frontModifiers:t.frontModifiers?m([...t.frontModifiers,e]):m([e])})},cloneWithEndModifier(t,e){return m({...t,endModifiers:t.endModifiers?m([...t.endModifiers,e]):m([e])})},cloneWithOrderByItem(t,e){return m({...t,orderBy:t.orderBy?Oo.cloneWithItem(t.orderBy,e):Oo.create(e)})},cloneWithGroupByItems(t,e){return m({...t,groupBy:t.groupBy?_h.cloneWithItems(t.groupBy,e):_h.create(e)})},cloneWithLimit(t,e){return m({...t,limit:e})},cloneWithOffset(t,e){return m({...t,offset:e})},cloneWithHaving(t,e){return m({...t,having:t.having?xh.cloneWithOperation(t.having,"And",e):xh.create(e)})},cloneWithSetOperation(t,e){return m({...t,setOperations:t.setOperations?m([...t.setOperations,e]):m([e])})},cloneWithoutSelections(t){return m({...t,selections:[]})},cloneWithoutLimit(t){return m({...t,limit:void 0})},cloneWithoutOffset(t){return m({...t,offset:void 0})},cloneWithoutOrderBy(t){return m({...t,orderBy:void 0})}});function $e(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}var Hn;const ca=class ca{constructor(e){D(this,Hn,void 0);z(this,Hn,m(e))}on(...e){return new ca({...i(this,Hn),joinNode:oa.cloneWithOn(i(this,Hn).joinNode,nn(e))})}onRef(e,n,r){return new ca({...i(this,Hn),joinNode:oa.cloneWithOn(i(this,Hn).joinNode,Wr(e,n,r))})}onTrue(){return new ca({...i(this,Hn),joinNode:oa.cloneWithOn(i(this,Hn).joinNode,tn.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return i(this,Hn).joinNode}};Hn=new WeakMap;let zu=ca;$e(zu,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const ag=m({is(t){return t.kind==="PartitionByItemNode"},create(t){return m({kind:"PartitionByItemNode",partitionBy:t})}});function ug(t){return xa(t).map(ag.create)}var Vi;const mc=class mc{constructor(e){D(this,Vi,void 0);z(this,Vi,m(e))}orderBy(e,n){return new mc({overNode:Ul.cloneWithOrderByItem(i(this,Vi).overNode,Zc(e,n))})}partitionBy(e){return new mc({overNode:Ul.cloneWithPartitionByItems(i(this,Vi).overNode,ug(e))})}$call(e){return e(this)}toOperationNode(){return i(this,Vi).overNode}};Vi=new WeakMap;let Hu=mc;$e(Hu,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const aa=m({is(t){return t.kind==="SelectionNode"},create(t){return m({kind:"SelectionNode",selection:t})},createSelectAll(){return m({kind:"SelectionNode",selection:qf.create()})},createSelectAllFromTable(t){return m({kind:"SelectionNode",selection:Xc.createSelectAll(t)})}});var Js;class cg{constructor(e){D(this,Js,void 0);z(this,Js,e)}get dynamicReference(){return i(this,Js)}get refType(){}toOperationNode(){return ep(i(this,Js))}}Js=new WeakMap;function lg(t){return wr(t)&&Pn(t)&&Dn(t.dynamicReference)}function Za(t){return Ln(t)?Za(t(Ao())):Xa(t)?t.map(e=>Oh(e)):[Oh(t)]}function Oh(t){return Dn(t)?aa.create(Xw(t)):lg(t)?aa.create(t.toOperationNode()):aa.create(gp(t))}function eu(t){return t?Array.isArray(t)?t.map(Eh):[Eh(t)]:[aa.createSelectAll()]}function Eh(t){if(Dn(t))return aa.createSelectAllFromTable(mn(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const fg=m({is(t){return t.kind==="ValuesNode"},create(t){return m({kind:"ValuesNode",values:m(t)})}}),hg=m({is(t){return t.kind==="DefaultInsertValueNode"},create(){return m({kind:"DefaultInsertValueNode"})}});function dg(t){const e=Ln(t)?t(Ao()):t,n=Xa(e)?e:m([e]);return pg(n)}function pg(t){const e=mg(t);return[m([...e.keys()].map(yt.create)),fg.create(t.map(n=>yg(n,e)))]}function mg(t){const e=new Map;for(const n of t){const r=Object.keys(n);for(const a of r)!e.has(a)&&n[a]!==void 0&&e.set(a,e.size)}return e}function yg(t,e){const n=Object.keys(t),r=Array.from({length:e.size});let a=!1;for(const p of n){const w=e.get(p);if(Ks(w))continue;const v=t[p];(Ks(v)||rl(v))&&(a=!0),r[w]=v}if(n.lengthKs(w)?p:Ir(w)))}return np.create(r)}const mr=m({is(t){return t.kind==="InsertQueryNode"},create(t,e,n){return m({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:n})},cloneWith(t,e){return m({...t,...e})}}),Ku=m({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return m({kind:"UpdateQueryNode",table:t,...e&&{with:e}})},cloneWithFromItems(t,e){return m({...t,from:t.from?Vu.cloneWithFroms(t.from,e):Vu.create(e)})},cloneWithUpdates(t,e){return m({...t,updates:t.updates?m([...t.updates,...e]):e})}}),Ch=m({is(t){return t.kind==="UsingNode"},create(t){return m({kind:"UsingNode",tables:m(t)})},cloneWithTables(t,e){return m({...t,tables:m([...t.tables,...e])})}}),ua=m({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return m({kind:"DeleteQueryNode",from:Vu.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return m({...t,orderBy:t.orderBy?Oo.cloneWithItem(t.orderBy,e):Oo.create(e)})},cloneWithLimit(t,e){return m({...t,limit:e})},cloneWithUsing(t,e){return m({...t,using:t.using!==void 0?Ch.cloneWithTables(t.using,e):Ch.create(e)})}}),hn=m({is(t){return t.kind==="WhereNode"},create(t){return m({kind:"WhereNode",where:t})},cloneWithOperation(t,e,n){return m({...t,where:e==="And"?ls.create(t.where,n):fs.create(t.where,n)})}}),qh=m({is(t){return t.kind==="ReturningNode"},create(t){return m({kind:"ReturningNode",selections:m(t)})},cloneWithSelections(t,e){return m({...t,selections:t.selections?m([...t.selections,...e]):m(e)})}}),wg=m({is(t){return t.kind==="ExplainNode"},create(t,e){return m({kind:"ExplainNode",format:t,options:e})}}),Re=m({is(t){return Fe.is(t)||mr.is(t)||Ku.is(t)||ua.is(t)},cloneWithWhere(t,e){return m({...t,where:t.where?hn.cloneWithOperation(t.where,"And",e):hn.create(e)})},cloneWithJoin(t,e){return m({...t,joins:t.joins?m([...t.joins,e]):m([e])})},cloneWithReturning(t,e){return m({...t,returning:t.returning?qh.cloneWithSelections(t.returning,e):qh.create(e)})},cloneWithoutWhere(t){return m({...t,where:void 0})},cloneWithExplain(t,e,n){return m({...t,explain:wg.create(e,n==null?void 0:n.toOperationNode())})}}),gg=m({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return m({kind:"ColumnUpdateNode",column:t,value:e})}});function Tf(t){const e=Ln(t)?t(Ao()):t;return Object.entries(e).filter(([n,r])=>r!==void 0).map(([n,r])=>gg.create(yt.create(n),Ir(r)))}const bg=m({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return m({kind:"OnDuplicateKeyNode",updates:t})}});class Ng{constructor(e,n){ge(this,"insertId");ge(this,"numInsertedOrUpdatedRows");this.insertId=e,this.numInsertedOrUpdatedRows=n}}class el extends Error{constructor(n){super("no result");ge(this,"node");this.node=n}}function tl(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const En=m({is(t){return t.kind==="OnConflictNode"},create(){return m({kind:"OnConflictNode"})},cloneWith(t,e){return m({...t,...e})},cloneWithIndexWhere(t,e){return m({...t,indexWhere:t.indexWhere?hn.cloneWithOperation(t.indexWhere,"And",e):hn.create(e)})},cloneWithIndexOrWhere(t,e){return m({...t,indexWhere:t.indexWhere?hn.cloneWithOperation(t.indexWhere,"Or",e):hn.create(e)})},cloneWithUpdateWhere(t,e){return m({...t,updateWhere:t.updateWhere?hn.cloneWithOperation(t.updateWhere,"And",e):hn.create(e)})},cloneWithUpdateOrWhere(t,e){return m({...t,updateWhere:t.updateWhere?hn.cloneWithOperation(t.updateWhere,"Or",e):hn.create(e)})},cloneWithoutIndexWhere(t){return m({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return m({...t,updateWhere:void 0})}});var et;const Or=class Or{constructor(e){D(this,et,void 0);z(this,et,m(e))}column(e){const n=yt.create(e);return new Or({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{columns:i(this,et).onConflictNode.columns?m([...i(this,et).onConflictNode.columns,n]):m([n])})})}columns(e){const n=e.map(yt.create);return new Or({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{columns:i(this,et).onConflictNode.columns?m([...i(this,et).onConflictNode.columns,...n]):m(n)})})}constraint(e){return new Or({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{constraint:ct.create(e)})})}expression(e){return new Or({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new Or({...i(this,et),onConflictNode:En.cloneWithIndexWhere(i(this,et).onConflictNode,nn(e))})}whereRef(e,n,r){return new Or({...i(this,et),onConflictNode:En.cloneWithIndexWhere(i(this,et).onConflictNode,Wr(e,n,r))})}clearWhere(){return new Or({...i(this,et),onConflictNode:En.cloneWithoutIndexWhere(i(this,et).onConflictNode)})}doNothing(){return new ap({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Gu({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{updates:Tf(e)})})}$call(e){return e(this)}};et=new WeakMap;let Ju=Or;$e(Ju,"don't await OnConflictBuilder instances.");var Ta;class ap{constructor(e){D(this,Ta,void 0);z(this,Ta,m(e))}toOperationNode(){return i(this,Ta).onConflictNode}}Ta=new WeakMap;$e(ap,"don't await OnConflictDoNothingBuilder instances.");var Kn;const la=class la{constructor(e){D(this,Kn,void 0);z(this,Kn,m(e))}where(...e){return new la({...i(this,Kn),onConflictNode:En.cloneWithUpdateWhere(i(this,Kn).onConflictNode,nn(e))})}whereRef(e,n,r){return new la({...i(this,Kn),onConflictNode:En.cloneWithUpdateWhere(i(this,Kn).onConflictNode,Wr(e,n,r))})}clearWhere(){return new la({...i(this,Kn),onConflictNode:En.cloneWithoutUpdateWhere(i(this,Kn).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return i(this,Kn).onConflictNode}};Kn=new WeakMap;let Gu=la;$e(Gu,"don't await OnConflictUpdateBuilder instances.");var Te;const zt=class zt{constructor(e){D(this,Te,void 0);z(this,Te,m(e))}values(e){const[n,r]=dg(e);return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{columns:n,values:r})})}columns(e){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{columns:m(e.map(yt.create))})})}expression(e){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{values:nl(e)})})}ignore(){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{ignore:!0})})}onConflict(e){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{onConflict:e(new Ju({onConflictNode:En.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{onDuplicateKey:bg.create(Tf(e))})})}returning(e){return new zt({...i(this,Te),queryNode:Re.cloneWithReturning(i(this,Te).queryNode,Za(e))})}returningAll(){return new zt({...i(this,Te),queryNode:Re.cloneWithReturning(i(this,Te).queryNode,eu())})}$call(e){return e(this)}$if(e,n){return e?n(this):new zt({...i(this,Te)})}$castTo(){return new zt(i(this,Te))}$narrowType(){return new zt(i(this,Te))}$assertType(){return new zt(i(this,Te))}withPlugin(e){return new zt({...i(this,Te),executor:i(this,Te).executor.withPlugin(e)})}toOperationNode(){return i(this,Te).executor.transformQuery(i(this,Te).queryNode,i(this,Te).queryId)}compile(){return i(this,Te).executor.compileQuery(this.toOperationNode(),i(this,Te).queryId)}async execute(){const e=this.compile(),n=e.query,r=await i(this,Te).executor.executeQuery(e,i(this,Te).queryId);return i(this,Te).executor.adapter.supportsReturning&&n.returning?r.rows:[new Ng(r.insertId,r.numAffectedRows??r.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=el){const n=await this.executeTakeFirst();if(n===void 0)throw tl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),r=i(this,Te).executor.stream(n,e,i(this,Te).queryId);for await(const a of r)yield*a.rows}async explain(e,n){return await new zt({...i(this,Te),queryNode:Re.cloneWithExplain(i(this,Te).queryNode,e,n)}).execute()}};Te=new WeakMap;let Oa=zt;$e(Oa,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class vg{constructor(e){ge(this,"numDeletedRows");this.numDeletedRows=e}}const up=m({is(t){return t.kind==="LimitNode"},create(t){return m({kind:"LimitNode",limit:ir.create(t)})}});var ve;const gt=class gt{constructor(e){D(this,ve,void 0);z(this,ve,m(e))}where(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithWhere(i(this,ve).queryNode,nn(e))})}whereRef(e,n,r){return new gt({...i(this,ve),queryNode:Re.cloneWithWhere(i(this,ve).queryNode,Wr(e,n,r))})}clearWhere(){return new gt({...i(this,ve),queryNode:Re.cloneWithoutWhere(i(this,ve).queryNode)})}using(e){return new gt({...i(this,ve),queryNode:ua.cloneWithUsing(i(this,ve).queryNode,qa(e))})}innerJoin(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithJoin(i(this,ve).queryNode,pn("InnerJoin",e))})}leftJoin(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithJoin(i(this,ve).queryNode,pn("LeftJoin",e))})}rightJoin(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithJoin(i(this,ve).queryNode,pn("RightJoin",e))})}fullJoin(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithJoin(i(this,ve).queryNode,pn("FullJoin",e))})}returning(e){return new gt({...i(this,ve),queryNode:Re.cloneWithReturning(i(this,ve).queryNode,Za(e))})}returningAll(e){return new gt({...i(this,ve),queryNode:Re.cloneWithReturning(i(this,ve).queryNode,eu(e))})}orderBy(e,n){return new gt({...i(this,ve),queryNode:ua.cloneWithOrderByItem(i(this,ve).queryNode,Zc(e,n))})}limit(e){return new gt({...i(this,ve),queryNode:ua.cloneWithLimit(i(this,ve).queryNode,up.create(e))})}$call(e){return e(this)}$if(e,n){return e?n(this):new gt({...i(this,ve)})}$castTo(){return new gt(i(this,ve))}$narrowType(){return new gt(i(this,ve))}$assertType(){return new gt(i(this,ve))}withPlugin(e){return new gt({...i(this,ve),executor:i(this,ve).executor.withPlugin(e)})}toOperationNode(){return i(this,ve).executor.transformQuery(i(this,ve).queryNode,i(this,ve).queryId)}compile(){return i(this,ve).executor.compileQuery(this.toOperationNode(),i(this,ve).queryId)}async execute(){const e=this.compile(),n=e.query,r=await i(this,ve).executor.executeQuery(e,i(this,ve).queryId);return i(this,ve).executor.adapter.supportsReturning&&n.returning?r.rows:[new vg(r.numAffectedRows??r.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=el){const n=await this.executeTakeFirst();if(n===void 0)throw tl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),r=i(this,ve).executor.stream(n,e,i(this,ve).queryId);for await(const a of r)yield*a.rows}async explain(e,n){return await new gt({...i(this,ve),queryNode:Re.cloneWithExplain(i(this,ve).queryNode,e,n)}).execute()}};ve=new WeakMap;let Yu=gt;$e(Yu,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class _g{constructor(e,n){ge(this,"numUpdatedRows");ge(this,"numChangedRows");this.numUpdatedRows=e,this.numChangedRows=n}}var Ce;const Ct=class Ct{constructor(e){D(this,Ce,void 0);z(this,Ce,m(e))}where(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithWhere(i(this,Ce).queryNode,nn(e))})}whereRef(e,n,r){return new Ct({...i(this,Ce),queryNode:Re.cloneWithWhere(i(this,Ce).queryNode,Wr(e,n,r))})}clearWhere(){return new Ct({...i(this,Ce),queryNode:Re.cloneWithoutWhere(i(this,Ce).queryNode)})}from(e){return new Ct({...i(this,Ce),queryNode:Ku.cloneWithFromItems(i(this,Ce).queryNode,qa(e))})}innerJoin(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithJoin(i(this,Ce).queryNode,pn("InnerJoin",e))})}leftJoin(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithJoin(i(this,Ce).queryNode,pn("LeftJoin",e))})}rightJoin(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithJoin(i(this,Ce).queryNode,pn("RightJoin",e))})}fullJoin(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithJoin(i(this,Ce).queryNode,pn("FullJoin",e))})}set(e){return new Ct({...i(this,Ce),queryNode:Ku.cloneWithUpdates(i(this,Ce).queryNode,Tf(e))})}returning(e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithReturning(i(this,Ce).queryNode,Za(e))})}returningAll(){return new Ct({...i(this,Ce),queryNode:Re.cloneWithReturning(i(this,Ce).queryNode,eu())})}$call(e){return e(this)}$if(e,n){return e?n(this):new Ct({...i(this,Ce)})}$castTo(){return new Ct(i(this,Ce))}$narrowType(){return new Ct(i(this,Ce))}$assertType(){return new Ct(i(this,Ce))}withPlugin(e){return new Ct({...i(this,Ce),executor:i(this,Ce).executor.withPlugin(e)})}toOperationNode(){return i(this,Ce).executor.transformQuery(i(this,Ce).queryNode,i(this,Ce).queryId)}compile(){return i(this,Ce).executor.compileQuery(this.toOperationNode(),i(this,Ce).queryId)}async execute(){const e=this.compile(),n=e.query,r=await i(this,Ce).executor.executeQuery(e,i(this,Ce).queryId);return i(this,Ce).executor.adapter.supportsReturning&&n.returning?r.rows:[new _g(r.numAffectedRows??r.numUpdatedOrDeletedRows??BigInt(0),r.numChangedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=el){const n=await this.executeTakeFirst();if(n===void 0)throw tl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),r=i(this,Ce).executor.stream(n,e,i(this,Ce).queryId);for await(const a of r)yield*a.rows}async explain(e,n){return await new Ct({...i(this,Ce),queryNode:Re.cloneWithExplain(i(this,Ce).queryNode,e,n)}).execute()}};Ce=new WeakMap;let Xu=Ct;$e(Xu,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const xg=m({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return m({kind:"CommonTableExpressionNode",name:t,expression:e})}}),Sh=m({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return m({kind:"CommonTableExpressionNameNode",table:ci.create(t),columns:e?m(e.map(yt.create)):void 0})}});function Ah(t,e){const n=e(Wg());return xg.create(Og(t),n.toOperationNode())}function Og(t){if(t.includes("(")){const e=t.split(/[\(\)]/),n=e[0],r=e[1].split(",").map(a=>a.trim());return Sh.create(n,r)}else return Sh.create(t)}const Cu=m({is(t){return t.kind==="WithNode"},create(t,e){return m({kind:"WithNode",expressions:m([t]),...e})},cloneWithExpression(t,e){return m({...t,expressions:m([...t.expressions,e])})}}),Ih=["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 Eg(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",column:this.transformNode(e.column),table:this.transformNode(e.table)}}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:m([...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)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}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}}yc=new WeakMap;const Sg=m({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 Ys,zi,Hi,wc,cp,gc,lp,bc,fp,Ki,na,ka,$l,Nc,hp;class Ag extends kf{constructor(n){super();D(this,wc);D(this,gc);D(this,bc);D(this,Ki);D(this,ka);D(this,Nc);D(this,Ys,void 0);D(this,zi,new Set);D(this,Hi,new Set);z(this,Ys,n)}transformNodeImpl(n){if(!_e(this,wc,cp).call(this,n))return super.transformNodeImpl(n);const r=_e(this,bc,fp).call(this,n);for(const p of r)i(this,Hi).add(p);const a=_e(this,gc,lp).call(this,n);for(const p of a)i(this,zi).add(p);const l=super.transformNodeImpl(n);for(const p of a)i(this,zi).delete(p);for(const p of r)i(this,Hi).delete(p);return l}transformSchemableIdentifier(n){const r=super.transformSchemableIdentifier(n);return r.schema||!i(this,zi).has(n.identifier.name)?r:{...r,schema:ct.create(i(this,Ys))}}transformReferences(n){const r=super.transformReferences(n);return r.table.table.schema?r:{...r,table:ci.createWithSchema(i(this,Ys),r.table.table.identifier.name)}}}Ys=new WeakMap,zi=new WeakMap,Hi=new WeakMap,wc=new WeakSet,cp=function(n){return n.kind in Sg},gc=new WeakSet,lp=function(n){const r=new Set;if("name"in n&&n.name&&hi.is(n.name)&&_e(this,ka,$l).call(this,n.name,r),"from"in n&&n.from)for(const a of n.from.froms)_e(this,Ki,na).call(this,a,r);if("into"in n&&n.into&&_e(this,Ki,na).call(this,n.into,r),"table"in n&&n.table&&_e(this,Ki,na).call(this,n.table,r),"joins"in n&&n.joins)for(const a of n.joins)_e(this,Ki,na).call(this,a.table,r);return r},bc=new WeakSet,fp=function(n){const r=new Set;return"with"in n&&n.with&&_e(this,Nc,hp).call(this,n.with,r),r},Ki=new WeakSet,na=function(n,r){const a=ci.is(n)?n:pi.is(n)&&ci.is(n.node)?n.node:null;a&&_e(this,ka,$l).call(this,a.table,r)},ka=new WeakSet,$l=function(n,r){const a=n.identifier.name;!i(this,zi).has(a)&&!i(this,Hi).has(a)&&r.add(a)},Nc=new WeakSet,hp=function(n,r){for(const a of n.expressions){const l=a.name.table.table.identifier.name;i(this,Hi).has(l)||r.add(l)}};var Wa;class tu{constructor(e){D(this,Wa,void 0);z(this,Wa,new Ag(e))}transformQuery(e){return i(this,Wa).transformNode(e.node)}async transformResult(e){return e.result}}Wa=new WeakMap;var tt;const $i=class $i{constructor(e){D(this,tt,void 0);z(this,tt,m(e))}selectFrom(e){return new Ea({queryId:nt(),executor:i(this,tt).executor,queryNode:Fe.create(qa(e),i(this,tt).withNode)})}insertInto(e){return new Oa({queryId:nt(),executor:i(this,tt).executor,queryNode:mr.create(mn(e),i(this,tt).withNode)})}replaceInto(e){return new Oa({queryId:nt(),executor:i(this,tt).executor,queryNode:mr.create(mn(e),i(this,tt).withNode,!0)})}deleteFrom(e){return new Yu({queryId:nt(),executor:i(this,tt).executor,queryNode:ua.create(qa(e),i(this,tt).withNode)})}updateTable(e){return new Xu({queryId:nt(),executor:i(this,tt).executor,queryNode:Ku.create(Sa(e),i(this,tt).withNode)})}with(e,n){const r=Ah(e,n);return new $i({...i(this,tt),withNode:i(this,tt).withNode?Cu.cloneWithExpression(i(this,tt).withNode,r):Cu.create(r)})}withRecursive(e,n){const r=Ah(e,n);return new $i({...i(this,tt),withNode:i(this,tt).withNode?Cu.cloneWithExpression(i(this,tt).withNode,r):Cu.create(r,{recursive:!0})})}withPlugin(e){return new $i({...i(this,tt),executor:i(this,tt).executor.withPlugin(e)})}withoutPlugins(){return new $i({...i(this,tt),executor:i(this,tt).executor.withoutPlugins()})}withSchema(e){return new $i({...i(this,tt),executor:i(this,tt).executor.withPluginAtFront(new tu(e))})}};tt=new WeakMap;let Zu=$i;var Ra,Xs,Zs;class Th{constructor(){D(this,Ra,void 0);D(this,Xs,void 0);D(this,Zs,void 0);ge(this,"resolve",e=>{i(this,Xs)&&i(this,Xs).call(this,e)});ge(this,"reject",e=>{i(this,Zs)&&i(this,Zs).call(this,e)});z(this,Ra,new Promise((e,n)=>{z(this,Zs,n),z(this,Xs,e)}))}get promise(){return i(this,Ra)}}Ra=new WeakMap,Xs=new WeakMap,Zs=new WeakMap;const kh=new Set;function Ig(t){kh.has(t)||(kh.add(t),console.log(t))}const Tg=m([]);var Ji,Da,Ql;class dp{constructor(e=Tg){D(this,Da);D(this,Ji,void 0);z(this,Ji,e)}get plugins(){return i(this,Ji)}transformQuery(e,n){for(const r of i(this,Ji)){const a=r.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 r=>{const a=await r.executeQuery(e),l=await _e(this,Da,Ql).call(this,a,n);return kg(a,l),l})}async*stream(e,n,r){const a=new Th,l=new Th;this.provideConnection(async w=>(a.resolve(w),await l.promise)).catch(w=>a.reject(w));const p=await a.promise;try{for await(const w of p.streamQuery(e,n))yield await _e(this,Da,Ql).call(this,w,r)}finally{l.resolve()}}}Ji=new WeakMap,Da=new WeakSet,Ql=async function(e,n){for(const r of i(this,Ji))e=await r.transformResult({result:e,queryId:n});return e};function kg(t,e){const{numAffectedRows:n}=t;n===void 0&&t.numUpdatedOrDeletedRows===void 0||n!==void 0&&e.numAffectedRows!==void 0||Ig("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class Ps extends dp{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 Ps([...this.plugins,e])}withPlugins(e){return new Ps([...this.plugins,...e])}withPluginAtFront(e){return new Ps([e,...this.plugins])}withoutPlugins(){return new Ps([])}}const Wf=new Ps;function Wg(){return new Zu({executor:Wf})}function Rg(t,e){return new zu({joinNode:oa.create(t,Sa(e))})}function Dg(){return new Hu({overNode:Ul.create()})}function pn(t,e){if(e.length===3)return Pg(t,e[0],e[1],e[2]);if(e.length===2)return Lg(t,e[0],e[1]);throw new Error("not implemented")}function Lg(t,e,n){return n(Rg(t,e)).toOperationNode()}function Pg(t,e,n,r){return oa.createWithOn(t,Sa(e),Wr(n,"=",r))}const Mg=m({is(t){return t.kind==="OffsetNode"},create(t){return m({kind:"OffsetNode",offset:ir.create(t)})}}),Bg=m({is(t){return t.kind==="GroupByItemNode"},create(t){return m({kind:"GroupByItemNode",groupBy:t})}});function Fg(t){return t=Ln(t)?t(Ao()):t,xa(t).map(Bg.create)}const pp=m({is(t){return t.kind==="SetOperationNode"},create(t,e,n){return m({kind:"SetOperationNode",operator:t,expression:e,all:n})}});function ks(t,e,n){return pp.create(t,e.toOperationNode(),n)}var Z;const xe=class xe{constructor(e){D(this,Z,void 0);z(this,Z,m(e))}get expressionType(){}where(...e){return new xe({...i(this,Z),queryNode:Re.cloneWithWhere(i(this,Z).queryNode,nn(e))})}whereRef(e,n,r){return new xe({...i(this,Z),queryNode:Re.cloneWithWhere(i(this,Z).queryNode,Wr(e,n,r))})}having(...e){return new xe({...i(this,Z),queryNode:Fe.cloneWithHaving(i(this,Z).queryNode,nn(e))})}havingRef(e,n,r){return new xe({...i(this,Z),queryNode:Fe.cloneWithHaving(i(this,Z).queryNode,Wr(e,n,r))})}select(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithSelections(i(this,Z).queryNode,Za(e))})}distinctOn(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithDistinctOn(i(this,Z).queryNode,xa(e))})}modifyFront(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithFrontModifier(i(this,Z).queryNode,vr.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithEndModifier(i(this,Z).queryNode,vr.createWithExpression(e.toOperationNode()))})}distinct(){return new xe({...i(this,Z),queryNode:Fe.cloneWithFrontModifier(i(this,Z).queryNode,vr.create("Distinct"))})}forUpdate(){return new xe({...i(this,Z),queryNode:Fe.cloneWithEndModifier(i(this,Z).queryNode,vr.create("ForUpdate"))})}forShare(){return new xe({...i(this,Z),queryNode:Fe.cloneWithEndModifier(i(this,Z).queryNode,vr.create("ForShare"))})}forKeyShare(){return new xe({...i(this,Z),queryNode:Fe.cloneWithEndModifier(i(this,Z).queryNode,vr.create("ForKeyShare"))})}forNoKeyUpdate(){return new xe({...i(this,Z),queryNode:Fe.cloneWithEndModifier(i(this,Z).queryNode,vr.create("ForNoKeyUpdate"))})}skipLocked(){return new xe({...i(this,Z),queryNode:Fe.cloneWithEndModifier(i(this,Z).queryNode,vr.create("SkipLocked"))})}noWait(){return new xe({...i(this,Z),queryNode:Fe.cloneWithEndModifier(i(this,Z).queryNode,vr.create("NoWait"))})}selectAll(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithSelections(i(this,Z).queryNode,eu(e))})}innerJoin(...e){return new xe({...i(this,Z),queryNode:Re.cloneWithJoin(i(this,Z).queryNode,pn("InnerJoin",e))})}leftJoin(...e){return new xe({...i(this,Z),queryNode:Re.cloneWithJoin(i(this,Z).queryNode,pn("LeftJoin",e))})}rightJoin(...e){return new xe({...i(this,Z),queryNode:Re.cloneWithJoin(i(this,Z).queryNode,pn("RightJoin",e))})}fullJoin(...e){return new xe({...i(this,Z),queryNode:Re.cloneWithJoin(i(this,Z).queryNode,pn("FullJoin",e))})}innerJoinLateral(...e){return new xe({...i(this,Z),queryNode:Re.cloneWithJoin(i(this,Z).queryNode,pn("LateralInnerJoin",e))})}leftJoinLateral(...e){return new xe({...i(this,Z),queryNode:Re.cloneWithJoin(i(this,Z).queryNode,pn("LateralLeftJoin",e))})}orderBy(e,n){return new xe({...i(this,Z),queryNode:Fe.cloneWithOrderByItem(i(this,Z).queryNode,Zc(e,n))})}groupBy(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithGroupByItems(i(this,Z).queryNode,Fg(e))})}limit(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithLimit(i(this,Z).queryNode,up.create(e))})}offset(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithOffset(i(this,Z).queryNode,Mg.create(e))})}union(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithSetOperation(i(this,Z).queryNode,ks("union",e,!1))})}unionAll(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithSetOperation(i(this,Z).queryNode,ks("union",e,!0))})}intersect(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithSetOperation(i(this,Z).queryNode,ks("intersect",e,!1))})}intersectAll(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithSetOperation(i(this,Z).queryNode,ks("intersect",e,!0))})}except(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithSetOperation(i(this,Z).queryNode,ks("except",e,!1))})}exceptAll(e){return new xe({...i(this,Z),queryNode:Fe.cloneWithSetOperation(i(this,Z).queryNode,ks("except",e,!0))})}as(e){return new Ug(this,e)}clearSelect(){return new xe({...i(this,Z),queryNode:Fe.cloneWithoutSelections(i(this,Z).queryNode)})}clearWhere(){return new xe({...i(this,Z),queryNode:Re.cloneWithoutWhere(i(this,Z).queryNode)})}clearLimit(){return new xe({...i(this,Z),queryNode:Fe.cloneWithoutLimit(i(this,Z).queryNode)})}clearOffset(){return new xe({...i(this,Z),queryNode:Fe.cloneWithoutOffset(i(this,Z).queryNode)})}clearOrderBy(){return new xe({...i(this,Z),queryNode:Fe.cloneWithoutOrderBy(i(this,Z).queryNode)})}$call(e){return e(this)}$if(e,n){return e?n(this):new xe({...i(this,Z)})}$castTo(){return new xe(i(this,Z))}$narrowType(){return new xe(i(this,Z))}$assertType(){return new xe(i(this,Z))}withPlugin(e){return new xe({...i(this,Z),executor:i(this,Z).executor.withPlugin(e)})}toOperationNode(){return i(this,Z).executor.transformQuery(i(this,Z).queryNode,i(this,Z).queryId)}compile(){return i(this,Z).executor.compileQuery(this.toOperationNode(),i(this,Z).queryId)}async execute(){const e=this.compile();return(await i(this,Z).executor.executeQuery(e,i(this,Z).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=el){const n=await this.executeTakeFirst();if(n===void 0)throw tl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),r=i(this,Z).executor.stream(n,e,i(this,Z).queryId);for await(const a of r)yield*a.rows}async explain(e,n){return await new xe({...i(this,Z),queryNode:Re.cloneWithExplain(i(this,Z).queryNode,e,n)}).execute()}};Z=new WeakMap;let Ea=xe;$e(Ea,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var eo,to;class Ug{constructor(e,n){D(this,eo,void 0);D(this,to,void 0);z(this,eo,e),z(this,to,n)}get expression(){return i(this,eo)}get alias(){return i(this,to)}toOperationNode(){return pi.create(i(this,eo).toOperationNode(),ct.create(i(this,to)))}}eo=new WeakMap,to=new WeakMap;const Ms=m({is(t){return t.kind==="ParensNode"},create(t){return m({kind:"ParensNode",node:t})}});var Yr;const Uf=class Uf{constructor(e){D(this,Yr,void 0);z(this,Yr,e)}get expressionType(){}as(e){return new Rf(this,e)}or(...e){return new jl(fs.create(i(this,Yr),nn(e)))}and(...e){return new Vl(ls.create(i(this,Yr),nn(e)))}$castTo(){return new Uf(i(this,Yr))}toOperationNode(){return i(this,Yr)}};Yr=new WeakMap;let mt=Uf;var no,Xr;class Rf{constructor(e,n){D(this,no,void 0);D(this,Xr,void 0);z(this,no,e),z(this,Xr,n)}get expression(){return i(this,no)}get alias(){return i(this,Xr)}toOperationNode(){return pi.create(i(this,no).toOperationNode(),Pn(i(this,Xr))?i(this,Xr).toOperationNode():ct.create(i(this,Xr)))}}no=new WeakMap,Xr=new WeakMap;var Gi;const vc=class vc{constructor(e){D(this,Gi,void 0);z(this,Gi,e)}get expressionType(){}as(e){return new Rf(this,e)}or(...e){return new vc(fs.create(i(this,Gi),nn(e)))}$castTo(){return new vc(i(this,Gi))}toOperationNode(){return Ms.create(i(this,Gi))}};Gi=new WeakMap;let jl=vc;var Yi;const _c=class _c{constructor(e){D(this,Yi,void 0);z(this,Yi,e)}get expressionType(){}as(e){return new Rf(this,e)}and(...e){return new _c(ls.create(i(this,Yi),nn(e)))}$castTo(){return new _c(i(this,Yi))}toOperationNode(){return Ms.create(i(this,Yi))}};Yi=new WeakMap;let Vl=_c;const Bs=m({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return m({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return m({...t,distinct:!0})},cloneWithFilter(t,e){return m({...t,filter:t.filter?hn.cloneWithOperation(t.filter,"And",e):hn.create(e)})},cloneWithOrFilter(t,e){return m({...t,filter:t.filter?hn.cloneWithOperation(t.filter,"Or",e):hn.create(e)})},cloneWithOver(t,e){return m({...t,over:e})}}),$g=m({is(t){return t.kind==="FunctionNode"},create(t,e){return m({kind:"FunctionNode",func:t,arguments:e})}});var vn;const Us=class Us{constructor(e){D(this,vn,void 0);z(this,vn,m(e))}get expressionType(){}as(e){return new Qg(this,e)}distinct(){return new Us({...i(this,vn),aggregateFunctionNode:Bs.cloneWithDistinct(i(this,vn).aggregateFunctionNode)})}filterWhere(...e){return new Us({...i(this,vn),aggregateFunctionNode:Bs.cloneWithFilter(i(this,vn).aggregateFunctionNode,nn(e))})}filterWhereRef(e,n,r){return new Us({...i(this,vn),aggregateFunctionNode:Bs.cloneWithFilter(i(this,vn).aggregateFunctionNode,Wr(e,n,r))})}over(e){const n=Dg();return new Us({...i(this,vn),aggregateFunctionNode:Bs.cloneWithOver(i(this,vn).aggregateFunctionNode,(e?e(n):n).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return i(this,vn).aggregateFunctionNode}};vn=new WeakMap;let Ca=Us;$e(Ca,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");var ro,io;class Qg{constructor(e,n){D(this,ro,void 0);D(this,io,void 0);z(this,ro,e),z(this,io,n)}get expression(){return i(this,ro)}get alias(){return i(this,io)}toOperationNode(){return pi.create(i(this,ro).toOperationNode(),ct.create(i(this,io)))}}ro=new WeakMap,io=new WeakMap;function mp(){const t=(n,r)=>new mt($g.create(n,xa(r))),e=(n,r)=>new Ca({aggregateFunctionNode:Bs.create(n,r?xa(r):void 0)});return Object.assign(t,{agg:e,avg(n){return e("avg",[n])},coalesce(n,...r){return t("coalesce",[n,...r])},count(n){return e("count",[n])},countAll(n){return new Ca({aggregateFunctionNode:Bs.create("count",eu(n))})},max(n){return e("max",[n])},min(n){return e("min",[n])},sum(n){return e("sum",[n])}})}const jg=m({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return m({kind:"UnaryOperationNode",operator:t,operand:e})}});function Vg(t,e){return jg.create(_a.create(t),kr(e))}const Df=m({is(t){return t.kind==="WhenNode"},create(t){return m({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return m({...t,result:e})}}),gr=m({is(t){return t.kind==="CaseNode"},create(t){return m({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return m({...t,when:m(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return m({...t,when:t.when?m([...t.when.slice(0,-1),Df.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return m({...t,...e})}});var so;class yp{constructor(e){D(this,so,void 0);z(this,so,m(e))}when(...e){return new wp({...i(this,so),node:gr.cloneWithWhen(i(this,so).node,Df.create(nn(e)))})}}so=new WeakMap;var oo;class wp{constructor(e){D(this,oo,void 0);z(this,oo,m(e))}then(e){return new zg({...i(this,oo),node:gr.cloneWithThen(i(this,oo).node,Ir(e))})}}oo=new WeakMap;var fr;class zg{constructor(e){D(this,fr,void 0);z(this,fr,m(e))}when(...e){return new wp({...i(this,fr),node:gr.cloneWithWhen(i(this,fr).node,Df.create(nn(e)))})}else(e){return new Hg({...i(this,fr),node:gr.cloneWith(i(this,fr).node,{else:Ir(e)})})}end(){return new mt(gr.cloneWith(i(this,fr).node,{isStatement:!1}))}endCase(){return new mt(gr.cloneWith(i(this,fr).node,{isStatement:!0}))}}fr=new WeakMap;var ao;class Hg{constructor(e){D(this,ao,void 0);z(this,ao,m(e))}end(){return new mt(gr.cloneWith(i(this,ao).node,{isStatement:!1}))}endCase(){return new mt(gr.cloneWith(i(this,ao).node,{isStatement:!0}))}}ao=new WeakMap;const Kg=m({is(t){return t.kind==="JSONPathLegNode"},create(t,e){return m({kind:"JSONPathLegNode",type:t,value:e})}});var Zr,La,Hl;class zl{constructor(e){D(this,La);D(this,Zr,void 0);z(this,Zr,e)}at(e){return _e(this,La,Hl).call(this,"ArrayLocation",e)}key(e){return _e(this,La,Hl).call(this,"Member",e)}}Zr=new WeakMap,La=new WeakSet,Hl=function(e,n){return new Jg(Bl.cloneWithTraversal(i(this,Zr),Fl.is(i(this,Zr).traversal)?Fl.cloneWithLeg(i(this,Zr).traversal,Kg.create(e,n)):Zd.cloneWithValue(i(this,Zr).traversal,ir.createImmediate(n))))};var uo;class Jg extends zl{constructor(n){super(n);D(this,uo,void 0);z(this,uo,n)}get expressionType(){}as(n){return new Gg(this,n)}$castTo(){return new zl(i(this,uo))}toOperationNode(){return i(this,uo)}}uo=new WeakMap;var co,ei;class Gg{constructor(e,n){D(this,co,void 0);D(this,ei,void 0);z(this,co,e),z(this,ei,n)}get expression(){return i(this,co)}get alias(){return i(this,ei)}toOperationNode(){return pi.create(i(this,co).toOperationNode(),Pn(i(this,ei))?i(this,ei).toOperationNode():ct.create(i(this,ei)))}}co=new WeakMap,ei=new WeakMap;function Lf(t=Wf){function e(a,l,p){return new mt(Ru(a,l,p))}function n(a,l){return new mt(Vg(a,l))}const r=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(a){return new Ea({queryId:nt(),executor:t,queryNode:Fe.create(qa(a))})},case(a){return new yp({node:gr.create(Ks(a)?void 0:kr(a))})},ref(a,l){return Ks(l)?new mt(hs(a)):new zl(Yw(a,l))},val(a){return new mt(rp(a))},cmpr(a,l,p){return new mt(Ru(a,l,p))},bxp(a,l,p){return new mt(Ru(a,l,p))},unary:n,not(a){return n("not",a)},exists(a){return n("exists",a)},neg(a){return n("-",a)},and(a){if(a.length===0)return new mt(ir.createImmediate(!0));if(a.length===1)return new mt(a[0].toOperationNode());let l=ls.create(a[0].toOperationNode(),a[1].toOperationNode());for(let p=2;pSa(e)):[Sa(t)]}function Sa(t){return Dn(t)?Yg(t):gp(t)}function Yg(t){const e=" as ";if(t.includes(e)){const[n,r]=t.split(e).map(bp);return pi.create(mn(n),ct.create(r))}else return mn(t)}function mn(t){const e=".";if(t.includes(e)){const[n,r]=t.split(e).map(bp);return ci.createWithSchema(n,r)}else return ci.create(t)}function bp(t){return t.trim()}const Np=m({is(t){return t.kind==="AddColumnNode"},create(t){return m({kind:"AddColumnNode",column:t})}}),pt=m({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return m({kind:"ColumnDefinitionNode",column:yt.create(t),dataType:e})},cloneWithFrontModifier(t,e){return m({...t,frontModifiers:t.frontModifiers?m([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return m({...t,endModifiers:t.endModifiers?m([...t.endModifiers,e]):[e]})},cloneWith(t,e){return m({...t,...e})}}),vp=m({is(t){return t.kind==="DropColumnNode"},create(t){return m({kind:"DropColumnNode",column:yt.create(t)})}}),_p=m({is(t){return t.kind==="RenameColumnNode"},create(t,e){return m({kind:"RenameColumnNode",column:yt.create(t),renameTo:yt.create(e)})}}),Pf=m({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return m({kind:"CheckConstraintNode",expression:t,name:e?ct.create(e):void 0})}}),Xg=["no action","restrict","cascade","set null","set default"],Du=m({is(t){return t.kind==="ReferencesNode"},create(t,e){return m({kind:"ReferencesNode",table:t,columns:m([...e])})},cloneWithOnDelete(t,e){return m({...t,onDelete:e})},cloneWithOnUpdate(t,e){return m({...t,onUpdate:e})}});function xp(t){return Pn(t)?t.toOperationNode():ir.createImmediate(t)}const qu=m({is(t){return t.kind==="GeneratedNode"},create(t){return m({kind:"GeneratedNode",...t})},createWithExpression(t){return m({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return m({...t,...e})}}),Zg=m({is(t){return t.kind==="DefaultValueNode"},create(t){return m({kind:"DefaultValueNode",defaultValue:t})}});function ec(t){if(Xg.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}var Ye;const At=class At{constructor(e){D(this,Ye,void 0);z(this,Ye,e)}autoIncrement(){return new At(pt.cloneWith(i(this,Ye),{autoIncrement:!0}))}primaryKey(){return new At(pt.cloneWith(i(this,Ye),{primaryKey:!0}))}references(e){const n=hs(e);if(!n.table||qf.is(n.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new At(pt.cloneWith(i(this,Ye),{references:Du.create(n.table,[n.column])}))}onDelete(e){if(!i(this,Ye).references)throw new Error("on delete constraint can only be added for foreign keys");return new At(pt.cloneWith(i(this,Ye),{references:Du.cloneWithOnDelete(i(this,Ye).references,ec(e))}))}onUpdate(e){if(!i(this,Ye).references)throw new Error("on update constraint can only be added for foreign keys");return new At(pt.cloneWith(i(this,Ye),{references:Du.cloneWithOnUpdate(i(this,Ye).references,ec(e))}))}unique(){return new At(pt.cloneWith(i(this,Ye),{unique:!0}))}notNull(){return new At(pt.cloneWith(i(this,Ye),{notNull:!0}))}unsigned(){return new At(pt.cloneWith(i(this,Ye),{unsigned:!0}))}defaultTo(e){return new At(pt.cloneWith(i(this,Ye),{defaultTo:Zg.create(xp(e))}))}check(e){return new At(pt.cloneWith(i(this,Ye),{check:Pf.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new At(pt.cloneWith(i(this,Ye),{generated:qu.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new At(pt.cloneWith(i(this,Ye),{generated:qu.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new At(pt.cloneWith(i(this,Ye),{generated:qu.create({identity:!0,byDefault:!0})}))}stored(){if(!i(this,Ye).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new At(pt.cloneWith(i(this,Ye),{generated:qu.cloneWith(i(this,Ye).generated,{stored:!0})}))}modifyFront(e){return new At(pt.cloneWithFrontModifier(i(this,Ye),e.toOperationNode()))}modifyEnd(e){return new At(pt.cloneWithEndModifier(i(this,Ye),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return i(this,Ye)}};Ye=new WeakMap;let di=At;$e(di,"don't await ColumnDefinitionBuilder instances directly.");const Op=m({is(t){return t.kind==="ModifyColumnNode"},create(t){return m({kind:"ModifyColumnNode",column:t})}}),eb=m({is(t){return t.kind==="DataTypeNode"},create(t){return m({kind:"DataTypeNode",dataType:t})}});function Eo(t){return Pn(t)?t.toOperationNode():eb.create(t)}const tc=m({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,n,r){return m({kind:"ForeignKeyConstraintNode",columns:t,references:Du.create(e,n),name:r?ct.create(r):void 0})},cloneWith(t,e){return m({...t,...e})}});var Xi;const xc=class xc{constructor(e){D(this,Xi,void 0);z(this,Xi,e)}onDelete(e){return new xc(tc.cloneWith(i(this,Xi),{onDelete:ec(e)}))}onUpdate(e){return new xc(tc.cloneWith(i(this,Xi),{onUpdate:ec(e)}))}$call(e){return e(this)}toOperationNode(){return i(this,Xi)}};Xi=new WeakMap;let Aa=xc;$e(Aa,"don't await ForeignKeyConstraintBuilder instances directly.");const Kl=m({is(t){return t.kind==="AddConstraintNode"},create(t){return m({kind:"AddConstraintNode",constraint:t})}}),Ep=m({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return m({kind:"UniqueConstraintNode",columns:m(t.map(yt.create)),name:e?ct.create(e):void 0})}}),Lu=m({is(t){return t.kind==="DropConstraintNode"},create(t){return m({kind:"DropConstraintNode",constraintName:ct.create(t)})},cloneWith(t,e){return m({...t,...e})}}),Zo=m({is(t){return t.kind==="AlterColumnNode"},create(t,e,n){return m({kind:"AlterColumnNode",column:yt.create(t),[e]:n})}});var Er;class Mf{constructor(e){D(this,Er,void 0);z(this,Er,e)}setDataType(e){return new ea(Zo.create(i(this,Er),"dataType",Eo(e)))}setDefault(e){return new ea(Zo.create(i(this,Er),"setDefault",xp(e)))}dropDefault(){return new ea(Zo.create(i(this,Er),"dropDefault",!0))}setNotNull(){return new ea(Zo.create(i(this,Er),"setNotNull",!0))}dropNotNull(){return new ea(Zo.create(i(this,Er),"dropNotNull",!0))}$call(e){return e(this)}}Er=new WeakMap;var Pa;class ea{constructor(e){D(this,Pa,void 0);z(this,Pa,e)}toOperationNode(){return i(this,Pa)}}Pa=new WeakMap;var Jn;class ra{constructor(e){D(this,Jn,void 0);z(this,Jn,m(e))}toOperationNode(){return i(this,Jn).executor.transformQuery(i(this,Jn).node,i(this,Jn).queryId)}compile(){return i(this,Jn).executor.compileQuery(this.toOperationNode(),i(this,Jn).queryId)}async execute(){await i(this,Jn).executor.executeQuery(this.compile(),i(this,Jn).queryId)}}Jn=new WeakMap;$e(ra,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");var Ht;const Oc=class Oc{constructor(e){D(this,Ht,void 0);z(this,Ht,m(e))}onDelete(e){return new Oc({...i(this,Ht),constraintBuilder:i(this,Ht).constraintBuilder.onDelete(e)})}onUpdate(e){return new Oc({...i(this,Ht),constraintBuilder:i(this,Ht).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return i(this,Ht).executor.transformQuery(vt.cloneWithTableProps(i(this,Ht).node,{addConstraint:Kl.create(i(this,Ht).constraintBuilder.toOperationNode())}),i(this,Ht).queryId)}compile(){return i(this,Ht).executor.compileQuery(this.toOperationNode(),i(this,Ht).queryId)}async execute(){await i(this,Ht).executor.executeQuery(this.compile(),i(this,Ht).queryId)}};Ht=new WeakMap;let nc=Oc;$e(nc,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");var bt;const fa=class fa{constructor(e){D(this,bt,void 0);z(this,bt,m(e))}ifExists(){return new fa({...i(this,bt),node:vt.cloneWithTableProps(i(this,bt).node,{dropConstraint:Lu.cloneWith(i(this,bt).node.dropConstraint,{ifExists:!0})})})}cascade(){return new fa({...i(this,bt),node:vt.cloneWithTableProps(i(this,bt).node,{dropConstraint:Lu.cloneWith(i(this,bt).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new fa({...i(this,bt),node:vt.cloneWithTableProps(i(this,bt).node,{dropConstraint:Lu.cloneWith(i(this,bt).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return i(this,bt).executor.transformQuery(i(this,bt).node,i(this,bt).queryId)}compile(){return i(this,bt).executor.compileQuery(this.toOperationNode(),i(this,bt).queryId)}async execute(){await i(this,bt).executor.executeQuery(this.compile(),i(this,bt).queryId)}};bt=new WeakMap;let rc=fa;$e(rc,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");var it;class Cp{constructor(e){D(this,it,void 0);z(this,it,m(e))}renameTo(e){return new ra({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{renameTo:mn(e)})})}setSchema(e){return new ra({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{setSchema:ct.create(e)})})}alterColumn(e,n){const r=n(new Mf(e));return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,r.toOperationNode())})}dropColumn(e){return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,vp.create(e))})}renameColumn(e,n){return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,_p.create(e,n))})}addColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,Np.create(a.toOperationNode()))})}modifyColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,Op.create(a.toOperationNode()))})}addUniqueConstraint(e,n){return new ra({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{addConstraint:Kl.create(Ep.create(n,e))})})}addCheckConstraint(e,n){return new ra({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{addConstraint:Kl.create(Pf.create(n.toOperationNode(),e))})})}addForeignKeyConstraint(e,n,r,a){return new nc({...i(this,it),constraintBuilder:new Aa(tc.create(n.map(yt.create),mn(r),a.map(yt.create),e))})}dropConstraint(e){return new rc({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{dropConstraint:Lu.create(e)})})}$call(e){return e(this)}}it=new WeakMap;var dt;const Qi=class Qi{constructor(e){D(this,dt,void 0);z(this,dt,m(e))}alterColumn(e,n){const r=n(new Mf(e));return new Qi({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,r.toOperationNode())})}dropColumn(e){return new Qi({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,vp.create(e))})}renameColumn(e,n){return new Qi({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,_p.create(e,n))})}addColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new Qi({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,Np.create(a.toOperationNode()))})}modifyColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new Qi({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,Op.create(a.toOperationNode()))})}toOperationNode(){return i(this,dt).executor.transformQuery(i(this,dt).node,i(this,dt).queryId)}compile(){return i(this,dt).executor.compileQuery(this.toOperationNode(),i(this,dt).queryId)}async execute(){await i(this,dt).executor.executeQuery(this.compile(),i(this,dt).queryId)}};dt=new WeakMap;let Gr=Qi;$e(Cp,"don't await AlterTableBuilder instances");$e(Mf,"don't await AlterColumnBuilder instances");$e(Gr,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class qp extends kf{transformValue(e){return{...super.transformValue(e),immediate:!0}}}var Xe;const cr=class cr{constructor(e){D(this,Xe,void 0);z(this,Xe,m(e))}ifNotExists(){return new cr({...i(this,Xe),node:Vr.cloneWith(i(this,Xe).node,{ifNotExists:!0})})}unique(){return new cr({...i(this,Xe),node:Vr.cloneWith(i(this,Xe).node,{unique:!0})})}on(e){return new cr({...i(this,Xe),node:Vr.cloneWith(i(this,Xe).node,{table:mn(e)})})}column(e){return new cr({...i(this,Xe),node:Vr.cloneWithColumns(i(this,Xe).node,[Nh(e)])})}columns(e){return new cr({...i(this,Xe),node:Vr.cloneWithColumns(i(this,Xe).node,e.map(Nh))})}expression(e){return new cr({...i(this,Xe),node:Vr.cloneWithColumns(i(this,Xe).node,[e.toOperationNode()])})}using(e){return new cr({...i(this,Xe),node:Vr.cloneWith(i(this,Xe).node,{using:tn.createWithSql(e)})})}where(...e){const n=new qp;return new cr({...i(this,Xe),node:Re.cloneWithWhere(i(this,Xe).node,n.transformNode(nn(e)))})}$call(e){return e(this)}toOperationNode(){return i(this,Xe).executor.transformQuery(i(this,Xe).node,i(this,Xe).queryId)}compile(){return i(this,Xe).executor.compileQuery(this.toOperationNode(),i(this,Xe).queryId)}async execute(){await i(this,Xe).executor.executeQuery(this.compile(),i(this,Xe).queryId)}};Xe=new WeakMap;let ic=cr;$e(ic,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");var _n;const $f=class $f{constructor(e){D(this,_n,void 0);z(this,_n,m(e))}ifNotExists(){return new $f({...i(this,_n),node:Jd.cloneWith(i(this,_n).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,_n).executor.transformQuery(i(this,_n).node,i(this,_n).queryId)}compile(){return i(this,_n).executor.compileQuery(this.toOperationNode(),i(this,_n).queryId)}async execute(){await i(this,_n).executor.executeQuery(this.compile(),i(this,_n).queryId)}};_n=new WeakMap;let sc=$f;$e(sc,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const tb=m({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return m({kind:"PrimaryKeyConstraintNode",columns:m(t.map(yt.create)),name:e?ct.create(e):void 0})}});function nb(t){if(Bw.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}var Ue;const Wn=class Wn{constructor(e){D(this,Ue,void 0);z(this,Ue,m(e))}temporary(){return new Wn({...i(this,Ue),node:jn.cloneWith(i(this,Ue).node,{temporary:!0})})}onCommit(e){return new Wn({...i(this,Ue),node:jn.cloneWith(i(this,Ue).node,{onCommit:nb(e)})})}ifNotExists(){return new Wn({...i(this,Ue),node:jn.cloneWith(i(this,Ue).node,{ifNotExists:!0})})}addColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new Wn({...i(this,Ue),node:jn.cloneWithColumn(i(this,Ue).node,a.toOperationNode())})}addPrimaryKeyConstraint(e,n){return new Wn({...i(this,Ue),node:jn.cloneWithConstraint(i(this,Ue).node,tb.create(n,e))})}addUniqueConstraint(e,n){return new Wn({...i(this,Ue),node:jn.cloneWithConstraint(i(this,Ue).node,Ep.create(n,e))})}addCheckConstraint(e,n){return new Wn({...i(this,Ue),node:jn.cloneWithConstraint(i(this,Ue).node,Pf.create(n.toOperationNode(),e))})}addForeignKeyConstraint(e,n,r,a,l=xo){const p=l(new Aa(tc.create(n.map(yt.create),mn(r),a.map(yt.create),e)));return new Wn({...i(this,Ue),node:jn.cloneWithConstraint(i(this,Ue).node,p.toOperationNode())})}modifyFront(e){return new Wn({...i(this,Ue),node:jn.cloneWithFrontModifier(i(this,Ue).node,e.toOperationNode())})}modifyEnd(e){return new Wn({...i(this,Ue),node:jn.cloneWithEndModifier(i(this,Ue).node,e.toOperationNode())})}$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)}};Ue=new WeakMap;let oc=Wn;$e(oc,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");var Pt;const ha=class ha{constructor(e){D(this,Pt,void 0);z(this,Pt,m(e))}on(e){return new ha({...i(this,Pt),node:Wu.cloneWith(i(this,Pt).node,{table:mn(e)})})}ifExists(){return new ha({...i(this,Pt),node:Wu.cloneWith(i(this,Pt).node,{ifExists:!0})})}cascade(){return new ha({...i(this,Pt),node:Wu.cloneWith(i(this,Pt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Pt).executor.transformQuery(i(this,Pt).node,i(this,Pt).queryId)}compile(){return i(this,Pt).executor.compileQuery(this.toOperationNode(),i(this,Pt).queryId)}async execute(){await i(this,Pt).executor.executeQuery(this.compile(),i(this,Pt).queryId)}};Pt=new WeakMap;let ac=ha;$e(ac,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");var Zt;const Ec=class Ec{constructor(e){D(this,Zt,void 0);z(this,Zt,m(e))}ifExists(){return new Ec({...i(this,Zt),node:Pl.cloneWith(i(this,Zt).node,{ifExists:!0})})}cascade(){return new Ec({...i(this,Zt),node:Pl.cloneWith(i(this,Zt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Zt).executor.transformQuery(i(this,Zt).node,i(this,Zt).queryId)}compile(){return i(this,Zt).executor.compileQuery(this.toOperationNode(),i(this,Zt).queryId)}async execute(){await i(this,Zt).executor.executeQuery(this.compile(),i(this,Zt).queryId)}};Zt=new WeakMap;let uc=Ec;$e(uc,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");var en;const Cc=class Cc{constructor(e){D(this,en,void 0);z(this,en,m(e))}ifExists(){return new Cc({...i(this,en),node:Ml.cloneWith(i(this,en).node,{ifExists:!0})})}cascade(){return new Cc({...i(this,en),node:Ml.cloneWith(i(this,en).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,en).executor.transformQuery(i(this,en).node,i(this,en).queryId)}compile(){return i(this,en).executor.compileQuery(this.toOperationNode(),i(this,en).queryId)}async execute(){await i(this,en).executor.executeQuery(this.compile(),i(this,en).queryId)}};en=new WeakMap;let cc=Cc;$e(cc,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const Kr=m({is(t){return t.kind==="CreateViewNode"},create(t){return m({kind:"CreateViewNode",name:hi.create(t)})},cloneWith(t,e){return m({...t,...e})}});var qc;class rb{constructor(){D(this,qc,new qp)}transformQuery(e){return i(this,qc).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}qc=new WeakMap;var ut;const Jr=class Jr{constructor(e){D(this,ut,void 0);z(this,ut,m(e))}temporary(){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{temporary:!0})})}materialized(){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{materialized:!0})})}ifNotExists(){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{ifNotExists:!0})})}orReplace(){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{orReplace:!0})})}columns(e){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{columns:e.map(tp)})})}as(e){const n=e.withPlugin(new rb).toOperationNode();return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{as:n})})}$call(e){return e(this)}toOperationNode(){return i(this,ut).executor.transformQuery(i(this,ut).node,i(this,ut).queryId)}compile(){return i(this,ut).executor.compileQuery(this.toOperationNode(),i(this,ut).queryId)}async execute(){await i(this,ut).executor.executeQuery(this.compile(),i(this,ut).queryId)}};ut=new WeakMap;let lc=Jr;$e(lc,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const Pu=m({is(t){return t.kind==="DropViewNode"},create(t){return m({kind:"DropViewNode",name:hi.create(t)})},cloneWith(t,e){return m({...t,...e})}});var Mt;const da=class da{constructor(e){D(this,Mt,void 0);z(this,Mt,m(e))}materialized(){return new da({...i(this,Mt),node:Pu.cloneWith(i(this,Mt).node,{materialized:!0})})}ifExists(){return new da({...i(this,Mt),node:Pu.cloneWith(i(this,Mt).node,{ifExists:!0})})}cascade(){return new da({...i(this,Mt),node:Pu.cloneWith(i(this,Mt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Mt).executor.transformQuery(i(this,Mt).node,i(this,Mt).queryId)}compile(){return i(this,Mt).executor.compileQuery(this.toOperationNode(),i(this,Mt).queryId)}async execute(){await i(this,Mt).executor.executeQuery(this.compile(),i(this,Mt).queryId)}};Mt=new WeakMap;let fc=da;$e(fc,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const Sp=m({is(t){return t.kind==="CreateTypeNode"},create(t){return m({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return m({...t,enum:Af.create(e.map(n=>ir.createImmediate(n)))})}});var xn;const Qf=class Qf{constructor(e){D(this,xn,void 0);z(this,xn,m(e))}toOperationNode(){return i(this,xn).executor.transformQuery(i(this,xn).node,i(this,xn).queryId)}asEnum(e){return new Qf({...i(this,xn),node:Sp.cloneWithEnum(i(this,xn).node,e)})}$call(e){return e(this)}compile(){return i(this,xn).executor.compileQuery(this.toOperationNode(),i(this,xn).queryId)}async execute(){await i(this,xn).executor.executeQuery(this.compile(),i(this,xn).queryId)}};xn=new WeakMap;let hc=Qf;$e(hc,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const Ap=m({is(t){return t.kind==="DropTypeNode"},create(t){return m({kind:"DropTypeNode",name:t})},cloneWith(t,e){return m({...t,...e})}});var On;const jf=class jf{constructor(e){D(this,On,void 0);z(this,On,m(e))}ifExists(){return new jf({...i(this,On),node:Ap.cloneWith(i(this,On).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,On).executor.transformQuery(i(this,On).node,i(this,On).queryId)}compile(){return i(this,On).executor.compileQuery(this.toOperationNode(),i(this,On).queryId)}async execute(){await i(this,On).executor.executeQuery(this.compile(),i(this,On).queryId)}};On=new WeakMap;let dc=jf;$e(dc,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function Wh(t){const e=".";if(t.includes(e)){const n=t.split(e).map(ib);if(n.length===2)return hi.createWithSchema(n[0],n[1]);throw new Error(`invalid schemable identifier ${t}`)}else return hi.create(t)}function ib(t){return t.trim()}var It;const pa=class pa{constructor(e){D(this,It,void 0);z(this,It,e)}createTable(e){return new oc({queryId:nt(),executor:i(this,It),node:jn.create(mn(e))})}dropTable(e){return new cc({queryId:nt(),executor:i(this,It),node:Ml.create(mn(e))})}createIndex(e){return new ic({queryId:nt(),executor:i(this,It),node:Vr.create(e)})}dropIndex(e){return new ac({queryId:nt(),executor:i(this,It),node:Wu.create(e)})}createSchema(e){return new sc({queryId:nt(),executor:i(this,It),node:Jd.create(e)})}dropSchema(e){return new uc({queryId:nt(),executor:i(this,It),node:Pl.create(e)})}alterTable(e){return new Cp({queryId:nt(),executor:i(this,It),node:vt.create(mn(e))})}createView(e){return new lc({queryId:nt(),executor:i(this,It),node:Kr.create(e)})}dropView(e){return new fc({queryId:nt(),executor:i(this,It),node:Pu.create(e)})}createType(e){return new hc({queryId:nt(),executor:i(this,It),node:Sp.create(Wh(e))})}dropType(e){return new dc({queryId:nt(),executor:i(this,It),node:Ap.create(Wh(e))})}withPlugin(e){return new pa(i(this,It).withPlugin(e))}withoutPlugins(){return new pa(i(this,It).withoutPlugins())}withSchema(e){return new pa(i(this,It).withPluginAtFront(new tu(e)))}};It=new WeakMap;let Jl=pa;class sb{ref(e){return new cg(e)}}var lo;class ob{constructor(e){D(this,lo,void 0);z(this,lo,e)}async provideConnection(e){const n=await i(this,lo).acquireConnection();try{return await e(n)}finally{await i(this,lo).releaseConnection(n)}}}lo=new WeakMap;var hr,dr,Cr;const ji=class ji extends dp{constructor(n,r,a,l=[]){super(l);D(this,hr,void 0);D(this,dr,void 0);D(this,Cr,void 0);z(this,hr,n),z(this,dr,r),z(this,Cr,a)}get adapter(){return i(this,dr)}compileQuery(n){return i(this,hr).compileQuery(n)}provideConnection(n){return i(this,Cr).provideConnection(n)}withPlugins(n){return new ji(i(this,hr),i(this,dr),i(this,Cr),[...this.plugins,...n])}withPlugin(n){return new ji(i(this,hr),i(this,dr),i(this,Cr),[...this.plugins,n])}withPluginAtFront(n){return new ji(i(this,hr),i(this,dr),i(this,Cr),[n,...this.plugins])}withConnectionProvider(n){return new ji(i(this,hr),i(this,dr),n,[...this.plugins])}withoutPlugins(){return new ji(i(this,hr),i(this,dr),i(this,Cr),[])}};hr=new WeakMap,dr=new WeakMap,Cr=new WeakMap;let Gl=ji;function Rh(){return typeof performance<"u"&&Ln(performance.now)?performance.now():Date.now()}var Gn,ti,qr,Zi,Ma,Sc,Ip,Ac,Tp,Ic,kp,Tc,Wp,Ba,Yl;class ab{constructor(e,n){D(this,Sc);D(this,Ac);D(this,Ic);D(this,Tc);D(this,Ba);D(this,Gn,void 0);D(this,ti,void 0);D(this,qr,void 0);D(this,Zi,void 0);D(this,Ma,new WeakSet);z(this,Gn,e),z(this,ti,n)}async init(){i(this,qr)||z(this,qr,i(this,Gn).init().catch(e=>(z(this,qr,void 0),Promise.reject(e)))),await i(this,qr)}async acquireConnection(){await this.init();const e=await i(this,Gn).acquireConnection();return i(this,Ma).has(e)||(_e(this,Sc,Ip).call(this)&&_e(this,Ac,Tp).call(this,e),i(this,Ma).add(e)),e}async releaseConnection(e){await i(this,Gn).releaseConnection(e)}beginTransaction(e,n){return i(this,Gn).beginTransaction(e,n)}commitTransaction(e){return i(this,Gn).commitTransaction(e)}rollbackTransaction(e){return i(this,Gn).rollbackTransaction(e)}async destroy(){i(this,qr)&&(await i(this,qr),i(this,Zi)||z(this,Zi,i(this,Gn).destroy().catch(e=>(z(this,Zi,void 0),Promise.reject(e)))),await i(this,Zi))}}Gn=new WeakMap,ti=new WeakMap,qr=new WeakMap,Zi=new WeakMap,Ma=new WeakMap,Sc=new WeakSet,Ip=function(){return i(this,ti).isLevelEnabled("query")||i(this,ti).isLevelEnabled("error")},Ac=new WeakSet,Tp=function(e){const n=e.executeQuery;e.executeQuery=async r=>{const a=Rh();try{return await n.call(e,r)}catch(l){throw await _e(this,Ic,kp).call(this,l,r,a),l}finally{await _e(this,Tc,Wp).call(this,r,a)}}},Ic=new WeakSet,kp=async function(e,n,r){await i(this,ti).error(()=>({level:"error",error:e,query:n,queryDurationMillis:_e(this,Ba,Yl).call(this,r)}))},Tc=new WeakSet,Wp=async function(e,n){await i(this,ti).query(()=>({level:"query",query:e,queryDurationMillis:_e(this,Ba,Yl).call(this,n)}))},Ba=new WeakSet,Yl=function(e){return Rh()-e};var Fa,ni,kc,Dp;class Rp{constructor(e){D(this,kc);D(this,Fa,void 0);D(this,ni,void 0);z(this,Fa,e)}async provideConnection(e){for(;i(this,ni);)await i(this,ni);const n=_e(this,kc,Dp).call(this,e);return z(this,ni,n.then(()=>{z(this,ni,void 0)}).catch(()=>{z(this,ni,void 0)})),n}}Fa=new WeakMap,ni=new WeakMap,kc=new WeakSet,Dp=async function(e){return await e(i(this,Fa))};const ub=["read uncommitted","read committed","repeatable read","serializable"];m(["query","error"]);var ri,es;class cb{constructor(e){D(this,ri,void 0);D(this,es,void 0);Ln(e)?(z(this,es,e),z(this,ri,m({query:!0,error:!0}))):(z(this,es,lb),z(this,ri,m({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return i(this,ri)[e]}async query(e){i(this,ri).query&&await i(this,es).call(this,e())}async error(e){i(this,ri).error&&await i(this,es).call(this,e())}}ri=new WeakMap,es=new WeakMap;function lb(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 fb(t){return wr(t)&&Ln(t.compile)}var Bt;const $s=class $s extends Zu{constructor(n){let r,a;if(hb(n))r={executor:n.executor},a={...n};else{const l=n.dialect,p=l.createDriver(),w=l.createQueryCompiler(),v=l.createAdapter(),d=new cb(n.log??[]),A=new ab(p,d),B=new ob(A),F=new Gl(w,v,B,n.plugins??[]);r={executor:F},a={config:n,executor:F,dialect:l,driver:A}}super(r);D(this,Bt,void 0);z(this,Bt,m(a))}get schema(){return new Jl(i(this,Bt).executor)}get dynamic(){return new sb}get introspection(){return i(this,Bt).dialect.createIntrospector(this.withoutPlugins())}case(n){return new yp({node:gr.create(Ks(n)?void 0:nl(n))})}get fn(){return mp()}transaction(){return new pc({...i(this,Bt)})}connection(){return new Lp({...i(this,Bt)})}withPlugin(n){return new $s({...i(this,Bt),executor:i(this,Bt).executor.withPlugin(n)})}withoutPlugins(){return new $s({...i(this,Bt),executor:i(this,Bt).executor.withoutPlugins()})}withSchema(n){return new $s({...i(this,Bt),executor:i(this,Bt).executor.withPluginAtFront(new tu(n))})}withTables(){return new $s({...i(this,Bt)})}async destroy(){await i(this,Bt).driver.destroy()}get isTransaction(){return!1}getExecutor(){return i(this,Bt).executor}executeQuery(n,r=nt()){const a=fb(n)?n.compile():n;return this.getExecutor().executeQuery(a,r)}};Bt=new WeakMap;let Ia=$s;var Yn;const Qs=class Qs extends Ia{constructor(n){super(n);D(this,Yn,void 0);z(this,Yn,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 Qs({...i(this,Yn),executor:i(this,Yn).executor.withPlugin(n)})}withoutPlugins(){return new Qs({...i(this,Yn),executor:i(this,Yn).executor.withoutPlugins()})}withSchema(n){return new Qs({...i(this,Yn),executor:i(this,Yn).executor.withPluginAtFront(new tu(n))})}withTables(){return new Qs({...i(this,Yn)})}};Yn=new WeakMap;let Xl=Qs;function hb(t){return wr(t)&&wr(t.config)&&wr(t.driver)&&wr(t.executor)&&wr(t.dialect)}var ts;class Lp{constructor(e){D(this,ts,void 0);z(this,ts,m(e))}async execute(e){return i(this,ts).executor.provideConnection(async n=>{const r=i(this,ts).executor.withConnectionProvider(new Rp(n)),a=new Ia({...i(this,ts),executor:r});return await e(a)})}}ts=new WeakMap;$e(Lp,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");var Xn;const Vf=class Vf{constructor(e){D(this,Xn,void 0);z(this,Xn,m(e))}setIsolationLevel(e){return new Vf({...i(this,Xn),isolationLevel:e})}async execute(e){const{isolationLevel:n,...r}=i(this,Xn),a={isolationLevel:n};return db(a),i(this,Xn).executor.provideConnection(async l=>{const p=i(this,Xn).executor.withConnectionProvider(new Rp(l)),w=new Xl({...r,executor:p});try{await i(this,Xn).driver.beginTransaction(l,a);const v=await e(w);return await i(this,Xn).driver.commitTransaction(l),v}catch(v){throw await i(this,Xn).driver.rollbackTransaction(l),v}})}};Xn=new WeakMap;let pc=Vf;$e(pc,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function db(t){if(t.isolationLevel&&!ub.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}var fn,fo,Mu,Ua,Zl,$a,ef;const Wc=class Wc{constructor(e){D(this,fo);D(this,Ua);D(this,$a);D(this,fn,void 0);z(this,fn,m(e))}get expressionType(){}as(e){return new pb(this,e)}$castTo(){return new Wc({...i(this,fn)})}castTo(){return this.$castTo()}withPlugin(e){return new Wc({...i(this,fn),plugins:i(this,fn).plugins!==void 0?m([...i(this,fn).plugins,e]):m([e])})}toOperationNode(){return _e(this,Ua,Zl).call(this,_e(this,fo,Mu).call(this))}compile(e){return _e(this,$a,ef).call(this,_e(this,fo,Mu).call(this,e))}async execute(e){const n=_e(this,fo,Mu).call(this,e);return n.executeQuery(_e(this,$a,ef).call(this,n),i(this,fn).queryId)}};fn=new WeakMap,fo=new WeakSet,Mu=function(e){const n=e!==void 0?e.getExecutor():Wf;return i(this,fn).plugins!==void 0?n.withPlugins(i(this,fn).plugins):n},Ua=new WeakSet,Zl=function(e){return e.transformQuery(i(this,fn).rawNode,i(this,fn).queryId)},$a=new WeakSet,ef=function(e){return e.compileQuery(_e(this,Ua,Zl).call(this,e),i(this,fn).queryId)};let zn=Wc;$e(zn,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");var ho,ii;class pb{constructor(e,n){D(this,ho,void 0);D(this,ii,void 0);z(this,ho,e),z(this,ii,n)}get expression(){return i(this,ho)}get alias(){return i(this,ii)}toOperationNode(){return pi.create(i(this,ho).toOperationNode(),Pn(i(this,ii))?i(this,ii).toOperationNode():ct.create(i(this,ii)))}}ho=new WeakMap,ii=new WeakMap;const Cn=Object.assign((t,...e)=>new zn({queryId:nt(),rawNode:tn.create(t,(e==null?void 0:e.map(Ir))??[])}),{ref(t){return new zn({queryId:nt(),rawNode:tn.createWithChild(hs(t))})},val(t){return new zn({queryId:nt(),rawNode:tn.createWithChild(Ir(t))})},value(t){return this.val(t)},table(t){return new zn({queryId:nt(),rawNode:tn.createWithChild(mn(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new zn({queryId:nt(),rawNode:tn.create(e,t.map(ct.create))})},lit(t){return new zn({queryId:nt(),rawNode:tn.createWithChild(ir.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new zn({queryId:nt(),rawNode:tn.createWithSql(t)})},join(t,e=Cn`, `){const n=new Array(2*t.length-1),r=e.toOperationNode();for(let a=0;a{this.nodeStack.push(e),i(this,Rc)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Rc=new WeakMap;var po,ns;class yb extends mb{constructor(){super(...arguments);D(this,po,"");D(this,ns,[])}get numParameters(){return i(this,ns).length}compileQuery(n){return z(this,po,""),z(this,ns,[]),this.visitNode(n),m({query:n,sql:this.getSql(),parameters:[...i(this,ns)]})}getSql(){return i(this,po)}visitSelectQuery(n){const r=this.parentNode!==void 0&&!mr.is(this.parentNode)&&!Kr.is(this.parentNode)&&!pp.is(this.parentNode);this.parentNode===void 0&&n.explain&&(this.visitNode(n.explain),this.append(" ")),r&&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," ")),r&&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,r=", "){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 r=this.nodeStack.find(Re.is)!==n;!r&&n.explain&&(this.visitNode(n.explain),this.append(" ")),r&&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)),r&&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(wb[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 _a.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))}visitJSONReference(n){this.visitNode(n.reference),this.visitNode(n.traversal)}visitJSONPath(n){n.inOperator&&this.visitNode(n.inOperator),this.append("'$");for(const r of n.pathLegs)this.visitNode(r);this.append("'")}visitJSONPathLeg(n){const r=n.type==="ArrayLocation";this.append(r?"[":"."),this.append(String(n.value)),r&&this.append("]")}visitJSONOperatorChain(n){for(let r=0,a=n.values.length;r"),this.visitNode(n.values[r])}append(n){z(this,po,i(this,po)+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 r=this.getLeftIdentifierWrapper(),a=this.getRightIdentifierWrapper();let l="";for(const p of n)l+=p,p===r?l+=r:p===a&&(l+=a);return l}addParameter(n){i(this,ns).push(n)}appendImmediateValue(n){if(Dn(n))this.append(`'${n}'`);else if(Lw(n)||Hd(n))this.append(n.toString());else if(Kd(n))this.append("null");else if(Pw(n))this.appendImmediateValue(n.toISOString());else if(Mw(n))this.appendImmediateValue(n.toString());else throw new Error(`invalid immediate value ${n}`)}}po=new WeakMap,ns=new WeakMap;const wb=m({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),gb=m({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),dn=m({raw(t,e=[]){return m({sql:t,query:tn.createWithSql(t),parameters:m(e)})}}),bb=/"/g;class Pp extends yb{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(bb,'""')}visitDefaultInsertValue(e){this.append("null")}}const Nb="kysely_migration",vb="kysely_migration_lock";m({__noMigrations__:!0});var mo,Dc,Bp;class Mp{constructor(e){D(this,Dc);D(this,mo,void 0);z(this,mo,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let n=i(this,mo).selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(n=n.where("name","!=",Nb).where("name","!=",vb));const r=await n.execute();return Promise.all(r.map(({name:a})=>_e(this,Dc,Bp).call(this,a)))}async getMetadata(e){return{tables:await this.getTables(e)}}}mo=new WeakMap,Dc=new WeakSet,Bp=async function(e){var p,w,v,d,A,B;const n=i(this,mo),r=await n.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),a=(B=(A=(d=(v=(w=(p=r.sql)==null?void 0:p.split(/[\(\),]/))==null?void 0:w.find(F=>F.toLowerCase().includes("autoincrement")))==null?void 0:v.trimStart())==null?void 0:d.split(/\s+/))==null?void 0:A[0])==null?void 0:B.replace(/["`]/g,""),l=await n.selectFrom(Cn`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:r.type==="view",columns:l.map(F=>({name:F.name,dataType:F.type,isNullable:!F.notnull,isAutoIncrementing:F.name===a,hasDefaultValue:F.dflt_value!=null}))}};class Fp{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Up=class{createQueryCompiler(){return new Pp}createAdapter(){return new Fp}createIntrospector(t){return new Mp(t)}},Qa,Hh,$p=(Hh=class{constructor(){D(this,Qa,new _b);ge(this,"connection")}async acquireConnection(){return await i(this,Qa).lock(),this.connection}async beginTransaction(t){await t.executeQuery(dn.raw("begin"))}async commitTransaction(t){await t.executeQuery(dn.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(dn.raw("rollback"))}async releaseConnection(){i(this,Qa).unlock()}},Qa=new WeakMap,Hh),_b=class{constructor(){ge(this,"promise");ge(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()}},Qp=class{streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:n,query:r}=t;return["SelectQueryNode","RawNode"].includes(r.kind)?{rows:await this.query(n,e)}:{rows:[],...await this.exec(n,e)}}};function xb({func:t,delay:e,maxCalls:n}){let r,a=0,l=null;function p(){r&&clearTimeout(r),a=0,l=null}function w(){a>=n?(t(l),p()):(r&&clearTimeout(r),r=setTimeout(()=>{t(l),p(),r=void 0},e))}return v=>{a++,l=v,r===void 0&&a===0?(t(v),a++):w()}}var Ob=class extends $p{constructor(e){super();ge(this,"config");ge(this,"db");this.config=e}async init(){var e,n,r,a,l,p;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 Eb(this.db,(e=this.config.onWrite)==null?void 0:e.func,(n=this.config.onWrite)==null?void 0:n.isThrottle,(r=this.config.onWrite)==null?void 0:r.maxCalls,(a=this.config.onWrite)==null?void 0:a.delay),await((p=(l=this.config).onCreateConnection)==null?void 0:p.call(l,this.connection))}async beginTransaction(e){await e.executeQuery(dn.raw("begin")),e.transactionNum++}async commitTransaction(e){await e.executeQuery(dn.raw("commit")),e.transactionNum--}async rollbackTransaction(e){await e.executeQuery(dn.raw("rollback")),e.transactionNum--}async destroy(){var e;(e=this.db)==null||e.close()}},Eb=class extends Qp{constructor(e,n,r=!1,a=1e3,l=2e3){super();ge(this,"db");ge(this,"onWrite");ge(this,"transactionNum",0);this.db=e,this.onWrite=n?r?xb({func:n,maxCalls:a,delay:l}):n:void 0}query(e,n){const r=this.db.prepare(e);r.bind(n);const a=[];for(;r.step();)a.push(r.getAsObject());return r.free(),a}exec(e,n){this.db.run(e,n);const r=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:r}}},ja,Kh,Cb=(Kh=class extends Up{constructor(e){super();D(this,ja,void 0);z(this,ja,e)}createDriver(){return new Ob(i(this,ja))}},ja=new WeakMap,Kh),qb=class extends $p{constructor(e){super();ge(this,"config");ge(this,"db");this.config=e}async init(){var e,n;this.db=typeof this.config.database=="function"?await this.config.database():this.config.database,this.connection=new Sb(this.db),await((n=(e=this.config).onCreateConnection)==null?void 0:n.call(e,this.connection))}async destroy(){var e;await((e=this.db)==null?void 0:e.sqlite.close(this.db.db))}},Sb=class extends Qp{constructor(e){super();ge(this,"sqlite");ge(this,"db");this.db=e.db,this.sqlite=e.sqlite}async run(e){const n=this.sqlite.str_new(this.db,e.sql),r=await this.sqlite.prepare_v2(this.db,this.sqlite.str_value(n));if(r===null)return[];const a=r.stmt;try{typeof e.param<"u"&&this.sqlite.bind_collection(a,e.param);const l=[];let p=[];for(;await this.sqlite.step(a)===100;){p=p.length===0?this.sqlite.column_names(a):p;const w=this.sqlite.row(a);l.push(p.reduce((v,d,A)=>(v[d]=w[A],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 r=await this.run({sql:"SELECT last_insert_rowid() as id"});return{insertId:BigInt(r[0].id),numAffectedRows:BigInt(this.sqlite.changes(this.db))}}},Va,Jh,Ab=(Jh=class extends Up{constructor(e){super();D(this,Va,void 0);z(this,Va,e)}createDriver(){return new qb(i(this,Va))}},Va=new WeakMap,Jh);function Ib(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Tb(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){if(this instanceof r){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(r){var a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:function(){return t[r]}})}),n}var jp={exports:{}};const kb={},Wb=Object.freeze(Object.defineProperty({__proto__:null,default:kb},Symbol.toStringTag,{value:"Module"})),Su=Tb(Wb);(function(t,e){var n=void 0,r=function(a){return n||(n=new Promise(function(l,p){var w=typeof a<"u"?a:{},v=w.onAbort;w.onAbort=function(o){p(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(S,J){switch(typeof J){case"boolean":bu(S,J?1:0);break;case"number":wu(S,J);break;case"string":Yo(S,J,-1,-1);break;case"object":if(J===null)Go(S);else if(J.length!=null){var s=Ss(J);gu(S,s,J.length,-1),Ii(s)}else Wi(S,"Wrong API use : tried to return a value of an unknown type ("+J+").",-1);break;default:Go(S)}}function c(S,J){for(var s=[],u=0;u>>0),S!=null){var J=this.filename,s="/",u=J;if(s&&(s=typeof s=="string"?s:yi(s),u=J?ue(s+"/"+J):s),J=on(!0,!0),u=gi(u,(J!==void 0?J:438)&4095|32768,0),S){if(typeof S=="string"){s=Array(S.length);for(var f=0,y=S.length;f{ne||(T=Su,ne=Su)},E=function(o,c){return ye(),o=ne.normalize(o),T.readFileSync(o,c?void 0:"utf8")},q=o=>(o=E(o,!0),o.buffer||(o=new Uint8Array(o)),o),N=(o,c,h)=>{ye(),o=ne.normalize(o),T.readFile(o,function(g,O){g?h(g):c(O.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),be=d.printErr||console.warn.bind(console);Object.assign(d,A),A=null,d.thisProgram&&(B=d.thisProgram);var Ne;d.wasmBinary&&(Ne=d.wasmBinary),d.noExitRuntime,typeof WebAssembly!="object"&&x("no native wasm support detected");var Ze,He=!1,Ot=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Et(o,c,h){var g=c+h;for(h=c;o[h]&&!(h>=g);)++h;if(16O?g+=String.fromCharCode(O):(O-=65536,g+=String.fromCharCode(55296|O>>10,56320|O&1023))}}else g+=String.fromCharCode(O)}return g}function Qe(o,c){return o?Et(qe,o,c):""}function $t(o,c,h,g){if(!(0=U){var we=o.charCodeAt(++R);U=65536+((U&1023)<<10)|we&1023}if(127>=U){if(h>=g)break;c[h++]=U}else{if(2047>=U){if(h+1>=g)break;c[h++]=192|U>>6}else{if(65535>=U){if(h+2>=g)break;c[h++]=224|U>>12}else{if(h+3>=g)break;c[h++]=240|U>>18,c[h++]=128|U>>12&63}c[h++]=128|U>>6&63}c[h++]=128|U&63}}return c[h]=0,h-O}function rn(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 ht,pe,qe,st,de,ke,Wt,br;function ds(){var o=Ze.buffer;ht=o,d.HEAP8=pe=new Int8Array(o),d.HEAP16=st=new Int16Array(o),d.HEAP32=de=new Int32Array(o),d.HEAPU8=qe=new Uint8Array(o),d.HEAPU16=new Uint16Array(o),d.HEAPU32=ke=new Uint32Array(o),d.HEAPF32=Wt=new Float32Array(o),d.HEAPF64=br=new Float64Array(o)}var wn,sn=[],fe=[],Pe=[];function Mn(){var o=d.preRun.shift();sn.unshift(o)}var Qt=0,Ke=null;function x(o){throw d.onAbort&&d.onAbort(o),o="Aborted("+o+")",be(o),He=!0,new WebAssembly.RuntimeError(o+". Build with -sASSERTIONS for more info.")}function C(){return W.startsWith("data:application/octet-stream;base64,")}var W;if(W="sql-wasm.wasm",!C()){var P=W;W=d.locateFile?d.locateFile(P,b):b+P}function H(){var o=W;try{if(o==W&&Ne)return new Uint8Array(Ne);if(q)return q(o);throw"both async and sync fetching of the wasm failed"}catch(c){x(c)}}function ee(){if(!Ne&&(F||Y)){if(typeof fetch=="function"&&!W.startsWith("file://"))return fetch(W,{credentials:"same-origin"}).then(function(o){if(!o.ok)throw"failed to load wasm binary file at '"+W+"'";return o.arrayBuffer()}).catch(function(){return H()});if(N)return new Promise(function(o,c){N(W,function(h){o(new Uint8Array(h))},c)})}return Promise.resolve().then(function(){return H()})}var $,V;function re(o){for(;0>0];case"i8":return pe[o>>0];case"i16":return st[o>>1];case"i32":return de[o>>2];case"i64":return de[o>>2];case"float":return Wt[o>>2];case"double":return br[o>>3];case"*":return ke[o>>2];default:x("invalid type for getValue: "+c)}return null}function ce(o){var c="i32";switch(c.endsWith("*")&&(c="*"),c){case"i1":pe[o>>0]=0;break;case"i8":pe[o>>0]=0;break;case"i16":st[o>>1]=0;break;case"i32":de[o>>2]=0;break;case"i64":V=[0,($=0,1<=+Math.abs($)?0<$?(Math.min(+Math.floor($/4294967296),4294967295)|0)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],de[o>>2]=V[0],de[o+4>>2]=V[1];break;case"float":Wt[o>>2]=0;break;case"double":br[o>>3]=0;break;case"*":ke[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 O=o[g];O==="."?o.splice(g,1):O===".."?(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},me=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)},Oe=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(X)try{var c=Su;return()=>c.randomBytes(1)[0]}catch{}return()=>x("randomDevice")}function De(){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 rt(o,c){var h=Array(rn(o)+1);return o=$t(o,h,0,h.length),c&&(h.length=o),h}var he=[];function gn(o,c){he[o]={input:[],output:[],Xa:c},wi(o,mi)}var mi={open:function(o){var c=he[o.node.rdev];if(!c)throw new Q(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 Q(60);for(var O=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-O,g),8c)throw new Q(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,O){if((o.node.mode&61440)!==32768)throw new Q(43);if(o=o.node.Ia,O&2||o.buffer!==ht){if((0{if(o=De("/",o),!o)return{path:"",node:null};if(c=Object.assign({rb:!0,kb:0},c),8!!U),!1);for(var h=Rt,g="/",O=0;O{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}},ys=(o,c)=>{for(var h=0,g=0;g>>0)%bn.length},Nr=o=>{var c=ys(o.parent.id,o.name);if(bn[c]===o)bn[c]=o.Wa;else for(c=bn[c];c;){if(c.Wa===o){c.Wa=o.Wa;break}c=c.Wa}},sr=(o,c)=>{var h;if(h=(h=Dr(o,"x"))?h:o.Ga.lookup?0:2)throw new Q(h,o);for(h=bn[ys(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)},Io=(o,c,h,g)=>(o=new Uo(o,c,h,g),c=ys(o.parent.id,o.name),o.Wa=bn[c],bn[c]=o),il={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},To=o=>{var c=["r","w","rw"][o&3];return o&512&&(c+="w"),c},Dr=(o,c)=>{if(ms)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},ws=(o,c)=>{try{return sr(o,c),20}catch{}return Dr(o,"wx")},ko=(o,c,h)=>{try{var g=sr(o,c)}catch(O){return O.Ka}if(o=Dr(o,"wx"))return o;if(h){if((g.mode&61440)!==16384)return 54;if(g===g.parent||yi(g)==="/")return 10}else if((g.mode&61440)===16384)return 31;return 0},Wo=(o=0)=>{for(;4096>=o;o++)if(!qn[o])return o;throw new Q(33)},Nn=(o,c)=>(Ei||(Ei=function(){this.$a={}},Ei.prototype={},Object.defineProperties(Ei.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 Ei,o),c=Wo(c),o.fd=c,qn[c]=o),gs={open:o=>{o.Ha=te[o.node.rdev].Ha,o.Ha.open&&o.Ha.open(o)},Ta:()=>{throw new Q(70)}},wi=(o,c)=>{te[o]={Ha:c}},Ro=(o,c)=>{var h=c==="/",g=!c;if(h&&Rt)throw new Q(10);if(!h&&!g){var O=Dt(c,{rb:!1});if(c=O.path,O=O.node,O.Va)throw new Q(10);if((O.mode&61440)!==16384)throw new Q(54)}c={type:o,Kb:{},ub:c,Eb:[]},o=o.Ra(c),o.Ra=c,c.root=o,h?Rt=o:O&&(O.Va=c,O.Ra&&O.Ra.Eb.push(c))},gi=(o,c,h)=>{var g=Dt(o,{parent:!0}).node;if(o=Oe(o),!o||o==="."||o==="..")throw new Q(28);var O=ws(g,o);if(O)throw new Q(O);if(!g.Ga.ab)throw new Q(63);return g.Ga.ab(g,o,c,h)},Yt=(o,c)=>gi(o,(c!==void 0?c:511)&1023|16384,0),bi=(o,c,h)=>{typeof h>"u"&&(h=c,c=438),gi(o,c|8192,h)},bs=(o,c)=>{if(!De(o))throw new Q(44);var h=Dt(c,{parent:!0}).node;if(!h)throw new Q(44);c=Oe(c);var g=ws(h,c);if(g)throw new Q(g);if(!h.Ga.symlink)throw new Q(63);h.Ga.symlink(h,c,o)},Do=o=>{var c=Dt(o,{parent:!0}).node;o=Oe(o);var h=sr(c,o),g=ko(c,o,!0);if(g)throw new Q(g);if(!c.Ga.rmdir)throw new Q(63);if(h.Va)throw new Q(10);c.Ga.rmdir(c,o),Nr(h)},Ni=o=>{var c=Dt(o,{parent:!0}).node;if(!c)throw new Q(44);o=Oe(o);var h=sr(c,o),g=ko(c,o,!1);if(g)throw new Q(g);if(!c.Ga.unlink)throw new Q(63);if(h.Va)throw new Q(10);c.Ga.unlink(c,o),Nr(h)},Lo=o=>{if(o=Dt(o).node,!o)throw new Q(44);if(!o.Ga.readlink)throw new Q(28);return De(yi(o.parent),o.Ga.readlink(o))},Lr=(o,c)=>{if(o=Dt(o,{Sa:!c}).node,!o)throw new Q(44);if(!o.Ga.Pa)throw new Q(63);return o.Ga.Pa(o)},Po=o=>Lr(o,!0),Ns=(o,c)=>{if(o=typeof o=="string"?Dt(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new Q(63);o.Ga.Oa(o,{mode:c&4095|o.mode&-4096,timestamp:Date.now()})},Pr=(o,c)=>{if(0>c)throw new Q(28);if(o=typeof o=="string"?Dt(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new Q(63);if((o.mode&61440)===16384)throw new Q(31);if((o.mode&61440)!==32768)throw new Q(28);var h=Dr(o,"w");if(h)throw new Q(h);o.Ga.Oa(o,{size:c,timestamp:Date.now()})},or=(o,c,h)=>{if(o==="")throw new Q(44);if(typeof c=="string"){var g=il[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 O=o;else{o=ue(o);try{O=Dt(o,{Sa:!(c&131072)}).node}catch{}}if(g=!1,c&64)if(O){if(c&128)throw new Q(20)}else O=gi(o,h,0),g=!0;if(!O)throw new Q(44);if((O.mode&61440)===8192&&(c&=-513),c&65536&&(O.mode&61440)!==16384)throw new Q(54);if(!g&&(h=O?(O.mode&61440)===40960?32:(O.mode&61440)===16384&&(To(c)!=="r"||c&512)?31:Dr(O,To(c)):44))throw new Q(h);return c&512&&!g&&Pr(O,0),c&=-131713,O=Nn({node:O,path:yi(O),flags:c,seekable:!0,position:0,Ha:O.Ha,Ib:[],error:!1}),O.Ha.open&&O.Ha.open(O),!d.logReadFiles||c&1||(Ci||(Ci={}),o in Ci||(Ci[o]=1)),O},Ve=o=>{if(o.fd===null)throw new Q(8);o.hb&&(o.hb=null);try{o.Ha.close&&o.Ha.close(o)}catch(c){throw c}finally{qn[o.fd]=null}o.fd=null},Mr=(o,c,h)=>{if(o.fd===null)throw new Q(8);if(!o.seekable||!o.Ha.Ta)throw new Q(70);if(h!=0&&h!=1&&h!=2)throw new Q(28);o.position=o.Ha.Ta(o,c,h),o.Ib=[]},vi=(o,c,h,g,O)=>{if(0>g||0>O)throw new Q(28);if(o.fd===null)throw new Q(8);if((o.flags&2097155)===1)throw new Q(8);if((o.node.mode&61440)===16384)throw new Q(31);if(!o.Ha.read)throw new Q(28);var R=typeof O<"u";if(!R)O=o.position;else if(!o.seekable)throw new Q(70);return c=o.Ha.read(o,c,h,g,O),R||(o.position+=c),c},ar=(o,c,h,g,O)=>{if(0>g||0>O)throw new Q(28);if(o.fd===null)throw new Q(8);if(!(o.flags&2097155))throw new Q(8);if((o.node.mode&61440)===16384)throw new Q(31);if(!o.Ha.write)throw new Q(28);o.seekable&&o.flags&1024&&Mr(o,0,2);var R=typeof O<"u";if(!R)O=o.position;else if(!o.seekable)throw new Q(70);return c=o.Ha.write(o,c,h,g,O,void 0),R||(o.position+=c),c},vs=o=>{var c,h=or(o,h||0);o=Lr(o).size;var g=new Uint8Array(o);return vi(h,g,0,o,0),c=g,Ve(h),c},_i=()=>{Q||(Q=function(o,c){this.node=c,this.Hb=function(h){this.Ka=h},this.Hb(o),this.message="FS error"},Q.prototype=Error(),Q.prototype.constructor=Q,[44].forEach(o=>{Bn[o]=new Q(o),Bn[o].stack=""}))},xi,on=(o,c)=>{var h=0;return o&&(h|=365),c&&(h|=146),h},Sn=(o,c,h)=>{o=ue("/dev/"+o);var g=on(!!c,!!h);Oi||(Oi=64);var O=Oi++<<8|0;wi(O,{open:R=>{R.seekable=!1},close:()=>{h&&h.buffer&&h.buffer.length&&h(10)},read:(R,U,we,Le)=>{for(var We=0,ot=0;ot{for(var We=0;We>2]=g.dev,de[h+8>>2]=g.ino,de[h+12>>2]=g.mode,ke[h+16>>2]=g.nlink,de[h+20>>2]=g.uid,de[h+24>>2]=g.gid,de[h+28>>2]=g.rdev,V=[g.size>>>0,($=g.size,1<=+Math.abs($)?0<$?(Math.min(+Math.floor($/4294967296),4294967295)|0)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],de[h+40>>2]=V[0],de[h+44>>2]=V[1],de[h+48>>2]=4096,de[h+52>>2]=g.blocks,V=[Math.floor(g.atime.getTime()/1e3)>>>0,($=Math.floor(g.atime.getTime()/1e3),1<=+Math.abs($)?0<$?(Math.min(+Math.floor($/4294967296),4294967295)|0)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],de[h+56>>2]=V[0],de[h+60>>2]=V[1],ke[h+64>>2]=0,V=[Math.floor(g.mtime.getTime()/1e3)>>>0,($=Math.floor(g.mtime.getTime()/1e3),1<=+Math.abs($)?0<$?(Math.min(+Math.floor($/4294967296),4294967295)|0)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],de[h+72>>2]=V[0],de[h+76>>2]=V[1],ke[h+80>>2]=0,V=[Math.floor(g.ctime.getTime()/1e3)>>>0,($=Math.floor(g.ctime.getTime()/1e3),1<=+Math.abs($)?0<$?(Math.min(+Math.floor($/4294967296),4294967295)|0)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],de[h+88>>2]=V[0],de[h+92>>2]=V[1],ke[h+96>>2]=0,V=[g.ino>>>0,($=g.ino,1<=+Math.abs($)?0<$?(Math.min(+Math.floor($/4294967296),4294967295)|0)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],de[h+104>>2]=V[0],de[h+108>>2]=V[1],0}var Br=void 0;function Si(){return Br+=4,de[Br-4>>2]}function an(o){if(o=qn[o],!o)throw new Q(8);return o}function _s(o){return ke[o>>2]+4294967296*de[o+4>>2]}function Mo(o){var c=rn(o)+1,h=Ai(c);return h&&$t(o,pe,h,c),h}function nu(o,c,h){function g(Le){return(Le=Le.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Le[1]:"GMT"}var O=new Date().getFullYear(),R=new Date(O,0,1),U=new Date(O,6,1);O=R.getTimezoneOffset();var we=U.getTimezoneOffset();de[o>>2]=60*Math.max(O,we),de[c>>2]=+(O!=we),o=g(R),c=g(U),o=Mo(o),c=Mo(c),we>2]=o,ke[h+4>>2]=c):(ke[h>>2]=c,ke[h+4>>2]=o)}function xs(o,c,h){xs.Bb||(xs.Bb=!0,nu(o,c,h))}var Bo;Bo=X?()=>{var o=process.hrtime();return 1e3*o[0]+o[1]/1e6}:()=>performance.now();var Os={};function Fo(){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",_:B||"./this.program"},c;for(c in Os)Os[c]===void 0?delete o[c]:o[c]=Os[c];var h=[];for(c in o)h.push(c+"="+o[c]);Es=h}return Es}var Es,Un=void 0,Cs=[];function qs(o,c){if(!Un){Un=new WeakMap;var h=wn.length;if(Un)for(var g=0;g<0+h;g++){var O=wn.get(g);O&&Un.set(O,g)}}if(Un.has(o))return Un.get(o);if(Cs.length)h=Cs.pop();else{try{wn.grow(1)}catch(we){throw we instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":we}h=wn.length-1}try{wn.set(h,o)}catch(we){if(!(we instanceof TypeError))throw we;if(typeof WebAssembly.Function=="function"){g=WebAssembly.Function,O={i:"i32",j:"i64",f:"f32",d:"f64",p:"i32"};for(var R={parameters:[],results:c[0]=="v"?[]:[O[c[0]]]},U=1;UU?g.push(U):g.push(U%128|128,U>>7),U=0;UO?c.push(O):c.push(O%128|128,O>>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}wn.set(h,c)}return Un.set(o,h),h}function Fr(o){Un.delete(wn.get(o)),Cs.push(o)}function Ss(o){var c=Ai(o.length);return o.subarray||o.slice||(o=new Uint8Array(o)),qe.set(o,c),c}function ru(o,c,h,g){var O={string:We=>{var ot=0;if(We!=null&&We!==0){var An=(We.length<<2)+1;ot=$n(An),$t(We,qe,ot,An)}return ot},array:We=>{var ot=$n(We.length);return pe.set(We,ot),ot}};o=d["_"+o];var R=[],U=0;if(g)for(var we=0;we{Yt("/dev"),wi(259,{read:()=>0,write:(c,h,g,O)=>O}),bi("/dev/null",259),gn(1280,jt),gn(1536,ps),bi("/dev/tty",1280),bi("/dev/tty1",1536);var o=je();Sn("random",o),Sn("urandom",o),Yt("/dev/shm"),Yt("/dev/shm/tmp")})(),(()=>{Yt("/proc");var o=Yt("/proc/self");Yt("/proc/self/fd"),Ro({Ra:()=>{var c=Io(o,"fd",16895,73);return c.Ga={lookup:(h,g)=>{var O=qn[+g];if(!O)throw new Q(8);return h={parent:null,Ra:{ub:"fake"},Ga:{readlink:()=>O.path}},h.parent=h}},c}},"/proc/self/fd")})();var iu={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),Ns(o,c),0}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return-h.Ka}},H:function(o,c,h){try{if(c=Qe(c),c=Fn(o,c),h&-8)return-28;var g=Dt(c,{Sa:!0}).node;return g?(o="",h&4&&(o+="r"),h&2&&(o+="w"),h&1&&(o+="x"),o&&Dr(g,o)?-2:0):-44}catch(O){if(typeof Je>"u"||!(O instanceof Q))throw O;return-O.Ka}},i:function(o,c){try{var h=qn[o];if(!h)throw new Q(8);return Ns(h.node,c),0}catch(g){if(typeof Je>"u"||!(g instanceof Q))throw g;return-g.Ka}},g:function(o){try{var c=qn[o];if(!c)throw new Q(8);var h=c.node,g=typeof h=="string"?Dt(h,{Sa:!0}).node:h;if(!g.Ga.Oa)throw new Q(63);return g.Ga.Oa(g,{timestamp:Date.now()}),0}catch(O){if(typeof Je>"u"||!(O instanceof Q))throw O;return-O.Ka}},b:function(o,c,h){Br=h;try{var g=an(o);switch(c){case 0:var O=Si();return 0>O?-28:Nn(g,O).fd;case 1:case 2:return 0;case 3:return g.flags;case 4:return O=Si(),g.flags|=O,0;case 5:return O=Si(),st[O+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return de[$o()>>2]=28,-1;default:return-28}}catch(R){if(typeof Je>"u"||!(R instanceof Q))throw R;return-R.Ka}},G:function(o,c){try{var h=an(o);return qi(Lr,h.path,c)}catch(g){if(typeof Je>"u"||!(g instanceof Q))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=qn[o];if(!g)throw new Q(8);if(!(g.flags&2097155))throw new Q(28);return Pr(g.node,c),0}catch(O){if(typeof Je>"u"||!(O instanceof Q))throw O;return-O.Ka}},B:function(o,c){try{if(c===0)return-28;var h=rn("/")+1;return c"u"||!(g instanceof Q))throw g;return-g.Ka}},E:function(o,c){try{return o=Qe(o),qi(Po,o,c)}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return-h.Ka}},y:function(o,c,h){try{return c=Qe(c),c=Fn(o,c),c=ue(c),c[c.length-1]==="/"&&(c=c.substr(0,c.length-1)),Yt(c,h),0}catch(g){if(typeof Je>"u"||!(g instanceof Q))throw g;return-g.Ka}},D:function(o,c,h,g){try{c=Qe(c);var O=g&256;return c=Fn(o,c,g&4096),qi(O?Po:Lr,c,h)}catch(R){if(typeof Je>"u"||!(R instanceof Q))throw R;return-R.Ka}},v:function(o,c,h,g){Br=g;try{c=Qe(c),c=Fn(o,c);var O=g?Si():0;return or(c,h,O).fd}catch(R){if(typeof Je>"u"||!(R instanceof Q))throw R;return-R.Ka}},t:function(o,c,h,g){try{if(c=Qe(c),c=Fn(o,c),0>=g)return-28;var O=Lo(c),R=Math.min(g,rn(O)),U=pe[h+R];return $t(O,qe,h,g+1),pe[h+R]=U,R}catch(we){if(typeof Je>"u"||!(we instanceof Q))throw we;return-we.Ka}},s:function(o){try{return o=Qe(o),Do(o),0}catch(c){if(typeof Je>"u"||!(c instanceof Q))throw c;return-c.Ka}},F:function(o,c){try{return o=Qe(o),qi(Lr,o,c)}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return-h.Ka}},p:function(o,c,h){try{return c=Qe(c),c=Fn(o,c),h===0?Ni(c):h===512?Do(c):x("Invalid flags passed to unlinkat"),0}catch(g){if(typeof Je>"u"||!(g instanceof Q))throw g;return-g.Ka}},o:function(o,c,h){try{if(c=Qe(c),c=Fn(o,c,!0),h){var g=_s(h),O=de[h+8>>2];R=1e3*g+O/1e6,h+=16,g=_s(h),O=de[h+8>>2],U=1e3*g+O/1e6}else var R=Date.now(),U=R;o=R;var we=Dt(c,{Sa:!0}).node;return we.Ga.Oa(we,{timestamp:Math.max(o,U)}),0}catch(Le){if(typeof Je>"u"||!(Le instanceof Q))throw Le;return-Le.Ka}},e:function(){return Date.now()},j:function(o,c){o=new Date(1e3*_s(o)),de[c>>2]=o.getSeconds(),de[c+4>>2]=o.getMinutes(),de[c+8>>2]=o.getHours(),de[c+12>>2]=o.getDate(),de[c+16>>2]=o.getMonth(),de[c+20>>2]=o.getFullYear()-1900,de[c+24>>2]=o.getDay();var h=new Date(o.getFullYear(),0,1);de[c+28>>2]=(o.getTime()-h.getTime())/864e5|0,de[c+36>>2]=-(60*o.getTimezoneOffset());var g=new Date(o.getFullYear(),6,1).getTimezoneOffset();h=h.getTimezoneOffset(),de[c+32>>2]=(g!=h&&o.getTimezoneOffset()==Math.min(h,g))|0},w:function(o,c,h,g,O,R){try{var U=an(g);if(c&2&&!(h&2)&&(U.flags&2097155)!==2)throw new Q(2);if((U.flags&2097155)===1)throw new Q(2);if(!U.Ha.bb)throw new Q(43);var we=U.Ha.bb(U,o,O,c,h),Le=we.Fb;return de[R>>2]=we.vb,Le}catch(We){if(typeof Je>"u"||!(We instanceof Q))throw We;return-We.Ka}},x:function(o,c,h,g,O,R){try{var U=an(O);if(h&2){var we=qe.slice(o,o+c);U&&U.Ha.cb&&U.Ha.cb(U,we,R,c,g)}}catch(Le){if(typeof Je>"u"||!(Le instanceof Q))throw Le;return-Le.Ka}},n:xs,q:function(){return 2147483648},d:Bo,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 O=Math;g=Math.max(o,g),O=O.min.call(O,2147483648,g+(65536-g%65536)%65536);e:{try{Ze.grow(O-ht.byteLength+65535>>>16),ds();var R=1;break e}catch{}R=void 0}if(R)return!0}return!1},z:function(o,c){var h=0;return Fo().forEach(function(g,O){var R=c+h;for(O=ke[o+4*O>>2]=R,R=0;R>0]=g.charCodeAt(R);pe[O>>0]=0,h+=g.length+1}),0},A:function(o,c){var h=Fo();ke[o>>2]=h.length;var g=0;return h.forEach(function(O){g+=O.length+1}),ke[c>>2]=g,0},f:function(o){try{var c=an(o);return Ve(c),0}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return h.Ka}},m:function(o,c){try{var h=an(o);return pe[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 Q))throw g;return g.Ka}},u:function(o,c,h,g){try{e:{var O=an(o);o=c;for(var R=c=0;R>2],we=ke[o+4>>2];o+=8;var Le=vi(O,pe,U,we);if(0>Le){var We=-1;break e}if(c+=Le,Le>2]=We,0}catch(ot){if(typeof Je>"u"||!(ot instanceof Q))throw ot;return ot.Ka}},k:function(o,c,h,g,O){try{if(c=h+2097152>>>0<4194305-!!c?(c>>>0)+4294967296*h:NaN,isNaN(c))return 61;var R=an(o);return Mr(R,c,g),V=[R.position>>>0,($=R.position,1<=+Math.abs($)?0<$?(Math.min(+Math.floor($/4294967296),4294967295)|0)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],de[O>>2]=V[0],de[O+4>>2]=V[1],R.hb&&c===0&&g===0&&(R.hb=null),0}catch(U){if(typeof Je>"u"||!(U instanceof Q))throw U;return U.Ka}},C:function(o){try{var c=an(o);return c.Ha&&c.Ha.fsync?c.Ha.fsync(c):0}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return h.Ka}},r:function(o,c,h,g){try{e:{var O=an(o);o=c;for(var R=c=0;R>2],we=ke[o+4>>2];o+=8;var Le=ar(O,pe,U,we);if(0>Le){var We=-1;break e}c+=Le}We=c}return ke[g>>2]=We,0}catch(ot){if(typeof Je>"u"||!(ot instanceof Q))throw ot;return ot.Ka}}};(function(){function o(O){d.asm=O.exports,Ze=d.asm.I,ds(),wn=d.asm.Aa,fe.unshift(d.asm.J),Qt--,d.monitorRunDependencies&&d.monitorRunDependencies(Qt),Qt==0&&Ke&&(O=Ke,Ke=null,O())}function c(O){o(O.instance)}function h(O){return ee().then(function(R){return WebAssembly.instantiate(R,g)}).then(function(R){return R}).then(O,function(R){be("failed to asynchronously prepare wasm: "+R),x(R)})}var g={a:iu};if(Qt++,d.monitorRunDependencies&&d.monitorRunDependencies(Qt),d.instantiateWasm)try{return d.instantiateWasm(g,o)}catch(O){return be("Module.instantiateWasm callback failed with error: "+O),!1}return function(){return Ne||typeof WebAssembly.instantiateStreaming!="function"||C()||W.startsWith("file://")||X||typeof fetch!="function"?h(c):fetch(W,{credentials:"same-origin"}).then(function(O){return WebAssembly.instantiateStreaming(O,g).then(c,function(R){return be("wasm streaming compile failed: "+R),be("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 $o=d.___errno_location=function(){return($o=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 Ai=d._malloc=function(){return(Ai=d._malloc=d.asm.ya).apply(null,arguments)},Ii=d._free=function(){return(Ii=d._free=d.asm.za).apply(null,arguments)};d._RegisterExtensionFunctions=function(){return(d._RegisterExtensionFunctions=d.asm.Ba).apply(null,arguments)};var Qo=d._emscripten_builtin_memalign=function(){return(Qo=d._emscripten_builtin_memalign=d.asm.Ca).apply(null,arguments)},Ur=d.stackSave=function(){return(Ur=d.stackSave=d.asm.Da).apply(null,arguments)},$r=d.stackRestore=function(){return($r=d.stackRestore=d.asm.Ea).apply(null,arguments)},$n=d.stackAlloc=function(){return($n=d.stackAlloc=d.asm.Fa).apply(null,arguments)};d.UTF8ToString=Qe,d.stackAlloc=$n,d.stackSave=Ur,d.stackRestore=$r,d.cwrap=function(o,c,h,g){h=h||[];var O=h.every(R=>R==="number"||R==="boolean");return c!=="string"&&O&&!g?d["_"+o]:function(){return ru(o,c,h,arguments)}};var Ti;Ke=function o(){Ti||jo(),Ti||(Ke=o)};function jo(){function o(){if(!Ti&&(Ti=!0,d.calledRun=!0,!He)){if(d.noFSInit||xi||(xi=!0,_i(),d.stdin=d.stdin,d.stdout=d.stdout,d.stderr=d.stderr,d.stdin?Sn("stdin",d.stdin):bs("/dev/tty","/dev/stdin"),d.stdout?Sn("stdout",null,d.stdout):bs("/dev/tty","/dev/stdout"),d.stderr?Sn("stderr",null,d.stderr):bs("/dev/tty1","/dev/stderr"),or("/dev/stdin",0),or("/dev/stdout",1),or("/dev/stderr",1)),ms=!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();Pe.unshift(c)}re(Pe)}}if(!(0=this._size)return 0;const r=this._data.subarray(e,Math.min(this._size,e+n.length));return n.set(r),r.length}reserve(e){if(this._data.length>=e)return;const n=e-this._data.length,r=Math.min(Bb,Math.max(Mb,this._data.length)),a=new Uint8Array(this._data.length+Math.max(r,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 Ub=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,Bf=new Promise((t,e)=>{const n=Ub.open(Pb,1);n.onupgradeneeded=()=>n.result.createObjectStore("files",{keyPath:"name"}),n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)});async function $b(t){const e=await Bf,n=await new Promise((r,a)=>{const p=e.transaction("files","readonly").objectStore("files").get(t);p.onsuccess=()=>r(p.result),p.onerror=()=>a(p.error)});if(n&&!Fs.has(t)){const r=new Fb(n.data);return Fs.set(t,r),r}else return Fs.has(t)?Fs.get(t):null}async function Qb(t,e){const n=await Bf;await new Promise((r,a)=>{const p=n.transaction("files","readwrite").objectStore("files").put({name:t,data:e});p.onsuccess=()=>r(!0),p.onerror=()=>a(p.error)})}async function Dh(t){const e=await Bf;await new Promise((n,r)=>{const l=e.transaction("files","readwrite").objectStore("files").delete(t);l.onsuccess=()=>n(!0),l.onerror=()=>r(l.error)})}async function jb(t,e){if(await Qb(t,e),Fs.has(t)){const n=Fs.get(t);n.truncate(0),n.write(0,e)}}var Vb=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),zb=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,r)=>typeof r=="string"&&e.exec(r)?new Date(r):r)}catch{}}return t},Hb=class extends kf{constructor(e){super();ge(this,"serializer");this.serializer=e||Vb}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:r,...a}=n,l=this.serializer(r);return r===l?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...a,value:l}})}transformValue(e){return{...e,value:this.serializer(e.value)}}},Kb=class{constructor({deserializer:t,serializer:e}={}){ge(this,"serializeParametersTransformer");ge(this,"deserializer");ge(this,"ctx");this.serializeParametersTransformer=new Hb(e),this.deserializer=t||zb,this.ctx=new WeakMap}transformQuery({node:t,queryId:e}){return t.kind==="SelectQueryNode"&&this.ctx.set(e,t.kind),this.serializeParametersTransformer.transformNode(t)}async parseResult(t){return await Promise.all(t.map(async e=>{const n={...e};for(const r in n)n[r]=await this.deserializer(n[r]);return n}))}async transformResult({result:t,queryId:e}){const{rows:n}=t,r=this.ctx.get(e);return this.ctx.delete(e),n&&r==="SelectQueryNode"?{...t,rows:await this.parseResult(n)}:t}};function vl(t){return typeof t=="string"}function Jb(t){return typeof t=="boolean"}async function Lh(t,e,n,r,a="rowid"){await Cn` - create trigger if not exists ${Cn.raw(e)}_${Cn.raw(r)} - after ${Cn.raw(n)} - on ${Cn.table(e)} - begin - update ${Cn.table(e)} - set ${Cn.ref(r)} = datetime('now','localtime') - where ${Cn.ref(a)} = NEW.${Cn.ref(a)}; - end - `.execute(t).catch(l=>{console.error(l)})}function Gb(t){const e=new Map;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const r=t[n];e.set(n,r)}return e}async function Yb(t,e,n=!1){for(const[r,a]of e){const{columns:l,property:p}=a;n&&await t.schema.dropTable(r).ifExists().execute().catch();let w=t.schema.createTable(r),v="rowid",d=!1,A="createAt",B="updateAt";if(p!=null&&p.timestamp&&!Jb(p.timestamp)){const{create:F,update:Y}=p.timestamp;A=F??"createAt",B=Y??"updateAt"}for(const F in l){if(!Object.prototype.hasOwnProperty.call(l,F))continue;const Y=l[F];let X="text";const{type:b,notNull:E,defaultTo:N}=Y;switch(b){case"boolean":case"date":case"object":case"string":X="text";break;case"increments":v=F;case"number":X="integer";break;case"blob":X="blob"}[A,B].includes(F)||(w=w.addColumn(F,X,q=>b==="increments"?(d=!0,q.autoIncrement().primaryKey()):(E&&(q=q.notNull()),N!==void 0&&(q=q.defaultTo(N instanceof Function?N(Cn):N)),q)))}if(p){const F=p.primary,Y=p.unique;if(p.timestamp&&(A&&(w=w.addColumn(A,"text")),B&&(w=w.addColumn(B,"text"))),!d&&F){const X=vl(F);v=X?F:F[0],w=w.addPrimaryKeyConstraint(`pk_${X?F:F.join("_")}`,X?[F]:F)}Y==null||Y.forEach(X=>{const b=vl(X);v=!F&&!d?b?X:X[0]:v,w=w.addUniqueConstraint(`un_${b?X:X.join("_")}`,b?[X]:X)})}if(await w.ifNotExists().execute(),p!=null&&p.index)for(const F of p.index){const Y=vl(F);let X=t.schema.createIndex(`idx_${Y?F:F.join("_")}`).on(r);X=Y?X.column(F):X.columns(F),await X.ifNotExists().execute()}p!=null&&p.timestamp&&(A&&await Lh(t,r,"insert",A,v),B&&await Lh(t,r,"update",B,v))}}var Xb=class{constructor(){ge(this,"items");this.items=[]}push(t){this.items.push(t)}pop(){return this.items.pop()}peek(){return this.items[this.items.length-1]}isEmpty(){return this.items.length===0}size(){return this.items.length}},Zb=class{constructor(t){ge(this,"kysely");ge(this,"status");ge(this,"tableMap");ge(this,"logger");ge(this,"trxs");const{dialect:e,tables:n,dropTableBeforeInit:r,onQuery:a,plugins:l,logger:p}=t;this.logger=p;const w=l??[];w.push(new Kb),this.kysely=new Ia({dialect:e,log:v=>{var d;v.level==="error"?(d=this.logger)==null||d.error("Uncaught DB Error",v.error):a==null||a(v.query,v.queryDurationMillis)},plugins:w}),this.status=r?0:1,this.tableMap=Gb(n),this.trxs=new Xb}async init(t=!1){const e=t||this.status===0;return await Yb(this.kysely,this.tableMap,e),this.status=2,this}async isEmptyTable(){var t;return this.status!==2&&await this.init(),this.status===2?!1:((t=this.logger)==null||t.error("fail to init table"),!0)}async transaction(t,e){if(!await this.isEmptyTable())return await this.kysely.transaction().execute(n=>(this.trxs.push(n),t(n))).catch(n=>{var r;e&&((r=this.logger)==null||r.error(e,n))}).finally(()=>{this.trxs.pop()})}getDB(){return this.trxs.isEmpty()?this.kysely:this.trxs.peek()}async exec(t,e){if(!await this.isEmptyTable())return t(this.getDB()).catch(n=>{var r;e&&((r=this.logger)==null||r.error(e,n))})}async execOne(t,e){if(!await this.isEmptyTable())return t(this.getDB()).executeTakeFirstOrThrow().catch(n=>{var r;e&&((r=this.logger)==null||r.error(e,n))})}async execList(t,e){if(!await this.isEmptyTable())return t(this.getDB()).execute().catch(n=>{var r;e&&((r=this.logger)==null||r.error(e,n))})}async toSQL(t){return t(this.getDB()).compile()}async raw(t){if(!await this.isEmptyTable())return t(Cn).execute(this.getDB())}};async function Ff(t){const e=await new Zb({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(r=>r.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 eN=new Cb({async database(){const t=await Db({locateFile:()=>Lb});return new t.Database(await $b("sqljs"))},onWrite:{func(t){console.log(`[sqljs] write to indexeddb, length: ${t.length}`),jb("sqljs",t)},isThrottle:!0}});function tN(){const t=Hm();function e(){Ff(eN).then(n=>{t.value=n})}return{result:t,run:e}}function nN(){return new Worker(""+new URL("sqljsWorker-c2b6105d.js",import.meta.url).href)}function rN(){return new Worker(""+new URL("officialWasmWorker-4253d4af.js",import.meta.url).href)}const ze=0,iN=5,Nt=10,Vp=12,zp=14,Li=21,_l=25,sN=27,Ph=100,oN=101,aN=3850,uN=522,cN=1,lN=2,Hp=4,fN=8,Rs=0,Ui=1,Bu=2,hN=3,Fu=4,dN=512,pN=1024,mN=2048,yN=16384,Mh=1,Bh=2,Fh=3,Uh=4,$h=5,Qh=0x7fffffffffffffffn,jh=-0x8000000000000000n;class _r extends Error{constructor(e,n){super(e),this.code=n}}const Ws=!0;function wN(t){const e={},n=t._getSqliteFree(),r=t._malloc(8),a=[r,r+4];function l(b){if(typeof b!="string")return 0;const E=t.lengthBytesUTF8(b),N=t._sqlite3_malloc(E+1);return t.stringToUTF8(b,N,E+1),N}function p(b,E){return BigInt(E)<<32n|BigInt(b)&0xffffffffn}const w=function(){const b=BigInt(Number.MAX_SAFE_INTEGER)>>32n,E=BigInt(Number.MIN_SAFE_INTEGER)>>32n;return function(N,q){return q>b||q2147483647||T<-2147483648)return _l;const ne=E(N,q,T);return X(b,ne,A.get(N))}}(),e.bind_int64=function(){const b="sqlite3_bind_int64",E=t.cwrap(b,...Ee("nnnn:n"));return function(N,q,T){if(B(N),T>Qh||T>32n,ae=E(N,q,Number(ne),Number(ye));return X(b,ae,A.get(N))}}(),e.bind_null=function(){const b="sqlite3_bind_null",E=t.cwrap(b,...Ee("nn:n"));return function(N,q){B(N);const T=E(N,q);return X(b,T,A.get(N))}}(),e.bind_parameter_name=function(){const b="sqlite3_bind_parameter_name",E=t.cwrap(b,...Ee("n:s"));return function(N,q){return B(N),E(N,q)}}(),e.bind_text=function(){const b="sqlite3_bind_text",E=t.cwrap(b,...Ee("nnnnn:n"));return function(N,q,T){B(N);const ne=l(T),ye=E(N,q,ne,-1,n);return X(b,ye,A.get(N))}}(),e.changes=function(){const b="sqlite3_changes",E=t.cwrap(b,...Ee("n:n"));return function(N){return d(N),E(N)}}(),e.close=function(){const b="sqlite3_close",E=t.cwrap(b,...Ee("n:n"),{async:Ws});return async function(N){d(N);const q=await E(N);return v.delete(N),X(b,q,N)}}(),e.column=function(b,E){B(b);const N=e.column_type(b,E);switch(N){case Uh:return e.column_blob(b,E);case Bh:return e.column_double(b,E);case Mh:const q=e.column_int(b,E),T=t.getTempRet0();return w(q,T);case $h:return null;case Fh:return e.column_text(b,E);default:throw new _r("unknown type",N)}},e.column_blob=function(){const b="sqlite3_column_blob",E=t.cwrap(b,...Ee("nn:n"));return function(N,q){B(N);const T=e.column_bytes(N,q),ne=E(N,q);return t.HEAPU8.subarray(ne,ne+T)}}(),e.column_bytes=function(){const b="sqlite3_column_bytes",E=t.cwrap(b,...Ee("nn:n"));return function(N,q){return B(N),E(N,q)}}(),e.column_count=function(){const b="sqlite3_column_count",E=t.cwrap(b,...Ee("n:n"));return function(N){return B(N),E(N)}}(),e.column_double=function(){const b="sqlite3_column_double",E=t.cwrap(b,...Ee("nn:n"));return function(N,q){return B(N),E(N,q)}}(),e.column_int=function(){const b="sqlite3_column_int64",E=t.cwrap(b,...Ee("nn:n"));return function(N,q){return B(N),E(N,q)}}(),e.column_int64=function(){const b="sqlite3_column_int64",E=t.cwrap(b,...Ee("nn:n"));return function(N,q){B(N);const T=E(N,q),ne=t.getTempRet0();return p(T,ne)}}(),e.column_name=function(){const b="sqlite3_column_name",E=t.cwrap(b,...Ee("nn:s"));return function(N,q){return B(N),E(N,q)}}(),e.column_names=function(b){const E=[],N=e.column_count(b);for(let q=0;qQh||q>32n;E(N,Number(T),Number(ne))}}(),e.result_null=function(){const b="sqlite3_result_null",E=t.cwrap(b,...Ee("n:n"));return function(N){E(N)}}(),e.result_text=function(){const b="sqlite3_result_text",E=t.cwrap(b,...Ee("nnnn:n"));return function(N,q){const T=l(q);E(N,T,-1,n)}}(),e.row=function(b){const E=[],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 r,a;n.ready=new Promise((s,u)=>{r=s,a=u});var l=Object.assign({},n),p="./this.program",w=(s,u)=>{throw u},v=typeof window=="object",d=typeof importScripts=="function",A="",B;(v||d)&&(d?A=self.location.href:typeof document<"u"&&document.currentScript&&(A=document.currentScript.src),t&&(A=t),A.indexOf("blob:")!==0?A=A.substr(0,A.replace(/[?#].*/,"").lastIndexOf("/")+1):A="",d&&(B=s=>{var u=new XMLHttpRequest;return u.open("GET",s,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}));var F=n.print||console.log.bind(console),Y=n.printErr||console.warn.bind(console);Object.assign(n,l),l=null,n.thisProgram&&(p=n.thisProgram),n.quit&&(w=n.quit);var X;n.wasmBinary&&(X=n.wasmBinary);var b=n.noExitRuntime||!0;typeof WebAssembly!="object"&&st("no native wasm support detected");var E,N=!1,q,T,ne,ye,ae,be,Ne,Ze;function He(){var s=E.buffer;n.HEAP8=T=new Int8Array(s),n.HEAP16=ye=new Int16Array(s),n.HEAP32=ae=new Int32Array(s),n.HEAPU8=ne=new Uint8Array(s),n.HEAPU16=new Uint16Array(s),n.HEAPU32=be=new Uint32Array(s),n.HEAPF32=Ne=new Float32Array(s),n.HEAPF64=Ze=new Float64Array(s)}var Ot=[],Et=[],Qe=[],$t=[],rn=0;function ht(){var s=n.preRun.shift();Ot.unshift(s)}var pe=0,qe=null;function st(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 de(s){return s.startsWith("data:application/octet-stream;base64,")}var ke;if(n.locateFile){if(ke="wa-sqlite-async.wasm",!de(ke)){var Wt=ke;ke=n.locateFile?n.locateFile(Wt,A):A+Wt}}else ke=new URL(""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,self.location).href;function br(s){try{if(s==ke&&X)return new Uint8Array(X);if(B)return B(s);throw"both async and sync fetching of the wasm failed"}catch(u){st(u)}}function ds(s){return X||!v&&!d||typeof fetch!="function"?Promise.resolve().then(()=>br(s)):fetch(s,{credentials:"same-origin"}).then(u=>{if(!u.ok)throw"failed to load wasm binary file at '"+s+"'";return u.arrayBuffer()}).catch(()=>br(s))}function wn(s,u,f){return ds(s).then(y=>WebAssembly.instantiate(y,u)).then(y=>y).then(f,y=>{Y("failed to asynchronously prepare wasm: "+y),st(y)})}function sn(s,u){var f=ke;return X||typeof WebAssembly.instantiateStreaming!="function"||de(f)||typeof fetch!="function"?wn(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"),wn(f,s,u)}))}var fe,Pe;function Mn(s){this.name="ExitStatus",this.message="Program terminated with exit("+s+")",this.status=s}function Qt(s){for(;0>0];case"i8":return T[s>>0];case"i16":return ye[s>>1];case"i32":return ae[s>>2];case"i64":return ae[s>>2];case"float":return Ne[s>>2];case"double":return Ze[s>>3];case"*":return be[s>>2];default:st("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":ye[s>>1]=u;break;case"i32":ae[s>>2]=u;break;case"i64":Pe=[u>>>0,(fe=u,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[s>>2]=Pe[0],ae[s+4>>2]=Pe[1];break;case"float":Ne[s>>2]=u;break;case"double":Ze[s>>3]=u;break;case"*":be[s>>2]=u;break;default:st("invalid type for setValue: "+f)}}var C=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function W(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 P(s,u){return s?W(ne,s,u):""}var H=(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=H(s.split("/").filter(y=>!!y),!u).join("/"))||u||(s="."),s&&f&&(s+="/"),(u?"/":"")+s},$=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);st("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=H(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=I){var j=s.charCodeAt(++k);I=65536+((I&1023)<<10)|j&1023}if(127>=I){if(f>=y)break;u[f++]=I}else{if(2047>=I){if(f+1>=y)break;u[f++]=192|I>>6}else{if(65535>=I){if(f+2>=y)break;u[f++]=224|I>>12}else{if(f+3>=y)break;u[f++]=240|I>>18,u[f++]=128|I>>12&63}u[f++]=128|I>>6&63}u[f++]=128|I&63}}return u[f]=0,f-_}var me=[];function Oe(s,u){me[s]={input:[],Rb:[],bc:u},ws(s,je)}var je={open:function(s){var u=me[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){he.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!!I);for(var f=gn,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}},ms=(s,u)=>{for(var f=0,y=0;y>>0)%le.length},Q=s=>{var u=ms(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}},Bn=(s,u)=>{var f;if(f=(f=Nr(s,"x"))?f:s.Cb.cc?0:2)throw new te(f,s);for(f=le[ms(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)},Dt=(s,u,f,y)=>(s=new hu(s,u,f,y),u=ms(s.parent.id,s.name),s.ac=le[u],le[u]=s),yi={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},ys=s=>{var u=["r","w","rw"][s&3];return s&512&&(u+="w"),u},Nr=(s,u)=>{if(Rt)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},sr=(s,u)=>{try{return Bn(s,u),20}catch{}return Nr(s,"wx")},Io=(s,u,f)=>{try{var y=Bn(s,u)}catch(_){return _.Ob}if(s=Nr(s,"wx"))return s;if(f){if((y.mode&61440)!==16384)return 54;if(y===y.parent||bn(y)==="/")return 10}else if((y.mode&61440)===16384)return 31;return 0},il=(s=0)=>{for(;4096>=s;s++)if(!jt[s])return s;throw new te(33)},To=(s,u)=>(Mr||(Mr=function(){this.hc={}},Mr.prototype={},Object.defineProperties(Mr.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 Mr,s),u=il(u),s.Wb=u,jt[u]=s),Dr={open:s=>{s.Mb=mi[s.node.ec].Mb,s.Mb.open&&s.Mb.open(s)},Zb:()=>{throw new te(70)}},ws=(s,u)=>{mi[s]={Mb:u}},ko=(s,u)=>{var f=u==="/",y=!u;if(f&&gn)throw new te(10);if(!f&&!y){var _=Vt(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?gn=s:_&&(_.$b=u,_.Ub&&_.Ub.Mc.push(u))},Wo=(s,u,f)=>{var y=Vt(s,{parent:!0}).node;if(s=V(s),!s||s==="."||s==="..")throw new te(28);var _=sr(y,s);if(_)throw new te(_);if(!y.Cb.jc)throw new te(63);return y.Cb.jc(y,s,u,f)},Nn=(s,u)=>Wo(s,(u!==void 0?u:511)&1023|16384,0),gs=(s,u,f)=>{typeof f>"u"&&(f=u,u=438),Wo(s,u|8192,f)},wi=(s,u)=>{if(!ce(s))throw new te(44);var f=Vt(u,{parent:!0}).node;if(!f)throw new te(44);u=V(u);var y=sr(f,u);if(y)throw new te(y);if(!f.Cb.nc)throw new te(63);f.Cb.nc(f,u,s)},Ro=s=>{var u=Vt(s,{parent:!0}).node;s=V(s);var f=Bn(u,s),y=Io(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),Q(f)},gi=s=>{if(s=Vt(s).node,!s)throw new te(44);if(!s.Cb.fc)throw new te(28);return ce(bn(s.parent),s.Cb.fc(s))},Yt=(s,u)=>{if(s=Vt(s,{Yb:!u}).node,!s)throw new te(44);if(!s.Cb.Tb)throw new te(63);return s.Cb.Tb(s)},bi=s=>Yt(s,!0),bs=(s,u)=>{if(s=typeof s=="string"?Vt(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()})},Do=(s,u)=>{if(0>u)throw new te(28);if(s=typeof s=="string"?Vt(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=Nr(s,"w");if(f)throw new te(f);s.Cb.Qb(s,{size:u,timestamp:Date.now()})},Ni=(s,u,f)=>{if(s==="")throw new te(44);if(typeof u=="string"){var y=yi[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{_=Vt(s,{Yb:!(u&131072)}).node}catch{}}if(y=!1,u&64)if(_){if(u&128)throw new te(20)}else _=Wo(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&&(ys(u)!=="r"||u&512)?31:Nr(_,ys(u)):44))throw new te(f);return u&512&&!y&&Do(_,0),u&=-131713,_=To({node:_,path:bn(_),flags:u,seekable:!0,position:0,Mb:_.Mb,Tc:[],error:!1}),_.Mb.open&&_.Mb.open(_),!n.logReadFiles||u&1||(vi||(vi={}),s in vi||(vi[s]=1)),_},Lo=(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=[]},Lr=()=>{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=>{qn[s]=new te(s),qn[s].stack=""}))},Po,Ns=(s,u)=>{var f=0;return s&&(f|=365),u&&(f|=146),f},Pr=(s,u,f)=>{s=ee("/dev/"+s);var y=Ns(!!u,!!f);or||(or=64);var _=or++<<8|0;ws(_,{open:k=>{k.seekable=!1},close:()=>{f&&f.buffer&&f.buffer.length&&f(10)},read:(k,I,j,L)=>{for(var M=0,ie=0;ie{for(var M=0;M>2]=y.Ic,ae[f+8>>2]=y.qc,ae[f+12>>2]=y.mode,be[f+16>>2]=y.Oc,ae[f+20>>2]=y.uid,ae[f+24>>2]=y.Lc,ae[f+28>>2]=y.ec,Pe=[y.size>>>0,(fe=y.size,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+40>>2]=Pe[0],ae[f+44>>2]=Pe[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 Pe=[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]=Pe[0],ae[f+60>>2]=Pe[1],be[f+64>>2]=s%1e3*1e3,Pe=[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]=Pe[0],ae[f+76>>2]=Pe[1],be[f+80>>2]=u%1e3*1e3,Pe=[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]=Pe[0],ae[f+92>>2]=Pe[1],be[f+96>>2]=_%1e3*1e3,Pe=[y.qc>>>0,(fe=y.qc,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+104>>2]=Pe[0],ae[f+108>>2]=Pe[1],0}var _i=void 0;function xi(){return _i+=4,ae[_i-4>>2]}function on(s){if(s=jt[s],!s)throw new te(8);return s}function Sn(s,u,f){return ue(s,ne,u,f)}function Oi(s){return be[s>>2]+4294967296*ae[s+4>>2]}var Je=[0,31,60,91,121,152,182,213,244,274,305,335],Ei=[0,31,59,90,120,151,181,212,243,273,304,334];function Ci(s){var u=oe(s)+1,f=Jo(u);return f&&Sn(s,f,u),f}var Fn={};function qi(){if(!Br){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",_:p||"./this.program"},u;for(u in Fn)Fn[u]===void 0?delete s[u]:s[u]=Fn[u];var f=[];for(u in s)f.push(u+"="+s[u]);Br=f}return Br}var Br;function Si(){}function an(){}function _s(){}function Mo(){}function nu(){}function xs(){}function Bo(){}function Os(){}function Fo(){}function Es(){}function Un(){}function Cs(){}function qs(){}function Fr(){}function Ss(){}function ru(){}function Uo(){}function iu(){}function $o(){}function Ai(){}function Ii(){}function Qo(){}function Ur(){}function $r(){}function $n(){}function Ti(){}function jo(){}function o(){}function c(){}function h(){}function g(){}function O(){}function R(){}function U(){}function we(){}function Le(){}function We(){}function ot(){}function An(){}function Vo(s){q=s,b||0{Ho={resolve:s,reject:u}})}function ul(){var s=Jo(12300),u=s+12;ae[s>>2]=u,ae[s+4>>2]=u+12288,u=As[0];var f=ou[u];return f===void 0&&(f=ol++,ou[u]=f,au[f]=u),ae[s+8>>2]=f,s}function cu(s){if(!N){if(Qn===0){var u=!1,f=!1;s((y=0)=>{if(!N&&(su=y,u=!0,f)){Qn=2,ki(()=>Wi(In)),y=!1;try{var _=(0,n.asm[au[ae[In+8>>2]]])()}catch(j){_=j,y=!0}var k=!1;if(!In){var I=Ho;I&&(Ho=null,(y?I.reject:I.resolve)(_),k=!0)}if(y&&!k)throw _}}),f=!0,u||(Qn=1,In=ul(),ki(()=>gu(In)))}else Qn===2?(Qn=0,ki(Xo),du(In),In=null,al.forEach(y=>{if(!N)try{if(y(),!(b||0{s().then(u)})}var fu={};function Tn(s,u,f,y,_){function k(G){return--rn,L!==0&&Go(L),u==="string"?P(G):u==="boolean"?!!G:G}var I={string:G=>{var se=0;if(G!=null&&G!==0){se=oe(G)+1;var Ae=Yo(se);Sn(G,Ae,se),se=Ae}return se},array:G=>{var se=Yo(G.length);return T.set(G,se),se}};s=n["_"+s];var j=[],L=0;if(y)for(var M=0;M{Nn("/dev"),ws(259,{read:()=>0,write:(y,_,k,I)=>I}),gs("/dev/null",259),Oe(1280,De),Oe(1536,rt),gs("/dev/tty",1280),gs("/dev/tty1",1536);var s=new Uint8Array(1024),u=0,f=()=>(u===0&&(u=K(s).byteLength),s[--u]);Pr("random",f),Pr("urandom",f),Nn("/dev/shm"),Nn("/dev/shm/tmp")})(),(()=>{Nn("/proc");var s=Nn("/proc/self");Nn("/proc/self/fd"),ko({Ub:()=>{var u=Dt(s,"fd",16895,73);return u.Cb={cc:(f,y)=>{var _=jt[+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),Tn("set_authorizer","number",["number"],[u])},Si=function(u,f,y,_,k,I){if(s.has(u)){const{f:j,uc:L}=s.get(u);return j(L,f,y?P(y):null,_?P(_):null,k?P(k):null,I?P(I):null)}return 0}}(),function(){const s=new Map,u=new Map;n.createFunction=function(f,y,_,k,I,j){const L=s.size;return s.set(L,{f:j,Xb:I}),Tn("create_function","number","number string number number number number".split(" "),[f,y,_,k,L,0])},n.createAggregate=function(f,y,_,k,I,j,L){const M=s.size;return s.set(M,{step:j,Jc:L,Xb:I}),Tn("create_function","number","number string number number number number".split(" "),[f,y,_,k,M,1])},n.getFunctionUserData=function(f){return u.get(f)},_s=function(f,y,_,k){f=s.get(f),u.set(y,f.Xb),f.f(y,new Uint32Array(ne.buffer,k,_)),u.delete(y)},nu=function(f,y,_,k){f=s.get(f),u.set(y,f.Xb),f.step(y,new Uint32Array(ne.buffer,k,_)),u.delete(y)},an=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),Tn("progress_handler",null,["number","number"],[u,f])},Mo=function(u){if(s.has(u)){const{f,uc:y}=s.get(u);return f(y)}return 0}}(),function(){function s(L,M){const ie=`get${L}`,G=`set${L}`;return new Proxy(new DataView(ne.buffer,M,L==="Int32"?4:8),{get(se,Ae){if(Ae===ie)return function(Ge,St){if(!St)throw Error("must be little endian");return se[Ae](Ge,St)};if(Ae===G)return function(Ge,St,wt){if(!wt)throw Error("must be little endian");return se[Ae](Ge,St,wt)};if(typeof Ae=="string"&&Ae.match(/^(get)|(set)/))throw Error("invalid type");return se[Ae]}})}const u=typeof fu=="object",f=new Map,y=new Map,_=new Map,k=u?new Set:null,I=u?new Set:null,j=new Map;Qo=function(L,M,ie,G){j.set(P(L),{size:M,dc:Array.from(new Uint32Array(ne.buffer,G,ie))})},n.createModule=function(L,M,ie,G){u&&(ie.handleAsync=lu);const se=f.size;return f.set(se,{module:ie,Xb:G}),G=0,ie.xCreate&&(G|=1),ie.xConnect&&(G|=2),ie.xBestIndex&&(G|=4),ie.xDisconnect&&(G|=8),ie.xDestroy&&(G|=16),ie.xOpen&&(G|=32),ie.xClose&&(G|=64),ie.xFilter&&(G|=128),ie.xNext&&(G|=256),ie.xEof&&(G|=512),ie.xColumn&&(G|=1024),ie.xRowid&&(G|=2048),ie.xUpdate&&(G|=4096),ie.xBegin&&(G|=8192),ie.xSync&&(G|=16384),ie.xCommit&&(G|=32768),ie.xRollback&&(G|=65536),ie.xFindFunction&&(G|=131072),ie.xRename&&(G|=262144),Tn("create_module","number",["number","string","number","number"],[L,M,se,G])},Cs=function(L,M,ie,G,se,Ae){if(M=f.get(M),y.set(se,M),u){k.delete(se);for(const Ge of k)y.delete(Ge)}return G=Array.from(new Uint32Array(ne.buffer,G,ie)).map(Ge=>P(Ge)),M.module.xCreate(L,M.Xb,G,se,s("Int32",Ae))},Un=function(L,M,ie,G,se,Ae){if(M=f.get(M),y.set(se,M),u){k.delete(se);for(const Ge of k)y.delete(Ge)}return G=Array.from(new Uint32Array(ne.buffer,G,ie)).map(Ge=>P(Ge)),M.module.xConnect(L,M.Xb,G,se,s("Int32",Ae))},Bo=function(L,M){var ie=y.get(L),G=j.get("sqlite3_index_info").dc;const se={};se.nConstraint=Ke(M+G[0],"i32"),se.aConstraint=[];for(var Ae=Ke(M+G[1],"*"),Ge=j.get("sqlite3_index_constraint").size,St=0;St>=2,be[I]+be[I+1]*2**32}const f=typeof fu=="object",y=new Map,_=new Map;n.registerVFS=function(I,j){if(Tn("sqlite3_vfs_find","number",["string"],[I.name]))throw Error(`VFS '${I.name}' already registered`);f&&(I.handleAsync=lu);var L=I.Vc??64;const M=n._malloc(4);return j=Tn("register_vfs","number",["string","number","number","number"],[I.name,L,j?1:0,M]),j||(L=Ke(M,"*"),y.set(L,I)),n._free(M),j};const k=f?new Set:null;jo=function(I){const j=_.get(I);return f?k.add(I):_.delete(I),j.xClose(I)},U=function(I,j,L,M){return _.get(I).xRead(I,ne.subarray(j,j+L),u(M))},An=function(I,j,L,M){return _.get(I).xWrite(I,ne.subarray(j,j+L),u(M))},We=function(I,j){return _.get(I).xTruncate(I,u(j))},Le=function(I,j){return _.get(I).xSync(I,j)},g=function(I,j){const L=_.get(I);return j=s("BigInt64",j),L.xFileSize(I,j)},O=function(I,j){return _.get(I).xLock(I,j)},ot=function(I,j){return _.get(I).xUnlock(I,j)},Ti=function(I,j){const L=_.get(I);return j=s("Int32",j),L.xCheckReservedLock(I,j)},h=function(I,j,L){const M=_.get(I);return L=new DataView(ne.buffer,L),M.xFileControl(I,j,L)},we=function(I){return _.get(I).xSectorSize(I)},c=function(I){return _.get(I).xDeviceCharacteristics(I)},R=function(I,j,L,M,ie){if(I=y.get(I),_.set(L,I),f){k.delete(L);for(var G of k)_.delete(G)}if(G=null,M&64){G=1;const se=[];for(;G;){const Ae=ne[j++];if(Ae)se.push(Ae);else switch(ne[j]||(G=null),G){case 1:se.push(63),G=2;break;case 2:se.push(61),G=3;break;case 3:se.push(38),G=2}}G=new TextDecoder().decode(new Uint8Array(se))}else j&&(G=P(j));return ie=s("Int32",ie),I.xOpen(G,L,M,ie)},o=function(I,j,L){return y.get(I).xDelete(P(j),L)},$n=function(I,j,L,M){return I=y.get(I),M=s("Int32",M),I.xAccess(P(j),L,M)}}();var cl={a:function(s,u,f,y){st("Assertion failed: "+P(s)+", at: "+[u?P(u):"unknown filename",f,y?P(y):"unknown function"])},K:function(s,u){try{return s=P(s),bs(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=P(u),u=ar(s,u),f&-8)return-28;var y=Vt(u,{Yb:!0}).node;return y?(s="",f&4&&(s+="r"),f&2&&(s+="w"),f&1&&(s+="x"),s&&Nr(y,s)?-2:0):-44}catch(_){if(typeof Ve>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},L:function(s,u){try{var f=jt[s];if(!f)throw new te(8);return bs(f.node,u),0}catch(y){if(typeof Ve>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},J:function(s){try{var u=jt[s];if(!u)throw new te(8);var f=u.node,y=typeof f=="string"?Vt(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){_i=f;try{var y=on(s);switch(u){case 0:var _=xi();return 0>_?-28:To(y,_).Wb;case 1:case 2:return 0;case 3:return y.flags;case 4:return _=xi(),y.flags|=_,0;case 5:return _=xi(),ye[_+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return ae[Ko()>>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=on(s);return vs(Yt,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=jt[s];if(!y)throw new te(8);if(!(y.flags&2097155))throw new te(28);return Do(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=P(s),vs(bi,s,u)}catch(f){if(typeof Ve>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},z:function(s,u,f){try{return u=P(u),u=ar(s,u),u=ee(u),u[u.length-1]==="/"&&(u=u.substr(0,u.length-1)),Nn(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=P(u);var _=y&256;return u=ar(s,u,y&4096),vs(_?bi:Yt,u,f)}catch(k){if(typeof Ve>"u"||k.name!=="ErrnoError")throw k;return-k.Ob}},u:function(s,u,f,y){_i=y;try{u=P(u),u=ar(s,u);var _=y?xi():0;return Ni(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=P(u),u=ar(s,u),0>=y)return-28;var _=gi(u),k=Math.min(y,oe(_)),I=T[f+k];return Sn(_,f,y+1),T[f+k]=I,k}catch(j){if(typeof Ve>"u"||j.name!=="ErrnoError")throw j;return-j.Ob}},r:function(s){try{return s=P(s),Ro(s),0}catch(u){if(typeof Ve>"u"||u.name!=="ErrnoError")throw u;return-u.Ob}},H:function(s,u){try{return s=P(s),vs(Yt,s,u)}catch(f){if(typeof Ve>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},o:function(s,u,f){try{if(u=P(u),u=ar(s,u),f===0){s=u;var y=Vt(s,{parent:!0}).node;if(!y)throw new te(44);var _=V(s),k=Bn(y,_),I=Io(y,_,!1);if(I)throw new te(I);if(!y.Cb.oc)throw new te(63);if(k.$b)throw new te(10);y.Cb.oc(y,_),Q(k)}else f===512?Ro(u):st("Invalid flags passed to unlinkat");return 0}catch(j){if(typeof Ve>"u"||j.name!=="ErrnoError")throw j;return-j.Ob}},n:function(s,u,f){try{if(u=P(u),u=ar(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],I=1e3*y+_/1e6}else var k=Date.now(),I=k;s=k;var j=Vt(u,{Yb:!0}).node;return j.Cb.Qb(j,{timestamp:Math.max(s,I)}),0}catch(L){if(typeof Ve>"u"||L.name!=="ErrnoError")throw L;return-L.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?Ei:Je)[s.getMonth()]+s.getDate()-1|0,ae[u+36>>2]=-(60*s.getTimezoneOffset()),f=new Date(s.getFullYear(),6,1).getTimezoneOffset();var y=new Date(s.getFullYear(),0,1).getTimezoneOffset();ae[u+32>>2]=(f!=y&&s.getTimezoneOffset()==Math.min(y,f))|0},w:function(s,u,f,y,_,k,I){try{var j=on(y);if(u&2&&!(f&2)&&(j.flags&2097155)!==2)throw new te(2);if((j.flags&2097155)===1)throw new te(2);if(!j.Mb.kc)throw new te(43);var L=j.Mb.kc(j,s,_,u,f),M=L.Pc;return ae[k>>2]=L.Dc,be[I>>2]=M,0}catch(ie){if(typeof Ve>"u"||ie.name!=="ErrnoError")throw ie;return-ie.Ob}},x:function(s,u,f,y,_,k){try{var I=on(_);if(f&2){if((I.node.mode&61440)!==32768)throw new te(43);y&2||I.Mb.lc&&I.Mb.lc(I,ne.slice(s,s+u),k,u,y)}}catch(j){if(typeof Ve>"u"||j.name!=="ErrnoError")throw j;return-j.Ob}},p:function(s,u,f){function y(L){return(L=L.toTimeString().match(/\(([A-Za-z ]+)\)$/))?L[1]:"GMT"}var _=new Date().getFullYear(),k=new Date(_,0,1),I=new Date(_,6,1);_=k.getTimezoneOffset();var j=I.getTimezoneOffset();be[s>>2]=60*Math.max(_,j),ae[u>>2]=+(_!=j),s=y(k),u=y(I),s=Ci(s),u=Ci(u),j<_?(be[f>>2]=s,be[f+4>>2]=u):(be[f>>2]=u,be[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 I=E.buffer;try{E.grow(k.call(_,2147483648,y)-I.byteLength+65535>>>16),He();var j=1;break e}catch{}j=void 0}if(j)return!0}return!1},A:function(s,u){var f=0;return qi().forEach(function(y,_){var k=u+f;for(_=be[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=qi();be[s>>2]=f.length;var y=0;return f.forEach(function(_){y+=_.length+1}),be[u>>2]=y,0},f:function(s){try{var u=on(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{jt[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=on(s);return T[u>>0]=f.Sb?2:(f.mode&61440)===16384?3:(f.mode&61440)===40960?7:4,ye[u+2>>1]=0,Pe=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[u+8>>2]=Pe[0],ae[u+12>>2]=Pe[1],Pe=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[u+16>>2]=Pe[0],ae[u+20>>2]=Pe[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 _=on(s);s=u;for(var k,I=u=0;I>2],L=be[s+4>>2];s+=8;var M=_,ie=j,G=L,se=k,Ae=T;if(0>G||0>se)throw new te(28);if(M.Wb===null)throw new te(8);if((M.flags&2097155)===1)throw new te(8);if((M.node.mode&61440)===16384)throw new te(31);if(!M.Mb.read)throw new te(28);var Ge=typeof se<"u";if(!Ge)se=M.position;else if(!M.seekable)throw new te(70);var St=M.Mb.read(M,Ae,ie,G,se);Ge||(M.position+=St);var wt=St;if(0>wt){var un=-1;break e}if(u+=wt,wt>2]=un,0}catch(Lt){if(typeof Ve>"u"||Lt.name!=="ErrnoError")throw Lt;return Lt.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=on(s);return Lo(k,u,y),Pe=[k.position>>>0,(fe=k.position,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[_>>2]=Pe[0],ae[_+4>>2]=Pe[1],k.pc&&u===0&&y===0&&(k.pc=null),0}catch(I){if(typeof Ve>"u"||I.name!=="ErrnoError")throw I;return I.Ob}},D:function(s){try{var u=on(s);return cu(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 _=on(s);s=u;for(var k,I=u=0;I>2],L=be[s+4>>2];s+=8;var M=_,ie=j,G=L,se=k,Ae=T;if(0>G||0>se)throw new te(28);if(M.Wb===null)throw new te(8);if(!(M.flags&2097155))throw new te(8);if((M.node.mode&61440)===16384)throw new te(31);if(!M.Mb.write)throw new te(28);M.seekable&&M.flags&1024&&Lo(M,0,2);var Ge=typeof se<"u";if(!Ge)se=M.position;else if(!M.seekable)throw new te(70);var St=M.Mb.write(M,Ae,ie,G,se,void 0);Ge||(M.position+=St);var wt=St;if(0>wt){var un=-1;break e}u+=wt,typeof k<"u"&&(k+=wt)}un=u}return be[y>>2]=un,0}catch(Lt){if(typeof Ve>"u"||Lt.name!=="ErrnoError")throw Lt;return Lt.Ob}},ra:Si,N:an,ga:_s,ca:Mo,Y:nu,la:xs,G:Bo,h:Os,oa:Fo,ja:Es,ea:Un,fa:Cs,k:qs,v:Fr,pa:Ss,g:ru,qa:Uo,da:iu,ha:$o,ia:Ai,na:Ii,c:Qo,ka:Ur,ma:$r,aa:$n,V:Ti,$:jo,ba:o,S:c,U:h,Z:g,X:O,R,Q:U,T:we,_:Le,O:We,W:ot,P:An};(function(){function s(f){if(f=f.exports,f=sl(f),n.asm=f,E=n.asm.sa,He(),Et.unshift(n.asm.ta),pe--,n.monitorRunDependencies&&n.monitorRunDependencies(pe),pe==0&&qe){var y=qe;qe=null,y()}return f}var u={a:cl};if(pe++,n.monitorRunDependencies&&n.monitorRunDependencies(pe),n.instantiateWasm)try{return n.instantiateWasm(u,s)}catch(f){Y("Module.instantiateWasm callback failed with error: "+f),a(f)}return sn(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 Ko(){return(Ko=n.asm.rb).apply(null,arguments)}var Jo=n._malloc=function(){return(Jo=n._malloc=n.asm.sb).apply(null,arguments)},du=n._free=function(){return(du=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 pu=n._main=function(){return(pu=n._main=n.asm.Bb).apply(null,arguments)};function mu(){return(mu=n.asm.Db).apply(null,arguments)}function yu(){return(yu=n.asm.Eb).apply(null,arguments)}function wu(){return(wu=n.asm.Fb).apply(null,arguments)}function Go(){return(Go=n.asm.Gb).apply(null,arguments)}function Yo(){return(Yo=n.asm.Hb).apply(null,arguments)}function gu(){return(gu=n.asm.Ib).apply(null,arguments)}function bu(){return(bu=n.asm.Jb).apply(null,arguments)}function Wi(){return(Wi=n.asm.Kb).apply(null,arguments)}function Xo(){return(Xo=n.asm.Lb).apply(null,arguments)}n.getTempRet0=yu,n.ccall=Tn,n.cwrap=function(s,u,f,y){var _=!f||f.every(k=>k==="number"||k==="boolean");return u!=="string"&&_&&!y?n["_"+s]:function(){return Tn(s,u,f,arguments,y)}},n.setValue=x,n.getValue=Ke,n.UTF8ToString=P,n.stringToUTF8=Sn,n.lengthBytesUTF8=oe;var Is;qe=function s(){Is||S(),Is||(qe=s)};function S(){function s(){if(!Is&&(Is=!0,n.calledRun=!0,!N)){if(n.noFSInit||Po||(Po=!0,Lr(),n.stdin=n.stdin,n.stdout=n.stdout,n.stderr=n.stderr,n.stdin?Pr("stdin",n.stdin):wi("/dev/tty","/dev/stdin"),n.stdout?Pr("stdout",null,n.stdout):wi("/dev/tty","/dev/stdout"),n.stderr?Pr("stderr",null,n.stderr):wi("/dev/tty1","/dev/stderr"),Ni("/dev/stdin",0),Ni("/dev/stdout",1),Ni("/dev/stderr",1)),Rt=!1,Qt(Et),Qt(Qe),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),J){var u=pu;try{var f=u(0,0);q=f,Vo(f)}catch(y){zo(y)}}if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)u=n.postRun.shift(),$t.unshift(u);Qt($t)}}if(!(0{try{await navigator.locks.request(e,n,l=>{if(r(l),l)return new Promise(p=>i(this,yo).set(e,p))})}catch(l){a(l)}})}_releaseWebLock(e){var n;(n=i(this,yo).get(e))==null||n(),i(this,yo).delete(e)}async _pollWebLock(e){var r;return(r=(await navigator.locks.query()).held.find(({name:a})=>a===e))==null?void 0:r.mode}_getTimeoutSignal(){if(this.timeoutMillis){const e=new AbortController;return setTimeout(()=>e.abort(),this.timeoutMillis),e.signal}}}Ft=new WeakMap,yo=new WeakMap,za=new WeakMap,Ha=new WeakSet,tf=async function(e,n){const r=n&NN;try{const a=()=>e.call(this,r);return await z(this,za,i(this,za).then(a,a)),z(this,Ft,r),ze}catch(a){return a.name==="AbortError"?iN:(console.error(a),aN)}},Lc=new WeakSet,Kp=async function(e){if(e===i(this,Ft))return ze;switch(i(this,Ft)){case Rs:switch(e){case Ui:return this._NONEtoSHARED();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}case Ui:switch(e){case Bu:return this._SHAREDtoRESERVED();case Fu:return this._SHAREDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}case Bu:switch(e){case Fu:return this._RESERVEDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}},Pc=new WeakSet,Jp=async function(e){if(e===i(this,Ft))return ze;switch(i(this,Ft)){case Fu:switch(e){case Ui:return this._EXCLUSIVEtoSHARED();case Rs:return this._EXCLUSIVEtoNONE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}case Bu:switch(e){case Ui:return this._RESERVEDtoSHARED();case Rs:return this._RESERVEDtoNONE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}case Ui:switch(e){case Rs:return this._SHAREDtoNONE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}};class _N extends vN{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 xN=5e3;let ON=0;const xl=new WeakMap;function lr(...t){}var wo,go,Ka,Tt,Ja,bo,rs,Mc,Gp;class EN{constructor(e,n={durability:"default"}){D(this,Mc);D(this,wo,void 0);D(this,go,void 0);D(this,Ka,void 0);D(this,Tt,null);D(this,Ja,0);D(this,bo,Promise.resolve());D(this,rs,Promise.resolve());z(this,go,Promise.resolve(e).then(r=>z(this,wo,r))),z(this,Ka,n)}async close(){const e=i(this,wo)??await i(this,go);await i(this,bo),await this.sync(),e.close()}async run(e,n){const r=i(this,bo).then(()=>_e(this,Mc,Gp).call(this,e,n));return z(this,bo,r.catch(()=>{})),r}async sync(){await i(this,rs),z(this,rs,Promise.resolve())}}wo=new WeakMap,go=new WeakMap,Ka=new WeakMap,Tt=new WeakMap,Ja=new WeakMap,bo=new WeakMap,rs=new WeakMap,Mc=new WeakSet,Gp=async function(e,n){var a,l;const r=i(this,wo)??await i(this,go);if(e==="readwrite"&&((a=i(this,Tt))==null?void 0:a.mode)==="readonly")z(this,Tt,null);else if(performance.now()-i(this,Ja)>xN){try{(l=i(this,Tt))==null||l.commit()}catch(p){if(p.name!=="InvalidStateError")throw p}await new Promise(p=>setTimeout(p)),z(this,Tt,null)}for(let p=0;p<2;++p){if(!i(this,Tt)){z(this,Tt,r.transaction(r.objectStoreNames,e,i(this,Ka)));const w=z(this,Ja,performance.now());z(this,rs,i(this,rs).then(()=>new Promise((v,d)=>{i(this,Tt).addEventListener("complete",A=>{v(),i(this,Tt)===A.target&&z(this,Tt,null),lr(`transaction ${xl.get(A.target)} complete`)}),i(this,Tt).addEventListener("abort",A=>{console.warn("tx abort",(performance.now()-w)/1e3);const B=A.target.error;d(B),i(this,Tt)===A.target&&z(this,Tt,null),lr(`transaction ${xl.get(A.target)} aborted`,B)})}))),xl.set(i(this,Tt),ON++)}try{const w=Object.fromEntries(Array.from(r.objectStoreNames,v=>[v,new CN(i(this,Tt).objectStore(v))]));return await n(w)}catch(w){if(z(this,Tt,null),p)throw w}}};function zr(t){return new Promise((e,n)=>{t.addEventListener("success",()=>e(t.result)),t.addEventListener("error",()=>n(t.error))})}var qt;class CN{constructor(e){D(this,qt,void 0);z(this,qt,e)}get(e){lr(`get ${i(this,qt).name}`,e);const n=i(this,qt).get(e);return zr(n)}getAll(e,n){lr(`getAll ${i(this,qt).name}`,e,n);const r=i(this,qt).getAll(e,n);return zr(r)}getKey(e){lr(`getKey ${i(this,qt).name}`,e);const n=i(this,qt).getKey(e);return zr(n)}getAllKeys(e,n){lr(`getAllKeys ${i(this,qt).name}`,e,n);const r=i(this,qt).getAllKeys(e,n);return zr(r)}put(e,n){lr(`put ${i(this,qt).name}`,e,n);const r=i(this,qt).put(e,n);return zr(r)}delete(e){lr(`delete ${i(this,qt).name}`,e);const n=i(this,qt).delete(e);return zr(n)}clear(){lr(`clear ${i(this,qt).name}`);const e=i(this,qt).clear();return zr(e)}index(e){return new qN(i(this,qt).index(e))}}qt=new WeakMap;var is;class qN{constructor(e){D(this,is,void 0);z(this,is,e)}getAllKeys(e,n){lr(`IDBIndex.getAllKeys ${i(this,is).objectStore.name}<${i(this,is).name}>`,e,n);const r=i(this,is).getAllKeys(e,n);return zr(r)}}is=new WeakMap;const SN=512,Vh=3e3,zh={durability:"default",purge:"deferred",purgeAtLeast:16};function cn(...t){}var si,Ut,lt,ss,os,Sr,Ga,nf,Bc,Yp,Fc,Xp,oi,Ds,Uc,Zp;class AN extends bN{constructor(n="wa-sqlite",r=zh){super();D(this,Ga);D(this,Bc);D(this,Fc);D(this,oi);D(this,Uc);D(this,si,void 0);D(this,Ut,new Map);D(this,lt,void 0);D(this,ss,new Set);D(this,os,performance.now());D(this,Sr,new Set);this.name=n,z(this,si,Object.assign({},zh,r)),z(this,lt,new EN(IN(n),{durability:i(this,si).durability}))}async close(){var n;for(const r of i(this,Ut).keys())await this.xClose(r);await((n=i(this,lt))==null?void 0:n.close()),z(this,lt,null)}xOpen(n,r,a,l){return this.handleAsync(async()=>{n===null&&(n=`null_${r}`),cn(`xOpen ${n} 0x${r.toString(16)} 0x${a.toString(16)}`);try{const p=new URL(n,"http://localhost/"),w={path:p.pathname,flags:a,block0:null,locks:new _N(p.pathname)};return i(this,Ut).set(r,w),await i(this,lt).run("readwrite",async({blocks:v})=>{if(w.block0=await v.get(_e(this,oi,Ds).call(this,w,0)),!w.block0)if(a&Hp)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&cN,!0),ze}catch(p){return console.error(p),zp}})}xClose(n){return this.handleAsync(async()=>{try{const r=i(this,Ut).get(n);return r&&(cn(`xClose ${r.path}`),i(this,Ut).delete(n),r.flags&fN&&i(this,lt).run("readwrite",({blocks:a})=>{a.delete(IDBKeyRange.bound([r.path],[r.path,[]]))})),ze}catch(r){return console.error(r),Nt}})}xRead(n,r,a){return this.handleAsync(async()=>{const l=i(this,Ut).get(n);cn(`xRead ${l.path} ${r.byteLength} ${a}`);try{return await i(this,lt).run("readonly",async({blocks:w})=>{let v=0;for(;vVh){const p=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&i(this,Sr).add(n),await new Promise(v=>setTimeout(v));const w=_e(this,Ga,nf).call(this,n,r,a);return z(this,os,performance.now()),w});return l&&i(this,Sr).delete(n),p}return _e(this,Ga,nf).call(this,n,r,a)}xTruncate(n,r){const a=i(this,Ut).get(n);cn(`xTruncate ${a.path} ${r}`);try{Object.assign(a.block0,{fileSize:r,data:a.block0.data.slice(0,r)});const l=Object.assign({},a.block0);return i(this,lt).run("readwrite",({blocks:p})=>{p.delete(_e(this,oi,Ds).call(this,a,-1/0,-r)),p.put(l)}),ze}catch(l){return console.error(l),Nt}}xSync(n,r){const a=i(this,Sr).has(n);if(a||i(this,si).durability!=="relaxed"||performance.now()-i(this,os)>Vh){const p=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&i(this,Sr).add(n);const w=await _e(this,Bc,Yp).call(this,n,r);return z(this,os,performance.now()),w});return a&&i(this,Sr).delete(n),p}const l=i(this,Ut).get(n);return cn(`xSync ${l.path} ${r}`),ze}xFileSize(n,r){const a=i(this,Ut).get(n);return cn(`xFileSize ${a.path}`),r.setBigInt64(0,BigInt(a.block0.fileSize),!0),ze}xLock(n,r){return this.handleAsync(async()=>{const a=i(this,Ut).get(n);cn(`xLock ${a.path} ${r}`);try{const l=await a.locks.lock(r);return l===ze&&a.locks.state===Ui&&(a.block0=await i(this,lt).run("readonly",({blocks:p})=>p.get(_e(this,oi,Ds).call(this,a,0)))),l}catch(l){return console.error(l),Nt}})}xUnlock(n,r){return this.handleAsync(async()=>{const a=i(this,Ut).get(n);cn(`xUnlock ${a.path} ${r}`);try{return a.locks.unlock(r)}catch(l){return console.error(l),Nt}})}xCheckReservedLock(n,r){return this.handleAsync(async()=>{const a=i(this,Ut).get(n);cn(`xCheckReservedLock ${a.path}`);const l=await a.locks.isSomewhereReserved();return r.setInt32(0,l?1:0,!0),ze})}xSectorSize(n){return SN}xDeviceCharacteristics(n){return yN|dN|pN|mN}xFileControl(n,r,a){const l=i(this,Ut).get(n);switch(cn(`xFileControl ${l.path} ${r}`),r){case 11:return l.overwrite=!0,ze;case 21:if(l.overwrite)try{return this.handleAsync(async()=>(await _e(this,Uc,Zp).call(this,l),ze))}catch(p){return console.error(p),Nt}return ze;case 22:return l.overwrite=!1,ze;case 31:return this.handleAsync(async()=>{try{return l.block0.version--,l.changedPages=new Set,i(this,lt).run("readwrite",async({blocks:p})=>{const w=await p.index("version").getAllKeys(IDBKeyRange.bound([l.path],[l.path,l.block0.version]));for(const v of w)p.delete(v)}),ze}catch(p){return console.error(p),Nt}});case 32:try{const p=Object.assign({},l.block0);p.data=p.data.slice();const w=l.changedPages;return l.changedPages=null,i(this,lt).run("readwrite",async({blocks:v})=>{v.put(p);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 A of w)d.data.set(A,p.version);v.put(d),_e(this,Fc,Xp).call(this,l.path,d.count)}),ze}catch(p){return console.error(p),Nt}case 33:return this.handleAsync(async()=>{try{return l.changedPages=null,l.block0=await i(this,lt).run("readonly",({blocks:p})=>p.get([l.path,0,l.block0.version+1])),ze}catch(p){return console.error(p),Nt}});default:return Vp}}xAccess(n,r,a){return this.handleAsync(async()=>{try{const l=new URL(n,"file://localhost/").pathname;cn(`xAccess ${l} ${r}`);const p=await i(this,lt).run("readonly",({blocks:w})=>w.getKey(_e(this,oi,Ds).call(this,{path:l},0)));return a.setInt32(0,p?1:0,!0),ze}catch(l){return console.error(l),Nt}})}xDelete(n,r){return this.handleAsync(async()=>{const a=new URL(n,"file://localhost/").pathname;try{return i(this,lt).run("readwrite",({blocks:l})=>l.delete(IDBKeyRange.bound([a],[a,[]]))),r&&await i(this,lt).sync(),ze}catch(l){return console.error(l),Nt}})}async purge(n){const r=Date.now();await i(this,lt).run("readwrite",async({blocks:a})=>{const l=await a.get([n,"purge",0]);if(l){for(const[p,w]of l.data)a.delete(IDBKeyRange.bound([n,p,w],[n,p,1/0],!0,!1));await a.delete([n,"purge",0])}cn(`purge ${n} ${(l==null?void 0:l.data.size)??0} pages in ${Date.now()-r} ms`)})}}si=new WeakMap,Ut=new WeakMap,lt=new WeakMap,ss=new WeakMap,os=new WeakMap,Sr=new WeakMap,Ga=new WeakSet,nf=function(n,r,a){const l=i(this,Ut).get(n);cn(`xWrite ${l.path} ${r.byteLength} ${a}`);try{const p=l.block0.fileSize;l.block0.fileSize=Math.max(l.block0.fileSize,a+r.byteLength);const w=a===0?l.block0:{path:l.path,offset:-a,version:l.block0.version,data:null};return w.data=r.slice(),l.changedPages?(p===l.block0.fileSize&&l.changedPages.add(-a),a!==0&&i(this,lt).run("readwrite",({blocks:v})=>v.put(w))):i(this,lt).run("readwrite",({blocks:v})=>v.put(w)),ze}catch(p){return console.error(p),Nt}},Bc=new WeakSet,Yp=async function(n,r){const a=i(this,Ut).get(n);cn(`xSync ${a.path} ${r}`);try{await i(this,lt).sync()}catch(l){return console.error(l),Nt}return ze},Fc=new WeakSet,Xp=function(n,r){i(this,si).purge==="manual"||i(this,ss).has(n)||r{this.purge(n),i(this,ss).delete(n)}):setTimeout(()=>{this.purge(n),i(this,ss).delete(n)}),i(this,ss).add(n))},oi=new WeakSet,Ds=function(n,r,a=0){const l=!r||-r{const Y=await F.index("version").getAllKeys(IDBKeyRange.bound([n.path,B+1],[n.path,1/0]));for(const X of Y)F.delete(X);F.delete([n.path,"purge",0]);for(let X=0;X=A)break;const T={path:E.path,offset:q,version:B,data:E.data.subarray(N*l,(N+1)*l)};T.offset===0&&(T.fileSize=A,n.block0=T),F.put(T)}}}})};function IN(t){return new Promise((e,n)=>{const r=globalThis.indexedDB.open(t,5);r.addEventListener("upgradeneeded",function(){r.result.createObjectStore("blocks",{keyPath:["path","offset","version"]}).createIndex("version",["path","version"])}),r.addEventListener("success",()=>{e(r.result)}),r.addEventListener("error",()=>{n(r.error)})})}const TN=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,kN=new Ab({async database(){const t=await gN({locateFile:()=>TN}),e=wN(t),n="wa-sqlite-test";e.vfs_register(new AN(n));const r=await e.open_v2(n,void 0,n);return{sqlite:e,db:r}}});function WN(){console.log("start wa-sqlite test"),Ff(kN).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite]",e))})}function RN(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(a){a(n)}),(r=t.get("*"))&&r.slice().map(function(a){a(e,n)})}}}function DN(t){const e=RN(t);return{...e,once(n,r){const a=l=>{e.off(n,a),r(l)};e.on(n,a)}}}var LN=class{constructor(t){ge(this,"config");ge(this,"worker");ge(this,"connection");ge(this,"connectionMutex",new PN);ge(this,"mitt");this.config=t}async init(){var e,n;this.worker=this.config.worker??new Worker(new URL(""+new URL("worker-568e2893.js",import.meta.url).href,self.location),{type:"module"}),this.mitt=DN(),this.worker.onmessage=({data:{msg:r,type:a}})=>{var l;(l=this.mitt)==null||l.emit(a,r)};const t={type:"init",dbName:this.config.dbName,url:this.config.url};this.worker.postMessage(t),await new Promise((r,a)=>{var l;(l=this.mitt)==null||l.once("init",({err:p})=>{p?a(p):r()})}),this.connection=new MN(this.worker,this.mitt),this.config.usePRAGMA&&await this.optimzePragma(this.connection),await((n=(e=this.config).onCreateConnection)==null?void 0:n.call(e,this.connection))}async optimzePragma(t){await t.executeQuery(dn.raw("PRAGMA cache_size = 4096;")),await t.executeQuery(dn.raw("PRAGMA journal_mode = WAL;")),await t.executeQuery(dn.raw("PRAGMA temp_store = MEMORY;")),await t.executeQuery(dn.raw(`PRAGMA page_size = ${32*1024};`)),await t.executeQuery(dn.raw("PRAGMA synchronous = NORMAL;"))}async acquireConnection(){return await this.connectionMutex.lock(),this.connection}async beginTransaction(t){await t.executeQuery(dn.raw("begin"))}async commitTransaction(t){await t.executeQuery(dn.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(dn.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:r})=>{var a,l;r?e(r):((a=this.worker)==null||a.terminate(),(l=this.mitt)==null||l.all.clear(),this.mitt=void 0,t())})})}},PN=class{constructor(){ge(this,"promise");ge(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()}},MN=class{constructor(t,e){ge(this,"worker");ge(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:r}=t,l={type:"run",isQuery:["SelectQueryNode","RawNode"].includes(r.kind),sql:n,parameters:e};return this.worker.postMessage(l),new Promise((p,w)=>{this.mitt||w("kysely instance has been destroyed"),this.mitt.once("run",({data:v,err:d})=>{!d&&v?p(v):w(d)})})}},Ya,Gh,BN=(Gh=class{constructor(t){D(this,Ya,void 0);z(this,Ya,t)}createDriver(){return new LN(i(this,Ya))}createQueryCompiler(){return new Pp}createAdapter(){return new Fp}createIntrospector(t){return new Mp(t)}},Ya=new WeakMap,Gh);const FN=new BN({dbName:"wa-sqlite-worker-test"});function UN(){console.log("start wa-sqlite-worker test"),Ff(FN).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite-worker]",e))})}const $N=_t("h1",null,[Na(" test "),_t("a",{href:"https://github.com/kysely-org/kysely",target:"_blank"},"Kysely"),Na(" WASM dialect ")],-1),QN=_t("br",null,null,-1),jN=_t("h3",null,"see worker result in console",-1),VN=_t("h3",null,[Na(" you can explore "),_t("a",{href:"https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API#origin_private_file_system",target:"_blank"}," OPFS "),Na(" file using "),_t("a",{href:"https://chrome.google.com/webstore/detail/opfs-explorer/acndjpgkpaclldomagafnognkcgjignd",target:"_blank"}," opfs-explorer ")],-1),zN=_t("br",null,null,-1),HN={class:"buttons"},KN=_t("br",null,null,-1),JN=_t("div",null," result run in main thread: ",-1),GN=gy({__name:"App",setup(t){const e=new nN,{result:n,run:r}=tN(),a=new rN;function l(){r()}function p(){e.postMessage("")}function w(){a.postMessage("")}function v(){WN()}function d(){UN()}async function A(){(await window.indexedDB.databases()).forEach(Y=>{window.indexedDB.deleteDatabase(Y.name)})}async function B(){const F=await navigator.storage.getDirectory();await Dh("sqljs"),await Dh("sqlijsWorker"),await A();try{await F.removeEntry("test.db")}catch{}try{await F.removeEntry("test.db-journal")}catch{}console.log("clear all")}return(F,Y)=>(Hy(),Gy(Zn,null,[$N,QN,jN,VN,zN,_t("div",HN,[_t("button",{onClick:Y[0]||(Y[0]=X=>l())}," test sqljs in main thread "),_t("button",{onClick:Y[1]||(Y[1]=X=>p())}," test sqljs in Worker "),_t("button",{onClick:Y[2]||(Y[2]=X=>w())}," test officialWasm in Worker "),_t("button",{onClick:Y[3]||(Y[3]=X=>v())}," test wa-sqlite in main thread "),_t("button",{onClick:Y[4]||(Y[4]=X=>d())}," test wa-sqlite in Worker "),_t("button",{onClick:Y[5]||(Y[5]=X=>B())}," clear ")]),KN,JN,_t("pre",null,""+um(bd(n))+` - `,1)],64))}});Rw(GN).mount("#root"); diff --git a/assets/index-5a44e06c.js b/assets/index-5a44e06c.js new file mode 100644 index 0000000..a072bfa --- /dev/null +++ b/assets/index-5a44e06c.js @@ -0,0 +1,15 @@ +var em=Object.defineProperty;var tm=(t,e,n)=>e in t?em(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ge=(t,e,n)=>(tm(t,typeof e!="symbol"?e+"":e,n),n),ll=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var i=(t,e,n)=>(ll(t,e,"read from private field"),n?n.call(t):e.get(t)),D=(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)},z=(t,e,n,r)=>(ll(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);var _e=(t,e,n)=>(ll(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"]'))r(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const p of l.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&r(p)}).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 r(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),r=t.split(",");for(let a=0;a!!n[a.toLowerCase()]:a=>!!n[a]}function rf(t){if(Ae(t)){const e={};for(let n=0;n{if(n){const r=n.split(rm);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function sf(t){let e="";if(kt(t))e=t;else if(Ae(t))for(let n=0;nkt(t)?t:t==null?"":Ae(t)||ft(t)&&(t.toString===ed||!Ie(t.toString))?JSON.stringify(t,Yh,2):String(t),Yh=(t,e)=>e&&e.__v_isRef?Yh(t,e.value):Vs(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((n,[r,a])=>(n[`${r} =>`]=a,n),{})}:Xh(e)?{[`Set(${e.size})`]:[...e.values()]}:ft(e)&&!Ae(e)&&!td(e)?String(e):e,at={},js=[],rr=()=>{},cm=()=>!1,lm=/^on[^a-z]/,Qc=t=>lm.test(t),of=t=>t.startsWith("onUpdate:"),Gt=Object.assign,af=(t,e)=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)},fm=Object.prototype.hasOwnProperty,Me=(t,e)=>fm.call(t,e),Ae=Array.isArray,Vs=t=>$c(t)==="[object Map]",Xh=t=>$c(t)==="[object Set]",Ie=t=>typeof t=="function",kt=t=>typeof t=="string",uf=t=>typeof t=="symbol",ft=t=>t!==null&&typeof t=="object",Zh=t=>ft(t)&&Ie(t.then)&&Ie(t.catch),ed=Object.prototype.toString,$c=t=>ed.call(t),hm=t=>$c(t).slice(8,-1),td=t=>$c(t)==="[object Object]",cf=t=>kt(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Su=nf(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),jc=t=>{const e=Object.create(null);return n=>e[n]||(e[n]=t(n))},dm=/-(\w)/g,No=jc(t=>t.replace(dm,(e,n)=>n?n.toUpperCase():"")),pm=/\B([A-Z])/g,Co=jc(t=>t.replace(pm,"-$1").toLowerCase()),nd=jc(t=>t.charAt(0).toUpperCase()+t.slice(1)),fl=jc(t=>t?`on${nd(t)}`:""),ma=(t,e)=>!Object.is(t,e),hl=(t,e)=>{for(let n=0;n{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})},mm=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let Vf;const ym=()=>Vf||(Vf=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});let Vn;class wm{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=Vn,!e&&Vn&&(this.index=(Vn.scopes||(Vn.scopes=[])).push(this)-1)}get active(){return this._active}run(e){if(this._active){const n=Vn;try{return Vn=this,e()}finally{Vn=n}}}on(){Vn=this}off(){Vn=this.parent}stop(e){if(this._active){let n,r;for(n=0,r=this.effects.length;n{const e=new Set(t);return e.w=0,e.n=0,e},rd=t=>(t.w&li)>0,id=t=>(t.n&li)>0,Nm=({deps:t})=>{if(t.length)for(let e=0;e{const{deps:e}=t;if(e.length){let n=0;for(let r=0;r{(S==="length"||S>=v)&&w.push(d)})}else switch(n!==void 0&&w.push(p.get(n)),e){case"add":Ae(t)?cf(n)&&w.push(p.get("length")):(w.push(p.get(as)),Vs(t)&&w.push(p.get(El)));break;case"delete":Ae(t)||(w.push(p.get(as)),Vs(t)&&w.push(p.get(El)));break;case"set":Vs(t)&&w.push(p.get(as));break}if(w.length===1)w[0]&&Cl(w[0]);else{const v=[];for(const d of w)d&&v.push(...d);Cl(lf(v))}}function Cl(t,e){const n=Ae(t)?t:[...t];for(const r of n)r.computed&&Hf(r);for(const r of n)r.computed||Hf(r)}function Hf(t,e){(t!==er||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const _m=nf("__proto__,__v_isRef,__isVue"),ad=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(uf)),xm=hf(),Om=hf(!1,!0),Em=hf(!0),Kf=Cm();function Cm(){const t={};return["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...n){const r=Be(this);for(let l=0,p=this.length;l{t[e]=function(...n){qo();const r=Be(this)[e].apply(this,n);return Ao(),r}}),t}function qm(t){const e=Be(this);return yn(e,"has",t),e.hasOwnProperty(t)}function hf(t=!1,e=!1){return function(r,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?$m:hd:e?fd:ld).get(r))return r;const p=Ae(r);if(!t){if(p&&Me(Kf,a))return Reflect.get(Kf,a,l);if(a==="hasOwnProperty")return qm}const w=Reflect.get(r,a,l);return(uf(a)?ad.has(a):_m(a))||(t||yn(r,"get",a),e)?w:Jt(w)?p&&cf(a)?w:w.value:ft(w)?t?dd(w):mf(w):w}}const Am=ud(),Sm=ud(!0);function ud(t=!1){return function(n,r,a,l){let p=n[r];if(vo(p)&&Jt(p)&&!Jt(a))return!1;if(!t&&(!Qu(a)&&!vo(a)&&(p=Be(p),a=Be(a)),!Ae(n)&&Jt(p)&&!Jt(a)))return p.value=a,!0;const w=Ae(n)&&cf(r)?Number(r)t,Vc=t=>Reflect.getPrototypeOf(t);function Nu(t,e,n=!1,r=!1){t=t.__v_raw;const a=Be(t),l=Be(e);n||(e!==l&&yn(a,"get",e),yn(a,"get",l));const{has:p}=Vc(a),w=r?df:n?wf:ya;if(p.call(a,e))return w(t.get(e));if(p.call(a,l))return w(t.get(l));t!==a&&t.get(e)}function vu(t,e=!1){const n=this.__v_raw,r=Be(n),a=Be(t);return e||(t!==a&&yn(r,"has",t),yn(r,"has",a)),t===a?n.has(t):n.has(t)||n.has(a)}function _u(t,e=!1){return t=t.__v_raw,!e&&yn(Be(t),"iterate",as),Reflect.get(t,"size",t)}function Jf(t){t=Be(t);const e=Be(this);return Vc(e).has.call(e,t)||(e.add(t),Tr(e,"add",t,t)),this}function Gf(t,e){e=Be(e);const n=Be(this),{has:r,get:a}=Vc(n);let l=r.call(n,t);l||(t=Be(t),l=r.call(n,t));const p=a.call(n,t);return n.set(t,e),l?ma(e,p)&&Tr(n,"set",t,e):Tr(n,"add",t,e),this}function Yf(t){const e=Be(this),{has:n,get:r}=Vc(e);let a=n.call(e,t);a||(t=Be(t),a=n.call(e,t)),r&&r.call(e,t);const l=e.delete(t);return a&&Tr(e,"delete",t,void 0),l}function Xf(){const t=Be(this),e=t.size!==0,n=t.clear();return e&&Tr(t,"clear",void 0,void 0),n}function xu(t,e){return function(r,a){const l=this,p=l.__v_raw,w=Be(p),v=e?df:t?wf:ya;return!t&&yn(w,"iterate",as),p.forEach((d,S)=>r.call(a,v(d),v(S),l))}}function Ou(t,e,n){return function(...r){const a=this.__v_raw,l=Be(a),p=Vs(l),w=t==="entries"||t===Symbol.iterator&&p,v=t==="keys"&&p,d=a[t](...r),S=n?df:e?wf:ya;return!e&&yn(l,"iterate",v?El:as),{next(){const{value:B,done:j}=d.next();return j?{value:B,done:j}:{value:w?[S(B[0]),S(B[1])]:S(B),done:j}},[Symbol.iterator](){return this}}}}function jr(t){return function(...e){return t==="delete"?!1:this}}function Dm(){const t={get(l){return Nu(this,l)},get size(){return _u(this)},has:vu,add:Jf,set:Gf,delete:Yf,clear:Xf,forEach:xu(!1,!1)},e={get(l){return Nu(this,l,!1,!0)},get size(){return _u(this)},has:vu,add:Jf,set:Gf,delete:Yf,clear:Xf,forEach:xu(!1,!0)},n={get(l){return Nu(this,l,!0)},get size(){return _u(this,!0)},has(l){return vu.call(this,l,!0)},add:jr("add"),set:jr("set"),delete:jr("delete"),clear:jr("clear"),forEach:xu(!0,!1)},r={get(l){return Nu(this,l,!0,!0)},get size(){return _u(this,!0)},has(l){return vu.call(this,l,!0)},add:jr("add"),set:jr("set"),delete:jr("delete"),clear:jr("clear"),forEach:xu(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(l=>{t[l]=Ou(l,!1,!1),n[l]=Ou(l,!0,!1),e[l]=Ou(l,!1,!0),r[l]=Ou(l,!0,!0)}),[t,n,e,r]}const[Pm,Lm,Mm,Bm]=Dm();function pf(t,e){const n=e?t?Bm:Mm:t?Lm:Pm;return(r,a,l)=>a==="__v_isReactive"?!t:a==="__v_isReadonly"?t:a==="__v_raw"?r:Reflect.get(Me(n,a)&&a in r?n:r,a,l)}const Fm={get:pf(!1,!1)},Um={get:pf(!1,!0)},Qm={get:pf(!0,!1)},ld=new WeakMap,fd=new WeakMap,hd=new WeakMap,$m=new WeakMap;function jm(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Vm(t){return t.__v_skip||!Object.isExtensible(t)?0:jm(hm(t))}function mf(t){return vo(t)?t:yf(t,!1,cd,Fm,ld)}function zm(t){return yf(t,!1,Rm,Um,fd)}function dd(t){return yf(t,!0,Wm,Qm,hd)}function yf(t,e,n,r,a){if(!ft(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const l=a.get(t);if(l)return l;const p=Vm(t);if(p===0)return t;const w=new Proxy(t,p===2?r:n);return a.set(t,w),w}function zs(t){return vo(t)?zs(t.__v_raw):!!(t&&t.__v_isReactive)}function vo(t){return!!(t&&t.__v_isReadonly)}function Qu(t){return!!(t&&t.__v_isShallow)}function pd(t){return zs(t)||vo(t)}function Be(t){const e=t&&t.__v_raw;return e?Be(e):t}function md(t){return Uu(t,"__v_skip",!0),t}const ya=t=>ft(t)?mf(t):t,wf=t=>ft(t)?dd(t):t;function yd(t){ai&&er&&(t=Be(t),od(t.dep||(t.dep=lf())))}function wd(t,e){t=Be(t);const n=t.dep;n&&Cl(n)}function Jt(t){return!!(t&&t.__v_isRef===!0)}function Hm(t){return Km(t,!1)}function Km(t,e){return Jt(t)?t:new Jm(t,e)}class Jm{constructor(e,n){this.__v_isShallow=n,this.dep=void 0,this.__v_isRef=!0,this._rawValue=n?e:Be(e),this._value=n?e:ya(e)}get value(){return yd(this),this._value}set value(e){const n=this.__v_isShallow||Qu(e)||vo(e);e=n?e:Be(e),ma(e,this._rawValue)&&(this._rawValue=e,this._value=n?e:ya(e),wd(this))}}function gd(t){return Jt(t)?t.value:t}const Gm={get:(t,e,n)=>gd(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const a=t[e];return Jt(a)&&!Jt(n)?(a.value=n,!0):Reflect.set(t,e,n,r)}};function bd(t){return zs(t)?t:new Proxy(t,Gm)}var Nd;class Ym{constructor(e,n,r,a){this._setter=n,this.dep=void 0,this.__v_isRef=!0,this[Nd]=!1,this._dirty=!0,this.effect=new ff(e,()=>{this._dirty||(this._dirty=!0,wd(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!a,this.__v_isReadonly=r}get value(){const e=Be(this);return yd(e),(e._dirty||!e._cacheable)&&(e._dirty=!1,e._value=e.effect.run()),e._value}set value(e){this._setter(e)}}Nd="__v_isReadonly";function Xm(t,e,n=!1){let r,a;const l=Ie(t);return l?(r=t,a=rr):(r=t.get,a=t.set),new Ym(r,a,l||!a,n)}function ui(t,e,n,r){let a;try{a=r?t(...r):t()}catch(l){zc(l,e,n)}return a}function Rn(t,e,n,r){if(Ie(t)){const l=ui(t,e,n,r);return l&&Zh(l)&&l.catch(p=>{zc(p,e,n)}),l}const a=[];for(let l=0;l>>1;ga(Kt[r])yr&&Kt.splice(e,1)}function ry(t){Ae(t)?Hs.push(...t):(!xr||!xr.includes(t,t.allowRecurse?Mi+1:Mi))&&Hs.push(t),_d()}function Zf(t,e=wa?yr+1:0){for(;ega(n)-ga(r)),Mi=0;Mit.id==null?1/0:t.id,iy=(t,e)=>{const n=ga(t)-ga(e);if(n===0){if(t.pre&&!e.pre)return-1;if(e.pre&&!t.pre)return 1}return n};function Od(t){ql=!1,wa=!0,Kt.sort(iy);const e=rr;try{for(yr=0;yrkt(te)?te.trim():te)),B&&(a=n.map(mm))}let w,v=r[w=fl(e)]||r[w=fl(No(e))];!v&&l&&(v=r[w=fl(Co(e))]),v&&Rn(v,t,6,a);const d=r[w+"Once"];if(d){if(!t.emitted)t.emitted={};else if(t.emitted[w])return;t.emitted[w]=!0,Rn(d,t,6,a)}}function Ed(t,e,n=!1){const r=e.emitsCache,a=r.get(t);if(a!==void 0)return a;const l=t.emits;let p={},w=!1;if(!Ie(t)){const v=d=>{const S=Ed(d,e,!0);S&&(w=!0,Gt(p,S))};!n&&e.mixins.length&&e.mixins.forEach(v),t.extends&&v(t.extends),t.mixins&&t.mixins.forEach(v)}return!l&&!w?(ft(t)&&r.set(t,null),null):(Ae(l)?l.forEach(v=>p[v]=null):Gt(p,l),ft(t)&&r.set(t,p),p)}function Hc(t,e){return!t||!Qc(e)?!1:(e=e.slice(2).replace(/Once$/,""),Me(t,e[0].toLowerCase()+e.slice(1))||Me(t,Co(e))||Me(t,e))}let tr=null,Cd=null;function $u(t){const e=tr;return tr=t,Cd=t&&t.type.__scopeId||null,e}function oy(t,e=tr,n){if(!e||t._n)return t;const r=(...a)=>{r._d&&uh(-1);const l=$u(e);let p;try{p=t(...a)}finally{$u(l),r._d&&uh(1)}return p};return r._n=!0,r._c=!0,r._d=!0,r}function dl(t){const{type:e,vnode:n,proxy:r,withProxy:a,props:l,propsOptions:[p],slots:w,attrs:v,emit:d,render:S,renderCache:B,data:j,setupState:te,ctx:se,inheritAttrs:b}=t;let E,N;const A=$u(t);try{if(n.shapeFlag&4){const X=a||r;E=pr(S.call(X,X,B,l,te,j,se)),N=v}else{const X=e;E=pr(X.length>1?X(l,{attrs:v,slots:w,emit:d}):X(l,null)),N=e.props?v:ay(v)}}catch(X){sa.length=0,zc(X,t,1),E=us(Sr)}let I=E;if(N&&b!==!1){const X=Object.keys(N),{shapeFlag:de}=I;X.length&&de&7&&(p&&X.some(of)&&(N=uy(N,p)),I=fi(I,N))}return n.dirs&&(I=fi(I),I.dirs=I.dirs?I.dirs.concat(n.dirs):n.dirs),n.transition&&(I.transition=n.transition),E=I,$u(A),E}const ay=t=>{let e;for(const n in t)(n==="class"||n==="style"||Qc(n))&&((e||(e={}))[n]=t[n]);return e},uy=(t,e)=>{const n={};for(const r in t)(!of(r)||!(r.slice(9)in e))&&(n[r]=t[r]);return n};function cy(t,e,n){const{props:r,children:a,component:l}=t,{props:p,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 r?eh(r,p,d):!!p;if(v&8){const S=e.dynamicProps;for(let B=0;Bt.__isSuspense;function hy(t,e){e&&e.pendingBranch?Ae(t)?e.effects.push(...t):e.effects.push(t):ry(t)}function dy(t,e){if(xt){let n=xt.provides;const r=xt.parent&&xt.parent.provides;r===n&&(n=xt.provides=Object.create(r)),n[t]=e}}function Iu(t,e,n=!1){const r=xt||tr;if(r){const a=r.parent==null?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides;if(a&&t in a)return a[t];if(arguments.length>1)return n&&Ie(e)?e.call(r.proxy):e}}const Eu={};function pl(t,e,n){return qd(t,e,n)}function qd(t,e,{immediate:n,deep:r,flush:a,onTrack:l,onTrigger:p}=at){const w=bm()===(xt==null?void 0:xt.scope)?xt:null;let v,d=!1,S=!1;if(Jt(t)?(v=()=>t.value,d=Qu(t)):zs(t)?(v=()=>t,r=!0):Ae(t)?(S=!0,d=t.some(I=>zs(I)||Qu(I)),v=()=>t.map(I=>{if(Jt(I))return I.value;if(zs(I))return Ps(I);if(Ie(I))return ui(I,w,2)})):Ie(t)?e?v=()=>ui(t,w,2):v=()=>{if(!(w&&w.isUnmounted))return B&&B(),Rn(t,w,3,[j])}:v=rr,e&&r){const I=v;v=()=>Ps(I())}let B,j=I=>{B=N.onStop=()=>{ui(I,w,4)}},te;if(va)if(j=rr,e?n&&Rn(e,w,3,[v(),S?[]:void 0,j]):v(),a==="sync"){const I=hw();te=I.__watcherHandles||(I.__watcherHandles=[])}else return rr;let se=S?new Array(t.length).fill(Eu):Eu;const b=()=>{if(N.active)if(e){const I=N.run();(r||d||(S?I.some((X,de)=>ma(X,se[de])):ma(I,se)))&&(B&&B(),Rn(e,w,3,[I,se===Eu?void 0:S&&se[0]===Eu?[]:se,j]),se=I)}else N.run()};b.allowRecurse=!!e;let E;a==="sync"?E=b:a==="post"?E=()=>ln(b,w&&w.suspense):(b.pre=!0,w&&(b.id=w.uid),E=()=>bf(b));const N=new ff(v,E);e?n?b():se=N.run():a==="post"?ln(N.run.bind(N),w&&w.suspense):N.run();const A=()=>{N.stop(),w&&w.scope&&af(w.scope.effects,N)};return te&&te.push(A),A}function py(t,e,n){const r=this.proxy,a=kt(t)?t.includes(".")?Ad(r,t):()=>r[t]:t.bind(r,r);let l;Ie(e)?l=e:(l=e.handler,n=e);const p=xt;_o(this);const w=qd(a,l.bind(r),n);return p?_o(p):cs(),w}function Ad(t,e){const n=e.split(".");return()=>{let r=t;for(let a=0;a{Ps(n,e)});else if(td(t))for(const n in t)Ps(t[n],e);return t}function my(){const t={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return kd(()=>{t.isMounted=!0}),Wd(()=>{t.isUnmounting=!0}),t}const kn=[Function,Array],yy={name:"BaseTransition",props:{mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:kn,onEnter:kn,onAfterEnter:kn,onEnterCancelled:kn,onBeforeLeave:kn,onLeave:kn,onAfterLeave:kn,onLeaveCancelled:kn,onBeforeAppear:kn,onAppear:kn,onAfterAppear:kn,onAppearCancelled:kn},setup(t,{slots:e}){const n=iw(),r=my();let a;return()=>{const l=e.default&&Id(e.default(),!0);if(!l||!l.length)return;let p=l[0];if(l.length>1){for(const b of l)if(b.type!==Sr){p=b;break}}const w=Be(t),{mode:v}=w;if(r.isLeaving)return ml(p);const d=th(p);if(!d)return ml(p);const S=Al(d,w,r,n);Sl(d,S);const B=n.subTree,j=B&&th(B);let te=!1;const{getTransitionKey:se}=d.type;if(se){const b=se();a===void 0?a=b:b!==a&&(a=b,te=!0)}if(j&&j.type!==Sr&&(!Bi(d,j)||te)){const b=Al(j,w,r,n);if(Sl(j,b),v==="out-in")return r.isLeaving=!0,b.afterLeave=()=>{r.isLeaving=!1,n.update.active!==!1&&n.update()},ml(p);v==="in-out"&&d.type!==Sr&&(b.delayLeave=(E,N,A)=>{const I=Sd(r,j);I[String(j.key)]=j,E._leaveCb=()=>{N(),E._leaveCb=void 0,delete S.delayedLeave},S.delayedLeave=A})}return p}}},wy=yy;function Sd(t,e){const{leavingVNodes:n}=t;let r=n.get(e.type);return r||(r=Object.create(null),n.set(e.type,r)),r}function Al(t,e,n,r){const{appear:a,mode:l,persisted:p=!1,onBeforeEnter:w,onEnter:v,onAfterEnter:d,onEnterCancelled:S,onBeforeLeave:B,onLeave:j,onAfterLeave:te,onLeaveCancelled:se,onBeforeAppear:b,onAppear:E,onAfterAppear:N,onAppearCancelled:A}=e,I=String(t.key),X=Sd(n,t),de=(Ne,Ze)=>{Ne&&Rn(Ne,r,9,Ze)},oe=(Ne,Ze)=>{const He=Ze[1];de(Ne,Ze),Ae(Ne)?Ne.every(Ot=>Ot.length<=1)&&He():Ne.length<=1&&He()},be={mode:l,persisted:p,beforeEnter(Ne){let Ze=w;if(!n.isMounted)if(a)Ze=b||w;else return;Ne._leaveCb&&Ne._leaveCb(!0);const He=X[I];He&&Bi(t,He)&&He.el._leaveCb&&He.el._leaveCb(),de(Ze,[Ne])},enter(Ne){let Ze=v,He=d,Ot=S;if(!n.isMounted)if(a)Ze=E||v,He=N||d,Ot=A||S;else return;let Et=!1;const $e=Ne._enterCb=Qt=>{Et||(Et=!0,Qt?de(Ot,[Ne]):de(He,[Ne]),be.delayedLeave&&be.delayedLeave(),Ne._enterCb=void 0)};Ze?oe(Ze,[Ne,$e]):$e()},leave(Ne,Ze){const He=String(t.key);if(Ne._enterCb&&Ne._enterCb(!0),n.isUnmounting)return Ze();de(B,[Ne]);let Ot=!1;const Et=Ne._leaveCb=$e=>{Ot||(Ot=!0,Ze(),$e?de(se,[Ne]):de(te,[Ne]),Ne._leaveCb=void 0,X[He]===t&&delete X[He])};X[He]=t,j?oe(j,[Ne,Et]):Et()},clone(Ne){return Al(Ne,e,n,r)}};return be}function ml(t){if(Kc(t))return t=fi(t),t.children=null,t}function th(t){return Kc(t)?t.children?t.children[0]:void 0:t}function Sl(t,e){t.shapeFlag&6&&t.component?Sl(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 Id(t,e=!1,n){let r=[],a=0;for(let l=0;l1)for(let l=0;l!!t.type.__asyncLoader,Kc=t=>t.type.__isKeepAlive;function by(t,e){Td(t,"a",e)}function Ny(t,e){Td(t,"da",e)}function Td(t,e,n=xt){const r=t.__wdc||(t.__wdc=()=>{let a=n;for(;a;){if(a.isDeactivated)return;a=a.parent}return t()});if(Jc(e,r,n),n){let a=n.parent;for(;a&&a.parent;)Kc(a.parent.vnode)&&vy(r,e,n,a),a=a.parent}}function vy(t,e,n,r){const a=Jc(e,t,r,!0);Rd(()=>{af(r[e],a)},n)}function Jc(t,e,n=xt,r=!1){if(n){const a=n[t]||(n[t]=[]),l=e.__weh||(e.__weh=(...p)=>{if(n.isUnmounted)return;qo(),_o(n);const w=Rn(e,n,t,p);return cs(),Ao(),w});return r?a.unshift(l):a.push(l),l}}const Rr=t=>(e,n=xt)=>(!va||t==="sp")&&Jc(t,(...r)=>e(...r),n),_y=Rr("bm"),kd=Rr("m"),xy=Rr("bu"),Oy=Rr("u"),Wd=Rr("bum"),Rd=Rr("um"),Ey=Rr("sp"),Cy=Rr("rtg"),qy=Rr("rtc");function Ay(t,e=xt){Jc("ec",t,e)}function Ri(t,e,n,r){const a=t.dirs,l=e&&e.dirs;for(let p=0;pt?jd(t)?xf(t)||t.proxy:Il(t.parent):null,ia=Gt(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=>Il(t.parent),$root:t=>Il(t.root),$emit:t=>t.emit,$options:t=>Nf(t),$forceUpdate:t=>t.f||(t.f=()=>bf(t.update)),$nextTick:t=>t.n||(t.n=ey.bind(t.proxy)),$watch:t=>py.bind(t)}),yl=(t,e)=>t!==at&&!t.__isScriptSetup&&Me(t,e),Iy={get({_:t},e){const{ctx:n,setupState:r,data:a,props:l,accessCache:p,type:w,appContext:v}=t;let d;if(e[0]!=="$"){const te=p[e];if(te!==void 0)switch(te){case 1:return r[e];case 2:return a[e];case 4:return n[e];case 3:return l[e]}else{if(yl(r,e))return p[e]=1,r[e];if(a!==at&&Me(a,e))return p[e]=2,a[e];if((d=t.propsOptions[0])&&Me(d,e))return p[e]=3,l[e];if(n!==at&&Me(n,e))return p[e]=4,n[e];Tl&&(p[e]=0)}}const S=ia[e];let B,j;if(S)return e==="$attrs"&&yn(t,"get",e),S(t);if((B=w.__cssModules)&&(B=B[e]))return B;if(n!==at&&Me(n,e))return p[e]=4,n[e];if(j=v.config.globalProperties,Me(j,e))return j[e]},set({_:t},e,n){const{data:r,setupState:a,ctx:l}=t;return yl(a,e)?(a[e]=n,!0):r!==at&&Me(r,e)?(r[e]=n,!0):Me(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(l[e]=n,!0)},has({_:{data:t,setupState:e,accessCache:n,ctx:r,appContext:a,propsOptions:l}},p){let w;return!!n[p]||t!==at&&Me(t,p)||yl(e,p)||(w=l[0])&&Me(w,p)||Me(r,p)||Me(ia,p)||Me(a.config.globalProperties,p)},defineProperty(t,e,n){return n.get!=null?t._.accessCache[e]=0:Me(n,"value")&&this.set(t,e,n.value,null),Reflect.defineProperty(t,e,n)}};let Tl=!0;function Ty(t){const e=Nf(t),n=t.proxy,r=t.ctx;Tl=!1,e.beforeCreate&&nh(e.beforeCreate,t,"bc");const{data:a,computed:l,methods:p,watch:w,provide:v,inject:d,created:S,beforeMount:B,mounted:j,beforeUpdate:te,updated:se,activated:b,deactivated:E,beforeDestroy:N,beforeUnmount:A,destroyed:I,unmounted:X,render:de,renderTracked:oe,renderTriggered:be,errorCaptured:Ne,serverPrefetch:Ze,expose:He,inheritAttrs:Ot,components:Et,directives:$e,filters:Qt}=e;if(d&&ky(d,r,null,t.appContext.config.unwrapInjectedRef),p)for(const me in p){const qe=p[me];Ie(qe)&&(r[me]=qe.bind(n))}if(a){const me=a.call(n,n);ft(me)&&(t.data=mf(me))}if(Tl=!0,l)for(const me in l){const qe=l[me],st=Ie(qe)?qe.bind(n,n):Ie(qe.get)?qe.get.bind(n,n):rr,pe=!Ie(qe)&&Ie(qe.set)?qe.set.bind(n):rr,ke=lw({get:st,set:pe});Object.defineProperty(r,me,{enumerable:!0,configurable:!0,get:()=>ke.value,set:Wt=>ke.value=Wt})}if(w)for(const me in w)Dd(w[me],r,n,me);if(v){const me=Ie(v)?v.call(n):v;Reflect.ownKeys(me).forEach(qe=>{dy(qe,me[qe])})}S&&nh(S,t,"c");function ht(me,qe){Ae(qe)?qe.forEach(st=>me(st.bind(n))):qe&&me(qe.bind(n))}if(ht(_y,B),ht(kd,j),ht(xy,te),ht(Oy,se),ht(by,b),ht(Ny,E),ht(Ay,Ne),ht(qy,oe),ht(Cy,be),ht(Wd,A),ht(Rd,X),ht(Ey,Ze),Ae(He))if(He.length){const me=t.exposed||(t.exposed={});He.forEach(qe=>{Object.defineProperty(me,qe,{get:()=>n[qe],set:st=>n[qe]=st})})}else t.exposed||(t.exposed={});de&&t.render===rr&&(t.render=de),Ot!=null&&(t.inheritAttrs=Ot),Et&&(t.components=Et),$e&&(t.directives=$e)}function ky(t,e,n=rr,r=!1){Ae(t)&&(t=kl(t));for(const a in t){const l=t[a];let p;ft(l)?"default"in l?p=Iu(l.from||a,l.default,!0):p=Iu(l.from||a):p=Iu(l),Jt(p)&&r?Object.defineProperty(e,a,{enumerable:!0,configurable:!0,get:()=>p.value,set:w=>p.value=w}):e[a]=p}}function nh(t,e,n){Rn(Ae(t)?t.map(r=>r.bind(e.proxy)):t.bind(e.proxy),e,n)}function Dd(t,e,n,r){const a=r.includes(".")?Ad(n,r):()=>n[r];if(kt(t)){const l=e[t];Ie(l)&&pl(a,l)}else if(Ie(t))pl(a,t.bind(n));else if(ft(t))if(Ae(t))t.forEach(l=>Dd(l,e,n,r));else{const l=Ie(t.handler)?t.handler.bind(n):e[t.handler];Ie(l)&&pl(a,l,t)}}function Nf(t){const e=t.type,{mixins:n,extends:r}=e,{mixins:a,optionsCache:l,config:{optionMergeStrategies:p}}=t.appContext,w=l.get(e);let v;return w?v=w:!a.length&&!n&&!r?v=e:(v={},a.length&&a.forEach(d=>ju(v,d,p,!0)),ju(v,e,p)),ft(e)&&l.set(e,v),v}function ju(t,e,n,r=!1){const{mixins:a,extends:l}=e;l&&ju(t,l,n,!0),a&&a.forEach(p=>ju(t,p,n,!0));for(const p in e)if(!(r&&p==="expose")){const w=Wy[p]||n&&n[p];t[p]=w?w(t[p],e[p]):e[p]}return t}const Wy={data:rh,props:Li,emits:Li,methods:Li,computed:Li,beforeCreate:Xt,created:Xt,beforeMount:Xt,mounted:Xt,beforeUpdate:Xt,updated:Xt,beforeDestroy:Xt,beforeUnmount:Xt,destroyed:Xt,unmounted:Xt,activated:Xt,deactivated:Xt,errorCaptured:Xt,serverPrefetch:Xt,components:Li,directives:Li,watch:Dy,provide:rh,inject:Ry};function rh(t,e){return e?t?function(){return Gt(Ie(t)?t.call(this,this):t,Ie(e)?e.call(this,this):e)}:e:t}function Ry(t,e){return Li(kl(t),kl(e))}function kl(t){if(Ae(t)){const e={};for(let n=0;n0)&&!(p&16)){if(p&8){const S=t.vnode.dynamicProps;for(let B=0;B{v=!0;const[j,te]=Ld(B,e,!0);Gt(p,j),te&&w.push(...te)};!n&&e.mixins.length&&e.mixins.forEach(S),t.extends&&S(t.extends),t.mixins&&t.mixins.forEach(S)}if(!l&&!v)return ft(t)&&r.set(t,js),js;if(Ae(l))for(let S=0;S-1,te[1]=b<0||se-1||Me(te,"default"))&&w.push(B)}}}const d=[p,w];return ft(t)&&r.set(t,d),d}function ih(t){return t[0]!=="$"}function sh(t){const e=t&&t.toString().match(/^\s*(function|class) (\w+)/);return e?e[2]:t===null?"null":""}function oh(t,e){return sh(t)===sh(e)}function ah(t,e){return Ae(e)?e.findIndex(n=>oh(n,t)):Ie(e)&&oh(e,t)?0:-1}const Md=t=>t[0]==="_"||t==="$stable",vf=t=>Ae(t)?t.map(pr):[pr(t)],My=(t,e,n)=>{if(e._n)return e;const r=oy((...a)=>vf(e(...a)),n);return r._c=!1,r},Bd=(t,e,n)=>{const r=t._ctx;for(const a in t){if(Md(a))continue;const l=t[a];if(Ie(l))e[a]=My(a,l,r);else if(l!=null){const p=vf(l);e[a]=()=>p}}},Fd=(t,e)=>{const n=vf(e);t.slots.default=()=>n},By=(t,e)=>{if(t.vnode.shapeFlag&32){const n=e._;n?(t.slots=Be(e),Uu(e,"_",n)):Bd(e,t.slots={})}else t.slots={},e&&Fd(t,e);Uu(t.slots,Yc,1)},Fy=(t,e,n)=>{const{vnode:r,slots:a}=t;let l=!0,p=at;if(r.shapeFlag&32){const w=e._;w?n&&w===1?l=!1:(Gt(a,e),!n&&w===1&&delete a._):(l=!e.$stable,Bd(e,a)),p=e}else e&&(Fd(t,e),p={default:1});if(l)for(const w in a)!Md(w)&&!(w in p)&&delete a[w]};function Ud(){return{app:null,config:{isNativeTag:cm,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 Uy=0;function Qy(t,e){return function(r,a=null){Ie(r)||(r=Object.assign({},r)),a!=null&&!ft(a)&&(a=null);const l=Ud(),p=new Set;let w=!1;const v=l.app={_uid:Uy++,_component:r,_props:a,_container:null,_context:l,_instance:null,version:dw,get config(){return l.config},set config(d){},use(d,...S){return p.has(d)||(d&&Ie(d.install)?(p.add(d),d.install(v,...S)):Ie(d)&&(p.add(d),d(v,...S))),v},mixin(d){return l.mixins.includes(d)||l.mixins.push(d),v},component(d,S){return S?(l.components[d]=S,v):l.components[d]},directive(d,S){return S?(l.directives[d]=S,v):l.directives[d]},mount(d,S,B){if(!w){const j=us(r,a);return j.appContext=l,S&&e?e(j,d):t(j,d,B),w=!0,v._container=d,d.__vue_app__=v,xf(j.component)||j.component.proxy}},unmount(){w&&(t(null,v._container),delete v._container.__vue_app__)},provide(d,S){return l.provides[d]=S,v}};return v}}function Rl(t,e,n,r,a=!1){if(Ae(t)){t.forEach((j,te)=>Rl(j,e&&(Ae(e)?e[te]:e),n,r,a));return}if(Tu(r)&&!a)return;const l=r.shapeFlag&4?xf(r.component)||r.component.proxy:r.el,p=a?null:l,{i:w,r:v}=t,d=e&&e.r,S=w.refs===at?w.refs={}:w.refs,B=w.setupState;if(d!=null&&d!==v&&(kt(d)?(S[d]=null,Me(B,d)&&(B[d]=null)):Jt(d)&&(d.value=null)),Ie(v))ui(v,w,12,[p,S]);else{const j=kt(v),te=Jt(v);if(j||te){const se=()=>{if(t.f){const b=j?Me(B,v)?B[v]:S[v]:v.value;a?Ae(b)&&af(b,l):Ae(b)?b.includes(l)||b.push(l):j?(S[v]=[l],Me(B,v)&&(B[v]=S[v])):(v.value=[l],t.k&&(S[t.k]=v.value))}else j?(S[v]=p,Me(B,v)&&(B[v]=p)):te&&(v.value=p,t.k&&(S[t.k]=p))};p?(se.id=-1,ln(se,n)):se()}}}const ln=hy;function $y(t){return jy(t)}function jy(t,e){const n=ym();n.__VUE__=!0;const{insert:r,remove:a,patchProp:l,createElement:p,createText:w,createComment:v,setText:d,setElementText:S,parentNode:B,nextSibling:j,setScopeId:te=rr,insertStaticContent:se}=t,b=(x,C,W,L=null,H=null,Z=null,U=!1,V=null,ne=!!C.dynamicChildren)=>{if(x===C)return;x&&!Bi(x,C)&&(L=fe(x),Wt(x,H,Z,!0),x=null),C.patchFlag===-2&&(ne=!1,C.dynamicChildren=null);const{type:K,ref:ce,shapeFlag:ae}=C;switch(K){case Gc:E(x,C,W,L);break;case Sr:N(x,C,W,L);break;case wl:x==null&&A(C,W,L,U);break;case Zn:Et(x,C,W,L,H,Z,U,V,ne);break;default:ae&1?de(x,C,W,L,H,Z,U,V,ne):ae&6?$e(x,C,W,L,H,Z,U,V,ne):(ae&64||ae&128)&&K.process(x,C,W,L,H,Z,U,V,ne,Mn)}ce!=null&&H&&Rl(ce,x&&x.ref,Z,C||x,!C)},E=(x,C,W,L)=>{if(x==null)r(C.el=w(C.children),W,L);else{const H=C.el=x.el;C.children!==x.children&&d(H,C.children)}},N=(x,C,W,L)=>{x==null?r(C.el=v(C.children||""),W,L):C.el=x.el},A=(x,C,W,L)=>{[x.el,x.anchor]=se(x.children,C,W,L,x.el,x.anchor)},I=({el:x,anchor:C},W,L)=>{let H;for(;x&&x!==C;)H=j(x),r(x,W,L),x=H;r(C,W,L)},X=({el:x,anchor:C})=>{let W;for(;x&&x!==C;)W=j(x),a(x),x=W;a(C)},de=(x,C,W,L,H,Z,U,V,ne)=>{U=U||C.type==="svg",x==null?oe(C,W,L,H,Z,U,V,ne):Ze(x,C,H,Z,U,V,ne)},oe=(x,C,W,L,H,Z,U,V)=>{let ne,K;const{type:ce,props:ae,shapeFlag:ue,transition:ye,dirs:Oe}=x;if(ne=x.el=p(x.type,Z,ae&&ae.is,ae),ue&8?S(ne,x.children):ue&16&&Ne(x.children,ne,null,L,H,Z&&ce!=="foreignObject",U,V),Oe&&Ri(x,null,L,"created"),be(ne,x,x.scopeId,U,L),ae){for(const De in ae)De!=="value"&&!Su(De)&&l(ne,De,null,ae[De],Z,x.children,L,H,sn);"value"in ae&&l(ne,"value",null,ae.value),(K=ae.onVnodeBeforeMount)&&ur(K,L,x)}Oe&&Ri(x,null,L,"beforeMount");const je=(!H||H&&!H.pendingBranch)&&ye&&!ye.persisted;je&&ye.beforeEnter(ne),r(ne,C,W),((K=ae&&ae.onVnodeMounted)||je||Oe)&&ln(()=>{K&&ur(K,L,x),je&&ye.enter(ne),Oe&&Ri(x,null,L,"mounted")},H)},be=(x,C,W,L,H)=>{if(W&&te(x,W),L)for(let Z=0;Z{for(let K=ne;K{const V=C.el=x.el;let{patchFlag:ne,dynamicChildren:K,dirs:ce}=C;ne|=x.patchFlag&16;const ae=x.props||at,ue=C.props||at;let ye;W&&Di(W,!1),(ye=ue.onVnodeBeforeUpdate)&&ur(ye,W,C,x),ce&&Ri(C,x,W,"beforeUpdate"),W&&Di(W,!0);const Oe=H&&C.type!=="foreignObject";if(K?He(x.dynamicChildren,K,V,W,L,Oe,Z):U||qe(x,C,V,null,W,L,Oe,Z,!1),ne>0){if(ne&16)Ot(V,C,ae,ue,W,L,H);else if(ne&2&&ae.class!==ue.class&&l(V,"class",null,ue.class,H),ne&4&&l(V,"style",ae.style,ue.style,H),ne&8){const je=C.dynamicProps;for(let De=0;De{ye&&ur(ye,W,C,x),ce&&Ri(C,x,W,"updated")},L)},He=(x,C,W,L,H,Z,U)=>{for(let V=0;V{if(W!==L){if(W!==at)for(const V in W)!Su(V)&&!(V in L)&&l(x,V,W[V],null,U,C.children,H,Z,sn);for(const V in L){if(Su(V))continue;const ne=L[V],K=W[V];ne!==K&&V!=="value"&&l(x,V,K,ne,U,C.children,H,Z,sn)}"value"in L&&l(x,"value",W.value,L.value)}},Et=(x,C,W,L,H,Z,U,V,ne)=>{const K=C.el=x?x.el:w(""),ce=C.anchor=x?x.anchor:w("");let{patchFlag:ae,dynamicChildren:ue,slotScopeIds:ye}=C;ye&&(V=V?V.concat(ye):ye),x==null?(r(K,W,L),r(ce,W,L),Ne(C.children,W,ce,H,Z,U,V,ne)):ae>0&&ae&64&&ue&&x.dynamicChildren?(He(x.dynamicChildren,ue,W,H,Z,U,V),(C.key!=null||H&&C===H.subTree)&&Qd(x,C,!0)):qe(x,C,W,ce,H,Z,U,V,ne)},$e=(x,C,W,L,H,Z,U,V,ne)=>{C.slotScopeIds=V,x==null?C.shapeFlag&512?H.ctx.activate(C,W,L,U,ne):Qt(C,W,L,H,Z,U,ne):rn(x,C,ne)},Qt=(x,C,W,L,H,Z,U)=>{const V=x.component=rw(x,L,H);if(Kc(x)&&(V.ctx.renderer=Mn),sw(V),V.asyncDep){if(H&&H.registerDep(V,ht),!x.el){const ne=V.subTree=us(Sr);N(null,ne,C,W)}return}ht(V,x,C,W,H,Z,U)},rn=(x,C,W)=>{const L=C.component=x.component;if(cy(x,C,W))if(L.asyncDep&&!L.asyncResolved){me(L,C,W);return}else L.next=C,ny(L.update),L.update();else C.el=x.el,L.vnode=C},ht=(x,C,W,L,H,Z,U)=>{const V=()=>{if(x.isMounted){let{next:ce,bu:ae,u:ue,parent:ye,vnode:Oe}=x,je=ce,De;Di(x,!1),ce?(ce.el=Oe.el,me(x,ce,U)):ce=Oe,ae&&hl(ae),(De=ce.props&&ce.props.onVnodeBeforeUpdate)&&ur(De,ye,ce,Oe),Di(x,!0);const rt=dl(x),he=x.subTree;x.subTree=rt,b(he,rt,B(he.el),fe(he),x,H,Z),ce.el=rt.el,je===null&&ly(x,rt.el),ue&&ln(ue,H),(De=ce.props&&ce.props.onVnodeUpdated)&&ln(()=>ur(De,ye,ce,Oe),H)}else{let ce;const{el:ae,props:ue}=C,{bm:ye,m:Oe,parent:je}=x,De=Tu(C);if(Di(x,!1),ye&&hl(ye),!De&&(ce=ue&&ue.onVnodeBeforeMount)&&ur(ce,je,C),Di(x,!0),ae&&Ke){const rt=()=>{x.subTree=dl(x),Ke(ae,x.subTree,x,H,null)};De?C.type.__asyncLoader().then(()=>!x.isUnmounted&&rt()):rt()}else{const rt=x.subTree=dl(x);b(null,rt,W,L,x,H,Z),C.el=rt.el}if(Oe&&ln(Oe,H),!De&&(ce=ue&&ue.onVnodeMounted)){const rt=C;ln(()=>ur(ce,je,rt),H)}(C.shapeFlag&256||je&&Tu(je.vnode)&&je.vnode.shapeFlag&256)&&x.a&&ln(x.a,H),x.isMounted=!0,C=W=L=null}},ne=x.effect=new ff(V,()=>bf(K),x.scope),K=x.update=()=>ne.run();K.id=x.uid,Di(x,!0),K()},me=(x,C,W)=>{C.component=x;const L=x.vnode.props;x.vnode=C,x.next=null,Ly(x,C.props,L,W),Fy(x,C.children,W),qo(),Zf(),Ao()},qe=(x,C,W,L,H,Z,U,V,ne=!1)=>{const K=x&&x.children,ce=x?x.shapeFlag:0,ae=C.children,{patchFlag:ue,shapeFlag:ye}=C;if(ue>0){if(ue&128){pe(K,ae,W,L,H,Z,U,V,ne);return}else if(ue&256){st(K,ae,W,L,H,Z,U,V,ne);return}}ye&8?(ce&16&&sn(K,H,Z),ae!==K&&S(W,ae)):ce&16?ye&16?pe(K,ae,W,L,H,Z,U,V,ne):sn(K,H,Z,!0):(ce&8&&S(W,""),ye&16&&Ne(ae,W,L,H,Z,U,V,ne))},st=(x,C,W,L,H,Z,U,V,ne)=>{x=x||js,C=C||js;const K=x.length,ce=C.length,ae=Math.min(K,ce);let ue;for(ue=0;uece?sn(x,H,Z,!0,!1,ae):Ne(C,W,L,H,Z,U,V,ne,ae)},pe=(x,C,W,L,H,Z,U,V,ne)=>{let K=0;const ce=C.length;let ae=x.length-1,ue=ce-1;for(;K<=ae&&K<=ue;){const ye=x[K],Oe=C[K]=ne?Hr(C[K]):pr(C[K]);if(Bi(ye,Oe))b(ye,Oe,W,null,H,Z,U,V,ne);else break;K++}for(;K<=ae&&K<=ue;){const ye=x[ae],Oe=C[ue]=ne?Hr(C[ue]):pr(C[ue]);if(Bi(ye,Oe))b(ye,Oe,W,null,H,Z,U,V,ne);else break;ae--,ue--}if(K>ae){if(K<=ue){const ye=ue+1,Oe=yeue)for(;K<=ae;)Wt(x[K],H,Z,!0),K++;else{const ye=K,Oe=K,je=new Map;for(K=Oe;K<=ue;K++){const le=C[K]=ne?Hr(C[K]):pr(C[K]);le.key!=null&&je.set(le.key,K)}let De,rt=0;const he=ue-Oe+1;let gn=!1,mi=0;const jt=new Array(he);for(K=0;K=he){Wt(le,H,Z,!0);continue}let Rt;if(le.key!=null)Rt=je.get(le.key);else for(De=Oe;De<=ue;De++)if(jt[De-Oe]===0&&Bi(le,C[De])){Rt=De;break}Rt===void 0?Wt(le,H,Z,!0):(jt[Rt-Oe]=K+1,Rt>=mi?mi=Rt:gn=!0,b(le,C[Rt],W,null,H,Z,U,V,ne),rt++)}const ps=gn?Vy(jt):js;for(De=ps.length-1,K=he-1;K>=0;K--){const le=Oe+K,Rt=C[le],ee=le+1{const{el:Z,type:U,transition:V,children:ne,shapeFlag:K}=x;if(K&6){ke(x.component.subTree,C,W,L);return}if(K&128){x.suspense.move(C,W,L);return}if(K&64){U.move(x,C,W,Mn);return}if(U===Zn){r(Z,C,W);for(let ae=0;aeV.enter(Z),H);else{const{leave:ae,delayLeave:ue,afterLeave:ye}=V,Oe=()=>r(Z,C,W),je=()=>{ae(Z,()=>{Oe(),ye&&ye()})};ue?ue(Z,Oe,je):je()}else r(Z,C,W)},Wt=(x,C,W,L=!1,H=!1)=>{const{type:Z,props:U,ref:V,children:ne,dynamicChildren:K,shapeFlag:ce,patchFlag:ae,dirs:ue}=x;if(V!=null&&Rl(V,null,W,x,!0),ce&256){C.ctx.deactivate(x);return}const ye=ce&1&&ue,Oe=!Tu(x);let je;if(Oe&&(je=U&&U.onVnodeBeforeUnmount)&&ur(je,C,x),ce&6)wn(x.component,W,L);else{if(ce&128){x.suspense.unmount(W,L);return}ye&&Ri(x,null,C,"beforeUnmount"),ce&64?x.type.remove(x,C,W,H,Mn,L):K&&(Z!==Zn||ae>0&&ae&64)?sn(K,C,W,!1,!0):(Z===Zn&&ae&384||!H&&ce&16)&&sn(ne,C,W),L&&br(x)}(Oe&&(je=U&&U.onVnodeUnmounted)||ye)&&ln(()=>{je&&ur(je,C,x),ye&&Ri(x,null,C,"unmounted")},W)},br=x=>{const{type:C,el:W,anchor:L,transition:H}=x;if(C===Zn){ds(W,L);return}if(C===wl){X(x);return}const Z=()=>{a(W),H&&!H.persisted&&H.afterLeave&&H.afterLeave()};if(x.shapeFlag&1&&H&&!H.persisted){const{leave:U,delayLeave:V}=H,ne=()=>U(W,Z);V?V(x.el,Z,ne):ne()}else Z()},ds=(x,C)=>{let W;for(;x!==C;)W=j(x),a(x),x=W;a(C)},wn=(x,C,W)=>{const{bum:L,scope:H,update:Z,subTree:U,um:V}=x;L&&hl(L),H.stop(),Z&&(Z.active=!1,Wt(U,x,C,W)),V&&ln(V,C),ln(()=>{x.isUnmounted=!0},C),C&&C.pendingBranch&&!C.isUnmounted&&x.asyncDep&&!x.asyncResolved&&x.suspenseId===C.pendingId&&(C.deps--,C.deps===0&&C.resolve())},sn=(x,C,W,L=!1,H=!1,Z=0)=>{for(let U=Z;Ux.shapeFlag&6?fe(x.component.subTree):x.shapeFlag&128?x.suspense.next():j(x.anchor||x.el),Le=(x,C,W)=>{x==null?C._vnode&&Wt(C._vnode,null,null,!0):b(C._vnode||null,x,C,null,null,null,W),Zf(),xd(),C._vnode=x},Mn={p:b,um:Wt,m:ke,r:br,mt:Qt,mc:Ne,pc:qe,pbc:He,n:fe,o:t};let $t,Ke;return e&&([$t,Ke]=e(Mn)),{render:Le,hydrate:$t,createApp:Qy(Le,$t)}}function Di({effect:t,update:e},n){t.allowRecurse=e.allowRecurse=n}function Qd(t,e,n=!1){const r=t.children,a=e.children;if(Ae(r)&&Ae(a))for(let l=0;l>1,t[n[w]]0&&(e[r]=n[l-1]),n[l]=r)}}for(l=n.length,p=n[l-1];l-- >0;)n[l]=p,p=e[p];return n}const zy=t=>t.__isTeleport,Zn=Symbol(void 0),Gc=Symbol(void 0),Sr=Symbol(void 0),wl=Symbol(void 0),sa=[];let nr=null;function Hy(t=!1){sa.push(nr=t?null:[])}function Ky(){sa.pop(),nr=sa[sa.length-1]||null}let ba=1;function uh(t){ba+=t}function Jy(t){return t.dynamicChildren=ba>0?nr||js:null,Ky(),ba>0&&nr&&nr.push(t),t}function Gy(t,e,n,r,a,l){return Jy(_t(t,e,n,r,a,l,!0))}function Yy(t){return t?t.__v_isVNode===!0:!1}function Bi(t,e){return t.type===e.type&&t.key===e.key}const Yc="__vInternal",$d=({key:t})=>t??null,ku=({ref:t,ref_key:e,ref_for:n})=>t!=null?kt(t)||Jt(t)||Ie(t)?{i:tr,r:t,k:e,f:!!n}:t:null;function _t(t,e=null,n=null,r=0,a=null,l=t===Zn?0:1,p=!1,w=!1){const v={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&$d(e),ref:e&&ku(e),scopeId:Cd,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:r,dynamicProps:a,dynamicChildren:null,appContext:null,ctx:tr};return w?(_f(v,n),l&128&&t.normalize(v)):n&&(v.shapeFlag|=kt(n)?8:16),ba>0&&!p&&nr&&(v.patchFlag>0||l&6)&&v.patchFlag!==32&&nr.push(v),v}const us=Xy;function Xy(t,e=null,n=null,r=0,a=null,l=!1){if((!t||t===Sy)&&(t=Sr),Yy(t)){const w=fi(t,e,!0);return n&&_f(w,n),ba>0&&!l&&nr&&(w.shapeFlag&6?nr[nr.indexOf(t)]=w:nr.push(w)),w.patchFlag|=-2,w}if(cw(t)&&(t=t.__vccOpts),e){e=Zy(e);let{class:w,style:v}=e;w&&!kt(w)&&(e.class=sf(w)),ft(v)&&(pd(v)&&!Ae(v)&&(v=Gt({},v)),e.style=rf(v))}const p=kt(t)?1:fy(t)?128:zy(t)?64:ft(t)?4:Ie(t)?2:0;return _t(t,e,n,r,a,p,l,!0)}function Zy(t){return t?pd(t)||Yc in t?Gt({},t):t:null}function fi(t,e,n=!1){const{props:r,ref:a,patchFlag:l,children:p}=t,w=e?ew(r||{},e):r;return{__v_isVNode:!0,__v_skip:!0,type:t.type,props:w,key:w&&$d(w),ref:e&&e.ref?n&&a?Ae(a)?a.concat(ku(e)):[a,ku(e)]:ku(e):a,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:p,target:t.target,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==Zn?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&&fi(t.ssContent),ssFallback:t.ssFallback&&fi(t.ssFallback),el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce}}function Na(t=" ",e=0){return us(Gc,null,t,e)}function pr(t){return t==null||typeof t=="boolean"?us(Sr):Ae(t)?us(Zn,null,t.slice()):typeof t=="object"?Hr(t):us(Gc,null,String(t))}function Hr(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:fi(t)}function _f(t,e){let n=0;const{shapeFlag:r}=t;if(e==null)e=null;else if(Ae(e))n=16;else if(typeof e=="object")if(r&65){const a=e.default;a&&(a._c&&(a._d=!1),_f(t,a()),a._c&&(a._d=!0));return}else{n=32;const a=e._;!a&&!(Yc in e)?e._ctx=tr:a===3&&tr&&(tr.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Ie(e)?(e={default:e,_ctx:tr},n=32):(e=String(e),r&64?(n=16,e=[Na(e)]):n=8);t.children=e,t.shapeFlag|=n}function ew(...t){const e={};for(let n=0;nxt||tr,_o=t=>{xt=t,t.scope.on()},cs=()=>{xt&&xt.scope.off(),xt=null};function jd(t){return t.vnode.shapeFlag&4}let va=!1;function sw(t,e=!1){va=e;const{props:n,children:r}=t.vnode,a=jd(t);Py(t,n,a,e),By(t,r);const l=a?ow(t,e):void 0;return va=!1,l}function ow(t,e){const n=t.type;t.accessCache=Object.create(null),t.proxy=md(new Proxy(t.ctx,Iy));const{setup:r}=n;if(r){const a=t.setupContext=r.length>1?uw(t):null;_o(t),qo();const l=ui(r,t,0,[t.props,a]);if(Ao(),cs(),Zh(l)){if(l.then(cs,cs),e)return l.then(p=>{ch(t,p,e)}).catch(p=>{zc(p,t,0)});t.asyncDep=l}else ch(t,l,e)}else Vd(t,e)}function ch(t,e,n){Ie(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:ft(e)&&(t.setupState=bd(e)),Vd(t,n)}let lh;function Vd(t,e,n){const r=t.type;if(!t.render){if(!e&&lh&&!r.render){const a=r.template||Nf(t).template;if(a){const{isCustomElement:l,compilerOptions:p}=t.appContext.config,{delimiters:w,compilerOptions:v}=r,d=Gt(Gt({isCustomElement:l,delimiters:w},p),v);r.render=lh(a,d)}}t.render=r.render||rr}_o(t),qo(),Ty(t),Ao(),cs()}function aw(t){return new Proxy(t.attrs,{get(e,n){return yn(t,"get","$attrs"),e[n]}})}function uw(t){const e=r=>{t.exposed=r||{}};let n;return{get attrs(){return n||(n=aw(t))},slots:t.slots,emit:t.emit,expose:e}}function xf(t){if(t.exposed)return t.exposeProxy||(t.exposeProxy=new Proxy(bd(md(t.exposed)),{get(e,n){if(n in e)return e[n];if(n in ia)return ia[n](t)},has(e,n){return n in e||n in ia}}))}function cw(t){return Ie(t)&&"__vccOpts"in t}const lw=(t,e)=>Xm(t,e,va),fw=Symbol(""),hw=()=>Iu(fw),dw="3.2.47",pw="http://www.w3.org/2000/svg",Fi=typeof document<"u"?document:null,fh=Fi&&Fi.createElement("template"),mw={insert:(t,e,n)=>{e.insertBefore(t,n||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,n,r)=>{const a=e?Fi.createElementNS(pw,t):Fi.createElement(t,n?{is:n}:void 0);return t==="select"&&r&&r.multiple!=null&&a.setAttribute("multiple",r.multiple),a},createText:t=>Fi.createTextNode(t),createComment:t=>Fi.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Fi.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,n,r,a,l){const p=n?n.previousSibling:e.lastChild;if(a&&(a===l||a.nextSibling))for(;e.insertBefore(a.cloneNode(!0),n),!(a===l||!(a=a.nextSibling)););else{fh.innerHTML=r?`${t}`:t;const w=fh.content;if(r){const v=w.firstChild;for(;v.firstChild;)w.appendChild(v.firstChild);w.removeChild(v)}e.insertBefore(w,n)}return[p?p.nextSibling:e.firstChild,n?n.previousSibling:e.lastChild]}};function yw(t,e,n){const r=t._vtc;r&&(e=(e?[e,...r]:[...r]).join(" ")),e==null?t.removeAttribute("class"):n?t.setAttribute("class",e):t.className=e}function ww(t,e,n){const r=t.style,a=kt(n);if(n&&!a){if(e&&!kt(e))for(const l in e)n[l]==null&&Dl(r,l,"");for(const l in n)Dl(r,l,n[l])}else{const l=r.display;a?e!==n&&(r.cssText=n):e&&t.removeAttribute("style"),"_vod"in t&&(r.display=l)}}const hh=/\s*!important$/;function Dl(t,e,n){if(Ae(n))n.forEach(r=>Dl(t,e,r));else if(n==null&&(n=""),e.startsWith("--"))t.setProperty(e,n);else{const r=gw(t,e);hh.test(n)?t.setProperty(Co(r),n.replace(hh,""),"important"):t[r]=n}}const dh=["Webkit","Moz","ms"],gl={};function gw(t,e){const n=gl[e];if(n)return n;let r=No(e);if(r!=="filter"&&r in t)return gl[e]=r;r=nd(r);for(let a=0;abl||(Ew.then(()=>bl=0),bl=Date.now());function qw(t,e){const n=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=n.attached)return;Rn(Aw(r,n.value),e,5,[r])};return n.value=t,n.attached=Cw(),n}function Aw(t,e){if(Ae(e)){const n=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{n.call(t),t._stopped=!0},e.map(r=>a=>!a._stopped&&r&&r(a))}else return e}const yh=/^on[a-z]/,Sw=(t,e,n,r,a=!1,l,p,w,v)=>{e==="class"?yw(t,r,a):e==="style"?ww(t,n,r):Qc(e)?of(e)||xw(t,e,n,r,p):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Iw(t,e,r,a))?Nw(t,e,r,l,p,w,v):(e==="true-value"?t._trueValue=r:e==="false-value"&&(t._falseValue=r),bw(t,e,r,a))};function Iw(t,e,n,r){return r?!!(e==="innerHTML"||e==="textContent"||e in t&&yh.test(e)&&Ie(n)):e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA"||yh.test(e)&&kt(n)?!1:e in t}const Tw={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};wy.props;const kw=Gt({patchProp:Sw},mw);let wh;function Ww(){return wh||(wh=$y(kw))}const Rw=(...t)=>{const e=Ww().createApp(...t),{mount:n}=e;return e.mount=r=>{const a=Dw(r);if(!a)return;const l=e._component;!Ie(l)&&!l.render&&!l.template&&(l.template=a.innerHTML),a.innerHTML="";const p=n(a,!1,a instanceof SVGElement);return a instanceof Element&&(a.removeAttribute("v-cloak"),a.setAttribute("data-v-app","")),p},e};function Dw(t){return kt(t)?document.querySelector(t):t}function Ks(t){return typeof t>"u"||t===void 0}function Dn(t){return typeof t=="string"}function Pw(t){return typeof t=="number"}function zd(t){return typeof t=="boolean"}function Hd(t){return t===null}function Lw(t){return t instanceof Date}function Mw(t){return typeof t=="bigint"}function Pn(t){return typeof t=="function"}function wr(t){return typeof t=="object"&&t!==null}function m(t){return Object.freeze(t)}function Xa(t){return Array.isArray(t)}function xo(t){return t}const vt=m({is(t){return t.kind==="AlterTableNode"},create(t){return m({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return m({...t,...e})},cloneWithColumnAlteration(t,e){return m({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),ct=m({is(t){return t.kind==="IdentifierNode"},create(t){return m({kind:"IdentifierNode",name:t})}}),Vr=m({is(t){return t.kind==="CreateIndexNode"},create(t){return m({kind:"CreateIndexNode",name:ct.create(t)})},cloneWith(t,e){return m({...t,...e})},cloneWithColumns(t,e){return m({...t,columns:[...t.columns||[],...e]})}}),Kd=m({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return m({kind:"CreateSchemaNode",schema:ct.create(t),...e})},cloneWith(t,e){return m({...t,...e})}}),Bw=["preserve rows","delete rows","drop"],jn=m({is(t){return t.kind==="CreateTableNode"},create(t){return m({kind:"CreateTableNode",table:t,columns:m([])})},cloneWithColumn(t,e){return m({...t,columns:m([...t.columns,e])})},cloneWithConstraint(t,e){return m({...t,constraints:t.constraints?m([...t.constraints,e]):m([e])})},cloneWithFrontModifier(t,e){return m({...t,frontModifiers:t.frontModifiers?m([...t.frontModifiers,e]):m([e])})},cloneWithEndModifier(t,e){return m({...t,endModifiers:t.endModifiers?m([...t.endModifiers,e]):m([e])})},cloneWith(t,e){return m({...t,...e})}}),hi=m({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return m({kind:"SchemableIdentifierNode",identifier:ct.create(t)})},createWithSchema(t,e){return m({kind:"SchemableIdentifierNode",schema:ct.create(t),identifier:ct.create(e)})}}),Wu=m({is(t){return t.kind==="DropIndexNode"},create(t,e){return m({kind:"DropIndexNode",name:hi.create(t),...e})},cloneWith(t,e){return m({...t,...e})}}),Pl=m({is(t){return t.kind==="DropSchemaNode"},create(t,e){return m({kind:"DropSchemaNode",schema:ct.create(t),...e})},cloneWith(t,e){return m({...t,...e})}}),Ll=m({is(t){return t.kind==="DropTableNode"},create(t,e){return m({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return m({...t,...e})}}),pi=m({is(t){return t.kind==="AliasNode"},create(t,e){return m({kind:"AliasNode",node:t,alias:e})}}),ci=m({is(t){return t.kind==="TableNode"},create(t){return m({kind:"TableNode",table:hi.create(t)})},createWithSchema(t,e){return m({kind:"TableNode",table:hi.createWithSchema(t,e)})}});function Ln(t){return wr(t)&&Pn(t.toOperationNode)}function Of(t){return wr(t)&&"expressionType"in t&&Ln(t)}function Fw(t){return wr(t)&&"expression"in t&&Dn(t.alias)&&Ln(t)}const vr=m({is(t){return t.kind==="SelectModifierNode"},create(t){return m({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return m({kind:"SelectModifierNode",rawModifier:t})}}),ls=m({is(t){return t.kind==="AndNode"},create(t,e){return m({kind:"AndNode",left:t,right:e})}}),fs=m({is(t){return t.kind==="OrNode"},create(t,e){return m({kind:"OrNode",left:t,right:e})}}),Nl=m({is(t){return t.kind==="OnNode"},create(t){return m({kind:"OnNode",on:t})},cloneWithOperation(t,e,n){return m({...t,on:e==="And"?ls.create(t.on,n):fs.create(t.on,n)})}}),oa=m({is(t){return t.kind==="JoinNode"},create(t,e){return m({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,n){return m({kind:"JoinNode",joinType:t,table:e,on:Nl.create(n)})},cloneWithOn(t,e){return m({...t,on:t.on?Nl.cloneWithOperation(t.on,"And",e):Nl.create(e)})}}),Ef=m({is(t){return t.kind==="BinaryOperationNode"},create(t,e,n){return m({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:n})}}),Jd=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp"],Uw=["+","-","*","/","%","^","&","|","#","<<",">>"],Gd=["->","->>"],Yd=[...Jd,...Uw,"&&","||"],Qw=["exists","not exists"],$w=["not","-",...Qw],jw=[...Yd,...Gd,...$w],_a=m({is(t){return t.kind==="OperatorNode"},create(t){return m({kind:"OperatorNode",operator:t})}});function Vw(t){return Dn(t)&&Yd.includes(t)}function zw(t){return Dn(t)&&Jd.includes(t)}function gh(t){return Dn(t)&&Gd.includes(t)}const yt=m({is(t){return t.kind==="ColumnNode"},create(t){return m({kind:"ColumnNode",column:ct.create(t)})}}),Cf=m({is(t){return t.kind==="SelectAllNode"},create(){return m({kind:"SelectAllNode"})}}),Xc=m({is(t){return t.kind==="ReferenceNode"},create(t,e){return m({kind:"ReferenceNode",table:e,column:t})},createSelectAll(t){return m({kind:"ReferenceNode",table:t,column:Cf.create()})}}),Hw=m({is(t){return t.kind==="OrderByItemNode"},create(t,e){return m({kind:"OrderByItemNode",orderBy:t,direction:e})}}),tn=m({is(t){return t.kind==="RawNode"},create(t,e){return m({kind:"RawNode",sqlFragments:m(t),parameters:m(e)})},createWithSql(t){return tn.create([t],[])},createWithChild(t){return tn.create(["",""],[t])},createWithChildren(t){return tn.create(new Array(t.length+1).fill(""),t)}});function Kw(t){return t==="asc"||t==="desc"}function Zc(t,e){return Hw.create(Jw(t),Gw(e))}function Jw(t){return kr(t)}function Gw(t){if(t)return t==="asc"||t==="desc"?tn.createWithSql(t):t.toOperationNode()}const Ml=m({is(t){return t.kind==="JSONReferenceNode"},create(t,e){return m({kind:"JSONReferenceNode",reference:t,traversal:e})},cloneWithTraversal(t,e){return m({...t,traversal:e})}}),Xd=m({is(t){return t.kind==="JSONOperatorChainNode"},create(t){return m({kind:"JSONOperatorChainNode",operator:t,values:m([])})},cloneWithValue(t,e){return m({...t,values:m([...t.values,e])})}}),Bl=m({is(t){return t.kind==="JSONPathNode"},create(t){return m({kind:"JSONPathNode",inOperator:t,pathLegs:m([])})},cloneWithLeg(t,e){return m({...t,pathLegs:m([...t.pathLegs,e])})}});function Zd(t){return Dn(t)?hs(t):t.toOperationNode()}function xa(t){return Xa(t)?t.map(e=>kr(e)):[kr(t)]}function kr(t){return rl(t)?nl(t):Zd(t)}function Yw(t,e){const n=hs(t);if(gh(e))return Ml.create(n,Xd.create(_a.create(e)));const r=e.slice(0,-1);if(gh(r))return Ml.create(n,Bl.create(_a.create(r)));throw new Error(`Invalid JSON operator: ${e}`)}function hs(t){const e=".";if(!t.includes(e))return Xc.create(yt.create(t));const n=t.split(e).map(qf);if(n.length===3)return Zw(n);if(n.length===2)return eg(n);throw new Error(`invalid column reference ${t}`)}function Xw(t){const e=" as ";if(t.includes(e)){const[n,r]=t.split(e).map(qf);return pi.create(hs(n),ct.create(r))}else return hs(t)}function ep(t){return yt.create(t)}function bh(t){const e=" ";if(t.includes(e)){const[n,r]=t.split(e).map(qf);if(!Kw(r))throw new Error(`invalid order direction "${r}" next to "${n}"`);return Zc(n,r)}else return ep(t)}function Zw(t){const[e,n,r]=t;return Xc.create(yt.create(r),ci.createWithSchema(e,n))}function eg(t){const[e,n]=t;return Xc.create(yt.create(n),ci.create(e))}function qf(t){return t.trim()}const tp=m({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return m({kind:"PrimitiveValueListNode",values:m([...t])})}}),Af=m({is(t){return t.kind==="ValueListNode"},create(t){return m({kind:"ValueListNode",values:m(t)})}}),ir=m({is(t){return t.kind==="ValueNode"},create(t){return m({kind:"ValueNode",value:t})},createImmediate(t){return m({kind:"ValueNode",value:t,immediate:!0})}});function np(t){return Xa(t)?tg(t):Ir(t)}function Ir(t){return rl(t)?nl(t):ir.create(t)}function tg(t){return t.some(rl)?Af.create(t.map(e=>Ir(e))):tp.create(t)}function nn(t){if(t.length>1&&!sp(t[1]))throw new Error(`invalid comparison operator ${JSON.stringify(t[1])}`);return rp(t)}function rp(t){if(t.length===3)return Ru(t[0],t[1],t[2]);if(t.length===1)return og(t[0]);throw new Error(`invalid arguments: ${JSON.stringify(t)}`)}function Ru(t,e,n){if(!ip(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return rg(e)&&ig(n)?sg(t,e,n):Ef.create(kr(t),Sf(e),np(n))}function Wr(t,e,n){if(!sp(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return ng(t,e,n)}function ng(t,e,n){if(!ip(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Ef.create(kr(t),Sf(e),kr(n))}function ip(t){return Vw(t)||Of(t)}function sp(t){return zw(t)||Of(t)}function rg(t){return t==="is"||t==="is not"}function ig(t){return Hd(t)||zd(t)}function sg(t,e,n){return Ef.create(kr(t),Sf(e),ir.createImmediate(n))}function Sf(t){if(Dn(t)&&jw.includes(t))return _a.create(t);if(Ln(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function og(t){return Pn(t)?t(Df()).toOperationNode():Ln(t)?t.toOperationNode():ir.create(t)}const Oo=m({is(t){return t.kind==="OrderByNode"},create(t){return m({kind:"OrderByNode",items:m([t])})},cloneWithItem(t,e){return m({...t,items:m([...t.items,e])})}}),Nh=m({is(t){return t.kind==="PartitionByNode"},create(t){return m({kind:"PartitionByNode",items:m(t)})},cloneWithItems(t,e){return m({...t,items:m([...t.items,...e])})}}),Fl=m({is(t){return t.kind==="OverNode"},create(){return m({kind:"OverNode"})},cloneWithOrderByItem(t,e){return m({...t,orderBy:t.orderBy?Oo.cloneWithItem(t.orderBy,e):Oo.create(e)})},cloneWithPartitionByItems(t,e){return m({...t,partitionBy:t.partitionBy?Nh.cloneWithItems(t.partitionBy,e):Nh.create(e)})}}),Vu=m({is(t){return t.kind==="FromNode"},create(t){return m({kind:"FromNode",froms:m(t)})},cloneWithFroms(t,e){return m({...t,froms:m([...t.froms,...e])})}}),vh=m({is(t){return t.kind==="GroupByNode"},create(t){return m({kind:"GroupByNode",items:m(t)})},cloneWithItems(t,e){return m({...t,items:m([...t.items,...e])})}}),_h=m({is(t){return t.kind==="HavingNode"},create(t){return m({kind:"HavingNode",having:t})},cloneWithOperation(t,e,n){return m({...t,having:e==="And"?ls.create(t.having,n):fs.create(t.having,n)})}}),Fe=m({is(t){return t.kind==="SelectQueryNode"},create(t,e){return m({kind:"SelectQueryNode",from:Vu.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return m({...t,selections:t.selections?m([...t.selections,...e]):m(e)})},cloneWithDistinctOn(t,e){return m({...t,distinctOn:t.distinctOn?m([...t.distinctOn,...e]):m(e)})},cloneWithFrontModifier(t,e){return m({...t,frontModifiers:t.frontModifiers?m([...t.frontModifiers,e]):m([e])})},cloneWithEndModifier(t,e){return m({...t,endModifiers:t.endModifiers?m([...t.endModifiers,e]):m([e])})},cloneWithOrderByItem(t,e){return m({...t,orderBy:t.orderBy?Oo.cloneWithItem(t.orderBy,e):Oo.create(e)})},cloneWithGroupByItems(t,e){return m({...t,groupBy:t.groupBy?vh.cloneWithItems(t.groupBy,e):vh.create(e)})},cloneWithLimit(t,e){return m({...t,limit:e})},cloneWithOffset(t,e){return m({...t,offset:e})},cloneWithHaving(t,e){return m({...t,having:t.having?_h.cloneWithOperation(t.having,"And",e):_h.create(e)})},cloneWithSetOperation(t,e){return m({...t,setOperations:t.setOperations?m([...t.setOperations,e]):m([e])})},cloneWithoutSelections(t){return m({...t,selections:[]})},cloneWithoutLimit(t){return m({...t,limit:void 0})},cloneWithoutOffset(t){return m({...t,offset:void 0})},cloneWithoutOrderBy(t){return m({...t,orderBy:void 0})}});function Qe(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}var Hn;const ca=class ca{constructor(e){D(this,Hn,void 0);z(this,Hn,m(e))}on(...e){return new ca({...i(this,Hn),joinNode:oa.cloneWithOn(i(this,Hn).joinNode,nn(e))})}onRef(e,n,r){return new ca({...i(this,Hn),joinNode:oa.cloneWithOn(i(this,Hn).joinNode,Wr(e,n,r))})}onTrue(){return new ca({...i(this,Hn),joinNode:oa.cloneWithOn(i(this,Hn).joinNode,tn.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return i(this,Hn).joinNode}};Hn=new WeakMap;let zu=ca;Qe(zu,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const ag=m({is(t){return t.kind==="PartitionByItemNode"},create(t){return m({kind:"PartitionByItemNode",partitionBy:t})}});function ug(t){return xa(t).map(ag.create)}var Vi;const mc=class mc{constructor(e){D(this,Vi,void 0);z(this,Vi,m(e))}orderBy(e,n){return new mc({overNode:Fl.cloneWithOrderByItem(i(this,Vi).overNode,Zc(e,n))})}partitionBy(e){return new mc({overNode:Fl.cloneWithPartitionByItems(i(this,Vi).overNode,ug(e))})}$call(e){return e(this)}toOperationNode(){return i(this,Vi).overNode}};Vi=new WeakMap;let Hu=mc;Qe(Hu,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const aa=m({is(t){return t.kind==="SelectionNode"},create(t){return m({kind:"SelectionNode",selection:t})},createSelectAll(){return m({kind:"SelectionNode",selection:Cf.create()})},createSelectAllFromTable(t){return m({kind:"SelectionNode",selection:Xc.createSelectAll(t)})}});var Js;class cg{constructor(e){D(this,Js,void 0);z(this,Js,e)}get dynamicReference(){return i(this,Js)}get refType(){}toOperationNode(){return Zd(i(this,Js))}}Js=new WeakMap;function lg(t){return wr(t)&&Ln(t)&&Dn(t.dynamicReference)}function Za(t){return Pn(t)?Za(t(So())):Xa(t)?t.map(e=>xh(e)):[xh(t)]}function xh(t){return Dn(t)?aa.create(Xw(t)):lg(t)?aa.create(t.toOperationNode()):aa.create(wp(t))}function eu(t){return t?Array.isArray(t)?t.map(Oh):[Oh(t)]:[aa.createSelectAll()]}function Oh(t){if(Dn(t))return aa.createSelectAllFromTable(mn(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const fg=m({is(t){return t.kind==="ValuesNode"},create(t){return m({kind:"ValuesNode",values:m(t)})}}),hg=m({is(t){return t.kind==="DefaultInsertValueNode"},create(){return m({kind:"DefaultInsertValueNode"})}});function dg(t){const e=Pn(t)?t(So()):t,n=Xa(e)?e:m([e]);return pg(n)}function pg(t){const e=mg(t);return[m([...e.keys()].map(yt.create)),fg.create(t.map(n=>yg(n,e)))]}function mg(t){const e=new Map;for(const n of t){const r=Object.keys(n);for(const a of r)!e.has(a)&&n[a]!==void 0&&e.set(a,e.size)}return e}function yg(t,e){const n=Object.keys(t),r=Array.from({length:e.size});let a=!1;for(const p of n){const w=e.get(p);if(Ks(w))continue;const v=t[p];(Ks(v)||rl(v))&&(a=!0),r[w]=v}if(n.lengthKs(w)?p:Ir(w)))}return tp.create(r)}const mr=m({is(t){return t.kind==="InsertQueryNode"},create(t,e,n){return m({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:n})},cloneWith(t,e){return m({...t,...e})}}),Ku=m({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return m({kind:"UpdateQueryNode",table:t,...e&&{with:e}})},cloneWithFromItems(t,e){return m({...t,from:t.from?Vu.cloneWithFroms(t.from,e):Vu.create(e)})},cloneWithUpdates(t,e){return m({...t,updates:t.updates?m([...t.updates,...e]):e})}}),Eh=m({is(t){return t.kind==="UsingNode"},create(t){return m({kind:"UsingNode",tables:m(t)})},cloneWithTables(t,e){return m({...t,tables:m([...t.tables,...e])})}}),ua=m({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return m({kind:"DeleteQueryNode",from:Vu.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return m({...t,orderBy:t.orderBy?Oo.cloneWithItem(t.orderBy,e):Oo.create(e)})},cloneWithLimit(t,e){return m({...t,limit:e})},cloneWithUsing(t,e){return m({...t,using:t.using!==void 0?Eh.cloneWithTables(t.using,e):Eh.create(e)})}}),hn=m({is(t){return t.kind==="WhereNode"},create(t){return m({kind:"WhereNode",where:t})},cloneWithOperation(t,e,n){return m({...t,where:e==="And"?ls.create(t.where,n):fs.create(t.where,n)})}}),Ch=m({is(t){return t.kind==="ReturningNode"},create(t){return m({kind:"ReturningNode",selections:m(t)})},cloneWithSelections(t,e){return m({...t,selections:t.selections?m([...t.selections,...e]):m(e)})}}),wg=m({is(t){return t.kind==="ExplainNode"},create(t,e){return m({kind:"ExplainNode",format:t,options:e})}}),Re=m({is(t){return Fe.is(t)||mr.is(t)||Ku.is(t)||ua.is(t)},cloneWithWhere(t,e){return m({...t,where:t.where?hn.cloneWithOperation(t.where,"And",e):hn.create(e)})},cloneWithJoin(t,e){return m({...t,joins:t.joins?m([...t.joins,e]):m([e])})},cloneWithReturning(t,e){return m({...t,returning:t.returning?Ch.cloneWithSelections(t.returning,e):Ch.create(e)})},cloneWithoutWhere(t){return m({...t,where:void 0})},cloneWithExplain(t,e,n){return m({...t,explain:wg.create(e,n==null?void 0:n.toOperationNode())})}}),gg=m({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return m({kind:"ColumnUpdateNode",column:t,value:e})}});function If(t){const e=Pn(t)?t(So()):t;return Object.entries(e).filter(([n,r])=>r!==void 0).map(([n,r])=>gg.create(yt.create(n),Ir(r)))}const bg=m({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return m({kind:"OnDuplicateKeyNode",updates:t})}});class Ng{constructor(e,n){ge(this,"insertId");ge(this,"numInsertedOrUpdatedRows");this.insertId=e,this.numInsertedOrUpdatedRows=n}}class el extends Error{constructor(n){super("no result");ge(this,"node");this.node=n}}function tl(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const En=m({is(t){return t.kind==="OnConflictNode"},create(){return m({kind:"OnConflictNode"})},cloneWith(t,e){return m({...t,...e})},cloneWithIndexWhere(t,e){return m({...t,indexWhere:t.indexWhere?hn.cloneWithOperation(t.indexWhere,"And",e):hn.create(e)})},cloneWithIndexOrWhere(t,e){return m({...t,indexWhere:t.indexWhere?hn.cloneWithOperation(t.indexWhere,"Or",e):hn.create(e)})},cloneWithUpdateWhere(t,e){return m({...t,updateWhere:t.updateWhere?hn.cloneWithOperation(t.updateWhere,"And",e):hn.create(e)})},cloneWithUpdateOrWhere(t,e){return m({...t,updateWhere:t.updateWhere?hn.cloneWithOperation(t.updateWhere,"Or",e):hn.create(e)})},cloneWithoutIndexWhere(t){return m({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return m({...t,updateWhere:void 0})}});var et;const Or=class Or{constructor(e){D(this,et,void 0);z(this,et,m(e))}column(e){const n=yt.create(e);return new Or({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{columns:i(this,et).onConflictNode.columns?m([...i(this,et).onConflictNode.columns,n]):m([n])})})}columns(e){const n=e.map(yt.create);return new Or({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{columns:i(this,et).onConflictNode.columns?m([...i(this,et).onConflictNode.columns,...n]):m(n)})})}constraint(e){return new Or({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{constraint:ct.create(e)})})}expression(e){return new Or({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new Or({...i(this,et),onConflictNode:En.cloneWithIndexWhere(i(this,et).onConflictNode,nn(e))})}whereRef(e,n,r){return new Or({...i(this,et),onConflictNode:En.cloneWithIndexWhere(i(this,et).onConflictNode,Wr(e,n,r))})}clearWhere(){return new Or({...i(this,et),onConflictNode:En.cloneWithoutIndexWhere(i(this,et).onConflictNode)})}doNothing(){return new op({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Gu({...i(this,et),onConflictNode:En.cloneWith(i(this,et).onConflictNode,{updates:If(e)})})}$call(e){return e(this)}};et=new WeakMap;let Ju=Or;Qe(Ju,"don't await OnConflictBuilder instances.");var Ta;class op{constructor(e){D(this,Ta,void 0);z(this,Ta,m(e))}toOperationNode(){return i(this,Ta).onConflictNode}}Ta=new WeakMap;Qe(op,"don't await OnConflictDoNothingBuilder instances.");var Kn;const la=class la{constructor(e){D(this,Kn,void 0);z(this,Kn,m(e))}where(...e){return new la({...i(this,Kn),onConflictNode:En.cloneWithUpdateWhere(i(this,Kn).onConflictNode,nn(e))})}whereRef(e,n,r){return new la({...i(this,Kn),onConflictNode:En.cloneWithUpdateWhere(i(this,Kn).onConflictNode,Wr(e,n,r))})}clearWhere(){return new la({...i(this,Kn),onConflictNode:En.cloneWithoutUpdateWhere(i(this,Kn).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return i(this,Kn).onConflictNode}};Kn=new WeakMap;let Gu=la;Qe(Gu,"don't await OnConflictUpdateBuilder instances.");var Te;const zt=class zt{constructor(e){D(this,Te,void 0);z(this,Te,m(e))}values(e){const[n,r]=dg(e);return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{columns:n,values:r})})}columns(e){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{columns:m(e.map(yt.create))})})}expression(e){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{values:nl(e)})})}ignore(){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{ignore:!0})})}onConflict(e){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{onConflict:e(new Ju({onConflictNode:En.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new zt({...i(this,Te),queryNode:mr.cloneWith(i(this,Te).queryNode,{onDuplicateKey:bg.create(If(e))})})}returning(e){return new zt({...i(this,Te),queryNode:Re.cloneWithReturning(i(this,Te).queryNode,Za(e))})}returningAll(){return new zt({...i(this,Te),queryNode:Re.cloneWithReturning(i(this,Te).queryNode,eu())})}$call(e){return e(this)}$if(e,n){return e?n(this):new zt({...i(this,Te)})}$castTo(){return new zt(i(this,Te))}$narrowType(){return new zt(i(this,Te))}$assertType(){return new zt(i(this,Te))}withPlugin(e){return new zt({...i(this,Te),executor:i(this,Te).executor.withPlugin(e)})}toOperationNode(){return i(this,Te).executor.transformQuery(i(this,Te).queryNode,i(this,Te).queryId)}compile(){return i(this,Te).executor.compileQuery(this.toOperationNode(),i(this,Te).queryId)}async execute(){const e=this.compile(),n=e.query,r=await i(this,Te).executor.executeQuery(e,i(this,Te).queryId);return i(this,Te).executor.adapter.supportsReturning&&n.returning?r.rows:[new Ng(r.insertId,r.numAffectedRows??r.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=el){const n=await this.executeTakeFirst();if(n===void 0)throw tl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),r=i(this,Te).executor.stream(n,e,i(this,Te).queryId);for await(const a of r)yield*a.rows}async explain(e,n){return await new zt({...i(this,Te),queryNode:Re.cloneWithExplain(i(this,Te).queryNode,e,n)}).execute()}};Te=new WeakMap;let Oa=zt;Qe(Oa,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class vg{constructor(e){ge(this,"numDeletedRows");this.numDeletedRows=e}}const ap=m({is(t){return t.kind==="LimitNode"},create(t){return m({kind:"LimitNode",limit:ir.create(t)})}});var ve;const gt=class gt{constructor(e){D(this,ve,void 0);z(this,ve,m(e))}where(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithWhere(i(this,ve).queryNode,nn(e))})}whereRef(e,n,r){return new gt({...i(this,ve),queryNode:Re.cloneWithWhere(i(this,ve).queryNode,Wr(e,n,r))})}clearWhere(){return new gt({...i(this,ve),queryNode:Re.cloneWithoutWhere(i(this,ve).queryNode)})}using(e){return new gt({...i(this,ve),queryNode:ua.cloneWithUsing(i(this,ve).queryNode,qa(e))})}innerJoin(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithJoin(i(this,ve).queryNode,pn("InnerJoin",e))})}leftJoin(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithJoin(i(this,ve).queryNode,pn("LeftJoin",e))})}rightJoin(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithJoin(i(this,ve).queryNode,pn("RightJoin",e))})}fullJoin(...e){return new gt({...i(this,ve),queryNode:Re.cloneWithJoin(i(this,ve).queryNode,pn("FullJoin",e))})}returning(e){return new gt({...i(this,ve),queryNode:Re.cloneWithReturning(i(this,ve).queryNode,Za(e))})}returningAll(e){return new gt({...i(this,ve),queryNode:Re.cloneWithReturning(i(this,ve).queryNode,eu(e))})}orderBy(e,n){return new gt({...i(this,ve),queryNode:ua.cloneWithOrderByItem(i(this,ve).queryNode,Zc(e,n))})}limit(e){return new gt({...i(this,ve),queryNode:ua.cloneWithLimit(i(this,ve).queryNode,ap.create(e))})}$call(e){return e(this)}$if(e,n){return e?n(this):new gt({...i(this,ve)})}$castTo(){return new gt(i(this,ve))}$narrowType(){return new gt(i(this,ve))}$assertType(){return new gt(i(this,ve))}withPlugin(e){return new gt({...i(this,ve),executor:i(this,ve).executor.withPlugin(e)})}toOperationNode(){return i(this,ve).executor.transformQuery(i(this,ve).queryNode,i(this,ve).queryId)}compile(){return i(this,ve).executor.compileQuery(this.toOperationNode(),i(this,ve).queryId)}async execute(){const e=this.compile(),n=e.query,r=await i(this,ve).executor.executeQuery(e,i(this,ve).queryId);return i(this,ve).executor.adapter.supportsReturning&&n.returning?r.rows:[new vg(r.numAffectedRows??r.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=el){const n=await this.executeTakeFirst();if(n===void 0)throw tl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),r=i(this,ve).executor.stream(n,e,i(this,ve).queryId);for await(const a of r)yield*a.rows}async explain(e,n){return await new gt({...i(this,ve),queryNode:Re.cloneWithExplain(i(this,ve).queryNode,e,n)}).execute()}};ve=new WeakMap;let Yu=gt;Qe(Yu,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class _g{constructor(e,n){ge(this,"numUpdatedRows");ge(this,"numChangedRows");this.numUpdatedRows=e,this.numChangedRows=n}}var Ce;const Ct=class Ct{constructor(e){D(this,Ce,void 0);z(this,Ce,m(e))}where(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithWhere(i(this,Ce).queryNode,nn(e))})}whereRef(e,n,r){return new Ct({...i(this,Ce),queryNode:Re.cloneWithWhere(i(this,Ce).queryNode,Wr(e,n,r))})}clearWhere(){return new Ct({...i(this,Ce),queryNode:Re.cloneWithoutWhere(i(this,Ce).queryNode)})}from(e){return new Ct({...i(this,Ce),queryNode:Ku.cloneWithFromItems(i(this,Ce).queryNode,qa(e))})}innerJoin(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithJoin(i(this,Ce).queryNode,pn("InnerJoin",e))})}leftJoin(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithJoin(i(this,Ce).queryNode,pn("LeftJoin",e))})}rightJoin(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithJoin(i(this,Ce).queryNode,pn("RightJoin",e))})}fullJoin(...e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithJoin(i(this,Ce).queryNode,pn("FullJoin",e))})}set(e){return new Ct({...i(this,Ce),queryNode:Ku.cloneWithUpdates(i(this,Ce).queryNode,If(e))})}returning(e){return new Ct({...i(this,Ce),queryNode:Re.cloneWithReturning(i(this,Ce).queryNode,Za(e))})}returningAll(){return new Ct({...i(this,Ce),queryNode:Re.cloneWithReturning(i(this,Ce).queryNode,eu())})}$call(e){return e(this)}$if(e,n){return e?n(this):new Ct({...i(this,Ce)})}$castTo(){return new Ct(i(this,Ce))}$narrowType(){return new Ct(i(this,Ce))}$assertType(){return new Ct(i(this,Ce))}withPlugin(e){return new Ct({...i(this,Ce),executor:i(this,Ce).executor.withPlugin(e)})}toOperationNode(){return i(this,Ce).executor.transformQuery(i(this,Ce).queryNode,i(this,Ce).queryId)}compile(){return i(this,Ce).executor.compileQuery(this.toOperationNode(),i(this,Ce).queryId)}async execute(){const e=this.compile(),n=e.query,r=await i(this,Ce).executor.executeQuery(e,i(this,Ce).queryId);return i(this,Ce).executor.adapter.supportsReturning&&n.returning?r.rows:[new _g(r.numAffectedRows??r.numUpdatedOrDeletedRows??BigInt(0),r.numChangedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=el){const n=await this.executeTakeFirst();if(n===void 0)throw tl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),r=i(this,Ce).executor.stream(n,e,i(this,Ce).queryId);for await(const a of r)yield*a.rows}async explain(e,n){return await new Ct({...i(this,Ce),queryNode:Re.cloneWithExplain(i(this,Ce).queryNode,e,n)}).execute()}};Ce=new WeakMap;let Xu=Ct;Qe(Xu,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const xg=m({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return m({kind:"CommonTableExpressionNode",name:t,expression:e})}}),qh=m({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return m({kind:"CommonTableExpressionNameNode",table:ci.create(t),columns:e?m(e.map(yt.create)):void 0})}});function Ah(t,e){const n=e(Wg());return xg.create(Og(t),n.toOperationNode())}function Og(t){if(t.includes("(")){const e=t.split(/[\(\)]/),n=e[0],r=e[1].split(",").map(a=>a.trim());return qh.create(n,r)}else return qh.create(t)}const Cu=m({is(t){return t.kind==="WithNode"},create(t,e){return m({kind:"WithNode",expressions:m([t]),...e})},cloneWithExpression(t,e){return m({...t,expressions:m([...t.expressions,e])})}}),Sh=["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 Eg(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",column:this.transformNode(e.column),table:this.transformNode(e.table)}}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:m([...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)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}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}}yc=new WeakMap;const Ag=m({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 Ys,zi,Hi,wc,up,gc,cp,bc,lp,Ki,na,ka,Ul,Nc,fp;class Sg extends Tf{constructor(n){super();D(this,wc);D(this,gc);D(this,bc);D(this,Ki);D(this,ka);D(this,Nc);D(this,Ys,void 0);D(this,zi,new Set);D(this,Hi,new Set);z(this,Ys,n)}transformNodeImpl(n){if(!_e(this,wc,up).call(this,n))return super.transformNodeImpl(n);const r=_e(this,bc,lp).call(this,n);for(const p of r)i(this,Hi).add(p);const a=_e(this,gc,cp).call(this,n);for(const p of a)i(this,zi).add(p);const l=super.transformNodeImpl(n);for(const p of a)i(this,zi).delete(p);for(const p of r)i(this,Hi).delete(p);return l}transformSchemableIdentifier(n){const r=super.transformSchemableIdentifier(n);return r.schema||!i(this,zi).has(n.identifier.name)?r:{...r,schema:ct.create(i(this,Ys))}}transformReferences(n){const r=super.transformReferences(n);return r.table.table.schema?r:{...r,table:ci.createWithSchema(i(this,Ys),r.table.table.identifier.name)}}}Ys=new WeakMap,zi=new WeakMap,Hi=new WeakMap,wc=new WeakSet,up=function(n){return n.kind in Ag},gc=new WeakSet,cp=function(n){const r=new Set;if("name"in n&&n.name&&hi.is(n.name)&&_e(this,ka,Ul).call(this,n.name,r),"from"in n&&n.from)for(const a of n.from.froms)_e(this,Ki,na).call(this,a,r);if("into"in n&&n.into&&_e(this,Ki,na).call(this,n.into,r),"table"in n&&n.table&&_e(this,Ki,na).call(this,n.table,r),"joins"in n&&n.joins)for(const a of n.joins)_e(this,Ki,na).call(this,a.table,r);return r},bc=new WeakSet,lp=function(n){const r=new Set;return"with"in n&&n.with&&_e(this,Nc,fp).call(this,n.with,r),r},Ki=new WeakSet,na=function(n,r){const a=ci.is(n)?n:pi.is(n)&&ci.is(n.node)?n.node:null;a&&_e(this,ka,Ul).call(this,a.table,r)},ka=new WeakSet,Ul=function(n,r){const a=n.identifier.name;!i(this,zi).has(a)&&!i(this,Hi).has(a)&&r.add(a)},Nc=new WeakSet,fp=function(n,r){for(const a of n.expressions){const l=a.name.table.table.identifier.name;i(this,Hi).has(l)||r.add(l)}};var Wa;class tu{constructor(e){D(this,Wa,void 0);z(this,Wa,new Sg(e))}transformQuery(e){return i(this,Wa).transformNode(e.node)}async transformResult(e){return e.result}}Wa=new WeakMap;var tt;const Qi=class Qi{constructor(e){D(this,tt,void 0);z(this,tt,m(e))}selectFrom(e){return new Ea({queryId:nt(),executor:i(this,tt).executor,queryNode:Fe.create(qa(e),i(this,tt).withNode)})}insertInto(e){return new Oa({queryId:nt(),executor:i(this,tt).executor,queryNode:mr.create(mn(e),i(this,tt).withNode)})}replaceInto(e){return new Oa({queryId:nt(),executor:i(this,tt).executor,queryNode:mr.create(mn(e),i(this,tt).withNode,!0)})}deleteFrom(e){return new Yu({queryId:nt(),executor:i(this,tt).executor,queryNode:ua.create(qa(e),i(this,tt).withNode)})}updateTable(e){return new Xu({queryId:nt(),executor:i(this,tt).executor,queryNode:Ku.create(Aa(e),i(this,tt).withNode)})}with(e,n){const r=Ah(e,n);return new Qi({...i(this,tt),withNode:i(this,tt).withNode?Cu.cloneWithExpression(i(this,tt).withNode,r):Cu.create(r)})}withRecursive(e,n){const r=Ah(e,n);return new Qi({...i(this,tt),withNode:i(this,tt).withNode?Cu.cloneWithExpression(i(this,tt).withNode,r):Cu.create(r,{recursive:!0})})}withPlugin(e){return new Qi({...i(this,tt),executor:i(this,tt).executor.withPlugin(e)})}withoutPlugins(){return new Qi({...i(this,tt),executor:i(this,tt).executor.withoutPlugins()})}withSchema(e){return new Qi({...i(this,tt),executor:i(this,tt).executor.withPluginAtFront(new tu(e))})}};tt=new WeakMap;let Zu=Qi;var Ra,Xs,Zs;class Ih{constructor(){D(this,Ra,void 0);D(this,Xs,void 0);D(this,Zs,void 0);ge(this,"resolve",e=>{i(this,Xs)&&i(this,Xs).call(this,e)});ge(this,"reject",e=>{i(this,Zs)&&i(this,Zs).call(this,e)});z(this,Ra,new Promise((e,n)=>{z(this,Zs,n),z(this,Xs,e)}))}get promise(){return i(this,Ra)}}Ra=new WeakMap,Xs=new WeakMap,Zs=new WeakMap;const Th=new Set;function Ig(t){Th.has(t)||(Th.add(t),console.log(t))}const Tg=m([]);var Ji,Da,Ql;class hp{constructor(e=Tg){D(this,Da);D(this,Ji,void 0);z(this,Ji,e)}get plugins(){return i(this,Ji)}transformQuery(e,n){for(const r of i(this,Ji)){const a=r.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 r=>{const a=await r.executeQuery(e),l=await _e(this,Da,Ql).call(this,a,n);return kg(a,l),l})}async*stream(e,n,r){const a=new Ih,l=new Ih;this.provideConnection(async w=>(a.resolve(w),await l.promise)).catch(w=>a.reject(w));const p=await a.promise;try{for await(const w of p.streamQuery(e,n))yield await _e(this,Da,Ql).call(this,w,r)}finally{l.resolve()}}}Ji=new WeakMap,Da=new WeakSet,Ql=async function(e,n){for(const r of i(this,Ji))e=await r.transformResult({result:e,queryId:n});return e};function kg(t,e){const{numAffectedRows:n}=t;n===void 0&&t.numUpdatedOrDeletedRows===void 0||n!==void 0&&e.numAffectedRows!==void 0||Ig("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class Ls extends hp{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 kf=new Ls;function Wg(){return new Zu({executor:kf})}function Rg(t,e){return new zu({joinNode:oa.create(t,Aa(e))})}function Dg(){return new Hu({overNode:Fl.create()})}function pn(t,e){if(e.length===3)return Lg(t,e[0],e[1],e[2]);if(e.length===2)return Pg(t,e[0],e[1]);throw new Error("not implemented")}function Pg(t,e,n){return n(Rg(t,e)).toOperationNode()}function Lg(t,e,n,r){return oa.createWithOn(t,Aa(e),Wr(n,"=",r))}const Mg=m({is(t){return t.kind==="OffsetNode"},create(t){return m({kind:"OffsetNode",offset:ir.create(t)})}}),Bg=m({is(t){return t.kind==="GroupByItemNode"},create(t){return m({kind:"GroupByItemNode",groupBy:t})}});function Fg(t){return t=Pn(t)?t(So()):t,xa(t).map(Bg.create)}const dp=m({is(t){return t.kind==="SetOperationNode"},create(t,e,n){return m({kind:"SetOperationNode",operator:t,expression:e,all:n})}});function ks(t,e,n){return dp.create(t,e.toOperationNode(),n)}var Y;const xe=class xe{constructor(e){D(this,Y,void 0);z(this,Y,m(e))}get expressionType(){}where(...e){return new xe({...i(this,Y),queryNode:Re.cloneWithWhere(i(this,Y).queryNode,nn(e))})}whereRef(e,n,r){return new xe({...i(this,Y),queryNode:Re.cloneWithWhere(i(this,Y).queryNode,Wr(e,n,r))})}having(...e){return new xe({...i(this,Y),queryNode:Fe.cloneWithHaving(i(this,Y).queryNode,nn(e))})}havingRef(e,n,r){return new xe({...i(this,Y),queryNode:Fe.cloneWithHaving(i(this,Y).queryNode,Wr(e,n,r))})}select(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithSelections(i(this,Y).queryNode,Za(e))})}distinctOn(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithDistinctOn(i(this,Y).queryNode,xa(e))})}modifyFront(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithFrontModifier(i(this,Y).queryNode,vr.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithEndModifier(i(this,Y).queryNode,vr.createWithExpression(e.toOperationNode()))})}distinct(){return new xe({...i(this,Y),queryNode:Fe.cloneWithFrontModifier(i(this,Y).queryNode,vr.create("Distinct"))})}forUpdate(){return new xe({...i(this,Y),queryNode:Fe.cloneWithEndModifier(i(this,Y).queryNode,vr.create("ForUpdate"))})}forShare(){return new xe({...i(this,Y),queryNode:Fe.cloneWithEndModifier(i(this,Y).queryNode,vr.create("ForShare"))})}forKeyShare(){return new xe({...i(this,Y),queryNode:Fe.cloneWithEndModifier(i(this,Y).queryNode,vr.create("ForKeyShare"))})}forNoKeyUpdate(){return new xe({...i(this,Y),queryNode:Fe.cloneWithEndModifier(i(this,Y).queryNode,vr.create("ForNoKeyUpdate"))})}skipLocked(){return new xe({...i(this,Y),queryNode:Fe.cloneWithEndModifier(i(this,Y).queryNode,vr.create("SkipLocked"))})}noWait(){return new xe({...i(this,Y),queryNode:Fe.cloneWithEndModifier(i(this,Y).queryNode,vr.create("NoWait"))})}selectAll(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithSelections(i(this,Y).queryNode,eu(e))})}innerJoin(...e){return new xe({...i(this,Y),queryNode:Re.cloneWithJoin(i(this,Y).queryNode,pn("InnerJoin",e))})}leftJoin(...e){return new xe({...i(this,Y),queryNode:Re.cloneWithJoin(i(this,Y).queryNode,pn("LeftJoin",e))})}rightJoin(...e){return new xe({...i(this,Y),queryNode:Re.cloneWithJoin(i(this,Y).queryNode,pn("RightJoin",e))})}fullJoin(...e){return new xe({...i(this,Y),queryNode:Re.cloneWithJoin(i(this,Y).queryNode,pn("FullJoin",e))})}innerJoinLateral(...e){return new xe({...i(this,Y),queryNode:Re.cloneWithJoin(i(this,Y).queryNode,pn("LateralInnerJoin",e))})}leftJoinLateral(...e){return new xe({...i(this,Y),queryNode:Re.cloneWithJoin(i(this,Y).queryNode,pn("LateralLeftJoin",e))})}orderBy(e,n){return new xe({...i(this,Y),queryNode:Fe.cloneWithOrderByItem(i(this,Y).queryNode,Zc(e,n))})}groupBy(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithGroupByItems(i(this,Y).queryNode,Fg(e))})}limit(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithLimit(i(this,Y).queryNode,ap.create(e))})}offset(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithOffset(i(this,Y).queryNode,Mg.create(e))})}union(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithSetOperation(i(this,Y).queryNode,ks("union",e,!1))})}unionAll(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithSetOperation(i(this,Y).queryNode,ks("union",e,!0))})}intersect(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithSetOperation(i(this,Y).queryNode,ks("intersect",e,!1))})}intersectAll(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithSetOperation(i(this,Y).queryNode,ks("intersect",e,!0))})}except(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithSetOperation(i(this,Y).queryNode,ks("except",e,!1))})}exceptAll(e){return new xe({...i(this,Y),queryNode:Fe.cloneWithSetOperation(i(this,Y).queryNode,ks("except",e,!0))})}as(e){return new Ug(this,e)}clearSelect(){return new xe({...i(this,Y),queryNode:Fe.cloneWithoutSelections(i(this,Y).queryNode)})}clearWhere(){return new xe({...i(this,Y),queryNode:Re.cloneWithoutWhere(i(this,Y).queryNode)})}clearLimit(){return new xe({...i(this,Y),queryNode:Fe.cloneWithoutLimit(i(this,Y).queryNode)})}clearOffset(){return new xe({...i(this,Y),queryNode:Fe.cloneWithoutOffset(i(this,Y).queryNode)})}clearOrderBy(){return new xe({...i(this,Y),queryNode:Fe.cloneWithoutOrderBy(i(this,Y).queryNode)})}$call(e){return e(this)}$if(e,n){return e?n(this):new xe({...i(this,Y)})}$castTo(){return new xe(i(this,Y))}$narrowType(){return new xe(i(this,Y))}$assertType(){return new xe(i(this,Y))}withPlugin(e){return new xe({...i(this,Y),executor:i(this,Y).executor.withPlugin(e)})}toOperationNode(){return i(this,Y).executor.transformQuery(i(this,Y).queryNode,i(this,Y).queryId)}compile(){return i(this,Y).executor.compileQuery(this.toOperationNode(),i(this,Y).queryId)}async execute(){const e=this.compile();return(await i(this,Y).executor.executeQuery(e,i(this,Y).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=el){const n=await this.executeTakeFirst();if(n===void 0)throw tl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),r=i(this,Y).executor.stream(n,e,i(this,Y).queryId);for await(const a of r)yield*a.rows}async explain(e,n){return await new xe({...i(this,Y),queryNode:Re.cloneWithExplain(i(this,Y).queryNode,e,n)}).execute()}};Y=new WeakMap;let Ea=xe;Qe(Ea,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var eo,to;class Ug{constructor(e,n){D(this,eo,void 0);D(this,to,void 0);z(this,eo,e),z(this,to,n)}get expression(){return i(this,eo)}get alias(){return i(this,to)}toOperationNode(){return pi.create(i(this,eo).toOperationNode(),ct.create(i(this,to)))}}eo=new WeakMap,to=new WeakMap;const Ms=m({is(t){return t.kind==="ParensNode"},create(t){return m({kind:"ParensNode",node:t})}});var Yr;const Ff=class Ff{constructor(e){D(this,Yr,void 0);z(this,Yr,e)}get expressionType(){}as(e){return new Wf(this,e)}or(...e){return new $l(fs.create(i(this,Yr),nn(e)))}and(...e){return new jl(ls.create(i(this,Yr),nn(e)))}$castTo(){return new Ff(i(this,Yr))}toOperationNode(){return i(this,Yr)}};Yr=new WeakMap;let mt=Ff;var no,Xr;class Wf{constructor(e,n){D(this,no,void 0);D(this,Xr,void 0);z(this,no,e),z(this,Xr,n)}get expression(){return i(this,no)}get alias(){return i(this,Xr)}toOperationNode(){return pi.create(i(this,no).toOperationNode(),Ln(i(this,Xr))?i(this,Xr).toOperationNode():ct.create(i(this,Xr)))}}no=new WeakMap,Xr=new WeakMap;var Gi;const vc=class vc{constructor(e){D(this,Gi,void 0);z(this,Gi,e)}get expressionType(){}as(e){return new Wf(this,e)}or(...e){return new vc(fs.create(i(this,Gi),nn(e)))}$castTo(){return new vc(i(this,Gi))}toOperationNode(){return Ms.create(i(this,Gi))}};Gi=new WeakMap;let $l=vc;var Yi;const _c=class _c{constructor(e){D(this,Yi,void 0);z(this,Yi,e)}get expressionType(){}as(e){return new Wf(this,e)}and(...e){return new _c(ls.create(i(this,Yi),nn(e)))}$castTo(){return new _c(i(this,Yi))}toOperationNode(){return Ms.create(i(this,Yi))}};Yi=new WeakMap;let jl=_c;const Bs=m({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return m({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return m({...t,distinct:!0})},cloneWithFilter(t,e){return m({...t,filter:t.filter?hn.cloneWithOperation(t.filter,"And",e):hn.create(e)})},cloneWithOrFilter(t,e){return m({...t,filter:t.filter?hn.cloneWithOperation(t.filter,"Or",e):hn.create(e)})},cloneWithOver(t,e){return m({...t,over:e})}}),Qg=m({is(t){return t.kind==="FunctionNode"},create(t,e){return m({kind:"FunctionNode",func:t,arguments:e})}});var vn;const Us=class Us{constructor(e){D(this,vn,void 0);z(this,vn,m(e))}get expressionType(){}as(e){return new $g(this,e)}distinct(){return new Us({...i(this,vn),aggregateFunctionNode:Bs.cloneWithDistinct(i(this,vn).aggregateFunctionNode)})}filterWhere(...e){return new Us({...i(this,vn),aggregateFunctionNode:Bs.cloneWithFilter(i(this,vn).aggregateFunctionNode,nn(e))})}filterWhereRef(e,n,r){return new Us({...i(this,vn),aggregateFunctionNode:Bs.cloneWithFilter(i(this,vn).aggregateFunctionNode,Wr(e,n,r))})}over(e){const n=Dg();return new Us({...i(this,vn),aggregateFunctionNode:Bs.cloneWithOver(i(this,vn).aggregateFunctionNode,(e?e(n):n).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return i(this,vn).aggregateFunctionNode}};vn=new WeakMap;let Ca=Us;Qe(Ca,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");var ro,io;class $g{constructor(e,n){D(this,ro,void 0);D(this,io,void 0);z(this,ro,e),z(this,io,n)}get expression(){return i(this,ro)}get alias(){return i(this,io)}toOperationNode(){return pi.create(i(this,ro).toOperationNode(),ct.create(i(this,io)))}}ro=new WeakMap,io=new WeakMap;function pp(){const t=(n,r)=>new mt(Qg.create(n,xa(r))),e=(n,r)=>new Ca({aggregateFunctionNode:Bs.create(n,r?xa(r):void 0)});return Object.assign(t,{agg:e,avg(n){return e("avg",[n])},coalesce(n,...r){return t("coalesce",[n,...r])},count(n){return e("count",[n])},countAll(n){return new Ca({aggregateFunctionNode:Bs.create("count",eu(n))})},max(n){return e("max",[n])},min(n){return e("min",[n])},sum(n){return e("sum",[n])}})}const jg=m({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return m({kind:"UnaryOperationNode",operator:t,operand:e})}});function Vg(t,e){return jg.create(_a.create(t),kr(e))}const Rf=m({is(t){return t.kind==="WhenNode"},create(t){return m({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return m({...t,result:e})}}),gr=m({is(t){return t.kind==="CaseNode"},create(t){return m({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return m({...t,when:m(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return m({...t,when:t.when?m([...t.when.slice(0,-1),Rf.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return m({...t,...e})}});var so;class mp{constructor(e){D(this,so,void 0);z(this,so,m(e))}when(...e){return new yp({...i(this,so),node:gr.cloneWithWhen(i(this,so).node,Rf.create(nn(e)))})}}so=new WeakMap;var oo;class yp{constructor(e){D(this,oo,void 0);z(this,oo,m(e))}then(e){return new zg({...i(this,oo),node:gr.cloneWithThen(i(this,oo).node,Ir(e))})}}oo=new WeakMap;var fr;class zg{constructor(e){D(this,fr,void 0);z(this,fr,m(e))}when(...e){return new yp({...i(this,fr),node:gr.cloneWithWhen(i(this,fr).node,Rf.create(nn(e)))})}else(e){return new Hg({...i(this,fr),node:gr.cloneWith(i(this,fr).node,{else:Ir(e)})})}end(){return new mt(gr.cloneWith(i(this,fr).node,{isStatement:!1}))}endCase(){return new mt(gr.cloneWith(i(this,fr).node,{isStatement:!0}))}}fr=new WeakMap;var ao;class Hg{constructor(e){D(this,ao,void 0);z(this,ao,m(e))}end(){return new mt(gr.cloneWith(i(this,ao).node,{isStatement:!1}))}endCase(){return new mt(gr.cloneWith(i(this,ao).node,{isStatement:!0}))}}ao=new WeakMap;const Kg=m({is(t){return t.kind==="JSONPathLegNode"},create(t,e){return m({kind:"JSONPathLegNode",type:t,value:e})}});var Zr,Pa,zl;class Vl{constructor(e){D(this,Pa);D(this,Zr,void 0);z(this,Zr,e)}at(e){return _e(this,Pa,zl).call(this,"ArrayLocation",e)}key(e){return _e(this,Pa,zl).call(this,"Member",e)}}Zr=new WeakMap,Pa=new WeakSet,zl=function(e,n){return new Jg(Ml.cloneWithTraversal(i(this,Zr),Bl.is(i(this,Zr).traversal)?Bl.cloneWithLeg(i(this,Zr).traversal,Kg.create(e,n)):Xd.cloneWithValue(i(this,Zr).traversal,ir.createImmediate(n))))};var uo;class Jg extends Vl{constructor(n){super(n);D(this,uo,void 0);z(this,uo,n)}get expressionType(){}as(n){return new Gg(this,n)}$castTo(){return new Vl(i(this,uo))}toOperationNode(){return i(this,uo)}}uo=new WeakMap;var co,ei;class Gg{constructor(e,n){D(this,co,void 0);D(this,ei,void 0);z(this,co,e),z(this,ei,n)}get expression(){return i(this,co)}get alias(){return i(this,ei)}toOperationNode(){return pi.create(i(this,co).toOperationNode(),Ln(i(this,ei))?i(this,ei).toOperationNode():ct.create(i(this,ei)))}}co=new WeakMap,ei=new WeakMap;function Df(t=kf){function e(a,l,p){return new mt(Ru(a,l,p))}function n(a,l){return new mt(Vg(a,l))}const r=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(a){return new Ea({queryId:nt(),executor:t,queryNode:Fe.create(qa(a))})},case(a){return new mp({node:gr.create(Ks(a)?void 0:kr(a))})},ref(a,l){return Ks(l)?new mt(hs(a)):new Vl(Yw(a,l))},val(a){return new mt(np(a))},cmpr(a,l,p){return new mt(Ru(a,l,p))},bxp(a,l,p){return new mt(Ru(a,l,p))},unary:n,not(a){return n("not",a)},exists(a){return n("exists",a)},neg(a){return n("-",a)},and(a){if(a.length===0)return new mt(ir.createImmediate(!0));if(a.length===1)return new mt(a[0].toOperationNode());let l=ls.create(a[0].toOperationNode(),a[1].toOperationNode());for(let p=2;pAa(e)):[Aa(t)]}function Aa(t){return Dn(t)?Yg(t):wp(t)}function Yg(t){const e=" as ";if(t.includes(e)){const[n,r]=t.split(e).map(gp);return pi.create(mn(n),ct.create(r))}else return mn(t)}function mn(t){const e=".";if(t.includes(e)){const[n,r]=t.split(e).map(gp);return ci.createWithSchema(n,r)}else return ci.create(t)}function gp(t){return t.trim()}const bp=m({is(t){return t.kind==="AddColumnNode"},create(t){return m({kind:"AddColumnNode",column:t})}}),pt=m({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return m({kind:"ColumnDefinitionNode",column:yt.create(t),dataType:e})},cloneWithFrontModifier(t,e){return m({...t,frontModifiers:t.frontModifiers?m([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return m({...t,endModifiers:t.endModifiers?m([...t.endModifiers,e]):[e]})},cloneWith(t,e){return m({...t,...e})}}),Np=m({is(t){return t.kind==="DropColumnNode"},create(t){return m({kind:"DropColumnNode",column:yt.create(t)})}}),vp=m({is(t){return t.kind==="RenameColumnNode"},create(t,e){return m({kind:"RenameColumnNode",column:yt.create(t),renameTo:yt.create(e)})}}),Pf=m({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return m({kind:"CheckConstraintNode",expression:t,name:e?ct.create(e):void 0})}}),Xg=["no action","restrict","cascade","set null","set default"],Du=m({is(t){return t.kind==="ReferencesNode"},create(t,e){return m({kind:"ReferencesNode",table:t,columns:m([...e])})},cloneWithOnDelete(t,e){return m({...t,onDelete:e})},cloneWithOnUpdate(t,e){return m({...t,onUpdate:e})}});function _p(t){return Ln(t)?t.toOperationNode():ir.createImmediate(t)}const qu=m({is(t){return t.kind==="GeneratedNode"},create(t){return m({kind:"GeneratedNode",...t})},createWithExpression(t){return m({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return m({...t,...e})}}),Zg=m({is(t){return t.kind==="DefaultValueNode"},create(t){return m({kind:"DefaultValueNode",defaultValue:t})}});function ec(t){if(Xg.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}var Ye;const St=class St{constructor(e){D(this,Ye,void 0);z(this,Ye,e)}autoIncrement(){return new St(pt.cloneWith(i(this,Ye),{autoIncrement:!0}))}primaryKey(){return new St(pt.cloneWith(i(this,Ye),{primaryKey:!0}))}references(e){const n=hs(e);if(!n.table||Cf.is(n.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new St(pt.cloneWith(i(this,Ye),{references:Du.create(n.table,[n.column])}))}onDelete(e){if(!i(this,Ye).references)throw new Error("on delete constraint can only be added for foreign keys");return new St(pt.cloneWith(i(this,Ye),{references:Du.cloneWithOnDelete(i(this,Ye).references,ec(e))}))}onUpdate(e){if(!i(this,Ye).references)throw new Error("on update constraint can only be added for foreign keys");return new St(pt.cloneWith(i(this,Ye),{references:Du.cloneWithOnUpdate(i(this,Ye).references,ec(e))}))}unique(){return new St(pt.cloneWith(i(this,Ye),{unique:!0}))}notNull(){return new St(pt.cloneWith(i(this,Ye),{notNull:!0}))}unsigned(){return new St(pt.cloneWith(i(this,Ye),{unsigned:!0}))}defaultTo(e){return new St(pt.cloneWith(i(this,Ye),{defaultTo:Zg.create(_p(e))}))}check(e){return new St(pt.cloneWith(i(this,Ye),{check:Pf.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new St(pt.cloneWith(i(this,Ye),{generated:qu.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new St(pt.cloneWith(i(this,Ye),{generated:qu.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new St(pt.cloneWith(i(this,Ye),{generated:qu.create({identity:!0,byDefault:!0})}))}stored(){if(!i(this,Ye).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new St(pt.cloneWith(i(this,Ye),{generated:qu.cloneWith(i(this,Ye).generated,{stored:!0})}))}modifyFront(e){return new St(pt.cloneWithFrontModifier(i(this,Ye),e.toOperationNode()))}modifyEnd(e){return new St(pt.cloneWithEndModifier(i(this,Ye),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return i(this,Ye)}};Ye=new WeakMap;let di=St;Qe(di,"don't await ColumnDefinitionBuilder instances directly.");const xp=m({is(t){return t.kind==="ModifyColumnNode"},create(t){return m({kind:"ModifyColumnNode",column:t})}}),eb=m({is(t){return t.kind==="DataTypeNode"},create(t){return m({kind:"DataTypeNode",dataType:t})}});function Eo(t){return Ln(t)?t.toOperationNode():eb.create(t)}const tc=m({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,n,r){return m({kind:"ForeignKeyConstraintNode",columns:t,references:Du.create(e,n),name:r?ct.create(r):void 0})},cloneWith(t,e){return m({...t,...e})}});var Xi;const xc=class xc{constructor(e){D(this,Xi,void 0);z(this,Xi,e)}onDelete(e){return new xc(tc.cloneWith(i(this,Xi),{onDelete:ec(e)}))}onUpdate(e){return new xc(tc.cloneWith(i(this,Xi),{onUpdate:ec(e)}))}$call(e){return e(this)}toOperationNode(){return i(this,Xi)}};Xi=new WeakMap;let Sa=xc;Qe(Sa,"don't await ForeignKeyConstraintBuilder instances directly.");const Hl=m({is(t){return t.kind==="AddConstraintNode"},create(t){return m({kind:"AddConstraintNode",constraint:t})}}),Op=m({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return m({kind:"UniqueConstraintNode",columns:m(t.map(yt.create)),name:e?ct.create(e):void 0})}}),Pu=m({is(t){return t.kind==="DropConstraintNode"},create(t){return m({kind:"DropConstraintNode",constraintName:ct.create(t)})},cloneWith(t,e){return m({...t,...e})}}),Zo=m({is(t){return t.kind==="AlterColumnNode"},create(t,e,n){return m({kind:"AlterColumnNode",column:yt.create(t),[e]:n})}});var Er;class Lf{constructor(e){D(this,Er,void 0);z(this,Er,e)}setDataType(e){return new ea(Zo.create(i(this,Er),"dataType",Eo(e)))}setDefault(e){return new ea(Zo.create(i(this,Er),"setDefault",_p(e)))}dropDefault(){return new ea(Zo.create(i(this,Er),"dropDefault",!0))}setNotNull(){return new ea(Zo.create(i(this,Er),"setNotNull",!0))}dropNotNull(){return new ea(Zo.create(i(this,Er),"dropNotNull",!0))}$call(e){return e(this)}}Er=new WeakMap;var La;class ea{constructor(e){D(this,La,void 0);z(this,La,e)}toOperationNode(){return i(this,La)}}La=new WeakMap;var Jn;class ra{constructor(e){D(this,Jn,void 0);z(this,Jn,m(e))}toOperationNode(){return i(this,Jn).executor.transformQuery(i(this,Jn).node,i(this,Jn).queryId)}compile(){return i(this,Jn).executor.compileQuery(this.toOperationNode(),i(this,Jn).queryId)}async execute(){await i(this,Jn).executor.executeQuery(this.compile(),i(this,Jn).queryId)}}Jn=new WeakMap;Qe(ra,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");var Ht;const Oc=class Oc{constructor(e){D(this,Ht,void 0);z(this,Ht,m(e))}onDelete(e){return new Oc({...i(this,Ht),constraintBuilder:i(this,Ht).constraintBuilder.onDelete(e)})}onUpdate(e){return new Oc({...i(this,Ht),constraintBuilder:i(this,Ht).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return i(this,Ht).executor.transformQuery(vt.cloneWithTableProps(i(this,Ht).node,{addConstraint:Hl.create(i(this,Ht).constraintBuilder.toOperationNode())}),i(this,Ht).queryId)}compile(){return i(this,Ht).executor.compileQuery(this.toOperationNode(),i(this,Ht).queryId)}async execute(){await i(this,Ht).executor.executeQuery(this.compile(),i(this,Ht).queryId)}};Ht=new WeakMap;let nc=Oc;Qe(nc,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");var bt;const fa=class fa{constructor(e){D(this,bt,void 0);z(this,bt,m(e))}ifExists(){return new fa({...i(this,bt),node:vt.cloneWithTableProps(i(this,bt).node,{dropConstraint:Pu.cloneWith(i(this,bt).node.dropConstraint,{ifExists:!0})})})}cascade(){return new fa({...i(this,bt),node:vt.cloneWithTableProps(i(this,bt).node,{dropConstraint:Pu.cloneWith(i(this,bt).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new fa({...i(this,bt),node:vt.cloneWithTableProps(i(this,bt).node,{dropConstraint:Pu.cloneWith(i(this,bt).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return i(this,bt).executor.transformQuery(i(this,bt).node,i(this,bt).queryId)}compile(){return i(this,bt).executor.compileQuery(this.toOperationNode(),i(this,bt).queryId)}async execute(){await i(this,bt).executor.executeQuery(this.compile(),i(this,bt).queryId)}};bt=new WeakMap;let rc=fa;Qe(rc,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");var it;class Ep{constructor(e){D(this,it,void 0);z(this,it,m(e))}renameTo(e){return new ra({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{renameTo:mn(e)})})}setSchema(e){return new ra({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{setSchema:ct.create(e)})})}alterColumn(e,n){const r=n(new Lf(e));return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,r.toOperationNode())})}dropColumn(e){return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,Np.create(e))})}renameColumn(e,n){return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,vp.create(e,n))})}addColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,bp.create(a.toOperationNode()))})}modifyColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new Gr({...i(this,it),node:vt.cloneWithColumnAlteration(i(this,it).node,xp.create(a.toOperationNode()))})}addUniqueConstraint(e,n){return new ra({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{addConstraint:Hl.create(Op.create(n,e))})})}addCheckConstraint(e,n){return new ra({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{addConstraint:Hl.create(Pf.create(n.toOperationNode(),e))})})}addForeignKeyConstraint(e,n,r,a){return new nc({...i(this,it),constraintBuilder:new Sa(tc.create(n.map(yt.create),mn(r),a.map(yt.create),e))})}dropConstraint(e){return new rc({...i(this,it),node:vt.cloneWithTableProps(i(this,it).node,{dropConstraint:Pu.create(e)})})}$call(e){return e(this)}}it=new WeakMap;var dt;const $i=class $i{constructor(e){D(this,dt,void 0);z(this,dt,m(e))}alterColumn(e,n){const r=n(new Lf(e));return new $i({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,r.toOperationNode())})}dropColumn(e){return new $i({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,Np.create(e))})}renameColumn(e,n){return new $i({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,vp.create(e,n))})}addColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new $i({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,bp.create(a.toOperationNode()))})}modifyColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new $i({...i(this,dt),node:vt.cloneWithColumnAlteration(i(this,dt).node,xp.create(a.toOperationNode()))})}toOperationNode(){return i(this,dt).executor.transformQuery(i(this,dt).node,i(this,dt).queryId)}compile(){return i(this,dt).executor.compileQuery(this.toOperationNode(),i(this,dt).queryId)}async execute(){await i(this,dt).executor.executeQuery(this.compile(),i(this,dt).queryId)}};dt=new WeakMap;let Gr=$i;Qe(Ep,"don't await AlterTableBuilder instances");Qe(Lf,"don't await AlterColumnBuilder instances");Qe(Gr,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class Cp extends Tf{transformValue(e){return{...super.transformValue(e),immediate:!0}}}var Xe;const cr=class cr{constructor(e){D(this,Xe,void 0);z(this,Xe,m(e))}ifNotExists(){return new cr({...i(this,Xe),node:Vr.cloneWith(i(this,Xe).node,{ifNotExists:!0})})}unique(){return new cr({...i(this,Xe),node:Vr.cloneWith(i(this,Xe).node,{unique:!0})})}on(e){return new cr({...i(this,Xe),node:Vr.cloneWith(i(this,Xe).node,{table:mn(e)})})}column(e){return new cr({...i(this,Xe),node:Vr.cloneWithColumns(i(this,Xe).node,[bh(e)])})}columns(e){return new cr({...i(this,Xe),node:Vr.cloneWithColumns(i(this,Xe).node,e.map(bh))})}expression(e){return new cr({...i(this,Xe),node:Vr.cloneWithColumns(i(this,Xe).node,[e.toOperationNode()])})}using(e){return new cr({...i(this,Xe),node:Vr.cloneWith(i(this,Xe).node,{using:tn.createWithSql(e)})})}where(...e){const n=new Cp;return new cr({...i(this,Xe),node:Re.cloneWithWhere(i(this,Xe).node,n.transformNode(nn(e)))})}$call(e){return e(this)}toOperationNode(){return i(this,Xe).executor.transformQuery(i(this,Xe).node,i(this,Xe).queryId)}compile(){return i(this,Xe).executor.compileQuery(this.toOperationNode(),i(this,Xe).queryId)}async execute(){await i(this,Xe).executor.executeQuery(this.compile(),i(this,Xe).queryId)}};Xe=new WeakMap;let ic=cr;Qe(ic,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");var _n;const Uf=class Uf{constructor(e){D(this,_n,void 0);z(this,_n,m(e))}ifNotExists(){return new Uf({...i(this,_n),node:Kd.cloneWith(i(this,_n).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,_n).executor.transformQuery(i(this,_n).node,i(this,_n).queryId)}compile(){return i(this,_n).executor.compileQuery(this.toOperationNode(),i(this,_n).queryId)}async execute(){await i(this,_n).executor.executeQuery(this.compile(),i(this,_n).queryId)}};_n=new WeakMap;let sc=Uf;Qe(sc,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const tb=m({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return m({kind:"PrimaryKeyConstraintNode",columns:m(t.map(yt.create)),name:e?ct.create(e):void 0})}});function nb(t){if(Bw.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}var Ue;const Wn=class Wn{constructor(e){D(this,Ue,void 0);z(this,Ue,m(e))}temporary(){return new Wn({...i(this,Ue),node:jn.cloneWith(i(this,Ue).node,{temporary:!0})})}onCommit(e){return new Wn({...i(this,Ue),node:jn.cloneWith(i(this,Ue).node,{onCommit:nb(e)})})}ifNotExists(){return new Wn({...i(this,Ue),node:jn.cloneWith(i(this,Ue).node,{ifNotExists:!0})})}addColumn(e,n,r=xo){const a=r(new di(pt.create(e,Eo(n))));return new Wn({...i(this,Ue),node:jn.cloneWithColumn(i(this,Ue).node,a.toOperationNode())})}addPrimaryKeyConstraint(e,n){return new Wn({...i(this,Ue),node:jn.cloneWithConstraint(i(this,Ue).node,tb.create(n,e))})}addUniqueConstraint(e,n){return new Wn({...i(this,Ue),node:jn.cloneWithConstraint(i(this,Ue).node,Op.create(n,e))})}addCheckConstraint(e,n){return new Wn({...i(this,Ue),node:jn.cloneWithConstraint(i(this,Ue).node,Pf.create(n.toOperationNode(),e))})}addForeignKeyConstraint(e,n,r,a,l=xo){const p=l(new Sa(tc.create(n.map(yt.create),mn(r),a.map(yt.create),e)));return new Wn({...i(this,Ue),node:jn.cloneWithConstraint(i(this,Ue).node,p.toOperationNode())})}modifyFront(e){return new Wn({...i(this,Ue),node:jn.cloneWithFrontModifier(i(this,Ue).node,e.toOperationNode())})}modifyEnd(e){return new Wn({...i(this,Ue),node:jn.cloneWithEndModifier(i(this,Ue).node,e.toOperationNode())})}$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)}};Ue=new WeakMap;let oc=Wn;Qe(oc,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");var Lt;const ha=class ha{constructor(e){D(this,Lt,void 0);z(this,Lt,m(e))}on(e){return new ha({...i(this,Lt),node:Wu.cloneWith(i(this,Lt).node,{table:mn(e)})})}ifExists(){return new ha({...i(this,Lt),node:Wu.cloneWith(i(this,Lt).node,{ifExists:!0})})}cascade(){return new ha({...i(this,Lt),node:Wu.cloneWith(i(this,Lt).node,{cascade:!0})})}$call(e){return e(this)}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;let ac=ha;Qe(ac,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");var Zt;const Ec=class Ec{constructor(e){D(this,Zt,void 0);z(this,Zt,m(e))}ifExists(){return new Ec({...i(this,Zt),node:Pl.cloneWith(i(this,Zt).node,{ifExists:!0})})}cascade(){return new Ec({...i(this,Zt),node:Pl.cloneWith(i(this,Zt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Zt).executor.transformQuery(i(this,Zt).node,i(this,Zt).queryId)}compile(){return i(this,Zt).executor.compileQuery(this.toOperationNode(),i(this,Zt).queryId)}async execute(){await i(this,Zt).executor.executeQuery(this.compile(),i(this,Zt).queryId)}};Zt=new WeakMap;let uc=Ec;Qe(uc,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");var en;const Cc=class Cc{constructor(e){D(this,en,void 0);z(this,en,m(e))}ifExists(){return new Cc({...i(this,en),node:Ll.cloneWith(i(this,en).node,{ifExists:!0})})}cascade(){return new Cc({...i(this,en),node:Ll.cloneWith(i(this,en).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,en).executor.transformQuery(i(this,en).node,i(this,en).queryId)}compile(){return i(this,en).executor.compileQuery(this.toOperationNode(),i(this,en).queryId)}async execute(){await i(this,en).executor.executeQuery(this.compile(),i(this,en).queryId)}};en=new WeakMap;let cc=Cc;Qe(cc,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const Kr=m({is(t){return t.kind==="CreateViewNode"},create(t){return m({kind:"CreateViewNode",name:hi.create(t)})},cloneWith(t,e){return m({...t,...e})}});var qc;class rb{constructor(){D(this,qc,new Cp)}transformQuery(e){return i(this,qc).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}qc=new WeakMap;var ut;const Jr=class Jr{constructor(e){D(this,ut,void 0);z(this,ut,m(e))}temporary(){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{temporary:!0})})}materialized(){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{materialized:!0})})}ifNotExists(){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{ifNotExists:!0})})}orReplace(){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{orReplace:!0})})}columns(e){return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{columns:e.map(ep)})})}as(e){const n=e.withPlugin(new rb).toOperationNode();return new Jr({...i(this,ut),node:Kr.cloneWith(i(this,ut).node,{as:n})})}$call(e){return e(this)}toOperationNode(){return i(this,ut).executor.transformQuery(i(this,ut).node,i(this,ut).queryId)}compile(){return i(this,ut).executor.compileQuery(this.toOperationNode(),i(this,ut).queryId)}async execute(){await i(this,ut).executor.executeQuery(this.compile(),i(this,ut).queryId)}};ut=new WeakMap;let lc=Jr;Qe(lc,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const Lu=m({is(t){return t.kind==="DropViewNode"},create(t){return m({kind:"DropViewNode",name:hi.create(t)})},cloneWith(t,e){return m({...t,...e})}});var Mt;const da=class da{constructor(e){D(this,Mt,void 0);z(this,Mt,m(e))}materialized(){return new da({...i(this,Mt),node:Lu.cloneWith(i(this,Mt).node,{materialized:!0})})}ifExists(){return new da({...i(this,Mt),node:Lu.cloneWith(i(this,Mt).node,{ifExists:!0})})}cascade(){return new da({...i(this,Mt),node:Lu.cloneWith(i(this,Mt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Mt).executor.transformQuery(i(this,Mt).node,i(this,Mt).queryId)}compile(){return i(this,Mt).executor.compileQuery(this.toOperationNode(),i(this,Mt).queryId)}async execute(){await i(this,Mt).executor.executeQuery(this.compile(),i(this,Mt).queryId)}};Mt=new WeakMap;let fc=da;Qe(fc,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const qp=m({is(t){return t.kind==="CreateTypeNode"},create(t){return m({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return m({...t,enum:Af.create(e.map(n=>ir.createImmediate(n)))})}});var xn;const Qf=class Qf{constructor(e){D(this,xn,void 0);z(this,xn,m(e))}toOperationNode(){return i(this,xn).executor.transformQuery(i(this,xn).node,i(this,xn).queryId)}asEnum(e){return new Qf({...i(this,xn),node:qp.cloneWithEnum(i(this,xn).node,e)})}$call(e){return e(this)}compile(){return i(this,xn).executor.compileQuery(this.toOperationNode(),i(this,xn).queryId)}async execute(){await i(this,xn).executor.executeQuery(this.compile(),i(this,xn).queryId)}};xn=new WeakMap;let hc=Qf;Qe(hc,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const Ap=m({is(t){return t.kind==="DropTypeNode"},create(t){return m({kind:"DropTypeNode",name:t})},cloneWith(t,e){return m({...t,...e})}});var On;const $f=class $f{constructor(e){D(this,On,void 0);z(this,On,m(e))}ifExists(){return new $f({...i(this,On),node:Ap.cloneWith(i(this,On).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,On).executor.transformQuery(i(this,On).node,i(this,On).queryId)}compile(){return i(this,On).executor.compileQuery(this.toOperationNode(),i(this,On).queryId)}async execute(){await i(this,On).executor.executeQuery(this.compile(),i(this,On).queryId)}};On=new WeakMap;let dc=$f;Qe(dc,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function kh(t){const e=".";if(t.includes(e)){const n=t.split(e).map(ib);if(n.length===2)return hi.createWithSchema(n[0],n[1]);throw new Error(`invalid schemable identifier ${t}`)}else return hi.create(t)}function ib(t){return t.trim()}var It;const pa=class pa{constructor(e){D(this,It,void 0);z(this,It,e)}createTable(e){return new oc({queryId:nt(),executor:i(this,It),node:jn.create(mn(e))})}dropTable(e){return new cc({queryId:nt(),executor:i(this,It),node:Ll.create(mn(e))})}createIndex(e){return new ic({queryId:nt(),executor:i(this,It),node:Vr.create(e)})}dropIndex(e){return new ac({queryId:nt(),executor:i(this,It),node:Wu.create(e)})}createSchema(e){return new sc({queryId:nt(),executor:i(this,It),node:Kd.create(e)})}dropSchema(e){return new uc({queryId:nt(),executor:i(this,It),node:Pl.create(e)})}alterTable(e){return new Ep({queryId:nt(),executor:i(this,It),node:vt.create(mn(e))})}createView(e){return new lc({queryId:nt(),executor:i(this,It),node:Kr.create(e)})}dropView(e){return new fc({queryId:nt(),executor:i(this,It),node:Lu.create(e)})}createType(e){return new hc({queryId:nt(),executor:i(this,It),node:qp.create(kh(e))})}dropType(e){return new dc({queryId:nt(),executor:i(this,It),node:Ap.create(kh(e))})}withPlugin(e){return new pa(i(this,It).withPlugin(e))}withoutPlugins(){return new pa(i(this,It).withoutPlugins())}withSchema(e){return new pa(i(this,It).withPluginAtFront(new tu(e)))}};It=new WeakMap;let Kl=pa;class sb{ref(e){return new cg(e)}}var lo;class ob{constructor(e){D(this,lo,void 0);z(this,lo,e)}async provideConnection(e){const n=await i(this,lo).acquireConnection();try{return await e(n)}finally{await i(this,lo).releaseConnection(n)}}}lo=new WeakMap;var hr,dr,Cr;const ji=class ji extends hp{constructor(n,r,a,l=[]){super(l);D(this,hr,void 0);D(this,dr,void 0);D(this,Cr,void 0);z(this,hr,n),z(this,dr,r),z(this,Cr,a)}get adapter(){return i(this,dr)}compileQuery(n){return i(this,hr).compileQuery(n)}provideConnection(n){return i(this,Cr).provideConnection(n)}withPlugins(n){return new ji(i(this,hr),i(this,dr),i(this,Cr),[...this.plugins,...n])}withPlugin(n){return new ji(i(this,hr),i(this,dr),i(this,Cr),[...this.plugins,n])}withPluginAtFront(n){return new ji(i(this,hr),i(this,dr),i(this,Cr),[n,...this.plugins])}withConnectionProvider(n){return new ji(i(this,hr),i(this,dr),n,[...this.plugins])}withoutPlugins(){return new ji(i(this,hr),i(this,dr),i(this,Cr),[])}};hr=new WeakMap,dr=new WeakMap,Cr=new WeakMap;let Jl=ji;function Wh(){return typeof performance<"u"&&Pn(performance.now)?performance.now():Date.now()}var Gn,ti,qr,Zi,Ma,Ac,Sp,Sc,Ip,Ic,Tp,Tc,kp,Ba,Gl;class ab{constructor(e,n){D(this,Ac);D(this,Sc);D(this,Ic);D(this,Tc);D(this,Ba);D(this,Gn,void 0);D(this,ti,void 0);D(this,qr,void 0);D(this,Zi,void 0);D(this,Ma,new WeakSet);z(this,Gn,e),z(this,ti,n)}async init(){i(this,qr)||z(this,qr,i(this,Gn).init().catch(e=>(z(this,qr,void 0),Promise.reject(e)))),await i(this,qr)}async acquireConnection(){await this.init();const e=await i(this,Gn).acquireConnection();return i(this,Ma).has(e)||(_e(this,Ac,Sp).call(this)&&_e(this,Sc,Ip).call(this,e),i(this,Ma).add(e)),e}async releaseConnection(e){await i(this,Gn).releaseConnection(e)}beginTransaction(e,n){return i(this,Gn).beginTransaction(e,n)}commitTransaction(e){return i(this,Gn).commitTransaction(e)}rollbackTransaction(e){return i(this,Gn).rollbackTransaction(e)}async destroy(){i(this,qr)&&(await i(this,qr),i(this,Zi)||z(this,Zi,i(this,Gn).destroy().catch(e=>(z(this,Zi,void 0),Promise.reject(e)))),await i(this,Zi))}}Gn=new WeakMap,ti=new WeakMap,qr=new WeakMap,Zi=new WeakMap,Ma=new WeakMap,Ac=new WeakSet,Sp=function(){return i(this,ti).isLevelEnabled("query")||i(this,ti).isLevelEnabled("error")},Sc=new WeakSet,Ip=function(e){const n=e.executeQuery;e.executeQuery=async r=>{const a=Wh();try{return await n.call(e,r)}catch(l){throw await _e(this,Ic,Tp).call(this,l,r,a),l}finally{await _e(this,Tc,kp).call(this,r,a)}}},Ic=new WeakSet,Tp=async function(e,n,r){await i(this,ti).error(()=>({level:"error",error:e,query:n,queryDurationMillis:_e(this,Ba,Gl).call(this,r)}))},Tc=new WeakSet,kp=async function(e,n){await i(this,ti).query(()=>({level:"query",query:e,queryDurationMillis:_e(this,Ba,Gl).call(this,n)}))},Ba=new WeakSet,Gl=function(e){return Wh()-e};var Fa,ni,kc,Rp;class Wp{constructor(e){D(this,kc);D(this,Fa,void 0);D(this,ni,void 0);z(this,Fa,e)}async provideConnection(e){for(;i(this,ni);)await i(this,ni);const n=_e(this,kc,Rp).call(this,e);return z(this,ni,n.then(()=>{z(this,ni,void 0)}).catch(()=>{z(this,ni,void 0)})),n}}Fa=new WeakMap,ni=new WeakMap,kc=new WeakSet,Rp=async function(e){return await e(i(this,Fa))};const ub=["read uncommitted","read committed","repeatable read","serializable"];m(["query","error"]);var ri,es;class cb{constructor(e){D(this,ri,void 0);D(this,es,void 0);Pn(e)?(z(this,es,e),z(this,ri,m({query:!0,error:!0}))):(z(this,es,lb),z(this,ri,m({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return i(this,ri)[e]}async query(e){i(this,ri).query&&await i(this,es).call(this,e())}async error(e){i(this,ri).error&&await i(this,es).call(this,e())}}ri=new WeakMap,es=new WeakMap;function lb(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 fb(t){return wr(t)&&Pn(t.compile)}var Bt;const Qs=class Qs extends Zu{constructor(n){let r,a;if(hb(n))r={executor:n.executor},a={...n};else{const l=n.dialect,p=l.createDriver(),w=l.createQueryCompiler(),v=l.createAdapter(),d=new cb(n.log??[]),S=new ab(p,d),B=new ob(S),j=new Jl(w,v,B,n.plugins??[]);r={executor:j},a={config:n,executor:j,dialect:l,driver:S}}super(r);D(this,Bt,void 0);z(this,Bt,m(a))}get schema(){return new Kl(i(this,Bt).executor)}get dynamic(){return new sb}get introspection(){return i(this,Bt).dialect.createIntrospector(this.withoutPlugins())}case(n){return new mp({node:gr.create(Ks(n)?void 0:nl(n))})}get fn(){return pp()}transaction(){return new pc({...i(this,Bt)})}connection(){return new Dp({...i(this,Bt)})}withPlugin(n){return new Qs({...i(this,Bt),executor:i(this,Bt).executor.withPlugin(n)})}withoutPlugins(){return new Qs({...i(this,Bt),executor:i(this,Bt).executor.withoutPlugins()})}withSchema(n){return new Qs({...i(this,Bt),executor:i(this,Bt).executor.withPluginAtFront(new tu(n))})}withTables(){return new Qs({...i(this,Bt)})}async destroy(){await i(this,Bt).driver.destroy()}get isTransaction(){return!1}getExecutor(){return i(this,Bt).executor}executeQuery(n,r=nt()){const a=fb(n)?n.compile():n;return this.getExecutor().executeQuery(a,r)}};Bt=new WeakMap;let Ia=Qs;var Yn;const $s=class $s extends Ia{constructor(n){super(n);D(this,Yn,void 0);z(this,Yn,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 $s({...i(this,Yn),executor:i(this,Yn).executor.withPlugin(n)})}withoutPlugins(){return new $s({...i(this,Yn),executor:i(this,Yn).executor.withoutPlugins()})}withSchema(n){return new $s({...i(this,Yn),executor:i(this,Yn).executor.withPluginAtFront(new tu(n))})}withTables(){return new $s({...i(this,Yn)})}};Yn=new WeakMap;let Yl=$s;function hb(t){return wr(t)&&wr(t.config)&&wr(t.driver)&&wr(t.executor)&&wr(t.dialect)}var ts;class Dp{constructor(e){D(this,ts,void 0);z(this,ts,m(e))}async execute(e){return i(this,ts).executor.provideConnection(async n=>{const r=i(this,ts).executor.withConnectionProvider(new Wp(n)),a=new Ia({...i(this,ts),executor:r});return await e(a)})}}ts=new WeakMap;Qe(Dp,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");var Xn;const jf=class jf{constructor(e){D(this,Xn,void 0);z(this,Xn,m(e))}setIsolationLevel(e){return new jf({...i(this,Xn),isolationLevel:e})}async execute(e){const{isolationLevel:n,...r}=i(this,Xn),a={isolationLevel:n};return db(a),i(this,Xn).executor.provideConnection(async l=>{const p=i(this,Xn).executor.withConnectionProvider(new Wp(l)),w=new Yl({...r,executor:p});try{await i(this,Xn).driver.beginTransaction(l,a);const v=await e(w);return await i(this,Xn).driver.commitTransaction(l),v}catch(v){throw await i(this,Xn).driver.rollbackTransaction(l),v}})}};Xn=new WeakMap;let pc=jf;Qe(pc,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function db(t){if(t.isolationLevel&&!ub.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}var fn,fo,Mu,Ua,Xl,Qa,Zl;const Wc=class Wc{constructor(e){D(this,fo);D(this,Ua);D(this,Qa);D(this,fn,void 0);z(this,fn,m(e))}get expressionType(){}as(e){return new pb(this,e)}$castTo(){return new Wc({...i(this,fn)})}castTo(){return this.$castTo()}withPlugin(e){return new Wc({...i(this,fn),plugins:i(this,fn).plugins!==void 0?m([...i(this,fn).plugins,e]):m([e])})}toOperationNode(){return _e(this,Ua,Xl).call(this,_e(this,fo,Mu).call(this))}compile(e){return _e(this,Qa,Zl).call(this,_e(this,fo,Mu).call(this,e))}async execute(e){const n=_e(this,fo,Mu).call(this,e);return n.executeQuery(_e(this,Qa,Zl).call(this,n),i(this,fn).queryId)}};fn=new WeakMap,fo=new WeakSet,Mu=function(e){const n=e!==void 0?e.getExecutor():kf;return i(this,fn).plugins!==void 0?n.withPlugins(i(this,fn).plugins):n},Ua=new WeakSet,Xl=function(e){return e.transformQuery(i(this,fn).rawNode,i(this,fn).queryId)},Qa=new WeakSet,Zl=function(e){return e.compileQuery(_e(this,Ua,Xl).call(this,e),i(this,fn).queryId)};let zn=Wc;Qe(zn,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");var ho,ii;class pb{constructor(e,n){D(this,ho,void 0);D(this,ii,void 0);z(this,ho,e),z(this,ii,n)}get expression(){return i(this,ho)}get alias(){return i(this,ii)}toOperationNode(){return pi.create(i(this,ho).toOperationNode(),Ln(i(this,ii))?i(this,ii).toOperationNode():ct.create(i(this,ii)))}}ho=new WeakMap,ii=new WeakMap;const Cn=Object.assign((t,...e)=>new zn({queryId:nt(),rawNode:tn.create(t,(e==null?void 0:e.map(Ir))??[])}),{ref(t){return new zn({queryId:nt(),rawNode:tn.createWithChild(hs(t))})},val(t){return new zn({queryId:nt(),rawNode:tn.createWithChild(Ir(t))})},value(t){return this.val(t)},table(t){return new zn({queryId:nt(),rawNode:tn.createWithChild(mn(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new zn({queryId:nt(),rawNode:tn.create(e,t.map(ct.create))})},lit(t){return new zn({queryId:nt(),rawNode:tn.createWithChild(ir.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new zn({queryId:nt(),rawNode:tn.createWithSql(t)})},join(t,e=Cn`, `){const n=new Array(2*t.length-1),r=e.toOperationNode();for(let a=0;a{this.nodeStack.push(e),i(this,Rc)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Rc=new WeakMap;var po,ns;class yb extends mb{constructor(){super(...arguments);D(this,po,"");D(this,ns,[])}get numParameters(){return i(this,ns).length}compileQuery(n){return z(this,po,""),z(this,ns,[]),this.visitNode(n),m({query:n,sql:this.getSql(),parameters:[...i(this,ns)]})}getSql(){return i(this,po)}visitSelectQuery(n){const r=this.parentNode!==void 0&&!mr.is(this.parentNode)&&!Kr.is(this.parentNode)&&!dp.is(this.parentNode);this.parentNode===void 0&&n.explain&&(this.visitNode(n.explain),this.append(" ")),r&&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," ")),r&&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,r=", "){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 r=this.nodeStack.find(Re.is)!==n;!r&&n.explain&&(this.visitNode(n.explain),this.append(" ")),r&&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)),r&&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(wb[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 _a.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))}visitJSONReference(n){this.visitNode(n.reference),this.visitNode(n.traversal)}visitJSONPath(n){n.inOperator&&this.visitNode(n.inOperator),this.append("'$");for(const r of n.pathLegs)this.visitNode(r);this.append("'")}visitJSONPathLeg(n){const r=n.type==="ArrayLocation";this.append(r?"[":"."),this.append(String(n.value)),r&&this.append("]")}visitJSONOperatorChain(n){for(let r=0,a=n.values.length;r"),this.visitNode(n.values[r])}append(n){z(this,po,i(this,po)+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 r=this.getLeftIdentifierWrapper(),a=this.getRightIdentifierWrapper();let l="";for(const p of n)l+=p,p===r?l+=r:p===a&&(l+=a);return l}addParameter(n){i(this,ns).push(n)}appendImmediateValue(n){if(Dn(n))this.append(`'${n}'`);else if(Pw(n)||zd(n))this.append(n.toString());else if(Hd(n))this.append("null");else if(Lw(n))this.appendImmediateValue(n.toISOString());else if(Mw(n))this.appendImmediateValue(n.toString());else throw new Error(`invalid immediate value ${n}`)}}po=new WeakMap,ns=new WeakMap;const wb=m({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),gb=m({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),dn=m({raw(t,e=[]){return m({sql:t,query:tn.createWithSql(t),parameters:m(e)})}}),bb=/"/g;class Pp extends yb{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(bb,'""')}visitDefaultInsertValue(e){this.append("null")}}const Nb="kysely_migration",vb="kysely_migration_lock";m({__noMigrations__:!0});var mo,Dc,Mp;class Lp{constructor(e){D(this,Dc);D(this,mo,void 0);z(this,mo,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let n=i(this,mo).selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(n=n.where("name","!=",Nb).where("name","!=",vb));const r=await n.execute();return Promise.all(r.map(({name:a})=>_e(this,Dc,Mp).call(this,a)))}async getMetadata(e){return{tables:await this.getTables(e)}}}mo=new WeakMap,Dc=new WeakSet,Mp=async function(e){var p,w,v,d,S,B;const n=i(this,mo),r=await n.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),a=(B=(S=(d=(v=(w=(p=r.sql)==null?void 0:p.split(/[\(\),]/))==null?void 0:w.find(j=>j.toLowerCase().includes("autoincrement")))==null?void 0:v.trimStart())==null?void 0:d.split(/\s+/))==null?void 0:S[0])==null?void 0:B.replace(/["`]/g,""),l=await n.selectFrom(Cn`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:r.type==="view",columns:l.map(j=>({name:j.name,dataType:j.type,isNullable:!j.notnull,isAutoIncrementing:j.name===a,hasDefaultValue:j.dflt_value!=null}))}};class Bp{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Fp=class{createQueryCompiler(){return new Pp}createAdapter(){return new Bp}createIntrospector(t){return new Lp(t)}},$a,zh,Up=(zh=class{constructor(){D(this,$a,new _b);ge(this,"connection")}async acquireConnection(){return await i(this,$a).lock(),this.connection}async beginTransaction(t){await t.executeQuery(dn.raw("begin"))}async commitTransaction(t){await t.executeQuery(dn.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(dn.raw("rollback"))}async releaseConnection(){i(this,$a).unlock()}},$a=new WeakMap,zh),_b=class{constructor(){ge(this,"promise");ge(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()}},Qp=class{streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:n,query:r}=t;return["SelectQueryNode","RawNode"].includes(r.kind)?{rows:await this.query(n,e)}:{rows:[],...await this.exec(n,e)}}};function xb({func:t,delay:e,maxCalls:n}){let r,a=0,l=null;function p(){r&&clearTimeout(r),a=0,l=null}function w(){a>=n?(t(l),p()):(r&&clearTimeout(r),r=setTimeout(()=>{t(l),p(),r=void 0},e))}return v=>{a++,l=v,r===void 0&&a===0?(t(v),a++):w()}}var Ob=class extends Up{constructor(e){super();ge(this,"config");ge(this,"db");this.config=e}async init(){var e,n,r,a,l,p;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 Eb(this.db,(e=this.config.onWrite)==null?void 0:e.func,(n=this.config.onWrite)==null?void 0:n.isThrottle,(r=this.config.onWrite)==null?void 0:r.maxCalls,(a=this.config.onWrite)==null?void 0:a.delay),await((p=(l=this.config).onCreateConnection)==null?void 0:p.call(l,this.connection))}async beginTransaction(e){await e.executeQuery(dn.raw("begin")),e.transactionNum++}async commitTransaction(e){await e.executeQuery(dn.raw("commit")),e.transactionNum--}async rollbackTransaction(e){await e.executeQuery(dn.raw("rollback")),e.transactionNum--}async destroy(){var e;(e=this.db)==null||e.close()}},Eb=class extends Qp{constructor(e,n,r=!1,a=1e3,l=2e3){super();ge(this,"db");ge(this,"onWrite");ge(this,"transactionNum",0);this.db=e,this.onWrite=n?r?xb({func:n,maxCalls:a,delay:l}):n:void 0}query(e,n){const r=this.db.prepare(e);r.bind(n);const a=[];for(;r.step();)a.push(r.getAsObject());return r.free(),a}exec(e,n){this.db.run(e,n);const r=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:r}}},ja,Hh,Cb=(Hh=class extends Fp{constructor(e){super();D(this,ja,void 0);z(this,ja,e)}createDriver(){return new Ob(i(this,ja))}},ja=new WeakMap,Hh),qb=class extends Up{constructor(e){super();ge(this,"config");ge(this,"db");this.config=e}async init(){var e,n;this.db=typeof this.config.database=="function"?await this.config.database():this.config.database,this.connection=new Ab(this.db),await((n=(e=this.config).onCreateConnection)==null?void 0:n.call(e,this.connection))}async destroy(){var e;await((e=this.db)==null?void 0:e.sqlite.close(this.db.db))}},Ab=class extends Qp{constructor(e){super();ge(this,"sqlite");ge(this,"db");this.db=e.db,this.sqlite=e.sqlite}async run(e){const n=this.sqlite.str_new(this.db,e.sql),r=await this.sqlite.prepare_v2(this.db,this.sqlite.str_value(n));if(r===null)return[];const a=r.stmt;try{typeof e.param<"u"&&this.sqlite.bind_collection(a,e.param);const l=[];let p=[];for(;await this.sqlite.step(a)===100;){p=p.length===0?this.sqlite.column_names(a):p;const w=this.sqlite.row(a);l.push(p.reduce((v,d,S)=>(v[d]=w[S],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 r=await this.run({sql:"SELECT last_insert_rowid() as id"});return{insertId:BigInt(r[0].id),numAffectedRows:BigInt(this.sqlite.changes(this.db))}}},Va,Kh,Sb=(Kh=class extends Fp{constructor(e){super();D(this,Va,void 0);z(this,Va,e)}createDriver(){return new qb(i(this,Va))}},Va=new WeakMap,Kh);function Ib(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Tb(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:function(){return t[r]}})}),n}var $p={exports:{}};const kb={},Wb=Object.freeze(Object.defineProperty({__proto__:null,default:kb},Symbol.toStringTag,{value:"Module"})),Au=Tb(Wb);(function(t,e){var n=void 0,r=function(a){return n||(n=new Promise(function(l,p){var w=typeof a<"u"?a:{},v=w.onAbort;w.onAbort=function(o){p(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(q,J){switch(typeof J){case"boolean":bu(q,J?1:0);break;case"number":wu(q,J);break;case"string":Yo(q,J,-1,-1);break;case"object":if(J===null)Go(q);else if(J.length!=null){var s=As(J);gu(q,s,J.length,-1),Ii(s)}else Wi(q,"Wrong API use : tried to return a value of an unknown type ("+J+").",-1);break;default:Go(q)}}function c(q,J){for(var s=[],u=0;u>>0),q!=null){var J=this.filename,s="/",u=J;if(s&&(s=typeof s=="string"?s:yi(s),u=J?ue(s+"/"+J):s),J=on(!0,!0),u=gi(u,(J!==void 0?J:438)&4095|32768,0),q){if(typeof q=="string"){s=Array(q.length);for(var f=0,y=q.length;f{X||(I=Au,X=Au)},E=function(o,c){return de(),o=X.normalize(o),I.readFileSync(o,c?void 0:"utf8")},A=o=>(o=E(o,!0),o.buffer||(o=new Uint8Array(o)),o),N=(o,c,h)=>{de(),o=X.normalize(o),I.readFile(o,function(g,O){g?h(g):c(O.buffer)})},1{var c=new XMLHttpRequest;return c.open("GET",o,!1),c.send(null),c.responseText},te&&(A=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 oe=d.print||console.log.bind(console),be=d.printErr||console.warn.bind(console);Object.assign(d,S),S=null,d.thisProgram&&(B=d.thisProgram);var Ne;d.wasmBinary&&(Ne=d.wasmBinary),d.noExitRuntime,typeof WebAssembly!="object"&&x("no native wasm support detected");var Ze,He=!1,Ot=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Et(o,c,h){var g=c+h;for(h=c;o[h]&&!(h>=g);)++h;if(16O?g+=String.fromCharCode(O):(O-=65536,g+=String.fromCharCode(55296|O>>10,56320|O&1023))}}else g+=String.fromCharCode(O)}return g}function $e(o,c){return o?Et(qe,o,c):""}function Qt(o,c,h,g){if(!(0=F){var we=o.charCodeAt(++R);F=65536+((F&1023)<<10)|we&1023}if(127>=F){if(h>=g)break;c[h++]=F}else{if(2047>=F){if(h+1>=g)break;c[h++]=192|F>>6}else{if(65535>=F){if(h+2>=g)break;c[h++]=224|F>>12}else{if(h+3>=g)break;c[h++]=240|F>>18,c[h++]=128|F>>12&63}c[h++]=128|F>>6&63}c[h++]=128|F&63}}return c[h]=0,h-O}function rn(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 ht,me,qe,st,pe,ke,Wt,br;function ds(){var o=Ze.buffer;ht=o,d.HEAP8=me=new Int8Array(o),d.HEAP16=st=new Int16Array(o),d.HEAP32=pe=new Int32Array(o),d.HEAPU8=qe=new Uint8Array(o),d.HEAPU16=new Uint16Array(o),d.HEAPU32=ke=new Uint32Array(o),d.HEAPF32=Wt=new Float32Array(o),d.HEAPF64=br=new Float64Array(o)}var wn,sn=[],fe=[],Le=[];function Mn(){var o=d.preRun.shift();sn.unshift(o)}var $t=0,Ke=null;function x(o){throw d.onAbort&&d.onAbort(o),o="Aborted("+o+")",be(o),He=!0,new WebAssembly.RuntimeError(o+". Build with -sASSERTIONS for more info.")}function C(){return W.startsWith("data:application/octet-stream;base64,")}var W;if(W="sql-wasm.wasm",!C()){var L=W;W=d.locateFile?d.locateFile(L,b):b+L}function H(){var o=W;try{if(o==W&&Ne)return new Uint8Array(Ne);if(A)return A(o);throw"both async and sync fetching of the wasm failed"}catch(c){x(c)}}function Z(){if(!Ne&&(j||te)){if(typeof fetch=="function"&&!W.startsWith("file://"))return fetch(W,{credentials:"same-origin"}).then(function(o){if(!o.ok)throw"failed to load wasm binary file at '"+W+"'";return o.arrayBuffer()}).catch(function(){return H()});if(N)return new Promise(function(o,c){N(W,function(h){o(new Uint8Array(h))},c)})}return Promise.resolve().then(function(){return H()})}var U,V;function ne(o){for(;0>0];case"i8":return me[o>>0];case"i16":return st[o>>1];case"i32":return pe[o>>2];case"i64":return pe[o>>2];case"float":return Wt[o>>2];case"double":return br[o>>3];case"*":return ke[o>>2];default:x("invalid type for getValue: "+c)}return null}function ce(o){var c="i32";switch(c.endsWith("*")&&(c="*"),c){case"i1":me[o>>0]=0;break;case"i8":me[o>>0]=0;break;case"i16":st[o>>1]=0;break;case"i32":pe[o>>2]=0;break;case"i64":V=[0,(U=0,1<=+Math.abs(U)?0>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],pe[o>>2]=V[0],pe[o+4>>2]=V[1];break;case"float":Wt[o>>2]=0;break;case"double":br[o>>3]=0;break;case"*":ke[o>>2]=0;break;default:x("invalid type for setValue: "+c)}}var ae=(o,c)=>{for(var h=0,g=o.length-1;0<=g;g--){var O=o[g];O==="."?o.splice(g,1):O===".."?(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=ae(o.split("/").filter(g=>!!g),!c).join("/"))||c||(o="."),o&&h&&(o+="/"),(c?"/":"")+o},ye=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)},Oe=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(se)try{var c=Au;return()=>c.randomBytes(1)[0]}catch{}return()=>x("randomDevice")}function De(){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=ae(o.split("/").filter(g=>!!g),!c).join("/"),(c?"/":"")+o||"."}function rt(o,c){var h=Array(rn(o)+1);return o=Qt(o,h,0,h.length),c&&(h.length=o),h}var he=[];function gn(o,c){he[o]={input:[],output:[],Xa:c},wi(o,mi)}var mi={open:function(o){var c=he[o.node.rdev];if(!c)throw new Q(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 Q(60);for(var O=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-O,g),8c)throw new Q(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,O){if((o.node.mode&61440)!==32768)throw new Q(43);if(o=o.node.Ia,O&2||o.buffer!==ht){if((0{if(o=De("/",o),!o)return{path:"",node:null};if(c=Object.assign({rb:!0,kb:0},c),8!!F),!1);for(var h=Rt,g="/",O=0;O{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}},ys=(o,c)=>{for(var h=0,g=0;g>>0)%bn.length},Nr=o=>{var c=ys(o.parent.id,o.name);if(bn[c]===o)bn[c]=o.Wa;else for(c=bn[c];c;){if(c.Wa===o){c.Wa=o.Wa;break}c=c.Wa}},sr=(o,c)=>{var h;if(h=(h=Dr(o,"x"))?h:o.Ga.lookup?0:2)throw new Q(h,o);for(h=bn[ys(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)},Io=(o,c,h,g)=>(o=new Uo(o,c,h,g),c=ys(o.parent.id,o.name),o.Wa=bn[c],bn[c]=o),il={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},To=o=>{var c=["r","w","rw"][o&3];return o&512&&(c+="w"),c},Dr=(o,c)=>{if(ms)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},ws=(o,c)=>{try{return sr(o,c),20}catch{}return Dr(o,"wx")},ko=(o,c,h)=>{try{var g=sr(o,c)}catch(O){return O.Ka}if(o=Dr(o,"wx"))return o;if(h){if((g.mode&61440)!==16384)return 54;if(g===g.parent||yi(g)==="/")return 10}else if((g.mode&61440)===16384)return 31;return 0},Wo=(o=0)=>{for(;4096>=o;o++)if(!qn[o])return o;throw new Q(33)},Nn=(o,c)=>(Ei||(Ei=function(){this.$a={}},Ei.prototype={},Object.defineProperties(Ei.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 Ei,o),c=Wo(c),o.fd=c,qn[c]=o),gs={open:o=>{o.Ha=ee[o.node.rdev].Ha,o.Ha.open&&o.Ha.open(o)},Ta:()=>{throw new Q(70)}},wi=(o,c)=>{ee[o]={Ha:c}},Ro=(o,c)=>{var h=c==="/",g=!c;if(h&&Rt)throw new Q(10);if(!h&&!g){var O=Dt(c,{rb:!1});if(c=O.path,O=O.node,O.Va)throw new Q(10);if((O.mode&61440)!==16384)throw new Q(54)}c={type:o,Kb:{},ub:c,Eb:[]},o=o.Ra(c),o.Ra=c,c.root=o,h?Rt=o:O&&(O.Va=c,O.Ra&&O.Ra.Eb.push(c))},gi=(o,c,h)=>{var g=Dt(o,{parent:!0}).node;if(o=Oe(o),!o||o==="."||o==="..")throw new Q(28);var O=ws(g,o);if(O)throw new Q(O);if(!g.Ga.ab)throw new Q(63);return g.Ga.ab(g,o,c,h)},Yt=(o,c)=>gi(o,(c!==void 0?c:511)&1023|16384,0),bi=(o,c,h)=>{typeof h>"u"&&(h=c,c=438),gi(o,c|8192,h)},bs=(o,c)=>{if(!De(o))throw new Q(44);var h=Dt(c,{parent:!0}).node;if(!h)throw new Q(44);c=Oe(c);var g=ws(h,c);if(g)throw new Q(g);if(!h.Ga.symlink)throw new Q(63);h.Ga.symlink(h,c,o)},Do=o=>{var c=Dt(o,{parent:!0}).node;o=Oe(o);var h=sr(c,o),g=ko(c,o,!0);if(g)throw new Q(g);if(!c.Ga.rmdir)throw new Q(63);if(h.Va)throw new Q(10);c.Ga.rmdir(c,o),Nr(h)},Ni=o=>{var c=Dt(o,{parent:!0}).node;if(!c)throw new Q(44);o=Oe(o);var h=sr(c,o),g=ko(c,o,!1);if(g)throw new Q(g);if(!c.Ga.unlink)throw new Q(63);if(h.Va)throw new Q(10);c.Ga.unlink(c,o),Nr(h)},Po=o=>{if(o=Dt(o).node,!o)throw new Q(44);if(!o.Ga.readlink)throw new Q(28);return De(yi(o.parent),o.Ga.readlink(o))},Pr=(o,c)=>{if(o=Dt(o,{Sa:!c}).node,!o)throw new Q(44);if(!o.Ga.Pa)throw new Q(63);return o.Ga.Pa(o)},Lo=o=>Pr(o,!0),Ns=(o,c)=>{if(o=typeof o=="string"?Dt(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new Q(63);o.Ga.Oa(o,{mode:c&4095|o.mode&-4096,timestamp:Date.now()})},Lr=(o,c)=>{if(0>c)throw new Q(28);if(o=typeof o=="string"?Dt(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new Q(63);if((o.mode&61440)===16384)throw new Q(31);if((o.mode&61440)!==32768)throw new Q(28);var h=Dr(o,"w");if(h)throw new Q(h);o.Ga.Oa(o,{size:c,timestamp:Date.now()})},or=(o,c,h)=>{if(o==="")throw new Q(44);if(typeof c=="string"){var g=il[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 O=o;else{o=ue(o);try{O=Dt(o,{Sa:!(c&131072)}).node}catch{}}if(g=!1,c&64)if(O){if(c&128)throw new Q(20)}else O=gi(o,h,0),g=!0;if(!O)throw new Q(44);if((O.mode&61440)===8192&&(c&=-513),c&65536&&(O.mode&61440)!==16384)throw new Q(54);if(!g&&(h=O?(O.mode&61440)===40960?32:(O.mode&61440)===16384&&(To(c)!=="r"||c&512)?31:Dr(O,To(c)):44))throw new Q(h);return c&512&&!g&&Lr(O,0),c&=-131713,O=Nn({node:O,path:yi(O),flags:c,seekable:!0,position:0,Ha:O.Ha,Ib:[],error:!1}),O.Ha.open&&O.Ha.open(O),!d.logReadFiles||c&1||(Ci||(Ci={}),o in Ci||(Ci[o]=1)),O},Ve=o=>{if(o.fd===null)throw new Q(8);o.hb&&(o.hb=null);try{o.Ha.close&&o.Ha.close(o)}catch(c){throw c}finally{qn[o.fd]=null}o.fd=null},Mr=(o,c,h)=>{if(o.fd===null)throw new Q(8);if(!o.seekable||!o.Ha.Ta)throw new Q(70);if(h!=0&&h!=1&&h!=2)throw new Q(28);o.position=o.Ha.Ta(o,c,h),o.Ib=[]},vi=(o,c,h,g,O)=>{if(0>g||0>O)throw new Q(28);if(o.fd===null)throw new Q(8);if((o.flags&2097155)===1)throw new Q(8);if((o.node.mode&61440)===16384)throw new Q(31);if(!o.Ha.read)throw new Q(28);var R=typeof O<"u";if(!R)O=o.position;else if(!o.seekable)throw new Q(70);return c=o.Ha.read(o,c,h,g,O),R||(o.position+=c),c},ar=(o,c,h,g,O)=>{if(0>g||0>O)throw new Q(28);if(o.fd===null)throw new Q(8);if(!(o.flags&2097155))throw new Q(8);if((o.node.mode&61440)===16384)throw new Q(31);if(!o.Ha.write)throw new Q(28);o.seekable&&o.flags&1024&&Mr(o,0,2);var R=typeof O<"u";if(!R)O=o.position;else if(!o.seekable)throw new Q(70);return c=o.Ha.write(o,c,h,g,O,void 0),R||(o.position+=c),c},vs=o=>{var c,h=or(o,h||0);o=Pr(o).size;var g=new Uint8Array(o);return vi(h,g,0,o,0),c=g,Ve(h),c},_i=()=>{Q||(Q=function(o,c){this.node=c,this.Hb=function(h){this.Ka=h},this.Hb(o),this.message="FS error"},Q.prototype=Error(),Q.prototype.constructor=Q,[44].forEach(o=>{Bn[o]=new Q(o),Bn[o].stack=""}))},xi,on=(o,c)=>{var h=0;return o&&(h|=365),c&&(h|=146),h},An=(o,c,h)=>{o=ue("/dev/"+o);var g=on(!!c,!!h);Oi||(Oi=64);var O=Oi++<<8|0;wi(O,{open:R=>{R.seekable=!1},close:()=>{h&&h.buffer&&h.buffer.length&&h(10)},read:(R,F,we,Pe)=>{for(var We=0,ot=0;ot{for(var We=0;We>2]=g.dev,pe[h+8>>2]=g.ino,pe[h+12>>2]=g.mode,ke[h+16>>2]=g.nlink,pe[h+20>>2]=g.uid,pe[h+24>>2]=g.gid,pe[h+28>>2]=g.rdev,V=[g.size>>>0,(U=g.size,1<=+Math.abs(U)?0>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],pe[h+40>>2]=V[0],pe[h+44>>2]=V[1],pe[h+48>>2]=4096,pe[h+52>>2]=g.blocks,V=[Math.floor(g.atime.getTime()/1e3)>>>0,(U=Math.floor(g.atime.getTime()/1e3),1<=+Math.abs(U)?0>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],pe[h+56>>2]=V[0],pe[h+60>>2]=V[1],ke[h+64>>2]=0,V=[Math.floor(g.mtime.getTime()/1e3)>>>0,(U=Math.floor(g.mtime.getTime()/1e3),1<=+Math.abs(U)?0>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],pe[h+72>>2]=V[0],pe[h+76>>2]=V[1],ke[h+80>>2]=0,V=[Math.floor(g.ctime.getTime()/1e3)>>>0,(U=Math.floor(g.ctime.getTime()/1e3),1<=+Math.abs(U)?0>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],pe[h+88>>2]=V[0],pe[h+92>>2]=V[1],ke[h+96>>2]=0,V=[g.ino>>>0,(U=g.ino,1<=+Math.abs(U)?0>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],pe[h+104>>2]=V[0],pe[h+108>>2]=V[1],0}var Br=void 0;function Ai(){return Br+=4,pe[Br-4>>2]}function an(o){if(o=qn[o],!o)throw new Q(8);return o}function _s(o){return ke[o>>2]+4294967296*pe[o+4>>2]}function Mo(o){var c=rn(o)+1,h=Si(c);return h&&Qt(o,me,h,c),h}function nu(o,c,h){function g(Pe){return(Pe=Pe.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Pe[1]:"GMT"}var O=new Date().getFullYear(),R=new Date(O,0,1),F=new Date(O,6,1);O=R.getTimezoneOffset();var we=F.getTimezoneOffset();pe[o>>2]=60*Math.max(O,we),pe[c>>2]=+(O!=we),o=g(R),c=g(F),o=Mo(o),c=Mo(c),we>2]=o,ke[h+4>>2]=c):(ke[h>>2]=c,ke[h+4>>2]=o)}function xs(o,c,h){xs.Bb||(xs.Bb=!0,nu(o,c,h))}var Bo;Bo=se?()=>{var o=process.hrtime();return 1e3*o[0]+o[1]/1e6}:()=>performance.now();var Os={};function Fo(){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",_:B||"./this.program"},c;for(c in Os)Os[c]===void 0?delete o[c]:o[c]=Os[c];var h=[];for(c in o)h.push(c+"="+o[c]);Es=h}return Es}var Es,Un=void 0,Cs=[];function qs(o,c){if(!Un){Un=new WeakMap;var h=wn.length;if(Un)for(var g=0;g<0+h;g++){var O=wn.get(g);O&&Un.set(O,g)}}if(Un.has(o))return Un.get(o);if(Cs.length)h=Cs.pop();else{try{wn.grow(1)}catch(we){throw we instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":we}h=wn.length-1}try{wn.set(h,o)}catch(we){if(!(we instanceof TypeError))throw we;if(typeof WebAssembly.Function=="function"){g=WebAssembly.Function,O={i:"i32",j:"i64",f:"f32",d:"f64",p:"i32"};for(var R={parameters:[],results:c[0]=="v"?[]:[O[c[0]]]},F=1;FF?g.push(F):g.push(F%128|128,F>>7),F=0;FO?c.push(O):c.push(O%128|128,O>>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}wn.set(h,c)}return Un.set(o,h),h}function Fr(o){Un.delete(wn.get(o)),Cs.push(o)}function As(o){var c=Si(o.length);return o.subarray||o.slice||(o=new Uint8Array(o)),qe.set(o,c),c}function ru(o,c,h,g){var O={string:We=>{var ot=0;if(We!=null&&We!==0){var Sn=(We.length<<2)+1;ot=Qn(Sn),Qt(We,qe,ot,Sn)}return ot},array:We=>{var ot=Qn(We.length);return me.set(We,ot),ot}};o=d["_"+o];var R=[],F=0;if(g)for(var we=0;we{Yt("/dev"),wi(259,{read:()=>0,write:(c,h,g,O)=>O}),bi("/dev/null",259),gn(1280,jt),gn(1536,ps),bi("/dev/tty",1280),bi("/dev/tty1",1536);var o=je();An("random",o),An("urandom",o),Yt("/dev/shm"),Yt("/dev/shm/tmp")})(),(()=>{Yt("/proc");var o=Yt("/proc/self");Yt("/proc/self/fd"),Ro({Ra:()=>{var c=Io(o,"fd",16895,73);return c.Ga={lookup:(h,g)=>{var O=qn[+g];if(!O)throw new Q(8);return h={parent:null,Ra:{ub:"fake"},Ga:{readlink:()=>O.path}},h.parent=h}},c}},"/proc/self/fd")})();var iu={a:function(o,c,h,g){x("Assertion failed: "+$e(o)+", at: "+[c?$e(c):"unknown filename",h,g?$e(g):"unknown function"])},h:function(o,c){try{return o=$e(o),Ns(o,c),0}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return-h.Ka}},H:function(o,c,h){try{if(c=$e(c),c=Fn(o,c),h&-8)return-28;var g=Dt(c,{Sa:!0}).node;return g?(o="",h&4&&(o+="r"),h&2&&(o+="w"),h&1&&(o+="x"),o&&Dr(g,o)?-2:0):-44}catch(O){if(typeof Je>"u"||!(O instanceof Q))throw O;return-O.Ka}},i:function(o,c){try{var h=qn[o];if(!h)throw new Q(8);return Ns(h.node,c),0}catch(g){if(typeof Je>"u"||!(g instanceof Q))throw g;return-g.Ka}},g:function(o){try{var c=qn[o];if(!c)throw new Q(8);var h=c.node,g=typeof h=="string"?Dt(h,{Sa:!0}).node:h;if(!g.Ga.Oa)throw new Q(63);return g.Ga.Oa(g,{timestamp:Date.now()}),0}catch(O){if(typeof Je>"u"||!(O instanceof Q))throw O;return-O.Ka}},b:function(o,c,h){Br=h;try{var g=an(o);switch(c){case 0:var O=Ai();return 0>O?-28:Nn(g,O).fd;case 1:case 2:return 0;case 3:return g.flags;case 4:return O=Ai(),g.flags|=O,0;case 5:return O=Ai(),st[O+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return pe[Qo()>>2]=28,-1;default:return-28}}catch(R){if(typeof Je>"u"||!(R instanceof Q))throw R;return-R.Ka}},G:function(o,c){try{var h=an(o);return qi(Pr,h.path,c)}catch(g){if(typeof Je>"u"||!(g instanceof Q))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=qn[o];if(!g)throw new Q(8);if(!(g.flags&2097155))throw new Q(28);return Lr(g.node,c),0}catch(O){if(typeof Je>"u"||!(O instanceof Q))throw O;return-O.Ka}},B:function(o,c){try{if(c===0)return-28;var h=rn("/")+1;return c"u"||!(g instanceof Q))throw g;return-g.Ka}},E:function(o,c){try{return o=$e(o),qi(Lo,o,c)}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return-h.Ka}},y:function(o,c,h){try{return c=$e(c),c=Fn(o,c),c=ue(c),c[c.length-1]==="/"&&(c=c.substr(0,c.length-1)),Yt(c,h),0}catch(g){if(typeof Je>"u"||!(g instanceof Q))throw g;return-g.Ka}},D:function(o,c,h,g){try{c=$e(c);var O=g&256;return c=Fn(o,c,g&4096),qi(O?Lo:Pr,c,h)}catch(R){if(typeof Je>"u"||!(R instanceof Q))throw R;return-R.Ka}},v:function(o,c,h,g){Br=g;try{c=$e(c),c=Fn(o,c);var O=g?Ai():0;return or(c,h,O).fd}catch(R){if(typeof Je>"u"||!(R instanceof Q))throw R;return-R.Ka}},t:function(o,c,h,g){try{if(c=$e(c),c=Fn(o,c),0>=g)return-28;var O=Po(c),R=Math.min(g,rn(O)),F=me[h+R];return Qt(O,qe,h,g+1),me[h+R]=F,R}catch(we){if(typeof Je>"u"||!(we instanceof Q))throw we;return-we.Ka}},s:function(o){try{return o=$e(o),Do(o),0}catch(c){if(typeof Je>"u"||!(c instanceof Q))throw c;return-c.Ka}},F:function(o,c){try{return o=$e(o),qi(Pr,o,c)}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return-h.Ka}},p:function(o,c,h){try{return c=$e(c),c=Fn(o,c),h===0?Ni(c):h===512?Do(c):x("Invalid flags passed to unlinkat"),0}catch(g){if(typeof Je>"u"||!(g instanceof Q))throw g;return-g.Ka}},o:function(o,c,h){try{if(c=$e(c),c=Fn(o,c,!0),h){var g=_s(h),O=pe[h+8>>2];R=1e3*g+O/1e6,h+=16,g=_s(h),O=pe[h+8>>2],F=1e3*g+O/1e6}else var R=Date.now(),F=R;o=R;var we=Dt(c,{Sa:!0}).node;return we.Ga.Oa(we,{timestamp:Math.max(o,F)}),0}catch(Pe){if(typeof Je>"u"||!(Pe instanceof Q))throw Pe;return-Pe.Ka}},e:function(){return Date.now()},j:function(o,c){o=new Date(1e3*_s(o)),pe[c>>2]=o.getSeconds(),pe[c+4>>2]=o.getMinutes(),pe[c+8>>2]=o.getHours(),pe[c+12>>2]=o.getDate(),pe[c+16>>2]=o.getMonth(),pe[c+20>>2]=o.getFullYear()-1900,pe[c+24>>2]=o.getDay();var h=new Date(o.getFullYear(),0,1);pe[c+28>>2]=(o.getTime()-h.getTime())/864e5|0,pe[c+36>>2]=-(60*o.getTimezoneOffset());var g=new Date(o.getFullYear(),6,1).getTimezoneOffset();h=h.getTimezoneOffset(),pe[c+32>>2]=(g!=h&&o.getTimezoneOffset()==Math.min(h,g))|0},w:function(o,c,h,g,O,R){try{var F=an(g);if(c&2&&!(h&2)&&(F.flags&2097155)!==2)throw new Q(2);if((F.flags&2097155)===1)throw new Q(2);if(!F.Ha.bb)throw new Q(43);var we=F.Ha.bb(F,o,O,c,h),Pe=we.Fb;return pe[R>>2]=we.vb,Pe}catch(We){if(typeof Je>"u"||!(We instanceof Q))throw We;return-We.Ka}},x:function(o,c,h,g,O,R){try{var F=an(O);if(h&2){var we=qe.slice(o,o+c);F&&F.Ha.cb&&F.Ha.cb(F,we,R,c,g)}}catch(Pe){if(typeof Je>"u"||!(Pe instanceof Q))throw Pe;return-Pe.Ka}},n:xs,q:function(){return 2147483648},d:Bo,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 O=Math;g=Math.max(o,g),O=O.min.call(O,2147483648,g+(65536-g%65536)%65536);e:{try{Ze.grow(O-ht.byteLength+65535>>>16),ds();var R=1;break e}catch{}R=void 0}if(R)return!0}return!1},z:function(o,c){var h=0;return Fo().forEach(function(g,O){var R=c+h;for(O=ke[o+4*O>>2]=R,R=0;R>0]=g.charCodeAt(R);me[O>>0]=0,h+=g.length+1}),0},A:function(o,c){var h=Fo();ke[o>>2]=h.length;var g=0;return h.forEach(function(O){g+=O.length+1}),ke[c>>2]=g,0},f:function(o){try{var c=an(o);return Ve(c),0}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return h.Ka}},m:function(o,c){try{var h=an(o);return me[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 Q))throw g;return g.Ka}},u:function(o,c,h,g){try{e:{var O=an(o);o=c;for(var R=c=0;R>2],we=ke[o+4>>2];o+=8;var Pe=vi(O,me,F,we);if(0>Pe){var We=-1;break e}if(c+=Pe,Pe>2]=We,0}catch(ot){if(typeof Je>"u"||!(ot instanceof Q))throw ot;return ot.Ka}},k:function(o,c,h,g,O){try{if(c=h+2097152>>>0<4194305-!!c?(c>>>0)+4294967296*h:NaN,isNaN(c))return 61;var R=an(o);return Mr(R,c,g),V=[R.position>>>0,(U=R.position,1<=+Math.abs(U)?0>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],pe[O>>2]=V[0],pe[O+4>>2]=V[1],R.hb&&c===0&&g===0&&(R.hb=null),0}catch(F){if(typeof Je>"u"||!(F instanceof Q))throw F;return F.Ka}},C:function(o){try{var c=an(o);return c.Ha&&c.Ha.fsync?c.Ha.fsync(c):0}catch(h){if(typeof Je>"u"||!(h instanceof Q))throw h;return h.Ka}},r:function(o,c,h,g){try{e:{var O=an(o);o=c;for(var R=c=0;R>2],we=ke[o+4>>2];o+=8;var Pe=ar(O,me,F,we);if(0>Pe){var We=-1;break e}c+=Pe}We=c}return ke[g>>2]=We,0}catch(ot){if(typeof Je>"u"||!(ot instanceof Q))throw ot;return ot.Ka}}};(function(){function o(O){d.asm=O.exports,Ze=d.asm.I,ds(),wn=d.asm.Aa,fe.unshift(d.asm.J),$t--,d.monitorRunDependencies&&d.monitorRunDependencies($t),$t==0&&Ke&&(O=Ke,Ke=null,O())}function c(O){o(O.instance)}function h(O){return Z().then(function(R){return WebAssembly.instantiate(R,g)}).then(function(R){return R}).then(O,function(R){be("failed to asynchronously prepare wasm: "+R),x(R)})}var g={a:iu};if($t++,d.monitorRunDependencies&&d.monitorRunDependencies($t),d.instantiateWasm)try{return d.instantiateWasm(g,o)}catch(O){return be("Module.instantiateWasm callback failed with error: "+O),!1}return function(){return Ne||typeof WebAssembly.instantiateStreaming!="function"||C()||W.startsWith("file://")||se||typeof fetch!="function"?h(c):fetch(W,{credentials:"same-origin"}).then(function(O){return WebAssembly.instantiateStreaming(O,g).then(c,function(R){return be("wasm streaming compile failed: "+R),be("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 Qo=d.___errno_location=function(){return(Qo=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 Si=d._malloc=function(){return(Si=d._malloc=d.asm.ya).apply(null,arguments)},Ii=d._free=function(){return(Ii=d._free=d.asm.za).apply(null,arguments)};d._RegisterExtensionFunctions=function(){return(d._RegisterExtensionFunctions=d.asm.Ba).apply(null,arguments)};var $o=d._emscripten_builtin_memalign=function(){return($o=d._emscripten_builtin_memalign=d.asm.Ca).apply(null,arguments)},Ur=d.stackSave=function(){return(Ur=d.stackSave=d.asm.Da).apply(null,arguments)},Qr=d.stackRestore=function(){return(Qr=d.stackRestore=d.asm.Ea).apply(null,arguments)},Qn=d.stackAlloc=function(){return(Qn=d.stackAlloc=d.asm.Fa).apply(null,arguments)};d.UTF8ToString=$e,d.stackAlloc=Qn,d.stackSave=Ur,d.stackRestore=Qr,d.cwrap=function(o,c,h,g){h=h||[];var O=h.every(R=>R==="number"||R==="boolean");return c!=="string"&&O&&!g?d["_"+o]:function(){return ru(o,c,h,arguments)}};var Ti;Ke=function o(){Ti||jo(),Ti||(Ke=o)};function jo(){function o(){if(!Ti&&(Ti=!0,d.calledRun=!0,!He)){if(d.noFSInit||xi||(xi=!0,_i(),d.stdin=d.stdin,d.stdout=d.stdout,d.stderr=d.stderr,d.stdin?An("stdin",d.stdin):bs("/dev/tty","/dev/stdin"),d.stdout?An("stdout",null,d.stdout):bs("/dev/tty","/dev/stdout"),d.stderr?An("stderr",null,d.stderr):bs("/dev/tty1","/dev/stderr"),or("/dev/stdin",0),or("/dev/stdout",1),or("/dev/stderr",1)),ms=!1,ne(fe),d.onRuntimeInitialized&&d.onRuntimeInitialized(),d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;){var c=d.postRun.shift();Le.unshift(c)}ne(Le)}}if(!(0<$t)){if(d.preRun)for(typeof d.preRun=="function"&&(d.preRun=[d.preRun]);d.preRun.length;)Mn();ne(sn),0<$t||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1),o()},1)):o())}}if(d.preInit)for(typeof d.preInit=="function"&&(d.preInit=[d.preInit]);0=this._size)return 0;const r=this._data.subarray(e,Math.min(this._size,e+n.length));return n.set(r),r.length}reserve(e){if(this._data.length>=e)return;const n=e-this._data.length,r=Math.min(Bb,Math.max(Mb,this._data.length)),a=new Uint8Array(this._data.length+Math.max(r,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 Ub=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,Mf=new Promise((t,e)=>{const n=Ub.open(Lb,1);n.onupgradeneeded=()=>n.result.createObjectStore("files",{keyPath:"name"}),n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)});async function Qb(t){const e=await Mf,n=await new Promise((r,a)=>{const p=e.transaction("files","readonly").objectStore("files").get(t);p.onsuccess=()=>r(p.result),p.onerror=()=>a(p.error)});if(n&&!Fs.has(t)){const r=new Fb(n.data);return Fs.set(t,r),r}else return Fs.has(t)?Fs.get(t):null}async function $b(t,e){const n=await Mf;await new Promise((r,a)=>{const p=n.transaction("files","readwrite").objectStore("files").put({name:t,data:e});p.onsuccess=()=>r(!0),p.onerror=()=>a(p.error)})}async function Rh(t){const e=await Mf;await new Promise((n,r)=>{const l=e.transaction("files","readwrite").objectStore("files").delete(t);l.onsuccess=()=>n(!0),l.onerror=()=>r(l.error)})}async function jb(t,e){if(await $b(t,e),Fs.has(t)){const n=Fs.get(t);n.truncate(0),n.write(0,e)}}var jp=t=>t==null||typeof t=="bigint"||typeof t=="string"||typeof t=="number"||typeof t=="object"&&"buffer"in t?t:typeof t=="boolean"?`${t}`:t instanceof Date?t.toISOString():JSON.stringify(t),Vb=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,r)=>typeof r=="string"&&e.exec(r)?new Date(r):r)}catch{}}return t},zb=class extends Tf{constructor(e){super();ge(this,"serializer");this.serializer=e||jp}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:r,...a}=n,l=this.serializer(r);return r===l?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...a,value:l}})}transformValue(e){return{...e,value:this.serializer(e.value)}}},Hb=class{constructor({deserializer:t,serializer:e}={}){ge(this,"serializeParametersTransformer");ge(this,"deserializer");ge(this,"ctx");this.serializeParametersTransformer=new zb(e),this.deserializer=t||Vb,this.ctx=new WeakMap}transformQuery({node:t,queryId:e}){return t.kind==="SelectQueryNode"&&this.ctx.set(e,t.kind),this.serializeParametersTransformer.transformNode(t)}async parseResult(t){return await Promise.all(t.map(async e=>{const n={...e};for(const r in n)n[r]=await this.deserializer(n[r]);return n}))}async transformResult({result:t,queryId:e}){const{rows:n}=t,r=this.ctx.get(e);return this.ctx.delete(e),n&&r==="SelectQueryNode"?{...t,rows:await this.parseResult(n)}:t}};async function Dh(t,e,n,r,a="rowid"){await Cn` + create trigger if not exists ${Cn.raw(e)}_${Cn.raw(r)} + after ${Cn.raw(n)} + on ${Cn.table(e)} + begin + update ${Cn.table(e)} + set ${Cn.ref(r)} = datetime('now','localtime') + where ${Cn.ref(a)} = NEW.${Cn.ref(a)}; + end + `.execute(t).catch(l=>{console.error(l)})}function Kb(t){const e=new Map;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const r=t[n];e.set(n,r)}return e}async function Jb(t,e,n=!1){for(const[r,a]of e){const{columns:l,property:p}=a;n&&await t.schema.dropTable(r).ifExists().execute().catch();let w=t.schema.createTable(r);const{index:v,primary:d,timestamp:S,unique:B}=p||{};let j="rowid",te=!1;const se=typeof S=="object"&&S.create||"createAt",b=typeof S=="object"&&S.update||"updateAt";for(const[E,N]of Object.entries(l)){let A="text";const{type:I,notNull:X,defaultTo:de}=N;switch(I){case"boolean":case"date":case"object":case"string":A="text";break;case"increments":j=E;case"number":A="integer";break;case"blob":A="blob"}[se,b].includes(E)||(w=w.addColumn(E,A,oe=>I==="increments"?(te=!0,oe.autoIncrement().primaryKey()):(X&&(oe=oe.notNull()),de!==void 0&&(oe=oe.defaultTo(de instanceof Function?de(Cn):de)),oe)))}if(S&&(w=w.addColumn(se,"text").addColumn(b,"text")),!te&&d){const E=Array.isArray(d);j=E?d[0]:d,w=w.addPrimaryKeyConstraint(`pk_${E?d.join("_"):d}`,E?d:[d])}if(B==null||B.forEach(E=>{const N=Array.isArray(E);j=!d&&!te?N?E[0]:E:j,w=w.addUniqueConstraint(`un_${N?E.join("_"):E}`,N?E:[E])}),await w.ifNotExists().execute(),v)for(const E of v){const N=Array.isArray(E);await t.schema.createIndex(`idx_${N?E.join("_"):E}`).on(r).columns(N?E:[E]).ifNotExists().execute()}S&&(await Dh(t,r,"insert",se,j),await Dh(t,r,"update",b,j))}}function Gb(t){function e(n){return`__precomile_${n}`}return{setParam(n){let r;return(a,l)=>{if(!r){const{parameters:p,sql:w,query:v}=n(t,e).compile();r={sql:w,query:(l==null?void 0:l(v))||{kind:v.kind},parameters:p}}return{...r,parameters:r.parameters.map(p=>typeof p=="string"&&p.startsWith("__precomile_")?jp(a[p.slice(12)]):p)}}}}}var Yb=class{constructor(){ge(this,"items");this.items=[]}push(t){this.items.push(t)}pop(){return this.items.pop()}peek(){return this.items[this.items.length-1]}isEmpty(){return this.items.length===0}size(){return this.items.length}},Xb=class{constructor(t){ge(this,"kysely");ge(this,"status");ge(this,"tableMap");ge(this,"logger");ge(this,"trxs");const{dialect:e,tables:n,dropTableBeforeInit:r,onQuery:a,plugins:l,logger:p}=t;this.logger=p;const w=l??[];w.push(new Hb),this.kysely=new Ia({dialect:e,log:v=>{var d;v.level==="error"?(d=this.logger)==null||d.error("Uncaught DB Error",v.error):a==null||a(v.query,v.queryDurationMillis)},plugins:w}),this.status=r?0:1,this.tableMap=Kb(n),this.trxs=new Yb}async init(t=!1){const e=t||this.status===0;return await Jb(this.kysely,this.tableMap,e),this.status=2,this}async isEmptyTable(){var t;return this.status!==2&&await this.init(),this.status===2?!1:((t=this.logger)==null||t.error("fail to init table"),!0)}async transaction(t,e){if(!await this.isEmptyTable())return await this.kysely.transaction().execute(n=>(this.trxs.push(n),t(n))).catch(n=>{var r;e&&((r=this.logger)==null||r.error(e,n))}).finally(()=>{this.trxs.pop()})}getDB(){return this.trxs.isEmpty()?this.kysely:this.trxs.peek()}async exec(t,e){if(!await this.isEmptyTable())return t(this.getDB()).catch(n=>{var r;e&&((r=this.logger)==null||r.error(e,n))})}async execOne(t,e){const n=await this.execList(t,e);return n!=null&&n.length?n[0]:void 0}async execList(t,e){if(!await this.isEmptyTable())return t(this.getDB()).execute().catch(n=>{var r;e&&((r=this.logger)==null||r.error(e,n))})}preCompile(t){return Gb(t(this.kysely))}async execCompiledRows(t,e){const n=await this.execCompiled(t,e);return(n==null?void 0:n.rows)??void 0}async execCompiled(t,e){if(!await this.isEmptyTable())return this.getDB().executeQuery(t).catch(n=>{var r;e&&((r=this.logger)==null||r.error(e,n))})}async toSQL(t){return t(this.getDB()).compile()}async raw(t){if(!await this.isEmptyTable())return t(Cn).execute(this.getDB())}};async function Bf(t){const e=await new Xb({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(r=>r.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 Zb=new Cb({async database(){const t=await Db({locateFile:()=>Pb});return new t.Database(await Qb("sqljs"))},onWrite:{func(t){console.log(`[sqljs] write to indexeddb, length: ${t.length}`),jb("sqljs",t)},isThrottle:!0}});function eN(){const t=Hm();function e(){Bf(Zb).then(n=>{t.value=n})}return{result:t,run:e}}function tN(){return new Worker(""+new URL("sqljsWorker-05f9f7e1.js",import.meta.url).href)}function nN(){return new Worker(""+new URL("officialWasmWorker-18f6c592.js",import.meta.url).href)}const ze=0,rN=5,Nt=10,Vp=12,zp=14,Pi=21,vl=25,iN=27,Ph=100,sN=101,oN=3850,aN=522,uN=1,cN=2,Hp=4,lN=8,Rs=0,Ui=1,Bu=2,fN=3,Fu=4,hN=512,dN=1024,pN=2048,mN=16384,Lh=1,Mh=2,Bh=3,Fh=4,Uh=5,Qh=0x7fffffffffffffffn,$h=-0x8000000000000000n;class _r extends Error{constructor(e,n){super(e),this.code=n}}const Ws=!0;function yN(t){const e={},n=t._getSqliteFree(),r=t._malloc(8),a=[r,r+4];function l(b){if(typeof b!="string")return 0;const E=t.lengthBytesUTF8(b),N=t._sqlite3_malloc(E+1);return t.stringToUTF8(b,N,E+1),N}function p(b,E){return BigInt(E)<<32n|BigInt(b)&0xffffffffn}const w=function(){const b=BigInt(Number.MAX_SAFE_INTEGER)>>32n,E=BigInt(Number.MIN_SAFE_INTEGER)>>32n;return function(N,A){return A>b||A2147483647||I<-2147483648)return vl;const X=E(N,A,I);return se(b,X,S.get(N))}}(),e.bind_int64=function(){const b="sqlite3_bind_int64",E=t.cwrap(b,...Ee("nnnn:n"));return function(N,A,I){if(B(N),I>Qh||I<$h)return vl;const X=I&0xffffffffn,de=I>>32n,oe=E(N,A,Number(X),Number(de));return se(b,oe,S.get(N))}}(),e.bind_null=function(){const b="sqlite3_bind_null",E=t.cwrap(b,...Ee("nn:n"));return function(N,A){B(N);const I=E(N,A);return se(b,I,S.get(N))}}(),e.bind_parameter_name=function(){const b="sqlite3_bind_parameter_name",E=t.cwrap(b,...Ee("n:s"));return function(N,A){return B(N),E(N,A)}}(),e.bind_text=function(){const b="sqlite3_bind_text",E=t.cwrap(b,...Ee("nnnnn:n"));return function(N,A,I){B(N);const X=l(I),de=E(N,A,X,-1,n);return se(b,de,S.get(N))}}(),e.changes=function(){const b="sqlite3_changes",E=t.cwrap(b,...Ee("n:n"));return function(N){return d(N),E(N)}}(),e.close=function(){const b="sqlite3_close",E=t.cwrap(b,...Ee("n:n"),{async:Ws});return async function(N){d(N);const A=await E(N);return v.delete(N),se(b,A,N)}}(),e.column=function(b,E){B(b);const N=e.column_type(b,E);switch(N){case Fh:return e.column_blob(b,E);case Mh:return e.column_double(b,E);case Lh:const A=e.column_int(b,E),I=t.getTempRet0();return w(A,I);case Uh:return null;case Bh:return e.column_text(b,E);default:throw new _r("unknown type",N)}},e.column_blob=function(){const b="sqlite3_column_blob",E=t.cwrap(b,...Ee("nn:n"));return function(N,A){B(N);const I=e.column_bytes(N,A),X=E(N,A);return t.HEAPU8.subarray(X,X+I)}}(),e.column_bytes=function(){const b="sqlite3_column_bytes",E=t.cwrap(b,...Ee("nn:n"));return function(N,A){return B(N),E(N,A)}}(),e.column_count=function(){const b="sqlite3_column_count",E=t.cwrap(b,...Ee("n:n"));return function(N){return B(N),E(N)}}(),e.column_double=function(){const b="sqlite3_column_double",E=t.cwrap(b,...Ee("nn:n"));return function(N,A){return B(N),E(N,A)}}(),e.column_int=function(){const b="sqlite3_column_int64",E=t.cwrap(b,...Ee("nn:n"));return function(N,A){return B(N),E(N,A)}}(),e.column_int64=function(){const b="sqlite3_column_int64",E=t.cwrap(b,...Ee("nn:n"));return function(N,A){B(N);const I=E(N,A),X=t.getTempRet0();return p(I,X)}}(),e.column_name=function(){const b="sqlite3_column_name",E=t.cwrap(b,...Ee("nn:s"));return function(N,A){return B(N),E(N,A)}}(),e.column_names=function(b){const E=[],N=e.column_count(b);for(let A=0;AQh||A<$h)return vl;const I=A&0xffffffffn,X=A>>32n;E(N,Number(I),Number(X))}}(),e.result_null=function(){const b="sqlite3_result_null",E=t.cwrap(b,...Ee("n:n"));return function(N){E(N)}}(),e.result_text=function(){const b="sqlite3_result_text",E=t.cwrap(b,...Ee("nnnn:n"));return function(N,A){const I=l(A);E(N,I,-1,n)}}(),e.row=function(b){const E=[],N=e.data_count(b);for(let A=0;A{var t=import.meta.url;return function(e={}){var n;n||(n=typeof e<"u"?e:{});var r,a;n.ready=new Promise((s,u)=>{r=s,a=u});var l=Object.assign({},n),p="./this.program",w=(s,u)=>{throw u},v=typeof window=="object",d=typeof importScripts=="function",S="",B;(v||d)&&(d?S=self.location.href:typeof document<"u"&&document.currentScript&&(S=document.currentScript.src),t&&(S=t),S.indexOf("blob:")!==0?S=S.substr(0,S.replace(/[?#].*/,"").lastIndexOf("/")+1):S="",d&&(B=s=>{var u=new XMLHttpRequest;return u.open("GET",s,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}));var j=n.print||console.log.bind(console),te=n.printErr||console.warn.bind(console);Object.assign(n,l),l=null,n.thisProgram&&(p=n.thisProgram),n.quit&&(w=n.quit);var se;n.wasmBinary&&(se=n.wasmBinary);var b=n.noExitRuntime||!0;typeof WebAssembly!="object"&&st("no native wasm support detected");var E,N=!1,A,I,X,de,oe,be,Ne,Ze;function He(){var s=E.buffer;n.HEAP8=I=new Int8Array(s),n.HEAP16=de=new Int16Array(s),n.HEAP32=oe=new Int32Array(s),n.HEAPU8=X=new Uint8Array(s),n.HEAPU16=new Uint16Array(s),n.HEAPU32=be=new Uint32Array(s),n.HEAPF32=Ne=new Float32Array(s),n.HEAPF64=Ze=new Float64Array(s)}var Ot=[],Et=[],$e=[],Qt=[],rn=0;function ht(){var s=n.preRun.shift();Ot.unshift(s)}var me=0,qe=null;function st(s){throw n.onAbort&&n.onAbort(s),s="Aborted("+s+")",te(s),N=!0,A=1,s=new WebAssembly.RuntimeError(s+". Build with -sASSERTIONS for more info."),a(s),s}function pe(s){return s.startsWith("data:application/octet-stream;base64,")}var ke;if(n.locateFile){if(ke="wa-sqlite-async.wasm",!pe(ke)){var Wt=ke;ke=n.locateFile?n.locateFile(Wt,S):S+Wt}}else ke=new URL(""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,self.location).href;function br(s){try{if(s==ke&&se)return new Uint8Array(se);if(B)return B(s);throw"both async and sync fetching of the wasm failed"}catch(u){st(u)}}function ds(s){return se||!v&&!d||typeof fetch!="function"?Promise.resolve().then(()=>br(s)):fetch(s,{credentials:"same-origin"}).then(u=>{if(!u.ok)throw"failed to load wasm binary file at '"+s+"'";return u.arrayBuffer()}).catch(()=>br(s))}function wn(s,u,f){return ds(s).then(y=>WebAssembly.instantiate(y,u)).then(y=>y).then(f,y=>{te("failed to asynchronously prepare wasm: "+y),st(y)})}function sn(s,u){var f=ke;return se||typeof WebAssembly.instantiateStreaming!="function"||pe(f)||typeof fetch!="function"?wn(f,s,u):fetch(f,{credentials:"same-origin"}).then(y=>WebAssembly.instantiateStreaming(y,s).then(u,function(_){return te("wasm streaming compile failed: "+_),te("falling back to ArrayBuffer instantiation"),wn(f,s,u)}))}var fe,Le;function Mn(s){this.name="ExitStatus",this.message="Program terminated with exit("+s+")",this.status=s}function $t(s){for(;0>0];case"i8":return I[s>>0];case"i16":return de[s>>1];case"i32":return oe[s>>2];case"i64":return oe[s>>2];case"float":return Ne[s>>2];case"double":return Ze[s>>3];case"*":return be[s>>2];default:st("invalid type for getValue: "+u)}}function x(s,u,f="i8"){switch(f.endsWith("*")&&(f="*"),f){case"i1":I[s>>0]=u;break;case"i8":I[s>>0]=u;break;case"i16":de[s>>1]=u;break;case"i32":oe[s>>2]=u;break;case"i64":Le=[u>>>0,(fe=u,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],oe[s>>2]=Le[0],oe[s+4>>2]=Le[1];break;case"float":Ne[s>>2]=u;break;case"double":Ze[s>>3]=u;break;case"*":be[s>>2]=u;break;default:st("invalid type for setValue: "+f)}}var C=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function W(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?W(X,s,u):""}var H=(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},Z=s=>{var u=s.charAt(0)==="/",f=s.substr(-1)==="/";return(s=H(s.split("/").filter(y=>!!y),!u).join("/"))||u||(s="."),s&&f&&(s+="/"),(u?"/":"")+s},U=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=Z(s),s=s.replace(/\/$/,"");var u=s.lastIndexOf("/");return u===-1?s:s.substr(u+1)};function ne(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return s=>crypto.getRandomValues(s);st("initRandomDevice")}function K(s){return(K=ne())(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=H(s.split("/").filter(y=>!!y),!u).join("/"),(u?"/":"")+s||"."}function ae(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=T){var $=s.charCodeAt(++k);T=65536+((T&1023)<<10)|$&1023}if(127>=T){if(f>=y)break;u[f++]=T}else{if(2047>=T){if(f+1>=y)break;u[f++]=192|T>>6}else{if(65535>=T){if(f+2>=y)break;u[f++]=224|T>>12}else{if(f+3>=y)break;u[f++]=240|T>>18,u[f++]=128|T>>12&63}u[f++]=128|T>>6&63}u[f++]=128|T&63}}return u[f]=0,f-_}var ye=[];function Oe(s,u){ye[s]={input:[],Rb:[],bc:u},ws(s,je)}var je={open:function(s){var u=ye[s.node.ec];if(!u)throw new ee(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 ee(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 ee(28);return u},vc:function(s,u,f){he.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 ee(43);if(s=s.node.Nb,_&2||s.buffer!==I.buffer){if((0{if(s=ce(s),!s)return{path:"",node:null};if(u=Object.assign({yc:!0,tc:0},u),8!!T);for(var f=gn,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}},ms=(s,u)=>{for(var f=0,y=0;y>>0)%le.length},Q=s=>{var u=ms(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}},Bn=(s,u)=>{var f;if(f=(f=Nr(s,"x"))?f:s.Cb.cc?0:2)throw new ee(f,s);for(f=le[ms(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)},Dt=(s,u,f,y)=>(s=new hu(s,u,f,y),u=ms(s.parent.id,s.name),s.ac=le[u],le[u]=s),yi={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},ys=s=>{var u=["r","w","rw"][s&3];return s&512&&(u+="w"),u},Nr=(s,u)=>{if(Rt)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},sr=(s,u)=>{try{return Bn(s,u),20}catch{}return Nr(s,"wx")},Io=(s,u,f)=>{try{var y=Bn(s,u)}catch(_){return _.Ob}if(s=Nr(s,"wx"))return s;if(f){if((y.mode&61440)!==16384)return 54;if(y===y.parent||bn(y)==="/")return 10}else if((y.mode&61440)===16384)return 31;return 0},il=(s=0)=>{for(;4096>=s;s++)if(!jt[s])return s;throw new ee(33)},To=(s,u)=>(Mr||(Mr=function(){this.hc={}},Mr.prototype={},Object.defineProperties(Mr.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 Mr,s),u=il(u),s.Wb=u,jt[u]=s),Dr={open:s=>{s.Mb=mi[s.node.ec].Mb,s.Mb.open&&s.Mb.open(s)},Zb:()=>{throw new ee(70)}},ws=(s,u)=>{mi[s]={Mb:u}},ko=(s,u)=>{var f=u==="/",y=!u;if(f&&gn)throw new ee(10);if(!f&&!y){var _=Vt(u,{yc:!1});if(u=_.path,_=_.node,_.$b)throw new ee(10);if((_.mode&61440)!==16384)throw new ee(54)}u={type:s,Wc:{},Ac:u,Mc:[]},s=s.Ub(u),s.Ub=u,u.root=s,f?gn=s:_&&(_.$b=u,_.Ub&&_.Ub.Mc.push(u))},Wo=(s,u,f)=>{var y=Vt(s,{parent:!0}).node;if(s=V(s),!s||s==="."||s==="..")throw new ee(28);var _=sr(y,s);if(_)throw new ee(_);if(!y.Cb.jc)throw new ee(63);return y.Cb.jc(y,s,u,f)},Nn=(s,u)=>Wo(s,(u!==void 0?u:511)&1023|16384,0),gs=(s,u,f)=>{typeof f>"u"&&(f=u,u=438),Wo(s,u|8192,f)},wi=(s,u)=>{if(!ce(s))throw new ee(44);var f=Vt(u,{parent:!0}).node;if(!f)throw new ee(44);u=V(u);var y=sr(f,u);if(y)throw new ee(y);if(!f.Cb.nc)throw new ee(63);f.Cb.nc(f,u,s)},Ro=s=>{var u=Vt(s,{parent:!0}).node;s=V(s);var f=Bn(u,s),y=Io(u,s,!0);if(y)throw new ee(y);if(!u.Cb.mc)throw new ee(63);if(f.$b)throw new ee(10);u.Cb.mc(u,s),Q(f)},gi=s=>{if(s=Vt(s).node,!s)throw new ee(44);if(!s.Cb.fc)throw new ee(28);return ce(bn(s.parent),s.Cb.fc(s))},Yt=(s,u)=>{if(s=Vt(s,{Yb:!u}).node,!s)throw new ee(44);if(!s.Cb.Tb)throw new ee(63);return s.Cb.Tb(s)},bi=s=>Yt(s,!0),bs=(s,u)=>{if(s=typeof s=="string"?Vt(s,{Yb:!0}).node:s,!s.Cb.Qb)throw new ee(63);s.Cb.Qb(s,{mode:u&4095|s.mode&-4096,timestamp:Date.now()})},Do=(s,u)=>{if(0>u)throw new ee(28);if(s=typeof s=="string"?Vt(s,{Yb:!0}).node:s,!s.Cb.Qb)throw new ee(63);if((s.mode&61440)===16384)throw new ee(31);if((s.mode&61440)!==32768)throw new ee(28);var f=Nr(s,"w");if(f)throw new ee(f);s.Cb.Qb(s,{size:u,timestamp:Date.now()})},Ni=(s,u,f)=>{if(s==="")throw new ee(44);if(typeof u=="string"){var y=yi[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=Z(s);try{_=Vt(s,{Yb:!(u&131072)}).node}catch{}}if(y=!1,u&64)if(_){if(u&128)throw new ee(20)}else _=Wo(s,f,0),y=!0;if(!_)throw new ee(44);if((_.mode&61440)===8192&&(u&=-513),u&65536&&(_.mode&61440)!==16384)throw new ee(54);if(!y&&(f=_?(_.mode&61440)===40960?32:(_.mode&61440)===16384&&(ys(u)!=="r"||u&512)?31:Nr(_,ys(u)):44))throw new ee(f);return u&512&&!y&&Do(_,0),u&=-131713,_=To({node:_,path:bn(_),flags:u,seekable:!0,position:0,Mb:_.Mb,Tc:[],error:!1}),_.Mb.open&&_.Mb.open(_),!n.logReadFiles||u&1||(vi||(vi={}),s in vi||(vi[s]=1)),_},Po=(s,u,f)=>{if(s.Wb===null)throw new ee(8);if(!s.seekable||!s.Mb.Zb)throw new ee(70);if(f!=0&&f!=1&&f!=2)throw new ee(28);s.position=s.Mb.Zb(s,u,f),s.Tc=[]},Pr=()=>{ee||(ee=function(s,u){this.name="ErrnoError",this.node=u,this.Rc=function(f){this.Ob=f},this.Rc(s),this.message="FS error"},ee.prototype=Error(),ee.prototype.constructor=ee,[44].forEach(s=>{qn[s]=new ee(s),qn[s].stack=""}))},Lo,Ns=(s,u)=>{var f=0;return s&&(f|=365),u&&(f|=146),f},Lr=(s,u,f)=>{s=Z("/dev/"+s);var y=Ns(!!u,!!f);or||(or=64);var _=or++<<8|0;ws(_,{open:k=>{k.seekable=!1},close:()=>{f&&f.buffer&&f.buffer.length&&f(10)},read:(k,T,$,P)=>{for(var M=0,re=0;re{for(var M=0;M>2]=y.Ic,oe[f+8>>2]=y.qc,oe[f+12>>2]=y.mode,be[f+16>>2]=y.Oc,oe[f+20>>2]=y.uid,oe[f+24>>2]=y.Lc,oe[f+28>>2]=y.ec,Le=[y.size>>>0,(fe=y.size,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],oe[f+40>>2]=Le[0],oe[f+44>>2]=Le[1],oe[f+48>>2]=4096,oe[f+52>>2]=y.Gc,s=y.Ec.getTime(),u=y.Nc.getTime();var _=y.Hc.getTime();return Le=[Math.floor(s/1e3)>>>0,(fe=Math.floor(s/1e3),1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],oe[f+56>>2]=Le[0],oe[f+60>>2]=Le[1],be[f+64>>2]=s%1e3*1e3,Le=[Math.floor(u/1e3)>>>0,(fe=Math.floor(u/1e3),1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],oe[f+72>>2]=Le[0],oe[f+76>>2]=Le[1],be[f+80>>2]=u%1e3*1e3,Le=[Math.floor(_/1e3)>>>0,(fe=Math.floor(_/1e3),1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],oe[f+88>>2]=Le[0],oe[f+92>>2]=Le[1],be[f+96>>2]=_%1e3*1e3,Le=[y.qc>>>0,(fe=y.qc,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],oe[f+104>>2]=Le[0],oe[f+108>>2]=Le[1],0}var _i=void 0;function xi(){return _i+=4,oe[_i-4>>2]}function on(s){if(s=jt[s],!s)throw new ee(8);return s}function An(s,u,f){return ue(s,X,u,f)}function Oi(s){return be[s>>2]+4294967296*oe[s+4>>2]}var Je=[0,31,60,91,121,152,182,213,244,274,305,335],Ei=[0,31,59,90,120,151,181,212,243,273,304,334];function Ci(s){var u=ae(s)+1,f=Jo(u);return f&&An(s,f,u),f}var Fn={};function qi(){if(!Br){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",_:p||"./this.program"},u;for(u in Fn)Fn[u]===void 0?delete s[u]:s[u]=Fn[u];var f=[];for(u in s)f.push(u+"="+s[u]);Br=f}return Br}var Br;function Ai(){}function an(){}function _s(){}function Mo(){}function nu(){}function xs(){}function Bo(){}function Os(){}function Fo(){}function Es(){}function Un(){}function Cs(){}function qs(){}function Fr(){}function As(){}function ru(){}function Uo(){}function iu(){}function Qo(){}function Si(){}function Ii(){}function $o(){}function Ur(){}function Qr(){}function Qn(){}function Ti(){}function jo(){}function o(){}function c(){}function h(){}function g(){}function O(){}function R(){}function F(){}function we(){}function Pe(){}function We(){}function ot(){}function Sn(){}function Vo(s){A=s,b||0{Ho={resolve:s,reject:u}})}function ul(){var s=Jo(12300),u=s+12;oe[s>>2]=u,oe[s+4>>2]=u+12288,u=Ss[0];var f=ou[u];return f===void 0&&(f=ol++,ou[u]=f,au[f]=u),oe[s+8>>2]=f,s}function cu(s){if(!N){if($n===0){var u=!1,f=!1;s((y=0)=>{if(!N&&(su=y,u=!0,f)){$n=2,ki(()=>Wi(In)),y=!1;try{var _=(0,n.asm[au[oe[In+8>>2]]])()}catch($){_=$,y=!0}var k=!1;if(!In){var T=Ho;T&&(Ho=null,(y?T.reject:T.resolve)(_),k=!0)}if(y&&!k)throw _}}),f=!0,u||($n=1,In=ul(),ki(()=>gu(In)))}else $n===2?($n=0,ki(Xo),du(In),In=null,al.forEach(y=>{if(!N)try{if(y(),!(b||0{s().then(u)})}var fu={};function Tn(s,u,f,y,_){function k(G){return--rn,P!==0&&Go(P),u==="string"?L(G):u==="boolean"?!!G:G}var T={string:G=>{var ie=0;if(G!=null&&G!==0){ie=ae(G)+1;var Se=Yo(ie);An(G,Se,ie),ie=Se}return ie},array:G=>{var ie=Yo(G.length);return I.set(G,ie),ie}};s=n["_"+s];var $=[],P=0;if(y)for(var M=0;M{Nn("/dev"),ws(259,{read:()=>0,write:(y,_,k,T)=>T}),gs("/dev/null",259),Oe(1280,De),Oe(1536,rt),gs("/dev/tty",1280),gs("/dev/tty1",1536);var s=new Uint8Array(1024),u=0,f=()=>(u===0&&(u=K(s).byteLength),s[--u]);Lr("random",f),Lr("urandom",f),Nn("/dev/shm"),Nn("/dev/shm/tmp")})(),(()=>{Nn("/proc");var s=Nn("/proc/self");Nn("/proc/self/fd"),ko({Ub:()=>{var u=Dt(s,"fd",16895,73);return u.Cb={cc:(f,y)=>{var _=jt[+y];if(!_)throw new ee(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),Tn("set_authorizer","number",["number"],[u])},Ai=function(u,f,y,_,k,T){if(s.has(u)){const{f:$,uc:P}=s.get(u);return $(P,f,y?L(y):null,_?L(_):null,k?L(k):null,T?L(T):null)}return 0}}(),function(){const s=new Map,u=new Map;n.createFunction=function(f,y,_,k,T,$){const P=s.size;return s.set(P,{f:$,Xb:T}),Tn("create_function","number","number string number number number number".split(" "),[f,y,_,k,P,0])},n.createAggregate=function(f,y,_,k,T,$,P){const M=s.size;return s.set(M,{step:$,Jc:P,Xb:T}),Tn("create_function","number","number string number number number number".split(" "),[f,y,_,k,M,1])},n.getFunctionUserData=function(f){return u.get(f)},_s=function(f,y,_,k){f=s.get(f),u.set(y,f.Xb),f.f(y,new Uint32Array(X.buffer,k,_)),u.delete(y)},nu=function(f,y,_,k){f=s.get(f),u.set(y,f.Xb),f.step(y,new Uint32Array(X.buffer,k,_)),u.delete(y)},an=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),Tn("progress_handler",null,["number","number"],[u,f])},Mo=function(u){if(s.has(u)){const{f,uc:y}=s.get(u);return f(y)}return 0}}(),function(){function s(P,M){const re=`get${P}`,G=`set${P}`;return new Proxy(new DataView(X.buffer,M,P==="Int32"?4:8),{get(ie,Se){if(Se===re)return function(Ge,At){if(!At)throw Error("must be little endian");return ie[Se](Ge,At)};if(Se===G)return function(Ge,At,wt){if(!wt)throw Error("must be little endian");return ie[Se](Ge,At,wt)};if(typeof Se=="string"&&Se.match(/^(get)|(set)/))throw Error("invalid type");return ie[Se]}})}const u=typeof fu=="object",f=new Map,y=new Map,_=new Map,k=u?new Set:null,T=u?new Set:null,$=new Map;$o=function(P,M,re,G){$.set(L(P),{size:M,dc:Array.from(new Uint32Array(X.buffer,G,re))})},n.createModule=function(P,M,re,G){u&&(re.handleAsync=lu);const ie=f.size;return f.set(ie,{module:re,Xb:G}),G=0,re.xCreate&&(G|=1),re.xConnect&&(G|=2),re.xBestIndex&&(G|=4),re.xDisconnect&&(G|=8),re.xDestroy&&(G|=16),re.xOpen&&(G|=32),re.xClose&&(G|=64),re.xFilter&&(G|=128),re.xNext&&(G|=256),re.xEof&&(G|=512),re.xColumn&&(G|=1024),re.xRowid&&(G|=2048),re.xUpdate&&(G|=4096),re.xBegin&&(G|=8192),re.xSync&&(G|=16384),re.xCommit&&(G|=32768),re.xRollback&&(G|=65536),re.xFindFunction&&(G|=131072),re.xRename&&(G|=262144),Tn("create_module","number",["number","string","number","number"],[P,M,ie,G])},Cs=function(P,M,re,G,ie,Se){if(M=f.get(M),y.set(ie,M),u){k.delete(ie);for(const Ge of k)y.delete(Ge)}return G=Array.from(new Uint32Array(X.buffer,G,re)).map(Ge=>L(Ge)),M.module.xCreate(P,M.Xb,G,ie,s("Int32",Se))},Un=function(P,M,re,G,ie,Se){if(M=f.get(M),y.set(ie,M),u){k.delete(ie);for(const Ge of k)y.delete(Ge)}return G=Array.from(new Uint32Array(X.buffer,G,re)).map(Ge=>L(Ge)),M.module.xConnect(P,M.Xb,G,ie,s("Int32",Se))},Bo=function(P,M){var re=y.get(P),G=$.get("sqlite3_index_info").dc;const ie={};ie.nConstraint=Ke(M+G[0],"i32"),ie.aConstraint=[];for(var Se=Ke(M+G[1],"*"),Ge=$.get("sqlite3_index_constraint").size,At=0;At>=2,be[T]+be[T+1]*2**32}const f=typeof fu=="object",y=new Map,_=new Map;n.registerVFS=function(T,$){if(Tn("sqlite3_vfs_find","number",["string"],[T.name]))throw Error(`VFS '${T.name}' already registered`);f&&(T.handleAsync=lu);var P=T.Vc??64;const M=n._malloc(4);return $=Tn("register_vfs","number",["string","number","number","number"],[T.name,P,$?1:0,M]),$||(P=Ke(M,"*"),y.set(P,T)),n._free(M),$};const k=f?new Set:null;jo=function(T){const $=_.get(T);return f?k.add(T):_.delete(T),$.xClose(T)},F=function(T,$,P,M){return _.get(T).xRead(T,X.subarray($,$+P),u(M))},Sn=function(T,$,P,M){return _.get(T).xWrite(T,X.subarray($,$+P),u(M))},We=function(T,$){return _.get(T).xTruncate(T,u($))},Pe=function(T,$){return _.get(T).xSync(T,$)},g=function(T,$){const P=_.get(T);return $=s("BigInt64",$),P.xFileSize(T,$)},O=function(T,$){return _.get(T).xLock(T,$)},ot=function(T,$){return _.get(T).xUnlock(T,$)},Ti=function(T,$){const P=_.get(T);return $=s("Int32",$),P.xCheckReservedLock(T,$)},h=function(T,$,P){const M=_.get(T);return P=new DataView(X.buffer,P),M.xFileControl(T,$,P)},we=function(T){return _.get(T).xSectorSize(T)},c=function(T){return _.get(T).xDeviceCharacteristics(T)},R=function(T,$,P,M,re){if(T=y.get(T),_.set(P,T),f){k.delete(P);for(var G of k)_.delete(G)}if(G=null,M&64){G=1;const ie=[];for(;G;){const Se=X[$++];if(Se)ie.push(Se);else switch(X[$]||(G=null),G){case 1:ie.push(63),G=2;break;case 2:ie.push(61),G=3;break;case 3:ie.push(38),G=2}}G=new TextDecoder().decode(new Uint8Array(ie))}else $&&(G=L($));return re=s("Int32",re),T.xOpen(G,P,M,re)},o=function(T,$,P){return y.get(T).xDelete(L($),P)},Qn=function(T,$,P,M){return T=y.get(T),M=s("Int32",M),T.xAccess(L($),P,M)}}();var cl={a:function(s,u,f,y){st("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),bs(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=ar(s,u),f&-8)return-28;var y=Vt(u,{Yb:!0}).node;return y?(s="",f&4&&(s+="r"),f&2&&(s+="w"),f&1&&(s+="x"),s&&Nr(y,s)?-2:0):-44}catch(_){if(typeof Ve>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},L:function(s,u){try{var f=jt[s];if(!f)throw new ee(8);return bs(f.node,u),0}catch(y){if(typeof Ve>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},J:function(s){try{var u=jt[s];if(!u)throw new ee(8);var f=u.node,y=typeof f=="string"?Vt(f,{Yb:!0}).node:f;if(!y.Cb.Qb)throw new ee(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){_i=f;try{var y=on(s);switch(u){case 0:var _=xi();return 0>_?-28:To(y,_).Wb;case 1:case 2:return 0;case 3:return y.flags;case 4:return _=xi(),y.flags|=_,0;case 5:return _=xi(),de[_+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return oe[Ko()>>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=on(s);return vs(Yt,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=jt[s];if(!y)throw new ee(8);if(!(y.flags&2097155))throw new ee(28);return Do(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=ae("/")+1;return u"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},F:function(s,u){try{return s=L(s),vs(bi,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=ar(s,u),u=Z(u),u[u.length-1]==="/"&&(u=u.substr(0,u.length-1)),Nn(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=ar(s,u,y&4096),vs(_?bi:Yt,u,f)}catch(k){if(typeof Ve>"u"||k.name!=="ErrnoError")throw k;return-k.Ob}},u:function(s,u,f,y){_i=y;try{u=L(u),u=ar(s,u);var _=y?xi():0;return Ni(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=ar(s,u),0>=y)return-28;var _=gi(u),k=Math.min(y,ae(_)),T=I[f+k];return An(_,f,y+1),I[f+k]=T,k}catch($){if(typeof Ve>"u"||$.name!=="ErrnoError")throw $;return-$.Ob}},r:function(s){try{return s=L(s),Ro(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),vs(Yt,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=ar(s,u),f===0){s=u;var y=Vt(s,{parent:!0}).node;if(!y)throw new ee(44);var _=V(s),k=Bn(y,_),T=Io(y,_,!1);if(T)throw new ee(T);if(!y.Cb.oc)throw new ee(63);if(k.$b)throw new ee(10);y.Cb.oc(y,_),Q(k)}else f===512?Ro(u):st("Invalid flags passed to unlinkat");return 0}catch($){if(typeof Ve>"u"||$.name!=="ErrnoError")throw $;return-$.Ob}},n:function(s,u,f){try{if(u=L(u),u=ar(s,u,!0),f){var y=Oi(f),_=oe[f+8>>2];k=1e3*y+_/1e6,f+=16,y=Oi(f),_=oe[f+8>>2],T=1e3*y+_/1e6}else var k=Date.now(),T=k;s=k;var $=Vt(u,{Yb:!0}).node;return $.Cb.Qb($,{timestamp:Math.max(s,T)}),0}catch(P){if(typeof Ve>"u"||P.name!=="ErrnoError")throw P;return-P.Ob}},y:function(s,u){s=new Date(1e3*Oi(s)),oe[u>>2]=s.getSeconds(),oe[u+4>>2]=s.getMinutes(),oe[u+8>>2]=s.getHours(),oe[u+12>>2]=s.getDate(),oe[u+16>>2]=s.getMonth(),oe[u+20>>2]=s.getFullYear()-1900,oe[u+24>>2]=s.getDay();var f=s.getFullYear();oe[u+28>>2]=(f%4!==0||f%100===0&&f%400!==0?Ei:Je)[s.getMonth()]+s.getDate()-1|0,oe[u+36>>2]=-(60*s.getTimezoneOffset()),f=new Date(s.getFullYear(),6,1).getTimezoneOffset();var y=new Date(s.getFullYear(),0,1).getTimezoneOffset();oe[u+32>>2]=(f!=y&&s.getTimezoneOffset()==Math.min(y,f))|0},w:function(s,u,f,y,_,k,T){try{var $=on(y);if(u&2&&!(f&2)&&($.flags&2097155)!==2)throw new ee(2);if(($.flags&2097155)===1)throw new ee(2);if(!$.Mb.kc)throw new ee(43);var P=$.Mb.kc($,s,_,u,f),M=P.Pc;return oe[k>>2]=P.Dc,be[T>>2]=M,0}catch(re){if(typeof Ve>"u"||re.name!=="ErrnoError")throw re;return-re.Ob}},x:function(s,u,f,y,_,k){try{var T=on(_);if(f&2){if((T.node.mode&61440)!==32768)throw new ee(43);y&2||T.Mb.lc&&T.Mb.lc(T,X.slice(s,s+u),k,u,y)}}catch($){if(typeof Ve>"u"||$.name!=="ErrnoError")throw $;return-$.Ob}},p:function(s,u,f){function y(P){return(P=P.toTimeString().match(/\(([A-Za-z ]+)\)$/))?P[1]:"GMT"}var _=new Date().getFullYear(),k=new Date(_,0,1),T=new Date(_,6,1);_=k.getTimezoneOffset();var $=T.getTimezoneOffset();be[s>>2]=60*Math.max(_,$),oe[u>>2]=+(_!=$),s=y(k),u=y(T),s=Ci(s),u=Ci(u),$<_?(be[f>>2]=s,be[f+4>>2]=u):(be[f>>2]=u,be[f+4>>2]=s)},e:function(){return Date.now()},d:()=>performance.now(),l:function(s){var u=X.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 T=E.buffer;try{E.grow(k.call(_,2147483648,y)-T.byteLength+65535>>>16),He();var $=1;break e}catch{}$=void 0}if($)return!0}return!1},A:function(s,u){var f=0;return qi().forEach(function(y,_){var k=u+f;for(_=be[s+4*_>>2]=k,k=0;k>0]=y.charCodeAt(k);I[_>>0]=0,f+=y.length+1}),0},B:function(s,u){var f=qi();be[s>>2]=f.length;var y=0;return f.forEach(function(_){y+=_.length+1}),be[u>>2]=y,0},f:function(s){try{var u=on(s);if(u.Wb===null)throw new ee(8);u.pc&&(u.pc=null);try{u.Mb.close&&u.Mb.close(u)}catch(f){throw f}finally{jt[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=on(s);return I[u>>0]=f.Sb?2:(f.mode&61440)===16384?3:(f.mode&61440)===40960?7:4,de[u+2>>1]=0,Le=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],oe[u+8>>2]=Le[0],oe[u+12>>2]=Le[1],Le=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],oe[u+16>>2]=Le[0],oe[u+20>>2]=Le[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 _=on(s);s=u;for(var k,T=u=0;T>2],P=be[s+4>>2];s+=8;var M=_,re=$,G=P,ie=k,Se=I;if(0>G||0>ie)throw new ee(28);if(M.Wb===null)throw new ee(8);if((M.flags&2097155)===1)throw new ee(8);if((M.node.mode&61440)===16384)throw new ee(31);if(!M.Mb.read)throw new ee(28);var Ge=typeof ie<"u";if(!Ge)ie=M.position;else if(!M.seekable)throw new ee(70);var At=M.Mb.read(M,Se,re,G,ie);Ge||(M.position+=At);var wt=At;if(0>wt){var un=-1;break e}if(u+=wt,wt>2]=un,0}catch(Pt){if(typeof Ve>"u"||Pt.name!=="ErrnoError")throw Pt;return Pt.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=on(s);return Po(k,u,y),Le=[k.position>>>0,(fe=k.position,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],oe[_>>2]=Le[0],oe[_+4>>2]=Le[1],k.pc&&u===0&&y===0&&(k.pc=null),0}catch(T){if(typeof Ve>"u"||T.name!=="ErrnoError")throw T;return T.Ob}},D:function(s){try{var u=on(s);return cu(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 _=on(s);s=u;for(var k,T=u=0;T>2],P=be[s+4>>2];s+=8;var M=_,re=$,G=P,ie=k,Se=I;if(0>G||0>ie)throw new ee(28);if(M.Wb===null)throw new ee(8);if(!(M.flags&2097155))throw new ee(8);if((M.node.mode&61440)===16384)throw new ee(31);if(!M.Mb.write)throw new ee(28);M.seekable&&M.flags&1024&&Po(M,0,2);var Ge=typeof ie<"u";if(!Ge)ie=M.position;else if(!M.seekable)throw new ee(70);var At=M.Mb.write(M,Se,re,G,ie,void 0);Ge||(M.position+=At);var wt=At;if(0>wt){var un=-1;break e}u+=wt,typeof k<"u"&&(k+=wt)}un=u}return be[y>>2]=un,0}catch(Pt){if(typeof Ve>"u"||Pt.name!=="ErrnoError")throw Pt;return Pt.Ob}},ra:Ai,N:an,ga:_s,ca:Mo,Y:nu,la:xs,G:Bo,h:Os,oa:Fo,ja:Es,ea:Un,fa:Cs,k:qs,v:Fr,pa:As,g:ru,qa:Uo,da:iu,ha:Qo,ia:Si,na:Ii,c:$o,ka:Ur,ma:Qr,aa:Qn,V:Ti,$:jo,ba:o,S:c,U:h,Z:g,X:O,R,Q:F,T:we,_:Pe,O:We,W:ot,P:Sn};(function(){function s(f){if(f=f.exports,f=sl(f),n.asm=f,E=n.asm.sa,He(),Et.unshift(n.asm.ta),me--,n.monitorRunDependencies&&n.monitorRunDependencies(me),me==0&&qe){var y=qe;qe=null,y()}return f}var u={a:cl};if(me++,n.monitorRunDependencies&&n.monitorRunDependencies(me),n.instantiateWasm)try{return n.instantiateWasm(u,s)}catch(f){te("Module.instantiateWasm callback failed with error: "+f),a(f)}return sn(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 Ko(){return(Ko=n.asm.rb).apply(null,arguments)}var Jo=n._malloc=function(){return(Jo=n._malloc=n.asm.sb).apply(null,arguments)},du=n._free=function(){return(du=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 pu=n._main=function(){return(pu=n._main=n.asm.Bb).apply(null,arguments)};function mu(){return(mu=n.asm.Db).apply(null,arguments)}function yu(){return(yu=n.asm.Eb).apply(null,arguments)}function wu(){return(wu=n.asm.Fb).apply(null,arguments)}function Go(){return(Go=n.asm.Gb).apply(null,arguments)}function Yo(){return(Yo=n.asm.Hb).apply(null,arguments)}function gu(){return(gu=n.asm.Ib).apply(null,arguments)}function bu(){return(bu=n.asm.Jb).apply(null,arguments)}function Wi(){return(Wi=n.asm.Kb).apply(null,arguments)}function Xo(){return(Xo=n.asm.Lb).apply(null,arguments)}n.getTempRet0=yu,n.ccall=Tn,n.cwrap=function(s,u,f,y){var _=!f||f.every(k=>k==="number"||k==="boolean");return u!=="string"&&_&&!y?n["_"+s]:function(){return Tn(s,u,f,arguments,y)}},n.setValue=x,n.getValue=Ke,n.UTF8ToString=L,n.stringToUTF8=An,n.lengthBytesUTF8=ae;var Is;qe=function s(){Is||q(),Is||(qe=s)};function q(){function s(){if(!Is&&(Is=!0,n.calledRun=!0,!N)){if(n.noFSInit||Lo||(Lo=!0,Pr(),n.stdin=n.stdin,n.stdout=n.stdout,n.stderr=n.stderr,n.stdin?Lr("stdin",n.stdin):wi("/dev/tty","/dev/stdin"),n.stdout?Lr("stdout",null,n.stdout):wi("/dev/tty","/dev/stdout"),n.stderr?Lr("stderr",null,n.stderr):wi("/dev/tty1","/dev/stderr"),Ni("/dev/stdin",0),Ni("/dev/stdout",1),Ni("/dev/stderr",1)),Rt=!1,$t(Et),$t($e),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),J){var u=pu;try{var f=u(0,0);A=f,Vo(f)}catch(y){zo(y)}}if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)u=n.postRun.shift(),Qt.unshift(u);$t(Qt)}}if(!(0{try{await navigator.locks.request(e,n,l=>{if(r(l),l)return new Promise(p=>i(this,yo).set(e,p))})}catch(l){a(l)}})}_releaseWebLock(e){var n;(n=i(this,yo).get(e))==null||n(),i(this,yo).delete(e)}async _pollWebLock(e){var r;return(r=(await navigator.locks.query()).held.find(({name:a})=>a===e))==null?void 0:r.mode}_getTimeoutSignal(){if(this.timeoutMillis){const e=new AbortController;return setTimeout(()=>e.abort(),this.timeoutMillis),e.signal}}}Ft=new WeakMap,yo=new WeakMap,za=new WeakMap,Ha=new WeakSet,ef=async function(e,n){const r=n&bN;try{const a=()=>e.call(this,r);return await z(this,za,i(this,za).then(a,a)),z(this,Ft,r),ze}catch(a){return a.name==="AbortError"?rN:(console.error(a),oN)}},Pc=new WeakSet,Kp=async function(e){if(e===i(this,Ft))return ze;switch(i(this,Ft)){case Rs:switch(e){case Ui:return this._NONEtoSHARED();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}case Ui:switch(e){case Bu:return this._SHAREDtoRESERVED();case Fu:return this._SHAREDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}case Bu:switch(e){case Fu:return this._RESERVEDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}},Lc=new WeakSet,Jp=async function(e){if(e===i(this,Ft))return ze;switch(i(this,Ft)){case Fu:switch(e){case Ui:return this._EXCLUSIVEtoSHARED();case Rs:return this._EXCLUSIVEtoNONE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}case Bu:switch(e){case Ui:return this._RESERVEDtoSHARED();case Rs:return this._RESERVEDtoNONE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}case Ui:switch(e){case Rs:return this._SHAREDtoNONE();default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}default:throw new Error(`unexpected transition ${i(this,Ft)} -> ${e}`)}};class vN extends NN{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 _N=5e3;let xN=0;const _l=new WeakMap;function lr(...t){}var wo,go,Ka,Tt,Ja,bo,rs,Mc,Gp;class ON{constructor(e,n={durability:"default"}){D(this,Mc);D(this,wo,void 0);D(this,go,void 0);D(this,Ka,void 0);D(this,Tt,null);D(this,Ja,0);D(this,bo,Promise.resolve());D(this,rs,Promise.resolve());z(this,go,Promise.resolve(e).then(r=>z(this,wo,r))),z(this,Ka,n)}async close(){const e=i(this,wo)??await i(this,go);await i(this,bo),await this.sync(),e.close()}async run(e,n){const r=i(this,bo).then(()=>_e(this,Mc,Gp).call(this,e,n));return z(this,bo,r.catch(()=>{})),r}async sync(){await i(this,rs),z(this,rs,Promise.resolve())}}wo=new WeakMap,go=new WeakMap,Ka=new WeakMap,Tt=new WeakMap,Ja=new WeakMap,bo=new WeakMap,rs=new WeakMap,Mc=new WeakSet,Gp=async function(e,n){var a,l;const r=i(this,wo)??await i(this,go);if(e==="readwrite"&&((a=i(this,Tt))==null?void 0:a.mode)==="readonly")z(this,Tt,null);else if(performance.now()-i(this,Ja)>_N){try{(l=i(this,Tt))==null||l.commit()}catch(p){if(p.name!=="InvalidStateError")throw p}await new Promise(p=>setTimeout(p)),z(this,Tt,null)}for(let p=0;p<2;++p){if(!i(this,Tt)){z(this,Tt,r.transaction(r.objectStoreNames,e,i(this,Ka)));const w=z(this,Ja,performance.now());z(this,rs,i(this,rs).then(()=>new Promise((v,d)=>{i(this,Tt).addEventListener("complete",S=>{v(),i(this,Tt)===S.target&&z(this,Tt,null),lr(`transaction ${_l.get(S.target)} complete`)}),i(this,Tt).addEventListener("abort",S=>{console.warn("tx abort",(performance.now()-w)/1e3);const B=S.target.error;d(B),i(this,Tt)===S.target&&z(this,Tt,null),lr(`transaction ${_l.get(S.target)} aborted`,B)})}))),_l.set(i(this,Tt),xN++)}try{const w=Object.fromEntries(Array.from(r.objectStoreNames,v=>[v,new EN(i(this,Tt).objectStore(v))]));return await n(w)}catch(w){if(z(this,Tt,null),p)throw w}}};function zr(t){return new Promise((e,n)=>{t.addEventListener("success",()=>e(t.result)),t.addEventListener("error",()=>n(t.error))})}var qt;class EN{constructor(e){D(this,qt,void 0);z(this,qt,e)}get(e){lr(`get ${i(this,qt).name}`,e);const n=i(this,qt).get(e);return zr(n)}getAll(e,n){lr(`getAll ${i(this,qt).name}`,e,n);const r=i(this,qt).getAll(e,n);return zr(r)}getKey(e){lr(`getKey ${i(this,qt).name}`,e);const n=i(this,qt).getKey(e);return zr(n)}getAllKeys(e,n){lr(`getAllKeys ${i(this,qt).name}`,e,n);const r=i(this,qt).getAllKeys(e,n);return zr(r)}put(e,n){lr(`put ${i(this,qt).name}`,e,n);const r=i(this,qt).put(e,n);return zr(r)}delete(e){lr(`delete ${i(this,qt).name}`,e);const n=i(this,qt).delete(e);return zr(n)}clear(){lr(`clear ${i(this,qt).name}`);const e=i(this,qt).clear();return zr(e)}index(e){return new CN(i(this,qt).index(e))}}qt=new WeakMap;var is;class CN{constructor(e){D(this,is,void 0);z(this,is,e)}getAllKeys(e,n){lr(`IDBIndex.getAllKeys ${i(this,is).objectStore.name}<${i(this,is).name}>`,e,n);const r=i(this,is).getAllKeys(e,n);return zr(r)}}is=new WeakMap;const qN=512,jh=3e3,Vh={durability:"default",purge:"deferred",purgeAtLeast:16};function cn(...t){}var si,Ut,lt,ss,os,Ar,Ga,tf,Bc,Yp,Fc,Xp,oi,Ds,Uc,Zp;class AN extends gN{constructor(n="wa-sqlite",r=Vh){super();D(this,Ga);D(this,Bc);D(this,Fc);D(this,oi);D(this,Uc);D(this,si,void 0);D(this,Ut,new Map);D(this,lt,void 0);D(this,ss,new Set);D(this,os,performance.now());D(this,Ar,new Set);this.name=n,z(this,si,Object.assign({},Vh,r)),z(this,lt,new ON(SN(n),{durability:i(this,si).durability}))}async close(){var n;for(const r of i(this,Ut).keys())await this.xClose(r);await((n=i(this,lt))==null?void 0:n.close()),z(this,lt,null)}xOpen(n,r,a,l){return this.handleAsync(async()=>{n===null&&(n=`null_${r}`),cn(`xOpen ${n} 0x${r.toString(16)} 0x${a.toString(16)}`);try{const p=new URL(n,"http://localhost/"),w={path:p.pathname,flags:a,block0:null,locks:new vN(p.pathname)};return i(this,Ut).set(r,w),await i(this,lt).run("readwrite",async({blocks:v})=>{if(w.block0=await v.get(_e(this,oi,Ds).call(this,w,0)),!w.block0)if(a&Hp)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&uN,!0),ze}catch(p){return console.error(p),zp}})}xClose(n){return this.handleAsync(async()=>{try{const r=i(this,Ut).get(n);return r&&(cn(`xClose ${r.path}`),i(this,Ut).delete(n),r.flags&lN&&i(this,lt).run("readwrite",({blocks:a})=>{a.delete(IDBKeyRange.bound([r.path],[r.path,[]]))})),ze}catch(r){return console.error(r),Nt}})}xRead(n,r,a){return this.handleAsync(async()=>{const l=i(this,Ut).get(n);cn(`xRead ${l.path} ${r.byteLength} ${a}`);try{return await i(this,lt).run("readonly",async({blocks:w})=>{let v=0;for(;vjh){const p=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&i(this,Ar).add(n),await new Promise(v=>setTimeout(v));const w=_e(this,Ga,tf).call(this,n,r,a);return z(this,os,performance.now()),w});return l&&i(this,Ar).delete(n),p}return _e(this,Ga,tf).call(this,n,r,a)}xTruncate(n,r){const a=i(this,Ut).get(n);cn(`xTruncate ${a.path} ${r}`);try{Object.assign(a.block0,{fileSize:r,data:a.block0.data.slice(0,r)});const l=Object.assign({},a.block0);return i(this,lt).run("readwrite",({blocks:p})=>{p.delete(_e(this,oi,Ds).call(this,a,-1/0,-r)),p.put(l)}),ze}catch(l){return console.error(l),Nt}}xSync(n,r){const a=i(this,Ar).has(n);if(a||i(this,si).durability!=="relaxed"||performance.now()-i(this,os)>jh){const p=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&i(this,Ar).add(n);const w=await _e(this,Bc,Yp).call(this,n,r);return z(this,os,performance.now()),w});return a&&i(this,Ar).delete(n),p}const l=i(this,Ut).get(n);return cn(`xSync ${l.path} ${r}`),ze}xFileSize(n,r){const a=i(this,Ut).get(n);return cn(`xFileSize ${a.path}`),r.setBigInt64(0,BigInt(a.block0.fileSize),!0),ze}xLock(n,r){return this.handleAsync(async()=>{const a=i(this,Ut).get(n);cn(`xLock ${a.path} ${r}`);try{const l=await a.locks.lock(r);return l===ze&&a.locks.state===Ui&&(a.block0=await i(this,lt).run("readonly",({blocks:p})=>p.get(_e(this,oi,Ds).call(this,a,0)))),l}catch(l){return console.error(l),Nt}})}xUnlock(n,r){return this.handleAsync(async()=>{const a=i(this,Ut).get(n);cn(`xUnlock ${a.path} ${r}`);try{return a.locks.unlock(r)}catch(l){return console.error(l),Nt}})}xCheckReservedLock(n,r){return this.handleAsync(async()=>{const a=i(this,Ut).get(n);cn(`xCheckReservedLock ${a.path}`);const l=await a.locks.isSomewhereReserved();return r.setInt32(0,l?1:0,!0),ze})}xSectorSize(n){return qN}xDeviceCharacteristics(n){return mN|hN|dN|pN}xFileControl(n,r,a){const l=i(this,Ut).get(n);switch(cn(`xFileControl ${l.path} ${r}`),r){case 11:return l.overwrite=!0,ze;case 21:if(l.overwrite)try{return this.handleAsync(async()=>(await _e(this,Uc,Zp).call(this,l),ze))}catch(p){return console.error(p),Nt}return ze;case 22:return l.overwrite=!1,ze;case 31:return this.handleAsync(async()=>{try{return l.block0.version--,l.changedPages=new Set,i(this,lt).run("readwrite",async({blocks:p})=>{const w=await p.index("version").getAllKeys(IDBKeyRange.bound([l.path],[l.path,l.block0.version]));for(const v of w)p.delete(v)}),ze}catch(p){return console.error(p),Nt}});case 32:try{const p=Object.assign({},l.block0);p.data=p.data.slice();const w=l.changedPages;return l.changedPages=null,i(this,lt).run("readwrite",async({blocks:v})=>{v.put(p);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 S of w)d.data.set(S,p.version);v.put(d),_e(this,Fc,Xp).call(this,l.path,d.count)}),ze}catch(p){return console.error(p),Nt}case 33:return this.handleAsync(async()=>{try{return l.changedPages=null,l.block0=await i(this,lt).run("readonly",({blocks:p})=>p.get([l.path,0,l.block0.version+1])),ze}catch(p){return console.error(p),Nt}});default:return Vp}}xAccess(n,r,a){return this.handleAsync(async()=>{try{const l=new URL(n,"file://localhost/").pathname;cn(`xAccess ${l} ${r}`);const p=await i(this,lt).run("readonly",({blocks:w})=>w.getKey(_e(this,oi,Ds).call(this,{path:l},0)));return a.setInt32(0,p?1:0,!0),ze}catch(l){return console.error(l),Nt}})}xDelete(n,r){return this.handleAsync(async()=>{const a=new URL(n,"file://localhost/").pathname;try{return i(this,lt).run("readwrite",({blocks:l})=>l.delete(IDBKeyRange.bound([a],[a,[]]))),r&&await i(this,lt).sync(),ze}catch(l){return console.error(l),Nt}})}async purge(n){const r=Date.now();await i(this,lt).run("readwrite",async({blocks:a})=>{const l=await a.get([n,"purge",0]);if(l){for(const[p,w]of l.data)a.delete(IDBKeyRange.bound([n,p,w],[n,p,1/0],!0,!1));await a.delete([n,"purge",0])}cn(`purge ${n} ${(l==null?void 0:l.data.size)??0} pages in ${Date.now()-r} ms`)})}}si=new WeakMap,Ut=new WeakMap,lt=new WeakMap,ss=new WeakMap,os=new WeakMap,Ar=new WeakMap,Ga=new WeakSet,tf=function(n,r,a){const l=i(this,Ut).get(n);cn(`xWrite ${l.path} ${r.byteLength} ${a}`);try{const p=l.block0.fileSize;l.block0.fileSize=Math.max(l.block0.fileSize,a+r.byteLength);const w=a===0?l.block0:{path:l.path,offset:-a,version:l.block0.version,data:null};return w.data=r.slice(),l.changedPages?(p===l.block0.fileSize&&l.changedPages.add(-a),a!==0&&i(this,lt).run("readwrite",({blocks:v})=>v.put(w))):i(this,lt).run("readwrite",({blocks:v})=>v.put(w)),ze}catch(p){return console.error(p),Nt}},Bc=new WeakSet,Yp=async function(n,r){const a=i(this,Ut).get(n);cn(`xSync ${a.path} ${r}`);try{await i(this,lt).sync()}catch(l){return console.error(l),Nt}return ze},Fc=new WeakSet,Xp=function(n,r){i(this,si).purge==="manual"||i(this,ss).has(n)||r{this.purge(n),i(this,ss).delete(n)}):setTimeout(()=>{this.purge(n),i(this,ss).delete(n)}),i(this,ss).add(n))},oi=new WeakSet,Ds=function(n,r,a=0){const l=!r||-r{const te=await j.index("version").getAllKeys(IDBKeyRange.bound([n.path,B+1],[n.path,1/0]));for(const se of te)j.delete(se);j.delete([n.path,"purge",0]);for(let se=0;se=S)break;const I={path:E.path,offset:A,version:B,data:E.data.subarray(N*l,(N+1)*l)};I.offset===0&&(I.fileSize=S,n.block0=I),j.put(I)}}}})};function SN(t){return new Promise((e,n)=>{const r=globalThis.indexedDB.open(t,5);r.addEventListener("upgradeneeded",function(){r.result.createObjectStore("blocks",{keyPath:["path","offset","version"]}).createIndex("version",["path","version"])}),r.addEventListener("success",()=>{e(r.result)}),r.addEventListener("error",()=>{n(r.error)})})}const IN=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,TN=new Sb({async database(){const t=await wN({locateFile:()=>IN}),e=yN(t),n="wa-sqlite-test";e.vfs_register(new AN(n));const r=await e.open_v2(n,void 0,n);return{sqlite:e,db:r}}});function kN(){console.log("start wa-sqlite test"),Bf(TN).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite]",e))})}function WN(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(a){a(n)}),(r=t.get("*"))&&r.slice().map(function(a){a(e,n)})}}}function RN(t){const e=WN(t);return{...e,once(n,r){const a=l=>{e.off(n,a),r(l)};e.on(n,a)}}}var DN=class{constructor(t){ge(this,"config");ge(this,"worker");ge(this,"connection");ge(this,"connectionMutex",new PN);ge(this,"mitt");this.config=t}async init(){var e,n;this.worker=this.config.worker??new Worker(new URL(""+new URL("worker-568e2893.js",import.meta.url).href,self.location),{type:"module"}),this.mitt=RN(),this.worker.onmessage=({data:{msg:r,type:a}})=>{var l;(l=this.mitt)==null||l.emit(a,r)};const t={type:"init",dbName:this.config.dbName,url:this.config.url};this.worker.postMessage(t),await new Promise((r,a)=>{var l;(l=this.mitt)==null||l.once("init",({err:p})=>{p?a(p):r()})}),this.connection=new LN(this.worker,this.mitt),this.config.usePRAGMA&&await this.optimzePragma(this.connection),await((n=(e=this.config).onCreateConnection)==null?void 0:n.call(e,this.connection))}async optimzePragma(t){await t.executeQuery(dn.raw("PRAGMA cache_size = 4096;")),await t.executeQuery(dn.raw("PRAGMA journal_mode = WAL;")),await t.executeQuery(dn.raw("PRAGMA temp_store = MEMORY;")),await t.executeQuery(dn.raw(`PRAGMA page_size = ${32*1024};`)),await t.executeQuery(dn.raw("PRAGMA synchronous = NORMAL;"))}async acquireConnection(){return await this.connectionMutex.lock(),this.connection}async beginTransaction(t){await t.executeQuery(dn.raw("begin"))}async commitTransaction(t){await t.executeQuery(dn.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(dn.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:r})=>{var a,l;r?e(r):((a=this.worker)==null||a.terminate(),(l=this.mitt)==null||l.all.clear(),this.mitt=void 0,t())})})}},PN=class{constructor(){ge(this,"promise");ge(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()}},LN=class{constructor(t,e){ge(this,"worker");ge(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:r}=t,l={type:"run",isQuery:["SelectQueryNode","RawNode"].includes(r.kind),sql:n,parameters:e};return this.worker.postMessage(l),new Promise((p,w)=>{this.mitt||w("kysely instance has been destroyed"),this.mitt.once("run",({data:v,err:d})=>{!d&&v?p(v):w(d)})})}},Ya,Jh,MN=(Jh=class{constructor(t){D(this,Ya,void 0);z(this,Ya,t)}createDriver(){return new DN(i(this,Ya))}createQueryCompiler(){return new Pp}createAdapter(){return new Bp}createIntrospector(t){return new Lp(t)}},Ya=new WeakMap,Jh);const BN=new MN({dbName:"wa-sqlite-worker-test"});function FN(){console.log("start wa-sqlite-worker test"),Bf(BN).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite-worker]",e))})}const UN=_t("h1",null,[Na(" test "),_t("a",{href:"https://github.com/kysely-org/kysely",target:"_blank"},"Kysely"),Na(" WASM dialect ")],-1),QN=_t("br",null,null,-1),$N=_t("h3",null,"see worker result in console",-1),jN=_t("h3",null,[Na(" you can explore "),_t("a",{href:"https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API#origin_private_file_system",target:"_blank"}," OPFS "),Na(" file using "),_t("a",{href:"https://chrome.google.com/webstore/detail/opfs-explorer/acndjpgkpaclldomagafnognkcgjignd",target:"_blank"}," opfs-explorer ")],-1),VN=_t("br",null,null,-1),zN={class:"buttons"},HN=_t("br",null,null,-1),KN=_t("div",null," result run in main thread: ",-1),JN=gy({__name:"App",setup(t){const e=new tN,{result:n,run:r}=eN(),a=new nN;function l(){r()}function p(){e.postMessage("")}function w(){a.postMessage("")}function v(){kN()}function d(){FN()}async function S(){(await window.indexedDB.databases()).forEach(te=>{window.indexedDB.deleteDatabase(te.name)})}async function B(){const j=await navigator.storage.getDirectory();await Rh("sqljs"),await Rh("sqlijsWorker"),await S();try{await j.removeEntry("test.db")}catch{}try{await j.removeEntry("test.db-journal")}catch{}console.log("clear all")}return(j,te)=>(Hy(),Gy(Zn,null,[UN,QN,$N,jN,VN,_t("div",zN,[_t("button",{onClick:te[0]||(te[0]=se=>l())}," test sqljs in main thread "),_t("button",{onClick:te[1]||(te[1]=se=>p())}," test sqljs in Worker "),_t("button",{onClick:te[2]||(te[2]=se=>w())}," test officialWasm in Worker "),_t("button",{onClick:te[3]||(te[3]=se=>v())}," test wa-sqlite in main thread "),_t("button",{onClick:te[4]||(te[4]=se=>d())}," test wa-sqlite in Worker "),_t("button",{onClick:te[5]||(te[5]=se=>B())}," clear ")]),HN,KN,_t("pre",null,""+um(gd(n))+` + `,1)],64))}});Rw(JN).mount("#root"); diff --git a/assets/officialWasmWorker-4253d4af.js b/assets/officialWasmWorker-18f6c592.js similarity index 60% rename from assets/officialWasmWorker-4253d4af.js rename to assets/officialWasmWorker-18f6c592.js index 71484a4..e8a2bec 100644 --- a/assets/officialWasmWorker-4253d4af.js +++ b/assets/officialWasmWorker-18f6c592.js @@ -1,13 +1,17 @@ -var gd=Object.defineProperty;var wd=(Te,we,He)=>we in Te?gd(Te,we,{enumerable:!0,configurable:!0,writable:!0,value:He}):Te[we]=He;var xe=(Te,we,He)=>(wd(Te,typeof we!="symbol"?we+"":we,He),He),bo=(Te,we,He)=>{if(!we.has(Te))throw TypeError("Cannot "+He)};var o=(Te,we,He)=>(bo(Te,we,"read from private field"),He?He.call(Te):we.get(Te)),D=(Te,we,He)=>{if(we.has(Te))throw TypeError("Cannot add the same private member more than once");we instanceof WeakSet?we.add(Te):we.set(Te,He)},G=(Te,we,He,Tr)=>(bo(Te,we,"write to private field"),Tr?Tr.call(Te,He):we.set(Te,He),He);var Ae=(Te,we,He)=>(bo(Te,we,"access private method"),He);(function(){var Mt,Wn,or,Le,Yr,Ut,_e,ae,ce,ar,ls,lr,Fn,Ln,us,Ga,cs,$a,ds,Ha,Dn,vi,ei,qo,fs,Ka,ti,De,ni,ur,cr,Bn,ri,No,U,dr,fr,qn,hr,Nn,Mn,Un,St,_r,mr,yr,gr,Ht,wr,vn,ii,vo,br,qr,xn,Pe,Qn,an,si,Qt,ht,Ye,Be,$e,We,kt,ke,at,mt,yt,ws,Qe,lt,Ot,At,it,Nr,Xt,Yt,ln,jt,Sn,un,Vn,ci,bs,Xa,qs,Ya,Ns,Za,vs,el,di,xo,fi,kn,xs,tl,On,Jn,ut,zt,Gn,Vt,vt,Er,Ps,hi,Eo,pi,So,Sr,An,Ss,kr,$n,Or,ks,nl,_i,xa,mi,Ea;"use strict";function Te(t){return typeof t>"u"||t===void 0}function we(t){return typeof t=="string"}function He(t){return typeof t=="number"}function Tr(t){return typeof t=="boolean"}function ko(t){return t===null}function rl(t){return t instanceof Date}function il(t){return typeof t=="bigint"}function Tt(t){return typeof t=="function"}function Jt(t){return typeof t=="object"&&t!==null}function h(t){return Object.freeze(t)}function Cr(t){return Array.isArray(t)}function Yn(t){return t}const Ke=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]})}}),Ue=h({is(t){return t.kind==="IdentifierNode"},create(t){return h({kind:"IdentifierNode",name:t})}}),hn=h({is(t){return t.kind==="CreateIndexNode"},create(t){return h({kind:"CreateIndexNode",name:Ue.create(t)})},cloneWith(t,e){return h({...t,...e})},cloneWithColumns(t,e){return h({...t,columns:[...t.columns||[],...e]})}}),Oo=h({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return h({kind:"CreateSchemaNode",schema:Ue.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),sl=["preserve rows","delete rows","drop"],Dt=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})}}),pn=h({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return h({kind:"SchemableIdentifierNode",identifier:Ue.create(t)})},createWithSchema(t,e){return h({kind:"SchemableIdentifierNode",schema:Ue.create(t),identifier:Ue.create(e)})}}),xi=h({is(t){return t.kind==="DropIndexNode"},create(t,e){return h({kind:"DropIndexNode",name:pn.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),Ws=h({is(t){return t.kind==="DropSchemaNode"},create(t,e){return h({kind:"DropSchemaNode",schema:Ue.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),Fs=h({is(t){return t.kind==="DropTableNode"},create(t,e){return h({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return h({...t,...e})}}),_n=h({is(t){return t.kind==="AliasNode"},create(t,e){return h({kind:"AliasNode",node:t,alias:e})}}),mn=h({is(t){return t.kind==="TableNode"},create(t){return h({kind:"TableNode",table:pn.create(t)})},createWithSchema(t,e){return h({kind:"TableNode",table:pn.createWithSchema(t,e)})}});function Ct(t){return Jt(t)&&Tt(t.toOperationNode)}function Ls(t){return Jt(t)&&"expressionType"in t&&Ct(t)}function ol(t){return Jt(t)&&"expression"in t&&we(t.alias)&&Ct(t)}const tn=h({is(t){return t.kind==="SelectModifierNode"},create(t){return h({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return h({kind:"SelectModifierNode",rawModifier:t})}}),Tn=h({is(t){return t.kind==="AndNode"},create(t,e){return h({kind:"AndNode",left:t,right:e})}}),Cn=h({is(t){return t.kind==="OrNode"},create(t,e){return h({kind:"OrNode",left:t,right:e})}}),Ds=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"?Tn.create(t.on,r):Cn.create(t.on,r)})}}),Pr=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:Ds.create(r)})},cloneWithOn(t,e){return h({...t,on:t.on?Ds.cloneWithOperation(t.on,"And",e):Ds.create(e)})}}),Rs=h({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return h({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),Ao=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp"],al=["+","-","*","/","%","^","&","|","#","<<",">>"],Io=["->","->>"],To=[...Ao,...al,"&&","||"],ll=["not","-",...["exists","not exists"]],ul=[...To,...Io,...ll],Wr=h({is(t){return t.kind==="OperatorNode"},create(t){return h({kind:"OperatorNode",operator:t})}});function cl(t){return we(t)&&To.includes(t)}function dl(t){return we(t)&&Ao.includes(t)}function Co(t){return we(t)&&Io.includes(t)}const Ve=h({is(t){return t.kind==="ColumnNode"},create(t){return h({kind:"ColumnNode",column:Ue.create(t)})}}),Bs=h({is(t){return t.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}}),Ei=h({is(t){return t.kind==="ReferenceNode"},create(t,e){return h({kind:"ReferenceNode",table:e,column:t})},createSelectAll(t){return h({kind:"ReferenceNode",table:t,column:Bs.create()})}}),fl=h({is(t){return t.kind==="OrderByItemNode"},create(t,e){return h({kind:"OrderByItemNode",orderBy:t,direction:e})}}),pt=h({is(t){return t.kind==="RawNode"},create(t,e){return h({kind:"RawNode",sqlFragments:h(t),parameters:h(e)})},createWithSql(t){return pt.create([t],[])},createWithChild(t){return pt.create(["",""],[t])},createWithChildren(t){return pt.create(new Array(t.length+1).fill(""),t)}});function hl(t){return t==="asc"||t==="desc"}function Si(t,e){return fl.create(pl(t),_l(e))}function pl(t){return nn(t)}function _l(t){if(t)return t==="asc"||t==="desc"?pt.createWithSql(t):t.toOperationNode()}const Ms=h({is(t){return t.kind==="JSONReferenceNode"},create(t,e){return h({kind:"JSONReferenceNode",reference:t,traversal:e})},cloneWithTraversal(t,e){return h({...t,traversal:e})}}),Po=h({is(t){return t.kind==="JSONOperatorChainNode"},create(t){return h({kind:"JSONOperatorChainNode",operator:t,values:h([])})},cloneWithValue(t,e){return h({...t,values:h([...t.values,e])})}}),Us=h({is(t){return t.kind==="JSONPathNode"},create(t){return h({kind:"JSONPathNode",inOperator:t,pathLegs:h([])})},cloneWithLeg(t,e){return h({...t,pathLegs:h([...t.pathLegs,e])})}});function Wo(t){return we(t)?Pn(t):t.toOperationNode()}function Fr(t){return Cr(t)?t.map(e=>nn(e)):[nn(t)]}function nn(t){return Ui(t)?Mi(t):Wo(t)}function ml(t,e){const r=Pn(t);if(Co(e))return Ms.create(r,Po.create(Wr.create(e)));const n=e.slice(0,-1);if(Co(n))return Ms.create(r,Us.create(Wr.create(n)));throw new Error(`Invalid JSON operator: ${e}`)}function Pn(t){const e=".";if(!t.includes(e))return Ei.create(Ve.create(t));const r=t.split(e).map(Qs);if(r.length===3)return gl(r);if(r.length===2)return wl(r);throw new Error(`invalid column reference ${t}`)}function yl(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(Qs);return _n.create(Pn(r),Ue.create(n))}else return Pn(t)}function Fo(t){return Ve.create(t)}function Lo(t){const e=" ";if(t.includes(e)){const[r,n]=t.split(e).map(Qs);if(!hl(n))throw new Error(`invalid order direction "${n}" next to "${r}"`);return Si(r,n)}else return Fo(t)}function gl(t){const[e,r,n]=t;return Ei.create(Ve.create(n),mn.createWithSchema(e,r))}function wl(t){const[e,r]=t;return Ei.create(Ve.create(r),mn.create(e))}function Qs(t){return t.trim()}const Do=h({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return h({kind:"PrimitiveValueListNode",values:h([...t])})}}),js=h({is(t){return t.kind==="ValueListNode"},create(t){return h({kind:"ValueListNode",values:h(t)})}}),Rt=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 Ro(t){return Cr(t)?bl(t):rn(t)}function rn(t){return Ui(t)?Mi(t):Rt.create(t)}function bl(t){return t.some(Ui)?js.create(t.map(e=>rn(e))):Do.create(t)}function _t(t){if(t.length>1&&!Uo(t[1]))throw new Error(`invalid comparison operator ${JSON.stringify(t[1])}`);return Bo(t)}function Bo(t){if(t.length===3)return ki(t[0],t[1],t[2]);if(t.length===1)return El(t[0]);throw new Error(`invalid arguments: ${JSON.stringify(t)}`)}function ki(t,e,r){if(!Mo(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Nl(e)&&vl(r)?xl(t,e,r):Rs.create(nn(t),zs(e),Ro(r))}function sn(t,e,r){if(!Uo(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return ql(t,e,r)}function ql(t,e,r){if(!Mo(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Rs.create(nn(t),zs(e),nn(r))}function Mo(t){return cl(t)||Ls(t)}function Uo(t){return dl(t)||Ls(t)}function Nl(t){return t==="is"||t==="is not"}function vl(t){return ko(t)||Tr(t)}function xl(t,e,r){return Rs.create(nn(t),zs(e),Rt.createImmediate(r))}function zs(t){if(we(t)&&ul.includes(t))return Wr.create(t);if(Ct(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function El(t){return Tt(t)?t(eo()).toOperationNode():Ct(t)?t.toOperationNode():Rt.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])})}}),Qo=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])})}}),Vs=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?Qo.cloneWithItems(t.partitionBy,e):Qo.create(e)})}}),Oi=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])})}}),jo=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])})}}),zo=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"?Tn.create(t.having,r):Cn.create(t.having,r)})}}),Ee=h({is(t){return t.kind==="SelectQueryNode"},create(t,e){return h({kind:"SelectQueryNode",from:Oi.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?jo.cloneWithItems(t.groupBy,e):jo.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?zo.cloneWithOperation(t.having,"And",e):zo.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})}});function Se(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}const Xr=class Xr{constructor(e){D(this,Mt,void 0);G(this,Mt,h(e))}on(...e){return new Xr({...o(this,Mt),joinNode:Pr.cloneWithOn(o(this,Mt).joinNode,_t(e))})}onRef(e,r,n){return new Xr({...o(this,Mt),joinNode:Pr.cloneWithOn(o(this,Mt).joinNode,sn(e,r,n))})}onTrue(){return new Xr({...o(this,Mt),joinNode:Pr.cloneWithOn(o(this,Mt).joinNode,pt.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return o(this,Mt).joinNode}};Mt=new WeakMap;let Ai=Xr;Se(Ai,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const Sl=h({is(t){return t.kind==="PartitionByItemNode"},create(t){return h({kind:"PartitionByItemNode",partitionBy:t})}});function kl(t){return Fr(t).map(Sl.create)}const as=class as{constructor(e){D(this,Wn,void 0);G(this,Wn,h(e))}orderBy(e,r){return new as({overNode:Vs.cloneWithOrderByItem(o(this,Wn).overNode,Si(e,r))})}partitionBy(e){return new as({overNode:Vs.cloneWithPartitionByItems(o(this,Wn).overNode,kl(e))})}$call(e){return e(this)}toOperationNode(){return o(this,Wn).overNode}};Wn=new WeakMap;let Ii=as;Se(Ii,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const Lr=h({is(t){return t.kind==="SelectionNode"},create(t){return h({kind:"SelectionNode",selection:t})},createSelectAll(){return h({kind:"SelectionNode",selection:Bs.create()})},createSelectAllFromTable(t){return h({kind:"SelectionNode",selection:Ei.createSelectAll(t)})}});class Ol{constructor(e){D(this,or,void 0);G(this,or,e)}get dynamicReference(){return o(this,or)}get refType(){}toOperationNode(){return Wo(o(this,or))}}or=new WeakMap;function Al(t){return Jt(t)&&Ct(t)&&we(t.dynamicReference)}function Dr(t){return Tt(t)?Dr(t(ir())):Cr(t)?t.map(e=>Vo(e)):[Vo(t)]}function Vo(t){return we(t)?Lr.create(yl(t)):Al(t)?Lr.create(t.toOperationNode()):Lr.create(aa(t))}function Rr(t){return t?Array.isArray(t)?t.map(Jo):[Jo(t)]:[Lr.createSelectAll()]}function Jo(t){if(we(t))return Lr.createSelectAllFromTable(Nt(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const Il=h({is(t){return t.kind==="ValuesNode"},create(t){return h({kind:"ValuesNode",values:h(t)})}}),Tl=h({is(t){return t.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function Cl(t){const e=Tt(t)?t(ir()):t,r=Cr(e)?e:h([e]);return Pl(r)}function Pl(t){const e=Wl(t);return[h([...e.keys()].map(Ve.create)),Il.create(t.map(r=>Fl(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 Fl(t,e){const r=Object.keys(t),n=Array.from({length:e.size});let A=!1;for(const Y of r){const pe=e.get(Y);if(Te(pe))continue;const Ie=t[Y];(Te(Ie)||Ui(Ie))&&(A=!0),n[pe]=Ie}if(r.lengthTe(pe)?Y:rn(pe)))}return Do.create(n)}const Gt=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})}}),Ti=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?Oi.cloneWithFroms(t.from,e):Oi.create(e)})},cloneWithUpdates(t,e){return h({...t,updates:t.updates?h([...t.updates,...e]):e})}}),Go=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])})}}),Br=h({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return h({kind:"DeleteQueryNode",from:Oi.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?Go.cloneWithTables(t.using,e):Go.create(e)})}}),bt=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"?Tn.create(t.where,r):Cn.create(t.where,r)})}}),$o=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)})}}),Ll=h({is(t){return t.kind==="ExplainNode"},create(t,e){return h({kind:"ExplainNode",format:t,options:e})}}),ye=h({is(t){return Ee.is(t)||Gt.is(t)||Ti.is(t)||Br.is(t)},cloneWithWhere(t,e){return h({...t,where:t.where?bt.cloneWithOperation(t.where,"And",e):bt.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?$o.cloneWithSelections(t.returning,e):$o.create(e)})},cloneWithoutWhere(t){return h({...t,where:void 0})},cloneWithExplain(t,e,r){return h({...t,explain:Ll.create(e,r==null?void 0:r.toOperationNode())})}}),Dl=h({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return h({kind:"ColumnUpdateNode",column:t,value:e})}});function Js(t){const e=Tt(t)?t(ir()):t;return Object.entries(e).filter(([r,n])=>n!==void 0).map(([r,n])=>Dl.create(Ve.create(r),rn(n)))}const Rl=h({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return h({kind:"OnDuplicateKeyNode",updates:t})}});class Bl{constructor(e,r){xe(this,"insertId");xe(this,"numInsertedOrUpdatedRows");this.insertId=e,this.numInsertedOrUpdatedRows=r}}class Ci extends Error{constructor(r){super("no result");xe(this,"node");this.node=r}}function Pi(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const xt=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?bt.cloneWithOperation(t.indexWhere,"And",e):bt.create(e)})},cloneWithIndexOrWhere(t,e){return h({...t,indexWhere:t.indexWhere?bt.cloneWithOperation(t.indexWhere,"Or",e):bt.create(e)})},cloneWithUpdateWhere(t,e){return h({...t,updateWhere:t.updateWhere?bt.cloneWithOperation(t.updateWhere,"And",e):bt.create(e)})},cloneWithUpdateOrWhere(t,e){return h({...t,updateWhere:t.updateWhere?bt.cloneWithOperation(t.updateWhere,"Or",e):bt.create(e)})},cloneWithoutIndexWhere(t){return h({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return h({...t,updateWhere:void 0})}}),on=class on{constructor(e){D(this,Le,void 0);G(this,Le,h(e))}column(e){const r=Ve.create(e);return new on({...o(this,Le),onConflictNode:xt.cloneWith(o(this,Le).onConflictNode,{columns:o(this,Le).onConflictNode.columns?h([...o(this,Le).onConflictNode.columns,r]):h([r])})})}columns(e){const r=e.map(Ve.create);return new on({...o(this,Le),onConflictNode:xt.cloneWith(o(this,Le).onConflictNode,{columns:o(this,Le).onConflictNode.columns?h([...o(this,Le).onConflictNode.columns,...r]):h(r)})})}constraint(e){return new on({...o(this,Le),onConflictNode:xt.cloneWith(o(this,Le).onConflictNode,{constraint:Ue.create(e)})})}expression(e){return new on({...o(this,Le),onConflictNode:xt.cloneWith(o(this,Le).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new on({...o(this,Le),onConflictNode:xt.cloneWithIndexWhere(o(this,Le).onConflictNode,_t(e))})}whereRef(e,r,n){return new on({...o(this,Le),onConflictNode:xt.cloneWithIndexWhere(o(this,Le).onConflictNode,sn(e,r,n))})}clearWhere(){return new on({...o(this,Le),onConflictNode:xt.cloneWithoutIndexWhere(o(this,Le).onConflictNode)})}doNothing(){return new Ho({...o(this,Le),onConflictNode:xt.cloneWith(o(this,Le).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Fi({...o(this,Le),onConflictNode:xt.cloneWith(o(this,Le).onConflictNode,{updates:Js(e)})})}$call(e){return e(this)}};Le=new WeakMap;let Wi=on;Se(Wi,"don't await OnConflictBuilder instances.");class Ho{constructor(e){D(this,Yr,void 0);G(this,Yr,h(e))}toOperationNode(){return o(this,Yr).onConflictNode}}Yr=new WeakMap,Se(Ho,"don't await OnConflictDoNothingBuilder instances.");const Zr=class Zr{constructor(e){D(this,Ut,void 0);G(this,Ut,h(e))}where(...e){return new Zr({...o(this,Ut),onConflictNode:xt.cloneWithUpdateWhere(o(this,Ut).onConflictNode,_t(e))})}whereRef(e,r,n){return new Zr({...o(this,Ut),onConflictNode:xt.cloneWithUpdateWhere(o(this,Ut).onConflictNode,sn(e,r,n))})}clearWhere(){return new Zr({...o(this,Ut),onConflictNode:xt.cloneWithoutUpdateWhere(o(this,Ut).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return o(this,Ut).onConflictNode}};Ut=new WeakMap;let Fi=Zr;Se(Fi,"don't await OnConflictUpdateBuilder instances.");const ft=class ft{constructor(e){D(this,_e,void 0);G(this,_e,h(e))}values(e){const[r,n]=Cl(e);return new ft({...o(this,_e),queryNode:Gt.cloneWith(o(this,_e).queryNode,{columns:r,values:n})})}columns(e){return new ft({...o(this,_e),queryNode:Gt.cloneWith(o(this,_e).queryNode,{columns:h(e.map(Ve.create))})})}expression(e){return new ft({...o(this,_e),queryNode:Gt.cloneWith(o(this,_e).queryNode,{values:Mi(e)})})}ignore(){return new ft({...o(this,_e),queryNode:Gt.cloneWith(o(this,_e).queryNode,{ignore:!0})})}onConflict(e){return new ft({...o(this,_e),queryNode:Gt.cloneWith(o(this,_e).queryNode,{onConflict:e(new Wi({onConflictNode:xt.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new ft({...o(this,_e),queryNode:Gt.cloneWith(o(this,_e).queryNode,{onDuplicateKey:Rl.create(Js(e))})})}returning(e){return new ft({...o(this,_e),queryNode:ye.cloneWithReturning(o(this,_e).queryNode,Dr(e))})}returningAll(){return new ft({...o(this,_e),queryNode:ye.cloneWithReturning(o(this,_e).queryNode,Rr())})}$call(e){return e(this)}$if(e,r){return e?r(this):new ft({...o(this,_e)})}$castTo(){return new ft(o(this,_e))}$narrowType(){return new ft(o(this,_e))}$assertType(){return new ft(o(this,_e))}withPlugin(e){return new ft({...o(this,_e),executor:o(this,_e).executor.withPlugin(e)})}toOperationNode(){return o(this,_e).executor.transformQuery(o(this,_e).queryNode,o(this,_e).queryId)}compile(){return o(this,_e).executor.compileQuery(this.toOperationNode(),o(this,_e).queryId)}async execute(){const e=this.compile(),r=e.query,n=await o(this,_e).executor.executeQuery(e,o(this,_e).queryId);return o(this,_e).executor.adapter.supportsReturning&&r.returning?n.rows:[new Bl(n.insertId,n.numAffectedRows??n.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Ci){const r=await this.executeTakeFirst();if(r===void 0)throw Pi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=o(this,_e).executor.stream(r,e,o(this,_e).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new ft({...o(this,_e),queryNode:ye.cloneWithExplain(o(this,_e).queryNode,e,r)}).execute()}};_e=new WeakMap;let Mr=ft;Se(Mr,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Ml{constructor(e){xe(this,"numDeletedRows");this.numDeletedRows=e}}const Ko=h({is(t){return t.kind==="LimitNode"},create(t){return h({kind:"LimitNode",limit:Rt.create(t)})}}),Xe=class Xe{constructor(e){D(this,ae,void 0);G(this,ae,h(e))}where(...e){return new Xe({...o(this,ae),queryNode:ye.cloneWithWhere(o(this,ae).queryNode,_t(e))})}whereRef(e,r,n){return new Xe({...o(this,ae),queryNode:ye.cloneWithWhere(o(this,ae).queryNode,sn(e,r,n))})}clearWhere(){return new Xe({...o(this,ae),queryNode:ye.cloneWithoutWhere(o(this,ae).queryNode)})}using(e){return new Xe({...o(this,ae),queryNode:Br.cloneWithUsing(o(this,ae).queryNode,zr(e))})}innerJoin(...e){return new Xe({...o(this,ae),queryNode:ye.cloneWithJoin(o(this,ae).queryNode,qt("InnerJoin",e))})}leftJoin(...e){return new Xe({...o(this,ae),queryNode:ye.cloneWithJoin(o(this,ae).queryNode,qt("LeftJoin",e))})}rightJoin(...e){return new Xe({...o(this,ae),queryNode:ye.cloneWithJoin(o(this,ae).queryNode,qt("RightJoin",e))})}fullJoin(...e){return new Xe({...o(this,ae),queryNode:ye.cloneWithJoin(o(this,ae).queryNode,qt("FullJoin",e))})}returning(e){return new Xe({...o(this,ae),queryNode:ye.cloneWithReturning(o(this,ae).queryNode,Dr(e))})}returningAll(e){return new Xe({...o(this,ae),queryNode:ye.cloneWithReturning(o(this,ae).queryNode,Rr(e))})}orderBy(e,r){return new Xe({...o(this,ae),queryNode:Br.cloneWithOrderByItem(o(this,ae).queryNode,Si(e,r))})}limit(e){return new Xe({...o(this,ae),queryNode:Br.cloneWithLimit(o(this,ae).queryNode,Ko.create(e))})}$call(e){return e(this)}$if(e,r){return e?r(this):new Xe({...o(this,ae)})}$castTo(){return new Xe(o(this,ae))}$narrowType(){return new Xe(o(this,ae))}$assertType(){return new Xe(o(this,ae))}withPlugin(e){return new Xe({...o(this,ae),executor:o(this,ae).executor.withPlugin(e)})}toOperationNode(){return o(this,ae).executor.transformQuery(o(this,ae).queryNode,o(this,ae).queryId)}compile(){return o(this,ae).executor.compileQuery(this.toOperationNode(),o(this,ae).queryId)}async execute(){const e=this.compile(),r=e.query,n=await o(this,ae).executor.executeQuery(e,o(this,ae).queryId);return o(this,ae).executor.adapter.supportsReturning&&r.returning?n.rows:[new Ml(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Ci){const r=await this.executeTakeFirst();if(r===void 0)throw Pi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=o(this,ae).executor.stream(r,e,o(this,ae).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new Xe({...o(this,ae),queryNode:ye.cloneWithExplain(o(this,ae).queryNode,e,r)}).execute()}};ae=new WeakMap;let Li=Xe;Se(Li,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Ul{constructor(e,r){xe(this,"numUpdatedRows");xe(this,"numChangedRows");this.numUpdatedRows=e,this.numChangedRows=r}}const nt=class nt{constructor(e){D(this,ce,void 0);G(this,ce,h(e))}where(...e){return new nt({...o(this,ce),queryNode:ye.cloneWithWhere(o(this,ce).queryNode,_t(e))})}whereRef(e,r,n){return new nt({...o(this,ce),queryNode:ye.cloneWithWhere(o(this,ce).queryNode,sn(e,r,n))})}clearWhere(){return new nt({...o(this,ce),queryNode:ye.cloneWithoutWhere(o(this,ce).queryNode)})}from(e){return new nt({...o(this,ce),queryNode:Ti.cloneWithFromItems(o(this,ce).queryNode,zr(e))})}innerJoin(...e){return new nt({...o(this,ce),queryNode:ye.cloneWithJoin(o(this,ce).queryNode,qt("InnerJoin",e))})}leftJoin(...e){return new nt({...o(this,ce),queryNode:ye.cloneWithJoin(o(this,ce).queryNode,qt("LeftJoin",e))})}rightJoin(...e){return new nt({...o(this,ce),queryNode:ye.cloneWithJoin(o(this,ce).queryNode,qt("RightJoin",e))})}fullJoin(...e){return new nt({...o(this,ce),queryNode:ye.cloneWithJoin(o(this,ce).queryNode,qt("FullJoin",e))})}set(e){return new nt({...o(this,ce),queryNode:Ti.cloneWithUpdates(o(this,ce).queryNode,Js(e))})}returning(e){return new nt({...o(this,ce),queryNode:ye.cloneWithReturning(o(this,ce).queryNode,Dr(e))})}returningAll(){return new nt({...o(this,ce),queryNode:ye.cloneWithReturning(o(this,ce).queryNode,Rr())})}$call(e){return e(this)}$if(e,r){return e?r(this):new nt({...o(this,ce)})}$castTo(){return new nt(o(this,ce))}$narrowType(){return new nt(o(this,ce))}$assertType(){return new nt(o(this,ce))}withPlugin(e){return new nt({...o(this,ce),executor:o(this,ce).executor.withPlugin(e)})}toOperationNode(){return o(this,ce).executor.transformQuery(o(this,ce).queryNode,o(this,ce).queryId)}compile(){return o(this,ce).executor.compileQuery(this.toOperationNode(),o(this,ce).queryId)}async execute(){const e=this.compile(),r=e.query,n=await o(this,ce).executor.executeQuery(e,o(this,ce).queryId);return o(this,ce).executor.adapter.supportsReturning&&r.returning?n.rows:[new Ul(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0),n.numChangedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Ci){const r=await this.executeTakeFirst();if(r===void 0)throw Pi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=o(this,ce).executor.stream(r,e,o(this,ce).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new nt({...o(this,ce),queryNode:ye.cloneWithExplain(o(this,ce).queryNode,e,r)}).execute()}};ce=new WeakMap;let Di=nt;Se(Di,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const Ql=h({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return h({kind:"CommonTableExpressionNode",name:t,expression:e})}}),Xo=h({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return h({kind:"CommonTableExpressionNameNode",table:mn.create(t),columns:e?h(e.map(Ve.create)):void 0})}});function Yo(t,e){const r=e(Yl());return Ql.create(jl(t),r.toOperationNode())}function jl(t){if(t.includes("(")){const e=t.split(/[\(\)]/),r=e[0],n=e[1].split(",").map(A=>A.trim());return Xo.create(r,n)}else return Xo.create(t)}const Ri=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])})}}),Zo=["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",column:this.transformNode(e.column),table:this.transformNode(e.table)}}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)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}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}}ls=new WeakMap;const Gl=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 $l extends Gs{constructor(r){super();D(this,us);D(this,cs);D(this,ds);D(this,Dn);D(this,ei);D(this,fs);D(this,lr,void 0);D(this,Fn,new Set);D(this,Ln,new Set);G(this,lr,r)}transformNodeImpl(r){if(!Ae(this,us,Ga).call(this,r))return super.transformNodeImpl(r);const n=Ae(this,ds,Ha).call(this,r);for(const Y of n)o(this,Ln).add(Y);const A=Ae(this,cs,$a).call(this,r);for(const Y of A)o(this,Fn).add(Y);const V=super.transformNodeImpl(r);for(const Y of A)o(this,Fn).delete(Y);for(const Y of n)o(this,Ln).delete(Y);return V}transformSchemableIdentifier(r){const n=super.transformSchemableIdentifier(r);return n.schema||!o(this,Fn).has(r.identifier.name)?n:{...n,schema:Ue.create(o(this,lr))}}transformReferences(r){const n=super.transformReferences(r);return n.table.table.schema?n:{...n,table:mn.createWithSchema(o(this,lr),n.table.table.identifier.name)}}}lr=new WeakMap,Fn=new WeakMap,Ln=new WeakMap,us=new WeakSet,Ga=function(r){return r.kind in Gl},cs=new WeakSet,$a=function(r){const n=new Set;if("name"in r&&r.name&&pn.is(r.name)&&Ae(this,ei,qo).call(this,r.name,n),"from"in r&&r.from)for(const A of r.from.froms)Ae(this,Dn,vi).call(this,A,n);if("into"in r&&r.into&&Ae(this,Dn,vi).call(this,r.into,n),"table"in r&&r.table&&Ae(this,Dn,vi).call(this,r.table,n),"joins"in r&&r.joins)for(const A of r.joins)Ae(this,Dn,vi).call(this,A.table,n);return n},ds=new WeakSet,Ha=function(r){const n=new Set;return"with"in r&&r.with&&Ae(this,fs,Ka).call(this,r.with,n),n},Dn=new WeakSet,vi=function(r,n){const A=mn.is(r)?r:_n.is(r)&&mn.is(r.node)?r.node:null;A&&Ae(this,ei,qo).call(this,A.table,n)},ei=new WeakSet,qo=function(r,n){const A=r.identifier.name;!o(this,Fn).has(A)&&!o(this,Ln).has(A)&&n.add(A)},fs=new WeakSet,Ka=function(r,n){for(const A of r.expressions){const V=A.name.table.table.identifier.name;o(this,Ln).has(V)||n.add(V)}};class Ur{constructor(e){D(this,ti,void 0);G(this,ti,new $l(e))}transformQuery(e){return o(this,ti).transformNode(e.node)}async transformResult(e){return e.result}}ti=new WeakMap;const Rn=class Rn{constructor(e){D(this,De,void 0);G(this,De,h(e))}selectFrom(e){return new Qr({queryId:Fe(),executor:o(this,De).executor,queryNode:Ee.create(zr(e),o(this,De).withNode)})}insertInto(e){return new Mr({queryId:Fe(),executor:o(this,De).executor,queryNode:Gt.create(Nt(e),o(this,De).withNode)})}replaceInto(e){return new Mr({queryId:Fe(),executor:o(this,De).executor,queryNode:Gt.create(Nt(e),o(this,De).withNode,!0)})}deleteFrom(e){return new Li({queryId:Fe(),executor:o(this,De).executor,queryNode:Br.create(zr(e),o(this,De).withNode)})}updateTable(e){return new Di({queryId:Fe(),executor:o(this,De).executor,queryNode:Ti.create(Vr(e),o(this,De).withNode)})}with(e,r){const n=Yo(e,r);return new Rn({...o(this,De),withNode:o(this,De).withNode?Ri.cloneWithExpression(o(this,De).withNode,n):Ri.create(n)})}withRecursive(e,r){const n=Yo(e,r);return new Rn({...o(this,De),withNode:o(this,De).withNode?Ri.cloneWithExpression(o(this,De).withNode,n):Ri.create(n,{recursive:!0})})}withPlugin(e){return new Rn({...o(this,De),executor:o(this,De).executor.withPlugin(e)})}withoutPlugins(){return new Rn({...o(this,De),executor:o(this,De).executor.withoutPlugins()})}withSchema(e){return new Rn({...o(this,De),executor:o(this,De).executor.withPluginAtFront(new Ur(e))})}};De=new WeakMap;let Bi=Rn;class ea{constructor(){D(this,ni,void 0);D(this,ur,void 0);D(this,cr,void 0);xe(this,"resolve",e=>{o(this,ur)&&o(this,ur).call(this,e)});xe(this,"reject",e=>{o(this,cr)&&o(this,cr).call(this,e)});G(this,ni,new Promise((e,r)=>{G(this,cr,r),G(this,ur,e)}))}get promise(){return o(this,ni)}}ni=new WeakMap,ur=new WeakMap,cr=new WeakMap;const ta=new Set;function Hl(t){ta.has(t)||(ta.add(t),console.log(t))}const Kl=h([]);class na{constructor(e=Kl){D(this,ri);D(this,Bn,void 0);G(this,Bn,e)}get plugins(){return o(this,Bn)}transformQuery(e,r){for(const n of o(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),V=await Ae(this,ri,No).call(this,A,r);return Xl(A,V),V})}async*stream(e,r,n){const A=new ea,V=new ea;this.provideConnection(async pe=>(A.resolve(pe),await V.promise)).catch(pe=>A.reject(pe));const Y=await A.promise;try{for await(const pe of Y.streamQuery(e,r))yield await Ae(this,ri,No).call(this,pe,n)}finally{V.resolve()}}}Bn=new WeakMap,ri=new WeakSet,No=async function(e,r){for(const n of o(this,Bn))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||Hl("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class er extends na{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 $s=new er;function Yl(){return new Bi({executor:$s})}function Zl(t,e){return new Ai({joinNode:Pr.create(t,Vr(e))})}function eu(){return new Ii({overNode:Vs.create()})}function qt(t,e){if(e.length===3)return nu(t,e[0],e[1],e[2]);if(e.length===2)return tu(t,e[0],e[1]);throw new Error("not implemented")}function tu(t,e,r){return r(Zl(t,e)).toOperationNode()}function nu(t,e,r,n){return Pr.createWithOn(t,Vr(e),sn(r,"=",n))}const ru=h({is(t){return t.kind==="OffsetNode"},create(t){return h({kind:"OffsetNode",offset:Rt.create(t)})}}),iu=h({is(t){return t.kind==="GroupByItemNode"},create(t){return h({kind:"GroupByItemNode",groupBy:t})}});function su(t){return t=Tt(t)?t(ir()):t,Fr(t).map(iu.create)}const ra=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 ra.create(t,e.toOperationNode(),r)}const le=class le{constructor(e){D(this,U,void 0);G(this,U,h(e))}get expressionType(){}where(...e){return new le({...o(this,U),queryNode:ye.cloneWithWhere(o(this,U).queryNode,_t(e))})}whereRef(e,r,n){return new le({...o(this,U),queryNode:ye.cloneWithWhere(o(this,U).queryNode,sn(e,r,n))})}having(...e){return new le({...o(this,U),queryNode:Ee.cloneWithHaving(o(this,U).queryNode,_t(e))})}havingRef(e,r,n){return new le({...o(this,U),queryNode:Ee.cloneWithHaving(o(this,U).queryNode,sn(e,r,n))})}select(e){return new le({...o(this,U),queryNode:Ee.cloneWithSelections(o(this,U).queryNode,Dr(e))})}distinctOn(e){return new le({...o(this,U),queryNode:Ee.cloneWithDistinctOn(o(this,U).queryNode,Fr(e))})}modifyFront(e){return new le({...o(this,U),queryNode:Ee.cloneWithFrontModifier(o(this,U).queryNode,tn.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new le({...o(this,U),queryNode:Ee.cloneWithEndModifier(o(this,U).queryNode,tn.createWithExpression(e.toOperationNode()))})}distinct(){return new le({...o(this,U),queryNode:Ee.cloneWithFrontModifier(o(this,U).queryNode,tn.create("Distinct"))})}forUpdate(){return new le({...o(this,U),queryNode:Ee.cloneWithEndModifier(o(this,U).queryNode,tn.create("ForUpdate"))})}forShare(){return new le({...o(this,U),queryNode:Ee.cloneWithEndModifier(o(this,U).queryNode,tn.create("ForShare"))})}forKeyShare(){return new le({...o(this,U),queryNode:Ee.cloneWithEndModifier(o(this,U).queryNode,tn.create("ForKeyShare"))})}forNoKeyUpdate(){return new le({...o(this,U),queryNode:Ee.cloneWithEndModifier(o(this,U).queryNode,tn.create("ForNoKeyUpdate"))})}skipLocked(){return new le({...o(this,U),queryNode:Ee.cloneWithEndModifier(o(this,U).queryNode,tn.create("SkipLocked"))})}noWait(){return new le({...o(this,U),queryNode:Ee.cloneWithEndModifier(o(this,U).queryNode,tn.create("NoWait"))})}selectAll(e){return new le({...o(this,U),queryNode:Ee.cloneWithSelections(o(this,U).queryNode,Rr(e))})}innerJoin(...e){return new le({...o(this,U),queryNode:ye.cloneWithJoin(o(this,U).queryNode,qt("InnerJoin",e))})}leftJoin(...e){return new le({...o(this,U),queryNode:ye.cloneWithJoin(o(this,U).queryNode,qt("LeftJoin",e))})}rightJoin(...e){return new le({...o(this,U),queryNode:ye.cloneWithJoin(o(this,U).queryNode,qt("RightJoin",e))})}fullJoin(...e){return new le({...o(this,U),queryNode:ye.cloneWithJoin(o(this,U).queryNode,qt("FullJoin",e))})}innerJoinLateral(...e){return new le({...o(this,U),queryNode:ye.cloneWithJoin(o(this,U).queryNode,qt("LateralInnerJoin",e))})}leftJoinLateral(...e){return new le({...o(this,U),queryNode:ye.cloneWithJoin(o(this,U).queryNode,qt("LateralLeftJoin",e))})}orderBy(e,r){return new le({...o(this,U),queryNode:Ee.cloneWithOrderByItem(o(this,U).queryNode,Si(e,r))})}groupBy(e){return new le({...o(this,U),queryNode:Ee.cloneWithGroupByItems(o(this,U).queryNode,su(e))})}limit(e){return new le({...o(this,U),queryNode:Ee.cloneWithLimit(o(this,U).queryNode,Ko.create(e))})}offset(e){return new le({...o(this,U),queryNode:Ee.cloneWithOffset(o(this,U).queryNode,ru.create(e))})}union(e){return new le({...o(this,U),queryNode:Ee.cloneWithSetOperation(o(this,U).queryNode,tr("union",e,!1))})}unionAll(e){return new le({...o(this,U),queryNode:Ee.cloneWithSetOperation(o(this,U).queryNode,tr("union",e,!0))})}intersect(e){return new le({...o(this,U),queryNode:Ee.cloneWithSetOperation(o(this,U).queryNode,tr("intersect",e,!1))})}intersectAll(e){return new le({...o(this,U),queryNode:Ee.cloneWithSetOperation(o(this,U).queryNode,tr("intersect",e,!0))})}except(e){return new le({...o(this,U),queryNode:Ee.cloneWithSetOperation(o(this,U).queryNode,tr("except",e,!1))})}exceptAll(e){return new le({...o(this,U),queryNode:Ee.cloneWithSetOperation(o(this,U).queryNode,tr("except",e,!0))})}as(e){return new ou(this,e)}clearSelect(){return new le({...o(this,U),queryNode:Ee.cloneWithoutSelections(o(this,U).queryNode)})}clearWhere(){return new le({...o(this,U),queryNode:ye.cloneWithoutWhere(o(this,U).queryNode)})}clearLimit(){return new le({...o(this,U),queryNode:Ee.cloneWithoutLimit(o(this,U).queryNode)})}clearOffset(){return new le({...o(this,U),queryNode:Ee.cloneWithoutOffset(o(this,U).queryNode)})}clearOrderBy(){return new le({...o(this,U),queryNode:Ee.cloneWithoutOrderBy(o(this,U).queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new le({...o(this,U)})}$castTo(){return new le(o(this,U))}$narrowType(){return new le(o(this,U))}$assertType(){return new le(o(this,U))}withPlugin(e){return new le({...o(this,U),executor:o(this,U).executor.withPlugin(e)})}toOperationNode(){return o(this,U).executor.transformQuery(o(this,U).queryNode,o(this,U).queryId)}compile(){return o(this,U).executor.compileQuery(this.toOperationNode(),o(this,U).queryId)}async execute(){const e=this.compile();return(await o(this,U).executor.executeQuery(e,o(this,U).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Ci){const r=await this.executeTakeFirst();if(r===void 0)throw Pi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=o(this,U).executor.stream(r,e,o(this,U).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new le({...o(this,U),queryNode:ye.cloneWithExplain(o(this,U).queryNode,e,r)}).execute()}};U=new WeakMap;let Qr=le;Se(Qr,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class ou{constructor(e,r){D(this,dr,void 0);D(this,fr,void 0);G(this,dr,e),G(this,fr,r)}get expression(){return o(this,dr)}get alias(){return o(this,fr)}toOperationNode(){return _n.create(o(this,dr).toOperationNode(),Ue.create(o(this,fr)))}}dr=new WeakMap,fr=new WeakMap;const nr=h({is(t){return t.kind==="ParensNode"},create(t){return h({kind:"ParensNode",node:t})}}),lo=class lo{constructor(e){D(this,qn,void 0);G(this,qn,e)}get expressionType(){}as(e){return new Hs(this,e)}or(...e){return new Ks(Cn.create(o(this,qn),_t(e)))}and(...e){return new Xs(Tn.create(o(this,qn),_t(e)))}$castTo(){return new lo(o(this,qn))}toOperationNode(){return o(this,qn)}};qn=new WeakMap;let Je=lo;class Hs{constructor(e,r){D(this,hr,void 0);D(this,Nn,void 0);G(this,hr,e),G(this,Nn,r)}get expression(){return o(this,hr)}get alias(){return o(this,Nn)}toOperationNode(){return _n.create(o(this,hr).toOperationNode(),Ct(o(this,Nn))?o(this,Nn).toOperationNode():Ue.create(o(this,Nn)))}}hr=new WeakMap,Nn=new WeakMap;const hs=class hs{constructor(e){D(this,Mn,void 0);G(this,Mn,e)}get expressionType(){}as(e){return new Hs(this,e)}or(...e){return new hs(Cn.create(o(this,Mn),_t(e)))}$castTo(){return new hs(o(this,Mn))}toOperationNode(){return nr.create(o(this,Mn))}};Mn=new WeakMap;let Ks=hs;const ps=class ps{constructor(e){D(this,Un,void 0);G(this,Un,e)}get expressionType(){}as(e){return new Hs(this,e)}and(...e){return new ps(Tn.create(o(this,Un),_t(e)))}$castTo(){return new ps(o(this,Un))}toOperationNode(){return nr.create(o(this,Un))}};Un=new WeakMap;let Xs=ps;const rr=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?bt.cloneWithOperation(t.filter,"And",e):bt.create(e)})},cloneWithOrFilter(t,e){return h({...t,filter:t.filter?bt.cloneWithOperation(t.filter,"Or",e):bt.create(e)})},cloneWithOver(t,e){return h({...t,over:e})}}),au=h({is(t){return t.kind==="FunctionNode"},create(t,e){return h({kind:"FunctionNode",func:t,arguments:e})}}),pr=class pr{constructor(e){D(this,St,void 0);G(this,St,h(e))}get expressionType(){}as(e){return new lu(this,e)}distinct(){return new pr({...o(this,St),aggregateFunctionNode:rr.cloneWithDistinct(o(this,St).aggregateFunctionNode)})}filterWhere(...e){return new pr({...o(this,St),aggregateFunctionNode:rr.cloneWithFilter(o(this,St).aggregateFunctionNode,_t(e))})}filterWhereRef(e,r,n){return new pr({...o(this,St),aggregateFunctionNode:rr.cloneWithFilter(o(this,St).aggregateFunctionNode,sn(e,r,n))})}over(e){const r=eu();return new pr({...o(this,St),aggregateFunctionNode:rr.cloneWithOver(o(this,St).aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return o(this,St).aggregateFunctionNode}};St=new WeakMap;let jr=pr;Se(jr,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class lu{constructor(e,r){D(this,_r,void 0);D(this,mr,void 0);G(this,_r,e),G(this,mr,r)}get expression(){return o(this,_r)}get alias(){return o(this,mr)}toOperationNode(){return _n.create(o(this,_r).toOperationNode(),Ue.create(o(this,mr)))}}_r=new WeakMap,mr=new WeakMap;function ia(){const t=(r,n)=>new Je(au.create(r,Fr(n))),e=(r,n)=>new jr({aggregateFunctionNode:rr.create(r,n?Fr(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 jr({aggregateFunctionNode:rr.create("count",Rr(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}const uu=h({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return h({kind:"UnaryOperationNode",operator:t,operand:e})}});function cu(t,e){return uu.create(Wr.create(t),nn(e))}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})}});class sa{constructor(e){D(this,yr,void 0);G(this,yr,h(e))}when(...e){return new oa({...o(this,yr),node:$t.cloneWithWhen(o(this,yr).node,Ys.create(_t(e)))})}}yr=new WeakMap;class oa{constructor(e){D(this,gr,void 0);G(this,gr,h(e))}then(e){return new du({...o(this,gr),node:$t.cloneWithThen(o(this,gr).node,rn(e))})}}gr=new WeakMap;class du{constructor(e){D(this,Ht,void 0);G(this,Ht,h(e))}when(...e){return new oa({...o(this,Ht),node:$t.cloneWithWhen(o(this,Ht).node,Ys.create(_t(e)))})}else(e){return new fu({...o(this,Ht),node:$t.cloneWith(o(this,Ht).node,{else:rn(e)})})}end(){return new Je($t.cloneWith(o(this,Ht).node,{isStatement:!1}))}endCase(){return new Je($t.cloneWith(o(this,Ht).node,{isStatement:!0}))}}Ht=new WeakMap;class fu{constructor(e){D(this,wr,void 0);G(this,wr,h(e))}end(){return new Je($t.cloneWith(o(this,wr).node,{isStatement:!1}))}endCase(){return new Je($t.cloneWith(o(this,wr).node,{isStatement:!0}))}}wr=new WeakMap;const hu=h({is(t){return t.kind==="JSONPathLegNode"},create(t,e){return h({kind:"JSONPathLegNode",type:t,value:e})}});class Zs{constructor(e){D(this,ii);D(this,vn,void 0);G(this,vn,e)}at(e){return Ae(this,ii,vo).call(this,"ArrayLocation",e)}key(e){return Ae(this,ii,vo).call(this,"Member",e)}}vn=new WeakMap,ii=new WeakSet,vo=function(e,r){return new pu(Ms.cloneWithTraversal(o(this,vn),Us.is(o(this,vn).traversal)?Us.cloneWithLeg(o(this,vn).traversal,hu.create(e,r)):Po.cloneWithValue(o(this,vn).traversal,Rt.createImmediate(r))))};class pu extends Zs{constructor(r){super(r);D(this,br,void 0);G(this,br,r)}get expressionType(){}as(r){return new _u(this,r)}$castTo(){return new Zs(o(this,br))}toOperationNode(){return o(this,br)}}br=new WeakMap;class _u{constructor(e,r){D(this,qr,void 0);D(this,xn,void 0);G(this,qr,e),G(this,xn,r)}get expression(){return o(this,qr)}get alias(){return o(this,xn)}toOperationNode(){return _n.create(o(this,qr).toOperationNode(),Ct(o(this,xn))?o(this,xn).toOperationNode():Ue.create(o(this,xn)))}}qr=new WeakMap,xn=new WeakMap;function eo(t=$s){function e(A,V,Y){return new Je(ki(A,V,Y))}function r(A,V){return new Je(cu(A,V))}const n=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(A){return new Qr({queryId:Fe(),executor:t,queryNode:Ee.create(zr(A))})},case(A){return new sa({node:$t.create(Te(A)?void 0:nn(A))})},ref(A,V){return Te(V)?new Je(Pn(A)):new Zs(ml(A,V))},val(A){return new Je(Ro(A))},cmpr(A,V,Y){return new Je(ki(A,V,Y))},bxp(A,V,Y){return new Je(ki(A,V,Y))},unary:r,not(A){return r("not",A)},exists(A){return r("exists",A)},neg(A){return r("-",A)},and(A){if(A.length===0)return new Je(Rt.createImmediate(!0));if(A.length===1)return new Je(A[0].toOperationNode());let V=Tn.create(A[0].toOperationNode(),A[1].toOperationNode());for(let Y=2;YVr(e)):[Vr(t)]}function Vr(t){return we(t)?mu(t):aa(t)}function mu(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(la);return _n.create(Nt(r),Ue.create(n))}else return Nt(t)}function Nt(t){const e=".";if(t.includes(e)){const[r,n]=t.split(e).map(la);return mn.createWithSchema(r,n)}else return mn.create(t)}function la(t){return t.trim()}const ua=h({is(t){return t.kind==="AddColumnNode"},create(t){return h({kind:"AddColumnNode",column:t})}}),Ge=h({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return h({kind:"ColumnDefinitionNode",column:Ve.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})}}),ca=h({is(t){return t.kind==="DropColumnNode"},create(t){return h({kind:"DropColumnNode",column:Ve.create(t)})}}),da=h({is(t){return t.kind==="RenameColumnNode"},create(t,e){return h({kind:"RenameColumnNode",column:Ve.create(t),renameTo:Ve.create(e)})}}),to=h({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return h({kind:"CheckConstraintNode",expression:t,name:e?Ue.create(e):void 0})}}),yu=["no action","restrict","cascade","set null","set default"],Qi=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 fa(t){return Ct(t)?t.toOperationNode():Rt.createImmediate(t)}const ji=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})}}),gu=h({is(t){return t.kind==="DefaultValueNode"},create(t){return h({kind:"DefaultValueNode",defaultValue:t})}});function zi(t){if(yu.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const rt=class rt{constructor(e){D(this,Pe,void 0);G(this,Pe,e)}autoIncrement(){return new rt(Ge.cloneWith(o(this,Pe),{autoIncrement:!0}))}primaryKey(){return new rt(Ge.cloneWith(o(this,Pe),{primaryKey:!0}))}references(e){const r=Pn(e);if(!r.table||Bs.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new rt(Ge.cloneWith(o(this,Pe),{references:Qi.create(r.table,[r.column])}))}onDelete(e){if(!o(this,Pe).references)throw new Error("on delete constraint can only be added for foreign keys");return new rt(Ge.cloneWith(o(this,Pe),{references:Qi.cloneWithOnDelete(o(this,Pe).references,zi(e))}))}onUpdate(e){if(!o(this,Pe).references)throw new Error("on update constraint can only be added for foreign keys");return new rt(Ge.cloneWith(o(this,Pe),{references:Qi.cloneWithOnUpdate(o(this,Pe).references,zi(e))}))}unique(){return new rt(Ge.cloneWith(o(this,Pe),{unique:!0}))}notNull(){return new rt(Ge.cloneWith(o(this,Pe),{notNull:!0}))}unsigned(){return new rt(Ge.cloneWith(o(this,Pe),{unsigned:!0}))}defaultTo(e){return new rt(Ge.cloneWith(o(this,Pe),{defaultTo:gu.create(fa(e))}))}check(e){return new rt(Ge.cloneWith(o(this,Pe),{check:to.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new rt(Ge.cloneWith(o(this,Pe),{generated:ji.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new rt(Ge.cloneWith(o(this,Pe),{generated:ji.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new rt(Ge.cloneWith(o(this,Pe),{generated:ji.create({identity:!0,byDefault:!0})}))}stored(){if(!o(this,Pe).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new rt(Ge.cloneWith(o(this,Pe),{generated:ji.cloneWith(o(this,Pe).generated,{stored:!0})}))}modifyFront(e){return new rt(Ge.cloneWithFrontModifier(o(this,Pe),e.toOperationNode()))}modifyEnd(e){return new rt(Ge.cloneWithEndModifier(o(this,Pe),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return o(this,Pe)}};Pe=new WeakMap;let yn=rt;Se(yn,"don't await ColumnDefinitionBuilder instances directly.");const ha=h({is(t){return t.kind==="ModifyColumnNode"},create(t){return h({kind:"ModifyColumnNode",column:t})}}),wu=h({is(t){return t.kind==="DataTypeNode"},create(t){return h({kind:"DataTypeNode",dataType:t})}});function sr(t){return Ct(t)?t.toOperationNode():wu.create(t)}const Vi=h({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,n){return h({kind:"ForeignKeyConstraintNode",columns:t,references:Qi.create(e,r),name:n?Ue.create(n):void 0})},cloneWith(t,e){return h({...t,...e})}}),_s=class _s{constructor(e){D(this,Qn,void 0);G(this,Qn,e)}onDelete(e){return new _s(Vi.cloneWith(o(this,Qn),{onDelete:zi(e)}))}onUpdate(e){return new _s(Vi.cloneWith(o(this,Qn),{onUpdate:zi(e)}))}$call(e){return e(this)}toOperationNode(){return o(this,Qn)}};Qn=new WeakMap;let Jr=_s;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})}}),pa=h({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return h({kind:"UniqueConstraintNode",columns:h(t.map(Ve.create)),name:e?Ue.create(e):void 0})}}),Ji=h({is(t){return t.kind==="DropConstraintNode"},create(t){return h({kind:"DropConstraintNode",constraintName:Ue.create(t)})},cloneWith(t,e){return h({...t,...e})}}),Gr=h({is(t){return t.kind==="AlterColumnNode"},create(t,e,r){return h({kind:"AlterColumnNode",column:Ve.create(t),[e]:r})}});class ro{constructor(e){D(this,an,void 0);G(this,an,e)}setDataType(e){return new $r(Gr.create(o(this,an),"dataType",sr(e)))}setDefault(e){return new $r(Gr.create(o(this,an),"setDefault",fa(e)))}dropDefault(){return new $r(Gr.create(o(this,an),"dropDefault",!0))}setNotNull(){return new $r(Gr.create(o(this,an),"setNotNull",!0))}dropNotNull(){return new $r(Gr.create(o(this,an),"dropNotNull",!0))}$call(e){return e(this)}}an=new WeakMap;class $r{constructor(e){D(this,si,void 0);G(this,si,e)}toOperationNode(){return o(this,si)}}si=new WeakMap;class Hr{constructor(e){D(this,Qt,void 0);G(this,Qt,h(e))}toOperationNode(){return o(this,Qt).executor.transformQuery(o(this,Qt).node,o(this,Qt).queryId)}compile(){return o(this,Qt).executor.compileQuery(this.toOperationNode(),o(this,Qt).queryId)}async execute(){await o(this,Qt).executor.executeQuery(this.compile(),o(this,Qt).queryId)}}Qt=new WeakMap,Se(Hr,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const ms=class ms{constructor(e){D(this,ht,void 0);G(this,ht,h(e))}onDelete(e){return new ms({...o(this,ht),constraintBuilder:o(this,ht).constraintBuilder.onDelete(e)})}onUpdate(e){return new ms({...o(this,ht),constraintBuilder:o(this,ht).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return o(this,ht).executor.transformQuery(Ke.cloneWithTableProps(o(this,ht).node,{addConstraint:no.create(o(this,ht).constraintBuilder.toOperationNode())}),o(this,ht).queryId)}compile(){return o(this,ht).executor.compileQuery(this.toOperationNode(),o(this,ht).queryId)}async execute(){await o(this,ht).executor.executeQuery(this.compile(),o(this,ht).queryId)}};ht=new WeakMap;let Gi=ms;Se(Gi,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const oi=class oi{constructor(e){D(this,Ye,void 0);G(this,Ye,h(e))}ifExists(){return new oi({...o(this,Ye),node:Ke.cloneWithTableProps(o(this,Ye).node,{dropConstraint:Ji.cloneWith(o(this,Ye).node.dropConstraint,{ifExists:!0})})})}cascade(){return new oi({...o(this,Ye),node:Ke.cloneWithTableProps(o(this,Ye).node,{dropConstraint:Ji.cloneWith(o(this,Ye).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new oi({...o(this,Ye),node:Ke.cloneWithTableProps(o(this,Ye).node,{dropConstraint:Ji.cloneWith(o(this,Ye).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return o(this,Ye).executor.transformQuery(o(this,Ye).node,o(this,Ye).queryId)}compile(){return o(this,Ye).executor.compileQuery(this.toOperationNode(),o(this,Ye).queryId)}async execute(){await o(this,Ye).executor.executeQuery(this.compile(),o(this,Ye).queryId)}};Ye=new WeakMap;let $i=oi;Se($i,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class _a{constructor(e){D(this,Be,void 0);G(this,Be,h(e))}renameTo(e){return new Hr({...o(this,Be),node:Ke.cloneWithTableProps(o(this,Be).node,{renameTo:Nt(e)})})}setSchema(e){return new Hr({...o(this,Be),node:Ke.cloneWithTableProps(o(this,Be).node,{setSchema:Ue.create(e)})})}alterColumn(e,r){const n=r(new ro(e));return new gn({...o(this,Be),node:Ke.cloneWithColumnAlteration(o(this,Be).node,n.toOperationNode())})}dropColumn(e){return new gn({...o(this,Be),node:Ke.cloneWithColumnAlteration(o(this,Be).node,ca.create(e))})}renameColumn(e,r){return new gn({...o(this,Be),node:Ke.cloneWithColumnAlteration(o(this,Be).node,da.create(e,r))})}addColumn(e,r,n=Yn){const A=n(new yn(Ge.create(e,sr(r))));return new gn({...o(this,Be),node:Ke.cloneWithColumnAlteration(o(this,Be).node,ua.create(A.toOperationNode()))})}modifyColumn(e,r,n=Yn){const A=n(new yn(Ge.create(e,sr(r))));return new gn({...o(this,Be),node:Ke.cloneWithColumnAlteration(o(this,Be).node,ha.create(A.toOperationNode()))})}addUniqueConstraint(e,r){return new Hr({...o(this,Be),node:Ke.cloneWithTableProps(o(this,Be).node,{addConstraint:no.create(pa.create(r,e))})})}addCheckConstraint(e,r){return new Hr({...o(this,Be),node:Ke.cloneWithTableProps(o(this,Be).node,{addConstraint:no.create(to.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,n,A){return new Gi({...o(this,Be),constraintBuilder:new Jr(Vi.create(r.map(Ve.create),Nt(n),A.map(Ve.create),e))})}dropConstraint(e){return new $i({...o(this,Be),node:Ke.cloneWithTableProps(o(this,Be).node,{dropConstraint:Ji.create(e)})})}$call(e){return e(this)}}Be=new WeakMap;const jn=class jn{constructor(e){D(this,$e,void 0);G(this,$e,h(e))}alterColumn(e,r){const n=r(new ro(e));return new jn({...o(this,$e),node:Ke.cloneWithColumnAlteration(o(this,$e).node,n.toOperationNode())})}dropColumn(e){return new jn({...o(this,$e),node:Ke.cloneWithColumnAlteration(o(this,$e).node,ca.create(e))})}renameColumn(e,r){return new jn({...o(this,$e),node:Ke.cloneWithColumnAlteration(o(this,$e).node,da.create(e,r))})}addColumn(e,r,n=Yn){const A=n(new yn(Ge.create(e,sr(r))));return new jn({...o(this,$e),node:Ke.cloneWithColumnAlteration(o(this,$e).node,ua.create(A.toOperationNode()))})}modifyColumn(e,r,n=Yn){const A=n(new yn(Ge.create(e,sr(r))));return new jn({...o(this,$e),node:Ke.cloneWithColumnAlteration(o(this,$e).node,ha.create(A.toOperationNode()))})}toOperationNode(){return o(this,$e).executor.transformQuery(o(this,$e).node,o(this,$e).queryId)}compile(){return o(this,$e).executor.compileQuery(this.toOperationNode(),o(this,$e).queryId)}async execute(){await o(this,$e).executor.executeQuery(this.compile(),o(this,$e).queryId)}};$e=new WeakMap;let gn=jn;Se(_a,"don't await AlterTableBuilder instances"),Se(ro,"don't await AlterColumnBuilder instances"),Se(gn,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class ma extends Gs{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const Kt=class Kt{constructor(e){D(this,We,void 0);G(this,We,h(e))}ifNotExists(){return new Kt({...o(this,We),node:hn.cloneWith(o(this,We).node,{ifNotExists:!0})})}unique(){return new Kt({...o(this,We),node:hn.cloneWith(o(this,We).node,{unique:!0})})}on(e){return new Kt({...o(this,We),node:hn.cloneWith(o(this,We).node,{table:Nt(e)})})}column(e){return new Kt({...o(this,We),node:hn.cloneWithColumns(o(this,We).node,[Lo(e)])})}columns(e){return new Kt({...o(this,We),node:hn.cloneWithColumns(o(this,We).node,e.map(Lo))})}expression(e){return new Kt({...o(this,We),node:hn.cloneWithColumns(o(this,We).node,[e.toOperationNode()])})}using(e){return new Kt({...o(this,We),node:hn.cloneWith(o(this,We).node,{using:pt.createWithSql(e)})})}where(...e){const r=new ma;return new Kt({...o(this,We),node:ye.cloneWithWhere(o(this,We).node,r.transformNode(_t(e)))})}$call(e){return e(this)}toOperationNode(){return o(this,We).executor.transformQuery(o(this,We).node,o(this,We).queryId)}compile(){return o(this,We).executor.compileQuery(this.toOperationNode(),o(this,We).queryId)}async execute(){await o(this,We).executor.executeQuery(this.compile(),o(this,We).queryId)}};We=new WeakMap;let Hi=Kt;Se(Hi,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const uo=class uo{constructor(e){D(this,kt,void 0);G(this,kt,h(e))}ifNotExists(){return new uo({...o(this,kt),node:Oo.cloneWith(o(this,kt).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,kt).executor.transformQuery(o(this,kt).node,o(this,kt).queryId)}compile(){return o(this,kt).executor.compileQuery(this.toOperationNode(),o(this,kt).queryId)}async execute(){await o(this,kt).executor.executeQuery(this.compile(),o(this,kt).queryId)}};kt=new WeakMap;let Ki=uo;Se(Ki,"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(Ve.create)),name:e?Ue.create(e):void 0})}});function qu(t){if(sl.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const Pt=class Pt{constructor(e){D(this,ke,void 0);G(this,ke,h(e))}temporary(){return new Pt({...o(this,ke),node:Dt.cloneWith(o(this,ke).node,{temporary:!0})})}onCommit(e){return new Pt({...o(this,ke),node:Dt.cloneWith(o(this,ke).node,{onCommit:qu(e)})})}ifNotExists(){return new Pt({...o(this,ke),node:Dt.cloneWith(o(this,ke).node,{ifNotExists:!0})})}addColumn(e,r,n=Yn){const A=n(new yn(Ge.create(e,sr(r))));return new Pt({...o(this,ke),node:Dt.cloneWithColumn(o(this,ke).node,A.toOperationNode())})}addPrimaryKeyConstraint(e,r){return new Pt({...o(this,ke),node:Dt.cloneWithConstraint(o(this,ke).node,bu.create(r,e))})}addUniqueConstraint(e,r){return new Pt({...o(this,ke),node:Dt.cloneWithConstraint(o(this,ke).node,pa.create(r,e))})}addCheckConstraint(e,r){return new Pt({...o(this,ke),node:Dt.cloneWithConstraint(o(this,ke).node,to.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,n,A,V=Yn){const Y=V(new Jr(Vi.create(r.map(Ve.create),Nt(n),A.map(Ve.create),e)));return new Pt({...o(this,ke),node:Dt.cloneWithConstraint(o(this,ke).node,Y.toOperationNode())})}modifyFront(e){return new Pt({...o(this,ke),node:Dt.cloneWithFrontModifier(o(this,ke).node,e.toOperationNode())})}modifyEnd(e){return new Pt({...o(this,ke),node:Dt.cloneWithEndModifier(o(this,ke).node,e.toOperationNode())})}$call(e){return e(this)}toOperationNode(){return o(this,ke).executor.transformQuery(o(this,ke).node,o(this,ke).queryId)}compile(){return o(this,ke).executor.compileQuery(this.toOperationNode(),o(this,ke).queryId)}async execute(){await o(this,ke).executor.executeQuery(this.compile(),o(this,ke).queryId)}};ke=new WeakMap;let Xi=Pt;Se(Xi,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const ai=class ai{constructor(e){D(this,at,void 0);G(this,at,h(e))}on(e){return new ai({...o(this,at),node:xi.cloneWith(o(this,at).node,{table:Nt(e)})})}ifExists(){return new ai({...o(this,at),node:xi.cloneWith(o(this,at).node,{ifExists:!0})})}cascade(){return new ai({...o(this,at),node:xi.cloneWith(o(this,at).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,at).executor.transformQuery(o(this,at).node,o(this,at).queryId)}compile(){return o(this,at).executor.compileQuery(this.toOperationNode(),o(this,at).queryId)}async execute(){await o(this,at).executor.executeQuery(this.compile(),o(this,at).queryId)}};at=new WeakMap;let Yi=ai;Se(Yi,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const ys=class ys{constructor(e){D(this,mt,void 0);G(this,mt,h(e))}ifExists(){return new ys({...o(this,mt),node:Ws.cloneWith(o(this,mt).node,{ifExists:!0})})}cascade(){return new ys({...o(this,mt),node:Ws.cloneWith(o(this,mt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,mt).executor.transformQuery(o(this,mt).node,o(this,mt).queryId)}compile(){return o(this,mt).executor.compileQuery(this.toOperationNode(),o(this,mt).queryId)}async execute(){await o(this,mt).executor.executeQuery(this.compile(),o(this,mt).queryId)}};mt=new WeakMap;let Zi=ys;Se(Zi,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const gs=class gs{constructor(e){D(this,yt,void 0);G(this,yt,h(e))}ifExists(){return new gs({...o(this,yt),node:Fs.cloneWith(o(this,yt).node,{ifExists:!0})})}cascade(){return new gs({...o(this,yt),node:Fs.cloneWith(o(this,yt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,yt).executor.transformQuery(o(this,yt).node,o(this,yt).queryId)}compile(){return o(this,yt).executor.compileQuery(this.toOperationNode(),o(this,yt).queryId)}async execute(){await o(this,yt).executor.executeQuery(this.compile(),o(this,yt).queryId)}};yt=new WeakMap;let es=gs;Se(es,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const wn=h({is(t){return t.kind==="CreateViewNode"},create(t){return h({kind:"CreateViewNode",name:pn.create(t)})},cloneWith(t,e){return h({...t,...e})}});class Nu{constructor(){D(this,ws,new ma)}transformQuery(e){return o(this,ws).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}ws=new WeakMap;const En=class En{constructor(e){D(this,Qe,void 0);G(this,Qe,h(e))}temporary(){return new En({...o(this,Qe),node:wn.cloneWith(o(this,Qe).node,{temporary:!0})})}materialized(){return new En({...o(this,Qe),node:wn.cloneWith(o(this,Qe).node,{materialized:!0})})}ifNotExists(){return new En({...o(this,Qe),node:wn.cloneWith(o(this,Qe).node,{ifNotExists:!0})})}orReplace(){return new En({...o(this,Qe),node:wn.cloneWith(o(this,Qe).node,{orReplace:!0})})}columns(e){return new En({...o(this,Qe),node:wn.cloneWith(o(this,Qe).node,{columns:e.map(Fo)})})}as(e){const r=e.withPlugin(new Nu).toOperationNode();return new En({...o(this,Qe),node:wn.cloneWith(o(this,Qe).node,{as:r})})}$call(e){return e(this)}toOperationNode(){return o(this,Qe).executor.transformQuery(o(this,Qe).node,o(this,Qe).queryId)}compile(){return o(this,Qe).executor.compileQuery(this.toOperationNode(),o(this,Qe).queryId)}async execute(){await o(this,Qe).executor.executeQuery(this.compile(),o(this,Qe).queryId)}};Qe=new WeakMap;let ts=En;Se(ts,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const ns=h({is(t){return t.kind==="DropViewNode"},create(t){return h({kind:"DropViewNode",name:pn.create(t)})},cloneWith(t,e){return h({...t,...e})}}),li=class li{constructor(e){D(this,lt,void 0);G(this,lt,h(e))}materialized(){return new li({...o(this,lt),node:ns.cloneWith(o(this,lt).node,{materialized:!0})})}ifExists(){return new li({...o(this,lt),node:ns.cloneWith(o(this,lt).node,{ifExists:!0})})}cascade(){return new li({...o(this,lt),node:ns.cloneWith(o(this,lt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,lt).executor.transformQuery(o(this,lt).node,o(this,lt).queryId)}compile(){return o(this,lt).executor.compileQuery(this.toOperationNode(),o(this,lt).queryId)}async execute(){await o(this,lt).executor.executeQuery(this.compile(),o(this,lt).queryId)}};lt=new WeakMap;let rs=li;Se(rs,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const ya=h({is(t){return t.kind==="CreateTypeNode"},create(t){return h({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return h({...t,enum:js.create(e.map(r=>Rt.createImmediate(r)))})}}),co=class co{constructor(e){D(this,Ot,void 0);G(this,Ot,h(e))}toOperationNode(){return o(this,Ot).executor.transformQuery(o(this,Ot).node,o(this,Ot).queryId)}asEnum(e){return new co({...o(this,Ot),node:ya.cloneWithEnum(o(this,Ot).node,e)})}$call(e){return e(this)}compile(){return o(this,Ot).executor.compileQuery(this.toOperationNode(),o(this,Ot).queryId)}async execute(){await o(this,Ot).executor.executeQuery(this.compile(),o(this,Ot).queryId)}};Ot=new WeakMap;let is=co;Se(is,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const ga=h({is(t){return t.kind==="DropTypeNode"},create(t){return h({kind:"DropTypeNode",name:t})},cloneWith(t,e){return h({...t,...e})}}),fo=class fo{constructor(e){D(this,At,void 0);G(this,At,h(e))}ifExists(){return new fo({...o(this,At),node:ga.cloneWith(o(this,At).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,At).executor.transformQuery(o(this,At).node,o(this,At).queryId)}compile(){return o(this,At).executor.compileQuery(this.toOperationNode(),o(this,At).queryId)}async execute(){await o(this,At).executor.executeQuery(this.compile(),o(this,At).queryId)}};At=new WeakMap;let ss=fo;Se(ss,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function wa(t){const e=".";if(t.includes(e)){const r=t.split(e).map(vu);if(r.length===2)return pn.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return pn.create(t)}function vu(t){return t.trim()}const ui=class ui{constructor(e){D(this,it,void 0);G(this,it,e)}createTable(e){return new Xi({queryId:Fe(),executor:o(this,it),node:Dt.create(Nt(e))})}dropTable(e){return new es({queryId:Fe(),executor:o(this,it),node:Fs.create(Nt(e))})}createIndex(e){return new Hi({queryId:Fe(),executor:o(this,it),node:hn.create(e)})}dropIndex(e){return new Yi({queryId:Fe(),executor:o(this,it),node:xi.create(e)})}createSchema(e){return new Ki({queryId:Fe(),executor:o(this,it),node:Oo.create(e)})}dropSchema(e){return new Zi({queryId:Fe(),executor:o(this,it),node:Ws.create(e)})}alterTable(e){return new _a({queryId:Fe(),executor:o(this,it),node:Ke.create(Nt(e))})}createView(e){return new ts({queryId:Fe(),executor:o(this,it),node:wn.create(e)})}dropView(e){return new rs({queryId:Fe(),executor:o(this,it),node:ns.create(e)})}createType(e){return new is({queryId:Fe(),executor:o(this,it),node:ya.create(wa(e))})}dropType(e){return new ss({queryId:Fe(),executor:o(this,it),node:ga.create(wa(e))})}withPlugin(e){return new ui(o(this,it).withPlugin(e))}withoutPlugins(){return new ui(o(this,it).withoutPlugins())}withSchema(e){return new ui(o(this,it).withPluginAtFront(new Ur(e)))}};it=new WeakMap;let io=ui;class xu{ref(e){return new Ol(e)}}class Eu{constructor(e){D(this,Nr,void 0);G(this,Nr,e)}async provideConnection(e){const r=await o(this,Nr).acquireConnection();try{return await e(r)}finally{await o(this,Nr).releaseConnection(r)}}}Nr=new WeakMap;const zn=class zn extends na{constructor(r,n,A,V=[]){super(V);D(this,Xt,void 0);D(this,Yt,void 0);D(this,ln,void 0);G(this,Xt,r),G(this,Yt,n),G(this,ln,A)}get adapter(){return o(this,Yt)}compileQuery(r){return o(this,Xt).compileQuery(r)}provideConnection(r){return o(this,ln).provideConnection(r)}withPlugins(r){return new zn(o(this,Xt),o(this,Yt),o(this,ln),[...this.plugins,...r])}withPlugin(r){return new zn(o(this,Xt),o(this,Yt),o(this,ln),[...this.plugins,r])}withPluginAtFront(r){return new zn(o(this,Xt),o(this,Yt),o(this,ln),[r,...this.plugins])}withConnectionProvider(r){return new zn(o(this,Xt),o(this,Yt),r,[...this.plugins])}withoutPlugins(){return new zn(o(this,Xt),o(this,Yt),o(this,ln),[])}};Xt=new WeakMap,Yt=new WeakMap,ln=new WeakMap;let so=zn;function ba(){return typeof performance<"u"&&Tt(performance.now)?performance.now():Date.now()}class Su{constructor(e,r){D(this,bs);D(this,qs);D(this,Ns);D(this,vs);D(this,di);D(this,jt,void 0);D(this,Sn,void 0);D(this,un,void 0);D(this,Vn,void 0);D(this,ci,new WeakSet);G(this,jt,e),G(this,Sn,r)}async init(){o(this,un)||G(this,un,o(this,jt).init().catch(e=>(G(this,un,void 0),Promise.reject(e)))),await o(this,un)}async acquireConnection(){await this.init();const e=await o(this,jt).acquireConnection();return o(this,ci).has(e)||(Ae(this,bs,Xa).call(this)&&Ae(this,qs,Ya).call(this,e),o(this,ci).add(e)),e}async releaseConnection(e){await o(this,jt).releaseConnection(e)}beginTransaction(e,r){return o(this,jt).beginTransaction(e,r)}commitTransaction(e){return o(this,jt).commitTransaction(e)}rollbackTransaction(e){return o(this,jt).rollbackTransaction(e)}async destroy(){o(this,un)&&(await o(this,un),o(this,Vn)||G(this,Vn,o(this,jt).destroy().catch(e=>(G(this,Vn,void 0),Promise.reject(e)))),await o(this,Vn))}}jt=new WeakMap,Sn=new WeakMap,un=new WeakMap,Vn=new WeakMap,ci=new WeakMap,bs=new WeakSet,Xa=function(){return o(this,Sn).isLevelEnabled("query")||o(this,Sn).isLevelEnabled("error")},qs=new WeakSet,Ya=function(e){const r=e.executeQuery;e.executeQuery=async n=>{const A=ba();try{return await r.call(e,n)}catch(V){throw await Ae(this,Ns,Za).call(this,V,n,A),V}finally{await Ae(this,vs,el).call(this,n,A)}}},Ns=new WeakSet,Za=async function(e,r,n){await o(this,Sn).error(()=>({level:"error",error:e,query:r,queryDurationMillis:Ae(this,di,xo).call(this,n)}))},vs=new WeakSet,el=async function(e,r){await o(this,Sn).query(()=>({level:"query",query:e,queryDurationMillis:Ae(this,di,xo).call(this,r)}))},di=new WeakSet,xo=function(e){return ba()-e};class qa{constructor(e){D(this,xs);D(this,fi,void 0);D(this,kn,void 0);G(this,fi,e)}async provideConnection(e){for(;o(this,kn);)await o(this,kn);const r=Ae(this,xs,tl).call(this,e);return G(this,kn,r.then(()=>{G(this,kn,void 0)}).catch(()=>{G(this,kn,void 0)})),r}}fi=new WeakMap,kn=new WeakMap,xs=new WeakSet,tl=async function(e){return await e(o(this,fi))};const ku=["read uncommitted","read committed","repeatable read","serializable"];h(["query","error"]);class Ou{constructor(e){D(this,On,void 0);D(this,Jn,void 0);Tt(e)?(G(this,Jn,e),G(this,On,h({query:!0,error:!0}))):(G(this,Jn,Au),G(this,On,h({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return o(this,On)[e]}async query(e){o(this,On).query&&await o(this,Jn).call(this,e())}async error(e){o(this,On).error&&await o(this,Jn).call(this,e())}}On=new WeakMap,Jn=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 Iu(t){return Jt(t)&&Tt(t.compile)}const vr=class vr extends Bi{constructor(r){let n,A;if(Tu(r))n={executor:r.executor},A={...r};else{const V=r.dialect,Y=V.createDriver(),pe=V.createQueryCompiler(),Ie=V.createAdapter(),ct=new Ou(r.log??[]),Ze=new Su(Y,ct),et=new Eu(Ze),se=new so(pe,Ie,et,r.plugins??[]);n={executor:se},A={config:r,executor:se,dialect:V,driver:Ze}}super(n);D(this,ut,void 0);G(this,ut,h(A))}get schema(){return new io(o(this,ut).executor)}get dynamic(){return new xu}get introspection(){return o(this,ut).dialect.createIntrospector(this.withoutPlugins())}case(r){return new sa({node:$t.create(Te(r)?void 0:Mi(r))})}get fn(){return ia()}transaction(){return new os({...o(this,ut)})}connection(){return new Na({...o(this,ut)})}withPlugin(r){return new vr({...o(this,ut),executor:o(this,ut).executor.withPlugin(r)})}withoutPlugins(){return new vr({...o(this,ut),executor:o(this,ut).executor.withoutPlugins()})}withSchema(r){return new vr({...o(this,ut),executor:o(this,ut).executor.withPluginAtFront(new Ur(r))})}withTables(){return new vr({...o(this,ut)})}async destroy(){await o(this,ut).driver.destroy()}get isTransaction(){return!1}getExecutor(){return o(this,ut).executor}executeQuery(r,n=Fe()){const A=Iu(r)?r.compile():r;return this.getExecutor().executeQuery(A,n)}};ut=new WeakMap;let Kr=vr;const xr=class xr extends Kr{constructor(r){super(r);D(this,zt,void 0);G(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 xr({...o(this,zt),executor:o(this,zt).executor.withPlugin(r)})}withoutPlugins(){return new xr({...o(this,zt),executor:o(this,zt).executor.withoutPlugins()})}withSchema(r){return new xr({...o(this,zt),executor:o(this,zt).executor.withPluginAtFront(new Ur(r))})}withTables(){return new xr({...o(this,zt)})}};zt=new WeakMap;let oo=xr;function Tu(t){return Jt(t)&&Jt(t.config)&&Jt(t.driver)&&Jt(t.executor)&&Jt(t.dialect)}class Na{constructor(e){D(this,Gn,void 0);G(this,Gn,h(e))}async execute(e){return o(this,Gn).executor.provideConnection(async r=>{const n=o(this,Gn).executor.withConnectionProvider(new qa(r)),A=new Kr({...o(this,Gn),executor:n});return await e(A)})}}Gn=new WeakMap,Se(Na,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const ho=class ho{constructor(e){D(this,Vt,void 0);G(this,Vt,h(e))}setIsolationLevel(e){return new ho({...o(this,Vt),isolationLevel:e})}async execute(e){const{isolationLevel:r,...n}=o(this,Vt),A={isolationLevel:r};return Cu(A),o(this,Vt).executor.provideConnection(async V=>{const Y=o(this,Vt).executor.withConnectionProvider(new qa(V)),pe=new oo({...n,executor:Y});try{await o(this,Vt).driver.beginTransaction(V,A);const Ie=await e(pe);return await o(this,Vt).driver.commitTransaction(V),Ie}catch(Ie){throw await o(this,Vt).driver.rollbackTransaction(V),Ie}})}};Vt=new WeakMap;let os=ho;Se(os,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function Cu(t){if(t.isolationLevel&&!ku.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const Es=class Es{constructor(e){D(this,Er);D(this,hi);D(this,pi);D(this,vt,void 0);G(this,vt,h(e))}get expressionType(){}as(e){return new Pu(this,e)}$castTo(){return new Es({...o(this,vt)})}castTo(){return this.$castTo()}withPlugin(e){return new Es({...o(this,vt),plugins:o(this,vt).plugins!==void 0?h([...o(this,vt).plugins,e]):h([e])})}toOperationNode(){return Ae(this,hi,Eo).call(this,Ae(this,Er,Ps).call(this))}compile(e){return Ae(this,pi,So).call(this,Ae(this,Er,Ps).call(this,e))}async execute(e){const r=Ae(this,Er,Ps).call(this,e);return r.executeQuery(Ae(this,pi,So).call(this,r),o(this,vt).queryId)}};vt=new WeakMap,Er=new WeakSet,Ps=function(e){const r=e!==void 0?e.getExecutor():$s;return o(this,vt).plugins!==void 0?r.withPlugins(o(this,vt).plugins):r},hi=new WeakSet,Eo=function(e){return e.transformQuery(o(this,vt).rawNode,o(this,vt).queryId)},pi=new WeakSet,So=function(e){return e.compileQuery(Ae(this,hi,Eo).call(this,e),o(this,vt).queryId)};let Bt=Es;Se(Bt,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class Pu{constructor(e,r){D(this,Sr,void 0);D(this,An,void 0);G(this,Sr,e),G(this,An,r)}get expression(){return o(this,Sr)}get alias(){return o(this,An)}toOperationNode(){return _n.create(o(this,Sr).toOperationNode(),Ct(o(this,An))?o(this,An).toOperationNode():Ue.create(o(this,An)))}}Sr=new WeakMap,An=new WeakMap;const Et=Object.assign((t,...e)=>new Bt({queryId:Fe(),rawNode:pt.create(t,(e==null?void 0:e.map(rn))??[])}),{ref(t){return new Bt({queryId:Fe(),rawNode:pt.createWithChild(Pn(t))})},val(t){return new Bt({queryId:Fe(),rawNode:pt.createWithChild(rn(t))})},value(t){return this.val(t)},table(t){return new Bt({queryId:Fe(),rawNode:pt.createWithChild(Nt(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new Bt({queryId:Fe(),rawNode:pt.create(e,t.map(Ue.create))})},lit(t){return new Bt({queryId:Fe(),rawNode:pt.createWithChild(Rt.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new Bt({queryId:Fe(),rawNode:pt.createWithSql(t)})},join(t,e=Et`, `){const r=new Array(2*t.length-1),n=e.toOperationNode();for(let A=0;A{this.nodeStack.push(e),o(this,Ss)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Ss=new WeakMap;class Fu extends Wu{constructor(){super(...arguments);D(this,kr,"");D(this,$n,[])}get numParameters(){return o(this,$n).length}compileQuery(r){return G(this,kr,""),G(this,$n,[]),this.visitNode(r),h({query:r,sql:this.getSql(),parameters:[...o(this,$n)]})}getSql(){return o(this,kr)}visitSelectQuery(r){const n=this.parentNode!==void 0&&!Gt.is(this.parentNode)&&!wn.is(this.parentNode)&&!ra.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 V=0;V<=A;V++)this.visitNode(r[V]),VV&&this.visitNode(A[V])}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(ye.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(Lu[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 Wr.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))}visitJSONReference(r){this.visitNode(r.reference),this.visitNode(r.traversal)}visitJSONPath(r){r.inOperator&&this.visitNode(r.inOperator),this.append("'$");for(const n of r.pathLegs)this.visitNode(n);this.append("'")}visitJSONPathLeg(r){const n=r.type==="ArrayLocation";this.append(n?"[":"."),this.append(String(r.value)),n&&this.append("]")}visitJSONOperatorChain(r){for(let n=0,A=r.values.length;n"),this.visitNode(r.values[n])}append(r){G(this,kr,o(this,kr)+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 V="";for(const Y of r)V+=Y,Y===n?V+=n:Y===A&&(V+=A);return V}addParameter(r){o(this,$n).push(r)}appendImmediateValue(r){if(we(r))this.append(`'${r}'`);else if(He(r)||Tr(r))this.append(r.toString());else if(ko(r))this.append("null");else if(rl(r))this.appendImmediateValue(r.toISOString());else if(il(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}kr=new WeakMap,$n=new WeakMap;const Lu=h({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),Du=h({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),bn=h({raw(t,e=[]){return h({sql:t,query:pt.createWithSql(t),parameters:h(e)})}}),Ru=/"/g;class Bu extends Fu{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(Ru,'""')}visitDefaultInsertValue(e){this.append("null")}}const Mu="kysely_migration",Uu="kysely_migration_lock";h({__noMigrations__:!0});class Qu{constructor(e){D(this,ks);D(this,Or,void 0);G(this,Or,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=o(this,Or).selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",Mu).where("name","!=",Uu));const n=await r.execute();return Promise.all(n.map(({name:A})=>Ae(this,ks,nl).call(this,A)))}async getMetadata(e){return{tables:await this.getTables(e)}}}Or=new WeakMap,ks=new WeakSet,nl=async function(e){var Y,pe,Ie,ct,Ze,et;const r=o(this,Or),n=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),A=(et=(Ze=(ct=(Ie=(pe=(Y=n.sql)==null?void 0:Y.split(/[\(\),]/))==null?void 0:pe.find(se=>se.toLowerCase().includes("autoincrement")))==null?void 0:Ie.trimStart())==null?void 0:ct.split(/\s+/))==null?void 0:Ze[0])==null?void 0:et.replace(/["`]/g,""),V=await r.selectFrom(Et`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:n.type==="view",columns:V.map(se=>({name:se.name,dataType:se.type,isNullable:!se.notnull,isAutoIncrementing:se.name===A,hasDefaultValue:se.dflt_value!=null}))}};class ju{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var zu=class{createQueryCompiler(){return new Bu}createAdapter(){return new ju}createIntrospector(t){return new Qu(t)}},Vu=(xa=class{constructor(){D(this,_i,new Ju);xe(this,"connection")}async acquireConnection(){return await o(this,_i).lock(),this.connection}async beginTransaction(t){await t.executeQuery(bn.raw("begin"))}async commitTransaction(t){await t.executeQuery(bn.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(bn.raw("rollback"))}async releaseConnection(){o(this,_i).unlock()}},_i=new WeakMap,xa),Ju=class{constructor(){xe(this,"promise");xe(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()}},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)}}},$u=class extends Vu{constructor(e){super();xe(this,"config");xe(this,"db");this.config=e}async init(){var e,r;this.db=typeof this.config.database=="function"?await this.config.database():this.config.database,this.connection=new Hu(this.db),await((r=(e=this.config).onCreateConnection)==null?void 0:r.call(e,this.connection))}async destroy(){var e;(e=this.db)==null||e.close()}},Hu=class extends Gu{constructor(e){super();xe(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)}}},Ku=(Ea=class extends zu{constructor(e){super();D(this,mi,void 0);G(this,mi,e)}createDriver(){return new $u(o(this,mi))}},mi=new WeakMap,Ea);async function Xu(t,e=4096,r=32*1024){await t.executeQuery(bn.raw(`PRAGMA cache_size = ${e};`)),await t.executeQuery(bn.raw("PRAGMA journal_mode = WAL;")),await t.executeQuery(bn.raw("PRAGMA temp_store = MEMORY;")),await t.executeQuery(bn.raw(`PRAGMA page_size = ${r};`)),await t.executeQuery(bn.raw("PRAGMA synchronous = NORMAL;"))}var Yu=(()=>{var t=self.location.href;return function(e){var r=e||{},n=typeof r<"u"?r:{},A,V;n.ready=new Promise(function(s,i){A=s,V=i});const Y=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:()=>{}});delete globalThis.sqlite3InitModuleState,Y.debugModule("globalThis.location =",globalThis.location);const pe="emscripten-bug-17951";n[pe]=function s(i,l){i.env.foo=function(){};const a=n.locateFile(s.uri,typeof se>"u"?"":se);Y.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[pe].uri="sqlite3.wasm";var Ie=Object.assign({},n),ct="./this.program",Ze=typeof window=="object",et=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var se="";function Wt(s){return n.locateFile?n.locateFile(s,se):se+s}var Me,cn,yi;(Ze||et)&&(et?se=self.location.href:typeof document<"u"&&document.currentScript&&(se=document.currentScript.src),t&&(se=t),se.indexOf("blob:")!==0?se=se.substr(0,se.replace(/[?#].*/,"").lastIndexOf("/")+1):se="",Me=s=>{var i=new XMLHttpRequest;return i.open("GET",s,!1),i.send(null),i.responseText},et&&(yi=s=>{var i=new XMLHttpRequest;return i.open("GET",s,!1),i.responseType="arraybuffer",i.send(null),new Uint8Array(i.response)}),cn=(s,i,l)=>{var a=new XMLHttpRequest;a.open("GET",s,!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 dn=n.print||console.log.bind(console),gt=n.printErr||console.warn.bind(console);Object.assign(n,Ie),Ie=null,n.arguments&&n.arguments,n.thisProgram&&(ct=n.thisProgram),n.quit&&n.quit;var gi;n.wasmBinary&&(gi=n.wasmBinary),n.noExitRuntime,typeof WebAssembly!="object"&&Kn("no native wasm support detected");var In,Sa=!1;function dc(s,i){s||Kn(i)}var ka=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Ar(s,i,l){for(var a=i+l,u=i;s[u]&&!(u>=a);)++u;if(u-i>16&&s.buffer&&ka)return ka.decode(s.subarray(i,u));for(var d="";i>10,56320|z&1023)}}return d}function fc(s,i){return s?Ar(bi,s,i):""}function Os(s,i,l,a){if(!(a>0))return 0;for(var u=l,d=l+a-1,N=0;N=55296&&S<=57343){var C=s.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 Oa(s,i,l){return Os(s,bi,i,l)}function wi(s){for(var i=0,l=0;l=55296&&a<=57343?(i+=4,++l):i+=3}return i}var It,bi,Aa,me,tt;function Ia(){var s=In.buffer;n.HEAP8=It=new Int8Array(s),n.HEAP16=Aa=new Int16Array(s),n.HEAP32=me=new Int32Array(s),n.HEAPU8=bi=new Uint8Array(s),n.HEAPU16=new Uint16Array(s),n.HEAPU32=tt=new Uint32Array(s),n.HEAPF32=new Float32Array(s),n.HEAPF64=new Float64Array(s),n.HEAP64=new BigInt64Array(s),n.HEAPU64=new BigUint64Array(s)}var Ta=n.INITIAL_MEMORY||16777216;n.wasmMemory?In=n.wasmMemory:In=new WebAssembly.Memory({initial:Ta/65536,maximum:2147483648/65536}),Ia(),Ta=In.buffer.byteLength;var Ca=[],Pa=[],Wa=[];function hc(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)mc(n.preRun.shift());_o(Ca)}function pc(){!n.noFSInit&&!c.init.initialized&&c.init(),c.ignorePermissions=!1,_o(Pa)}function _c(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)gc(n.postRun.shift());_o(Wa)}function mc(s){Ca.unshift(s)}function yc(s){Pa.unshift(s)}function gc(s){Wa.unshift(s)}var Hn=0,qi=null;function Nd(s){return s}function po(s){Hn++,n.monitorRunDependencies&&n.monitorRunDependencies(Hn)}function As(s){if(Hn--,n.monitorRunDependencies&&n.monitorRunDependencies(Hn),Hn==0&&qi){var i=qi;qi=null,i()}}function Kn(s){n.onAbort&&n.onAbort(s),s="Aborted("+s+")",gt(s),Sa=!0,s+=". Build with -sASSERTIONS for more info.";var i=new WebAssembly.RuntimeError(s);throw V(i),i}var wc="data:application/octet-stream;base64,";function Fa(s){return s.startsWith(wc)}var Ft;n.locateFile?(Ft="sqlite3.wasm",Fa(Ft)||(Ft=Wt(Ft))):Ft=new URL(""+new URL("sqlite3-14470338.wasm",self.location.href).href,self.location).href;function La(s){try{if(s==Ft&&gi)return new Uint8Array(gi);if(yi)return yi(s);throw"both async and sync fetching of the wasm failed"}catch(i){Kn(i)}}function bc(){return!gi&&(Ze||et)&&typeof fetch=="function"?fetch(Ft,{credentials:"same-origin"}).then(function(s){if(!s.ok)throw"failed to load wasm binary file at '"+Ft+"'";return s.arrayBuffer()}).catch(function(){return La(Ft)}):Promise.resolve().then(function(){return La(Ft)})}function qc(){var s={env:Qa,wasi_snapshot_preview1:Qa};function i(N,S){var C=N.exports;n.asm=C,n.asm.__indirect_function_table,yc(n.asm.__wasm_call_ctors),As()}po();function l(N){i(N.instance)}function a(N){return bc().then(function(S){return WebAssembly.instantiate(S,s)}).then(function(S){return S}).then(N,function(S){gt("failed to asynchronously prepare wasm: "+S),Kn(S)})}function u(){return!gi&&typeof WebAssembly.instantiateStreaming=="function"&&!Fa(Ft)&&typeof fetch=="function"?fetch(Ft,{credentials:"same-origin"}).then(function(N){var S=WebAssembly.instantiateStreaming(N,s);return S.then(l,function(C){return gt("wasm streaming compile failed: "+C),gt("falling back to ArrayBuffer instantiation"),a(l)})}):a(l)}if(n.instantiateWasm)try{var d=n.instantiateWasm(s,i);return d}catch(N){gt("Module.instantiateWasm callback failed with error: "+N),V(N)}return u().catch(V),{}}var ge,st;function _o(s){for(;s.length>0;)s.shift()(n)}var ve={isAbs:s=>s.charAt(0)==="/",splitPath:s=>{var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return i.exec(s).slice(1)},normalizeArray:(s,i)=>{for(var l=0,a=s.length-1;a>=0;a--){var u=s[a];u==="."?s.splice(a,1):u===".."?(s.splice(a,1),l++):l&&(s.splice(a,1),l--)}if(i)for(;l;l--)s.unshift("..");return s},normalize:s=>{var i=ve.isAbs(s),l=s.substr(-1)==="/";return s=ve.normalizeArray(s.split("/").filter(a=>!!a),!i).join("/"),!s&&!i&&(s="."),s&&l&&(s+="/"),(i?"/":"")+s},dirname:s=>{var i=ve.splitPath(s),l=i[0],a=i[1];return!l&&!a?".":(a&&(a=a.substr(0,a.length-1)),l+a)},basename:s=>{if(s==="/")return"/";s=ve.normalize(s),s=s.replace(/\/$/,"");var i=s.lastIndexOf("/");return i===-1?s:s.substr(i+1)},join:function(){var s=Array.prototype.slice.call(arguments);return ve.normalize(s.join("/"))},join2:(s,i)=>ve.normalize(s+"/"+i)};function Nc(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var s=new Uint8Array(1);return()=>(crypto.getRandomValues(s),s[0])}else return()=>Kn("randomDevice")}var fn={resolve:function(){for(var s="",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"";s=a+"/"+s,i=ve.isAbs(a)}return s=ve.normalizeArray(s.split("/").filter(u=>!!u),!i).join("/"),(i?"/":"")+s||"."},relative:(s,i)=>{s=fn.resolve(s).substr(1),i=fn.resolve(i).substr(1);function l(z){for(var K=0;K=0&&z[te]==="";te--);return K>te?[]:z.slice(K,te-K+1)}for(var a=l(s.split("/")),u=l(i.split("/")),d=Math.min(a.length,u.length),N=d,S=0;S0?l:wi(s)+1,u=new Array(a),d=Os(s,u,0,u.length);return i&&(u.length=d),u}var Xn={ttys:[],init:function(){},shutdown:function(){},register:function(s,i){Xn.ttys[s]={input:[],output:[],ops:i},c.registerDevice(s,Xn.stream_ops)},stream_ops:{open:function(s){var i=Xn.ttys[s.node.rdev];if(!i)throw new c.ErrnoError(43);s.tty=i,s.seekable=!1},close:function(s){s.tty.ops.fsync(s.tty)},fsync:function(s){s.tty.ops.fsync(s.tty)},read:function(s,i,l,a,u){if(!s.tty||!s.tty.ops.get_char)throw new c.ErrnoError(60);for(var d=0,N=0;Nge in Ie?vd(Ie,ge,{enumerable:!0,configurable:!0,writable:!0,value:Ke}):Ie[ge]=Ke;var ve=(Ie,ge,Ke)=>(xd(Ie,typeof ge!="symbol"?ge+"":ge,Ke),Ke),qo=(Ie,ge,Ke)=>{if(!ge.has(Ie))throw TypeError("Cannot "+Ke)};var o=(Ie,ge,Ke)=>(qo(Ie,ge,"read from private field"),Ke?Ke.call(Ie):ge.get(Ie)),D=(Ie,ge,Ke)=>{if(ge.has(Ie))throw TypeError("Cannot add the same private member more than once");ge instanceof WeakSet?ge.add(Ie):ge.set(Ie,Ke)},G=(Ie,ge,Ke,Wr)=>(qo(Ie,ge,"write to private field"),Wr?Wr.call(Ie,Ke):ge.set(Ie,Ke),Ke);var Oe=(Ie,ge,Ke)=>(qo(Ie,ge,"access private method"),Ke);(function(){var Bt,Wn,lr,Le,ti,Ut,pe,oe,ue,ur,cs,cr,Fn,Ln,ds,$a,fs,Ka,hs,Xa,Dn,Ei,ri,No,ps,Ya,ii,De,si,dr,fr,Mn,oi,vo,U,hr,pr,bn,_r,qn,Bn,Un,Et,yr,gr,wr,br,$t,qr,Nn,ai,xo,Nr,vr,vn,Pe,Qn,ln,li,Qt,ht,Ze,Me,$e,We,St,Se,at,mt,yt,qs,Qe,lt,kt,At,it,xr,Xt,Yt,un,jt,En,cn,Vn,hi,Ns,Za,vs,el,xs,tl,Es,nl,pi,Eo,_i,Sn,Ss,rl,kn,Jn,ut,zt,Gn,Vt,Nt,kr,Fs,mi,So,yi,ko,Ar,An,As,Or,Hn,Ir,Os,il,gi,ka,wi,Aa;"use strict";function Ie(t){return typeof t>"u"||t===void 0}function ge(t){return typeof t=="string"}function Ke(t){return typeof t=="number"}function Wr(t){return typeof t=="boolean"}function Ao(t){return t===null}function sl(t){return t instanceof Date}function ol(t){return typeof t=="bigint"}function Ct(t){return typeof t=="function"}function Jt(t){return typeof t=="object"&&t!==null}function h(t){return Object.freeze(t)}function Fr(t){return Array.isArray(t)}function er(t){return t}const Xe=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]})}}),Ue=h({is(t){return t.kind==="IdentifierNode"},create(t){return h({kind:"IdentifierNode",name:t})}}),fn=h({is(t){return t.kind==="CreateIndexNode"},create(t){return h({kind:"CreateIndexNode",name:Ue.create(t)})},cloneWith(t,e){return h({...t,...e})},cloneWithColumns(t,e){return h({...t,columns:[...t.columns||[],...e]})}}),Oo=h({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return h({kind:"CreateSchemaNode",schema:Ue.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),al=["preserve rows","delete rows","drop"],Dt=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})}}),hn=h({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return h({kind:"SchemableIdentifierNode",identifier:Ue.create(t)})},createWithSchema(t,e){return h({kind:"SchemableIdentifierNode",schema:Ue.create(t),identifier:Ue.create(e)})}}),Si=h({is(t){return t.kind==="DropIndexNode"},create(t,e){return h({kind:"DropIndexNode",name:hn.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),Ls=h({is(t){return t.kind==="DropSchemaNode"},create(t,e){return h({kind:"DropSchemaNode",schema:Ue.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),Ds=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})}}),_n=h({is(t){return t.kind==="TableNode"},create(t){return h({kind:"TableNode",table:hn.create(t)})},createWithSchema(t,e){return h({kind:"TableNode",table:hn.createWithSchema(t,e)})}});function Pt(t){return Jt(t)&&Ct(t.toOperationNode)}function Rs(t){return Jt(t)&&"expressionType"in t&&Pt(t)}function ll(t){return Jt(t)&&"expression"in t&&ge(t.alias)&&Pt(t)}const nn=h({is(t){return t.kind==="SelectModifierNode"},create(t){return h({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return h({kind:"SelectModifierNode",rawModifier:t})}}),Tn=h({is(t){return t.kind==="AndNode"},create(t,e){return h({kind:"AndNode",left:t,right:e})}}),Cn=h({is(t){return t.kind==="OrNode"},create(t,e){return h({kind:"OrNode",left:t,right:e})}}),Ms=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"?Tn.create(t.on,r):Cn.create(t.on,r)})}}),Lr=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:Ms.create(r)})},cloneWithOn(t,e){return h({...t,on:t.on?Ms.cloneWithOperation(t.on,"And",e):Ms.create(e)})}}),Bs=h({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return h({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),Io=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp"],ul=["+","-","*","/","%","^","&","|","#","<<",">>"],To=["->","->>"],Co=[...Io,...ul,"&&","||"],cl=["not","-",...["exists","not exists"]],dl=[...Co,...To,...cl],Dr=h({is(t){return t.kind==="OperatorNode"},create(t){return h({kind:"OperatorNode",operator:t})}});function fl(t){return ge(t)&&Co.includes(t)}function hl(t){return ge(t)&&Io.includes(t)}function Po(t){return ge(t)&&To.includes(t)}const Je=h({is(t){return t.kind==="ColumnNode"},create(t){return h({kind:"ColumnNode",column:Ue.create(t)})}}),Us=h({is(t){return t.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}}),ki=h({is(t){return t.kind==="ReferenceNode"},create(t,e){return h({kind:"ReferenceNode",table:e,column:t})},createSelectAll(t){return h({kind:"ReferenceNode",table:t,column:Us.create()})}}),pl=h({is(t){return t.kind==="OrderByItemNode"},create(t,e){return h({kind:"OrderByItemNode",orderBy:t,direction:e})}}),pt=h({is(t){return t.kind==="RawNode"},create(t,e){return h({kind:"RawNode",sqlFragments:h(t),parameters:h(e)})},createWithSql(t){return pt.create([t],[])},createWithChild(t){return pt.create(["",""],[t])},createWithChildren(t){return pt.create(new Array(t.length+1).fill(""),t)}});function _l(t){return t==="asc"||t==="desc"}function Ai(t,e){return pl.create(ml(t),yl(e))}function ml(t){return rn(t)}function yl(t){if(t)return t==="asc"||t==="desc"?pt.createWithSql(t):t.toOperationNode()}const Qs=h({is(t){return t.kind==="JSONReferenceNode"},create(t,e){return h({kind:"JSONReferenceNode",reference:t,traversal:e})},cloneWithTraversal(t,e){return h({...t,traversal:e})}}),Wo=h({is(t){return t.kind==="JSONOperatorChainNode"},create(t){return h({kind:"JSONOperatorChainNode",operator:t,values:h([])})},cloneWithValue(t,e){return h({...t,values:h([...t.values,e])})}}),js=h({is(t){return t.kind==="JSONPathNode"},create(t){return h({kind:"JSONPathNode",inOperator:t,pathLegs:h([])})},cloneWithLeg(t,e){return h({...t,pathLegs:h([...t.pathLegs,e])})}});function Fo(t){return ge(t)?Pn(t):t.toOperationNode()}function Rr(t){return Fr(t)?t.map(e=>rn(e)):[rn(t)]}function rn(t){return ji(t)?Qi(t):Fo(t)}function gl(t,e){const r=Pn(t);if(Po(e))return Qs.create(r,Wo.create(Dr.create(e)));const n=e.slice(0,-1);if(Po(n))return Qs.create(r,js.create(Dr.create(n)));throw new Error(`Invalid JSON operator: ${e}`)}function Pn(t){const e=".";if(!t.includes(e))return ki.create(Je.create(t));const r=t.split(e).map(zs);if(r.length===3)return bl(r);if(r.length===2)return ql(r);throw new Error(`invalid column reference ${t}`)}function wl(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(zs);return pn.create(Pn(r),Ue.create(n))}else return Pn(t)}function Lo(t){return Je.create(t)}function Do(t){const e=" ";if(t.includes(e)){const[r,n]=t.split(e).map(zs);if(!_l(n))throw new Error(`invalid order direction "${n}" next to "${r}"`);return Ai(r,n)}else return Lo(t)}function bl(t){const[e,r,n]=t;return ki.create(Je.create(n),_n.createWithSchema(e,r))}function ql(t){const[e,r]=t;return ki.create(Je.create(r),_n.create(e))}function zs(t){return t.trim()}const Ro=h({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return h({kind:"PrimitiveValueListNode",values:h([...t])})}}),Vs=h({is(t){return t.kind==="ValueListNode"},create(t){return h({kind:"ValueListNode",values:h(t)})}}),Rt=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 Mo(t){return Fr(t)?Nl(t):sn(t)}function sn(t){return ji(t)?Qi(t):Rt.create(t)}function Nl(t){return t.some(ji)?Vs.create(t.map(e=>sn(e))):Ro.create(t)}function _t(t){if(t.length>1&&!Qo(t[1]))throw new Error(`invalid comparison operator ${JSON.stringify(t[1])}`);return Bo(t)}function Bo(t){if(t.length===3)return Oi(t[0],t[1],t[2]);if(t.length===1)return kl(t[0]);throw new Error(`invalid arguments: ${JSON.stringify(t)}`)}function Oi(t,e,r){if(!Uo(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return xl(e)&&El(r)?Sl(t,e,r):Bs.create(rn(t),Js(e),Mo(r))}function on(t,e,r){if(!Qo(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return vl(t,e,r)}function vl(t,e,r){if(!Uo(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Bs.create(rn(t),Js(e),rn(r))}function Uo(t){return fl(t)||Rs(t)}function Qo(t){return hl(t)||Rs(t)}function xl(t){return t==="is"||t==="is not"}function El(t){return Ao(t)||Wr(t)}function Sl(t,e,r){return Bs.create(rn(t),Js(e),Rt.createImmediate(r))}function Js(t){if(ge(t)&&dl.includes(t))return Dr.create(t);if(Pt(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function kl(t){return Ct(t)?t(no()).toOperationNode():Pt(t)?t.toOperationNode():Rt.create(t)}const tr=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])})}}),jo=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?tr.cloneWithItem(t.orderBy,e):tr.create(e)})},cloneWithPartitionByItems(t,e){return h({...t,partitionBy:t.partitionBy?jo.cloneWithItems(t.partitionBy,e):jo.create(e)})}}),Ii=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])})}}),zo=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])})}}),Vo=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"?Tn.create(t.having,r):Cn.create(t.having,r)})}}),xe=h({is(t){return t.kind==="SelectQueryNode"},create(t,e){return h({kind:"SelectQueryNode",from:Ii.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?tr.cloneWithItem(t.orderBy,e):tr.create(e)})},cloneWithGroupByItems(t,e){return h({...t,groupBy:t.groupBy?zo.cloneWithItems(t.groupBy,e):zo.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?Vo.cloneWithOperation(t.having,"And",e):Vo.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})}});function Ee(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}const ei=class ei{constructor(e){D(this,Bt,void 0);G(this,Bt,h(e))}on(...e){return new ei({...o(this,Bt),joinNode:Lr.cloneWithOn(o(this,Bt).joinNode,_t(e))})}onRef(e,r,n){return new ei({...o(this,Bt),joinNode:Lr.cloneWithOn(o(this,Bt).joinNode,on(e,r,n))})}onTrue(){return new ei({...o(this,Bt),joinNode:Lr.cloneWithOn(o(this,Bt).joinNode,pt.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return o(this,Bt).joinNode}};Bt=new WeakMap;let Ti=ei;Ee(Ti,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const Al=h({is(t){return t.kind==="PartitionByItemNode"},create(t){return h({kind:"PartitionByItemNode",partitionBy:t})}});function Ol(t){return Rr(t).map(Al.create)}const us=class us{constructor(e){D(this,Wn,void 0);G(this,Wn,h(e))}orderBy(e,r){return new us({overNode:Gs.cloneWithOrderByItem(o(this,Wn).overNode,Ai(e,r))})}partitionBy(e){return new us({overNode:Gs.cloneWithPartitionByItems(o(this,Wn).overNode,Ol(e))})}$call(e){return e(this)}toOperationNode(){return o(this,Wn).overNode}};Wn=new WeakMap;let Ci=us;Ee(Ci,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const Mr=h({is(t){return t.kind==="SelectionNode"},create(t){return h({kind:"SelectionNode",selection:t})},createSelectAll(){return h({kind:"SelectionNode",selection:Us.create()})},createSelectAllFromTable(t){return h({kind:"SelectionNode",selection:ki.createSelectAll(t)})}});class Il{constructor(e){D(this,lr,void 0);G(this,lr,e)}get dynamicReference(){return o(this,lr)}get refType(){}toOperationNode(){return Fo(o(this,lr))}}lr=new WeakMap;function Tl(t){return Jt(t)&&Pt(t)&&ge(t.dynamicReference)}function Br(t){return Ct(t)?Br(t(or())):Fr(t)?t.map(e=>Jo(e)):[Jo(t)]}function Jo(t){return ge(t)?Mr.create(wl(t)):Tl(t)?Mr.create(t.toOperationNode()):Mr.create(la(t))}function Ur(t){return t?Array.isArray(t)?t.map(Go):[Go(t)]:[Mr.createSelectAll()]}function Go(t){if(ge(t))return Mr.createSelectAllFromTable(qt(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const Cl=h({is(t){return t.kind==="ValuesNode"},create(t){return h({kind:"ValuesNode",values:h(t)})}}),Pl=h({is(t){return t.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function Wl(t){const e=Ct(t)?t(or()):t,r=Fr(e)?e:h([e]);return Fl(r)}function Fl(t){const e=Ll(t);return[h([...e.keys()].map(Je.create)),Cl.create(t.map(r=>Dl(r,e)))]}function Ll(t){const e=new Map;for(const r of t){const n=Object.keys(r);for(const O of n)!e.has(O)&&r[O]!==void 0&&e.set(O,e.size)}return e}function Dl(t,e){const r=Object.keys(t),n=Array.from({length:e.size});let O=!1;for(const Y of r){const he=e.get(Y);if(Ie(he))continue;const Te=t[Y];(Ie(Te)||ji(Te))&&(O=!0),n[he]=Te}if(r.lengthIe(he)?Y:sn(he)))}return Ro.create(n)}const Gt=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})}}),Pi=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?Ii.cloneWithFroms(t.from,e):Ii.create(e)})},cloneWithUpdates(t,e){return h({...t,updates:t.updates?h([...t.updates,...e]):e})}}),Ho=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])})}}),Qr=h({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return h({kind:"DeleteQueryNode",from:Ii.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return h({...t,orderBy:t.orderBy?tr.cloneWithItem(t.orderBy,e):tr.create(e)})},cloneWithLimit(t,e){return h({...t,limit:e})},cloneWithUsing(t,e){return h({...t,using:t.using!==void 0?Ho.cloneWithTables(t.using,e):Ho.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"?Tn.create(t.where,r):Cn.create(t.where,r)})}}),$o=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)})}}),Rl=h({is(t){return t.kind==="ExplainNode"},create(t,e){return h({kind:"ExplainNode",format:t,options:e})}}),me=h({is(t){return xe.is(t)||Gt.is(t)||Pi.is(t)||Qr.is(t)},cloneWithWhere(t,e){return h({...t,where:t.where?wt.cloneWithOperation(t.where,"And",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?$o.cloneWithSelections(t.returning,e):$o.create(e)})},cloneWithoutWhere(t){return h({...t,where:void 0})},cloneWithExplain(t,e,r){return h({...t,explain:Rl.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 Hs(t){const e=Ct(t)?t(or()):t;return Object.entries(e).filter(([r,n])=>n!==void 0).map(([r,n])=>Ml.create(Je.create(r),sn(n)))}const Bl=h({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return h({kind:"OnDuplicateKeyNode",updates:t})}});class Ul{constructor(e,r){ve(this,"insertId");ve(this,"numInsertedOrUpdatedRows");this.insertId=e,this.numInsertedOrUpdatedRows=r}}class Wi extends Error{constructor(r){super("no result");ve(this,"node");this.node=r}}function Fi(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const vt=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})}}),an=class an{constructor(e){D(this,Le,void 0);G(this,Le,h(e))}column(e){const r=Je.create(e);return new an({...o(this,Le),onConflictNode:vt.cloneWith(o(this,Le).onConflictNode,{columns:o(this,Le).onConflictNode.columns?h([...o(this,Le).onConflictNode.columns,r]):h([r])})})}columns(e){const r=e.map(Je.create);return new an({...o(this,Le),onConflictNode:vt.cloneWith(o(this,Le).onConflictNode,{columns:o(this,Le).onConflictNode.columns?h([...o(this,Le).onConflictNode.columns,...r]):h(r)})})}constraint(e){return new an({...o(this,Le),onConflictNode:vt.cloneWith(o(this,Le).onConflictNode,{constraint:Ue.create(e)})})}expression(e){return new an({...o(this,Le),onConflictNode:vt.cloneWith(o(this,Le).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new an({...o(this,Le),onConflictNode:vt.cloneWithIndexWhere(o(this,Le).onConflictNode,_t(e))})}whereRef(e,r,n){return new an({...o(this,Le),onConflictNode:vt.cloneWithIndexWhere(o(this,Le).onConflictNode,on(e,r,n))})}clearWhere(){return new an({...o(this,Le),onConflictNode:vt.cloneWithoutIndexWhere(o(this,Le).onConflictNode)})}doNothing(){return new Ko({...o(this,Le),onConflictNode:vt.cloneWith(o(this,Le).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Di({...o(this,Le),onConflictNode:vt.cloneWith(o(this,Le).onConflictNode,{updates:Hs(e)})})}$call(e){return e(this)}};Le=new WeakMap;let Li=an;Ee(Li,"don't await OnConflictBuilder instances.");class Ko{constructor(e){D(this,ti,void 0);G(this,ti,h(e))}toOperationNode(){return o(this,ti).onConflictNode}}ti=new WeakMap,Ee(Ko,"don't await OnConflictDoNothingBuilder instances.");const ni=class ni{constructor(e){D(this,Ut,void 0);G(this,Ut,h(e))}where(...e){return new ni({...o(this,Ut),onConflictNode:vt.cloneWithUpdateWhere(o(this,Ut).onConflictNode,_t(e))})}whereRef(e,r,n){return new ni({...o(this,Ut),onConflictNode:vt.cloneWithUpdateWhere(o(this,Ut).onConflictNode,on(e,r,n))})}clearWhere(){return new ni({...o(this,Ut),onConflictNode:vt.cloneWithoutUpdateWhere(o(this,Ut).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return o(this,Ut).onConflictNode}};Ut=new WeakMap;let Di=ni;Ee(Di,"don't await OnConflictUpdateBuilder instances.");const ft=class ft{constructor(e){D(this,pe,void 0);G(this,pe,h(e))}values(e){const[r,n]=Wl(e);return new ft({...o(this,pe),queryNode:Gt.cloneWith(o(this,pe).queryNode,{columns:r,values:n})})}columns(e){return new ft({...o(this,pe),queryNode:Gt.cloneWith(o(this,pe).queryNode,{columns:h(e.map(Je.create))})})}expression(e){return new ft({...o(this,pe),queryNode:Gt.cloneWith(o(this,pe).queryNode,{values:Qi(e)})})}ignore(){return new ft({...o(this,pe),queryNode:Gt.cloneWith(o(this,pe).queryNode,{ignore:!0})})}onConflict(e){return new ft({...o(this,pe),queryNode:Gt.cloneWith(o(this,pe).queryNode,{onConflict:e(new Li({onConflictNode:vt.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new ft({...o(this,pe),queryNode:Gt.cloneWith(o(this,pe).queryNode,{onDuplicateKey:Bl.create(Hs(e))})})}returning(e){return new ft({...o(this,pe),queryNode:me.cloneWithReturning(o(this,pe).queryNode,Br(e))})}returningAll(){return new ft({...o(this,pe),queryNode:me.cloneWithReturning(o(this,pe).queryNode,Ur())})}$call(e){return e(this)}$if(e,r){return e?r(this):new ft({...o(this,pe)})}$castTo(){return new ft(o(this,pe))}$narrowType(){return new ft(o(this,pe))}$assertType(){return new ft(o(this,pe))}withPlugin(e){return new ft({...o(this,pe),executor:o(this,pe).executor.withPlugin(e)})}toOperationNode(){return o(this,pe).executor.transformQuery(o(this,pe).queryNode,o(this,pe).queryId)}compile(){return o(this,pe).executor.compileQuery(this.toOperationNode(),o(this,pe).queryId)}async execute(){const e=this.compile(),r=e.query,n=await o(this,pe).executor.executeQuery(e,o(this,pe).queryId);return o(this,pe).executor.adapter.supportsReturning&&r.returning?n.rows:[new Ul(n.insertId,n.numAffectedRows??n.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Wi){const r=await this.executeTakeFirst();if(r===void 0)throw Fi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=o(this,pe).executor.stream(r,e,o(this,pe).queryId);for await(const O of n)yield*O.rows}async explain(e,r){return await new ft({...o(this,pe),queryNode:me.cloneWithExplain(o(this,pe).queryNode,e,r)}).execute()}};pe=new WeakMap;let jr=ft;Ee(jr,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Ql{constructor(e){ve(this,"numDeletedRows");this.numDeletedRows=e}}const Xo=h({is(t){return t.kind==="LimitNode"},create(t){return h({kind:"LimitNode",limit:Rt.create(t)})}}),Ye=class Ye{constructor(e){D(this,oe,void 0);G(this,oe,h(e))}where(...e){return new Ye({...o(this,oe),queryNode:me.cloneWithWhere(o(this,oe).queryNode,_t(e))})}whereRef(e,r,n){return new Ye({...o(this,oe),queryNode:me.cloneWithWhere(o(this,oe).queryNode,on(e,r,n))})}clearWhere(){return new Ye({...o(this,oe),queryNode:me.cloneWithoutWhere(o(this,oe).queryNode)})}using(e){return new Ye({...o(this,oe),queryNode:Qr.cloneWithUsing(o(this,oe).queryNode,Gr(e))})}innerJoin(...e){return new Ye({...o(this,oe),queryNode:me.cloneWithJoin(o(this,oe).queryNode,bt("InnerJoin",e))})}leftJoin(...e){return new Ye({...o(this,oe),queryNode:me.cloneWithJoin(o(this,oe).queryNode,bt("LeftJoin",e))})}rightJoin(...e){return new Ye({...o(this,oe),queryNode:me.cloneWithJoin(o(this,oe).queryNode,bt("RightJoin",e))})}fullJoin(...e){return new Ye({...o(this,oe),queryNode:me.cloneWithJoin(o(this,oe).queryNode,bt("FullJoin",e))})}returning(e){return new Ye({...o(this,oe),queryNode:me.cloneWithReturning(o(this,oe).queryNode,Br(e))})}returningAll(e){return new Ye({...o(this,oe),queryNode:me.cloneWithReturning(o(this,oe).queryNode,Ur(e))})}orderBy(e,r){return new Ye({...o(this,oe),queryNode:Qr.cloneWithOrderByItem(o(this,oe).queryNode,Ai(e,r))})}limit(e){return new Ye({...o(this,oe),queryNode:Qr.cloneWithLimit(o(this,oe).queryNode,Xo.create(e))})}$call(e){return e(this)}$if(e,r){return e?r(this):new Ye({...o(this,oe)})}$castTo(){return new Ye(o(this,oe))}$narrowType(){return new Ye(o(this,oe))}$assertType(){return new Ye(o(this,oe))}withPlugin(e){return new Ye({...o(this,oe),executor:o(this,oe).executor.withPlugin(e)})}toOperationNode(){return o(this,oe).executor.transformQuery(o(this,oe).queryNode,o(this,oe).queryId)}compile(){return o(this,oe).executor.compileQuery(this.toOperationNode(),o(this,oe).queryId)}async execute(){const e=this.compile(),r=e.query,n=await o(this,oe).executor.executeQuery(e,o(this,oe).queryId);return o(this,oe).executor.adapter.supportsReturning&&r.returning?n.rows:[new Ql(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Wi){const r=await this.executeTakeFirst();if(r===void 0)throw Fi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=o(this,oe).executor.stream(r,e,o(this,oe).queryId);for await(const O of n)yield*O.rows}async explain(e,r){return await new Ye({...o(this,oe),queryNode:me.cloneWithExplain(o(this,oe).queryNode,e,r)}).execute()}};oe=new WeakMap;let Ri=Ye;Ee(Ri,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class jl{constructor(e,r){ve(this,"numUpdatedRows");ve(this,"numChangedRows");this.numUpdatedRows=e,this.numChangedRows=r}}const nt=class nt{constructor(e){D(this,ue,void 0);G(this,ue,h(e))}where(...e){return new nt({...o(this,ue),queryNode:me.cloneWithWhere(o(this,ue).queryNode,_t(e))})}whereRef(e,r,n){return new nt({...o(this,ue),queryNode:me.cloneWithWhere(o(this,ue).queryNode,on(e,r,n))})}clearWhere(){return new nt({...o(this,ue),queryNode:me.cloneWithoutWhere(o(this,ue).queryNode)})}from(e){return new nt({...o(this,ue),queryNode:Pi.cloneWithFromItems(o(this,ue).queryNode,Gr(e))})}innerJoin(...e){return new nt({...o(this,ue),queryNode:me.cloneWithJoin(o(this,ue).queryNode,bt("InnerJoin",e))})}leftJoin(...e){return new nt({...o(this,ue),queryNode:me.cloneWithJoin(o(this,ue).queryNode,bt("LeftJoin",e))})}rightJoin(...e){return new nt({...o(this,ue),queryNode:me.cloneWithJoin(o(this,ue).queryNode,bt("RightJoin",e))})}fullJoin(...e){return new nt({...o(this,ue),queryNode:me.cloneWithJoin(o(this,ue).queryNode,bt("FullJoin",e))})}set(e){return new nt({...o(this,ue),queryNode:Pi.cloneWithUpdates(o(this,ue).queryNode,Hs(e))})}returning(e){return new nt({...o(this,ue),queryNode:me.cloneWithReturning(o(this,ue).queryNode,Br(e))})}returningAll(){return new nt({...o(this,ue),queryNode:me.cloneWithReturning(o(this,ue).queryNode,Ur())})}$call(e){return e(this)}$if(e,r){return e?r(this):new nt({...o(this,ue)})}$castTo(){return new nt(o(this,ue))}$narrowType(){return new nt(o(this,ue))}$assertType(){return new nt(o(this,ue))}withPlugin(e){return new nt({...o(this,ue),executor:o(this,ue).executor.withPlugin(e)})}toOperationNode(){return o(this,ue).executor.transformQuery(o(this,ue).queryNode,o(this,ue).queryId)}compile(){return o(this,ue).executor.compileQuery(this.toOperationNode(),o(this,ue).queryId)}async execute(){const e=this.compile(),r=e.query,n=await o(this,ue).executor.executeQuery(e,o(this,ue).queryId);return o(this,ue).executor.adapter.supportsReturning&&r.returning?n.rows:[new jl(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0),n.numChangedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Wi){const r=await this.executeTakeFirst();if(r===void 0)throw Fi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=o(this,ue).executor.stream(r,e,o(this,ue).queryId);for await(const O of n)yield*O.rows}async explain(e,r){return await new nt({...o(this,ue),queryNode:me.cloneWithExplain(o(this,ue).queryNode,e,r)}).execute()}};ue=new WeakMap;let Mi=nt;Ee(Mi,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const zl=h({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return h({kind:"CommonTableExpressionNode",name:t,expression:e})}}),Yo=h({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return h({kind:"CommonTableExpressionNameNode",table:_n.create(t),columns:e?h(e.map(Je.create)):void 0})}});function Zo(t,e){const r=e(eu());return zl.create(Vl(t),r.toOperationNode())}function Vl(t){if(t.includes("(")){const e=t.split(/[\(\)]/),r=e[0],n=e[1].split(",").map(O=>O.trim());return Yo.create(r,n)}else return Yo.create(t)}const Bi=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])})}}),ea=["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 Jl(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",column:this.transformNode(e.column),table:this.transformNode(e.table)}}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)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}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}}cs=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 Kl extends $s{constructor(r){super();D(this,ds);D(this,fs);D(this,hs);D(this,Dn);D(this,ri);D(this,ps);D(this,cr,void 0);D(this,Fn,new Set);D(this,Ln,new Set);G(this,cr,r)}transformNodeImpl(r){if(!Oe(this,ds,$a).call(this,r))return super.transformNodeImpl(r);const n=Oe(this,hs,Xa).call(this,r);for(const Y of n)o(this,Ln).add(Y);const O=Oe(this,fs,Ka).call(this,r);for(const Y of O)o(this,Fn).add(Y);const j=super.transformNodeImpl(r);for(const Y of O)o(this,Fn).delete(Y);for(const Y of n)o(this,Ln).delete(Y);return j}transformSchemableIdentifier(r){const n=super.transformSchemableIdentifier(r);return n.schema||!o(this,Fn).has(r.identifier.name)?n:{...n,schema:Ue.create(o(this,cr))}}transformReferences(r){const n=super.transformReferences(r);return n.table.table.schema?n:{...n,table:_n.createWithSchema(o(this,cr),n.table.table.identifier.name)}}}cr=new WeakMap,Fn=new WeakMap,Ln=new WeakMap,ds=new WeakSet,$a=function(r){return r.kind in $l},fs=new WeakSet,Ka=function(r){const n=new Set;if("name"in r&&r.name&&hn.is(r.name)&&Oe(this,ri,No).call(this,r.name,n),"from"in r&&r.from)for(const O of r.from.froms)Oe(this,Dn,Ei).call(this,O,n);if("into"in r&&r.into&&Oe(this,Dn,Ei).call(this,r.into,n),"table"in r&&r.table&&Oe(this,Dn,Ei).call(this,r.table,n),"joins"in r&&r.joins)for(const O of r.joins)Oe(this,Dn,Ei).call(this,O.table,n);return n},hs=new WeakSet,Xa=function(r){const n=new Set;return"with"in r&&r.with&&Oe(this,ps,Ya).call(this,r.with,n),n},Dn=new WeakSet,Ei=function(r,n){const O=_n.is(r)?r:pn.is(r)&&_n.is(r.node)?r.node:null;O&&Oe(this,ri,No).call(this,O.table,n)},ri=new WeakSet,No=function(r,n){const O=r.identifier.name;!o(this,Fn).has(O)&&!o(this,Ln).has(O)&&n.add(O)},ps=new WeakSet,Ya=function(r,n){for(const O of r.expressions){const j=O.name.table.table.identifier.name;o(this,Ln).has(j)||n.add(j)}};class zr{constructor(e){D(this,ii,void 0);G(this,ii,new Kl(e))}transformQuery(e){return o(this,ii).transformNode(e.node)}async transformResult(e){return e.result}}ii=new WeakMap;const Rn=class Rn{constructor(e){D(this,De,void 0);G(this,De,h(e))}selectFrom(e){return new Vr({queryId:Fe(),executor:o(this,De).executor,queryNode:xe.create(Gr(e),o(this,De).withNode)})}insertInto(e){return new jr({queryId:Fe(),executor:o(this,De).executor,queryNode:Gt.create(qt(e),o(this,De).withNode)})}replaceInto(e){return new jr({queryId:Fe(),executor:o(this,De).executor,queryNode:Gt.create(qt(e),o(this,De).withNode,!0)})}deleteFrom(e){return new Ri({queryId:Fe(),executor:o(this,De).executor,queryNode:Qr.create(Gr(e),o(this,De).withNode)})}updateTable(e){return new Mi({queryId:Fe(),executor:o(this,De).executor,queryNode:Pi.create(Hr(e),o(this,De).withNode)})}with(e,r){const n=Zo(e,r);return new Rn({...o(this,De),withNode:o(this,De).withNode?Bi.cloneWithExpression(o(this,De).withNode,n):Bi.create(n)})}withRecursive(e,r){const n=Zo(e,r);return new Rn({...o(this,De),withNode:o(this,De).withNode?Bi.cloneWithExpression(o(this,De).withNode,n):Bi.create(n,{recursive:!0})})}withPlugin(e){return new Rn({...o(this,De),executor:o(this,De).executor.withPlugin(e)})}withoutPlugins(){return new Rn({...o(this,De),executor:o(this,De).executor.withoutPlugins()})}withSchema(e){return new Rn({...o(this,De),executor:o(this,De).executor.withPluginAtFront(new zr(e))})}};De=new WeakMap;let Ui=Rn;class ta{constructor(){D(this,si,void 0);D(this,dr,void 0);D(this,fr,void 0);ve(this,"resolve",e=>{o(this,dr)&&o(this,dr).call(this,e)});ve(this,"reject",e=>{o(this,fr)&&o(this,fr).call(this,e)});G(this,si,new Promise((e,r)=>{G(this,fr,r),G(this,dr,e)}))}get promise(){return o(this,si)}}si=new WeakMap,dr=new WeakMap,fr=new WeakMap;const na=new Set;function Xl(t){na.has(t)||(na.add(t),console.log(t))}const Yl=h([]);class ra{constructor(e=Yl){D(this,oi);D(this,Mn,void 0);G(this,Mn,e)}get plugins(){return o(this,Mn)}transformQuery(e,r){for(const n of o(this,Mn)){const O=n.transformQuery({node:e,queryId:r});if(O.kind===e.kind)e=O;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 ${O.kind}`].join(" "))}return e}async executeQuery(e,r){return await this.provideConnection(async n=>{const O=await n.executeQuery(e),j=await Oe(this,oi,vo).call(this,O,r);return Zl(O,j),j})}async*stream(e,r,n){const O=new ta,j=new ta;this.provideConnection(async he=>(O.resolve(he),await j.promise)).catch(he=>O.reject(he));const Y=await O.promise;try{for await(const he of Y.streamQuery(e,r))yield await Oe(this,oi,vo).call(this,he,n)}finally{j.resolve()}}}Mn=new WeakMap,oi=new WeakSet,vo=async function(e,r){for(const n of o(this,Mn))e=await n.transformResult({result:e,queryId:r});return e};function Zl(t,e){const{numAffectedRows:r}=t;r===void 0&&t.numUpdatedOrDeletedRows===void 0||r!==void 0&&e.numAffectedRows!==void 0||Xl("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class nr extends ra{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 nr([...this.plugins,e])}withPlugins(e){return new nr([...this.plugins,...e])}withPluginAtFront(e){return new nr([e,...this.plugins])}withoutPlugins(){return new nr([])}}const Ks=new nr;function eu(){return new Ui({executor:Ks})}function tu(t,e){return new Ti({joinNode:Lr.create(t,Hr(e))})}function nu(){return new Ci({overNode:Gs.create()})}function bt(t,e){if(e.length===3)return iu(t,e[0],e[1],e[2]);if(e.length===2)return ru(t,e[0],e[1]);throw new Error("not implemented")}function ru(t,e,r){return r(tu(t,e)).toOperationNode()}function iu(t,e,r,n){return Lr.createWithOn(t,Hr(e),on(r,"=",n))}const su=h({is(t){return t.kind==="OffsetNode"},create(t){return h({kind:"OffsetNode",offset:Rt.create(t)})}}),ou=h({is(t){return t.kind==="GroupByItemNode"},create(t){return h({kind:"GroupByItemNode",groupBy:t})}});function au(t){return t=Ct(t)?t(or()):t,Rr(t).map(ou.create)}const ia=h({is(t){return t.kind==="SetOperationNode"},create(t,e,r){return h({kind:"SetOperationNode",operator:t,expression:e,all:r})}});function rr(t,e,r){return ia.create(t,e.toOperationNode(),r)}const ae=class ae{constructor(e){D(this,U,void 0);G(this,U,h(e))}get expressionType(){}where(...e){return new ae({...o(this,U),queryNode:me.cloneWithWhere(o(this,U).queryNode,_t(e))})}whereRef(e,r,n){return new ae({...o(this,U),queryNode:me.cloneWithWhere(o(this,U).queryNode,on(e,r,n))})}having(...e){return new ae({...o(this,U),queryNode:xe.cloneWithHaving(o(this,U).queryNode,_t(e))})}havingRef(e,r,n){return new ae({...o(this,U),queryNode:xe.cloneWithHaving(o(this,U).queryNode,on(e,r,n))})}select(e){return new ae({...o(this,U),queryNode:xe.cloneWithSelections(o(this,U).queryNode,Br(e))})}distinctOn(e){return new ae({...o(this,U),queryNode:xe.cloneWithDistinctOn(o(this,U).queryNode,Rr(e))})}modifyFront(e){return new ae({...o(this,U),queryNode:xe.cloneWithFrontModifier(o(this,U).queryNode,nn.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new ae({...o(this,U),queryNode:xe.cloneWithEndModifier(o(this,U).queryNode,nn.createWithExpression(e.toOperationNode()))})}distinct(){return new ae({...o(this,U),queryNode:xe.cloneWithFrontModifier(o(this,U).queryNode,nn.create("Distinct"))})}forUpdate(){return new ae({...o(this,U),queryNode:xe.cloneWithEndModifier(o(this,U).queryNode,nn.create("ForUpdate"))})}forShare(){return new ae({...o(this,U),queryNode:xe.cloneWithEndModifier(o(this,U).queryNode,nn.create("ForShare"))})}forKeyShare(){return new ae({...o(this,U),queryNode:xe.cloneWithEndModifier(o(this,U).queryNode,nn.create("ForKeyShare"))})}forNoKeyUpdate(){return new ae({...o(this,U),queryNode:xe.cloneWithEndModifier(o(this,U).queryNode,nn.create("ForNoKeyUpdate"))})}skipLocked(){return new ae({...o(this,U),queryNode:xe.cloneWithEndModifier(o(this,U).queryNode,nn.create("SkipLocked"))})}noWait(){return new ae({...o(this,U),queryNode:xe.cloneWithEndModifier(o(this,U).queryNode,nn.create("NoWait"))})}selectAll(e){return new ae({...o(this,U),queryNode:xe.cloneWithSelections(o(this,U).queryNode,Ur(e))})}innerJoin(...e){return new ae({...o(this,U),queryNode:me.cloneWithJoin(o(this,U).queryNode,bt("InnerJoin",e))})}leftJoin(...e){return new ae({...o(this,U),queryNode:me.cloneWithJoin(o(this,U).queryNode,bt("LeftJoin",e))})}rightJoin(...e){return new ae({...o(this,U),queryNode:me.cloneWithJoin(o(this,U).queryNode,bt("RightJoin",e))})}fullJoin(...e){return new ae({...o(this,U),queryNode:me.cloneWithJoin(o(this,U).queryNode,bt("FullJoin",e))})}innerJoinLateral(...e){return new ae({...o(this,U),queryNode:me.cloneWithJoin(o(this,U).queryNode,bt("LateralInnerJoin",e))})}leftJoinLateral(...e){return new ae({...o(this,U),queryNode:me.cloneWithJoin(o(this,U).queryNode,bt("LateralLeftJoin",e))})}orderBy(e,r){return new ae({...o(this,U),queryNode:xe.cloneWithOrderByItem(o(this,U).queryNode,Ai(e,r))})}groupBy(e){return new ae({...o(this,U),queryNode:xe.cloneWithGroupByItems(o(this,U).queryNode,au(e))})}limit(e){return new ae({...o(this,U),queryNode:xe.cloneWithLimit(o(this,U).queryNode,Xo.create(e))})}offset(e){return new ae({...o(this,U),queryNode:xe.cloneWithOffset(o(this,U).queryNode,su.create(e))})}union(e){return new ae({...o(this,U),queryNode:xe.cloneWithSetOperation(o(this,U).queryNode,rr("union",e,!1))})}unionAll(e){return new ae({...o(this,U),queryNode:xe.cloneWithSetOperation(o(this,U).queryNode,rr("union",e,!0))})}intersect(e){return new ae({...o(this,U),queryNode:xe.cloneWithSetOperation(o(this,U).queryNode,rr("intersect",e,!1))})}intersectAll(e){return new ae({...o(this,U),queryNode:xe.cloneWithSetOperation(o(this,U).queryNode,rr("intersect",e,!0))})}except(e){return new ae({...o(this,U),queryNode:xe.cloneWithSetOperation(o(this,U).queryNode,rr("except",e,!1))})}exceptAll(e){return new ae({...o(this,U),queryNode:xe.cloneWithSetOperation(o(this,U).queryNode,rr("except",e,!0))})}as(e){return new lu(this,e)}clearSelect(){return new ae({...o(this,U),queryNode:xe.cloneWithoutSelections(o(this,U).queryNode)})}clearWhere(){return new ae({...o(this,U),queryNode:me.cloneWithoutWhere(o(this,U).queryNode)})}clearLimit(){return new ae({...o(this,U),queryNode:xe.cloneWithoutLimit(o(this,U).queryNode)})}clearOffset(){return new ae({...o(this,U),queryNode:xe.cloneWithoutOffset(o(this,U).queryNode)})}clearOrderBy(){return new ae({...o(this,U),queryNode:xe.cloneWithoutOrderBy(o(this,U).queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new ae({...o(this,U)})}$castTo(){return new ae(o(this,U))}$narrowType(){return new ae(o(this,U))}$assertType(){return new ae(o(this,U))}withPlugin(e){return new ae({...o(this,U),executor:o(this,U).executor.withPlugin(e)})}toOperationNode(){return o(this,U).executor.transformQuery(o(this,U).queryNode,o(this,U).queryId)}compile(){return o(this,U).executor.compileQuery(this.toOperationNode(),o(this,U).queryId)}async execute(){const e=this.compile();return(await o(this,U).executor.executeQuery(e,o(this,U).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Wi){const r=await this.executeTakeFirst();if(r===void 0)throw Fi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=o(this,U).executor.stream(r,e,o(this,U).queryId);for await(const O of n)yield*O.rows}async explain(e,r){return await new ae({...o(this,U),queryNode:me.cloneWithExplain(o(this,U).queryNode,e,r)}).execute()}};U=new WeakMap;let Vr=ae;Ee(Vr,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class lu{constructor(e,r){D(this,hr,void 0);D(this,pr,void 0);G(this,hr,e),G(this,pr,r)}get expression(){return o(this,hr)}get alias(){return o(this,pr)}toOperationNode(){return pn.create(o(this,hr).toOperationNode(),Ue.create(o(this,pr)))}}hr=new WeakMap,pr=new WeakMap;const ir=h({is(t){return t.kind==="ParensNode"},create(t){return h({kind:"ParensNode",node:t})}}),uo=class uo{constructor(e){D(this,bn,void 0);G(this,bn,e)}get expressionType(){}as(e){return new Xs(this,e)}or(...e){return new Ys(Cn.create(o(this,bn),_t(e)))}and(...e){return new Zs(Tn.create(o(this,bn),_t(e)))}$castTo(){return new uo(o(this,bn))}toOperationNode(){return o(this,bn)}};bn=new WeakMap;let Ge=uo;class Xs{constructor(e,r){D(this,_r,void 0);D(this,qn,void 0);G(this,_r,e),G(this,qn,r)}get expression(){return o(this,_r)}get alias(){return o(this,qn)}toOperationNode(){return pn.create(o(this,_r).toOperationNode(),Pt(o(this,qn))?o(this,qn).toOperationNode():Ue.create(o(this,qn)))}}_r=new WeakMap,qn=new WeakMap;const _s=class _s{constructor(e){D(this,Bn,void 0);G(this,Bn,e)}get expressionType(){}as(e){return new Xs(this,e)}or(...e){return new _s(Cn.create(o(this,Bn),_t(e)))}$castTo(){return new _s(o(this,Bn))}toOperationNode(){return ir.create(o(this,Bn))}};Bn=new WeakMap;let Ys=_s;const ms=class ms{constructor(e){D(this,Un,void 0);G(this,Un,e)}get expressionType(){}as(e){return new Xs(this,e)}and(...e){return new ms(Tn.create(o(this,Un),_t(e)))}$castTo(){return new ms(o(this,Un))}toOperationNode(){return ir.create(o(this,Un))}};Un=new WeakMap;let Zs=ms;const sr=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})}}),uu=h({is(t){return t.kind==="FunctionNode"},create(t,e){return h({kind:"FunctionNode",func:t,arguments:e})}}),mr=class mr{constructor(e){D(this,Et,void 0);G(this,Et,h(e))}get expressionType(){}as(e){return new cu(this,e)}distinct(){return new mr({...o(this,Et),aggregateFunctionNode:sr.cloneWithDistinct(o(this,Et).aggregateFunctionNode)})}filterWhere(...e){return new mr({...o(this,Et),aggregateFunctionNode:sr.cloneWithFilter(o(this,Et).aggregateFunctionNode,_t(e))})}filterWhereRef(e,r,n){return new mr({...o(this,Et),aggregateFunctionNode:sr.cloneWithFilter(o(this,Et).aggregateFunctionNode,on(e,r,n))})}over(e){const r=nu();return new mr({...o(this,Et),aggregateFunctionNode:sr.cloneWithOver(o(this,Et).aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return o(this,Et).aggregateFunctionNode}};Et=new WeakMap;let Jr=mr;Ee(Jr,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class cu{constructor(e,r){D(this,yr,void 0);D(this,gr,void 0);G(this,yr,e),G(this,gr,r)}get expression(){return o(this,yr)}get alias(){return o(this,gr)}toOperationNode(){return pn.create(o(this,yr).toOperationNode(),Ue.create(o(this,gr)))}}yr=new WeakMap,gr=new WeakMap;function sa(){const t=(r,n)=>new Ge(uu.create(r,Rr(n))),e=(r,n)=>new Jr({aggregateFunctionNode:sr.create(r,n?Rr(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 Jr({aggregateFunctionNode:sr.create("count",Ur(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}const du=h({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return h({kind:"UnaryOperationNode",operator:t,operand:e})}});function fu(t,e){return du.create(Dr.create(t),rn(e))}const eo=h({is(t){return t.kind==="WhenNode"},create(t){return h({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return h({...t,result:e})}}),Ht=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),eo.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return h({...t,...e})}});class oa{constructor(e){D(this,wr,void 0);G(this,wr,h(e))}when(...e){return new aa({...o(this,wr),node:Ht.cloneWithWhen(o(this,wr).node,eo.create(_t(e)))})}}wr=new WeakMap;class aa{constructor(e){D(this,br,void 0);G(this,br,h(e))}then(e){return new hu({...o(this,br),node:Ht.cloneWithThen(o(this,br).node,sn(e))})}}br=new WeakMap;class hu{constructor(e){D(this,$t,void 0);G(this,$t,h(e))}when(...e){return new aa({...o(this,$t),node:Ht.cloneWithWhen(o(this,$t).node,eo.create(_t(e)))})}else(e){return new pu({...o(this,$t),node:Ht.cloneWith(o(this,$t).node,{else:sn(e)})})}end(){return new Ge(Ht.cloneWith(o(this,$t).node,{isStatement:!1}))}endCase(){return new Ge(Ht.cloneWith(o(this,$t).node,{isStatement:!0}))}}$t=new WeakMap;class pu{constructor(e){D(this,qr,void 0);G(this,qr,h(e))}end(){return new Ge(Ht.cloneWith(o(this,qr).node,{isStatement:!1}))}endCase(){return new Ge(Ht.cloneWith(o(this,qr).node,{isStatement:!0}))}}qr=new WeakMap;const _u=h({is(t){return t.kind==="JSONPathLegNode"},create(t,e){return h({kind:"JSONPathLegNode",type:t,value:e})}});class to{constructor(e){D(this,ai);D(this,Nn,void 0);G(this,Nn,e)}at(e){return Oe(this,ai,xo).call(this,"ArrayLocation",e)}key(e){return Oe(this,ai,xo).call(this,"Member",e)}}Nn=new WeakMap,ai=new WeakSet,xo=function(e,r){return new mu(Qs.cloneWithTraversal(o(this,Nn),js.is(o(this,Nn).traversal)?js.cloneWithLeg(o(this,Nn).traversal,_u.create(e,r)):Wo.cloneWithValue(o(this,Nn).traversal,Rt.createImmediate(r))))};class mu extends to{constructor(r){super(r);D(this,Nr,void 0);G(this,Nr,r)}get expressionType(){}as(r){return new yu(this,r)}$castTo(){return new to(o(this,Nr))}toOperationNode(){return o(this,Nr)}}Nr=new WeakMap;class yu{constructor(e,r){D(this,vr,void 0);D(this,vn,void 0);G(this,vr,e),G(this,vn,r)}get expression(){return o(this,vr)}get alias(){return o(this,vn)}toOperationNode(){return pn.create(o(this,vr).toOperationNode(),Pt(o(this,vn))?o(this,vn).toOperationNode():Ue.create(o(this,vn)))}}vr=new WeakMap,vn=new WeakMap;function no(t=Ks){function e(O,j,Y){return new Ge(Oi(O,j,Y))}function r(O,j){return new Ge(fu(O,j))}const n=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(O){return new Vr({queryId:Fe(),executor:t,queryNode:xe.create(Gr(O))})},case(O){return new oa({node:Ht.create(Ie(O)?void 0:rn(O))})},ref(O,j){return Ie(j)?new Ge(Pn(O)):new to(gl(O,j))},val(O){return new Ge(Mo(O))},cmpr(O,j,Y){return new Ge(Oi(O,j,Y))},bxp(O,j,Y){return new Ge(Oi(O,j,Y))},unary:r,not(O){return r("not",O)},exists(O){return r("exists",O)},neg(O){return r("-",O)},and(O){if(O.length===0)return new Ge(Rt.createImmediate(!0));if(O.length===1)return new Ge(O[0].toOperationNode());let j=Tn.create(O[0].toOperationNode(),O[1].toOperationNode());for(let Y=2;YHr(e)):[Hr(t)]}function Hr(t){return ge(t)?gu(t):la(t)}function gu(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(ua);return pn.create(qt(r),Ue.create(n))}else return qt(t)}function qt(t){const e=".";if(t.includes(e)){const[r,n]=t.split(e).map(ua);return _n.createWithSchema(r,n)}else return _n.create(t)}function ua(t){return t.trim()}const ca=h({is(t){return t.kind==="AddColumnNode"},create(t){return h({kind:"AddColumnNode",column:t})}}),He=h({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return h({kind:"ColumnDefinitionNode",column:Je.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})}}),da=h({is(t){return t.kind==="DropColumnNode"},create(t){return h({kind:"DropColumnNode",column:Je.create(t)})}}),fa=h({is(t){return t.kind==="RenameColumnNode"},create(t,e){return h({kind:"RenameColumnNode",column:Je.create(t),renameTo:Je.create(e)})}}),ro=h({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return h({kind:"CheckConstraintNode",expression:t,name:e?Ue.create(e):void 0})}}),wu=["no action","restrict","cascade","set null","set default"],zi=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 ha(t){return Pt(t)?t.toOperationNode():Rt.createImmediate(t)}const Vi=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})}}),bu=h({is(t){return t.kind==="DefaultValueNode"},create(t){return h({kind:"DefaultValueNode",defaultValue:t})}});function Ji(t){if(wu.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const rt=class rt{constructor(e){D(this,Pe,void 0);G(this,Pe,e)}autoIncrement(){return new rt(He.cloneWith(o(this,Pe),{autoIncrement:!0}))}primaryKey(){return new rt(He.cloneWith(o(this,Pe),{primaryKey:!0}))}references(e){const r=Pn(e);if(!r.table||Us.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new rt(He.cloneWith(o(this,Pe),{references:zi.create(r.table,[r.column])}))}onDelete(e){if(!o(this,Pe).references)throw new Error("on delete constraint can only be added for foreign keys");return new rt(He.cloneWith(o(this,Pe),{references:zi.cloneWithOnDelete(o(this,Pe).references,Ji(e))}))}onUpdate(e){if(!o(this,Pe).references)throw new Error("on update constraint can only be added for foreign keys");return new rt(He.cloneWith(o(this,Pe),{references:zi.cloneWithOnUpdate(o(this,Pe).references,Ji(e))}))}unique(){return new rt(He.cloneWith(o(this,Pe),{unique:!0}))}notNull(){return new rt(He.cloneWith(o(this,Pe),{notNull:!0}))}unsigned(){return new rt(He.cloneWith(o(this,Pe),{unsigned:!0}))}defaultTo(e){return new rt(He.cloneWith(o(this,Pe),{defaultTo:bu.create(ha(e))}))}check(e){return new rt(He.cloneWith(o(this,Pe),{check:ro.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new rt(He.cloneWith(o(this,Pe),{generated:Vi.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new rt(He.cloneWith(o(this,Pe),{generated:Vi.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new rt(He.cloneWith(o(this,Pe),{generated:Vi.create({identity:!0,byDefault:!0})}))}stored(){if(!o(this,Pe).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new rt(He.cloneWith(o(this,Pe),{generated:Vi.cloneWith(o(this,Pe).generated,{stored:!0})}))}modifyFront(e){return new rt(He.cloneWithFrontModifier(o(this,Pe),e.toOperationNode()))}modifyEnd(e){return new rt(He.cloneWithEndModifier(o(this,Pe),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return o(this,Pe)}};Pe=new WeakMap;let mn=rt;Ee(mn,"don't await ColumnDefinitionBuilder instances directly.");const pa=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 ar(t){return Pt(t)?t.toOperationNode():qu.create(t)}const Gi=h({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,n){return h({kind:"ForeignKeyConstraintNode",columns:t,references:zi.create(e,r),name:n?Ue.create(n):void 0})},cloneWith(t,e){return h({...t,...e})}}),ys=class ys{constructor(e){D(this,Qn,void 0);G(this,Qn,e)}onDelete(e){return new ys(Gi.cloneWith(o(this,Qn),{onDelete:Ji(e)}))}onUpdate(e){return new ys(Gi.cloneWith(o(this,Qn),{onUpdate:Ji(e)}))}$call(e){return e(this)}toOperationNode(){return o(this,Qn)}};Qn=new WeakMap;let $r=ys;Ee($r,"don't await ForeignKeyConstraintBuilder instances directly.");const io=h({is(t){return t.kind==="AddConstraintNode"},create(t){return h({kind:"AddConstraintNode",constraint:t})}}),_a=h({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return h({kind:"UniqueConstraintNode",columns:h(t.map(Je.create)),name:e?Ue.create(e):void 0})}}),Hi=h({is(t){return t.kind==="DropConstraintNode"},create(t){return h({kind:"DropConstraintNode",constraintName:Ue.create(t)})},cloneWith(t,e){return h({...t,...e})}}),Kr=h({is(t){return t.kind==="AlterColumnNode"},create(t,e,r){return h({kind:"AlterColumnNode",column:Je.create(t),[e]:r})}});class so{constructor(e){D(this,ln,void 0);G(this,ln,e)}setDataType(e){return new Xr(Kr.create(o(this,ln),"dataType",ar(e)))}setDefault(e){return new Xr(Kr.create(o(this,ln),"setDefault",ha(e)))}dropDefault(){return new Xr(Kr.create(o(this,ln),"dropDefault",!0))}setNotNull(){return new Xr(Kr.create(o(this,ln),"setNotNull",!0))}dropNotNull(){return new Xr(Kr.create(o(this,ln),"dropNotNull",!0))}$call(e){return e(this)}}ln=new WeakMap;class Xr{constructor(e){D(this,li,void 0);G(this,li,e)}toOperationNode(){return o(this,li)}}li=new WeakMap;class Yr{constructor(e){D(this,Qt,void 0);G(this,Qt,h(e))}toOperationNode(){return o(this,Qt).executor.transformQuery(o(this,Qt).node,o(this,Qt).queryId)}compile(){return o(this,Qt).executor.compileQuery(this.toOperationNode(),o(this,Qt).queryId)}async execute(){await o(this,Qt).executor.executeQuery(this.compile(),o(this,Qt).queryId)}}Qt=new WeakMap,Ee(Yr,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const gs=class gs{constructor(e){D(this,ht,void 0);G(this,ht,h(e))}onDelete(e){return new gs({...o(this,ht),constraintBuilder:o(this,ht).constraintBuilder.onDelete(e)})}onUpdate(e){return new gs({...o(this,ht),constraintBuilder:o(this,ht).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return o(this,ht).executor.transformQuery(Xe.cloneWithTableProps(o(this,ht).node,{addConstraint:io.create(o(this,ht).constraintBuilder.toOperationNode())}),o(this,ht).queryId)}compile(){return o(this,ht).executor.compileQuery(this.toOperationNode(),o(this,ht).queryId)}async execute(){await o(this,ht).executor.executeQuery(this.compile(),o(this,ht).queryId)}};ht=new WeakMap;let $i=gs;Ee($i,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const ui=class ui{constructor(e){D(this,Ze,void 0);G(this,Ze,h(e))}ifExists(){return new ui({...o(this,Ze),node:Xe.cloneWithTableProps(o(this,Ze).node,{dropConstraint:Hi.cloneWith(o(this,Ze).node.dropConstraint,{ifExists:!0})})})}cascade(){return new ui({...o(this,Ze),node:Xe.cloneWithTableProps(o(this,Ze).node,{dropConstraint:Hi.cloneWith(o(this,Ze).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new ui({...o(this,Ze),node:Xe.cloneWithTableProps(o(this,Ze).node,{dropConstraint:Hi.cloneWith(o(this,Ze).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return o(this,Ze).executor.transformQuery(o(this,Ze).node,o(this,Ze).queryId)}compile(){return o(this,Ze).executor.compileQuery(this.toOperationNode(),o(this,Ze).queryId)}async execute(){await o(this,Ze).executor.executeQuery(this.compile(),o(this,Ze).queryId)}};Ze=new WeakMap;let Ki=ui;Ee(Ki,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class ma{constructor(e){D(this,Me,void 0);G(this,Me,h(e))}renameTo(e){return new Yr({...o(this,Me),node:Xe.cloneWithTableProps(o(this,Me).node,{renameTo:qt(e)})})}setSchema(e){return new Yr({...o(this,Me),node:Xe.cloneWithTableProps(o(this,Me).node,{setSchema:Ue.create(e)})})}alterColumn(e,r){const n=r(new so(e));return new yn({...o(this,Me),node:Xe.cloneWithColumnAlteration(o(this,Me).node,n.toOperationNode())})}dropColumn(e){return new yn({...o(this,Me),node:Xe.cloneWithColumnAlteration(o(this,Me).node,da.create(e))})}renameColumn(e,r){return new yn({...o(this,Me),node:Xe.cloneWithColumnAlteration(o(this,Me).node,fa.create(e,r))})}addColumn(e,r,n=er){const O=n(new mn(He.create(e,ar(r))));return new yn({...o(this,Me),node:Xe.cloneWithColumnAlteration(o(this,Me).node,ca.create(O.toOperationNode()))})}modifyColumn(e,r,n=er){const O=n(new mn(He.create(e,ar(r))));return new yn({...o(this,Me),node:Xe.cloneWithColumnAlteration(o(this,Me).node,pa.create(O.toOperationNode()))})}addUniqueConstraint(e,r){return new Yr({...o(this,Me),node:Xe.cloneWithTableProps(o(this,Me).node,{addConstraint:io.create(_a.create(r,e))})})}addCheckConstraint(e,r){return new Yr({...o(this,Me),node:Xe.cloneWithTableProps(o(this,Me).node,{addConstraint:io.create(ro.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,n,O){return new $i({...o(this,Me),constraintBuilder:new $r(Gi.create(r.map(Je.create),qt(n),O.map(Je.create),e))})}dropConstraint(e){return new Ki({...o(this,Me),node:Xe.cloneWithTableProps(o(this,Me).node,{dropConstraint:Hi.create(e)})})}$call(e){return e(this)}}Me=new WeakMap;const jn=class jn{constructor(e){D(this,$e,void 0);G(this,$e,h(e))}alterColumn(e,r){const n=r(new so(e));return new jn({...o(this,$e),node:Xe.cloneWithColumnAlteration(o(this,$e).node,n.toOperationNode())})}dropColumn(e){return new jn({...o(this,$e),node:Xe.cloneWithColumnAlteration(o(this,$e).node,da.create(e))})}renameColumn(e,r){return new jn({...o(this,$e),node:Xe.cloneWithColumnAlteration(o(this,$e).node,fa.create(e,r))})}addColumn(e,r,n=er){const O=n(new mn(He.create(e,ar(r))));return new jn({...o(this,$e),node:Xe.cloneWithColumnAlteration(o(this,$e).node,ca.create(O.toOperationNode()))})}modifyColumn(e,r,n=er){const O=n(new mn(He.create(e,ar(r))));return new jn({...o(this,$e),node:Xe.cloneWithColumnAlteration(o(this,$e).node,pa.create(O.toOperationNode()))})}toOperationNode(){return o(this,$e).executor.transformQuery(o(this,$e).node,o(this,$e).queryId)}compile(){return o(this,$e).executor.compileQuery(this.toOperationNode(),o(this,$e).queryId)}async execute(){await o(this,$e).executor.executeQuery(this.compile(),o(this,$e).queryId)}};$e=new WeakMap;let yn=jn;Ee(ma,"don't await AlterTableBuilder instances"),Ee(so,"don't await AlterColumnBuilder instances"),Ee(yn,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class ya extends $s{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const Kt=class Kt{constructor(e){D(this,We,void 0);G(this,We,h(e))}ifNotExists(){return new Kt({...o(this,We),node:fn.cloneWith(o(this,We).node,{ifNotExists:!0})})}unique(){return new Kt({...o(this,We),node:fn.cloneWith(o(this,We).node,{unique:!0})})}on(e){return new Kt({...o(this,We),node:fn.cloneWith(o(this,We).node,{table:qt(e)})})}column(e){return new Kt({...o(this,We),node:fn.cloneWithColumns(o(this,We).node,[Do(e)])})}columns(e){return new Kt({...o(this,We),node:fn.cloneWithColumns(o(this,We).node,e.map(Do))})}expression(e){return new Kt({...o(this,We),node:fn.cloneWithColumns(o(this,We).node,[e.toOperationNode()])})}using(e){return new Kt({...o(this,We),node:fn.cloneWith(o(this,We).node,{using:pt.createWithSql(e)})})}where(...e){const r=new ya;return new Kt({...o(this,We),node:me.cloneWithWhere(o(this,We).node,r.transformNode(_t(e)))})}$call(e){return e(this)}toOperationNode(){return o(this,We).executor.transformQuery(o(this,We).node,o(this,We).queryId)}compile(){return o(this,We).executor.compileQuery(this.toOperationNode(),o(this,We).queryId)}async execute(){await o(this,We).executor.executeQuery(this.compile(),o(this,We).queryId)}};We=new WeakMap;let Xi=Kt;Ee(Xi,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const co=class co{constructor(e){D(this,St,void 0);G(this,St,h(e))}ifNotExists(){return new co({...o(this,St),node:Oo.cloneWith(o(this,St).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,St).executor.transformQuery(o(this,St).node,o(this,St).queryId)}compile(){return o(this,St).executor.compileQuery(this.toOperationNode(),o(this,St).queryId)}async execute(){await o(this,St).executor.executeQuery(this.compile(),o(this,St).queryId)}};St=new WeakMap;let Yi=co;Ee(Yi,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const Nu=h({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return h({kind:"PrimaryKeyConstraintNode",columns:h(t.map(Je.create)),name:e?Ue.create(e):void 0})}});function vu(t){if(al.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const Wt=class Wt{constructor(e){D(this,Se,void 0);G(this,Se,h(e))}temporary(){return new Wt({...o(this,Se),node:Dt.cloneWith(o(this,Se).node,{temporary:!0})})}onCommit(e){return new Wt({...o(this,Se),node:Dt.cloneWith(o(this,Se).node,{onCommit:vu(e)})})}ifNotExists(){return new Wt({...o(this,Se),node:Dt.cloneWith(o(this,Se).node,{ifNotExists:!0})})}addColumn(e,r,n=er){const O=n(new mn(He.create(e,ar(r))));return new Wt({...o(this,Se),node:Dt.cloneWithColumn(o(this,Se).node,O.toOperationNode())})}addPrimaryKeyConstraint(e,r){return new Wt({...o(this,Se),node:Dt.cloneWithConstraint(o(this,Se).node,Nu.create(r,e))})}addUniqueConstraint(e,r){return new Wt({...o(this,Se),node:Dt.cloneWithConstraint(o(this,Se).node,_a.create(r,e))})}addCheckConstraint(e,r){return new Wt({...o(this,Se),node:Dt.cloneWithConstraint(o(this,Se).node,ro.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,n,O,j=er){const Y=j(new $r(Gi.create(r.map(Je.create),qt(n),O.map(Je.create),e)));return new Wt({...o(this,Se),node:Dt.cloneWithConstraint(o(this,Se).node,Y.toOperationNode())})}modifyFront(e){return new Wt({...o(this,Se),node:Dt.cloneWithFrontModifier(o(this,Se).node,e.toOperationNode())})}modifyEnd(e){return new Wt({...o(this,Se),node:Dt.cloneWithEndModifier(o(this,Se).node,e.toOperationNode())})}$call(e){return e(this)}toOperationNode(){return o(this,Se).executor.transformQuery(o(this,Se).node,o(this,Se).queryId)}compile(){return o(this,Se).executor.compileQuery(this.toOperationNode(),o(this,Se).queryId)}async execute(){await o(this,Se).executor.executeQuery(this.compile(),o(this,Se).queryId)}};Se=new WeakMap;let Zi=Wt;Ee(Zi,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const ci=class ci{constructor(e){D(this,at,void 0);G(this,at,h(e))}on(e){return new ci({...o(this,at),node:Si.cloneWith(o(this,at).node,{table:qt(e)})})}ifExists(){return new ci({...o(this,at),node:Si.cloneWith(o(this,at).node,{ifExists:!0})})}cascade(){return new ci({...o(this,at),node:Si.cloneWith(o(this,at).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,at).executor.transformQuery(o(this,at).node,o(this,at).queryId)}compile(){return o(this,at).executor.compileQuery(this.toOperationNode(),o(this,at).queryId)}async execute(){await o(this,at).executor.executeQuery(this.compile(),o(this,at).queryId)}};at=new WeakMap;let es=ci;Ee(es,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const ws=class ws{constructor(e){D(this,mt,void 0);G(this,mt,h(e))}ifExists(){return new ws({...o(this,mt),node:Ls.cloneWith(o(this,mt).node,{ifExists:!0})})}cascade(){return new ws({...o(this,mt),node:Ls.cloneWith(o(this,mt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,mt).executor.transformQuery(o(this,mt).node,o(this,mt).queryId)}compile(){return o(this,mt).executor.compileQuery(this.toOperationNode(),o(this,mt).queryId)}async execute(){await o(this,mt).executor.executeQuery(this.compile(),o(this,mt).queryId)}};mt=new WeakMap;let ts=ws;Ee(ts,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const bs=class bs{constructor(e){D(this,yt,void 0);G(this,yt,h(e))}ifExists(){return new bs({...o(this,yt),node:Ds.cloneWith(o(this,yt).node,{ifExists:!0})})}cascade(){return new bs({...o(this,yt),node:Ds.cloneWith(o(this,yt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,yt).executor.transformQuery(o(this,yt).node,o(this,yt).queryId)}compile(){return o(this,yt).executor.compileQuery(this.toOperationNode(),o(this,yt).queryId)}async execute(){await o(this,yt).executor.executeQuery(this.compile(),o(this,yt).queryId)}};yt=new WeakMap;let ns=bs;Ee(ns,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const gn=h({is(t){return t.kind==="CreateViewNode"},create(t){return h({kind:"CreateViewNode",name:hn.create(t)})},cloneWith(t,e){return h({...t,...e})}});class xu{constructor(){D(this,qs,new ya)}transformQuery(e){return o(this,qs).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}qs=new WeakMap;const xn=class xn{constructor(e){D(this,Qe,void 0);G(this,Qe,h(e))}temporary(){return new xn({...o(this,Qe),node:gn.cloneWith(o(this,Qe).node,{temporary:!0})})}materialized(){return new xn({...o(this,Qe),node:gn.cloneWith(o(this,Qe).node,{materialized:!0})})}ifNotExists(){return new xn({...o(this,Qe),node:gn.cloneWith(o(this,Qe).node,{ifNotExists:!0})})}orReplace(){return new xn({...o(this,Qe),node:gn.cloneWith(o(this,Qe).node,{orReplace:!0})})}columns(e){return new xn({...o(this,Qe),node:gn.cloneWith(o(this,Qe).node,{columns:e.map(Lo)})})}as(e){const r=e.withPlugin(new xu).toOperationNode();return new xn({...o(this,Qe),node:gn.cloneWith(o(this,Qe).node,{as:r})})}$call(e){return e(this)}toOperationNode(){return o(this,Qe).executor.transformQuery(o(this,Qe).node,o(this,Qe).queryId)}compile(){return o(this,Qe).executor.compileQuery(this.toOperationNode(),o(this,Qe).queryId)}async execute(){await o(this,Qe).executor.executeQuery(this.compile(),o(this,Qe).queryId)}};Qe=new WeakMap;let rs=xn;Ee(rs,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const is=h({is(t){return t.kind==="DropViewNode"},create(t){return h({kind:"DropViewNode",name:hn.create(t)})},cloneWith(t,e){return h({...t,...e})}}),di=class di{constructor(e){D(this,lt,void 0);G(this,lt,h(e))}materialized(){return new di({...o(this,lt),node:is.cloneWith(o(this,lt).node,{materialized:!0})})}ifExists(){return new di({...o(this,lt),node:is.cloneWith(o(this,lt).node,{ifExists:!0})})}cascade(){return new di({...o(this,lt),node:is.cloneWith(o(this,lt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,lt).executor.transformQuery(o(this,lt).node,o(this,lt).queryId)}compile(){return o(this,lt).executor.compileQuery(this.toOperationNode(),o(this,lt).queryId)}async execute(){await o(this,lt).executor.executeQuery(this.compile(),o(this,lt).queryId)}};lt=new WeakMap;let ss=di;Ee(ss,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const ga=h({is(t){return t.kind==="CreateTypeNode"},create(t){return h({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return h({...t,enum:Vs.create(e.map(r=>Rt.createImmediate(r)))})}}),fo=class fo{constructor(e){D(this,kt,void 0);G(this,kt,h(e))}toOperationNode(){return o(this,kt).executor.transformQuery(o(this,kt).node,o(this,kt).queryId)}asEnum(e){return new fo({...o(this,kt),node:ga.cloneWithEnum(o(this,kt).node,e)})}$call(e){return e(this)}compile(){return o(this,kt).executor.compileQuery(this.toOperationNode(),o(this,kt).queryId)}async execute(){await o(this,kt).executor.executeQuery(this.compile(),o(this,kt).queryId)}};kt=new WeakMap;let os=fo;Ee(os,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const wa=h({is(t){return t.kind==="DropTypeNode"},create(t){return h({kind:"DropTypeNode",name:t})},cloneWith(t,e){return h({...t,...e})}}),ho=class ho{constructor(e){D(this,At,void 0);G(this,At,h(e))}ifExists(){return new ho({...o(this,At),node:wa.cloneWith(o(this,At).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return o(this,At).executor.transformQuery(o(this,At).node,o(this,At).queryId)}compile(){return o(this,At).executor.compileQuery(this.toOperationNode(),o(this,At).queryId)}async execute(){await o(this,At).executor.executeQuery(this.compile(),o(this,At).queryId)}};At=new WeakMap;let as=ho;Ee(as,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function ba(t){const e=".";if(t.includes(e)){const r=t.split(e).map(Eu);if(r.length===2)return hn.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return hn.create(t)}function Eu(t){return t.trim()}const fi=class fi{constructor(e){D(this,it,void 0);G(this,it,e)}createTable(e){return new Zi({queryId:Fe(),executor:o(this,it),node:Dt.create(qt(e))})}dropTable(e){return new ns({queryId:Fe(),executor:o(this,it),node:Ds.create(qt(e))})}createIndex(e){return new Xi({queryId:Fe(),executor:o(this,it),node:fn.create(e)})}dropIndex(e){return new es({queryId:Fe(),executor:o(this,it),node:Si.create(e)})}createSchema(e){return new Yi({queryId:Fe(),executor:o(this,it),node:Oo.create(e)})}dropSchema(e){return new ts({queryId:Fe(),executor:o(this,it),node:Ls.create(e)})}alterTable(e){return new ma({queryId:Fe(),executor:o(this,it),node:Xe.create(qt(e))})}createView(e){return new rs({queryId:Fe(),executor:o(this,it),node:gn.create(e)})}dropView(e){return new ss({queryId:Fe(),executor:o(this,it),node:is.create(e)})}createType(e){return new os({queryId:Fe(),executor:o(this,it),node:ga.create(ba(e))})}dropType(e){return new as({queryId:Fe(),executor:o(this,it),node:wa.create(ba(e))})}withPlugin(e){return new fi(o(this,it).withPlugin(e))}withoutPlugins(){return new fi(o(this,it).withoutPlugins())}withSchema(e){return new fi(o(this,it).withPluginAtFront(new zr(e)))}};it=new WeakMap;let oo=fi;class Su{ref(e){return new Il(e)}}class ku{constructor(e){D(this,xr,void 0);G(this,xr,e)}async provideConnection(e){const r=await o(this,xr).acquireConnection();try{return await e(r)}finally{await o(this,xr).releaseConnection(r)}}}xr=new WeakMap;const zn=class zn extends ra{constructor(r,n,O,j=[]){super(j);D(this,Xt,void 0);D(this,Yt,void 0);D(this,un,void 0);G(this,Xt,r),G(this,Yt,n),G(this,un,O)}get adapter(){return o(this,Yt)}compileQuery(r){return o(this,Xt).compileQuery(r)}provideConnection(r){return o(this,un).provideConnection(r)}withPlugins(r){return new zn(o(this,Xt),o(this,Yt),o(this,un),[...this.plugins,...r])}withPlugin(r){return new zn(o(this,Xt),o(this,Yt),o(this,un),[...this.plugins,r])}withPluginAtFront(r){return new zn(o(this,Xt),o(this,Yt),o(this,un),[r,...this.plugins])}withConnectionProvider(r){return new zn(o(this,Xt),o(this,Yt),r,[...this.plugins])}withoutPlugins(){return new zn(o(this,Xt),o(this,Yt),o(this,un),[])}};Xt=new WeakMap,Yt=new WeakMap,un=new WeakMap;let ao=zn;function qa(){return typeof performance<"u"&&Ct(performance.now)?performance.now():Date.now()}class Au{constructor(e,r){D(this,Ns);D(this,vs);D(this,xs);D(this,Es);D(this,pi);D(this,jt,void 0);D(this,En,void 0);D(this,cn,void 0);D(this,Vn,void 0);D(this,hi,new WeakSet);G(this,jt,e),G(this,En,r)}async init(){o(this,cn)||G(this,cn,o(this,jt).init().catch(e=>(G(this,cn,void 0),Promise.reject(e)))),await o(this,cn)}async acquireConnection(){await this.init();const e=await o(this,jt).acquireConnection();return o(this,hi).has(e)||(Oe(this,Ns,Za).call(this)&&Oe(this,vs,el).call(this,e),o(this,hi).add(e)),e}async releaseConnection(e){await o(this,jt).releaseConnection(e)}beginTransaction(e,r){return o(this,jt).beginTransaction(e,r)}commitTransaction(e){return o(this,jt).commitTransaction(e)}rollbackTransaction(e){return o(this,jt).rollbackTransaction(e)}async destroy(){o(this,cn)&&(await o(this,cn),o(this,Vn)||G(this,Vn,o(this,jt).destroy().catch(e=>(G(this,Vn,void 0),Promise.reject(e)))),await o(this,Vn))}}jt=new WeakMap,En=new WeakMap,cn=new WeakMap,Vn=new WeakMap,hi=new WeakMap,Ns=new WeakSet,Za=function(){return o(this,En).isLevelEnabled("query")||o(this,En).isLevelEnabled("error")},vs=new WeakSet,el=function(e){const r=e.executeQuery;e.executeQuery=async n=>{const O=qa();try{return await r.call(e,n)}catch(j){throw await Oe(this,xs,tl).call(this,j,n,O),j}finally{await Oe(this,Es,nl).call(this,n,O)}}},xs=new WeakSet,tl=async function(e,r,n){await o(this,En).error(()=>({level:"error",error:e,query:r,queryDurationMillis:Oe(this,pi,Eo).call(this,n)}))},Es=new WeakSet,nl=async function(e,r){await o(this,En).query(()=>({level:"query",query:e,queryDurationMillis:Oe(this,pi,Eo).call(this,r)}))},pi=new WeakSet,Eo=function(e){return qa()-e};class Na{constructor(e){D(this,Ss);D(this,_i,void 0);D(this,Sn,void 0);G(this,_i,e)}async provideConnection(e){for(;o(this,Sn);)await o(this,Sn);const r=Oe(this,Ss,rl).call(this,e);return G(this,Sn,r.then(()=>{G(this,Sn,void 0)}).catch(()=>{G(this,Sn,void 0)})),r}}_i=new WeakMap,Sn=new WeakMap,Ss=new WeakSet,rl=async function(e){return await e(o(this,_i))};const Ou=["read uncommitted","read committed","repeatable read","serializable"];h(["query","error"]);class Iu{constructor(e){D(this,kn,void 0);D(this,Jn,void 0);Ct(e)?(G(this,Jn,e),G(this,kn,h({query:!0,error:!0}))):(G(this,Jn,Tu),G(this,kn,h({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return o(this,kn)[e]}async query(e){o(this,kn).query&&await o(this,Jn).call(this,e())}async error(e){o(this,kn).error&&await o(this,Jn).call(this,e())}}kn=new WeakMap,Jn=new WeakMap;function Tu(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 Cu(t){return Jt(t)&&Ct(t.compile)}const Er=class Er extends Ui{constructor(r){let n,O;if(Pu(r))n={executor:r.executor},O={...r};else{const j=r.dialect,Y=j.createDriver(),he=j.createQueryCompiler(),Te=j.createAdapter(),je=new Iu(r.log??[]),et=new Au(Y,je),ct=new ku(et),ke=new ao(he,Te,ct,r.plugins??[]);n={executor:ke},O={config:r,executor:ke,dialect:j,driver:et}}super(n);D(this,ut,void 0);G(this,ut,h(O))}get schema(){return new oo(o(this,ut).executor)}get dynamic(){return new Su}get introspection(){return o(this,ut).dialect.createIntrospector(this.withoutPlugins())}case(r){return new oa({node:Ht.create(Ie(r)?void 0:Qi(r))})}get fn(){return sa()}transaction(){return new ls({...o(this,ut)})}connection(){return new va({...o(this,ut)})}withPlugin(r){return new Er({...o(this,ut),executor:o(this,ut).executor.withPlugin(r)})}withoutPlugins(){return new Er({...o(this,ut),executor:o(this,ut).executor.withoutPlugins()})}withSchema(r){return new Er({...o(this,ut),executor:o(this,ut).executor.withPluginAtFront(new zr(r))})}withTables(){return new Er({...o(this,ut)})}async destroy(){await o(this,ut).driver.destroy()}get isTransaction(){return!1}getExecutor(){return o(this,ut).executor}executeQuery(r,n=Fe()){const O=Cu(r)?r.compile():r;return this.getExecutor().executeQuery(O,n)}};ut=new WeakMap;let Zr=Er;const Sr=class Sr extends Zr{constructor(r){super(r);D(this,zt,void 0);G(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({...o(this,zt),executor:o(this,zt).executor.withPlugin(r)})}withoutPlugins(){return new Sr({...o(this,zt),executor:o(this,zt).executor.withoutPlugins()})}withSchema(r){return new Sr({...o(this,zt),executor:o(this,zt).executor.withPluginAtFront(new zr(r))})}withTables(){return new Sr({...o(this,zt)})}};zt=new WeakMap;let lo=Sr;function Pu(t){return Jt(t)&&Jt(t.config)&&Jt(t.driver)&&Jt(t.executor)&&Jt(t.dialect)}class va{constructor(e){D(this,Gn,void 0);G(this,Gn,h(e))}async execute(e){return o(this,Gn).executor.provideConnection(async r=>{const n=o(this,Gn).executor.withConnectionProvider(new Na(r)),O=new Zr({...o(this,Gn),executor:n});return await e(O)})}}Gn=new WeakMap,Ee(va,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const po=class po{constructor(e){D(this,Vt,void 0);G(this,Vt,h(e))}setIsolationLevel(e){return new po({...o(this,Vt),isolationLevel:e})}async execute(e){const{isolationLevel:r,...n}=o(this,Vt),O={isolationLevel:r};return Wu(O),o(this,Vt).executor.provideConnection(async j=>{const Y=o(this,Vt).executor.withConnectionProvider(new Na(j)),he=new lo({...n,executor:Y});try{await o(this,Vt).driver.beginTransaction(j,O);const Te=await e(he);return await o(this,Vt).driver.commitTransaction(j),Te}catch(Te){throw await o(this,Vt).driver.rollbackTransaction(j),Te}})}};Vt=new WeakMap;let ls=po;Ee(ls,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function Wu(t){if(t.isolationLevel&&!Ou.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const ks=class ks{constructor(e){D(this,kr);D(this,mi);D(this,yi);D(this,Nt,void 0);G(this,Nt,h(e))}get expressionType(){}as(e){return new Fu(this,e)}$castTo(){return new ks({...o(this,Nt)})}castTo(){return this.$castTo()}withPlugin(e){return new ks({...o(this,Nt),plugins:o(this,Nt).plugins!==void 0?h([...o(this,Nt).plugins,e]):h([e])})}toOperationNode(){return Oe(this,mi,So).call(this,Oe(this,kr,Fs).call(this))}compile(e){return Oe(this,yi,ko).call(this,Oe(this,kr,Fs).call(this,e))}async execute(e){const r=Oe(this,kr,Fs).call(this,e);return r.executeQuery(Oe(this,yi,ko).call(this,r),o(this,Nt).queryId)}};Nt=new WeakMap,kr=new WeakSet,Fs=function(e){const r=e!==void 0?e.getExecutor():Ks;return o(this,Nt).plugins!==void 0?r.withPlugins(o(this,Nt).plugins):r},mi=new WeakSet,So=function(e){return e.transformQuery(o(this,Nt).rawNode,o(this,Nt).queryId)},yi=new WeakSet,ko=function(e){return e.compileQuery(Oe(this,mi,So).call(this,e),o(this,Nt).queryId)};let Mt=ks;Ee(Mt,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class Fu{constructor(e,r){D(this,Ar,void 0);D(this,An,void 0);G(this,Ar,e),G(this,An,r)}get expression(){return o(this,Ar)}get alias(){return o(this,An)}toOperationNode(){return pn.create(o(this,Ar).toOperationNode(),Pt(o(this,An))?o(this,An).toOperationNode():Ue.create(o(this,An)))}}Ar=new WeakMap,An=new WeakMap;const xt=Object.assign((t,...e)=>new Mt({queryId:Fe(),rawNode:pt.create(t,(e==null?void 0:e.map(sn))??[])}),{ref(t){return new Mt({queryId:Fe(),rawNode:pt.createWithChild(Pn(t))})},val(t){return new Mt({queryId:Fe(),rawNode:pt.createWithChild(sn(t))})},value(t){return this.val(t)},table(t){return new Mt({queryId:Fe(),rawNode:pt.createWithChild(qt(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new Mt({queryId:Fe(),rawNode:pt.create(e,t.map(Ue.create))})},lit(t){return new Mt({queryId:Fe(),rawNode:pt.createWithChild(Rt.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new Mt({queryId:Fe(),rawNode:pt.createWithSql(t)})},join(t,e=xt`, `){const r=new Array(2*t.length-1),n=e.toOperationNode();for(let O=0;O{this.nodeStack.push(e),o(this,As)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}As=new WeakMap;class Du extends Lu{constructor(){super(...arguments);D(this,Or,"");D(this,Hn,[])}get numParameters(){return o(this,Hn).length}compileQuery(r){return G(this,Or,""),G(this,Hn,[]),this.visitNode(r),h({query:r,sql:this.getSql(),parameters:[...o(this,Hn)]})}getSql(){return o(this,Or)}visitSelectQuery(r){const n=this.parentNode!==void 0&&!Gt.is(this.parentNode)&&!gn.is(this.parentNode)&&!ia.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 O=r.length-1;for(let j=0;j<=O;j++)this.visitNode(r[j]),jj&&this.visitNode(O[j])}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(me.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(Ru[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 Dr.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))}visitJSONReference(r){this.visitNode(r.reference),this.visitNode(r.traversal)}visitJSONPath(r){r.inOperator&&this.visitNode(r.inOperator),this.append("'$");for(const n of r.pathLegs)this.visitNode(n);this.append("'")}visitJSONPathLeg(r){const n=r.type==="ArrayLocation";this.append(n?"[":"."),this.append(String(r.value)),n&&this.append("]")}visitJSONOperatorChain(r){for(let n=0,O=r.values.length;n"),this.visitNode(r.values[n])}append(r){G(this,Or,o(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(),O=this.getRightIdentifierWrapper();let j="";for(const Y of r)j+=Y,Y===n?j+=n:Y===O&&(j+=O);return j}addParameter(r){o(this,Hn).push(r)}appendImmediateValue(r){if(ge(r))this.append(`'${r}'`);else if(Ke(r)||Wr(r))this.append(r.toString());else if(Ao(r))this.append("null");else if(sl(r))this.appendImmediateValue(r.toISOString());else if(ol(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}Or=new WeakMap,Hn=new WeakMap;const Ru=h({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),Mu=h({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),wn=h({raw(t,e=[]){return h({sql:t,query:pt.createWithSql(t),parameters:h(e)})}}),Bu=/"/g;class Uu extends Du{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 Qu="kysely_migration",ju="kysely_migration_lock";h({__noMigrations__:!0});class zu{constructor(e){D(this,Os);D(this,Ir,void 0);G(this,Ir,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=o(this,Ir).selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",Qu).where("name","!=",ju));const n=await r.execute();return Promise.all(n.map(({name:O})=>Oe(this,Os,il).call(this,O)))}async getMetadata(e){return{tables:await this.getTables(e)}}}Ir=new WeakMap,Os=new WeakSet,il=async function(e){var Y,he,Te,je,et,ct;const r=o(this,Ir),n=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),O=(ct=(et=(je=(Te=(he=(Y=n.sql)==null?void 0:Y.split(/[\(\),]/))==null?void 0:he.find(ke=>ke.toLowerCase().includes("autoincrement")))==null?void 0:Te.trimStart())==null?void 0:je.split(/\s+/))==null?void 0:et[0])==null?void 0:ct.replace(/["`]/g,""),j=await r.selectFrom(xt`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:n.type==="view",columns:j.map(ke=>({name:ke.name,dataType:ke.type,isNullable:!ke.notnull,isAutoIncrementing:ke.name===O,hasDefaultValue:ke.dflt_value!=null}))}};class Vu{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Ju=class{createQueryCompiler(){return new Uu}createAdapter(){return new Vu}createIntrospector(t){return new zu(t)}},Gu=(ka=class{constructor(){D(this,gi,new Hu);ve(this,"connection")}async acquireConnection(){return await o(this,gi).lock(),this.connection}async beginTransaction(t){await t.executeQuery(wn.raw("begin"))}async commitTransaction(t){await t.executeQuery(wn.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(wn.raw("rollback"))}async releaseConnection(){o(this,gi).unlock()}},gi=new WeakMap,ka),Hu=class{constructor(){ve(this,"promise");ve(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()}},$u=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)}}},Ku=class extends Gu{constructor(e){super();ve(this,"config");ve(this,"db");this.config=e}async init(){var e,r;this.db=typeof this.config.database=="function"?await this.config.database():this.config.database,this.connection=new Xu(this.db),await((r=(e=this.config).onCreateConnection)==null?void 0:r.call(e,this.connection))}async destroy(){var e;(e=this.db)==null||e.close()}},Xu=class extends $u{constructor(e){super();ve(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)}}},Yu=(Aa=class extends Ju{constructor(e){super();D(this,wi,void 0);G(this,wi,e)}createDriver(){return new Ku(o(this,wi))}},wi=new WeakMap,Aa);async function Zu(t,e=4096,r=32*1024){await t.executeQuery(wn.raw(`PRAGMA cache_size = ${e};`)),await t.executeQuery(wn.raw("PRAGMA journal_mode = WAL;")),await t.executeQuery(wn.raw("PRAGMA temp_store = MEMORY;")),await t.executeQuery(wn.raw(`PRAGMA page_size = ${r};`)),await t.executeQuery(wn.raw("PRAGMA synchronous = NORMAL;"))}var ec=(()=>{var t=self.location.href;return function(e){var r=e||{},n=typeof r<"u"?r:{},O,j;n.ready=new Promise(function(s,i){O=s,j=i});const Y=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:()=>{}});delete globalThis.sqlite3InitModuleState,Y.debugModule("globalThis.location =",globalThis.location);const he="emscripten-bug-17951";n[he]=function s(i,l){i.env.foo=function(){};const a=n.locateFile(s.uri,typeof ke>"u"?"":ke);Y.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[he].uri="sqlite3.wasm";var Te=Object.assign({},n),je="./this.program",et=typeof window=="object",ct=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var ke="";function bi(s){return n.locateFile?n.locateFile(s,ke):ke+s}var $n,Tr,Be;(et||ct)&&(ct?ke=self.location.href:typeof document<"u"&&document.currentScript&&(ke=document.currentScript.src),t&&(ke=t),ke.indexOf("blob:")!==0?ke=ke.substr(0,ke.replace(/[?#].*/,"").lastIndexOf("/")+1):ke="",$n=s=>{var i=new XMLHttpRequest;return i.open("GET",s,!1),i.send(null),i.responseText},ct&&(Be=s=>{var i=new XMLHttpRequest;return i.open("GET",s,!1),i.responseType="arraybuffer",i.send(null),new Uint8Array(i.response)}),Tr=(s,i,l)=>{var a=new XMLHttpRequest;a.open("GET",s,!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 Ot=n.print||console.log.bind(console),It=n.printErr||console.warn.bind(console);Object.assign(n,Te),Te=null,n.arguments&&n.arguments,n.thisProgram&&(je=n.thisProgram),n.quit&&n.quit;var On;n.wasmBinary&&(On=n.wasmBinary),n.noExitRuntime,typeof WebAssembly!="object"&&Yn("no native wasm support detected");var Zt,Kn=!1;function In(s,i){s||Yn(i)}var Oa=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Cr(s,i,l){for(var a=i+l,u=i;s[u]&&!(u>=a);)++u;if(u-i>16&&s.buffer&&Oa)return Oa.decode(s.subarray(i,u));for(var d="";i>10,56320|V&1023)}}return d}function yc(s,i){return s?Cr(Ni,s,i):""}function Is(s,i,l,a){if(!(a>0))return 0;for(var u=l,d=l+a-1,N=0;N=55296&&S<=57343){var C=s.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 Ia(s,i,l){return Is(s,Ni,i,l)}function qi(s){for(var i=0,l=0;l=55296&&a<=57343?(i+=4,++l):i+=3}return i}var Tt,Ni,Ta,_e,tt;function Ca(){var s=Zt.buffer;n.HEAP8=Tt=new Int8Array(s),n.HEAP16=Ta=new Int16Array(s),n.HEAP32=_e=new Int32Array(s),n.HEAPU8=Ni=new Uint8Array(s),n.HEAPU16=new Uint16Array(s),n.HEAPU32=tt=new Uint32Array(s),n.HEAPF32=new Float32Array(s),n.HEAPF64=new Float64Array(s),n.HEAP64=new BigInt64Array(s),n.HEAPU64=new BigUint64Array(s)}var Pa=n.INITIAL_MEMORY||16777216;n.wasmMemory?Zt=n.wasmMemory:Zt=new WebAssembly.Memory({initial:Pa/65536,maximum:2147483648/65536}),Ca(),Pa=Zt.buffer.byteLength;var Wa=[],Fa=[],La=[];function gc(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)qc(n.preRun.shift());mo(Wa)}function wc(){!n.noFSInit&&!c.init.initialized&&c.init(),c.ignorePermissions=!1,mo(Fa)}function bc(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)vc(n.postRun.shift());mo(La)}function qc(s){Wa.unshift(s)}function Nc(s){Fa.unshift(s)}function vc(s){La.unshift(s)}var Xn=0,vi=null;function kd(s){return s}function _o(s){Xn++,n.monitorRunDependencies&&n.monitorRunDependencies(Xn)}function Ts(s){if(Xn--,n.monitorRunDependencies&&n.monitorRunDependencies(Xn),Xn==0&&vi){var i=vi;vi=null,i()}}function Yn(s){n.onAbort&&n.onAbort(s),s="Aborted("+s+")",It(s),Kn=!0,s+=". Build with -sASSERTIONS for more info.";var i=new WebAssembly.RuntimeError(s);throw j(i),i}var xc="data:application/octet-stream;base64,";function Da(s){return s.startsWith(xc)}var Ft;n.locateFile?(Ft="sqlite3.wasm",Da(Ft)||(Ft=bi(Ft))):Ft=new URL(""+new URL("sqlite3-14470338.wasm",self.location.href).href,self.location).href;function Ra(s){try{if(s==Ft&&On)return new Uint8Array(On);if(Be)return Be(s);throw"both async and sync fetching of the wasm failed"}catch(i){Yn(i)}}function Ec(){return!On&&(et||ct)&&typeof fetch=="function"?fetch(Ft,{credentials:"same-origin"}).then(function(s){if(!s.ok)throw"failed to load wasm binary file at '"+Ft+"'";return s.arrayBuffer()}).catch(function(){return Ra(Ft)}):Promise.resolve().then(function(){return Ra(Ft)})}function Sc(){var s={env:za,wasi_snapshot_preview1:za};function i(N,S){var C=N.exports;n.asm=C,n.asm.__indirect_function_table,Nc(n.asm.__wasm_call_ctors),Ts()}_o();function l(N){i(N.instance)}function a(N){return Ec().then(function(S){return WebAssembly.instantiate(S,s)}).then(function(S){return S}).then(N,function(S){It("failed to asynchronously prepare wasm: "+S),Yn(S)})}function u(){return!On&&typeof WebAssembly.instantiateStreaming=="function"&&!Da(Ft)&&typeof fetch=="function"?fetch(Ft,{credentials:"same-origin"}).then(function(N){var S=WebAssembly.instantiateStreaming(N,s);return S.then(l,function(C){return It("wasm streaming compile failed: "+C),It("falling back to ArrayBuffer instantiation"),a(l)})}):a(l)}if(n.instantiateWasm)try{var d=n.instantiateWasm(s,i);return d}catch(N){It("Module.instantiateWasm callback failed with error: "+N),j(N)}return u().catch(j),{}}var ye,st;function mo(s){for(;s.length>0;)s.shift()(n)}var Ne={isAbs:s=>s.charAt(0)==="/",splitPath:s=>{var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return i.exec(s).slice(1)},normalizeArray:(s,i)=>{for(var l=0,a=s.length-1;a>=0;a--){var u=s[a];u==="."?s.splice(a,1):u===".."?(s.splice(a,1),l++):l&&(s.splice(a,1),l--)}if(i)for(;l;l--)s.unshift("..");return s},normalize:s=>{var i=Ne.isAbs(s),l=s.substr(-1)==="/";return s=Ne.normalizeArray(s.split("/").filter(a=>!!a),!i).join("/"),!s&&!i&&(s="."),s&&l&&(s+="/"),(i?"/":"")+s},dirname:s=>{var i=Ne.splitPath(s),l=i[0],a=i[1];return!l&&!a?".":(a&&(a=a.substr(0,a.length-1)),l+a)},basename:s=>{if(s==="/")return"/";s=Ne.normalize(s),s=s.replace(/\/$/,"");var i=s.lastIndexOf("/");return i===-1?s:s.substr(i+1)},join:function(){var s=Array.prototype.slice.call(arguments);return Ne.normalize(s.join("/"))},join2:(s,i)=>Ne.normalize(s+"/"+i)};function kc(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var s=new Uint8Array(1);return()=>(crypto.getRandomValues(s),s[0])}else return()=>Yn("randomDevice")}var dn={resolve:function(){for(var s="",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"";s=a+"/"+s,i=Ne.isAbs(a)}return s=Ne.normalizeArray(s.split("/").filter(u=>!!u),!i).join("/"),(i?"/":"")+s||"."},relative:(s,i)=>{s=dn.resolve(s).substr(1),i=dn.resolve(i).substr(1);function l(V){for(var K=0;K=0&&V[te]==="";te--);return K>te?[]:V.slice(K,te-K+1)}for(var a=l(s.split("/")),u=l(i.split("/")),d=Math.min(a.length,u.length),N=d,S=0;S0?l:qi(s)+1,u=new Array(a),d=Is(s,u,0,u.length);return i&&(u.length=d),u}var Zn={ttys:[],init:function(){},shutdown:function(){},register:function(s,i){Zn.ttys[s]={input:[],output:[],ops:i},c.registerDevice(s,Zn.stream_ops)},stream_ops:{open:function(s){var i=Zn.ttys[s.node.rdev];if(!i)throw new c.ErrnoError(43);s.tty=i,s.seekable=!1},close:function(s){s.tty.ops.fsync(s.tty)},fsync:function(s){s.tty.ops.fsync(s.tty)},read:function(s,i,l,a,u){if(!s.tty||!s.tty.ops.get_char)throw new c.ErrnoError(60);for(var d=0,N=0;N0&&(dn(Ar(s.output,0)),s.output=[])}},default_tty1_ops:{put_char:function(s,i){i===null||i===10?(gt(Ar(s.output,0)),s.output=[]):i!=0&&s.output.push(i)},fsync:function(s){s.output&&s.output.length>0&&(gt(Ar(s.output,0)),s.output=[])}}};function Da(s){Kn()}var fe={ops_table:null,mount:function(s){return fe.createNode(null,"/",16895,0)},createNode:function(s,i,l,a){if(c.isBlkdev(l)||c.isFIFO(l))throw new c.ErrnoError(63);fe.ops_table||(fe.ops_table={dir:{node:{getattr:fe.node_ops.getattr,setattr:fe.node_ops.setattr,lookup:fe.node_ops.lookup,mknod:fe.node_ops.mknod,rename:fe.node_ops.rename,unlink:fe.node_ops.unlink,rmdir:fe.node_ops.rmdir,readdir:fe.node_ops.readdir,symlink:fe.node_ops.symlink},stream:{llseek:fe.stream_ops.llseek}},file:{node:{getattr:fe.node_ops.getattr,setattr:fe.node_ops.setattr},stream:{llseek:fe.stream_ops.llseek,read:fe.stream_ops.read,write:fe.stream_ops.write,allocate:fe.stream_ops.allocate,mmap:fe.stream_ops.mmap,msync:fe.stream_ops.msync}},link:{node:{getattr:fe.node_ops.getattr,setattr:fe.node_ops.setattr,readlink:fe.node_ops.readlink},stream:{}},chrdev:{node:{getattr:fe.node_ops.getattr,setattr:fe.node_ops.setattr},stream:c.chrdev_stream_ops}});var u=c.createNode(s,i,l,a);return c.isDir(u.mode)?(u.node_ops=fe.ops_table.dir.node,u.stream_ops=fe.ops_table.dir.stream,u.contents={}):c.isFile(u.mode)?(u.node_ops=fe.ops_table.file.node,u.stream_ops=fe.ops_table.file.stream,u.usedBytes=0,u.contents=null):c.isLink(u.mode)?(u.node_ops=fe.ops_table.link.node,u.stream_ops=fe.ops_table.link.stream):c.isChrdev(u.mode)&&(u.node_ops=fe.ops_table.chrdev.node,u.stream_ops=fe.ops_table.chrdev.stream),u.timestamp=Date.now(),s&&(s.contents[i]=u,s.timestamp=u.timestamp),u},getFileDataAsTypedArray:function(s){return s.contents?s.contents.subarray?s.contents.subarray(0,s.usedBytes):new Uint8Array(s.contents):new Uint8Array(0)},expandFileStorage:function(s,i){var l=s.contents?s.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=s.contents;s.contents=new Uint8Array(i),s.usedBytes>0&&s.contents.set(u.subarray(0,s.usedBytes),0)}},resizeFileStorage:function(s,i){if(s.usedBytes!=i)if(i==0)s.contents=null,s.usedBytes=0;else{var l=s.contents;s.contents=new Uint8Array(i),l&&s.contents.set(l.subarray(0,Math.min(i,s.usedBytes))),s.usedBytes=i}},node_ops:{getattr:function(s){var i={};return i.dev=c.isChrdev(s.mode)?s.id:1,i.ino=s.id,i.mode=s.mode,i.nlink=1,i.uid=0,i.gid=0,i.rdev=s.rdev,c.isDir(s.mode)?i.size=4096:c.isFile(s.mode)?i.size=s.usedBytes:c.isLink(s.mode)?i.size=s.link.length:i.size=0,i.atime=new Date(s.timestamp),i.mtime=new Date(s.timestamp),i.ctime=new Date(s.timestamp),i.blksize=4096,i.blocks=Math.ceil(i.size/i.blksize),i},setattr:function(s,i){i.mode!==void 0&&(s.mode=i.mode),i.timestamp!==void 0&&(s.timestamp=i.timestamp),i.size!==void 0&&fe.resizeFileStorage(s,i.size)},lookup:function(s,i){throw c.genericErrors[44]},mknod:function(s,i,l,a){return fe.createNode(s,i,l,a)},rename:function(s,i,l){if(c.isDir(s.mode)){var a;try{a=c.lookupNode(i,l)}catch{}if(a)for(var u in a.contents)throw new c.ErrnoError(55)}delete s.parent.contents[s.name],s.parent.timestamp=Date.now(),s.name=l,i.contents[l]=s,i.timestamp=s.parent.timestamp,s.parent=i},unlink:function(s,i){delete s.contents[i],s.timestamp=Date.now()},rmdir:function(s,i){var l=c.lookupNode(s,i);for(var a in l.contents)throw new c.ErrnoError(55);delete s.contents[i],s.timestamp=Date.now()},readdir:function(s){var i=[".",".."];for(var l in s.contents)s.contents.hasOwnProperty(l)&&i.push(l);return i},symlink:function(s,i,l){var a=fe.createNode(s,i,41471,0);return a.link=l,a},readlink:function(s){if(!c.isLink(s.mode))throw new c.ErrnoError(28);return s.link}},stream_ops:{read:function(s,i,l,a,u){var d=s.node.contents;if(u>=s.node.usedBytes)return 0;var N=Math.min(s.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{dc(d,'Loading data file "'+s+'" failed (no arrayBuffer).'),i(new Uint8Array(d)),u&&As()},d=>{if(l)l();else throw'Loading data file "'+s+'" 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:(s,i={})=>{if(s=fn.resolve(s),!s)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=s.split("/").filter(te=>!!te),u=c.root,d="/",N=0;N40)throw new c.ErrnoError(32)}}return{path:d,node:u}},getPath:s=>{for(var i;;){if(c.isRoot(s)){var l=s.mount.mountpoint;return i?l[l.length-1]!=="/"?l+"/"+i:l+i:l}i=i?s.name+"/"+i:s.name,s=s.parent}},hashName:(s,i)=>{for(var l=0,a=0;a>>0)%c.nameTable.length},hashAddNode:s=>{var i=c.hashName(s.parent.id,s.name);s.name_next=c.nameTable[i],c.nameTable[i]=s},hashRemoveNode:s=>{var i=c.hashName(s.parent.id,s.name);if(c.nameTable[i]===s)c.nameTable[i]=s.name_next;else for(var l=c.nameTable[i];l;){if(l.name_next===s){l.name_next=s.name_next;break}l=l.name_next}},lookupNode:(s,i)=>{var l=c.mayLookup(s);if(l)throw new c.ErrnoError(l,s);for(var a=c.hashName(s.id,i),u=c.nameTable[a];u;u=u.name_next){var d=u.name;if(u.parent.id===s.id&&d===i)return u}return c.lookup(s,i)},createNode:(s,i,l,a)=>{var u=new c.FSNode(s,i,l,a);return c.hashAddNode(u),u},destroyNode:s=>{c.hashRemoveNode(s)},isRoot:s=>s===s.parent,isMountpoint:s=>!!s.mounted,isFile:s=>(s&61440)===32768,isDir:s=>(s&61440)===16384,isLink:s=>(s&61440)===40960,isChrdev:s=>(s&61440)===8192,isBlkdev:s=>(s&61440)===24576,isFIFO:s=>(s&61440)===4096,isSocket:s=>(s&49152)===49152,flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:s=>{var i=c.flagModes[s];if(typeof i>"u")throw new Error("Unknown file open mode: "+s);return i},flagsToPermissionString:s=>{var i=["r","w","rw"][s&3];return s&512&&(i+="w"),i},nodePermissions:(s,i)=>c.ignorePermissions?0:i.includes("r")&&!(s.mode&292)||i.includes("w")&&!(s.mode&146)||i.includes("x")&&!(s.mode&73)?2:0,mayLookup:s=>{var i=c.nodePermissions(s,"x");return i||(s.node_ops.lookup?0:2)},mayCreate:(s,i)=>{try{var l=c.lookupNode(s,i);return 20}catch{}return c.nodePermissions(s,"wx")},mayDelete:(s,i,l)=>{var a;try{a=c.lookupNode(s,i)}catch(d){return d.errno}var u=c.nodePermissions(s,"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:(s,i)=>s?c.isLink(s.mode)?32:c.isDir(s.mode)&&(c.flagsToPermissionString(i)!=="r"||i&512)?31:c.nodePermissions(s,c.flagsToPermissionString(i)):44,MAX_OPEN_FDS:4096,nextfd:(s=0,i=c.MAX_OPEN_FDS)=>{for(var l=s;l<=i;l++)if(!c.streams[l])return l;throw new c.ErrnoError(33)},getStream:s=>c.streams[s],createStream:(s,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}}})),s=Object.assign(new c.FSStream,s);var a=c.nextfd(i,l);return s.fd=a,c.streams[a]=s,s},closeStream:s=>{c.streams[s]=null},chrdev_stream_ops:{open:s=>{var i=c.getDevice(s.node.rdev);s.stream_ops=i.stream_ops,s.stream_ops.open&&s.stream_ops.open(s)},llseek:()=>{throw new c.ErrnoError(70)}},major:s=>s>>8,minor:s=>s&255,makedev:(s,i)=>s<<8|i,registerDevice:(s,i)=>{c.devices[s]={stream_ops:i}},getDevice:s=>c.devices[s],getMounts:s=>{for(var i=[],l=[s];l.length;){var a=l.pop();i.push(a),l.push.apply(l,a.mounts)}return i},syncfs:(s,i)=>{typeof s=="function"&&(i=s,s=!1),c.syncFSRequests++,c.syncFSRequests>1&>("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,s,d)})},mount:(s,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:s,opts:i,mountpoint:l,mounts:[]},C=s.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:s=>{var i=c.lookupPath(s,{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:(s,i)=>s.node_ops.lookup(s,i),mknod:(s,i,l)=>{var a=c.lookupPath(s,{parent:!0}),u=a.node,d=ve.basename(s);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:(s,i)=>(i=i!==void 0?i:438,i&=4095,i|=32768,c.mknod(s,i,0)),mkdir:(s,i)=>(i=i!==void 0?i:511,i&=1023,i|=16384,c.mknod(s,i,0)),mkdirTree:(s,i)=>{for(var l=s.split("/"),a="",u=0;u(typeof l>"u"&&(l=i,i=438),i|=8192,c.mknod(s,i,l)),symlink:(s,i)=>{if(!fn.resolve(s))throw new c.ErrnoError(44);var l=c.lookupPath(i,{parent:!0}),a=l.node;if(!a)throw new c.ErrnoError(44);var u=ve.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,s)},rename:(s,i)=>{var l=ve.dirname(s),a=ve.dirname(i),u=ve.basename(s),d=ve.basename(i),N,S,C;if(N=c.lookupPath(s,{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),K=fn.relative(s,a);if(K.charAt(0)!==".")throw new c.ErrnoError(28);if(K=fn.relative(i,l),K.charAt(0)!==".")throw new c.ErrnoError(55);var te;try{te=c.lookupNode(C,d)}catch{}if(z!==te){var k=c.isDir(z.mode),m=c.mayDelete(S,u,k);if(m)throw new c.ErrnoError(m);if(m=te?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)||te&&c.isMountpoint(te))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:s=>{var i=c.lookupPath(s,{parent:!0}),l=i.node,a=ve.basename(s),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:s=>{var i=c.lookupPath(s,{follow:!0}),l=i.node;if(!l.node_ops.readdir)throw new c.ErrnoError(54);return l.node_ops.readdir(l)},unlink:s=>{var i=c.lookupPath(s,{parent:!0}),l=i.node;if(!l)throw new c.ErrnoError(44);var a=ve.basename(s),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:s=>{var i=c.lookupPath(s),l=i.node;if(!l)throw new c.ErrnoError(44);if(!l.node_ops.readlink)throw new c.ErrnoError(28);return fn.resolve(c.getPath(l.parent),l.node_ops.readlink(l))},stat:(s,i)=>{var l=c.lookupPath(s,{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:s=>c.stat(s,!0),chmod:(s,i,l)=>{var a;if(typeof s=="string"){var u=c.lookupPath(s,{follow:!l});a=u.node}else a=s;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:(s,i)=>{c.chmod(s,i,!0)},fchmod:(s,i)=>{var l=c.getStream(s);if(!l)throw new c.ErrnoError(8);c.chmod(l.node,i)},chown:(s,i,l,a)=>{var u;if(typeof s=="string"){var d=c.lookupPath(s,{follow:!a});u=d.node}else u=s;if(!u.node_ops.setattr)throw new c.ErrnoError(63);u.node_ops.setattr(u,{timestamp:Date.now()})},lchown:(s,i,l)=>{c.chown(s,i,l,!0)},fchown:(s,i,l)=>{var a=c.getStream(s);if(!a)throw new c.ErrnoError(8);c.chown(a.node,i,l)},truncate:(s,i)=>{if(i<0)throw new c.ErrnoError(28);var l;if(typeof s=="string"){var a=c.lookupPath(s,{follow:!0});l=a.node}else l=s;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:(s,i)=>{var l=c.getStream(s);if(!l)throw new c.ErrnoError(8);if(!(l.flags&2097155))throw new c.ErrnoError(28);c.truncate(l.node,i)},utime:(s,i,l)=>{var a=c.lookupPath(s,{follow:!0}),u=a.node;u.node_ops.setattr(u,{timestamp:Math.max(i,l)})},open:(s,i,l)=>{if(s==="")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 s=="object")a=s;else{s=ve.normalize(s);try{var u=c.lookupPath(s,{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(s,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={}),s in c.readFiles||(c.readFiles[s]=1)),S},close:s=>{if(c.isClosed(s))throw new c.ErrnoError(8);s.getdents&&(s.getdents=null);try{s.stream_ops.close&&s.stream_ops.close(s)}catch(i){throw i}finally{c.closeStream(s.fd)}s.fd=null},isClosed:s=>s.fd===null,llseek:(s,i,l)=>{if(c.isClosed(s))throw new c.ErrnoError(8);if(!s.seekable||!s.stream_ops.llseek)throw new c.ErrnoError(70);if(l!=0&&l!=1&&l!=2)throw new c.ErrnoError(28);return s.position=s.stream_ops.llseek(s,i,l),s.ungotten=[],s.position},read:(s,i,l,a,u)=>{if(a<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(s))throw new c.ErrnoError(8);if((s.flags&2097155)===1)throw new c.ErrnoError(8);if(c.isDir(s.node.mode))throw new c.ErrnoError(31);if(!s.stream_ops.read)throw new c.ErrnoError(28);var d=typeof u<"u";if(!d)u=s.position;else if(!s.seekable)throw new c.ErrnoError(70);var N=s.stream_ops.read(s,i,l,a,u);return d||(s.position+=N),N},write:(s,i,l,a,u,d)=>{if(a<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(s))throw new c.ErrnoError(8);if(!(s.flags&2097155))throw new c.ErrnoError(8);if(c.isDir(s.node.mode))throw new c.ErrnoError(31);if(!s.stream_ops.write)throw new c.ErrnoError(28);s.seekable&&s.flags&1024&&c.llseek(s,0,2);var N=typeof u<"u";if(!N)u=s.position;else if(!s.seekable)throw new c.ErrnoError(70);var S=s.stream_ops.write(s,i,l,a,u,d);return N||(s.position+=S),S},allocate:(s,i,l)=>{if(c.isClosed(s))throw new c.ErrnoError(8);if(i<0||l<=0)throw new c.ErrnoError(28);if(!(s.flags&2097155))throw new c.ErrnoError(8);if(!c.isFile(s.node.mode)&&!c.isDir(s.node.mode))throw new c.ErrnoError(43);if(!s.stream_ops.allocate)throw new c.ErrnoError(138);s.stream_ops.allocate(s,i,l)},mmap:(s,i,l,a,u)=>{if(a&2&&!(u&2)&&(s.flags&2097155)!==2)throw new c.ErrnoError(2);if((s.flags&2097155)===1)throw new c.ErrnoError(2);if(!s.stream_ops.mmap)throw new c.ErrnoError(43);return s.stream_ops.mmap(s,i,l,a,u)},msync:(s,i,l,a,u)=>s.stream_ops.msync?s.stream_ops.msync(s,i,l,a,u):0,munmap:s=>0,ioctl:(s,i,l)=>{if(!s.stream_ops.ioctl)throw new c.ErrnoError(59);return s.stream_ops.ioctl(s,i,l)},readFile:(s,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(s,i.flags),u=c.stat(s),d=u.size,N=new Uint8Array(d);return c.read(a,N,0,d,0),i.encoding==="utf8"?l=Ar(N,0):i.encoding==="binary"&&(l=N),c.close(a),l},writeFile:(s,i,l={})=>{l.flags=l.flags||577;var a=c.open(s,l.flags,l.mode);if(typeof i=="string"){var u=new Uint8Array(wi(i)+1),d=Os(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:s=>{var i=c.lookupPath(s,{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)),Xn.register(c.makedev(5,0),Xn.default_tty_ops),Xn.register(c.makedev(6,0),Xn.default_tty1_ops),c.mkdev("/dev/tty",c.makedev(5,0)),c.mkdev("/dev/tty1",c.makedev(6,0));var s=Nc();c.createDevice("/dev","random",s),c.createDevice("/dev","urandom",s),c.mkdir("/dev/shm"),c.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{c.mkdir("/proc");var s=c.mkdir("/proc/self");c.mkdir("/proc/self/fd"),c.mount({mount:()=>{var i=c.createNode(s,"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(s=>{c.genericErrors[s]=new c.ErrnoError(s),c.genericErrors[s].stack=""}))},staticInit:()=>{c.ensureErrnoError(),c.nameTable=new Array(4096),c.mount(fe,{},"/"),c.createDefaultDirectories(),c.createDefaultDevices(),c.createSpecialDirectories(),c.filesystems={MEMFS:fe}},init:(s,i,l)=>{c.init.initialized=!0,c.ensureErrnoError(),n.stdin=s||n.stdin,n.stdout=i||n.stdout,n.stderr=l||n.stderr,c.createStandardStreams()},quit:()=>{c.init.initialized=!1;for(var s=0;s{var l=0;return s&&(l|=365),i&&(l|=146),l},findObject:(s,i)=>{var l=c.analyzePath(s,i);return l.exists?l.object:null},analyzePath:(s,i)=>{try{var l=c.lookupPath(s,{follow:!i});s=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(s,{parent:!0});a.parentExists=!0,a.parentPath=l.path,a.parentObject=l.node,a.name=ve.basename(s),l=c.lookupPath(s,{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:(s,i,l,a)=>{s=typeof s=="string"?s:c.getPath(s);for(var u=i.split("/").reverse();u.length;){var d=u.pop();if(d){var N=ve.join2(s,d);try{c.mkdir(N)}catch{}s=N}}return N},createFile:(s,i,l,a,u)=>{var d=ve.join2(typeof s=="string"?s:c.getPath(s),i),N=c.getMode(a,u);return c.create(d,N)},createDataFile:(s,i,l,a,u,d)=>{var N=i;s&&(s=typeof s=="string"?s:c.getPath(s),N=i?ve.join2(s,i):s);var S=c.getMode(a,u),C=c.create(N,S);if(l){if(typeof l=="string"){for(var z=new Array(l.length),K=0,te=l.length;K{var u=ve.join2(typeof s=="string"?s:c.getPath(s),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,K,te)=>{for(var k=0,m=0;m{for(var k=0;k{if(s.isDevice||s.isFolder||s.link||s.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(Me)try{s.contents=mo(Me(s.url),!0),s.usedBytes=s.contents.length}catch{throw new c.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(s,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",q=(x=m.getResponseHeader("Content-Encoding"))&&x==="gzip",W=1024*1024;E||(W=y);var B=(L,ie)=>{if(L>ie)throw new Error("invalid range ("+L+", "+ie+") or no bytes requested!");if(ie>y-1)throw new Error("only "+y+" bytes available! programmer error!");var j=new XMLHttpRequest;if(j.open("GET",l,!1),y!==W&&j.setRequestHeader("Range","bytes="+L+"-"+ie),j.responseType="arraybuffer",j.overrideMimeType&&j.overrideMimeType("text/plain; charset=x-user-defined"),j.send(null),!(j.status>=200&&j.status<300||j.status===304))throw new Error("Couldn't load "+l+". Status: "+j.status);return j.response!==void 0?new Uint8Array(j.response||[]):mo(j.responseText||"",!0)},R=this;R.setDataGetter(L=>{var ie=L*W,j=(L+1)*W-1;if(j=Math.min(j,y-1),typeof R.chunks[L]>"u"&&(R.chunks[L]=B(ie,j)),typeof R.chunks[L]>"u")throw new Error("doXHR failed!");return R.chunks[L]}),(q||!y)&&(W=y=1,y=this.getter(0).length,W=y,dn("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=y,this._chunkSize=W,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!et)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(s,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={},K=Object.keys(C.stream_ops);K.forEach(k=>{var m=C.stream_ops[k];z[k]=function(){return c.forceLoadFile(C),m.apply(null,arguments)}});function te(k,m,y,x,E){var q=k.node.contents;if(E>=q.length)return 0;var W=Math.min(q.length-E,x);if(q.slice)for(var B=0;B(c.forceLoadFile(C),te(k,m,y,x,E)),z.mmap=(k,m,y,x,E)=>{c.forceLoadFile(C);var q=Da();if(!q)throw new c.ErrnoError(48);return te(k,It,q,m,y),{ptr:q,allocated:!0}},C.stream_ops=z,C},createPreloadedFile:(s,i,l,a,u,d,N,S,C,z)=>{var K=i?fn.resolve(ve.join2(s,i)):s;function te(k){function m(y){z&&z(),S||c.createDataFile(s,i,y,a,u,C),d&&d(),As()}Browser.handledByPreloadPlugin(k,K,m,()=>{N&&N(),As()})||m(k)}po(),typeof l=="string"?vc(l,k=>te(k),N):te(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:(s,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=()=>{dn("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,K=s.length;function te(){z==0?i():l()}s.forEach(k=>{var m=S.put(c.analyzePath(k).object.contents,k);m.onsuccess=()=>{C++,C+z==K&&te()},m.onerror=()=>{z++,C+z==K&&te()}}),N.onerror=l},u.onerror=l},loadFilesFromDB:(s,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,K=s.length;function te(){z==0?i():l()}s.forEach(k=>{var m=S.get(k);m.onsuccess=()=>{c.analyzePath(k).exists&&c.unlink(k),c.createDataFile(ve.dirname(k),ve.basename(k),m.result,!0,!0,!0),C++,C+z==K&&te()},m.onerror=()=>{z++,C+z==K&&te()}}),N.onerror=l},u.onerror=l}},de={DEFAULT_POLLMASK:5,calculateAt:function(s,i,l){if(ve.isAbs(i))return i;var a;if(s===-100)a=c.cwd();else{var u=de.getStreamFromFD(s);a=u.path}if(i.length==0){if(!l)throw new c.ErrnoError(44);return a}return ve.join2(a,i)},doStat:function(s,i,l){try{var a=s(i)}catch(S){if(S&&S.node&&ve.normalize(i)!==ve.normalize(c.getPath(S.node)))return-54;throw S}me[l>>2]=a.dev,me[l+8>>2]=a.ino,me[l+12>>2]=a.mode,tt[l+16>>2]=a.nlink,me[l+20>>2]=a.uid,me[l+24>>2]=a.gid,me[l+28>>2]=a.rdev,st=[a.size>>>0,(ge=a.size,+Math.abs(ge)>=1?ge>0?(Math.min(+Math.floor(ge/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ge-+(~~ge>>>0))/4294967296)>>>0:0)],me[l+40>>2]=st[0],me[l+44>>2]=st[1],me[l+48>>2]=4096,me[l+52>>2]=a.blocks;var u=a.atime.getTime(),d=a.mtime.getTime(),N=a.ctime.getTime();return st=[Math.floor(u/1e3)>>>0,(ge=Math.floor(u/1e3),+Math.abs(ge)>=1?ge>0?(Math.min(+Math.floor(ge/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ge-+(~~ge>>>0))/4294967296)>>>0:0)],me[l+56>>2]=st[0],me[l+60>>2]=st[1],tt[l+64>>2]=u%1e3*1e3,st=[Math.floor(d/1e3)>>>0,(ge=Math.floor(d/1e3),+Math.abs(ge)>=1?ge>0?(Math.min(+Math.floor(ge/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ge-+(~~ge>>>0))/4294967296)>>>0:0)],me[l+72>>2]=st[0],me[l+76>>2]=st[1],tt[l+80>>2]=d%1e3*1e3,st=[Math.floor(N/1e3)>>>0,(ge=Math.floor(N/1e3),+Math.abs(ge)>=1?ge>0?(Math.min(+Math.floor(ge/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ge-+(~~ge>>>0))/4294967296)>>>0:0)],me[l+88>>2]=st[0],me[l+92>>2]=st[1],tt[l+96>>2]=N%1e3*1e3,st=[a.ino>>>0,(ge=a.ino,+Math.abs(ge)>=1?ge>0?(Math.min(+Math.floor(ge/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ge-+(~~ge>>>0))/4294967296)>>>0:0)],me[l+104>>2]=st[0],me[l+108>>2]=st[1],0},doMsync:function(s,i,l,a,u){if(!c.isFile(i.node.mode))throw new c.ErrnoError(43);if(a&2)return 0;var d=bi.slice(s,s+l);c.msync(i,d,u,l,a)},varargs:void 0,get:function(){de.varargs+=4;var s=me[de.varargs-4>>2];return s},getStr:function(s){var i=fc(s);return i},getStreamFromFD:function(s){var i=c.getStream(s);if(!i)throw new c.ErrnoError(8);return i}};function xc(s,i){try{return s=de.getStr(s),c.chmod(s,i),0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Ec(s,i,l,a){try{if(i=de.getStr(i),i=de.calculateAt(s,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 Sc(s,i){try{return c.fchmod(s,i),0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function kc(s,i,l){try{return c.fchown(s,i,l),0}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}function Oc(s){return me[ja()>>2]=s,s}function Ac(s,i,l){de.varargs=l;try{var a=de.getStreamFromFD(s);switch(i){case 0:{var u=de.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=de.get();return a.flags|=u,0}case 5:{var u=de.get(),N=0;return Aa[u+N>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return Oc(28),-1;default:return-28}}catch(S){if(typeof c>"u"||!(S instanceof c.ErrnoError))throw S;return-S.errno}}function Ic(s,i){try{var l=de.getStreamFromFD(s);return de.doStat(c.stat,l.path,i)}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}var Tc=9007199254740992,Cc=-9007199254740992;function Ra(s){return sTc?NaN:Number(s)}function Pc(s,i){try{return i=Ra(i),isNaN(i)?-61:(c.ftruncate(s,i),0)}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Wc(s,i){try{if(i===0)return-28;var l=c.cwd(),a=wi(l)+1;return i"u"||!(u instanceof c.ErrnoError))throw u;return-u.errno}}function Fc(s,i,l){de.varargs=l;try{var a=de.getStreamFromFD(s);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=de.get();return me[u>>2]=0,0}case 21520:return a.tty?-28:-59;case 21531:{var u=de.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 Lc(s,i){try{return s=de.getStr(s),de.doStat(c.lstat,s,i)}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Dc(s,i,l){try{return i=de.getStr(i),i=de.calculateAt(s,i),i=ve.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 Rc(s,i,l,a){try{i=de.getStr(i);var u=a&256,d=a&4096;return a=a&-6401,i=de.calculateAt(s,i,d),de.doStat(u?c.lstat:c.stat,i,l)}catch(N){if(typeof c>"u"||!(N instanceof c.ErrnoError))throw N;return-N.errno}}function Bc(s,i,l,a){de.varargs=a;try{i=de.getStr(i),i=de.calculateAt(s,i);var u=a?de.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 Mc(s,i,l,a){try{if(i=de.getStr(i),i=de.calculateAt(s,i),a<=0)return-28;var u=c.readlink(i),d=Math.min(a,wi(u)),N=It[l+d];return Oa(u,l,a+1),It[l+d]=N,d}catch(S){if(typeof c>"u"||!(S instanceof c.ErrnoError))throw S;return-S.errno}}function Uc(s){try{return s=de.getStr(s),c.rmdir(s),0}catch(i){if(typeof c>"u"||!(i instanceof c.ErrnoError))throw i;return-i.errno}}function Qc(s,i){try{return s=de.getStr(s),de.doStat(c.stat,s,i)}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function jc(s,i,l){try{return i=de.getStr(i),i=de.calculateAt(s,i),l===0?c.unlink(i):l===512?c.rmdir(i):Kn("Invalid flags passed to unlinkat"),0}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}function yo(s){return tt[s>>2]+me[s+4>>2]*4294967296}function zc(s,i,l,a){try{if(i=de.getStr(i),i=de.calculateAt(s,i,!0),l){var N=yo(l),S=me[l+8>>2];u=N*1e3+S/(1e3*1e3),l+=16,N=yo(l),S=me[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 Vc=!0;function Jc(){return Vc}function Gc(s){return s%4===0&&(s%100!==0||s%400===0)}var $c=[0,31,60,91,121,152,182,213,244,274,305,335],Hc=[0,31,59,90,120,151,181,212,243,273,304,334];function Kc(s){var i=Gc(s.getFullYear()),l=i?$c:Hc,a=l[s.getMonth()]+s.getDate()-1;return a}function Xc(s,i){var l=new Date(yo(s)*1e3);me[i>>2]=l.getSeconds(),me[i+4>>2]=l.getMinutes(),me[i+8>>2]=l.getHours(),me[i+12>>2]=l.getDate(),me[i+16>>2]=l.getMonth(),me[i+20>>2]=l.getFullYear()-1900,me[i+24>>2]=l.getDay();var a=Kc(l)|0;me[i+28>>2]=a,me[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;me[i+32>>2]=S}function Ba(s){var i=wi(s)+1,l=za(i);return l&&Os(s,It,l,i),l}function Yc(s,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);tt[s>>2]=C*60,me[i>>2]=+(N!=S);function z(y){var x=y.toTimeString().match(/\(([A-Za-z ]+)\)$/);return x?x[1]:"GMT"}var K=z(u),te=z(d),k=Ba(K),m=Ba(te);S>2]=k,tt[l+4>>2]=m):(tt[l>>2]=m,tt[l+4>>2]=k)}function Zc(){return Date.now()}var Ma;Ma=()=>performance.now();function ed(){return 2147483648}function td(s){var i=In.buffer;try{return In.grow(s-i.byteLength+65535>>>16),Ia(),1}catch{}}function nd(s){var i=bi.length;s=s>>>0;var l=ed();if(s>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,s+100663296);var N=Math.min(l,a(Math.max(s,d),65536)),S=td(N);if(S)return!0}return!1}var go={};function rd(){return ct||"./this.program"}function Ni(){if(!Ni.strings){var s=(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:s,_:rd()};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]);Ni.strings=a}return Ni.strings}function id(s,i,l){for(var a=0;a>0]=s.charCodeAt(a);l||(It[i>>0]=0)}function sd(s,i){var l=0;return Ni().forEach(function(a,u){var d=i+l;tt[s+u*4>>2]=d,id(a,d),l+=a.length+1}),0}function od(s,i){var l=Ni();tt[s>>2]=l.length;var a=0;return l.forEach(function(u){a+=u.length+1}),tt[i>>2]=a,0}function ad(s){try{var i=de.getStreamFromFD(s);return c.close(i),0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return l.errno}}function ld(s,i){try{var l=de.getStreamFromFD(s),a=l.tty?2:c.isDir(l.mode)?3:c.isLink(l.mode)?7:4;return It[i>>0]=a,0}catch(u){if(typeof c>"u"||!(u instanceof c.ErrnoError))throw u;return u.errno}}function ud(s,i,l,a){for(var u=0,d=0;d>2],S=tt[i+4>>2];i+=8;var C=c.read(s,It,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 dd(s,i,l,a){try{if(i=Ra(i),isNaN(i))return 61;var u=de.getStreamFromFD(s);return c.llseek(u,i,l),st=[u.position>>>0,(ge=u.position,+Math.abs(ge)>=1?ge>0?(Math.min(+Math.floor(ge/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ge-+(~~ge>>>0))/4294967296)>>>0:0)],me[a>>2]=st[0],me[a+4>>2]=st[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 fd(s){try{var i=de.getStreamFromFD(s);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 hd(s,i,l,a){for(var u=0,d=0;d>2],S=tt[i+4>>2];i+=8;var C=c.write(s,It,N,S,a);if(C<0)return-1;u+=C,typeof a<"u"&&(a+=C)}return u}function pd(s,i,l,a){try{var u=de.getStreamFromFD(s),d=hd(u,i,l);return tt[a>>2]=d,0}catch(N){if(typeof c>"u"||!(N instanceof c.ErrnoError))throw N;return N.errno}}var Ua=function(s,i,l,a){s||(s=this),this.parent=s,this.mount=s.mount,this.mounted=null,this.id=c.nextInode++,this.name=i,this.mode=l,this.node_ops={},this.stream_ops={},this.rdev=a},Is=365,Ts=146;Object.defineProperties(Ua.prototype,{read:{get:function(){return(this.mode&Is)===Is},set:function(s){s?this.mode|=Is:this.mode&=~Is}},write:{get:function(){return(this.mode&Ts)===Ts},set:function(s){s?this.mode|=Ts:this.mode&=~Ts}},isFolder:{get:function(){return c.isDir(this.mode)}},isDevice:{get:function(){return c.isChrdev(this.mode)}}}),c.FSNode=Ua,c.staticInit();var Qa={__syscall_chmod:xc,__syscall_faccessat:Ec,__syscall_fchmod:Sc,__syscall_fchown32:kc,__syscall_fcntl64:Ac,__syscall_fstat64:Ic,__syscall_ftruncate64:Pc,__syscall_getcwd:Wc,__syscall_ioctl:Fc,__syscall_lstat64:Lc,__syscall_mkdirat:Dc,__syscall_newfstatat:Rc,__syscall_openat:Bc,__syscall_readlinkat:Mc,__syscall_rmdir:Uc,__syscall_stat64:Qc,__syscall_unlinkat:jc,__syscall_utimensat:zc,_emscripten_get_now_is_monotonic:Jc,_localtime_js:Xc,_tzset_js:Yc,emscripten_date_now:Zc,emscripten_get_now:Ma,emscripten_resize_heap:nd,environ_get:sd,environ_sizes_get:od,fd_close:ad,fd_fdstat_get:ld,fd_read:cd,fd_seek:dd,fd_sync:fd,fd_write:pd,memory:In};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 ja=n.___errno_location=function(){return(ja=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 za=n._malloc=function(){return(za=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=In;var Cs;qi=function s(){Cs||Va(),Cs||(qi=s)};function Va(s){if(Hn>0||(hc(),Hn>0))return;function i(){Cs||(Cs=!0,n.calledRun=!0,!Sa&&(pc(),A(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),_c()))}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 Va(),n.postRun||(n.postRun=[]),n.postRun.push(function(s){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 s<"u"?!!s.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 P=N(_);typeof p[1]=="object"?super(P,p[1]):(p[0]=P+":",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 K=f=>typeof f!="bigint"&&f===(f|0)&&f<=2147483647&&f>=-2147483648,te=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&&K(f.constructor.BYTES_PER_ELEMENT)?f:!1,x=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,E=f=>f.buffer instanceof x,q=(f,p,_)=>E(f)?f.slice(p,_):f.subarray(p,_),W=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=>W(f)||z("Value is not of a supported TypedArray type."),L=new TextDecoder("utf-8"),ie=function(f,p,_){return L.decode(q(f,p,_))},j=function(f){return B(f)?ie(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,_,P,F,ne,re,oe,he)=>{},sqlite3_create_function:(f,p,_,P,F,ne,re,oe)=>{},sqlite3_create_window_function:(f,p,_,P,F,ne,re,oe,he,ue)=>{},sqlite3_prepare_v3:(f,p,_,P,F,ne)=>{},sqlite3_prepare_v2:(f,p,_,P,F)=>{},sqlite3_exec:(f,p,_,P,F)=>{},sqlite3_randomness:(f,p)=>{}});const v={affirmBindableTypedArray:R,flexibleString:j,bigIntFits32:k,bigIntFits64:te,bigIntFitsDouble:m,isBindableTypedArray:W,isInt32:K,isSQLableTypedArray:B,isTypedArray:y,typedArrayToString:ie,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,isSharedTypedArray:E,toss:function(...f){throw new Error(f.join(" "))},toss3:z,typedArrayPart:q};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 P of[f,p,_])d.exports[P]instanceof Function||z("Missing required exports[",P,"] function.");d.alloc=function P(F){return P.impl(F)||g.toss("Failed to allocate",F," bytes.")},d.alloc.impl=d.exports[f],d.realloc=function P(F,ne){const re=P.impl(F,ne);return ne?re||g.toss("Failed to reallocate",ne," 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(P=>{_[P]=u.sqlite3_compileoption_used(P)}),_}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(re,oe){const he=f._rx.exec(re);oe[0]=he?he[1]:re,oe[1]=he?f._rxInt.test(he[2])?+he[2]:he[2]:!0});const _={},P=[0,0];let F=0,ne;for(;ne=u.sqlite3_compileoption_get(F++);)f._opt(ne,P),_[P[0]]=P[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),P=[];let F=0,ne=0;for(;Ff===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 P=p.byteLength,F=0;const ne=d.exports.sqlite3_randomness,re=d.heap8u(),oe=P<512?P:512,he=d.pstack.alloc(oe);do{const ue=P>oe?oe:P;ne(ue,he),p.set(q(re,he,he+ue),F),P-=ue,F+=ue}while(P>0)}catch(P){console.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",P)}finally{d.pstack.restore(_)}return p}d.exports.sqlite3_randomness(...f)};let O;if(u.sqlite3_wasmfs_opfs_dir=function(){if(O!==void 0)return O;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 O="";try{return f&&d.xCallWrapped("sqlite3_wasm_init_wasmfs","i32",["string"],f)===0?O=f:O=""}catch{return O=""}},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 P=u.sqlite3_vfs_find(p);return P?f?P===u.sqlite3_js_db_vfs(f,_)?P:!1:P===u.sqlite3_vfs_find(0)?P:!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 P;try{const F=d.scopedAlloc(8+d.ptrSizeof),ne=F+8,re=p?d.isPtr(p)?p:d.scopedAllocCString(""+p):0;let oe=d.exports.sqlite3_wasm_db_serialize(f,re,ne,F,0);oe&&z("Database serialization failed with code",w.capi.sqlite3_js_rc_str(oe)),P=d.peekPtr(ne);const he=d.peek(F,"i64");return oe=he?d.heap8u().slice(P,P+Number(he)):new Uint8Array,oe}finally{P&&d.exports.sqlite3_free(P),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,_,P){let F;_?(d.isPtr(_)?F=_:_ instanceof ArrayBuffer&&(_=new Uint8Array(_)),_ instanceof Uint8Array?(F=d.allocFromTypedArray(_),(arguments.length<4||!v.isInt32(P)||P<0)&&(P=_.byteLength)):C.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")):F=0,(!v.isInt32(P)||P<0)&&(d.dealloc(F),C.toss("Invalid 4th argument for sqlite3_js_vfs_create_file()."));try{const ne=d.sqlite3_wasm_vfs_create_file(f,p,F,P);ne&&C.toss("Creation of file failed with sqlite3 result code",u.sqlite3_js_rc_str(ne))}finally{d.dealloc(F)}},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 P=f(p);return P.stores.forEach(F=>{const ne=[];let re;for(re=0;reF.removeItem(oe)),_+=ne.length}),_},u.sqlite3_js_kvvfs_size=function(p=""){let _=0;const P=f(p);return P.stores.forEach(F=>{let ne;for(ne=0;neb(f,p,"sqlite3_preupdate_new"),u.sqlite3_preupdate_old_js=(f,p)=>b(f,p,"sqlite3_preupdate_old"),u.sqlite3changeset_new_js=(f,p)=>b(f,p,"sqlite3changeset_new"),u.sqlite3changeset_old_js=(f,p)=>b(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(F=>{throw console.error("an async sqlite3 initializer failed:",F),F}));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 j;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 O=d.memory&&d.heapSize===d.memory.buffer.byteLength?d:N();switch(g){case Int8Array:return O.HEAP8;case Uint8Array:return O.HEAP8U;case Int16Array:return O.HEAP16;case Uint16Array:return O.HEAP16U;case Int32Array:return O.HEAP32;case Uint32Array:return O.HEAP32U;case 8:return v?O.HEAP8U:O.HEAP8;case 16:return v?O.HEAP16U:O.HEAP16;case 32:return v?O.HEAP32U:O.HEAP32;case 64:if(O.HEAP64)return v?O.HEAP64U:O.HEAP64;break;default:if(i.bigIntEnabled){if(g===self.BigUint64Array)return O.HEAP64U;if(g===self.BigInt64Array)return O.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=O;O=v,v=f}const b=g._.sigParams(O),w=[1,96];g._.uleb128Encode(w,"push",b.length);for(const f of b)g._.pushSigType(w,f);return O[0]==="v"?w.push(0):(w.push(1),g._.pushSigType(w,O[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,O,b){if(b&&!d.scopedAlloc.length&&l("No scopedAllocPush() scope is active."),typeof v=="string"){const _=O;O=v,v=_}(typeof O!="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),b&&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,O);w.set(p,_),b&&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,O=i.functionTable();v.push(g);const b=O.get(g);return O.set(g,null),b},i.peek=function(v,O="i8"){O.endsWith("*")&&(O=a);const b=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()),O){case"i1":case"i8":f=b.HEAP8[v>>0];break;case"i16":f=b.HEAP16[v>>1];break;case"i32":f=b.HEAP32[v>>2];break;case"float":case"f32":f=b.HEAP32F[v>>2];break;case"double":case"f64":f=Number(b.HEAP64F[v>>3]);break;case"i64":if(i.bigIntEnabled){f=BigInt(b.HEAP64[v>>3]);break}default:l("Invalid type for peek():",O)}w&&w.push(f)}while(w&&arguments[0].length);return w||f},i.poke=function(g,v,O="i8"){O.endsWith("*")&&(O=a);const b=d.memory&&d.heapSize===d.memory.buffer.byteLength?d:N();for(const w of Array.isArray(g)?g:[g])switch(O){case"i1":case"i8":b.HEAP8[w>>0]=v;continue;case"i16":b.HEAP16[w>>1]=v;continue;case"i32":b.HEAP32[w>>2]=v;continue;case"float":case"f32":b.HEAP32F[w>>2]=v;continue;case"double":case"f64":b.HEAP64F[w>>3]=v;continue;case"i64":if(b.HEAP64){b.HEAP64[w>>3]=BigInt(v);continue}default:l("Invalid type for poke(): "+O)}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 O=g;for(;v[O]!==0;++O);return O-g};const C=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,z=function(g,v,O){return d.utf8Decoder.decode(g.buffer instanceof C?g.slice(v,O):g.subarray(v,O))};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 O=0;for(let b=0;b=55296&&w<=57343&&(w=65536+((w&1023)<<10)|g.charCodeAt(++b)&1023),w<=127?++O:w<=2047?O+=2:w<=65535?O+=3:O+=4}return O},i.jstrcpy=function(g,v,O=0,b=-1,w=!0){if((!v||!(v instanceof Int8Array)&&!(v instanceof Uint8Array))&&l("jstrcpy() target must be an Int8Array or Uint8Array."),b<0&&(b=v.length-O),!(b>0)||!(O>=0))return 0;let f=0,p=g.length;const _=O,P=O+b-(w?1:0);for(;f=55296&&F<=57343&&(F=65536+((F&1023)<<10)|g.charCodeAt(++f)&1023),F<=127){if(O>=P)break;v[O++]=F}else if(F<=2047){if(O+1>=P)break;v[O++]=192|F>>6,v[O++]=128|F&63}else if(F<=65535){if(O+2>=P)break;v[O++]=224|F>>12,v[O++]=128|F>>6&63,v[O++]=128|F&63}else{if(O+3>=P)break;v[O++]=240|F>>18,v[O++]=128|F>>12&63,v[O++]=128|F>>6&63,v[O++]=128|F&63}}return w&&(v[O++]=0),O-_},i.cstrncpy=function(g,v,O){if((!g||!v)&&l("cstrncpy() does not accept NULL strings."),O<0)O=i.cstrlen(strPtr)+1;else if(!(O>0))return 0;const b=i.heap8u();let w=0,f;for(;wd.utf8Encoder.encode(v?g+"\0":g);const K=(g,v)=>{(!(g.alloc instanceof Function)||!(g.dealloc instanceof Function))&&l("Object is missing alloc() and/or dealloc() function(s)","required by",v+"().")},te=function(g,v,O,b){if(K(i,b),typeof g!="string")return null;{const w=d.utf8Encoder.encode(g),f=O(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)=>te(g,v,i.alloc,"allocCString()"),i.scopedAllocPush=function(){K(i,"scopedAllocPush");const g=[];return d.scopedAlloc.push(g),g},i.scopedAllocPop=function(g){K(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 O;O=g.pop();)i.functionEntry(O)?i.uninstallFunction(O):i.dealloc(O)},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)=>te(g,v,i.scopedAlloc,"scopedAllocCString()");const k=function(g,v){const O=i[g?"scopedAlloc":"alloc"]((v.length+1)*i.ptrSizeof);let b=0;return v.forEach(w=>{i.pokePtr(O+i.ptrSizeof*b++,i[g?"scopedAllocCString":"allocCString"](""+w))}),i.pokePtr(O+i.ptrSizeof*b,0),O};i.scopedAllocMainArgv=g=>k(!0,g),i.allocMainArgv=g=>k(!1,g),i.cArgvToJs=(g,v)=>{const O=[];for(let b=0;bm(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 O=i.xGet(g);return O instanceof Function||l("Exported symbol",g,"is not a function."),O.length!==v.length&&y(g,O.length),arguments.length===2&&Array.isArray(arguments[1])?O.apply(null,arguments[1]):O.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 q=a==="i32"?g=>g|0:g=>BigInt(g)|BigInt(0);x.set("i32",q).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("**",q).set("*",q),E.set("*",q).set("pointer",q).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 O of g)x.set(O+"*",v),E.set(O+"*",v),E.set(O,x.get(O)||l("Missing arg converter:",O))}const W=function(g){return typeof g=="string"?i.scopedAllocCString(g):g?q(g):null};x.set("string",W).set("utf8",W).set("pointer",W),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,O){l("AbstractArgAdapter must be subclassed.")}};x.FuncPtrAdapter=(j=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)."),j.bindScopes.indexOf(v.bindScope)<0&&l("Invalid options.bindScope ("+v.bindMod+") for FuncPtrAdapter. Expecting one of: ("+j.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,O){return this}contextMap(v){const O=this.__cmap||(this.__cmap=new Map);let b=O.get(v);return b===void 0&&O.set(v,b=[]),b}convertArg(v,O,b){let w=this.singleton;if(!w&&this.isContext&&(w=this.contextMap(this.contextKey(O,b))),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(j.debugFuncInstall&&j.debugOut("FuncPtrAdapter installed",this,this.contextKey(O,b),"@"+f,v),w){if(w[1]){j.debugFuncInstall&&j.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,b),"@"+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){j.debugFuncInstall&&j.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,b),"@"+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+".")}},xe(j,"warnOnUse",!1),xe(j,"debugFuncInstall",!1),xe(j,"debugOut",console.debug.bind(console)),xe(j,"bindScopes",["transient","context","singleton","permanent"]),j);const R=g=>x.get(g)||l("Argument adapter not found:",g),L=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?L(g)(v):void 0,d.xWrap.convertResultNoCheck=(g,v)=>g===null?v:g?E.get(g)(v):void 0,i.xWrap=function(g,v,...O){arguments.length===3&&Array.isArray(arguments[2])&&(O=arguments[2]),i.isPtr(g)&&(g=i.functionEntry(g)||l("Function pointer not found in WASM function table."));const b=g instanceof Function,w=b?g:i.xGet(g);if(b&&(g=w.name||"unnamed function"),O.length!==w.length&&y(g,w.length),v===null&&w.length===0)return w;v!=null&&L(v);for(const p of O)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 P in p)p[P]=f.convertArgNoCheck(O[P],p[P],p,P);return f.convertResultNoCheck(v,w.apply(null,p))}finally{i.scopedAllocPop(_)}}};const ie=function(g,v,O,b,w,f){if(typeof O=="string"){if(v===1)return f.get(O);if(v===2){if(b)b instanceof Function||l(w,"requires a function argument.");else return delete f.get(O),g;return f.set(O,b),g}}l("Invalid arguments to",w)};return i.xWrap.resultAdapter=function g(v,O){return ie(g,arguments.length,v,O,"resultAdapter()",E)},i.xWrap.argAdapter=function g(v,O){return ie(g,arguments.length,v,O,"argAdapter()",x)},i.xWrap.FuncPtrAdapter=x.FuncPtrAdapter,i.xCallWrapped=function(g,v,O,...b){return Array.isArray(arguments[3])&&(b=arguments[3]),i.xWrap(g,v,O||[]).apply(null,b||[])},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(K){return z.malloc(K)||S("Allocation of",K,"bytes failed.")},C.dealloc=function(K){z.free(K)}}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||"",K=l.memberSuffix||"",te=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 J=function $(X){return arguments.length===0?$.__flags:(X<0?(delete $.__flags.getter,delete $.__flags.setter,delete $.__flags.alloc,delete $.__flags.dealloc):($.__flags.getter=(1&X)!==0,$.__flags.setter=(2&X)!==0,$.__flags.alloc=(4&X)!==0,$.__flags.dealloc=(8&X)!==0),$._flags)};return Object.defineProperty(J,"__flags",{iterable:!1,writable:!1,value:Object.create(T)}),T||J(0),J},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}(),q=T=>T[1]==="(",W=T=>T==="P",B=T=>q(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)},L=m?()=>!0:()=>a("BigInt64Array is not available."),ie=function(T){switch(B(T)){case"p":case"P":case"s":{switch(y){case 4:return"getInt32";case 8:return L()&&"getBigInt64"}break}case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return L()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}a("Unhandled DataView getter for signature:",T)},j=function(T){switch(B(T)){case"p":case"P":case"s":{switch(y){case 4:return"setInt32";case 8:return L()&&"setBigInt64"}break}case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return L()&&"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 L()&&k;case"p":case"P":case"s":switch(y){case 4:return Number;case 8:return L()&&k}break}a("Unhandled DataView set wrapper for signature:",T)},v=(T,J)=>T+"::"+J,O=function(T,J){return()=>a(v(T,J),"is read-only.")},b=new WeakMap,w="(pointer-is-external)",f=function(T,J,$){if($||($=b.get(J)),$){if(b.delete(J),Array.isArray(J.ondispose)){let X;for(;X=J.ondispose.shift();)try{X instanceof Function?X.call(J):X instanceof be?X.dispose():typeof X=="number"&&S(X)}catch(Oe){console.warn("ondispose() for",T.structName,"@",$,"threw. NOT propagating it.",Oe)}}else if(J.ondispose instanceof Function)try{J.ondispose()}catch(X){console.warn("ondispose() for",T.structName,"@",$,"threw. NOT propagating it.",X)}delete J.ondispose,T.debugFlags.__flags.dealloc&&C("debug.dealloc:",J[w]?"EXTERNAL":"",T.structName,"instance:",T.structInfo.sizeof,"bytes @"+$),J[w]||S($)}},p=T=>({configurable:!1,writable:!1,iterable:!1,value:T}),_=function(T,J,$){let X=!$;$?Object.defineProperty(J,w,p($)):($=N(T.structInfo.sizeof),$||a("Allocation of",T.structName,"structure failed."));try{T.debugFlags.__flags.alloc&&C("debug.alloc:",X?"":"EXTERNAL",T.structName,"instance:",T.structInfo.sizeof,"bytes @"+$),X&&d().fill(0,$,$+T.structInfo.sizeof),b.set(J,$)}catch(Oe){throw f(T,J,$),Oe}},P=function(){const T=this.pointer;return T?new Uint8Array(d().slice(T,T+this.structInfo.sizeof)):null},ne=p(T=>z+T+K),re=function(T,J,$=!0){let X=T.members[J];if(!X&&(z||K)){for(const Oe of Object.values(T.members))if(Oe.key===J){X=Oe;break}!X&&$&&a(v(T.name,J),"is not a mapped struct member.")}return X},oe=function T(J,$,X=!1){T._||(T._=Re=>Re.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i"));const Oe=re(J.structInfo,$,!0);return X?T._(Oe.signature):Oe.signature},he={configurable:!1,enumerable:!1,get:function(){return b.get(this)},set:()=>a("Cannot assign the 'pointer' property of a struct.")},ue=p(function(){const T=[];for(const J of Object.keys(this.structInfo.members))T.push(this.memberKey(J));return T}),qe=new TextDecoder("utf-8"),ze=new TextEncoder,dt=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,Zt=function(T,J,$){return qe.decode(T.buffer instanceof dt?T.slice(J,$):T.subarray(J,$))},I=function(T,J,$=!1){const X=re(T.structInfo,J,$);return X&&X.signature.length===1&&X.signature[0]==="s"?X:!1},M=function(T){T.signature!=="s"&&a("Invalid member type signature for C-string value:",JSON.stringify(T))},Q=function(J,$){const X=re(J.structInfo,$,!0);M(X);const Oe=J[X.key];if(!Oe)return null;let Re=Oe;const Ce=d();for(;Ce[Re]!==0;++Re);return Oe===Re?"":Zt(Ce,Oe,Re)},Z=function(T,...J){T.ondispose?Array.isArray(T.ondispose)||(T.ondispose=[T.ondispose]):T.ondispose=[],T.ondispose.push(...J)},H=function(T){const J=ze.encode(T),$=N(J.length+1);$||a("Allocation error while duplicating string:",T);const X=d();return X.set(J,$),X[$+J.length]=0,$},Ne=function(T,J,$){const X=re(T.structInfo,J,!0);M(X);const Oe=H($);return T[X.key]=Oe,Z(T,Oe),T},be=function(J,$){arguments[2]!==p&&a("Do not call the StructType constructor","from client-level code."),Object.defineProperties(this,{structName:p(J),structInfo:p($)})};be.prototype=Object.create(null,{dispose:p(function(){f(this.constructor,this)}),lookupMember:p(function(T,J=!0){return re(this.structInfo,T,J)}),memberToJsString:p(function(T){return Q(this,T)}),memberIsString:p(function(T,J=!0){return I(this,T,J)}),memberKey:ne,memberKeys:ue,memberSignature:p(function(T,J=!1){return oe(this,T,J)}),memoryDump:p(P),pointer:he,setMemberCString:p(function(T,J){return Ne(this,T,J)})}),Object.assign(be.prototype,{addOnDispose:function(...T){return Z(this,...T),this}}),Object.defineProperties(be,{allocCString:p(H),isA:p(T=>T instanceof be),hasExternalPointer:p(T=>T instanceof be&&!!T[w]),memberKey:ne});const ee=T=>Number.isFinite(T)||T instanceof(k||Number),Lt=function T(J,$,X){if(!T._){T._={getters:{},setters:{},sw:{}};const wt=["i","c","C","p","P","s","f","d","v()"];te&&wt.push("j"),wt.forEach(function(en){T._.getters[en]=ie(en),T._.setters[en]=j(en),T._.sw[en]=g(en)});const _d=/^[ipPsjfdcC]$/,md=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/;T.sigCheck=function(en,yd,Ja,wo){Object.prototype.hasOwnProperty.call(en,Ja)&&a(en.structName,"already has a property named",Ja+"."),_d.test(wo)||md.test(wo)||a("Malformed signature for",v(en.structName,yd)+":",wo)}}const Oe=J.memberKey($);T.sigCheck(J.prototype,$,Oe,X.signature),X.key=Oe,X.name=$;const Re=B(X.signature),Ce=v(J.prototype.structName,Oe),je=J.prototype.debugFlags.__flags,Ir=Object.create(null);Ir.configurable=!1,Ir.enumerable=!1,Ir.get=function(){je.getter&&C("debug.getter:",T._.getters[Re],"for",R(Re),Ce,"@",this.pointer,"+",X.offset,"sz",X.sizeof);let wt=new DataView(d().buffer,this.pointer+X.offset,X.sizeof)[T._.getters[Re]](0,E);return je.getter&&C("debug.getter:",Ce,"result =",wt),wt},X.readOnly?Ir.set=O(J.prototype.structName,Oe):Ir.set=function(wt){if(je.setter&&C("debug.setter:",T._.setters[Re],"for",R(Re),Ce,"@",this.pointer,"+",X.offset,"sz",X.sizeof,wt),this.pointer||a("Cannot set struct property on disposed instance."),wt===null)wt=0;else for(;!ee(wt);){if(W(X.signature)&&wt instanceof be){wt=wt.pointer||0,je.setter&&C("debug.setter:",Ce,"resolved to",wt);break}a("Invalid value for pointer-type",Ce+".")}new DataView(d().buffer,this.pointer+X.offset,X.sizeof)[T._.setters[Re]](0,T._.sw[Re](wt),E)},Object.defineProperty(J.prototype,Oe,Ir)},ot=function T(J,$){arguments.length===1?($=J,J=$.name):$.name||($.name=J),J||a("Struct name is required.");let X=!1;Object.keys($.members).forEach(Ce=>{const je=$.members[Ce];je.sizeof?je.sizeof===1?je.signature==="c"||je.signature==="C"||a("Unexpected sizeof==1 member",v($.name,Ce),"with signature",je.signature):(je.sizeof%4!==0&&(console.warn("Invalid struct member description =",je,"from",$),a(J,"member",Ce,"sizeof is not aligned. sizeof="+je.sizeof)),je.offset%4!==0&&(console.warn("Invalid struct member description =",je,"from",$),a(J,"member",Ce,"offset is not aligned. offset="+je.offset))):a(J,"member",Ce,"is missing sizeof."),(!X||X.offsetCe instanceof Re),memberKey:ne,memberKeys:ue,methodInfoForKey:p(function(Ce){}),structInfo:p($),structName:p(J)}),Re.prototype=new be(J,$,p),Object.defineProperties(Re.prototype,{debugFlags:Oe,constructor:p(Re)}),Object.keys($.members).forEach(Ce=>Lt(Re,Ce,$.members[Ce])),Re};return ot.StructType=be,ot.config=l,ot.allocCString=H,ot.debugFlags||(ot.debugFlags=u.__makeDebugFlags(u.debugFlags)),ot},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,q)=>{try{const W=u.cArgvToJs(x,E);return m||(m=u.cArgvToJs(x,q)),k(W,m)|0}catch(W){return W.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,q,W)=>{try{return x=x&&u.cstrToJs(x),E=E&&u.cstrToJs(E),q=q&&u.cstrToJs(q),W=W&&u.cstrToJs(W),k(m,y,x,E,q,W)||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,q,W,B)=>{k(m,y,x,u.cstrToJs(E),u.cstrToJs(q),W,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,q)=>{k(m,y,u.cstrToJs(x),u.cstrToJs(E),q)}}),"*"]],["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",q=>k(d.flexibleString(q))),u.xWrap.argAdapter("string:static",(function(q){return u.isPtr(q)?q:(q=""+q,this[q]||(this[q]=u.allocCString(q)))}).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*",q=>{var W;return m(q instanceof(((W=i==null?void 0:i.oo1)==null?void 0:W.Stmt)||y)?q.pointer:q)})("sqlite3*",q=>{var W;return m(q instanceof(((W=i==null?void 0:i.oo1)==null?void 0:W.DB)||y)?q.pointer:q)})("sqlite3_index_info*",q=>m(q instanceof(a.sqlite3_index_info||y)?q.pointer:q))("sqlite3_module*",q=>m(q instanceof(a.sqlite3_module||y)?q.pointer:q))("sqlite3_vfs*",q=>typeof q=="string"?a.sqlite3_vfs_find(q)||i.SQLite3Error.toss(a.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",q):m(q instanceof(a.sqlite3_vfs||y)?q.pointer:q));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 q of u.bindingSignatures)a[q[0]]=u.xWrap.apply(null,q);for(const q of u.bindingSignatures.wasm)u[q[0]]=u.xWrap.apply(null,q);const E=function(q){return()=>l(q+"() is unavailable due to lack","of BigInt support in this build.")};for(const q of u.bindingSignatures.int64)a[q[0]]=u.bigIntEnabled?u.xWrap.apply(null,q):E(q[0]);if(delete u.bindingSignatures,u.exports.sqlite3_wasm_db_error){const q=u.xWrap("sqlite3_wasm_db_error","int","sqlite3*","int","string");d.sqlite3_wasm_db_error=function(W,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),W?q(W,B,R):B}}else d.sqlite3_wasm_db_error=function(q,W,B){return console.warn("sqlite3_wasm_db_error() is not exported.",arguments),W}}{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 q of Object.entries(u.ctype[E]))a[q[0]]=q[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 q of Object.entries(u.ctype[E]))y[q[1]]=q[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,K=(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}));K.addCollation=function(k,m){const y=K(k,1);y.collation||(y.collation=new Set),y.collation.add(z(m).toLowerCase())},K._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)},K.addFunction=function(k,m,y){const x=K(k,1);x.udf||(x.udf=new Map),this._addUDF(k,m,y,x.udf)},K.addWindowFunc=function(k,m,y){const x=K(k,1);x.wudf||(x.wudf=new Map),this._addUDF(k,m,y,x.wudf)},K.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 q=u.exports[E];m.length=q.length;try{a[E](...m)}catch(W){console.warn("close-time call of",E+"(",m,") threw:",W)}}const y=K(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 q=x?a.sqlite3_create_window_function:a.sqlite3_create_function_v2;for(const W of E){const B=W[0],R=W[1],L=[k,B,0,a.SQLITE_UTF8,0,0,0,0,0];x&&L.push(0);for(const ie of R)try{L[2]=ie,q.apply(null,L)}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{K.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,q,W,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,q,W,B);return R===0&&W instanceof Function&&K.addCollation(y,x),R}catch(R){return d.sqlite3_wasm_db_error(y,R)}},a.sqlite3_create_collation=(y,x,E,q,W)=>arguments.length===5?a.sqlite3_create_collation_v2(y,x,E,q,W,0):N(y,"sqlite3_create_collation",5)}{const k=function(E,q){return E[0]+":"+(E[2]<0?-1:E[2])+":"+q+":"+u.cstrToJs(E[1]).toLowerCase()},m=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:k,callProxy:E=>(q,W,B)=>{try{E(q,...a.sqlite3_values_to_js(W,B))}catch(R){a.sqlite3_result_error_js(q,R)}}},xFinalAndValue:{signature:"v(p)",contextKey:k,callProxy:E=>q=>{try{a.sqlite3_result_js(q,E(q))}catch(W){a.sqlite3_result_error_js(q,W)}}},xFunc:{signature:"v(pip)",contextKey:k,callProxy:E=>(q,W,B)=>{try{a.sqlite3_result_js(q,E(q,...a.sqlite3_values_to_js(W,B)))}catch(R){a.sqlite3_result_error_js(q,R)}}},xDestroy:{signature:"v(p)",contextKey:k,callProxy:E=>q=>{try{E(q)}catch(W){console.error("UDF xDestroy method threw:",W)}}}}),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(q,W,B,R,L,ie,j,g,v){if(E.length!==arguments.length)return N(q,"sqlite3_create_function_v2",E.length);if(!(R&15))R|=a.SQLITE_UTF8;else if(a.SQLITE_UTF8!==(R&15))return S(q);try{const O=y(q,W,B,R,L,ie,j,g,v);return O===0&&(ie instanceof Function||j instanceof Function||g instanceof Function||v instanceof Function)&&K.addFunction(q,W,B),O}catch(O){return console.error("sqlite3_create_function_v2() setup threw:",O),d.sqlite3_wasm_db_error(q,O,"Creation of UDF threw: "+O)}},a.sqlite3_create_function=function E(q,W,B,R,L,ie,j,g){return E.length===arguments.length?a.sqlite3_create_function_v2(q,W,B,R,L,ie,j,g,0):N(q,"sqlite3_create_function",E.length)},a.sqlite3_create_window_function=function E(q,W,B,R,L,ie,j,g,v,O){if(E.length!==arguments.length)return N(q,"sqlite3_create_window_function",E.length);if(!(R&15))R|=a.SQLITE_UTF8;else if(a.SQLITE_UTF8!==(R&15))return S(q);try{const b=x(q,W,B,R,L,ie,j,g,v,O);return b===0&&(ie instanceof Function||j instanceof Function||g instanceof Function||v instanceof Function||O instanceof Function)&&K.addWindowFunc(q,W,B),b}catch(b){return console.error("sqlite3_create_window_function() setup threw:",b),d.sqlite3_wasm_db_error(q,b,"Creation of UDF threw: "+b)}},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,q,W,B,R){if(y.length!==arguments.length)return N(x,"sqlite3_prepare_v3",y.length);const[L,ie]=k(E,q);switch(typeof L){case"string":return m.basic(x,L,ie,W,B,null);case"number":return m.full(x,L,ie,W,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,q,W,B){return y.length===arguments.length?a.sqlite3_prepare_v3(x,E,q,0,W,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,q,W,B){if(y.length!==arguments.length)return N(a.sqlite3_db_handle(x),"sqlite3_bind_text",y.length);if(u.isPtr(q)||q===null)return k(x,E,q,W,B);q instanceof ArrayBuffer?q=new Uint8Array(q):Array.isArray(pMem)&&(q=pMem.join(""));let R,L;try{if(d.isSQLableTypedArray(q))R=u.allocFromTypedArray(q),L=q.byteLength;else if(typeof q=="string")[R,L]=u.allocCString(q);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,L,a.SQLITE_WASM_DEALLOC)}catch(ie){return u.dealloc(R),d.sqlite3_wasm_db_error(a.sqlite3_db_handle(x),ie)}},a.sqlite3_bind_blob=function y(x,E,q,W,B){if(y.length!==arguments.length)return N(a.sqlite3_db_handle(x),"sqlite3_bind_blob",y.length);if(u.isPtr(q)||q===null)return m(x,E,q,W,B);q instanceof ArrayBuffer?q=new Uint8Array(q):Array.isArray(q)&&(q=q.join(""));let R,L;try{if(d.isBindableTypedArray(q))R=u.allocFromTypedArray(q),L=W>=0?W:q.byteLength;else if(typeof q=="string")[R,L]=u.allocCString(q);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,L,a.SQLITE_WASM_DEALLOC)}catch(ie){return u.dealloc(R),d.sqlite3_wasm_db_error(a.sqlite3_db_handle(x),ie)}}}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 te=a.sqlite3_vfs_find("kvvfs");if(te)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=q=>u.peek(q)===115?sessionStorage:localStorage,E={xRead:(q,W,B,R)=>{const L=y.pointer,ie=u.scopedAllocPush();try{const j=m(q,W);if(!j)return-3;const g=u.cstrToJs(j),v=x(q).getItem(g);if(!v)return-1;const O=v.length;if(R<=0)return O;if(R===1)return u.poke(B,0),O;const b=u.scopedAllocCString(v);return R>O+1&&(R=O+1),u.heap8u().copyWithin(B,b,b+R-1),u.poke(B+R-1,0),R-1}catch(j){return console.error("kvstorageRead()",j),-2}finally{y.restore(L),u.scopedAllocPop(ie)}},xWrite:(q,W,B)=>{const R=y.pointer;try{const L=m(q,W);if(!L)return 1;const ie=u.cstrToJs(L);return x(q).setItem(ie,u.cstrToJs(B)),0}catch(L){return console.error("kvstorageWrite()",L),a.SQLITE_IOERR}finally{y.restore(R)}},xDelete:(q,W)=>{const B=y.pointer;try{const R=m(q,W);return R?(x(q).removeItem(u.cstrToJs(R)),0):1}catch(R){return console.error("kvstorageDelete()",R),a.SQLITE_IOERR}finally{y.restore(B)}}};for(const q of Object.keys(E))k[k.memberKey(q)]=u.installFunction(k.memberSignature(q),E[q])}else a.sqlite3_vfs_unregister(te);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=(...b)=>{throw new i.SQLite3Error(...b)},a=i.capi,u=i.wasm,d=i.util,N=new WeakMap,S=new WeakMap,C=(b,w,f)=>{const p=Object.getOwnPropertyDescriptor(b,w);return p?p.value:f},z=function(b,w){return w&&(b instanceof m&&(b=b.pointer),l("sqlite3 result code",w+":",b?a.sqlite3_errmsg(b):a.sqlite3_errstr(w))),arguments[0]},K=u.installFunction("i(ippp)",(function(b,w,f,p){a.SQLITE_TRACE_STMT===b&&console.log("SQL TRACE #"+ ++this.counter+" via sqlite3@"+w+":",u.cstrToJs(p))}).bind({counter:0})),te=Object.create(null),k=function b(...w){if(!b._name2vfs){b._name2vfs=Object.create(null);const ue=typeof importScripts=="function"?qe=>l("The VFS for",qe,"is only available in the main window thread."):!1;b._name2vfs[":localStorage:"]={vfs:"kvvfs",filename:ue||(()=>"local")},b._name2vfs[":sessionStorage:"]={vfs:"kvvfs",filename:ue||(()=>"session")}}const f=b.normalizeArgs(...w);let p=f.filename,_=f.vfs,P=f.flags;(typeof p!="string"&&typeof p!="number"||typeof P!="string"||_&&typeof _!="string"&&typeof _!="number")&&(i.config.error("Invalid DB ctor args",f,arguments),l("Invalid arguments for DB constructor."));let F=typeof p=="number"?u.cstrToJs(p):p;const ne=b._name2vfs[F];ne&&(_=ne.vfs,p=F=ne.filename(F));let re,oe=0;P.indexOf("c")>=0&&(oe|=a.SQLITE_OPEN_CREATE|a.SQLITE_OPEN_READWRITE),P.indexOf("w")>=0&&(oe|=a.SQLITE_OPEN_READWRITE),oe===0&&(oe|=a.SQLITE_OPEN_READONLY),oe|=a.SQLITE_OPEN_EXRESCODE;const he=u.pstack.pointer;try{const ue=u.pstack.allocPtr();let qe=a.sqlite3_open_v2(p,ue,oe,_||0);re=u.peekPtr(ue),z(re,qe),a.sqlite3_extended_result_codes(re,1),P.indexOf("t")>=0&&a.sqlite3_trace_v2(re,a.SQLITE_TRACE_STMT,K,re)}catch(ue){throw re&&a.sqlite3_close_v2(re),ue}finally{u.pstack.restore(he)}this.filename=F,N.set(this,re),S.set(this,Object.create(null));try{const ue=a.sqlite3_js_db_vfs(re);ue||l("Internal error: cannot get VFS for new db handle.");const qe=te[ue];qe instanceof Function?qe(this,i):qe&&z(re,a.sqlite3_exec(re,qe,0,0,0))}catch(ue){throw this.close(),ue}};k.setVfsPostOpenSql=function(b,w){te[b]=w},k.normalizeArgs=function(b=":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=b,p.flags=w,p.vfs=f),p};const m=function(...b){k.apply(this,b)};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(b){return b.pointer||l("DB has been closed."),b},q=function(b,w){return(w!==(w|0)||w<0||w>=b.columnCount)&&l("Column index",w,"is out of range."),b},W=function(b,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=()=>b;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=P=>{const F=P.get(Object.create(null))[_];return F===void 0?l(a.SQLITE_NOTFOUND,"exec(): unknown result column:",_):F};break}l("Invalid rowMode:",p.rowMode)}return f},B=(b,w,f,...p)=>{const _=b.prepare(w);try{return _.bind(f).step()?_.get(...p):void 0}finally{_.finalize()}},R=(b,w,f,p)=>b.exec({sql:w,bind:f,rowMode:p,returnValue:"resultRows"});m.checkRc=(b,w)=>z(b,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 b=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(b),this.onclose&&this.onclose.after instanceof Function)try{this.onclose.after(this)}catch{}delete this.filename}},changes:function(b=!1,w=!1){const f=E(this).pointer;return b?w?a.sqlite3_total_changes64(f):a.sqlite3_total_changes(f):w?a.sqlite3_changes64(f):a.sqlite3_changes(f)},dbFilename:function(b="main"){return a.sqlite3_db_filename(E(this).pointer,b)},dbName:function(b=0){return a.sqlite3_db_name(E(this).pointer,b)},dbVfsName:function(b=0){let w;const f=a.sqlite3_js_db_vfs(E(this).pointer,b);if(f){const p=new a.sqlite3_vfs(f);try{w=u.cstrToJs(p.$zName)}finally{p.dispose()}}return w},prepare:function(b){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,b,-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 b=W(this,arguments);if(!b.sql)return l("exec() requires an SQL string.");const w=b.opt,f=w.callback,p=Array.isArray(w.resultRows)?w.resultRows:void 0;let _,P=w.bind,F=!!(b.cbArg||w.columnNames||p);const ne=u.scopedAllocPush(),re=Array.isArray(w.saveSql)?w.saveSql:void 0;try{const oe=d.isSQLableTypedArray(b.sql);let he=oe?b.sql.byteLength:u.jstrlen(b.sql);const ue=u.scopedAlloc(2*u.ptrSizeof+(he+1)),qe=ue+u.ptrSizeof;let ze=qe+u.ptrSizeof;const dt=ze+he;for(oe?u.heap8().set(b.sql,ze):u.jstrcpy(b.sql,u.heap8(),ze,he,!1),u.poke(ze+he,0);ze&&u.peek(ze,"i8");){u.pokePtr([ue,qe],0),m.checkRc(this,a.sqlite3_prepare_v3(this.pointer,ze,he,0,ue,qe));const Zt=u.peekPtr(ue);if(ze=u.peekPtr(qe),he=dt-ze,!!Zt){if(re&&re.push(a.sqlite3_sql(Zt).trim()),_=new x(this,Zt,y),P&&_.parameterCount&&(_.bind(P),P=null),F&&_.columnCount){if(F=!1,Array.isArray(w.columnNames)&&_.getColumnNames(w.columnNames),b.cbArg||p){for(;_.step();_._isLocked=!1){_._isLocked=!0;const I=b.cbArg(_);if(p&&p.push(I),f&&f.call(w,I,_)===!1)break}_._isLocked=!1}}else _.step();_.finalize(),_=null}}}finally{_&&(delete _._isLocked,_.finalize()),u.scopedAllocPop(ne)}return b.returnVal()},createFunction:function(w,f,p){const _=M=>M 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 P=p.xStep||0,F=p.xFinal||0;const ne=p.xValue||0,re=p.xInverse||0;let oe;_(f)?(oe=!1,(_(P)||_(F))&&l("Ambiguous arguments: scalar or aggregate?"),P=F=null):_(P)?(_(F)||l("Missing xFinal() callback for aggregate or window UDF."),f=null):_(F)?l("Missing xStep() callback for aggregate or window UDF."):l("Missing function-type properties."),oe===!1?(_(ne)||_(re))&&l("xValue and xInverse are not permitted for non-window UDFs."):_(ne)?(_(re)||l("xInverse must be provided if xValue is."),oe=!0):_(re)&&l("xValue must be provided if xInverse is.");const he=p.pApp;he!=null&&(typeof he!="number"||!d.isInt32(he))&&l("Invalid value for pApp property. Must be a legal WASM pointer value.");const ue=p.xDestroy||0;ue&&!_(ue)&&l("xDestroy property must be a function.");let qe=0;C(p,"deterministic")&&(qe|=a.SQLITE_DETERMINISTIC),C(p,"directOnly")&&(qe|=a.SQLITE_DIRECTONLY),C(p,"innocuous")&&(qe|=a.SQLITE_INNOCUOUS),w=w.toLowerCase();const ze=f||P,dt=C(p,"arity"),Zt=typeof dt=="number"?dt:ze.length?ze.length-1:0;let I;return oe?I=a.sqlite3_create_window_function(this.pointer,w,Zt,a.SQLITE_UTF8|qe,he||0,P,F,ne,re,ue):I=a.sqlite3_create_function_v2(this.pointer,w,Zt,a.SQLITE_UTF8|qe,he||0,f,P,F,ue),m.checkRc(this,I),this},selectValue:function(b,w,f){return B(this,b,w,0,f)},selectValues:function(b,w,f){const p=this.prepare(b),_=[];try{for(p.bind(w);p.step();)_.push(p.get(0,f))}finally{p.finalize()}return _},selectArray:function(b,w){return B(this,b,w,[])},selectObject:function(b,w){return B(this,b,w,{})},selectArrays:function(b,w){return R(this,b,w,"array")},selectObjects:function(b,w){return R(this,b,w,"object")},openStatementCount:function(){return this.pointer?Object.keys(S.get(this)).length:0},transaction:function(b){let w="BEGIN";arguments.length>1&&(/[^a-zA-Z]/.test(arguments[0])&&l(a.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier."),w+=" "+arguments[0],b=arguments[1]),E(this).exec(w);try{const f=b(this);return this.exec("COMMIT"),f}catch(f){throw this.exec("ROLLBACK"),f}},savepoint:function(b){E(this).exec("SAVEPOINT oo1");try{const w=b(this);return this.exec("RELEASE oo1"),w}catch(w){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),w}},checkRc:function(b){return m.checkRc(this,b)}};const L=function(b){return b.pointer||l("Stmt has been closed."),b},ie=function(b){let w=y[b==null?"null":typeof b];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(b)?y.blob:void 0}},j=function(b){return ie(b)||l("Unsupported bind() argument type:",typeof b)},g=function(b,w){const f=typeof w=="number"?w:a.sqlite3_bind_parameter_index(b.pointer,w);return f===0||!d.isInt32(f)?l("Invalid bind() parameter name: "+w):(f<1||f>b.parameterCount)&&l("Bind index",w,"is out of range."),f},v=function(b,w){return b._isLocked&&l("Operation is illegal when statement is locked:",w),b},O=function b(w,f,p,_){v(L(w),"bind()"),b._||(b._tooBigInt=F=>l("BigInt value is too big to store without precision loss:",F),b._={string:function(F,ne,re,oe){const[he,ue]=u.allocCString(re,!0);return(oe?a.sqlite3_bind_blob:a.sqlite3_bind_text)(F.pointer,ne,he,ue,a.SQLITE_WASM_DEALLOC)}}),j(_),f=g(w,f);let P=0;switch(_==null?y.null:p){case y.null:P=a.sqlite3_bind_null(w.pointer,f);break;case y.string:P=b._.string(w,f,_,!1);break;case y.number:{let F;d.isInt32(_)?F=a.sqlite3_bind_int:typeof _=="bigint"?d.bigIntFits64(_)?u.bigIntEnabled?F=a.sqlite3_bind_int64:d.bigIntFitsDouble(_)?(_=Number(_),F=a.sqlite3_bind_double):b._tooBigInt(_):b._tooBigInt(_):(_=Number(_),u.bigIntEnabled&&Number.isInteger(_)?F=a.sqlite3_bind_int64:F=a.sqlite3_bind_double),P=F(w.pointer,f,_);break}case y.boolean:P=a.sqlite3_bind_int(w.pointer,f,_?1:0);break;case y.blob:{if(typeof _=="string"){P=b._.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 F=u.alloc(_.byteLength||1);u.heap8().set(_.byteLength?_:[0],F),P=a.sqlite3_bind_blob(w.pointer,f,F,_.byteLength,a.SQLITE_WASM_DEALLOC);break}default:i.config.warn("Unsupported bind() argument type:",_),l("Unsupported bind() argument type: "+typeof _)}return P&&m.checkRc(w.db.pointer,P),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(L(this),"clearBindings()"),a.sqlite3_clear_bindings(this.pointer),this._mayGet=!1,this},reset:function(b){return v(this,"reset()"),b&&this.clearBindings(),a.sqlite3_reset(L(this).pointer),this._mayGet=!1,this},bind:function(){L(this);let b,w;switch(arguments.length){case 1:b=1,w=arguments[0];break;case 2:b=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?O(this,b,y.null,w):Array.isArray(w)?(arguments.length!==1&&l("When binding an array, an index argument is not permitted."),w.forEach((f,p)=>O(this,p+1,j(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=>O(this,f,j(w[f]),w[f])),this):O(this,b,j(w),w)))},bindAsBlob:function(b,w){L(this),arguments.length===1&&(w=b,b=1);const f=j(w);return y.string!==f&&y.blob!==f&&y.null!==f&&l("Invalid value type for bindAsBlob()"),O(this,b,y.blob,w)},step:function(){v(this,"step()");const b=a.sqlite3_step(L(this).pointer);switch(b){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=",b,a.sqlite3_js_rc_str(b),"SQL =",a.sqlite3_sql(this.pointer)),m.checkRc(this.db.pointer,b)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){const b=this.step();return this.finalize(),b},get:function(b,w){if(L(this)._mayGet||l("Stmt.step() has not (recently) returned true."),Array.isArray(b)){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,b);return(f>Number.MAX_SAFE_INTEGER||fl("The pointer property is read-only.")};Object.defineProperty(x.prototype,"pointer",b),Object.defineProperty(m.prototype,"pointer",b)}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 b=i.oo1.JsStorageDb;b.prototype=Object.create(m.prototype),b.clearStorage=a.sqlite3_js_kvvfs_clear,b.prototype.clearStorage=function(){return b.clearStorage(E(this).filename)},b.storageSize=a.sqlite3_js_kvvfs_size,b.prototype.storageSize=function(){return b.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 q=this.dbList.indexOf(m);q>=0&&this.dbList.splice(q,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])},K=function(m){const y=/^file:.+(vfs=(\w+))/.exec(m);return a.capi.sqlite3_vfs_find(y?y[2]:0)},te=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 q,W;if(y.vfs=x.vfs,te(x.filename)?y.filename=x.filename||"":(y.filename=x.filename,q=x.byteArray,q&&(W=K(x.filename))),W){let R;try{R=a.wasm.allocFromTypedArray(q);const L=a.wasm.sqlite3_wasm_vfs_create_file(W,y.filename,R,q.byteLength);L&&a.SQLite3Error.toss(L)}catch(L){throw new a.SQLite3Error(L.name+" creating "+x.filename+": "+L.message,{cause:L})}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 q=0;const W=!!y.columnNames;typeof E=="string"&&(W||(y.columnNames=[]),y.callback=function(B,R){N.post({type:E,columnNames:y.columnNames,rowNumber:++q,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 q=performance.now();try{k.hasOwnProperty(E)&&k[E]instanceof Function?y=await k[E](m):l("Unknown db worker message type:",m.type)}catch(W){E="error",y={operation:m.type,message:W.message,errorClass:W.name,input:m},W.stack&&(y.stack=typeof W.stack=="string"?W.stack.split(/\n\s*/):W.stack)}x||(x=y.dbId||z()),N.post({type:E,dbId:x,messageId:m.messageId,workerReceivedTime:q,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,q=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(L,ie)=>m(y,L,ie,q);m.argcProxy||(m.argcProxy=function(L,ie,j,g){return function(...v){return j.length!==arguments.length&&u("Argument mismatch for",L.structInfo.name+"::"+ie+": Native signature is:",g),j.apply(this,v)}},m.removeFuncList=function(){this.ondispose.__removeFuncList&&(this.ondispose.__removeFuncList.forEach((L,ie)=>{if(typeof L=="number")try{l.uninstallFunction(L)}catch{}}),delete this.ondispose.__removeFuncList)});const W=y.memberSignature(x);W.length<2&&u("Member",x,"does not have a function pointer signature:",W);const B=y.memberKey(x),R=q&&!l.isPtr(E)?m.argcProxy(y,B,E,W):E;if(l.isPtr(R))R&&!l.functionEntry(R)&&u("Pointer",R,"is not a WASM function table entry."),y[B]=R;else{const L=l.installFunction(R,y.memberSignature(x,!0));y[B]=L,(!y.ondispose||!y.ondispose.__removeFuncList)&&(y.addOnDispose("ondispose.__removeFuncList handler",m.removeFuncList),y.ondispose.__removeFuncList=[]),y.ondispose.__removeFuncList.push(B,L)}return(L,ie)=>m(y,L,ie,q)};z.installMethodArgcCheck=!1;const K=function(m,y,x=z.installMethodArgcCheck){const E=new Map;for(const q of Object.keys(y)){const W=y[q],B=E.get(W);if(B){const R=m.memberKey(q);m[R]=m[m.memberKey(B)]}else z(m,q,W,x),E.set(W,q)}return m};S.StructType.prototype.installMethod=function(y,x,E=z.installMethodArgcCheck){return arguments.length<3&&y&&typeof y=="object"?K(this,...arguments):z(this,...arguments)},S.StructType.prototype.installMethods=function(m,y=z.installMethodArgcCheck){return K(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 q=m[E];q&&(++y,K(q.struct,q.methods,!!q.applyArgcCheck),E==="vfs"&&(!q.struct.$zName&&typeof q.name=="string"&&q.struct.addOnDispose(q.struct.$zName=l.allocCString(q.name)),q.struct.registerVfs(!!q.asDefault)))}return y||u("Misuse: installVfs() options object requires at least","one of:",x),this};const te=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 q=this.get(x);return E&&this.delete(x),q}).bind(new Map)},k=function(m,y){const x=te(m,y);return Object.assign(Object.create(null),{StructType:y,create:E=>{const q=x();return l.pokePtr(E,q.pointer),q},get:E=>x(E),unget:E=>x(E,!0),dispose:E=>{const q=x(E,!0);q&&q.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 q;return x instanceof i.WasmAllocError?q=a.SQLITE_NOMEM:arguments.length>2?q=E:x instanceof i.SQLite3Error&&(q=x.resultCode),q||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 q of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){const W=q[0],B=q[1];E[W]===!0?E[W]=E[B]:E[B]===!0&&(E[B]=E[W])}if(m.catchExceptions){const q=function(R,L){return["xConnect","xCreate"].indexOf(R)>=0?function(ie,j,g,v,O,b){try{return L(...arguments)||0}catch(w){return w instanceof i.WasmAllocError||(l.dealloc(l.peekPtr(b)),l.pokePtr(b,l.allocCString(w.message))),N.xError(R,w)}}:function(...ie){try{return L(...ie)||0}catch(j){return N.xError(R,j)}}},W=["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 W){const L=E[R];if(L instanceof Function)R==="xConnect"&&E.xCreate===L?B[R]=E.xCreate:R==="xCreate"&&E.xConnect===L?B[R]=E.xConnect:B[R]=q(R,L);else continue}K(x,B,!1)}else K(x,E,!!m.applyArgcCheck);if(x.$iVersion===0){let q;typeof m.iVersion=="number"?q=m.iVersion:x.$xShadowName?q=3:x.$xSavePoint||x.$xRelease||x.$xRollbackTo?q=2:q=1,x.$iVersion=q}}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 K={0:i.config.error,1:i.config.warn,2:i.config.log},te=(I,...M)=>{u.verbose>I&&K[I]("OPFS syncer:",...M)},k=(...I)=>te(2,...I),m=(...I)=>te(1,...I),y=(...I)=>te(0,...I),x=i.util.toss,E=i.capi,q=i.wasm,W=E.sqlite3_vfs,B=E.sqlite3_file,R=E.sqlite3_io_methods,L=Object.create(null),ie=()=>{var I;return globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&((I=navigator==null?void 0:navigator.storage)==null?void 0:I.getDirectory)};L.metrics={dump:function(){let I,M=0,Q=0,Z=0;for(I in _.opIds){const H=P[I];M+=H.count,Q+=H.time,Z+=H.wait,H.avgTime=H.count&&H.time?H.time/H.count:0,H.avgWait=H.count&&H.wait?H.wait/H.count:0}i.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",P,` -Total of`,M,"op(s) for",Q,"ms (incl. "+Z+" ms of waiting on the async side)"),i.config.log("Serialization metrics:",P.s11n),w.postMessage({type:"opfs-async-metrics"})},reset:function(){let I;const M=Z=>Z.count=Z.time=Z.wait=0;for(I in _.opIds)M(P[I]=Object.create(null));let Q=P.s11n=Object.create(null);Q=Q.serialize=Object.create(null),Q.count=Q.time=0,Q=P.s11n.deserialize=Object.create(null),Q.count=Q.time=0}};const j=new W,g=new R;let v;const O=I=>(v=!0,j.dispose(),z(I)),b=I=>(v=!1,C(I)),w=new Worker(new URL(""+new URL("sqlite3-opfs-async-proxy-9f074d6f.js",self.location.href).href,self.location));setTimeout(()=>{v===void 0&&O(new Error("Timeout while waiting for OPFS async proxy worker."))},4e3),w._originalOnError=w.onerror,w.onerror=function(I){y("Error initializing OPFS asyncer:",I),O(new Error("Loading OPFS async Worker failed for unknown reasons."))};const f=E.sqlite3_vfs_find(null),p=f?new W(f):null;j.$iVersion=2,j.$szOsFile=E.sqlite3_file.structInfo.sizeof,j.$mxPathname=1024,j.$zName=q.allocCString("opfs"),j.$xDlOpen=j.$xDlError=j.$xDlSym=j.$xDlClose=null,j.ondispose=["$zName",j.$zName,"cleanup default VFS wrapper",()=>p?p.dispose():null,"cleanup opfsIoMethods",()=>g.dispose()];const _=Object.create(null);_.verbose=u.verbose,_.littleEndian=(()=>{const I=new ArrayBuffer(2);return new DataView(I).setInt16(0,256,!0),new Int16Array(I)[0]===256})(),_.asyncIdleWaitTime=150,_.asyncS11nExceptions=1,_.fileBufferSize=1024*64,_.sabS11nOffset=_.fileBufferSize,_.sabS11nSize=j.$mxPathname*2,_.sabIO=new SharedArrayBuffer(_.fileBufferSize+_.sabS11nSize),_.opIds=Object.create(null);const P=Object.create(null);{let I=0;_.opIds.whichOp=I++,_.opIds.rc=I++,_.opIds.xAccess=I++,_.opIds.xClose=I++,_.opIds.xDelete=I++,_.opIds.xDeleteNoWait=I++,_.opIds.xFileSize=I++,_.opIds.xLock=I++,_.opIds.xOpen=I++,_.opIds.xRead=I++,_.opIds.xSleep=I++,_.opIds.xSync=I++,_.opIds.xTruncate=I++,_.opIds.xUnlock=I++,_.opIds.xWrite=I++,_.opIds.mkdir=I++,_.opIds["opfs-async-metrics"]=I++,_.opIds["opfs-async-shutdown"]=I++,_.opIds.retry=I++,_.sabOP=new SharedArrayBuffer(I*4),L.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(I=>{(_.sq3Codes[I]=E[I])===void 0&&x("Maintenance required: not found:",I)}),_.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,defaultUnlockAsap:!1});const F=(I,...M)=>{const Q=_.opIds[I]||x("Invalid op ID:",I);_.s11n.serialize(...M),Atomics.store(_.sabOPView,_.opIds.rc,-1),Atomics.store(_.sabOPView,_.opIds.whichOp,Q),Atomics.notify(_.sabOPView,_.opIds.whichOp);const Z=performance.now();Atomics.wait(_.sabOPView,_.opIds.rc,-1);const H=Atomics.load(_.sabOPView,_.opIds.rc);if(P[I].wait+=performance.now()-Z,H&&_.asyncS11nExceptions){const Ne=_.s11n.deserialize();Ne&&y(I+"() async error:",...Ne)}return H};L.debug={asyncShutdown:()=>{m("Shutting down OPFS async listener. The OPFS VFS will no longer work."),F("opfs-async-shutdown")},asyncRestart:()=>{m("Attempting to restart OPFS VFS async listener. Might work, might not."),w.postMessage({type:"opfs-async-restart"})}};const ne=()=>{if(_.s11n)return _.s11n;const I=new TextDecoder,M=new TextEncoder("utf-8"),Q=new Uint8Array(_.sabIO,_.sabS11nOffset,_.sabS11nSize),Z=new DataView(_.sabIO,_.sabS11nOffset,_.sabS11nSize);_.s11n=Object.create(null);const H=Object.create(null);H.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},H.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},H.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},H.string={id:4};const Ne=ee=>H[typeof ee]||x("Maintenance required: this value type cannot be serialized.",ee),be=ee=>{switch(ee){case H.number.id:return H.number;case H.bigint.id:return H.bigint;case H.boolean.id:return H.boolean;case H.string.id:return H.string;default:x("Invalid type ID:",ee)}};return _.s11n.deserialize=function(ee=!1){++P.s11n.deserialize.count;const Lt=performance.now(),ot=Q[0],T=ot?[]:null;if(ot){const J=[];let $=1,X,Oe,Re;for(X=0;X{he.start=performance.now(),he.op=I,++P[I].count},qe=()=>P[he.op].time+=performance.now()-he.start,ze={xCheckReservedLock:function(I,M){const Q=oe[I];return q.poke(M,Q.lockType?1:0,"i32"),0},xClose:function(I){ue("xClose");let M=0;const Q=oe[I];return Q&&(delete oe[I],M=F("xClose",I),Q.sq3File&&Q.sq3File.dispose()),qe(),M},xDeviceCharacteristics:function(I){return E.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(I,M,Q){return E.SQLITE_NOTFOUND},xFileSize:function(I,M){ue("xFileSize");let Q=F("xFileSize",I);if(Q==0)try{const Z=_.s11n.deserialize()[0];q.poke(M,Z,"i64")}catch(Z){y("Unexpected error reading xFileSize() result:",Z),Q=_.sq3Codes.SQLITE_IOERR}return qe(),Q},xLock:function(I,M){ue("xLock");const Q=oe[I];let Z=0;return Q.lockType?Q.lockType=M:(Z=F("xLock",I,M),Z===0&&(Q.lockType=M)),qe(),Z},xRead:function(I,M,Q,Z){ue("xRead");const H=oe[I];let Ne;try{Ne=F("xRead",I,Q,Number(Z)),(Ne===0||E.SQLITE_IOERR_SHORT_READ===Ne)&&q.heap8u().set(H.sabView.subarray(0,Q),M)}catch(be){y("xRead(",arguments,") failed:",be,H),Ne=E.SQLITE_IOERR_READ}return qe(),Ne},xSync:function(I,M){ue("xSync"),++P.xSync.count;const Q=F("xSync",I,M);return qe(),Q},xTruncate:function(I,M){ue("xTruncate");const Q=F("xTruncate",I,Number(M));return qe(),Q},xUnlock:function(I,M){ue("xUnlock");const Q=oe[I];let Z=0;return E.SQLITE_LOCK_NONE===M&&Q.lockType&&(Z=F("xUnlock",I,M)),Z===0&&(Q.lockType=M),qe(),Z},xWrite:function(I,M,Q,Z){ue("xWrite");const H=oe[I];let Ne;try{H.sabView.set(q.heap8u().subarray(M,M+Q)),Ne=F("xWrite",I,Q,Number(Z))}catch(be){y("xWrite(",arguments,") failed:",be,H),Ne=E.SQLITE_IOERR_WRITE}return qe(),Ne}},dt={xAccess:function(I,M,Q,Z){ue("xAccess");const H=F("xAccess",q.cstrToJs(M));return q.poke(Z,H?0:1,"i32"),qe(),0},xCurrentTime:function(I,M){return q.poke(M,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(I,M){return q.poke(M,24405875e-1*864e5+new Date().getTime(),"i64"),0},xDelete:function(I,M,Q){return ue("xDelete"),F("xDelete",q.cstrToJs(M),Q,!1),qe(),0},xFullPathname:function(I,M,Q,Z){return q.cstrncpy(Z,M,Q)!!Z):Q},L.getDirForFilename=async function(M,Q=!1){const Z=L.getResolvedPath(M,!0),H=Z.pop();let Ne=L.rootDirectory;for(const be of Z)be&&(Ne=await Ne.getDirectoryHandle(be,{create:!!Q}));return[Ne,H]},L.mkdir=async function(I){try{return await L.getDirForFilename(I+"/filepart",!0),!0}catch{return!1}},L.entryExists=async function(I){try{const[M,Q]=await L.getDirForFilename(I);return await M.getFileHandle(Q),!0}catch{return!1}},L.randomFilename=re,L.registerVfs=(I=!1)=>q.exports.sqlite3_vfs_register(j.pointer,I?1:0),L.treeList=async function(){const I=async function Q(Z,H){H.name=Z.name,H.dirs=[],H.files=[];for await(const Ne of Z.values())if(Ne.kind==="directory"){const be=Object.create(null);H.dirs.push(be),await Q(Ne,be)}else H.files.push(Ne.name)},M=Object.create(null);return await I(L.rootDirectory,M),M},L.rmfr=async function(){const I=L.rootDirectory,M={recurse:!0};for await(const Q of I.values())I.removeEntry(Q.name,M)},L.unlink=async function(I,M=!1,Q=!1){try{const[Z,H]=await L.getDirForFilename(I,!1);return await Z.removeEntry(H,{recursive:M}),!0}catch(Z){if(Q)throw new Error("unlink(",arguments[0],") failed: "+Z.message,{cause:Z});return!1}},L.traverse=async function(I){const M={recursive:!0,directory:L.rootDirectory};typeof I=="function"&&(I={callback:I}),I=Object.assign(M,I||{}),async function Z(H,Ne){for await(const be of H.values()){if(I.callback(be,H,Ne)===!1)return!1;if(I.recursive&&be.kind==="directory"&&await Z(be,Ne+1)===!1)break}}(I.directory,0)},i.oo1){const I=function(...M){const Q=i.oo1.DB.dbCtorHelper.normalizeArgs(...M);Q.vfs=j.$zName,i.oo1.DB.dbCtorHelper.call(this,Q)};I.prototype=Object.create(i.oo1.DB.prototype),i.oo1.OpfsDb=I,i.oo1.DB.dbCtorHelper.setVfsPostOpenSql(j.pointer,function(M,Q){Q.capi.sqlite3_busy_timeout(M,1e4),Q.capi.sqlite3_exec(M,["pragma journal_mode=persist;","pragma cache_size=-16384;"],0,0,0)})}const Zt=function(){const I=q.scopedAllocPush(),M=new B;try{const Q=M.pointer,Z=E.SQLITE_OPEN_CREATE|E.SQLITE_OPEN_READWRITE|E.SQLITE_OPEN_MAIN_DB,H=q.scopedAlloc(8),Ne="/sanity/check/file"+re(8),be=q.scopedAllocCString(Ne);let ee;if(_.s11n.serialize("This is ä string."),ee=_.s11n.deserialize(),k("deserialize() says:",ee),ee[0]!=="This is ä string."&&x("String d13n error."),dt.xAccess(j.pointer,be,0,H),ee=q.peek(H,"i32"),k("xAccess(",Ne,") exists ?=",ee),ee=dt.xOpen(j.pointer,be,Q,Z,H),k("open rc =",ee,"state.sabOPView[xOpen] =",_.sabOPView[_.opIds.xOpen]),ee!==0){y("open failed with code",ee);return}dt.xAccess(j.pointer,be,0,H),ee=q.peek(H,"i32"),ee||x("xAccess() failed to detect file."),ee=ze.xSync(M.pointer,0),ee&&x("sync failed w/ rc",ee),ee=ze.xTruncate(M.pointer,1024),ee&&x("truncate failed w/ rc",ee),q.poke(H,0,"i64"),ee=ze.xFileSize(M.pointer,H),ee&&x("xFileSize failed w/ rc",ee),k("xFileSize says:",q.peek(H,"i64")),ee=ze.xWrite(M.pointer,be,10,1),ee&&x("xWrite() failed!");const Lt=q.scopedAlloc(16);ee=ze.xRead(M.pointer,Lt,6,2),q.poke(Lt+6,0);let ot=q.cstrToJs(Lt);k("xRead() got:",ot),ot!=="sanity"&&x("Unexpected xRead() value."),dt.xSleep&&(k("xSleep()ing before close()ing..."),dt.xSleep(j.pointer,2e3),k("waking up from xSleep()")),ee=ze.xClose(Q),k("xClose rc =",ee,"sabOPView =",_.sabOPView),k("Deleting file:",Ne),dt.xDelete(j.pointer,be,4660),dt.xAccess(j.pointer,be,0,H),ee=q.peek(H,"i32"),ee&&x("Expecting 0 from xAccess(",Ne,") after xDelete()."),m("End of OPFS sanity checks.")}finally{M.dispose(),q.scopedAllocPop(I)}};w.onmessage=function({data:I}){switch(I.type){case"opfs-unavailable":O(new Error(I.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:ze},vfs:{struct:j,methods:dt}}),_.sabOPView=new Int32Array(_.sabOP),_.sabFileBufView=new Uint8Array(_.sabIO,0,_.fileBufferSize),_.sabS11nView=new Uint8Array(_.sabIO,_.sabS11nOffset,_.sabS11nSize),ne(),u.sanityChecks&&(m("Running sanity checks because of opfs-sanity-check URL arg..."),Zt()),ie()?navigator.storage.getDirectory().then(M=>{w.onerror=w._originalOnError,delete w._originalOnError,i.opfs=L,L.rootDirectory=M,k("End of OPFS sqlite3_vfs setup.",j),b(i)}).catch(O):b(i)}catch(M){y(M),O(M)}break}default:{const M="Unexpected message from the OPFS async worker: "+JSON.stringify(I);y(M),O(new Error(M));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 s<"u"){const i=Object.assign(Object.create(null),{exports:s.asm,memory:s.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}s.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(...V){return t(...V).then(Y=>{var ct,Ze,et;if(typeof WorkerGlobalScope<"u"&&(Y.ENVIRONMENT_IS_PTHREAD||Y._pthread_self||typeof threadAlert=="function"||(et=(Ze=(ct=globalThis==null?void 0:globalThis.location)==null?void 0:ct.pathname)==null?void 0:Ze.endsWith)!=null&&et.call(Ze,".worker.js")))return Y;const pe=Y.sqlite3;pe.scriptInfo=e,A.__isUnderTest&&(pe.__isUnderTest=!0);const Ie=pe.asyncPostInit;return delete pe.asyncPostInit,Ie()}).catch(Y=>{throw console.error("Exception loading sqlite3 module:",Y),Y})},globalThis.sqlite3InitModule.ready=t.ready,globalThis.sqlite3InitModuleState.moduleScript){const A=globalThis.sqlite3InitModuleState;let V=A.moduleScript.src.split("/");V.pop(),A.scriptDir=V.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=class extends Gs{constructor(e){super();xe(this,"serializer");this.serializer=e||ec}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,V=this.serializer(n);return n===V?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...A,value:V}})}transformValue(e){return{...e,value:this.serializer(e.value)}}},rc=class{constructor({deserializer:t,serializer:e}={}){xe(this,"serializeParametersTransformer");xe(this,"deserializer");xe(this,"ctx");this.serializeParametersTransformer=new nc(e),this.deserializer=t||tc,this.ctx=new WeakMap}transformQuery({node:t,queryId:e}){return t.kind==="SelectQueryNode"&&this.ctx.set(e,t.kind),this.serializeParametersTransformer.transformNode(t)}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({result:t,queryId:e}){const{rows:r}=t,n=this.ctx.get(e);return this.ctx.delete(e),r&&n==="SelectQueryNode"?{...t,rows:await this.parseResult(r)}:t}};function ao(t){return typeof t=="string"}function ic(t){return typeof t=="boolean"}async function va(t,e,r,n,A="rowid"){await Et` - create trigger if not exists ${Et.raw(e)}_${Et.raw(n)} - after ${Et.raw(r)} - on ${Et.table(e)} +`)),!i)return null;s.input=yo(i,!0)}return s.input.shift()},put_char:function(s,i){i===null||i===10?(Ot(Cr(s.output,0)),s.output=[]):i!=0&&s.output.push(i)},fsync:function(s){s.output&&s.output.length>0&&(Ot(Cr(s.output,0)),s.output=[])}},default_tty1_ops:{put_char:function(s,i){i===null||i===10?(It(Cr(s.output,0)),s.output=[]):i!=0&&s.output.push(i)},fsync:function(s){s.output&&s.output.length>0&&(It(Cr(s.output,0)),s.output=[])}}};function Ma(s){Yn()}var de={ops_table:null,mount:function(s){return de.createNode(null,"/",16895,0)},createNode:function(s,i,l,a){if(c.isBlkdev(l)||c.isFIFO(l))throw new c.ErrnoError(63);de.ops_table||(de.ops_table={dir:{node:{getattr:de.node_ops.getattr,setattr:de.node_ops.setattr,lookup:de.node_ops.lookup,mknod:de.node_ops.mknod,rename:de.node_ops.rename,unlink:de.node_ops.unlink,rmdir:de.node_ops.rmdir,readdir:de.node_ops.readdir,symlink:de.node_ops.symlink},stream:{llseek:de.stream_ops.llseek}},file:{node:{getattr:de.node_ops.getattr,setattr:de.node_ops.setattr},stream:{llseek:de.stream_ops.llseek,read:de.stream_ops.read,write:de.stream_ops.write,allocate:de.stream_ops.allocate,mmap:de.stream_ops.mmap,msync:de.stream_ops.msync}},link:{node:{getattr:de.node_ops.getattr,setattr:de.node_ops.setattr,readlink:de.node_ops.readlink},stream:{}},chrdev:{node:{getattr:de.node_ops.getattr,setattr:de.node_ops.setattr},stream:c.chrdev_stream_ops}});var u=c.createNode(s,i,l,a);return c.isDir(u.mode)?(u.node_ops=de.ops_table.dir.node,u.stream_ops=de.ops_table.dir.stream,u.contents={}):c.isFile(u.mode)?(u.node_ops=de.ops_table.file.node,u.stream_ops=de.ops_table.file.stream,u.usedBytes=0,u.contents=null):c.isLink(u.mode)?(u.node_ops=de.ops_table.link.node,u.stream_ops=de.ops_table.link.stream):c.isChrdev(u.mode)&&(u.node_ops=de.ops_table.chrdev.node,u.stream_ops=de.ops_table.chrdev.stream),u.timestamp=Date.now(),s&&(s.contents[i]=u,s.timestamp=u.timestamp),u},getFileDataAsTypedArray:function(s){return s.contents?s.contents.subarray?s.contents.subarray(0,s.usedBytes):new Uint8Array(s.contents):new Uint8Array(0)},expandFileStorage:function(s,i){var l=s.contents?s.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=s.contents;s.contents=new Uint8Array(i),s.usedBytes>0&&s.contents.set(u.subarray(0,s.usedBytes),0)}},resizeFileStorage:function(s,i){if(s.usedBytes!=i)if(i==0)s.contents=null,s.usedBytes=0;else{var l=s.contents;s.contents=new Uint8Array(i),l&&s.contents.set(l.subarray(0,Math.min(i,s.usedBytes))),s.usedBytes=i}},node_ops:{getattr:function(s){var i={};return i.dev=c.isChrdev(s.mode)?s.id:1,i.ino=s.id,i.mode=s.mode,i.nlink=1,i.uid=0,i.gid=0,i.rdev=s.rdev,c.isDir(s.mode)?i.size=4096:c.isFile(s.mode)?i.size=s.usedBytes:c.isLink(s.mode)?i.size=s.link.length:i.size=0,i.atime=new Date(s.timestamp),i.mtime=new Date(s.timestamp),i.ctime=new Date(s.timestamp),i.blksize=4096,i.blocks=Math.ceil(i.size/i.blksize),i},setattr:function(s,i){i.mode!==void 0&&(s.mode=i.mode),i.timestamp!==void 0&&(s.timestamp=i.timestamp),i.size!==void 0&&de.resizeFileStorage(s,i.size)},lookup:function(s,i){throw c.genericErrors[44]},mknod:function(s,i,l,a){return de.createNode(s,i,l,a)},rename:function(s,i,l){if(c.isDir(s.mode)){var a;try{a=c.lookupNode(i,l)}catch{}if(a)for(var u in a.contents)throw new c.ErrnoError(55)}delete s.parent.contents[s.name],s.parent.timestamp=Date.now(),s.name=l,i.contents[l]=s,i.timestamp=s.parent.timestamp,s.parent=i},unlink:function(s,i){delete s.contents[i],s.timestamp=Date.now()},rmdir:function(s,i){var l=c.lookupNode(s,i);for(var a in l.contents)throw new c.ErrnoError(55);delete s.contents[i],s.timestamp=Date.now()},readdir:function(s){var i=[".",".."];for(var l in s.contents)s.contents.hasOwnProperty(l)&&i.push(l);return i},symlink:function(s,i,l){var a=de.createNode(s,i,41471,0);return a.link=l,a},readlink:function(s){if(!c.isLink(s.mode))throw new c.ErrnoError(28);return s.link}},stream_ops:{read:function(s,i,l,a,u){var d=s.node.contents;if(u>=s.node.usedBytes)return 0;var N=Math.min(s.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{In(d,'Loading data file "'+s+'" failed (no arrayBuffer).'),i(new Uint8Array(d)),u&&Ts()},d=>{if(l)l();else throw'Loading data file "'+s+'" failed.'}),u&&_o()}var c={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(s,i={})=>{if(s=dn.resolve(s),!s)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=s.split("/").filter(te=>!!te),u=c.root,d="/",N=0;N40)throw new c.ErrnoError(32)}}return{path:d,node:u}},getPath:s=>{for(var i;;){if(c.isRoot(s)){var l=s.mount.mountpoint;return i?l[l.length-1]!=="/"?l+"/"+i:l+i:l}i=i?s.name+"/"+i:s.name,s=s.parent}},hashName:(s,i)=>{for(var l=0,a=0;a>>0)%c.nameTable.length},hashAddNode:s=>{var i=c.hashName(s.parent.id,s.name);s.name_next=c.nameTable[i],c.nameTable[i]=s},hashRemoveNode:s=>{var i=c.hashName(s.parent.id,s.name);if(c.nameTable[i]===s)c.nameTable[i]=s.name_next;else for(var l=c.nameTable[i];l;){if(l.name_next===s){l.name_next=s.name_next;break}l=l.name_next}},lookupNode:(s,i)=>{var l=c.mayLookup(s);if(l)throw new c.ErrnoError(l,s);for(var a=c.hashName(s.id,i),u=c.nameTable[a];u;u=u.name_next){var d=u.name;if(u.parent.id===s.id&&d===i)return u}return c.lookup(s,i)},createNode:(s,i,l,a)=>{var u=new c.FSNode(s,i,l,a);return c.hashAddNode(u),u},destroyNode:s=>{c.hashRemoveNode(s)},isRoot:s=>s===s.parent,isMountpoint:s=>!!s.mounted,isFile:s=>(s&61440)===32768,isDir:s=>(s&61440)===16384,isLink:s=>(s&61440)===40960,isChrdev:s=>(s&61440)===8192,isBlkdev:s=>(s&61440)===24576,isFIFO:s=>(s&61440)===4096,isSocket:s=>(s&49152)===49152,flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:s=>{var i=c.flagModes[s];if(typeof i>"u")throw new Error("Unknown file open mode: "+s);return i},flagsToPermissionString:s=>{var i=["r","w","rw"][s&3];return s&512&&(i+="w"),i},nodePermissions:(s,i)=>c.ignorePermissions?0:i.includes("r")&&!(s.mode&292)||i.includes("w")&&!(s.mode&146)||i.includes("x")&&!(s.mode&73)?2:0,mayLookup:s=>{var i=c.nodePermissions(s,"x");return i||(s.node_ops.lookup?0:2)},mayCreate:(s,i)=>{try{var l=c.lookupNode(s,i);return 20}catch{}return c.nodePermissions(s,"wx")},mayDelete:(s,i,l)=>{var a;try{a=c.lookupNode(s,i)}catch(d){return d.errno}var u=c.nodePermissions(s,"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:(s,i)=>s?c.isLink(s.mode)?32:c.isDir(s.mode)&&(c.flagsToPermissionString(i)!=="r"||i&512)?31:c.nodePermissions(s,c.flagsToPermissionString(i)):44,MAX_OPEN_FDS:4096,nextfd:(s=0,i=c.MAX_OPEN_FDS)=>{for(var l=s;l<=i;l++)if(!c.streams[l])return l;throw new c.ErrnoError(33)},getStream:s=>c.streams[s],createStream:(s,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}}})),s=Object.assign(new c.FSStream,s);var a=c.nextfd(i,l);return s.fd=a,c.streams[a]=s,s},closeStream:s=>{c.streams[s]=null},chrdev_stream_ops:{open:s=>{var i=c.getDevice(s.node.rdev);s.stream_ops=i.stream_ops,s.stream_ops.open&&s.stream_ops.open(s)},llseek:()=>{throw new c.ErrnoError(70)}},major:s=>s>>8,minor:s=>s&255,makedev:(s,i)=>s<<8|i,registerDevice:(s,i)=>{c.devices[s]={stream_ops:i}},getDevice:s=>c.devices[s],getMounts:s=>{for(var i=[],l=[s];l.length;){var a=l.pop();i.push(a),l.push.apply(l,a.mounts)}return i},syncfs:(s,i)=>{typeof s=="function"&&(i=s,s=!1),c.syncFSRequests++,c.syncFSRequests>1&&It("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,s,d)})},mount:(s,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:s,opts:i,mountpoint:l,mounts:[]},C=s.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:s=>{var i=c.lookupPath(s,{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:(s,i)=>s.node_ops.lookup(s,i),mknod:(s,i,l)=>{var a=c.lookupPath(s,{parent:!0}),u=a.node,d=Ne.basename(s);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:(s,i)=>(i=i!==void 0?i:438,i&=4095,i|=32768,c.mknod(s,i,0)),mkdir:(s,i)=>(i=i!==void 0?i:511,i&=1023,i|=16384,c.mknod(s,i,0)),mkdirTree:(s,i)=>{for(var l=s.split("/"),a="",u=0;u(typeof l>"u"&&(l=i,i=438),i|=8192,c.mknod(s,i,l)),symlink:(s,i)=>{if(!dn.resolve(s))throw new c.ErrnoError(44);var l=c.lookupPath(i,{parent:!0}),a=l.node;if(!a)throw new c.ErrnoError(44);var u=Ne.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,s)},rename:(s,i)=>{var l=Ne.dirname(s),a=Ne.dirname(i),u=Ne.basename(s),d=Ne.basename(i),N,S,C;if(N=c.lookupPath(s,{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),K=dn.relative(s,a);if(K.charAt(0)!==".")throw new c.ErrnoError(28);if(K=dn.relative(i,l),K.charAt(0)!==".")throw new c.ErrnoError(55);var te;try{te=c.lookupNode(C,d)}catch{}if(V!==te){var k=c.isDir(V.mode),m=c.mayDelete(S,u,k);if(m)throw new c.ErrnoError(m);if(m=te?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)||te&&c.isMountpoint(te))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:s=>{var i=c.lookupPath(s,{parent:!0}),l=i.node,a=Ne.basename(s),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:s=>{var i=c.lookupPath(s,{follow:!0}),l=i.node;if(!l.node_ops.readdir)throw new c.ErrnoError(54);return l.node_ops.readdir(l)},unlink:s=>{var i=c.lookupPath(s,{parent:!0}),l=i.node;if(!l)throw new c.ErrnoError(44);var a=Ne.basename(s),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:s=>{var i=c.lookupPath(s),l=i.node;if(!l)throw new c.ErrnoError(44);if(!l.node_ops.readlink)throw new c.ErrnoError(28);return dn.resolve(c.getPath(l.parent),l.node_ops.readlink(l))},stat:(s,i)=>{var l=c.lookupPath(s,{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:s=>c.stat(s,!0),chmod:(s,i,l)=>{var a;if(typeof s=="string"){var u=c.lookupPath(s,{follow:!l});a=u.node}else a=s;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:(s,i)=>{c.chmod(s,i,!0)},fchmod:(s,i)=>{var l=c.getStream(s);if(!l)throw new c.ErrnoError(8);c.chmod(l.node,i)},chown:(s,i,l,a)=>{var u;if(typeof s=="string"){var d=c.lookupPath(s,{follow:!a});u=d.node}else u=s;if(!u.node_ops.setattr)throw new c.ErrnoError(63);u.node_ops.setattr(u,{timestamp:Date.now()})},lchown:(s,i,l)=>{c.chown(s,i,l,!0)},fchown:(s,i,l)=>{var a=c.getStream(s);if(!a)throw new c.ErrnoError(8);c.chown(a.node,i,l)},truncate:(s,i)=>{if(i<0)throw new c.ErrnoError(28);var l;if(typeof s=="string"){var a=c.lookupPath(s,{follow:!0});l=a.node}else l=s;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:(s,i)=>{var l=c.getStream(s);if(!l)throw new c.ErrnoError(8);if(!(l.flags&2097155))throw new c.ErrnoError(28);c.truncate(l.node,i)},utime:(s,i,l)=>{var a=c.lookupPath(s,{follow:!0}),u=a.node;u.node_ops.setattr(u,{timestamp:Math.max(i,l)})},open:(s,i,l)=>{if(s==="")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 s=="object")a=s;else{s=Ne.normalize(s);try{var u=c.lookupPath(s,{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(s,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={}),s in c.readFiles||(c.readFiles[s]=1)),S},close:s=>{if(c.isClosed(s))throw new c.ErrnoError(8);s.getdents&&(s.getdents=null);try{s.stream_ops.close&&s.stream_ops.close(s)}catch(i){throw i}finally{c.closeStream(s.fd)}s.fd=null},isClosed:s=>s.fd===null,llseek:(s,i,l)=>{if(c.isClosed(s))throw new c.ErrnoError(8);if(!s.seekable||!s.stream_ops.llseek)throw new c.ErrnoError(70);if(l!=0&&l!=1&&l!=2)throw new c.ErrnoError(28);return s.position=s.stream_ops.llseek(s,i,l),s.ungotten=[],s.position},read:(s,i,l,a,u)=>{if(a<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(s))throw new c.ErrnoError(8);if((s.flags&2097155)===1)throw new c.ErrnoError(8);if(c.isDir(s.node.mode))throw new c.ErrnoError(31);if(!s.stream_ops.read)throw new c.ErrnoError(28);var d=typeof u<"u";if(!d)u=s.position;else if(!s.seekable)throw new c.ErrnoError(70);var N=s.stream_ops.read(s,i,l,a,u);return d||(s.position+=N),N},write:(s,i,l,a,u,d)=>{if(a<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(s))throw new c.ErrnoError(8);if(!(s.flags&2097155))throw new c.ErrnoError(8);if(c.isDir(s.node.mode))throw new c.ErrnoError(31);if(!s.stream_ops.write)throw new c.ErrnoError(28);s.seekable&&s.flags&1024&&c.llseek(s,0,2);var N=typeof u<"u";if(!N)u=s.position;else if(!s.seekable)throw new c.ErrnoError(70);var S=s.stream_ops.write(s,i,l,a,u,d);return N||(s.position+=S),S},allocate:(s,i,l)=>{if(c.isClosed(s))throw new c.ErrnoError(8);if(i<0||l<=0)throw new c.ErrnoError(28);if(!(s.flags&2097155))throw new c.ErrnoError(8);if(!c.isFile(s.node.mode)&&!c.isDir(s.node.mode))throw new c.ErrnoError(43);if(!s.stream_ops.allocate)throw new c.ErrnoError(138);s.stream_ops.allocate(s,i,l)},mmap:(s,i,l,a,u)=>{if(a&2&&!(u&2)&&(s.flags&2097155)!==2)throw new c.ErrnoError(2);if((s.flags&2097155)===1)throw new c.ErrnoError(2);if(!s.stream_ops.mmap)throw new c.ErrnoError(43);return s.stream_ops.mmap(s,i,l,a,u)},msync:(s,i,l,a,u)=>s.stream_ops.msync?s.stream_ops.msync(s,i,l,a,u):0,munmap:s=>0,ioctl:(s,i,l)=>{if(!s.stream_ops.ioctl)throw new c.ErrnoError(59);return s.stream_ops.ioctl(s,i,l)},readFile:(s,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(s,i.flags),u=c.stat(s),d=u.size,N=new Uint8Array(d);return c.read(a,N,0,d,0),i.encoding==="utf8"?l=Cr(N,0):i.encoding==="binary"&&(l=N),c.close(a),l},writeFile:(s,i,l={})=>{l.flags=l.flags||577;var a=c.open(s,l.flags,l.mode);if(typeof i=="string"){var u=new Uint8Array(qi(i)+1),d=Is(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:s=>{var i=c.lookupPath(s,{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)),Zn.register(c.makedev(5,0),Zn.default_tty_ops),Zn.register(c.makedev(6,0),Zn.default_tty1_ops),c.mkdev("/dev/tty",c.makedev(5,0)),c.mkdev("/dev/tty1",c.makedev(6,0));var s=kc();c.createDevice("/dev","random",s),c.createDevice("/dev","urandom",s),c.mkdir("/dev/shm"),c.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{c.mkdir("/proc");var s=c.mkdir("/proc/self");c.mkdir("/proc/self/fd"),c.mount({mount:()=>{var i=c.createNode(s,"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(s=>{c.genericErrors[s]=new c.ErrnoError(s),c.genericErrors[s].stack=""}))},staticInit:()=>{c.ensureErrnoError(),c.nameTable=new Array(4096),c.mount(de,{},"/"),c.createDefaultDirectories(),c.createDefaultDevices(),c.createSpecialDirectories(),c.filesystems={MEMFS:de}},init:(s,i,l)=>{c.init.initialized=!0,c.ensureErrnoError(),n.stdin=s||n.stdin,n.stdout=i||n.stdout,n.stderr=l||n.stderr,c.createStandardStreams()},quit:()=>{c.init.initialized=!1;for(var s=0;s{var l=0;return s&&(l|=365),i&&(l|=146),l},findObject:(s,i)=>{var l=c.analyzePath(s,i);return l.exists?l.object:null},analyzePath:(s,i)=>{try{var l=c.lookupPath(s,{follow:!i});s=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(s,{parent:!0});a.parentExists=!0,a.parentPath=l.path,a.parentObject=l.node,a.name=Ne.basename(s),l=c.lookupPath(s,{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:(s,i,l,a)=>{s=typeof s=="string"?s:c.getPath(s);for(var u=i.split("/").reverse();u.length;){var d=u.pop();if(d){var N=Ne.join2(s,d);try{c.mkdir(N)}catch{}s=N}}return N},createFile:(s,i,l,a,u)=>{var d=Ne.join2(typeof s=="string"?s:c.getPath(s),i),N=c.getMode(a,u);return c.create(d,N)},createDataFile:(s,i,l,a,u,d)=>{var N=i;s&&(s=typeof s=="string"?s:c.getPath(s),N=i?Ne.join2(s,i):s);var S=c.getMode(a,u),C=c.create(N,S);if(l){if(typeof l=="string"){for(var V=new Array(l.length),K=0,te=l.length;K{var u=Ne.join2(typeof s=="string"?s:c.getPath(s),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,K,te)=>{for(var k=0,m=0;m{for(var k=0;k{if(s.isDevice||s.isFolder||s.link||s.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($n)try{s.contents=yo($n(s.url),!0),s.usedBytes=s.contents.length}catch{throw new c.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(s,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",q=(x=m.getResponseHeader("Content-Encoding"))&&x==="gzip",W=1024*1024;E||(W=y);var M=(L,ie)=>{if(L>ie)throw new Error("invalid range ("+L+", "+ie+") or no bytes requested!");if(ie>y-1)throw new Error("only "+y+" bytes available! programmer error!");var z=new XMLHttpRequest;if(z.open("GET",l,!1),y!==W&&z.setRequestHeader("Range","bytes="+L+"-"+ie),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||[]):yo(z.responseText||"",!0)},R=this;R.setDataGetter(L=>{var ie=L*W,z=(L+1)*W-1;if(z=Math.min(z,y-1),typeof R.chunks[L]>"u"&&(R.chunks[L]=M(ie,z)),typeof R.chunks[L]>"u")throw new Error("doXHR failed!");return R.chunks[L]}),(q||!y)&&(W=y=1,y=this.getter(0).length,W=y,Ot("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=y,this._chunkSize=W,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!ct)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(s,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={},K=Object.keys(C.stream_ops);K.forEach(k=>{var m=C.stream_ops[k];V[k]=function(){return c.forceLoadFile(C),m.apply(null,arguments)}});function te(k,m,y,x,E){var q=k.node.contents;if(E>=q.length)return 0;var W=Math.min(q.length-E,x);if(q.slice)for(var M=0;M(c.forceLoadFile(C),te(k,m,y,x,E)),V.mmap=(k,m,y,x,E)=>{c.forceLoadFile(C);var q=Ma();if(!q)throw new c.ErrnoError(48);return te(k,Tt,q,m,y),{ptr:q,allocated:!0}},C.stream_ops=V,C},createPreloadedFile:(s,i,l,a,u,d,N,S,C,V)=>{var K=i?dn.resolve(Ne.join2(s,i)):s;function te(k){function m(y){V&&V(),S||c.createDataFile(s,i,y,a,u,C),d&&d(),Ts()}Browser.handledByPreloadPlugin(k,K,m,()=>{N&&N(),Ts()})||m(k)}_o(),typeof l=="string"?Ac(l,k=>te(k),N):te(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:(s,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=()=>{Ot("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,K=s.length;function te(){V==0?i():l()}s.forEach(k=>{var m=S.put(c.analyzePath(k).object.contents,k);m.onsuccess=()=>{C++,C+V==K&&te()},m.onerror=()=>{V++,C+V==K&&te()}}),N.onerror=l},u.onerror=l},loadFilesFromDB:(s,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,K=s.length;function te(){V==0?i():l()}s.forEach(k=>{var m=S.get(k);m.onsuccess=()=>{c.analyzePath(k).exists&&c.unlink(k),c.createDataFile(Ne.dirname(k),Ne.basename(k),m.result,!0,!0,!0),C++,C+V==K&&te()},m.onerror=()=>{V++,C+V==K&&te()}}),N.onerror=l},u.onerror=l}},ce={DEFAULT_POLLMASK:5,calculateAt:function(s,i,l){if(Ne.isAbs(i))return i;var a;if(s===-100)a=c.cwd();else{var u=ce.getStreamFromFD(s);a=u.path}if(i.length==0){if(!l)throw new c.ErrnoError(44);return a}return Ne.join2(a,i)},doStat:function(s,i,l){try{var a=s(i)}catch(S){if(S&&S.node&&Ne.normalize(i)!==Ne.normalize(c.getPath(S.node)))return-54;throw S}_e[l>>2]=a.dev,_e[l+8>>2]=a.ino,_e[l+12>>2]=a.mode,tt[l+16>>2]=a.nlink,_e[l+20>>2]=a.uid,_e[l+24>>2]=a.gid,_e[l+28>>2]=a.rdev,st=[a.size>>>0,(ye=a.size,+Math.abs(ye)>=1?ye>0?(Math.min(+Math.floor(ye/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ye-+(~~ye>>>0))/4294967296)>>>0:0)],_e[l+40>>2]=st[0],_e[l+44>>2]=st[1],_e[l+48>>2]=4096,_e[l+52>>2]=a.blocks;var u=a.atime.getTime(),d=a.mtime.getTime(),N=a.ctime.getTime();return st=[Math.floor(u/1e3)>>>0,(ye=Math.floor(u/1e3),+Math.abs(ye)>=1?ye>0?(Math.min(+Math.floor(ye/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ye-+(~~ye>>>0))/4294967296)>>>0:0)],_e[l+56>>2]=st[0],_e[l+60>>2]=st[1],tt[l+64>>2]=u%1e3*1e3,st=[Math.floor(d/1e3)>>>0,(ye=Math.floor(d/1e3),+Math.abs(ye)>=1?ye>0?(Math.min(+Math.floor(ye/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ye-+(~~ye>>>0))/4294967296)>>>0:0)],_e[l+72>>2]=st[0],_e[l+76>>2]=st[1],tt[l+80>>2]=d%1e3*1e3,st=[Math.floor(N/1e3)>>>0,(ye=Math.floor(N/1e3),+Math.abs(ye)>=1?ye>0?(Math.min(+Math.floor(ye/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ye-+(~~ye>>>0))/4294967296)>>>0:0)],_e[l+88>>2]=st[0],_e[l+92>>2]=st[1],tt[l+96>>2]=N%1e3*1e3,st=[a.ino>>>0,(ye=a.ino,+Math.abs(ye)>=1?ye>0?(Math.min(+Math.floor(ye/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ye-+(~~ye>>>0))/4294967296)>>>0:0)],_e[l+104>>2]=st[0],_e[l+108>>2]=st[1],0},doMsync:function(s,i,l,a,u){if(!c.isFile(i.node.mode))throw new c.ErrnoError(43);if(a&2)return 0;var d=Ni.slice(s,s+l);c.msync(i,d,u,l,a)},varargs:void 0,get:function(){ce.varargs+=4;var s=_e[ce.varargs-4>>2];return s},getStr:function(s){var i=yc(s);return i},getStreamFromFD:function(s){var i=c.getStream(s);if(!i)throw new c.ErrnoError(8);return i}};function Oc(s,i){try{return s=ce.getStr(s),c.chmod(s,i),0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Ic(s,i,l,a){try{if(i=ce.getStr(i),i=ce.calculateAt(s,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 Tc(s,i){try{return c.fchmod(s,i),0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Cc(s,i,l){try{return c.fchown(s,i,l),0}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}function Pc(s){return _e[Va()>>2]=s,s}function Wc(s,i,l){ce.varargs=l;try{var a=ce.getStreamFromFD(s);switch(i){case 0:{var u=ce.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=ce.get();return a.flags|=u,0}case 5:{var u=ce.get(),N=0;return Ta[u+N>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return Pc(28),-1;default:return-28}}catch(S){if(typeof c>"u"||!(S instanceof c.ErrnoError))throw S;return-S.errno}}function Fc(s,i){try{var l=ce.getStreamFromFD(s);return ce.doStat(c.stat,l.path,i)}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}var Lc=9007199254740992,Dc=-9007199254740992;function Ba(s){return sLc?NaN:Number(s)}function Rc(s,i){try{return i=Ba(i),isNaN(i)?-61:(c.ftruncate(s,i),0)}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Mc(s,i){try{if(i===0)return-28;var l=c.cwd(),a=qi(l)+1;return i"u"||!(u instanceof c.ErrnoError))throw u;return-u.errno}}function Bc(s,i,l){ce.varargs=l;try{var a=ce.getStreamFromFD(s);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=ce.get();return _e[u>>2]=0,0}case 21520:return a.tty?-28:-59;case 21531:{var u=ce.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 Uc(s,i){try{return s=ce.getStr(s),ce.doStat(c.lstat,s,i)}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Qc(s,i,l){try{return i=ce.getStr(i),i=ce.calculateAt(s,i),i=Ne.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 jc(s,i,l,a){try{i=ce.getStr(i);var u=a&256,d=a&4096;return a=a&-6401,i=ce.calculateAt(s,i,d),ce.doStat(u?c.lstat:c.stat,i,l)}catch(N){if(typeof c>"u"||!(N instanceof c.ErrnoError))throw N;return-N.errno}}function zc(s,i,l,a){ce.varargs=a;try{i=ce.getStr(i),i=ce.calculateAt(s,i);var u=a?ce.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 Vc(s,i,l,a){try{if(i=ce.getStr(i),i=ce.calculateAt(s,i),a<=0)return-28;var u=c.readlink(i),d=Math.min(a,qi(u)),N=Tt[l+d];return Ia(u,l,a+1),Tt[l+d]=N,d}catch(S){if(typeof c>"u"||!(S instanceof c.ErrnoError))throw S;return-S.errno}}function Jc(s){try{return s=ce.getStr(s),c.rmdir(s),0}catch(i){if(typeof c>"u"||!(i instanceof c.ErrnoError))throw i;return-i.errno}}function Gc(s,i){try{return s=ce.getStr(s),ce.doStat(c.stat,s,i)}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Hc(s,i,l){try{return i=ce.getStr(i),i=ce.calculateAt(s,i),l===0?c.unlink(i):l===512?c.rmdir(i):Yn("Invalid flags passed to unlinkat"),0}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}function go(s){return tt[s>>2]+_e[s+4>>2]*4294967296}function $c(s,i,l,a){try{if(i=ce.getStr(i),i=ce.calculateAt(s,i,!0),l){var N=go(l),S=_e[l+8>>2];u=N*1e3+S/(1e3*1e3),l+=16,N=go(l),S=_e[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 Kc=!0;function Xc(){return Kc}function Yc(s){return s%4===0&&(s%100!==0||s%400===0)}var Zc=[0,31,60,91,121,152,182,213,244,274,305,335],ed=[0,31,59,90,120,151,181,212,243,273,304,334];function td(s){var i=Yc(s.getFullYear()),l=i?Zc:ed,a=l[s.getMonth()]+s.getDate()-1;return a}function nd(s,i){var l=new Date(go(s)*1e3);_e[i>>2]=l.getSeconds(),_e[i+4>>2]=l.getMinutes(),_e[i+8>>2]=l.getHours(),_e[i+12>>2]=l.getDate(),_e[i+16>>2]=l.getMonth(),_e[i+20>>2]=l.getFullYear()-1900,_e[i+24>>2]=l.getDay();var a=td(l)|0;_e[i+28>>2]=a,_e[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;_e[i+32>>2]=S}function Ua(s){var i=qi(s)+1,l=Ja(i);return l&&Is(s,Tt,l,i),l}function rd(s,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);tt[s>>2]=C*60,_e[i>>2]=+(N!=S);function V(y){var x=y.toTimeString().match(/\(([A-Za-z ]+)\)$/);return x?x[1]:"GMT"}var K=V(u),te=V(d),k=Ua(K),m=Ua(te);S>2]=k,tt[l+4>>2]=m):(tt[l>>2]=m,tt[l+4>>2]=k)}function id(){return Date.now()}var Qa;Qa=()=>performance.now();function sd(){return 2147483648}function od(s){var i=Zt.buffer;try{return Zt.grow(s-i.byteLength+65535>>>16),Ca(),1}catch{}}function ad(s){var i=Ni.length;s=s>>>0;var l=sd();if(s>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,s+100663296);var N=Math.min(l,a(Math.max(s,d),65536)),S=od(N);if(S)return!0}return!1}var wo={};function ld(){return je||"./this.program"}function xi(){if(!xi.strings){var s=(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:s,_:ld()};for(var l in wo)wo[l]===void 0?delete i[l]:i[l]=wo[l];var a=[];for(var l in i)a.push(l+"="+i[l]);xi.strings=a}return xi.strings}function ud(s,i,l){for(var a=0;a>0]=s.charCodeAt(a);l||(Tt[i>>0]=0)}function cd(s,i){var l=0;return xi().forEach(function(a,u){var d=i+l;tt[s+u*4>>2]=d,ud(a,d),l+=a.length+1}),0}function dd(s,i){var l=xi();tt[s>>2]=l.length;var a=0;return l.forEach(function(u){a+=u.length+1}),tt[i>>2]=a,0}function fd(s){try{var i=ce.getStreamFromFD(s);return c.close(i),0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return l.errno}}function hd(s,i){try{var l=ce.getStreamFromFD(s),a=l.tty?2:c.isDir(l.mode)?3:c.isLink(l.mode)?7:4;return Tt[i>>0]=a,0}catch(u){if(typeof c>"u"||!(u instanceof c.ErrnoError))throw u;return u.errno}}function pd(s,i,l,a){for(var u=0,d=0;d>2],S=tt[i+4>>2];i+=8;var C=c.read(s,Tt,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 md(s,i,l,a){try{if(i=Ba(i),isNaN(i))return 61;var u=ce.getStreamFromFD(s);return c.llseek(u,i,l),st=[u.position>>>0,(ye=u.position,+Math.abs(ye)>=1?ye>0?(Math.min(+Math.floor(ye/4294967296),4294967295)|0)>>>0:~~+Math.ceil((ye-+(~~ye>>>0))/4294967296)>>>0:0)],_e[a>>2]=st[0],_e[a+4>>2]=st[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 yd(s){try{var i=ce.getStreamFromFD(s);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 gd(s,i,l,a){for(var u=0,d=0;d>2],S=tt[i+4>>2];i+=8;var C=c.write(s,Tt,N,S,a);if(C<0)return-1;u+=C,typeof a<"u"&&(a+=C)}return u}function wd(s,i,l,a){try{var u=ce.getStreamFromFD(s),d=gd(u,i,l);return tt[a>>2]=d,0}catch(N){if(typeof c>"u"||!(N instanceof c.ErrnoError))throw N;return N.errno}}var ja=function(s,i,l,a){s||(s=this),this.parent=s,this.mount=s.mount,this.mounted=null,this.id=c.nextInode++,this.name=i,this.mode=l,this.node_ops={},this.stream_ops={},this.rdev=a},Cs=365,Ps=146;Object.defineProperties(ja.prototype,{read:{get:function(){return(this.mode&Cs)===Cs},set:function(s){s?this.mode|=Cs:this.mode&=~Cs}},write:{get:function(){return(this.mode&Ps)===Ps},set:function(s){s?this.mode|=Ps:this.mode&=~Ps}},isFolder:{get:function(){return c.isDir(this.mode)}},isDevice:{get:function(){return c.isChrdev(this.mode)}}}),c.FSNode=ja,c.staticInit();var za={__syscall_chmod:Oc,__syscall_faccessat:Ic,__syscall_fchmod:Tc,__syscall_fchown32:Cc,__syscall_fcntl64:Wc,__syscall_fstat64:Fc,__syscall_ftruncate64:Rc,__syscall_getcwd:Mc,__syscall_ioctl:Bc,__syscall_lstat64:Uc,__syscall_mkdirat:Qc,__syscall_newfstatat:jc,__syscall_openat:zc,__syscall_readlinkat:Vc,__syscall_rmdir:Jc,__syscall_stat64:Gc,__syscall_unlinkat:Hc,__syscall_utimensat:$c,_emscripten_get_now_is_monotonic:Xc,_localtime_js:nd,_tzset_js:rd,emscripten_date_now:id,emscripten_get_now:Qa,emscripten_resize_heap:ad,environ_get:cd,environ_sizes_get:dd,fd_close:fd,fd_fdstat_get:hd,fd_read:_d,fd_seek:md,fd_sync:yd,fd_write:wd,memory:Zt};Sc(),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 Va=n.___errno_location=function(){return(Va=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 Ja=n._malloc=function(){return(Ja=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=Zt;var Ws;vi=function s(){Ws||Ga(),Ws||(vi=s)};function Ga(s){if(Xn>0||(gc(),Xn>0))return;function i(){Ws||(Ws=!0,n.calledRun=!0,!Kn&&(wc(),O(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),bc()))}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 Ga(),n.postRun||(n.postRun=[]),n.postRun.push(function(s){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 s<"u"?!!s.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 P=N(_);typeof p[1]=="object"?super(P,p[1]):(p[0]=P+":",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 K=f=>typeof f!="bigint"&&f===(f|0)&&f<=2147483647&&f>=-2147483648,te=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&&K(f.constructor.BYTES_PER_ELEMENT)?f:!1,x=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,E=f=>f.buffer instanceof x,q=(f,p,_)=>E(f)?f.slice(p,_):f.subarray(p,_),W=f=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),M=f=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),R=f=>W(f)||V("Value is not of a supported TypedArray type."),L=new TextDecoder("utf-8"),ie=function(f,p,_){return L.decode(q(f,p,_))},z=function(f){return M(f)?ie(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,_,P,F,ne,re,se,fe)=>{},sqlite3_create_function:(f,p,_,P,F,ne,re,se)=>{},sqlite3_create_window_function:(f,p,_,P,F,ne,re,se,fe,le)=>{},sqlite3_prepare_v3:(f,p,_,P,F,ne)=>{},sqlite3_prepare_v2:(f,p,_,P,F)=>{},sqlite3_exec:(f,p,_,P,F)=>{},sqlite3_randomness:(f,p)=>{}});const v={affirmBindableTypedArray:R,flexibleString:z,bigIntFits32:k,bigIntFits64:te,bigIntFitsDouble:m,isBindableTypedArray:W,isInt32:K,isSQLableTypedArray:M,isTypedArray:y,typedArrayToString:ie,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,isSharedTypedArray:E,toss:function(...f){throw new Error(f.join(" "))},toss3:V,typedArrayPart:q};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)),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 P of[f,p,_])d.exports[P]instanceof Function||V("Missing required exports[",P,"] function.");d.alloc=function P(F){return P.impl(F)||g.toss("Failed to allocate",F," bytes.")},d.alloc.impl=d.exports[f],d.realloc=function P(F,ne){const re=P.impl(F,ne);return ne?re||g.toss("Failed to reallocate",ne," 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(P=>{_[P]=u.sqlite3_compileoption_used(P)}),_}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(re,se){const fe=f._rx.exec(re);se[0]=fe?fe[1]:re,se[1]=fe?f._rxInt.test(fe[2])?+fe[2]:fe[2]:!0});const _={},P=[0,0];let F=0,ne;for(;ne=u.sqlite3_compileoption_get(F++);)f._opt(ne,P),_[P[0]]=P[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),P=[];let F=0,ne=0;for(;Ff===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 P=p.byteLength,F=0;const ne=d.exports.sqlite3_randomness,re=d.heap8u(),se=P<512?P:512,fe=d.pstack.alloc(se);do{const le=P>se?se:P;ne(le,fe),p.set(q(re,fe,fe+le),F),P-=le,F+=le}while(P>0)}catch(P){console.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",P)}finally{d.pstack.restore(_)}return p}d.exports.sqlite3_randomness(...f)};let A;if(u.sqlite3_wasmfs_opfs_dir=function(){if(A!==void 0)return A;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 A="";try{return f&&d.xCallWrapped("sqlite3_wasm_init_wasmfs","i32",["string"],f)===0?A=f:A=""}catch{return A=""}},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 P=u.sqlite3_vfs_find(p);return P?f?P===u.sqlite3_js_db_vfs(f,_)?P:!1:P===u.sqlite3_vfs_find(0)?P:!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 P;try{const F=d.scopedAlloc(8+d.ptrSizeof),ne=F+8,re=p?d.isPtr(p)?p:d.scopedAllocCString(""+p):0;let se=d.exports.sqlite3_wasm_db_serialize(f,re,ne,F,0);se&&V("Database serialization failed with code",w.capi.sqlite3_js_rc_str(se)),P=d.peekPtr(ne);const fe=d.peek(F,"i64");return se=fe?d.heap8u().slice(P,P+Number(fe)):new Uint8Array,se}finally{P&&d.exports.sqlite3_free(P),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,_,P){let F;_?(d.isPtr(_)?F=_:_ instanceof ArrayBuffer&&(_=new Uint8Array(_)),_ instanceof Uint8Array?(F=d.allocFromTypedArray(_),(arguments.length<4||!v.isInt32(P)||P<0)&&(P=_.byteLength)):C.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")):F=0,(!v.isInt32(P)||P<0)&&(d.dealloc(F),C.toss("Invalid 4th argument for sqlite3_js_vfs_create_file()."));try{const ne=d.sqlite3_wasm_vfs_create_file(f,p,F,P);ne&&C.toss("Creation of file failed with sqlite3 result code",u.sqlite3_js_rc_str(ne))}finally{d.dealloc(F)}},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 P=f(p);return P.stores.forEach(F=>{const ne=[];let re;for(re=0;reF.removeItem(se)),_+=ne.length}),_},u.sqlite3_js_kvvfs_size=function(p=""){let _=0;const P=f(p);return P.stores.forEach(F=>{let ne;for(ne=0;neb(f,p,"sqlite3_preupdate_new"),u.sqlite3_preupdate_old_js=(f,p)=>b(f,p,"sqlite3_preupdate_old"),u.sqlite3changeset_new_js=(f,p)=>b(f,p,"sqlite3changeset_new"),u.sqlite3changeset_old_js=(f,p)=>b(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(F=>{throw console.error("an async sqlite3 initializer failed:",F),F}));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 A=d.memory&&d.heapSize===d.memory.buffer.byteLength?d:N();switch(g){case Int8Array:return A.HEAP8;case Uint8Array:return A.HEAP8U;case Int16Array:return A.HEAP16;case Uint16Array:return A.HEAP16U;case Int32Array:return A.HEAP32;case Uint32Array:return A.HEAP32U;case 8:return v?A.HEAP8U:A.HEAP8;case 16:return v?A.HEAP16U:A.HEAP16;case 32:return v?A.HEAP32U:A.HEAP32;case 64:if(A.HEAP64)return v?A.HEAP64U:A.HEAP64;break;default:if(i.bigIntEnabled){if(g===self.BigUint64Array)return A.HEAP64U;if(g===self.BigInt64Array)return A.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=A;A=v,v=f}const b=g._.sigParams(A),w=[1,96];g._.uleb128Encode(w,"push",b.length);for(const f of b)g._.pushSigType(w,f);return A[0]==="v"?w.push(0):(w.push(1),g._.pushSigType(w,A[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,A,b){if(b&&!d.scopedAlloc.length&&l("No scopedAllocPush() scope is active."),typeof v=="string"){const _=A;A=v,v=_}(typeof A!="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),b&&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,A);w.set(p,_),b&&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,A=i.functionTable();v.push(g);const b=A.get(g);return A.set(g,null),b},i.peek=function(v,A="i8"){A.endsWith("*")&&(A=a);const b=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()),A){case"i1":case"i8":f=b.HEAP8[v>>0];break;case"i16":f=b.HEAP16[v>>1];break;case"i32":f=b.HEAP32[v>>2];break;case"float":case"f32":f=b.HEAP32F[v>>2];break;case"double":case"f64":f=Number(b.HEAP64F[v>>3]);break;case"i64":if(i.bigIntEnabled){f=BigInt(b.HEAP64[v>>3]);break}default:l("Invalid type for peek():",A)}w&&w.push(f)}while(w&&arguments[0].length);return w||f},i.poke=function(g,v,A="i8"){A.endsWith("*")&&(A=a);const b=d.memory&&d.heapSize===d.memory.buffer.byteLength?d:N();for(const w of Array.isArray(g)?g:[g])switch(A){case"i1":case"i8":b.HEAP8[w>>0]=v;continue;case"i16":b.HEAP16[w>>1]=v;continue;case"i32":b.HEAP32[w>>2]=v;continue;case"float":case"f32":b.HEAP32F[w>>2]=v;continue;case"double":case"f64":b.HEAP64F[w>>3]=v;continue;case"i64":if(b.HEAP64){b.HEAP64[w>>3]=BigInt(v);continue}default:l("Invalid type for poke(): "+A)}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 A=g;for(;v[A]!==0;++A);return A-g};const C=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,V=function(g,v,A){return d.utf8Decoder.decode(g.buffer instanceof C?g.slice(v,A):g.subarray(v,A))};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 A=0;for(let b=0;b=55296&&w<=57343&&(w=65536+((w&1023)<<10)|g.charCodeAt(++b)&1023),w<=127?++A:w<=2047?A+=2:w<=65535?A+=3:A+=4}return A},i.jstrcpy=function(g,v,A=0,b=-1,w=!0){if((!v||!(v instanceof Int8Array)&&!(v instanceof Uint8Array))&&l("jstrcpy() target must be an Int8Array or Uint8Array."),b<0&&(b=v.length-A),!(b>0)||!(A>=0))return 0;let f=0,p=g.length;const _=A,P=A+b-(w?1:0);for(;f=55296&&F<=57343&&(F=65536+((F&1023)<<10)|g.charCodeAt(++f)&1023),F<=127){if(A>=P)break;v[A++]=F}else if(F<=2047){if(A+1>=P)break;v[A++]=192|F>>6,v[A++]=128|F&63}else if(F<=65535){if(A+2>=P)break;v[A++]=224|F>>12,v[A++]=128|F>>6&63,v[A++]=128|F&63}else{if(A+3>=P)break;v[A++]=240|F>>18,v[A++]=128|F>>12&63,v[A++]=128|F>>6&63,v[A++]=128|F&63}}return w&&(v[A++]=0),A-_},i.cstrncpy=function(g,v,A){if((!g||!v)&&l("cstrncpy() does not accept NULL strings."),A<0)A=i.cstrlen(strPtr)+1;else if(!(A>0))return 0;const b=i.heap8u();let w=0,f;for(;wd.utf8Encoder.encode(v?g+"\0":g);const K=(g,v)=>{(!(g.alloc instanceof Function)||!(g.dealloc instanceof Function))&&l("Object is missing alloc() and/or dealloc() function(s)","required by",v+"().")},te=function(g,v,A,b){if(K(i,b),typeof g!="string")return null;{const w=d.utf8Encoder.encode(g),f=A(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)=>te(g,v,i.alloc,"allocCString()"),i.scopedAllocPush=function(){K(i,"scopedAllocPush");const g=[];return d.scopedAlloc.push(g),g},i.scopedAllocPop=function(g){K(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 A;A=g.pop();)i.functionEntry(A)?i.uninstallFunction(A):i.dealloc(A)},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)=>te(g,v,i.scopedAlloc,"scopedAllocCString()");const k=function(g,v){const A=i[g?"scopedAlloc":"alloc"]((v.length+1)*i.ptrSizeof);let b=0;return v.forEach(w=>{i.pokePtr(A+i.ptrSizeof*b++,i[g?"scopedAllocCString":"allocCString"](""+w))}),i.pokePtr(A+i.ptrSizeof*b,0),A};i.scopedAllocMainArgv=g=>k(!0,g),i.allocMainArgv=g=>k(!1,g),i.cArgvToJs=(g,v)=>{const A=[];for(let b=0;bm(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 A=i.xGet(g);return A instanceof Function||l("Exported symbol",g,"is not a function."),A.length!==v.length&&y(g,A.length),arguments.length===2&&Array.isArray(arguments[1])?A.apply(null,arguments[1]):A.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 q=a==="i32"?g=>g|0:g=>BigInt(g)|BigInt(0);x.set("i32",q).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("**",q).set("*",q),E.set("*",q).set("pointer",q).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 A of g)x.set(A+"*",v),E.set(A+"*",v),E.set(A,x.get(A)||l("Missing arg converter:",A))}const W=function(g){return typeof g=="string"?i.scopedAllocCString(g):g?q(g):null};x.set("string",W).set("utf8",W).set("pointer",W),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,A){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,A){return this}contextMap(v){const A=this.__cmap||(this.__cmap=new Map);let b=A.get(v);return b===void 0&&A.set(v,b=[]),b}convertArg(v,A,b){let w=this.singleton;if(!w&&this.isContext&&(w=this.contextMap(this.contextKey(A,b))),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(A,b),"@"+f,v),w){if(w[1]){z.debugFuncInstall&&z.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(A,b),"@"+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(A,b),"@"+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+".")}},ve(z,"warnOnUse",!1),ve(z,"debugFuncInstall",!1),ve(z,"debugOut",console.debug.bind(console)),ve(z,"bindScopes",["transient","context","singleton","permanent"]),z);const R=g=>x.get(g)||l("Argument adapter not found:",g),L=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?L(g)(v):void 0,d.xWrap.convertResultNoCheck=(g,v)=>g===null?v:g?E.get(g)(v):void 0,i.xWrap=function(g,v,...A){arguments.length===3&&Array.isArray(arguments[2])&&(A=arguments[2]),i.isPtr(g)&&(g=i.functionEntry(g)||l("Function pointer not found in WASM function table."));const b=g instanceof Function,w=b?g:i.xGet(g);if(b&&(g=w.name||"unnamed function"),A.length!==w.length&&y(g,w.length),v===null&&w.length===0)return w;v!=null&&L(v);for(const p of A)p instanceof M?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 P in p)p[P]=f.convertArgNoCheck(A[P],p[P],p,P);return f.convertResultNoCheck(v,w.apply(null,p))}finally{i.scopedAllocPop(_)}}};const ie=function(g,v,A,b,w,f){if(typeof A=="string"){if(v===1)return f.get(A);if(v===2){if(b)b instanceof Function||l(w,"requires a function argument.");else return delete f.get(A),g;return f.set(A,b),g}}l("Invalid arguments to",w)};return i.xWrap.resultAdapter=function g(v,A){return ie(g,arguments.length,v,A,"resultAdapter()",E)},i.xWrap.argAdapter=function g(v,A){return ie(g,arguments.length,v,A,"argAdapter()",x)},i.xWrap.FuncPtrAdapter=x.FuncPtrAdapter,i.xCallWrapped=function(g,v,A,...b){return Array.isArray(arguments[3])&&(b=arguments[3]),i.xWrap(g,v,A||[]).apply(null,b||[])},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(K){return V.malloc(K)||S("Allocation of",K,"bytes failed.")},C.dealloc=function(K){V.free(K)}}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||"",K=l.memberSuffix||"",te=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 J=function H(X){return arguments.length===0?H.__flags:(X<0?(delete H.__flags.getter,delete H.__flags.setter,delete H.__flags.alloc,delete H.__flags.dealloc):(H.__flags.getter=(1&X)!==0,H.__flags.setter=(2&X)!==0,H.__flags.alloc=(4&X)!==0,H.__flags.dealloc=(8&X)!==0),H._flags)};return Object.defineProperty(J,"__flags",{iterable:!1,writable:!1,value:Object.create(T)}),T||J(0),J},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}(),q=T=>T[1]==="(",W=T=>T==="P",M=T=>q(T)?"p":T[0],R=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)},L=m?()=>!0:()=>a("BigInt64Array is not available."),ie=function(T){switch(M(T)){case"p":case"P":case"s":{switch(y){case 4:return"getInt32";case 8:return L()&&"getBigInt64"}break}case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return L()&&"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 L()&&"setBigInt64"}break}case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return L()&&"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 L()&&k;case"p":case"P":case"s":switch(y){case 4:return Number;case 8:return L()&&k}break}a("Unhandled DataView set wrapper for signature:",T)},v=(T,J)=>T+"::"+J,A=function(T,J){return()=>a(v(T,J),"is read-only.")},b=new WeakMap,w="(pointer-is-external)",f=function(T,J,H){if(H||(H=b.get(J)),H){if(b.delete(J),Array.isArray(J.ondispose)){let X;for(;X=J.ondispose.shift();)try{X instanceof Function?X.call(J):X instanceof we?X.dispose():typeof X=="number"&&S(X)}catch(Ae){console.warn("ondispose() for",T.structName,"@",H,"threw. NOT propagating it.",Ae)}}else if(J.ondispose instanceof Function)try{J.ondispose()}catch(X){console.warn("ondispose() for",T.structName,"@",H,"threw. NOT propagating it.",X)}delete J.ondispose,T.debugFlags.__flags.dealloc&&C("debug.dealloc:",J[w]?"EXTERNAL":"",T.structName,"instance:",T.structInfo.sizeof,"bytes @"+H),J[w]||S(H)}},p=T=>({configurable:!1,writable:!1,iterable:!1,value:T}),_=function(T,J,H){let X=!H;H?Object.defineProperty(J,w,p(H)):(H=N(T.structInfo.sizeof),H||a("Allocation of",T.structName,"structure failed."));try{T.debugFlags.__flags.alloc&&C("debug.alloc:",X?"":"EXTERNAL",T.structName,"instance:",T.structInfo.sizeof,"bytes @"+H),X&&d().fill(0,H,H+T.structInfo.sizeof),b.set(J,H)}catch(Ae){throw f(T,J,H),Ae}},P=function(){const T=this.pointer;return T?new Uint8Array(d().slice(T,T+this.structInfo.sizeof)):null},ne=p(T=>V+T+K),re=function(T,J,H=!0){let X=T.members[J];if(!X&&(V||K)){for(const Ae of Object.values(T.members))if(Ae.key===J){X=Ae;break}!X&&H&&a(v(T.name,J),"is not a mapped struct member.")}return X},se=function T(J,H,X=!1){T._||(T._=Re=>Re.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i"));const Ae=re(J.structInfo,H,!0);return X?T._(Ae.signature):Ae.signature},fe={configurable:!1,enumerable:!1,get:function(){return b.get(this)},set:()=>a("Cannot assign the 'pointer' property of a struct.")},le=p(function(){const T=[];for(const J of Object.keys(this.structInfo.members))T.push(this.memberKey(J));return T}),be=new TextDecoder("utf-8"),Ve=new TextEncoder,dt=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,en=function(T,J,H){return be.decode(T.buffer instanceof dt?T.slice(J,H):T.subarray(J,H))},I=function(T,J,H=!1){const X=re(T.structInfo,J,H);return X&&X.signature.length===1&&X.signature[0]==="s"?X:!1},B=function(T){T.signature!=="s"&&a("Invalid member type signature for C-string value:",JSON.stringify(T))},Q=function(J,H){const X=re(J.structInfo,H,!0);B(X);const Ae=J[X.key];if(!Ae)return null;let Re=Ae;const Ce=d();for(;Ce[Re]!==0;++Re);return Ae===Re?"":en(Ce,Ae,Re)},Z=function(T,...J){T.ondispose?Array.isArray(T.ondispose)||(T.ondispose=[T.ondispose]):T.ondispose=[],T.ondispose.push(...J)},$=function(T){const J=Ve.encode(T),H=N(J.length+1);H||a("Allocation error while duplicating string:",T);const X=d();return X.set(J,H),X[H+J.length]=0,H},qe=function(T,J,H){const X=re(T.structInfo,J,!0);B(X);const Ae=$(H);return T[X.key]=Ae,Z(T,Ae),T},we=function(J,H){arguments[2]!==p&&a("Do not call the StructType constructor","from client-level code."),Object.defineProperties(this,{structName:p(J),structInfo:p(H)})};we.prototype=Object.create(null,{dispose:p(function(){f(this.constructor,this)}),lookupMember:p(function(T,J=!0){return re(this.structInfo,T,J)}),memberToJsString:p(function(T){return Q(this,T)}),memberIsString:p(function(T,J=!0){return I(this,T,J)}),memberKey:ne,memberKeys:le,memberSignature:p(function(T,J=!1){return se(this,T,J)}),memoryDump:p(P),pointer:fe,setMemberCString:p(function(T,J){return qe(this,T,J)})}),Object.assign(we.prototype,{addOnDispose:function(...T){return Z(this,...T),this}}),Object.defineProperties(we,{allocCString:p($),isA:p(T=>T instanceof we),hasExternalPointer:p(T=>T instanceof we&&!!T[w]),memberKey:ne});const ee=T=>Number.isFinite(T)||T instanceof(k||Number),Lt=function T(J,H,X){if(!T._){T._={getters:{},setters:{},sw:{}};const gt=["i","c","C","p","P","s","f","d","v()"];te&>.push("j"),gt.forEach(function(tn){T._.getters[tn]=ie(tn),T._.setters[tn]=z(tn),T._.sw[tn]=g(tn)});const bd=/^[ipPsjfdcC]$/,qd=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/;T.sigCheck=function(tn,Nd,Ha,bo){Object.prototype.hasOwnProperty.call(tn,Ha)&&a(tn.structName,"already has a property named",Ha+"."),bd.test(bo)||qd.test(bo)||a("Malformed signature for",v(tn.structName,Nd)+":",bo)}}const Ae=J.memberKey(H);T.sigCheck(J.prototype,H,Ae,X.signature),X.key=Ae,X.name=H;const Re=M(X.signature),Ce=v(J.prototype.structName,Ae),ze=J.prototype.debugFlags.__flags,Pr=Object.create(null);Pr.configurable=!1,Pr.enumerable=!1,Pr.get=function(){ze.getter&&C("debug.getter:",T._.getters[Re],"for",R(Re),Ce,"@",this.pointer,"+",X.offset,"sz",X.sizeof);let gt=new DataView(d().buffer,this.pointer+X.offset,X.sizeof)[T._.getters[Re]](0,E);return ze.getter&&C("debug.getter:",Ce,"result =",gt),gt},X.readOnly?Pr.set=A(J.prototype.structName,Ae):Pr.set=function(gt){if(ze.setter&&C("debug.setter:",T._.setters[Re],"for",R(Re),Ce,"@",this.pointer,"+",X.offset,"sz",X.sizeof,gt),this.pointer||a("Cannot set struct property on disposed instance."),gt===null)gt=0;else for(;!ee(gt);){if(W(X.signature)&> instanceof we){gt=gt.pointer||0,ze.setter&&C("debug.setter:",Ce,"resolved to",gt);break}a("Invalid value for pointer-type",Ce+".")}new DataView(d().buffer,this.pointer+X.offset,X.sizeof)[T._.setters[Re]](0,T._.sw[Re](gt),E)},Object.defineProperty(J.prototype,Ae,Pr)},ot=function T(J,H){arguments.length===1?(H=J,J=H.name):H.name||(H.name=J),J||a("Struct name is required.");let X=!1;Object.keys(H.members).forEach(Ce=>{const ze=H.members[Ce];ze.sizeof?ze.sizeof===1?ze.signature==="c"||ze.signature==="C"||a("Unexpected sizeof==1 member",v(H.name,Ce),"with signature",ze.signature):(ze.sizeof%4!==0&&(console.warn("Invalid struct member description =",ze,"from",H),a(J,"member",Ce,"sizeof is not aligned. sizeof="+ze.sizeof)),ze.offset%4!==0&&(console.warn("Invalid struct member description =",ze,"from",H),a(J,"member",Ce,"offset is not aligned. offset="+ze.offset))):a(J,"member",Ce,"is missing sizeof."),(!X||X.offsetCe instanceof Re),memberKey:ne,memberKeys:le,methodInfoForKey:p(function(Ce){}),structInfo:p(H),structName:p(J)}),Re.prototype=new we(J,H,p),Object.defineProperties(Re.prototype,{debugFlags:Ae,constructor:p(Re)}),Object.keys(H.members).forEach(Ce=>Lt(Re,Ce,H.members[Ce])),Re};return ot.StructType=we,ot.config=l,ot.allocCString=$,ot.debugFlags||(ot.debugFlags=u.__makeDebugFlags(u.debugFlags)),ot},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,q)=>{try{const W=u.cArgvToJs(x,E);return m||(m=u.cArgvToJs(x,q)),k(W,m)|0}catch(W){return W.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,q,W)=>{try{return x=x&&u.cstrToJs(x),E=E&&u.cstrToJs(E),q=q&&u.cstrToJs(q),W=W&&u.cstrToJs(W),k(m,y,x,E,q,W)||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,q,W,M)=>{k(m,y,x,u.cstrToJs(E),u.cstrToJs(q),W,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,q)=>{k(m,y,u.cstrToJs(x),u.cstrToJs(E),q)}}),"*"]],["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",q=>k(d.flexibleString(q))),u.xWrap.argAdapter("string:static",(function(q){return u.isPtr(q)?q:(q=""+q,this[q]||(this[q]=u.allocCString(q)))}).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*",q=>{var W;return m(q instanceof(((W=i==null?void 0:i.oo1)==null?void 0:W.Stmt)||y)?q.pointer:q)})("sqlite3*",q=>{var W;return m(q instanceof(((W=i==null?void 0:i.oo1)==null?void 0:W.DB)||y)?q.pointer:q)})("sqlite3_index_info*",q=>m(q instanceof(a.sqlite3_index_info||y)?q.pointer:q))("sqlite3_module*",q=>m(q instanceof(a.sqlite3_module||y)?q.pointer:q))("sqlite3_vfs*",q=>typeof q=="string"?a.sqlite3_vfs_find(q)||i.SQLite3Error.toss(a.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",q):m(q instanceof(a.sqlite3_vfs||y)?q.pointer:q));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 q of u.bindingSignatures)a[q[0]]=u.xWrap.apply(null,q);for(const q of u.bindingSignatures.wasm)u[q[0]]=u.xWrap.apply(null,q);const E=function(q){return()=>l(q+"() is unavailable due to lack","of BigInt support in this build.")};for(const q of u.bindingSignatures.int64)a[q[0]]=u.bigIntEnabled?u.xWrap.apply(null,q):E(q[0]);if(delete u.bindingSignatures,u.exports.sqlite3_wasm_db_error){const q=u.xWrap("sqlite3_wasm_db_error","int","sqlite3*","int","string");d.sqlite3_wasm_db_error=function(W,M,R){return M instanceof i.WasmAllocError?(M=a.SQLITE_NOMEM,R=0):M instanceof Error&&(R=R||""+M,M=M.resultCode||a.SQLITE_ERROR),W?q(W,M,R):M}}else d.sqlite3_wasm_db_error=function(q,W,M){return console.warn("sqlite3_wasm_db_error() is not exported.",arguments),W}}{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 q of Object.entries(u.ctype[E]))a[q[0]]=q[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 q of Object.entries(u.ctype[E]))y[q[1]]=q[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,K=(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}));K.addCollation=function(k,m){const y=K(k,1);y.collation||(y.collation=new Set),y.collation.add(V(m).toLowerCase())},K._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)},K.addFunction=function(k,m,y){const x=K(k,1);x.udf||(x.udf=new Map),this._addUDF(k,m,y,x.udf)},K.addWindowFunc=function(k,m,y){const x=K(k,1);x.wudf||(x.wudf=new Map),this._addUDF(k,m,y,x.wudf)},K.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 q=u.exports[E];m.length=q.length;try{a[E](...m)}catch(W){console.warn("close-time call of",E+"(",m,") threw:",W)}}const y=K(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 q=x?a.sqlite3_create_window_function:a.sqlite3_create_function_v2;for(const W of E){const M=W[0],R=W[1],L=[k,M,0,a.SQLITE_UTF8,0,0,0,0,0];x&&L.push(0);for(const ie of R)try{L[2]=ie,q.apply(null,L)}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{K.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,q,W,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 R=m(y,x,E,q,W,M);return R===0&&W instanceof Function&&K.addCollation(y,x),R}catch(R){return d.sqlite3_wasm_db_error(y,R)}},a.sqlite3_create_collation=(y,x,E,q,W)=>arguments.length===5?a.sqlite3_create_collation_v2(y,x,E,q,W,0):N(y,"sqlite3_create_collation",5)}{const k=function(E,q){return E[0]+":"+(E[2]<0?-1:E[2])+":"+q+":"+u.cstrToJs(E[1]).toLowerCase()},m=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:k,callProxy:E=>(q,W,M)=>{try{E(q,...a.sqlite3_values_to_js(W,M))}catch(R){a.sqlite3_result_error_js(q,R)}}},xFinalAndValue:{signature:"v(p)",contextKey:k,callProxy:E=>q=>{try{a.sqlite3_result_js(q,E(q))}catch(W){a.sqlite3_result_error_js(q,W)}}},xFunc:{signature:"v(pip)",contextKey:k,callProxy:E=>(q,W,M)=>{try{a.sqlite3_result_js(q,E(q,...a.sqlite3_values_to_js(W,M)))}catch(R){a.sqlite3_result_error_js(q,R)}}},xDestroy:{signature:"v(p)",contextKey:k,callProxy:E=>q=>{try{E(q)}catch(W){console.error("UDF xDestroy method threw:",W)}}}}),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(q,W,M,R,L,ie,z,g,v){if(E.length!==arguments.length)return N(q,"sqlite3_create_function_v2",E.length);if(!(R&15))R|=a.SQLITE_UTF8;else if(a.SQLITE_UTF8!==(R&15))return S(q);try{const A=y(q,W,M,R,L,ie,z,g,v);return A===0&&(ie instanceof Function||z instanceof Function||g instanceof Function||v instanceof Function)&&K.addFunction(q,W,M),A}catch(A){return console.error("sqlite3_create_function_v2() setup threw:",A),d.sqlite3_wasm_db_error(q,A,"Creation of UDF threw: "+A)}},a.sqlite3_create_function=function E(q,W,M,R,L,ie,z,g){return E.length===arguments.length?a.sqlite3_create_function_v2(q,W,M,R,L,ie,z,g,0):N(q,"sqlite3_create_function",E.length)},a.sqlite3_create_window_function=function E(q,W,M,R,L,ie,z,g,v,A){if(E.length!==arguments.length)return N(q,"sqlite3_create_window_function",E.length);if(!(R&15))R|=a.SQLITE_UTF8;else if(a.SQLITE_UTF8!==(R&15))return S(q);try{const b=x(q,W,M,R,L,ie,z,g,v,A);return b===0&&(ie instanceof Function||z instanceof Function||g instanceof Function||v instanceof Function||A instanceof Function)&&K.addWindowFunc(q,W,M),b}catch(b){return console.error("sqlite3_create_window_function() setup threw:",b),d.sqlite3_wasm_db_error(q,b,"Creation of UDF threw: "+b)}},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,q,W,M,R){if(y.length!==arguments.length)return N(x,"sqlite3_prepare_v3",y.length);const[L,ie]=k(E,q);switch(typeof L){case"string":return m.basic(x,L,ie,W,M,null);case"number":return m.full(x,L,ie,W,M,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,q,W,M){return y.length===arguments.length?a.sqlite3_prepare_v3(x,E,q,0,W,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,q,W,M){if(y.length!==arguments.length)return N(a.sqlite3_db_handle(x),"sqlite3_bind_text",y.length);if(u.isPtr(q)||q===null)return k(x,E,q,W,M);q instanceof ArrayBuffer?q=new Uint8Array(q):Array.isArray(pMem)&&(q=pMem.join(""));let R,L;try{if(d.isSQLableTypedArray(q))R=u.allocFromTypedArray(q),L=q.byteLength;else if(typeof q=="string")[R,L]=u.allocCString(q);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,L,a.SQLITE_WASM_DEALLOC)}catch(ie){return u.dealloc(R),d.sqlite3_wasm_db_error(a.sqlite3_db_handle(x),ie)}},a.sqlite3_bind_blob=function y(x,E,q,W,M){if(y.length!==arguments.length)return N(a.sqlite3_db_handle(x),"sqlite3_bind_blob",y.length);if(u.isPtr(q)||q===null)return m(x,E,q,W,M);q instanceof ArrayBuffer?q=new Uint8Array(q):Array.isArray(q)&&(q=q.join(""));let R,L;try{if(d.isBindableTypedArray(q))R=u.allocFromTypedArray(q),L=W>=0?W:q.byteLength;else if(typeof q=="string")[R,L]=u.allocCString(q);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,L,a.SQLITE_WASM_DEALLOC)}catch(ie){return u.dealloc(R),d.sqlite3_wasm_db_error(a.sqlite3_db_handle(x),ie)}}}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 te=a.sqlite3_vfs_find("kvvfs");if(te)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=q=>u.peek(q)===115?sessionStorage:localStorage,E={xRead:(q,W,M,R)=>{const L=y.pointer,ie=u.scopedAllocPush();try{const z=m(q,W);if(!z)return-3;const g=u.cstrToJs(z),v=x(q).getItem(g);if(!v)return-1;const A=v.length;if(R<=0)return A;if(R===1)return u.poke(M,0),A;const b=u.scopedAllocCString(v);return R>A+1&&(R=A+1),u.heap8u().copyWithin(M,b,b+R-1),u.poke(M+R-1,0),R-1}catch(z){return console.error("kvstorageRead()",z),-2}finally{y.restore(L),u.scopedAllocPop(ie)}},xWrite:(q,W,M)=>{const R=y.pointer;try{const L=m(q,W);if(!L)return 1;const ie=u.cstrToJs(L);return x(q).setItem(ie,u.cstrToJs(M)),0}catch(L){return console.error("kvstorageWrite()",L),a.SQLITE_IOERR}finally{y.restore(R)}},xDelete:(q,W)=>{const M=y.pointer;try{const R=m(q,W);return R?(x(q).removeItem(u.cstrToJs(R)),0):1}catch(R){return console.error("kvstorageDelete()",R),a.SQLITE_IOERR}finally{y.restore(M)}}};for(const q of Object.keys(E))k[k.memberKey(q)]=u.installFunction(k.memberSignature(q),E[q])}else a.sqlite3_vfs_unregister(te);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=(...b)=>{throw new i.SQLite3Error(...b)},a=i.capi,u=i.wasm,d=i.util,N=new WeakMap,S=new WeakMap,C=(b,w,f)=>{const p=Object.getOwnPropertyDescriptor(b,w);return p?p.value:f},V=function(b,w){return w&&(b instanceof m&&(b=b.pointer),l("sqlite3 result code",w+":",b?a.sqlite3_errmsg(b):a.sqlite3_errstr(w))),arguments[0]},K=u.installFunction("i(ippp)",(function(b,w,f,p){a.SQLITE_TRACE_STMT===b&&console.log("SQL TRACE #"+ ++this.counter+" via sqlite3@"+w+":",u.cstrToJs(p))}).bind({counter:0})),te=Object.create(null),k=function b(...w){if(!b._name2vfs){b._name2vfs=Object.create(null);const le=typeof importScripts=="function"?be=>l("The VFS for",be,"is only available in the main window thread."):!1;b._name2vfs[":localStorage:"]={vfs:"kvvfs",filename:le||(()=>"local")},b._name2vfs[":sessionStorage:"]={vfs:"kvvfs",filename:le||(()=>"session")}}const f=b.normalizeArgs(...w);let p=f.filename,_=f.vfs,P=f.flags;(typeof p!="string"&&typeof p!="number"||typeof P!="string"||_&&typeof _!="string"&&typeof _!="number")&&(i.config.error("Invalid DB ctor args",f,arguments),l("Invalid arguments for DB constructor."));let F=typeof p=="number"?u.cstrToJs(p):p;const ne=b._name2vfs[F];ne&&(_=ne.vfs,p=F=ne.filename(F));let re,se=0;P.indexOf("c")>=0&&(se|=a.SQLITE_OPEN_CREATE|a.SQLITE_OPEN_READWRITE),P.indexOf("w")>=0&&(se|=a.SQLITE_OPEN_READWRITE),se===0&&(se|=a.SQLITE_OPEN_READONLY),se|=a.SQLITE_OPEN_EXRESCODE;const fe=u.pstack.pointer;try{const le=u.pstack.allocPtr();let be=a.sqlite3_open_v2(p,le,se,_||0);re=u.peekPtr(le),V(re,be),a.sqlite3_extended_result_codes(re,1),P.indexOf("t")>=0&&a.sqlite3_trace_v2(re,a.SQLITE_TRACE_STMT,K,re)}catch(le){throw re&&a.sqlite3_close_v2(re),le}finally{u.pstack.restore(fe)}this.filename=F,N.set(this,re),S.set(this,Object.create(null));try{const le=a.sqlite3_js_db_vfs(re);le||l("Internal error: cannot get VFS for new db handle.");const be=te[le];be instanceof Function?be(this,i):be&&V(re,a.sqlite3_exec(re,be,0,0,0))}catch(le){throw this.close(),le}};k.setVfsPostOpenSql=function(b,w){te[b]=w},k.normalizeArgs=function(b=":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=b,p.flags=w,p.vfs=f),p};const m=function(...b){k.apply(this,b)};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(b){return b.pointer||l("DB has been closed."),b},q=function(b,w){return(w!==(w|0)||w<0||w>=b.columnCount)&&l("Column index",w,"is out of range."),b},W=function(b,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=()=>b;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=P=>{const F=P.get(Object.create(null))[_];return F===void 0?l(a.SQLITE_NOTFOUND,"exec(): unknown result column:",_):F};break}l("Invalid rowMode:",p.rowMode)}return f},M=(b,w,f,...p)=>{const _=b.prepare(w);try{return _.bind(f).step()?_.get(...p):void 0}finally{_.finalize()}},R=(b,w,f,p)=>b.exec({sql:w,bind:f,rowMode:p,returnValue:"resultRows"});m.checkRc=(b,w)=>V(b,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 b=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(b),this.onclose&&this.onclose.after instanceof Function)try{this.onclose.after(this)}catch{}delete this.filename}},changes:function(b=!1,w=!1){const f=E(this).pointer;return b?w?a.sqlite3_total_changes64(f):a.sqlite3_total_changes(f):w?a.sqlite3_changes64(f):a.sqlite3_changes(f)},dbFilename:function(b="main"){return a.sqlite3_db_filename(E(this).pointer,b)},dbName:function(b=0){return a.sqlite3_db_name(E(this).pointer,b)},dbVfsName:function(b=0){let w;const f=a.sqlite3_js_db_vfs(E(this).pointer,b);if(f){const p=new a.sqlite3_vfs(f);try{w=u.cstrToJs(p.$zName)}finally{p.dispose()}}return w},prepare:function(b){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,b,-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 b=W(this,arguments);if(!b.sql)return l("exec() requires an SQL string.");const w=b.opt,f=w.callback,p=Array.isArray(w.resultRows)?w.resultRows:void 0;let _,P=w.bind,F=!!(b.cbArg||w.columnNames||p);const ne=u.scopedAllocPush(),re=Array.isArray(w.saveSql)?w.saveSql:void 0;try{const se=d.isSQLableTypedArray(b.sql);let fe=se?b.sql.byteLength:u.jstrlen(b.sql);const le=u.scopedAlloc(2*u.ptrSizeof+(fe+1)),be=le+u.ptrSizeof;let Ve=be+u.ptrSizeof;const dt=Ve+fe;for(se?u.heap8().set(b.sql,Ve):u.jstrcpy(b.sql,u.heap8(),Ve,fe,!1),u.poke(Ve+fe,0);Ve&&u.peek(Ve,"i8");){u.pokePtr([le,be],0),m.checkRc(this,a.sqlite3_prepare_v3(this.pointer,Ve,fe,0,le,be));const en=u.peekPtr(le);if(Ve=u.peekPtr(be),fe=dt-Ve,!!en){if(re&&re.push(a.sqlite3_sql(en).trim()),_=new x(this,en,y),P&&_.parameterCount&&(_.bind(P),P=null),F&&_.columnCount){if(F=!1,Array.isArray(w.columnNames)&&_.getColumnNames(w.columnNames),b.cbArg||p){for(;_.step();_._isLocked=!1){_._isLocked=!0;const I=b.cbArg(_);if(p&&p.push(I),f&&f.call(w,I,_)===!1)break}_._isLocked=!1}}else _.step();_.finalize(),_=null}}}finally{_&&(delete _._isLocked,_.finalize()),u.scopedAllocPop(ne)}return b.returnVal()},createFunction:function(w,f,p){const _=B=>B 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 P=p.xStep||0,F=p.xFinal||0;const ne=p.xValue||0,re=p.xInverse||0;let se;_(f)?(se=!1,(_(P)||_(F))&&l("Ambiguous arguments: scalar or aggregate?"),P=F=null):_(P)?(_(F)||l("Missing xFinal() callback for aggregate or window UDF."),f=null):_(F)?l("Missing xStep() callback for aggregate or window UDF."):l("Missing function-type properties."),se===!1?(_(ne)||_(re))&&l("xValue and xInverse are not permitted for non-window UDFs."):_(ne)?(_(re)||l("xInverse must be provided if xValue is."),se=!0):_(re)&&l("xValue must be provided if xInverse is.");const fe=p.pApp;fe!=null&&(typeof fe!="number"||!d.isInt32(fe))&&l("Invalid value for pApp property. Must be a legal WASM pointer value.");const le=p.xDestroy||0;le&&!_(le)&&l("xDestroy property must be a function.");let be=0;C(p,"deterministic")&&(be|=a.SQLITE_DETERMINISTIC),C(p,"directOnly")&&(be|=a.SQLITE_DIRECTONLY),C(p,"innocuous")&&(be|=a.SQLITE_INNOCUOUS),w=w.toLowerCase();const Ve=f||P,dt=C(p,"arity"),en=typeof dt=="number"?dt:Ve.length?Ve.length-1:0;let I;return se?I=a.sqlite3_create_window_function(this.pointer,w,en,a.SQLITE_UTF8|be,fe||0,P,F,ne,re,le):I=a.sqlite3_create_function_v2(this.pointer,w,en,a.SQLITE_UTF8|be,fe||0,f,P,F,le),m.checkRc(this,I),this},selectValue:function(b,w,f){return M(this,b,w,0,f)},selectValues:function(b,w,f){const p=this.prepare(b),_=[];try{for(p.bind(w);p.step();)_.push(p.get(0,f))}finally{p.finalize()}return _},selectArray:function(b,w){return M(this,b,w,[])},selectObject:function(b,w){return M(this,b,w,{})},selectArrays:function(b,w){return R(this,b,w,"array")},selectObjects:function(b,w){return R(this,b,w,"object")},openStatementCount:function(){return this.pointer?Object.keys(S.get(this)).length:0},transaction:function(b){let w="BEGIN";arguments.length>1&&(/[^a-zA-Z]/.test(arguments[0])&&l(a.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier."),w+=" "+arguments[0],b=arguments[1]),E(this).exec(w);try{const f=b(this);return this.exec("COMMIT"),f}catch(f){throw this.exec("ROLLBACK"),f}},savepoint:function(b){E(this).exec("SAVEPOINT oo1");try{const w=b(this);return this.exec("RELEASE oo1"),w}catch(w){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),w}},checkRc:function(b){return m.checkRc(this,b)}};const L=function(b){return b.pointer||l("Stmt has been closed."),b},ie=function(b){let w=y[b==null?"null":typeof b];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(b)?y.blob:void 0}},z=function(b){return ie(b)||l("Unsupported bind() argument type:",typeof b)},g=function(b,w){const f=typeof w=="number"?w:a.sqlite3_bind_parameter_index(b.pointer,w);return f===0||!d.isInt32(f)?l("Invalid bind() parameter name: "+w):(f<1||f>b.parameterCount)&&l("Bind index",w,"is out of range."),f},v=function(b,w){return b._isLocked&&l("Operation is illegal when statement is locked:",w),b},A=function b(w,f,p,_){v(L(w),"bind()"),b._||(b._tooBigInt=F=>l("BigInt value is too big to store without precision loss:",F),b._={string:function(F,ne,re,se){const[fe,le]=u.allocCString(re,!0);return(se?a.sqlite3_bind_blob:a.sqlite3_bind_text)(F.pointer,ne,fe,le,a.SQLITE_WASM_DEALLOC)}}),z(_),f=g(w,f);let P=0;switch(_==null?y.null:p){case y.null:P=a.sqlite3_bind_null(w.pointer,f);break;case y.string:P=b._.string(w,f,_,!1);break;case y.number:{let F;d.isInt32(_)?F=a.sqlite3_bind_int:typeof _=="bigint"?d.bigIntFits64(_)?u.bigIntEnabled?F=a.sqlite3_bind_int64:d.bigIntFitsDouble(_)?(_=Number(_),F=a.sqlite3_bind_double):b._tooBigInt(_):b._tooBigInt(_):(_=Number(_),u.bigIntEnabled&&Number.isInteger(_)?F=a.sqlite3_bind_int64:F=a.sqlite3_bind_double),P=F(w.pointer,f,_);break}case y.boolean:P=a.sqlite3_bind_int(w.pointer,f,_?1:0);break;case y.blob:{if(typeof _=="string"){P=b._.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 F=u.alloc(_.byteLength||1);u.heap8().set(_.byteLength?_:[0],F),P=a.sqlite3_bind_blob(w.pointer,f,F,_.byteLength,a.SQLITE_WASM_DEALLOC);break}default:i.config.warn("Unsupported bind() argument type:",_),l("Unsupported bind() argument type: "+typeof _)}return P&&m.checkRc(w.db.pointer,P),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(L(this),"clearBindings()"),a.sqlite3_clear_bindings(this.pointer),this._mayGet=!1,this},reset:function(b){return v(this,"reset()"),b&&this.clearBindings(),a.sqlite3_reset(L(this).pointer),this._mayGet=!1,this},bind:function(){L(this);let b,w;switch(arguments.length){case 1:b=1,w=arguments[0];break;case 2:b=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?A(this,b,y.null,w):Array.isArray(w)?(arguments.length!==1&&l("When binding an array, an index argument is not permitted."),w.forEach((f,p)=>A(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=>A(this,f,z(w[f]),w[f])),this):A(this,b,z(w),w)))},bindAsBlob:function(b,w){L(this),arguments.length===1&&(w=b,b=1);const f=z(w);return y.string!==f&&y.blob!==f&&y.null!==f&&l("Invalid value type for bindAsBlob()"),A(this,b,y.blob,w)},step:function(){v(this,"step()");const b=a.sqlite3_step(L(this).pointer);switch(b){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=",b,a.sqlite3_js_rc_str(b),"SQL =",a.sqlite3_sql(this.pointer)),m.checkRc(this.db.pointer,b)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){const b=this.step();return this.finalize(),b},get:function(b,w){if(L(this)._mayGet||l("Stmt.step() has not (recently) returned true."),Array.isArray(b)){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,b);return(f>Number.MAX_SAFE_INTEGER||fl("The pointer property is read-only.")};Object.defineProperty(x.prototype,"pointer",b),Object.defineProperty(m.prototype,"pointer",b)}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 b=i.oo1.JsStorageDb;b.prototype=Object.create(m.prototype),b.clearStorage=a.sqlite3_js_kvvfs_clear,b.prototype.clearStorage=function(){return b.clearStorage(E(this).filename)},b.storageSize=a.sqlite3_js_kvvfs_size,b.prototype.storageSize=function(){return b.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 q=this.dbList.indexOf(m);q>=0&&this.dbList.splice(q,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])},K=function(m){const y=/^file:.+(vfs=(\w+))/.exec(m);return a.capi.sqlite3_vfs_find(y?y[2]:0)},te=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 q,W;if(y.vfs=x.vfs,te(x.filename)?y.filename=x.filename||"":(y.filename=x.filename,q=x.byteArray,q&&(W=K(x.filename))),W){let R;try{R=a.wasm.allocFromTypedArray(q);const L=a.wasm.sqlite3_wasm_vfs_create_file(W,y.filename,R,q.byteLength);L&&a.SQLite3Error.toss(L)}catch(L){throw new a.SQLite3Error(L.name+" creating "+x.filename+": "+L.message,{cause:L})}finally{R&&a.wasm.dealloc(R)}}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 q=0;const W=!!y.columnNames;typeof E=="string"&&(W||(y.columnNames=[]),y.callback=function(M,R){N.post({type:E,columnNames:y.columnNames,rowNumber:++q,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 q=performance.now();try{k.hasOwnProperty(E)&&k[E]instanceof Function?y=await k[E](m):l("Unknown db worker message type:",m.type)}catch(W){E="error",y={operation:m.type,message:W.message,errorClass:W.name,input:m},W.stack&&(y.stack=typeof W.stack=="string"?W.stack.split(/\n\s*/):W.stack)}x||(x=y.dbId||V()),N.post({type:E,dbId:x,messageId:m.messageId,workerReceivedTime:q,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,q=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(L,ie)=>m(y,L,ie,q);m.argcProxy||(m.argcProxy=function(L,ie,z,g){return function(...v){return z.length!==arguments.length&&u("Argument mismatch for",L.structInfo.name+"::"+ie+": Native signature is:",g),z.apply(this,v)}},m.removeFuncList=function(){this.ondispose.__removeFuncList&&(this.ondispose.__removeFuncList.forEach((L,ie)=>{if(typeof L=="number")try{l.uninstallFunction(L)}catch{}}),delete this.ondispose.__removeFuncList)});const W=y.memberSignature(x);W.length<2&&u("Member",x,"does not have a function pointer signature:",W);const M=y.memberKey(x),R=q&&!l.isPtr(E)?m.argcProxy(y,M,E,W):E;if(l.isPtr(R))R&&!l.functionEntry(R)&&u("Pointer",R,"is not a WASM function table entry."),y[M]=R;else{const L=l.installFunction(R,y.memberSignature(x,!0));y[M]=L,(!y.ondispose||!y.ondispose.__removeFuncList)&&(y.addOnDispose("ondispose.__removeFuncList handler",m.removeFuncList),y.ondispose.__removeFuncList=[]),y.ondispose.__removeFuncList.push(M,L)}return(L,ie)=>m(y,L,ie,q)};V.installMethodArgcCheck=!1;const K=function(m,y,x=V.installMethodArgcCheck){const E=new Map;for(const q of Object.keys(y)){const W=y[q],M=E.get(W);if(M){const R=m.memberKey(q);m[R]=m[m.memberKey(M)]}else V(m,q,W,x),E.set(W,q)}return m};S.StructType.prototype.installMethod=function(y,x,E=V.installMethodArgcCheck){return arguments.length<3&&y&&typeof y=="object"?K(this,...arguments):V(this,...arguments)},S.StructType.prototype.installMethods=function(m,y=V.installMethodArgcCheck){return K(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 q=m[E];q&&(++y,K(q.struct,q.methods,!!q.applyArgcCheck),E==="vfs"&&(!q.struct.$zName&&typeof q.name=="string"&&q.struct.addOnDispose(q.struct.$zName=l.allocCString(q.name)),q.struct.registerVfs(!!q.asDefault)))}return y||u("Misuse: installVfs() options object requires at least","one of:",x),this};const te=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 q=this.get(x);return E&&this.delete(x),q}).bind(new Map)},k=function(m,y){const x=te(m,y);return Object.assign(Object.create(null),{StructType:y,create:E=>{const q=x();return l.pokePtr(E,q.pointer),q},get:E=>x(E),unget:E=>x(E,!0),dispose:E=>{const q=x(E,!0);q&&q.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 q;return x instanceof i.WasmAllocError?q=a.SQLITE_NOMEM:arguments.length>2?q=E:x instanceof i.SQLite3Error&&(q=x.resultCode),q||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 q of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){const W=q[0],M=q[1];E[W]===!0?E[W]=E[M]:E[M]===!0&&(E[M]=E[W])}if(m.catchExceptions){const q=function(R,L){return["xConnect","xCreate"].indexOf(R)>=0?function(ie,z,g,v,A,b){try{return L(...arguments)||0}catch(w){return w instanceof i.WasmAllocError||(l.dealloc(l.peekPtr(b)),l.pokePtr(b,l.allocCString(w.message))),N.xError(R,w)}}:function(...ie){try{return L(...ie)||0}catch(z){return N.xError(R,z)}}},W=["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 R of W){const L=E[R];if(L instanceof Function)R==="xConnect"&&E.xCreate===L?M[R]=E.xCreate:R==="xCreate"&&E.xConnect===L?M[R]=E.xConnect:M[R]=q(R,L);else continue}K(x,M,!1)}else K(x,E,!!m.applyArgcCheck);if(x.$iVersion===0){let q;typeof m.iVersion=="number"?q=m.iVersion:x.$xShadowName?q=3:x.$xSavePoint||x.$xRelease||x.$xRollbackTo?q=2:q=1,x.$iVersion=q}}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 K={0:i.config.error,1:i.config.warn,2:i.config.log},te=(I,...B)=>{u.verbose>I&&K[I]("OPFS syncer:",...B)},k=(...I)=>te(2,...I),m=(...I)=>te(1,...I),y=(...I)=>te(0,...I),x=i.util.toss,E=i.capi,q=i.wasm,W=E.sqlite3_vfs,M=E.sqlite3_file,R=E.sqlite3_io_methods,L=Object.create(null),ie=()=>{var I;return globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&((I=navigator==null?void 0:navigator.storage)==null?void 0:I.getDirectory)};L.metrics={dump:function(){let I,B=0,Q=0,Z=0;for(I in _.opIds){const $=P[I];B+=$.count,Q+=$.time,Z+=$.wait,$.avgTime=$.count&&$.time?$.time/$.count:0,$.avgWait=$.count&&$.wait?$.wait/$.count:0}i.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",P,` +Total of`,B,"op(s) for",Q,"ms (incl. "+Z+" ms of waiting on the async side)"),i.config.log("Serialization metrics:",P.s11n),w.postMessage({type:"opfs-async-metrics"})},reset:function(){let I;const B=Z=>Z.count=Z.time=Z.wait=0;for(I in _.opIds)B(P[I]=Object.create(null));let Q=P.s11n=Object.create(null);Q=Q.serialize=Object.create(null),Q.count=Q.time=0,Q=P.s11n.deserialize=Object.create(null),Q.count=Q.time=0}};const z=new W,g=new R;let v;const A=I=>(v=!0,z.dispose(),V(I)),b=I=>(v=!1,C(I)),w=new Worker(new URL(""+new URL("sqlite3-opfs-async-proxy-9f074d6f.js",self.location.href).href,self.location));setTimeout(()=>{v===void 0&&A(new Error("Timeout while waiting for OPFS async proxy worker."))},4e3),w._originalOnError=w.onerror,w.onerror=function(I){y("Error initializing OPFS asyncer:",I),A(new Error("Loading OPFS async Worker failed for unknown reasons."))};const f=E.sqlite3_vfs_find(null),p=f?new W(f):null;z.$iVersion=2,z.$szOsFile=E.sqlite3_file.structInfo.sizeof,z.$mxPathname=1024,z.$zName=q.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 I=new ArrayBuffer(2);return new DataView(I).setInt16(0,256,!0),new Int16Array(I)[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 P=Object.create(null);{let I=0;_.opIds.whichOp=I++,_.opIds.rc=I++,_.opIds.xAccess=I++,_.opIds.xClose=I++,_.opIds.xDelete=I++,_.opIds.xDeleteNoWait=I++,_.opIds.xFileSize=I++,_.opIds.xLock=I++,_.opIds.xOpen=I++,_.opIds.xRead=I++,_.opIds.xSleep=I++,_.opIds.xSync=I++,_.opIds.xTruncate=I++,_.opIds.xUnlock=I++,_.opIds.xWrite=I++,_.opIds.mkdir=I++,_.opIds["opfs-async-metrics"]=I++,_.opIds["opfs-async-shutdown"]=I++,_.opIds.retry=I++,_.sabOP=new SharedArrayBuffer(I*4),L.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(I=>{(_.sq3Codes[I]=E[I])===void 0&&x("Maintenance required: not found:",I)}),_.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,defaultUnlockAsap:!1});const F=(I,...B)=>{const Q=_.opIds[I]||x("Invalid op ID:",I);_.s11n.serialize(...B),Atomics.store(_.sabOPView,_.opIds.rc,-1),Atomics.store(_.sabOPView,_.opIds.whichOp,Q),Atomics.notify(_.sabOPView,_.opIds.whichOp);const Z=performance.now();Atomics.wait(_.sabOPView,_.opIds.rc,-1);const $=Atomics.load(_.sabOPView,_.opIds.rc);if(P[I].wait+=performance.now()-Z,$&&_.asyncS11nExceptions){const qe=_.s11n.deserialize();qe&&y(I+"() async error:",...qe)}return $};L.debug={asyncShutdown:()=>{m("Shutting down OPFS async listener. The OPFS VFS will no longer work."),F("opfs-async-shutdown")},asyncRestart:()=>{m("Attempting to restart OPFS VFS async listener. Might work, might not."),w.postMessage({type:"opfs-async-restart"})}};const ne=()=>{if(_.s11n)return _.s11n;const I=new TextDecoder,B=new TextEncoder("utf-8"),Q=new Uint8Array(_.sabIO,_.sabS11nOffset,_.sabS11nSize),Z=new DataView(_.sabIO,_.sabS11nOffset,_.sabS11nSize);_.s11n=Object.create(null);const $=Object.create(null);$.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},$.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},$.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},$.string={id:4};const qe=ee=>$[typeof ee]||x("Maintenance required: this value type cannot be serialized.",ee),we=ee=>{switch(ee){case $.number.id:return $.number;case $.bigint.id:return $.bigint;case $.boolean.id:return $.boolean;case $.string.id:return $.string;default:x("Invalid type ID:",ee)}};return _.s11n.deserialize=function(ee=!1){++P.s11n.deserialize.count;const Lt=performance.now(),ot=Q[0],T=ot?[]:null;if(ot){const J=[];let H=1,X,Ae,Re;for(X=0;X{fe.start=performance.now(),fe.op=I,++P[I].count},be=()=>P[fe.op].time+=performance.now()-fe.start,Ve={xCheckReservedLock:function(I,B){const Q=se[I];return q.poke(B,Q.lockType?1:0,"i32"),0},xClose:function(I){le("xClose");let B=0;const Q=se[I];return Q&&(delete se[I],B=F("xClose",I),Q.sq3File&&Q.sq3File.dispose()),be(),B},xDeviceCharacteristics:function(I){return E.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(I,B,Q){return E.SQLITE_NOTFOUND},xFileSize:function(I,B){le("xFileSize");let Q=F("xFileSize",I);if(Q==0)try{const Z=_.s11n.deserialize()[0];q.poke(B,Z,"i64")}catch(Z){y("Unexpected error reading xFileSize() result:",Z),Q=_.sq3Codes.SQLITE_IOERR}return be(),Q},xLock:function(I,B){le("xLock");const Q=se[I];let Z=0;return Q.lockType?Q.lockType=B:(Z=F("xLock",I,B),Z===0&&(Q.lockType=B)),be(),Z},xRead:function(I,B,Q,Z){le("xRead");const $=se[I];let qe;try{qe=F("xRead",I,Q,Number(Z)),(qe===0||E.SQLITE_IOERR_SHORT_READ===qe)&&q.heap8u().set($.sabView.subarray(0,Q),B)}catch(we){y("xRead(",arguments,") failed:",we,$),qe=E.SQLITE_IOERR_READ}return be(),qe},xSync:function(I,B){le("xSync"),++P.xSync.count;const Q=F("xSync",I,B);return be(),Q},xTruncate:function(I,B){le("xTruncate");const Q=F("xTruncate",I,Number(B));return be(),Q},xUnlock:function(I,B){le("xUnlock");const Q=se[I];let Z=0;return E.SQLITE_LOCK_NONE===B&&Q.lockType&&(Z=F("xUnlock",I,B)),Z===0&&(Q.lockType=B),be(),Z},xWrite:function(I,B,Q,Z){le("xWrite");const $=se[I];let qe;try{$.sabView.set(q.heap8u().subarray(B,B+Q)),qe=F("xWrite",I,Q,Number(Z))}catch(we){y("xWrite(",arguments,") failed:",we,$),qe=E.SQLITE_IOERR_WRITE}return be(),qe}},dt={xAccess:function(I,B,Q,Z){le("xAccess");const $=F("xAccess",q.cstrToJs(B));return q.poke(Z,$?0:1,"i32"),be(),0},xCurrentTime:function(I,B){return q.poke(B,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(I,B){return q.poke(B,24405875e-1*864e5+new Date().getTime(),"i64"),0},xDelete:function(I,B,Q){return le("xDelete"),F("xDelete",q.cstrToJs(B),Q,!1),be(),0},xFullPathname:function(I,B,Q,Z){return q.cstrncpy(Z,B,Q)!!Z):Q},L.getDirForFilename=async function(B,Q=!1){const Z=L.getResolvedPath(B,!0),$=Z.pop();let qe=L.rootDirectory;for(const we of Z)we&&(qe=await qe.getDirectoryHandle(we,{create:!!Q}));return[qe,$]},L.mkdir=async function(I){try{return await L.getDirForFilename(I+"/filepart",!0),!0}catch{return!1}},L.entryExists=async function(I){try{const[B,Q]=await L.getDirForFilename(I);return await B.getFileHandle(Q),!0}catch{return!1}},L.randomFilename=re,L.registerVfs=(I=!1)=>q.exports.sqlite3_vfs_register(z.pointer,I?1:0),L.treeList=async function(){const I=async function Q(Z,$){$.name=Z.name,$.dirs=[],$.files=[];for await(const qe of Z.values())if(qe.kind==="directory"){const we=Object.create(null);$.dirs.push(we),await Q(qe,we)}else $.files.push(qe.name)},B=Object.create(null);return await I(L.rootDirectory,B),B},L.rmfr=async function(){const I=L.rootDirectory,B={recurse:!0};for await(const Q of I.values())I.removeEntry(Q.name,B)},L.unlink=async function(I,B=!1,Q=!1){try{const[Z,$]=await L.getDirForFilename(I,!1);return await Z.removeEntry($,{recursive:B}),!0}catch(Z){if(Q)throw new Error("unlink(",arguments[0],") failed: "+Z.message,{cause:Z});return!1}},L.traverse=async function(I){const B={recursive:!0,directory:L.rootDirectory};typeof I=="function"&&(I={callback:I}),I=Object.assign(B,I||{}),async function Z($,qe){for await(const we of $.values()){if(I.callback(we,$,qe)===!1)return!1;if(I.recursive&&we.kind==="directory"&&await Z(we,qe+1)===!1)break}}(I.directory,0)},i.oo1){const I=function(...B){const Q=i.oo1.DB.dbCtorHelper.normalizeArgs(...B);Q.vfs=z.$zName,i.oo1.DB.dbCtorHelper.call(this,Q)};I.prototype=Object.create(i.oo1.DB.prototype),i.oo1.OpfsDb=I,i.oo1.DB.dbCtorHelper.setVfsPostOpenSql(z.pointer,function(B,Q){Q.capi.sqlite3_busy_timeout(B,1e4),Q.capi.sqlite3_exec(B,["pragma journal_mode=persist;","pragma cache_size=-16384;"],0,0,0)})}const en=function(){const I=q.scopedAllocPush(),B=new M;try{const Q=B.pointer,Z=E.SQLITE_OPEN_CREATE|E.SQLITE_OPEN_READWRITE|E.SQLITE_OPEN_MAIN_DB,$=q.scopedAlloc(8),qe="/sanity/check/file"+re(8),we=q.scopedAllocCString(qe);let ee;if(_.s11n.serialize("This is ä string."),ee=_.s11n.deserialize(),k("deserialize() says:",ee),ee[0]!=="This is ä string."&&x("String d13n error."),dt.xAccess(z.pointer,we,0,$),ee=q.peek($,"i32"),k("xAccess(",qe,") exists ?=",ee),ee=dt.xOpen(z.pointer,we,Q,Z,$),k("open rc =",ee,"state.sabOPView[xOpen] =",_.sabOPView[_.opIds.xOpen]),ee!==0){y("open failed with code",ee);return}dt.xAccess(z.pointer,we,0,$),ee=q.peek($,"i32"),ee||x("xAccess() failed to detect file."),ee=Ve.xSync(B.pointer,0),ee&&x("sync failed w/ rc",ee),ee=Ve.xTruncate(B.pointer,1024),ee&&x("truncate failed w/ rc",ee),q.poke($,0,"i64"),ee=Ve.xFileSize(B.pointer,$),ee&&x("xFileSize failed w/ rc",ee),k("xFileSize says:",q.peek($,"i64")),ee=Ve.xWrite(B.pointer,we,10,1),ee&&x("xWrite() failed!");const Lt=q.scopedAlloc(16);ee=Ve.xRead(B.pointer,Lt,6,2),q.poke(Lt+6,0);let ot=q.cstrToJs(Lt);k("xRead() got:",ot),ot!=="sanity"&&x("Unexpected xRead() value."),dt.xSleep&&(k("xSleep()ing before close()ing..."),dt.xSleep(z.pointer,2e3),k("waking up from xSleep()")),ee=Ve.xClose(Q),k("xClose rc =",ee,"sabOPView =",_.sabOPView),k("Deleting file:",qe),dt.xDelete(z.pointer,we,4660),dt.xAccess(z.pointer,we,0,$),ee=q.peek($,"i32"),ee&&x("Expecting 0 from xAccess(",qe,") after xDelete()."),m("End of OPFS sanity checks.")}finally{B.dispose(),q.scopedAllocPop(I)}};w.onmessage=function({data:I}){switch(I.type){case"opfs-unavailable":A(new Error(I.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:Ve},vfs:{struct:z,methods:dt}}),_.sabOPView=new Int32Array(_.sabOP),_.sabFileBufView=new Uint8Array(_.sabIO,0,_.fileBufferSize),_.sabS11nView=new Uint8Array(_.sabIO,_.sabS11nOffset,_.sabS11nSize),ne(),u.sanityChecks&&(m("Running sanity checks because of opfs-sanity-check URL arg..."),en()),ie()?navigator.storage.getDirectory().then(B=>{w.onerror=w._originalOnError,delete w._originalOnError,i.opfs=L,L.rootDirectory=B,k("End of OPFS sqlite3_vfs setup.",z),b(i)}).catch(A):b(i)}catch(B){y(B),A(B)}break}default:{const B="Unexpected message from the OPFS async worker: "+JSON.stringify(I);y(B),A(new Error(B));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 s<"u"){const i=Object.assign(Object.create(null),{exports:s.asm,memory:s.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}s.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 tc=function(){var r,n;const t=ec;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")?(...O)=>console.warn("sqlite3.debugModule:",...O):()=>{},e.urlParams.has("sqlite3.dir"))e.sqlite3Dir=e.urlParams.get("sqlite3.dir")+"/";else if(e.moduleScript){const O=e.moduleScript.src.split("/");O.pop(),e.sqlite3Dir=O.join("/")+"/"}if(globalThis.sqlite3InitModule=function O(...j){return t(...j).then(Y=>{var je,et,ct;if(typeof WorkerGlobalScope<"u"&&(Y.ENVIRONMENT_IS_PTHREAD||Y._pthread_self||typeof threadAlert=="function"||(ct=(et=(je=globalThis==null?void 0:globalThis.location)==null?void 0:je.pathname)==null?void 0:et.endsWith)!=null&&ct.call(et,".worker.js")))return Y;const he=Y.sqlite3;he.scriptInfo=e,O.__isUnderTest&&(he.__isUnderTest=!0);const Te=he.asyncPostInit;return delete he.asyncPostInit,Te()}).catch(Y=>{throw console.error("Exception loading sqlite3 module:",Y),Y})},globalThis.sqlite3InitModule.ready=t.ready,globalThis.sqlite3InitModuleState.moduleScript){const O=globalThis.sqlite3InitModuleState;let j=O.moduleScript.src.split("/");j.pop(),O.scriptDir=j.join("/")+"/"}return e.debugModule("sqlite3InitModuleState =",e),globalThis.sqlite3InitModule}();/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function nc(t){return t.constructor.name==="MessagePort"}function rc(t){nc(t)&&t.close()}function ic(t){return sc(t,{type:"RELEASE"}).then(()=>{rc(t)})}const xa=new WeakMap;"FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(xa.get(t)||0)-1;xa.set(t,e),e===0&&ic(t)});function sc(t,e,r){return new Promise(n=>{const O=oc();t.addEventListener("message",function j(Y){!Y.data||!Y.data.id||Y.data.id!==O||(t.removeEventListener("message",j),n(Y.data))}),t.start&&t.start(),t.postMessage(Object.assign({id:O},e),r)})}function oc(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Ea=t=>t==null||typeof t=="bigint"||typeof t=="string"||typeof t=="number"||typeof t=="object"&&"buffer"in t?t:typeof t=="boolean"?`${t}`:t instanceof Date?t.toISOString():JSON.stringify(t),ac=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},lc=class extends $s{constructor(e){super();ve(this,"serializer");this.serializer=e||Ea}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,...O}=r,j=this.serializer(n);return n===j?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...O,value:j}})}transformValue(e){return{...e,value:this.serializer(e.value)}}},uc=class{constructor({deserializer:t,serializer:e}={}){ve(this,"serializeParametersTransformer");ve(this,"deserializer");ve(this,"ctx");this.serializeParametersTransformer=new lc(e),this.deserializer=t||ac,this.ctx=new WeakMap}transformQuery({node:t,queryId:e}){return t.kind==="SelectQueryNode"&&this.ctx.set(e,t.kind),this.serializeParametersTransformer.transformNode(t)}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({result:t,queryId:e}){const{rows:r}=t,n=this.ctx.get(e);return this.ctx.delete(e),r&&n==="SelectQueryNode"?{...t,rows:await this.parseResult(r)}:t}};async function Sa(t,e,r,n,O="rowid"){await xt` + create trigger if not exists ${xt.raw(e)}_${xt.raw(n)} + after ${xt.raw(r)} + on ${xt.table(e)} begin - update ${Et.table(e)} - set ${Et.ref(n)} = datetime('now','localtime') - where ${Et.ref(A)} = NEW.${Et.ref(A)}; + update ${xt.table(e)} + set ${xt.ref(n)} = datetime('now','localtime') + where ${xt.ref(O)} = NEW.${xt.ref(O)}; end - `.execute(t).catch(V=>{console.error(V)})}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:V,property:Y}=A;r&&await t.schema.dropTable(n).ifExists().execute().catch();let pe=t.schema.createTable(n),Ie="rowid",ct=!1,Ze="createAt",et="updateAt";if(Y!=null&&Y.timestamp&&!ic(Y.timestamp)){const{create:se,update:Wt}=Y.timestamp;Ze=se??"createAt",et=Wt??"updateAt"}for(const se in V){if(!Object.prototype.hasOwnProperty.call(V,se))continue;const Wt=V[se];let Me="text";const{type:cn,notNull:yi,defaultTo:dn}=Wt;switch(cn){case"boolean":case"date":case"object":case"string":Me="text";break;case"increments":Ie=se;case"number":Me="integer";break;case"blob":Me="blob"}[Ze,et].includes(se)||(pe=pe.addColumn(se,Me,gt=>cn==="increments"?(ct=!0,gt.autoIncrement().primaryKey()):(yi&&(gt=gt.notNull()),dn!==void 0&&(gt=gt.defaultTo(dn instanceof Function?dn(Et):dn)),gt)))}if(Y){const se=Y.primary,Wt=Y.unique;if(Y.timestamp&&(Ze&&(pe=pe.addColumn(Ze,"text")),et&&(pe=pe.addColumn(et,"text"))),!ct&&se){const Me=ao(se);Ie=Me?se:se[0],pe=pe.addPrimaryKeyConstraint(`pk_${Me?se:se.join("_")}`,Me?[se]:se)}Wt==null||Wt.forEach(Me=>{const cn=ao(Me);Ie=!se&&!ct?cn?Me:Me[0]:Ie,pe=pe.addUniqueConstraint(`un_${cn?Me:Me.join("_")}`,cn?[Me]:Me)})}if(await pe.ifNotExists().execute(),Y!=null&&Y.index)for(const se of Y.index){const Wt=ao(se);let Me=t.schema.createIndex(`idx_${Wt?se:se.join("_")}`).on(n);Me=Wt?Me.column(se):Me.columns(se),await Me.ifNotExists().execute()}Y!=null&&Y.timestamp&&(Ze&&await va(t,n,"insert",Ze,Ie),et&&await va(t,n,"update",et,Ie))}}var ac=class{constructor(){xe(this,"items");this.items=[]}push(t){this.items.push(t)}pop(){return this.items.pop()}peek(){return this.items[this.items.length-1]}isEmpty(){return this.items.length===0}size(){return this.items.length}},lc=class{constructor(t){xe(this,"kysely");xe(this,"status");xe(this,"tableMap");xe(this,"logger");xe(this,"trxs");const{dialect:e,tables:r,dropTableBeforeInit:n,onQuery:A,plugins:V,logger:Y}=t;this.logger=Y;const pe=V??[];pe.push(new rc),this.kysely=new Kr({dialect:e,log:Ie=>{var ct;Ie.level==="error"?(ct=this.logger)==null||ct.error("Uncaught DB Error",Ie.error):A==null||A(Ie.query,Ie.queryDurationMillis)},plugins:pe}),this.status=n?0:1,this.tableMap=sc(r),this.trxs=new ac}async init(t=!1){const e=t||this.status===0;return await oc(this.kysely,this.tableMap,e),this.status=2,this}async isEmptyTable(){var t;return this.status!==2&&await this.init(),this.status===2?!1:((t=this.logger)==null||t.error("fail to init table"),!0)}async transaction(t,e){if(!await this.isEmptyTable())return await this.kysely.transaction().execute(r=>(this.trxs.push(r),t(r))).catch(r=>{var n;e&&((n=this.logger)==null||n.error(e,r))}).finally(()=>{this.trxs.pop()})}getDB(){return this.trxs.isEmpty()?this.kysely:this.trxs.peek()}async exec(t,e){if(!await this.isEmptyTable())return t(this.getDB()).catch(r=>{var n;e&&((n=this.logger)==null||n.error(e,r))})}async execOne(t,e){if(!await this.isEmptyTable())return t(this.getDB()).executeTakeFirstOrThrow().catch(r=>{var n;e&&((n=this.logger)==null||n.error(e,r))})}async execList(t,e){if(!await this.isEmptyTable())return t(this.getDB()).execute().catch(r=>{var n;e&&((n=this.logger)==null||n.error(e,r))})}async toSQL(t){return t(this.getDB()).compile()}async raw(t){if(!await this.isEmptyTable())return t(Et).execute(this.getDB())}};async function uc(t){const e=await new lc({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 cc=new Ku({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))},async onCreateConnection(t){await Xu(t)}});onmessage=()=>{console.log("start official wasm test"),uc(cc).then(t=>{t==null||t.forEach(e=>console.log("[official wasm]",e))})}})(); + `.execute(t).catch(j=>{console.error(j)})}function cc(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 dc(t,e,r=!1){for(const[n,O]of e){const{columns:j,property:Y}=O;r&&await t.schema.dropTable(n).ifExists().execute().catch();let he=t.schema.createTable(n);const{index:Te,primary:je,timestamp:et,unique:ct}=Y||{};let ke="rowid",bi=!1;const $n=typeof et=="object"&&et.create||"createAt",Tr=typeof et=="object"&&et.update||"updateAt";for(const[Be,Ot]of Object.entries(j)){let It="text";const{type:On,notNull:Zt,defaultTo:Kn}=Ot;switch(On){case"boolean":case"date":case"object":case"string":It="text";break;case"increments":ke=Be;case"number":It="integer";break;case"blob":It="blob"}[$n,Tr].includes(Be)||(he=he.addColumn(Be,It,In=>On==="increments"?(bi=!0,In.autoIncrement().primaryKey()):(Zt&&(In=In.notNull()),Kn!==void 0&&(In=In.defaultTo(Kn instanceof Function?Kn(xt):Kn)),In)))}if(et&&(he=he.addColumn($n,"text").addColumn(Tr,"text")),!bi&&je){const Be=Array.isArray(je);ke=Be?je[0]:je,he=he.addPrimaryKeyConstraint(`pk_${Be?je.join("_"):je}`,Be?je:[je])}if(ct==null||ct.forEach(Be=>{const Ot=Array.isArray(Be);ke=!je&&!bi?Ot?Be[0]:Be:ke,he=he.addUniqueConstraint(`un_${Ot?Be.join("_"):Be}`,Ot?Be:[Be])}),await he.ifNotExists().execute(),Te)for(const Be of Te){const Ot=Array.isArray(Be);await t.schema.createIndex(`idx_${Ot?Be.join("_"):Be}`).on(n).columns(Ot?Be:[Be]).ifNotExists().execute()}et&&(await Sa(t,n,"insert",$n,ke),await Sa(t,n,"update",Tr,ke))}}function fc(t){function e(r){return`__precomile_${r}`}return{setParam(r){let n;return(O,j)=>{if(!n){const{parameters:Y,sql:he,query:Te}=r(t,e).compile();n={sql:he,query:(j==null?void 0:j(Te))||{kind:Te.kind},parameters:Y}}return{...n,parameters:n.parameters.map(Y=>typeof Y=="string"&&Y.startsWith("__precomile_")?Ea(O[Y.slice(12)]):Y)}}}}}var hc=class{constructor(){ve(this,"items");this.items=[]}push(t){this.items.push(t)}pop(){return this.items.pop()}peek(){return this.items[this.items.length-1]}isEmpty(){return this.items.length===0}size(){return this.items.length}},pc=class{constructor(t){ve(this,"kysely");ve(this,"status");ve(this,"tableMap");ve(this,"logger");ve(this,"trxs");const{dialect:e,tables:r,dropTableBeforeInit:n,onQuery:O,plugins:j,logger:Y}=t;this.logger=Y;const he=j??[];he.push(new uc),this.kysely=new Zr({dialect:e,log:Te=>{var je;Te.level==="error"?(je=this.logger)==null||je.error("Uncaught DB Error",Te.error):O==null||O(Te.query,Te.queryDurationMillis)},plugins:he}),this.status=n?0:1,this.tableMap=cc(r),this.trxs=new hc}async init(t=!1){const e=t||this.status===0;return await dc(this.kysely,this.tableMap,e),this.status=2,this}async isEmptyTable(){var t;return this.status!==2&&await this.init(),this.status===2?!1:((t=this.logger)==null||t.error("fail to init table"),!0)}async transaction(t,e){if(!await this.isEmptyTable())return await this.kysely.transaction().execute(r=>(this.trxs.push(r),t(r))).catch(r=>{var n;e&&((n=this.logger)==null||n.error(e,r))}).finally(()=>{this.trxs.pop()})}getDB(){return this.trxs.isEmpty()?this.kysely:this.trxs.peek()}async exec(t,e){if(!await this.isEmptyTable())return t(this.getDB()).catch(r=>{var n;e&&((n=this.logger)==null||n.error(e,r))})}async execOne(t,e){const r=await this.execList(t,e);return r!=null&&r.length?r[0]:void 0}async execList(t,e){if(!await this.isEmptyTable())return t(this.getDB()).execute().catch(r=>{var n;e&&((n=this.logger)==null||n.error(e,r))})}preCompile(t){return fc(t(this.kysely))}async execCompiledRows(t,e){const r=await this.execCompiled(t,e);return(r==null?void 0:r.rows)??void 0}async execCompiled(t,e){if(!await this.isEmptyTable())return this.getDB().executeQuery(t).catch(r=>{var n;e&&((n=this.logger)==null||n.error(e,r))})}async toSQL(t){return t(this.getDB()).compile()}async raw(t){if(!await this.isEmptyTable())return t(xt).execute(this.getDB())}};async function _c(t){const e=await new pc({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 mc=new Yu({database:async()=>{const t=(await tc()).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))},async onCreateConnection(t){await Zu(t)}});onmessage=()=>{console.log("start official wasm test"),_c(mc).then(t=>{t==null||t.forEach(e=>console.log("[official wasm]",e))})}})(); diff --git a/assets/sqljsWorker-05f9f7e1.js b/assets/sqljsWorker-05f9f7e1.js new file mode 100644 index 0000000..52cc5d3 --- /dev/null +++ b/assets/sqljsWorker-05f9f7e1.js @@ -0,0 +1,12 @@ +var zl=Object.defineProperty;var Kl=($,L,ce)=>L in $?zl($,L,{enumerable:!0,configurable:!0,writable:!0,value:ce}):$[L]=ce;var B=($,L,ce)=>(Kl($,typeof L!="symbol"?L+"":L,ce),ce),Io=($,L,ce)=>{if(!L.has($))throw TypeError("Cannot "+ce)};var i=($,L,ce)=>(Io($,L,"read from private field"),ce?ce.call($):L.get($)),N=($,L,ce)=>{if(L.has($))throw TypeError("Cannot add the same private member more than once");L instanceof WeakSet?L.add($):L.set($,ce)},g=($,L,ce,hi)=>(Io($,L,"write to private field"),hi?hi.call($,ce):L.set($,ce),ce);var V=($,L,ce)=>(Io($,L,"access private method"),ce);(function(){var et,nr,Lr,H,Si,tt,D,q,I,Pr,zn,Br,sr,or,Kn,Tu,Hn,Su,Yn,Eu,ar,un,Ai,To,Xn,Au,Di,Y,Ri,Mr,Fr,hr,_i,So,b,Qr,Ur,Mt,Jr,Ft,cr,lr,Be,jr,$r,Gr,zr,ct,Kr,Qt,Li,Eo,Hr,Yr,Ut,G,dr,xt,Pi,rt,qe,fe,X,oe,z,Me,Q,be,ke,Ie,ss,re,ge,Fe,Qe,we,Xr,dt,ft,Ot,it,Vt,qt,mr,Ui,os,Du,as,Ru,us,_u,hs,Lu,Ji,Ao,Vi,jt,cs,Pu,$t,yr,xe,nt,Nr,st,De,ti,Is,ji,Do,$i,Ro,ri,Gt,ds,ii,wr,ni,fs,Bu,Gi,_a,zi,La;"use strict";function $(t){return typeof t>"u"||t===void 0}function L(t){return typeof t=="string"}function ce(t){return typeof t=="number"}function hi(t){return typeof t=="boolean"}function _o(t){return t===null}function Mu(t){return t instanceof Date}function Fu(t){return typeof t=="bigint"}function Ve(t){return typeof t=="function"}function at(t){return typeof t=="object"&&t!==null}function a(t){return Object.freeze(t)}function ci(t){return Array.isArray(t)}function Wr(t){return t}const le=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]})}}),te=a({is(t){return t.kind==="IdentifierNode"},create(t){return a({kind:"IdentifierNode",name:t})}}),At=a({is(t){return t.kind==="CreateIndexNode"},create(t){return a({kind:"CreateIndexNode",name:te.create(t)})},cloneWith(t,e){return a({...t,...e})},cloneWithColumns(t,e){return a({...t,columns:[...t.columns||[],...e]})}}),Lo=a({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return a({kind:"CreateSchemaNode",schema:te.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Qu=["preserve rows","delete rows","drop"],Ye=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})}}),Dt=a({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return a({kind:"SchemableIdentifierNode",identifier:te.create(t)})},createWithSchema(t,e){return a({kind:"SchemableIdentifierNode",schema:te.create(t),identifier:te.create(e)})}}),hn=a({is(t){return t.kind==="DropIndexNode"},create(t,e){return a({kind:"DropIndexNode",name:Dt.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Ts=a({is(t){return t.kind==="DropSchemaNode"},create(t,e){return a({kind:"DropSchemaNode",schema:te.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Ss=a({is(t){return t.kind==="DropTableNode"},create(t,e){return a({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return a({...t,...e})}}),Rt=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:Dt.create(t)})},createWithSchema(t,e){return a({kind:"TableNode",table:Dt.createWithSchema(t,e)})}});function je(t){return at(t)&&Ve(t.toOperationNode)}function Es(t){return at(t)&&"expressionType"in t&&je(t)}function Uu(t){return at(t)&&"expression"in t&&L(t.alias)&&je(t)}const Nt=a({is(t){return t.kind==="SelectModifierNode"},create(t){return a({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return a({kind:"SelectModifierNode",rawModifier:t})}}),tr=a({is(t){return t.kind==="AndNode"},create(t,e){return a({kind:"AndNode",left:t,right:e})}}),rr=a({is(t){return t.kind==="OrNode"},create(t,e){return a({kind:"OrNode",left:t,right:e})}}),As=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"?tr.create(t.on,r):rr.create(t.on,r)})}}),li=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:As.create(r)})},cloneWithOn(t,e){return a({...t,on:t.on?As.cloneWithOperation(t.on,"And",e):As.create(e)})}}),Ds=a({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return a({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),Po=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp"],Ju=["+","-","*","/","%","^","&","|","#","<<",">>"],Bo=["->","->>"],Mo=[...Po,...Ju,"&&","||"],Vu=["not","-",...["exists","not exists"]],ju=[...Mo,...Bo,...Vu],di=a({is(t){return t.kind==="OperatorNode"},create(t){return a({kind:"OperatorNode",operator:t})}});function $u(t){return L(t)&&Mo.includes(t)}function Gu(t){return L(t)&&Po.includes(t)}function Fo(t){return L(t)&&Bo.includes(t)}const ie=a({is(t){return t.kind==="ColumnNode"},create(t){return a({kind:"ColumnNode",column:te.create(t)})}}),Rs=a({is(t){return t.kind==="SelectAllNode"},create(){return a({kind:"SelectAllNode"})}}),cn=a({is(t){return t.kind==="ReferenceNode"},create(t,e){return a({kind:"ReferenceNode",table:e,column:t})},createSelectAll(t){return a({kind:"ReferenceNode",table:t,column:Rs.create()})}}),zu=a({is(t){return t.kind==="OrderByItemNode"},create(t,e){return a({kind:"OrderByItemNode",orderBy:t,direction:e})}}),Ce=a({is(t){return t.kind==="RawNode"},create(t,e){return a({kind:"RawNode",sqlFragments:a(t),parameters:a(e)})},createWithSql(t){return Ce.create([t],[])},createWithChild(t){return Ce.create(["",""],[t])},createWithChildren(t){return Ce.create(new Array(t.length+1).fill(""),t)}});function Ku(t){return t==="asc"||t==="desc"}function ln(t,e){return zu.create(Hu(t),Yu(e))}function Hu(t){return wt(t)}function Yu(t){if(t)return t==="asc"||t==="desc"?Ce.createWithSql(t):t.toOperationNode()}const _s=a({is(t){return t.kind==="JSONReferenceNode"},create(t,e){return a({kind:"JSONReferenceNode",reference:t,traversal:e})},cloneWithTraversal(t,e){return a({...t,traversal:e})}}),Qo=a({is(t){return t.kind==="JSONOperatorChainNode"},create(t){return a({kind:"JSONOperatorChainNode",operator:t,values:a([])})},cloneWithValue(t,e){return a({...t,values:a([...t.values,e])})}}),Ls=a({is(t){return t.kind==="JSONPathNode"},create(t){return a({kind:"JSONPathNode",inOperator:t,pathLegs:a([])})},cloneWithLeg(t,e){return a({...t,pathLegs:a([...t.pathLegs,e])})}});function Uo(t){return L(t)?ir(t):t.toOperationNode()}function fi(t){return ci(t)?t.map(e=>wt(e)):[wt(t)]}function wt(t){return Wn(t)?Cn(t):Uo(t)}function Xu(t,e){const r=ir(t);if(Fo(e))return _s.create(r,Qo.create(di.create(e)));const u=e.slice(0,-1);if(Fo(u))return _s.create(r,Ls.create(di.create(u)));throw new Error(`Invalid JSON operator: ${e}`)}function ir(t){const e=".";if(!t.includes(e))return cn.create(ie.create(t));const r=t.split(e).map(Ps);if(r.length===3)return eh(r);if(r.length===2)return th(r);throw new Error(`invalid column reference ${t}`)}function Zu(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(Ps);return Rt.create(ir(r),te.create(u))}else return ir(t)}function Jo(t){return ie.create(t)}function Vo(t){const e=" ";if(t.includes(e)){const[r,u]=t.split(e).map(Ps);if(!Ku(u))throw new Error(`invalid order direction "${u}" next to "${r}"`);return ln(r,u)}else return Jo(t)}function eh(t){const[e,r,u]=t;return cn.create(ie.create(u),_t.createWithSchema(e,r))}function th(t){const[e,r]=t;return cn.create(ie.create(r),_t.create(e))}function Ps(t){return t.trim()}const jo=a({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return a({kind:"PrimitiveValueListNode",values:a([...t])})}}),Bs=a({is(t){return t.kind==="ValueListNode"},create(t){return a({kind:"ValueListNode",values:a(t)})}}),Xe=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 ci(t)?rh(t):vt(t)}function vt(t){return Wn(t)?Cn(t):Xe.create(t)}function rh(t){return t.some(Wn)?Bs.create(t.map(e=>vt(e))):jo.create(t)}function We(t){if(t.length>1&&!Ko(t[1]))throw new Error(`invalid comparison operator ${JSON.stringify(t[1])}`);return Go(t)}function Go(t){if(t.length===3)return dn(t[0],t[1],t[2]);if(t.length===1)return ah(t[0]);throw new Error(`invalid arguments: ${JSON.stringify(t)}`)}function dn(t,e,r){if(!zo(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return nh(e)&&sh(r)?oh(t,e,r):Ds.create(wt(t),Ms(e),$o(r))}function bt(t,e,r){if(!Ko(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return ih(t,e,r)}function ih(t,e,r){if(!zo(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Ds.create(wt(t),Ms(e),wt(r))}function zo(t){return $u(t)||Es(t)}function Ko(t){return Gu(t)||Es(t)}function nh(t){return t==="is"||t==="is not"}function sh(t){return _o(t)||hi(t)}function oh(t,e,r){return Ds.create(wt(t),Ms(e),Xe.createImmediate(r))}function Ms(t){if(L(t)&&ju.includes(t))return di.create(t);if(je(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function ah(t){return Ve(t)?t(Ks()).toOperationNode():je(t)?t.toOperationNode():Xe.create(t)}const kr=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])})}}),Ho=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])})}}),Fs=a({is(t){return t.kind==="OverNode"},create(){return a({kind:"OverNode"})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?kr.cloneWithItem(t.orderBy,e):kr.create(e)})},cloneWithPartitionByItems(t,e){return a({...t,partitionBy:t.partitionBy?Ho.cloneWithItems(t.partitionBy,e):Ho.create(e)})}}),fn=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])})}}),Yo=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])})}}),Xo=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"?tr.create(t.having,r):rr.create(t.having,r)})}}),M=a({is(t){return t.kind==="SelectQueryNode"},create(t,e){return a({kind:"SelectQueryNode",from:fn.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?kr.cloneWithItem(t.orderBy,e):kr.create(e)})},cloneWithGroupByItems(t,e){return a({...t,groupBy:t.groupBy?Yo.cloneWithItems(t.groupBy,e):Yo.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?Xo.cloneWithOperation(t.having,"And",e):Xo.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})}});function F(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}const Ti=class Ti{constructor(e){N(this,et,void 0);g(this,et,a(e))}on(...e){return new Ti({...i(this,et),joinNode:li.cloneWithOn(i(this,et).joinNode,We(e))})}onRef(e,r,u){return new Ti({...i(this,et),joinNode:li.cloneWithOn(i(this,et).joinNode,bt(e,r,u))})}onTrue(){return new Ti({...i(this,et),joinNode:li.cloneWithOn(i(this,et).joinNode,Ce.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return i(this,et).joinNode}};et=new WeakMap;let pn=Ti;F(pn,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const uh=a({is(t){return t.kind==="PartitionByItemNode"},create(t){return a({kind:"PartitionByItemNode",partitionBy:t})}});function hh(t){return fi(t).map(uh.create)}const Gn=class Gn{constructor(e){N(this,nr,void 0);g(this,nr,a(e))}orderBy(e,r){return new Gn({overNode:Fs.cloneWithOrderByItem(i(this,nr).overNode,ln(e,r))})}partitionBy(e){return new Gn({overNode:Fs.cloneWithPartitionByItems(i(this,nr).overNode,hh(e))})}$call(e){return e(this)}toOperationNode(){return i(this,nr).overNode}};nr=new WeakMap;let mn=Gn;F(mn,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const pi=a({is(t){return t.kind==="SelectionNode"},create(t){return a({kind:"SelectionNode",selection:t})},createSelectAll(){return a({kind:"SelectionNode",selection:Rs.create()})},createSelectAllFromTable(t){return a({kind:"SelectionNode",selection:cn.createSelectAll(t)})}});class ch{constructor(e){N(this,Lr,void 0);g(this,Lr,e)}get dynamicReference(){return i(this,Lr)}get refType(){}toOperationNode(){return Uo(i(this,Lr))}}Lr=new WeakMap;function lh(t){return at(t)&&je(t)&&L(t.dynamicReference)}function mi(t){return Ve(t)?mi(t(Ar())):ci(t)?t.map(e=>Zo(e)):[Zo(t)]}function Zo(t){return L(t)?pi.create(Zu(t)):lh(t)?pi.create(t.toOperationNode()):pi.create(ma(t))}function yi(t){return t?Array.isArray(t)?t.map(ea):[ea(t)]:[pi.createSelectAll()]}function ea(t){if(L(t))return pi.createSelectAllFromTable(Ae(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const dh=a({is(t){return t.kind==="ValuesNode"},create(t){return a({kind:"ValuesNode",values:a(t)})}}),fh=a({is(t){return t.kind==="DefaultInsertValueNode"},create(){return a({kind:"DefaultInsertValueNode"})}});function ph(t){const e=Ve(t)?t(Ar()):t,r=ci(e)?e:a([e]);return mh(r)}function mh(t){const e=yh(t);return[a([...e.keys()].map(ie.create)),dh.create(t.map(r=>Nh(r,e)))]}function yh(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 Nh(t,e){const r=Object.keys(t),u=Array.from({length:e.size});let d=!1;for(const x of r){const W=e.get(x);if($(W))continue;const j=t[x];($(j)||Wn(j))&&(d=!0),u[W]=j}if(r.length$(W)?x:vt(W)))}return jo.create(u)}const ut=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})}}),yn=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?fn.cloneWithFroms(t.from,e):fn.create(e)})},cloneWithUpdates(t,e){return a({...t,updates:t.updates?a([...t.updates,...e]):e})}}),ta=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])})}}),Ni=a({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return a({kind:"DeleteQueryNode",from:fn.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?kr.cloneWithItem(t.orderBy,e):kr.create(e)})},cloneWithLimit(t,e){return a({...t,limit:e})},cloneWithUsing(t,e){return a({...t,using:t.using!==void 0?ta.cloneWithTables(t.using,e):ta.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"?tr.create(t.where,r):rr.create(t.where,r)})}}),ra=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)})}}),wh=a({is(t){return t.kind==="ExplainNode"},create(t,e){return a({kind:"ExplainNode",format:t,options:e})}}),_=a({is(t){return M.is(t)||ut.is(t)||yn.is(t)||Ni.is(t)},cloneWithWhere(t,e){return a({...t,where:t.where?Se.cloneWithOperation(t.where,"And",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?ra.cloneWithSelections(t.returning,e):ra.create(e)})},cloneWithoutWhere(t){return a({...t,where:void 0})},cloneWithExplain(t,e,r){return a({...t,explain:wh.create(e,r==null?void 0:r.toOperationNode())})}}),vh=a({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return a({kind:"ColumnUpdateNode",column:t,value:e})}});function Qs(t){const e=Ve(t)?t(Ar()):t;return Object.entries(e).filter(([r,u])=>u!==void 0).map(([r,u])=>vh.create(ie.create(r),vt(u)))}const bh=a({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return a({kind:"OnDuplicateKeyNode",updates:t})}});class gh{constructor(e,r){B(this,"insertId");B(this,"numInsertedOrUpdatedRows");this.insertId=e,this.numInsertedOrUpdatedRows=r}}class Nn extends Error{constructor(r){super("no result");B(this,"node");this.node=r}}function wn(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const Le=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})}}),gt=class gt{constructor(e){N(this,H,void 0);g(this,H,a(e))}column(e){const r=ie.create(e);return new gt({...i(this,H),onConflictNode:Le.cloneWith(i(this,H).onConflictNode,{columns:i(this,H).onConflictNode.columns?a([...i(this,H).onConflictNode.columns,r]):a([r])})})}columns(e){const r=e.map(ie.create);return new gt({...i(this,H),onConflictNode:Le.cloneWith(i(this,H).onConflictNode,{columns:i(this,H).onConflictNode.columns?a([...i(this,H).onConflictNode.columns,...r]):a(r)})})}constraint(e){return new gt({...i(this,H),onConflictNode:Le.cloneWith(i(this,H).onConflictNode,{constraint:te.create(e)})})}expression(e){return new gt({...i(this,H),onConflictNode:Le.cloneWith(i(this,H).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new gt({...i(this,H),onConflictNode:Le.cloneWithIndexWhere(i(this,H).onConflictNode,We(e))})}whereRef(e,r,u){return new gt({...i(this,H),onConflictNode:Le.cloneWithIndexWhere(i(this,H).onConflictNode,bt(e,r,u))})}clearWhere(){return new gt({...i(this,H),onConflictNode:Le.cloneWithoutIndexWhere(i(this,H).onConflictNode)})}doNothing(){return new ia({...i(this,H),onConflictNode:Le.cloneWith(i(this,H).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new bn({...i(this,H),onConflictNode:Le.cloneWith(i(this,H).onConflictNode,{updates:Qs(e)})})}$call(e){return e(this)}};H=new WeakMap;let vn=gt;F(vn,"don't await OnConflictBuilder instances.");class ia{constructor(e){N(this,Si,void 0);g(this,Si,a(e))}toOperationNode(){return i(this,Si).onConflictNode}}Si=new WeakMap,F(ia,"don't await OnConflictDoNothingBuilder instances.");const Ei=class Ei{constructor(e){N(this,tt,void 0);g(this,tt,a(e))}where(...e){return new Ei({...i(this,tt),onConflictNode:Le.cloneWithUpdateWhere(i(this,tt).onConflictNode,We(e))})}whereRef(e,r,u){return new Ei({...i(this,tt),onConflictNode:Le.cloneWithUpdateWhere(i(this,tt).onConflictNode,bt(e,r,u))})}clearWhere(){return new Ei({...i(this,tt),onConflictNode:Le.cloneWithoutUpdateWhere(i(this,tt).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return i(this,tt).onConflictNode}};tt=new WeakMap;let bn=Ei;F(bn,"don't await OnConflictUpdateBuilder instances.");const Oe=class Oe{constructor(e){N(this,D,void 0);g(this,D,a(e))}values(e){const[r,u]=ph(e);return new Oe({...i(this,D),queryNode:ut.cloneWith(i(this,D).queryNode,{columns:r,values:u})})}columns(e){return new Oe({...i(this,D),queryNode:ut.cloneWith(i(this,D).queryNode,{columns:a(e.map(ie.create))})})}expression(e){return new Oe({...i(this,D),queryNode:ut.cloneWith(i(this,D).queryNode,{values:Cn(e)})})}ignore(){return new Oe({...i(this,D),queryNode:ut.cloneWith(i(this,D).queryNode,{ignore:!0})})}onConflict(e){return new Oe({...i(this,D),queryNode:ut.cloneWith(i(this,D).queryNode,{onConflict:e(new vn({onConflictNode:Le.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new Oe({...i(this,D),queryNode:ut.cloneWith(i(this,D).queryNode,{onDuplicateKey:bh.create(Qs(e))})})}returning(e){return new Oe({...i(this,D),queryNode:_.cloneWithReturning(i(this,D).queryNode,mi(e))})}returningAll(){return new Oe({...i(this,D),queryNode:_.cloneWithReturning(i(this,D).queryNode,yi())})}$call(e){return e(this)}$if(e,r){return e?r(this):new Oe({...i(this,D)})}$castTo(){return new Oe(i(this,D))}$narrowType(){return new Oe(i(this,D))}$assertType(){return new Oe(i(this,D))}withPlugin(e){return new Oe({...i(this,D),executor:i(this,D).executor.withPlugin(e)})}toOperationNode(){return i(this,D).executor.transformQuery(i(this,D).queryNode,i(this,D).queryId)}compile(){return i(this,D).executor.compileQuery(this.toOperationNode(),i(this,D).queryId)}async execute(){const e=this.compile(),r=e.query,u=await i(this,D).executor.executeQuery(e,i(this,D).queryId);return i(this,D).executor.adapter.supportsReturning&&r.returning?u.rows:[new gh(u.insertId,u.numAffectedRows??u.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Nn){const r=await this.executeTakeFirst();if(r===void 0)throw wn(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,D).executor.stream(r,e,i(this,D).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new Oe({...i(this,D),queryNode:_.cloneWithExplain(i(this,D).queryNode,e,r)}).execute()}};D=new WeakMap;let wi=Oe;F(wi,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class xh{constructor(e){B(this,"numDeletedRows");this.numDeletedRows=e}}const na=a({is(t){return t.kind==="LimitNode"},create(t){return a({kind:"LimitNode",limit:Xe.create(t)})}}),de=class de{constructor(e){N(this,q,void 0);g(this,q,a(e))}where(...e){return new de({...i(this,q),queryNode:_.cloneWithWhere(i(this,q).queryNode,We(e))})}whereRef(e,r,u){return new de({...i(this,q),queryNode:_.cloneWithWhere(i(this,q).queryNode,bt(e,r,u))})}clearWhere(){return new de({...i(this,q),queryNode:_.cloneWithoutWhere(i(this,q).queryNode)})}using(e){return new de({...i(this,q),queryNode:Ni.cloneWithUsing(i(this,q).queryNode,xi(e))})}innerJoin(...e){return new de({...i(this,q),queryNode:_.cloneWithJoin(i(this,q).queryNode,Ee("InnerJoin",e))})}leftJoin(...e){return new de({...i(this,q),queryNode:_.cloneWithJoin(i(this,q).queryNode,Ee("LeftJoin",e))})}rightJoin(...e){return new de({...i(this,q),queryNode:_.cloneWithJoin(i(this,q).queryNode,Ee("RightJoin",e))})}fullJoin(...e){return new de({...i(this,q),queryNode:_.cloneWithJoin(i(this,q).queryNode,Ee("FullJoin",e))})}returning(e){return new de({...i(this,q),queryNode:_.cloneWithReturning(i(this,q).queryNode,mi(e))})}returningAll(e){return new de({...i(this,q),queryNode:_.cloneWithReturning(i(this,q).queryNode,yi(e))})}orderBy(e,r){return new de({...i(this,q),queryNode:Ni.cloneWithOrderByItem(i(this,q).queryNode,ln(e,r))})}limit(e){return new de({...i(this,q),queryNode:Ni.cloneWithLimit(i(this,q).queryNode,na.create(e))})}$call(e){return e(this)}$if(e,r){return e?r(this):new de({...i(this,q)})}$castTo(){return new de(i(this,q))}$narrowType(){return new de(i(this,q))}$assertType(){return new de(i(this,q))}withPlugin(e){return new de({...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 xh(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Nn){const r=await this.executeTakeFirst();if(r===void 0)throw wn(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 de({...i(this,q),queryNode:_.cloneWithExplain(i(this,q).queryNode,e,r)}).execute()}};q=new WeakMap;let gn=de;F(gn,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Oh{constructor(e,r){B(this,"numUpdatedRows");B(this,"numChangedRows");this.numUpdatedRows=e,this.numChangedRows=r}}const me=class me{constructor(e){N(this,I,void 0);g(this,I,a(e))}where(...e){return new me({...i(this,I),queryNode:_.cloneWithWhere(i(this,I).queryNode,We(e))})}whereRef(e,r,u){return new me({...i(this,I),queryNode:_.cloneWithWhere(i(this,I).queryNode,bt(e,r,u))})}clearWhere(){return new me({...i(this,I),queryNode:_.cloneWithoutWhere(i(this,I).queryNode)})}from(e){return new me({...i(this,I),queryNode:yn.cloneWithFromItems(i(this,I).queryNode,xi(e))})}innerJoin(...e){return new me({...i(this,I),queryNode:_.cloneWithJoin(i(this,I).queryNode,Ee("InnerJoin",e))})}leftJoin(...e){return new me({...i(this,I),queryNode:_.cloneWithJoin(i(this,I).queryNode,Ee("LeftJoin",e))})}rightJoin(...e){return new me({...i(this,I),queryNode:_.cloneWithJoin(i(this,I).queryNode,Ee("RightJoin",e))})}fullJoin(...e){return new me({...i(this,I),queryNode:_.cloneWithJoin(i(this,I).queryNode,Ee("FullJoin",e))})}set(e){return new me({...i(this,I),queryNode:yn.cloneWithUpdates(i(this,I).queryNode,Qs(e))})}returning(e){return new me({...i(this,I),queryNode:_.cloneWithReturning(i(this,I).queryNode,mi(e))})}returningAll(){return new me({...i(this,I),queryNode:_.cloneWithReturning(i(this,I).queryNode,yi())})}$call(e){return e(this)}$if(e,r){return e?r(this):new me({...i(this,I)})}$castTo(){return new me(i(this,I))}$narrowType(){return new me(i(this,I))}$assertType(){return new me(i(this,I))}withPlugin(e){return new me({...i(this,I),executor:i(this,I).executor.withPlugin(e)})}toOperationNode(){return i(this,I).executor.transformQuery(i(this,I).queryNode,i(this,I).queryId)}compile(){return i(this,I).executor.compileQuery(this.toOperationNode(),i(this,I).queryId)}async execute(){const e=this.compile(),r=e.query,u=await i(this,I).executor.executeQuery(e,i(this,I).queryId);return i(this,I).executor.adapter.supportsReturning&&r.returning?u.rows:[new Oh(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0),u.numChangedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Nn){const r=await this.executeTakeFirst();if(r===void 0)throw wn(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,I).executor.stream(r,e,i(this,I).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new me({...i(this,I),queryNode:_.cloneWithExplain(i(this,I).queryNode,e,r)}).execute()}};I=new WeakMap;let xn=me;F(xn,"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})}}),sa=a({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return a({kind:"CommonTableExpressionNameNode",table:_t.create(t),columns:e?a(e.map(ie.create)):void 0})}});function oa(t,e){const r=e(Rh());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 sa.create(r,u)}else return sa.create(t)}const On=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])})}}),aa=["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 Wh(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",column:this.transformNode(e.column),table:this.transformNode(e.table)}}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)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}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}}zn=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 Sh extends Us{constructor(r){super();N(this,Kn);N(this,Hn);N(this,Yn);N(this,ar);N(this,Ai);N(this,Xn);N(this,Br,void 0);N(this,sr,new Set);N(this,or,new Set);g(this,Br,r)}transformNodeImpl(r){if(!V(this,Kn,Tu).call(this,r))return super.transformNodeImpl(r);const u=V(this,Yn,Eu).call(this,r);for(const x of u)i(this,or).add(x);const d=V(this,Hn,Su).call(this,r);for(const x of d)i(this,sr).add(x);const v=super.transformNodeImpl(r);for(const x of d)i(this,sr).delete(x);for(const x of u)i(this,or).delete(x);return v}transformSchemableIdentifier(r){const u=super.transformSchemableIdentifier(r);return u.schema||!i(this,sr).has(r.identifier.name)?u:{...u,schema:te.create(i(this,Br))}}transformReferences(r){const u=super.transformReferences(r);return u.table.table.schema?u:{...u,table:_t.createWithSchema(i(this,Br),u.table.table.identifier.name)}}}Br=new WeakMap,sr=new WeakMap,or=new WeakMap,Kn=new WeakSet,Tu=function(r){return r.kind in Th},Hn=new WeakSet,Su=function(r){const u=new Set;if("name"in r&&r.name&&Dt.is(r.name)&&V(this,Ai,To).call(this,r.name,u),"from"in r&&r.from)for(const d of r.from.froms)V(this,ar,un).call(this,d,u);if("into"in r&&r.into&&V(this,ar,un).call(this,r.into,u),"table"in r&&r.table&&V(this,ar,un).call(this,r.table,u),"joins"in r&&r.joins)for(const d of r.joins)V(this,ar,un).call(this,d.table,u);return u},Yn=new WeakSet,Eu=function(r){const u=new Set;return"with"in r&&r.with&&V(this,Xn,Au).call(this,r.with,u),u},ar=new WeakSet,un=function(r,u){const d=_t.is(r)?r:Rt.is(r)&&_t.is(r.node)?r.node:null;d&&V(this,Ai,To).call(this,d.table,u)},Ai=new WeakSet,To=function(r,u){const d=r.identifier.name;!i(this,sr).has(d)&&!i(this,or).has(d)&&u.add(d)},Xn=new WeakSet,Au=function(r,u){for(const d of r.expressions){const v=d.name.table.table.identifier.name;i(this,or).has(v)||u.add(v)}};class vi{constructor(e){N(this,Di,void 0);g(this,Di,new Sh(e))}transformQuery(e){return i(this,Di).transformNode(e.node)}async transformResult(e){return e.result}}Di=new WeakMap;const ur=class ur{constructor(e){N(this,Y,void 0);g(this,Y,a(e))}selectFrom(e){return new bi({queryId:K(),executor:i(this,Y).executor,queryNode:M.create(xi(e),i(this,Y).withNode)})}insertInto(e){return new wi({queryId:K(),executor:i(this,Y).executor,queryNode:ut.create(Ae(e),i(this,Y).withNode)})}replaceInto(e){return new wi({queryId:K(),executor:i(this,Y).executor,queryNode:ut.create(Ae(e),i(this,Y).withNode,!0)})}deleteFrom(e){return new gn({queryId:K(),executor:i(this,Y).executor,queryNode:Ni.create(xi(e),i(this,Y).withNode)})}updateTable(e){return new xn({queryId:K(),executor:i(this,Y).executor,queryNode:yn.create(Oi(e),i(this,Y).withNode)})}with(e,r){const u=oa(e,r);return new ur({...i(this,Y),withNode:i(this,Y).withNode?On.cloneWithExpression(i(this,Y).withNode,u):On.create(u)})}withRecursive(e,r){const u=oa(e,r);return new ur({...i(this,Y),withNode:i(this,Y).withNode?On.cloneWithExpression(i(this,Y).withNode,u):On.create(u,{recursive:!0})})}withPlugin(e){return new ur({...i(this,Y),executor:i(this,Y).executor.withPlugin(e)})}withoutPlugins(){return new ur({...i(this,Y),executor:i(this,Y).executor.withoutPlugins()})}withSchema(e){return new ur({...i(this,Y),executor:i(this,Y).executor.withPluginAtFront(new vi(e))})}};Y=new WeakMap;let qn=ur;class ua{constructor(){N(this,Ri,void 0);N(this,Mr,void 0);N(this,Fr,void 0);B(this,"resolve",e=>{i(this,Mr)&&i(this,Mr).call(this,e)});B(this,"reject",e=>{i(this,Fr)&&i(this,Fr).call(this,e)});g(this,Ri,new Promise((e,r)=>{g(this,Fr,r),g(this,Mr,e)}))}get promise(){return i(this,Ri)}}Ri=new WeakMap,Mr=new WeakMap,Fr=new WeakMap;const ha=new Set;function Eh(t){ha.has(t)||(ha.add(t),console.log(t))}const Ah=a([]);class ca{constructor(e=Ah){N(this,_i);N(this,hr,void 0);g(this,hr,e)}get plugins(){return i(this,hr)}transformQuery(e,r){for(const u of i(this,hr)){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),v=await V(this,_i,So).call(this,d,r);return Dh(d,v),v})}async*stream(e,r,u){const d=new ua,v=new ua;this.provideConnection(async W=>(d.resolve(W),await v.promise)).catch(W=>d.reject(W));const x=await d.promise;try{for await(const W of x.streamQuery(e,r))yield await V(this,_i,So).call(this,W,u)}finally{v.resolve()}}}hr=new WeakMap,_i=new WeakSet,So=async function(e,r){for(const u of i(this,hr))e=await u.transformResult({result:e,queryId:r});return e};function Dh(t,e){const{numAffectedRows:r}=t;r===void 0&&t.numUpdatedOrDeletedRows===void 0||r!==void 0&&e.numAffectedRows!==void 0||Eh("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class Ir extends ca{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 Ir([...this.plugins,e])}withPlugins(e){return new Ir([...this.plugins,...e])}withPluginAtFront(e){return new Ir([e,...this.plugins])}withoutPlugins(){return new Ir([])}}const Js=new Ir;function Rh(){return new qn({executor:Js})}function _h(t,e){return new pn({joinNode:li.create(t,Oi(e))})}function Lh(){return new mn({overNode:Fs.create()})}function Ee(t,e){if(e.length===3)return Bh(t,e[0],e[1],e[2]);if(e.length===2)return Ph(t,e[0],e[1]);throw new Error("not implemented")}function Ph(t,e,r){return r(_h(t,e)).toOperationNode()}function Bh(t,e,r,u){return li.createWithOn(t,Oi(e),bt(r,"=",u))}const Mh=a({is(t){return t.kind==="OffsetNode"},create(t){return a({kind:"OffsetNode",offset:Xe.create(t)})}}),Fh=a({is(t){return t.kind==="GroupByItemNode"},create(t){return a({kind:"GroupByItemNode",groupBy:t})}});function Qh(t){return t=Ve(t)?t(Ar()):t,fi(t).map(Fh.create)}const la=a({is(t){return t.kind==="SetOperationNode"},create(t,e,r){return a({kind:"SetOperationNode",operator:t,expression:e,all:r})}});function Tr(t,e,r){return la.create(t,e.toOperationNode(),r)}const C=class C{constructor(e){N(this,b,void 0);g(this,b,a(e))}get expressionType(){}where(...e){return new C({...i(this,b),queryNode:_.cloneWithWhere(i(this,b).queryNode,We(e))})}whereRef(e,r,u){return new C({...i(this,b),queryNode:_.cloneWithWhere(i(this,b).queryNode,bt(e,r,u))})}having(...e){return new C({...i(this,b),queryNode:M.cloneWithHaving(i(this,b).queryNode,We(e))})}havingRef(e,r,u){return new C({...i(this,b),queryNode:M.cloneWithHaving(i(this,b).queryNode,bt(e,r,u))})}select(e){return new C({...i(this,b),queryNode:M.cloneWithSelections(i(this,b).queryNode,mi(e))})}distinctOn(e){return new C({...i(this,b),queryNode:M.cloneWithDistinctOn(i(this,b).queryNode,fi(e))})}modifyFront(e){return new C({...i(this,b),queryNode:M.cloneWithFrontModifier(i(this,b).queryNode,Nt.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new C({...i(this,b),queryNode:M.cloneWithEndModifier(i(this,b).queryNode,Nt.createWithExpression(e.toOperationNode()))})}distinct(){return new C({...i(this,b),queryNode:M.cloneWithFrontModifier(i(this,b).queryNode,Nt.create("Distinct"))})}forUpdate(){return new C({...i(this,b),queryNode:M.cloneWithEndModifier(i(this,b).queryNode,Nt.create("ForUpdate"))})}forShare(){return new C({...i(this,b),queryNode:M.cloneWithEndModifier(i(this,b).queryNode,Nt.create("ForShare"))})}forKeyShare(){return new C({...i(this,b),queryNode:M.cloneWithEndModifier(i(this,b).queryNode,Nt.create("ForKeyShare"))})}forNoKeyUpdate(){return new C({...i(this,b),queryNode:M.cloneWithEndModifier(i(this,b).queryNode,Nt.create("ForNoKeyUpdate"))})}skipLocked(){return new C({...i(this,b),queryNode:M.cloneWithEndModifier(i(this,b).queryNode,Nt.create("SkipLocked"))})}noWait(){return new C({...i(this,b),queryNode:M.cloneWithEndModifier(i(this,b).queryNode,Nt.create("NoWait"))})}selectAll(e){return new C({...i(this,b),queryNode:M.cloneWithSelections(i(this,b).queryNode,yi(e))})}innerJoin(...e){return new C({...i(this,b),queryNode:_.cloneWithJoin(i(this,b).queryNode,Ee("InnerJoin",e))})}leftJoin(...e){return new C({...i(this,b),queryNode:_.cloneWithJoin(i(this,b).queryNode,Ee("LeftJoin",e))})}rightJoin(...e){return new C({...i(this,b),queryNode:_.cloneWithJoin(i(this,b).queryNode,Ee("RightJoin",e))})}fullJoin(...e){return new C({...i(this,b),queryNode:_.cloneWithJoin(i(this,b).queryNode,Ee("FullJoin",e))})}innerJoinLateral(...e){return new C({...i(this,b),queryNode:_.cloneWithJoin(i(this,b).queryNode,Ee("LateralInnerJoin",e))})}leftJoinLateral(...e){return new C({...i(this,b),queryNode:_.cloneWithJoin(i(this,b).queryNode,Ee("LateralLeftJoin",e))})}orderBy(e,r){return new C({...i(this,b),queryNode:M.cloneWithOrderByItem(i(this,b).queryNode,ln(e,r))})}groupBy(e){return new C({...i(this,b),queryNode:M.cloneWithGroupByItems(i(this,b).queryNode,Qh(e))})}limit(e){return new C({...i(this,b),queryNode:M.cloneWithLimit(i(this,b).queryNode,na.create(e))})}offset(e){return new C({...i(this,b),queryNode:M.cloneWithOffset(i(this,b).queryNode,Mh.create(e))})}union(e){return new C({...i(this,b),queryNode:M.cloneWithSetOperation(i(this,b).queryNode,Tr("union",e,!1))})}unionAll(e){return new C({...i(this,b),queryNode:M.cloneWithSetOperation(i(this,b).queryNode,Tr("union",e,!0))})}intersect(e){return new C({...i(this,b),queryNode:M.cloneWithSetOperation(i(this,b).queryNode,Tr("intersect",e,!1))})}intersectAll(e){return new C({...i(this,b),queryNode:M.cloneWithSetOperation(i(this,b).queryNode,Tr("intersect",e,!0))})}except(e){return new C({...i(this,b),queryNode:M.cloneWithSetOperation(i(this,b).queryNode,Tr("except",e,!1))})}exceptAll(e){return new C({...i(this,b),queryNode:M.cloneWithSetOperation(i(this,b).queryNode,Tr("except",e,!0))})}as(e){return new Uh(this,e)}clearSelect(){return new C({...i(this,b),queryNode:M.cloneWithoutSelections(i(this,b).queryNode)})}clearWhere(){return new C({...i(this,b),queryNode:_.cloneWithoutWhere(i(this,b).queryNode)})}clearLimit(){return new C({...i(this,b),queryNode:M.cloneWithoutLimit(i(this,b).queryNode)})}clearOffset(){return new C({...i(this,b),queryNode:M.cloneWithoutOffset(i(this,b).queryNode)})}clearOrderBy(){return new C({...i(this,b),queryNode:M.cloneWithoutOrderBy(i(this,b).queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new C({...i(this,b)})}$castTo(){return new C(i(this,b))}$narrowType(){return new C(i(this,b))}$assertType(){return new C(i(this,b))}withPlugin(e){return new C({...i(this,b),executor:i(this,b).executor.withPlugin(e)})}toOperationNode(){return i(this,b).executor.transformQuery(i(this,b).queryNode,i(this,b).queryId)}compile(){return i(this,b).executor.compileQuery(this.toOperationNode(),i(this,b).queryId)}async execute(){const e=this.compile();return(await i(this,b).executor.executeQuery(e,i(this,b).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Nn){const r=await this.executeTakeFirst();if(r===void 0)throw wn(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,b).executor.stream(r,e,i(this,b).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new C({...i(this,b),queryNode:_.cloneWithExplain(i(this,b).queryNode,e,r)}).execute()}};b=new WeakMap;let bi=C;F(bi,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Uh{constructor(e,r){N(this,Qr,void 0);N(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 Rt.create(i(this,Qr).toOperationNode(),te.create(i(this,Ur)))}}Qr=new WeakMap,Ur=new WeakMap;const Sr=a({is(t){return t.kind==="ParensNode"},create(t){return a({kind:"ParensNode",node:t})}}),ro=class ro{constructor(e){N(this,Mt,void 0);g(this,Mt,e)}get expressionType(){}as(e){return new Vs(this,e)}or(...e){return new js(rr.create(i(this,Mt),We(e)))}and(...e){return new $s(tr.create(i(this,Mt),We(e)))}$castTo(){return new ro(i(this,Mt))}toOperationNode(){return i(this,Mt)}};Mt=new WeakMap;let ne=ro;class Vs{constructor(e,r){N(this,Jr,void 0);N(this,Ft,void 0);g(this,Jr,e),g(this,Ft,r)}get expression(){return i(this,Jr)}get alias(){return i(this,Ft)}toOperationNode(){return Rt.create(i(this,Jr).toOperationNode(),je(i(this,Ft))?i(this,Ft).toOperationNode():te.create(i(this,Ft)))}}Jr=new WeakMap,Ft=new WeakMap;const Zn=class Zn{constructor(e){N(this,cr,void 0);g(this,cr,e)}get expressionType(){}as(e){return new Vs(this,e)}or(...e){return new Zn(rr.create(i(this,cr),We(e)))}$castTo(){return new Zn(i(this,cr))}toOperationNode(){return Sr.create(i(this,cr))}};cr=new WeakMap;let js=Zn;const es=class es{constructor(e){N(this,lr,void 0);g(this,lr,e)}get expressionType(){}as(e){return new Vs(this,e)}and(...e){return new es(tr.create(i(this,lr),We(e)))}$castTo(){return new es(i(this,lr))}toOperationNode(){return Sr.create(i(this,lr))}};lr=new WeakMap;let $s=es;const Er=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})}}),Jh=a({is(t){return t.kind==="FunctionNode"},create(t,e){return a({kind:"FunctionNode",func:t,arguments:e})}}),Vr=class Vr{constructor(e){N(this,Be,void 0);g(this,Be,a(e))}get expressionType(){}as(e){return new Vh(this,e)}distinct(){return new Vr({...i(this,Be),aggregateFunctionNode:Er.cloneWithDistinct(i(this,Be).aggregateFunctionNode)})}filterWhere(...e){return new Vr({...i(this,Be),aggregateFunctionNode:Er.cloneWithFilter(i(this,Be).aggregateFunctionNode,We(e))})}filterWhereRef(e,r,u){return new Vr({...i(this,Be),aggregateFunctionNode:Er.cloneWithFilter(i(this,Be).aggregateFunctionNode,bt(e,r,u))})}over(e){const r=Lh();return new Vr({...i(this,Be),aggregateFunctionNode:Er.cloneWithOver(i(this,Be).aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return i(this,Be).aggregateFunctionNode}};Be=new WeakMap;let gi=Vr;F(gi,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class Vh{constructor(e,r){N(this,jr,void 0);N(this,$r,void 0);g(this,jr,e),g(this,$r,r)}get expression(){return i(this,jr)}get alias(){return i(this,$r)}toOperationNode(){return Rt.create(i(this,jr).toOperationNode(),te.create(i(this,$r)))}}jr=new WeakMap,$r=new WeakMap;function da(){const t=(r,u)=>new ne(Jh.create(r,fi(u))),e=(r,u)=>new gi({aggregateFunctionNode:Er.create(r,u?fi(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 gi({aggregateFunctionNode:Er.create("count",yi(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}const jh=a({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return a({kind:"UnaryOperationNode",operator:t,operand:e})}});function $h(t,e){return jh.create(di.create(t),wt(e))}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})}}),ht=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})}});class fa{constructor(e){N(this,Gr,void 0);g(this,Gr,a(e))}when(...e){return new pa({...i(this,Gr),node:ht.cloneWithWhen(i(this,Gr).node,Gs.create(We(e)))})}}Gr=new WeakMap;class pa{constructor(e){N(this,zr,void 0);g(this,zr,a(e))}then(e){return new Gh({...i(this,zr),node:ht.cloneWithThen(i(this,zr).node,vt(e))})}}zr=new WeakMap;class Gh{constructor(e){N(this,ct,void 0);g(this,ct,a(e))}when(...e){return new pa({...i(this,ct),node:ht.cloneWithWhen(i(this,ct).node,Gs.create(We(e)))})}else(e){return new zh({...i(this,ct),node:ht.cloneWith(i(this,ct).node,{else:vt(e)})})}end(){return new ne(ht.cloneWith(i(this,ct).node,{isStatement:!1}))}endCase(){return new ne(ht.cloneWith(i(this,ct).node,{isStatement:!0}))}}ct=new WeakMap;class zh{constructor(e){N(this,Kr,void 0);g(this,Kr,a(e))}end(){return new ne(ht.cloneWith(i(this,Kr).node,{isStatement:!1}))}endCase(){return new ne(ht.cloneWith(i(this,Kr).node,{isStatement:!0}))}}Kr=new WeakMap;const Kh=a({is(t){return t.kind==="JSONPathLegNode"},create(t,e){return a({kind:"JSONPathLegNode",type:t,value:e})}});class zs{constructor(e){N(this,Li);N(this,Qt,void 0);g(this,Qt,e)}at(e){return V(this,Li,Eo).call(this,"ArrayLocation",e)}key(e){return V(this,Li,Eo).call(this,"Member",e)}}Qt=new WeakMap,Li=new WeakSet,Eo=function(e,r){return new Hh(_s.cloneWithTraversal(i(this,Qt),Ls.is(i(this,Qt).traversal)?Ls.cloneWithLeg(i(this,Qt).traversal,Kh.create(e,r)):Qo.cloneWithValue(i(this,Qt).traversal,Xe.createImmediate(r))))};class Hh extends zs{constructor(r){super(r);N(this,Hr,void 0);g(this,Hr,r)}get expressionType(){}as(r){return new Yh(this,r)}$castTo(){return new zs(i(this,Hr))}toOperationNode(){return i(this,Hr)}}Hr=new WeakMap;class Yh{constructor(e,r){N(this,Yr,void 0);N(this,Ut,void 0);g(this,Yr,e),g(this,Ut,r)}get expression(){return i(this,Yr)}get alias(){return i(this,Ut)}toOperationNode(){return Rt.create(i(this,Yr).toOperationNode(),je(i(this,Ut))?i(this,Ut).toOperationNode():te.create(i(this,Ut)))}}Yr=new WeakMap,Ut=new WeakMap;function Ks(t=Js){function e(d,v,x){return new ne(dn(d,v,x))}function r(d,v){return new ne($h(d,v))}const u=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(d){return new bi({queryId:K(),executor:t,queryNode:M.create(xi(d))})},case(d){return new fa({node:ht.create($(d)?void 0:wt(d))})},ref(d,v){return $(v)?new ne(ir(d)):new zs(Xu(d,v))},val(d){return new ne($o(d))},cmpr(d,v,x){return new ne(dn(d,v,x))},bxp(d,v,x){return new ne(dn(d,v,x))},unary:r,not(d){return r("not",d)},exists(d){return r("exists",d)},neg(d){return r("-",d)},and(d){if(d.length===0)return new ne(Xe.createImmediate(!0));if(d.length===1)return new ne(d[0].toOperationNode());let v=tr.create(d[0].toOperationNode(),d[1].toOperationNode());for(let x=2;xOi(e)):[Oi(t)]}function Oi(t){return L(t)?Xh(t):ma(t)}function Xh(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(ya);return Rt.create(Ae(r),te.create(u))}else return Ae(t)}function Ae(t){const e=".";if(t.includes(e)){const[r,u]=t.split(e).map(ya);return _t.createWithSchema(r,u)}else return _t.create(t)}function ya(t){return t.trim()}const Na=a({is(t){return t.kind==="AddColumnNode"},create(t){return a({kind:"AddColumnNode",column:t})}}),se=a({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return a({kind:"ColumnDefinitionNode",column:ie.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})}}),wa=a({is(t){return t.kind==="DropColumnNode"},create(t){return a({kind:"DropColumnNode",column:ie.create(t)})}}),va=a({is(t){return t.kind==="RenameColumnNode"},create(t,e){return a({kind:"RenameColumnNode",column:ie.create(t),renameTo:ie.create(e)})}}),Hs=a({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return a({kind:"CheckConstraintNode",expression:t,name:e?te.create(e):void 0})}}),Zh=["no action","restrict","cascade","set null","set default"],kn=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 ba(t){return je(t)?t.toOperationNode():Xe.createImmediate(t)}const In=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})}}),ec=a({is(t){return t.kind==="DefaultValueNode"},create(t){return a({kind:"DefaultValueNode",defaultValue:t})}});function Tn(t){if(Zh.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const Ne=class Ne{constructor(e){N(this,G,void 0);g(this,G,e)}autoIncrement(){return new Ne(se.cloneWith(i(this,G),{autoIncrement:!0}))}primaryKey(){return new Ne(se.cloneWith(i(this,G),{primaryKey:!0}))}references(e){const r=ir(e);if(!r.table||Rs.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new Ne(se.cloneWith(i(this,G),{references:kn.create(r.table,[r.column])}))}onDelete(e){if(!i(this,G).references)throw new Error("on delete constraint can only be added for foreign keys");return new Ne(se.cloneWith(i(this,G),{references:kn.cloneWithOnDelete(i(this,G).references,Tn(e))}))}onUpdate(e){if(!i(this,G).references)throw new Error("on update constraint can only be added for foreign keys");return new Ne(se.cloneWith(i(this,G),{references:kn.cloneWithOnUpdate(i(this,G).references,Tn(e))}))}unique(){return new Ne(se.cloneWith(i(this,G),{unique:!0}))}notNull(){return new Ne(se.cloneWith(i(this,G),{notNull:!0}))}unsigned(){return new Ne(se.cloneWith(i(this,G),{unsigned:!0}))}defaultTo(e){return new Ne(se.cloneWith(i(this,G),{defaultTo:ec.create(ba(e))}))}check(e){return new Ne(se.cloneWith(i(this,G),{check:Hs.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new Ne(se.cloneWith(i(this,G),{generated:In.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new Ne(se.cloneWith(i(this,G),{generated:In.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new Ne(se.cloneWith(i(this,G),{generated:In.create({identity:!0,byDefault:!0})}))}stored(){if(!i(this,G).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new Ne(se.cloneWith(i(this,G),{generated:In.cloneWith(i(this,G).generated,{stored:!0})}))}modifyFront(e){return new Ne(se.cloneWithFrontModifier(i(this,G),e.toOperationNode()))}modifyEnd(e){return new Ne(se.cloneWithEndModifier(i(this,G),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return i(this,G)}};G=new WeakMap;let Lt=Ne;F(Lt,"don't await ColumnDefinitionBuilder instances directly.");const ga=a({is(t){return t.kind==="ModifyColumnNode"},create(t){return a({kind:"ModifyColumnNode",column:t})}}),tc=a({is(t){return t.kind==="DataTypeNode"},create(t){return a({kind:"DataTypeNode",dataType:t})}});function Dr(t){return je(t)?t.toOperationNode():tc.create(t)}const Sn=a({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,u){return a({kind:"ForeignKeyConstraintNode",columns:t,references:kn.create(e,r),name:u?te.create(u):void 0})},cloneWith(t,e){return a({...t,...e})}}),ts=class ts{constructor(e){N(this,dr,void 0);g(this,dr,e)}onDelete(e){return new ts(Sn.cloneWith(i(this,dr),{onDelete:Tn(e)}))}onUpdate(e){return new ts(Sn.cloneWith(i(this,dr),{onUpdate:Tn(e)}))}$call(e){return e(this)}toOperationNode(){return i(this,dr)}};dr=new WeakMap;let qi=ts;F(qi,"don't await ForeignKeyConstraintBuilder instances directly.");const Ys=a({is(t){return t.kind==="AddConstraintNode"},create(t){return a({kind:"AddConstraintNode",constraint:t})}}),xa=a({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return a({kind:"UniqueConstraintNode",columns:a(t.map(ie.create)),name:e?te.create(e):void 0})}}),En=a({is(t){return t.kind==="DropConstraintNode"},create(t){return a({kind:"DropConstraintNode",constraintName:te.create(t)})},cloneWith(t,e){return a({...t,...e})}}),Ci=a({is(t){return t.kind==="AlterColumnNode"},create(t,e,r){return a({kind:"AlterColumnNode",column:ie.create(t),[e]:r})}});class Xs{constructor(e){N(this,xt,void 0);g(this,xt,e)}setDataType(e){return new Wi(Ci.create(i(this,xt),"dataType",Dr(e)))}setDefault(e){return new Wi(Ci.create(i(this,xt),"setDefault",ba(e)))}dropDefault(){return new Wi(Ci.create(i(this,xt),"dropDefault",!0))}setNotNull(){return new Wi(Ci.create(i(this,xt),"setNotNull",!0))}dropNotNull(){return new Wi(Ci.create(i(this,xt),"dropNotNull",!0))}$call(e){return e(this)}}xt=new WeakMap;class Wi{constructor(e){N(this,Pi,void 0);g(this,Pi,e)}toOperationNode(){return i(this,Pi)}}Pi=new WeakMap;class ki{constructor(e){N(this,rt,void 0);g(this,rt,a(e))}toOperationNode(){return i(this,rt).executor.transformQuery(i(this,rt).node,i(this,rt).queryId)}compile(){return i(this,rt).executor.compileQuery(this.toOperationNode(),i(this,rt).queryId)}async execute(){await i(this,rt).executor.executeQuery(this.compile(),i(this,rt).queryId)}}rt=new WeakMap,F(ki,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const rs=class rs{constructor(e){N(this,qe,void 0);g(this,qe,a(e))}onDelete(e){return new rs({...i(this,qe),constraintBuilder:i(this,qe).constraintBuilder.onDelete(e)})}onUpdate(e){return new rs({...i(this,qe),constraintBuilder:i(this,qe).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return i(this,qe).executor.transformQuery(le.cloneWithTableProps(i(this,qe).node,{addConstraint:Ys.create(i(this,qe).constraintBuilder.toOperationNode())}),i(this,qe).queryId)}compile(){return i(this,qe).executor.compileQuery(this.toOperationNode(),i(this,qe).queryId)}async execute(){await i(this,qe).executor.executeQuery(this.compile(),i(this,qe).queryId)}};qe=new WeakMap;let An=rs;F(An,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const Bi=class Bi{constructor(e){N(this,fe,void 0);g(this,fe,a(e))}ifExists(){return new Bi({...i(this,fe),node:le.cloneWithTableProps(i(this,fe).node,{dropConstraint:En.cloneWith(i(this,fe).node.dropConstraint,{ifExists:!0})})})}cascade(){return new Bi({...i(this,fe),node:le.cloneWithTableProps(i(this,fe).node,{dropConstraint:En.cloneWith(i(this,fe).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new Bi({...i(this,fe),node:le.cloneWithTableProps(i(this,fe).node,{dropConstraint:En.cloneWith(i(this,fe).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return i(this,fe).executor.transformQuery(i(this,fe).node,i(this,fe).queryId)}compile(){return i(this,fe).executor.compileQuery(this.toOperationNode(),i(this,fe).queryId)}async execute(){await i(this,fe).executor.executeQuery(this.compile(),i(this,fe).queryId)}};fe=new WeakMap;let Dn=Bi;F(Dn,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class Oa{constructor(e){N(this,X,void 0);g(this,X,a(e))}renameTo(e){return new ki({...i(this,X),node:le.cloneWithTableProps(i(this,X).node,{renameTo:Ae(e)})})}setSchema(e){return new ki({...i(this,X),node:le.cloneWithTableProps(i(this,X).node,{setSchema:te.create(e)})})}alterColumn(e,r){const u=r(new Xs(e));return new Pt({...i(this,X),node:le.cloneWithColumnAlteration(i(this,X).node,u.toOperationNode())})}dropColumn(e){return new Pt({...i(this,X),node:le.cloneWithColumnAlteration(i(this,X).node,wa.create(e))})}renameColumn(e,r){return new Pt({...i(this,X),node:le.cloneWithColumnAlteration(i(this,X).node,va.create(e,r))})}addColumn(e,r,u=Wr){const d=u(new Lt(se.create(e,Dr(r))));return new Pt({...i(this,X),node:le.cloneWithColumnAlteration(i(this,X).node,Na.create(d.toOperationNode()))})}modifyColumn(e,r,u=Wr){const d=u(new Lt(se.create(e,Dr(r))));return new Pt({...i(this,X),node:le.cloneWithColumnAlteration(i(this,X).node,ga.create(d.toOperationNode()))})}addUniqueConstraint(e,r){return new ki({...i(this,X),node:le.cloneWithTableProps(i(this,X).node,{addConstraint:Ys.create(xa.create(r,e))})})}addCheckConstraint(e,r){return new ki({...i(this,X),node:le.cloneWithTableProps(i(this,X).node,{addConstraint:Ys.create(Hs.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,u,d){return new An({...i(this,X),constraintBuilder:new qi(Sn.create(r.map(ie.create),Ae(u),d.map(ie.create),e))})}dropConstraint(e){return new Dn({...i(this,X),node:le.cloneWithTableProps(i(this,X).node,{dropConstraint:En.create(e)})})}$call(e){return e(this)}}X=new WeakMap;const fr=class fr{constructor(e){N(this,oe,void 0);g(this,oe,a(e))}alterColumn(e,r){const u=r(new Xs(e));return new fr({...i(this,oe),node:le.cloneWithColumnAlteration(i(this,oe).node,u.toOperationNode())})}dropColumn(e){return new fr({...i(this,oe),node:le.cloneWithColumnAlteration(i(this,oe).node,wa.create(e))})}renameColumn(e,r){return new fr({...i(this,oe),node:le.cloneWithColumnAlteration(i(this,oe).node,va.create(e,r))})}addColumn(e,r,u=Wr){const d=u(new Lt(se.create(e,Dr(r))));return new fr({...i(this,oe),node:le.cloneWithColumnAlteration(i(this,oe).node,Na.create(d.toOperationNode()))})}modifyColumn(e,r,u=Wr){const d=u(new Lt(se.create(e,Dr(r))));return new fr({...i(this,oe),node:le.cloneWithColumnAlteration(i(this,oe).node,ga.create(d.toOperationNode()))})}toOperationNode(){return i(this,oe).executor.transformQuery(i(this,oe).node,i(this,oe).queryId)}compile(){return i(this,oe).executor.compileQuery(this.toOperationNode(),i(this,oe).queryId)}async execute(){await i(this,oe).executor.executeQuery(this.compile(),i(this,oe).queryId)}};oe=new WeakMap;let Pt=fr;F(Oa,"don't await AlterTableBuilder instances"),F(Xs,"don't await AlterColumnBuilder instances"),F(Pt,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class qa extends Us{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const lt=class lt{constructor(e){N(this,z,void 0);g(this,z,a(e))}ifNotExists(){return new lt({...i(this,z),node:At.cloneWith(i(this,z).node,{ifNotExists:!0})})}unique(){return new lt({...i(this,z),node:At.cloneWith(i(this,z).node,{unique:!0})})}on(e){return new lt({...i(this,z),node:At.cloneWith(i(this,z).node,{table:Ae(e)})})}column(e){return new lt({...i(this,z),node:At.cloneWithColumns(i(this,z).node,[Vo(e)])})}columns(e){return new lt({...i(this,z),node:At.cloneWithColumns(i(this,z).node,e.map(Vo))})}expression(e){return new lt({...i(this,z),node:At.cloneWithColumns(i(this,z).node,[e.toOperationNode()])})}using(e){return new lt({...i(this,z),node:At.cloneWith(i(this,z).node,{using:Ce.createWithSql(e)})})}where(...e){const r=new qa;return new lt({...i(this,z),node:_.cloneWithWhere(i(this,z).node,r.transformNode(We(e)))})}$call(e){return e(this)}toOperationNode(){return i(this,z).executor.transformQuery(i(this,z).node,i(this,z).queryId)}compile(){return i(this,z).executor.compileQuery(this.toOperationNode(),i(this,z).queryId)}async execute(){await i(this,z).executor.executeQuery(this.compile(),i(this,z).queryId)}};z=new WeakMap;let Rn=lt;F(Rn,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const io=class io{constructor(e){N(this,Me,void 0);g(this,Me,a(e))}ifNotExists(){return new io({...i(this,Me),node:Lo.cloneWith(i(this,Me).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Me).executor.transformQuery(i(this,Me).node,i(this,Me).queryId)}compile(){return i(this,Me).executor.compileQuery(this.toOperationNode(),i(this,Me).queryId)}async execute(){await i(this,Me).executor.executeQuery(this.compile(),i(this,Me).queryId)}};Me=new WeakMap;let _n=io;F(_n,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const rc=a({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return a({kind:"PrimaryKeyConstraintNode",columns:a(t.map(ie.create)),name:e?te.create(e):void 0})}});function ic(t){if(Qu.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const $e=class $e{constructor(e){N(this,Q,void 0);g(this,Q,a(e))}temporary(){return new $e({...i(this,Q),node:Ye.cloneWith(i(this,Q).node,{temporary:!0})})}onCommit(e){return new $e({...i(this,Q),node:Ye.cloneWith(i(this,Q).node,{onCommit:ic(e)})})}ifNotExists(){return new $e({...i(this,Q),node:Ye.cloneWith(i(this,Q).node,{ifNotExists:!0})})}addColumn(e,r,u=Wr){const d=u(new Lt(se.create(e,Dr(r))));return new $e({...i(this,Q),node:Ye.cloneWithColumn(i(this,Q).node,d.toOperationNode())})}addPrimaryKeyConstraint(e,r){return new $e({...i(this,Q),node:Ye.cloneWithConstraint(i(this,Q).node,rc.create(r,e))})}addUniqueConstraint(e,r){return new $e({...i(this,Q),node:Ye.cloneWithConstraint(i(this,Q).node,xa.create(r,e))})}addCheckConstraint(e,r){return new $e({...i(this,Q),node:Ye.cloneWithConstraint(i(this,Q).node,Hs.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,u,d,v=Wr){const x=v(new qi(Sn.create(r.map(ie.create),Ae(u),d.map(ie.create),e)));return new $e({...i(this,Q),node:Ye.cloneWithConstraint(i(this,Q).node,x.toOperationNode())})}modifyFront(e){return new $e({...i(this,Q),node:Ye.cloneWithFrontModifier(i(this,Q).node,e.toOperationNode())})}modifyEnd(e){return new $e({...i(this,Q),node:Ye.cloneWithEndModifier(i(this,Q).node,e.toOperationNode())})}$call(e){return e(this)}toOperationNode(){return i(this,Q).executor.transformQuery(i(this,Q).node,i(this,Q).queryId)}compile(){return i(this,Q).executor.compileQuery(this.toOperationNode(),i(this,Q).queryId)}async execute(){await i(this,Q).executor.executeQuery(this.compile(),i(this,Q).queryId)}};Q=new WeakMap;let Ln=$e;F(Ln,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const Mi=class Mi{constructor(e){N(this,be,void 0);g(this,be,a(e))}on(e){return new Mi({...i(this,be),node:hn.cloneWith(i(this,be).node,{table:Ae(e)})})}ifExists(){return new Mi({...i(this,be),node:hn.cloneWith(i(this,be).node,{ifExists:!0})})}cascade(){return new Mi({...i(this,be),node:hn.cloneWith(i(this,be).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,be).executor.transformQuery(i(this,be).node,i(this,be).queryId)}compile(){return i(this,be).executor.compileQuery(this.toOperationNode(),i(this,be).queryId)}async execute(){await i(this,be).executor.executeQuery(this.compile(),i(this,be).queryId)}};be=new WeakMap;let Pn=Mi;F(Pn,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const is=class is{constructor(e){N(this,ke,void 0);g(this,ke,a(e))}ifExists(){return new is({...i(this,ke),node:Ts.cloneWith(i(this,ke).node,{ifExists:!0})})}cascade(){return new is({...i(this,ke),node:Ts.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)}};ke=new WeakMap;let Bn=is;F(Bn,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const ns=class ns{constructor(e){N(this,Ie,void 0);g(this,Ie,a(e))}ifExists(){return new ns({...i(this,Ie),node:Ss.cloneWith(i(this,Ie).node,{ifExists:!0})})}cascade(){return new ns({...i(this,Ie),node:Ss.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)}};Ie=new WeakMap;let Mn=ns;F(Mn,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const Bt=a({is(t){return t.kind==="CreateViewNode"},create(t){return a({kind:"CreateViewNode",name:Dt.create(t)})},cloneWith(t,e){return a({...t,...e})}});class nc{constructor(){N(this,ss,new qa)}transformQuery(e){return i(this,ss).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}ss=new WeakMap;const Jt=class Jt{constructor(e){N(this,re,void 0);g(this,re,a(e))}temporary(){return new Jt({...i(this,re),node:Bt.cloneWith(i(this,re).node,{temporary:!0})})}materialized(){return new Jt({...i(this,re),node:Bt.cloneWith(i(this,re).node,{materialized:!0})})}ifNotExists(){return new Jt({...i(this,re),node:Bt.cloneWith(i(this,re).node,{ifNotExists:!0})})}orReplace(){return new Jt({...i(this,re),node:Bt.cloneWith(i(this,re).node,{orReplace:!0})})}columns(e){return new Jt({...i(this,re),node:Bt.cloneWith(i(this,re).node,{columns:e.map(Jo)})})}as(e){const r=e.withPlugin(new nc).toOperationNode();return new Jt({...i(this,re),node:Bt.cloneWith(i(this,re).node,{as:r})})}$call(e){return e(this)}toOperationNode(){return i(this,re).executor.transformQuery(i(this,re).node,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)}};re=new WeakMap;let Fn=Jt;F(Fn,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const Qn=a({is(t){return t.kind==="DropViewNode"},create(t){return a({kind:"DropViewNode",name:Dt.create(t)})},cloneWith(t,e){return a({...t,...e})}}),Fi=class Fi{constructor(e){N(this,ge,void 0);g(this,ge,a(e))}materialized(){return new Fi({...i(this,ge),node:Qn.cloneWith(i(this,ge).node,{materialized:!0})})}ifExists(){return new Fi({...i(this,ge),node:Qn.cloneWith(i(this,ge).node,{ifExists:!0})})}cascade(){return new Fi({...i(this,ge),node:Qn.cloneWith(i(this,ge).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,ge).executor.transformQuery(i(this,ge).node,i(this,ge).queryId)}compile(){return i(this,ge).executor.compileQuery(this.toOperationNode(),i(this,ge).queryId)}async execute(){await i(this,ge).executor.executeQuery(this.compile(),i(this,ge).queryId)}};ge=new WeakMap;let Un=Fi;F(Un,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const Ca=a({is(t){return t.kind==="CreateTypeNode"},create(t){return a({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return a({...t,enum:Bs.create(e.map(r=>Xe.createImmediate(r)))})}}),no=class no{constructor(e){N(this,Fe,void 0);g(this,Fe,a(e))}toOperationNode(){return i(this,Fe).executor.transformQuery(i(this,Fe).node,i(this,Fe).queryId)}asEnum(e){return new no({...i(this,Fe),node:Ca.cloneWithEnum(i(this,Fe).node,e)})}$call(e){return e(this)}compile(){return i(this,Fe).executor.compileQuery(this.toOperationNode(),i(this,Fe).queryId)}async execute(){await i(this,Fe).executor.executeQuery(this.compile(),i(this,Fe).queryId)}};Fe=new WeakMap;let Jn=no;F(Jn,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const Wa=a({is(t){return t.kind==="DropTypeNode"},create(t){return a({kind:"DropTypeNode",name:t})},cloneWith(t,e){return a({...t,...e})}}),so=class so{constructor(e){N(this,Qe,void 0);g(this,Qe,a(e))}ifExists(){return new so({...i(this,Qe),node:Wa.cloneWith(i(this,Qe).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Qe).executor.transformQuery(i(this,Qe).node,i(this,Qe).queryId)}compile(){return i(this,Qe).executor.compileQuery(this.toOperationNode(),i(this,Qe).queryId)}async execute(){await i(this,Qe).executor.executeQuery(this.compile(),i(this,Qe).queryId)}};Qe=new WeakMap;let Vn=so;F(Vn,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function ka(t){const e=".";if(t.includes(e)){const r=t.split(e).map(sc);if(r.length===2)return Dt.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return Dt.create(t)}function sc(t){return t.trim()}const Qi=class Qi{constructor(e){N(this,we,void 0);g(this,we,e)}createTable(e){return new Ln({queryId:K(),executor:i(this,we),node:Ye.create(Ae(e))})}dropTable(e){return new Mn({queryId:K(),executor:i(this,we),node:Ss.create(Ae(e))})}createIndex(e){return new Rn({queryId:K(),executor:i(this,we),node:At.create(e)})}dropIndex(e){return new Pn({queryId:K(),executor:i(this,we),node:hn.create(e)})}createSchema(e){return new _n({queryId:K(),executor:i(this,we),node:Lo.create(e)})}dropSchema(e){return new Bn({queryId:K(),executor:i(this,we),node:Ts.create(e)})}alterTable(e){return new Oa({queryId:K(),executor:i(this,we),node:le.create(Ae(e))})}createView(e){return new Fn({queryId:K(),executor:i(this,we),node:Bt.create(e)})}dropView(e){return new Un({queryId:K(),executor:i(this,we),node:Qn.create(e)})}createType(e){return new Jn({queryId:K(),executor:i(this,we),node:Ca.create(ka(e))})}dropType(e){return new Vn({queryId:K(),executor:i(this,we),node:Wa.create(ka(e))})}withPlugin(e){return new Qi(i(this,we).withPlugin(e))}withoutPlugins(){return new Qi(i(this,we).withoutPlugins())}withSchema(e){return new Qi(i(this,we).withPluginAtFront(new vi(e)))}};we=new WeakMap;let Zs=Qi;class oc{ref(e){return new ch(e)}}class ac{constructor(e){N(this,Xr,void 0);g(this,Xr,e)}async provideConnection(e){const r=await i(this,Xr).acquireConnection();try{return await e(r)}finally{await i(this,Xr).releaseConnection(r)}}}Xr=new WeakMap;const pr=class pr extends ca{constructor(r,u,d,v=[]){super(v);N(this,dt,void 0);N(this,ft,void 0);N(this,Ot,void 0);g(this,dt,r),g(this,ft,u),g(this,Ot,d)}get adapter(){return i(this,ft)}compileQuery(r){return i(this,dt).compileQuery(r)}provideConnection(r){return i(this,Ot).provideConnection(r)}withPlugins(r){return new pr(i(this,dt),i(this,ft),i(this,Ot),[...this.plugins,...r])}withPlugin(r){return new pr(i(this,dt),i(this,ft),i(this,Ot),[...this.plugins,r])}withPluginAtFront(r){return new pr(i(this,dt),i(this,ft),i(this,Ot),[r,...this.plugins])}withConnectionProvider(r){return new pr(i(this,dt),i(this,ft),r,[...this.plugins])}withoutPlugins(){return new pr(i(this,dt),i(this,ft),i(this,Ot),[])}};dt=new WeakMap,ft=new WeakMap,Ot=new WeakMap;let eo=pr;function Ia(){return typeof performance<"u"&&Ve(performance.now)?performance.now():Date.now()}class uc{constructor(e,r){N(this,os);N(this,as);N(this,us);N(this,hs);N(this,Ji);N(this,it,void 0);N(this,Vt,void 0);N(this,qt,void 0);N(this,mr,void 0);N(this,Ui,new WeakSet);g(this,it,e),g(this,Vt,r)}async init(){i(this,qt)||g(this,qt,i(this,it).init().catch(e=>(g(this,qt,void 0),Promise.reject(e)))),await i(this,qt)}async acquireConnection(){await this.init();const e=await i(this,it).acquireConnection();return i(this,Ui).has(e)||(V(this,os,Du).call(this)&&V(this,as,Ru).call(this,e),i(this,Ui).add(e)),e}async releaseConnection(e){await i(this,it).releaseConnection(e)}beginTransaction(e,r){return i(this,it).beginTransaction(e,r)}commitTransaction(e){return i(this,it).commitTransaction(e)}rollbackTransaction(e){return i(this,it).rollbackTransaction(e)}async destroy(){i(this,qt)&&(await i(this,qt),i(this,mr)||g(this,mr,i(this,it).destroy().catch(e=>(g(this,mr,void 0),Promise.reject(e)))),await i(this,mr))}}it=new WeakMap,Vt=new WeakMap,qt=new WeakMap,mr=new WeakMap,Ui=new WeakMap,os=new WeakSet,Du=function(){return i(this,Vt).isLevelEnabled("query")||i(this,Vt).isLevelEnabled("error")},as=new WeakSet,Ru=function(e){const r=e.executeQuery;e.executeQuery=async u=>{const d=Ia();try{return await r.call(e,u)}catch(v){throw await V(this,us,_u).call(this,v,u,d),v}finally{await V(this,hs,Lu).call(this,u,d)}}},us=new WeakSet,_u=async function(e,r,u){await i(this,Vt).error(()=>({level:"error",error:e,query:r,queryDurationMillis:V(this,Ji,Ao).call(this,u)}))},hs=new WeakSet,Lu=async function(e,r){await i(this,Vt).query(()=>({level:"query",query:e,queryDurationMillis:V(this,Ji,Ao).call(this,r)}))},Ji=new WeakSet,Ao=function(e){return Ia()-e};class Ta{constructor(e){N(this,cs);N(this,Vi,void 0);N(this,jt,void 0);g(this,Vi,e)}async provideConnection(e){for(;i(this,jt);)await i(this,jt);const r=V(this,cs,Pu).call(this,e);return g(this,jt,r.then(()=>{g(this,jt,void 0)}).catch(()=>{g(this,jt,void 0)})),r}}Vi=new WeakMap,jt=new WeakMap,cs=new WeakSet,Pu=async function(e){return await e(i(this,Vi))};const hc=["read uncommitted","read committed","repeatable read","serializable"];a(["query","error"]);class cc{constructor(e){N(this,$t,void 0);N(this,yr,void 0);Ve(e)?(g(this,yr,e),g(this,$t,a({query:!0,error:!0}))):(g(this,yr,lc),g(this,$t,a({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return i(this,$t)[e]}async query(e){i(this,$t).query&&await i(this,yr).call(this,e())}async error(e){i(this,$t).error&&await i(this,yr).call(this,e())}}$t=new WeakMap,yr=new WeakMap;function lc(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 dc(t){return at(t)&&Ve(t.compile)}const Zr=class Zr extends qn{constructor(r){let u,d;if(fc(r))u={executor:r.executor},d={...r};else{const v=r.dialect,x=v.createDriver(),W=v.createQueryCompiler(),j=v.createAdapter(),c=new cc(r.log??[]),Te=new uc(x,c),Ge=new ac(Te),pe=new eo(W,j,Ge,r.plugins??[]);u={executor:pe},d={config:r,executor:pe,dialect:v,driver:Te}}super(u);N(this,xe,void 0);g(this,xe,a(d))}get schema(){return new Zs(i(this,xe).executor)}get dynamic(){return new oc}get introspection(){return i(this,xe).dialect.createIntrospector(this.withoutPlugins())}case(r){return new fa({node:ht.create($(r)?void 0:Cn(r))})}get fn(){return da()}transaction(){return new jn({...i(this,xe)})}connection(){return new Sa({...i(this,xe)})}withPlugin(r){return new Zr({...i(this,xe),executor:i(this,xe).executor.withPlugin(r)})}withoutPlugins(){return new Zr({...i(this,xe),executor:i(this,xe).executor.withoutPlugins()})}withSchema(r){return new Zr({...i(this,xe),executor:i(this,xe).executor.withPluginAtFront(new vi(r))})}withTables(){return new Zr({...i(this,xe)})}async destroy(){await i(this,xe).driver.destroy()}get isTransaction(){return!1}getExecutor(){return i(this,xe).executor}executeQuery(r,u=K()){const d=dc(r)?r.compile():r;return this.getExecutor().executeQuery(d,u)}};xe=new WeakMap;let Ii=Zr;const ei=class ei extends Ii{constructor(r){super(r);N(this,nt,void 0);g(this,nt,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 ei({...i(this,nt),executor:i(this,nt).executor.withPlugin(r)})}withoutPlugins(){return new ei({...i(this,nt),executor:i(this,nt).executor.withoutPlugins()})}withSchema(r){return new ei({...i(this,nt),executor:i(this,nt).executor.withPluginAtFront(new vi(r))})}withTables(){return new ei({...i(this,nt)})}};nt=new WeakMap;let to=ei;function fc(t){return at(t)&&at(t.config)&&at(t.driver)&&at(t.executor)&&at(t.dialect)}class Sa{constructor(e){N(this,Nr,void 0);g(this,Nr,a(e))}async execute(e){return i(this,Nr).executor.provideConnection(async r=>{const u=i(this,Nr).executor.withConnectionProvider(new Ta(r)),d=new Ii({...i(this,Nr),executor:u});return await e(d)})}}Nr=new WeakMap,F(Sa,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const oo=class oo{constructor(e){N(this,st,void 0);g(this,st,a(e))}setIsolationLevel(e){return new oo({...i(this,st),isolationLevel:e})}async execute(e){const{isolationLevel:r,...u}=i(this,st),d={isolationLevel:r};return pc(d),i(this,st).executor.provideConnection(async v=>{const x=i(this,st).executor.withConnectionProvider(new Ta(v)),W=new to({...u,executor:x});try{await i(this,st).driver.beginTransaction(v,d);const j=await e(W);return await i(this,st).driver.commitTransaction(v),j}catch(j){throw await i(this,st).driver.rollbackTransaction(v),j}})}};st=new WeakMap;let jn=oo;F(jn,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function pc(t){if(t.isolationLevel&&!hc.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const ls=class ls{constructor(e){N(this,ti);N(this,ji);N(this,$i);N(this,De,void 0);g(this,De,a(e))}get expressionType(){}as(e){return new mc(this,e)}$castTo(){return new ls({...i(this,De)})}castTo(){return this.$castTo()}withPlugin(e){return new ls({...i(this,De),plugins:i(this,De).plugins!==void 0?a([...i(this,De).plugins,e]):a([e])})}toOperationNode(){return V(this,ji,Do).call(this,V(this,ti,Is).call(this))}compile(e){return V(this,$i,Ro).call(this,V(this,ti,Is).call(this,e))}async execute(e){const r=V(this,ti,Is).call(this,e);return r.executeQuery(V(this,$i,Ro).call(this,r),i(this,De).queryId)}};De=new WeakMap,ti=new WeakSet,Is=function(e){const r=e!==void 0?e.getExecutor():Js;return i(this,De).plugins!==void 0?r.withPlugins(i(this,De).plugins):r},ji=new WeakSet,Do=function(e){return e.transformQuery(i(this,De).rawNode,i(this,De).queryId)},$i=new WeakSet,Ro=function(e){return e.compileQuery(V(this,ji,Do).call(this,e),i(this,De).queryId)};let Ze=ls;F(Ze,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class mc{constructor(e,r){N(this,ri,void 0);N(this,Gt,void 0);g(this,ri,e),g(this,Gt,r)}get expression(){return i(this,ri)}get alias(){return i(this,Gt)}toOperationNode(){return Rt.create(i(this,ri).toOperationNode(),je(i(this,Gt))?i(this,Gt).toOperationNode():te.create(i(this,Gt)))}}ri=new WeakMap,Gt=new WeakMap;const Pe=Object.assign((t,...e)=>new Ze({queryId:K(),rawNode:Ce.create(t,(e==null?void 0:e.map(vt))??[])}),{ref(t){return new Ze({queryId:K(),rawNode:Ce.createWithChild(ir(t))})},val(t){return new Ze({queryId:K(),rawNode:Ce.createWithChild(vt(t))})},value(t){return this.val(t)},table(t){return new Ze({queryId:K(),rawNode:Ce.createWithChild(Ae(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new Ze({queryId:K(),rawNode:Ce.create(e,t.map(te.create))})},lit(t){return new Ze({queryId:K(),rawNode:Ce.createWithChild(Xe.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new Ze({queryId:K(),rawNode:Ce.createWithSql(t)})},join(t,e=Pe`, `){const r=new Array(2*t.length-1),u=e.toOperationNode();for(let d=0;d{this.nodeStack.push(e),i(this,ds)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}ds=new WeakMap;class Nc extends yc{constructor(){super(...arguments);N(this,ii,"");N(this,wr,[])}get numParameters(){return i(this,wr).length}compileQuery(r){return g(this,ii,""),g(this,wr,[]),this.visitNode(r),a({query:r,sql:this.getSql(),parameters:[...i(this,wr)]})}getSql(){return i(this,ii)}visitSelectQuery(r){const u=this.parentNode!==void 0&&!ut.is(this.parentNode)&&!Bt.is(this.parentNode)&&!la.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 v=0;v<=d;v++)this.visitNode(r[v]),vv&&this.visitNode(d[v])}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(_.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(wc[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 di.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))}visitJSONReference(r){this.visitNode(r.reference),this.visitNode(r.traversal)}visitJSONPath(r){r.inOperator&&this.visitNode(r.inOperator),this.append("'$");for(const u of r.pathLegs)this.visitNode(u);this.append("'")}visitJSONPathLeg(r){const u=r.type==="ArrayLocation";this.append(u?"[":"."),this.append(String(r.value)),u&&this.append("]")}visitJSONOperatorChain(r){for(let u=0,d=r.values.length;u"),this.visitNode(r.values[u])}append(r){g(this,ii,i(this,ii)+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 v="";for(const x of r)v+=x,x===u?v+=u:x===d&&(v+=d);return v}addParameter(r){i(this,wr).push(r)}appendImmediateValue(r){if(L(r))this.append(`'${r}'`);else if(ce(r)||hi(r))this.append(r.toString());else if(_o(r))this.append("null");else if(Mu(r))this.appendImmediateValue(r.toISOString());else if(Fu(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}ii=new WeakMap,wr=new WeakMap;const wc=a({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),vc=a({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),Rr=a({raw(t,e=[]){return a({sql:t,query:Ce.createWithSql(t),parameters:a(e)})}}),bc=/"/g;class gc extends Nc{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(bc,'""')}visitDefaultInsertValue(e){this.append("null")}}const xc="kysely_migration",Oc="kysely_migration_lock";a({__noMigrations__:!0});class qc{constructor(e){N(this,fs);N(this,ni,void 0);g(this,ni,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=i(this,ni).selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",xc).where("name","!=",Oc));const u=await r.execute();return Promise.all(u.map(({name:d})=>V(this,fs,Bu).call(this,d)))}async getMetadata(e){return{tables:await this.getTables(e)}}}ni=new WeakMap,fs=new WeakSet,Bu=async function(e){var x,W,j,c,Te,Ge;const r=i(this,ni),u=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),d=(Ge=(Te=(c=(j=(W=(x=u.sql)==null?void 0:x.split(/[\(\),]/))==null?void 0:W.find(pe=>pe.toLowerCase().includes("autoincrement")))==null?void 0:j.trimStart())==null?void 0:c.split(/\s+/))==null?void 0:Te[0])==null?void 0:Ge.replace(/["`]/g,""),v=await r.selectFrom(Pe`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:u.type==="view",columns:v.map(pe=>({name:pe.name,dataType:pe.type,isNullable:!pe.notnull,isAutoIncrementing:pe.name===d,hasDefaultValue:pe.dflt_value!=null}))}};class Cc{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Wc=class{createQueryCompiler(){return new gc}createAdapter(){return new Cc}createIntrospector(t){return new qc(t)}},kc=(_a=class{constructor(){N(this,Gi,new Ic);B(this,"connection")}async acquireConnection(){return await i(this,Gi).lock(),this.connection}async beginTransaction(t){await t.executeQuery(Rr.raw("begin"))}async commitTransaction(t){await t.executeQuery(Rr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Rr.raw("rollback"))}async releaseConnection(){i(this,Gi).unlock()}},Gi=new WeakMap,_a),Ic=class{constructor(){B(this,"promise");B(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()}},Tc=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,v=null;function x(){u&&clearTimeout(u),d=0,v=null}function W(){d>=r?(t(v),x()):(u&&clearTimeout(u),u=setTimeout(()=>{t(v),x(),u=void 0},e))}return j=>{d++,v=j,u===void 0&&d===0?(t(j),d++):W()}}var Ec=class extends kc{constructor(e){super();B(this,"config");B(this,"db");this.config=e}async init(){var e,r,u,d,v,x;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 Ac(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),await((x=(v=this.config).onCreateConnection)==null?void 0:x.call(v,this.connection))}async beginTransaction(e){await e.executeQuery(Rr.raw("begin")),e.transactionNum++}async commitTransaction(e){await e.executeQuery(Rr.raw("commit")),e.transactionNum--}async rollbackTransaction(e){await e.executeQuery(Rr.raw("rollback")),e.transactionNum--}async destroy(){var e;(e=this.db)==null||e.close()}},Ac=class extends Tc{constructor(e,r,u=!1,d=1e3,v=2e3){super();B(this,"db");B(this,"onWrite");B(this,"transactionNum",0);this.db=e,this.onWrite=r?u?Sc({func:r,maxCalls:d,delay:v}):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}}},Dc=(La=class extends Wc{constructor(e){super();N(this,zi,void 0);g(this,zi,e)}createDriver(){return new Ec(i(this,zi))}},zi=new WeakMap,La);function Rc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _c(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function u(){return this instanceof u?Reflect.construct(e,arguments,this.constructor):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 Ea={exports:{}},Lc={},Pc=Object.freeze({__proto__:null,default:Lc}),$n=_c(Pc);(function(t,e){var r=void 0,u=function(d){return r||(r=new Promise(function(v,x){var W=typeof d<"u"?d:{},j=W.onAbort;W.onAbort=function(n){x(new Error(n)),j&&j(n)},W.postRun=W.postRun||[],W.postRun.push(function(){v(W)}),t=void 0;var c;c||(c=typeof W<"u"?W:{}),c.onRuntimeInitialized=function(){function n(f,w){switch(typeof w){case"boolean":jl(f,w?1:0);break;case"number":Ul(f,w);break;case"string":Jl(f,w,-1,-1);break;case"object":if(w===null)ku(f);else if(w.length!=null){var O=ko(w);Vl(f,O,w.length,-1),Cs(O)}else ks(f,"Wrong API use : tried to return a value of an unknown type ("+w+").",-1);break;default:ku(f)}}function s(f,w){for(var O=[],k=0;k>>0),f!=null){var w=this.filename,O="/",k=w;if(O&&(O=typeof O=="string"?O:Zi(O),k=w?St(O+"/"+w):O),w=pu(!0,!0),k=Ns(k,(w!==void 0?w:438)&4095|32768,0),f){if(typeof f=="string"){O=Array(f.length);for(var R=0,J=f.length;R{si||(vr=$n,si=$n)},Z=function(n,s){return zt(),n=si.normalize(n),vr.readFileSync(n,s?void 0:"utf8")},kt=n=>(n=Z(n,!0),n.buffer||(n=new Uint8Array(n)),n),Ue=(n,s,o)=>{zt(),n=si.normalize(n),vr.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},Ct&&(kt=n=>{var s=new XMLHttpRequest;return s.open("GET",n,!1),s.responseType="arraybuffer",s.send(null),new Uint8Array(s.response)}),Ue=(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 It=c.print||console.log.bind(console),br=c.printErr||console.warn.bind(console);Object.assign(c,Te),Te=null,c.thisProgram&&(Ge=c.thisProgram);var Ki;c.wasmBinary&&(Ki=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Ht("no native wasm support detected");var ao,Pa=!1,Ba=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Hi(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 ve(n,s){return n?Hi(pt,n,s):""}function gr(n,s,o,h){if(!(0=m){var S=n.charCodeAt(++p);m=65536+((m&1023)<<10)|S&1023}if(127>=m){if(o>=h)break;s[o++]=m}else{if(2047>=m){if(o+1>=h)break;s[o++]=192|m>>6}else{if(65535>=m){if(o+2>=h)break;s[o++]=224|m>>12}else{if(o+3>=h)break;s[o++]=240|m>>18,s[o++]=128|m>>12&63}s[o++]=128|m>>6&63}s[o++]=128|m&63}}return s[o]=0,o-l}function oi(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 uo,ye,pt,ps,T,ae,ho,co;function Ma(){var n=ao.buffer;uo=n,c.HEAP8=ye=new Int8Array(n),c.HEAP16=ps=new Int16Array(n),c.HEAP32=T=new Int32Array(n),c.HEAPU8=pt=new Uint8Array(n),c.HEAPU16=new Uint16Array(n),c.HEAPU32=ae=new Uint32Array(n),c.HEAPF32=ho=new Float32Array(n),c.HEAPF64=co=new Float64Array(n)}var Kt,Fa=[],Qa=[],Ua=[];function sl(){var n=c.preRun.shift();Fa.unshift(n)}var xr=0,Yi=null;function Ht(n){throw c.onAbort&&c.onAbort(n),n="Aborted("+n+")",br(n),Pa=!0,new WebAssembly.RuntimeError(n+". Build with -sASSERTIONS for more info.")}function Ja(){return ze.startsWith("data:application/octet-stream;base64,")}var ze;if(ze="sql-wasm.wasm",!Ja()){var Va=ze;ze=c.locateFile?c.locateFile(Va,Re):Re+Va}function ja(){var n=ze;try{if(n==ze&&Ki)return new Uint8Array(Ki);if(kt)return kt(n);throw"both async and sync fetching of the wasm failed"}catch(s){Ht(s)}}function ol(){if(!Ki&&(pe||Ct)){if(typeof fetch=="function"&&!ze.startsWith("file://"))return fetch(ze,{credentials:"same-origin"}).then(function(n){if(!n.ok)throw"failed to load wasm binary file at '"+ze+"'";return n.arrayBuffer()}).catch(function(){return ja()});if(Ue)return new Promise(function(n,s){Ue(ze,function(o){n(new Uint8Array(o))},s)})}return Promise.resolve().then(function(){return ja()})}var E,ue;function lo(n){for(;0>0];case"i8":return ye[n>>0];case"i16":return ps[n>>1];case"i32":return T[n>>2];case"i64":return T[n>>2];case"float":return ho[n>>2];case"double":return co[n>>3];case"*":return ae[n>>2];default:Ht("invalid type for getValue: "+s)}return null}function Xi(n){var s="i32";switch(s.endsWith("*")&&(s="*"),s){case"i1":ye[n>>0]=0;break;case"i8":ye[n>>0]=0;break;case"i16":ps[n>>1]=0;break;case"i32":T[n>>2]=0;break;case"i64":ue=[0,(E=0,1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[n>>2]=ue[0],T[n+4>>2]=ue[1];break;case"float":ho[n>>2]=0;break;case"double":co[n>>3]=0;break;case"*":ae[n>>2]=0;break;default:Ht("invalid type for setValue: "+s)}}var fo=(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},St=n=>{var s=n.charAt(0)==="/",o=n.substr(-1)==="/";return(n=fo(n.split("/").filter(h=>!!h),!s).join("/"))||s||(n="."),n&&o&&(n+="/"),(s?"/":"")+n},al=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)},ms=n=>{if(n==="/")return"/";n=St(n),n=n.replace(/\/$/,"");var s=n.lastIndexOf("/");return s===-1?n:n.substr(s+1)};function ul(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var n=new Uint8Array(1);return()=>(crypto.getRandomValues(n),n[0])}if(Wt)try{var s=$n;return()=>s.randomBytes(1)[0]}catch{}return()=>Ht("randomDevice")}function ys(){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=fo(n.split("/").filter(h=>!!h),!s).join("/"),(s?"/":"")+n||"."}function $a(n,s){var o=Array(oi(n)+1);return n=gr(n,o,0,o.length),s&&(o.length=n),o}var Ga=[];function za(n,s){Ga[n]={input:[],output:[],Xa:s},No(n,hl)}var hl={open:function(n){var s=Ga[n.node.rdev];if(!s)throw new y(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 y(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 y(28);return s},lb:function(n,s,o){A.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 y(43);if(n=n.node.Ia,l&2||n.buffer!==uo){if((0{if(n=ys("/",n),!n)return{path:"",node:null};if(s=Object.assign({rb:!0,kb:0},s),8!!m),!1);for(var o=po,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}},yo=(n,s)=>{for(var o=0,h=0;h>>0)%Xt.length},Ya=n=>{var s=yo(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}},Or=(n,s)=>{var o;if(o=(o=ai(n,"x"))?o:n.Ga.lookup?0:2)throw new y(o,n);for(o=Xt[yo(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)},Xa=(n,s,o,h)=>(n=new wu(n,s,o,h),s=yo(n.parent.id,n.name),n.Wa=Xt[s],Xt[s]=n),fl={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Za=n=>{var s=["r","w","rw"][n&3];return n&512&&(s+="w"),s},ai=(n,s)=>{if(Ha)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},eu=(n,s)=>{try{return Or(n,s),20}catch{}return ai(n,"wx")},tu=(n,s,o)=>{try{var h=Or(n,s)}catch(l){return l.Ka}if(n=ai(n,"wx"))return n;if(o){if((h.mode&61440)!==16384)return 54;if(h===h.parent||Zi(h)==="/")return 10}else if((h.mode&61440)===16384)return 31;return 0},pl=(n=0)=>{for(;4096>=n;n++)if(!Yt[n])return n;throw new y(33)},ru=(n,s)=>(rn||(rn=function(){this.$a={}},rn.prototype={},Object.defineProperties(rn.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 rn,n),s=pl(s),n.fd=s,Yt[s]=n),ml={open:n=>{n.Ha=Ka[n.node.rdev].Ha,n.Ha.open&&n.Ha.open(n)},Ta:()=>{throw new y(70)}},No=(n,s)=>{Ka[n]={Ha:s}},iu=(n,s)=>{var o=s==="/",h=!s;if(o&&po)throw new y(10);if(!o&&!h){var l=_e(s,{rb:!1});if(s=l.path,l=l.node,l.Va)throw new y(10);if((l.mode&61440)!==16384)throw new y(54)}s={type:n,Kb:{},ub:s,Eb:[]},n=n.Ra(s),n.Ra=s,s.root=n,o?po=n:l&&(l.Va=s,l.Ra&&l.Ra.Eb.push(s))},Ns=(n,s,o)=>{var h=_e(n,{parent:!0}).node;if(n=ms(n),!n||n==="."||n==="..")throw new y(28);var l=eu(h,n);if(l)throw new y(l);if(!h.Ga.ab)throw new y(63);return h.Ga.ab(h,n,s,o)},mt=(n,s)=>Ns(n,(s!==void 0?s:511)&1023|16384,0),ws=(n,s,o)=>{typeof o>"u"&&(o=s,s=438),Ns(n,s|8192,o)},wo=(n,s)=>{if(!ys(n))throw new y(44);var o=_e(s,{parent:!0}).node;if(!o)throw new y(44);s=ms(s);var h=eu(o,s);if(h)throw new y(h);if(!o.Ga.symlink)throw new y(63);o.Ga.symlink(o,s,n)},nu=n=>{var s=_e(n,{parent:!0}).node;n=ms(n);var o=Or(s,n),h=tu(s,n,!0);if(h)throw new y(h);if(!s.Ga.rmdir)throw new y(63);if(o.Va)throw new y(10);s.Ga.rmdir(s,n),Ya(o)},su=n=>{var s=_e(n,{parent:!0}).node;if(!s)throw new y(44);n=ms(n);var o=Or(s,n),h=tu(s,n,!1);if(h)throw new y(h);if(!s.Ga.unlink)throw new y(63);if(o.Va)throw new y(10);s.Ga.unlink(s,n),Ya(o)},ou=n=>{if(n=_e(n).node,!n)throw new y(44);if(!n.Ga.readlink)throw new y(28);return ys(Zi(n.parent),n.Ga.readlink(n))},en=(n,s)=>{if(n=_e(n,{Sa:!s}).node,!n)throw new y(44);if(!n.Ga.Pa)throw new y(63);return n.Ga.Pa(n)},au=n=>en(n,!0),vs=(n,s)=>{if(n=typeof n=="string"?_e(n,{Sa:!0}).node:n,!n.Ga.Oa)throw new y(63);n.Ga.Oa(n,{mode:s&4095|n.mode&-4096,timestamp:Date.now()})},uu=(n,s)=>{if(0>s)throw new y(28);if(n=typeof n=="string"?_e(n,{Sa:!0}).node:n,!n.Ga.Oa)throw new y(63);if((n.mode&61440)===16384)throw new y(31);if((n.mode&61440)!==32768)throw new y(28);var o=ai(n,"w");if(o)throw new y(o);n.Ga.Oa(n,{size:s,timestamp:Date.now()})},ui=(n,s,o)=>{if(n==="")throw new y(44);if(typeof s=="string"){var h=fl[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=St(n);try{l=_e(n,{Sa:!(s&131072)}).node}catch{}}if(h=!1,s&64)if(l){if(s&128)throw new y(20)}else l=Ns(n,o,0),h=!0;if(!l)throw new y(44);if((l.mode&61440)===8192&&(s&=-513),s&65536&&(l.mode&61440)!==16384)throw new y(54);if(!h&&(o=l?(l.mode&61440)===40960?32:(l.mode&61440)===16384&&(Za(s)!=="r"||s&512)?31:ai(l,Za(s)):44))throw new y(o);return s&512&&!h&&uu(l,0),s&=-131713,l=ru({node:l,path:Zi(l),flags:s,seekable:!0,position:0,Ha:l.Ha,Ib:[],error:!1}),l.Ha.open&&l.Ha.open(l),!c.logReadFiles||s&1||(bs||(bs={}),n in bs||(bs[n]=1)),l},vo=n=>{if(n.fd===null)throw new y(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},hu=(n,s,o)=>{if(n.fd===null)throw new y(8);if(!n.seekable||!n.Ha.Ta)throw new y(70);if(o!=0&&o!=1&&o!=2)throw new y(28);n.position=n.Ha.Ta(n,s,o),n.Ib=[]},cu=(n,s,o,h,l)=>{if(0>h||0>l)throw new y(28);if(n.fd===null)throw new y(8);if((n.flags&2097155)===1)throw new y(8);if((n.node.mode&61440)===16384)throw new y(31);if(!n.Ha.read)throw new y(28);var p=typeof l<"u";if(!p)l=n.position;else if(!n.seekable)throw new y(70);return s=n.Ha.read(n,s,o,h,l),p||(n.position+=s),s},lu=(n,s,o,h,l)=>{if(0>h||0>l)throw new y(28);if(n.fd===null)throw new y(8);if(!(n.flags&2097155))throw new y(8);if((n.node.mode&61440)===16384)throw new y(31);if(!n.Ha.write)throw new y(28);n.seekable&&n.flags&1024&&hu(n,0,2);var p=typeof l<"u";if(!p)l=n.position;else if(!n.seekable)throw new y(70);return s=n.Ha.write(n,s,o,h,l,void 0),p||(n.position+=s),s},yl=n=>{var s,o=ui(n,o||0);n=en(n).size;var h=new Uint8Array(n);return cu(o,h,0,n,0),s=h,vo(o),s},du=()=>{y||(y=function(n,s){this.node=s,this.Hb=function(o){this.Ka=o},this.Hb(n),this.message="FS error"},y.prototype=Error(),y.prototype.constructor=y,[44].forEach(n=>{mo[n]=new y(n),mo[n].stack=""}))},fu,pu=(n,s)=>{var o=0;return n&&(o|=365),s&&(o|=146),o},tn=(n,s,o)=>{n=St("/dev/"+n);var h=pu(!!s,!!o);bo||(bo=64);var l=bo++<<8|0;No(l,{open:p=>{p.seekable=!1},close:()=>{o&&o.buffer&&o.buffer.length&&o(10)},read:(p,m,S,U)=>{for(var P=0,he=0;he{for(var P=0;P>2]=h.dev,T[o+8>>2]=h.ino,T[o+12>>2]=h.mode,ae[o+16>>2]=h.nlink,T[o+20>>2]=h.uid,T[o+24>>2]=h.gid,T[o+28>>2]=h.rdev,ue=[h.size>>>0,(E=h.size,1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+40>>2]=ue[0],T[o+44>>2]=ue[1],T[o+48>>2]=4096,T[o+52>>2]=h.blocks,ue=[Math.floor(h.atime.getTime()/1e3)>>>0,(E=Math.floor(h.atime.getTime()/1e3),1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+56>>2]=ue[0],T[o+60>>2]=ue[1],ae[o+64>>2]=0,ue=[Math.floor(h.mtime.getTime()/1e3)>>>0,(E=Math.floor(h.mtime.getTime()/1e3),1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+72>>2]=ue[0],T[o+76>>2]=ue[1],ae[o+80>>2]=0,ue=[Math.floor(h.ctime.getTime()/1e3)>>>0,(E=Math.floor(h.ctime.getTime()/1e3),1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+88>>2]=ue[0],T[o+92>>2]=ue[1],ae[o+96>>2]=0,ue=[h.ino>>>0,(E=h.ino,1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+104>>2]=ue[0],T[o+108>>2]=ue[1],0}var xs=void 0;function Os(){return xs+=4,T[xs-4>>2]}function ot(n){if(n=Yt[n],!n)throw new y(8);return n}function go(n){return ae[n>>2]+4294967296*T[n+4>>2]}function mu(n){var s=oi(n)+1,o=qs(s);return o&&gr(n,ye,o,s),o}function Nl(n,s,o){function h(U){return(U=U.toTimeString().match(/\(([A-Za-z ]+)\)$/))?U[1]:"GMT"}var l=new Date().getFullYear(),p=new Date(l,0,1),m=new Date(l,6,1);l=p.getTimezoneOffset();var S=m.getTimezoneOffset();T[n>>2]=60*Math.max(l,S),T[s>>2]=+(l!=S),n=h(p),s=h(m),n=mu(n),s=mu(s),S>2]=n,ae[o+4>>2]=s):(ae[o>>2]=s,ae[o+4>>2]=n)}function xo(n,s,o){xo.Bb||(xo.Bb=!0,Nl(n,s,o))}var yu;yu=Wt?()=>{var n=process.hrtime();return 1e3*n[0]+n[1]/1e6}:()=>performance.now();var Oo={};function Nu(){if(!qo){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",_:Ge||"./this.program"},s;for(s in Oo)Oo[s]===void 0?delete n[s]:n[s]=Oo[s];var o=[];for(s in n)o.push(s+"="+n[s]);qo=o}return qo}var qo,Zt=void 0,Co=[];function Wo(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(Co.length)o=Co.pop();else{try{Kt.grow(1)}catch(S){throw S instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":S}o=Kt.length-1}try{Kt.set(o,n)}catch(S){if(!(S instanceof TypeError))throw S;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]]]},m=1;mm?h.push(m):h.push(m%128|128,m>>7),m=0;ml?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 nn(n){Zt.delete(Kt.get(n)),Co.push(n)}function ko(n){var s=qs(n.length);return n.subarray||n.slice||(n=new Uint8Array(n)),pt.set(n,s),s}function wl(n,s,o,h){var l={string:P=>{var he=0;if(P!=null&&P!==0){var Et=(P.length<<2)+1;he=er(Et),gr(P,pt,he,Et)}return he},array:P=>{var he=er(P.length);return ye.set(P,he),he}};n=c["_"+n];var p=[],m=0;if(h)for(var S=0;S{mt("/dev"),No(259,{read:()=>0,write:(s,o,h,l)=>l}),ws("/dev/null",259),za(1280,cl),za(1536,ll),ws("/dev/tty",1280),ws("/dev/tty1",1536);var n=ul();tn("random",n),tn("urandom",n),mt("/dev/shm"),mt("/dev/shm/tmp")})(),(()=>{mt("/proc");var n=mt("/proc/self");mt("/proc/self/fd"),iu({Ra:()=>{var s=Xa(n,"fd",16895,73);return s.Ga={lookup:(o,h)=>{var l=Yt[+h];if(!l)throw new y(8);return o={parent:null,Ra:{ub:"fake"},Ga:{readlink:()=>l.path}},o.parent=o}},s}},"/proc/self/fd")})();var vl={a:function(n,s,o,h){Ht("Assertion failed: "+ve(n)+", at: "+[s?ve(s):"unknown filename",o,h?ve(h):"unknown function"])},h:function(n,s){try{return n=ve(n),vs(n,s),0}catch(o){if(typeof ee>"u"||!(o instanceof y))throw o;return-o.Ka}},H:function(n,s,o){try{if(s=ve(s),s=qr(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&&ai(h,n)?-2:0):-44}catch(l){if(typeof ee>"u"||!(l instanceof y))throw l;return-l.Ka}},i:function(n,s){try{var o=Yt[n];if(!o)throw new y(8);return vs(o.node,s),0}catch(h){if(typeof ee>"u"||!(h instanceof y))throw h;return-h.Ka}},g:function(n){try{var s=Yt[n];if(!s)throw new y(8);var o=s.node,h=typeof o=="string"?_e(o,{Sa:!0}).node:o;if(!h.Ga.Oa)throw new y(63);return h.Ga.Oa(h,{timestamp:Date.now()}),0}catch(l){if(typeof ee>"u"||!(l instanceof y))throw l;return-l.Ka}},b:function(n,s,o){xs=o;try{var h=ot(n);switch(s){case 0:var l=Os();return 0>l?-28:ru(h,l).fd;case 1:case 2:return 0;case 3:return h.flags;case 4:return l=Os(),h.flags|=l,0;case 5:return l=Os(),ps[l+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return T[vu()>>2]=28,-1;default:return-28}}catch(p){if(typeof ee>"u"||!(p instanceof y))throw p;return-p.Ka}},G:function(n,s){try{var o=ot(n);return gs(en,o.path,s)}catch(h){if(typeof ee>"u"||!(h instanceof y))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 y(8);if(!(h.flags&2097155))throw new y(28);return uu(h.node,s),0}catch(l){if(typeof ee>"u"||!(l instanceof y))throw l;return-l.Ka}},B:function(n,s){try{if(s===0)return-28;var o=oi("/")+1;return s"u"||!(h instanceof y))throw h;return-h.Ka}},E:function(n,s){try{return n=ve(n),gs(au,n,s)}catch(o){if(typeof ee>"u"||!(o instanceof y))throw o;return-o.Ka}},y:function(n,s,o){try{return s=ve(s),s=qr(n,s),s=St(s),s[s.length-1]==="/"&&(s=s.substr(0,s.length-1)),mt(s,o),0}catch(h){if(typeof ee>"u"||!(h instanceof y))throw h;return-h.Ka}},D:function(n,s,o,h){try{s=ve(s);var l=h&256;return s=qr(n,s,h&4096),gs(l?au:en,s,o)}catch(p){if(typeof ee>"u"||!(p instanceof y))throw p;return-p.Ka}},v:function(n,s,o,h){xs=h;try{s=ve(s),s=qr(n,s);var l=h?Os():0;return ui(s,o,l).fd}catch(p){if(typeof ee>"u"||!(p instanceof y))throw p;return-p.Ka}},t:function(n,s,o,h){try{if(s=ve(s),s=qr(n,s),0>=h)return-28;var l=ou(s),p=Math.min(h,oi(l)),m=ye[o+p];return gr(l,pt,o,h+1),ye[o+p]=m,p}catch(S){if(typeof ee>"u"||!(S instanceof y))throw S;return-S.Ka}},s:function(n){try{return n=ve(n),nu(n),0}catch(s){if(typeof ee>"u"||!(s instanceof y))throw s;return-s.Ka}},F:function(n,s){try{return n=ve(n),gs(en,n,s)}catch(o){if(typeof ee>"u"||!(o instanceof y))throw o;return-o.Ka}},p:function(n,s,o){try{return s=ve(s),s=qr(n,s),o===0?su(s):o===512?nu(s):Ht("Invalid flags passed to unlinkat"),0}catch(h){if(typeof ee>"u"||!(h instanceof y))throw h;return-h.Ka}},o:function(n,s,o){try{if(s=ve(s),s=qr(n,s,!0),o){var h=go(o),l=T[o+8>>2];p=1e3*h+l/1e6,o+=16,h=go(o),l=T[o+8>>2],m=1e3*h+l/1e6}else var p=Date.now(),m=p;n=p;var S=_e(s,{Sa:!0}).node;return S.Ga.Oa(S,{timestamp:Math.max(n,m)}),0}catch(U){if(typeof ee>"u"||!(U instanceof y))throw U;return-U.Ka}},e:function(){return Date.now()},j:function(n,s){n=new Date(1e3*go(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 m=ot(h);if(s&2&&!(o&2)&&(m.flags&2097155)!==2)throw new y(2);if((m.flags&2097155)===1)throw new y(2);if(!m.Ha.bb)throw new y(43);var S=m.Ha.bb(m,n,l,s,o),U=S.Fb;return T[p>>2]=S.vb,U}catch(P){if(typeof ee>"u"||!(P instanceof y))throw P;return-P.Ka}},x:function(n,s,o,h,l,p){try{var m=ot(l);if(o&2){var S=pt.slice(n,n+s);m&&m.Ha.cb&&m.Ha.cb(m,S,p,s,h)}}catch(U){if(typeof ee>"u"||!(U instanceof y))throw U;return-U.Ka}},n:xo,q:function(){return 2147483648},d:yu,c:function(n){var s=pt.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{ao.grow(l-uo.byteLength+65535>>>16),Ma();var p=1;break e}catch{}p=void 0}if(p)return!0}return!1},z:function(n,s){var o=0;return Nu().forEach(function(h,l){var p=s+o;for(l=ae[n+4*l>>2]=p,p=0;p>0]=h.charCodeAt(p);ye[l>>0]=0,o+=h.length+1}),0},A:function(n,s){var o=Nu();ae[n>>2]=o.length;var h=0;return o.forEach(function(l){h+=l.length+1}),ae[s>>2]=h,0},f:function(n){try{var s=ot(n);return vo(s),0}catch(o){if(typeof ee>"u"||!(o instanceof y))throw o;return o.Ka}},m:function(n,s){try{var o=ot(n);return ye[s>>0]=o.tty?2:(o.mode&61440)===16384?3:(o.mode&61440)===40960?7:4,0}catch(h){if(typeof ee>"u"||!(h instanceof y))throw h;return h.Ka}},u:function(n,s,o,h){try{e:{var l=ot(n);n=s;for(var p=s=0;p>2],S=ae[n+4>>2];n+=8;var U=cu(l,ye,m,S);if(0>U){var P=-1;break e}if(s+=U,U>2]=P,0}catch(he){if(typeof ee>"u"||!(he instanceof y))throw he;return he.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=ot(n);return hu(p,s,h),ue=[p.position>>>0,(E=p.position,1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[l>>2]=ue[0],T[l+4>>2]=ue[1],p.hb&&s===0&&h===0&&(p.hb=null),0}catch(m){if(typeof ee>"u"||!(m instanceof y))throw m;return m.Ka}},C:function(n){try{var s=ot(n);return s.Ha&&s.Ha.fsync?s.Ha.fsync(s):0}catch(o){if(typeof ee>"u"||!(o instanceof y))throw o;return o.Ka}},r:function(n,s,o,h){try{e:{var l=ot(n);n=s;for(var p=s=0;p>2],S=ae[n+4>>2];n+=8;var U=lu(l,ye,m,S);if(0>U){var P=-1;break e}s+=U}P=s}return ae[h>>2]=P,0}catch(he){if(typeof ee>"u"||!(he instanceof y))throw he;return he.Ka}}};(function(){function n(l){c.asm=l.exports,ao=c.asm.I,Ma(),Kt=c.asm.Aa,Qa.unshift(c.asm.J),xr--,c.monitorRunDependencies&&c.monitorRunDependencies(xr),xr==0&&Yi&&(l=Yi,Yi=null,l())}function s(l){n(l.instance)}function o(l){return ol().then(function(p){return WebAssembly.instantiate(p,h)}).then(function(p){return p}).then(l,function(p){br("failed to asynchronously prepare wasm: "+p),Ht(p)})}var h={a:vl};if(xr++,c.monitorRunDependencies&&c.monitorRunDependencies(xr),c.instantiateWasm)try{return c.instantiateWasm(h,n)}catch(l){return br("Module.instantiateWasm callback failed with error: "+l),!1}return function(){return Ki||typeof WebAssembly.instantiateStreaming!="function"||Ja()||ze.startsWith("file://")||Wt||typeof fetch!="function"?o(s):fetch(ze,{credentials:"same-origin"}).then(function(l){return WebAssembly.instantiateStreaming(l,h).then(s,function(p){return br("wasm streaming compile failed: "+p),br("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 vu=c.___errno_location=function(){return(vu=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 qs=c._malloc=function(){return(qs=c._malloc=c.asm.ya).apply(null,arguments)},Cs=c._free=function(){return(Cs=c._free=c.asm.za).apply(null,arguments)};c._RegisterExtensionFunctions=function(){return(c._RegisterExtensionFunctions=c.asm.Ba).apply(null,arguments)};var bu=c._emscripten_builtin_memalign=function(){return(bu=c._emscripten_builtin_memalign=c.asm.Ca).apply(null,arguments)},sn=c.stackSave=function(){return(sn=c.stackSave=c.asm.Da).apply(null,arguments)},on=c.stackRestore=function(){return(on=c.stackRestore=c.asm.Ea).apply(null,arguments)},er=c.stackAlloc=function(){return(er=c.stackAlloc=c.asm.Fa).apply(null,arguments)};c.UTF8ToString=ve,c.stackAlloc=er,c.stackSave=sn,c.stackRestore=on,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 wl(n,s,o,arguments)}};var Ws;Yi=function n(){Ws||gu(),Ws||(Yi=n)};function gu(){function n(){if(!Ws&&(Ws=!0,c.calledRun=!0,!Pa)){if(c.noFSInit||fu||(fu=!0,du(),c.stdin=c.stdin,c.stdout=c.stdout,c.stderr=c.stderr,c.stdin?tn("stdin",c.stdin):wo("/dev/tty","/dev/stdin"),c.stdout?tn("stdout",null,c.stdout):wo("/dev/tty","/dev/stdout"),c.stderr?tn("stderr",null,c.stderr):wo("/dev/tty1","/dev/stderr"),ui("/dev/stdin",0),ui("/dev/stdout",1),ui("/dev/stderr",1)),Ha=!1,lo(Qa),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var s=c.postRun.shift();Ua.unshift(s)}lo(Ua)}}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(Jc,Math.max(Uc,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 jc=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,Aa=new Promise((t,e)=>{const r=jc.open(Qc,1);r.onupgradeneeded=()=>r.result.createObjectStore("files",{keyPath:"name"}),r.onsuccess=()=>t(r.result),r.onerror=()=>e(r.error)});async function $c(t){const e=await Aa,r=await new Promise((u,d)=>{const x=e.transaction("files","readonly").objectStore("files").get(t);x.onsuccess=()=>u(x.result),x.onerror=()=>d(x.error)});if(r&&!_r.has(t)){const u=new Vc(r.data);return _r.set(t,u),u}else return _r.has(t)?_r.get(t):null}async function Gc(t,e){const r=await Aa;await new Promise((u,d)=>{const x=r.transaction("files","readwrite").objectStore("files").put({name:t,data:e});x.onsuccess=()=>u(!0),x.onerror=()=>d(x.error)})}async function zc(t,e){if(await Gc(t,e),_r.has(t)){const r=_r.get(t);r.truncate(0),r.write(0,e)}}var Da=t=>t==null||typeof t=="bigint"||typeof t=="string"||typeof t=="number"||typeof t=="object"&&"buffer"in t?t:typeof t=="boolean"?`${t}`:t instanceof Date?t.toISOString():JSON.stringify(t),Kc=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},Hc=class extends Us{constructor(e){super();B(this,"serializer");this.serializer=e||Da}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,v=this.serializer(u);return u===v?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...d,value:v}})}transformValue(e){return{...e,value:this.serializer(e.value)}}},Yc=class{constructor({deserializer:t,serializer:e}={}){B(this,"serializeParametersTransformer");B(this,"deserializer");B(this,"ctx");this.serializeParametersTransformer=new Hc(e),this.deserializer=t||Kc,this.ctx=new WeakMap}transformQuery({node:t,queryId:e}){return t.kind==="SelectQueryNode"&&this.ctx.set(e,t.kind),this.serializeParametersTransformer.transformNode(t)}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({result:t,queryId:e}){const{rows:r}=t,u=this.ctx.get(e);return this.ctx.delete(e),r&&u==="SelectQueryNode"?{...t,rows:await this.parseResult(r)}:t}};async function Ra(t,e,r,u,d="rowid"){await Pe` + create trigger if not exists ${Pe.raw(e)}_${Pe.raw(u)} + after ${Pe.raw(r)} + on ${Pe.table(e)} + begin + update ${Pe.table(e)} + set ${Pe.ref(u)} = datetime('now','localtime') + where ${Pe.ref(d)} = NEW.${Pe.ref(d)}; + end + `.execute(t).catch(v=>{console.error(v)})}function Xc(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 Zc(t,e,r=!1){for(const[u,d]of e){const{columns:v,property:x}=d;r&&await t.schema.dropTable(u).ifExists().execute().catch();let W=t.schema.createTable(u);const{index:j,primary:c,timestamp:Te,unique:Ge}=x||{};let pe="rowid",Ct=!1;const Wt=typeof Te=="object"&&Te.create||"createAt",Re=typeof Te=="object"&&Te.update||"updateAt";for(const[Z,Ue]of Object.entries(v)){let kt="text";const{type:vr,notNull:si,defaultTo:zt}=Ue;switch(vr){case"boolean":case"date":case"object":case"string":kt="text";break;case"increments":pe=Z;case"number":kt="integer";break;case"blob":kt="blob"}[Wt,Re].includes(Z)||(W=W.addColumn(Z,kt,It=>vr==="increments"?(Ct=!0,It.autoIncrement().primaryKey()):(si&&(It=It.notNull()),zt!==void 0&&(It=It.defaultTo(zt instanceof Function?zt(Pe):zt)),It)))}if(Te&&(W=W.addColumn(Wt,"text").addColumn(Re,"text")),!Ct&&c){const Z=Array.isArray(c);pe=Z?c[0]:c,W=W.addPrimaryKeyConstraint(`pk_${Z?c.join("_"):c}`,Z?c:[c])}if(Ge==null||Ge.forEach(Z=>{const Ue=Array.isArray(Z);pe=!c&&!Ct?Ue?Z[0]:Z:pe,W=W.addUniqueConstraint(`un_${Ue?Z.join("_"):Z}`,Ue?Z:[Z])}),await W.ifNotExists().execute(),j)for(const Z of j){const Ue=Array.isArray(Z);await t.schema.createIndex(`idx_${Ue?Z.join("_"):Z}`).on(u).columns(Ue?Z:[Z]).ifNotExists().execute()}Te&&(await Ra(t,u,"insert",Wt,pe),await Ra(t,u,"update",Re,pe))}}function el(t){function e(r){return`__precomile_${r}`}return{setParam(r){let u;return(d,v)=>{if(!u){const{parameters:x,sql:W,query:j}=r(t,e).compile();u={sql:W,query:(v==null?void 0:v(j))||{kind:j.kind},parameters:x}}return{...u,parameters:u.parameters.map(x=>typeof x=="string"&&x.startsWith("__precomile_")?Da(d[x.slice(12)]):x)}}}}}var tl=class{constructor(){B(this,"items");this.items=[]}push(t){this.items.push(t)}pop(){return this.items.pop()}peek(){return this.items[this.items.length-1]}isEmpty(){return this.items.length===0}size(){return this.items.length}},rl=class{constructor(t){B(this,"kysely");B(this,"status");B(this,"tableMap");B(this,"logger");B(this,"trxs");const{dialect:e,tables:r,dropTableBeforeInit:u,onQuery:d,plugins:v,logger:x}=t;this.logger=x;const W=v??[];W.push(new Yc),this.kysely=new Ii({dialect:e,log:j=>{var c;j.level==="error"?(c=this.logger)==null||c.error("Uncaught DB Error",j.error):d==null||d(j.query,j.queryDurationMillis)},plugins:W}),this.status=u?0:1,this.tableMap=Xc(r),this.trxs=new tl}async init(t=!1){const e=t||this.status===0;return await Zc(this.kysely,this.tableMap,e),this.status=2,this}async isEmptyTable(){var t;return this.status!==2&&await this.init(),this.status===2?!1:((t=this.logger)==null||t.error("fail to init table"),!0)}async transaction(t,e){if(!await this.isEmptyTable())return await this.kysely.transaction().execute(r=>(this.trxs.push(r),t(r))).catch(r=>{var u;e&&((u=this.logger)==null||u.error(e,r))}).finally(()=>{this.trxs.pop()})}getDB(){return this.trxs.isEmpty()?this.kysely:this.trxs.peek()}async exec(t,e){if(!await this.isEmptyTable())return t(this.getDB()).catch(r=>{var u;e&&((u=this.logger)==null||u.error(e,r))})}async execOne(t,e){const r=await this.execList(t,e);return r!=null&&r.length?r[0]:void 0}async execList(t,e){if(!await this.isEmptyTable())return t(this.getDB()).execute().catch(r=>{var u;e&&((u=this.logger)==null||u.error(e,r))})}preCompile(t){return el(t(this.kysely))}async execCompiledRows(t,e){const r=await this.execCompiled(t,e);return(r==null?void 0:r.rows)??void 0}async execCompiled(t,e){if(!await this.isEmptyTable())return this.getDB().executeQuery(t).catch(r=>{var u;e&&((u=this.logger)==null||u.error(e,r))})}async toSQL(t){return t(this.getDB()).compile()}async raw(t){if(!await this.isEmptyTable())return t(Pe).execute(this.getDB())}};async function il(t){const e=await new rl({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 nl=new Dc({async database(){const t=await Mc({locateFile:()=>Fc});return new t.Database(await $c("sqlijsWorker"))},onWrite:{func(t){console.log(`[sqljs worker] write to indexeddb, length: ${t.length}`),zc("sqlijsWorker",t)}}});onmessage=()=>{console.log("start sqljs test"),il(nl).then(t=>{t==null||t.forEach(e=>console.log("[sqlijs]",e))})}})(); diff --git a/assets/sqljsWorker-c2b6105d.js b/assets/sqljsWorker-c2b6105d.js deleted file mode 100644 index 6113a05..0000000 --- a/assets/sqljsWorker-c2b6105d.js +++ /dev/null @@ -1,12 +0,0 @@ -var Kl=Object.defineProperty;var Hl=(G,B,le)=>B in G?Kl(G,B,{enumerable:!0,configurable:!0,writable:!0,value:le}):G[B]=le;var M=(G,B,le)=>(Hl(G,typeof B!="symbol"?B+"":B,le),le),Io=(G,B,le)=>{if(!B.has(G))throw TypeError("Cannot "+le)};var i=(G,B,le)=>(Io(G,B,"read from private field"),le?le.call(G):B.get(G)),N=(G,B,le)=>{if(B.has(G))throw TypeError("Cannot add the same private member more than once");B instanceof WeakSet?B.add(G):B.set(G,le)},g=(G,B,le,ni)=>(Io(G,B,"write to private field"),ni?ni.call(G,le):B.set(G,le),le);var j=(G,B,le)=>(Io(G,B,"access private method"),le);(function(){var et,tr,Ar,X,Ci,tt,D,q,I,Dr,Vn,Rr,rr,ir,$n,Tu,jn,Su,Gn,Eu,nr,nn,ki,To,zn,Au,Ii,Z,Ti,Lr,_r,or,Si,So,b,Br,Pr,Bt,Mr,Pt,ar,ur,Fe,Qr,Ur,Jr,Vr,lt,$r,Mt,Ei,Eo,jr,Gr,Ft,z,hr,Ot,Ai,rt,Ce,pe,ee,ae,K,Qe,U,be,Te,Se,ts,ie,ge,Ue,Je,we,zr,ft,pt,qt,it,Ut,Ct,dr,Bi,rs,Du,is,Ru,ns,Lu,ss,_u,Pi,Ao,Mi,Jt,os,Bu,Vt,fr,xe,nt,pr,st,_e,Yr,Ws,Fi,Do,Qi,Ro,Xr,$t,us,Zr,mr,ei,hs,Pu,Ui,Ra,Ji,La;"use strict";function G(t){return typeof t>"u"||t===void 0}function B(t){return typeof t=="string"}function le(t){return typeof t=="number"}function ni(t){return typeof t=="boolean"}function Lo(t){return t===null}function Mu(t){return t instanceof Date}function Fu(t){return typeof t=="bigint"}function $e(t){return typeof t=="function"}function ut(t){return typeof t=="object"&&t!==null}function a(t){return Object.freeze(t)}function si(t){return Array.isArray(t)}function xr(t){return t}const de=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]})}}),re=a({is(t){return t.kind==="IdentifierNode"},create(t){return a({kind:"IdentifierNode",name:t})}}),St=a({is(t){return t.kind==="CreateIndexNode"},create(t){return a({kind:"CreateIndexNode",name:re.create(t)})},cloneWith(t,e){return a({...t,...e})},cloneWithColumns(t,e){return a({...t,columns:[...t.columns||[],...e]})}}),_o=a({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return a({kind:"CreateSchemaNode",schema:re.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Qu=["preserve rows","delete rows","drop"],Ye=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})}}),Et=a({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return a({kind:"SchemableIdentifierNode",identifier:re.create(t)})},createWithSchema(t,e){return a({kind:"SchemableIdentifierNode",schema:re.create(t),identifier:re.create(e)})}}),sn=a({is(t){return t.kind==="DropIndexNode"},create(t,e){return a({kind:"DropIndexNode",name:Et.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),ks=a({is(t){return t.kind==="DropSchemaNode"},create(t,e){return a({kind:"DropSchemaNode",schema:re.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Is=a({is(t){return t.kind==="DropTableNode"},create(t,e){return a({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return a({...t,...e})}}),At=a({is(t){return t.kind==="AliasNode"},create(t,e){return a({kind:"AliasNode",node:t,alias:e})}}),Dt=a({is(t){return t.kind==="TableNode"},create(t){return a({kind:"TableNode",table:Et.create(t)})},createWithSchema(t,e){return a({kind:"TableNode",table:Et.createWithSchema(t,e)})}});function je(t){return ut(t)&&$e(t.toOperationNode)}function Ts(t){return ut(t)&&"expressionType"in t&&je(t)}function Uu(t){return ut(t)&&"expression"in t&&B(t.alias)&&je(t)}const wt=a({is(t){return t.kind==="SelectModifierNode"},create(t){return a({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return a({kind:"SelectModifierNode",rawModifier:t})}}),Xt=a({is(t){return t.kind==="AndNode"},create(t,e){return a({kind:"AndNode",left:t,right:e})}}),Zt=a({is(t){return t.kind==="OrNode"},create(t,e){return a({kind:"OrNode",left:t,right:e})}}),Ss=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"?Xt.create(t.on,r):Zt.create(t.on,r)})}}),oi=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:Ss.create(r)})},cloneWithOn(t,e){return a({...t,on:t.on?Ss.cloneWithOperation(t.on,"And",e):Ss.create(e)})}}),Es=a({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return a({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),Bo=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp"],Ju=["+","-","*","/","%","^","&","|","#","<<",">>"],Po=["->","->>"],Mo=[...Bo,...Ju,"&&","||"],Vu=["not","-",...["exists","not exists"]],$u=[...Mo,...Po,...Vu],ai=a({is(t){return t.kind==="OperatorNode"},create(t){return a({kind:"OperatorNode",operator:t})}});function ju(t){return B(t)&&Mo.includes(t)}function Gu(t){return B(t)&&Bo.includes(t)}function Fo(t){return B(t)&&Po.includes(t)}const ne=a({is(t){return t.kind==="ColumnNode"},create(t){return a({kind:"ColumnNode",column:re.create(t)})}}),As=a({is(t){return t.kind==="SelectAllNode"},create(){return a({kind:"SelectAllNode"})}}),on=a({is(t){return t.kind==="ReferenceNode"},create(t,e){return a({kind:"ReferenceNode",table:e,column:t})},createSelectAll(t){return a({kind:"ReferenceNode",table:t,column:As.create()})}}),zu=a({is(t){return t.kind==="OrderByItemNode"},create(t,e){return a({kind:"OrderByItemNode",orderBy:t,direction:e})}}),ke=a({is(t){return t.kind==="RawNode"},create(t,e){return a({kind:"RawNode",sqlFragments:a(t),parameters:a(e)})},createWithSql(t){return ke.create([t],[])},createWithChild(t){return ke.create(["",""],[t])},createWithChildren(t){return ke.create(new Array(t.length+1).fill(""),t)}});function Ku(t){return t==="asc"||t==="desc"}function an(t,e){return zu.create(Hu(t),Yu(e))}function Hu(t){return vt(t)}function Yu(t){if(t)return t==="asc"||t==="desc"?ke.createWithSql(t):t.toOperationNode()}const Ds=a({is(t){return t.kind==="JSONReferenceNode"},create(t,e){return a({kind:"JSONReferenceNode",reference:t,traversal:e})},cloneWithTraversal(t,e){return a({...t,traversal:e})}}),Qo=a({is(t){return t.kind==="JSONOperatorChainNode"},create(t){return a({kind:"JSONOperatorChainNode",operator:t,values:a([])})},cloneWithValue(t,e){return a({...t,values:a([...t.values,e])})}}),Rs=a({is(t){return t.kind==="JSONPathNode"},create(t){return a({kind:"JSONPathNode",inOperator:t,pathLegs:a([])})},cloneWithLeg(t,e){return a({...t,pathLegs:a([...t.pathLegs,e])})}});function Uo(t){return B(t)?er(t):t.toOperationNode()}function ui(t){return si(t)?t.map(e=>vt(e)):[vt(t)]}function vt(t){return xn(t)?gn(t):Uo(t)}function Xu(t,e){const r=er(t);if(Fo(e))return Ds.create(r,Qo.create(ai.create(e)));const u=e.slice(0,-1);if(Fo(u))return Ds.create(r,Rs.create(ai.create(u)));throw new Error(`Invalid JSON operator: ${e}`)}function er(t){const e=".";if(!t.includes(e))return on.create(ne.create(t));const r=t.split(e).map(Ls);if(r.length===3)return eh(r);if(r.length===2)return th(r);throw new Error(`invalid column reference ${t}`)}function Zu(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(Ls);return At.create(er(r),re.create(u))}else return er(t)}function Jo(t){return ne.create(t)}function Vo(t){const e=" ";if(t.includes(e)){const[r,u]=t.split(e).map(Ls);if(!Ku(u))throw new Error(`invalid order direction "${u}" next to "${r}"`);return an(r,u)}else return Jo(t)}function eh(t){const[e,r,u]=t;return on.create(ne.create(u),Dt.createWithSchema(e,r))}function th(t){const[e,r]=t;return on.create(ne.create(r),Dt.create(e))}function Ls(t){return t.trim()}const $o=a({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return a({kind:"PrimitiveValueListNode",values:a([...t])})}}),_s=a({is(t){return t.kind==="ValueListNode"},create(t){return a({kind:"ValueListNode",values:a(t)})}}),Xe=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 jo(t){return si(t)?rh(t):bt(t)}function bt(t){return xn(t)?gn(t):Xe.create(t)}function rh(t){return t.some(xn)?_s.create(t.map(e=>bt(e))):$o.create(t)}function Ie(t){if(t.length>1&&!Ko(t[1]))throw new Error(`invalid comparison operator ${JSON.stringify(t[1])}`);return Go(t)}function Go(t){if(t.length===3)return un(t[0],t[1],t[2]);if(t.length===1)return ah(t[0]);throw new Error(`invalid arguments: ${JSON.stringify(t)}`)}function un(t,e,r){if(!zo(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return nh(e)&&sh(r)?oh(t,e,r):Es.create(vt(t),Bs(e),jo(r))}function gt(t,e,r){if(!Ko(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return ih(t,e,r)}function ih(t,e,r){if(!zo(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Es.create(vt(t),Bs(e),vt(r))}function zo(t){return ju(t)||Ts(t)}function Ko(t){return Gu(t)||Ts(t)}function nh(t){return t==="is"||t==="is not"}function sh(t){return Lo(t)||ni(t)}function oh(t,e,r){return Es.create(vt(t),Bs(e),Xe.createImmediate(r))}function Bs(t){if(B(t)&&$u.includes(t))return ai.create(t);if(je(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function ah(t){return $e(t)?t(Gs()).toOperationNode():je(t)?t.toOperationNode():Xe.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])})}}),Ho=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])})}}),Ps=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?Ho.cloneWithItems(t.partitionBy,e):Ho.create(e)})}}),hn=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])})}}),Yo=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])})}}),Xo=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"?Xt.create(t.having,r):Zt.create(t.having,r)})}}),F=a({is(t){return t.kind==="SelectQueryNode"},create(t,e){return a({kind:"SelectQueryNode",from:hn.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?Yo.cloneWithItems(t.groupBy,e):Yo.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?Xo.cloneWithOperation(t.having,"And",e):Xo.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})}});function Q(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}const qi=class qi{constructor(e){N(this,et,void 0);g(this,et,a(e))}on(...e){return new qi({...i(this,et),joinNode:oi.cloneWithOn(i(this,et).joinNode,Ie(e))})}onRef(e,r,u){return new qi({...i(this,et),joinNode:oi.cloneWithOn(i(this,et).joinNode,gt(e,r,u))})}onTrue(){return new qi({...i(this,et),joinNode:oi.cloneWithOn(i(this,et).joinNode,ke.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return i(this,et).joinNode}};et=new WeakMap;let cn=qi;Q(cn,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const uh=a({is(t){return t.kind==="PartitionByItemNode"},create(t){return a({kind:"PartitionByItemNode",partitionBy:t})}});function hh(t){return ui(t).map(uh.create)}const Jn=class Jn{constructor(e){N(this,tr,void 0);g(this,tr,a(e))}orderBy(e,r){return new Jn({overNode:Ps.cloneWithOrderByItem(i(this,tr).overNode,an(e,r))})}partitionBy(e){return new Jn({overNode:Ps.cloneWithPartitionByItems(i(this,tr).overNode,hh(e))})}$call(e){return e(this)}toOperationNode(){return i(this,tr).overNode}};tr=new WeakMap;let ln=Jn;Q(ln,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const hi=a({is(t){return t.kind==="SelectionNode"},create(t){return a({kind:"SelectionNode",selection:t})},createSelectAll(){return a({kind:"SelectionNode",selection:As.create()})},createSelectAllFromTable(t){return a({kind:"SelectionNode",selection:on.createSelectAll(t)})}});class ch{constructor(e){N(this,Ar,void 0);g(this,Ar,e)}get dynamicReference(){return i(this,Ar)}get refType(){}toOperationNode(){return Uo(i(this,Ar))}}Ar=new WeakMap;function lh(t){return ut(t)&&je(t)&&B(t.dynamicReference)}function ci(t){return $e(t)?ci(t(Ir())):si(t)?t.map(e=>Zo(e)):[Zo(t)]}function Zo(t){return B(t)?hi.create(Zu(t)):lh(t)?hi.create(t.toOperationNode()):hi.create(ma(t))}function li(t){return t?Array.isArray(t)?t.map(ea):[ea(t)]:[hi.createSelectAll()]}function ea(t){if(B(t))return hi.createSelectAllFromTable(Le(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const dh=a({is(t){return t.kind==="ValuesNode"},create(t){return a({kind:"ValuesNode",values:a(t)})}}),fh=a({is(t){return t.kind==="DefaultInsertValueNode"},create(){return a({kind:"DefaultInsertValueNode"})}});function ph(t){const e=$e(t)?t(Ir()):t,r=si(e)?e:a([e]);return mh(r)}function mh(t){const e=yh(t);return[a([...e.keys()].map(ne.create)),dh.create(t.map(r=>Nh(r,e)))]}function yh(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 Nh(t,e){const r=Object.keys(t),u=Array.from({length:e.size});let d=!1;for(const x of r){const W=e.get(x);if(G(W))continue;const V=t[x];(G(V)||xn(V))&&(d=!0),u[W]=V}if(r.lengthG(W)?x:bt(W)))}return $o.create(u)}const ht=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})}}),dn=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?hn.cloneWithFroms(t.from,e):hn.create(e)})},cloneWithUpdates(t,e){return a({...t,updates:t.updates?a([...t.updates,...e]):e})}}),ta=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])})}}),di=a({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return a({kind:"DeleteQueryNode",from:hn.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?ta.cloneWithTables(t.using,e):ta.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"?Xt.create(t.where,r):Zt.create(t.where,r)})}}),ra=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)})}}),wh=a({is(t){return t.kind==="ExplainNode"},create(t,e){return a({kind:"ExplainNode",format:t,options:e})}}),L=a({is(t){return F.is(t)||ht.is(t)||dn.is(t)||di.is(t)},cloneWithWhere(t,e){return a({...t,where:t.where?De.cloneWithOperation(t.where,"And",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?ra.cloneWithSelections(t.returning,e):ra.create(e)})},cloneWithoutWhere(t){return a({...t,where:void 0})},cloneWithExplain(t,e,r){return a({...t,explain:wh.create(e,r==null?void 0:r.toOperationNode())})}}),vh=a({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return a({kind:"ColumnUpdateNode",column:t,value:e})}});function Ms(t){const e=$e(t)?t(Ir()):t;return Object.entries(e).filter(([r,u])=>u!==void 0).map(([r,u])=>vh.create(ne.create(r),bt(u)))}const bh=a({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return a({kind:"OnDuplicateKeyNode",updates:t})}});class gh{constructor(e,r){M(this,"insertId");M(this,"numInsertedOrUpdatedRows");this.insertId=e,this.numInsertedOrUpdatedRows=r}}class fn extends Error{constructor(r){super("no result");M(this,"node");this.node=r}}function pn(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const Pe=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})}}),xt=class xt{constructor(e){N(this,X,void 0);g(this,X,a(e))}column(e){const r=ne.create(e);return new xt({...i(this,X),onConflictNode:Pe.cloneWith(i(this,X).onConflictNode,{columns:i(this,X).onConflictNode.columns?a([...i(this,X).onConflictNode.columns,r]):a([r])})})}columns(e){const r=e.map(ne.create);return new xt({...i(this,X),onConflictNode:Pe.cloneWith(i(this,X).onConflictNode,{columns:i(this,X).onConflictNode.columns?a([...i(this,X).onConflictNode.columns,...r]):a(r)})})}constraint(e){return new xt({...i(this,X),onConflictNode:Pe.cloneWith(i(this,X).onConflictNode,{constraint:re.create(e)})})}expression(e){return new xt({...i(this,X),onConflictNode:Pe.cloneWith(i(this,X).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new xt({...i(this,X),onConflictNode:Pe.cloneWithIndexWhere(i(this,X).onConflictNode,Ie(e))})}whereRef(e,r,u){return new xt({...i(this,X),onConflictNode:Pe.cloneWithIndexWhere(i(this,X).onConflictNode,gt(e,r,u))})}clearWhere(){return new xt({...i(this,X),onConflictNode:Pe.cloneWithoutIndexWhere(i(this,X).onConflictNode)})}doNothing(){return new ia({...i(this,X),onConflictNode:Pe.cloneWith(i(this,X).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new yn({...i(this,X),onConflictNode:Pe.cloneWith(i(this,X).onConflictNode,{updates:Ms(e)})})}$call(e){return e(this)}};X=new WeakMap;let mn=xt;Q(mn,"don't await OnConflictBuilder instances.");class ia{constructor(e){N(this,Ci,void 0);g(this,Ci,a(e))}toOperationNode(){return i(this,Ci).onConflictNode}}Ci=new WeakMap,Q(ia,"don't await OnConflictDoNothingBuilder instances.");const Wi=class Wi{constructor(e){N(this,tt,void 0);g(this,tt,a(e))}where(...e){return new Wi({...i(this,tt),onConflictNode:Pe.cloneWithUpdateWhere(i(this,tt).onConflictNode,Ie(e))})}whereRef(e,r,u){return new Wi({...i(this,tt),onConflictNode:Pe.cloneWithUpdateWhere(i(this,tt).onConflictNode,gt(e,r,u))})}clearWhere(){return new Wi({...i(this,tt),onConflictNode:Pe.cloneWithoutUpdateWhere(i(this,tt).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return i(this,tt).onConflictNode}};tt=new WeakMap;let yn=Wi;Q(yn,"don't await OnConflictUpdateBuilder instances.");const qe=class qe{constructor(e){N(this,D,void 0);g(this,D,a(e))}values(e){const[r,u]=ph(e);return new qe({...i(this,D),queryNode:ht.cloneWith(i(this,D).queryNode,{columns:r,values:u})})}columns(e){return new qe({...i(this,D),queryNode:ht.cloneWith(i(this,D).queryNode,{columns:a(e.map(ne.create))})})}expression(e){return new qe({...i(this,D),queryNode:ht.cloneWith(i(this,D).queryNode,{values:gn(e)})})}ignore(){return new qe({...i(this,D),queryNode:ht.cloneWith(i(this,D).queryNode,{ignore:!0})})}onConflict(e){return new qe({...i(this,D),queryNode:ht.cloneWith(i(this,D).queryNode,{onConflict:e(new mn({onConflictNode:Pe.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new qe({...i(this,D),queryNode:ht.cloneWith(i(this,D).queryNode,{onDuplicateKey:bh.create(Ms(e))})})}returning(e){return new qe({...i(this,D),queryNode:L.cloneWithReturning(i(this,D).queryNode,ci(e))})}returningAll(){return new qe({...i(this,D),queryNode:L.cloneWithReturning(i(this,D).queryNode,li())})}$call(e){return e(this)}$if(e,r){return e?r(this):new qe({...i(this,D)})}$castTo(){return new qe(i(this,D))}$narrowType(){return new qe(i(this,D))}$assertType(){return new qe(i(this,D))}withPlugin(e){return new qe({...i(this,D),executor:i(this,D).executor.withPlugin(e)})}toOperationNode(){return i(this,D).executor.transformQuery(i(this,D).queryNode,i(this,D).queryId)}compile(){return i(this,D).executor.compileQuery(this.toOperationNode(),i(this,D).queryId)}async execute(){const e=this.compile(),r=e.query,u=await i(this,D).executor.executeQuery(e,i(this,D).queryId);return i(this,D).executor.adapter.supportsReturning&&r.returning?u.rows:[new gh(u.insertId,u.numAffectedRows??u.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=fn){const r=await this.executeTakeFirst();if(r===void 0)throw pn(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,D).executor.stream(r,e,i(this,D).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new qe({...i(this,D),queryNode:L.cloneWithExplain(i(this,D).queryNode,e,r)}).execute()}};D=new WeakMap;let fi=qe;Q(fi,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class xh{constructor(e){M(this,"numDeletedRows");this.numDeletedRows=e}}const na=a({is(t){return t.kind==="LimitNode"},create(t){return a({kind:"LimitNode",limit:Xe.create(t)})}}),fe=class fe{constructor(e){N(this,q,void 0);g(this,q,a(e))}where(...e){return new fe({...i(this,q),queryNode:L.cloneWithWhere(i(this,q).queryNode,Ie(e))})}whereRef(e,r,u){return new fe({...i(this,q),queryNode:L.cloneWithWhere(i(this,q).queryNode,gt(e,r,u))})}clearWhere(){return new fe({...i(this,q),queryNode:L.cloneWithoutWhere(i(this,q).queryNode)})}using(e){return new fe({...i(this,q),queryNode:di.cloneWithUsing(i(this,q).queryNode,Ni(e))})}innerJoin(...e){return new fe({...i(this,q),queryNode:L.cloneWithJoin(i(this,q).queryNode,Re("InnerJoin",e))})}leftJoin(...e){return new fe({...i(this,q),queryNode:L.cloneWithJoin(i(this,q).queryNode,Re("LeftJoin",e))})}rightJoin(...e){return new fe({...i(this,q),queryNode:L.cloneWithJoin(i(this,q).queryNode,Re("RightJoin",e))})}fullJoin(...e){return new fe({...i(this,q),queryNode:L.cloneWithJoin(i(this,q).queryNode,Re("FullJoin",e))})}returning(e){return new fe({...i(this,q),queryNode:L.cloneWithReturning(i(this,q).queryNode,ci(e))})}returningAll(e){return new fe({...i(this,q),queryNode:L.cloneWithReturning(i(this,q).queryNode,li(e))})}orderBy(e,r){return new fe({...i(this,q),queryNode:di.cloneWithOrderByItem(i(this,q).queryNode,an(e,r))})}limit(e){return new fe({...i(this,q),queryNode:di.cloneWithLimit(i(this,q).queryNode,na.create(e))})}$call(e){return e(this)}$if(e,r){return e?r(this):new fe({...i(this,q)})}$castTo(){return new fe(i(this,q))}$narrowType(){return new fe(i(this,q))}$assertType(){return new fe(i(this,q))}withPlugin(e){return new fe({...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 xh(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=fn){const r=await this.executeTakeFirst();if(r===void 0)throw pn(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 fe({...i(this,q),queryNode:L.cloneWithExplain(i(this,q).queryNode,e,r)}).execute()}};q=new WeakMap;let Nn=fe;Q(Nn,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Oh{constructor(e,r){M(this,"numUpdatedRows");M(this,"numChangedRows");this.numUpdatedRows=e,this.numChangedRows=r}}const me=class me{constructor(e){N(this,I,void 0);g(this,I,a(e))}where(...e){return new me({...i(this,I),queryNode:L.cloneWithWhere(i(this,I).queryNode,Ie(e))})}whereRef(e,r,u){return new me({...i(this,I),queryNode:L.cloneWithWhere(i(this,I).queryNode,gt(e,r,u))})}clearWhere(){return new me({...i(this,I),queryNode:L.cloneWithoutWhere(i(this,I).queryNode)})}from(e){return new me({...i(this,I),queryNode:dn.cloneWithFromItems(i(this,I).queryNode,Ni(e))})}innerJoin(...e){return new me({...i(this,I),queryNode:L.cloneWithJoin(i(this,I).queryNode,Re("InnerJoin",e))})}leftJoin(...e){return new me({...i(this,I),queryNode:L.cloneWithJoin(i(this,I).queryNode,Re("LeftJoin",e))})}rightJoin(...e){return new me({...i(this,I),queryNode:L.cloneWithJoin(i(this,I).queryNode,Re("RightJoin",e))})}fullJoin(...e){return new me({...i(this,I),queryNode:L.cloneWithJoin(i(this,I).queryNode,Re("FullJoin",e))})}set(e){return new me({...i(this,I),queryNode:dn.cloneWithUpdates(i(this,I).queryNode,Ms(e))})}returning(e){return new me({...i(this,I),queryNode:L.cloneWithReturning(i(this,I).queryNode,ci(e))})}returningAll(){return new me({...i(this,I),queryNode:L.cloneWithReturning(i(this,I).queryNode,li())})}$call(e){return e(this)}$if(e,r){return e?r(this):new me({...i(this,I)})}$castTo(){return new me(i(this,I))}$narrowType(){return new me(i(this,I))}$assertType(){return new me(i(this,I))}withPlugin(e){return new me({...i(this,I),executor:i(this,I).executor.withPlugin(e)})}toOperationNode(){return i(this,I).executor.transformQuery(i(this,I).queryNode,i(this,I).queryId)}compile(){return i(this,I).executor.compileQuery(this.toOperationNode(),i(this,I).queryId)}async execute(){const e=this.compile(),r=e.query,u=await i(this,I).executor.executeQuery(e,i(this,I).queryId);return i(this,I).executor.adapter.supportsReturning&&r.returning?u.rows:[new Oh(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0),u.numChangedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=fn){const r=await this.executeTakeFirst();if(r===void 0)throw pn(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,I).executor.stream(r,e,i(this,I).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new me({...i(this,I),queryNode:L.cloneWithExplain(i(this,I).queryNode,e,r)}).execute()}};I=new WeakMap;let wn=me;Q(wn,"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})}}),sa=a({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return a({kind:"CommonTableExpressionNameNode",table:Dt.create(t),columns:e?a(e.map(ne.create)):void 0})}});function oa(t,e){const r=e(Rh());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 sa.create(r,u)}else return sa.create(t)}const vn=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])})}}),aa=["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 Wh(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",column:this.transformNode(e.column),table:this.transformNode(e.table)}}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)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}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}}Vn=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 Sh extends Fs{constructor(r){super();N(this,$n);N(this,jn);N(this,Gn);N(this,nr);N(this,ki);N(this,zn);N(this,Rr,void 0);N(this,rr,new Set);N(this,ir,new Set);g(this,Rr,r)}transformNodeImpl(r){if(!j(this,$n,Tu).call(this,r))return super.transformNodeImpl(r);const u=j(this,Gn,Eu).call(this,r);for(const x of u)i(this,ir).add(x);const d=j(this,jn,Su).call(this,r);for(const x of d)i(this,rr).add(x);const v=super.transformNodeImpl(r);for(const x of d)i(this,rr).delete(x);for(const x of u)i(this,ir).delete(x);return v}transformSchemableIdentifier(r){const u=super.transformSchemableIdentifier(r);return u.schema||!i(this,rr).has(r.identifier.name)?u:{...u,schema:re.create(i(this,Rr))}}transformReferences(r){const u=super.transformReferences(r);return u.table.table.schema?u:{...u,table:Dt.createWithSchema(i(this,Rr),u.table.table.identifier.name)}}}Rr=new WeakMap,rr=new WeakMap,ir=new WeakMap,$n=new WeakSet,Tu=function(r){return r.kind in Th},jn=new WeakSet,Su=function(r){const u=new Set;if("name"in r&&r.name&&Et.is(r.name)&&j(this,ki,To).call(this,r.name,u),"from"in r&&r.from)for(const d of r.from.froms)j(this,nr,nn).call(this,d,u);if("into"in r&&r.into&&j(this,nr,nn).call(this,r.into,u),"table"in r&&r.table&&j(this,nr,nn).call(this,r.table,u),"joins"in r&&r.joins)for(const d of r.joins)j(this,nr,nn).call(this,d.table,u);return u},Gn=new WeakSet,Eu=function(r){const u=new Set;return"with"in r&&r.with&&j(this,zn,Au).call(this,r.with,u),u},nr=new WeakSet,nn=function(r,u){const d=Dt.is(r)?r:At.is(r)&&Dt.is(r.node)?r.node:null;d&&j(this,ki,To).call(this,d.table,u)},ki=new WeakSet,To=function(r,u){const d=r.identifier.name;!i(this,rr).has(d)&&!i(this,ir).has(d)&&u.add(d)},zn=new WeakSet,Au=function(r,u){for(const d of r.expressions){const v=d.name.table.table.identifier.name;i(this,ir).has(v)||u.add(v)}};class pi{constructor(e){N(this,Ii,void 0);g(this,Ii,new Sh(e))}transformQuery(e){return i(this,Ii).transformNode(e.node)}async transformResult(e){return e.result}}Ii=new WeakMap;const sr=class sr{constructor(e){N(this,Z,void 0);g(this,Z,a(e))}selectFrom(e){return new mi({queryId:Y(),executor:i(this,Z).executor,queryNode:F.create(Ni(e),i(this,Z).withNode)})}insertInto(e){return new fi({queryId:Y(),executor:i(this,Z).executor,queryNode:ht.create(Le(e),i(this,Z).withNode)})}replaceInto(e){return new fi({queryId:Y(),executor:i(this,Z).executor,queryNode:ht.create(Le(e),i(this,Z).withNode,!0)})}deleteFrom(e){return new Nn({queryId:Y(),executor:i(this,Z).executor,queryNode:di.create(Ni(e),i(this,Z).withNode)})}updateTable(e){return new wn({queryId:Y(),executor:i(this,Z).executor,queryNode:dn.create(wi(e),i(this,Z).withNode)})}with(e,r){const u=oa(e,r);return new sr({...i(this,Z),withNode:i(this,Z).withNode?vn.cloneWithExpression(i(this,Z).withNode,u):vn.create(u)})}withRecursive(e,r){const u=oa(e,r);return new sr({...i(this,Z),withNode:i(this,Z).withNode?vn.cloneWithExpression(i(this,Z).withNode,u):vn.create(u,{recursive:!0})})}withPlugin(e){return new sr({...i(this,Z),executor:i(this,Z).executor.withPlugin(e)})}withoutPlugins(){return new sr({...i(this,Z),executor:i(this,Z).executor.withoutPlugins()})}withSchema(e){return new sr({...i(this,Z),executor:i(this,Z).executor.withPluginAtFront(new pi(e))})}};Z=new WeakMap;let bn=sr;class ua{constructor(){N(this,Ti,void 0);N(this,Lr,void 0);N(this,_r,void 0);M(this,"resolve",e=>{i(this,Lr)&&i(this,Lr).call(this,e)});M(this,"reject",e=>{i(this,_r)&&i(this,_r).call(this,e)});g(this,Ti,new Promise((e,r)=>{g(this,_r,r),g(this,Lr,e)}))}get promise(){return i(this,Ti)}}Ti=new WeakMap,Lr=new WeakMap,_r=new WeakMap;const ha=new Set;function Eh(t){ha.has(t)||(ha.add(t),console.log(t))}const Ah=a([]);class ca{constructor(e=Ah){N(this,Si);N(this,or,void 0);g(this,or,e)}get plugins(){return i(this,or)}transformQuery(e,r){for(const u of i(this,or)){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),v=await j(this,Si,So).call(this,d,r);return Dh(d,v),v})}async*stream(e,r,u){const d=new ua,v=new ua;this.provideConnection(async W=>(d.resolve(W),await v.promise)).catch(W=>d.reject(W));const x=await d.promise;try{for await(const W of x.streamQuery(e,r))yield await j(this,Si,So).call(this,W,u)}finally{v.resolve()}}}or=new WeakMap,Si=new WeakSet,So=async function(e,r){for(const u of i(this,or))e=await u.transformResult({result:e,queryId:r});return e};function Dh(t,e){const{numAffectedRows:r}=t;r===void 0&&t.numUpdatedOrDeletedRows===void 0||r!==void 0&&e.numAffectedRows!==void 0||Eh("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class qr extends ca{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 Qs=new qr;function Rh(){return new bn({executor:Qs})}function Lh(t,e){return new cn({joinNode:oi.create(t,wi(e))})}function _h(){return new ln({overNode:Ps.create()})}function Re(t,e){if(e.length===3)return Ph(t,e[0],e[1],e[2]);if(e.length===2)return Bh(t,e[0],e[1]);throw new Error("not implemented")}function Bh(t,e,r){return r(Lh(t,e)).toOperationNode()}function Ph(t,e,r,u){return oi.createWithOn(t,wi(e),gt(r,"=",u))}const Mh=a({is(t){return t.kind==="OffsetNode"},create(t){return a({kind:"OffsetNode",offset:Xe.create(t)})}}),Fh=a({is(t){return t.kind==="GroupByItemNode"},create(t){return a({kind:"GroupByItemNode",groupBy:t})}});function Qh(t){return t=$e(t)?t(Ir()):t,ui(t).map(Fh.create)}const la=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 la.create(t,e.toOperationNode(),r)}const C=class C{constructor(e){N(this,b,void 0);g(this,b,a(e))}get expressionType(){}where(...e){return new C({...i(this,b),queryNode:L.cloneWithWhere(i(this,b).queryNode,Ie(e))})}whereRef(e,r,u){return new C({...i(this,b),queryNode:L.cloneWithWhere(i(this,b).queryNode,gt(e,r,u))})}having(...e){return new C({...i(this,b),queryNode:F.cloneWithHaving(i(this,b).queryNode,Ie(e))})}havingRef(e,r,u){return new C({...i(this,b),queryNode:F.cloneWithHaving(i(this,b).queryNode,gt(e,r,u))})}select(e){return new C({...i(this,b),queryNode:F.cloneWithSelections(i(this,b).queryNode,ci(e))})}distinctOn(e){return new C({...i(this,b),queryNode:F.cloneWithDistinctOn(i(this,b).queryNode,ui(e))})}modifyFront(e){return new C({...i(this,b),queryNode:F.cloneWithFrontModifier(i(this,b).queryNode,wt.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new C({...i(this,b),queryNode:F.cloneWithEndModifier(i(this,b).queryNode,wt.createWithExpression(e.toOperationNode()))})}distinct(){return new C({...i(this,b),queryNode:F.cloneWithFrontModifier(i(this,b).queryNode,wt.create("Distinct"))})}forUpdate(){return new C({...i(this,b),queryNode:F.cloneWithEndModifier(i(this,b).queryNode,wt.create("ForUpdate"))})}forShare(){return new C({...i(this,b),queryNode:F.cloneWithEndModifier(i(this,b).queryNode,wt.create("ForShare"))})}forKeyShare(){return new C({...i(this,b),queryNode:F.cloneWithEndModifier(i(this,b).queryNode,wt.create("ForKeyShare"))})}forNoKeyUpdate(){return new C({...i(this,b),queryNode:F.cloneWithEndModifier(i(this,b).queryNode,wt.create("ForNoKeyUpdate"))})}skipLocked(){return new C({...i(this,b),queryNode:F.cloneWithEndModifier(i(this,b).queryNode,wt.create("SkipLocked"))})}noWait(){return new C({...i(this,b),queryNode:F.cloneWithEndModifier(i(this,b).queryNode,wt.create("NoWait"))})}selectAll(e){return new C({...i(this,b),queryNode:F.cloneWithSelections(i(this,b).queryNode,li(e))})}innerJoin(...e){return new C({...i(this,b),queryNode:L.cloneWithJoin(i(this,b).queryNode,Re("InnerJoin",e))})}leftJoin(...e){return new C({...i(this,b),queryNode:L.cloneWithJoin(i(this,b).queryNode,Re("LeftJoin",e))})}rightJoin(...e){return new C({...i(this,b),queryNode:L.cloneWithJoin(i(this,b).queryNode,Re("RightJoin",e))})}fullJoin(...e){return new C({...i(this,b),queryNode:L.cloneWithJoin(i(this,b).queryNode,Re("FullJoin",e))})}innerJoinLateral(...e){return new C({...i(this,b),queryNode:L.cloneWithJoin(i(this,b).queryNode,Re("LateralInnerJoin",e))})}leftJoinLateral(...e){return new C({...i(this,b),queryNode:L.cloneWithJoin(i(this,b).queryNode,Re("LateralLeftJoin",e))})}orderBy(e,r){return new C({...i(this,b),queryNode:F.cloneWithOrderByItem(i(this,b).queryNode,an(e,r))})}groupBy(e){return new C({...i(this,b),queryNode:F.cloneWithGroupByItems(i(this,b).queryNode,Qh(e))})}limit(e){return new C({...i(this,b),queryNode:F.cloneWithLimit(i(this,b).queryNode,na.create(e))})}offset(e){return new C({...i(this,b),queryNode:F.cloneWithOffset(i(this,b).queryNode,Mh.create(e))})}union(e){return new C({...i(this,b),queryNode:F.cloneWithSetOperation(i(this,b).queryNode,Cr("union",e,!1))})}unionAll(e){return new C({...i(this,b),queryNode:F.cloneWithSetOperation(i(this,b).queryNode,Cr("union",e,!0))})}intersect(e){return new C({...i(this,b),queryNode:F.cloneWithSetOperation(i(this,b).queryNode,Cr("intersect",e,!1))})}intersectAll(e){return new C({...i(this,b),queryNode:F.cloneWithSetOperation(i(this,b).queryNode,Cr("intersect",e,!0))})}except(e){return new C({...i(this,b),queryNode:F.cloneWithSetOperation(i(this,b).queryNode,Cr("except",e,!1))})}exceptAll(e){return new C({...i(this,b),queryNode:F.cloneWithSetOperation(i(this,b).queryNode,Cr("except",e,!0))})}as(e){return new Uh(this,e)}clearSelect(){return new C({...i(this,b),queryNode:F.cloneWithoutSelections(i(this,b).queryNode)})}clearWhere(){return new C({...i(this,b),queryNode:L.cloneWithoutWhere(i(this,b).queryNode)})}clearLimit(){return new C({...i(this,b),queryNode:F.cloneWithoutLimit(i(this,b).queryNode)})}clearOffset(){return new C({...i(this,b),queryNode:F.cloneWithoutOffset(i(this,b).queryNode)})}clearOrderBy(){return new C({...i(this,b),queryNode:F.cloneWithoutOrderBy(i(this,b).queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new C({...i(this,b)})}$castTo(){return new C(i(this,b))}$narrowType(){return new C(i(this,b))}$assertType(){return new C(i(this,b))}withPlugin(e){return new C({...i(this,b),executor:i(this,b).executor.withPlugin(e)})}toOperationNode(){return i(this,b).executor.transformQuery(i(this,b).queryNode,i(this,b).queryId)}compile(){return i(this,b).executor.compileQuery(this.toOperationNode(),i(this,b).queryId)}async execute(){const e=this.compile();return(await i(this,b).executor.executeQuery(e,i(this,b).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=fn){const r=await this.executeTakeFirst();if(r===void 0)throw pn(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,b).executor.stream(r,e,i(this,b).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new C({...i(this,b),queryNode:L.cloneWithExplain(i(this,b).queryNode,e,r)}).execute()}};b=new WeakMap;let mi=C;Q(mi,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Uh{constructor(e,r){N(this,Br,void 0);N(this,Pr,void 0);g(this,Br,e),g(this,Pr,r)}get expression(){return i(this,Br)}get alias(){return i(this,Pr)}toOperationNode(){return At.create(i(this,Br).toOperationNode(),re.create(i(this,Pr)))}}Br=new WeakMap,Pr=new WeakMap;const Wr=a({is(t){return t.kind==="ParensNode"},create(t){return a({kind:"ParensNode",node:t})}}),to=class to{constructor(e){N(this,Bt,void 0);g(this,Bt,e)}get expressionType(){}as(e){return new Us(this,e)}or(...e){return new Js(Zt.create(i(this,Bt),Ie(e)))}and(...e){return new Vs(Xt.create(i(this,Bt),Ie(e)))}$castTo(){return new to(i(this,Bt))}toOperationNode(){return i(this,Bt)}};Bt=new WeakMap;let se=to;class Us{constructor(e,r){N(this,Mr,void 0);N(this,Pt,void 0);g(this,Mr,e),g(this,Pt,r)}get expression(){return i(this,Mr)}get alias(){return i(this,Pt)}toOperationNode(){return At.create(i(this,Mr).toOperationNode(),je(i(this,Pt))?i(this,Pt).toOperationNode():re.create(i(this,Pt)))}}Mr=new WeakMap,Pt=new WeakMap;const Kn=class Kn{constructor(e){N(this,ar,void 0);g(this,ar,e)}get expressionType(){}as(e){return new Us(this,e)}or(...e){return new Kn(Zt.create(i(this,ar),Ie(e)))}$castTo(){return new Kn(i(this,ar))}toOperationNode(){return Wr.create(i(this,ar))}};ar=new WeakMap;let Js=Kn;const Hn=class Hn{constructor(e){N(this,ur,void 0);g(this,ur,e)}get expressionType(){}as(e){return new Us(this,e)}and(...e){return new Hn(Xt.create(i(this,ur),Ie(e)))}$castTo(){return new Hn(i(this,ur))}toOperationNode(){return Wr.create(i(this,ur))}};ur=new WeakMap;let Vs=Hn;const kr=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})}}),Jh=a({is(t){return t.kind==="FunctionNode"},create(t,e){return a({kind:"FunctionNode",func:t,arguments:e})}}),Fr=class Fr{constructor(e){N(this,Fe,void 0);g(this,Fe,a(e))}get expressionType(){}as(e){return new Vh(this,e)}distinct(){return new Fr({...i(this,Fe),aggregateFunctionNode:kr.cloneWithDistinct(i(this,Fe).aggregateFunctionNode)})}filterWhere(...e){return new Fr({...i(this,Fe),aggregateFunctionNode:kr.cloneWithFilter(i(this,Fe).aggregateFunctionNode,Ie(e))})}filterWhereRef(e,r,u){return new Fr({...i(this,Fe),aggregateFunctionNode:kr.cloneWithFilter(i(this,Fe).aggregateFunctionNode,gt(e,r,u))})}over(e){const r=_h();return new Fr({...i(this,Fe),aggregateFunctionNode:kr.cloneWithOver(i(this,Fe).aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return i(this,Fe).aggregateFunctionNode}};Fe=new WeakMap;let yi=Fr;Q(yi,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class Vh{constructor(e,r){N(this,Qr,void 0);N(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 At.create(i(this,Qr).toOperationNode(),re.create(i(this,Ur)))}}Qr=new WeakMap,Ur=new WeakMap;function da(){const t=(r,u)=>new se(Jh.create(r,ui(u))),e=(r,u)=>new yi({aggregateFunctionNode:kr.create(r,u?ui(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 yi({aggregateFunctionNode:kr.create("count",li(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}const $h=a({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return a({kind:"UnaryOperationNode",operator:t,operand:e})}});function jh(t,e){return $h.create(ai.create(t),vt(e))}const $s=a({is(t){return t.kind==="WhenNode"},create(t){return a({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return a({...t,result:e})}}),ct=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),$s.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return a({...t,...e})}});class fa{constructor(e){N(this,Jr,void 0);g(this,Jr,a(e))}when(...e){return new pa({...i(this,Jr),node:ct.cloneWithWhen(i(this,Jr).node,$s.create(Ie(e)))})}}Jr=new WeakMap;class pa{constructor(e){N(this,Vr,void 0);g(this,Vr,a(e))}then(e){return new Gh({...i(this,Vr),node:ct.cloneWithThen(i(this,Vr).node,bt(e))})}}Vr=new WeakMap;class Gh{constructor(e){N(this,lt,void 0);g(this,lt,a(e))}when(...e){return new pa({...i(this,lt),node:ct.cloneWithWhen(i(this,lt).node,$s.create(Ie(e)))})}else(e){return new zh({...i(this,lt),node:ct.cloneWith(i(this,lt).node,{else:bt(e)})})}end(){return new se(ct.cloneWith(i(this,lt).node,{isStatement:!1}))}endCase(){return new se(ct.cloneWith(i(this,lt).node,{isStatement:!0}))}}lt=new WeakMap;class zh{constructor(e){N(this,$r,void 0);g(this,$r,a(e))}end(){return new se(ct.cloneWith(i(this,$r).node,{isStatement:!1}))}endCase(){return new se(ct.cloneWith(i(this,$r).node,{isStatement:!0}))}}$r=new WeakMap;const Kh=a({is(t){return t.kind==="JSONPathLegNode"},create(t,e){return a({kind:"JSONPathLegNode",type:t,value:e})}});class js{constructor(e){N(this,Ei);N(this,Mt,void 0);g(this,Mt,e)}at(e){return j(this,Ei,Eo).call(this,"ArrayLocation",e)}key(e){return j(this,Ei,Eo).call(this,"Member",e)}}Mt=new WeakMap,Ei=new WeakSet,Eo=function(e,r){return new Hh(Ds.cloneWithTraversal(i(this,Mt),Rs.is(i(this,Mt).traversal)?Rs.cloneWithLeg(i(this,Mt).traversal,Kh.create(e,r)):Qo.cloneWithValue(i(this,Mt).traversal,Xe.createImmediate(r))))};class Hh extends js{constructor(r){super(r);N(this,jr,void 0);g(this,jr,r)}get expressionType(){}as(r){return new Yh(this,r)}$castTo(){return new js(i(this,jr))}toOperationNode(){return i(this,jr)}}jr=new WeakMap;class Yh{constructor(e,r){N(this,Gr,void 0);N(this,Ft,void 0);g(this,Gr,e),g(this,Ft,r)}get expression(){return i(this,Gr)}get alias(){return i(this,Ft)}toOperationNode(){return At.create(i(this,Gr).toOperationNode(),je(i(this,Ft))?i(this,Ft).toOperationNode():re.create(i(this,Ft)))}}Gr=new WeakMap,Ft=new WeakMap;function Gs(t=Qs){function e(d,v,x){return new se(un(d,v,x))}function r(d,v){return new se(jh(d,v))}const u=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(d){return new mi({queryId:Y(),executor:t,queryNode:F.create(Ni(d))})},case(d){return new fa({node:ct.create(G(d)?void 0:vt(d))})},ref(d,v){return G(v)?new se(er(d)):new js(Xu(d,v))},val(d){return new se(jo(d))},cmpr(d,v,x){return new se(un(d,v,x))},bxp(d,v,x){return new se(un(d,v,x))},unary:r,not(d){return r("not",d)},exists(d){return r("exists",d)},neg(d){return r("-",d)},and(d){if(d.length===0)return new se(Xe.createImmediate(!0));if(d.length===1)return new se(d[0].toOperationNode());let v=Xt.create(d[0].toOperationNode(),d[1].toOperationNode());for(let x=2;xwi(e)):[wi(t)]}function wi(t){return B(t)?Xh(t):ma(t)}function Xh(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(ya);return At.create(Le(r),re.create(u))}else return Le(t)}function Le(t){const e=".";if(t.includes(e)){const[r,u]=t.split(e).map(ya);return Dt.createWithSchema(r,u)}else return Dt.create(t)}function ya(t){return t.trim()}const Na=a({is(t){return t.kind==="AddColumnNode"},create(t){return a({kind:"AddColumnNode",column:t})}}),oe=a({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return a({kind:"ColumnDefinitionNode",column:ne.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})}}),wa=a({is(t){return t.kind==="DropColumnNode"},create(t){return a({kind:"DropColumnNode",column:ne.create(t)})}}),va=a({is(t){return t.kind==="RenameColumnNode"},create(t,e){return a({kind:"RenameColumnNode",column:ne.create(t),renameTo:ne.create(e)})}}),zs=a({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return a({kind:"CheckConstraintNode",expression:t,name:e?re.create(e):void 0})}}),Zh=["no action","restrict","cascade","set null","set default"],On=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 ba(t){return je(t)?t.toOperationNode():Xe.createImmediate(t)}const qn=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})}}),ec=a({is(t){return t.kind==="DefaultValueNode"},create(t){return a({kind:"DefaultValueNode",defaultValue:t})}});function Cn(t){if(Zh.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const Ne=class Ne{constructor(e){N(this,z,void 0);g(this,z,e)}autoIncrement(){return new Ne(oe.cloneWith(i(this,z),{autoIncrement:!0}))}primaryKey(){return new Ne(oe.cloneWith(i(this,z),{primaryKey:!0}))}references(e){const r=er(e);if(!r.table||As.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new Ne(oe.cloneWith(i(this,z),{references:On.create(r.table,[r.column])}))}onDelete(e){if(!i(this,z).references)throw new Error("on delete constraint can only be added for foreign keys");return new Ne(oe.cloneWith(i(this,z),{references:On.cloneWithOnDelete(i(this,z).references,Cn(e))}))}onUpdate(e){if(!i(this,z).references)throw new Error("on update constraint can only be added for foreign keys");return new Ne(oe.cloneWith(i(this,z),{references:On.cloneWithOnUpdate(i(this,z).references,Cn(e))}))}unique(){return new Ne(oe.cloneWith(i(this,z),{unique:!0}))}notNull(){return new Ne(oe.cloneWith(i(this,z),{notNull:!0}))}unsigned(){return new Ne(oe.cloneWith(i(this,z),{unsigned:!0}))}defaultTo(e){return new Ne(oe.cloneWith(i(this,z),{defaultTo:ec.create(ba(e))}))}check(e){return new Ne(oe.cloneWith(i(this,z),{check:zs.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new Ne(oe.cloneWith(i(this,z),{generated:qn.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new Ne(oe.cloneWith(i(this,z),{generated:qn.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new Ne(oe.cloneWith(i(this,z),{generated:qn.create({identity:!0,byDefault:!0})}))}stored(){if(!i(this,z).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new Ne(oe.cloneWith(i(this,z),{generated:qn.cloneWith(i(this,z).generated,{stored:!0})}))}modifyFront(e){return new Ne(oe.cloneWithFrontModifier(i(this,z),e.toOperationNode()))}modifyEnd(e){return new Ne(oe.cloneWithEndModifier(i(this,z),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return i(this,z)}};z=new WeakMap;let Rt=Ne;Q(Rt,"don't await ColumnDefinitionBuilder instances directly.");const ga=a({is(t){return t.kind==="ModifyColumnNode"},create(t){return a({kind:"ModifyColumnNode",column:t})}}),tc=a({is(t){return t.kind==="DataTypeNode"},create(t){return a({kind:"DataTypeNode",dataType:t})}});function Tr(t){return je(t)?t.toOperationNode():tc.create(t)}const Wn=a({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,u){return a({kind:"ForeignKeyConstraintNode",columns:t,references:On.create(e,r),name:u?re.create(u):void 0})},cloneWith(t,e){return a({...t,...e})}}),Yn=class Yn{constructor(e){N(this,hr,void 0);g(this,hr,e)}onDelete(e){return new Yn(Wn.cloneWith(i(this,hr),{onDelete:Cn(e)}))}onUpdate(e){return new Yn(Wn.cloneWith(i(this,hr),{onUpdate:Cn(e)}))}$call(e){return e(this)}toOperationNode(){return i(this,hr)}};hr=new WeakMap;let vi=Yn;Q(vi,"don't await ForeignKeyConstraintBuilder instances directly.");const Ks=a({is(t){return t.kind==="AddConstraintNode"},create(t){return a({kind:"AddConstraintNode",constraint:t})}}),xa=a({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return a({kind:"UniqueConstraintNode",columns:a(t.map(ne.create)),name:e?re.create(e):void 0})}}),kn=a({is(t){return t.kind==="DropConstraintNode"},create(t){return a({kind:"DropConstraintNode",constraintName:re.create(t)})},cloneWith(t,e){return a({...t,...e})}}),bi=a({is(t){return t.kind==="AlterColumnNode"},create(t,e,r){return a({kind:"AlterColumnNode",column:ne.create(t),[e]:r})}});class Hs{constructor(e){N(this,Ot,void 0);g(this,Ot,e)}setDataType(e){return new gi(bi.create(i(this,Ot),"dataType",Tr(e)))}setDefault(e){return new gi(bi.create(i(this,Ot),"setDefault",ba(e)))}dropDefault(){return new gi(bi.create(i(this,Ot),"dropDefault",!0))}setNotNull(){return new gi(bi.create(i(this,Ot),"setNotNull",!0))}dropNotNull(){return new gi(bi.create(i(this,Ot),"dropNotNull",!0))}$call(e){return e(this)}}Ot=new WeakMap;class gi{constructor(e){N(this,Ai,void 0);g(this,Ai,e)}toOperationNode(){return i(this,Ai)}}Ai=new WeakMap;class xi{constructor(e){N(this,rt,void 0);g(this,rt,a(e))}toOperationNode(){return i(this,rt).executor.transformQuery(i(this,rt).node,i(this,rt).queryId)}compile(){return i(this,rt).executor.compileQuery(this.toOperationNode(),i(this,rt).queryId)}async execute(){await i(this,rt).executor.executeQuery(this.compile(),i(this,rt).queryId)}}rt=new WeakMap,Q(xi,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const Xn=class Xn{constructor(e){N(this,Ce,void 0);g(this,Ce,a(e))}onDelete(e){return new Xn({...i(this,Ce),constraintBuilder:i(this,Ce).constraintBuilder.onDelete(e)})}onUpdate(e){return new Xn({...i(this,Ce),constraintBuilder:i(this,Ce).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return i(this,Ce).executor.transformQuery(de.cloneWithTableProps(i(this,Ce).node,{addConstraint:Ks.create(i(this,Ce).constraintBuilder.toOperationNode())}),i(this,Ce).queryId)}compile(){return i(this,Ce).executor.compileQuery(this.toOperationNode(),i(this,Ce).queryId)}async execute(){await i(this,Ce).executor.executeQuery(this.compile(),i(this,Ce).queryId)}};Ce=new WeakMap;let In=Xn;Q(In,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const Di=class Di{constructor(e){N(this,pe,void 0);g(this,pe,a(e))}ifExists(){return new Di({...i(this,pe),node:de.cloneWithTableProps(i(this,pe).node,{dropConstraint:kn.cloneWith(i(this,pe).node.dropConstraint,{ifExists:!0})})})}cascade(){return new Di({...i(this,pe),node:de.cloneWithTableProps(i(this,pe).node,{dropConstraint:kn.cloneWith(i(this,pe).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new Di({...i(this,pe),node:de.cloneWithTableProps(i(this,pe).node,{dropConstraint:kn.cloneWith(i(this,pe).node.dropConstraint,{modifier:"restrict"})})})}$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)}};pe=new WeakMap;let Tn=Di;Q(Tn,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class Oa{constructor(e){N(this,ee,void 0);g(this,ee,a(e))}renameTo(e){return new xi({...i(this,ee),node:de.cloneWithTableProps(i(this,ee).node,{renameTo:Le(e)})})}setSchema(e){return new xi({...i(this,ee),node:de.cloneWithTableProps(i(this,ee).node,{setSchema:re.create(e)})})}alterColumn(e,r){const u=r(new Hs(e));return new Lt({...i(this,ee),node:de.cloneWithColumnAlteration(i(this,ee).node,u.toOperationNode())})}dropColumn(e){return new Lt({...i(this,ee),node:de.cloneWithColumnAlteration(i(this,ee).node,wa.create(e))})}renameColumn(e,r){return new Lt({...i(this,ee),node:de.cloneWithColumnAlteration(i(this,ee).node,va.create(e,r))})}addColumn(e,r,u=xr){const d=u(new Rt(oe.create(e,Tr(r))));return new Lt({...i(this,ee),node:de.cloneWithColumnAlteration(i(this,ee).node,Na.create(d.toOperationNode()))})}modifyColumn(e,r,u=xr){const d=u(new Rt(oe.create(e,Tr(r))));return new Lt({...i(this,ee),node:de.cloneWithColumnAlteration(i(this,ee).node,ga.create(d.toOperationNode()))})}addUniqueConstraint(e,r){return new xi({...i(this,ee),node:de.cloneWithTableProps(i(this,ee).node,{addConstraint:Ks.create(xa.create(r,e))})})}addCheckConstraint(e,r){return new xi({...i(this,ee),node:de.cloneWithTableProps(i(this,ee).node,{addConstraint:Ks.create(zs.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,u,d){return new In({...i(this,ee),constraintBuilder:new vi(Wn.create(r.map(ne.create),Le(u),d.map(ne.create),e))})}dropConstraint(e){return new Tn({...i(this,ee),node:de.cloneWithTableProps(i(this,ee).node,{dropConstraint:kn.create(e)})})}$call(e){return e(this)}}ee=new WeakMap;const cr=class cr{constructor(e){N(this,ae,void 0);g(this,ae,a(e))}alterColumn(e,r){const u=r(new Hs(e));return new cr({...i(this,ae),node:de.cloneWithColumnAlteration(i(this,ae).node,u.toOperationNode())})}dropColumn(e){return new cr({...i(this,ae),node:de.cloneWithColumnAlteration(i(this,ae).node,wa.create(e))})}renameColumn(e,r){return new cr({...i(this,ae),node:de.cloneWithColumnAlteration(i(this,ae).node,va.create(e,r))})}addColumn(e,r,u=xr){const d=u(new Rt(oe.create(e,Tr(r))));return new cr({...i(this,ae),node:de.cloneWithColumnAlteration(i(this,ae).node,Na.create(d.toOperationNode()))})}modifyColumn(e,r,u=xr){const d=u(new Rt(oe.create(e,Tr(r))));return new cr({...i(this,ae),node:de.cloneWithColumnAlteration(i(this,ae).node,ga.create(d.toOperationNode()))})}toOperationNode(){return i(this,ae).executor.transformQuery(i(this,ae).node,i(this,ae).queryId)}compile(){return i(this,ae).executor.compileQuery(this.toOperationNode(),i(this,ae).queryId)}async execute(){await i(this,ae).executor.executeQuery(this.compile(),i(this,ae).queryId)}};ae=new WeakMap;let Lt=cr;Q(Oa,"don't await AlterTableBuilder instances"),Q(Hs,"don't await AlterColumnBuilder instances"),Q(Lt,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class qa extends Fs{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const dt=class dt{constructor(e){N(this,K,void 0);g(this,K,a(e))}ifNotExists(){return new dt({...i(this,K),node:St.cloneWith(i(this,K).node,{ifNotExists:!0})})}unique(){return new dt({...i(this,K),node:St.cloneWith(i(this,K).node,{unique:!0})})}on(e){return new dt({...i(this,K),node:St.cloneWith(i(this,K).node,{table:Le(e)})})}column(e){return new dt({...i(this,K),node:St.cloneWithColumns(i(this,K).node,[Vo(e)])})}columns(e){return new dt({...i(this,K),node:St.cloneWithColumns(i(this,K).node,e.map(Vo))})}expression(e){return new dt({...i(this,K),node:St.cloneWithColumns(i(this,K).node,[e.toOperationNode()])})}using(e){return new dt({...i(this,K),node:St.cloneWith(i(this,K).node,{using:ke.createWithSql(e)})})}where(...e){const r=new qa;return new dt({...i(this,K),node:L.cloneWithWhere(i(this,K).node,r.transformNode(Ie(e)))})}$call(e){return e(this)}toOperationNode(){return i(this,K).executor.transformQuery(i(this,K).node,i(this,K).queryId)}compile(){return i(this,K).executor.compileQuery(this.toOperationNode(),i(this,K).queryId)}async execute(){await i(this,K).executor.executeQuery(this.compile(),i(this,K).queryId)}};K=new WeakMap;let Sn=dt;Q(Sn,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const ro=class ro{constructor(e){N(this,Qe,void 0);g(this,Qe,a(e))}ifNotExists(){return new ro({...i(this,Qe),node:_o.cloneWith(i(this,Qe).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Qe).executor.transformQuery(i(this,Qe).node,i(this,Qe).queryId)}compile(){return i(this,Qe).executor.compileQuery(this.toOperationNode(),i(this,Qe).queryId)}async execute(){await i(this,Qe).executor.executeQuery(this.compile(),i(this,Qe).queryId)}};Qe=new WeakMap;let En=ro;Q(En,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const rc=a({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return a({kind:"PrimaryKeyConstraintNode",columns:a(t.map(ne.create)),name:e?re.create(e):void 0})}});function ic(t){if(Qu.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const Ge=class Ge{constructor(e){N(this,U,void 0);g(this,U,a(e))}temporary(){return new Ge({...i(this,U),node:Ye.cloneWith(i(this,U).node,{temporary:!0})})}onCommit(e){return new Ge({...i(this,U),node:Ye.cloneWith(i(this,U).node,{onCommit:ic(e)})})}ifNotExists(){return new Ge({...i(this,U),node:Ye.cloneWith(i(this,U).node,{ifNotExists:!0})})}addColumn(e,r,u=xr){const d=u(new Rt(oe.create(e,Tr(r))));return new Ge({...i(this,U),node:Ye.cloneWithColumn(i(this,U).node,d.toOperationNode())})}addPrimaryKeyConstraint(e,r){return new Ge({...i(this,U),node:Ye.cloneWithConstraint(i(this,U).node,rc.create(r,e))})}addUniqueConstraint(e,r){return new Ge({...i(this,U),node:Ye.cloneWithConstraint(i(this,U).node,xa.create(r,e))})}addCheckConstraint(e,r){return new Ge({...i(this,U),node:Ye.cloneWithConstraint(i(this,U).node,zs.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,u,d,v=xr){const x=v(new vi(Wn.create(r.map(ne.create),Le(u),d.map(ne.create),e)));return new Ge({...i(this,U),node:Ye.cloneWithConstraint(i(this,U).node,x.toOperationNode())})}modifyFront(e){return new Ge({...i(this,U),node:Ye.cloneWithFrontModifier(i(this,U).node,e.toOperationNode())})}modifyEnd(e){return new Ge({...i(this,U),node:Ye.cloneWithEndModifier(i(this,U).node,e.toOperationNode())})}$call(e){return e(this)}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)}};U=new WeakMap;let An=Ge;Q(An,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const Ri=class Ri{constructor(e){N(this,be,void 0);g(this,be,a(e))}on(e){return new Ri({...i(this,be),node:sn.cloneWith(i(this,be).node,{table:Le(e)})})}ifExists(){return new Ri({...i(this,be),node:sn.cloneWith(i(this,be).node,{ifExists:!0})})}cascade(){return new Ri({...i(this,be),node:sn.cloneWith(i(this,be).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,be).executor.transformQuery(i(this,be).node,i(this,be).queryId)}compile(){return i(this,be).executor.compileQuery(this.toOperationNode(),i(this,be).queryId)}async execute(){await i(this,be).executor.executeQuery(this.compile(),i(this,be).queryId)}};be=new WeakMap;let Dn=Ri;Q(Dn,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const Zn=class Zn{constructor(e){N(this,Te,void 0);g(this,Te,a(e))}ifExists(){return new Zn({...i(this,Te),node:ks.cloneWith(i(this,Te).node,{ifExists:!0})})}cascade(){return new Zn({...i(this,Te),node:ks.cloneWith(i(this,Te).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Te).executor.transformQuery(i(this,Te).node,i(this,Te).queryId)}compile(){return i(this,Te).executor.compileQuery(this.toOperationNode(),i(this,Te).queryId)}async execute(){await i(this,Te).executor.executeQuery(this.compile(),i(this,Te).queryId)}};Te=new WeakMap;let Rn=Zn;Q(Rn,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const es=class es{constructor(e){N(this,Se,void 0);g(this,Se,a(e))}ifExists(){return new es({...i(this,Se),node:Is.cloneWith(i(this,Se).node,{ifExists:!0})})}cascade(){return new es({...i(this,Se),node:Is.cloneWith(i(this,Se).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Se).executor.transformQuery(i(this,Se).node,i(this,Se).queryId)}compile(){return i(this,Se).executor.compileQuery(this.toOperationNode(),i(this,Se).queryId)}async execute(){await i(this,Se).executor.executeQuery(this.compile(),i(this,Se).queryId)}};Se=new WeakMap;let Ln=es;Q(Ln,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const _t=a({is(t){return t.kind==="CreateViewNode"},create(t){return a({kind:"CreateViewNode",name:Et.create(t)})},cloneWith(t,e){return a({...t,...e})}});class nc{constructor(){N(this,ts,new qa)}transformQuery(e){return i(this,ts).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}ts=new WeakMap;const Qt=class Qt{constructor(e){N(this,ie,void 0);g(this,ie,a(e))}temporary(){return new Qt({...i(this,ie),node:_t.cloneWith(i(this,ie).node,{temporary:!0})})}materialized(){return new Qt({...i(this,ie),node:_t.cloneWith(i(this,ie).node,{materialized:!0})})}ifNotExists(){return new Qt({...i(this,ie),node:_t.cloneWith(i(this,ie).node,{ifNotExists:!0})})}orReplace(){return new Qt({...i(this,ie),node:_t.cloneWith(i(this,ie).node,{orReplace:!0})})}columns(e){return new Qt({...i(this,ie),node:_t.cloneWith(i(this,ie).node,{columns:e.map(Jo)})})}as(e){const r=e.withPlugin(new nc).toOperationNode();return new Qt({...i(this,ie),node:_t.cloneWith(i(this,ie).node,{as:r})})}$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)}};ie=new WeakMap;let _n=Qt;Q(_n,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const Bn=a({is(t){return t.kind==="DropViewNode"},create(t){return a({kind:"DropViewNode",name:Et.create(t)})},cloneWith(t,e){return a({...t,...e})}}),Li=class Li{constructor(e){N(this,ge,void 0);g(this,ge,a(e))}materialized(){return new Li({...i(this,ge),node:Bn.cloneWith(i(this,ge).node,{materialized:!0})})}ifExists(){return new Li({...i(this,ge),node:Bn.cloneWith(i(this,ge).node,{ifExists:!0})})}cascade(){return new Li({...i(this,ge),node:Bn.cloneWith(i(this,ge).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,ge).executor.transformQuery(i(this,ge).node,i(this,ge).queryId)}compile(){return i(this,ge).executor.compileQuery(this.toOperationNode(),i(this,ge).queryId)}async execute(){await i(this,ge).executor.executeQuery(this.compile(),i(this,ge).queryId)}};ge=new WeakMap;let Pn=Li;Q(Pn,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const Ca=a({is(t){return t.kind==="CreateTypeNode"},create(t){return a({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return a({...t,enum:_s.create(e.map(r=>Xe.createImmediate(r)))})}}),io=class io{constructor(e){N(this,Ue,void 0);g(this,Ue,a(e))}toOperationNode(){return i(this,Ue).executor.transformQuery(i(this,Ue).node,i(this,Ue).queryId)}asEnum(e){return new io({...i(this,Ue),node:Ca.cloneWithEnum(i(this,Ue).node,e)})}$call(e){return e(this)}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)}};Ue=new WeakMap;let Mn=io;Q(Mn,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const Wa=a({is(t){return t.kind==="DropTypeNode"},create(t){return a({kind:"DropTypeNode",name:t})},cloneWith(t,e){return a({...t,...e})}}),no=class no{constructor(e){N(this,Je,void 0);g(this,Je,a(e))}ifExists(){return new no({...i(this,Je),node:Wa.cloneWith(i(this,Je).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Je).executor.transformQuery(i(this,Je).node,i(this,Je).queryId)}compile(){return i(this,Je).executor.compileQuery(this.toOperationNode(),i(this,Je).queryId)}async execute(){await i(this,Je).executor.executeQuery(this.compile(),i(this,Je).queryId)}};Je=new WeakMap;let Fn=no;Q(Fn,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function ka(t){const e=".";if(t.includes(e)){const r=t.split(e).map(sc);if(r.length===2)return Et.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return Et.create(t)}function sc(t){return t.trim()}const _i=class _i{constructor(e){N(this,we,void 0);g(this,we,e)}createTable(e){return new An({queryId:Y(),executor:i(this,we),node:Ye.create(Le(e))})}dropTable(e){return new Ln({queryId:Y(),executor:i(this,we),node:Is.create(Le(e))})}createIndex(e){return new Sn({queryId:Y(),executor:i(this,we),node:St.create(e)})}dropIndex(e){return new Dn({queryId:Y(),executor:i(this,we),node:sn.create(e)})}createSchema(e){return new En({queryId:Y(),executor:i(this,we),node:_o.create(e)})}dropSchema(e){return new Rn({queryId:Y(),executor:i(this,we),node:ks.create(e)})}alterTable(e){return new Oa({queryId:Y(),executor:i(this,we),node:de.create(Le(e))})}createView(e){return new _n({queryId:Y(),executor:i(this,we),node:_t.create(e)})}dropView(e){return new Pn({queryId:Y(),executor:i(this,we),node:Bn.create(e)})}createType(e){return new Mn({queryId:Y(),executor:i(this,we),node:Ca.create(ka(e))})}dropType(e){return new Fn({queryId:Y(),executor:i(this,we),node:Wa.create(ka(e))})}withPlugin(e){return new _i(i(this,we).withPlugin(e))}withoutPlugins(){return new _i(i(this,we).withoutPlugins())}withSchema(e){return new _i(i(this,we).withPluginAtFront(new pi(e)))}};we=new WeakMap;let Ys=_i;class oc{ref(e){return new ch(e)}}class ac{constructor(e){N(this,zr,void 0);g(this,zr,e)}async provideConnection(e){const r=await i(this,zr).acquireConnection();try{return await e(r)}finally{await i(this,zr).releaseConnection(r)}}}zr=new WeakMap;const lr=class lr extends ca{constructor(r,u,d,v=[]){super(v);N(this,ft,void 0);N(this,pt,void 0);N(this,qt,void 0);g(this,ft,r),g(this,pt,u),g(this,qt,d)}get adapter(){return i(this,pt)}compileQuery(r){return i(this,ft).compileQuery(r)}provideConnection(r){return i(this,qt).provideConnection(r)}withPlugins(r){return new lr(i(this,ft),i(this,pt),i(this,qt),[...this.plugins,...r])}withPlugin(r){return new lr(i(this,ft),i(this,pt),i(this,qt),[...this.plugins,r])}withPluginAtFront(r){return new lr(i(this,ft),i(this,pt),i(this,qt),[r,...this.plugins])}withConnectionProvider(r){return new lr(i(this,ft),i(this,pt),r,[...this.plugins])}withoutPlugins(){return new lr(i(this,ft),i(this,pt),i(this,qt),[])}};ft=new WeakMap,pt=new WeakMap,qt=new WeakMap;let Xs=lr;function Ia(){return typeof performance<"u"&&$e(performance.now)?performance.now():Date.now()}class uc{constructor(e,r){N(this,rs);N(this,is);N(this,ns);N(this,ss);N(this,Pi);N(this,it,void 0);N(this,Ut,void 0);N(this,Ct,void 0);N(this,dr,void 0);N(this,Bi,new WeakSet);g(this,it,e),g(this,Ut,r)}async init(){i(this,Ct)||g(this,Ct,i(this,it).init().catch(e=>(g(this,Ct,void 0),Promise.reject(e)))),await i(this,Ct)}async acquireConnection(){await this.init();const e=await i(this,it).acquireConnection();return i(this,Bi).has(e)||(j(this,rs,Du).call(this)&&j(this,is,Ru).call(this,e),i(this,Bi).add(e)),e}async releaseConnection(e){await i(this,it).releaseConnection(e)}beginTransaction(e,r){return i(this,it).beginTransaction(e,r)}commitTransaction(e){return i(this,it).commitTransaction(e)}rollbackTransaction(e){return i(this,it).rollbackTransaction(e)}async destroy(){i(this,Ct)&&(await i(this,Ct),i(this,dr)||g(this,dr,i(this,it).destroy().catch(e=>(g(this,dr,void 0),Promise.reject(e)))),await i(this,dr))}}it=new WeakMap,Ut=new WeakMap,Ct=new WeakMap,dr=new WeakMap,Bi=new WeakMap,rs=new WeakSet,Du=function(){return i(this,Ut).isLevelEnabled("query")||i(this,Ut).isLevelEnabled("error")},is=new WeakSet,Ru=function(e){const r=e.executeQuery;e.executeQuery=async u=>{const d=Ia();try{return await r.call(e,u)}catch(v){throw await j(this,ns,Lu).call(this,v,u,d),v}finally{await j(this,ss,_u).call(this,u,d)}}},ns=new WeakSet,Lu=async function(e,r,u){await i(this,Ut).error(()=>({level:"error",error:e,query:r,queryDurationMillis:j(this,Pi,Ao).call(this,u)}))},ss=new WeakSet,_u=async function(e,r){await i(this,Ut).query(()=>({level:"query",query:e,queryDurationMillis:j(this,Pi,Ao).call(this,r)}))},Pi=new WeakSet,Ao=function(e){return Ia()-e};class Ta{constructor(e){N(this,os);N(this,Mi,void 0);N(this,Jt,void 0);g(this,Mi,e)}async provideConnection(e){for(;i(this,Jt);)await i(this,Jt);const r=j(this,os,Bu).call(this,e);return g(this,Jt,r.then(()=>{g(this,Jt,void 0)}).catch(()=>{g(this,Jt,void 0)})),r}}Mi=new WeakMap,Jt=new WeakMap,os=new WeakSet,Bu=async function(e){return await e(i(this,Mi))};const hc=["read uncommitted","read committed","repeatable read","serializable"];a(["query","error"]);class cc{constructor(e){N(this,Vt,void 0);N(this,fr,void 0);$e(e)?(g(this,fr,e),g(this,Vt,a({query:!0,error:!0}))):(g(this,fr,lc),g(this,Vt,a({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return i(this,Vt)[e]}async query(e){i(this,Vt).query&&await i(this,fr).call(this,e())}async error(e){i(this,Vt).error&&await i(this,fr).call(this,e())}}Vt=new WeakMap,fr=new WeakMap;function lc(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 dc(t){return ut(t)&&$e(t.compile)}const Kr=class Kr extends bn{constructor(r){let u,d;if(fc(r))u={executor:r.executor},d={...r};else{const v=r.dialect,x=v.createDriver(),W=v.createQueryCompiler(),V=v.createAdapter(),c=new cc(r.log??[]),Ee=new uc(x,c),Ae=new ac(Ee),_=new Xs(W,V,Ae,r.plugins??[]);u={executor:_},d={config:r,executor:_,dialect:v,driver:Ee}}super(u);N(this,xe,void 0);g(this,xe,a(d))}get schema(){return new Ys(i(this,xe).executor)}get dynamic(){return new oc}get introspection(){return i(this,xe).dialect.createIntrospector(this.withoutPlugins())}case(r){return new fa({node:ct.create(G(r)?void 0:gn(r))})}get fn(){return da()}transaction(){return new Qn({...i(this,xe)})}connection(){return new Sa({...i(this,xe)})}withPlugin(r){return new Kr({...i(this,xe),executor:i(this,xe).executor.withPlugin(r)})}withoutPlugins(){return new Kr({...i(this,xe),executor:i(this,xe).executor.withoutPlugins()})}withSchema(r){return new Kr({...i(this,xe),executor:i(this,xe).executor.withPluginAtFront(new pi(r))})}withTables(){return new Kr({...i(this,xe)})}async destroy(){await i(this,xe).driver.destroy()}get isTransaction(){return!1}getExecutor(){return i(this,xe).executor}executeQuery(r,u=Y()){const d=dc(r)?r.compile():r;return this.getExecutor().executeQuery(d,u)}};xe=new WeakMap;let Oi=Kr;const Hr=class Hr extends Oi{constructor(r){super(r);N(this,nt,void 0);g(this,nt,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 Hr({...i(this,nt),executor:i(this,nt).executor.withPlugin(r)})}withoutPlugins(){return new Hr({...i(this,nt),executor:i(this,nt).executor.withoutPlugins()})}withSchema(r){return new Hr({...i(this,nt),executor:i(this,nt).executor.withPluginAtFront(new pi(r))})}withTables(){return new Hr({...i(this,nt)})}};nt=new WeakMap;let Zs=Hr;function fc(t){return ut(t)&&ut(t.config)&&ut(t.driver)&&ut(t.executor)&&ut(t.dialect)}class Sa{constructor(e){N(this,pr,void 0);g(this,pr,a(e))}async execute(e){return i(this,pr).executor.provideConnection(async r=>{const u=i(this,pr).executor.withConnectionProvider(new Ta(r)),d=new Oi({...i(this,pr),executor:u});return await e(d)})}}pr=new WeakMap,Q(Sa,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const so=class so{constructor(e){N(this,st,void 0);g(this,st,a(e))}setIsolationLevel(e){return new so({...i(this,st),isolationLevel:e})}async execute(e){const{isolationLevel:r,...u}=i(this,st),d={isolationLevel:r};return pc(d),i(this,st).executor.provideConnection(async v=>{const x=i(this,st).executor.withConnectionProvider(new Ta(v)),W=new Zs({...u,executor:x});try{await i(this,st).driver.beginTransaction(v,d);const V=await e(W);return await i(this,st).driver.commitTransaction(v),V}catch(V){throw await i(this,st).driver.rollbackTransaction(v),V}})}};st=new WeakMap;let Qn=so;Q(Qn,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function pc(t){if(t.isolationLevel&&!hc.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const as=class as{constructor(e){N(this,Yr);N(this,Fi);N(this,Qi);N(this,_e,void 0);g(this,_e,a(e))}get expressionType(){}as(e){return new mc(this,e)}$castTo(){return new as({...i(this,_e)})}castTo(){return this.$castTo()}withPlugin(e){return new as({...i(this,_e),plugins:i(this,_e).plugins!==void 0?a([...i(this,_e).plugins,e]):a([e])})}toOperationNode(){return j(this,Fi,Do).call(this,j(this,Yr,Ws).call(this))}compile(e){return j(this,Qi,Ro).call(this,j(this,Yr,Ws).call(this,e))}async execute(e){const r=j(this,Yr,Ws).call(this,e);return r.executeQuery(j(this,Qi,Ro).call(this,r),i(this,_e).queryId)}};_e=new WeakMap,Yr=new WeakSet,Ws=function(e){const r=e!==void 0?e.getExecutor():Qs;return i(this,_e).plugins!==void 0?r.withPlugins(i(this,_e).plugins):r},Fi=new WeakSet,Do=function(e){return e.transformQuery(i(this,_e).rawNode,i(this,_e).queryId)},Qi=new WeakSet,Ro=function(e){return e.compileQuery(j(this,Fi,Do).call(this,e),i(this,_e).queryId)};let Ze=as;Q(Ze,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class mc{constructor(e,r){N(this,Xr,void 0);N(this,$t,void 0);g(this,Xr,e),g(this,$t,r)}get expression(){return i(this,Xr)}get alias(){return i(this,$t)}toOperationNode(){return At.create(i(this,Xr).toOperationNode(),je(i(this,$t))?i(this,$t).toOperationNode():re.create(i(this,$t)))}}Xr=new WeakMap,$t=new WeakMap;const Me=Object.assign((t,...e)=>new Ze({queryId:Y(),rawNode:ke.create(t,(e==null?void 0:e.map(bt))??[])}),{ref(t){return new Ze({queryId:Y(),rawNode:ke.createWithChild(er(t))})},val(t){return new Ze({queryId:Y(),rawNode:ke.createWithChild(bt(t))})},value(t){return this.val(t)},table(t){return new Ze({queryId:Y(),rawNode:ke.createWithChild(Le(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new Ze({queryId:Y(),rawNode:ke.create(e,t.map(re.create))})},lit(t){return new Ze({queryId:Y(),rawNode:ke.createWithChild(Xe.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new Ze({queryId:Y(),rawNode:ke.createWithSql(t)})},join(t,e=Me`, `){const r=new Array(2*t.length-1),u=e.toOperationNode();for(let d=0;d{this.nodeStack.push(e),i(this,us)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}us=new WeakMap;class Nc extends yc{constructor(){super(...arguments);N(this,Zr,"");N(this,mr,[])}get numParameters(){return i(this,mr).length}compileQuery(r){return g(this,Zr,""),g(this,mr,[]),this.visitNode(r),a({query:r,sql:this.getSql(),parameters:[...i(this,mr)]})}getSql(){return i(this,Zr)}visitSelectQuery(r){const u=this.parentNode!==void 0&&!ht.is(this.parentNode)&&!_t.is(this.parentNode)&&!la.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 v=0;v<=d;v++)this.visitNode(r[v]),vv&&this.visitNode(d[v])}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(L.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(wc[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 ai.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))}visitJSONReference(r){this.visitNode(r.reference),this.visitNode(r.traversal)}visitJSONPath(r){r.inOperator&&this.visitNode(r.inOperator),this.append("'$");for(const u of r.pathLegs)this.visitNode(u);this.append("'")}visitJSONPathLeg(r){const u=r.type==="ArrayLocation";this.append(u?"[":"."),this.append(String(r.value)),u&&this.append("]")}visitJSONOperatorChain(r){for(let u=0,d=r.values.length;u"),this.visitNode(r.values[u])}append(r){g(this,Zr,i(this,Zr)+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 v="";for(const x of r)v+=x,x===u?v+=u:x===d&&(v+=d);return v}addParameter(r){i(this,mr).push(r)}appendImmediateValue(r){if(B(r))this.append(`'${r}'`);else if(le(r)||ni(r))this.append(r.toString());else if(Lo(r))this.append("null");else if(Mu(r))this.appendImmediateValue(r.toISOString());else if(Fu(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}Zr=new WeakMap,mr=new WeakMap;const wc=a({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),vc=a({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),Sr=a({raw(t,e=[]){return a({sql:t,query:ke.createWithSql(t),parameters:a(e)})}}),bc=/"/g;class gc extends Nc{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(bc,'""')}visitDefaultInsertValue(e){this.append("null")}}const xc="kysely_migration",Oc="kysely_migration_lock";a({__noMigrations__:!0});class qc{constructor(e){N(this,hs);N(this,ei,void 0);g(this,ei,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=i(this,ei).selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",xc).where("name","!=",Oc));const u=await r.execute();return Promise.all(u.map(({name:d})=>j(this,hs,Pu).call(this,d)))}async getMetadata(e){return{tables:await this.getTables(e)}}}ei=new WeakMap,hs=new WeakSet,Pu=async function(e){var x,W,V,c,Ee,Ae;const r=i(this,ei),u=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),d=(Ae=(Ee=(c=(V=(W=(x=u.sql)==null?void 0:x.split(/[\(\),]/))==null?void 0:W.find(_=>_.toLowerCase().includes("autoincrement")))==null?void 0:V.trimStart())==null?void 0:c.split(/\s+/))==null?void 0:Ee[0])==null?void 0:Ae.replace(/["`]/g,""),v=await r.selectFrom(Me`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:u.type==="view",columns:v.map(_=>({name:_.name,dataType:_.type,isNullable:!_.notnull,isAutoIncrementing:_.name===d,hasDefaultValue:_.dflt_value!=null}))}};class Cc{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Wc=class{createQueryCompiler(){return new gc}createAdapter(){return new Cc}createIntrospector(t){return new qc(t)}},kc=(Ra=class{constructor(){N(this,Ui,new Ic);M(this,"connection")}async acquireConnection(){return await i(this,Ui).lock(),this.connection}async beginTransaction(t){await t.executeQuery(Sr.raw("begin"))}async commitTransaction(t){await t.executeQuery(Sr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Sr.raw("rollback"))}async releaseConnection(){i(this,Ui).unlock()}},Ui=new WeakMap,Ra),Ic=class{constructor(){M(this,"promise");M(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()}},Tc=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,v=null;function x(){u&&clearTimeout(u),d=0,v=null}function W(){d>=r?(t(v),x()):(u&&clearTimeout(u),u=setTimeout(()=>{t(v),x(),u=void 0},e))}return V=>{d++,v=V,u===void 0&&d===0?(t(V),d++):W()}}var Ec=class extends kc{constructor(e){super();M(this,"config");M(this,"db");this.config=e}async init(){var e,r,u,d,v,x;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 Ac(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),await((x=(v=this.config).onCreateConnection)==null?void 0:x.call(v,this.connection))}async beginTransaction(e){await e.executeQuery(Sr.raw("begin")),e.transactionNum++}async commitTransaction(e){await e.executeQuery(Sr.raw("commit")),e.transactionNum--}async rollbackTransaction(e){await e.executeQuery(Sr.raw("rollback")),e.transactionNum--}async destroy(){var e;(e=this.db)==null||e.close()}},Ac=class extends Tc{constructor(e,r,u=!1,d=1e3,v=2e3){super();M(this,"db");M(this,"onWrite");M(this,"transactionNum",0);this.db=e,this.onWrite=r?u?Sc({func:r,maxCalls:d,delay:v}):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}}},Dc=(La=class extends Wc{constructor(e){super();N(this,Ji,void 0);g(this,Ji,e)}createDriver(){return new Ec(i(this,Ji))}},Ji=new WeakMap,La);function Rc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Lc(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 v=Function.bind.apply(e,d);return new v}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 Ea={exports:{}},_c={},Bc=Object.freeze({__proto__:null,default:_c}),Un=Lc(Bc);(function(t,e){var r=void 0,u=function(d){return r||(r=new Promise(function(v,x){var W=typeof d<"u"?d:{},V=W.onAbort;W.onAbort=function(n){x(new Error(n)),V&&V(n)},W.postRun=W.postRun||[],W.postRun.push(function(){v(W)}),t=void 0;var c;c||(c=typeof W<"u"?W:{}),c.onRuntimeInitialized=function(){function n(f,w){switch(typeof w){case"boolean":jl(f,w?1:0);break;case"number":Jl(f,w);break;case"string":Vl(f,w,-1,-1);break;case"object":if(w===null)ku(f);else if(w.length!=null){var O=ko(w);$l(f,O,w.length,-1),Os(O)}else Cs(f,"Wrong API use : tried to return a value of an unknown type ("+w+").",-1);break;default:ku(f)}}function s(f,w){for(var O=[],k=0;k>>0),f!=null){var w=this.filename,O="/",k=w;if(O&&(O=typeof O=="string"?O:Ki(O),k=w?It(O+"/"+w):O),w=pu(!0,!0),k=ms(k,(w!==void 0?w:438)&4095|32768,0),f){if(typeof f=="string"){O=Array(f.length);for(var R=0,$=f.length;R<$;++R)O[R]=f.charCodeAt(R);f=O}Ns(k,w|146),O=ii(k,577),lu(O,f,0,f.length,0),vo(O),Ns(k,w)}}this.handleError(S(this.filename,p)),this.db=kt(p,"i32"),Gl(this.db),this.Za={},this.Na={}}var p=Yt(4),m=c.cwrap,S=m("sqlite3_open","number",["string","number"]),J=m("sqlite3_close_v2","number",["number"]),P=m("sqlite3_exec","number",["number","string","number","number","number"]),ce=m("sqlite3_changes","number",["number"]),Tt=m("sqlite3_prepare_v2","number",["number","string","number","number","number"]),xu=m("sqlite3_sql","string",["number"]),gl=m("sqlite3_normalized_sql","string",["number"]),Ou=m("sqlite3_prepare_v2","number",["number","number","number","number","number"]),xl=m("sqlite3_bind_text","number",["number","number","number","number","number"]),qu=m("sqlite3_bind_blob","number",["number","number","number","number","number"]),Ol=m("sqlite3_bind_double","number",["number","number","number"]),ql=m("sqlite3_bind_int","number",["number","number","number"]),Cl=m("sqlite3_bind_parameter_index","number",["number","string"]),Wl=m("sqlite3_step","number",["number"]),kl=m("sqlite3_errmsg","string",["number"]),Il=m("sqlite3_column_count","number",["number"]),Tl=m("sqlite3_data_count","number",["number"]),Sl=m("sqlite3_column_double","number",["number","number"]),Cu=m("sqlite3_column_text","string",["number","number"]),El=m("sqlite3_column_blob","number",["number","number"]),Al=m("sqlite3_column_bytes","number",["number","number"]),Dl=m("sqlite3_column_type","number",["number","number"]),Rl=m("sqlite3_column_name","string",["number","number"]),Ll=m("sqlite3_reset","number",["number"]),_l=m("sqlite3_clear_bindings","number",["number"]),Bl=m("sqlite3_finalize","number",["number"]),Wu=m("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),Pl=m("sqlite3_value_type","number",["number"]),Ml=m("sqlite3_value_bytes","number",["number"]),Fl=m("sqlite3_value_text","string",["number"]),Ql=m("sqlite3_value_blob","number",["number"]),Ul=m("sqlite3_value_double","number",["number"]),Jl=m("sqlite3_result_double","",["number","number"]),ku=m("sqlite3_result_null","",["number"]),Vl=m("sqlite3_result_text","",["number","string","number","number"]),$l=m("sqlite3_result_blob","",["number","number","number","number"]),jl=m("sqlite3_result_int","",["number","number"]),Cs=m("sqlite3_result_error","",["number","string","number"]),Iu=m("sqlite3_aggregate_context","number",["number","number"]),Gl=m("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=Wl(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),Sl(this.La,f)},o.prototype.Cb=function(f){if(f==null&&(f=this.Ja,this.Ja+=1),f=Cu(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),Cu(this.La,f)},o.prototype.getBlob=function(f){f==null&&(f=this.Ja,this.Ja+=1);var w=Al(this.La,f);f=El(this.La,f);for(var O=new Uint8Array(w),k=0;k{ls||(cs=Un,ls=Un)},Vi=function(n,s){return oo(),n=ls.normalize(n),cs.readFileSync(n,s?void 0:"utf8")},ot=n=>(n=Vi(n,!0),n.buffer||(n=new Uint8Array(n)),n),Wt=(n,s,o)=>{oo(),n=ls.normalize(n),cs.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},We&&(ot=n=>{var s=new XMLHttpRequest;return s.open("GET",n,!1),s.responseType="arraybuffer",s.send(null),new Uint8Array(s.response)}),Wt=(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 _a=c.print||console.log.bind(console),yr=c.printErr||console.warn.bind(console);Object.assign(c,Ee),Ee=null,c.thisProgram&&(Ae=c.thisProgram);var $i;c.wasmBinary&&($i=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Gt("no native wasm support detected");var ao,Ba=!1,Pa=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function ji(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 ve(n,s){return n?ji(mt,n,s):""}function Nr(n,s,o,h){if(!(0=m){var S=n.charCodeAt(++p);m=65536+((m&1023)<<10)|S&1023}if(127>=m){if(o>=h)break;s[o++]=m}else{if(2047>=m){if(o+1>=h)break;s[o++]=192|m>>6}else{if(65535>=m){if(o+2>=h)break;s[o++]=224|m>>12}else{if(o+3>=h)break;s[o++]=240|m>>18,s[o++]=128|m>>12&63}s[o++]=128|m>>6&63}s[o++]=128|m&63}}return s[o]=0,o-l}function ti(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 uo,ye,mt,ds,T,ue,ho,co;function Ma(){var n=ao.buffer;uo=n,c.HEAP8=ye=new Int8Array(n),c.HEAP16=ds=new Int16Array(n),c.HEAP32=T=new Int32Array(n),c.HEAPU8=mt=new Uint8Array(n),c.HEAPU16=new Uint16Array(n),c.HEAPU32=ue=new Uint32Array(n),c.HEAPF32=ho=new Float32Array(n),c.HEAPF64=co=new Float64Array(n)}var jt,Fa=[],Qa=[],Ua=[];function ol(){var n=c.preRun.shift();Fa.unshift(n)}var wr=0,Gi=null;function Gt(n){throw c.onAbort&&c.onAbort(n),n="Aborted("+n+")",yr(n),Ba=!0,new WebAssembly.RuntimeError(n+". Build with -sASSERTIONS for more info.")}function Ja(){return ze.startsWith("data:application/octet-stream;base64,")}var ze;if(ze="sql-wasm.wasm",!Ja()){var Va=ze;ze=c.locateFile?c.locateFile(Va,Oe):Oe+Va}function $a(){var n=ze;try{if(n==ze&&$i)return new Uint8Array($i);if(ot)return ot(n);throw"both async and sync fetching of the wasm failed"}catch(s){Gt(s)}}function al(){if(!$i&&(_||We)){if(typeof fetch=="function"&&!ze.startsWith("file://"))return fetch(ze,{credentials:"same-origin"}).then(function(n){if(!n.ok)throw"failed to load wasm binary file at '"+ze+"'";return n.arrayBuffer()}).catch(function(){return $a()});if(Wt)return new Promise(function(n,s){Wt(ze,function(o){n(new Uint8Array(o))},s)})}return Promise.resolve().then(function(){return $a()})}var E,he;function lo(n){for(;0>0];case"i8":return ye[n>>0];case"i16":return ds[n>>1];case"i32":return T[n>>2];case"i64":return T[n>>2];case"float":return ho[n>>2];case"double":return co[n>>3];case"*":return ue[n>>2];default:Gt("invalid type for getValue: "+s)}return null}function zi(n){var s="i32";switch(s.endsWith("*")&&(s="*"),s){case"i1":ye[n>>0]=0;break;case"i8":ye[n>>0]=0;break;case"i16":ds[n>>1]=0;break;case"i32":T[n>>2]=0;break;case"i64":he=[0,(E=0,1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[n>>2]=he[0],T[n+4>>2]=he[1];break;case"float":ho[n>>2]=0;break;case"double":co[n>>3]=0;break;case"*":ue[n>>2]=0;break;default:Gt("invalid type for setValue: "+s)}}var fo=(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},It=n=>{var s=n.charAt(0)==="/",o=n.substr(-1)==="/";return(n=fo(n.split("/").filter(h=>!!h),!s).join("/"))||s||(n="."),n&&o&&(n+="/"),(s?"/":"")+n},ul=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)},fs=n=>{if(n==="/")return"/";n=It(n),n=n.replace(/\/$/,"");var s=n.lastIndexOf("/");return s===-1?n:n.substr(s+1)};function hl(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var n=new Uint8Array(1);return()=>(crypto.getRandomValues(n),n[0])}if(H)try{var s=Un;return()=>s.randomBytes(1)[0]}catch{}return()=>Gt("randomDevice")}function ps(){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=fo(n.split("/").filter(h=>!!h),!s).join("/"),(s?"/":"")+n||"."}function ja(n,s){var o=Array(ti(n)+1);return n=Nr(n,o,0,o.length),s&&(o.length=n),o}var Ga=[];function za(n,s){Ga[n]={input:[],output:[],Xa:s},No(n,cl)}var cl={open:function(n){var s=Ga[n.node.rdev];if(!s)throw new y(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 y(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 y(28);return s},lb:function(n,s,o){A.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 y(43);if(n=n.node.Ia,l&2||n.buffer!==uo){if((0{if(n=ps("/",n),!n)return{path:"",node:null};if(s=Object.assign({rb:!0,kb:0},s),8!!m),!1);for(var o=po,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}},yo=(n,s)=>{for(var o=0,h=0;h>>0)%Kt.length},Ya=n=>{var s=yo(n.parent.id,n.name);if(Kt[s]===n)Kt[s]=n.Wa;else for(s=Kt[s];s;){if(s.Wa===n){s.Wa=n.Wa;break}s=s.Wa}},vr=(n,s)=>{var o;if(o=(o=ri(n,"x"))?o:n.Ga.lookup?0:2)throw new y(o,n);for(o=Kt[yo(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)},Xa=(n,s,o,h)=>(n=new wu(n,s,o,h),s=yo(n.parent.id,n.name),n.Wa=Kt[s],Kt[s]=n),pl={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Za=n=>{var s=["r","w","rw"][n&3];return n&512&&(s+="w"),s},ri=(n,s)=>{if(Ha)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},eu=(n,s)=>{try{return vr(n,s),20}catch{}return ri(n,"wx")},tu=(n,s,o)=>{try{var h=vr(n,s)}catch(l){return l.Ka}if(n=ri(n,"wx"))return n;if(o){if((h.mode&61440)!==16384)return 54;if(h===h.parent||Ki(h)==="/")return 10}else if((h.mode&61440)===16384)return 31;return 0},ml=(n=0)=>{for(;4096>=n;n++)if(!zt[n])return n;throw new y(33)},ru=(n,s)=>(Xi||(Xi=function(){this.$a={}},Xi.prototype={},Object.defineProperties(Xi.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 Xi,n),s=ml(s),n.fd=s,zt[s]=n),yl={open:n=>{n.Ha=Ka[n.node.rdev].Ha,n.Ha.open&&n.Ha.open(n)},Ta:()=>{throw new y(70)}},No=(n,s)=>{Ka[n]={Ha:s}},iu=(n,s)=>{var o=s==="/",h=!s;if(o&&po)throw new y(10);if(!o&&!h){var l=Be(s,{rb:!1});if(s=l.path,l=l.node,l.Va)throw new y(10);if((l.mode&61440)!==16384)throw new y(54)}s={type:n,Kb:{},ub:s,Eb:[]},n=n.Ra(s),n.Ra=s,s.root=n,o?po=n:l&&(l.Va=s,l.Ra&&l.Ra.Eb.push(s))},ms=(n,s,o)=>{var h=Be(n,{parent:!0}).node;if(n=fs(n),!n||n==="."||n==="..")throw new y(28);var l=eu(h,n);if(l)throw new y(l);if(!h.Ga.ab)throw new y(63);return h.Ga.ab(h,n,s,o)},yt=(n,s)=>ms(n,(s!==void 0?s:511)&1023|16384,0),ys=(n,s,o)=>{typeof o>"u"&&(o=s,s=438),ms(n,s|8192,o)},wo=(n,s)=>{if(!ps(n))throw new y(44);var o=Be(s,{parent:!0}).node;if(!o)throw new y(44);s=fs(s);var h=eu(o,s);if(h)throw new y(h);if(!o.Ga.symlink)throw new y(63);o.Ga.symlink(o,s,n)},nu=n=>{var s=Be(n,{parent:!0}).node;n=fs(n);var o=vr(s,n),h=tu(s,n,!0);if(h)throw new y(h);if(!s.Ga.rmdir)throw new y(63);if(o.Va)throw new y(10);s.Ga.rmdir(s,n),Ya(o)},su=n=>{var s=Be(n,{parent:!0}).node;if(!s)throw new y(44);n=fs(n);var o=vr(s,n),h=tu(s,n,!1);if(h)throw new y(h);if(!s.Ga.unlink)throw new y(63);if(o.Va)throw new y(10);s.Ga.unlink(s,n),Ya(o)},ou=n=>{if(n=Be(n).node,!n)throw new y(44);if(!n.Ga.readlink)throw new y(28);return ps(Ki(n.parent),n.Ga.readlink(n))},Hi=(n,s)=>{if(n=Be(n,{Sa:!s}).node,!n)throw new y(44);if(!n.Ga.Pa)throw new y(63);return n.Ga.Pa(n)},au=n=>Hi(n,!0),Ns=(n,s)=>{if(n=typeof n=="string"?Be(n,{Sa:!0}).node:n,!n.Ga.Oa)throw new y(63);n.Ga.Oa(n,{mode:s&4095|n.mode&-4096,timestamp:Date.now()})},uu=(n,s)=>{if(0>s)throw new y(28);if(n=typeof n=="string"?Be(n,{Sa:!0}).node:n,!n.Ga.Oa)throw new y(63);if((n.mode&61440)===16384)throw new y(31);if((n.mode&61440)!==32768)throw new y(28);var o=ri(n,"w");if(o)throw new y(o);n.Ga.Oa(n,{size:s,timestamp:Date.now()})},ii=(n,s,o)=>{if(n==="")throw new y(44);if(typeof s=="string"){var h=pl[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=It(n);try{l=Be(n,{Sa:!(s&131072)}).node}catch{}}if(h=!1,s&64)if(l){if(s&128)throw new y(20)}else l=ms(n,o,0),h=!0;if(!l)throw new y(44);if((l.mode&61440)===8192&&(s&=-513),s&65536&&(l.mode&61440)!==16384)throw new y(54);if(!h&&(o=l?(l.mode&61440)===40960?32:(l.mode&61440)===16384&&(Za(s)!=="r"||s&512)?31:ri(l,Za(s)):44))throw new y(o);return s&512&&!h&&uu(l,0),s&=-131713,l=ru({node:l,path:Ki(l),flags:s,seekable:!0,position:0,Ha:l.Ha,Ib:[],error:!1}),l.Ha.open&&l.Ha.open(l),!c.logReadFiles||s&1||(ws||(ws={}),n in ws||(ws[n]=1)),l},vo=n=>{if(n.fd===null)throw new y(8);n.hb&&(n.hb=null);try{n.Ha.close&&n.Ha.close(n)}catch(s){throw s}finally{zt[n.fd]=null}n.fd=null},hu=(n,s,o)=>{if(n.fd===null)throw new y(8);if(!n.seekable||!n.Ha.Ta)throw new y(70);if(o!=0&&o!=1&&o!=2)throw new y(28);n.position=n.Ha.Ta(n,s,o),n.Ib=[]},cu=(n,s,o,h,l)=>{if(0>h||0>l)throw new y(28);if(n.fd===null)throw new y(8);if((n.flags&2097155)===1)throw new y(8);if((n.node.mode&61440)===16384)throw new y(31);if(!n.Ha.read)throw new y(28);var p=typeof l<"u";if(!p)l=n.position;else if(!n.seekable)throw new y(70);return s=n.Ha.read(n,s,o,h,l),p||(n.position+=s),s},lu=(n,s,o,h,l)=>{if(0>h||0>l)throw new y(28);if(n.fd===null)throw new y(8);if(!(n.flags&2097155))throw new y(8);if((n.node.mode&61440)===16384)throw new y(31);if(!n.Ha.write)throw new y(28);n.seekable&&n.flags&1024&&hu(n,0,2);var p=typeof l<"u";if(!p)l=n.position;else if(!n.seekable)throw new y(70);return s=n.Ha.write(n,s,o,h,l,void 0),p||(n.position+=s),s},Nl=n=>{var s,o=ii(n,o||0);n=Hi(n).size;var h=new Uint8Array(n);return cu(o,h,0,n,0),s=h,vo(o),s},du=()=>{y||(y=function(n,s){this.node=s,this.Hb=function(o){this.Ka=o},this.Hb(n),this.message="FS error"},y.prototype=Error(),y.prototype.constructor=y,[44].forEach(n=>{mo[n]=new y(n),mo[n].stack=""}))},fu,pu=(n,s)=>{var o=0;return n&&(o|=365),s&&(o|=146),o},Yi=(n,s,o)=>{n=It("/dev/"+n);var h=pu(!!s,!!o);bo||(bo=64);var l=bo++<<8|0;No(l,{open:p=>{p.seekable=!1},close:()=>{o&&o.buffer&&o.buffer.length&&o(10)},read:(p,m,S,J)=>{for(var P=0,ce=0;ce{for(var P=0;P>2]=h.dev,T[o+8>>2]=h.ino,T[o+12>>2]=h.mode,ue[o+16>>2]=h.nlink,T[o+20>>2]=h.uid,T[o+24>>2]=h.gid,T[o+28>>2]=h.rdev,he=[h.size>>>0,(E=h.size,1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+40>>2]=he[0],T[o+44>>2]=he[1],T[o+48>>2]=4096,T[o+52>>2]=h.blocks,he=[Math.floor(h.atime.getTime()/1e3)>>>0,(E=Math.floor(h.atime.getTime()/1e3),1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+56>>2]=he[0],T[o+60>>2]=he[1],ue[o+64>>2]=0,he=[Math.floor(h.mtime.getTime()/1e3)>>>0,(E=Math.floor(h.mtime.getTime()/1e3),1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+72>>2]=he[0],T[o+76>>2]=he[1],ue[o+80>>2]=0,he=[Math.floor(h.ctime.getTime()/1e3)>>>0,(E=Math.floor(h.ctime.getTime()/1e3),1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+88>>2]=he[0],T[o+92>>2]=he[1],ue[o+96>>2]=0,he=[h.ino>>>0,(E=h.ino,1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[o+104>>2]=he[0],T[o+108>>2]=he[1],0}var bs=void 0;function gs(){return bs+=4,T[bs-4>>2]}function at(n){if(n=zt[n],!n)throw new y(8);return n}function go(n){return ue[n>>2]+4294967296*T[n+4>>2]}function mu(n){var s=ti(n)+1,o=xs(s);return o&&Nr(n,ye,o,s),o}function wl(n,s,o){function h(J){return(J=J.toTimeString().match(/\(([A-Za-z ]+)\)$/))?J[1]:"GMT"}var l=new Date().getFullYear(),p=new Date(l,0,1),m=new Date(l,6,1);l=p.getTimezoneOffset();var S=m.getTimezoneOffset();T[n>>2]=60*Math.max(l,S),T[s>>2]=+(l!=S),n=h(p),s=h(m),n=mu(n),s=mu(s),S>2]=n,ue[o+4>>2]=s):(ue[o>>2]=s,ue[o+4>>2]=n)}function xo(n,s,o){xo.Bb||(xo.Bb=!0,wl(n,s,o))}var yu;yu=H?()=>{var n=process.hrtime();return 1e3*n[0]+n[1]/1e6}:()=>performance.now();var Oo={};function Nu(){if(!qo){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",_:Ae||"./this.program"},s;for(s in Oo)Oo[s]===void 0?delete n[s]:n[s]=Oo[s];var o=[];for(s in n)o.push(s+"="+n[s]);qo=o}return qo}var qo,Ht=void 0,Co=[];function Wo(n,s){if(!Ht){Ht=new WeakMap;var o=jt.length;if(Ht)for(var h=0;h<0+o;h++){var l=jt.get(h);l&&Ht.set(l,h)}}if(Ht.has(n))return Ht.get(n);if(Co.length)o=Co.pop();else{try{jt.grow(1)}catch(S){throw S instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":S}o=jt.length-1}try{jt.set(o,n)}catch(S){if(!(S instanceof TypeError))throw S;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]]]},m=1;mm?h.push(m):h.push(m%128|128,m>>7),m=0;ml?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}jt.set(o,s)}return Ht.set(n,o),o}function Zi(n){Ht.delete(jt.get(n)),Co.push(n)}function ko(n){var s=xs(n.length);return n.subarray||n.slice||(n=new Uint8Array(n)),mt.set(n,s),s}function vl(n,s,o,h){var l={string:P=>{var ce=0;if(P!=null&&P!==0){var Tt=(P.length<<2)+1;ce=Yt(Tt),Nr(P,mt,ce,Tt)}return ce},array:P=>{var ce=Yt(P.length);return ye.set(P,ce),ce}};n=c["_"+n];var p=[],m=0;if(h)for(var S=0;S{yt("/dev"),No(259,{read:()=>0,write:(s,o,h,l)=>l}),ys("/dev/null",259),za(1280,ll),za(1536,dl),ys("/dev/tty",1280),ys("/dev/tty1",1536);var n=hl();Yi("random",n),Yi("urandom",n),yt("/dev/shm"),yt("/dev/shm/tmp")})(),(()=>{yt("/proc");var n=yt("/proc/self");yt("/proc/self/fd"),iu({Ra:()=>{var s=Xa(n,"fd",16895,73);return s.Ga={lookup:(o,h)=>{var l=zt[+h];if(!l)throw new y(8);return o={parent:null,Ra:{ub:"fake"},Ga:{readlink:()=>l.path}},o.parent=o}},s}},"/proc/self/fd")})();var bl={a:function(n,s,o,h){Gt("Assertion failed: "+ve(n)+", at: "+[s?ve(s):"unknown filename",o,h?ve(h):"unknown function"])},h:function(n,s){try{return n=ve(n),Ns(n,s),0}catch(o){if(typeof te>"u"||!(o instanceof y))throw o;return-o.Ka}},H:function(n,s,o){try{if(s=ve(s),s=br(n,s),o&-8)return-28;var h=Be(s,{Sa:!0}).node;return h?(n="",o&4&&(n+="r"),o&2&&(n+="w"),o&1&&(n+="x"),n&&ri(h,n)?-2:0):-44}catch(l){if(typeof te>"u"||!(l instanceof y))throw l;return-l.Ka}},i:function(n,s){try{var o=zt[n];if(!o)throw new y(8);return Ns(o.node,s),0}catch(h){if(typeof te>"u"||!(h instanceof y))throw h;return-h.Ka}},g:function(n){try{var s=zt[n];if(!s)throw new y(8);var o=s.node,h=typeof o=="string"?Be(o,{Sa:!0}).node:o;if(!h.Ga.Oa)throw new y(63);return h.Ga.Oa(h,{timestamp:Date.now()}),0}catch(l){if(typeof te>"u"||!(l instanceof y))throw l;return-l.Ka}},b:function(n,s,o){bs=o;try{var h=at(n);switch(s){case 0:var l=gs();return 0>l?-28:ru(h,l).fd;case 1:case 2:return 0;case 3:return h.flags;case 4:return l=gs(),h.flags|=l,0;case 5:return l=gs(),ds[l+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return T[vu()>>2]=28,-1;default:return-28}}catch(p){if(typeof te>"u"||!(p instanceof y))throw p;return-p.Ka}},G:function(n,s){try{var o=at(n);return vs(Hi,o.path,s)}catch(h){if(typeof te>"u"||!(h instanceof y))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=zt[n];if(!h)throw new y(8);if(!(h.flags&2097155))throw new y(28);return uu(h.node,s),0}catch(l){if(typeof te>"u"||!(l instanceof y))throw l;return-l.Ka}},B:function(n,s){try{if(s===0)return-28;var o=ti("/")+1;return s"u"||!(h instanceof y))throw h;return-h.Ka}},E:function(n,s){try{return n=ve(n),vs(au,n,s)}catch(o){if(typeof te>"u"||!(o instanceof y))throw o;return-o.Ka}},y:function(n,s,o){try{return s=ve(s),s=br(n,s),s=It(s),s[s.length-1]==="/"&&(s=s.substr(0,s.length-1)),yt(s,o),0}catch(h){if(typeof te>"u"||!(h instanceof y))throw h;return-h.Ka}},D:function(n,s,o,h){try{s=ve(s);var l=h&256;return s=br(n,s,h&4096),vs(l?au:Hi,s,o)}catch(p){if(typeof te>"u"||!(p instanceof y))throw p;return-p.Ka}},v:function(n,s,o,h){bs=h;try{s=ve(s),s=br(n,s);var l=h?gs():0;return ii(s,o,l).fd}catch(p){if(typeof te>"u"||!(p instanceof y))throw p;return-p.Ka}},t:function(n,s,o,h){try{if(s=ve(s),s=br(n,s),0>=h)return-28;var l=ou(s),p=Math.min(h,ti(l)),m=ye[o+p];return Nr(l,mt,o,h+1),ye[o+p]=m,p}catch(S){if(typeof te>"u"||!(S instanceof y))throw S;return-S.Ka}},s:function(n){try{return n=ve(n),nu(n),0}catch(s){if(typeof te>"u"||!(s instanceof y))throw s;return-s.Ka}},F:function(n,s){try{return n=ve(n),vs(Hi,n,s)}catch(o){if(typeof te>"u"||!(o instanceof y))throw o;return-o.Ka}},p:function(n,s,o){try{return s=ve(s),s=br(n,s),o===0?su(s):o===512?nu(s):Gt("Invalid flags passed to unlinkat"),0}catch(h){if(typeof te>"u"||!(h instanceof y))throw h;return-h.Ka}},o:function(n,s,o){try{if(s=ve(s),s=br(n,s,!0),o){var h=go(o),l=T[o+8>>2];p=1e3*h+l/1e6,o+=16,h=go(o),l=T[o+8>>2],m=1e3*h+l/1e6}else var p=Date.now(),m=p;n=p;var S=Be(s,{Sa:!0}).node;return S.Ga.Oa(S,{timestamp:Math.max(n,m)}),0}catch(J){if(typeof te>"u"||!(J instanceof y))throw J;return-J.Ka}},e:function(){return Date.now()},j:function(n,s){n=new Date(1e3*go(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 m=at(h);if(s&2&&!(o&2)&&(m.flags&2097155)!==2)throw new y(2);if((m.flags&2097155)===1)throw new y(2);if(!m.Ha.bb)throw new y(43);var S=m.Ha.bb(m,n,l,s,o),J=S.Fb;return T[p>>2]=S.vb,J}catch(P){if(typeof te>"u"||!(P instanceof y))throw P;return-P.Ka}},x:function(n,s,o,h,l,p){try{var m=at(l);if(o&2){var S=mt.slice(n,n+s);m&&m.Ha.cb&&m.Ha.cb(m,S,p,s,h)}}catch(J){if(typeof te>"u"||!(J instanceof y))throw J;return-J.Ka}},n:xo,q:function(){return 2147483648},d:yu,c:function(n){var s=mt.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{ao.grow(l-uo.byteLength+65535>>>16),Ma();var p=1;break e}catch{}p=void 0}if(p)return!0}return!1},z:function(n,s){var o=0;return Nu().forEach(function(h,l){var p=s+o;for(l=ue[n+4*l>>2]=p,p=0;p>0]=h.charCodeAt(p);ye[l>>0]=0,o+=h.length+1}),0},A:function(n,s){var o=Nu();ue[n>>2]=o.length;var h=0;return o.forEach(function(l){h+=l.length+1}),ue[s>>2]=h,0},f:function(n){try{var s=at(n);return vo(s),0}catch(o){if(typeof te>"u"||!(o instanceof y))throw o;return o.Ka}},m:function(n,s){try{var o=at(n);return ye[s>>0]=o.tty?2:(o.mode&61440)===16384?3:(o.mode&61440)===40960?7:4,0}catch(h){if(typeof te>"u"||!(h instanceof y))throw h;return h.Ka}},u:function(n,s,o,h){try{e:{var l=at(n);n=s;for(var p=s=0;p>2],S=ue[n+4>>2];n+=8;var J=cu(l,ye,m,S);if(0>J){var P=-1;break e}if(s+=J,J>2]=P,0}catch(ce){if(typeof te>"u"||!(ce instanceof y))throw ce;return ce.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=at(n);return hu(p,s,h),he=[p.position>>>0,(E=p.position,1<=+Math.abs(E)?0>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],T[l>>2]=he[0],T[l+4>>2]=he[1],p.hb&&s===0&&h===0&&(p.hb=null),0}catch(m){if(typeof te>"u"||!(m instanceof y))throw m;return m.Ka}},C:function(n){try{var s=at(n);return s.Ha&&s.Ha.fsync?s.Ha.fsync(s):0}catch(o){if(typeof te>"u"||!(o instanceof y))throw o;return o.Ka}},r:function(n,s,o,h){try{e:{var l=at(n);n=s;for(var p=s=0;p>2],S=ue[n+4>>2];n+=8;var J=lu(l,ye,m,S);if(0>J){var P=-1;break e}s+=J}P=s}return ue[h>>2]=P,0}catch(ce){if(typeof te>"u"||!(ce instanceof y))throw ce;return ce.Ka}}};(function(){function n(l){c.asm=l.exports,ao=c.asm.I,Ma(),jt=c.asm.Aa,Qa.unshift(c.asm.J),wr--,c.monitorRunDependencies&&c.monitorRunDependencies(wr),wr==0&&Gi&&(l=Gi,Gi=null,l())}function s(l){n(l.instance)}function o(l){return al().then(function(p){return WebAssembly.instantiate(p,h)}).then(function(p){return p}).then(l,function(p){yr("failed to asynchronously prepare wasm: "+p),Gt(p)})}var h={a:bl};if(wr++,c.monitorRunDependencies&&c.monitorRunDependencies(wr),c.instantiateWasm)try{return c.instantiateWasm(h,n)}catch(l){return yr("Module.instantiateWasm callback failed with error: "+l),!1}return function(){return $i||typeof WebAssembly.instantiateStreaming!="function"||Ja()||ze.startsWith("file://")||H||typeof fetch!="function"?o(s):fetch(ze,{credentials:"same-origin"}).then(function(l){return WebAssembly.instantiateStreaming(l,h).then(s,function(p){return yr("wasm streaming compile failed: "+p),yr("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 vu=c.___errno_location=function(){return(vu=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 xs=c._malloc=function(){return(xs=c._malloc=c.asm.ya).apply(null,arguments)},Os=c._free=function(){return(Os=c._free=c.asm.za).apply(null,arguments)};c._RegisterExtensionFunctions=function(){return(c._RegisterExtensionFunctions=c.asm.Ba).apply(null,arguments)};var bu=c._emscripten_builtin_memalign=function(){return(bu=c._emscripten_builtin_memalign=c.asm.Ca).apply(null,arguments)},en=c.stackSave=function(){return(en=c.stackSave=c.asm.Da).apply(null,arguments)},tn=c.stackRestore=function(){return(tn=c.stackRestore=c.asm.Ea).apply(null,arguments)},Yt=c.stackAlloc=function(){return(Yt=c.stackAlloc=c.asm.Fa).apply(null,arguments)};c.UTF8ToString=ve,c.stackAlloc=Yt,c.stackSave=en,c.stackRestore=tn,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 vl(n,s,o,arguments)}};var qs;Gi=function n(){qs||gu(),qs||(Gi=n)};function gu(){function n(){if(!qs&&(qs=!0,c.calledRun=!0,!Ba)){if(c.noFSInit||fu||(fu=!0,du(),c.stdin=c.stdin,c.stdout=c.stdout,c.stderr=c.stderr,c.stdin?Yi("stdin",c.stdin):wo("/dev/tty","/dev/stdin"),c.stdout?Yi("stdout",null,c.stdout):wo("/dev/tty","/dev/stdout"),c.stderr?Yi("stderr",null,c.stderr):wo("/dev/tty1","/dev/stderr"),ii("/dev/stdin",0),ii("/dev/stdout",1),ii("/dev/stderr",1)),Ha=!1,lo(Qa),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var s=c.postRun.shift();Ua.unshift(s)}lo(Ua)}}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(Jc,Math.max(Uc,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 $c=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,Aa=new Promise((t,e)=>{const r=$c.open(Qc,1);r.onupgradeneeded=()=>r.result.createObjectStore("files",{keyPath:"name"}),r.onsuccess=()=>t(r.result),r.onerror=()=>e(r.error)});async function jc(t){const e=await Aa,r=await new Promise((u,d)=>{const x=e.transaction("files","readonly").objectStore("files").get(t);x.onsuccess=()=>u(x.result),x.onerror=()=>d(x.error)});if(r&&!Er.has(t)){const u=new Vc(r.data);return Er.set(t,u),u}else return Er.has(t)?Er.get(t):null}async function Gc(t,e){const r=await Aa;await new Promise((u,d)=>{const x=r.transaction("files","readwrite").objectStore("files").put({name:t,data:e});x.onsuccess=()=>u(!0),x.onerror=()=>d(x.error)})}async function zc(t,e){if(await Gc(t,e),Er.has(t)){const r=Er.get(t);r.truncate(0),r.write(0,e)}}var Kc=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),Hc=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},Yc=class extends Fs{constructor(e){super();M(this,"serializer");this.serializer=e||Kc}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,v=this.serializer(u);return u===v?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...d,value:v}})}transformValue(e){return{...e,value:this.serializer(e.value)}}},Xc=class{constructor({deserializer:t,serializer:e}={}){M(this,"serializeParametersTransformer");M(this,"deserializer");M(this,"ctx");this.serializeParametersTransformer=new Yc(e),this.deserializer=t||Hc,this.ctx=new WeakMap}transformQuery({node:t,queryId:e}){return t.kind==="SelectQueryNode"&&this.ctx.set(e,t.kind),this.serializeParametersTransformer.transformNode(t)}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({result:t,queryId:e}){const{rows:r}=t,u=this.ctx.get(e);return this.ctx.delete(e),r&&u==="SelectQueryNode"?{...t,rows:await this.parseResult(r)}:t}};function eo(t){return typeof t=="string"}function Zc(t){return typeof t=="boolean"}async function Da(t,e,r,u,d="rowid"){await Me` - create trigger if not exists ${Me.raw(e)}_${Me.raw(u)} - after ${Me.raw(r)} - on ${Me.table(e)} - begin - update ${Me.table(e)} - set ${Me.ref(u)} = datetime('now','localtime') - where ${Me.ref(d)} = NEW.${Me.ref(d)}; - end - `.execute(t).catch(v=>{console.error(v)})}function el(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 tl(t,e,r=!1){for(const[u,d]of e){const{columns:v,property:x}=d;r&&await t.schema.dropTable(u).ifExists().execute().catch();let W=t.schema.createTable(u),V="rowid",c=!1,Ee="createAt",Ae="updateAt";if(x!=null&&x.timestamp&&!Zc(x.timestamp)){const{create:_,update:We}=x.timestamp;Ee=_??"createAt",Ae=We??"updateAt"}for(const _ in v){if(!Object.prototype.hasOwnProperty.call(v,_))continue;const We=v[_];let H="text";const{type:Oe,notNull:Vi,defaultTo:Wt}=We;switch(Oe){case"boolean":case"date":case"object":case"string":H="text";break;case"increments":V=_;case"number":H="integer";break;case"blob":H="blob"}[Ee,Ae].includes(_)||(W=W.addColumn(_,H,ot=>Oe==="increments"?(c=!0,ot.autoIncrement().primaryKey()):(Vi&&(ot=ot.notNull()),Wt!==void 0&&(ot=ot.defaultTo(Wt instanceof Function?Wt(Me):Wt)),ot)))}if(x){const _=x.primary,We=x.unique;if(x.timestamp&&(Ee&&(W=W.addColumn(Ee,"text")),Ae&&(W=W.addColumn(Ae,"text"))),!c&&_){const H=eo(_);V=H?_:_[0],W=W.addPrimaryKeyConstraint(`pk_${H?_:_.join("_")}`,H?[_]:_)}We==null||We.forEach(H=>{const Oe=eo(H);V=!_&&!c?Oe?H:H[0]:V,W=W.addUniqueConstraint(`un_${Oe?H:H.join("_")}`,Oe?[H]:H)})}if(await W.ifNotExists().execute(),x!=null&&x.index)for(const _ of x.index){const We=eo(_);let H=t.schema.createIndex(`idx_${We?_:_.join("_")}`).on(u);H=We?H.column(_):H.columns(_),await H.ifNotExists().execute()}x!=null&&x.timestamp&&(Ee&&await Da(t,u,"insert",Ee,V),Ae&&await Da(t,u,"update",Ae,V))}}var rl=class{constructor(){M(this,"items");this.items=[]}push(t){this.items.push(t)}pop(){return this.items.pop()}peek(){return this.items[this.items.length-1]}isEmpty(){return this.items.length===0}size(){return this.items.length}},il=class{constructor(t){M(this,"kysely");M(this,"status");M(this,"tableMap");M(this,"logger");M(this,"trxs");const{dialect:e,tables:r,dropTableBeforeInit:u,onQuery:d,plugins:v,logger:x}=t;this.logger=x;const W=v??[];W.push(new Xc),this.kysely=new Oi({dialect:e,log:V=>{var c;V.level==="error"?(c=this.logger)==null||c.error("Uncaught DB Error",V.error):d==null||d(V.query,V.queryDurationMillis)},plugins:W}),this.status=u?0:1,this.tableMap=el(r),this.trxs=new rl}async init(t=!1){const e=t||this.status===0;return await tl(this.kysely,this.tableMap,e),this.status=2,this}async isEmptyTable(){var t;return this.status!==2&&await this.init(),this.status===2?!1:((t=this.logger)==null||t.error("fail to init table"),!0)}async transaction(t,e){if(!await this.isEmptyTable())return await this.kysely.transaction().execute(r=>(this.trxs.push(r),t(r))).catch(r=>{var u;e&&((u=this.logger)==null||u.error(e,r))}).finally(()=>{this.trxs.pop()})}getDB(){return this.trxs.isEmpty()?this.kysely:this.trxs.peek()}async exec(t,e){if(!await this.isEmptyTable())return t(this.getDB()).catch(r=>{var u;e&&((u=this.logger)==null||u.error(e,r))})}async execOne(t,e){if(!await this.isEmptyTable())return t(this.getDB()).executeTakeFirstOrThrow().catch(r=>{var u;e&&((u=this.logger)==null||u.error(e,r))})}async execList(t,e){if(!await this.isEmptyTable())return t(this.getDB()).execute().catch(r=>{var u;e&&((u=this.logger)==null||u.error(e,r))})}async toSQL(t){return t(this.getDB()).compile()}async raw(t){if(!await this.isEmptyTable())return t(Me).execute(this.getDB())}};async function nl(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 sl=new Dc({async database(){const t=await Mc({locateFile:()=>Fc});return new t.Database(await jc("sqlijsWorker"))},onWrite:{func(t){console.log(`[sqljs worker] write to indexeddb, length: ${t.length}`),zc("sqlijsWorker",t)}}});onmessage=()=>{console.log("start sqljs test"),nl(sl).then(t=>{t==null||t.forEach(e=>console.log("[sqlijs]",e))})}})(); diff --git a/index.html b/index.html index 734903f..83300c4 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ test - +