Multi-directional interval reset between event log

Sorry for this fuzzy question, it just came into my mind, I don’t know whether there’s a correct term for this kind of question.

Let say we have a table of timeline recording types of events:

Event Type Date Interval
A 2026-3-25
B 2026-3-27
A 2026-3-28 3
B 2026-3-30 2
B 2026-3-31 1
B 2026-4-2 2
A 2026-4-5 8

Where event type A will reset both interval counting of A and B, while B only resets interval counting of B itself.
So there’s a bidirectional resetting relation between those kinds of event, how do I calculate the interval?
What if there’s more event types that have interrelation to determine other’s interval reset, what is the generic solution for it?