function figure(el, { caption, fullWidth = true } = {}) {
const id = DOM.uid("figure").id;
const captionEl = caption != null ? htl.html`<figcaption>${caption}` : null;
let classnames = [ns];
if (fullWidth) {
classnames.push(`${ns}--full-width`);
}
const ui = htl.html`<figure id=${id} class=${classnames.join(" ")}>
${el}
${captionEl}
</figure>`;
function refLink(text) {
text = text != null ? text : isString(caption) ? caption : "Figure";
const link = htl.html`<a href=${`#${id}`}>${text}`;
link.addEventListener("click", (e) => {
e.preventDefault();
ui.scrollIntoView();
});
return link;
}
initializeStyles();
return Object.assign(ui, { refLink });
}