<commit_before>import React, { Component } from 'react';
import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
import Relay from 'react-relay/classic';
import PropTypes from 'prop-types';
import Popover from 'material-ui/Popover';
import Checkbox from 'material-ui/Checkbox';
import FlatButton from 'material-ui/FlatButton';
import TextField from 'material-ui/TextField';
import CopyToClipboard from 'react-copy-to-clipboard';
import styled from 'styled-components';
import config from 'config'; // eslint-disable-line require-path-exists/exists
import PageTitle from '../PageTitle';
import MediaUtil from './MediaUtil';
import MediaStatus from './MediaStatus';
import PenderCard from '../PenderCard';
import CheckContext from '../../CheckContext';
import MediaRoute from '../../relay/MediaRoute';
import Message from '../Message';
import { can } from '../Can';
import CreateMemebusterMutation from '../../relay/mutations/CreateMemebusterMutation';
import UpdateMemebusterMutation from '../../relay/mutations/UpdateMemebusterMutation';
import RelayContainer from '../../relay/RelayContainer';
import {
  black87,
  black54,
  alertRed,
  ContentColumn,
  units,
} from '../../styles/js/shared';

const StyledTwoColumnLayout = styled(ContentColumn)`
  flex-direction: column;
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  padding: 0;
  flex-direction: row;

  .column {
    max-width: 100%;
  }
`;

const StyledPopover = styled(Popover)`
  .media-embed__customization-label {
    flex-grow: 1;
    font-size: ${units(2)};
    margin: ${units(2)}
    color: ${black54};

    .media-embed__customization-slogan {
      color: ${black87};
      font-size: 14px;
    }
    padding-#{$to-direction}: 16px;
  }

  #media-embed__copy-code, #media-embed__copy-share-url {
    padding: 16px;
    width: 560px;

    .media-embed__warning {
      color: ${alertRed};
      font-size: 14px;
      font-weight: bold;
    }

    .media-embed__copy-footer {
      display: flex;
    }

    #media-embed__code-field, #media-embed__share-field {
      background: transparent;
      border: 1px solid #eee;
      flex-grow: 1;
      font-family: 'Roboto Mono';
      font-size: 12px;
      padding: 1px;

      &:focus {
        outline: none;
      }
    }
  }
`;

class MediaEmbedComponent extends Component {
  constructor(props) {
    super(props);

    const { team } = props.media;
    const customizationOptions = {};
    let url = window.location.href.replace(/\/embed$/, `?t=${new Date().getTime()}`);
    if (props.media.dynamic_annotation_memebuster) {
      JSON.parse(props.media.dynamic_annotation_memebuster.content).forEach((field) => {
        if (field.field_name === 'memebuster_show_analysis') {
          customizationOptions.analysis = field.value;
        } else if (field.field_name === 'memebuster_disclaimer') {
          customizationOptions.disclaimer = field.value;
        } else if (field.field_name === 'memebuster_tasks') {
          field.value.forEach((id) => {
            customizationOptions[`task-${id}`] = true;
          });
        } else if (field.field_name === 'memebuster_custom_url') {
          customizationOptions.url = field.value;
          if (/^http/.test(field.value)) {
            url = field.value;
          }
        }
      });
    } else {
      if (team.get_disclaimer) {
        customizationOptions.disclaimer = team.get_disclaimer;
      }
      if (team.get_embed_tasks) {
        const teamTasksIds = team.get_embed_tasks.split(',');
        props.media.tasks.edges.forEach((task) => {
          if (teamTasksIds.indexOf(task.node.team_task_id.toString()) > -1) {
            customizationOptions[`task-${task.node.dbid}`] = true;<commit_msg>Ticket #7851: Make it work for orphan items<commit_after>import React, { Component } from 'react';
import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
import Relay from 'react-relay/classic';
import PropTypes from 'prop-types';
import Popover from 'material-ui/Popover';
import Checkbox from 'material-ui/Checkbox';
import FlatButton from 'material-ui/FlatButton';
import TextField from 'material-ui/TextField';
import CopyToClipboard from 'react-copy-to-clipboard';
import styled from 'styled-components';
import config from 'config'; // eslint-disable-line require-path-exists/exists
import PageTitle from '../PageTitle';
import MediaUtil from './MediaUtil';
import MediaStatus from './MediaStatus';
import PenderCard from '../PenderCard';
import CheckContext from '../../CheckContext';
import MediaRoute from '../../relay/MediaRoute';
import Message from '../Message';
import { can } from '../Can';
import CreateMemebusterMutation from '../../relay/mutations/CreateMemebusterMutation';
import UpdateMemebusterMutation from '../../relay/mutations/UpdateMemebusterMutation';
import RelayContainer from '../../relay/RelayContainer';
import {
  black87,
  black54,
  alertRed,
  ContentColumn,
  units,
} from '../../styles/js/shared';

const StyledTwoColumnLayout = styled(ContentColumn)`
  flex-direction: column;
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  padding: 0;
  flex-direction: row;

  .column {
    max-width: 100%;
  }
`;

const StyledPopover = styled(Popover)`
  .media-embed__customization-label {
    flex-grow: 1;
    font-size: ${units(2)};
    margin: ${units(2)}
    color: ${black54};

    .media-embed__customization-slogan {
      color: ${black87};
      font-size: 14px;
    }
    padding-#{$to-direction}: 16px;
  }

  #media-embed__copy-code, #media-embed__copy-share-url {
    padding: 16px;
    width: 560px;

    .media-embed__warning {
      color: ${alertRed};
      font-size: 14px;
      font-weight: bold;
    }

    .media-embed__copy-footer {
      display: flex;
    }

    #media-embed__code-field, #media-embed__share-field {
      background: transparent;
      border: 1px solid #eee;
      flex-grow: 1;
      font-family: 'Roboto Mono';
      font-size: 12px;
      padding: 1px;

      &:focus {
        outline: none;
      }
    }
  }
`;

class MediaEmbedComponent extends Component {
  constructor(props) {
    super(props);

    const { team } = props.media;
    const customizationOptions = {};
    let url = window.location.href.replace(/\/embed$/, `?t=${new Date().getTime()}`);
    if (props.media.dynamic_annotation_memebuster) {
      JSON.parse(props.media.dynamic_annotation_memebuster.content).forEach((field) => {
        if (field.field_name === 'memebuster_show_analysis') {
          customizationOptions.analysis = field.value;
        } else if (field.field_name === 'memebuster_disclaimer') {
          customizationOptions.disclaimer = field.value;
        } else if (field.field_name === 'memebuster_tasks') {
          field.value.forEach((id) => {
            customizationOptions[`task-${id}`] = true;
          });
        } else if (field.field_name === 'memebuster_custom_url') {
          customizationOptions.url = field.value;
          if (/^http/.test(field.value)) {
            url = field.value;
          }
        }
      });
    } else {
      if (team.get_disclaimer) {
        customizationOptions.disclaimer = team.get_disclaimer;
      }
      if (team.get_embed_tasks) {
        const teamTasksIds = team.get_embed_tasks.split(',');
        props.media.tasks.edges.forEach((task) => {
          const id = task.node.team_task_id ? task.node.team_task_id.toString() : '';
          if (teamTasksIds.indexOf(id) > -1) {
            customizationOptions[`task-${task.node.dbid}`] = true;
{'fraction_non_alphanumeric': 0.1426872770511296, 'fraction_numerical': 0.010569427929713304, 'mean_word_length': 3.03948772678762, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5435795', 'n_tokens_mistral': 2420, 'n_tokens_neox': 2349, 'n_words': 488}