\(=x^2+xy-x-y+y^2-x^2y^2\)
\(=\left(x+y\right)\left(x-1\right)+y^2\left(1-x^2\right)\)
\(=\left(x+y\right)\left(x-1\right)-y^2\left(x-1\right)\left(x+1\right)\)
\(=\left(x-1\right)\left(x+y-y^2x-y^2\right)\)
\(=\left(x-1\right)\cdot\left[x\left(1-y\right)\left(1+y\right)+y\left(1-y\right)\right]\)
\(=\left(x-1\right)\left(1-y\right)\left(x+xy+y\right)\)