"use strict";!function(e,a,r){function i(){var e=(new Date).getTime(),a="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==a?r:3&r|8).toString(16)});return a}function s(a){function r(){x.sort(function(e,a){return u.markerTip.time(e)-u.markerTip.time(a)})}function s(a){e.each(a,function(a,r){r.key=i(),p.find(".vjs-progress-control").append(n(r));var s=e("<div class='vjs-ch-box'><div class='vjs-ch-left'><div class='ch-number'>"+r.id+"</div><div class='vjs-ch-inner'><div class='ch-name'>"+r.text+"</div><div class='ch-time'><div class='ch-time-icon'><i></i></div><div class='ch-time-t1'></div><div class='ch-time-next'>></div><div class='ch-time-t2'>"+r.timeEnd+"</div></div></div></div><div class='vjs-ch-right'><div class='vjs-interactive'><p>explore o<br><b>interativo</b></p></div></div></div>");p.find(".vjs-marker:last-child").append(s),1==r.id?(e(".vjs-marker:last-child").find(".vjs-ch-box").addClass("vjs-ch-box-1"),e(".vjs-marker:last-child").find(".vjs-interactive").addClass("vjs-interactive-ch1"),e(".vjs-marker:last-child").find(".ch-number").addClass("ch-number-1"),e(".vjs-marker:last-child").find(".ch-time").addClass("ch-time-1"),e(".vjs-marker:last-child").find(".ch-name").addClass("ch-name-1"),e(".vjs-marker:last-child").find("a").attr("href","#section1")):2==r.id?(e(".vjs-marker:last-child").find(".vjs-ch-box").addClass("vjs-ch-box-2"),e(".vjs-marker:last-child").find(".vjs-interactive").addClass("vjs-interactive-ch2"),e(".vjs-marker:last-child").find(".ch-number").addClass("ch-number-2"),e(".vjs-marker:last-child").find(".ch-time").addClass("ch-time-2"),e(".vjs-marker:last-child").find(".ch-name").addClass("ch-name-2"),e(".vjs-marker:last-child").find("a").attr("href","#section2")):3==r.id?(e(".vjs-marker:last-child").find(".vjs-ch-box").addClass("vjs-ch-box-3"),e(".vjs-marker:last-child").find(".vjs-interactive").addClass("vjs-interactive-ch3"),e(".vjs-marker:last-child").find(".ch-number").addClass("ch-number-3"),e(".vjs-marker:last-child").find(".ch-time").addClass("ch-time-3"),e(".vjs-marker:last-child").find(".ch-name").addClass("ch-name-3"),e(".vjs-marker:last-child").find("a").attr("href","#section3")):4==r.id?(e(".vjs-marker:last-child").find(".vjs-ch-box").addClass("vjs-ch-box-4"),e(".vjs-marker:last-child").find(".vjs-interactive").addClass("vjs-interactive-ch4"),e(".vjs-marker:last-child").find(".ch-number").addClass("ch-number-4"),e(".vjs-marker:last-child").find(".ch-time").addClass("ch-time-4"),e(".vjs-marker:last-child").find(".ch-name").addClass("ch-name-4"),e(".vjs-marker:last-child").find("a").attr("href","#section4")):5==r.id?(e(".vjs-marker:last-child").find(".vjs-ch-box").addClass("vjs-ch-box-5"),e(".vjs-marker:last-child").find(".vjs-interactive").addClass("vjs-interactive-ch5"),e(".vjs-marker:last-child").find(".ch-number").addClass("ch-number-5"),e(".vjs-marker:last-child").find(".ch-time").addClass("ch-time-5"),e(".vjs-marker:last-child").find(".ch-name").addClass("ch-name-5"),e(".vjs-marker:last-child").find("a").attr("href","#section5")):6==r.id&&(e(".vjs-marker:last-child").find(".vjs-ch-box").addClass("vjs-ch-box-6"),e(".vjs-marker:last-child").find(".vjs-interactive").addClass("vjs-interactive-ch6"),e(".vjs-marker:last-child").find(".ch-number").addClass("ch-number-6"),e(".vjs-marker:last-child").find(".ch-time").addClass("ch-time-6"),e(".vjs-marker:last-child").find(".ch-name").addClass("ch-name-6"),e(".vjs-marker:last-child").find("a").attr("href","#section6")),j[r.key]=r,x.push(r)}),r()}function d(e){return u.markerTip.time(e)/y.duration()*100}function n(a,r){var i=e("<div class='vjs-marker'></div>");return i.css(u.markerStyle).css({"margin-left":-parseFloat(i.css("width"))/2+"px",left:d(a)+"%"}).attr("data-marker-key",a.key).attr("data-marker-time",u.markerTip.time(a)),a["class"]&&i.addClass(a["class"]),i.on("click",function(r){var i=!1;if("function"==typeof u.onMarkerClick&&(i=0==u.onMarkerClick(a)),!i){var s=e(this).data("marker-key");y.currentTime(u.markerTip.time(j[s]))}}),u.markerTip.display&&v(i),i}function c(){for(var e=0;e<x.length;e++){var a=x[e],i=p.find(".vjs-marker[data-marker-key='"+a.key+"']"),s=u.markerTip.time(a);i.data("marker-time")!=s&&(console.log("markerTime --> ",s),i.css({left:d(a)+"%"}).attr("data-marker-time",s))}r()}function l(e){T&&(g=-1,T.css("visibility","hidden")),b=-1;for(var a=0;a<e.length;a++){var i=e[a],s=x[i];s&&(delete j[s.key],x[i]=null,p.find(".vjs-marker[data-marker-key='"+s.key+"']").remove())}for(var a=x.length-1;a>=0;a--)null===x[a]&&x.splice(a,1);r()}function v(a){a.on("mouseover",function(){var a=j[e(this).data("marker-key")];C.find(".vjs-tip-inner").text(u.markerTip.text(a)),C.css({left:d(a)+"%","margin-left":-parseFloat(C.css("width"))/2-5+"px"})}).on("mouseout",function(){C.css("visibility","hidden")})}function m(){C=e("<div class='vjs-tip'><div class='vjs-tip-arrow'></div><div class='vjs-tip-inner'></div></div>"),p.find(".vjs-progress-control").append(C)}function h(e){if(!(0>b)){var a=x[b],r=u.markerTip.time(a);e>=r&&e<=r+u.breakOverlay.displayTime?(g!=b&&(g=b,T.find(".vjs-break-overlay-text").text(u.breakOverlay.text(a))),T.css("visibility","visible")):(g=-1,T.css("visibility","hidden"))}}function o(){T=e("<div class='vjs-break-overlay'><div class='vjs-break-overlay-text'></div></div>").css(u.breakOverlay.style),p.append(T),g=-1}function k(){var e,r=function(e){return e<x.length-1?u.markerTip.time(x[e+1]):y.duration()},i=y.currentTime();if(-1!=b){var s=r(b);if(i>=u.markerTip.time(x[b])&&s>i)return}if(x.length>0&&i<u.markerTip.time(x[0]))e=-1;else for(var t=0;t<x.length;t++)if(s=r(t),i>=u.markerTip.time(x[t])&&s>i){e=t;break}e!=b&&(-1!=e&&a.onMarkerReached&&a.onMarkerReached(x[e]),b=e),u.breakOverlay.display&&h(i)}function f(){u.markerTip.display&&m(),y.markers.removeAll(),s(a.markers),u.breakOverlay.display&&o(),k(),y.on("timeupdate",k)}var u=e.extend(!0,{},t,a),j={},x=[],p=e(this.el()),b=-1,y=this,C=null,T=null,g=-1;y.on("loadedmetadata",function(){f()}),y.markers={getMarkers:function(){return x},next:function(){for(var e=y.currentTime(),a=0;a<x.length;a++){var r=u.markerTip.time(x[a]);if(r>e){y.currentTime(r);break}}},prev:function(){for(var e=y.currentTime(),a=x.length-1;a>=0;a--){var r=u.markerTip.time(x[a]);if(e>r+.5){y.currentTime(r);break}}},add:function(e){s(e)},remove:function(e){l(e)},removeAll:function(){for(var e=[],a=0;a<x.length;a++)e.push(a);l(e)},updateTime:function(){c()},reset:function(e){y.markers.removeAll(),s(e)},destroy:function(){y.markers.removeAll(),T.remove(),C.remove(),y.off("timeupdate",h),delete y.markers}}}var t={markerStyle:{width:"7px","border-radius":"30%","background-color":"red"},markerTip:{display:!0,text:function(e){return"Break: "+e.text},time:function(e){return e.time}},breakOverlay:{display:!1,displayTime:3,text:function(e){return"Break overlay: "+e.overlayText},style:{width:"100%",height:"20%","background-color":"rgba(0,0,0,0.7)",color:"white","font-size":"17px"}},onMarkerClick:function(e){},onMarkerReached:function(e){},markers:[]};a.plugin("markers",s)}(jQuery,window.videojs);