this.primereact=this.primereact||{},this.primereact.tree=function(e,t,n,o){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){l=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw i}}}}function k(e,t){if(e){if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&r!==this.props.node.children.length?o[this.props.node.key]={checked:!1,partialChecked:!0}:delete o[this.props.node.key]),this.props.propagateSelectionUp&&this.props.onPropagateUp&&this.props.onPropagateUp(e)}},{key:"propagateDown",value:function(e,t,n){if(t?n[e.key]={checked:!0,partialChecked:!1}:delete n[e.key],e.children&&e.children.length)for(var o=0;ot.left+t.width||e.nativeEvent.x=Math.floor(t.top+t.height)||e.nativeEvent.y=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){l=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw i}}}}function T(e,t){if(e){if("string"==typeof e)return M(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(e,t):void 0}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);ne.index?e.index:e.index-1:e.index;i?i.children.splice(a,0,s):t.splice(a,0,s)}else i?i.children.push(s):t.push(s);this.props.onDragDrop&&this.props.onDragDrop({originalEvent:e.originalEvent,value:t,dragNode:s,dropNode:i,dropIndex:e.index})}}},{key:"validateDrop",value:function(e,t){return!!e&&(e!==t&&0!==t.indexOf(e))}},{key:"validateDropNode",value:function(e,t){return!!this.validateDrop(e,t)&&!(e.indexOf("-")>0&&e.substring(0,e.lastIndexOf("-"))===t)}},{key:"validateDropPoint",value:function(e){return!!this.validateDrop(this.dragState.path,e.path)&&(-1!==e.position||!this.areSiblings(this.dragState.path,e.path)||this.dragState.index+1!==e.index)}},{key:"areSiblings",value:function(e,t){return 1===e.length&&1===t.length||e.substring(0,e.lastIndexOf("-"))===t.substring(0,t.lastIndexOf("-"))}},{key:"findNode",value:function(e,t){if(0===t.length)return null;var n=parseInt(t[0],10),o=e.children?e.children[n]:e[n];return 1===t.length?o:(t.shift(),this.findNode(o,t))}},{key:"isNodeLeaf",value:function(e){return!1!==e.leaf&&!(e.children&&e.children.length)}},{key:"onFilterInputKeyDown",value:function(e){13===e.which&&e.preventDefault()}},{key:"onFilterInputChange",value:function(e){this.filterChanged=!0;var t=e.target.value;this.props.onFilterValueChange?this.props.onFilterValueChange({originalEvent:e,value:t}):this.setState({filterValue:t})}},{key:"filter",value:function(e){this.setState({filterValue:n.ObjectUtils.isNotEmpty(e)?e:""},this._filter)}},{key:"_filter",value:function(){if(this.filterChanged){var e=this.getFilterValue();if(n.ObjectUtils.isEmpty(e))this.filteredNodes=this.props.value;else{this.filteredNodes=[];var t,o=this.props.filterBy.split(","),r=e.toLocaleLowerCase(this.props.filterLocale),i="strict"===this.props.filterMode,s=K(this.props.value);try{for(s.s();!(t=s.n()).done;){var l=P({},t.value),a={searchFields:o,filterText:r,isStrictMode:i};(i&&(this.findFilteredNodes(l,a)||this.isFilterMatched(l,a))||!i&&(this.isFilterMatched(l,a)||this.findFilteredNodes(l,a)))&&this.filteredNodes.push(l)}}catch(e){s.e(e)}finally{s.f()}}this.filterChanged=!1}}},{key:"findFilteredNodes",value:function(e,t){if(e){var n=!1;if(e.children){var o=l(c=e.children)||a(c)||p(c)||d();e.children=[];var r,i=K(o);try{for(i.s();!(r=i.n()).done;){var s=P({},r.value);this.isFilterMatched(s,t)&&(n=!0,e.children.push(s))}}catch(e){i.e(e)}finally{i.f()}}if(n)return e.expanded=!0,!0}var c}},{key:"isFilterMatched",value:function(e,t){var o,r=t.searchFields,i=t.filterText,s=t.isStrictMode,l=!1,a=K(r);try{for(a.s();!(o=a.n()).done;){String(n.ObjectUtils.resolveFieldData(e,o.value)).toLocaleLowerCase(this.props.filterLocale).indexOf(i)>-1&&(l=!0)}}catch(e){a.e(e)}finally{a.f()}return(!l||s&&!this.isNodeLeaf(e))&&(l=this.findFilteredNodes(e,{searchFields:r,filterText:i,isStrictMode:s})||l),l}},{key:"renderRootChild",value:function(e,t,n){return i.default.createElement(O,{key:e.key||e.label,node:e,index:t,last:n,path:String(t),disabled:this.props.disabled,selectionMode:this.props.selectionMode,selectionKeys:this.props.selectionKeys,onSelectionChange:this.props.onSelectionChange,metaKeySelection:this.props.metaKeySelection,contextMenuSelectionKey:this.props.contextMenuSelectionKey,onContextMenuSelectionChange:this.props.onContextMenuSelectionChange,onContextMenu:this.props.onContextMenu,propagateSelectionDown:this.props.propagateSelectionDown,propagateSelectionUp:this.props.propagateSelectionUp,onExpand:this.props.onExpand,onCollapse:this.props.onCollapse,onSelect:this.props.onSelect,onUnselect:this.props.onUnselect,expandedKeys:this.getExpandedKeys(),onToggle:this.onToggle,nodeTemplate:this.props.nodeTemplate,togglerTemplate:this.props.togglerTemplate,isNodeLeaf:this.isNodeLeaf,dragdropScope:this.props.dragdropScope,onDragStart:this.onDragStart,onDragEnd:this.onDragEnd,onDrop:this.onDrop,onDropPoint:this.onDropPoint,onNodeClick:this.props.onNodeClick,onNodeDoubleClick:this.props.onNodeDoubleClick})}},{key:"renderRootChildren",value:function(){var e=this;this.props.filter&&(this.filterChanged=!0,this._filter());var t=this.getRootNode();return t.map((function(n,o){return e.renderRootChild(n,o,o===t.length-1)}))}},{key:"renderModel",value:function(){if(this.props.value){var e=this.renderRootChildren(),t=n.classNames("p-tree-container",this.props.contentClassName);return i.default.createElement("ul",{className:t,role:"tree","aria-label":this.props.ariaLabel,"aria-labelledby":this.props.ariaLabelledBy,style:this.props.contentStyle},e)}return null}},{key:"renderLoader",value:function(){if(this.props.loading){var e=n.classNames("p-tree-loading-icon pi-spin",this.props.loadingIcon);return i.default.createElement("div",{className:"p-tree-loading-overlay p-component-overlay"},i.default.createElement("i",{className:e}))}return null}},{key:"renderFilter",value:function(){if(this.props.filter){var e=this.getFilterValue();return e=n.ObjectUtils.isNotEmpty(e)?e:"",i.default.createElement("div",{className:"p-tree-filter-container"},i.default.createElement("input",{type:"text",value:e,autoComplete:"off",className:"p-tree-filter p-inputtext p-component",placeholder:this.props.filterPlaceholder,onKeyDown:this.onFilterInputKeyDown,onChange:this.onFilterInputChange,disabled:this.props.disabled}),i.default.createElement("span",{className:"p-tree-filter-icon pi pi-search"}))}return null}},{key:"renderHeader",value:function(){if(this.props.showHeader){var e=this.renderFilter(),t=e;if(this.props.header)t=n.ObjectUtils.getJSXElement(this.props.header,{filterContainerClassName:"p-tree-filter-container",filterIconClasssName:"p-tree-filter-icon pi pi-search",filterInput:{className:"p-tree-filter p-inputtext p-component",onKeyDown:this.onFilterInputKeyDown,onChange:this.onFilterInputChange},filterElement:e,element:t,props:this.props});return i.default.createElement("div",{className:"p-tree-header"},t)}return null}},{key:"renderFooter",value:function(){var e=n.ObjectUtils.getJSXElement(this.props.footer,this.props);return i.default.createElement("div",{className:"p-tree-footer"},e)}},{key:"render",value:function(){var e=n.classNames("p-tree p-component",this.props.className,{"p-tree-selectable":this.props.selectionMode,"p-tree-loading":this.props.loading,"p-disabled":this.props.disabled}),t=this.renderLoader(),o=this.renderModel(),r=this.renderHeader(),s=this.renderFooter();return i.default.createElement("div",{id:this.props.id,className:e,style:this.props.style},t,r,o,s)}}]),s}(t.Component);return D(L,"defaultProps",{id:null,value:null,disabled:!1,selectionMode:null,selectionKeys:null,onSelectionChange:null,contextMenuSelectionKey:null,onContextMenuSelectionChange:null,expandedKeys:null,style:null,className:null,contentStyle:null,contentClassName:null,metaKeySelection:!0,propagateSelectionUp:!0,propagateSelectionDown:!0,loading:!1,loadingIcon:"pi pi-spinner",dragdropScope:null,header:null,footer:null,showHeader:!0,filter:!1,filterValue:null,filterBy:"label",filterMode:"lenient",filterPlaceholder:null,filterLocale:void 0,nodeTemplate:null,togglerTemplate:null,onSelect:null,onUnselect:null,onExpand:null,onCollapse:null,onToggle:null,onDragDrop:null,onContextMenu:null,onFilterValueChange:null,onNodeClick:null,onNodeDoubleClick:null}),e.Tree=L,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.ripple);