"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const htmlReactParser = require("html-react-parser");
function getSSRStyles(html, server) {
  return server.constructStyleTagsFromChunks(server.extractCriticalToChunks(html));
}
function ServerStyles({ html, server }) {
  const styles = getSSRStyles(html, server);
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: htmlReactParser(styles) });
}
function createGetInitialProps(NextDocument, server) {
  return async function getInitialProps(ctx) {
    const initialProps = await NextDocument.getInitialProps(ctx);
    return {
      ...initialProps,
      styles: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
        initialProps.styles,
        /* @__PURE__ */ jsxRuntime.jsx(ServerStyles, { html: initialProps.html, server })
      ] })
    };
  };
}
exports.ServerStyles = ServerStyles;
exports.createGetInitialProps = createGetInitialProps;
exports.getSSRStyles = getSSRStyles;
