From 2151215509838dc8a1cf784d0b9cab851a6034da Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Wed, 2 Oct 2024 10:03:11 +0200 Subject: [PATCH] fix: build actions --- .../createOrUpdateStagingDeploy.ts | 2 +- .../createOrUpdateStagingDeploy/index.js | 14195 ++++++++-------- 2 files changed, 7448 insertions(+), 6749 deletions(-) diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.ts b/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.ts index caff455e9fa5..7b35cc1915ae 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.ts +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.ts @@ -1,5 +1,5 @@ import * as core from '@actions/core'; -import format from 'date-fns/format'; +import {format} from 'date-fns/format'; import fs from 'fs'; import CONST from '@github/libs/CONST'; import GithubUtils from '@github/libs/GithubUtils'; diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index d3e249ee6f47..5c28cab60a90 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -6439,5371 +6439,2616 @@ function removeHook(state, name, method) { /***/ }), -/***/ 8620: -/***/ ((module, exports) => { +/***/ 8932: +/***/ ((__unused_webpack_module, exports) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = addLeadingZeros; -function addLeadingZeros(number, targetLength) { - var sign = number < 0 ? '-' : ''; - var output = Math.abs(number).toString(); - while (output.length < targetLength) { - output = '0' + output; - } - return sign + output; -} -module.exports = exports.default; +Object.defineProperty(exports, "__esModule", ({ value: true })); -/***/ }), +class Deprecation extends Error { + constructor(message) { + super(message); // Maintains proper stack trace (only available on V8) -/***/ 618: -/***/ ((module, exports, __nccwpck_require__) => { + /* istanbul ignore next */ -"use strict"; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); + } + this.name = 'Deprecation'; + } + +} + +exports.Deprecation = Deprecation; -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _index = _interopRequireDefault(__nccwpck_require__(1773)); -var _default = _index.default; -exports["default"] = _default; -module.exports = exports.default; /***/ }), -/***/ 9307: +/***/ 3287: /***/ ((__unused_webpack_module, exports) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.getDefaultOptions = getDefaultOptions; -exports.setDefaultOptions = setDefaultOptions; -var defaultOptions = {}; -function getDefaultOptions() { - return defaultOptions; +Object.defineProperty(exports, "__esModule", ({ value: true })); + +/*! + * is-plain-object + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ + +function isObject(o) { + return Object.prototype.toString.call(o) === '[object Object]'; } -function setDefaultOptions(newOptions) { - defaultOptions = newOptions; + +function isPlainObject(o) { + var ctor,prot; + + if (isObject(o) === false) return false; + + // If has modified constructor + ctor = o.constructor; + if (ctor === undefined) return true; + + // If has modified prototype + prot = ctor.prototype; + if (isObject(prot) === false) return false; + + // If constructor does not have an Object-specific method + if (prot.hasOwnProperty('isPrototypeOf') === false) { + return false; + } + + // Most likely a plain Object + return true; } +exports.isPlainObject = isPlainObject; + + /***/ }), -/***/ 9257: +/***/ 467: /***/ ((module, exports, __nccwpck_require__) => { "use strict"; -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _index = _interopRequireDefault(__nccwpck_require__(2966)); -var _index2 = _interopRequireDefault(__nccwpck_require__(8493)); -var _index3 = _interopRequireDefault(__nccwpck_require__(7170)); -var _index4 = _interopRequireDefault(__nccwpck_require__(8761)); -var _index5 = _interopRequireDefault(__nccwpck_require__(8050)); -var _index6 = _interopRequireDefault(__nccwpck_require__(8620)); -var _index7 = _interopRequireDefault(__nccwpck_require__(289)); -var dayPeriodEnum = { - am: 'am', - pm: 'pm', - midnight: 'midnight', - noon: 'noon', - morning: 'morning', - afternoon: 'afternoon', - evening: 'evening', - night: 'night' -}; -/* - * | | Unit | | Unit | - * |-----|--------------------------------|-----|--------------------------------| - * | a | AM, PM | A* | Milliseconds in day | - * | b | AM, PM, noon, midnight | B | Flexible day period | - * | c | Stand-alone local day of week | C* | Localized hour w/ day period | - * | d | Day of month | D | Day of year | - * | e | Local day of week | E | Day of week | - * | f | | F* | Day of week in month | - * | g* | Modified Julian day | G | Era | - * | h | Hour [1-12] | H | Hour [0-23] | - * | i! | ISO day of week | I! | ISO week of year | - * | j* | Localized hour w/ day period | J* | Localized hour w/o day period | - * | k | Hour [1-24] | K | Hour [0-11] | - * | l* | (deprecated) | L | Stand-alone month | - * | m | Minute | M | Month | - * | n | | N | | - * | o! | Ordinal number modifier | O | Timezone (GMT) | - * | p! | Long localized time | P! | Long localized date | - * | q | Stand-alone quarter | Q | Quarter | - * | r* | Related Gregorian year | R! | ISO week-numbering year | - * | s | Second | S | Fraction of second | - * | t! | Seconds timestamp | T! | Milliseconds timestamp | - * | u | Extended year | U* | Cyclic year | - * | v* | Timezone (generic non-locat.) | V* | Timezone (location) | - * | w | Local week of year | W* | Week of month | - * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) | - * | y | Year (abs) | Y | Local week-numbering year | - * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) | - * - * Letters marked by * are not implemented but reserved by Unicode standard. - * - * Letters marked by ! are non-standard, but implemented by date-fns: - * - `o` modifies the previous token to turn it into an ordinal (see `format` docs) - * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days, - * i.e. 7 for Sunday, 1 for Monday, etc. - * - `I` is ISO week of year, as opposed to `w` which is local week of year. - * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year. - * `R` is supposed to be used in conjunction with `I` and `i` - * for universal ISO week-numbering date, whereas - * `Y` is supposed to be used in conjunction with `w` and `e` - * for week-numbering date specific to the locale. - * - `P` is long localized date format - * - `p` is long localized time format - */ +Object.defineProperty(exports, "__esModule", ({ value: true })); -var formatters = { - // Era - G: function G(date, token, localize) { - var era = date.getUTCFullYear() > 0 ? 1 : 0; - switch (token) { - // AD, BC - case 'G': - case 'GG': - case 'GGG': - return localize.era(era, { - width: 'abbreviated' - }); - // A, B - case 'GGGGG': - return localize.era(era, { - width: 'narrow' - }); - // Anno Domini, Before Christ - case 'GGGG': - default: - return localize.era(era, { - width: 'wide' - }); - } - }, - // Year - y: function y(date, token, localize) { - // Ordinal number - if (token === 'yo') { - var signedYear = date.getUTCFullYear(); - // Returns 1 for 1 BC (which is year 0 in JavaScript) - var year = signedYear > 0 ? signedYear : 1 - signedYear; - return localize.ordinalNumber(year, { - unit: 'year' - }); - } - return _index7.default.y(date, token); - }, - // Local week-numbering year - Y: function Y(date, token, localize, options) { - var signedWeekYear = (0, _index5.default)(date, options); - // Returns 1 for 1 BC (which is year 0 in JavaScript) - var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } - // Two digit year - if (token === 'YY') { - var twoDigitYear = weekYear % 100; - return (0, _index6.default)(twoDigitYear, 2); - } +var Stream = _interopDefault(__nccwpck_require__(2781)); +var http = _interopDefault(__nccwpck_require__(3685)); +var Url = _interopDefault(__nccwpck_require__(7310)); +var whatwgUrl = _interopDefault(__nccwpck_require__(3323)); +var https = _interopDefault(__nccwpck_require__(5687)); +var zlib = _interopDefault(__nccwpck_require__(9796)); - // Ordinal number - if (token === 'Yo') { - return localize.ordinalNumber(weekYear, { - unit: 'year' - }); - } +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js - // Padding - return (0, _index6.default)(weekYear, token.length); - }, - // ISO week-numbering year - R: function R(date, token) { - var isoWeekYear = (0, _index3.default)(date); +// fix for "Readable" isn't a named export issue +const Readable = Stream.Readable; - // Padding - return (0, _index6.default)(isoWeekYear, token.length); - }, - // 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: function u(date, token) { - var year = date.getUTCFullYear(); - return (0, _index6.default)(year, token.length); - }, - // Quarter - Q: function Q(date, token, localize) { - var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); - switch (token) { - // 1, 2, 3, 4 - case 'Q': - return String(quarter); - // 01, 02, 03, 04 - case 'QQ': - return (0, _index6.default)(quarter, 2); - // 1st, 2nd, 3rd, 4th - case 'Qo': - return localize.ordinalNumber(quarter, { - unit: 'quarter' - }); - // Q1, Q2, Q3, Q4 - case 'QQQ': - return localize.quarter(quarter, { - width: 'abbreviated', - context: 'formatting' - }); - // 1, 2, 3, 4 (narrow quarter; could be not numerical) - case 'QQQQQ': - return localize.quarter(quarter, { - width: 'narrow', - context: 'formatting' - }); - // 1st quarter, 2nd quarter, ... - case 'QQQQ': - default: - return localize.quarter(quarter, { - width: 'wide', - context: 'formatting' - }); - } - }, - // Stand-alone quarter - q: function q(date, token, localize) { - var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); - switch (token) { - // 1, 2, 3, 4 - case 'q': - return String(quarter); - // 01, 02, 03, 04 - case 'qq': - return (0, _index6.default)(quarter, 2); - // 1st, 2nd, 3rd, 4th - case 'qo': - return localize.ordinalNumber(quarter, { - unit: 'quarter' - }); - // Q1, Q2, Q3, Q4 - case 'qqq': - return localize.quarter(quarter, { - width: 'abbreviated', - context: 'standalone' - }); - // 1, 2, 3, 4 (narrow quarter; could be not numerical) - case 'qqqqq': - return localize.quarter(quarter, { - width: 'narrow', - context: 'standalone' - }); - // 1st quarter, 2nd quarter, ... - case 'qqqq': - default: - return localize.quarter(quarter, { - width: 'wide', - context: 'standalone' - }); - } - }, - // Month - M: function M(date, token, localize) { - var month = date.getUTCMonth(); - switch (token) { - case 'M': - case 'MM': - return _index7.default.M(date, token); - // 1st, 2nd, ..., 12th - case 'Mo': - return localize.ordinalNumber(month + 1, { - unit: 'month' - }); - // Jan, Feb, ..., Dec - case 'MMM': - return localize.month(month, { - width: 'abbreviated', - context: 'formatting' - }); - // J, F, ..., D - case 'MMMMM': - return localize.month(month, { - width: 'narrow', - context: 'formatting' - }); - // January, February, ..., December - case 'MMMM': - default: - return localize.month(month, { - width: 'wide', - context: 'formatting' - }); - } - }, - // Stand-alone month - L: function L(date, token, localize) { - var month = date.getUTCMonth(); - switch (token) { - // 1, 2, ..., 12 - case 'L': - return String(month + 1); - // 01, 02, ..., 12 - case 'LL': - return (0, _index6.default)(month + 1, 2); - // 1st, 2nd, ..., 12th - case 'Lo': - return localize.ordinalNumber(month + 1, { - unit: 'month' - }); - // Jan, Feb, ..., Dec - case 'LLL': - return localize.month(month, { - width: 'abbreviated', - context: 'standalone' - }); - // J, F, ..., D - case 'LLLLL': - return localize.month(month, { - width: 'narrow', - context: 'standalone' - }); - // January, February, ..., December - case 'LLLL': - default: - return localize.month(month, { - width: 'wide', - context: 'standalone' - }); - } - }, - // Local week of year - w: function w(date, token, localize, options) { - var week = (0, _index4.default)(date, options); - if (token === 'wo') { - return localize.ordinalNumber(week, { - unit: 'week' - }); - } - return (0, _index6.default)(week, token.length); - }, - // ISO week of year - I: function I(date, token, localize) { - var isoWeek = (0, _index2.default)(date); - if (token === 'Io') { - return localize.ordinalNumber(isoWeek, { - unit: 'week' - }); - } - return (0, _index6.default)(isoWeek, token.length); - }, - // Day of the month - d: function d(date, token, localize) { - if (token === 'do') { - return localize.ordinalNumber(date.getUTCDate(), { - unit: 'date' - }); - } - return _index7.default.d(date, token); - }, - // Day of year - D: function D(date, token, localize) { - var dayOfYear = (0, _index.default)(date); - if (token === 'Do') { - return localize.ordinalNumber(dayOfYear, { - unit: 'dayOfYear' - }); - } - return (0, _index6.default)(dayOfYear, token.length); - }, - // Day of week - E: function E(date, token, localize) { - var dayOfWeek = date.getUTCDay(); - switch (token) { - // Tue - case 'E': - case 'EE': - case 'EEE': - return localize.day(dayOfWeek, { - width: 'abbreviated', - context: 'formatting' - }); - // T - case 'EEEEE': - return localize.day(dayOfWeek, { - width: 'narrow', - context: 'formatting' - }); - // Tu - case 'EEEEEE': - return localize.day(dayOfWeek, { - width: 'short', - context: 'formatting' - }); - // Tuesday - case 'EEEE': - default: - return localize.day(dayOfWeek, { - width: 'wide', - context: 'formatting' - }); - } - }, - // Local day of week - e: function e(date, token, localize, options) { - var dayOfWeek = date.getUTCDay(); - var 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 (0, _index6.default)(localDayOfWeek, 2); - // 1st, 2nd, ..., 7th - case 'eo': - return localize.ordinalNumber(localDayOfWeek, { - unit: 'day' - }); - case 'eee': - return localize.day(dayOfWeek, { - width: 'abbreviated', - context: 'formatting' - }); - // T - case 'eeeee': - return localize.day(dayOfWeek, { - width: 'narrow', - context: 'formatting' - }); - // Tu - case 'eeeeee': - return localize.day(dayOfWeek, { - width: 'short', - context: 'formatting' - }); - // Tuesday - case 'eeee': - default: - return localize.day(dayOfWeek, { - width: 'wide', - context: 'formatting' - }); - } - }, - // Stand-alone local day of week - c: function c(date, token, localize, options) { - var dayOfWeek = date.getUTCDay(); - var 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 (0, _index6.default)(localDayOfWeek, token.length); - // 1st, 2nd, ..., 7th - case 'co': - return localize.ordinalNumber(localDayOfWeek, { - unit: 'day' - }); - case 'ccc': - return localize.day(dayOfWeek, { - width: 'abbreviated', - context: 'standalone' - }); - // T - case 'ccccc': - return localize.day(dayOfWeek, { - width: 'narrow', - context: 'standalone' - }); - // Tu - case 'cccccc': - return localize.day(dayOfWeek, { - width: 'short', - context: 'standalone' - }); - // Tuesday - case 'cccc': - default: - return localize.day(dayOfWeek, { - width: 'wide', - context: 'standalone' - }); - } - }, - // ISO day of week - i: function i(date, token, localize) { - var dayOfWeek = date.getUTCDay(); - var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; - switch (token) { - // 2 - case 'i': - return String(isoDayOfWeek); - // 02 - case 'ii': - return (0, _index6.default)(isoDayOfWeek, token.length); - // 2nd - case 'io': - return localize.ordinalNumber(isoDayOfWeek, { - unit: 'day' - }); - // Tue - case 'iii': - return localize.day(dayOfWeek, { - width: 'abbreviated', - context: 'formatting' - }); - // T - case 'iiiii': - return localize.day(dayOfWeek, { - width: 'narrow', - context: 'formatting' - }); - // Tu - case 'iiiiii': - return localize.day(dayOfWeek, { - width: 'short', - context: 'formatting' - }); - // Tuesday - case 'iiii': - default: - return localize.day(dayOfWeek, { - width: 'wide', - context: 'formatting' - }); - } - }, - // AM or PM - a: function a(date, token, localize) { - var hours = date.getUTCHours(); - var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am'; - switch (token) { - case 'a': - case 'aa': - return localize.dayPeriod(dayPeriodEnumValue, { - width: 'abbreviated', - context: 'formatting' - }); - case 'aaa': - return localize.dayPeriod(dayPeriodEnumValue, { - width: 'abbreviated', - context: 'formatting' - }).toLowerCase(); - case 'aaaaa': - return localize.dayPeriod(dayPeriodEnumValue, { - width: 'narrow', - context: 'formatting' - }); - case 'aaaa': - default: - return localize.dayPeriod(dayPeriodEnumValue, { - width: 'wide', - context: 'formatting' - }); - } - }, - // AM, PM, midnight, noon - b: function b(date, token, localize) { - var hours = date.getUTCHours(); - var 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 localize.dayPeriod(dayPeriodEnumValue, { - width: 'abbreviated', - context: 'formatting' - }); - case 'bbb': - return localize.dayPeriod(dayPeriodEnumValue, { - width: 'abbreviated', - context: 'formatting' - }).toLowerCase(); - case 'bbbbb': - return localize.dayPeriod(dayPeriodEnumValue, { - width: 'narrow', - context: 'formatting' - }); - case 'bbbb': - default: - return localize.dayPeriod(dayPeriodEnumValue, { - width: 'wide', - context: 'formatting' - }); - } - }, - // in the morning, in the afternoon, in the evening, at night - B: function B(date, token, localize) { - var hours = date.getUTCHours(); - var 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 localize.dayPeriod(dayPeriodEnumValue, { - width: 'abbreviated', - context: 'formatting' - }); - case 'BBBBB': - return localize.dayPeriod(dayPeriodEnumValue, { - width: 'narrow', - context: 'formatting' - }); - case 'BBBB': - default: - return localize.dayPeriod(dayPeriodEnumValue, { - width: 'wide', - context: 'formatting' - }); - } - }, - // Hour [1-12] - h: function h(date, token, localize) { - if (token === 'ho') { - var hours = date.getUTCHours() % 12; - if (hours === 0) hours = 12; - return localize.ordinalNumber(hours, { - unit: 'hour' - }); - } - return _index7.default.h(date, token); - }, - // Hour [0-23] - H: function H(date, token, localize) { - if (token === 'Ho') { - return localize.ordinalNumber(date.getUTCHours(), { - unit: 'hour' - }); - } - return _index7.default.H(date, token); - }, - // Hour [0-11] - K: function K(date, token, localize) { - var hours = date.getUTCHours() % 12; - if (token === 'Ko') { - return localize.ordinalNumber(hours, { - unit: 'hour' - }); - } - return (0, _index6.default)(hours, token.length); - }, - // Hour [1-24] - k: function k(date, token, localize) { - var hours = date.getUTCHours(); - if (hours === 0) hours = 24; - if (token === 'ko') { - return localize.ordinalNumber(hours, { - unit: 'hour' - }); - } - return (0, _index6.default)(hours, token.length); - }, - // Minute - m: function m(date, token, localize) { - if (token === 'mo') { - return localize.ordinalNumber(date.getUTCMinutes(), { - unit: 'minute' - }); - } - return _index7.default.m(date, token); - }, - // Second - s: function s(date, token, localize) { - if (token === 'so') { - return localize.ordinalNumber(date.getUTCSeconds(), { - unit: 'second' - }); - } - return _index7.default.s(date, token); - }, - // Fraction of second - S: function S(date, token) { - return _index7.default.S(date, token); - }, - // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) - X: function X(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timezoneOffset = originalDate.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': - // Hours and minutes without `:` delimiter - 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, ':'); - } - }, - // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) - x: function x(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timezoneOffset = originalDate.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': - // Hours and minutes without `:` delimiter - 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, ':'); - } - }, - // Timezone (GMT) - O: function O(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timezoneOffset = originalDate.getTimezoneOffset(); - switch (token) { - // Short - case 'O': - case 'OO': - case 'OOO': - return 'GMT' + formatTimezoneShort(timezoneOffset, ':'); - // Long - case 'OOOO': - default: - return 'GMT' + formatTimezone(timezoneOffset, ':'); - } - }, - // Timezone (specific non-location) - z: function z(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timezoneOffset = originalDate.getTimezoneOffset(); - switch (token) { - // Short - case 'z': - case 'zz': - case 'zzz': - return 'GMT' + formatTimezoneShort(timezoneOffset, ':'); - // Long - case 'zzzz': - default: - return 'GMT' + formatTimezone(timezoneOffset, ':'); - } - }, - // Seconds timestamp - t: function t(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timestamp = Math.floor(originalDate.getTime() / 1000); - return (0, _index6.default)(timestamp, token.length); - }, - // Milliseconds timestamp - T: function T(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timestamp = originalDate.getTime(); - return (0, _index6.default)(timestamp, token.length); - } -}; -function formatTimezoneShort(offset, dirtyDelimiter) { - var sign = offset > 0 ? '-' : '+'; - var absOffset = Math.abs(offset); - var hours = Math.floor(absOffset / 60); - var minutes = absOffset % 60; - if (minutes === 0) { - return sign + String(hours); - } - var delimiter = dirtyDelimiter || ''; - return sign + String(hours) + delimiter + (0, _index6.default)(minutes, 2); -} -function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) { - if (offset % 60 === 0) { - var sign = offset > 0 ? '-' : '+'; - return sign + (0, _index6.default)(Math.abs(offset) / 60, 2); - } - return formatTimezone(offset, dirtyDelimiter); -} -function formatTimezone(offset, dirtyDelimiter) { - var delimiter = dirtyDelimiter || ''; - var sign = offset > 0 ? '-' : '+'; - var absOffset = Math.abs(offset); - var hours = (0, _index6.default)(Math.floor(absOffset / 60), 2); - var minutes = (0, _index6.default)(absOffset % 60, 2); - return sign + hours + delimiter + minutes; -} -var _default = formatters; -exports["default"] = _default; -module.exports = exports.default; - -/***/ }), +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); -/***/ 289: -/***/ ((module, exports, __nccwpck_require__) => { +class Blob { + constructor() { + this[TYPE] = ''; -"use strict"; + const blobParts = arguments[0]; + const options = arguments[1]; + const buffers = []; + let size = 0; -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _index = _interopRequireDefault(__nccwpck_require__(8620)); -/* - * | | Unit | | Unit | - * |-----|--------------------------------|-----|--------------------------------| - * | a | AM, PM | A* | | - * | d | Day of month | D | | - * | h | Hour [1-12] | H | Hour [0-23] | - * | m | Minute | M | Month | - * | s | Second | S | Fraction of second | - * | y | Year (abs) | Y | | - * - * Letters marked by * are not implemented but reserved by Unicode standard. - */ - -var formatters = { - // Year - y: function y(date, token) { - // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens - // | Year | y | yy | yyy | yyyy | yyyyy | - // |----------|-------|----|-------|-------|-------| - // | AD 1 | 1 | 01 | 001 | 0001 | 00001 | - // | AD 12 | 12 | 12 | 012 | 0012 | 00012 | - // | AD 123 | 123 | 23 | 123 | 0123 | 00123 | - // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 | - // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 | - - var signedYear = date.getUTCFullYear(); - // Returns 1 for 1 BC (which is year 0 in JavaScript) - var year = signedYear > 0 ? signedYear : 1 - signedYear; - return (0, _index.default)(token === 'yy' ? year % 100 : year, token.length); - }, - // Month - M: function M(date, token) { - var month = date.getUTCMonth(); - return token === 'M' ? String(month + 1) : (0, _index.default)(month + 1, 2); - }, - // Day of the month - d: function d(date, token) { - return (0, _index.default)(date.getUTCDate(), token.length); - }, - // AM or PM - a: function a(date, token) { - var dayPeriodEnumValue = date.getUTCHours() / 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: function h(date, token) { - return (0, _index.default)(date.getUTCHours() % 12 || 12, token.length); - }, - // Hour [0-23] - H: function H(date, token) { - return (0, _index.default)(date.getUTCHours(), token.length); - }, - // Minute - m: function m(date, token) { - return (0, _index.default)(date.getUTCMinutes(), token.length); - }, - // Second - s: function s(date, token) { - return (0, _index.default)(date.getUTCSeconds(), token.length); - }, - // Fraction of second - S: function S(date, token) { - var numberOfDigits = token.length; - var milliseconds = date.getUTCMilliseconds(); - var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3)); - return (0, _index.default)(fractionalSeconds, token.length); - } -}; -var _default = formatters; -exports["default"] = _default; -module.exports = exports.default; - -/***/ }), - -/***/ 8387: -/***/ ((module, exports) => { - -"use strict"; + if (blobParts) { + const a = blobParts; + const length = Number(a.length); + for (let i = 0; i < length; i++) { + const element = a[i]; + let buffer; + if (element instanceof Buffer) { + buffer = element; + } else if (ArrayBuffer.isView(element)) { + buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); + } else if (element instanceof ArrayBuffer) { + buffer = Buffer.from(element); + } else if (element instanceof Blob) { + buffer = element[BUFFER]; + } else { + buffer = Buffer.from(typeof element === 'string' ? element : String(element)); + } + size += buffer.length; + buffers.push(buffer); + } + } + this[BUFFER] = Buffer.concat(buffers); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var dateLongFormatter = function dateLongFormatter(pattern, formatLong) { - switch (pattern) { - case 'P': - return formatLong.date({ - width: 'short' - }); - case 'PP': - return formatLong.date({ - width: 'medium' - }); - case 'PPP': - return formatLong.date({ - width: 'long' - }); - case 'PPPP': - default: - return formatLong.date({ - width: 'full' - }); - } -}; -var timeLongFormatter = function timeLongFormatter(pattern, formatLong) { - switch (pattern) { - case 'p': - return formatLong.time({ - width: 'short' - }); - case 'pp': - return formatLong.time({ - width: 'medium' - }); - case 'ppp': - return formatLong.time({ - width: 'long' - }); - case 'pppp': - default: - return formatLong.time({ - width: 'full' - }); - } -}; -var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) { - var matchResult = pattern.match(/(P+)(p+)?/) || []; - var datePattern = matchResult[1]; - var timePattern = matchResult[2]; - if (!timePattern) { - return dateLongFormatter(pattern, formatLong); - } - var dateTimeFormat; - switch (datePattern) { - case 'P': - dateTimeFormat = formatLong.dateTime({ - width: 'short' - }); - break; - case 'PP': - dateTimeFormat = formatLong.dateTime({ - width: 'medium' - }); - break; - case 'PPP': - dateTimeFormat = formatLong.dateTime({ - width: 'long' - }); - break; - case 'PPPP': - default: - dateTimeFormat = formatLong.dateTime({ - width: 'full' - }); - break; - } - return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong)); -}; -var longFormatters = { - p: timeLongFormatter, - P: dateTimeLongFormatter -}; -var _default = longFormatters; -exports["default"] = _default; -module.exports = exports.default; + let type = options && options.type !== undefined && String(options.type).toLowerCase(); + if (type && !/[^\u0020-\u007E]/.test(type)) { + this[TYPE] = type; + } + } + get size() { + return this[BUFFER].length; + } + get type() { + return this[TYPE]; + } + text() { + return Promise.resolve(this[BUFFER].toString()); + } + arrayBuffer() { + const buf = this[BUFFER]; + const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + return Promise.resolve(ab); + } + stream() { + const readable = new Readable(); + readable._read = function () {}; + readable.push(this[BUFFER]); + readable.push(null); + return readable; + } + toString() { + return '[object Blob]'; + } + slice() { + const size = this.size; -/***/ }), + const start = arguments[0]; + const end = arguments[1]; + let relativeStart, relativeEnd; + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + const span = Math.max(relativeEnd - relativeStart, 0); -/***/ 7032: -/***/ ((module, exports) => { + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +} -"use strict"; +Object.defineProperties(Blob.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); +Object.defineProperty(Blob.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = getTimezoneOffsetInMilliseconds; /** - * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds. - * They usually appear for dates that denote time before the timezones were introduced - * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891 - * and GMT+01:00:00 after that date) - * - * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above, - * which would lead to incorrect calculations. + * fetch-error.js * - * This function returns the timezone offset in milliseconds that takes seconds in account. + * FetchError interface for operational errors */ -function getTimezoneOffsetInMilliseconds(date) { - var 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.getTime() - utcDate.getTime(); -} -module.exports = exports.default; - -/***/ }), - -/***/ 2966: -/***/ ((module, exports, __nccwpck_require__) => { - -"use strict"; +/** + * Create FetchError instance + * + * @param String message Error message for human + * @param String type Error type for machine + * @param String systemError For Node.js system error + * @return FetchError + */ +function FetchError(message, type, systemError) { + Error.call(this, message); -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = getUTCDayOfYear; -var _index = _interopRequireDefault(__nccwpck_require__(6477)); -var _index2 = _interopRequireDefault(__nccwpck_require__(2063)); -var MILLISECONDS_IN_DAY = 86400000; -function getUTCDayOfYear(dirtyDate) { - (0, _index2.default)(1, arguments); - var date = (0, _index.default)(dirtyDate); - var timestamp = date.getTime(); - date.setUTCMonth(0, 1); - date.setUTCHours(0, 0, 0, 0); - var startOfYearTimestamp = date.getTime(); - var difference = timestamp - startOfYearTimestamp; - return Math.floor(difference / MILLISECONDS_IN_DAY) + 1; -} -module.exports = exports.default; + this.message = message; + this.type = type; -/***/ }), + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } -/***/ 8493: -/***/ ((module, exports, __nccwpck_require__) => { + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} -"use strict"; +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; +let convert; +try { + convert = (__nccwpck_require__(3975).convert); +} catch (e) {} -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = getUTCISOWeek; -var _index = _interopRequireDefault(__nccwpck_require__(6477)); -var _index2 = _interopRequireDefault(__nccwpck_require__(3061)); -var _index3 = _interopRequireDefault(__nccwpck_require__(1478)); -var _index4 = _interopRequireDefault(__nccwpck_require__(2063)); -var MILLISECONDS_IN_WEEK = 604800000; -function getUTCISOWeek(dirtyDate) { - (0, _index4.default)(1, arguments); - var date = (0, _index.default)(dirtyDate); - var diff = (0, _index2.default)(date).getTime() - (0, _index3.default)(date).getTime(); - - // Round the number of days to the nearest integer - // because the number of milliseconds in a week is not constant - // (e.g. it's different in the week of the daylight saving time clock shift) - return Math.round(diff / MILLISECONDS_IN_WEEK) + 1; -} -module.exports = exports.default; +const INTERNALS = Symbol('Body internals'); -/***/ }), +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream.PassThrough; -/***/ 7170: -/***/ ((module, exports, __nccwpck_require__) => { +/** + * Body mixin + * + * Ref: https://fetch.spec.whatwg.org/#body + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +function Body(body) { + var _this = this; -"use strict"; + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = getUTCISOWeekYear; -var _index = _interopRequireDefault(__nccwpck_require__(6477)); -var _index2 = _interopRequireDefault(__nccwpck_require__(2063)); -var _index3 = _interopRequireDefault(__nccwpck_require__(3061)); -function getUTCISOWeekYear(dirtyDate) { - (0, _index2.default)(1, arguments); - var date = (0, _index.default)(dirtyDate); - var year = date.getUTCFullYear(); - var fourthOfJanuaryOfNextYear = new Date(0); - fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4); - fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0); - var startOfNextYear = (0, _index3.default)(fourthOfJanuaryOfNextYear); - var fourthOfJanuaryOfThisYear = new Date(0); - fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4); - fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0); - var startOfThisYear = (0, _index3.default)(fourthOfJanuaryOfThisYear); - if (date.getTime() >= startOfNextYear.getTime()) { - return year + 1; - } else if (date.getTime() >= startOfThisYear.getTime()) { - return year; - } else { - return year - 1; - } -} -module.exports = exports.default; + if (body == null) { + // body is undefined or null + body = null; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + body = Buffer.from(body.toString()); + } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + body = Buffer.from(body); + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); + } else if (body instanceof Stream) ; else { + // none of the above + // coerce to string then buffer + body = Buffer.from(String(body)); + } + this[INTERNALS] = { + body, + disturbed: false, + error: null + }; + this.size = size; + this.timeout = timeout; -/***/ }), + if (body instanceof Stream) { + body.on('error', function (err) { + const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); + _this[INTERNALS].error = error; + }); + } +} -/***/ 8761: -/***/ ((module, exports, __nccwpck_require__) => { +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, -"use strict"; + get bodyUsed() { + return this[INTERNALS].disturbed; + }, + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = getUTCWeek; -var _index = _interopRequireDefault(__nccwpck_require__(6477)); -var _index2 = _interopRequireDefault(__nccwpck_require__(2258)); -var _index3 = _interopRequireDefault(__nccwpck_require__(2629)); -var _index4 = _interopRequireDefault(__nccwpck_require__(2063)); -var MILLISECONDS_IN_WEEK = 604800000; -function getUTCWeek(dirtyDate, options) { - (0, _index4.default)(1, arguments); - var date = (0, _index.default)(dirtyDate); - var diff = (0, _index2.default)(date, options).getTime() - (0, _index3.default)(date, options).getTime(); - - // Round the number of days to the nearest integer - // because the number of milliseconds in a week is not constant - // (e.g. it's different in the week of the daylight saving time clock shift) - return Math.round(diff / MILLISECONDS_IN_WEEK) + 1; -} -module.exports = exports.default; + /** + * Return raw response as Blob + * + * @return Promise + */ + blob() { + let ct = this.headers && this.headers.get('content-type') || ''; + return consumeBody.call(this).then(function (buf) { + return Object.assign( + // Prevent copying + new Blob([], { + type: ct.toLowerCase() + }), { + [BUFFER]: buf + }); + }); + }, -/***/ }), + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; -/***/ 8050: -/***/ ((module, exports, __nccwpck_require__) => { + return consumeBody.call(this).then(function (buffer) { + try { + return JSON.parse(buffer.toString()); + } catch (err) { + return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + } + }); + }, -"use strict"; + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = getUTCWeekYear; -var _index = _interopRequireDefault(__nccwpck_require__(6477)); -var _index2 = _interopRequireDefault(__nccwpck_require__(2063)); -var _index3 = _interopRequireDefault(__nccwpck_require__(2258)); -var _index4 = _interopRequireDefault(__nccwpck_require__(1985)); -var _index5 = __nccwpck_require__(9307); -function getUTCWeekYear(dirtyDate, options) { - var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; - (0, _index2.default)(1, arguments); - var date = (0, _index.default)(dirtyDate); - var year = date.getUTCFullYear(); - var defaultOptions = (0, _index5.getDefaultOptions)(); - var firstWeekContainsDate = (0, _index4.default)((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); - - // Test if weekStartsOn is between 1 and 7 _and_ is not NaN - if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { - throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively'); - } - var firstWeekOfNextYear = new Date(0); - firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate); - firstWeekOfNextYear.setUTCHours(0, 0, 0, 0); - var startOfNextYear = (0, _index3.default)(firstWeekOfNextYear, options); - var firstWeekOfThisYear = new Date(0); - firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate); - firstWeekOfThisYear.setUTCHours(0, 0, 0, 0); - var startOfThisYear = (0, _index3.default)(firstWeekOfThisYear, options); - if (date.getTime() >= startOfNextYear.getTime()) { - return year + 1; - } else if (date.getTime() >= startOfThisYear.getTime()) { - return year; - } else { - return year - 1; - } -} -module.exports = exports.default; + /** + * Decode response as text, while automatically detecting the encoding and + * trying to decode to UTF-8 (non-spec api) + * + * @return Promise + */ + textConverted() { + var _this3 = this; -/***/ }), + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; -/***/ 2509: -/***/ ((__unused_webpack_module, exports) => { +// In browsers, all properties are enumerable. +Object.defineProperties(Body.prototype, { + body: { enumerable: true }, + bodyUsed: { enumerable: true }, + arrayBuffer: { enumerable: true }, + blob: { enumerable: true }, + json: { enumerable: true }, + text: { enumerable: true } +}); -"use strict"; +Body.mixIn = function (proto) { + for (const name of Object.getOwnPropertyNames(Body.prototype)) { + // istanbul ignore else: future proof + if (!(name in proto)) { + const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); + Object.defineProperty(proto, name, desc); + } + } +}; +/** + * Consume and convert an entire Body to a Buffer. + * + * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * + * @return Promise + */ +function consumeBody() { + var _this4 = this; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.isProtectedDayOfYearToken = isProtectedDayOfYearToken; -exports.isProtectedWeekYearToken = isProtectedWeekYearToken; -exports.throwProtectedError = throwProtectedError; -var protectedDayOfYearTokens = ['D', 'DD']; -var protectedWeekYearTokens = ['YY', 'YYYY']; -function isProtectedDayOfYearToken(token) { - return protectedDayOfYearTokens.indexOf(token) !== -1; -} -function isProtectedWeekYearToken(token) { - return protectedWeekYearTokens.indexOf(token) !== -1; -} -function throwProtectedError(token, format, input) { - if (token === 'YYYY') { - throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); - } else if (token === 'YY') { - throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); - } else if (token === 'D') { - throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); - } else if (token === 'DD') { - throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); - } -} + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } -/***/ }), + this[INTERNALS].disturbed = true; -/***/ 2063: -/***/ ((module, exports) => { + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } -"use strict"; + let body = this.body; + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = requiredArgs; -function requiredArgs(required, args) { - if (args.length < required) { - throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present'); - } -} -module.exports = exports.default; + // body is blob + if (isBlob(body)) { + body = body.stream(); + } -/***/ }), + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } -/***/ 3061: -/***/ ((module, exports, __nccwpck_require__) => { + // istanbul ignore if: should never happen + if (!(body instanceof Stream)) { + return Body.Promise.resolve(Buffer.alloc(0)); + } -"use strict"; + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; + return new Body.Promise(function (resolve, reject) { + let resTimeout; -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = startOfUTCISOWeek; -var _index = _interopRequireDefault(__nccwpck_require__(6477)); -var _index2 = _interopRequireDefault(__nccwpck_require__(2063)); -function startOfUTCISOWeek(dirtyDate) { - (0, _index2.default)(1, arguments); - var weekStartsOn = 1; - var date = (0, _index.default)(dirtyDate); - var day = date.getUTCDay(); - var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; - date.setUTCDate(date.getUTCDate() - diff); - date.setUTCHours(0, 0, 0, 0); - return date; -} -module.exports = exports.default; + // allow timeout on slow response body + if (_this4.timeout) { + resTimeout = setTimeout(function () { + abort = true; + reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); + }, _this4.timeout); + } -/***/ }), + // handle stream errors + body.on('error', function (err) { + if (err.name === 'AbortError') { + // if the request was aborted, reject with this Error + abort = true; + reject(err); + } else { + // other errors, such as incorrect content-encoding + reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + } + }); -/***/ 1478: -/***/ ((module, exports, __nccwpck_require__) => { + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } -"use strict"; + if (_this4.size && accumBytes + chunk.length > _this4.size) { + abort = true; + reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + return; + } + accumBytes += chunk.length; + accum.push(chunk); + }); -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = startOfUTCISOWeekYear; -var _index = _interopRequireDefault(__nccwpck_require__(7170)); -var _index2 = _interopRequireDefault(__nccwpck_require__(3061)); -var _index3 = _interopRequireDefault(__nccwpck_require__(2063)); -function startOfUTCISOWeekYear(dirtyDate) { - (0, _index3.default)(1, arguments); - var year = (0, _index.default)(dirtyDate); - var fourthOfJanuary = new Date(0); - fourthOfJanuary.setUTCFullYear(year, 0, 4); - fourthOfJanuary.setUTCHours(0, 0, 0, 0); - var date = (0, _index2.default)(fourthOfJanuary); - return date; -} -module.exports = exports.default; + body.on('end', function () { + if (abort) { + return; + } -/***/ }), + clearTimeout(resTimeout); -/***/ 2258: -/***/ ((module, exports, __nccwpck_require__) => { + try { + resolve(Buffer.concat(accum, accumBytes)); + } catch (err) { + // handle streams that have accumulated too much data (issue #414) + reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + }); +} -"use strict"; +/** + * Detect buffer encoding and convert to target encoding + * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * + * @param Buffer buffer Incoming buffer + * @param String encoding Target encoding + * @return String + */ +function convertBody(buffer, headers) { + if (typeof convert !== 'function') { + throw new Error('The package `encoding` must be installed to use the textConverted() function'); + } + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = startOfUTCWeek; -var _index = _interopRequireDefault(__nccwpck_require__(6477)); -var _index2 = _interopRequireDefault(__nccwpck_require__(2063)); -var _index3 = _interopRequireDefault(__nccwpck_require__(1985)); -var _index4 = __nccwpck_require__(9307); -function startOfUTCWeek(dirtyDate, options) { - var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; - (0, _index2.default)(1, arguments); - var defaultOptions = (0, _index4.getDefaultOptions)(); - var weekStartsOn = (0, _index3.default)((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); - - // Test if weekStartsOn is between 0 and 6 _and_ is not NaN - if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { - throw new RangeError('weekStartsOn must be between 0 and 6 inclusively'); - } - var date = (0, _index.default)(dirtyDate); - var day = date.getUTCDay(); - var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; - date.setUTCDate(date.getUTCDate() - diff); - date.setUTCHours(0, 0, 0, 0); - return date; -} -module.exports = exports.default; + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } -/***/ }), + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); -/***/ 2629: -/***/ ((module, exports, __nccwpck_require__) => { + // html5 + if (!res && str) { + res = / { + // prevent decode issues when sites use incorrect encoding + // ref: https://hsivonen.fi/encoding-menu/ + if (charset === 'gb2312' || charset === 'gbk') { + charset = 'gb18030'; + } + } -"use strict"; + // turn raw buffers into a single utf-8 buffer + return convert(buffer, 'UTF-8', charset).toString(); +} +/** + * Detect a URLSearchParams object + * ref: https://github.com/bitinn/node-fetch/issues/296#issuecomment-307598143 + * + * @param Object obj Object to detect by type or brand + * @return String + */ +function isURLSearchParams(obj) { + // Duck-typing as a necessary condition. + if (typeof obj !== 'object' || typeof obj.append !== 'function' || typeof obj.delete !== 'function' || typeof obj.get !== 'function' || typeof obj.getAll !== 'function' || typeof obj.has !== 'function' || typeof obj.set !== 'function') { + return false; + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = toInteger; -function toInteger(dirtyNumber) { - if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) { - return NaN; - } - var number = Number(dirtyNumber); - if (isNaN(number)) { - return number; - } - return number < 0 ? Math.ceil(number) : Math.floor(number); + // Brand-checking and more duck-typing as optional condition. + return obj.constructor.name === 'URLSearchParams' || Object.prototype.toString.call(obj) === '[object URLSearchParams]' || typeof obj.sort === 'function'; } -module.exports = exports.default; -/***/ }), +/** + * Check if `obj` is a W3C `Blob` object (which `File` inherits from) + * @param {*} obj + * @return {boolean} + */ +function isBlob(obj) { + return typeof obj === 'object' && typeof obj.arrayBuffer === 'function' && typeof obj.type === 'string' && typeof obj.stream === 'function' && typeof obj.constructor === 'function' && typeof obj.constructor.name === 'string' && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]); +} -/***/ 524: -/***/ ((module, exports, __nccwpck_require__) => { +/** + * Clone body given Res/Req instance + * + * @param Mixed instance Response or Request instance + * @return Mixed + */ +function clone(instance) { + let p1, p2; + let body = instance.body; -"use strict"; + // don't allow cloning a used body + if (instance.bodyUsed) { + throw new Error('cannot clone body after it is used'); + } + + // check that body is a stream and not form-data object + // note: we can't clone the form-data object without having it as a dependency + if (body instanceof Stream && typeof body.getBoundary !== 'function') { + // tee instance body + p1 = new PassThrough(); + p2 = new PassThrough(); + body.pipe(p1); + body.pipe(p2); + // set instance body to teed body and return the other teed body + instance[INTERNALS].body = p1; + body = p2; + } + return body; +} -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = addMilliseconds; -var _index = _interopRequireDefault(__nccwpck_require__(1985)); -var _index2 = _interopRequireDefault(__nccwpck_require__(6477)); -var _index3 = _interopRequireDefault(__nccwpck_require__(2063)); /** - * @name addMilliseconds - * @category Millisecond Helpers - * @summary Add the specified number of milliseconds to the given date. - * - * @description - * Add the specified number of milliseconds to the given date. + * Performs the operation "extract a `Content-Type` value from |object|" as + * specified in the specification: + * https://fetch.spec.whatwg.org/#concept-bodyinit-extract * - * @param {Date|Number} date - the date to be changed - * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`. - * @returns {Date} the new date with the milliseconds added - * @throws {TypeError} 2 arguments required + * This function assumes that instance.body is present. * - * @example - * // Add 750 milliseconds to 10 July 2014 12:45:30.000: - * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750) - * //=> Thu Jul 10 2014 12:45:30.750 + * @param Mixed instance Any options.body input */ -function addMilliseconds(dirtyDate, dirtyAmount) { - (0, _index3.default)(2, arguments); - var timestamp = (0, _index2.default)(dirtyDate).getTime(); - var amount = (0, _index.default)(dirtyAmount); - return new Date(timestamp + amount); +function extractContentType(body) { + if (body === null) { + // body is null + return null; + } else if (typeof body === 'string') { + // body is string + return 'text/plain;charset=UTF-8'; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + return 'application/x-www-form-urlencoded;charset=UTF-8'; + } else if (isBlob(body)) { + // body is blob + return body.type || null; + } else if (Buffer.isBuffer(body)) { + // body is buffer + return null; + } else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + return null; + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + return null; + } else if (typeof body.getBoundary === 'function') { + // detect form data input from form-data module + return `multipart/form-data;boundary=${body.getBoundary()}`; + } else if (body instanceof Stream) { + // body is stream + // can't really do much about this + return null; + } else { + // Body constructor defaults other things to string + return 'text/plain;charset=UTF-8'; + } } -module.exports = exports.default; - -/***/ }), - -/***/ 2168: -/***/ ((module, exports, __nccwpck_require__) => { - -"use strict"; +/** + * The Fetch Standard treats this as if "total bytes" is a property on the body. + * For us, we have to explicitly get it with a function. + * + * ref: https://fetch.spec.whatwg.org/#concept-body-total-bytes + * + * @param Body instance Instance of Body + * @return Number? Number of bytes, or null if not possible + */ +function getTotalBytes(instance) { + const body = instance.body; -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = format; -var _index = _interopRequireDefault(__nccwpck_require__(9920)); -var _index2 = _interopRequireDefault(__nccwpck_require__(7923)); -var _index3 = _interopRequireDefault(__nccwpck_require__(6477)); -var _index4 = _interopRequireDefault(__nccwpck_require__(9257)); -var _index5 = _interopRequireDefault(__nccwpck_require__(8387)); -var _index6 = _interopRequireDefault(__nccwpck_require__(7032)); -var _index7 = __nccwpck_require__(2509); -var _index8 = _interopRequireDefault(__nccwpck_require__(1985)); -var _index9 = _interopRequireDefault(__nccwpck_require__(2063)); -var _index10 = __nccwpck_require__(9307); -var _index11 = _interopRequireDefault(__nccwpck_require__(618)); -// This RegExp consists of three parts separated by `|`: -// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token -// (one of the certain letters followed by `o`) -// - (\w)\1* matches any sequences of the same letter -// - '' matches two quote characters in a row -// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('), -// except a single quote symbol, which ends the sequence. -// Two quote characters do not end the sequence. -// If there is no matching single quote -// then the sequence will continue until the end of the string. -// - . matches any single character unmatched by previous parts of the RegExps -var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; -// This RegExp catches symbols escaped by quotes, and also -// sequences of symbols P, p, and the combinations like `PPPPPPPppppp` -var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; -var escapedStringRegExp = /^'([^]*?)'?$/; -var doubleQuoteRegExp = /''/g; -var unescapedLatinCharacterRegExp = /[a-zA-Z]/; + if (body === null) { + // body is null + return 0; + } else if (isBlob(body)) { + return body.size; + } else if (Buffer.isBuffer(body)) { + // body is buffer + return body.length; + } else if (body && typeof body.getLengthSync === 'function') { + // detect form data input from form-data module + if (body._lengthRetrievers && body._lengthRetrievers.length == 0 || // 1.x + body.hasKnownLength && body.hasKnownLength()) { + // 2.x + return body.getLengthSync(); + } + return null; + } else { + // body is stream + return null; + } +} /** - * @name format - * @category Common Helpers - * @summary Format the date. - * - * @description - * Return the formatted date string in the given format. The result may vary by locale. - * - * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries. - * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md - * - * The characters wrapped between two single quotes characters (') are escaped. - * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. - * (see the last example) + * Write a Body to a Node.js WritableStream (e.g. http.Request) object. * - * Format of the string is based on Unicode Technical Standard #35: - * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table - * with a few additions (see note 7 below the table). - * - * Accepted patterns: - * | Unit | Pattern | Result examples | Notes | - * |---------------------------------|---------|-----------------------------------|-------| - * | Era | G..GGG | AD, BC | | - * | | GGGG | Anno Domini, Before Christ | 2 | - * | | GGGGG | A, B | | - * | Calendar year | y | 44, 1, 1900, 2017 | 5 | - * | | yo | 44th, 1st, 0th, 17th | 5,7 | - * | | yy | 44, 01, 00, 17 | 5 | - * | | yyy | 044, 001, 1900, 2017 | 5 | - * | | yyyy | 0044, 0001, 1900, 2017 | 5 | - * | | yyyyy | ... | 3,5 | - * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 | - * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 | - * | | YY | 44, 01, 00, 17 | 5,8 | - * | | YYY | 044, 001, 1900, 2017 | 5 | - * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 | - * | | YYYYY | ... | 3,5 | - * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 | - * | | RR | -43, 00, 01, 1900, 2017 | 5,7 | - * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 | - * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 | - * | | RRRRR | ... | 3,5,7 | - * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 | - * | | uu | -43, 01, 1900, 2017 | 5 | - * | | uuu | -043, 001, 1900, 2017 | 5 | - * | | uuuu | -0043, 0001, 1900, 2017 | 5 | - * | | uuuuu | ... | 3,5 | - * | Quarter (formatting) | Q | 1, 2, 3, 4 | | - * | | Qo | 1st, 2nd, 3rd, 4th | 7 | - * | | QQ | 01, 02, 03, 04 | | - * | | QQQ | Q1, Q2, Q3, Q4 | | - * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 | - * | | QQQQQ | 1, 2, 3, 4 | 4 | - * | Quarter (stand-alone) | q | 1, 2, 3, 4 | | - * | | qo | 1st, 2nd, 3rd, 4th | 7 | - * | | qq | 01, 02, 03, 04 | | - * | | qqq | Q1, Q2, Q3, Q4 | | - * | | qqqq | 1st quarter, 2nd quarter, ... | 2 | - * | | qqqqq | 1, 2, 3, 4 | 4 | - * | Month (formatting) | M | 1, 2, ..., 12 | | - * | | Mo | 1st, 2nd, ..., 12th | 7 | - * | | MM | 01, 02, ..., 12 | | - * | | MMM | Jan, Feb, ..., Dec | | - * | | MMMM | January, February, ..., December | 2 | - * | | MMMMM | J, F, ..., D | | - * | Month (stand-alone) | L | 1, 2, ..., 12 | | - * | | Lo | 1st, 2nd, ..., 12th | 7 | - * | | LL | 01, 02, ..., 12 | | - * | | LLL | Jan, Feb, ..., Dec | | - * | | LLLL | January, February, ..., December | 2 | - * | | LLLLL | J, F, ..., D | | - * | Local week of year | w | 1, 2, ..., 53 | | - * | | wo | 1st, 2nd, ..., 53th | 7 | - * | | ww | 01, 02, ..., 53 | | - * | ISO week of year | I | 1, 2, ..., 53 | 7 | - * | | Io | 1st, 2nd, ..., 53th | 7 | - * | | II | 01, 02, ..., 53 | 7 | - * | Day of month | d | 1, 2, ..., 31 | | - * | | do | 1st, 2nd, ..., 31st | 7 | - * | | dd | 01, 02, ..., 31 | | - * | Day of year | D | 1, 2, ..., 365, 366 | 9 | - * | | Do | 1st, 2nd, ..., 365th, 366th | 7 | - * | | DD | 01, 02, ..., 365, 366 | 9 | - * | | DDD | 001, 002, ..., 365, 366 | | - * | | DDDD | ... | 3 | - * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | | - * | | EEEE | Monday, Tuesday, ..., Sunday | 2 | - * | | EEEEE | M, T, W, T, F, S, S | | - * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | | - * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 | - * | | io | 1st, 2nd, ..., 7th | 7 | - * | | ii | 01, 02, ..., 07 | 7 | - * | | iii | Mon, Tue, Wed, ..., Sun | 7 | - * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 | - * | | iiiii | M, T, W, T, F, S, S | 7 | - * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 | - * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | | - * | | eo | 2nd, 3rd, ..., 1st | 7 | - * | | ee | 02, 03, ..., 01 | | - * | | eee | Mon, Tue, Wed, ..., Sun | | - * | | eeee | Monday, Tuesday, ..., Sunday | 2 | - * | | eeeee | M, T, W, T, F, S, S | | - * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | | - * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | | - * | | co | 2nd, 3rd, ..., 1st | 7 | - * | | cc | 02, 03, ..., 01 | | - * | | ccc | Mon, Tue, Wed, ..., Sun | | - * | | cccc | Monday, Tuesday, ..., Sunday | 2 | - * | | ccccc | M, T, W, T, F, S, S | | - * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | | - * | AM, PM | a..aa | AM, PM | | - * | | aaa | am, pm | | - * | | aaaa | a.m., p.m. | 2 | - * | | aaaaa | a, p | | - * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | | - * | | bbb | am, pm, noon, midnight | | - * | | bbbb | a.m., p.m., noon, midnight | 2 | - * | | bbbbb | a, p, n, mi | | - * | Flexible day period | B..BBB | at night, in the morning, ... | | - * | | BBBB | at night, in the morning, ... | 2 | - * | | BBBBB | at night, in the morning, ... | | - * | Hour [1-12] | h | 1, 2, ..., 11, 12 | | - * | | ho | 1st, 2nd, ..., 11th, 12th | 7 | - * | | hh | 01, 02, ..., 11, 12 | | - * | Hour [0-23] | H | 0, 1, 2, ..., 23 | | - * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 | - * | | HH | 00, 01, 02, ..., 23 | | - * | Hour [0-11] | K | 1, 2, ..., 11, 0 | | - * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 | - * | | KK | 01, 02, ..., 11, 00 | | - * | Hour [1-24] | k | 24, 1, 2, ..., 23 | | - * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 | - * | | kk | 24, 01, 02, ..., 23 | | - * | Minute | m | 0, 1, ..., 59 | | - * | | mo | 0th, 1st, ..., 59th | 7 | - * | | mm | 00, 01, ..., 59 | | - * | Second | s | 0, 1, ..., 59 | | - * | | so | 0th, 1st, ..., 59th | 7 | - * | | ss | 00, 01, ..., 59 | | - * | Fraction of second | S | 0, 1, ..., 9 | | - * | | SS | 00, 01, ..., 99 | | - * | | SSS | 000, 001, ..., 999 | | - * | | SSSS | ... | 3 | - * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | | - * | | XX | -0800, +0530, Z | | - * | | XXX | -08:00, +05:30, Z | | - * | | XXXX | -0800, +0530, Z, +123456 | 2 | - * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | | - * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | | - * | | xx | -0800, +0530, +0000 | | - * | | xxx | -08:00, +05:30, +00:00 | 2 | - * | | xxxx | -0800, +0530, +0000, +123456 | | - * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | | - * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | | - * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 | - * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 | - * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 | - * | Seconds timestamp | t | 512969520 | 7 | - * | | tt | ... | 3,7 | - * | Milliseconds timestamp | T | 512969520900 | 7 | - * | | TT | ... | 3,7 | - * | Long localized date | P | 04/29/1453 | 7 | - * | | PP | Apr 29, 1453 | 7 | - * | | PPP | April 29th, 1453 | 7 | - * | | PPPP | Friday, April 29th, 1453 | 2,7 | - * | Long localized time | p | 12:00 AM | 7 | - * | | pp | 12:00:00 AM | 7 | - * | | ppp | 12:00:00 AM GMT+2 | 7 | - * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 | - * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 | - * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 | - * | | PPPppp | April 29th, 1453 at ... | 7 | - * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 | - * Notes: - * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale - * are the same as "stand-alone" units, but are different in some languages. - * "Formatting" units are declined according to the rules of the language - * in the context of a date. "Stand-alone" units are always nominative singular: - * - * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'` - * - * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'` - * - * 2. Any sequence of the identical letters is a pattern, unless it is escaped by - * the single quote characters (see below). - * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`) - * the output will be the same as default pattern for this unit, usually - * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units - * are marked with "2" in the last column of the table. - * - * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'` - * - * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'` - * - * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'` - * - * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'` - * - * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'` - * - * 3. Some patterns could be unlimited length (such as `yyyyyyyy`). - * The output will be padded with zeros to match the length of the pattern. - * - * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'` - * - * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales. - * These tokens represent the shortest form of the quarter. - * - * 5. The main difference between `y` and `u` patterns 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: - * - * | Year | `yy` | `uu` | - * |------|------|------| - * | 1 | 01 | 01 | - * | 14 | 14 | 14 | - * | 376 | 76 | 376 | - * | 1453 | 53 | 1453 | - * - * The same difference is true for local and ISO week-numbering years (`Y` and `R`), - * except local week-numbering years are dependent on `options.weekStartsOn` - * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear} - * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}). - * - * 6. Specific non-location timezones are currently unavailable in `date-fns`, - * so right now these tokens fall back to GMT timezones. - * - * 7. These patterns are not in the Unicode Technical Standard #35: - * - `i`: ISO day of week - * - `I`: ISO week of year - * - `R`: ISO week-numbering year - * - `t`: seconds timestamp - * - `T`: milliseconds timestamp - * - `o`: ordinal number modifier - * - `P`: long localized date - * - `p`: long localized time - * - * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years. - * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md - * - * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month. - * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md - * - * @param {Date|Number} date - the original date - * @param {String} format - the string of tokens - * @param {Object} [options] - an object with options. - * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale} - * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) - * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is - * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`; - * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md - * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`; - * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md - * @returns {String} the formatted date string - * @throws {TypeError} 2 arguments required - * @throws {RangeError} `date` must not be Invalid Date - * @throws {RangeError} `options.locale` must contain `localize` property - * @throws {RangeError} `options.locale` must contain `formatLong` property - * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 - * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7 - * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md - * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md - * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md - * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md - * @throws {RangeError} format string contains an unescaped latin alphabet character - * - * @example - * // Represent 11 February 2014 in middle-endian format: - * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy') - * //=> '02/11/2014' - * - * @example - * // Represent 2 July 2014 in Esperanto: - * import { eoLocale } from 'date-fns/locale/eo' - * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", { - * locale: eoLocale - * }) - * //=> '2-a de julio 2014' - * - * @example - * // Escape string by single quote characters: - * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'") - * //=> "3 o'clock" + * @param Body instance Instance of Body + * @return Void */ +function writeToStream(dest, instance) { + const body = instance.body; -function format(dirtyDate, dirtyFormatStr, options) { - var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4; - (0, _index9.default)(2, arguments); - var formatStr = String(dirtyFormatStr); - var defaultOptions = (0, _index10.getDefaultOptions)(); - var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : _index11.default; - var firstWeekContainsDate = (0, _index8.default)((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1); - - // Test if weekStartsOn is between 1 and 7 _and_ is not NaN - if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { - throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively'); - } - var weekStartsOn = (0, _index8.default)((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0); - // Test if weekStartsOn is between 0 and 6 _and_ is not NaN - if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { - throw new RangeError('weekStartsOn must be between 0 and 6 inclusively'); - } - if (!locale.localize) { - throw new RangeError('locale must contain localize property'); - } - if (!locale.formatLong) { - throw new RangeError('locale must contain formatLong property'); - } - var originalDate = (0, _index3.default)(dirtyDate); - if (!(0, _index.default)(originalDate)) { - throw new RangeError('Invalid time value'); - } - - // Convert the date in system timezone to the same date in UTC+00:00 timezone. - // This ensures that when UTC functions will be implemented, locales will be compatible with them. - // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376 - var timezoneOffset = (0, _index6.default)(originalDate); - var utcDate = (0, _index2.default)(originalDate, timezoneOffset); - var formatterOptions = { - firstWeekContainsDate: firstWeekContainsDate, - weekStartsOn: weekStartsOn, - locale: locale, - _originalDate: originalDate - }; - var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) { - var firstCharacter = substring[0]; - if (firstCharacter === 'p' || firstCharacter === 'P') { - var longFormatter = _index5.default[firstCharacter]; - return longFormatter(substring, locale.formatLong); - } - return substring; - }).join('').match(formattingTokensRegExp).map(function (substring) { - // Replace two single quote characters with one single quote character - if (substring === "''") { - return "'"; - } - var firstCharacter = substring[0]; - if (firstCharacter === "'") { - return cleanEscapedString(substring); - } - var formatter = _index4.default[firstCharacter]; - if (formatter) { - if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && (0, _index7.isProtectedWeekYearToken)(substring)) { - (0, _index7.throwProtectedError)(substring, dirtyFormatStr, String(dirtyDate)); - } - if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && (0, _index7.isProtectedDayOfYearToken)(substring)) { - (0, _index7.throwProtectedError)(substring, dirtyFormatStr, String(dirtyDate)); - } - return formatter(utcDate, substring, locale.localize, formatterOptions); - } - if (firstCharacter.match(unescapedLatinCharacterRegExp)) { - throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`'); - } - return substring; - }).join(''); - return result; -} -function cleanEscapedString(input) { - var matched = input.match(escapedStringRegExp); - if (!matched) { - return input; - } - return matched[1].replace(doubleQuoteRegExp, "'"); + if (body === null) { + // body is null + dest.end(); + } else if (isBlob(body)) { + body.stream().pipe(dest); + } else if (Buffer.isBuffer(body)) { + // body is buffer + dest.write(body); + dest.end(); + } else { + // body is stream + body.pipe(dest); + } } -module.exports = exports.default; - -/***/ }), - -/***/ 6801: -/***/ ((module, exports, __nccwpck_require__) => { - -"use strict"; +// expose Promise +Body.Promise = global.Promise; -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = isDate; -var _typeof2 = _interopRequireDefault(__nccwpck_require__(5605)); -var _index = _interopRequireDefault(__nccwpck_require__(2063)); /** - * @name isDate - * @category Common Helpers - * @summary Is the given value a date? - * - * @description - * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes. - * - * @param {*} value - the value to check - * @returns {boolean} true if the given value is a date - * @throws {TypeError} 1 arguments required - * - * @example - * // For a valid date: - * const result = isDate(new Date()) - * //=> true - * - * @example - * // For an invalid date: - * const result = isDate(new Date(NaN)) - * //=> true - * - * @example - * // For some value: - * const result = isDate('2014-02-31') - * //=> false + * headers.js * - * @example - * // For an object: - * const result = isDate({}) - * //=> false + * Headers class offers convenient helpers */ -function isDate(value) { - (0, _index.default)(1, arguments); - return value instanceof Date || (0, _typeof2.default)(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]'; -} -module.exports = exports.default; - -/***/ }), -/***/ 9920: -/***/ ((module, exports, __nccwpck_require__) => { +const invalidTokenRegex = /[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/; +const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/; -"use strict"; +function validateName(name) { + name = `${name}`; + if (invalidTokenRegex.test(name) || name === '') { + throw new TypeError(`${name} is not a legal HTTP header name`); + } +} +function validateValue(value) { + value = `${value}`; + if (invalidHeaderCharRegex.test(value)) { + throw new TypeError(`${value} is not a legal HTTP header value`); + } +} -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = isValid; -var _index = _interopRequireDefault(__nccwpck_require__(6801)); -var _index2 = _interopRequireDefault(__nccwpck_require__(6477)); -var _index3 = _interopRequireDefault(__nccwpck_require__(2063)); /** - * @name isValid - * @category Common Helpers - * @summary Is the given date valid? - * - * @description - * Returns false if argument is Invalid Date and true otherwise. - * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * Invalid Date is a Date, whose time value is NaN. - * - * Time value of Date: http://es5.github.io/#x15.9.1.1 - * - * @param {*} date - the date to check - * @returns {Boolean} the date is valid - * @throws {TypeError} 1 argument required - * - * @example - * // For the valid date: - * const result = isValid(new Date(2014, 1, 31)) - * //=> true + * Find the key in the map object given a header name. * - * @example - * // For the value, convertable into a date: - * const result = isValid(1393804800000) - * //=> true + * Returns undefined if not found. * - * @example - * // For the invalid date: - * const result = isValid(new Date('')) - * //=> false + * @param String name Header name + * @return String|Undefined */ -function isValid(dirtyDate) { - (0, _index3.default)(1, arguments); - if (!(0, _index.default)(dirtyDate) && typeof dirtyDate !== 'number') { - return false; - } - var date = (0, _index2.default)(dirtyDate); - return !isNaN(Number(date)); +function find(map, name) { + name = name.toLowerCase(); + for (const key in map) { + if (key.toLowerCase() === name) { + return key; + } + } + return undefined; } -module.exports = exports.default; -/***/ }), +const MAP = Symbol('map'); +class Headers { + /** + * Headers class + * + * @param Object headers Response headers + * @return Void + */ + constructor() { + let init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; -/***/ 1244: -/***/ ((module, exports) => { + this[MAP] = Object.create(null); -"use strict"; + if (init instanceof Headers) { + const rawHeaders = init.raw(); + const headerNames = Object.keys(rawHeaders); + for (const headerName of headerNames) { + for (const value of rawHeaders[headerName]) { + this.append(headerName, value); + } + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = buildFormatLongFn; -function buildFormatLongFn(args) { - return function () { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - // TODO: Remove String() - var width = options.width ? String(options.width) : args.defaultWidth; - var format = args.formats[width] || args.formats[args.defaultWidth]; - return format; - }; -} -module.exports = exports.default; + return; + } -/***/ }), + // We don't worry about converting prop to ByteString here as append() + // will handle it. + if (init == null) ; else if (typeof init === 'object') { + const method = init[Symbol.iterator]; + if (method != null) { + if (typeof method !== 'function') { + throw new TypeError('Header pairs must be iterable'); + } -/***/ 3647: -/***/ ((module, exports) => { + // sequence> + // Note: per spec we have to first exhaust the lists then process them + const pairs = []; + for (const pair of init) { + if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { + throw new TypeError('Each header pair must be iterable'); + } + pairs.push(Array.from(pair)); + } -"use strict"; + for (const pair of pairs) { + if (pair.length !== 2) { + throw new TypeError('Each header pair must be a name/value tuple'); + } + this.append(pair[0], pair[1]); + } + } else { + // record + for (const key of Object.keys(init)) { + const value = init[key]; + this.append(key, value); + } + } + } else { + throw new TypeError('Provided initializer must be an object'); + } + } + /** + * Return combined header value given name + * + * @param String name Header name + * @return Mixed + */ + get(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key === undefined) { + return null; + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = buildLocalizeFn; -function buildLocalizeFn(args) { - return function (dirtyIndex, options) { - var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone'; - var valuesArray; - if (context === 'formatting' && args.formattingValues) { - var defaultWidth = args.defaultFormattingWidth || args.defaultWidth; - var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth; - valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; - } else { - var _defaultWidth = args.defaultWidth; - var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth; - valuesArray = args.values[_width] || args.values[_defaultWidth]; - } - var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; - // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it! - return valuesArray[index]; - }; -} -module.exports = exports.default; + return this[MAP][key].join(', '); + } -/***/ }), + /** + * Iterate over all headers + * + * @param Function callback Executed for each item with parameters (value, name, thisArg) + * @param Boolean thisArg `this` context for callback function + * @return Void + */ + forEach(callback) { + let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; -/***/ 4029: -/***/ ((module, exports) => { + let pairs = getHeaders(this); + let i = 0; + while (i < pairs.length) { + var _pairs$i = pairs[i]; + const name = _pairs$i[0], + value = _pairs$i[1]; -"use strict"; + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } + } + /** + * Overwrite header values given name + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + set(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + this[MAP][key !== undefined ? key : name] = [value]; + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = buildMatchFn; -function buildMatchFn(args) { - return function (string) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var width = options.width; - var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; - var matchResult = string.match(matchPattern); - if (!matchResult) { - return null; - } - var matchedString = matchResult[0]; - var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; - var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) { - return pattern.test(matchedString); - }) : findKey(parsePatterns, function (pattern) { - return pattern.test(matchedString); - }); - var value; - value = args.valueCallback ? args.valueCallback(key) : key; - value = options.valueCallback ? options.valueCallback(value) : value; - var rest = string.slice(matchedString.length); - return { - value: value, - rest: rest - }; - }; -} -function findKey(object, predicate) { - for (var key in object) { - if (object.hasOwnProperty(key) && predicate(object[key])) { - return key; - } - } - return undefined; -} -function findIndex(array, predicate) { - for (var key = 0; key < array.length; key++) { - if (predicate(array[key])) { - return key; - } - } - return undefined; -} -module.exports = exports.default; - -/***/ }), - -/***/ 3364: -/***/ ((module, exports) => { + /** + * Append a value onto existing header + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + append(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + if (key !== undefined) { + this[MAP][key].push(value); + } else { + this[MAP][name] = [value]; + } + } -"use strict"; + /** + * Check for header name existence + * + * @param String name Header name + * @return Boolean + */ + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } + /** + * Delete all header values given name + * + * @param String name Header name + * @return Void + */ + delete(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key !== undefined) { + delete this[MAP][key]; + } + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = buildMatchPatternFn; -function buildMatchPatternFn(args) { - return function (string) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var matchResult = string.match(args.matchPattern); - if (!matchResult) return null; - var matchedString = matchResult[0]; - var parseResult = string.match(args.parsePattern); - if (!parseResult) return null; - var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; - value = options.valueCallback ? options.valueCallback(value) : value; - var rest = string.slice(matchedString.length); - return { - value: value, - rest: rest - }; - }; -} -module.exports = exports.default; + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } -/***/ }), + /** + * Get an iterator on keys. + * + * @return Iterator + */ + keys() { + return createHeadersIterator(this, 'key'); + } -/***/ 4846: -/***/ ((module, exports) => { + /** + * Get an iterator on values. + * + * @return Iterator + */ + values() { + return createHeadersIterator(this, 'value'); + } -"use strict"; + /** + * Get an iterator on entries. + * + * This is the default iterator of the Headers object. + * + * @return Iterator + */ + [Symbol.iterator]() { + return createHeadersIterator(this, 'key+value'); + } +} +Headers.prototype.entries = Headers.prototype[Symbol.iterator]; +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -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 = function formatDistance(token, count, options) { - var result; - var 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 !== null && options !== void 0 && options.addSuffix) { - if (options.comparison && options.comparison > 0) { - return 'in ' + result; - } else { - return result + ' ago'; - } - } - return result; -}; -var _default = formatDistance; -exports["default"] = _default; -module.exports = exports.default; +Object.defineProperties(Headers.prototype, { + get: { enumerable: true }, + forEach: { enumerable: true }, + set: { enumerable: true }, + append: { enumerable: true }, + has: { enumerable: true }, + delete: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true } +}); -/***/ }), +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; -/***/ 368: -/***/ ((module, exports, __nccwpck_require__) => { + const keys = Object.keys(headers[MAP]).sort(); + return keys.map(kind === 'key' ? function (k) { + return k.toLowerCase(); + } : kind === 'value' ? function (k) { + return headers[MAP][k].join(', '); + } : function (k) { + return [k.toLowerCase(), headers[MAP][k].join(', ')]; + }); +} -"use strict"; +const INTERNAL = Symbol('internal'); +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; +} -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _index = _interopRequireDefault(__nccwpck_require__(1244)); -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: (0, _index.default)({ - formats: dateFormats, - defaultWidth: 'full' - }), - time: (0, _index.default)({ - formats: timeFormats, - defaultWidth: 'full' - }), - dateTime: (0, _index.default)({ - formats: dateTimeFormats, - defaultWidth: 'full' - }) -}; -var _default = formatLong; -exports["default"] = _default; -module.exports = exports.default; +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } -/***/ }), + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; -/***/ 2430: -/***/ ((module, exports) => { + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } -"use strict"; + this[INTERNAL].index = index + 1; + return { + value: values[index], + done: false + }; + } +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -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 = function formatRelative(token, _date, _baseDate, _options) { - return formatRelativeLocale[token]; -}; -var _default = formatRelative; -exports["default"] = _default; -module.exports = exports.default; - -/***/ }), - -/***/ 5474: -/***/ ((module, exports, __nccwpck_require__) => { - -"use strict"; - +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true +}); -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _index = _interopRequireDefault(__nccwpck_require__(3647)); -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'] -}; +/** + * Export the Headers object in a form that Node.js can consume. + * + * @param Headers headers + * @return Object + */ +function exportNodeCompatibleHeaders(headers) { + const obj = Object.assign({ __proto__: null }, headers[MAP]); -// Note: in English, the names of days of the week and months are capitalized. -// If you are making a new locale based on this one, check if the same is true for the language you're working on. -// Generally, formatted dates should look like they are in the middle of a sentence, -// e.g. in Spanish language the weekdays and months should be in the lowercase. -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 = function ordinalNumber(dirtyNumber, _options) { - var number = Number(dirtyNumber); + // http.request() only supports string as Host header. This hack makes + // specifying custom Host header possible. + const hostHeaderKey = find(headers[MAP], 'Host'); + if (hostHeaderKey !== undefined) { + obj[hostHeaderKey] = obj[hostHeaderKey][0]; + } - // If ordinal numbers depend on context, for example, - // if they are different for different grammatical genders, - // use `options.unit`. - // - // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear', - // 'day', 'hour', 'minute', 'second'. + return obj; +} - var 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'; -}; -var localize = { - ordinalNumber: ordinalNumber, - era: (0, _index.default)({ - values: eraValues, - defaultWidth: 'wide' - }), - quarter: (0, _index.default)({ - values: quarterValues, - defaultWidth: 'wide', - argumentCallback: function argumentCallback(quarter) { - return quarter - 1; - } - }), - month: (0, _index.default)({ - values: monthValues, - defaultWidth: 'wide' - }), - day: (0, _index.default)({ - values: dayValues, - defaultWidth: 'wide' - }), - dayPeriod: (0, _index.default)({ - values: dayPeriodValues, - defaultWidth: 'wide', - formattingValues: formattingDayPeriodValues, - defaultFormattingWidth: 'wide' - }) -}; -var _default = localize; -exports["default"] = _default; -module.exports = exports.default; +/** + * Create a Headers object from an object of headers, ignoring those that do + * not conform to HTTP grammar productions. + * + * @param Object obj Object of headers + * @return Headers + */ +function createHeadersLenient(obj) { + const headers = new Headers(); + for (const name of Object.keys(obj)) { + if (invalidTokenRegex.test(name)) { + continue; + } + if (Array.isArray(obj[name])) { + for (const val of obj[name]) { + if (invalidHeaderCharRegex.test(val)) { + continue; + } + if (headers[MAP][name] === undefined) { + headers[MAP][name] = [val]; + } else { + headers[MAP][name].push(val); + } + } + } else if (!invalidHeaderCharRegex.test(obj[name])) { + headers[MAP][name] = [obj[name]]; + } + } + return headers; +} -/***/ }), +const INTERNALS$1 = Symbol('Response internals'); -/***/ 1338: -/***/ ((module, exports, __nccwpck_require__) => { +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http.STATUS_CODES; -"use strict"; +/** + * Response class + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +class Response { + constructor() { + let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + Body.call(this, body, opts); -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _index = _interopRequireDefault(__nccwpck_require__(4029)); -var _index2 = _interopRequireDefault(__nccwpck_require__(3364)); -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: (0, _index2.default)({ - matchPattern: matchOrdinalNumberPattern, - parsePattern: parseOrdinalNumberPattern, - valueCallback: function valueCallback(value) { - return parseInt(value, 10); - } - }), - era: (0, _index.default)({ - matchPatterns: matchEraPatterns, - defaultMatchWidth: 'wide', - parsePatterns: parseEraPatterns, - defaultParseWidth: 'any' - }), - quarter: (0, _index.default)({ - matchPatterns: matchQuarterPatterns, - defaultMatchWidth: 'wide', - parsePatterns: parseQuarterPatterns, - defaultParseWidth: 'any', - valueCallback: function valueCallback(index) { - return index + 1; - } - }), - month: (0, _index.default)({ - matchPatterns: matchMonthPatterns, - defaultMatchWidth: 'wide', - parsePatterns: parseMonthPatterns, - defaultParseWidth: 'any' - }), - day: (0, _index.default)({ - matchPatterns: matchDayPatterns, - defaultMatchWidth: 'wide', - parsePatterns: parseDayPatterns, - defaultParseWidth: 'any' - }), - dayPeriod: (0, _index.default)({ - matchPatterns: matchDayPeriodPatterns, - defaultMatchWidth: 'any', - parsePatterns: parseDayPeriodPatterns, - defaultParseWidth: 'any' - }) -}; -var _default = match; -exports["default"] = _default; -module.exports = exports.default; + const status = opts.status || 200; + const headers = new Headers(opts.headers); -/***/ }), + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } -/***/ 1773: -/***/ ((module, exports, __nccwpck_require__) => { + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; + } -"use strict"; + get url() { + return this[INTERNALS$1].url || ''; + } + get status() { + return this[INTERNALS$1].status; + } -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _index = _interopRequireDefault(__nccwpck_require__(4846)); -var _index2 = _interopRequireDefault(__nccwpck_require__(368)); -var _index3 = _interopRequireDefault(__nccwpck_require__(2430)); -var _index4 = _interopRequireDefault(__nccwpck_require__(5474)); -var _index5 = _interopRequireDefault(__nccwpck_require__(1338)); -/** - * @type {Locale} - * @category Locales - * @summary English locale (United States). - * @language English - * @iso-639-2 eng - * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp} - * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss} - */ -var locale = { - code: 'en-US', - formatDistance: _index.default, - formatLong: _index2.default, - formatRelative: _index3.default, - localize: _index4.default, - match: _index5.default, - options: { - weekStartsOn: 0 /* Sunday */, - firstWeekContainsDate: 1 - } -}; -var _default = locale; -exports["default"] = _default; -module.exports = exports.default; + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + } -/***/ }), + get redirected() { + return this[INTERNALS$1].counter > 0; + } -/***/ 7923: -/***/ ((module, exports, __nccwpck_require__) => { + get statusText() { + return this[INTERNALS$1].statusText; + } -"use strict"; + get headers() { + return this[INTERNALS$1].headers; + } - -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = subMilliseconds; -var _index = _interopRequireDefault(__nccwpck_require__(524)); -var _index2 = _interopRequireDefault(__nccwpck_require__(2063)); -var _index3 = _interopRequireDefault(__nccwpck_require__(1985)); -/** - * @name subMilliseconds - * @category Millisecond Helpers - * @summary Subtract the specified number of milliseconds from the given date. - * - * @description - * Subtract the specified number of milliseconds from the given date. - * - * @param {Date|Number} date - the date to be changed - * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`. - * @returns {Date} the new date with the milliseconds subtracted - * @throws {TypeError} 2 arguments required - * - * @example - * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000: - * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750) - * //=> Thu Jul 10 2014 12:45:29.250 - */ -function subMilliseconds(dirtyDate, dirtyAmount) { - (0, _index2.default)(2, arguments); - var amount = (0, _index3.default)(dirtyAmount); - return (0, _index.default)(dirtyDate, -amount); + /** + * Clone this response + * + * @return Response + */ + clone() { + return new Response(clone(this), { + url: this.url, + status: this.status, + statusText: this.statusText, + headers: this.headers, + ok: this.ok, + redirected: this.redirected + }); + } } -module.exports = exports.default; -/***/ }), +Body.mixIn(Response.prototype); -/***/ 6477: -/***/ ((module, exports, __nccwpck_require__) => { +Object.defineProperties(Response.prototype, { + url: { enumerable: true }, + status: { enumerable: true }, + ok: { enumerable: true }, + redirected: { enumerable: true }, + statusText: { enumerable: true }, + headers: { enumerable: true }, + clone: { enumerable: true } +}); -"use strict"; +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); +const INTERNALS$2 = Symbol('Request internals'); +const URL = Url.URL || whatwgUrl.URL; + +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url.parse; +const format_url = Url.format; -var _interopRequireDefault = (__nccwpck_require__(3286)["default"]); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = toDate; -var _typeof2 = _interopRequireDefault(__nccwpck_require__(5605)); -var _index = _interopRequireDefault(__nccwpck_require__(2063)); /** - * @name toDate - * @category Common Helpers - * @summary Convert the given argument to an instance of Date. - * - * @description - * Convert the given argument to an instance of Date. - * - * If the argument is an instance of Date, the function returns its clone. - * - * If the argument is a number, it is treated as a timestamp. - * - * If the argument is none of the above, the function returns Invalid Date. - * - * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`. - * - * @param {Date|Number} argument - the value to convert - * @returns {Date} the parsed date in the local time zone - * @throws {TypeError} 1 argument required - * - * @example - * // Clone the date: - * const result = toDate(new Date(2014, 1, 11, 11, 30, 30)) - * //=> Tue Feb 11 2014 11:30:30 + * Wrapper around `new URL` to handle arbitrary URLs * - * @example - * // Convert the timestamp to date: - * const result = toDate(1392098430000) - * //=> Tue Feb 11 2014 11:30:30 + * @param {string} urlStr + * @return {void} + */ +function parseURL(urlStr) { + /* + Check whether the URL is absolute or not + Scheme: https://tools.ietf.org/html/rfc3986#section-3.1 + Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3 */ -function toDate(argument) { - (0, _index.default)(1, arguments); - var argStr = Object.prototype.toString.call(argument); + if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) { + urlStr = new URL(urlStr).toString(); + } - // Clone the date - if (argument instanceof Date || (0, _typeof2.default)(argument) === 'object' && argStr === '[object Date]') { - // Prevent the date to lose the milliseconds when passed to new Date() in IE10 - return new Date(argument.getTime()); - } else if (typeof argument === 'number' || argStr === '[object Number]') { - return new Date(argument); - } else { - if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') { - // eslint-disable-next-line no-console - console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"); - // eslint-disable-next-line no-console - console.warn(new Error().stack); - } - return new Date(NaN); - } + // Fallback to old implementation for arbitrary URLs + return parse_url(urlStr); } -module.exports = exports.default; - -/***/ }), - -/***/ 8932: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; +const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; -Object.defineProperty(exports, "__esModule", ({ value: true })); +/** + * Check if a value is an instance of Request. + * + * @param Mixed input + * @return Boolean + */ +function isRequest(input) { + return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; +} -class Deprecation extends Error { - constructor(message) { - super(message); // Maintains proper stack trace (only available on V8) +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); +} - /* istanbul ignore next */ +/** + * Request class + * + * @param Mixed input Url or Request instance + * @param Object init Custom options + * @return Void + */ +class Request { + constructor(input) { + let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } + let parsedURL; - this.name = 'Deprecation'; - } + // normalize input + if (!isRequest(input)) { + if (input && input.href) { + // in order to support Node.js' Url objects; though WHATWG's URL objects + // will fall into this branch also (since their `toString()` will return + // `href` property anyway) + parsedURL = parseURL(input.href); + } else { + // coerce input to a string before attempting to parse + parsedURL = parseURL(`${input}`); + } + input = {}; + } else { + parsedURL = parseURL(input.url); + } -} + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); -exports.Deprecation = Deprecation; + if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { + throw new TypeError('Request with GET/HEAD method cannot have body'); + } + let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; -/***/ }), + Body.call(this, inputBody, { + timeout: init.timeout || input.timeout || 0, + size: init.size || input.size || 0 + }); -/***/ 3287: -/***/ ((__unused_webpack_module, exports) => { + const headers = new Headers(init.headers || input.headers || {}); -"use strict"; + if (inputBody != null && !headers.has('Content-Type')) { + const contentType = extractContentType(inputBody); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + let signal = isRequest(input) ? input.signal : null; + if ('signal' in init) signal = init.signal; -Object.defineProperty(exports, "__esModule", ({ value: true })); + if (signal != null && !isAbortSignal(signal)) { + throw new TypeError('Expected signal to be an instanceof AbortSignal'); + } -/*! - * is-plain-object - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ + this[INTERNALS$2] = { + method, + redirect: init.redirect || input.redirect || 'follow', + headers, + parsedURL, + signal + }; -function isObject(o) { - return Object.prototype.toString.call(o) === '[object Object]'; -} + // node-fetch-only options + this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; + this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; + this.counter = init.counter || input.counter || 0; + this.agent = init.agent || input.agent; + } -function isPlainObject(o) { - var ctor,prot; + get method() { + return this[INTERNALS$2].method; + } - if (isObject(o) === false) return false; + get url() { + return format_url(this[INTERNALS$2].parsedURL); + } - // If has modified constructor - ctor = o.constructor; - if (ctor === undefined) return true; + get headers() { + return this[INTERNALS$2].headers; + } - // If has modified prototype - prot = ctor.prototype; - if (isObject(prot) === false) return false; + get redirect() { + return this[INTERNALS$2].redirect; + } - // If constructor does not have an Object-specific method - if (prot.hasOwnProperty('isPrototypeOf') === false) { - return false; - } + get signal() { + return this[INTERNALS$2].signal; + } - // Most likely a plain Object - return true; + /** + * Clone this request + * + * @return Request + */ + clone() { + return new Request(this); + } } -exports.isPlainObject = isPlainObject; - - -/***/ }), - -/***/ 467: -/***/ ((module, exports, __nccwpck_require__) => { +Body.mixIn(Request.prototype); -"use strict"; +Object.defineProperty(Request.prototype, Symbol.toStringTag, { + value: 'Request', + writable: false, + enumerable: false, + configurable: true +}); +Object.defineProperties(Request.prototype, { + method: { enumerable: true }, + url: { enumerable: true }, + headers: { enumerable: true }, + redirect: { enumerable: true }, + clone: { enumerable: true }, + signal: { enumerable: true } +}); -Object.defineProperty(exports, "__esModule", ({ value: true })); - -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } - -var Stream = _interopDefault(__nccwpck_require__(2781)); -var http = _interopDefault(__nccwpck_require__(3685)); -var Url = _interopDefault(__nccwpck_require__(7310)); -var whatwgUrl = _interopDefault(__nccwpck_require__(3323)); -var https = _interopDefault(__nccwpck_require__(5687)); -var zlib = _interopDefault(__nccwpck_require__(9796)); - -// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js - -// fix for "Readable" isn't a named export issue -const Readable = Stream.Readable; - -const BUFFER = Symbol('buffer'); -const TYPE = Symbol('type'); - -class Blob { - constructor() { - this[TYPE] = ''; - - const blobParts = arguments[0]; - const options = arguments[1]; - - const buffers = []; - let size = 0; +/** + * Convert a Request to Node.js http request options. + * + * @param Request A Request instance + * @return Object The options object to be passed to http.request + */ +function getNodeRequestOptions(request) { + const parsedURL = request[INTERNALS$2].parsedURL; + const headers = new Headers(request[INTERNALS$2].headers); - if (blobParts) { - const a = blobParts; - const length = Number(a.length); - for (let i = 0; i < length; i++) { - const element = a[i]; - let buffer; - if (element instanceof Buffer) { - buffer = element; - } else if (ArrayBuffer.isView(element)) { - buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); - } else if (element instanceof ArrayBuffer) { - buffer = Buffer.from(element); - } else if (element instanceof Blob) { - buffer = element[BUFFER]; - } else { - buffer = Buffer.from(typeof element === 'string' ? element : String(element)); - } - size += buffer.length; - buffers.push(buffer); - } - } + // fetch step 1.3 + if (!headers.has('Accept')) { + headers.set('Accept', '*/*'); + } - this[BUFFER] = Buffer.concat(buffers); + // Basic fetch + if (!parsedURL.protocol || !parsedURL.hostname) { + throw new TypeError('Only absolute URLs are supported'); + } - let type = options && options.type !== undefined && String(options.type).toLowerCase(); - if (type && !/[^\u0020-\u007E]/.test(type)) { - this[TYPE] = type; - } + if (!/^https?:$/.test(parsedURL.protocol)) { + throw new TypeError('Only HTTP(S) protocols are supported'); } - get size() { - return this[BUFFER].length; + + if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) { + throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); } - get type() { - return this[TYPE]; + + // HTTP-network-or-cache fetch steps 2.4-2.7 + let contentLengthValue = null; + if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { + contentLengthValue = '0'; } - text() { - return Promise.resolve(this[BUFFER].toString()); + if (request.body != null) { + const totalBytes = getTotalBytes(request); + if (typeof totalBytes === 'number') { + contentLengthValue = String(totalBytes); + } } - arrayBuffer() { - const buf = this[BUFFER]; - const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - return Promise.resolve(ab); + if (contentLengthValue) { + headers.set('Content-Length', contentLengthValue); } - stream() { - const readable = new Readable(); - readable._read = function () {}; - readable.push(this[BUFFER]); - readable.push(null); - return readable; + + // HTTP-network-or-cache fetch step 2.11 + if (!headers.has('User-Agent')) { + headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); } - toString() { - return '[object Blob]'; + + // HTTP-network-or-cache fetch step 2.15 + if (request.compress && !headers.has('Accept-Encoding')) { + headers.set('Accept-Encoding', 'gzip,deflate'); } - slice() { - const size = this.size; - const start = arguments[0]; - const end = arguments[1]; - let relativeStart, relativeEnd; - if (start === undefined) { - relativeStart = 0; - } else if (start < 0) { - relativeStart = Math.max(size + start, 0); - } else { - relativeStart = Math.min(start, size); - } - if (end === undefined) { - relativeEnd = size; - } else if (end < 0) { - relativeEnd = Math.max(size + end, 0); - } else { - relativeEnd = Math.min(end, size); - } - const span = Math.max(relativeEnd - relativeStart, 0); + let agent = request.agent; + if (typeof agent === 'function') { + agent = agent(parsedURL); + } - const buffer = this[BUFFER]; - const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); - const blob = new Blob([], { type: arguments[2] }); - blob[BUFFER] = slicedBuffer; - return blob; + if (!headers.has('Connection') && !agent) { + headers.set('Connection', 'close'); } -} -Object.defineProperties(Blob.prototype, { - size: { enumerable: true }, - type: { enumerable: true }, - slice: { enumerable: true } -}); + // HTTP-network fetch step 4.2 + // chunked encoding is handled by Node.js -Object.defineProperty(Blob.prototype, Symbol.toStringTag, { - value: 'Blob', - writable: false, - enumerable: false, - configurable: true -}); + return Object.assign({}, parsedURL, { + method: request.method, + headers: exportNodeCompatibleHeaders(headers), + agent + }); +} /** - * fetch-error.js + * abort-error.js * - * FetchError interface for operational errors + * AbortError interface for cancelled requests */ /** - * Create FetchError instance + * Create AbortError instance * * @param String message Error message for human - * @param String type Error type for machine - * @param String systemError For Node.js system error - * @return FetchError + * @return AbortError */ -function FetchError(message, type, systemError) { +function AbortError(message) { Error.call(this, message); + this.type = 'aborted'; this.message = message; - this.type = type; - - // when err.type is `system`, err.code contains system error code - if (systemError) { - this.code = this.errno = systemError.code; - } // hide custom error implementation details from end-users Error.captureStackTrace(this, this.constructor); } -FetchError.prototype = Object.create(Error.prototype); -FetchError.prototype.constructor = FetchError; -FetchError.prototype.name = 'FetchError'; +AbortError.prototype = Object.create(Error.prototype); +AbortError.prototype.constructor = AbortError; +AbortError.prototype.name = 'AbortError'; -let convert; -try { - convert = (__nccwpck_require__(3975).convert); -} catch (e) {} +const URL$1 = Url.URL || whatwgUrl.URL; -const INTERNALS = Symbol('Body internals'); +// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 +const PassThrough$1 = Stream.PassThrough; -// fix an issue where "PassThrough" isn't a named export for node <10 -const PassThrough = Stream.PassThrough; +const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) { + const orig = new URL$1(original).hostname; + const dest = new URL$1(destination).hostname; + + return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest); +}; /** - * Body mixin - * - * Ref: https://fetch.spec.whatwg.org/#body + * Fetch function * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void + * @param Mixed url Absolute url or Request instance + * @param Object opts Fetch options + * @return Promise */ -function Body(body) { - var _this = this; +function fetch(url, opts) { - var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref$size = _ref.size; + // allow custom promise + if (!fetch.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } - let size = _ref$size === undefined ? 0 : _ref$size; - var _ref$timeout = _ref.timeout; - let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + Body.Promise = fetch.Promise; - if (body == null) { - // body is undefined or null - body = null; - } else if (isURLSearchParams(body)) { - // body is a URLSearchParams - body = Buffer.from(body.toString()); - } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { - // body is ArrayBuffer - body = Buffer.from(body); - } else if (ArrayBuffer.isView(body)) { - // body is ArrayBufferView - body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); - } else if (body instanceof Stream) ; else { - // none of the above - // coerce to string then buffer - body = Buffer.from(String(body)); - } - this[INTERNALS] = { - body, - disturbed: false, - error: null - }; - this.size = size; - this.timeout = timeout; - - if (body instanceof Stream) { - body.on('error', function (err) { - const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); - _this[INTERNALS].error = error; - }); - } -} - -Body.prototype = { - get body() { - return this[INTERNALS].body; - }, - - get bodyUsed() { - return this[INTERNALS].disturbed; - }, - - /** - * Decode response as ArrayBuffer - * - * @return Promise - */ - arrayBuffer() { - return consumeBody.call(this).then(function (buf) { - return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - }); - }, + // wrap http.request into fetch + return new fetch.Promise(function (resolve, reject) { + // build request object + const request = new Request(url, opts); + const options = getNodeRequestOptions(request); - /** - * Return raw response as Blob - * - * @return Promise - */ - blob() { - let ct = this.headers && this.headers.get('content-type') || ''; - return consumeBody.call(this).then(function (buf) { - return Object.assign( - // Prevent copying - new Blob([], { - type: ct.toLowerCase() - }), { - [BUFFER]: buf - }); - }); - }, + const send = (options.protocol === 'https:' ? https : http).request; + const signal = request.signal; - /** - * Decode response as json - * - * @return Promise - */ - json() { - var _this2 = this; + let response = null; - return consumeBody.call(this).then(function (buffer) { - try { - return JSON.parse(buffer.toString()); - } catch (err) { - return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + const abort = function abort() { + let error = new AbortError('The user aborted a request.'); + reject(error); + if (request.body && request.body instanceof Stream.Readable) { + request.body.destroy(error); } - }); - }, - - /** - * Decode response as text - * - * @return Promise - */ - text() { - return consumeBody.call(this).then(function (buffer) { - return buffer.toString(); - }); - }, + if (!response || !response.body) return; + response.body.emit('error', error); + }; - /** - * Decode response as buffer (non-spec api) - * - * @return Promise - */ - buffer() { - return consumeBody.call(this); - }, + if (signal && signal.aborted) { + abort(); + return; + } - /** - * Decode response as text, while automatically detecting the encoding and - * trying to decode to UTF-8 (non-spec api) - * - * @return Promise - */ - textConverted() { - var _this3 = this; + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; - return consumeBody.call(this).then(function (buffer) { - return convertBody(buffer, _this3.headers); - }); - } -}; + // send request + const req = send(options); + let reqTimeout; -// In browsers, all properties are enumerable. -Object.defineProperties(Body.prototype, { - body: { enumerable: true }, - bodyUsed: { enumerable: true }, - arrayBuffer: { enumerable: true }, - blob: { enumerable: true }, - json: { enumerable: true }, - text: { enumerable: true } -}); + if (signal) { + signal.addEventListener('abort', abortAndFinalize); + } -Body.mixIn = function (proto) { - for (const name of Object.getOwnPropertyNames(Body.prototype)) { - // istanbul ignore else: future proof - if (!(name in proto)) { - const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); - Object.defineProperty(proto, name, desc); + function finalize() { + req.abort(); + if (signal) signal.removeEventListener('abort', abortAndFinalize); + clearTimeout(reqTimeout); } - } -}; -/** - * Consume and convert an entire Body to a Buffer. - * - * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body - * - * @return Promise - */ -function consumeBody() { - var _this4 = this; + if (request.timeout) { + req.once('socket', function (socket) { + reqTimeout = setTimeout(function () { + reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); + finalize(); + }, request.timeout); + }); + } - if (this[INTERNALS].disturbed) { - return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); - } + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + finalize(); + }); - this[INTERNALS].disturbed = true; + req.on('response', function (res) { + clearTimeout(reqTimeout); - if (this[INTERNALS].error) { - return Body.Promise.reject(this[INTERNALS].error); - } + const headers = createHeadersLenient(res.headers); - let body = this.body; + // HTTP fetch step 5 + if (fetch.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); - // body is null - if (body === null) { - return Body.Promise.resolve(Buffer.alloc(0)); - } + // HTTP fetch step 5.3 + let locationURL = null; + try { + locationURL = location === null ? null : new URL$1(location, request.url).toString(); + } catch (err) { + // error here can only be invalid URL in Location: header + // do not throw when options.redirect == manual + // let the user extract the errorneous redirect URL + if (request.redirect !== 'manual') { + reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect')); + finalize(); + return; + } + } - // body is blob - if (isBlob(body)) { - body = body.stream(); - } + // HTTP fetch step 5.5 + switch (request.redirect) { + case 'error': + reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); + finalize(); + return; + case 'manual': + // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. + if (locationURL !== null) { + // handle corrupted header + try { + headers.set('Location', locationURL); + } catch (err) { + // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request + reject(err); + } + } + break; + case 'follow': + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } - // body is buffer - if (Buffer.isBuffer(body)) { - return Body.Promise.resolve(body); - } + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } - // istanbul ignore if: should never happen - if (!(body instanceof Stream)) { - return Body.Promise.resolve(Buffer.alloc(0)); - } + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOpts = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: request.body, + signal: request.signal, + timeout: request.timeout, + size: request.size + }; - // body is stream - // get ready to actually consume the body - let accum = []; - let accumBytes = 0; - let abort = false; + if (!isDomainOrSubdomain(request.url, locationURL)) { + for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) { + requestOpts.headers.delete(name); + } + } - return new Body.Promise(function (resolve, reject) { - let resTimeout; + // HTTP-redirect fetch step 9 + if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { + reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); + finalize(); + return; + } - // allow timeout on slow response body - if (_this4.timeout) { - resTimeout = setTimeout(function () { - abort = true; - reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); - }, _this4.timeout); - } + // HTTP-redirect fetch step 11 + if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { + requestOpts.method = 'GET'; + requestOpts.body = undefined; + requestOpts.headers.delete('content-length'); + } - // handle stream errors - body.on('error', function (err) { - if (err.name === 'AbortError') { - // if the request was aborted, reject with this Error - abort = true; - reject(err); - } else { - // other errors, such as incorrect content-encoding - reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOpts))); + finalize(); + return; + } } - }); - body.on('data', function (chunk) { - if (abort || chunk === null) { - return; - } + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); - if (_this4.size && accumBytes + chunk.length > _this4.size) { - abort = true; - reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter + }; + + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); + + // HTTP-network fetch step 12.1.1.4: handle content codings + + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { + response = new Response(body, response_options); + resolve(response); return; } - accumBytes += chunk.length; - accum.push(chunk); - }); + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib.Z_SYNC_FLUSH, + finishFlush: zlib.Z_SYNC_FLUSH + }; - body.on('end', function () { - if (abort) { + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib.createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); return; } - clearTimeout(resTimeout); + // for deflate + if (codings == 'deflate' || codings == 'x-deflate') { + // handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = res.pipe(new PassThrough$1()); + raw.once('data', function (chunk) { + // see http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0F) === 0x08) { + body = body.pipe(zlib.createInflate()); + } else { + body = body.pipe(zlib.createInflateRaw()); + } + response = new Response(body, response_options); + resolve(response); + }); + return; + } - try { - resolve(Buffer.concat(accum, accumBytes)); - } catch (err) { - // handle streams that have accumulated too much data (issue #414) - reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + // for br + if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') { + body = body.pipe(zlib.createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; } + + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); }); + + writeToStream(req, request); }); } - /** - * Detect buffer encoding and convert to target encoding - * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * Redirect code matching * - * @param Buffer buffer Incoming buffer - * @param String encoding Target encoding - * @return String + * @param Number code Status code + * @return Boolean */ -function convertBody(buffer, headers) { - if (typeof convert !== 'function') { - throw new Error('The package `encoding` must be installed to use the textConverted() function'); - } +fetch.isRedirect = function (code) { + return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; +}; - const ct = headers.get('content-type'); - let charset = 'utf-8'; - let res, str; +// expose Promise +fetch.Promise = global.Promise; - // header - if (ct) { - res = /charset=([^;]*)/i.exec(ct); - } +module.exports = exports = fetch; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports["default"] = exports; +exports.Headers = Headers; +exports.Request = Request; +exports.Response = Response; +exports.FetchError = FetchError; - // no charset in content type, peek at response body for at most 1024 bytes - str = buffer.slice(0, 1024).toString(); - // html5 - if (!res && str) { - res = / { - if (res) { - res = /charset=(.*)/i.exec(res.pop()); - } - } +"use strict"; - // xml - if (!res && str) { - res = /<\?xml.+?encoding=(['"])(.+?)\1/i.exec(str); - } - // found charset - if (res) { - charset = res.pop(); +var punycode = __nccwpck_require__(5477); +var mappingTable = __nccwpck_require__(1907); - // prevent decode issues when sites use incorrect encoding - // ref: https://hsivonen.fi/encoding-menu/ - if (charset === 'gb2312' || charset === 'gbk') { - charset = 'gb18030'; - } - } +var PROCESSING_OPTIONS = { + TRANSITIONAL: 0, + NONTRANSITIONAL: 1 +}; - // turn raw buffers into a single utf-8 buffer - return convert(buffer, 'UTF-8', charset).toString(); +function normalize(str) { // fix bug in v8 + return str.split('\u0000').map(function (s) { return s.normalize('NFC'); }).join('\u0000'); } -/** - * Detect a URLSearchParams object - * ref: https://github.com/bitinn/node-fetch/issues/296#issuecomment-307598143 - * - * @param Object obj Object to detect by type or brand - * @return String - */ -function isURLSearchParams(obj) { - // Duck-typing as a necessary condition. - if (typeof obj !== 'object' || typeof obj.append !== 'function' || typeof obj.delete !== 'function' || typeof obj.get !== 'function' || typeof obj.getAll !== 'function' || typeof obj.has !== 'function' || typeof obj.set !== 'function') { - return false; - } +function findStatus(val) { + var start = 0; + var end = mappingTable.length - 1; - // Brand-checking and more duck-typing as optional condition. - return obj.constructor.name === 'URLSearchParams' || Object.prototype.toString.call(obj) === '[object URLSearchParams]' || typeof obj.sort === 'function'; -} + while (start <= end) { + var mid = Math.floor((start + end) / 2); -/** - * Check if `obj` is a W3C `Blob` object (which `File` inherits from) - * @param {*} obj - * @return {boolean} - */ -function isBlob(obj) { - return typeof obj === 'object' && typeof obj.arrayBuffer === 'function' && typeof obj.type === 'string' && typeof obj.stream === 'function' && typeof obj.constructor === 'function' && typeof obj.constructor.name === 'string' && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]); + var target = mappingTable[mid]; + if (target[0][0] <= val && target[0][1] >= val) { + return target; + } else if (target[0][0] > val) { + end = mid - 1; + } else { + start = mid + 1; + } + } + + return null; } -/** - * Clone body given Res/Req instance - * - * @param Mixed instance Response or Request instance - * @return Mixed - */ -function clone(instance) { - let p1, p2; - let body = instance.body; +var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - // don't allow cloning a used body - if (instance.bodyUsed) { - throw new Error('cannot clone body after it is used'); - } +function countSymbols(string) { + return string + // replace every surrogate pair with a BMP symbol + .replace(regexAstralSymbols, '_') + // then get the length + .length; +} - // check that body is a stream and not form-data object - // note: we can't clone the form-data object without having it as a dependency - if (body instanceof Stream && typeof body.getBoundary !== 'function') { - // tee instance body - p1 = new PassThrough(); - p2 = new PassThrough(); - body.pipe(p1); - body.pipe(p2); - // set instance body to teed body and return the other teed body - instance[INTERNALS].body = p1; - body = p2; - } +function mapChars(domain_name, useSTD3, processing_option) { + var hasError = false; + var processed = ""; - return body; -} + var len = countSymbols(domain_name); + for (var i = 0; i < len; ++i) { + var codePoint = domain_name.codePointAt(i); + var status = findStatus(codePoint); -/** - * Performs the operation "extract a `Content-Type` value from |object|" as - * specified in the specification: - * https://fetch.spec.whatwg.org/#concept-bodyinit-extract - * - * This function assumes that instance.body is present. - * - * @param Mixed instance Any options.body input - */ -function extractContentType(body) { - if (body === null) { - // body is null - return null; - } else if (typeof body === 'string') { - // body is string - return 'text/plain;charset=UTF-8'; - } else if (isURLSearchParams(body)) { - // body is a URLSearchParams - return 'application/x-www-form-urlencoded;charset=UTF-8'; - } else if (isBlob(body)) { - // body is blob - return body.type || null; - } else if (Buffer.isBuffer(body)) { - // body is buffer - return null; - } else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { - // body is ArrayBuffer - return null; - } else if (ArrayBuffer.isView(body)) { - // body is ArrayBufferView - return null; - } else if (typeof body.getBoundary === 'function') { - // detect form data input from form-data module - return `multipart/form-data;boundary=${body.getBoundary()}`; - } else if (body instanceof Stream) { - // body is stream - // can't really do much about this - return null; - } else { - // Body constructor defaults other things to string - return 'text/plain;charset=UTF-8'; - } + switch (status[1]) { + case "disallowed": + hasError = true; + processed += String.fromCodePoint(codePoint); + break; + case "ignored": + break; + case "mapped": + processed += String.fromCodePoint.apply(String, status[2]); + break; + case "deviation": + if (processing_option === PROCESSING_OPTIONS.TRANSITIONAL) { + processed += String.fromCodePoint.apply(String, status[2]); + } else { + processed += String.fromCodePoint(codePoint); + } + break; + case "valid": + processed += String.fromCodePoint(codePoint); + break; + case "disallowed_STD3_mapped": + if (useSTD3) { + hasError = true; + processed += String.fromCodePoint(codePoint); + } else { + processed += String.fromCodePoint.apply(String, status[2]); + } + break; + case "disallowed_STD3_valid": + if (useSTD3) { + hasError = true; + } + + processed += String.fromCodePoint(codePoint); + break; + } + } + + return { + string: processed, + error: hasError + }; } -/** - * The Fetch Standard treats this as if "total bytes" is a property on the body. - * For us, we have to explicitly get it with a function. - * - * ref: https://fetch.spec.whatwg.org/#concept-body-total-bytes - * - * @param Body instance Instance of Body - * @return Number? Number of bytes, or null if not possible - */ -function getTotalBytes(instance) { - const body = instance.body; +var combiningMarksRegex = /[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFC-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2D]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC7F-\uDC82\uDCB0-\uDCBA\uDD00-\uDD02\uDD27-\uDD34\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDE2C-\uDE37\uDEDF-\uDEEA\uDF01-\uDF03\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDE30-\uDE40\uDEAB-\uDEB7]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF51-\uDF7E\uDF8F-\uDF92]|\uD82F[\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD83A[\uDCD0-\uDCD6]|\uDB40[\uDD00-\uDDEF]/; +function validateLabel(label, processing_option) { + if (label.substr(0, 4) === "xn--") { + label = punycode.toUnicode(label); + processing_option = PROCESSING_OPTIONS.NONTRANSITIONAL; + } - if (body === null) { - // body is null - return 0; - } else if (isBlob(body)) { - return body.size; - } else if (Buffer.isBuffer(body)) { - // body is buffer - return body.length; - } else if (body && typeof body.getLengthSync === 'function') { - // detect form data input from form-data module - if (body._lengthRetrievers && body._lengthRetrievers.length == 0 || // 1.x - body.hasKnownLength && body.hasKnownLength()) { - // 2.x - return body.getLengthSync(); - } - return null; - } else { - // body is stream - return null; - } -} + var error = false; -/** - * Write a Body to a Node.js WritableStream (e.g. http.Request) object. - * - * @param Body instance Instance of Body - * @return Void - */ -function writeToStream(dest, instance) { - const body = instance.body; + if (normalize(label) !== label || + (label[3] === "-" && label[4] === "-") || + label[0] === "-" || label[label.length - 1] === "-" || + label.indexOf(".") !== -1 || + label.search(combiningMarksRegex) === 0) { + error = true; + } + var len = countSymbols(label); + for (var i = 0; i < len; ++i) { + var status = findStatus(label.codePointAt(i)); + if ((processing === PROCESSING_OPTIONS.TRANSITIONAL && status[1] !== "valid") || + (processing === PROCESSING_OPTIONS.NONTRANSITIONAL && + status[1] !== "valid" && status[1] !== "deviation")) { + error = true; + break; + } + } - if (body === null) { - // body is null - dest.end(); - } else if (isBlob(body)) { - body.stream().pipe(dest); - } else if (Buffer.isBuffer(body)) { - // body is buffer - dest.write(body); - dest.end(); - } else { - // body is stream - body.pipe(dest); - } + return { + label: label, + error: error + }; } -// expose Promise -Body.Promise = global.Promise; - -/** - * headers.js - * - * Headers class offers convenient helpers - */ +function processing(domain_name, useSTD3, processing_option) { + var result = mapChars(domain_name, useSTD3, processing_option); + result.string = normalize(result.string); -const invalidTokenRegex = /[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/; -const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/; + var labels = result.string.split("."); + for (var i = 0; i < labels.length; ++i) { + try { + var validation = validateLabel(labels[i]); + labels[i] = validation.label; + result.error = result.error || validation.error; + } catch(e) { + result.error = true; + } + } -function validateName(name) { - name = `${name}`; - if (invalidTokenRegex.test(name) || name === '') { - throw new TypeError(`${name} is not a legal HTTP header name`); - } + return { + string: labels.join("."), + error: result.error + }; } -function validateValue(value) { - value = `${value}`; - if (invalidHeaderCharRegex.test(value)) { - throw new TypeError(`${value} is not a legal HTTP header value`); - } -} +module.exports.toASCII = function(domain_name, useSTD3, processing_option, verifyDnsLength) { + var result = processing(domain_name, useSTD3, processing_option); + var labels = result.string.split("."); + labels = labels.map(function(l) { + try { + return punycode.toASCII(l); + } catch(e) { + result.error = true; + return l; + } + }); -/** - * Find the key in the map object given a header name. - * - * Returns undefined if not found. - * - * @param String name Header name - * @return String|Undefined - */ -function find(map, name) { - name = name.toLowerCase(); - for (const key in map) { - if (key.toLowerCase() === name) { - return key; - } - } - return undefined; -} + if (verifyDnsLength) { + var total = labels.slice(0, labels.length - 1).join(".").length; + if (total.length > 253 || total.length === 0) { + result.error = true; + } -const MAP = Symbol('map'); -class Headers { - /** - * Headers class - * - * @param Object headers Response headers - * @return Void - */ - constructor() { - let init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; + for (var i=0; i < labels.length; ++i) { + if (labels.length > 63 || labels.length === 0) { + result.error = true; + break; + } + } + } - this[MAP] = Object.create(null); + if (result.error) return null; + return labels.join("."); +}; - if (init instanceof Headers) { - const rawHeaders = init.raw(); - const headerNames = Object.keys(rawHeaders); +module.exports.toUnicode = function(domain_name, useSTD3) { + var result = processing(domain_name, useSTD3, PROCESSING_OPTIONS.NONTRANSITIONAL); - for (const headerName of headerNames) { - for (const value of rawHeaders[headerName]) { - this.append(headerName, value); - } - } + return { + domain: result.string, + error: result.error + }; +}; - return; - } +module.exports.PROCESSING_OPTIONS = PROCESSING_OPTIONS; - // We don't worry about converting prop to ByteString here as append() - // will handle it. - if (init == null) ; else if (typeof init === 'object') { - const method = init[Symbol.iterator]; - if (method != null) { - if (typeof method !== 'function') { - throw new TypeError('Header pairs must be iterable'); - } - // sequence> - // Note: per spec we have to first exhaust the lists then process them - const pairs = []; - for (const pair of init) { - if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { - throw new TypeError('Each header pair must be iterable'); - } - pairs.push(Array.from(pair)); - } +/***/ }), - for (const pair of pairs) { - if (pair.length !== 2) { - throw new TypeError('Each header pair must be a name/value tuple'); - } - this.append(pair[0], pair[1]); - } - } else { - // record - for (const key of Object.keys(init)) { - const value = init[key]; - this.append(key, value); - } - } - } else { - throw new TypeError('Provided initializer must be an object'); - } - } +/***/ 5871: +/***/ ((module) => { - /** - * Return combined header value given name - * - * @param String name Header name - * @return Mixed - */ - get(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key === undefined) { - return null; - } +"use strict"; - return this[MAP][key].join(', '); - } - /** - * Iterate over all headers - * - * @param Function callback Executed for each item with parameters (value, name, thisArg) - * @param Boolean thisArg `this` context for callback function - * @return Void - */ - forEach(callback) { - let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; +var conversions = {}; +module.exports = conversions; - let pairs = getHeaders(this); - let i = 0; - while (i < pairs.length) { - var _pairs$i = pairs[i]; - const name = _pairs$i[0], - value = _pairs$i[1]; +function sign(x) { + return x < 0 ? -1 : 1; +} - callback.call(thisArg, value, name, this); - pairs = getHeaders(this); - i++; - } - } +function evenRound(x) { + // Round x to the nearest integer, choosing the even integer if it lies halfway between two. + if ((x % 1) === 0.5 && (x & 1) === 0) { // [even number].5; round down (i.e. floor) + return Math.floor(x); + } else { + return Math.round(x); + } +} - /** - * Overwrite header values given name - * - * @param String name Header name - * @param String value Header value - * @return Void - */ - set(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - this[MAP][key !== undefined ? key : name] = [value]; - } +function createNumberConversion(bitLength, typeOpts) { + if (!typeOpts.unsigned) { + --bitLength; + } + const lowerBound = typeOpts.unsigned ? 0 : -Math.pow(2, bitLength); + const upperBound = Math.pow(2, bitLength) - 1; - /** - * Append a value onto existing header - * - * @param String name Header name - * @param String value Header value - * @return Void - */ - append(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - if (key !== undefined) { - this[MAP][key].push(value); - } else { - this[MAP][name] = [value]; - } - } + const moduloVal = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength) : Math.pow(2, bitLength); + const moduloBound = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength - 1) : Math.pow(2, bitLength - 1); - /** - * Check for header name existence - * - * @param String name Header name - * @return Boolean - */ - has(name) { - name = `${name}`; - validateName(name); - return find(this[MAP], name) !== undefined; - } + return function(V, opts) { + if (!opts) opts = {}; - /** - * Delete all header values given name - * - * @param String name Header name - * @return Void - */ - delete(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key !== undefined) { - delete this[MAP][key]; - } - } + let x = +V; - /** - * Return raw headers (non-spec api) - * - * @return Object - */ - raw() { - return this[MAP]; - } + if (opts.enforceRange) { + if (!Number.isFinite(x)) { + throw new TypeError("Argument is not a finite number"); + } - /** - * Get an iterator on keys. - * - * @return Iterator - */ - keys() { - return createHeadersIterator(this, 'key'); - } + x = sign(x) * Math.floor(Math.abs(x)); + if (x < lowerBound || x > upperBound) { + throw new TypeError("Argument is not in byte range"); + } - /** - * Get an iterator on values. - * - * @return Iterator - */ - values() { - return createHeadersIterator(this, 'value'); - } + return x; + } - /** - * Get an iterator on entries. - * - * This is the default iterator of the Headers object. - * - * @return Iterator - */ - [Symbol.iterator]() { - return createHeadersIterator(this, 'key+value'); - } -} -Headers.prototype.entries = Headers.prototype[Symbol.iterator]; - -Object.defineProperty(Headers.prototype, Symbol.toStringTag, { - value: 'Headers', - writable: false, - enumerable: false, - configurable: true -}); + if (!isNaN(x) && opts.clamp) { + x = evenRound(x); -Object.defineProperties(Headers.prototype, { - get: { enumerable: true }, - forEach: { enumerable: true }, - set: { enumerable: true }, - append: { enumerable: true }, - has: { enumerable: true }, - delete: { enumerable: true }, - keys: { enumerable: true }, - values: { enumerable: true }, - entries: { enumerable: true } -}); + if (x < lowerBound) x = lowerBound; + if (x > upperBound) x = upperBound; + return x; + } -function getHeaders(headers) { - let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + if (!Number.isFinite(x) || x === 0) { + return 0; + } - const keys = Object.keys(headers[MAP]).sort(); - return keys.map(kind === 'key' ? function (k) { - return k.toLowerCase(); - } : kind === 'value' ? function (k) { - return headers[MAP][k].join(', '); - } : function (k) { - return [k.toLowerCase(), headers[MAP][k].join(', ')]; - }); -} + x = sign(x) * Math.floor(Math.abs(x)); + x = x % moduloVal; -const INTERNAL = Symbol('internal'); + if (!typeOpts.unsigned && x >= moduloBound) { + return x - moduloVal; + } else if (typeOpts.unsigned) { + if (x < 0) { + x += moduloVal; + } else if (x === -0) { // don't return negative zero + return 0; + } + } -function createHeadersIterator(target, kind) { - const iterator = Object.create(HeadersIteratorPrototype); - iterator[INTERNAL] = { - target, - kind, - index: 0 - }; - return iterator; + return x; + } } -const HeadersIteratorPrototype = Object.setPrototypeOf({ - next() { - // istanbul ignore if - if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { - throw new TypeError('Value of `this` is not a HeadersIterator'); - } +conversions["void"] = function () { + return undefined; +}; - var _INTERNAL = this[INTERNAL]; - const target = _INTERNAL.target, - kind = _INTERNAL.kind, - index = _INTERNAL.index; +conversions["boolean"] = function (val) { + return !!val; +}; - const values = getHeaders(target, kind); - const len = values.length; - if (index >= len) { - return { - value: undefined, - done: true - }; - } +conversions["byte"] = createNumberConversion(8, { unsigned: false }); +conversions["octet"] = createNumberConversion(8, { unsigned: true }); - this[INTERNAL].index = index + 1; +conversions["short"] = createNumberConversion(16, { unsigned: false }); +conversions["unsigned short"] = createNumberConversion(16, { unsigned: true }); - return { - value: values[index], - done: false - }; - } -}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); +conversions["long"] = createNumberConversion(32, { unsigned: false }); +conversions["unsigned long"] = createNumberConversion(32, { unsigned: true }); -Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { - value: 'HeadersIterator', - writable: false, - enumerable: false, - configurable: true -}); +conversions["long long"] = createNumberConversion(32, { unsigned: false, moduloBitLength: 64 }); +conversions["unsigned long long"] = createNumberConversion(32, { unsigned: true, moduloBitLength: 64 }); -/** - * Export the Headers object in a form that Node.js can consume. - * - * @param Headers headers - * @return Object - */ -function exportNodeCompatibleHeaders(headers) { - const obj = Object.assign({ __proto__: null }, headers[MAP]); +conversions["double"] = function (V) { + const x = +V; - // http.request() only supports string as Host header. This hack makes - // specifying custom Host header possible. - const hostHeaderKey = find(headers[MAP], 'Host'); - if (hostHeaderKey !== undefined) { - obj[hostHeaderKey] = obj[hostHeaderKey][0]; - } + if (!Number.isFinite(x)) { + throw new TypeError("Argument is not a finite floating-point value"); + } - return obj; -} + return x; +}; -/** - * Create a Headers object from an object of headers, ignoring those that do - * not conform to HTTP grammar productions. - * - * @param Object obj Object of headers - * @return Headers - */ -function createHeadersLenient(obj) { - const headers = new Headers(); - for (const name of Object.keys(obj)) { - if (invalidTokenRegex.test(name)) { - continue; - } - if (Array.isArray(obj[name])) { - for (const val of obj[name]) { - if (invalidHeaderCharRegex.test(val)) { - continue; - } - if (headers[MAP][name] === undefined) { - headers[MAP][name] = [val]; - } else { - headers[MAP][name].push(val); - } - } - } else if (!invalidHeaderCharRegex.test(obj[name])) { - headers[MAP][name] = [obj[name]]; - } - } - return headers; -} +conversions["unrestricted double"] = function (V) { + const x = +V; -const INTERNALS$1 = Symbol('Response internals'); + if (isNaN(x)) { + throw new TypeError("Argument is NaN"); + } -// fix an issue where "STATUS_CODES" aren't a named export for node <10 -const STATUS_CODES = http.STATUS_CODES; + return x; +}; -/** - * Response class - * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void - */ -class Response { - constructor() { - let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; +// not quite valid, but good enough for JS +conversions["float"] = conversions["double"]; +conversions["unrestricted float"] = conversions["unrestricted double"]; - Body.call(this, body, opts); +conversions["DOMString"] = function (V, opts) { + if (!opts) opts = {}; - const status = opts.status || 200; - const headers = new Headers(opts.headers); + if (opts.treatNullAsEmptyString && V === null) { + return ""; + } - if (body != null && !headers.has('Content-Type')) { - const contentType = extractContentType(body); - if (contentType) { - headers.append('Content-Type', contentType); - } - } + return String(V); +}; - this[INTERNALS$1] = { - url: opts.url, - status, - statusText: opts.statusText || STATUS_CODES[status], - headers, - counter: opts.counter - }; - } +conversions["ByteString"] = function (V, opts) { + const x = String(V); + let c = undefined; + for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) { + if (c > 255) { + throw new TypeError("Argument is not a valid bytestring"); + } + } - get url() { - return this[INTERNALS$1].url || ''; - } + return x; +}; - get status() { - return this[INTERNALS$1].status; - } +conversions["USVString"] = function (V) { + const S = String(V); + const n = S.length; + const U = []; + for (let i = 0; i < n; ++i) { + const c = S.charCodeAt(i); + if (c < 0xD800 || c > 0xDFFF) { + U.push(String.fromCodePoint(c)); + } else if (0xDC00 <= c && c <= 0xDFFF) { + U.push(String.fromCodePoint(0xFFFD)); + } else { + if (i === n - 1) { + U.push(String.fromCodePoint(0xFFFD)); + } else { + const d = S.charCodeAt(i + 1); + if (0xDC00 <= d && d <= 0xDFFF) { + const a = c & 0x3FF; + const b = d & 0x3FF; + U.push(String.fromCodePoint((2 << 15) + (2 << 9) * a + b)); + ++i; + } else { + U.push(String.fromCodePoint(0xFFFD)); + } + } + } + } - /** - * Convenience property representing if the request ended normally - */ - get ok() { - return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; - } + return U.join(''); +}; - get redirected() { - return this[INTERNALS$1].counter > 0; - } +conversions["Date"] = function (V, opts) { + if (!(V instanceof Date)) { + throw new TypeError("Argument is not a Date object"); + } + if (isNaN(V)) { + return undefined; + } - get statusText() { - return this[INTERNALS$1].statusText; - } + return V; +}; - get headers() { - return this[INTERNALS$1].headers; - } +conversions["RegExp"] = function (V, opts) { + if (!(V instanceof RegExp)) { + V = new RegExp(V); + } - /** - * Clone this response - * - * @return Response - */ - clone() { - return new Response(clone(this), { - url: this.url, - status: this.status, - statusText: this.statusText, - headers: this.headers, - ok: this.ok, - redirected: this.redirected - }); - } -} + return V; +}; -Body.mixIn(Response.prototype); -Object.defineProperties(Response.prototype, { - url: { enumerable: true }, - status: { enumerable: true }, - ok: { enumerable: true }, - redirected: { enumerable: true }, - statusText: { enumerable: true }, - headers: { enumerable: true }, - clone: { enumerable: true } -}); +/***/ }), -Object.defineProperty(Response.prototype, Symbol.toStringTag, { - value: 'Response', - writable: false, - enumerable: false, - configurable: true -}); +/***/ 8262: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -const INTERNALS$2 = Symbol('Request internals'); -const URL = Url.URL || whatwgUrl.URL; +"use strict"; -// fix an issue where "format", "parse" aren't a named export for node <10 -const parse_url = Url.parse; -const format_url = Url.format; +const usm = __nccwpck_require__(33); -/** - * Wrapper around `new URL` to handle arbitrary URLs - * - * @param {string} urlStr - * @return {void} - */ -function parseURL(urlStr) { - /* - Check whether the URL is absolute or not - Scheme: https://tools.ietf.org/html/rfc3986#section-3.1 - Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3 - */ - if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) { - urlStr = new URL(urlStr).toString(); - } +exports.implementation = class URLImpl { + constructor(constructorArgs) { + const url = constructorArgs[0]; + const base = constructorArgs[1]; - // Fallback to old implementation for arbitrary URLs - return parse_url(urlStr); -} + let parsedBase = null; + if (base !== undefined) { + parsedBase = usm.basicURLParse(base); + if (parsedBase === "failure") { + throw new TypeError("Invalid base URL"); + } + } -const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; + const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase }); + if (parsedURL === "failure") { + throw new TypeError("Invalid URL"); + } -/** - * Check if a value is an instance of Request. - * - * @param Mixed input - * @return Boolean - */ -function isRequest(input) { - return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; -} + this._url = parsedURL; -function isAbortSignal(signal) { - const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); - return !!(proto && proto.constructor.name === 'AbortSignal'); -} + // TODO: query stuff + } -/** - * Request class - * - * @param Mixed input Url or Request instance - * @param Object init Custom options - * @return Void - */ -class Request { - constructor(input) { - let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + get href() { + return usm.serializeURL(this._url); + } - let parsedURL; + set href(v) { + const parsedURL = usm.basicURLParse(v); + if (parsedURL === "failure") { + throw new TypeError("Invalid URL"); + } - // normalize input - if (!isRequest(input)) { - if (input && input.href) { - // in order to support Node.js' Url objects; though WHATWG's URL objects - // will fall into this branch also (since their `toString()` will return - // `href` property anyway) - parsedURL = parseURL(input.href); - } else { - // coerce input to a string before attempting to parse - parsedURL = parseURL(`${input}`); - } - input = {}; - } else { - parsedURL = parseURL(input.url); - } + this._url = parsedURL; + } - let method = init.method || input.method || 'GET'; - method = method.toUpperCase(); + get origin() { + return usm.serializeURLOrigin(this._url); + } - if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { - throw new TypeError('Request with GET/HEAD method cannot have body'); - } + get protocol() { + return this._url.scheme + ":"; + } - let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; + set protocol(v) { + usm.basicURLParse(v + ":", { url: this._url, stateOverride: "scheme start" }); + } - Body.call(this, inputBody, { - timeout: init.timeout || input.timeout || 0, - size: init.size || input.size || 0 - }); + get username() { + return this._url.username; + } - const headers = new Headers(init.headers || input.headers || {}); + set username(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } - if (inputBody != null && !headers.has('Content-Type')) { - const contentType = extractContentType(inputBody); - if (contentType) { - headers.append('Content-Type', contentType); - } - } + usm.setTheUsername(this._url, v); + } - let signal = isRequest(input) ? input.signal : null; - if ('signal' in init) signal = init.signal; + get password() { + return this._url.password; + } - if (signal != null && !isAbortSignal(signal)) { - throw new TypeError('Expected signal to be an instanceof AbortSignal'); - } + set password(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } - this[INTERNALS$2] = { - method, - redirect: init.redirect || input.redirect || 'follow', - headers, - parsedURL, - signal - }; + usm.setThePassword(this._url, v); + } - // node-fetch-only options - this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; - this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; - this.counter = init.counter || input.counter || 0; - this.agent = init.agent || input.agent; - } + get host() { + const url = this._url; - get method() { - return this[INTERNALS$2].method; - } + if (url.host === null) { + return ""; + } - get url() { - return format_url(this[INTERNALS$2].parsedURL); - } + if (url.port === null) { + return usm.serializeHost(url.host); + } - get headers() { - return this[INTERNALS$2].headers; - } + return usm.serializeHost(url.host) + ":" + usm.serializeInteger(url.port); + } - get redirect() { - return this[INTERNALS$2].redirect; - } + set host(v) { + if (this._url.cannotBeABaseURL) { + return; + } - get signal() { - return this[INTERNALS$2].signal; - } + usm.basicURLParse(v, { url: this._url, stateOverride: "host" }); + } - /** - * Clone this request - * - * @return Request - */ - clone() { - return new Request(this); - } -} - -Body.mixIn(Request.prototype); + get hostname() { + if (this._url.host === null) { + return ""; + } -Object.defineProperty(Request.prototype, Symbol.toStringTag, { - value: 'Request', - writable: false, - enumerable: false, - configurable: true -}); + return usm.serializeHost(this._url.host); + } -Object.defineProperties(Request.prototype, { - method: { enumerable: true }, - url: { enumerable: true }, - headers: { enumerable: true }, - redirect: { enumerable: true }, - clone: { enumerable: true }, - signal: { enumerable: true } -}); + set hostname(v) { + if (this._url.cannotBeABaseURL) { + return; + } -/** - * Convert a Request to Node.js http request options. - * - * @param Request A Request instance - * @return Object The options object to be passed to http.request - */ -function getNodeRequestOptions(request) { - const parsedURL = request[INTERNALS$2].parsedURL; - const headers = new Headers(request[INTERNALS$2].headers); + usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" }); + } - // fetch step 1.3 - if (!headers.has('Accept')) { - headers.set('Accept', '*/*'); - } + get port() { + if (this._url.port === null) { + return ""; + } - // Basic fetch - if (!parsedURL.protocol || !parsedURL.hostname) { - throw new TypeError('Only absolute URLs are supported'); - } + return usm.serializeInteger(this._url.port); + } - if (!/^https?:$/.test(parsedURL.protocol)) { - throw new TypeError('Only HTTP(S) protocols are supported'); - } + set port(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } - if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) { - throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); - } + if (v === "") { + this._url.port = null; + } else { + usm.basicURLParse(v, { url: this._url, stateOverride: "port" }); + } + } - // HTTP-network-or-cache fetch steps 2.4-2.7 - let contentLengthValue = null; - if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { - contentLengthValue = '0'; - } - if (request.body != null) { - const totalBytes = getTotalBytes(request); - if (typeof totalBytes === 'number') { - contentLengthValue = String(totalBytes); - } - } - if (contentLengthValue) { - headers.set('Content-Length', contentLengthValue); - } + get pathname() { + if (this._url.cannotBeABaseURL) { + return this._url.path[0]; + } - // HTTP-network-or-cache fetch step 2.11 - if (!headers.has('User-Agent')) { - headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); - } + if (this._url.path.length === 0) { + return ""; + } - // HTTP-network-or-cache fetch step 2.15 - if (request.compress && !headers.has('Accept-Encoding')) { - headers.set('Accept-Encoding', 'gzip,deflate'); - } + return "/" + this._url.path.join("/"); + } - let agent = request.agent; - if (typeof agent === 'function') { - agent = agent(parsedURL); - } + set pathname(v) { + if (this._url.cannotBeABaseURL) { + return; + } - if (!headers.has('Connection') && !agent) { - headers.set('Connection', 'close'); - } + this._url.path = []; + usm.basicURLParse(v, { url: this._url, stateOverride: "path start" }); + } - // HTTP-network fetch step 4.2 - // chunked encoding is handled by Node.js + get search() { + if (this._url.query === null || this._url.query === "") { + return ""; + } - return Object.assign({}, parsedURL, { - method: request.method, - headers: exportNodeCompatibleHeaders(headers), - agent - }); -} + return "?" + this._url.query; + } -/** - * abort-error.js - * - * AbortError interface for cancelled requests - */ + set search(v) { + // TODO: query stuff -/** - * Create AbortError instance - * - * @param String message Error message for human - * @return AbortError - */ -function AbortError(message) { - Error.call(this, message); + const url = this._url; - this.type = 'aborted'; - this.message = message; + if (v === "") { + url.query = null; + return; + } - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); -} + const input = v[0] === "?" ? v.substring(1) : v; + url.query = ""; + usm.basicURLParse(input, { url, stateOverride: "query" }); + } -AbortError.prototype = Object.create(Error.prototype); -AbortError.prototype.constructor = AbortError; -AbortError.prototype.name = 'AbortError'; + get hash() { + if (this._url.fragment === null || this._url.fragment === "") { + return ""; + } -const URL$1 = Url.URL || whatwgUrl.URL; + return "#" + this._url.fragment; + } -// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 -const PassThrough$1 = Stream.PassThrough; + set hash(v) { + if (v === "") { + this._url.fragment = null; + return; + } -const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) { - const orig = new URL$1(original).hostname; - const dest = new URL$1(destination).hostname; + const input = v[0] === "#" ? v.substring(1) : v; + this._url.fragment = ""; + usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" }); + } - return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest); + toJSON() { + return this.href; + } }; -/** - * Fetch function - * - * @param Mixed url Absolute url or Request instance - * @param Object opts Fetch options - * @return Promise - */ -function fetch(url, opts) { - - // allow custom promise - if (!fetch.Promise) { - throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); - } - - Body.Promise = fetch.Promise; - // wrap http.request into fetch - return new fetch.Promise(function (resolve, reject) { - // build request object - const request = new Request(url, opts); - const options = getNodeRequestOptions(request); +/***/ }), - const send = (options.protocol === 'https:' ? https : http).request; - const signal = request.signal; +/***/ 653: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - let response = null; +"use strict"; - const abort = function abort() { - let error = new AbortError('The user aborted a request.'); - reject(error); - if (request.body && request.body instanceof Stream.Readable) { - request.body.destroy(error); - } - if (!response || !response.body) return; - response.body.emit('error', error); - }; - if (signal && signal.aborted) { - abort(); - return; - } +const conversions = __nccwpck_require__(5871); +const utils = __nccwpck_require__(276); +const Impl = __nccwpck_require__(8262); - const abortAndFinalize = function abortAndFinalize() { - abort(); - finalize(); - }; +const impl = utils.implSymbol; - // send request - const req = send(options); - let reqTimeout; +function URL(url) { + if (!this || this[impl] || !(this instanceof URL)) { + throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function."); + } + if (arguments.length < 1) { + throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present."); + } + const args = []; + for (let i = 0; i < arguments.length && i < 2; ++i) { + args[i] = arguments[i]; + } + args[0] = conversions["USVString"](args[0]); + if (args[1] !== undefined) { + args[1] = conversions["USVString"](args[1]); + } - if (signal) { - signal.addEventListener('abort', abortAndFinalize); - } + module.exports.setup(this, args); +} - function finalize() { - req.abort(); - if (signal) signal.removeEventListener('abort', abortAndFinalize); - clearTimeout(reqTimeout); - } - - if (request.timeout) { - req.once('socket', function (socket) { - reqTimeout = setTimeout(function () { - reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); - finalize(); - }, request.timeout); - }); - } +URL.prototype.toJSON = function toJSON() { + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); + } + const args = []; + for (let i = 0; i < arguments.length && i < 0; ++i) { + args[i] = arguments[i]; + } + return this[impl].toJSON.apply(this[impl], args); +}; +Object.defineProperty(URL.prototype, "href", { + get() { + return this[impl].href; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].href = V; + }, + enumerable: true, + configurable: true +}); - req.on('error', function (err) { - reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); - finalize(); - }); +URL.prototype.toString = function () { + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); + } + return this.href; +}; - req.on('response', function (res) { - clearTimeout(reqTimeout); +Object.defineProperty(URL.prototype, "origin", { + get() { + return this[impl].origin; + }, + enumerable: true, + configurable: true +}); - const headers = createHeadersLenient(res.headers); +Object.defineProperty(URL.prototype, "protocol", { + get() { + return this[impl].protocol; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].protocol = V; + }, + enumerable: true, + configurable: true +}); - // HTTP fetch step 5 - if (fetch.isRedirect(res.statusCode)) { - // HTTP fetch step 5.2 - const location = headers.get('Location'); +Object.defineProperty(URL.prototype, "username", { + get() { + return this[impl].username; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].username = V; + }, + enumerable: true, + configurable: true +}); - // HTTP fetch step 5.3 - let locationURL = null; - try { - locationURL = location === null ? null : new URL$1(location, request.url).toString(); - } catch (err) { - // error here can only be invalid URL in Location: header - // do not throw when options.redirect == manual - // let the user extract the errorneous redirect URL - if (request.redirect !== 'manual') { - reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect')); - finalize(); - return; - } - } +Object.defineProperty(URL.prototype, "password", { + get() { + return this[impl].password; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].password = V; + }, + enumerable: true, + configurable: true +}); - // HTTP fetch step 5.5 - switch (request.redirect) { - case 'error': - reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); - finalize(); - return; - case 'manual': - // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. - if (locationURL !== null) { - // handle corrupted header - try { - headers.set('Location', locationURL); - } catch (err) { - // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request - reject(err); - } - } - break; - case 'follow': - // HTTP-redirect fetch step 2 - if (locationURL === null) { - break; - } +Object.defineProperty(URL.prototype, "host", { + get() { + return this[impl].host; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].host = V; + }, + enumerable: true, + configurable: true +}); - // HTTP-redirect fetch step 5 - if (request.counter >= request.follow) { - reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); - finalize(); - return; - } +Object.defineProperty(URL.prototype, "hostname", { + get() { + return this[impl].hostname; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].hostname = V; + }, + enumerable: true, + configurable: true +}); - // HTTP-redirect fetch step 6 (counter increment) - // Create a new Request object. - const requestOpts = { - headers: new Headers(request.headers), - follow: request.follow, - counter: request.counter + 1, - agent: request.agent, - compress: request.compress, - method: request.method, - body: request.body, - signal: request.signal, - timeout: request.timeout, - size: request.size - }; +Object.defineProperty(URL.prototype, "port", { + get() { + return this[impl].port; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].port = V; + }, + enumerable: true, + configurable: true +}); - if (!isDomainOrSubdomain(request.url, locationURL)) { - for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) { - requestOpts.headers.delete(name); - } - } +Object.defineProperty(URL.prototype, "pathname", { + get() { + return this[impl].pathname; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].pathname = V; + }, + enumerable: true, + configurable: true +}); - // HTTP-redirect fetch step 9 - if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { - reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); - finalize(); - return; - } +Object.defineProperty(URL.prototype, "search", { + get() { + return this[impl].search; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].search = V; + }, + enumerable: true, + configurable: true +}); - // HTTP-redirect fetch step 11 - if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { - requestOpts.method = 'GET'; - requestOpts.body = undefined; - requestOpts.headers.delete('content-length'); - } +Object.defineProperty(URL.prototype, "hash", { + get() { + return this[impl].hash; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].hash = V; + }, + enumerable: true, + configurable: true +}); - // HTTP-redirect fetch step 15 - resolve(fetch(new Request(locationURL, requestOpts))); - finalize(); - return; - } - } - // prepare response - res.once('end', function () { - if (signal) signal.removeEventListener('abort', abortAndFinalize); - }); - let body = res.pipe(new PassThrough$1()); +module.exports = { + is(obj) { + return !!obj && obj[impl] instanceof Impl.implementation; + }, + create(constructorArgs, privateData) { + let obj = Object.create(URL.prototype); + this.setup(obj, constructorArgs, privateData); + return obj; + }, + setup(obj, constructorArgs, privateData) { + if (!privateData) privateData = {}; + privateData.wrapper = obj; - const response_options = { - url: request.url, - status: res.statusCode, - statusText: res.statusMessage, - headers: headers, - size: request.size, - timeout: request.timeout, - counter: request.counter - }; - - // HTTP-network fetch step 12.1.1.3 - const codings = headers.get('Content-Encoding'); - - // HTTP-network fetch step 12.1.1.4: handle content codings - - // in following scenarios we ignore compression support - // 1. compression support is disabled - // 2. HEAD request - // 3. no Content-Encoding header - // 4. no content response (204) - // 5. content not modified response (304) - if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { - response = new Response(body, response_options); - resolve(response); - return; - } - - // For Node v6+ - // Be less strict when decoding compressed responses, since sometimes - // servers send slightly invalid responses that are still accepted - // by common browsers. - // Always using Z_SYNC_FLUSH is what cURL does. - const zlibOptions = { - flush: zlib.Z_SYNC_FLUSH, - finishFlush: zlib.Z_SYNC_FLUSH - }; - - // for gzip - if (codings == 'gzip' || codings == 'x-gzip') { - body = body.pipe(zlib.createGunzip(zlibOptions)); - response = new Response(body, response_options); - resolve(response); - return; - } - - // for deflate - if (codings == 'deflate' || codings == 'x-deflate') { - // handle the infamous raw deflate response from old servers - // a hack for old IIS and Apache servers - const raw = res.pipe(new PassThrough$1()); - raw.once('data', function (chunk) { - // see http://stackoverflow.com/questions/37519828 - if ((chunk[0] & 0x0F) === 0x08) { - body = body.pipe(zlib.createInflate()); - } else { - body = body.pipe(zlib.createInflateRaw()); - } - response = new Response(body, response_options); - resolve(response); - }); - return; - } - - // for br - if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') { - body = body.pipe(zlib.createBrotliDecompress()); - response = new Response(body, response_options); - resolve(response); - return; - } - - // otherwise, use response as-is - response = new Response(body, response_options); - resolve(response); - }); - - writeToStream(req, request); - }); -} -/** - * Redirect code matching - * - * @param Number code Status code - * @return Boolean - */ -fetch.isRedirect = function (code) { - return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; + obj[impl] = new Impl.implementation(constructorArgs, privateData); + obj[impl][utils.wrapperSymbol] = obj; + }, + interface: URL, + expose: { + Window: { URL: URL }, + Worker: { URL: URL } + } }; -// expose Promise -fetch.Promise = global.Promise; - -module.exports = exports = fetch; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports["default"] = exports; -exports.Headers = Headers; -exports.Request = Request; -exports.Response = Response; -exports.FetchError = FetchError; /***/ }), -/***/ 2299: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 3323: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -var punycode = __nccwpck_require__(5477); -var mappingTable = __nccwpck_require__(1907); - -var PROCESSING_OPTIONS = { - TRANSITIONAL: 0, - NONTRANSITIONAL: 1 -}; - -function normalize(str) { // fix bug in v8 - return str.split('\u0000').map(function (s) { return s.normalize('NFC'); }).join('\u0000'); -} - -function findStatus(val) { - var start = 0; - var end = mappingTable.length - 1; - - while (start <= end) { - var mid = Math.floor((start + end) / 2); - - var target = mappingTable[mid]; - if (target[0][0] <= val && target[0][1] >= val) { - return target; - } else if (target[0][0] > val) { - end = mid - 1; - } else { - start = mid + 1; - } - } - - return null; -} - -var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - -function countSymbols(string) { - return string - // replace every surrogate pair with a BMP symbol - .replace(regexAstralSymbols, '_') - // then get the length - .length; -} - -function mapChars(domain_name, useSTD3, processing_option) { - var hasError = false; - var processed = ""; - - var len = countSymbols(domain_name); - for (var i = 0; i < len; ++i) { - var codePoint = domain_name.codePointAt(i); - var status = findStatus(codePoint); - - switch (status[1]) { - case "disallowed": - hasError = true; - processed += String.fromCodePoint(codePoint); - break; - case "ignored": - break; - case "mapped": - processed += String.fromCodePoint.apply(String, status[2]); - break; - case "deviation": - if (processing_option === PROCESSING_OPTIONS.TRANSITIONAL) { - processed += String.fromCodePoint.apply(String, status[2]); - } else { - processed += String.fromCodePoint(codePoint); - } - break; - case "valid": - processed += String.fromCodePoint(codePoint); - break; - case "disallowed_STD3_mapped": - if (useSTD3) { - hasError = true; - processed += String.fromCodePoint(codePoint); - } else { - processed += String.fromCodePoint.apply(String, status[2]); - } - break; - case "disallowed_STD3_valid": - if (useSTD3) { - hasError = true; - } - - processed += String.fromCodePoint(codePoint); - break; - } - } - - return { - string: processed, - error: hasError - }; -} - -var combiningMarksRegex = /[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFC-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2D]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC7F-\uDC82\uDCB0-\uDCBA\uDD00-\uDD02\uDD27-\uDD34\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDE2C-\uDE37\uDEDF-\uDEEA\uDF01-\uDF03\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDE30-\uDE40\uDEAB-\uDEB7]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF51-\uDF7E\uDF8F-\uDF92]|\uD82F[\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD83A[\uDCD0-\uDCD6]|\uDB40[\uDD00-\uDDEF]/; - -function validateLabel(label, processing_option) { - if (label.substr(0, 4) === "xn--") { - label = punycode.toUnicode(label); - processing_option = PROCESSING_OPTIONS.NONTRANSITIONAL; - } - - var error = false; - - if (normalize(label) !== label || - (label[3] === "-" && label[4] === "-") || - label[0] === "-" || label[label.length - 1] === "-" || - label.indexOf(".") !== -1 || - label.search(combiningMarksRegex) === 0) { - error = true; - } +exports.URL = __nccwpck_require__(653)["interface"]; +exports.serializeURL = __nccwpck_require__(33).serializeURL; +exports.serializeURLOrigin = __nccwpck_require__(33).serializeURLOrigin; +exports.basicURLParse = __nccwpck_require__(33).basicURLParse; +exports.setTheUsername = __nccwpck_require__(33).setTheUsername; +exports.setThePassword = __nccwpck_require__(33).setThePassword; +exports.serializeHost = __nccwpck_require__(33).serializeHost; +exports.serializeInteger = __nccwpck_require__(33).serializeInteger; +exports.parseURL = __nccwpck_require__(33).parseURL; - var len = countSymbols(label); - for (var i = 0; i < len; ++i) { - var status = findStatus(label.codePointAt(i)); - if ((processing === PROCESSING_OPTIONS.TRANSITIONAL && status[1] !== "valid") || - (processing === PROCESSING_OPTIONS.NONTRANSITIONAL && - status[1] !== "valid" && status[1] !== "deviation")) { - error = true; - break; - } - } - return { - label: label, - error: error - }; -} +/***/ }), -function processing(domain_name, useSTD3, processing_option) { - var result = mapChars(domain_name, useSTD3, processing_option); - result.string = normalize(result.string); - - var labels = result.string.split("."); - for (var i = 0; i < labels.length; ++i) { - try { - var validation = validateLabel(labels[i]); - labels[i] = validation.label; - result.error = result.error || validation.error; - } catch(e) { - result.error = true; - } - } - - return { - string: labels.join("."), - error: result.error - }; -} - -module.exports.toASCII = function(domain_name, useSTD3, processing_option, verifyDnsLength) { - var result = processing(domain_name, useSTD3, processing_option); - var labels = result.string.split("."); - labels = labels.map(function(l) { - try { - return punycode.toASCII(l); - } catch(e) { - result.error = true; - return l; - } - }); - - if (verifyDnsLength) { - var total = labels.slice(0, labels.length - 1).join(".").length; - if (total.length > 253 || total.length === 0) { - result.error = true; - } - - for (var i=0; i < labels.length; ++i) { - if (labels.length > 63 || labels.length === 0) { - result.error = true; - break; - } - } - } - - if (result.error) return null; - return labels.join("."); -}; - -module.exports.toUnicode = function(domain_name, useSTD3) { - var result = processing(domain_name, useSTD3, PROCESSING_OPTIONS.NONTRANSITIONAL); - - return { - domain: result.string, - error: result.error - }; -}; - -module.exports.PROCESSING_OPTIONS = PROCESSING_OPTIONS; - - -/***/ }), - -/***/ 5871: -/***/ ((module) => { - -"use strict"; - - -var conversions = {}; -module.exports = conversions; - -function sign(x) { - return x < 0 ? -1 : 1; -} - -function evenRound(x) { - // Round x to the nearest integer, choosing the even integer if it lies halfway between two. - if ((x % 1) === 0.5 && (x & 1) === 0) { // [even number].5; round down (i.e. floor) - return Math.floor(x); - } else { - return Math.round(x); - } -} - -function createNumberConversion(bitLength, typeOpts) { - if (!typeOpts.unsigned) { - --bitLength; - } - const lowerBound = typeOpts.unsigned ? 0 : -Math.pow(2, bitLength); - const upperBound = Math.pow(2, bitLength) - 1; - - const moduloVal = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength) : Math.pow(2, bitLength); - const moduloBound = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength - 1) : Math.pow(2, bitLength - 1); - - return function(V, opts) { - if (!opts) opts = {}; - - let x = +V; - - if (opts.enforceRange) { - if (!Number.isFinite(x)) { - throw new TypeError("Argument is not a finite number"); - } - - x = sign(x) * Math.floor(Math.abs(x)); - if (x < lowerBound || x > upperBound) { - throw new TypeError("Argument is not in byte range"); - } - - return x; - } - - if (!isNaN(x) && opts.clamp) { - x = evenRound(x); - - if (x < lowerBound) x = lowerBound; - if (x > upperBound) x = upperBound; - return x; - } - - if (!Number.isFinite(x) || x === 0) { - return 0; - } - - x = sign(x) * Math.floor(Math.abs(x)); - x = x % moduloVal; - - if (!typeOpts.unsigned && x >= moduloBound) { - return x - moduloVal; - } else if (typeOpts.unsigned) { - if (x < 0) { - x += moduloVal; - } else if (x === -0) { // don't return negative zero - return 0; - } - } - - return x; - } -} - -conversions["void"] = function () { - return undefined; -}; - -conversions["boolean"] = function (val) { - return !!val; -}; - -conversions["byte"] = createNumberConversion(8, { unsigned: false }); -conversions["octet"] = createNumberConversion(8, { unsigned: true }); - -conversions["short"] = createNumberConversion(16, { unsigned: false }); -conversions["unsigned short"] = createNumberConversion(16, { unsigned: true }); - -conversions["long"] = createNumberConversion(32, { unsigned: false }); -conversions["unsigned long"] = createNumberConversion(32, { unsigned: true }); - -conversions["long long"] = createNumberConversion(32, { unsigned: false, moduloBitLength: 64 }); -conversions["unsigned long long"] = createNumberConversion(32, { unsigned: true, moduloBitLength: 64 }); - -conversions["double"] = function (V) { - const x = +V; - - if (!Number.isFinite(x)) { - throw new TypeError("Argument is not a finite floating-point value"); - } - - return x; -}; - -conversions["unrestricted double"] = function (V) { - const x = +V; - - if (isNaN(x)) { - throw new TypeError("Argument is NaN"); - } - - return x; -}; - -// not quite valid, but good enough for JS -conversions["float"] = conversions["double"]; -conversions["unrestricted float"] = conversions["unrestricted double"]; - -conversions["DOMString"] = function (V, opts) { - if (!opts) opts = {}; - - if (opts.treatNullAsEmptyString && V === null) { - return ""; - } - - return String(V); -}; - -conversions["ByteString"] = function (V, opts) { - const x = String(V); - let c = undefined; - for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) { - if (c > 255) { - throw new TypeError("Argument is not a valid bytestring"); - } - } - - return x; -}; - -conversions["USVString"] = function (V) { - const S = String(V); - const n = S.length; - const U = []; - for (let i = 0; i < n; ++i) { - const c = S.charCodeAt(i); - if (c < 0xD800 || c > 0xDFFF) { - U.push(String.fromCodePoint(c)); - } else if (0xDC00 <= c && c <= 0xDFFF) { - U.push(String.fromCodePoint(0xFFFD)); - } else { - if (i === n - 1) { - U.push(String.fromCodePoint(0xFFFD)); - } else { - const d = S.charCodeAt(i + 1); - if (0xDC00 <= d && d <= 0xDFFF) { - const a = c & 0x3FF; - const b = d & 0x3FF; - U.push(String.fromCodePoint((2 << 15) + (2 << 9) * a + b)); - ++i; - } else { - U.push(String.fromCodePoint(0xFFFD)); - } - } - } - } - - return U.join(''); -}; - -conversions["Date"] = function (V, opts) { - if (!(V instanceof Date)) { - throw new TypeError("Argument is not a Date object"); - } - if (isNaN(V)) { - return undefined; - } - - return V; -}; - -conversions["RegExp"] = function (V, opts) { - if (!(V instanceof RegExp)) { - V = new RegExp(V); - } - - return V; -}; - - -/***/ }), - -/***/ 8262: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -const usm = __nccwpck_require__(33); - -exports.implementation = class URLImpl { - constructor(constructorArgs) { - const url = constructorArgs[0]; - const base = constructorArgs[1]; - - let parsedBase = null; - if (base !== undefined) { - parsedBase = usm.basicURLParse(base); - if (parsedBase === "failure") { - throw new TypeError("Invalid base URL"); - } - } - - const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase }); - if (parsedURL === "failure") { - throw new TypeError("Invalid URL"); - } - - this._url = parsedURL; - - // TODO: query stuff - } - - get href() { - return usm.serializeURL(this._url); - } - - set href(v) { - const parsedURL = usm.basicURLParse(v); - if (parsedURL === "failure") { - throw new TypeError("Invalid URL"); - } - - this._url = parsedURL; - } - - get origin() { - return usm.serializeURLOrigin(this._url); - } - - get protocol() { - return this._url.scheme + ":"; - } - - set protocol(v) { - usm.basicURLParse(v + ":", { url: this._url, stateOverride: "scheme start" }); - } - - get username() { - return this._url.username; - } - - set username(v) { - if (usm.cannotHaveAUsernamePasswordPort(this._url)) { - return; - } - - usm.setTheUsername(this._url, v); - } - - get password() { - return this._url.password; - } - - set password(v) { - if (usm.cannotHaveAUsernamePasswordPort(this._url)) { - return; - } - - usm.setThePassword(this._url, v); - } - - get host() { - const url = this._url; - - if (url.host === null) { - return ""; - } - - if (url.port === null) { - return usm.serializeHost(url.host); - } - - return usm.serializeHost(url.host) + ":" + usm.serializeInteger(url.port); - } - - set host(v) { - if (this._url.cannotBeABaseURL) { - return; - } - - usm.basicURLParse(v, { url: this._url, stateOverride: "host" }); - } - - get hostname() { - if (this._url.host === null) { - return ""; - } - - return usm.serializeHost(this._url.host); - } - - set hostname(v) { - if (this._url.cannotBeABaseURL) { - return; - } - - usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" }); - } - - get port() { - if (this._url.port === null) { - return ""; - } - - return usm.serializeInteger(this._url.port); - } - - set port(v) { - if (usm.cannotHaveAUsernamePasswordPort(this._url)) { - return; - } - - if (v === "") { - this._url.port = null; - } else { - usm.basicURLParse(v, { url: this._url, stateOverride: "port" }); - } - } - - get pathname() { - if (this._url.cannotBeABaseURL) { - return this._url.path[0]; - } - - if (this._url.path.length === 0) { - return ""; - } - - return "/" + this._url.path.join("/"); - } - - set pathname(v) { - if (this._url.cannotBeABaseURL) { - return; - } - - this._url.path = []; - usm.basicURLParse(v, { url: this._url, stateOverride: "path start" }); - } - - get search() { - if (this._url.query === null || this._url.query === "") { - return ""; - } - - return "?" + this._url.query; - } - - set search(v) { - // TODO: query stuff - - const url = this._url; - - if (v === "") { - url.query = null; - return; - } - - const input = v[0] === "?" ? v.substring(1) : v; - url.query = ""; - usm.basicURLParse(input, { url, stateOverride: "query" }); - } - - get hash() { - if (this._url.fragment === null || this._url.fragment === "") { - return ""; - } - - return "#" + this._url.fragment; - } - - set hash(v) { - if (v === "") { - this._url.fragment = null; - return; - } - - const input = v[0] === "#" ? v.substring(1) : v; - this._url.fragment = ""; - usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" }); - } - - toJSON() { - return this.href; - } -}; - - -/***/ }), - -/***/ 653: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -const conversions = __nccwpck_require__(5871); -const utils = __nccwpck_require__(276); -const Impl = __nccwpck_require__(8262); - -const impl = utils.implSymbol; - -function URL(url) { - if (!this || this[impl] || !(this instanceof URL)) { - throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function."); - } - if (arguments.length < 1) { - throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present."); - } - const args = []; - for (let i = 0; i < arguments.length && i < 2; ++i) { - args[i] = arguments[i]; - } - args[0] = conversions["USVString"](args[0]); - if (args[1] !== undefined) { - args[1] = conversions["USVString"](args[1]); - } - - module.exports.setup(this, args); -} - -URL.prototype.toJSON = function toJSON() { - if (!this || !module.exports.is(this)) { - throw new TypeError("Illegal invocation"); - } - const args = []; - for (let i = 0; i < arguments.length && i < 0; ++i) { - args[i] = arguments[i]; - } - return this[impl].toJSON.apply(this[impl], args); -}; -Object.defineProperty(URL.prototype, "href", { - get() { - return this[impl].href; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].href = V; - }, - enumerable: true, - configurable: true -}); - -URL.prototype.toString = function () { - if (!this || !module.exports.is(this)) { - throw new TypeError("Illegal invocation"); - } - return this.href; -}; - -Object.defineProperty(URL.prototype, "origin", { - get() { - return this[impl].origin; - }, - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, "protocol", { - get() { - return this[impl].protocol; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].protocol = V; - }, - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, "username", { - get() { - return this[impl].username; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].username = V; - }, - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, "password", { - get() { - return this[impl].password; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].password = V; - }, - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, "host", { - get() { - return this[impl].host; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].host = V; - }, - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, "hostname", { - get() { - return this[impl].hostname; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].hostname = V; - }, - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, "port", { - get() { - return this[impl].port; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].port = V; - }, - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, "pathname", { - get() { - return this[impl].pathname; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].pathname = V; - }, - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, "search", { - get() { - return this[impl].search; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].search = V; - }, - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, "hash", { - get() { - return this[impl].hash; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].hash = V; - }, - enumerable: true, - configurable: true -}); - - -module.exports = { - is(obj) { - return !!obj && obj[impl] instanceof Impl.implementation; - }, - create(constructorArgs, privateData) { - let obj = Object.create(URL.prototype); - this.setup(obj, constructorArgs, privateData); - return obj; - }, - setup(obj, constructorArgs, privateData) { - if (!privateData) privateData = {}; - privateData.wrapper = obj; - - obj[impl] = new Impl.implementation(constructorArgs, privateData); - obj[impl][utils.wrapperSymbol] = obj; - }, - interface: URL, - expose: { - Window: { URL: URL }, - Worker: { URL: URL } - } -}; - - - -/***/ }), - -/***/ 3323: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -exports.URL = __nccwpck_require__(653)["interface"]; -exports.serializeURL = __nccwpck_require__(33).serializeURL; -exports.serializeURLOrigin = __nccwpck_require__(33).serializeURLOrigin; -exports.basicURLParse = __nccwpck_require__(33).basicURLParse; -exports.setTheUsername = __nccwpck_require__(33).setTheUsername; -exports.setThePassword = __nccwpck_require__(33).setThePassword; -exports.serializeHost = __nccwpck_require__(33).serializeHost; -exports.serializeInteger = __nccwpck_require__(33).serializeInteger; -exports.parseURL = __nccwpck_require__(33).parseURL; - - -/***/ }), - -/***/ 33: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 33: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; @@ -13107,390 +10352,961 @@ module.exports.parseURL = function (input, options) { /***/ }), -/***/ 276: -/***/ ((module) => { +/***/ 276: +/***/ ((module) => { + +"use strict"; + + +module.exports.mixin = function mixin(target, source) { + const keys = Object.getOwnPropertyNames(source); + for (let i = 0; i < keys.length; ++i) { + Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i])); + } +}; + +module.exports.wrapperSymbol = Symbol("wrapper"); +module.exports.implSymbol = Symbol("impl"); + +module.exports.wrapperForImpl = function (impl) { + return impl[module.exports.wrapperSymbol]; +}; + +module.exports.implForWrapper = function (wrapper) { + return wrapper[module.exports.implSymbol]; +}; + + + +/***/ }), + +/***/ 1223: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var wrappy = __nccwpck_require__(2940) +module.exports = wrappy(once) +module.exports.strict = wrappy(onceStrict) + +once.proto = once(function () { + Object.defineProperty(Function.prototype, 'once', { + value: function () { + return once(this) + }, + configurable: true + }) + + Object.defineProperty(Function.prototype, 'onceStrict', { + value: function () { + return onceStrict(this) + }, + configurable: true + }) +}) + +function once (fn) { + var f = function () { + if (f.called) return f.value + f.called = true + return f.value = fn.apply(this, arguments) + } + f.called = false + return f +} + +function onceStrict (fn) { + var f = function () { + if (f.called) + throw new Error(f.onceError) + f.called = true + return f.value = fn.apply(this, arguments) + } + var name = fn.name || 'Function wrapped with `once`' + f.onceError = name + " shouldn't be called more than once" + f.called = false + return f +} + + +/***/ }), + +/***/ 4294: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +module.exports = __nccwpck_require__(4219); + + +/***/ }), + +/***/ 4219: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +var net = __nccwpck_require__(1808); +var tls = __nccwpck_require__(4404); +var http = __nccwpck_require__(3685); +var https = __nccwpck_require__(5687); +var events = __nccwpck_require__(2361); +var assert = __nccwpck_require__(9491); +var util = __nccwpck_require__(3837); + + +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; + + +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; +} + +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} + +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; +} + +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} + + +function TunnelingAgent(options) { + var self = this; + self.options = options || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; + + self.on('free', function onFree(socket, host, port, localAddress) { + var options = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options.host && pending.port === options.port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } + } + socket.destroy(); + self.removeSocket(socket); + }); +} +util.inherits(TunnelingAgent, events.EventEmitter); + +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); + + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; + } + + // If we are under maxSockets create a new one. + self.createSocket(options, function(socket) { + socket.on('free', onFree); + socket.on('close', onCloseOrRemove); + socket.on('agentRemove', onCloseOrRemove); + req.onSocket(socket); + + function onFree() { + self.emit('free', socket, options); + } + + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; + +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); + + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: 'CONNECT', + path: options.host + ':' + options.port, + agent: false, + headers: { + host: options.host + ':' + options.port + } + }); + if (options.localAddress) { + connectOptions.localAddress = options.localAddress; + } + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64'); + } + + debug('making CONNECT request'); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; // for v0.6 + connectReq.once('response', onResponse); // for v0.6 + connectReq.once('upgrade', onUpgrade); // for v0.6 + connectReq.once('connect', onConnect); // for v0.7 or later + connectReq.once('error', onError); + connectReq.end(); + + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } + + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); + } + + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); + + if (res.statusCode !== 200) { + debug('tunneling socket could not be established, statusCode=%d', + res.statusCode); + socket.destroy(); + var error = new Error('tunneling socket could not be established, ' + + 'statusCode=' + res.statusCode); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + if (head.length > 0) { + debug('got illegal response body from proxy'); + socket.destroy(); + var error = new Error('got illegal response body from proxy'); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + debug('tunneling connection has established'); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + return cb(socket); + } + + function onError(cause) { + connectReq.removeAllListeners(); + + debug('tunneling socket could not be established, cause=%s\n', + cause.message, cause.stack); + var error = new Error('tunneling socket could not be established, ' + + 'cause=' + cause.message); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + } +}; + +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; + } + this.sockets.splice(pos, 1); + + var pending = this.requests.shift(); + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket); + }); + } +}; + +function createSecureSocket(options, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + var hostHeader = options.request.getHeader('host'); + var tlsOptions = mergeOptions({}, self.options, { + socket: socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host + }); + + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); +} + + +function toOptions(host, port, localAddress) { + if (typeof host === 'string') { // since v0.10 + return { + host: host, + port: port, + localAddress: localAddress + }; + } + return host; // for v0.11 or later +} + +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === 'object') { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== undefined) { + target[k] = overrides[k]; + } + } + } + } + return target; +} + + +var debug; +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0]; + } else { + args.unshift('TUNNEL:'); + } + console.error.apply(console, args); + } +} else { + debug = function() {}; +} +exports.debug = debug; // for test + + +/***/ }), + +/***/ 5030: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +function getUserAgent() { + if (typeof navigator === "object" && "userAgent" in navigator) { + return navigator.userAgent; + } + + if (typeof process === "object" && "version" in process) { + return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`; + } + + return ""; +} + +exports.getUserAgent = getUserAgent; +//# sourceMappingURL=index.js.map + + +/***/ }), + +/***/ 5840: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +Object.defineProperty(exports, "v1", ({ + enumerable: true, + get: function () { + return _v.default; + } +})); +Object.defineProperty(exports, "v3", ({ + enumerable: true, + get: function () { + return _v2.default; + } +})); +Object.defineProperty(exports, "v4", ({ + enumerable: true, + get: function () { + return _v3.default; + } +})); +Object.defineProperty(exports, "v5", ({ + enumerable: true, + get: function () { + return _v4.default; + } +})); +Object.defineProperty(exports, "NIL", ({ + enumerable: true, + get: function () { + return _nil.default; + } +})); +Object.defineProperty(exports, "version", ({ + enumerable: true, + get: function () { + return _version.default; + } +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _validate.default; + } +})); +Object.defineProperty(exports, "stringify", ({ + enumerable: true, + get: function () { + return _stringify.default; + } +})); +Object.defineProperty(exports, "parse", ({ + enumerable: true, + get: function () { + return _parse.default; + } +})); + +var _v = _interopRequireDefault(__nccwpck_require__(8628)); + +var _v2 = _interopRequireDefault(__nccwpck_require__(6409)); + +var _v3 = _interopRequireDefault(__nccwpck_require__(5122)); + +var _v4 = _interopRequireDefault(__nccwpck_require__(9120)); + +var _nil = _interopRequireDefault(__nccwpck_require__(5332)); + +var _version = _interopRequireDefault(__nccwpck_require__(1595)); + +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); + +var _parse = _interopRequireDefault(__nccwpck_require__(2746)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/***/ }), + +/***/ 4569: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('md5').update(bytes).digest(); +} + +var _default = md5; +exports["default"] = _default; + +/***/ }), + +/***/ 5332: +/***/ ((__unused_webpack_module, exports) => { "use strict"; -module.exports.mixin = function mixin(target, source) { - const keys = Object.getOwnPropertyNames(source); - for (let i = 0; i < keys.length; ++i) { - Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i])); +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = '00000000-0000-0000-0000-000000000000'; +exports["default"] = _default; + +/***/ }), + +/***/ 2746: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function parse(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); } -}; -module.exports.wrapperSymbol = Symbol("wrapper"); -module.exports.implSymbol = Symbol("impl"); + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ -module.exports.wrapperForImpl = function (impl) { - return impl[module.exports.wrapperSymbol]; -}; + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; // Parse ........-####-....-....-............ -module.exports.implForWrapper = function (wrapper) { - return wrapper[module.exports.implSymbol]; -}; + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ + + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; +} +var _default = parse; +exports["default"] = _default; /***/ }), -/***/ 1223: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 814: +/***/ ((__unused_webpack_module, exports) => { -var wrappy = __nccwpck_require__(2940) -module.exports = wrappy(once) -module.exports.strict = wrappy(onceStrict) +"use strict"; -once.proto = once(function () { - Object.defineProperty(Function.prototype, 'once', { - value: function () { - return once(this) - }, - configurable: true - }) - Object.defineProperty(Function.prototype, 'onceStrict', { - value: function () { - return onceStrict(this) - }, - configurable: true - }) -}) +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; +exports["default"] = _default; + +/***/ }), + +/***/ 807: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = rng; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate + +let poolPtr = rnds8Pool.length; + +function rng() { + if (poolPtr > rnds8Pool.length - 16) { + _crypto.default.randomFillSync(rnds8Pool); + + poolPtr = 0; + } + + return rnds8Pool.slice(poolPtr, poolPtr += 16); +} + +/***/ }), + +/***/ 5274: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function sha1(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('sha1').update(bytes).digest(); +} + +var _default = sha1; +exports["default"] = _default; + +/***/ }), + +/***/ 8950: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ +const byteToHex = []; + +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).substr(1)); +} + +function stringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one + // of the following: + // - One or more input array values don't map to a hex octet (leading to + // "undefined" in the uuid) + // - Invalid input values for the RFC `version` or `variant` fields + + if (!(0, _validate.default)(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } + + return uuid; +} + +var _default = stringify; +exports["default"] = _default; + +/***/ }), + +/***/ 8628: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(807)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html +let _nodeId; -function once (fn) { - var f = function () { - if (f.called) return f.value - f.called = true - return f.value = fn.apply(this, arguments) - } - f.called = false - return f -} +let _clockseq; // Previous uuid creation time -function onceStrict (fn) { - var f = function () { - if (f.called) - throw new Error(f.onceError) - f.called = true - return f.value = fn.apply(this, arguments) - } - var name = fn.name || 'Function wrapped with `once`' - f.onceError = name + " shouldn't be called more than once" - f.called = false - return f -} +let _lastMSecs = 0; +let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details -/***/ }), +function v1(options, buf, offset) { + let i = buf && offset || 0; + const b = buf || new Array(16); + options = options || {}; + let node = options.node || _nodeId; + let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not + // specified. We do this lazily to minimize issues related to insufficient + // system entropy. See #189 -/***/ 4294: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if (node == null || clockseq == null) { + const seedBytes = options.random || (options.rng || _rng.default)(); -module.exports = __nccwpck_require__(4219); + if (node == null) { + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; + } + if (clockseq == null) { + // Per 4.2.2, randomize (14 bit) clockseq + clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; + } + } // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. -/***/ }), -/***/ 4219: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock -"use strict"; + let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) + const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression -var net = __nccwpck_require__(1808); -var tls = __nccwpck_require__(4404); -var http = __nccwpck_require__(3685); -var https = __nccwpck_require__(5687); -var events = __nccwpck_require__(2361); -var assert = __nccwpck_require__(9491); -var util = __nccwpck_require__(3837); + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval -exports.httpOverHttp = httpOverHttp; -exports.httpsOverHttp = httpsOverHttp; -exports.httpOverHttps = httpOverHttps; -exports.httpsOverHttps = httpsOverHttps; + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } // Per 4.2.1.2 Throw error if too many uuids are requested -function httpOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - return agent; -} + if (nsecs >= 10000) { + throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); + } -function httpsOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch -function httpOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - return agent; -} + msecs += 12219292800000; // `time_low` -function httpsOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} + const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; // `time_mid` + const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; // `time_high_and_version` -function TunnelingAgent(options) { - var self = this; - self.options = options || {}; - self.proxyOptions = self.options.proxy || {}; - self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; - self.requests = []; - self.sockets = []; + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version - self.on('free', function onFree(socket, host, port, localAddress) { - var options = toOptions(host, port, localAddress); - for (var i = 0, len = self.requests.length; i < len; ++i) { - var pending = self.requests[i]; - if (pending.host === options.host && pending.port === options.port) { - // Detect the request to connect same origin server, - // reuse the connection. - self.requests.splice(i, 1); - pending.request.onSocket(socket); - return; - } - } - socket.destroy(); - self.removeSocket(socket); - }); -} -util.inherits(TunnelingAgent, events.EventEmitter); + b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) -TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { - var self = this; - var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); + b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` - if (self.sockets.length >= this.maxSockets) { - // We are over limit so we'll add it to the queue. - self.requests.push(options); - return; + b[i++] = clockseq & 0xff; // `node` + + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; } - // If we are under maxSockets create a new one. - self.createSocket(options, function(socket) { - socket.on('free', onFree); - socket.on('close', onCloseOrRemove); - socket.on('agentRemove', onCloseOrRemove); - req.onSocket(socket); + return buf || (0, _stringify.default)(b); +} - function onFree() { - self.emit('free', socket, options); - } +var _default = v1; +exports["default"] = _default; - function onCloseOrRemove(err) { - self.removeSocket(socket); - socket.removeListener('free', onFree); - socket.removeListener('close', onCloseOrRemove); - socket.removeListener('agentRemove', onCloseOrRemove); - } - }); -}; +/***/ }), -TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { - var self = this; - var placeholder = {}; - self.sockets.push(placeholder); +/***/ 6409: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - var connectOptions = mergeOptions({}, self.proxyOptions, { - method: 'CONNECT', - path: options.host + ':' + options.port, - agent: false, - headers: { - host: options.host + ':' + options.port - } - }); - if (options.localAddress) { - connectOptions.localAddress = options.localAddress; - } - if (connectOptions.proxyAuth) { - connectOptions.headers = connectOptions.headers || {}; - connectOptions.headers['Proxy-Authorization'] = 'Basic ' + - new Buffer(connectOptions.proxyAuth).toString('base64'); - } +"use strict"; - debug('making CONNECT request'); - var connectReq = self.request(connectOptions); - connectReq.useChunkedEncodingByDefault = false; // for v0.6 - connectReq.once('response', onResponse); // for v0.6 - connectReq.once('upgrade', onUpgrade); // for v0.6 - connectReq.once('connect', onConnect); // for v0.7 or later - connectReq.once('error', onError); - connectReq.end(); - function onResponse(res) { - // Very hacky. This is necessary to avoid http-parser leaks. - res.upgrade = true; - } +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - function onUpgrade(res, socket, head) { - // Hacky. - process.nextTick(function() { - onConnect(res, socket, head); - }); - } +var _v = _interopRequireDefault(__nccwpck_require__(5998)); - function onConnect(res, socket, head) { - connectReq.removeAllListeners(); - socket.removeAllListeners(); +var _md = _interopRequireDefault(__nccwpck_require__(4569)); - if (res.statusCode !== 200) { - debug('tunneling socket could not be established, statusCode=%d', - res.statusCode); - socket.destroy(); - var error = new Error('tunneling socket could not be established, ' + - 'statusCode=' + res.statusCode); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - if (head.length > 0) { - debug('got illegal response body from proxy'); - socket.destroy(); - var error = new Error('got illegal response body from proxy'); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - debug('tunneling connection has established'); - self.sockets[self.sockets.indexOf(placeholder)] = socket; - return cb(socket); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v3 = (0, _v.default)('v3', 0x30, _md.default); +var _default = v3; +exports["default"] = _default; + +/***/ }), - function onError(cause) { - connectReq.removeAllListeners(); +/***/ 5998: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - debug('tunneling socket could not be established, cause=%s\n', - cause.message, cause.stack); - var error = new Error('tunneling socket could not be established, ' + - 'cause=' + cause.message); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - } -}; +"use strict"; -TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { - var pos = this.sockets.indexOf(socket) - if (pos === -1) { - return; - } - this.sockets.splice(pos, 1); - var pending = this.requests.shift(); - if (pending) { - // If we have pending requests and a socket gets closed a new one - // needs to be created to take over in the pool for the one that closed. - this.createSocket(pending, function(socket) { - pending.request.onSocket(socket); - }); - } -}; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = _default; +exports.URL = exports.DNS = void 0; -function createSecureSocket(options, cb) { - var self = this; - TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { - var hostHeader = options.request.getHeader('host'); - var tlsOptions = mergeOptions({}, self.options, { - socket: socket, - servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host - }); +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); - // 0 is dummy port for v0.6 - var secureSocket = tls.connect(0, tlsOptions); - self.sockets[self.sockets.indexOf(socket)] = secureSocket; - cb(secureSocket); - }); -} +var _parse = _interopRequireDefault(__nccwpck_require__(2746)); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function toOptions(host, port, localAddress) { - if (typeof host === 'string') { // since v0.10 - return { - host: host, - port: port, - localAddress: localAddress - }; +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); } - return host; // for v0.11 or later + + return bytes; } -function mergeOptions(target) { - for (var i = 1, len = arguments.length; i < len; ++i) { - var overrides = arguments[i]; - if (typeof overrides === 'object') { - var keys = Object.keys(overrides); - for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { - var k = keys[j]; - if (overrides[k] !== undefined) { - target[k] = overrides[k]; - } - } +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +exports.DNS = DNS; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +exports.URL = URL; + +function _default(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + if (typeof value === 'string') { + value = stringToBytes(value); } - } - return target; -} + if (typeof namespace === 'string') { + namespace = (0, _parse.default)(namespace); + } -var debug; -if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { - debug = function() { - var args = Array.prototype.slice.call(arguments); - if (typeof args[0] === 'string') { - args[0] = 'TUNNEL: ' + args[0]; - } else { - args.unshift('TUNNEL:'); + if (namespace.length !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + + + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; } - console.error.apply(console, args); - } -} else { - debug = function() {}; -} -exports.debug = debug; // for test + return (0, _stringify.default)(bytes); + } // Function#name is not settable on some platforms (#270) + + + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support + + + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} /***/ }), -/***/ 5030: -/***/ ((__unused_webpack_module, exports) => { +/***/ 5122: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; -function getUserAgent() { - if (typeof navigator === "object" && "userAgent" in navigator) { - return navigator.userAgent; - } +var _rng = _interopRequireDefault(__nccwpck_require__(807)); - if (typeof process === "object" && "version" in process) { - return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`; +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function v4(options, buf, offset) { + options = options || {}; + + const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + + + rnds[6] = rnds[6] & 0x0f | 0x40; + rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = rnds[i]; + } + + return buf; } - return ""; + return (0, _stringify.default)(rnds); } -exports.getUserAgent = getUserAgent; -//# sourceMappingURL=index.js.map - +var _default = v4; +exports["default"] = _default; /***/ }), -/***/ 5840: +/***/ 9120: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -13499,84 +11315,45 @@ exports.getUserAgent = getUserAgent; Object.defineProperty(exports, "__esModule", ({ value: true })); -Object.defineProperty(exports, "v1", ({ - enumerable: true, - get: function () { - return _v.default; - } -})); -Object.defineProperty(exports, "v3", ({ - enumerable: true, - get: function () { - return _v2.default; - } -})); -Object.defineProperty(exports, "v4", ({ - enumerable: true, - get: function () { - return _v3.default; - } -})); -Object.defineProperty(exports, "v5", ({ - enumerable: true, - get: function () { - return _v4.default; - } -})); -Object.defineProperty(exports, "NIL", ({ - enumerable: true, - get: function () { - return _nil.default; - } -})); -Object.defineProperty(exports, "version", ({ - enumerable: true, - get: function () { - return _version.default; - } -})); -Object.defineProperty(exports, "validate", ({ - enumerable: true, - get: function () { - return _validate.default; - } -})); -Object.defineProperty(exports, "stringify", ({ - enumerable: true, - get: function () { - return _stringify.default; - } -})); -Object.defineProperty(exports, "parse", ({ - enumerable: true, - get: function () { - return _parse.default; - } -})); +exports["default"] = void 0; -var _v = _interopRequireDefault(__nccwpck_require__(8628)); +var _v = _interopRequireDefault(__nccwpck_require__(5998)); -var _v2 = _interopRequireDefault(__nccwpck_require__(6409)); +var _sha = _interopRequireDefault(__nccwpck_require__(5274)); -var _v3 = _interopRequireDefault(__nccwpck_require__(5122)); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var _v4 = _interopRequireDefault(__nccwpck_require__(9120)); +const v5 = (0, _v.default)('v5', 0x50, _sha.default); +var _default = v5; +exports["default"] = _default; + +/***/ }), -var _nil = _interopRequireDefault(__nccwpck_require__(5332)); +/***/ 6900: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -var _version = _interopRequireDefault(__nccwpck_require__(1595)); +"use strict"; -var _validate = _interopRequireDefault(__nccwpck_require__(6900)); -var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; -var _parse = _interopRequireDefault(__nccwpck_require__(2746)); +var _regex = _interopRequireDefault(__nccwpck_require__(814)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function validate(uuid) { + return typeof uuid === 'string' && _regex.default.test(uuid); +} + +var _default = validate; +exports["default"] = _default; + /***/ }), -/***/ 4569: +/***/ 1595: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -13587,1811 +11364,4733 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function md5(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === 'string') { - bytes = Buffer.from(bytes, 'utf8'); +function version(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); } - return _crypto.default.createHash('md5').update(bytes).digest(); + return parseInt(uuid.substr(14, 1), 16); } -var _default = md5; +var _default = version; exports["default"] = _default; /***/ }), -/***/ 5332: +/***/ 2940: +/***/ ((module) => { + +// Returns a wrapper function that returns a wrapped callback +// The wrapper function should do some stuff, and return a +// presumably different callback function. +// This makes sure that own properties are retained, so that +// decorations and such are not lost along the way. +module.exports = wrappy +function wrappy (fn, cb) { + if (fn && cb) return wrappy(fn)(cb) + + if (typeof fn !== 'function') + throw new TypeError('need wrapper function') + + Object.keys(fn).forEach(function (k) { + wrapper[k] = fn[k] + }) + + return wrapper + + function wrapper() { + var args = new Array(arguments.length) + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i] + } + var ret = fn.apply(this, args) + var cb = args[args.length-1] + if (typeof ret === 'function' && ret !== cb) { + Object.keys(cb).forEach(function (k) { + ret[k] = cb[k] + }) + } + return ret + } +} + + +/***/ }), + +/***/ 566: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const core = __importStar(__nccwpck_require__(2186)); +const format_1 = __nccwpck_require__(2464); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const CONST_1 = __importDefault(__nccwpck_require__(9873)); +const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); +const GitUtils_1 = __importDefault(__nccwpck_require__(1547)); +async function run() { + // Note: require('package.json').version does not work because ncc will resolve that to a plain string at compile time + const packageJson = JSON.parse(fs_1.default.readFileSync('package.json', 'utf8')); + const newVersionTag = packageJson.version; + try { + // Start by fetching the list of recent StagingDeployCash issues, along with the list of open deploy blockers + const { data: recentDeployChecklists } = await GithubUtils_1.default.octokit.issues.listForRepo({ + log: console, + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + labels: CONST_1.default.LABELS.STAGING_DEPLOY, + state: 'all', + }); + // Look at the state of the most recent StagingDeployCash, + // if it is open then we'll update the existing one, otherwise, we'll create a new one. + const mostRecentChecklist = recentDeployChecklists[0]; + const shouldCreateNewDeployChecklist = mostRecentChecklist.state !== 'open'; + const previousChecklist = shouldCreateNewDeployChecklist ? mostRecentChecklist : recentDeployChecklists[1]; + if (shouldCreateNewDeployChecklist) { + console.log('Latest StagingDeployCash is closed, creating a new one.', mostRecentChecklist); + } + else { + console.log('Latest StagingDeployCash is open, updating it instead of creating a new one.', 'Current:', mostRecentChecklist, 'Previous:', previousChecklist); + } + // Parse the data from the previous and current checklists into the format used to generate the checklist + const previousChecklistData = GithubUtils_1.default.getStagingDeployCashData(previousChecklist); + const currentChecklistData = shouldCreateNewDeployChecklist ? undefined : GithubUtils_1.default.getStagingDeployCashData(mostRecentChecklist); + // Find the list of PRs merged between the current checklist and the previous checklist + const mergedPRs = await GitUtils_1.default.getPullRequestsMergedBetween(previousChecklistData.tag ?? '', newVersionTag); + // Next, we generate the checklist body + let checklistBody = ''; + let checklistAssignees = []; + if (shouldCreateNewDeployChecklist) { + const stagingDeployCashBodyAndAssignees = await GithubUtils_1.default.generateStagingDeployCashBodyAndAssignees(newVersionTag, mergedPRs.map((value) => GithubUtils_1.default.getPullRequestURLFromNumber(value))); + if (stagingDeployCashBodyAndAssignees) { + checklistBody = stagingDeployCashBodyAndAssignees.issueBody; + checklistAssignees = stagingDeployCashBodyAndAssignees.issueAssignees.filter(Boolean); + } + } + else { + // Generate the updated PR list, preserving the previous state of `isVerified` for existing PRs + const PRList = mergedPRs.map((prNum) => { + const indexOfPRInCurrentChecklist = currentChecklistData?.PRList.findIndex((pr) => pr.number === prNum) ?? -1; + const isVerified = indexOfPRInCurrentChecklist >= 0 ? currentChecklistData?.PRList[indexOfPRInCurrentChecklist].isVerified : false; + return { + number: prNum, + url: GithubUtils_1.default.getPullRequestURLFromNumber(prNum), + isVerified, + }; + }); + // Generate the deploy blocker list, preserving the previous state of `isResolved` + const { data: openDeployBlockers } = await GithubUtils_1.default.octokit.issues.listForRepo({ + log: console, + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + labels: CONST_1.default.LABELS.DEPLOY_BLOCKER, + }); + // First, make sure we include all current deploy blockers + const deployBlockers = openDeployBlockers.map((deployBlocker) => { + const indexInCurrentChecklist = currentChecklistData?.deployBlockers.findIndex((item) => item.number === deployBlocker.number) ?? -1; + const isResolved = indexInCurrentChecklist >= 0 ? currentChecklistData?.deployBlockers[indexInCurrentChecklist].isResolved : false; + return { + number: deployBlocker.number, + url: deployBlocker.html_url, + isResolved, + }; + }); + // Then make sure we include any demoted or closed blockers as well, and just check them off automatically + currentChecklistData?.deployBlockers.forEach((deployBlocker) => { + const isResolved = deployBlockers.findIndex((openBlocker) => openBlocker.number === deployBlocker.number) < 0; + deployBlockers.push({ + ...deployBlocker, + isResolved, + }); + }); + const didVersionChange = newVersionTag !== currentChecklistData?.tag; + const stagingDeployCashBodyAndAssignees = await GithubUtils_1.default.generateStagingDeployCashBodyAndAssignees(newVersionTag, PRList.map((pr) => pr.url), PRList.filter((pr) => pr.isVerified).map((pr) => pr.url), deployBlockers.map((blocker) => blocker.url), deployBlockers.filter((blocker) => blocker.isResolved).map((blocker) => blocker.url), currentChecklistData?.internalQAPRList.filter((pr) => pr.isResolved).map((pr) => pr.url), didVersionChange ? false : currentChecklistData.isTimingDashboardChecked, didVersionChange ? false : currentChecklistData.isFirebaseChecked, didVersionChange ? false : currentChecklistData.isGHStatusChecked); + if (stagingDeployCashBodyAndAssignees) { + checklistBody = stagingDeployCashBodyAndAssignees.issueBody; + checklistAssignees = stagingDeployCashBodyAndAssignees.issueAssignees.filter(Boolean); + } + } + // Finally, create or update the checklist + const defaultPayload = { + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + body: checklistBody, + }; + if (shouldCreateNewDeployChecklist) { + const { data: newChecklist } = await GithubUtils_1.default.octokit.issues.create({ + ...defaultPayload, + title: `Deploy Checklist: New Expensify ${(0, format_1.format)(new Date(), CONST_1.default.DATE_FORMAT_STRING)}`, + labels: [CONST_1.default.LABELS.STAGING_DEPLOY], + assignees: [CONST_1.default.APPLAUSE_BOT].concat(checklistAssignees), + }); + console.log(`Successfully created new StagingDeployCash! 🎉 ${newChecklist.html_url}`); + return newChecklist; + } + const { data: updatedChecklist } = await GithubUtils_1.default.octokit.issues.update({ + ...defaultPayload, + // eslint-disable-next-line @typescript-eslint/naming-convention + issue_number: currentChecklistData?.number ?? 0, + }); + console.log(`Successfully updated StagingDeployCash! 🎉 ${updatedChecklist.html_url}`); + return updatedChecklist; + } + catch (err) { + console.error('An unknown error occurred!', err); + core.setFailed(err); + } +} +if (require.main === require.cache[eval('__filename')]) { + run(); +} +exports["default"] = run; + + +/***/ }), + +/***/ 9873: /***/ ((__unused_webpack_module, exports) => { "use strict"; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const GIT_CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', +}; +const CONST = { + ...GIT_CONST, + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + HELP_WANTED: 'Help Wanted', + CP_STAGING: 'CP Staging', + }, + ACTIONS: { + CREATED: 'created', + EDIT: 'edited', + }, + EVENTS: { + ISSUE_COMMENT: 'issue_comment', + }, + OPENAI_ROLES: { + USER: 'user', + ASSISTANT: 'assistant', + }, + PROPOSAL_KEYWORD: 'Proposal', + OPENAI_THREAD_COMPLETED: 'completed', + DATE_FORMAT_STRING: 'yyyy-MM-dd', + PULL_REQUEST_REGEX: new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`), + ISSUE_REGEX: new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`), + ISSUE_OR_PULL_REQUEST_REGEX: new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`), + POLL_RATE: 10000, + APP_REPO_URL: `https://github.com/${GIT_CONST.GITHUB_OWNER}/${GIT_CONST.APP_REPO}`, + APP_REPO_GIT_URL: `git@github.com:${GIT_CONST.GITHUB_OWNER}/${GIT_CONST.APP_REPO}.git`, + NO_ACTION: 'NO_ACTION', + OPENAI_POLL_RATE: 1500, + OPENAI_POLL_TIMEOUT: 90000, +}; +exports["default"] = CONST; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _default = '00000000-0000-0000-0000-000000000000'; -exports["default"] = _default; /***/ }), -/***/ 2746: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 1547: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ - value: true +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; })); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(6900)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function parse(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); - } - - let v; - const arr = new Uint8Array(16); // Parse ########-....-....-....-............ - - arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; - arr[1] = v >>> 16 & 0xff; - arr[2] = v >>> 8 & 0xff; - arr[3] = v & 0xff; // Parse ........-####-....-....-............ - - arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; - arr[5] = v & 0xff; // Parse ........-....-####-....-............ - - arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; - arr[7] = v & 0xff; // Parse ........-....-....-####-............ - - arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; - arr[9] = v & 0xff; // Parse ........-....-....-....-############ - // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) - - arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; - arr[11] = v / 0x100000000 & 0xff; - arr[12] = v >>> 24 & 0xff; - arr[13] = v >>> 16 & 0xff; - arr[14] = v >>> 8 & 0xff; - arr[15] = v & 0xff; - return arr; +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const child_process_1 = __nccwpck_require__(2081); +const CONST_1 = __importDefault(__nccwpck_require__(9873)); +const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(3902)); +const VersionUpdater = __importStar(__nccwpck_require__(8982)); +/** + * Check if a tag exists locally or in the remote. + */ +function tagExists(tag) { + try { + // Check if the tag exists locally + (0, child_process_1.execSync)(`git show-ref --tags ${tag}`, { stdio: 'ignore' }); + return true; // Tag exists locally + } + catch (error) { + // Tag does not exist locally, check in remote + let shouldRetry = true; + let needsRepack = false; + let doesTagExist = false; + while (shouldRetry) { + try { + if (needsRepack) { + // We have seen some scenarios where this fixes the git fetch. + // Why? Who knows... https://github.com/Expensify/App/pull/31459 + (0, child_process_1.execSync)('git repack -d', { stdio: 'inherit' }); + } + (0, child_process_1.execSync)(`git ls-remote --exit-code --tags origin ${tag}`, { stdio: 'ignore' }); + doesTagExist = true; + shouldRetry = false; + } + catch (e) { + if (!needsRepack) { + console.log('Attempting to repack and retry...'); + needsRepack = true; + } + else { + console.error("Repack didn't help, giving up..."); + shouldRetry = false; + } + } + } + return doesTagExist; + } +} +/** + * This essentially just calls getPreviousVersion in a loop, until it finds a version for which a tag exists. + * It's useful if we manually perform a version bump, because in that case a tag may not exist for the previous version. + * + * @param tag the current tag + * @param level the Semver level to step backward by + */ +function getPreviousExistingTag(tag, level) { + let previousVersion = VersionUpdater.getPreviousVersion(tag, level); + let tagExistsForPreviousVersion = false; + while (!tagExistsForPreviousVersion) { + if (tagExists(previousVersion)) { + tagExistsForPreviousVersion = true; + break; + } + console.log(`Tag for previous version ${previousVersion} does not exist. Checking for an older version...`); + previousVersion = VersionUpdater.getPreviousVersion(previousVersion, level); + } + return previousVersion; +} +/** + * @param [shallowExcludeTag] When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) + */ +function fetchTag(tag, shallowExcludeTag = '') { + let shouldRetry = true; + let needsRepack = false; + while (shouldRetry) { + try { + let command = ''; + if (needsRepack) { + // We have seen some scenarios where this fixes the git fetch. + // Why? Who knows... https://github.com/Expensify/App/pull/31459 + command = 'git repack -d'; + console.log(`Running command: ${command}`); + (0, child_process_1.execSync)(command); + } + command = `git fetch origin tag ${tag} --no-tags`; + // Note that this condition is only ever NOT true in the 1.0.0-0 edge case + if (shallowExcludeTag && shallowExcludeTag !== tag) { + command += ` --shallow-exclude=${shallowExcludeTag}`; + } + console.log(`Running command: ${command}`); + (0, child_process_1.execSync)(command); + shouldRetry = false; + } + catch (e) { + console.error(e); + if (!needsRepack) { + console.log('Attempting to repack and retry...'); + needsRepack = true; + } + else { + console.error("Repack didn't help, giving up..."); + shouldRetry = false; + } + } + } +} +/** + * Get merge logs between two tags (inclusive) as a JavaScript object. + */ +function getCommitHistoryAsJSON(fromTag, toTag) { + // Fetch tags, excluding commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history + const previousPatchVersion = getPreviousExistingTag(fromTag, VersionUpdater.SEMANTIC_VERSION_LEVELS.PATCH); + fetchTag(fromTag, previousPatchVersion); + fetchTag(toTag, previousPatchVersion); + console.log('Getting pull requests merged between the following tags:', fromTag, toTag); + return new Promise((resolve, reject) => { + let stdout = ''; + let stderr = ''; + const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; + console.log(`Running command: git ${args.join(' ')}`); + const spawnedProcess = (0, child_process_1.spawn)('git', args); + spawnedProcess.on('message', console.log); + spawnedProcess.stdout.on('data', (chunk) => { + console.log(chunk.toString()); + stdout += chunk.toString(); + }); + spawnedProcess.stderr.on('data', (chunk) => { + console.error(chunk.toString()); + stderr += chunk.toString(); + }); + spawnedProcess.on('close', (code) => { + if (code !== 0) { + console.log('code: ', code); + return reject(new Error(`${stderr}`)); + } + resolve(stdout); + }); + spawnedProcess.on('error', (err) => reject(err)); + }).then((stdout) => { + // Sanitize just the text within commit subjects as that's the only potentially un-parseable text. + const sanitizedOutput = stdout.replace(/(?<="subject": ").*?(?="})/g, (subject) => (0, sanitizeStringForJSONParse_1.default)(subject)); + // Then remove newlines, format as JSON and convert to a proper JS object + const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); + return JSON.parse(json); + }); +} +/** + * Parse merged PRs, excluding those from irrelevant branches. + */ +function getValidMergedPRs(commits) { + const mergedPRs = new Set(); + commits.forEach((commit) => { + const author = commit.authorName; + if (author === CONST_1.default.OS_BOTIFY) { + return; + } + const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/); + if (!Array.isArray(match) || match.length < 2) { + return; + } + const pr = Number.parseInt(match[1], 10); + if (mergedPRs.has(pr)) { + // If a PR shows up in the log twice, that means that the PR was deployed in the previous checklist. + // That also means that we don't want to include it in the current checklist, so we remove it now. + mergedPRs.delete(pr); + return; + } + mergedPRs.add(pr); + }); + return Array.from(mergedPRs); } - -var _default = parse; -exports["default"] = _default; - -/***/ }), - -/***/ 814: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; -exports["default"] = _default; - -/***/ }), - -/***/ 807: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = rng; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate - -let poolPtr = rnds8Pool.length; - -function rng() { - if (poolPtr > rnds8Pool.length - 16) { - _crypto.default.randomFillSync(rnds8Pool); - - poolPtr = 0; - } - - return rnds8Pool.slice(poolPtr, poolPtr += 16); +/** + * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags + */ +async function getPullRequestsMergedBetween(fromTag, toTag) { + console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); + const commitList = await getCommitHistoryAsJSON(fromTag, toTag); + console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); + // Find which commit messages correspond to merged PR's + const pullRequestNumbers = getValidMergedPRs(commitList).sort((a, b) => a - b); + console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); + return pullRequestNumbers; } +exports["default"] = { + getPreviousExistingTag, + getValidMergedPRs, + getPullRequestsMergedBetween, +}; + /***/ }), -/***/ 5274: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 9296: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ - value: true +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; })); -exports["default"] = void 0; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function sha1(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === 'string') { - bytes = Buffer.from(bytes, 'utf8'); - } - - return _crypto.default.createHash('sha1').update(bytes).digest(); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +/* eslint-disable @typescript-eslint/naming-convention, import/no-import-module-exports */ +const core = __importStar(__nccwpck_require__(2186)); +const utils_1 = __nccwpck_require__(3030); +const plugin_paginate_rest_1 = __nccwpck_require__(4193); +const plugin_throttling_1 = __nccwpck_require__(9968); +const EmptyObject_1 = __nccwpck_require__(8227); +const arrayDifference_1 = __importDefault(__nccwpck_require__(7034)); +const CONST_1 = __importDefault(__nccwpck_require__(9873)); +class GithubUtils { + static internalOctokit; + /** + * Initialize internal octokit. + * NOTE: When using GithubUtils in CI, you don't need to call this manually. + */ + static initOctokitWithToken(token) { + const Octokit = utils_1.GitHub.plugin(plugin_throttling_1.throttling, plugin_paginate_rest_1.paginateRest); + // Save a copy of octokit used in this class + this.internalOctokit = new Octokit((0, utils_1.getOctokitOptions)(token, { + throttle: { + retryAfterBaseValue: 2000, + onRateLimit: (retryAfter, options) => { + console.warn(`Request quota exhausted for request ${options.method} ${options.url}`); + // Retry five times when hitting a rate limit error, then give up + if (options.request.retryCount <= 5) { + console.log(`Retrying after ${retryAfter} seconds!`); + return true; + } + }, + onAbuseLimit: (retryAfter, options) => { + // does not retry, only logs a warning + console.warn(`Abuse detected for request ${options.method} ${options.url}`); + }, + }, + })); + } + /** + * Default initialize method assuming running in CI, getting the token from an input. + * + * @private + */ + static initOctokit() { + const token = core.getInput('GITHUB_TOKEN', { required: true }); + this.initOctokitWithToken(token); + } + /** + * Either give an existing instance of Octokit rest or create a new one + * + * @readonly + * @static + */ + static get octokit() { + if (!this.internalOctokit) { + this.initOctokit(); + } + // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style + return this.internalOctokit.rest; + } + /** + * Get the graphql instance from internal octokit. + * @readonly + * @static + */ + static get graphql() { + if (!this.internalOctokit) { + this.initOctokit(); + } + // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style + return this.internalOctokit.graphql; + } + /** + * Either give an existing instance of Octokit paginate or create a new one + * + * @readonly + * @static + */ + static get paginate() { + if (!this.internalOctokit) { + this.initOctokit(); + } + // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style + return this.internalOctokit.paginate; + } + /** + * Finds one open `StagingDeployCash` issue via GitHub octokit library. + */ + static getStagingDeployCash() { + return this.octokit.issues + .listForRepo({ + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + labels: CONST_1.default.LABELS.STAGING_DEPLOY, + state: 'open', + }) + .then(({ data }) => { + if (!data.length) { + throw new Error(`Unable to find ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`); + } + if (data.length > 1) { + throw new Error(`Found more than one ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`); + } + return this.getStagingDeployCashData(data[0]); + }); + } + /** + * Takes in a GitHub issue object and returns the data we want. + */ + static getStagingDeployCashData(issue) { + try { + const versionRegex = new RegExp('([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9]+))?', 'g'); + const tag = issue.body?.match(versionRegex)?.[0].replace(/`/g, ''); + return { + title: issue.title, + url: issue.url, + number: this.getIssueOrPullRequestNumberFromURL(issue.url), + labels: issue.labels, + PRList: this.getStagingDeployCashPRList(issue), + deployBlockers: this.getStagingDeployCashDeployBlockers(issue), + internalQAPRList: this.getStagingDeployCashInternalQA(issue), + isTimingDashboardChecked: issue.body ? /-\s\[x]\sI checked the \[App Timing Dashboard]/.test(issue.body) : false, + isFirebaseChecked: issue.body ? /-\s\[x]\sI checked \[Firebase Crashlytics]/.test(issue.body) : false, + isGHStatusChecked: issue.body ? /-\s\[x]\sI checked \[GitHub Status]/.test(issue.body) : false, + tag, + }; + } + catch (exception) { + throw new Error(`Unable to find ${CONST_1.default.LABELS.STAGING_DEPLOY} issue with correct data.`); + } + } + /** + * Parse the PRList and Internal QA section of the StagingDeployCash issue body. + * + * @private + */ + static getStagingDeployCashPRList(issue) { + let PRListSection = issue.body?.match(/pull requests:\*\*\r?\n((?:-.*\r?\n)+)\r?\n\r?\n?/) ?? null; + if (PRListSection?.length !== 2) { + // No PRs, return an empty array + console.log('Hmmm...The open StagingDeployCash does not list any pull requests, continuing...'); + return []; + } + PRListSection = PRListSection[1]; + const PRList = [...PRListSection.matchAll(new RegExp(`- \\[([ x])] (${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({ + url: match[2], + number: Number.parseInt(match[3], 10), + isVerified: match[1] === 'x', + })); + return PRList.sort((a, b) => a.number - b.number); + } + /** + * Parse DeployBlocker section of the StagingDeployCash issue body. + * + * @private + */ + static getStagingDeployCashDeployBlockers(issue) { + let deployBlockerSection = issue.body?.match(/Deploy Blockers:\*\*\r?\n((?:-.*\r?\n)+)/) ?? null; + if (deployBlockerSection?.length !== 2) { + return []; + } + deployBlockerSection = deployBlockerSection[1]; + const deployBlockers = [...deployBlockerSection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.ISSUE_OR_PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({ + url: match[2], + number: Number.parseInt(match[3], 10), + isResolved: match[1] === 'x', + })); + return deployBlockers.sort((a, b) => a.number - b.number); + } + /** + * Parse InternalQA section of the StagingDeployCash issue body. + * + * @private + */ + static getStagingDeployCashInternalQA(issue) { + let internalQASection = issue.body?.match(/Internal QA:\*\*\r?\n((?:- \[[ x]].*\r?\n)+)/) ?? null; + if (internalQASection?.length !== 2) { + return []; + } + internalQASection = internalQASection[1]; + const internalQAPRs = [...internalQASection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({ + url: match[2].split('-')[0].trim(), + number: Number.parseInt(match[3], 10), + isResolved: match[1] === 'x', + })); + return internalQAPRs.sort((a, b) => a.number - b.number); + } + /** + * Generate the issue body and assignees for a StagingDeployCash. + */ + static generateStagingDeployCashBodyAndAssignees(tag, PRList, verifiedPRList = [], deployBlockers = [], resolvedDeployBlockers = [], resolvedInternalQAPRs = [], isTimingDashboardChecked = false, isFirebaseChecked = false, isGHStatusChecked = false) { + return this.fetchAllPullRequests(PRList.map((pr) => this.getPullRequestNumberFromURL(pr))) + .then((data) => { + const internalQAPRs = Array.isArray(data) ? data.filter((pr) => !(0, EmptyObject_1.isEmptyObject)(pr.labels.find((item) => item.name === CONST_1.default.LABELS.INTERNAL_QA))) : []; + return Promise.all(internalQAPRs.map((pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({ url: pr.html_url, mergerLogin })))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = results.reduce((acc, { url, mergerLogin }) => { + acc[url] = mergerLogin; + return acc; + }, {}); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + const noQAPRs = Array.isArray(data) ? data.filter((PR) => /\[No\s?QA]/i.test(PR.title)).map((item) => item.html_url) : []; + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = [...new Set([...verifiedPRList, ...noQAPRs])]; + const sortedPRList = [...new Set((0, arrayDifference_1.default)(PRList, Object.keys(internalQAPRMap)))].sort((a, b) => GithubUtils.getPullRequestNumberFromURL(a) - GithubUtils.getPullRequestNumberFromURL(b)); + const sortedDeployBlockers = [...new Set(deployBlockers)].sort((a, b) => GithubUtils.getIssueOrPullRequestNumberFromURL(a) - GithubUtils.getIssueOrPullRequestNumberFromURL(b)); + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + // PR list + if (sortedPRList.length > 0) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + sortedPRList.forEach((URL) => { + issueBody += verifiedOrNoQAPRs.includes(URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } + // Internal QA PR list + if (!(0, EmptyObject_1.isEmptyObject)(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + Object.keys(internalQAPRMap).forEach((URL) => { + const merger = internalQAPRMap[URL]; + const mergerMention = `@${merger}`; + issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } + // Deploy blockers + if (deployBlockers.length > 0) { + issueBody += '**Deploy Blockers:**\r\n'; + sortedDeployBlockers.forEach((URL) => { + issueBody += resolvedDeployBlockers.includes(URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isTimingDashboardChecked ? 'x' : ' '}] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isFirebaseChecked ? 'x' : ' '}] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = [...new Set(Object.values(internalQAPRMap))]; + const issue = { issueBody, issueAssignees }; + return issue; + }); + }) + .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); + } + /** + * Fetch all pull requests given a list of PR numbers. + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = pullRequestNumbers.sort((a, b) => a - b)[0]; + return this.paginate(this.octokit.pulls.list, { + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({ data }, done) => { + if (data.find((pr) => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then((prList) => prList.filter((pr) => pullRequestNumbers.includes(pr.number))) + .catch((err) => console.error('Failed to get PR list', err)); + } + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({ data: pullRequest }) => pullRequest.merged_by?.login); + } + static getPullRequestBody(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({ data: pullRequestComment }) => pullRequestComment.body); + } + static getAllReviewComments(pullRequestNumber) { + return this.paginate(this.octokit.pulls.listReviews, { + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + pull_number: pullRequestNumber, + per_page: 100, + }, (response) => response.data.map((review) => review.body)); + } + static getAllComments(issueNumber) { + return this.paginate(this.octokit.issues.listComments, { + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + issue_number: issueNumber, + per_page: 100, + }, (response) => response.data.map((comment) => comment.body)); + } + /** + * Create comment on pull request + */ + static createComment(repo, number, messageBody) { + console.log(`Writing comment on #${number}`); + return this.octokit.issues.createComment({ + owner: CONST_1.default.GITHUB_OWNER, + repo, + issue_number: number, + body: messageBody, + }); + } + /** + * Get the most recent workflow run for the given New Expensify workflow. + */ + static getLatestWorkflowRunID(workflow) { + console.log(`Fetching New Expensify workflow runs for ${workflow}...`); + return this.octokit.actions + .listWorkflowRuns({ + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + workflow_id: workflow, + }) + .then((response) => response.data.workflow_runs[0]?.id); + } + /** + * Generate the URL of an New Expensify pull request given the PR number. + */ + static getPullRequestURLFromNumber(value) { + return `${CONST_1.default.APP_REPO_URL}/pull/${value}`; + } + /** + * Parse the pull request number from a URL. + * + * @throws {Error} If the URL is not a valid Github Pull Request. + */ + static getPullRequestNumberFromURL(URL) { + const matches = URL.match(CONST_1.default.PULL_REQUEST_REGEX); + if (!Array.isArray(matches) || matches.length !== 2) { + throw new Error(`Provided URL ${URL} is not a Github Pull Request!`); + } + return Number.parseInt(matches[1], 10); + } + /** + * Parse the issue number from a URL. + * + * @throws {Error} If the URL is not a valid Github Issue. + */ + static getIssueNumberFromURL(URL) { + const matches = URL.match(CONST_1.default.ISSUE_REGEX); + if (!Array.isArray(matches) || matches.length !== 2) { + throw new Error(`Provided URL ${URL} is not a Github Issue!`); + } + return Number.parseInt(matches[1], 10); + } + /** + * Parse the issue or pull request number from a URL. + * + * @throws {Error} If the URL is not a valid Github Issue or Pull Request. + */ + static getIssueOrPullRequestNumberFromURL(URL) { + const matches = URL.match(CONST_1.default.ISSUE_OR_PULL_REQUEST_REGEX); + if (!Array.isArray(matches) || matches.length !== 2) { + throw new Error(`Provided URL ${URL} is not a valid Github Issue or Pull Request!`); + } + return Number.parseInt(matches[1], 10); + } + /** + * Return the login of the actor who closed an issue or PR. If the issue is not closed, return an empty string. + */ + static getActorWhoClosedIssue(issueNumber) { + return this.paginate(this.octokit.issues.listEvents, { + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + issue_number: issueNumber, + per_page: 100, + }) + .then((events) => events.filter((event) => event.event === 'closed')) + .then((closedEvents) => closedEvents.at(-1)?.actor?.login ?? ''); + } + /** + * Returns a single artifact by name. If none is found, it returns undefined. + */ + static getArtifactByName(artifactName) { + return this.octokit.actions + .listArtifactsForRepo({ + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + per_page: 1, + name: artifactName, + }) + .then((response) => response.data.artifacts[0]); + } + /** + * Given an artifact ID, returns the download URL to a zip file containing the artifact. + */ + static getArtifactDownloadURL(artifactId) { + return this.octokit.actions + .downloadArtifact({ + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, + artifact_id: artifactId, + archive_format: 'zip', + }) + .then((response) => response.url); + } } +exports["default"] = GithubUtils; -var _default = sha1; -exports["default"] = _default; /***/ }), -/***/ 8950: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 3902: +/***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(6900)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - +/* eslint-disable @typescript-eslint/naming-convention */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +const replacer = (str) => ({ + '\\': '\\\\', + '\t': '\\t', + '\n': '\\n', + '\r': '\\r', + '\f': '\\f', + '"': '\\"', +}[str] ?? ''); /** - * Convert array of 16 byte values to UUID string format of the form: - * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + * Replace any characters in the string that will break JSON.parse for our Git Log output + * + * Solution partly taken from SO user Gabriel Rodríguez Flores 🙇 + * https://stackoverflow.com/questions/52789718/how-to-remove-special-characters-before-json-parse-while-file-reading */ -const byteToHex = []; - -for (let i = 0; i < 256; ++i) { - byteToHex.push((i + 0x100).toString(16).substr(1)); -} - -function stringify(arr, offset = 0) { - // Note: Be careful editing this code! It's been tuned for performance - // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 - const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one - // of the following: - // - One or more input array values don't map to a hex octet (leading to - // "undefined" in the uuid) - // - Invalid input values for the RFC `version` or `variant` fields - - if (!(0, _validate.default)(uuid)) { - throw TypeError('Stringified UUID is invalid'); - } - - return uuid; -} +const sanitizeStringForJSONParse = (inputString) => { + if (typeof inputString !== 'string') { + throw new TypeError('Input must me of type String'); + } + // Replace any newlines and escape backslashes + return inputString.replace(/\\|\t|\n|\r|\f|"/g, replacer); +}; +exports["default"] = sanitizeStringForJSONParse; -var _default = stringify; -exports["default"] = _default; /***/ }), -/***/ 8628: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 8982: +/***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _rng = _interopRequireDefault(__nccwpck_require__(807)); - -var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// **`v1()` - Generate time-based UUID** -// -// Inspired by https://github.com/LiosK/UUID.js -// and http://docs.python.org/library/uuid.html -let _nodeId; - -let _clockseq; // Previous uuid creation time - - -let _lastMSecs = 0; -let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details - -function v1(options, buf, offset) { - let i = buf && offset || 0; - const b = buf || new Array(16); - options = options || {}; - let node = options.node || _nodeId; - let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not - // specified. We do this lazily to minimize issues related to insufficient - // system entropy. See #189 - - if (node == null || clockseq == null) { - const seedBytes = options.random || (options.rng || _rng.default)(); - - if (node == null) { - // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) - node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getPreviousVersion = exports.incrementPatch = exports.incrementMinor = exports.SEMANTIC_VERSION_LEVELS = exports.MAX_INCREMENTS = exports.incrementVersion = exports.getVersionStringFromNumber = exports.getVersionNumberFromString = exports.isValidSemverLevel = void 0; +const SEMANTIC_VERSION_LEVELS = { + MAJOR: 'MAJOR', + MINOR: 'MINOR', + PATCH: 'PATCH', + BUILD: 'BUILD', +}; +exports.SEMANTIC_VERSION_LEVELS = SEMANTIC_VERSION_LEVELS; +const MAX_INCREMENTS = 99; +exports.MAX_INCREMENTS = MAX_INCREMENTS; +function isValidSemverLevel(str) { + return Object.keys(SEMANTIC_VERSION_LEVELS).includes(str); +} +exports.isValidSemverLevel = isValidSemverLevel; +/** + * Transforms a versions string into a number + */ +const getVersionNumberFromString = (versionString) => { + const [version, build] = versionString.split('-'); + const [major, minor, patch] = version.split('.').map((n) => Number(n)); + return [major, minor, patch, Number.isInteger(Number(build)) ? Number(build) : 0]; +}; +exports.getVersionNumberFromString = getVersionNumberFromString; +/** + * Transforms version numbers components into a version string + */ +const getVersionStringFromNumber = (major, minor, patch, build = 0) => `${major}.${minor}.${patch}-${build}`; +exports.getVersionStringFromNumber = getVersionStringFromNumber; +/** + * Increments a minor version + */ +const incrementMinor = (major, minor) => { + if (minor < MAX_INCREMENTS) { + return getVersionStringFromNumber(major, minor + 1, 0, 0); } - - if (clockseq == null) { - // Per 4.2.2, randomize (14 bit) clockseq - clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; + return getVersionStringFromNumber(major + 1, 0, 0, 0); +}; +exports.incrementMinor = incrementMinor; +/** + * Increments a Patch version + */ +const incrementPatch = (major, minor, patch) => { + if (patch < MAX_INCREMENTS) { + return getVersionStringFromNumber(major, minor, patch + 1, 0); } - } // UUID timestamps are 100 nano-second units since the Gregorian epoch, - // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so - // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' - // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. - - - let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock - // cycle to simulate higher resolution clock - - let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) - - const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression - - if (dt < 0 && options.clockseq === undefined) { - clockseq = clockseq + 1 & 0x3fff; - } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new - // time interval - - - if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { - nsecs = 0; - } // Per 4.2.1.2 Throw error if too many uuids are requested - - - if (nsecs >= 10000) { - throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); - } - - _lastMSecs = msecs; - _lastNSecs = nsecs; - _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch - - msecs += 12219292800000; // `time_low` - - const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; - b[i++] = tl >>> 24 & 0xff; - b[i++] = tl >>> 16 & 0xff; - b[i++] = tl >>> 8 & 0xff; - b[i++] = tl & 0xff; // `time_mid` - - const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; - b[i++] = tmh >>> 8 & 0xff; - b[i++] = tmh & 0xff; // `time_high_and_version` - - b[i++] = tmh >>> 24 & 0xf | 0x10; // include version - - b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) - - b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` - - b[i++] = clockseq & 0xff; // `node` - - for (let n = 0; n < 6; ++n) { - b[i + n] = node[n]; - } - - return buf || (0, _stringify.default)(b); + return incrementMinor(major, minor); +}; +exports.incrementPatch = incrementPatch; +/** + * Increments a build version + */ +const incrementVersion = (version, level) => { + const [major, minor, patch, build] = getVersionNumberFromString(version); + // Majors will always be incremented + if (level === SEMANTIC_VERSION_LEVELS.MAJOR) { + return getVersionStringFromNumber(major + 1, 0, 0, 0); + } + if (level === SEMANTIC_VERSION_LEVELS.MINOR) { + return incrementMinor(major, minor); + } + if (level === SEMANTIC_VERSION_LEVELS.PATCH) { + return incrementPatch(major, minor, patch); + } + if (build < MAX_INCREMENTS) { + return getVersionStringFromNumber(major, minor, patch, build + 1); + } + return incrementPatch(major, minor, patch); +}; +exports.incrementVersion = incrementVersion; +function getPreviousVersion(currentVersion, level) { + const [major, minor, patch, build] = getVersionNumberFromString(currentVersion); + if (level === SEMANTIC_VERSION_LEVELS.MAJOR) { + if (major === 1) { + return getVersionStringFromNumber(1, 0, 0, 0); + } + return getVersionStringFromNumber(major - 1, 0, 0, 0); + } + if (level === SEMANTIC_VERSION_LEVELS.MINOR) { + if (minor === 0) { + return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.MAJOR); + } + return getVersionStringFromNumber(major, minor - 1, 0, 0); + } + if (level === SEMANTIC_VERSION_LEVELS.PATCH) { + if (patch === 0) { + return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.MINOR); + } + return getVersionStringFromNumber(major, minor, patch - 1, 0); + } + if (build === 0) { + return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.PATCH); + } + return getVersionStringFromNumber(major, minor, patch, build - 1); } +exports.getPreviousVersion = getPreviousVersion; -var _default = v1; -exports["default"] = _default; /***/ }), -/***/ 6409: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 8227: +/***/ ((__unused_webpack_module, exports) => { "use strict"; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isEmptyObject = void 0; +function isEmptyObject(obj) { + return Object.keys(obj ?? {}).length === 0; +} +exports.isEmptyObject = isEmptyObject; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _v = _interopRequireDefault(__nccwpck_require__(5998)); - -var _md = _interopRequireDefault(__nccwpck_require__(4569)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const v3 = (0, _v.default)('v3', 0x30, _md.default); -var _default = v3; -exports["default"] = _default; /***/ }), -/***/ 5998: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 7034: +/***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = _default; -exports.URL = exports.DNS = void 0; - -var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); - -var _parse = _interopRequireDefault(__nccwpck_require__(2746)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function stringToBytes(str) { - str = unescape(encodeURIComponent(str)); // UTF8 escape - - const bytes = []; - - for (let i = 0; i < str.length; ++i) { - bytes.push(str.charCodeAt(i)); - } - - return bytes; +Object.defineProperty(exports, "__esModule", ({ value: true })); +/** + * This function is an equivalent of _.difference, it takes two arrays and returns the difference between them. + * It returns an array of items that are in the first array but not in the second array. + */ +function arrayDifference(array1, array2) { + return [array1, array2].reduce((a, b) => a.filter((c) => !b.includes(c))); } +exports["default"] = arrayDifference; -const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; -exports.DNS = DNS; -const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; -exports.URL = URL; - -function _default(name, version, hashfunc) { - function generateUUID(value, namespace, buf, offset) { - if (typeof value === 'string') { - value = stringToBytes(value); - } - - if (typeof namespace === 'string') { - namespace = (0, _parse.default)(namespace); - } - - if (namespace.length !== 16) { - throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); - } // Compute hash of namespace and value, Per 4.3 - // Future: Use spread syntax when supported on all platforms, e.g. `bytes = - // hashfunc([...namespace, ... value])` - - - let bytes = new Uint8Array(16 + value.length); - bytes.set(namespace); - bytes.set(value, namespace.length); - bytes = hashfunc(bytes); - bytes[6] = bytes[6] & 0x0f | version; - bytes[8] = bytes[8] & 0x3f | 0x80; - - if (buf) { - offset = offset || 0; - - for (let i = 0; i < 16; ++i) { - buf[offset + i] = bytes[i]; - } - return buf; - } +/***/ }), - return (0, _stringify.default)(bytes); - } // Function#name is not settable on some platforms (#270) +/***/ 9491: +/***/ ((module) => { +"use strict"; +module.exports = require("assert"); - try { - generateUUID.name = name; // eslint-disable-next-line no-empty - } catch (err) {} // For CommonJS default export support +/***/ }), +/***/ 2081: +/***/ ((module) => { - generateUUID.DNS = DNS; - generateUUID.URL = URL; - return generateUUID; -} +"use strict"; +module.exports = require("child_process"); /***/ }), -/***/ 5122: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 6113: +/***/ ((module) => { "use strict"; +module.exports = require("crypto"); +/***/ }), -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _rng = _interopRequireDefault(__nccwpck_require__(807)); - -var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); +/***/ 3975: +/***/ ((module) => { -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +"use strict"; +module.exports = require("encoding"); -function v4(options, buf, offset) { - options = options || {}; +/***/ }), - const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` +/***/ 2361: +/***/ ((module) => { +"use strict"; +module.exports = require("events"); - rnds[6] = rnds[6] & 0x0f | 0x40; - rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided +/***/ }), - if (buf) { - offset = offset || 0; +/***/ 7147: +/***/ ((module) => { - for (let i = 0; i < 16; ++i) { - buf[offset + i] = rnds[i]; - } +"use strict"; +module.exports = require("fs"); - return buf; - } +/***/ }), - return (0, _stringify.default)(rnds); -} +/***/ 3685: +/***/ ((module) => { -var _default = v4; -exports["default"] = _default; +"use strict"; +module.exports = require("http"); /***/ }), -/***/ 9120: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 5687: +/***/ ((module) => { "use strict"; +module.exports = require("https"); +/***/ }), -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; +/***/ 1808: +/***/ ((module) => { -var _v = _interopRequireDefault(__nccwpck_require__(5998)); +"use strict"; +module.exports = require("net"); -var _sha = _interopRequireDefault(__nccwpck_require__(5274)); +/***/ }), -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +/***/ 2037: +/***/ ((module) => { -const v5 = (0, _v.default)('v5', 0x50, _sha.default); -var _default = v5; -exports["default"] = _default; +"use strict"; +module.exports = require("os"); /***/ }), -/***/ 6900: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 1017: +/***/ ((module) => { "use strict"; +module.exports = require("path"); +/***/ }), -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; +/***/ 5477: +/***/ ((module) => { -var _regex = _interopRequireDefault(__nccwpck_require__(814)); +"use strict"; +module.exports = require("punycode"); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +/***/ }), -function validate(uuid) { - return typeof uuid === 'string' && _regex.default.test(uuid); -} +/***/ 2781: +/***/ ((module) => { -var _default = validate; -exports["default"] = _default; +"use strict"; +module.exports = require("stream"); /***/ }), -/***/ 1595: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 4404: +/***/ ((module) => { "use strict"; +module.exports = require("tls"); +/***/ }), -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(6900)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +/***/ 7310: +/***/ ((module) => { -function version(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); - } +"use strict"; +module.exports = require("url"); - return parseInt(uuid.substr(14, 1), 16); -} +/***/ }), -var _default = version; -exports["default"] = _default; +/***/ 3837: +/***/ ((module) => { + +"use strict"; +module.exports = require("util"); /***/ }), -/***/ 2940: +/***/ 9796: /***/ ((module) => { -// Returns a wrapper function that returns a wrapped callback -// The wrapper function should do some stuff, and return a -// presumably different callback function. -// This makes sure that own properties are retained, so that -// decorations and such are not lost along the way. -module.exports = wrappy -function wrappy (fn, cb) { - if (fn && cb) return wrappy(fn)(cb) +"use strict"; +module.exports = require("zlib"); - if (typeof fn !== 'function') - throw new TypeError('need wrapper function') +/***/ }), - Object.keys(fn).forEach(function (k) { - wrapper[k] = fn[k] - }) +/***/ 6411: +/***/ ((__unused_webpack_module, exports) => { - return wrapper +"use strict"; - function wrapper() { - var args = new Array(arguments.length) - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i] - } - var ret = fn.apply(this, args) - var cb = args[args.length-1] - if (typeof ret === 'function' && ret !== cb) { - Object.keys(cb).forEach(function (k) { - ret[k] = cb[k] - }) - } - return ret - } +exports.addLeadingZeros = addLeadingZeros; +function addLeadingZeros(number, targetLength) { + const sign = number < 0 ? "-" : ""; + const output = Math.abs(number).toString().padStart(targetLength, "0"); + return sign + output; } /***/ }), -/***/ 566: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 7479: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; +Object.defineProperty(exports, "defaultLocale", ({ + enumerable: true, + get: function () { + return _index.enUS; + }, })); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const core = __importStar(__nccwpck_require__(2186)); -const format_1 = __importDefault(__nccwpck_require__(2168)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const CONST_1 = __importDefault(__nccwpck_require__(9873)); -const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); -const GitUtils_1 = __importDefault(__nccwpck_require__(1547)); -async function run() { - // Note: require('package.json').version does not work because ncc will resolve that to a plain string at compile time - const packageJson = JSON.parse(fs_1.default.readFileSync('package.json', 'utf8')); - const newVersionTag = packageJson.version; - try { - // Start by fetching the list of recent StagingDeployCash issues, along with the list of open deploy blockers - const { data: recentDeployChecklists } = await GithubUtils_1.default.octokit.issues.listForRepo({ - log: console, - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - labels: CONST_1.default.LABELS.STAGING_DEPLOY, - state: 'all', - }); - // Look at the state of the most recent StagingDeployCash, - // if it is open then we'll update the existing one, otherwise, we'll create a new one. - const mostRecentChecklist = recentDeployChecklists[0]; - const shouldCreateNewDeployChecklist = mostRecentChecklist.state !== 'open'; - const previousChecklist = shouldCreateNewDeployChecklist ? mostRecentChecklist : recentDeployChecklists[1]; - if (shouldCreateNewDeployChecklist) { - console.log('Latest StagingDeployCash is closed, creating a new one.', mostRecentChecklist); - } - else { - console.log('Latest StagingDeployCash is open, updating it instead of creating a new one.', 'Current:', mostRecentChecklist, 'Previous:', previousChecklist); - } - // Parse the data from the previous and current checklists into the format used to generate the checklist - const previousChecklistData = GithubUtils_1.default.getStagingDeployCashData(previousChecklist); - const currentChecklistData = shouldCreateNewDeployChecklist ? undefined : GithubUtils_1.default.getStagingDeployCashData(mostRecentChecklist); - // Find the list of PRs merged between the current checklist and the previous checklist - const mergedPRs = await GitUtils_1.default.getPullRequestsMergedBetween(previousChecklistData.tag ?? '', newVersionTag); - // Next, we generate the checklist body - let checklistBody = ''; - let checklistAssignees = []; - if (shouldCreateNewDeployChecklist) { - const stagingDeployCashBodyAndAssignees = await GithubUtils_1.default.generateStagingDeployCashBodyAndAssignees(newVersionTag, mergedPRs.map((value) => GithubUtils_1.default.getPullRequestURLFromNumber(value))); - if (stagingDeployCashBodyAndAssignees) { - checklistBody = stagingDeployCashBodyAndAssignees.issueBody; - checklistAssignees = stagingDeployCashBodyAndAssignees.issueAssignees.filter(Boolean); - } - } - else { - // Generate the updated PR list, preserving the previous state of `isVerified` for existing PRs - const PRList = mergedPRs.map((prNum) => { - const indexOfPRInCurrentChecklist = currentChecklistData?.PRList.findIndex((pr) => pr.number === prNum) ?? -1; - const isVerified = indexOfPRInCurrentChecklist >= 0 ? currentChecklistData?.PRList[indexOfPRInCurrentChecklist].isVerified : false; - return { - number: prNum, - url: GithubUtils_1.default.getPullRequestURLFromNumber(prNum), - isVerified, - }; - }); - // Generate the deploy blocker list, preserving the previous state of `isResolved` - const { data: openDeployBlockers } = await GithubUtils_1.default.octokit.issues.listForRepo({ - log: console, - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - labels: CONST_1.default.LABELS.DEPLOY_BLOCKER, - }); - // First, make sure we include all current deploy blockers - const deployBlockers = openDeployBlockers.map((deployBlocker) => { - const indexInCurrentChecklist = currentChecklistData?.deployBlockers.findIndex((item) => item.number === deployBlocker.number) ?? -1; - const isResolved = indexInCurrentChecklist >= 0 ? currentChecklistData?.deployBlockers[indexInCurrentChecklist].isResolved : false; - return { - number: deployBlocker.number, - url: deployBlocker.html_url, - isResolved, - }; - }); - // Then make sure we include any demoted or closed blockers as well, and just check them off automatically - currentChecklistData?.deployBlockers.forEach((deployBlocker) => { - const isResolved = deployBlockers.findIndex((openBlocker) => openBlocker.number === deployBlocker.number) < 0; - deployBlockers.push({ - ...deployBlocker, - isResolved, - }); - }); - const didVersionChange = newVersionTag !== currentChecklistData?.tag; - const stagingDeployCashBodyAndAssignees = await GithubUtils_1.default.generateStagingDeployCashBodyAndAssignees(newVersionTag, PRList.map((pr) => pr.url), PRList.filter((pr) => pr.isVerified).map((pr) => pr.url), deployBlockers.map((blocker) => blocker.url), deployBlockers.filter((blocker) => blocker.isResolved).map((blocker) => blocker.url), currentChecklistData?.internalQAPRList.filter((pr) => pr.isResolved).map((pr) => pr.url), didVersionChange ? false : currentChecklistData.isTimingDashboardChecked, didVersionChange ? false : currentChecklistData.isFirebaseChecked, didVersionChange ? false : currentChecklistData.isGHStatusChecked); - if (stagingDeployCashBodyAndAssignees) { - checklistBody = stagingDeployCashBodyAndAssignees.issueBody; - checklistAssignees = stagingDeployCashBodyAndAssignees.issueAssignees.filter(Boolean); - } - } - // Finally, create or update the checklist - const defaultPayload = { - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - body: checklistBody, - }; - if (shouldCreateNewDeployChecklist) { - const { data: newChecklist } = await GithubUtils_1.default.octokit.issues.create({ - ...defaultPayload, - title: `Deploy Checklist: New Expensify ${(0, format_1.default)(new Date(), CONST_1.default.DATE_FORMAT_STRING)}`, - labels: [CONST_1.default.LABELS.STAGING_DEPLOY], - assignees: [CONST_1.default.APPLAUSE_BOT].concat(checklistAssignees), - }); - console.log(`Successfully created new StagingDeployCash! 🎉 ${newChecklist.html_url}`); - return newChecklist; - } - const { data: updatedChecklist } = await GithubUtils_1.default.octokit.issues.update({ - ...defaultPayload, - // eslint-disable-next-line @typescript-eslint/naming-convention - issue_number: currentChecklistData?.number ?? 0, - }); - console.log(`Successfully updated StagingDeployCash! 🎉 ${updatedChecklist.html_url}`); - return updatedChecklist; - } - catch (err) { - console.error('An unknown error occurred!', err); - core.setFailed(err); - } -} -if (require.main === require.cache[eval('__filename')]) { - run(); -} -exports["default"] = run; +var _index = __nccwpck_require__(9425); /***/ }), -/***/ 9873: +/***/ 5586: /***/ ((__unused_webpack_module, exports) => { -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); -const GIT_CONST = { - GITHUB_OWNER: 'Expensify', - APP_REPO: 'App', -}; -const CONST = { - ...GIT_CONST, - APPLAUSE_BOT: 'applausebot', - OS_BOTIFY: 'OSBotify', - LABELS: { - STAGING_DEPLOY: 'StagingDeployCash', - DEPLOY_BLOCKER: 'DeployBlockerCash', - INTERNAL_QA: 'InternalQA', - HELP_WANTED: 'Help Wanted', - CP_STAGING: 'CP Staging', - }, - ACTIONS: { - CREATED: 'created', - EDIT: 'edited', - }, - EVENTS: { - ISSUE_COMMENT: 'issue_comment', - }, - OPENAI_ROLES: { - USER: 'user', - ASSISTANT: 'assistant', - }, - PROPOSAL_KEYWORD: 'Proposal', - OPENAI_THREAD_COMPLETED: 'completed', - DATE_FORMAT_STRING: 'yyyy-MM-dd', - PULL_REQUEST_REGEX: new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`), - ISSUE_REGEX: new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`), - ISSUE_OR_PULL_REQUEST_REGEX: new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`), - POLL_RATE: 10000, - APP_REPO_URL: `https://github.com/${GIT_CONST.GITHUB_OWNER}/${GIT_CONST.APP_REPO}`, - APP_REPO_GIT_URL: `git@github.com:${GIT_CONST.GITHUB_OWNER}/${GIT_CONST.APP_REPO}.git`, - NO_ACTION: 'NO_ACTION', - OPENAI_POLL_RATE: 1500, - OPENAI_POLL_TIMEOUT: 90000, -}; -exports["default"] = CONST; - +"use strict"; + +exports.getDefaultOptions = getDefaultOptions; +exports.setDefaultOptions = setDefaultOptions; + +let defaultOptions = {}; + +function getDefaultOptions() { + return defaultOptions; +} + +function setDefaultOptions(newOptions) { + defaultOptions = newOptions; +} + /***/ }), -/***/ 1547: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 6615: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; +exports.formatters = void 0; +var _index = __nccwpck_require__(1412); +var _index2 = __nccwpck_require__(6703); +var _index3 = __nccwpck_require__(7131); +var _index4 = __nccwpck_require__(3080); +var _index5 = __nccwpck_require__(9116); + +var _index6 = __nccwpck_require__(6411); +var _index7 = __nccwpck_require__(8914); + +const dayPeriodEnum = { + am: "am", + pm: "pm", + midnight: "midnight", + noon: "noon", + morning: "morning", + afternoon: "afternoon", + evening: "evening", + night: "night", }; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const child_process_1 = __nccwpck_require__(2081); -const CONST_1 = __importDefault(__nccwpck_require__(9873)); -const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(3902)); -const VersionUpdater = __importStar(__nccwpck_require__(8982)); -/** - * Check if a tag exists locally or in the remote. + +/* + * | | Unit | | Unit | + * |-----|--------------------------------|-----|--------------------------------| + * | a | AM, PM | A* | Milliseconds in day | + * | b | AM, PM, noon, midnight | B | Flexible day period | + * | c | Stand-alone local day of week | C* | Localized hour w/ day period | + * | d | Day of month | D | Day of year | + * | e | Local day of week | E | Day of week | + * | f | | F* | Day of week in month | + * | g* | Modified Julian day | G | Era | + * | h | Hour [1-12] | H | Hour [0-23] | + * | i! | ISO day of week | I! | ISO week of year | + * | j* | Localized hour w/ day period | J* | Localized hour w/o day period | + * | k | Hour [1-24] | K | Hour [0-11] | + * | l* | (deprecated) | L | Stand-alone month | + * | m | Minute | M | Month | + * | n | | N | | + * | o! | Ordinal number modifier | O | Timezone (GMT) | + * | p! | Long localized time | P! | Long localized date | + * | q | Stand-alone quarter | Q | Quarter | + * | r* | Related Gregorian year | R! | ISO week-numbering year | + * | s | Second | S | Fraction of second | + * | t! | Seconds timestamp | T! | Milliseconds timestamp | + * | u | Extended year | U* | Cyclic year | + * | v* | Timezone (generic non-locat.) | V* | Timezone (location) | + * | w | Local week of year | W* | Week of month | + * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) | + * | y | Year (abs) | Y | Local week-numbering year | + * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) | + * + * Letters marked by * are not implemented but reserved by Unicode standard. + * + * Letters marked by ! are non-standard, but implemented by date-fns: + * - `o` modifies the previous token to turn it into an ordinal (see `format` docs) + * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days, + * i.e. 7 for Sunday, 1 for Monday, etc. + * - `I` is ISO week of year, as opposed to `w` which is local week of year. + * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year. + * `R` is supposed to be used in conjunction with `I` and `i` + * for universal ISO week-numbering date, whereas + * `Y` is supposed to be used in conjunction with `w` and `e` + * for week-numbering date specific to the locale. + * - `P` is long localized date format + * - `p` is long localized time format */ -function tagExists(tag) { - try { - // Check if the tag exists locally - (0, child_process_1.execSync)(`git show-ref --tags ${tag}`, { stdio: 'ignore' }); - return true; // Tag exists locally + +const formatters = (exports.formatters = { + // Era + G: function (date, token, localize) { + const era = date.getFullYear() > 0 ? 1 : 0; + switch (token) { + // AD, BC + case "G": + case "GG": + case "GGG": + return localize.era(era, { width: "abbreviated" }); + // A, B + case "GGGGG": + return localize.era(era, { width: "narrow" }); + // Anno Domini, Before Christ + case "GGGG": + default: + return localize.era(era, { width: "wide" }); } - catch (error) { - // Tag does not exist locally, check in remote - let shouldRetry = true; - let needsRepack = false; - let doesTagExist = false; - while (shouldRetry) { - try { - if (needsRepack) { - // We have seen some scenarios where this fixes the git fetch. - // Why? Who knows... https://github.com/Expensify/App/pull/31459 - (0, child_process_1.execSync)('git repack -d', { stdio: 'inherit' }); - } - (0, child_process_1.execSync)(`git ls-remote --exit-code --tags origin ${tag}`, { stdio: 'ignore' }); - doesTagExist = true; - shouldRetry = false; - } - catch (e) { - if (!needsRepack) { - console.log('Attempting to repack and retry...'); - needsRepack = true; - } - else { - console.error("Repack didn't help, giving up..."); - shouldRetry = false; - } - } - } - return doesTagExist; + }, + + // Year + y: function (date, token, localize) { + // Ordinal number + if (token === "yo") { + const signedYear = date.getFullYear(); + // Returns 1 for 1 BC (which is year 0 in JavaScript) + const year = signedYear > 0 ? signedYear : 1 - signedYear; + return localize.ordinalNumber(year, { unit: "year" }); } -} -/** - * This essentially just calls getPreviousVersion in a loop, until it finds a version for which a tag exists. - * It's useful if we manually perform a version bump, because in that case a tag may not exist for the previous version. - * - * @param tag the current tag - * @param level the Semver level to step backward by - */ -function getPreviousExistingTag(tag, level) { - let previousVersion = VersionUpdater.getPreviousVersion(tag, level); - let tagExistsForPreviousVersion = false; - while (!tagExistsForPreviousVersion) { - if (tagExists(previousVersion)) { - tagExistsForPreviousVersion = true; - break; - } - console.log(`Tag for previous version ${previousVersion} does not exist. Checking for an older version...`); - previousVersion = VersionUpdater.getPreviousVersion(previousVersion, level); + + return _index7.lightFormatters.y(date, token); + }, + + // Local week-numbering year + Y: function (date, token, localize, options) { + const signedWeekYear = (0, _index5.getWeekYear)(date, options); + // Returns 1 for 1 BC (which is year 0 in JavaScript) + const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; + + // Two digit year + if (token === "YY") { + const twoDigitYear = weekYear % 100; + return (0, _index6.addLeadingZeros)(twoDigitYear, 2); } - return previousVersion; -} -/** - * @param [shallowExcludeTag] When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) - */ -function fetchTag(tag, shallowExcludeTag = '') { - let shouldRetry = true; - let needsRepack = false; - while (shouldRetry) { - try { - let command = ''; - if (needsRepack) { - // We have seen some scenarios where this fixes the git fetch. - // Why? Who knows... https://github.com/Expensify/App/pull/31459 - command = 'git repack -d'; - console.log(`Running command: ${command}`); - (0, child_process_1.execSync)(command); - } - command = `git fetch origin tag ${tag} --no-tags`; - // Note that this condition is only ever NOT true in the 1.0.0-0 edge case - if (shallowExcludeTag && shallowExcludeTag !== tag) { - command += ` --shallow-exclude=${shallowExcludeTag}`; - } - console.log(`Running command: ${command}`); - (0, child_process_1.execSync)(command); - shouldRetry = false; - } - catch (e) { - console.error(e); - if (!needsRepack) { - console.log('Attempting to repack and retry...'); - needsRepack = true; - } - else { - console.error("Repack didn't help, giving up..."); - shouldRetry = false; - } - } + + // Ordinal number + if (token === "Yo") { + return localize.ordinalNumber(weekYear, { unit: "year" }); + } + + // Padding + return (0, _index6.addLeadingZeros)(weekYear, token.length); + }, + + // ISO week-numbering year + R: function (date, token) { + const isoWeekYear = (0, _index3.getISOWeekYear)(date); + + // Padding + return (0, _index6.addLeadingZeros)(isoWeekYear, token.length); + }, + + // 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: function (date, token) { + const year = date.getFullYear(); + return (0, _index6.addLeadingZeros)(year, token.length); + }, + + // Quarter + Q: function (date, token, localize) { + 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 (0, _index6.addLeadingZeros)(quarter, 2); + // 1st, 2nd, 3rd, 4th + case "Qo": + return localize.ordinalNumber(quarter, { unit: "quarter" }); + // Q1, Q2, Q3, Q4 + case "QQQ": + return localize.quarter(quarter, { + width: "abbreviated", + context: "formatting", + }); + // 1, 2, 3, 4 (narrow quarter; could be not numerical) + case "QQQQQ": + return localize.quarter(quarter, { + width: "narrow", + context: "formatting", + }); + // 1st quarter, 2nd quarter, ... + case "QQQQ": + default: + return localize.quarter(quarter, { + width: "wide", + context: "formatting", + }); + } + }, + + // Stand-alone quarter + q: function (date, token, localize) { + 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 (0, _index6.addLeadingZeros)(quarter, 2); + // 1st, 2nd, 3rd, 4th + case "qo": + return localize.ordinalNumber(quarter, { unit: "quarter" }); + // Q1, Q2, Q3, Q4 + case "qqq": + return localize.quarter(quarter, { + width: "abbreviated", + context: "standalone", + }); + // 1, 2, 3, 4 (narrow quarter; could be not numerical) + case "qqqqq": + return localize.quarter(quarter, { + width: "narrow", + context: "standalone", + }); + // 1st quarter, 2nd quarter, ... + case "qqqq": + default: + return localize.quarter(quarter, { + width: "wide", + context: "standalone", + }); } -} -/** - * Get merge logs between two tags (inclusive) as a JavaScript object. - */ -function getCommitHistoryAsJSON(fromTag, toTag) { - // Fetch tags, excluding commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history - const previousPatchVersion = getPreviousExistingTag(fromTag, VersionUpdater.SEMANTIC_VERSION_LEVELS.PATCH); - fetchTag(fromTag, previousPatchVersion); - fetchTag(toTag, previousPatchVersion); - console.log('Getting pull requests merged between the following tags:', fromTag, toTag); - return new Promise((resolve, reject) => { - let stdout = ''; - let stderr = ''; - const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; - console.log(`Running command: git ${args.join(' ')}`); - const spawnedProcess = (0, child_process_1.spawn)('git', args); - spawnedProcess.on('message', console.log); - spawnedProcess.stdout.on('data', (chunk) => { - console.log(chunk.toString()); - stdout += chunk.toString(); + }, + + // Month + M: function (date, token, localize) { + const month = date.getMonth(); + switch (token) { + case "M": + case "MM": + return _index7.lightFormatters.M(date, token); + // 1st, 2nd, ..., 12th + case "Mo": + return localize.ordinalNumber(month + 1, { unit: "month" }); + // Jan, Feb, ..., Dec + case "MMM": + return localize.month(month, { + width: "abbreviated", + context: "formatting", }); - spawnedProcess.stderr.on('data', (chunk) => { - console.error(chunk.toString()); - stderr += chunk.toString(); + // J, F, ..., D + case "MMMMM": + return localize.month(month, { + width: "narrow", + context: "formatting", }); - spawnedProcess.on('close', (code) => { - if (code !== 0) { - console.log('code: ', code); - return reject(new Error(`${stderr}`)); - } - resolve(stdout); + // January, February, ..., December + case "MMMM": + default: + return localize.month(month, { width: "wide", context: "formatting" }); + } + }, + + // Stand-alone month + L: function (date, token, localize) { + const month = date.getMonth(); + switch (token) { + // 1, 2, ..., 12 + case "L": + return String(month + 1); + // 01, 02, ..., 12 + case "LL": + return (0, _index6.addLeadingZeros)(month + 1, 2); + // 1st, 2nd, ..., 12th + case "Lo": + return localize.ordinalNumber(month + 1, { unit: "month" }); + // Jan, Feb, ..., Dec + case "LLL": + return localize.month(month, { + width: "abbreviated", + context: "standalone", }); - spawnedProcess.on('error', (err) => reject(err)); - }).then((stdout) => { - // Sanitize just the text within commit subjects as that's the only potentially un-parseable text. - const sanitizedOutput = stdout.replace(/(?<="subject": ").*?(?="})/g, (subject) => (0, sanitizeStringForJSONParse_1.default)(subject)); - // Then remove newlines, format as JSON and convert to a proper JS object - const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); - return JSON.parse(json); - }); -} -/** - * Parse merged PRs, excluding those from irrelevant branches. - */ -function getValidMergedPRs(commits) { - const mergedPRs = new Set(); - commits.forEach((commit) => { - const author = commit.authorName; - if (author === CONST_1.default.OS_BOTIFY) { - return; - } - const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/); - if (!Array.isArray(match) || match.length < 2) { - return; - } - const pr = Number.parseInt(match[1], 10); - if (mergedPRs.has(pr)) { - // If a PR shows up in the log twice, that means that the PR was deployed in the previous checklist. - // That also means that we don't want to include it in the current checklist, so we remove it now. - mergedPRs.delete(pr); - return; - } - mergedPRs.add(pr); - }); - return Array.from(mergedPRs); -} -/** - * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags - */ -async function getPullRequestsMergedBetween(fromTag, toTag) { - console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); - const commitList = await getCommitHistoryAsJSON(fromTag, toTag); - console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); - // Find which commit messages correspond to merged PR's - const pullRequestNumbers = getValidMergedPRs(commitList).sort((a, b) => a - b); - console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); - return pullRequestNumbers; -} -exports["default"] = { - getPreviousExistingTag, - getValidMergedPRs, - getPullRequestsMergedBetween, -}; + // J, F, ..., D + case "LLLLL": + return localize.month(month, { + width: "narrow", + context: "standalone", + }); + // January, February, ..., December + case "LLLL": + default: + return localize.month(month, { width: "wide", context: "standalone" }); + } + }, + // Local week of year + w: function (date, token, localize, options) { + const week = (0, _index4.getWeek)(date, options); -/***/ }), + if (token === "wo") { + return localize.ordinalNumber(week, { unit: "week" }); + } -/***/ 9296: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + return (0, _index6.addLeadingZeros)(week, token.length); + }, -"use strict"; + // ISO week of year + I: function (date, token, localize) { + const isoWeek = (0, _index2.getISOWeek)(date); -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -/* eslint-disable @typescript-eslint/naming-convention, import/no-import-module-exports */ -const core = __importStar(__nccwpck_require__(2186)); -const utils_1 = __nccwpck_require__(3030); -const plugin_paginate_rest_1 = __nccwpck_require__(4193); -const plugin_throttling_1 = __nccwpck_require__(9968); -const EmptyObject_1 = __nccwpck_require__(8227); -const arrayDifference_1 = __importDefault(__nccwpck_require__(7034)); -const CONST_1 = __importDefault(__nccwpck_require__(9873)); -class GithubUtils { - static internalOctokit; - /** - * Initialize internal octokit. - * NOTE: When using GithubUtils in CI, you don't need to call this manually. - */ - static initOctokitWithToken(token) { - const Octokit = utils_1.GitHub.plugin(plugin_throttling_1.throttling, plugin_paginate_rest_1.paginateRest); - // Save a copy of octokit used in this class - this.internalOctokit = new Octokit((0, utils_1.getOctokitOptions)(token, { - throttle: { - retryAfterBaseValue: 2000, - onRateLimit: (retryAfter, options) => { - console.warn(`Request quota exhausted for request ${options.method} ${options.url}`); - // Retry five times when hitting a rate limit error, then give up - if (options.request.retryCount <= 5) { - console.log(`Retrying after ${retryAfter} seconds!`); - return true; - } - }, - onAbuseLimit: (retryAfter, options) => { - // does not retry, only logs a warning - console.warn(`Abuse detected for request ${options.method} ${options.url}`); - }, - }, - })); + if (token === "Io") { + return localize.ordinalNumber(isoWeek, { unit: "week" }); } - /** - * Default initialize method assuming running in CI, getting the token from an input. - * - * @private - */ - static initOctokit() { - const token = core.getInput('GITHUB_TOKEN', { required: true }); - this.initOctokitWithToken(token); + + return (0, _index6.addLeadingZeros)(isoWeek, token.length); + }, + + // Day of the month + d: function (date, token, localize) { + if (token === "do") { + return localize.ordinalNumber(date.getDate(), { unit: "date" }); } - /** - * Either give an existing instance of Octokit rest or create a new one - * - * @readonly - * @static - */ - static get octokit() { - if (!this.internalOctokit) { - this.initOctokit(); - } - // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style - return this.internalOctokit.rest; + + return _index7.lightFormatters.d(date, token); + }, + + // Day of year + D: function (date, token, localize) { + const dayOfYear = (0, _index.getDayOfYear)(date); + + if (token === "Do") { + return localize.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); } - /** - * Get the graphql instance from internal octokit. - * @readonly - * @static - */ - static get graphql() { - if (!this.internalOctokit) { - this.initOctokit(); - } - // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style - return this.internalOctokit.graphql; + + return (0, _index6.addLeadingZeros)(dayOfYear, token.length); + }, + + // Day of week + E: function (date, token, localize) { + const dayOfWeek = date.getDay(); + switch (token) { + // Tue + case "E": + case "EE": + case "EEE": + return localize.day(dayOfWeek, { + width: "abbreviated", + context: "formatting", + }); + // T + case "EEEEE": + return localize.day(dayOfWeek, { + width: "narrow", + context: "formatting", + }); + // Tu + case "EEEEEE": + return localize.day(dayOfWeek, { + width: "short", + context: "formatting", + }); + // Tuesday + case "EEEE": + default: + return localize.day(dayOfWeek, { + width: "wide", + context: "formatting", + }); } - /** - * Either give an existing instance of Octokit paginate or create a new one - * - * @readonly - * @static - */ - static get paginate() { - if (!this.internalOctokit) { - this.initOctokit(); - } - // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style - return this.internalOctokit.paginate; + }, + + // Local day of week + e: function (date, token, localize, 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 (0, _index6.addLeadingZeros)(localDayOfWeek, 2); + // 1st, 2nd, ..., 7th + case "eo": + return localize.ordinalNumber(localDayOfWeek, { unit: "day" }); + case "eee": + return localize.day(dayOfWeek, { + width: "abbreviated", + context: "formatting", + }); + // T + case "eeeee": + return localize.day(dayOfWeek, { + width: "narrow", + context: "formatting", + }); + // Tu + case "eeeeee": + return localize.day(dayOfWeek, { + width: "short", + context: "formatting", + }); + // Tuesday + case "eeee": + default: + return localize.day(dayOfWeek, { + width: "wide", + context: "formatting", + }); } - /** - * Finds one open `StagingDeployCash` issue via GitHub octokit library. - */ - static getStagingDeployCash() { - return this.octokit.issues - .listForRepo({ - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - labels: CONST_1.default.LABELS.STAGING_DEPLOY, - state: 'open', - }) - .then(({ data }) => { - if (!data.length) { - throw new Error(`Unable to find ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`); - } - if (data.length > 1) { - throw new Error(`Found more than one ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`); - } - return this.getStagingDeployCashData(data[0]); + }, + + // Stand-alone local day of week + c: function (date, token, localize, 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 (0, _index6.addLeadingZeros)(localDayOfWeek, token.length); + // 1st, 2nd, ..., 7th + case "co": + return localize.ordinalNumber(localDayOfWeek, { unit: "day" }); + case "ccc": + return localize.day(dayOfWeek, { + width: "abbreviated", + context: "standalone", + }); + // T + case "ccccc": + return localize.day(dayOfWeek, { + width: "narrow", + context: "standalone", + }); + // Tu + case "cccccc": + return localize.day(dayOfWeek, { + width: "short", + context: "standalone", + }); + // Tuesday + case "cccc": + default: + return localize.day(dayOfWeek, { + width: "wide", + context: "standalone", }); } - /** - * Takes in a GitHub issue object and returns the data we want. - */ - static getStagingDeployCashData(issue) { - try { - const versionRegex = new RegExp('([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9]+))?', 'g'); - const tag = issue.body?.match(versionRegex)?.[0].replace(/`/g, ''); - return { - title: issue.title, - url: issue.url, - number: this.getIssueOrPullRequestNumberFromURL(issue.url), - labels: issue.labels, - PRList: this.getStagingDeployCashPRList(issue), - deployBlockers: this.getStagingDeployCashDeployBlockers(issue), - internalQAPRList: this.getStagingDeployCashInternalQA(issue), - isTimingDashboardChecked: issue.body ? /-\s\[x]\sI checked the \[App Timing Dashboard]/.test(issue.body) : false, - isFirebaseChecked: issue.body ? /-\s\[x]\sI checked \[Firebase Crashlytics]/.test(issue.body) : false, - isGHStatusChecked: issue.body ? /-\s\[x]\sI checked \[GitHub Status]/.test(issue.body) : false, - tag, - }; - } - catch (exception) { - throw new Error(`Unable to find ${CONST_1.default.LABELS.STAGING_DEPLOY} issue with correct data.`); - } + }, + + // ISO day of week + i: function (date, token, localize) { + const dayOfWeek = date.getDay(); + const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; + switch (token) { + // 2 + case "i": + return String(isoDayOfWeek); + // 02 + case "ii": + return (0, _index6.addLeadingZeros)(isoDayOfWeek, token.length); + // 2nd + case "io": + return localize.ordinalNumber(isoDayOfWeek, { unit: "day" }); + // Tue + case "iii": + return localize.day(dayOfWeek, { + width: "abbreviated", + context: "formatting", + }); + // T + case "iiiii": + return localize.day(dayOfWeek, { + width: "narrow", + context: "formatting", + }); + // Tu + case "iiiiii": + return localize.day(dayOfWeek, { + width: "short", + context: "formatting", + }); + // Tuesday + case "iiii": + default: + return localize.day(dayOfWeek, { + width: "wide", + context: "formatting", + }); } - /** - * Parse the PRList and Internal QA section of the StagingDeployCash issue body. - * - * @private - */ - static getStagingDeployCashPRList(issue) { - let PRListSection = issue.body?.match(/pull requests:\*\*\r?\n((?:-.*\r?\n)+)\r?\n\r?\n?/) ?? null; - if (PRListSection?.length !== 2) { - // No PRs, return an empty array - console.log('Hmmm...The open StagingDeployCash does not list any pull requests, continuing...'); - return []; - } - PRListSection = PRListSection[1]; - const PRList = [...PRListSection.matchAll(new RegExp(`- \\[([ x])] (${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({ - url: match[2], - number: Number.parseInt(match[3], 10), - isVerified: match[1] === 'x', - })); - return PRList.sort((a, b) => a.number - b.number); + }, + + // AM or PM + a: function (date, token, localize) { + const hours = date.getHours(); + const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; + + switch (token) { + case "a": + case "aa": + return localize.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting", + }); + case "aaa": + return localize + .dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting", + }) + .toLowerCase(); + case "aaaaa": + return localize.dayPeriod(dayPeriodEnumValue, { + width: "narrow", + context: "formatting", + }); + case "aaaa": + default: + return localize.dayPeriod(dayPeriodEnumValue, { + width: "wide", + context: "formatting", + }); } - /** - * Parse DeployBlocker section of the StagingDeployCash issue body. - * - * @private - */ - static getStagingDeployCashDeployBlockers(issue) { - let deployBlockerSection = issue.body?.match(/Deploy Blockers:\*\*\r?\n((?:-.*\r?\n)+)/) ?? null; - if (deployBlockerSection?.length !== 2) { - return []; - } - deployBlockerSection = deployBlockerSection[1]; - const deployBlockers = [...deployBlockerSection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.ISSUE_OR_PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({ - url: match[2], - number: Number.parseInt(match[3], 10), - isResolved: match[1] === 'x', - })); - return deployBlockers.sort((a, b) => a.number - b.number); + }, + + // AM, PM, midnight, noon + b: function (date, token, localize) { + 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"; } - /** - * Parse InternalQA section of the StagingDeployCash issue body. - * - * @private - */ - static getStagingDeployCashInternalQA(issue) { - let internalQASection = issue.body?.match(/Internal QA:\*\*\r?\n((?:- \[[ x]].*\r?\n)+)/) ?? null; - if (internalQASection?.length !== 2) { - return []; - } - internalQASection = internalQASection[1]; - const internalQAPRs = [...internalQASection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({ - url: match[2].split('-')[0].trim(), - number: Number.parseInt(match[3], 10), - isResolved: match[1] === 'x', - })); - return internalQAPRs.sort((a, b) => a.number - b.number); + + switch (token) { + case "b": + case "bb": + return localize.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting", + }); + case "bbb": + return localize + .dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting", + }) + .toLowerCase(); + case "bbbbb": + return localize.dayPeriod(dayPeriodEnumValue, { + width: "narrow", + context: "formatting", + }); + case "bbbb": + default: + return localize.dayPeriod(dayPeriodEnumValue, { + width: "wide", + context: "formatting", + }); } - /** - * Generate the issue body and assignees for a StagingDeployCash. - */ - static generateStagingDeployCashBodyAndAssignees(tag, PRList, verifiedPRList = [], deployBlockers = [], resolvedDeployBlockers = [], resolvedInternalQAPRs = [], isTimingDashboardChecked = false, isFirebaseChecked = false, isGHStatusChecked = false) { - return this.fetchAllPullRequests(PRList.map((pr) => this.getPullRequestNumberFromURL(pr))) - .then((data) => { - const internalQAPRs = Array.isArray(data) ? data.filter((pr) => !(0, EmptyObject_1.isEmptyObject)(pr.labels.find((item) => item.name === CONST_1.default.LABELS.INTERNAL_QA))) : []; - return Promise.all(internalQAPRs.map((pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({ url: pr.html_url, mergerLogin })))).then((results) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', - // 'https://github.com/Expensify/App/pull/9642': 'mountiny' - // } - const internalQAPRMap = results.reduce((acc, { url, mergerLogin }) => { - acc[url] = mergerLogin; - return acc; - }, {}); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - const noQAPRs = Array.isArray(data) ? data.filter((PR) => /\[No\s?QA]/i.test(PR.title)).map((item) => item.html_url) : []; - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = [...new Set([...verifiedPRList, ...noQAPRs])]; - const sortedPRList = [...new Set((0, arrayDifference_1.default)(PRList, Object.keys(internalQAPRMap)))].sort((a, b) => GithubUtils.getPullRequestNumberFromURL(a) - GithubUtils.getPullRequestNumberFromURL(b)); - const sortedDeployBlockers = [...new Set(deployBlockers)].sort((a, b) => GithubUtils.getIssueOrPullRequestNumberFromURL(a) - GithubUtils.getIssueOrPullRequestNumberFromURL(b)); - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - // PR list - if (sortedPRList.length > 0) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - sortedPRList.forEach((URL) => { - issueBody += verifiedOrNoQAPRs.includes(URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } - // Internal QA PR list - if (!(0, EmptyObject_1.isEmptyObject)(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - Object.keys(internalQAPRMap).forEach((URL) => { - const merger = internalQAPRMap[URL]; - const mergerMention = `@${merger}`; - issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` - ${mergerMention}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } - // Deploy blockers - if (deployBlockers.length > 0) { - issueBody += '**Deploy Blockers:**\r\n'; - sortedDeployBlockers.forEach((URL) => { - issueBody += resolvedDeployBlockers.includes(URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isTimingDashboardChecked ? 'x' : ' '}] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isFirebaseChecked ? 'x' : ' '}] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - const issueAssignees = [...new Set(Object.values(internalQAPRMap))]; - const issue = { issueBody, issueAssignees }; - return issue; - }); - }) - .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); + }, + + // in the morning, in the afternoon, in the evening, at night + B: function (date, token, localize) { + 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; } - /** - * Fetch all pull requests given a list of PR numbers. - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = pullRequestNumbers.sort((a, b) => a - b)[0]; - return this.paginate(this.octokit.pulls.list, { - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({ data }, done) => { - if (data.find((pr) => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then((prList) => prList.filter((pr) => pullRequestNumbers.includes(pr.number))) - .catch((err) => console.error('Failed to get PR list', err)); + + switch (token) { + case "B": + case "BB": + case "BBB": + return localize.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting", + }); + case "BBBBB": + return localize.dayPeriod(dayPeriodEnumValue, { + width: "narrow", + context: "formatting", + }); + case "BBBB": + default: + return localize.dayPeriod(dayPeriodEnumValue, { + width: "wide", + context: "formatting", + }); } - static getPullRequestMergerLogin(pullRequestNumber) { - return this.octokit.pulls - .get({ - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - pull_number: pullRequestNumber, - }) - .then(({ data: pullRequest }) => pullRequest.merged_by?.login); + }, + + // Hour [1-12] + h: function (date, token, localize) { + if (token === "ho") { + let hours = date.getHours() % 12; + if (hours === 0) hours = 12; + return localize.ordinalNumber(hours, { unit: "hour" }); } - static getPullRequestBody(pullRequestNumber) { - return this.octokit.pulls - .get({ - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - pull_number: pullRequestNumber, - }) - .then(({ data: pullRequestComment }) => pullRequestComment.body); + + return _index7.lightFormatters.h(date, token); + }, + + // Hour [0-23] + H: function (date, token, localize) { + if (token === "Ho") { + return localize.ordinalNumber(date.getHours(), { unit: "hour" }); } - static getAllReviewComments(pullRequestNumber) { - return this.paginate(this.octokit.pulls.listReviews, { - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - pull_number: pullRequestNumber, - per_page: 100, - }, (response) => response.data.map((review) => review.body)); + + return _index7.lightFormatters.H(date, token); + }, + + // Hour [0-11] + K: function (date, token, localize) { + const hours = date.getHours() % 12; + + if (token === "Ko") { + return localize.ordinalNumber(hours, { unit: "hour" }); } - static getAllComments(issueNumber) { - return this.paginate(this.octokit.issues.listComments, { - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - issue_number: issueNumber, - per_page: 100, - }, (response) => response.data.map((comment) => comment.body)); + + return (0, _index6.addLeadingZeros)(hours, token.length); + }, + + // Hour [1-24] + k: function (date, token, localize) { + let hours = date.getHours(); + if (hours === 0) hours = 24; + + if (token === "ko") { + return localize.ordinalNumber(hours, { unit: "hour" }); } - /** - * Create comment on pull request - */ - static createComment(repo, number, messageBody) { - console.log(`Writing comment on #${number}`); - return this.octokit.issues.createComment({ - owner: CONST_1.default.GITHUB_OWNER, - repo, - issue_number: number, - body: messageBody, - }); + + return (0, _index6.addLeadingZeros)(hours, token.length); + }, + + // Minute + m: function (date, token, localize) { + if (token === "mo") { + return localize.ordinalNumber(date.getMinutes(), { unit: "minute" }); } - /** - * Get the most recent workflow run for the given New Expensify workflow. - */ - static getLatestWorkflowRunID(workflow) { - console.log(`Fetching New Expensify workflow runs for ${workflow}...`); - return this.octokit.actions - .listWorkflowRuns({ - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - workflow_id: workflow, - }) - .then((response) => response.data.workflow_runs[0]?.id); + + return _index7.lightFormatters.m(date, token); + }, + + // Second + s: function (date, token, localize) { + if (token === "so") { + return localize.ordinalNumber(date.getSeconds(), { unit: "second" }); } - /** - * Generate the URL of an New Expensify pull request given the PR number. - */ - static getPullRequestURLFromNumber(value) { - return `${CONST_1.default.APP_REPO_URL}/pull/${value}`; + + return _index7.lightFormatters.s(date, token); + }, + + // Fraction of second + S: function (date, token) { + return _index7.lightFormatters.S(date, token); + }, + + // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) + X: function (date, token, _localize) { + const timezoneOffset = date.getTimezoneOffset(); + + if (timezoneOffset === 0) { + return "Z"; } - /** - * Parse the pull request number from a URL. - * - * @throws {Error} If the URL is not a valid Github Pull Request. - */ - static getPullRequestNumberFromURL(URL) { - const matches = URL.match(CONST_1.default.PULL_REQUEST_REGEX); - if (!Array.isArray(matches) || matches.length !== 2) { - throw new Error(`Provided URL ${URL} is not a Github Pull Request!`); - } - return Number.parseInt(matches[1], 10); + + 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": // Hours and minutes without `:` delimiter + 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, ":"); } - /** - * Parse the issue number from a URL. - * - * @throws {Error} If the URL is not a valid Github Issue. - */ - static getIssueNumberFromURL(URL) { - const matches = URL.match(CONST_1.default.ISSUE_REGEX); - if (!Array.isArray(matches) || matches.length !== 2) { - throw new Error(`Provided URL ${URL} is not a Github Issue!`); - } - return Number.parseInt(matches[1], 10); + }, + + // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) + x: 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": // Hours and minutes without `:` delimiter + 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, ":"); + } + }, + + // Timezone (GMT) + O: 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, ":"); + } + }, + + // Timezone (specific non-location) + z: 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, ":"); + } + }, + + // Seconds timestamp + t: function (date, token, _localize) { + const timestamp = Math.trunc(+date / 1000); + return (0, _index6.addLeadingZeros)(timestamp, token.length); + }, + + // Milliseconds timestamp + T: function (date, token, _localize) { + return (0, _index6.addLeadingZeros)(+date, token.length); + }, +}); + +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 + (0, _index6.addLeadingZeros)(minutes, 2) + ); +} + +function formatTimezoneWithOptionalMinutes(offset, delimiter) { + if (offset % 60 === 0) { + const sign = offset > 0 ? "-" : "+"; + return sign + (0, _index6.addLeadingZeros)(Math.abs(offset) / 60, 2); + } + return formatTimezone(offset, delimiter); +} + +function formatTimezone(offset, delimiter = "") { + const sign = offset > 0 ? "-" : "+"; + const absOffset = Math.abs(offset); + const hours = (0, _index6.addLeadingZeros)(Math.trunc(absOffset / 60), 2); + const minutes = (0, _index6.addLeadingZeros)(absOffset % 60, 2); + return sign + hours + delimiter + minutes; +} + + +/***/ }), + +/***/ 8914: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.lightFormatters = void 0; +var _index = __nccwpck_require__(6411); + +/* + * | | Unit | | Unit | + * |-----|--------------------------------|-----|--------------------------------| + * | a | AM, PM | A* | | + * | d | Day of month | D | | + * | h | Hour [1-12] | H | Hour [0-23] | + * | m | Minute | M | Month | + * | s | Second | S | Fraction of second | + * | y | Year (abs) | Y | | + * + * Letters marked by * are not implemented but reserved by Unicode standard. + */ + +const lightFormatters = (exports.lightFormatters = { + // Year + y(date, token) { + // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens + // | Year | y | yy | yyy | yyyy | yyyyy | + // |----------|-------|----|-------|-------|-------| + // | AD 1 | 1 | 01 | 001 | 0001 | 00001 | + // | AD 12 | 12 | 12 | 012 | 0012 | 00012 | + // | AD 123 | 123 | 23 | 123 | 0123 | 00123 | + // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 | + // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 | + + const signedYear = date.getFullYear(); + // Returns 1 for 1 BC (which is year 0 in JavaScript) + const year = signedYear > 0 ? signedYear : 1 - signedYear; + return (0, _index.addLeadingZeros)( + token === "yy" ? year % 100 : year, + token.length, + ); + }, + + // Month + M(date, token) { + const month = date.getMonth(); + return token === "M" + ? String(month + 1) + : (0, _index.addLeadingZeros)(month + 1, 2); + }, + + // Day of the month + d(date, token) { + return (0, _index.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."; } - /** - * Parse the issue or pull request number from a URL. - * - * @throws {Error} If the URL is not a valid Github Issue or Pull Request. - */ - static getIssueOrPullRequestNumberFromURL(URL) { - const matches = URL.match(CONST_1.default.ISSUE_OR_PULL_REQUEST_REGEX); - if (!Array.isArray(matches) || matches.length !== 2) { - throw new Error(`Provided URL ${URL} is not a valid Github Issue or Pull Request!`); - } - return Number.parseInt(matches[1], 10); + }, + + // Hour [1-12] + h(date, token) { + return (0, _index.addLeadingZeros)( + date.getHours() % 12 || 12, + token.length, + ); + }, + + // Hour [0-23] + H(date, token) { + return (0, _index.addLeadingZeros)(date.getHours(), token.length); + }, + + // Minute + m(date, token) { + return (0, _index.addLeadingZeros)(date.getMinutes(), token.length); + }, + + // Second + s(date, token) { + return (0, _index.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 (0, _index.addLeadingZeros)(fractionalSeconds, token.length); + }, +}); + + +/***/ }), + +/***/ 6376: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.longFormatters = void 0; + +const dateLongFormatter = (pattern, formatLong) => { + switch (pattern) { + case "P": + return formatLong.date({ width: "short" }); + case "PP": + return formatLong.date({ width: "medium" }); + case "PPP": + return formatLong.date({ width: "long" }); + case "PPPP": + default: + return formatLong.date({ width: "full" }); + } +}; + +const timeLongFormatter = (pattern, formatLong) => { + switch (pattern) { + case "p": + return formatLong.time({ width: "short" }); + case "pp": + return formatLong.time({ width: "medium" }); + case "ppp": + return formatLong.time({ width: "long" }); + case "pppp": + default: + return formatLong.time({ width: "full" }); + } +}; + +const dateTimeLongFormatter = (pattern, formatLong) => { + const matchResult = pattern.match(/(P+)(p+)?/) || []; + const datePattern = matchResult[1]; + const timePattern = matchResult[2]; + + if (!timePattern) { + return dateLongFormatter(pattern, formatLong); + } + + let dateTimeFormat; + + switch (datePattern) { + case "P": + dateTimeFormat = formatLong.dateTime({ width: "short" }); + break; + case "PP": + dateTimeFormat = formatLong.dateTime({ width: "medium" }); + break; + case "PPP": + dateTimeFormat = formatLong.dateTime({ width: "long" }); + break; + case "PPPP": + default: + dateTimeFormat = formatLong.dateTime({ width: "full" }); + break; + } + + return dateTimeFormat + .replace("{{date}}", dateLongFormatter(datePattern, formatLong)) + .replace("{{time}}", timeLongFormatter(timePattern, formatLong)); +}; + +const longFormatters = (exports.longFormatters = { + p: timeLongFormatter, + P: dateTimeLongFormatter, +}); + + +/***/ }), + +/***/ 1546: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.getTimezoneOffsetInMilliseconds = getTimezoneOffsetInMilliseconds; +var _index = __nccwpck_require__(6439); + +/** + * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds. + * They usually appear for dates that denote time before the timezones were introduced + * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891 + * and GMT+01:00:00 after that date) + * + * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above, + * which would lead to incorrect calculations. + * + * This function returns the timezone offset in milliseconds that takes seconds in account. + */ +function getTimezoneOffsetInMilliseconds(date) { + const _date = (0, _index.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; +} + + +/***/ }), + +/***/ 8897: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.normalizeDates = normalizeDates; +var _index = __nccwpck_require__(926); + +function normalizeDates(context, ...dates) { + const normalize = _index.constructFrom.bind( + null, + context || dates.find((date) => typeof date === "object"), + ); + return dates.map(normalize); +} + + +/***/ }), + +/***/ 3554: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.isProtectedDayOfYearToken = isProtectedDayOfYearToken; +exports.isProtectedWeekYearToken = isProtectedWeekYearToken; +exports.warnOrThrowProtectedError = warnOrThrowProtectedError; +const dayOfYearTokenRE = /^D+$/; +const weekYearTokenRE = /^Y+$/; + +const throwTokens = ["D", "DD", "YY", "YYYY"]; + +function isProtectedDayOfYearToken(token) { + return dayOfYearTokenRE.test(token); +} + +function isProtectedWeekYearToken(token) { + return weekYearTokenRE.test(token); +} + +function warnOrThrowProtectedError(token, format, input) { + const _message = message(token, format, input); + console.warn(_message); + if (throwTokens.includes(token)) throw new RangeError(_message); +} + +function message(token, format, input) { + const subject = token[0] === "Y" ? "years" : "days of the month"; + return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`; +} + + +/***/ }), + +/***/ 4278: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.secondsInYear = + exports.secondsInWeek = + exports.secondsInQuarter = + exports.secondsInMonth = + exports.secondsInMinute = + exports.secondsInHour = + exports.secondsInDay = + exports.quartersInYear = + exports.monthsInYear = + exports.monthsInQuarter = + exports.minutesInYear = + exports.minutesInMonth = + exports.minutesInHour = + exports.minutesInDay = + exports.minTime = + exports.millisecondsInWeek = + exports.millisecondsInSecond = + exports.millisecondsInMinute = + exports.millisecondsInHour = + exports.millisecondsInDay = + exports.maxTime = + exports.daysInYear = + exports.daysInWeek = + exports.constructFromSymbol = + void 0; /** + * @module constants + * @summary Useful constants + * @description + * Collection of useful date constants. + * + * The constants could be imported from `date-fns/constants`: + * + * ```ts + * import { maxTime, minTime } from "date-fns/constants"; + * + * function isAllowedTime(time) { + * return time <= maxTime && time >= minTime; + * } + * ``` + */ + +/** + * @constant + * @name daysInWeek + * @summary Days in 1 week. + */ +const daysInWeek = (exports.daysInWeek = 7); + +/** + * @constant + * @name daysInYear + * @summary Days in 1 year. + * + * @description + * How many days in a year. + * + * One years equals 365.2425 days according to the formula: + * + * > Leap year occurs every 4 years, except for years that are divisible by 100 and not divisible by 400. + * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days + */ +const daysInYear = (exports.daysInYear = 365.2425); + +/** + * @constant + * @name maxTime + * @summary Maximum allowed time. + * + * @example + * import { maxTime } from "date-fns/constants"; + * + * const isValid = 8640000000000001 <= maxTime; + * //=> false + * + * new Date(8640000000000001); + * //=> Invalid Date + */ +const maxTime = (exports.maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000); + +/** + * @constant + * @name minTime + * @summary Minimum allowed time. + * + * @example + * import { minTime } from "date-fns/constants"; + * + * const isValid = -8640000000000001 >= minTime; + * //=> false + * + * new Date(-8640000000000001) + * //=> Invalid Date + */ +const minTime = (exports.minTime = -maxTime); + +/** + * @constant + * @name millisecondsInWeek + * @summary Milliseconds in 1 week. + */ +const millisecondsInWeek = (exports.millisecondsInWeek = 604800000); + +/** + * @constant + * @name millisecondsInDay + * @summary Milliseconds in 1 day. + */ +const millisecondsInDay = (exports.millisecondsInDay = 86400000); + +/** + * @constant + * @name millisecondsInMinute + * @summary Milliseconds in 1 minute + */ +const millisecondsInMinute = (exports.millisecondsInMinute = 60000); + +/** + * @constant + * @name millisecondsInHour + * @summary Milliseconds in 1 hour + */ +const millisecondsInHour = (exports.millisecondsInHour = 3600000); + +/** + * @constant + * @name millisecondsInSecond + * @summary Milliseconds in 1 second + */ +const millisecondsInSecond = (exports.millisecondsInSecond = 1000); + +/** + * @constant + * @name minutesInYear + * @summary Minutes in 1 year. + */ +const minutesInYear = (exports.minutesInYear = 525600); + +/** + * @constant + * @name minutesInMonth + * @summary Minutes in 1 month. + */ +const minutesInMonth = (exports.minutesInMonth = 43200); + +/** + * @constant + * @name minutesInDay + * @summary Minutes in 1 day. + */ +const minutesInDay = (exports.minutesInDay = 1440); + +/** + * @constant + * @name minutesInHour + * @summary Minutes in 1 hour. + */ +const minutesInHour = (exports.minutesInHour = 60); + +/** + * @constant + * @name monthsInQuarter + * @summary Months in 1 quarter. + */ +const monthsInQuarter = (exports.monthsInQuarter = 3); + +/** + * @constant + * @name monthsInYear + * @summary Months in 1 year. + */ +const monthsInYear = (exports.monthsInYear = 12); + +/** + * @constant + * @name quartersInYear + * @summary Quarters in 1 year + */ +const quartersInYear = (exports.quartersInYear = 4); + +/** + * @constant + * @name secondsInHour + * @summary Seconds in 1 hour. + */ +const secondsInHour = (exports.secondsInHour = 3600); + +/** + * @constant + * @name secondsInMinute + * @summary Seconds in 1 minute. + */ +const secondsInMinute = (exports.secondsInMinute = 60); + +/** + * @constant + * @name secondsInDay + * @summary Seconds in 1 day. + */ +const secondsInDay = (exports.secondsInDay = secondsInHour * 24); + +/** + * @constant + * @name secondsInWeek + * @summary Seconds in 1 week. + */ +const secondsInWeek = (exports.secondsInWeek = secondsInDay * 7); + +/** + * @constant + * @name secondsInYear + * @summary Seconds in 1 year. + */ +const secondsInYear = (exports.secondsInYear = secondsInDay * daysInYear); + +/** + * @constant + * @name secondsInMonth + * @summary Seconds in 1 month + */ +const secondsInMonth = (exports.secondsInMonth = secondsInYear / 12); + +/** + * @constant + * @name secondsInQuarter + * @summary Seconds in 1 quarter. + */ +const secondsInQuarter = (exports.secondsInQuarter = secondsInMonth * 3); + +/** + * @constant + * @name constructFromSymbol + * @summary Symbol enabling Date extensions to inherit properties from the reference date. + * + * The symbol is used to enable the `constructFrom` function to construct a date + * using a reference date and a value. It allows to transfer extra properties + * from the reference date to the new date. It's useful for extensions like + * [`TZDate`](https://github.com/date-fns/tz) that accept a time zone as + * a constructor argument. + */ +const constructFromSymbol = (exports.constructFromSymbol = + Symbol.for("constructDateFrom")); + + +/***/ }), + +/***/ 926: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.constructFrom = constructFrom; +var _index = __nccwpck_require__(4278); + +/** + * @name constructFrom + * @category Generic Helpers + * @summary Constructs a date using the reference date and the value + * + * @description + * The function constructs a new date using the constructor from the reference + * date and the given value. It helps to build generic functions that accept + * date extensions. + * + * It defaults to `Date` if the passed reference date is a number or a string. + * + * Starting from v3.7.0, it allows to construct a date using `[Symbol.for("constructDateFrom")]` + * enabling to transfer extra properties from the reference date to the new date. + * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz) + * that accept a time zone as a constructor argument. + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * + * @param date - The reference date to take constructor from + * @param value - The value to create the date + * + * @returns Date initialized using the given date and value + * + * @example + * import { constructFrom } from "date-fns"; + * + * // A function that clones a date preserving the original type + * function cloneDate(date: DateType): DateType { + * return constructFrom( + * date, // Use constructor from the given date + * date.getTime() // Use the date value to create a new date + * ); + * } + */ +function constructFrom(date, value) { + if (typeof date === "function") return date(value); + + if (date && typeof date === "object" && _index.constructFromSymbol in date) + return date[_index.constructFromSymbol](value); + + if (date instanceof Date) return new date.constructor(value); + + return new Date(value); +} + + +/***/ }), + +/***/ 5671: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.differenceInCalendarDays = differenceInCalendarDays; +var _index = __nccwpck_require__(1546); +var _index2 = __nccwpck_require__(8897); +var _index3 = __nccwpck_require__(4278); +var _index4 = __nccwpck_require__(5951); + +/** + * The {@link differenceInCalendarDays} function options. + */ + +/** + * @name differenceInCalendarDays + * @category Day Helpers + * @summary Get the number of calendar days between the given dates. + * + * @description + * Get the number of calendar days between the given dates. This means that the times are removed + * from the dates and then the difference in days is calculated. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - The options object + * + * @returns The number of calendar days + * + * @example + * // How many calendar days are between + * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00? + * const result = differenceInCalendarDays( + * new Date(2012, 6, 2, 0, 0), + * new Date(2011, 6, 2, 23, 0) + * ) + * //=> 366 + * // How many calendar days are between + * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00? + * const result = differenceInCalendarDays( + * new Date(2011, 6, 3, 0, 1), + * new Date(2011, 6, 2, 23, 59) + * ) + * //=> 1 + */ +function differenceInCalendarDays(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = (0, _index2.normalizeDates)( + options?.in, + laterDate, + earlierDate, + ); + + const laterStartOfDay = (0, _index4.startOfDay)(laterDate_); + const earlierStartOfDay = (0, _index4.startOfDay)(earlierDate_); + + const laterTimestamp = + +laterStartOfDay - + (0, _index.getTimezoneOffsetInMilliseconds)(laterStartOfDay); + const earlierTimestamp = + +earlierStartOfDay - + (0, _index.getTimezoneOffsetInMilliseconds)(earlierStartOfDay); + + // Round the number of days to the nearest integer because the number of + // milliseconds in a day is not constant (e.g. it's different in the week of + // the daylight saving time clock shift). + return Math.round( + (laterTimestamp - earlierTimestamp) / _index3.millisecondsInDay, + ); +} + + +/***/ }), + +/***/ 2464: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.format = exports.formatDate = format; +Object.defineProperty(exports, "formatters", ({ + enumerable: true, + get: function () { + return _index3.formatters; + }, +})); +Object.defineProperty(exports, "longFormatters", ({ + enumerable: true, + get: function () { + return _index4.longFormatters; + }, +})); +var _index = __nccwpck_require__(7479); +var _index2 = __nccwpck_require__(5586); +var _index3 = __nccwpck_require__(6615); +var _index4 = __nccwpck_require__(6376); +var _index5 = __nccwpck_require__(3554); + +var _index6 = __nccwpck_require__(6142); +var _index7 = __nccwpck_require__(6439); + +// Rexports of internal for libraries to use. +// See: https://github.com/date-fns/date-fns/issues/3638#issuecomment-1877082874 + +// This RegExp consists of three parts separated by `|`: +// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token +// (one of the certain letters followed by `o`) +// - (\w)\1* matches any sequences of the same letter +// - '' matches two quote characters in a row +// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('), +// except a single quote symbol, which ends the sequence. +// Two quote characters do not end the sequence. +// If there is no matching single quote +// then the sequence will continue until the end of the string. +// - . matches any single character unmatched by previous parts of the RegExps +const formattingTokensRegExp = + /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; + +// This RegExp catches symbols escaped by quotes, and also +// sequences of symbols P, p, and the combinations like `PPPPPPPppppp` +const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; + +const escapedStringRegExp = /^'([^]*?)'?$/; +const doubleQuoteRegExp = /''/g; +const unescapedLatinCharacterRegExp = /[a-zA-Z]/; + +/** + * The {@link format} function options. + */ + +/** + * @name format + * @alias formatDate + * @category Common Helpers + * @summary Format the date. + * + * @description + * Return the formatted date string in the given format. The result may vary by locale. + * + * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries. + * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * The characters wrapped between two single quotes characters (') are escaped. + * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. + * (see the last example) + * + * Format of the string is based on Unicode Technical Standard #35: + * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table + * with a few additions (see note 7 below the table). + * + * Accepted patterns: + * | Unit | Pattern | Result examples | Notes | + * |---------------------------------|---------|-----------------------------------|-------| + * | Era | G..GGG | AD, BC | | + * | | GGGG | Anno Domini, Before Christ | 2 | + * | | GGGGG | A, B | | + * | Calendar year | y | 44, 1, 1900, 2017 | 5 | + * | | yo | 44th, 1st, 0th, 17th | 5,7 | + * | | yy | 44, 01, 00, 17 | 5 | + * | | yyy | 044, 001, 1900, 2017 | 5 | + * | | yyyy | 0044, 0001, 1900, 2017 | 5 | + * | | yyyyy | ... | 3,5 | + * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 | + * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 | + * | | YY | 44, 01, 00, 17 | 5,8 | + * | | YYY | 044, 001, 1900, 2017 | 5 | + * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 | + * | | YYYYY | ... | 3,5 | + * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 | + * | | RR | -43, 00, 01, 1900, 2017 | 5,7 | + * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 | + * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 | + * | | RRRRR | ... | 3,5,7 | + * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 | + * | | uu | -43, 01, 1900, 2017 | 5 | + * | | uuu | -043, 001, 1900, 2017 | 5 | + * | | uuuu | -0043, 0001, 1900, 2017 | 5 | + * | | uuuuu | ... | 3,5 | + * | Quarter (formatting) | Q | 1, 2, 3, 4 | | + * | | Qo | 1st, 2nd, 3rd, 4th | 7 | + * | | QQ | 01, 02, 03, 04 | | + * | | QQQ | Q1, Q2, Q3, Q4 | | + * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 | + * | | QQQQQ | 1, 2, 3, 4 | 4 | + * | Quarter (stand-alone) | q | 1, 2, 3, 4 | | + * | | qo | 1st, 2nd, 3rd, 4th | 7 | + * | | qq | 01, 02, 03, 04 | | + * | | qqq | Q1, Q2, Q3, Q4 | | + * | | qqqq | 1st quarter, 2nd quarter, ... | 2 | + * | | qqqqq | 1, 2, 3, 4 | 4 | + * | Month (formatting) | M | 1, 2, ..., 12 | | + * | | Mo | 1st, 2nd, ..., 12th | 7 | + * | | MM | 01, 02, ..., 12 | | + * | | MMM | Jan, Feb, ..., Dec | | + * | | MMMM | January, February, ..., December | 2 | + * | | MMMMM | J, F, ..., D | | + * | Month (stand-alone) | L | 1, 2, ..., 12 | | + * | | Lo | 1st, 2nd, ..., 12th | 7 | + * | | LL | 01, 02, ..., 12 | | + * | | LLL | Jan, Feb, ..., Dec | | + * | | LLLL | January, February, ..., December | 2 | + * | | LLLLL | J, F, ..., D | | + * | Local week of year | w | 1, 2, ..., 53 | | + * | | wo | 1st, 2nd, ..., 53th | 7 | + * | | ww | 01, 02, ..., 53 | | + * | ISO week of year | I | 1, 2, ..., 53 | 7 | + * | | Io | 1st, 2nd, ..., 53th | 7 | + * | | II | 01, 02, ..., 53 | 7 | + * | Day of month | d | 1, 2, ..., 31 | | + * | | do | 1st, 2nd, ..., 31st | 7 | + * | | dd | 01, 02, ..., 31 | | + * | Day of year | D | 1, 2, ..., 365, 366 | 9 | + * | | Do | 1st, 2nd, ..., 365th, 366th | 7 | + * | | DD | 01, 02, ..., 365, 366 | 9 | + * | | DDD | 001, 002, ..., 365, 366 | | + * | | DDDD | ... | 3 | + * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | | + * | | EEEE | Monday, Tuesday, ..., Sunday | 2 | + * | | EEEEE | M, T, W, T, F, S, S | | + * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | | + * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 | + * | | io | 1st, 2nd, ..., 7th | 7 | + * | | ii | 01, 02, ..., 07 | 7 | + * | | iii | Mon, Tue, Wed, ..., Sun | 7 | + * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 | + * | | iiiii | M, T, W, T, F, S, S | 7 | + * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 | + * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | | + * | | eo | 2nd, 3rd, ..., 1st | 7 | + * | | ee | 02, 03, ..., 01 | | + * | | eee | Mon, Tue, Wed, ..., Sun | | + * | | eeee | Monday, Tuesday, ..., Sunday | 2 | + * | | eeeee | M, T, W, T, F, S, S | | + * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | | + * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | | + * | | co | 2nd, 3rd, ..., 1st | 7 | + * | | cc | 02, 03, ..., 01 | | + * | | ccc | Mon, Tue, Wed, ..., Sun | | + * | | cccc | Monday, Tuesday, ..., Sunday | 2 | + * | | ccccc | M, T, W, T, F, S, S | | + * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | | + * | AM, PM | a..aa | AM, PM | | + * | | aaa | am, pm | | + * | | aaaa | a.m., p.m. | 2 | + * | | aaaaa | a, p | | + * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | | + * | | bbb | am, pm, noon, midnight | | + * | | bbbb | a.m., p.m., noon, midnight | 2 | + * | | bbbbb | a, p, n, mi | | + * | Flexible day period | B..BBB | at night, in the morning, ... | | + * | | BBBB | at night, in the morning, ... | 2 | + * | | BBBBB | at night, in the morning, ... | | + * | Hour [1-12] | h | 1, 2, ..., 11, 12 | | + * | | ho | 1st, 2nd, ..., 11th, 12th | 7 | + * | | hh | 01, 02, ..., 11, 12 | | + * | Hour [0-23] | H | 0, 1, 2, ..., 23 | | + * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 | + * | | HH | 00, 01, 02, ..., 23 | | + * | Hour [0-11] | K | 1, 2, ..., 11, 0 | | + * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 | + * | | KK | 01, 02, ..., 11, 00 | | + * | Hour [1-24] | k | 24, 1, 2, ..., 23 | | + * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 | + * | | kk | 24, 01, 02, ..., 23 | | + * | Minute | m | 0, 1, ..., 59 | | + * | | mo | 0th, 1st, ..., 59th | 7 | + * | | mm | 00, 01, ..., 59 | | + * | Second | s | 0, 1, ..., 59 | | + * | | so | 0th, 1st, ..., 59th | 7 | + * | | ss | 00, 01, ..., 59 | | + * | Fraction of second | S | 0, 1, ..., 9 | | + * | | SS | 00, 01, ..., 99 | | + * | | SSS | 000, 001, ..., 999 | | + * | | SSSS | ... | 3 | + * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | | + * | | XX | -0800, +0530, Z | | + * | | XXX | -08:00, +05:30, Z | | + * | | XXXX | -0800, +0530, Z, +123456 | 2 | + * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | | + * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | | + * | | xx | -0800, +0530, +0000 | | + * | | xxx | -08:00, +05:30, +00:00 | 2 | + * | | xxxx | -0800, +0530, +0000, +123456 | | + * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | | + * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | | + * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 | + * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 | + * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 | + * | Seconds timestamp | t | 512969520 | 7 | + * | | tt | ... | 3,7 | + * | Milliseconds timestamp | T | 512969520900 | 7 | + * | | TT | ... | 3,7 | + * | Long localized date | P | 04/29/1453 | 7 | + * | | PP | Apr 29, 1453 | 7 | + * | | PPP | April 29th, 1453 | 7 | + * | | PPPP | Friday, April 29th, 1453 | 2,7 | + * | Long localized time | p | 12:00 AM | 7 | + * | | pp | 12:00:00 AM | 7 | + * | | ppp | 12:00:00 AM GMT+2 | 7 | + * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 | + * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 | + * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 | + * | | PPPppp | April 29th, 1453 at ... | 7 | + * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 | + * Notes: + * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale + * are the same as "stand-alone" units, but are different in some languages. + * "Formatting" units are declined according to the rules of the language + * in the context of a date. "Stand-alone" units are always nominative singular: + * + * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'` + * + * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'` + * + * 2. Any sequence of the identical letters is a pattern, unless it is escaped by + * the single quote characters (see below). + * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`) + * the output will be the same as default pattern for this unit, usually + * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units + * are marked with "2" in the last column of the table. + * + * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'` + * + * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'` + * + * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'` + * + * 3. Some patterns could be unlimited length (such as `yyyyyyyy`). + * The output will be padded with zeros to match the length of the pattern. + * + * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'` + * + * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales. + * These tokens represent the shortest form of the quarter. + * + * 5. The main difference between `y` and `u` patterns 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: + * + * | Year | `yy` | `uu` | + * |------|------|------| + * | 1 | 01 | 01 | + * | 14 | 14 | 14 | + * | 376 | 76 | 376 | + * | 1453 | 53 | 1453 | + * + * The same difference is true for local and ISO week-numbering years (`Y` and `R`), + * except local week-numbering years are dependent on `options.weekStartsOn` + * and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear) + * and [getWeekYear](https://date-fns.org/docs/getWeekYear)). + * + * 6. Specific non-location timezones are currently unavailable in `date-fns`, + * so right now these tokens fall back to GMT timezones. + * + * 7. These patterns are not in the Unicode Technical Standard #35: + * - `i`: ISO day of week + * - `I`: ISO week of year + * - `R`: ISO week-numbering year + * - `t`: seconds timestamp + * - `T`: milliseconds timestamp + * - `o`: ordinal number modifier + * - `P`: long localized date + * - `p`: long localized time + * + * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years. + * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month. + * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * @param date - The original date + * @param format - The string of tokens + * @param options - An object with options + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `localize` property + * @throws `options.locale` must contain `formatLong` property + * @throws use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @throws use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @throws use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @throws use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @throws format string contains an unescaped latin alphabet character + * + * @example + * // Represent 11 February 2014 in middle-endian format: + * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy') + * //=> '02/11/2014' + * + * @example + * // Represent 2 July 2014 in Esperanto: + * import { eoLocale } from 'date-fns/locale/eo' + * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", { + * locale: eoLocale + * }) + * //=> '2-a de julio 2014' + * + * @example + * // Escape string by single quote characters: + * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'") + * //=> "3 o'clock" + */ +function format(date, formatStr, options) { + const defaultOptions = (0, _index2.getDefaultOptions)(); + const locale = + options?.locale ?? defaultOptions.locale ?? _index.defaultLocale; + + const firstWeekContainsDate = + options?.firstWeekContainsDate ?? + options?.locale?.options?.firstWeekContainsDate ?? + defaultOptions.firstWeekContainsDate ?? + defaultOptions.locale?.options?.firstWeekContainsDate ?? + 1; + + const weekStartsOn = + options?.weekStartsOn ?? + options?.locale?.options?.weekStartsOn ?? + defaultOptions.weekStartsOn ?? + defaultOptions.locale?.options?.weekStartsOn ?? + 0; + + const originalDate = (0, _index7.toDate)(date, options?.in); + + if (!(0, _index6.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 = _index4.longFormatters[firstCharacter]; + return longFormatter(substring, locale.formatLong); + } + return substring; + }) + .join("") + .match(formattingTokensRegExp) + .map((substring) => { + // Replace two single quote characters with one single quote character + if (substring === "''") { + return { isToken: false, value: "'" }; + } + + const firstCharacter = substring[0]; + if (firstCharacter === "'") { + return { isToken: false, value: cleanEscapedString(substring) }; + } + + if (_index3.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 }; + }); + + // invoke localize preprocessor (only for french locales at the moment) + 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 && + (0, _index5.isProtectedWeekYearToken)(token)) || + (!options?.useAdditionalDayOfYearTokens && + (0, _index5.isProtectedDayOfYearToken)(token)) + ) { + (0, _index5.warnOrThrowProtectedError)(token, formatStr, String(date)); + } + + const formatter = _index3.formatters[token[0]]; + return formatter(originalDate, token, locale.localize, formatterOptions); + }) + .join(""); +} + +function cleanEscapedString(input) { + const matched = input.match(escapedStringRegExp); + + if (!matched) { + return input; + } + + return matched[1].replace(doubleQuoteRegExp, "'"); +} + + +/***/ }), + +/***/ 1412: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.getDayOfYear = getDayOfYear; +var _index = __nccwpck_require__(5671); +var _index2 = __nccwpck_require__(8537); +var _index3 = __nccwpck_require__(6439); + +/** + * The {@link getDayOfYear} function options. + */ + +/** + * @name getDayOfYear + * @category Day Helpers + * @summary Get the day of the year of the given date. + * + * @description + * Get the day of the year of the given date. + * + * @param date - The given date + * @param options - The options + * + * @returns The day of year + * + * @example + * // Which day of the year is 2 July 2014? + * const result = getDayOfYear(new Date(2014, 6, 2)) + * //=> 183 + */ +function getDayOfYear(date, options) { + const _date = (0, _index3.toDate)(date, options?.in); + const diff = (0, _index.differenceInCalendarDays)( + _date, + (0, _index2.startOfYear)(_date), + ); + const dayOfYear = diff + 1; + return dayOfYear; +} + + +/***/ }), + +/***/ 6703: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.getISOWeek = getISOWeek; +var _index = __nccwpck_require__(4278); +var _index2 = __nccwpck_require__(8516); +var _index3 = __nccwpck_require__(5437); +var _index4 = __nccwpck_require__(6439); + +/** + * The {@link getISOWeek} function options. + */ + +/** + * @name getISOWeek + * @category ISO Week Helpers + * @summary Get the ISO week of the given date. + * + * @description + * Get the ISO week of the given date. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param date - The given date + * @param options - The options + * + * @returns The ISO week + * + * @example + * // Which week of the ISO-week numbering year is 2 January 2005? + * const result = getISOWeek(new Date(2005, 0, 2)) + * //=> 53 + */ +function getISOWeek(date, options) { + const _date = (0, _index4.toDate)(date, options?.in); + const diff = + +(0, _index2.startOfISOWeek)(_date) - + +(0, _index3.startOfISOWeekYear)(_date); + + // Round the number of weeks to the nearest integer because the number of + // milliseconds in a week is not constant (e.g. it's different in the week of + // the daylight saving time clock shift). + return Math.round(diff / _index.millisecondsInWeek) + 1; +} + + +/***/ }), + +/***/ 7131: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.getISOWeekYear = getISOWeekYear; +var _index = __nccwpck_require__(926); +var _index2 = __nccwpck_require__(8516); +var _index3 = __nccwpck_require__(6439); + +/** + * The {@link getISOWeekYear} function options. + */ + +/** + * @name getISOWeekYear + * @category ISO Week-Numbering Year Helpers + * @summary Get the ISO week-numbering year of the given date. + * + * @description + * Get the ISO week-numbering year of the given date, + * which always starts 3 days before the year's first Thursday. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param date - The given date + * + * @returns The ISO week-numbering year + * + * @example + * // Which ISO-week numbering year is 2 January 2005? + * const result = getISOWeekYear(new Date(2005, 0, 2)) + * //=> 2004 + */ +function getISOWeekYear(date, options) { + const _date = (0, _index3.toDate)(date, options?.in); + const year = _date.getFullYear(); + + const fourthOfJanuaryOfNextYear = (0, _index.constructFrom)(_date, 0); + fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); + fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); + const startOfNextYear = (0, _index2.startOfISOWeek)( + fourthOfJanuaryOfNextYear, + ); + + const fourthOfJanuaryOfThisYear = (0, _index.constructFrom)(_date, 0); + fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); + fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); + const startOfThisYear = (0, _index2.startOfISOWeek)( + fourthOfJanuaryOfThisYear, + ); + + if (_date.getTime() >= startOfNextYear.getTime()) { + return year + 1; + } else if (_date.getTime() >= startOfThisYear.getTime()) { + return year; + } else { + return year - 1; + } +} + + +/***/ }), + +/***/ 3080: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.getWeek = getWeek; +var _index = __nccwpck_require__(4278); +var _index2 = __nccwpck_require__(1284); +var _index3 = __nccwpck_require__(5129); +var _index4 = __nccwpck_require__(6439); + +/** + * The {@link getWeek} function options. + */ + +/** + * @name getWeek + * @category Week Helpers + * @summary Get the local week index of the given date. + * + * @description + * Get the local week index of the given date. + * The exact calculation depends on the values of + * `options.weekStartsOn` (which is the index of the first day of the week) + * and `options.firstWeekContainsDate` (which is the day of January, which is always in + * the first week of the week-numbering year) + * + * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system + * + * @param date - The given date + * @param options - An object with options + * + * @returns The week + * + * @example + * // Which week of the local week numbering year is 2 January 2005 with default options? + * const result = getWeek(new Date(2005, 0, 2)) + * //=> 2 + * + * @example + * // Which week of the local week numbering year is 2 January 2005, + * // if Monday is the first day of the week, + * // and the first week of the year always contains 4 January? + * const result = getWeek(new Date(2005, 0, 2), { + * weekStartsOn: 1, + * firstWeekContainsDate: 4 + * }) + * //=> 53 + */ +function getWeek(date, options) { + const _date = (0, _index4.toDate)(date, options?.in); + const diff = + +(0, _index2.startOfWeek)(_date, options) - + +(0, _index3.startOfWeekYear)(_date, options); + + // Round the number of weeks to the nearest integer because the number of + // milliseconds in a week is not constant (e.g. it's different in the week of + // the daylight saving time clock shift). + return Math.round(diff / _index.millisecondsInWeek) + 1; +} + + +/***/ }), + +/***/ 9116: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.getWeekYear = getWeekYear; +var _index = __nccwpck_require__(5586); +var _index2 = __nccwpck_require__(926); +var _index3 = __nccwpck_require__(1284); +var _index4 = __nccwpck_require__(6439); + +/** + * The {@link getWeekYear} function options. + */ + +/** + * @name getWeekYear + * @category Week-Numbering Year Helpers + * @summary Get the local week-numbering year of the given date. + * + * @description + * Get the local week-numbering year of the given date. + * The exact calculation depends on the values of + * `options.weekStartsOn` (which is the index of the first day of the week) + * and `options.firstWeekContainsDate` (which is the day of January, which is always in + * the first week of the week-numbering year) + * + * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system + * + * @param date - The given date + * @param options - An object with options. + * + * @returns The local week-numbering year + * + * @example + * // Which week numbering year is 26 December 2004 with the default settings? + * const result = getWeekYear(new Date(2004, 11, 26)) + * //=> 2005 + * + * @example + * // Which week numbering year is 26 December 2004 if week starts on Saturday? + * const result = getWeekYear(new Date(2004, 11, 26), { weekStartsOn: 6 }) + * //=> 2004 + * + * @example + * // Which week numbering year is 26 December 2004 if the first week contains 4 January? + * const result = getWeekYear(new Date(2004, 11, 26), { firstWeekContainsDate: 4 }) + * //=> 2004 + */ +function getWeekYear(date, options) { + const _date = (0, _index4.toDate)(date, options?.in); + const year = _date.getFullYear(); + + const defaultOptions = (0, _index.getDefaultOptions)(); + const firstWeekContainsDate = + options?.firstWeekContainsDate ?? + options?.locale?.options?.firstWeekContainsDate ?? + defaultOptions.firstWeekContainsDate ?? + defaultOptions.locale?.options?.firstWeekContainsDate ?? + 1; + + const firstWeekOfNextYear = (0, _index2.constructFrom)( + options?.in || date, + 0, + ); + firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); + firstWeekOfNextYear.setHours(0, 0, 0, 0); + const startOfNextYear = (0, _index3.startOfWeek)( + firstWeekOfNextYear, + options, + ); + + const firstWeekOfThisYear = (0, _index2.constructFrom)( + options?.in || date, + 0, + ); + firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); + firstWeekOfThisYear.setHours(0, 0, 0, 0); + const startOfThisYear = (0, _index3.startOfWeek)( + firstWeekOfThisYear, + options, + ); + + if (+_date >= +startOfNextYear) { + return year + 1; + } else if (+_date >= +startOfThisYear) { + return year; + } else { + return year - 1; + } +} + + +/***/ }), + +/***/ 1652: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.isDate = isDate; /** + * @name isDate + * @category Common Helpers + * @summary Is the given value a date? + * + * @description + * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes. + * + * @param value - The value to check + * + * @returns True if the given value is a date + * + * @example + * // For a valid date: + * const result = isDate(new Date()) + * //=> true + * + * @example + * // For an invalid date: + * const result = isDate(new Date(NaN)) + * //=> true + * + * @example + * // For some value: + * const result = isDate('2014-02-31') + * //=> false + * + * @example + * // For an object: + * const result = isDate({}) + * //=> false + */ +function isDate(value) { + return ( + value instanceof Date || + (typeof value === "object" && + Object.prototype.toString.call(value) === "[object Date]") + ); +} + + +/***/ }), + +/***/ 6142: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.isValid = isValid; +var _index = __nccwpck_require__(1652); +var _index2 = __nccwpck_require__(6439); + +/** + * @name isValid + * @category Common Helpers + * @summary Is the given date valid? + * + * @description + * Returns false if argument is Invalid Date and true otherwise. + * Argument is converted to Date using `toDate`. See [toDate](https://date-fns.org/docs/toDate) + * Invalid Date is a Date, whose time value is NaN. + * + * Time value of Date: http://es5.github.io/#x15.9.1.1 + * + * @param date - The date to check + * + * @returns The date is valid + * + * @example + * // For the valid date: + * const result = isValid(new Date(2014, 1, 31)) + * //=> true + * + * @example + * // For the value, convertible into a date: + * const result = isValid(1393804800000) + * //=> true + * + * @example + * // For the invalid date: + * const result = isValid(new Date('')) + * //=> false + */ +function isValid(date) { + return !( + (!(0, _index.isDate)(date) && typeof date !== "number") || + isNaN(+(0, _index2.toDate)(date)) + ); +} + + +/***/ }), + +/***/ 9566: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.buildFormatLongFn = buildFormatLongFn; + +function buildFormatLongFn(args) { + return (options = {}) => { + // TODO: Remove String() + const width = options.width ? String(options.width) : args.defaultWidth; + const format = args.formats[width] || args.formats[args.defaultWidth]; + return format; + }; +} + + +/***/ }), + +/***/ 4177: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.buildLocalizeFn = buildLocalizeFn; + +/** + * The localize function argument callback which allows to convert raw value to + * the actual type. + * + * @param value - The value to convert + * + * @returns The converted value + */ + +/** + * The map of localized values for each width. + */ + +/** + * The index type of the locale unit value. It types conversion of units of + * values that don't start at 0 (i.e. quarters). + */ + +/** + * Converts the unit value to the tuple of values. + */ + +/** + * The tuple of localized era values. The first element represents BC, + * the second element represents AD. + */ + +/** + * The tuple of localized quarter values. The first element represents Q1. + */ + +/** + * The tuple of localized day values. The first element represents Sunday. + */ + +/** + * The tuple of localized month values. The first element represents January. + */ + +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]; } - /** - * Return the login of the actor who closed an issue or PR. If the issue is not closed, return an empty string. - */ - static getActorWhoClosedIssue(issueNumber) { - return this.paginate(this.octokit.issues.listEvents, { - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - issue_number: issueNumber, - per_page: 100, - }) - .then((events) => events.filter((event) => event.event === 'closed')) - .then((closedEvents) => closedEvents.at(-1)?.actor?.login ?? ''); + const index = args.argumentCallback ? args.argumentCallback(value) : value; + + // @ts-expect-error - For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it! + return valuesArray[index]; + }; +} + + +/***/ }), + +/***/ 3277: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.buildMatchFn = buildMatchFn; + +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; } - /** - * Returns a single artifact by name. If none is found, it returns undefined. - */ - static getArtifactByName(artifactName) { - return this.octokit.actions - .listArtifactsForRepo({ - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - per_page: 1, - name: artifactName, - }) - .then((response) => response.data.artifacts[0]); + 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 }; + }; +} + +function findKey(object, predicate) { + for (const key in object) { + if ( + Object.prototype.hasOwnProperty.call(object, key) && + predicate(object[key]) + ) { + return key; } - /** - * Given an artifact ID, returns the download URL to a zip file containing the artifact. - */ - static getArtifactDownloadURL(artifactId) { - return this.octokit.actions - .downloadArtifact({ - owner: CONST_1.default.GITHUB_OWNER, - repo: CONST_1.default.APP_REPO, - artifact_id: artifactId, - archive_format: 'zip', - }) - .then((response) => response.url); + } + return undefined; +} + +function findIndex(array, predicate) { + for (let key = 0; key < array.length; key++) { + if (predicate(array[key])) { + return key; } + } + return undefined; } -exports["default"] = GithubUtils; -/***/ }), +/***/ }), + +/***/ 8009: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.buildMatchPatternFn = buildMatchPatternFn; + +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]; + + // [TODO] I challenge you to fix the type + value = options.valueCallback ? options.valueCallback(value) : value; + + const rest = string.slice(matchedString.length); + + return { value, rest }; + }; +} + + +/***/ }), + +/***/ 9425: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.enUS = void 0; +var _index = __nccwpck_require__(5436); +var _index2 = __nccwpck_require__(5217); +var _index3 = __nccwpck_require__(1566); +var _index4 = __nccwpck_require__(2720); +var _index5 = __nccwpck_require__(6686); + +/** + * @category Locales + * @summary English locale (United States). + * @language English + * @iso-639-2 eng + * @author Sasha Koss [@kossnocorp](https://github.com/kossnocorp) + * @author Lesha Koss [@leshakoss](https://github.com/leshakoss) + */ +const enUS = (exports.enUS = { + code: "en-US", + formatDistance: _index.formatDistance, + formatLong: _index2.formatLong, + formatRelative: _index3.formatRelative, + localize: _index4.localize, + match: _index5.match, + options: { + weekStartsOn: 0 /* Sunday */, + firstWeekContainsDate: 1, + }, +}); + + +/***/ }), + +/***/ 5436: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.formatDistance = void 0; + +const 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", + }, -/***/ 3902: -/***/ ((__unused_webpack_module, exports) => { + xMonths: { + one: "1 month", + other: "{{count}} months", + }, -"use strict"; + aboutXYears: { + one: "about 1 year", + other: "about {{count}} years", + }, -/* eslint-disable @typescript-eslint/naming-convention */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -const replacer = (str) => ({ - '\\': '\\\\', - '\t': '\\t', - '\n': '\\n', - '\r': '\\r', - '\f': '\\f', - '"': '\\"', -}[str] ?? ''); -/** - * Replace any characters in the string that will break JSON.parse for our Git Log output - * - * Solution partly taken from SO user Gabriel Rodríguez Flores 🙇 - * https://stackoverflow.com/questions/52789718/how-to-remove-special-characters-before-json-parse-while-file-reading - */ -const sanitizeStringForJSONParse = (inputString) => { - if (typeof inputString !== 'string') { - throw new TypeError('Input must me of type String'); + 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", + }, +}; + +const formatDistance = (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"; } - // Replace any newlines and escape backslashes - return inputString.replace(/\\|\t|\n|\r|\f|"/g, replacer); + } + + return result; }; -exports["default"] = sanitizeStringForJSONParse; +exports.formatDistance = formatDistance; /***/ }), -/***/ 8982: -/***/ ((__unused_webpack_module, exports) => { +/***/ 5217: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getPreviousVersion = exports.incrementPatch = exports.incrementMinor = exports.SEMANTIC_VERSION_LEVELS = exports.MAX_INCREMENTS = exports.incrementVersion = exports.getVersionStringFromNumber = exports.getVersionNumberFromString = exports.isValidSemverLevel = void 0; -const SEMANTIC_VERSION_LEVELS = { - MAJOR: 'MAJOR', - MINOR: 'MINOR', - PATCH: 'PATCH', - BUILD: 'BUILD', -}; -exports.SEMANTIC_VERSION_LEVELS = SEMANTIC_VERSION_LEVELS; -const MAX_INCREMENTS = 99; -exports.MAX_INCREMENTS = MAX_INCREMENTS; -function isValidSemverLevel(str) { - return Object.keys(SEMANTIC_VERSION_LEVELS).includes(str); -} -exports.isValidSemverLevel = isValidSemverLevel; -/** - * Transforms a versions string into a number - */ -const getVersionNumberFromString = (versionString) => { - const [version, build] = versionString.split('-'); - const [major, minor, patch] = version.split('.').map((n) => Number(n)); - return [major, minor, patch, Number.isInteger(Number(build)) ? Number(build) : 0]; -}; -exports.getVersionNumberFromString = getVersionNumberFromString; -/** - * Transforms version numbers components into a version string - */ -const getVersionStringFromNumber = (major, minor, patch, build = 0) => `${major}.${minor}.${patch}-${build}`; -exports.getVersionStringFromNumber = getVersionStringFromNumber; -/** - * Increments a minor version - */ -const incrementMinor = (major, minor) => { - if (minor < MAX_INCREMENTS) { - return getVersionStringFromNumber(major, minor + 1, 0, 0); - } - return getVersionStringFromNumber(major + 1, 0, 0, 0); +exports.formatLong = void 0; +var _index = __nccwpck_require__(9566); + +const dateFormats = { + full: "EEEE, MMMM do, y", + long: "MMMM do, y", + medium: "MMM d, y", + short: "MM/dd/yyyy", }; -exports.incrementMinor = incrementMinor; -/** - * Increments a Patch version - */ -const incrementPatch = (major, minor, patch) => { - if (patch < MAX_INCREMENTS) { - return getVersionStringFromNumber(major, minor, patch + 1, 0); - } - return incrementMinor(major, minor); + +const timeFormats = { + full: "h:mm:ss a zzzz", + long: "h:mm:ss a z", + medium: "h:mm:ss a", + short: "h:mm a", }; -exports.incrementPatch = incrementPatch; -/** - * Increments a build version - */ -const incrementVersion = (version, level) => { - const [major, minor, patch, build] = getVersionNumberFromString(version); - // Majors will always be incremented - if (level === SEMANTIC_VERSION_LEVELS.MAJOR) { - return getVersionStringFromNumber(major + 1, 0, 0, 0); - } - if (level === SEMANTIC_VERSION_LEVELS.MINOR) { - return incrementMinor(major, minor); - } - if (level === SEMANTIC_VERSION_LEVELS.PATCH) { - return incrementPatch(major, minor, patch); - } - if (build < MAX_INCREMENTS) { - return getVersionStringFromNumber(major, minor, patch, build + 1); - } - return incrementPatch(major, minor, patch); + +const dateTimeFormats = { + full: "{{date}} 'at' {{time}}", + long: "{{date}} 'at' {{time}}", + medium: "{{date}}, {{time}}", + short: "{{date}}, {{time}}", }; -exports.incrementVersion = incrementVersion; -function getPreviousVersion(currentVersion, level) { - const [major, minor, patch, build] = getVersionNumberFromString(currentVersion); - if (level === SEMANTIC_VERSION_LEVELS.MAJOR) { - if (major === 1) { - return getVersionStringFromNumber(1, 0, 0, 0); - } - return getVersionStringFromNumber(major - 1, 0, 0, 0); - } - if (level === SEMANTIC_VERSION_LEVELS.MINOR) { - if (minor === 0) { - return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.MAJOR); - } - return getVersionStringFromNumber(major, minor - 1, 0, 0); - } - if (level === SEMANTIC_VERSION_LEVELS.PATCH) { - if (patch === 0) { - return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.MINOR); - } - return getVersionStringFromNumber(major, minor, patch - 1, 0); - } - if (build === 0) { - return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.PATCH); - } - return getVersionStringFromNumber(major, minor, patch, build - 1); -} -exports.getPreviousVersion = getPreviousVersion; + +const formatLong = (exports.formatLong = { + date: (0, _index.buildFormatLongFn)({ + formats: dateFormats, + defaultWidth: "full", + }), + + time: (0, _index.buildFormatLongFn)({ + formats: timeFormats, + defaultWidth: "full", + }), + + dateTime: (0, _index.buildFormatLongFn)({ + formats: dateTimeFormats, + defaultWidth: "full", + }), +}); /***/ }), -/***/ 8227: +/***/ 1566: /***/ ((__unused_webpack_module, exports) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isEmptyObject = void 0; -function isEmptyObject(obj) { - return Object.keys(obj ?? {}).length === 0; -} -exports.isEmptyObject = isEmptyObject; +exports.formatRelative = void 0; + +const formatRelativeLocale = { + lastWeek: "'last' eeee 'at' p", + yesterday: "'yesterday at' p", + today: "'today at' p", + tomorrow: "'tomorrow at' p", + nextWeek: "eeee 'at' p", + other: "P", +}; + +const formatRelative = (token, _date, _baseDate, _options) => + formatRelativeLocale[token]; +exports.formatRelative = formatRelative; /***/ }), -/***/ 7034: -/***/ ((__unused_webpack_module, exports) => { +/***/ 2720: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * This function is an equivalent of _.difference, it takes two arrays and returns the difference between them. - * It returns an array of items that are in the first array but not in the second array. - */ -function arrayDifference(array1, array2) { - return [array1, array2].reduce((a, b) => a.filter((c) => !b.includes(c))); -} -exports["default"] = arrayDifference; +exports.localize = void 0; +var _index = __nccwpck_require__(4177); + +const eraValues = { + narrow: ["B", "A"], + abbreviated: ["BC", "AD"], + wide: ["Before Christ", "Anno Domini"], +}; + +const quarterValues = { + narrow: ["1", "2", "3", "4"], + abbreviated: ["Q1", "Q2", "Q3", "Q4"], + wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"], +}; + +// Note: in English, the names of days of the week and months are capitalized. +// If you are making a new locale based on this one, check if the same is true for the language you're working on. +// Generally, formatted dates should look like they are in the middle of a sentence, +// e.g. in Spanish language the weekdays and months should be in the lowercase. +const 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", + ], +}; + +const 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", + ], +}; + +const 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", + }, +}; + +const 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", + }, +}; + +const ordinalNumber = (dirtyNumber, _options) => { + const number = Number(dirtyNumber); + + // If ordinal numbers depend on context, for example, + // if they are different for different grammatical genders, + // use `options.unit`. + // + // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear', + // 'day', 'hour', 'minute', 'second'. + + 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"; +}; + +const localize = (exports.localize = { + ordinalNumber, + + era: (0, _index.buildLocalizeFn)({ + values: eraValues, + defaultWidth: "wide", + }), + + quarter: (0, _index.buildLocalizeFn)({ + values: quarterValues, + defaultWidth: "wide", + argumentCallback: (quarter) => quarter - 1, + }), + + month: (0, _index.buildLocalizeFn)({ + values: monthValues, + defaultWidth: "wide", + }), + + day: (0, _index.buildLocalizeFn)({ + values: dayValues, + defaultWidth: "wide", + }), + + dayPeriod: (0, _index.buildLocalizeFn)({ + values: dayPeriodValues, + defaultWidth: "wide", + formattingValues: formattingDayPeriodValues, + defaultFormattingWidth: "wide", + }), +}); /***/ }), -/***/ 9491: -/***/ ((module) => { +/***/ 6686: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -module.exports = require("assert"); -/***/ }), +exports.match = void 0; -/***/ 2081: -/***/ ((module) => { +var _index = __nccwpck_require__(3277); +var _index2 = __nccwpck_require__(8009); -"use strict"; -module.exports = require("child_process"); +const matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; +const parseOrdinalNumberPattern = /\d+/i; -/***/ }), +const 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, +}; +const parseEraPatterns = { + any: [/^b/i, /^(a|c)/i], +}; -/***/ 6113: -/***/ ((module) => { +const matchQuarterPatterns = { + narrow: /^[1234]/i, + abbreviated: /^q[1234]/i, + wide: /^[1234](th|st|nd|rd)? quarter/i, +}; +const parseQuarterPatterns = { + any: [/1/i, /2/i, /3/i, /4/i], +}; -"use strict"; -module.exports = require("crypto"); +const 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, +}; +const 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, + ], +}; -/***/ }), +const 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, +}; +const 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], +}; -/***/ 3975: -/***/ ((module) => { +const 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, +}; +const 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, + }, +}; -"use strict"; -module.exports = require("encoding"); +const match = (exports.match = { + ordinalNumber: (0, _index2.buildMatchPatternFn)({ + matchPattern: matchOrdinalNumberPattern, + parsePattern: parseOrdinalNumberPattern, + valueCallback: (value) => parseInt(value, 10), + }), -/***/ }), + era: (0, _index.buildMatchFn)({ + matchPatterns: matchEraPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseEraPatterns, + defaultParseWidth: "any", + }), -/***/ 2361: -/***/ ((module) => { + quarter: (0, _index.buildMatchFn)({ + matchPatterns: matchQuarterPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseQuarterPatterns, + defaultParseWidth: "any", + valueCallback: (index) => index + 1, + }), -"use strict"; -module.exports = require("events"); + month: (0, _index.buildMatchFn)({ + matchPatterns: matchMonthPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseMonthPatterns, + defaultParseWidth: "any", + }), -/***/ }), + day: (0, _index.buildMatchFn)({ + matchPatterns: matchDayPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseDayPatterns, + defaultParseWidth: "any", + }), -/***/ 7147: -/***/ ((module) => { + dayPeriod: (0, _index.buildMatchFn)({ + matchPatterns: matchDayPeriodPatterns, + defaultMatchWidth: "any", + parsePatterns: parseDayPeriodPatterns, + defaultParseWidth: "any", + }), +}); -"use strict"; -module.exports = require("fs"); /***/ }), -/***/ 3685: -/***/ ((module) => { +/***/ 5951: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -module.exports = require("http"); -/***/ }), +exports.startOfDay = startOfDay; +var _index = __nccwpck_require__(6439); -/***/ 5687: -/***/ ((module) => { +/** + * The {@link startOfDay} function options. + */ + +/** + * @name startOfDay + * @category Day Helpers + * @summary Return the start of a day for the given date. + * + * @description + * Return the start of a day for the given date. + * The result will be in the local timezone. + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - The options + * + * @returns The start of a day + * + * @example + * // The start of a day for 2 September 2014 11:55:00: + * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 02 2014 00:00:00 + */ +function startOfDay(date, options) { + const _date = (0, _index.toDate)(date, options?.in); + _date.setHours(0, 0, 0, 0); + return _date; +} -"use strict"; -module.exports = require("https"); /***/ }), -/***/ 1808: -/***/ ((module) => { +/***/ 8516: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -module.exports = require("net"); -/***/ }), +exports.startOfISOWeek = startOfISOWeek; +var _index = __nccwpck_require__(1284); -/***/ 2037: -/***/ ((module) => { +/** + * The {@link startOfISOWeek} function options. + */ + +/** + * @name startOfISOWeek + * @category ISO Week Helpers + * @summary Return the start of an ISO week for the given date. + * + * @description + * Return the start of an ISO week for the given date. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The start of an ISO week + * + * @example + * // The start of an ISO week for 2 September 2014 11:55:00: + * const result = startOfISOWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Mon Sep 01 2014 00:00:00 + */ +function startOfISOWeek(date, options) { + return (0, _index.startOfWeek)(date, { ...options, weekStartsOn: 1 }); +} -"use strict"; -module.exports = require("os"); /***/ }), -/***/ 1017: -/***/ ((module) => { +/***/ 5437: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -module.exports = require("path"); -/***/ }), +exports.startOfISOWeekYear = startOfISOWeekYear; +var _index = __nccwpck_require__(926); +var _index2 = __nccwpck_require__(7131); +var _index3 = __nccwpck_require__(8516); -/***/ 5477: -/***/ ((module) => { +/** + * The {@link startOfISOWeekYear} function options. + */ + +/** + * @name startOfISOWeekYear + * @category ISO Week-Numbering Year Helpers + * @summary Return the start of an ISO week-numbering year for the given date. + * + * @description + * Return the start of an ISO week-numbering year, + * which always starts 3 days before the year's first Thursday. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The start of an ISO week-numbering year + * + * @example + * // The start of an ISO week-numbering year for 2 July 2005: + * const result = startOfISOWeekYear(new Date(2005, 6, 2)) + * //=> Mon Jan 03 2005 00:00:00 + */ +function startOfISOWeekYear(date, options) { + const year = (0, _index2.getISOWeekYear)(date, options); + const fourthOfJanuary = (0, _index.constructFrom)(options?.in || date, 0); + fourthOfJanuary.setFullYear(year, 0, 4); + fourthOfJanuary.setHours(0, 0, 0, 0); + return (0, _index3.startOfISOWeek)(fourthOfJanuary); +} -"use strict"; -module.exports = require("punycode"); /***/ }), -/***/ 2781: -/***/ ((module) => { +/***/ 1284: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -module.exports = require("stream"); -/***/ }), +exports.startOfWeek = startOfWeek; +var _index = __nccwpck_require__(5586); +var _index2 = __nccwpck_require__(6439); -/***/ 4404: -/***/ ((module) => { +/** + * The {@link startOfWeek} function options. + */ -"use strict"; -module.exports = require("tls"); +/** + * @name startOfWeek + * @category Week Helpers + * @summary Return the start of a week for the given date. + * + * @description + * Return the start of a week for the given date. + * The result will be in the local timezone. + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The start of a week + * + * @example + * // The start of a week for 2 September 2014 11:55:00: + * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sun Aug 31 2014 00:00:00 + * + * @example + * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00: + * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 }) + * //=> Mon Sep 01 2014 00:00:00 + */ +function startOfWeek(date, options) { + const defaultOptions = (0, _index.getDefaultOptions)(); + const weekStartsOn = + options?.weekStartsOn ?? + options?.locale?.options?.weekStartsOn ?? + defaultOptions.weekStartsOn ?? + defaultOptions.locale?.options?.weekStartsOn ?? + 0; -/***/ }), + const _date = (0, _index2.toDate)(date, options?.in); + const day = _date.getDay(); + const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; -/***/ 7310: -/***/ ((module) => { + _date.setDate(_date.getDate() - diff); + _date.setHours(0, 0, 0, 0); + return _date; +} -"use strict"; -module.exports = require("url"); /***/ }), -/***/ 3837: -/***/ ((module) => { +/***/ 5129: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -module.exports = require("util"); + +exports.startOfWeekYear = startOfWeekYear; +var _index = __nccwpck_require__(5586); +var _index2 = __nccwpck_require__(926); +var _index3 = __nccwpck_require__(9116); +var _index4 = __nccwpck_require__(1284); + +/** + * The {@link startOfWeekYear} function options. + */ + +/** + * @name startOfWeekYear + * @category Week-Numbering Year Helpers + * @summary Return the start of a local week-numbering year for the given date. + * + * @description + * Return the start of a local week-numbering year. + * The exact calculation depends on the values of + * `options.weekStartsOn` (which is the index of the first day of the week) + * and `options.firstWeekContainsDate` (which is the day of January, which is always in + * the first week of the week-numbering year) + * + * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * @typeParam ResultDate - The result `Date` type. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The start of a week-numbering year + * + * @example + * // The start of an a week-numbering year for 2 July 2005 with default settings: + * const result = startOfWeekYear(new Date(2005, 6, 2)) + * //=> Sun Dec 26 2004 00:00:00 + * + * @example + * // The start of a week-numbering year for 2 July 2005 + * // if Monday is the first day of week + * // and 4 January is always in the first week of the year: + * const result = startOfWeekYear(new Date(2005, 6, 2), { + * weekStartsOn: 1, + * firstWeekContainsDate: 4 + * }) + * //=> Mon Jan 03 2005 00:00:00 + */ +function startOfWeekYear(date, options) { + const defaultOptions = (0, _index.getDefaultOptions)(); + const firstWeekContainsDate = + options?.firstWeekContainsDate ?? + options?.locale?.options?.firstWeekContainsDate ?? + defaultOptions.firstWeekContainsDate ?? + defaultOptions.locale?.options?.firstWeekContainsDate ?? + 1; + + const year = (0, _index3.getWeekYear)(date, options); + const firstWeek = (0, _index2.constructFrom)(options?.in || date, 0); + firstWeek.setFullYear(year, 0, firstWeekContainsDate); + firstWeek.setHours(0, 0, 0, 0); + const _date = (0, _index4.startOfWeek)(firstWeek, options); + return _date; +} + /***/ }), -/***/ 9796: -/***/ ((module) => { +/***/ 8537: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -module.exports = require("zlib"); -/***/ }), +exports.startOfYear = startOfYear; +var _index = __nccwpck_require__(6439); -/***/ 3286: -/***/ ((module) => { +/** + * The {@link startOfYear} function options. + */ -function _interopRequireDefault(e) { - return e && e.__esModule ? e : { - "default": e - }; +/** + * @name startOfYear + * @category Year Helpers + * @summary Return the start of a year for the given date. + * + * @description + * Return the start of a year for the given date. + * The result will be in the local timezone. + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - The options + * + * @returns The start of a year + * + * @example + * // The start of a year for 2 September 2014 11:55:00: + * const result = startOfYear(new Date(2014, 8, 2, 11, 55, 00)) + * //=> Wed Jan 01 2014 00:00:00 + */ +function startOfYear(date, options) { + const date_ = (0, _index.toDate)(date, options?.in); + date_.setFullYear(date_.getFullYear(), 0, 1); + date_.setHours(0, 0, 0, 0); + return date_; } -module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports; + /***/ }), -/***/ 5605: -/***/ ((module) => { +/***/ 6439: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; -function _typeof(o) { - "@babel/helpers - typeof"; +exports.toDate = toDate; +var _index = __nccwpck_require__(926); - return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { - return typeof o; - } : function (o) { - return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; - }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); +/** + * @name toDate + * @category Common Helpers + * @summary Convert the given argument to an instance of Date. + * + * @description + * Convert the given argument to an instance of Date. + * + * If the argument is an instance of Date, the function returns its clone. + * + * If the argument is a number, it is treated as a timestamp. + * + * If the argument is none of the above, the function returns Invalid Date. + * + * Starting from v3.7.0, it clones a date using `[Symbol.for("constructDateFrom")]` + * enabling to transfer extra properties from the reference date to the new date. + * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz) + * that accept a time zone as a constructor argument. + * + * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`. + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param argument - The value to convert + * + * @returns The parsed date in the local time zone + * + * @example + * // Clone the date: + * const result = toDate(new Date(2014, 1, 11, 11, 30, 30)) + * //=> Tue Feb 11 2014 11:30:30 + * + * @example + * // Convert the timestamp to date: + * const result = toDate(1392098430000) + * //=> Tue Feb 11 2014 11:30:30 + */ +function toDate(argument, context) { + // [TODO] Get rid of `toDate` or `constructFrom`? + return (0, _index.constructFrom)(context || argument, argument); } -module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; + /***/ }),