diff --git a/.licenses/npm/fast-xml-parser.dep.yml b/.licenses/npm/fast-xml-parser.dep.yml index 11bcccb90..bcfe67052 100644 --- a/.licenses/npm/fast-xml-parser.dep.yml +++ b/.licenses/npm/fast-xml-parser.dep.yml @@ -1,27 +1,11 @@ --- name: fast-xml-parser -version: 3.17.4 +version: 4.0.10 type: npm -summary: Validate XML or Parse XML to JS/JSON very fast without C/C++ based libraries +summary: Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++ based libraries and no callback. homepage: https://github.com/NaturalIntelligence/fast-xml-parser#readme license: mit licenses: - sources: LICENSE - text: "MIT License\n\nCopyright (c) 2017 Amit Kumar Gupta\n\nPermission is hereby - granted, free of charge, to any person obtaining a copy\nof this software and - associated documentation files (the \"Software\"), to deal\nin the Software without - restriction, including without limitation the rights\nto use, copy, modify, merge, - publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit - persons to whom the Software is\nfurnished to do so, subject to the following - conditions:\n\nIf you use this library in a public repository then you give us - the right to mention your company name and logo in user's list without further - permission required, but you can request them to be taken down within 30 days. - \n\nThe above copyright notice and this permission notice shall be included in - all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED - \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT - LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE - AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE - FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR - THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" + text: "MIT License\n\nCopyright (c) 2017 Amit Kumar Gupta\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE." notices: [] diff --git a/.licenses/npm/strnum.dep.yml b/.licenses/npm/strnum.dep.yml new file mode 100644 index 000000000..645c13fc4 --- /dev/null +++ b/.licenses/npm/strnum.dep.yml @@ -0,0 +1,11 @@ +--- +name: strnum +version: 1.0.5 +type: npm +summary: Parse string into Number based on configuration +homepage: https://github.com/NaturalIntelligence/strnum +license: mit +licenses: +- sources: LICENSE + text: "MIT License\n\nCopyright (c) 2021 Natural Intelligence\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE." +notices: [] diff --git a/.licenses/npm/xmlbuilder.dep.yml b/.licenses/npm/xmlbuilder.dep.yml deleted file mode 100644 index 40a3813a3..000000000 --- a/.licenses/npm/xmlbuilder.dep.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: xmlbuilder -version: 13.0.2 -type: npm -summary: An XML builder for node.js -homepage: http://github.com/oozcitak/xmlbuilder-js -license: mit -licenses: -- sources: LICENSE - text: "The MIT License (MIT)\r\n\r\nCopyright (c) 2013 Ozgur Ozcitak\r\n\r\nPermission - is hereby granted, free of charge, to any person obtaining a copy\r\nof this software - and associated documentation files (the \"Software\"), to deal\r\nin the Software - without restriction, including without limitation the rights\r\nto use, copy, - modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, - and to permit persons to whom the Software is\r\nfurnished to do so, subject to - the following conditions:\r\n\r\nThe above copyright notice and this permission - notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE - SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, - INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR - A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR - COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n" -notices: [] diff --git a/dist/index.js b/dist/index.js index 82fb7257a..5d5e6910d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5,146 +5,186 @@ /***/ (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; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.configAuthentication = void 0; -const fs = __importStar(__nccwpck_require__(7147)); -const path = __importStar(__nccwpck_require__(1017)); -const core = __importStar(__nccwpck_require__(2186)); -const github = __importStar(__nccwpck_require__(5438)); -const xmlbuilder = __importStar(__nccwpck_require__(2958)); -const xmlParser = __importStar(__nccwpck_require__(7448)); -function configAuthentication(feedUrl, existingFileLocation = '', processRoot = process.cwd()) { - const existingNuGetConfig = path.resolve(processRoot, existingFileLocation === '' - ? getExistingNugetConfig(processRoot) - : existingFileLocation); - const tempNuGetConfig = path.resolve(processRoot, '../', 'nuget.config'); - writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); -} -exports.configAuthentication = configAuthentication; -function isValidKey(key) { - return /^[\w\-\.]+$/i.test(key); -} -function getExistingNugetConfig(processRoot) { - const defaultConfigName = 'nuget.config'; - const configFileNames = fs - .readdirSync(processRoot) - .filter(filename => filename.toLowerCase() === defaultConfigName); - if (configFileNames.length) { - return configFileNames[0]; - } - return defaultConfigName; -} -function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { - core.info(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`); - let xml; - let sourceKeys = []; - let owner = core.getInput('owner'); - let sourceUrl = feedUrl; - if (!owner) { - owner = github.context.repo.owner; - } - if (!process.env.NUGET_AUTH_TOKEN) { - throw new Error('The NUGET_AUTH_TOKEN environment variable was not provided. In this step, add the following: \r\nenv:\r\n NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}'); - } - if (fs.existsSync(existingFileLocation)) { - // get key from existing NuGet.config so NuGet/dotnet can match credentials - const curContents = fs.readFileSync(existingFileLocation, 'utf8'); - const json = xmlParser.parse(curContents, { ignoreAttributes: false }); - if (typeof json.configuration === 'undefined') { - throw new Error(`The provided NuGet.config seems invalid.`); - } - if (typeof json.configuration.packageSources != 'undefined') { - if (typeof json.configuration.packageSources.add != 'undefined') { - // file has at least one - if (typeof json.configuration.packageSources.add[0] === 'undefined') { - // file has only one - if (json.configuration.packageSources.add['@_value'] - .toLowerCase() - .includes(feedUrl.toLowerCase())) { - const key = json.configuration.packageSources.add['@_key']; - sourceKeys.push(key); - core.debug(`Found a URL with key ${key}`); - } - } - else { - // file has 2+ - for (let i = 0; i < json.configuration.packageSources.add.length; i++) { - const source = json.configuration.packageSources.add[i]; - const value = source['@_value']; - core.debug(`source '${value}'`); - if (value.toLowerCase().includes(feedUrl.toLowerCase())) { - const key = source['@_key']; - sourceKeys.push(key); - core.debug(`Found a URL with key ${key}`); - } - } - } - } - } - } - xml = xmlbuilder - .create('configuration') - .ele('config') - .ele('add', { key: 'defaultPushSource', value: sourceUrl }) - .up() - .up(); - if (!sourceKeys.length) { - let keystring = 'Source'; - xml = xml - .ele('packageSources') - .ele('add', { key: keystring, value: sourceUrl }) - .up() - .up(); - sourceKeys.push(keystring); - } - xml = xml.ele('packageSourceCredentials'); - sourceKeys.forEach(key => { - if (!isValidKey(key)) { - throw new Error("Source name can contain letters, numbers, and '-', '_', '.' symbols only. Please, fix source name in NuGet.config and try again."); - } - xml = xml - .ele(key) - .ele('add', { key: 'Username', value: owner }) - .up() - .ele('add', { - key: 'ClearTextPassword', - value: process.env.NUGET_AUTH_TOKEN - }) - .up() - .up(); - }); - // If NuGet fixes itself such that on Linux it can look for environment variables in the config file (it doesn't seem to work today), - // use this for the value above - // process.platform == 'win32' - // ? '%NUGET_AUTH_TOKEN%' - // : '$NUGET_AUTH_TOKEN' - const output = xml.end({ pretty: true }); - fs.writeFileSync(tempFileLocation, output); -} + +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; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.configAuthentication = void 0; +const fs = __importStar(__nccwpck_require__(7147)); +const path = __importStar(__nccwpck_require__(1017)); +const core = __importStar(__nccwpck_require__(2186)); +const github = __importStar(__nccwpck_require__(5438)); +const fast_xml_parser_1 = __nccwpck_require__(2603); +function configAuthentication(feedUrl, existingFileLocation = '', processRoot = process.cwd()) { + const existingNuGetConfig = path.resolve(processRoot, existingFileLocation === '' + ? getExistingNugetConfig(processRoot) + : existingFileLocation); + const tempNuGetConfig = path.resolve(processRoot, '../', 'nuget.config'); + writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); +} +exports.configAuthentication = configAuthentication; +function isValidKey(key) { + return /^[\w\-\.]+$/i.test(key); +} +function getExistingNugetConfig(processRoot) { + const defaultConfigName = 'nuget.config'; + const configFileNames = fs + .readdirSync(processRoot) + .filter(filename => filename.toLowerCase() === defaultConfigName); + if (configFileNames.length) { + return configFileNames[0]; + } + return defaultConfigName; +} +function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { + var _a, _b; + core.info(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`); + let sourceKeys = []; + let owner = core.getInput('owner'); + let sourceUrl = feedUrl; + if (!owner) { + owner = github.context.repo.owner; + } + if (!process.env.NUGET_AUTH_TOKEN) { + throw new Error('The NUGET_AUTH_TOKEN environment variable was not provided. In this step, add the following: \r\nenv:\r\n NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}'); + } + if (fs.existsSync(existingFileLocation)) { + // get key from existing NuGet.config so NuGet/dotnet can match credentials + const curContents = fs.readFileSync(existingFileLocation, 'utf8'); + const parserOptions = { + ignoreAttributes: false + }; + const parser = new fast_xml_parser_1.XMLParser(parserOptions); + const json = parser.parse(curContents); + if (typeof json.configuration === 'undefined') { + throw new Error(`The provided NuGet.config seems invalid.`); + } + if ((_b = (_a = json.configuration) === null || _a === void 0 ? void 0 : _a.packageSources) === null || _b === void 0 ? void 0 : _b.add) { + const packageSources = json.configuration.packageSources.add; + if (Array.isArray(packageSources)) { + packageSources.forEach(source => { + const value = source['@_value']; + core.debug(`source '${value}'`); + if (value.toLowerCase().includes(feedUrl.toLowerCase())) { + const key = source['@_key']; + sourceKeys.push(key); + core.debug(`Found a URL with key ${key}`); + } + }); + } + else { + if (packageSources['@_value'] + .toLowerCase() + .includes(feedUrl.toLowerCase())) { + const key = packageSources['@_key']; + sourceKeys.push(key); + core.debug(`Found a URL with key ${key}`); + } + } + } + } + const xmlSource = [ + { + '?xml': [ + { + '#text': '' + } + ], + ':@': { + '@_version': '1.0' + } + }, + { + configuration: [ + { + config: [ + { + add: [], + ':@': { + '@_key': 'defaultPushSource', + '@_value': sourceUrl + } + } + ] + } + ] + } + ]; + if (!sourceKeys.length) { + let keystring = 'Source'; + xmlSource[1].configuration.push({ + packageSources: [ + { + add: [], + ':@': { + '@_key': keystring, + '@_value': sourceUrl + } + } + ] + }); + sourceKeys.push(keystring); + } + const packageSourceCredentials = []; + sourceKeys.forEach(key => { + if (!isValidKey(key)) { + throw new Error("Source name can contain letters, numbers, and '-', '_', '.' symbols only. Please, fix source name in NuGet.config and try again."); + } + packageSourceCredentials.push({ + [key]: [ + { + add: [], + ':@': { + '@_key': 'Username', + '@_value': owner + } + }, + { + add: [], + ':@': { + '@_key': 'ClearTextPassword', + '@_value': process.env.NUGET_AUTH_TOKEN + } + } + ] + }); + }); + xmlSource[1].configuration.push({ + packageSourceCredentials + }); + const xmlBuilderOptions = { + format: true, + ignoreAttributes: false, + preserveOrder: true, + allowBooleanAttributes: true, + suppressBooleanAttributes: true, + suppressEmptyNode: true + }; + const builder = new fast_xml_parser_1.XMLBuilder(xmlBuilderOptions); + const output = builder.build(xmlSource).trim(); + fs.writeFileSync(tempFileLocation, output); +} /***/ }), @@ -153,251 +193,251 @@ function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { /***/ (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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var _a; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.DotnetCoreInstaller = exports.DotnetVersionResolver = void 0; -// Load tempDirectory before it gets wiped by tool-cache -const core = __importStar(__nccwpck_require__(2186)); -const exec = __importStar(__nccwpck_require__(1514)); -const io = __importStar(__nccwpck_require__(7436)); -const hc = __importStar(__nccwpck_require__(6255)); -const fs_1 = __nccwpck_require__(7147); -const promises_1 = __nccwpck_require__(3292); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const os_1 = __importDefault(__nccwpck_require__(2037)); -const semver_1 = __importDefault(__nccwpck_require__(5911)); -const utils_1 = __nccwpck_require__(918); -class DotnetVersionResolver { - constructor(version) { - this.inputVersion = version.trim(); - this.resolvedArgument = { type: '', value: '', qualityFlag: false }; - } - resolveVersionInput() { - return __awaiter(this, void 0, void 0, function* () { - if (!semver_1.default.validRange(this.inputVersion)) { - throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x`); - } - if (semver_1.default.valid(this.inputVersion)) { - this.resolvedArgument.type = 'version'; - this.resolvedArgument.value = this.inputVersion; - } - else { - const [major, minor] = this.inputVersion.split('.'); - if (this.isNumericTag(major)) { - this.resolvedArgument.type = 'channel'; - if (this.isNumericTag(minor)) { - this.resolvedArgument.value = `${major}.${minor}`; - } - else { - const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { - allowRetries: true, - maxRetries: 3 - }); - this.resolvedArgument.value = yield this.getLatestVersion(httpClient, [major, minor]); - } - } - this.resolvedArgument.qualityFlag = +major >= 6 ? true : false; - } - }); - } - isNumericTag(versionTag) { - return /^\d+$/.test(versionTag); - } - createDotNetVersion() { - return __awaiter(this, void 0, void 0, function* () { - yield this.resolveVersionInput(); - if (!this.resolvedArgument.type) { - return this.resolvedArgument; - } - if (utils_1.IS_WINDOWS) { - this.resolvedArgument.type = - this.resolvedArgument.type === 'channel' ? '-Channel' : '-Version'; - } - else { - this.resolvedArgument.type = - this.resolvedArgument.type === 'channel' ? '--channel' : '--version'; - } - return this.resolvedArgument; - }); - } - getLatestVersion(httpClient, versionParts) { - return __awaiter(this, void 0, void 0, function* () { - const response = yield httpClient.getJson(DotnetVersionResolver.DotNetCoreIndexUrl); - const result = response.result || {}; - let releasesInfo = result['releases-index']; - let releaseInfo = releasesInfo.find(info => { - let sdkParts = info['channel-version'].split('.'); - return sdkParts[0] === versionParts[0]; - }); - if (!releaseInfo) { - throw new Error(`Could not find info for version ${versionParts.join('.')} at ${DotnetVersionResolver.DotNetCoreIndexUrl}`); - } - return releaseInfo['channel-version']; - }); - } -} -exports.DotnetVersionResolver = DotnetVersionResolver; -DotnetVersionResolver.DotNetCoreIndexUrl = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json'; -class DotnetCoreInstaller { - constructor(version, quality) { - this.version = version; - this.quality = quality; - } - static convertInstallPathToAbsolute(installDir) { - let transformedPath; - if (path_1.default.isAbsolute(installDir)) { - transformedPath = installDir; - } - else { - transformedPath = installDir.startsWith('~') - ? path_1.default.join(os_1.default.homedir(), installDir.slice(1)) - : (transformedPath = path_1.default.join(process.cwd(), installDir)); - } - return path_1.default.normalize(transformedPath); - } - static addToPath() { - core.addPath(process.env['DOTNET_INSTALL_DIR']); - core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']); - } - setQuality(dotnetVersion, scriptArguments) { - const option = utils_1.IS_WINDOWS ? '-Quality' : '--quality'; - if (dotnetVersion.qualityFlag) { - scriptArguments.push(option, this.quality); - } - else { - core.warning(`'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A and A.x formats where the major tag is higher than 5. You specified: ${this.version}. 'dotnet-quality' input is ignored.`); - } - } - installDotnet() { - return __awaiter(this, void 0, void 0, function* () { - const windowsDefaultOptions = [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command' - ]; - const scriptName = utils_1.IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; - const escapedScript = path_1.default - .join(__dirname, '..', 'externals', scriptName) - .replace(/'/g, "''"); - let scriptArguments; - let scriptPath = ''; - const versionResolver = new DotnetVersionResolver(this.version); - const dotnetVersion = yield versionResolver.createDotNetVersion(); - if (utils_1.IS_WINDOWS) { - scriptArguments = ['&', `'${escapedScript}'`]; - if (dotnetVersion.type) { - scriptArguments.push(dotnetVersion.type, dotnetVersion.value); - } - if (this.quality) { - this.setQuality(dotnetVersion, scriptArguments); - } - if (process.env['https_proxy'] != null) { - scriptArguments.push(`-ProxyAddress ${process.env['https_proxy']}`); - } - // This is not currently an option - if (process.env['no_proxy'] != null) { - scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); - } - scriptPath = - (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); - scriptArguments = windowsDefaultOptions.concat(scriptArguments); - } - else { - (0, fs_1.chmodSync)(escapedScript, '777'); - scriptPath = yield io.which(escapedScript, true); - scriptArguments = []; - if (dotnetVersion.type) { - scriptArguments.push(dotnetVersion.type, dotnetVersion.value); - } - if (this.quality) { - this.setQuality(dotnetVersion, scriptArguments); - } - } - // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used - const getExecOutputOptions = { - ignoreReturnCode: true, - env: process.env - }; - const { exitCode, stdout } = yield exec.getExecOutput(`"${scriptPath}"`, scriptArguments, getExecOutputOptions); - if (exitCode) { - throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`); - } - return this.outputDotnetVersion(dotnetVersion.value); - }); - } - outputDotnetVersion(version) { - return __awaiter(this, void 0, void 0, function* () { - const installationPath = process.env['DOTNET_INSTALL_DIR']; - let versionsOnRunner = yield (0, promises_1.readdir)(path_1.default.join(installationPath.replace(/'/g, ''), 'sdk')); - let installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version, { - includePrerelease: true - }); - return installedVersion; - }); - } -} -exports.DotnetCoreInstaller = DotnetCoreInstaller; -_a = DotnetCoreInstaller; -(() => { - const installationDirectoryWindows = path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet'); - const installationDirectoryLinux = '/usr/share/dotnet'; - const installationDirectoryMac = path_1.default.join(process.env['HOME'] + '', '.dotnet'); - const dotnetInstallDir = process.env['DOTNET_INSTALL_DIR']; - if (dotnetInstallDir) { - process.env['DOTNET_INSTALL_DIR'] = - _a.convertInstallPathToAbsolute(dotnetInstallDir); - } - else { - if (utils_1.IS_WINDOWS) { - process.env['DOTNET_INSTALL_DIR'] = installationDirectoryWindows; - } - else { - process.env['DOTNET_INSTALL_DIR'] = utils_1.IS_LINUX - ? installationDirectoryLinux - : installationDirectoryMac; - } - } -})(); + +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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +var _a; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.DotnetCoreInstaller = exports.DotnetVersionResolver = void 0; +// Load tempDirectory before it gets wiped by tool-cache +const core = __importStar(__nccwpck_require__(2186)); +const exec = __importStar(__nccwpck_require__(1514)); +const io = __importStar(__nccwpck_require__(7436)); +const hc = __importStar(__nccwpck_require__(6255)); +const fs_1 = __nccwpck_require__(7147); +const promises_1 = __nccwpck_require__(3292); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const os_1 = __importDefault(__nccwpck_require__(2037)); +const semver_1 = __importDefault(__nccwpck_require__(5911)); +const utils_1 = __nccwpck_require__(918); +class DotnetVersionResolver { + constructor(version) { + this.inputVersion = version.trim(); + this.resolvedArgument = { type: '', value: '', qualityFlag: false }; + } + resolveVersionInput() { + return __awaiter(this, void 0, void 0, function* () { + if (!semver_1.default.validRange(this.inputVersion)) { + throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x`); + } + if (semver_1.default.valid(this.inputVersion)) { + this.resolvedArgument.type = 'version'; + this.resolvedArgument.value = this.inputVersion; + } + else { + const [major, minor] = this.inputVersion.split('.'); + if (this.isNumericTag(major)) { + this.resolvedArgument.type = 'channel'; + if (this.isNumericTag(minor)) { + this.resolvedArgument.value = `${major}.${minor}`; + } + else { + const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { + allowRetries: true, + maxRetries: 3 + }); + this.resolvedArgument.value = yield this.getLatestVersion(httpClient, [major, minor]); + } + } + this.resolvedArgument.qualityFlag = +major >= 6 ? true : false; + } + }); + } + isNumericTag(versionTag) { + return /^\d+$/.test(versionTag); + } + createDotNetVersion() { + return __awaiter(this, void 0, void 0, function* () { + yield this.resolveVersionInput(); + if (!this.resolvedArgument.type) { + return this.resolvedArgument; + } + if (utils_1.IS_WINDOWS) { + this.resolvedArgument.type = + this.resolvedArgument.type === 'channel' ? '-Channel' : '-Version'; + } + else { + this.resolvedArgument.type = + this.resolvedArgument.type === 'channel' ? '--channel' : '--version'; + } + return this.resolvedArgument; + }); + } + getLatestVersion(httpClient, versionParts) { + return __awaiter(this, void 0, void 0, function* () { + const response = yield httpClient.getJson(DotnetVersionResolver.DotNetCoreIndexUrl); + const result = response.result || {}; + let releasesInfo = result['releases-index']; + let releaseInfo = releasesInfo.find(info => { + let sdkParts = info['channel-version'].split('.'); + return sdkParts[0] === versionParts[0]; + }); + if (!releaseInfo) { + throw new Error(`Could not find info for version ${versionParts.join('.')} at ${DotnetVersionResolver.DotNetCoreIndexUrl}`); + } + return releaseInfo['channel-version']; + }); + } +} +exports.DotnetVersionResolver = DotnetVersionResolver; +DotnetVersionResolver.DotNetCoreIndexUrl = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json'; +class DotnetCoreInstaller { + constructor(version, quality) { + this.version = version; + this.quality = quality; + } + static convertInstallPathToAbsolute(installDir) { + let transformedPath; + if (path_1.default.isAbsolute(installDir)) { + transformedPath = installDir; + } + else { + transformedPath = installDir.startsWith('~') + ? path_1.default.join(os_1.default.homedir(), installDir.slice(1)) + : (transformedPath = path_1.default.join(process.cwd(), installDir)); + } + return path_1.default.normalize(transformedPath); + } + static addToPath() { + core.addPath(process.env['DOTNET_INSTALL_DIR']); + core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']); + } + setQuality(dotnetVersion, scriptArguments) { + const option = utils_1.IS_WINDOWS ? '-Quality' : '--quality'; + if (dotnetVersion.qualityFlag) { + scriptArguments.push(option, this.quality); + } + else { + core.warning(`'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A and A.x formats where the major tag is higher than 5. You specified: ${this.version}. 'dotnet-quality' input is ignored.`); + } + } + installDotnet() { + return __awaiter(this, void 0, void 0, function* () { + const windowsDefaultOptions = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command' + ]; + const scriptName = utils_1.IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; + const escapedScript = path_1.default + .join(__dirname, '..', 'externals', scriptName) + .replace(/'/g, "''"); + let scriptArguments; + let scriptPath = ''; + const versionResolver = new DotnetVersionResolver(this.version); + const dotnetVersion = yield versionResolver.createDotNetVersion(); + if (utils_1.IS_WINDOWS) { + scriptArguments = ['&', `'${escapedScript}'`]; + if (dotnetVersion.type) { + scriptArguments.push(dotnetVersion.type, dotnetVersion.value); + } + if (this.quality) { + this.setQuality(dotnetVersion, scriptArguments); + } + if (process.env['https_proxy'] != null) { + scriptArguments.push(`-ProxyAddress ${process.env['https_proxy']}`); + } + // This is not currently an option + if (process.env['no_proxy'] != null) { + scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); + } + scriptPath = + (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); + scriptArguments = windowsDefaultOptions.concat(scriptArguments); + } + else { + (0, fs_1.chmodSync)(escapedScript, '777'); + scriptPath = yield io.which(escapedScript, true); + scriptArguments = []; + if (dotnetVersion.type) { + scriptArguments.push(dotnetVersion.type, dotnetVersion.value); + } + if (this.quality) { + this.setQuality(dotnetVersion, scriptArguments); + } + } + // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used + const getExecOutputOptions = { + ignoreReturnCode: true, + env: process.env + }; + const { exitCode, stdout } = yield exec.getExecOutput(`"${scriptPath}"`, scriptArguments, getExecOutputOptions); + if (exitCode) { + throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`); + } + return this.outputDotnetVersion(dotnetVersion.value); + }); + } + outputDotnetVersion(version) { + return __awaiter(this, void 0, void 0, function* () { + const installationPath = process.env['DOTNET_INSTALL_DIR']; + let versionsOnRunner = yield (0, promises_1.readdir)(path_1.default.join(installationPath.replace(/'/g, ''), 'sdk')); + let installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version, { + includePrerelease: true + }); + return installedVersion; + }); + } +} +exports.DotnetCoreInstaller = DotnetCoreInstaller; +_a = DotnetCoreInstaller; +(() => { + const installationDirectoryWindows = path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet'); + const installationDirectoryLinux = '/usr/share/dotnet'; + const installationDirectoryMac = path_1.default.join(process.env['HOME'] + '', '.dotnet'); + const dotnetInstallDir = process.env['DOTNET_INSTALL_DIR']; + if (dotnetInstallDir) { + process.env['DOTNET_INSTALL_DIR'] = + _a.convertInstallPathToAbsolute(dotnetInstallDir); + } + else { + if (utils_1.IS_WINDOWS) { + process.env['DOTNET_INSTALL_DIR'] = installationDirectoryWindows; + } + else { + process.env['DOTNET_INSTALL_DIR'] = utils_1.IS_LINUX + ? installationDirectoryLinux + : installationDirectoryMac; + } + } +})(); /***/ }), @@ -406,138 +446,138 @@ _a = DotnetCoreInstaller; /***/ (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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.run = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const installer_1 = __nccwpck_require__(1480); -const fs = __importStar(__nccwpck_require__(7147)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const semver_1 = __importDefault(__nccwpck_require__(5911)); -const auth = __importStar(__nccwpck_require__(8527)); -const qualityOptions = [ - 'daily', - 'signed', - 'validated', - 'preview', - 'ga' -]; -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - // - // dotnet-version is optional, but needs to be provided for most use cases. - // If supplied, install / use from the tool cache. - // global-version-file may be specified to point to a specific global.json - // and will be used to install an additional version. - // If not supplied, look for version in ./global.json. - // If a valid version still can't be identified, nothing will be installed. - // Proxy, auth, (etc) are still set up, even if no version is identified - // - const versions = core.getMultilineInput('dotnet-version'); - const installedDotnetVersions = []; - const globalJsonFileInput = core.getInput('global-json-file'); - if (globalJsonFileInput) { - const globalJsonPath = path_1.default.join(process.cwd(), globalJsonFileInput); - if (!fs.existsSync(globalJsonPath)) { - throw new Error(`The specified global.json file '${globalJsonFileInput}' does not exist`); - } - versions.push(getVersionFromGlobalJson(globalJsonPath)); - } - if (!versions.length) { - // Try to fall back to global.json - core.debug('No version found, trying to find version from global.json'); - const globalJsonPath = path_1.default.join(process.cwd(), 'global.json'); - if (fs.existsSync(globalJsonPath)) { - versions.push(getVersionFromGlobalJson(globalJsonPath)); - } - } - if (versions.length) { - const quality = core.getInput('dotnet-quality'); - if (quality && !qualityOptions.includes(quality)) { - throw new Error(`${quality} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`); - } - let dotnetInstaller; - const uniqueVersions = new Set(versions); - for (const version of uniqueVersions) { - dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality); - const installedVersion = yield dotnetInstaller.installDotnet(); - installedDotnetVersions.push(installedVersion); - } - installer_1.DotnetCoreInstaller.addToPath(); - } - const sourceUrl = core.getInput('source-url'); - const configFile = core.getInput('config-file'); - if (sourceUrl) { - auth.configAuthentication(sourceUrl, configFile); - } - const comparisonRange = globalJsonFileInput - ? versions[versions.length - 1] - : '*'; - const versionToOutput = semver_1.default.maxSatisfying(installedDotnetVersions, comparisonRange, { - includePrerelease: true - }); - core.setOutput('dotnet-version', versionToOutput); - const matchersPath = path_1.default.join(__dirname, '..', '.github'); - core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`); - } - catch (error) { - core.setFailed(error.message); - } - }); -} -exports.run = run; -function getVersionFromGlobalJson(globalJsonPath) { - let version = ''; - const globalJson = JSON.parse( - // .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649 - fs.readFileSync(globalJsonPath, { encoding: 'utf8' }).trim()); - if (globalJson.sdk && globalJson.sdk.version) { - version = globalJson.sdk.version; - const rollForward = globalJson.sdk.rollForward; - if (rollForward && rollForward === 'latestFeature') { - const [major, minor] = version.split('.'); - version = `${major}.${minor}`; - } - } - return version; -} -run(); + +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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.run = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const installer_1 = __nccwpck_require__(1480); +const fs = __importStar(__nccwpck_require__(7147)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const semver_1 = __importDefault(__nccwpck_require__(5911)); +const auth = __importStar(__nccwpck_require__(8527)); +const qualityOptions = [ + 'daily', + 'signed', + 'validated', + 'preview', + 'ga' +]; +function run() { + return __awaiter(this, void 0, void 0, function* () { + try { + // + // dotnet-version is optional, but needs to be provided for most use cases. + // If supplied, install / use from the tool cache. + // global-version-file may be specified to point to a specific global.json + // and will be used to install an additional version. + // If not supplied, look for version in ./global.json. + // If a valid version still can't be identified, nothing will be installed. + // Proxy, auth, (etc) are still set up, even if no version is identified + // + const versions = core.getMultilineInput('dotnet-version'); + const installedDotnetVersions = []; + const globalJsonFileInput = core.getInput('global-json-file'); + if (globalJsonFileInput) { + const globalJsonPath = path_1.default.join(process.cwd(), globalJsonFileInput); + if (!fs.existsSync(globalJsonPath)) { + throw new Error(`The specified global.json file '${globalJsonFileInput}' does not exist`); + } + versions.push(getVersionFromGlobalJson(globalJsonPath)); + } + if (!versions.length) { + // Try to fall back to global.json + core.debug('No version found, trying to find version from global.json'); + const globalJsonPath = path_1.default.join(process.cwd(), 'global.json'); + if (fs.existsSync(globalJsonPath)) { + versions.push(getVersionFromGlobalJson(globalJsonPath)); + } + } + if (versions.length) { + const quality = core.getInput('dotnet-quality'); + if (quality && !qualityOptions.includes(quality)) { + throw new Error(`${quality} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`); + } + let dotnetInstaller; + const uniqueVersions = new Set(versions); + for (const version of uniqueVersions) { + dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality); + const installedVersion = yield dotnetInstaller.installDotnet(); + installedDotnetVersions.push(installedVersion); + } + installer_1.DotnetCoreInstaller.addToPath(); + } + const sourceUrl = core.getInput('source-url'); + const configFile = core.getInput('config-file'); + if (sourceUrl) { + auth.configAuthentication(sourceUrl, configFile); + } + const comparisonRange = globalJsonFileInput + ? versions[versions.length - 1] + : '*'; + const versionToOutput = semver_1.default.maxSatisfying(installedDotnetVersions, comparisonRange, { + includePrerelease: true + }); + core.setOutput('dotnet-version', versionToOutput); + const matchersPath = path_1.default.join(__dirname, '..', '.github'); + core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`); + } + catch (error) { + core.setFailed(error.message); + } + }); +} +exports.run = run; +function getVersionFromGlobalJson(globalJsonPath) { + let version = ''; + const globalJson = JSON.parse( + // .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649 + fs.readFileSync(globalJsonPath, { encoding: 'utf8' }).trim()); + if (globalJson.sdk && globalJson.sdk.version) { + version = globalJson.sdk.version; + const rollForward = globalJson.sdk.rollForward; + if (rollForward && rollForward === 'latestFeature') { + const [major, minor] = version.split('.'); + version = `${major}.${minor}`; + } + } + return version; +} +run(); /***/ }), @@ -546,11 +586,11 @@ run(); /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.IS_LINUX = exports.IS_WINDOWS = void 0; -exports.IS_WINDOWS = process.platform === 'win32'; -exports.IS_LINUX = process.platform === 'linux'; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.IS_LINUX = exports.IS_WINDOWS = void 0; +exports.IS_WINDOWS = process.platform === 'win32'; +exports.IS_LINUX = process.platform === 'linux'; /***/ }), @@ -8343,656 +8383,41 @@ module.exports = opts => { /***/ }), -/***/ 5152: +/***/ 2603: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -//parse Empty Node as self closing node -const buildOptions = (__nccwpck_require__(8280).buildOptions); -const defaultOptions = { - attributeNamePrefix: '@_', - attrNodeName: false, - textNodeName: '#text', - ignoreAttributes: true, - cdataTagName: false, - cdataPositionChar: '\\c', - format: false, - indentBy: ' ', - supressEmptyNode: false, - tagValueProcessor: function(a) { - return a; - }, - attrValueProcessor: function(a) { - return a; - }, -}; +const validator = __nccwpck_require__(1739); +const XMLParser = __nccwpck_require__(2380); +const XMLBuilder = __nccwpck_require__(660); -const props = [ - 'attributeNamePrefix', - 'attrNodeName', - 'textNodeName', - 'ignoreAttributes', - 'cdataTagName', - 'cdataPositionChar', - 'format', - 'indentBy', - 'supressEmptyNode', - 'tagValueProcessor', - 'attrValueProcessor', -]; +module.exports = { + XMLParser: XMLParser, + XMLValidator: validator, + XMLBuilder: XMLBuilder +} -function Parser(options) { - this.options = buildOptions(options, defaultOptions, props); - if (this.options.ignoreAttributes || this.options.attrNodeName) { - this.isAttribute = function(/*a*/) { - return false; - }; - } else { - this.attrPrefixLen = this.options.attributeNamePrefix.length; - this.isAttribute = isAttribute; - } - if (this.options.cdataTagName) { - this.isCDATA = isCDATA; - } else { - this.isCDATA = function(/*a*/) { - return false; - }; - } - this.replaceCDATAstr = replaceCDATAstr; - this.replaceCDATAarr = replaceCDATAarr; +/***/ }), - if (this.options.format) { - this.indentate = indentate; - this.tagEndChar = '>\n'; - this.newLine = '\n'; - } else { - this.indentate = function() { - return ''; - }; - this.tagEndChar = '>'; - this.newLine = ''; - } +/***/ 8280: +/***/ ((__unused_webpack_module, exports) => { - if (this.options.supressEmptyNode) { - this.buildTextNode = buildEmptyTextNode; - this.buildObjNode = buildEmptyObjNode; - } else { - this.buildTextNode = buildTextValNode; - this.buildObjNode = buildObjectNode; - } +"use strict"; - this.buildTextValNode = buildTextValNode; - this.buildObjectNode = buildObjectNode; -} -Parser.prototype.parse = function(jObj) { - return this.j2x(jObj, 0).val; -}; - -Parser.prototype.j2x = function(jObj, level) { - let attrStr = ''; - let val = ''; - const keys = Object.keys(jObj); - const len = keys.length; - for (let i = 0; i < len; i++) { - const key = keys[i]; - if (typeof jObj[key] === 'undefined') { - // supress undefined node - } else if (jObj[key] === null) { - val += this.indentate(level) + '<' + key + '/' + this.tagEndChar; - } else if (jObj[key] instanceof Date) { - val += this.buildTextNode(jObj[key], key, '', level); - } else if (typeof jObj[key] !== 'object') { - //premitive type - const attr = this.isAttribute(key); - if (attr) { - attrStr += ' ' + attr + '="' + this.options.attrValueProcessor('' + jObj[key]) + '"'; - } else if (this.isCDATA(key)) { - if (jObj[this.options.textNodeName]) { - val += this.replaceCDATAstr(jObj[this.options.textNodeName], jObj[key]); - } else { - val += this.replaceCDATAstr('', jObj[key]); - } - } else { - //tag value - if (key === this.options.textNodeName) { - if (jObj[this.options.cdataTagName]) { - //value will added while processing cdata - } else { - val += this.options.tagValueProcessor('' + jObj[key]); - } - } else { - val += this.buildTextNode(jObj[key], key, '', level); - } - } - } else if (Array.isArray(jObj[key])) { - //repeated nodes - if (this.isCDATA(key)) { - val += this.indentate(level); - if (jObj[this.options.textNodeName]) { - val += this.replaceCDATAarr(jObj[this.options.textNodeName], jObj[key]); - } else { - val += this.replaceCDATAarr('', jObj[key]); - } - } else { - //nested nodes - const arrLen = jObj[key].length; - for (let j = 0; j < arrLen; j++) { - const item = jObj[key][j]; - if (typeof item === 'undefined') { - // supress undefined node - } else if (item === null) { - val += this.indentate(level) + '<' + key + '/' + this.tagEndChar; - } else if (typeof item === 'object') { - const result = this.j2x(item, level + 1); - val += this.buildObjNode(result.val, key, result.attrStr, level); - } else { - val += this.buildTextNode(item, key, '', level); - } - } - } - } else { - //nested node - if (this.options.attrNodeName && key === this.options.attrNodeName) { - const Ks = Object.keys(jObj[key]); - const L = Ks.length; - for (let j = 0; j < L; j++) { - attrStr += ' ' + Ks[j] + '="' + this.options.attrValueProcessor('' + jObj[key][Ks[j]]) + '"'; - } - } else { - const result = this.j2x(jObj[key], level + 1); - val += this.buildObjNode(result.val, key, result.attrStr, level); - } - } - } - return {attrStr: attrStr, val: val}; -}; - -function replaceCDATAstr(str, cdata) { - str = this.options.tagValueProcessor('' + str); - if (this.options.cdataPositionChar === '' || str === '') { - return str + ''); - } - return str + this.newLine; - } -} - -function buildObjectNode(val, key, attrStr, level) { - if (attrStr && !val.includes('<')) { - return ( - this.indentate(level) + - '<' + - key + - attrStr + - '>' + - val + - //+ this.newLine - // + this.indentate(level) - '' + - this.options.tagValueProcessor(val) + - ' { - -"use strict"; - -const char = function(a) { - return String.fromCharCode(a); -}; - -const chars = { - nilChar: char(176), - missingChar: char(201), - nilPremitive: char(175), - missingPremitive: char(200), - - emptyChar: char(178), - emptyValue: char(177), //empty Premitive - - boundryChar: char(179), - - objStart: char(198), - arrStart: char(204), - arrayEnd: char(185), -}; - -const charsArr = [ - chars.nilChar, - chars.nilPremitive, - chars.missingChar, - chars.missingPremitive, - chars.boundryChar, - chars.emptyChar, - chars.emptyValue, - chars.arrayEnd, - chars.objStart, - chars.arrStart, -]; - -const _e = function(node, e_schema, options) { - if (typeof e_schema === 'string') { - //premitive - if (node && node[0] && node[0].val !== undefined) { - return getValue(node[0].val, e_schema); - } else { - return getValue(node, e_schema); - } - } else { - const hasValidData = hasData(node); - if (hasValidData === true) { - let str = ''; - if (Array.isArray(e_schema)) { - //attributes can't be repeated. hence check in children tags only - str += chars.arrStart; - const itemSchema = e_schema[0]; - //var itemSchemaType = itemSchema; - const arr_len = node.length; - - if (typeof itemSchema === 'string') { - for (let arr_i = 0; arr_i < arr_len; arr_i++) { - const r = getValue(node[arr_i].val, itemSchema); - str = processValue(str, r); - } - } else { - for (let arr_i = 0; arr_i < arr_len; arr_i++) { - const r = _e(node[arr_i], itemSchema, options); - str = processValue(str, r); - } - } - str += chars.arrayEnd; //indicates that next item is not array item - } else { - //object - str += chars.objStart; - const keys = Object.keys(e_schema); - if (Array.isArray(node)) { - node = node[0]; - } - for (let i in keys) { - const key = keys[i]; - //a property defined in schema can be present either in attrsMap or children tags - //options.textNodeName will not present in both maps, take it's value from val - //options.attrNodeName will be present in attrsMap - let r; - if (!options.ignoreAttributes && node.attrsMap && node.attrsMap[key]) { - r = _e(node.attrsMap[key], e_schema[key], options); - } else if (key === options.textNodeName) { - r = _e(node.val, e_schema[key], options); - } else { - r = _e(node.child[key], e_schema[key], options); - } - str = processValue(str, r); - } - } - return str; - } else { - return hasValidData; - } - } -}; - -const getValue = function(a /*, type*/) { - switch (a) { - case undefined: - return chars.missingPremitive; - case null: - return chars.nilPremitive; - case '': - return chars.emptyValue; - default: - return a; - } -}; - -const processValue = function(str, r) { - if (!isAppChar(r[0]) && !isAppChar(str[str.length - 1])) { - str += chars.boundryChar; - } - return str + r; -}; - -const isAppChar = function(ch) { - return charsArr.indexOf(ch) !== -1; -}; - -function hasData(jObj) { - if (jObj === undefined) { - return chars.missingChar; - } else if (jObj === null) { - return chars.nilChar; - } else if ( - jObj.child && - Object.keys(jObj.child).length === 0 && - (!jObj.attrsMap || Object.keys(jObj.attrsMap).length === 0) - ) { - return chars.emptyChar; - } else { - return true; - } -} - -const x2j = __nccwpck_require__(6712); -const buildOptions = (__nccwpck_require__(8280).buildOptions); - -const convert2nimn = function(node, e_schema, options) { - options = buildOptions(options, x2j.defaultOptions, x2j.props); - return _e(node, e_schema, options); -}; - -exports.convert2nimn = convert2nimn; - - -/***/ }), - -/***/ 8270: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -const util = __nccwpck_require__(8280); - -const convertToJson = function(node, options) { - const jObj = {}; - - //when no child node or attr is present - if ((!node.child || util.isEmptyObject(node.child)) && (!node.attrsMap || util.isEmptyObject(node.attrsMap))) { - return util.isExist(node.val) ? node.val : ''; - } else { - //otherwise create a textnode if node has some text - if (util.isExist(node.val)) { - if (!(typeof node.val === 'string' && (node.val === '' || node.val === options.cdataPositionChar))) { - if(options.arrayMode === "strict"){ - jObj[options.textNodeName] = [ node.val ]; - }else{ - jObj[options.textNodeName] = node.val; - } - } - } - } - - util.merge(jObj, node.attrsMap, options.arrayMode); - - const keys = Object.keys(node.child); - for (let index = 0; index < keys.length; index++) { - var tagname = keys[index]; - if (node.child[tagname] && node.child[tagname].length > 1) { - jObj[tagname] = []; - for (var tag in node.child[tagname]) { - jObj[tagname].push(convertToJson(node.child[tagname][tag], options)); - } - } else { - if(options.arrayMode === true){ - const result = convertToJson(node.child[tagname][0], options) - if(typeof result === 'object') - jObj[tagname] = [ result ]; - else - jObj[tagname] = result; - }else if(options.arrayMode === "strict"){ - jObj[tagname] = [convertToJson(node.child[tagname][0], options) ]; - }else{ - jObj[tagname] = convertToJson(node.child[tagname][0], options); - } - } - } - - //add value - return jObj; -}; - -exports.convertToJson = convertToJson; - - -/***/ }), - -/***/ 6014: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -const util = __nccwpck_require__(8280); -const buildOptions = (__nccwpck_require__(8280).buildOptions); -const x2j = __nccwpck_require__(6712); - -//TODO: do it later -const convertToJsonString = function(node, options) { - options = buildOptions(options, x2j.defaultOptions, x2j.props); - - options.indentBy = options.indentBy || ''; - return _cToJsonStr(node, options, 0); -}; - -const _cToJsonStr = function(node, options, level) { - let jObj = '{'; - - //traver through all the children - const keys = Object.keys(node.child); - - for (let index = 0; index < keys.length; index++) { - var tagname = keys[index]; - if (node.child[tagname] && node.child[tagname].length > 1) { - jObj += '"' + tagname + '" : [ '; - for (var tag in node.child[tagname]) { - jObj += _cToJsonStr(node.child[tagname][tag], options) + ' , '; - } - jObj = jObj.substr(0, jObj.length - 1) + ' ] '; //remove extra comma in last - } else { - jObj += '"' + tagname + '" : ' + _cToJsonStr(node.child[tagname][0], options) + ' ,'; - } - } - util.merge(jObj, node.attrsMap); - //add attrsMap as new children - if (util.isEmptyObject(jObj)) { - return util.isExist(node.val) ? node.val : ''; - } else { - if (util.isExist(node.val)) { - if (!(typeof node.val === 'string' && (node.val === '' || node.val === options.cdataPositionChar))) { - jObj += '"' + options.textNodeName + '" : ' + stringval(node.val); - } - } - } - //add value - if (jObj[jObj.length - 1] === ',') { - jObj = jObj.substr(0, jObj.length - 2); - } - return jObj + '}'; -}; - -function stringval(v) { - if (v === true || v === false || !isNaN(v)) { - return v; - } else { - return '"' + v + '"'; - } -} - -function indentate(options, level) { - return options.indentBy.repeat(level); -} - -exports.convertToJsonString = convertToJsonString; - - -/***/ }), - -/***/ 7448: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -const nodeToJson = __nccwpck_require__(8270); -const xmlToNodeobj = __nccwpck_require__(6712); -const x2xmlnode = __nccwpck_require__(6712); -const buildOptions = (__nccwpck_require__(8280).buildOptions); -const validator = __nccwpck_require__(1739); - -exports.parse = function(xmlData, options, validationOption) { - if( validationOption){ - if(validationOption === true) validationOption = {} - - const result = validator.validate(xmlData, validationOption); - if (result !== true) { - throw Error( result.err.msg) - } - } - options = buildOptions(options, x2xmlnode.defaultOptions, x2xmlnode.props); - const traversableObj = xmlToNodeobj.getTraversalObj(xmlData, options) - //print(traversableObj, " "); - return nodeToJson.convertToJson(traversableObj, options); -}; -exports.convertTonimn = __nccwpck_require__(1901).convert2nimn; -exports.getTraversalObj = xmlToNodeobj.getTraversalObj; -exports.convertToJson = nodeToJson.convertToJson; -exports.convertToJsonString = __nccwpck_require__(6014).convertToJsonString; -exports.validate = validator.validate; -exports.j2xParser = __nccwpck_require__(5152); -exports.parseToNimn = function(xmlData, schema, options) { - return exports.convertTonimn(exports.getTraversalObj(xmlData, options), schema, options); -}; - - -function print(xmlNode, indentation){ - if(xmlNode){ - console.log(indentation + "{") - console.log(indentation + " \"tagName\": \"" + xmlNode.tagname + "\", "); - if(xmlNode.parent){ - console.log(indentation + " \"parent\": \"" + xmlNode.parent.tagname + "\", "); - } - console.log(indentation + " \"val\": \"" + xmlNode.val + "\", "); - console.log(indentation + " \"attrs\": " + JSON.stringify(xmlNode.attrsMap,null,4) + ", "); - - if(xmlNode.child){ - console.log(indentation + "\"child\": {") - const indentation2 = indentation + indentation; - Object.keys(xmlNode.child).forEach( function(key) { - const node = xmlNode.child[key]; - - if(Array.isArray(node)){ - console.log(indentation + "\""+key+"\" :[") - node.forEach( function(item,index) { - //console.log(indentation + " \""+index+"\" : [") - print(item, indentation2); - }) - console.log(indentation + "],") - }else{ - console.log(indentation + " \""+key+"\" : {") - print(node, indentation2); - console.log(indentation + "},") - } - }); - console.log(indentation + "},") - } - console.log(indentation + "},") - } -} - -/***/ }), - -/***/ 8280: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - - -const nameStartChar = ':A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; -const nameChar = nameStartChar + '\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040'; -const nameRegexp = '[' + nameStartChar + '][' + nameChar + ']*' -const regexName = new RegExp('^' + nameRegexp + '$'); +const nameStartChar = ':A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; +const nameChar = nameStartChar + '\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040'; +const nameRegexp = '[' + nameStartChar + '][' + nameChar + ']*' +const regexName = new RegExp('^' + nameRegexp + '$'); const getAllMatches = function(string, regex) { const matches = []; let match = regex.exec(string); while (match) { const allmatches = []; + allmatches.startIndex = regex.lastIndex - match[0].length; const len = match.length; for (let index = 0; index < len; index++) { allmatches.push(match[index]); @@ -9026,9 +8451,9 @@ exports.merge = function(target, a, arrayMode) { const keys = Object.keys(a); // will return an array of own properties const len = keys.length; //don't make it inline for (let i = 0; i < len; i++) { - if(arrayMode === 'strict'){ + if (arrayMode === 'strict') { target[keys[i]] = [ a[keys[i]] ]; - }else{ + } else { target[keys[i]] = a[keys[i]]; } } @@ -9049,22 +8474,6 @@ exports.getValue = function(v) { // const fakeCall = function(a) {return a;}; // const fakeCallNoReturn = function() {}; -exports.buildOptions = function(options, defaultOptions, props) { - var newOptions = {}; - if (!options) { - return defaultOptions; //if there are not options - } - - for (let i = 0; i < props.length; i++) { - if (options[props[i]] !== undefined) { - newOptions[props[i]] = options[props[i]]; - } else { - newOptions[props[i]] = defaultOptions[props[i]]; - } - } - return newOptions; -}; - exports.isName = isName; exports.getAllMatches = getAllMatches; exports.nameRegexp = nameRegexp; @@ -9082,13 +8491,12 @@ const util = __nccwpck_require__(8280); const defaultOptions = { allowBooleanAttributes: false, //A tag can have attributes without any value + unpairedTags: [] }; -const props = ['allowBooleanAttributes']; - //const tagsPattern = new RegExp("<\\/?([\\w:\\-_\.]+)\\s*\/?>","g"); exports.validate = function (xmlData, options) { - options = util.buildOptions(options, defaultOptions, props); + options = Object.assign({}, defaultOptions, options); //xmlData = xmlData.replace(/(\r\n|\n|\r)/gm,"");//make it single line //xmlData = xmlData.replace(/(^\s*<\?xml.*?\?>)/g,"");//Remove XML starting tag @@ -9103,19 +8511,20 @@ exports.validate = function (xmlData, options) { // check for byte order mark (BOM) xmlData = xmlData.substr(1); } - + for (let i = 0; i < xmlData.length; i++) { - if (xmlData[i] === '<') { + + if (xmlData[i] === '<' && xmlData[i+1] === '?') { + i+=2; + i = readPI(xmlData,i); + if (i.err) return i; + }else if (xmlData[i] === '<') { //starting of tag //read until you reach to '>' avoiding any '>' in attribute value - + let tagStartPos = i; i++; - if (xmlData[i] === '?') { - i = readPI(xmlData, ++i); - if (i.err) { - return i; - } - } else if (xmlData[i] === '!') { + + if (xmlData[i] === '!') { i = readCommentAndCDATA(xmlData, i); continue; } else { @@ -9148,7 +8557,7 @@ exports.validate = function (xmlData, options) { if (!validateTagName(tagName)) { let msg; if (tagName.trim().length === 0) { - msg = "There is an unnecessary space between tag name and backward slash ' 0) { - return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, i)); + return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos)); } else { const otg = tags.pop(); - if (tagName !== otg) { - return getErrorObject('InvalidTag', "Closing tag '"+otg+"' is expected inplace of '"+tagName+"'.", getLineNumberForPosition(xmlData, i)); + if (tagName !== otg.tagName) { + let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos); + return getErrorObject('InvalidTag', + "Expected closing tag '"+otg.tagName+"' (opened in line "+openPos.line+", col "+openPos.col+") instead of closing tag '"+tagName+"'.", + getLineNumberForPosition(xmlData, tagStartPos)); } //when there are no more tags, we reached the root level. @@ -9203,8 +8616,10 @@ exports.validate = function (xmlData, options) { //if the root level has been reached before ... if (reachedRoot === true) { return getErrorObject('InvalidXml', 'Multiple possible root nodes found.', getLineNumberForPosition(xmlData, i)); + } else if(options.unpairedTags.indexOf(tagName) !== -1){ + //don't push into stack } else { - tags.push(tagName); + tags.push({tagName, tagStartPos}); } tagFound = true; } @@ -9218,7 +8633,10 @@ exports.validate = function (xmlData, options) { i++; i = readCommentAndCDATA(xmlData, i); continue; - } else { + } else if (xmlData[i+1] === '?') { + i = readPI(xmlData, ++i); + if (i.err) return i; + } else{ break; } } else if (xmlData[i] === '&') { @@ -9226,6 +8644,10 @@ exports.validate = function (xmlData, options) { if (afterAmp == -1) return getErrorObject('InvalidChar', "char '&' is not expected.", getLineNumberForPosition(xmlData, i)); i = afterAmp; + }else{ + if (reachedRoot === true && !isWhiteSpace(xmlData[i])) { + return getErrorObject('InvalidXml', "Extra text at the end", getLineNumberForPosition(xmlData, i)); + } } } //end of reading tag text value if (xmlData[i] === '<') { @@ -9233,7 +8655,7 @@ exports.validate = function (xmlData, options) { } } } else { - if (xmlData[i] === ' ' || xmlData[i] === '\t' || xmlData[i] === '\n' || xmlData[i] === '\r') { + if ( isWhiteSpace(xmlData[i])) { continue; } return getErrorObject('InvalidChar', "char '"+xmlData[i]+"' is not expected.", getLineNumberForPosition(xmlData, i)); @@ -9242,24 +8664,31 @@ exports.validate = function (xmlData, options) { if (!tagFound) { return getErrorObject('InvalidXml', 'Start tag expected.', 1); - } else if (tags.length > 0) { - return getErrorObject('InvalidXml', "Invalid '"+JSON.stringify(tags, null, 4).replace(/\r?\n/g, '')+"' found.", 1); + }else if (tags.length == 1) { + return getErrorObject('InvalidTag', "Unclosed tag '"+tags[0].tagName+"'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos)); + }else if (tags.length > 0) { + return getErrorObject('InvalidXml', "Invalid '"+ + JSON.stringify(tags.map(t => t.tagName), null, 4).replace(/\r?\n/g, '')+ + "' found.", {line: 1, col: 1}); } return true; }; +function isWhiteSpace(char){ + return char === ' ' || char === '\t' || char === '\n' || char === '\r'; +} /** * Read Processing insstructions and skip * @param {*} xmlData * @param {*} i */ function readPI(xmlData, i) { - var start = i; + const start = i; for (; i < xmlData.length; i++) { if (xmlData[i] == '?' || xmlData[i] == ' ') { //tagname - var tagname = xmlData.substr(start, i - start); + const tagname = xmlData.substr(start, i - start); if (i > 5 && tagname === 'xml') { return getErrorObject('InvalidXml', 'XML declaration allowed only at the start of the document.', getLineNumberForPosition(xmlData, i)); } else if (xmlData[i] == '?' && xmlData[i + 1] == '>') { @@ -9325,8 +8754,8 @@ function readCommentAndCDATA(xmlData, i) { return i; } -var doubleQuote = '"'; -var singleQuote = "'"; +const doubleQuote = '"'; +const singleQuote = "'"; /** * Keep reading xmlData until '<' is found outside the attribute value. @@ -9343,7 +8772,6 @@ function readAttributeStr(xmlData, i) { startChar = xmlData[i]; } else if (startChar !== xmlData[i]) { //if vaue is enclosed with double quote then single quotes are allowed inside the value and vice versa - continue; } else { startChar = ''; } @@ -9384,23 +8812,25 @@ function validateAttributeString(attrStr, options) { for (let i = 0; i < matches.length; i++) { if (matches[i][1].length === 0) { //nospace before attribute name: a="sd"b="saf" - return getErrorObject('InvalidAttr', "Attribute '"+matches[i][2]+"' has no space in starting.", getPositionFromMatch(attrStr, matches[i][0])) + return getErrorObject('InvalidAttr', "Attribute '"+matches[i][2]+"' has no space in starting.", getPositionFromMatch(matches[i])) + } else if (matches[i][3] !== undefined && matches[i][4] === undefined) { + return getErrorObject('InvalidAttr', "Attribute '"+matches[i][2]+"' is without value.", getPositionFromMatch(matches[i])); } else if (matches[i][3] === undefined && !options.allowBooleanAttributes) { //independent attribute: ab - return getErrorObject('InvalidAttr', "boolean attribute '"+matches[i][2]+"' is not allowed.", getPositionFromMatch(attrStr, matches[i][0])); + return getErrorObject('InvalidAttr', "boolean attribute '"+matches[i][2]+"' is not allowed.", getPositionFromMatch(matches[i])); } /* else if(matches[i][6] === undefined){//attribute without value: ab= return { err: { code:"InvalidAttr",msg:"attribute " + matches[i][2] + " has no value assigned."}}; } */ const attrName = matches[i][2]; if (!validateAttrName(attrName)) { - return getErrorObject('InvalidAttr', "Attribute '"+attrName+"' is an invalid name.", getPositionFromMatch(attrStr, matches[i][0])); + return getErrorObject('InvalidAttr', "Attribute '"+attrName+"' is an invalid name.", getPositionFromMatch(matches[i])); } if (!attrNames.hasOwnProperty(attrName)) { //check for duplicate attribute. attrNames[attrName] = 1; } else { - return getErrorObject('InvalidAttr', "Attribute '"+attrName+"' is repeated.", getPositionFromMatch(attrStr, matches[i][0])); + return getErrorObject('InvalidAttr', "Attribute '"+attrName+"' is repeated.", getPositionFromMatch(matches[i])); } } @@ -9447,7 +8877,8 @@ function getErrorObject(code, message, lineNumber) { err: { code: code, msg: message, - line: lineNumber, + line: lineNumber.line || lineNumber, + col: lineNumber.col, }, }; } @@ -9464,1778 +8895,1997 @@ function validateTagName(tagname) { //this function returns the line number for the character at the given index function getLineNumberForPosition(xmlData, index) { - var lines = xmlData.substring(0, index).split(/\r?\n/); - return lines.length; -} + const lines = xmlData.substring(0, index).split(/\r?\n/); + return { + line: lines.length, -//this function returns the position of the last character of match within attrStr -function getPositionFromMatch(attrStr, match) { - return attrStr.indexOf(match) + match.length; + // column number is last line's length + 1, because column numbering starts at 1: + col: lines[lines.length - 1].length + 1 + }; } - -/***/ }), - -/***/ 9539: -/***/ ((module) => { - -"use strict"; - - -module.exports = function(tagname, parent, val) { - this.tagname = tagname; - this.parent = parent; - this.child = {}; //child tags - this.attrsMap = {}; //attributes map - this.val = val; //text only - this.addChild = function(child) { - if (Array.isArray(this.child[child.tagname])) { - //already presents - this.child[child.tagname].push(child); - } else { - this.child[child.tagname] = [child]; - } - }; -}; +//this function returns the position of the first character of match within attrStr +function getPositionFromMatch(match) { + return match.startIndex + match[1].length; +} /***/ }), -/***/ 6712: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 660: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; - -const util = __nccwpck_require__(8280); -const buildOptions = (__nccwpck_require__(8280).buildOptions); -const xmlNode = __nccwpck_require__(9539); -const regx = - '<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)' - .replace(/NAME/g, util.nameRegexp); - -//const tagsRegx = new RegExp("<(\\/?[\\w:\\-\._]+)([^>]*)>(\\s*"+cdataRegx+")*([^<]+)?","g"); -//const tagsRegx = new RegExp("<(\\/?)((\\w*:)?([\\w:\\-\._]+))([^>]*)>([^<]*)("+cdataRegx+"([^<]*))*([^<]+)?","g"); - -//polyfill -if (!Number.parseInt && window.parseInt) { - Number.parseInt = window.parseInt; -} -if (!Number.parseFloat && window.parseFloat) { - Number.parseFloat = window.parseFloat; -} +//parse Empty Node as self closing node +const buildFromOrderedJs = __nccwpck_require__(2462); const defaultOptions = { attributeNamePrefix: '@_', - attrNodeName: false, + attributesGroupName: false, textNodeName: '#text', ignoreAttributes: true, - ignoreNameSpace: false, - allowBooleanAttributes: false, //a tag can have attributes without any value - //ignoreRootElement : false, - parseNodeValue: true, - parseAttributeValue: false, - arrayMode: false, - trimValues: true, //Trim string values of tag and attributes - cdataTagName: false, - cdataPositionChar: '\\c', - tagValueProcessor: function(a, tagName) { + cdataPropName: false, + format: false, + indentBy: ' ', + suppressEmptyNode: false, + suppressUnpairedNode: true, + suppressBooleanAttributes: true, + tagValueProcessor: function(key, a) { return a; }, - attrValueProcessor: function(a, attrName) { + attributeValueProcessor: function(attrName, a) { return a; }, - stopNodes: [] - //decodeStrict: false, + preserveOrder: false, + commentPropName: false, + unpairedTags: [], + entities: [ + { regex: new RegExp("&", "g"), val: "&" },//it must be on top + { regex: new RegExp(">", "g"), val: ">" }, + { regex: new RegExp("<", "g"), val: "<" }, + { regex: new RegExp("\'", "g"), val: "'" }, + { regex: new RegExp("\"", "g"), val: """ } + ], + processEntities: true, + stopNodes: [], + transformTagName: false, }; -exports.defaultOptions = defaultOptions; +function Builder(options) { + this.options = Object.assign({}, defaultOptions, options); + if (this.options.ignoreAttributes || this.options.attributesGroupName) { + this.isAttribute = function(/*a*/) { + return false; + }; + } else { + this.attrPrefixLen = this.options.attributeNamePrefix.length; + this.isAttribute = isAttribute; + } -const props = [ - 'attributeNamePrefix', - 'attrNodeName', - 'textNodeName', - 'ignoreAttributes', - 'ignoreNameSpace', - 'allowBooleanAttributes', - 'parseNodeValue', - 'parseAttributeValue', - 'arrayMode', - 'trimValues', - 'cdataTagName', - 'cdataPositionChar', - 'tagValueProcessor', - 'attrValueProcessor', - 'parseTrueNumberOnly', - 'stopNodes' -]; -exports.props = props; + this.processTextOrObjNode = processTextOrObjNode -/** - * Trim -> valueProcessor -> parse value - * @param {string} tagName - * @param {string} val - * @param {object} options - */ -function processTagValue(tagName, val, options) { - if (val) { - if (options.trimValues) { - val = val.trim(); - } - val = options.tagValueProcessor(val, tagName); - val = parseValue(val, options.parseNodeValue, options.parseTrueNumberOnly); + if (this.options.format) { + this.indentate = indentate; + this.tagEndChar = '>\n'; + this.newLine = '\n'; + } else { + this.indentate = function() { + return ''; + }; + this.tagEndChar = '>'; + this.newLine = ''; } - return val; + if (this.options.suppressEmptyNode) { + this.buildTextNode = buildEmptyTextNode; + this.buildObjNode = buildEmptyObjNode; + } else { + this.buildTextNode = buildTextValNode; + this.buildObjNode = buildObjectNode; + } + + this.buildTextValNode = buildTextValNode; + this.buildObjectNode = buildObjectNode; + + this.replaceEntitiesValue = replaceEntitiesValue; + this.buildAttrPairStr = buildAttrPairStr; } -function resolveNameSpace(tagname, options) { - if (options.ignoreNameSpace) { - const tags = tagname.split(':'); - const prefix = tagname.charAt(0) === '/' ? '/' : ''; - if (tags[0] === 'xmlns') { - return ''; - } - if (tags.length === 2) { - tagname = prefix + tags[1]; +Builder.prototype.build = function(jObj) { + if(this.options.preserveOrder){ + return buildFromOrderedJs(jObj, this.options); + }else { + if(Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1){ + jObj = { + [this.options.arrayNodeName] : jObj + } } + return this.j2x(jObj, 0).val; } - return tagname; -} +}; -function parseValue(val, shouldParse, parseTrueNumberOnly) { - if (shouldParse && typeof val === 'string') { - let parsed; - if (val.trim() === '' || isNaN(val)) { - parsed = val === 'true' ? true : val === 'false' ? false : val; +Builder.prototype.j2x = function(jObj, level) { + let attrStr = ''; + let val = ''; + for (let key in jObj) { + if (typeof jObj[key] === 'undefined') { + // supress undefined node + } else if (jObj[key] === null) { + if(key[0] === "?") val += this.indentate(level) + '<' + key + '?' + this.tagEndChar; + else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar; + // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar; + } else if (jObj[key] instanceof Date) { + val += this.buildTextNode(jObj[key], key, '', level); + } else if (typeof jObj[key] !== 'object') { + //premitive type + const attr = this.isAttribute(key); + if (attr) { + attrStr += this.buildAttrPairStr(attr, '' + jObj[key]); + }else { + //tag value + if (key === this.options.textNodeName) { + let newval = this.options.tagValueProcessor(key, '' + jObj[key]); + val += this.replaceEntitiesValue(newval); + } else { + val += this.buildTextNode(jObj[key], key, '', level); + } + } + } else if (Array.isArray(jObj[key])) { + //repeated nodes + const arrLen = jObj[key].length; + for (let j = 0; j < arrLen; j++) { + const item = jObj[key][j]; + if (typeof item === 'undefined') { + // supress undefined node + } else if (item === null) { + if(key[0] === "?") val += this.indentate(level) + '<' + key + '?' + this.tagEndChar; + else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar; + // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar; + } else if (typeof item === 'object') { + val += this.processTextOrObjNode(item, key, level) + } else { + val += this.buildTextNode(item, key, '', level); + } + } } else { - if (val.indexOf('0x') !== -1) { - //support hexa decimal - parsed = Number.parseInt(val, 16); - } else if (val.indexOf('.') !== -1) { - parsed = Number.parseFloat(val); - val = val.replace(/\.?0+$/, ""); + //nested node + if (this.options.attributesGroupName && key === this.options.attributesGroupName) { + const Ks = Object.keys(jObj[key]); + const L = Ks.length; + for (let j = 0; j < L; j++) { + attrStr += this.buildAttrPairStr(Ks[j], '' + jObj[key][Ks[j]]); + } } else { - parsed = Number.parseInt(val, 10); - } - if (parseTrueNumberOnly) { - parsed = String(parsed) === val ? parsed : val; + val += this.processTextOrObjNode(jObj[key], key, level) } } - return parsed; + } + return {attrStr: attrStr, val: val}; +}; + +function buildAttrPairStr(attrName, val){ + val = this.options.attributeValueProcessor(attrName, '' + val); + val = this.replaceEntitiesValue(val); + if (this.options.suppressBooleanAttributes && val === "true") { + return ' ' + attrName; + } else return ' ' + attrName + '="' + val + '"'; +} + +function processTextOrObjNode (object, key, level) { + const result = this.j2x(object, level + 1); + if (object[this.options.textNodeName] !== undefined && Object.keys(object).length === 1) { + return this.buildTextNode(object[this.options.textNodeName], key, result.attrStr, level); } else { - if (util.isExist(val)) { - return val; - } else { - return ''; - } + return this.buildObjNode(result.val, key, result.attrStr, level); } } -//TODO: change regex to capture NS -//const attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])((.|\n)*?)\\2","gm"); -const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])(.*?)\\3)?', 'g'); +function buildObjectNode(val, key, attrStr, level) { + let tagEndExp = '' + val + tagEndExp ); + } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) { + return this.indentate(level) + `` + this.newLine; + }else { + return ( + this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar + + val + + this.indentate(level) + tagEndExp ); + } +} -function buildAttributesMap(attrStr, options) { - if (!options.ignoreAttributes && typeof attrStr === 'string') { - attrStr = attrStr.replace(/\r?\n/g, ' '); - //attrStr = attrStr || attrStr.trim(); +function buildEmptyObjNode(val, key, attrStr, level) { + if (val !== '') { + return this.buildObjectNode(val, key, attrStr, level); + } else { + if(key[0] === "?") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar; + else return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar; + } +} - const matches = util.getAllMatches(attrStr, attrsRegx); - const len = matches.length; //don't make it inline - const attrs = {}; - for (let i = 0; i < len; i++) { - const attrName = resolveNameSpace(matches[i][1], options); - if (attrName.length) { - if (matches[i][4] !== undefined) { - if (options.trimValues) { - matches[i][4] = matches[i][4].trim(); - } - matches[i][4] = options.attrValueProcessor(matches[i][4], attrName); - attrs[options.attributeNamePrefix + attrName] = parseValue( - matches[i][4], - options.parseAttributeValue, - options.parseTrueNumberOnly - ); - } else if (options.allowBooleanAttributes) { - attrs[options.attributeNamePrefix + attrName] = true; - } +function buildTextValNode(val, key, attrStr, level) { + if (this.options.cdataPropName !== false && key === this.options.cdataPropName) { + return this.indentate(level) + `` + this.newLine; + }else if (this.options.commentPropName !== false && key === this.options.commentPropName) { + return this.indentate(level) + `` + this.newLine; + }else{ + let textValue = this.options.tagValueProcessor(key, val); + textValue = this.replaceEntitiesValue(textValue); + + if( textValue === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired + if(this.options.suppressUnpairedNode){ + return this.indentate(level) + '<' + key + this.tagEndChar; + }else{ + return this.indentate(level) + '<' + key + "/" + this.tagEndChar; } + } else{ + return ( + this.indentate(level) + '<' + key + attrStr + '>' + + textValue + + ' 0 && this.options.processEntities){ + for (let i=0; i", i, "Closing Tag is not closed.") - let tagName = xmlData.substring(i+2,closeIndex).trim(); +function buildEmptyTextNode(val, key, attrStr, level) { + if( val === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired + if(this.options.suppressUnpairedNode){ + return this.indentate(level) + '<' + key + this.tagEndChar; + }else{ + return this.indentate(level) + '<' + key + "/" + this.tagEndChar; + } + }else if (val !== '') { //empty + return this.buildTextValNode(val, key, attrStr, level); + } else { + if(key[0] === "?") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar; //PI tag + else return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar; //normal + } +} - if(options.ignoreNameSpace){ - const colonIndex = tagName.indexOf(":"); - if(colonIndex !== -1){ - tagName = tagName.substr(colonIndex+1); - } - } +function indentate(level) { + return this.options.indentBy.repeat(level); +} - /* if (currentNode.parent) { - currentNode.parent.val = util.getValue(currentNode.parent.val) + '' + processTagValue2(tagName, textData , options); - } */ - if(currentNode){ - if(currentNode.val){ - currentNode.val = util.getValue(currentNode.val) + '' + processTagValue(tagName, textData , options); - }else{ - currentNode.val = processTagValue(tagName, textData , options); - } - } +function isAttribute(name /*, options*/) { + if (name.startsWith(this.options.attributeNamePrefix)) { + return name.substr(this.attrPrefixLen); + } else { + return false; + } +} - if (options.stopNodes.length && options.stopNodes.includes(currentNode.tagname)) { - currentNode.child = [] - if (currentNode.attrsMap == undefined) { currentNode.attrsMap = {}} - currentNode.val = xmlData.substr(currentNode.startIndex + 1, i - currentNode.startIndex - 1) - } - currentNode = currentNode.parent; - textData = ""; - i = closeIndex; - } else if( xmlData[i+1] === '?') { - i = findClosingIndex(xmlData, "?>", i, "Pi Tag is not closed.") - } else if(xmlData.substr(i + 1, 3) === '!--') { - i = findClosingIndex(xmlData, "-->", i, "Comment is not closed.") - } else if( xmlData.substr(i + 1, 2) === '!D') { - const closeIndex = findClosingIndex(xmlData, ">", i, "DOCTYPE is not closed.") - const tagExp = xmlData.substring(i, closeIndex); - if(tagExp.indexOf("[") >= 0){ - i = xmlData.indexOf("]>", i) + 1; - }else{ - i = closeIndex; - } - }else if(xmlData.substr(i + 1, 2) === '![') { - const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2 - const tagExp = xmlData.substring(i + 9,closeIndex); +module.exports = Builder; - //considerations - //1. CDATA will always have parent node - //2. A tag with CDATA is not a leaf node so it's value would be string type. - if(textData){ - currentNode.val = util.getValue(currentNode.val) + '' + processTagValue(currentNode.tagname, textData , options); - textData = ""; - } - if (options.cdataTagName) { - //add cdata node - const childNode = new xmlNode(options.cdataTagName, currentNode, tagExp); - currentNode.addChild(childNode); - //for backtracking - currentNode.val = util.getValue(currentNode.val) + options.cdataPositionChar; - //add rest value to parent node - if (tagExp) { - childNode.val = tagExp; - } - } else { - currentNode.val = (currentNode.val || '') + (tagExp || ''); - } +/***/ }), - i = closeIndex + 2; - }else {//Opening tag - const result = closingIndexForOpeningTag(xmlData, i+1) - let tagExp = result.data; - const closeIndex = result.index; - const separatorIndex = tagExp.indexOf(" "); - let tagName = tagExp; - if(separatorIndex !== -1){ - tagName = tagExp.substr(0, separatorIndex).trimRight(); - tagExp = tagExp.substr(separatorIndex + 1); - } +/***/ 2462: +/***/ ((module) => { - if(options.ignoreNameSpace){ - const colonIndex = tagName.indexOf(":"); - if(colonIndex !== -1){ - tagName = tagName.substr(colonIndex+1); - } - } +const EOL = "\n"; - //save text to parent node - if (currentNode && textData) { - if(currentNode.tagname !== '!xml'){ - currentNode.val = util.getValue(currentNode.val) + '' + processTagValue( currentNode.tagname, textData, options); - } - } +/** + * + * @param {array} jArray + * @param {any} options + * @returns + */ +function toXml(jArray, options){ + return arrToStr( jArray, options, "", 0); +} - if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){//selfClosing tag +function arrToStr(arr, options, jPath, level){ + let xmlStr = ""; - if(tagName[tagName.length - 1] === "/"){ //remove trailing '/' - tagName = tagName.substr(0, tagName.length - 1); - tagExp = tagName; - }else{ - tagExp = tagExp.substr(0, tagExp.length - 1); - } + let indentation = ""; + if(options.format && options.indentBy.length > 0){//TODO: this logic can be avoided for each call + indentation = EOL + "" + options.indentBy.repeat(level); + } - const childNode = new xmlNode(tagName, currentNode, ''); - if(tagName !== tagExp){ - childNode.attrsMap = buildAttributesMap(tagExp, options); - } - currentNode.addChild(childNode); - }else{//opening tag + for (let i = 0; i < arr.length; i++) { + const tagObj = arr[i]; + const tagName = propName(tagObj); + let newJPath = ""; + if(jPath.length === 0) newJPath = tagName + else newJPath = `${jPath}.${tagName}`; - const childNode = new xmlNode( tagName, currentNode ); - if (options.stopNodes.length && options.stopNodes.includes(childNode.tagname)) { - childNode.startIndex=closeIndex; - } - if(tagName !== tagExp){ - childNode.attrsMap = buildAttributesMap(tagExp, options); - } - currentNode.addChild(childNode); - currentNode = childNode; - } - textData = ""; - i = closeIndex; - } - }else{ - textData += xmlData[i]; + if(tagName === options.textNodeName){ + let tagText = tagObj[tagName]; + if(!isStopNode(newJPath, options)){ + tagText = options.tagValueProcessor( tagName, tagText); + tagText = replaceEntitiesValue(tagText, options); + } + xmlStr += indentation + tagText; + continue; + }else if( tagName === options.cdataPropName){ + xmlStr += indentation + ``; + continue; + }else if( tagName === options.commentPropName){ + xmlStr += indentation + ``; + continue; + }else if( tagName[0] === "?"){ + const attStr = attr_to_str(tagObj[":@"], options); + const tempInd = tagName === "?xml" ? "" : indentation; + let piTextNodeName = tagObj[tagName][0][options.textNodeName]; + piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : ""; //remove extra spacing + xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr}?>`; + continue; + } + const attStr = attr_to_str(tagObj[":@"], options); + let tagStart = indentation + `<${tagName}${attStr}`; + let tagValue = arrToStr(tagObj[tagName], options, newJPath, level + 1); + if(options.unpairedTags.indexOf(tagName) !== -1){ + if(options.suppressUnpairedNode) xmlStr += tagStart + ">"; + else xmlStr += tagStart + "/>"; + }else if( (!tagValue || tagValue.length === 0) && options.suppressEmptyNode){ + xmlStr += tagStart + "/>"; + }else{ + //TODO: node with only text value should not parse the text value in next line + xmlStr += tagStart + `>${tagValue}${indentation}` ; + } } - } - return xmlObj; + + return xmlStr; } -function closingIndexForOpeningTag(data, i){ - let attrBoundary; - let tagExp = ""; - for (let index = i; index < data.length; index++) { - let ch = data[index]; - if (attrBoundary) { - if (ch === attrBoundary) attrBoundary = "";//reset - } else if (ch === '"' || ch === "'") { - attrBoundary = ch; - } else if (ch === '>') { - return { - data: tagExp, - index: index - } - } else if (ch === '\t') { - ch = " " +function propName(obj){ + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if(key !== ":@") return key; } - tagExp += ch; } -} -function findClosingIndex(xmlData, str, i, errMsg){ - const closingIndex = xmlData.indexOf(str, i); - if(closingIndex === -1){ - throw new Error(errMsg) - }else{ - return closingIndex + str.length - 1; - } +function attr_to_str(attrMap, options){ + let attrStr = ""; + if(attrMap && !options.ignoreAttributes){ + for (let attr in attrMap){ + let attrVal = options.attributeValueProcessor(attr, attrMap[attr]); + attrVal = replaceEntitiesValue(attrVal, options); + if(attrVal === true && options.suppressBooleanAttributes){ + attrStr+= ` ${attr.substr(options.attributeNamePrefix.length)}`; + }else{ + attrStr+= ` ${attr.substr(options.attributeNamePrefix.length)}="${attrVal}"`; + } + } + } + return attrStr; } -exports.getTraversalObj = getTraversalObj; +function isStopNode(jPath, options){ + jPath = jPath.substr(0,jPath.length - options.textNodeName.length - 1); + let tagName = jPath.substr(jPath.lastIndexOf(".") + 1); + for(let index in options.stopNodes){ + if(options.stopNodes[index] === jPath || options.stopNodes[index] === "*."+tagName) return true; + } + return false; +} +function replaceEntitiesValue(textValue, options){ + if(textValue && textValue.length > 0 && options.processEntities){ + for (let i=0; i< options.entities.length; i++) { + const entity = options.entities[i]; + textValue = textValue.replace(entity.regex, entity.val); + } + } + return textValue; + } +module.exports = toXml; /***/ }), -/***/ 1585: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; +/***/ 6072: +/***/ ((module) => { -const {PassThrough} = __nccwpck_require__(2781); +//TODO: handle comments +function readDocType(xmlData, i){ + + const entities = {}; + if( xmlData[i + 3] === 'O' && + xmlData[i + 4] === 'C' && + xmlData[i + 5] === 'T' && + xmlData[i + 6] === 'Y' && + xmlData[i + 7] === 'P' && + xmlData[i + 8] === 'E') + { + i = i+9; + let angleBracketsCount = 1; + let hasBody = false, entity = false, comment = false; + let exp = ""; + for(;i') { + if(comment){ + if( xmlData[i - 1] === "-" && xmlData[i - 2] === "-"){ + comment = false; + }else{ + throw new Error(`Invalid XML comment in DOCTYPE`); + } + }else if(entity){ + parseEntityExp(exp, entities); + entity = false; + } + angleBracketsCount--; + if (angleBracketsCount === 0) { + break; + } + }else if( xmlData[i] === '['){ + hasBody = true; + }else{ + exp += xmlData[i]; + } + } + if(angleBracketsCount !== 0){ + throw new Error(`Unclosed DOCTYPE`); + } + }else{ + throw new Error(`Invalid Tag instead of DOCTYPE`); + } + return {entities, i}; +} -module.exports = options => { - options = Object.assign({}, options); +const entityRegex = RegExp("^\\s([a-zA-z0-0]+)[ \t](['\"])([^&]+)\\2"); +function parseEntityExp(exp, entities){ + const match = entityRegex.exec(exp); + if(match){ + entities[ match[1] ] = { + regx : RegExp( `&${match[1]};`,"g"), + val: match[3] + }; + } +} +module.exports = readDocType; - const {array} = options; - let {encoding} = options; - const buffer = encoding === 'buffer'; - let objectMode = false; +/***/ }), - if (array) { - objectMode = !(encoding || buffer); - } else { - encoding = encoding || 'utf8'; - } +/***/ 6993: +/***/ ((__unused_webpack_module, exports) => { - if (buffer) { - encoding = null; - } - let len = 0; - const ret = []; - const stream = new PassThrough({objectMode}); +const defaultOptions = { + preserveOrder: false, + attributeNamePrefix: '@_', + attributesGroupName: false, + textNodeName: '#text', + ignoreAttributes: true, + removeNSPrefix: false, // remove NS from tag name or attribute name if true + allowBooleanAttributes: false, //a tag can have attributes without any value + //ignoreRootElement : false, + parseTagValue: true, + parseAttributeValue: false, + trimValues: true, //Trim string values of tag and attributes + cdataPropName: false, + numberParseOptions: { + hex: true, + leadingZeros: true + }, + tagValueProcessor: function(tagName, val) { + return val; + }, + attributeValueProcessor: function(attrName, val) { + return val; + }, + stopNodes: [], //nested tags will not be parsed even for errors + alwaysCreateTextNode: false, + isArray: () => false, + commentPropName: false, + unpairedTags: [], + processEntities: true, + htmlEntities: false, + ignoreDeclaration: false, + ignorePiTags: false, + transformTagName: false, +}; + +const buildOptions = function(options) { + return Object.assign({}, defaultOptions, options); +}; - if (encoding) { - stream.setEncoding(encoding); - } +exports.buildOptions = buildOptions; +exports.defaultOptions = defaultOptions; - stream.on('data', chunk => { - ret.push(chunk); +/***/ }), - if (objectMode) { - len = ret.length; - } else { - len += chunk.length; - } - }); +/***/ 5832: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - stream.getBufferedValue = () => { - if (array) { - return ret; - } +"use strict"; - return buffer ? Buffer.concat(ret, len) : ret.join(''); - }; +///@ts-check - stream.getBufferedLength = () => len; +const util = __nccwpck_require__(8280); +const xmlNode = __nccwpck_require__(7462); +const readDocType = __nccwpck_require__(6072); +const toNumber = __nccwpck_require__(4526); - return stream; -}; +const regx = + '<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)' + .replace(/NAME/g, util.nameRegexp); +//const tagsRegx = new RegExp("<(\\/?[\\w:\\-\._]+)([^>]*)>(\\s*"+cdataRegx+")*([^<]+)?","g"); +//const tagsRegx = new RegExp("<(\\/?)((\\w*:)?([\\w:\\-\._]+))([^>]*)>([^<]*)("+cdataRegx+"([^<]*))*([^<]+)?","g"); -/***/ }), +class OrderedObjParser{ + constructor(options){ + this.options = options; + this.currentNode = null; + this.tagsNodeStack = []; + this.docTypeEntities = {}; + this.lastEntities = { + "amp" : { regex: /&(amp|#38|#x26);/g, val : "&"}, + "apos" : { regex: /&(apos|#39|#x27);/g, val : "'"}, + "gt" : { regex: /&(gt|#62|#x3E);/g, val : ">"}, + "lt" : { regex: /&(lt|#60|#x3C);/g, val : "<"}, + "quot" : { regex: /&(quot|#34|#x22);/g, val : "\""}, + }; + this.htmlEntities = { + "space": { regex: /&(nbsp|#160);/g, val: " " }, + // "lt" : { regex: /&(lt|#60);/g, val: "<" }, + // "gt" : { regex: /&(gt|#62);/g, val: ">" }, + // "amp" : { regex: /&(amp|#38);/g, val: "&" }, + // "quot" : { regex: /&(quot|#34);/g, val: "\"" }, + // "apos" : { regex: /&(apos|#39);/g, val: "'" }, + "cent" : { regex: /&(cent|#162);/g, val: "¢" }, + "pound" : { regex: /&(pound|#163);/g, val: "£" }, + "yen" : { regex: /&(yen|#165);/g, val: "¥" }, + "euro" : { regex: /&(euro|#8364);/g, val: "€" }, + "copyright" : { regex: /&(copy|#169);/g, val: "©" }, + "reg" : { regex: /&(reg|#174);/g, val: "®" }, + "inr" : { regex: /&(inr|#8377);/g, val: "₹" }, + }; + this.addExternalEntities = addExternalEntities; + this.parseXml = parseXml; + this.parseTextData = parseTextData; + this.resolveNameSpace = resolveNameSpace; + this.buildAttributesMap = buildAttributesMap; + this.isItStopNode = isItStopNode; + this.replaceEntitiesValue = replaceEntitiesValue; + this.readStopNodeData = readStopNodeData; + this.saveTextToParentTag = saveTextToParentTag; + } -/***/ 1766: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +} -"use strict"; +function addExternalEntities(externalEntities){ + const entKeys = Object.keys(externalEntities); + for (let i = 0; i < entKeys.length; i++) { + const ent = entKeys[i]; + this.lastEntities[ent] = { + regex: new RegExp("&"+ent+";","g"), + val : externalEntities[ent] + } + } +} -const pump = __nccwpck_require__(8341); -const bufferStream = __nccwpck_require__(1585); +/** + * @param {string} val + * @param {string} tagName + * @param {string} jPath + * @param {boolean} dontTrim + * @param {boolean} hasAttributes + * @param {boolean} isLeafNode + * @param {boolean} escapeEntities + */ +function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) { + if (val !== undefined) { + if (this.options.trimValues && !dontTrim) { + val = val.trim(); + } + if(val.length > 0){ + if(!escapeEntities) val = this.replaceEntitiesValue(val); + + const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode); + if(newval === null || newval === undefined){ + //don't parse + return val; + }else if(typeof newval !== typeof val || newval !== val){ + //overwrite + return newval; + }else if(this.options.trimValues){ + return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions); + }else{ + const trimmedVal = val.trim(); + if(trimmedVal === val){ + return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions); + }else{ + return val; + } + } + } + } +} -class MaxBufferError extends Error { - constructor() { - super('maxBuffer exceeded'); - this.name = 'MaxBufferError'; - } +function resolveNameSpace(tagname) { + if (this.options.removeNSPrefix) { + const tags = tagname.split(':'); + const prefix = tagname.charAt(0) === '/' ? '/' : ''; + if (tags[0] === 'xmlns') { + return ''; + } + if (tags.length === 2) { + tagname = prefix + tags[1]; + } + } + return tagname; } -function getStream(inputStream, options) { - if (!inputStream) { - return Promise.reject(new Error('Expected a stream')); - } +//TODO: change regex to capture NS +//const attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])((.|\n)*?)\\2","gm"); +const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm'); - options = Object.assign({maxBuffer: Infinity}, options); +function buildAttributesMap(attrStr, jPath) { + if (!this.options.ignoreAttributes && typeof attrStr === 'string') { + // attrStr = attrStr.replace(/\r?\n/g, ' '); + //attrStr = attrStr || attrStr.trim(); - const {maxBuffer} = options; + const matches = util.getAllMatches(attrStr, attrsRegx); + const len = matches.length; //don't make it inline + const attrs = {}; + for (let i = 0; i < len; i++) { + const attrName = this.resolveNameSpace(matches[i][1]); + let oldVal = matches[i][4]; + const aName = this.options.attributeNamePrefix + attrName; + if (attrName.length) { + if (oldVal !== undefined) { + if (this.options.trimValues) { + oldVal = oldVal.trim(); + } + oldVal = this.replaceEntitiesValue(oldVal); + const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath); + if(newVal === null || newVal === undefined){ + //don't parse + attrs[aName] = oldVal; + }else if(typeof newVal !== typeof oldVal || newVal !== oldVal){ + //overwrite + attrs[aName] = newVal; + }else{ + //parse + attrs[aName] = parseValue( + oldVal, + this.options.parseAttributeValue, + this.options.numberParseOptions + ); + } + } else if (this.options.allowBooleanAttributes) { + attrs[aName] = true; + } + } + } + if (!Object.keys(attrs).length) { + return; + } + if (this.options.attributesGroupName) { + const attrCollection = {}; + attrCollection[this.options.attributesGroupName] = attrs; + return attrCollection; + } + return attrs; + } +} - let stream; - return new Promise((resolve, reject) => { - const rejectPromise = error => { - if (error) { // A null check - error.bufferedData = stream.getBufferedValue(); - } - reject(error); - }; +const parseXml = function(xmlData) { + xmlData = xmlData.replace(/\r\n?/g, "\n"); //TODO: remove this line + const xmlObj = new xmlNode('!xml'); + let currentNode = xmlObj; + let textData = ""; + let jPath = ""; + for(let i=0; i< xmlData.length; i++){//for each char in XML data + const ch = xmlData[i]; + if(ch === '<'){ + // const nextIndex = i+1; + // const _2ndChar = xmlData[nextIndex]; + if( xmlData[i+1] === '/') {//Closing Tag + const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.") + let tagName = xmlData.substring(i+2,closeIndex).trim(); - stream = pump(inputStream, bufferStream(options), error => { - if (error) { - rejectPromise(error); - return; - } + if(this.options.removeNSPrefix){ + const colonIndex = tagName.indexOf(":"); + if(colonIndex !== -1){ + tagName = tagName.substr(colonIndex+1); + } + } - resolve(); - }); + if(this.options.transformTagName) { + tagName = this.options.transformTagName(tagName); + } - stream.on('data', () => { - if (stream.getBufferedLength() > maxBuffer) { - rejectPromise(new MaxBufferError()); - } - }); - }).then(() => stream.getBufferedValue()); -} + if(currentNode){ + textData = this.saveTextToParentTag(textData, currentNode, jPath); + } -module.exports = getStream; -module.exports.buffer = (stream, options) => getStream(stream, Object.assign({}, options, {encoding: 'buffer'})); -module.exports.array = (stream, options) => getStream(stream, Object.assign({}, options, {array: true})); -module.exports.MaxBufferError = MaxBufferError; + jPath = jPath.substr(0, jPath.lastIndexOf(".")); + + currentNode = this.tagsNodeStack.pop();//avoid recurssion, set the parent tag scope + textData = ""; + i = closeIndex; + } else if( xmlData[i+1] === '?') { + let tagData = readTagExp(xmlData,i, false, "?>"); + if(!tagData) throw new Error("Pi Tag is not closed."); -/***/ }), + textData = this.saveTextToParentTag(textData, currentNode, jPath); + if( (this.options.ignoreDeclaration && tagData.tagName === "?xml") || this.options.ignorePiTags){ -/***/ 1554: -/***/ ((module) => { + }else{ + + const childNode = new xmlNode(tagData.tagName); + childNode.add(this.options.textNodeName, ""); + + if(tagData.tagName !== tagData.tagExp && tagData.attrExpPresent){ + childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath); + } + currentNode.addChild(childNode); -"use strict"; + } -var isStream = module.exports = function (stream) { - return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function'; -}; + i = tagData.closeIndex + 1; + } else if(xmlData.substr(i + 1, 3) === '!--') { + const endIndex = findClosingIndex(xmlData, "-->", i+4, "Comment is not closed.") + if(this.options.commentPropName){ + const comment = xmlData.substring(i + 4, endIndex - 2); -isStream.writable = function (stream) { - return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object'; -}; + textData = this.saveTextToParentTag(textData, currentNode, jPath); -isStream.readable = function (stream) { - return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object'; -}; + currentNode.add(this.options.commentPropName, [ { [this.options.textNodeName] : comment } ]); + } + i = endIndex; + } else if( xmlData.substr(i + 1, 2) === '!D') { + const result = readDocType(xmlData, i); + this.docTypeEntities = result.entities; + i = result.i; + }else if(xmlData.substr(i + 1, 2) === '![') { + const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2; + const tagExp = xmlData.substring(i + 9,closeIndex); -isStream.duplex = function (stream) { - return isStream.writable(stream) && isStream.readable(stream); -}; + textData = this.saveTextToParentTag(textData, currentNode, jPath); -isStream.transform = function (stream) { - return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object'; -}; + //cdata should be set even if it is 0 length string + if(this.options.cdataPropName){ + // let val = this.parseTextData(tagExp, this.options.cdataPropName, jPath + "." + this.options.cdataPropName, true, false, true); + // if(!val) val = ""; + currentNode.add(this.options.cdataPropName, [ { [this.options.textNodeName] : tagExp } ]); + }else{ + let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true); + if(val == undefined) val = ""; + currentNode.add(this.options.textNodeName, val); + } + + i = closeIndex + 2; + }else {//Opening tag + let result = readTagExp(xmlData,i, this. options.removeNSPrefix); + let tagName= result.tagName; + let tagExp = result.tagExp; + let attrExpPresent = result.attrExpPresent; + let closeIndex = result.closeIndex; + if (this.options.transformTagName) { + tagName = this.options.transformTagName(tagName); + } + + //save text as child node + if (currentNode && textData) { + if(currentNode.tagname !== '!xml'){ + //when nested tag is found + textData = this.saveTextToParentTag(textData, currentNode, jPath, false); + } + } -/***/ }), + if(tagName !== xmlObj.tagname){ + jPath += jPath ? "." + tagName : tagName; + } -/***/ 7126: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + //check if last tag was unpaired tag + const lastTag = currentNode; + if(lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1 ){ + currentNode = this.tagsNodeStack.pop(); + } -var fs = __nccwpck_require__(7147) -var core -if (process.platform === 'win32' || global.TESTING_WINDOWS) { - core = __nccwpck_require__(2001) -} else { - core = __nccwpck_require__(9728) -} + if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) { //TODO: namespace + let tagContent = ""; + //self-closing tag + if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){ + i = result.closeIndex; + } + //boolean tag + else if(this.options.unpairedTags.indexOf(tagName) !== -1){ + i = result.closeIndex; + } + //normal tag + else{ + //read until closing tag is found + const result = this.readStopNodeData(xmlData, tagName, closeIndex + 1); + if(!result) throw new Error(`Unexpected end of ${tagName}`); + i = result.i; + tagContent = result.tagContent; + } -module.exports = isexe -isexe.sync = sync + const childNode = new xmlNode(tagName); + if(tagName !== tagExp && attrExpPresent){ + childNode[":@"] = this.buildAttributesMap(tagExp, jPath); + } + if(tagContent) { + tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true); + } + + jPath = jPath.substr(0, jPath.lastIndexOf(".")); + childNode.add(this.options.textNodeName, tagContent); + + currentNode.addChild(childNode); + }else{ + //selfClosing tag + if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){ + if(tagName[tagName.length - 1] === "/"){ //remove trailing '/' + tagName = tagName.substr(0, tagName.length - 1); + tagExp = tagName; + }else{ + tagExp = tagExp.substr(0, tagExp.length - 1); + } + + if(this.options.transformTagName) { + tagName = this.options.transformTagName(tagName); + } -function isexe (path, options, cb) { - if (typeof options === 'function') { - cb = options - options = {} + const childNode = new xmlNode(tagName); + if(tagName !== tagExp && attrExpPresent){ + childNode[":@"] = this.buildAttributesMap(tagExp, jPath); + } + jPath = jPath.substr(0, jPath.lastIndexOf(".")); + currentNode.addChild(childNode); + } + //opening tag + else{ + const childNode = new xmlNode( tagName); + this.tagsNodeStack.push(currentNode); + + if(tagName !== tagExp && attrExpPresent){ + childNode[":@"] = this.buildAttributesMap(tagExp, jPath); + } + currentNode.addChild(childNode); + currentNode = childNode; + } + textData = ""; + i = closeIndex; + } + } + }else{ + textData += xmlData[i]; + } } + return xmlObj.child; +} - if (!cb) { - if (typeof Promise !== 'function') { - throw new TypeError('callback not provided') +const replaceEntitiesValue = function(val){ + if(this.options.processEntities){ + for(let entityName in this.docTypeEntities){ + const entity = this.docTypeEntities[entityName]; + val = val.replace( entity.regx, entity.val); + } + for(let entityName in this.lastEntities){ + const entity = this.lastEntities[entityName]; + val = val.replace( entity.regex, entity.val); + } + if(this.options.htmlEntities){ + for(let entityName in this.htmlEntities){ + const entity = this.htmlEntities[entityName]; + val = val.replace( entity.regex, entity.val); + } } + } + return val; +} +function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) { + if (textData) { //store previously collected data as textNode + if(isLeafNode === undefined) isLeafNode = Object.keys(currentNode.child).length === 0 + + textData = this.parseTextData(textData, + currentNode.tagname, + jPath, + false, + currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false, + isLeafNode); - return new Promise(function (resolve, reject) { - isexe(path, options || {}, function (er, is) { - if (er) { - reject(er) - } else { - resolve(is) - } - }) - }) + if (textData !== undefined && textData !== "") + currentNode.add(this.options.textNodeName, textData); + textData = ""; } + return textData; +} - core(path, options || {}, function (er, is) { - // ignore EACCES because that just means we aren't allowed to run it - if (er) { - if (er.code === 'EACCES' || options && options.ignoreErrors) { - er = null - is = false - } - } - cb(er, is) - }) +//TODO: use jPath to simplify the logic +/** + * + * @param {string[]} stopNodes + * @param {string} jPath + * @param {string} currentTagName + */ +function isItStopNode(stopNodes, jPath, currentTagName){ + const allNodesExp = "*." + currentTagName; + for (const stopNodePath in stopNodes) { + const stopNodeExp = stopNodes[stopNodePath]; + if( allNodesExp === stopNodeExp || jPath === stopNodeExp ) return true; + } + return false; } -function sync (path, options) { - // my kingdom for a filtered catch - try { - return core.sync(path, options || {}) - } catch (er) { - if (options && options.ignoreErrors || er.code === 'EACCES') { - return false - } else { - throw er +/** + * Returns the tag Expression and where it is ending handling single-dobule quotes situation + * @param {string} xmlData + * @param {number} i starting index + * @returns + */ +function tagExpWithClosingIndex(xmlData, i, closingChar = ">"){ + let attrBoundary; + let tagExp = ""; + for (let index = i; index < xmlData.length; index++) { + let ch = xmlData[index]; + if (attrBoundary) { + if (ch === attrBoundary) attrBoundary = "";//reset + } else if (ch === '"' || ch === "'") { + attrBoundary = ch; + } else if (ch === closingChar[0]) { + if(closingChar[1]){ + if(xmlData[index + 1] === closingChar[1]){ + return { + data: tagExp, + index: index + } + } + }else{ + return { + data: tagExp, + index: index + } + } + } else if (ch === '\t') { + ch = " " } + tagExp += ch; } } +function findClosingIndex(xmlData, str, i, errMsg){ + const closingIndex = xmlData.indexOf(str, i); + if(closingIndex === -1){ + throw new Error(errMsg) + }else{ + return closingIndex + str.length - 1; + } +} -/***/ }), +function readTagExp(xmlData,i, removeNSPrefix, closingChar = ">"){ + const result = tagExpWithClosingIndex(xmlData, i+1, closingChar); + if(!result) return; + let tagExp = result.data; + const closeIndex = result.index; + const separatorIndex = tagExp.search(/\s/); + let tagName = tagExp; + let attrExpPresent = true; + if(separatorIndex !== -1){//separate tag name and attributes expression + tagName = tagExp.substr(0, separatorIndex).replace(/\s\s*$/, ''); + tagExp = tagExp.substr(separatorIndex + 1); + } -/***/ 9728: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if(removeNSPrefix){ + const colonIndex = tagName.indexOf(":"); + if(colonIndex !== -1){ + tagName = tagName.substr(colonIndex+1); + attrExpPresent = tagName !== result.data.substr(colonIndex + 1); + } + } -module.exports = isexe -isexe.sync = sync + return { + tagName: tagName, + tagExp: tagExp, + closeIndex: closeIndex, + attrExpPresent: attrExpPresent, + } +} +/** + * find paired tag for a stop node + * @param {string} xmlData + * @param {string} tagName + * @param {number} i + */ +function readStopNodeData(xmlData, tagName, i){ + const startIndex = i; + // Starting at 1 since we already have an open tag + let openTagCount = 1; -var fs = __nccwpck_require__(7147) + for (; i < xmlData.length; i++) { + if( xmlData[i] === "<"){ + if (xmlData[i+1] === "/") {//close tag + const closeIndex = findClosingIndex(xmlData, ">", i, `${tagName} is not closed`); + let closeTagName = xmlData.substring(i+2,closeIndex).trim(); + if(closeTagName === tagName){ + openTagCount--; + if (openTagCount === 0) { + return { + tagContent: xmlData.substring(startIndex, i), + i : closeIndex + } + } + } + i=closeIndex; + } else if(xmlData[i+1] === '?') { + const closeIndex = findClosingIndex(xmlData, "?>", i+1, "StopNode is not closed.") + i=closeIndex; + } else if(xmlData.substr(i + 1, 3) === '!--') { + const closeIndex = findClosingIndex(xmlData, "-->", i+3, "StopNode is not closed.") + i=closeIndex; + } else if(xmlData.substr(i + 1, 2) === '![') { + const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2; + i=closeIndex; + } else { + const tagData = readTagExp(xmlData, i, '>') -function isexe (path, options, cb) { - fs.stat(path, function (er, stat) { - cb(er, er ? false : checkStat(stat, options)) - }) + if (tagData) { + const openTagName = tagData && tagData.tagName; + if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length-1] !== "/") { + openTagCount++; + } + i=tagData.closeIndex; + } + } + } + }//end for loop } -function sync (path, options) { - return checkStat(fs.statSync(path), options) +function parseValue(val, shouldParse, options) { + if (shouldParse && typeof val === 'string') { + //console.log(options) + const newval = val.trim(); + if(newval === 'true' ) return true; + else if(newval === 'false' ) return false; + else return toNumber(val, options); + } else { + if (util.isExist(val)) { + return val; + } else { + return ''; + } + } } -function checkStat (stat, options) { - return stat.isFile() && checkMode(stat, options) -} -function checkMode (stat, options) { - var mod = stat.mode - var uid = stat.uid - var gid = stat.gid +module.exports = OrderedObjParser; - var myUid = options.uid !== undefined ? - options.uid : process.getuid && process.getuid() - var myGid = options.gid !== undefined ? - options.gid : process.getgid && process.getgid() - var u = parseInt('100', 8) - var g = parseInt('010', 8) - var o = parseInt('001', 8) - var ug = u | g +/***/ }), - var ret = (mod & o) || - (mod & g) && gid === myGid || - (mod & u) && uid === myUid || - (mod & ug) && myUid === 0 +/***/ 2380: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return ret +const { buildOptions} = __nccwpck_require__(6993); +const OrderedObjParser = __nccwpck_require__(5832); +const { prettify} = __nccwpck_require__(2882); +const validator = __nccwpck_require__(1739); + +class XMLParser{ + + constructor(options){ + this.externalEntities = {}; + this.options = buildOptions(options); + + } + /** + * Parse XML dats to JS object + * @param {string|Buffer} xmlData + * @param {boolean|Object} validationOption + */ + parse(xmlData,validationOption){ + if(typeof xmlData === "string"){ + }else if( xmlData.toString){ + xmlData = xmlData.toString(); + }else{ + throw new Error("XML data is accepted in String or Bytes[] form.") + } + if( validationOption){ + if(validationOption === true) validationOption = {}; //validate with default options + + const result = validator.validate(xmlData, validationOption); + if (result !== true) { + throw Error( `${result.err.msg}:${result.err.line}:${result.err.col}` ) + } + } + const orderedObjParser = new OrderedObjParser(this.options); + orderedObjParser.addExternalEntities(this.externalEntities); + const orderedResult = orderedObjParser.parseXml(xmlData); + if(this.options.preserveOrder || orderedResult === undefined) return orderedResult; + else return prettify(orderedResult, this.options); + } + + /** + * Add Entity which is not by default supported by this library + * @param {string} key + * @param {string} value + */ + addEntity(key, value){ + if(value.indexOf("&") !== -1){ + throw new Error("Entity value can't have '&'") + }else if(key.indexOf("&") !== -1 || key.indexOf(";") !== -1){ + throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for ' '") + }else{ + this.externalEntities[key] = value; + } + } } +module.exports = XMLParser; /***/ }), -/***/ 2001: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 2882: +/***/ ((__unused_webpack_module, exports) => { -module.exports = isexe -isexe.sync = sync +"use strict"; -var fs = __nccwpck_require__(7147) -function checkPathExt (path, options) { - var pathext = options.pathExt !== undefined ? - options.pathExt : process.env.PATHEXT +/** + * + * @param {array} node + * @param {any} options + * @returns + */ +function prettify(node, options){ + return compress( node, options); +} - if (!pathext) { - return true - } +/** + * + * @param {array} arr + * @param {object} options + * @param {string} jPath + * @returns object + */ +function compress(arr, options, jPath){ + let text; + const compressedObj = {}; + for (let i = 0; i < arr.length; i++) { + const tagObj = arr[i]; + const property = propName(tagObj); + let newJpath = ""; + if(jPath === undefined) newJpath = property; + else newJpath = jPath + "." + property; + + if(property === options.textNodeName){ + if(text === undefined) text = tagObj[property]; + else text += "" + tagObj[property]; + }else if(property === undefined){ + continue; + }else if(tagObj[property]){ + + let val = compress(tagObj[property], options, newJpath); + const isLeaf = isLeafTag(val, options); - pathext = pathext.split(';') - if (pathext.indexOf('') !== -1) { - return true - } - for (var i = 0; i < pathext.length; i++) { - var p = pathext[i].toLowerCase() - if (p && path.substr(-p.length).toLowerCase() === p) { - return true + if(tagObj[":@"]){ + assignAttributes( val, tagObj[":@"], newJpath, options); + }else if(Object.keys(val).length === 1 && val[options.textNodeName] !== undefined && !options.alwaysCreateTextNode){ + val = val[options.textNodeName]; + }else if(Object.keys(val).length === 0){ + if(options.alwaysCreateTextNode) val[options.textNodeName] = ""; + else val = ""; + } + + if(compressedObj[property] !== undefined && compressedObj.hasOwnProperty(property)) { + if(!Array.isArray(compressedObj[property])) { + compressedObj[property] = [ compressedObj[property] ]; + } + compressedObj[property].push(val); + }else{ + //TODO: if a node is not an array, then check if it should be an array + //also determine if it is a leaf node + if (options.isArray(property, newJpath, isLeaf )) { + compressedObj[property] = [val]; + }else{ + compressedObj[property] = val; + } + } } + } - return false + // if(text && text.length > 0) compressedObj[options.textNodeName] = text; + if(typeof text === "string"){ + if(text.length > 0) compressedObj[options.textNodeName] = text; + }else if(text !== undefined) compressedObj[options.textNodeName] = text; + return compressedObj; } -function checkStat (stat, path, options) { - if (!stat.isSymbolicLink() && !stat.isFile()) { - return false +function propName(obj){ + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if(key !== ":@") return key; } - return checkPathExt(path, options) } -function isexe (path, options, cb) { - fs.stat(path, function (er, stat) { - cb(er, er ? false : checkStat(stat, path, options)) - }) +function assignAttributes(obj, attrMap, jpath, options){ + if (attrMap) { + const keys = Object.keys(attrMap); + const len = keys.length; //don't make it inline + for (let i = 0; i < len; i++) { + const atrrName = keys[i]; + if (options.isArray(atrrName, jpath + "." + atrrName, true, true)) { + obj[atrrName] = [ attrMap[atrrName] ]; + } else { + obj[atrrName] = attrMap[atrrName]; + } + } + } } -function sync (path, options) { - return checkStat(fs.statSync(path), path, options) +function isLeafTag(obj, options){ + const propCount = Object.keys(obj).length; + if( propCount === 0 || (propCount === 1 && obj[options.textNodeName]) ) return true; + return false; } +exports.prettify = prettify; /***/ }), -/***/ 9197: +/***/ 7462: /***/ ((module) => { -/** - * lodash (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ +"use strict"; -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; +class XmlNode{ + constructor(tagname) { + this.tagname = tagname; + this.child = []; //nested tags, text, cdata, comments in order + this[":@"] = {}; //attributes map + } + add(key,val){ + // this.child.push( {name : key, val: val, isCdata: isCdata }); + this.child.push( {[key]: val }); + } + addChild(node) { + if(node[":@"] && Object.keys(node[":@"]).length > 0){ + this.child.push( { [node.tagname]: node.child, [":@"]: node[":@"] }); + }else{ + this.child.push( { [node.tagname]: node.child }); + } + }; +}; -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; -/** `Object#toString` result references. */ -var funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - symbolTag = '[object Symbol]'; +module.exports = XmlNode; -/** Used to match property names within property paths. */ -var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/, - reLeadingDot = /^\./, - rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; +/***/ }), -/** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). - */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; +/***/ 1585: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -/** Used to match backslashes in property paths. */ -var reEscapeChar = /\\(\\)?/g; +"use strict"; -/** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; +const {PassThrough} = __nccwpck_require__(2781); -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; +module.exports = options => { + options = Object.assign({}, options); -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + const {array} = options; + let {encoding} = options; + const buffer = encoding === 'buffer'; + let objectMode = false; -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); + if (array) { + objectMode = !(encoding || buffer); + } else { + encoding = encoding || 'utf8'; + } -/** - * Gets the value at `key` of `object`. - * - * @private - * @param {Object} [object] The object to query. - * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. - */ -function getValue(object, key) { - return object == null ? undefined : object[key]; -} + if (buffer) { + encoding = null; + } -/** - * Checks if `value` is a host object in IE < 9. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a host object, else `false`. - */ -function isHostObject(value) { - // Many host objects are `Object` objects that can coerce to strings - // despite having improperly defined `toString` methods. - var result = false; - if (value != null && typeof value.toString != 'function') { - try { - result = !!(value + ''); - } catch (e) {} - } - return result; -} + let len = 0; + const ret = []; + const stream = new PassThrough({objectMode}); -/** Used for built-in method references. */ -var arrayProto = Array.prototype, - funcProto = Function.prototype, - objectProto = Object.prototype; + if (encoding) { + stream.setEncoding(encoding); + } -/** Used to detect overreaching core-js shims. */ -var coreJsData = root['__core-js_shared__']; + stream.on('data', chunk => { + ret.push(chunk); -/** Used to detect methods masquerading as native. */ -var maskSrcKey = (function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); - return uid ? ('Symbol(src)_1.' + uid) : ''; -}()); + if (objectMode) { + len = ret.length; + } else { + len += chunk.length; + } + }); -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; + stream.getBufferedValue = () => { + if (array) { + return ret; + } -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; + return buffer ? Buffer.concat(ret, len) : ret.join(''); + }; -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; + stream.getBufferedLength = () => len; -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); + return stream; +}; -/** Built-in value references. */ -var Symbol = root.Symbol, - splice = arrayProto.splice; -/* Built-in method references that are verified to be native. */ -var Map = getNative(root, 'Map'), - nativeCreate = getNative(Object, 'create'); +/***/ }), -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; +/***/ 1766: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -/** - * Creates a hash object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Hash(entries) { - var index = -1, - length = entries ? entries.length : 0; +"use strict"; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} +const pump = __nccwpck_require__(8341); +const bufferStream = __nccwpck_require__(1585); -/** - * Removes all key-value entries from the hash. - * - * @private - * @name clear - * @memberOf Hash - */ -function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; +class MaxBufferError extends Error { + constructor() { + super('maxBuffer exceeded'); + this.name = 'MaxBufferError'; + } } -/** - * Removes `key` and its value from the hash. - * - * @private - * @name delete - * @memberOf Hash - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function hashDelete(key) { - return this.has(key) && delete this.__data__[key]; -} +function getStream(inputStream, options) { + if (!inputStream) { + return Promise.reject(new Error('Expected a stream')); + } -/** - * Gets the hash value for `key`. - * - * @private - * @name get - * @memberOf Hash - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty.call(data, key) ? data[key] : undefined; -} + options = Object.assign({maxBuffer: Infinity}, options); -/** - * Checks if a hash value for `key` exists. - * - * @private - * @name has - * @memberOf Hash - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function hashHas(key) { - var data = this.__data__; - return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); -} + const {maxBuffer} = options; -/** - * Sets the hash `key` to `value`. - * - * @private - * @name set - * @memberOf Hash - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. - */ -function hashSet(key, value) { - var data = this.__data__; - data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; - return this; -} + let stream; + return new Promise((resolve, reject) => { + const rejectPromise = error => { + if (error) { // A null check + error.bufferedData = stream.getBufferedValue(); + } + reject(error); + }; -// Add methods to `Hash`. -Hash.prototype.clear = hashClear; -Hash.prototype['delete'] = hashDelete; -Hash.prototype.get = hashGet; -Hash.prototype.has = hashHas; -Hash.prototype.set = hashSet; + stream = pump(inputStream, bufferStream(options), error => { + if (error) { + rejectPromise(error); + return; + } -/** - * Creates an list cache object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function ListCache(entries) { - var index = -1, - length = entries ? entries.length : 0; + resolve(); + }); - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } + stream.on('data', () => { + if (stream.getBufferedLength() > maxBuffer) { + rejectPromise(new MaxBufferError()); + } + }); + }).then(() => stream.getBufferedValue()); } -/** - * Removes all key-value entries from the list cache. - * - * @private - * @name clear - * @memberOf ListCache - */ -function listCacheClear() { - this.__data__ = []; -} +module.exports = getStream; +module.exports.buffer = (stream, options) => getStream(stream, Object.assign({}, options, {encoding: 'buffer'})); +module.exports.array = (stream, options) => getStream(stream, Object.assign({}, options, {array: true})); +module.exports.MaxBufferError = MaxBufferError; -/** - * Removes `key` and its value from the list cache. - * - * @private - * @name delete - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); - } - return true; -} +/***/ }), -/** - * Gets the list cache value for `key`. - * - * @private - * @name get - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); +/***/ 1554: +/***/ ((module) => { - return index < 0 ? undefined : data[index][1]; -} +"use strict"; -/** - * Checks if a list cache value for `key` exists. - * - * @private - * @name has - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; -} -/** - * Sets the list cache `key` to `value`. - * - * @private - * @name set - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. - */ -function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); +var isStream = module.exports = function (stream) { + return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function'; +}; - if (index < 0) { - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; -} +isStream.writable = function (stream) { + return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object'; +}; -// Add methods to `ListCache`. -ListCache.prototype.clear = listCacheClear; -ListCache.prototype['delete'] = listCacheDelete; -ListCache.prototype.get = listCacheGet; -ListCache.prototype.has = listCacheHas; -ListCache.prototype.set = listCacheSet; +isStream.readable = function (stream) { + return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object'; +}; -/** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function MapCache(entries) { - var index = -1, - length = entries ? entries.length : 0; +isStream.duplex = function (stream) { + return isStream.writable(stream) && isStream.readable(stream); +}; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} +isStream.transform = function (stream) { + return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object'; +}; -/** - * Removes all key-value entries from the map. - * - * @private - * @name clear - * @memberOf MapCache - */ -function mapCacheClear() { - this.__data__ = { - 'hash': new Hash, - 'map': new (Map || ListCache), - 'string': new Hash - }; -} -/** - * Removes `key` and its value from the map. - * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function mapCacheDelete(key) { - return getMapData(this, key)['delete'](key); -} +/***/ }), -/** - * Gets the map value for `key`. - * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function mapCacheGet(key) { - return getMapData(this, key).get(key); -} +/***/ 7126: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -/** - * Checks if a map value for `key` exists. - * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function mapCacheHas(key) { - return getMapData(this, key).has(key); +var fs = __nccwpck_require__(7147) +var core +if (process.platform === 'win32' || global.TESTING_WINDOWS) { + core = __nccwpck_require__(2001) +} else { + core = __nccwpck_require__(9728) } -/** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ -function mapCacheSet(key, value) { - getMapData(this, key).set(key, value); - return this; -} +module.exports = isexe +isexe.sync = sync -// Add methods to `MapCache`. -MapCache.prototype.clear = mapCacheClear; -MapCache.prototype['delete'] = mapCacheDelete; -MapCache.prototype.get = mapCacheGet; -MapCache.prototype.has = mapCacheHas; -MapCache.prototype.set = mapCacheSet; - -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } +function isexe (path, options, cb) { + if (typeof options === 'function') { + cb = options + options = {} } - return -1; -} - -/** - * The base implementation of `_.get` without support for default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. - */ -function baseGet(object, path) { - path = isKey(path, object) ? [path] : castPath(path); - var index = 0, - length = path.length; + if (!cb) { + if (typeof Promise !== 'function') { + throw new TypeError('callback not provided') + } - while (object != null && index < length) { - object = object[toKey(path[index++])]; + return new Promise(function (resolve, reject) { + isexe(path, options || {}, function (er, is) { + if (er) { + reject(er) + } else { + resolve(is) + } + }) + }) } - return (index && index == length) ? object : undefined; + + core(path, options || {}, function (er, is) { + // ignore EACCES because that just means we aren't allowed to run it + if (er) { + if (er.code === 'EACCES' || options && options.ignoreErrors) { + er = null + is = false + } + } + cb(er, is) + }) } -/** - * The base implementation of `_.isNative` without bad shim checks. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - */ -function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; +function sync (path, options) { + // my kingdom for a filtered catch + try { + return core.sync(path, options || {}) + } catch (er) { + if (options && options.ignoreErrors || er.code === 'EACCES') { + return false + } else { + throw er + } } - var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); } -/** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ -function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; + +/***/ }), + +/***/ 9728: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +module.exports = isexe +isexe.sync = sync + +var fs = __nccwpck_require__(7147) + +function isexe (path, options, cb) { + fs.stat(path, function (er, stat) { + cb(er, er ? false : checkStat(stat, options)) + }) } -/** - * Casts `value` to a path array if it's not one. - * - * @private - * @param {*} value The value to inspect. - * @returns {Array} Returns the cast property path array. - */ -function castPath(value) { - return isArray(value) ? value : stringToPath(value); +function sync (path, options) { + return checkStat(fs.statSync(path), options) } -/** - * Gets the data for `map`. - * - * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. - */ -function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) - ? data[typeof key == 'string' ? 'string' : 'hash'] - : data.map; +function checkStat (stat, options) { + return stat.isFile() && checkMode(stat, options) } -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : undefined; +function checkMode (stat, options) { + var mod = stat.mode + var uid = stat.uid + var gid = stat.gid + + var myUid = options.uid !== undefined ? + options.uid : process.getuid && process.getuid() + var myGid = options.gid !== undefined ? + options.gid : process.getgid && process.getgid() + + var u = parseInt('100', 8) + var g = parseInt('010', 8) + var o = parseInt('001', 8) + var ug = u | g + + var ret = (mod & o) || + (mod & g) && gid === myGid || + (mod & u) && uid === myUid || + (mod & ug) && myUid === 0 + + return ret } -/** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ -function isKey(value, object) { - if (isArray(value)) { - return false; + +/***/ }), + +/***/ 2001: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +module.exports = isexe +isexe.sync = sync + +var fs = __nccwpck_require__(7147) + +function checkPathExt (path, options) { + var pathext = options.pathExt !== undefined ? + options.pathExt : process.env.PATHEXT + + if (!pathext) { + return true } - var type = typeof value; - if (type == 'number' || type == 'symbol' || type == 'boolean' || - value == null || isSymbol(value)) { - return true; + + pathext = pathext.split(';') + if (pathext.indexOf('') !== -1) { + return true } - return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || - (object != null && value in Object(object)); + for (var i = 0; i < pathext.length; i++) { + var p = pathext[i].toLowerCase() + if (p && path.substr(-p.length).toLowerCase() === p) { + return true + } + } + return false } -/** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ -function isKeyable(value) { - var type = typeof value; - return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') - ? (value !== '__proto__') - : (value === null); +function checkStat (stat, path, options) { + if (!stat.isSymbolicLink() && !stat.isFile()) { + return false + } + return checkPathExt(path, options) } -/** - * Checks if `func` has its source masked. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is masked, else `false`. - */ -function isMasked(func) { - return !!maskSrcKey && (maskSrcKey in func); +function isexe (path, options, cb) { + fs.stat(path, function (er, stat) { + cb(er, er ? false : checkStat(stat, path, options)) + }) } -/** - * Converts `string` to a property path array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the property path array. +function sync (path, options) { + return checkStat(fs.statSync(path), path, options) +} + + +/***/ }), + +/***/ 9197: +/***/ ((module) => { + +/** + * lodash (Custom Build) + * Build: `lodash modularize exports="npm" -o ./` + * Copyright jQuery Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ -var stringToPath = memoize(function(string) { - string = toString(string); - var result = []; - if (reLeadingDot.test(string)) { - result.push(''); - } - string.replace(rePropName, function(match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); - }); - return result; -}); +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** `Object#toString` result references. */ +var funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + symbolTag = '[object Symbol]'; + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/, + reLeadingDot = /^\./, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** - * Converts `value` to a string key if it's not a string or symbol. + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +/** + * Gets the value at `key` of `object`. * * @private - * @param {*} value The value to inspect. - * @returns {string|symbol} Returns the key. + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. */ -function toKey(value) { - if (typeof value == 'string' || isSymbol(value)) { - return value; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +function getValue(object, key) { + return object == null ? undefined : object[key]; } /** - * Converts `func` to its source code. + * Checks if `value` is a host object in IE < 9. * * @private - * @param {Function} func The function to process. - * @returns {string} Returns the source code. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a host object, else `false`. */ -function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) {} +function isHostObject(value) { + // Many host objects are `Object` objects that can coerce to strings + // despite having improperly defined `toString` methods. + var result = false; + if (value != null && typeof value.toString != 'function') { try { - return (func + ''); + result = !!(value + ''); } catch (e) {} } - return ''; + return result; } +/** Used for built-in method references. */ +var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype; + +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; + +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + /** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided, it determines the cache key for storing the result based on the - * arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is used as the map cache key. The `func` - * is invoked with the `this` binding of the memoized function. - * - * **Note:** The cache is exposed as the `cache` property on the memoized - * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) - * method interface of `delete`, `get`, `has`, and `set`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] The function to resolve the cache key. - * @returns {Function} Returns the new memoized function. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * var other = { 'c': 3, 'd': 4 }; - * - * var values = _.memoize(_.values); - * values(object); - * // => [1, 2] - * - * values(other); - * // => [3, 4] - * - * object.a = 2; - * values(object); - * // => [1, 2] - * - * // Modify the result cache. - * values.cache.set(object, ['a', 'b']); - * values(object); - * // => ['a', 'b'] - * - * // Replace `_.memoize.Cache`. - * _.memoize.Cache = WeakMap; + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. */ -function memoize(func, resolver) { - if (typeof func != 'function' || (resolver && typeof resolver != 'function')) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var memoized = function() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; +var objectToString = objectProto.toString; - if (cache.has(key)) { - return cache.get(key); - } - var result = func.apply(this, args); - memoized.cache = cache.set(key, result); - return result; - }; - memoized.cache = new (memoize.Cache || MapCache); - return memoized; -} +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); -// Assign cache to `_.memoize`. -memoize.Cache = MapCache; +/** Built-in value references. */ +var Symbol = root.Symbol, + splice = arrayProto.splice; + +/* Built-in method references that are verified to be native. */ +var Map = getNative(root, 'Map'), + nativeCreate = getNative(Object, 'create'); + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; /** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false + * Creates a hash object. * - * _.eq(NaN, NaN); - * // => true + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -function eq(value, other) { - return value === other || (value !== value && other !== other); +function Hash(entries) { + var index = -1, + length = entries ? entries.length : 0; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } /** - * Checks if `value` is classified as an `Array` object. + * Removes all key-value entries from the hash. * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false + * @private + * @name clear + * @memberOf Hash */ -var isArray = Array.isArray; +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; +} /** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true + * Removes `key` and its value from the hash. * - * _.isFunction(/abc/); - * // => false + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8-9 which returns 'object' for typed array and other constructors. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; +function hashDelete(key) { + return this.has(key) && delete this.__data__[key]; } /** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true + * Gets the hash value for `key`. * - * _.isObject(null); - * // => false + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); +function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty.call(data, key) ? data[key] : undefined; } /** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false + * Checks if a hash value for `key` exists. * - * _.isObjectLike(null); - * // => false + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; +function hashHas(key) { + var data = this.__data__; + return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); } /** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true + * Sets the hash `key` to `value`. * - * _.isSymbol('abc'); - * // => false + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && objectToString.call(value) == symbolTag); +function hashSet(key, value) { + var data = this.__data__; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; } +// Add methods to `Hash`. +Hash.prototype.clear = hashClear; +Hash.prototype['delete'] = hashDelete; +Hash.prototype.get = hashGet; +Hash.prototype.has = hashHas; +Hash.prototype.set = hashSet; + /** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {string} Returns the string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' + * Creates an list cache object. * - * _.toString([1, 2, 3]); - * // => '1,2,3' + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -function toString(value) { - return value == null ? '' : baseToString(value); +function ListCache(entries) { + var index = -1, + length = entries ? entries.length : 0; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } /** - * Gets the value at `path` of `object`. If the resolved value is - * `undefined`, the `defaultValue` is returned in its place. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.get(object, 'a[0].b.c'); - * // => 3 - * - * _.get(object, ['a', '0', 'b', 'c']); - * // => 3 + * Removes all key-value entries from the list cache. * - * _.get(object, 'a.b.c', 'default'); - * // => 'default' + * @private + * @name clear + * @memberOf ListCache */ -function get(object, path, defaultValue) { - var result = object == null ? undefined : baseGet(object, path); - return result === undefined ? defaultValue : result; +function listCacheClear() { + this.__data__ = []; } -module.exports = get; - - -/***/ }), - -/***/ 1552: -/***/ ((module) => { - /** - * lodash (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ +function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0, - MAX_SAFE_INTEGER = 9007199254740991; - -/** `Object#toString` result references. */ -var funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - symbolTag = '[object Symbol]'; - -/** Used to match property names within property paths. */ -var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/, - reLeadingDot = /^\./, - rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + return true; +} /** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - -/** Used to match backslashes in property paths. */ -var reEscapeChar = /\\(\\)?/g; - -/** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; +function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); + return index < 0 ? undefined : data[index][1]; +} /** - * Gets the value at `key` of `object`. + * Checks if a list cache value for `key` exists. * * @private - * @param {Object} [object] The object to query. - * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function getValue(object, key) { - return object == null ? undefined : object[key]; +function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; } /** - * Checks if `value` is a host object in IE < 9. + * Sets the list cache `key` to `value`. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. */ -function isHostObject(value) { - // Many host objects are `Object` objects that can coerce to strings - // despite having improperly defined `toString` methods. - var result = false; - if (value != null && typeof value.toString != 'function') { - try { - result = !!(value + ''); - } catch (e) {} +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + data.push([key, value]); + } else { + data[index][1] = value; } - return result; + return this; } -/** Used for built-in method references. */ -var arrayProto = Array.prototype, - funcProto = Function.prototype, - objectProto = Object.prototype; - -/** Used to detect overreaching core-js shims. */ -var coreJsData = root['__core-js_shared__']; - -/** Used to detect methods masquerading as native. */ -var maskSrcKey = (function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); - return uid ? ('Symbol(src)_1.' + uid) : ''; -}()); - -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); - -/** Built-in value references. */ -var Symbol = root.Symbol, - splice = arrayProto.splice; - -/* Built-in method references that are verified to be native. */ -var Map = getNative(root, 'Map'), - nativeCreate = getNative(Object, 'create'); - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; /** - * Creates a hash object. + * Creates a map cache object to store key-value pairs. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ -function Hash(entries) { +function MapCache(entries) { var index = -1, length = entries ? entries.length : 0; @@ -11247,329 +10897,121 @@ function Hash(entries) { } /** - * Removes all key-value entries from the hash. + * Removes all key-value entries from the map. * * @private * @name clear - * @memberOf Hash + * @memberOf MapCache */ -function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; +function mapCacheClear() { + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; } /** - * Removes `key` and its value from the hash. + * Removes `key` and its value from the map. * * @private * @name delete - * @memberOf Hash - * @param {Object} hash The hash to modify. + * @memberOf MapCache * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function hashDelete(key) { - return this.has(key) && delete this.__data__[key]; +function mapCacheDelete(key) { + return getMapData(this, key)['delete'](key); } /** - * Gets the hash value for `key`. + * Gets the map value for `key`. * * @private * @name get - * @memberOf Hash + * @memberOf MapCache * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ -function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty.call(data, key) ? data[key] : undefined; +function mapCacheGet(key) { + return getMapData(this, key).get(key); } /** - * Checks if a hash value for `key` exists. + * Checks if a map value for `key` exists. * * @private * @name has - * @memberOf Hash + * @memberOf MapCache * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function hashHas(key) { - var data = this.__data__; - return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); +function mapCacheHas(key) { + return getMapData(this, key).has(key); } /** - * Sets the hash `key` to `value`. + * Sets the map `key` to `value`. * * @private * @name set - * @memberOf Hash + * @memberOf MapCache * @param {string} key The key of the value to set. * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. + * @returns {Object} Returns the map cache instance. */ -function hashSet(key, value) { - var data = this.__data__; - data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; +function mapCacheSet(key, value) { + getMapData(this, key).set(key, value); return this; } -// Add methods to `Hash`. -Hash.prototype.clear = hashClear; -Hash.prototype['delete'] = hashDelete; -Hash.prototype.get = hashGet; -Hash.prototype.has = hashHas; -Hash.prototype.set = hashSet; +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; /** - * Creates an list cache object. + * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. */ -function ListCache(entries) { - var index = -1, - length = entries ? entries.length : 0; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } } + return -1; } /** - * Removes all key-value entries from the list cache. + * The base implementation of `_.get` without support for default values. * * @private - * @name clear - * @memberOf ListCache + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. */ -function listCacheClear() { - this.__data__ = []; +function baseGet(object, path) { + path = isKey(path, object) ? [path] : castPath(path); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; } /** - * Removes `key` and its value from the list cache. - * - * @private - * @name delete - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); - } - return true; -} - -/** - * Gets the list cache value for `key`. - * - * @private - * @name get - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - return index < 0 ? undefined : data[index][1]; -} - -/** - * Checks if a list cache value for `key` exists. - * - * @private - * @name has - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; -} - -/** - * Sets the list cache `key` to `value`. - * - * @private - * @name set - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. - */ -function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; -} - -// Add methods to `ListCache`. -ListCache.prototype.clear = listCacheClear; -ListCache.prototype['delete'] = listCacheDelete; -ListCache.prototype.get = listCacheGet; -ListCache.prototype.has = listCacheHas; -ListCache.prototype.set = listCacheSet; - -/** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function MapCache(entries) { - var index = -1, - length = entries ? entries.length : 0; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -/** - * Removes all key-value entries from the map. - * - * @private - * @name clear - * @memberOf MapCache - */ -function mapCacheClear() { - this.__data__ = { - 'hash': new Hash, - 'map': new (Map || ListCache), - 'string': new Hash - }; -} - -/** - * Removes `key` and its value from the map. - * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function mapCacheDelete(key) { - return getMapData(this, key)['delete'](key); -} - -/** - * Gets the map value for `key`. - * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function mapCacheGet(key) { - return getMapData(this, key).get(key); -} - -/** - * Checks if a map value for `key` exists. - * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function mapCacheHas(key) { - return getMapData(this, key).has(key); -} - -/** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ -function mapCacheSet(key, value) { - getMapData(this, key).set(key, value); - return this; -} - -// Add methods to `MapCache`. -MapCache.prototype.clear = mapCacheClear; -MapCache.prototype['delete'] = mapCacheDelete; -MapCache.prototype.get = mapCacheGet; -MapCache.prototype.has = mapCacheHas; -MapCache.prototype.set = mapCacheSet; - -/** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function assignValue(object, key, value) { - var objValue = object[key]; - if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || - (value === undefined && !(key in object))) { - object[key] = value; - } -} - -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; -} - -/** - * The base implementation of `_.isNative` without bad shim checks. + * The base implementation of `_.isNative` without bad shim checks. * * @private * @param {*} value The value to check. @@ -11584,46 +11026,6 @@ function baseIsNative(value) { return pattern.test(toSource(value)); } -/** - * The base implementation of `_.set`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize path creation. - * @returns {Object} Returns `object`. - */ -function baseSet(object, path, value, customizer) { - if (!isObject(object)) { - return object; - } - path = isKey(path, object) ? [path] : castPath(path); - - var index = -1, - length = path.length, - lastIndex = length - 1, - nested = object; - - while (nested != null && ++index < length) { - var key = toKey(path[index]), - newValue = value; - - if (index != lastIndex) { - var objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - newValue = isObject(objValue) - ? objValue - : (isIndex(path[index + 1]) ? [] : {}); - } - } - assignValue(nested, key, newValue); - nested = nested[key]; - } - return object; -} - /** * The base implementation of `_.toString` which doesn't convert nullish * values to empty strings. @@ -11684,27 +11086,12 @@ function getNative(object, key) { } /** - * Checks if `value` is a valid array-like index. + * Checks if `value` is a property name and not a property path. * * @private * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); -} - -/** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ function isKey(value, object) { if (isArray(value)) { @@ -12056,43 +11443,41 @@ function toString(value) { } /** - * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, - * it's created. Arrays are created for missing index properties while objects - * are created for all other missing properties. Use `_.setWith` to customize - * `path` creation. - * - * **Note:** This method mutates `object`. + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. * * @static * @memberOf _ * @since 3.7.0 * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @returns {Object} Returns `object`. + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. * @example * * var object = { 'a': [{ 'b': { 'c': 3 } }] }; * - * _.set(object, 'a[0].b.c', 4); - * console.log(object.a[0].b.c); - * // => 4 + * _.get(object, 'a[0].b.c'); + * // => 3 * - * _.set(object, ['x', '0', 'y', 'z'], 5); - * console.log(object.x[0].y.z); - * // => 5 + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' */ -function set(object, path, value) { - return object == null ? object : baseSet(object, path, value); +function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, path); + return result === undefined ? defaultValue : result; } -module.exports = set; +module.exports = get; /***/ }), -/***/ 8216: +/***/ 1552: /***/ ((module) => { /** @@ -12104,18 +11489,26 @@ module.exports = set; * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ -/** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; +var INFINITY = 1 / 0, + MAX_SAFE_INTEGER = 9007199254740991; /** `Object#toString` result references. */ var funcTag = '[object Function]', - genTag = '[object GeneratorFunction]'; + genTag = '[object GeneratorFunction]', + symbolTag = '[object Symbol]'; + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/, + reLeadingDot = /^\./, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** * Used to match `RegExp` @@ -12123,9 +11516,15 @@ var funcTag = '[object Function]', */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + /** Used to detect host constructors (Safari). */ var reIsHostCtor = /^\[object .+?Constructor\]$/; +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + /** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; @@ -12135,111 +11534,6 @@ var freeSelf = typeof self == 'object' && self && self.Object === Object && self /** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function('return this')(); -/** - * A specialized version of `_.includes` for arrays without support for - * specifying an index to search from. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ -function arrayIncludes(array, value) { - var length = array ? array.length : 0; - return !!length && baseIndexOf(array, value, 0) > -1; -} - -/** - * This function is like `arrayIncludes` except that it accepts a comparator. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @param {Function} comparator The comparator invoked per element. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ -function arrayIncludesWith(array, value, comparator) { - var index = -1, - length = array ? array.length : 0; - - while (++index < length) { - if (comparator(value, array[index])) { - return true; - } - } - return false; -} - -/** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} fromIndex The index to search from. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function baseFindIndex(array, predicate, fromIndex, fromRight) { - var length = array.length, - index = fromIndex + (fromRight ? 1 : -1); - - while ((fromRight ? index-- : ++index < length)) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; -} - -/** - * The base implementation of `_.indexOf` without `fromIndex` bounds checks. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function baseIndexOf(array, value, fromIndex) { - if (value !== value) { - return baseFindIndex(array, baseIsNaN, fromIndex); - } - var index = fromIndex - 1, - length = array.length; - - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; -} - -/** - * The base implementation of `_.isNaN` without support for number objects. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - */ -function baseIsNaN(value) { - return value !== value; -} - -/** - * Checks if a cache value for `key` exists. - * - * @private - * @param {Object} cache The cache to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function cacheHas(cache, key) { - return cache.has(key); -} - /** * Gets the value at `key` of `object`. * @@ -12271,23 +11565,6 @@ function isHostObject(value) { return result; } -/** - * Converts `set` to an array of its values. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the values. - */ -function setToArray(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function(value) { - result[++index] = value; - }); - return result; -} - /** Used for built-in method references. */ var arrayProto = Array.prototype, funcProto = Function.prototype, @@ -12322,13 +11599,17 @@ var reIsNative = RegExp('^' + ); /** Built-in value references. */ -var splice = arrayProto.splice; +var Symbol = root.Symbol, + splice = arrayProto.splice; /* Built-in method references that are verified to be native. */ var Map = getNative(root, 'Map'), - Set = getNative(root, 'Set'), nativeCreate = getNative(Object, 'create'); +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + /** * Creates a hash object. * @@ -12634,75 +11915,43 @@ MapCache.prototype.has = mapCacheHas; MapCache.prototype.set = mapCacheSet; /** - * - * Creates an array cache object to store unique values. + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. * * @private - * @constructor - * @param {Array} [values] The values to cache. + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. */ -function SetCache(values) { - var index = -1, - length = values ? values.length : 0; - - this.__data__ = new MapCache; - while (++index < length) { - this.add(values[index]); +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + object[key] = value; } } /** - * Adds `value` to the array cache. + * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private - * @name add - * @memberOf SetCache - * @alias push - * @param {*} value The value to cache. - * @returns {Object} Returns the cache instance. + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. */ -function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; } /** - * Checks if `value` is in the array cache. - * - * @private - * @name has - * @memberOf SetCache - * @param {*} value The value to search for. - * @returns {number} Returns `true` if `value` is found, else `false`. - */ -function setCacheHas(value) { - return this.__data__.has(value); -} - -// Add methods to `SetCache`. -SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; -SetCache.prototype.has = setCacheHas; - -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; -} - -/** - * The base implementation of `_.isNative` without bad shim checks. + * The base implementation of `_.isNative` without bad shim checks. * * @private * @param {*} value The value to check. @@ -12718,76 +11967,75 @@ function baseIsNative(value) { } /** - * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * The base implementation of `_.set`. * * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new duplicate free array. + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. */ -function baseUniq(array, iteratee, comparator) { +function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } + path = isKey(path, object) ? [path] : castPath(path); + var index = -1, - includes = arrayIncludes, - length = array.length, - isCommon = true, - result = [], - seen = result; + length = path.length, + lastIndex = length - 1, + nested = object; - if (comparator) { - isCommon = false; - includes = arrayIncludesWith; - } - else if (length >= LARGE_ARRAY_SIZE) { - var set = iteratee ? null : createSet(array); - if (set) { - return setToArray(set); - } - isCommon = false; - includes = cacheHas; - seen = new SetCache; - } - else { - seen = iteratee ? [] : result; - } - outer: - while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; + while (nested != null && ++index < length) { + var key = toKey(path[index]), + newValue = value; - value = (comparator || value !== 0) ? value : 0; - if (isCommon && computed === computed) { - var seenIndex = seen.length; - while (seenIndex--) { - if (seen[seenIndex] === computed) { - continue outer; - } - } - if (iteratee) { - seen.push(computed); - } - result.push(value); - } - else if (!includes(seen, computed, comparator)) { - if (seen !== result) { - seen.push(computed); + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); } - result.push(value); } + assignValue(nested, key, newValue); + nested = nested[key]; } - return result; + return object; } /** - * Creates a set object of `values`. + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. * * @private - * @param {Array} values The values to add to the set. - * @returns {Object} Returns the new set. + * @param {*} value The value to process. + * @returns {string} Returns the string. */ -var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { - return new Set(values); -}; +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @returns {Array} Returns the cast property path array. + */ +function castPath(value) { + return isArray(value) ? value : stringToPath(value); +} /** * Gets the data for `map`. @@ -12817,6 +12065,42 @@ function getNative(object, key) { return baseIsNative(value) ? value : undefined; } +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && + (typeof value == 'number' || reIsUint.test(value)) && + (value > -1 && value % 1 == 0 && value < length); +} + +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + if (isArray(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); +} + /** * Checks if `value` is suitable for use as unique object key. * @@ -12842,6 +12126,41 @@ function isMasked(func) { return !!maskSrcKey && (maskSrcKey in func); } +/** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ +var stringToPath = memoize(function(string) { + string = toString(string); + + var result = []; + if (reLeadingDot.test(string)) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, string) { + result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; +}); + +/** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ +function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + /** * Converts `func` to its source code. * @@ -12862,43 +12181,87 @@ function toSource(func) { } /** - * Creates a duplicate-free version of an array, using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons, in which only the first occurrence of each - * element is kept. + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `delete`, `get`, `has`, and `set`. * * @static * @memberOf _ * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. * @example * - * _.uniq([2, 1, 2]); - * // => [2, 1] - */ -function uniq(array) { - return (array && array.length) - ? baseUniq(array) - : []; -} - -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; * - * var object = { 'a': 1 }; + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result); + return result; + }; + memoized.cache = new (memoize.Cache || MapCache); + return memoized; +} + +// Assign cache to `_.memoize`. +memoize.Cache = MapCache; + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; * var other = { 'a': 1 }; * * _.eq(object, object); @@ -12920,6 +12283,31 @@ function eq(value, other) { return value === other || (value !== value && other !== other); } +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + /** * Checks if `value` is classified as a `Function` object. * @@ -12975,12732 +12363,8672 @@ function isObject(value) { } /** - * This method returns `undefined`. + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". * * @static * @memberOf _ - * @since 2.3.0 - * @category Util + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. * @example * - * _.times(2, _.noop); - * // => [undefined, undefined] + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false */ -function noop() { - // No operation performed. +function isObjectLike(value) { + return !!value && typeof value == 'object'; } -module.exports = uniq; - - -/***/ }), - -/***/ 7493: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - -const os = __nccwpck_require__(2037); +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && objectToString.call(value) == symbolTag); +} -const nameMap = new Map([ - [19, 'Catalina'], - [18, 'Mojave'], - [17, 'High Sierra'], - [16, 'Sierra'], - [15, 'El Capitan'], - [14, 'Yosemite'], - [13, 'Mavericks'], - [12, 'Mountain Lion'], - [11, 'Lion'], - [10, 'Snow Leopard'], - [9, 'Leopard'], - [8, 'Tiger'], - [7, 'Panther'], - [6, 'Jaguar'], - [5, 'Puma'] -]); +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {string} Returns the string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString(value) { + return value == null ? '' : baseToString(value); +} -const macosRelease = release => { - release = Number((release || os.release()).split('.')[0]); - return { - name: nameMap.get(release), - version: '10.' + (release - 4) - }; -}; +/** + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, ['x', '0', 'y', 'z'], 5); + * console.log(object.x[0].y.z); + * // => 5 + */ +function set(object, path, value) { + return object == null ? object : baseSet(object, path, value); +} -module.exports = macosRelease; -// TODO: remove this in the next major version -module.exports["default"] = macosRelease; +module.exports = set; /***/ }), -/***/ 8560: +/***/ 8216: /***/ ((module) => { -"use strict"; - - /** - * Tries to execute a function and discards any error that occurs. - * @param {Function} fn - Function that might or might not throw an error. - * @returns {?*} Return-value of the function when no error occurred. + * lodash (Custom Build) + * Build: `lodash modularize exports="npm" -o ./` + * Copyright jQuery Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ -module.exports = function(fn) { - - try { return fn() } catch (e) {} -} - -/***/ }), +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; -/***/ 467: -/***/ ((module, exports, __nccwpck_require__) => { +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; -"use strict"; +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; +/** `Object#toString` result references. */ +var funcTag = '[object Function]', + genTag = '[object GeneratorFunction]'; -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; - - 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); - - 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; +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - 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); +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; - const buffer = this[BUFFER]; - const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); - const blob = new Blob([], { type: arguments[2] }); - blob[BUFFER] = slicedBuffer; - return blob; - } -} +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; -Object.defineProperties(Blob.prototype, { - size: { enumerable: true }, - type: { enumerable: true }, - slice: { enumerable: true } -}); +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; -Object.defineProperty(Blob.prototype, Symbol.toStringTag, { - value: 'Blob', - writable: false, - enumerable: false, - configurable: true -}); +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); /** - * fetch-error.js + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. * - * FetchError interface for operational errors + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. */ +function arrayIncludes(array, value) { + var length = array ? array.length : 0; + return !!length && baseIndexOf(array, value, 0) > -1; +} /** - * Create FetchError instance + * This function is like `arrayIncludes` except that it accepts a comparator. * - * @param String message Error message for human - * @param String type Error type for machine - * @param String systemError For Node.js system error - * @return FetchError + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @param {Function} comparator The comparator invoked per element. + * @returns {boolean} Returns `true` if `target` is found, else `false`. */ -function FetchError(message, type, systemError) { - Error.call(this, message); - - this.message = message; - this.type = type; +function arrayIncludesWith(array, value, comparator) { + var index = -1, + length = array ? array.length : 0; - // when err.type is `system`, err.code contains system error code - if (systemError) { - this.code = this.errno = systemError.code; + while (++index < length) { + if (comparator(value, array[index])) { + return true; + } } - - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); + return false; } -FetchError.prototype = Object.create(Error.prototype); -FetchError.prototype.constructor = FetchError; -FetchError.prototype.name = 'FetchError'; +/** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 1 : -1); -let convert; -try { - convert = (__nccwpck_require__(2877).convert); -} catch (e) {} + while ((fromRight ? index-- : ++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; +} -const INTERNALS = Symbol('Body internals'); +/** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return baseFindIndex(array, baseIsNaN, fromIndex); + } + var index = fromIndex - 1, + length = array.length; -// fix an issue where "PassThrough" isn't a named export for node <10 -const PassThrough = Stream.PassThrough; + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; +} /** - * Body mixin - * - * Ref: https://fetch.spec.whatwg.org/#body + * The base implementation of `_.isNaN` without support for number objects. * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. */ -function Body(body) { - var _this = this; +function baseIsNaN(value) { + return value !== value; +} - var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref$size = _ref.size; +/** + * Checks if a cache value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function cacheHas(cache, key) { + return cache.has(key); +} - let size = _ref$size === undefined ? 0 : _ref$size; - var _ref$timeout = _ref.timeout; - let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; - - 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; - }); - } +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue(object, key) { + return object == null ? undefined : object[key]; } -Body.prototype = { - get body() { - return this[INTERNALS].body; - }, +/** + * Checks if `value` is a host object in IE < 9. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + */ +function isHostObject(value) { + // Many host objects are `Object` objects that can coerce to strings + // despite having improperly defined `toString` methods. + var result = false; + if (value != null && typeof value.toString != 'function') { + try { + result = !!(value + ''); + } catch (e) {} + } + return result; +} - get bodyUsed() { - return this[INTERNALS].disturbed; - }, +/** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ +function setToArray(set) { + var index = -1, + result = Array(set.size); - /** - * Decode response as ArrayBuffer - * - * @return Promise - */ - arrayBuffer() { - return consumeBody.call(this).then(function (buf) { - return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - }); - }, + set.forEach(function(value) { + result[++index] = value; + }); + return result; +} - /** - * 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 - }); - }); - }, +/** Used for built-in method references. */ +var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype; - /** - * Decode response as json - * - * @return Promise - */ - json() { - var _this2 = this; +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; - 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')); - } - }); - }, +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); - /** - * Decode response as text - * - * @return Promise - */ - text() { - return consumeBody.call(this).then(function (buffer) { - return buffer.toString(); - }); - }, +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; - /** - * Decode response as buffer (non-spec api) - * - * @return Promise - */ - buffer() { - return consumeBody.call(this); - }, +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - /** - * 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; +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var objectToString = objectProto.toString; - return consumeBody.call(this).then(function (buffer) { - return convertBody(buffer, _this3.headers); - }); - } -}; +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); -// 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 } -}); +/** Built-in value references. */ +var splice = arrayProto.splice; -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); - } - } -}; +/* Built-in method references that are verified to be native. */ +var Map = getNative(root, 'Map'), + Set = getNative(root, 'Set'), + nativeCreate = getNative(Object, 'create'); /** - * Consume and convert an entire Body to a Buffer. - * - * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * Creates a hash object. * - * @return Promise + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -function consumeBody() { - var _this4 = this; +function Hash(entries) { + var index = -1, + length = entries ? entries.length : 0; - if (this[INTERNALS].disturbed) { - return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); - } + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} - this[INTERNALS].disturbed = true; +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; +} - if (this[INTERNALS].error) { - return Body.Promise.reject(this[INTERNALS].error); - } - - let body = this.body; - - // body is null - if (body === null) { - return Body.Promise.resolve(Buffer.alloc(0)); - } - - // body is blob - if (isBlob(body)) { - body = body.stream(); - } - - // body is buffer - if (Buffer.isBuffer(body)) { - return Body.Promise.resolve(body); - } - - // istanbul ignore if: should never happen - if (!(body instanceof Stream)) { - return Body.Promise.resolve(Buffer.alloc(0)); - } - - // 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; - - // 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)); - } - }); - - body.on('data', function (chunk) { - if (abort || chunk === null) { - return; - } - - 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); - }); - - body.on('end', function () { - if (abort) { - return; - } - - clearTimeout(resTimeout); - - 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)); - } - }); - }); -} +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + return this.has(key) && delete this.__data__[key]; +} /** - * Detect buffer encoding and convert to target encoding - * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * Gets the hash value for `key`. * - * @param Buffer buffer Incoming buffer - * @param String encoding Target encoding - * @return String + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -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; - - // 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(); - - // html5 - if (!res && str) { - res = / -1; +} +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); - 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); - } + if (index < 0) { + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; } -// expose Promise -Body.Promise = global.Promise; +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; /** - * headers.js + * Creates a map cache object to store key-value pairs. * - * Headers class offers convenient helpers + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ +function MapCache(entries) { + var index = -1, + length = entries ? entries.length : 0; -const invalidTokenRegex = /[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/; -const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/; - -function validateName(name) { - name = `${name}`; - if (invalidTokenRegex.test(name) || name === '') { - throw new TypeError(`${name} is not a legal HTTP header name`); - } + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } -function validateValue(value) { - value = `${value}`; - if (invalidHeaderCharRegex.test(value)) { - throw new TypeError(`${value} is not a legal HTTP header value`); - } +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; } /** - * Find the key in the map object given a header name. - * - * Returns undefined if not found. + * Removes `key` and its value from the map. * - * @param String name Header name - * @return String|Undefined + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function find(map, name) { - name = name.toLowerCase(); - for (const key in map) { - if (key.toLowerCase() === name) { - return key; - } - } - return undefined; +function mapCacheDelete(key) { + return getMapData(this, key)['delete'](key); } -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; +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return getMapData(this, key).get(key); +} - this[MAP] = Object.create(null); +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return getMapData(this, key).has(key); +} - if (init instanceof Headers) { - const rawHeaders = init.raw(); - const headerNames = Object.keys(rawHeaders); +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + getMapData(this, key).set(key, value); + return this; +} - for (const headerName of headerNames) { - for (const value of rawHeaders[headerName]) { - this.append(headerName, value); - } - } - - 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'); - } - - // 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'); - } - } - - /** - * 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; - } - - 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; - - 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]; - - 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]; - } - - /** - * 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]; - } - } - - /** - * 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]; - } - } - - /** - * Return raw headers (non-spec api) - * - * @return Object - */ - raw() { - return this[MAP]; - } - - /** - * Get an iterator on keys. - * - * @return Iterator - */ - keys() { - return createHeadersIterator(this, 'key'); - } - - /** - * Get an iterator on values. - * - * @return Iterator - */ - values() { - return createHeadersIterator(this, 'value'); - } - - /** - * 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.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'; - - 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(', ')]; - }); -} - -const INTERNAL = Symbol('internal'); - -function createHeadersIterator(target, kind) { - const iterator = Object.create(HeadersIteratorPrototype); - iterator[INTERNAL] = { - target, - kind, - index: 0 - }; - return iterator; -} - -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; - - const values = getHeaders(target, kind); - const len = values.length; - if (index >= len) { - return { - value: undefined, - done: true - }; - } - - this[INTERNAL].index = index + 1; - - return { - value: values[index], - done: false - }; - } -}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); - -Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { - value: 'HeadersIterator', - writable: false, - enumerable: false, - configurable: true -}); - -/** - * 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]); - - // 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]; - } - - return obj; -} - -/** - * 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'); - -// fix an issue where "STATUS_CODES" aren't a named export for node <10 -const STATUS_CODES = http.STATUS_CODES; - -/** - * 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); - - 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); - } - } - - this[INTERNALS$1] = { - url: opts.url, - status, - statusText: opts.statusText || STATUS_CODES[status], - headers, - counter: opts.counter - }; - } - - get url() { - return this[INTERNALS$1].url || ''; - } - - get status() { - return this[INTERNALS$1].status; - } - - /** - * 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; - } - - get statusText() { - return this[INTERNALS$1].statusText; - } - - get headers() { - return this[INTERNALS$1].headers; - } - - /** - * 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 - }); - } -} - -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 -}); - -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; - -/** - * 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(); - } - - // Fallback to old implementation for arbitrary URLs - return parse_url(urlStr); -} - -const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; - -/** - * 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'; -} - -function isAbortSignal(signal) { - const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); - return !!(proto && proto.constructor.name === 'AbortSignal'); -} - -/** - * 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] : {}; - - let parsedURL; - - // 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(); - - 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 - }); - - const headers = new Headers(init.headers || input.headers || {}); - - 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; - - if (signal != null && !isAbortSignal(signal)) { - throw new TypeError('Expected signal to be an instanceof AbortSignal'); - } - - this[INTERNALS$2] = { - method, - redirect: init.redirect || input.redirect || 'follow', - headers, - parsedURL, - signal - }; - - // 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 method() { - return this[INTERNALS$2].method; - } - - get url() { - return format_url(this[INTERNALS$2].parsedURL); - } - - get headers() { - return this[INTERNALS$2].headers; - } - - get redirect() { - return this[INTERNALS$2].redirect; - } - - get signal() { - return this[INTERNALS$2].signal; - } - - /** - * Clone this request - * - * @return Request - */ - clone() { - return new Request(this); - } -} - -Body.mixIn(Request.prototype); - -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 } -}); - -/** - * 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); - - // fetch step 1.3 - if (!headers.has('Accept')) { - headers.set('Accept', '*/*'); - } - - // Basic fetch - if (!parsedURL.protocol || !parsedURL.hostname) { - throw new TypeError('Only absolute URLs are supported'); - } - - if (!/^https?:$/.test(parsedURL.protocol)) { - throw new TypeError('Only HTTP(S) protocols are supported'); - } - - if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) { - throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); - } - - // 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); - } - - // 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)'); - } - - // HTTP-network-or-cache fetch step 2.15 - if (request.compress && !headers.has('Accept-Encoding')) { - headers.set('Accept-Encoding', 'gzip,deflate'); - } - - let agent = request.agent; - if (typeof agent === 'function') { - agent = agent(parsedURL); - } - - if (!headers.has('Connection') && !agent) { - headers.set('Connection', 'close'); - } - - // HTTP-network fetch step 4.2 - // chunked encoding is handled by Node.js - - return Object.assign({}, parsedURL, { - method: request.method, - headers: exportNodeCompatibleHeaders(headers), - agent - }); -} - -/** - * abort-error.js - * - * AbortError interface for cancelled requests - */ - -/** - * Create AbortError instance - * - * @param String message Error message for human - * @return AbortError - */ -function AbortError(message) { - Error.call(this, message); - - this.type = 'aborted'; - this.message = message; - - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); -} - -AbortError.prototype = Object.create(Error.prototype); -AbortError.prototype.constructor = AbortError; -AbortError.prototype.name = 'AbortError'; - -const URL$1 = Url.URL || whatwgUrl.URL; - -// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 -const PassThrough$1 = 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); -}; - -/** - * 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; - - let response = null; - - 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 abortAndFinalize = function abortAndFinalize() { - abort(); - finalize(); - }; - - // send request - const req = send(options); - let reqTimeout; - - if (signal) { - signal.addEventListener('abort', abortAndFinalize); - } - - 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); - }); - } - - req.on('error', function (err) { - reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); - finalize(); - }); - - req.on('response', function (res) { - clearTimeout(reqTimeout); - - const headers = createHeadersLenient(res.headers); - - // HTTP fetch step 5 - if (fetch.isRedirect(res.statusCode)) { - // HTTP fetch step 5.2 - const location = headers.get('Location'); - - // 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; - } - } - - // 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; - } - - // HTTP-redirect fetch step 5 - if (request.counter >= request.follow) { - reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); - finalize(); - return; - } - - // 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 - }; - - if (!isDomainOrSubdomain(request.url, locationURL)) { - for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) { - requestOpts.headers.delete(name); - } - } - - // 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; - } - - // 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'); - } - - // 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()); - - 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; -}; - -// 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__) => { - -"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; - } - - 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__) => { - -"use strict"; - -const punycode = __nccwpck_require__(5477); -const tr46 = __nccwpck_require__(2299); - -const specialSchemes = { - ftp: 21, - file: null, - gopher: 70, - http: 80, - https: 443, - ws: 80, - wss: 443 -}; - -const failure = Symbol("failure"); - -function countSymbols(str) { - return punycode.ucs2.decode(str).length; -} - -function at(input, idx) { - const c = input[idx]; - return isNaN(c) ? undefined : String.fromCodePoint(c); -} - -function isASCIIDigit(c) { - return c >= 0x30 && c <= 0x39; -} - -function isASCIIAlpha(c) { - return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); -} - -function isASCIIAlphanumeric(c) { - return isASCIIAlpha(c) || isASCIIDigit(c); -} - -function isASCIIHex(c) { - return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66); -} - -function isSingleDot(buffer) { - return buffer === "." || buffer.toLowerCase() === "%2e"; -} - -function isDoubleDot(buffer) { - buffer = buffer.toLowerCase(); - return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e"; -} - -function isWindowsDriveLetterCodePoints(cp1, cp2) { - return isASCIIAlpha(cp1) && (cp2 === 58 || cp2 === 124); -} - -function isWindowsDriveLetterString(string) { - return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|"); -} - -function isNormalizedWindowsDriveLetterString(string) { - return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && string[1] === ":"; -} - -function containsForbiddenHostCodePoint(string) { - return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/) !== -1; -} - -function containsForbiddenHostCodePointExcludingPercent(string) { - return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/) !== -1; -} - -function isSpecialScheme(scheme) { - return specialSchemes[scheme] !== undefined; -} - -function isSpecial(url) { - return isSpecialScheme(url.scheme); -} - -function defaultPort(scheme) { - return specialSchemes[scheme]; -} - -function percentEncode(c) { - let hex = c.toString(16).toUpperCase(); - if (hex.length === 1) { - hex = "0" + hex; - } - - return "%" + hex; -} - -function utf8PercentEncode(c) { - const buf = new Buffer(c); - - let str = ""; - - for (let i = 0; i < buf.length; ++i) { - str += percentEncode(buf[i]); - } - - return str; -} - -function utf8PercentDecode(str) { - const input = new Buffer(str); - const output = []; - for (let i = 0; i < input.length; ++i) { - if (input[i] !== 37) { - output.push(input[i]); - } else if (input[i] === 37 && isASCIIHex(input[i + 1]) && isASCIIHex(input[i + 2])) { - output.push(parseInt(input.slice(i + 1, i + 3).toString(), 16)); - i += 2; - } else { - output.push(input[i]); - } - } - return new Buffer(output).toString(); -} - -function isC0ControlPercentEncode(c) { - return c <= 0x1F || c > 0x7E; -} - -const extraPathPercentEncodeSet = new Set([32, 34, 35, 60, 62, 63, 96, 123, 125]); -function isPathPercentEncode(c) { - return isC0ControlPercentEncode(c) || extraPathPercentEncodeSet.has(c); -} - -const extraUserinfoPercentEncodeSet = - new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]); -function isUserinfoPercentEncode(c) { - return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c); -} - -function percentEncodeChar(c, encodeSetPredicate) { - const cStr = String.fromCodePoint(c); - - if (encodeSetPredicate(c)) { - return utf8PercentEncode(cStr); - } - - return cStr; -} - -function parseIPv4Number(input) { - let R = 10; - - if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") { - input = input.substring(2); - R = 16; - } else if (input.length >= 2 && input.charAt(0) === "0") { - input = input.substring(1); - R = 8; - } - - if (input === "") { - return 0; - } - - const regex = R === 10 ? /[^0-9]/ : (R === 16 ? /[^0-9A-Fa-f]/ : /[^0-7]/); - if (regex.test(input)) { - return failure; - } - - return parseInt(input, R); -} - -function parseIPv4(input) { - const parts = input.split("."); - if (parts[parts.length - 1] === "") { - if (parts.length > 1) { - parts.pop(); - } - } - - if (parts.length > 4) { - return input; - } - - const numbers = []; - for (const part of parts) { - if (part === "") { - return input; - } - const n = parseIPv4Number(part); - if (n === failure) { - return input; - } - - numbers.push(n); - } - - for (let i = 0; i < numbers.length - 1; ++i) { - if (numbers[i] > 255) { - return failure; - } - } - if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) { - return failure; - } - - let ipv4 = numbers.pop(); - let counter = 0; - - for (const n of numbers) { - ipv4 += n * Math.pow(256, 3 - counter); - ++counter; - } - - return ipv4; -} - -function serializeIPv4(address) { - let output = ""; - let n = address; - - for (let i = 1; i <= 4; ++i) { - output = String(n % 256) + output; - if (i !== 4) { - output = "." + output; - } - n = Math.floor(n / 256); - } - - return output; -} - -function parseIPv6(input) { - const address = [0, 0, 0, 0, 0, 0, 0, 0]; - let pieceIndex = 0; - let compress = null; - let pointer = 0; - - input = punycode.ucs2.decode(input); - - if (input[pointer] === 58) { - if (input[pointer + 1] !== 58) { - return failure; - } - - pointer += 2; - ++pieceIndex; - compress = pieceIndex; - } - - while (pointer < input.length) { - if (pieceIndex === 8) { - return failure; - } - - if (input[pointer] === 58) { - if (compress !== null) { - return failure; - } - ++pointer; - ++pieceIndex; - compress = pieceIndex; - continue; - } - - let value = 0; - let length = 0; - - while (length < 4 && isASCIIHex(input[pointer])) { - value = value * 0x10 + parseInt(at(input, pointer), 16); - ++pointer; - ++length; - } - - if (input[pointer] === 46) { - if (length === 0) { - return failure; - } - - pointer -= length; - - if (pieceIndex > 6) { - return failure; - } - - let numbersSeen = 0; - - while (input[pointer] !== undefined) { - let ipv4Piece = null; - - if (numbersSeen > 0) { - if (input[pointer] === 46 && numbersSeen < 4) { - ++pointer; - } else { - return failure; - } - } - - if (!isASCIIDigit(input[pointer])) { - return failure; - } - - while (isASCIIDigit(input[pointer])) { - const number = parseInt(at(input, pointer)); - if (ipv4Piece === null) { - ipv4Piece = number; - } else if (ipv4Piece === 0) { - return failure; - } else { - ipv4Piece = ipv4Piece * 10 + number; - } - if (ipv4Piece > 255) { - return failure; - } - ++pointer; - } - - address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece; - - ++numbersSeen; - - if (numbersSeen === 2 || numbersSeen === 4) { - ++pieceIndex; - } - } - - if (numbersSeen !== 4) { - return failure; - } - - break; - } else if (input[pointer] === 58) { - ++pointer; - if (input[pointer] === undefined) { - return failure; - } - } else if (input[pointer] !== undefined) { - return failure; - } - - address[pieceIndex] = value; - ++pieceIndex; - } - - if (compress !== null) { - let swaps = pieceIndex - compress; - pieceIndex = 7; - while (pieceIndex !== 0 && swaps > 0) { - const temp = address[compress + swaps - 1]; - address[compress + swaps - 1] = address[pieceIndex]; - address[pieceIndex] = temp; - --pieceIndex; - --swaps; - } - } else if (compress === null && pieceIndex !== 8) { - return failure; - } - - return address; -} - -function serializeIPv6(address) { - let output = ""; - const seqResult = findLongestZeroSequence(address); - const compress = seqResult.idx; - let ignore0 = false; - - for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) { - if (ignore0 && address[pieceIndex] === 0) { - continue; - } else if (ignore0) { - ignore0 = false; - } - - if (compress === pieceIndex) { - const separator = pieceIndex === 0 ? "::" : ":"; - output += separator; - ignore0 = true; - continue; - } - - output += address[pieceIndex].toString(16); - - if (pieceIndex !== 7) { - output += ":"; - } - } - - return output; -} - -function parseHost(input, isSpecialArg) { - if (input[0] === "[") { - if (input[input.length - 1] !== "]") { - return failure; - } - - return parseIPv6(input.substring(1, input.length - 1)); - } - - if (!isSpecialArg) { - return parseOpaqueHost(input); - } - - const domain = utf8PercentDecode(input); - const asciiDomain = tr46.toASCII(domain, false, tr46.PROCESSING_OPTIONS.NONTRANSITIONAL, false); - if (asciiDomain === null) { - return failure; - } - - if (containsForbiddenHostCodePoint(asciiDomain)) { - return failure; - } - - const ipv4Host = parseIPv4(asciiDomain); - if (typeof ipv4Host === "number" || ipv4Host === failure) { - return ipv4Host; - } - - return asciiDomain; -} - -function parseOpaqueHost(input) { - if (containsForbiddenHostCodePointExcludingPercent(input)) { - return failure; - } - - let output = ""; - const decoded = punycode.ucs2.decode(input); - for (let i = 0; i < decoded.length; ++i) { - output += percentEncodeChar(decoded[i], isC0ControlPercentEncode); - } - return output; -} - -function findLongestZeroSequence(arr) { - let maxIdx = null; - let maxLen = 1; // only find elements > 1 - let currStart = null; - let currLen = 0; - - for (let i = 0; i < arr.length; ++i) { - if (arr[i] !== 0) { - if (currLen > maxLen) { - maxIdx = currStart; - maxLen = currLen; - } - - currStart = null; - currLen = 0; - } else { - if (currStart === null) { - currStart = i; - } - ++currLen; - } - } - - // if trailing zeros - if (currLen > maxLen) { - maxIdx = currStart; - maxLen = currLen; - } - - return { - idx: maxIdx, - len: maxLen - }; -} - -function serializeHost(host) { - if (typeof host === "number") { - return serializeIPv4(host); - } - - // IPv6 serializer - if (host instanceof Array) { - return "[" + serializeIPv6(host) + "]"; - } - - return host; -} - -function trimControlChars(url) { - return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, ""); -} - -function trimTabAndNewline(url) { - return url.replace(/\u0009|\u000A|\u000D/g, ""); -} - -function shortenPath(url) { - const path = url.path; - if (path.length === 0) { - return; - } - if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) { - return; - } - - path.pop(); -} - -function includesCredentials(url) { - return url.username !== "" || url.password !== ""; -} - -function cannotHaveAUsernamePasswordPort(url) { - return url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file"; -} - -function isNormalizedWindowsDriveLetter(string) { - return /^[A-Za-z]:$/.test(string); -} - -function URLStateMachine(input, base, encodingOverride, url, stateOverride) { - this.pointer = 0; - this.input = input; - this.base = base || null; - this.encodingOverride = encodingOverride || "utf-8"; - this.stateOverride = stateOverride; - this.url = url; - this.failure = false; - this.parseError = false; - - if (!this.url) { - this.url = { - scheme: "", - username: "", - password: "", - host: null, - port: null, - path: [], - query: null, - fragment: null, - - cannotBeABaseURL: false - }; - - const res = trimControlChars(this.input); - if (res !== this.input) { - this.parseError = true; - } - this.input = res; - } - - const res = trimTabAndNewline(this.input); - if (res !== this.input) { - this.parseError = true; - } - this.input = res; - - this.state = stateOverride || "scheme start"; - - this.buffer = ""; - this.atFlag = false; - this.arrFlag = false; - this.passwordTokenSeenFlag = false; - - this.input = punycode.ucs2.decode(this.input); - - for (; this.pointer <= this.input.length; ++this.pointer) { - const c = this.input[this.pointer]; - const cStr = isNaN(c) ? undefined : String.fromCodePoint(c); - - // exec state machine - const ret = this["parse " + this.state](c, cStr); - if (!ret) { - break; // terminate algorithm - } else if (ret === failure) { - this.failure = true; - break; - } - } -} - -URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) { - if (isASCIIAlpha(c)) { - this.buffer += cStr.toLowerCase(); - this.state = "scheme"; - } else if (!this.stateOverride) { - this.state = "no scheme"; - --this.pointer; - } else { - this.parseError = true; - return failure; - } - - return true; -}; - -URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) { - if (isASCIIAlphanumeric(c) || c === 43 || c === 45 || c === 46) { - this.buffer += cStr.toLowerCase(); - } else if (c === 58) { - if (this.stateOverride) { - if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) { - return false; - } - - if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) { - return false; - } - - if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") { - return false; - } - - if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) { - return false; - } - } - this.url.scheme = this.buffer; - this.buffer = ""; - if (this.stateOverride) { - return false; - } - if (this.url.scheme === "file") { - if (this.input[this.pointer + 1] !== 47 || this.input[this.pointer + 2] !== 47) { - this.parseError = true; - } - this.state = "file"; - } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) { - this.state = "special relative or authority"; - } else if (isSpecial(this.url)) { - this.state = "special authority slashes"; - } else if (this.input[this.pointer + 1] === 47) { - this.state = "path or authority"; - ++this.pointer; - } else { - this.url.cannotBeABaseURL = true; - this.url.path.push(""); - this.state = "cannot-be-a-base-URL path"; - } - } else if (!this.stateOverride) { - this.buffer = ""; - this.state = "no scheme"; - this.pointer = -1; - } else { - this.parseError = true; - return failure; - } - - return true; -}; - -URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) { - if (this.base === null || (this.base.cannotBeABaseURL && c !== 35)) { - return failure; - } else if (this.base.cannotBeABaseURL && c === 35) { - this.url.scheme = this.base.scheme; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - this.url.fragment = ""; - this.url.cannotBeABaseURL = true; - this.state = "fragment"; - } else if (this.base.scheme === "file") { - this.state = "file"; - --this.pointer; - } else { - this.state = "relative"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) { - if (c === 47 && this.input[this.pointer + 1] === 47) { - this.state = "special authority ignore slashes"; - ++this.pointer; - } else { - this.parseError = true; - this.state = "relative"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) { - if (c === 47) { - this.state = "authority"; - } else { - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse relative"] = function parseRelative(c) { - this.url.scheme = this.base.scheme; - if (isNaN(c)) { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - } else if (c === 47) { - this.state = "relative slash"; - } else if (c === 63) { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(); - this.url.query = ""; - this.state = "query"; - } else if (c === 35) { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - this.url.fragment = ""; - this.state = "fragment"; - } else if (isSpecial(this.url) && c === 92) { - this.parseError = true; - this.state = "relative slash"; - } else { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(0, this.base.path.length - 1); - - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) { - if (isSpecial(this.url) && (c === 47 || c === 92)) { - if (c === 92) { - this.parseError = true; - } - this.state = "special authority ignore slashes"; - } else if (c === 47) { - this.state = "authority"; - } else { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) { - if (c === 47 && this.input[this.pointer + 1] === 47) { - this.state = "special authority ignore slashes"; - ++this.pointer; - } else { - this.parseError = true; - this.state = "special authority ignore slashes"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) { - if (c !== 47 && c !== 92) { - this.state = "authority"; - --this.pointer; - } else { - this.parseError = true; - } - - return true; -}; - -URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) { - if (c === 64) { - this.parseError = true; - if (this.atFlag) { - this.buffer = "%40" + this.buffer; - } - this.atFlag = true; - - // careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars - const len = countSymbols(this.buffer); - for (let pointer = 0; pointer < len; ++pointer) { - const codePoint = this.buffer.codePointAt(pointer); - - if (codePoint === 58 && !this.passwordTokenSeenFlag) { - this.passwordTokenSeenFlag = true; - continue; - } - const encodedCodePoints = percentEncodeChar(codePoint, isUserinfoPercentEncode); - if (this.passwordTokenSeenFlag) { - this.url.password += encodedCodePoints; - } else { - this.url.username += encodedCodePoints; - } - } - this.buffer = ""; - } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || - (isSpecial(this.url) && c === 92)) { - if (this.atFlag && this.buffer === "") { - this.parseError = true; - return failure; - } - this.pointer -= countSymbols(this.buffer) + 1; - this.buffer = ""; - this.state = "host"; - } else { - this.buffer += cStr; - } - - return true; -}; - -URLStateMachine.prototype["parse hostname"] = -URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) { - if (this.stateOverride && this.url.scheme === "file") { - --this.pointer; - this.state = "file host"; - } else if (c === 58 && !this.arrFlag) { - if (this.buffer === "") { - this.parseError = true; - return failure; - } - - const host = parseHost(this.buffer, isSpecial(this.url)); - if (host === failure) { - return failure; - } - - this.url.host = host; - this.buffer = ""; - this.state = "port"; - if (this.stateOverride === "hostname") { - return false; - } - } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || - (isSpecial(this.url) && c === 92)) { - --this.pointer; - if (isSpecial(this.url) && this.buffer === "") { - this.parseError = true; - return failure; - } else if (this.stateOverride && this.buffer === "" && - (includesCredentials(this.url) || this.url.port !== null)) { - this.parseError = true; - return false; - } - - const host = parseHost(this.buffer, isSpecial(this.url)); - if (host === failure) { - return failure; - } - - this.url.host = host; - this.buffer = ""; - this.state = "path start"; - if (this.stateOverride) { - return false; - } - } else { - if (c === 91) { - this.arrFlag = true; - } else if (c === 93) { - this.arrFlag = false; - } - this.buffer += cStr; - } - - return true; -}; - -URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) { - if (isASCIIDigit(c)) { - this.buffer += cStr; - } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || - (isSpecial(this.url) && c === 92) || - this.stateOverride) { - if (this.buffer !== "") { - const port = parseInt(this.buffer); - if (port > Math.pow(2, 16) - 1) { - this.parseError = true; - return failure; - } - this.url.port = port === defaultPort(this.url.scheme) ? null : port; - this.buffer = ""; - } - if (this.stateOverride) { - return false; - } - this.state = "path start"; - --this.pointer; - } else { - this.parseError = true; - return failure; - } - - return true; -}; - -const fileOtherwiseCodePoints = new Set([47, 92, 63, 35]); - -URLStateMachine.prototype["parse file"] = function parseFile(c) { - this.url.scheme = "file"; - - if (c === 47 || c === 92) { - if (c === 92) { - this.parseError = true; - } - this.state = "file slash"; - } else if (this.base !== null && this.base.scheme === "file") { - if (isNaN(c)) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - } else if (c === 63) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - this.url.query = ""; - this.state = "query"; - } else if (c === 35) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - this.url.fragment = ""; - this.state = "fragment"; - } else { - if (this.input.length - this.pointer - 1 === 0 || // remaining consists of 0 code points - !isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) || - (this.input.length - this.pointer - 1 >= 2 && // remaining has at least 2 code points - !fileOtherwiseCodePoints.has(this.input[this.pointer + 2]))) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - shortenPath(this.url); - } else { - this.parseError = true; - } - - this.state = "path"; - --this.pointer; - } - } else { - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) { - if (c === 47 || c === 92) { - if (c === 92) { - this.parseError = true; - } - this.state = "file host"; - } else { - if (this.base !== null && this.base.scheme === "file") { - if (isNormalizedWindowsDriveLetterString(this.base.path[0])) { - this.url.path.push(this.base.path[0]); - } else { - this.url.host = this.base.host; - } - } - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) { - if (isNaN(c) || c === 47 || c === 92 || c === 63 || c === 35) { - --this.pointer; - if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) { - this.parseError = true; - this.state = "path"; - } else if (this.buffer === "") { - this.url.host = ""; - if (this.stateOverride) { - return false; - } - this.state = "path start"; - } else { - let host = parseHost(this.buffer, isSpecial(this.url)); - if (host === failure) { - return failure; - } - if (host === "localhost") { - host = ""; - } - this.url.host = host; - - if (this.stateOverride) { - return false; - } - - this.buffer = ""; - this.state = "path start"; - } - } else { - this.buffer += cStr; - } - - return true; -}; - -URLStateMachine.prototype["parse path start"] = function parsePathStart(c) { - if (isSpecial(this.url)) { - if (c === 92) { - this.parseError = true; - } - this.state = "path"; - - if (c !== 47 && c !== 92) { - --this.pointer; - } - } else if (!this.stateOverride && c === 63) { - this.url.query = ""; - this.state = "query"; - } else if (!this.stateOverride && c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } else if (c !== undefined) { - this.state = "path"; - if (c !== 47) { - --this.pointer; - } - } - - return true; -}; - -URLStateMachine.prototype["parse path"] = function parsePath(c) { - if (isNaN(c) || c === 47 || (isSpecial(this.url) && c === 92) || - (!this.stateOverride && (c === 63 || c === 35))) { - if (isSpecial(this.url) && c === 92) { - this.parseError = true; - } - - if (isDoubleDot(this.buffer)) { - shortenPath(this.url); - if (c !== 47 && !(isSpecial(this.url) && c === 92)) { - this.url.path.push(""); - } - } else if (isSingleDot(this.buffer) && c !== 47 && - !(isSpecial(this.url) && c === 92)) { - this.url.path.push(""); - } else if (!isSingleDot(this.buffer)) { - if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) { - if (this.url.host !== "" && this.url.host !== null) { - this.parseError = true; - this.url.host = ""; - } - this.buffer = this.buffer[0] + ":"; - } - this.url.path.push(this.buffer); - } - this.buffer = ""; - if (this.url.scheme === "file" && (c === undefined || c === 63 || c === 35)) { - while (this.url.path.length > 1 && this.url.path[0] === "") { - this.parseError = true; - this.url.path.shift(); - } - } - if (c === 63) { - this.url.query = ""; - this.state = "query"; - } - if (c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } - } else { - // TODO: If c is not a URL code point and not "%", parse error. - - if (c === 37 && - (!isASCIIHex(this.input[this.pointer + 1]) || - !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } - - this.buffer += percentEncodeChar(c, isPathPercentEncode); - } - - return true; -}; - -URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCannotBeABaseURLPath(c) { - if (c === 63) { - this.url.query = ""; - this.state = "query"; - } else if (c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } else { - // TODO: Add: not a URL code point - if (!isNaN(c) && c !== 37) { - this.parseError = true; - } - - if (c === 37 && - (!isASCIIHex(this.input[this.pointer + 1]) || - !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } - - if (!isNaN(c)) { - this.url.path[0] = this.url.path[0] + percentEncodeChar(c, isC0ControlPercentEncode); - } - } - - return true; -}; - -URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) { - if (isNaN(c) || (!this.stateOverride && c === 35)) { - if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") { - this.encodingOverride = "utf-8"; - } - - const buffer = new Buffer(this.buffer); // TODO: Use encoding override instead - for (let i = 0; i < buffer.length; ++i) { - if (buffer[i] < 0x21 || buffer[i] > 0x7E || buffer[i] === 0x22 || buffer[i] === 0x23 || - buffer[i] === 0x3C || buffer[i] === 0x3E) { - this.url.query += percentEncode(buffer[i]); - } else { - this.url.query += String.fromCodePoint(buffer[i]); - } - } - - this.buffer = ""; - if (c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } - } else { - // TODO: If c is not a URL code point and not "%", parse error. - if (c === 37 && - (!isASCIIHex(this.input[this.pointer + 1]) || - !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } - - this.buffer += cStr; - } - - return true; -}; - -URLStateMachine.prototype["parse fragment"] = function parseFragment(c) { - if (isNaN(c)) { // do nothing - } else if (c === 0x0) { - this.parseError = true; - } else { - // TODO: If c is not a URL code point and not "%", parse error. - if (c === 37 && - (!isASCIIHex(this.input[this.pointer + 1]) || - !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } - - this.url.fragment += percentEncodeChar(c, isC0ControlPercentEncode); - } - - return true; -}; - -function serializeURL(url, excludeFragment) { - let output = url.scheme + ":"; - if (url.host !== null) { - output += "//"; - - if (url.username !== "" || url.password !== "") { - output += url.username; - if (url.password !== "") { - output += ":" + url.password; - } - output += "@"; - } - - output += serializeHost(url.host); - - if (url.port !== null) { - output += ":" + url.port; - } - } else if (url.host === null && url.scheme === "file") { - output += "//"; - } - - if (url.cannotBeABaseURL) { - output += url.path[0]; - } else { - for (const string of url.path) { - output += "/" + string; - } - } - - if (url.query !== null) { - output += "?" + url.query; - } - - if (!excludeFragment && url.fragment !== null) { - output += "#" + url.fragment; - } - - return output; -} - -function serializeOrigin(tuple) { - let result = tuple.scheme + "://"; - result += serializeHost(tuple.host); - - if (tuple.port !== null) { - result += ":" + tuple.port; - } - - return result; -} - -module.exports.serializeURL = serializeURL; - -module.exports.serializeURLOrigin = function (url) { - // https://url.spec.whatwg.org/#concept-url-origin - switch (url.scheme) { - case "blob": - try { - return module.exports.serializeURLOrigin(module.exports.parseURL(url.path[0])); - } catch (e) { - // serializing an opaque origin returns "null" - return "null"; - } - case "ftp": - case "gopher": - case "http": - case "https": - case "ws": - case "wss": - return serializeOrigin({ - scheme: url.scheme, - host: url.host, - port: url.port - }); - case "file": - // spec says "exercise to the reader", chrome says "file://" - return "file://"; - default: - // serializing an opaque origin returns "null" - return "null"; - } -}; - -module.exports.basicURLParse = function (input, options) { - if (options === undefined) { - options = {}; - } - - const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride); - if (usm.failure) { - return "failure"; - } - - return usm.url; -}; - -module.exports.setTheUsername = function (url, username) { - url.username = ""; - const decoded = punycode.ucs2.decode(username); - for (let i = 0; i < decoded.length; ++i) { - url.username += percentEncodeChar(decoded[i], isUserinfoPercentEncode); - } -}; - -module.exports.setThePassword = function (url, password) { - url.password = ""; - const decoded = punycode.ucs2.decode(password); - for (let i = 0; i < decoded.length; ++i) { - url.password += percentEncodeChar(decoded[i], isUserinfoPercentEncode); - } -}; - -module.exports.serializeHost = serializeHost; - -module.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort; - -module.exports.serializeInteger = function (integer) { - return String(integer); -}; - -module.exports.parseURL = function (input, options) { - if (options === undefined) { - options = {}; - } - - // We don't handle blobs, so this just delegates: - return module.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride }); -}; - - -/***/ }), - -/***/ 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]; -}; - - - -/***/ }), - -/***/ 502: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - -const path = __nccwpck_require__(1017); -const pathKey = __nccwpck_require__(539); - -module.exports = opts => { - opts = Object.assign({ - cwd: process.cwd(), - path: process.env[pathKey()] - }, opts); - - let prev; - let pth = path.resolve(opts.cwd); - const ret = []; - - while (prev !== pth) { - ret.push(path.join(pth, 'node_modules/.bin')); - prev = pth; - pth = path.resolve(pth, '..'); - } - - // ensure the running `node` binary is used - ret.push(path.dirname(process.execPath)); - - return ret.concat(opts.path).join(path.delimiter); -}; - -module.exports.env = opts => { - opts = Object.assign({ - env: process.env - }, opts); - - const env = Object.assign({}, opts.env); - const path = pathKey({env}); - - opts.path = env[path]; - env[path] = module.exports(opts); - - return env; -}; - - -/***/ }), - -/***/ 2072: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = paginationMethodsPlugin - -function paginationMethodsPlugin (octokit) { - octokit.getFirstPage = (__nccwpck_require__(9555).bind)(null, octokit) - octokit.getLastPage = (__nccwpck_require__(2203).bind)(null, octokit) - octokit.getNextPage = (__nccwpck_require__(6655).bind)(null, octokit) - octokit.getPreviousPage = (__nccwpck_require__(3032).bind)(null, octokit) - octokit.hasFirstPage = __nccwpck_require__(9631) - octokit.hasLastPage = __nccwpck_require__(4286) - octokit.hasNextPage = __nccwpck_require__(500) - octokit.hasPreviousPage = __nccwpck_require__(5996) -} - - -/***/ }), - -/***/ 191: -/***/ ((module) => { - -module.exports = deprecate - -const loggedMessages = {} - -function deprecate (message) { - if (loggedMessages[message]) { - return - } - - console.warn(`DEPRECATED (@octokit/rest): ${message}`) - loggedMessages[message] = 1 -} - - -/***/ }), - -/***/ 9555: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = getFirstPage - -const getPage = __nccwpck_require__(8604) - -function getFirstPage (octokit, link, headers) { - return getPage(octokit, link, 'first', headers) -} - - -/***/ }), - -/***/ 2203: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = getLastPage - -const getPage = __nccwpck_require__(8604) - -function getLastPage (octokit, link, headers) { - return getPage(octokit, link, 'last', headers) -} - - -/***/ }), - -/***/ 6655: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = getNextPage - -const getPage = __nccwpck_require__(8604) - -function getNextPage (octokit, link, headers) { - return getPage(octokit, link, 'next', headers) -} - - -/***/ }), - -/***/ 7889: -/***/ ((module) => { - -module.exports = getPageLinks - -function getPageLinks (link) { - link = link.link || link.headers.link || '' - - const links = {} - - // link format: - // '; rel="next", ; rel="last"' - link.replace(/<([^>]*)>;\s*rel="([\w]*)"/g, (m, uri, type) => { - links[type] = uri - }) - - return links -} - - -/***/ }), - -/***/ 8604: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = getPage - -const deprecate = __nccwpck_require__(191) -const getPageLinks = __nccwpck_require__(7889) -const HttpError = __nccwpck_require__(6058) - -function getPage (octokit, link, which, headers) { - deprecate(`octokit.get${which.charAt(0).toUpperCase() + which.slice(1)}Page() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) - const url = getPageLinks(link)[which] - - if (!url) { - const urlError = new HttpError(`No ${which} page found`, 404) - return Promise.reject(urlError) - } - - const requestOptions = { - url, - headers: applyAcceptHeader(link, headers) - } - - const promise = octokit.request(requestOptions) - - return promise -} - -function applyAcceptHeader (res, headers) { - const previous = res.headers && res.headers['x-github-media-type'] - - if (!previous || (headers && headers.accept)) { - return headers - } - headers = headers || {} - headers.accept = 'application/vnd.' + previous - .replace('; param=', '.') - .replace('; format=', '+') - - return headers -} - - -/***/ }), - -/***/ 3032: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = getPreviousPage - -const getPage = __nccwpck_require__(8604) - -function getPreviousPage (octokit, link, headers) { - return getPage(octokit, link, 'prev', headers) -} - - -/***/ }), - -/***/ 9631: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = hasFirstPage - -const deprecate = __nccwpck_require__(191) -const getPageLinks = __nccwpck_require__(7889) - -function hasFirstPage (link) { - deprecate(`octokit.hasFirstPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) - return getPageLinks(link).first -} - - -/***/ }), - -/***/ 4286: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = hasLastPage - -const deprecate = __nccwpck_require__(191) -const getPageLinks = __nccwpck_require__(7889) - -function hasLastPage (link) { - deprecate(`octokit.hasLastPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) - return getPageLinks(link).last -} - - -/***/ }), - -/***/ 500: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = hasNextPage - -const deprecate = __nccwpck_require__(191) -const getPageLinks = __nccwpck_require__(7889) - -function hasNextPage (link) { - deprecate(`octokit.hasNextPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) - return getPageLinks(link).next -} - - -/***/ }), - -/***/ 5996: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = hasPreviousPage - -const deprecate = __nccwpck_require__(191) -const getPageLinks = __nccwpck_require__(7889) - -function hasPreviousPage (link) { - deprecate(`octokit.hasPreviousPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) - return getPageLinks(link).prev -} - - -/***/ }), - -/***/ 6058: -/***/ ((module) => { - -module.exports = class HttpError extends Error { - constructor (message, code, headers) { - super(message) +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; - // Maintains proper stack trace (only available on V8) - /* istanbul ignore next */ - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor) - } +/** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ +function SetCache(values) { + var index = -1, + length = values ? values.length : 0; - this.name = 'HttpError' - this.code = code - this.headers = headers + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); } } +/** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ +function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; +} -/***/ }), - -/***/ 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 - }) +/** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ +function setCacheHas(value) { + return this.__data__.has(value); +} - Object.defineProperty(Function.prototype, 'onceStrict', { - value: function () { - return onceStrict(this) - }, - configurable: true - }) -}) +// Add methods to `SetCache`. +SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; +SetCache.prototype.has = setCacheHas; -function once (fn) { - var f = function () { - if (f.called) return f.value - f.called = true - return f.value = fn.apply(this, arguments) +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } } - f.called = false - return f + return -1; } -function onceStrict (fn) { - var f = function () { - if (f.called) - throw new Error(f.onceError) - f.called = true - return f.value = fn.apply(this, arguments) +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; } - var name = fn.name || 'Function wrapped with `once`' - f.onceError = name + " shouldn't be called more than once" - f.called = false - return f + var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); } +/** + * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ +function baseUniq(array, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + length = array.length, + isCommon = true, + result = [], + seen = result; -/***/ }), - -/***/ 4824: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - -const os = __nccwpck_require__(2037); -const macosRelease = __nccwpck_require__(7493); -const winRelease = __nccwpck_require__(3515); - -const osName = (platform, release) => { - if (!platform && release) { - throw new Error('You can\'t specify a `release` without specifying `platform`'); - } - - platform = platform || os.platform(); - - let id; - - if (platform === 'darwin') { - if (!release && os.platform() === 'darwin') { - release = os.release(); - } - - const prefix = release ? (Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X') : 'macOS'; - id = release ? macosRelease(release).name : ''; - return prefix + (id ? ' ' + id : ''); - } - - if (platform === 'linux') { - if (!release && os.platform() === 'linux') { - release = os.release(); - } - - id = release ? release.replace(/^(\d+\.\d+).*/, '$1') : ''; - return 'Linux' + (id ? ' ' + id : ''); - } - - if (platform === 'win32') { - if (!release && os.platform() === 'win32') { - release = os.release(); - } - - id = release ? winRelease(release) : ''; - return 'Windows' + (id ? ' ' + id : ''); - } - - return platform; -}; - -module.exports = osName; - - -/***/ }), - -/***/ 1330: -/***/ ((module) => { - -"use strict"; - -module.exports = (promise, onFinally) => { - onFinally = onFinally || (() => {}); - - return promise.then( - val => new Promise(resolve => { - resolve(onFinally()); - }).then(() => val), - err => new Promise(resolve => { - resolve(onFinally()); - }).then(() => { - throw err; - }) - ); -}; - - -/***/ }), - -/***/ 539: -/***/ ((module) => { - -"use strict"; - -module.exports = opts => { - opts = opts || {}; - - const env = opts.env || process.env; - const platform = opts.platform || process.platform; + if (comparator) { + isCommon = false; + includes = arrayIncludesWith; + } + else if (length >= LARGE_ARRAY_SIZE) { + var set = iteratee ? null : createSet(array); + if (set) { + return setToArray(set); + } + isCommon = false; + includes = cacheHas; + seen = new SetCache; + } + else { + seen = iteratee ? [] : result; + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; - if (platform !== 'win32') { - return 'PATH'; - } + value = (comparator || value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } + else if (!includes(seen, computed, comparator)) { + if (seen !== result) { + seen.push(computed); + } + result.push(value); + } + } + return result; +} - return Object.keys(env).find(x => x.toUpperCase() === 'PATH') || 'Path'; +/** + * Creates a set object of `values`. + * + * @private + * @param {Array} values The values to add to the set. + * @returns {Object} Returns the new set. + */ +var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { + return new Set(values); }; - -/***/ }), - -/***/ 8341: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -var once = __nccwpck_require__(1223) -var eos = __nccwpck_require__(1205) -var fs = __nccwpck_require__(7147) // we only need fs to get the ReadStream and WriteStream prototypes - -var noop = function () {} -var ancient = /^v?\.0/.test(process.version) - -var isFn = function (fn) { - return typeof fn === 'function' +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; } -var isFS = function (stream) { - if (!ancient) return false // newer node version do not need to care about fs is a special way - if (!fs) return false // browser - return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close) +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; } -var isRequest = function (stream) { - return stream.setHeader && isFn(stream.abort) +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); } -var destroyer = function (stream, reading, writing, callback) { - callback = once(callback) - - var closed = false - stream.on('close', function () { - closed = true - }) +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} - eos(stream, {readable: reading, writable: writing}, function (err) { - if (err) return callback(err) - closed = true - callback() - }) +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to process. + * @returns {string} Returns the source code. + */ +function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} - var destroyed = false - return function (err) { - if (closed) return - if (destroyed) return - destroyed = true +/** + * Creates a duplicate-free version of an array, using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons, in which only the first occurrence of each + * element is kept. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.uniq([2, 1, 2]); + * // => [2, 1] + */ +function uniq(array) { + return (array && array.length) + ? baseUniq(array) + : []; +} - if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks - if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} - if (isFn(stream.destroy)) return stream.destroy() +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 8-9 which returns 'object' for typed array and other constructors. + var tag = isObject(value) ? objectToString.call(value) : ''; + return tag == funcTag || tag == genTag; +} - callback(err || new Error('stream was destroyed')) - } +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); } -var call = function (fn) { - fn() +/** + * This method returns `undefined`. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Util + * @example + * + * _.times(2, _.noop); + * // => [undefined, undefined] + */ +function noop() { + // No operation performed. } -var pipe = function (from, to) { - return from.pipe(to) -} +module.exports = uniq; -var pump = function () { - var streams = Array.prototype.slice.call(arguments) - var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop - if (Array.isArray(streams[0])) streams = streams[0] - if (streams.length < 2) throw new Error('pump requires two streams per minimum') +/***/ }), - var error - var destroys = streams.map(function (stream, i) { - var reading = i < streams.length - 1 - var writing = i > 0 - return destroyer(stream, reading, writing, function (err) { - if (!error) error = err - if (err) destroys.forEach(call) - if (reading) return - destroys.forEach(call) - callback(error) - }) - }) +/***/ 7493: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return streams.reduce(pipe) -} +"use strict"; -module.exports = pump +const os = __nccwpck_require__(2037); +const nameMap = new Map([ + [19, 'Catalina'], + [18, 'Mojave'], + [17, 'High Sierra'], + [16, 'Sierra'], + [15, 'El Capitan'], + [14, 'Yosemite'], + [13, 'Mavericks'], + [12, 'Mountain Lion'], + [11, 'Lion'], + [10, 'Snow Leopard'], + [9, 'Leopard'], + [8, 'Tiger'], + [7, 'Panther'], + [6, 'Jaguar'], + [5, 'Puma'] +]); -/***/ }), +const macosRelease = release => { + release = Number((release || os.release()).split('.')[0]); + return { + name: nameMap.get(release), + version: '10.' + (release - 4) + }; +}; -/***/ 5911: -/***/ ((module, exports) => { +module.exports = macosRelease; +// TODO: remove this in the next major version +module.exports["default"] = macosRelease; -exports = module.exports = SemVer -var debug -/* istanbul ignore next */ -if (typeof process === 'object' && - process.env && - process.env.NODE_DEBUG && - /\bsemver\b/i.test(process.env.NODE_DEBUG)) { - debug = function () { - var args = Array.prototype.slice.call(arguments, 0) - args.unshift('SEMVER') - console.log.apply(console, args) - } -} else { - debug = function () {} -} +/***/ }), -// Note: this is the semver.org version of the spec that it implements -// Not necessarily the package version of this code. -exports.SEMVER_SPEC_VERSION = '2.0.0' +/***/ 8560: +/***/ ((module) => { -var MAX_LENGTH = 256 -var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +"use strict"; -// Max safe segment length for coercion. -var MAX_SAFE_COMPONENT_LENGTH = 16 -// The actual regexps go on exports.re -var re = exports.re = [] -var src = exports.src = [] -var t = exports.tokens = {} -var R = 0 +/** + * Tries to execute a function and discards any error that occurs. + * @param {Function} fn - Function that might or might not throw an error. + * @returns {?*} Return-value of the function when no error occurred. + */ +module.exports = function(fn) { + + try { return fn() } catch (e) {} -function tok (n) { - t[n] = R++ } -// The following Regular Expressions can be used for tokenizing, -// validating, and parsing SemVer version strings. +/***/ }), -// ## Numeric Identifier -// A single `0`, or a non-zero digit followed by zero or more digits. +/***/ 467: +/***/ ((module, exports, __nccwpck_require__) => { -tok('NUMERICIDENTIFIER') -src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' -tok('NUMERICIDENTIFIERLOOSE') -src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+' +"use strict"; -// ## Non-numeric Identifier -// Zero or more digits, followed by a letter or hyphen, and then zero or -// more letters, digits, or hyphens. -tok('NONNUMERICIDENTIFIER') -src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' +Object.defineProperty(exports, "__esModule", ({ value: true })); -// ## Main Version -// Three dot-separated numeric identifiers. +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } -tok('MAINVERSION') -src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')' +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)); -tok('MAINVERSIONLOOSE') -src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. +// fix for "Readable" isn't a named export issue +const Readable = Stream.Readable; -tok('PRERELEASEIDENTIFIER') -src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); -tok('PRERELEASEIDENTIFIERLOOSE') -src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' +class Blob { + constructor() { + this[TYPE] = ''; -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. + const blobParts = arguments[0]; + const options = arguments[1]; -tok('PRERELEASE') -src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' + const buffers = []; + let size = 0; -tok('PRERELEASELOOSE') -src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' + 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); + } + } -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. + this[BUFFER] = Buffer.concat(buffers); + + 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); -tok('BUILDIDENTIFIER') -src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +} -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. +Object.defineProperties(Blob.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); -tok('BUILD') -src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + - '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))' +Object.defineProperty(Blob.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); -// ## Full Version String -// A main version, followed optionally by a pre-release version and -// build metadata. +/** + * fetch-error.js + * + * FetchError interface for operational errors + */ -// Note that the only major, minor, patch, and pre-release sections of -// the version string are capturing groups. The build metadata is not a -// capturing group, because it should not ever be used in version -// comparison. +/** + * 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); -tok('FULL') -tok('FULLPLAIN') -src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + - src[t.PRERELEASE] + '?' + - src[t.BUILD] + '?' + this.message = message; + this.type = type; -src[t.FULL] = '^' + src[t.FULLPLAIN] + '$' + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } -// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. -// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty -// common in the npm registry. -tok('LOOSEPLAIN') -src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + - src[t.PRERELEASELOOSE] + '?' + - src[t.BUILD] + '?' + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} -tok('LOOSE') -src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; -tok('GTLT') -src[t.GTLT] = '((?:<|>)?=?)' +let convert; +try { + convert = (__nccwpck_require__(2877).convert); +} catch (e) {} -// Something like "2.*" or "1.2.x". -// Note that "x.x" is a valid xRange identifer, meaning "any version" -// Only the first item is strictly required. -tok('XRANGEIDENTIFIERLOOSE') -src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' -tok('XRANGEIDENTIFIER') -src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' +const INTERNALS = Symbol('Body internals'); -tok('XRANGEPLAIN') -src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:' + src[t.PRERELEASE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream.PassThrough; -tok('XRANGEPLAINLOOSE') -src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:' + src[t.PRERELEASELOOSE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' +/** + * 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; -tok('XRANGE') -src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' -tok('XRANGELOOSE') -src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; -// Coercion. -// Extract anything that could conceivably be a part of a valid semver -tok('COERCE') -src[t.COERCE] = '(^|[^\\d])' + - '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + - '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + - '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + - '(?:$|[^\\d])' -tok('COERCERTL') -re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g') + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; -// Tilde ranges. -// Meaning is "reasonably at or greater than" -tok('LONETILDE') -src[t.LONETILDE] = '(?:~>?)' + 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; -tok('TILDETRIM') -src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' -re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') -var tildeTrimReplace = '$1~' + 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; + }); + } +} -tok('TILDE') -src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' -tok('TILDELOOSE') -src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, -// Caret ranges. -// Meaning is "at least and backwards compatible with" -tok('LONECARET') -src[t.LONECARET] = '(?:\\^)' + get bodyUsed() { + return this[INTERNALS].disturbed; + }, -tok('CARETTRIM') -src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' -re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') -var caretTrimReplace = '$1^' + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, -tok('CARET') -src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' -tok('CARETLOOSE') -src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' + /** + * 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 + }); + }); + }, -// A simple gt/lt/eq thing, or just "" to indicate "any version" -tok('COMPARATORLOOSE') -src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$' -tok('COMPARATOR') -src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$' + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; -// An expression to strip any whitespace between the gtlt and the thing -// it modifies, so that `> 1.2.3` ==> `>1.2.3` -tok('COMPARATORTRIM') -src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + - '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')' + 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')); + } + }); + }, -// this one has to use the /g flag -re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') -var comparatorTrimReplace = '$1$2$3' + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, -// Something like `1.2.3 - 1.2.4` -// Note that these all use the loose form, because they'll be -// checked against either the strict or loose comparator form -// later. -tok('HYPHENRANGE') -src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAIN] + ')' + - '\\s*$' + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, -tok('HYPHENRANGELOOSE') -src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s*$' + /** + * 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; -// Star ranges basically just allow anything at all. -tok('STAR') -src[t.STAR] = '(<|>)?=?\\s*\\*' + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; -// Compile to actual regexp objects. -// All are flag-free, unless they were created above with a flag. -for (var i = 0; i < R; i++) { - debug(i, src[i]) - if (!re[i]) { - re[i] = new RegExp(src[i]) - } -} +// 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 } +}); -exports.parse = parse -function parse (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } +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); + } + } +}; - if (version instanceof SemVer) { - return version - } +/** + * 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 (typeof version !== 'string') { - return null - } + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } - if (version.length > MAX_LENGTH) { - return null - } + this[INTERNALS].disturbed = true; - var r = options.loose ? re[t.LOOSE] : re[t.FULL] - if (!r.test(version)) { - return null - } + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } - try { - return new SemVer(version, options) - } catch (er) { - return null - } -} + let body = this.body; -exports.valid = valid -function valid (version, options) { - var v = parse(version, options) - return v ? v.version : null -} + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } -exports.clean = clean -function clean (version, options) { - var s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null -} + // body is blob + if (isBlob(body)) { + body = body.stream(); + } -exports.SemVer = SemVer + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } -function SemVer (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - if (version instanceof SemVer) { - if (version.loose === options.loose) { - return version - } else { - version = version.version - } - } else if (typeof version !== 'string') { - throw new TypeError('Invalid Version: ' + version) - } + // istanbul ignore if: should never happen + if (!(body instanceof Stream)) { + return Body.Promise.resolve(Buffer.alloc(0)); + } - if (version.length > MAX_LENGTH) { - throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') - } + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; - if (!(this instanceof SemVer)) { - return new SemVer(version, options) - } + return new Body.Promise(function (resolve, reject) { + let resTimeout; - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose + // 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); + } - var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) + // 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)); + } + }); - if (!m) { - throw new TypeError('Invalid Version: ' + version) - } + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } - this.raw = version + 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; + } - // these are actually numbers - this.major = +m[1] - this.minor = +m[2] - this.patch = +m[3] + accumBytes += chunk.length; + accum.push(chunk); + }); - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError('Invalid major version') - } + body.on('end', function () { + if (abort) { + return; + } - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError('Invalid minor version') - } + clearTimeout(resTimeout); - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError('Invalid patch version') - } + 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)); + } + }); + }); +} - // numberify any prerelease numeric ids - if (!m[4]) { - this.prerelease = [] - } else { - this.prerelease = m[4].split('.').map(function (id) { - if (/^[0-9]+$/.test(id)) { - var num = +id - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num - } - } - return id - }) - } +/** + * 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'); + } - this.build = m[5] ? m[5].split('.') : [] - this.format() -} + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; -SemVer.prototype.format = function () { - this.version = this.major + '.' + this.minor + '.' + this.patch - if (this.prerelease.length) { - this.version += '-' + this.prerelease.join('.') - } - return this.version -} + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } -SemVer.prototype.toString = function () { - return this.version -} + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); -SemVer.prototype.compare = function (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } + // html5 + if (!res && str) { + res = / having one - if (this.prerelease.length && !other.prerelease.length) { - return -1 - } else if (!this.prerelease.length && other.prerelease.length) { - return 1 - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0 - } + // prevent decode issues when sites use incorrect encoding + // ref: https://hsivonen.fi/encoding-menu/ + if (charset === 'gb2312' || charset === 'gbk') { + charset = 'gb18030'; + } + } - var i = 0 - do { - var a = this.prerelease[i] - var b = other.prerelease[i] - debug('prerelease compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) + // turn raw buffers into a single utf-8 buffer + return convert(buffer, 'UTF-8', charset).toString(); } -SemVer.prototype.compareBuild = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +/** + * 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; + } - var i = 0 - do { - var a = this.build[i] - var b = other.build[i] - debug('prerelease compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) + // 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'; } -// preminor will bump the version up to the next minor release, and immediately -// down to pre-release. premajor and prepatch work the same way. -SemVer.prototype.inc = function (release, identifier) { - switch (release) { - case 'premajor': - this.prerelease.length = 0 - this.patch = 0 - this.minor = 0 - this.major++ - this.inc('pre', identifier) - break - case 'preminor': - this.prerelease.length = 0 - this.patch = 0 - this.minor++ - this.inc('pre', identifier) - break - case 'prepatch': - // If this is already a prerelease, it will bump to the next version - // drop any prereleases that might already exist, since they are not - // relevant at this point. - this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) - break - // If the input is a non-prerelease version, this acts the same as - // prepatch. - case 'prerelease': - if (this.prerelease.length === 0) { - this.inc('patch', identifier) - } - this.inc('pre', identifier) - break +/** + * 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]); +} - case 'major': - // If this is a pre-major version, bump up to the same major version. - // Otherwise increment major. - // 1.0.0-5 bumps to 1.0.0 - // 1.1.0 bumps to 2.0.0 - if (this.minor !== 0 || - this.patch !== 0 || - this.prerelease.length === 0) { - this.major++ - } - this.minor = 0 - this.patch = 0 - this.prerelease = [] - break - case 'minor': - // If this is a pre-minor version, bump up to the same minor version. - // Otherwise increment minor. - // 1.2.0-5 bumps to 1.2.0 - // 1.2.1 bumps to 1.3.0 - if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++ - } - this.patch = 0 - this.prerelease = [] - break - case 'patch': - // If this is not a pre-release version, it will increment the patch. - // If it is a pre-release it will bump up to the same patch version. - // 1.2.0-5 patches to 1.2.0 - // 1.2.0 patches to 1.2.1 - if (this.prerelease.length === 0) { - this.patch++ - } - this.prerelease = [] - break - // This probably shouldn't be used publicly. - // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction. - case 'pre': - if (this.prerelease.length === 0) { - this.prerelease = [0] - } else { - var i = this.prerelease.length - while (--i >= 0) { - if (typeof this.prerelease[i] === 'number') { - this.prerelease[i]++ - i = -2 - } - } - if (i === -1) { - // didn't increment anything - this.prerelease.push(0) - } - } - if (identifier) { - // 1.2.0-beta.1 bumps to 1.2.0-beta.2, - // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 - if (this.prerelease[0] === identifier) { - if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] - } - } else { - this.prerelease = [identifier, 0] - } - } - break +/** + * 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; + + // don't allow cloning a used body + if (instance.bodyUsed) { + throw new Error('cannot clone body after it is used'); + } - default: - throw new Error('invalid increment argument: ' + release) - } - this.format() - this.raw = this.version - return this + // 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; } -exports.inc = inc -function inc (version, release, loose, identifier) { - if (typeof (loose) === 'string') { - identifier = loose - loose = undefined - } +/** + * 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'; + } +} - try { - return new SemVer(version, loose).inc(release, identifier).version - } catch (er) { - return null - } +/** + * 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; + + + 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; + } } -exports.diff = diff -function diff (version1, version2) { - if (eq(version1, version2)) { - return null - } else { - var v1 = parse(version1) - var v2 = parse(version2) - var prefix = '' - if (v1.prerelease.length || v2.prerelease.length) { - prefix = 'pre' - var defaultResult = 'prerelease' - } - for (var key in v1) { - if (key === 'major' || key === 'minor' || key === 'patch') { - if (v1[key] !== v2[key]) { - return prefix + key - } - } - } - return defaultResult // may be undefined - } +/** + * 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 (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); + } } -exports.compareIdentifiers = compareIdentifiers +// expose Promise +Body.Promise = global.Promise; -var numeric = /^[0-9]+$/ -function compareIdentifiers (a, b) { - var anum = numeric.test(a) - var bnum = numeric.test(b) +/** + * headers.js + * + * Headers class offers convenient helpers + */ - if (anum && bnum) { - a = +a - b = +b - } +const invalidTokenRegex = /[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/; +const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/; - return a === b ? 0 - : (anum && !bnum) ? -1 - : (bnum && !anum) ? 1 - : a < b ? -1 - : 1 +function validateName(name) { + name = `${name}`; + if (invalidTokenRegex.test(name) || name === '') { + throw new TypeError(`${name} is not a legal HTTP header name`); + } } -exports.rcompareIdentifiers = rcompareIdentifiers -function rcompareIdentifiers (a, b) { - return compareIdentifiers(b, a) +function validateValue(value) { + value = `${value}`; + if (invalidHeaderCharRegex.test(value)) { + throw new TypeError(`${value} is not a legal HTTP header value`); + } } -exports.major = major -function major (a, loose) { - return new SemVer(a, loose).major +/** + * 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; } -exports.minor = minor -function minor (a, loose) { - return new SemVer(a, loose).minor -} +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; -exports.patch = patch -function patch (a, loose) { - return new SemVer(a, loose).patch -} + this[MAP] = Object.create(null); -exports.compare = compare -function compare (a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)) -} + 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); + } + } + + 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'); + } + + // 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)); + } -exports.compareLoose = compareLoose -function compareLoose (a, b) { - return compare(a, b, true) -} + 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'); + } + } -exports.compareBuild = compareBuild -function compareBuild (a, b, loose) { - var versionA = new SemVer(a, loose) - var versionB = new SemVer(b, loose) - return versionA.compare(versionB) || versionA.compareBuild(versionB) -} + /** + * 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; + } -exports.rcompare = rcompare -function rcompare (a, b, loose) { - return compare(b, a, loose) -} + return this[MAP][key].join(', '); + } -exports.sort = sort -function sort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(a, b, loose) - }) -} + /** + * 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; -exports.rsort = rsort -function rsort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(b, a, loose) - }) -} + 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]; -exports.gt = gt -function gt (a, b, loose) { - return compare(a, b, loose) > 0 -} + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } + } -exports.lt = lt -function lt (a, b, loose) { - return compare(a, b, loose) < 0 -} + /** + * 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]; + } -exports.eq = eq -function eq (a, b, loose) { - return compare(a, b, loose) === 0 -} + /** + * 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]; + } + } -exports.neq = neq -function neq (a, b, loose) { - return compare(a, b, loose) !== 0 -} + /** + * Check for header name existence + * + * @param String name Header name + * @return Boolean + */ + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } -exports.gte = gte -function gte (a, b, loose) { - return compare(a, b, loose) >= 0 -} + /** + * 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]; + } + } -exports.lte = lte -function lte (a, b, loose) { - return compare(a, b, loose) <= 0 -} + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } -exports.cmp = cmp -function cmp (a, op, b, loose) { - switch (op) { - case '===': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a === b + /** + * Get an iterator on keys. + * + * @return Iterator + */ + keys() { + return createHeadersIterator(this, 'key'); + } - case '!==': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a !== b + /** + * Get an iterator on values. + * + * @return Iterator + */ + values() { + return createHeadersIterator(this, 'value'); + } - case '': - case '=': - case '==': - return eq(a, b, loose) + /** + * 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]; - case '!=': - return neq(a, b, loose) +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); - case '>': - return gt(a, b, loose) +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 } +}); - case '>=': - return gte(a, b, loose) +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; - case '<': - return lt(a, b, loose) + 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(', ')]; + }); +} - case '<=': - return lte(a, b, loose) +const INTERNAL = Symbol('internal'); - default: - throw new TypeError('Invalid operator: ' + op) - } +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; } -exports.Comparator = Comparator -function Comparator (comp, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp - } else { - comp = comp.value - } - } +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } - if (!(this instanceof Comparator)) { - return new Comparator(comp, options) - } + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; - debug('comparator', comp, options) - this.options = options - this.loose = !!options.loose - this.parse(comp) + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } - if (this.semver === ANY) { - this.value = '' - } else { - this.value = this.operator + this.semver.version - } + this[INTERNAL].index = index + 1; - debug('comp', this) -} + return { + value: values[index], + done: false + }; + } +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); -var ANY = {} -Comparator.prototype.parse = function (comp) { - var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var m = comp.match(r) +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true +}); - if (!m) { - throw new TypeError('Invalid comparator: ' + comp) - } +/** + * 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]); - this.operator = m[1] !== undefined ? m[1] : '' - if (this.operator === '=') { - this.operator = '' - } + // 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 it literally is just '>' or '' then allow anything. - if (!m[2]) { - this.semver = ANY - } else { - this.semver = new SemVer(m[2], this.options.loose) - } + return obj; } -Comparator.prototype.toString = function () { - return this.value +/** + * 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; } -Comparator.prototype.test = function (version) { - debug('Comparator.test', version, this.options.loose) +const INTERNALS$1 = Symbol('Response internals'); - if (this.semver === ANY || version === ANY) { - return true - } +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http.STATUS_CODES; - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } +/** + * 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] : {}; - return cmp(version, this.operator, this.semver, this.options) -} + Body.call(this, body, opts); -Comparator.prototype.intersects = function (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } + const status = opts.status || 200; + const headers = new Headers(opts.headers); - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } - var rangeTmp + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; + } - if (this.operator === '') { - if (this.value === '') { - return true - } - rangeTmp = new Range(comp.value, options) - return satisfies(this.value, rangeTmp, options) - } else if (comp.operator === '') { - if (comp.value === '') { - return true - } - rangeTmp = new Range(this.value, options) - return satisfies(comp.semver, rangeTmp, options) - } + get url() { + return this[INTERNALS$1].url || ''; + } - var sameDirectionIncreasing = - (this.operator === '>=' || this.operator === '>') && - (comp.operator === '>=' || comp.operator === '>') - var sameDirectionDecreasing = - (this.operator === '<=' || this.operator === '<') && - (comp.operator === '<=' || comp.operator === '<') - var sameSemVer = this.semver.version === comp.semver.version - var differentDirectionsInclusive = - (this.operator === '>=' || this.operator === '<=') && - (comp.operator === '>=' || comp.operator === '<=') - var oppositeDirectionsLessThan = - cmp(this.semver, '<', comp.semver, options) && - ((this.operator === '>=' || this.operator === '>') && - (comp.operator === '<=' || comp.operator === '<')) - var oppositeDirectionsGreaterThan = - cmp(this.semver, '>', comp.semver, options) && - ((this.operator === '<=' || this.operator === '<') && - (comp.operator === '>=' || comp.operator === '>')) + get status() { + return this[INTERNALS$1].status; + } - return sameDirectionIncreasing || sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || oppositeDirectionsGreaterThan -} + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + } -exports.Range = Range -function Range (range, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } + get redirected() { + return this[INTERNALS$1].counter > 0; + } + + get statusText() { + return this[INTERNALS$1].statusText; + } - if (range instanceof Range) { - if (range.loose === !!options.loose && - range.includePrerelease === !!options.includePrerelease) { - return range - } else { - return new Range(range.raw, options) - } - } + get headers() { + return this[INTERNALS$1].headers; + } - if (range instanceof Comparator) { - return new Range(range.value, options) - } + /** + * 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 + }); + } +} - if (!(this instanceof Range)) { - return new Range(range, options) - } +Body.mixIn(Response.prototype); - this.options = options - this.loose = !!options.loose - this.includePrerelease = !!options.includePrerelease +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 } +}); - // First, split based on boolean or || - this.raw = range - this.set = range.split(/\s*\|\|\s*/).map(function (range) { - return this.parseRange(range.trim()) - }, this).filter(function (c) { - // throw out any that are not relevant for whatever reason - return c.length - }) +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); - if (!this.set.length) { - throw new TypeError('Invalid SemVer Range: ' + range) - } +const INTERNALS$2 = Symbol('Request internals'); +const URL = Url.URL || whatwgUrl.URL; - this.format() -} +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url.parse; +const format_url = Url.format; -Range.prototype.format = function () { - this.range = this.set.map(function (comps) { - return comps.join(' ').trim() - }).join('||').trim() - return this.range -} +/** + * 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(); + } -Range.prototype.toString = function () { - return this.range + // Fallback to old implementation for arbitrary URLs + return parse_url(urlStr); } -Range.prototype.parseRange = function (range) { - var loose = this.options.loose - range = range.trim() - // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` - var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] - range = range.replace(hr, hyphenReplace) - debug('hyphen replace', range) - // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` - range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[t.COMPARATORTRIM]) +const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; - // `~ 1.2.3` => `~1.2.3` - range = range.replace(re[t.TILDETRIM], tildeTrimReplace) +/** + * 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'; +} - // `^ 1.2.3` => `^1.2.3` - range = range.replace(re[t.CARETTRIM], caretTrimReplace) +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); +} - // normalize spaces - range = range.split(/\s+/).join(' ') +/** + * 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] : {}; - // At this point, the range is completely trimmed and - // ready to be split into comparators. + let parsedURL; - var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var set = range.split(' ').map(function (comp) { - return parseComparator(comp, this.options) - }, this).join(' ').split(/\s+/) - if (this.options.loose) { - // in loose mode, throw out any that are not valid comparators - set = set.filter(function (comp) { - return !!comp.match(compRe) - }) - } - set = set.map(function (comp) { - return new Comparator(comp, this.options) - }, this) + // 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); + } - return set -} + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); -Range.prototype.intersects = function (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') - } + if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { + throw new TypeError('Request with GET/HEAD method cannot have body'); + } - return this.set.some(function (thisComparators) { - return ( - isSatisfiable(thisComparators, options) && - range.set.some(function (rangeComparators) { - return ( - isSatisfiable(rangeComparators, options) && - thisComparators.every(function (thisComparator) { - return rangeComparators.every(function (rangeComparator) { - return thisComparator.intersects(rangeComparator, options) - }) - }) - ) - }) - ) - }) -} + let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; -// take a set of comparators and determine whether there -// exists a version which can satisfy it -function isSatisfiable (comparators, options) { - var result = true - var remainingComparators = comparators.slice() - var testComparator = remainingComparators.pop() + Body.call(this, inputBody, { + timeout: init.timeout || input.timeout || 0, + size: init.size || input.size || 0 + }); - while (result && remainingComparators.length) { - result = remainingComparators.every(function (otherComparator) { - return testComparator.intersects(otherComparator, options) - }) + const headers = new Headers(init.headers || input.headers || {}); - testComparator = remainingComparators.pop() - } + if (inputBody != null && !headers.has('Content-Type')) { + const contentType = extractContentType(inputBody); + if (contentType) { + headers.append('Content-Type', contentType); + } + } - return result -} + let signal = isRequest(input) ? input.signal : null; + if ('signal' in init) signal = init.signal; -// Mostly just for testing and legacy API reasons -exports.toComparators = toComparators -function toComparators (range, options) { - return new Range(range, options).set.map(function (comp) { - return comp.map(function (c) { - return c.value - }).join(' ').trim().split(' ') - }) -} + if (signal != null && !isAbortSignal(signal)) { + throw new TypeError('Expected signal to be an instanceof AbortSignal'); + } -// comprised of xranges, tildes, stars, and gtlt's at this point. -// already replaced the hyphen ranges -// turn into a set of JUST comparators. -function parseComparator (comp, options) { - debug('comp', comp, options) - comp = replaceCarets(comp, options) - debug('caret', comp) - comp = replaceTildes(comp, options) - debug('tildes', comp) - comp = replaceXRanges(comp, options) - debug('xrange', comp) - comp = replaceStars(comp, options) - debug('stars', comp) - return comp -} + this[INTERNALS$2] = { + method, + redirect: init.redirect || input.redirect || 'follow', + headers, + parsedURL, + signal + }; -function isX (id) { - return !id || id.toLowerCase() === 'x' || id === '*' -} + // 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; + } -// ~, ~> --> * (any, kinda silly) -// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 -// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 -// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 -// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 -// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 -function replaceTildes (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceTilde(comp, options) - }).join(' ') -} + get method() { + return this[INTERNALS$2].method; + } -function replaceTilde (comp, options) { - var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] - return comp.replace(r, function (_, M, m, p, pr) { - debug('tilde', comp, _, M, m, p, pr) - var ret + get url() { + return format_url(this[INTERNALS$2].parsedURL); + } - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - // ~1.2 == >=1.2.0 <1.3.0 - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else if (pr) { - debug('replaceTilde pr', pr) - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } else { - // ~1.2.3 == >=1.2.3 <1.3.0 - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } + get headers() { + return this[INTERNALS$2].headers; + } - debug('tilde return', ret) - return ret - }) -} + get redirect() { + return this[INTERNALS$2].redirect; + } -// ^ --> * (any, kinda silly) -// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 -// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 -// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 -// ^1.2.3 --> >=1.2.3 <2.0.0 -// ^1.2.0 --> >=1.2.0 <2.0.0 -function replaceCarets (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceCaret(comp, options) - }).join(' ') + get signal() { + return this[INTERNALS$2].signal; + } + + /** + * Clone this request + * + * @return Request + */ + clone() { + return new Request(this); + } } -function replaceCaret (comp, options) { - debug('caret', comp, options) - var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] - return comp.replace(r, function (_, M, m, p, pr) { - debug('caret', comp, _, M, m, p, pr) - var ret +Body.mixIn(Request.prototype); - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - if (M === '0') { - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else { - ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' - } - } else if (pr) { - debug('replaceCaret pr', pr) - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + (+M + 1) + '.0.0' - } - } else { - debug('no pr') - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + (+M + 1) + '.0.0' - } - } +Object.defineProperty(Request.prototype, Symbol.toStringTag, { + value: 'Request', + writable: false, + enumerable: false, + configurable: true +}); - debug('caret return', ret) - return ret - }) -} +Object.defineProperties(Request.prototype, { + method: { enumerable: true }, + url: { enumerable: true }, + headers: { enumerable: true }, + redirect: { enumerable: true }, + clone: { enumerable: true }, + signal: { enumerable: true } +}); -function replaceXRanges (comp, options) { - debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map(function (comp) { - return replaceXRange(comp, options) - }).join(' ') -} +/** + * 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); -function replaceXRange (comp, options) { - comp = comp.trim() - var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] - return comp.replace(r, function (ret, gtlt, M, m, p, pr) { - debug('xRange', comp, ret, gtlt, M, m, p, pr) - var xM = isX(M) - var xm = xM || isX(m) - var xp = xm || isX(p) - var anyX = xp + // fetch step 1.3 + if (!headers.has('Accept')) { + headers.set('Accept', '*/*'); + } - if (gtlt === '=' && anyX) { - gtlt = '' - } + // Basic fetch + if (!parsedURL.protocol || !parsedURL.hostname) { + throw new TypeError('Only absolute URLs are supported'); + } - // if we're including prereleases in the match, then we need - // to fix this to -0, the lowest possible prerelease value - pr = options.includePrerelease ? '-0' : '' + if (!/^https?:$/.test(parsedURL.protocol)) { + throw new TypeError('Only HTTP(S) protocols are supported'); + } - if (xM) { - if (gtlt === '>' || gtlt === '<') { - // nothing is allowed - ret = '<0.0.0-0' - } else { - // nothing is forbidden - ret = '*' - } - } else if (gtlt && anyX) { - // we know patch is an x, because we have any x at all. - // replace X with 0 - if (xm) { - m = 0 - } - p = 0 + 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 (gtlt === '>') { - // >1 => >=2.0.0 - // >1.2 => >=1.3.0 - // >1.2.3 => >= 1.2.4 - gtlt = '>=' - if (xm) { - M = +M + 1 - m = 0 - p = 0 - } else { - m = +m + 1 - p = 0 - } - } else if (gtlt === '<=') { - // <=0.7.x is actually <0.8.0, since any 0.7.x should - // pass. Similarly, <=7.x is actually <8.0.0, etc. - gtlt = '<' - if (xm) { - M = +M + 1 - } else { - m = +m + 1 - } - } + // 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); + } + + // 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)'); + } + + // HTTP-network-or-cache fetch step 2.15 + if (request.compress && !headers.has('Accept-Encoding')) { + headers.set('Accept-Encoding', 'gzip,deflate'); + } + + let agent = request.agent; + if (typeof agent === 'function') { + agent = agent(parsedURL); + } - ret = gtlt + M + '.' + m + '.' + p + pr - } else if (xm) { - ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr - } else if (xp) { - ret = '>=' + M + '.' + m + '.0' + pr + - ' <' + M + '.' + (+m + 1) + '.0' + pr - } + if (!headers.has('Connection') && !agent) { + headers.set('Connection', 'close'); + } - debug('xRange return', ret) + // HTTP-network fetch step 4.2 + // chunked encoding is handled by Node.js - return ret - }) + return Object.assign({}, parsedURL, { + method: request.method, + headers: exportNodeCompatibleHeaders(headers), + agent + }); } -// Because * is AND-ed with everything else in the comparator, -// and '' means "any version", just remove the *s entirely. -function replaceStars (comp, options) { - debug('replaceStars', comp, options) - // Looseness is ignored here. star is always as loose as it gets! - return comp.trim().replace(re[t.STAR], '') -} +/** + * abort-error.js + * + * AbortError interface for cancelled requests + */ -// This function is passed to string.replace(re[t.HYPHENRANGE]) -// M, m, patch, prerelease, build -// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 -// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do -// 1.2 - 3.4 => >=1.2.0 <3.5.0 -function hyphenReplace ($0, - from, fM, fm, fp, fpr, fb, - to, tM, tm, tp, tpr, tb) { - if (isX(fM)) { - from = '' - } else if (isX(fm)) { - from = '>=' + fM + '.0.0' - } else if (isX(fp)) { - from = '>=' + fM + '.' + fm + '.0' - } else { - from = '>=' + from - } +/** + * Create AbortError instance + * + * @param String message Error message for human + * @return AbortError + */ +function AbortError(message) { + Error.call(this, message); - if (isX(tM)) { - to = '' - } else if (isX(tm)) { - to = '<' + (+tM + 1) + '.0.0' - } else if (isX(tp)) { - to = '<' + tM + '.' + (+tm + 1) + '.0' - } else if (tpr) { - to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr - } else { - to = '<=' + to - } + this.type = 'aborted'; + this.message = message; - return (from + ' ' + to).trim() + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); } -// if ANY of the sets match ALL of its comparators, then pass -Range.prototype.test = function (version) { - if (!version) { - return false - } +AbortError.prototype = Object.create(Error.prototype); +AbortError.prototype.constructor = AbortError; +AbortError.prototype.name = 'AbortError'; - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } +const URL$1 = Url.URL || whatwgUrl.URL; - for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true - } - } - return false -} +// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 +const PassThrough$1 = Stream.PassThrough; -function testSet (set, version, options) { - for (var i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false - } - } +const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) { + const orig = new URL$1(original).hostname; + const dest = new URL$1(destination).hostname; - if (version.prerelease.length && !options.includePrerelease) { - // Find the set of versions that are allowed to have prereleases - // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 - // That should allow `1.2.3-pr.2` to pass. - // However, `1.2.4-alpha.notready` should NOT be allowed, - // even though it's within the range set by the comparators. - for (i = 0; i < set.length; i++) { - debug(set[i].semver) - if (set[i].semver === ANY) { - continue - } + return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest); +}; - if (set[i].semver.prerelease.length > 0) { - var allowed = set[i].semver - if (allowed.major === version.major && - allowed.minor === version.minor && - allowed.patch === version.patch) { - return true - } - } - } +/** + * Fetch function + * + * @param Mixed url Absolute url or Request instance + * @param Object opts Fetch options + * @return Promise + */ +function fetch(url, opts) { - // Version has a -pre, but it's not one of the ones we like. - return false - } + // allow custom promise + if (!fetch.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } - return true -} + Body.Promise = fetch.Promise; -exports.satisfies = satisfies -function satisfies (version, range, options) { - try { - range = new Range(range, options) - } catch (er) { - return false - } - return range.test(version) -} + // 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); -exports.maxSatisfying = maxSatisfying -function maxSatisfying (versions, range, options) { - var max = null - var maxSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach(function (v) { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!max || maxSV.compare(v) === -1) { - // compare(max, v, true) - max = v - maxSV = new SemVer(max, options) - } - } - }) - return max -} + const send = (options.protocol === 'https:' ? https : http).request; + const signal = request.signal; -exports.minSatisfying = minSatisfying -function minSatisfying (versions, range, options) { - var min = null - var minSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach(function (v) { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!min || minSV.compare(v) === 1) { - // compare(min, v, true) - min = v - minSV = new SemVer(min, options) - } - } - }) - return min -} + let response = null; -exports.minVersion = minVersion -function minVersion (range, loose) { - range = new Range(range, loose) + 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); + }; - var minver = new SemVer('0.0.0') - if (range.test(minver)) { - return minver - } + if (signal && signal.aborted) { + abort(); + return; + } - minver = new SemVer('0.0.0-0') - if (range.test(minver)) { - return minver - } + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; + + // send request + const req = send(options); + let reqTimeout; + + if (signal) { + signal.addEventListener('abort', abortAndFinalize); + } + + 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); + }); + } - minver = null - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + finalize(); + }); - comparators.forEach(function (comparator) { - // Clone to avoid manipulating the comparator's semver object. - var compver = new SemVer(comparator.semver.version) - switch (comparator.operator) { - case '>': - if (compver.prerelease.length === 0) { - compver.patch++ - } else { - compver.prerelease.push(0) - } - compver.raw = compver.format() - /* fallthrough */ - case '': - case '>=': - if (!minver || gt(minver, compver)) { - minver = compver - } - break - case '<': - case '<=': - /* Ignore maximum versions */ - break - /* istanbul ignore next */ - default: - throw new Error('Unexpected operation: ' + comparator.operator) - } - }) - } + req.on('response', function (res) { + clearTimeout(reqTimeout); - if (minver && range.test(minver)) { - return minver - } + const headers = createHeadersLenient(res.headers); - return null -} + // HTTP fetch step 5 + if (fetch.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); -exports.validRange = validRange -function validRange (range, options) { - try { - // Return '*' instead of '' so that truthiness works. - // This will throw if it's invalid anyway - return new Range(range, options).range || '*' - } catch (er) { - return null - } -} + // 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; + } + } -// Determine if version is less than all the versions possible in the range -exports.ltr = ltr -function ltr (version, range, options) { - return outside(version, range, '<', options) -} + // 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; + } -// Determine if version is greater than all the versions possible in the range. -exports.gtr = gtr -function gtr (version, range, options) { - return outside(version, range, '>', options) -} + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } -exports.outside = outside -function outside (version, range, hilo, options) { - version = new SemVer(version, options) - range = new Range(range, options) + // 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 + }; - var gtfn, ltefn, ltfn, comp, ecomp - switch (hilo) { - case '>': - gtfn = gt - ltefn = lte - ltfn = lt - comp = '>' - ecomp = '>=' - break - case '<': - gtfn = lt - ltefn = gte - ltfn = gt - comp = '<' - ecomp = '<=' - break - default: - throw new TypeError('Must provide a hilo val of "<" or ">"') - } + if (!isDomainOrSubdomain(request.url, locationURL)) { + for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) { + requestOpts.headers.delete(name); + } + } - // If it satisifes the range it is not outside - if (satisfies(version, range, options)) { - return false - } + // 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; + } - // From now on, variable terms are as if we're in "gtr" mode. - // but note that everything is flipped for the "ltr" function. + // 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'); + } - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOpts))); + finalize(); + return; + } + } - var high = null - var low = null + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); - comparators.forEach(function (comparator) { - if (comparator.semver === ANY) { - comparator = new Comparator('>=0.0.0') - } - high = high || comparator - low = low || comparator - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator - } - }) + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter + }; - // If the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false - } + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); - // If the lowest version comparator has an operator and our version - // is less than it then it isn't higher than the range - if ((!low.operator || low.operator === comp) && - ltefn(version, low.semver)) { - return false - } else if (low.operator === ecomp && ltfn(version, low.semver)) { - return false - } - } - return true -} + // HTTP-network fetch step 12.1.1.4: handle content codings -exports.prerelease = prerelease -function prerelease (version, options) { - var parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} + // 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; + } -exports.intersects = intersects -function intersects (r1, r2, options) { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) -} + // 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 + }; -exports.coerce = coerce -function coerce (version, options) { - if (version instanceof SemVer) { - return version - } + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib.createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); + return; + } - if (typeof version === 'number') { - version = String(version) - } + // 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; + } - if (typeof version !== 'string') { - return null - } + // for br + if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') { + body = body.pipe(zlib.createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; + } - options = options || {} + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); + }); - var match = null - if (!options.rtl) { - match = version.match(re[t.COERCE]) - } else { - // Find the right-most coercible string that does not share - // a terminus with a more left-ward coercible string. - // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' - // - // Walk through the string checking with a /g regexp - // Manually set the index so as to pick up overlapping matches. - // Stop when we get a match that ends at the string end, since no - // coercible string can be more right-ward without the same terminus. - var next - while ((next = re[t.COERCERTL].exec(version)) && - (!match || match.index + match[0].length !== version.length) - ) { - if (!match || - next.index + next[0].length !== match.index + match[0].length) { - match = next - } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length - } - // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 - } + 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; +}; - if (match === null) { - return null - } +// expose Promise +fetch.Promise = global.Promise; - return parse(match[2] + - '.' + (match[3] || '0') + - '.' + (match[4] || '0'), options) -} +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; /***/ }), -/***/ 7032: +/***/ 2299: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var shebangRegex = __nccwpck_require__(2638); - -module.exports = function (str) { - var match = str.match(shebangRegex); - - if (!match) { - return null; - } - var arr = match[0].replace(/#! ?/, '').split(' '); - var bin = arr[0].split('/').pop(); - var arg = arr[1]; +var punycode = __nccwpck_require__(5477); +var mappingTable = __nccwpck_require__(1907); - return (bin === 'env' ? - arg : - bin + (arg ? ' ' + arg : '') - ); +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; -/***/ 2638: -/***/ ((module) => { + while (start <= end) { + var mid = Math.floor((start + end) / 2); -"use strict"; + 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; + } + } -module.exports = /^#!.*/; + 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; +} -/***/ 4931: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +function mapChars(domain_name, useSTD3, processing_option) { + var hasError = false; + var processed = ""; -// Note: since nyc uses this module to output coverage, any lines -// that are in the direct sync flow of nyc's outputCoverage are -// ignored, since we can never get coverage for them. -var assert = __nccwpck_require__(9491) -var signals = __nccwpck_require__(3710) + var len = countSymbols(domain_name); + for (var i = 0; i < len; ++i) { + var codePoint = domain_name.codePointAt(i); + var status = findStatus(codePoint); -var EE = __nccwpck_require__(2361) -/* istanbul ignore if */ -if (typeof EE !== 'function') { - EE = EE.EventEmitter -} + 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; + } -var emitter -if (process.__signal_exit_emitter__) { - emitter = process.__signal_exit_emitter__ -} else { - emitter = process.__signal_exit_emitter__ = new EE() - emitter.count = 0 - emitter.emitted = {} -} + processed += String.fromCodePoint(codePoint); + break; + } + } -// Because this emitter is a global, we have to check to see if a -// previous version of this library failed to enable infinite listeners. -// I know what you're about to say. But literally everything about -// signal-exit is a compromise with evil. Get used to it. -if (!emitter.infinite) { - emitter.setMaxListeners(Infinity) - emitter.infinite = true + return { + string: processed, + error: hasError + }; } -module.exports = function (cb, opts) { - assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler') +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]/; - if (loaded === false) { - load() +function validateLabel(label, processing_option) { + if (label.substr(0, 4) === "xn--") { + label = punycode.toUnicode(label); + processing_option = PROCESSING_OPTIONS.NONTRANSITIONAL; } - var ev = 'exit' - if (opts && opts.alwaysLast) { - ev = 'afterexit' + 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; } - var remove = function () { - emitter.removeListener(ev, cb) - if (emitter.listeners('exit').length === 0 && - emitter.listeners('afterexit').length === 0) { - unload() + 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; } } - emitter.on(ev, cb) - return remove + return { + label: label, + error: error + }; } -module.exports.unload = unload -function unload () { - if (!loaded) { - return - } - loaded = false +function processing(domain_name, useSTD3, processing_option) { + var result = mapChars(domain_name, useSTD3, processing_option); + result.string = normalize(result.string); - signals.forEach(function (sig) { + var labels = result.string.split("."); + for (var i = 0; i < labels.length; ++i) { try { - process.removeListener(sig, sigListeners[sig]) - } catch (er) {} - }) - process.emit = originalProcessEmit - process.reallyExit = originalProcessReallyExit - emitter.count -= 1 -} - -function emit (event, code, signal) { - if (emitter.emitted[event]) { - return + var validation = validateLabel(labels[i]); + labels[i] = validation.label; + result.error = result.error || validation.error; + } catch(e) { + result.error = true; + } } - emitter.emitted[event] = true - emitter.emit(event, code, signal) + + return { + string: labels.join("."), + error: result.error + }; } -// { : , ... } -var sigListeners = {} -signals.forEach(function (sig) { - sigListeners[sig] = function listener () { - // If there are no other listeners, an exit is coming! - // Simplest way: remove us and then re-send the signal. - // We know that this will kill the process, so we can - // safely emit now. - var listeners = process.listeners(sig) - if (listeners.length === emitter.count) { - unload() - emit('exit', null, sig) - /* istanbul ignore next */ - emit('afterexit', null, sig) - /* istanbul ignore next */ - process.kill(process.pid, sig) +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; + } } } -}) -module.exports.signals = function () { - return signals -} + if (result.error) return null; + return labels.join("."); +}; -module.exports.load = load +module.exports.toUnicode = function(domain_name, useSTD3) { + var result = processing(domain_name, useSTD3, PROCESSING_OPTIONS.NONTRANSITIONAL); -var loaded = false + return { + domain: result.string, + error: result.error + }; +}; -function load () { - if (loaded) { - return - } - loaded = true +module.exports.PROCESSING_OPTIONS = PROCESSING_OPTIONS; - // This is the number of onSignalExit's that are in play. - // It's important so that we can count the correct number of - // listeners on signals, and don't wait for the other one to - // handle it instead of us. - emitter.count += 1 - signals = signals.filter(function (sig) { - try { - process.on(sig, sigListeners[sig]) - return true - } catch (er) { - return false - } - }) +/***/ }), - process.emit = processEmit - process.reallyExit = processReallyExit -} +/***/ 5871: +/***/ ((module) => { -var originalProcessReallyExit = process.reallyExit -function processReallyExit (code) { - process.exitCode = code || 0 - emit('exit', process.exitCode, null) - /* istanbul ignore next */ - emit('afterexit', process.exitCode, null) - /* istanbul ignore next */ - originalProcessReallyExit.call(process, process.exitCode) +"use strict"; + + +var conversions = {}; +module.exports = conversions; + +function sign(x) { + return x < 0 ? -1 : 1; } -var originalProcessEmit = process.emit -function processEmit (ev, arg) { - if (ev === 'exit') { - if (arg !== undefined) { - process.exitCode = arg +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); } - var ret = originalProcessEmit.apply(this, arguments) - emit('exit', process.exitCode, null) - /* istanbul ignore next */ - emit('afterexit', process.exitCode, null) - return ret - } else { - return originalProcessEmit.apply(this, arguments) - } } +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); -/***/ 3710: -/***/ ((module) => { + return function(V, opts) { + if (!opts) opts = {}; -// This is not the set of all possible signals. -// -// It IS, however, the set of all signals that trigger -// an exit on either Linux or BSD systems. Linux is a -// superset of the signal names supported on BSD, and -// the unknown signals just fail to register, so we can -// catch that easily enough. -// -// Don't bother with SIGKILL. It's uncatchable, which -// means that we can't fire any callbacks anyway. -// -// If a user does happen to register a handler on a non- -// fatal signal like SIGWINCH or something, and then -// exit, it'll end up firing `process.emit('exit')`, so -// the handler will be fired anyway. -// -// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised -// artificially, inherently leave the process in a -// state from which it is not safe to try and enter JS -// listeners. -module.exports = [ - 'SIGABRT', - 'SIGALRM', - 'SIGHUP', - 'SIGINT', - 'SIGTERM' -] + let x = +V; -if (process.platform !== 'win32') { - module.exports.push( - 'SIGVTALRM', - 'SIGXCPU', - 'SIGXFSZ', - 'SIGUSR2', - 'SIGTRAP', - 'SIGSYS', - 'SIGQUIT', - 'SIGIOT' - // should detect profiler and enable/disable accordingly. - // see #21 - // 'SIGPROF' - ) -} + 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; + } + } -if (process.platform === 'linux') { - module.exports.push( - 'SIGIO', - 'SIGPOLL', - 'SIGPWR', - 'SIGSTKFLT', - 'SIGUNUSED' - ) + return x; + } } +conversions["void"] = function () { + return undefined; +}; -/***/ }), - -/***/ 5515: -/***/ ((module) => { +conversions["boolean"] = function (val) { + return !!val; +}; -"use strict"; +conversions["byte"] = createNumberConversion(8, { unsigned: false }); +conversions["octet"] = createNumberConversion(8, { unsigned: true }); -module.exports = function (x) { - var lf = typeof x === 'string' ? '\n' : '\n'.charCodeAt(); - var cr = typeof x === 'string' ? '\r' : '\r'.charCodeAt(); +conversions["short"] = createNumberConversion(16, { unsigned: false }); +conversions["unsigned short"] = createNumberConversion(16, { unsigned: true }); - if (x[x.length - 1] === lf) { - x = x.slice(0, x.length - 1); - } +conversions["long"] = createNumberConversion(32, { unsigned: false }); +conversions["unsigned long"] = createNumberConversion(32, { unsigned: true }); - if (x[x.length - 1] === cr) { - x = x.slice(0, x.length - 1); - } +conversions["long long"] = createNumberConversion(32, { unsigned: false, moduloBitLength: 64 }); +conversions["unsigned long long"] = createNumberConversion(32, { unsigned: true, moduloBitLength: 64 }); - return x; -}; +conversions["double"] = function (V) { + const x = +V; + if (!Number.isFinite(x)) { + throw new TypeError("Argument is not a finite floating-point value"); + } -/***/ }), + return x; +}; -/***/ 4294: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +conversions["unrestricted double"] = function (V) { + const x = +V; -module.exports = __nccwpck_require__(4219); + 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"]; -/***/ 4219: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +conversions["DOMString"] = function (V, opts) { + if (!opts) opts = {}; -"use strict"; + if (opts.treatNullAsEmptyString && V === null) { + return ""; + } + return String(V); +}; -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); +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; +}; -exports.httpOverHttp = httpOverHttp; -exports.httpsOverHttp = httpsOverHttp; -exports.httpOverHttps = httpOverHttps; -exports.httpsOverHttps = httpsOverHttps; +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(''); +}; -function httpOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - return agent; -} +conversions["Date"] = function (V, opts) { + if (!(V instanceof Date)) { + throw new TypeError("Argument is not a Date object"); + } + if (isNaN(V)) { + return undefined; + } -function httpsOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} + return V; +}; -function httpOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - return agent; -} +conversions["RegExp"] = function (V, opts) { + if (!(V instanceof RegExp)) { + V = new RegExp(V); + } -function httpsOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} + return V; +}; -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); +/***/ 8262: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { - var self = this; - var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); +"use strict"; - if (self.sockets.length >= this.maxSockets) { - // We are over limit so we'll add it to the queue. - self.requests.push(options); - return; - } +const usm = __nccwpck_require__(33); - // 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); +exports.implementation = class URLImpl { + constructor(constructorArgs) { + const url = constructorArgs[0]; + const base = constructorArgs[1]; - function onFree() { - self.emit('free', socket, options); + let parsedBase = null; + if (base !== undefined) { + parsedBase = usm.basicURLParse(base); + if (parsedBase === "failure") { + throw new TypeError("Invalid base URL"); + } } - function onCloseOrRemove(err) { - self.removeSocket(socket); - socket.removeListener('free', onFree); - socket.removeListener('close', onCloseOrRemove); - socket.removeListener('agentRemove', onCloseOrRemove); + const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase }); + if (parsedURL === "failure") { + throw new TypeError("Invalid URL"); } - }); -}; -TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { - var self = this; - var placeholder = {}; - self.sockets.push(placeholder); + this._url = parsedURL; - 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; + // TODO: query stuff } - if (connectOptions.proxyAuth) { - connectOptions.headers = connectOptions.headers || {}; - connectOptions.headers['Proxy-Authorization'] = 'Basic ' + - new Buffer(connectOptions.proxyAuth).toString('base64'); + + 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; } - 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(); + get origin() { + return usm.serializeURLOrigin(this._url); + } - function onResponse(res) { - // Very hacky. This is necessary to avoid http-parser leaks. - res.upgrade = true; + get protocol() { + return this._url.scheme + ":"; } - function onUpgrade(res, socket, head) { - // Hacky. - process.nextTick(function() { - onConnect(res, socket, head); - }); + set protocol(v) { + usm.basicURLParse(v + ":", { url: this._url, stateOverride: "scheme start" }); } - function onConnect(res, socket, head) { - connectReq.removeAllListeners(); - socket.removeAllListeners(); + get username() { + return this._url.username; + } - 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); + set username(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { 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); + + usm.setTheUsername(this._url, v); + } + + get password() { + return this._url.password; + } + + set password(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { return; } - debug('tunneling connection has established'); - self.sockets[self.sockets.indexOf(placeholder)] = socket; - return cb(socket); + + usm.setThePassword(this._url, v); } - function onError(cause) { - connectReq.removeAllListeners(); + get host() { + const url = this._url; - 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); - } -}; + if (url.host === null) { + return ""; + } -TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { - var pos = this.sockets.indexOf(socket) - if (pos === -1) { - return; + if (url.port === null) { + return usm.serializeHost(url.host); + } + + return usm.serializeHost(url.host) + ":" + usm.serializeInteger(url.port); } - 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); - }); + set host(v) { + if (this._url.cannotBeABaseURL) { + return; + } + + usm.basicURLParse(v, { url: this._url, stateOverride: "host" }); } -}; -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 - }); + get hostname() { + if (this._url.host === null) { + return ""; + } - // 0 is dummy port for v0.6 - var secureSocket = tls.connect(0, tlsOptions); - self.sockets[self.sockets.indexOf(socket)] = secureSocket; - cb(secureSocket); - }); -} + return usm.serializeHost(this._url.host); + } + set hostname(v) { + if (this._url.cannotBeABaseURL) { + return; + } -function toOptions(host, port, localAddress) { - if (typeof host === 'string') { // since v0.10 - return { - host: host, - port: port, - localAddress: localAddress - }; + usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" }); } - 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]; - } - } + get port() { + if (this._url.port === null) { + return ""; } + + return usm.serializeInteger(this._url.port); } - return target; -} + set port(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } -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]; + if (v === "") { + this._url.port = null; } else { - args.unshift('TUNNEL:'); + usm.basicURLParse(v, { url: this._url, stateOverride: "port" }); } - console.error.apply(console, args); } -} else { - debug = function() {}; -} -exports.debug = debug; // for test + get pathname() { + if (this._url.cannotBeABaseURL) { + return this._url.path[0]; + } -/***/ }), + if (this._url.path.length === 0) { + return ""; + } -/***/ 2280: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + return "/" + this._url.path.join("/"); + } -module.exports = getUserAgentNode + set pathname(v) { + if (this._url.cannotBeABaseURL) { + return; + } -const osName = __nccwpck_require__(4824) + this._url.path = []; + usm.basicURLParse(v, { url: this._url, stateOverride: "path start" }); + } -function getUserAgentNode () { - try { - return `Node.js/${process.version.substr(1)} (${osName()}; ${process.arch})` - } catch (error) { - if (/wmic os get Caption/.test(error.message)) { - return 'Windows ' + get search() { + if (this._url.query === null || this._url.query === "") { + return ""; } - throw error + 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; + } +}; /***/ }), -/***/ 5840: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 653: +/***/ ((module, __unused_webpack_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; +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."); } -})); -Object.defineProperty(exports, "v4", ({ - enumerable: true, - get: function () { - return _v3.default; + if (arguments.length < 1) { + throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present."); } -})); -Object.defineProperty(exports, "v5", ({ - enumerable: true, - get: function () { - return _v4.default; + const args = []; + for (let i = 0; i < arguments.length && i < 2; ++i) { + args[i] = arguments[i]; } -})); -Object.defineProperty(exports, "NIL", ({ - enumerable: true, - get: function () { - return _nil.default; + args[0] = conversions["USVString"](args[0]); + if (args[1] !== undefined) { + args[1] = conversions["USVString"](args[1]); } -})); -Object.defineProperty(exports, "version", ({ - enumerable: true, - get: function () { - return _version.default; + + module.exports.setup(this, args); +} + +URL.prototype.toJSON = function toJSON() { + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); } -})); -Object.defineProperty(exports, "validate", ({ - enumerable: true, - get: function () { - return _validate.default; + const args = []; + for (let i = 0; i < arguments.length && i < 0; ++i) { + args[i] = arguments[i]; } -})); -Object.defineProperty(exports, "stringify", ({ + 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, - get: function () { - return _stringify.default; + configurable: true +}); + +URL.prototype.toString = function () { + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); } -})); -Object.defineProperty(exports, "parse", ({ + return this.href; +}; + +Object.defineProperty(URL.prototype, "origin", { + get() { + return this[impl].origin; + }, enumerable: true, - get: function () { - return _parse.default; - } -})); + configurable: true +}); -var _v = _interopRequireDefault(__nccwpck_require__(8628)); +Object.defineProperty(URL.prototype, "protocol", { + get() { + return this[impl].protocol; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].protocol = V; + }, + enumerable: true, + configurable: true +}); -var _v2 = _interopRequireDefault(__nccwpck_require__(6409)); +Object.defineProperty(URL.prototype, "username", { + get() { + return this[impl].username; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].username = V; + }, + enumerable: true, + configurable: true +}); -var _v3 = _interopRequireDefault(__nccwpck_require__(5122)); +Object.defineProperty(URL.prototype, "password", { + get() { + return this[impl].password; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].password = V; + }, + enumerable: true, + configurable: true +}); -var _v4 = _interopRequireDefault(__nccwpck_require__(9120)); +Object.defineProperty(URL.prototype, "host", { + get() { + return this[impl].host; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].host = V; + }, + enumerable: true, + configurable: true +}); -var _nil = _interopRequireDefault(__nccwpck_require__(5332)); +Object.defineProperty(URL.prototype, "hostname", { + get() { + return this[impl].hostname; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].hostname = V; + }, + enumerable: true, + configurable: true +}); -var _version = _interopRequireDefault(__nccwpck_require__(1595)); +Object.defineProperty(URL.prototype, "port", { + get() { + return this[impl].port; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].port = V; + }, + enumerable: true, + configurable: true +}); -var _validate = _interopRequireDefault(__nccwpck_require__(6900)); +Object.defineProperty(URL.prototype, "pathname", { + get() { + return this[impl].pathname; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].pathname = V; + }, + enumerable: true, + configurable: true +}); -var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); +Object.defineProperty(URL.prototype, "search", { + get() { + return this[impl].search; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].search = V; + }, + enumerable: true, + configurable: true +}); -var _parse = _interopRequireDefault(__nccwpck_require__(2746)); +Object.defineProperty(URL.prototype, "hash", { + get() { + return this[impl].hash; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].hash = V; + }, + enumerable: true, + configurable: true +}); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -/***/ }), +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; -/***/ 4569: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + obj[impl] = new Impl.implementation(constructorArgs, privateData); + obj[impl][utils.wrapperSymbol] = obj; + }, + interface: URL, + expose: { + Window: { URL: URL }, + Worker: { URL: URL } + } +}; -"use strict"; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; +/***/ }), -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); +/***/ 3323: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +"use strict"; -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(); -} +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 _default = md5; -exports["default"] = _default; /***/ }), -/***/ 5332: -/***/ ((__unused_webpack_module, exports) => { +/***/ 33: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; +const punycode = __nccwpck_require__(5477); +const tr46 = __nccwpck_require__(2299); + +const specialSchemes = { + ftp: 21, + file: null, + gopher: 70, + http: 80, + https: 443, + ws: 80, + wss: 443 +}; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _default = '00000000-0000-0000-0000-000000000000'; -exports["default"] = _default; +const failure = Symbol("failure"); -/***/ }), +function countSymbols(str) { + return punycode.ucs2.decode(str).length; +} -/***/ 2746: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +function at(input, idx) { + const c = input[idx]; + return isNaN(c) ? undefined : String.fromCodePoint(c); +} -"use strict"; +function isASCIIDigit(c) { + return c >= 0x30 && c <= 0x39; +} +function isASCIIAlpha(c) { + return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); +} -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; +function isASCIIAlphanumeric(c) { + return isASCIIAlpha(c) || isASCIIDigit(c); +} -var _validate = _interopRequireDefault(__nccwpck_require__(6900)); +function isASCIIHex(c) { + return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66); +} -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function isSingleDot(buffer) { + return buffer === "." || buffer.toLowerCase() === "%2e"; +} -function parse(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); - } +function isDoubleDot(buffer) { + buffer = buffer.toLowerCase(); + return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e"; +} - let v; - const arr = new Uint8Array(16); // Parse ########-....-....-....-............ +function isWindowsDriveLetterCodePoints(cp1, cp2) { + return isASCIIAlpha(cp1) && (cp2 === 58 || cp2 === 124); +} - 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 ........-####-....-....-............ +function isWindowsDriveLetterString(string) { + return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|"); +} - arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; - arr[5] = v & 0xff; // Parse ........-....-####-....-............ +function isNormalizedWindowsDriveLetterString(string) { + return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && string[1] === ":"; +} - arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; - arr[7] = v & 0xff; // Parse ........-....-....-####-............ +function containsForbiddenHostCodePoint(string) { + return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/) !== -1; +} - 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) +function containsForbiddenHostCodePointExcludingPercent(string) { + return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/) !== -1; +} - 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; +function isSpecialScheme(scheme) { + return specialSchemes[scheme] !== undefined; } -var _default = parse; -exports["default"] = _default; +function isSpecial(url) { + return isSpecialScheme(url.scheme); +} -/***/ }), +function defaultPort(scheme) { + return specialSchemes[scheme]; +} -/***/ 814: -/***/ ((__unused_webpack_module, exports) => { +function percentEncode(c) { + let hex = c.toString(16).toUpperCase(); + if (hex.length === 1) { + hex = "0" + hex; + } -"use strict"; + return "%" + hex; +} +function utf8PercentEncode(c) { + const buf = new Buffer(c); -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; + let str = ""; -/***/ }), + for (let i = 0; i < buf.length; ++i) { + str += percentEncode(buf[i]); + } -/***/ 807: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + return str; +} -"use strict"; +function utf8PercentDecode(str) { + const input = new Buffer(str); + const output = []; + for (let i = 0; i < input.length; ++i) { + if (input[i] !== 37) { + output.push(input[i]); + } else if (input[i] === 37 && isASCIIHex(input[i + 1]) && isASCIIHex(input[i + 2])) { + output.push(parseInt(input.slice(i + 1, i + 3).toString(), 16)); + i += 2; + } else { + output.push(input[i]); + } + } + return new Buffer(output).toString(); +} +function isC0ControlPercentEncode(c) { + return c <= 0x1F || c > 0x7E; +} -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = rng; +const extraPathPercentEncodeSet = new Set([32, 34, 35, 60, 62, 63, 96, 123, 125]); +function isPathPercentEncode(c) { + return isC0ControlPercentEncode(c) || extraPathPercentEncodeSet.has(c); +} -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); +const extraUserinfoPercentEncodeSet = + new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]); +function isUserinfoPercentEncode(c) { + return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c); +} -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function percentEncodeChar(c, encodeSetPredicate) { + const cStr = String.fromCodePoint(c); -const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate + if (encodeSetPredicate(c)) { + return utf8PercentEncode(cStr); + } -let poolPtr = rnds8Pool.length; + return cStr; +} -function rng() { - if (poolPtr > rnds8Pool.length - 16) { - _crypto.default.randomFillSync(rnds8Pool); +function parseIPv4Number(input) { + let R = 10; - poolPtr = 0; + if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") { + input = input.substring(2); + R = 16; + } else if (input.length >= 2 && input.charAt(0) === "0") { + input = input.substring(1); + R = 8; } - return rnds8Pool.slice(poolPtr, poolPtr += 16); + if (input === "") { + return 0; + } + + const regex = R === 10 ? /[^0-9]/ : (R === 16 ? /[^0-9A-Fa-f]/ : /[^0-7]/); + if (regex.test(input)) { + return failure; + } + + return parseInt(input, R); } -/***/ }), +function parseIPv4(input) { + const parts = input.split("."); + if (parts[parts.length - 1] === "") { + if (parts.length > 1) { + parts.pop(); + } + } -/***/ 5274: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + if (parts.length > 4) { + return input; + } -"use strict"; + const numbers = []; + for (const part of parts) { + if (part === "") { + return input; + } + const n = parseIPv4Number(part); + if (n === failure) { + return input; + } + numbers.push(n); + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; + for (let i = 0; i < numbers.length - 1; ++i) { + if (numbers[i] > 255) { + return failure; + } + } + if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) { + return failure; + } -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + let ipv4 = numbers.pop(); + let counter = 0; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + for (const n of numbers) { + ipv4 += n * Math.pow(256, 3 - counter); + ++counter; + } -function sha1(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === 'string') { - bytes = Buffer.from(bytes, 'utf8'); + return ipv4; +} + +function serializeIPv4(address) { + let output = ""; + let n = address; + + for (let i = 1; i <= 4; ++i) { + output = String(n % 256) + output; + if (i !== 4) { + output = "." + output; + } + n = Math.floor(n / 256); } - return _crypto.default.createHash('sha1').update(bytes).digest(); + return output; } -var _default = sha1; -exports["default"] = _default; +function parseIPv6(input) { + const address = [0, 0, 0, 0, 0, 0, 0, 0]; + let pieceIndex = 0; + let compress = null; + let pointer = 0; -/***/ }), + input = punycode.ucs2.decode(input); -/***/ 8950: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + if (input[pointer] === 58) { + if (input[pointer + 1] !== 58) { + return failure; + } -"use strict"; + pointer += 2; + ++pieceIndex; + compress = pieceIndex; + } + while (pointer < input.length) { + if (pieceIndex === 8) { + return failure; + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; + if (input[pointer] === 58) { + if (compress !== null) { + return failure; + } + ++pointer; + ++pieceIndex; + compress = pieceIndex; + continue; + } -var _validate = _interopRequireDefault(__nccwpck_require__(6900)); + let value = 0; + let length = 0; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + while (length < 4 && isASCIIHex(input[pointer])) { + value = value * 0x10 + parseInt(at(input, pointer), 16); + ++pointer; + ++length; + } -/** - * Convert array of 16 byte values to UUID string format of the form: - * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX - */ -const byteToHex = []; + if (input[pointer] === 46) { + if (length === 0) { + return failure; + } -for (let i = 0; i < 256; ++i) { - byteToHex.push((i + 0x100).toString(16).substr(1)); -} + pointer -= length; -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 (pieceIndex > 6) { + return failure; + } - if (!(0, _validate.default)(uuid)) { - throw TypeError('Stringified UUID is invalid'); - } + let numbersSeen = 0; - return uuid; -} + while (input[pointer] !== undefined) { + let ipv4Piece = null; -var _default = stringify; -exports["default"] = _default; + if (numbersSeen > 0) { + if (input[pointer] === 46 && numbersSeen < 4) { + ++pointer; + } else { + return failure; + } + } -/***/ }), + if (!isASCIIDigit(input[pointer])) { + return failure; + } -/***/ 8628: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + while (isASCIIDigit(input[pointer])) { + const number = parseInt(at(input, pointer)); + if (ipv4Piece === null) { + ipv4Piece = number; + } else if (ipv4Piece === 0) { + return failure; + } else { + ipv4Piece = ipv4Piece * 10 + number; + } + if (ipv4Piece > 255) { + return failure; + } + ++pointer; + } -"use strict"; + address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece; + ++numbersSeen; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; + if (numbersSeen === 2 || numbersSeen === 4) { + ++pieceIndex; + } + } -var _rng = _interopRequireDefault(__nccwpck_require__(807)); + if (numbersSeen !== 4) { + return failure; + } -var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); + break; + } else if (input[pointer] === 58) { + ++pointer; + if (input[pointer] === undefined) { + return failure; + } + } else if (input[pointer] !== undefined) { + return failure; + } -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + address[pieceIndex] = value; + ++pieceIndex; + } -// **`v1()` - Generate time-based UUID** -// -// Inspired by https://github.com/LiosK/UUID.js -// and http://docs.python.org/library/uuid.html -let _nodeId; + if (compress !== null) { + let swaps = pieceIndex - compress; + pieceIndex = 7; + while (pieceIndex !== 0 && swaps > 0) { + const temp = address[compress + swaps - 1]; + address[compress + swaps - 1] = address[pieceIndex]; + address[pieceIndex] = temp; + --pieceIndex; + --swaps; + } + } else if (compress === null && pieceIndex !== 8) { + return failure; + } -let _clockseq; // Previous uuid creation time + return address; +} +function serializeIPv6(address) { + let output = ""; + const seqResult = findLongestZeroSequence(address); + const compress = seqResult.idx; + let ignore0 = false; -let _lastMSecs = 0; -let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details + for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) { + if (ignore0 && address[pieceIndex] === 0) { + continue; + } else if (ignore0) { + ignore0 = false; + } -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 (compress === pieceIndex) { + const separator = pieceIndex === 0 ? "::" : ":"; + output += separator; + ignore0 = true; + continue; + } - if (node == null || clockseq == null) { - const seedBytes = options.random || (options.rng || _rng.default)(); + output += address[pieceIndex].toString(16); - 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 (pieceIndex !== 7) { + output += ":"; } + } - if (clockseq == null) { - // Per 4.2.2, randomize (14 bit) clockseq - clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; + return output; +} + +function parseHost(input, isSpecialArg) { + if (input[0] === "[") { + if (input[input.length - 1] !== "]") { + return failure; } - } // 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. + return parseIPv6(input.substring(1, input.length - 1)); + } + + if (!isSpecialArg) { + return parseOpaqueHost(input); + } + + const domain = utf8PercentDecode(input); + const asciiDomain = tr46.toASCII(domain, false, tr46.PROCESSING_OPTIONS.NONTRANSITIONAL, false); + if (asciiDomain === null) { + return failure; + } + + if (containsForbiddenHostCodePoint(asciiDomain)) { + return failure; + } + + const ipv4Host = parseIPv4(asciiDomain); + if (typeof ipv4Host === "number" || ipv4Host === failure) { + return ipv4Host; + } + + return asciiDomain; +} - 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 +function parseOpaqueHost(input) { + if (containsForbiddenHostCodePointExcludingPercent(input)) { + return failure; + } - let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) + let output = ""; + const decoded = punycode.ucs2.decode(input); + for (let i = 0; i < decoded.length; ++i) { + output += percentEncodeChar(decoded[i], isC0ControlPercentEncode); + } + return output; +} - const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression +function findLongestZeroSequence(arr) { + let maxIdx = null; + let maxLen = 1; // only find elements > 1 + let currStart = null; + let currLen = 0; - 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 + for (let i = 0; i < arr.length; ++i) { + if (arr[i] !== 0) { + if (currLen > maxLen) { + maxIdx = currStart; + maxLen = currLen; + } + currStart = null; + currLen = 0; + } else { + if (currStart === null) { + currStart = i; + } + ++currLen; + } + } - if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { - nsecs = 0; - } // Per 4.2.1.2 Throw error if too many uuids are requested + // if trailing zeros + if (currLen > maxLen) { + maxIdx = currStart; + maxLen = currLen; + } + return { + idx: maxIdx, + len: maxLen + }; +} - if (nsecs >= 10000) { - throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); +function serializeHost(host) { + if (typeof host === "number") { + return serializeIPv4(host); } - _lastMSecs = msecs; - _lastNSecs = nsecs; - _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch - - msecs += 12219292800000; // `time_low` + // IPv6 serializer + if (host instanceof Array) { + return "[" + serializeIPv6(host) + "]"; + } - 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` + return host; +} - const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; - b[i++] = tmh >>> 8 & 0xff; - b[i++] = tmh & 0xff; // `time_high_and_version` +function trimControlChars(url) { + return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, ""); +} - b[i++] = tmh >>> 24 & 0xf | 0x10; // include version +function trimTabAndNewline(url) { + return url.replace(/\u0009|\u000A|\u000D/g, ""); +} - b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) +function shortenPath(url) { + const path = url.path; + if (path.length === 0) { + return; + } + if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) { + return; + } - b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` + path.pop(); +} - b[i++] = clockseq & 0xff; // `node` +function includesCredentials(url) { + return url.username !== "" || url.password !== ""; +} - for (let n = 0; n < 6; ++n) { - b[i + n] = node[n]; - } +function cannotHaveAUsernamePasswordPort(url) { + return url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file"; +} - return buf || (0, _stringify.default)(b); +function isNormalizedWindowsDriveLetter(string) { + return /^[A-Za-z]:$/.test(string); } -var _default = v1; -exports["default"] = _default; +function URLStateMachine(input, base, encodingOverride, url, stateOverride) { + this.pointer = 0; + this.input = input; + this.base = base || null; + this.encodingOverride = encodingOverride || "utf-8"; + this.stateOverride = stateOverride; + this.url = url; + this.failure = false; + this.parseError = false; -/***/ }), + if (!this.url) { + this.url = { + scheme: "", + username: "", + password: "", + host: null, + port: null, + path: [], + query: null, + fragment: null, -/***/ 6409: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + cannotBeABaseURL: false + }; -"use strict"; + const res = trimControlChars(this.input); + if (res !== this.input) { + this.parseError = true; + } + this.input = res; + } + const res = trimTabAndNewline(this.input); + if (res !== this.input) { + this.parseError = true; + } + this.input = res; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; + this.state = stateOverride || "scheme start"; -var _v = _interopRequireDefault(__nccwpck_require__(5998)); + this.buffer = ""; + this.atFlag = false; + this.arrFlag = false; + this.passwordTokenSeenFlag = false; -var _md = _interopRequireDefault(__nccwpck_require__(4569)); + this.input = punycode.ucs2.decode(this.input); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + for (; this.pointer <= this.input.length; ++this.pointer) { + const c = this.input[this.pointer]; + const cStr = isNaN(c) ? undefined : String.fromCodePoint(c); -const v3 = (0, _v.default)('v3', 0x30, _md.default); -var _default = v3; -exports["default"] = _default; + // exec state machine + const ret = this["parse " + this.state](c, cStr); + if (!ret) { + break; // terminate algorithm + } else if (ret === failure) { + this.failure = true; + break; + } + } +} -/***/ }), +URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) { + if (isASCIIAlpha(c)) { + this.buffer += cStr.toLowerCase(); + this.state = "scheme"; + } else if (!this.stateOverride) { + this.state = "no scheme"; + --this.pointer; + } else { + this.parseError = true; + return failure; + } -/***/ 5998: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + return true; +}; -"use strict"; +URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) { + if (isASCIIAlphanumeric(c) || c === 43 || c === 45 || c === 46) { + this.buffer += cStr.toLowerCase(); + } else if (c === 58) { + if (this.stateOverride) { + if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) { + return false; + } + if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) { + return false; + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = _default; -exports.URL = exports.DNS = void 0; + if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") { + return false; + } -var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); + if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) { + return false; + } + } + this.url.scheme = this.buffer; + this.buffer = ""; + if (this.stateOverride) { + return false; + } + if (this.url.scheme === "file") { + if (this.input[this.pointer + 1] !== 47 || this.input[this.pointer + 2] !== 47) { + this.parseError = true; + } + this.state = "file"; + } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) { + this.state = "special relative or authority"; + } else if (isSpecial(this.url)) { + this.state = "special authority slashes"; + } else if (this.input[this.pointer + 1] === 47) { + this.state = "path or authority"; + ++this.pointer; + } else { + this.url.cannotBeABaseURL = true; + this.url.path.push(""); + this.state = "cannot-be-a-base-URL path"; + } + } else if (!this.stateOverride) { + this.buffer = ""; + this.state = "no scheme"; + this.pointer = -1; + } else { + this.parseError = true; + return failure; + } -var _parse = _interopRequireDefault(__nccwpck_require__(2746)); + return true; +}; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) { + if (this.base === null || (this.base.cannotBeABaseURL && c !== 35)) { + return failure; + } else if (this.base.cannotBeABaseURL && c === 35) { + this.url.scheme = this.base.scheme; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.url.cannotBeABaseURL = true; + this.state = "fragment"; + } else if (this.base.scheme === "file") { + this.state = "file"; + --this.pointer; + } else { + this.state = "relative"; + --this.pointer; + } -function stringToBytes(str) { - str = unescape(encodeURIComponent(str)); // UTF8 escape + return true; +}; - const bytes = []; +URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) { + if (c === 47 && this.input[this.pointer + 1] === 47) { + this.state = "special authority ignore slashes"; + ++this.pointer; + } else { + this.parseError = true; + this.state = "relative"; + --this.pointer; + } - for (let i = 0; i < str.length; ++i) { - bytes.push(str.charCodeAt(i)); + return true; +}; + +URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) { + if (c === 47) { + this.state = "authority"; + } else { + this.state = "path"; + --this.pointer; } - return bytes; -} + return true; +}; -const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; -exports.DNS = DNS; -const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; -exports.URL = URL; +URLStateMachine.prototype["parse relative"] = function parseRelative(c) { + this.url.scheme = this.base.scheme; + if (isNaN(c)) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + } else if (c === 47) { + this.state = "relative slash"; + } else if (c === 63) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.state = "fragment"; + } else if (isSpecial(this.url) && c === 92) { + this.parseError = true; + this.state = "relative slash"; + } else { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(0, this.base.path.length - 1); -function _default(name, version, hashfunc) { - function generateUUID(value, namespace, buf, offset) { - if (typeof value === 'string') { - value = stringToBytes(value); - } + this.state = "path"; + --this.pointer; + } - if (typeof namespace === 'string') { - namespace = (0, _parse.default)(namespace); + return true; +}; + +URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) { + if (isSpecial(this.url) && (c === 47 || c === 92)) { + if (c === 92) { + this.parseError = true; } + this.state = "special authority ignore slashes"; + } else if (c === 47) { + this.state = "authority"; + } else { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.state = "path"; + --this.pointer; + } - 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])` + return true; +}; +URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) { + if (c === 47 && this.input[this.pointer + 1] === 47) { + this.state = "special authority ignore slashes"; + ++this.pointer; + } else { + this.parseError = true; + this.state = "special authority ignore slashes"; + --this.pointer; + } - 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; + return true; +}; - if (buf) { - offset = offset || 0; +URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) { + if (c !== 47 && c !== 92) { + this.state = "authority"; + --this.pointer; + } else { + this.parseError = true; + } - for (let i = 0; i < 16; ++i) { - buf[offset + i] = bytes[i]; - } + return true; +}; - return buf; +URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) { + if (c === 64) { + this.parseError = true; + if (this.atFlag) { + this.buffer = "%40" + this.buffer; } + this.atFlag = true; - return (0, _stringify.default)(bytes); - } // Function#name is not settable on some platforms (#270) + // careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars + const len = countSymbols(this.buffer); + for (let pointer = 0; pointer < len; ++pointer) { + const codePoint = this.buffer.codePointAt(pointer); + if (codePoint === 58 && !this.passwordTokenSeenFlag) { + this.passwordTokenSeenFlag = true; + continue; + } + const encodedCodePoints = percentEncodeChar(codePoint, isUserinfoPercentEncode); + if (this.passwordTokenSeenFlag) { + this.url.password += encodedCodePoints; + } else { + this.url.username += encodedCodePoints; + } + } + this.buffer = ""; + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92)) { + if (this.atFlag && this.buffer === "") { + this.parseError = true; + return failure; + } + this.pointer -= countSymbols(this.buffer) + 1; + this.buffer = ""; + this.state = "host"; + } else { + this.buffer += cStr; + } - try { - generateUUID.name = name; // eslint-disable-next-line no-empty - } catch (err) {} // For CommonJS default export support + return true; +}; +URLStateMachine.prototype["parse hostname"] = +URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) { + if (this.stateOverride && this.url.scheme === "file") { + --this.pointer; + this.state = "file host"; + } else if (c === 58 && !this.arrFlag) { + if (this.buffer === "") { + this.parseError = true; + return failure; + } - generateUUID.DNS = DNS; - generateUUID.URL = URL; - return generateUUID; -} + const host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } -/***/ }), + this.url.host = host; + this.buffer = ""; + this.state = "port"; + if (this.stateOverride === "hostname") { + return false; + } + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92)) { + --this.pointer; + if (isSpecial(this.url) && this.buffer === "") { + this.parseError = true; + return failure; + } else if (this.stateOverride && this.buffer === "" && + (includesCredentials(this.url) || this.url.port !== null)) { + this.parseError = true; + return false; + } -/***/ 5122: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + const host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } -"use strict"; + this.url.host = host; + this.buffer = ""; + this.state = "path start"; + if (this.stateOverride) { + return false; + } + } else { + if (c === 91) { + this.arrFlag = true; + } else if (c === 93) { + this.arrFlag = false; + } + this.buffer += cStr; + } + return true; +}; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; +URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) { + if (isASCIIDigit(c)) { + this.buffer += cStr; + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92) || + this.stateOverride) { + if (this.buffer !== "") { + const port = parseInt(this.buffer); + if (port > Math.pow(2, 16) - 1) { + this.parseError = true; + return failure; + } + this.url.port = port === defaultPort(this.url.scheme) ? null : port; + this.buffer = ""; + } + if (this.stateOverride) { + return false; + } + this.state = "path start"; + --this.pointer; + } else { + this.parseError = true; + return failure; + } -var _rng = _interopRequireDefault(__nccwpck_require__(807)); + return true; +}; -var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); +const fileOtherwiseCodePoints = new Set([47, 92, 63, 35]); + +URLStateMachine.prototype["parse file"] = function parseFile(c) { + this.url.scheme = "file"; + + if (c === 47 || c === 92) { + if (c === 92) { + this.parseError = true; + } + this.state = "file slash"; + } else if (this.base !== null && this.base.scheme === "file") { + if (isNaN(c)) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + } else if (c === 63) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.state = "fragment"; + } else { + if (this.input.length - this.pointer - 1 === 0 || // remaining consists of 0 code points + !isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) || + (this.input.length - this.pointer - 1 >= 2 && // remaining has at least 2 code points + !fileOtherwiseCodePoints.has(this.input[this.pointer + 2]))) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + shortenPath(this.url); + } else { + this.parseError = true; + } -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + this.state = "path"; + --this.pointer; + } + } else { + this.state = "path"; + --this.pointer; + } -function v4(options, buf, offset) { - options = options || {}; + return true; +}; - const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` +URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) { + if (c === 47 || c === 92) { + if (c === 92) { + this.parseError = true; + } + this.state = "file host"; + } else { + if (this.base !== null && this.base.scheme === "file") { + if (isNormalizedWindowsDriveLetterString(this.base.path[0])) { + this.url.path.push(this.base.path[0]); + } else { + this.url.host = this.base.host; + } + } + this.state = "path"; + --this.pointer; + } + return true; +}; - rnds[6] = rnds[6] & 0x0f | 0x40; - rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided +URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) { + if (isNaN(c) || c === 47 || c === 92 || c === 63 || c === 35) { + --this.pointer; + if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) { + this.parseError = true; + this.state = "path"; + } else if (this.buffer === "") { + this.url.host = ""; + if (this.stateOverride) { + return false; + } + this.state = "path start"; + } else { + let host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + if (host === "localhost") { + host = ""; + } + this.url.host = host; - if (buf) { - offset = offset || 0; + if (this.stateOverride) { + return false; + } - for (let i = 0; i < 16; ++i) { - buf[offset + i] = rnds[i]; + this.buffer = ""; + this.state = "path start"; } - - return buf; + } else { + this.buffer += cStr; } - return (0, _stringify.default)(rnds); -} + return true; +}; -var _default = v4; -exports["default"] = _default; +URLStateMachine.prototype["parse path start"] = function parsePathStart(c) { + if (isSpecial(this.url)) { + if (c === 92) { + this.parseError = true; + } + this.state = "path"; -/***/ }), + if (c !== 47 && c !== 92) { + --this.pointer; + } + } else if (!this.stateOverride && c === 63) { + this.url.query = ""; + this.state = "query"; + } else if (!this.stateOverride && c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } else if (c !== undefined) { + this.state = "path"; + if (c !== 47) { + --this.pointer; + } + } -/***/ 9120: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + return true; +}; -"use strict"; +URLStateMachine.prototype["parse path"] = function parsePath(c) { + if (isNaN(c) || c === 47 || (isSpecial(this.url) && c === 92) || + (!this.stateOverride && (c === 63 || c === 35))) { + if (isSpecial(this.url) && c === 92) { + this.parseError = true; + } + if (isDoubleDot(this.buffer)) { + shortenPath(this.url); + if (c !== 47 && !(isSpecial(this.url) && c === 92)) { + this.url.path.push(""); + } + } else if (isSingleDot(this.buffer) && c !== 47 && + !(isSpecial(this.url) && c === 92)) { + this.url.path.push(""); + } else if (!isSingleDot(this.buffer)) { + if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) { + if (this.url.host !== "" && this.url.host !== null) { + this.parseError = true; + this.url.host = ""; + } + this.buffer = this.buffer[0] + ":"; + } + this.url.path.push(this.buffer); + } + this.buffer = ""; + if (this.url.scheme === "file" && (c === undefined || c === 63 || c === 35)) { + while (this.url.path.length > 1 && this.url.path[0] === "") { + this.parseError = true; + this.url.path.shift(); + } + } + if (c === 63) { + this.url.query = ""; + this.state = "query"; + } + if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } + } else { + // TODO: If c is not a URL code point and not "%", parse error. -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } -var _v = _interopRequireDefault(__nccwpck_require__(5998)); + this.buffer += percentEncodeChar(c, isPathPercentEncode); + } -var _sha = _interopRequireDefault(__nccwpck_require__(5274)); + return true; +}; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCannotBeABaseURLPath(c) { + if (c === 63) { + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } else { + // TODO: Add: not a URL code point + if (!isNaN(c) && c !== 37) { + this.parseError = true; + } -const v5 = (0, _v.default)('v5', 0x50, _sha.default); -var _default = v5; -exports["default"] = _default; + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } -/***/ }), + if (!isNaN(c)) { + this.url.path[0] = this.url.path[0] + percentEncodeChar(c, isC0ControlPercentEncode); + } + } -/***/ 6900: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + return true; +}; -"use strict"; +URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) { + if (isNaN(c) || (!this.stateOverride && c === 35)) { + if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") { + this.encodingOverride = "utf-8"; + } + const buffer = new Buffer(this.buffer); // TODO: Use encoding override instead + for (let i = 0; i < buffer.length; ++i) { + if (buffer[i] < 0x21 || buffer[i] > 0x7E || buffer[i] === 0x22 || buffer[i] === 0x23 || + buffer[i] === 0x3C || buffer[i] === 0x3E) { + this.url.query += percentEncode(buffer[i]); + } else { + this.url.query += String.fromCodePoint(buffer[i]); + } + } -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; + this.buffer = ""; + if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } + } else { + // TODO: If c is not a URL code point and not "%", parse error. + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } -var _regex = _interopRequireDefault(__nccwpck_require__(814)); + this.buffer += cStr; + } -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + return true; +}; -function validate(uuid) { - return typeof uuid === 'string' && _regex.default.test(uuid); -} +URLStateMachine.prototype["parse fragment"] = function parseFragment(c) { + if (isNaN(c)) { // do nothing + } else if (c === 0x0) { + this.parseError = true; + } else { + // TODO: If c is not a URL code point and not "%", parse error. + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } -var _default = validate; -exports["default"] = _default; + this.url.fragment += percentEncodeChar(c, isC0ControlPercentEncode); + } -/***/ }), + return true; +}; -/***/ 1595: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +function serializeURL(url, excludeFragment) { + let output = url.scheme + ":"; + if (url.host !== null) { + output += "//"; -"use strict"; + if (url.username !== "" || url.password !== "") { + output += url.username; + if (url.password !== "") { + output += ":" + url.password; + } + output += "@"; + } + output += serializeHost(url.host); -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; + if (url.port !== null) { + output += ":" + url.port; + } + } else if (url.host === null && url.scheme === "file") { + output += "//"; + } -var _validate = _interopRequireDefault(__nccwpck_require__(6900)); + if (url.cannotBeABaseURL) { + output += url.path[0]; + } else { + for (const string of url.path) { + output += "/" + string; + } + } -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + if (url.query !== null) { + output += "?" + url.query; + } -function version(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); + if (!excludeFragment && url.fragment !== null) { + output += "#" + url.fragment; } - return parseInt(uuid.substr(14, 1), 16); + return output; } -var _default = version; -exports["default"] = _default; - -/***/ }), - -/***/ 4207: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -module.exports = which -which.sync = whichSync - -var isWindows = process.platform === 'win32' || - process.env.OSTYPE === 'cygwin' || - process.env.OSTYPE === 'msys' - -var path = __nccwpck_require__(1017) -var COLON = isWindows ? ';' : ':' -var isexe = __nccwpck_require__(7126) +function serializeOrigin(tuple) { + let result = tuple.scheme + "://"; + result += serializeHost(tuple.host); -function getNotFoundError (cmd) { - var er = new Error('not found: ' + cmd) - er.code = 'ENOENT' + if (tuple.port !== null) { + result += ":" + tuple.port; + } - return er + return result; } -function getPathInfo (cmd, opt) { - var colon = opt.colon || COLON - var pathEnv = opt.path || process.env.PATH || '' - var pathExt = [''] - - pathEnv = pathEnv.split(colon) +module.exports.serializeURL = serializeURL; - var pathExtExe = '' - if (isWindows) { - pathEnv.unshift(process.cwd()) - pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM') - pathExt = pathExtExe.split(colon) +module.exports.serializeURLOrigin = function (url) { + // https://url.spec.whatwg.org/#concept-url-origin + switch (url.scheme) { + case "blob": + try { + return module.exports.serializeURLOrigin(module.exports.parseURL(url.path[0])); + } catch (e) { + // serializing an opaque origin returns "null" + return "null"; + } + case "ftp": + case "gopher": + case "http": + case "https": + case "ws": + case "wss": + return serializeOrigin({ + scheme: url.scheme, + host: url.host, + port: url.port + }); + case "file": + // spec says "exercise to the reader", chrome says "file://" + return "file://"; + default: + // serializing an opaque origin returns "null" + return "null"; + } +}; +module.exports.basicURLParse = function (input, options) { + if (options === undefined) { + options = {}; + } - // Always test the cmd itself first. isexe will check to make sure - // it's found in the pathExt set. - if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') - pathExt.unshift('') + const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride); + if (usm.failure) { + return "failure"; } - // If it has a slash, then we don't bother searching the pathenv. - // just check the file itself, and that's it. - if (cmd.match(/\//) || isWindows && cmd.match(/\\/)) - pathEnv = [''] + return usm.url; +}; - return { - env: pathEnv, - ext: pathExt, - extExe: pathExtExe +module.exports.setTheUsername = function (url, username) { + url.username = ""; + const decoded = punycode.ucs2.decode(username); + for (let i = 0; i < decoded.length; ++i) { + url.username += percentEncodeChar(decoded[i], isUserinfoPercentEncode); } -} +}; -function which (cmd, opt, cb) { - if (typeof opt === 'function') { - cb = opt - opt = {} +module.exports.setThePassword = function (url, password) { + url.password = ""; + const decoded = punycode.ucs2.decode(password); + for (let i = 0; i < decoded.length; ++i) { + url.password += percentEncodeChar(decoded[i], isUserinfoPercentEncode); } +}; - var info = getPathInfo(cmd, opt) - var pathEnv = info.env - var pathExt = info.ext - var pathExtExe = info.extExe - var found = [] +module.exports.serializeHost = serializeHost; - ;(function F (i, l) { - if (i === l) { - if (opt.all && found.length) - return cb(null, found) - else - return cb(getNotFoundError(cmd)) - } +module.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort; - var pathPart = pathEnv[i] - if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') - pathPart = pathPart.slice(1, -1) +module.exports.serializeInteger = function (integer) { + return String(integer); +}; - var p = path.join(pathPart, cmd) - if (!pathPart && (/^\.[\\\/]/).test(cmd)) { - p = cmd.slice(0, 2) + p - } - ;(function E (ii, ll) { - if (ii === ll) return F(i + 1, l) - var ext = pathExt[ii] - isexe(p + ext, { pathExt: pathExtExe }, function (er, is) { - if (!er && is) { - if (opt.all) - found.push(p + ext) - else - return cb(null, p + ext) - } - return E(ii + 1, ll) - }) - })(0, pathExt.length) - })(0, pathEnv.length) -} +module.exports.parseURL = function (input, options) { + if (options === undefined) { + options = {}; + } -function whichSync (cmd, opt) { - opt = opt || {} + // We don't handle blobs, so this just delegates: + return module.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride }); +}; - var info = getPathInfo(cmd, opt) - var pathEnv = info.env - var pathExt = info.ext - var pathExtExe = info.extExe - var found = [] - for (var i = 0, l = pathEnv.length; i < l; i ++) { - var pathPart = pathEnv[i] - if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') - pathPart = pathPart.slice(1, -1) +/***/ }), - var p = path.join(pathPart, cmd) - if (!pathPart && /^\.[\\\/]/.test(cmd)) { - p = cmd.slice(0, 2) + p - } - for (var j = 0, ll = pathExt.length; j < ll; j ++) { - var cur = p + pathExt[j] - var is - try { - is = isexe.sync(cur, { pathExt: pathExtExe }) - if (is) { - if (opt.all) - found.push(cur) - else - return cur - } - } catch (ex) {} - } +/***/ 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])); } +}; - if (opt.all && found.length) - return found +module.exports.wrapperSymbol = Symbol("wrapper"); +module.exports.implSymbol = Symbol("impl"); - if (opt.nothrow) - return null +module.exports.wrapperForImpl = function (impl) { + return impl[module.exports.wrapperSymbol]; +}; + +module.exports.implForWrapper = function (wrapper) { + return wrapper[module.exports.implSymbol]; +}; - throw getNotFoundError(cmd) -} /***/ }), -/***/ 3515: +/***/ 502: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -const os = __nccwpck_require__(2037); -const execa = __nccwpck_require__(5447); +const path = __nccwpck_require__(1017); +const pathKey = __nccwpck_require__(539); -// Reference: https://www.gaijin.at/en/lstwinver.php -const names = new Map([ - ['10.0', '10'], - ['6.3', '8.1'], - ['6.2', '8'], - ['6.1', '7'], - ['6.0', 'Vista'], - ['5.2', 'Server 2003'], - ['5.1', 'XP'], - ['5.0', '2000'], - ['4.9', 'ME'], - ['4.1', '98'], - ['4.0', '95'] -]); +module.exports = opts => { + opts = Object.assign({ + cwd: process.cwd(), + path: process.env[pathKey()] + }, opts); -const windowsRelease = release => { - const version = /\d+\.\d/.exec(release || os.release()); + let prev; + let pth = path.resolve(opts.cwd); + const ret = []; - if (release && !version) { - throw new Error('`release` argument doesn\'t match `n.n`'); + while (prev !== pth) { + ret.push(path.join(pth, 'node_modules/.bin')); + prev = pth; + pth = path.resolve(pth, '..'); } - const ver = (version || [])[0]; - - // Server 2008, 2012 and 2016 versions are ambiguous with desktop versions and must be detected at runtime. - // If `release` is omitted or we're on a Windows system, and the version number is an ambiguous version - // then use `wmic` to get the OS caption: https://msdn.microsoft.com/en-us/library/aa394531(v=vs.85).aspx - // If the resulting caption contains the year 2008, 2012 or 2016, it is a server version, so return a server OS name. - if ((!release || release === os.release()) && ['6.1', '6.2', '6.3', '10.0'].includes(ver)) { - const stdout = execa.sync('wmic', ['os', 'get', 'Caption']).stdout || ''; - const year = (stdout.match(/2008|2012|2016/) || [])[0]; - if (year) { - return `Server ${year}`; - } - } + // ensure the running `node` binary is used + ret.push(path.dirname(process.execPath)); - return names.get(ver); + return ret.concat(opts.path).join(path.delimiter); }; -module.exports = windowsRelease; +module.exports.env = opts => { + opts = Object.assign({ + env: process.env + }, opts); + const env = Object.assign({}, opts.env); + const path = pathKey({env}); -/***/ }), + opts.path = env[path]; + env[path] = module.exports(opts); -/***/ 2940: -/***/ ((module) => { + return env; +}; -// 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] - }) +/***/ 2072: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return wrapper +module.exports = paginationMethodsPlugin - 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 - } +function paginationMethodsPlugin (octokit) { + octokit.getFirstPage = (__nccwpck_require__(9555).bind)(null, octokit) + octokit.getLastPage = (__nccwpck_require__(2203).bind)(null, octokit) + octokit.getNextPage = (__nccwpck_require__(6655).bind)(null, octokit) + octokit.getPreviousPage = (__nccwpck_require__(3032).bind)(null, octokit) + octokit.hasFirstPage = __nccwpck_require__(9631) + octokit.hasLastPage = __nccwpck_require__(4286) + octokit.hasNextPage = __nccwpck_require__(500) + octokit.hasPreviousPage = __nccwpck_require__(5996) } /***/ }), -/***/ 2839: -/***/ (function(module) { - -// Generated by CoffeeScript 2.4.1 -(function() { - module.exports = { - Disconnected: 1, - Preceding: 2, - Following: 4, - Contains: 8, - ContainedBy: 16, - ImplementationSpecific: 32 - }; - -}).call(this); +/***/ 191: +/***/ ((module) => { +module.exports = deprecate -/***/ }), +const loggedMessages = {} -/***/ 9267: -/***/ (function(module) { - -// Generated by CoffeeScript 2.4.1 -(function() { - module.exports = { - Element: 1, - Attribute: 2, - Text: 3, - CData: 4, - EntityReference: 5, - EntityDeclaration: 6, - ProcessingInstruction: 7, - Comment: 8, - Document: 9, - DocType: 10, - DocumentFragment: 11, - NotationDeclaration: 12, - // Numeric codes up to 200 are reserved to W3C for possible future use. - // Following are types internal to this library: - Declaration: 201, - Raw: 202, - AttributeDeclaration: 203, - ElementDeclaration: 204, - Dummy: 205 - }; +function deprecate (message) { + if (loggedMessages[message]) { + return + } -}).call(this); + console.warn(`DEPRECATED (@octokit/rest): ${message}`) + loggedMessages[message] = 1 +} /***/ }), -/***/ 8229: -/***/ (function(module) { - -// Generated by CoffeeScript 2.4.1 -(function() { - // Copies all enumerable own properties from `sources` to `target` - var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject, - hasProp = {}.hasOwnProperty; - - assign = function(target, ...sources) { - var i, key, len, source; - if (isFunction(Object.assign)) { - Object.assign.apply(null, arguments); - } else { - for (i = 0, len = sources.length; i < len; i++) { - source = sources[i]; - if (source != null) { - for (key in source) { - if (!hasProp.call(source, key)) continue; - target[key] = source[key]; - } - } - } - } - return target; - }; - - // Determines if `val` is a Function object - isFunction = function(val) { - return !!val && Object.prototype.toString.call(val) === '[object Function]'; - }; - - // Determines if `val` is an Object - isObject = function(val) { - var ref; - return !!val && ((ref = typeof val) === 'function' || ref === 'object'); - }; - - // Determines if `val` is an Array - isArray = function(val) { - if (isFunction(Array.isArray)) { - return Array.isArray(val); - } else { - return Object.prototype.toString.call(val) === '[object Array]'; - } - }; - - // Determines if `val` is an empty Array or an Object with no own properties - isEmpty = function(val) { - var key; - if (isArray(val)) { - return !val.length; - } else { - for (key in val) { - if (!hasProp.call(val, key)) continue; - return false; - } - return true; - } - }; - - // Determines if `val` is a plain Object - isPlainObject = function(val) { - var ctor, proto; - return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object)); - }; +/***/ 9555: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // Gets the primitive value of an object - getValue = function(obj) { - if (isFunction(obj.valueOf)) { - return obj.valueOf(); - } else { - return obj; - } - }; +module.exports = getFirstPage - module.exports.assign = assign; +const getPage = __nccwpck_require__(8604) - module.exports.isFunction = isFunction; +function getFirstPage (octokit, link, headers) { + return getPage(octokit, link, 'first', headers) +} - module.exports.isObject = isObject; - module.exports.isArray = isArray; +/***/ }), - module.exports.isEmpty = isEmpty; +/***/ 2203: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - module.exports.isPlainObject = isPlainObject; +module.exports = getLastPage - module.exports.getValue = getValue; +const getPage = __nccwpck_require__(8604) -}).call(this); +function getLastPage (octokit, link, headers) { + return getPage(octokit, link, 'last', headers) +} /***/ }), -/***/ 9766: -/***/ (function(module) { - -// Generated by CoffeeScript 2.4.1 -(function() { - module.exports = { - None: 0, - OpenTag: 1, - InsideTag: 2, - CloseTag: 3 - }; - -}).call(this); +/***/ 6655: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +module.exports = getNextPage -/***/ }), +const getPage = __nccwpck_require__(8604) -/***/ 8376: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +function getNextPage (octokit, link, headers) { + return getPage(octokit, link, 'next', headers) +} -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLAttribute, XMLNode; - NodeType = __nccwpck_require__(9267); +/***/ }), - XMLNode = __nccwpck_require__(7608); +/***/ 7889: +/***/ ((module) => { - // Represents an attribute - module.exports = XMLAttribute = (function() { - class XMLAttribute { - // Initializes a new instance of `XMLAttribute` +module.exports = getPageLinks - // `parent` the parent node - // `name` attribute target - // `value` attribute value - constructor(parent, name, value) { - this.parent = parent; - if (this.parent) { - this.options = this.parent.options; - this.stringify = this.parent.stringify; - } - if (name == null) { - throw new Error("Missing attribute name. " + this.debugInfo(name)); - } - this.name = this.stringify.name(name); - this.value = this.stringify.attValue(value); - this.type = NodeType.Attribute; - // DOM level 3 - this.isId = false; - this.schemaTypeInfo = null; - } +function getPageLinks (link) { + link = link.link || link.headers.link || '' - // Creates and returns a deep clone of `this` - clone() { - return Object.create(this); - } + const links = {} - // Converts the XML fragment to string + // link format: + // '; rel="next", ; rel="last"' + link.replace(/<([^>]*)>;\s*rel="([\w]*)"/g, (m, uri, type) => { + links[type] = uri + }) - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); - } + return links +} - - // Returns debug string for this node - debugInfo(name) { - name = name || this.name; - if (name == null) { - return "parent: <" + this.parent.name + ">"; - } else { - return "attribute: {" + name + "}, parent: <" + this.parent.name + ">"; - } - } - isEqualNode(node) { - if (node.namespaceURI !== this.namespaceURI) { - return false; - } - if (node.prefix !== this.prefix) { - return false; - } - if (node.localName !== this.localName) { - return false; - } - if (node.value !== this.value) { - return false; - } - return true; - } +/***/ }), - }; +/***/ 8604: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // DOM level 1 - Object.defineProperty(XMLAttribute.prototype, 'nodeType', { - get: function() { - return this.type; - } - }); +module.exports = getPage - Object.defineProperty(XMLAttribute.prototype, 'ownerElement', { - get: function() { - return this.parent; - } - }); +const deprecate = __nccwpck_require__(191) +const getPageLinks = __nccwpck_require__(7889) +const HttpError = __nccwpck_require__(6058) - // DOM level 3 - Object.defineProperty(XMLAttribute.prototype, 'textContent', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); +function getPage (octokit, link, which, headers) { + deprecate(`octokit.get${which.charAt(0).toUpperCase() + which.slice(1)}Page() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) + const url = getPageLinks(link)[which] - // DOM level 4 - Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', { - get: function() { - return ''; - } - }); + if (!url) { + const urlError = new HttpError(`No ${which} page found`, 404) + return Promise.reject(urlError) + } - Object.defineProperty(XMLAttribute.prototype, 'prefix', { - get: function() { - return ''; - } - }); + const requestOptions = { + url, + headers: applyAcceptHeader(link, headers) + } - Object.defineProperty(XMLAttribute.prototype, 'localName', { - get: function() { - return this.name; - } - }); + const promise = octokit.request(requestOptions) - Object.defineProperty(XMLAttribute.prototype, 'specified', { - get: function() { - return true; - } - }); + return promise +} - return XMLAttribute; +function applyAcceptHeader (res, headers) { + const previous = res.headers && res.headers['x-github-media-type'] - }).call(this); + if (!previous || (headers && headers.accept)) { + return headers + } + headers = headers || {} + headers.accept = 'application/vnd.' + previous + .replace('; param=', '.') + .replace('; format=', '+') -}).call(this); + return headers +} /***/ }), -/***/ 333: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLCData, XMLCharacterData; +/***/ 3032: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - NodeType = __nccwpck_require__(9267); +module.exports = getPreviousPage - XMLCharacterData = __nccwpck_require__(7709); +const getPage = __nccwpck_require__(8604) - // Represents a CDATA node - module.exports = XMLCData = class XMLCData extends XMLCharacterData { - // Initializes a new instance of `XMLCData` +function getPreviousPage (octokit, link, headers) { + return getPage(octokit, link, 'prev', headers) +} - // `text` CDATA text - constructor(parent, text) { - super(parent); - if (text == null) { - throw new Error("Missing CDATA text. " + this.debugInfo()); - } - this.name = "#cdata-section"; - this.type = NodeType.CData; - this.value = this.stringify.cdata(text); - } - // Creates and returns a deep clone of `this` - clone() { - return Object.create(this); - } +/***/ }), - // Converts the XML fragment to string +/***/ 9631: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.cdata(this, this.options.writer.filterOptions(options)); - } +module.exports = hasFirstPage - }; +const deprecate = __nccwpck_require__(191) +const getPageLinks = __nccwpck_require__(7889) -}).call(this); +function hasFirstPage (link) { + deprecate(`octokit.hasFirstPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) + return getPageLinks(link).first +} /***/ }), -/***/ 7709: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var XMLCharacterData, XMLNode; - - XMLNode = __nccwpck_require__(7608); - - // Represents a character data node - module.exports = XMLCharacterData = (function() { - class XMLCharacterData extends XMLNode { - // Initializes a new instance of `XMLCharacterData` +/***/ 4286: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - constructor(parent) { - super(parent); - this.value = ''; - } +module.exports = hasLastPage - - // Creates and returns a deep clone of `this` - clone() { - return Object.create(this); - } +const deprecate = __nccwpck_require__(191) +const getPageLinks = __nccwpck_require__(7889) - // DOM level 1 functions to be implemented later - substringData(offset, count) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +function hasLastPage (link) { + deprecate(`octokit.hasLastPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) + return getPageLinks(link).last +} - appendData(arg) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - insertData(offset, arg) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +/***/ }), - deleteData(offset, count) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +/***/ 500: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - replaceData(offset, count, arg) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +module.exports = hasNextPage - isEqualNode(node) { - if (!super.isEqualNode(node)) { - return false; - } - if (node.data !== this.data) { - return false; - } - return true; - } +const deprecate = __nccwpck_require__(191) +const getPageLinks = __nccwpck_require__(7889) - }; +function hasNextPage (link) { + deprecate(`octokit.hasNextPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) + return getPageLinks(link).next +} - // DOM level 1 - Object.defineProperty(XMLCharacterData.prototype, 'data', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); - Object.defineProperty(XMLCharacterData.prototype, 'length', { - get: function() { - return this.value.length; - } - }); +/***/ }), - // DOM level 3 - Object.defineProperty(XMLCharacterData.prototype, 'textContent', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); +/***/ 5996: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return XMLCharacterData; +module.exports = hasPreviousPage - }).call(this); +const deprecate = __nccwpck_require__(191) +const getPageLinks = __nccwpck_require__(7889) -}).call(this); +function hasPreviousPage (link) { + deprecate(`octokit.hasPreviousPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) + return getPageLinks(link).prev +} /***/ }), -/***/ 4407: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLCharacterData, XMLComment; +/***/ 6058: +/***/ ((module) => { - NodeType = __nccwpck_require__(9267); +module.exports = class HttpError extends Error { + constructor (message, code, headers) { + super(message) - XMLCharacterData = __nccwpck_require__(7709); + // Maintains proper stack trace (only available on V8) + /* istanbul ignore next */ + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor) + } - // Represents a comment node - module.exports = XMLComment = class XMLComment extends XMLCharacterData { - // Initializes a new instance of `XMLComment` + this.name = 'HttpError' + this.code = code + this.headers = headers + } +} - // `text` comment text - constructor(parent, text) { - super(parent); - if (text == null) { - throw new Error("Missing comment text. " + this.debugInfo()); - } - this.name = "#comment"; - this.type = NodeType.Comment; - this.value = this.stringify.comment(text); - } - // Creates and returns a deep clone of `this` - clone() { - return Object.create(this); - } +/***/ }), - // Converts the XML fragment to string +/***/ 1223: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.comment(this, this.options.writer.filterOptions(options)); - } +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 + }) -}).call(this); + 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 +} -/***/ 7465: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList; - - XMLDOMErrorHandler = __nccwpck_require__(6744); - - XMLDOMStringList = __nccwpck_require__(7028); - - // Implements the DOMConfiguration interface - module.exports = XMLDOMConfiguration = (function() { - class XMLDOMConfiguration { - constructor() { - var clonedSelf; - this.defaultParams = { - "canonical-form": false, - "cdata-sections": false, - "comments": false, - "datatype-normalization": false, - "element-content-whitespace": true, - "entities": true, - "error-handler": new XMLDOMErrorHandler(), - "infoset": true, - "validate-if-schema": false, - "namespaces": true, - "namespace-declarations": true, - "normalize-characters": false, - "schema-location": '', - "schema-type": '', - "split-cdata-sections": true, - "validate": false, - "well-formed": true - }; - this.params = clonedSelf = Object.create(this.defaultParams); - } - // Gets the value of a parameter. +/***/ }), - // `name` name of the parameter - getParameter(name) { - if (this.params.hasOwnProperty(name)) { - return this.params[name]; - } else { - return null; - } - } +/***/ 4824: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // Checks if setting a parameter to a specific value is supported. +"use strict"; - // `name` name of the parameter - // `value` parameter value - canSetParameter(name, value) { - return true; - } +const os = __nccwpck_require__(2037); +const macosRelease = __nccwpck_require__(7493); +const winRelease = __nccwpck_require__(3515); - // Sets the value of a parameter. +const osName = (platform, release) => { + if (!platform && release) { + throw new Error('You can\'t specify a `release` without specifying `platform`'); + } - // `name` name of the parameter - // `value` new value or null if the user wishes to unset the parameter - setParameter(name, value) { - if (value != null) { - return this.params[name] = value; - } else { - return delete this.params[name]; - } - } + platform = platform || os.platform(); - }; + let id; - // Returns the list of parameter names - Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', { - get: function() { - return new XMLDOMStringList(Object.keys(this.defaultParams)); - } - }); + if (platform === 'darwin') { + if (!release && os.platform() === 'darwin') { + release = os.release(); + } - return XMLDOMConfiguration; + const prefix = release ? (Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X') : 'macOS'; + id = release ? macosRelease(release).name : ''; + return prefix + (id ? ' ' + id : ''); + } - }).call(this); + if (platform === 'linux') { + if (!release && os.platform() === 'linux') { + release = os.release(); + } -}).call(this); + id = release ? release.replace(/^(\d+\.\d+).*/, '$1') : ''; + return 'Linux' + (id ? ' ' + id : ''); + } + if (platform === 'win32') { + if (!release && os.platform() === 'win32') { + release = os.release(); + } -/***/ }), + id = release ? winRelease(release) : ''; + return 'Windows' + (id ? ' ' + id : ''); + } -/***/ 6744: -/***/ (function(module) { + return platform; +}; -// Generated by CoffeeScript 2.4.1 -(function() { - // Represents the error handler for DOM operations - var XMLDOMErrorHandler; +module.exports = osName; - module.exports = XMLDOMErrorHandler = class XMLDOMErrorHandler { - // Initializes a new instance of `XMLDOMErrorHandler` - constructor() {} +/***/ }), - // Called on the error handler when an error occurs. +/***/ 1330: +/***/ ((module) => { - // `error` the error message as a string - handleError(error) { - throw new Error(error); - } +"use strict"; - }; +module.exports = (promise, onFinally) => { + onFinally = onFinally || (() => {}); -}).call(this); + return promise.then( + val => new Promise(resolve => { + resolve(onFinally()); + }).then(() => val), + err => new Promise(resolve => { + resolve(onFinally()); + }).then(() => { + throw err; + }) + ); +}; /***/ }), -/***/ 8310: -/***/ (function(module) { - -// Generated by CoffeeScript 2.4.1 -(function() { - // Implements the DOMImplementation interface - var XMLDOMImplementation; +/***/ 539: +/***/ ((module) => { - module.exports = XMLDOMImplementation = class XMLDOMImplementation { - // Tests if the DOM implementation implements a specific feature. +"use strict"; - // `feature` package name of the feature to test. In Level 1, the - // legal values are "HTML" and "XML" (case-insensitive). - // `version` version number of the package name to test. - // In Level 1, this is the string "1.0". If the version is - // not specified, supporting any version of the feature will - // cause the method to return true. - hasFeature(feature, version) { - return true; - } +module.exports = opts => { + opts = opts || {}; - // Creates a new document type declaration. + const env = opts.env || process.env; + const platform = opts.platform || process.platform; - // `qualifiedName` qualified name of the document type to be created - // `publicId` public identifier of the external subset - // `systemId` system identifier of the external subset - createDocumentType(qualifiedName, publicId, systemId) { - throw new Error("This DOM method is not implemented."); - } + if (platform !== 'win32') { + return 'PATH'; + } - // Creates a new document. + return Object.keys(env).find(x => x.toUpperCase() === 'PATH') || 'Path'; +}; - // `namespaceURI` namespace URI of the document element to create - // `qualifiedName` the qualified name of the document to be created - // `doctype` the type of document to be created or null - createDocument(namespaceURI, qualifiedName, doctype) { - throw new Error("This DOM method is not implemented."); - } - // Creates a new HTML document. +/***/ }), - // `title` document title - createHTMLDocument(title) { - throw new Error("This DOM method is not implemented."); - } +/***/ 8341: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // Returns a specialized object which implements the specialized APIs - // of the specified feature and version. +var once = __nccwpck_require__(1223) +var eos = __nccwpck_require__(1205) +var fs = __nccwpck_require__(7147) // we only need fs to get the ReadStream and WriteStream prototypes - // `feature` name of the feature requested. - // `version` version number of the feature to test - getFeature(feature, version) { - throw new Error("This DOM method is not implemented."); - } +var noop = function () {} +var ancient = /^v?\.0/.test(process.version) - }; +var isFn = function (fn) { + return typeof fn === 'function' +} -}).call(this); +var isFS = function (stream) { + if (!ancient) return false // newer node version do not need to care about fs is a special way + if (!fs) return false // browser + return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close) +} +var isRequest = function (stream) { + return stream.setHeader && isFn(stream.abort) +} -/***/ }), +var destroyer = function (stream, reading, writing, callback) { + callback = once(callback) -/***/ 7028: -/***/ (function(module) { + var closed = false + stream.on('close', function () { + closed = true + }) -// Generated by CoffeeScript 2.4.1 -(function() { - // Represents a list of string entries - var XMLDOMStringList; + eos(stream, {readable: reading, writable: writing}, function (err) { + if (err) return callback(err) + closed = true + callback() + }) - module.exports = XMLDOMStringList = (function() { - class XMLDOMStringList { - // Initializes a new instance of `XMLDOMStringList` - // This is just a wrapper around an ordinary - // JS array. + var destroyed = false + return function (err) { + if (closed) return + if (destroyed) return + destroyed = true - // `arr` the array of string values - constructor(arr) { - this.arr = arr || []; - } + if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks + if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want - // Returns the indexth item in the collection. + if (isFn(stream.destroy)) return stream.destroy() - // `index` index into the collection - item(index) { - return this.arr[index] || null; - } + callback(err || new Error('stream was destroyed')) + } +} - // Test if a string is part of this DOMStringList. +var call = function (fn) { + fn() +} - // `str` the string to look for - contains(str) { - return this.arr.indexOf(str) !== -1; - } +var pipe = function (from, to) { + return from.pipe(to) +} - }; +var pump = function () { + var streams = Array.prototype.slice.call(arguments) + var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop - // Returns the number of strings in the list. - Object.defineProperty(XMLDOMStringList.prototype, 'length', { - get: function() { - return this.arr.length; - } - }); + if (Array.isArray(streams[0])) streams = streams[0] + if (streams.length < 2) throw new Error('pump requires two streams per minimum') - return XMLDOMStringList; + var error + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1 + var writing = i > 0 + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err + if (err) destroys.forEach(call) + if (reading) return + destroys.forEach(call) + callback(error) + }) + }) - }).call(this); + return streams.reduce(pipe) +} -}).call(this); +module.exports = pump /***/ }), -/***/ 1015: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLDTDAttList, XMLNode; - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - // Represents an attribute list - module.exports = XMLDTDAttList = class XMLDTDAttList extends XMLNode { - // Initializes a new instance of `XMLDTDAttList` - - // `parent` the parent `XMLDocType` element - // `elementName` the name of the element containing this attribute - // `attributeName` attribute name - // `attributeType` type of the attribute - // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, - // #FIXED or #DEFAULT) - // `defaultValue` default value of the attribute - // (only used for #FIXED or #DEFAULT) - constructor(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { - super(parent); - if (elementName == null) { - throw new Error("Missing DTD element name. " + this.debugInfo()); - } - if (attributeName == null) { - throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName)); - } - if (!attributeType) { - throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName)); - } - if (!defaultValueType) { - throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName)); - } - if (defaultValueType.indexOf('#') !== 0) { - defaultValueType = '#' + defaultValueType; - } - if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) { - throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName)); - } - if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) { - throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName)); - } - this.elementName = this.stringify.name(elementName); - this.type = NodeType.AttributeDeclaration; - this.attributeName = this.stringify.name(attributeName); - this.attributeType = this.stringify.dtdAttType(attributeType); - if (defaultValue) { - this.defaultValue = this.stringify.dtdAttDefault(defaultValue); - } - this.defaultValueType = defaultValueType; - } +/***/ 5911: +/***/ ((module, exports) => { - // Converts the XML fragment to string +exports = module.exports = SemVer - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options)); - } +var debug +/* istanbul ignore next */ +if (typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG)) { + debug = function () { + var args = Array.prototype.slice.call(arguments, 0) + args.unshift('SEMVER') + console.log.apply(console, args) + } +} else { + debug = function () {} +} - }; +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +exports.SEMVER_SPEC_VERSION = '2.0.0' -}).call(this); +var MAX_LENGTH = 256 +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 +// Max safe segment length for coercion. +var MAX_SAFE_COMPONENT_LENGTH = 16 -/***/ }), +// The actual regexps go on exports.re +var re = exports.re = [] +var src = exports.src = [] +var t = exports.tokens = {} +var R = 0 -/***/ 2421: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +function tok (n) { + t[n] = R++ +} -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLDTDElement, XMLNode; +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. - XMLNode = __nccwpck_require__(7608); +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. - NodeType = __nccwpck_require__(9267); +tok('NUMERICIDENTIFIER') +src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' +tok('NUMERICIDENTIFIERLOOSE') +src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+' - // Represents an attribute - module.exports = XMLDTDElement = class XMLDTDElement extends XMLNode { - // Initializes a new instance of `XMLDTDElement` +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. - // `parent` the parent `XMLDocType` element - // `name` element name - // `value` element content (defaults to #PCDATA) - constructor(parent, name, value) { - super(parent); - if (name == null) { - throw new Error("Missing DTD element name. " + this.debugInfo()); - } - if (!value) { - value = '(#PCDATA)'; - } - if (Array.isArray(value)) { - value = '(' + value.join(',') + ')'; - } - this.name = this.stringify.name(name); - this.type = NodeType.ElementDeclaration; - this.value = this.stringify.dtdElementValue(value); - } +tok('NONNUMERICIDENTIFIER') +src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' - // Converts the XML fragment to string +// ## Main Version +// Three dot-separated numeric identifiers. - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options)); - } +tok('MAINVERSION') +src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')' - }; +tok('MAINVERSIONLOOSE') +src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' -}).call(this); +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. +tok('PRERELEASEIDENTIFIER') +src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' -/***/ }), +tok('PRERELEASEIDENTIFIERLOOSE') +src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' -/***/ 53: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLDTDEntity, XMLNode, isObject; +tok('PRERELEASE') +src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' - ({isObject} = __nccwpck_require__(8229)); +tok('PRERELEASELOOSE') +src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' - XMLNode = __nccwpck_require__(7608); +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. - NodeType = __nccwpck_require__(9267); +tok('BUILDIDENTIFIER') +src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' - // Represents an entity declaration in the DTD - module.exports = XMLDTDEntity = (function() { - class XMLDTDEntity extends XMLNode { - // Initializes a new instance of `XMLDTDEntity` +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. - // `parent` the parent `XMLDocType` element - // `pe` whether this is a parameter entity or a general entity - // defaults to `false` (general entity) - // `name` the name of the entity - // `value` internal entity value or an object with external entity details - // `value.pubID` public identifier - // `value.sysID` system identifier - // `value.nData` notation declaration - constructor(parent, pe, name, value) { - super(parent); - if (name == null) { - throw new Error("Missing DTD entity name. " + this.debugInfo(name)); - } - if (value == null) { - throw new Error("Missing DTD entity value. " + this.debugInfo(name)); - } - this.pe = !!pe; - this.name = this.stringify.name(name); - this.type = NodeType.EntityDeclaration; - if (!isObject(value)) { - this.value = this.stringify.dtdEntityValue(value); - this.internal = true; - } else { - if (!value.pubID && !value.sysID) { - throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name)); - } - if (value.pubID && !value.sysID) { - throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name)); - } - this.internal = false; - if (value.pubID != null) { - this.pubID = this.stringify.dtdPubID(value.pubID); - } - if (value.sysID != null) { - this.sysID = this.stringify.dtdSysID(value.sysID); - } - if (value.nData != null) { - this.nData = this.stringify.dtdNData(value.nData); - } - if (this.pe && this.nData) { - throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name)); - } - } - } +tok('BUILD') +src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + + '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))' - // Converts the XML fragment to string +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options)); - } +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. - }; +tok('FULL') +tok('FULLPLAIN') +src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + + src[t.PRERELEASE] + '?' + + src[t.BUILD] + '?' - // DOM level 1 - Object.defineProperty(XMLDTDEntity.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); +src[t.FULL] = '^' + src[t.FULLPLAIN] + '$' - Object.defineProperty(XMLDTDEntity.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +tok('LOOSEPLAIN') +src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + + src[t.PRERELEASELOOSE] + '?' + + src[t.BUILD] + '?' - Object.defineProperty(XMLDTDEntity.prototype, 'notationName', { - get: function() { - return this.nData || null; - } - }); +tok('LOOSE') +src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' - // DOM level 3 - Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', { - get: function() { - return null; - } - }); +tok('GTLT') +src[t.GTLT] = '((?:<|>)?=?)' - Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', { - get: function() { - return null; - } - }); +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +tok('XRANGEIDENTIFIERLOOSE') +src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' +tok('XRANGEIDENTIFIER') +src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' - Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', { - get: function() { - return null; - } - }); +tok('XRANGEPLAIN') +src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:' + src[t.PRERELEASE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' - return XMLDTDEntity; +tok('XRANGEPLAINLOOSE') +src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:' + src[t.PRERELEASELOOSE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' - }).call(this); +tok('XRANGE') +src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' +tok('XRANGELOOSE') +src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' -}).call(this); +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +tok('COERCE') +src[t.COERCE] = '(^|[^\\d])' + + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:$|[^\\d])' +tok('COERCERTL') +re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g') +// Tilde ranges. +// Meaning is "reasonably at or greater than" +tok('LONETILDE') +src[t.LONETILDE] = '(?:~>?)' -/***/ }), +tok('TILDETRIM') +src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' +re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') +var tildeTrimReplace = '$1~' -/***/ 2837: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +tok('TILDE') +src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' +tok('TILDELOOSE') +src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLDTDNotation, XMLNode; +// Caret ranges. +// Meaning is "at least and backwards compatible with" +tok('LONECARET') +src[t.LONECARET] = '(?:\\^)' - XMLNode = __nccwpck_require__(7608); +tok('CARETTRIM') +src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' +re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') +var caretTrimReplace = '$1^' - NodeType = __nccwpck_require__(9267); +tok('CARET') +src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' +tok('CARETLOOSE') +src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' - // Represents a NOTATION entry in the DTD - module.exports = XMLDTDNotation = (function() { - class XMLDTDNotation extends XMLNode { - // Initializes a new instance of `XMLDTDNotation` +// A simple gt/lt/eq thing, or just "" to indicate "any version" +tok('COMPARATORLOOSE') +src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$' +tok('COMPARATOR') +src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$' - // `parent` the parent `XMLDocType` element - // `name` the name of the notation - // `value` an object with external entity details - // `value.pubID` public identifier - // `value.sysID` system identifier - constructor(parent, name, value) { - super(parent); - if (name == null) { - throw new Error("Missing DTD notation name. " + this.debugInfo(name)); - } - if (!value.pubID && !value.sysID) { - throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name)); - } - this.name = this.stringify.name(name); - this.type = NodeType.NotationDeclaration; - if (value.pubID != null) { - this.pubID = this.stringify.dtdPubID(value.pubID); - } - if (value.sysID != null) { - this.sysID = this.stringify.dtdSysID(value.sysID); - } - } +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +tok('COMPARATORTRIM') +src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + + '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')' - // Converts the XML fragment to string +// this one has to use the /g flag +re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') +var comparatorTrimReplace = '$1$2$3' - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options)); - } +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +tok('HYPHENRANGE') +src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAIN] + ')' + + '\\s*$' - }; +tok('HYPHENRANGELOOSE') +src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s*$' - // DOM level 1 - Object.defineProperty(XMLDTDNotation.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); +// Star ranges basically just allow anything at all. +tok('STAR') +src[t.STAR] = '(<|>)?=?\\s*\\*' - Object.defineProperty(XMLDTDNotation.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); +// Compile to actual regexp objects. +// All are flag-free, unless they were created above with a flag. +for (var i = 0; i < R; i++) { + debug(i, src[i]) + if (!re[i]) { + re[i] = new RegExp(src[i]) + } +} - return XMLDTDNotation; +exports.parse = parse +function parse (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } - }).call(this); + if (version instanceof SemVer) { + return version + } -}).call(this); + if (typeof version !== 'string') { + return null + } + if (version.length > MAX_LENGTH) { + return null + } -/***/ }), + var r = options.loose ? re[t.LOOSE] : re[t.FULL] + if (!r.test(version)) { + return null + } -/***/ 6364: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + try { + return new SemVer(version, options) + } catch (er) { + return null + } +} -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLDeclaration, XMLNode, isObject; +exports.valid = valid +function valid (version, options) { + var v = parse(version, options) + return v ? v.version : null +} - ({isObject} = __nccwpck_require__(8229)); +exports.clean = clean +function clean (version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} - XMLNode = __nccwpck_require__(7608); +exports.SemVer = SemVer - NodeType = __nccwpck_require__(9267); +function SemVer (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + if (version instanceof SemVer) { + if (version.loose === options.loose) { + return version + } else { + version = version.version + } + } else if (typeof version !== 'string') { + throw new TypeError('Invalid Version: ' + version) + } - // Represents the XML declaration - module.exports = XMLDeclaration = class XMLDeclaration extends XMLNode { - // Initializes a new instance of `XMLDeclaration` + if (version.length > MAX_LENGTH) { + throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') + } - // `parent` the document object + if (!(this instanceof SemVer)) { + return new SemVer(version, options) + } - // `version` A version number string, e.g. 1.0 - // `encoding` Encoding declaration, e.g. UTF-8 - // `standalone` standalone document declaration: true or false - constructor(parent, version, encoding, standalone) { - super(parent); - // arguments may also be passed as an object - if (isObject(version)) { - ({version, encoding, standalone} = version); - } - if (!version) { - version = '1.0'; - } - this.type = NodeType.Declaration; - this.version = this.stringify.xmlVersion(version); - if (encoding != null) { - this.encoding = this.stringify.xmlEncoding(encoding); - } - if (standalone != null) { - this.standalone = this.stringify.xmlStandalone(standalone); - } - } + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose - // Converts to string + var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.declaration(this, this.options.writer.filterOptions(options)); - } + if (!m) { + throw new TypeError('Invalid Version: ' + version) + } - }; + this.raw = version -}).call(this); + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } -/***/ }), + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } -/***/ 1801: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject; + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = [] + } else { + this.prerelease = m[4].split('.').map(function (id) { + if (/^[0-9]+$/.test(id)) { + var num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } - ({isObject} = __nccwpck_require__(8229)); + this.build = m[5] ? m[5].split('.') : [] + this.format() +} - XMLNode = __nccwpck_require__(7608); +SemVer.prototype.format = function () { + this.version = this.major + '.' + this.minor + '.' + this.patch + if (this.prerelease.length) { + this.version += '-' + this.prerelease.join('.') + } + return this.version +} - NodeType = __nccwpck_require__(9267); +SemVer.prototype.toString = function () { + return this.version +} - XMLDTDAttList = __nccwpck_require__(1015); +SemVer.prototype.compare = function (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } - XMLDTDEntity = __nccwpck_require__(53); + return this.compareMain(other) || this.comparePre(other) +} - XMLDTDElement = __nccwpck_require__(2421); +SemVer.prototype.compareMain = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } - XMLDTDNotation = __nccwpck_require__(2837); + return compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) +} - XMLNamedNodeMap = __nccwpck_require__(4361); +SemVer.prototype.comparePre = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } - // Represents doctype declaration - module.exports = XMLDocType = (function() { - class XMLDocType extends XMLNode { - // Initializes a new instance of `XMLDocType` + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1 + } else if (!this.prerelease.length && other.prerelease.length) { + return 1 + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0 + } - // `parent` the document object + var i = 0 + do { + var a = this.prerelease[i] + var b = other.prerelease[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) +} - // `pubID` public identifier of the external subset - // `sysID` system identifier of the external subset - constructor(parent, pubID, sysID) { - var child, i, len, ref; - super(parent); - this.type = NodeType.DocType; - // set DTD name to the name of the root node - if (parent.children) { - ref = parent.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - if (child.type === NodeType.Element) { - this.name = child.name; - break; - } - } - } - this.documentObject = parent; - // arguments may also be passed as an object - if (isObject(pubID)) { - ({pubID, sysID} = pubID); - } - if (sysID == null) { - [sysID, pubID] = [pubID, sysID]; - } - if (pubID != null) { - this.pubID = this.stringify.dtdPubID(pubID); - } - if (sysID != null) { - this.sysID = this.stringify.dtdSysID(sysID); - } - } +SemVer.prototype.compareBuild = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } - // Creates an element type declaration + var i = 0 + do { + var a = this.build[i] + var b = other.build[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) +} - // `name` element name - // `value` element content (defaults to #PCDATA) - element(name, value) { - var child; - child = new XMLDTDElement(this, name, value); - this.children.push(child); - return this; +// preminor will bump the version up to the next minor release, and immediately +// down to pre-release. premajor and prepatch work the same way. +SemVer.prototype.inc = function (release, identifier) { + switch (release) { + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier) + break + case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0 + this.inc('patch', identifier) + this.inc('pre', identifier) + break + // If the input is a non-prerelease version, this acts the same as + // prepatch. + case 'prerelease': + if (this.prerelease.length === 0) { + this.inc('patch', identifier) } + this.inc('pre', identifier) + break - // Creates an attribute declaration - - // `elementName` the name of the element containing this attribute - // `attributeName` attribute name - // `attributeType` type of the attribute (defaults to CDATA) - // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or - // #DEFAULT) (defaults to #IMPLIED) - // `defaultValue` default value of the attribute - // (only used for #FIXED or #DEFAULT) - attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - var child; - child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); - this.children.push(child); - return this; + case 'major': + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if (this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0) { + this.major++ } - - // Creates a general entity declaration - - // `name` the name of the entity - // `value` internal entity value or an object with external entity details - // `value.pubID` public identifier - // `value.sysID` system identifier - // `value.nData` notation declaration - entity(name, value) { - var child; - child = new XMLDTDEntity(this, false, name, value); - this.children.push(child); - return this; + this.minor = 0 + this.patch = 0 + this.prerelease = [] + break + case 'minor': + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++ } - - // Creates a parameter entity declaration - - // `name` the name of the entity - // `value` internal entity value or an object with external entity details - // `value.pubID` public identifier - // `value.sysID` system identifier - pEntity(name, value) { - var child; - child = new XMLDTDEntity(this, true, name, value); - this.children.push(child); - return this; + this.patch = 0 + this.prerelease = [] + break + case 'patch': + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++ } - - // Creates a NOTATION declaration - - // `name` the name of the notation - // `value` an object with external entity details - // `value.pubID` public identifier - // `value.sysID` system identifier - notation(name, value) { - var child; - child = new XMLDTDNotation(this, name, value); - this.children.push(child); - return this; + this.prerelease = [] + break + // This probably shouldn't be used publicly. + // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction. + case 'pre': + if (this.prerelease.length === 0) { + this.prerelease = [0] + } else { + var i = this.prerelease.length + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++ + i = -2 + } + } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0) + } } - - // Converts to string - - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.docType(this, this.options.writer.filterOptions(options)); + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0] + } + } else { + this.prerelease = [identifier, 0] + } } + break - // Aliases - ele(name, value) { - return this.element(name, value); - } + default: + throw new Error('invalid increment argument: ' + release) + } + this.format() + this.raw = this.version + return this +} - att(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); - } +exports.inc = inc +function inc (version, release, loose, identifier) { + if (typeof (loose) === 'string') { + identifier = loose + loose = undefined + } - ent(name, value) { - return this.entity(name, value); - } + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } +} - pent(name, value) { - return this.pEntity(name, value); +exports.diff = diff +function diff (version1, version2) { + if (eq(version1, version2)) { + return null + } else { + var v1 = parse(version1) + var v2 = parse(version2) + var prefix = '' + if (v1.prerelease.length || v2.prerelease.length) { + prefix = 'pre' + var defaultResult = 'prerelease' + } + for (var key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key + } } + } + return defaultResult // may be undefined + } +} - not(name, value) { - return this.notation(name, value); - } +exports.compareIdentifiers = compareIdentifiers - up() { - return this.root() || this.documentObject; - } +var numeric = /^[0-9]+$/ +function compareIdentifiers (a, b) { + var anum = numeric.test(a) + var bnum = numeric.test(b) - isEqualNode(node) { - if (!super.isEqualNode(node)) { - return false; - } - if (node.name !== this.name) { - return false; - } - if (node.publicId !== this.publicId) { - return false; - } - if (node.systemId !== this.systemId) { - return false; - } - return true; - } + if (anum && bnum) { + a = +a + b = +b + } - }; + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +} - // DOM level 1 - Object.defineProperty(XMLDocType.prototype, 'entities', { - get: function() { - var child, i, len, nodes, ref; - nodes = {}; - ref = this.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - if ((child.type === NodeType.EntityDeclaration) && !child.pe) { - nodes[child.name] = child; - } - } - return new XMLNamedNodeMap(nodes); - } - }); +exports.rcompareIdentifiers = rcompareIdentifiers +function rcompareIdentifiers (a, b) { + return compareIdentifiers(b, a) +} - Object.defineProperty(XMLDocType.prototype, 'notations', { - get: function() { - var child, i, len, nodes, ref; - nodes = {}; - ref = this.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - if (child.type === NodeType.NotationDeclaration) { - nodes[child.name] = child; - } - } - return new XMLNamedNodeMap(nodes); - } - }); +exports.major = major +function major (a, loose) { + return new SemVer(a, loose).major +} - // DOM level 2 - Object.defineProperty(XMLDocType.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); +exports.minor = minor +function minor (a, loose) { + return new SemVer(a, loose).minor +} - Object.defineProperty(XMLDocType.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); +exports.patch = patch +function patch (a, loose) { + return new SemVer(a, loose).patch +} - Object.defineProperty(XMLDocType.prototype, 'internalSubset', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +exports.compare = compare +function compare (a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) +} - return XMLDocType; +exports.compareLoose = compareLoose +function compareLoose (a, b) { + return compare(a, b, true) +} - }).call(this); +exports.compareBuild = compareBuild +function compareBuild (a, b, loose) { + var versionA = new SemVer(a, loose) + var versionB = new SemVer(b, loose) + return versionA.compare(versionB) || versionA.compareBuild(versionB) +} -}).call(this); +exports.rcompare = rcompare +function rcompare (a, b, loose) { + return compare(b, a, loose) +} +exports.sort = sort +function sort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(a, b, loose) + }) +} -/***/ }), +exports.rsort = rsort +function rsort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(b, a, loose) + }) +} -/***/ 3730: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject; - - ({isPlainObject} = __nccwpck_require__(8229)); - - XMLDOMImplementation = __nccwpck_require__(8310); - - XMLDOMConfiguration = __nccwpck_require__(7465); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - XMLStringifier = __nccwpck_require__(8594); - - XMLStringWriter = __nccwpck_require__(5913); - - // Represents an XML builder - module.exports = XMLDocument = (function() { - class XMLDocument extends XMLNode { - // Initializes a new instance of `XMLDocument` - - // `options.keepNullNodes` whether nodes with null values will be kept - // or ignored: true or false - // `options.keepNullAttributes` whether attributes with null values will be - // kept or ignored: true or false - // `options.ignoreDecorators` whether decorator strings will be ignored when - // converting JS objects: true or false - // `options.separateArrayItems` whether array items are created as separate - // nodes when passed as an object value: true or false - // `options.noDoubleEncoding` whether existing html entities are encoded: - // true or false - // `options.stringify` a set of functions to use for converting values to - // strings - // `options.writer` the default XML writer to use for converting nodes to - // string. If the default writer is not set, the built-in XMLStringWriter - // will be used instead. - constructor(options) { - super(null); - this.name = "#document"; - this.type = NodeType.Document; - this.documentURI = null; - this.domConfig = new XMLDOMConfiguration(); - options || (options = {}); - if (!options.writer) { - options.writer = new XMLStringWriter(); - } - this.options = options; - this.stringify = new XMLStringifier(options); - } +exports.gt = gt +function gt (a, b, loose) { + return compare(a, b, loose) > 0 +} - // Ends the document and passes it to the given XML writer - - // `writer` is either an XML writer or a plain object to pass to the - // constructor of the default XML writer. The default writer is assigned when - // creating the XML document. Following flags are recognized by the - // built-in XMLStringWriter: - // `writer.pretty` pretty prints the result - // `writer.indent` indentation for pretty print - // `writer.offset` how many indentations to add to every line for pretty print - // `writer.newline` newline sequence for pretty print - end(writer) { - var writerOptions; - writerOptions = {}; - if (!writer) { - writer = this.options.writer; - } else if (isPlainObject(writer)) { - writerOptions = writer; - writer = this.options.writer; - } - return writer.document(this, writer.filterOptions(writerOptions)); - } +exports.lt = lt +function lt (a, b, loose) { + return compare(a, b, loose) < 0 +} - // Converts the XML document to string +exports.eq = eq +function eq (a, b, loose) { + return compare(a, b, loose) === 0 +} - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.document(this, this.options.writer.filterOptions(options)); - } +exports.neq = neq +function neq (a, b, loose) { + return compare(a, b, loose) !== 0 +} - // DOM level 1 functions to be implemented later - createElement(tagName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +exports.gte = gte +function gte (a, b, loose) { + return compare(a, b, loose) >= 0 +} - createDocumentFragment() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +exports.lte = lte +function lte (a, b, loose) { + return compare(a, b, loose) <= 0 +} - createTextNode(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +exports.cmp = cmp +function cmp (a, op, b, loose) { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a === b - createComment(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b - createCDATASection(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + case '': + case '=': + case '==': + return eq(a, b, loose) - createProcessingInstruction(target, data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + case '!=': + return neq(a, b, loose) - createAttribute(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + case '>': + return gt(a, b, loose) - createEntityReference(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + case '>=': + return gte(a, b, loose) - getElementsByTagName(tagname) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + case '<': + return lt(a, b, loose) - // DOM level 2 functions to be implemented later - importNode(importedNode, deep) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + case '<=': + return lte(a, b, loose) - createElementNS(namespaceURI, qualifiedName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + default: + throw new TypeError('Invalid operator: ' + op) + } +} - createAttributeNS(namespaceURI, qualifiedName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +exports.Comparator = Comparator +function Comparator (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } - getElementsByTagNameNS(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } - getElementById(elementId) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + if (!(this instanceof Comparator)) { + return new Comparator(comp, options) + } - // DOM level 3 functions to be implemented later - adoptNode(source) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + debug('comparator', comp, options) + this.options = options + this.loose = !!options.loose + this.parse(comp) - normalizeDocument() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + if (this.semver === ANY) { + this.value = '' + } else { + this.value = this.operator + this.semver.version + } - renameNode(node, namespaceURI, qualifiedName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + debug('comp', this) +} - // DOM level 4 functions to be implemented later - getElementsByClassName(classNames) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +var ANY = {} +Comparator.prototype.parse = function (comp) { + var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var m = comp.match(r) - createEvent(eventInterface) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + if (!m) { + throw new TypeError('Invalid comparator: ' + comp) + } - createRange() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } - createNodeIterator(root, whatToShow, filter) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY + } else { + this.semver = new SemVer(m[2], this.options.loose) + } +} - createTreeWalker(root, whatToShow, filter) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +Comparator.prototype.toString = function () { + return this.value +} - }; +Comparator.prototype.test = function (version) { + debug('Comparator.test', version, this.options.loose) - // DOM level 1 - Object.defineProperty(XMLDocument.prototype, 'implementation', { - value: new XMLDOMImplementation() - }); + if (this.semver === ANY || version === ANY) { + return true + } - Object.defineProperty(XMLDocument.prototype, 'doctype', { - get: function() { - var child, i, len, ref; - ref = this.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - if (child.type === NodeType.DocType) { - return child; - } - } - return null; - } - }); + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } - Object.defineProperty(XMLDocument.prototype, 'documentElement', { - get: function() { - return this.rootObject || null; - } - }); + return cmp(version, this.operator, this.semver, this.options) +} - // DOM level 3 - Object.defineProperty(XMLDocument.prototype, 'inputEncoding', { - get: function() { - return null; - } - }); +Comparator.prototype.intersects = function (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } - Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', { - get: function() { - return false; - } - }); + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } - Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].encoding; - } else { - return null; - } - } - }); + var rangeTmp - Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].standalone === 'yes'; - } else { - return false; - } - } - }); + if (this.operator === '') { + if (this.value === '') { + return true + } + rangeTmp = new Range(comp.value, options) + return satisfies(this.value, rangeTmp, options) + } else if (comp.operator === '') { + if (comp.value === '') { + return true + } + rangeTmp = new Range(this.value, options) + return satisfies(comp.semver, rangeTmp, options) + } - Object.defineProperty(XMLDocument.prototype, 'xmlVersion', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].version; - } else { - return "1.0"; - } - } - }); + var sameDirectionIncreasing = + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '>=' || comp.operator === '>') + var sameDirectionDecreasing = + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '<=' || comp.operator === '<') + var sameSemVer = this.semver.version === comp.semver.version + var differentDirectionsInclusive = + (this.operator === '>=' || this.operator === '<=') && + (comp.operator === '>=' || comp.operator === '<=') + var oppositeDirectionsLessThan = + cmp(this.semver, '<', comp.semver, options) && + ((this.operator === '>=' || this.operator === '>') && + (comp.operator === '<=' || comp.operator === '<')) + var oppositeDirectionsGreaterThan = + cmp(this.semver, '>', comp.semver, options) && + ((this.operator === '<=' || this.operator === '<') && + (comp.operator === '>=' || comp.operator === '>')) - // DOM level 4 - Object.defineProperty(XMLDocument.prototype, 'URL', { - get: function() { - return this.documentURI; - } - }); + return sameDirectionIncreasing || sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || oppositeDirectionsGreaterThan +} - Object.defineProperty(XMLDocument.prototype, 'origin', { - get: function() { - return null; - } - }); +exports.Range = Range +function Range (range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } - Object.defineProperty(XMLDocument.prototype, 'compatMode', { - get: function() { - return null; - } - }); + if (range instanceof Range) { + if (range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease) { + return range + } else { + return new Range(range.raw, options) + } + } - Object.defineProperty(XMLDocument.prototype, 'characterSet', { - get: function() { - return null; - } - }); + if (range instanceof Comparator) { + return new Range(range.value, options) + } - Object.defineProperty(XMLDocument.prototype, 'contentType', { - get: function() { - return null; - } - }); + if (!(this instanceof Range)) { + return new Range(range, options) + } - return XMLDocument; + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease - }).call(this); + // First, split based on boolean or || + this.raw = range + this.set = range.split(/\s*\|\|\s*/).map(function (range) { + return this.parseRange(range.trim()) + }, this).filter(function (c) { + // throw out any that are not relevant for whatever reason + return c.length + }) -}).call(this); + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range) + } + this.format() +} -/***/ }), +Range.prototype.format = function () { + this.range = this.set.map(function (comps) { + return comps.join(' ').trim() + }).join('||').trim() + return this.range +} -/***/ 7356: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +Range.prototype.toString = function () { + return this.range +} -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject, - hasProp = {}.hasOwnProperty; +Range.prototype.parseRange = function (range) { + var loose = this.options.loose + range = range.trim() + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] + range = range.replace(hr, hyphenReplace) + debug('hyphen replace', range) + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range, re[t.COMPARATORTRIM]) - ({isObject, isFunction, isPlainObject, getValue} = __nccwpck_require__(8229)); + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[t.TILDETRIM], tildeTrimReplace) - NodeType = __nccwpck_require__(9267); + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[t.CARETTRIM], caretTrimReplace) - XMLDocument = __nccwpck_require__(3730); + // normalize spaces + range = range.split(/\s+/).join(' ') - XMLElement = __nccwpck_require__(9437); + // At this point, the range is completely trimmed and + // ready to be split into comparators. - XMLCData = __nccwpck_require__(333); + var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var set = range.split(' ').map(function (comp) { + return parseComparator(comp, this.options) + }, this).join(' ').split(/\s+/) + if (this.options.loose) { + // in loose mode, throw out any that are not valid comparators + set = set.filter(function (comp) { + return !!comp.match(compRe) + }) + } + set = set.map(function (comp) { + return new Comparator(comp, this.options) + }, this) - XMLComment = __nccwpck_require__(4407); + return set +} - XMLRaw = __nccwpck_require__(6329); +Range.prototype.intersects = function (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } - XMLText = __nccwpck_require__(1318); + return this.set.some(function (thisComparators) { + return ( + isSatisfiable(thisComparators, options) && + range.set.some(function (rangeComparators) { + return ( + isSatisfiable(rangeComparators, options) && + thisComparators.every(function (thisComparator) { + return rangeComparators.every(function (rangeComparator) { + return thisComparator.intersects(rangeComparator, options) + }) + }) + ) + }) + ) + }) +} - XMLProcessingInstruction = __nccwpck_require__(6939); +// take a set of comparators and determine whether there +// exists a version which can satisfy it +function isSatisfiable (comparators, options) { + var result = true + var remainingComparators = comparators.slice() + var testComparator = remainingComparators.pop() - XMLDeclaration = __nccwpck_require__(6364); + while (result && remainingComparators.length) { + result = remainingComparators.every(function (otherComparator) { + return testComparator.intersects(otherComparator, options) + }) - XMLDocType = __nccwpck_require__(1801); + testComparator = remainingComparators.pop() + } - XMLDTDAttList = __nccwpck_require__(1015); + return result +} - XMLDTDEntity = __nccwpck_require__(53); +// Mostly just for testing and legacy API reasons +exports.toComparators = toComparators +function toComparators (range, options) { + return new Range(range, options).set.map(function (comp) { + return comp.map(function (c) { + return c.value + }).join(' ').trim().split(' ') + }) +} - XMLDTDElement = __nccwpck_require__(2421); +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +function parseComparator (comp, options) { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp +} - XMLDTDNotation = __nccwpck_require__(2837); +function isX (id) { + return !id || id.toLowerCase() === 'x' || id === '*' +} - XMLAttribute = __nccwpck_require__(8376); +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 +function replaceTildes (comp, options) { + return comp.trim().split(/\s+/).map(function (comp) { + return replaceTilde(comp, options) + }).join(' ') +} - XMLStringifier = __nccwpck_require__(8594); +function replaceTilde (comp, options) { + var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] + return comp.replace(r, function (_, M, m, p, pr) { + debug('tilde', comp, _, M, m, p, pr) + var ret - XMLStringWriter = __nccwpck_require__(5913); + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0 + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else if (pr) { + debug('replaceTilde pr', pr) + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + } else { + // ~1.2.3 == >=1.2.3 <1.3.0 + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + (+m + 1) + '.0' + } - WriterState = __nccwpck_require__(9766); + debug('tilde return', ret) + return ret + }) +} - // Represents an XML builder - module.exports = XMLDocumentCB = class XMLDocumentCB { - // Initializes a new instance of `XMLDocumentCB` +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 +// ^1.2.3 --> >=1.2.3 <2.0.0 +// ^1.2.0 --> >=1.2.0 <2.0.0 +function replaceCarets (comp, options) { + return comp.trim().split(/\s+/).map(function (comp) { + return replaceCaret(comp, options) + }).join(' ') +} - // `options.keepNullNodes` whether nodes with null values will be kept - // or ignored: true or false - // `options.keepNullAttributes` whether attributes with null values will be - // kept or ignored: true or false - // `options.ignoreDecorators` whether decorator strings will be ignored when - // converting JS objects: true or false - // `options.separateArrayItems` whether array items are created as separate - // nodes when passed as an object value: true or false - // `options.noDoubleEncoding` whether existing html entities are encoded: - // true or false - // `options.stringify` a set of functions to use for converting values to - // strings - // `options.writer` the default XML writer to use for converting nodes to - // string. If the default writer is not set, the built-in XMLStringWriter - // will be used instead. +function replaceCaret (comp, options) { + debug('caret', comp, options) + var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] + return comp.replace(r, function (_, M, m, p, pr) { + debug('caret', comp, _, M, m, p, pr) + var ret - // `onData` the function to be called when a new chunk of XML is output. The - // string containing the XML chunk is passed to `onData` as its first - // argument, and the current indentation level as its second argument. - // `onEnd` the function to be called when the XML document is completed with - // `end`. `onEnd` does not receive any arguments. - constructor(options, onData, onEnd) { - var writerOptions; - this.name = "?xml"; - this.type = NodeType.Document; - options || (options = {}); - writerOptions = {}; - if (!options.writer) { - options.writer = new XMLStringWriter(); - } else if (isPlainObject(options.writer)) { - writerOptions = options.writer; - options.writer = new XMLStringWriter(); + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + if (M === '0') { + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else { + ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' } - this.options = options; - this.writer = options.writer; - this.writerOptions = this.writer.filterOptions(writerOptions); - this.stringify = new XMLStringifier(options); - this.onDataCallback = onData || function() {}; - this.onEndCallback = onEnd || function() {}; - this.currentNode = null; - this.currentLevel = -1; - this.openTags = {}; - this.documentStarted = false; - this.documentCompleted = false; - this.root = null; - } - - // Creates a child element node from the given XMLNode - - // `node` the child node - createChildNode(node) { - var att, attName, attributes, child, i, len, ref, ref1; - switch (node.type) { - case NodeType.CData: - this.cdata(node.value); - break; - case NodeType.Comment: - this.comment(node.value); - break; - case NodeType.Element: - attributes = {}; - ref = node.attribs; - for (attName in ref) { - if (!hasProp.call(ref, attName)) continue; - att = ref[attName]; - attributes[attName] = att.value; - } - this.node(node.name, attributes); - break; - case NodeType.Dummy: - this.dummy(); - break; - case NodeType.Raw: - this.raw(node.value); - break; - case NodeType.Text: - this.text(node.value); - break; - case NodeType.ProcessingInstruction: - this.instruction(node.target, node.value); - break; - default: - throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name); + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + m + '.' + (+p + 1) + } else { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + } + } else { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + (+M + 1) + '.0.0' } - ref1 = node.children; - // write child nodes recursively - for (i = 0, len = ref1.length; i < len; i++) { - child = ref1[i]; - this.createChildNode(child); - if (child.type === NodeType.Element) { - this.up(); + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + m + '.' + (+p + 1) + } else { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + (+m + 1) + '.0' } + } else { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + (+M + 1) + '.0.0' } - return this; } - // Creates a dummy node + debug('caret return', ret) + return ret + }) +} - dummy() { - // no-op, just return this - return this; - } +function replaceXRanges (comp, options) { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map(function (comp) { + return replaceXRange(comp, options) + }).join(' ') +} - // Creates a node +function replaceXRange (comp, options) { + comp = comp.trim() + var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] + return comp.replace(r, function (ret, gtlt, M, m, p, pr) { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + var xM = isX(M) + var xm = xM || isX(m) + var xp = xm || isX(p) + var anyX = xp - // `name` name of the node - // `attributes` an object containing name/value pairs of attributes - // `text` element text - node(name, attributes, text) { - if (name == null) { - throw new Error("Missing node name."); - } - if (this.root && this.currentLevel === -1) { - throw new Error("Document can only have one root node. " + this.debugInfo(name)); - } - this.openCurrent(); - name = getValue(name); - if (attributes == null) { - attributes = {}; - } - attributes = getValue(attributes); - // swap argument order: text <-> attributes - if (!isObject(attributes)) { - [text, attributes] = [attributes, text]; - } - this.currentNode = new XMLElement(this, name, attributes); - this.currentNode.children = false; - this.currentLevel++; - this.openTags[this.currentLevel] = this.currentNode; - if (text != null) { - this.text(text); - } - return this; + if (gtlt === '=' && anyX) { + gtlt = '' } - // Creates a child element node or an element type declaration when called - // inside the DTD + // if we're including prereleases in the match, then we need + // to fix this to -0, the lowest possible prerelease value + pr = options.includePrerelease ? '-0' : '' - // `name` name of the node - // `attributes` an object containing name/value pairs of attributes - // `text` element text - element(name, attributes, text) { - var child, i, len, oldValidationFlag, ref, root; - if (this.currentNode && this.currentNode.type === NodeType.DocType) { - this.dtdElement(...arguments); + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0-0' } else { - if (Array.isArray(name) || isObject(name) || isFunction(name)) { - oldValidationFlag = this.options.noValidation; - this.options.noValidation = true; - root = new XMLDocument(this.options).element('TEMP_ROOT'); - root.element(name); - this.options.noValidation = oldValidationFlag; - ref = root.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - this.createChildNode(child); - if (child.type === NodeType.Element) { - this.up(); - } - } - } else { - this.node(name, attributes, text); - } - } - return this; - } - - // Adds or modifies an attribute - - // `name` attribute name - // `value` attribute value - attribute(name, value) { - var attName, attValue; - if (!this.currentNode || this.currentNode.children) { - throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name)); + // nothing is forbidden + ret = '*' } - if (name != null) { - name = getValue(name); + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0 } - if (isObject(name)) { // expand if object - for (attName in name) { - if (!hasProp.call(name, attName)) continue; - attValue = name[attName]; - this.attribute(attName, attValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); + p = 0 + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + // >1.2.3 => >= 1.2.4 + gtlt = '>=' + if (xm) { + M = +M + 1 + m = 0 + p = 0 + } else { + m = +m + 1 + p = 0 } - if (this.options.keepNullAttributes && (value == null)) { - this.currentNode.attribs[name] = new XMLAttribute(this, name, ""); - } else if (value != null) { - this.currentNode.attribs[name] = new XMLAttribute(this, name, value); + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) { + M = +M + 1 + } else { + m = +m + 1 } } - return this; - } - - // Creates a text node - - // `value` element text - text(value) { - var node; - this.openCurrent(); - node = new XMLText(this, value); - this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; - } - - // Creates a CDATA node - // `value` element text without CDATA delimiters - cdata(value) { - var node; - this.openCurrent(); - node = new XMLCData(this, value); - this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; + ret = gtlt + M + '.' + m + '.' + p + pr + } else if (xm) { + ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr + } else if (xp) { + ret = '>=' + M + '.' + m + '.0' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + pr } - // Creates a comment node + debug('xRange return', ret) - // `value` comment text - comment(value) { - var node; - this.openCurrent(); - node = new XMLComment(this, value); - this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; - } + return ret + }) +} - // Adds unescaped raw text +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +function replaceStars (comp, options) { + debug('replaceStars', comp, options) + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[t.STAR], '') +} - // `value` text - raw(value) { - var node; - this.openCurrent(); - node = new XMLRaw(this, value); - this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; - } +// This function is passed to string.replace(re[t.HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0 +function hyphenReplace ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = '>=' + fM + '.0.0' + } else if (isX(fp)) { + from = '>=' + fM + '.' + fm + '.0' + } else { + from = '>=' + from + } - // Adds a processing instruction + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = '<' + (+tM + 1) + '.0.0' + } else if (isX(tp)) { + to = '<' + tM + '.' + (+tm + 1) + '.0' + } else if (tpr) { + to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr + } else { + to = '<=' + to + } - // `target` instruction target - // `value` instruction value - instruction(target, value) { - var i, insTarget, insValue, len, node; - this.openCurrent(); - if (target != null) { - target = getValue(target); - } - if (value != null) { - value = getValue(value); - } - if (Array.isArray(target)) { // expand if array - for (i = 0, len = target.length; i < len; i++) { - insTarget = target[i]; - this.instruction(insTarget); - } - } else if (isObject(target)) { // expand if object - for (insTarget in target) { - if (!hasProp.call(target, insTarget)) continue; - insValue = target[insTarget]; - this.instruction(insTarget, insValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - node = new XMLProcessingInstruction(this, target, value); - this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - } - return this; - } + return (from + ' ' + to).trim() +} - // Creates the xml declaration +// if ANY of the sets match ALL of its comparators, then pass +Range.prototype.test = function (version) { + if (!version) { + return false + } - // `version` A version number string, e.g. 1.0 - // `encoding` Encoding declaration, e.g. UTF-8 - // `standalone` standalone document declaration: true or false - declaration(version, encoding, standalone) { - var node; - this.openCurrent(); - if (this.documentStarted) { - throw new Error("declaration() must be the first node."); - } - node = new XMLDeclaration(this, version, encoding, standalone); - this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false } + } - // Creates the document type declaration - - // `root` the name of the root node - // `pubID` the public identifier of the external subset - // `sysID` the system identifier of the external subset - doctype(root, pubID, sysID) { - this.openCurrent(); - if (root == null) { - throw new Error("Missing root node name."); - } - if (this.root) { - throw new Error("dtd() must come before the root node."); - } - this.currentNode = new XMLDocType(this, pubID, sysID); - this.currentNode.rootNodeName = root; - this.currentNode.children = false; - this.currentLevel++; - this.openTags[this.currentLevel] = this.currentNode; - return this; - } - - // Creates an element type declaration - - // `name` element name - // `value` element content (defaults to #PCDATA) - dtdElement(name, value) { - var node; - this.openCurrent(); - node = new XMLDTDElement(this, name, value); - this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; - } - - // Creates an attribute declaration - - // `elementName` the name of the element containing this attribute - // `attributeName` attribute name - // `attributeType` type of the attribute (defaults to CDATA) - // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or - // #DEFAULT) (defaults to #IMPLIED) - // `defaultValue` default value of the attribute - // (only used for #FIXED or #DEFAULT) - attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - var node; - this.openCurrent(); - node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); - this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; - } - - // Creates a general entity declaration - - // `name` the name of the entity - // `value` internal entity value or an object with external entity details - // `value.pubID` public identifier - // `value.sysID` system identifier - // `value.nData` notation declaration - entity(name, value) { - var node; - this.openCurrent(); - node = new XMLDTDEntity(this, false, name, value); - this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; - } - - // Creates a parameter entity declaration - - // `name` the name of the entity - // `value` internal entity value or an object with external entity details - // `value.pubID` public identifier - // `value.sysID` system identifier - pEntity(name, value) { - var node; - this.openCurrent(); - node = new XMLDTDEntity(this, true, name, value); - this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; - } - - // Creates a NOTATION declaration - - // `name` the name of the notation - // `value` an object with external entity details - // `value.pubID` public identifier - // `value.sysID` system identifier - notation(name, value) { - var node; - this.openCurrent(); - node = new XMLDTDNotation(this, name, value); - this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - return this; - } - - // Gets the parent node - up() { - if (this.currentLevel < 0) { - throw new Error("The document node has no parent."); - } - if (this.currentNode) { - if (this.currentNode.children) { - this.closeNode(this.currentNode); - } else { - this.openNode(this.currentNode); - } - this.currentNode = null; - } else { - this.closeNode(this.openTags[this.currentLevel]); - } - delete this.openTags[this.currentLevel]; - this.currentLevel--; - return this; + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true } + } + return false +} - // Ends the document - end() { - while (this.currentLevel >= 0) { - this.up(); - } - return this.onEnd(); +function testSet (set, version, options) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false } + } - // Opens the current parent node - openCurrent() { - if (this.currentNode) { - this.currentNode.children = true; - return this.openNode(this.currentNode); + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === ANY) { + continue } - } - // Writes the opening tag of the current node or the entire node if it has - // no child nodes - openNode(node) { - var att, chunk, name, ref; - if (!node.isOpen) { - if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) { - this.root = node; - } - chunk = ''; - if (node.type === NodeType.Element) { - this.writerOptions.state = WriterState.OpenTag; - chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name; - ref = node.attribs; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - att = ref[name]; - chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel); - } - chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel); - this.writerOptions.state = WriterState.InsideTag; // if node.type is NodeType.DocType - } else { - this.writerOptions.state = WriterState.OpenTag; - chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ''; - } - chunk += this.writer.endline(node, this.writerOptions, this.currentLevel); + if (set[i].semver.prerelease.length > 0) { + var allowed = set[i].semver + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true } - this.onData(chunk, this.currentLevel); - return node.isOpen = true; } } - // Writes the closing tag of the current node - closeNode(node) { - var chunk; - if (!node.isClosed) { - chunk = ''; - this.writerOptions.state = WriterState.CloseTag; - if (node.type === NodeType.Element) { - chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '' + this.writer.endline(node, this.writerOptions, this.currentLevel); // if node.type is NodeType.DocType - } else { - chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel); - } - this.writerOptions.state = WriterState.None; - this.onData(chunk, this.currentLevel); - return node.isClosed = true; - } - } + // Version has a -pre, but it's not one of the ones we like. + return false + } - // Called when a new chunk of XML is output + return true +} - // `chunk` a string containing the XML chunk - // `level` current indentation level - onData(chunk, level) { - this.documentStarted = true; - return this.onDataCallback(chunk, level + 1); - } +exports.satisfies = satisfies +function satisfies (version, range, options) { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) +} - // Called when the XML document is completed - onEnd() { - this.documentCompleted = true; - return this.onEndCallback(); +exports.maxSatisfying = maxSatisfying +function maxSatisfying (versions, range, options) { + var max = null + var maxSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach(function (v) { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } } + }) + return max +} - // Returns debug string - debugInfo(name) { - if (name == null) { - return ""; - } else { - return "node: <" + name + ">"; +exports.minSatisfying = minSatisfying +function minSatisfying (versions, range, options) { + var min = null + var minSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach(function (v) { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) } } + }) + return min +} - // Node aliases - ele() { - return this.element(...arguments); - } +exports.minVersion = minVersion +function minVersion (range, loose) { + range = new Range(range, loose) - nod(name, attributes, text) { - return this.node(name, attributes, text); - } + var minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } - txt(value) { - return this.text(value); - } + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } - dat(value) { - return this.cdata(value); - } + minver = null + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] - com(value) { - return this.comment(value); - } + comparators.forEach(function (comparator) { + // Clone to avoid manipulating the comparator's semver object. + var compver = new SemVer(comparator.semver.version) + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++ + } else { + compver.prerelease.push(0) + } + compver.raw = compver.format() + /* fallthrough */ + case '': + case '>=': + if (!minver || gt(minver, compver)) { + minver = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error('Unexpected operation: ' + comparator.operator) + } + }) + } - ins(target, value) { - return this.instruction(target, value); - } + if (minver && range.test(minver)) { + return minver + } - dec(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); - } + return null +} - dtd(root, pubID, sysID) { - return this.doctype(root, pubID, sysID); - } +exports.validRange = validRange +function validRange (range, options) { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' + } catch (er) { + return null + } +} - e(name, attributes, text) { - return this.element(name, attributes, text); - } +// Determine if version is less than all the versions possible in the range +exports.ltr = ltr +function ltr (version, range, options) { + return outside(version, range, '<', options) +} - n(name, attributes, text) { - return this.node(name, attributes, text); - } +// Determine if version is greater than all the versions possible in the range. +exports.gtr = gtr +function gtr (version, range, options) { + return outside(version, range, '>', options) +} + +exports.outside = outside +function outside (version, range, hilo, options) { + version = new SemVer(version, options) + range = new Range(range, options) - t(value) { - return this.text(value); - } + var gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } - d(value) { - return this.cdata(value); - } + // If it satisifes the range it is not outside + if (satisfies(version, range, options)) { + return false + } - c(value) { - return this.comment(value); - } + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. - r(value) { - return this.raw(value); - } + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] - i(target, value) { - return this.instruction(target, value); - } + var high = null + var low = null - // Attribute aliases - att() { - if (this.currentNode && this.currentNode.type === NodeType.DocType) { - return this.attList(...arguments); - } else { - return this.attribute(...arguments); + comparators.forEach(function (comparator) { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.0') } - } - - a() { - if (this.currentNode && this.currentNode.type === NodeType.DocType) { - return this.attList(...arguments); - } else { - return this.attribute(...arguments); + high = high || comparator + low = low || comparator + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator } - } - - // DTD aliases - // att() and ele() are defined above - ent(name, value) { - return this.entity(name, value); - } + }) - pent(name, value) { - return this.pEntity(name, value); + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false } - not(name, value) { - return this.notation(name, value); + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false } + } + return true +} - }; - -}).call(this); - - -/***/ }), - -/***/ 3590: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLDummy, XMLNode; - - XMLNode = __nccwpck_require__(7608); +exports.prerelease = prerelease +function prerelease (version, options) { + var parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} - NodeType = __nccwpck_require__(9267); +exports.intersects = intersects +function intersects (r1, r2, options) { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) +} - // Represents a raw node - module.exports = XMLDummy = class XMLDummy extends XMLNode { - // Initializes a new instance of `XMLDummy` +exports.coerce = coerce +function coerce (version, options) { + if (version instanceof SemVer) { + return version + } - // `XMLDummy` is a special node representing a node with - // a null value. Dummy nodes are created while recursively - // building the XML tree. Simply skipping null values doesn't - // work because that would break the recursive chain. - constructor(parent) { - super(parent); - this.type = NodeType.Dummy; - } + if (typeof version === 'number') { + version = String(version) + } - // Creates and returns a deep clone of `this` - clone() { - return Object.create(this); - } + if (typeof version !== 'string') { + return null + } - // Converts the XML fragment to string + options = options || {} - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return ''; + var match = null + if (!options.rtl) { + match = version.match(re[t.COERCE]) + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + var next + while ((next = re[t.COERCERTL].exec(version)) && + (!match || match.index + match[0].length !== version.length) + ) { + if (!match || + next.index + next[0].length !== match.index + match[0].length) { + match = next + } + re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length } + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 + } - }; + if (match === null) { + return null + } -}).call(this); + return parse(match[2] + + '.' + (match[3] || '0') + + '.' + (match[4] || '0'), options) +} /***/ }), -/***/ 9437: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject, - hasProp = {}.hasOwnProperty; +/***/ 7032: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - ({isObject, isFunction, getValue} = __nccwpck_require__(8229)); +"use strict"; - XMLNode = __nccwpck_require__(7608); +var shebangRegex = __nccwpck_require__(2638); - NodeType = __nccwpck_require__(9267); +module.exports = function (str) { + var match = str.match(shebangRegex); - XMLAttribute = __nccwpck_require__(8376); + if (!match) { + return null; + } - XMLNamedNodeMap = __nccwpck_require__(4361); + var arr = match[0].replace(/#! ?/, '').split(' '); + var bin = arr[0].split('/').pop(); + var arg = arr[1]; - // Represents an element of the XML document - module.exports = XMLElement = (function() { - class XMLElement extends XMLNode { - // Initializes a new instance of `XMLElement` + return (bin === 'env' ? + arg : + bin + (arg ? ' ' + arg : '') + ); +}; - // `parent` the parent node - // `name` element name - // `attributes` an object containing name/value pairs of attributes - constructor(parent, name, attributes) { - var child, j, len, ref; - super(parent); - if (name == null) { - throw new Error("Missing element name. " + this.debugInfo()); - } - this.name = this.stringify.name(name); - this.type = NodeType.Element; - this.attribs = {}; - this.schemaTypeInfo = null; - if (attributes != null) { - this.attribute(attributes); - } - // set properties if this is the root node - if (parent.type === NodeType.Document) { - this.isRoot = true; - this.documentObject = parent; - parent.rootObject = this; - // set dtd name - if (parent.children) { - ref = parent.children; - for (j = 0, len = ref.length; j < len; j++) { - child = ref[j]; - if (child.type === NodeType.DocType) { - child.name = this.name; - break; - } - } - } - } - } - // Creates and returns a deep clone of `this` +/***/ }), - clone() { - var att, attName, clonedSelf, ref; - clonedSelf = Object.create(this); - // remove document element - if (clonedSelf.isRoot) { - clonedSelf.documentObject = null; - } - // clone attributes - clonedSelf.attribs = {}; - ref = this.attribs; - for (attName in ref) { - if (!hasProp.call(ref, attName)) continue; - att = ref[attName]; - clonedSelf.attribs[attName] = att.clone(); - } - // clone child nodes - clonedSelf.children = []; - this.children.forEach(function(child) { - var clonedChild; - clonedChild = child.clone(); - clonedChild.parent = clonedSelf; - return clonedSelf.children.push(clonedChild); - }); - return clonedSelf; - } +/***/ 2638: +/***/ ((module) => { - // Adds or modifies an attribute +"use strict"; - // `name` attribute name - // `value` attribute value - attribute(name, value) { - var attName, attValue; - if (name != null) { - name = getValue(name); - } - if (isObject(name)) { // expand if object - for (attName in name) { - if (!hasProp.call(name, attName)) continue; - attValue = name[attName]; - this.attribute(attName, attValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - if (this.options.keepNullAttributes && (value == null)) { - this.attribs[name] = new XMLAttribute(this, name, ""); - } else if (value != null) { - this.attribs[name] = new XMLAttribute(this, name, value); - } - } - return this; - } +module.exports = /^#!.*/; - // Removes an attribute - // `name` attribute name - removeAttribute(name) { - var attName, j, len; - // Also defined in DOM level 1 - // removeAttribute(name) removes an attribute by name. - if (name == null) { - throw new Error("Missing attribute name. " + this.debugInfo()); - } - name = getValue(name); - if (Array.isArray(name)) { // expand if array - for (j = 0, len = name.length; j < len; j++) { - attName = name[j]; - delete this.attribs[attName]; - } - } else { - delete this.attribs[name]; - } - return this; - } +/***/ }), - // Converts the XML fragment to string +/***/ 4931: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - // `options.allowEmpty` do not self close empty element tags - toString(options) { - return this.options.writer.element(this, this.options.writer.filterOptions(options)); - } +// Note: since nyc uses this module to output coverage, any lines +// that are in the direct sync flow of nyc's outputCoverage are +// ignored, since we can never get coverage for them. +var assert = __nccwpck_require__(9491) +var signals = __nccwpck_require__(3710) - // Aliases - att(name, value) { - return this.attribute(name, value); - } +var EE = __nccwpck_require__(2361) +/* istanbul ignore if */ +if (typeof EE !== 'function') { + EE = EE.EventEmitter +} - a(name, value) { - return this.attribute(name, value); - } +var emitter +if (process.__signal_exit_emitter__) { + emitter = process.__signal_exit_emitter__ +} else { + emitter = process.__signal_exit_emitter__ = new EE() + emitter.count = 0 + emitter.emitted = {} +} - // DOM Level 1 - getAttribute(name) { - if (this.attribs.hasOwnProperty(name)) { - return this.attribs[name].value; - } else { - return null; - } - } +// Because this emitter is a global, we have to check to see if a +// previous version of this library failed to enable infinite listeners. +// I know what you're about to say. But literally everything about +// signal-exit is a compromise with evil. Get used to it. +if (!emitter.infinite) { + emitter.setMaxListeners(Infinity) + emitter.infinite = true +} - setAttribute(name, value) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +module.exports = function (cb, opts) { + assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler') - getAttributeNode(name) { - if (this.attribs.hasOwnProperty(name)) { - return this.attribs[name]; - } else { - return null; - } - } + if (loaded === false) { + load() + } - setAttributeNode(newAttr) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + var ev = 'exit' + if (opts && opts.alwaysLast) { + ev = 'afterexit' + } - removeAttributeNode(oldAttr) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + var remove = function () { + emitter.removeListener(ev, cb) + if (emitter.listeners('exit').length === 0 && + emitter.listeners('afterexit').length === 0) { + unload() + } + } + emitter.on(ev, cb) - getElementsByTagName(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + return remove +} - // DOM Level 2 - getAttributeNS(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +module.exports.unload = unload +function unload () { + if (!loaded) { + return + } + loaded = false - setAttributeNS(namespaceURI, qualifiedName, value) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + signals.forEach(function (sig) { + try { + process.removeListener(sig, sigListeners[sig]) + } catch (er) {} + }) + process.emit = originalProcessEmit + process.reallyExit = originalProcessReallyExit + emitter.count -= 1 +} - removeAttributeNS(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +function emit (event, code, signal) { + if (emitter.emitted[event]) { + return + } + emitter.emitted[event] = true + emitter.emit(event, code, signal) +} - getAttributeNodeNS(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +// { : , ... } +var sigListeners = {} +signals.forEach(function (sig) { + sigListeners[sig] = function listener () { + // If there are no other listeners, an exit is coming! + // Simplest way: remove us and then re-send the signal. + // We know that this will kill the process, so we can + // safely emit now. + var listeners = process.listeners(sig) + if (listeners.length === emitter.count) { + unload() + emit('exit', null, sig) + /* istanbul ignore next */ + emit('afterexit', null, sig) + /* istanbul ignore next */ + process.kill(process.pid, sig) + } + } +}) - setAttributeNodeNS(newAttr) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +module.exports.signals = function () { + return signals +} - getElementsByTagNameNS(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +module.exports.load = load - hasAttribute(name) { - return this.attribs.hasOwnProperty(name); - } +var loaded = false - hasAttributeNS(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +function load () { + if (loaded) { + return + } + loaded = true - // DOM Level 3 - setIdAttribute(name, isId) { - if (this.attribs.hasOwnProperty(name)) { - return this.attribs[name].isId; - } else { - return isId; - } - } + // This is the number of onSignalExit's that are in play. + // It's important so that we can count the correct number of + // listeners on signals, and don't wait for the other one to + // handle it instead of us. + emitter.count += 1 - setIdAttributeNS(namespaceURI, localName, isId) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + signals = signals.filter(function (sig) { + try { + process.on(sig, sigListeners[sig]) + return true + } catch (er) { + return false + } + }) - setIdAttributeNode(idAttr, isId) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + process.emit = processEmit + process.reallyExit = processReallyExit +} - // DOM Level 4 - getElementsByTagName(tagname) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +var originalProcessReallyExit = process.reallyExit +function processReallyExit (code) { + process.exitCode = code || 0 + emit('exit', process.exitCode, null) + /* istanbul ignore next */ + emit('afterexit', process.exitCode, null) + /* istanbul ignore next */ + originalProcessReallyExit.call(process, process.exitCode) +} - getElementsByTagNameNS(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +var originalProcessEmit = process.emit +function processEmit (ev, arg) { + if (ev === 'exit') { + if (arg !== undefined) { + process.exitCode = arg + } + var ret = originalProcessEmit.apply(this, arguments) + emit('exit', process.exitCode, null) + /* istanbul ignore next */ + emit('afterexit', process.exitCode, null) + return ret + } else { + return originalProcessEmit.apply(this, arguments) + } +} - getElementsByClassName(classNames) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - isEqualNode(node) { - var i, j, ref; - if (!super.isEqualNode(node)) { - return false; - } - if (node.namespaceURI !== this.namespaceURI) { - return false; - } - if (node.prefix !== this.prefix) { - return false; - } - if (node.localName !== this.localName) { - return false; - } - if (node.attribs.length !== this.attribs.length) { - return false; - } - for (i = j = 0, ref = this.attribs.length - 1; (0 <= ref ? j <= ref : j >= ref); i = 0 <= ref ? ++j : --j) { - if (!this.attribs[i].isEqualNode(node.attribs[i])) { - return false; - } - } - return true; - } +/***/ }), - }; +/***/ 3710: +/***/ ((module) => { - // DOM level 1 - Object.defineProperty(XMLElement.prototype, 'tagName', { - get: function() { - return this.name; - } - }); +// This is not the set of all possible signals. +// +// It IS, however, the set of all signals that trigger +// an exit on either Linux or BSD systems. Linux is a +// superset of the signal names supported on BSD, and +// the unknown signals just fail to register, so we can +// catch that easily enough. +// +// Don't bother with SIGKILL. It's uncatchable, which +// means that we can't fire any callbacks anyway. +// +// If a user does happen to register a handler on a non- +// fatal signal like SIGWINCH or something, and then +// exit, it'll end up firing `process.emit('exit')`, so +// the handler will be fired anyway. +// +// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised +// artificially, inherently leave the process in a +// state from which it is not safe to try and enter JS +// listeners. +module.exports = [ + 'SIGABRT', + 'SIGALRM', + 'SIGHUP', + 'SIGINT', + 'SIGTERM' +] - // DOM level 4 - Object.defineProperty(XMLElement.prototype, 'namespaceURI', { - get: function() { - return ''; - } - }); +if (process.platform !== 'win32') { + module.exports.push( + 'SIGVTALRM', + 'SIGXCPU', + 'SIGXFSZ', + 'SIGUSR2', + 'SIGTRAP', + 'SIGSYS', + 'SIGQUIT', + 'SIGIOT' + // should detect profiler and enable/disable accordingly. + // see #21 + // 'SIGPROF' + ) +} - Object.defineProperty(XMLElement.prototype, 'prefix', { - get: function() { - return ''; - } - }); +if (process.platform === 'linux') { + module.exports.push( + 'SIGIO', + 'SIGPOLL', + 'SIGPWR', + 'SIGSTKFLT', + 'SIGUNUSED' + ) +} - Object.defineProperty(XMLElement.prototype, 'localName', { - get: function() { - return this.name; - } - }); - Object.defineProperty(XMLElement.prototype, 'id', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +/***/ }), - Object.defineProperty(XMLElement.prototype, 'className', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +/***/ 5515: +/***/ ((module) => { - Object.defineProperty(XMLElement.prototype, 'classList', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +"use strict"; - Object.defineProperty(XMLElement.prototype, 'attributes', { - get: function() { - if (!this.attributeMap || !this.attributeMap.nodes) { - this.attributeMap = new XMLNamedNodeMap(this.attribs); - } - return this.attributeMap; - } - }); +module.exports = function (x) { + var lf = typeof x === 'string' ? '\n' : '\n'.charCodeAt(); + var cr = typeof x === 'string' ? '\r' : '\r'.charCodeAt(); - return XMLElement; + if (x[x.length - 1] === lf) { + x = x.slice(0, x.length - 1); + } - }).call(this); + if (x[x.length - 1] === cr) { + x = x.slice(0, x.length - 1); + } -}).call(this); + return x; +}; /***/ }), -/***/ 4361: -/***/ (function(module) { - -// Generated by CoffeeScript 2.4.1 -(function() { - // Represents a map of nodes accessed by a string key - var XMLNamedNodeMap; - - module.exports = XMLNamedNodeMap = (function() { - class XMLNamedNodeMap { - // Initializes a new instance of `XMLNamedNodeMap` - // This is just a wrapper around an ordinary - // JS object. - - // `nodes` the object containing nodes. - constructor(nodes) { - this.nodes = nodes; - } - - // Creates and returns a deep clone of `this` +/***/ 4526: +/***/ ((module) => { - clone() { - // this class should not be cloned since it wraps - // around a given object. The calling function should check - // whether the wrapped object is null and supply a new object - // (from the clone). - return this.nodes = null; - } +const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/; +const numRegex = /^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/; +// const octRegex = /0x[a-z0-9]+/; +// const binRegex = /0x[a-z0-9]+/; - // DOM Level 1 - getNamedItem(name) { - return this.nodes[name]; - } - setNamedItem(node) { - var oldNode; - oldNode = this.nodes[node.nodeName]; - this.nodes[node.nodeName] = node; - return oldNode || null; - } +//polyfill +if (!Number.parseInt && window.parseInt) { + Number.parseInt = window.parseInt; +} +if (!Number.parseFloat && window.parseFloat) { + Number.parseFloat = window.parseFloat; +} - removeNamedItem(name) { - var oldNode; - oldNode = this.nodes[name]; - delete this.nodes[name]; - return oldNode || null; - } + +const consider = { + hex : true, + leadingZeros: true, + decimalPoint: "\.", + eNotation: true + //skipLike: /regex/ +}; - item(index) { - return this.nodes[Object.keys(this.nodes)[index]] || null; - } +function toNumber(str, options = {}){ + // const options = Object.assign({}, consider); + // if(opt.leadingZeros === false){ + // options.leadingZeros = false; + // }else if(opt.hex === false){ + // options.hex = false; + // } - // DOM level 2 functions to be implemented later - getNamedItemNS(namespaceURI, localName) { - throw new Error("This DOM method is not implemented."); - } + options = Object.assign({}, consider, options ); + if(!str || typeof str !== "string" ) return str; + + let trimmedStr = str.trim(); + // if(trimmedStr === "0.0") return 0; + // else if(trimmedStr === "+0.0") return 0; + // else if(trimmedStr === "-0.0") return -0; + + if(options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str; + else if (options.hex && hexRegex.test(trimmedStr)) { + return Number.parseInt(trimmedStr, 16); + // } else if (options.parseOct && octRegex.test(str)) { + // return Number.parseInt(val, 8); + // }else if (options.parseBin && binRegex.test(str)) { + // return Number.parseInt(val, 2); + }else{ + //separate negative sign, leading zeros, and rest number + const match = numRegex.exec(trimmedStr); + if(match){ + const sign = match[1]; + const leadingZeros = match[2]; + let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros + //trim ending zeros for floating number + + const eNotation = match[4] || match[6]; + if(!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".") return str; //-0123 + else if(!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".") return str; //0123 + else{//no leading zeros or leading zeros are allowed + const num = Number(trimmedStr); + const numStr = "" + num; + if(numStr.search(/[eE]/) !== -1){ //given number is long and parsed to eNotation + if(options.eNotation) return num; + else return str; + }else if(eNotation){ //given number has enotation + if(options.eNotation) return num; + else return str; + }else if(trimmedStr.indexOf(".") !== -1){ //floating number + // const decimalPart = match[5].substr(1); + // const intPart = trimmedStr.substr(0,trimmedStr.indexOf(".")); + + + // const p = numStr.indexOf("."); + // const givenIntPart = numStr.substr(0,p); + // const givenDecPart = numStr.substr(p+1); + if(numStr === "0" && (numTrimmedByZeros === "") ) return num; //0.0 + else if(numStr === numTrimmedByZeros) return num; //0.456. 0.79000 + else if( sign && numStr === "-"+numTrimmedByZeros) return num; + else return str; + } + + if(leadingZeros){ + // if(numTrimmedByZeros === numStr){ + // if(options.leadingZeros) return num; + // else return str; + // }else return str; + if(numTrimmedByZeros === numStr) return num; + else if(sign+numTrimmedByZeros === numStr) return num; + else return str; + } - setNamedItemNS(node) { - throw new Error("This DOM method is not implemented."); - } + if(trimmedStr === numStr) return num; + else if(trimmedStr === sign+numStr) return num; + // else{ + // //number with +/- sign + // trimmedStr.test(/[-+][0-9]); - removeNamedItemNS(namespaceURI, localName) { - throw new Error("This DOM method is not implemented."); - } + // } + return str; + } + // else if(!eNotation && trimmedStr && trimmedStr !== Number(trimmedStr) ) return str; + + }else{ //non-numeric string + return str; + } + } +} - }; +/** + * + * @param {string} numStr without leading zeros + * @returns + */ +function trimZeros(numStr){ + if(numStr && numStr.indexOf(".") !== -1){//float + numStr = numStr.replace(/0+$/, ""); //remove ending zeros + if(numStr === ".") numStr = "0"; + else if(numStr[0] === ".") numStr = "0"+numStr; + else if(numStr[numStr.length-1] === ".") numStr = numStr.substr(0,numStr.length-1); + return numStr; + } + return numStr; +} +module.exports = toNumber - - // DOM level 1 - Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { - get: function() { - return Object.keys(this.nodes).length || 0; - } - }); - return XMLNamedNodeMap; +/***/ }), - }).call(this); +/***/ 4294: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -}).call(this); +module.exports = __nccwpck_require__(4219); /***/ }), -/***/ 7608: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, - hasProp = {}.hasOwnProperty, - splice = [].splice; +/***/ 4219: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - ({isObject, isFunction, isEmpty, getValue} = __nccwpck_require__(8229)); +"use strict"; - XMLElement = null; - XMLCData = null; +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); - XMLComment = null; - XMLDeclaration = null; +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; - XMLDocType = null; - XMLRaw = null; +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; +} - XMLText = null; +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} - XMLProcessingInstruction = null; +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; +} - XMLDummy = null; +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} - NodeType = null; - XMLNodeList = null; +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 = []; - XMLNamedNodeMap = null; + 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); - DocumentPosition = null; +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); - // Represents a generic XMl element - module.exports = XMLNode = (function() { - class XMLNode { - // Initializes a new instance of `XMLNode` + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; + } - // `parent` the parent node - constructor(parent1) { - this.parent = parent1; - if (this.parent) { - this.options = this.parent.options; - this.stringify = this.parent.stringify; - } - this.value = null; - this.children = []; - this.baseURI = null; - // first execution, load dependencies that are otherwise - // circular (so we can't load them at the top) - if (!XMLElement) { - XMLElement = __nccwpck_require__(9437); - XMLCData = __nccwpck_require__(333); - XMLComment = __nccwpck_require__(4407); - XMLDeclaration = __nccwpck_require__(6364); - XMLDocType = __nccwpck_require__(1801); - XMLRaw = __nccwpck_require__(6329); - XMLText = __nccwpck_require__(1318); - XMLProcessingInstruction = __nccwpck_require__(6939); - XMLDummy = __nccwpck_require__(3590); - NodeType = __nccwpck_require__(9267); - XMLNodeList = __nccwpck_require__(6768); - XMLNamedNodeMap = __nccwpck_require__(4361); - DocumentPosition = __nccwpck_require__(2839); - } - } + // 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); - - // Sets the parent node of this node and its children recursively - - // `parent` the parent node - setParent(parent) { - var child, j, len, ref1, results; - this.parent = parent; - if (parent) { - this.options = parent.options; - this.stringify = parent.stringify; - } - ref1 = this.children; - results = []; - for (j = 0, len = ref1.length; j < len; j++) { - child = ref1[j]; - results.push(child.setParent(this)); - } - return results; - } + function onFree() { + self.emit('free', socket, options); + } - // Creates a child element node + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; - // `name` node name or an object describing the XML tree - // `attributes` an object containing name/value pairs of attributes - // `text` element text - element(name, attributes, text) { - var childNode, item, j, k, key, lastChild, len, len1, val; - lastChild = null; - if (attributes === null && (text == null)) { - [attributes, text] = [{}, null]; - } - if (attributes == null) { - attributes = {}; - } - attributes = getValue(attributes); - // swap argument order: text <-> attributes - if (!isObject(attributes)) { - [text, attributes] = [attributes, text]; - } - if (name != null) { - name = getValue(name); - } - // expand if array - if (Array.isArray(name)) { - for (j = 0, len = name.length; j < len; j++) { - item = name[j]; - lastChild = this.element(item); - } - // evaluate if function - } else if (isFunction(name)) { - lastChild = this.element(name.apply()); - // expand if object - } else if (isObject(name)) { - for (key in name) { - if (!hasProp.call(name, key)) continue; - val = name[key]; - if (isFunction(val)) { - // evaluate if function - val = val.apply(); - } - // assign attributes - if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) { - lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val); - // skip empty arrays - } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) { - lastChild = this.dummy(); - // empty objects produce one node - } else if (isObject(val) && isEmpty(val)) { - lastChild = this.element(key); - // skip null and undefined nodes - } else if (!this.options.keepNullNodes && (val == null)) { - lastChild = this.dummy(); - - // expand list by creating child nodes - } else if (!this.options.separateArrayItems && Array.isArray(val)) { - for (k = 0, len1 = val.length; k < len1; k++) { - item = val[k]; - childNode = {}; - childNode[key] = item; - lastChild = this.element(childNode); - } - - // expand child nodes under parent - } else if (isObject(val)) { - // if the key is #text expand child nodes under this node to support mixed content - if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) { - lastChild = this.element(val); - } else { - lastChild = this.element(key); - lastChild.element(val); - } - } else { - - // text node - lastChild = this.element(key, val); - } - } - // skip null nodes - } else if (!this.options.keepNullNodes && text === null) { - lastChild = this.dummy(); - } else { - // text node - if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) { - lastChild = this.text(text); - // cdata node - } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) { - lastChild = this.cdata(text); - // comment node - } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) { - lastChild = this.comment(text); - // raw text node - } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) { - lastChild = this.raw(text); - // processing instruction - } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) { - lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text); - } else { - // element node - lastChild = this.node(name, attributes, text); - } - } - if (lastChild == null) { - throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo()); - } - return lastChild; - } +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); - // Creates a child element node before the current node - - // `name` node name or an object describing the XML tree - // `attributes` an object containing name/value pairs of attributes - // `text` element text - insertBefore(name, attributes, text) { - var child, i, newChild, refChild, removed; - // DOM level 1 - // insertBefore(newChild, refChild) inserts the child node newChild before refChild - if (name != null ? name.type : void 0) { - newChild = name; - refChild = attributes; - newChild.setParent(this); - if (refChild) { - // temporarily remove children starting *with* refChild - i = children.indexOf(refChild); - removed = children.splice(i); - - // add the new child - children.push(newChild); - - // add back removed children after new child - Array.prototype.push.apply(children, removed); - } else { - children.push(newChild); - } - return newChild; - } else { - if (this.isRoot) { - throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); - } - - // temporarily remove children starting *with* this - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i); - - // add the new child - child = this.parent.element(name, attributes, text); - - // add back removed children after new child - Array.prototype.push.apply(this.parent.children, removed); - return child; - } - } + 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'); + } - // Creates a child element node after the current node + 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(); - // `name` node name or an object describing the XML tree - // `attributes` an object containing name/value pairs of attributes - // `text` element text - insertAfter(name, attributes, text) { - var child, i, removed; - if (this.isRoot) { - throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); - } - - // temporarily remove children starting *after* this - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i + 1); - - // add the new child - child = this.parent.element(name, attributes, text); - - // add back removed children after new child - Array.prototype.push.apply(this.parent.children, removed); - return child; - } + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } - // Deletes a child element node + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); + } - remove() { - var i, ref1; - if (this.isRoot) { - throw new Error("Cannot remove the root element. " + this.debugInfo()); - } - i = this.parent.children.indexOf(this); - splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1; - return this.parent; - } + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); - // Creates a node + 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); + } - // `name` name of the node - // `attributes` an object containing name/value pairs of attributes - // `text` element text - node(name, attributes, text) { - var child; - if (name != null) { - name = getValue(name); - } - attributes || (attributes = {}); - attributes = getValue(attributes); - // swap argument order: text <-> attributes - if (!isObject(attributes)) { - [text, attributes] = [attributes, text]; - } - child = new XMLElement(this, name, attributes); - if (text != null) { - child.text(text); - } - this.children.push(child); - return child; - } + function onError(cause) { + connectReq.removeAllListeners(); - // Creates a text node + 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); + } +}; - // `value` element text - text(value) { - var child; - if (isObject(value)) { - this.element(value); - } - child = new XMLText(this, value); - this.children.push(child); - return this; - } +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; + } + this.sockets.splice(pos, 1); - // Creates a CDATA node + 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); + }); + } +}; - // `value` element text without CDATA delimiters - cdata(value) { - var child; - child = new XMLCData(this, value); - this.children.push(child); - return this; - } +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 + }); - // Creates a comment node + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); +} - // `value` comment text - comment(value) { - var child; - child = new XMLComment(this, value); - this.children.push(child); - return this; - } - // Creates a comment node before the current node - - // `value` comment text - commentBefore(value) { - var child, i, removed; - // temporarily remove children starting *with* this - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i); - // add the new child - child = this.parent.comment(value); - // add back removed children after new child - Array.prototype.push.apply(this.parent.children, removed); - return this; - } +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 +} - // Creates a comment node after the current node - - // `value` comment text - commentAfter(value) { - var child, i, removed; - // temporarily remove children starting *after* this - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i + 1); - // add the new child - child = this.parent.comment(value); - // add back removed children after new child - Array.prototype.push.apply(this.parent.children, removed); - return this; +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; +} - // Adds unescaped raw text - // `value` text - raw(value) { - var child; - child = new XMLRaw(this, value); - this.children.push(child); - return this; - } +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 - // Adds a dummy node - dummy() { - var child; - child = new XMLDummy(this); - // Normally when a new node is created it is added to the child node collection. - // However, dummy nodes are never added to the XML tree. They are created while - // converting JS objects to XML nodes in order not to break the recursive function - // chain. They can be thought of as invisible nodes. They can be traversed through - // by using prev(), next(), up(), etc. functions but they do not exists in the tree. - - // @children.push child - return child; - } - // Adds a processing instruction +/***/ }), - // `target` instruction target - // `value` instruction value - instruction(target, value) { - var insTarget, insValue, instruction, j, len; - if (target != null) { - target = getValue(target); - } - if (value != null) { - value = getValue(value); - } - if (Array.isArray(target)) { // expand if array - for (j = 0, len = target.length; j < len; j++) { - insTarget = target[j]; - this.instruction(insTarget); - } - } else if (isObject(target)) { // expand if object - for (insTarget in target) { - if (!hasProp.call(target, insTarget)) continue; - insValue = target[insTarget]; - this.instruction(insTarget, insValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - instruction = new XMLProcessingInstruction(this, target, value); - this.children.push(instruction); - } - return this; - } +/***/ 2280: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // Creates a processing instruction node before the current node - - // `target` instruction target - // `value` instruction value - instructionBefore(target, value) { - var child, i, removed; - // temporarily remove children starting *with* this - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i); - // add the new child - child = this.parent.instruction(target, value); - // add back removed children after new child - Array.prototype.push.apply(this.parent.children, removed); - return this; - } +module.exports = getUserAgentNode - // Creates a processing instruction node after the current node - - // `target` instruction target - // `value` instruction value - instructionAfter(target, value) { - var child, i, removed; - // temporarily remove children starting *after* this - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i + 1); - // add the new child - child = this.parent.instruction(target, value); - // add back removed children after new child - Array.prototype.push.apply(this.parent.children, removed); - return this; - } +const osName = __nccwpck_require__(4824) - // Creates the xml declaration - - // `version` A version number string, e.g. 1.0 - // `encoding` Encoding declaration, e.g. UTF-8 - // `standalone` standalone document declaration: true or false - declaration(version, encoding, standalone) { - var doc, xmldec; - doc = this.document(); - xmldec = new XMLDeclaration(doc, version, encoding, standalone); - // Replace XML declaration if exists, otherwise insert at top - if (doc.children.length === 0) { - doc.children.unshift(xmldec); - } else if (doc.children[0].type === NodeType.Declaration) { - doc.children[0] = xmldec; - } else { - doc.children.unshift(xmldec); - } - return doc.root() || doc; - } +function getUserAgentNode () { + try { + return `Node.js/${process.version.substr(1)} (${osName()}; ${process.arch})` + } catch (error) { + if (/wmic os get Caption/.test(error.message)) { + return 'Windows ' + } - // Creates the document type declaration - - // `pubID` the public identifier of the external subset - // `sysID` the system identifier of the external subset - dtd(pubID, sysID) { - var child, doc, doctype, i, j, k, len, len1, ref1, ref2; - doc = this.document(); - doctype = new XMLDocType(doc, pubID, sysID); - ref1 = doc.children; - // Replace DTD if exists - for (i = j = 0, len = ref1.length; j < len; i = ++j) { - child = ref1[i]; - if (child.type === NodeType.DocType) { - doc.children[i] = doctype; - return doctype; - } - } - ref2 = doc.children; - // insert before root node if the root node exists - for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) { - child = ref2[i]; - if (child.isRoot) { - doc.children.splice(i, 0, doctype); - return doctype; - } - } - // otherwise append to end - doc.children.push(doctype); - return doctype; - } + throw error + } +} - // Gets the parent node - up() { - if (this.isRoot) { - throw new Error("The root node has no parent. Use doc() if you need to get the document object."); - } - return this.parent; - } - // Gets the root node - root() { - var node; - node = this; - while (node) { - if (node.type === NodeType.Document) { - return node.rootObject; - } else if (node.isRoot) { - return node; - } else { - node = node.parent; - } - } - } +/***/ }), - // Gets the node representing the XML document - document() { - var node; - node = this; - while (node) { - if (node.type === NodeType.Document) { - return node; - } else { - node = node.parent; - } - } - } +/***/ 5840: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - // Ends the document and converts string - end(options) { - return this.document().end(options); - } +"use strict"; - // Gets the previous node - prev() { - var i; - i = this.parent.children.indexOf(this); - if (i < 1) { - throw new Error("Already at the first node. " + this.debugInfo()); - } - return this.parent.children[i - 1]; - } - // Gets the next node - next() { - var i; - i = this.parent.children.indexOf(this); - if (i === -1 || i === this.parent.children.length - 1) { - throw new Error("Already at the last node. " + this.debugInfo()); - } - return this.parent.children[i + 1]; - } +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; + } +})); - // Imports cloned root from another XML document - - // `doc` the XML document to insert nodes from - importDocument(doc) { - var child, clonedRoot, j, len, ref1; - clonedRoot = doc.root().clone(); - clonedRoot.parent = this; - clonedRoot.isRoot = false; - this.children.push(clonedRoot); - // set properties if imported element becomes the root node - if (this.type === NodeType.Document) { - clonedRoot.isRoot = true; - clonedRoot.documentObject = this; - this.rootObject = clonedRoot; - // set dtd name - if (this.children) { - ref1 = this.children; - for (j = 0, len = ref1.length; j < len; j++) { - child = ref1[j]; - if (child.type === NodeType.DocType) { - child.name = clonedRoot.name; - break; - } - } - } - } - return this; - } +var _v = _interopRequireDefault(__nccwpck_require__(8628)); - - // Returns debug string for this node - debugInfo(name) { - var ref1, ref2; - name = name || this.name; - if ((name == null) && !((ref1 = this.parent) != null ? ref1.name : void 0)) { - return ""; - } else if (name == null) { - return "parent: <" + this.parent.name + ">"; - } else if (!((ref2 = this.parent) != null ? ref2.name : void 0)) { - return "node: <" + name + ">"; - } else { - return "node: <" + name + ">, parent: <" + this.parent.name + ">"; - } - } +var _v2 = _interopRequireDefault(__nccwpck_require__(6409)); - // Aliases - ele(name, attributes, text) { - return this.element(name, attributes, text); - } +var _v3 = _interopRequireDefault(__nccwpck_require__(5122)); - nod(name, attributes, text) { - return this.node(name, attributes, text); - } +var _v4 = _interopRequireDefault(__nccwpck_require__(9120)); - txt(value) { - return this.text(value); - } +var _nil = _interopRequireDefault(__nccwpck_require__(5332)); - dat(value) { - return this.cdata(value); - } +var _version = _interopRequireDefault(__nccwpck_require__(1595)); - com(value) { - return this.comment(value); - } +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); - ins(target, value) { - return this.instruction(target, value); - } +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); - doc() { - return this.document(); - } +var _parse = _interopRequireDefault(__nccwpck_require__(2746)); - dec(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - e(name, attributes, text) { - return this.element(name, attributes, text); - } +/***/ }), - n(name, attributes, text) { - return this.node(name, attributes, text); - } +/***/ 4569: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - t(value) { - return this.text(value); - } +"use strict"; - d(value) { - return this.cdata(value); - } - c(value) { - return this.comment(value); - } +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - r(value) { - return this.raw(value); - } +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - i(target, value) { - return this.instruction(target, value); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - u() { - return this.up(); - } +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } - // can be deprecated in a future release - importXMLBuilder(doc) { - return this.importDocument(doc); - } + return _crypto.default.createHash('md5').update(bytes).digest(); +} - // Adds or modifies an attribute. +var _default = md5; +exports["default"] = _default; - // `name` attribute name - // `value` attribute value - attribute(name, value) { - throw new Error("attribute() applies to element nodes only."); - } +/***/ }), - att(name, value) { - return this.attribute(name, value); - } +/***/ 5332: +/***/ ((__unused_webpack_module, exports) => { - a(name, value) { - return this.attribute(name, value); - } +"use strict"; - // Removes an attribute - // `name` attribute name - removeAttribute(name) { - throw new Error("attribute() applies to element nodes only."); - } +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = '00000000-0000-0000-0000-000000000000'; +exports["default"] = _default; - // DOM level 1 functions to be implemented later - replaceChild(newChild, oldChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +/***/ }), - removeChild(oldChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +/***/ 2746: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - appendChild(newChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +"use strict"; - hasChildNodes() { - return this.children.length !== 0; - } - cloneNode(deep) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - normalize() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); - // DOM level 2 - isSupported(feature, version) { - return true; - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - hasAttributes() { - return this.attribs.length !== 0; - } +function parse(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } - // DOM level 3 functions to be implemented later - compareDocumentPosition(other) { - var ref, res; - ref = this; - if (ref === other) { - return 0; - } else if (this.document() !== other.document()) { - res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific; - if (Math.random() < 0.5) { - res |= DocumentPosition.Preceding; - } else { - res |= DocumentPosition.Following; - } - return res; - } else if (ref.isAncestor(other)) { - return DocumentPosition.Contains | DocumentPosition.Preceding; - } else if (ref.isDescendant(other)) { - return DocumentPosition.Contains | DocumentPosition.Following; - } else if (ref.isPreceding(other)) { - return DocumentPosition.Preceding; - } else { - return DocumentPosition.Following; - } - } + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ - isSameNode(other) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + 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 ........-####-....-....-............ - lookupPrefix(namespaceURI) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ - isDefaultNamespace(namespaceURI) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ - lookupNamespaceURI(prefix) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + 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) - isEqualNode(node) { - var i, j, ref1; - if (node.nodeType !== this.nodeType) { - return false; - } - if (node.children.length !== this.children.length) { - return false; - } - for (i = j = 0, ref1 = this.children.length - 1; (0 <= ref1 ? j <= ref1 : j >= ref1); i = 0 <= ref1 ? ++j : --j) { - if (!this.children[i].isEqualNode(node.children[i])) { - return false; - } - } - return true; - } + 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; +} - getFeature(feature, version) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +var _default = parse; +exports["default"] = _default; - setUserData(key, data, handler) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +/***/ }), - getUserData(key) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +/***/ 814: +/***/ ((__unused_webpack_module, exports) => { - // Returns true if other is an inclusive descendant of node, - // and false otherwise. - contains(other) { - if (!other) { - return false; - } - return other === this || this.isDescendant(other); - } +"use strict"; - // An object A is called a descendant of an object B, if either A is - // a child of B or A is a child of an object C that is a descendant of B. - isDescendant(node) { - var child, isDescendantChild, j, len, ref1; - ref1 = this.children; - for (j = 0, len = ref1.length; j < len; j++) { - child = ref1[j]; - if (node === child) { - return true; - } - isDescendantChild = child.isDescendant(node); - if (isDescendantChild) { - return true; - } - } - return false; - } - // An object A is called an ancestor of an object B if and only if - // B is a descendant of A. - isAncestor(node) { - return node.isDescendant(this); - } +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; - // An object A is preceding an object B if A and B are in the - // same tree and A comes before B in tree order. - isPreceding(node) { - var nodePos, thisPos; - nodePos = this.treePosition(node); - thisPos = this.treePosition(this); - if (nodePos === -1 || thisPos === -1) { - return false; - } else { - return nodePos < thisPos; - } - } +/***/ }), - // An object A is folllowing an object B if A and B are in the - // same tree and A comes after B in tree order. - isFollowing(node) { - var nodePos, thisPos; - nodePos = this.treePosition(node); - thisPos = this.treePosition(this); - if (nodePos === -1 || thisPos === -1) { - return false; - } else { - return nodePos > thisPos; - } - } +/***/ 807: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - // Returns the preorder position of the given node in the tree, or -1 - // if the node is not in the tree. - treePosition(node) { - var found, pos; - pos = 0; - found = false; - this.foreachTreeNode(this.document(), function(childNode) { - pos++; - if (!found && childNode === node) { - return found = true; - } - }); - if (found) { - return pos; - } else { - return -1; - } - } +"use strict"; - - // Depth-first preorder traversal through the XML tree - foreachTreeNode(node, func) { - var child, j, len, ref1, res; - node || (node = this.document()); - ref1 = node.children; - for (j = 0, len = ref1.length; j < len; j++) { - child = ref1[j]; - if (res = func(child)) { - return res; - } else { - res = this.foreachTreeNode(child, func); - if (res) { - return res; - } - } - } - } - }; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = rng; - // DOM level 1 - Object.defineProperty(XMLNode.prototype, 'nodeName', { - get: function() { - return this.name; - } - }); +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - Object.defineProperty(XMLNode.prototype, 'nodeType', { - get: function() { - return this.type; - } - }); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - Object.defineProperty(XMLNode.prototype, 'nodeValue', { - get: function() { - return this.value; - } - }); +const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate - Object.defineProperty(XMLNode.prototype, 'parentNode', { - get: function() { - return this.parent; - } - }); +let poolPtr = rnds8Pool.length; - Object.defineProperty(XMLNode.prototype, 'childNodes', { - get: function() { - if (!this.childNodeList || !this.childNodeList.nodes) { - this.childNodeList = new XMLNodeList(this.children); - } - return this.childNodeList; - } - }); +function rng() { + if (poolPtr > rnds8Pool.length - 16) { + _crypto.default.randomFillSync(rnds8Pool); - Object.defineProperty(XMLNode.prototype, 'firstChild', { - get: function() { - return this.children[0] || null; - } - }); + poolPtr = 0; + } - Object.defineProperty(XMLNode.prototype, 'lastChild', { - get: function() { - return this.children[this.children.length - 1] || null; - } - }); + return rnds8Pool.slice(poolPtr, poolPtr += 16); +} - Object.defineProperty(XMLNode.prototype, 'previousSibling', { - get: function() { - var i; - i = this.parent.children.indexOf(this); - return this.parent.children[i - 1] || null; - } - }); +/***/ }), - Object.defineProperty(XMLNode.prototype, 'nextSibling', { - get: function() { - var i; - i = this.parent.children.indexOf(this); - return this.parent.children[i + 1] || null; - } - }); +/***/ 5274: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - Object.defineProperty(XMLNode.prototype, 'ownerDocument', { - get: function() { - return this.document() || null; - } - }); +"use strict"; - // DOM level 3 - Object.defineProperty(XMLNode.prototype, 'textContent', { - get: function() { - var child, j, len, ref1, str; - if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) { - str = ''; - ref1 = this.children; - for (j = 0, len = ref1.length; j < len; j++) { - child = ref1[j]; - if (child.textContent) { - str += child.textContent; - } - } - return str; - } else { - return null; - } - }, - set: function(value) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - return XMLNode; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - }).call(this); +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); -}).call(this); +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(); +} -/***/ 6768: -/***/ (function(module) { +var _default = sha1; +exports["default"] = _default; -// Generated by CoffeeScript 2.4.1 -(function() { - // Represents a list of nodes - var XMLNodeList; +/***/ }), - module.exports = XMLNodeList = (function() { - class XMLNodeList { - // Initializes a new instance of `XMLNodeList` - // This is just a wrapper around an ordinary - // JS array. +/***/ 8950: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - // `nodes` the array containing nodes. - constructor(nodes) { - this.nodes = nodes; - } +"use strict"; - // Creates and returns a deep clone of `this` - clone() { - // this class should not be cloned since it wraps - // around a given array. The calling function should check - // whether the wrapped array is null and supply a new array - // (from the clone). - return this.nodes = null; - } +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - // DOM Level 1 - item(index) { - return this.nodes[index] || null; - } +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); - }; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - // DOM level 1 - Object.defineProperty(XMLNodeList.prototype, 'length', { - get: function() { - return this.nodes.length || 0; - } - }); +/** + * 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)); +} - return XMLNodeList; +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 - }).call(this); + if (!(0, _validate.default)(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } -}).call(this); + return uuid; +} +var _default = stringify; +exports["default"] = _default; /***/ }), -/***/ 6939: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +/***/ 8628: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLCharacterData, XMLProcessingInstruction; +"use strict"; - NodeType = __nccwpck_require__(9267); - XMLCharacterData = __nccwpck_require__(7709); +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - // Represents a processing instruction - module.exports = XMLProcessingInstruction = class XMLProcessingInstruction extends XMLCharacterData { - // Initializes a new instance of `XMLProcessingInstruction` +var _rng = _interopRequireDefault(__nccwpck_require__(807)); - // `parent` the parent node - // `target` instruction target - // `value` instruction value - constructor(parent, target, value) { - super(parent); - if (target == null) { - throw new Error("Missing instruction target. " + this.debugInfo()); - } - this.type = NodeType.ProcessingInstruction; - this.target = this.stringify.insTarget(target); - this.name = this.target; - if (value) { - this.value = this.stringify.insValue(value); - } - } +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); - // Creates and returns a deep clone of `this` - clone() { - return Object.create(this); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - // Converts the XML fragment to string +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html +let _nodeId; - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options)); - } +let _clockseq; // Previous uuid creation time - isEqualNode(node) { - if (!super.isEqualNode(node)) { - return false; - } - if (node.target !== this.target) { - return false; - } - return true; - } - }; +let _lastMSecs = 0; +let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details -}).call(this); +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]]; + } -/***/ 6329: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + 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. -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLNode, XMLRaw; - NodeType = __nccwpck_require__(9267); + 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 - XMLNode = __nccwpck_require__(7608); + let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) - // Represents a raw node - module.exports = XMLRaw = class XMLRaw extends XMLNode { - // Initializes a new instance of `XMLRaw` + const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression - // `text` raw text - constructor(parent, text) { - super(parent); - if (text == null) { - throw new Error("Missing raw text. " + this.debugInfo()); - } - this.type = NodeType.Raw; - this.value = this.stringify.raw(text); - } + 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 - // Creates and returns a deep clone of `this` - clone() { - return Object.create(this); - } - // Converts the XML fragment to string + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } // Per 4.2.1.2 Throw error if too many uuids are requested - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.raw(this, this.options.writer.filterOptions(options)); - } - }; + if (nsecs >= 10000) { + throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); + } -}).call(this); + _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` -/***/ 8601: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; // `time_high_and_version` -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, WriterState, XMLStreamWriter, XMLWriterBase, - hasProp = {}.hasOwnProperty; + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version - NodeType = __nccwpck_require__(9267); + b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) - XMLWriterBase = __nccwpck_require__(6752); + b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` - WriterState = __nccwpck_require__(9766); + b[i++] = clockseq & 0xff; // `node` - // Prints XML nodes to a stream - module.exports = XMLStreamWriter = class XMLStreamWriter extends XMLWriterBase { - // Initializes a new instance of `XMLStreamWriter` + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; + } - // `stream` output stream - // `options.pretty` pretty prints the result - // `options.indent` indentation string - // `options.newline` newline sequence - // `options.offset` a fixed number of indentations to add to every line - // `options.allowEmpty` do not self close empty element tags - // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF - // `options.spaceBeforeSlash` add a space before the closing slash of empty elements - constructor(stream, options) { - super(options); - this.stream = stream; - } + return buf || (0, _stringify.default)(b); +} - endline(node, options, level) { - if (node.isLastRootNode && options.state === WriterState.CloseTag) { - return ''; - } else { - return super.endline(node, options, level); - } - } +var _default = v1; +exports["default"] = _default; - document(doc, options) { - var child, i, j, k, len1, len2, ref, ref1, results; - ref = doc.children; - // set a flag so that we don't insert a newline after the last root level node - for (i = j = 0, len1 = ref.length; j < len1; i = ++j) { - child = ref[i]; - child.isLastRootNode = i === doc.children.length - 1; - } - options = this.filterOptions(options); - ref1 = doc.children; - results = []; - for (k = 0, len2 = ref1.length; k < len2; k++) { - child = ref1[k]; - results.push(this.writeChildNode(child, options, 0)); - } - return results; - } +/***/ }), - cdata(node, options, level) { - return this.stream.write(super.cdata(node, options, level)); - } +/***/ 6409: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - comment(node, options, level) { - return this.stream.write(super.comment(node, options, level)); - } +"use strict"; - declaration(node, options, level) { - return this.stream.write(super.declaration(node, options, level)); - } - docType(node, options, level) { - var child, j, len1, ref; - level || (level = 0); - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - this.stream.write(this.indent(node, options, level)); - this.stream.write(' 0) { - this.stream.write(' ['); - this.stream.write(this.endline(node, options, level)); - options.state = WriterState.InsideTag; - ref = node.children; - for (j = 0, len1 = ref.length; j < len1; j++) { - child = ref[j]; - this.writeChildNode(child, options, level + 1); - } - options.state = WriterState.CloseTag; - this.stream.write(']'); - } - // close tag - options.state = WriterState.CloseTag; - this.stream.write(options.spaceBeforeSlash + '>'); - this.stream.write(this.endline(node, options, level)); - options.state = WriterState.None; - return this.closeNode(node, options, level); - } - - element(node, options, level) { - var att, attLen, child, childNodeCount, firstChildNode, j, len, len1, name, prettySuppressed, r, ratt, ref, ref1, ref2, rline; - level || (level = 0); - // open tag - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '<' + node.name; - // attributes - if (options.pretty && options.width > 0) { - len = r.length; - ref = node.attribs; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - att = ref[name]; - ratt = this.attribute(att, options, level); - attLen = ratt.length; - if (len + attLen > options.width) { - rline = this.indent(node, options, level + 1) + ratt; - r += this.endline(node, options, level) + rline; - len = rline.length; - } else { - rline = ' ' + ratt; - r += rline; - len += rline.length; - } - } - } else { - ref1 = node.attribs; - for (name in ref1) { - if (!hasProp.call(ref1, name)) continue; - att = ref1[name]; - r += this.attribute(att, options, level); - } - } - this.stream.write(r); - childNodeCount = node.children.length; - firstChildNode = childNodeCount === 0 ? null : node.children[0]; - if (childNodeCount === 0 || node.children.every(function(e) { - return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === ''; - })) { - // empty element - if (options.allowEmpty) { - this.stream.write('>'); - options.state = WriterState.CloseTag; - this.stream.write(''); - } else { - options.state = WriterState.CloseTag; - this.stream.write(options.spaceBeforeSlash + '/>'); - } - } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) { - // do not indent text-only nodes - this.stream.write('>'); - options.state = WriterState.InsideTag; - options.suppressPrettyCount++; - prettySuppressed = true; - this.writeChildNode(firstChildNode, options, level + 1); - options.suppressPrettyCount--; - prettySuppressed = false; - options.state = WriterState.CloseTag; - this.stream.write(''); - } else { - this.stream.write('>' + this.endline(node, options, level)); - options.state = WriterState.InsideTag; - ref2 = node.children; - // inner tags - for (j = 0, len1 = ref2.length; j < len1; j++) { - child = ref2[j]; - this.writeChildNode(child, options, level + 1); - } - // close tag - options.state = WriterState.CloseTag; - this.stream.write(this.indent(node, options, level) + ''); - } - this.stream.write(this.endline(node, options, level)); - options.state = WriterState.None; - return this.closeNode(node, options, level); - } +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - processingInstruction(node, options, level) { - return this.stream.write(super.processingInstruction(node, options, level)); - } +var _v = _interopRequireDefault(__nccwpck_require__(5998)); - raw(node, options, level) { - return this.stream.write(super.raw(node, options, level)); - } +var _md = _interopRequireDefault(__nccwpck_require__(4569)); - text(node, options, level) { - return this.stream.write(super.text(node, options, level)); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - dtdAttList(node, options, level) { - return this.stream.write(super.dtdAttList(node, options, level)); - } +const v3 = (0, _v.default)('v3', 0x30, _md.default); +var _default = v3; +exports["default"] = _default; - dtdElement(node, options, level) { - return this.stream.write(super.dtdElement(node, options, level)); - } +/***/ }), - dtdEntity(node, options, level) { - return this.stream.write(super.dtdEntity(node, options, level)); - } +/***/ 5998: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - dtdNotation(node, options, level) { - return this.stream.write(super.dtdNotation(node, options, level)); - } +"use strict"; - }; -}).call(this); +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)); -/***/ 5913: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var XMLStringWriter, XMLWriterBase; - - XMLWriterBase = __nccwpck_require__(6752); - - // Prints XML nodes as plain text - module.exports = XMLStringWriter = class XMLStringWriter extends XMLWriterBase { - // Initializes a new instance of `XMLStringWriter` - - // `options.pretty` pretty prints the result - // `options.indent` indentation string - // `options.newline` newline sequence - // `options.offset` a fixed number of indentations to add to every line - // `options.allowEmpty` do not self close empty element tags - // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF - // `options.spaceBeforeSlash` add a space before the closing slash of empty elements - constructor(options) { - super(options); - } - - document(doc, options) { - var child, i, len, r, ref; - options = this.filterOptions(options); - r = ''; - ref = doc.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - r += this.writeChildNode(child, options, 0); - } - // remove trailing newline - if (options.pretty && r.slice(-options.newline.length) === options.newline) { - r = r.slice(0, -options.newline.length); - } - return r; - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - }; +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape -}).call(this); + const bytes = []; + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } -/***/ }), + return bytes; +} -/***/ 8594: -/***/ (function(module) { - -// Generated by CoffeeScript 2.4.1 -(function() { - // Converts values to strings - var XMLStringifier, - hasProp = {}.hasOwnProperty; - - module.exports = XMLStringifier = (function() { - class XMLStringifier { - // Initializes a new instance of `XMLStringifier` - - // `options.version` The version number string of the XML spec to validate against, e.g. 1.0 - // `options.noDoubleEncoding` whether existing html entities are encoded: true or false - // `options.stringify` a set of functions to use for converting values to strings - // `options.noValidation` whether values will be validated and escaped or returned as is - constructor(options) { - var key, ref, value; - // Checks whether the given string contains legal characters - // Fails with an exception on error - - // `str` the string to check - this.assertLegalChar = this.assertLegalChar.bind(this); - // Checks whether the given string contains legal characters for a name - // Fails with an exception on error - - // `str` the string to check - this.assertLegalName = this.assertLegalName.bind(this); - options || (options = {}); - this.options = options; - if (!this.options.version) { - this.options.version = '1.0'; - } - ref = options.stringify || {}; - for (key in ref) { - if (!hasProp.call(ref, key)) continue; - value = ref[key]; - this[key] = value; - } - } +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +exports.DNS = DNS; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +exports.URL = URL; - // Defaults - name(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalName('' + val || ''); - } +function _default(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + if (typeof value === 'string') { + value = stringToBytes(value); + } - text(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar(this.textEscape('' + val || '')); - } + if (typeof namespace === 'string') { + namespace = (0, _parse.default)(namespace); + } - cdata(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - val = val.replace(']]>', ']]]]>'); - return this.assertLegalChar(val); - } + 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])` - comment(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - if (val.match(/--/)) { - throw new Error("Comment text cannot contain double-hypen: " + val); - } - return this.assertLegalChar(val); - } - raw(val) { - if (this.options.noValidation) { - return val; - } - return '' + val || ''; - } + 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; - attValue(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar(this.attEscape(val = '' + val || '')); - } + if (buf) { + offset = offset || 0; - insTarget(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; } - insValue(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - if (val.match(/\?>/)) { - throw new Error("Invalid processing instruction value: " + val); - } - return this.assertLegalChar(val); - } + return buf; + } - xmlVersion(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - if (!val.match(/1\.[0-9]+/)) { - throw new Error("Invalid version number: " + val); - } - return val; - } + return (0, _stringify.default)(bytes); + } // Function#name is not settable on some platforms (#270) - xmlEncoding(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) { - throw new Error("Invalid encoding: " + val); - } - return this.assertLegalChar(val); - } - xmlStandalone(val) { - if (this.options.noValidation) { - return val; - } - if (val) { - return "yes"; - } else { - return "no"; - } - } + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support - dtdPubID(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - } - dtdSysID(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - } + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} - dtdElementValue(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - } +/***/ }), - dtdAttType(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - } +/***/ 5122: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - dtdAttDefault(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - } +"use strict"; - dtdEntityValue(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - } - dtdNData(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - } +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - assertLegalChar(str) { - var regex, res; - if (this.options.noValidation) { - return str; - } - regex = ''; - if (this.options.version === '1.0') { - // Valid characters from https://www.w3.org/TR/xml/#charsets - // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. - // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] - // This ES5 compatible Regexp has been generated using the "regenerate" NPM module: - // let xml_10_InvalidChars = regenerate() - // .addRange(0x0000, 0x0008) - // .add(0x000B, 0x000C) - // .addRange(0x000E, 0x001F) - // .addRange(0xD800, 0xDFFF) - // .addRange(0xFFFE, 0xFFFF) - regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; - if (res = str.match(regex)) { - throw new Error(`Invalid character in string: ${str} at index ${res.index}`); - } - } else if (this.options.version === '1.1') { - // Valid characters from https://www.w3.org/TR/xml11/#charsets - // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. - // [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] - // This ES5 compatible Regexp has been generated using the "regenerate" NPM module: - // let xml_11_InvalidChars = regenerate() - // .add(0x0000) - // .addRange(0xD800, 0xDFFF) - // .addRange(0xFFFE, 0xFFFF) - regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; - if (res = str.match(regex)) { - throw new Error(`Invalid character in string: ${str} at index ${res.index}`); - } - } - return str; - } +var _rng = _interopRequireDefault(__nccwpck_require__(807)); - assertLegalName(str) { - var regex; - if (this.options.noValidation) { - return str; - } - this.assertLegalChar(str); - regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/; - if (!str.match(regex)) { - throw new Error("Invalid character in name"); - } - return str; - } +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); - // Escapes special characters in text +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping +function v4(options, buf, offset) { + options = options || {}; - // `str` the string to escape - textEscape(str) { - var ampregex; - if (this.options.noValidation) { - return str; - } - ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; - return str.replace(ampregex, '&').replace(//g, '>').replace(/\r/g, ' '); - } + const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` - // Escapes special characters in attribute values - // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping + rnds[6] = rnds[6] & 0x0f | 0x40; + rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided - // `str` the string to escape - attEscape(str) { - var ampregex; - if (this.options.noValidation) { - return str; - } - ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; - return str.replace(ampregex, '&').replace(/ { - XMLStringifier.prototype.convertRawKey = '#raw'; +"use strict"; - return XMLStringifier; - }).call(this); +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; -}).call(this); +var _v = _interopRequireDefault(__nccwpck_require__(5998)); +var _sha = _interopRequireDefault(__nccwpck_require__(5274)); -/***/ }), +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -/***/ 1318: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +const v5 = (0, _v.default)('v5', 0x50, _sha.default); +var _default = v5; +exports["default"] = _default; -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, XMLCharacterData, XMLText; +/***/ }), - NodeType = __nccwpck_require__(9267); +/***/ 6900: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - XMLCharacterData = __nccwpck_require__(7709); +"use strict"; - // Represents a text node - module.exports = XMLText = (function() { - class XMLText extends XMLCharacterData { - // Initializes a new instance of `XMLText` - // `text` element text - constructor(parent, text) { - super(parent); - if (text == null) { - throw new Error("Missing element text. " + this.debugInfo()); - } - this.name = "#text"; - this.type = NodeType.Text; - this.value = this.stringify.text(text); - } +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - // Creates and returns a deep clone of `this` - clone() { - return Object.create(this); - } +var _regex = _interopRequireDefault(__nccwpck_require__(814)); - // Converts the XML fragment to string +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - // `options.pretty` pretty prints the result - // `options.indent` indentation for pretty print - // `options.offset` how many indentations to add to every line for pretty print - // `options.newline` newline sequence for pretty print - toString(options) { - return this.options.writer.text(this, this.options.writer.filterOptions(options)); - } +function validate(uuid) { + return typeof uuid === 'string' && _regex.default.test(uuid); +} - // DOM level 1 functions to be implemented later - splitText(offset) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +var _default = validate; +exports["default"] = _default; - // DOM level 3 functions to be implemented later - replaceWholeText(content) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } +/***/ }), - }; +/***/ 1595: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - // DOM level 3 - Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +"use strict"; - Object.defineProperty(XMLText.prototype, 'wholeText', { - get: function() { - var next, prev, str; - str = ''; - prev = this.previousSibling; - while (prev) { - str = prev.data + str; - prev = prev.previousSibling; - } - str += this.data; - next = this.nextSibling; - while (next) { - str = str + next.data; - next = next.nextSibling; - } - return str; - } - }); - return XMLText; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; - }).call(this); +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); -}).call(this); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function version(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } -/***/ }), + return parseInt(uuid.substr(14, 1), 16); +} -/***/ 6752: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +var _default = version; +exports["default"] = _default; -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign, - hasProp = {}.hasOwnProperty; +/***/ }), - ({assign} = __nccwpck_require__(8229)); +/***/ 4207: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - NodeType = __nccwpck_require__(9267); +module.exports = which +which.sync = whichSync - XMLDeclaration = __nccwpck_require__(6364); +var isWindows = process.platform === 'win32' || + process.env.OSTYPE === 'cygwin' || + process.env.OSTYPE === 'msys' - XMLDocType = __nccwpck_require__(1801); +var path = __nccwpck_require__(1017) +var COLON = isWindows ? ';' : ':' +var isexe = __nccwpck_require__(7126) - XMLCData = __nccwpck_require__(333); +function getNotFoundError (cmd) { + var er = new Error('not found: ' + cmd) + er.code = 'ENOENT' - XMLComment = __nccwpck_require__(4407); + return er +} - XMLElement = __nccwpck_require__(9437); +function getPathInfo (cmd, opt) { + var colon = opt.colon || COLON + var pathEnv = opt.path || process.env.PATH || '' + var pathExt = [''] - XMLRaw = __nccwpck_require__(6329); + pathEnv = pathEnv.split(colon) - XMLText = __nccwpck_require__(1318); + var pathExtExe = '' + if (isWindows) { + pathEnv.unshift(process.cwd()) + pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM') + pathExt = pathExtExe.split(colon) - XMLProcessingInstruction = __nccwpck_require__(6939); - XMLDummy = __nccwpck_require__(3590); + // Always test the cmd itself first. isexe will check to make sure + // it's found in the pathExt set. + if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') + pathExt.unshift('') + } - XMLDTDAttList = __nccwpck_require__(1015); + // If it has a slash, then we don't bother searching the pathenv. + // just check the file itself, and that's it. + if (cmd.match(/\//) || isWindows && cmd.match(/\\/)) + pathEnv = [''] - XMLDTDElement = __nccwpck_require__(2421); + return { + env: pathEnv, + ext: pathExt, + extExe: pathExtExe + } +} - XMLDTDEntity = __nccwpck_require__(53); +function which (cmd, opt, cb) { + if (typeof opt === 'function') { + cb = opt + opt = {} + } - XMLDTDNotation = __nccwpck_require__(2837); + var info = getPathInfo(cmd, opt) + var pathEnv = info.env + var pathExt = info.ext + var pathExtExe = info.extExe + var found = [] - WriterState = __nccwpck_require__(9766); + ;(function F (i, l) { + if (i === l) { + if (opt.all && found.length) + return cb(null, found) + else + return cb(getNotFoundError(cmd)) + } - // Base class for XML writers - module.exports = XMLWriterBase = class XMLWriterBase { - // Initializes a new instance of `XMLWriterBase` + var pathPart = pathEnv[i] + if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') + pathPart = pathPart.slice(1, -1) - // `options.pretty` pretty prints the result - // `options.indent` indentation string - // `options.newline` newline sequence - // `options.offset` a fixed number of indentations to add to every line - // `options.width` maximum column width - // `options.allowEmpty` do not self close empty element tags - // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF - // `options.spaceBeforeSlash` add a space before the closing slash of empty elements - constructor(options) { - var key, ref, value; - options || (options = {}); - this.options = options; - ref = options.writer || {}; - for (key in ref) { - if (!hasProp.call(ref, key)) continue; - value = ref[key]; - this["_" + key] = this[key]; - this[key] = value; - } + var p = path.join(pathPart, cmd) + if (!pathPart && (/^\.[\\\/]/).test(cmd)) { + p = cmd.slice(0, 2) + p } + ;(function E (ii, ll) { + if (ii === ll) return F(i + 1, l) + var ext = pathExt[ii] + isexe(p + ext, { pathExt: pathExtExe }, function (er, is) { + if (!er && is) { + if (opt.all) + found.push(p + ext) + else + return cb(null, p + ext) + } + return E(ii + 1, ll) + }) + })(0, pathExt.length) + })(0, pathEnv.length) +} - // Filters writer options and provides defaults - - // `options` writer options - filterOptions(options) { - var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7; - options || (options = {}); - options = assign({}, this.options, options); - filteredOptions = { - writer: this - }; - filteredOptions.pretty = options.pretty || false; - filteredOptions.allowEmpty = options.allowEmpty || false; - filteredOptions.indent = (ref = options.indent) != null ? ref : ' '; - filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n'; - filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0; - filteredOptions.width = (ref3 = options.width) != null ? ref3 : 0; - filteredOptions.dontPrettyTextNodes = (ref4 = (ref5 = options.dontPrettyTextNodes) != null ? ref5 : options.dontprettytextnodes) != null ? ref4 : 0; - filteredOptions.spaceBeforeSlash = (ref6 = (ref7 = options.spaceBeforeSlash) != null ? ref7 : options.spacebeforeslash) != null ? ref6 : ''; - if (filteredOptions.spaceBeforeSlash === true) { - filteredOptions.spaceBeforeSlash = ' '; - } - filteredOptions.suppressPrettyCount = 0; - filteredOptions.user = {}; - filteredOptions.state = WriterState.None; - return filteredOptions; - } +function whichSync (cmd, opt) { + opt = opt || {} - // Returns the indentation string for the current level + var info = getPathInfo(cmd, opt) + var pathEnv = info.env + var pathExt = info.ext + var pathExtExe = info.extExe + var found = [] - // `node` current node - // `options` writer options - // `level` current indentation level - indent(node, options, level) { - var indentLevel; - if (!options.pretty || options.suppressPrettyCount) { - return ''; - } else if (options.pretty) { - indentLevel = (level || 0) + options.offset + 1; - if (indentLevel > 0) { - return new Array(indentLevel).join(options.indent); + for (var i = 0, l = pathEnv.length; i < l; i ++) { + var pathPart = pathEnv[i] + if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') + pathPart = pathPart.slice(1, -1) + + var p = path.join(pathPart, cmd) + if (!pathPart && /^\.[\\\/]/.test(cmd)) { + p = cmd.slice(0, 2) + p + } + for (var j = 0, ll = pathExt.length; j < ll; j ++) { + var cur = p + pathExt[j] + var is + try { + is = isexe.sync(cur, { pathExt: pathExtExe }) + if (is) { + if (opt.all) + found.push(cur) + else + return cur } - } - return ''; + } catch (ex) {} } + } - // Returns the newline string + if (opt.all && found.length) + return found - // `node` current node - // `options` writer options - // `level` current indentation level - endline(node, options, level) { - if (!options.pretty || options.suppressPrettyCount) { - return ''; - } else { - return options.newline; - } - } + if (opt.nothrow) + return null - attribute(att, options, level) { - var r; - this.openAttribute(att, options, level); - if (options.pretty && options.width > 0) { - r = att.name + '="' + att.value + '"'; - } else { - r = ' ' + att.name + '="' + att.value + '"'; - } - this.closeAttribute(att, options, level); - return r; - } - - cdata(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - comment(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - declaration(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + ''; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - docType(node, options, level) { - var child, i, len1, r, ref; - level || (level = 0); - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level); - r += ' 0) { - r += ' ['; - r += this.endline(node, options, level); - options.state = WriterState.InsideTag; - ref = node.children; - for (i = 0, len1 = ref.length; i < len1; i++) { - child = ref[i]; - r += this.writeChildNode(child, options, level + 1); - } - options.state = WriterState.CloseTag; - r += ']'; - } - // close tag - options.state = WriterState.CloseTag; - r += options.spaceBeforeSlash + '>'; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - element(node, options, level) { - var att, attLen, child, childNodeCount, firstChildNode, i, j, len, len1, len2, name, prettySuppressed, r, ratt, ref, ref1, ref2, ref3, rline; - level || (level = 0); - prettySuppressed = false; - // open tag - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '<' + node.name; - // attributes - if (options.pretty && options.width > 0) { - len = r.length; - ref = node.attribs; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - att = ref[name]; - ratt = this.attribute(att, options, level); - attLen = ratt.length; - if (len + attLen > options.width) { - rline = this.indent(node, options, level + 1) + ratt; - r += this.endline(node, options, level) + rline; - len = rline.length; - } else { - rline = ' ' + ratt; - r += rline; - len += rline.length; - } - } - } else { - ref1 = node.attribs; - for (name in ref1) { - if (!hasProp.call(ref1, name)) continue; - att = ref1[name]; - r += this.attribute(att, options, level); - } - } - childNodeCount = node.children.length; - firstChildNode = childNodeCount === 0 ? null : node.children[0]; - if (childNodeCount === 0 || node.children.every(function(e) { - return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === ''; - })) { - // empty element - if (options.allowEmpty) { - r += '>'; - options.state = WriterState.CloseTag; - r += '' + this.endline(node, options, level); - } else { - options.state = WriterState.CloseTag; - r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level); - } - } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) { - // do not indent text-only nodes - r += '>'; - options.state = WriterState.InsideTag; - options.suppressPrettyCount++; - prettySuppressed = true; - r += this.writeChildNode(firstChildNode, options, level + 1); - options.suppressPrettyCount--; - prettySuppressed = false; - options.state = WriterState.CloseTag; - r += '' + this.endline(node, options, level); - } else { - // if ANY are a text node, then suppress pretty now - if (options.dontPrettyTextNodes) { - ref2 = node.children; - for (i = 0, len1 = ref2.length; i < len1; i++) { - child = ref2[i]; - if ((child.type === NodeType.Text || child.type === NodeType.Raw) && (child.value != null)) { - options.suppressPrettyCount++; - prettySuppressed = true; - break; - } - } - } - // close the opening tag, after dealing with newline - r += '>' + this.endline(node, options, level); - options.state = WriterState.InsideTag; - ref3 = node.children; - // inner tags - for (j = 0, len2 = ref3.length; j < len2; j++) { - child = ref3[j]; - r += this.writeChildNode(child, options, level + 1); - } - // close tag - options.state = WriterState.CloseTag; - r += this.indent(node, options, level) + ''; - if (prettySuppressed) { - options.suppressPrettyCount--; - } - r += this.endline(node, options, level); - options.state = WriterState.None; - } - this.closeNode(node, options, level); - return r; - } - - writeChildNode(node, options, level) { - switch (node.type) { - case NodeType.CData: - return this.cdata(node, options, level); - case NodeType.Comment: - return this.comment(node, options, level); - case NodeType.Element: - return this.element(node, options, level); - case NodeType.Raw: - return this.raw(node, options, level); - case NodeType.Text: - return this.text(node, options, level); - case NodeType.ProcessingInstruction: - return this.processingInstruction(node, options, level); - case NodeType.Dummy: - return ''; - case NodeType.Declaration: - return this.declaration(node, options, level); - case NodeType.DocType: - return this.docType(node, options, level); - case NodeType.AttributeDeclaration: - return this.dtdAttList(node, options, level); - case NodeType.ElementDeclaration: - return this.dtdElement(node, options, level); - case NodeType.EntityDeclaration: - return this.dtdEntity(node, options, level); - case NodeType.NotationDeclaration: - return this.dtdNotation(node, options, level); - default: - throw new Error("Unknown XML node type: " + node.constructor.name); - } - } + throw getNotFoundError(cmd) +} - processingInstruction(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + ''; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - raw(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level); - options.state = WriterState.InsideTag; - r += node.value; - options.state = WriterState.CloseTag; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - text(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level); - options.state = WriterState.InsideTag; - r += node.value; - options.state = WriterState.CloseTag; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - dtdAttList(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - dtdElement(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - dtdEntity(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - - dtdNotation(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - } - openNode(node, options, level) {} +/***/ }), - closeNode(node, options, level) {} +/***/ 3515: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - openAttribute(att, options, level) {} +"use strict"; - closeAttribute(att, options, level) {} +const os = __nccwpck_require__(2037); +const execa = __nccwpck_require__(5447); - }; +// Reference: https://www.gaijin.at/en/lstwinver.php +const names = new Map([ + ['10.0', '10'], + ['6.3', '8.1'], + ['6.2', '8'], + ['6.1', '7'], + ['6.0', 'Vista'], + ['5.2', 'Server 2003'], + ['5.1', 'XP'], + ['5.0', '2000'], + ['4.9', 'ME'], + ['4.1', '98'], + ['4.0', '95'] +]); -}).call(this); +const windowsRelease = release => { + const version = /\d+\.\d/.exec(release || os.release()); + if (release && !version) { + throw new Error('`release` argument doesn\'t match `n.n`'); + } -/***/ }), + const ver = (version || [])[0]; -/***/ 2958: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 2.4.1 -(function() { - var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction; - - ({assign, isFunction} = __nccwpck_require__(8229)); - - XMLDOMImplementation = __nccwpck_require__(8310); - - XMLDocument = __nccwpck_require__(3730); - - XMLDocumentCB = __nccwpck_require__(7356); - - XMLStringWriter = __nccwpck_require__(5913); - - XMLStreamWriter = __nccwpck_require__(8601); - - NodeType = __nccwpck_require__(9267); - - WriterState = __nccwpck_require__(9766); - - // Creates a new document and returns the root node for - // chain-building the document tree - - // `name` name of the root element - - // `xmldec.version` A version number string, e.g. 1.0 - // `xmldec.encoding` Encoding declaration, e.g. UTF-8 - // `xmldec.standalone` standalone document declaration: true or false - - // `doctype.pubID` public identifier of the external subset - // `doctype.sysID` system identifier of the external subset - - // `options.headless` whether XML declaration and doctype will be included: - // true or false - // `options.keepNullNodes` whether nodes with null values will be kept - // or ignored: true or false - // `options.keepNullAttributes` whether attributes with null values will be - // kept or ignored: true or false - // `options.ignoreDecorators` whether decorator strings will be ignored when - // converting JS objects: true or false - // `options.separateArrayItems` whether array items are created as separate - // nodes when passed as an object value: true or false - // `options.noDoubleEncoding` whether existing html entities are encoded: - // true or false - // `options.stringify` a set of functions to use for converting values to - // strings - // `options.writer` the default XML writer to use for converting nodes to - // string. If the default writer is not set, the built-in XMLStringWriter - // will be used instead. - module.exports.create = function(name, xmldec, doctype, options) { - var doc, root; - if (name == null) { - throw new Error("Root element needs a name."); - } - options = assign({}, xmldec, doctype, options); - // create the document node - doc = new XMLDocument(options); - // add the root node - root = doc.element(name); - // prolog - if (!options.headless) { - doc.declaration(options); - if ((options.pubID != null) || (options.sysID != null)) { - doc.dtd(options); - } - } - return root; - }; + // Server 2008, 2012 and 2016 versions are ambiguous with desktop versions and must be detected at runtime. + // If `release` is omitted or we're on a Windows system, and the version number is an ambiguous version + // then use `wmic` to get the OS caption: https://msdn.microsoft.com/en-us/library/aa394531(v=vs.85).aspx + // If the resulting caption contains the year 2008, 2012 or 2016, it is a server version, so return a server OS name. + if ((!release || release === os.release()) && ['6.1', '6.2', '6.3', '10.0'].includes(ver)) { + const stdout = execa.sync('wmic', ['os', 'get', 'Caption']).stdout || ''; + const year = (stdout.match(/2008|2012|2016/) || [])[0]; + if (year) { + return `Server ${year}`; + } + } - // Creates a new document and returns the document node for - // chain-building the document tree - - // `options.keepNullNodes` whether nodes with null values will be kept - // or ignored: true or false - // `options.keepNullAttributes` whether attributes with null values will be - // kept or ignored: true or false - // `options.ignoreDecorators` whether decorator strings will be ignored when - // converting JS objects: true or false - // `options.separateArrayItems` whether array items are created as separate - // nodes when passed as an object value: true or false - // `options.noDoubleEncoding` whether existing html entities are encoded: - // true or false - // `options.stringify` a set of functions to use for converting values to - // strings - // `options.writer` the default XML writer to use for converting nodes to - // string. If the default writer is not set, the built-in XMLStringWriter - // will be used instead. - - // `onData` the function to be called when a new chunk of XML is output. The - // string containing the XML chunk is passed to `onData` as its single - // argument. - // `onEnd` the function to be called when the XML document is completed with - // `end`. `onEnd` does not receive any arguments. - module.exports.begin = function(options, onData, onEnd) { - if (isFunction(options)) { - [onData, onEnd] = [options, onData]; - options = {}; - } - if (onData) { - return new XMLDocumentCB(options, onData, onEnd); - } else { - return new XMLDocument(options); - } - }; + return names.get(ver); +}; - module.exports.stringWriter = function(options) { - return new XMLStringWriter(options); - }; +module.exports = windowsRelease; - module.exports.streamWriter = function(stream, options) { - return new XMLStreamWriter(stream, options); - }; - module.exports.implementation = new XMLDOMImplementation(); +/***/ }), + +/***/ 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') - module.exports.nodeType = NodeType; + Object.keys(fn).forEach(function (k) { + wrapper[k] = fn[k] + }) - module.exports.writerState = WriterState; + return wrapper -}).call(this); + 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 + } +} /***/ }), diff --git a/package-lock.json b/package-lock.json index 1687485e4..7f8095f70 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,9 +14,8 @@ "@actions/github": "^1.1.0", "@actions/http-client": "^2.0.1", "@actions/io": "^1.0.2", - "fast-xml-parser": "^3.15.1", - "semver": "^6.3.0", - "xmlbuilder": "^13.0.2" + "fast-xml-parser": "^4.0.10", + "semver": "^6.3.0" }, "devDependencies": { "@types/jest": "^27.0.2", @@ -1992,12 +1991,14 @@ "dev": true }, "node_modules/fast-xml-parser": { - "version": "3.17.4", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.17.4.tgz", - "integrity": "sha512-qudnQuyYBgnvzf5Lj/yxMcf4L9NcVWihXJg7CiU1L+oUCq8MUnFEfH2/nXR/W5uq+yvUN1h7z6s7vs2v1WkL1A==", - "hasInstallScript": true, + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.0.10.tgz", + "integrity": "sha512-mYMMIk7Ho1QOiedyvafdyPamn1Vlda+5n95lcn0g79UiCQoLQ2xfPQ8m3pcxBMpVaftYXtoIE2wrNTjmLQnnkg==", + "dependencies": { + "strnum": "^1.0.5" + }, "bin": { - "xml2js": "cli.js" + "fxparser": "src/cli/cli.js" }, "funding": { "type": "paypal", @@ -4207,6 +4208,11 @@ "node": ">=6" } }, + "node_modules/strnum": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", + "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" + }, "node_modules/supports-color": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", @@ -4669,14 +4675,6 @@ "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", "dev": true }, - "node_modules/xmlbuilder": { - "version": "13.0.2", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-13.0.2.tgz", - "integrity": "sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ==", - "engines": { - "node": ">=6.0" - } - }, "node_modules/xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", @@ -6296,9 +6294,12 @@ "dev": true }, "fast-xml-parser": { - "version": "3.17.4", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.17.4.tgz", - "integrity": "sha512-qudnQuyYBgnvzf5Lj/yxMcf4L9NcVWihXJg7CiU1L+oUCq8MUnFEfH2/nXR/W5uq+yvUN1h7z6s7vs2v1WkL1A==" + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.0.10.tgz", + "integrity": "sha512-mYMMIk7Ho1QOiedyvafdyPamn1Vlda+5n95lcn0g79UiCQoLQ2xfPQ8m3pcxBMpVaftYXtoIE2wrNTjmLQnnkg==", + "requires": { + "strnum": "^1.0.5" + } }, "fb-watchman": { "version": "2.0.1", @@ -7970,6 +7971,11 @@ "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "dev": true }, + "strnum": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", + "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" + }, "supports-color": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", @@ -8301,11 +8307,6 @@ "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", "dev": true }, - "xmlbuilder": { - "version": "13.0.2", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-13.0.2.tgz", - "integrity": "sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ==" - }, "xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", diff --git a/package.json b/package.json index efa743ef0..6e80f1a1c 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,8 @@ "@actions/github": "^1.1.0", "@actions/http-client": "^2.0.1", "@actions/io": "^1.0.2", - "fast-xml-parser": "^3.15.1", - "semver": "^6.3.0", - "xmlbuilder": "^13.0.2" + "fast-xml-parser": "^4.0.10", + "semver": "^6.3.0" }, "devDependencies": { "@types/jest": "^27.0.2", diff --git a/src/authutil.ts b/src/authutil.ts index 60a4dd731..56b802389 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -2,8 +2,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as core from '@actions/core'; import * as github from '@actions/github'; -import * as xmlbuilder from 'xmlbuilder'; -import * as xmlParser from 'fast-xml-parser'; +import {XMLParser, XMLBuilder} from 'fast-xml-parser'; export function configAuthentication( feedUrl: string, @@ -49,7 +48,6 @@ function writeFeedToFile( core.info( `dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}` ); - let xml: xmlbuilder.XMLElement; let sourceKeys: string[] = []; let owner: string = core.getInput('owner'); let sourceUrl: string = feedUrl; @@ -66,64 +64,90 @@ function writeFeedToFile( if (fs.existsSync(existingFileLocation)) { // get key from existing NuGet.config so NuGet/dotnet can match credentials const curContents: string = fs.readFileSync(existingFileLocation, 'utf8'); - const json = xmlParser.parse(curContents, {ignoreAttributes: false}); + + const parserOptions = { + ignoreAttributes: false + }; + const parser = new XMLParser(parserOptions); + const json = parser.parse(curContents); if (typeof json.configuration === 'undefined') { throw new Error(`The provided NuGet.config seems invalid.`); } - if (typeof json.configuration.packageSources != 'undefined') { - if (typeof json.configuration.packageSources.add != 'undefined') { - // file has at least one - if (typeof json.configuration.packageSources.add[0] === 'undefined') { - // file has only one - if ( - json.configuration.packageSources.add['@_value'] - .toLowerCase() - .includes(feedUrl.toLowerCase()) - ) { - const key = json.configuration.packageSources.add['@_key']; + if (json.configuration?.packageSources?.add) { + const packageSources = json.configuration.packageSources.add; + + if (Array.isArray(packageSources)) { + packageSources.forEach(source => { + const value = source['@_value']; + core.debug(`source '${value}'`); + if (value.toLowerCase().includes(feedUrl.toLowerCase())) { + const key = source['@_key']; sourceKeys.push(key); core.debug(`Found a URL with key ${key}`); } - } else { - // file has 2+ - for ( - let i = 0; - i < json.configuration.packageSources.add.length; - i++ - ) { - const source = json.configuration.packageSources.add[i]; - const value = source['@_value']; - core.debug(`source '${value}'`); - if (value.toLowerCase().includes(feedUrl.toLowerCase())) { - const key = source['@_key']; - sourceKeys.push(key); - core.debug(`Found a URL with key ${key}`); - } - } + }); + } else { + if ( + packageSources['@_value'] + .toLowerCase() + .includes(feedUrl.toLowerCase()) + ) { + const key = packageSources['@_key']; + sourceKeys.push(key); + core.debug(`Found a URL with key ${key}`); } } } } - xml = xmlbuilder - .create('configuration') - .ele('config') - .ele('add', {key: 'defaultPushSource', value: sourceUrl}) - .up() - .up(); + const xmlSource: any[] = [ + { + '?xml': [ + { + '#text': '' + } + ], + ':@': { + '@_version': '1.0' + } + }, + { + configuration: [ + { + config: [ + { + add: [], + ':@': { + '@_key': 'defaultPushSource', + '@_value': sourceUrl + } + } + ] + } + ] + } + ]; if (!sourceKeys.length) { let keystring = 'Source'; - xml = xml - .ele('packageSources') - .ele('add', {key: keystring, value: sourceUrl}) - .up() - .up(); + + xmlSource[1].configuration.push({ + packageSources: [ + { + add: [], + ':@': { + '@_key': keystring, + '@_value': sourceUrl + } + } + ] + }); + sourceKeys.push(keystring); } - xml = xml.ele('packageSourceCredentials'); + const packageSourceCredentials: any[] = []; sourceKeys.forEach(key => { if (!isValidKey(key)) { throw new Error( @@ -131,24 +155,42 @@ function writeFeedToFile( ); } - xml = xml - .ele(key) - .ele('add', {key: 'Username', value: owner}) - .up() - .ele('add', { - key: 'ClearTextPassword', - value: process.env.NUGET_AUTH_TOKEN - }) - .up() - .up(); + packageSourceCredentials.push({ + [key]: [ + { + add: [], + ':@': { + '@_key': 'Username', + '@_value': owner + } + }, + { + add: [], + ':@': { + '@_key': 'ClearTextPassword', + '@_value': process.env.NUGET_AUTH_TOKEN + } + } + ] + }); + }); + + xmlSource[1].configuration.push({ + packageSourceCredentials }); - // If NuGet fixes itself such that on Linux it can look for environment variables in the config file (it doesn't seem to work today), - // use this for the value above - // process.platform == 'win32' - // ? '%NUGET_AUTH_TOKEN%' - // : '$NUGET_AUTH_TOKEN' + const xmlBuilderOptions = { + format: true, + ignoreAttributes: false, + preserveOrder: true, + allowBooleanAttributes: true, + suppressBooleanAttributes: true, + suppressEmptyNode: true + }; + + const builder = new XMLBuilder(xmlBuilderOptions); + + const output = builder.build(xmlSource).trim(); - const output = xml.end({pretty: true}); fs.writeFileSync(tempFileLocation, output); }