@noormdev/cli 1.0.0-alpha.0 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4MUZ22JB.js +4 -0
- package/dist/chunk-BX5KFQ6D.js +1 -0
- package/dist/chunk-DGJUBN33.js +1 -0
- package/dist/chunk-MQJKW43U.js +1 -0
- package/dist/chunk-O7NFFKRC.js +1 -0
- package/dist/chunk-RBOB52ZJ.js +6 -0
- package/dist/chunk-TGNLDSZU.js +213 -0
- package/dist/devtools-RJP7TZE6.js +7 -0
- package/dist/engine-E7UBRVEC.js +1 -0
- package/dist/esm-FK2ZKTD7.js +2 -0
- package/dist/index.js +719 -271
- package/dist/mssql-2XQG4WUZ.js +1 -0
- package/dist/mysql-XWGAH4UX.js +1 -0
- package/dist/mysql2-KRZWXZIF.js +3007 -0
- package/dist/open-QFL643MX.js +2 -0
- package/dist/postgres-KQB7PRSJ.js +1 -0
- package/dist/sqlite-SK4I3XQS.js +1 -0
- package/dist/tarn-E5JKU5EV.js +1 -0
- package/dist/tedious-R2TVM4UU.js +191 -0
- package/package.json +2 -6
- package/dist/chunk-FQKJMLMW.js +0 -1
- package/dist/chunk-WOT6VMZA.js +0 -1
- package/dist/engine-Z55HXOAZ.js +0 -1
- package/dist/mssql-GVXYXFBZ.js +0 -1
- package/dist/mysql-LUTQ2CEP.js +0 -1
- package/dist/postgres-DEDRRMUE.js +0 -1
- package/dist/sqlite-OQR7CVXV.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as r,t as e}from"./chunk-O7NFFKRC.js";function n(t,o){return e.createWithChildren([e.createWithSql(`${t} `),r.create(o)])}export{n as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.create;var e=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var m=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(a&&(b=a(a=0)),b);var o=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),p=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0})},g=(a,b,c,f)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of j(b))!l.call(a,d)&&d!==c&&e(a,d,{get:()=>b[d],enumerable:!(f=i(b,d))||f.enumerable});return a};var q=(a,b,c)=>(c=a!=null?h(k(a)):{},g(b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c,a)),r=a=>g(e({},"__esModule",{value:!0}),a);export{m as a,n as b,o as c,p as d,q as e,r as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as te,B as ct,C as ut,D as Ve,E as lt,H as u,I as mt,J as z,L as ft,M as Nt,N as wt,O as yt,P as vt,Q as xt,R as gt,S as T,T as pe,U as Ct,V as f,a as et,b as ze,c as tt,d as Be,e as it,f as rt,g as st,i as Q,j as O,k as i,l as m,m as p,n as w,o as nt,p as ot,q as d,r as at,s as ht,t as C,u as ae,v as pt,w as dt,x as R,y as he,z as P}from"./chunk-O7NFFKRC.js";var o=i({is(t){return t.kind==="AlterTableNode"},create(t){return i({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return i({...t,...e})},cloneWithColumnAlteration(t,e){return i({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}});var y=i({is(t){return t.kind==="CreateIndexNode"},create(t){return i({kind:"CreateIndexNode",name:p.create(t)})},cloneWith(t,e){return i({...t,...e})},cloneWithColumns(t,e){return i({...t,columns:[...t.columns||[],...e]})}});var de=i({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return i({kind:"CreateSchemaNode",schema:p.create(t),...e})},cloneWith(t,e){return i({...t,...e})}});var bt=["preserve rows","delete rows","drop"],l=i({is(t){return t.kind==="CreateTableNode"},create(t){return i({kind:"CreateTableNode",table:t,columns:i([])})},cloneWithColumn(t,e){return i({...t,columns:i([...t.columns,e])})},cloneWithConstraint(t,e){return i({...t,constraints:t.constraints?i([...t.constraints,e]):i([e])})},cloneWithFrontModifier(t,e){return i({...t,frontModifiers:t.frontModifiers?i([...t.frontModifiers,e]):i([e])})},cloneWithEndModifier(t,e){return i({...t,endModifiers:t.endModifiers?i([...t.endModifiers,e]):i([e])})},cloneWith(t,e){return i({...t,...e})}});var E=i({is(t){return t.kind==="DropIndexNode"},create(t,e){return i({kind:"DropIndexNode",name:w.create(t),...e})},cloneWith(t,e){return i({...t,...e})}});var ie=i({is(t){return t.kind==="DropSchemaNode"},create(t,e){return i({kind:"DropSchemaNode",schema:p.create(t),...e})},cloneWith(t,e){return i({...t,...e})}});var re=i({is(t){return t.kind==="DropTableNode"},create(t,e){return i({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return i({...t,...e})}});var Fe=i({is(t){return t.kind==="AddColumnNode"},create(t){return i({kind:"AddColumnNode",column:t})}});var a=i({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return i({kind:"ColumnDefinitionNode",column:d.create(t),dataType:e})},cloneWithFrontModifier(t,e){return i({...t,frontModifiers:t.frontModifiers?i([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return i({...t,endModifiers:t.endModifiers?i([...t.endModifiers,e]):[e]})},cloneWith(t,e){return i({...t,...e})}});var Ue=i({is(t){return t.kind==="DropColumnNode"},create(t){return i({kind:"DropColumnNode",column:d.create(t)})}});var $e=i({is(t){return t.kind==="RenameColumnNode"},create(t,e){return i({kind:"RenameColumnNode",column:d.create(t),renameTo:d.create(e)})}});var B=i({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return i({kind:"CheckConstraintNode",expression:t,name:e?p.create(e):void 0})}});var It=["no action","restrict","cascade","set null","set default"],V=i({is(t){return t.kind==="ReferencesNode"},create(t,e){return i({kind:"ReferencesNode",table:t,columns:i([...e])})},cloneWithOnDelete(t,e){return i({...t,onDelete:e})},cloneWithOnUpdate(t,e){return i({...t,onUpdate:e})}});function ce(t){return nt(t)?t.toOperationNode():P.createImmediate(t)}var se=i({is(t){return t.kind==="GeneratedNode"},create(t){return i({kind:"GeneratedNode",...t})},createWithExpression(t){return i({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return i({...t,...e})}});var Ot=i({is(t){return t.kind==="DefaultValueNode"},create(t){return i({kind:"DefaultValueNode",defaultValue:t})}});function F(t){if(It.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}var D=class t{#e;constructor(e){this.#e=e}autoIncrement(){return new t(a.cloneWith(this.#e,{autoIncrement:!0}))}identity(){return new t(a.cloneWith(this.#e,{identity:!0}))}primaryKey(){return new t(a.cloneWith(this.#e,{primaryKey:!0}))}references(e){let r=pt(e);if(!r.table||at.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new t(a.cloneWith(this.#e,{references:V.create(r.table,[r.column])}))}onDelete(e){if(!this.#e.references)throw new Error("on delete constraint can only be added for foreign keys");return new t(a.cloneWith(this.#e,{references:V.cloneWithOnDelete(this.#e.references,F(e))}))}onUpdate(e){if(!this.#e.references)throw new Error("on update constraint can only be added for foreign keys");return new t(a.cloneWith(this.#e,{references:V.cloneWithOnUpdate(this.#e.references,F(e))}))}unique(){return new t(a.cloneWith(this.#e,{unique:!0}))}notNull(){return new t(a.cloneWith(this.#e,{notNull:!0}))}unsigned(){return new t(a.cloneWith(this.#e,{unsigned:!0}))}defaultTo(e){return new t(a.cloneWith(this.#e,{defaultTo:Ot.create(ce(e))}))}check(e){return new t(a.cloneWith(this.#e,{check:B.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new t(a.cloneWith(this.#e,{generated:se.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new t(a.cloneWith(this.#e,{generated:se.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new t(a.cloneWith(this.#e,{generated:se.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#e.generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new t(a.cloneWith(this.#e,{generated:se.cloneWith(this.#e.generated,{stored:!0})}))}modifyFront(e){return new t(a.cloneWithFrontModifier(this.#e,e.toOperationNode()))}nullsNotDistinct(){return new t(a.cloneWith(this.#e,{nullsNotDistinct:!0}))}ifNotExists(){return new t(a.cloneWith(this.#e,{ifNotExists:!0}))}modifyEnd(e){return new t(a.cloneWithEndModifier(this.#e,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#e}};var Ke=i({is(t){return t.kind==="ModifyColumnNode"},create(t){return i({kind:"ModifyColumnNode",column:t})}});var v=i({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,s){return i({kind:"ForeignKeyConstraintNode",columns:t,references:V.create(e,r),name:s?p.create(s):void 0})},cloneWith(t,e){return i({...t,...e})}});var U=class t{#e;constructor(e){this.#e=e}onDelete(e){return new t(v.cloneWith(this.#e,{onDelete:F(e)}))}onUpdate(e){return new t(v.cloneWith(this.#e,{onUpdate:F(e)}))}deferrable(){return new t(v.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new t(v.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new t(v.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new t(v.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}};var $=i({is(t){return t.kind==="AddConstraintNode"},create(t){return i({kind:"AddConstraintNode",constraint:t})}});var b=i({is(t){return t.kind==="UniqueConstraintNode"},create(t,e,r){return i({kind:"UniqueConstraintNode",columns:i(t.map(d.create)),name:e?p.create(e):void 0,nullsNotDistinct:r})},cloneWith(t,e){return i({...t,...e})}});var K=i({is(t){return t.kind==="DropConstraintNode"},create(t){return i({kind:"DropConstraintNode",constraintName:p.create(t)})},cloneWith(t,e){return i({...t,...e})}});var J=i({is(t){return t.kind==="AlterColumnNode"},create(t,e,r){return i({kind:"AlterColumnNode",column:d.create(t),[e]:r})}});var ne=class{#e;constructor(e){this.#e=e}setDataType(e){return new A(J.create(this.#e,"dataType",T(e)))}setDefault(e){return new A(J.create(this.#e,"setDefault",ce(e)))}dropDefault(){return new A(J.create(this.#e,"dropDefault",!0))}setNotNull(){return new A(J.create(this.#e,"setNotNull",!0))}dropNotNull(){return new A(J.create(this.#e,"dropNotNull",!0))}$call(e){return e(this)}},A=class{#e;constructor(e){this.#e=e}toOperationNode(){return this.#e}};var W=class{#e;constructor(e){this.#e=i(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var ue=class t{#e;constructor(e){this.#e=i(e)}onDelete(e){return new t({...this.#e,constraintBuilder:this.#e.constraintBuilder.onDelete(e)})}onUpdate(e){return new t({...this.#e,constraintBuilder:this.#e.constraintBuilder.onUpdate(e)})}deferrable(){return new t({...this.#e,constraintBuilder:this.#e.constraintBuilder.deferrable()})}notDeferrable(){return new t({...this.#e,constraintBuilder:this.#e.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new t({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new t({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyImmediate()})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(o.cloneWithTableProps(this.#e.node,{addConstraint:$.create(this.#e.constraintBuilder.toOperationNode())}),this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var oe=class t{#e;constructor(e){this.#e=i(e)}ifExists(){return new t({...this.#e,node:o.cloneWithTableProps(this.#e.node,{dropConstraint:K.cloneWith(this.#e.node.dropConstraint,{ifExists:!0})})})}cascade(){return new t({...this.#e,node:o.cloneWithTableProps(this.#e.node,{dropConstraint:K.cloneWith(this.#e.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new t({...this.#e,node:o.cloneWithTableProps(this.#e.node,{dropConstraint:K.cloneWith(this.#e.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var S=i({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return i({kind:"PrimaryKeyConstraintNode",columns:i(t.map(d.create)),name:e?p.create(e):void 0})},cloneWith(t,e){return i({...t,...e})}});var k=i({is(t){return t.kind==="AddIndexNode"},create(t){return i({kind:"AddIndexNode",name:p.create(t)})},cloneWith(t,e){return i({...t,...e})},cloneWithColumns(t,e){return i({...t,columns:[...t.columns||[],...e]})}});var le=class t{#e;constructor(e){this.#e=i(e)}unique(){return new t({...this.#e,node:o.cloneWithTableProps(this.#e.node,{addIndex:k.cloneWith(this.#e.node.addIndex,{unique:!0})})})}column(e){return new t({...this.#e,node:o.cloneWithTableProps(this.#e.node,{addIndex:k.cloneWithColumns(this.#e.node.addIndex,[R(e)])})})}columns(e){return new t({...this.#e,node:o.cloneWithTableProps(this.#e.node,{addIndex:k.cloneWithColumns(this.#e.node.addIndex,e.map(R))})})}expression(e){return new t({...this.#e,node:o.cloneWithTableProps(this.#e.node,{addIndex:k.cloneWithColumns(this.#e.node.addIndex,[e.toOperationNode()])})})}using(e){return new t({...this.#e,node:o.cloneWithTableProps(this.#e.node,{addIndex:k.cloneWith(this.#e.node.addIndex,{using:C.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var G=class t{#e;constructor(e){this.#e=e}nullsNotDistinct(){return new t(b.cloneWith(this.#e,{nullsNotDistinct:!0}))}deferrable(){return new t(b.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new t(b.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new t(b.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new t(b.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}};var j=class t{#e;constructor(e){this.#e=e}deferrable(){return new t(S.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new t(S.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new t(S.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new t(S.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}};var H=class{#e;constructor(e){this.#e=e}$call(e){return e(this)}toOperationNode(){return this.#e}};var Tt=i({is(t){return t.kind==="RenameConstraintNode"},create(t,e){return i({kind:"RenameConstraintNode",oldName:p.create(t),newName:p.create(e)})}});var me=class{#e;constructor(e){this.#e=i(e)}renameTo(e){return new W({...this.#e,node:o.cloneWithTableProps(this.#e.node,{renameTo:f(e)})})}setSchema(e){return new W({...this.#e,node:o.cloneWithTableProps(this.#e.node,{setSchema:p.create(e)})})}alterColumn(e,r){let s=r(new ne(e));return new L({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,s.toOperationNode())})}dropColumn(e){return new L({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,Ue.create(e))})}renameColumn(e,r){return new L({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,$e.create(e,r))})}addColumn(e,r,s=m){let n=s(new D(a.create(e,T(r))));return new L({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,Fe.create(n.toOperationNode()))})}modifyColumn(e,r,s=m){let n=s(new D(a.create(e,T(r))));return new L({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,Ke.create(n.toOperationNode()))})}addUniqueConstraint(e,r,s=m){let n=s(new G(b.create(r,e)));return new W({...this.#e,node:o.cloneWithTableProps(this.#e.node,{addConstraint:$.create(n.toOperationNode())})})}addCheckConstraint(e,r,s=m){let n=s(new H(B.create(r.toOperationNode(),e)));return new W({...this.#e,node:o.cloneWithTableProps(this.#e.node,{addConstraint:$.create(n.toOperationNode())})})}addForeignKeyConstraint(e,r,s,n,h=m){let c=h(new U(v.create(r.map(d.create),f(s),n.map(d.create),e)));return new ue({...this.#e,constraintBuilder:c})}addPrimaryKeyConstraint(e,r,s=m){let n=s(new j(S.create(r,e)));return new W({...this.#e,node:o.cloneWithTableProps(this.#e.node,{addConstraint:$.create(n.toOperationNode())})})}dropConstraint(e){return new oe({...this.#e,node:o.cloneWithTableProps(this.#e.node,{dropConstraint:K.create(e)})})}renameConstraint(e,r){return new oe({...this.#e,node:o.cloneWithTableProps(this.#e.node,{renameConstraint:Tt.create(e,r)})})}addIndex(e){return new le({...this.#e,node:o.cloneWithTableProps(this.#e.node,{addIndex:k.create(e)})})}dropIndex(e){return new W({...this.#e,node:o.cloneWithTableProps(this.#e.node,{dropIndex:E.create(e)})})}$call(e){return e(this)}},L=class t{#e;constructor(e){this.#e=i(e)}alterColumn(e,r){let s=r(new ne(e));return new t({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,s.toOperationNode())})}dropColumn(e){return new t({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,Ue.create(e))})}renameColumn(e,r){return new t({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,$e.create(e,r))})}addColumn(e,r,s=m){let n=s(new D(a.create(e,T(r))));return new t({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,Fe.create(n.toOperationNode()))})}modifyColumn(e,r,s=m){let n=s(new D(a.create(e,T(r))));return new t({...this.#e,node:o.cloneWithColumnAlteration(this.#e.node,Ke.create(n.toOperationNode()))})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var Y=class extends mt{transformPrimitiveValueList(e){return he.create(e.values.map(P.createImmediate))}transformValue(e){return P.createImmediate(e.value)}};var fe=class t{#e;constructor(e){this.#e=i(e)}ifNotExists(){return new t({...this.#e,node:y.cloneWith(this.#e.node,{ifNotExists:!0})})}unique(){return new t({...this.#e,node:y.cloneWith(this.#e.node,{unique:!0})})}nullsNotDistinct(){return new t({...this.#e,node:y.cloneWith(this.#e.node,{nullsNotDistinct:!0})})}on(e){return new t({...this.#e,node:y.cloneWith(this.#e.node,{table:f(e)})})}column(e){return new t({...this.#e,node:y.cloneWithColumns(this.#e.node,[R(e)])})}columns(e){return new t({...this.#e,node:y.cloneWithColumns(this.#e.node,e.map(R))})}expression(e){return new t({...this.#e,node:y.cloneWithColumns(this.#e.node,[e.toOperationNode()])})}using(e){return new t({...this.#e,node:y.cloneWith(this.#e.node,{using:C.createWithSql(e)})})}where(...e){let r=new Y;return new t({...this.#e,node:lt.cloneWithWhere(this.#e.node,r.transformNode(ct(e),this.#e.queryId))})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var Ne=class t{#e;constructor(e){this.#e=i(e)}ifNotExists(){return new t({...this.#e,node:de.cloneWith(this.#e.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};function Dt(t){if(bt.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}var we=class t{#e;constructor(e){this.#e=i(e)}temporary(){return new t({...this.#e,node:l.cloneWith(this.#e.node,{temporary:!0})})}onCommit(e){return new t({...this.#e,node:l.cloneWith(this.#e.node,{onCommit:Dt(e)})})}ifNotExists(){return new t({...this.#e,node:l.cloneWith(this.#e.node,{ifNotExists:!0})})}addColumn(e,r,s=m){let n=s(new D(a.create(e,T(r))));return new t({...this.#e,node:l.cloneWithColumn(this.#e.node,n.toOperationNode())})}addPrimaryKeyConstraint(e,r,s=m){let n=s(new j(S.create(r,e)));return new t({...this.#e,node:l.cloneWithConstraint(this.#e.node,n.toOperationNode())})}addUniqueConstraint(e,r,s=m){let n=s(new G(b.create(r,e)));return new t({...this.#e,node:l.cloneWithConstraint(this.#e.node,n.toOperationNode())})}addCheckConstraint(e,r,s=m){let n=s(new H(B.create(r.toOperationNode(),e)));return new t({...this.#e,node:l.cloneWithConstraint(this.#e.node,n.toOperationNode())})}addForeignKeyConstraint(e,r,s,n,h=m){let c=h(new U(v.create(r.map(d.create),f(s),n.map(d.create),e)));return new t({...this.#e,node:l.cloneWithConstraint(this.#e.node,c.toOperationNode())})}modifyFront(e){return new t({...this.#e,node:l.cloneWithFrontModifier(this.#e.node,e.toOperationNode())})}modifyEnd(e){return new t({...this.#e,node:l.cloneWithEndModifier(this.#e.node,e.toOperationNode())})}as(e){return new t({...this.#e,node:l.cloneWith(this.#e.node,{selectQuery:pe(e)})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var ye=class t{#e;constructor(e){this.#e=i(e)}on(e){return new t({...this.#e,node:E.cloneWith(this.#e.node,{table:f(e)})})}ifExists(){return new t({...this.#e,node:E.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new t({...this.#e,node:E.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var ve=class t{#e;constructor(e){this.#e=i(e)}ifExists(){return new t({...this.#e,node:ie.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new t({...this.#e,node:ie.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var xe=class t{#e;constructor(e){this.#e=i(e)}ifExists(){return new t({...this.#e,node:re.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new t({...this.#e,node:re.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var x=i({is(t){return t.kind==="CreateViewNode"},create(t){return i({kind:"CreateViewNode",name:w.create(t)})},cloneWith(t,e){return i({...t,...e})}});var ge=class{#e=new Y;transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}transformResult(e){return Promise.resolve(e.result)}};var Ce=class t{#e;constructor(e){this.#e=i(e)}temporary(){return new t({...this.#e,node:x.cloneWith(this.#e.node,{temporary:!0})})}materialized(){return new t({...this.#e,node:x.cloneWith(this.#e.node,{materialized:!0})})}ifNotExists(){return new t({...this.#e,node:x.cloneWith(this.#e.node,{ifNotExists:!0})})}orReplace(){return new t({...this.#e,node:x.cloneWith(this.#e.node,{orReplace:!0})})}columns(e){return new t({...this.#e,node:x.cloneWith(this.#e.node,{columns:e.map(dt)})})}as(e){let r=e.withPlugin(new ge).toOperationNode();return new t({...this.#e,node:x.cloneWith(this.#e.node,{as:r})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var X=i({is(t){return t.kind==="DropViewNode"},create(t){return i({kind:"DropViewNode",name:w.create(t)})},cloneWith(t,e){return i({...t,...e})}});var be=class t{#e;constructor(e){this.#e=i(e)}materialized(){return new t({...this.#e,node:X.cloneWith(this.#e.node,{materialized:!0})})}ifExists(){return new t({...this.#e,node:X.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new t({...this.#e,node:X.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var Ie=i({is(t){return t.kind==="CreateTypeNode"},create(t){return i({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return i({...t,enum:he.create(e.map(P.createImmediate))})}});var Oe=class t{#e;constructor(e){this.#e=i(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}asEnum(e){return new t({...this.#e,node:Ie.cloneWithEnum(this.#e.node,e)})}$call(e){return e(this)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var Te=i({is(t){return t.kind==="DropTypeNode"},create(t){return i({kind:"DropTypeNode",name:t})},cloneWith(t,e){return i({...t,...e})}});var De=class t{#e;constructor(e){this.#e=i(e)}ifExists(){return new t({...this.#e,node:Te.cloneWith(this.#e.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};function Je(t){if(t.includes(".")){let r=t.split(".").map(Pt);if(r.length===2)return w.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return w.create(t)}function Pt(t){return t.trim()}var Z=i({is(t){return t.kind==="RefreshMaterializedViewNode"},create(t){return i({kind:"RefreshMaterializedViewNode",name:w.create(t)})},cloneWith(t,e){return i({...t,...e})}});var We=class t{#e;constructor(e){this.#e=i(e)}concurrently(){return new t({...this.#e,node:Z.cloneWith(this.#e.node,{concurrently:!0,withNoData:!1})})}withData(){return new t({...this.#e,node:Z.cloneWith(this.#e.node,{withNoData:!1})})}withNoData(){return new t({...this.#e,node:Z.cloneWith(this.#e.node,{withNoData:!0,concurrently:!1})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};var Se=class t{#e;constructor(e){this.#e=e}createTable(e){return new we({queryId:u(),executor:this.#e,node:l.create(f(e))})}dropTable(e){return new xe({queryId:u(),executor:this.#e,node:re.create(f(e))})}createIndex(e){return new fe({queryId:u(),executor:this.#e,node:y.create(e)})}dropIndex(e){return new ye({queryId:u(),executor:this.#e,node:E.create(e)})}createSchema(e){return new Ne({queryId:u(),executor:this.#e,node:de.create(e)})}dropSchema(e){return new ve({queryId:u(),executor:this.#e,node:ie.create(e)})}alterTable(e){return new me({queryId:u(),executor:this.#e,node:o.create(f(e))})}createView(e){return new Ce({queryId:u(),executor:this.#e,node:x.create(e)})}refreshMaterializedView(e){return new We({queryId:u(),executor:this.#e,node:Z.create(e)})}dropView(e){return new be({queryId:u(),executor:this.#e,node:X.create(e)})}createType(e){return new Oe({queryId:u(),executor:this.#e,node:Ie.create(Je(e))})}dropType(e){return new De({queryId:u(),executor:this.#e,node:Te.create(Je(e))})}withPlugin(e){return new t(this.#e.withPlugin(e))}withoutPlugins(){return new t(this.#e.withoutPlugins())}withSchema(e){return new t(this.#e.withPluginAtFront(new z(e)))}};var Ee=class{ref(e){return new ht(e)}table(e){return new Ct(e)}};var ke=class{#e;constructor(e){this.#e=e}async provideConnection(e){let r=await this.#e.acquireConnection();try{return await e(r)}finally{await this.#e.releaseConnection(r)}}};var Pe=class t extends Nt{#e;#t;#i;constructor(e,r,s,n=[]){super(n),this.#e=e,this.#t=r,this.#i=s}get adapter(){return this.#t}compileQuery(e,r){return this.#e.compileQuery(e,r)}provideConnection(e){return this.#i.provideConnection(e)}withPlugins(e){return new t(this.#e,this.#t,this.#i,[...this.plugins,...e])}withPlugin(e){return new t(this.#e,this.#t,this.#i,[...this.plugins,e])}withPluginAtFront(e){return new t(this.#e,this.#t,this.#i,[e,...this.plugins])}withConnectionProvider(e){return new t(this.#e,this.#t,e,[...this.plugins])}withoutPlugins(){return new t(this.#e,this.#t,this.#i,[])}};function Ae(){return typeof performance<"u"&&Q(performance.now)?performance.now():Date.now()}var Le=class{#e;#t;#i;#s;#r;#n=new WeakSet;constructor(e,r){this.#s=!1,this.#e=e,this.#t=r}async init(){if(this.#r)throw new Error("driver has already been destroyed");this.#i||(this.#i=this.#e.init().then(()=>{this.#s=!0}).catch(e=>(this.#i=void 0,Promise.reject(e)))),await this.#i}async acquireConnection(){if(this.#r)throw new Error("driver has already been destroyed");this.#s||await this.init();let e=await this.#e.acquireConnection();return this.#n.has(e)||(this.#p()&&this.#d(e),this.#n.add(e)),e}async releaseConnection(e){await this.#e.releaseConnection(e)}beginTransaction(e,r){return this.#e.beginTransaction(e,r)}commitTransaction(e){return this.#e.commitTransaction(e)}rollbackTransaction(e){return this.#e.rollbackTransaction(e)}savepoint(e,r,s){if(this.#e.savepoint)return this.#e.savepoint(e,r,s);throw new Error("The `savepoint` method is not supported by this driver")}rollbackToSavepoint(e,r,s){if(this.#e.rollbackToSavepoint)return this.#e.rollbackToSavepoint(e,r,s);throw new Error("The `rollbackToSavepoint` method is not supported by this driver")}releaseSavepoint(e,r,s){if(this.#e.releaseSavepoint)return this.#e.releaseSavepoint(e,r,s);throw new Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(){this.#i&&(await this.#i,this.#r||(this.#r=this.#e.destroy().catch(e=>(this.#r=void 0,Promise.reject(e)))),await this.#r)}#p(){return this.#t.isLevelEnabled("query")||this.#t.isLevelEnabled("error")}#d(e){let r=e.executeQuery,s=e.streamQuery,n=this;e.executeQuery=async h=>{let c,I=Ae();try{return await r.call(e,h)}catch(g){throw c=g,await n.#o(g,h,I),g}finally{c||await n.#a(h,I)}},e.streamQuery=async function*(h,c){let I,g=Ae();try{for await(let N of s.call(e,h,c))yield N}catch(N){throw I=N,await n.#o(N,h,g),N}finally{I||await n.#a(h,g,!0)}}}async#o(e,r,s){await this.#t.error(()=>({level:"error",error:e,query:r,queryDurationMillis:this.#h(s)}))}async#a(e,r,s=!1){await this.#t.query(()=>({level:"query",isStream:s,query:e,queryDurationMillis:this.#h(r)}))}#h(e){return Ae()-e}};var At=()=>{},_=class{#e;#t;constructor(e){this.#e=e}async provideConnection(e){for(;this.#t;)await this.#t.catch(At);return this.#t=this.#i(e).finally(()=>{this.#t=void 0}),this.#t}async#i(e){return await e(this.#e)}};var Lt=["read only","read write"],Mt=["read uncommitted","read committed","repeatable read","serializable","snapshot"];function Ge(t){if(t.accessMode&&!Lt.includes(t.accessMode))throw new Error(`invalid transaction access mode ${t.accessMode}`);if(t.isolationLevel&&!Mt.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}var qt=["query","error"],Ro=i(qt),Me=class{#e;#t;constructor(e){Q(e)?(this.#t=e,this.#e=i({query:!0,error:!0})):(this.#t=Qt,this.#e=i({query:e.includes("query"),error:e.includes("error")}))}isLevelEnabled(e){return this.#e[e]}async query(e){this.#e.query&&await this.#t(e())}async error(e){this.#e.error&&await this.#t(e())}};function Qt(t){if(t.level==="query"){let e=`kysely:query:${t.isStream?"stream:":""}`;console.log(`${e} ${t.query.sql}`),console.log(`${e} duration: ${t.queryDurationMillis.toFixed(1)}ms`)}else t.level==="error"&&(t.error instanceof Error?console.error(`kysely:error: ${t.error.stack??t.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:t.error,query:t.query.sql,queryDurationMillis:t.queryDurationMillis})}`))}function Wt(t){return O(t)&&Q(t.compile)}Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");var qe=class t extends wt{#e;constructor(e){let r,s;if(Rt(e))r={executor:e.executor},s={...e};else{let n=e.dialect,h=n.createDriver(),c=n.createQueryCompiler(),I=n.createAdapter(),g=new Me(e.log??[]),N=new Le(h,g),ee=new ke(N),_e=new Pe(c,I,ee,e.plugins??[]);r={executor:_e},s={config:e,executor:_e,dialect:n,driver:N}}super(r),this.#e=i(s)}get schema(){return new Se(this.#e.executor)}get dynamic(){return new Ee}get introspection(){return this.#e.dialect.createIntrospector(this.withoutPlugins())}case(e){return new gt({node:xt.create(et(e)?void 0:pe(e))})}get fn(){return vt()}transaction(){return new He({...this.#e})}startTransaction(){return new Ye({...this.#e})}connection(){return new je({...this.#e})}withPlugin(e){return new t({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new t({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new t({...this.#e,executor:this.#e.executor.withPluginAtFront(new z(e))})}withTables(){return new t({...this.#e})}async destroy(){await this.#e.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#e.executor}executeQuery(e,r){r!==void 0&&ae("Passing `queryId` in `db.executeQuery` is deprecated and will result in a compile-time error in the future.");let s=Wt(e)?e.compile():e;return this.getExecutor().executeQuery(s)}async[Symbol.asyncDispose](){await this.destroy()}},Qe=class t extends qe{#e;constructor(e){super(e),this.#e=e}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(e){return new t({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new t({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new t({...this.#e,executor:this.#e.executor.withPluginAtFront(new z(e))})}withTables(){return new t({...this.#e})}};function Rt(t){return O(t)&&O(t.config)&&O(t.driver)&&O(t.executor)&&O(t.dialect)}var je=class{#e;constructor(e){this.#e=i(e)}async execute(e){return this.#e.executor.provideConnection(async r=>{let s=this.#e.executor.withConnectionProvider(new _(r)),n=new qe({...this.#e,executor:s});return await e(n)})}},He=class t{#e;constructor(e){this.#e=i(e)}setAccessMode(e){return new t({...this.#e,accessMode:e})}setIsolationLevel(e){return new t({...this.#e,isolationLevel:e})}async execute(e){let{isolationLevel:r,accessMode:s,...n}=this.#e,h={isolationLevel:r,accessMode:s};return Ge(h),this.#e.executor.provideConnection(async c=>{let I=this.#e.executor.withConnectionProvider(new _(c)),g=new Qe({...n,executor:I}),N=!1;try{await this.#e.driver.beginTransaction(c,h),N=!0;let ee=await e(g);return await this.#e.driver.commitTransaction(c),ee}catch(ee){throw N&&await this.#e.driver.rollbackTransaction(c),ee}})}},Ye=class t{#e;constructor(e){this.#e=i(e)}setAccessMode(e){return new t({...this.#e,accessMode:e})}setIsolationLevel(e){return new t({...this.#e,isolationLevel:e})}async execute(){let{isolationLevel:e,accessMode:r,...s}=this.#e,n={isolationLevel:e,accessMode:r};Ge(n);let h=await ft(this.#e.executor);return await this.#e.driver.beginTransaction(h.connection,n),new Xe({...s,connection:h,executor:this.#e.executor.withConnectionProvider(new _(h.connection))})}},Xe=class t extends Qe{#e;#t;#i;constructor(e){let r={isCommitted:!1,isRolledBack:!1};e={...e,executor:new Ze(e.executor,r)};let{connection:s,...n}=e;super(n),this.#e=i(e),this.#i=r;let h=u();this.#t=c=>e.executor.compileQuery(c,h)}get isCommitted(){return this.#i.isCommitted}get isRolledBack(){return this.#i.isRolledBack}commit(){return q(this.#i),new M(async()=>{await this.#e.driver.commitTransaction(this.#e.connection.connection),this.#i.isCommitted=!0,this.#e.connection.release()})}rollback(){return q(this.#i),new M(async()=>{await this.#e.driver.rollbackTransaction(this.#e.connection.connection),this.#i.isRolledBack=!0,this.#e.connection.release()})}savepoint(e){return q(this.#i),new M(async()=>(await this.#e.driver.savepoint?.(this.#e.connection.connection,e,this.#t),new t({...this.#e})))}rollbackToSavepoint(e){return q(this.#i),new M(async()=>(await this.#e.driver.rollbackToSavepoint?.(this.#e.connection.connection,e,this.#t),new t({...this.#e})))}releaseSavepoint(e){return q(this.#i),new M(async()=>(await this.#e.driver.releaseSavepoint?.(this.#e.connection.connection,e,this.#t),new t({...this.#e})))}withPlugin(e){return new t({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new t({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new t({...this.#e,executor:this.#e.executor.withPluginAtFront(new z(e))})}withTables(){return new t({...this.#e})}},M=class{#e;constructor(e){this.#e=e}async execute(){return await this.#e()}};function q(t){if(t.isCommitted)throw new Error("Transaction is already committed");if(t.isRolledBack)throw new Error("Transaction is already rolled back")}var Ze=class t{#e;#t;constructor(e,r){e instanceof t?this.#e=e.#e:this.#e=e,this.#t=r}get adapter(){return this.#e.adapter}get plugins(){return this.#e.plugins}transformQuery(e,r){return this.#e.transformQuery(e,r)}compileQuery(e,r){return this.#e.compileQuery(e,r)}provideConnection(e){return this.#e.provideConnection(e)}executeQuery(e){return q(this.#t),this.#e.executeQuery(e)}stream(e,r){return q(this.#t),this.#e.stream(e,r)}withConnectionProvider(e){return new t(this.#e.withConnectionProvider(e),this.#t)}withPlugin(e){return new t(this.#e.withPlugin(e),this.#t)}withPlugins(e){return new t(this.#e.withPlugins(e),this.#t)}withPluginAtFront(e){return new t(this.#e.withPluginAtFront(e),this.#t)}withoutPlugins(){return new t(this.#e.withoutPlugins(),this.#t)}};var Re=class{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#e=i({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),RenameConstraintNode:this.visitRenameConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),RefreshMaterializedViewNode:this.visitRefreshMaterializedView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this),OrActionNode:this.visitOrAction.bind(this),CollateNode:this.visitCollate.bind(this)});visitNode=e=>{this.nodeStack.push(e),this.#e[e.kind](e),this.nodeStack.pop()}};var zt=/'/g,St=class extends Re{#e="";#t=[];get numParameters(){return this.#t.length}compileQuery(e,r){return this.#e="",this.#t=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode(e),i({query:e,queryId:r,sql:this.getSql(),parameters:[...this.#t]})}getSql(){return this.#e}visitSelectQuery(e){let r=this.parentNode!==void 0&&!te.is(this.parentNode)&&!ut.is(this.parentNode)&&!l.is(this.parentNode)&&!x.is(this.parentNode)&&!yt.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),r&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("select"),e.distinctOn&&(this.append(" "),this.compileDistinctOn(e.distinctOn)),e.frontModifiers?.length&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.top&&(this.append(" "),this.visitNode(e.top)),e.selections&&(this.append(" "),this.compileList(e.selections)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.groupBy&&(this.append(" "),this.visitNode(e.groupBy)),e.having&&(this.append(" "),this.visitNode(e.having)),e.setOperations&&(this.append(" "),this.compileList(e.setOperations," ")),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.offset&&(this.append(" "),this.visitNode(e.offset)),e.fetch&&(this.append(" "),this.visitNode(e.fetch)),e.endModifiers?.length&&(this.append(" "),this.compileList(this.sortSelectModifiers([...e.endModifiers])," ")),r&&this.append(")")}visitFrom(e){this.append("from "),this.compileList(e.froms)}visitSelection(e){this.visitNode(e.selection)}visitColumn(e){this.visitNode(e.column)}compileDistinctOn(e){this.append("distinct on ("),this.compileList(e),this.append(")")}compileList(e,r=", "){let s=e.length-1;for(let n=0;n<=s;n++)this.visitNode(e[n]),n<s&&this.append(r)}visitWhere(e){this.append("where "),this.visitNode(e.where)}visitHaving(e){this.append("having "),this.visitNode(e.having)}visitInsertQuery(e){let r=this.parentNode!==void 0&&!te.is(this.parentNode)&&!C.is(this.parentNode)&&!Ve.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),r&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append(e.replace?"replace":"insert"),e.ignore&&(ae("`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead."),this.append(" ignore")),e.orAction&&(this.append(" "),this.visitNode(e.orAction)),e.top&&(this.append(" "),this.visitNode(e.top)),e.into&&(this.append(" into "),this.visitNode(e.into)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.output&&(this.append(" "),this.visitNode(e.output)),e.values&&(this.append(" "),this.visitNode(e.values)),e.defaultValues&&(this.append(" "),this.append("default values")),e.onConflict&&(this.append(" "),this.visitNode(e.onConflict)),e.onDuplicateKey&&(this.append(" "),this.visitNode(e.onDuplicateKey)),e.returning&&(this.append(" "),this.visitNode(e.returning)),r&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitValues(e){this.append("values "),this.compileList(e.values)}visitDeleteQuery(e){let r=this.parentNode!==void 0&&!te.is(this.parentNode)&&!C.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),r&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("delete "),e.top&&(this.visitNode(e.top),this.append(" ")),this.visitNode(e.from),e.output&&(this.append(" "),this.visitNode(e.output)),e.using&&(this.append(" "),this.visitNode(e.using)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),r&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitReturning(e){this.append("returning "),this.compileList(e.selections)}visitAlias(e){this.visitNode(e.node),this.append(" as "),this.visitNode(e.alias)}visitReference(e){e.table&&(this.visitNode(e.table),this.append(".")),this.visitNode(e.column)}visitSelectAll(e){this.append("*")}visitIdentifier(e){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier(e),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier(e){if(!ze(e.name))throw new Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier(e.name))}visitAnd(e){this.visitNode(e.left),this.append(" and "),this.visitNode(e.right)}visitOr(e){this.visitNode(e.left),this.append(" or "),this.visitNode(e.right)}visitValue(e){e.immediate?this.appendImmediateValue(e.value):this.appendValue(e.value)}visitValueList(e){this.append("("),this.compileList(e.values),this.append(")")}visitTuple(e){this.append("("),this.compileList(e.values),this.append(")")}visitPrimitiveValueList(e){this.append("(");let{values:r}=e;for(let s=0;s<r.length;++s)this.appendValue(r[s]),s!==r.length-1&&this.append(", ");this.append(")")}visitParens(e){this.append("("),this.visitNode(e.node),this.append(")")}visitJoin(e){this.append(Vt[e.joinType]),this.append(" "),this.visitNode(e.table),e.on&&(this.append(" "),this.visitNode(e.on))}visitOn(e){this.append("on "),this.visitNode(e.on)}visitRaw(e){let{sqlFragments:r,parameters:s}=e;for(let n=0;n<r.length;++n)this.append(r[n]),s.length>n&&this.visitNode(s[n])}visitOperator(e){this.append(e.operator)}visitTable(e){this.visitNode(e.table)}visitSchemableIdentifier(e){e.schema&&(this.visitNode(e.schema),this.append(".")),this.visitNode(e.identifier)}visitCreateTable(e){this.append("create "),e.frontModifiers&&e.frontModifiers.length>0&&(this.compileList(e.frontModifiers," "),this.append(" ")),e.temporary&&this.append("temporary "),this.append("table "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.table),e.selectQuery?(this.append(" as "),this.visitNode(e.selectQuery)):(this.append(" ("),this.compileList([...e.columns,...e.constraints??[]]),this.append(")"),e.onCommit&&(this.append(" on commit "),this.append(e.onCommit)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," ")))}visitColumnDefinition(e){e.ifNotExists&&this.append("if not exists "),this.visitNode(e.column),this.append(" "),this.visitNode(e.dataType),e.unsigned&&this.append(" unsigned"),e.frontModifiers&&e.frontModifiers.length>0&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.generated&&(this.append(" "),this.visitNode(e.generated)),e.identity&&this.append(" identity"),e.defaultTo&&(this.append(" "),this.visitNode(e.defaultTo)),e.notNull&&this.append(" not null"),e.unique&&this.append(" unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.primaryKey&&this.append(" primary key"),e.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),e.references&&(this.append(" "),this.visitNode(e.references)),e.check&&(this.append(" "),this.visitNode(e.check)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(e){this.append("references "),this.visitNode(e.table),this.append(" ("),this.compileList(e.columns),this.append(")"),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate))}visitDropTable(e){this.append("drop table "),e.ifExists&&this.append("if exists "),this.visitNode(e.table),e.cascade&&this.append(" cascade")}visitDataType(e){this.append(e.dataType)}visitOrderBy(e){this.append("order by "),this.compileList(e.items)}visitOrderByItem(e){this.visitNode(e.orderBy),e.collation&&(this.append(" "),this.visitNode(e.collation)),e.direction&&(this.append(" "),this.visitNode(e.direction)),e.nulls&&(this.append(" nulls "),this.append(e.nulls))}visitGroupBy(e){this.append("group by "),this.compileList(e.items)}visitGroupByItem(e){this.visitNode(e.groupBy)}visitUpdateQuery(e){let r=this.parentNode!==void 0&&!te.is(this.parentNode)&&!C.is(this.parentNode)&&!Ve.is(this.parentNode);if(this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),r&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("update "),e.top&&(this.visitNode(e.top),this.append(" ")),e.table&&(this.visitNode(e.table),this.append(" ")),this.append("set "),e.updates&&this.compileList(e.updates),e.output&&(this.append(" "),this.visitNode(e.output)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins){if(!e.from)throw new Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins");this.append(" "),this.compileList(e.joins," ")}e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),r&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitColumnUpdate(e){this.visitNode(e.column),this.append(" = "),this.visitNode(e.value)}visitLimit(e){this.append("limit "),this.visitNode(e.limit)}visitOffset(e){this.append("offset "),this.visitNode(e.offset)}visitOnConflict(e){this.append("on conflict"),e.columns?(this.append(" ("),this.compileList(e.columns),this.append(")")):e.constraint?(this.append(" on constraint "),this.visitNode(e.constraint)):e.indexExpression&&(this.append(" ("),this.visitNode(e.indexExpression),this.append(")")),e.indexWhere&&(this.append(" "),this.visitNode(e.indexWhere)),e.doNothing===!0?this.append(" do nothing"):e.updates&&(this.append(" do update set "),this.compileList(e.updates),e.updateWhere&&(this.append(" "),this.visitNode(e.updateWhere)))}visitOnDuplicateKey(e){this.append("on duplicate key update "),this.compileList(e.updates)}visitCreateIndex(e){this.append("create "),e.unique&&this.append("unique "),this.append("index "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.using&&(this.append(" using "),this.visitNode(e.using)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.where&&(this.append(" "),this.visitNode(e.where))}visitDropIndex(e){this.append("drop index "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.cascade&&this.append(" cascade")}visitCreateSchema(e){this.append("create schema "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.schema)}visitDropSchema(e){this.append("drop schema "),e.ifExists&&this.append("if exists "),this.visitNode(e.schema),e.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("primary key ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}buildDeferrable(e){e.deferrable!==void 0&&(e.deferrable?this.append(" deferrable"):this.append(" not deferrable")),e.initiallyDeferred!==void 0&&(e.initiallyDeferred?this.append(" initially deferred"):this.append(" initially immediate"))}visitUniqueConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),this.append(" ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}visitCheckConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("check ("),this.visitNode(e.expression),this.append(")")}visitForeignKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("foreign key ("),this.compileList(e.columns),this.append(") "),this.visitNode(e.references),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate)),this.buildDeferrable(e)}visitList(e){this.compileList(e.items)}visitWith(e){this.append("with "),e.recursive&&this.append("recursive "),this.compileList(e.expressions)}visitCommonTableExpression(e){this.visitNode(e.name),this.append(" as "),Be(e.materialized)&&(e.materialized||this.append("not "),this.append("materialized ")),this.visitNode(e.expression)}visitCommonTableExpressionName(e){this.visitNode(e.table),e.columns&&(this.append("("),this.compileList(e.columns),this.append(")"))}visitAlterTable(e){this.append("alter table "),this.visitNode(e.table),this.append(" "),e.renameTo&&(this.append("rename to "),this.visitNode(e.renameTo)),e.setSchema&&(this.append("set schema "),this.visitNode(e.setSchema)),e.addConstraint&&this.visitNode(e.addConstraint),e.dropConstraint&&this.visitNode(e.dropConstraint),e.renameConstraint&&this.visitNode(e.renameConstraint),e.columnAlterations&&this.compileColumnAlterations(e.columnAlterations),e.addIndex&&this.visitNode(e.addIndex),e.dropIndex&&this.visitNode(e.dropIndex)}visitAddColumn(e){this.append("add column "),this.visitNode(e.column)}visitRenameColumn(e){this.append("rename column "),this.visitNode(e.column),this.append(" to "),this.visitNode(e.renameTo)}visitDropColumn(e){this.append("drop column "),this.visitNode(e.column)}visitAlterColumn(e){this.append("alter column "),this.visitNode(e.column),this.append(" "),e.dataType&&(this.announcesNewColumnDataType()&&this.append("type "),this.visitNode(e.dataType),e.dataTypeExpression&&(this.append("using "),this.visitNode(e.dataTypeExpression))),e.setDefault&&(this.append("set default "),this.visitNode(e.setDefault)),e.dropDefault&&this.append("drop default"),e.setNotNull&&this.append("set not null"),e.dropNotNull&&this.append("drop not null")}visitModifyColumn(e){this.append("modify column "),this.visitNode(e.column)}visitAddConstraint(e){this.append("add "),this.visitNode(e.constraint)}visitDropConstraint(e){this.append("drop constraint "),e.ifExists&&this.append("if exists "),this.visitNode(e.constraintName),e.modifier==="cascade"?this.append(" cascade"):e.modifier==="restrict"&&this.append(" restrict")}visitRenameConstraint(e){this.append("rename constraint "),this.visitNode(e.oldName),this.append(" to "),this.visitNode(e.newName)}visitSetOperation(e){this.append(e.operator),this.append(" "),e.all&&this.append("all "),this.visitNode(e.expression)}visitCreateView(e){this.append("create "),e.orReplace&&this.append("or replace "),e.materialized&&this.append("materialized "),e.temporary&&this.append("temporary "),this.append("view "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),this.append(" "),e.columns&&(this.append("("),this.compileList(e.columns),this.append(") ")),e.as&&(this.append("as "),this.visitNode(e.as))}visitRefreshMaterializedView(e){this.append("refresh materialized view "),e.concurrently&&this.append("concurrently "),this.visitNode(e.name),e.withNoData?this.append(" with no data"):this.append(" with data")}visitDropView(e){this.append("drop "),e.materialized&&this.append("materialized "),this.append("view "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.cascade&&this.append(" cascade")}visitGenerated(e){this.append("generated "),e.always&&this.append("always "),e.byDefault&&this.append("by default "),this.append("as "),e.identity&&this.append("identity"),e.expression&&(this.append("("),this.visitNode(e.expression),this.append(")")),e.stored&&this.append(" stored")}visitDefaultValue(e){this.append("default "),this.visitNode(e.defaultValue)}visitSelectModifier(e){e.rawModifier?this.visitNode(e.rawModifier):this.append(Bt[e.modifier]),e.of&&(this.append(" of "),this.compileList(e.of,", "))}visitCreateType(e){this.append("create type "),this.visitNode(e.name),e.enum&&(this.append(" as enum "),this.visitNode(e.enum))}visitDropType(e){this.append("drop type "),e.ifExists&&this.append("if exists "),this.visitNode(e.name)}visitExplain(e){this.append("explain"),(e.options||e.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),e.options&&(this.visitNode(e.options),e.format&&this.append(this.getExplainOptionsDelimiter())),e.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(e.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(e){this.append("default")}visitAggregateFunction(e){this.append(e.func),this.append("("),e.distinct&&this.append("distinct "),this.compileList(e.aggregated),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),this.append(")"),e.withinGroup&&(this.append(" within group ("),this.visitNode(e.withinGroup),this.append(")")),e.filter&&(this.append(" filter("),this.visitNode(e.filter),this.append(")")),e.over&&(this.append(" "),this.visitNode(e.over))}visitOver(e){this.append("over("),e.partitionBy&&(this.visitNode(e.partitionBy),e.orderBy&&this.append(" ")),e.orderBy&&this.visitNode(e.orderBy),this.append(")")}visitPartitionBy(e){this.append("partition by "),this.compileList(e.items)}visitPartitionByItem(e){this.visitNode(e.partitionBy)}visitBinaryOperation(e){this.visitNode(e.leftOperand),this.append(" "),this.visitNode(e.operator),this.append(" "),this.visitNode(e.rightOperand)}visitUnaryOperation(e){this.visitNode(e.operator),this.isMinusOperator(e.operator)||this.append(" "),this.visitNode(e.operand)}isMinusOperator(e){return ot.is(e)&&e.operator==="-"}visitUsing(e){this.append("using "),this.compileList(e.tables)}visitFunction(e){this.append(e.func),this.append("("),this.compileList(e.arguments),this.append(")")}visitCase(e){this.append("case"),e.value&&(this.append(" "),this.visitNode(e.value)),e.when&&(this.append(" "),this.compileList(e.when," ")),e.else&&(this.append(" else "),this.visitNode(e.else)),this.append(" end"),e.isStatement&&this.append(" case")}visitWhen(e){this.append("when "),this.visitNode(e.condition),e.result&&(this.append(" then "),this.visitNode(e.result))}visitJSONReference(e){this.visitNode(e.reference),this.visitNode(e.traversal)}visitJSONPath(e){e.inOperator&&this.visitNode(e.inOperator),this.append("'$");for(let r of e.pathLegs)this.visitNode(r);this.append("'")}visitJSONPathLeg(e){let r=e.type==="ArrayLocation";this.append(r?"[":"."),this.append(String(e.value)),r&&this.append("]")}visitJSONOperatorChain(e){for(let r=0,s=e.values.length;r<s;r++)r===s-1?this.visitNode(e.operator):this.append("->"),this.visitNode(e.values[r])}visitMergeQuery(e){e.with&&(this.visitNode(e.with),this.append(" ")),this.append("merge "),e.top&&(this.visitNode(e.top),this.append(" ")),this.append("into "),this.visitNode(e.into),e.using&&(this.append(" "),this.visitNode(e.using)),e.whens&&(this.append(" "),this.compileList(e.whens," ")),e.returning&&(this.append(" "),this.visitNode(e.returning)),e.output&&(this.append(" "),this.visitNode(e.output)),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitMatched(e){e.not&&this.append("not "),this.append("matched"),e.bySource&&this.append(" by source")}visitAddIndex(e){this.append("add "),e.unique&&this.append("unique "),this.append("index "),this.visitNode(e.name),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.using&&(this.append(" using "),this.visitNode(e.using))}visitCast(e){this.append("cast("),this.visitNode(e.expression),this.append(" as "),this.visitNode(e.dataType),this.append(")")}visitFetch(e){this.append("fetch next "),this.visitNode(e.rowCount),this.append(` rows ${e.modifier}`)}visitOutput(e){this.append("output "),this.compileList(e.selections)}visitTop(e){this.append(`top(${e.expression})`),e.modifiers&&this.append(` ${e.modifiers}`)}visitOrAction(e){this.append(e.action)}visitCollate(e){this.append("collate "),this.visitNode(e.collation)}append(e){this.#e+=e}appendValue(e){this.addParameter(e),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(e){let r=this.getLeftIdentifierWrapper(),s=this.getRightIdentifierWrapper(),n="";for(let h of e)n+=h,h===r?n+=r:h===s&&(n+=s);return n}sanitizeStringLiteral(e){return e.replace(zt,"''")}addParameter(e){this.#t.push(e)}appendImmediateValue(e){if(ze(e))this.appendStringLiteral(e);else if(tt(e)||Be(e)||st(e))this.append(e.toString());else if(it(e))this.append("null");else if(rt(e))this.appendImmediateValue(e.toISOString());else throw new Error(`invalid immediate value ${e}`)}appendStringLiteral(e){this.append("'"),this.append(this.sanitizeStringLiteral(e)),this.append("'")}sortSelectModifiers(e){return e.sort((r,s)=>r.modifier&&s.modifier?Et[r.modifier]-Et[s.modifier]:1),i(e)}compileColumnAlterations(e){this.compileList(e)}announcesNewColumnDataType(){return!0}},Bt=i({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),Et=i({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),Vt=i({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",CrossJoin:"cross join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",LateralCrossJoin:"cross join lateral",OuterApply:"outer apply",CrossApply:"cross apply",Using:"using"});var Oa=i({raw(t,e=[]){return i({sql:t,query:C.createWithSql(t),parameters:i(e),queryId:u()})}});var kt=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}};var Ea="kysely_migration",ka="kysely_migration_lock";var Pa=i({__noMigrations__:!0});export{qe as a,St as b,Oa as c,kt as d,Ea as e,ka as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function M(r){return typeof r>"u"||r===void 0}function p(r){return typeof r=="string"}function pe(r){return typeof r=="number"}function ze(r){return typeof r=="boolean"}function Ie(r){return r===null}function ko(r){return r instanceof Date}function Ue(r){return typeof r=="bigint"}function Co(r){return typeof Buffer<"u"&&Buffer.isBuffer(r)}function x(r){return typeof r=="function"}function X(r){return typeof r=="object"&&r!==null}function o(r){return Object.freeze(r)}function Re(r){return C(r)?r:[r]}function C(r){return Array.isArray(r)}function Eo(r){return r}var nt=new Set;function le(r){nt.has(r)||(nt.add(r),console.log(r))}var it=["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 st(r){let e="";for(let t=0;t<r;++t)e+=Xt();return e}function Xt(){return it[~~(Math.random()*it.length)]}function w(){return new Wr}var Wr=class{#e;get queryId(){return this.#e===void 0&&(this.#e=st(8)),this.#e}};var g=o({is(r){return r.kind==="AliasNode"},create(r,e){return o({kind:"AliasNode",node:r,alias:e})}});var u=o({is(r){return r.kind==="IdentifierNode"},create(r){return o({kind:"IdentifierNode",name:r})}});var T=o({is(r){return r.kind==="AndNode"},create(r,e){return o({kind:"AndNode",left:r,right:e})}});var P=o({is(r){return r.kind==="OrNode"},create(r,e){return o({kind:"OrNode",left:r,right:e})}});var Ve=o({is(r){return r.kind==="OnNode"},create(r){return o({kind:"OnNode",on:r})},cloneWithOperation(r,e,t){return o({...r,on:e==="And"?T.create(r.on,t):P.create(r.on,t)})}});var Q=o({is(r){return r.kind==="JoinNode"},create(r,e){return o({kind:"JoinNode",joinType:r,table:e,on:void 0})},createWithOn(r,e,t){return o({kind:"JoinNode",joinType:r,table:e,on:Ve.create(t)})},cloneWithOn(r,e){return o({...r,on:r.on?Ve.cloneWithOperation(r.on,"And",e):Ve.create(e)})}});var Je=o({is(r){return r.kind==="ListNode"},create(r){return o({kind:"ListNode",items:o(r)})}});var $e=class{nodeStack=[];#e=o({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode(e,t){if(!e)return e;this.nodeStack.push(e);let n=this.transformNodeImpl(e,t);return this.nodeStack.pop(),o(n)}transformNodeImpl(e,t){return this.#e[e.kind](e,t)}transformNodeList(e,t){return e&&o(e.map(n=>this.transformNode(n,t)))}transformSelectQuery(e,t){return{kind:"SelectQueryNode",from:this.transformNode(e.from,t),selections:this.transformNodeList(e.selections,t),distinctOn:this.transformNodeList(e.distinctOn,t),joins:this.transformNodeList(e.joins,t),groupBy:this.transformNode(e.groupBy,t),orderBy:this.transformNode(e.orderBy,t),where:this.transformNode(e.where,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),limit:this.transformNode(e.limit,t),offset:this.transformNode(e.offset,t),with:this.transformNode(e.with,t),having:this.transformNode(e.having,t),explain:this.transformNode(e.explain,t),setOperations:this.transformNodeList(e.setOperations,t),fetch:this.transformNode(e.fetch,t),top:this.transformNode(e.top,t)}}transformSelection(e,t){return{kind:"SelectionNode",selection:this.transformNode(e.selection,t)}}transformColumn(e,t){return{kind:"ColumnNode",column:this.transformNode(e.column,t)}}transformAlias(e,t){return{kind:"AliasNode",node:this.transformNode(e.node,t),alias:this.transformNode(e.alias,t)}}transformTable(e,t){return{kind:"TableNode",table:this.transformNode(e.table,t)}}transformFrom(e,t){return{kind:"FromNode",froms:this.transformNodeList(e.froms,t)}}transformReference(e,t){return{kind:"ReferenceNode",column:this.transformNode(e.column,t),table:this.transformNode(e.table,t)}}transformAnd(e,t){return{kind:"AndNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)}}transformOr(e,t){return{kind:"OrNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)}}transformValueList(e,t){return{kind:"ValueListNode",values:this.transformNodeList(e.values,t)}}transformParens(e,t){return{kind:"ParensNode",node:this.transformNode(e.node,t)}}transformJoin(e,t){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,t),on:this.transformNode(e.on,t)}}transformRaw(e,t){return{kind:"RawNode",sqlFragments:o([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,t)}}transformWhere(e,t){return{kind:"WhereNode",where:this.transformNode(e.where,t)}}transformInsertQuery(e,t){return{kind:"InsertQueryNode",into:this.transformNode(e.into,t),columns:this.transformNodeList(e.columns,t),values:this.transformNode(e.values,t),returning:this.transformNode(e.returning,t),onConflict:this.transformNode(e.onConflict,t),onDuplicateKey:this.transformNode(e.onDuplicateKey,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),ignore:e.ignore,orAction:this.transformNode(e.orAction,t),replace:e.replace,explain:this.transformNode(e.explain,t),defaultValues:e.defaultValues,top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)}}transformValues(e,t){return{kind:"ValuesNode",values:this.transformNodeList(e.values,t)}}transformDeleteQuery(e,t){return{kind:"DeleteQueryNode",from:this.transformNode(e.from,t),using:this.transformNode(e.using,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),orderBy:this.transformNode(e.orderBy,t),limit:this.transformNode(e.limit,t),explain:this.transformNode(e.explain,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)}}transformReturning(e,t){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections,t)}}transformCreateTable(e,t){return{kind:"CreateTableNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),constraints:this.transformNodeList(e.constraints,t),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),selectQuery:this.transformNode(e.selectQuery,t)}}transformColumnDefinition(e,t){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),references:this.transformNode(e.references,t),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,t),check:this.transformNode(e.check,t),generated:this.transformNode(e.generated,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e,t){return{kind:"AddColumnNode",column:this.transformNode(e.column,t)}}transformDropTable(e,t){return{kind:"DropTableNode",table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e,t){return{kind:"OrderByNode",items:this.transformNodeList(e.items,t)}}transformOrderByItem(e,t){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,t),direction:this.transformNode(e.direction,t),collation:this.transformNode(e.collation,t),nulls:e.nulls}}transformGroupBy(e,t){return{kind:"GroupByNode",items:this.transformNodeList(e.items,t)}}transformGroupByItem(e,t){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,t)}}transformUpdateQuery(e,t){return{kind:"UpdateQueryNode",table:this.transformNode(e.table,t),from:this.transformNode(e.from,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),updates:this.transformNodeList(e.updates,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),explain:this.transformNode(e.explain,t),limit:this.transformNode(e.limit,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t),orderBy:this.transformNode(e.orderBy,t)}}transformColumnUpdate(e,t){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column,t),value:this.transformNode(e.value,t)}}transformLimit(e,t){return{kind:"LimitNode",limit:this.transformNode(e.limit,t)}}transformOffset(e,t){return{kind:"OffsetNode",offset:this.transformNode(e.offset,t)}}transformOnConflict(e,t){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns,t),constraint:this.transformNode(e.constraint,t),indexExpression:this.transformNode(e.indexExpression,t),indexWhere:this.transformNode(e.indexWhere,t),updates:this.transformNodeList(e.updates,t),updateWhere:this.transformNode(e.updateWhere,t),doNothing:e.doNothing}}transformOnDuplicateKey(e,t){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,t)}}transformCreateIndex(e,t){return{kind:"CreateIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,t),nullsNotDistinct:e.nullsNotDistinct}}transformList(e,t){return{kind:"ListNode",items:this.transformNodeList(e.items,t)}}transformDropIndex(e,t){return{kind:"DropIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e,t){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformUniqueConstraint(e,t){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformForeignKeyConstraint(e,t){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,t),references:this.transformNode(e.references,t),name:this.transformNode(e.name,t),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformSetOperation(e,t){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,t),all:e.all}}transformReferences(e,t){return{kind:"ReferencesNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e,t){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression,t),name:this.transformNode(e.name,t)}}transformWith(e,t){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions,t),recursive:e.recursive}}transformCommonTableExpression(e,t){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name,t),materialized:e.materialized,expression:this.transformNode(e.expression,t)}}transformCommonTableExpressionName(e,t){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t)}}transformHaving(e,t){return{kind:"HavingNode",having:this.transformNode(e.having,t)}}transformCreateSchema(e,t){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema,t),ifNotExists:e.ifNotExists}}transformDropSchema(e,t){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema,t),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e,t){return{kind:"AlterTableNode",table:this.transformNode(e.table,t),renameTo:this.transformNode(e.renameTo,t),setSchema:this.transformNode(e.setSchema,t),columnAlterations:this.transformNodeList(e.columnAlterations,t),addConstraint:this.transformNode(e.addConstraint,t),dropConstraint:this.transformNode(e.dropConstraint,t),renameConstraint:this.transformNode(e.renameConstraint,t),addIndex:this.transformNode(e.addIndex,t),dropIndex:this.transformNode(e.dropIndex,t)}}transformDropColumn(e,t){return{kind:"DropColumnNode",column:this.transformNode(e.column,t)}}transformRenameColumn(e,t){return{kind:"RenameColumnNode",column:this.transformNode(e.column,t),renameTo:this.transformNode(e.renameTo,t)}}transformAlterColumn(e,t){return{kind:"AlterColumnNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),dataTypeExpression:this.transformNode(e.dataTypeExpression,t),setDefault:this.transformNode(e.setDefault,t),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e,t){return{kind:"ModifyColumnNode",column:this.transformNode(e.column,t)}}transformAddConstraint(e,t){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,t)}}transformDropConstraint(e,t){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,t),ifExists:e.ifExists,modifier:e.modifier}}transformRenameConstraint(e,t){return{kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,t),newName:this.transformNode(e.newName,t)}}transformCreateView(e,t){return{kind:"CreateViewNode",name:this.transformNode(e.name,t),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,t),as:this.transformNode(e.as,t)}}transformRefreshMaterializedView(e,t){return{kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,t),concurrently:e.concurrently,withNoData:e.withNoData}}transformDropView(e,t){return{kind:"DropViewNode",name:this.transformNode(e.name,t),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e,t){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,t)}}transformDefaultValue(e,t){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,t)}}transformOn(e,t){return{kind:"OnNode",on:this.transformNode(e.on,t)}}transformSelectModifier(e,t){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,t),of:this.transformNodeList(e.of,t)}}transformCreateType(e,t){return{kind:"CreateTypeNode",name:this.transformNode(e.name,t),enum:this.transformNode(e.enum,t)}}transformDropType(e,t){return{kind:"DropTypeNode",name:this.transformNode(e.name,t),ifExists:e.ifExists}}transformExplain(e,t){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,t)}}transformSchemableIdentifier(e,t){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,t),identifier:this.transformNode(e.identifier,t)}}transformAggregateFunction(e,t){return{kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,t),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,t),withinGroup:this.transformNode(e.withinGroup,t),filter:this.transformNode(e.filter,t),over:this.transformNode(e.over,t)}}transformOver(e,t){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy,t),partitionBy:this.transformNode(e.partitionBy,t)}}transformPartitionBy(e,t){return{kind:"PartitionByNode",items:this.transformNodeList(e.items,t)}}transformPartitionByItem(e,t){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,t)}}transformBinaryOperation(e,t){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,t),operator:this.transformNode(e.operator,t),rightOperand:this.transformNode(e.rightOperand,t)}}transformUnaryOperation(e,t){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator,t),operand:this.transformNode(e.operand,t)}}transformUsing(e,t){return{kind:"UsingNode",tables:this.transformNodeList(e.tables,t)}}transformFunction(e,t){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,t)}}transformCase(e,t){return{kind:"CaseNode",value:this.transformNode(e.value,t),when:this.transformNodeList(e.when,t),else:this.transformNode(e.else,t),isStatement:e.isStatement}}transformWhen(e,t){return{kind:"WhenNode",condition:this.transformNode(e.condition,t),result:this.transformNode(e.result,t)}}transformJSONReference(e,t){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference,t),traversal:this.transformNode(e.traversal,t)}}transformJSONPath(e,t){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,t),pathLegs:this.transformNodeList(e.pathLegs,t)}}transformJSONPathLeg(e,t){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e,t){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,t),values:this.transformNodeList(e.values,t)}}transformTuple(e,t){return{kind:"TupleNode",values:this.transformNodeList(e.values,t)}}transformMergeQuery(e,t){return{kind:"MergeQueryNode",into:this.transformNode(e.into,t),using:this.transformNode(e.using,t),whens:this.transformNodeList(e.whens,t),with:this.transformNode(e.with,t),top:this.transformNode(e.top,t),endModifiers:this.transformNodeList(e.endModifiers,t),output:this.transformNode(e.output,t),returning:this.transformNode(e.returning,t)}}transformMatched(e,t){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e,t){return{kind:"AddIndexNode",name:this.transformNode(e.name,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists}}transformCast(e,t){return{kind:"CastNode",expression:this.transformNode(e.expression,t),dataType:this.transformNode(e.dataType,t)}}transformFetch(e,t){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount,t),modifier:e.modifier}}transformTop(e,t){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e,t){return{kind:"OutputNode",selections:this.transformNodeList(e.selections,t)}}transformDataType(e,t){return e}transformSelectAll(e,t){return e}transformIdentifier(e,t){return e}transformValue(e,t){return e}transformPrimitiveValueList(e,t){return e}transformOperator(e,t){return e}transformDefaultInsertValue(e,t){return e}transformOrAction(e,t){return e}transformCollate(e,t){return e}};var Ae=o({is(r){return r.kind==="SchemableIdentifierNode"},create(r){return o({kind:"SchemableIdentifierNode",identifier:u.create(r)})},createWithSchema(r,e){return o({kind:"SchemableIdentifierNode",schema:u.create(r),identifier:u.create(e)})}});var B=o({is(r){return r.kind==="TableNode"},create(r){return o({kind:"TableNode",table:Ae.create(r)})},createWithSchema(r,e){return o({kind:"TableNode",table:Ae.createWithSchema(r,e)})}});var Te=o({is(r){return r.kind==="UsingNode"},create(r){return o({kind:"UsingNode",tables:o(r)})},cloneWithTables(r,e){return o({...r,tables:o([...r.tables,...e])})}});var Zt=o({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),_t={json_agg:!0,to_json:!0},Ge=class extends $e{#e;#r=new Set;#t=new Set;constructor(e){super(),this.#e=e}transformNodeImpl(e,t){if(!this.#s(e))return super.transformNodeImpl(e,t);let n=this.#u(e);for(let A of n)this.#t.add(A);let i=this.#a(e);for(let A of i)this.#r.add(A);let m=super.transformNodeImpl(e,t);for(let A of i)this.#r.delete(A);for(let A of n)this.#t.delete(A);return m}transformSchemableIdentifier(e,t){let n=super.transformSchemableIdentifier(e,t);return n.schema||!this.#r.has(e.identifier.name)?n:{...n,schema:u.create(this.#e)}}transformReferences(e,t){let n=super.transformReferences(e,t);return n.table.table.schema?n:{...n,table:B.createWithSchema(this.#e,n.table.table.identifier.name)}}transformAggregateFunction(e,t){return{...super.transformAggregateFunction({...e,aggregated:[]},t),aggregated:this.#n(e,t,"aggregated")}}transformFunction(e,t){return{...super.transformFunction({...e,arguments:[]},t),arguments:this.#n(e,t,"arguments")}}transformSelectModifier(e,t){return{...super.transformSelectModifier({...e,of:void 0},t),of:e.of?.map(n=>B.is(n)&&!n.table.schema?{...n,table:this.transformIdentifier(n.table.identifier,t)}:this.transformNode(n,t))}}#n(e,t,n){return _t[e.func]?e[n].map(i=>!B.is(i)||i.table.schema?this.transformNode(i,t):{...i,table:this.transformIdentifier(i.table.identifier,t)}):this.transformNodeList(e[n],t)}#s(e){return e.kind in Zt}#a(e){let t=new Set;if("name"in e&&e.name&&Ae.is(e.name)&&this.#i(e.name,t),"from"in e&&e.from)for(let n of e.from.froms)this.#o(n,t);if("into"in e&&e.into&&this.#o(e.into,t),"table"in e&&e.table&&this.#o(e.table,t),"joins"in e&&e.joins)for(let n of e.joins)this.#o(n.table,t);return"using"in e&&e.using&&(Q.is(e.using)?this.#o(e.using.table,t):this.#o(e.using,t)),t}#u(e){let t=new Set;return"with"in e&&e.with&&this.#d(e.with,t),t}#o(e,t){if(B.is(e))return this.#i(e.table,t);if(g.is(e)&&B.is(e.node))return this.#i(e.node.table,t);if(Je.is(e)){for(let n of e.items)this.#o(n,t);return}if(Te.is(e)){for(let n of e.tables)this.#o(n,t);return}}#i(e,t){let n=e.identifier.name;!this.#r.has(n)&&!this.#t.has(n)&&t.add(n)}#d(e,t){for(let n of e.expressions){let i=n.name.table.table.identifier.name;this.#t.has(i)||t.add(i)}}};var Ne=class{#e;constructor(e){this.#e=new Ge(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}};var Be=class{#e;#r;#t;constructor(){this.#e=new Promise((e,t)=>{this.#t=t,this.#r=e})}get promise(){return this.#e}resolve=e=>{this.#r&&this.#r(e)};reject=e=>{this.#t&&this.#t(e)}};async function at(r){let e=new Be,t=new Be;return r.provideConnection(async n=>(e.resolve(n),await t.promise)).catch(n=>e.reject(n)),o({connection:await e.promise,release:t.resolve})}var G=o({is(r){return r.kind==="SelectModifierNode"},create(r,e){return o({kind:"SelectModifierNode",modifier:r,of:e})},createWithExpression(r){return o({kind:"SelectModifierNode",rawModifier:r})}});var oe=o({is(r){return r.kind==="BinaryOperationNode"},create(r,e,t){return o({kind:"BinaryOperationNode",leftOperand:r,operator:e,rightOperand:t})}});function f(r){return X(r)&&x(r.toOperationNode)}var eo=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],ro=["+","-","*","/","%","^","&","|","#","<<",">>"],ut=["->","->>"],to=[...eo,...ro,"&&","||"],oo=["exists","not exists"],no=["not","-",...oo],dt=[...to,...ut,...no,"between","between symmetric"],v=o({is(r){return r.kind==="OperatorNode"},create(r){return o({kind:"OperatorNode",operator:r})}});function Sr(r){return p(r)&&ut.includes(r)}var E=o({is(r){return r.kind==="ColumnNode"},create(r){return o({kind:"ColumnNode",column:u.create(r)})}});var je=o({is(r){return r.kind==="SelectAllNode"},create(){return o({kind:"SelectAllNode"})}});var ye=o({is(r){return r.kind==="ReferenceNode"},create(r,e){return o({kind:"ReferenceNode",table:e,column:r})},createSelectAll(r){return o({kind:"ReferenceNode",table:r,column:je.create()})}});function Ke(r){return X(r)&&"expressionType"in r&&f(r)}function mt(r){return X(r)&&"expression"in r&&p(r.alias)&&f(r)}var me=o({is(r){return r.kind==="FromNode"},create(r){return o({kind:"FromNode",froms:o(r)})},cloneWithFroms(r,e){return o({...r,froms:o([...r.froms,...e])})}});var br=o({is(r){return r.kind==="GroupByNode"},create(r){return o({kind:"GroupByNode",items:o(r)})},cloneWithItems(r,e){return o({...r,items:o([...r.items,...e])})}});var kr=o({is(r){return r.kind==="HavingNode"},create(r){return o({kind:"HavingNode",having:r})},cloneWithOperation(r,e,t){return o({...r,having:e==="And"?T.create(r.having,t):P.create(r.having,t)})}});var l=o({is(r){return r.kind==="InsertQueryNode"},create(r,e,t){return o({kind:"InsertQueryNode",into:r,...e&&{with:e},replace:t})},createWithoutInto(){return o({kind:"InsertQueryNode"})},cloneWith(r,e){return o({...r,...e})}});var j=o({is(r){return r.kind==="UpdateQueryNode"},create(r,e){return o({kind:"UpdateQueryNode",table:r.length===1?r[0]:Je.create(r),...e&&{with:e}})},createWithoutTable(){return o({kind:"UpdateQueryNode"})},cloneWithFromItems(r,e){return o({...r,from:r.from?me.cloneWithFroms(r.from,e):me.create(e)})},cloneWithUpdates(r,e){return o({...r,updates:r.updates?o([...r.updates,...e]):e})},cloneWithLimit(r,e){return o({...r,limit:e})}});var ne=o({is(r){return r.kind==="DeleteQueryNode"},create(r,e){return o({kind:"DeleteQueryNode",from:me.create(r),...e&&{with:e}})},cloneWithOrderByItems:(r,e)=>s.cloneWithOrderByItems(r,e),cloneWithoutOrderBy:r=>s.cloneWithoutOrderBy(r),cloneWithLimit(r,e){return o({...r,limit:e})},cloneWithoutLimit(r){return o({...r,limit:void 0})},cloneWithUsing(r,e){return o({...r,using:r.using!==void 0?Te.cloneWithTables(r.using,e):Te.create(e)})}});var b=o({is(r){return r.kind==="WhereNode"},create(r){return o({kind:"WhereNode",where:r})},cloneWithOperation(r,e,t){return o({...r,where:e==="And"?T.create(r.where,t):P.create(r.where,t)})}});var Cr=o({is(r){return r.kind==="ReturningNode"},create(r){return o({kind:"ReturningNode",selections:o(r)})},cloneWithSelections(r,e){return o({...r,selections:r.selections?o([...r.selections,...e]):o(e)})}});var ct=o({is(r){return r.kind==="ExplainNode"},create(r,e){return o({kind:"ExplainNode",format:r,options:e})}});var Z=o({is(r){return r.kind==="WhenNode"},create(r){return o({kind:"WhenNode",condition:r})},cloneWithResult(r,e){return o({...r,result:e})}});var q=o({is(r){return r.kind==="MergeQueryNode"},create(r,e){return o({kind:"MergeQueryNode",into:r,...e&&{with:e}})},cloneWithUsing(r,e){return o({...r,using:e})},cloneWithWhen(r,e){return o({...r,whens:r.whens?o([...r.whens,e]):o([e])})},cloneWithThen(r,e){return o({...r,whens:r.whens?o([...r.whens.slice(0,-1),Z.cloneWithResult(r.whens[r.whens.length-1],e)]):void 0})}});var Er=o({is(r){return r.kind==="OutputNode"},create(r){return o({kind:"OutputNode",selections:o(r)})},cloneWithSelections(r,e){return o({...r,selections:r.selections?o([...r.selections,...e]):o(e)})}});var _=o({is(r){return r.kind==="OrderByNode"},create(r){return o({kind:"OrderByNode",items:o([...r])})},cloneWithItems(r,e){return o({...r,items:o([...r.items,...e])})}});var s=o({is(r){return d.is(r)||l.is(r)||j.is(r)||ne.is(r)||q.is(r)},cloneWithEndModifier(r,e){return o({...r,endModifiers:r.endModifiers?o([...r.endModifiers,e]):o([e])})},cloneWithWhere(r,e){return o({...r,where:r.where?b.cloneWithOperation(r.where,"And",e):b.create(e)})},cloneWithJoin(r,e){return o({...r,joins:r.joins?o([...r.joins,e]):o([e])})},cloneWithReturning(r,e){return o({...r,returning:r.returning?Cr.cloneWithSelections(r.returning,e):Cr.create(e)})},cloneWithoutReturning(r){return o({...r,returning:void 0})},cloneWithoutWhere(r){return o({...r,where:void 0})},cloneWithExplain(r,e,t){return o({...r,explain:ct.create(e,t?.toOperationNode())})},cloneWithTop(r,e){return o({...r,top:e})},cloneWithOutput(r,e){return o({...r,output:r.output?Er.cloneWithSelections(r.output,e):Er.create(e)})},cloneWithOrderByItems(r,e){return o({...r,orderBy:r.orderBy?_.cloneWithItems(r.orderBy,e):_.create(e)})},cloneWithoutOrderBy(r){return o({...r,orderBy:void 0})}});var d=o({is(r){return r.kind==="SelectQueryNode"},create(r){return o({kind:"SelectQueryNode",...r&&{with:r}})},createFrom(r,e){return o({kind:"SelectQueryNode",from:me.create(r),...e&&{with:e}})},cloneWithSelections(r,e){return o({...r,selections:r.selections?o([...r.selections,...e]):o(e)})},cloneWithDistinctOn(r,e){return o({...r,distinctOn:r.distinctOn?o([...r.distinctOn,...e]):o(e)})},cloneWithFrontModifier(r,e){return o({...r,frontModifiers:r.frontModifiers?o([...r.frontModifiers,e]):o([e])})},cloneWithOrderByItems:(r,e)=>s.cloneWithOrderByItems(r,e),cloneWithGroupByItems(r,e){return o({...r,groupBy:r.groupBy?br.cloneWithItems(r.groupBy,e):br.create(e)})},cloneWithLimit(r,e){return o({...r,limit:e})},cloneWithOffset(r,e){return o({...r,offset:e})},cloneWithFetch(r,e){return o({...r,fetch:e})},cloneWithHaving(r,e){return o({...r,having:r.having?kr.cloneWithOperation(r.having,"And",e):kr.create(e)})},cloneWithSetOperations(r,e){return o({...r,setOperations:r.setOperations?o([...r.setOperations,...e]):o([...e])})},cloneWithoutSelections(r){return o({...r,selections:[]})},cloneWithoutLimit(r){return o({...r,limit:void 0})},cloneWithoutOffset(r){return o({...r,offset:void 0})},cloneWithoutOrderBy:r=>s.cloneWithoutOrderBy(r),cloneWithoutGroupBy(r){return o({...r,groupBy:void 0})}});var ht=class{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new Rr(this.#e,e)}},Rr=class{#e;#r;get table(){return this.#e}get alias(){return this.#r}constructor(e,t){this.#e=e,this.#r=t}toOperationNode(){return g.create(N(this.#e),u.create(this.#r))}};function ft(r){return X(r)&&f(r)&&p(r.table)&&p(r.alias)}function z(r){return C(r)?r.map(e=>ce(e)):[ce(r)]}function ce(r){return p(r)?Ar(r):ft(r)?r.toOperationNode():He(r)}function Ar(r){let e=" as ";if(r.includes(e)){let[t,n]=r.split(e).map(pt);return g.create(N(t),u.create(n))}else return N(r)}function N(r){if(r.includes(".")){let[t,n]=r.split(".").map(pt);return B.createWithSchema(t,n)}else return B.create(r)}function pt(r){return r.trim()}var ie=o({is(r){return r.kind==="ParensNode"},create(r){return o({kind:"ParensNode",node:r})}});var a=class r{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new qe(this,e)}or(...e){return new Tr(P.create(this.#e,h(e)))}and(...e){return new Br(T.create(this.#e,h(e)))}$castTo(){return new r(this.#e)}$notNull(){return new r(this.#e)}toOperationNode(){return this.#e}},qe=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return g.create(this.#e.toOperationNode(),f(this.#r)?this.#r.toOperationNode():u.create(this.#r))}},Tr=class r{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new qe(this,e)}or(...e){return new r(P.create(this.#e,h(e)))}$castTo(){return new r(this.#e)}toOperationNode(){return ie.create(this.#e)}},Br=class r{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new qe(this,e)}and(...e){return new r(T.create(this.#e,h(e)))}$castTo(){return new r(this.#e)}toOperationNode(){return ie.create(this.#e)}};var K=o({is(r){return r.kind==="AggregateFunctionNode"},create(r,e=[]){return o({kind:"AggregateFunctionNode",func:r,aggregated:e})},cloneWithDistinct(r){return o({...r,distinct:!0})},cloneWithOrderBy(r,e,t=!1){let n=t?"withinGroup":"orderBy";return o({...r,[n]:r[n]?_.cloneWithItems(r[n],e):_.create(e)})},cloneWithFilter(r,e){return o({...r,filter:r.filter?b.cloneWithOperation(r.filter,"And",e):b.create(e)})},cloneWithOrFilter(r,e){return o({...r,filter:r.filter?b.cloneWithOperation(r.filter,"Or",e):b.create(e)})},cloneWithOver(r,e){return o({...r,over:e})}});var qr=o({is(r){return r.kind==="FunctionNode"},create(r,e){return o({kind:"FunctionNode",func:r,arguments:e})}});var we=o({is(r){return r.kind==="SelectionNode"},create(r){return o({kind:"SelectionNode",selection:r})},createSelectAll(){return o({kind:"SelectionNode",selection:je.create()})},createSelectAllFromTable(r){return o({kind:"SelectionNode",selection:ye.createSelectAll(r)})}});var lt=class{#e;get dynamicReference(){return this.#e}get refType(){}constructor(e){this.#e=e}toOperationNode(){return Lr(this.#e)}};function Ye(r){return X(r)&&f(r)&&p(r.dynamicReference)}function O(r){return x(r)?O(r(I())):C(r)?r.map(e=>Nt(e)):[Nt(r)]}function Nt(r){return p(r)?we.create(wt(r)):Ye(r)?we.create(r.toOperationNode()):we.create(He(r))}function W(r){return r?Array.isArray(r)?r.map(yt):[yt(r)]:[we.createSelectAll()]}function yt(r){if(p(r))return we.createSelectAllFromTable(N(r));throw new Error(`invalid value selectAll expression: ${JSON.stringify(r)}`)}var Fr=o({is(r){return r.kind==="PartitionByNode"},create(r){return o({kind:"PartitionByNode",items:o(r)})},cloneWithItems(r,e){return o({...r,items:o([...r.items,...e])})}});var Le=o({is(r){return r.kind==="OverNode"},create(){return o({kind:"OverNode"})},cloneWithOrderByItems(r,e){return o({...r,orderBy:r.orderBy?_.cloneWithItems(r.orderBy,e):_.create(e)})},cloneWithPartitionByItems(r,e){return o({...r,partitionBy:r.partitionBy?Fr.cloneWithItems(r.partitionBy,e):Fr.create(e)})}});var y=o({is(r){return r.kind==="RawNode"},create(r,e){return o({kind:"RawNode",sqlFragments:o(r),parameters:o(e)})},createWithSql(r){return y.create([r],[])},createWithChild(r){return y.create(["",""],[r])},createWithChildren(r){return y.create(new Array(r.length+1).fill(""),r)}});var Xe=class r{#e;constructor(e){this.#e=o(e)}on(...e){return new r({...this.#e,joinNode:Q.cloneWithOn(this.#e.joinNode,h(e))})}onRef(e,t,n){return new r({...this.#e,joinNode:Q.cloneWithOn(this.#e.joinNode,S(e,t,n))})}onTrue(){return new r({...this.#e,joinNode:Q.cloneWithOn(this.#e.joinNode,y.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}};var U=o({is(r){return r.kind==="OrderByItemNode"},create(r,e){return o({kind:"OrderByItemNode",orderBy:r,direction:e})},cloneWith(r,e){return o({...r,...e})}});var Ot=o({is(r){return r.kind==="CollateNode"},create(r){return o({kind:"CollateNode",collation:u.create(r)})}});var Ze=class r{#e;constructor(e){this.#e=o(e)}desc(){return new r({node:U.cloneWith(this.#e.node,{direction:y.createWithSql("desc")})})}asc(){return new r({node:U.cloneWith(this.#e.node,{direction:y.createWithSql("asc")})})}nullsLast(){return new r({node:U.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new r({node:U.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new r({node:U.cloneWith(this.#e.node,{collation:Ot.create(e)})})}toOperationNode(){return this.#e.node}};function Mr(r){return r==="asc"||r==="desc"}function L(r){if(r.length===2)return[Dr(r[0],r[1])];if(r.length===1){let[e]=r;return Array.isArray(e)?(le("orderBy(array) is deprecated, use multiple orderBy calls instead."),e.map(t=>Dr(t))):[Dr(e)]}throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${r.length}`)}function Dr(r,e){let t=io(r);if(U.is(t)){if(e)throw new Error("Cannot specify direction twice!");return t}return xt(t,e)}function io(r){if(ee(r))return H(r);if(Ye(r))return r.toOperationNode();let[e,t]=r.split(" ");return t?(le("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),xt(V(e),t)):V(r)}function xt(r,e){if(typeof e=="string"){if(!Mr(e))throw new Error(`Invalid order by direction: ${e}`);return U.create(r,y.createWithSql(e))}if(Ke(e))return le("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),U.create(r,e.toOperationNode());let t=U.create(r);return e?e(new Ze({node:t})).toOperationNode():t}var gt=o({is(r){return r.kind==="PartitionByItemNode"},create(r){return o({kind:"PartitionByItemNode",partitionBy:r})}});function Wt(r){return re(r).map(gt.create)}var _e=class r{#e;constructor(e){this.#e=o(e)}orderBy(...e){return new r({overNode:Le.cloneWithOrderByItems(this.#e.overNode,L(e))})}clearOrderBy(){return new r({overNode:s.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new r({overNode:Le.cloneWithPartitionByItems(this.#e.overNode,Wt(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}};var so=o([]),er=class{#e;constructor(e=so){this.#e=e}get plugins(){return this.#e}transformQuery(e,t){for(let n of this.#e){let i=n.transformQuery({node:e,queryId:t});if(i.kind===e.kind)e=i;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 ${i.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async t=>{let n=await t.executeQuery(e);return"numUpdatedOrDeletedRows"in n&&le("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`."),await this.#r(n,e.queryId)})}async*stream(e,t){let{connection:n,release:i}=await at(this);try{for await(let m of n.streamQuery(e,t))yield await this.#r(m,e.queryId)}finally{i()}}async#r(e,t){for(let n of this.#e)e=await n.transformResult({result:e,queryId:t});return e}};var Pr=class r extends er{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 r([...this.plugins,e])}withPlugins(e){return new r([...this.plugins,...e])}withPluginAtFront(e){return new r([e,...this.plugins])}withoutPlugins(){return new r([])}},se=new Pr;function St(){return new rr({executor:se})}function bt(r,e){return new Xe({joinNode:Q.create(r,ce(e))})}function kt(){return new _e({overNode:Le.create()})}var Oe=class r{#e;constructor(e){this.#e=o(e)}get expressionType(){}as(e){return new Qr(this,e)}distinct(){return new r({...this.#e,aggregateFunctionNode:K.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new r({...this.#e,aggregateFunctionNode:s.cloneWithOrderByItems(this.#e.aggregateFunctionNode,L(e))})}clearOrderBy(){return new r({...this.#e,aggregateFunctionNode:s.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new r({...this.#e,aggregateFunctionNode:K.cloneWithOrderBy(this.#e.aggregateFunctionNode,L(e),!0)})}filterWhere(...e){return new r({...this.#e,aggregateFunctionNode:K.cloneWithFilter(this.#e.aggregateFunctionNode,h(e))})}filterWhereRef(e,t,n){return new r({...this.#e,aggregateFunctionNode:K.cloneWithFilter(this.#e.aggregateFunctionNode,S(e,t,n))})}over(e){let t=kt();return new r({...this.#e,aggregateFunctionNode:K.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(t):t).toOperationNode())})}$call(e){return e(this)}$castTo(){return new r(this.#e)}$notNull(){return new r(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}},Qr=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return g.create(this.#e.toOperationNode(),u.create(this.#r))}};function Ct(){let r=(t,n)=>new a(qr.create(t,re(n??[]))),e=(t,n)=>new Oe({aggregateFunctionNode:K.create(t,n?re(n):void 0)});return Object.assign(r,{agg:e,avg(t){return e("avg",[t])},coalesce(...t){return r("coalesce",t)},count(t){return e("count",[t])},countAll(t){return new Oe({aggregateFunctionNode:K.create("count",W(t))})},max(t){return e("max",[t])},min(t){return e("min",[t])},sum(t){return e("sum",[t])},any(t){return r("any",[t])},jsonAgg(t){return new Oe({aggregateFunctionNode:K.create("json_agg",[p(t)?N(t):t.toOperationNode()])})},toJson(t){return new a(qr.create("to_json",[p(t)?N(t):t.toOperationNode()]))}})}var Et=o({is(r){return r.kind==="UnaryOperationNode"},create(r,e){return o({kind:"UnaryOperationNode",operator:r,operand:e})}});function Rt(r,e){return Et.create(v.create(r),k(e))}var tr=o({is(r){return r.kind==="PrimitiveValueListNode"},create(r){return o({kind:"PrimitiveValueListNode",values:o([...r])})}});var or=o({is(r){return r.kind==="ValueListNode"},create(r){return o({kind:"ValueListNode",values:o(r)})}});var F=o({is(r){return r.kind==="ValueNode"},create(r){return o({kind:"ValueNode",value:r})},createImmediate(r){return o({kind:"ValueNode",value:r,immediate:!0})}});function At(r){return C(r)?ao(r):c(r)}function c(r){return ee(r)?H(r):F.create(r)}function nr(r){return pe(r)||ze(r)||Ie(r)}function Fe(r){if(!nr(r))throw new Error(`unsafe immediate value ${JSON.stringify(r)}`);return F.createImmediate(r)}function ao(r){return r.some(ee)?or.create(r.map(e=>c(e))):tr.create(r)}var J=o({is(r){return r.kind==="CaseNode"},create(r){return o({kind:"CaseNode",value:r})},cloneWithWhen(r,e){return o({...r,when:o(r.when?[...r.when,e]:[e])})},cloneWithThen(r,e){return o({...r,when:r.when?o([...r.when.slice(0,-1),Z.cloneWithResult(r.when[r.when.length-1],e)]):void 0})},cloneWith(r,e){return o({...r,...e})}});var ir=class{#e;constructor(e){this.#e=o(e)}when(...e){return new sr({...this.#e,node:J.cloneWithWhen(this.#e.node,Z.create(h(e)))})}},sr=class{#e;constructor(e){this.#e=o(e)}then(e){return new vr({...this.#e,node:J.cloneWithThen(this.#e.node,nr(e)?Fe(e):c(e))})}},vr=class{#e;constructor(e){this.#e=o(e)}when(...e){return new sr({...this.#e,node:J.cloneWithWhen(this.#e.node,Z.create(h(e)))})}else(e){return new zr({...this.#e,node:J.cloneWith(this.#e.node,{else:nr(e)?Fe(e):c(e)})})}end(){return new a(J.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(J.cloneWith(this.#e.node,{isStatement:!0}))}},zr=class{#e;constructor(e){this.#e=o(e)}end(){return new a(J.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(J.cloneWith(this.#e.node,{isStatement:!0}))}};var ar=o({is(r){return r.kind==="JSONOperatorChainNode"},create(r){return o({kind:"JSONOperatorChainNode",operator:r,values:o([])})},cloneWithValue(r,e){return o({...r,values:o([...r.values,e])})}});var Ir=o({is(r){return r.kind==="JSONPathLegNode"},create(r,e){return o({kind:"JSONPathLegNode",type:r,value:e})}});var ae=o({is(r){return r.kind==="JSONPathNode"},create(r){return o({kind:"JSONPathNode",inOperator:r,pathLegs:o([])})},cloneWithLeg(r,e){return o({...r,pathLegs:o([...r.pathLegs,e])})}});var xe=o({is(r){return r.kind==="JSONReferenceNode"},create(r,e){return o({kind:"JSONReferenceNode",reference:r,traversal:e})},cloneWithTraversal(r,e){return o({...r,traversal:e})}});var ge=class{#e;constructor(e){this.#e=e}at(e){return this.#r("ArrayLocation",e)}key(e){return this.#r("Member",e)}#r(e,t){return xe.is(this.#e)?new ur(xe.cloneWithTraversal(this.#e,ae.is(this.#e.traversal)?ae.cloneWithLeg(this.#e.traversal,Ir.create(e,t)):ar.cloneWithValue(this.#e.traversal,F.createImmediate(t)))):new ur(ae.cloneWithLeg(this.#e,Ir.create(e,t)))}},ur=class r extends ge{#e;constructor(e){super(e),this.#e=e}get expressionType(){}as(e){return new Ur(this,e)}$castTo(){return new r(this.#e)}$notNull(){return new r(this.#e)}toOperationNode(){return this.#e}},Ur=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return g.create(this.#e.toOperationNode(),f(this.#r)?this.#r.toOperationNode():u.create(this.#r))}};var Vr=o({is(r){return r.kind==="TupleNode"},create(r){return o({kind:"TupleNode",values:o(r)})}});var uo=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],mo=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],Tt=o({is(r){return r.kind==="DataTypeNode"},create(r){return o({kind:"DataTypeNode",dataType:r})}});function Bt(r){return!!(uo.includes(r)||mo.some(e=>e.test(r)))}function qt(r){if(f(r))return r.toOperationNode();if(Bt(r))return Tt.create(r);throw new Error(`invalid column data type ${JSON.stringify(r)}`)}var Lt=o({is(r){return r.kind==="CastNode"},create(r,e){return o({kind:"CastNode",expression:r,dataType:e})}});function mr(r=se){function e(i,m,A){return new a(dr(i,m,A))}function t(i,m){return new a(Rt(i,m))}let n=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(i){return De({queryId:w(),executor:r,queryNode:d.createFrom(z(i))})},case(i){return new ir({node:J.create(M(i)?void 0:k(i))})},ref(i,m){return M(m)?new a(V(i)):new ge(Ft(i,m))},jsonPath(){return new ge(ae.create())},table(i){return new a(N(i))},val(i){return new a(c(i))},refTuple(...i){return new a(Vr.create(i.map(k)))},tuple(...i){return new a(Vr.create(i.map(c)))},lit(i){return new a(Fe(i))},unary:t,not(i){return t("not",i)},exists(i){return t("exists",i)},neg(i){return t("-",i)},between(i,m,A){return new a(oe.create(k(i),v.create("between"),T.create(c(m),c(A))))},betweenSymmetric(i,m,A){return new a(oe.create(k(i),v.create("between symmetric"),T.create(c(m),c(A))))},and(i){return C(i)?new a(We(i,"and")):new a(Jr(i,"and"))},or(i){return C(i)?new a(We(i,"or")):new a(Jr(i,"or"))},parens(...i){let m=h(i);return ie.is(m)?new a(m):new a(ie.create(m))},cast(i,m){return new a(Lt.create(k(i),qt(m)))},withSchema(i){return mr(r.withPluginAtFront(new Ne(i)))}});return n.fn=Ct(),n.eb=n,n}function I(r){return mr()}function H(r){if(f(r))return r.toOperationNode();if(x(r))return r(I()).toOperationNode();throw new Error(`invalid expression: ${JSON.stringify(r)}`)}function He(r){if(f(r))return r.toOperationNode();if(x(r))return r(I()).toOperationNode();throw new Error(`invalid aliased expression: ${JSON.stringify(r)}`)}function ee(r){return Ke(r)||mt(r)||x(r)}function Lr(r){return p(r)?V(r):r.toOperationNode()}function re(r){return C(r)?r.map(e=>k(e)):[k(r)]}function k(r){return ee(r)?H(r):Lr(r)}function Ft(r,e){let t=V(r);if(Sr(e))return xe.create(t,ar.create(v.create(e)));let n=e.slice(0,-1);if(Sr(n))return xe.create(t,ae.create(v.create(n)));throw new Error(`Invalid JSON operator: ${e}`)}function V(r){if(!r.includes("."))return ye.create(E.create(r));let t=r.split(".").map($r);if(t.length===3)return ho(t);if(t.length===2)return fo(t);throw new Error(`invalid column reference ${r}`)}function wt(r){let e=" as ";if(r.includes(e)){let[t,n]=r.split(e).map($r);return g.create(V(t),u.create(n))}else return V(r)}function co(r){return E.create(r)}function Ud(r){if(r.includes(" ")){let[t,n]=r.split(" ").map($r);if(!Mr(n))throw new Error(`invalid order direction "${n}" next to "${t}"`);return L([t,n])[0]}else return co(r)}function ho(r){let[e,t,n]=r;return ye.create(E.create(n),B.createWithSchema(e,t))}function fo(r){let[e,t]=r;return ye.create(E.create(t),B.create(e))}function $r(r){return r.trim()}function h(r){if(r.length===3)return dr(r[0],r[1],r[2]);if(r.length===1)return c(r[0]);throw new Error(`invalid arguments: ${JSON.stringify(r)}`)}function dr(r,e,t){return po(e)&&Mt(t)?oe.create(k(r),Gr(e),F.createImmediate(t)):oe.create(k(r),Gr(e),At(t))}function S(r,e,t){return oe.create(k(r),Gr(e),k(t))}function Jr(r,e){return We(Object.entries(r).filter(([,t])=>!M(t)).map(([t,n])=>dr(t,Mt(n)?"is":"=",n)),e)}function We(r,e,t=!0){let n=e==="and"?T.create:P.create;if(r.length===0)return oe.create(F.createImmediate(1),v.create("="),F.createImmediate(e==="and"?1:0));let i=Dt(r[0]);for(let m=1;m<r.length;++m)i=n(i,Dt(r[m]));return r.length>1&&t?ie.create(i):i}function po(r){return r==="is"||r==="is not"}function Mt(r){return Ie(r)||ze(r)}function Gr(r){if(p(r)&&dt.includes(r))return v.create(r);if(f(r))return r.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(r)}`)}function Dt(r){return f(r)?r.toOperationNode():r}function ue(r,e){if(e.length===3)return No(r,e[0],e[1],e[2]);if(e.length===2)return lo(r,e[0],e[1]);if(e.length===1)return yo(r,e[0]);throw new Error("not implemented")}function lo(r,e,t){return t(bt(r,e)).toOperationNode()}function No(r,e,t,n){return Q.createWithOn(r,ce(e),S(t,"=",n))}function yo(r,e){return Q.create(r,ce(e))}var Se=o({is(r){return r.kind==="LimitNode"},create(r){return o({kind:"LimitNode",limit:r})}});var Pt=o({is(r){return r.kind==="OffsetNode"},create(r){return o({kind:"OffsetNode",offset:r})}});var Qt=o({is(r){return r.kind==="GroupByItemNode"},create(r){return o({kind:"GroupByItemNode",groupBy:r})}});function vt(r){return r=x(r)?r(I()):r,re(r).map(Qt.create)}var D=class extends Error{node;constructor(e){super("no result"),this.node=e}};function Y(r){return Object.prototype.hasOwnProperty.call(r,"prototype")}var zt=o({is(r){return r.kind==="SetOperationNode"},create(r,e,t){return o({kind:"SetOperationNode",operator:r,expression:e,all:t})}});function he(r,e,t){return x(e)&&(e=e(mr())),C(e)||(e=[e]),e.map(n=>zt.create(r,H(n),t))}var It=o({is(r){return r.kind==="FetchNode"},create(r,e){return{kind:"FetchNode",rowCount:F.create(r),modifier:e}}});function Ut(r,e){if(!pe(r)&&!Ue(r))throw new Error(`Invalid fetch row count: ${r}`);if(!wo(e))throw new Error(`Invalid fetch modifier: ${e}`);return It.create(r,e)}function wo(r){return r==="only"||r==="with ties"}var Vt=o({is(r){return r.kind==="TopNode"},create(r,e){return o({kind:"TopNode",expression:r,modifiers:e})}});function $(r,e){if(!pe(r)&&!Ue(r))throw new Error(`Invalid top expression: ${r}`);if(!M(e)&&!Oo(e))throw new Error(`Invalid top modifiers: ${e}`);return Vt.create(r,e)}function Oo(r){return r==="percent"||r==="with ties"||r==="percent with ties"}var jr=class r{#e;constructor(e){this.#e=o(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,S(e,t,n))})}having(...e){return new r({...this.#e,queryNode:d.cloneWithHaving(this.#e.queryNode,h(e))})}havingRef(e,t,n){return new r({...this.#e,queryNode:d.cloneWithHaving(this.#e.queryNode,S(e,t,n))})}select(e){return new r({...this.#e,queryNode:d.cloneWithSelections(this.#e.queryNode,O(e))})}distinctOn(e){return new r({...this.#e,queryNode:d.cloneWithDistinctOn(this.#e.queryNode,re(e))})}modifyFront(e){return new r({...this.#e,queryNode:d.cloneWithFrontModifier(this.#e.queryNode,G.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.createWithExpression(e.toOperationNode()))})}distinct(){return new r({...this.#e,queryNode:d.cloneWithFrontModifier(this.#e.queryNode,G.create("Distinct"))})}forUpdate(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("ForUpdate",e?Re(e).map(N):void 0))})}forShare(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("ForShare",e?Re(e).map(N):void 0))})}forKeyShare(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("ForKeyShare",e?Re(e).map(N):void 0))})}forNoKeyUpdate(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("ForNoKeyUpdate",e?Re(e).map(N):void 0))})}skipLocked(){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("SkipLocked"))})}noWait(){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("NoWait"))})}selectAll(e){return new r({...this.#e,queryNode:d.cloneWithSelections(this.#e.queryNode,W(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}crossJoin(...e){return this.#r("CrossJoin",e)}innerJoinLateral(...e){return this.#r("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#r("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#r("LateralCrossJoin",e)}crossApply(...e){return this.#r("CrossApply",e)}outerApply(...e){return this.#r("OuterApply",e)}#r(e,t){return new r({...this.#e,queryNode:s.cloneWithJoin(this.#e.queryNode,ue(e,t))})}orderBy(...e){return new r({...this.#e,queryNode:s.cloneWithOrderByItems(this.#e.queryNode,L(e))})}groupBy(e){return new r({...this.#e,queryNode:d.cloneWithGroupByItems(this.#e.queryNode,vt(e))})}limit(e){return new r({...this.#e,queryNode:d.cloneWithLimit(this.#e.queryNode,Se.create(c(e)))})}offset(e){return new r({...this.#e,queryNode:d.cloneWithOffset(this.#e.queryNode,Pt.create(c(e)))})}fetch(e,t="only"){return new r({...this.#e,queryNode:d.cloneWithFetch(this.#e.queryNode,Ut(e,t))})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}union(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("union",e,!1))})}unionAll(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("union",e,!0))})}intersect(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("intersect",e,!1))})}intersectAll(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("intersect",e,!0))})}except(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("except",e,!1))})}exceptAll(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("except",e,!0))})}as(e){return new Kr(this,e)}clearSelect(){return new r({...this.#e,queryNode:d.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new r({...this.#e,queryNode:s.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new r({...this.#e,queryNode:d.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new r({...this.#e,queryNode:d.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new r({...this.#e,queryNode:s.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new r({...this.#e,queryNode:d.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}$asTuple(){return new a(this.toOperationNode())}$asScalar(){return new a(this.toOperationNode())}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile();return(await this.#e.executor.executeQuery(e)).rows}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e);for await(let i of n)yield*i.rows}async explain(e,t){return await new r({...this.#e,queryNode:s.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};function De(r){return new jr(r)}var Kr=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return g.create(this.#e.toOperationNode(),u.create(this.#r))}};var Jt=o({is(r){return r.kind==="ValuesNode"},create(r){return o({kind:"ValuesNode",values:o(r)})}});var $t=o({is(r){return r.kind==="DefaultInsertValueNode"},create(){return o({kind:"DefaultInsertValueNode"})}});function cr(r){let e=x(r)?r(I()):r,t=C(e)?e:o([e]);return xo(t)}function xo(r){let e=go(r);return[o([...e.keys()].map(E.create)),Jt.create(r.map(t=>Wo(t,e)))]}function go(r){let e=new Map;for(let t of r){let n=Object.keys(t);for(let i of n)!e.has(i)&&t[i]!==void 0&&e.set(i,e.size)}return e}function Wo(r,e){let t=Object.keys(r),n=Array.from({length:e.size}),i=!1,m=t.length;for(let ve of t){let Ee=e.get(ve);if(M(Ee)){m--;continue}let gr=r[ve];(M(gr)||ee(gr))&&(i=!0),n[Ee]=gr}if(m<e.size||i){let ve=$t.create();return or.create(n.map(Ee=>M(Ee)?ve:c(Ee)))}return tr.create(n)}var Hr=o({is(r){return r.kind==="ColumnUpdateNode"},create(r,e){return o({kind:"ColumnUpdateNode",column:r,value:e})}});function Gt(...r){return r.length===2?[Hr.create(k(r[0]),c(r[1]))]:Me(r[0])}function Me(r){let e=x(r)?r(I()):r;return Object.entries(e).filter(([t,n])=>n!==void 0).map(([t,n])=>Hr.create(E.create(t),c(n)))}var jt=o({is(r){return r.kind==="OnDuplicateKeyNode"},create(r){return o({kind:"OnDuplicateKeyNode",updates:r})}});var hr=class{insertId;numInsertedOrUpdatedRows;constructor(e,t){this.insertId=e,this.numInsertedOrUpdatedRows=t}};var R=o({is(r){return r.kind==="OnConflictNode"},create(){return o({kind:"OnConflictNode"})},cloneWith(r,e){return o({...r,...e})},cloneWithIndexWhere(r,e){return o({...r,indexWhere:r.indexWhere?b.cloneWithOperation(r.indexWhere,"And",e):b.create(e)})},cloneWithIndexOrWhere(r,e){return o({...r,indexWhere:r.indexWhere?b.cloneWithOperation(r.indexWhere,"Or",e):b.create(e)})},cloneWithUpdateWhere(r,e){return o({...r,updateWhere:r.updateWhere?b.cloneWithOperation(r.updateWhere,"And",e):b.create(e)})},cloneWithUpdateOrWhere(r,e){return o({...r,updateWhere:r.updateWhere?b.cloneWithOperation(r.updateWhere,"Or",e):b.create(e)})},cloneWithoutIndexWhere(r){return o({...r,indexWhere:void 0})},cloneWithoutUpdateWhere(r){return o({...r,updateWhere:void 0})}});var fr=class r{#e;constructor(e){this.#e=o(e)}column(e){let t=E.create(e);return new r({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?o([...this.#e.onConflictNode.columns,t]):o([t])})})}columns(e){let t=e.map(E.create);return new r({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?o([...this.#e.onConflictNode.columns,...t]):o(t)})})}constraint(e){return new r({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{constraint:u.create(e)})})}expression(e){return new r({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new r({...this.#e,onConflictNode:R.cloneWithIndexWhere(this.#e.onConflictNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,onConflictNode:R.cloneWithIndexWhere(this.#e.onConflictNode,S(e,t,n))})}clearWhere(){return new r({...this.#e,onConflictNode:R.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new Yr({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Xr({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{updates:Me(e)})})}$call(e){return e(this)}},Yr=class{#e;constructor(e){this.#e=o(e)}toOperationNode(){return this.#e.onConflictNode}},Xr=class r{#e;constructor(e){this.#e=o(e)}where(...e){return new r({...this.#e,onConflictNode:R.cloneWithUpdateWhere(this.#e.onConflictNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,onConflictNode:R.cloneWithUpdateWhere(this.#e.onConflictNode,S(e,t,n))})}clearWhere(){return new r({...this.#e,onConflictNode:R.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}};var fe=o({is(r){return r.kind==="OrActionNode"},create(r){return o({kind:"OrActionNode",action:r})}});var Pe=class r{#e;constructor(e){this.#e=o(e)}values(e){let[t,n]=cr(e);return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{columns:t,values:n})})}columns(e){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{columns:o(e.map(E.create))})})}expression(e){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{values:H(e)})})}defaultValues(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("ignore")})})}orIgnore(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("ignore")})})}orAbort(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("abort")})})}orFail(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("fail")})})}orReplace(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("replace")})})}orRollback(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("rollback")})})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}onConflict(e){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{onConflict:e(new fr({onConflictNode:R.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{onDuplicateKey:jt.create(Me(e))})})}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W())})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}clearReturning(){return new r({...this.#e,queryNode:s.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:n}=this.#e.executor,i=e.query;return i.returning&&n.supportsReturning||i.output&&n.supportsOutput?t.rows:[new hr(t.insertId,t.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e);for await(let i of n)yield*i.rows}async explain(e,t){return await new r({...this.#e,queryNode:s.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};var pr=class{numDeletedRows;constructor(e){this.numDeletedRows=e}};var lr=class r{#e;constructor(e){this.#e=o(e)}where(...e){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,S(e,t,n))})}clearWhere(){return new r({...this.#e,queryNode:s.cloneWithoutWhere(this.#e.queryNode)})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}using(e){return new r({...this.#e,queryNode:ne.cloneWithUsing(this.#e.queryNode,z(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}#r(e,t){return new r({...this.#e,queryNode:s.cloneWithJoin(this.#e.queryNode,ue(e,t))})}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W(e))})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}clearReturning(){return new r({...this.#e,queryNode:s.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new r({...this.#e,queryNode:ne.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new r({...this.#e,queryNode:s.cloneWithOrderByItems(this.#e.queryNode,L(e))})}clearOrderBy(){return new r({...this.#e,queryNode:s.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new r({...this.#e,queryNode:ne.cloneWithLimit(this.#e.queryNode,Se.create(c(e)))})}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:n}=this.#e.executor,i=e.query;return i.returning&&n.supportsReturning||i.output&&n.supportsOutput?t.rows:[new pr(t.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e);for await(let i of n)yield*i.rows}async explain(e,t){return await new r({...this.#e,queryNode:s.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};var Nr=class{numUpdatedRows;numChangedRows;constructor(e,t){this.numUpdatedRows=e,this.numChangedRows=t}};var be=class r{#e;constructor(e){this.#e=o(e)}where(...e){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,S(e,t,n))})}clearWhere(){return new r({...this.#e,queryNode:s.cloneWithoutWhere(this.#e.queryNode)})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}from(e){return new r({...this.#e,queryNode:j.cloneWithFromItems(this.#e.queryNode,z(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}#r(e,t){return new r({...this.#e,queryNode:s.cloneWithJoin(this.#e.queryNode,ue(e,t))})}orderBy(...e){return new r({...this.#e,queryNode:s.cloneWithOrderByItems(this.#e.queryNode,L(e))})}clearOrderBy(){return new r({...this.#e,queryNode:s.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new r({...this.#e,queryNode:j.cloneWithLimit(this.#e.queryNode,Se.create(c(e)))})}set(...e){return new r({...this.#e,queryNode:j.cloneWithUpdates(this.#e.queryNode,Gt(...e))})}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W(e))})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new r({...this.#e,queryNode:s.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:n}=this.#e.executor,i=e.query;return i.returning&&n.supportsReturning||i.output&&n.supportsOutput?t.rows:[new Nr(t.numAffectedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e);for await(let i of n)yield*i.rows}async explain(e,t){return await new r({...this.#e,queryNode:s.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};var Zr=o({is(r){return r.kind==="CommonTableExpressionNameNode"},create(r,e){return o({kind:"CommonTableExpressionNameNode",table:B.create(r),columns:e?o(e.map(E.create)):void 0})}});var ke=o({is(r){return r.kind==="CommonTableExpressionNode"},create(r,e){return o({kind:"CommonTableExpressionNode",name:r,expression:e})},cloneWith(r,e){return o({...r,...e})}});var yr=class r{#e;constructor(e){this.#e=o(e)}materialized(){return new r({...this.#e,node:ke.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new r({...this.#e,node:ke.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}};function _r(r,e){let t=e(St()).toOperationNode();return x(r)?r(So(t)).toOperationNode():ke.create(Kt(r),t)}function So(r){return e=>new yr({node:ke.create(Kt(e),r)})}function Kt(r){if(r.includes("(")){let e=r.split(/[\(\)]/),t=e[0],n=e[1].split(",").map(i=>i.trim());return Zr.create(t,n)}else return Zr.create(r)}var Qe=o({is(r){return r.kind==="WithNode"},create(r,e){return o({kind:"WithNode",expressions:o([r]),...e})},cloneWithExpression(r,e){return o({...r,expressions:o([...r.expressions,e])})}});var Ht=o({is(r){return r.kind==="MatchedNode"},create(r,e=!1){return o({kind:"MatchedNode",not:r,bySource:e})}});function et(r,e,t){return Z.create(We([Ht.create(!r.isMatched,r.bySource),...e&&e.length>0?[e.length===3&&t?S(e[0],e[1],e[2]):h(e)]:[]],"and",!1))}function Ce(r){return p(r)?y.create([r],[]):f(r)?r.toOperationNode():r}var wr=class{numChangedRows;constructor(e){this.numChangedRows=e}};var Or=class r{#e;constructor(e){this.#e=o(e)}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}using(...e){return new de({...this.#e,queryNode:q.cloneWithUsing(this.#e.queryNode,ue("Using",e))})}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W(e))})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}},de=class r{#e;constructor(e){this.#e=o(e)}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}whenMatched(){return this.#r([])}whenMatchedAnd(...e){return this.#r(e)}whenMatchedAndRef(e,t,n){return this.#r([e,t,n],!0)}#r(e,t){return new xr({...this.#e,queryNode:q.cloneWithWhen(this.#e.queryNode,et({isMatched:!0},e,t))})}whenNotMatched(){return this.#t([])}whenNotMatchedAnd(...e){return this.#t(e)}whenNotMatchedAndRef(e,t,n){return this.#t([e,t,n],!0)}whenNotMatchedBySource(){return this.#t([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#t(e,!1,!0)}whenNotMatchedBySourceAndRef(e,t,n){return this.#t([e,t,n],!0,!0)}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W(e))})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}#t(e,t=!1,n=!1){let i={...this.#e,queryNode:q.cloneWithWhen(this.#e.queryNode,et({isMatched:!1,bySource:n},e,t))},m=n?xr:rt;return new m(i)}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:n}=this.#e.executor,i=e.query;return i.returning&&n.supportsReturning||i.output&&n.supportsOutput?t.rows:[new wr(t.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}},xr=class{#e;constructor(e){this.#e=o(e)}thenDelete(){return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce("delete"))})}thenDoNothing(){return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce("do nothing"))})}thenUpdate(e){return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce(e(new be({queryId:this.#e.queryId,executor:se,queryNode:j.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(t=>t.set(...e))}},rt=class{#e;constructor(e){this.#e=o(e)}thenDoNothing(){return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce("do nothing"))})}thenInsertValues(e){let[t,n]=cr(e);return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce(l.cloneWith(l.createWithoutInto(),{columns:t,values:n})))})}};var rr=class r{#e;constructor(e){this.#e=o(e)}selectFrom(e){return De({queryId:w(),executor:this.#e.executor,queryNode:d.createFrom(z(e),this.#e.withNode)})}selectNoFrom(e){return De({queryId:w(),executor:this.#e.executor,queryNode:d.cloneWithSelections(d.create(this.#e.withNode),O(e))})}insertInto(e){return new Pe({queryId:w(),executor:this.#e.executor,queryNode:l.create(N(e),this.#e.withNode)})}replaceInto(e){return new Pe({queryId:w(),executor:this.#e.executor,queryNode:l.create(N(e),this.#e.withNode,!0)})}deleteFrom(e){return new lr({queryId:w(),executor:this.#e.executor,queryNode:ne.create(z(e),this.#e.withNode)})}updateTable(e){return new be({queryId:w(),executor:this.#e.executor,queryNode:j.create(z(e),this.#e.withNode)})}mergeInto(e){return new Or({queryId:w(),executor:this.#e.executor,queryNode:q.create(Ar(e),this.#e.withNode)})}with(e,t){let n=_r(e,t);return new r({...this.#e,withNode:this.#e.withNode?Qe.cloneWithExpression(this.#e.withNode,n):Qe.create(n)})}withRecursive(e,t){let n=_r(e,t);return new r({...this.#e,withNode:this.#e.withNode?Qe.cloneWithExpression(this.#e.withNode,n):Qe.create(n,{recursive:!0})})}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new r({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new r({...this.#e,executor:this.#e.executor.withPluginAtFront(new Ne(e))})}};var tt=class r{#e;constructor(e){this.#e=o(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new ot(this,e)}$castTo(){return new r({...this.#e})}$notNull(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,plugins:this.#e.plugins!==void 0?o([...this.#e.plugins,e]):o([e])})}toOperationNode(){return this.#t(this.#r())}compile(e){return this.#n(this.#r(e))}async execute(e){let t=this.#r(e);return t.executeQuery(this.#n(t))}#r(e){let t=e!==void 0?e.getExecutor():se;return this.#e.plugins!==void 0?t.withPlugins(this.#e.plugins):t}#t(e){return e.transformQuery(this.#e.rawNode,this.#e.queryId)}#n(e){return e.compileQuery(this.#t(e),this.#e.queryId)}};function te(r){return new tt(r)}var ot=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}get rawBuilder(){return this.#e}toOperationNode(){return g.create(this.#e.toOperationNode(),f(this.#r)?this.#r.toOperationNode():u.create(this.#r))}};var bo=Object.assign((r,...e)=>te({queryId:w(),rawNode:y.create(r,e?.map(Yt)??[])}),{ref(r){return te({queryId:w(),rawNode:y.createWithChild(V(r))})},val(r){return te({queryId:w(),rawNode:y.createWithChild(c(r))})},value(r){return this.val(r)},table(r){return te({queryId:w(),rawNode:y.createWithChild(N(r))})},id(...r){let e=new Array(r.length+1).fill(".");return e[0]="",e[e.length-1]="",te({queryId:w(),rawNode:y.create(e,r.map(u.create))})},lit(r){return te({queryId:w(),rawNode:y.createWithChild(F.createImmediate(r))})},literal(r){return this.lit(r)},raw(r){return te({queryId:w(),rawNode:y.createWithSql(r)})},join(r,e=bo`, `){let t=new Array(Math.max(2*r.length-1,0)),n=e.toOperationNode();for(let i=0;i<r.length;++i)t[2*i]=Yt(r[i]),i!==r.length-1&&(t[2*i+1]=n);return te({queryId:w(),rawNode:y.createWithChildren(t)})}});function Yt(r){return f(r)?r.toOperationNode():c(r)}export{M as a,p as b,pe as c,ze as d,Ie as e,ko as f,Ue as g,Co as h,x as i,X as j,o as k,Eo as l,u as m,Ae as n,f as o,v as p,E as q,je as r,lt as s,y as t,le as u,V as v,co as w,Ud as x,or as y,F as z,ie as A,h as B,l as C,Z as D,s as E,d as F,st as G,w as H,$e as I,Ne as J,Be as K,at as L,er as M,rr as N,zt as O,Ct as P,J as Q,ir as R,qt as S,H as T,ht as U,N as V,bo as W};
|