Mapping Microsoft EllipticalArcTo to ECMA-376 arcTo

I have a use case where I have to convert parameters representing the arc of the ellipse. I have x, y, A, B, C, D from Microfost standart and I need to convert it to hR, stAng, swAng, wR from ECMA-376.

I tried to find similar questions solved.

I guess this link may be helpful.

It would be good to see convert realization in JS. But any help appreciated.

I tried this but I guess my geometry is weak. Can you please help?