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,OAAO,EAAK,QAAS,EAAW,SAGvC,KACJ,CAER,CAGJ,IAAI,EAAc,KAWlB,GATI,EAAK,WAAW,KAChB,EAAc,EAET,YAAa,GAAQ,EAAK,WAAW,EAAK,UAC3C,EAAK,UAAU,EAAK,QAAQ,QAAQ,MAAM,WAC1C,EAAc,EAAK,QAAQ,SAAU,KAIzC,EAAa,CACb,MAAM,EAAS,IAAI,gBAAgB,EAAM,EAAa,EAAS,SAAS,EAAY,UAAU,IAAM,IAAM,SAAK,GAE/G,YADA,EAAS,KAAM,EAEnB,CAEA,IAAI,EAAW,EACf,UAAU,EAAM,GAAM,SAAU,EAAK,GAC7B,EAAW,EACX,QAAQ,MAAM,+CAA+C,2GAGjE,GAAY,EAER,EAAK,iBACL,EAAI,OAGJ,KACA,EAAS,IAAI,gBAAgB,EAAM,EAAM,IAAK,IACvC,OAAS,SAGpB,EAAS,KAAM,GACnB,GACJ,GAAG,EACP","file":"/npm/markdown-link-check@3.14.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/markdown-link-check@3.14.2/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nconst async = require('async');\nconst linkCheck = require('link-check');\nconst LinkCheckResult = require('link-check').LinkCheckResult;\nconst markdownLinkExtractor = require('markdown-link-extractor');\nconst ProgressBar = require('progress');\n\nconst envVarPatternMatcher = /(?<pattern>{{env\\.(?<name>[a-zA-Z0-9\\-_]+)}})/;\n\n/*\n * Performs some special replacements for the following patterns:\n * - {{BASEURL}} - to be replaced with opts.projectBaseUrl\n * - {{env.<env_var_name>}} - to be replaced with the environment variable specified with <env_var_name>\n */\nfunction performSpecialReplacements(str, opts) {\n    // replace the `{{BASEURL}}` with the opts.projectBaseUrl. Helpful to build absolute urls \"relative\" to project roots\n    str = str.replace('{{BASEURL}}', opts.projectBaseUrl);\n\n    // replace {{env.<env_var_name>}} with the corresponding environment variable or an empty string if none is set.\n    var envVarMatch;\n    do {\n        envVarMatch = envVarPatternMatcher.exec(str);\n\n        if(!envVarMatch) {\n            break;\n        }\n\n        var envVarPattern = envVarMatch.groups.pattern;\n        var envVarName = envVarMatch.groups.name;\n\n        var envVarPatternReplacement = '';\n\n        if(envVarName in process.env) {\n            envVarPatternReplacement = process.env[envVarName];\n        }\n\n        str = str.replace(envVarPattern, envVarPatternReplacement);\n        // eslint-disable-next-line no-constant-condition\n    } while (true);\n\n    return str;\n}\n\nfunction removeCodeBlocks(markdown) {\n    return markdown.replace(/^```[\\S\\s]+?^```$/gm, '');\n}\n\nfunction extractHtmlSections(markdown) {\n    markdown =\n        // remove code blocks\n        removeCodeBlocks(markdown)\n        // remove HTML comments\n        .replace(/<!--[\\S\\s]+?-->/gm, '')\n        // remove single line code (if not escaped with \"\\\")\n        .replace(/(?<!\\\\)`[\\S\\s]+?(?<!\\\\)`/gm, '');\n\n    const regexAllId = /<(?<tag>[^\\s]+).*?id=[\"'](?<id>[^\"']*?)[\"'].*?>/gmi;\n    const regexAName = /<a.*?name=[\"'](?<name>[^\"']*?)[\"'].*?>/gmi;\n\n    const sections = []\n        .concat(Array.from(markdown.matchAll(regexAllId), (match) => match.groups.id))\n        .concat(Array.from(markdown.matchAll(regexAName), (match) => match.groups.name));\n\n    return sections\n}\n\nfunction extractSections(markdown) {\n    // First remove code blocks.\n    markdown = removeCodeBlocks(markdown);\n\n    const sectionTitles = markdown.match(/^#+ .*$/gm) || [];\n\n    const sections = sectionTitles.map(section =>\n        // The links are compared with the headings (simple text comparison).\n        // However, the links are url-encoded beforehand, so the headings\n        // have to also be encoded so that they can also be matched.\n        encodeURIComponent(\n            section\n                // replace links, the links can start with \"./\", \"/\", \"http://\", \"https://\" or \"#\"\n                // and keep the value of the text ($1)\n                .replace(/\\[(.+)\\]\\(((?:\\.?\\/|https?:\\/\\/|#)[\\w\\d./?=#-]+)\\)/, \"$1\")\n                // make everything (Unicode-aware) lower case\n                .toLowerCase()\n                // remove white spaces and \"#\" at the beginning\n                .replace(/^#+\\s*/, '')\n                // remove everything that is NOT a (Unicode) Letter, (Unicode) Number decimal,\n                // (Unicode) Number letter, white space, underscore or hyphen\n                // https://ruby-doc.org/3.3.2/Regexp.html#class-Regexp-label-Unicode+Character+Categories\n                .replace(/[^\\p{L}\\p{Nd}\\p{Nl}\\s_\\-`]/gu, \"\")\n                // remove sequences of *\n                .replace(/\\*(?=.*)/gu, \"\")\n                // remove leftover backticks\n                .replace(/`/gu, \"\")\n                // Now replace remaining blanks with '-'\n                .replace(/\\s/gu, \"-\")\n        )\n    );\n\n    var uniq = {};\n    for (var section of sections) {\n        if (section in uniq) {\n            uniq[section]++;\n            section = section + '-' + uniq[section];\n        }\n        uniq[section] = 0;\n    }\n    const uniqueSections = Object.keys(uniq) ?? [];\n\n    return uniqueSections;\n}\n\nmodule.exports = function markdownLinkCheck(markdown, opts, callback) {\n    if (arguments.length === 2 && typeof opts === 'function') {\n        // optional 'opts' not supplied.\n        callback = opts;\n        opts = {};\n    }\n\n    if(!opts.ignoreDisable) {\n        markdown = [\n            /(<!--[ \\t]+markdown-link-check-disable[ \\t]+-->[\\S\\s]*?<!--[ \\t]+markdown-link-check-enable[ \\t]+-->)/mg,\n            /(<!--[ \\t]+markdown-link-check-disable[ \\t]+-->[\\S\\s]*(?!<!--[ \\t]+markdown-link-check-enable[ \\t]+-->))/mg,\n            /(<!--[ \\t]+markdown-link-check-disable-next-line[ \\t]+-->\\r?\\n[^\\r\\n]*)/mg,\n            /([^\\r\\n]*<!--[ \\t]+markdown-link-check-disable-line[ \\t]+-->[^\\r\\n]*)/mg\n        ].reduce(function(_markdown, disablePattern) {\n            return _markdown.replace(new RegExp(disablePattern), '');\n        }, markdown);\n    }\n\n    const links = markdownLinkExtractor(markdown);\n    const sections = extractSections(markdown).concat(extractHtmlSections(markdown));\n    const linksCollection = [...new Set(links)]\n    const bar = (opts.showProgressBar) ?\n        new ProgressBar('Checking... [:bar] :percent', {\n            complete: '=',\n            incomplete: ' ',\n            width: 25,\n            total: linksCollection.length\n        }) : undefined;\n\n    async.mapLimit(linksCollection, 2, function (link, callback) {\n        if (opts.ignorePatterns) {\n            const shouldIgnore = opts.ignorePatterns.some(function(ignorePattern) {\n                return ignorePattern.pattern instanceof RegExp ? ignorePattern.pattern.test(link) : (new RegExp(ignorePattern.pattern)).test(link) ? true : false;\n            });\n\n            if (shouldIgnore) {\n                const result = new LinkCheckResult(opts, link, 0, undefined);\n                result.status = 'ignored'; // custom status for ignored links\n                callback(null, result);\n                return;\n            }\n        }\n\n        if (opts.replacementPatterns) {\n            for (let replacementPattern of opts.replacementPatterns) {\n                let pattern = replacementPattern.pattern instanceof RegExp ? replacementPattern.pattern : new RegExp(replacementPattern.pattern, replacementPattern.global ? 'g' : '');\n                link = link.replace(pattern, performSpecialReplacements(replacementPattern.replacement, opts));\n            }\n        }\n\n        // Make sure it is not undefined and that the appropriate headers are always recalculated for a given link.\n        opts.headers = {};\n\n        if (opts.httpHeaders) {\n            for (const httpHeader of opts.httpHeaders) {\n                if (httpHeader.headers) {\n                    for (const header of Object.keys(httpHeader.headers)) {\n                        httpHeader.headers[header] = performSpecialReplacements(httpHeader.headers[header], opts);\n                    }\n                }\n\n                for (const url of httpHeader.urls) {\n                    if (link.startsWith(url)) {\n                        Object.assign(opts.headers, httpHeader.headers);\n\n                        // The headers of this httpHeader has been applied, the other URLs of this httpHeader don't need to be evaluated any further.\n                        break;\n                    }\n                }\n            }\n        }\n\n        let sectionLink = null;\n\n        if (link.startsWith('#')) {\n            sectionLink = link;\n        }\n        else if ('baseUrl' in opts && link.startsWith(opts.baseUrl)) {\n            if (link.substring(opts.baseUrl.length).match(/^\\/*#/)) {\n                sectionLink = link.replace(/^[^#]+/, '');\n            }\n        }\n\n        if (sectionLink) {\n            const result = new LinkCheckResult(opts, sectionLink, sections.includes(sectionLink.substring(1)) ? 200 : 404, undefined);\n            callback(null, result);\n            return;\n        }\n\n        let numCalls = 0;\n        linkCheck(link, opts, function (err, result) {\n            if (numCalls > 0) {\n                console.trace(`linkCheck called us back more than once for ${link}. This is likely due to a server answering HEAD with 302 and a body, against the HTTP spec. Ignoring.`);\n                return;\n            }\n            numCalls += 1;\n\n            if (opts.showProgressBar) {\n                bar.tick();\n            }\n\n            if (err) {\n                result = new LinkCheckResult(opts, link, 500, err);\n                result.status = 'error'; // custom status for errored links\n            }\n\n            callback(null, result);\n        });\n    }, callback);\n};\n"]}