A couple years ago I was struck with panic disorder for seemingly no reason. I got it so bad that for months I was effectively bedridden and would frequently get bouts of muscle pain, then became agoraphobic. Couldn't sleep, couldn't drive, couldn't eat, sometimes couldn't even drink. Panic disorder is real shit, but its biggest weakness is that it's an affliction of the mind. A good therapist helps, but ironically, what really helped me is having many panic attacks.
The more you have and the more you survive (because you WILL survive them), the more confident you become. This makes you worry about them less, and the less you worry about attacks, the less they're gonna happen. I went down from having two or three debilitating ones every day to having exceptionally tame ones every couple of months. This leaves more stable ground for you to work out the root causes, to be in extended states of a clear and rational mind. Another thing I've already seen people point out is distractions. Working or creating tasks for yourself to do is also a great idea, if you are able to retain focus on something, then an attack won't spiral out of control. This thread is full of great advice, but I would also recommend researching the nature of panic attacks. Read what psychologists have to say about them, learn everything you can about how they work.
It's all a humbling experience, a very important one. No matter how much it breaks you down, you adapt, and you're stronger for it if I'm being honest.