It's all shapeshifting fun and games for 19th-century Minnesota outlaw Nellie King until she runs headlong into a fateful dilemma.

Fired from a vaudeville show and with the authorities closing in on her for financial fraud — she and partner Edward Loudon look to The Child, an orphan teen who has recently come into their care, for a possible solution.

The adults in the makeshift family have a choice between suffering together or trafficking the adolescent to a whorehouse madam.

Nellie's decision, which comes late in the musical "Whoa, Nellie! The Outlaw King of the Wild Middle West," is one that's liable to shape King's reputation forever and color our view of a figure being plucked from history with relish.

Up until that moment, the musical at St. Paul's History Theatre, composed with spry wit and vim by playwright Josef Evans and staged with pizzazz by Laura Leffler, is mostly a blast. True, the storyline goes all over the place, partly on account of the many aliases and disguises that Nellie (Em Adam Rosenberg) uses as she commits crimes and has overlapping marriages in Minnesota and South Dakota.

As one musical number puts it, wherever she goes, she leaves "a trail of broken laws and broken hearts."

Rosenberg, who uses they/them pronouns, is charmingly solicitous as the notorious title character. Their Nellie is as smooth as a porcelain doll, with a high gloss mien covering most of the character's intents and emotions.

The smart musical boasts an ebullient, razzle-dazzle score and catchy songs with titles such as "Ride 'Em Cowboy," "You Gotta Be Crazy (Not to Go Crazy)," and "If You Find Yourself in Florida," which has uncanny contemporary resonance.

Choreographer Joey Miller intersperses sophisticated little dances throughout the show.

"Nellie," which takes place on Joel Sass' vaudeville proscenium stage and in Bryce Turgeon's fabulous period costumes (all done with some playful liberties), leaves us feeling entertained and enlightened. But the joy is complicated by moral qualms. For while Nellie's actions skirt law and ethics, they don't have the Greek-level Oedipal-scale knots and twists until we get to that pivotal scene with The Child (Grace Hillmyer).

Told like "Cabaret" with direct address and flashbacks, "Nellie" has a fetching and prickly narrator in Bert Williams (John Jamison II in yet another notable turn), who delivers the story with honesty and deadpan irony while occasionally cracking wise on the show's — and society's — contradictions.

The cast is energetic and polished. Tod Petersen is glitzy and appealing as showman John Durham. Sweet-voiced Erin Nicole Farsté is compelling as opera singer Aida Walker.

Besides Williams and Walker, "Nellie" ropes in other historical figures such as female impersonator Julian Eltinge (Jay Owen Eisenberg, who, like most of the cast, is deft in other ensemble roles), investigative reporter Nelly Bly (versatile Therese Walth), expert sharpshooter Annie Oakley (Leslie Vincent) and husband Edward Loudon (Thomas Bevan).

"Nellie" takes place at a time that's similar to today in that old ways and vices are being amplified in new-fangled technology that leaves many people feeling at sea. Then, the media was unregulated and without standards. The show takes a dim view of the press as fanciful no-nothings whose members invent stories on a whim and print exclamatory balderdash.

But the hearts of people do not change as quickly, and with "Nellie," we see a figure yearning for one of America's cardinal hopes at a time when it was difficult to be an independent thinking woman just out trying to make a living. "Set Me Free," Rosenberg's Nellie sings with sincerity and passion, almost unaware that some of the bars that constrict her are of her own complicated making.

'Whoa, Nellie'

When: 7:30 p.m. Thu.-Sat., 2 p.m. Sun. Ends June 8.

Where: History Theatre, 30 E. 10th St., St. Paul.

Tickets: $30-$74. 651-292-4323 or historytheatre.com.