// @requirements REQ-PRODUCT-TERMS-ACCEPTANCE REQ-PRODUCT-MOBILE REQ-PRODUCT-A11Y import { readFile } from 'node:fs/promises'; import { compileLegalDocuments, createTermsOffer } from 'notabenda/content'; import { renderLegalLinks } from 'notabenda'; export async function agreementFiles(base) { const files = {}; for (const [theme,prefix] of [['light',''],['dark','/dark']]) { const config = structuredClone(base); config.site.id = 'juniper-agreement'; for (const [kind,doc] of Object.entries(config.documents)) doc.route = `${prefix}/agreement/${kind}`; const build = compileLegalDocuments(config,{mode:'preview',stylesheetUrl:prefix ? '/assets/dark.css' : '/assets/notabenda.css'}); const offer = createTermsOffer(build.artifact,{scopeId:`sample-${theme}`,statement:'I agree to this version of the fictional Juniper Notes sample terms.',actionLabel:'Record sample agreement'},{mode:'preview'}); Object.assign(files,Object.fromEntries(Object.entries(build.files).filter(([file])=>file.startsWith('artifacts/') || file.startsWith(`${prefix ? 'dark/' : ''}agreement/`)))); files[`${prefix ? 'dark/' : ''}agreement/offer.json`] = JSON.stringify(offer); files[`${prefix ? 'dark/' : ''}agreement/index.html`] = `Juniper Notes · Terms agreement
Juniper NotesJuniper Notes examples

Terms agreement

Review your terms

Read the terms before agreeing. Your choice is recorded only when saving is confirmed.

`; } files['assets/agreement.mjs'] = await readFile(new URL('./agreement.mjs',import.meta.url),'utf8'); return files; }