import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { MsSqlColumn, MsSqlColumnBuilder } from "./common.js";
class MsSqlTimeStringBuilder extends MsSqlColumnBuilder {
  static [entityKind] = "MsSqlTimeBuilder";
  constructor(name, config) {
    super(name, "string", "MsSqlTime");
    this.config.precision = config?.precision;
  }
  /** @internal */
  build(table) {
    return new MsSqlTimeString(
      table,
      this.config
    );
  }
}
class MsSqlTimeString extends MsSqlColumn {
  static [entityKind] = "MsSqlTime";
  fsp = this.config.precision;
  getSQLType() {
    const precision = this.fsp === void 0 ? "" : `(${this.fsp})`;
    return `time${precision}`;
  }
  mapFromDriverValue(value) {
    return typeof value === "string" ? value : value?.toISOString().split("T")[1]?.split("Z")[0] ?? null;
  }
}
class MsSqlTimeBuilder extends MsSqlColumnBuilder {
  static [entityKind] = "MsSqlTimeBuilder";
  constructor(name, config) {
    super(name, "date", "MsSqlTime");
    this.config.precision = config?.precision;
  }
  /** @internal */
  build(table) {
    return new MsSqlTime(table, this.config);
  }
}
class MsSqlTime extends MsSqlColumn {
  static [entityKind] = "MsSqlTime";
  fsp = this.config.precision;
  getSQLType() {
    const precision = this.fsp === void 0 ? "" : `(${this.fsp})`;
    return `time${precision}`;
  }
}
function time(a, b) {
  const { name, config } = getColumnNameAndConfig(a, b);
  if (config?.mode === "string") {
    return new MsSqlTimeStringBuilder(name, config);
  }
  return new MsSqlTimeBuilder(name, config);
}
export {
  MsSqlTime,
  MsSqlTimeBuilder,
  MsSqlTimeString,
  MsSqlTimeStringBuilder,
  time
};
//# sourceMappingURL=time.js.map