Liferay.Loader.define("questions-web@1.0.58/js/pages/NavigationBar.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/link', '@frontend-taglib-clay$clayui/navigation-bar', 'frontend-js-react-web$react', 'questions-web$react-router-dom', '../AppContext.es', '../hooks/useQueryParams.es', '../utils/utils.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports["default"] = void 0;

    var _link = _interopRequireDefault(require("@frontend-taglib-clay$clayui/link"));

    var _navigationBar = _interopRequireDefault(require("@frontend-taglib-clay$clayui/navigation-bar"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _reactRouterDom = require("questions-web$react-router-dom");

    var _AppContext = require("../AppContext.es");

    var _useQueryParams = _interopRequireDefault(require("../hooks/useQueryParams.es"));

    var _utils = require("../utils/utils.es");

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { "default": obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj["default"] = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { "default": obj };
    }

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */
    var _default = (0, _reactRouterDom.withRouter)(function (_ref) {
      var history = _ref.history,
          location = _ref.location;
      var context = (0, _react.useContext)(_AppContext.AppContext);
      var queryParams = (0, _useQueryParams["default"])(location);
      var match = (0, _reactRouterDom.matchPath)(location.pathname, {
        path: '/questions/:sectionTitle/',
        strict: false
      });
      var sectionTitle = match && match.params && match.params.sectionTitle !== 'tag' && match.params.sectionTitle || queryParams.get('sectiontitle');

      var isActive = function isActive(value) {
        return location.pathname === value;
      };

      var historyPushParser = (0, _utils.historyPushWithSlug)(history.push);
      return _react["default"].createElement("section", {
        className: "questions-section questions-section-nav"
      }, _react["default"].createElement("div", {
        className: "questions-container"
      }, _react["default"].createElement("div", {
        className: "row"
      }, _react["default"].createElement("div", {
        className: "align-items-center col d-flex justify-content-between"
      }, _react["default"].createElement(_navigationBar["default"], {
        className: "border-0 navigation-bar",
        triggerLabel: function label() {
          if (location.pathname.includes('tags')) {
            return Liferay.Language.get('tags');
          } else if (location.pathname.includes('activity')) {
            return Liferay.Language.get('my-activity');
          } else if (location.pathname.includes('subscriptions')) {
            return Liferay.Language.get('my-subscriptions');
          }

          return Liferay.Language.get('questions');
        }()
      }, _react["default"].createElement(_navigationBar["default"].Item, {
        active: isActive("/questions/".concat(sectionTitle)) || isActive('/'),
        onClick: function onClick() {
          return historyPushParser(sectionTitle ? "/questions/".concat(sectionTitle) : '/');
        }
      }, _react["default"].createElement(_link["default"], {
        className: "nav-link",
        displayType: "unstyled"
      }, Liferay.Language.get('questions'))), _react["default"].createElement(_navigationBar["default"].Item, {
        active: isActive("/tags"),
        onClick: function onClick() {
          return historyPushParser('/tags');
        }
      }, _react["default"].createElement(_link["default"], {
        className: "nav-link",
        displayType: "unstyled"
      }, Liferay.Language.get('tags'))), _react["default"].createElement(_navigationBar["default"].Item, {
        active: isActive("/subscriptions/".concat(context.userId)),
        className: Liferay.ThemeDisplay.isSignedIn() ? 'ml-md-auto' : 'd-none',
        onClick: function onClick() {
          return historyPushParser("/subscriptions/".concat(context.userId).concat(sectionTitle ? '?sectionTitle=' + sectionTitle : ''));
        }
      }, _react["default"].createElement(_link["default"], {
        className: "nav-link",
        displayType: "unstyled"
      }, Liferay.Language.get('my-subscriptions'))), _react["default"].createElement(_navigationBar["default"].Item, {
        active: isActive("/activity/".concat(context.userId)),
        className: Liferay.ThemeDisplay.isSignedIn() ? '' : 'd-none',
        onClick: function onClick() {
          return historyPushParser("/activity/".concat(context.userId).concat(sectionTitle ? '?sectionTitle=' + sectionTitle : ''));
        }
      }, _react["default"].createElement(_link["default"], {
        className: "nav-link",
        displayType: "unstyled"
      }, Liferay.Language.get('my-activity'))))))));
    });

    exports["default"] = _default;
    //# sourceMappingURL=NavigationBar.es.js.map
  }
});
//# sourceMappingURL=NavigationBar.es.js.map