import { detectTriggerRemoval } from "./detect-trigger-removal";
import { monitorTriggeredText } from "./monitor-triggered-text";
export const getAppendTransactionHandler = (getCurrentView, getActiveTrigger, resetActiveTrigger, contentConverter) => {
    return (transactions, _oldState, newState) => {
        const activeTrigger = getActiveTrigger();
        if (!activeTrigger) {
            return;
        }
        const triggerRemoved = detectTriggerRemoval(transactions[0], // Pass the first transaction
        activeTrigger, resetActiveTrigger, contentConverter, getCurrentView());
        if (triggerRemoved) {
            resetActiveTrigger();
            return;
        }
        monitorTriggeredText(newState.doc, activeTrigger, newState.selection.from, contentConverter, getCurrentView());
    };
};
