new Promise(()=>{
 "use strict";

const F = function(){
  const
    watchData = document.getElementById('js-initial-watch-data')
    ,apiData = JSON.parse(watchData.getAttribute('data-api-data'))
    ,environment = JSON.parse(watchData.getAttribute('data-environment'))
    ,video = apiData.video
    ,thread = apiData.thread
    ,owner = apiData.owner
    ,tL = apiData.tags
    ,area = environment.i18n.area.toLowerCase()
    ,p = window.popThumb
    ,data = p.data;
  var tags = [];
  for(let i = tL.length; i--;){
    let t = tL[i];
    tags.unshift({
      "text" : t.name,
      "category" : (t.isCategory? 1: 0),
      "dic" : (t.isDictionaryExists? 1: 0),
      "lock" : (t.isLocked? 1: 0),
      "domain" : area,
      "area" : area,
    });
  }
  var
    vid = video.id
    ,D = {
      "title" : video.title,
      "description" : video.description,
      "description_videoarray" : video.description,
      "view_counter" : video.viewCount,
      "mylist_counter" : video.mylistCount,
      "comment_counter" : thread.commentCount,
      "tags" : tags,
    }
    ,D2 = {};
  
  if (!!owner) {
    D["user_id"] = owner.id;
    D["user_nickname"] = owner.nickname;
  }
  if (!!data[`obj_${vid}`]) {
    D2 = data[`obj_${vid}`][1];
  } else {
    let duration = video.duration;
    D2 = {
      "thumbnail_url" : video.thumbnailURL,
      "deleted" : (video.isDeleted? 1: 0),
      "video_id" : vid,
      "first_retrieve" : video.postedDateTime.replace(/[/]/g, '-').replace(' ', 'T') +'+00:00',
      "length_in_seconds" : duration,
      "length" : ('0' +((duration /60) |0)).slice(-2) + ':' + ('0' +(duration %60)).slice(-2),
      "movie_type" : video.movieType,
      "size_low" : null,
      "usingAPI" : {},
    };
  }
  for(let j in D) D2[j] = D[j];
  data[`obj_${vid}`] = ['object', D2];
  if(typeof p.save === "function") window.setTimeout(p.save, 1000);
  //console.log('update popThumbFA');
};

document.addEventListener("DOMContentLoaded", F, false);
});