/**
 * WordPress dependencies
 */
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { __ } from '@wordpress/i18n';

/**
 * Internal dependencies
 */
import Editor from '../editor';
import SidebarNavigationScreen from '../sidebar-navigation-screen';
import DataViewsSidebarContent from '../sidebar-dataviews';
import PostList from '../post-list';
import { unlock } from '../../lock-unlock';
import { PostEdit } from '../post-edit';
import { jsx as _jsx } from "react/jsx-runtime";
const {
  useLocation
} = unlock(routerPrivateApis);
function MobilePagesView() {
  const {
    query = {}
  } = useLocation();
  const {
    canvas = 'view'
  } = query;
  return canvas === 'edit' ? /*#__PURE__*/_jsx(Editor, {}) : /*#__PURE__*/_jsx(PostList, {
    postType: "page"
  });
}
export const pagesRoute = {
  name: 'pages',
  path: '/page',
  areas: {
    sidebar: /*#__PURE__*/_jsx(SidebarNavigationScreen, {
      title: __('Pages'),
      backPath: "/",
      content: /*#__PURE__*/_jsx(DataViewsSidebarContent, {
        postType: "page"
      })
    }),
    content: /*#__PURE__*/_jsx(PostList, {
      postType: "page"
    }),
    preview({
      query
    }) {
      const isListView = (query.layout === 'list' || !query.layout) && query.isCustom !== 'true';
      return isListView ? /*#__PURE__*/_jsx(Editor, {}) : undefined;
    },
    mobile: /*#__PURE__*/_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__*/_jsx(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