A browser utility showPopupAndRedirect(message, targetUrl) opens a modal dialog containing message. While this dialog is open, all other invocations are blocked. When the dialog is closed, the browser navigates to targetUrl only if targetUrl is a string with positive length.
Your job is to simulate a list of scheduled calls to this utility. The input calls is a list of records of the form [requestedAt, message, targetUrl, closeAfter]. The value requestedAt is the time the call is made, and closeAfter is how many time units the popup stays open before being dismissed. If a call arrives while another popup is already open, it waits until the current popup closes, then starts immediately.
At the time a popup starts, append [time, "popup", message] to the result. At the time it closes, append [time, "redirect", targetUrl] only when targetUrl is a non-empty string; otherwise, do not record a redirect for that call. Continue processing all later scheduled calls even after a redirect is recorded.
Process calls by increasing requestedAt. If two calls have the same requestedAt, preserve their original input order.
Example 1:
Input: calls = [[1, "Saved", "/home", 4]]
Output: [[1, "popup", "Saved"], [5, "redirect", "/home"]]
Explanation: The popup starts at time 1, closes at time 1 + 4 = 5, and /home is a valid non-empty string.
Example 2:
Input: calls = [[2, "First", "/one", 3], [3, "Second", "/two", 2]]
Output: [[2, "popup", "First"], [5, "redirect", "/one"], [5, "popup", "Second"], [7, "redirect", "/two"]]
Explanation: The first popup occupies time 2 through 5. The second call is requested at time 3, so it waits until time 5 and then runs.
Example 3:
Input: calls = [[1, "Hi", "", 2], [2, "There", null, 1]]
Output: [[1, "popup", "Hi"], [3, "popup", "There"]]
Explanation: The first popup closes at time 3, but its target is an empty string, so no redirect is recorded. The second call was waiting and starts at time 3; its target is null, so no redirect is recorded for it either.
Constraints:
0 <= calls.length <= 2500000 <= requestedAt <= 10^80 <= closeAfter <= 10^8message is a string.targetUrl may be any value; a redirect is recorded only when targetUrl is a string with length greater than 0.