import './index-BeUCYK3T.js';
import { Pattern, TagBase } from 'typia/lib/tags';
import { tags } from 'typia';

type ClickHousePrecision<P extends number> = {
    _clickhouse_precision?: P;
};
declare const DecimalRegex: "^-?\\d+(\\.\\d+)?$";
type ClickHouseDecimal<P extends number, S extends number> = {
    _clickhouse_precision?: P;
    _clickhouse_scale?: S;
} & Pattern<typeof DecimalRegex>;
type ClickHouseFixedStringSize<N extends number> = {
    _clickhouse_fixed_string_size?: N;
};
/**
 * FixedString(N) - Fixed-length string of exactly N bytes.
 *
 * ClickHouse stores exactly N bytes, padding shorter values with null bytes.
 * Values exceeding N bytes will throw an exception.
 *
 * Use for binary data: hashes, IP addresses, UUIDs, MAC addresses.
 *
 * @example
 * interface BinaryData {
 *   md5_hash: string & FixedString<16>;    // 16-byte MD5
 *   sha256_hash: string & FixedString<32>; // 32-byte SHA256
 * }
 */
type FixedString<N extends number> = string & ClickHouseFixedStringSize<N>;
type ClickHouseByteSize<N extends number> = {
    _clickhouse_byte_size?: N;
};
type LowCardinality = {
    _LowCardinality?: true;
};
type DateTime = Date;
type DateTime64<P extends number> = Date & ClickHousePrecision<P>;
type DateTimeString = string & tags.Format<"date-time">;
/**
 * JS Date objects cannot hold microsecond precision.
 * Use string as the runtime type to avoid losing information.
 */
type DateTime64String<P extends number> = string & tags.Format<"date-time"> & ClickHousePrecision<P>;
type Float32 = number & ClickHouseFloat<"float32">;
type Float64 = number & ClickHouseFloat<"float64">;
type Int8 = number & ClickHouseInt<"int8">;
type Int16 = number & ClickHouseInt<"int16">;
type Int32 = number & ClickHouseInt<"int32">;
type Int64 = number & ClickHouseInt<"int64">;
type UInt8 = number & ClickHouseInt<"uint8">;
type UInt16 = number & ClickHouseInt<"uint16">;
type UInt32 = number & ClickHouseInt<"uint32">;
type UInt64 = number & ClickHouseInt<"uint64">;
type Decimal<P extends number, S extends number> = string & ClickHouseDecimal<P, S>;
/**
 * Attach compression codec to a column type.
 *
 * Any valid ClickHouse codec expression is allowed. ClickHouse validates the codec at runtime.
 *
 * @template T The base data type
 * @template CodecExpr The codec expression (single codec or chain)
 *
 * @example
 * interface Metrics {
 *   // Single codec
 *   log_blob: string & ClickHouseCodec<"ZSTD(3)">;
 *
 *   // Codec chain (processed left-to-right)
 *   timestamp: Date & ClickHouseCodec<"Delta, LZ4">;
 *   temperature: number & ClickHouseCodec<"Gorilla, ZSTD">;
 *
 *   // Specialized codecs
 *   counter: number & ClickHouseCodec<"DoubleDelta">;
 *
 *   // Can combine with other annotations
 *   count: UInt64 & ClickHouseCodec<"DoubleDelta, LZ4">;
 * }
 */
type ClickHouseCodec<CodecExpr extends string> = {
    _clickhouse_codec?: CodecExpr;
};
type ClickHouseFloat<Value extends "float32" | "float64"> = tags.Type<Value extends "float32" ? "float" : "double">;
type ClickHouseInt<Value extends "int8" | "int16" | "int32" | "int64" | "uint8" | "uint16" | "uint32" | "uint64"> = Value extends "int32" | "int64" | "uint32" | "uint64" ? tags.Type<Value> : TagBase<{
    target: "number";
    kind: "type";
    value: Value;
    validate: Value extends "int8" ? "-128 <= $input && $input <= 127" : Value extends "int16" ? "-32768 <= $input && $input <= 32767" : Value extends "uint8" ? "0 <= $input && $input <= 255" : Value extends "uint16" ? "0 <= $input && $input <= 65535" : never;
    exclusive: true;
    schema: {
        type: "integer";
    };
}>;
/**
 * By default, nested objects map to the `Nested` type in clickhouse.
 * Write `nestedObject: AnotherInterfaceType & ClickHouseNamedTuple`
 * to map AnotherInterfaceType to the named tuple type.
 */
type ClickHouseNamedTuple = {
    _clickhouse_mapped_type?: "namedTuple";
};
type ClickHouseJson<maxDynamicPaths extends number | undefined = undefined, maxDynamicTypes extends number | undefined = undefined, skipPaths extends string[] = [], skipRegexes extends string[] = []> = {
    _clickhouse_mapped_type?: "JSON";
    _clickhouse_json_settings?: {
        maxDynamicPaths?: maxDynamicPaths;
        maxDynamicTypes?: maxDynamicTypes;
        skipPaths?: skipPaths;
        skipRegexes?: skipRegexes;
    };
};
type ClickHousePoint = [number, number] & {
    _clickhouse_mapped_type?: "Point";
};
type ClickHouseRing = ClickHousePoint[] & {
    _clickhouse_mapped_type?: "Ring";
};
type ClickHouseLineString = ClickHousePoint[] & {
    _clickhouse_mapped_type?: "LineString";
};
type ClickHouseMultiLineString = ClickHouseLineString[] & {
    _clickhouse_mapped_type?: "MultiLineString";
};
type ClickHousePolygon = ClickHouseRing[] & {
    _clickhouse_mapped_type?: "Polygon";
};
type ClickHouseMultiPolygon = ClickHousePolygon[] & {
    _clickhouse_mapped_type?: "MultiPolygon";
};
/**
 * typia may have trouble handling this type.
 * In which case, use {@link WithDefault} as a workaround
 *
 * @example
 * { field: number & ClickHouseDefault<"0"> }
 */
type ClickHouseDefault<SqlExpression extends string> = {
    _clickhouse_default?: SqlExpression;
};
/**
 * @example
 * {
 *   ...
 *   timestamp: Date;
 *   debugMessage: string & ClickHouseTTL<"timestamp + INTERVAL 1 WEEK">;
 * }
 */
type ClickHouseTTL<SqlExpression extends string> = {
    _clickhouse_ttl?: SqlExpression;
};
/**
 * ClickHouse MATERIALIZED column annotation.
 * The column value is computed at INSERT time and physically stored.
 * Cannot be explicitly inserted by users.
 *
 * @example
 * interface Events {
 *   eventTime: DateTime;
 *   // Extract date component - computed and stored at insert time
 *   eventDate: Date & ClickHouseMaterialized<"toDate(event_time)">;
 *
 *   userId: string;
 *   // Precompute hash for fast lookups
 *   userHash: UInt64 & ClickHouseMaterialized<"cityHash64(userId)">;
 * }
 *
 * @remarks
 * - MATERIALIZED and DEFAULT are mutually exclusive
 * - Can be combined with ClickHouseCodec for compression
 * - Changing the expression modifies the column in-place (existing values preserved)
 */
type ClickHouseMaterialized<SqlExpression extends string> = {
    _clickhouse_materialized?: SqlExpression;
};
/**
 * See also {@link ClickHouseDefault}
 *
 * @example{ updated_at: WithDefault<Date, "now()"> }
 */
type WithDefault<T, _SqlExpression extends string> = T;

type Key<T extends string | number | Date> = T;
type JWT<T extends object> = T;

export type { UInt32 as A, UInt64 as B, ClickHouseByteSize as C, DateTime as D, Decimal as E, FixedString as F, Int8 as I, JWT as J, Key as K, LowCardinality as L, UInt8 as U, WithDefault as W, ClickHouseInt as a, ClickHouseNamedTuple as b, ClickHousePoint as c, ClickHouseRing as d, ClickHouseLineString as e, ClickHouseMultiLineString as f, ClickHousePolygon as g, ClickHouseMultiPolygon as h, ClickHousePrecision as i, ClickHouseDecimal as j, ClickHouseFixedStringSize as k, ClickHouseFloat as l, ClickHouseJson as m, ClickHouseDefault as n, ClickHouseTTL as o, ClickHouseMaterialized as p, ClickHouseCodec as q, DateTime64 as r, DateTimeString as s, DateTime64String as t, Float32 as u, Float64 as v, Int16 as w, Int32 as x, Int64 as y, UInt16 as z };
