import e,{Component as t}from"react";import{classNames as n}from"primereact/utils";function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n1&&this.node.children.map((function(t,o){var r=n("p-organizationchart-line-left",{"p-organizationchart-line-top":0!==o}),i=n("p-organizationchart-line-right",{"p-organizationchart-line-top":o!==d-1});return[e.createElement("td",{key:o+"_lineleft",className:r}," "),e.createElement("td",{key:o+"_lineright",className:i}," ")]}))),h=e.createElement("tr",{style:{visibility:c},className:"p-organizationchart-nodes"},this.node.children&&this.node.children.map((function(n,o){return e.createElement("td",{key:o,colSpan:"2"},e.createElement(i,{node:n,nodeTemplate:t.props.nodeTemplate,selectionMode:t.props.selectionMode,onNodeClick:t.props.onNodeClick,isSelected:t.props.isSelected}))})));return e.createElement("table",{className:"p-organizationchart-table"},e.createElement("tbody",null,a,p,u,h))}}]),i}();g(N,"defaultProps",{node:null,nodeTemplate:null,root:!1,first:!1,last:!1,selectionMode:null,onNodeClick:null,isSelected:null});var S=function(o){h(u,t);var p=v(u);function u(e){var t;return c(this,u),(t=p.call(this,e)).root=t.props.value&&t.props.value.length?t.props.value[0]:null,t.onNodeClick=t.onNodeClick.bind(a(t)),t.isSelected=t.isSelected.bind(a(t)),t}return d(u,[{key:"onNodeClick",value:function(e,t){if(this.props.selectionMode){var n=e.target;if(n.className&&(-1!==n.className.indexOf("p-node-toggler")||-1!==n.className.indexOf("p-node-toggler-icon")))return;if(!1===t.selectable)return;var o,a=this.findIndexInSelection(t),c=a>=0;"single"===this.props.selectionMode?c?(o=null,this.props.onNodeUnselect&&this.props.onNodeUnselect({originalEvent:e,node:t})):(o=t,this.props.onNodeSelect&&this.props.onNodeSelect({originalEvent:e,node:t})):"multiple"===this.props.selectionMode&&(c?(o=this.props.selection.filter((function(e,t){return t!==a})),this.props.onNodeUnselect&&this.props.onNodeUnselect({originalEvent:e,node:t})):(o=[].concat(r(p=this.props.selection||[])||i(p)||l(p)||s(),[t]),this.props.onNodeSelect&&this.props.onNodeSelect({originalEvent:e,node:t}))),this.props.onSelectionChange&&this.props.onSelectionChange({originalEvent:e,data:o})}var p}},{key:"findIndexInSelection",value:function(e){var t=-1;if(this.props.selectionMode&&this.props.selection)if("single"===this.props.selectionMode)t=this.props.selection===e?0:-1;else if("multiple"===this.props.selectionMode)for(var n=0;n