/* wp:polyfill */
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
var _exportNames = {
  postTitle: true,
  clipboard: true,
  notices: true
};
exports.clipboard = clipboard;
exports.default = void 0;
exports.notices = notices;
exports.postTitle = void 0;
var _data = require("@wordpress/data");
var _reducer = require("./reducer.js");
Object.keys(_reducer).forEach(function (key) {
  if (key === "default" || key === "__esModule") return;
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  if (key in exports && exports[key] === _reducer[key]) return;
  Object.defineProperty(exports, key, {
    enumerable: true,
    get: function () {
      return _reducer[key];
    }
  });
});
var _defaults = require("./defaults.js");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

_defaults.EDITOR_SETTINGS_DEFAULTS.autosaveInterval = 1; // This is a way to override default behavior on mobile, and make it ping the native save every second as long as something changed

/**
 * Reducer returning the post title state.
 *
 * @param {Object} state  Current state.
 * @param {Object} action Dispatched action.
 *
 * @return {Object} Updated state.
 */
const postTitle = exports.postTitle = (0, _data.combineReducers)({
  isSelected(state = false, action) {
    switch (action.type) {
      case 'TOGGLE_POST_TITLE_SELECTION':
        return action.isSelected;
    }
    return state;
  }
});

/**
 * Reducer returning the clipboard state.
 *
 * @param {Object} state  Current state.
 * @param {Object} action Dispatched action.
 *
 * @return {Object} Updated state.
 */
function clipboard(state = null, action) {
  switch (action.type) {
    case 'UPDATE_CLIPBOARD':
      return action.clipboard;
  }
  return state;
}

/**
 * Reducer returning the notices state.
 *
 * @param {Object} state  Current state.
 * @param {Object} action Dispatched action.
 *
 * @return {Object} Updated state.
 */
function notices(state = [], action) {
  switch (action.type) {
    case 'CREATE_NOTICE':
      return [...state, action.notice];
    case 'REMOVE_ALL_NOTICES':
      return [];
    case 'REMOVE_NOTICE':
      return state.filter(notice => notice.id !== action.id);
  }
  return state;
}
var _default = exports.default = (0, _data.combineReducers)({
  postId: _reducer.postId,
  postType: _reducer.postType,
  postTitle,
  renderingMode: _reducer.renderingMode,
  saving: _reducer.saving,
  postLock: _reducer.postLock,
  postSavingLock: _reducer.postSavingLock,
  template: _reducer.template,
  editorSettings: _reducer.editorSettings,
  clipboard,
  notices
});
//# sourceMappingURL=reducer.native.js.map