<commit_before>protocol SeekbarDelegate: NSObjectProtocol {
    func seek(_: TimeInterval)
}

class SeekbarView: UIView {
    @IBOutlet weak var seekBarContainerView: DragDetectorView! {
        didSet {
            seekBarContainerView.target = self
            seekBarContainerView.selector = #selector(handleSeekbarViewTouch(_:))
        }
    }
    @IBOutlet weak var scrubberPosition: NSLayoutConstraint!
    @IBOutlet weak var scrubber: UIView! {
        didSet {
            scrubber.accessibilityIdentifier = "scrubber"
        }
    }
    @IBOutlet weak var scrubberOuterCircle: UIView?
    @IBOutlet weak var bufferBar: UIView!
    @IBOutlet weak var progressBar: UIView!
    @IBOutlet weak var timeLabelView: UIView! {
        didSet {
            timeLabelView.isHidden = true
        }
    }
    @IBOutlet weak var timeLabel: UILabel!
    @IBOutlet weak var timeLabelPosition: NSLayoutConstraint!
    @IBOutlet weak var bufferWidth: NSLayoutConstraint!
    
    @IBOutlet open var scrubberOuterCircleWidthConstraint: NSLayoutConstraint?
    @IBOutlet open var scrubberOuterCircleHeightConstraint: NSLayoutConstraint?

    @IBOutlet open var progressBarWidthConstraint: NSLayoutConstraint?
    
    var isLive = false {
        didSet {
            setupStyle()
        }
    }

    var seekbarWidth: CGFloat = 0
    var videoDuration: CGFloat = 0
    var isSeeking = false
    var scrubberInitialWidth: CGFloat = 0.0
    var scrubberInitialHeight: CGFloat = 0.0
    
    weak var delegate: SeekbarDelegate?

    @objc func handleSeekbarViewTouch(_ view: DragDetectorView) {
        guard let touch = view.currentTouch else { return }

        let touchPoint = touch.location(in: seekBarContainerView)
        moveScrubber(relativeTo: touchPoint.x)
        seeking(relativeTo: scrubberPosition.constant, state: view.touchState)
        adjustScrubberConstraints()
        updateTimeLabel(relativeTo: scrubberPosition.constant)
    }

    func updateScrubber(time: CGFloat) {
        if !isSeeking && videoDuration > 0 {
            var position = (time / videoDuration) * (seekBarContainerView.frame.width - scrubber.frame.width)
            if position > seekBarContainerView.frame.width - scrubber.frame.width {
                position = seekBarContainerView.frame.width - scrubber.frame.width
            } else if position < 0 {
                position = 0
            }
            scrubberPosition.constant = position
            progressBarWidthConstraint?.constant = position + scrubber.frame.width / 2
            updateTimeLabel(relativeTo: scrubberPosition.constant)
        }
    }

    private func moveScrubber(relativeTo horizontalTouchPoint: CGFloat) {
        var position = horizontalTouchPoint - scrubberInitialWidth / 2
        let minBoundPosition = 0 - scrubberInitialWidth / 2
        let maxBoundPosition = seekBarContainerView.frame.width - scrubberInitialWidth / 2

        if position <= minBoundPosition {
            position = minBoundPosition
        } else if position > maxBoundPosition {
            position = maxBoundPosition
        }
        scrubberPosition.constant = position
        progressBarWidthConstraint?.constant = position + scrubber.frame.width / 2
    }
    
    private func moveTimeLabel(relativeTo horizontalTouchPoint: CGFloat, state: DragDetectorView.State) {
        if state == .moved {
            timeLabelView.isHidden = false
            var position = scrubberPosition.constant - timeLabelView.frame.width / 2 + scrubber.frame.width / 2
            if position <= 0 {
                position = 0
            } else if position > seekBarContainerView.frame.width - timeLabelView.frame.width {
                position = seekBarContainerView.frame.width - timeLabelView.frame.width
            }
            timeLabelPosition.constant = position
        } else {
            timeLabelView.isHidden = true
        }
    }

    private func updateTimeLabel(relativeTo horizontalTouchPoint: CGFloat) {
        let secs = seconds(relativeTo: horizontalTouchPoint)
        timeLabel.text = ClapprDateFormatter.formatSeconds(secs)
    }
<commit_msg>feat:Fix move and update scrubber<commit_after>protocol SeekbarDelegate: NSObjectProtocol {
    func seek(_: TimeInterval)
}

class SeekbarView: UIView {
    @IBOutlet weak var seekBarContainerView: DragDetectorView! {
        didSet {
            seekBarContainerView.target = self
            seekBarContainerView.selector = #selector(handleSeekbarViewTouch(_:))
        }
    }
    @IBOutlet weak var scrubberPosition: NSLayoutConstraint!
    @IBOutlet weak var scrubber: UIView! {
        didSet {
            scrubber.accessibilityIdentifier = "scrubber"
        }
    }
    @IBOutlet weak var scrubberOuterCircle: UIView?
    @IBOutlet weak var bufferBar: UIView!
    @IBOutlet weak var progressBar: UIView!
    @IBOutlet weak var timeLabelView: UIView! {
        didSet {
            timeLabelView.isHidden = true
        }
    }
    @IBOutlet weak var timeLabel: UILabel!
    @IBOutlet weak var timeLabelPosition: NSLayoutConstraint!
    @IBOutlet weak var bufferWidth: NSLayoutConstraint!
    
    @IBOutlet open var scrubberOuterCircleWidthConstraint: NSLayoutConstraint?
    @IBOutlet open var scrubberOuterCircleHeightConstraint: NSLayoutConstraint?

    @IBOutlet open var progressBarWidthConstraint: NSLayoutConstraint?
    
    var isLive = false {
        didSet {
            setupStyle()
        }
    }

    var seekbarWidth: CGFloat = 0
    var videoDuration: CGFloat = 0
    var isSeeking = false
    var scrubberInitialWidth: CGFloat = 0.0
    var scrubberInitialHeight: CGFloat = 0.0
    
    weak var delegate: SeekbarDelegate?

    @objc func handleSeekbarViewTouch(_ view: DragDetectorView) {
        guard let touch = view.currentTouch else { return }

        let touchPoint = touch.location(in: seekBarContainerView)
        moveScrubber(relativeTo: touchPoint.x)
        seeking(relativeTo: scrubberPosition.constant, state: view.touchState)
        adjustScrubberConstraints()
        updateTimeLabel(relativeTo: scrubberPosition.constant)
    }

    func updateScrubber(time: CGFloat) {
        if !isSeeking && videoDuration > 0 {
            let haltScrubberWidth = scrubberInitialWidth / 2
            let minBoundPosition =  -haltScrubberWidth
            let maxBoundPosition = seekBarContainerView.frame.width + haltScrubberWidth

            var position = (time / videoDuration) * (seekBarContainerView.frame.width)

            if position > maxBoundPosition {
                position = maxBoundPosition
            } else if position < minBoundPosition {
                position = minBoundPosition
            }
            scrubberPosition.constant = position - haltScrubberWidth
            progressBarWidthConstraint?.constant = position

            updateTimeLabel(relativeTo: scrubberPosition.constant)
        }
    }

    private func moveScrubber(relativeTo horizontalTouchPoint: CGFloat) {
        let haltScrubberWidth = scrubberInitialWidth / 2
        let minBoundPosition =  -haltScrubberWidth
        let maxBoundPosition = seekBarContainerView.frame.width - haltScrubberWidth

        var position = horizontalTouchPoint - haltScrubberWidth

        if position <= minBoundPosition {
            position = minBoundPosition
        } else if position > maxBoundPosition {
            position = maxBoundPosition
        }

        scrubberPosition.constant = position
        progressBarWidthConstraint?.constant = position + haltScrubberWidth
    }
    
    private func moveTimeLabel(relativeTo horizontalTouchPoint: CGFloat, state: DragDetectorView.State) {
        if state == .moved {
            timeLabelView.isHidden = false
            var position = scrubberPosition.constant - timeLabelView.frame.width / 2 + scrubber.frame.width / 2
            if position <= 0 {
                position = 0
            } else if position > seekBarContainerView.frame.width - timeLabelView.frame.width {
                position = seekBarContainerView.frame.width - timeLabelView.frame.width
            }
            timeLabelPosition.constant = position
        } else {
            timeLabelView.isHidden = true
        }
    }

    private func updateTimeLabel(relativeTo horizontalTouchPoint: CGFloat) {
        let secs = seconds(relativeTo: horizontalTouchPoint)
        timeLabel.text = ClapprDateFormatter.formatSeconds(secs)
    }

{'fraction_non_alphanumeric': 0.06569256355428843, 'fraction_numerical': 0.003801377999524828, 'mean_word_length': 2.5734295415959254, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '143505', 'n_tokens_mistral': 2268, 'n_tokens_neox': 2216, 'n_words': 522}