@gjermundgaraba/clankerauth-dev 0.26.2 → 0.26.3

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.
@@ -5,8 +5,8 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <meta name="color-scheme" content="light" />
7
7
  <title>clankerauth</title>
8
- <script type="module" crossorigin src="/assets/index-kuPpbPut.js"></script>
9
- <link rel="stylesheet" crossorigin href="/assets/index-sZpVl70Z.css">
8
+ <script type="module" crossorigin src="/assets/index-wQZ9O_DU.js"></script>
9
+ <link rel="stylesheet" crossorigin href="/assets/index-Bj2lPl11.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjermundgaraba/clankerauth-dev",
3
- "version": "0.26.2",
3
+ "version": "0.26.3",
4
4
  "description": "Disposable local clankerauth issuer for application development",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,13 +27,13 @@
27
27
  "access": "public"
28
28
  },
29
29
  "devDependencies": {
30
- "@clankerauth/server": "0.26.2",
30
+ "@clankerauth/server": "0.26.3",
31
31
  "@clankerauth/web": "0.1.0",
32
32
  "@effect/platform-node": "4.0.5",
33
- "@gjermundgaraba/clankerauth-admin-api": "0.26.2",
33
+ "@gjermundgaraba/clankerauth-admin-api": "0.26.3",
34
34
  "@opentelemetry/api": "1.9.1",
35
35
  "effect": "4.0.5",
36
- "jose": "6.2.12",
36
+ "jose": "6.2.13",
37
37
  "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
38
38
  "vite-plus": "1.3.0"
39
39
  },
@@ -1,17 +0,0 @@
1
- import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as ee,S as v,T as y,U as b,V as te,W as x,X as ne,Y as re,Z as ie,_ as ae,b as S,c as C,d as oe,et as se,f as w,g as ce,h as le,i as ue,it as T,j as de,k as fe,l as E,m as pe,nt as D,p as O,q as k,rt as me,s as he,tt as A,u as j,v as ge,w as _e,x as ve,y as ye,z as be}from"./sqlite-introspector-DSCAP82F-CISODKY3.mjs";import{t as M}from"./compiled-query-C8AL3JwF.mjs";import{n as xe,r as Se,t as Ce}from"./sqlite-adapter-CS5jtB3L.mjs";import{A as we}from"./get-id-field-CHlYHt3y.mjs";import{N as Te}from"./schemas-CYWNDEcx.mjs";import{c as Ee,i as De,n as Oe,t as ke,u as Ae}from"./schema-check-6AE7KkNs.mjs";import{t as je}from"./factory-tEOeUNZI.mjs";const N=k({is(e){return e.kind===`AlterTableNode`},create(e){return k({kind:`AlterTableNode`,table:e})},cloneWithTableProps(e,t){return k({...e,...t})},cloneWithColumnAlteration(e,t){return k({...e,columnAlterations:e.columnAlterations?[...e.columnAlterations,t]:[t]})}}),P=k({is(e){return e.kind===`CreateIndexNode`},create(e){return k({kind:`CreateIndexNode`,name:d.create(e)})},cloneWith(e,t){return k({...e,...t})},cloneWithColumns(e,t){return k({...e,columns:[...e.columns||[],...t]})}}),Me=k({is(e){return e.kind===`CreateSchemaNode`},create(e,t){return k({kind:`CreateSchemaNode`,schema:d.create(e),...t})},cloneWith(e,t){return k({...e,...t})}}),F=k({is(e){return e.kind===`DropIndexNode`},create(e,t){return k({kind:`DropIndexNode`,name:b.create(e),...t})},cloneWith(e,t){return k({...e,...t})}}),Ne=k({is(e){return e.kind===`DropSchemaNode`},create(e,t){return k({kind:`DropSchemaNode`,schema:d.create(e),...t})},cloneWith(e,t){return k({...e,...t})}}),Pe=k({is(e){return e.kind===`DropTableNode`},create(e,t){return k({kind:`DropTableNode`,table:e,...t})},cloneWith(e,t){return k({...e,...t})}}),Fe=k({is(e){return e.kind===`AddColumnNode`},create(e){return k({kind:`AddColumnNode`,column:e})}}),I=k({is(e){return e.kind===`ColumnDefinitionNode`},create(e,t){return k({kind:`ColumnDefinitionNode`,column:n.create(e),dataType:t})},cloneWithFrontModifier(e,t){return k({...e,frontModifiers:e.frontModifiers?k([...e.frontModifiers,t]):[t]})},cloneWithEndModifier(e,t){return k({...e,endModifiers:e.endModifiers?k([...e.endModifiers,t]):[t]})},cloneWith(e,t){return k({...e,...t})}}),Ie=k({is(e){return e.kind===`DropColumnNode`},create(e){return k({kind:`DropColumnNode`,column:n.create(e)})},cloneWith(e,t){return k({...e,...t})}}),Le=k({is(e){return e.kind===`RenameColumnNode`},create(e,t){return k({kind:`RenameColumnNode`,column:n.create(e),renameTo:n.create(t)})}}),Re=k({is(e){return e.kind===`CheckConstraintNode`},create(e,t){return k({kind:`CheckConstraintNode`,expression:e,name:t?d.create(t):void 0})}}),ze=k({cascade:!0,"no action":!0,restrict:!0,"set default":!0,"set null":!0});Object.keys(ze);const Be=k({is(e){return e.kind===`ReferencesNode`},create(e,t){return k({kind:`ReferencesNode`,table:e,columns:k([...t])})},cloneWithOnDelete(e,t){return k({...e,onDelete:t})},cloneWithOnUpdate(e,t){return k({...e,onUpdate:t})}});function Ve(e){return D(e)&&ze[e]}function He(e){return te(e)?e.toOperationNode():t.createImmediate(e)}const Ue=k({is(e){return e.kind===`GeneratedNode`},create(e){return k({kind:`GeneratedNode`,...e})},createWithExpression(e){return k({kind:`GeneratedNode`,always:!0,expression:e})},cloneWith(e,t){return k({...e,...t})}}),We=k({is(e){return e.kind===`DefaultValueNode`},create(e){return k({kind:`DefaultValueNode`,defaultValue:e})}});function L(e){if(Ve(e))return e;throw Error(`invalid OnModifyForeignAction ${e}`)}var R=class e{#e;constructor(e){this.#e=e}autoIncrement(){return new e(I.cloneWith(this.#e,{autoIncrement:!0}))}identity(){return new e(I.cloneWith(this.#e,{identity:!0}))}primaryKey(){return new e(I.cloneWith(this.#e,{primaryKey:!0}))}references(t){let n=g(t);if(!n.table||be.is(n.column))throw Error(`invalid call references('${t}'). The reference must have format table.column or schema.table.column`);return new e(I.cloneWith(this.#e,{references:Be.create(n.table,[n.column])}))}onDelete(t){if(!this.#e.references)throw Error(`on delete constraint can only be added for foreign keys`);return new e(I.cloneWith(this.#e,{references:Be.cloneWithOnDelete(this.#e.references,L(t))}))}onUpdate(t){if(!this.#e.references)throw Error(`on update constraint can only be added for foreign keys`);return new e(I.cloneWith(this.#e,{references:Be.cloneWithOnUpdate(this.#e.references,L(t))}))}unique(){return new e(I.cloneWith(this.#e,{unique:!0}))}notNull(){return new e(I.cloneWith(this.#e,{notNull:!0}))}unsigned(){return new e(I.cloneWith(this.#e,{unsigned:!0}))}defaultTo(t){return new e(I.cloneWith(this.#e,{defaultTo:We.create(He(t))}))}check(t){return new e(I.cloneWith(this.#e,{check:Re.create(t.toOperationNode())}))}generatedAlwaysAs(t){return new e(I.cloneWith(this.#e,{generated:Ue.createWithExpression(t.toOperationNode())}))}generatedAlwaysAsIdentity(){return new e(I.cloneWith(this.#e,{generated:Ue.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new e(I.cloneWith(this.#e,{generated:Ue.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#e.generated)throw Error(`stored() can only be called after generatedAlwaysAs`);return new e(I.cloneWith(this.#e,{generated:Ue.cloneWith(this.#e.generated,{stored:!0})}))}modifyFront(t){return new e(I.cloneWithFrontModifier(this.#e,t.toOperationNode()))}nullsNotDistinct(){return new e(I.cloneWith(this.#e,{nullsNotDistinct:!0}))}ifNotExists(){return new e(I.cloneWith(this.#e,{ifNotExists:!0}))}modifyEnd(t){return new e(I.cloneWithEndModifier(this.#e,t.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#e}};const Ge=k({is(e){return e.kind===`ModifyColumnNode`},create(e){return k({kind:`ModifyColumnNode`,column:e})}}),z=k({is(e){return e.kind===`ForeignKeyConstraintNode`},create(e,t,n,r){return k({kind:`ForeignKeyConstraintNode`,columns:e,references:Be.create(t,n),name:r?d.create(r):void 0})},cloneWith(e,t){return k({...e,...t})}});var Ke=class e{#e;constructor(e){this.#e=e}onDelete(t){return new e(z.cloneWith(this.#e,{onDelete:L(t)}))}onUpdate(t){return new e(z.cloneWith(this.#e,{onUpdate:L(t)}))}deferrable(){return new e(z.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new e(z.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new e(z.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new e(z.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}};const qe=k({is(e){return e.kind===`AddConstraintNode`},create(e){return k({kind:`AddConstraintNode`,constraint:e})}}),B=k({is(e){return e.kind===`UniqueConstraintNode`},create(e,t,r){return D(e.at(0))&&(o("`UniqueConstraintNode.create(columns: string[], ...)` is deprecated - pass `ColumnNode[]` instead."),e=e.map(n.create)),k({kind:`UniqueConstraintNode`,columns:k(e),name:t?d.create(t):void 0,nullsNotDistinct:r})},cloneWith(e,t){return k({...e,...t})}}),Je=k({is(e){return e.kind===`DropConstraintNode`},create(e){return k({kind:`DropConstraintNode`,constraintName:d.create(e)})},cloneWith(e,t){return k({...e,...t})}}),V=k({is(e){return e.kind===`AlterColumnNode`},create(e,t,r){return k({kind:`AlterColumnNode`,column:n.create(e),[t]:r})}});var Ye=class{#e;constructor(e){this.#e=e}setDataType(e){return new H(V.create(this.#e,`dataType`,O(e)))}setDefault(e){return new H(V.create(this.#e,`setDefault`,He(e)))}dropDefault(){return new H(V.create(this.#e,`dropDefault`,!0))}setNotNull(){return new H(V.create(this.#e,`setNotNull`,!0))}dropNotNull(){return new H(V.create(this.#e,`dropNotNull`,!0))}$call(e){return e(this)}},H=class{#e;constructor(e){this.#e=e}toOperationNode(){return this.#e}},U=class{#e;constructor(e){this.#e=k(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(e){await this.#e.executor.executeQuery(this.compile(),e)}},Xe=class e{#e;constructor(e){this.#e=k(e)}onDelete(t){return new e({...this.#e,constraintBuilder:this.#e.constraintBuilder.onDelete(t)})}onUpdate(t){return new e({...this.#e,constraintBuilder:this.#e.constraintBuilder.onUpdate(t)})}deferrable(){return new e({...this.#e,constraintBuilder:this.#e.constraintBuilder.deferrable()})}notDeferrable(){return new e({...this.#e,constraintBuilder:this.#e.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new e({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new e({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyImmediate()})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(N.cloneWithTableProps(this.#e.node,{addConstraint:qe.create(this.#e.constraintBuilder.toOperationNode())}),this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(e){await this.#e.executor.executeQuery(this.compile(),e)}},Ze=class e{#e;constructor(e){this.#e=k(e)}ifExists(){return new e({...this.#e,node:N.cloneWithTableProps(this.#e.node,{dropConstraint:Je.cloneWith(this.#e.node.dropConstraint,{ifExists:!0})})})}cascade(){return new e({...this.#e,node:N.cloneWithTableProps(this.#e.node,{dropConstraint:Je.cloneWith(this.#e.node.dropConstraint,{modifier:`cascade`})})})}restrict(){return new e({...this.#e,node:N.cloneWithTableProps(this.#e.node,{dropConstraint:Je.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(e){await this.#e.executor.executeQuery(this.compile(),e)}};const W=k({is(e){return e.kind===`PrimaryKeyConstraintNode`},create(e,t){return k({kind:`PrimaryKeyConstraintNode`,columns:k(e.map(n.create)),name:t?d.create(t):void 0})},cloneWith(e,t){return k({...e,...t})}}),G=k({is(e){return e.kind===`AddIndexNode`},create(e){return k({kind:`AddIndexNode`,name:d.create(e)})},cloneWith(e,t){return k({...e,...t})},cloneWithColumns(e,t){return k({...e,columns:[...e.columns||[],...t]})}});var Qe=class e{#e;constructor(e){this.#e=k(e)}unique(){return new e({...this.#e,node:N.cloneWithTableProps(this.#e.node,{addIndex:G.cloneWith(this.#e.node.addIndex,{unique:!0})})})}column(t){return new e({...this.#e,node:N.cloneWithTableProps(this.#e.node,{addIndex:G.cloneWithColumns(this.#e.node.addIndex,[D(t)?m(t):t.toOperationNode()])})})}columns(t){return new e({...this.#e,node:N.cloneWithTableProps(this.#e.node,{addIndex:G.cloneWithColumns(this.#e.node.addIndex,t.map(e=>D(e)?m(e):e.toOperationNode()))})})}expression(t){return new e({...this.#e,node:N.cloneWithTableProps(this.#e.node,{addIndex:G.cloneWithColumns(this.#e.node.addIndex,[t.toOperationNode()])})})}using(t){return new e({...this.#e,node:N.cloneWithTableProps(this.#e.node,{addIndex:G.cloneWith(this.#e.node.addIndex,{using:l.createWithSql(t)})})})}$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(e){await this.#e.executor.executeQuery(this.compile(),e)}},$e=class e{#e;constructor(e){this.#e=e}nullsNotDistinct(){return new e(B.cloneWith(this.#e,{nullsNotDistinct:!0}))}deferrable(){return new e(B.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new e(B.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new e(B.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new e(B.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}},et=class e{#e;constructor(e){this.#e=e}deferrable(){return new e(W.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new e(W.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new e(W.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new e(W.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}},tt=class{#e;constructor(e){this.#e=e}$call(e){return e(this)}toOperationNode(){return this.#e}};const nt=k({is(e){return e.kind===`RenameConstraintNode`},create(e,t){return k({kind:`RenameConstraintNode`,oldName:d.create(e),newName:d.create(t)})}});var rt=class e{#e;constructor(e){this.#e=k({...e})}ifExists(){return new e({...this.#e,node:Ie.cloneWith(this.#e.node,{ifExists:!0})})}toOperationNode(){return this.#e.node}},it=class{#e;constructor(e){this.#e=k(e)}renameTo(e){return new U({...this.#e,node:N.cloneWithTableProps(this.#e.node,{renameTo:j(e)})})}setSchema(e){return new U({...this.#e,node:N.cloneWithTableProps(this.#e.node,{setSchema:d.create(e)})})}alterColumn(e,t){let n=t(new Ye(e));return new K({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,n.toOperationNode())})}dropColumn(e,t=T){let n=t(new rt({node:Ie.create(e)}));return new K({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,n.toOperationNode())})}renameColumn(e,t){return new K({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,Le.create(e,t))})}addColumn(e,t,n=T){let r=n(new R(I.create(e,O(t))));return new K({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,Fe.create(r.toOperationNode()))})}modifyColumn(e,t,n=T){let r=n(new R(I.create(e,O(t))));return new K({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,Ge.create(r.toOperationNode()))})}addUniqueConstraint(e,t,r=T){let i=r(new $e(B.create(t.map(e=>D(e)?n.create(e):w(e)),e)));return new U({...this.#e,node:N.cloneWithTableProps(this.#e.node,{addConstraint:qe.create(i.toOperationNode())})})}addCheckConstraint(e,t,n=T){let r=n(new tt(Re.create(t.toOperationNode(),e)));return new U({...this.#e,node:N.cloneWithTableProps(this.#e.node,{addConstraint:qe.create(r.toOperationNode())})})}addForeignKeyConstraint(e,t,r,i,a=T){let o=a(new Ke(z.create(t.map(n.create),j(r),i.map(n.create),e)));return new Xe({...this.#e,constraintBuilder:o})}addPrimaryKeyConstraint(e,t,n=T){let r=n(new et(W.create(t,e)));return new U({...this.#e,node:N.cloneWithTableProps(this.#e.node,{addConstraint:qe.create(r.toOperationNode())})})}dropConstraint(e){return new Ze({...this.#e,node:N.cloneWithTableProps(this.#e.node,{dropConstraint:Je.create(e)})})}renameConstraint(e,t){return new Ze({...this.#e,node:N.cloneWithTableProps(this.#e.node,{renameConstraint:nt.create(e,t)})})}addIndex(e){return new Qe({...this.#e,node:N.cloneWithTableProps(this.#e.node,{addIndex:G.create(e)})})}dropIndex(e){return new U({...this.#e,node:N.cloneWithTableProps(this.#e.node,{dropIndex:F.create(e)})})}$call(e){return e(this)}},K=class e{#e;constructor(e){this.#e=k(e)}alterColumn(t,n){let r=n(new Ye(t));return new e({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,r.toOperationNode())})}dropColumn(t,n=T){let r=n(new rt({node:Ie.create(t)}));return new e({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,r.toOperationNode())})}renameColumn(t,n){return new e({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,Le.create(t,n))})}addColumn(t,n,r=T){let i=r(new R(I.create(t,O(n))));return new e({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,Fe.create(i.toOperationNode()))})}modifyColumn(t,n,r=T){let i=r(new R(I.create(t,O(n))));return new e({...this.#e,node:N.cloneWithColumnAlteration(this.#e.node,Ge.create(i.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(e){await this.#e.executor.executeQuery(this.compile(),e)}},at=class extends _e{transformPrimitiveValueList(e){return de.create(e.values.map(t.createImmediate))}transformValue(e){return t.createImmediate(e.value)}},ot=class e{#e;constructor(e){this.#e=k(e)}ifNotExists(){return new e({...this.#e,node:P.cloneWith(this.#e.node,{ifNotExists:!0})})}unique(){return new e({...this.#e,node:P.cloneWith(this.#e.node,{unique:!0})})}nullsNotDistinct(){return new e({...this.#e,node:P.cloneWith(this.#e.node,{nullsNotDistinct:!0})})}on(t){return new e({...this.#e,node:P.cloneWith(this.#e.node,{table:j(t)})})}column(t){return new e({...this.#e,node:P.cloneWithColumns(this.#e.node,[D(t)?m(t):t.toOperationNode()])})}columns(t){return new e({...this.#e,node:P.cloneWithColumns(this.#e.node,t.map(e=>D(e)?m(e):e.toOperationNode()))})}expression(t){return new e({...this.#e,node:P.cloneWithColumns(this.#e.node,[t.toOperationNode()])})}using(t){return new e({...this.#e,node:P.cloneWith(this.#e.node,{using:l.createWithSql(t)})})}where(...t){let n=new at;return new e({...this.#e,node:h.cloneWithWhere(this.#e.node,n.transformNode(fe(t),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(e){await this.#e.executor.executeQuery(this.compile(),e)}},st=class e{#e;constructor(e){this.#e=k(e)}ifNotExists(){return new e({...this.#e,node:Me.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(e){await this.#e.executor.executeQuery(this.compile(),e)}};function ct(e){if(s.includes(e))return e;throw Error(`invalid OnCommitAction ${e}`)}var lt=class e{#e;constructor(e){this.#e=e}using(t){return new e(G.cloneWith(this.#e,{using:l.createWithSql(t)}))}$call(e){return e(this)}toOperationNode(){return this.#e}},ut=class e{#e;constructor(e){this.#e=k(e)}temporary(){return new e({...this.#e,node:x.cloneWith(this.#e.node,{temporary:!0})})}onCommit(t){return new e({...this.#e,node:x.cloneWith(this.#e.node,{onCommit:ct(t)})})}ifNotExists(){return new e({...this.#e,node:x.cloneWith(this.#e.node,{ifNotExists:!0})})}addColumn(t,n,r=T){let i=r(new R(I.create(t,O(n))));return new e({...this.#e,node:x.cloneWithColumn(this.#e.node,i.toOperationNode())})}addPrimaryKeyConstraint(t,n,r=T){let i=r(new et(W.create(n,t)));return new e({...this.#e,node:x.cloneWithConstraint(this.#e.node,i.toOperationNode())})}addUniqueConstraint(t,r,i=T){let a=i(new $e(B.create(r.map(e=>D(e)?n.create(e):w(e)),t)));return new e({...this.#e,node:x.cloneWithConstraint(this.#e.node,a.toOperationNode())})}addIndex(t,r,i=T){let a=i(new lt(G.cloneWithColumns(G.create(t),r.map(e=>D(e)?n.create(e):w(e)))));return new e({...this.#e,node:x.cloneWithIndex(this.#e.node,a.toOperationNode())})}addCheckConstraint(t,n,r=T){let i=r(new tt(Re.create(n.toOperationNode(),t)));return new e({...this.#e,node:x.cloneWithConstraint(this.#e.node,i.toOperationNode())})}addForeignKeyConstraint(t,r,i,a,o=T){let s=o(new Ke(z.create(r.map(n.create),j(i),a.map(n.create),t)));return new e({...this.#e,node:x.cloneWithConstraint(this.#e.node,s.toOperationNode())})}modifyFront(t){return new e({...this.#e,node:x.cloneWithFrontModifier(this.#e.node,t.toOperationNode())})}modifyEnd(t){return new e({...this.#e,node:x.cloneWithEndModifier(this.#e.node,t.toOperationNode())})}as(t){return new e({...this.#e,node:x.cloneWith(this.#e.node,{selectQuery:w(t)})})}$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(e){await this.#e.executor.executeQuery(this.compile(),e)}},dt=class e{#e;constructor(e){this.#e=k(e)}on(t){return new e({...this.#e,node:F.cloneWith(this.#e.node,{table:j(t)})})}ifExists(){return new e({...this.#e,node:F.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new e({...this.#e,node:F.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(e){await this.#e.executor.executeQuery(this.compile(),e)}},ft=class e{#e;constructor(e){this.#e=k(e)}ifExists(){return new e({...this.#e,node:Ne.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new e({...this.#e,node:Ne.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(e){await this.#e.executor.executeQuery(this.compile(),e)}},pt=class e{#e;constructor(e){this.#e=k(e)}temporary(){return new e({...this.#e,node:Pe.cloneWith(this.#e.node,{temporary:!0})})}ifExists(){return new e({...this.#e,node:Pe.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new e({...this.#e,node:Pe.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(e){await this.#e.executor.executeQuery(this.compile(),e)}},mt=class{#e=new at;transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}transformResult(e){return Promise.resolve(e.result)}},ht=class e{#e;constructor(e){this.#e=k(e)}temporary(){return new e({...this.#e,node:E.cloneWith(this.#e.node,{temporary:!0})})}materialized(){return new e({...this.#e,node:E.cloneWith(this.#e.node,{materialized:!0})})}ifNotExists(){return new e({...this.#e,node:E.cloneWith(this.#e.node,{ifNotExists:!0})})}orReplace(){return new e({...this.#e,node:E.cloneWith(this.#e.node,{orReplace:!0})})}columns(t){return new e({...this.#e,node:E.cloneWith(this.#e.node,{columns:t.map(p)})})}as(t){let n=t.withPlugin(new mt).toOperationNode();return new e({...this.#e,node:E.cloneWith(this.#e.node,{as:n})})}$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(e){await this.#e.executor.executeQuery(this.compile(),e)}};const gt=k({is(e){return e.kind===`DropViewNode`},create(e){return k({kind:`DropViewNode`,name:b.create(e)})},cloneWith(e,t){return k({...e,...t})}});var _t=class e{#e;constructor(e){this.#e=k(e)}materialized(){return new e({...this.#e,node:gt.cloneWith(this.#e.node,{materialized:!0})})}ifExists(){return new e({...this.#e,node:gt.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new e({...this.#e,node:gt.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(e){await this.#e.executor.executeQuery(this.compile(),e)}};const vt=k({is(e){return e.kind===`CreateTypeNode`},create(e){return k({kind:`CreateTypeNode`,name:e})},cloneWithEnum(e,n){return k({...e,enum:de.create(n.map(t.createImmediate))})}});var yt=class e{#e;constructor(e){this.#e=k(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}asEnum(t){return new e({...this.#e,node:vt.cloneWithEnum(this.#e.node,t)})}$call(e){return e(this)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(e){await this.#e.executor.executeQuery(this.compile(),e)}};const bt=k({is(e){return e.kind===`DropTypeNode`},create(e){return Array.isArray(e)||(e=[e]),k({kind:`DropTypeNode`,name:e[0],additionalNames:e.slice(1)})},cloneWith(e,t){return k({...e,...t})}});var xt=class e{#e;constructor(e){this.#e=k(e)}ifExists(){return new e({...this.#e,node:bt.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new e({...this.#e,node:bt.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(e){await this.#e.executor.executeQuery(this.compile(),e)}};function St(e){if(e.includes(`.`)){let t=e.split(`.`).map(wt);if(t.length===2)return b.createWithSchema(t[0],t[1]);throw Error(`invalid schemable identifier ${e}`)}return b.create(e)}function Ct(e){return Array.isArray(e)||(e=[e]),e.map(St)}function wt(e){return e.trim()}const q=k({is(e){return e.kind===`RefreshMaterializedViewNode`},create(e){return k({kind:`RefreshMaterializedViewNode`,name:b.create(e)})},cloneWith(e,t){return k({...e,...t})}});var Tt=class e{#e;constructor(e){this.#e=k(e)}concurrently(){return new e({...this.#e,node:q.cloneWith(this.#e.node,{concurrently:!0,withNoData:!1})})}withData(){return new e({...this.#e,node:q.cloneWith(this.#e.node,{withNoData:!1})})}withNoData(){return new e({...this.#e,node:q.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(e){await this.#e.executor.executeQuery(this.compile(),e)}};const J=k({is(e){return e.kind===`AlterTypeNode`},create(e){return k({kind:`AlterTypeNode`,name:e})},cloneWith(e,t){return k({...e,...t})}}),Et=k({is(e){return e.kind===`AddValueNode`},create(e){return k({kind:`AddValueNode`,value:e})},cloneWith(e,t){return k({...e,...t})}});var Dt=class{#e;constructor(e){this.#e=k(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(e){return await this.#e.executor.executeQuery(this.compile(),e)}},Ot,kt=class extends Dt{#e;constructor(e){super(e),this.#e=e}ifNotExists(){return new Ot({...this.#e,node:J.cloneWith(this.#e.node,{addValue:Et.cloneWith(this.#e.node.addValue,{ifNotExists:!0})})})}before(e){return this.#t(e,!0)}after(e){return this.#t(e,!1)}#t(e,n){return new Ot({...this.#e,node:J.cloneWith(this.#e.node,{addValue:Et.cloneWith(this.#e.node.addValue,{isBefore:n,neighborValue:t.createImmediate(e)})})})}};Ot=kt;const At=k({is(e){return e.kind===`RenameValueNode`},create(e,t){return k({kind:`RenameValueNode`,oldValue:e,newValue:t})}});var jt=class{#e;constructor(e){this.#e=k(e)}addValue(e){return new kt({...this.#e,node:J.cloneWith(this.#e.node,{addValue:Et.create(t.createImmediate(e))})})}renameTo(e){return new Dt({...this.#e,node:J.cloneWith(this.#e.node,{renameTo:d.create(e)})})}renameValue(e,n){return new Dt({...this.#e,node:J.cloneWith(this.#e.node,{renameValue:At.create(t.createImmediate(e),t.createImmediate(n))})})}setSchema(e){return new Dt({...this.#e,node:J.cloneWith(this.#e.node,{setSchema:d.create(e)})})}},Mt=class e{#e;constructor(e){this.#e=e}createTable(e){return new ut({queryId:y(),executor:this.#e,node:x.create(j(e))})}dropTable(e){return new pt({queryId:y(),executor:this.#e,node:Pe.create(j(e))})}createIndex(e){return new ot({queryId:y(),executor:this.#e,node:P.create(e)})}dropIndex(e){return new dt({queryId:y(),executor:this.#e,node:F.create(e)})}createSchema(e){return new st({queryId:y(),executor:this.#e,node:Me.create(e)})}dropSchema(e){return new ft({queryId:y(),executor:this.#e,node:Ne.create(e)})}alterTable(e){return new it({queryId:y(),executor:this.#e,node:N.create(j(e))})}createView(e){return new ht({queryId:y(),executor:this.#e,node:E.create(e)})}refreshMaterializedView(e){return new Tt({queryId:y(),executor:this.#e,node:q.create(e)})}dropView(e){return new _t({queryId:y(),executor:this.#e,node:gt.create(e)})}createType(e){return new yt({queryId:y(),executor:this.#e,node:vt.create(St(e))})}alterType(e){return new jt({executor:this.#e,node:J.create(St(e)),queryId:y()})}dropType(e){return new xt({queryId:y(),executor:this.#e,node:bt.create(Ct(e))})}withPlugin(t){return new e(this.#e.withPlugin(t))}withoutPlugins(){return new e(this.#e.withoutPlugins())}withSchema(t){return new e(this.#e.withPluginAtFront(new r(t)))}},Nt=class{ref(e){return new f(e)}table(e){return new oe(e)}},Pt=class{#e;constructor(e){this.#e=e}async provideConnection(e,t){let n=await this.#e.acquireConnection(t);try{return await e(n)}finally{await this.#e.releaseConnection(n,t)}}},Ft=class e extends ge{#e;#t;#n;constructor(e,t,n,r=[]){super(r),this.#e=e,this.#t=t,this.#n=n}get adapter(){return this.#t}compileQuery(e,t){return this.#e.compileQuery(e,t)}provideConnection(e,t){return this.#n.provideConnection(e,t)}withPlugins(t){return new e(this.#e,this.#t,this.#n,[...this.plugins,...t])}withPlugin(t){return new e(this.#e,this.#t,this.#n,[...this.plugins,t])}withPluginAtFront(t){return new e(this.#e,this.#t,this.#n,[t,...this.plugins])}withConnectionProvider(t){return new e(this.#e,this.#t,t,[...this.plugins])}withoutPlugins(){return new e(this.#e,this.#t,this.#n,[])}};function It(){return typeof performance<`u`&&_(performance.now)?performance.now():Date.now()}var Lt=class{#e;#t;async obtainLock(){for(;this.#e;)await this.#e;this.#e=new Promise(e=>{this.#t=e})}releaseLock(){let e=this.#t;this.#e=void 0,this.#t=void 0,e?.()}},Rt=class{#e;#t;#n;#r;#i;#a=/* @__PURE__ */ new WeakSet;#o;constructor(e,t,n){this.#e=e,this.#r=!1,this.#t=n,t.supportsMultipleConnections===!1&&(this.#o=new Lt)}async init(e){if(this.#i)throw Error(`driver has already been destroyed`);this.#n??=this.#e.init(e).then(()=>{this.#r=!0}).catch(e=>{throw this.#n=void 0,e}),await S(this.#n,e?.signal,`init`)}async acquireConnection(e){if(this.#i)throw Error(`driver has already been destroyed`);if(this.#r||await this.init(e),this.#o){let t=this.#o.obtainLock();await S(t,e?.signal,`acquireConnection:mutex`,()=>t.then(()=>this.#o?.releaseLock()))}let t=this.#e.acquireConnection(e),n=await S(t,e?.signal,`acquireConnection:acquire`,()=>t?.then(e=>this.releaseConnection(e).catch(ye(`driver.releaseConnection`))).catch(ye(`driver.acquireConnection`)));return this.#a.has(n)||(this.#s()&&this.#c(n),this.#a.add(n)),n}async releaseConnection(e,t){await this.#e.releaseConnection(e,t),this.#o?.releaseLock()}async beginTransaction(e,t){return await this.#e.beginTransaction(e,t)}async commitTransaction(e){return await this.#e.commitTransaction(e)}async rollbackTransaction(e){return await this.#e.rollbackTransaction(e)}async savepoint(e,t,n){if(this.#e.savepoint)return await this.#e.savepoint(e,t,n);throw Error("The `savepoint` method is not supported by this driver")}async rollbackToSavepoint(e,t,n){if(this.#e.rollbackToSavepoint)return await this.#e.rollbackToSavepoint(e,t,n);throw Error("The `rollbackToSavepoint` method is not supported by this driver")}async releaseSavepoint(e,t,n){if(this.#e.releaseSavepoint)return await this.#e.releaseSavepoint(e,t,n);throw Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(e){this.#n&&(await S(this.#n,e?.signal,`destroy:initPromise`),this.#i??=this.#e.destroy(e).catch(e=>{throw this.#i=void 0,e}),await S(this.#i,e?.signal,`destroy`))}#s(){return this.#t.isLevelEnabled(`query`)||this.#t.isLevelEnabled(`error`)}#c(e){let t=e.executeQuery,n=e.streamQuery,r=this;e.executeQuery=async(n,i)=>{let a,o=It();try{return await t.call(e,n,i)}catch(e){throw a=e,await r.#l(e,n,o),e}finally{a||await r.#u(n,o)}},e.streamQuery=async function*(t,i,a){let o,s=It();try{for await(let r of n.call(e,t,i,a))yield r}catch(e){throw o=e,await r.#l(e,t,s),e}finally{o||await r.#u(t,s,!0)}}}async#l(e,t,n){await this.#t.error(()=>({level:`error`,error:e,query:t,queryDurationMillis:this.#d(n)}))}async#u(e,t,n=!1){await this.#t.query(()=>({level:`query`,isStream:n,query:e,queryDurationMillis:this.#d(t)}))}#d(e){return It()-e}};const zt=()=>{};var Bt=class{#e;#t;constructor(e){this.#e=e}async provideConnection(e){for(;this.#t;)await this.#t.catch(zt);return this.#t=this.#n(e).finally(()=>{this.#t=void 0}),this.#t}async#n(e){return await e(this.#e)}};const Vt=[`read only`,`read write`],Ht=[`read uncommitted`,`read committed`,`repeatable read`,`serializable`,`snapshot`];function Ut(e){if(e.accessMode&&!Vt.includes(e.accessMode))throw Error(`invalid transaction access mode ${e.accessMode}`);if(e.isolationLevel&&!Ht.includes(e.isolationLevel))throw Error(`invalid transaction isolation level ${e.isolationLevel}`)}k([`query`,`error`]);var Wt=class{#e;#t;constructor(e){_(e)?(this.#t=e,this.#e=k({query:!0,error:!0})):(this.#t=Gt,this.#e=k({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 Gt(e){if(e.level===`query`){let t=`kysely:query:${e.isStream?`stream:`:``}`;console.log(`${t} ${e.query.sql}`),console.log(`${t} duration: ${e.queryDurationMillis.toFixed(1)}ms`)}else e.level===`error`&&(e.error instanceof Error?console.error(`kysely:error: ${e.error.stack??e.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:e.error,query:e.query.sql,queryDurationMillis:e.queryDurationMillis})}`))}function Kt(e){return A(e)&&_(e.compile)}Symbol.asyncDispose??=Symbol(`Symbol.asyncDispose`);var Y=class e extends ae{#e;constructor(e){let t,n;if(Jt(e))t={executor:e.executor},n={...e};else{let r=e.dialect,i=r.createDriver(),a=r.createQueryCompiler(),o=r.createAdapter(),s=new Rt(i,o,new Wt(e.log??[])),c=new Ft(a,o,new Pt(s),e.plugins??[]);t={executor:c},n={config:e,executor:c,dialect:r,driver:s}}super(t),this.#e=k(n)}get schema(){return new Mt(this.#e.executor)}get dynamic(){return new Nt}get introspection(){return this.#e.dialect.createIntrospector(this.withoutPlugins())}case(e){return new pe({node:le.create(me(e)?void 0:w(e))})}get fn(){return ce()}transaction(){return new Xt({...this.#e})}startTransaction(){return new Zt({...this.#e})}connection(){return new Yt({...this.#e})}withPlugin(t){return new e({...this.#e,executor:this.#e.executor.withPlugin(t)})}withoutPlugins(){return new e({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(t){return new e({...this.#e,executor:this.#e.executor.withPluginAtFront(new r(t))})}$extendTables(){return new e({...this.#e})}$omitTables(){return new e({...this.#e})}$pickTables(){return new e({...this.#e})}withTables(){return this.$extendTables()}async destroy(){await this.#e.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#e.executor}async executeQuery(e,t){let n=Kt(e)?e.compile():e;return await this.#e.executor.executeQuery(n,t)}async[Symbol.asyncDispose](){await this.destroy()}},qt=class e extends Y{#e;constructor(e){super(e),this.#e=e}get isTransaction(){return!0}transaction(){throw Error(`calling the transaction method for a Transaction is not supported`)}startTransaction(){throw Error(`calling the controlled transaction method for a Transaction is not supported`)}connection(){throw Error(`calling the connection method for a Transaction is not supported`)}destroy(){throw Error(`calling the destroy method for a Transaction is not supported`)}withPlugin(t){return new e({...this.#e,executor:this.#e.executor.withPlugin(t)})}withoutPlugins(){return new e({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(t){return new e({...this.#e,executor:this.#e.executor.withPluginAtFront(new r(t))})}withTables(){return new e({...this.#e})}$extendTables(){return new e({...this.#e})}$omitTables(){return new e({...this.#e})}$pickTables(){return new e({...this.#e})}};function Jt(e){return A(e)&&A(e.config)&&A(e.driver)&&A(e.executor)&&A(e.dialect)}var Yt=class{#e;constructor(e){this.#e=k(e)}async execute(e,t){return this.#e.executor.provideConnection(async t=>{let n=this.#e.executor.withConnectionProvider(new Bt(t));return await e(new Y({...this.#e,executor:n}))},k({signal:t?.signal}))}},Xt=class e{#e;constructor(e){this.#e=k(e)}setAccessMode(t){return new e({...this.#e,accessMode:t})}setIsolationLevel(t){return new e({...this.#e,isolationLevel:t})}async execute(e){let{isolationLevel:t,accessMode:n,...r}=this.#e,i={isolationLevel:t,accessMode:n};return Ut(i),this.#e.executor.provideConnection(async t=>{let n={isCommitted:!1,isRolledBack:!1},a=new $t(this.#e.executor.withConnectionProvider(new Bt(t)),n),o=new qt({...r,executor:a}),s=!1;try{await this.#e.driver.beginTransaction(t,i),s=!0;let r=await e(o);return await this.#e.driver.commitTransaction(t),n.isCommitted=!0,r}catch(e){throw s&&(await this.#e.driver.rollbackTransaction(t),n.isRolledBack=!0),e}})}},Zt=class e{#e;constructor(e){this.#e=k(e)}setAccessMode(t){return new e({...this.#e,accessMode:t})}setIsolationLevel(t){return new e({...this.#e,isolationLevel:t})}async execute(){let{isolationLevel:e,accessMode:t,...n}=this.#e,r={isolationLevel:e,accessMode:t};Ut(r);let i=await ve(this.#e.executor);return await this.#e.driver.beginTransaction(i.connection,r),new Qt({...n,connection:i,executor:this.#e.executor.withConnectionProvider(new Bt(i.connection))})}},Qt=class e extends qt{#e;#t;#n;constructor(e){let t={isCommitted:!1,isRolledBack:!1};e={...e,executor:new $t(e.executor,t)};let{connection:n,...r}=e;super(r),this.#e=k(e),this.#n=t;let i=y();this.#t=t=>e.executor.compileQuery(t,i)}get isCommitted(){return this.#n.isCommitted}get isRolledBack(){return this.#n.isRolledBack}commit(){return Z(this.#n),new X(async()=>{await this.#e.driver.commitTransaction(this.#e.connection.connection),this.#n.isCommitted=!0,this.#e.connection.release()})}rollback(){return Z(this.#n),new X(async()=>{await this.#e.driver.rollbackTransaction(this.#e.connection.connection),this.#n.isRolledBack=!0,this.#e.connection.release()})}savepoint(t){return Z(this.#n),new X(async()=>(await this.#e.driver.savepoint?.(this.#e.connection.connection,t,this.#t),new e({...this.#e})))}rollbackToSavepoint(t){return Z(this.#n),new X(async()=>(await this.#e.driver.rollbackToSavepoint?.(this.#e.connection.connection,t,this.#t),new e({...this.#e})))}releaseSavepoint(t){return Z(this.#n),new X(async()=>(await this.#e.driver.releaseSavepoint?.(this.#e.connection.connection,t,this.#t),new e({...this.#e})))}withPlugin(t){return new e({...this.#e,executor:this.#e.executor.withPlugin(t)})}withoutPlugins(){return new e({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(t){return new e({...this.#e,executor:this.#e.executor.withPluginAtFront(new r(t))})}withTables(){return new e({...this.#e})}$extendTables(){return new e({...this.#e})}$omitTables(){return new e({...this.#e})}$pickTables(){return new e({...this.#e})}},X=class{#e;constructor(e){this.#e=e}async execute(){return await this.#e()}};function Z(e){if(e.isCommitted)throw Error(`Transaction is already committed`);if(e.isRolledBack)throw Error(`Transaction is already rolled back`)}var $t=class e{#e;#t;constructor(t,n){this.#e=t instanceof e?t.#e:t,this.#t=n}get adapter(){return this.#e.adapter}get plugins(){return this.#e.plugins}transformQuery(e,t){return this.#e.transformQuery(e,t)}compileQuery(e,t){return this.#e.compileQuery(e,t)}provideConnection(e,t){return this.#e.provideConnection(e,t)}executeQuery(e,t){return Z(this.#t),this.#e.executeQuery(e,t)}stream(e,t,n){return Z(this.#t),this.#e.stream(e,t,n)}withConnectionProvider(t){return new e(this.#e.withConnectionProvider(t),this.#t)}withPlugin(t){return new e(this.#e.withPlugin(t),this.#t)}withPlugins(t){return new e(this.#e.withPlugins(t),this.#t)}withPluginAtFront(t){return new e(this.#e.withPluginAtFront(t),this.#t)}withoutPlugins(){return new e(this.#e.withoutPlugins(),this.#t)}};function Q(e,t){return l.createWithChildren([l.createWithSql(`${e} `),d.create(t)])}var en=class{#e;#t;#n;constructor(e){this.#e=k({...e})}async init(e){this.#t=_(this.#e.database)?await this.#e.database(e):this.#e.database,this.#n=new tn(this.#t),this.#e.onCreateConnection&&await this.#e.onCreateConnection(this.#n,e)}async acquireConnection(){return this.#n}async beginTransaction(e){await e.executeQuery(M.raw(`begin`))}async commitTransaction(e){await e.executeQuery(M.raw(`commit`))}async rollbackTransaction(e){await e.executeQuery(M.raw(`rollback`))}async savepoint(e,t,n){await e.executeQuery(n(Q(`savepoint`,t),y()))}async rollbackToSavepoint(e,t,n){await e.executeQuery(n(Q(`rollback to`,t),y()))}async releaseSavepoint(e,t,n){await e.executeQuery(n(Q(`release`,t),y()))}async releaseConnection(){}async destroy(){this.#t?.close()}},tn=class{#e;constructor(e){this.#e=e}async executeQuery(e){let{sql:t,parameters:n}=e,r=this.#e.prepare(t);if(r.reader)return{rows:r.all(n)};let{changes:i,lastInsertRowid:a}=r.run(n);return{insertId:a==null?void 0:BigInt(a),numAffectedRows:i==null?void 0:BigInt(i),rows:[]}}async*streamQuery(e,t){let{sql:n,parameters:r,query:a}=e,o=this.#e.prepare(n);if(!i.is(a))throw Error(`Sqlite driver only supports streaming of select queries`);let s=o.iterate(r);for(let e of s)yield{rows:[e]}}};const $=`kysely_migration`,nn=`kysely_migration_lock`;k({__noMigrations__:!0});var rn=class{#e;constructor(e){this.#e=e}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){return await this.#n(e)}#t(e,t){let n=e.selectFrom(`sqlite_master`).where(`type`,`in`,[`table`,`view`]).where(`name`,`not like`,`sqlite_%`).select([`name`,`sql`,`type`]).orderBy(`name`);return t.withInternalKyselyTables||(n=n.where(`name`,`!=`,$).where(`name`,`!=`,nn)),n}async#n(e){let t=await this.#t(this.#e,e).execute(),n=await this.#e.with(`table_list`,t=>this.#t(t,e)).selectFrom([`table_list as tl`,C`pragma_table_info(tl.name)`.as(`p`)]).select([`tl.name as table`,`p.cid`,`p.name`,`p.type`,`p.notnull`,`p.dflt_value`,`p.pk`]).orderBy(`tl.name`).orderBy(`p.cid`).execute(),r={};for(let e of n)r[e.table]??=[],r[e.table].push(e);return t.map(({name:e,sql:t,type:n})=>{let i=t?.split(/[\(\),]/)?.find(e=>e.toLowerCase().includes(`autoincrement`))?.trimStart()?.split(/\s+/)?.[0]?.replace(/["`]/g,``),a=r[e]??[];if(!i){let e=a.filter(e=>e.pk>0);e.length===1&&e[0].type.toLowerCase()===`integer`&&(i=e[0].name)}return{name:e,isView:n===`view`,isForeign:!1,columns:a.map(e=>({name:e.name,dataType:e.type,isNullable:!e.notnull,isAutoIncrementing:e.name===i,hasDefaultValue:e.dflt_value!=null,comment:void 0}))}})}},an=class{#e;constructor(e){this.#e=k({...e})}createDriver(){return new en(this.#e)}createQueryCompiler(){return new xe}createAdapter(){return new Ce}createIntrospector(e){return new rn(e)}};function on(e,t){if(sn(e)&&t.stack){let n=t.stack.split(`
2
- `).slice(1).join(`
3
- `);return e.stack+=`\n${n}`,e}return e}function sn(e){return A(e)&&D(e.stack)}const cn=Symbol();var ln=class{#e;#t=/* @__PURE__ */ new WeakMap;#n;constructor(e){this.#e=k({...e})}async init(e){this.#n=_(this.#e.pool)?await this.#e.pool(e):this.#e.pool}async acquireConnection(e){let t=await this.#r(),n=this.#t.get(t);return n||(n=new dn(t,this.#e.controlConnection),this.#t.set(t,n),this.#e?.onCreateConnection&&await this.#e.onCreateConnection(n,e)),this.#e?.onReserveConnection&&await this.#e.onReserveConnection(n,e),n}async beginTransaction(e,t){if(t.isolationLevel||t.accessMode){let n=[];t.isolationLevel&&n.push(`isolation level ${t.isolationLevel}`),t.accessMode&&n.push(t.accessMode);let r=`set transaction ${n.join(`, `)}`;await e.executeQuery(M.raw(r))}await e.executeQuery(M.raw(`begin`))}async commitTransaction(e){await e.executeQuery(M.raw(`commit`))}async rollbackTransaction(e){await e.executeQuery(M.raw(`rollback`))}async savepoint(e,t,n){await e.executeQuery(n(Q(`savepoint`,t),y()))}async rollbackToSavepoint(e,t,n){await e.executeQuery(n(Q(`rollback to`,t),y()))}async releaseSavepoint(e,t,n){await e.executeQuery(n(Q(`release savepoint`,t),y()))}async releaseConnection(e){e[cn]()}async destroy(){return new Promise((e,t)=>{this.#n.end(n=>{n?t(n):e()})})}async#r(){return new Promise((e,t)=>{this.#n.getConnection(async(n,r)=>{n?t(n):e(r)})})}};function un(e){return A(e)&&`insertId`in e&&`affectedRows`in e}var dn=class{#e;#t;#n;#r;constructor(e,t){this.#e=e,this.#t=t}async cancelQuery(e){await this.#a(`kill query ${this.#n}`,e)}async collectSessionInfo(){if(this.#n)return;let{threadId:e}=this.#e;if(e!=null)this.#n=e;else{let[{cid:e}]=await this.#i(M.raw(`select connection_id() as cid`));this.#n=Number(e)}}async executeQuery(e){try{this.#r=e.queryId;let t=await this.#i(e);if(!un(t))return{rows:Array.isArray(t)?t:[]};let{insertId:n,affectedRows:r,changedRows:i}=t;return{insertId:n!=null&&n.toString()!==`0`?BigInt(n):void 0,numAffectedRows:r==null?void 0:BigInt(r),numChangedRows:i==null?void 0:BigInt(i),rows:[]}}catch(e){throw on(e,/* @__PURE__ */ Error())}finally{this.#r=void 0}}async killSession(e){try{this.#e.destroy()}catch{}await this.#a(`kill connection ${this.#n}`,e)}async*streamQuery(e,t){this.#r=e.queryId;let n=this.#e.query(e.sql,e.parameters).stream({objectMode:!0});try{for await(let e of n)yield{rows:[e]}}catch(e){if(A(e)&&`code`in e&&e.code===`ERR_STREAM_PREMATURE_CLOSE`)return;throw e}finally{this.#r=void 0}}[cn](){this.#e.release()}#i(e){return new Promise((t,n)=>{this.#e.query(e.sql,e.parameters,(e,r)=>{e?n(e):t(r)})})}async#a(e,t){if(!this.#r)return;let{config:n}=this.#e,r=this.#r;if(!this.#t||!n)return await t(async t=>{r.queryId===this.#r?.queryId&&await t.executeQuery(M.raw(e,[]))});let{clientFlags:i,maxPacketSize:a,...o}=n,s=this.#t(o);try{await new Promise((t,n)=>{s.connect(i=>{if(i)return n(i);if(r.queryId!==this.#r?.queryId)return t();s.query(e,[],e=>{if(e)return n(e);t()})})})}finally{s.destroy()}}};const fn=/[\\']/g,pn=/`/g,mn=/[\\'"]/g;var hn=class extends he{getCurrentParameterPlaceholder(){return`?`}getLeftExplainOptionsWrapper(){return``}getExplainOptionAssignment(){return`=`}getExplainOptionsDelimiter(){return` `}getRightExplainOptionsWrapper(){return``}getLeftIdentifierWrapper(){return pn.source}getRightIdentifierWrapper(){return pn.source}sanitizeIdentifier(e){return e.replace(pn,"``")}sanitizeStringLiteral(e){return e.replace(fn,e=>e===`\\`?`\\\\`:`''`)}sanitizeJSONPathMemberValue(e){return e.replace(mn,e=>e===`\\`?`\\\\\\\\`:e===`'`?`''`:`\\\\"`)}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.using&&(this.append(` using `),this.visitNode(e.using)),e.table&&(this.append(` on `),this.visitNode(e.table)),e.columns&&(this.append(` (`),this.compileList(e.columns),this.append(`)`)),e.where&&(this.append(` `),this.visitNode(e.where))}},gn=class{#e;constructor(e){this.#e=e}async getSchemas(){return(await this.#e.selectFrom(`information_schema.schemata`).select(`schema_name`).$castTo().execute()).map(e=>({name:e.SCHEMA_NAME}))}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.selectFrom(`information_schema.columns as columns`).innerJoin(`information_schema.tables as tables`,e=>e.onRef(`columns.TABLE_CATALOG`,`=`,`tables.TABLE_CATALOG`).onRef(`columns.TABLE_SCHEMA`,`=`,`tables.TABLE_SCHEMA`).onRef(`columns.TABLE_NAME`,`=`,`tables.TABLE_NAME`)).select([`columns.COLUMN_NAME`,`columns.COLUMN_DEFAULT`,`columns.TABLE_NAME`,`columns.TABLE_SCHEMA`,`tables.TABLE_TYPE`,`tables.ENGINE`,`columns.IS_NULLABLE`,`columns.DATA_TYPE`,`columns.EXTRA`,`columns.COLUMN_COMMENT`]).where(`columns.TABLE_SCHEMA`,`=`,C`database()`).orderBy(`columns.TABLE_NAME`).orderBy(`columns.ORDINAL_POSITION`).$castTo();e.withInternalKyselyTables||(t=t.where(`columns.TABLE_NAME`,`!=`,$).where(`columns.TABLE_NAME`,`!=`,nn));let n=await t.execute();return this.#t(n)}#t(e){return e.reduce((e,t)=>{let n=e.find(e=>e.name===t.TABLE_NAME);return n||(n=k({name:t.TABLE_NAME,isView:t.TABLE_TYPE===`VIEW`,isForeign:t.ENGINE===`FEDERATED`,schema:t.TABLE_SCHEMA,columns:[]}),e.push(n)),n.columns.push(k({name:t.COLUMN_NAME,dataType:t.DATA_TYPE,isNullable:t.IS_NULLABLE===`YES`,isAutoIncrementing:t.EXTRA.toLowerCase().includes(`auto_increment`),hasDefaultValue:t.COLUMN_DEFAULT!==null,comment:t.COLUMN_COMMENT===``?void 0:t.COLUMN_COMMENT})),e},[])}};const _n=`ea586330-2c93-47c8-908d-981d9d270f9d`;var vn=class extends Se{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}async acquireMigrationLock(e,t){await C`select get_lock(${C.lit(_n)}, ${C.lit(3600)})`.execute(e)}async releaseMigrationLock(e,t){await C`select release_lock(${C.lit(_n)})`.execute(e)}},yn=class{#e;constructor(e){this.#e=e}createDriver(){return new ln(this.#e)}createQueryCompiler(){return new hn}createAdapter(){return new vn}createIntrospector(e){return new gn(e)}};const bn=Symbol();var xn=class{#e;#t=/* @__PURE__ */ new WeakMap;#n;constructor(e){this.#e=k({...e})}async init(e){this.#n=_(this.#e.pool)?await this.#e.pool(e):this.#e.pool}async acquireConnection(e){let t=await this.#n.connect(),n=this.#t.get(t);return n||(n=new Sn(t,{controlClient:this.#e.controlClient||this.#n.Client,cursor:this.#e.cursor??null,poolOptions:this.#n.options}),this.#t.set(t,n),this.#e.onCreateConnection&&await this.#e.onCreateConnection(n,e)),this.#e.onReserveConnection&&await this.#e.onReserveConnection(n,e),n}async beginTransaction(e,t){let n=`begin`;(t.isolationLevel||t.accessMode)&&(n=`start transaction`,t.isolationLevel&&(n+=` isolation level ${t.isolationLevel}`),t.accessMode&&(n+=` ${t.accessMode}`)),await e.executeQuery(M.raw(n))}async commitTransaction(e){await e.executeQuery(M.raw(`commit`))}async rollbackTransaction(e){await e.executeQuery(M.raw(`rollback`))}async savepoint(e,t,n){await e.executeQuery(n(Q(`savepoint`,t),y()))}async rollbackToSavepoint(e,t,n){await e.executeQuery(n(Q(`rollback to`,t),y()))}async releaseSavepoint(e,t,n){await e.executeQuery(n(Q(`release`,t),y()))}async releaseConnection(e){e[bn]()}async destroy(){if(this.#n){let e=this.#n;this.#n=void 0,await e.end()}}},Sn=class{#e;#t;#n;#r;constructor(e,t){this.#e=e,this.#t=t}async cancelQuery(e){return await this.#i(`select pg_cancel_backend(${this.#r})`,e)}async collectSessionInfo(){if(this.#r)return;let{processID:e}=this.#e;if(e)this.#r=e;else{let{rows:[{pid:e}]}=await this.#e.query(`select pg_backend_pid() as pid`,[]);this.#r=Number(e)}}async executeQuery(e){try{this.#n=e.queryId;let{command:t,rowCount:n,rows:r}=await this.#e.query(e.sql,e.parameters);return{numAffectedRows:t===`INSERT`||t===`UPDATE`||t===`DELETE`||t===`MERGE`?BigInt(n):void 0,rows:r??[]}}catch(e){throw on(e,/* @__PURE__ */ Error())}finally{this.#n=void 0}}async killSession(e){return await this.#i(`select pg_terminate_backend(${this.#r})`,e)}async*streamQuery(e,t){if(!this.#t.cursor)throw Error("`cursor` is not present in your postgres dialect config. It's required to make streaming work in postgres.");this.#n=e.queryId;let n=this.#e.query(new this.#t.cursor(e.sql,e.parameters.slice()));try{for(;;){let e=await n.read(t);if(e.length===0)break;yield{rows:e}}}finally{await n.close(),this.#n=void 0}}[bn](){this.#e.release()}async#i(e,t){if(!this.#n)return;let{controlClient:n,poolOptions:r}=this.#t,i=this.#n;if(!n)return await t(async t=>{i.queryId===this.#n?.queryId&&await t.executeQuery(M.raw(e,[]))});let a=new n({...r,password:`password`in r?r.password:void 0});try{if(await a.connect(),i.queryId!==this.#n.queryId)return;await a.query(e,[])}finally{a.end()}}},Cn=class{#e;constructor(e){this.#e=e}async getSchemas(){return(await this.#e.selectFrom(`pg_catalog.pg_namespace`).select(`nspname`).$castTo().execute()).map(e=>({name:e.nspname}))}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.selectFrom(`pg_catalog.pg_attribute as a`).innerJoin(`pg_catalog.pg_class as c`,`a.attrelid`,`c.oid`).innerJoin(`pg_catalog.pg_namespace as ns`,`c.relnamespace`,`ns.oid`).innerJoin(`pg_catalog.pg_type as typ`,`a.atttypid`,`typ.oid`).innerJoin(`pg_catalog.pg_namespace as dtns`,`typ.typnamespace`,`dtns.oid`).select([`a.attname as column`,`a.attnotnull as not_null`,`a.atthasdef as has_default`,`c.relname as table`,`c.relkind as table_type`,`ns.nspname as schema`,`typ.typname as type`,`dtns.nspname as type_schema`,C`col_description(a.attrelid, a.attnum)`.as(`column_description`),C`pg_get_serial_sequence(quote_ident(ns.nspname) || '.' || quote_ident(c.relname), a.attname)`.as(`auto_incrementing`)]).where(`c.relkind`,`in`,[`r`,`v`,`p`,`f`]).where(`ns.nspname`,`!~`,`^pg_`).where(`ns.nspname`,`!=`,`information_schema`).where(`ns.nspname`,`!=`,`crdb_internal`).where(C`has_schema_privilege(ns.nspname, 'USAGE')`).where(`a.attnum`,`>=`,0).where(`a.attisdropped`,`!=`,!0).orderBy(`ns.nspname`).orderBy(`c.relname`).orderBy(`a.attnum`).$castTo();e.withInternalKyselyTables||(t=t.where(`c.relname`,`!=`,$).where(`c.relname`,`!=`,nn));let n=await t.execute();return this.#t(n)}#t(e){let t=[],n=/* @__PURE__ */ new Map;for(let r of e){let e=n.get(r.schema);e||(e=/* @__PURE__ */ new Map,n.set(r.schema,e));let i=e.get(r.table);i||(i=k({columns:[],isForeign:r.table_type===`f`,isView:r.table_type===`v`,name:r.table,schema:r.schema}),e.set(r.table,i),t.push(i)),i.columns.push(k({comment:r.column_description??void 0,dataType:r.type,dataTypeSchema:r.type_schema,hasDefaultValue:r.has_default,isAutoIncrementing:r.auto_incrementing!==null,isNullable:!r.not_null,name:r.column}))}return t}};const wn=/"/g;var Tn=class extends he{sanitizeIdentifier(e){return e.replace(wn,`""`)}};const En=BigInt(`3853314791062309107`);var Dn=class extends Se{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(e,t){await C`
4
- with set_timeout as (
5
- select set_config('lock_timeout', '${C.lit(36e5)}', true) as config_val
6
- )
7
- select pg_advisory_lock(${C.lit(En)})
8
- from set_timeout`.execute(e)}async releaseMigrationLock(e,t){await C`select pg_advisory_unlock(${C.lit(En)})`.execute(e)}},On=class{#e;constructor(e){this.#e=e}createDriver(){return new xn(this.#e)}createQueryCompiler(){return new Tn}createAdapter(){return new Dn}createIntrospector(e){return new Cn(e)}},kn=class extends Se{get supportsCreateIfNotExists(){return!1}get supportsTransactionalDdl(){return!0}get supportsOutput(){return!0}async acquireMigrationLock(e,t){await C`exec sp_getapplock @DbPrincipal = ${C.lit(`dbo`)}, @Resource = ${C.lit($)}, @LockMode = ${C.lit(`Exclusive`)}, @LockOwner = ${C.lit(`Session`)}`.execute(e)}async releaseMigrationLock(e,t){await C`exec sp_releaseapplock @DbPrincipal = ${C.lit(`dbo`)}, @Resource = ${C.lit($)}, @LockOwner = ${C.lit(`Session`)}`.execute(e)}};const An=Symbol(),jn=Symbol(),Mn=Symbol();var Nn=class{#e;#t;constructor(e){this.#e=k({...e});let{tarn:t,tedious:n,validateConnections:r}=this.#e;this.#t=new t.Pool({...t.options,create:async()=>await new Pn(await n.connectionFactory(),n).connect(),destroy:async e=>{await e[jn]()},validate:r===!1?void 0:e=>e[Mn]()})}async init(){}async acquireConnection(){return await this.#t.acquire().promise}async beginTransaction(e,t){await e.beginTransaction(t)}async commitTransaction(e){await e.commitTransaction()}async rollbackTransaction(e){await e.rollbackTransaction()}async savepoint(e,t){await e.savepoint(t)}async rollbackToSavepoint(e,t){await e.rollbackTransaction(t)}async releaseConnection(e){this.#e.resetConnectionsOnRelease&&await e[An](),this.#t.release(e)}async destroy(){await this.#t.destroy()}},Pn=class{#e;#t;#n;#r;constructor(e,t){this.#e=e,this.#t=!1,this.#n=t}async beginTransaction(e){let{isolationLevel:t}=e;await new Promise((e,n)=>this.#e.beginTransaction(t=>{t?n(t):e(void 0)},t?a(8):void 0,t?this.#i(t):void 0))}async cancelQuery(){if(this.#r)return new Promise(e=>{this.#r?.request.once(`requestCompleted`,e),this.#e.cancel()||(this.#r?.request.off(`requestCompleted`,e),e())})}async commitTransaction(){await new Promise((e,t)=>this.#e.commitTransaction(n=>{n?t(n):e(void 0)}))}async connect(){let{promise:e,reject:t,resolve:n}=new v;this.#e.connect(e=>{if(e)return t(e);n()}),this.#e.on(`error`,e=>{e instanceof Error&&`code`in e&&e.code===`ESOCKET`&&(this.#t=!0),console.error(e),t(e)});function r(){t(/* @__PURE__ */ Error(`The connection ended without ever completing the connection`))}return this.#e.once(`end`,r),await e,this.#e.off(`end`,r),this}async executeQuery(e){try{let t=new v;this.#r=new Fn({compiledQuery:e,tedious:this.#n,onDone:t}),this.#e.execSql(this.#r.request);let{rowCount:n,rows:r}=await t.promise;return{numAffectedRows:n===void 0?void 0:BigInt(n),rows:r}}catch(e){throw on(e,/* @__PURE__ */ Error())}finally{this.#r=void 0}}async rollbackTransaction(e){await new Promise((t,n)=>this.#e.rollbackTransaction(e=>{e?n(e):t(void 0)},e))}async savepoint(e){await new Promise((t,n)=>this.#e.saveTransaction(e=>{e?n(e):t(void 0)},e))}async*streamQuery(e,t){this.#r=new Fn({compiledQuery:e,streamChunkSize:t,tedious:this.#n}),this.#e.execSql(this.#r.request);try{for(;;){let e=await this.#r.readChunk();if(e.length===0||(yield{rows:e},e.length<t))break}}finally{await this.cancelQuery(),this.#r=void 0}}#i(e){let{ISOLATION_LEVEL:t}=this.#n,n={"read committed":t.READ_COMMITTED,"read uncommitted":t.READ_UNCOMMITTED,"repeatable read":t.REPEATABLE_READ,serializable:t.SERIALIZABLE,snapshot:t.SNAPSHOT}[e];if(n===void 0)throw Error(`Unknown isolation level: ${e}`);return n}[jn](){return`closed`in this.#e&&this.#e.closed?Promise.resolve():new Promise(e=>{this.#e.once(`end`,e),this.#e.close()})}async[An](){await new Promise((e,t)=>{this.#e.reset(n=>{if(n)return t(n);e()})})}async[Mn](){if(this.#t||this.#a())return!1;try{let e=new v,t=new Fn({compiledQuery:M.raw(`select 1`),onDone:e,tedious:this.#n});return this.#e.execSql(t.request),await e.promise,!0}catch{return!1}}#a(){return`closed`in this.#e&&!!this.#e.closed}},Fn=class{#e;#t;#n;#r;#i;#a;constructor(e){let{compiledQuery:t,onDone:n,streamChunkSize:r,tedious:i}=e;if(this.#t=[],this.#n=r,this.#r={},this.#i=i,n){let e=`onDone`;this.#r[e]=(t,r)=>{if(t!==`chunkReady`){if(delete this.#r[e],t===`error`)return n.reject(r);n.resolve({rowCount:this.#a,rows:this.#t})}}}this.#e=new this.#i.Request(t.sql,(e,t)=>{if(e)return Object.values(this.#r).forEach(t=>t(`error`,e instanceof AggregateError?e.errors:e));this.#a=t}),this.#o(t.parameters),this.#s()}get request(){return this.#e}readChunk(){let e=this.readChunk.name;return new Promise((t,n)=>{this.#r[e]=(r,i)=>{if(delete this.#r[e],r===`error`)return n(i);t(this.#t.splice(0,this.#n))},this.#e.resume()})}#o(e){for(let t=0;t<e.length;t++){let n=e[t];this.#e.addParameter(String(t+1),this.#c(n),n)}}#s(){let e=this.#n?()=>{this.#n<=this.#t.length&&(this.#e.pause(),Object.values(this.#r).forEach(e=>e(`chunkReady`)))}:()=>{},t=t=>{let n={};for(let e of t)n[e.metadata.colName]=e.value;this.#t.push(n),e()};this.#e.on(`row`,t),this.#e.once(`requestCompleted`,()=>{Object.values(this.#r).forEach(e=>e(`completed`)),this.#e.off(`row`,t)})}#c(t){return e(t)||me(t)||D(t)?this.#i.TYPES.NVarChar:u(t)||se(t)&&t%1==0?t<-2147483648||t>2147483647?this.#i.TYPES.BigInt:this.#i.TYPES.Int:se(t)?this.#i.TYPES.Float:re(t)?this.#i.TYPES.Bit:ie(t)?this.#i.TYPES.DateTime:ne(t)?this.#i.TYPES.VarBinary:this.#i.TYPES.NVarChar}},In=class{#e;constructor(e){this.#e=e}async getSchemas(){return await this.#e.selectFrom(`sys.schemas`).select(`name`).execute()}async getTables(e={withInternalKyselyTables:!1}){let t=await this.#e.selectFrom(`sys.tables as tables`).leftJoin(`sys.schemas as table_schemas`,`table_schemas.schema_id`,`tables.schema_id`).innerJoin(`sys.columns as columns`,`columns.object_id`,`tables.object_id`).innerJoin(`sys.types as types`,`types.user_type_id`,`columns.user_type_id`).leftJoin(`sys.schemas as type_schemas`,`type_schemas.schema_id`,`types.schema_id`).leftJoin(`sys.extended_properties as comments`,e=>e.onRef(`comments.major_id`,`=`,`tables.object_id`).onRef(`comments.minor_id`,`=`,`columns.column_id`).on(`comments.name`,`=`,`MS_Description`)).$if(!e.withInternalKyselyTables,e=>e.where(`tables.name`,`!=`,$).where(`tables.name`,`!=`,nn)).select([`tables.name as table_name`,e=>e.ref(`tables.type`).$castTo().as(`table_type`),`table_schemas.name as table_schema_name`,`columns.default_object_id as column_default_object_id`,`columns.generated_always_type_desc as column_generated_always_type`,`columns.is_computed as column_is_computed`,`columns.is_identity as column_is_identity`,`columns.is_nullable as column_is_nullable`,`columns.is_rowguidcol as column_is_rowguidcol`,`columns.name as column_name`,`types.is_nullable as type_is_nullable`,`types.name as type_name`,`type_schemas.name as type_schema_name`,`comments.value as column_comment`]).unionAll(this.#e.selectFrom(`sys.views as views`).leftJoin(`sys.schemas as view_schemas`,`view_schemas.schema_id`,`views.schema_id`).innerJoin(`sys.columns as columns`,`columns.object_id`,`views.object_id`).innerJoin(`sys.types as types`,`types.user_type_id`,`columns.user_type_id`).leftJoin(`sys.schemas as type_schemas`,`type_schemas.schema_id`,`types.schema_id`).leftJoin(`sys.extended_properties as comments`,e=>e.onRef(`comments.major_id`,`=`,`views.object_id`).onRef(`comments.minor_id`,`=`,`columns.column_id`).on(`comments.name`,`=`,`MS_Description`)).select([`views.name as table_name`,`views.type as table_type`,`view_schemas.name as table_schema_name`,`columns.default_object_id as column_default_object_id`,`columns.generated_always_type_desc as column_generated_always_type`,`columns.is_computed as column_is_computed`,`columns.is_identity as column_is_identity`,`columns.is_nullable as column_is_nullable`,`columns.is_rowguidcol as column_is_rowguidcol`,`columns.name as column_name`,`types.is_nullable as type_is_nullable`,`types.name as type_name`,`type_schemas.name as type_schema_name`,`comments.value as column_comment`])).orderBy(`table_schema_name`).orderBy(`table_name`).orderBy(`column_name`).execute(),n={};for(let e of t){let t=`${e.table_schema_name}.${e.table_name}`;(n[t]=n[t]||k({columns:[],isForeign:!1,isView:e.table_type===`V `,name:e.table_name,schema:e.table_schema_name??void 0})).columns.push(k({dataType:e.type_name,dataTypeSchema:e.type_schema_name??void 0,hasDefaultValue:e.column_default_object_id>0||e.column_generated_always_type!==`NOT_APPLICABLE`||e.column_is_identity||e.column_is_computed||e.column_is_rowguidcol,isAutoIncrementing:e.column_is_identity,isNullable:e.column_is_nullable&&e.type_is_nullable,name:e.column_name,comment:e.column_comment??void 0}))}return Object.values(n)}};const Ln=/^[a-z0-9_]$/i;var Rn=class extends he{getCurrentParameterPlaceholder(){return`@${this.numParameters}`}visitOffset(e){super.visitOffset(e),this.append(` rows`)}compileColumnAlterations(e){let t={};for(let n of e)t[n.kind]||(t[n.kind]=[]),t[n.kind].push(n);let n=!0;t.AddColumnNode&&(this.append(`add `),this.compileList(t.AddColumnNode),n=!1),t.AlterColumnNode&&(n||this.append(`, `),this.compileList(t.AlterColumnNode)),t.DropColumnNode&&(n||this.append(`, `),this.append(`drop `),this.compileList(t.DropColumnNode),n=!1),t.ModifyColumnNode&&(n||this.append(`, `),this.compileList(t.ModifyColumnNode)),t.RenameColumnNode&&(n||this.append(`, `),this.compileList(t.RenameColumnNode))}visitAddColumn(e){this.visitNode(e.column)}visitDropColumn(e){this.append(`column `),e.ifExists&&this.append(`if exists `),this.visitNode(e.column)}visitMergeQuery(e){super.visitMergeQuery(e),this.append(`;`)}visitCollate(e){this.append(`collate `);let{name:t}=e.collation;for(let e of t)if(!Ln.test(e))throw Error(`Invalid collation: ${t}`);this.append(t)}announcesNewColumnDataType(){return!1}},zn=class{#e;constructor(e){this.#e=e}createDriver(){return new Nn(this.#e)}createQueryCompiler(){return new Rn}createAdapter(){return new kn}createIntrospector(e){return new In(e)}};function Bn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Vn(e){if(!e)return null;if(`dialect`in e)return Vn(e.dialect);if(`createDriver`in e){if(e instanceof an)return`sqlite`;if(e instanceof yn)return`mysql`;if(e instanceof On)return`postgres`;if(e instanceof zn)return`mssql`}return`aggregate`in e?`sqlite`:`getConnection`in e?`mysql`:`connect`in e?`postgres`:`fileControl`in e||`open`in e&&`close`in e&&`prepare`in e||`batch`in e&&`exec`in e&&`prepare`in e?`sqlite`:null}function Hn(e,t){if(e!==void 0){if(typeof e!=`string`||e.length===0)throw new Te("`database.schemaName` must be a non-empty schema name.");if(t!==`postgres`)throw new Te(`\`database.schemaName\` is only supported on PostgreSQL, but the configured database type is "${t??`unknown`}".`)}}const Un=async e=>{let t=e.database;if(!t)return{kysely:null,databaseType:null,introspectIndexes:void 0,schemaName:void 0,transaction:void 0};if(`db`in t){let e=t.schemaName;return Hn(e,t.type),{kysely:e?t.db.withSchema(e):t.db,databaseType:t.type,introspectIndexes:void 0,schemaName:e,transaction:t.transaction}}if(`dialect`in t){let e=t.schemaName;Hn(e,t.type);let n=new Y({dialect:t.dialect});return{kysely:e?n.withSchema(e):n,databaseType:t.type,introspectIndexes:void 0,schemaName:e,transaction:t.transaction}}let n,r,i,a=Vn(t);if(`createDriver`in t&&(n=t),`aggregate`in t&&!(`createSession`in t)&&(n=new an({database:t}),i=!0),`getConnection`in t&&(n=new yn(t),i=!0),`connect`in t&&(n=new On({pool:t}),i=!0),`fileControl`in t){let{BunSqliteDialect:e}=await import(`./bun-sqlite-dialect-DoOVo4ja-DD-Erl56.mjs`);n=new e({database:t}),i=!0}if(`createSession`in t){let e;try{({DatabaseSync:e}=await import(
9
- /* @vite-ignore */
10
- /* webpackIgnore: true */
11
- `node:sqlite`))}catch(e){if(typeof e==`object`&&e&&`code`in e&&e.code!==`ERR_UNKNOWN_BUILTIN_MODULE`)throw e}if(e&&t instanceof e){let{NodeSqliteDialect:e}=await import(`./src-mhYy55vF.mjs`).then(e=>e.n);n=new e({database:t}),i=!0}}if(`batch`in t&&`exec`in t&&`prepare`in t){let{createD1IndexIntrospector:e,D1SqliteDialect:a}=await import(`./d1-sqlite-dialect-m0f01-4z-C492fKQn.mjs`);n=new a({database:t}),r=e(t),i=!1}return{kysely:n?new Y({dialect:n}):null,databaseType:a,introspectIndexes:r,schemaName:void 0,transaction:i}};function Wn(e,t,n){return n===`postgres`?C`${C.ref(e)} ILIKE ${t}`:C`LOWER(${C.ref(e)}) LIKE LOWER(${t})`}function Gn(e,t){return{lhs:C`LOWER(${C.ref(e)})`,values:t.map(e=>e.toLowerCase())}}function Kn(e,t){return{lhs:C`LOWER(${C.ref(e)})`,values:t.map(e=>e.toLowerCase())}}function qn(e,t){return{lhs:C`LOWER(${C.ref(e)})`,value:t.toLowerCase()}}function Jn(e,t){return{lhs:C`LOWER(${C.ref(e)})`,value:t.toLowerCase()}}function Yn(e){return e.map(e=>({name:e.name,schema:e.schema,columns:e.columns.map(e=>({name:e.name,nullable:e.isNullable,hasDefault:e.hasDefaultValue||e.isAutoIncrementing}))}))}function Xn(e,t){let n={};for(let[r,i]of Object.entries(t)){let t=Object.entries(i.fields),a=Zn(e,r,[i.idColumn??`id`,...t.map(([e])=>e)]),o={};t.forEach(([e,t],n)=>{o[a.columns[n+1]??e]=t}),n[a.table]={...i,fields:o,schema:a.schema??i.schema,...a.columns[0]!==`id`&&{idColumn:a.columns[0]}}}return n}function Zn(e,t,r){let{query:a}=e.selectFrom(t).select(r).compile();if(!i.is(a))return{table:t,columns:[]};let o=a.from?.froms[0],s=o&&c.is(o)?o.table:void 0;return{schema:s?.schema?.name,table:s?.identifier.name??t,columns:(a.selections??[]).map(({selection:e})=>ee.is(e)&&n.is(e.column)?e.column.column.name:void 0)}}async function Qn(e){return(await C`
12
- SELECT pg_catalog.current_schema() AS schema
13
- `.execute(e.withoutPlugins())).rows[0]?.schema??`public`}async function $n(e){return(await C`
14
- SELECT SCHEMA_NAME() AS "schemaName"
15
- `.execute(e.withoutPlugins())).rows[0]?.schemaName||`dbo`}async function er(e,t){if(t===`postgres`)return(await C`
16
- SELECT pg_catalog.current_schemas(true)::text[] AS schemas
17
- `.execute(e.withoutPlugins())).rows[0]?.schemas??[];if(t===`mssql`)return[await $n(e),`dbo`]}async function tr(e,t,n){let r=Xn(e,n);return t===`sqlite`?Ee(r,Yn(await ue(e,Object.entries(r).flatMap(([e,t])=>t.disableMigrations?[]:[e])))):e.connection().execute(async e=>{let n=await er(e,t),i=Yn(await e.introspection.getTables());for(let[e,t]of Object.entries(r))t.schema===void 0&&n&&(t.schema=n.find(t=>i.some(n=>n.name===e&&n.schema===t))??``);return Ee(r,i)})}const nr=(e,t)=>{let n=null,r=!1,i=(e,n=!1)=>({getFieldName:i,schema:a,getDefaultFieldName:o,getDefaultModelName:s,getFieldAttributes:c,getModelName:l,options:u})=>{t?.type===`mysql`&&u.advanced?.database?.generateId===!1&&!r&&(r=!0,we.warn(`[Kysely Adapter] MySQL does not support INSERT...RETURNING. With generateId set to false, the adapter uses best-effort fallback strategies (unique columns, full-field match) to retrieve inserted rows. For reliable behavior, use Better Auth's default ID generation, a custom generateId function, or generateId: "serial" for auto-increment.`));let d=e=>{let t=[],n=[];if(e)for(let[r,i]of Object.entries(e)){let e=a[i.modelKey??s(r)]?.fields,[o,c]=r.includes(`.`)?r.split(`.`):[void 0,r];if(e){e.id={type:`string`};for(let[i,a]of Object.entries(e))t.push(C`${C.ref(`join_${c}`)}.${C.ref(a.fieldName||i)} as ${C.ref(`_joined_${c}_${a.fieldName||i}`)}`),n.push({joinModel:r,joinModelRef:c,fieldName:a.fieldName||i})}}return{allSelectsStr:n,allSelects:t}},f=async(r,o,s,c,l)=>{if(t?.type===`mysql`){if(l.length>0){let t=await o.executeTakeFirst();if(!t||Number(t.numUpdatedRows??0)===0)return null;let n=l.find(e=>e.field===`id`&&(e.operator===void 0||e.operator===`eq`)&&e.connector!==`OR`&&e.value!==void 0&&e.value!==null),a,u;if(r.id!==void 0&&r.id!==null)a=`id`,u=r.id;else if(n)a=`id`,u=n.value;else if(l[0]?.field)a=l[0].field,u=r[a]===void 0?l[0].value:r[a];else return null;return await e.selectFrom(s).selectAll().where(i({model:c,field:a}),u===null?`is`:`=`,u).limit(1).executeTakeFirst()}await o.execute();let t=async e=>{if(r.id)return await e.selectFrom(s).selectAll().where(i({model:c,field:`id`}),`=`,r.id).limit(1).executeTakeFirst();if(u.advanced?.database?.generateId===`serial`){let t=(await C`SELECT LAST_INSERT_ID() as id`.execute(e)).rows[0]?.id;if(t)return await e.selectFrom(s).selectAll().where(i({model:c,field:`id`}),`=`,t).limit(1).executeTakeFirst()}let t=a[c]?.fields;if(t)for(let[n,a]of Object.entries(t)){if(!a.unique)continue;let t=i({model:c,field:n}),o=r[t];if(o==null)continue;let l=await e.selectFrom(s).selectAll().where(t,`=`,o).limit(1).executeTakeFirst();if(l)return l}let n=e.selectFrom(s).selectAll(),o=!1;for(let[e,t]of Object.entries(r))t!==void 0&&(n=n.where(e,t===null?`is`:`=`,t),o=!0);if(o){let e=await n.limit(2).execute();if(e.length===1)return e[0]}return we.warn(`[Kysely Adapter] Unable to safely identify the inserted "${s}" row on MySQL. Enable Better Auth ID generation or use generateId: "serial" for reliable behavior.`),null};return n?t(e):e.transaction().execute(t)}return t?.type===`mssql`?await o.outputAll(`inserted`).executeTakeFirst():await o.returningAll().executeTakeFirst()};function p(e,n,r){if(!r)return{and:null,or:null};let a={and:[],or:[]};return r.forEach(r=>{let{field:o,value:s,operator:c=`eq`,connector:l=`AND`,mode:u=`sensitive`}=r,d=s,f=i({model:n,field:o}),p=u===`insensitive`&&(typeof d==`string`||Array.isArray(d)&&d.every(e=>typeof e==`string`)),m=n=>{let r=`${e}.${f}`;if(c.toLowerCase()===`in`){if(p){let{lhs:e,values:t}=Gn(r,Array.isArray(d)?d:[d]);return n(e,`in`,t)}return n(r,`in`,Array.isArray(d)?d:[d])}if(c.toLowerCase()===`not_in`){if(p){let{lhs:e,values:t}=Kn(r,Array.isArray(d)?d:[d]);return n(e,`not in`,t)}return n(r,`not in`,Array.isArray(d)?d:[d])}if(c===`contains`)return p&&typeof d==`string`?Wn(r,`%${d}%`,t?.type):n(r,`like`,`%${d}%`);if(c===`starts_with`)return p&&typeof d==`string`?Wn(r,`${d}%`,t?.type):n(r,`like`,`${d}%`);if(c===`ends_with`)return p&&typeof d==`string`?Wn(r,`%${d}`,t?.type):n(r,`like`,`%${d}`);if(c===`eq`){if(d===null)return n(r,`is`,null);if(p&&typeof d==`string`){let{lhs:e,value:t}=qn(r,d);return n(e,`=`,t)}return n(r,`=`,d)}if(c===`ne`){if(d===null)return n(r,`is not`,null);if(p&&typeof d==`string`){let{lhs:e,value:t}=Jn(r,d);return n(e,`<>`,t)}return n(r,`<>`,d)}return c===`gt`?n(r,`>`,d):c===`gte`?n(r,`>=`,d):c===`lt`?n(r,`<`,d):c===`lte`?n(r,`<=`,d):n(r,c,d)};l===`OR`?a.or.push(m):a.and.push(m)}),{and:a.and.length?a.and:null,or:a.or.length?a.or:null}}function m(e,t,n){if(!t||!e.length)return e;let r=/* @__PURE__ */ new Map;for(let a of e){let e={},o={};for(let[e]of Object.entries(t))o[e]={};for(let[r,s]of Object.entries(a)){let a=String(r),c=!1;for(let{joinModel:e,fieldName:r,joinModelRef:l}of n)if(a===`_joined_${l}_${r}`||a===`_Joined${Bn(l)}${Bn(r)}`){o[e][i({model:t[e]?.modelKey??e,field:r})]=s,c=!0;break}c||(e[r]=s)}let s=e.id;if(!s)continue;if(!r.has(s)){let n={...e};for(let[e,r]of Object.entries(t))n[e]=r.relation===`one-to-one`?null:[];r.set(s,n)}let c=r.get(s);for(let[e,n]of Object.entries(t)){let t=n.relation===`one-to-one`,r=n.limit??100,a=o[e],s=a&&Object.keys(a).length>0&&Object.values(a).some(e=>e!=null);if(t)c[e]=s?a:null;else{let t=e;if(Array.isArray(c[t])&&s){if(c[t].length>=r)continue;let o=i({model:n.modelKey??e,field:`id`}),s=a[o];s?!c[t].some(e=>e[o]===s)&&c[t].length<r&&c[t].push(a):c[t].length<r&&c[t].push(a)}}}}let a=Array.from(r.values());for(let e of a)for(let[n,r]of Object.entries(t))if(r.relation!==`one-to-one`){let t=n;if(Array.isArray(e[t])){let n=r.limit??100;e[t].length>n&&(e[t]=e[t].slice(0,n))}}return a}return{async create({data:t,model:n,modelKey:r=n}){return await f(t,e.insertInto(n).values(t),n,r,[])},async findOne({model:t,modelKey:n=t,where:r,select:a,join:o}){let{and:s,or:c}=p(t,n,r),l=e.selectFrom(e=>{let r=e.selectFrom(t);return s&&(r=r.where(e=>e.and(s.map(t=>t(e))))),c&&(r=r.where(e=>e.or(c.map(t=>t(e))))),r=a?.length&&a.length>0?r.select(a.map(e=>i({model:n,field:e}))):r.selectAll(),r.as(`primary`)}).selectAll(`primary`);if(o)for(let[e,t]of Object.entries(o)){let[n,r]=e.includes(`.`)?e.split(`.`):[void 0,e];l=l.leftJoin(`${e} as join_${r}`,e=>e.onRef(`join_${r}.${t.on.to}`,`=`,`primary.${t.on.from}`))}let{allSelectsStr:u,allSelects:f}=d(o);l=l.select(f);let h=await l.execute();if(!h||!Array.isArray(h)||h.length===0)return null;let g=h[0];return o?m(h,o,u)[0]:g},async findMany({model:n,modelKey:r=n,where:a,limit:o,select:s,offset:c,sortBy:l,join:u}){let{and:f,or:h}=p(n,r,a),g=e.selectFrom(e=>{let a=e.selectFrom(n);return t?.type===`mssql`?c===void 0?o!==void 0&&(a=a.top(o)):(l||(a=a.orderBy(i({model:r,field:`id`}))),a=a.offset(c).fetch(o||100)):(o!==void 0&&(a=a.limit(o)),c!==void 0&&(a=a.offset(c))),l?.field&&(a=a.orderBy(`${i({model:r,field:l.field})}`,l.direction)),f&&(a=a.where(e=>e.and(f.map(t=>t(e))))),h&&(a=a.where(e=>e.or(h.map(t=>t(e))))),a=s?.length&&s.length>0?a.select(s.map(e=>i({model:r,field:e}))):a.selectAll(),a.as(`primary`)}).selectAll(`primary`);if(u)for(let[e,t]of Object.entries(u)){let[n,r]=e.includes(`.`)?e.split(`.`):[void 0,e];g=g.leftJoin(`${e} as join_${r}`,e=>e.onRef(`join_${r}.${t.on.to}`,`=`,`primary.${t.on.from}`))}let{allSelectsStr:_,allSelects:ee}=d(u);g=g.select(ee),l?.field&&(g=g.orderBy(`${i({model:r,field:l.field})}`,l.direction));let v=await g.execute();return v?u?m(v,u,_):v:[]},async update({model:t,modelKey:n=t,where:r,update:i}){if(r.length===0)return null;let{and:a,or:o}=p(t,n,r),s=e.updateTable(t).set(i);return a&&(s=s.where(e=>e.and(a.map(t=>t(e))))),o&&(s=s.where(e=>e.or(o.map(t=>t(e))))),await f(i,s,t,n,r)},async updateMany({model:t,modelKey:n=t,where:r,update:i}){let{and:a,or:o}=p(t,n,r),s=e.updateTable(t).set(i);a&&(s=s.where(e=>e.and(a.map(t=>t(e))))),o&&(s=s.where(e=>e.or(o.map(t=>t(e)))));let c=(await s.executeTakeFirst()).numUpdatedRows;return c>2**53-1?2**53-1:Number(c)},async count({model:t,modelKey:n=t,where:r}){let{and:i,or:a}=p(t,n,r),o=e.selectFrom(t).select(e.fn.count(`id`).as(`count`));i&&(o=o.where(e=>e.and(i.map(t=>t(e))))),a&&(o=o.where(e=>e.or(a.map(t=>t(e)))));let s=await o.execute();return typeof s[0].count==`number`?s[0].count:typeof s[0].count==`bigint`?Number(s[0].count):parseInt(s[0].count)},async delete({model:t,modelKey:n=t,where:r}){let{and:i,or:a}=p(t,n,r),o=e.deleteFrom(t);i&&(o=o.where(e=>e.and(i.map(t=>t(e))))),a&&(o=o.where(e=>e.or(a.map(t=>t(e))))),await o.execute()},async deleteMany({model:t,modelKey:n=t,where:r}){let{and:i,or:a}=p(t,n,r),o=e.deleteFrom(t);i&&(o=o.where(e=>e.and(i.map(t=>t(e))))),a&&(o=o.where(e=>e.or(a.map(t=>t(e)))));let s=(await o.executeTakeFirst()).numDeletedRows;return s>2**53-1?2**53-1:Number(s)},async consumeOne({model:r,modelKey:a=r,where:o}){let{and:s,or:c}=p(r,a,o),l=e=>(s&&(e=e.where(e=>e.and(s.map(t=>t(e))))),c&&(e=e.where(e=>e.or(c.map(t=>t(e))))),e),u=i({model:a,field:`id`}),d=async(e,n)=>{let i=n[u]??n.id;if(i==null)return null;let a=e.deleteFrom(r).where(`${r}.${u}`,`=`,i);if(t?.type===`mysql`){let e=await a.executeTakeFirst();return Number(e.numDeletedRows)>0?n:null}return t?.type===`mssql`?await a.outputAll(`deleted`).executeTakeFirst()??null:await a.returningAll().executeTakeFirst()??null},f=async e=>t?.type===`mssql`?await e.outputAll(`deleted`).executeTakeFirst()??null:await e.returningAll().executeTakeFirst()??null;if(t?.type===`mysql`){let t=async e=>{let t=await l(e.selectFrom(r).selectAll().forUpdate()).limit(1).executeTakeFirst();return t?d(e,t):null};return n?t(e):e.transaction().execute(t)}let m=l(e.selectFrom(r).select(`${r}.${u}`)),h=t?.type===`mssql`?m.top(1):m.limit(1);return f(l(e.deleteFrom(r).where(`${r}.${u}`,`in`,h)))},async incrementOne({model:r,modelKey:a=r,where:o,increment:s,set:c}){let{and:l,or:u}=p(r,a,o),d=e=>(l&&(e=e.where(e=>e.and(l.map(t=>t(e))))),u&&(e=e.where(e=>e.or(u.map(t=>t(e))))),e),f={...c??{}};for(let[e,t]of Object.entries(s))f[e]=C`${C.ref(e)} + ${t}`;let m=i({model:a,field:`id`});if(t?.type===`mysql`){let t=async e=>{let t=await d(e.selectFrom(r).select(`${r}.${m}`).forUpdate()).limit(1).executeTakeFirst();if(!t)return null;let n=t[m]??t.id;if(n==null)return null;let i=await d(e.updateTable(r).set(f)).where(`${r}.${m}`,`=`,n).executeTakeFirst();return Number(i.numUpdatedRows)===0?null:await e.selectFrom(r).selectAll().where(`${r}.${m}`,`=`,n).limit(1).executeTakeFirst()??null};return n?t(e):e.transaction().execute(t)}let h=d(e.selectFrom(r).select(`${r}.${m}`)),g=t?.type===`mssql`?h.top(1):h.limit(1),_=d(e.updateTable(r).set(f)).where(`${r}.${m}`,`in`,g);return t?.type===`mssql`?await _.outputAll(`inserted`).executeTakeFirst()??null:await _.returningAll().executeTakeFirst()??null},options:t}},a=null;a={config:{adapterId:`kysely`,adapterName:`Kysely Adapter`,usePlural:t?.usePlural,debugLogs:t?.debugLogs,supportsBooleans:!(t?.type===`sqlite`||t?.type===`mssql`||t?.type===`mysql`||!t?.type),supportsDates:!(t?.type===`sqlite`||t?.type===`mssql`||!t?.type),supportsJSON:t?.type===`postgres`,supportsArrays:!1,supportsUUIDs:t?.type===`postgres`,transaction:t?.transaction?t=>e.transaction().execute(e=>t(je({config:{...a.config,transaction:!1},adapter:i(e,!0)})(n))):!1},adapter:i(e)};let o=je(a);return r=>{n=r;let i=o(r);return De(i,Oe(()=>tr(e,t?.type,Ae(r,{usePlural:t?.usePlural})),`database`,r.database),{runtimeEnabled:ke(r)}),i}};export{nr as a,Y as c,Qn as i,Vn as n,Yn as o,$n as r,Xn as s,Un as t};