// Field-level "?" reference dialogs. Sibling to why-panels.js: why-panels are always-visible // section prose ("why this works"); this is an on-demand, per-field reference library ("what are // my options"). See FIELD_HELP_SPEC.md (deleted after implementation) for the design rationale. import { HELP_TOPICS } from "./field-help-content.js"; export function initFieldHelp({ getPlan, getTempUnit, getMachineProfile }) { const dialog = document.getElementById("field-help-dialog"); if (!dialog) return; const titleEl = document.getElementById("help-dialog-title"); const bodyEl = document.getElementById("help-dialog-body"); let lastTrigger = null; function openTopic(key, trigger) { const topic = HELP_TOPICS[key]; if (!topic) return; lastTrigger = trigger; titleEl.textContent = topic.title; bodyEl.replaceChildren(topic.render(getPlan(), getTempUnit?.(), getMachineProfile?.())); bodyEl.scrollTop = 0; dialog.showModal(); } // A button appended into a `.field-label` span is a labelable element, and a