import { __commonJSMin } from "../../../_virtual/rolldown_runtime.js";
var require_duration = /* @__PURE__ */ __commonJSMin(((e, t) => {
	(function(n, r) {
		typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs_plugin_duration = r();
	})(e, (function() {
		var e, t, n = 1e3, r = 6e4, i = 36e5, a = 864e5, o = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, s = 31536e6, c = 2628e6, l = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/, u = {
			years: s,
			months: c,
			days: a,
			hours: i,
			minutes: r,
			seconds: n,
			milliseconds: 1,
			weeks: 6048e5
		}, d = function(e) {
			return e instanceof v;
		}, f = function(e, t, n) {
			return new v(e, n, t.$l);
		}, p = function(e) {
			return t.p(e) + "s";
		}, m = function(e) {
			return e < 0;
		}, h = function(e) {
			return m(e) ? Math.ceil(e) : Math.floor(e);
		}, g = function(e) {
			return Math.abs(e);
		}, _ = function(e, t) {
			return e ? m(e) ? {
				negative: !0,
				format: "" + g(e) + t
			} : {
				negative: !1,
				format: "" + e + t
			} : {
				negative: !1,
				format: ""
			};
		}, v = function() {
			function m(e, t, n) {
				var r = this;
				if (this.$d = {}, this.$l = n, e === void 0 && (this.$ms = 0, this.parseFromMilliseconds()), t) return f(e * u[p(t)], this);
				if (typeof e == "number") return this.$ms = e, this.parseFromMilliseconds(), this;
				if (typeof e == "object") return Object.keys(e).forEach((function(t) {
					r.$d[p(t)] = e[t];
				})), this.calMilliseconds(), this;
				if (typeof e == "string") {
					var i = e.match(l);
					if (i) {
						var a = i.slice(2).map((function(e) {
							return e == null ? 0 : Number(e);
						}));
						return this.$d.years = a[0], this.$d.months = a[1], this.$d.weeks = a[2], this.$d.days = a[3], this.$d.hours = a[4], this.$d.minutes = a[5], this.$d.seconds = a[6], this.calMilliseconds(), this;
					}
				}
				return this;
			}
			var g = m.prototype;
			return g.calMilliseconds = function() {
				var e = this;
				this.$ms = Object.keys(this.$d).reduce((function(t, n) {
					return t + (e.$d[n] || 0) * u[n];
				}), 0);
			}, g.parseFromMilliseconds = function() {
				var e = this.$ms;
				this.$d.years = h(e / s), e %= s, this.$d.months = h(e / c), e %= c, this.$d.days = h(e / a), e %= a, this.$d.hours = h(e / i), e %= i, this.$d.minutes = h(e / r), e %= r, this.$d.seconds = h(e / n), e %= n, this.$d.milliseconds = e;
			}, g.toISOString = function() {
				var e = _(this.$d.years, "Y"), t = _(this.$d.months, "M"), n = +this.$d.days || 0;
				this.$d.weeks && (n += 7 * this.$d.weeks);
				var r = _(n, "D"), i = _(this.$d.hours, "H"), a = _(this.$d.minutes, "M"), o = this.$d.seconds || 0;
				this.$d.milliseconds && (o += this.$d.milliseconds / 1e3, o = Math.round(1e3 * o) / 1e3);
				var s = _(o, "S"), c = e.negative || t.negative || r.negative || i.negative || a.negative || s.negative, l = i.format || a.format || s.format ? "T" : "", u = (c ? "-" : "") + "P" + e.format + t.format + r.format + l + i.format + a.format + s.format;
				return u === "P" || u === "-P" ? "P0D" : u;
			}, g.toJSON = function() {
				return this.toISOString();
			}, g.format = function(e) {
				var n = e || "YYYY-MM-DDTHH:mm:ss", r = {
					Y: this.$d.years,
					YY: t.s(this.$d.years, 2, "0"),
					YYYY: t.s(this.$d.years, 4, "0"),
					M: this.$d.months,
					MM: t.s(this.$d.months, 2, "0"),
					D: this.$d.days,
					DD: t.s(this.$d.days, 2, "0"),
					H: this.$d.hours,
					HH: t.s(this.$d.hours, 2, "0"),
					m: this.$d.minutes,
					mm: t.s(this.$d.minutes, 2, "0"),
					s: this.$d.seconds,
					ss: t.s(this.$d.seconds, 2, "0"),
					SSS: t.s(this.$d.milliseconds, 3, "0")
				};
				return n.replace(o, (function(e, t) {
					return t || String(r[e]);
				}));
			}, g.as = function(e) {
				return this.$ms / u[p(e)];
			}, g.get = function(e) {
				var t = this.$ms, n = p(e);
				return n === "milliseconds" ? t %= 1e3 : t = n === "weeks" ? h(t / u[n]) : this.$d[n], t || 0;
			}, g.add = function(e, t, n) {
				var r;
				return r = t ? e * u[p(t)] : d(e) ? e.$ms : f(e, this).$ms, f(this.$ms + r * (n ? -1 : 1), this);
			}, g.subtract = function(e, t) {
				return this.add(e, t, !0);
			}, g.locale = function(e) {
				var t = this.clone();
				return t.$l = e, t;
			}, g.clone = function() {
				return f(this.$ms, this);
			}, g.humanize = function(t) {
				return e().add(this.$ms, "ms").locale(this.$l).fromNow(!t);
			}, g.valueOf = function() {
				return this.asMilliseconds();
			}, g.milliseconds = function() {
				return this.get("milliseconds");
			}, g.asMilliseconds = function() {
				return this.as("milliseconds");
			}, g.seconds = function() {
				return this.get("seconds");
			}, g.asSeconds = function() {
				return this.as("seconds");
			}, g.minutes = function() {
				return this.get("minutes");
			}, g.asMinutes = function() {
				return this.as("minutes");
			}, g.hours = function() {
				return this.get("hours");
			}, g.asHours = function() {
				return this.as("hours");
			}, g.days = function() {
				return this.get("days");
			}, g.asDays = function() {
				return this.as("days");
			}, g.weeks = function() {
				return this.get("weeks");
			}, g.asWeeks = function() {
				return this.as("weeks");
			}, g.months = function() {
				return this.get("months");
			}, g.asMonths = function() {
				return this.as("months");
			}, g.years = function() {
				return this.get("years");
			}, g.asYears = function() {
				return this.as("years");
			}, m;
		}(), y = function(e, t, n) {
			return e.add(t.years() * n, "y").add(t.months() * n, "M").add(t.days() * n, "d").add(t.hours() * n, "h").add(t.minutes() * n, "m").add(t.seconds() * n, "s").add(t.milliseconds() * n, "ms");
		};
		return function(n, r, i) {
			e = i, t = i().$utils(), i.duration = function(e, t) {
				return f(e, { $l: i.locale() }, t);
			}, i.isDuration = d;
			var a = r.prototype.add, o = r.prototype.subtract;
			r.prototype.add = function(e, t) {
				return d(e) ? y(this, e, 1) : a.bind(this)(e, t);
			}, r.prototype.subtract = function(e, t) {
				return d(e) ? y(this, e, -1) : o.bind(this)(e, t);
			};
		};
	}));
}));
export default require_duration();
export { require_duration };
