// SRI App — J0 pitch mode: the five-beat storyboard as a guided run.
// The bar narrates; the app performs each beat with the same typed intents a user would fire.
// Beat 4 leaves the approval live on purpose — governance as a feature, on camera.

function PitchBar({ beat, onNext, onEnd }) {
  const beats = window.SRIData.pitch;
  const b = beats[beat];
  if (!b) return null;
  const last = beat === beats.length - 1;
  return (
    <div className="pitchBar" data-screen-label={"Pitch beat " + b.id}>
      <span className="pitchBeatN tabular">{b.id}</span>
      <div className="pitchMain">
        <div className="pitchT">{b.t}</div>
        <div className="pitchLine">{b.line}</div>
      </div>
      <div className="pitchActs">
        {!last && <button type="button" className="pitchNext" onClick={onNext}>Next beat</button>}
        {last && <button type="button" className="pitchNext" onClick={onEnd}>End the run</button>}
        {!last && <button type="button" className="pitchEnd" onClick={onEnd}>End</button>}
      </div>
    </div>
  );
}

Object.assign(window, { PitchBar });
