PRAGUE (NYTIMES) - For more than 1,000 years, the sprawling castle complex perched high above Prague has been the seat of power for Holy Roman emperors, the kings of Bohemia and, now, Czech President Milos Zeman.
And for the last four years, the Chinese technology giant Huawei has had a contract to fulfil the communication needs of the president and his staff.
The presidential contract is the most visible symbol of how deeply Huawei has established itself in the Czech Republic, long viewed by China as a springboard country for its interests across the European Union.
So when the Czech government's cyber-security agency issued a directive in December warning that Huawei represented a potential national security threat, company officials were shocked - as was Mr Zeman, known for his closeness to China.
Huawei has threatened legal and financial retaliation. Mr Zeman has accused his own intelligence services, including the cyber-security agency, known as Nukib, of "dirty tricks".
The unexpected confrontation in the Czech Republic comes as Huawei, already entangled in the trade war between China and the United States, is running into deepening problems in EU countries, where it has worked for years to build inroads.
In January, only weeks after Nukib issued its directive against Huawei, Polish authorities arrested a Huawei employee in Warsaw on charges of spying.
Looming above everything is the question of which companies will build the infrastructure of the fifth generation of wireless technology, known as 5G.
United States officials regard the technology as a national security issue and have moved aggressively to limit the role of Chinese companies, especially Huawei.
Speaking in Budapest on Monday (Feb 11), US Secretary of State Mike Pompeo, who is touring Central Europe, warned about "risks that Huawei's presence in their networks present - actual risks to their people, to the loss of privacy protections".
Huawei is already hitting problems in Germany and Britain, traditional American allies. Yet few people would have predicted that the most direct action against the company would come from the Czech Republic, where Mr Zeman has long courted Chinese investment and is planning to make his fifth visit to China in the spring.
The Nukib directive has infuriated the president and driven a wedge into the Czech government.
In an interview, Mr Dusan Navratil, the head of the agency, said the stakes are high because 5G "will change the whole way societies function".
While the public might think of 5G as simply a matter of faster download times, the system is designed to be far more, linking everything from the cars we drive to the hospitals we visit in a way unimaginable only a decade ago.
Mr Navratil said one reason his agency penalised Huawei was China's National Intelligence Law, which was passed in 2017 and requires Chinese companies to support, provide assistance and cooperate in the authoritarian nation's national intelligence work, wherever they operate. While declining to discuss classified intelligence, he offered an analogy.
"Imagine there is a restaurant where the hygiene is filthy rotten," Mr Navratil said. "The agency overseeing the restaurant has no evidence someone has gotten sick or died. But does that mean you should eat there?"
As a result of the agency's move, Huawei's business in the Czech Republic could be devastated. The directive doesn't affect consumer products, such as mobile phones, but it aims to severely restrict the role Huawei can play in 5G, and to block it from supplying equipment to public and private entities deemed critical to national security.
"This is the first time we have ever issued such a warning," Mr Navratil said.
Since then, the Ministries of Health and Justice announced that they would not honour existing contracts to buy servers from Huawei. The country's largest carmaker, Skoda, has temporarily stopped Huawei from bidding on projects as it undergoes a security review demanded by the new cyber directive.
Even Huawei's contract with the presidential offices is under review.
In turn, Huawei has been hitting back. Last week, the company threatened litigation against the cyber agency, as well as economic retaliation. It also has intensified lobbying campaigns with some lawmakers and others in the political elite, including a Czech delegation that the company hosted in China last month.
"The Chinese believe they are one to two years ahead of everyone and they see this as an effort to slow them down," said Mr Jaroslav Roman, a Czech Communist Party official on the visit.
"They wanted us to know that if the discrimination continued, there would be repercussions."
Huawei officials have argued that the Chinese law regarding intelligence is being deliberately misinterpreted, a point disputed by many Western experts.
But it is the threat of economic retaliation that has most alarmed many business leaders and lawmakers, given how ardently Mr Zeman has built economic ties between the two countries. One example is PPF Group, the largest Czech company, which has focused on China in recent years.
Its home lending business counts some 15 million Chinese customers, which is not much in Chinese terms but hugely important for the Czech-owned company. PPF also controls the country's largest telecom provider, O2, and had signed a memorandum of understanding with Huawei regarding future projects before the security agency issued its warning. That will now have to be reviewed.
Mr Mel Carvill, a board member for Home Credit, a consumer loan company that is a part of the PPF Group, said the Chinese regulatory agency overseeing the home lending business had not taken any action against the company.
"Of course, if relations between countries deteriorate, things might become difficult," he said.
Huawei officials, for their part, were so confident in their standing in the Czech Republic that in June, they decided to push for Czech security clearance to work on critical infrastructure - a move that may have contributed to the cyber agency's decision to scrutinise the Chinese company more closely.
"It was overreach on their part," said Mr Jakub Janda, director at the Prague-based think tank, European Values.
Mr Janda said there was particular concern about the dozens of technology assistants working for Huawei who had unlimited access to all the data gathered by their mobile partners.
Unlike cases involving Russians accused of spying in the Czech Republic, Mr Janda noted, concerns about Chinese espionage are kept quiet for diplomatic reasons. No one has been charged with spying in the country.
Even as Huawei is trying to regain footing in the Czech Republic, the company is also mounting a public relations counteroffensive in Poland, after the arrest in January of the company executive. Last week, Huawei issued a news release in Poland, warning that communication services would increase by 300 per cent if the company were excluded from the market.
Meanwhile, Huawei has sought to ease Polish security concerns by promising to spend hundreds of millions on a new cyber-security centre. It has also offered the Polish government access to Huawei's source code in order to prove that its equipment does not have a "back door" for the Chinese intelligence services.
However, some experts have said such gestures are hollow, given how often codes can be updated or changed.
For Mr Navratil, the head of the Czech cyber agency, the issue facing security officials was as evident as it was urgent.
"We are a sovereign country and we have a right to say what is in our security interest," he said.
It would be helpful, he said, if Nato or the EU would offer some specific guidance, since it would give small nations greater ability to act without fear of retaliation.
That does not appear to be happening anytime soon.
"Given the stakes," Mr Navratil said, "we cannot just rush headlong into this."