I would expect most of us here have faced many rejections, some of which were deeply painful. When you care about something, some say, losing it hurts. (But was there ever a guarantee? Or was it only an expectation?)

Some people find ways to focus on the process itself and don't couple their well-being to the "end result" (whether success or failure).* This is a practice. You can learn it from others and from experience.

It is one thing to be honest with oneself and say "Yes, this thought is coming into my mind". You don't have to deny that feeling. That is one thought in your head. Acknowledge it and move on. You don't have to repeat it. You don't have to try to 'analyze' it. You can think about something else, and changing your brain patterns is probably a good idea. If the same idea pops up again, fine. Remember to be patient with yourself.

Some ideas that might work for you include: Find emotional support where you can. / Learn cognitive techniques to remind yourself to not fall into ruts. / Put sticky notes on walls. / Do something totally different. / Sunshine and fresh air can do a lot of good.

If one of these things doesn't seem to help, thank yourself for trying it, don't worry, try something else. If you need more support (mental health for example), seek it out.

* And how do you define the end-result? How much you helped people you care about? Maybe a time-averaged well-being metric? Something else? This is deeply personal, and I think it is worth reflecting on.