<commit_before>import UIKit

class PageHistoryFilterCountCollectionViewCell: UICollectionViewCell {
    @IBOutlet private weak var titleLabel: UILabel!
    @IBOutlet private weak var imageView: UIImageView!
    @IBOutlet private weak var imageLabel: UILabel!

    @IBOutlet private weak var rightSeparator: UIView!

    override func awakeFromNib() {
        super.awakeFromNib()
        updateFonts()
    }

    private func updateFonts() {
        imageLabel.font = UIFont.wmf_font(.callout, compatibleWithTraitCollection: traitCollection)
        titleLabel.font = UIFont.wmf_font(.footnote, compatibleWithTraitCollection: traitCollection)
    }

    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        super.traitCollectionDidChange(previousTraitCollection)
        updateFonts()
    }

    func configure(with title: String, image: UIImage, imageText: String, isRightSeparatorHidden: Bool) {
        titleLabel.text = title
        imageView.image = image
        imageLabel.text = imageText<commit_msg>add a sizing method<commit_after>import UIKit

class PageHistoryFilterCountCollectionViewCell: UICollectionViewCell {
    @IBOutlet private weak var titleLabel: UILabel!
    @IBOutlet private weak var imageView: UIImageView!
    @IBOutlet private weak var imageLabel: UILabel!

    @IBOutlet private weak var rightSeparator: UIView!

    override func awakeFromNib() {
        super.awakeFromNib()
        updateFonts()
    }

    @IBOutlet private var sizingOnlyWidthConstraint: NSLayoutConstraint!

    func sizeWith(width: CGFloat, title: String, image: UIImage, imageText: String, isRightSeparatorHidden: Bool) -> CGSize {
        if let sizingOnlyWidthConstraint = sizingOnlyWidthConstraint, sizingOnlyWidthConstraint.constant != width {
            sizingOnlyWidthConstraint.constant = width
        } else {
            sizingOnlyWidthConstraint = widthAnchor.constraint(equalToConstant: width)
            sizingOnlyWidthConstraint?.isActive = true
        }
        configure(with: title, image: image, imageText: imageText, isRightSeparatorHidden: isRightSeparatorHidden)
        setNeedsLayout()
        layoutIfNeeded()
        return systemLayoutSizeFitting(UIView.layoutFittingCompressedSize,
                                            withHorizontalFittingPriority: UILayoutPriority.defaultHigh,
                                            verticalFittingPriority: UILayoutPriority.defaultLow)
    }

    private func updateFonts() {
        imageLabel.font = UIFont.wmf_font(.callout, compatibleWithTraitCollection: traitCollection)
        titleLabel.font = UIFont.wmf_font(.footnote, compatibleWithTraitCollection: traitCollection)
    }

    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        super.traitCollectionDidChange(previousTraitCollection)
        updateFonts()
    }

    func configure(with title: String, image: UIImage, imageText: String, isRightSeparatorHidden: Bool) {
        titleLabel.text = title
        imageView.image = image
        imageLabel.text = imageText
{'fraction_non_alphanumeric': 0.06612903225806452, 'fraction_numerical': 0.0, 'mean_word_length': 3.487698986975398, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5525700', 'n_tokens_mistral': 813, 'n_tokens_neox': 805, 'n_words': 185}