If anyone can claim the title of "most surprised" by Thursday's Affordable Care Act ruling, it might be Matt Salo. He directs the National Association of Medicaid Directors here in Washington and had no inkling that the Supreme Court would make the law's expansion of Medicaid to 17 million Americans an option, rather than a requirement.

"We did not see that coming," Salo says. "I did manage to put together a short little statement, but this is not an option we had prepared for at all."

Salo works with all 50 states, including those that really like the law—and those who hate it. From where he sits, he sees governors and Medicaid directors now facing a very big choice.

"States are going to weigh leaving huge amounts of federal dollars on the table, versus accepting potential exposure from expanding an entitlement program," Salo says. "You used to just have to hold your nose because you had to do it. Now, every state is going to have to make some aggressive calculations."

Those calculations pretty much boil down to two incentives, pulling in opposite directions. On the one hand, there's a deep pot of federal money for states to expand their Medicaid programs. On the other, there's the fear of getting even more saddled with bills from an increasingly expensive entitlement program.

Let's unpack that a little bit.

There's one really big incentive to expand Medicaid: a huge sum of federal money. The federal government will pay the complete cost for the Medicaid expansion for three years,  100 percent of the bill for enrolling the newly eligible. That's a great deal for states, since the federal match for Medicaid is traditionally much lower. It varies by state—those with low-income residents get a higher match than those with high earners— but on average, the federal government currently pays 57 percent of the bill.

The Urban Institute's John Holohan ran the numbers for the Kaiser Family Foundation and found that the federal government will spend $443.5 billion on this provision from 2014 to 2019.

"Spending in 2014 is expected to be relatively small, particularly for states, because enrollment is being phased-in and the federal matching rate for new eligibles is 100 percent," Holohan concluded.

When you think about it that way, the Medicaid expansion sounds like a real win: States get loads of free money to pay their residents' health-care bills. It would be a big help to local hospitals and doctors, who often get stuck with uninsured patients' bills. And it would likely drive down the cost of health care for everyone; studies have found higher rates of uninsurance to be associated with higher costs for everyone else.

That's the good side. Now, the negatives: States could incur significant costs from the expansion. The federal government won't cover all bills for Medicaid enrollees who were already eligible for the program but never signed up. States worry about those people showing up to enroll, because of all the publicity around the health-care expansion, and having to accept them at the regular match rate.

Meanwhile, the 100 percent match rate doesn't last forever. After those first three years, the federal government's match rate starts dropping: It will pay 95 percent of the cost beginning in 2017 and then, in 2020, foot 90 percent of the bill.

States fear that the federal government might decide to ratchet back that number, Salo says. The White House has already shown a willingness to reduce Medicaid spending. Why wouldn't it rejigger a program that pays for Medicaid at a rate much higher than it has traditionally spent?

States already see Medicaid eating up a big chunk of their spending plans. The entitlement program takes a 24 percent bite out of state budgets—and keeps eating more. The National Association of State Budget Officers found that Medicaid costs grew by 20 percent in 2012.

"Then it does become an additional state expense," Salo says. "There isn't a state out there that hasn't seen the White House and Congress talking about reducing Medicaid spending, and thinking about that."

Let's take a state like Texas—which has the nation's highest rate of uninsured residents and is not a fan of the Affordable Care Act. It stands to gain a lot from the federal expansion: It would receive $52 billion from 2014 to 2019, and its Medicaid program would expand by 45.5 percent. One study from Bloomberg Government estimates that Texas would get more money from the Medicaid expansion than any other state.

However, the Lone Star State would also have to spend $2.6 billion of its own money on the expansion and see its Medicaid costs rise by 3 percent over the same time period. This is all to implement a law that the Texas government sued to overturn.

The White House, for its part, thinks that all states will play ball. After all, all states participate in Medicaid now—and do so with a lot less federal funding than the expansion provides.

But Texas isn't so sure it's game. "I’m pleased that it gives states more ability to push back against a forced expansion of Medicaid," Texas Health and Human Services Commission chairman Tom Suehs said in a statement Thursday. He said he'll be working with Texas Gov. Rick Perry "to fully analyze the ruling."

After the Supreme Court ruling, states are likely having similar conversations across the country -- as they begin to think through their next move.