It’s a New York nightmare: What if you accidentally throw out your precious jewelry, or money, or car keys with the city’s 24 million pounds of trash collected each day?

Last Friday, Jill, a Staten Island mother-of-three, was disturbed when she realized she’d just tossed all three. Her wallet — which contained not only cash and credit cards but also car keys and a pair of gold earrings from the 1940s — had ended up in the trash after a mix-up while her daughter unloaded bags from their car.

She realized this just after a Department of Sanitation garbage truck had emptied her family’s trash cans and rolled away.

Everything else would be a headache to replace. But she was crushed by the loss of the jewelry, which was a family heirloom.

A New York City Department of Sanitation worker (left) helped this woman retrieve her lost backpack. DSNY

“I wore the earrings for my wedding, my daughter wore them for her high school graduation and prom,” Jill, who asked to withhold her last name, told The Post. “When you lose something so personal, you are hysterical.”

She’s not alone. Joshua Goodman, Deputy Commissioner, Public Affairs & Customer Experience for the NYC Department of Sanitation, said they get similar frantic calls a couple of times each month.

Over the years, New Yorkers have tossed out — and recovered — a $1,500 lottery ticket, laptops, clothing, passports and even tefillin, the leather boxes Orthodox Jews men bind to their arms to hold prayer scrolls.

Such instances, Goodman said, are “a good reminder that every item in the trash used to belong to someone.”

A Stated Island woman named Jill last week was able to recover her thrown-away wallet (right) after shifting through all the trash (left) collected by her neighborhood’s truck

Jill drove around her neighborhood, trying to locate the truck to no avail. Then she called 311, which connected her with the Staten Island transfer station, where neighborhood waste is loaded onto larger trucks for the journey to a final disposal spot.

The station would be Jill’s last hope — and it’s not usually open to the public.

But employees were able to pinpoint the local truck that had picked up Jill’s garbage and prevent the cargo from being shipped out of the city.

This woman was lucky enough to find her laptop that had accidentally ended up in the garbage. DSNY

“You have a finite amount of time” — two or three hours after street pick-up — “before the trash is taken to a transfer station and taken out of the city via a barge or rail car,” said Goodman. Jill called within a half hour.

The DOS invited her to the station to dig through the mountain of trash, giving her 90 minutes and suggesting she bring a friend to help.

“Everyone has their emergency contact. They should also have their emergency trash buddy,” Goodman quipped.

Wearing garbage bags around her feet and legs — the better to wade through the high piles of trash — this woman uncovered a bag of clothing she accidentally put out with the trash. DSNY

Jill arrived at a warehouse near Fresh Kills Park and found an entire truck’s worth of trash pick-up waiting for her — along with helpful sanitation workers, including one who offered a pair of heavy-duty gloves after seeing hers and recognizing they would be no match for Staten Island garbage.

“I’m usually in pressed pants and lipstick,” said Jill, noting that the knee-deep refuse was “pretty smelly.”

Goodman noted that the city trash “is less gross than it used to be” thanks to the rollout of the curbside composting, although the program won’t reach Staten Island until October.

The sanitation department advises wearing gloves, masks and boots for a trash dig. The people went all out with head-to-toe coverage and successfully reclaimed a sandwich bag full of jewelry. DSNY

After about a half hour of searching, Jill spotted her green wallet.

“I was in shock,” she said. “Everything was intact. [But] it smells like a pile of garbage. I treated myself to a nice new Anne Klein wallet. It’s bright yellow. Now, I’m all into these bright colors, because god forbid if something should ever happen again.”

Her 19-year-old daughter who mixed up the bags, meanwhile, lost car privileges for a week.

Jill said the order helped remind that New York is full of people willing to go the extra mile to help each other out.

“They were so wonderful,” she said of the sanitation workers. “They do deal with garbage, but they have big hearts. When you think the city doesn’t care, sometimes, deep down, it does.”

By ting