import{readFileSync as u}from"fs";import R from"mustache";import*as I from"path";import{withPathPrefix as r}from"@redocly/theme/core/utils";import{RUNTIME_RESOURCES_DIR as t}from"../constants/common.js";import{INIT_BROWSER_HOOKS_SCRIPT as T}from"./init-browser-hooks-script.js";function O(e,{title:o,favicon:i,preload:s,bodyHtml:m,linkTags:n,headScriptTags:c,postBodyScriptTags:p,preBodyScriptTags:l}){const a=`<link rel="stylesheet" href="${r(t)}/browser-entry.css" />`,d=`<script async type="module" src="${r(t)}/browser-entry.js"></script>`,f=I.resolve(e),S=R.render(u(f).toString(),{title:o,favicon:i,redocHTML:m,preload:T+(s?.join(`
`)||""),redocHead:(n||"")+a,headScriptTags:c,postBodyScriptTags:p,preBodyScriptTags:l}),[h,y]=S.split("</body>");return`${h}${d}</body>${y}`}export{O as compileCustomTemplate};
