A teenager who attacked two men in an early morning unprovoked incident in Wrexham - knocking both unconscious - has been spared immediate custody.

Both men hit their heads on the ground when they fell and one victim ended up with bleeds to the brain.

A court heard how it was feared on the night that he was dying and the 17-year-old attacker - who said he had "been out for a little drink" before the 3am attack - was warned he could have killed his victims and been charged with one punch manslaughter.

The prosecution said the youth bragged at the scene that they had been knocked out by him then a boy aged 16 - but he denied that in court.

A youth who cannot be publicly identified because of his age appeared at a North East Wales Youth Court at Mold and admitted affray following the incident in July of last year.

District Judge Gwyn Jones said the two victims had been out enjoying themselves and had done nothing to the defendant.

But he became aggressive and used his fists and caused serious injury.

One of them had to have treatment at Stoke Hospital which indicated the extent of the injury he suffered "as a result of your arrogance and violence."

He said the youth "could so easily be facing a far more serious charge" and it was no exaggeration to say that he could have killed them.

That is what could happen when people used force and victims hit their head and suffered catastrophic injuries.

His record of previous convictions did him no favours and the judge said he had given serious consideration as to whether the defendant should be subject to a detention and training order.

"You would have quite a shock in a custodial institution," he warned.

However, given his timely guilty plea and the realistic prospect that he could be rehabilitated the judge said he was persuaded that the most appropriate sentence would be a youth rehabilitation order with intensive supervision and surveillance. That, he warned, was not "an easy option."

The boy would be supervised for 91 days to try and change his attitude and to give him the necessary tools to try and ensure that he did not come back to court.

He was ordered to carry out 160 hours of unpaid work in the community and he must observe a 26 week tagged curfew to keep him indoors between 7pm and 7am.

The youth was ordered to pay £500 compensation to one victim and £100 to the other.

Justin Espie, prosecuting, said that victims Samuel Pugh, 23, and Sean Walker, 24, had been for a night out in Wrexham town centre and at 3am were outside Cresta Cabs and took no attention of a male who turned aggressively at them and said "what did you say?"

Two other males approached and all three started throwing punches at them.

Both were knocked to the ground, hit their heads and were unconscious.

One was punched a second time when he got up and a thud was heard when his head hit the ground again.

He suffered a significant wound to the back of the head, was unconscious for a matter of minutes and was described as convulsing on the ground.

The defendant continued to brag "you have been knocked out by a 16-year-old," the prosecutor alleged.

Mr Espie said that the attack was totally unprovoked.

The victim was defenceless and people present began to panic because he appeared dead.

He said the defendant was traced through Facebook photographs and a co-defendant - who had no previous convictions - had previously received a community order and told to pay compensation.

But the defendant had a number of previous convictions involving violence and he said it had been a random, unprovoked attack - sustained violence which caused a high level of injury.

In a victim impact statement Mr Pugh told how he suffered a wound to the back of the head, three bleeds on the brain and he spent 11 nights at the Royal University Hospital in Stoke.

He had a seizure and had to take epilepsy medication.

The victim said he was not allowed to drive and had to stay in Cheshire rather than drive to work. He had been unable to drive for eight months which affected his ability to carry out his work duties.

Two weeks after the attack he had graduated and while he had been able to attend the ceremony he had been unable to celebrate with his friends and he had missed out on a holiday to Greece.

He did not go out in Wrexham for six months after the unprovoked attack and it had caused him a great deal of stress and anxiety and had left him with continuing health issues.

Mr Walker, in his victim impact statement, told how he could still not believe what had happened.

He had seen his friend lying on the floor covered in blood.

"I honestly thought he could die. He looked incredibly vulnerable," he said.

"I didn't want any trouble. I just wanted my friend to be ok. I will remember the incident for the rest of my life. I genuinely thought that Sam would die."

Emma Simoes, defending, said her client appreciated the serious position he was in and that there could have been far more serious consequences.

She urged the court to deal with him in a way that avoided immediate custody, in line with a comprehensive report from the youth justice service.

Ten months had passed and she said there had been a considerable shift in his behaviour, attitude and motivation.

It was accepted that custody was more than justified but said the priority for someone of his age was rehabilitation.

She said it was not pre-planned.

It was his case that an altercation was already taking place and he got involved.

He was ashamed of his behaviour and was remorseful.