A state sum invariant of tangles in surfaces