\(xy+x+y+1=2\Rightarrow\left(x+1\right)\left(y+1\right)=2\)
\(1+y^2=xy+x+y+y^2=x\left(y+1\right)+y\left(y+1\right)=\left(x+y\right)\left(y+1\right)\)
\(1+x^2=\left(x+y\right)\left(x+1\right)\)
\(\Rightarrow S=2x\sqrt{\frac{y+1}{x+1}}+2y\sqrt{\frac{x+1}{y+1}}+\left(x+y\right)\sqrt{\left(x+1\right)\left(y+1\right)}\)
\(=\frac{2x}{x+1}\sqrt{\left(x+1\right)\left(y+1\right)}+\frac{2y}{y+1}\sqrt{\left(x+1\right)\left(y+1\right)}+\sqrt{2}\left(x+y\right)\)
\(=\sqrt{2}\left(\frac{2x}{x+1}+\frac{2y}{y+1}+x+y\right)=\sqrt{2}\left(5-\frac{2}{x+1}-\frac{2}{y+1}+x+y\right)\)
\(=\sqrt{2}\left[5-\frac{2\left(x+y+2\right)}{\left(x+1\right)\left(y+1\right)}+x+y\right]=\sqrt{2}\left[5-\left(x+y+2\right)+x+y\right]\)
\(=3\sqrt{2}\)