import { app } from "../../../scripts/app.js"; const PREFIXES = ["video", "audio"]; const STRING_FIELDS = [ "sigmas", "cfg", "stg", "rescale", "modality_scale", "perturb_attn", "skip_step", "cross_attn", "cfg_zero_star", ]; const FIELD_LABELS = { sigmas: "Sigmas", cfg: "CFG", stg: "STG", rescale: "Rescale", modality_scale: "Modality Scale", perturb_attn: "Perturb Attn", skip_step: "Skip Step", cross_attn: "Cross Attn", cfg_zero_star: "CFG Zero*", }; const _origProps = {}; function toggleWidget(node, widget, show) { if (!widget) return; if (!_origProps[widget.name]) { _origProps[widget.name] = { origComputeSize: widget.computeSize, }; } const origSize = node.size; widget.hidden = !show; widget.computeSize = show ? _origProps[widget.name].origComputeSize : () => [0, -3.3]; widget.linkedWidgets?.forEach((w) => toggleWidget(node, w, show)); const height = show ? Math.max(node.computeSize()[1], origSize[1]) : node.computeSize()[1]; node.setSize([node.size[0], height]); if (show) delete widget.computedHeight; else widget.computedHeight = 0; } function toggleModalityWidgets(node, prefix, enabled) { for (const w of node.widgets) { if ( w.name.startsWith(prefix + "_") && w.name !== prefix + "_enabled" ) { toggleWidget(node, w, enabled); } } } function injectMultilineLabels(node) { const labelMap = {}; for (const prefix of PREFIXES) { for (const field of STRING_FIELDS) { const key = prefix + "_" + field; labelMap[key] = prefix.toUpperCase() + " " + FIELD_LABELS[field]; } } function applyLabels() { let allDone = true; for (const w of node.widgets) { if (!(w.name in labelMap)) continue; // w.element is the