One of my best friends is going to have a cardiac surgery and she is only 17. Unfortunately she is in a high-functioning depression and I really don't know what to say or what to do for her to give her a little bit of peace because recently nothing can cheer her up.Moreover we are not in the same city for a while. Also she is really afraid of this surgery and I want to help her as her best friend, but the key question is HOW?
Like your friend I've been a young person going through a couple of heart surgeries (minor ones relatively speaking and I was in my early twenties). Also like your friend, I have high-function depression.
While baldPrussian's answer is awesome and you should definitely follow it. Only do so if your friend really wants you to make that kind of space for them.
If they just want a distraction, then be your normal self with them. When I was going through all of my surgeries or when I was deeply depressed, all I really wanted was someone to be there for me to help me distract myself from myself. You can just be present for your friend, joke around, play games, complain about how boring daytime TV is or how terrible the food is. If you and your friend are comfortable with it, make macabre jokes about the situation. My mom has a serious cancer and we make inappropriate jokes like how I can't believe that I have to push in around in a wheelchair. (Though, do be careful about what is said, how it's said, and where. We found that some of our joking was around other patients and that it's probably terrible that we're laughing while everyone is, understandably, solemn.)
Just breaking the tension may be all your friend needs. And if you're unsure, just ask. A good phrase I've seen floating around is "Do you want advice or just need me to listen?" Your friend probably knows what they need in that moment.
Since you've commented that you are not in the same town as your friend, I'll add that messaging/texting would definitely be nice, or a phone call if that's their thing. Video calls are an option to if they're up for it. Post-surgery can leave one rather exhausted and holding a phone for extended periods of time be an issue (also depends on the nature of the surgery, if catheters are used to access the heart sitting up is not very pleasant, at least in my experience).
If either of you are into memes, sending memes would be a great asset since there's a multitude on the internet.
Contacting them before the surgery will probably help them feel reassured and settle any nerves. Then checking up on them afterwards gives you the chance see how they're doing and, if this is yall's kind of humor, rib them about how they're worries were over nothing.
You've got 2 things going on there, each of which require a different approach. There's a lot of info out there on handling depressed friends an done or two most excellent TED talks on the subject (https://www.ted.com/topics/depression), so I'll skip that.
In seminary, we learn about walking through people's fear and grief - it's a big part of an effective ministry. So let me start by saying this: you're asking the right question.
Unfortunately many fears are irrational - look at people's fears about spiders, frogs, dark, etc. There's generally no amount of reason you can present to an irrational situation that will calm that. So rather than trying to argue or reason them out of their fear, the important thing is then presence.
When spending time in an Assisted Living facility, I found that the most effective ministry was that - being there. Allow the individual to talk about what frightens them. Hold their hand. Stress that you are there for them now and after it's all over. Don't worry about saying the right thing - focus on just not saying the really wrong thing, ie don't make their fear worse by talking about death or possible unpleasant complications. Make plans on what you will do while they recuperate - playing cards or board games while they are stuck in bed, texting them, checking up on them, etc. Just knowing that someone cares, in my experience, is a HUGE thing when dealing with fear.
Again: let your friend talk about their fears. Listen. Don't deny their fear but stress that you will go through this together because that's what friends do.
Good luck to you; I think many readers will wish they had a friend like you.