import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { MsSqlColumn } from "./common.js";
import { MsSqlDateColumnBaseBuilder } from "./date.common.js";
class MsSqlDateBuilder extends MsSqlDateColumnBaseBuilder {
  static [entityKind] = "MsSqlDateBuilder";
  constructor(name) {
    super(name, "date", "MsSqlDate");
  }
  /** @internal */
  build(table) {
    return new MsSqlDate(table, this.config);
  }
}
class MsSqlDate extends MsSqlColumn {
  static [entityKind] = "MsSqlDate";
  constructor(table, config) {
    super(table, config);
  }
  getSQLType() {
    return `date`;
  }
  mapFromDriverValue(value) {
    return new Date(value);
  }
}
class MsSqlDateStringBuilder extends MsSqlDateColumnBaseBuilder {
  static [entityKind] = "MsSqlDateStringBuilder";
  constructor(name) {
    super(name, "string", "MsSqlDateString");
  }
  /** @internal */
  build(table) {
    return new MsSqlDateString(
      table,
      this.config
    );
  }
}
class MsSqlDateString extends MsSqlColumn {
  static [entityKind] = "MsSqlDateString";
  constructor(table, config) {
    super(table, config);
  }
  getSQLType() {
    return `date`;
  }
  mapFromDriverValue(value) {
    return typeof value === "string" ? value : value?.toISOString().split("T")[0] ?? null;
  }
}
function date(a, b) {
  const { name, config } = getColumnNameAndConfig(a, b);
  if (config?.mode === "string") {
    return new MsSqlDateStringBuilder(name);
  }
  return new MsSqlDateBuilder(name);
}
export {
  MsSqlDate,
  MsSqlDateBuilder,
  MsSqlDateString,
  MsSqlDateStringBuilder,
  date
};
//# sourceMappingURL=date.js.map