/* root.tsx generated by @compiled/babel-plugin v0.38.1 */
"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Root = Root;
exports.gridRootId = void 0;
require("./root.compiled.css");
var _runtime = require("@compiled/react/runtime");
var _react = _interopRequireWildcard(require("react"));
var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _skipLinksProvider = require("../../context/skip-links/skip-links-provider");
var _topNavStartContextProvider = require("../../context/top-nav-start/top-nav-start-context-provider");
var _useIsFhsEnabled = require("../fhs-rollout/use-is-fhs-enabled");
var _constants = require("./constants");
var _hoistSlotSizesContext = require("./hoist-slot-sizes-context");
var _elementContext = require("./side-nav/element-context");
var _isSideNavShortcutEnabledContext = require("./side-nav/is-side-nav-shortcut-enabled-context");
var _toggleButtonProvider = require("./side-nav/toggle-button-provider");
var _visibilityProvider = require("./side-nav/visibility-provider");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
// ID of the root element that the banner and top bar slots hoist their sizes to. Only internally exported.
var gridRootId = exports.gridRootId = 'unsafe-design-system-page-layout-root';
var styles = {
  root: "_1e0c11p5 _1tke1kxc _1lmcq9em _yv0ei47z _2z0516ab _1ciragmp _12fkuz0r _12qzrxre _1rqt70if _xkmgbaui _jbc7rxre _tyve1jg8",
  sideNavScrollTimeline: "_10iwgc9s"
};

/**
 * The root component of the navigation system. It wraps the underlying components with the necessary contexts allowing to use certain data and hooks
 * @param skipLinksLabel - The very first element of the layout is a skip links container that can be accessed by pressing Tab button and holds the links to the other sections of the layout thus improving accessibility. This parameter defines the header text for this container
 */
function Root(_ref) {
  var children = _ref.children,
    xcss = _ref.xcss,
    _ref$UNSAFE_dangerous = _ref.UNSAFE_dangerouslyHoistSlotSizes,
    UNSAFE_dangerouslyHoistSlotSizes = _ref$UNSAFE_dangerous === void 0 ? false : _ref$UNSAFE_dangerous,
    _ref$skipLinksLabel = _ref.skipLinksLabel,
    skipLinksLabel = _ref$skipLinksLabel === void 0 ? 'Skip to:' : _ref$skipLinksLabel,
    testId = _ref.testId,
    defaultSideNavCollapsed = _ref.defaultSideNavCollapsed,
    _ref$isSideNavShortcu = _ref.isSideNavShortcutEnabled,
    isSideNavShortcutEnabled = _ref$isSideNavShortcu === void 0 ? false : _ref$isSideNavShortcu;
  var ref = (0, _react.useRef)(null);
  var isFhsEnabled = (0, _useIsFhsEnabled.useIsFhsEnabled)();
  (0, _react.useEffect)(function () {
    if (process.env.NODE_ENV !== 'production') {
      var IGNORED_ELEMENTS = ['SCRIPT', 'STYLE'];
      if (ref.current) {
        Array.from(ref.current.children).forEach(function (child) {
          if (!IGNORED_ELEMENTS.includes(child.tagName) && !child.hasAttribute('data-layout-slot')) {
            // eslint-disable-next-line no-console
            console.error("Page Layout Error\n\nThis element has been forcibly hidden:\n\n", child, "\n\nAn element was rendered as a child of the page layout root that isn't a page layout component! Resolve this error by moving it into a page layout component.\n\nThis message will not be displayed in production.\n");
          }
        });
      }
    }
  }, []);
  return /*#__PURE__*/_react.default.createElement(_visibilityProvider.SideNavVisibilityProvider, {
    defaultCollapsed: defaultSideNavCollapsed
  }, /*#__PURE__*/_react.default.createElement(_toggleButtonProvider.SideNavToggleButtonProvider, null, /*#__PURE__*/_react.default.createElement(_elementContext.SideNavElementProvider, null, /*#__PURE__*/_react.default.createElement(_isSideNavShortcutEnabledContext.IsSideNavShortcutEnabledProvider, {
    isSideNavShortcutEnabled: isSideNavShortcutEnabled
  }, /*#__PURE__*/_react.default.createElement(_topNavStartContextProvider.TopNavStartProvider, null, /*#__PURE__*/_react.default.createElement(_openLayerObserver.OpenLayerObserver, null, /*#__PURE__*/_react.default.createElement(_hoistSlotSizesContext.DangerouslyHoistSlotSizes.Provider, {
    value: UNSAFE_dangerouslyHoistSlotSizes
  }, /*#__PURE__*/_react.default.createElement(_skipLinksProvider.SkipLinksProvider, {
    label: skipLinksLabel,
    testId: testId
  }, /*#__PURE__*/_react.default.createElement("div", {
    ref: ref,
    className: (0, _runtime.ax)([styles.root, isFhsEnabled && (0, _platformFeatureFlags.fg)('platform-dst-side-nav-layering-fixes') && styles.sideNavScrollTimeline, xcss]),
    id: gridRootId,
    "data-testid": testId
  }, children)))))))));
}