Evaluate $\int \sqrt{\frac{\sin(x-a)}{\sin(x+a)}}dx$

$$\int \sqrt{\dfrac{\sin(x-a)}{\sin(x+a)}}dx$$

My attempt is as follows:-

$$\int \sqrt{\dfrac{\sin(x-a)\sin(x-a)}{\sin(x+a)\sin(x-a)}}dx$$ $$\int \sin(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}dx$$

Integrating by parts-

$$-\cos(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}+\int \cos(x-a)\dfrac{d}{dx}\left(\dfrac{1}{\sqrt{\sin^2x-\sin^2a}}\right)dx$$

$$-\cos(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}+\int \cos(x-a)\left(-\dfrac{\sin x\cos x}{(\sin^2x-\sin^2a)^\frac{3}{2}}\right)dx$$

$$-\cos(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}-\int \cos x\cos a\left(\dfrac{\sin x\cos x}{(\sin^2x-\sin^2a)^\frac{3}{2}}\right)dx-\int \sin x\sin a\left(\dfrac{\sin x\cos x}{(\sin^2x-\sin^2a)^\frac{3}{2}}\right)dx$$

$$-\cos(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}-\cos a\int\dfrac{\sin x\cos^2 x}{(\cos^2a-\cos^2x)^\frac{3}{2}}dx-\sin a\int \dfrac{\sin^2x\cos x}{(\sin^2x-\sin^2a)^\frac{3}{2}}dx$$

$$\cos x=t$$ $$-\sin x=\dfrac{dt}{dx}$$

$$-\cos(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}+\cos a\int \dfrac{t^2}{\left(\cos^2a-t^2\right)^\frac{3}{2}}dt-\sin a\int \dfrac{y^2}{\left(y^2-\sin^2a\right)^\frac{3}{2}}dy$$

$$I=\cos a\int \dfrac{t^2}{\left(\cos^2a-t^2\right)^\frac{3}{2}}dt$$ $$t=\cos a\cos z$$ $$\dfrac{dt}{dz}=-\cos a\sin z$$

$$I=-\int \dfrac{\cos^4a\cos^2z\sin z}{\left(\cos^2a-\cos^2a\cos^2z\right)^\frac{3}{2}}dz$$

$$I=-\int \dfrac{\cos^4a\cos^2z\sin z}{\cos^3a\sin^3z}dz$$ $$I=-\cos a\int \cot^2z$$ $$I=-\cos a\int (\mathrm{cosec}^2z-1) dz$$ $$I=\cos a\cot z+z\cos a$$

$$I_1=-\sin a\int \dfrac{y^2}{\left(y^2-\sin^2a\right)^\frac{3}{2}}dy$$ $$y=\sin a\sec u$$ $$\dfrac{dy}{du}=\sin a\sec u\tan u$$

$$I_1=-\sin a\int \dfrac{\sin^3a\sec^3u\tan u}{(\sin^2a\tan^2u)^\frac{3}{2}}du$$ $$I_1=-\sin a\int \dfrac{\sec^3u}{\tan^2u}du$$ $$I_1=-\sin a\int \dfrac{\sec u}{\sin^2u}du$$

$$\sin u=v$$ $$\cos u=\dfrac{dv}{du}$$ $$du=\dfrac{dv}{\sqrt{1-v^2}}$$ $$-\sin a\int \dfrac{1}{v^2(1-v^2)}dv$$ $$\sin a\int \dfrac{v^2-(v^2-1)}{v^2(v^2-1)}dv$$ $$\sin a\left(\dfrac{1}{2}\ln\left|\dfrac{v-1}{v+1}\right|+\dfrac{1}{v}\right)$$

So integral would be

$$-\cos(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}+\cos a\cot z+z\cos a+\sin a\left(\dfrac{1}{2}\ln\left|\dfrac{v-1}{v+1}\right|+\dfrac{1}{v}\right)+C$$

$$-\cos(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}+\cos a\dfrac{t}{\sqrt{\cos^2a-t^2}}+\cos a\cos^{-1}\left(\dfrac{t}{\cos a}\right)+\dfrac{\sin a}{2}\cdot\ln\left|\dfrac{\sin u-1}{\sin u+1}\right|+\dfrac{\sin a}{\sin u}+C$$

$$-\cos(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}+\cos a\dfrac{\cos x}{\sqrt{\cos^2a-\cos^2x}}+\cos a\cos^{-1}\left(\dfrac{\cos x}{\cos a}\right)+\dfrac{\sin a}{2}\cdot\ln\left|\dfrac{\sqrt{y^2-\sin^2a}-y}{\sqrt{y^2-\sin^2a}+y}\right|+\dfrac{y\sin a}{\sqrt{y^2-\sin^2a}}+C$$

$$-\cos(x-a)\sqrt{\dfrac{1}{\sin^2x-\sin^2a}}+\cos a\dfrac{\cos x}{\sqrt{\cos^2a-\cos^2x}}+\cos a\cos^{-1}\left(\dfrac{\cos x}{\cos a}\right)+\dfrac{\sin a}{2}\cdot\ln\left|\dfrac{\sqrt{\sin^2x-\sin^2a}-\sin x}{\sqrt{\sin^2x-\sin^2a}+\sin x}\right|+\dfrac{\sin x\sin a}{\sqrt{\sin^2x-\sin^2a}}+C$$

$$\cos a\cos^{-1}\left(\dfrac{\cos x}{\cos a}\right)+\dfrac{\sin a}{2}\cdot\ln\left|\dfrac{\sqrt{\sin^2x-\sin^2a}-\sin x}{\sqrt{\sin^2x-\sin^2a}+\sin x}\right|+C$$

First of all, it went very long, what clever way I am missing here? Please feel free to suggest any other shorter alternatives

$$\int\frac{\sin(x-a)}{\sqrt{\sin^2x-\sin^2a}}dx$$ $$=\cos a\int\frac{\sin x}{\sqrt{\cos^2a-\cos^2x}}dx-\sin a\int\frac{\cos x}{\sqrt{\sin^2x-\sin^2a}}dx$$ Now, substitute $$\sin x$$ in second integral and $$\cos x$$ in first integral to reduce to standard formulas.