"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const continuous = require("./src-continuous.cjs");
const init = require("./src-init.cjs");
const nice = require("./src-nice.cjs");
const defaultLocale = require("../d3-time-format/src-defaultLocale.cjs");
const second = require("../d3-time/src-second.cjs");
const minute = require("../d3-time/src-minute.cjs");
const hour = require("../d3-time/src-hour.cjs");
const day = require("../d3-time/src-day.cjs");
const week = require("../d3-time/src-week.cjs");
const month = require("../d3-time/src-month.cjs");
const year = require("../d3-time/src-year.cjs");
const ticks = require("../d3-time/src-ticks.cjs");
function date(t) {
  return new Date(t);
}
function number(t) {
  return t instanceof Date ? +t : +/* @__PURE__ */ new Date(+t);
}
function calendar(ticks2, tickInterval, year2, month2, week2, day2, hour2, minute2, second2, format) {
  var scale = continuous.default(), invert = scale.invert, domain = scale.domain;
  var formatMillisecond = format(".%L"), formatSecond = format(":%S"), formatMinute = format("%I:%M"), formatHour = format("%I %p"), formatDay = format("%a %d"), formatWeek = format("%b %d"), formatMonth = format("%B"), formatYear = format("%Y");
  function tickFormat(date2) {
    return (second2(date2) < date2 ? formatMillisecond : minute2(date2) < date2 ? formatSecond : hour2(date2) < date2 ? formatMinute : day2(date2) < date2 ? formatHour : month2(date2) < date2 ? week2(date2) < date2 ? formatDay : formatWeek : year2(date2) < date2 ? formatMonth : formatYear)(date2);
  }
  scale.invert = function(y) {
    return new Date(invert(y));
  };
  scale.domain = function(_) {
    return arguments.length ? domain(Array.from(_, number)) : domain().map(date);
  };
  scale.ticks = function(interval) {
    var d = domain();
    return ticks2(d[0], d[d.length - 1], interval == null ? 10 : interval);
  };
  scale.tickFormat = function(count, specifier) {
    return specifier == null ? tickFormat : format(specifier);
  };
  scale.nice = function(interval) {
    var d = domain();
    if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval);
    return interval ? domain(nice.default(d, interval)) : scale;
  };
  scale.copy = function() {
    return continuous.copy(scale, calendar(ticks2, tickInterval, year2, month2, week2, day2, hour2, minute2, second2, format));
  };
  return scale;
}
function time() {
  return init.initRange.apply(calendar(ticks.timeTicks, ticks.timeTickInterval, year.timeYear, month.timeMonth, week.timeSunday, day.timeDay, hour.timeHour, minute.timeMinute, second.second, defaultLocale.timeFormat).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
exports.calendar = calendar;
exports.default = time;
//# sourceMappingURL=src-time.cjs.map
