// warn-row.jsx - WarnRow component
// Loaded after sortof-shared.jsx; defines globals that sortof-app.jsx references.
const { useState } = React;
function WarnAction({ a, inputWsids, onAddWsid, onSwapWsid, onRemoveWsid }) {
if (a.type === 'add-wsid') {
const staged = actionStaged(a, inputWsids);
return (
);
}
if (a.type === 'swap-wsid') {
const staged = actionStaged(a, inputWsids);
return (
);
}
if (a.type === 'remove-wsid') {
const staged = actionStaged(a, inputWsids);
return (
);
}
if (a.type === 'search-workshop') {
return (
↗ {a.label}
);
}
return null;
}
function WarnBranchPicker({ w, inputWsids, isAdditive, onPickBranch, onToggleBranch }) {
const [branchOpen, setBranchOpen] = useState(isAdditive);
const liveSet = new Set(D.SORTED_ORDER || []);
const controlled = new Set();
for (const ww of (D.WARNINGS || [])) {
if (String(ww.wsid) === String(w.wsid) && Array.isArray(ww.alternatives)) {
for (const a of ww.alternatives) controlled.add(a);
}
}
const alwaysOn = (w.wsid)
? (D.MOD_DB || [])
.filter(m => String(m.wsid) === String(w.wsid)
&& !controlled.has(m.modId)
&& liveSet.has(m.modId))
.map(m => m.modId)
: [];
return (
<>
{branchOpen && (
{alwaysOn.map(modId => (
★ {modId}
))}
{w.alternatives.map(modId => {
const activeSet = new Set(D.SORTED_ORDER || []);
const isActive = isAdditive ? activeSet.has(modId) : modId === w.picked;
const isPrimary = modId === w.picked;
return (
);
})}
)}
>
);
}
function WarnRow({ w, inputWsids, onAddWsid, onPickBranch, onSwapWsid, onRemoveWsid, onToggleBranch }) {
const isAdditive = w.tag === 'unmatched-addons';
const hasPicker = Array.isArray(w.alternatives);
const rowStaged = (Array.isArray(w.actions) ? w.actions : []).some(a => actionStaged(a, inputWsids));
return (
{warnAccent(w) === 'red' ? '!' : warnAccent(w) === 'info' ? '›' : '⚠'}
{w.tag}
{Array.isArray(w.actions) && w.actions.map((a, j) => (
))}
{hasPicker && (
)}
);
}
Object.assign(window, { WarnRow });