import { s as sql, i as is, C as Column } from './utils-BvHPJOVk.js';
export { B as BaseName, a as CONSTANTS, b as ColumnBuilder, E as ExtraConfigBuilder, c as ExtraConfigColumns, F as FakePrimitiveParam, d as FnConstructor, I as IsAlias, N as Name, O as OriginalName, P as Param, f as Placeholder, S as SQL, g as StringChunk, h as Subquery, j as Table, k as TableColumns, l as TableSchema, V as View, m as ViewBaseConfig, W as WithSubquery, n as applyMixins, o as assertUnreachable, p as base64ToUint8Array, e as entityKind, q as extractExtendedColumnType, r as fillPlaceholders, t as getColumnNameAndConfig, u as getColumnTable, v as getColumns, w as getTableColumns, x as getTableLikeName, y as getTableName, z as getTableUniqueName, A as getViewName, D as getViewSelectedFields, G as hasOwnEntityKind, H as haveSameKeys, J as isConfig, K as isDriverValueEncoder, L as isNoop, M as isSQLWrapper, Q as isTable, R as isView, U as isWithEnum, X as jitCompatCheck, Y as make$ReturningResponseMapper, Z as makeDefaultQueryMapper, _ as makeJitQueryMapper, $ as mapResultRow, a0 as mapUpdateSet, a1 as name, a2 as noopDecoder, a3 as noopEncoder, a4 as noopMapper, a5 as orderSelectedFields, a6 as param, a7 as placeholder, a8 as sqlCommenter, a9 as textDecoder } from './utils-BvHPJOVk.js';
import { e as eq, d as desc, a as and, k as lte, g as gte, o as or, i as inArray, m as isNotNull } from './logger-ChCwlV5k.js';
export { A as AggregatedField, C as ColumnAliasProxyHandler, p as ColumnTableAliasProxyHandler, q as ConsoleLogWriter, r as Count, D as DefaultLogger, s as DrizzleError, t as DrizzleQueryError, M as Many, N as NoopLogger, O as One, Q as QueryPromise, R as Relation, u as RelationTableAliasProxyHandler, v as RelationsBuilderColumn, w as RelationsBuilderJunctionColumn, x as RelationsBuilderTable, y as RelationsHelperStatic, T as TableAliasProxyHandler, z as TransactionRollbackError, V as ViewSelectionAliasProxyHandler, B as aliasedColumn, E as aliasedRelation, F as aliasedTable, G as aliasedTableColumn, H as arrayContained, I as arrayContains, J as arrayOverlaps, f as asc, K as between, L as bindIfParam, P as buildRelations, S as buildRelationsParts, U as createRelationsHelper, W as defineRelations, X as defineRelationsPart, Y as exists, Z as extractTablesFromSchema, _ as fieldSelectionToSQL, $ as getOrderByOperators, a0 as getOriginalColumnFromAlias, a1 as getTableAsAliasSQL, h as gt, a2 as ilike, c as isNull, l as like, j as lt, a3 as makeDefaultRqbMapper, a4 as makeJitRqbMapper, a5 as mapColumnsInAliasedSQLToAlias, a6 as mapColumnsInSQLToAlias, a7 as mapRelationalRow, a8 as mapRelationalRowFromArrays, n as ne, a9 as not, aa as notBetween, ab as notExists, ac as notIlike, b as notInArray, ad as notLike, ae as operators, af as orderByOperators, ag as processRelations, ah as relationExtrasToSQL, ai as relationToSQL, aj as relationsFilterToSQL, ak as relationsOrderToSQL } from './logger-ChCwlV5k.js';

//#region src/sql/functions/aggregate.ts
/**
* Returns the number of values in `expression`.
*
* ## Examples
*
* ```ts
* // Number employees with null values
* db.select({ value: count() }).from(employees)
* // Number of employees where `name` is not null
* db.select({ value: count(employees.name) }).from(employees)
* ```
*
* @see countDistinct to get the number of non-duplicate values in `expression`
*/
function count(expression) {
	return sql`count(${expression || sql.raw("*")})`.mapWith(Number);
}
/**
* Returns the number of non-duplicate values in `expression`.
*
* ## Examples
*
* ```ts
* // Number of employees where `name` is distinct
* db.select({ value: countDistinct(employees.name) }).from(employees)
* ```
*
* @see count to get the number of values in `expression`, including duplicates
*/
function countDistinct(expression) {
	return sql`count(distinct ${expression})`.mapWith(Number);
}
/**
* Returns the average (arithmetic mean) of all non-null values in `expression`.
*
* ## Examples
*
* ```ts
* // Average salary of an employee
* db.select({ value: avg(employees.salary) }).from(employees)
* ```
*
* @see avgDistinct to get the average of all non-null and non-duplicate values in `expression`
*/
function avg(expression) {
	return sql`avg(${expression})`.mapWith(String);
}
/**
* Returns the average (arithmetic mean) of all non-null and non-duplicate values in `expression`.
*
* ## Examples
*
* ```ts
* // Average salary of an employee where `salary` is distinct
* db.select({ value: avgDistinct(employees.salary) }).from(employees)
* ```
*
* @see avg to get the average of all non-null values in `expression`, including duplicates
*/
function avgDistinct(expression) {
	return sql`avg(distinct ${expression})`.mapWith(String);
}
/**
* Returns the sum of all non-null values in `expression`.
*
* ## Examples
*
* ```ts
* // Sum of every employee's salary
* db.select({ value: sum(employees.salary) }).from(employees)
* ```
*
* @see sumDistinct to get the sum of all non-null and non-duplicate values in `expression`
*/
function sum(expression) {
	return sql`sum(${expression})`.mapWith(String);
}
/**
* Returns the sum of all non-null and non-duplicate values in `expression`.
*
* ## Examples
*
* ```ts
* // Sum of every employee's salary where `salary` is distinct (no duplicates)
* db.select({ value: sumDistinct(employees.salary) }).from(employees)
* ```
*
* @see sum to get the sum of all non-null values in `expression`, including duplicates
*/
function sumDistinct(expression) {
	return sql`sum(distinct ${expression})`.mapWith(String);
}
/**
* Returns the maximum value in `expression`.
*
* ## Examples
*
* ```ts
* // The employee with the highest salary
* db.select({ value: max(employees.salary) }).from(employees)
* ```
*/
function max(expression) {
	return sql`max(${expression})`.mapWith(is(expression, Column) ? expression : String);
}
/**
* Returns the minimum value in `expression`.
*
* ## Examples
*
* ```ts
* // The employee with the lowest salary
* db.select({ value: min(employees.salary) }).from(employees)
* ```
*/
function min(expression) {
	return sql`min(${expression})`.mapWith(is(expression, Column) ? expression : String);
}

//#region src/sql/functions/vector.ts
function toSql(value) {
	return JSON.stringify(value);
}
/**
* Used in sorting and in querying, if used in sorting,
* this specifies that the given column or expression should be sorted in an order
* that minimizes the L2 distance to the given value.
* If used in querying, this specifies that it should return the L2 distance
* between the given column or expression and the given value.
*
* ## Examples
*
* ```ts
* // Sort cars by embedding similarity
* // to the given embedding
* db.select().from(cars)
*   .orderBy(l2Distance(cars.embedding, embedding));
* ```
*
* ```ts
* // Select distance of cars and embedding
* // to the given embedding
* db.select({distance: l2Distance(cars.embedding, embedding)}).from(cars)
* ```
*/
function l2Distance(column, value) {
	if (Array.isArray(value)) return sql`${column} <-> ${toSql(value)}`;
	return sql`${column} <-> ${value}`;
}
/**
* L1 distance is one of the possible distance measures between two probability distribution vectors and it is
* calculated as the sum of the absolute differences.
* The smaller the distance between the observed probability vectors, the higher the accuracy of the synthetic data
*
* ## Examples
*
* ```ts
* // Sort cars by embedding similarity
* // to the given embedding
* db.select().from(cars)
*   .orderBy(l1Distance(cars.embedding, embedding));
* ```
*
* ```ts
* // Select distance of cars and embedding
* // to the given embedding
* db.select({distance: l1Distance(cars.embedding, embedding)}).from(cars)
* ```
*/
function l1Distance(column, value) {
	if (Array.isArray(value)) return sql`${column} <+> ${toSql(value)}`;
	return sql`${column} <+> ${value}`;
}
/**
* Used in sorting and in querying, if used in sorting,
* this specifies that the given column or expression should be sorted in an order
* that minimizes the inner product distance to the given value.
* If used in querying, this specifies that it should return the inner product distance
* between the given column or expression and the given value.
*
* ## Examples
*
* ```ts
* // Sort cars by embedding similarity
* // to the given embedding
* db.select().from(cars)
*   .orderBy(innerProduct(cars.embedding, embedding));
* ```
*
* ```ts
* // Select distance of cars and embedding
* // to the given embedding
* db.select({ distance: innerProduct(cars.embedding, embedding) }).from(cars)
* ```
*/
function innerProduct(column, value) {
	if (Array.isArray(value)) return sql`${column} <#> ${toSql(value)}`;
	return sql`${column} <#> ${value}`;
}
/**
* Used in sorting and in querying, if used in sorting,
* this specifies that the given column or expression should be sorted in an order
* that minimizes the cosine distance to the given value.
* If used in querying, this specifies that it should return the cosine distance
* between the given column or expression and the given value.
*
* ## Examples
*
* ```ts
* // Sort cars by embedding similarity
* // to the given embedding
* db.select().from(cars)
*   .orderBy(cosineDistance(cars.embedding, embedding));
* ```
*
* ```ts
* // Select distance of cars and embedding
* // to the given embedding
* db.select({distance: cosineDistance(cars.embedding, embedding)}).from(cars)
* ```
*/
function cosineDistance(column, value) {
	if (Array.isArray(value)) return sql`${column} <=> ${toSql(value)}`;
	return sql`${column} <=> ${value}`;
}
/**
* Hamming distance between two strings or vectors of equal length is the number of positions at which the
* corresponding symbols are different. In other words, it measures the minimum number of
* substitutions required to change one string into the other, or equivalently,
* the minimum number of errors that could have transformed one string into the other
*
* ## Examples
*
* ```ts
* // Sort cars by embedding similarity
* // to the given embedding
* db.select().from(cars)
*   .orderBy(hammingDistance(cars.embedding, embedding));
* ```
*/
function hammingDistance(column, value) {
	if (Array.isArray(value)) return sql`${column} <~> ${toSql(value)}`;
	return sql`${column} <~> ${value}`;
}
/**
* ## Examples
*
* ```ts
* // Sort cars by embedding similarity
* // to the given embedding
* db.select().from(cars)
*   .orderBy(jaccardDistance(cars.embedding, embedding));
* ```
*/
function jaccardDistance(column, value) {
	if (Array.isArray(value)) return sql`${column} <%> ${toSql(value)}`;
	return sql`${column} <%> ${value}`;
}

export { Column, and, avg, avgDistinct, cosineDistance, count, countDistinct, desc, eq, gte, hammingDistance, inArray, innerProduct, is, isNotNull, jaccardDistance, l1Distance, l2Distance, lte, max, min, or, sql, sum, sumDistinct };
//# sourceMappingURL=index-DIWrtHjY.js.map
