Do you have another AC adapter at hand? (Any adapter with an output voltage of 19V, a matching plug and correct polarity (negative on the sleeve of the plug) will do.) That will help you narrow it down to either the AC adapter or the laptop itself. (I’ve had power issues with laptops two times, and both times it was the AC adapter.)
If it’s the AC adapter, replacements are easy to find—a lot of HP ones are compatible, and also some generic or third-party ones—see above for specs.
If the problem persists regardless of the AC adapter and you have access to a port replicator, you could try that to narrow the issue down further. If the laptop runs on AC power when docked but not with the AC adapter plugged into the laptop, it may be due to a faulty power jack (or wiring).