import { jsx } from "react/jsx-runtime";
import { loadView } from "@wordpress/views";
import Editor from "../editor";
import SidebarNavigationScreenTemplatesBrowse from "../sidebar-navigation-screen-templates-browse";
import SidebarNavigationScreenUnsupported from "../sidebar-navigation-screen-unsupported";
import PageTemplates from "../page-templates";
import { getDefaultView } from "../page-templates/view-utils";
async function isTemplateListView(query) {
  const { activeView = "active" } = query;
  const view = await loadView({
    kind: "postType",
    name: "wp_template",
    slug: activeView,
    defaultView: getDefaultView(activeView)
  });
  return view.type === "list";
}
const templatesRoute = {
  name: "templates",
  path: "/template",
  areas: {
    sidebar({ siteData }) {
      const isBlockTheme = siteData.currentTheme?.is_block_theme;
      return isBlockTheme ? /* @__PURE__ */ jsx(SidebarNavigationScreenTemplatesBrowse, { backPath: "/" }) : /* @__PURE__ */ jsx(SidebarNavigationScreenUnsupported, {});
    },
    content({ siteData }) {
      const isBlockTheme = siteData.currentTheme?.is_block_theme;
      return isBlockTheme ? /* @__PURE__ */ jsx(PageTemplates, {}) : void 0;
    },
    async preview({ query, siteData }) {
      const isBlockTheme = siteData.currentTheme?.is_block_theme;
      if (!isBlockTheme) {
        return void 0;
      }
      const isListView = await isTemplateListView(query);
      return isListView ? /* @__PURE__ */ jsx(Editor, {}) : void 0;
    },
    mobile({ siteData }) {
      const isBlockTheme = siteData.currentTheme?.is_block_theme;
      return isBlockTheme ? /* @__PURE__ */ jsx(PageTemplates, {}) : /* @__PURE__ */ jsx(SidebarNavigationScreenUnsupported, {});
    }
  },
  widths: {
    async content({ query }) {
      const isListView = await isTemplateListView(query);
      return isListView ? 380 : void 0;
    }
  }
};
export {
  templatesRoute
};
//# sourceMappingURL=templates.js.map
