"use client";
'use strict';

const jsxRuntime = require('react/jsx-runtime');
const React = require('react');
const context = require('@btst/stack/context');
const components = require('@btst/stack/client/components');
const defaultError = require('../shared/default-error.cjs');
const _404Page = require('./404-page.cjs');
const editorSkeleton = require('../loading/editor-skeleton.cjs');

const ContentEditorPageInternal = React.lazy(
  () => import('./content-editor-page.internal.cjs').then((m) => ({
    default: m.ContentEditorPage
  }))
);
function ContentEditorPageComponent({
  typeSlug,
  id
}) {
  const { onRouteError } = context.usePluginOverrides("cms");
  const isNew = !id;
  const path = isNew ? `/cms/${typeSlug}/new` : `/cms/${typeSlug}/${id}`;
  return /* @__PURE__ */ jsxRuntime.jsx(
    components.ComposedRoute,
    {
      path,
      PageComponent: ContentEditorPageInternal,
      ErrorComponent: defaultError.DefaultError,
      LoadingComponent: editorSkeleton.EditorSkeleton,
      NotFoundComponent: _404Page.NotFoundPage,
      props: { typeSlug, id },
      onError: (error) => {
        if (onRouteError) {
          onRouteError("contentEditor", error, {
            path,
            params: { typeSlug, id: id ?? "" },
            isSSR: typeof window === "undefined"
          });
        }
      }
    }
  );
}

exports.ContentEditorPageComponent = ContentEditorPageComponent;
