import { css } from './css.ts'; import { attr } from './attr.ts'; import { classify } from './class.ts'; import { data } from './data.ts'; import { aria } from './aria.ts'; import { on } from './events.ts'; import { DomCollection } from './collection.ts'; import type { StampOptions, StampMap, TemplateConfig, EvListener } from './types.ts'; /** * Normalize a stamp map entry — string shorthand becomes { text }. */ function normalize(entry: string | StampOptions): StampOptions { return typeof entry === 'string' ? { text: entry } : entry; } /** * Shallow-merge two StampOptions — stamp values override base. */ function mergeOptions(base: StampOptions, stamp: StampOptions): StampOptions { return { ...base, ...stamp }; } /** * Apply StampOptions to a single element using standalone DOM functions. */ function applyOptions(el: HTMLElement, opts: StampOptions, signal?: AbortSignal): void { if (opts.text) el.textContent = opts.text; if (opts.class) classify.add(el, opts.class); if (opts.css) css(el, opts.css); if (opts.attrs) attr(el, opts.attrs); if (opts.data) data(el, opts.data); if (opts.aria) aria(el, opts.aria); if (opts.on) { for (const [event, handler] of Object.entries(opts.on)) { on(el, event, handler as EvListener, signal ? { signal } : undefined); } } } /** * Reusable template stamper — configure once, stamp many. * * Caches an HTML `