// Generated, do not edit. sha256:618e9d10819427320df9cea13ee26eca05db3121f4e69b541d2a8a431e85957a
import { esc } from './escape.js';
const MOUNT = 'page-hint';
const INFO = '';
let lead = '';
let empty = null;
export function configureHint({ lead: l = '', empty: e = null } = {}) {
lead = l || '';
empty = e;
}
function legend(title, content, className = '') {
return `
${esc(title)}
${lead}
${content}
`;
}
export function setPageHint(host, { title, rows = [] } = {}) {
const mount = document.getElementById(MOUNT);
if (!mount || !host?.isConnected) return;
mount.innerHTML = legend(title, rows.map(row).join(''));
watchFit(mount);
}
export function clearPageHint() {
const mount = document.getElementById(MOUNT);
if (!mount) return;
mount.innerHTML = empty ? legend(empty.title, '', empty.className || '') : '';
if (empty) watchFit(mount);
}
function watchFit(mount) {
if (mount.dataset.fitWatch) return;
mount.dataset.fitWatch = '1';
const fit = () => {
const panel = mount.querySelector('.hint-panel');
if (!panel) return;
panel.classList.remove('is-wide');
if (panel.scrollHeight > panel.clientHeight + 1) panel.classList.add('is-wide');
};
mount.addEventListener('pointerenter', fit);
mount.addEventListener('focusin', fit);
}
function row(r) {
if (r && typeof r === 'object' && r.heading) return `
${r.heading}
`;
const text = typeof r === 'string' ? r : (r?.text ?? '');
const sample = typeof r === 'string' ? '' : (r?.sample ?? '');
return `