Dream11 search suggestions should update only after the user stops typing for a specified interval. Implement a trailing-edge debounce utility that suppresses intermediate events and emits only the latest event after no newer event arrives within wait time units.
Write debounce_events(events, wait), where events is a list of events represented as [timestamp, value]. Timestamps are non-decreasing integers, and values may be strings or other JSON-compatible values. Return a new list of [emit_timestamp, value] pairs.
The first event in a burst is replaced whenever another event arrives within wait time units. The latest event is emitted at event_timestamp + wait. If a new event arrives at exactly the pending event's deadline, emit the pending event first, then begin a new burst with the current event. The input list is already complete, so flush the final pending event before returning.
def debounce_events(events, wait):