"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.pagesRoute = void 0;
var _router = require("@wordpress/router");
var _i18n = require("@wordpress/i18n");
var _editor = _interopRequireDefault(require("../editor"));
var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
var _sidebarDataviews = _interopRequireDefault(require("../sidebar-dataviews"));
var _postList = _interopRequireDefault(require("../post-list"));
var _lockUnlock = require("../../lock-unlock");
var _postEdit = require("../post-edit");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const {
  useLocation
} = (0, _lockUnlock.unlock)(_router.privateApis);
function MobilePagesView() {
  const {
    query = {}
  } = useLocation();
  const {
    canvas = 'view'
  } = query;
  return canvas === 'edit' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_postList.default, {
    postType: "page"
  });
}
const pagesRoute = exports.pagesRoute = {
  name: 'pages',
  path: '/page',
  areas: {
    sidebar: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationScreen.default, {
      title: (0, _i18n.__)('Pages'),
      backPath: "/",
      content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarDataviews.default, {
        postType: "page"
      })
    }),
    content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_postList.default, {
      postType: "page"
    }),
    preview({
      query
    }) {
      const isListView = (query.layout === 'list' || !query.layout) && query.isCustom !== 'true';
      return isListView ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.default, {}) : undefined;
    },
    mobile: /*#__PURE__*/(0, _jsxRuntime.jsx)(MobilePagesView, {}),
    edit({
      query
    }) {
      var _query$layout;
      const hasQuickEdit = ((_query$layout = query.layout) !== null && _query$layout !== void 0 ? _query$layout : 'list') !== 'list' && !!query.quickEdit;
      return hasQuickEdit ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_postEdit.PostEdit, {
        postType: "page",
        postId: query.postId
      }) : undefined;
    }
  },
  widths: {
    content({
      query
    }) {
      const isListView = (query.layout === 'list' || !query.layout) && query.isCustom !== 'true';
      return isListView ? 380 : undefined;
    },
    edit({
      query
    }) {
      var _query$layout2;
      const hasQuickEdit = ((_query$layout2 = query.layout) !== null && _query$layout2 !== void 0 ? _query$layout2 : 'list') !== 'list' && !!query.quickEdit;
      return hasQuickEdit ? 380 : undefined;
    }
  }
};
//# sourceMappingURL=pages.js.map