I hope that you’re not beating yourself up too much.
And if you are in the usa, maybe ask for reasonable accommodation, intermittent FMLA, or something that would provide you some protection if you feel your job-threatened.
I wish you the best as you deal with the feelings of inadequacy.