"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
var _exportNames = {
  initializeEditor: true,
  reinitializeEditor: true,
  store: true,
  PluginTemplateSettingPanel: true,
  initializePostsDashboard: true
};
Object.defineProperty(exports, "PluginTemplateSettingPanel", {
  enumerable: true,
  get: function () {
    return _pluginTemplateSettingPanel.default;
  }
});
exports.initializeEditor = initializeEditor;
Object.defineProperty(exports, "initializePostsDashboard", {
  enumerable: true,
  get: function () {
    return _posts.initializePostsDashboard;
  }
});
exports.reinitializeEditor = reinitializeEditor;
Object.defineProperty(exports, "store", {
  enumerable: true,
  get: function () {
    return _store.store;
  }
});
var _blocks = require("@wordpress/blocks");
var _blockLibrary = require("@wordpress/block-library");
var _data = require("@wordpress/data");
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
var _element = require("@wordpress/element");
var _editor = require("@wordpress/editor");
var _preferences = require("@wordpress/preferences");
var _widgets = require("@wordpress/widgets");
require("./hooks");
var _store = require("./store");
var _lockUnlock = require("./lock-unlock");
var _app = _interopRequireDefault(require("./components/app"));
var _jsxRuntime = require("react/jsx-runtime");
var _pluginTemplateSettingPanel = _interopRequireDefault(require("./components/plugin-template-setting-panel"));
var _deprecated2 = require("./deprecated");
Object.keys(_deprecated2).forEach(function (key) {
  if (key === "default" || key === "__esModule") return;
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  if (key in exports && exports[key] === _deprecated2[key]) return;
  Object.defineProperty(exports, key, {
    enumerable: true,
    get: function () {
      return _deprecated2[key];
    }
  });
});
var _posts = require("./posts");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const {
  registerCoreBlockBindingsSources
} = (0, _lockUnlock.unlock)(_editor.privateApis);

/**
 * Initializes the site editor screen.
 *
 * @param {string} id       ID of the root element to render the screen in.
 * @param {Object} settings Editor settings.
 */
function initializeEditor(id, settings) {
  const target = document.getElementById(id);
  const root = (0, _element.createRoot)(target);
  (0, _data.dispatch)(_blocks.store).reapplyBlockTypeFilters();
  const coreBlocks = (0, _blockLibrary.__experimentalGetCoreBlocks)().filter(({
    name
  }) => name !== 'core/freeform');
  (0, _blockLibrary.registerCoreBlocks)(coreBlocks);
  registerCoreBlockBindingsSources();
  (0, _data.dispatch)(_blocks.store).setFreeformFallbackBlockName('core/html');
  (0, _widgets.registerLegacyWidgetBlock)({
    inserter: false
  });
  (0, _widgets.registerWidgetGroupBlock)({
    inserter: false
  });
  if (globalThis.IS_GUTENBERG_PLUGIN) {
    (0, _blockLibrary.__experimentalRegisterExperimentalCoreBlocks)({
      enableFSEBlocks: true
    });
  }

  // We dispatch actions and update the store synchronously before rendering
  // so that we won't trigger unnecessary re-renders with useEffect.
  (0, _data.dispatch)(_preferences.store).setDefaults('core/edit-site', {
    welcomeGuide: true,
    welcomeGuideStyles: true,
    welcomeGuidePage: true,
    welcomeGuideTemplate: true
  });
  (0, _data.dispatch)(_preferences.store).setDefaults('core', {
    allowRightClickOverrides: true,
    distractionFree: false,
    editorMode: 'visual',
    editorTool: 'edit',
    fixedToolbar: false,
    focusMode: false,
    inactivePanels: [],
    keepCaretInsideBlock: false,
    openPanels: ['post-status'],
    showBlockBreadcrumbs: true,
    showListViewByDefault: false,
    enableChoosePatternModal: true
  });
  if (window.__experimentalMediaProcessing) {
    (0, _data.dispatch)(_preferences.store).setDefaults('core/media', {
      requireApproval: true,
      optimizeOnUpload: true
    });
  }
  (0, _data.dispatch)(_store.store).updateSettings(settings);

  // Prevent the default browser action for files dropped outside of dropzones.
  window.addEventListener('dragover', e => e.preventDefault(), false);
  window.addEventListener('drop', e => e.preventDefault(), false);
  root.render(/*#__PURE__*/(0, _jsxRuntime.jsx)(_element.StrictMode, {
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_app.default, {})
  }));
  return root;
}
function reinitializeEditor() {
  (0, _deprecated.default)('wp.editSite.reinitializeEditor', {
    since: '6.2',
    version: '6.3'
  });
}

// Temporary: While the posts dashboard is being iterated on
// it's being built in the same package as the site editor.
//# sourceMappingURL=index.js.map