termites but good old wood rot due to the roof sloping towards the door instead of away. After several years of soaking in water the wood just falls apart. The swollen puffy look is typical of water damage.
It looks like an upper balcony door? If so the roofing is sloped wrong pooling water at the door frame. That should be corrected. The door should never be sitting in water.
Repairs should start with the roof repairs. If the rest of the door is solid and useable yet then taking a saw to the door frame beyond the rot would work. Just cut the frame off two or three feet up where the wood is solid and rebuild the frame with new wood. Or you could accomplish the same thing by buying a whole new prehung door and have the job done in an hour. I’ve seen damaged doors at the home centers where you could buy the entire door and frame for $15. Use the damaged door for a workbench or something and use the frame to replace yours.
No matter what you do, if you don’t fix the water pooling problem the door will rot out again very soon.