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