My (40M) wife (38F) Cheated

My wife of 6 years and I have been going through a funk. She’s said it’s a midlife crisis, but I had my suspicions something more was going on. Turns out she’s had this side relationship for a few months and they had sex. She admitted recently to it and said she regrets it so much and she loves me and wants to be with me and move on.

I’m a good guy, I’m attractive and have always been told I’m good in bed. I take good care of her and spoil her. Why she did this is beyond me. Yes, it’s frustrating she spent time with another man, but I’m focusing most on the sexual aspect.

How can I move on? How can I function in a relationship knowing she’s done this? I can’t get the image of her with someone else out of my head and I don’t know if I can ever get past the thought of this other dude in my wife. Makes me not want to go back in. I just don’t know if it’s worth attempting to salvage a relationship which is doomed to fail.