4. In the expansion of $(x+\sqrt{x}+1)^{2 n+1}\left(n \in \mathbf{Z}_{+}\right)$, the sum of the coefficients of the integer powers of $x$ is $\qquad$
$$
\begin{array}{l}
\text { 4. } \frac{1}{2}\left(3^{2 n+1}+1\right) . \\
\text { Let } P=(x+\sqrt{x}+1)^{2 n+1} \text {, } \\
Q=(x-\sqrt{x}+1)^{2 n+1} .
\end{array}
$$

By the binomial theorem, we know that the sum of the integer powers of $x$ in $P$ and $Q$ is the same, denoted as $S(x)$, and the sum of the non-integer powers of $x$ are opposites. Therefore,
$$
\begin{array}{l}
2 S(x)=P+Q \\
=(x+\sqrt{x}+1)^{2 n+1}+(x-\sqrt{x}+1)^{2 n+1} .
\end{array}
$$

Let $x=1$. Then the sum of the required coefficients is $\frac{1}{2}\left(3^{2 n+1}+1\right)$.