/* eslint-disable @next/internal/no-ambiguous-jsx -- whole module is used in React Client */ import React, { type JSX } from 'react' import { isHTTPAccessFallbackError } from '../../client/components/http-access-fallback/http-access-fallback' import { getURLFromRedirectError, getRedirectStatusCodeFromError, } from '../../client/components/redirect' import { isRedirectError } from '../../client/components/redirect-error' import { renderToReadableStream } from 'react-dom/server' import { streamToString } from '../stream-utils/node-web-streams-helper' import { RedirectStatusCode } from '../../client/components/redirect-status-code' import { addPathPrefix } from '../../shared/lib/router/utils/add-path-prefix' import type { ClientTraceDataEntry } from '../lib/trace/tracer' export function makeGetServerInsertedHTML({ polyfills, renderServerInsertedHTML, serverCapturedErrors, tracingMetadata, basePath, }: { polyfills: JSX.IntrinsicElements['script'][] renderServerInsertedHTML: () => React.ReactNode tracingMetadata: ClientTraceDataEntry[] | undefined serverCapturedErrors: Array basePath: string }) { let flushedErrorMetaTagsUntilIndex = 0 // These only need to be rendered once, they'll be set to empty arrays once flushed. let polyfillTags = polyfills.map((polyfill) => { return