"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.defaultLayouts = void 0;
exports.useDefaultViews = useDefaultViews;
var _i18n = require("@wordpress/i18n");
var _icons = require("@wordpress/icons");
var _data = require("@wordpress/data");
var _coreData = require("@wordpress/core-data");
var _element = require("@wordpress/element");
var _constants = require("../../utils/constants");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const defaultLayouts = exports.defaultLayouts = {
  [_constants.LAYOUT_TABLE]: {},
  [_constants.LAYOUT_GRID]: {},
  [_constants.LAYOUT_LIST]: {}
};
const DEFAULT_POST_BASE = {
  type: _constants.LAYOUT_LIST,
  search: '',
  filters: [],
  page: 1,
  perPage: 20,
  sort: {
    field: 'title',
    direction: 'asc'
  },
  showLevels: true,
  titleField: 'title',
  mediaField: 'featured_media',
  fields: ['author', 'status'],
  ...defaultLayouts[_constants.LAYOUT_LIST]
};
function useDefaultViews({
  postType
}) {
  const labels = (0, _data.useSelect)(select => {
    const {
      getPostType
    } = select(_coreData.store);
    return getPostType(postType)?.labels;
  }, [postType]);
  return (0, _element.useMemo)(() => {
    return [{
      title: labels?.all_items || (0, _i18n.__)('All items'),
      slug: 'all',
      icon: _icons.pages,
      view: DEFAULT_POST_BASE
    }, {
      title: (0, _i18n.__)('Published'),
      slug: 'published',
      icon: _icons.published,
      view: DEFAULT_POST_BASE,
      filters: [{
        field: 'status',
        operator: _constants.OPERATOR_IS_ANY,
        value: 'publish'
      }]
    }, {
      title: (0, _i18n.__)('Scheduled'),
      slug: 'future',
      icon: _icons.scheduled,
      view: DEFAULT_POST_BASE,
      filters: [{
        field: 'status',
        operator: _constants.OPERATOR_IS_ANY,
        value: 'future'
      }]
    }, {
      title: (0, _i18n.__)('Drafts'),
      slug: 'drafts',
      icon: _icons.drafts,
      view: DEFAULT_POST_BASE,
      filters: [{
        field: 'status',
        operator: _constants.OPERATOR_IS_ANY,
        value: 'draft'
      }]
    }, {
      title: (0, _i18n.__)('Pending'),
      slug: 'pending',
      icon: _icons.pending,
      view: DEFAULT_POST_BASE,
      filters: [{
        field: 'status',
        operator: _constants.OPERATOR_IS_ANY,
        value: 'pending'
      }]
    }, {
      title: (0, _i18n.__)('Private'),
      slug: 'private',
      icon: _icons.notAllowed,
      view: DEFAULT_POST_BASE,
      filters: [{
        field: 'status',
        operator: _constants.OPERATOR_IS_ANY,
        value: 'private'
      }]
    }, {
      title: (0, _i18n.__)('Trash'),
      slug: 'trash',
      icon: _icons.trash,
      view: {
        ...DEFAULT_POST_BASE,
        type: _constants.LAYOUT_TABLE,
        layout: defaultLayouts[_constants.LAYOUT_TABLE].layout
      },
      filters: [{
        field: 'status',
        operator: _constants.OPERATOR_IS_ANY,
        value: 'trash'
      }]
    }];
  }, [labels]);
}
//# sourceMappingURL=default-views.js.map