"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = App;
var _components = require("@wordpress/components");
var _editor = require("@wordpress/editor");
var _notices = require("@wordpress/notices");
var _data = require("@wordpress/data");
var _i18n = require("@wordpress/i18n");
var _plugins = require("@wordpress/plugins");
var _router = require("@wordpress/router");
var _layout = _interopRequireDefault(require("../layout"));
var _lockUnlock = require("../../lock-unlock");
var _useCommonCommands = require("../../hooks/commands/use-common-commands");
var _useEditModeCommands = require("../../hooks/commands/use-edit-mode-commands");
var _useInitEditedEntityFromUrl = _interopRequireDefault(require("../sync-state-with-url/use-init-edited-entity-from-url"));
var _router2 = _interopRequireDefault(require("../layout/router"));
var _useSetCommandContext = _interopRequireDefault(require("../../hooks/commands/use-set-command-context"));
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const {
  RouterProvider
} = (0, _lockUnlock.unlock)(_router.privateApis);
const {
  GlobalStylesProvider
} = (0, _lockUnlock.unlock)(_editor.privateApis);
function AppLayout() {
  // This ensures the edited entity id and type are initialized properly.
  (0, _useInitEditedEntityFromUrl.default)();
  (0, _useEditModeCommands.useEditModeCommands)();
  (0, _useCommonCommands.useCommonCommands)();
  (0, _useSetCommandContext.default)();
  const route = (0, _router2.default)();
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_layout.default, {
    route: route
  });
}
function App() {
  const {
    createErrorNotice
  } = (0, _data.useDispatch)(_notices.store);
  function onPluginAreaError(name) {
    createErrorNotice((0, _i18n.sprintf)( /* translators: %s: plugin name */
    (0, _i18n.__)('The "%s" plugin has encountered an error and cannot be rendered.'), name));
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SlotFillProvider, {
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(GlobalStylesProvider, {
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.UnsavedChangesWarning, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(RouterProvider, {
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(AppLayout, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_plugins.PluginArea, {
          onError: onPluginAreaError
        })]
      })]
    })
  });
}
//# sourceMappingURL=index.js.map