"use client";
import { jsx } from 'react/jsx-runtime';
import { lazy } from 'react';
import { usePluginOverrides } from '@btst/stack/context';
import { ComposedRoute } from '@btst/stack/client/components';
import { DefaultError } from '../shared/default-error.mjs';
import { PostLoading } from '../loading/index.mjs';
import { NotFoundPage } from './404-page.mjs';

const PostPage = lazy(
  () => import('./post-page.internal.mjs').then((m) => ({ default: m.PostPage }))
);
function PostPageComponent({ slug }) {
  const { onRouteError } = usePluginOverrides("blog");
  return /* @__PURE__ */ jsx(
    ComposedRoute,
    {
      path: `/blog/${slug}`,
      PageComponent: PostPage,
      ErrorComponent: DefaultError,
      LoadingComponent: PostLoading,
      NotFoundComponent: NotFoundPage,
      props: { slug },
      onError: (error) => {
        if (onRouteError) {
          onRouteError("post", error, {
            path: `/blog/${slug}`,
            isSSR: typeof window === "undefined",
            slug
          });
        }
      }
    }
  );
}

export { PostPageComponent };
