Files
pixivnow/.wrangler/tmp/dev-m5fb1Z/[[path]].js
JuLuogo 1147cd270b feat: 迁移到Cloudflare Workers并重构API请求处理
refactor: 使用fetch替换axios并优化请求处理逻辑

docs: 添加DEPLOYMENT.md部署指南

build: 更新package.json依赖和脚本配置

style: 更新组件类型定义和注释

perf: 优化图片代理和用户数据初始化逻辑
2025-10-08 15:53:36 +08:00

2745 lines
89 KiB
JavaScript

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// .wrangler/tmp/bundle-lcE67Q/checked-fetch.js
var urls = /* @__PURE__ */ new Set();
function checkURL(request, init) {
const url = request instanceof URL ? request : new URL(
(typeof request === "string" ? new Request(request, init) : request).url
);
if (url.port && url.port !== "443" && url.protocol === "https:") {
if (!urls.has(url.toString())) {
urls.add(url.toString());
console.warn(
`WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers:
- ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command.
`
);
}
}
}
__name(checkURL, "checkURL");
globalThis.fetch = new Proxy(globalThis.fetch, {
apply(target, thisArg, argArray) {
const [request, init] = argArray;
checkURL(request, init);
return Reflect.apply(target, thisArg, argArray);
}
});
// node_modules/.pnpm/itty-router@5.0.22/node_modules/itty-router/index.mjs
var t = /* @__PURE__ */ __name(({ base: e = "", routes: t2 = [], ...r2 } = {}) => ({ __proto__: new Proxy({}, { get: /* @__PURE__ */ __name((r3, o2, a, s) => (r4, ...c) => t2.push([o2.toUpperCase?.(), RegExp(`^${(s = (e + r4).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), c, s]) && a, "get") }), routes: t2, ...r2, async fetch(e2, ...o2) {
let a, s, c = new URL(e2.url), n = e2.query = { __proto__: null };
for (let [e3, t3] of c.searchParams) n[e3] = n[e3] ? [].concat(n[e3], t3) : t3;
e: try {
for (let t3 of r2.before || []) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break e;
t: for (let [r3, n2, l, i] of t2) if ((r3 == e2.method || "ALL" == r3) && (s = c.pathname.match(n2))) {
e2.params = s.groups || {}, e2.route = i;
for (let t3 of l) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break t;
}
} catch (t3) {
if (!r2.catch) throw t3;
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
}
try {
for (let t3 of r2.finally || []) a = await t3(a, e2.proxy ?? e2, ...o2) ?? a;
} catch (t3) {
if (!r2.catch) throw t3;
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
}
return a;
} }), "t");
var r = /* @__PURE__ */ __name((e = "text/plain; charset=utf-8", t2) => (r2, o2 = {}) => {
if (void 0 === r2 || r2 instanceof Response) return r2;
const a = new Response(t2?.(r2) ?? r2, o2.url ? void 0 : o2);
return a.headers.set("content-type", e), a;
}, "r");
var o = r("application/json; charset=utf-8", JSON.stringify);
var p = r("text/plain; charset=utf-8", String);
var f = r("text/html");
var u = r("image/jpeg");
var h = r("image/png");
var g = r("image/webp");
var y = /* @__PURE__ */ __name((e = {}) => {
const { origin: t2 = "*", credentials: r2 = false, allowMethods: o2 = "*", allowHeaders: a, exposeHeaders: s, maxAge: c } = e, n = /* @__PURE__ */ __name((e2) => {
const o3 = e2?.headers.get("origin");
return true === t2 ? o3 : t2 instanceof RegExp ? t2.test(o3) ? o3 : void 0 : Array.isArray(t2) ? t2.includes(o3) ? o3 : void 0 : t2 instanceof Function ? t2(o3) : "*" == t2 && r2 ? o3 : t2;
}, "n"), l = /* @__PURE__ */ __name((e2, t3) => {
for (const [r3, o3] of Object.entries(t3)) o3 && e2.headers.append(r3, o3);
return e2;
}, "l");
return { corsify: /* @__PURE__ */ __name((e2, t3) => e2?.headers?.get("access-control-allow-origin") || 101 == e2.status ? e2 : l(e2.clone(), { "access-control-allow-origin": n(t3), "access-control-allow-credentials": r2 }), "corsify"), preflight: /* @__PURE__ */ __name((e2) => {
if ("OPTIONS" == e2.method) {
const t3 = new Response(null, { status: 204 });
return l(t3, { "access-control-allow-origin": n(e2), "access-control-allow-methods": o2?.join?.(",") ?? o2, "access-control-expose-headers": s?.join?.(",") ?? s, "access-control-allow-headers": a?.join?.(",") ?? a ?? e2.headers.get("access-control-request-headers"), "access-control-max-age": c, "access-control-allow-credentials": r2 });
}
}, "preflight") };
}, "y");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
var formatDistanceLocale = {
lessThanXSeconds: {
one: "less than a second",
other: "less than {{count}} seconds"
},
xSeconds: {
one: "1 second",
other: "{{count}} seconds"
},
halfAMinute: "half a minute",
lessThanXMinutes: {
one: "less than a minute",
other: "less than {{count}} minutes"
},
xMinutes: {
one: "1 minute",
other: "{{count}} minutes"
},
aboutXHours: {
one: "about 1 hour",
other: "about {{count}} hours"
},
xHours: {
one: "1 hour",
other: "{{count}} hours"
},
xDays: {
one: "1 day",
other: "{{count}} days"
},
aboutXWeeks: {
one: "about 1 week",
other: "about {{count}} weeks"
},
xWeeks: {
one: "1 week",
other: "{{count}} weeks"
},
aboutXMonths: {
one: "about 1 month",
other: "about {{count}} months"
},
xMonths: {
one: "1 month",
other: "{{count}} months"
},
aboutXYears: {
one: "about 1 year",
other: "about {{count}} years"
},
xYears: {
one: "1 year",
other: "{{count}} years"
},
overXYears: {
one: "over 1 year",
other: "over {{count}} years"
},
almostXYears: {
one: "almost 1 year",
other: "almost {{count}} years"
}
};
var formatDistance = /* @__PURE__ */ __name((token, count, options) => {
let result;
const tokenValue = formatDistanceLocale[token];
if (typeof tokenValue === "string") {
result = tokenValue;
} else if (count === 1) {
result = tokenValue.one;
} else {
result = tokenValue.other.replace("{{count}}", count.toString());
}
if (options?.addSuffix) {
if (options.comparison && options.comparison > 0) {
return "in " + result;
} else {
return result + " ago";
}
}
return result;
}, "formatDistance");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
function buildFormatLongFn(args) {
return (options = {}) => {
const width = options.width ? String(options.width) : args.defaultWidth;
const format3 = args.formats[width] || args.formats[args.defaultWidth];
return format3;
};
}
__name(buildFormatLongFn, "buildFormatLongFn");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/formatLong.js
var dateFormats = {
full: "EEEE, MMMM do, y",
long: "MMMM do, y",
medium: "MMM d, y",
short: "MM/dd/yyyy"
};
var timeFormats = {
full: "h:mm:ss a zzzz",
long: "h:mm:ss a z",
medium: "h:mm:ss a",
short: "h:mm a"
};
var dateTimeFormats = {
full: "{{date}} 'at' {{time}}",
long: "{{date}} 'at' {{time}}",
medium: "{{date}}, {{time}}",
short: "{{date}}, {{time}}"
};
var formatLong = {
date: buildFormatLongFn({
formats: dateFormats,
defaultWidth: "full"
}),
time: buildFormatLongFn({
formats: timeFormats,
defaultWidth: "full"
}),
dateTime: buildFormatLongFn({
formats: dateTimeFormats,
defaultWidth: "full"
})
};
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
var formatRelativeLocale = {
lastWeek: "'last' eeee 'at' p",
yesterday: "'yesterday at' p",
today: "'today at' p",
tomorrow: "'tomorrow at' p",
nextWeek: "eeee 'at' p",
other: "P"
};
var formatRelative = /* @__PURE__ */ __name((token, _date, _baseDate, _options) => formatRelativeLocale[token], "formatRelative");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
function buildLocalizeFn(args) {
return (value, options) => {
const context = options?.context ? String(options.context) : "standalone";
let valuesArray;
if (context === "formatting" && args.formattingValues) {
const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
const width = options?.width ? String(options.width) : defaultWidth;
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
} else {
const defaultWidth = args.defaultWidth;
const width = options?.width ? String(options.width) : args.defaultWidth;
valuesArray = args.values[width] || args.values[defaultWidth];
}
const index = args.argumentCallback ? args.argumentCallback(value) : value;
return valuesArray[index];
};
}
__name(buildLocalizeFn, "buildLocalizeFn");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/localize.js
var eraValues = {
narrow: ["B", "A"],
abbreviated: ["BC", "AD"],
wide: ["Before Christ", "Anno Domini"]
};
var quarterValues = {
narrow: ["1", "2", "3", "4"],
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
};
var monthValues = {
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
abbreviated: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
wide: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
};
var dayValues = {
narrow: ["S", "M", "T", "W", "T", "F", "S"],
short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
wide: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
]
};
var dayPeriodValues = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
}
};
var formattingDayPeriodValues = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
}
};
var ordinalNumber = /* @__PURE__ */ __name((dirtyNumber, _options) => {
const number = Number(dirtyNumber);
const rem100 = number % 100;
if (rem100 > 20 || rem100 < 10) {
switch (rem100 % 10) {
case 1:
return number + "st";
case 2:
return number + "nd";
case 3:
return number + "rd";
}
}
return number + "th";
}, "ordinalNumber");
var localize = {
ordinalNumber,
era: buildLocalizeFn({
values: eraValues,
defaultWidth: "wide"
}),
quarter: buildLocalizeFn({
values: quarterValues,
defaultWidth: "wide",
argumentCallback: /* @__PURE__ */ __name((quarter) => quarter - 1, "argumentCallback")
}),
month: buildLocalizeFn({
values: monthValues,
defaultWidth: "wide"
}),
day: buildLocalizeFn({
values: dayValues,
defaultWidth: "wide"
}),
dayPeriod: buildLocalizeFn({
values: dayPeriodValues,
defaultWidth: "wide",
formattingValues: formattingDayPeriodValues,
defaultFormattingWidth: "wide"
})
};
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildMatchFn.js
function buildMatchFn(args) {
return (string, options = {}) => {
const width = options.width;
const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
const matchResult = string.match(matchPattern);
if (!matchResult) {
return null;
}
const matchedString = matchResult[0];
const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
// [TODO] -- I challenge you to fix the type
findKey(parsePatterns, (pattern) => pattern.test(matchedString))
);
let value;
value = args.valueCallback ? args.valueCallback(key) : key;
value = options.valueCallback ? (
// [TODO] -- I challenge you to fix the type
options.valueCallback(value)
) : value;
const rest = string.slice(matchedString.length);
return { value, rest };
};
}
__name(buildMatchFn, "buildMatchFn");
function findKey(object, predicate) {
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
return key;
}
}
return void 0;
}
__name(findKey, "findKey");
function findIndex(array, predicate) {
for (let key = 0; key < array.length; key++) {
if (predicate(array[key])) {
return key;
}
}
return void 0;
}
__name(findIndex, "findIndex");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
function buildMatchPatternFn(args) {
return (string, options = {}) => {
const matchResult = string.match(args.matchPattern);
if (!matchResult) return null;
const matchedString = matchResult[0];
const parseResult = string.match(args.parsePattern);
if (!parseResult) return null;
let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
value = options.valueCallback ? options.valueCallback(value) : value;
const rest = string.slice(matchedString.length);
return { value, rest };
};
}
__name(buildMatchPatternFn, "buildMatchPatternFn");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/match.js
var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
var parseOrdinalNumberPattern = /\d+/i;
var matchEraPatterns = {
narrow: /^(b|a)/i,
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
wide: /^(before christ|before common era|anno domini|common era)/i
};
var parseEraPatterns = {
any: [/^b/i, /^(a|c)/i]
};
var matchQuarterPatterns = {
narrow: /^[1234]/i,
abbreviated: /^q[1234]/i,
wide: /^[1234](th|st|nd|rd)? quarter/i
};
var parseQuarterPatterns = {
any: [/1/i, /2/i, /3/i, /4/i]
};
var matchMonthPatterns = {
narrow: /^[jfmasond]/i,
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
};
var parseMonthPatterns = {
narrow: [
/^j/i,
/^f/i,
/^m/i,
/^a/i,
/^m/i,
/^j/i,
/^j/i,
/^a/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
],
any: [
/^ja/i,
/^f/i,
/^mar/i,
/^ap/i,
/^may/i,
/^jun/i,
/^jul/i,
/^au/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
]
};
var matchDayPatterns = {
narrow: /^[smtwf]/i,
short: /^(su|mo|tu|we|th|fr|sa)/i,
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
};
var parseDayPatterns = {
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
};
var matchDayPeriodPatterns = {
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
};
var parseDayPeriodPatterns = {
any: {
am: /^a/i,
pm: /^p/i,
midnight: /^mi/i,
noon: /^no/i,
morning: /morning/i,
afternoon: /afternoon/i,
evening: /evening/i,
night: /night/i
}
};
var match = {
ordinalNumber: buildMatchPatternFn({
matchPattern: matchOrdinalNumberPattern,
parsePattern: parseOrdinalNumberPattern,
valueCallback: /* @__PURE__ */ __name((value) => parseInt(value, 10), "valueCallback")
}),
era: buildMatchFn({
matchPatterns: matchEraPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseEraPatterns,
defaultParseWidth: "any"
}),
quarter: buildMatchFn({
matchPatterns: matchQuarterPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseQuarterPatterns,
defaultParseWidth: "any",
valueCallback: /* @__PURE__ */ __name((index) => index + 1, "valueCallback")
}),
month: buildMatchFn({
matchPatterns: matchMonthPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseMonthPatterns,
defaultParseWidth: "any"
}),
day: buildMatchFn({
matchPatterns: matchDayPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseDayPatterns,
defaultParseWidth: "any"
}),
dayPeriod: buildMatchFn({
matchPatterns: matchDayPeriodPatterns,
defaultMatchWidth: "any",
parsePatterns: parseDayPeriodPatterns,
defaultParseWidth: "any"
})
};
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US.js
var enUS = {
code: "en-US",
formatDistance,
formatLong,
formatRelative,
localize,
match,
options: {
weekStartsOn: 0,
firstWeekContainsDate: 1
}
};
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/defaultOptions.js
var defaultOptions = {};
function getDefaultOptions() {
return defaultOptions;
}
__name(getDefaultOptions, "getDefaultOptions");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constants.js
var daysInYear = 365.2425;
var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
var minTime = -maxTime;
var millisecondsInWeek = 6048e5;
var millisecondsInDay = 864e5;
var secondsInHour = 3600;
var secondsInDay = secondsInHour * 24;
var secondsInWeek = secondsInDay * 7;
var secondsInYear = secondsInDay * daysInYear;
var secondsInMonth = secondsInYear / 12;
var secondsInQuarter = secondsInMonth * 3;
var constructFromSymbol = Symbol.for("constructDateFrom");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constructFrom.js
function constructFrom(date, value) {
if (typeof date === "function") return date(value);
if (date && typeof date === "object" && constructFromSymbol in date)
return date[constructFromSymbol](value);
if (date instanceof Date) return new date.constructor(value);
return new Date(value);
}
__name(constructFrom, "constructFrom");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/toDate.js
function toDate(argument, context) {
return constructFrom(context || argument, argument);
}
__name(toDate, "toDate");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
function getTimezoneOffsetInMilliseconds(date) {
const _date = toDate(date);
const utcDate = new Date(
Date.UTC(
_date.getFullYear(),
_date.getMonth(),
_date.getDate(),
_date.getHours(),
_date.getMinutes(),
_date.getSeconds(),
_date.getMilliseconds()
)
);
utcDate.setUTCFullYear(_date.getFullYear());
return +date - +utcDate;
}
__name(getTimezoneOffsetInMilliseconds, "getTimezoneOffsetInMilliseconds");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/normalizeDates.js
function normalizeDates(context, ...dates) {
const normalize = constructFrom.bind(
null,
context || dates.find((date) => typeof date === "object")
);
return dates.map(normalize);
}
__name(normalizeDates, "normalizeDates");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfDay.js
function startOfDay(date, options) {
const _date = toDate(date, options?.in);
_date.setHours(0, 0, 0, 0);
return _date;
}
__name(startOfDay, "startOfDay");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInCalendarDays.js
function differenceInCalendarDays(laterDate, earlierDate, options) {
const [laterDate_, earlierDate_] = normalizeDates(
options?.in,
laterDate,
earlierDate
);
const laterStartOfDay = startOfDay(laterDate_);
const earlierStartOfDay = startOfDay(earlierDate_);
const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
}
__name(differenceInCalendarDays, "differenceInCalendarDays");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfYear.js
function startOfYear(date, options) {
const date_ = toDate(date, options?.in);
date_.setFullYear(date_.getFullYear(), 0, 1);
date_.setHours(0, 0, 0, 0);
return date_;
}
__name(startOfYear, "startOfYear");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDayOfYear.js
function getDayOfYear(date, options) {
const _date = toDate(date, options?.in);
const diff = differenceInCalendarDays(_date, startOfYear(_date));
const dayOfYear = diff + 1;
return dayOfYear;
}
__name(getDayOfYear, "getDayOfYear");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfWeek.js
function startOfWeek(date, options) {
const defaultOptions2 = getDefaultOptions();
const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
const _date = toDate(date, options?.in);
const day = _date.getDay();
const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
_date.setDate(_date.getDate() - diff);
_date.setHours(0, 0, 0, 0);
return _date;
}
__name(startOfWeek, "startOfWeek");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfISOWeek.js
function startOfISOWeek(date, options) {
return startOfWeek(date, { ...options, weekStartsOn: 1 });
}
__name(startOfISOWeek, "startOfISOWeek");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getISOWeekYear.js
function getISOWeekYear(date, options) {
const _date = toDate(date, options?.in);
const year = _date.getFullYear();
const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
if (_date.getTime() >= startOfNextYear.getTime()) {
return year + 1;
} else if (_date.getTime() >= startOfThisYear.getTime()) {
return year;
} else {
return year - 1;
}
}
__name(getISOWeekYear, "getISOWeekYear");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfISOWeekYear.js
function startOfISOWeekYear(date, options) {
const year = getISOWeekYear(date, options);
const fourthOfJanuary = constructFrom(options?.in || date, 0);
fourthOfJanuary.setFullYear(year, 0, 4);
fourthOfJanuary.setHours(0, 0, 0, 0);
return startOfISOWeek(fourthOfJanuary);
}
__name(startOfISOWeekYear, "startOfISOWeekYear");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getISOWeek.js
function getISOWeek(date, options) {
const _date = toDate(date, options?.in);
const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
return Math.round(diff / millisecondsInWeek) + 1;
}
__name(getISOWeek, "getISOWeek");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getWeekYear.js
function getWeekYear(date, options) {
const _date = toDate(date, options?.in);
const year = _date.getFullYear();
const defaultOptions2 = getDefaultOptions();
const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
firstWeekOfNextYear.setHours(0, 0, 0, 0);
const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
firstWeekOfThisYear.setHours(0, 0, 0, 0);
const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
if (+_date >= +startOfNextYear) {
return year + 1;
} else if (+_date >= +startOfThisYear) {
return year;
} else {
return year - 1;
}
}
__name(getWeekYear, "getWeekYear");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfWeekYear.js
function startOfWeekYear(date, options) {
const defaultOptions2 = getDefaultOptions();
const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
const year = getWeekYear(date, options);
const firstWeek = constructFrom(options?.in || date, 0);
firstWeek.setFullYear(year, 0, firstWeekContainsDate);
firstWeek.setHours(0, 0, 0, 0);
const _date = startOfWeek(firstWeek, options);
return _date;
}
__name(startOfWeekYear, "startOfWeekYear");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getWeek.js
function getWeek(date, options) {
const _date = toDate(date, options?.in);
const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
return Math.round(diff / millisecondsInWeek) + 1;
}
__name(getWeek, "getWeek");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/addLeadingZeros.js
function addLeadingZeros(number, targetLength) {
const sign = number < 0 ? "-" : "";
const output = Math.abs(number).toString().padStart(targetLength, "0");
return sign + output;
}
__name(addLeadingZeros, "addLeadingZeros");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/format/lightFormatters.js
var lightFormatters = {
// Year
y(date, token) {
const signedYear = date.getFullYear();
const year = signedYear > 0 ? signedYear : 1 - signedYear;
return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
},
// Month
M(date, token) {
const month = date.getMonth();
return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
},
// Day of the month
d(date, token) {
return addLeadingZeros(date.getDate(), token.length);
},
// AM or PM
a(date, token) {
const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
switch (token) {
case "a":
case "aa":
return dayPeriodEnumValue.toUpperCase();
case "aaa":
return dayPeriodEnumValue;
case "aaaaa":
return dayPeriodEnumValue[0];
case "aaaa":
default:
return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
}
},
// Hour [1-12]
h(date, token) {
return addLeadingZeros(date.getHours() % 12 || 12, token.length);
},
// Hour [0-23]
H(date, token) {
return addLeadingZeros(date.getHours(), token.length);
},
// Minute
m(date, token) {
return addLeadingZeros(date.getMinutes(), token.length);
},
// Second
s(date, token) {
return addLeadingZeros(date.getSeconds(), token.length);
},
// Fraction of second
S(date, token) {
const numberOfDigits = token.length;
const milliseconds = date.getMilliseconds();
const fractionalSeconds = Math.trunc(
milliseconds * Math.pow(10, numberOfDigits - 3)
);
return addLeadingZeros(fractionalSeconds, token.length);
}
};
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/format/formatters.js
var dayPeriodEnum = {
am: "am",
pm: "pm",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
};
var formatters = {
// Era
G: /* @__PURE__ */ __name(function(date, token, localize2) {
const era = date.getFullYear() > 0 ? 1 : 0;
switch (token) {
// AD, BC
case "G":
case "GG":
case "GGG":
return localize2.era(era, { width: "abbreviated" });
// A, B
case "GGGGG":
return localize2.era(era, { width: "narrow" });
// Anno Domini, Before Christ
case "GGGG":
default:
return localize2.era(era, { width: "wide" });
}
}, "G"),
// Year
y: /* @__PURE__ */ __name(function(date, token, localize2) {
if (token === "yo") {
const signedYear = date.getFullYear();
const year = signedYear > 0 ? signedYear : 1 - signedYear;
return localize2.ordinalNumber(year, { unit: "year" });
}
return lightFormatters.y(date, token);
}, "y"),
// Local week-numbering year
Y: /* @__PURE__ */ __name(function(date, token, localize2, options) {
const signedWeekYear = getWeekYear(date, options);
const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
if (token === "YY") {
const twoDigitYear = weekYear % 100;
return addLeadingZeros(twoDigitYear, 2);
}
if (token === "Yo") {
return localize2.ordinalNumber(weekYear, { unit: "year" });
}
return addLeadingZeros(weekYear, token.length);
}, "Y"),
// ISO week-numbering year
R: /* @__PURE__ */ __name(function(date, token) {
const isoWeekYear = getISOWeekYear(date);
return addLeadingZeros(isoWeekYear, token.length);
}, "R"),
// Extended year. This is a single number designating the year of this calendar system.
// The main difference between `y` and `u` localizers are B.C. years:
// | Year | `y` | `u` |
// |------|-----|-----|
// | AC 1 | 1 | 1 |
// | BC 1 | 1 | 0 |
// | BC 2 | 2 | -1 |
// Also `yy` always returns the last two digits of a year,
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
u: /* @__PURE__ */ __name(function(date, token) {
const year = date.getFullYear();
return addLeadingZeros(year, token.length);
}, "u"),
// Quarter
Q: /* @__PURE__ */ __name(function(date, token, localize2) {
const quarter = Math.ceil((date.getMonth() + 1) / 3);
switch (token) {
// 1, 2, 3, 4
case "Q":
return String(quarter);
// 01, 02, 03, 04
case "QQ":
return addLeadingZeros(quarter, 2);
// 1st, 2nd, 3rd, 4th
case "Qo":
return localize2.ordinalNumber(quarter, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "QQQ":
return localize2.quarter(quarter, {
width: "abbreviated",
context: "formatting"
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "QQQQQ":
return localize2.quarter(quarter, {
width: "narrow",
context: "formatting"
});
// 1st quarter, 2nd quarter, ...
case "QQQQ":
default:
return localize2.quarter(quarter, {
width: "wide",
context: "formatting"
});
}
}, "Q"),
// Stand-alone quarter
q: /* @__PURE__ */ __name(function(date, token, localize2) {
const quarter = Math.ceil((date.getMonth() + 1) / 3);
switch (token) {
// 1, 2, 3, 4
case "q":
return String(quarter);
// 01, 02, 03, 04
case "qq":
return addLeadingZeros(quarter, 2);
// 1st, 2nd, 3rd, 4th
case "qo":
return localize2.ordinalNumber(quarter, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "qqq":
return localize2.quarter(quarter, {
width: "abbreviated",
context: "standalone"
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "qqqqq":
return localize2.quarter(quarter, {
width: "narrow",
context: "standalone"
});
// 1st quarter, 2nd quarter, ...
case "qqqq":
default:
return localize2.quarter(quarter, {
width: "wide",
context: "standalone"
});
}
}, "q"),
// Month
M: /* @__PURE__ */ __name(function(date, token, localize2) {
const month = date.getMonth();
switch (token) {
case "M":
case "MM":
return lightFormatters.M(date, token);
// 1st, 2nd, ..., 12th
case "Mo":
return localize2.ordinalNumber(month + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "MMM":
return localize2.month(month, {
width: "abbreviated",
context: "formatting"
});
// J, F, ..., D
case "MMMMM":
return localize2.month(month, {
width: "narrow",
context: "formatting"
});
// January, February, ..., December
case "MMMM":
default:
return localize2.month(month, { width: "wide", context: "formatting" });
}
}, "M"),
// Stand-alone month
L: /* @__PURE__ */ __name(function(date, token, localize2) {
const month = date.getMonth();
switch (token) {
// 1, 2, ..., 12
case "L":
return String(month + 1);
// 01, 02, ..., 12
case "LL":
return addLeadingZeros(month + 1, 2);
// 1st, 2nd, ..., 12th
case "Lo":
return localize2.ordinalNumber(month + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "LLL":
return localize2.month(month, {
width: "abbreviated",
context: "standalone"
});
// J, F, ..., D
case "LLLLL":
return localize2.month(month, {
width: "narrow",
context: "standalone"
});
// January, February, ..., December
case "LLLL":
default:
return localize2.month(month, { width: "wide", context: "standalone" });
}
}, "L"),
// Local week of year
w: /* @__PURE__ */ __name(function(date, token, localize2, options) {
const week = getWeek(date, options);
if (token === "wo") {
return localize2.ordinalNumber(week, { unit: "week" });
}
return addLeadingZeros(week, token.length);
}, "w"),
// ISO week of year
I: /* @__PURE__ */ __name(function(date, token, localize2) {
const isoWeek = getISOWeek(date);
if (token === "Io") {
return localize2.ordinalNumber(isoWeek, { unit: "week" });
}
return addLeadingZeros(isoWeek, token.length);
}, "I"),
// Day of the month
d: /* @__PURE__ */ __name(function(date, token, localize2) {
if (token === "do") {
return localize2.ordinalNumber(date.getDate(), { unit: "date" });
}
return lightFormatters.d(date, token);
}, "d"),
// Day of year
D: /* @__PURE__ */ __name(function(date, token, localize2) {
const dayOfYear = getDayOfYear(date);
if (token === "Do") {
return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
}
return addLeadingZeros(dayOfYear, token.length);
}, "D"),
// Day of week
E: /* @__PURE__ */ __name(function(date, token, localize2) {
const dayOfWeek = date.getDay();
switch (token) {
// Tue
case "E":
case "EE":
case "EEE":
return localize2.day(dayOfWeek, {
width: "abbreviated",
context: "formatting"
});
// T
case "EEEEE":
return localize2.day(dayOfWeek, {
width: "narrow",
context: "formatting"
});
// Tu
case "EEEEEE":
return localize2.day(dayOfWeek, {
width: "short",
context: "formatting"
});
// Tuesday
case "EEEE":
default:
return localize2.day(dayOfWeek, {
width: "wide",
context: "formatting"
});
}
}, "E"),
// Local day of week
e: /* @__PURE__ */ __name(function(date, token, localize2, options) {
const dayOfWeek = date.getDay();
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
switch (token) {
// Numerical value (Nth day of week with current locale or weekStartsOn)
case "e":
return String(localDayOfWeek);
// Padded numerical value
case "ee":
return addLeadingZeros(localDayOfWeek, 2);
// 1st, 2nd, ..., 7th
case "eo":
return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
case "eee":
return localize2.day(dayOfWeek, {
width: "abbreviated",
context: "formatting"
});
// T
case "eeeee":
return localize2.day(dayOfWeek, {
width: "narrow",
context: "formatting"
});
// Tu
case "eeeeee":
return localize2.day(dayOfWeek, {
width: "short",
context: "formatting"
});
// Tuesday
case "eeee":
default:
return localize2.day(dayOfWeek, {
width: "wide",
context: "formatting"
});
}
}, "e"),
// Stand-alone local day of week
c: /* @__PURE__ */ __name(function(date, token, localize2, options) {
const dayOfWeek = date.getDay();
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
switch (token) {
// Numerical value (same as in `e`)
case "c":
return String(localDayOfWeek);
// Padded numerical value
case "cc":
return addLeadingZeros(localDayOfWeek, token.length);
// 1st, 2nd, ..., 7th
case "co":
return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
case "ccc":
return localize2.day(dayOfWeek, {
width: "abbreviated",
context: "standalone"
});
// T
case "ccccc":
return localize2.day(dayOfWeek, {
width: "narrow",
context: "standalone"
});
// Tu
case "cccccc":
return localize2.day(dayOfWeek, {
width: "short",
context: "standalone"
});
// Tuesday
case "cccc":
default:
return localize2.day(dayOfWeek, {
width: "wide",
context: "standalone"
});
}
}, "c"),
// ISO day of week
i: /* @__PURE__ */ __name(function(date, token, localize2) {
const dayOfWeek = date.getDay();
const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
switch (token) {
// 2
case "i":
return String(isoDayOfWeek);
// 02
case "ii":
return addLeadingZeros(isoDayOfWeek, token.length);
// 2nd
case "io":
return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
// Tue
case "iii":
return localize2.day(dayOfWeek, {
width: "abbreviated",
context: "formatting"
});
// T
case "iiiii":
return localize2.day(dayOfWeek, {
width: "narrow",
context: "formatting"
});
// Tu
case "iiiiii":
return localize2.day(dayOfWeek, {
width: "short",
context: "formatting"
});
// Tuesday
case "iiii":
default:
return localize2.day(dayOfWeek, {
width: "wide",
context: "formatting"
});
}
}, "i"),
// AM or PM
a: /* @__PURE__ */ __name(function(date, token, localize2) {
const hours = date.getHours();
const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
switch (token) {
case "a":
case "aa":
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
});
case "aaa":
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "aaaaa":
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting"
});
case "aaaa":
default:
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting"
});
}
}, "a"),
// AM, PM, midnight, noon
b: /* @__PURE__ */ __name(function(date, token, localize2) {
const hours = date.getHours();
let dayPeriodEnumValue;
if (hours === 12) {
dayPeriodEnumValue = dayPeriodEnum.noon;
} else if (hours === 0) {
dayPeriodEnumValue = dayPeriodEnum.midnight;
} else {
dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
}
switch (token) {
case "b":
case "bb":
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
});
case "bbb":
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "bbbbb":
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting"
});
case "bbbb":
default:
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting"
});
}
}, "b"),
// in the morning, in the afternoon, in the evening, at night
B: /* @__PURE__ */ __name(function(date, token, localize2) {
const hours = date.getHours();
let dayPeriodEnumValue;
if (hours >= 17) {
dayPeriodEnumValue = dayPeriodEnum.evening;
} else if (hours >= 12) {
dayPeriodEnumValue = dayPeriodEnum.afternoon;
} else if (hours >= 4) {
dayPeriodEnumValue = dayPeriodEnum.morning;
} else {
dayPeriodEnumValue = dayPeriodEnum.night;
}
switch (token) {
case "B":
case "BB":
case "BBB":
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
});
case "BBBBB":
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting"
});
case "BBBB":
default:
return localize2.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting"
});
}
}, "B"),
// Hour [1-12]
h: /* @__PURE__ */ __name(function(date, token, localize2) {
if (token === "ho") {
let hours = date.getHours() % 12;
if (hours === 0) hours = 12;
return localize2.ordinalNumber(hours, { unit: "hour" });
}
return lightFormatters.h(date, token);
}, "h"),
// Hour [0-23]
H: /* @__PURE__ */ __name(function(date, token, localize2) {
if (token === "Ho") {
return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
}
return lightFormatters.H(date, token);
}, "H"),
// Hour [0-11]
K: /* @__PURE__ */ __name(function(date, token, localize2) {
const hours = date.getHours() % 12;
if (token === "Ko") {
return localize2.ordinalNumber(hours, { unit: "hour" });
}
return addLeadingZeros(hours, token.length);
}, "K"),
// Hour [1-24]
k: /* @__PURE__ */ __name(function(date, token, localize2) {
let hours = date.getHours();
if (hours === 0) hours = 24;
if (token === "ko") {
return localize2.ordinalNumber(hours, { unit: "hour" });
}
return addLeadingZeros(hours, token.length);
}, "k"),
// Minute
m: /* @__PURE__ */ __name(function(date, token, localize2) {
if (token === "mo") {
return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
}
return lightFormatters.m(date, token);
}, "m"),
// Second
s: /* @__PURE__ */ __name(function(date, token, localize2) {
if (token === "so") {
return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
}
return lightFormatters.s(date, token);
}, "s"),
// Fraction of second
S: /* @__PURE__ */ __name(function(date, token) {
return lightFormatters.S(date, token);
}, "S"),
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
X: /* @__PURE__ */ __name(function(date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
if (timezoneOffset === 0) {
return "Z";
}
switch (token) {
// Hours and optional minutes
case "X":
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XX`
case "XXXX":
case "XX":
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XXX`
case "XXXXX":
case "XXX":
// Hours and minutes with `:` delimiter
default:
return formatTimezone(timezoneOffset, ":");
}
}, "X"),
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
x: /* @__PURE__ */ __name(function(date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
switch (token) {
// Hours and optional minutes
case "x":
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xx`
case "xxxx":
case "xx":
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xxx`
case "xxxxx":
case "xxx":
// Hours and minutes with `:` delimiter
default:
return formatTimezone(timezoneOffset, ":");
}
}, "x"),
// Timezone (GMT)
O: /* @__PURE__ */ __name(function(date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
switch (token) {
// Short
case "O":
case "OO":
case "OOO":
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
// Long
case "OOOO":
default:
return "GMT" + formatTimezone(timezoneOffset, ":");
}
}, "O"),
// Timezone (specific non-location)
z: /* @__PURE__ */ __name(function(date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
switch (token) {
// Short
case "z":
case "zz":
case "zzz":
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
// Long
case "zzzz":
default:
return "GMT" + formatTimezone(timezoneOffset, ":");
}
}, "z"),
// Seconds timestamp
t: /* @__PURE__ */ __name(function(date, token, _localize) {
const timestamp = Math.trunc(+date / 1e3);
return addLeadingZeros(timestamp, token.length);
}, "t"),
// Milliseconds timestamp
T: /* @__PURE__ */ __name(function(date, token, _localize) {
return addLeadingZeros(+date, token.length);
}, "T")
};
function formatTimezoneShort(offset, delimiter = "") {
const sign = offset > 0 ? "-" : "+";
const absOffset = Math.abs(offset);
const hours = Math.trunc(absOffset / 60);
const minutes = absOffset % 60;
if (minutes === 0) {
return sign + String(hours);
}
return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
}
__name(formatTimezoneShort, "formatTimezoneShort");
function formatTimezoneWithOptionalMinutes(offset, delimiter) {
if (offset % 60 === 0) {
const sign = offset > 0 ? "-" : "+";
return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
}
return formatTimezone(offset, delimiter);
}
__name(formatTimezoneWithOptionalMinutes, "formatTimezoneWithOptionalMinutes");
function formatTimezone(offset, delimiter = "") {
const sign = offset > 0 ? "-" : "+";
const absOffset = Math.abs(offset);
const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
const minutes = addLeadingZeros(absOffset % 60, 2);
return sign + hours + delimiter + minutes;
}
__name(formatTimezone, "formatTimezone");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/format/longFormatters.js
var dateLongFormatter = /* @__PURE__ */ __name((pattern, formatLong2) => {
switch (pattern) {
case "P":
return formatLong2.date({ width: "short" });
case "PP":
return formatLong2.date({ width: "medium" });
case "PPP":
return formatLong2.date({ width: "long" });
case "PPPP":
default:
return formatLong2.date({ width: "full" });
}
}, "dateLongFormatter");
var timeLongFormatter = /* @__PURE__ */ __name((pattern, formatLong2) => {
switch (pattern) {
case "p":
return formatLong2.time({ width: "short" });
case "pp":
return formatLong2.time({ width: "medium" });
case "ppp":
return formatLong2.time({ width: "long" });
case "pppp":
default:
return formatLong2.time({ width: "full" });
}
}, "timeLongFormatter");
var dateTimeLongFormatter = /* @__PURE__ */ __name((pattern, formatLong2) => {
const matchResult = pattern.match(/(P+)(p+)?/) || [];
const datePattern = matchResult[1];
const timePattern = matchResult[2];
if (!timePattern) {
return dateLongFormatter(pattern, formatLong2);
}
let dateTimeFormat;
switch (datePattern) {
case "P":
dateTimeFormat = formatLong2.dateTime({ width: "short" });
break;
case "PP":
dateTimeFormat = formatLong2.dateTime({ width: "medium" });
break;
case "PPP":
dateTimeFormat = formatLong2.dateTime({ width: "long" });
break;
case "PPPP":
default:
dateTimeFormat = formatLong2.dateTime({ width: "full" });
break;
}
return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
}, "dateTimeLongFormatter");
var longFormatters = {
p: timeLongFormatter,
P: dateTimeLongFormatter
};
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/protectedTokens.js
var dayOfYearTokenRE = /^D+$/;
var weekYearTokenRE = /^Y+$/;
var throwTokens = ["D", "DD", "YY", "YYYY"];
function isProtectedDayOfYearToken(token) {
return dayOfYearTokenRE.test(token);
}
__name(isProtectedDayOfYearToken, "isProtectedDayOfYearToken");
function isProtectedWeekYearToken(token) {
return weekYearTokenRE.test(token);
}
__name(isProtectedWeekYearToken, "isProtectedWeekYearToken");
function warnOrThrowProtectedError(token, format3, input) {
const _message = message(token, format3, input);
console.warn(_message);
if (throwTokens.includes(token)) throw new RangeError(_message);
}
__name(warnOrThrowProtectedError, "warnOrThrowProtectedError");
function message(token, format3, input) {
const subject = token[0] === "Y" ? "years" : "days of the month";
return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format3}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
}
__name(message, "message");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isDate.js
function isDate(value) {
return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
}
__name(isDate, "isDate");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isValid.js
function isValid(date) {
return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
}
__name(isValid, "isValid");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/format.js
var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
var escapedStringRegExp = /^'([^]*?)'?$/;
var doubleQuoteRegExp = /''/g;
var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
function format(date, formatStr, options) {
const defaultOptions2 = getDefaultOptions();
const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
const originalDate = toDate(date, options?.in);
if (!isValid(originalDate)) {
throw new RangeError("Invalid time value");
}
let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
const firstCharacter = substring[0];
if (firstCharacter === "p" || firstCharacter === "P") {
const longFormatter = longFormatters[firstCharacter];
return longFormatter(substring, locale.formatLong);
}
return substring;
}).join("").match(formattingTokensRegExp).map((substring) => {
if (substring === "''") {
return { isToken: false, value: "'" };
}
const firstCharacter = substring[0];
if (firstCharacter === "'") {
return { isToken: false, value: cleanEscapedString(substring) };
}
if (formatters[firstCharacter]) {
return { isToken: true, value: substring };
}
if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
throw new RangeError(
"Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
);
}
return { isToken: false, value: substring };
});
if (locale.localize.preprocessor) {
parts = locale.localize.preprocessor(originalDate, parts);
}
const formatterOptions = {
firstWeekContainsDate,
weekStartsOn,
locale
};
return parts.map((part) => {
if (!part.isToken) return part.value;
const token = part.value;
if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
warnOrThrowProtectedError(token, formatStr, String(date));
}
const formatter = formatters[token[0]];
return formatter(originalDate, token, locale.localize, formatterOptions);
}).join("");
}
__name(format, "format");
function cleanEscapedString(input) {
const matched = input.match(escapedStringRegExp);
if (!matched) {
return input;
}
return matched[1].replace(doubleQuoteRegExp, "'");
}
__name(cleanEscapedString, "cleanEscapedString");
// node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDefaultOptions.js
function getDefaultOptions2() {
return Object.assign({}, getDefaultOptions());
}
__name(getDefaultOptions2, "getDefaultOptions");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/_lib/tzIntlTimeZoneName/index.js
function tzIntlTimeZoneName(length, date, options) {
const defaultOptions2 = getDefaultOptions2();
const dtf = getDTF(length, options.timeZone, options.locale ?? defaultOptions2.locale);
return "formatToParts" in dtf ? partsTimeZone(dtf, date) : hackyTimeZone(dtf, date);
}
__name(tzIntlTimeZoneName, "tzIntlTimeZoneName");
function partsTimeZone(dtf, date) {
const formatted = dtf.formatToParts(date);
for (let i = formatted.length - 1; i >= 0; --i) {
if (formatted[i].type === "timeZoneName") {
return formatted[i].value;
}
}
return void 0;
}
__name(partsTimeZone, "partsTimeZone");
function hackyTimeZone(dtf, date) {
const formatted = dtf.format(date).replace(/\u200E/g, "");
const tzNameMatch = / [\w-+ ]+$/.exec(formatted);
return tzNameMatch ? tzNameMatch[0].substr(1) : "";
}
__name(hackyTimeZone, "hackyTimeZone");
function getDTF(length, timeZone, locale) {
return new Intl.DateTimeFormat(locale ? [locale.code, "en-US"] : void 0, {
timeZone,
timeZoneName: length
});
}
__name(getDTF, "getDTF");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/_lib/tzTokenizeDate/index.js
function tzTokenizeDate(date, timeZone) {
const dtf = getDateTimeFormat(timeZone);
return "formatToParts" in dtf ? partsOffset(dtf, date) : hackyOffset(dtf, date);
}
__name(tzTokenizeDate, "tzTokenizeDate");
var typeToPos = {
year: 0,
month: 1,
day: 2,
hour: 3,
minute: 4,
second: 5
};
function partsOffset(dtf, date) {
try {
const formatted = dtf.formatToParts(date);
const filled = [];
for (let i = 0; i < formatted.length; i++) {
const pos = typeToPos[formatted[i].type];
if (pos !== void 0) {
filled[pos] = parseInt(formatted[i].value, 10);
}
}
return filled;
} catch (error) {
if (error instanceof RangeError) {
return [NaN];
}
throw error;
}
}
__name(partsOffset, "partsOffset");
function hackyOffset(dtf, date) {
const formatted = dtf.format(date);
const parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted);
return [
parseInt(parsed[3], 10),
parseInt(parsed[1], 10),
parseInt(parsed[2], 10),
parseInt(parsed[4], 10),
parseInt(parsed[5], 10),
parseInt(parsed[6], 10)
];
}
__name(hackyOffset, "hackyOffset");
var dtfCache = {};
var testDateFormatted = new Intl.DateTimeFormat("en-US", {
hourCycle: "h23",
timeZone: "America/New_York",
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
}).format(/* @__PURE__ */ new Date("2014-06-25T04:00:00.123Z"));
var hourCycleSupported = testDateFormatted === "06/25/2014, 00:00:00" || testDateFormatted === "\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";
function getDateTimeFormat(timeZone) {
if (!dtfCache[timeZone]) {
dtfCache[timeZone] = hourCycleSupported ? new Intl.DateTimeFormat("en-US", {
hourCycle: "h23",
timeZone,
year: "numeric",
month: "numeric",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
}) : new Intl.DateTimeFormat("en-US", {
hour12: false,
timeZone,
year: "numeric",
month: "numeric",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
});
}
return dtfCache[timeZone];
}
__name(getDateTimeFormat, "getDateTimeFormat");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/_lib/newDateUTC/index.js
function newDateUTC(fullYear, month, day, hour, minute, second, millisecond) {
const utcDate = /* @__PURE__ */ new Date(0);
utcDate.setUTCFullYear(fullYear, month, day);
utcDate.setUTCHours(hour, minute, second, millisecond);
return utcDate;
}
__name(newDateUTC, "newDateUTC");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/_lib/tzParseTimezone/index.js
var MILLISECONDS_IN_HOUR = 36e5;
var MILLISECONDS_IN_MINUTE = 6e4;
var patterns = {
timezone: /([Z+-].*)$/,
timezoneZ: /^(Z)$/,
timezoneHH: /^([+-]\d{2})$/,
timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
};
function tzParseTimezone(timezoneString, date, isUtcDate) {
if (!timezoneString) {
return 0;
}
let token = patterns.timezoneZ.exec(timezoneString);
if (token) {
return 0;
}
let hours;
let absoluteOffset;
token = patterns.timezoneHH.exec(timezoneString);
if (token) {
hours = parseInt(token[1], 10);
if (!validateTimezone(hours)) {
return NaN;
}
return -(hours * MILLISECONDS_IN_HOUR);
}
token = patterns.timezoneHHMM.exec(timezoneString);
if (token) {
hours = parseInt(token[2], 10);
const minutes = parseInt(token[3], 10);
if (!validateTimezone(hours, minutes)) {
return NaN;
}
absoluteOffset = Math.abs(hours) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE;
return token[1] === "+" ? -absoluteOffset : absoluteOffset;
}
if (isValidTimezoneIANAString(timezoneString)) {
date = new Date(date || Date.now());
const utcDate = isUtcDate ? date : toUtcDate(date);
const offset = calcOffset(utcDate, timezoneString);
const fixedOffset = isUtcDate ? offset : fixOffset(date, offset, timezoneString);
return -fixedOffset;
}
return NaN;
}
__name(tzParseTimezone, "tzParseTimezone");
function toUtcDate(date) {
return newDateUTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
}
__name(toUtcDate, "toUtcDate");
function calcOffset(date, timezoneString) {
const tokens = tzTokenizeDate(date, timezoneString);
const asUTC = newDateUTC(tokens[0], tokens[1] - 1, tokens[2], tokens[3] % 24, tokens[4], tokens[5], 0).getTime();
let asTS = date.getTime();
const over = asTS % 1e3;
asTS -= over >= 0 ? over : 1e3 + over;
return asUTC - asTS;
}
__name(calcOffset, "calcOffset");
function fixOffset(date, offset, timezoneString) {
const localTS = date.getTime();
let utcGuess = localTS - offset;
const o2 = calcOffset(new Date(utcGuess), timezoneString);
if (offset === o2) {
return offset;
}
utcGuess -= o2 - offset;
const o3 = calcOffset(new Date(utcGuess), timezoneString);
if (o2 === o3) {
return o2;
}
return Math.max(o2, o3);
}
__name(fixOffset, "fixOffset");
function validateTimezone(hours, minutes) {
return -23 <= hours && hours <= 23 && (minutes == null || 0 <= minutes && minutes <= 59);
}
__name(validateTimezone, "validateTimezone");
var validIANATimezoneCache = {};
function isValidTimezoneIANAString(timeZoneString) {
if (validIANATimezoneCache[timeZoneString])
return true;
try {
new Intl.DateTimeFormat(void 0, { timeZone: timeZoneString });
validIANATimezoneCache[timeZoneString] = true;
return true;
} catch (error) {
return false;
}
}
__name(isValidTimezoneIANAString, "isValidTimezoneIANAString");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/format/formatters/index.js
var MILLISECONDS_IN_MINUTE2 = 60 * 1e3;
var formatters2 = {
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
X: /* @__PURE__ */ __name(function(date, token, options) {
const timezoneOffset = getTimeZoneOffset(options.timeZone, date);
if (timezoneOffset === 0) {
return "Z";
}
switch (token) {
// Hours and optional minutes
case "X":
return formatTimezoneWithOptionalMinutes2(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimeter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XX`
case "XXXX":
case "XX":
return formatTimezone2(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimeter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XXX`
case "XXXXX":
case "XXX":
// Hours and minutes with `:` delimeter
default:
return formatTimezone2(timezoneOffset, ":");
}
}, "X"),
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
x: /* @__PURE__ */ __name(function(date, token, options) {
const timezoneOffset = getTimeZoneOffset(options.timeZone, date);
switch (token) {
// Hours and optional minutes
case "x":
return formatTimezoneWithOptionalMinutes2(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimeter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xx`
case "xxxx":
case "xx":
return formatTimezone2(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimeter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xxx`
case "xxxxx":
case "xxx":
// Hours and minutes with `:` delimeter
default:
return formatTimezone2(timezoneOffset, ":");
}
}, "x"),
// Timezone (GMT)
O: /* @__PURE__ */ __name(function(date, token, options) {
const timezoneOffset = getTimeZoneOffset(options.timeZone, date);
switch (token) {
// Short
case "O":
case "OO":
case "OOO":
return "GMT" + formatTimezoneShort2(timezoneOffset, ":");
// Long
case "OOOO":
default:
return "GMT" + formatTimezone2(timezoneOffset, ":");
}
}, "O"),
// Timezone (specific non-location)
z: /* @__PURE__ */ __name(function(date, token, options) {
switch (token) {
// Short
case "z":
case "zz":
case "zzz":
return tzIntlTimeZoneName("short", date, options);
// Long
case "zzzz":
default:
return tzIntlTimeZoneName("long", date, options);
}
}, "z")
};
function getTimeZoneOffset(timeZone, originalDate) {
const timeZoneOffset = timeZone ? tzParseTimezone(timeZone, originalDate, true) / MILLISECONDS_IN_MINUTE2 : originalDate?.getTimezoneOffset() ?? 0;
if (Number.isNaN(timeZoneOffset)) {
throw new RangeError("Invalid time zone specified: " + timeZone);
}
return timeZoneOffset;
}
__name(getTimeZoneOffset, "getTimeZoneOffset");
function addLeadingZeros2(number, targetLength) {
const sign = number < 0 ? "-" : "";
let output = Math.abs(number).toString();
while (output.length < targetLength) {
output = "0" + output;
}
return sign + output;
}
__name(addLeadingZeros2, "addLeadingZeros");
function formatTimezone2(offset, delimiter = "") {
const sign = offset > 0 ? "-" : "+";
const absOffset = Math.abs(offset);
const hours = addLeadingZeros2(Math.floor(absOffset / 60), 2);
const minutes = addLeadingZeros2(Math.floor(absOffset % 60), 2);
return sign + hours + delimiter + minutes;
}
__name(formatTimezone2, "formatTimezone");
function formatTimezoneWithOptionalMinutes2(offset, delimiter) {
if (offset % 60 === 0) {
const sign = offset > 0 ? "-" : "+";
return sign + addLeadingZeros2(Math.abs(offset) / 60, 2);
}
return formatTimezone2(offset, delimiter);
}
__name(formatTimezoneWithOptionalMinutes2, "formatTimezoneWithOptionalMinutes");
function formatTimezoneShort2(offset, delimiter = "") {
const sign = offset > 0 ? "-" : "+";
const absOffset = Math.abs(offset);
const hours = Math.floor(absOffset / 60);
const minutes = absOffset % 60;
if (minutes === 0) {
return sign + String(hours);
}
return sign + String(hours) + delimiter + addLeadingZeros2(minutes, 2);
}
__name(formatTimezoneShort2, "formatTimezoneShort");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/_lib/getTimezoneOffsetInMilliseconds/index.js
function getTimezoneOffsetInMilliseconds2(date) {
const utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
utcDate.setUTCFullYear(date.getFullYear());
return +date - +utcDate;
}
__name(getTimezoneOffsetInMilliseconds2, "getTimezoneOffsetInMilliseconds");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/_lib/tzPattern/index.js
var tzPattern = /(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/;
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/toDate/index.js
var MILLISECONDS_IN_HOUR2 = 36e5;
var MILLISECONDS_IN_MINUTE3 = 6e4;
var DEFAULT_ADDITIONAL_DIGITS = 2;
var patterns2 = {
dateTimePattern: /^([0-9W+-]+)(T| )(.*)/,
datePattern: /^([0-9W+-]+)(.*)/,
plainTime: /:/,
// year tokens
YY: /^(\d{2})$/,
YYY: [
/^([+-]\d{2})$/,
// 0 additional digits
/^([+-]\d{3})$/,
// 1 additional digit
/^([+-]\d{4})$/
// 2 additional digits
],
YYYY: /^(\d{4})/,
YYYYY: [
/^([+-]\d{4})/,
// 0 additional digits
/^([+-]\d{5})/,
// 1 additional digit
/^([+-]\d{6})/
// 2 additional digits
],
// date tokens
MM: /^-(\d{2})$/,
DDD: /^-?(\d{3})$/,
MMDD: /^-?(\d{2})-?(\d{2})$/,
Www: /^-?W(\d{2})$/,
WwwD: /^-?W(\d{2})-?(\d{1})$/,
HH: /^(\d{2}([.,]\d*)?)$/,
HHMM: /^(\d{2}):?(\d{2}([.,]\d*)?)$/,
HHMMSS: /^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,
// time zone tokens (to identify the presence of a tz)
timeZone: tzPattern
};
function toDate2(argument, options = {}) {
if (arguments.length < 1) {
throw new TypeError("1 argument required, but only " + arguments.length + " present");
}
if (argument === null) {
return /* @__PURE__ */ new Date(NaN);
}
const additionalDigits = options.additionalDigits == null ? DEFAULT_ADDITIONAL_DIGITS : Number(options.additionalDigits);
if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
throw new RangeError("additionalDigits must be 0, 1 or 2");
}
if (argument instanceof Date || typeof argument === "object" && Object.prototype.toString.call(argument) === "[object Date]") {
return new Date(argument.getTime());
} else if (typeof argument === "number" || Object.prototype.toString.call(argument) === "[object Number]") {
return new Date(argument);
} else if (!(Object.prototype.toString.call(argument) === "[object String]")) {
return /* @__PURE__ */ new Date(NaN);
}
const dateStrings = splitDateString(argument);
const { year, restDateString } = parseYear(dateStrings.date, additionalDigits);
const date = parseDate(restDateString, year);
if (date === null || isNaN(date.getTime())) {
return /* @__PURE__ */ new Date(NaN);
}
if (date) {
const timestamp = date.getTime();
let time = 0;
let offset;
if (dateStrings.time) {
time = parseTime(dateStrings.time);
if (time === null || isNaN(time)) {
return /* @__PURE__ */ new Date(NaN);
}
}
if (dateStrings.timeZone || options.timeZone) {
offset = tzParseTimezone(dateStrings.timeZone || options.timeZone, new Date(timestamp + time));
if (isNaN(offset)) {
return /* @__PURE__ */ new Date(NaN);
}
} else {
offset = getTimezoneOffsetInMilliseconds2(new Date(timestamp + time));
offset = getTimezoneOffsetInMilliseconds2(new Date(timestamp + time + offset));
}
return new Date(timestamp + time + offset);
} else {
return /* @__PURE__ */ new Date(NaN);
}
}
__name(toDate2, "toDate");
function splitDateString(dateString) {
const dateStrings = {};
let parts = patterns2.dateTimePattern.exec(dateString);
let timeString;
if (!parts) {
parts = patterns2.datePattern.exec(dateString);
if (parts) {
dateStrings.date = parts[1];
timeString = parts[2];
} else {
dateStrings.date = null;
timeString = dateString;
}
} else {
dateStrings.date = parts[1];
timeString = parts[3];
}
if (timeString) {
const token = patterns2.timeZone.exec(timeString);
if (token) {
dateStrings.time = timeString.replace(token[1], "");
dateStrings.timeZone = token[1].trim();
} else {
dateStrings.time = timeString;
}
}
return dateStrings;
}
__name(splitDateString, "splitDateString");
function parseYear(dateString, additionalDigits) {
if (dateString) {
const patternYYY = patterns2.YYY[additionalDigits];
const patternYYYYY = patterns2.YYYYY[additionalDigits];
let token = patterns2.YYYY.exec(dateString) || patternYYYYY.exec(dateString);
if (token) {
const yearString = token[1];
return {
year: parseInt(yearString, 10),
restDateString: dateString.slice(yearString.length)
};
}
token = patterns2.YY.exec(dateString) || patternYYY.exec(dateString);
if (token) {
const centuryString = token[1];
return {
year: parseInt(centuryString, 10) * 100,
restDateString: dateString.slice(centuryString.length)
};
}
}
return {
year: null
};
}
__name(parseYear, "parseYear");
function parseDate(dateString, year) {
if (year === null) {
return null;
}
let date;
let month;
let week;
if (!dateString || !dateString.length) {
date = /* @__PURE__ */ new Date(0);
date.setUTCFullYear(year);
return date;
}
let token = patterns2.MM.exec(dateString);
if (token) {
date = /* @__PURE__ */ new Date(0);
month = parseInt(token[1], 10) - 1;
if (!validateDate(year, month)) {
return /* @__PURE__ */ new Date(NaN);
}
date.setUTCFullYear(year, month);
return date;
}
token = patterns2.DDD.exec(dateString);
if (token) {
date = /* @__PURE__ */ new Date(0);
const dayOfYear = parseInt(token[1], 10);
if (!validateDayOfYearDate(year, dayOfYear)) {
return /* @__PURE__ */ new Date(NaN);
}
date.setUTCFullYear(year, 0, dayOfYear);
return date;
}
token = patterns2.MMDD.exec(dateString);
if (token) {
date = /* @__PURE__ */ new Date(0);
month = parseInt(token[1], 10) - 1;
const day = parseInt(token[2], 10);
if (!validateDate(year, month, day)) {
return /* @__PURE__ */ new Date(NaN);
}
date.setUTCFullYear(year, month, day);
return date;
}
token = patterns2.Www.exec(dateString);
if (token) {
week = parseInt(token[1], 10) - 1;
if (!validateWeekDate(week)) {
return /* @__PURE__ */ new Date(NaN);
}
return dayOfISOWeekYear(year, week);
}
token = patterns2.WwwD.exec(dateString);
if (token) {
week = parseInt(token[1], 10) - 1;
const dayOfWeek = parseInt(token[2], 10) - 1;
if (!validateWeekDate(week, dayOfWeek)) {
return /* @__PURE__ */ new Date(NaN);
}
return dayOfISOWeekYear(year, week, dayOfWeek);
}
return null;
}
__name(parseDate, "parseDate");
function parseTime(timeString) {
let hours;
let minutes;
let token = patterns2.HH.exec(timeString);
if (token) {
hours = parseFloat(token[1].replace(",", "."));
if (!validateTime(hours)) {
return NaN;
}
return hours % 24 * MILLISECONDS_IN_HOUR2;
}
token = patterns2.HHMM.exec(timeString);
if (token) {
hours = parseInt(token[1], 10);
minutes = parseFloat(token[2].replace(",", "."));
if (!validateTime(hours, minutes)) {
return NaN;
}
return hours % 24 * MILLISECONDS_IN_HOUR2 + minutes * MILLISECONDS_IN_MINUTE3;
}
token = patterns2.HHMMSS.exec(timeString);
if (token) {
hours = parseInt(token[1], 10);
minutes = parseInt(token[2], 10);
const seconds = parseFloat(token[3].replace(",", "."));
if (!validateTime(hours, minutes, seconds)) {
return NaN;
}
return hours % 24 * MILLISECONDS_IN_HOUR2 + minutes * MILLISECONDS_IN_MINUTE3 + seconds * 1e3;
}
return null;
}
__name(parseTime, "parseTime");
function dayOfISOWeekYear(isoWeekYear, week, day) {
week = week || 0;
day = day || 0;
const date = /* @__PURE__ */ new Date(0);
date.setUTCFullYear(isoWeekYear, 0, 4);
const fourthOfJanuaryDay = date.getUTCDay() || 7;
const diff = week * 7 + day + 1 - fourthOfJanuaryDay;
date.setUTCDate(date.getUTCDate() + diff);
return date;
}
__name(dayOfISOWeekYear, "dayOfISOWeekYear");
var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var DAYS_IN_MONTH_LEAP_YEAR = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function isLeapYearIndex(year) {
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
}
__name(isLeapYearIndex, "isLeapYearIndex");
function validateDate(year, month, date) {
if (month < 0 || month > 11) {
return false;
}
if (date != null) {
if (date < 1) {
return false;
}
const isLeapYear = isLeapYearIndex(year);
if (isLeapYear && date > DAYS_IN_MONTH_LEAP_YEAR[month]) {
return false;
}
if (!isLeapYear && date > DAYS_IN_MONTH[month]) {
return false;
}
}
return true;
}
__name(validateDate, "validateDate");
function validateDayOfYearDate(year, dayOfYear) {
if (dayOfYear < 1) {
return false;
}
const isLeapYear = isLeapYearIndex(year);
if (isLeapYear && dayOfYear > 366) {
return false;
}
if (!isLeapYear && dayOfYear > 365) {
return false;
}
return true;
}
__name(validateDayOfYearDate, "validateDayOfYearDate");
function validateWeekDate(week, day) {
if (week < 0 || week > 52) {
return false;
}
if (day != null && (day < 0 || day > 6)) {
return false;
}
return true;
}
__name(validateWeekDate, "validateWeekDate");
function validateTime(hours, minutes, seconds) {
if (hours < 0 || hours >= 25) {
return false;
}
if (minutes != null && (minutes < 0 || minutes >= 60)) {
return false;
}
if (seconds != null && (seconds < 0 || seconds >= 60)) {
return false;
}
return true;
}
__name(validateTime, "validateTime");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/format/index.js
var tzFormattingTokensRegExp = /([xXOz]+)|''|'(''|[^'])+('|$)/g;
function format2(date, formatStr, options = {}) {
formatStr = String(formatStr);
const matches = formatStr.match(tzFormattingTokensRegExp);
if (matches) {
const d = toDate2(options.originalDate || date, options);
formatStr = matches.reduce(function(result, token) {
if (token[0] === "'") {
return result;
}
const pos = result.indexOf(token);
const precededByQuotedSection = result[pos - 1] === "'";
const replaced = result.replace(token, "'" + formatters2[token[0]](d, token, options) + "'");
return precededByQuotedSection ? replaced.substring(0, pos - 1) + replaced.substring(pos + 1) : replaced;
}, formatStr);
}
return format(date, formatStr, options);
}
__name(format2, "format");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/toZonedTime/index.js
function toZonedTime(date, timeZone, options) {
date = toDate2(date, options);
const offsetMilliseconds = tzParseTimezone(timeZone, date, true);
const d = new Date(date.getTime() - offsetMilliseconds);
const resultDate = /* @__PURE__ */ new Date(0);
resultDate.setFullYear(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
resultDate.setHours(d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds());
return resultDate;
}
__name(toZonedTime, "toZonedTime");
// node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/formatInTimeZone/index.js
function formatInTimeZone(date, timeZone, formatStr, options) {
options = {
...options,
timeZone,
originalDate: date
};
return format2(toZonedTime(date, timeZone, { timeZone: options.timeZone }), formatStr, options);
}
__name(formatInTimeZone, "formatInTimeZone");
// functions/[[path]].ts
var { preflight, corsify } = y();
var router = t();
router.all("/*", preflight);
router.all("/(ajax|rpc)/:path+", async (req, env) => {
const url = new URL(req.url);
url.hostname = "www.pixiv.net";
const headers = new Headers(req.headers);
headers.set("origin", "https://www.pixiv.net");
headers.set("referer", "https://www.pixiv.net/");
const newReq = new Request(url.toString(), {
method: req.method,
headers,
body: req.body
});
return fetch(newReq);
});
router.all("/(~|-)/:path+", async (req, env) => {
const url = new URL(req.url);
const prefix = url.pathname.split("/")[1];
switch (prefix) {
case "-":
url.hostname = "i.pximg.net";
break;
case "~":
url.hostname = "s.pximg.net";
break;
default:
return new Response("Invalid request", { status: 400 });
}
url.pathname = url.pathname.substring(prefix.length + 1);
const headers = new Headers();
const proxyHeaders = [
"accept",
"accept-encoding",
"accept-language",
"range",
"if-range",
"if-none-match",
"if-modified-since",
"cache-control"
];
for (const h2 of proxyHeaders) {
if (req.headers.has(h2)) {
headers.set(h2, req.headers.get(h2));
}
}
headers.set("referer", "https://www.pixiv.net/");
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
const newReq = new Request(url.toString(), {
headers
});
return fetch(newReq);
});
router.all("/api/illust/random", async (req, env) => {
const url = new URL(req.url);
url.hostname = "www.pixiv.net";
url.pathname = "/ajax/illust/discovery";
const requestImage = (req.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
url.searchParams.set("mode", url.searchParams.get("mode") ?? "safe");
url.searchParams.set("max", requestImage ? "1" : url.searchParams.get("max") ?? "18");
const headers = new Headers(req.headers);
headers.set("referer", "https://www.pixiv.net/");
const newReq = new Request(url.toString(), {
headers
});
const res = await fetch(newReq);
const data = await res.json();
const illusts = (data.illusts ?? []).filter(
(value) => Object.keys(value).includes("id")
);
const PXIMG_BASEURL_I = (env.VITE_PXIMG_BASEURL_I || "https://i.pximg.net/").replace(/\/$/, "") + "/";
illusts.forEach((value) => {
try {
const updateDate = new Date(value.updateDate);
const middle = `img/${formatInTimeZone(
updateDate,
"Asia/Tokyo",
"yyyy/MM/dd/HH/mm/ss"
)}/${value.id}`;
value.urls = {
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
};
} catch (error) {
console.error("Error formatting date for illust:", value.id, error);
value.urls = {
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/img/2024/01/01/00/00/00/${value.id}_p0_square1200.jpg`,
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/img/2024/01/01/00/00/00/${value.id}_p0_square1200.jpg`,
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/img/2024/01/01/00/00/00/${value.id}_p0_master1200.jpg`,
regular: `${PXIMG_BASEURL_I}img-master/img/2024/01/01/00/00/00/${value.id}_p0_master1200.jpg`,
original: `${PXIMG_BASEURL_I}img-original/img/2024/01/01/00/00/00/${value.id}_p0.jpg`
};
}
});
if (requestImage) {
return new Response(null, { status: 302, headers: { Location: illusts[0].urls.regular } });
}
return new Response(JSON.stringify(illusts), {
headers: { "Content-Type": "application/json" }
});
});
router.all("/api/user", async (req, env) => {
const token = req.headers.get("cookie")?.match(/PHPSESSID=([^;]+)/)?.[1] || new URL(req.url).searchParams.get("token");
if (!token) {
return new Response(JSON.stringify({ message: "\u672A\u914D\u7F6E\u7528\u6237\u5BC6\u94A5" }), { status: 403, headers: { "Content-Type": "application/json" } });
}
const url = new URL(req.url);
url.hostname = "www.pixiv.net";
url.pathname = "/";
const headers = new Headers(req.headers);
headers.set("cookie", `PHPSESSID=${token}`);
const newReq = new Request(url.toString(), {
headers
});
const res = await fetch(newReq);
const text = await res.text();
let meta = null;
class MetaHandler {
constructor(type) {
this.type = type;
}
static {
__name(this, "MetaHandler");
}
text(chunk) {
try {
if (this.type === "legacy") {
const data = JSON.parse(chunk.text);
meta = {
userData: data.userData,
token: data.token || ""
};
} else {
const nextData = JSON.parse(chunk.text);
const perloadState = JSON.parse(
nextData?.props?.pageProps?.serverSerializedPreloadedState
);
meta = {
userData: perloadState?.userData?.self,
token: perloadState?.api?.token || ""
};
}
} catch (e) {
console.error("Error parsing meta", e);
}
}
}
const rewriter = new HTMLRewriter().on('meta[name="global-data"]', new MetaHandler("legacy")).on("script#__NEXT_DATA__", new MetaHandler("next"));
await rewriter.transform(new Response(text)).text();
if (!meta || !meta.userData) {
return new Response(JSON.stringify({ message: "\u65E0\u6CD5\u83B7\u53D6\u767B\u5F55\u72B6\u6001" }), { status: 401, headers: { "Content-Type": "application/json" } });
}
const responseHeaders = new Headers({
"cache-control": "no-cache",
"set-cookie": `CSRFTOKEN=${meta.token}; path=/; secure; sameSite=Lax`,
"Content-Type": "application/json"
});
return new Response(JSON.stringify(meta), { headers: responseHeaders });
});
var path_default = {
fetch: /* @__PURE__ */ __name((req, env, ctx) => router.handle(req, env, ctx).then(corsify).catch((err) => {
console.error(err);
return new Response("Internal Server Error", { status: 500 });
}), "fetch")
};
// node_modules/.pnpm/wrangler@4.42.1/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts
var drainBody = /* @__PURE__ */ __name(async (request, env, _ctx, middlewareCtx) => {
try {
return await middlewareCtx.next(request, env);
} finally {
try {
if (request.body !== null && !request.bodyUsed) {
const reader = request.body.getReader();
while (!(await reader.read()).done) {
}
}
} catch (e) {
console.error("Failed to drain the unused request body.", e);
}
}
}, "drainBody");
var middleware_ensure_req_body_drained_default = drainBody;
// node_modules/.pnpm/wrangler@4.42.1/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts
function reduceError(e) {
return {
name: e?.name,
message: e?.message ?? String(e),
stack: e?.stack,
cause: e?.cause === void 0 ? void 0 : reduceError(e.cause)
};
}
__name(reduceError, "reduceError");
var jsonError = /* @__PURE__ */ __name(async (request, env, _ctx, middlewareCtx) => {
try {
return await middlewareCtx.next(request, env);
} catch (e) {
const error = reduceError(e);
return Response.json(error, {
status: 500,
headers: { "MF-Experimental-Error-Stack": "true" }
});
}
}, "jsonError");
var middleware_miniflare3_json_error_default = jsonError;
// .wrangler/tmp/bundle-lcE67Q/middleware-insertion-facade.js
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
middleware_ensure_req_body_drained_default,
middleware_miniflare3_json_error_default
];
var middleware_insertion_facade_default = path_default;
// node_modules/.pnpm/wrangler@4.42.1/node_modules/wrangler/templates/middleware/common.ts
var __facade_middleware__ = [];
function __facade_register__(...args) {
__facade_middleware__.push(...args.flat());
}
__name(__facade_register__, "__facade_register__");
function __facade_invokeChain__(request, env, ctx, dispatch, middlewareChain) {
const [head, ...tail] = middlewareChain;
const middlewareCtx = {
dispatch,
next(newRequest, newEnv) {
return __facade_invokeChain__(newRequest, newEnv, ctx, dispatch, tail);
}
};
return head(request, env, ctx, middlewareCtx);
}
__name(__facade_invokeChain__, "__facade_invokeChain__");
function __facade_invoke__(request, env, ctx, dispatch, finalMiddleware) {
return __facade_invokeChain__(request, env, ctx, dispatch, [
...__facade_middleware__,
finalMiddleware
]);
}
__name(__facade_invoke__, "__facade_invoke__");
// .wrangler/tmp/bundle-lcE67Q/middleware-loader.entry.ts
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
constructor(scheduledTime, cron, noRetry) {
this.scheduledTime = scheduledTime;
this.cron = cron;
this.#noRetry = noRetry;
}
static {
__name(this, "__Facade_ScheduledController__");
}
#noRetry;
noRetry() {
if (!(this instanceof ___Facade_ScheduledController__)) {
throw new TypeError("Illegal invocation");
}
this.#noRetry();
}
};
function wrapExportedHandler(worker) {
if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) {
return worker;
}
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
__facade_register__(middleware);
}
const fetchDispatcher = /* @__PURE__ */ __name(function(request, env, ctx) {
if (worker.fetch === void 0) {
throw new Error("Handler does not export a fetch() function.");
}
return worker.fetch(request, env, ctx);
}, "fetchDispatcher");
return {
...worker,
fetch(request, env, ctx) {
const dispatcher = /* @__PURE__ */ __name(function(type, init) {
if (type === "scheduled" && worker.scheduled !== void 0) {
const controller = new __Facade_ScheduledController__(
Date.now(),
init.cron ?? "",
() => {
}
);
return worker.scheduled(controller, env, ctx);
}
}, "dispatcher");
return __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher);
}
};
}
__name(wrapExportedHandler, "wrapExportedHandler");
function wrapWorkerEntrypoint(klass) {
if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) {
return klass;
}
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
__facade_register__(middleware);
}
return class extends klass {
#fetchDispatcher = /* @__PURE__ */ __name((request, env, ctx) => {
this.env = env;
this.ctx = ctx;
if (super.fetch === void 0) {
throw new Error("Entrypoint class does not define a fetch() function.");
}
return super.fetch(request);
}, "#fetchDispatcher");
#dispatcher = /* @__PURE__ */ __name((type, init) => {
if (type === "scheduled" && super.scheduled !== void 0) {
const controller = new __Facade_ScheduledController__(
Date.now(),
init.cron ?? "",
() => {
}
);
return super.scheduled(controller);
}
}, "#dispatcher");
fetch(request) {
return __facade_invoke__(
request,
this.env,
this.ctx,
this.#dispatcher,
this.#fetchDispatcher
);
}
};
}
__name(wrapWorkerEntrypoint, "wrapWorkerEntrypoint");
var WRAPPED_ENTRY;
if (typeof middleware_insertion_facade_default === "object") {
WRAPPED_ENTRY = wrapExportedHandler(middleware_insertion_facade_default);
} else if (typeof middleware_insertion_facade_default === "function") {
WRAPPED_ENTRY = wrapWorkerEntrypoint(middleware_insertion_facade_default);
}
var middleware_loader_entry_default = WRAPPED_ENTRY;
export {
__INTERNAL_WRANGLER_MIDDLEWARE__,
middleware_loader_entry_default as default
};
//# sourceMappingURL=%5B%5Bpath%5D%5D.js.map