Nearly three years since the group's elusive leader Abu Bakr al-Baghdadi declared a self-styled Islamic State in Iraq and Syria, ISIS is reeling from losses across its so-called "caliphate."

It is fast losing its grip on Mosul, its biggest hub in Iraq, and its de-facto capital in Syria -- Raqqa -- is all but surrounded.

But it's not just territory that the militant group is losing.

Over the last six months, ISIS has seen its finances slashed media operations crippled and several high-ranking leaders killed or captured.

The Syrian Democratic Forces -- an alliance of Kurds and Arab tribes -- are approaching the outskirts of Raqqa, and the battle will begin within "days," the French defense minister said Friday.

While the fight against ISIS is far from won, the lines of this war are slowly being redrawn. As the group is driven from key cities and villages in what was once its self-proclaimed caliphate, ISIS is evolving from territorial to ideological threat.

So what could ISIS 2.0 look like?

Going to ground

Before he was killed in a drone strike last year , ISIS spokesman Abu Mohammed al-Adnani said that potential setbacks in Mosul and Raqqa would not spell the group's end: "No: defeat is losing the will and the desire to fight."

For some ISIS fighters, there will be no escape from the battles of Mosul and Raqqa. Nor do they want one. Urged on by the messages of al-Adnani and al-Baghdadi, they will embrace martyrdom in the alleyways of Mosul and the wide expanses of the Jazeera desert. Most of those who fight to the death are likely to be foreign fighters, if past experience is any guide. Moroccans, Tunisians and Chechens will be among them.

Since its inception, ISIS has prepared for the 'day after' the caliphate. Its battle cry has long been "Baqiya wa tatamaddad," or "remain and expand." While its expansion may take generations, the group's leadership is ready for a stateless Islamic State. Top commanders and hardcore fighters will likely remain in Iraq and Syria, forming an underground resistance.

ISIS has cultivated deep roots in Sunni parts of Iraq (less so in Syria where many jihadists regard it as an interloper). Over the past decade, the group has developed networks skilled at raising money, obtaining weapons and clandestine organization across a wide swathe of Iraq -- from Diyala in the east to Rutbah close to the Jordanian border.

Even as it is under pressure in Mosul, ISIS remains active in many of these places, and is capable of carrying out suicide bombings in Baghdad, Tikrit and elsewhere. It has shown resilience in Syria, looking to establish footholds far from its Raqqa headquarters. In some ways, it is returning to what it does best -- agile attacks, mobility and surprise.

Switching allegiances

As ISIS' fortunes decline, some militants may try to switch allegiance to other groups. In Syria, these include the former al Qaeda affiliate Jabhat Fateh al Sham. But there's a long history of bad blood between the two groups, which had a bitter and public falling out three years ago. Few in the ISIS hierarchy would contemplate such a move.

In Iraq, there are precious few alternatives for ISIS militants because the group has systematically attacked rivals in the region.

Even so, ISIS' decline is an opportunity for al Qaeda in Iraq, Syria and beyond. Terrorism expert Bruce Hoffman suggests some militants will see al Qaeda as the only option for continuing their struggle. ISIS traces its origins to an al Qaeda franchise in Iraq (AQI).

Waging jihad in the West

At least 75% of ISIS fighters have been killed since the US-led coalition launched airstrikes in Iraq and Syria, according to US officials . By last December, they estimate ISIS' ranks had winnowed to between 12,000 and 15,000.

It is extraordinarily difficult to estimate how many foreign fighters remain in the region. But far fewer foreign fighters have been able to reach the 'promised land' in the last year than previously.

The most worrying possibility for the West is that these foreign fighters, finding survival in Iraq and Syria difficult post-caliphate, might return home to carry out lone-wolf style attacks -- as well as recruit new members and revive underground networks.

They will try to use migrant routes and often will travel alone. The travel patterns of those involved in the Paris and Brussels attacks uncovered deep flaws in the tracking of such individuals among European security services. While it's now much harder for foreign fighters to travel through Turkey, as migrant flows have slowed, an unknown number have slipped through the cracks.