"use strict";
/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackChunkdoctrine_website"] = self["webpackChunkdoctrine_website"] || []).push([["sidebar"],{

/***/ "./source/js/sidebar.js":
/*!******************************!*\
  !*** ./source/js/sidebar.js ***!
  \******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* provided dependency */ var $ = __webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\");\nwindow.String.prototype.replaceAll = function (search, replacement) {\n  var target = this;\n\n  return target.split(search).join(replacement);\n};\n\nvar Sidebar = function () {\n  this.loadCurrentDocsMenu();\n  this.initVersionLinks();\n\n  $('[data-toggle=\"offcanvas\"]').click(function () {\n    $('.row-offcanvas').toggleClass('active');\n    $('.sidebar').toggle();\n  });\n\n  $('.toc-item').on('click', function () {\n    $('.toc-toggle').click();\n  });\n\n  var self = this;\n\n  window.onhashchange = function () {\n    self.loadCurrentDocsMenu();\n    self.initVersionLinks();\n  };\n};\n\nSidebar.prototype.initVersionLinks = function () {\n  $('.project-version-switcher').each(function () {\n    var linkUrl = $(this).attr('href').split('#')[0];\n\n    $(this).attr('href', linkUrl + window.location.hash);\n  });\n};\n\nSidebar.prototype.getTopLevelParent = function (elem) {\n  // scroll menu to element\n  var topLevelParent = elem.parent('ul').prev('li').parent('ul').prev('li');\n\n  if (!topLevelParent.length) {\n    topLevelParent = elem.parent('ul').prev('li');\n  }\n\n  if (!topLevelParent.length) {\n    topLevelParent = elem;\n  }\n\n  return topLevelParent;\n};\n\nSidebar.prototype.scrollToElement = function (elem) {\n  var topLevelParent = this.getTopLevelParent(elem);\n\n  var topElem = document.getElementById(topLevelParent.attr('id'));\n\n  if (topElem) {\n    var offsetTop = topElem.offsetTop;\n\n    $('.sidebar-sticky').scrollTop(offsetTop);\n  }\n};\n\nSidebar.prototype.removeQueryStringParameter = function (key, url) {\n  if (!url) url = window.location.href;\n\n  var hashParts = url.split('#');\n\n  var regex = new RegExp('([?&])' + key + '=.*?(&|#|$)', 'i');\n\n  if (hashParts[0].match(regex)) {\n    //REMOVE KEY AND VALUE\n    url = hashParts[0].replace(regex, '$1');\n\n    //REMOVE TRAILING ? OR &\n    url = url.replace(/([?&])$/, '');\n\n    //ADD HASH\n    if (typeof hashParts[1] !== 'undefined' && hashParts[1] !== null)\n      url += '#' + hashParts[1];\n  }\n\n  return url;\n};\n\nSidebar.prototype.getCurrentDocsMenu = function () {\n  var currentUrl = this.removeQueryStringParameter('q', window.location.href);\n  var lastPart = currentUrl.substr(currentUrl.lastIndexOf('/') + 1);\n  var primaryHash = $('h1.section-header a').attr('href');\n\n  if (!lastPart) {\n    lastPart = 'index.html';\n  }\n\n  if (lastPart[0] === '#') {\n    lastPart = 'index.html' + lastPart;\n  }\n\n  if (!window.location.hash) {\n    lastPart = lastPart + primaryHash;\n  }\n\n  var id = this.normalize(lastPart);\n  var lastPartWithPrimaryHash =\n    lastPart.substr(0, lastPart.lastIndexOf('#')) + primaryHash;\n  var idWithPrimaryHash = this.normalize(lastPartWithPrimaryHash);\n\n  // try the current link with the hash\n  var currentDocsMenu = $('#' + id);\n\n  // if we can't find it, open the primary menu item for this page\n  if (!currentDocsMenu.length) {\n    currentDocsMenu = $('#' + idWithPrimaryHash);\n  }\n\n  return currentDocsMenu;\n};\n\nSidebar.prototype.normalize = function (string) {\n  return string\n    .replaceAll('../', '')\n    .replaceAll('#', '-')\n    .replaceAll('.', '-')\n    .replaceAll('/', '-')\n    .replaceAll('_', '-');\n};\n\nSidebar.prototype.closeAll = function () {\n  $('.opened').removeClass('opened');\n  $('.opened-ul').removeClass('opened-ul');\n};\n\nSidebar.prototype.openElement = function (elem) {\n  elem.addClass('opened');\n\n  // top level clicked, open children\n  elem.find('ul').first().addClass('opened-ul').removeClass('closed-ul');\n\n  // child clicked, open parents\n  elem.parents('ul').addClass('opened-ul').removeClass('closed-ul');\n  elem.parents('ul').parent('li').addClass('opened');\n};\n\nSidebar.prototype.loadCurrentDocsMenu = function () {\n  var currentDocsMenu = this.getCurrentDocsMenu();\n\n  if (!currentDocsMenu.length) {\n    return;\n  }\n\n  this.closeAll();\n\n  this.openElement(currentDocsMenu);\n\n  this.scrollToElement(currentDocsMenu);\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Sidebar);\n\n\n//# sourceURL=webpack://doctrine-website/./source/js/sidebar.js?");

/***/ })

}]);