<commit_before><link rel="import" href="tweet-control.html">
<link rel="import" href="tweet-media.html">

<template id="tweet">
  <style>
    :host {
      display: block;
    }
    #container {
      padding: 0.5em 1em;
    }
    #reply, #retweeted {
      color: #888;
    }
    #creator {
      color: green;
    }
    #body {
      color: black;
    }
    #body a{
      color: #377ac3;
      text-decoration: none;
    }

    .avatar {
      height: 16px;
    }

    #text {
      white-space: pre-wrap;
    }

    #media {
      display: flex;
      flex-direction: row;
      white-space: nowrap;
      width: 400px;
      overflow-x: auto;
      overflow-y: hidden;
    }
  </style>

  <div id="container">
    <x-tweet-control id="control"></x-tweet-control>
    <div id="retweeted"></div>
    <div id="reply"></div>
    <div id="creator"></div>
    <div id="body">
      <div id="text"></div>
      <div id="media"></div>
    </div>
  </div>
</template>

<template id="reply">
  <span class="reply-to">In reply to:</span>
  <span class="name"></span>
  <span class="handle">
    (<span class="screen-name"></span>)
  </span>
</template>

<template id="retweeted">
  <img class="avatar" src=""/>
  <span class="name"></span>
  <span class="handle">
    (<span class="screen-name"></span>)
  </span>
  <span> retweeted</span>
</template>

<template id="creator">
  <img class="avatar" src=""/>
  <span class="name"></span>
  <span class="handle">
    (<span class="screen-name"></span>)
  </span>
</template>


<script type="text/javascript">
  (function() {
    "use strict";

    const $$$tweet = document.currentScript.ownerDocument.querySelector('template#tweet').content;
    const $$$retweeted = document.currentScript.ownerDocument.querySelector('template#retweeted').content;
    const $$$reply = document.currentScript.ownerDocument.querySelector('template#reply').content;
    const $$$creator = document.currentScript.ownerDocument.querySelector('template#creator').content;

    class Tweet extends XElement {
      constructor() {
        super();
        this.attachShadow({mode: 'open'}).appendChild(document.importNode($$$tweet, true));

        this.$('#container').handle('mouseenter', () => {
          this.$('#control').show();
        });
        this.$('#container').handle('mouseleave', () => {
          this.$('#control').hide();
        });

        this.tweet = null;
      }

      connectedCallback() {
        if (this.tweet == null) {
          throw new Error('tweet is null');
        }
        $.registerObjectCallback(this.tweet, this);
        this.refresh();
      }

      disconnectedCallback() {
        $.unregisterObjectCallback(this.tweet, this);
      }

      setTweet(tweet) {
        if (this.tweet) {
          throw new Error('tweet has already been set:' + this.tweet.tweetId);
        }
        this.tweet = tweet;
        return this;
      }

      /*private*/ setReplyTo(screen_name) {
        $$$reply.$('.screen-name').textContent = screen_name;

        let $container = this.$('#reply');
        $.removeAllChildren($container);
        $container.appendChild(document.importNode($$$reply, true));
        return this;
      }

      /*private*/ setRetweeted(user) {
        $$$retweeted.$('.avatar').src = user.profile_image_url_https;
        $$$retweeted.$('.name').textContent = user.name;
        $$$retweeted.$('.screen-name').textContent = user.screen_name;

        let $container = this.$('#retweeted');
        $.removeAllChildren($container);
        $container.appendChild(document.importNode($$$retweeted, true));
        return this;
      }

      /*private*/ setCreator(user) {
        $$$creator.$('.avatar').src = user.profile_image_url_https;
        $$$creator.$('.name').textContent = user.name;
        $$$creator.$('.screen-name').textContent = user.screen_name;

        let $container = this.$('#creator');
        $.removeAllChildren($container);
        $container.appendChild(document.importNode($$$creator, true));
        return this;
      }

      /*private*/ setText(text) {
        let entities = [];
        [this.tweet.entities, this.tweet.extended_entities].forEach((obj) => {
          if ($.isDefined(obj)) {
            entities = Object.keys(obj).reduce((all, key) => {
              return all.concat(obj[key]);
            }, entities);
          }
        });
        this.$('#text').innerHTML = twttr.txt.autoLink(text, {
          urlEntities: entities
        });
        this.$('#text').querySelectorAll('a').forEach(function(node) {
          node.target = '_blank';
        });
        return this;
      }

      /*private*/ setMedia(entities, extended_entities) {
        let media = [];
        if (extended_entities && extended_entities.media) {<commit_msg>add link of author<commit_after><link rel="import" href="tweet-control.html">
<link rel="import" href="tweet-media.html">

<template id="tweet">
  <style>
    :host {
      display: block;
    }
    #container {
      padding: 0.5em 1em;
    }
    #reply, #retweeted {
      color: #888;
    }
    #body {
      color: black;
    }
    #body a{
      color: #377ac3;
      text-decoration: none;
    }

    .avatar {
      height: 16px;
    }

    #text {
      white-space: pre-wrap;
    }

    #media {
      display: flex;
      flex-direction: row;
      white-space: nowrap;
      width: 400px;
      overflow-x: auto;
      overflow-y: hidden;
    }
  </style>

  <div id="container">
    <x-tweet-control id="control"></x-tweet-control>
    <div id="retweeted"></div>
    <div id="reply"></div>
    <div id="creator"></div>
    <div id="body">
      <div id="text"></div>
      <div id="media"></div>
    </div>
  </div>
</template>

<template id="reply">
  <span class="reply-to">In reply to:</span>
  <span class="name"></span>
  <span class="handle">
    (<span class="screen-name"></span>)
  </span>
</template>

<template id="retweeted">
  <img class="avatar" src=""/>
  <span class="name"></span>
  <span class="handle">
    (<span class="screen-name"></span>)
  </span>
  <span> retweeted</span>
</template>

<template id="creator">
  <a href="#" target="_blank" style="color: green; text-decoration: none;">
    <img class="avatar" src=""/>
    <span class="name"></span>
    <span class="handle">
      (<span class="screen-name"></span>)
    </span>
  </a>
</template>


<script type="text/javascript">
  (function() {
    "use strict";

    const $$$tweet = document.currentScript.ownerDocument.querySelector('template#tweet').content;
    const $$$retweeted = document.currentScript.ownerDocument.querySelector('template#retweeted').content;
    const $$$reply = document.currentScript.ownerDocument.querySelector('template#reply').content;
    const $$$creator = document.currentScript.ownerDocument.querySelector('template#creator').content;

    class Tweet extends XElement {
      constructor() {
        super();
        this.attachShadow({mode: 'open'}).appendChild(document.importNode($$$tweet, true));

        this.$('#container').handle('mouseenter', () => {
          this.$('#control').show();
        });
        this.$('#container').handle('mouseleave', () => {
          this.$('#control').hide();
        });

        this.tweet = null;
      }

      connectedCallback() {
        if (this.tweet == null) {
          throw new Error('tweet is null');
        }
        $.registerObjectCallback(this.tweet, this);
        this.refresh();
      }

      disconnectedCallback() {
        $.unregisterObjectCallback(this.tweet, this);
      }

      setTweet(tweet) {
        if (this.tweet) {
          throw new Error('tweet has already been set:' + this.tweet.tweetId);
        }
        this.tweet = tweet;
        return this;
      }

      /*private*/ setReplyTo(screen_name) {
        $$$reply.$('.screen-name').textContent = screen_name;

        let $container = this.$('#reply');
        $.removeAllChildren($container);
        $container.appendChild(document.importNode($$$reply, true));
        return this;
      }

      /*private*/ setRetweeted(user) {
        $$$retweeted.$('.avatar').src = user.profile_image_url_https;
        $$$retweeted.$('.name').textContent = user.name;
        $$$retweeted.$('.screen-name').textContent = user.screen_name;

        let $container = this.$('#retweeted');
        $.removeAllChildren($container);
        $container.appendChild(document.importNode($$$retweeted, true));
        return this;
      }

      /*private*/ setCreator(user) {
        $$$creator.$('a').href = `https://twitter.com/${user.screen_name}`
        $$$creator.$('.avatar').src = user.profile_image_url_https;
        $$$creator.$('.name').textContent = user.name;
        $$$creator.$('.screen-name').textContent = user.screen_name;

        let $container = this.$('#creator');
        $.removeAllChildren($container);
        $container.appendChild(document.importNode($$$creator, true));
        return this;
      }

      /*private*/ setText(text) {
        let entities = [];
        [this.tweet.entities, this.tweet.extended_entities].forEach((obj) => {
          if ($.isDefined(obj)) {
            entities = Object.keys(obj).reduce((all, key) => {
              return all.concat(obj[key]);
            }, entities);
          }
        });
        this.$('#text').innerHTML = twttr.txt.autoLink(text, {
          urlEntities: entities
        });
        this.$('#text').querySelectorAll('a').forEach(function(node) {
          node.target = '_blank';
        });
        return this;
      }

      /*private*/ setMedia(entities, extended_entities) {
        let media = [];
        if (extended_entities && extended_entities.media) {
{'fraction_non_alphanumeric': 0.18218414533443436, 'fraction_numerical': 0.003096614368290669, 'mean_word_length': 2.5092357841361825, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 119, 'https://': 1, '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': '6571241', 'n_tokens_mistral': 3014, 'n_tokens_neox': 2973, 'n_words': 510}