Jay Leno is “Tonight Show” history — but now, thanks to a new memoir by his longtime producer, 22 years of celebrity hissy-fits, presidential gaffes and backstage snafus are fair game.

Dave Berg, hired as a segment producer for “The Tonight Show with Jay Leno” before its debut on May 25, 1992, dishes on the most beloved and reviled guests to visit the Burbank set in ­“Behind the Curtain: An Insider’s View of Jay Leno’s Tonight Show” (Pelican), out Sunday.

Here’s a peek backstage:

Thin skins abound in Hollywood, but Helen Hunt’s hide was thinner than most. After a producer “gently” critiqued her performance during an appearance to promote “Mad About You,” she refused to return for 14 years.

Kobe Bryant also embargoed Leno after the host cracked wise about the basketball star being charged with sexually assaulting a 19-year-old woman.

Leno “felt strongly that O.J. Simpson” was guilty of murder, so he snubbed lawyer Johnnie Cochran, dismissing him as an “opportunist.” But he invited prosecutors Marcia Clark and Christopher Darden.

Each guest received $500 to appear, but unless they were a Top-10 A-list actor, they barely budged the ratings dial. At least not the way cute animals could.

When David Letterman announced he had scored Martha Stewart’s first late-night interview following her five-month prison stint for insider trading, Berg knew Leno would be trounced in the ratings with a lineup led by Benjamin Bratt. So the show booked an animal trainer.

“Facing near-impossible odds, we led with animals and won the ratings battle against Letterman and Martha by .4 of a point, approximately half a million viewers,” he writes. (Bratt refused to follow an animal and came back another day as the lead guest, but never returned to the show.)

Surprise, surprise — Christian Bale is difficult. Berg recounts a 2002 pre-interview with the surly Brit that ended abruptly because the questions were “too personal.”

What were these probing questions? “I had asked him where he grew up (Wales), how big his family was (three sisters), and what his first gig was (a Pac-Man cereal commercial). [He] didn’t seem to have even a basic understanding of how ‘The Tonight Show’ worked,” Berg writes. “I was glad he dropped out, thus averting an awkward on-air ­exchange with Jay.”

Another difficult — or, as Berg puts it, “complicated” — guest was Teri Hatcher.

“I called her Teri One and Teri Two, though not to her face. Teri One was charming, smart, witty and flirtatious,” Berg writes. “Terri Two was moody. She would call me late the night before her scheduled appearance, scream at me for not having better ideas, and then hang up. The next day, she would come to show as Teri One, acting as if nothing had ever happened.”

In March 2009, when President Obama was booked — making him the first sitting president to ever appear on a late-night entertainment show — the “Desperate Housewives” star was bumped. One of her staffers called the show, saying the actress understood, but “a girl likes to be appreciated.” When Berg offered flowers, the aide said, “You know, girls like Louis Vuitton . . . Maybe a handbag?” She got flowers.

Not all celebrities were pros. Jesse Jackson suffered from serious stage fright. “I never would have guessed that this prominent civil rights activist and one-time presidential candidate would be a nervous Nellie,” recalls Berg. “One time he was shaking so hard backstage, he had to hold onto me for support.”

To help with stage fright, Leno came up with the idea of The Jay Bar, a mobile station loaded with beer and wine to help guests unwind before the show. But some guests didn’t know when to turn off the spigot. In 2003, Quentin Tarantino hit The Jay Bar so hard that he was slurring and “occasionally incoherent” on air.

Then there were the divas. Eddie Murphy handed over an entire page of necessities for the 45 minutes he spent in his dressing room prior to his appearance.

It included, “4 Snapple Fruit Punch, 4 Snapple Orangeade, 4 Snapple Grapeade, 4 Dr. Browne’s Cream Soda, 4 Dr. Browne’s Root Beer, Coke in glass bottles, bananas, cherries, Evian bottled water, Juicy Fruit Gum, Snickers, Milky Ways, peppermints, York Peppermint Patties, writing pads/pencils/pens, regular-sized towels, washcloths/small.”

Jessica Simpson would come on only if they paid for her hair and makeup — a tab she estimated at $18,000. The show refused. But when Sarah Palin agreed to go on after her 2008 defeat for vice president, the show coughed up $35,000 to fly her family and friends on a private jet from Anchorage, Alaska.

Paula Abdul was one of the show’s riskiest guests. “Her behavior was consistently erratic. She would cancel appearances for strange reasons, and when she did show up, her speech was often so slurred we could barely understand her,” Berg writes. His job was to make sure she was “coherent enough to appear.”

So why did they keep booking her? “Ratings! Part of her appeal, ironically, is that you never knew what she might say.”

Dennis Rodman was chronically late. And even though he did the show 28 times, he was always a headache for producers. When limousines no longer worked, the crew chartered a private helicopter to fly him from his home in Newport Beach, just an hour’s drive from Burbank, to ensure his on-time arrival.

An unnamed “prominent political commentator” insisted Berg brief him about the coming interview while the guest urinated with the door to his dressing-room bathroom ajar.

An unidentified actress had a “wardrobe malfunction,” letting her towel drop to the floor when Leno and Berg walked into her room. Jay didn’t miss a beat: “How could any towel withstand that kind of pressure?” But when it happened a second time, during a follow-up appearance, he was tongue-tied.

A presidential candidate whom Berg doesn’t name nearly missed his cue because he was engaged in some private antics with his wife, recalls Berg. “All of a sudden, the door opened and the candidate emerged, looking sheepish as he straightened his tie and said nothing. His wife, whose hair was mussed and whose lipstick was noticeably smeared, was smiling as she wished her husband good luck.”

He did his best interview with Leno ever.

President Bill Clinton was Berg’s white whale. After many rebuffs, the show sent him a $12,000 custom-made tandem bicycle as a get-well gift after his triple-bypass surgery.

It was returned, because Hillary, then a New York senator, could not legally accept gifts worth more than $50. (The two-seater bike was conceivably for her, too.)

When the show commissioned another pricey bike with only one seat, Clinton accepted, but still never appeared on the show. Aides told Berg that Clinton “simply didn’t like Jay’s never-ending Monica Lewinsky jokes.”