I can see why you say the law is ambiguous, but it is not:
"A throw-in is awarded to the opponents of the player who last touched the ball when the whole of the ball passes over the touchline, on the ground or in the air.". Note the law doesn't make any distinction about if the touch was when the ball was in play or not.
Had the law said "...awarded to the opponents of the player who last touched the ball when it was in play..." then it would would have been a retake.
But as the law stands now, the TI was taken correctly. The ball came into play. At this point its a new phase of play with no prior offences (infringements) to be considered. Then the ball which was in play goes out of play. Its a 'new' throw in regardless of what the last restart was. The ball was last touched by blue (all be it when the ball was out of play), therefore blue's opponent is taking a throw in from where the ball went out of play.
EDIT: Given that you haven't specified where the ball went out of play, it could also be a goal kick or a corner kick to the opponents.