/*
    *
    * Wijmo Library 5.20181.436
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
var __extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();define(["require","exports","wijmo/wijmo","wijmo/wijmo.nav"],function(e,t,n,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=i||t;window.wijmo=window.wijmo||{},window.wijmo.nav=s;var r=function(e){function t(i,s){var r=e.call(this,i)||this;r._itmPath=new u("items"),r._dspPath=new u("header"),r._imgPath=new u,r._html=!1,r._animated=!0,r._xpndOnClick=!0,r._autoColl=!0,r._showChk=!1,r._srch="",r._isReadOnly=!0,r.itemsSourceChanged=new n.Event,r.loadingItems=new n.Event,r.loadedItems=new n.Event,r.itemClicked=new n.Event,r.selectedItemChanged=new n.Event,r.checkedItemsChanged=new n.Event,r.isCollapsedChanging=new n.Event,r.isCollapsedChanged=new n.Event,r.isCheckedChanging=new n.Event,r.isCheckedChanged=new n.Event,r.formatItem=new n.Event,r.dragStart=new n.Event,r.dragOver=new n.Event,r.drop=new n.Event,r.dragEnd=new n.Event,r.nodeEditStarting=new n.Event,r.nodeEditStarted=new n.Event,r.nodeEditEnding=new n.Event,r.nodeEditEnded=new n.Event;var o=r.getTemplate();r.applyTemplate("wj-control wj-content wj-treeview",o,{_root:"root"});var a=r.hostElement;return n.setAttribute(a,"role","tree",!0),n.addClass(r._root,t._CNDL),n.setAttribute(r._root,"role","group",!0),r.addEventListener(a,"mousedown",r._mousedown.bind(r)),r.addEventListener(a,"click",r._click.bind(r)),r.addEventListener(a,"keydown",r._keydown.bind(r)),r.addEventListener(a,"keypress",r._keypress.bind(r)),r.addEventListener(a,"wheel",function(e){a.scrollHeight>a.offsetHeight&&(e.deltaY<0&&0==a.scrollTop||e.deltaY>0&&a.scrollTop+a.offsetHeight>=a.scrollHeight)&&(e.preventDefault(),e.stopPropagation())}),r.addEventListener(a,"blur",function(e){r._edtNode&&!n.contains(r._edtNode.element,n.getActiveElement())&&r.finishEditing()},!0),r.initialize(s),r.refresh(),r}return __extends(t,e),Object.defineProperty(t.prototype,"itemsSource",{get:function(){return this._items},set:function(e){this._items!=e&&(this._items=n.asArray(e),this.onItemsSourceChanged(),this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"childItemsPath",{get:function(){return this._itmPath.path},set:function(e){e!=this.childItemsPath&&(this._itmPath.path=e,this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"displayMemberPath",{get:function(){return this._dspPath.path},set:function(e){e!=this.displayMemberPath&&(this._dspPath.path=e,this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageMemberPath",{get:function(){return this._imgPath.path},set:function(e){e!=this.imageMemberPath&&(this._imgPath.path=e,this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isContentHtml",{get:function(){return this._html},set:function(e){e!=this._html&&(this._html=n.asBoolean(e),this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showCheckboxes",{get:function(){return this._showChk},set:function(e){e!=this._showChk&&(this._showChk=n.asBoolean(e),this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoCollapse",{get:function(){return this._autoColl},set:function(e){this._autoColl=n.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAnimated",{get:function(){return this._animated},set:function(e){e!=this._animated&&(this._animated=n.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isReadOnly",{get:function(){return this._isReadOnly},set:function(e){this._isReadOnly=n.asBoolean(e),n.toggleClass(this.hostElement,"wj-state-readonly",this.isReadOnly)},enumerable:!0,configurable:!0}),t.prototype.startEditing=function(e){if(this.isReadOnly)return!1;if(e||(e=this.selectedNode),!e||e.isDisabled)return!1;if(!this.finishEditing())return!1;var i=e.element.querySelector("."+t._CNDT);if(!i)return!1;var s=new l(e);if(!this.onNodeEditStarting(s))return!1;i.tabIndex=0,i.focus(),i.contentEditable="true",i.style.cursor="auto";var r=document.createRange();r.selectNodeContents(i);var o=getSelection();return o.removeAllRanges(),o.addRange(r),i.focus(),n.setAttribute(i,"autocomplete","off"),n.setAttribute(i,"autocorrect","off"),this._edtNode=e,this.onNodeEditStarted(s),!0},t.prototype.finishEditing=function(e){var n=this._edtNode;if(n){var i=n.element.querySelector("."+t._CNDT);if(!i)return!1;var s=new l(n);if(!this.onNodeEditEnding(s))return!1;var r=n.dataItem,o=n.level;this.isContentHtml?e?i.innerHTML=this._dspPath.getValue(r,o):this._dspPath.setValue(r,o,i.innerHTML):e?i.textContent=this._dspPath.getValue(r,o):this._dspPath.setValue(r,o,i.textContent),document.createRange().selectNodeContents(i),getSelection().removeAllRanges(),i.contentEditable="false",i.style.cursor="",this._edtNode=null,this.onNodeEditEnded(s)}return!0},Object.defineProperty(t.prototype,"allowDragging",{get:function(){return null!=this._dd},set:function(e){if(e!=this.allowDragging){n.asBoolean(e)?this._dd=new c(this):(this._dd.dispose(),this._dd=null);for(var i=this.hostElement.querySelectorAll("."+t._CND),s=0;s<i.length;s++){var r=i[s];n.setAttribute(r,"draggable",!!this._dd||null)}}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"expandOnClick",{get:function(){return this._xpndOnClick},set:function(e){this._xpndOnClick=n.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedItem",{get:function(){return this._selNode?this._selNode.dataItem:null},set:function(e){e!=this.selectedItem&&(this.selectedNode=e?this.getNode(e):null)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedNode",{get:function(){return this._selNode},set:function(e){e!=this.selectedNode&&(this._prevSel=this._selNode,e?e.select():this._selNode&&(n.removeClass(this._selNode.element,t._CSEL),this._selNode=null,this.onSelectedItemChanged()))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedPath",{get:function(){for(var e=[],t=this.selectedNode;t;t=t.parentNode){var n=this._dspPath.getValue(t.dataItem,t.level);e.splice(0,0,n)}return e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"checkedItems",{get:function(){if(null==this._chkItems){var e=t,n="."+e._CND+"."+e._CEMP+" > input:checked."+e._CNDC,i=this._root.querySelectorAll(n);this._chkItems=[];for(var s=0;s<i.length;s++){var r=i[s].parentElement[e._DATAITEM_KEY];this._chkItems.push(r)}}return this._chkItems},set:function(e){if(this.showCheckboxes)for(var n=t,i="."+n._CND+"."+n._CEMP,s=this._root.querySelectorAll(i),r=0;r<s.length;r++){var a=new o(this,s[r]),l=e.indexOf(a.dataItem)>-1;a.isChecked!=l&&(a.isChecked=l)}},enumerable:!0,configurable:!0}),t.prototype.checkAllItems=function(e){if(this.showCheckboxes)for(var n=t,i="."+n._CND+"."+n._CEMP,s=this._root.querySelectorAll(i),r=0;r<s.length;r++){var a=new o(this,s[r]);a.isChecked!=e&&(a.isChecked=e)}},Object.defineProperty(t.prototype,"totalItemCount",{get:function(){return this.hostElement.querySelectorAll("."+t._CND).length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lazyLoadFunction",{get:function(){return this._lazyLoad},set:function(e){e!=this._lazyLoad&&(this._lazyLoad=n.asFunction(e),this._reload())},enumerable:!0,configurable:!0}),t.prototype.getFirstNode=function(e,n){var i=this.hostElement.querySelector("."+t._CND),s=i?new o(this,i):null;return e&&s&&!s.element.offsetHeight&&(s=s.next(e,n)),n&&s&&s.isDisabled&&(s=s.next(e,n)),s},t.prototype.getLastNode=function(e,n){var i=this.hostElement.querySelectorAll("."+t._CND+":last-child"),s=i.length?new o(this,i[i.length-1]):null;return e&&s&&!s.element.offsetHeight&&(s=s.previous(e,n)),n&&s&&s.isDisabled&&(s=s.previous(e,n)),s},Object.defineProperty(t.prototype,"nodes",{get:function(){return o._getChildNodes(this,this._root)},enumerable:!0,configurable:!0}),t.prototype.getNode=function(e){this._isDirty&&this._loadTree();for(var n=this.hostElement.querySelectorAll("."+t._CND),i=0;i<n.length;i++){var s=n[i];if(s[t._DATAITEM_KEY]==e)return new o(this,s)}return null},t.prototype.addChildNode=function(e,t){var n=this._createNode(t),i=this.nodes;return i?e<i.length?n.move(i[e],h.Before):n.move(i[i.length-1],h.After):n.move(this,h.Into),n},t.prototype.collapseToLevel=function(e){var t=this._animated,n=this._autoColl;this._animated=this._autoColl=!1,this._collapseToLevel(this.nodes,e,0),this._animated=t,this._autoColl=n},t.prototype.loadTree=function(e){this._loadTree(e)},t.prototype.onItemsSourceChanged=function(e){this.itemsSourceChanged.raise(this,e)},t.prototype.onLoadingItems=function(e){return this.loadingItems.raise(this,e),!e.cancel},t.prototype.onLoadedItems=function(e){this.loadedItems.raise(this,e)},t.prototype.onItemClicked=function(e){this.itemClicked.raise(this,e)},t.prototype.onSelectedItemChanged=function(e){this.selectedItemChanged.raise(this,e)},t.prototype.onCheckedItemsChanged=function(e){this._chkItems=null,this.checkedItemsChanged.raise(this,e)},t.prototype.onIsCollapsedChanging=function(e){return this.isCollapsedChanging.raise(this,e),!e.cancel},t.prototype.onIsCollapsedChanged=function(e){this.isCollapsedChanged.raise(this,e)},t.prototype.onIsCheckedChanging=function(e){return this.isCheckedChanging.raise(this,e),!e.cancel},t.prototype.onIsCheckedChanged=function(e){this.isCheckedChanged.raise(this,e)},t.prototype.onFormatItem=function(e){this.formatItem.raise(this,e)},t.prototype.onDragStart=function(e){return this.dragStart.raise(this,e),!e.cancel},t.prototype.onDragOver=function(e){return this.dragOver.raise(this,e),!e.cancel},t.prototype.onDrop=function(e){return this.drop.raise(this,e),!e.cancel},t.prototype.onDragEnd=function(e){this.dragEnd.raise(this,e)},t.prototype.onNodeEditStarting=function(e){return this.nodeEditStarting.raise(this,e),!e.cancel},t.prototype.onNodeEditStarted=function(e){this.nodeEditStarted.raise(this,e)},t.prototype.onNodeEditEnding=function(e){return this.nodeEditEnding.raise(this,e),!e.cancel},t.prototype.onNodeEditEnded=function(e){this.nodeEditEnded.raise(this,e)},t.prototype.refresh=function(t){void 0===t&&(t=!0),e.prototype.refresh.call(this,t),!this.isUpdating&&this._isDirty&&this._loadTree()},t.prototype._raiseCheckedItemsChanged=function(){var e=this;this._toItemsChanged&&clearTimeout(this._toItemsChanged),this._toItemsChanged=setTimeout(function(){e._toItemsChanged=null,e.onCheckedItemsChanged()},10)},t.prototype._reload=function(){this._isDirty=!0,this.invalidate()},t.prototype._createNode=function(e){return new t(document.createElement("div"),{childItemsPath:this.childItemsPath,displayMemberPath:this.displayMemberPath,imageMemberPath:this.imageMemberPath,isContentHtml:this.isContentHtml,showCheckboxes:this.showCheckboxes,itemsSource:[e]}).getFirstNode()},t.prototype._mousedown=function(e){if(!e.defaultPrevented){var i=n.closest(e.target,"input."+t._CNDC),s=n.closestClass(e.target,t._CND),r=s?new o(this,s):null;r&&!r.isDisabled&&(this.selectedNode=r),this._dnIndet=i&&i.indeterminate}},t.prototype._click=function(e){if(!e.defaultPrevented){var i=n.closestClass(e.target,t._CND);if(i){var s=new o(this,i),r=n.closest(e.target,"input."+t._CNDC);if(s.isDisabled)return;if(!r&&s.equals(this._edtNode))return;if(i.focus(),r&&(e.preventDefault(),e.stopPropagation(),setTimeout(function(){r.indeterminate=!1,s.isChecked=!s.isChecked})),!r){var a=e.target,l=(e.ctrlKey||e.metaKey)&&!s.hasPendingChildren,d=i.getBoundingClientRect(),h=!1;(this.rightToLeft?d.right-e.clientX:e.clientX-d.left)<=a.offsetHeight?(l?this.collapseToLevel(s.isCollapsed?s.level+1:s.level):s.isCollapsed=!s.isCollapsed,h=!0):this.expandOnClick&&s.isCollapsed&&(l?this.collapseToLevel(s.level):s.isCollapsed=!1,h=!0),h&&l&&this.selectedNode&&this.selectedNode.ensureVisible(),h||this.isReadOnly||this.selectedNode&&this.selectedNode.equals(this._prevSel)&&this.startEditing()}this.selectedItem&&this.onItemClicked()}}},t.prototype._keydown=function(e){if(!e.defaultPrevented){var t=this._selNode,i=void 0,s=e.keyCode,r=!0;if(t&&!t.isDisabled){switch(s){case n.Key.F2:this.startEditing(),e.preventDefault();break;case n.Key.Escape:this.finishEditing(!0),e.preventDefault();break;case n.Key.Up:case n.Key.Down:this.finishEditing();break;case n.Key.Enter:this._edtNode?(this.finishEditing(),s=n.Key.Down):(this.startEditing(),e.preventDefault())}if(this._edtNode)return;if(this.rightToLeft)switch(s){case n.Key.Left:s=n.Key.Right;break;case n.Key.Right:s=n.Key.Left}switch(s){case n.Key.Left:!t.isCollapsed&&t.hasChildren?t.setCollapsed(!0):(t=t.parentNode)&&t.select();break;case n.Key.Right:t.setCollapsed(!1);break;case n.Key.Up:i=t.previous(!0,!0);break;case n.Key.Down:i=t.next(!0,!0);break;case n.Key.Home:i=this.getFirstNode(!0,!0);break;case n.Key.End:i=this.getLastNode(!0,!0);break;case n.Key.Space:if(this.selectedItem){var o=t.checkBox;o&&(t.isChecked=!o.checked)}break;case n.Key.Enter:this.selectedItem&&this.onItemClicked();break;default:r=!1}r&&(e.preventDefault(),i&&i.select())}}},t.prototype._keypress=function(e){var i=this;if(!e.defaultPrevented){if(e.ctrlKey||e.metaKey||e.altKey)return;if(e.target instanceof HTMLInputElement)return;if(this._edtNode)return;if(e.charCode>32&&this.startEditing(this.selectedNode)){var s=n.getActiveElement();if(n.contains(this._edtNode.element,s)){s.textContent=String.fromCharCode(e.charCode),e.preventDefault();var r=document.createRange();r.selectNodeContents(s),r.collapse(!1);var o=getSelection();o.removeAllRanges(),o.addRange(r)}return}if(e.charCode>32||32==e.charCode&&this._srch){e.preventDefault(),this._srch+=String.fromCharCode(e.charCode).toLowerCase(),this._toSrch&&clearTimeout(this._toSrch),this._toSrch=setTimeout(function(){i._toSrch=null,i._srch=""},t._AS_DLY);var a=this._findNext();null==a&&this._srch.length>1&&(this._srch=this._srch[this._srch.length-1],a=this._findNext()),null!=a&&(this.selectedItem=a)}}},t.prototype._findNext=function(){if(this.hostElement&&this.selectedItem){var e=this.getNode(this.selectedItem),t=e,n=!1,i=!1;for(1==this._srch.length&&(i=!0);t;){if(!t.isDisabled&&!i&&0==t.element.textContent.trim().toLowerCase().indexOf(this._srch))return t.dataItem;var s=t.next(!0,!0);if(s==e&&n)break;s||n||(s=this.getFirstNode(!0,!0),n=!0),t=s,i=!1}}return null},t.prototype._loadTree=function(e){var i=this._root;if(i){if(!this.onLoadingItems(new n.CancelEventArgs))return;this._isDirty=!1;var s=this.containsFocus(),r=this.selectedItem;this.selectedItem=null,this._chkItems=null,this._ldLvl=-1;var a=void 0;if(e&&n.isFunction(window.Map)){a=new Map;for(var l=this.hostElement.querySelectorAll("."+t._CND),d=0;d<l.length;d++){h=l[d];n.hasClass(h,t._CCLD)&&a.set(h[t._DATAITEM_KEY],!0)}}if(i.innerHTML="",this._items)for(d=0;d<this._items.length;d++)this._addItem(i,0,this._items[d]);if(a)for(var l=this.hostElement.querySelectorAll("."+t._CND),d=0;d<l.length;d++){var h=l[d],c=o._isNodeList(h),u=a.get(h[t._DATAITEM_KEY]);n.toggleClass(h,t._CCLD,1==u),n.setAttribute(h,"aria-expanded",c?(!u).toString():null)}s&&!this.containsFocus()&&this.focus(),this.selectedItem=r,this.onLoadedItems(),this._ldLvl=-1}},t.prototype._addItem=function(e,i,s){var r=this._dspPath.getValue(s,i),o=this._imgPath.getValue(s,i),l=n.asArray(this._itmPath.getValue(s,i),!0),d=document.createElement("div");n.addClass(d,t._CND),d.tabIndex=0,n.setAttribute(d,"role","treeitem",!0);var h=document.createElement("span");if(this.isContentHtml?h.innerHTML=r:h.textContent=r,n.addClass(h,t._CNDT),d.appendChild(h),o){var c=document.createElement("img");c.src=o,d.insertBefore(c,d.firstChild)}if(this._showChk&&!this._lazyLoad){var u=document.createElement("input");u.type="checkbox",u.tabIndex=-1,n.addClass(u,t._CNDC),d.insertBefore(u,d.firstChild)}if(this._dd&&d.setAttribute("draggable","true"),e.appendChild(d),d[t._DATAITEM_KEY]=s,l&&0==l.length&&!this.lazyLoadFunction&&(l=null),l){var p=!0;if(i>this._ldLvl?(this._ldLvl=i,0==l.length&&(n.addClass(d,t._CCLD),p=!1)):(n.addClass(d,t._CCLD),p=!1,i<this._ldLvl&&(this._ldLvl=1e4)),l.length>0){var _=document.createElement("div");n.addClass(_,t._CNDL);for(var f=0;f<l.length;f++)this._addItem(_,i+1,l[f]);e.appendChild(_),n.setAttribute(d,"aria-expanded",p.toString(),!0),n.setAttribute(_,"role","group",!0)}}else n.addClass(d,t._CEMP);this.formatItem.hasHandlers&&this.onFormatItem(new a(s,d,i))},t.prototype._collapseToLevel=function(e,t,n){for(var i=0;i<e.length;i++){var s=e[i];s.hasPendingChildren||(s.isCollapsed=n>=t,s.hasChildren&&this._collapseToLevel(s.nodes,t,n+1))}},t.prototype._lazyLoadNode=function(e){var i=this.hostElement;n.hasClass(i,t._CLDG)||(n.addClass(i,t._CLDG),n.addClass(e.element,t._CLDG),this.lazyLoadFunction(e,this._lazyLoadCallback.bind(e)))},t.prototype._lazyLoadCallback=function(e){var t=this;t.treeView._lazyLoadNodeDone(t,e)},t.prototype._lazyLoadNodeDone=function(e,i){var s=t;n.removeClass(e.element,s._CLDG),n.removeClass(this.hostElement,s._CLDG);var r=e.dataItem,o=e.level,a=n.asArray(i,!0);if(null==a||0==a.length)this._itmPath.setValue(r,o,null),n.addClass(e.element,s._CEMP);else if(a.length){this._itmPath.setValue(r,o,a);var l=document.createElement("div"),d=e.element;n.addClass(l,s._CNDL),d.parentElement.insertBefore(l,d.nextSibling);for(var h=0;h<a.length;h++)this._addItem(l,o+1,a[h]);e.isCollapsed=!1}},t._DATAITEM_KEY="wj-Data-Item",t._AS_DLY=600,t._AN_DLY=200,t._CND="wj-node",t._CNDL="wj-nodelist",t._CEMP="wj-state-empty",t._CNDT="wj-node-text",t._CNDC="wj-node-check",t._CSEL="wj-state-selected",t._CCLD="wj-state-collapsed",t._CCLG="wj-state-collapsing",t._CLDG="wj-state-loading",t.controlTemplate='<div wj-part="root"></div>',t}(n.Control);t.TreeView=r;var o=function(){function e(t,i){n.hasClass(i,"wj-treeview")?(t=n.Control.getControl(i),i=null):e._assertNode(i),this._t=t,this._e=i}return Object.defineProperty(e.prototype,"dataItem",{get:function(){return this._e[r._DATAITEM_KEY]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return this._e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"treeView",{get:function(){return this._t},enumerable:!0,configurable:!0}),e.prototype.ensureVisible=function(){for(var e=this.parentNode;e;e=e.parentNode)e.isCollapsed=!1;var t=this._t.hostElement,n=this.element.getBoundingClientRect(),i=t.getBoundingClientRect();n.bottom>i.bottom?t.scrollTop+=n.bottom-i.bottom:n.top<i.top&&(t.scrollTop-=i.top-n.top)},e.prototype.equals=function(e){return null!=e&&e.element==this.element},e.prototype.select=function(){var e=this._t,t=e._selNode;this.equals(t)||(t&&n.removeClass(t.element,r._CSEL),e._selNode=this,n.addClass(this.element,r._CSEL),this.ensureVisible(),e.containsFocus()&&this.element.focus(),e.onSelectedItemChanged())},Object.defineProperty(e.prototype,"index",{get:function(){for(var t=0,n=this._pse(this.element);n;n=this._pse(n))e._isNode(n)&&t++;return t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parentNode",{get:function(){var t=null;if(this._e){var n=this._e.parentElement;e._assertNodeList(n),t=this._pse(n)}return t?new e(this._t,t):null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"level",{get:function(){for(var e=-1,t=this;t;t=t.parentNode)e++;return e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasChildren",{get:function(){return e._isNode(this._e)&&!e._isEmpty(this._e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasPendingChildren",{get:function(){return this.isCollapsed&&this.hasChildren&&!e._isNodeList(this.element.nextElementSibling)&&n.isFunction(this._t.lazyLoadFunction)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nodes",{get:function(){return this.hasChildren?e._getChildNodes(this._t,this._e.nextSibling):null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"checkBox",{get:function(){return this._e.querySelector("input."+r._CNDC)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isCollapsed",{get:function(){return this.hasChildren&&n.hasClass(this._e,r._CCLD)},set:function(e){if(e!=this.isCollapsed){var t=this._t,i=new l(this);t.onIsCollapsedChanging(i)&&(this.setCollapsed(n.asBoolean(e),t.isAnimated,t.autoCollapse),t.onIsCollapsedChanged(i))}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isChecked",{get:function(){var e=this.checkBox;return e&&!e.indeterminate?e.checked:null},set:function(e){if(e!=this.isChecked){var t=this._t,i=new l(this);t.onIsCheckedChanging(i)&&(this.setChecked(n.asBoolean(e),!0),t.onIsCheckedChanged(i))}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDisabled",{get:function(){return this._e&&null!=this._e.getAttribute("disabled")},set:function(e){(e=n.asBoolean(e,!0))!=this.isDisabled&&n.enable(this._e,!e)},enumerable:!0,configurable:!0}),e.prototype.previous=function(t,n){var i=this._pse(this._e);if(!i&&e._isNodeList(this._e.parentElement)&&(i=this._pse(this._e.parentElement)),e._isNodeList(i)){for(;e._isNodeList(i)&&i.childElementCount;)i=i.lastChild;e._isNodeList(i)&&(i=this._pse(i))}var s=e._isNode(i)?new e(this._t,i):null;return t&&s&&!s.element.offsetHeight&&(s=s.previous(t,n)),n&&s&&s.isDisabled&&(s=s.previous(t,n)),s},e.prototype.next=function(t,n){var i=this._e.nextSibling;if(e._isNodeList(i)&&(i=i.childElementCount?i.firstChild:i.nextSibling),!i)for(var s=this._e.parentElement;!i&&e._isNodeList(s);s=s.parentElement)i=s.nextSibling;var r=e._isNode(i)?new e(this._t,i):null;return t&&r&&!r.element.offsetHeight&&(r=r.next(t,n)),n&&r&&r.isDisabled&&(r=r.next(t,n)),r},e.prototype.previousSibling=function(){for(var t=this._pse(this.element);e._isNodeList(t);)t=this._pse(t);return t?new e(this._t,t):null},e.prototype.nextSibling=function(){var t=this.element.nextSibling;return e._isNodeList(t)&&(t=t.nextSibling),t?new e(this._t,t):null},e.prototype.setCollapsed=function(t,i,s){var o=this._t,a=this._e,l=this._e.nextElementSibling,d=e._isNodeList(l);if(n.setAttribute(a,"aria-expanded",d?(!t).toString():null),t!=this.isCollapsed)if(t||d||!n.isFunction(o.lazyLoadFunction)){if(null==i&&(i=o.isAnimated),null==s&&(s=o.autoCollapse),i){if(d){var h=l.offsetHeight,c=l.style;t?(n.toggleClass(a,r._CCLG,!0),n.animate(function(e){e<1?(e=1-e,c.height=(e*h).toFixed(0)+"px"):(c.height=c.opacity="",n.toggleClass(a,r._CCLD,!0),n.toggleClass(a,r._CCLG,!1))},r._AN_DLY)):(n.toggleClass(a,r._CCLD,!1),c.height=c.opacity="0",n.animate(function(e){c.height=e>=1?c.opacity="":(e*h).toFixed(0)+"px"},r._AN_DLY))}}else n.toggleClass(a,r._CCLD,t);if(!t&&s){var u=a.parentElement;if(e._isNodeList(u))for(var p=0;p<u.children.length;p++){var _=u.children[p];_!=a&&e._isNode(_)&&(n.toggleClass(_,r._CCLD,!0),_.setAttribute("aria-expanded","false"))}}}else o._lazyLoadNode(this)},e.prototype.setChecked=function(e,t){var n=this.checkBox,i=n.checked!=e;if(n.checked=e,n.indeterminate=!1,this.hasChildren)for(var s=this.nodes,r=0;r<s.length;r++)s[r].setChecked(e,!1);if(t){var o=this.parentNode;o&&o._updateCheckedState()}this._t&&i&&this._t._raiseCheckedItemsChanged()},e.prototype.remove=function(){var t=this._t,i=this.parentNode,s=this._getArray(),r=s.indexOf(this.dataItem);t.selectedNode==this&&(t.selectedNode=this.nextSibling()||this.previousSibling()||i);var o=this.element.nextSibling;e._isNodeList(o)&&n.removeChild(o),n.removeChild(this.element),i&&i._updateState(),s.splice(r,1),this._t=null},e.prototype.addChildNode=function(e,t){var n=this._t._createNode(t),i=this.nodes;return i?e<i.length?n.move(i[e],h.Before):n.move(i[i.length-1],h.After):n.move(this,h.Into),n},e.prototype.refresh=function(e){var t=this._getArray();e&&(t[this.index]=e),e=t[this.index];var i=this._t._createNode(e),s=this.hasChildren&&!this.hasPendingChildren?this.element.nextSibling:null;s&&n.removeChild(s),(s=i.hasChildren&&!i.hasPendingChildren?i.element.nextSibling:null)&&this.element.parentElement.insertBefore(s,this.element.nextSibling),this.element.innerHTML=i.element.innerHTML,this._updateState()},e.prototype.move=function(t,n){if(t instanceof e&&this._contains(t))return!1;var i=this.parentNode,s=this._getArray();this._moveElements(t,n);var r=this.parentNode,o=this._getArray();i&&i._updateState(),r&&r._updateState();var a=this.dataItem,l=s.indexOf(a);return s.splice(l,1),o.splice(this.index,0,a),t.treeView&&(this._t=t.treeView),!0},Object.defineProperty(e.prototype,"itemsSource",{get:function(){return this._getArray()},enumerable:!0,configurable:!0}),e.prototype._pse=function(e){return e.previousElementSibling},e.prototype._contains=function(e){for(;e;e=e.parentNode)if(e.element==this.element)return!0;return!1},e.prototype._getArray=function(){var e=this._t,t=this.parentNode,n=e.itemsSource;if(t){var i=e._itmPath;(n=i.getValue(t.dataItem,this.level))||(n=[],i.setValue(t.dataItem,this.level,n))}return n},e.prototype._moveElements=function(t,i){var s=document.createDocumentFragment(),o=this.hasChildren&&!this.hasPendingChildren?this.element.nextSibling:null;if(s.appendChild(this.element),o&&(e._assertNodeList(o),s.appendChild(o)),t instanceof r)t._root.insertBefore(s,null);else{var a=t.element,l=a?a.parentElement:t.treeView._root;e._assertNodeList(l);var d=h;switch(i){case d.Before:l.insertBefore(s,a);break;case d.After:a=(t=t.nextSibling())?t.element:null,l.insertBefore(s,a);break;case d.Into:t.hasChildren&&!t.hasPendingChildren||(o=document.createElement("div"),n.addClass(o,r._CNDL),l.insertBefore(o,a.nextSibling)),l=t.element.nextSibling,e._assertNodeList(l),l.insertBefore(s,null)}}},e.prototype._updateState=function(){this._updateEmptyState(),this._updateCheckedState()},e.prototype._updateEmptyState=function(){var t=this.element.nextSibling,i=!1;e._isNodeList(t)&&(t.childElementCount?i=!0:n.removeChild(t)),n.toggleClass(this.element,r._CEMP,!i),i||this.element.removeAttribute("aria-expanded")},e.prototype._updateCheckedState=function(){var e=this.checkBox,t=this.nodes,n=0,i=0;if(e&&t){for(var s=0;s<t.length;s++)switch(t[s].isChecked){case!0:n++;break;case!1:i++}n==t.length?(e.checked=!0,e.indeterminate=!1):i==t.length?(e.checked=!1,e.indeterminate=!1):(e.checked=!1,e.indeterminate=!0)}var r=this.parentNode;r&&r._updateCheckedState()},e._getChildNodes=function(t,n){e._assertNodeList(n);var i=[];if(e._isNodeList(n))for(var s=n.children,r=0;r<s.length;r++){var o=s[r];e._isNode(o)&&i.push(new e(t,o))}return i},e._isNode=function(e){return e&&n.hasClass(e,r._CND)},e._isNodeList=function(e){return e&&n.hasClass(e,r._CNDL)},e._isEmpty=function(t){return e._isNode(t)&&n.hasClass(t,r._CEMP)},e._isCollapsed=function(t){return e._isNode(t)&&!e._isEmpty(t)&&n.hasClass(t,r._CCLD)},e._assertNode=function(t){n.assert(e._isNode(t),"node expected")},e._assertNodeList=function(t){n.assert(e._isNodeList(t),"nodeList expected")},e}();t.TreeNode=o;var a=function(e){function t(t,i,s){var r=e.call(this)||this;return r._data=t,r._e=n.asType(i,HTMLElement),r._level=s,r}return __extends(t,e),Object.defineProperty(t.prototype,"dataItem",{get:function(){return this._data},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this._e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._level},enumerable:!0,configurable:!0}),t}(n.EventArgs);t.FormatNodeEventArgs=a;var l=function(e){function t(t){var n=e.call(this)||this;return n._node=t,n}return __extends(t,e),Object.defineProperty(t.prototype,"node",{get:function(){return this._node},enumerable:!0,configurable:!0}),t}(n.CancelEventArgs);t.TreeNodeEventArgs=l;var d=function(e){function t(t,i,s){var r=e.call(this)||this;return r._src=n.asType(t,o),r._tgt=n.asType(i,o),r._pos=s,r}return __extends(t,e),Object.defineProperty(t.prototype,"dragSource",{get:function(){return this._src},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dropTarget",{get:function(){return this._tgt},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._pos},set:function(e){this._pos=n.asEnum(e,h)},enumerable:!0,configurable:!0}),t}(n.CancelEventArgs);t.TreeNodeDragDropEventArgs=d;var h;!function(e){e[e.Before=0]="Before",e[e.After=1]="After",e[e.Into=2]="Into"}(h=t.DropPosition||(t.DropPosition={}));var c=function(){function e(e){this._tree=n.asType(e,r),this._dragstartBnd=this._dragstart.bind(this),this._dragoverBnd=this._dragover.bind(this),this._dropBnd=this._drop.bind(this),this._dragendBnd=this._dragend.bind(this);var t=this._tree,i=t.hostElement;t.addEventListener(i,"dragstart",this._dragstartBnd),t.addEventListener(i,"dragover",this._dragoverBnd),t.addEventListener(i,"dragleave",this._dragoverBnd),t.addEventListener(i,"drop",this._dropBnd),t.addEventListener(i,"dragend",this._dragendBnd),t.addEventListener(i,"keydown",this._keydown)}return e.prototype.dispose=function(){var e=this._tree,t=e.hostElement;e.removeEventListener(t,"dragstart",this._dragstartBnd),e.removeEventListener(t,"dragover",this._dragoverBnd),e.removeEventListener(t,"dragleave",this._dragoverBnd),e.removeEventListener(t,"drop",this._dropBnd),e.removeEventListener(t,"dragend",this._dragendBnd),e.removeEventListener(t,"keydown",this._keydown),this._showDragMarker()},e.prototype._dragstart=function(t){if(!t.defaultPrevented){var i=this._tree,s=n.closestClass(t.target,r._CND),a=e;if(a._drgSrc=o._isNode(s)?new o(i,s):null,a._drgSrc){var d=new l(a._drgSrc);i.onDragStart(d)||(a._drgSrc=null)}a._drgSrc&&t.dataTransfer?(n._startDrag(t.dataTransfer,"copyMove"),t.stopPropagation()):t.preventDefault()}},e.prototype._dragover=function(e){this._handleDragDrop(e,!1)},e.prototype._drop=function(e){this._handleDragDrop(e,!0)},e.prototype._dragend=function(t){e._drgSrc=null,this._showDragMarker(),this._tree.onDragEnd()},e.prototype._keydown=function(e){e.defaultPrevented||e.keyCode==n.Key.Escape&&this._dragendBnd(null)},e.prototype._handleDragDrop=function(t,i){var s,a,l=this._tree,c=e,u=h,p=u.Into;if(!t.defaultPrevented&&c._drgSrc){var _=document.elementFromPoint(t.clientX,t.clientY),f=n.closestClass(_,r._CND);if(null==f){var g=n.Control.getControl(n.closest(_,".wj-treeview"));g instanceof r&&0==g.totalItemCount&&(f=g.hostElement)}if(f==c._drgSrc.element&&(f=null),f){a=f.getBoundingClientRect();var m=new o(l,f),b=m.hasPendingChildren?a.height/2:a.height/3;null==m.element?((a=n.Rect.fromBoundingRect(a)).inflate(-12,-12),p=u.Before):t.clientY<a.top+b?p=u.Before:(t.clientY>a.bottom-b||m.hasPendingChildren)&&(p=u.After,!m.hasChildren||m.isCollapsed||m.hasPendingChildren||(p=u.Before,a=(f=(m=m.next(!0,!1)).element).getBoundingClientRect())),c._drgSrc._contains(m)?f=null:((s=new d(c._drgSrc,m,p)).cancel=c._drgSrc.treeView!=m.treeView,l.onDragOver(s)||(f=null))}if(f)if((p=s.position)==u.Before){var C=s.dragSource.next(!0,!1);C&&C.element==f&&(f=null)}else if(p==u.After){var v=s.dragSource.previous(!0,!1);v&&v.element==f&&(f=null)}if(f&&!i?(t.dataTransfer.dropEffect="move",t.preventDefault(),t.stopPropagation(),this._showDragMarker(a,p)):this._showDragMarker(),f&&i&&l.onDrop(s)){l.hostElement.focus();var y=s.dragSource;y.move(s.dropTarget,s.position),y.select()}}},e.prototype._showDragMarker=function(t,i){var s=this._tree,r=e._dMarker.parentElement;if(t){var o=s.hostElement.getBoundingClientRect(),a=i==h.After?t.bottom:t.top,l={top:Math.round(a-o.top+s.hostElement.scrollTop-2),width:"75%",height:i==h.Into?t.height:4,opacity:i==h.Into?"0.15":""};s.rightToLeft?l.right=Math.round(o.right-t.right):l.left=Math.round(t.left-o.left),n.setCss(e._dMarker,l),r!=s._root&&s._root.appendChild(e._dMarker)}else r&&r.removeChild(e._dMarker)},e._dMarker=n.createElement('<div class="wj-marker">&nbsp;</div>'),e}();t._TreeDragDropManager=c;var u=function(){function e(e){this.path=e}return Object.defineProperty(e.prototype,"path",{get:function(){return this._path},set:function(e){if(this._path=e,n.isString(e))this._bindings=[new n.Binding(e)];else if(n.isArray(e)){this._bindings=[];for(var t=0;t<e.length;t++)this._bindings.push(new n.Binding(e[t]))}else null!=e&&n.assert(!1,"Path should be a string or an array of strings.");this._maxLevel=this._bindings?this._bindings.length-1:-1},enumerable:!0,configurable:!0}),e.prototype.getValue=function(e,t){var n=Math.min(t,this._maxLevel);return n>-1?this._bindings[n].getValue(e):null},e.prototype.setValue=function(e,t,n){var i=Math.min(t,this._maxLevel);i>-1&&this._bindings[i].setValue(e,n)},e}();t._BindingArray=u;var p=function(e){function t(t,i,s){var r=e.call(this,t,null,!0)||this;r._tabs=new n.ObservableArray,r._selectedIndex=-1,r._animated=!0,r._autoSwitch=!0,r.selectedIndexChanged=new n.Event;var o=r.hostElement,a=[];if(!s)for(;o.firstElementChild;){var l=o.firstElementChild;o.removeChild(l),a.push(l)}var d=r.getTemplate();return r.applyTemplate("wj-control wj-tabpanel",d,{_dRoot:"root",_dTabHeaders:"tabheaders",_dTabPanes:"tabpanes"}),r._tabIndex=o.tabIndex,o.tabIndex=-1,r._dRoot.tabIndex=r._dTabHeaders.tabIndex=r._dTabPanes.tabIndex=-1,r.addEventListener(o,"click",r._click.bind(r)),r.addEventListener(o,"keydown",r._keydown.bind(r)),r._tabs.collectionChanged.addHandler(r._populateControl.bind(r)),r.tabs.deferUpdate(function(){a.forEach(function(e){n.assert(2==e.childElementCount,"TabPanel children should contain header and pane elements"),r.tabs.push(new _(e.children[0],e.children[1]))})}),r.initialize(i),r.selectedIndex<0&&r.tabs.length?r.selectedIndex=0:r.onSelectedIndexChanged(),r}return __extends(t,e),Object.defineProperty(t.prototype,"tabs",{get:function(){return this._tabs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedIndex",{get:function(){return this._selectedIndex},set:function(e){(e=n.asInt(e,!1))!=this._selectedIndex?(this._selectedIndex=e,this._updateContent(),this.onSelectedIndexChanged()):this._updateContent()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedTab",{get:function(){var e=this._selectedIndex;return e>-1?this._tabs[e]:null},set:function(e){for(var t=-1,n=0;n<this._tabs.length&&t<0;n++)this._tabs[n]==e&&(t=n);this.selectedIndex=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAnimated",{get:function(){return this._animated},set:function(e){this._animated=n.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoSwitch",{get:function(){return this._autoSwitch},set:function(e){e!=this._autoSwitch&&(this._autoSwitch=n.asBoolean(e),this._updateContent())},enumerable:!0,configurable:!0}),t.prototype.getTab=function(e){for(t=0;t<this._tabs.length;t++)if((n=this._tabs[t]).header.id==e||n.pane.id==e)return n;for(var t=0;t<this._tabs.length;t++){var n=this._tabs[t];if(n.header.textContent==e)return n}return null},t.prototype.onSelectedIndexChanged=function(e){this.selectedIndexChanged.raise(this,e)},t.prototype._populateControl=function(){var e=this;this._removeChildren(this._dTabHeaders),this._removeChildren(this._dTabPanes);var t=-1;this._tabs.forEach(function(i,s){n.assert(i instanceof _,"tabs array must contain Tab objects."),i._setPanel(e);var r=i.header,o=i.pane;n.addClass(r,"wj-tabheader"),n.setAttribute(r,"role","tab"),n.setAttribute(r,"aria-controls",o.id?o.id:null),e._dTabHeaders.appendChild(r),n.addClass(o,"wj-tabpane"),n.setAttribute(o,"role","tabpanel"),n.setAttribute(o,"aria-labelledby",r.id?r.id:null),e._dTabPanes.appendChild(o),t<0&&(n.hasClass(r,"wj-state-active")||"true"==r.getAttribute("aria-selected"))&&(t=s)}),t<0&&this._tabs.length>0&&(t=0),t>-1?this.selectedIndex=t:this.selectedIndex>-1&&this.selectedIndex<this._tabs.length&&this._updateContent(),this._validateSelection()},t.prototype._validateSelection=function(){var e=this.selectedTab;if(e&&(e.isDisabled||!e.isVisible)){var t=this._getNextIndex(this.selectedIndex,1);t<0&&(t=this._getNextIndex(this.selectedIndex,-1)),this.selectedIndex=t}},t.prototype._updateContent=function(){var e=this,t=n.contains(this._dTabHeaders,n.getActiveElement()),i=this._dTabHeaders.children,s=this._dTabPanes.children,r=this._selectedIndex;if(r>-1&&r<s.length){var o=(h=s[r]).style;this.isAnimated?(o.opacity="0",this._toAnim&&clearInterval(this._toAnim),this._toAnim=n.animate(function(t){1==t?(o.opacity="",e._toAnim=null):o.opacity=t.toString()})):o.opacity=""}for(var a=0;a<i.length;a++){var l=a==r,d=i[a],h=s[a];n.setAttribute(d,"aria-selected",l),n.toggleClass(d,"wj-state-active",l),n.toggleClass(h,"wj-state-active",l),d.tabIndex=l||!this._autoSwitch?this._tabIndex:-1,l&&(t&&d.focus(),n.Control.invalidateAll(h))}},t.prototype._removeChildren=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},t.prototype._click=function(e){var t=this._getTabIndex(e.target);t>-1&&(this.selectedIndex=t)},t.prototype._keydown=function(e){if(!e.defaultPrevented){var t=this._getTabIndex(n.getActiveElement());if(t>-1){var i=e.keyCode;if(this.rightToLeft)switch(i){case n.Key.Left:i=n.Key.Right;break;case n.Key.Right:i=n.Key.Left}switch(i){case n.Key.Left:case n.Key.Up:case n.Key.Right:case n.Key.Down:case n.Key.Home:case n.Key.PageUp:case n.Key.End:case n.Key.PageDown:switch(i){case n.Key.Left:case n.Key.Up:t=this._getNextIndex(t,-1);break;case n.Key.Right:case n.Key.Down:t=this._getNextIndex(t,1);break;case n.Key.Home:case n.Key.PageUp:t=this._getNextIndex(-1,1);break;case n.Key.End:case n.Key.PageDown:t=this._getNextIndex(this._tabs.length,-1)}t>-1&&(this._autoSwitch?this.selectedIndex=t:this._tabs[t].header.focus()),e.preventDefault();break;case n.Key.Enter:case n.Key.Space:t>-1&&this._tabs[t].header.click(),e.preventDefault()}}}},t.prototype._getTabIndex=function(e){var t=n.closest(e,".wj-tabheader");if(t&&n.closest(t,".wj-tabpanel")==this.hostElement)for(var i=0;i<this._tabs.length;i++)if(this._tabs[i].header==t)return i;return-1},t.prototype._getNextIndex=function(e,t){for(var n=e+t;n>-1&&n<this._tabs.length;n+=t){var i=this._tabs[n];if(!i.isDisabled&&i.isVisible)return n}return-1},t.controlTemplate='<div wj-part="root"><div wj-part="tabheaders" class="wj-tabheaders" role="tablist"></div><div wj-part="tabpanes" class="wj-tabpanes"></div></div>',t}(n.Control);t.TabPanel=p;var _=function(){function e(e,t){this._hdr=n.asType(n.getElement(e),HTMLElement),this._pane=n.asType(n.getElement(t),HTMLElement)}return Object.defineProperty(e.prototype,"tabPanel",{get:function(){return this._p},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"header",{get:function(){return this._hdr},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pane",{get:function(){return this._pane},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDisabled",{get:function(){return n.hasClass(this._hdr,"wj-state-disabled")},set:function(e){n.toggleClass(this._hdr,"wj-state-disabled",n.asBoolean(e)),this._p&&this._p._validateSelection()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return"none"!=this._hdr.style.display},set:function(e){this._hdr.style.display=n.asBoolean(e)?"":"none",this._p&&this._p._validateSelection()},enumerable:!0,configurable:!0}),e.prototype._setParts=function(e,t){if(e=n.asType(n.getElement(e),HTMLElement),t=n.asType(n.getElement(t),HTMLElement,!1),this._hdr!==e||this._pane!==t){var i=this.isDisabled,s=this.isVisible;this._hdr=e,this._pane=t,this.isDisabled=i,this.isVisible=s;var r=this.tabPanel;r&&!r.tabs.isUpdating&&r._populateControl()}},e.prototype._setPanel=function(e){this._p=e},e}();t.Tab=_});