'use strict'; const fs = require('node:fs'); const path = require('node:path'); const node_url = require('node:url'); const __epubook_core = require('@epubook/core'); function _interopNamespaceCompat(e) { if (e && typeof e === 'object' && 'default' in e) return e; const n = Object.create(null); if (e) { for (const k in e) { n[k] = e[k]; } } n.default = e; return n; } const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs); const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path); const __epubook_core__namespace = /*#__PURE__*/_interopNamespaceCompat(__epubook_core); const Chapter = (file, { title, content }) => { const lines = content.split(/\r?\n/); return new __epubook_core.XHTMLBuilder(file).title(title).body( /* @__PURE__ */ __epubook_core__namespace.h(__epubook_core__namespace.Fragment, null, /* @__PURE__ */ __epubook_core__namespace.h("h2", null, title), lines.map((l) => /* @__PURE__ */ __epubook_core__namespace.h("p", null, l))) ); }; const styles = ["./styles/main.css", "./styles/cover.css"]; async function DefaultTheme() { return { name: "@epubook/theme-default", styles: await Promise.all(styles.map((d) => loadStyle(d))), images: [], pages: { cover(file, { image, title = "\u5C01\u9762" }) { return new __epubook_core.XHTMLBuilder(file).title(title).bodyAttrs({ class: "cover" }).body({ tag: "img", attrs: { src: image.relative(file) } }); }, nav(file, { nav, option }) { if (!option.title) { option.title = "\u76EE\u5F55"; } return new __epubook_core.XHTMLBuilder(file).title("\u76EE\u5F55"); }, chapter: Chapter } }; } async function loadStyle(dir) { const d = path__namespace.join(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))), "../../", dir); return fs__namespace.promises.readFile(d, "utf-8"); } exports.Chapter = Chapter; exports.DefaultTheme = DefaultTheme;