12. Given that the center of a hyperbola is at the origin, and its foci are on the coordinate axes, the distance from point $P(-2,0)$ to its asymptotes is $\frac{2 \sqrt{6}}{3}$. If a line with a slope of $\frac{\sqrt{2}}{2}$ passing through point $P$ intersects the hyperbola at points $A$ and $B$, and intersects the $y$-axis at point $M$, and $PM$ is the geometric mean of $PA$ and $PB$, then the semi-focal distance of the hyperbola is $\qquad$
12. $\sqrt{3}$ or $\sqrt{21}$.

Let the equation of the asymptote be $y=k x$.
From the given condition, we have $\frac{|-2 k|}{\sqrt{1+k^{2}}}=\frac{2 \sqrt{6}}{3}$, solving for $k$ gives $k= \pm \sqrt{2}$. Therefore, the equations of the asymptotes of the hyperbola are $y= \pm \sqrt{2} x$. Suppose the equation of the hyperbola is $2 x^{2}-y^{2}=\lambda(\lambda \neq 0)$. Let $A\left(x_{1}, y_{1}\right)$ and $B\left(x_{2}, y_{2}\right)$, and the equation of line $A B$ is $y=\frac{\sqrt{2}}{2}(x+2)$. Substituting into the equation of the hyperbola and eliminating $y$ yields $3 x^{2}-4 x-2 \lambda-4=0$.

When $\Delta=16+12(2 \lambda+4)>0$, i.e., $\lambda>-\frac{8}{3}$, the above equation has exactly two real roots, and
$$
x_{1}+x_{2}=\frac{4}{3}, x_{1} x_{2}=-\frac{2}{3}(\lambda+2) .
$$

From the given condition, $P M^{2}=P A \cdot P B$, which can be transformed into
$$
\begin{array}{l}
\left|\left(x_{1}+2\right)\left(x_{2}+2\right)\right|=4 \\
\Rightarrow\left|x_{1} x_{2}+2\left(x_{1}+x_{2}\right)+4\right|=4 \\
\Rightarrow\left|-\frac{2}{3}(\lambda+2)+2 \times \frac{4}{3}+4\right|=4 .
\end{array}
$$

Solving for $\lambda$ gives $\lambda=2$ or $\lambda=14$.
Therefore, the equation of the hyperbola is
$2 x^{2}-y^{2}=2$ or $2 x^{2}-y^{2}=14$
$\Rightarrow x^{2}-\frac{y^{2}}{2}=1$ or $\frac{x^{2}}{7}-\frac{y^{2}}{14}=1$.
Thus, the semi-focal distance of the hyperbola is $\sqrt{1+2}=\sqrt{3}$ or
$$
\sqrt{7+14}=\sqrt{21} \text {. }
$$