<commit_before>import select from 'select-dom';
import React from 'dom-chef';
import features from '../libs/features';
import * as icons from '../libs/icons';
import {getRepoURL} from '../libs/utils';

function addInlineLinks(comment: HTMLElement, timestamp: string): void {
	const links = select.all<HTMLAnchorElement>(`
		[href^="${location.origin}"][href*="/blob/"]:not(.rgh-linkified-code),
		[href^="${location.origin}"][href*="/tree/"]:not(.rgh-linkified-code)
	`, comment);

	for (const link of links) {
		const linkParts = link.pathname.split('/');
		// Skip permalinks
		if (/^[0-9a-f]{40}$/.test(linkParts[4])) {
			continue;
		}

		linkParts[4] = `HEAD@{${timestamp}}`; // Change git ref
		link.after(
			' ',
			<a
				href={linkParts.join('/') + link.hash}
				className="muted-link tooltipped tooltipped-n"
				aria-label="Visit as permalink">
				{icons.clock()}
			</a>
		);
	}
}

function addDropdownLink(comment: HTMLElement, timestamp: string): void {
	const dropdownPosition = select('.show-more-popover .dropdown-divider', comment);

	// Comment-less reviews don't have a dropdown
	if (!dropdownPosition) {
		return;
	}

	dropdownPosition.after(
		<a
			href={`/${getRepoURL()}/tree/HEAD@{${timestamp}}`}
			className="dropdown-item btn-link"
			role="menuitem"
			title="Browse repository like it appeared on this day">
			View repo at this time
		</a>,
		<div className="dropdown-divider" />
	);
}

function init(): void {
	const comments = select.all(`
		:not(.js-new-comment-form) > .timeline-comment:not(.rgh-time-machine-links),<commit_msg>Avoid error in `comments-time-machine-links`<commit_after>import select from 'select-dom';
import React from 'dom-chef';
import features from '../libs/features';
import * as icons from '../libs/icons';
import {getRepoURL} from '../libs/utils';

function addInlineLinks(comment: HTMLElement, timestamp: string): void {
	const links = select.all<HTMLAnchorElement>(`
		[href^="${location.origin}"][href*="/blob/"]:not(.rgh-linkified-code),
		[href^="${location.origin}"][href*="/tree/"]:not(.rgh-linkified-code)
	`, comment);

	for (const link of links) {
		const linkParts = link.pathname.split('/');
		// Skip permalinks
		if (/^[0-9a-f]{40}$/.test(linkParts[4])) {
			continue;
		}

		linkParts[4] = `HEAD@{${timestamp}}`; // Change git ref
		link.after(
			' ',
			<a
				href={linkParts.join('/') + link.hash}
				className="muted-link tooltipped tooltipped-n"
				aria-label="Visit as permalink">
				{icons.clock()}
			</a>
		);
	}
}

function addDropdownLink(comment: HTMLElement, timestamp: string): void {
	const dropdownPosition = select('.show-more-popover .dropdown-divider', comment);

	// Comment-less reviews don't have a dropdown
	if (!dropdownPosition) {
		return;
	}

	dropdownPosition.after(
		<a
			href={`/${getRepoURL()}/tree/HEAD@{${timestamp}}`}
			className="dropdown-item btn-link"
			role="menuitem"
			title="Browse repository like it appeared on this day">
			View repo at this time
		</a>,
		<div className="dropdown-divider" />
	);
}

function init(): void {
	// PR reviews' main content has nested `.timeline-comment`, but the deepest one doesn't have `relative-time`. These are filtered out with `:not([id^="pullrequestreview"])`
	const comments = select.all(`
		:not(.js-new-comment-form):not([id^="pullrequestreview"]) > .timeline-comment:not(.rgh-time-machine-links),
{'fraction_non_alphanumeric': 0.1840308696942713, 'fraction_numerical': 0.003561887800534283, 'mean_word_length': 4.224806201550388, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '7581819', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1121, 'n_words': 248}