import React, { useState } from 'react' /** * Active / Inactive pill (the reference builder F:7561-7592) with an in-flight guard: while `onToggle(next)` (may return a promise) * runs, the pill is disabled and shows a wait cursor, so double clicks cannot send two requests. * Props: isActive, onToggle(nextActive) => Promise|void, busy (optional external flag). */ export default function ActivePill({ isActive, onToggle, busy = false }) { const [inFlight, setInFlight] = useState(false) const locked = inFlight || busy const click = async () => { if (locked || !onToggle) return setInFlight(true) try { await onToggle(!isActive) } finally { setInFlight(false) } } return ( ) }