NEW YORK — With Donald Trump's fixer-turned-foe Michael Cohen expected to take the witness stand Monday, the judge in the former president's hush money case issued prosecutors a stern warning: Get Cohen to stop his taunting posts and jabs at Trump.

Judge Juan M. Merchan's comments came as a dramatic and consequential week in the first criminal trial of a former American president drew to a close Friday.

Prosecutors have been building up their case ahead of crucial testimony from Cohen, who arranged the $130,000 payout to porn actor Stormy Daniels to keep her from going public ahead of the 2016 election about an an alleged sexual encounter with Trump a decade earlier. Trump denies ever having sex with Daniels.

Defense attorneys will argue that the disbarred lawyer who served prison time is out to get the former president and cannot be believed.

Two people familiar with the matter told The Associated Press that Cohen is expected to take the stand Monday. The people could not discuss the matter publicly and and spoke to AP on condition of anonymity.

Trump's lawyers complained after Cohen this week wore a shirt featuring a figure resembling the former president behind bars in a social media video. They have argued it's unfair Trump is under a gag order that prevents him from speaking publicly about witnesses while Cohen has continued to post about Trump on social media.

"It's becoming a problem every single day that President Trump is not allowed to respond to this witness but this witness is allowed to continue to talk," defense attorney Todd Blanche said.

Merchan told prosecutors they should inform Cohen "that the judge is asking him to refrain from making any more statements" about the case or about Donald Trump. Prosecutors told the judge they had already requested that Cohen and other witnesses not talk about the case, but had no direct means of controlling their behavior.

As the third week of testimony wrapped up Friday, the case that ultimately hinges on record-keeping returned to deeply technical testimony — a sharp contrast from Daniels' dramatic, if not downright seamy, account of the alleged sexual encounter with Trump that riveted jurors earlier this week.

The prosecution could rest its case by the end of next week, prosecutor Joshua Steinglass said.

Jurors saw social media posts showing that Trump initially praised Cohen after the then-lawyer came under federal investigation. Trump started bashing him after Cohen pleaded guilty to campaign-finance violations, along with other crimes, and claimed Trump directed him to arrange the payment for Daniels. Trump was never charged with any crime related to that federal investigation.

Trump, who was visibly angry during much of Daniels' testimony, chatted frequently with his lawyers and read through a stack of papers on the table in front of him as jurors heard from witnesses including AT&T and Verizon workers, who authenticated phone records.

Leaving the courthouse, Trump addressed the allegation at the heart of the case: that he falsified his company's records to conceal the nature of hush money reimbursements to Cohen.

"A very good bookkeeper marked a legal expense as a legal expense," Trump said. "He was a lawyer, not a fixer," he added, referring to Cohen.

Friday's dry testimony appeared to test jurors' patience at times. One juror stifled a yawn while another stretched out his arms. Others shifted their gaze around the room or stared up at the ceiling.

In one of the livelier moments, Trump attorney Emil Bove asked a paralegal about the "tedious" work of going through lengthy phone, data and other records and preparing charts from them.

"Actually, I kind of enjoyed it," the paralegal said matter-of-factly, to chuckles from the courtroom audience.

"Respect," Bove replied.

Witnesses in the case have seesawed between bookkeepers and bankers with testimony about records and finances to Daniels and others with unflattering stories about Trump and the tabloid world machinations meant to keep them secret. Despite all the drama, in the end, the trial is about money changing hands — business transactions — and whether those payments were made to illegally influence the 2016 election.

Back on the witness stand Friday morning was Madeleine Westerhout, a former Trump White House aide. Prosecutors used Westerhout's testimony to detail the process by which Trump got personal mail — including checks to sign — while in the White House. It's relevant because that's how he received and signed the checks that reimbursed Cohen for the payment to Daniels, prosecutors say.

Westerhout testified that Trump was "very upset" when The Wall Street Journal published a 2018 story about the hush money deal with Daniels.

"My understanding was that he knew it would be hurtful to his family," Westerhout said, though she acknowledged she didn't recall him saying so specifically. The answer, elicited by Trump lawyer Susan Necheles, goes to the defense's argument that Daniels was paid to stay silent in order to protect Trump's family, not his campaign.

Daniels' story of an alleged sexual encounter with Trump was a crucial building block for prosecutors, who are seeking to show that the Republican and his allies buried unflattering stories in the waning weeks of the 2016 presidential election in an effort to illegally influence the race.

Over more than 7½ hours of testimony, Daniels relayed in graphic detail what she says happened after the two met at a 2006 celebrity golf outing at Lake Tahoe where sponsors included the adult film studio where she worked. Daniels explained how she felt surprise, fear and discomfort, even as she consented to sex with Trump.

During combative cross-examination, Trump's lawyers sought to paint Daniels as a liar and extortionist who's trying to take down the former president after drawing money and fame from her claims.

After Daniels left the witness stand Thursday, Trump's attorneys pushed for a mistrial over the level of tawdry details she provided, but Judge Juan M. Merchan denied the request.

This criminal case could be the only one of four against the presumptive Republican presidential nominee to go to trial before voters decide in November whether to send him back to the White House. Trump has pleaded not guilty and casts himself as the victim of a politically tainted justice system working to deny him another term.

___

Richer reported from Washington. Associated Press reporters Eric Tucker in Washington, Ruth Brown in New York and Adriana Gomez Licon in Miami contributed.