<commit_before><template>
  <div class="rutracker-post" v-once>
    <slot></slot>
  </div>
</template>

<script>
export default {
  data() {
    return {
      absolute_link_regexp: new RegExp("^https?://"),
      image_aligned_max_width: 0,
    }
  },

  mounted() {
    this.image_aligned_max_width = Math.round(document.documentElement.clientWidth / 3) + 50
    this.initPost()
  },

  methods: {
    convertThumbSrcToOriginal(thumb) {
      return thumb.replace(
          /http(s?):\/\/i(\d+)\.imageban\.ru\/thumbs\/(\d+)\.(\d+)\.(\d+)\/(\w+)\.(\w+)/,
          'http$1://i$2.imageban.ru/out/$3/$4/$5/$6.$7'
      ).replace(
          /http(s?):\/\/img(\d+)\.lostpic\.net\/(\d+)\/(\d+)\/(\d+)\/(\w+)\.th\.(\w+)/,
          'http$1://img$2.lostpic.net/$3/$4/$5/$6.$7'
      )/*.replace(
          /https?:\/\/s(\d+)\.radikal\.ru\/i(\d+)\/(\d+)\/([a-z\d]+)\/([a-z\d]+)t\.([a-z]+)/,
          'https://s$1.radikal.ru/i$2/$3/$4/$5.$6'
      )*/
    },

    fitImage(a, b) {
      return "undefined" == typeof a.naturalHeight && (a.naturalHeight = a.height, a.naturalWidth = a.width), a.width > b ? (a.height = Math.round(b / a.width * a.height), a.width = b, a.style.cursor = "move", !1) : !(a.width == b && a.width < a.naturalWidth) || (a.height = a.naturalHeight, a.width = a.naturalWidth, !1)
    },

    getOriginalImageFromLink($item) {
      if (!$item.attr('title').search(/fastpic\.ru/)) {
        return
      }

      const href = $item.parent('.postLink').attr('href')

      if (!href || -1 === href.search(/fastpic\.ru/)) {
        return
      }

      const src = href.replace(
          /https?:\/\/fastpic\.ru\/view\/(\d+)\/(\d+)\/(\w+)\/((?:\w+)(\w{2}))\.(\w+)\.html/,
          'https://i$1.fastpic.ru/big/$2/$3/$5/$4.$6?noht=1'
      )

      return src !== href ? src : ''
    },

    getOriginalSrc($item) {
      const path = $item.attr('title')

      let src = this.convertThumbSrcToOriginal(path)

      if (src !== path) {
        return src<commit_msg>Улучшение алгоритма нахождения оригинальных изображений<commit_after><template>
  <div class="rutracker-post" v-once>
    <slot></slot>
  </div>
</template>

<script>
export default {
  data() {
    return {
      absolute_link_regexp: new RegExp("^https?://"),
      image_aligned_max_width: 0,
    }
  },

  mounted() {
    this.image_aligned_max_width = Math.round(document.documentElement.clientWidth / 3) + 50
    this.initPost()
  },

  methods: {
    convertThumbSrcToOriginal(thumb) {
      return thumb.replace(
          /http(s?):\/\/i(\d+)\.imageban\.ru\/thumbs\/(\d+)\.(\d+)\.(\d+)\/(\w+)\.(\w+)/,
          'http$1://i$2.imageban.ru/out/$3/$4/$5/$6.$7'
      ).replace(
          /http(s?):\/\/img(\d+)\.lostpic\.net\/(\d+)\/(\d+)\/(\d+)\/(\w+)\.th\.(\w+)/,
          'http$1://img$2.lostpic.net/$3/$4/$5/$6.$7'
      )/*.replace(
          /https?:\/\/s(\d+)\.radikal\.ru\/i(\d+)\/(\d+)\/([a-z\d]+)\/([a-z\d]+)t\.([a-z]+)/,
          'https://s$1.radikal.ru/i$2/$3/$4/$5.$6'
      )*/
    },

    fitImage(a, b) {
      return "undefined" == typeof a.naturalHeight && (a.naturalHeight = a.height, a.naturalWidth = a.width), a.width > b ? (a.height = Math.round(b / a.width * a.height), a.width = b, a.style.cursor = "move", !1) : !(a.width == b && a.width < a.naturalWidth) || (a.height = a.naturalHeight, a.width = a.naturalWidth, !1)
    },

    getOriginalImageFromLink($item) {
      const title = $item.attr('title')

      if (-1 !== title.search(/fastpic\.ru/)) {
        return this.getOriginalFastpicSrc($item.parent('.postLink').attr('href'))
      } else if (-1 !== title.search(/\.radikal\.ru/)) {
        return this.getOriginalRadikalSrc($item.parent('.postLink').attr('href'))
      }

      return
    },

    getOriginalFastpicSrc(path) {
      if (!path || -1 === path.search(/fastpic\.ru/)) {
        return
      }

      const src = path.replace(
          /https?:\/\/fastpic\.ru\/view\/(\d+)\/(\d+)\/(\w+)\/((?:\w+)(\w{2}))\.(\w+)\.html/,
          'https://i$1.fastpic.ru/big/$2/$3/$5/$4.$6?noht=1'
      )

      return src !== path ? src : ''
    },

    getOriginalRadikalSrc(path) {
      if (!path || -1 === path.search(/\.radikal\.ru/)) {
        return
      }

      return path
    },

    getOriginalSrc($item) {
      const path = $item.attr('title')

      let src = this.convertThumbSrcToOriginal(path)

      if (src !== path) {
        return src
{'fraction_non_alphanumeric': 0.25838849577721984, 'fraction_numerical': 0.016662862360191738, 'mean_word_length': 2.1078014184397165, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 4, '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': '5319', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1709, 'n_words': 217}