"use client";
'use strict';

const jsxRuntime = require('react/jsx-runtime');
const context = require('@btst/stack/context');
const postForms = require('../forms/post-forms.cjs');
const pageHeader = require('../shared/page-header.cjs');
const pageWrapper = require('../shared/page-wrapper.cjs');
const index = require('../../localization/index.cjs');
const useRouteLifecycle = require('../../../../../../../ui/src/hooks/use-route-lifecycle.cjs');

function NewPostPage() {
  const overrides = context.usePluginOverrides("blog", {
    localization: index.BLOG_LOCALIZATION
  });
  const { localization, navigate } = overrides;
  const basePath = context.useBasePath();
  useRouteLifecycle.useRouteLifecycle({
    routeName: "newPost",
    context: {
      path: "/blog/new",
      isSSR: typeof window === "undefined"
    },
    overrides,
    beforeRenderHook: (overrides2, context) => {
      if (overrides2.onBeforeNewPostPageRendered) {
        return overrides2.onBeforeNewPostPageRendered(context);
      }
      return true;
    }
  });
  const handleClose = () => {
    navigate(`${basePath}/blog`);
  };
  const handleSuccess = (post) => {
    if (post.published) {
      navigate(`${basePath}/blog`);
    } else {
      navigate(`${basePath}/blog/drafts`);
    }
  };
  return /* @__PURE__ */ jsxRuntime.jsxs(pageWrapper.PageWrapper, { className: "gap-6", testId: "new-post-page", children: [
    /* @__PURE__ */ jsxRuntime.jsx(
      pageHeader.PageHeader,
      {
        title: localization.BLOG_POST_ADD_TITLE,
        description: localization.BLOG_POST_ADD_DESCRIPTION
      }
    ),
    /* @__PURE__ */ jsxRuntime.jsx(postForms.AddPostForm, { onClose: handleClose, onSuccess: handleSuccess })
  ] });
}

exports.NewPostPage = NewPostPage;
