"/**\n * Copyright (C) 2022 The Software Heritage developers\n * See the AUTHORS file at the top-level directory of this distribution\n * License: GNU Affero General Public License version 3, or any later version\n * See top-level LICENSE file for more information\n */\n\nimport {handleFetchError, errorMessageFromResponse, csrfPost,\n getHumanReadableDate} from 'utils/functions';\nimport userRequestsFilterCheckboxFn from 'utils/requests-filter-checkbox.ejs';\nimport {swhSpinnerSrc} from 'utils/constants';\n\nlet requestBrowseTable;\n\nconst addForgeCheckboxId = 'swh-add-forge-user-filter';\nconst userRequestsFilterCheckbox = userRequestsFilterCheckboxFn({\n 'inputId': addForgeCheckboxId,\n 'checked': true // by default, display only user requests\n});\n\nexport function onCreateRequestPageLoad() {\n $(document).ready(() => {\n $('#requestCreateForm').submit(async function(event) {\n event.preventDefault();\n try {\n const response = await csrfPost($(this).attr('action'),\n {'Content-Type': 'application/x-www-form-urlencoded'},\n $(this).serialize());\n handleFetchError(response);\n $('#userMessageDetail').empty();\n $('#userMessage').text('Your request has been submitted');\n $('#userMessage').removeClass('badge-danger');\n $('#userMessage').addClass('badge-success');\n requestBrowseTable.draw(); // redraw the table to update the list\n } catch (errorResponse) {\n $('#userMessageDetail').empty();\n\n let errorMessage;\n const errorData = await errorResponse.json();\n // if (errorResponse.content_type === 'text/plain') { // does not work?\n if (errorResponse.status === 409) {\n errorMessage = errorData;\n } else { // assuming json response\n // const exception = errorData['exception'];\n errorMessage = errorMessageFromResponse(\n errorData, 'An unknown error occurred during the request creation');\n }\n $('#userMessage').text(errorMessage);\n $('#userMessage').removeClass('badge-success');\n $('#userMessage').addClass('badge-danger');\n }\n });\n\n populateRequestBrowseList(); // Load existing requests\n });\n}\n\nexport function populateRequestBrowseList() {\n requestBrowseTable = $('#add-forge-request-browse')\n .on('error.dt', (e, settings, techNote, message) => {\n $('#add-forge-browse-request-error').text(message);\n })\n .DataTable({\n serverSide: true,\n processing: true,\n language: {\n processing: `<img src=\"${swhSpinnerSrc}\"></img>`\n },\n retrieve: true,\n searching: true,\n info: false,\n // Layout configuration, see [1] for more details\n // [1] https://datatables.net/reference/option/dom\n dom: '<\"row\"<\"col-sm-3\"l><\"col-sm-6 text-left user-requests-filter\"><\"col-sm-3\"f>>' +\n '<\"row\"<\"col-sm-12\"tr>>' +\n '<\"row\"<\"col-sm-5\"i><\"col-sm-7\"p>>',\n ajax: {\n 'url': Urls.add_forge_request_list_datatables(),\n data: (d) => {\n const checked = $(`#${addForgeCheckboxId}`).prop('checked');\n // If this function is called while the page is loading, 'checked' is\n // undefined. As the checkbox defaults to being checked, coerce this to true.\n if (swh.webapp.isUserLoggedIn() && (checked === undefined || checked)) {\n d.user_requests_only = '1';\n }\n }\n },\n fnInitComplete: function() {\n if (swh.webapp.isUserLoggedIn()) {\n $('div.user-requests-filter').html(userRequestsFilterCheckbox);\n $(`#${addForgeCheckboxId}`).on('change', () => {\n requestBrowseTable.draw();\n });\n }\n },\n columns: [\n {\n data: 'submission_date',\n name: 'submission_date',\n render: getHumanReadableDate\n },\n {\n data: 'forge_type',\n name: 'forge_type',\n render: $.fn.dataTable.render.text()\n },\n {\n data: 'forge_url',\n name: 'forge_url',\n render: function(data, type, row) {\n if (type === 'display') {\n let html = '';\n const sanitizedURL = $.fn.dataTable.render.text().display(data);\n html += sanitizedURL;\n html += ` <a href=\"${sanitizedURL}\" target=\"_blank\" rel=\"noopener noreferrer\">` +\n '<i class=\"mdi mdi-open-in-new\" aria-hidden=\"true\"></i></a>';\n return html;\n }\n return data;\n }\n },\n {\n data: 'status',\n name: 'status',\n render: function(data, type, row, meta) {\n return swh.add_forge.formatRequestStatusName(data);\n }\n }\n ]\n });\n}\n",
"/**\n * Copyright (C) 2022 The Software Heritage developers\n * See the AUTHORS file at the top-level directory of this distribution\n * License: GNU Affero General Public License version 3, or any later version\n * See top-level LICENSE file for more information\n */\n\nimport {getHumanReadableDate} from 'utils/functions';\n\nexport function onModerationPageLoad() {\n populateModerationList();\n}\n\nexport async function populateModerationList() {\n $('#swh-add-forge-now-moderation-list')\n .on('error.dt', (e, settings, techNote, message) => {\n $('#swh-add-forge-now-moderation-list-error').text(message);\n })\n .DataTable({\n serverSide: true,\n processing: true,\n searching: true,\n info: false,\n dom: '<<\"d-flex justify-content-between align-items-center\"f' +\n '<\"#list-exclude\">l>rt<\"bottom\"ip>>',\n ajax: {\n 'url': Urls.add_forge_request_list_datatables()\n },\n columns: [\n {\n data: 'id',\n name: 'id',\n render: function(data, type, row, meta) {\n const dashboardUrl = Urls.add_forge_now_request_dashboard(data);\n return `<a href=${dashboardUrl}>${data}</a>`;\n }\n },\n {\n data: 'submission_date',\n name: 'submission_date',\n render: getHumanReadableDate\n },\n {\n data: 'forge_type',\n name: 'forge_type',\n render: $.fn.dataTable.render.text()\n },\n {\n data: 'forge_url',\n name: 'forge_url',\n render: $.fn.dataTable.render.text()\n },\n {\n data: 'last_moderator',\n name: 'last_moderator',\n render: $.fn.dataTable.render.text()\n },\n {\n data: 'last_modified_date',\n name: 'last_modified_date',\n render: getHumanReadableDate\n },\n {\n data: 'status',\n name: 'status',\n render: function(data, type, row, meta) {\n return swh.add_forge.formatRequestStatusName(data);\n }\n }\n ]\n });\n}\n",
"/**\n * Copyright (C) 2022 The Software Heritage developers\n * See the AUTHORS file at the top-level directory of this distribution\n * License: GNU Affero General Public License version 3, or any later version\n * See top-level LICENSE file for more information\n */\n\nimport {handleFetchError, csrfPost, getHumanReadableDate} from 'utils/functions';\nimport emailTempate from './forge-admin-email.ejs';\nimport requestHistoryItem from './add-request-history-item.ejs';\n\nlet forgeRequest;\n\nexport function onRequestDashboardLoad(requestId) {\n $(document).ready(() => {\n populateRequestDetails(requestId);\n\n $('#contactForgeAdmin').click((event) => {\n contactForgeAdmin(event);\n });\n\n $('#updateRequestForm').submit(async function(event) {\n event.preventDefault();\n try {\n const response = await csrfPost($(this).attr('action'),\n {'Content-Type': 'application/x-www-form-urlencoded'},\n $(this).serialize());\n handleFetchError(response);\n $('#userMessage').text('The request status has been updated ');\n $('#userMessage').removeClass('badge-danger');\n $('#userMessage').addClass('badge-success');\n populateRequestDetails(requestId);\n } catch (response) {\n $('#userMessage').text('Sorry; Updating the request failed');\n $('#userMessage').removeClass('badge-success');\n $('#userMessage').addClass('badge-danger');\n }\n });\n });\n}\n\nasync function populateRequestDetails(requestId) {\n try {\n const response = await fetch(Urls.api_1_add_forge_request_get(requestId));\n handleFetchError(response);\n const data = await response.json();\n forgeRequest = data.request;\n\n $('#requestStatus').text(swh.add_forge.formatRequestStatusName(forgeRequest.status));\n $('#requestType').text(forgeRequest.forge_type);\n $('#requestURL').text(forgeRequest.forge_url);\n $('#requestContactName').text(forgeRequest.forge_contact_name);\n $('#requestContactConsent').text(forgeRequest.submitter_forward_username);\n $('#requestContactEmail').text(forgeRequest.forge_contact_email);\n $('#submitterMessage').text(forgeRequest.forge_contact_comment);\n $('#updateComment').val('');\n\n // Setting data for the email, now adding static data\n $('#contactForgeAdmin').attr('emailTo', forgeRequest.forge_contact_email);\n $('#contactForgeAdmin').attr('emailCc', forgeRequest.inbound_email_address);\n $('#contactForgeAdmin').attr('emailSubject', `Software Heritage archival request for ${forgeRequest.forge_domain}`);\n populateRequestHistory(data.history);\n populateDecisionSelectOption(forgeRequest.status);\n } catch (e) {\n if (e instanceof Response) {\n // The fetch request failed (in handleFetchError), show the error message\n $('#fetchError').removeClass('d-none');\n $('#requestDetails').addClass('d-none');\n } else {\n // Unknown exception, pass it through\n throw e;\n }\n }\n}\n\nfunction populateRequestHistory(history) {\n $('#requestHistory').children().remove();\n\n history.forEach((event, index) => {\n const historyEvent = requestHistoryItem({\n 'event': event,\n 'index': index,\n 'getHumanReadableDate': getHumanReadableDate\n });\n $('#requestHistory').append(historyEvent);\n });\n}\n\nexport function populateDecisionSelectOption(currentStatus) {\n const nextStatusesFor = {\n 'PENDING': ['WAITING_FOR_FEEDBACK', 'REJECTED', 'SUSPENDED'],\n 'WAITING_FOR_FEEDBACK': ['FEEDBACK_TO_HANDLE'],\n 'FEEDBACK_TO_HANDLE': [\n 'WAITING_FOR_FEEDBACK',\n 'ACCEPTED',\n 'REJECTED',\n 'SUSPENDED'\n ],\n 'ACCEPTED': ['SCHEDULED'],\n 'SCHEDULED': [\n 'FIRST_LISTING_DONE',\n 'FIRST_ORIGIN_LOADED'\n ],\n 'FIRST_LISTING_DONE': ['FIRST_ORIGIN_LOADED'],\n 'FIRST_ORIGIN_LOADED': [],\n 'REJECTED': [],\n 'SUSPENDED': ['PENDING'],\n 'DENIED': []\n };\n\n // Determine the possible next status out of the current one\n const nextStatuses = nextStatusesFor[currentStatus];\n\n function addStatusOption(status, index) {\n // Push the next possible status options\n const label = swh.add_forge.formatRequestStatusName(status);\n $('#decisionOptions').append(\n `<option value=\"${status}\">${label}</option>`\n );\n }\n // Remove all the options and add new ones\n $('#decisionOptions').children().remove();\n nextStatuses.forEach(addStatusOption);\n $('#decisionOptions').append(\n '<option hidden disabled selected value> -- Add a comment -- </option>'\n );\n}\n\nfunction contactForgeAdmin(event) {\n // Open the mailclient with pre-filled text\n const mailTo = encodeURIComponent($('#contactForgeAdmin').attr('emailTo'));\n const mailCc = encodeURIComponent($('#contactForgeAdmin').attr('emailCc'));\n const subject = encodeURIComponent($('#contactForgeAdmin').attr('emailSubject'));\n const emailText = encodeURIComponent(emailTempate({'forgeUrl': forgeRequest.forge_url}).trim().replace(/\\n/g, '\\r\\n'));\n const w = window.open('', '_blank', '', true);\n w.location.href = `mailto:${mailTo}?Cc=${mailCc}&Reply-To=${mailCc}&Subject=${subject}&body=${emailText}`;\n w.focus();\n}\n",
"/**\n * Copyright (C) 2019 The Software Heritage developers\n * See the AUTHORS file at the top-level directory of this distribution\n * License: GNU Affero General Public License version 3, or any later version\n * See top-level LICENSE file for more information\n */\n\nimport {staticAsset} from 'utils/functions';\n\n// Constants defining Bootstrap Breakpoints\nexport const BREAKPOINT_SM = 768;\nexport const BREAKPOINT_MD = 992;\nexport const BREAKPOINT_LG = 1200;\n\nexport const swhSpinnerSrc = staticAsset('img/swh-spinner.gif');\n",
"/**\n * Copyright (C) 2018-2020 The Software Heritage developers\n * See the AUTHORS file at the top-level directory of this distribution\n * License: GNU Affero General Public License version 3, or any later version\n * See top-level LICENSE file for more information\n */\n\n// utility functions\n\nimport Cookies from 'js-cookie';\n\nexport function handleFetchError(response) {\n if (!response.ok) {\n throw response;\n }\n return response;\n}\n\nexport function handleFetchErrors(responses) {\n for (let i = 0; i < responses.length; ++i) {\n if (!responses[i].ok) {\n throw responses[i];\n }\n }\n return responses;\n}\n\nexport function errorMessageFromResponse(errorData, defaultMessage) {\n let errorMessage = '';\n try {\n const reason = JSON.parse(errorData['reason']);\n Object.entries(reason).forEach((keys, _) => {\n const key = keys[0];\n const message = keys[1][0]; // take only the first issue\n errorMessage += `\\n${key}: ${message}`;\n });\n } catch (_) {\n errorMessage = errorData['reason']; // can't parse it, leave it raw\n }\n return errorMessage ? `Error: ${errorMessage}` : defaultMessage;\n}\n\nexport function staticAsset(asset) {\n return `${__STATIC__}${asset}`;\n}\n\nexport function csrfPost(url, headers = {}, body = null) {\n headers['X-CSRFToken'] = Cookies.get('csrftoken');\n return fetch(url, {\n credentials: 'include',\n headers: headers,\n method: 'POST',\n body: body\n });\n}\n\nexport function isGitRepoUrl(url, pathPrefix = '/') {\n const allowedProtocols = ['http:', 'https:', 'git:'];\n if (allowedProtocols.find(protocol => protocol === url.protocol) === undefined) {\n return false;\n }\n if (!url.pathname.startsWith(pathPrefix)) {\n return false;\n }\n const re = new RegExp('[\\\\w\\\\.-]+\\\\/?(?!=.git)(?:\\\\.git\\\\/?)?$');\n return re.test(url.pathname.slice(pathPrefix.length));\n};\n\nexport function removeUrlFragment() {\n history.replaceState('', document.title, window.location.pathname + window.location.search);\n}\n\nexport function selectText(startNode, endNode) {\n const selection = window.getSelection();\n selection.removeAllRanges();\n const range = document.createRange();\n range.setStart(startNode, 0);\n if (endNode.nodeName !== '#text') {\n range.setEnd(endNode, endNode.childNodes.length);\n } else {\n range.setEnd(endNode, endNode.textContent.length);\n }\n selection.addRange(range);\n}\n\nexport function htmlAlert(type, message, closable = false) {\n let closeButton = '';\n let extraClasses = '';\n if (closable) {\n closeButton =\n `<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">\n <span aria-hidden=\"true\">×</span>\n </button>`;\n extraClasses = 'alert-dismissible';\n }\n return `<div class=\"alert alert-${type} ${extraClasses}\" role=\"alert\">${message}${closeButton}</div>`;\n}\n\nexport function isValidURL(string) {\n try {\n new URL(string);\n } catch (_) {\n return false;\n }\n return true;\n}\n\nexport async function isArchivedOrigin(originPath) {\n if (!isValidURL(originPath)) {\n // Not a valid URL, return immediately\n return false;\n } else {\n const response = await fetch(Urls.api_1_origin(originPath));\n return response.ok && response.status === 200; // Success response represents an archived origin\n }\n}\n\nasync function getCanonicalGithubOriginURL(ownerRepo) {\n const ghApiResponse = await fetch(`https://api.github.com/repos/${ownerRepo}`);\n if (ghApiResponse.ok && ghApiResponse.status === 200) {\n const ghApiResponseData = await ghApiResponse.json();\n return ghApiResponseData.html_url;\n }\n}\n\nexport async function getCanonicalOriginURL(originUrl) {\n let originUrlLower = originUrl.toLowerCase();\n // github.com URL processing\n const ghUrlRegex = /^http[s]*:\\/\\/github.com\\//;\n if (originUrlLower.match(ghUrlRegex)) {\n // remove trailing .git\n if (originUrlLower.endsWith('.git')) {\n originUrlLower = originUrlLower.slice(0, -4);\n }\n // remove trailing slash\n if (originUrlLower.endsWith('/')) {\n originUrlLower = originUrlLower.slice(0, -1);\n }\n // extract {owner}/{repo}\n const ownerRepo = originUrlLower.replace(ghUrlRegex, '');\n // fetch canonical URL from github Web API\n const url = await getCanonicalGithubOriginURL(ownerRepo);\n if (url) {\n return url;\n }\n }\n\n const ghpagesUrlRegex = /^http[s]*:\\/\\/(?<owner>[^/]+).github.io\\/(?<repo>[^/]+)\\/?.*/;\n const parsedUrl = originUrlLower.match(ghpagesUrlRegex);\n if (parsedUrl) {\n const ownerRepo = `${parsedUrl.groups.owner}/${parsedUrl.groups.repo}`;\n // fetch canonical URL from github Web API\n const url = await getCanonicalGithubOriginURL(ownerRepo);\n if (url) {\n return url;\n }\n }\n\n return originUrl;\n}\n\nexport function getHumanReadableDate(data) {\n // Display iso format date string into a human readable date\n // This is expected to be used by date field in datatable listing views\n // Example: 3/24/2022, 10:31:08 AM\n const date = new Date(data);\n return date.toLocaleString();\n}\n",
"module.exports = function anonymous(locals, escapeFn, include, rethrow\n) {\nescapeFn = escapeFn || function (markup) {\n return markup == undefined\n ? ''\n : String(markup)\n .replace(_MATCH_HTML, encode_char);\n};\nvar _ENCODE_HTML_RULES = {\n\"&\": \"&\"\n , \"<\": \"<\"\n , \">\": \">\"\n , '\"': \""\"\n , \"'\": \"'\"\n }\n , _MATCH_HTML = /[&<>'\"]/g;\nfunction encode_char(c) {\n return _ENCODE_HTML_RULES[c] || c;\n};\n;\n var __output = \"\";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n with (locals || {}) {\n ; __append(\"\\nDear forge administrator,\\n\\nThe mission of Software Heritage is to collect, preserve and share all the\\npublicly available source code (see https://www.softwareheritage.org for more\\ninformation).\\n\\nWe just received a request to add the forge hosted at \")\n ; __append(escapeFn( forgeUrl ))\n ; __append(\" to the\\nlist of software origins that are archived, and it is our understanding that you\\nare the contact person for this forge.\\n\\nIn order to archive the forge contents, we will have to periodically pull the\\npublic repositories it contains and clone them into the\\nSoftware Heritage archive.\\n\\nWould you be so kind as to reply to this message to acknowledge the reception\\nof this email and let us know if there are any special steps we should take in\\norder to properly archive the public repositories hosted on your infrastructure?\\n\\nThank you in advance for your help.\\n\\nKind regards,\\nThe Software Heritage team\\n\")\n }\n return __output;\n\n}",
"module.exports = function anonymous(locals, escapeFn, include, rethrow\n) {\nescapeFn = escapeFn || function (markup) {\n return markup == undefined\n ? ''\n : String(markup)\n .replace(_MATCH_HTML, encode_char);\n};\nvar _ENCODE_HTML_RULES = {\n\"&\": \"&\"\n , \"<\": \"<\"\n , \">\": \">\"\n , '\"': \""\"\n , \"'\": \"'\"\n }\n , _MATCH_HTML = /[&<>'\"]/g;\nfunction encode_char(c) {\n return _ENCODE_HTML_RULES[c] || c;\n};\n;\n var __output = \"\";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n with (locals || {}) {\n ; __append(\"\\n<div class=\\\"custom-control custom-checkbox swhid-option\\\">\\n <input class=\\\"custom-control-input\\\" value=\\\"option-user-requests-filter\\\" type=\\\"checkbox\\\"\\n \")\n ; if (checked) { \n ; __append(\"\\n checked=\\\"checked\\\"\\n \")\n ; } \n ; __append(\"\\n id=\\\"\")\n ; __append(escapeFn( inputId ))\n ; __append(\"\\\">\\n <label class=\\\"custom-control-label font-weight-normal\\\" for=\\\"\")\n ; __append(escapeFn( inputId ))\n ; __append(\"\\\">\\n show only your own requests\\n </label>\\n</div>\\n\")\n }\n return __output;\n\n}",
"/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n\"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n\"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n\"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n\"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n",
"function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\n\nexport default function _asyncToGenerator(fn) {\n return function () {\n var self = this,\n args = arguments;\n return new Promise(function (resolve, reject) {\n var gen = fn.apply(self, args);\n\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n\n _next(undefined);\n });\n };\n}",
"/*! js-cookie v3.0.1 | MIT */\n/* eslint-disable no-var */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n target[key] = source[key];\n }\n }\n return target\n}\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\n\nfunction init (converter, defaultAttributes) {\n function set (key, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n key = encodeURIComponent(key)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n key + '=' + converter.write(value, key) + stringifiedAttributes)\n }\n\n function get (key) {\n if (typeof document === 'undefined' || (arguments.length && !key)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var foundKey = decodeURIComponent(parts[0]);\n jar[foundKey] = converter.read(value, foundKey);\n\n if (key === foundKey) {\n break\n }\n } catch (e) {}\n }\n\n return key ? jar[key] : jar\n }\n\n return Object.create(\n {\n set: set,\n get: get,\n remove: function (key, attributes) {\n set(\n key,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n/* eslint-enable no-var */\n\nexport default api;\n",
"// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n",
"/**\n * Copyright (C) 2022 The Software Heritage developers\n * See the AUTHORS file at the top-level directory of this distribution\n * License: GNU Affero General Public License version 3, or any later version\n * See top-level LICENSE file for more information\n */\n\n// bundle for add forge views\n\nexport * from './add-forge.css';\nexport * from './create-request';\nexport * from './moderation-dashboard';\nexport * from './request-dashboard';\n\nexport function formatRequestStatusName(status) {\n // Mapping to format the request status to a human readable text\n const statusLabel = {\n 'PENDING': 'Pending',\n 'WAITING_FOR_FEEDBACK': 'Waiting for feedback',\n 'FEEDBACK_TO_HANDLE': 'Feedback to handle',\n 'ACCEPTED': 'Accepted',\n 'SCHEDULED': 'Scheduled',\n 'FIRST_LISTING_DONE': 'First listing done',\n 'FIRST_ORIGIN_LOADED': 'First origin loaded',\n 'REJECTED': 'Rejected',\n 'SUSPENDED': 'Suspended',\n 'DENIED': 'Denied'\n };\n return status in statusLabel ? statusLabel[status] : status;\n}\n"