diff --git a/dist/hr_duo b/dist/hr_duo deleted file mode 160000 index b28b669..0000000 --- a/dist/hr_duo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b28b6694e2f76272da759708c46f1977378ea886 diff --git a/dist/vue-orgchart.common.js b/dist/vue-orgchart.common.js index d592293..96037a7 100644 --- a/dist/vue-orgchart.common.js +++ b/dist/vue-orgchart.common.js @@ -4277,8 +4277,8 @@ var VoBasic = { render: function render() { return {}; } }, - pan: { type: Boolean, default: false }, - zoom: { type: Boolean, default: false }, + pan: { type: Boolean, default: true }, + zoom: { type: Boolean, default: true }, direction: { type: String, default: 't2b' }, verticalDepth: { type: Number }, toggleSiblingsResp: { type: Boolean, default: false }, @@ -4396,8 +4396,8 @@ var VoEdit = { render: function render() { name: 'VoEdit', props: { data: { type: Object }, - pan: { type: Boolean, default: false }, - zoom: { type: Boolean, default: false }, + pan: { type: Boolean, default: true }, + zoom: { type: Boolean, default: true }, direction: { type: String, default: 't2b' }, verticalDepth: { type: Number }, toggleSiblingsResp: { type: Boolean, default: false }, diff --git a/dist/vue-orgchart.common.min.js b/dist/vue-orgchart.common.min.js index ef20d51..53407e6 100644 --- a/dist/vue-orgchart.common.min.js +++ b/dist/vue-orgchart.common.min.js @@ -1 +1 @@ -"use strict";function listCacheClear(){this.__data__=[],this.size=0}function eq(e,t){return e===t||e!=e&&t!=t}function assocIndexOf(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}function listCacheDelete(e){var t=this.__data__,r=assocIndexOf(t,e);if(r<0)return!1;return r==t.length-1?t.pop():splice.call(t,r,1),--this.size,!0}function listCacheGet(e){var t=this.__data__,r=assocIndexOf(t,e);return r<0?void 0:t[r][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function ListCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e<=MAX_SAFE_INTEGER}function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}function stubFalse(){return!1}function isPlainObject(e){if(!isObjectLike(e)||baseGetTag(e)!=objectTag)return!1;var t=getPrototype(e);if(null===t)return!0;var r=hasOwnProperty$5.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&funcToString$2.call(r)==objectCtorString}function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!typedArrayTags[baseGetTag(e)]}function baseUnary(e){return function(t){return e(t)}}function assignValue(e,t,r){var n=e[t];hasOwnProperty$6.call(e,t)&&eq(n,r)&&(void 0!==r||t in e)||baseAssignValue(e,t,r)}function copyObject(e,t,r,n){var i=!r;r||(r={});for(var a=-1,o=t.length;++a-1&&e%1==0&&e0){if(++t>=HOT_COUNT)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function baseRest(e,t){return setToString(overRest(e,t,identity),e+"")}function isIterateeCall(e,t,r){if(!isObject(r))return!1;var n=typeof t;return!!("number"==n?isArrayLike(r)&&isIndex(t,r.length):"string"==n&&t in r)&&eq(r[t],e)}function createAssigner(e){return baseRest(function(t,r){var n=-1,i=r.length,a=i>1?r[i-1]:void 0,o=i>2?r[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,o&&isIterateeCall(r[0],r[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++n0?t.split(" ").forEach(function(t){return e.classList.add(t)}):e.classList.add(t)})}},{key:"_removeClass",value:function(e,t){e.forEach(function(e){t.indexOf(" ")>0?t.split(" ").forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t)})}},{key:"_css",value:function(e,t,r){e.forEach(function(e){e.style[t]=r})}},{key:"_removeAttr",value:function(e,t){e.forEach(function(e){e.removeAttribute(t)})}},{key:"_one",value:function(e,t,r,n){e&&e.addEventListener(t,function i(a){try{r.call(n,a)}finally{e.removeEventListener(t,i)}})}},{key:"_getDescElements",value:function(e,t){var r=[];return e.forEach(function(e){return r.push.apply(r,toConsumableArray(e.querySelectorAll(t)))}),r}},{key:"_getJSON",value:function(e){return new Promise(function(t,r){var n=new XMLHttpRequest;n.open("GET",e),n.onreadystatechange=function(){4===this.readyState&&(200===this.status?t(JSON.parse(this.response)):r(new Error(this.statusText)))},n.responseType="json",n.setRequestHeader("Content-Type","application/json"),n.send()})}},{key:"_buildJsonDS",value:function(e){var t=this,r={name:e.firstChild.textContent.trim(),relationship:("LI"===e.parentNode.parentNode.nodeName?"1":"0")+(e.parentNode.children.length>1?1:0)+(e.children.length?1:0)};return e.id&&(r.id=e.id),e.querySelector("ul")&&Array.from(e.querySelector("ul").children).forEach(function(e){r.children||(r.children=[]),r.children.push(t._buildJsonDS(e))}),r}},{key:"_attachRel",value:function(e,t){if(e.relationship=t+(e.children&&e.children.length>0?1:0),e.children){var r=!0,n=!1,i=void 0;try{for(var a,o=e.children[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value;this._attachRel(s,"1"+(e.children.length>1?1:0))}}catch(e){n=!0,i=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw i}}}return e}},{key:"_repaint",value:function(e){e&&(e.style.offsetWidth=e.offsetWidth)}},{key:"_isInAction",value:function(e){return e.querySelector(":scope > .edge").className.indexOf("fa-")>-1}},{key:"_getNodeState",value:function(e,t){var r=this,n=void 0,i={exist:!1,visible:!1};return"parent"===t?((n=this._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}))&&(i.exist=!0),i.exist&&this._isVisible(n.parentNode.children[0])&&(i.visible=!0)):"children"===t?((n=this._closest(e,function(e){return"TR"===e.nodeName}).nextElementSibling)&&(i.exist=!0),i.exist&&this._isVisible(n)&&(i.visible=!0)):"siblings"===t&&((n=this._siblings(this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode)).length&&(i.exist=!0),i.exist&&n.some(function(e){return r._isVisible(e)})&&(i.visible=!0)),i}},{key:"getRelatedNodes",value:function(e,t){return"parent"===t?this._closest(e,function(e){return e.classList.contains("nodes")}).parentNode.children[0].querySelector(".node"):"children"===t?Array.from(this._closest(e,function(e){return"TABLE"===e.nodeName}).lastChild.children).map(function(e){return e.querySelector(".node")}):"siblings"===t?this._siblings(this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode).map(function(e){return e.querySelector(".node")}):[]}},{key:"_switchHorizontalArrow",value:function(e){var t=this.options,r=e.querySelector(".leftEdge"),n=e.querySelector(".rightEdge"),i=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;if(t.toggleSiblingsResp&&(void 0===t.ajaxURL||this._closest(e,function(e){return e.classList.contains(".nodes")}).dataset.siblingsLoaded)){var a=i.previousElementSibling,o=i.nextElementSibling;a&&(a.classList.contains("hidden")?(r.classList.add("fa-chevron-left"),r.classList.remove("fa-chevron-right")):(r.classList.add("fa-chevron-right"),r.classList.remove("fa-chevron-left"))),o&&(o.classList.contains("hidden")?(n.classList.add("fa-chevron-right"),n.classList.remove("fa-chevron-left")):(n.classList.add("fa-chevron-left"),n.classList.remove("fa-chevron-right")))}else{var s=this._siblings(i),c=!!s.length&&!s.some(function(e){return e.classList.contains("hidden")});r.classList.toggle("fa-chevron-right",c),r.classList.toggle("fa-chevron-left",!c),n.classList.toggle("fa-chevron-left",c),n.classList.toggle("fa-chevron-right",!c)}}},{key:"_hoverNode",value:function(e){var t=e.target,r=!1,n=t.querySelector(":scope > .topEdge"),i=t.querySelector(":scope > .bottomEdge"),a=t.querySelector(":scope > .leftEdge");"mouseenter"===e.type?(n&&(r=this._getNodeState(t,"parent").visible,n.classList.toggle("fa-chevron-up",!r),n.classList.toggle("fa-chevron-down",r)),i&&(r=this._getNodeState(t,"children").visible,i.classList.toggle("fa-chevron-down",!r),i.classList.toggle("fa-chevron-up",r)),a&&this._switchHorizontalArrow(t)):Array.from(t.querySelectorAll(":scope > .edge")).forEach(function(e){e.classList.remove("fa-chevron-up","fa-chevron-down","fa-chevron-right","fa-chevron-left")})}},{key:"_clickNode",value:function(e){var t=e.currentTarget,r=this.chart.querySelector(".focused");r&&r.classList.remove("focused"),t.classList.add("focused")}},{key:"_buildParentNode",value:function(e,t,r){var n=this,i=document.createElement("table");t.relationship=t.relationship||"001",this._createNode(t,0).then(function(e){var t=n.chart;e.classList.remove("slide-up"),e.classList.add("slide-down");var a=document.createElement("tr"),o=document.createElement("tr"),s=document.createElement("tr"),c=document.createElement("tr");a.setAttribute("class","hidden"),a.innerHTML='',i.appendChild(a),o.setAttribute("class","lines hidden"),o.innerHTML='
',i.appendChild(o),s.setAttribute("class","lines hidden"),s.innerHTML='  ',i.appendChild(s),c.setAttribute("class","nodes"),c.innerHTML='',i.appendChild(c),i.querySelector("td").appendChild(e),t.insertBefore(i,t.children[0]),i.children[3].children[0].appendChild(t.lastChild),r()}).catch(function(e){console.error("Failed to create parent node",e)})}},{key:"_switchVerticalArrow",value:function(e){e.classList.toggle("fa-chevron-up"),e.classList.toggle("fa-chevron-down")}},{key:"showParent",value:function(e){var t=this._prevAll(this._closest(e,function(e){return e.classList.contains("nodes")}));this._removeClass(t,"hidden"),this._addClass(Array(t[0].children).slice(1,-1),"hidden");var r=t[2].querySelector(".node");this._one(r,"transitionend",function(){r.classList.remove("slide"),this._isInAction(e)&&this._switchVerticalArrow(e.querySelector(":scope > .topEdge"))},this),this._repaint(r),r.classList.add("slide"),r.classList.remove("slide-down")}},{key:"showSiblings",value:function(e,t){var r=this,n=[],i=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;n=t?"left"===t?this._prevAll(i):this._nextAll(i):this._siblings(i),this._removeClass(n,"hidden");var a=this._prevAll(this._closest(e,function(e){return e.classList.contains("nodes")}));if(i=Array.from(a[0].querySelectorAll(":scope > .hidden")),t?this._removeClass(i.slice(0,2*n.length),"hidden"):this._removeClass(i,"hidden"),!this._getNodeState(e,"parent").visible){this._removeClass(a,"hidden");var o=a[2].querySelector(".node");this._one(o,"transitionend",function(e){e.target.classList.remove("slide")},this),this._repaint(o),o.classList.add("slide"),o.classList.remove("slide-down")}n.forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){r._isVisible(e)&&(e.classList.add("slide"),e.classList.remove("slide-left","slide-right"))})}),this._one(n[0].querySelector(".slide"),"transitionend",function(){var t=this;n.forEach(function(e){t._removeClass(Array.from(e.querySelectorAll(".slide")),"slide")}),this._isInAction(e)&&(this._switchHorizontalArrow(e),e.querySelector(".topEdge").classList.remove("fa-chevron-up"),e.querySelector(".topEdge").classList.add("fa-chevron-down"))},this)}},{key:"hideSiblings",value:function(e,t){var r=this,n=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;if(this._siblings(n).forEach(function(e){e.querySelector(".spinner")&&(r.chart.dataset.inAjax=!1)}),!t||t&&"left"===t){this._prevAll(n).forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){r._isVisible(e)&&e.classList.add("slide","slide-right")})})}if(!t||t&&"left"!==t){this._nextAll(n).forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){r._isVisible(e)&&e.classList.add("slide","slide-left")})})}var i=[];this._siblings(n).forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelectorAll(".slide")))});var a=[],o=!0,s=!1,c=void 0;try{for(var l,d=i[Symbol.iterator]();!(o=(l=d.next()).done);o=!0){var u=l.value,h=this._closest(u,function(e){return e.classList.contains("nodes")}).previousElementSibling;a.push(h),a.push(h.previousElementSibling)}}catch(e){s=!0,c=e}finally{try{!o&&d.return&&d.return()}finally{if(s)throw c}}(a=[].concat(toConsumableArray(new Set(a)))).forEach(function(e){e.style.visibility="hidden"}),this._one(i[0],"transitionend",function(r){var o=this;a.forEach(function(e){e.removeAttribute("style")});var s=[];s=t?"left"===t?this._prevAll(n,":not(.hidden)"):this._nextAll(n,":not(.hidden)"):this._siblings(n);var c=Array.from(this._closest(n,function(e){return e.classList.contains("nodes")}).previousElementSibling.querySelectorAll(":scope > :not(.hidden)")).slice(1,t?2*s.length+1:-1);this._addClass(c,"hidden"),this._removeClass(i,"slide"),s.forEach(function(e){Array.from(e.querySelectorAll(".node")).slice(1).forEach(function(e){o._isVisible(e)&&(e.classList.remove("slide-left","slide-right"),e.classList.add("slide-up"))})}),s.forEach(function(e){o._addClass(Array.from(e.querySelectorAll(".lines")),"hidden"),o._addClass(Array.from(e.querySelectorAll(".nodes")),"hidden"),o._addClass(Array.from(e.querySelectorAll(".verticalNodes")),"hidden")}),this._addClass(s,"hidden"),this._isInAction(e)&&this._switchHorizontalArrow(e)},this)}},{key:"hideParent",value:function(e){var t=Array.from(this._closest(e,function(e){return e.classList.contains("nodes")}).parentNode.children).slice(0,3);t[0].querySelector(".spinner")&&(this.chart.dataset.inAjax=!1),this._getNodeState(e,"siblings").visible&&this.hideSiblings(e);var r=t.slice(1);this._css(r,"visibility","hidden");var n=t[0].querySelector(".node"),i=this._getNodeState(n,"parent").visible;n&&this._isVisible(n)&&(n.classList.add("slide","slide-down"),this._one(n,"transitionend",function(){n.classList.remove("slide"),this._removeAttr(r,"style"),this._addClass(t,"hidden")},this)),n&&i&&this.hideParent(n)}},{key:"addParent",value:function(e,t){var r=this;this._buildParentNode(e,t,function(){if(!e.querySelector(":scope > .topEdge")){var t=document.createElement("i");t.setAttribute("class","edge verticalEdge topEdge fa"),e.appendChild(t)}r.showParent(e)})}},{key:"_startLoading",value:function(e,t){var r=this.options,n=this.chart;if(void 0!==n.dataset.inAjax&&"true"===n.dataset.inAjax)return!1;e.classList.add("hidden");var i=document.createElement("i");i.setAttribute("class","fa fa-circle-o-notch fa-spin spinner"),t.appendChild(i),this._addClass(Array.from(t.querySelectorAll(":scope > *:not(.spinner)")),"hazy"),n.dataset.inAjax=!0;var a=this.chartContainer.querySelector(".oc-export-btn"+(""!==r.chartClass?"."+r.chartClass:""));return a&&(a.disabled=!0),!0}},{key:"_endLoading",value:function(e,t){var r=this.options;e.classList.remove("hidden"),t.querySelector(":scope > .spinner").remove(),this._removeClass(Array.from(t.querySelectorAll(":scope > .hazy")),"hazy"),this.chart.dataset.inAjax=!1;var n=this.chartContainer.querySelector(".oc-export-btn"+(""!==r.chartClass?"."+r.chartClass:""));n&&(n.disabled=!1)}},{key:"_clickTopEdge",value:function(e){e.stopPropagation();var t=this,r=e.target,n=r.parentNode,i=this._getNodeState(n,"parent"),a=this.options;if(i.exist){var o=this._closest(n,function(e){return e.classList.contains("nodes")}).parentNode.firstChild.querySelector(".node");if(o.classList.contains("slide"))return;i.visible?(this.hideParent(n),this._one(o,"transitionend",function(){this._isInAction(n)&&(this._switchVerticalArrow(r),this._switchHorizontalArrow(n))},this)):this.showParent(n)}else{var s=r.parentNode.id;this._startLoading(r,n)&&this._getJSON("function"==typeof a.ajaxURL.parent?a.ajaxURL.parent(n.dataset.source):a.ajaxURL.parent+s).then(function(e){"true"===t.chart.dataset.inAjax&&Object.keys(e).length&&t.addParent(n,e)}).catch(function(e){console.error("Failed to get parent node data.",e)}).finally(function(){t._endLoading(r,n)})}}},{key:"hideChildren",value:function(e){var t=this,r=this._nextAll(e.parentNode.parentNode),n=r[r.length-1],i=[];n.querySelector(".spinner")&&(this.chart.dataset.inAjax=!1);var a=Array.from(n.querySelectorAll(".node")).filter(function(e){return t._isVisible(e)}),o=n.classList.contains("verticalNodes");o||(a.forEach(function(e){Array.prototype.push.apply(i,t._prevAll(t._closest(e,function(e){return e.classList.contains("nodes")}),".lines"))}),i=[].concat(toConsumableArray(new Set(i))),this._css(i,"visibility","hidden")),this._one(a[0],"transitionend",function(s){this._removeClass(a,"slide"),o?t._addClass(r,"hidden"):(i.forEach(function(e){e.removeAttribute("style"),e.classList.add("hidden"),e.parentNode.lastChild.classList.add("hidden")}),this._addClass(Array.from(n.querySelectorAll(".verticalNodes")),"hidden")),this._isInAction(e)&&this._switchVerticalArrow(e.querySelector(".bottomEdge"))},this),this._addClass(a,"slide slide-up")}},{key:"showChildren",value:function(e){var t=this,r=this,n=this._nextAll(e.parentNode.parentNode),i=[];this._removeClass(n,"hidden"),n.some(function(e){return e.classList.contains("verticalNodes")})?n.forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelectorAll(".node")).filter(function(e){return r._isVisible(e)}))}):Array.from(n[2].children).forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelector("tr").querySelectorAll(".node")).filter(function(e){return r._isVisible(e)}))}),this._repaint(i[0]),this._one(i[0],"transitionend",function(r){t._removeClass(i,"slide"),t._isInAction(e)&&t._switchVerticalArrow(e.querySelector(".bottomEdge"))},this),this._addClass(i,"slide"),this._removeClass(i,"slide-up")}},{key:"_buildChildNode",value:function(e,t,r){var n=t.children||t.siblings;e.querySelector("td").setAttribute("colSpan",2*n.length),this.buildHierarchy(e,{children:n},0,r)}},{key:"addChildren",value:function(e,t){var r=this,n=this.options,i=0;this.chart.dataset.inEdit="addChildren",this._buildChildNode.call(this,this._closest(e,function(e){return"TABLE"===e.nodeName}),t,function(){if(++i===t.children.length){if(!e.querySelector(".bottomEdge")){var a=document.createElement("i");a.setAttribute("class","edge verticalEdge bottomEdge fa"),e.appendChild(a)}if(!e.querySelector(".symbol")){var o=document.createElement("i");o.setAttribute("class","fa "+n.parentNodeSymbol+" symbol"),e.querySelector(":scope > .title").appendChild(o)}r.showChildren(e),r.chart.dataset.inEdit=""}})}},{key:"_clickBottomEdge",value:function(e){var t=this;e.stopPropagation();var r=this,n=this.options,i=e.target,a=i.parentNode,o=this._getNodeState(a,"children");if(o.exist){var s=this._closest(a,function(e){return"TR"===e.nodeName}).parentNode.lastChild;if(Array.from(s.querySelectorAll(".node")).some(function(e){return t._isVisible(e)&&e.classList.contains("slide")}))return;o.visible?this.hideChildren(a):this.showChildren(a)}else{var c=i.parentNode.id;this._startLoading(i,a)&&this._getJSON("function"==typeof n.ajaxURL.children?n.ajaxURL.children(a.dataset.source):n.ajaxURL.children+c).then(function(e){"true"===r.chart.dataset.inAjax&&e.children.length&&r.addChildren(a,e)}).catch(function(e){console.error("Failed to get children nodes data",e)}).finally(function(){r._endLoading(i,a)})}}},{key:"_complementLine",value:function(e,t,r){var n=e.parentNode.parentNode.children;n[0].children[0].setAttribute("colspan",2*t),n[1].children[0].setAttribute("colspan",2*t);for(var i=0;i1?Math.floor(s/2-1):0;if("TD"===e.parentNode.nodeName){var l=this._prevAll(e.parentNode.parentNode);l[0].remove(),l[1].remove();var d=0;i._buildChildNode.call(i,i._closest(e.parentNode,function(e){return"TABLE"===e.nodeName}),t,function(){if(++d===a){var t=Array.from(i._closest(e.parentNode,function(e){return"TABLE"===e.nodeName}).lastChild.children);if(o>1){var n=e.parentNode.parentNode;Array.from(n.children).forEach(function(e){t[0].parentNode.insertBefore(e,t[0])}),n.remove(),i._complementLine(t[0],s,o),i._addClass(t,"hidden"),t.forEach(function(e){i._addClass(e.querySelectorAll(".node"),"slide-left")})}else{var l=e.parentNode.parentNode;t[c].parentNode.insertBefore(e.parentNode,t[c+1]),l.remove(),i._complementLine(t[c],s,1),i._addClass(t,"hidden"),i._addClass(i._getDescElements(t.slice(0,c+1),".node"),"slide-right"),i._addClass(i._getDescElements(t.slice(c+1),".node"),"slide-left")}r()}})}else{var u=0;i.buildHierarchy.call(i,i.chart,t,0,function(){if(++u===s){var t=e.nextElementSibling.children[3].children[c],a=document.createElement("td");a.setAttribute("colspan",2),a.appendChild(e),t.parentNode.insertBefore(a,t.nextElementSibling),i._complementLine(t,s,1);var o=i._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0];o.classList.add("hidden"),i._addClass(Array.from(o.querySelectorAll(".node")),"slide-down");var l=n._siblings(e.parentNode);i._addClass(l,"hidden"),i._addClass(i._getDescElements(l.slice(0,c),".node"),"slide-right"),i._addClass(i._getDescElements(l.slice(c),".node"),"slide-left"),r()}})}}},{key:"addSiblings",value:function(e,t){var r=this;this.chart.dataset.inEdit="addSiblings",this._buildSiblingNode.call(this,this._closest(e,function(e){return"TABLE"===e.nodeName}),t,function(){if(r._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}).dataset.siblingsLoaded=!0,!e.querySelector(".leftEdge")){var t=document.createElement("i"),n=document.createElement("i");t.setAttribute("class","edge horizontalEdge rightEdge fa"),e.appendChild(t),n.setAttribute("class","edge horizontalEdge leftEdge fa"),e.appendChild(n)}r.showSiblings(e),r.chart.dataset.inEdit=""})}},{key:"removeNodes",value:function(e){var t=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode,r=this._siblings(t.parentNode);"TD"===t.nodeName?this._getNodeState(e,"siblings").exist?(r[2].querySelector(".topLine").nextElementSibling.remove(),r[2].querySelector(".topLine").remove(),r[0].children[0].setAttribute("colspan",r[2].children.length),r[1].children[0].setAttribute("colspan",r[2].children.length),t.remove()):(r[0].children[0].removeAttribute("colspan"),r[0].querySelector(".bottomEdge").remove(),this._siblings(r[0]).forEach(function(e){return e.remove()})):Array.from(t.parentNode.children).forEach(function(e){return e.remove()})}},{key:"_clickHorizontalEdge",value:function(e){var t=this;e.stopPropagation();var r=this,n=this.options,i=e.target,a=i.parentNode,o=this._getNodeState(a,"siblings");if(o.exist){var s=this._closest(a,function(e){return"TABLE"===e.nodeName}).parentNode;if(this._siblings(s).some(function(e){var r=e.querySelector(".node");return t._isVisible(r)&&r.classList.contains("slide")}))return;if(n.toggleSiblingsResp){var c=this._closest(a,function(e){return"TABLE"===e.nodeName}).parentNode.previousElementSibling,l=this._closest(a,function(e){return"TABLE"===e.nodeName}).parentNode.nextElementSibling;i.classList.contains("leftEdge")?c&&c.classList.contains("hidden")?this.showSiblings(a,"left"):this.hideSiblings(a,"left"):l&&l.classList.contains("hidden")?this.showSiblings(a,"right"):this.hideSiblings(a,"right")}else o.visible?this.hideSiblings(a):this.showSiblings(a)}else{var d=i.parentNode.id,u=this._getNodeState(a,"parent").exist?"function"==typeof n.ajaxURL.siblings?n.ajaxURL.siblings(JSON.parse(a.dataset.source)):n.ajaxURL.siblings+d:"function"==typeof n.ajaxURL.families?n.ajaxURL.families(JSON.parse(a.dataset.source)):n.ajaxURL.families+d;this._startLoading(i,a)&&this._getJSON(u).then(function(e){"true"===r.chart.dataset.inAjax&&(e.siblings||e.children)&&r.addSiblings(a,e)}).catch(function(e){console.error("Failed to get sibling nodes data",e)}).finally(function(){r._endLoading(i,a)})}}},{key:"_clickToggleButton",value:function(e){var t=this,r=e.target,n=r.parentNode.nextElementSibling,i=Array.from(n.querySelectorAll(".node")),a=Array.from(n.children).map(function(e){return e.querySelector(".node")});a.some(function(e){return e.classList.contains("slide")})||(r.classList.toggle("fa-plus-square"),r.classList.toggle("fa-minus-square"),i[0].classList.contains("slide-up")?(n.classList.remove("hidden"),this._repaint(a[0]),this._addClass(a,"slide"),this._removeClass(a,"slide-up"),this._one(a[0],"transitionend",function(){t._removeClass(a,"slide")})):(this._addClass(i,"slide slide-up"),this._one(i[0],"transitionend",function(){t._removeClass(i,"slide"),i.forEach(function(e){t._closest(e,function(e){return"UL"===e.nodeName}).classList.add("hidden")})}),i.forEach(function(e){var r=Array.from(e.querySelectorAll(".toggleBtn"));t._removeClass(r,"fa-minus-square"),t._addClass(r,"fa-plus-square")})))}},{key:"_dispatchClickEvent",value:function(e){var t=e.target.classList;t.contains("topEdge")?this._clickTopEdge(e):t.contains("rightEdge")||t.contains("leftEdge")?this._clickHorizontalEdge(e):t.contains("bottomEdge")?this._clickBottomEdge(e):t.contains("toggleBtn")?this._clickToggleButton(e):this._clickNode(e)}},{key:"_onDragStart",value:function(e){var t=e.target,r=this.options,n=/firefox/.test(window.navigator.userAgent.toLowerCase());if(n&&e.dataTransfer.setData("text/html","hack for firefox"),this.chart.style.transform){var i=void 0,a=void 0;document.querySelector(".ghost-node")?a=(i=this.chart.querySelector(":scope > .ghost-node")).children[0]:((i=document.createElementNS("http://www.w3.org/2000/svg","svg")).classList.add("ghost-node"),a=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.appendChild(a),this.chart.appendChild(i));var o=this.chart.style.transform.split(","),s=Math.abs(window.parseFloat("t2b"===r.direction||"b2t"===r.direction?o[0].slice(o[0].indexOf("(")+1):o[1]));i.setAttribute("width",t.offsetWidth),i.setAttribute("height",t.offsetHeight),a.setAttribute("x",5*s),a.setAttribute("y",5*s),a.setAttribute("width",120*s),a.setAttribute("height",40*s),a.setAttribute("rx",4*s),a.setAttribute("ry",4*s),a.setAttribute("stroke-width",1*s);var c=e.offsetX*s,l=e.offsetY*s;if("l2r"===r.direction?(c=e.offsetY*s,l=e.offsetX*s):"r2l"===r.direction?(c=t.offsetWidth-e.offsetY*s,l=e.offsetX*s):"b2t"===r.direction&&(c=t.offsetWidth-e.offsetX*s,l=t.offsetHeight-e.offsetY*s),n){var d=document.createElement("img");d.src="data:image/svg+xml;utf8,"+(new XMLSerializer).serializeToString(i),e.dataTransfer.setDragImage(d,c,l),a.setAttribute("fill","rgb(255, 255, 255)"),a.setAttribute("stroke","rgb(191, 0, 0)")}else e.dataTransfer.setDragImage(i,c,l)}var u=e.target,h=null;null!==this._closest(u,function(e){return e.classList&&e.classList.contains("nodes")})&&(h=this._closest(u,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0].querySelector(".node"));var f=Array.from(this._closest(u,function(e){return"TABLE"===e.nodeName}).querySelectorAll(".node"));this.dragged=u,Array.from(this.chart.querySelectorAll(".node")).forEach(function(e){f.includes(e)||(r.dropCriteria?r.dropCriteria(u,h,e)&&e.classList.add("allowedDrop"):e.classList.add("allowedDrop"))})}},{key:"_onDragOver",value:function(e){e.preventDefault();e.currentTarget.classList.contains("allowedDrop")||(e.dataTransfer.dropEffect="none")}},{key:"_onDragEnd",value:function(e){Array.from(this.chart.querySelectorAll(".allowedDrop")).forEach(function(e){e.classList.remove("allowedDrop")})}},{key:"_onDrop",value:function(e){var t=e.currentTarget,r=this.chart,n=this.dragged,i=this._closest(n,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0].children[0];if(this._removeClass(Array.from(r.querySelectorAll(".allowedDrop")),"allowedDrop"),t.parentNode.parentNode.nextElementSibling){var a=window.parseInt(t.parentNode.colSpan)+2;if(t.parentNode.setAttribute("colspan",a),t.parentNode.parentNode.nextElementSibling.children[0].setAttribute("colspan",a),!n.querySelector(".horizontalEdge")){var o=document.createElement("i"),s=document.createElement("i");o.setAttribute("class","edge horizontalEdge rightEdge fa"),n.appendChild(o),s.setAttribute("class","edge horizontalEdge leftEdge fa"),n.appendChild(s)}var c=t.parentNode.parentNode.nextElementSibling.nextElementSibling,l=document.createElement("td"),d=document.createElement("td");l.setAttribute("class","leftLine topLine"),l.innerHTML=" ",c.insertBefore(l,c.children[1]),d.setAttribute("class","rightLine topLine"),d.innerHTML=" ",c.insertBefore(d,c.children[2]),c.nextElementSibling.appendChild(this._closest(n,function(e){return"TABLE"===e.nodeName}).parentNode);var u=this._siblings(this._closest(n,function(e){return"TABLE"===e.nodeName}).parentNode).map(function(e){return e.querySelector(".node")});if(1===u.length){var h=document.createElement("i"),f=document.createElement("i");h.setAttribute("class","edge horizontalEdge rightEdge fa"),u[0].appendChild(h),f.setAttribute("class","edge horizontalEdge leftEdge fa"),u[0].appendChild(f)}}else{var p=document.createElement("i");p.setAttribute("class","edge verticalEdge bottomEdge fa"),t.appendChild(p),t.parentNode.setAttribute("colspan",2);var g=this._closest(t,function(e){return"TABLE"===e.nodeName}),y=document.createElement("tr"),v=document.createElement("tr"),b=document.createElement("tr");y.setAttribute("class","lines"),y.innerHTML='
',g.appendChild(y),v.setAttribute("class","lines"),v.innerHTML='  ',g.appendChild(v),b.setAttribute("class","nodes"),g.appendChild(b),Array.from(n.querySelectorAll(".horizontalEdge")).forEach(function(e){n.removeChild(e)});var m=this._closest(n,function(e){return"TABLE"===e.nodeName}).parentNode;b.appendChild(m)}var _=window.parseInt(i.colSpan);if(_>2){i.setAttribute("colspan",_-2),i.parentNode.nextElementSibling.children[0].setAttribute("colspan",_-2);var A=i.parentNode.nextElementSibling.nextElementSibling;A.children[1].remove(),A.children[1].remove();var S=Array.from(i.parentNode.parentNode.children[3].children).map(function(e){return e.querySelector(".node")});1===S.length&&(S[0].querySelector(".leftEdge").remove(),S[0].querySelector(".rightEdge").remove())}else i.removeAttribute("colspan"),i.querySelector(".node").removeChild(i.querySelector(".bottomEdge")),Array.from(i.parentNode.parentNode.children).slice(1).forEach(function(e){return e.remove()});var E=new CustomEvent("nodedropped.orgchart",{detail:{draggedNode:n,dragZone:i.children[0],dropZone:t}});r.dispatchEvent(E)}},{key:"_createNode",value:function(e,t){var r=this,n=this.options;return new Promise(function(i,a){if(e.children){var o=!0,s=!1,c=void 0;try{for(var l,d=e.children[Symbol.iterator]();!(o=(l=d.next()).done);o=!0){l.value.parentId=e.id}}catch(e){s=!0,c=e}finally{try{!o&&d.return&&d.return()}finally{if(s)throw c}}}var u=document.createElement("div");delete e.children,u.dataset.source=JSON.stringify(e),e[n.nodeId]&&(u.id=e[n.nodeId]);var h=r.chart.dataset.inEdit,f=void 0;f=h?"addChildren"===h?" slide-up":"":t>=n.depth?" slide-up":"",u.setAttribute("class","node "+(e.className||"")+f),n.draggable&&u.setAttribute("draggable",!0),e.parentId&&u.setAttribute("data-parent",e.parentId),u.innerHTML='\n
'+e[n.nodeTitle]+"
\n "+(n.nodeContent?'
'+e[n.nodeContent]+"
":"")+"\n ";var p=e.relationship||"";if(n.verticalDepth&&t+2>n.verticalDepth){if(t+1>=n.verticalDepth&&Number(p.substr(2,1))){var g=document.createElement("i"),y=t+1>=n.depth?"plus":"minus";g.setAttribute("class","toggleBtn fa fa-"+y+"-square"),u.appendChild(g)}}else{if(Number(p.substr(0,1))){var v=document.createElement("i");v.setAttribute("class","edge verticalEdge topEdge fa"),u.appendChild(v)}if(Number(p.substr(1,1))){var b=document.createElement("i"),m=document.createElement("i");b.setAttribute("class","edge horizontalEdge rightEdge fa"),u.appendChild(b),m.setAttribute("class","edge horizontalEdge leftEdge fa"),u.appendChild(m)}if(Number(p.substr(2,1))){var _=document.createElement("i"),A=document.createElement("i"),S=u.querySelector(":scope > .title");_.setAttribute("class","edge verticalEdge bottomEdge fa"),u.appendChild(_),A.setAttribute("class","fa "+n.parentNodeSymbol+" symbol"),S.insertBefore(A,S.children[0])}}n.toggleCollapse&&(u.addEventListener("mouseenter",r._hoverNode.bind(r)),u.addEventListener("mouseleave",r._hoverNode.bind(r)),u.addEventListener("click",r._dispatchClickEvent.bind(r))),n.draggable&&(u.addEventListener("dragstart",r._onDragStart.bind(r)),u.addEventListener("dragover",r._onDragOver.bind(r)),u.addEventListener("dragend",r._onDragEnd.bind(r)),u.addEventListener("drop",r._onDrop.bind(r))),n.createNode&&n.createNode(u,e),i(u)})}},{key:"buildHierarchy",value:function(e,t,r,n){var i=this,a=this.options,o=void 0,s=t.children,c=a.verticalDepth&&r+1>=a.verticalDepth;if(Object.keys(t).length>1&&(o=c?e:document.createElement("table"),c||e.appendChild(o),this._createNode(t,r).then(function(e){if(c)o.insertBefore(e,o.firstChild);else{var t=document.createElement("tr");t.innerHTML="\n \n \n ",t.children[0].appendChild(e),o.insertBefore(t,o.children[0]?o.children[0]:null)}n&&n()}).catch(function(e){console.error("Failed to creat node",e)})),s&&0!==s.length){1===Object.keys(t).length&&(o=e);var l=void 0,d=a.verticalDepth&&r+2>=a.verticalDepth,u=i.chart.dataset.inEdit;if(l=u?"addSiblings"===u?"":" hidden":r+1>=a.depth?" hidden":"",!d){var h=document.createElement("tr");h.setAttribute("class","lines"+l),h.innerHTML='\n \n
\n \n ',o.appendChild(h)}var f=document.createElement("tr");f.setAttribute("class","lines"+l),f.innerHTML='\n  \n '+s.slice(1).map(function(){return'\n  \n  \n '}).join("")+'\n  \n ';var p=void 0;if(d)if(p=document.createElement("ul"),l&&p.classList.add(l.trim()),r+2===a.verticalDepth){var g=document.createElement("tr");g.setAttribute("class","verticalNodes"+l),g.innerHTML="",g.firstChild.appendChild(p),o.appendChild(g)}else o.appendChild(p);else(p=document.createElement("tr")).setAttribute("class","nodes"+l),o.appendChild(f),o.appendChild(p);s.forEach(function(e){var t=void 0;d?t=document.createElement("li"):(t=document.createElement("td")).setAttribute("colspan",2),p.appendChild(t),i.buildHierarchy(t,e,r+1,n)})}}},{key:"_clickChart",value:function(e){!this._closest(e.target,function(e){return e.classList&&e.classList.contains("node")})&&this.chart.querySelector(".node.focused")&&this.chart.querySelector(".node.focused").classList.remove("focused")}},{key:"_clickExportButton",value:function(){var e=this.options,t=this.chartContainer,r=t.querySelector(":scope > .mask"),n=t.querySelector(".orgchart:not(.hidden)"),i="l2r"===e.direction||"r2l"===e.direction;r?r.classList.remove("hidden"):((r=document.createElement("div")).setAttribute("class","mask"),r.innerHTML='',t.appendChild(r)),t.classList.add("canvasContainer"),window.html2canvas(n,{width:i?n.clientHeight:n.clientWidth,height:i?n.clientWidth:n.clientHeight,onclone:function(e){var t=e.querySelector(".canvasContainer");t.style.overflow="visible",t.querySelector(".orgchart:not(.hidden)").transform=""}}).then(function(e){var r=t.querySelector(".oc-download-btn");t.querySelector(".mask").classList.add("hidden"),r.setAttribute("href",e.toDataURL()),r.click()}).catch(function(e){console.error("Failed to export the curent orgchart!",e)}).finally(function(){t.classList.remove("canvasContainer")})}},{key:"_loopChart",value:function(e){var t=this,r={id:e.querySelector(".node").id};return e.children[3]&&Array.from(e.children[3].children).forEach(function(e){r.children||(r.children=[]),r.children.push(t._loopChart(e.firstChild))}),r}},{key:"_loopChartDataset",value:function(e){var t=this,r=JSON.parse(e.querySelector(".node").dataset.source);return e.children[3]&&Array.from(e.children[3].children).forEach(function(e){r.children||(r.children=[]),r.children.push(t._loopChartDataset(e.firstChild))}),r}},{key:"getChartJSON",value:function(){return this.chart.querySelector(".node").id?this._loopChartDataset(this.chart.querySelector("table")):"Error: Nodes of orghcart to be exported must have id attribute!"}},{key:"getHierarchy",value:function(){return this.chart.querySelector(".node").id?this._loopChart(this.chart.querySelector("table")):"Error: Nodes of orghcart to be exported must have id attribute!"}},{key:"_onPanStart",value:function(e){var t=e.currentTarget;if(this._closest(e.target,function(e){return e.classList&&e.classList.contains("node")})||e.touches&&e.touches.length>1)t.dataset.panning=!1;else{t.style.cursor="move",t.dataset.panning=!0;var r=0,n=0,i=window.getComputedStyle(t).transform;if("none"!==i){var a=i.split(",");i.includes("3d")?(r=Number.parseInt(a[12],10),n=Number.parseInt(a[13],10)):(r=Number.parseInt(a[4],10),n=Number.parseInt(a[5],10))}var o=0,s=0;if(e.targetTouches){if(1===e.targetTouches.length)o=e.targetTouches[0].pageX-r,s=e.targetTouches[0].pageY-n;else if(e.targetTouches.length>1)return}else o=e.pageX-r,s=e.pageY-n;t.dataset.panStart=JSON.stringify({startX:o,startY:s}),t.addEventListener("mousemove",this._onPanning.bind(this)),t.addEventListener("touchmove",this._onPanning.bind(this))}}},{key:"_onPanning",value:function(e){var t=e.currentTarget;if("false"!==t.dataset.panning){var r=0,n=0,i=JSON.parse(t.dataset.panStart),a=i.startX,o=i.startY;if(e.targetTouches){if(1===e.targetTouches.length)r=e.targetTouches[0].pageX-a,n=e.targetTouches[0].pageY-o;else if(e.targetTouches.length>1)return}else r=e.pageX-a,n=e.pageY-o;var s=window.getComputedStyle(t).transform;if("none"===s)s.includes("3d")?t.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, "+r+", "+n+", 0, 1)":t.style.transform="matrix(1, 0, 0, 1, "+r+", "+n+")";else{var c=s.split(",");s.includes("3d")?(c[12]=r,c[13]=n):(c[4]=r,c[5]=n+")"),t.style.transform=c.join(",")}}}},{key:"_onPanEnd",value:function(e){var t=this.chart;"true"===t.dataset.panning&&(t.dataset.panning=!1,t.style.cursor="default",document.body.removeEventListener("mousemove",this._onPanning),document.body.removeEventListener("touchmove",this._onPanning))}},{key:"_setChartScale",value:function(e,t){var r=window.getComputedStyle(e).transform;if("none"===r)e.style.transform="scale("+t+","+t+")";else{var n=r.split(",");r.includes("3d")?e.style.transform=r+" scale3d("+t+","+t+", 1)":(n[0]="matrix("+t,n[3]=t,e.style.transform=r+" scale("+t+","+t+")")}e.dataset.scale=t}},{key:"_onWheeling",value:function(e){e.preventDefault();var t=e.deltaY>0?.8:1.2;this._setChartScale(this.chart,t)}},{key:"_getPinchDist",value:function(e){return Math.sqrt((e.touches[0].clientX-e.touches[1].clientX)*(e.touches[0].clientX-e.touches[1].clientX)+(e.touches[0].clientY-e.touches[1].clientY)*(e.touches[0].clientY-e.touches[1].clientY))}},{key:"_onTouchStart",value:function(e){var t=this.chart;if(e.touches&&2===e.touches.length){var r=this._getPinchDist(e);t.dataset.pinching=!0,t.dataset.pinchDistStart=r}}},{key:"_onTouchMove",value:function(e){var t=this.chart;if(t.dataset.pinching){var r=this._getPinchDist(e);t.dataset.pinchDistEnd=r}}},{key:"_onTouchEnd",value:function(e){var t=this.chart;if(t.dataset.pinching){t.dataset.pinching=!1;var r=t.dataset.pinchDistEnd-t.dataset.pinchDistStart;r>0?this._setChartScale(t,1):r<0&&this._setChartScale(t,-1)}}},{key:"name",get:function(){return this._name}}]),e}(),arrayProto=Array.prototype,splice=arrayProto.splice;ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;var freeGlobal="object"==typeof global&&global&&global.Object===Object&&global,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),Symbol$1=root.Symbol,objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty,nativeObjectToString=objectProto$1.toString,symToStringTag$1=Symbol$1?Symbol$1.toStringTag:void 0,objectProto$2=Object.prototype,nativeObjectToString$1=objectProto$2.toString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$1?Symbol$1.toStringTag:void 0,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]",coreJsData=root["__core-js_shared__"],maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto=Object.prototype,funcToString=funcProto.toString,hasOwnProperty=objectProto.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Map=getNative(root,"Map"),nativeCreate=getNative(Object,"create"),HASH_UNDEFINED="__lodash_hash_undefined__",objectProto$3=Object.prototype,hasOwnProperty$2=objectProto$3.hasOwnProperty,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,HASH_UNDEFINED$1="__lodash_hash_undefined__";Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet,MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var LARGE_ARRAY_SIZE=200;Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;var defineProperty$1=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),baseFor=createBaseFor(),freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,Buffer=moduleExports?root.Buffer:void 0,allocUnsafe=Buffer?Buffer.allocUnsafe:void 0,Uint8Array=root.Uint8Array,objectCreate=Object.create,baseCreate=function(){function e(){}return function(t){if(!isObject(t))return{};if(objectCreate)return objectCreate(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),getPrototype=overArg(Object.getPrototypeOf,Object),objectProto$5=Object.prototype,argsTag="[object Arguments]",objectProto$6=Object.prototype,hasOwnProperty$4=objectProto$6.hasOwnProperty,propertyIsEnumerable=objectProto$6.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&hasOwnProperty$4.call(e,"callee")&&!propertyIsEnumerable.call(e,"callee")},isArray=Array.isArray,MAX_SAFE_INTEGER=9007199254740991,freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer$1=moduleExports$1?root.Buffer:void 0,nativeIsBuffer=Buffer$1?Buffer$1.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,objectTag="[object Object]",funcProto$2=Function.prototype,objectProto$7=Object.prototype,funcToString$2=funcProto$2.toString,hasOwnProperty$5=objectProto$7.hasOwnProperty,objectCtorString=funcToString$2.call(Object),argsTag$1="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag$1="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag$1="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag$1]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var freeExports$2="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,freeProcess=moduleExports$2&&freeGlobal.process,nodeUtil=function(){try{return freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}(),nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,objectProto$8=Object.prototype,hasOwnProperty$6=objectProto$8.hasOwnProperty,MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/,objectProto$9=Object.prototype,hasOwnProperty$7=objectProto$9.hasOwnProperty,objectProto$10=Object.prototype,hasOwnProperty$8=objectProto$10.hasOwnProperty,nativeMax=Math.max,baseSetToString=defineProperty$1?function(e,t){return defineProperty$1(e,"toString",{configurable:!0,enumerable:!1,value:constant(t),writable:!0})}:identity,HOT_COUNT=800,HOT_SPAN=16,nativeNow=Date.now,setToString=shortOut(baseSetToString),merge=createAssigner(function(e,t,r){baseMerge(e,t,r)}),mergeOptions=function(e,t){return merge(e,t)},VoBasic={render:function(){var e=this.$createElement;return(this._self._c||e)("div",{staticClass:"vo-basic",attrs:{id:"chart-container"}})},staticRenderFns:[],name:"orgchart",props:{data:{type:Object,default:function(){return{}}},pan:{type:Boolean,default:!1},zoom:{type:Boolean,default:!1},direction:{type:String,default:"t2b"},verticalDepth:{type:Number},toggleSiblingsResp:{type:Boolean,default:!1},ajaxURL:{type:Object},depth:{type:Number,default:999},nodeTitle:{type:String,default:"name"},parentNodeSymbol:{type:String,default:""},nodeContent:{type:String},nodeId:{type:String,default:"id"},createNode:{type:Function},exportButton:{type:Boolean,default:!1},exportButtonName:{type:String,default:"Export"},exportFilename:{type:String},chartClass:{type:String,default:""},draggable:{type:Boolean,default:!1},dropCriteria:{type:Function},toggleCollapse:{type:Boolean,default:!0}},data:function(){return{newData:null,orgchart:null,defaultOptions:{chartContainer:"#chart-container"}}},mounted:function(){null===this.newData&&this.initOrgChart()},methods:{initOrgChart:function(){var e=mergeOptions(this.defaultOptions,this.$props);this.orgchart=new OrgChart$1(e)}},watch:{data:function(e){var t=this;this.newData=e;new Promise(function(t){e&&t()}).then(function(){var e=mergeOptions(t.defaultOptions,t.$props);t.orgchart=new OrgChart$1(e)})}}},closest=function e(t,r){return t&&(r(t)&&t!==document.querySelector(".orgchart")?t:e(t.parentNode,r))},bindEventHandler=function(e,t,r,n){n?document.querySelector(n).addEventListener(t,function(t){(t.target.classList&&t.target.classList.contains(e.slice(1))||closest(t.target,function(t){return t.classList&&t.classList.contains(e.slice(1))}))&&r(t)}):document.querySelectorAll(e).forEach(function(e){e.addEventListener(t,r)})},clickNode=function(e){var t=closest(e.target,function(e){return e.classList&&e.classList.contains("node")}),r=document.getElementById("selected-node");r.value=t.querySelector(".title").textContent,r.dataset.node=t.id},clickChart=function(e){closest(e.target,function(e){return e.classList&&e.classList.contains("node")})||(document.getElementById("selected-node").textContent="")},getId=function(){return 1e3*(new Date).getTime()+Math.floor(1001*Math.random())},VoEdit={render:function(){var e=this.$createElement;return(this._self._c||e)("div",{staticClass:"vo-edit",attrs:{id:"chart-container"}})},staticRenderFns:[],name:"VoEdit",props:{data:{type:Object},pan:{type:Boolean,default:!1},zoom:{type:Boolean,default:!1},direction:{type:String,default:"t2b"},verticalDepth:{type:Number},toggleSiblingsResp:{type:Boolean,default:!1},ajaxURL:{type:Object},depth:{type:Number,default:999},nodeTitle:{type:String,default:"name"},parentNodeSymbol:{type:String,default:""},nodeContent:{type:String},nodeId:{type:String,default:"id"},createNode:{type:Function},exportButton:{type:Boolean,default:!1},exportButtonName:{type:String,default:"Export"},exportFilename:{type:String},chartClass:{type:String,default:""},draggable:{type:Boolean,default:!1},dropCriteria:{type:Function},toggleCollapse:{type:Boolean,default:!0}},data:function(){return{newData:null,orgchart:null,defaultOptions:{chartContainer:"#chart-container",createNode:function(e,t){e.id=getId()}}}},mounted:function(){null===this.newData&&this.initOrgChart(),this.$nextTick(function(){bindEventHandler(".node","click",clickNode,"#chart-container"),bindEventHandler(".orgchart","click",clickChart,"#chart-container")})},methods:{initOrgChart:function(){var e=mergeOptions(this.defaultOptions,this.$props);this.orgchart=new OrgChart$1(e)}},watch:{data:function(e){var t=this;this.newData=e;new Promise(function(t){e&&t()}).then(function(){var e=mergeOptions(t.defaultOptions,t.$props);t.orgchart=new OrgChart$1(e)})}}};"undefined"!=typeof window&&window.Vue&&(window.Vue.component("vo-basic",VoBasic),window.Vue.component("vo-edit",VoEdit)),exports.VoBasic=VoBasic,exports.VoEdit=VoEdit; +"use strict";function listCacheClear(){this.__data__=[],this.size=0}function eq(e,t){return e===t||e!=e&&t!=t}function assocIndexOf(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}function listCacheDelete(e){var t=this.__data__,r=assocIndexOf(t,e);if(r<0)return!1;return r==t.length-1?t.pop():splice.call(t,r,1),--this.size,!0}function listCacheGet(e){var t=this.__data__,r=assocIndexOf(t,e);return r<0?void 0:t[r][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function ListCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e<=MAX_SAFE_INTEGER}function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}function stubFalse(){return!1}function isPlainObject(e){if(!isObjectLike(e)||baseGetTag(e)!=objectTag)return!1;var t=getPrototype(e);if(null===t)return!0;var r=hasOwnProperty$5.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&funcToString$2.call(r)==objectCtorString}function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!typedArrayTags[baseGetTag(e)]}function baseUnary(e){return function(t){return e(t)}}function assignValue(e,t,r){var n=e[t];hasOwnProperty$6.call(e,t)&&eq(n,r)&&(void 0!==r||t in e)||baseAssignValue(e,t,r)}function copyObject(e,t,r,n){var i=!r;r||(r={});for(var a=-1,o=t.length;++a-1&&e%1==0&&e0){if(++t>=HOT_COUNT)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function baseRest(e,t){return setToString(overRest(e,t,identity),e+"")}function isIterateeCall(e,t,r){if(!isObject(r))return!1;var n=typeof t;return!!("number"==n?isArrayLike(r)&&isIndex(t,r.length):"string"==n&&t in r)&&eq(r[t],e)}function createAssigner(e){return baseRest(function(t,r){var n=-1,i=r.length,a=i>1?r[i-1]:void 0,o=i>2?r[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,o&&isIterateeCall(r[0],r[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++n0?t.split(" ").forEach(function(t){return e.classList.add(t)}):e.classList.add(t)})}},{key:"_removeClass",value:function(e,t){e.forEach(function(e){t.indexOf(" ")>0?t.split(" ").forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t)})}},{key:"_css",value:function(e,t,r){e.forEach(function(e){e.style[t]=r})}},{key:"_removeAttr",value:function(e,t){e.forEach(function(e){e.removeAttribute(t)})}},{key:"_one",value:function(e,t,r,n){e&&e.addEventListener(t,function i(a){try{r.call(n,a)}finally{e.removeEventListener(t,i)}})}},{key:"_getDescElements",value:function(e,t){var r=[];return e.forEach(function(e){return r.push.apply(r,toConsumableArray(e.querySelectorAll(t)))}),r}},{key:"_getJSON",value:function(e){return new Promise(function(t,r){var n=new XMLHttpRequest;n.open("GET",e),n.onreadystatechange=function(){4===this.readyState&&(200===this.status?t(JSON.parse(this.response)):r(new Error(this.statusText)))},n.responseType="json",n.setRequestHeader("Content-Type","application/json"),n.send()})}},{key:"_buildJsonDS",value:function(e){var t=this,r={name:e.firstChild.textContent.trim(),relationship:("LI"===e.parentNode.parentNode.nodeName?"1":"0")+(e.parentNode.children.length>1?1:0)+(e.children.length?1:0)};return e.id&&(r.id=e.id),e.querySelector("ul")&&Array.from(e.querySelector("ul").children).forEach(function(e){r.children||(r.children=[]),r.children.push(t._buildJsonDS(e))}),r}},{key:"_attachRel",value:function(e,t){if(e.relationship=t+(e.children&&e.children.length>0?1:0),e.children){var r=!0,n=!1,i=void 0;try{for(var a,o=e.children[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value;this._attachRel(s,"1"+(e.children.length>1?1:0))}}catch(e){n=!0,i=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw i}}}return e}},{key:"_repaint",value:function(e){e&&(e.style.offsetWidth=e.offsetWidth)}},{key:"_isInAction",value:function(e){return e.querySelector(":scope > .edge").className.indexOf("fa-")>-1}},{key:"_getNodeState",value:function(e,t){var r=this,n=void 0,i={exist:!1,visible:!1};return"parent"===t?((n=this._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}))&&(i.exist=!0),i.exist&&this._isVisible(n.parentNode.children[0])&&(i.visible=!0)):"children"===t?((n=this._closest(e,function(e){return"TR"===e.nodeName}).nextElementSibling)&&(i.exist=!0),i.exist&&this._isVisible(n)&&(i.visible=!0)):"siblings"===t&&((n=this._siblings(this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode)).length&&(i.exist=!0),i.exist&&n.some(function(e){return r._isVisible(e)})&&(i.visible=!0)),i}},{key:"getRelatedNodes",value:function(e,t){return"parent"===t?this._closest(e,function(e){return e.classList.contains("nodes")}).parentNode.children[0].querySelector(".node"):"children"===t?Array.from(this._closest(e,function(e){return"TABLE"===e.nodeName}).lastChild.children).map(function(e){return e.querySelector(".node")}):"siblings"===t?this._siblings(this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode).map(function(e){return e.querySelector(".node")}):[]}},{key:"_switchHorizontalArrow",value:function(e){var t=this.options,r=e.querySelector(".leftEdge"),n=e.querySelector(".rightEdge"),i=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;if(t.toggleSiblingsResp&&(void 0===t.ajaxURL||this._closest(e,function(e){return e.classList.contains(".nodes")}).dataset.siblingsLoaded)){var a=i.previousElementSibling,o=i.nextElementSibling;a&&(a.classList.contains("hidden")?(r.classList.add("fa-chevron-left"),r.classList.remove("fa-chevron-right")):(r.classList.add("fa-chevron-right"),r.classList.remove("fa-chevron-left"))),o&&(o.classList.contains("hidden")?(n.classList.add("fa-chevron-right"),n.classList.remove("fa-chevron-left")):(n.classList.add("fa-chevron-left"),n.classList.remove("fa-chevron-right")))}else{var s=this._siblings(i),c=!!s.length&&!s.some(function(e){return e.classList.contains("hidden")});r.classList.toggle("fa-chevron-right",c),r.classList.toggle("fa-chevron-left",!c),n.classList.toggle("fa-chevron-left",c),n.classList.toggle("fa-chevron-right",!c)}}},{key:"_hoverNode",value:function(e){var t=e.target,r=!1,n=t.querySelector(":scope > .topEdge"),i=t.querySelector(":scope > .bottomEdge"),a=t.querySelector(":scope > .leftEdge");"mouseenter"===e.type?(n&&(r=this._getNodeState(t,"parent").visible,n.classList.toggle("fa-chevron-up",!r),n.classList.toggle("fa-chevron-down",r)),i&&(r=this._getNodeState(t,"children").visible,i.classList.toggle("fa-chevron-down",!r),i.classList.toggle("fa-chevron-up",r)),a&&this._switchHorizontalArrow(t)):Array.from(t.querySelectorAll(":scope > .edge")).forEach(function(e){e.classList.remove("fa-chevron-up","fa-chevron-down","fa-chevron-right","fa-chevron-left")})}},{key:"_clickNode",value:function(e){var t=e.currentTarget,r=this.chart.querySelector(".focused");r&&r.classList.remove("focused"),t.classList.add("focused")}},{key:"_buildParentNode",value:function(e,t,r){var n=this,i=document.createElement("table");t.relationship=t.relationship||"001",this._createNode(t,0).then(function(e){var t=n.chart;e.classList.remove("slide-up"),e.classList.add("slide-down");var a=document.createElement("tr"),o=document.createElement("tr"),s=document.createElement("tr"),c=document.createElement("tr");a.setAttribute("class","hidden"),a.innerHTML='',i.appendChild(a),o.setAttribute("class","lines hidden"),o.innerHTML='
',i.appendChild(o),s.setAttribute("class","lines hidden"),s.innerHTML='  ',i.appendChild(s),c.setAttribute("class","nodes"),c.innerHTML='',i.appendChild(c),i.querySelector("td").appendChild(e),t.insertBefore(i,t.children[0]),i.children[3].children[0].appendChild(t.lastChild),r()}).catch(function(e){console.error("Failed to create parent node",e)})}},{key:"_switchVerticalArrow",value:function(e){e.classList.toggle("fa-chevron-up"),e.classList.toggle("fa-chevron-down")}},{key:"showParent",value:function(e){var t=this._prevAll(this._closest(e,function(e){return e.classList.contains("nodes")}));this._removeClass(t,"hidden"),this._addClass(Array(t[0].children).slice(1,-1),"hidden");var r=t[2].querySelector(".node");this._one(r,"transitionend",function(){r.classList.remove("slide"),this._isInAction(e)&&this._switchVerticalArrow(e.querySelector(":scope > .topEdge"))},this),this._repaint(r),r.classList.add("slide"),r.classList.remove("slide-down")}},{key:"showSiblings",value:function(e,t){var r=this,n=[],i=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;n=t?"left"===t?this._prevAll(i):this._nextAll(i):this._siblings(i),this._removeClass(n,"hidden");var a=this._prevAll(this._closest(e,function(e){return e.classList.contains("nodes")}));if(i=Array.from(a[0].querySelectorAll(":scope > .hidden")),t?this._removeClass(i.slice(0,2*n.length),"hidden"):this._removeClass(i,"hidden"),!this._getNodeState(e,"parent").visible){this._removeClass(a,"hidden");var o=a[2].querySelector(".node");this._one(o,"transitionend",function(e){e.target.classList.remove("slide")},this),this._repaint(o),o.classList.add("slide"),o.classList.remove("slide-down")}n.forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){r._isVisible(e)&&(e.classList.add("slide"),e.classList.remove("slide-left","slide-right"))})}),this._one(n[0].querySelector(".slide"),"transitionend",function(){var t=this;n.forEach(function(e){t._removeClass(Array.from(e.querySelectorAll(".slide")),"slide")}),this._isInAction(e)&&(this._switchHorizontalArrow(e),e.querySelector(".topEdge").classList.remove("fa-chevron-up"),e.querySelector(".topEdge").classList.add("fa-chevron-down"))},this)}},{key:"hideSiblings",value:function(e,t){var r=this,n=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;if(this._siblings(n).forEach(function(e){e.querySelector(".spinner")&&(r.chart.dataset.inAjax=!1)}),!t||t&&"left"===t){this._prevAll(n).forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){r._isVisible(e)&&e.classList.add("slide","slide-right")})})}if(!t||t&&"left"!==t){this._nextAll(n).forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){r._isVisible(e)&&e.classList.add("slide","slide-left")})})}var i=[];this._siblings(n).forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelectorAll(".slide")))});var a=[],o=!0,s=!1,c=void 0;try{for(var l,d=i[Symbol.iterator]();!(o=(l=d.next()).done);o=!0){var u=l.value,h=this._closest(u,function(e){return e.classList.contains("nodes")}).previousElementSibling;a.push(h),a.push(h.previousElementSibling)}}catch(e){s=!0,c=e}finally{try{!o&&d.return&&d.return()}finally{if(s)throw c}}(a=[].concat(toConsumableArray(new Set(a)))).forEach(function(e){e.style.visibility="hidden"}),this._one(i[0],"transitionend",function(r){var o=this;a.forEach(function(e){e.removeAttribute("style")});var s=[];s=t?"left"===t?this._prevAll(n,":not(.hidden)"):this._nextAll(n,":not(.hidden)"):this._siblings(n);var c=Array.from(this._closest(n,function(e){return e.classList.contains("nodes")}).previousElementSibling.querySelectorAll(":scope > :not(.hidden)")).slice(1,t?2*s.length+1:-1);this._addClass(c,"hidden"),this._removeClass(i,"slide"),s.forEach(function(e){Array.from(e.querySelectorAll(".node")).slice(1).forEach(function(e){o._isVisible(e)&&(e.classList.remove("slide-left","slide-right"),e.classList.add("slide-up"))})}),s.forEach(function(e){o._addClass(Array.from(e.querySelectorAll(".lines")),"hidden"),o._addClass(Array.from(e.querySelectorAll(".nodes")),"hidden"),o._addClass(Array.from(e.querySelectorAll(".verticalNodes")),"hidden")}),this._addClass(s,"hidden"),this._isInAction(e)&&this._switchHorizontalArrow(e)},this)}},{key:"hideParent",value:function(e){var t=Array.from(this._closest(e,function(e){return e.classList.contains("nodes")}).parentNode.children).slice(0,3);t[0].querySelector(".spinner")&&(this.chart.dataset.inAjax=!1),this._getNodeState(e,"siblings").visible&&this.hideSiblings(e);var r=t.slice(1);this._css(r,"visibility","hidden");var n=t[0].querySelector(".node"),i=this._getNodeState(n,"parent").visible;n&&this._isVisible(n)&&(n.classList.add("slide","slide-down"),this._one(n,"transitionend",function(){n.classList.remove("slide"),this._removeAttr(r,"style"),this._addClass(t,"hidden")},this)),n&&i&&this.hideParent(n)}},{key:"addParent",value:function(e,t){var r=this;this._buildParentNode(e,t,function(){if(!e.querySelector(":scope > .topEdge")){var t=document.createElement("i");t.setAttribute("class","edge verticalEdge topEdge fa"),e.appendChild(t)}r.showParent(e)})}},{key:"_startLoading",value:function(e,t){var r=this.options,n=this.chart;if(void 0!==n.dataset.inAjax&&"true"===n.dataset.inAjax)return!1;e.classList.add("hidden");var i=document.createElement("i");i.setAttribute("class","fa fa-circle-o-notch fa-spin spinner"),t.appendChild(i),this._addClass(Array.from(t.querySelectorAll(":scope > *:not(.spinner)")),"hazy"),n.dataset.inAjax=!0;var a=this.chartContainer.querySelector(".oc-export-btn"+(""!==r.chartClass?"."+r.chartClass:""));return a&&(a.disabled=!0),!0}},{key:"_endLoading",value:function(e,t){var r=this.options;e.classList.remove("hidden"),t.querySelector(":scope > .spinner").remove(),this._removeClass(Array.from(t.querySelectorAll(":scope > .hazy")),"hazy"),this.chart.dataset.inAjax=!1;var n=this.chartContainer.querySelector(".oc-export-btn"+(""!==r.chartClass?"."+r.chartClass:""));n&&(n.disabled=!1)}},{key:"_clickTopEdge",value:function(e){e.stopPropagation();var t=this,r=e.target,n=r.parentNode,i=this._getNodeState(n,"parent"),a=this.options;if(i.exist){var o=this._closest(n,function(e){return e.classList.contains("nodes")}).parentNode.firstChild.querySelector(".node");if(o.classList.contains("slide"))return;i.visible?(this.hideParent(n),this._one(o,"transitionend",function(){this._isInAction(n)&&(this._switchVerticalArrow(r),this._switchHorizontalArrow(n))},this)):this.showParent(n)}else{var s=r.parentNode.id;this._startLoading(r,n)&&this._getJSON("function"==typeof a.ajaxURL.parent?a.ajaxURL.parent(n.dataset.source):a.ajaxURL.parent+s).then(function(e){"true"===t.chart.dataset.inAjax&&Object.keys(e).length&&t.addParent(n,e)}).catch(function(e){console.error("Failed to get parent node data.",e)}).finally(function(){t._endLoading(r,n)})}}},{key:"hideChildren",value:function(e){var t=this,r=this._nextAll(e.parentNode.parentNode),n=r[r.length-1],i=[];n.querySelector(".spinner")&&(this.chart.dataset.inAjax=!1);var a=Array.from(n.querySelectorAll(".node")).filter(function(e){return t._isVisible(e)}),o=n.classList.contains("verticalNodes");o||(a.forEach(function(e){Array.prototype.push.apply(i,t._prevAll(t._closest(e,function(e){return e.classList.contains("nodes")}),".lines"))}),i=[].concat(toConsumableArray(new Set(i))),this._css(i,"visibility","hidden")),this._one(a[0],"transitionend",function(s){this._removeClass(a,"slide"),o?t._addClass(r,"hidden"):(i.forEach(function(e){e.removeAttribute("style"),e.classList.add("hidden"),e.parentNode.lastChild.classList.add("hidden")}),this._addClass(Array.from(n.querySelectorAll(".verticalNodes")),"hidden")),this._isInAction(e)&&this._switchVerticalArrow(e.querySelector(".bottomEdge"))},this),this._addClass(a,"slide slide-up")}},{key:"showChildren",value:function(e){var t=this,r=this,n=this._nextAll(e.parentNode.parentNode),i=[];this._removeClass(n,"hidden"),n.some(function(e){return e.classList.contains("verticalNodes")})?n.forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelectorAll(".node")).filter(function(e){return r._isVisible(e)}))}):Array.from(n[2].children).forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelector("tr").querySelectorAll(".node")).filter(function(e){return r._isVisible(e)}))}),this._repaint(i[0]),this._one(i[0],"transitionend",function(r){t._removeClass(i,"slide"),t._isInAction(e)&&t._switchVerticalArrow(e.querySelector(".bottomEdge"))},this),this._addClass(i,"slide"),this._removeClass(i,"slide-up")}},{key:"_buildChildNode",value:function(e,t,r){var n=t.children||t.siblings;e.querySelector("td").setAttribute("colSpan",2*n.length),this.buildHierarchy(e,{children:n},0,r)}},{key:"addChildren",value:function(e,t){var r=this,n=this.options,i=0;this.chart.dataset.inEdit="addChildren",this._buildChildNode.call(this,this._closest(e,function(e){return"TABLE"===e.nodeName}),t,function(){if(++i===t.children.length){if(!e.querySelector(".bottomEdge")){var a=document.createElement("i");a.setAttribute("class","edge verticalEdge bottomEdge fa"),e.appendChild(a)}if(!e.querySelector(".symbol")){var o=document.createElement("i");o.setAttribute("class","fa "+n.parentNodeSymbol+" symbol"),e.querySelector(":scope > .title").appendChild(o)}r.showChildren(e),r.chart.dataset.inEdit=""}})}},{key:"_clickBottomEdge",value:function(e){var t=this;e.stopPropagation();var r=this,n=this.options,i=e.target,a=i.parentNode,o=this._getNodeState(a,"children");if(o.exist){var s=this._closest(a,function(e){return"TR"===e.nodeName}).parentNode.lastChild;if(Array.from(s.querySelectorAll(".node")).some(function(e){return t._isVisible(e)&&e.classList.contains("slide")}))return;o.visible?this.hideChildren(a):this.showChildren(a)}else{var c=i.parentNode.id;this._startLoading(i,a)&&this._getJSON("function"==typeof n.ajaxURL.children?n.ajaxURL.children(a.dataset.source):n.ajaxURL.children+c).then(function(e){"true"===r.chart.dataset.inAjax&&e.children.length&&r.addChildren(a,e)}).catch(function(e){console.error("Failed to get children nodes data",e)}).finally(function(){r._endLoading(i,a)})}}},{key:"_complementLine",value:function(e,t,r){var n=e.parentNode.parentNode.children;n[0].children[0].setAttribute("colspan",2*t),n[1].children[0].setAttribute("colspan",2*t);for(var i=0;i1?Math.floor(s/2-1):0;if("TD"===e.parentNode.nodeName){var l=this._prevAll(e.parentNode.parentNode);l[0].remove(),l[1].remove();var d=0;i._buildChildNode.call(i,i._closest(e.parentNode,function(e){return"TABLE"===e.nodeName}),t,function(){if(++d===a){var t=Array.from(i._closest(e.parentNode,function(e){return"TABLE"===e.nodeName}).lastChild.children);if(o>1){var n=e.parentNode.parentNode;Array.from(n.children).forEach(function(e){t[0].parentNode.insertBefore(e,t[0])}),n.remove(),i._complementLine(t[0],s,o),i._addClass(t,"hidden"),t.forEach(function(e){i._addClass(e.querySelectorAll(".node"),"slide-left")})}else{var l=e.parentNode.parentNode;t[c].parentNode.insertBefore(e.parentNode,t[c+1]),l.remove(),i._complementLine(t[c],s,1),i._addClass(t,"hidden"),i._addClass(i._getDescElements(t.slice(0,c+1),".node"),"slide-right"),i._addClass(i._getDescElements(t.slice(c+1),".node"),"slide-left")}r()}})}else{var u=0;i.buildHierarchy.call(i,i.chart,t,0,function(){if(++u===s){var t=e.nextElementSibling.children[3].children[c],a=document.createElement("td");a.setAttribute("colspan",2),a.appendChild(e),t.parentNode.insertBefore(a,t.nextElementSibling),i._complementLine(t,s,1);var o=i._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0];o.classList.add("hidden"),i._addClass(Array.from(o.querySelectorAll(".node")),"slide-down");var l=n._siblings(e.parentNode);i._addClass(l,"hidden"),i._addClass(i._getDescElements(l.slice(0,c),".node"),"slide-right"),i._addClass(i._getDescElements(l.slice(c),".node"),"slide-left"),r()}})}}},{key:"addSiblings",value:function(e,t){var r=this;this.chart.dataset.inEdit="addSiblings",this._buildSiblingNode.call(this,this._closest(e,function(e){return"TABLE"===e.nodeName}),t,function(){if(r._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}).dataset.siblingsLoaded=!0,!e.querySelector(".leftEdge")){var t=document.createElement("i"),n=document.createElement("i");t.setAttribute("class","edge horizontalEdge rightEdge fa"),e.appendChild(t),n.setAttribute("class","edge horizontalEdge leftEdge fa"),e.appendChild(n)}r.showSiblings(e),r.chart.dataset.inEdit=""})}},{key:"removeNodes",value:function(e){var t=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode,r=this._siblings(t.parentNode);"TD"===t.nodeName?this._getNodeState(e,"siblings").exist?(r[2].querySelector(".topLine").nextElementSibling.remove(),r[2].querySelector(".topLine").remove(),r[0].children[0].setAttribute("colspan",r[2].children.length),r[1].children[0].setAttribute("colspan",r[2].children.length),t.remove()):(r[0].children[0].removeAttribute("colspan"),r[0].querySelector(".bottomEdge").remove(),this._siblings(r[0]).forEach(function(e){return e.remove()})):Array.from(t.parentNode.children).forEach(function(e){return e.remove()})}},{key:"_clickHorizontalEdge",value:function(e){var t=this;e.stopPropagation();var r=this,n=this.options,i=e.target,a=i.parentNode,o=this._getNodeState(a,"siblings");if(o.exist){var s=this._closest(a,function(e){return"TABLE"===e.nodeName}).parentNode;if(this._siblings(s).some(function(e){var r=e.querySelector(".node");return t._isVisible(r)&&r.classList.contains("slide")}))return;if(n.toggleSiblingsResp){var c=this._closest(a,function(e){return"TABLE"===e.nodeName}).parentNode.previousElementSibling,l=this._closest(a,function(e){return"TABLE"===e.nodeName}).parentNode.nextElementSibling;i.classList.contains("leftEdge")?c&&c.classList.contains("hidden")?this.showSiblings(a,"left"):this.hideSiblings(a,"left"):l&&l.classList.contains("hidden")?this.showSiblings(a,"right"):this.hideSiblings(a,"right")}else o.visible?this.hideSiblings(a):this.showSiblings(a)}else{var d=i.parentNode.id,u=this._getNodeState(a,"parent").exist?"function"==typeof n.ajaxURL.siblings?n.ajaxURL.siblings(JSON.parse(a.dataset.source)):n.ajaxURL.siblings+d:"function"==typeof n.ajaxURL.families?n.ajaxURL.families(JSON.parse(a.dataset.source)):n.ajaxURL.families+d;this._startLoading(i,a)&&this._getJSON(u).then(function(e){"true"===r.chart.dataset.inAjax&&(e.siblings||e.children)&&r.addSiblings(a,e)}).catch(function(e){console.error("Failed to get sibling nodes data",e)}).finally(function(){r._endLoading(i,a)})}}},{key:"_clickToggleButton",value:function(e){var t=this,r=e.target,n=r.parentNode.nextElementSibling,i=Array.from(n.querySelectorAll(".node")),a=Array.from(n.children).map(function(e){return e.querySelector(".node")});a.some(function(e){return e.classList.contains("slide")})||(r.classList.toggle("fa-plus-square"),r.classList.toggle("fa-minus-square"),i[0].classList.contains("slide-up")?(n.classList.remove("hidden"),this._repaint(a[0]),this._addClass(a,"slide"),this._removeClass(a,"slide-up"),this._one(a[0],"transitionend",function(){t._removeClass(a,"slide")})):(this._addClass(i,"slide slide-up"),this._one(i[0],"transitionend",function(){t._removeClass(i,"slide"),i.forEach(function(e){t._closest(e,function(e){return"UL"===e.nodeName}).classList.add("hidden")})}),i.forEach(function(e){var r=Array.from(e.querySelectorAll(".toggleBtn"));t._removeClass(r,"fa-minus-square"),t._addClass(r,"fa-plus-square")})))}},{key:"_dispatchClickEvent",value:function(e){var t=e.target.classList;t.contains("topEdge")?this._clickTopEdge(e):t.contains("rightEdge")||t.contains("leftEdge")?this._clickHorizontalEdge(e):t.contains("bottomEdge")?this._clickBottomEdge(e):t.contains("toggleBtn")?this._clickToggleButton(e):this._clickNode(e)}},{key:"_onDragStart",value:function(e){var t=e.target,r=this.options,n=/firefox/.test(window.navigator.userAgent.toLowerCase());if(n&&e.dataTransfer.setData("text/html","hack for firefox"),this.chart.style.transform){var i=void 0,a=void 0;document.querySelector(".ghost-node")?a=(i=this.chart.querySelector(":scope > .ghost-node")).children[0]:((i=document.createElementNS("http://www.w3.org/2000/svg","svg")).classList.add("ghost-node"),a=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.appendChild(a),this.chart.appendChild(i));var o=this.chart.style.transform.split(","),s=Math.abs(window.parseFloat("t2b"===r.direction||"b2t"===r.direction?o[0].slice(o[0].indexOf("(")+1):o[1]));i.setAttribute("width",t.offsetWidth),i.setAttribute("height",t.offsetHeight),a.setAttribute("x",5*s),a.setAttribute("y",5*s),a.setAttribute("width",120*s),a.setAttribute("height",40*s),a.setAttribute("rx",4*s),a.setAttribute("ry",4*s),a.setAttribute("stroke-width",1*s);var c=e.offsetX*s,l=e.offsetY*s;if("l2r"===r.direction?(c=e.offsetY*s,l=e.offsetX*s):"r2l"===r.direction?(c=t.offsetWidth-e.offsetY*s,l=e.offsetX*s):"b2t"===r.direction&&(c=t.offsetWidth-e.offsetX*s,l=t.offsetHeight-e.offsetY*s),n){var d=document.createElement("img");d.src="data:image/svg+xml;utf8,"+(new XMLSerializer).serializeToString(i),e.dataTransfer.setDragImage(d,c,l),a.setAttribute("fill","rgb(255, 255, 255)"),a.setAttribute("stroke","rgb(191, 0, 0)")}else e.dataTransfer.setDragImage(i,c,l)}var u=e.target,h=null;null!==this._closest(u,function(e){return e.classList&&e.classList.contains("nodes")})&&(h=this._closest(u,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0].querySelector(".node"));var f=Array.from(this._closest(u,function(e){return"TABLE"===e.nodeName}).querySelectorAll(".node"));this.dragged=u,Array.from(this.chart.querySelectorAll(".node")).forEach(function(e){f.includes(e)||(r.dropCriteria?r.dropCriteria(u,h,e)&&e.classList.add("allowedDrop"):e.classList.add("allowedDrop"))})}},{key:"_onDragOver",value:function(e){e.preventDefault();e.currentTarget.classList.contains("allowedDrop")||(e.dataTransfer.dropEffect="none")}},{key:"_onDragEnd",value:function(e){Array.from(this.chart.querySelectorAll(".allowedDrop")).forEach(function(e){e.classList.remove("allowedDrop")})}},{key:"_onDrop",value:function(e){var t=e.currentTarget,r=this.chart,n=this.dragged,i=this._closest(n,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0].children[0];if(this._removeClass(Array.from(r.querySelectorAll(".allowedDrop")),"allowedDrop"),t.parentNode.parentNode.nextElementSibling){var a=window.parseInt(t.parentNode.colSpan)+2;if(t.parentNode.setAttribute("colspan",a),t.parentNode.parentNode.nextElementSibling.children[0].setAttribute("colspan",a),!n.querySelector(".horizontalEdge")){var o=document.createElement("i"),s=document.createElement("i");o.setAttribute("class","edge horizontalEdge rightEdge fa"),n.appendChild(o),s.setAttribute("class","edge horizontalEdge leftEdge fa"),n.appendChild(s)}var c=t.parentNode.parentNode.nextElementSibling.nextElementSibling,l=document.createElement("td"),d=document.createElement("td");l.setAttribute("class","leftLine topLine"),l.innerHTML=" ",c.insertBefore(l,c.children[1]),d.setAttribute("class","rightLine topLine"),d.innerHTML=" ",c.insertBefore(d,c.children[2]),c.nextElementSibling.appendChild(this._closest(n,function(e){return"TABLE"===e.nodeName}).parentNode);var u=this._siblings(this._closest(n,function(e){return"TABLE"===e.nodeName}).parentNode).map(function(e){return e.querySelector(".node")});if(1===u.length){var h=document.createElement("i"),f=document.createElement("i");h.setAttribute("class","edge horizontalEdge rightEdge fa"),u[0].appendChild(h),f.setAttribute("class","edge horizontalEdge leftEdge fa"),u[0].appendChild(f)}}else{var p=document.createElement("i");p.setAttribute("class","edge verticalEdge bottomEdge fa"),t.appendChild(p),t.parentNode.setAttribute("colspan",2);var g=this._closest(t,function(e){return"TABLE"===e.nodeName}),y=document.createElement("tr"),v=document.createElement("tr"),b=document.createElement("tr");y.setAttribute("class","lines"),y.innerHTML='
',g.appendChild(y),v.setAttribute("class","lines"),v.innerHTML='  ',g.appendChild(v),b.setAttribute("class","nodes"),g.appendChild(b),Array.from(n.querySelectorAll(".horizontalEdge")).forEach(function(e){n.removeChild(e)});var m=this._closest(n,function(e){return"TABLE"===e.nodeName}).parentNode;b.appendChild(m)}var _=window.parseInt(i.colSpan);if(_>2){i.setAttribute("colspan",_-2),i.parentNode.nextElementSibling.children[0].setAttribute("colspan",_-2);var A=i.parentNode.nextElementSibling.nextElementSibling;A.children[1].remove(),A.children[1].remove();var S=Array.from(i.parentNode.parentNode.children[3].children).map(function(e){return e.querySelector(".node")});1===S.length&&(S[0].querySelector(".leftEdge").remove(),S[0].querySelector(".rightEdge").remove())}else i.removeAttribute("colspan"),i.querySelector(".node").removeChild(i.querySelector(".bottomEdge")),Array.from(i.parentNode.parentNode.children).slice(1).forEach(function(e){return e.remove()});var E=new CustomEvent("nodedropped.orgchart",{detail:{draggedNode:n,dragZone:i.children[0],dropZone:t}});r.dispatchEvent(E)}},{key:"_createNode",value:function(e,t){var r=this,n=this.options;return new Promise(function(i,a){if(e.children){var o=!0,s=!1,c=void 0;try{for(var l,d=e.children[Symbol.iterator]();!(o=(l=d.next()).done);o=!0){l.value.parentId=e.id}}catch(e){s=!0,c=e}finally{try{!o&&d.return&&d.return()}finally{if(s)throw c}}}var u=document.createElement("div");delete e.children,u.dataset.source=JSON.stringify(e),e[n.nodeId]&&(u.id=e[n.nodeId]);var h=r.chart.dataset.inEdit,f=void 0;f=h?"addChildren"===h?" slide-up":"":t>=n.depth?" slide-up":"",u.setAttribute("class","node "+(e.className||"")+f),n.draggable&&u.setAttribute("draggable",!0),e.parentId&&u.setAttribute("data-parent",e.parentId),u.innerHTML='\n
'+e[n.nodeTitle]+"
\n "+(n.nodeContent?'
'+e[n.nodeContent]+"
":"")+"\n ";var p=e.relationship||"";if(n.verticalDepth&&t+2>n.verticalDepth){if(t+1>=n.verticalDepth&&Number(p.substr(2,1))){var g=document.createElement("i"),y=t+1>=n.depth?"plus":"minus";g.setAttribute("class","toggleBtn fa fa-"+y+"-square"),u.appendChild(g)}}else{if(Number(p.substr(0,1))){var v=document.createElement("i");v.setAttribute("class","edge verticalEdge topEdge fa"),u.appendChild(v)}if(Number(p.substr(1,1))){var b=document.createElement("i"),m=document.createElement("i");b.setAttribute("class","edge horizontalEdge rightEdge fa"),u.appendChild(b),m.setAttribute("class","edge horizontalEdge leftEdge fa"),u.appendChild(m)}if(Number(p.substr(2,1))){var _=document.createElement("i"),A=document.createElement("i"),S=u.querySelector(":scope > .title");_.setAttribute("class","edge verticalEdge bottomEdge fa"),u.appendChild(_),A.setAttribute("class","fa "+n.parentNodeSymbol+" symbol"),S.insertBefore(A,S.children[0])}}n.toggleCollapse&&(u.addEventListener("mouseenter",r._hoverNode.bind(r)),u.addEventListener("mouseleave",r._hoverNode.bind(r)),u.addEventListener("click",r._dispatchClickEvent.bind(r))),n.draggable&&(u.addEventListener("dragstart",r._onDragStart.bind(r)),u.addEventListener("dragover",r._onDragOver.bind(r)),u.addEventListener("dragend",r._onDragEnd.bind(r)),u.addEventListener("drop",r._onDrop.bind(r))),n.createNode&&n.createNode(u,e),i(u)})}},{key:"buildHierarchy",value:function(e,t,r,n){var i=this,a=this.options,o=void 0,s=t.children,c=a.verticalDepth&&r+1>=a.verticalDepth;if(Object.keys(t).length>1&&(o=c?e:document.createElement("table"),c||e.appendChild(o),this._createNode(t,r).then(function(e){if(c)o.insertBefore(e,o.firstChild);else{var t=document.createElement("tr");t.innerHTML="\n \n \n ",t.children[0].appendChild(e),o.insertBefore(t,o.children[0]?o.children[0]:null)}n&&n()}).catch(function(e){console.error("Failed to creat node",e)})),s&&0!==s.length){1===Object.keys(t).length&&(o=e);var l=void 0,d=a.verticalDepth&&r+2>=a.verticalDepth,u=i.chart.dataset.inEdit;if(l=u?"addSiblings"===u?"":" hidden":r+1>=a.depth?" hidden":"",!d){var h=document.createElement("tr");h.setAttribute("class","lines"+l),h.innerHTML='\n \n
\n \n ',o.appendChild(h)}var f=document.createElement("tr");f.setAttribute("class","lines"+l),f.innerHTML='\n  \n '+s.slice(1).map(function(){return'\n  \n  \n '}).join("")+'\n  \n ';var p=void 0;if(d)if(p=document.createElement("ul"),l&&p.classList.add(l.trim()),r+2===a.verticalDepth){var g=document.createElement("tr");g.setAttribute("class","verticalNodes"+l),g.innerHTML="",g.firstChild.appendChild(p),o.appendChild(g)}else o.appendChild(p);else(p=document.createElement("tr")).setAttribute("class","nodes"+l),o.appendChild(f),o.appendChild(p);s.forEach(function(e){var t=void 0;d?t=document.createElement("li"):(t=document.createElement("td")).setAttribute("colspan",2),p.appendChild(t),i.buildHierarchy(t,e,r+1,n)})}}},{key:"_clickChart",value:function(e){!this._closest(e.target,function(e){return e.classList&&e.classList.contains("node")})&&this.chart.querySelector(".node.focused")&&this.chart.querySelector(".node.focused").classList.remove("focused")}},{key:"_clickExportButton",value:function(){var e=this.options,t=this.chartContainer,r=t.querySelector(":scope > .mask"),n=t.querySelector(".orgchart:not(.hidden)"),i="l2r"===e.direction||"r2l"===e.direction;r?r.classList.remove("hidden"):((r=document.createElement("div")).setAttribute("class","mask"),r.innerHTML='',t.appendChild(r)),t.classList.add("canvasContainer"),window.html2canvas(n,{width:i?n.clientHeight:n.clientWidth,height:i?n.clientWidth:n.clientHeight,onclone:function(e){var t=e.querySelector(".canvasContainer");t.style.overflow="visible",t.querySelector(".orgchart:not(.hidden)").transform=""}}).then(function(e){var r=t.querySelector(".oc-download-btn");t.querySelector(".mask").classList.add("hidden"),r.setAttribute("href",e.toDataURL()),r.click()}).catch(function(e){console.error("Failed to export the curent orgchart!",e)}).finally(function(){t.classList.remove("canvasContainer")})}},{key:"_loopChart",value:function(e){var t=this,r={id:e.querySelector(".node").id};return e.children[3]&&Array.from(e.children[3].children).forEach(function(e){r.children||(r.children=[]),r.children.push(t._loopChart(e.firstChild))}),r}},{key:"_loopChartDataset",value:function(e){var t=this,r=JSON.parse(e.querySelector(".node").dataset.source);return e.children[3]&&Array.from(e.children[3].children).forEach(function(e){r.children||(r.children=[]),r.children.push(t._loopChartDataset(e.firstChild))}),r}},{key:"getChartJSON",value:function(){return this.chart.querySelector(".node").id?this._loopChartDataset(this.chart.querySelector("table")):"Error: Nodes of orghcart to be exported must have id attribute!"}},{key:"getHierarchy",value:function(){return this.chart.querySelector(".node").id?this._loopChart(this.chart.querySelector("table")):"Error: Nodes of orghcart to be exported must have id attribute!"}},{key:"_onPanStart",value:function(e){var t=e.currentTarget;if(this._closest(e.target,function(e){return e.classList&&e.classList.contains("node")})||e.touches&&e.touches.length>1)t.dataset.panning=!1;else{t.style.cursor="move",t.dataset.panning=!0;var r=0,n=0,i=window.getComputedStyle(t).transform;if("none"!==i){var a=i.split(",");i.includes("3d")?(r=Number.parseInt(a[12],10),n=Number.parseInt(a[13],10)):(r=Number.parseInt(a[4],10),n=Number.parseInt(a[5],10))}var o=0,s=0;if(e.targetTouches){if(1===e.targetTouches.length)o=e.targetTouches[0].pageX-r,s=e.targetTouches[0].pageY-n;else if(e.targetTouches.length>1)return}else o=e.pageX-r,s=e.pageY-n;t.dataset.panStart=JSON.stringify({startX:o,startY:s}),t.addEventListener("mousemove",this._onPanning.bind(this)),t.addEventListener("touchmove",this._onPanning.bind(this))}}},{key:"_onPanning",value:function(e){var t=e.currentTarget;if("false"!==t.dataset.panning){var r=0,n=0,i=JSON.parse(t.dataset.panStart),a=i.startX,o=i.startY;if(e.targetTouches){if(1===e.targetTouches.length)r=e.targetTouches[0].pageX-a,n=e.targetTouches[0].pageY-o;else if(e.targetTouches.length>1)return}else r=e.pageX-a,n=e.pageY-o;var s=window.getComputedStyle(t).transform;if("none"===s)s.includes("3d")?t.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, "+r+", "+n+", 0, 1)":t.style.transform="matrix(1, 0, 0, 1, "+r+", "+n+")";else{var c=s.split(",");s.includes("3d")?(c[12]=r,c[13]=n):(c[4]=r,c[5]=n+")"),t.style.transform=c.join(",")}}}},{key:"_onPanEnd",value:function(e){var t=this.chart;"true"===t.dataset.panning&&(t.dataset.panning=!1,t.style.cursor="default",document.body.removeEventListener("mousemove",this._onPanning),document.body.removeEventListener("touchmove",this._onPanning))}},{key:"_setChartScale",value:function(e,t){var r=window.getComputedStyle(e).transform;if("none"===r)e.style.transform="scale("+t+","+t+")";else{var n=r.split(",");r.includes("3d")?e.style.transform=r+" scale3d("+t+","+t+", 1)":(n[0]="matrix("+t,n[3]=t,e.style.transform=r+" scale("+t+","+t+")")}e.dataset.scale=t}},{key:"_onWheeling",value:function(e){e.preventDefault();var t=e.deltaY>0?.8:1.2;this._setChartScale(this.chart,t)}},{key:"_getPinchDist",value:function(e){return Math.sqrt((e.touches[0].clientX-e.touches[1].clientX)*(e.touches[0].clientX-e.touches[1].clientX)+(e.touches[0].clientY-e.touches[1].clientY)*(e.touches[0].clientY-e.touches[1].clientY))}},{key:"_onTouchStart",value:function(e){var t=this.chart;if(e.touches&&2===e.touches.length){var r=this._getPinchDist(e);t.dataset.pinching=!0,t.dataset.pinchDistStart=r}}},{key:"_onTouchMove",value:function(e){var t=this.chart;if(t.dataset.pinching){var r=this._getPinchDist(e);t.dataset.pinchDistEnd=r}}},{key:"_onTouchEnd",value:function(e){var t=this.chart;if(t.dataset.pinching){t.dataset.pinching=!1;var r=t.dataset.pinchDistEnd-t.dataset.pinchDistStart;r>0?this._setChartScale(t,1):r<0&&this._setChartScale(t,-1)}}},{key:"name",get:function(){return this._name}}]),e}(),arrayProto=Array.prototype,splice=arrayProto.splice;ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;var freeGlobal="object"==typeof global&&global&&global.Object===Object&&global,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),Symbol$1=root.Symbol,objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty,nativeObjectToString=objectProto$1.toString,symToStringTag$1=Symbol$1?Symbol$1.toStringTag:void 0,objectProto$2=Object.prototype,nativeObjectToString$1=objectProto$2.toString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$1?Symbol$1.toStringTag:void 0,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]",coreJsData=root["__core-js_shared__"],maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto=Object.prototype,funcToString=funcProto.toString,hasOwnProperty=objectProto.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Map=getNative(root,"Map"),nativeCreate=getNative(Object,"create"),HASH_UNDEFINED="__lodash_hash_undefined__",objectProto$3=Object.prototype,hasOwnProperty$2=objectProto$3.hasOwnProperty,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,HASH_UNDEFINED$1="__lodash_hash_undefined__";Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet,MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var LARGE_ARRAY_SIZE=200;Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;var defineProperty$1=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),baseFor=createBaseFor(),freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,Buffer=moduleExports?root.Buffer:void 0,allocUnsafe=Buffer?Buffer.allocUnsafe:void 0,Uint8Array=root.Uint8Array,objectCreate=Object.create,baseCreate=function(){function e(){}return function(t){if(!isObject(t))return{};if(objectCreate)return objectCreate(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),getPrototype=overArg(Object.getPrototypeOf,Object),objectProto$5=Object.prototype,argsTag="[object Arguments]",objectProto$6=Object.prototype,hasOwnProperty$4=objectProto$6.hasOwnProperty,propertyIsEnumerable=objectProto$6.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&hasOwnProperty$4.call(e,"callee")&&!propertyIsEnumerable.call(e,"callee")},isArray=Array.isArray,MAX_SAFE_INTEGER=9007199254740991,freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer$1=moduleExports$1?root.Buffer:void 0,nativeIsBuffer=Buffer$1?Buffer$1.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,objectTag="[object Object]",funcProto$2=Function.prototype,objectProto$7=Object.prototype,funcToString$2=funcProto$2.toString,hasOwnProperty$5=objectProto$7.hasOwnProperty,objectCtorString=funcToString$2.call(Object),argsTag$1="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag$1="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag$1="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag$1]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var freeExports$2="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,freeProcess=moduleExports$2&&freeGlobal.process,nodeUtil=function(){try{return freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}(),nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,objectProto$8=Object.prototype,hasOwnProperty$6=objectProto$8.hasOwnProperty,MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/,objectProto$9=Object.prototype,hasOwnProperty$7=objectProto$9.hasOwnProperty,objectProto$10=Object.prototype,hasOwnProperty$8=objectProto$10.hasOwnProperty,nativeMax=Math.max,baseSetToString=defineProperty$1?function(e,t){return defineProperty$1(e,"toString",{configurable:!0,enumerable:!1,value:constant(t),writable:!0})}:identity,HOT_COUNT=800,HOT_SPAN=16,nativeNow=Date.now,setToString=shortOut(baseSetToString),merge=createAssigner(function(e,t,r){baseMerge(e,t,r)}),mergeOptions=function(e,t){return merge(e,t)},VoBasic={render:function(){var e=this.$createElement;return(this._self._c||e)("div",{staticClass:"vo-basic",attrs:{id:"chart-container"}})},staticRenderFns:[],name:"orgchart",props:{data:{type:Object,default:function(){return{}}},pan:{type:Boolean,default:!0},zoom:{type:Boolean,default:!0},direction:{type:String,default:"t2b"},verticalDepth:{type:Number},toggleSiblingsResp:{type:Boolean,default:!1},ajaxURL:{type:Object},depth:{type:Number,default:999},nodeTitle:{type:String,default:"name"},parentNodeSymbol:{type:String,default:""},nodeContent:{type:String},nodeId:{type:String,default:"id"},createNode:{type:Function},exportButton:{type:Boolean,default:!1},exportButtonName:{type:String,default:"Export"},exportFilename:{type:String},chartClass:{type:String,default:""},draggable:{type:Boolean,default:!1},dropCriteria:{type:Function},toggleCollapse:{type:Boolean,default:!0}},data:function(){return{newData:null,orgchart:null,defaultOptions:{chartContainer:"#chart-container"}}},mounted:function(){null===this.newData&&this.initOrgChart()},methods:{initOrgChart:function(){var e=mergeOptions(this.defaultOptions,this.$props);this.orgchart=new OrgChart$1(e)}},watch:{data:function(e){var t=this;this.newData=e;new Promise(function(t){e&&t()}).then(function(){var e=mergeOptions(t.defaultOptions,t.$props);t.orgchart=new OrgChart$1(e)})}}},closest=function e(t,r){return t&&(r(t)&&t!==document.querySelector(".orgchart")?t:e(t.parentNode,r))},bindEventHandler=function(e,t,r,n){n?document.querySelector(n).addEventListener(t,function(t){(t.target.classList&&t.target.classList.contains(e.slice(1))||closest(t.target,function(t){return t.classList&&t.classList.contains(e.slice(1))}))&&r(t)}):document.querySelectorAll(e).forEach(function(e){e.addEventListener(t,r)})},clickNode=function(e){var t=closest(e.target,function(e){return e.classList&&e.classList.contains("node")}),r=document.getElementById("selected-node");r.value=t.querySelector(".title").textContent,r.dataset.node=t.id},clickChart=function(e){closest(e.target,function(e){return e.classList&&e.classList.contains("node")})||(document.getElementById("selected-node").textContent="")},getId=function(){return 1e3*(new Date).getTime()+Math.floor(1001*Math.random())},VoEdit={render:function(){var e=this.$createElement;return(this._self._c||e)("div",{staticClass:"vo-edit",attrs:{id:"chart-container"}})},staticRenderFns:[],name:"VoEdit",props:{data:{type:Object},pan:{type:Boolean,default:!0},zoom:{type:Boolean,default:!0},direction:{type:String,default:"t2b"},verticalDepth:{type:Number},toggleSiblingsResp:{type:Boolean,default:!1},ajaxURL:{type:Object},depth:{type:Number,default:999},nodeTitle:{type:String,default:"name"},parentNodeSymbol:{type:String,default:""},nodeContent:{type:String},nodeId:{type:String,default:"id"},createNode:{type:Function},exportButton:{type:Boolean,default:!1},exportButtonName:{type:String,default:"Export"},exportFilename:{type:String},chartClass:{type:String,default:""},draggable:{type:Boolean,default:!1},dropCriteria:{type:Function},toggleCollapse:{type:Boolean,default:!0}},data:function(){return{newData:null,orgchart:null,defaultOptions:{chartContainer:"#chart-container",createNode:function(e,t){e.id=getId()}}}},mounted:function(){null===this.newData&&this.initOrgChart(),this.$nextTick(function(){bindEventHandler(".node","click",clickNode,"#chart-container"),bindEventHandler(".orgchart","click",clickChart,"#chart-container")})},methods:{initOrgChart:function(){var e=mergeOptions(this.defaultOptions,this.$props);this.orgchart=new OrgChart$1(e)}},watch:{data:function(e){var t=this;this.newData=e;new Promise(function(t){e&&t()}).then(function(){var e=mergeOptions(t.defaultOptions,t.$props);t.orgchart=new OrgChart$1(e)})}}};"undefined"!=typeof window&&window.Vue&&(window.Vue.component("vo-basic",VoBasic),window.Vue.component("vo-edit",VoEdit)),exports.VoBasic=VoBasic,exports.VoEdit=VoEdit; diff --git a/dist/vue-orgchart.esm.js b/dist/vue-orgchart.esm.js index f8738d8..4f32dfc 100644 --- a/dist/vue-orgchart.esm.js +++ b/dist/vue-orgchart.esm.js @@ -4273,8 +4273,8 @@ var VoBasic = { render: function render() { return {}; } }, - pan: { type: Boolean, default: false }, - zoom: { type: Boolean, default: false }, + pan: { type: Boolean, default: true }, + zoom: { type: Boolean, default: true }, direction: { type: String, default: 't2b' }, verticalDepth: { type: Number }, toggleSiblingsResp: { type: Boolean, default: false }, @@ -4392,8 +4392,8 @@ var VoEdit = { render: function render() { name: 'VoEdit', props: { data: { type: Object }, - pan: { type: Boolean, default: false }, - zoom: { type: Boolean, default: false }, + pan: { type: Boolean, default: true }, + zoom: { type: Boolean, default: true }, direction: { type: String, default: 't2b' }, verticalDepth: { type: Number }, toggleSiblingsResp: { type: Boolean, default: false }, diff --git a/dist/vue-orgchart.js b/dist/vue-orgchart.js index d38ea11..5ab237e 100644 --- a/dist/vue-orgchart.js +++ b/dist/vue-orgchart.js @@ -1,7 +1,7 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global['vue-orgchart-al'] = {}))); + (factory((global['vue-orgchart'] = {}))); }(this, (function (exports) { 'use strict'; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { @@ -4279,8 +4279,8 @@ var VoBasic = { render: function render() { return {}; } }, - pan: { type: Boolean, default: false }, - zoom: { type: Boolean, default: false }, + pan: { type: Boolean, default: true }, + zoom: { type: Boolean, default: true }, direction: { type: String, default: 't2b' }, verticalDepth: { type: Number }, toggleSiblingsResp: { type: Boolean, default: false }, @@ -4398,8 +4398,8 @@ var VoEdit = { render: function render() { name: 'VoEdit', props: { data: { type: Object }, - pan: { type: Boolean, default: false }, - zoom: { type: Boolean, default: false }, + pan: { type: Boolean, default: true }, + zoom: { type: Boolean, default: true }, direction: { type: String, default: 't2b' }, verticalDepth: { type: Number }, toggleSiblingsResp: { type: Boolean, default: false }, diff --git a/dist/vue-orgchart.min.js b/dist/vue-orgchart.min.js index 4bf18d6..cd6be81 100644 --- a/dist/vue-orgchart.min.js +++ b/dist/vue-orgchart.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e["vue-orgchart-al"]={})}(this,function(e){"use strict";function t(e,t){return e===t||e!=e&&t!=t}function n(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1}function r(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e<=Oe}function _(e){return null!=e&&b(e.length)&&!s(e)}function E(e,n,r){var i=e[n];Ze.call(e,n)&&t(i,r)&&(void 0!==r||n in e)||f(e,n,r)}function S(e,t){return!!(t=null==t?Ke:t)&&("number"==typeof e||Qe.test(e))&&e>-1&&e%1==0&&e0?t.split(" ").forEach(function(t){return e.classList.add(t)}):e.classList.add(t)})}},{key:"_removeClass",value:function(e,t){e.forEach(function(e){t.indexOf(" ")>0?t.split(" ").forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t)})}},{key:"_css",value:function(e,t,n){e.forEach(function(e){e.style[t]=n})}},{key:"_removeAttr",value:function(e,t){e.forEach(function(e){e.removeAttribute(t)})}},{key:"_one",value:function(e,t,n,r){e&&e.addEventListener(t,function i(o){try{n.call(r,o)}finally{e.removeEventListener(t,i)}})}},{key:"_getDescElements",value:function(e,t){var n=[];return e.forEach(function(e){return n.push.apply(n,D(e.querySelectorAll(t)))}),n}},{key:"_getJSON",value:function(e){return new Promise(function(t,n){var r=new XMLHttpRequest;r.open("GET",e),r.onreadystatechange=function(){4===this.readyState&&(200===this.status?t(JSON.parse(this.response)):n(new Error(this.statusText)))},r.responseType="json",r.setRequestHeader("Content-Type","application/json"),r.send()})}},{key:"_buildJsonDS",value:function(e){var t=this,n={name:e.firstChild.textContent.trim(),relationship:("LI"===e.parentNode.parentNode.nodeName?"1":"0")+(e.parentNode.children.length>1?1:0)+(e.children.length?1:0)};return e.id&&(n.id=e.id),e.querySelector("ul")&&Array.from(e.querySelector("ul").children).forEach(function(e){n.children||(n.children=[]),n.children.push(t._buildJsonDS(e))}),n}},{key:"_attachRel",value:function(e,t){if(e.relationship=t+(e.children&&e.children.length>0?1:0),e.children){var n=!0,r=!1,i=void 0;try{for(var o,s=e.children[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var a=o.value;this._attachRel(a,"1"+(e.children.length>1?1:0))}}catch(e){r=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}}return e}},{key:"_repaint",value:function(e){e&&(e.style.offsetWidth=e.offsetWidth)}},{key:"_isInAction",value:function(e){return e.querySelector(":scope > .edge").className.indexOf("fa-")>-1}},{key:"_getNodeState",value:function(e,t){var n=this,r=void 0,i={exist:!1,visible:!1};return"parent"===t?((r=this._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}))&&(i.exist=!0),i.exist&&this._isVisible(r.parentNode.children[0])&&(i.visible=!0)):"children"===t?((r=this._closest(e,function(e){return"TR"===e.nodeName}).nextElementSibling)&&(i.exist=!0),i.exist&&this._isVisible(r)&&(i.visible=!0)):"siblings"===t&&((r=this._siblings(this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode)).length&&(i.exist=!0),i.exist&&r.some(function(e){return n._isVisible(e)})&&(i.visible=!0)),i}},{key:"getRelatedNodes",value:function(e,t){return"parent"===t?this._closest(e,function(e){return e.classList.contains("nodes")}).parentNode.children[0].querySelector(".node"):"children"===t?Array.from(this._closest(e,function(e){return"TABLE"===e.nodeName}).lastChild.children).map(function(e){return e.querySelector(".node")}):"siblings"===t?this._siblings(this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode).map(function(e){return e.querySelector(".node")}):[]}},{key:"_switchHorizontalArrow",value:function(e){var t=this.options,n=e.querySelector(".leftEdge"),r=e.querySelector(".rightEdge"),i=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;if(t.toggleSiblingsResp&&(void 0===t.ajaxURL||this._closest(e,function(e){return e.classList.contains(".nodes")}).dataset.siblingsLoaded)){var o=i.previousElementSibling,s=i.nextElementSibling;o&&(o.classList.contains("hidden")?(n.classList.add("fa-chevron-left"),n.classList.remove("fa-chevron-right")):(n.classList.add("fa-chevron-right"),n.classList.remove("fa-chevron-left"))),s&&(s.classList.contains("hidden")?(r.classList.add("fa-chevron-right"),r.classList.remove("fa-chevron-left")):(r.classList.add("fa-chevron-left"),r.classList.remove("fa-chevron-right")))}else{var a=this._siblings(i),l=!!a.length&&!a.some(function(e){return e.classList.contains("hidden")});n.classList.toggle("fa-chevron-right",l),n.classList.toggle("fa-chevron-left",!l),r.classList.toggle("fa-chevron-left",l),r.classList.toggle("fa-chevron-right",!l)}}},{key:"_hoverNode",value:function(e){var t=e.target,n=!1,r=t.querySelector(":scope > .topEdge"),i=t.querySelector(":scope > .bottomEdge"),o=t.querySelector(":scope > .leftEdge");"mouseenter"===e.type?(r&&(n=this._getNodeState(t,"parent").visible,r.classList.toggle("fa-chevron-up",!n),r.classList.toggle("fa-chevron-down",n)),i&&(n=this._getNodeState(t,"children").visible,i.classList.toggle("fa-chevron-down",!n),i.classList.toggle("fa-chevron-up",n)),o&&this._switchHorizontalArrow(t)):Array.from(t.querySelectorAll(":scope > .edge")).forEach(function(e){e.classList.remove("fa-chevron-up","fa-chevron-down","fa-chevron-right","fa-chevron-left")})}},{key:"_clickNode",value:function(e){var t=e.currentTarget,n=this.chart.querySelector(".focused");n&&n.classList.remove("focused"),t.classList.add("focused")}},{key:"_buildParentNode",value:function(e,t,n){var r=this,i=document.createElement("table");t.relationship=t.relationship||"001",this._createNode(t,0).then(function(e){var t=r.chart;e.classList.remove("slide-up"),e.classList.add("slide-down");var o=document.createElement("tr"),s=document.createElement("tr"),a=document.createElement("tr"),l=document.createElement("tr");o.setAttribute("class","hidden"),o.innerHTML='',i.appendChild(o),s.setAttribute("class","lines hidden"),s.innerHTML='
',i.appendChild(s),a.setAttribute("class","lines hidden"),a.innerHTML='  ',i.appendChild(a),l.setAttribute("class","nodes"),l.innerHTML='',i.appendChild(l),i.querySelector("td").appendChild(e),t.insertBefore(i,t.children[0]),i.children[3].children[0].appendChild(t.lastChild),n()}).catch(function(e){console.error("Failed to create parent node",e)})}},{key:"_switchVerticalArrow",value:function(e){e.classList.toggle("fa-chevron-up"),e.classList.toggle("fa-chevron-down")}},{key:"showParent",value:function(e){var t=this._prevAll(this._closest(e,function(e){return e.classList.contains("nodes")}));this._removeClass(t,"hidden"),this._addClass(Array(t[0].children).slice(1,-1),"hidden");var n=t[2].querySelector(".node");this._one(n,"transitionend",function(){n.classList.remove("slide"),this._isInAction(e)&&this._switchVerticalArrow(e.querySelector(":scope > .topEdge"))},this),this._repaint(n),n.classList.add("slide"),n.classList.remove("slide-down")}},{key:"showSiblings",value:function(e,t){var n=this,r=[],i=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;r=t?"left"===t?this._prevAll(i):this._nextAll(i):this._siblings(i),this._removeClass(r,"hidden");var o=this._prevAll(this._closest(e,function(e){return e.classList.contains("nodes")}));if(i=Array.from(o[0].querySelectorAll(":scope > .hidden")),t?this._removeClass(i.slice(0,2*r.length),"hidden"):this._removeClass(i,"hidden"),!this._getNodeState(e,"parent").visible){this._removeClass(o,"hidden");var s=o[2].querySelector(".node");this._one(s,"transitionend",function(e){e.target.classList.remove("slide")},this),this._repaint(s),s.classList.add("slide"),s.classList.remove("slide-down")}r.forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){n._isVisible(e)&&(e.classList.add("slide"),e.classList.remove("slide-left","slide-right"))})}),this._one(r[0].querySelector(".slide"),"transitionend",function(){var t=this;r.forEach(function(e){t._removeClass(Array.from(e.querySelectorAll(".slide")),"slide")}),this._isInAction(e)&&(this._switchHorizontalArrow(e),e.querySelector(".topEdge").classList.remove("fa-chevron-up"),e.querySelector(".topEdge").classList.add("fa-chevron-down"))},this)}},{key:"hideSiblings",value:function(e,t){var n=this,r=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;if(this._siblings(r).forEach(function(e){e.querySelector(".spinner")&&(n.chart.dataset.inAjax=!1)}),!t||t&&"left"===t){this._prevAll(r).forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){n._isVisible(e)&&e.classList.add("slide","slide-right")})})}if(!t||t&&"left"!==t){this._nextAll(r).forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){n._isVisible(e)&&e.classList.add("slide","slide-left")})})}var i=[];this._siblings(r).forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelectorAll(".slide")))});var o=[],s=!0,a=!1,l=void 0;try{for(var c,d=i[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){var u=c.value,h=this._closest(u,function(e){return e.classList.contains("nodes")}).previousElementSibling;o.push(h),o.push(h.previousElementSibling)}}catch(e){a=!0,l=e}finally{try{!s&&d.return&&d.return()}finally{if(a)throw l}}(o=[].concat(D(new Set(o)))).forEach(function(e){e.style.visibility="hidden"}),this._one(i[0],"transitionend",function(n){var s=this;o.forEach(function(e){e.removeAttribute("style")});var a=[];a=t?"left"===t?this._prevAll(r,":not(.hidden)"):this._nextAll(r,":not(.hidden)"):this._siblings(r);var l=Array.from(this._closest(r,function(e){return e.classList.contains("nodes")}).previousElementSibling.querySelectorAll(":scope > :not(.hidden)")).slice(1,t?2*a.length+1:-1);this._addClass(l,"hidden"),this._removeClass(i,"slide"),a.forEach(function(e){Array.from(e.querySelectorAll(".node")).slice(1).forEach(function(e){s._isVisible(e)&&(e.classList.remove("slide-left","slide-right"),e.classList.add("slide-up"))})}),a.forEach(function(e){s._addClass(Array.from(e.querySelectorAll(".lines")),"hidden"),s._addClass(Array.from(e.querySelectorAll(".nodes")),"hidden"),s._addClass(Array.from(e.querySelectorAll(".verticalNodes")),"hidden")}),this._addClass(a,"hidden"),this._isInAction(e)&&this._switchHorizontalArrow(e)},this)}},{key:"hideParent",value:function(e){var t=Array.from(this._closest(e,function(e){return e.classList.contains("nodes")}).parentNode.children).slice(0,3);t[0].querySelector(".spinner")&&(this.chart.dataset.inAjax=!1),this._getNodeState(e,"siblings").visible&&this.hideSiblings(e);var n=t.slice(1);this._css(n,"visibility","hidden");var r=t[0].querySelector(".node"),i=this._getNodeState(r,"parent").visible;r&&this._isVisible(r)&&(r.classList.add("slide","slide-down"),this._one(r,"transitionend",function(){r.classList.remove("slide"),this._removeAttr(n,"style"),this._addClass(t,"hidden")},this)),r&&i&&this.hideParent(r)}},{key:"addParent",value:function(e,t){var n=this;this._buildParentNode(e,t,function(){if(!e.querySelector(":scope > .topEdge")){var t=document.createElement("i");t.setAttribute("class","edge verticalEdge topEdge fa"),e.appendChild(t)}n.showParent(e)})}},{key:"_startLoading",value:function(e,t){var n=this.options,r=this.chart;if(void 0!==r.dataset.inAjax&&"true"===r.dataset.inAjax)return!1;e.classList.add("hidden");var i=document.createElement("i");i.setAttribute("class","fa fa-circle-o-notch fa-spin spinner"),t.appendChild(i),this._addClass(Array.from(t.querySelectorAll(":scope > *:not(.spinner)")),"hazy"),r.dataset.inAjax=!0;var o=this.chartContainer.querySelector(".oc-export-btn"+(""!==n.chartClass?"."+n.chartClass:""));return o&&(o.disabled=!0),!0}},{key:"_endLoading",value:function(e,t){var n=this.options;e.classList.remove("hidden"),t.querySelector(":scope > .spinner").remove(),this._removeClass(Array.from(t.querySelectorAll(":scope > .hazy")),"hazy"),this.chart.dataset.inAjax=!1;var r=this.chartContainer.querySelector(".oc-export-btn"+(""!==n.chartClass?"."+n.chartClass:""));r&&(r.disabled=!1)}},{key:"_clickTopEdge",value:function(e){e.stopPropagation();var t=this,n=e.target,r=n.parentNode,i=this._getNodeState(r,"parent"),o=this.options;if(i.exist){var s=this._closest(r,function(e){return e.classList.contains("nodes")}).parentNode.firstChild.querySelector(".node");if(s.classList.contains("slide"))return;i.visible?(this.hideParent(r),this._one(s,"transitionend",function(){this._isInAction(r)&&(this._switchVerticalArrow(n),this._switchHorizontalArrow(r))},this)):this.showParent(r)}else{var a=n.parentNode.id;this._startLoading(n,r)&&this._getJSON("function"==typeof o.ajaxURL.parent?o.ajaxURL.parent(r.dataset.source):o.ajaxURL.parent+a).then(function(e){"true"===t.chart.dataset.inAjax&&Object.keys(e).length&&t.addParent(r,e)}).catch(function(e){console.error("Failed to get parent node data.",e)}).finally(function(){t._endLoading(n,r)})}}},{key:"hideChildren",value:function(e){var t=this,n=this._nextAll(e.parentNode.parentNode),r=n[n.length-1],i=[];r.querySelector(".spinner")&&(this.chart.dataset.inAjax=!1);var o=Array.from(r.querySelectorAll(".node")).filter(function(e){return t._isVisible(e)}),s=r.classList.contains("verticalNodes");s||(o.forEach(function(e){Array.prototype.push.apply(i,t._prevAll(t._closest(e,function(e){return e.classList.contains("nodes")}),".lines"))}),i=[].concat(D(new Set(i))),this._css(i,"visibility","hidden")),this._one(o[0],"transitionend",function(a){this._removeClass(o,"slide"),s?t._addClass(n,"hidden"):(i.forEach(function(e){e.removeAttribute("style"),e.classList.add("hidden"),e.parentNode.lastChild.classList.add("hidden")}),this._addClass(Array.from(r.querySelectorAll(".verticalNodes")),"hidden")),this._isInAction(e)&&this._switchVerticalArrow(e.querySelector(".bottomEdge"))},this),this._addClass(o,"slide slide-up")}},{key:"showChildren",value:function(e){var t=this,n=this,r=this._nextAll(e.parentNode.parentNode),i=[];this._removeClass(r,"hidden"),r.some(function(e){return e.classList.contains("verticalNodes")})?r.forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelectorAll(".node")).filter(function(e){return n._isVisible(e)}))}):Array.from(r[2].children).forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelector("tr").querySelectorAll(".node")).filter(function(e){return n._isVisible(e)}))}),this._repaint(i[0]),this._one(i[0],"transitionend",function(n){t._removeClass(i,"slide"),t._isInAction(e)&&t._switchVerticalArrow(e.querySelector(".bottomEdge"))},this),this._addClass(i,"slide"),this._removeClass(i,"slide-up")}},{key:"_buildChildNode",value:function(e,t,n){var r=t.children||t.siblings;e.querySelector("td").setAttribute("colSpan",2*r.length),this.buildHierarchy(e,{children:r},0,n)}},{key:"addChildren",value:function(e,t){var n=this,r=this.options,i=0;this.chart.dataset.inEdit="addChildren",this._buildChildNode.call(this,this._closest(e,function(e){return"TABLE"===e.nodeName}),t,function(){if(++i===t.children.length){if(!e.querySelector(".bottomEdge")){var o=document.createElement("i");o.setAttribute("class","edge verticalEdge bottomEdge fa"),e.appendChild(o)}if(!e.querySelector(".symbol")){var s=document.createElement("i");s.setAttribute("class","fa "+r.parentNodeSymbol+" symbol"),e.querySelector(":scope > .title").appendChild(s)}n.showChildren(e),n.chart.dataset.inEdit=""}})}},{key:"_clickBottomEdge",value:function(e){var t=this;e.stopPropagation();var n=this,r=this.options,i=e.target,o=i.parentNode,s=this._getNodeState(o,"children");if(s.exist){var a=this._closest(o,function(e){return"TR"===e.nodeName}).parentNode.lastChild;if(Array.from(a.querySelectorAll(".node")).some(function(e){return t._isVisible(e)&&e.classList.contains("slide")}))return;s.visible?this.hideChildren(o):this.showChildren(o)}else{var l=i.parentNode.id;this._startLoading(i,o)&&this._getJSON("function"==typeof r.ajaxURL.children?r.ajaxURL.children(o.dataset.source):r.ajaxURL.children+l).then(function(e){"true"===n.chart.dataset.inAjax&&e.children.length&&n.addChildren(o,e)}).catch(function(e){console.error("Failed to get children nodes data",e)}).finally(function(){n._endLoading(i,o)})}}},{key:"_complementLine",value:function(e,t,n){var r=e.parentNode.parentNode.children;r[0].children[0].setAttribute("colspan",2*t),r[1].children[0].setAttribute("colspan",2*t);for(var i=0;i1?Math.floor(a/2-1):0;if("TD"===e.parentNode.nodeName){var c=this._prevAll(e.parentNode.parentNode);c[0].remove(),c[1].remove();var d=0;i._buildChildNode.call(i,i._closest(e.parentNode,function(e){return"TABLE"===e.nodeName}),t,function(){if(++d===o){var t=Array.from(i._closest(e.parentNode,function(e){return"TABLE"===e.nodeName}).lastChild.children);if(s>1){var r=e.parentNode.parentNode;Array.from(r.children).forEach(function(e){t[0].parentNode.insertBefore(e,t[0])}),r.remove(),i._complementLine(t[0],a,s),i._addClass(t,"hidden"),t.forEach(function(e){i._addClass(e.querySelectorAll(".node"),"slide-left")})}else{var c=e.parentNode.parentNode;t[l].parentNode.insertBefore(e.parentNode,t[l+1]),c.remove(),i._complementLine(t[l],a,1),i._addClass(t,"hidden"),i._addClass(i._getDescElements(t.slice(0,l+1),".node"),"slide-right"),i._addClass(i._getDescElements(t.slice(l+1),".node"),"slide-left")}n()}})}else{var u=0;i.buildHierarchy.call(i,i.chart,t,0,function(){if(++u===a){var t=e.nextElementSibling.children[3].children[l],o=document.createElement("td");o.setAttribute("colspan",2),o.appendChild(e),t.parentNode.insertBefore(o,t.nextElementSibling),i._complementLine(t,a,1);var s=i._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0];s.classList.add("hidden"),i._addClass(Array.from(s.querySelectorAll(".node")),"slide-down");var c=r._siblings(e.parentNode);i._addClass(c,"hidden"),i._addClass(i._getDescElements(c.slice(0,l),".node"),"slide-right"),i._addClass(i._getDescElements(c.slice(l),".node"),"slide-left"),n()}})}}},{key:"addSiblings",value:function(e,t){var n=this;this.chart.dataset.inEdit="addSiblings",this._buildSiblingNode.call(this,this._closest(e,function(e){return"TABLE"===e.nodeName}),t,function(){if(n._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}).dataset.siblingsLoaded=!0,!e.querySelector(".leftEdge")){var t=document.createElement("i"),r=document.createElement("i");t.setAttribute("class","edge horizontalEdge rightEdge fa"),e.appendChild(t),r.setAttribute("class","edge horizontalEdge leftEdge fa"),e.appendChild(r)}n.showSiblings(e),n.chart.dataset.inEdit=""})}},{key:"removeNodes",value:function(e){var t=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode,n=this._siblings(t.parentNode);"TD"===t.nodeName?this._getNodeState(e,"siblings").exist?(n[2].querySelector(".topLine").nextElementSibling.remove(),n[2].querySelector(".topLine").remove(),n[0].children[0].setAttribute("colspan",n[2].children.length),n[1].children[0].setAttribute("colspan",n[2].children.length),t.remove()):(n[0].children[0].removeAttribute("colspan"),n[0].querySelector(".bottomEdge").remove(),this._siblings(n[0]).forEach(function(e){return e.remove()})):Array.from(t.parentNode.children).forEach(function(e){return e.remove()})}},{key:"_clickHorizontalEdge",value:function(e){var t=this;e.stopPropagation();var n=this,r=this.options,i=e.target,o=i.parentNode,s=this._getNodeState(o,"siblings");if(s.exist){var a=this._closest(o,function(e){return"TABLE"===e.nodeName}).parentNode;if(this._siblings(a).some(function(e){var n=e.querySelector(".node");return t._isVisible(n)&&n.classList.contains("slide")}))return;if(r.toggleSiblingsResp){var l=this._closest(o,function(e){return"TABLE"===e.nodeName}).parentNode.previousElementSibling,c=this._closest(o,function(e){return"TABLE"===e.nodeName}).parentNode.nextElementSibling;i.classList.contains("leftEdge")?l&&l.classList.contains("hidden")?this.showSiblings(o,"left"):this.hideSiblings(o,"left"):c&&c.classList.contains("hidden")?this.showSiblings(o,"right"):this.hideSiblings(o,"right")}else s.visible?this.hideSiblings(o):this.showSiblings(o)}else{var d=i.parentNode.id,u=this._getNodeState(o,"parent").exist?"function"==typeof r.ajaxURL.siblings?r.ajaxURL.siblings(JSON.parse(o.dataset.source)):r.ajaxURL.siblings+d:"function"==typeof r.ajaxURL.families?r.ajaxURL.families(JSON.parse(o.dataset.source)):r.ajaxURL.families+d;this._startLoading(i,o)&&this._getJSON(u).then(function(e){"true"===n.chart.dataset.inAjax&&(e.siblings||e.children)&&n.addSiblings(o,e)}).catch(function(e){console.error("Failed to get sibling nodes data",e)}).finally(function(){n._endLoading(i,o)})}}},{key:"_clickToggleButton",value:function(e){var t=this,n=e.target,r=n.parentNode.nextElementSibling,i=Array.from(r.querySelectorAll(".node")),o=Array.from(r.children).map(function(e){return e.querySelector(".node")});o.some(function(e){return e.classList.contains("slide")})||(n.classList.toggle("fa-plus-square"),n.classList.toggle("fa-minus-square"),i[0].classList.contains("slide-up")?(r.classList.remove("hidden"),this._repaint(o[0]),this._addClass(o,"slide"),this._removeClass(o,"slide-up"),this._one(o[0],"transitionend",function(){t._removeClass(o,"slide")})):(this._addClass(i,"slide slide-up"),this._one(i[0],"transitionend",function(){t._removeClass(i,"slide"),i.forEach(function(e){t._closest(e,function(e){return"UL"===e.nodeName}).classList.add("hidden")})}),i.forEach(function(e){var n=Array.from(e.querySelectorAll(".toggleBtn"));t._removeClass(n,"fa-minus-square"),t._addClass(n,"fa-plus-square")})))}},{key:"_dispatchClickEvent",value:function(e){var t=e.target.classList;t.contains("topEdge")?this._clickTopEdge(e):t.contains("rightEdge")||t.contains("leftEdge")?this._clickHorizontalEdge(e):t.contains("bottomEdge")?this._clickBottomEdge(e):t.contains("toggleBtn")?this._clickToggleButton(e):this._clickNode(e)}},{key:"_onDragStart",value:function(e){var t=e.target,n=this.options,r=/firefox/.test(window.navigator.userAgent.toLowerCase());if(r&&e.dataTransfer.setData("text/html","hack for firefox"),this.chart.style.transform){var i=void 0,o=void 0;document.querySelector(".ghost-node")?o=(i=this.chart.querySelector(":scope > .ghost-node")).children[0]:((i=document.createElementNS("http://www.w3.org/2000/svg","svg")).classList.add("ghost-node"),o=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.appendChild(o),this.chart.appendChild(i));var s=this.chart.style.transform.split(","),a=Math.abs(window.parseFloat("t2b"===n.direction||"b2t"===n.direction?s[0].slice(s[0].indexOf("(")+1):s[1]));i.setAttribute("width",t.offsetWidth),i.setAttribute("height",t.offsetHeight),o.setAttribute("x",5*a),o.setAttribute("y",5*a),o.setAttribute("width",120*a),o.setAttribute("height",40*a),o.setAttribute("rx",4*a),o.setAttribute("ry",4*a),o.setAttribute("stroke-width",1*a);var l=e.offsetX*a,c=e.offsetY*a;if("l2r"===n.direction?(l=e.offsetY*a,c=e.offsetX*a):"r2l"===n.direction?(l=t.offsetWidth-e.offsetY*a,c=e.offsetX*a):"b2t"===n.direction&&(l=t.offsetWidth-e.offsetX*a,c=t.offsetHeight-e.offsetY*a),r){var d=document.createElement("img");d.src="data:image/svg+xml;utf8,"+(new XMLSerializer).serializeToString(i),e.dataTransfer.setDragImage(d,l,c),o.setAttribute("fill","rgb(255, 255, 255)"),o.setAttribute("stroke","rgb(191, 0, 0)")}else e.dataTransfer.setDragImage(i,l,c)}var u=e.target,h=null;null!==this._closest(u,function(e){return e.classList&&e.classList.contains("nodes")})&&(h=this._closest(u,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0].querySelector(".node"));var f=Array.from(this._closest(u,function(e){return"TABLE"===e.nodeName}).querySelectorAll(".node"));this.dragged=u,Array.from(this.chart.querySelectorAll(".node")).forEach(function(e){f.includes(e)||(n.dropCriteria?n.dropCriteria(u,h,e)&&e.classList.add("allowedDrop"):e.classList.add("allowedDrop"))})}},{key:"_onDragOver",value:function(e){e.preventDefault();e.currentTarget.classList.contains("allowedDrop")||(e.dataTransfer.dropEffect="none")}},{key:"_onDragEnd",value:function(e){Array.from(this.chart.querySelectorAll(".allowedDrop")).forEach(function(e){e.classList.remove("allowedDrop")})}},{key:"_onDrop",value:function(e){var t=e.currentTarget,n=this.chart,r=this.dragged,i=this._closest(r,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0].children[0];if(this._removeClass(Array.from(n.querySelectorAll(".allowedDrop")),"allowedDrop"),t.parentNode.parentNode.nextElementSibling){var o=window.parseInt(t.parentNode.colSpan)+2;if(t.parentNode.setAttribute("colspan",o),t.parentNode.parentNode.nextElementSibling.children[0].setAttribute("colspan",o),!r.querySelector(".horizontalEdge")){var s=document.createElement("i"),a=document.createElement("i");s.setAttribute("class","edge horizontalEdge rightEdge fa"),r.appendChild(s),a.setAttribute("class","edge horizontalEdge leftEdge fa"),r.appendChild(a)}var l=t.parentNode.parentNode.nextElementSibling.nextElementSibling,c=document.createElement("td"),d=document.createElement("td");c.setAttribute("class","leftLine topLine"),c.innerHTML=" ",l.insertBefore(c,l.children[1]),d.setAttribute("class","rightLine topLine"),d.innerHTML=" ",l.insertBefore(d,l.children[2]),l.nextElementSibling.appendChild(this._closest(r,function(e){return"TABLE"===e.nodeName}).parentNode);var u=this._siblings(this._closest(r,function(e){return"TABLE"===e.nodeName}).parentNode).map(function(e){return e.querySelector(".node")});if(1===u.length){var h=document.createElement("i"),f=document.createElement("i");h.setAttribute("class","edge horizontalEdge rightEdge fa"),u[0].appendChild(h),f.setAttribute("class","edge horizontalEdge leftEdge fa"),u[0].appendChild(f)}}else{var p=document.createElement("i");p.setAttribute("class","edge verticalEdge bottomEdge fa"),t.appendChild(p),t.parentNode.setAttribute("colspan",2);var v=this._closest(t,function(e){return"TABLE"===e.nodeName}),g=document.createElement("tr"),y=document.createElement("tr"),m=document.createElement("tr");g.setAttribute("class","lines"),g.innerHTML='
',v.appendChild(g),y.setAttribute("class","lines"),y.innerHTML='  ',v.appendChild(y),m.setAttribute("class","nodes"),v.appendChild(m),Array.from(r.querySelectorAll(".horizontalEdge")).forEach(function(e){r.removeChild(e)});var b=this._closest(r,function(e){return"TABLE"===e.nodeName}).parentNode;m.appendChild(b)}var _=window.parseInt(i.colSpan);if(_>2){i.setAttribute("colspan",_-2),i.parentNode.nextElementSibling.children[0].setAttribute("colspan",_-2);var E=i.parentNode.nextElementSibling.nextElementSibling;E.children[1].remove(),E.children[1].remove();var S=Array.from(i.parentNode.parentNode.children[3].children).map(function(e){return e.querySelector(".node")});1===S.length&&(S[0].querySelector(".leftEdge").remove(),S[0].querySelector(".rightEdge").remove())}else i.removeAttribute("colspan"),i.querySelector(".node").removeChild(i.querySelector(".bottomEdge")),Array.from(i.parentNode.parentNode.children).slice(1).forEach(function(e){return e.remove()});var A=new CustomEvent("nodedropped.orgchart",{detail:{draggedNode:r,dragZone:i.children[0],dropZone:t}});n.dispatchEvent(A)}},{key:"_createNode",value:function(e,t){var n=this,r=this.options;return new Promise(function(i,o){if(e.children){var s=!0,a=!1,l=void 0;try{for(var c,d=e.children[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){c.value.parentId=e.id}}catch(e){a=!0,l=e}finally{try{!s&&d.return&&d.return()}finally{if(a)throw l}}}var u=document.createElement("div");delete e.children,u.dataset.source=JSON.stringify(e),e[r.nodeId]&&(u.id=e[r.nodeId]);var h=n.chart.dataset.inEdit,f=void 0;f=h?"addChildren"===h?" slide-up":"":t>=r.depth?" slide-up":"",u.setAttribute("class","node "+(e.className||"")+f),r.draggable&&u.setAttribute("draggable",!0),e.parentId&&u.setAttribute("data-parent",e.parentId),u.innerHTML='\n
'+e[r.nodeTitle]+"
\n "+(r.nodeContent?'
'+e[r.nodeContent]+"
":"")+"\n ";var p=e.relationship||"";if(r.verticalDepth&&t+2>r.verticalDepth){if(t+1>=r.verticalDepth&&Number(p.substr(2,1))){var v=document.createElement("i"),g=t+1>=r.depth?"plus":"minus";v.setAttribute("class","toggleBtn fa fa-"+g+"-square"),u.appendChild(v)}}else{if(Number(p.substr(0,1))){var y=document.createElement("i");y.setAttribute("class","edge verticalEdge topEdge fa"),u.appendChild(y)}if(Number(p.substr(1,1))){var m=document.createElement("i"),b=document.createElement("i");m.setAttribute("class","edge horizontalEdge rightEdge fa"),u.appendChild(m),b.setAttribute("class","edge horizontalEdge leftEdge fa"),u.appendChild(b)}if(Number(p.substr(2,1))){var _=document.createElement("i"),E=document.createElement("i"),S=u.querySelector(":scope > .title");_.setAttribute("class","edge verticalEdge bottomEdge fa"),u.appendChild(_),E.setAttribute("class","fa "+r.parentNodeSymbol+" symbol"),S.insertBefore(E,S.children[0])}}r.toggleCollapse&&(u.addEventListener("mouseenter",n._hoverNode.bind(n)),u.addEventListener("mouseleave",n._hoverNode.bind(n)),u.addEventListener("click",n._dispatchClickEvent.bind(n))),r.draggable&&(u.addEventListener("dragstart",n._onDragStart.bind(n)),u.addEventListener("dragover",n._onDragOver.bind(n)),u.addEventListener("dragend",n._onDragEnd.bind(n)),u.addEventListener("drop",n._onDrop.bind(n))),r.createNode&&r.createNode(u,e),i(u)})}},{key:"buildHierarchy",value:function(e,t,n,r){var i=this,o=this.options,s=void 0,a=t.children,l=o.verticalDepth&&n+1>=o.verticalDepth;if(Object.keys(t).length>1&&(s=l?e:document.createElement("table"),l||e.appendChild(s),this._createNode(t,n).then(function(e){if(l)s.insertBefore(e,s.firstChild);else{var t=document.createElement("tr");t.innerHTML="\n \n \n ",t.children[0].appendChild(e),s.insertBefore(t,s.children[0]?s.children[0]:null)}r&&r()}).catch(function(e){console.error("Failed to creat node",e)})),a&&0!==a.length){1===Object.keys(t).length&&(s=e);var c=void 0,d=o.verticalDepth&&n+2>=o.verticalDepth,u=i.chart.dataset.inEdit;if(c=u?"addSiblings"===u?"":" hidden":n+1>=o.depth?" hidden":"",!d){var h=document.createElement("tr");h.setAttribute("class","lines"+c),h.innerHTML='\n \n
\n \n ',s.appendChild(h)}var f=document.createElement("tr");f.setAttribute("class","lines"+c),f.innerHTML='\n  \n '+a.slice(1).map(function(){return'\n  \n  \n '}).join("")+'\n  \n ';var p=void 0;if(d)if(p=document.createElement("ul"),c&&p.classList.add(c.trim()),n+2===o.verticalDepth){var v=document.createElement("tr");v.setAttribute("class","verticalNodes"+c),v.innerHTML="",v.firstChild.appendChild(p),s.appendChild(v)}else s.appendChild(p);else(p=document.createElement("tr")).setAttribute("class","nodes"+c),s.appendChild(f),s.appendChild(p);a.forEach(function(e){var t=void 0;d?t=document.createElement("li"):(t=document.createElement("td")).setAttribute("colspan",2),p.appendChild(t),i.buildHierarchy(t,e,n+1,r)})}}},{key:"_clickChart",value:function(e){!this._closest(e.target,function(e){return e.classList&&e.classList.contains("node")})&&this.chart.querySelector(".node.focused")&&this.chart.querySelector(".node.focused").classList.remove("focused")}},{key:"_clickExportButton",value:function(){var e=this.options,t=this.chartContainer,n=t.querySelector(":scope > .mask"),r=t.querySelector(".orgchart:not(.hidden)"),i="l2r"===e.direction||"r2l"===e.direction;n?n.classList.remove("hidden"):((n=document.createElement("div")).setAttribute("class","mask"),n.innerHTML='',t.appendChild(n)),t.classList.add("canvasContainer"),window.html2canvas(r,{width:i?r.clientHeight:r.clientWidth,height:i?r.clientWidth:r.clientHeight,onclone:function(e){var t=e.querySelector(".canvasContainer");t.style.overflow="visible",t.querySelector(".orgchart:not(.hidden)").transform=""}}).then(function(e){var n=t.querySelector(".oc-download-btn");t.querySelector(".mask").classList.add("hidden"),n.setAttribute("href",e.toDataURL()),n.click()}).catch(function(e){console.error("Failed to export the curent orgchart!",e)}).finally(function(){t.classList.remove("canvasContainer")})}},{key:"_loopChart",value:function(e){var t=this,n={id:e.querySelector(".node").id};return e.children[3]&&Array.from(e.children[3].children).forEach(function(e){n.children||(n.children=[]),n.children.push(t._loopChart(e.firstChild))}),n}},{key:"_loopChartDataset",value:function(e){var t=this,n=JSON.parse(e.querySelector(".node").dataset.source);return e.children[3]&&Array.from(e.children[3].children).forEach(function(e){n.children||(n.children=[]),n.children.push(t._loopChartDataset(e.firstChild))}),n}},{key:"getChartJSON",value:function(){return this.chart.querySelector(".node").id?this._loopChartDataset(this.chart.querySelector("table")):"Error: Nodes of orghcart to be exported must have id attribute!"}},{key:"getHierarchy",value:function(){return this.chart.querySelector(".node").id?this._loopChart(this.chart.querySelector("table")):"Error: Nodes of orghcart to be exported must have id attribute!"}},{key:"_onPanStart",value:function(e){var t=e.currentTarget;if(this._closest(e.target,function(e){return e.classList&&e.classList.contains("node")})||e.touches&&e.touches.length>1)t.dataset.panning=!1;else{t.style.cursor="move",t.dataset.panning=!0;var n=0,r=0,i=window.getComputedStyle(t).transform;if("none"!==i){var o=i.split(",");i.includes("3d")?(n=Number.parseInt(o[12],10),r=Number.parseInt(o[13],10)):(n=Number.parseInt(o[4],10),r=Number.parseInt(o[5],10))}var s=0,a=0;if(e.targetTouches){if(1===e.targetTouches.length)s=e.targetTouches[0].pageX-n,a=e.targetTouches[0].pageY-r;else if(e.targetTouches.length>1)return}else s=e.pageX-n,a=e.pageY-r;t.dataset.panStart=JSON.stringify({startX:s,startY:a}),t.addEventListener("mousemove",this._onPanning.bind(this)),t.addEventListener("touchmove",this._onPanning.bind(this))}}},{key:"_onPanning",value:function(e){var t=e.currentTarget;if("false"!==t.dataset.panning){var n=0,r=0,i=JSON.parse(t.dataset.panStart),o=i.startX,s=i.startY;if(e.targetTouches){if(1===e.targetTouches.length)n=e.targetTouches[0].pageX-o,r=e.targetTouches[0].pageY-s;else if(e.targetTouches.length>1)return}else n=e.pageX-o,r=e.pageY-s;var a=window.getComputedStyle(t).transform;if("none"===a)a.includes("3d")?t.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, "+n+", "+r+", 0, 1)":t.style.transform="matrix(1, 0, 0, 1, "+n+", "+r+")";else{var l=a.split(",");a.includes("3d")?(l[12]=n,l[13]=r):(l[4]=n,l[5]=r+")"),t.style.transform=l.join(",")}}}},{key:"_onPanEnd",value:function(e){var t=this.chart;"true"===t.dataset.panning&&(t.dataset.panning=!1,t.style.cursor="default",document.body.removeEventListener("mousemove",this._onPanning),document.body.removeEventListener("touchmove",this._onPanning))}},{key:"_setChartScale",value:function(e,t){var n=window.getComputedStyle(e).transform;if("none"===n)e.style.transform="scale("+t+","+t+")";else{var r=n.split(",");n.includes("3d")?e.style.transform=n+" scale3d("+t+","+t+", 1)":(r[0]="matrix("+t,r[3]=t,e.style.transform=n+" scale("+t+","+t+")")}e.dataset.scale=t}},{key:"_onWheeling",value:function(e){e.preventDefault();var t=e.deltaY>0?.8:1.2;this._setChartScale(this.chart,t)}},{key:"_getPinchDist",value:function(e){return Math.sqrt((e.touches[0].clientX-e.touches[1].clientX)*(e.touches[0].clientX-e.touches[1].clientX)+(e.touches[0].clientY-e.touches[1].clientY)*(e.touches[0].clientY-e.touches[1].clientY))}},{key:"_onTouchStart",value:function(e){var t=this.chart;if(e.touches&&2===e.touches.length){var n=this._getPinchDist(e);t.dataset.pinching=!0,t.dataset.pinchDistStart=n}}},{key:"_onTouchMove",value:function(e){var t=this.chart;if(t.dataset.pinching){var n=this._getPinchDist(e);t.dataset.pinchDistEnd=n}}},{key:"_onTouchEnd",value:function(e){var t=this.chart;if(t.dataset.pinching){t.dataset.pinching=!1;var n=t.dataset.pinchDistEnd-t.dataset.pinchDistStart;n>0?this._setChartScale(t,1):n<0&&this._setChartScale(t,-1)}}},{key:"name",get:function(){return this._name}}]),e}(),z=Array.prototype.splice;r.prototype.clear=function(){this.__data__=[],this.size=0},r.prototype.delete=function(e){var t=this.__data__,r=n(t,e);return!(r<0||(r==t.length-1?t.pop():z.call(t,r,1),--this.size,0))},r.prototype.get=function(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]},r.prototype.has=function(e){return n(this.__data__,e)>-1},r.prototype.set=function(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this};var H="object"==typeof global&&global&&global.Object===Object&&global,R="object"==typeof self&&self&&self.Object===Object&&self,M=H||R||Function("return this")(),I=M.Symbol,F=Object.prototype,U=F.hasOwnProperty,V=F.toString,J=I?I.toStringTag:void 0,X=Object.prototype.toString,Y="[object Null]",$="[object Undefined]",W=I?I.toStringTag:void 0,G="[object AsyncFunction]",Z="[object Function]",K="[object GeneratorFunction]",Q="[object Proxy]",ee=M["__core-js_shared__"],te=function(){var e=/[^.]+$/.exec(ee&&ee.keys&&ee.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ne=Function.prototype.toString,re=/^\[object .+?Constructor\]$/,ie=Function.prototype,oe=Object.prototype,se=ie.toString,ae=oe.hasOwnProperty,le=RegExp("^"+se.call(ae).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ce=l(M,"Map"),de=l(Object,"create"),ue="__lodash_hash_undefined__",he=Object.prototype.hasOwnProperty,fe=Object.prototype.hasOwnProperty,pe="__lodash_hash_undefined__";c.prototype.clear=function(){this.__data__=de?de(null):{},this.size=0},c.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},c.prototype.get=function(e){var t=this.__data__;if(de){var n=t[e];return n===ue?void 0:n}return he.call(t,e)?t[e]:void 0},c.prototype.has=function(e){var t=this.__data__;return de?void 0!==t[e]:fe.call(t,e)},c.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=de&&void 0===t?pe:t,this},u.prototype.clear=function(){this.size=0,this.__data__={hash:new c,map:new(ce||r),string:new c}},u.prototype.delete=function(e){var t=d(this,e).delete(e);return this.size-=t?1:0,t},u.prototype.get=function(e){return d(this,e).get(e)},u.prototype.has=function(e){return d(this,e).has(e)},u.prototype.set=function(e,t){var n=d(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};var ve=200;h.prototype.clear=function(){this.__data__=new r,this.size=0},h.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},h.prototype.get=function(e){return this.__data__.get(e)},h.prototype.has=function(e){return this.__data__.has(e)},h.prototype.set=function(e,t){var n=this.__data__;if(n instanceof r){var i=n.__data__;if(!ce||i.length0){if(++t>=it)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(rt),lt=function(e){return q(function(n,r){var i=-1,s=r.length,a=s>1?r[s-1]:void 0,l=s>2?r[2]:void 0;for(a=e.length>3&&"function"==typeof a?(s--,a):void 0,l&&function(e,n,r){if(!o(r))return!1;var i=typeof n;return!!("number"==i?_(r)&&S(n,r.length):"string"==i&&n in r)&&t(r[n],e)}(r[0],r[1],l)&&(a=s<3?void 0:a,s=1),n=Object(n);++i-1&&e%1==0&&e<=Oe}function _(e){return null!=e&&b(e.length)&&!s(e)}function E(e,n,r){var i=e[n];Ze.call(e,n)&&t(i,r)&&(void 0!==r||n in e)||f(e,n,r)}function S(e,t){return!!(t=null==t?Ke:t)&&("number"==typeof e||Qe.test(e))&&e>-1&&e%1==0&&e0?t.split(" ").forEach(function(t){return e.classList.add(t)}):e.classList.add(t)})}},{key:"_removeClass",value:function(e,t){e.forEach(function(e){t.indexOf(" ")>0?t.split(" ").forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t)})}},{key:"_css",value:function(e,t,n){e.forEach(function(e){e.style[t]=n})}},{key:"_removeAttr",value:function(e,t){e.forEach(function(e){e.removeAttribute(t)})}},{key:"_one",value:function(e,t,n,r){e&&e.addEventListener(t,function i(o){try{n.call(r,o)}finally{e.removeEventListener(t,i)}})}},{key:"_getDescElements",value:function(e,t){var n=[];return e.forEach(function(e){return n.push.apply(n,D(e.querySelectorAll(t)))}),n}},{key:"_getJSON",value:function(e){return new Promise(function(t,n){var r=new XMLHttpRequest;r.open("GET",e),r.onreadystatechange=function(){4===this.readyState&&(200===this.status?t(JSON.parse(this.response)):n(new Error(this.statusText)))},r.responseType="json",r.setRequestHeader("Content-Type","application/json"),r.send()})}},{key:"_buildJsonDS",value:function(e){var t=this,n={name:e.firstChild.textContent.trim(),relationship:("LI"===e.parentNode.parentNode.nodeName?"1":"0")+(e.parentNode.children.length>1?1:0)+(e.children.length?1:0)};return e.id&&(n.id=e.id),e.querySelector("ul")&&Array.from(e.querySelector("ul").children).forEach(function(e){n.children||(n.children=[]),n.children.push(t._buildJsonDS(e))}),n}},{key:"_attachRel",value:function(e,t){if(e.relationship=t+(e.children&&e.children.length>0?1:0),e.children){var n=!0,r=!1,i=void 0;try{for(var o,s=e.children[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var a=o.value;this._attachRel(a,"1"+(e.children.length>1?1:0))}}catch(e){r=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}}return e}},{key:"_repaint",value:function(e){e&&(e.style.offsetWidth=e.offsetWidth)}},{key:"_isInAction",value:function(e){return e.querySelector(":scope > .edge").className.indexOf("fa-")>-1}},{key:"_getNodeState",value:function(e,t){var n=this,r=void 0,i={exist:!1,visible:!1};return"parent"===t?((r=this._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}))&&(i.exist=!0),i.exist&&this._isVisible(r.parentNode.children[0])&&(i.visible=!0)):"children"===t?((r=this._closest(e,function(e){return"TR"===e.nodeName}).nextElementSibling)&&(i.exist=!0),i.exist&&this._isVisible(r)&&(i.visible=!0)):"siblings"===t&&((r=this._siblings(this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode)).length&&(i.exist=!0),i.exist&&r.some(function(e){return n._isVisible(e)})&&(i.visible=!0)),i}},{key:"getRelatedNodes",value:function(e,t){return"parent"===t?this._closest(e,function(e){return e.classList.contains("nodes")}).parentNode.children[0].querySelector(".node"):"children"===t?Array.from(this._closest(e,function(e){return"TABLE"===e.nodeName}).lastChild.children).map(function(e){return e.querySelector(".node")}):"siblings"===t?this._siblings(this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode).map(function(e){return e.querySelector(".node")}):[]}},{key:"_switchHorizontalArrow",value:function(e){var t=this.options,n=e.querySelector(".leftEdge"),r=e.querySelector(".rightEdge"),i=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;if(t.toggleSiblingsResp&&(void 0===t.ajaxURL||this._closest(e,function(e){return e.classList.contains(".nodes")}).dataset.siblingsLoaded)){var o=i.previousElementSibling,s=i.nextElementSibling;o&&(o.classList.contains("hidden")?(n.classList.add("fa-chevron-left"),n.classList.remove("fa-chevron-right")):(n.classList.add("fa-chevron-right"),n.classList.remove("fa-chevron-left"))),s&&(s.classList.contains("hidden")?(r.classList.add("fa-chevron-right"),r.classList.remove("fa-chevron-left")):(r.classList.add("fa-chevron-left"),r.classList.remove("fa-chevron-right")))}else{var a=this._siblings(i),l=!!a.length&&!a.some(function(e){return e.classList.contains("hidden")});n.classList.toggle("fa-chevron-right",l),n.classList.toggle("fa-chevron-left",!l),r.classList.toggle("fa-chevron-left",l),r.classList.toggle("fa-chevron-right",!l)}}},{key:"_hoverNode",value:function(e){var t=e.target,n=!1,r=t.querySelector(":scope > .topEdge"),i=t.querySelector(":scope > .bottomEdge"),o=t.querySelector(":scope > .leftEdge");"mouseenter"===e.type?(r&&(n=this._getNodeState(t,"parent").visible,r.classList.toggle("fa-chevron-up",!n),r.classList.toggle("fa-chevron-down",n)),i&&(n=this._getNodeState(t,"children").visible,i.classList.toggle("fa-chevron-down",!n),i.classList.toggle("fa-chevron-up",n)),o&&this._switchHorizontalArrow(t)):Array.from(t.querySelectorAll(":scope > .edge")).forEach(function(e){e.classList.remove("fa-chevron-up","fa-chevron-down","fa-chevron-right","fa-chevron-left")})}},{key:"_clickNode",value:function(e){var t=e.currentTarget,n=this.chart.querySelector(".focused");n&&n.classList.remove("focused"),t.classList.add("focused")}},{key:"_buildParentNode",value:function(e,t,n){var r=this,i=document.createElement("table");t.relationship=t.relationship||"001",this._createNode(t,0).then(function(e){var t=r.chart;e.classList.remove("slide-up"),e.classList.add("slide-down");var o=document.createElement("tr"),s=document.createElement("tr"),a=document.createElement("tr"),l=document.createElement("tr");o.setAttribute("class","hidden"),o.innerHTML='',i.appendChild(o),s.setAttribute("class","lines hidden"),s.innerHTML='
',i.appendChild(s),a.setAttribute("class","lines hidden"),a.innerHTML='  ',i.appendChild(a),l.setAttribute("class","nodes"),l.innerHTML='',i.appendChild(l),i.querySelector("td").appendChild(e),t.insertBefore(i,t.children[0]),i.children[3].children[0].appendChild(t.lastChild),n()}).catch(function(e){console.error("Failed to create parent node",e)})}},{key:"_switchVerticalArrow",value:function(e){e.classList.toggle("fa-chevron-up"),e.classList.toggle("fa-chevron-down")}},{key:"showParent",value:function(e){var t=this._prevAll(this._closest(e,function(e){return e.classList.contains("nodes")}));this._removeClass(t,"hidden"),this._addClass(Array(t[0].children).slice(1,-1),"hidden");var n=t[2].querySelector(".node");this._one(n,"transitionend",function(){n.classList.remove("slide"),this._isInAction(e)&&this._switchVerticalArrow(e.querySelector(":scope > .topEdge"))},this),this._repaint(n),n.classList.add("slide"),n.classList.remove("slide-down")}},{key:"showSiblings",value:function(e,t){var n=this,r=[],i=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;r=t?"left"===t?this._prevAll(i):this._nextAll(i):this._siblings(i),this._removeClass(r,"hidden");var o=this._prevAll(this._closest(e,function(e){return e.classList.contains("nodes")}));if(i=Array.from(o[0].querySelectorAll(":scope > .hidden")),t?this._removeClass(i.slice(0,2*r.length),"hidden"):this._removeClass(i,"hidden"),!this._getNodeState(e,"parent").visible){this._removeClass(o,"hidden");var s=o[2].querySelector(".node");this._one(s,"transitionend",function(e){e.target.classList.remove("slide")},this),this._repaint(s),s.classList.add("slide"),s.classList.remove("slide-down")}r.forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){n._isVisible(e)&&(e.classList.add("slide"),e.classList.remove("slide-left","slide-right"))})}),this._one(r[0].querySelector(".slide"),"transitionend",function(){var t=this;r.forEach(function(e){t._removeClass(Array.from(e.querySelectorAll(".slide")),"slide")}),this._isInAction(e)&&(this._switchHorizontalArrow(e),e.querySelector(".topEdge").classList.remove("fa-chevron-up"),e.querySelector(".topEdge").classList.add("fa-chevron-down"))},this)}},{key:"hideSiblings",value:function(e,t){var n=this,r=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode;if(this._siblings(r).forEach(function(e){e.querySelector(".spinner")&&(n.chart.dataset.inAjax=!1)}),!t||t&&"left"===t){this._prevAll(r).forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){n._isVisible(e)&&e.classList.add("slide","slide-right")})})}if(!t||t&&"left"!==t){this._nextAll(r).forEach(function(e){Array.from(e.querySelectorAll(".node")).forEach(function(e){n._isVisible(e)&&e.classList.add("slide","slide-left")})})}var i=[];this._siblings(r).forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelectorAll(".slide")))});var o=[],s=!0,a=!1,l=void 0;try{for(var c,d=i[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){var u=c.value,h=this._closest(u,function(e){return e.classList.contains("nodes")}).previousElementSibling;o.push(h),o.push(h.previousElementSibling)}}catch(e){a=!0,l=e}finally{try{!s&&d.return&&d.return()}finally{if(a)throw l}}(o=[].concat(D(new Set(o)))).forEach(function(e){e.style.visibility="hidden"}),this._one(i[0],"transitionend",function(n){var s=this;o.forEach(function(e){e.removeAttribute("style")});var a=[];a=t?"left"===t?this._prevAll(r,":not(.hidden)"):this._nextAll(r,":not(.hidden)"):this._siblings(r);var l=Array.from(this._closest(r,function(e){return e.classList.contains("nodes")}).previousElementSibling.querySelectorAll(":scope > :not(.hidden)")).slice(1,t?2*a.length+1:-1);this._addClass(l,"hidden"),this._removeClass(i,"slide"),a.forEach(function(e){Array.from(e.querySelectorAll(".node")).slice(1).forEach(function(e){s._isVisible(e)&&(e.classList.remove("slide-left","slide-right"),e.classList.add("slide-up"))})}),a.forEach(function(e){s._addClass(Array.from(e.querySelectorAll(".lines")),"hidden"),s._addClass(Array.from(e.querySelectorAll(".nodes")),"hidden"),s._addClass(Array.from(e.querySelectorAll(".verticalNodes")),"hidden")}),this._addClass(a,"hidden"),this._isInAction(e)&&this._switchHorizontalArrow(e)},this)}},{key:"hideParent",value:function(e){var t=Array.from(this._closest(e,function(e){return e.classList.contains("nodes")}).parentNode.children).slice(0,3);t[0].querySelector(".spinner")&&(this.chart.dataset.inAjax=!1),this._getNodeState(e,"siblings").visible&&this.hideSiblings(e);var n=t.slice(1);this._css(n,"visibility","hidden");var r=t[0].querySelector(".node"),i=this._getNodeState(r,"parent").visible;r&&this._isVisible(r)&&(r.classList.add("slide","slide-down"),this._one(r,"transitionend",function(){r.classList.remove("slide"),this._removeAttr(n,"style"),this._addClass(t,"hidden")},this)),r&&i&&this.hideParent(r)}},{key:"addParent",value:function(e,t){var n=this;this._buildParentNode(e,t,function(){if(!e.querySelector(":scope > .topEdge")){var t=document.createElement("i");t.setAttribute("class","edge verticalEdge topEdge fa"),e.appendChild(t)}n.showParent(e)})}},{key:"_startLoading",value:function(e,t){var n=this.options,r=this.chart;if(void 0!==r.dataset.inAjax&&"true"===r.dataset.inAjax)return!1;e.classList.add("hidden");var i=document.createElement("i");i.setAttribute("class","fa fa-circle-o-notch fa-spin spinner"),t.appendChild(i),this._addClass(Array.from(t.querySelectorAll(":scope > *:not(.spinner)")),"hazy"),r.dataset.inAjax=!0;var o=this.chartContainer.querySelector(".oc-export-btn"+(""!==n.chartClass?"."+n.chartClass:""));return o&&(o.disabled=!0),!0}},{key:"_endLoading",value:function(e,t){var n=this.options;e.classList.remove("hidden"),t.querySelector(":scope > .spinner").remove(),this._removeClass(Array.from(t.querySelectorAll(":scope > .hazy")),"hazy"),this.chart.dataset.inAjax=!1;var r=this.chartContainer.querySelector(".oc-export-btn"+(""!==n.chartClass?"."+n.chartClass:""));r&&(r.disabled=!1)}},{key:"_clickTopEdge",value:function(e){e.stopPropagation();var t=this,n=e.target,r=n.parentNode,i=this._getNodeState(r,"parent"),o=this.options;if(i.exist){var s=this._closest(r,function(e){return e.classList.contains("nodes")}).parentNode.firstChild.querySelector(".node");if(s.classList.contains("slide"))return;i.visible?(this.hideParent(r),this._one(s,"transitionend",function(){this._isInAction(r)&&(this._switchVerticalArrow(n),this._switchHorizontalArrow(r))},this)):this.showParent(r)}else{var a=n.parentNode.id;this._startLoading(n,r)&&this._getJSON("function"==typeof o.ajaxURL.parent?o.ajaxURL.parent(r.dataset.source):o.ajaxURL.parent+a).then(function(e){"true"===t.chart.dataset.inAjax&&Object.keys(e).length&&t.addParent(r,e)}).catch(function(e){console.error("Failed to get parent node data.",e)}).finally(function(){t._endLoading(n,r)})}}},{key:"hideChildren",value:function(e){var t=this,n=this._nextAll(e.parentNode.parentNode),r=n[n.length-1],i=[];r.querySelector(".spinner")&&(this.chart.dataset.inAjax=!1);var o=Array.from(r.querySelectorAll(".node")).filter(function(e){return t._isVisible(e)}),s=r.classList.contains("verticalNodes");s||(o.forEach(function(e){Array.prototype.push.apply(i,t._prevAll(t._closest(e,function(e){return e.classList.contains("nodes")}),".lines"))}),i=[].concat(D(new Set(i))),this._css(i,"visibility","hidden")),this._one(o[0],"transitionend",function(a){this._removeClass(o,"slide"),s?t._addClass(n,"hidden"):(i.forEach(function(e){e.removeAttribute("style"),e.classList.add("hidden"),e.parentNode.lastChild.classList.add("hidden")}),this._addClass(Array.from(r.querySelectorAll(".verticalNodes")),"hidden")),this._isInAction(e)&&this._switchVerticalArrow(e.querySelector(".bottomEdge"))},this),this._addClass(o,"slide slide-up")}},{key:"showChildren",value:function(e){var t=this,n=this,r=this._nextAll(e.parentNode.parentNode),i=[];this._removeClass(r,"hidden"),r.some(function(e){return e.classList.contains("verticalNodes")})?r.forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelectorAll(".node")).filter(function(e){return n._isVisible(e)}))}):Array.from(r[2].children).forEach(function(e){Array.prototype.push.apply(i,Array.from(e.querySelector("tr").querySelectorAll(".node")).filter(function(e){return n._isVisible(e)}))}),this._repaint(i[0]),this._one(i[0],"transitionend",function(n){t._removeClass(i,"slide"),t._isInAction(e)&&t._switchVerticalArrow(e.querySelector(".bottomEdge"))},this),this._addClass(i,"slide"),this._removeClass(i,"slide-up")}},{key:"_buildChildNode",value:function(e,t,n){var r=t.children||t.siblings;e.querySelector("td").setAttribute("colSpan",2*r.length),this.buildHierarchy(e,{children:r},0,n)}},{key:"addChildren",value:function(e,t){var n=this,r=this.options,i=0;this.chart.dataset.inEdit="addChildren",this._buildChildNode.call(this,this._closest(e,function(e){return"TABLE"===e.nodeName}),t,function(){if(++i===t.children.length){if(!e.querySelector(".bottomEdge")){var o=document.createElement("i");o.setAttribute("class","edge verticalEdge bottomEdge fa"),e.appendChild(o)}if(!e.querySelector(".symbol")){var s=document.createElement("i");s.setAttribute("class","fa "+r.parentNodeSymbol+" symbol"),e.querySelector(":scope > .title").appendChild(s)}n.showChildren(e),n.chart.dataset.inEdit=""}})}},{key:"_clickBottomEdge",value:function(e){var t=this;e.stopPropagation();var n=this,r=this.options,i=e.target,o=i.parentNode,s=this._getNodeState(o,"children");if(s.exist){var a=this._closest(o,function(e){return"TR"===e.nodeName}).parentNode.lastChild;if(Array.from(a.querySelectorAll(".node")).some(function(e){return t._isVisible(e)&&e.classList.contains("slide")}))return;s.visible?this.hideChildren(o):this.showChildren(o)}else{var l=i.parentNode.id;this._startLoading(i,o)&&this._getJSON("function"==typeof r.ajaxURL.children?r.ajaxURL.children(o.dataset.source):r.ajaxURL.children+l).then(function(e){"true"===n.chart.dataset.inAjax&&e.children.length&&n.addChildren(o,e)}).catch(function(e){console.error("Failed to get children nodes data",e)}).finally(function(){n._endLoading(i,o)})}}},{key:"_complementLine",value:function(e,t,n){var r=e.parentNode.parentNode.children;r[0].children[0].setAttribute("colspan",2*t),r[1].children[0].setAttribute("colspan",2*t);for(var i=0;i1?Math.floor(a/2-1):0;if("TD"===e.parentNode.nodeName){var c=this._prevAll(e.parentNode.parentNode);c[0].remove(),c[1].remove();var d=0;i._buildChildNode.call(i,i._closest(e.parentNode,function(e){return"TABLE"===e.nodeName}),t,function(){if(++d===o){var t=Array.from(i._closest(e.parentNode,function(e){return"TABLE"===e.nodeName}).lastChild.children);if(s>1){var r=e.parentNode.parentNode;Array.from(r.children).forEach(function(e){t[0].parentNode.insertBefore(e,t[0])}),r.remove(),i._complementLine(t[0],a,s),i._addClass(t,"hidden"),t.forEach(function(e){i._addClass(e.querySelectorAll(".node"),"slide-left")})}else{var c=e.parentNode.parentNode;t[l].parentNode.insertBefore(e.parentNode,t[l+1]),c.remove(),i._complementLine(t[l],a,1),i._addClass(t,"hidden"),i._addClass(i._getDescElements(t.slice(0,l+1),".node"),"slide-right"),i._addClass(i._getDescElements(t.slice(l+1),".node"),"slide-left")}n()}})}else{var u=0;i.buildHierarchy.call(i,i.chart,t,0,function(){if(++u===a){var t=e.nextElementSibling.children[3].children[l],o=document.createElement("td");o.setAttribute("colspan",2),o.appendChild(e),t.parentNode.insertBefore(o,t.nextElementSibling),i._complementLine(t,a,1);var s=i._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0];s.classList.add("hidden"),i._addClass(Array.from(s.querySelectorAll(".node")),"slide-down");var c=r._siblings(e.parentNode);i._addClass(c,"hidden"),i._addClass(i._getDescElements(c.slice(0,l),".node"),"slide-right"),i._addClass(i._getDescElements(c.slice(l),".node"),"slide-left"),n()}})}}},{key:"addSiblings",value:function(e,t){var n=this;this.chart.dataset.inEdit="addSiblings",this._buildSiblingNode.call(this,this._closest(e,function(e){return"TABLE"===e.nodeName}),t,function(){if(n._closest(e,function(e){return e.classList&&e.classList.contains("nodes")}).dataset.siblingsLoaded=!0,!e.querySelector(".leftEdge")){var t=document.createElement("i"),r=document.createElement("i");t.setAttribute("class","edge horizontalEdge rightEdge fa"),e.appendChild(t),r.setAttribute("class","edge horizontalEdge leftEdge fa"),e.appendChild(r)}n.showSiblings(e),n.chart.dataset.inEdit=""})}},{key:"removeNodes",value:function(e){var t=this._closest(e,function(e){return"TABLE"===e.nodeName}).parentNode,n=this._siblings(t.parentNode);"TD"===t.nodeName?this._getNodeState(e,"siblings").exist?(n[2].querySelector(".topLine").nextElementSibling.remove(),n[2].querySelector(".topLine").remove(),n[0].children[0].setAttribute("colspan",n[2].children.length),n[1].children[0].setAttribute("colspan",n[2].children.length),t.remove()):(n[0].children[0].removeAttribute("colspan"),n[0].querySelector(".bottomEdge").remove(),this._siblings(n[0]).forEach(function(e){return e.remove()})):Array.from(t.parentNode.children).forEach(function(e){return e.remove()})}},{key:"_clickHorizontalEdge",value:function(e){var t=this;e.stopPropagation();var n=this,r=this.options,i=e.target,o=i.parentNode,s=this._getNodeState(o,"siblings");if(s.exist){var a=this._closest(o,function(e){return"TABLE"===e.nodeName}).parentNode;if(this._siblings(a).some(function(e){var n=e.querySelector(".node");return t._isVisible(n)&&n.classList.contains("slide")}))return;if(r.toggleSiblingsResp){var l=this._closest(o,function(e){return"TABLE"===e.nodeName}).parentNode.previousElementSibling,c=this._closest(o,function(e){return"TABLE"===e.nodeName}).parentNode.nextElementSibling;i.classList.contains("leftEdge")?l&&l.classList.contains("hidden")?this.showSiblings(o,"left"):this.hideSiblings(o,"left"):c&&c.classList.contains("hidden")?this.showSiblings(o,"right"):this.hideSiblings(o,"right")}else s.visible?this.hideSiblings(o):this.showSiblings(o)}else{var d=i.parentNode.id,u=this._getNodeState(o,"parent").exist?"function"==typeof r.ajaxURL.siblings?r.ajaxURL.siblings(JSON.parse(o.dataset.source)):r.ajaxURL.siblings+d:"function"==typeof r.ajaxURL.families?r.ajaxURL.families(JSON.parse(o.dataset.source)):r.ajaxURL.families+d;this._startLoading(i,o)&&this._getJSON(u).then(function(e){"true"===n.chart.dataset.inAjax&&(e.siblings||e.children)&&n.addSiblings(o,e)}).catch(function(e){console.error("Failed to get sibling nodes data",e)}).finally(function(){n._endLoading(i,o)})}}},{key:"_clickToggleButton",value:function(e){var t=this,n=e.target,r=n.parentNode.nextElementSibling,i=Array.from(r.querySelectorAll(".node")),o=Array.from(r.children).map(function(e){return e.querySelector(".node")});o.some(function(e){return e.classList.contains("slide")})||(n.classList.toggle("fa-plus-square"),n.classList.toggle("fa-minus-square"),i[0].classList.contains("slide-up")?(r.classList.remove("hidden"),this._repaint(o[0]),this._addClass(o,"slide"),this._removeClass(o,"slide-up"),this._one(o[0],"transitionend",function(){t._removeClass(o,"slide")})):(this._addClass(i,"slide slide-up"),this._one(i[0],"transitionend",function(){t._removeClass(i,"slide"),i.forEach(function(e){t._closest(e,function(e){return"UL"===e.nodeName}).classList.add("hidden")})}),i.forEach(function(e){var n=Array.from(e.querySelectorAll(".toggleBtn"));t._removeClass(n,"fa-minus-square"),t._addClass(n,"fa-plus-square")})))}},{key:"_dispatchClickEvent",value:function(e){var t=e.target.classList;t.contains("topEdge")?this._clickTopEdge(e):t.contains("rightEdge")||t.contains("leftEdge")?this._clickHorizontalEdge(e):t.contains("bottomEdge")?this._clickBottomEdge(e):t.contains("toggleBtn")?this._clickToggleButton(e):this._clickNode(e)}},{key:"_onDragStart",value:function(e){var t=e.target,n=this.options,r=/firefox/.test(window.navigator.userAgent.toLowerCase());if(r&&e.dataTransfer.setData("text/html","hack for firefox"),this.chart.style.transform){var i=void 0,o=void 0;document.querySelector(".ghost-node")?o=(i=this.chart.querySelector(":scope > .ghost-node")).children[0]:((i=document.createElementNS("http://www.w3.org/2000/svg","svg")).classList.add("ghost-node"),o=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.appendChild(o),this.chart.appendChild(i));var s=this.chart.style.transform.split(","),a=Math.abs(window.parseFloat("t2b"===n.direction||"b2t"===n.direction?s[0].slice(s[0].indexOf("(")+1):s[1]));i.setAttribute("width",t.offsetWidth),i.setAttribute("height",t.offsetHeight),o.setAttribute("x",5*a),o.setAttribute("y",5*a),o.setAttribute("width",120*a),o.setAttribute("height",40*a),o.setAttribute("rx",4*a),o.setAttribute("ry",4*a),o.setAttribute("stroke-width",1*a);var l=e.offsetX*a,c=e.offsetY*a;if("l2r"===n.direction?(l=e.offsetY*a,c=e.offsetX*a):"r2l"===n.direction?(l=t.offsetWidth-e.offsetY*a,c=e.offsetX*a):"b2t"===n.direction&&(l=t.offsetWidth-e.offsetX*a,c=t.offsetHeight-e.offsetY*a),r){var d=document.createElement("img");d.src="data:image/svg+xml;utf8,"+(new XMLSerializer).serializeToString(i),e.dataTransfer.setDragImage(d,l,c),o.setAttribute("fill","rgb(255, 255, 255)"),o.setAttribute("stroke","rgb(191, 0, 0)")}else e.dataTransfer.setDragImage(i,l,c)}var u=e.target,h=null;null!==this._closest(u,function(e){return e.classList&&e.classList.contains("nodes")})&&(h=this._closest(u,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0].querySelector(".node"));var f=Array.from(this._closest(u,function(e){return"TABLE"===e.nodeName}).querySelectorAll(".node"));this.dragged=u,Array.from(this.chart.querySelectorAll(".node")).forEach(function(e){f.includes(e)||(n.dropCriteria?n.dropCriteria(u,h,e)&&e.classList.add("allowedDrop"):e.classList.add("allowedDrop"))})}},{key:"_onDragOver",value:function(e){e.preventDefault();e.currentTarget.classList.contains("allowedDrop")||(e.dataTransfer.dropEffect="none")}},{key:"_onDragEnd",value:function(e){Array.from(this.chart.querySelectorAll(".allowedDrop")).forEach(function(e){e.classList.remove("allowedDrop")})}},{key:"_onDrop",value:function(e){var t=e.currentTarget,n=this.chart,r=this.dragged,i=this._closest(r,function(e){return e.classList&&e.classList.contains("nodes")}).parentNode.children[0].children[0];if(this._removeClass(Array.from(n.querySelectorAll(".allowedDrop")),"allowedDrop"),t.parentNode.parentNode.nextElementSibling){var o=window.parseInt(t.parentNode.colSpan)+2;if(t.parentNode.setAttribute("colspan",o),t.parentNode.parentNode.nextElementSibling.children[0].setAttribute("colspan",o),!r.querySelector(".horizontalEdge")){var s=document.createElement("i"),a=document.createElement("i");s.setAttribute("class","edge horizontalEdge rightEdge fa"),r.appendChild(s),a.setAttribute("class","edge horizontalEdge leftEdge fa"),r.appendChild(a)}var l=t.parentNode.parentNode.nextElementSibling.nextElementSibling,c=document.createElement("td"),d=document.createElement("td");c.setAttribute("class","leftLine topLine"),c.innerHTML=" ",l.insertBefore(c,l.children[1]),d.setAttribute("class","rightLine topLine"),d.innerHTML=" ",l.insertBefore(d,l.children[2]),l.nextElementSibling.appendChild(this._closest(r,function(e){return"TABLE"===e.nodeName}).parentNode);var u=this._siblings(this._closest(r,function(e){return"TABLE"===e.nodeName}).parentNode).map(function(e){return e.querySelector(".node")});if(1===u.length){var h=document.createElement("i"),f=document.createElement("i");h.setAttribute("class","edge horizontalEdge rightEdge fa"),u[0].appendChild(h),f.setAttribute("class","edge horizontalEdge leftEdge fa"),u[0].appendChild(f)}}else{var p=document.createElement("i");p.setAttribute("class","edge verticalEdge bottomEdge fa"),t.appendChild(p),t.parentNode.setAttribute("colspan",2);var v=this._closest(t,function(e){return"TABLE"===e.nodeName}),g=document.createElement("tr"),y=document.createElement("tr"),m=document.createElement("tr");g.setAttribute("class","lines"),g.innerHTML='
',v.appendChild(g),y.setAttribute("class","lines"),y.innerHTML='  ',v.appendChild(y),m.setAttribute("class","nodes"),v.appendChild(m),Array.from(r.querySelectorAll(".horizontalEdge")).forEach(function(e){r.removeChild(e)});var b=this._closest(r,function(e){return"TABLE"===e.nodeName}).parentNode;m.appendChild(b)}var _=window.parseInt(i.colSpan);if(_>2){i.setAttribute("colspan",_-2),i.parentNode.nextElementSibling.children[0].setAttribute("colspan",_-2);var E=i.parentNode.nextElementSibling.nextElementSibling;E.children[1].remove(),E.children[1].remove();var S=Array.from(i.parentNode.parentNode.children[3].children).map(function(e){return e.querySelector(".node")});1===S.length&&(S[0].querySelector(".leftEdge").remove(),S[0].querySelector(".rightEdge").remove())}else i.removeAttribute("colspan"),i.querySelector(".node").removeChild(i.querySelector(".bottomEdge")),Array.from(i.parentNode.parentNode.children).slice(1).forEach(function(e){return e.remove()});var A=new CustomEvent("nodedropped.orgchart",{detail:{draggedNode:r,dragZone:i.children[0],dropZone:t}});n.dispatchEvent(A)}},{key:"_createNode",value:function(e,t){var n=this,r=this.options;return new Promise(function(i,o){if(e.children){var s=!0,a=!1,l=void 0;try{for(var c,d=e.children[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){c.value.parentId=e.id}}catch(e){a=!0,l=e}finally{try{!s&&d.return&&d.return()}finally{if(a)throw l}}}var u=document.createElement("div");delete e.children,u.dataset.source=JSON.stringify(e),e[r.nodeId]&&(u.id=e[r.nodeId]);var h=n.chart.dataset.inEdit,f=void 0;f=h?"addChildren"===h?" slide-up":"":t>=r.depth?" slide-up":"",u.setAttribute("class","node "+(e.className||"")+f),r.draggable&&u.setAttribute("draggable",!0),e.parentId&&u.setAttribute("data-parent",e.parentId),u.innerHTML='\n
'+e[r.nodeTitle]+"
\n "+(r.nodeContent?'
'+e[r.nodeContent]+"
":"")+"\n ";var p=e.relationship||"";if(r.verticalDepth&&t+2>r.verticalDepth){if(t+1>=r.verticalDepth&&Number(p.substr(2,1))){var v=document.createElement("i"),g=t+1>=r.depth?"plus":"minus";v.setAttribute("class","toggleBtn fa fa-"+g+"-square"),u.appendChild(v)}}else{if(Number(p.substr(0,1))){var y=document.createElement("i");y.setAttribute("class","edge verticalEdge topEdge fa"),u.appendChild(y)}if(Number(p.substr(1,1))){var m=document.createElement("i"),b=document.createElement("i");m.setAttribute("class","edge horizontalEdge rightEdge fa"),u.appendChild(m),b.setAttribute("class","edge horizontalEdge leftEdge fa"),u.appendChild(b)}if(Number(p.substr(2,1))){var _=document.createElement("i"),E=document.createElement("i"),S=u.querySelector(":scope > .title");_.setAttribute("class","edge verticalEdge bottomEdge fa"),u.appendChild(_),E.setAttribute("class","fa "+r.parentNodeSymbol+" symbol"),S.insertBefore(E,S.children[0])}}r.toggleCollapse&&(u.addEventListener("mouseenter",n._hoverNode.bind(n)),u.addEventListener("mouseleave",n._hoverNode.bind(n)),u.addEventListener("click",n._dispatchClickEvent.bind(n))),r.draggable&&(u.addEventListener("dragstart",n._onDragStart.bind(n)),u.addEventListener("dragover",n._onDragOver.bind(n)),u.addEventListener("dragend",n._onDragEnd.bind(n)),u.addEventListener("drop",n._onDrop.bind(n))),r.createNode&&r.createNode(u,e),i(u)})}},{key:"buildHierarchy",value:function(e,t,n,r){var i=this,o=this.options,s=void 0,a=t.children,l=o.verticalDepth&&n+1>=o.verticalDepth;if(Object.keys(t).length>1&&(s=l?e:document.createElement("table"),l||e.appendChild(s),this._createNode(t,n).then(function(e){if(l)s.insertBefore(e,s.firstChild);else{var t=document.createElement("tr");t.innerHTML="\n \n \n ",t.children[0].appendChild(e),s.insertBefore(t,s.children[0]?s.children[0]:null)}r&&r()}).catch(function(e){console.error("Failed to creat node",e)})),a&&0!==a.length){1===Object.keys(t).length&&(s=e);var c=void 0,d=o.verticalDepth&&n+2>=o.verticalDepth,u=i.chart.dataset.inEdit;if(c=u?"addSiblings"===u?"":" hidden":n+1>=o.depth?" hidden":"",!d){var h=document.createElement("tr");h.setAttribute("class","lines"+c),h.innerHTML='\n \n
\n \n ',s.appendChild(h)}var f=document.createElement("tr");f.setAttribute("class","lines"+c),f.innerHTML='\n  \n '+a.slice(1).map(function(){return'\n  \n  \n '}).join("")+'\n  \n ';var p=void 0;if(d)if(p=document.createElement("ul"),c&&p.classList.add(c.trim()),n+2===o.verticalDepth){var v=document.createElement("tr");v.setAttribute("class","verticalNodes"+c),v.innerHTML="",v.firstChild.appendChild(p),s.appendChild(v)}else s.appendChild(p);else(p=document.createElement("tr")).setAttribute("class","nodes"+c),s.appendChild(f),s.appendChild(p);a.forEach(function(e){var t=void 0;d?t=document.createElement("li"):(t=document.createElement("td")).setAttribute("colspan",2),p.appendChild(t),i.buildHierarchy(t,e,n+1,r)})}}},{key:"_clickChart",value:function(e){!this._closest(e.target,function(e){return e.classList&&e.classList.contains("node")})&&this.chart.querySelector(".node.focused")&&this.chart.querySelector(".node.focused").classList.remove("focused")}},{key:"_clickExportButton",value:function(){var e=this.options,t=this.chartContainer,n=t.querySelector(":scope > .mask"),r=t.querySelector(".orgchart:not(.hidden)"),i="l2r"===e.direction||"r2l"===e.direction;n?n.classList.remove("hidden"):((n=document.createElement("div")).setAttribute("class","mask"),n.innerHTML='',t.appendChild(n)),t.classList.add("canvasContainer"),window.html2canvas(r,{width:i?r.clientHeight:r.clientWidth,height:i?r.clientWidth:r.clientHeight,onclone:function(e){var t=e.querySelector(".canvasContainer");t.style.overflow="visible",t.querySelector(".orgchart:not(.hidden)").transform=""}}).then(function(e){var n=t.querySelector(".oc-download-btn");t.querySelector(".mask").classList.add("hidden"),n.setAttribute("href",e.toDataURL()),n.click()}).catch(function(e){console.error("Failed to export the curent orgchart!",e)}).finally(function(){t.classList.remove("canvasContainer")})}},{key:"_loopChart",value:function(e){var t=this,n={id:e.querySelector(".node").id};return e.children[3]&&Array.from(e.children[3].children).forEach(function(e){n.children||(n.children=[]),n.children.push(t._loopChart(e.firstChild))}),n}},{key:"_loopChartDataset",value:function(e){var t=this,n=JSON.parse(e.querySelector(".node").dataset.source);return e.children[3]&&Array.from(e.children[3].children).forEach(function(e){n.children||(n.children=[]),n.children.push(t._loopChartDataset(e.firstChild))}),n}},{key:"getChartJSON",value:function(){return this.chart.querySelector(".node").id?this._loopChartDataset(this.chart.querySelector("table")):"Error: Nodes of orghcart to be exported must have id attribute!"}},{key:"getHierarchy",value:function(){return this.chart.querySelector(".node").id?this._loopChart(this.chart.querySelector("table")):"Error: Nodes of orghcart to be exported must have id attribute!"}},{key:"_onPanStart",value:function(e){var t=e.currentTarget;if(this._closest(e.target,function(e){return e.classList&&e.classList.contains("node")})||e.touches&&e.touches.length>1)t.dataset.panning=!1;else{t.style.cursor="move",t.dataset.panning=!0;var n=0,r=0,i=window.getComputedStyle(t).transform;if("none"!==i){var o=i.split(",");i.includes("3d")?(n=Number.parseInt(o[12],10),r=Number.parseInt(o[13],10)):(n=Number.parseInt(o[4],10),r=Number.parseInt(o[5],10))}var s=0,a=0;if(e.targetTouches){if(1===e.targetTouches.length)s=e.targetTouches[0].pageX-n,a=e.targetTouches[0].pageY-r;else if(e.targetTouches.length>1)return}else s=e.pageX-n,a=e.pageY-r;t.dataset.panStart=JSON.stringify({startX:s,startY:a}),t.addEventListener("mousemove",this._onPanning.bind(this)),t.addEventListener("touchmove",this._onPanning.bind(this))}}},{key:"_onPanning",value:function(e){var t=e.currentTarget;if("false"!==t.dataset.panning){var n=0,r=0,i=JSON.parse(t.dataset.panStart),o=i.startX,s=i.startY;if(e.targetTouches){if(1===e.targetTouches.length)n=e.targetTouches[0].pageX-o,r=e.targetTouches[0].pageY-s;else if(e.targetTouches.length>1)return}else n=e.pageX-o,r=e.pageY-s;var a=window.getComputedStyle(t).transform;if("none"===a)a.includes("3d")?t.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, "+n+", "+r+", 0, 1)":t.style.transform="matrix(1, 0, 0, 1, "+n+", "+r+")";else{var l=a.split(",");a.includes("3d")?(l[12]=n,l[13]=r):(l[4]=n,l[5]=r+")"),t.style.transform=l.join(",")}}}},{key:"_onPanEnd",value:function(e){var t=this.chart;"true"===t.dataset.panning&&(t.dataset.panning=!1,t.style.cursor="default",document.body.removeEventListener("mousemove",this._onPanning),document.body.removeEventListener("touchmove",this._onPanning))}},{key:"_setChartScale",value:function(e,t){var n=window.getComputedStyle(e).transform;if("none"===n)e.style.transform="scale("+t+","+t+")";else{var r=n.split(",");n.includes("3d")?e.style.transform=n+" scale3d("+t+","+t+", 1)":(r[0]="matrix("+t,r[3]=t,e.style.transform=n+" scale("+t+","+t+")")}e.dataset.scale=t}},{key:"_onWheeling",value:function(e){e.preventDefault();var t=e.deltaY>0?.8:1.2;this._setChartScale(this.chart,t)}},{key:"_getPinchDist",value:function(e){return Math.sqrt((e.touches[0].clientX-e.touches[1].clientX)*(e.touches[0].clientX-e.touches[1].clientX)+(e.touches[0].clientY-e.touches[1].clientY)*(e.touches[0].clientY-e.touches[1].clientY))}},{key:"_onTouchStart",value:function(e){var t=this.chart;if(e.touches&&2===e.touches.length){var n=this._getPinchDist(e);t.dataset.pinching=!0,t.dataset.pinchDistStart=n}}},{key:"_onTouchMove",value:function(e){var t=this.chart;if(t.dataset.pinching){var n=this._getPinchDist(e);t.dataset.pinchDistEnd=n}}},{key:"_onTouchEnd",value:function(e){var t=this.chart;if(t.dataset.pinching){t.dataset.pinching=!1;var n=t.dataset.pinchDistEnd-t.dataset.pinchDistStart;n>0?this._setChartScale(t,1):n<0&&this._setChartScale(t,-1)}}},{key:"name",get:function(){return this._name}}]),e}(),z=Array.prototype.splice;r.prototype.clear=function(){this.__data__=[],this.size=0},r.prototype.delete=function(e){var t=this.__data__,r=n(t,e);return!(r<0||(r==t.length-1?t.pop():z.call(t,r,1),--this.size,0))},r.prototype.get=function(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]},r.prototype.has=function(e){return n(this.__data__,e)>-1},r.prototype.set=function(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this};var H="object"==typeof global&&global&&global.Object===Object&&global,R="object"==typeof self&&self&&self.Object===Object&&self,M=H||R||Function("return this")(),I=M.Symbol,F=Object.prototype,U=F.hasOwnProperty,V=F.toString,J=I?I.toStringTag:void 0,X=Object.prototype.toString,Y="[object Null]",$="[object Undefined]",W=I?I.toStringTag:void 0,G="[object AsyncFunction]",Z="[object Function]",K="[object GeneratorFunction]",Q="[object Proxy]",ee=M["__core-js_shared__"],te=function(){var e=/[^.]+$/.exec(ee&&ee.keys&&ee.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ne=Function.prototype.toString,re=/^\[object .+?Constructor\]$/,ie=Function.prototype,oe=Object.prototype,se=ie.toString,ae=oe.hasOwnProperty,le=RegExp("^"+se.call(ae).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ce=l(M,"Map"),de=l(Object,"create"),ue="__lodash_hash_undefined__",he=Object.prototype.hasOwnProperty,fe=Object.prototype.hasOwnProperty,pe="__lodash_hash_undefined__";c.prototype.clear=function(){this.__data__=de?de(null):{},this.size=0},c.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},c.prototype.get=function(e){var t=this.__data__;if(de){var n=t[e];return n===ue?void 0:n}return he.call(t,e)?t[e]:void 0},c.prototype.has=function(e){var t=this.__data__;return de?void 0!==t[e]:fe.call(t,e)},c.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=de&&void 0===t?pe:t,this},u.prototype.clear=function(){this.size=0,this.__data__={hash:new c,map:new(ce||r),string:new c}},u.prototype.delete=function(e){var t=d(this,e).delete(e);return this.size-=t?1:0,t},u.prototype.get=function(e){return d(this,e).get(e)},u.prototype.has=function(e){return d(this,e).has(e)},u.prototype.set=function(e,t){var n=d(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};var ve=200;h.prototype.clear=function(){this.__data__=new r,this.size=0},h.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},h.prototype.get=function(e){return this.__data__.get(e)},h.prototype.has=function(e){return this.__data__.has(e)},h.prototype.set=function(e,t){var n=this.__data__;if(n instanceof r){var i=n.__data__;if(!ce||i.length0){if(++t>=it)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(rt),lt=function(e){return q(function(n,r){var i=-1,s=r.length,a=s>1?r[s-1]:void 0,l=s>2?r[2]:void 0;for(a=e.length>3&&"function"==typeof a?(s--,a):void 0,l&&function(e,n,r){if(!o(r))return!1;var i=typeof n;return!!("number"==i?_(r)&&S(n,r.length):"string"==i&&n in r)&&t(r[n],e)}(r[0],r[1],l)&&(a=s<3?void 0:a,s=1),n=Object(n);++i
-




+





+
@@ -41,7 +45,7 @@