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