Last week’s mass shooting in El Paso, Texas, has sent public discourse about immigration off the rails.

It has allowed radicals to frame as racist normal law enforcement activities and immigration rules. We saw this in New York recently, with anti-ICE protesters stopping traffic on the West Side Highway and holding sit-ins at an Amazon store to protest the company’s compliance with immigration rules.

In the left’s telling — and it’s increasingly hard to distinguish the hard left from the soft — the administration and those who support it are no better than the insane white nationalist who committed the El Paso atrocity.

Similar hysteria has greeted a new Trump administration regulation governing legal immigrants’ access to public welfare. The New York Times depicted the new rule as part of an effort by the president and his hard-line immigration adviser, Stephen Miller, to “shift” the demographic makeup of newcomers to the country.

Under the new rule, those who are in the country legally will have a more difficult time obtaining green cards or gaining citizenship if they received food stamps, housing assistance, Medicare or other public benefits.

But the outrage about this rule, which is set to go into effect in 60 days, is overblown. Even in the era of mass immigration in the 19th and early 20th centuries, those who came here had to promise not to become a “public charge” upon the United States.

That meant immigrants pledged to work and/or could look to sponsors who would guarantee their support.

The idea of restricting immigration to those who could work is an old one. The federal Immigration Act of 1882 was the first US law to specifically insist that immigrants who couldn’t take care of themselves would be excluded.

That “public-charge” principle has been part of every subsequent federal statute on the subject. The landmark 1965 Immigration and Nationality Act liberalized the system, but it nevertheless allowed for the deportation of immigrants who became public charges within five years.

Moreover, far from being a Trump innovation, the likelihood of needing government assistance is already grounds to deny an immigrant a green card or citizenship.

What is different is that this rule broadens the definition of a public charge. Instead of being defined as receiving welfare payments, it will now also include the myriad benefits available under the ever-expanding welfare state that exists in the 21st century.

Critics complain that this will discourage legal immigrants from seeking assistance that they might need. But the Trump administration wants to shift our immigration system to one based on merit, like the ones that reign in Canada and many European countries.

As with every other debate, however, liberals are turning this into a question of race and identity. Trump, they argue, wants to make it harder for immigrants from non-white countries.

But the story of immigration to the United States has always been about people of every race, color and creed who come here to work and take advantage of American freedoms and opportunity — not a desire to take advantage of the welfare state.

This isn’t about race, Trump’s irresponsible comments about wanting people from Norway and not s- -thole countries notwithstanding.

Even if you don’t share administration hard-liners’ desire to cut back legal immigration, ­emphasizing merit is a common-sense concern that is supported by most Americans. Our culture is rooted in self-sufficiency and individual initiative. Our immigration system should reflect our national creed.

The devil is in the details in a regulation that is a staggering 837 pages long and that lists factors that will either negatively or positively affect the decisions of officials about granting green cards and eligibility for citizenship. It should be enforced in such a way that will not penalize those who came here to work and fell on hard times for reasons not of their own making.

It isn’t surprising that those who advocate open borders and wish to abolish ICE would also oppose public-charge laws. But it ill behooves those who claim to champion the rights of immigrants to take a stand that essentially ­demands that Americans to go along with prioritizing the needs of newcomers.

To maintain America’s pro-immigration consensus, immigration must be seen as about opportunity — not welfarism.

Jonathan Tobin is editor in chief of JNS.org and a contributor to National Review. Twitter: @JonathanS_Tobin