Vulpis ad Personam Tragicam

Hello!!
I’m having some troubles understading this:

“Personam tragicam forte vulpes viderat;
quam postquam huc illuc semel atque iterum verterat,
‘O quanta species’ inquit ‘cerebrum non habet!’
Hoc illis dictum est quibus honorem et gloriam
Fortuna tribuit, sensum communem abstulit.”

What is this “quam”, is it the prounoun? The whole verse is very strange to me.
To which noun is “dictum” refering?

Yes, quam refers to personam, and is the direct object of verterat. Hoc dictum est has as its antecedent the entire preceding sentence.

Could we translate like that:
“quam postquam huc illuc semel atque iterum verterat”
“It[the fox] looked here and there and turned to it[the mask]”

No, there’s no “looked,” and verto doesn’t mean “turn to” but just “turn” (transitive). And don’t forget the postquam. “After she’d more than once turned it this way and that, she said (inquit) …”

dictum refers to hochoc meaning the fox’s exclamation, o quanta species …. “This is said to those to whom …”

Thank you!!! I’ve understood now!!!