from .rules_loader import load_custom_rules

# Load rules ONCE at import time
CUSTOM_REPLACEMENTS = load_custom_rules()


def apply_custom_rules(text, rules=None):
    if rules is None:
        rules = CUSTOM_REPLACEMENTS

    for key, value in rules.items():
        text = text.replace(key, value)

    return text
