const tails = new Map();
export function enqueueSuggestedEditFieldTask(key, task) {
    const previous = tails.get(key) ?? Promise.resolve();
    const run = previous.catch(() => undefined).then(task);
    const tail = run.then(() => undefined, () => undefined);
    tails.set(key, tail);
    void tail.finally(() => {
        if (tails.get(key) === tail)
            tails.delete(key);
    });
    return run;
}
export function waitForSuggestedEditFieldTasks(key) {
    return enqueueSuggestedEditFieldTask(key, async () => undefined);
}
//# sourceMappingURL=suggestedEditFieldQueue.js.map