Others have heavily covered the legality portion of this but I want to point out one other key factor: any employer that tries to pull this kind of shit clearly has a significant employee retention problem, and they're trying to fix it by trapping their employees financially rather than getting to the root of the problem.
Refuse to sign this agreement and find another job. If they let you join without signing this agreement keep applying elsewhere because you'll almost certainly learn very quickly why they have such a bad employee retention problem
That's probably only worth if your state has damages above and beyond what's stolen from you; otherwise a lot of life hassle for a shitty job, which is what the deal was in the first place
At my last company, when I joined they gave me an employee agreement to sign that not only granted to them the rights over any software that I developed while working for them even if it was personal projects that I did for myself on my own time (which is standard corporate bullshittery) but also granted to them rights over anything that I had developed in my entire life previous to working for them. I told them they had to be fucking kidding me (like, surely they should have understood that at a minimum that would conflict with the rights of my previous employers who I had developed stuff for) and refused to sign it. They ended up hiring me anyway, without my ever having signed any employee agreement at all - I got like weekly email reminders from HR about it for a year until they finally just stopped.