UNPKG

dhtmlx-gantt

Version:

An open source JavaScript Gantt chart that helps you illustrate a project schedule in a nice-looking chart.

23 lines (17 loc) 606 kB
(function($t,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):V(($t=typeof globalThis<"u"?globalThis:$t||self).dhtmlxgantt={})})(this,function($t){"use strict";/** @license dhtmlxGantt v.9.1.1 Standard This version of dhtmlxGantt is distributed under GPL 2.0 license and can be legally used in GPL projects. To use dhtmlxGantt in non-GPL projects (and get Pro version of the product), please obtain Individual, Commercial, Enterprise or Ultimate license on our site https://dhtmlx.com/docs/products/dhtmlxGantt/#licensing or contact us at info@dhtmlx.com (c) XB Software */function V(t){var n=0,e=0,i=0,a=0;if(t.getBoundingClientRect){var s=t.getBoundingClientRect(),r=document.body,o=document.documentElement||document.body.parentNode||document.body,l=window.pageYOffset||o.scrollTop||r.scrollTop,d=window.pageXOffset||o.scrollLeft||r.scrollLeft,c=o.clientTop||r.clientTop||0,u=o.clientLeft||r.clientLeft||0;n=s.top+l-c,e=s.left+d-u,i=document.body.offsetWidth-s.right,a=document.body.offsetHeight-s.bottom}else{for(;t;)n+=parseInt(t.offsetTop,10),e+=parseInt(t.offsetLeft,10),t=t.offsetParent;i=document.body.offsetWidth-t.offsetWidth-e,a=document.body.offsetHeight-t.offsetHeight-n}return{y:Math.round(n),x:Math.round(e),width:t.offsetWidth,height:t.offsetHeight,right:Math.round(i),bottom:Math.round(a)}}function In(t){var n=!1,e=!1;if(window.getComputedStyle){var i=window.getComputedStyle(t,null);n=i.display,e=i.visibility}else t.currentStyle&&(n=t.currentStyle.display,e=t.currentStyle.visibility);return n!="none"&&e!="hidden"}function Mn(t){return!isNaN(t.getAttribute("tabindex"))&&1*t.getAttribute("tabindex")>=0}function Nn(t){return!{a:!0,area:!0}[t.nodeName.loLowerCase()]||!!t.getAttribute("href")}function Ln(t){return!{input:!0,select:!0,textarea:!0,button:!0,object:!0}[t.nodeName.toLowerCase()]||!t.hasAttribute("disabled")}function At(t){for(var n=t.querySelectorAll(["a[href]","area[href]","input","select","textarea","button","iframe","object","embed","[tabindex]","[contenteditable]"].join(", ")),e=Array.prototype.slice.call(n,0),i=0;i<e.length;i++)e[i].$position=i;for(e.sort(function(s,r){return s.tabIndex===0&&r.tabIndex!==0?1:s.tabIndex!==0&&r.tabIndex===0?-1:s.tabIndex===r.tabIndex?s.$position-r.$position:s.tabIndex<r.tabIndex?-1:1}),i=0;i<e.length;i++){var a=e[i];(Mn(a)||Ln(a)||Nn(a))&&In(a)||(e.splice(i,1),i--)}return e}function Me(){var t=document.createElement("div");t.style.cssText="visibility:hidden;position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;height:110px;min-height:100px;overflow-y:scroll;",document.body.appendChild(t);var n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),Math.max(n,15)}function Z(t){if(!t)return"";var n=t.className||"";return n.baseVal&&(n=n.baseVal),n.indexOf||(n=""),oe(n)}function wt(t,n){n&&t.className.indexOf(n)===-1&&(t.className+=" "+n)}function jt(t,n){n=n.split(" ");for(var e=0;e<n.length;e++){var i=new RegExp("\\s?\\b"+n[e]+"\\b(?![-_.])","");t.className=t.className.replace(i,"")}}function re(t){return typeof t=="string"?document.getElementById(t)||document.querySelector(t)||document.body:t||document.body}var Wt;function Ne(t,n){Wt||(Wt=document.createElement("div")),Wt.innerHTML=n;var e=Wt.firstChild;return t.appendChild(e),e}function Le(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Re(t,n){for(var e=t.childNodes,i=e.length,a=[],s=0;s<i;s++){var r=e[s];r.className&&r.className.indexOf(n)!==-1&&a.push(r)}return a}function yt(t){var n;return t.tagName?n=t:(n=(t=t||window.event).target||t.srcElement).shadowRoot&&t.composedPath&&(n=t.composedPath()[0]),n}function nt(t,n){if(n){for(var e=yt(t);e;){if(e.getAttribute&&e.getAttribute(n))return e;e=e.parentNode||e.host}return null}}function oe(t){return(String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")}).apply(t)}function ft(t,n,e){var i=yt(t),a="";for(e===void 0&&(e=!0);i;){if(a=Z(i)){var s=a.indexOf(n);if(s>=0){if(!e)return i;var r=s===0||!oe(a.charAt(s-1)),o=s+n.length>=a.length||!oe(a.charAt(s+n.length));if(r&&o)return i}}i=i.parentNode}return null}function at(t,n){var r;const e=document.documentElement,i=V(n),{clientX:a,clientY:s}=((r=t.touches)==null?void 0:r[0])??t;return{x:a+e.scrollLeft-e.clientLeft-i.x+n.scrollLeft,y:s+e.scrollTop-e.clientTop-i.y+n.scrollTop}}function Pe(t,n){const e=V(t),i=V(n);return{x:e.x-i.x,y:e.y-i.y}}function J(t,n){if(!t||!n)return!1;for(;t&&t!=n;)t=t.parentNode;return t===n}function dt(t,n){if(t.closest)return t.closest(n);if(t.matches||t.msMatchesSelector||t.webkitMatchesSelector){var e=t;if(!document.documentElement.contains(e))return null;do{if((e.matches||e.msMatchesSelector||e.webkitMatchesSelector).call(e,n))return e;e=e.parentElement||e.parentNode}while(e!==null&&e.nodeType===1);return null}return console.error("Your browser is not supported"),null}function He(t){for(;t;){if(t.offsetWidth>0&&t.offsetHeight>0)return t;t=t.parentElement}return null}function Oe(){return document.head.createShadowRoot||document.head.attachShadow}function le(){var t=document.activeElement;return t.shadowRoot&&(t=t.shadowRoot.activeElement),t===document.body&&document.getSelection&&(t=document.getSelection().focusNode||document.body),t}function bt(t){if(!t||!Oe())return document.body;for(;t.parentNode&&(t=t.parentNode);)if(t instanceof ShadowRoot)return t.host;return document.body}const Be=Object.freeze(Object.defineProperty({__proto__:null,addClassName:wt,closest:dt,getActiveElement:le,getChildNodes:Re,getClassName:Z,getClosestSizedElement:He,getFocusableNodes:At,getNodePosition:V,getRelativeEventPosition:at,getRelativeNodePosition:Pe,getRootNode:bt,getScrollSize:Me,getTargetNode:yt,hasClass:function(t,n){return"classList"in t?t.classList.contains(n):new RegExp("\\b"+n+"\\b").test(t.className)},hasShadowParent:function(t){return!!bt(t)},insertNode:Ne,isChildOf:J,isShadowDomSupported:Oe,locateAttribute:nt,locateClassName:ft,removeClassName:jt,removeNode:Le,toNode:re},Symbol.toStringTag,{value:"Module"})),Q=typeof window<"u"?window:global;let Rn=class{constructor(t){this._mouseDown=!1,this._touchStarts=!1,this._touchActive=!1,this._longTapTimer=!1,this._gantt=t,this._domEvents=t._createDomEventScope()}attach(t,n,e){const i=this._gantt,a=t.getViewPort();this._originPosition=Q.getComputedStyle(a).display,this._restoreOriginPosition=()=>{a.style.position=this._originPosition},this._originPosition==="static"&&(a.style.position="relative");const s=i.$services.getService("state");s.registerProvider("clickDrag",()=>({autoscroll:!1}));let r=null;const o=()=>{r&&(this._mouseDown=!0,t.setStart(i.copy(r)),t.setPosition(i.copy(r)),t.setEnd(i.copy(r)),r=null)};this._domEvents.attach(a,"mousedown",f=>{u(f)});const l=bt(i.$root)||document.body;function d(f){return f.changedTouches&&f.changedTouches[0]||f}this._domEvents.attach(l,"mouseup",f=>{h(f)}),this._domEvents.attach(a,"mousemove",f=>{_(f)}),this._domEvents.attach(a,"touchstart",f=>{this._touchStarts=!0,this._longTapTimer=setTimeout(()=>{this._touchStarts&&(u(d(f)),this._touchStarts=!1,this._touchActive=!0)},this._gantt.config.touch_drag)}),this._domEvents.attach(l,"touchend",f=>{this._touchStarts=!1,this._touchActive=!1,clearTimeout(this._longTapTimer),h(d(f))}),this._domEvents.attach(a,"touchmove",f=>{if(this._touchActive){let y=c();if(y&&i.utils.dom.closest(f.target,y))return;_(d(f)),f.preventDefault()}else this._touchStarts=!1,clearTimeout(this._longTapTimer)});const c=()=>{let f=".gantt_task_line, .gantt_task_link";return e!==void 0&&(f=e instanceof Array?e.join(", "):e),f},u=f=>{r=null;let y=c();y&&i.utils.dom.closest(f.target,y)||(s.registerProvider("clickDrag",()=>({autoscroll:this._mouseDown})),n&&f[n]!==!0||(r=this._getCoordinates(f,t)))},h=f=>{if(r=null,(!n||f[n]===!0)&&this._mouseDown===!0){this._mouseDown=!1;const y=this._getCoordinates(f,t);t.dragEnd(y)}},_=f=>{if(n&&f[n]!==!0)return;const y=this._gantt.ext.clickDrag,v=(this._gantt.config.drag_timeline||{}).useKey;if(y&&v&&!n&&f[v])return;let b=null;if(!this._mouseDown&&r)return b=this._getCoordinates(f,t),void(Math.abs(r.relative.left-b.relative.left)>5&&o());this._mouseDown===!0&&(b=this._getCoordinates(f,t),t.setEnd(b),t.render())}}detach(){const t=this._gantt;this._domEvents.detachAll(),this._restoreOriginPosition&&this._restoreOriginPosition(),t.$services.getService("state").unregisterProvider("clickDrag")}destructor(){this.detach()}_getCoordinates(t,n){const e=n.getViewPort(),i=e.getBoundingClientRect(),{clientX:a,clientY:s}=t;return{absolute:{left:a,top:s},relative:{left:a-i.left+e.scrollLeft,top:s-i.top+e.scrollTop}}}};var ze=function(){this._silent_mode=!1,this.listeners={}};ze.prototype={_silentStart:function(){this._silent_mode=!0},_silentEnd:function(){this._silent_mode=!1}};function st(t){var n=new ze;t.attachEvent=function(e,i,a){e="ev_"+e.toLowerCase(),n.listeners[e]||(n.listeners[e]=function(r){var o={},l=0,d=function(){var c=!0;for(var u in o){var h=o[u].apply(r,arguments);c=c&&h}return c};return d.addEvent=function(c,u){if(typeof c=="function"){var h;if(u&&u.id?h=u.id:(h=l,l++),u&&u.once){var _=c;c=function(){_(),d.removeEvent(h)}}return o[h]=c,h}return!1},d.removeEvent=function(c){delete o[c]},d.clear=function(){o={}},d}(this)),a&&a.thisObject&&(i=i.bind(a.thisObject));var s=e+":"+n.listeners[e].addEvent(i,a);return a&&a.id&&(s=a.id),s},t.attachAll=function(e){this.attachEvent("listen_all",e)},t.callEvent=function(e,i){if(n._silent_mode)return!0;var a="ev_"+e.toLowerCase(),s=n.listeners;return s.ev_listen_all&&s.ev_listen_all.apply(this,[e].concat(i)),!s[a]||s[a].apply(this,i)},t.checkEvent=function(e){return!!n.listeners["ev_"+e.toLowerCase()]},t.detachEvent=function(e){if(e){var i=n.listeners;for(var a in i)i[a].removeEvent(e);var s=e.split(":");if(i=n.listeners,s.length===2){var r=s[0],o=s[1];i[r]&&i[r].removeEvent(o)}}},t.detachAllEvents=function(){for(var e in n.listeners)n.listeners[e].clear()}}var je={second:1,minute:60,hour:3600,day:86400,week:604800,month:2592e3,quarter:7776e3,year:31536e3};function Ft(t){return je[t]||je.hour}function xt(t,n){if(t.forEach)t.forEach(n);else for(var e=t.slice(),i=0;i<e.length;i++)n(e[i],i)}function Pn(t,n){if(t.find)return t.find(n);for(var e=0;e<t.length;e++)if(n(t[e],e))return t[e]}function Vt(t,n){if(t.includes)return t.includes(n);for(var e=0;e<t.length;e++)if(t[e]===n)return!0;return!1}function de(t){return Array.isArray?Array.isArray(t):t&&t.length!==void 0&&t.pop&&t.push}function tt(t){return!(!t||typeof t!="object")&&!!(t.getFullYear&&t.getMonth&&t.getDate)}function St(t){return tt(t)&&!isNaN(t.getTime())}function ce(t,n){var e,i=function(){i.$cancelTimeout(),i.$pending=!0;var a=Array.prototype.slice.call(arguments);e=setTimeout(function(){t.apply(this,a),i.$pending=!1},n)};return i.$pending=!1,i.$cancelTimeout=function(){clearTimeout(e),i.$pending=!1},i.$execute=function(){var a=Array.prototype.slice.call(arguments);t.apply(this,a),i.$cancelTimeout()},i}function rt(t,n){return We(t)&&!We(n)&&(t="0"),t}function We(t){return t===0}function Tt(t,n){for(var e,i,a,s=0,r=t.length-1;s<=r;)if(i=+t[e=Math.floor((s+r)/2)],a=+t[e-1],i<n)s=e+1;else{if(!(i>n)){for(;+t[e]==+t[e+1];)e++;return e}if(!isNaN(a)&&a<n)return e-1;r=e-1}return t.length-1}class Hn{constructor(n,e,i){var a;this._el=document.createElement("div"),this.defaultRender=(s,r)=>{this._el||(this._el=document.createElement("div"));const o=this._el,l=Math.min(s.relative.top,r.relative.top),d=Math.max(s.relative.top,r.relative.top),c=Math.min(s.relative.left,r.relative.left),u=Math.max(s.relative.left,r.relative.left);if(this._singleRow){const h=this._getTaskPositionByTop(this._startPoint.relative.top);o.style.height=h.height+"px",o.style.top=h.top+"px"}else o.style.height=Math.abs(d-l)+"px",o.style.top=l+"px";return o.style.width=Math.abs(u-c)+"px",o.style.left=c+"px",o},this._gantt=e,this._view=i,this._viewPort=n.viewPort,this._el.classList.add(n.className),typeof n.callback=="function"&&(this._callback=n.callback),this.render=()=>{let s;s=n.render?n.render(this._startPoint,this._endPoint):this.defaultRender(this._startPoint,this._endPoint),s!==this._el&&(this._el&&this._el.parentNode&&this._el.parentNode.removeChild(this._el),this._el=s),n.className!==""&&this._el.classList.add(n.className),this.draw()},(a=this._viewPort).attachEvent&&a.detachEvent||st(this._viewPort),this._singleRow=n.singleRow,this._useRequestAnimationFrame=n.useRequestAnimationFrame}draw(){if(this._useRequestAnimationFrame)return requestAnimationFrame(()=>{this._viewPort.appendChild(this.getElement())});this._viewPort.appendChild(this.getElement())}clear(){if(this._useRequestAnimationFrame)return requestAnimationFrame(()=>{this._el.parentNode&&this._viewPort.removeChild(this._el)});this._el.parentNode&&this._viewPort.removeChild(this._el)}getElement(){return this._el}getViewPort(){return this._viewPort}setStart(n){const e=this._gantt;this._startPoint=n,this._startDate=e.dateFromPos(this._startPoint.relative.left),this._viewPort.callEvent("onBeforeDrag",[this._startPoint])}setEnd(n){const e=this._gantt;if(this._endPoint=n,this._singleRow){const i=this._getTaskPositionByTop(this._startPoint.relative.top);this._endPoint.relative.top=i.top}this._endDate=e.dateFromPos(this._endPoint.relative.left),this._startPoint.relative.left>this._endPoint.relative.left&&(this._positionPoint={relative:{left:this._endPoint.relative.left,top:this._positionPoint.relative.top},absolute:{left:this._endPoint.absolute.left,top:this._positionPoint.absolute.top}}),this._startPoint.relative.top>this._endPoint.relative.top&&(this._positionPoint={relative:{left:this._positionPoint.relative.left,top:this._endPoint.relative.top},absolute:{left:this._positionPoint.absolute.left,top:this._endPoint.absolute.top}}),this._viewPort.callEvent("onDrag",[this._startPoint,this._endPoint])}setPosition(n){this._positionPoint=n}dragEnd(n){const e=this._gantt;n.relative.left<0&&(n.relative.left=0),this._viewPort.callEvent("onBeforeDragEnd",[this._startPoint,n]),this.setEnd(n),this._endDate=this._endDate||e.getState().max_date,this._startDate.valueOf()>this._endDate.valueOf()&&([this._startDate,this._endDate]=[this._endDate,this._startDate]),this.clear();const i=e.getTaskByTime(this._startDate,this._endDate),a=this._getTasksByTop(this._startPoint.relative.top,this._endPoint.relative.top);this._viewPort.callEvent("onDragEnd",[this._startPoint,this._endPoint]),this._callback&&this._callback(this._startPoint,this._endPoint,this._startDate,this._endDate,i,a)}getInBounds(){return this._singleRow}_getTasksByTop(n,e){const i=this._gantt;let a=n,s=e;n>e&&(a=e,s=n);const r=this._getTaskPositionByTop(a).index,o=this._getTaskPositionByTop(s).index,l=[];for(let d=r;d<=o;d++)i.getTaskByIndex(d)&&l.push(i.getTaskByIndex(d));return l}_getTaskPositionByTop(n){const e=this._gantt,i=this._view,a=i.getItemIndexByTopPosition(n),s=e.getTaskByIndex(a);if(s){const r=i.getItemHeight(s.id);return{top:i.getItemTop(s.id)||0,height:r||0,index:a}}{const r=i.getTotalHeight();return{top:n>r?r:0,height:e.config.row_height,index:n>r?e.getTaskCount():0}}}}let ue=!1;class Ut{constructor(n){this._mouseDown=!1,this._calculateDirectionVector=()=>{if(this._trace.length>=10){const e=this._trace.slice(this._trace.length-10),i=[];for(let s=1;s<e.length;s++)i.push({x:e[s].x-e[s-1].x,y:e[s].y-e[s-1].y});const a={x:0,y:0};return i.forEach(s=>{a.x+=s.x,a.y+=s.y}),{magnitude:Math.sqrt(a.x*a.x+a.y*a.y),angleDegrees:180*Math.atan2(Math.abs(a.y),Math.abs(a.x))/Math.PI}}return null},this._applyDndReadyStyles=()=>{this._timeline.$task.classList.add("gantt_timeline_move_available")},this._clearDndReadyStyles=()=>{this._timeline.$task.classList.remove("gantt_timeline_move_available")},this._getScrollPosition=e=>{const i=this._gantt;return{x:i.$ui.getView(e.$config.scrollX).getScrollState().position,y:i.$ui.getView(e.$config.scrollY).getScrollState().position}},this._countNewScrollPosition=e=>{const i=this._calculateDirectionVector();let a=this._startPoint.x-e.x,s=this._startPoint.y-e.y;return i&&(i.angleDegrees<15?s=0:i.angleDegrees>75&&(a=0)),{x:this._scrollState.x+a,y:this._scrollState.y+s}},this._setScrollPosition=(e,i)=>{const a=this._gantt;requestAnimationFrame(()=>{a.scrollLayoutCell(e.$id,i.x,i.y)})},this._stopDrag=e=>{const i=this._gantt;if(this._trace=[],i.$root.classList.remove("gantt_noselect"),this._originalReadonly!==void 0&&this._mouseDown&&(i.config.readonly=this._originalReadonly,i.config.drag_timeline&&i.config.drag_timeline.render&&i.render()),this._originAutoscroll!==void 0&&(i.config.autoscroll=this._originAutoscroll),i.config.drag_timeline){const{useKey:a}=i.config.drag_timeline;if(a&&e[a]!==!0)return}this._mouseDown=!1,ue=!1},this._startDrag=e=>{const i=this._gantt;this._originAutoscroll=i.config.autoscroll,i.config.autoscroll=!1,ue=!0,i.$root.classList.add("gantt_noselect"),this._originalReadonly=i.config.readonly,i.config.readonly=!0,i.config.drag_timeline&&i.config.drag_timeline.render&&i.render(),this._trace=[],this._mouseDown=!0;const{x:a,y:s}=this._getScrollPosition(this._timeline);this._scrollState={x:a,y:s},this._startPoint={x:e.clientX,y:e.clientY},this._trace.push(this._startPoint)},this._gantt=n,this._domEvents=n._createDomEventScope(),this._trace=[]}static create(n){return new Ut(n)}static _isDragInProgress(){return ue}destructor(){this._domEvents.detachAll()}attach(n){this._timeline=n;const e=this._gantt;this._domEvents.attach(n.$task,"mousedown",i=>{if(!e.config.drag_timeline)return;const{useKey:a,ignore:s,enabled:r}=e.config.drag_timeline;if(r===!1)return;let o=".gantt_task_line, .gantt_task_link";s!==void 0&&(o=s instanceof Array?s.join(", "):s),o&&e.utils.dom.closest(i.target,o)||a&&i[a]!==!0||this._startDrag(i)}),this._domEvents.attach(document,"keydown",i=>{if(!e.config.drag_timeline)return;const{useKey:a}=e.config.drag_timeline;a&&i[a]===!0&&this._applyDndReadyStyles()}),this._domEvents.attach(document,"keyup",i=>{if(!e.config.drag_timeline)return;const{useKey:a}=e.config.drag_timeline;a&&i[a]===!1&&(this._clearDndReadyStyles(),this._stopDrag(i))}),this._domEvents.attach(document,"mouseup",i=>{this._stopDrag(i)}),this._domEvents.attach(e.$root,"mouseup",i=>{this._stopDrag(i)}),this._domEvents.attach(document,"mouseleave",i=>{this._stopDrag(i)}),this._domEvents.attach(e.$root,"mouseleave",i=>{this._stopDrag(i)}),this._domEvents.attach(e.$root,"mousemove",i=>{if(!e.config.drag_timeline)return;const{useKey:a}=e.config.drag_timeline;if(a&&i[a]!==!0)return;const s=this._gantt.ext.clickDrag,r=(this._gantt.config.click_drag||{}).useKey;if((!s||!r||a||!i[r])&&this._mouseDown===!0){this._trace.push({x:i.clientX,y:i.clientY});const o=this._countNewScrollPosition({x:i.clientX,y:i.clientY});this._setScrollPosition(n,o),this._scrollState=o,this._startPoint={x:i.clientX,y:i.clientY}}})}}var he,On={}.constructor.toString();function K(t){var n,e;if(t&&typeof t=="object")switch(!0){case tt(t):e=new Date(t);break;case de(t):for(e=new Array(t.length),n=0;n<t.length;n++)e[n]=K(t[n]);break;default:if(function(i){return i.constructor.toString()!==On}(t))e=Object.create(t);else{if(function(i){return i.$$typeof&&i.$$typeof.toString().includes("react.")}(t))return e=t;e={}}for(n in t)Object.prototype.hasOwnProperty.apply(t,[n])&&(e[n]=K(t[n]))}return e||t}function R(t,n,e){for(var i in n)(t[i]===void 0||e)&&(t[i]=n[i]);return t}function U(t){return t!==void 0}function ot(){return he||(he=new Date().valueOf()),++he}function O(t,n){return t.bind?t.bind(n):function(){return t.apply(n,arguments)}}function Fe(t,n,e,i){t.addEventListener?t.addEventListener(n,e,i!==void 0&&i):t.attachEvent&&t.attachEvent("on"+n,e)}function Ve(t,n,e,i){t.removeEventListener?t.removeEventListener(n,e,i!==void 0&&i):t.detachEvent&&t.detachEvent("on"+n,e)}const Bn=Object.freeze(Object.defineProperty({__proto__:null,bind:O,copy:K,defined:U,event:Fe,eventRemove:Ve,mixin:R,uid:ot},Symbol.toStringTag,{value:"Module"}));function qt(t){var n=t.date;return t.$services,{getSum:function(e,i,a){a===void 0&&(a=e.length-1),i===void 0&&(i=0);for(var s=0,r=i;r<=a;r++)s+=e[r];return s},setSumWidth:function(e,i,a,s){var r=i.width;s===void 0&&(s=r.length-1),a===void 0&&(a=0);var o=s-a+1;if(!(a>r.length-1||o<=0||s>r.length-1)){var l=e-this.getSum(r,a,s);this.adjustSize(l,r,a,s),this.adjustSize(-l,r,s+1),i.full_width=this.getSum(r)}},splitSize:function(e,i){for(var a=[],s=0;s<i;s++)a[s]=0;return this.adjustSize(e,a),a},adjustSize:function(e,i,a,s){a||(a=0),s===void 0&&(s=i.length-1);for(var r=s-a+1,o=this.getSum(i,a,s),l=a;l<=s;l++){var d=Math.floor(e*(o?i[l]/o:1/r));o-=i[l],e-=d,r--,i[l]+=d}i[i.length-1]+=e},sortScales:function(e){function i(s,r){var o=new Date(1970,0,1);return n.add(o,r,s)-o}e.sort(function(s,r){return i(s.unit,s.step)<i(r.unit,r.step)?1:i(s.unit,s.step)>i(r.unit,r.step)?-1:0});for(var a=0;a<e.length;a++)e[a].index=a},_prepareScaleObject:function(e){var i=e.format;return i||(i=e.template||e.date||"%d %M"),typeof i=="string"&&(i=t.date.date_to_str(i)),{unit:e.unit||"day",step:e.step||1,format:i,css:e.css,projection:e.projection||null,column_width:e.column_width||null}},primaryScale:function(e){const i=(e||t.config).scales[0],a={unit:i.unit,step:i.step,template:i.template,format:i.format,date:i.date,css:i.css||t.templates.scale_cell_class,projection:i.projection||null,column_width:i.column_width||null};return this._prepareScaleObject(a)},getAdditionalScales:function(e){return(e||t.config).scales.slice(1).map((function(i){return this._prepareScaleObject(i)}).bind(this))},prepareConfigs:function(e,i,a,s,r,o,l){for(var d=this.splitSize(s,e.length),c=a,u=[],h=e.length-1;h>=0;h--){var _=h==e.length-1,f=this.initScaleConfig(e[h],r,o);_&&this.processIgnores(f),_&&f.column_width&&(c=f.column_width*(f.display_count||f.count)),this.initColSizes(f,i,c,d[h]),this.limitVisibleRange(f),_&&(c=f.full_width),u.unshift(f)}for(h=0;h<u.length-1;h++)this.alineScaleColumns(u[u.length-1],u[h]);for(h=0;h<u.length;h++)l&&this.reverseScale(u[h]),this.setPosSettings(u[h]);return u},reverseScale:function(e){e.width=e.width.reverse(),e.trace_x=e.trace_x.reverse();var i=e.trace_indexes;e.trace_indexes={},e.trace_index_transition={},e.rtl=!0;for(var a=0;a<e.trace_x.length;a++)e.trace_indexes[e.trace_x[a].valueOf()]=a,e.trace_index_transition[i[e.trace_x[a].valueOf()]]=a;return e},setPosSettings:function(e){for(var i=0,a=e.trace_x.length;i<a;i++)e.left.push((e.width[i-1]||0)+(e.left[i-1]||0))},_ignore_time_config:function(e,i){if(t.config.skip_off_time){for(var a=!0,s=e,r=0;r<i.step;r++)r&&(s=n.add(e,r,i.unit)),a=a&&!this.isWorkTime(s,i.unit);return a}return!1},processIgnores:function(e){e.ignore_x={},e.display_count=e.count},initColSizes:function(e,i,a,s){var r=a;e.height=s;var o=e.display_count===void 0?e.count:e.display_count;o||(o=1);const l=!isNaN(1*e.column_width)&&1*e.column_width>0;if(l){const h=1*e.column_width;e.col_width=h,r=h*o}else e.col_width=Math.floor(r/o),i&&e.col_width<i&&(e.col_width=i,r=e.col_width*o);e.width=[];for(var d=e.ignore_x||{},c=0;c<e.trace_x.length;c++)if(d[e.trace_x[c].valueOf()]||e.display_count==e.count)e.width[c]=l?e.col_width:0;else{var u=1;e.unit=="month"&&(u=Math.round((n.add(e.trace_x[c],e.step,e.unit)-e.trace_x[c])/864e5)),e.width[c]=u}l||this.adjustSize(r-this.getSum(e.width),e.width),e.full_width=this.getSum(e.width)},initScaleConfig:function(e,i,a){var s=R({count:0,col_width:0,full_width:0,height:0,width:[],left:[],trace_x:[],trace_indexes:{},min_date:new Date(i),max_date:new Date(a)},e);return this.eachColumn(e.unit,e.step,i,a,function(r){s.count++,s.trace_x.push(new Date(r)),s.trace_indexes[r.valueOf()]=s.trace_x.length-1}),s.trace_x_ascending=s.trace_x.slice(),s},iterateScales:function(e,i,a,s,r){for(var o=i.trace_x,l=e.trace_x,d=a||0,c=s||l.length-1,u=0,h=1;h<o.length;h++){var _=e.trace_indexes[+o[h]];_!==void 0&&_<=c&&(r&&r.apply(this,[u,h,d,_]),d=_,u=h)}},alineScaleColumns:function(e,i,a,s){this.iterateScales(e,i,a,s,function(r,o,l,d){var c=this.getSum(e.width,l,d-1);this.getSum(i.width,r,o-1)!=c&&this.setSumWidth(c,i,r,o-1)})},eachColumn:function(e,i,a,s,r){var o=new Date(a),l=new Date(s);n[e+"_start"]&&(o=n[e+"_start"](o));var d=new Date(o);for(+d>=+l&&(l=n.add(d,i,e));+d<+l;){r.call(this,new Date(d));var c=d.getTimezoneOffset();d=n.add(d,i,e),d=t._correct_dst_change(d,c,i,e),n[e+"_start"]&&(d=n[e+"_start"](d))}},limitVisibleRange:function(e){var i=e.trace_x,a=e.width.length-1,s=0;if(+i[0]<+e.min_date&&a!=0){var r=Math.floor(e.width[0]*((i[1]-e.min_date)/(i[1]-i[0])));s+=e.width[0]-r,e.width[0]=r,i[0]=new Date(e.min_date)}var o=i.length-1,l=i[o],d=n.add(l,e.step,e.unit);if(+d>+e.max_date&&o>0&&(r=e.width[o]-Math.floor(e.width[o]*((d-e.max_date)/(d-l))),s+=e.width[o]-r,e.width[o]=r),s){for(var c=this.getSum(e.width),u=0,h=0;h<e.width.length;h++){var _=Math.floor(s*(e.width[h]/c));e.width[h]+=_,u+=_}this.adjustSize(s-u,e.width)}}}}function zn(t){(function(){var n=[];function e(){return!!n.length}function i(d){setTimeout(function(){e()||t.$destroyed||t.focus()},1)}function a(d){t.eventRemove(d,"keydown",r),t.event(d,"keydown",r),n.push(d)}function s(){var d=n.pop();d&&t.eventRemove(d,"keydown",r),i()}function r(d){var c=d.currentTarget;c==n[n.length-1]&&t.$keyboardNavigation.trapFocus(c,d)}function o(){a(t.getLightbox())}t.attachEvent("onLightbox",o),t.attachEvent("onAfterLightbox",s),t.attachEvent("onLightboxChange",function(){s(),o()}),t.attachEvent("onAfterQuickInfo",function(){i()}),t.attachEvent("onMessagePopup",function(d){l=t.utils.dom.getActiveElement(),a(d)}),t.attachEvent("onAfterMessagePopup",function(){s(),setTimeout(function(){l&&l.focus&&(l.focus(),l=null)},1)});var l=null;t.$keyboardNavigation.isModal=e})()}class jn{constructor(n){this.show=(e,i)=>{i===void 0?this._showForTask(e):this._showAtCoordinates(e,i)},this.hide=e=>{const i=this._gantt,a=this._quickInfoBox;this._quickInfoBoxId=0;const s=this._quickInfoTask;if(this._quickInfoTask=null,a&&a.parentNode){if(i.config.quick_info_detached)return i.callEvent("onAfterQuickInfo",[s]),a.parentNode.removeChild(a);a.className+=" gantt_qi_hidden",a.style.right==="auto"?a.style.left="-350px":a.style.right="-350px",e&&(a.style.left=a.style.right="",a.parentNode.removeChild(a)),i.callEvent("onAfterQuickInfo",[s])}},this.getNode=()=>this._quickInfoBox?this._quickInfoBox:null,this.setContainer=e=>{e&&(this._container=typeof e=="string"?document.getElementById(e):e)},this.setContent=e=>{const i=this._gantt,a={taskId:null,header:{title:"",date:""},content:"",buttons:i.config.quickinfo_buttons};e||(e=a),e.taskId||(e.taskId=a.taskId),e.header||(e.header=a.header),e.header.title||(e.header.title=a.header.title),e.header.date||(e.header.date=a.header.date),e.content||(e.content=a.content),e.buttons||(e.buttons=a.buttons);let s=this.getNode();s||(s=this._createQuickInfoElement()),e.taskId&&(this._quickInfoBoxId=e.taskId);const r=s.querySelector(".gantt_cal_qi_title"),o=r.querySelector(".gantt_cal_qi_tcontent"),l=r.querySelector(".gantt_cal_qi_tdate"),d=s.querySelector(".gantt_cal_qi_content"),c=s.querySelector(".gantt_cal_qi_controls");i._waiAria.quickInfoHeader(s,[e.header.title,e.header.date].join(" ")),o.innerHTML=e.header.title,l.innerHTML=e.header.date,e.header.title||e.header.date?r.style.display="":r.style.display="none",d.innerHTML=e.content;const u=e.buttons;u.length?c.style.display="":c.style.display="none";let h="";for(let _=0;_<u.length;_++){const f=i._waiAria.quickInfoButtonAttrString(i.locale.labels[u[_]]);h+=`<div class="gantt_qi_big_icon ${u[_]} dhx_gantt_${u[_]}" title="${i.locale.labels[u[_]]}" ${f}> <div class='dhx_menu_icon dhx_gantt_icon ${u[_]} gantt_menu_icon dhx_gantt_${u[_]}'></div> <div>${i.locale.labels[u[_]]}</div> </div>`}c.innerHTML=h,i.eventRemove(s,"click",this._qiButtonClickHandler),i.eventRemove(s,"keypress",this._qiKeyPressHandler),i.event(s,"click",this._qiButtonClickHandler),i.event(s,"keypress",this._qiKeyPressHandler)},this._qiButtonClickHandler=e=>{this._qi_button_click(e.target)},this._qiKeyPressHandler=e=>{const i=e.which;i!==13&&i!==32||setTimeout(()=>{this._qi_button_click(e.target)},1)},this._gantt=n}_showAtCoordinates(n,e){this.hide(!0),this._quickInfoBoxId=0,this._quickInfoTask=null,this._quickInfoBox||(this._createQuickInfoElement(),this.setContent()),this._appendAtCoordinates(n,e),this._gantt.callEvent("onQuickInfo",[null])}_showForTask(n){const e=this._gantt;if(n===this._quickInfoBoxId&&e.utils.dom.isChildOf(this._quickInfoBox,document.body)||!e.config.show_quick_info)return;this.hide(!0);const i=this._getContainer(),a=this._get_event_counter_part(n,6,i.xViewport,i.yViewport);a&&(this._quickInfoBox=this._init_quick_info(n),this._quickInfoTask=n,this._quickInfoBox.className=this._prepare_quick_info_classname(n),this._fill_quick_data(n),this._show_quick_info(a,6),e.callEvent("onQuickInfo",[n]))}_get_event_counter_part(n,e,i,a){const s=this._gantt;let r=s.getTaskNode(n);if(!r&&(r=s.getTaskRowNode(n),!r))return null;let o=0;const l=e+r.offsetTop+r.offsetHeight;let d=r;if(s.utils.dom.isChildOf(d,i))for(;d&&d!==i;)o+=d.offsetLeft,d=d.offsetParent;const c=s.getScrollState();return d?{left:o,top:l,dx:o+r.offsetWidth/2-c.x>i.offsetWidth/2?1:0,dy:l+r.offsetHeight/2-c.y>a.offsetHeight/2?1:0,width:r.offsetWidth,height:r.offsetHeight}:null}_createQuickInfoElement(){const n=this._gantt,e=document.createElement("div");e.className+="gantt_cal_quick_info",n._waiAria.quickInfoAttr(e);var i=` <div class="gantt_cal_qi_tcontrols"> <a class="gantt_cal_qi_close_btn dhx_gantt_icon dhx_gantt_icon_close"></a> </div> <div class="gantt_cal_qi_title" ${n._waiAria.quickInfoHeaderAttrString()}> <div class="gantt_cal_qi_tcontent"></div> <div class="gantt_cal_qi_tdate"></div> </div> <div class="gantt_cal_qi_content"></div>`;if(i+='<div class="gantt_cal_qi_controls">',i+="</div>",e.innerHTML=i,n.config.quick_info_detached){const a=this._getContainer();n.event(a.parent,"scroll",()=>{this.hide()})}return this._quickInfoBox=e,e}_init_quick_info(n){const e=this._gantt,i=e.getTask(n);return typeof this._quickInfoReadonly=="boolean"&&e.isReadonly(i)!==this._quickInfoReadonly&&(this.hide(!0),this._quickInfoBox=null),this._quickInfoReadonly=e.isReadonly(i),this._quickInfoBox||(this._quickInfoBox=this._createQuickInfoElement()),this._quickInfoBox}_prepare_quick_info_classname(n){const e=this._gantt,i=e.getTask(n);let a=`gantt_cal_quick_info gantt_${e.getTaskType(i)}`;const s=e.templates.quick_info_class(i.start_date,i.end_date,i);return s&&(a+=" "+s),a}_fill_quick_data(n){const e=this._gantt,i=e.getTask(n);this._quickInfoBoxId=n;let a=[];if(this._quickInfoReadonly){const s=e.config.quickinfo_buttons,r={icon_delete:!0,icon_edit:!0};for(let o=0;o<s.length;o++)this._quickInfoReadonly&&r[s[o]]||a.push(s[o])}else a=e.config.quickinfo_buttons;this.setContent({header:{title:e.templates.quick_info_title(i.start_date,i.end_date,i),date:e.templates.quick_info_date(i.start_date,i.end_date,i)},content:e.templates.quick_info_content(i.start_date,i.end_date,i),buttons:a})}_appendAtCoordinates(n,e){const i=this._quickInfoBox,a=this._getContainer();i.parentNode&&i.parentNode.nodeName.toLowerCase()!=="#document-fragment"||a.parent.appendChild(i),i.style.left=n+"px",i.style.top=e+"px"}_show_quick_info(n,e){const i=this._gantt,a=this._quickInfoBox;if(i.config.quick_info_detached){const s=this._getContainer();a.parentNode&&a.parentNode.nodeName.toLowerCase()!=="#document-fragment"||s.parent.appendChild(a);const r=a.offsetWidth,o=a.offsetHeight,l=i.getScrollState(),d=s.xViewport,c=s.yViewport,u=d.offsetWidth+l.x-r,h=n.top-l.y+o;let _=n.top;h>c.offsetHeight/2&&(_=n.top-(o+n.height+2*e),_<l.y&&h<=c.offsetHeight&&(_=n.top)),_<l.y&&(_=l.y);const f=Math.min(Math.max(l.x,n.left-n.dx*(r-n.width)),u),y=_;this._appendAtCoordinates(f,y)}else a.style.top="20px",n.dx===1?(a.style.right="auto",a.style.left="-300px",setTimeout(()=>{a.style.left="10px"},1)):(a.style.left="auto",a.style.right="-300px",setTimeout(()=>{a.style.right="10px"},1)),a.className+=" gantt_qi_"+(n.dx===1?"left":"right"),i.$root.appendChild(a)}_qi_button_click(n){const e=this._gantt,i=this._quickInfoBox;if(!n||n===i)return;if(n.closest(".gantt_cal_qi_close_btn"))return void this.hide();const a=n.className;if(a.indexOf("_icon")!==-1){const s=this._quickInfoBoxId;e.$click.buttons[a.split(" ")[1].replace("icon_","")](s)}else this._qi_button_click(n.parentNode)}_getContainer(){const n=this._gantt;let e=this._container?this._container:n.$task_data;return e&&e.offsetHeight&&e.offsetWidth?{parent:e,xViewport:n.$task,yViewport:n.$task_data}:(e=this._container?this._container:n.$grid_data,e&&e.offsetHeight&&e.offsetWidth?{parent:e,xViewport:n.$grid,yViewport:n.$grid_data}:{parent:this._container?this._container:n.$layout,xViewport:n.$layout,yViewport:n.$layout})}}function Gt(t,n){t=t||Fe,n=n||Ve;var e=[],i={attach:function(a,s,r,o){e.push({element:a,event:s,callback:r,capture:o}),t(a,s,r,o)},detach:function(a,s,r,o){n(a,s,r,o);for(var l=0;l<e.length;l++){var d=e[l];d.element===a&&d.event===s&&d.callback===r&&d.capture===o&&(e.splice(l,1),l--)}},detachAll:function(){for(var a=e.slice(),s=0;s<a.length;s++){var r=a[s];i.detach(r.element,r.event,r.callback,r.capture),i.detach(r.element,r.event,r.callback,void 0),i.detach(r.element,r.event,r.callback,!1),i.detach(r.element,r.event,r.callback,!0)}e.splice(0,e.length)},extend:function(){return Gt(this.event,this.eventRemove)}};return i}class Wn{constructor(n){this._gantt=n}getNode(){const n=this._gantt;return this._tooltipNode||(this._tooltipNode=document.createElement("div"),this._tooltipNode.className="gantt_tooltip",n._waiAria.tooltipAttr(this._tooltipNode)),this._tooltipNode}setViewport(n){return this._root=n,this}show(n,e){const i=this._gantt,a=document.body,s=this.getNode();if(J(s,a)||(this.hide(),s.style.top=s.style.top||"0px",s.style.left=s.style.left||"0px",a.appendChild(s)),this._isLikeMouseEvent(n)){const r=this._calculateTooltipPosition(n);e=r.top,n=r.left}return s.style.top=e+"px",s.style.left=n+"px",i._waiAria.tooltipVisibleAttr(s),this}hide(){const n=this._gantt,e=this.getNode();return e&&e.parentNode&&e.parentNode.removeChild(e),n._waiAria.tooltipHiddenAttr(e),this}setContent(n){return this.getNode().innerHTML=n,this}_isLikeMouseEvent(n){return!(!n||typeof n!="object")&&"clientX"in n&&"clientY"in n}_getViewPort(){return this._root||document.body}_calculateTooltipPosition(n){const e=this._gantt,i=this._getViewPortSize(),a=this.getNode(),s={top:0,left:0,width:a.offsetWidth,height:a.offsetHeight,bottom:0,right:0},r=e.config.tooltip_offset_x,o=e.config.tooltip_offset_y,l=document.body,d=at(n,l),c=V(l);d.y+=c.y,s.top=d.y,s.left=d.x,s.top+=o,s.left+=r,s.bottom=s.top+s.height,s.right=s.left+s.width;const u=window.scrollY+l.scrollTop;return s.top<i.top-u?(s.top=i.top,s.bottom=s.top+s.height):s.bottom>i.bottom&&(s.bottom=i.bottom,s.top=s.bottom-s.height),s.left<i.left?(s.left=i.left,s.right=i.left+s.width):s.right>i.right&&(s.right=i.right,s.left=s.right-s.width),d.x>=s.left&&d.x<=s.right&&(s.left=d.x-s.width-r,s.right=s.left+s.width),d.y>=s.top&&d.y<=s.bottom&&(s.top=d.y-s.height-o,s.bottom=s.top+s.height),s.left<0&&(s.left=0),s.right<0&&(s.right=0),s}_getViewPortSize(){const n=this._gantt,e=this._getViewPort();let i,a=e,s=window.scrollY+document.body.scrollTop,r=window.scrollX+document.body.scrollLeft;return e===n.$task_data?(a=n.$task,s=0,r=0,i=V(n.$task)):i=V(a),{left:i.x+r,top:i.y+s,width:i.width,height:i.height,bottom:i.y+i.height+s,right:i.x+i.width+r}}}class Fn{constructor(n){this._listeners={},this.tooltip=new Wn(n),this._gantt=n,this._domEvents=Gt(),this._initDelayedFunctions()}destructor(){this.tooltip.hide(),this._domEvents.detachAll()}hideTooltip(){this.delayHide()}attach(n){let e=document.body;const i=this._gantt;n.global||(e=i.$root);let a=null;const s=r=>{const o=yt(r),l=dt(o,n.selector);if(J(o,this.tooltip.getNode()))return;const d=()=>{a=l,n.onmouseenter(r,l)};a?l&&l===a?n.onmousemove(r,l):(n.onmouseleave(r,a),a=null,l&&l!==a&&d()):l&&d()};this.detach(n.selector),this._domEvents.attach(e,"mousemove",s),this._listeners[n.selector]={node:e,handler:s}}detach(n){const e=this._listeners[n];e&&this._domEvents.detach(e.node,"mousemove",e.handler)}tooltipFor(n){const e=i=>{let a=i;return document.createEventObject&&!document.createEvent&&(a=document.createEventObject(i)),a};this._initDelayedFunctions(),this.attach({selector:n.selector,global:n.global,onmouseenter:(i,a)=>{const s=n.html(i,a);s&&this.delayShow(e(i),s)},onmousemove:(i,a)=>{const s=n.html(i,a);s?this.delayShow(e(i),s):(this.delayShow.$cancelTimeout(),this.delayHide())},onmouseleave:()=>{this.delayShow.$cancelTimeout(),this.delayHide()}})}_initDelayedFunctions(){const n=this._gantt;this.delayShow&&this.delayShow.$cancelTimeout(),this.delayHide&&this.delayHide.$cancelTimeout(),this.tooltip.hide(),this.delayShow=ce((e,i)=>{n.callEvent("onBeforeTooltip",[e])===!1?this.tooltip.hide():(this.tooltip.setContent(i),this.tooltip.show(e))},n.config.tooltip_timeout||1),this.delayHide=ce(()=>{this.delayShow.$cancelTimeout(),this.tooltip.hide()},n.config.tooltip_hide_timeout||1)}}const Ue={onBeforeUndo:"onAfterUndo",onBeforeRedo:"onAfterRedo"},qe=["onTaskDragStart","onAfterTaskUpdate","onAfterParentExpand","onAfterTaskDelete","onBeforeBatchUpdate"];class Vn{constructor(n,e){this._batchAction=null,this._batchMode=!1,this._ignore=!1,this._ignoreMoveEvents=!1,this._initialTasks={},this._initialLinks={},this._nestedTasks={},this._nestedLinks={},this._undo=n,this._gantt=e,this._attachEvents()}store(n,e,i=!1){return e===this._gantt.config.undo_types.task?this._storeTask(n,i):e===this._gantt.config.undo_types.link&&this._storeLink(n,i)}isMoveEventsIgnored(){return this._ignoreMoveEvents}toggleIgnoreMoveEvents(n){this._ignoreMoveEvents=n||!1}startIgnore(){this._ignore=!0}stopIgnore(){this._ignore=!1}startBatchAction(){this._timeout||(this._timeout=setTimeout(()=>{this.stopBatchAction(),this._timeout=null},10)),this._ignore||this._batchMode||(this._batchMode=!0,this._batchAction=this._undo.action.create())}stopBatchAction(){if(this._ignore)return;const n=this._undo;this._batchAction&&n.logAction(this._batchAction),this._batchMode=!1,this._batchAction=null}onTaskAdded(n){this._ignore||this._storeTaskCommand(n,this._undo.command.type.add)}onTaskUpdated(n){this._ignore||this._storeTaskCommand(n,this._undo.command.type.update)}onTaskMoved(n){this._ignore||(n.$local_index=this._gantt.getTaskIndex(n.id),this._storeEntityCommand(n,this.getInitialTask(n.id),this._undo.command.type.move,this._undo.command.entity.task))}onTaskDeleted(n){if(!this._ignore){if(this._storeTaskCommand(n,this._undo.command.type.remove),this._nestedTasks[n.id]){const e=this._nestedTasks[n.id];for(let i=0;i<e.length;i++)this._storeTaskCommand(e[i],this._undo.command.type.remove)}if(this._nestedLinks[n.id]){const e=this._nestedLinks[n.id];for(let i=0;i<e.length;i++)this._storeLinkCommand(e[i],this._undo.command.type.remove)}}}onLinkAdded(n){this._ignore||this._storeLinkCommand(n,this._undo.command.type.add)}onLinkUpdated(n){this._ignore||this._storeLinkCommand(n,this._undo.command.type.update)}onLinkDeleted(n){this._ignore||this._storeLinkCommand(n,this._undo.command.type.remove)}setNestedTasks(n,e){const i=this._gantt;let a=null;const s=[];let r=this._getLinks(i.getTask(n));for(let d=0;d<e.length;d++)a=this.setInitialTask(e[d]),r=r.concat(this._getLinks(a)),s.push(a);const o={};for(let d=0;d<r.length;d++)o[r[d]]=!0;const l=[];for(const d in o)l.push(this.setInitialLink(d));this._nestedTasks[n]=s,this._nestedLinks[n]=l}setInitialTask(n,e){const i=this._gantt;if(e||!this._initialTasks[n]||!this._batchMode){const a=i.copy(i.getTask(n));a.$index=i.getGlobalTaskIndex(n),a.$local_index=i.getTaskIndex(n),this.setInitialTaskObject(n,a)}return this._initialTasks[n]}getInitialTask(n){return this._initialTasks[n]}clearInitialTasks(){this._initialTasks={}}setInitialTaskObject(n,e){this._initialTasks[n]=e}setInitialLink(n,e){return this._initialLinks[n]&&this._batchMode||(this._initialLinks[n]=this._gantt.copy(this._gantt.getLink(n))),this._initialLinks[n]}getInitialLink(n){return this._initialLinks[n]}clearInitialLinks(){this._initialLinks={}}_attachEvents(){let n=null;const e=this._gantt,i=()=>{n||(n=setTimeout(()=>{n=null}),this.clearInitialTasks(),e.eachTask(l=>{this.setInitialTask(l.id)}),this.clearInitialLinks(),e.getLinks().forEach(l=>{this.setInitialLink(l.id)}))},a=l=>e.copy(e.getTask(l));for(const l in Ue)e.attachEvent(l,()=>(this.startIgnore(),!0)),e.attachEvent(Ue[l],()=>(this.stopIgnore(),!0));for(let l=0;l<qe.length;l++)e.attachEvent(qe[l],()=>(this.startBatchAction(),!0));e.attachEvent("onParse",()=>{this._undo.clearUndoStack(),this._undo.clearRedoStack(),i()}),e.attachEvent("onAfterTaskAdd",(l,d)=>{this.setInitialTask(l,!0),this.onTaskAdded(d)}),e.attachEvent("onAfterTaskUpdate",(l,d)=>{this.onTaskUpdated(d)}),e.attachEvent("onAfterParentExpand",(l,d)=>{this.onTaskUpdated(d)}),e.attachEvent("onAfterTaskDelete",(l,d)=>{this.onTaskDeleted(d)}),e.attachEvent("onAfterLinkAdd",(l,d)=>{this.setInitialLink(l,!0),this.onLinkAdded(d)}),e.attachEvent("onAfterLinkUpdate",(l,d)=>{this.onLinkUpdated(d)}),e.attachEvent("onAfterLinkDelete",(l,d)=>{this.onLinkDeleted(d)}),e.attachEvent("onRowDragEnd",(l,d)=>(this.onTaskMoved(a(l)),this.toggleIgnoreMoveEvents(),!0)),e.attachEvent("onBeforeTaskDelete",l=>{this.store(l,e.config.undo_types.task);const d=[];return i(),e.eachTask(c=>{d.push(c.id)},l),this.setNestedTasks(l,d),!0});const s=e.getDatastore("task");s.attachEvent("onBeforeItemMove",(l,d,c)=>(this.isMoveEventsIgnored()||i(),!0)),s.attachEvent("onAfterItemMove",(l,d,c)=>(this.isMoveEventsIgnored()||this.onTaskMoved(a(l)),!0)),e.attachEvent("onRowDragStart",(l,d,c)=>(this.toggleIgnoreMoveEvents(!0),i(),!0));let r=null,o=!1;if(e.attachEvent("onBeforeTaskDrag",l=>{if(r=e.getState().drag_id,r===l){const d=e.getTask(l);e.isSummaryTask(d)&&e.config.drag_project&&(o=!0)}if(e.plugins().multiselect){const d=e.getSelectedTasks();d.length>1&&d.forEach(c=>{this.store(c,e.config.undo_types.task,!0)})}return this.store(l,e.config.undo_types.task)}),e.attachEvent("onAfterTaskDrag",l=>{(o||e.plugins().multiselect&&e.getSelectedTasks().length>1)&&r===l&&(o=!1,r=null,this.stopBatchAction()),this.store(l,e.config.undo_types.task,!0)}),e.attachEvent("onLightbox",l=>this.store(l,e.config.undo_types.task)),e.attachEvent("onBeforeTaskAutoSchedule",l=>(this.store(l.id,e.config.undo_types.task,!0),!0)),e.ext.inlineEditors){let l=null,d=null;e.attachEvent("onGanttLayoutReady",()=>{l&&e.ext.inlineEditors.detachEvent(l),d&&e.ext.inlineEditors.detachEvent(d),d=e.ext.inlineEditors.attachEvent("onEditStart",c=>{e.$data.tempAssignmentsStore&&e._lightbox_id||this.store(c.id,e.config.undo_types.task)}),l=e.ext.inlineEditors.attachEvent("onBeforeEditStart",c=>(this.stopBatchAction(),!0))})}}_storeCommand(n){const e=this._undo;if(e.updateConfigs(),e.undoEnabled)if(this._batchMode)this._batchAction.commands.push(n);else{const i=e.action.create([n]);e.logAction(i)}}_storeEntityCommand(n,e,i,a){const s=this._undo.command.create(n,e,i,a);this._storeCommand(s)}_storeTaskCommand(n,e){this._gantt.isTaskExists(n.id)&&(n.$local_index=this._gantt.getTaskIndex(n.id)),this._storeEntityCommand(n,this.getInitialTask(n.id),e,this._undo.command.entity.task)}_storeLinkCommand(n,e){this._storeEntityCommand(n,this.getInitialLink(n.id),e,this._undo.command.entity.link)}_getLinks(n){return n.$source.concat(n.$target)}_storeTask(n,e=!1){const i=this._gantt;return this.setInitialTask(n,e),i.eachTask(a=>{this.setInitialTask(a.id)},n),!0}_storeLink(n,e=!1){return this.setInitialLink(n,e),!0}}class Un{constructor(n){this.maxSteps=100,this.undoEnabled=!0,this.redoEnabled=!0,this.action={create:e=>({commands:e?e.slice():[]}),invert:e=>{const i=this._gantt.copy(e),a=this.command;for(let s=0;s<e.commands.length;s++){const r=i.commands[s]=a.invert(i.commands[s]);r.type!==a.type.update&&r.type!==a.type.move||([r.value,r.oldValue]=[r.oldValue,r.value])}return i}},this.command={entity:null,type:null,create:(e,i,a,s)=>{const r=this._gantt;return{entity:s,type:a,value:r.copy(e),oldValue:r.copy(i||e)}},invert:e=>{const i=this._gantt.copy(e);return i.type=this.command.inverseCommands(e.type),i},inverseCommands:e=>{const i=this._gantt,a=this.command.type;switch(e){case a.update:return a.update;case a.remove:return a.add;case a.add:return a.remove;case a.move:return a.move;default:return i.assert(!1,"Invalid command "+e),null}}},this._undoStack=[],this._redoStack=[],this._gantt=n}getUndoStack(){return this._undoStack}setUndoStack(n){this._undoStack=n}getRedoStack(){return this._redoStack}setRedoStack(n){this._redoStack=n}clearUndoStack(){this._undoStack=[]}clearRedoStack(){this._redoStack=[]}updateConfigs(){const n=this._gantt;this.maxSteps=n.config.undo_steps||100,this.command.entity=n.config.undo_types,this.command.type=n.config.undo_actions,this.undoEnabled=!!n.config.undo,this.redoEnabled=!!n.config.redo}undo(){const n=this._gantt;if(this.updateConfigs(),!this.undoEnabled)return;const e=this._pop(this._undoStack);if(e&&this._reorderCommands(e),n.callEvent("onBeforeUndo",[e])!==!1&&e)return this._applyAction(this.action.invert(e)),this._push(this._redoStack,n.copy(e)),void n.callEvent("onAfterUndo",[e]);n.callEvent("onAfterUndo",[null])}redo(){const n=this._gantt;if(this.updateConfigs(),!this.redoEnabled)return;const e=this._pop(this._redoStack);if(e&&this._reorderCommands(e),n.callEvent("onBeforeRedo",[e])!==!1&&e)return this._applyAction(e),this._push(this._undoStack,n.copy(e)),void n.callEvent("onAfterRedo",[e]);n.callEvent("onAfterRedo",[null])}logAction(n){this._push(this._undoStack,n),this._redoStack=[]}_push(n,e){const i=this._gantt;if(!e.commands.length)return;const a=n===this._undoStack?"onBeforeUndoStack":"onBeforeRedoStack";if(i.callEvent(a,[e])!==!1&&e.commands.length){for(n.push(e);n.length>this.maxSteps;)n.shift();return e}}_pop(n){return n.pop()}_reorderCommands(n){const e={any:0,link:1,task:2},i={move:1,any:0};n.commands.sort(function(a,s){if(a.entity==="task"&&s.entity==="task")return a.type!==s.type?(i[s.type]||0)-(i[a.type]||0):a.type==="move"&&a.oldValue&&s.oldValue&&s.oldValue.parent===a.oldValue.parent?a.oldValue.$index-s.oldValue.$index:0;{const r=e[a.entity]||e.any;return(e[s.entity]||e.any)-r}})}_applyAction(n){let e=null;const i=this.command.entity,a=this.command.type,s=this._gantt,r={};r[i.task]={add:"addTask",get:"getTask",update:"updateTask",remove:"deleteTask",move:"moveTask",isExists:"isTaskExists"},r[i.link]={add:"addLink",get:"getLink",update:"updateLink",remove:"deleteLink",isExists:"isLinkExists"},s.batchUpdate(function(){for(let o=0;o<n.commands.length;o++){e=n.commands[o];const l=r[e.entity][e.type],d=r[e.entity].get,c=r[e.entity].isExists;if(e.type===a.add)s[l](e.oldValue,e.oldValue.parent,e.oldValue.$local_index);else if(e.type===a.remove)s[c](e.value.id)&&s[l](e.value.id);else if(e.type===a.update){const u=s[d](e.value.id);for(const h in e.value){let _=!(h.startsWith("$")||h.startsWith("_"));["$open"].indexOf(h)>-1&&(_=!0),_&&(u[h]=e.value[h])}s[l](e.value.id)}else e.type===a.move&&(s[l](e.value.id,e.value.$local_index,e.value.parent),s.callEvent("onRowDragEnd",[e.value.id]))}})}}const qn={click_drag:function(t){t.ext||(t.ext={});const n={className:"gantt_click_drag_rect",useRequestAnimationFrame:!0,callback:void 0,singleRow:!1};function e(){const i={viewPort:t.$task_data,...n};t.ext.clickDrag&&t.ext.clickDrag.destructor(),t.ext.clickDrag=new Rn(t);const a=t.config.click_drag;i.render=a.render||n.render,i.className=a.className||n.className,i.callback=a.callback||n.callback,i.viewPort=a.viewPort||t.$task_data,i.useRequestAnimationFrame=a.useRequestAnimationFrame===void 0?n.useRequestAnimationFrame:a.useRequestAnimationFrame,i.singleRow=a.singleRow===void 0?n.singleRow:a.singleRow;const s=t.$ui.getView("timeline"),r=new Hn(i,t,s);t.ext.clickDrag.attach(r,a.useKey,a.ignore)}t.attachEvent("onGanttReady",()=>{t.config.click_drag&&e()}),t.attachEvent("onGanttLayoutReady",function(){t.$container&&t.config.click_drag&&t.attachEvent("onGanttRender",function(){e()},{once:!0})}),t.attachEvent("onDestroy",()=>{t.ext.clickDrag&&t.ext.clickDrag.destructor()})},drag_timeline:function(t){t.ext||(t.ext={}),t.ext.dragTimeline={create:()=>Ut.create(t),_isDragInProgress:()=>Ut._isDragInProgress},t.config.drag_timeline={enabled:!0,render:!1}},fullscreen:function(t){function n(){const c=document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement;return!(!c||c!==document.body)}function e(){try{return document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled}catch(c){console.error("Fullscreen is not available:",c)}}t.$services.getService("state").registerProvider("fullscreen",()=>e()?{fullscreen:n()}:void 0);let i={overflow:null,padding:null,paddingTop:null,paddingRight:null,paddingBottom:null,paddingLeft:null};const a={width:null,height:null,top:null,left:null,position:null,zIndex:null,modified:!1};let s=null;function r(c,u){u.width=c.width,u.height=c.height,u.top=c.top,u.left=c.left,u.position=c.position,u.zIndex=c.zIndex}let o=!1;function l(){if(!t.$container)return;let c;n()?o&&(c="onExpand",function(){const u=t.ext.fullscreen.getFullscreenElement(),h=document.body;r(u.style,a),i={overflow:h.style.overflow,padding:h.style.padding?h.style.padding:null,paddingTop:h.style.paddingTop?h.style.paddingTop:null,paddingRight:h.style.paddingRight?h.style.paddingRight:null,paddingBottom:h.style.paddingBottom?h.style.paddingBottom:null,paddingLeft:h.style.paddingLeft?h.style.paddingLeft:null},h.style.padding&&(h.style.padding="0"),h.style.paddingTop&&(h.style.paddingTop="0"),h.style.paddingRight&&(h.style.paddingRight="0"),h.style.paddingBottom&&(h.style.paddingBottom="0"),h.style.paddingLeft&&(h.style.paddingLeft="0"),h.style.overflow="hidden",u.style.width="100vw",u.style.height="100vh",u.style.top="0px",u.style.left="0px",u.style.position="ab