/*
@license
dhtmlxScheduler v.5.1.6 Professional Evaluation

This software is covered by DHTMLX Evaluation License. Contact sales@dhtmlx.com to get Commercial or Enterprise license. Usage without proper license is prohibited.

(c) Dinamenta, UAB.
*/
Scheduler.plugin(function(e){e._temp_matrix_scope=function(){function t(){var e=document.createElement("p");e.style.width="100%",e.style.height="200px";var t=document.createElement("div");t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.visibility="hidden",t.style.width="200px",t.style.height="150px",t.style.overflow="hidden",t.appendChild(e),document.body.appendChild(t);var a=e.offsetWidth;t.style.overflow="scroll";var n=e.offsetWidth;return a==n&&(n=t.clientWidth),document.body.removeChild(t),
a-n}function a(t){return e.templates.xml_format(t)}function n(t,a,n,i){a._is_ev_creating=!1;var r=t.querySelector(".dhx_timeline_label_col"),o=t.querySelector(".dhx_timeline_data_wrapper");a.scrollable||(o=e.$container.querySelector(".dhx_cal_data"));var l=e._els.dhx_cal_header[0];o.onscroll=function(o){var d=this.scrollTop,s=this.scrollLeft,_=e._timeline_smart_render.getViewPort(0,s,d);(s!==a._x_scroll||a._is_ev_creating)&&(a.second_scale?e._timeline_smart_render.updateHeader(a,_,l.children[1]):e._timeline_smart_render.updateHeader(a,_,l.children[0])),
l.style.left=-1-s+"px",(d!==a._y_scroll||a._is_ev_creating)&&e._timeline_smart_render.updateLabels(a,_,r),a.scrollable&&(r.style.top=-d+"px"),e._timeline_save_scroll_pos(a,d,s),a._is_ev_creating=!1,e._timeline_smart_render.updateGridCols(a,_),e._timeline_smart_render.updateGridRows(a,_),"cell"!=a.render&&e._timeline_smart_render.updateEvents(a,_),e._populate_timeline_rendered(t);var c=0;a._scales={};var u;u="cell"===a.render?this.querySelectorAll(".dhx_timeline_data_col .dhx_timeline_data_row"):this.querySelectorAll(".dhx_timeline_data_col .dhx_matrix_line");
for(var h=0,p=u.length;p>h;h++){var v=u[h].getAttribute("data-section-id"),m=a.order[v];n[m]=i[m].height,a._scales[v]=u[h]}for(var h=0,p=n.length;p>h;h++)c+=n[h];var g=e.$container.querySelector(".dhx_timeline_data_col");g.style.height=c+"px"},a.scroll_position?(a.scrollTo(a.scroll_position),a.scroll_position=null):e._timeline_set_scroll_pos(t,a),a._is_ev_creating=!0}function i(e,t){if(e.closest)return e.closest(t);if(e.matches||e.msMatchesSelector||e.webkitMatchesSelector){var a=e;if(!document.documentElement.contains(a))return null;
do{var n=a.matches||a.msMatchesSelector||a.webkitMatchesSelector;if(n.call(a,t))return a;a=a.parentElement||a.parentNode}while(null!==a&&1===a.nodeType);return null}return window.console.error("Your browser is not supported"),null}function r(t,a){var n=e.matrix[e._mode],i={},r={},o=a;for(i.x=t.touches?t.touches[0].pageX:t.pageX,i.y=t.touches?t.touches[0].pageY:t.pageY,r.left=o.offsetLeft+n.dx,r.top=o.offsetTop;o;)r.left+=o.offsetLeft,r.top+=o.offsetTop,o=o.offsetParent;return{x:i.x-r.left,y:i.y-r.top
}}function o(t){g&&clearInterval(g),e._schedulerOuter=e.$container.querySelector(".dhx_timeline_data_wrapper");var a={pageX:t.touches?t.touches[0].pageX:t.pageX,pageY:t.touches?t.touches[0].pageY:t.pageY};g=setInterval(function(){l(a)},m)}function l(t){if(!e.getState().drag_id)return clearInterval(g),void(f=null);var a=e.matrix[e._mode];if(a){var n=e._schedulerOuter,i=r(t,n),o=n.offsetWidth-a.dx,l=n.offsetHeight,_=i.x,c=i.y,u=a.autoscroll||{};e._merge(u,{range_x:200,range_y:100,speed_x:20,speed_y:10
});var h=d(_,o,f?f.x:0,u.range_x);a.scrollable||(h=0);var p=d(c,l,f?f.y:0,u.range_y);!p&&!h||f||(f={x:_,y:c},h=0,p=0),h*=u.speed_x,p*=u.speed_y,h&&p&&(Math.abs(h/5)>Math.abs(p)?p=0:Math.abs(p/5)>Math.abs(h)&&(h=0)),h||p?(f.started=!0,s(h,p)):clearInterval(g)}}function d(e,t,a,n){return n>e&&(!f||f.started||a>e)?-1:n>t-e&&(!f||f.started||e>a)?1:0}function s(t,a){var n=e._schedulerOuter;a&&(n.scrollTop+=a),t&&(n.scrollLeft+=t)}e.matrix={},e._merge=function(e,t){for(var a in t)"undefined"==typeof e[a]&&(e[a]=t[a]);
},e.createTimelineView=function(t){function a(t,a,n){for(var i=e.date[n.name+"_start"](new Date(t)),r=0,o=i,l=n.x_step,d=n.x_unit;a>o;)r++,o=e.date.add(o,l,d);return r}e._skin_init(),e._merge(t,{column_width:100,autoscroll:{range_x:200,range_y:100,speed_x:20,speed_y:10},_section_autowidth:!0,_x_scroll:0,_y_scroll:0,_h_cols:{},_label_rows:[],section_autoheight:!0,name:"matrix",x:"time",y:"time",x_step:1,x_unit:"hour",y_unit:"day",y_step:1,x_start:0,x_size:24,y_start:0,y_size:7,render:"cell",dx:200,
dy:50,event_dy:e.xy.bar_height-5,event_min_dy:e.xy.bar_height-5,resize_events:!0,fit_events:!0,show_unassigned:!1,second_scale:!1,round_position:!1,_logic:function(t,a,n){var i={};return e.checkEvent("onBeforeSectionRender")&&(i=e.callEvent("onBeforeSectionRender",[t,a,n])),i}}),t._original_x_start=t.x_start,"day"!=t.x_unit&&(t.first_hour=t.last_hour=0),t._start_correction=t.first_hour?60*t.first_hour*60*1e3:0,t._end_correction=t.last_hour?60*(24-t.last_hour)*60*1e3:0,e.checkEvent("onTimelineCreated")&&e.callEvent("onTimelineCreated",[t]);
var n=e.render_data;e.render_data=function(a,i){if(this._mode!=t.name)return n.apply(this,arguments);if(i&&!t.show_unassigned&&"cell"!=t.render)for(var r=0;r<a.length;r++)this.clear_event(a[r]),this.render_timeline_event.call(this.matrix[this._mode],a[r],!0);else e._renderMatrix.call(t,!0,!0)},e.matrix[t.name]=t,e.templates[t.name+"_cell_value"]=function(e){return e?e.length:""},e.templates[t.name+"_cell_class"]=function(e){return""},e.templates[t.name+"_scalex_class"]=function(e){return""},e.templates[t.name+"_second_scalex_class"]=function(e){
return""},e.templates[t.name+"_scaley_class"]=function(e,t,a){return""},e.templates[t.name+"_scale_label"]=function(e,t,a){return t},e.templates[t.name+"_tooltip"]=function(e,t,a){return a.text},e.templates[t.name+"_date"]=function(t,a){return t.getDay()==a.getDay()&&864e5>a-t||+t==+e.date.date_part(new Date(a))||+e.date.add(t,1,"day")==+a&&0===a.getHours()&&0===a.getMinutes()?e.templates.day_date(t):t.getDay()!=a.getDay()&&864e5>a-t?e.templates.day_date(t)+" &ndash; "+e.templates.day_date(a):e.templates.week_date(t,a);
},e.templates[t.name+"_scale_date"]=e.date.date_to_str(t.x_date||e.config.hour_date),e.templates[t.name+"_second_scale_date"]=e.date.date_to_str(t.second_scale&&t.second_scale.x_date?t.second_scale.x_date:e.config.hour_date),e.date["add_"+t.name+"_private"]=function(a,n){var i=n,r=t.x_unit;if("minute"==t.x_unit||"hour"==t.x_unit){var o=i;"hour"==t.x_unit&&(o*=60),o%1440||(i=o/1440,r="day")}return e.date.add(a,i,r)},e.date["add_"+t.name]=function(a,n,i){var r=e.date["add_"+t.name+"_private"](a,(t.x_length||t.x_size)*t.x_step*n);
if("minute"==t.x_unit||"hour"==t.x_unit){var o=t.x_length||t.x_size,l="hour"==t.x_unit?60*t.x_step:t.x_step;if(l*o%1440)if(+e.date.date_part(new Date(a))==+e.date.date_part(new Date(r)))t.x_start+=n*o;else{var d=1440/(o*l)-1,s=Math.round(d*o);n>0?t.x_start=t.x_start-s:t.x_start=s+t.x_start}}return r},e.date[t.name+"_start"]=function(a){var n=e.date[t.x_unit+"_start"]||e.date.day_start,i=n.call(e.date,a),r=i.getTimezoneOffset();i=e.date.add(i,t.x_step*t.x_start,t.x_unit);var o=i.getTimezoneOffset();
return r!=o&&i.setTime(i.getTime()+6e4*(o-r)),i},t.scrollTo=e.bind(function(t){if(this.scrollable&&t){var a;a=t.date?t.date:t.left?t.left:t;var n=-1;t.section?n=this.posFromSection(t.section):t.top&&(n=t.top);var i;i="number"==typeof a?a:this.posFromDate(a);var r=e.$container.querySelector(".dhx_timeline_data_wrapper");r.scrollLeft=i,n>0&&(r.scrollTop=n)}},t),t.posFromDate=e.bind(function(t){return e._timeline_getX({start_date:t},!1,this)-1},t),t.posFromSection=e.bind(function(e){var t=this.order[e];
if(void 0===t)return-1;var a=0;for(var n in this.order)this.order[n]<t&&(a+=this._section_height[n]);return a},t),t.setRange=e.bind(function(t,n){var i=e.date[this.name+"_start"](new Date(t)),r=a(t,n,this);this.x_size=r,e.setCurrentView(i,this.name)},t),e.callEvent("onOptionsLoad",[t]),e[t.name+"_view"]=function(a){a?e._set_timeline_dates(t):e._renderMatrix.apply(t,arguments)};var i=new Date;e.date.add(i,t.x_step,t.x_unit).valueOf()-i.valueOf();e["mouse_"+t.name]=function(a){var n=this._drag_event;
this._drag_id&&(n=this.getEvent(this._drag_id)),t.scrollable&&!a.converted?(a.converted=1,a.x-=t.dx-t._x_scroll,a.y+=t._y_scroll):a.x-=t.dx;var i=e._timeline_drag_date(t,a.x);if(a.x=0,a.force_redraw=!0,a.custom=!0,"move"==this._drag_mode&&this._drag_id&&this._drag_event){var n=this.getEvent(this._drag_id),r=this._drag_event;if(a._ignores=this._ignores_detected||t._start_correction||t._end_correction,void 0===r._move_delta&&(r._move_delta=(n.start_date-i)/6e4,this.config.preserve_length&&a._ignores&&(r._move_delta=this._get_real_event_length(n.start_date,i,t),
r._event_length=this._get_real_event_length(n.start_date,n.end_date,t))),this.config.preserve_length&&a._ignores){var o=(r._event_length,this._get_fictional_event_length(i,r._move_delta,t,!0));i=new Date(i-o)}else i=e.date.add(i,r._move_delta,"minute")}if("resize"==this._drag_mode&&n&&(this.config.timeline_swap_resize&&this._drag_id&&(this._drag_from_start&&+i>+n.end_date?this._drag_from_start=!1:!this._drag_from_start&&+i<+n.start_date&&(this._drag_from_start=!0)),a.resize_from_start=this._drag_from_start,
!this.config.timeline_swap_resize&&this._drag_id&&this._drag_from_start&&+i>=+e.date.add(n.end_date,-e.config.time_step,"minute")&&(i=e.date.add(n.end_date,-e.config.time_step,"minute"))),t.round_position)switch(this._drag_mode){case"move":this.config.preserve_length||(i=e._timeline_get_rounded_date.call(t,i,!1),"day"==t.x_unit&&(a.custom=!1));break;case"resize":this._drag_event&&((null===this._drag_event._resize_from_start||void 0===this._drag_event._resize_from_start)&&(this._drag_event._resize_from_start=a.resize_from_start),
a.resize_from_start=this._drag_event._resize_from_start,i=e._timeline_get_rounded_date.call(t,i,!this._drag_event._resize_from_start))}this._resolve_timeline_section(t,a),a.section&&this._update_timeline_section({pos:a,event:this.getEvent(this._drag_id),view:t}),a.y=Math.round((this._correct_shift(i,1)-this._min_date)/(6e4*this.config.time_step)),a.shift=this.config.time_step,t.round_position&&"new-size"==this._drag_mode&&i<=this._drag_start&&(a.shift=e.date.add(this._drag_start,t.x_step,t.x_unit)-this._drag_start);
var l=this._is_pos_changed(this._drag_pos,a);return this._drag_pos&&l&&(this._drag_event._dhx_changed=!0),l||this._drag_pos.has_moved||(a.force_redraw=!1),a}},e._prepare_timeline_events=function(t){var a=[];if("cell"==t.render)a=e._timeline_trace_events.call(t);else for(var n=e.get_visible_events(),i=t.order,r=0;r<n.length;r++){var o=n[r],l=o[t.y_property],d=t.order[l];if(t.show_unassigned&&!l){for(var s in i)if(i.hasOwnProperty(s)){d=i[s],a[d]||(a[d]=[]);var _=e._lame_copy({},o);_[t.y_property]=s,
a[d].push(_)}}else a[d]||(a[d]=[]),a[d].push(o)}return a},e._populate_timeline_rendered=function(t){e._rendered=[];for(var a=t.querySelectorAll("div[event_id]"),n=0;n<a.length;n++)e._rendered.push(a[n])},e._get_timeline_event_height=function(e,t){var a=e[t.y_property],n=t.event_dy;return"full"==t.event_dy&&(n=t.section_autoheight?t._section_height[a]-6:t.dy-3),t.resize_events&&(n=Math.max(Math.floor(n/e._count),t.event_min_dy)),n},e._get_timeline_event_y=function(t,a){var n=t,i=2+n*a+(n?2*n:0);return e.config.cascade_event_display&&(i=2+n*e.config.cascade_event_margin+(n?2*n:0)),
i},e.render_timeline_event=function(t,a){var n=t[this.y_property];if(!n)return"";var i=t._sorder,r=e._timeline_getX(t,!1,this),o=e._timeline_getX(t,!0,this),l=e._get_timeline_event_height(t,this),d=l-2;t._inner||"full"!=this.event_dy||(d=(d+2)*(t._count-i)-2),d+=3;var s=e._get_timeline_event_y(t._sorder,l),_=l+s+2;(!this._events_height[n]||this._events_height[n]<_)&&(this._events_height[n]=_);var c=e.templates.event_class(t.start_date,t.end_date,t);c="dhx_cal_event_line "+(c||""),e.getState().select_id==t.id&&(c+=" dhx_cal_event_selected"),
t._no_drag_move&&(c+=" no_drag_move");var u=t.color?"background:"+t.color+";":"",h=t.textColor?"color:"+t.textColor+";":"",p=e.templates.event_bar_text(t.start_date,t.end_date,t),v="<div "+e._waiAria.eventBarAttrString(t)+" event_id='"+t.id+"' class='"+c+"' style='"+u+h+"position:absolute; top:"+s+"px; height: "+d+"px; left:"+r+"px; width:"+Math.max(0,o-r)+"px;"+(t._text_style||"")+"'>";if(e.config.drag_resize&&!e.config.readonly){var m="dhx_event_resize",g=d+1,f="<div class='"+m+" "+m+"_start' style='height: "+g+"px;'></div>",b="<div class='"+m+" "+m+"_end' style='height: "+g+"px;'></div>";
v+=(t._no_resize_start?"":f)+(t._no_resize_end?"":b)}if(v+=p+"</div>",!a)return v;var y=document.createElement("div");y.innerHTML=v;var x=this._scales[n];x&&(x=x.querySelector(".dhx_timeline_data_row"),e._rendered.push(y.firstChild),x.appendChild(y.firstChild))},e._timeline_trace_events=function(){for(var t=e.get_visible_events(),a=[],n=0;n<this.y_unit.length;n++)a[n]=[];var i;a[i]||(a[i]=[]);for(var n=0;n<t.length;n++){i=this.order[t[n][this.y_property]];for(var r=0;this._trace_x[r+1]&&t[n].start_date>=this._trace_x[r+1];)r++;
for(;this._trace_x[r]&&t[n].end_date>this._trace_x[r];)a[i][r]||(a[i][r]=[]),a[i][r].push(t[n]),r++}return a},e._timeline_getX=function(t,a,n){var i=0,r=n._step,o=n.round_position,l=0,d=a?t.end_date:t.start_date;d.valueOf()>e._max_date.valueOf()&&(d=e._max_date);var s=d-e._min_date_timeline;if(s>0){var _=e._get_date_index(n,d);e._ignores[_]&&(o=!0);for(var c=0;_>c;c++)i+=e._cols[c];var u=e._timeline_get_rounded_date.apply(n,[d,!1]);o?+d>+u&&a&&(l=e._cols[_]):(s=d-u,n.first_hour||n.last_hour?(s-=n._start_correction,
0>s&&(s=0),l=Math.round(s/r),l>e._cols[_]&&(l=e._cols[_])):l=Math.round(s/r))}e._border_box_bvents();return i+=a?0===s||o?l-2:l:l+1},e._timeline_get_rounded_date=function(t,a){var n=e._get_date_index(this,t),i=this._trace_x[n];return a&&+t!=+this._trace_x[n]&&(i=this._trace_x[n+1]?this._trace_x[n+1]:e.date.add(this._trace_x[n],this.x_step,this.x_unit)),new Date(i)},e._timeline_skip_ignored=function(t){if(e._ignores_detected)for(var a,n,i,r,o=0;o<t.length;o++){for(r=t[o],i=!1,a=e._get_date_index(this,r.start_date),
n=e._get_date_index(this,r.end_date);n>a;){if(!e._ignores[a]){i=!0;break}a++}i||a!=n||e._ignores[n]||+r.end_date>+this._trace_x[n]&&(i=!0),i||(t.splice(o,1),o--)}},e._timeline_calculate_event_positions=function(t){if(t&&"cell"!=this.render){e._timeline_skip_ignored.call(this,t),t.sort(this.sort||function(e,t){return e.start_date.valueOf()==t.start_date.valueOf()?e.id>t.id?1:-1:e.start_date>t.start_date?1:-1});for(var a=[],n=t.length,i=-1,r=null,o=0;n>o;o++){var l=t[o];l._inner=!1;var d=this.round_position?e._timeline_get_rounded_date.apply(this,[l.start_date,!1]):l.start_date;
for(this.round_position?e._timeline_get_rounded_date.apply(this,[l.end_date,!0]):l.end_date;a.length;){var s=a[a.length-1];if(!(s.end_date.valueOf()<=d.valueOf()))break;a.splice(a.length-1,1)}for(var _=!1,c=0;c<a.length;c++){var u=a[c];if(u.end_date.valueOf()<=d.valueOf()){_=!0,l._sorder=u._sorder,a.splice(c,1),l._inner=!0;break}}if(a.length&&(a[a.length-1]._inner=!0),!_)if(a.length)if(a.length<=a[a.length-1]._sorder){if(a[a.length-1]._sorder)for(var h=0;h<a.length;h++){for(var p=!1,v=0;v<a.length;v++)if(a[v]._sorder==h){
p=!0;break}if(!p){l._sorder=h;break}}else l._sorder=0;l._inner=!0}else{for(var m=a[0]._sorder,g=1;g<a.length;g++)a[g]._sorder>m&&(m=a[g]._sorder);l._sorder=m+1,i<l._sorder&&(i=l._sorder,r=l),l._inner=!1}else l._sorder=0;a.push(l),a.length>(a.max_count||0)?(a.max_count=a.length,l._count=a.length):l._count=l._count?l._count:1}for(var f=0;f<t.length;f++)t[f]._count=a.max_count;(r||t[0])&&e.render_timeline_event.call(this,r||t[0],!1)}},e._timeline_get_events_html=function(t){var a="";if(t&&"cell"!=this.render)for(var n=0;n<t.length;n++)a+=e.render_timeline_event.call(this,t[n],!1);
return a},e._timeline_update_events_html=function(t){var a="";if(t&&"cell"!=this.render)for(var n=0;n<t.length;n++)a+=e.render_timeline_event.call(this,t[n],!1);return a},e._timeline_get_block_stats=function(e,a){var n={};return a._sch_height=e.offsetHeight,n.style_data_wrapper="padding-left:"+a.dx+"px;",n.style_label_wrapper="width: "+a.dx+"px;",a.scrollable?(n.style_data_wrapper+="height:"+(a._sch_height-1)+"px;",void 0===a.html_scroll_width&&(a.html_scroll_width=t()),a._section_autowidth?a.custom_scroll_width=0:a.custom_scroll_width=a.html_scroll_width,
n.style_label_wrapper+="height:"+(a._sch_height-1-a.custom_scroll_width)+"px;"):(n.style_data_wrapper+="height:"+(a._sch_height-1)+"px;",n.style_label_wrapper+="height:"+(a._sch_height-1)+"px;overflow:visible;"),n},e._timeline_get_cur_row_stats=function(t,a){var n=t._logic(t.render,t.y_unit[a],t);if(e._merge(n,{height:t.dy}),t.section_autoheight){var i=t.scrollable?t._sch_height-e.xy.scroll_width:t._sch_height;t.y_unit.length*n.height<i&&(n.height=Math.max(n.height,Math.floor((i-1)/t.y_unit.length))),
t._section_height[t.y_unit[a].key]=n.height}return n.td_className||(n.td_className="dhx_matrix_scell"+(e.templates[t.name+"_scaley_class"](t.y_unit[a].key,t.y_unit[a].label,t.y_unit[a])?" "+e.templates[t.name+"_scaley_class"](t.y_unit[a].key,t.y_unit[a].label,t.y_unit[a]):"")),n.td_content||(n.td_content=e.templates[t.name+"_scale_label"](t.y_unit[a].key,t.y_unit[a].label,t.y_unit[a])),e._merge(n,{tr_className:"",style_height:"height:"+n.height+"px;",style_width:"width:"+t.dx+"px;",summ_width:"width:"+t._summ+"px;",
table_className:""}),n},e._timeline_get_fit_events_stats=function(e,t,a){if(e.fit_events){var n=e._events_height[e.y_unit[t].key]||0;a.height=n>a.height?n:a.height,a.style_height="height:"+a.height+"px;",a.style_line_height="line-height:"+(a.height-1)+"px;",e._section_height[e.y_unit[t].key]=a.height}return a},e._timeline_set_scroll_pos=function(e,t){var a=e.querySelector(".dhx_timeline_data_wrapper");a.scrollTop=t._y_scroll||0,a.scrollLeft=t._x_scroll||0},e._timeline_save_scroll_pos=function(e,t,a){
e._y_scroll=t||0,e._x_scroll=a||0},e._timeline_get_html_for_cell_data_row=function(e,t,a,n){return"<div class='dhx_timeline_data_row' data-section-id='"+n+"' data-section-index='"+e+"' style='"+t.summ_width+t.style_height+" position:absolute; top:"+a+"px;'>"},e._timeline_get_html_for_cell_ignores=function(e){return'<div style="'+e.style_height+e.style_line_height+'"></div>'},e._timeline_get_html_for_cell=function(t,n,i,r,o,l){var d=i._trace_x[t],s=i.y_unit[n],_=e._cols[t],c=a(d);return"<div data-col-id='"+t+"' data-col-date='"+c+"' class='dhx_matrix_cell dhx_timeline_data_cell "+e.templates[i.name+"_cell_class"](r,d,s)+"' style='width:"+_+"px;"+o.style_height+o.style_line_height+"  left:"+l+"px;'><div style='width:auto'>"+e.templates[i.name+"_cell_value"](r,d,s)+"</div></div>";
},e._timeline_get_html_for_bar_matrix_line=function(e,t,a,n){return"<div style='"+t.summ_width+" "+t.style_height+" position:absolute; top:"+a+"px;' data-section-id='"+n+"' data-section-index='"+e+"' class='dhx_matrix_line'>"},e._timeline_get_html_for_bar_data_row=function(e){return"<div class='dhx_timeline_data_row "+e.table_className+"' style='"+e.summ_width+" "+e.style_height+"' >"},e._timeline_get_html_for_bar_ignores=function(){return""},e._timeline_get_html_for_bar=function(t,n,i,r,o){var l=a(i._trace_x[t]);
return"<div class='dhx_matrix_cell dhx_timeline_data_cell "+e.templates[i.name+"_cell_class"](r,i._trace_x[t],i.y_unit[n])+"' style='width:"+e._cols[t]+"px; left:"+o+"px;'  data-col-id='"+t+"' data-col-date='"+l+"' ></div>"},e._timeline_render_scale_header=function(t,a){var n=e.$container.querySelector(".dhx_timeline_scale_header");if(n&&n.parentNode.removeChild(n),a){n=document.createElement("div");var i="dhx_timeline_scale_header";t.second_scale&&(i+=" dhx_timeline_second_scale");var r=e.xy.scale_height;
n.className=i,n.style.cssText=["width:"+(t.dx-1)+"px","height:"+r+"px","line-height:"+r+"px","top:"+(e.xy.nav_height+2)+"px","left:0"].join(";"),n.innerHTML=e.locale.labels[t.name+"_scale_header"]||"",e.$container.appendChild(n)}},e._timeline_y_scale=function(t){var a=e._timeline_get_block_stats(t,this),i=this.scrollable?" dhx_timeline_scrollable_data":"",r="<div class='dhx_timeline_table_wrapper'>",o="<div class='dhx_timeline_label_wrapper' style='"+a.style_label_wrapper+"'><div class='dhx_timeline_label_col'>",l="<div class='dhx_timeline_data_wrapper"+i+"' style='"+a.style_data_wrapper+"'><div class='dhx_timeline_data_col'>";
e._load_mode&&e._load();var d=e._prepare_timeline_events(this);e._timeline_smart_render.cachePreparedEvents(d);for(var s=0,_=0;_<e._cols.length;_++)s+=e._cols[_];var c=new Date,u=e._cols.length-e._ignores_detected;c=(e.date.add(c,this.x_step*u,this.x_unit)-c-(this._start_correction+this._end_correction)*u)/s,this._step=c,this._summ=s;var h=e._colsS.heights=[],p=[];this._events_height={},this._section_height={},this._label_rows=[];var v=!1,m=0,g=null;(this.scrollable||this.smart_rendering)&&(g=e._timeline_smart_render.getViewPort(this._sch_height)),
e._timeline_smart_render._rendered_labels_cache=[],e._timeline_smart_render._rendered_events_cache=[];var f,b=!!g;f=this.scrollable?this.smart_rendering===!1?!1:!!b:!!this.smart_rendering&&b;for(var y=[],x=0,k=0;k<this.y_unit.length;k++){var w=e._timeline_get_cur_row_stats(this,k);y.push(w),x+=w.height}g&&x<g.bottom&&(g.top=Math.max(0,x-g.height),g.bottom=g.top+g.height);for(var k=0;k<this.y_unit.length;k++){var w=y[k],D=this.y_unit[k];e._timeline_calculate_event_positions.call(this,d[k]),w=e._timeline_get_fit_events_stats(this,k,w);
var E="<div class='dhx_timeline_label_row "+w.tr_className+"' style='top:"+m+"px;"+w.style_height+w.style_line_height+"'data-row-index='"+k+"' data-row-id='"+D.key+"'><div class='"+w.td_className+"' style='"+w.style_width+" height:"+w.height+"px;' "+e._waiAria.label(w.td_content)+">"+w.td_content+"</div></div>";if(f&&this._label_rows.push({div:E,top:m,section:D}),f&&(e._timeline_smart_render.isInYViewPort({top:m,bottom:m+w.height},g)||(v=!0)),m+=w.height,v)v=!1;else{o+=E,f&&e._timeline_smart_render._rendered_labels_cache.push(k);
var S=0;if("cell"==this.render){l+=e._timeline_get_html_for_cell_data_row(k,w,m-w.height,D.key);for(var N=0;N<e._cols.length;N++)e._ignores[N]&&!f?l+=e._timeline_get_html_for_cell_ignores(w):f&&b?e._timeline_smart_render.isInXViewPort({left:S,right:S+e._cols[N]},g)&&(l+=e._timeline_get_html_for_cell(N,k,this,d[k][N],w,S)):l+=e._timeline_get_html_for_cell(N,k,this,d[k][N],w,S),S+=e._cols[N];l+="</div>"}else{l+=e._timeline_get_html_for_bar_matrix_line(k,w,m-w.height,D.key);var M=d[k];f&&b&&(M=e._timeline_smart_render.getVisibleEventsForRow(this,g,d,k));
var A=e._timeline_get_events_html.call(this,M);l+=A,l+=e._timeline_get_html_for_bar_data_row(w);for(var N=0;N<e._cols.length;N++)e._ignores[N]?l+=e._timeline_get_html_for_bar_ignores():f&&b?e._timeline_smart_render.isInXViewPort({left:S,right:S+e._cols[N]},g)&&(l+=e._timeline_get_html_for_bar(N,k,this,d[k],S)):l+=e._timeline_get_html_for_bar(N,k,this,d[k],S),S+=e._cols[N];l+="</div></div>"}}w.sectionKey=D.key,p.push(w)}if(r+=o+"</div></div>",r+=l+"</div></div>",r+="</div>",this._matrix=d,t.innerHTML=r,
f){var C=e.$container.querySelector(".dhx_timeline_data_col");C.style.height=m+"px"}e._populate_timeline_rendered(t),this._scales={};for(var _=0,O=p.length;O>_;_++){h.push(p[_].height);var T=p[_].sectionKey;e._timeline_finalize_section_add(this,T,t)}f&&n(t,this,h,p)},e._timeline_finalize_section_add=function(t,a,n){var i=t._scales[a]=n.querySelector(".dhx_timeline_data_col [data-section-id='"+a+"']");i&&e.callEvent("onScaleAdd",[i,a])},e.attachEvent("onBeforeViewChange",function(t,a,n,i){if(e.matrix[n]){
var r=e.matrix[n];if(r.scrollable){if("tree"==r.render&&t===n&&a===i)return!0;r._x_scroll=r._y_scroll=0,e.$container.querySelector(".dhx_timeline_scrollable_data")&&e._timeline_set_scroll_pos(e._els.dhx_cal_data[0],r)}}return!0}),e._timeline_x_dates=function(t){var a=e._min_date,n=e._max_date;e._process_ignores(a,this.x_size,this.x_unit,this.x_step,t);for(var i=(this.x_size+(t?e._ignores_detected:0),0),r=0;+n>+a;)if(this._trace_x[r]=new Date(a),"month"==this.x_unit&&e.date[this.x_unit+"_start"]&&(a=e.date[this.x_unit+"_start"](new Date(a))),
a=e.date.add(a,this.x_step,this.x_unit),e.date[this.x_unit+"_start"]&&(a=e.date[this.x_unit+"_start"](a)),e._ignores[r]||i++,r++,t)if(i<this.x_size&&!(+n>+a))n=e.date["add_"+this.name+"_private"](n,(this.x_length||this.x_size)*this.x_step);else if(i>=this.x_size){e._max_date=a;break}return{total:r,displayed:i}},e._timeline_x_scale=function(t){var n=e.xy.scale_height,i=this._header_resized||e.xy.scale_height;e._cols=[],e._colsS={height:0},this._trace_x=[];var r=e._x-this.dx-e.xy.scroll_width;if(this.scrollable&&this.column_width>0){
var o=this.column_width*this.x_size;o>r&&(r=o,this._section_autowidth=!1)}var l=[this.dx],d=e._els.dhx_cal_header[0];d.style.width=l[0]+r+"px";for(var s=e._min_date_timeline=e._min_date,_=e.config.preserve_scale_length,c=e._timeline_x_dates.call(this,_),u=c.displayed,h=c.total,p=0;h>p;p++)e._ignores[p]?(e._cols[p]=0,u++):e._cols[p]=Math.floor(r/(u-p)),r-=e._cols[p],l[p+1]=l[p]+e._cols[p];if(t.innerHTML="<div></div>",this.second_scale){for(var v=this.second_scale.x_unit,m=[this._trace_x[0]],g=[],f=[this.dx,this.dx],b=0,y=0;y<this._trace_x.length;y++){
var x=this._trace_x[y],k=e._timeline_is_new_interval(v,x,m[b]);k&&(++b,m[b]=x,f[b+1]=f[b]);var w=b+1;g[b]=e._cols[y]+(g[b]||0),f[w]+=e._cols[y]}t.innerHTML="<div></div><div></div>";var D=t.firstChild;D.style.height=i+"px";var E=t.lastChild;E.style.position="relative",E.className="dhx_bottom_scale_container";for(var S=0;S<m.length;S++){var N=m[S],M=e.templates[this.name+"_second_scalex_class"](N),A=document.createElement("div");A.className="dhx_scale_bar dhx_second_scale_bar"+(M?" "+M:""),e.set_xy(A,g[S]-1,i-3,f[S],0),
A.innerHTML=e.templates[this.name+"_second_scale_date"](N),D.appendChild(A)}}e.xy.scale_height=i,t=t.lastChild,this._h_cols={};for(var C=0;C<this._trace_x.length;C++)if(!e._ignores[C]){s=this._trace_x[C],e._render_x_header(C,l[C],s,t);var O=e.templates[this.name+"_scalex_class"](s);O&&(t.lastChild.className+=" "+O),t.lastChild.setAttribute("data-col-id",C),t.lastChild.setAttribute("data-col-date",a(s));var T=t.lastChild.cloneNode(!0);this._h_cols[C]={div:T,left:l[C]}}e.xy.scale_height=n;var L=this._trace_x;
t.onclick=function(t){var a=e._timeline_locate_hcell(t);a&&e.callEvent("onXScaleClick",[a.x,L[a.x],t||event])},t.ondblclick=function(t){var a=e._timeline_locate_hcell(t);a&&e.callEvent("onXScaleDblClick",[a.x,L[a.x],t||event])}},e._timeline_is_new_interval=function(t,a,n){switch(t){case"hour":return a.getHours()!=n.getHours()||e._timeline_is_new_interval("day",a,n);case"day":return!(a.getDate()==n.getDate()&&a.getMonth()==n.getMonth()&&a.getFullYear()==n.getFullYear());case"week":return!(e.date.week_start(new Date(a)).valueOf()==e.date.week_start(new Date(n)).valueOf());
case"month":return!(a.getMonth()==n.getMonth()&&a.getFullYear()==n.getFullYear());case"year":return!(a.getFullYear()==n.getFullYear());default:return!1}},e._timeline_reset_scale_height=function(t){if(this._header_resized&&(!t||!this.second_scale)){e.xy.scale_height/=2,this._header_resized=!1;var a=e._els.dhx_cal_header[0];a.className=a.className.replace(/ dhx_second_cal_header/gi,"")}},e._timeline_set_full_view=function(t){if(e._timeline_reset_scale_height.call(this,t),t){this.second_scale&&!this._header_resized&&(this._header_resized=e.xy.scale_height,
e.xy.scale_height*=2,e._els.dhx_cal_header[0].className+=" dhx_second_cal_header"),e.set_sizes(),e._init_matrix_tooltip();var a=e._min_date;if(e._timeline_x_scale.call(this,e._els.dhx_cal_header[0]),e.$container.querySelector(".dhx_timeline_scrollable_data")){var n=e._timeline_smart_render.getViewPort(),i=e._timeline_smart_render.getVisibleHeader(this,n);i&&(this.second_scale?e._els.dhx_cal_header[0].children[1].innerHTML=i:e._els.dhx_cal_header[0].children[0].innerHTML=i)}e._timeline_y_scale.call(this,e._els.dhx_cal_data[0]),
e._min_date=a,e._els.dhx_cal_date[0].innerHTML=e.templates[this.name+"_date"](e._min_date,e._max_date),e._mark_now&&e._mark_now(),e._timeline_reset_scale_height.call(this,t)}e._timeline_render_scale_header(this,t),e._timeline_hideToolTip()},e._timeline_hideToolTip=function(){e._tooltip&&(e._tooltip.style.display="none",e._tooltip.date="")},e._timeline_showToolTip=function(t,a,n){if("cell"==t.render){var i=a.x+"_"+a.y,r=t._matrix[a.y][a.x];if(!r)return e._timeline_hideToolTip();if(r.sort(function(e,t){
return e.start_date>t.start_date?1:-1}),e._tooltip){if(e._tooltip.date==i)return;e._tooltip.innerHTML=""}else{var o=e._tooltip=document.createElement("div");o.className="dhx_year_tooltip",document.body.appendChild(o),o.onclick=e._click.dhx_cal_data}for(var l="",d=0;d<r.length;d++){var s=r[d].color?"background-color:"+r[d].color+";":"",_=r[d].textColor?"color:"+r[d].textColor+";":"";l+="<div class='dhx_tooltip_line' event_id='"+r[d].id+"' style='"+s+_+"'>",l+="<div class='dhx_tooltip_date'>"+(r[d]._timed?e.templates.event_date(r[d].start_date):"")+"</div>",
l+="<div class='dhx_event_icon icon_details'>&nbsp;</div>",l+=e.templates[t.name+"_tooltip"](r[d].start_date,r[d].end_date,r[d])+"</div>"}e._tooltip.style.display="",e._tooltip.style.top="0px",document.body.offsetWidth-n.left-e._tooltip.offsetWidth<0?e._tooltip.style.left=n.left-e._tooltip.offsetWidth+"px":e._tooltip.style.left=n.left+a.src.offsetWidth+"px",e._tooltip.date=i,e._tooltip.innerHTML=l,document.body.offsetHeight-n.top-e._tooltip.offsetHeight<0?e._tooltip.style.top=n.top-e._tooltip.offsetHeight+a.src.offsetHeight+"px":e._tooltip.style.top=n.top+"px";
}},e._matrix_tooltip_handler=function(t){var a=e.matrix[e._mode];if(a&&"cell"==a.render){if(a){var n=e._locate_cell_timeline(t),t=t||event;t.target||t.srcElement;if(n)return e._timeline_showToolTip(a,n,e.$domHelpers.getOffset(n.src))}e._timeline_hideToolTip()}},e._init_matrix_tooltip=function(){e._detachDomEvent(e._els.dhx_cal_data[0],"mouseover",e._matrix_tooltip_handler),dhtmlxEvent(e._els.dhx_cal_data[0],"mouseover",e._matrix_tooltip_handler)},e._set_timeline_dates=function(t){e._min_date=e.date[t.name+"_start"](new Date(e._date)),
e._max_date=e.date["add_"+t.name+"_private"](e._min_date,t.x_size*t.x_step),e.date[t.x_unit+"_start"]&&(e._max_date=e.date[t.x_unit+"_start"](e._max_date)),e._table_view=!0},e._renderMatrix=function(t,a){a||(e._els.dhx_cal_data[0].scrollTop=0),e._set_timeline_dates(this),e._timeline_set_full_view.call(this,t)},e._timeline_html_index=function(t){for(var a=t.parentNode.childNodes,n=-1,i=0;i<a.length;i++)if(a[i]==t){n=i;break}var r=n;if(e._ignores_detected)for(var o in e._ignores)e._ignores[o]&&r>=1*o&&r++;
return r},e._timeline_locate_hcell=function(t){t=t||event;for(var a=t.target?t.target:t.srcElement;a&&"DIV"!=a.tagName;)a=a.parentNode;if(a&&"DIV"==a.tagName){var n=e._getClassName(a).split(" ")[0];if("dhx_scale_bar"==n)return{x:e._timeline_html_index(a),y:-1,src:a,scale:!0}}},e._locate_cell_timeline=function(t){t=t||event;for(var a=t.target?t.target:t.srcElement,n={},r=e.matrix[e._mode],o=e.getActionData(t),l=e._ignores,d=0,s=0;s<r._trace_x.length-1&&!(+o.date<r._trace_x[s+1]);s++)l[s]||d++;n.x=0===d?0:s,
n.y=r.order[o.section];var _=(e._isRender("cell")?1:0,0);if(r.scrollable&&"cell"===r.render){if(!r._scales[o.section]||!r._scales[o.section].querySelector(".dhx_matrix_cell"))return;var c=r._scales[o.section].querySelector(".dhx_matrix_cell");if(!c)return;var u=c.offsetLeft;if(u>0){for(var h=e._timeline_drag_date(r,u),p=0;p<r._trace_x.length-1&&!(+h<r._trace_x[p+1]);p++);_=p}}n.src=r._scales[o.section]?r._scales[o.section].querySelectorAll(".dhx_matrix_cell")[s-_]:null;var v=!1,m=i(a,".dhx_matrix_scell");
return m&&(a=m,v=!0),v?(n.x=-1,n.src=a,n.scale=!0):n.x=s,n};var _=e._click.dhx_cal_data;e._click.dhx_marked_timespan=e._click.dhx_cal_data=function(t){var a=_.apply(this,arguments),n=e.matrix[e._mode];if(n){var i=e._locate_cell_timeline(t);i&&(i.scale?e.callEvent("onYScaleClick",[i.y,n.y_unit[i.y],t||event]):(e.callEvent("onCellClick",[i.x,i.y,n._trace_x[i.x],(n._matrix[i.y]||{})[i.x]||[],t||event]),e._timeline_set_scroll_pos(e._els.dhx_cal_data[0],n)))}return a},e.dblclick_dhx_matrix_cell=function(t){
var a=e.matrix[e._mode];if(a){var n=e._locate_cell_timeline(t);n&&(n.scale?e.callEvent("onYScaleDblClick",[n.y,a.y_unit[n.y],t||event]):e.callEvent("onCellDblClick",[n.x,n.y,a._trace_x[n.x],(a._matrix[n.y]||{})[n.x]||[],t||event]))}};var c=e.dblclick_dhx_marked_timespan||function(){};e.dblclick_dhx_marked_timespan=function(t){var a=e.matrix[e._mode];return a?e.dblclick_dhx_matrix_cell(t):c.apply(this,arguments)},e.dblclick_dhx_matrix_scell=function(t){return e.dblclick_dhx_matrix_cell(t)},e._isRender=function(t){
return e.matrix[e._mode]&&e.matrix[e._mode].render==t},e.attachEvent("onCellDblClick",function(t,a,n,i,r){if(!this.config.readonly&&("dblclick"!=r.type||this.config.dblclick_create)){var o=e.matrix[e._mode],l={};l.start_date=o._trace_x[t],l.end_date=o._trace_x[t+1]?o._trace_x[t+1]:e.date.add(o._trace_x[t],o.x_step,o.x_unit),o._start_correction&&(l.start_date=new Date(1*l.start_date+o._start_correction)),o._end_correction&&(l.end_date=new Date(l.end_date-o._end_correction)),l[o.y_property]=o.y_unit[a].key,
e.addEventNow(l,null,r)}}),e.attachEvent("onBeforeDrag",function(t,a,n){return!e._isRender("cell")}),e.attachEvent("onEventChanged",function(e,t){t._timed=this.isOneDayEvent(t)}),e.attachEvent("onBeforeEventChanged",function(e,t,a,n){return e&&(e._move_delta=void 0),n&&(n._move_delta=void 0),!0}),e._is_column_visible=function(t){var a=e.matrix[e._mode],n=e._get_date_index(a,t);return!e._ignores[n]};var u=e._render_marked_timespan;e._render_marked_timespan=function(t,a,n,i,r){if(!e.config.display_marked_timespans)return[];
if(e.matrix&&e.matrix[e._mode]){if(e._isRender("cell"))return;var o=e._lame_copy({},e.matrix[e._mode]);o.round_position=!1;var l=[],d=[],s=[],_=t.sections?t.sections.units||t.sections.timeline:null;if(n)s=[a],d=[n];else{var c=o.order;if(_)c.hasOwnProperty(_)&&(d.push(_),s.push(o._scales[_]));else if(o._scales)for(var h in c)c.hasOwnProperty(h)&&o._scales[h]&&(d.push(h),s.push(o._scales[h]))}var i=i?new Date(i):e._min_date,r=r?new Date(r):e._max_date;if(i.valueOf()<e._min_date.valueOf()&&(i=new Date(e._min_date)),
r.valueOf()>e._max_date.valueOf()&&(r=new Date(e._max_date)),!o._trace_x)return;for(var p=0;p<o._trace_x.length&&!e._is_column_visible(o._trace_x[p]);p++);if(p==o._trace_x.length)return;var v=[];if(t.days>6){var m=new Date(t.days);e.date.date_part(new Date(i))<=+m&&+r>=+m&&v.push(m)}else v.push.apply(v,e._get_dates_by_index(t.days));for(var g=t.zones,f=e._get_css_classes_by_config(t),b=0;b<d.length;b++){a=s[b],n=d[b];for(var p=0;p<v.length;p++)for(var y=v[p],x=0;x<g.length;x+=2){var k=g[x],w=g[x+1],D=new Date(+y+60*k*1e3),E=new Date(+y+60*w*1e3);
if(D=new Date(D.valueOf()+1e3*(D.getTimezoneOffset()-y.getTimezoneOffset())*60),E=new Date(E.valueOf()+1e3*(E.getTimezoneOffset()-y.getTimezoneOffset())*60),E>i&&r>D){var S=e._get_block_by_config(t);S.className=f;var N=e._timeline_getX({start_date:D},!1,o)-1,M=e._timeline_getX({start_date:E},!1,o)-1,A=Math.max(1,M-N-1),C=o._section_height[n]-1||o.dy-1;S.style.cssText="height: "+C+"px; left: "+N+"px; width: "+A+"px; top: 0;",a.insertBefore(S,a.firstChild),l.push(S)}}}return l}return u.apply(e,[t,a,n]);
};var h=e._append_mark_now;e._append_mark_now=function(t,a){if(e.matrix&&e.matrix[e._mode]){var n=e._currentDate(),i=e._get_zone_minutes(n),r={days:+e.date.date_part(n),zones:[i,i+1],css:"dhx_matrix_now_time",type:"dhx_now_time"};return e._render_marked_timespan(r)}return h.apply(e,[t,a])};var p=e._mark_timespans;e._mark_timespans=function(){if(e.matrix&&e.matrix[e.getState().mode]){for(var t=[],a=e.matrix[e.getState().mode],n=a.y_unit,i=0;i<n.length;i++){var r=n[i].key,o=a._scales[r],l=e._on_scale_add_marker(o,r);
t.push.apply(t,l)}return t}return p.apply(this,arguments)};var v=e._on_scale_add_marker;e._on_scale_add_marker=function(t,a){if(e.matrix&&e.matrix[e._mode]){var n=[],i=e._marked_timespans;if(i&&e.matrix&&e.matrix[e._mode])for(var r=e._mode,o=e._min_date,l=e._max_date,d=i.global,s=e.date.date_part(new Date(o));l>s;s=e.date.add(s,1,"day")){var _=+s,c=s.getDay(),u=[],h=d[_]||d[c];if(u.push.apply(u,e._get_configs_to_render(h)),i[r]&&i[r][a]){var p=[],m=e._get_types_to_render(i[r][a][c],i[r][a][_]);p.push.apply(p,e._get_configs_to_render(m)),
p.length&&(u=p)}for(var g=0;g<u.length;g++){var f=u[g],b=f.days;7>b?(b=_,n.push.apply(n,e._render_marked_timespan(f,t,a,s,e.date.add(s,1,"day"))),b=c):n.push.apply(n,e._render_marked_timespan(f,t,a,s,e.date.add(s,1,"day")))}}return n}return v.apply(this,arguments)},e._resolve_timeline_section=function(e,t){var a=0,n=0;for(a;a<this._colsS.heights.length&&(n+=this._colsS.heights[a],!(n>t.y));a++);e.y_unit[a]||(a=e.y_unit.length-1),this._drag_event&&!this._drag_event._orig_section&&(this._drag_event._orig_section=e.y_unit[a].key),
t.fields={},a>=0&&e.y_unit[a]&&(t.section=t.fields[e.y_property]=e.y_unit[a].key)},e._update_timeline_section=function(e){var t=e.view,a=e.event,n=e.pos;if(a){if(a[t.y_property]!=n.section){var i=this._get_timeline_event_height(a,t);a._sorder=this._get_dnd_order(a._sorder,i,t._section_height[n.section])}a[t.y_property]=n.section}},e._get_date_index=function(e,t){for(var a=0,n=e._trace_x;a<n.length-1&&+t>=+n[a+1];)a++;return a},e._timeline_drag_date=function(t,a){var n=t,i={x:a};if(!n._trace_x.length)return new Date(e.getState().date);
var r,o,l=0,d=0;for(d;d<=this._cols.length-1;d++)if(o=this._cols[d],l+=o,l>i.x){r=(i.x-(l-o))/o,r=0>r?0:r;break}if(n.round_position){var s=1,_=e.getState().drag_mode;_&&"move"!=_&&"create"!=_&&(s=.5),r>=s&&d++,r=0}if(0===d&&this._ignores[0])for(d=1,r=0;this._ignores[d];)d++;else if(d==this._cols.length&&this._ignores[d-1]){for(d=this._cols.length-1,r=0;this._ignores[d];)d--;d++}var c;if(d>=n._trace_x.length)c=e.date.add(n._trace_x[n._trace_x.length-1],n.x_step,n.x_unit),n._end_correction&&(c=new Date(c-n._end_correction));else{
var u=r*o*n._step+n._start_correction;c=new Date(+n._trace_x[d]+u)}return c},e.attachEvent("onBeforeTodayDisplayed",function(){for(var t in e.matrix){var a=e.matrix[t];a.x_start=a._original_x_start}return!0}),e.attachEvent("onOptionsLoad",function(){for(var t in e.matrix){var a=e.matrix[t];a.order={},e.callEvent("onOptionsLoadStart",[]);for(var t=0;t<a.y_unit.length;t++)a.order[a.y_unit[t].key]=t;e.callEvent("onOptionsLoadFinal",[]),e._date&&a.name==e._mode&&e.setCurrentView(e._date,e._mode)}}),e.attachEvent("onBeforeDrag",function(t,a,n){
if("resize"==a){var i=n.target||n.srcElement,r=e._getClassName(i);r.indexOf("dhx_event_resize_end")<0?e._drag_from_start=!0:e._drag_from_start=!1}return!0});var m=10,g=null,f=null,b=e.attachEvent("onSchedulerReady",function(){e.matrix&&(dhtmlxEvent(document.body,"mousemove",o),e.detachEvent(b))});e._timeline_smart_render={_prepared_events_cache:null,_rendered_events_cache:[],_rendered_header_cache:[],_rendered_labels_cache:[],_rows_to_delete:[],_rows_to_add:[],_cols_to_delete:[],_cols_to_add:[],getViewPort:function(t,a,n){
var i=e.$container.querySelector(".dhx_cal_data"),r=i.getBoundingClientRect(),o=e.$container.querySelector(".dhx_timeline_scrollable_data");if(o&&void 0===a&&(a=o.scrollLeft),void 0===n&&(n=o?o.scrollTop:i.scrollTop),!r.x&&!r.y){var l={};return l._x_shift=r.left,l._y_shift=r.top,l.width=r.width,l.height=r.height,l.left=r.left,l.right=r.right,l.top=r.top,l.bottom=r.bottom,a&&(l.left+=a,l.right+=a),t&&(r.height=t),n&&(l.top+=n,l.bottom+=n),l}r._x_shift=r.left,r._y_shift=r.top,a&&(r.x+=a),t&&(r.height=t),
n&&(r.y+=n);var d={};for(var s in r)d[s]=r[s];return d},isInXViewPort:function(e,t){return e.left+t._x_shift<t.right+100&&e.right+t._x_shift>t.left-100},isInYViewPort:function(e,t){return e.top+t._y_shift<t.bottom+100&&e.bottom+t._y_shift>t.top-100},getVisibleHeader:function(t,a){var n="";this._rendered_header_cache=[];for(var i in t._h_cols){var r=t._h_cols[i];if(this.isInXViewPort({left:r.left,right:r.left+e._cols[i]},a)){var o=r.div.outerHTML;n+=o,this._rendered_header_cache.push(r.div.getAttribute("data-col-id"));
}}return n},updateHeader:function(t,a,n){this._cols_to_delete=[],this._cols_to_add=[];for(var i=e.$container.querySelectorAll(".dhx_cal_header > div"),r=i[i.length-1].querySelectorAll(".dhx_scale_bar"),o=[],l=0;l<r.length;l++)o.push(r[l].getAttribute("data-col-id"));var d=this.getVisibleHeader(t,a);if(d){for(var s=this._rendered_header_cache.slice(),_=[],l=0,c=o.length;c>l;l++){var u=s.indexOf(o[l]);u>-1?s.splice(u,1):_.push(o[l])}_.length&&(this._cols_to_delete=_.slice(),this._deleteHeaderCells(_,t,n)),
s.length&&(this._cols_to_add=s.slice(),this._addHeaderCells(s,t,n))}},_deleteHeaderCells:function(e,t,a){for(var n=0;n<e.length;n++){var i=a.querySelector('[data-col-id="'+e[n]+'"]');i&&a.removeChild(i)}},_addHeaderCells:function(e,t,a){for(var n="",i=0;i<e.length;i++)n+=t._h_cols[e[i]].div.outerHTML;a.insertAdjacentHTML("beforeEnd",n)},getVisibleLabels:function(e,t){if(e._label_rows.length){var a="";this._rendered_labels_cache=[];for(var n=0;n<e._label_rows.length;n++)if(this.isInYViewPort({top:e._label_rows[n].top,
bottom:e._label_rows[n].top+e._section_height[e.y_unit[n].key]},t)){var i=e._label_rows[n].div;a+=i,this._rendered_labels_cache.push(n)}return a}},updateLabels:function(e,t,a){this._rows_to_delete=[],this._rows_to_add=[];var n=this._rendered_labels_cache.slice();n.length||(this.getVisibleLabels(e,t),n=this._rendered_labels_cache.slice());var i=this.getVisibleLabels(e,t);if(i){for(var r=this._rendered_labels_cache.slice(),o=[],l=0,d=n.length;d>l;l++){var s=r.indexOf(n[l]);s>-1?r.splice(s,1):o.push(n[l]);
}o.length&&(this._rows_to_delete=o.slice(),this._deleteLabelCells(o,e,a)),r.length&&(this._rows_to_add=r.slice(),this._addLabelCells(r,e,a))}},_deleteLabelCells:function(e,t,a){for(var n=0;n<e.length;n++){var i=a.querySelector('[data-row-index="'+e[n]+'"]');i&&a.removeChild(i)}},_addLabelCells:function(e,t,a){for(var n="",i=0;i<e.length;i++)n+=t._label_rows[e[i]].div;a.insertAdjacentHTML("beforeEnd",n)},cachePreparedEvents:function(e){this._prepared_events_cache=e},getPreparedEvents:function(t){var a;
return this._prepared_events_cache?a=this._prepared_events_cache:(a=e._prepare_timeline_events(t),this.cachePreparedEvents(a)),a},updateEvents:function(t,a){var n=this.getPreparedEvents(t),i=this._rendered_events_cache.slice();this._rendered_events_cache=[];var r=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(r){for(var o=0;o<this._rendered_labels_cache.length;o++){for(var l=this._rendered_labels_cache[o],d=[],s=i[l]?i[l].slice():[],_=e._timeline_smart_render.getVisibleEventsForRow(t,a,n,l),c=0,u=_.length;u>c;c++){
var h=s.indexOf(_[c].id);h>-1?s.splice(h,1):d.push(_[c])}var p=r.querySelector('[data-section-index="'+l+'"]');s.length&&this._deleteEvents(s,t,p),d.length&&this._addEvents(d,t,p,l)}t._matrix=n}},_deleteEvents:function(e,t,a){for(var n=0;n<e.length;n++){var i=a.querySelector('[event_id="'+e[n]+'"]');i&&(i.classList.contains("dhx_in_move")||a.removeChild(i))}},_addEvents:function(t,a,n,i){var r=e._timeline_update_events_html.call(a,t);n.insertAdjacentHTML("beforeEnd",r)},getVisibleEventsForRow:function(t,a,n,i){
var r=[];if("cell"==t.render)r=n;else if(n[i])for(var o=0,l=n[i].length;l>o;o++){var d=e._timeline_getX(n[i][o],!1,t),s=e._timeline_getX(n[i][o],!0,t);e._timeline_smart_render.isInXViewPort({left:d,right:s},a)&&(r.push(n[i][o]),this._rendered_events_cache[i]||(this._rendered_events_cache[i]=[]),this._rendered_events_cache[i].push(n[i][o].id))}return r},getVisibleRowCellsHTML:function(t,a,n,i,r){for(var o,l="",d=this._rendered_header_cache,s=0;s<d.length;s++){var _=d[s];o=t._h_cols[_].left-t.dx,l+=e._ignores[_]?"cell"==t.render?e._timeline_get_html_for_cell_ignores(n):e._timeline_get_html_for_bar_ignores():"cell"==t.render?e._timeline_get_html_for_cell(_,r,t,i[r][_],n,o):e._timeline_get_html_for_bar(_,r,t,i[r],o);
}return l},getVisibleTimelineRowsHTML:function(t,a,n,i){var r="",o=e._timeline_get_cur_row_stats(t,i);o=e._timeline_get_fit_events_stats(t,i,o);var l=t._label_rows[i];return"cell"==t.render?(r+=e._timeline_get_html_for_cell_data_row(i,o,l.top,l.section.key),r+=this.getVisibleRowCellsHTML(t,a,o,n,i),r+="</div>"):(r+=e._timeline_get_html_for_bar_matrix_line(i,o,l.top,l.section.key),r+=e._timeline_get_html_for_bar_data_row(o),r+=this.getVisibleRowCellsHTML(t,a,o,n,i),r+="</div></div>"),r},updateGridRows:function(e,t){
this._rows_to_delete.length&&this._deleteGridRows(this._rows_to_delete),this._rows_to_add.length&&this._addGridRows(this._rows_to_add,e,t)},_deleteGridRows:function(t){var a=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(a){for(var n=0;n<t.length;n++){var i=a.querySelector('[data-section-index="'+t[n]+'"]');a.removeChild(i)}this._rows_to_delete=[]}},_addGridRows:function(t,a,n){var i=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(i){for(var r=this.getPreparedEvents(a),o="",l=0;l<t.length;l++)o+=this.getVisibleTimelineRowsHTML(a,n,r,t[l]);
i.insertAdjacentHTML("beforeEnd",o);for(var l=0;l<t.length;l++)e._timeline_finalize_section_add(a,a.y_unit[t[l]].key,i);e._mark_now&&e._mark_now(),this._rows_to_add=[]}},updateGridCols:function(t,a){for(var n=this._rendered_header_cache,i={},r={},o=0;o<n.length;o++)r[n[o]]=!0;var l=e.$container.querySelector(".dhx_timeline_data_row");if(l)for(var d=l.querySelectorAll("[data-col-id]"),o=0;o<d.length;o++)i[d[o].getAttribute("data-col-id")]=!0;var s=[],_=[];for(var o in i)r[o]||s.push(o);for(var o in r)i[o]||_.push(o);
s.length&&this._deleteGridCols(s,t),_.length&&this._addGridCols(_,t,a)},_deleteGridCols:function(t,a){var n=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(n){for(var i=0;i<this._rendered_labels_cache.length;i++){var r;if(r="cell"==a.render?n.querySelector('[data-section-index="'+this._rendered_labels_cache[i]+'"]'):n.querySelector('[data-section-index="'+this._rendered_labels_cache[i]+'"] .dhx_timeline_data_row '))for(var o=0;o<t.length;o++){var l=r.querySelector('[data-col-id="'+t[o]+'"]');
l&&r.removeChild(l)}}this._cols_to_delete=[]}},_addGridCols:function(t,a,n){var i=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(i){for(var r=this.getPreparedEvents(a),o=0;o<this._rendered_labels_cache.length;o++){var l=this._rendered_labels_cache[o],d="",s=e._timeline_get_cur_row_stats(a,l);s=e._timeline_get_fit_events_stats(a,l,s);var _;if(_="cell"==a.render?i.querySelector('[data-section-index="'+l+'"]'):i.querySelector('[data-section-index="'+l+'"] .dhx_timeline_data_row')){
for(var c=0;c<t.length;c++){var u=_.querySelector('[data-col-id="'+t[c]+'"]');if(!u){var h=this.getVisibleGridCell(a,n,s,r,l,t[c]);h&&(d+=h)}}_.insertAdjacentHTML("beforeEnd",d)}}this._cols_to_add=[]}},getVisibleGridCell:function(t,a,n,i,r,o){if(t._h_cols[o]){var l="",d=t._h_cols[o].left-t.dx;return"cell"==t.render?e._ignores[o]||(l+=e._timeline_get_html_for_cell(o,r,t,i[r][o],n,d)):e._ignores[o]||(l+=e._timeline_get_html_for_bar(o,r,t,i[r],d)),l}}}},e._temp_matrix_scope()});