TikTok has agreed to pay Alabama at least £74 million and introduce new protections for teenagers, settling the state's lawsuit days before its case was due before a jury.