Liferay.Loader.define("site-navigation-admin-web@3.0.25/site_navigation_menu_editor/components/AppLayout", ['module', 'exports', 'require', 'frontend-js-react-web$classnames', 'frontend-js-react-web$prop-types', 'frontend-js-react-web$react', '../contexts/SidebarPanelIdContext'], 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.AppLayout = void 0;

    var _classnames = _interopRequireDefault(require("frontend-js-react-web$classnames"));

    var _propTypes = _interopRequireDefault(require("frontend-js-react-web$prop-types"));

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

    var _SidebarPanelIdContext = require("../contexts/SidebarPanelIdContext");

    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_SIDEBAR_PANELS = [];

    var AppLayout = function AppLayout(_ref) {
      var contentChildren = _ref.contentChildren,
          _ref$sidebarPanels = _ref.sidebarPanels,
          sidebarPanels = _ref$sidebarPanels === void 0 ? DEFAULT_SIDEBAR_PANELS : _ref$sidebarPanels,
          toolbarChildren = _ref.toolbarChildren;
      var setSidebarPanelId = (0, _SidebarPanelIdContext.useSetSidebarPanelId)();
      var sidebarPanelId = (0, _SidebarPanelIdContext.useSidebarPanelId)();
      var SidebarPanel = (0, _react.useMemo)(function () {
        var _sidebarPanels$find;

        return sidebarPanels === null || sidebarPanels === void 0 ? void 0 : (_sidebarPanels$find = sidebarPanels.find(function (sidebarPanel) {
          return sidebarPanel.sidebarPanelId === sidebarPanelId;
        })) === null || _sidebarPanels$find === void 0 ? void 0 : _sidebarPanels$find.component;
      }, [sidebarPanelId, sidebarPanels]);
      (0, _react.useEffect)(function () {
        var handler = onProductMenuOpen(function () {
          return setSidebarPanelId(null);
        });
        return function () {
          handler.removeListener();
        };
      }, [setSidebarPanelId]);
      (0, _react.useEffect)(function () {
        setSidebarPanelId(null);
      }, [setSidebarPanelId, sidebarPanels]);
      (0, _react.useEffect)(function () {
        if (SidebarPanel) {
          closeProductMenu();
        }
      }, [SidebarPanel]);
      return _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement("div", {
        className: "bg-white component-tbar tbar"
      }, _react["default"].createElement("div", {
        className: "container-fluid container-fluid-max-xl"
      }, _react["default"].createElement("div", {
        className: "px-1 tbar-nav"
      }, toolbarChildren))), _react["default"].createElement("div", {
        className: (0, _classnames["default"])('align-items-stretch d-flex site_navigation_menu_editor_AppLayout-content', {
          'site_navigation_menu_editor_AppLayout-content--with-sidebar': !!SidebarPanel
        })
      }, _react["default"].createElement("div", {
        className: "flex-grow-1"
      }, contentChildren), _react["default"].createElement("div", {
        className: (0, _classnames["default"])('site_navigation_menu_editor_AppLayout-sidebar', {
          'site_navigation_menu_editor_AppLayout-sidebar--visible': !!SidebarPanel
        })
      }, SidebarPanel && _react["default"].createElement(SidebarPanel, null))));
    };

    exports.AppLayout = AppLayout;

    AppLayout.ToolbarItem = function (_ref2) {
      var children = _ref2.children,
          expand = _ref2.expand;
      return _react["default"].createElement("li", {
        className: (0, _classnames["default"])('tbar-item', {
          'tbar-item-expand': expand
        })
      }, children);
    };

    AppLayout.ToolbarItem.propTypes = {
      children: _propTypes["default"].node,
      expand: _propTypes["default"].bool
    };

    function closeProductMenu() {
      Liferay.SideNavigation.hide(document.querySelector('.product-menu-toggle'));
    }

    function onProductMenuOpen(fn) {
      var _Liferay$SideNavigati, _Liferay$SideNavigati2;

      return (_Liferay$SideNavigati = (_Liferay$SideNavigati2 = Liferay.SideNavigation.instance(document.querySelector('.product-menu-toggle'))) === null || _Liferay$SideNavigati2 === void 0 ? void 0 : _Liferay$SideNavigati2.on('openStart.lexicon.sidenav', fn)) !== null && _Liferay$SideNavigati !== void 0 ? _Liferay$SideNavigati : {
        removeListener: function removeListener() {}
      };
    }
    //# sourceMappingURL=AppLayout.js.map
  }
});
//# sourceMappingURL=AppLayout.js.map