const pgToZqlNumericTypeMap = Object.freeze({
  "smallint": "number",
  "integer": "number",
  "int": "number",
  "int2": "number",
  "int4": "number",
  "int8": "number",
  "bigint": "number",
  "smallserial": "number",
  "serial": "number",
  "serial2": "number",
  "serial4": "number",
  "serial8": "number",
  "bigserial": "number",
  "decimal": "number",
  "numeric": "number",
  "real": "number",
  "double precision": "number",
  "float": "number",
  "float4": "number",
  "float8": "number"
});
function isPgNumberType(pgType) {
  return Object.hasOwn(pgToZqlNumericTypeMap, formatTypeForLookup(pgType));
}
const pgToZqlStringTypeMap = Object.freeze({
  "bpchar": "string",
  "character": "string",
  "character varying": "string",
  "text": "string",
  "uuid": "string",
  "varchar": "string"
});
function isPgStringType(pgType) {
  return Object.hasOwn(pgToZqlStringTypeMap, formatTypeForLookup(pgType));
}
const pgToZqlTypeMap = Object.freeze({
  // Numeric types
  ...pgToZqlNumericTypeMap,
  // Date/Time types
  "date": "number",
  "time": "number",
  "time with time zone": "number",
  "time without time zone": "number",
  "timestamp": "number",
  "timestamptz": "number",
  "timestamp with time zone": "number",
  "timestamp without time zone": "number",
  // String types
  ...pgToZqlStringTypeMap,
  // Boolean types
  "bool": "boolean",
  "boolean": "boolean",
  "json": "json",
  "jsonb": "json"
  // TODO: Add support for these.
  // 'bytea':
});
function dataTypeToZqlValueType(pgType, isEnum, isArray) {
  if (isArray) {
    return "json";
  }
  const valueType = pgToZqlTypeMap[formatTypeForLookup(pgType)];
  if (valueType === void 0 && isEnum) {
    return "string";
  }
  return valueType;
}
function formatTypeForLookup(pgType) {
  const startOfArgs = pgType.indexOf("(");
  if (startOfArgs === -1) {
    return pgType.toLocaleLowerCase();
  }
  return pgType.toLocaleLowerCase().substring(0, startOfArgs);
}
export {
  dataTypeToZqlValueType,
  isPgNumberType,
  isPgStringType,
  pgToZqlNumericTypeMap,
  pgToZqlStringTypeMap,
  pgToZqlTypeMap
};
//# sourceMappingURL=pg-data-type.js.map
