"// 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) 2021 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 introJs from 'intro.js';\nimport 'intro.js/introjs.css';\nimport './swh-introjs.css';\nimport guidedTourSteps from './guided-tour-steps.yaml';\nimport {disableScrolling, enableScrolling} from 'utils/scrolling';\n\nlet guidedTour = [];\nlet tour = null;\nlet previousElement = null;\n// we use a origin available both in production and swh-web tests\n// environment to ease tour testing\nconst originUrl = 'https://github.com/memononen/libtess2';\n// sha1 for the content used\nconst contentSha1 = 'sha1_git:2d4e23bf1d3f64c1e8b94622178e18d89c653de0';\n\nfunction openSWHIDsTabBeforeNextStep() {\n window.scrollTo(0, 0);\n if (!$('#swh-identifiers').tabSlideOut('isOpen')) {\n $('.introjs-helperLayer, .introjs-tooltipReferenceLayer').hide();\n $('#swh-identifiers').tabSlideOut('open');\n setTimeout(() => {\n $('.introjs-helperLayer, .introjs-tooltipReferenceLayer').show();\n tour.nextStep();\n }, 500);\n return false;\n }\n return true;\n}\n\n// init guided tour configuration when page loads in order\n// to hack on it in cypress tests\n$(() => {\n // tour is defined by an array of objects containing:\n // - URL of page to run a tour\n // - intro.js configuration with tour steps\n // - optional intro.js callback function for tour interactivity\n guidedTour = [\n {\n url: Urls.swh_web_homepage(),\n introJsOptions: {\n disableInteraction: true,\n scrollToElement: false,\n steps: guidedTourSteps.homepage\n }\n },\n {\n url: `${Urls.browse_origin_directory()}?origin_url=${originUrl}`,\n introJsOptions: {\n disableInteraction: true,\n scrollToElement: false,\n steps: guidedTourSteps.browseOrigin\n },\n onBeforeChange: function(targetElement) {\n // open SWHIDs tab before its tour step\n if (targetElement && targetElement.id === 'swh-identifiers') {\n return openSWHIDsTabBeforeNextStep();\n }\n return true;\n }\n },\n {\n url: `${Urls.browse_content(contentSha1)}?origin_url=${originUrl}&path=Example/example.c`,\n introJsOptions: {\n steps: guidedTourSteps.browseContent\n },\n onBeforeChange: function(targetElement) {\n const lineNumberStart = 11;\n const lineNumberEnd = 17;\n if (targetElement && $(targetElement).hasClass('swhid')) {\n return openSWHIDsTabBeforeNextStep();\n // forbid move to next step until user clicks on line numbers\n } else if (targetElement && targetElement.dataset.lineNumber === `${lineNumberEnd}`) {\n const background = $(`.hljs-ln-numbers[data-line-number=\"${lineNumberStart}\"]`).css('background-color');\n const canGoNext = background !== 'rgba(0, 0, 0, 0)';\n if (!canGoNext && $('#swh-next-step-disabled').length === 0) {\n $('.introjs-tooltiptext').append(\n `<p id=\"swh-next-step-disabled\" style=\"color: red; font-weight: bold\">\n You need to select the line number before proceeding to<br/>next step.\n </p>`);\n }\n previousElement = targetElement;\n return canGoNext;\n } else if (previousElement && previousElement.dataset.lineNumber === `${lineNumberEnd}`) {\n let canGoNext = true;\n for (let i = lineNumberStart; i <= lineNumberEnd; ++i) {\n const background = $(`.hljs-ln-numbers[data-line-number=\"${i}\"]`).css('background-color');\n canGoNext = canGoNext && background !== 'rgba(0, 0, 0, 0)';\n if (!canGoNext) {\n swh.webapp.resetHighlightedLines();\n swh.webapp.scrollToLine(swh.webapp.highlightLine(lineNumberStart, true));\n if ($('#swh-next-step-disabled').length === 0) {\n $('.introjs-tooltiptext').append(\n `<p id=\"swh-next-step-disabled\" style=\"color: red; font-weight: bold\">\n You need to select the line numbers range from ${lineNumberStart}\n to ${lineNumberEnd} before proceeding to next step.\n </p>`);\n }\n break;\n }\n }\n return canGoNext;\n }\n previousElement = targetElement;\n return true;\n }\n }\n ];\n // init guided tour on page if guided_tour query parameter is present\n const searchParams = new URLSearchParams(window.location.search);\n if (searchParams && searchParams.has('guided_tour')) {\n initGuidedTour(parseInt(searchParams.get('guided_tour')));\n }\n});\n\nexport function getGuidedTour() {\n return guidedTour;\n}\n\nexport function guidedTourButtonClick(event) {\n event.preventDefault();\n initGuidedTour();\n}\n\nexport function initGuidedTour(page = 0) {\n if (page >= guidedTour.length) {\n return;\n }\n const pageUrl = new URL(window.location.origin + guidedTour[page].url);\n const currentUrl = new URL(window.location.href);\n const guidedTourNext = currentUrl.searchParams.get('guided_tour_next');\n currentUrl.searchParams.delete('guided_tour');\n currentUrl.searchParams.delete('guided_tour_next');\n const pageUrlStr = decodeURIComponent(pageUrl.toString());\n const currentUrlStr = decodeURIComponent(currentUrl.toString());\n if (currentUrlStr !== pageUrlStr) {\n // go to guided tour page URL if current one does not match\n pageUrl.searchParams.set('guided_tour', page);\n if (page === 0) {\n // user will be redirected to the page he was at the end of the tour\n pageUrl.searchParams.set('guided_tour_next', currentUrlStr);\n }\n window.location = decodeURIComponent(pageUrl.toString());\n } else {\n // create intro.js guided tour and configure it\n tour = introJs().setOptions(guidedTour[page].introJsOptions);\n tour.setOptions({\n 'exitOnOverlayClick': false,\n 'showBullets': false\n });\n if (page < guidedTour.length - 1) {\n // if not on the last page of the tour, rename next button label\n // and schedule next page loading when clicking on it\n tour.setOption('doneLabel', 'Next page')\n .onexit(() => {\n // re-enable page scrolling when exiting tour\n enableScrolling();\n })\n .oncomplete(() => {\n const nextPageUrl = new URL(window.location.origin + guidedTour[page + 1].url);\n nextPageUrl.searchParams.set('guided_tour', page + 1);\n if (guidedTourNext) {\n nextPageUrl.searchParams.set('guided_tour_next', guidedTourNext);\n } else if (page === 0) {\n nextPageUrl.searchParams.set('guided_tour_next', currentUrlStr);\n }\n window.location.href = decodeURIComponent(nextPageUrl.toString());\n });\n } else {\n tour.oncomplete(() => {\n enableScrolling(); // re-enable page scrolling when tour is complete\n if (guidedTourNext) {\n window.location.href = guidedTourNext;\n }\n });\n }\n if (guidedTour[page].hasOwnProperty('onBeforeChange')) {\n tour.onbeforechange(guidedTour[page].onBeforeChange);\n }\n setTimeout(() => {\n // run guided tour with a little delay to ensure every asynchronous operations\n // after page load have been executed\n disableScrolling(); // disable page scrolling with mouse or keyboard while tour runs.\n tour.start();\n window.scrollTo(0, 0);\n }, 500);\n }\n};\n"