(function(){var n,a,u,d,r,v,g,nt,f,tt,y,p,t,e,o,i,s,it,rt,w,h,ut,b,c,k,ft,et,ot,st=[].slice,ht={}.hasOwnProperty,l=function(n,t){function r(){this.constructor=n}for(var i in t)ht.call(t,i)&&(n[i]=t[i]);return r.prototype=t.prototype,n.prototype=new r,n.__super__=t.prototype,n};n=this.jQuery;s=function(){function t(t,i){this.$el=n(t);this.options=n.extend({},this.defaults,i)}return t.prototype.defaults={},t.prototype.destroy=function(){return this._deinit()},t.prototype._init=function(){return null},t.prototype._deinit=function(){return null},t.register=function(i,r){var f,e,o,u;return u=function(){return"simple_widget_"+r},e=function(t,r){var o,f,s,e,h;for(o=u(),e=0,h=t.length;e<h;e++)f=t[e],s=new i(f,r),n.data(f,o)||n.data(f,o,s),s._init();return t},o=function(i){var e,o,r,f,h,s;for(e=u(),s=[],f=0,h=i.length;f<h;f++)o=i[f],r=n.data(o,e),r&&r instanceof t&&r.destroy(),s.push(n.removeData(o,e));return s},f=function(i,r,f){var c,h,e,o,s,l;for(h=null,s=0,l=i.length;s<l;s++)c=i[s],e=n.data(c,u()),e&&e instanceof t&&(o=e[r],o&&typeof o=="function"&&(h=o.apply(e,f)));return h},n.fn[r]=function(){var t,r,n,i,u;return(n=arguments[0],r=2<=arguments.length?st.call(arguments,1):[],t=this,n===void 0||typeof n=="object")?(u=n,e(t,u)):typeof n=="string"&&n[0]!=="_"?(i=n,i==="destroy"?o(t):f(t,i,r)):void 0}},t}();this.SimpleWidget=s;tt=function(t){function i(){return ft=i.__super__.constructor.apply(this,arguments)}return l(i,t),i.is_mouse_handled=!1,i.prototype._init=function(){return this.$el.bind("mousedown.mousewidget",n.proxy(this._mouseDown,this)),this.$el.bind("touchstart.mousewidget",n.proxy(this._touchStart,this)),this.is_mouse_started=!1,this.mouse_delay=0,this._mouse_delay_timer=null,this._is_mouse_delay_met=!0,this.mouse_down_info=null},i.prototype._deinit=function(){var t;return this.$el.unbind("mousedown.mousewidget"),this.$el.unbind("touchstart.mousewidget"),t=n(document),t.unbind("mousemove.mousewidget"),t.unbind("mouseup.mousewidget")},i.prototype._mouseDown=function(n){var t;if(n.which===1)return t=this._handleMouseDown(n,this._getPositionInfo(n)),t&&n.preventDefault(),t},i.prototype._handleMouseDown=function(n,t){if(!i.is_mouse_handled)return(this.is_mouse_started&&this._handleMouseUp(t),this.mouse_down_info=t,!this._mouseCapture(t))?void 0:(this._handleStartMouse(),this.is_mouse_handled=!0,!0)},i.prototype._handleStartMouse=function(){var t;return t=n(document),t.bind("mousemove.mousewidget",n.proxy(this._mouseMove,this)),t.bind("touchmove.mousewidget",n.proxy(this._touchMove,this)),t.bind("mouseup.mousewidget",n.proxy(this._mouseUp,this)),t.bind("touchend.mousewidget",n.proxy(this._touchEnd,this)),this.mouse_delay?this._startMouseDelayTimer():void 0},i.prototype._startMouseDelayTimer=function(){var n=this;return this._mouse_delay_timer&&clearTimeout(this._mouse_delay_timer),this._mouse_delay_timer=setTimeout(function(){return n._is_mouse_delay_met=!0},this.mouse_delay),this._is_mouse_delay_met=!1},i.prototype._mouseMove=function(n){return this._handleMouseMove(n,this._getPositionInfo(n))},i.prototype._handleMouseMove=function(n,t){return this.is_mouse_started?(this._mouseDrag(t),n.preventDefault()):this.mouse_delay&&!this._is_mouse_delay_met?!0:(this.is_mouse_started=this._mouseStart(this.mouse_down_info)!==!1,this.is_mouse_started?this._mouseDrag(t):this._handleMouseUp(t),!this.is_mouse_started)},i.prototype._getPositionInfo=function(n){return{page_x:n.pageX,page_y:n.pageY,target:n.target,original_event:n}},i.prototype._mouseUp=function(n){return this._handleMouseUp(this._getPositionInfo(n))},i.prototype._handleMouseUp=function(t){var i;i=n(document);i.unbind("mousemove.mousewidget");i.unbind("touchmove.mousewidget");i.unbind("mouseup.mousewidget");i.unbind("touchend.mousewidget");this.is_mouse_started&&(this.is_mouse_started=!1,this._mouseStop(t))},i.prototype._mouseCapture=function(){return!0},i.prototype._mouseStart=function(){return null},i.prototype._mouseDrag=function(){return null},i.prototype._mouseStop=function(){return null},i.prototype.setMouseDelay=function(n){return this.mouse_delay=n},i.prototype._touchStart=function(n){var t;if(!(n.originalEvent.touches.length>1))return t=n.originalEvent.changedTouches[0],this._handleMouseDown(n,this._getPositionInfo(t))},i.prototype._touchMove=function(n){var t;if(!(n.originalEvent.touches.length>1))return t=n.originalEvent.changedTouches[0],this._handleMouseMove(n,this._getPositionInfo(t))},i.prototype._touchEnd=function(n){var t;if(!(n.originalEvent.touches.length>1))return t=n.originalEvent.changedTouches[0],this._handleMouseUp(this._getPositionInfo(t))},i}(s);this.Tree={};n=this.jQuery;t={getName:function(n){return t.strings[n-1]},nameToIndex:function(n){for(var i,u=i=1,r=t.strings.length;1<=r?i<=r:i>=r;u=1<=r?++i:--i)if(t.strings[u-1]===n)return u;return 0}};t.BEFORE=1;t.AFTER=2;t.INSIDE=3;t.NONE=4;t.strings=["before","after","inside","none"];this.Tree.Position=t;y=function(){function i(n,t,r){t==null&&(t=!1);r==null&&(r=i);this.setData(n);this.children=[];this.parent=null;t&&(this.id_mapping={},this.tree=this,this.node_class=r)}return i.prototype.setData=function(n){var t,r,i;if(typeof n!="object")return this.name=n;i=[];for(t in n)r=n[t],t==="label"?i.push(this.name=r):i.push(this[t]=r);return i},i.prototype.initFromData=function(n){var i,r,t=this;return r=function(n){return t.setData(n),n.children?i(n.children):void 0},i=function(n){for(var u,r,i=0,f=n.length;i<f;i++)u=n[i],r=new t.tree.node_class(""),r.initFromData(u),t.addChild(r);return null},r(n),null},i.prototype.loadFromData=function(n){var r,t,i,u;for(this.removeChildren(),i=0,u=n.length;i<u;i++)t=n[i],r=new this.tree.node_class(t),this.addChild(r),typeof t=="object"&&t.children&&r.loadFromData(t.children);return null},i.prototype.addChild=function(n){return this.children.push(n),n._setParent(this)},i.prototype.addChildAtPosition=function(n,t){return this.children.splice(t,0,n),n._setParent(this)},i.prototype._setParent=function(n){return this.parent=n,this.tree=n.tree,this.tree.addNodeToIndex(this)},i.prototype.removeChild=function(n){return n.removeChildren(),this._removeChild(n)},i.prototype._removeChild=function(n){return this.children.splice(this.getChildIndex(n),1),this.tree.removeNodeFromIndex(n)},i.prototype.getChildIndex=function(t){return n.inArray(t,this.children)},i.prototype.hasChildren=function(){return this.children.length!==0},i.prototype.isFolder=function(){return this.hasChildren()||this.load_on_demand},i.prototype.iterate=function(n){var t,i=this;return t=function(r,u){var e,s,f,h,o;if(r.children){for(o=r.children,f=0,h=o.length;f<h;f++)e=o[f],s=n(e,u),i.hasChildren()&&s&&t(e,u+1);return null}},t(this,0),null},i.prototype.moveNode=function(n,i,r){if(!n.isParentOf(i))return(n.parent._removeChild(n),r===t.AFTER)?i.parent.addChildAtPosition(n,i.parent.getChildIndex(i)+1):r===t.BEFORE?i.parent.addChildAtPosition(n,i.parent.getChildIndex(i)):r===t.INSIDE?i.addChildAtPosition(n,0):void 0},i.prototype.getData=function(){var n,t=this;return n=function(t){var e,i,r,u,o,f,s;for(e=[],f=0,s=t.length;f<s;f++){r=t[f];u={};for(i in r)o=r[i],i!=="parent"&&i!=="children"&&i!=="element"&&i!=="tree"&&Object.prototype.hasOwnProperty.call(r,i)&&(u[i]=o);r.hasChildren()&&(u.children=n(r.children));e.push(u)}return e},n(this.children)},i.prototype.getNodeByName=function(n){var t;return t=null,this.iterate(function(i){return i.name===n?(t=i,!1):!0}),t},i.prototype.addAfter=function(n){var i,t;return this.parent?(t=new this.tree.node_class(n),i=this.parent.getChildIndex(this),this.parent.addChildAtPosition(t,i+1),t):null},i.prototype.addBefore=function(n){var i,t;return this.parent?(t=new this.tree.node_class(n),i=this.parent.getChildIndex(this),this.parent.addChildAtPosition(t,i),t):null},i.prototype.addParent=function(n){var f,t,i,r,e,u;if(this.parent){for(t=new this.tree.node_class(n),t._setParent(this.tree),i=this.parent,u=i.children,r=0,e=u.length;r<e;r++)f=u[r],t.addChild(f);return i.children=[],i.addChild(t),t}return null},i.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this),this.parent=null},i.prototype.append=function(n){var t;return t=new this.tree.node_class(n),this.addChild(t),t},i.prototype.prepend=function(n){var t;return t=new this.tree.node_class(n),this.addChildAtPosition(t,0),t},i.prototype.isParentOf=function(n){for(var t=n.parent;t;){if(t===this)return!0;t=t.parent}return!1},i.prototype.getLevel=function(){for(var t=0,n=this;n.parent;)t+=1,n=n.parent;return t},i.prototype.getNodeById=function(n){return this.id_mapping[n]},i.prototype.addNodeToIndex=function(n){if(n.id!=null)return this.id_mapping[n.id]=n},i.prototype.removeNodeFromIndex=function(n){if(n.id!=null)return delete this.id_mapping[n.id]},i.prototype.removeChildren=function(){var n=this;return this.iterate(function(t){return n.tree.removeNodeFromIndex(t),!0}),this.children=[]},i.prototype.getPreviousSibling=function(){var n;return this.parent?(n=this.parent.getChildIndex(this)-1,n>=0?this.parent.children[n]:null):null},i.prototype.getNextSibling=function(){var n;return this.parent?(n=this.parent.getChildIndex(this)+1,n<this.parent.children.length?this.parent.children[n]:null):null},i}();this.Tree.Node=y;nt=function(s){function h(){return et=h.__super__.constructor.apply(this,arguments)}return l(h,s),h.prototype.defaults={autoOpen:!1,saveState:!1,dragAndDrop:!1,selectable:!0,useContextMenu:!0,onCanSelectNode:null,onSetStateFromStorage:null,onGetStateFromStorage:null,onCreateLi:null,onIsMoveHandle:null,onCanMove:null,onCanMoveTo:null,onLoadFailed:null,autoEscape:!0,dataUrl:null,closedIcon:"&#x25ba;",openedIcon:"&#x25bc;",slide:!0,nodeClass:y,dataFilter:null,keyboardSupport:!0},h.prototype.toggle=function(n,t){return t==null&&(t=!0),n.is_open?this.closeNode(n,t):this.openNode(n,t)},h.prototype.getTree=function(){return this.tree},h.prototype.selectNode=function(n){return this._selectNode(n,!1)},h.prototype._selectNode=function(n,t){var u,f,e,r,i=this;if(t==null&&(t=!1),this.select_node_handler){if(u=function(){return i.options.onCanSelectNode?i.options.selectable&&i.options.onCanSelectNode(n):i.options.selectable},e=function(){var t;return t=n.parent,t&&t.parent&&!t.is_open?i.openNode(t,!1):void 0},r=function(){if(i.options.saveState)return i.save_state_handler.saveState()},!n){this._deselectCurrentNode();r();return}if(u())return this.select_node_handler.isNodeSelected(n)?t&&(this._deselectCurrentNode(),this._triggerEvent("tree.select",{node:null,previous_node:n})):(f=this.getSelectedNode(),this._deselectCurrentNode(),this.addToSelection(n),this._triggerEvent("tree.select",{node:n,deselected_node:f}),e()),r()}},h.prototype.getSelectedNode=function(){return this.select_node_handler.getSelectedNode()},h.prototype.toJson=function(){return JSON.stringify(this.tree.getData())},h.prototype.loadData=function(n,t){return this._loadData(n,t)},h.prototype.loadDataFromUrl=function(t,i,r){return n.type(t)!=="string"&&(r=i,i=t,t=null),this._loadDataFromUrl(t,i,r)},h.prototype._loadDataFromUrl=function(t,i,u){var e,s,h,o,f=this;return e=null,s=function(){var n;return i?(n=new r(i,f),e=n.getLi()):e=f.element,e.addClass("jqtree-loading")},o=function(){if(e)return e.removeClass("jqtree-loading")},h=function(){return n.type(t)==="string"&&(t={url:t}),t.method?void 0:t.method="get"},s(),t||(t=this._getDataUrlInfo(i)),h(),n.ajax({url:t.url,data:t.data,type:t.method.toUpperCase(),cache:!1,dataType:"json",success:function(t){var r;return r=n.isArray(t)||typeof t=="object"?t:n.parseJSON(t),f.options.dataFilter&&(r=f.options.dataFilter(r)),o(),f._loadData(r,i),u&&n.isFunction(u)?u():void 0},error:function(n){if(o(),f.options.onLoadFailed)return f.options.onLoadFailed(n)}})},h.prototype._loadData=function(n,t){var u,r,i,f;if(this._triggerEvent("tree.load_data",{tree_data:n}),t){for(r=this.select_node_handler.getSelectedNodes(t),i=0,f=r.length;i<f;i++)u=r[i],this.select_node_handler.removeFromSelection(u);t.loadFromData(n);t.load_on_demand=!1;this._refreshElements(t.parent)}else this._initTree(n);if(this.is_dragging)return this.dnd_handler.refreshHitAreas()},h.prototype.getNodeById=function(n){return this.tree.getNodeById(n)},h.prototype.getNodeByName=function(n){return this.tree.getNodeByName(n)},h.prototype.openNode=function(n,t){return t==null&&(t=!0),this._openNode(n,t)},h.prototype._openNode=function(n,t,i){var f,u,e=this;if(t==null&&(t=!0),f=function(n,t,i){var u;return u=new r(n,e),u.open(i,t)},n.isFolder()){if(n.load_on_demand)return this._loadFolderOnDemand(n,t,i);for(u=n.parent;u&&!u.is_open;)u.parent&&f(u,!1,null),u=u.parent;return f(n,t,i),this._saveState()}},h.prototype._loadFolderOnDemand=function(n,t,i){var r=this;return t==null&&(t=!0),this._loadDataFromUrl(null,n,function(){return r._openNode(n,t,i)})},h.prototype.closeNode=function(n,t){return t==null&&(t=!0),n.isFolder()?(new r(n,this).close(t),this._saveState()):void 0},h.prototype.isDragging=function(){return this.is_dragging},h.prototype.refreshHitAreas=function(){return this.dnd_handler.refreshHitAreas()},h.prototype.addNodeAfter=function(n,t){var i;return i=t.addAfter(n),this._refreshElements(t.parent),i},h.prototype.addNodeBefore=function(n,t){var i;return i=t.addBefore(n),this._refreshElements(t.parent),i},h.prototype.addParentNode=function(n,t){var i;return i=t.addParent(n),this._refreshElements(i.parent),i},h.prototype.removeNode=function(n){var t;return t=n.parent,t?(this.select_node_handler.removeFromSelection(n,!0),n.remove(),this._refreshElements(t.parent)):void 0},h.prototype.appendNode=function(n,t){var i,r;return t||(t=this.tree),i=t.isFolder(),r=t.append(n),i?this._refreshElements(t):this._refreshElements(t.parent),r},h.prototype.prependNode=function(n,t){var i;return t||(t=this.tree),i=t.prepend(n),this._refreshElements(t),i},h.prototype.updateNode=function(n,t){var i;return i=t.id&&t.id!==n.id,i&&this.tree.removeNodeFromIndex(n),n.setData(t),i&&this.tree.addNodeToIndex(n),this._refreshElements(n.parent),this._selectCurrentNode()},h.prototype.moveNode=function(n,i,r){var u;return u=t.nameToIndex(r),this.tree.moveNode(n,i,u),this._refreshElements()},h.prototype.getStateFromStorage=function(){return this.save_state_handler.getStateFromStorage()},h.prototype.addToSelection=function(n){return this.select_node_handler.addToSelection(n),this._getNodeElementForNode(n).select()},h.prototype.getSelectedNodes=function(){return this.select_node_handler.getSelectedNodes()},h.prototype.isNodeSelected=function(n){return this.select_node_handler.isNodeSelected(n)},h.prototype.removeFromSelection=function(n){return this.select_node_handler.removeFromSelection(n),this._getNodeElementForNode(n).deselect()},h.prototype.scrollToNode=function(t){var i,r;return i=n(t.element),r=i.offset().top-this.$el.offset().top,this.scroll_handler.scrollTo(r)},h.prototype.getState=function(){return this.save_state_handler.getState()},h.prototype.setState=function(n){return this.save_state_handler.setState(n),this._refreshElements()},h.prototype._init=function(){return h.__super__._init.call(this),this.element=this.$el,this.mouse_delay=300,this.is_initialized=!1,typeof e!="undefined"&&e!==null?this.save_state_handler=new e(this):this.options.saveState=!1,typeof i!="undefined"&&i!==null&&(this.select_node_handler=new i(this)),typeof u!="undefined"&&u!==null?this.dnd_handler=new u(this):this.options.dragAndDrop=!1,typeof o!="undefined"&&o!==null&&(this.scroll_handler=new o(this)),typeof f!="undefined"&&f!==null&&typeof i!="undefined"&&i!==null&&(this.key_handler=new f(this)),this._initData(),this.element.click(n.proxy(this._click,this)),this.element.dblclick(n.proxy(this._dblclick,this)),this.options.useContextMenu?this.element.bind("contextmenu",n.proxy(this._contextmenu,this)):void 0},h.prototype._deinit=function(){return this.element.empty(),this.element.unbind(),this.key_handler.deinit(),this.tree=null,h.__super__._deinit.call(this)},h.prototype._initData=function(){return this.options.data?this._loadData(this.options.data):this._loadDataFromUrl(this._getDataUrlInfo())},h.prototype._getDataUrlInfo=function(t){var i,r,u=this;return i=this.options.dataUrl||this.element.data("url"),r=function(){var n,f,r;return r={url:i},t&&t.id?(n={node:t.id},r.data=n):(f=u._getNodeIdToBeSelected(),f&&(n={selected_node:f},r.data=n)),r},n.isFunction(i)?i(t):n.type(i)==="string"?r():i},h.prototype._getNodeIdToBeSelected=function(){return this.options.saveState?this.save_state_handler.getNodeIdToBeSelected():null},h.prototype._initTree=function(n){return this.tree=new this.options.nodeClass(null,!0,this.options.nodeClass),this.select_node_handler&&this.select_node_handler.clear(),this.tree.loadFromData(n),this._openNodes(),this._refreshElements(),this.is_initialized?void 0:(this.is_initialized=!0,this._triggerEvent("tree.init"))},h.prototype._openNodes=function(){var n;if(!this.options.saveState||!this.save_state_handler.restoreState())return this.options.autoOpen===!1?void 0:(n=this.options.autoOpen===!0?-1:parseInt(this.options.autoOpen),this.tree.iterate(function(t,i){return t.hasChildren()&&(t.is_open=!0),i!==n}))},h.prototype._refreshElements=function(t){var r,s,h,c,l,f,e,u,o,i=this;return t==null&&(t=null),e=function(n){return i.options.autoEscape?rt(n):n},l=function(t){var i;return i=t?"jqtree-tree":"",n('<ul class="jqtree_common '+i+'"><\/ul>')},h=function(n){var t;if(t=n.isFolder()?s(n):c(n),i.options.onCreateLi)i.options.onCreateLi(n,t);return t},c=function(t){var u,f,r;return r=["jqtree_common"],i.select_node_handler&&i.select_node_handler.isNodeSelected(t)&&r.push("jqtree-selected"),u=r.join(" "),f=e(t.name),n('<li class="'+u+'"><div class="jqtree-element jqtree_common"><span class="jqtree-title jqtree_common">'+f+"<\/span><\/div><\/li>")},s=function(t){var r,u,f,o,s,h;return s=function(){var n;return n=["jqtree-toggler"],t.is_open||n.push("jqtree-closed"),n.join(" ")},h=function(){var n;return n=["jqtree-folder"],t.is_open||n.push("jqtree-closed"),i.select_node_handler&&i.select_node_handler.isNodeSelected(t)&&n.push("jqtree-selected"),n.join(" ")},u=s(),o=h(),f=e(t.name),r=t.is_open?i.options.openedIcon:i.options.closedIcon,n('<li class="jqtree_common '+o+'"><div class="jqtree-element jqtree_common"><a class="jqtree_common '+u+'">'+r+'<\/a><span class="jqtree_common jqtree-title">'+f+"<\/span><\/div><\/li>")},f=function(n,t,i){var u,o,r,e,s;for(o=l(i),n.append(o),e=0,s=t.length;e<s;e++)r=t[e],u=h(r),o.append(u),r.element=u[0],u.data("node",r),r.hasChildren()&&f(u,r.children,!1,r.is_open);return null},t&&t.parent?(u=!1,o=this._getNodeElementForNode(t),o.getUl().remove(),r=o.$element):(t=this.tree,r=this.element,r.empty(),u=!0),f(r,t.children,u,u),this._triggerEvent("tree.refresh")},h.prototype._click=function(n){var t,r,i;if(t=this._getClickTarget(n.target),t){if(t.type==="button")return this.toggle(t.node,this.options.slide),n.preventDefault(),n.stopPropagation();if(t.type==="label"&&(i=t.node,r=this._triggerEvent("tree.click",{node:i}),!r.isDefaultPrevented()))return this._selectNode(i,!0)}},h.prototype._dblclick=function(n){var t;return t=this._getClickTarget(n.target),t&&t.type==="label"?this._triggerEvent("tree.dblclick",{node:t.node}):void 0},h.prototype._getClickTarget=function(t){var r,u,f,i;if(f=n(t),r=f.closest(".jqtree-toggler"),r.length){if(i=this._getNode(r),i)return{type:"button",node:i}}else if(u=f.closest(".jqtree-element"),u.length&&(i=this._getNode(u),i))return{type:"label",node:i};return null},h.prototype._getNode=function(n){var t;return t=n.closest("li"),t.length===0?null:t.data("node")},h.prototype._getNodeElementForNode=function(n){return n.isFolder()?new r(n,this):new p(n,this)},h.prototype._getNodeElement=function(n){var t;return t=this._getNode(n),t?this._getNodeElementForNode(t):null},h.prototype._contextmenu=function(t){var i,r;return i=n(t.target).closest("ul.jqtree-tree .jqtree-element"),i.length&&(r=this._getNode(i),r)?(t.preventDefault(),t.stopPropagation(),this._triggerEvent("tree.contextmenu",{node:r,click_event:t}),!1):void 0},h.prototype._saveState=function(){if(this.options.saveState)return this.save_state_handler.saveState()},h.prototype._mouseCapture=function(n){return this.options.dragAndDrop?this.dnd_handler.mouseCapture(n):!1},h.prototype._mouseStart=function(n){return this.options.dragAndDrop?this.dnd_handler.mouseStart(n):!1},h.prototype._mouseDrag=function(n){var t;return this.options.dragAndDrop?(t=this.dnd_handler.mouseDrag(n),this.scroll_handler&&this.scroll_handler.checkScrolling(),t):!1},h.prototype._mouseStop=function(n){return this.options.dragAndDrop?this.dnd_handler.mouseStop(n):!1},h.prototype._triggerEvent=function(t,i){var r;return r=n.Event(t),n.extend(r,i),this.element.trigger(r),r},h.prototype.testGenerateHitAreas=function(n){return this.dnd_handler.current_item=this._getNodeElementForNode(n),this.dnd_handler.generateHitAreas(),this.dnd_handler.hit_areas},h.prototype._selectCurrentNode=function(){var n,t;return n=this.getSelectedNode(),n&&(t=this._getNodeElementForNode(n),t)?t.select():void 0},h.prototype._deselectCurrentNode=function(){var n;return n=this.getSelectedNode(),n?this.removeFromSelection(n):void 0},h}(tt);s.register(nt,"tree");p=function(){function i(n,t){this.init(n,t)}return i.prototype.init=function(t,i){return this.node=t,this.tree_widget=i,this.$element=n(t.element)},i.prototype.getUl=function(){return this.$element.children("ul:first")},i.prototype.getSpan=function(){return this.$element.children(".jqtree-element").find("span.jqtree-title")},i.prototype.getLi=function(){return this.$element},i.prototype.addDropHint=function(n){return n===t.INSIDE?new a(this.$element):new v(this.node,this.$element,n)},i.prototype.select=function(){return this.getLi().addClass("jqtree-selected")},i.prototype.deselect=function(){return this.getLi().removeClass("jqtree-selected")},i}();r=function(n){function i(){return ot=i.__super__.constructor.apply(this,arguments)}return l(i,n),i.prototype.open=function(n,t){var i,r,u=this;return t==null&&(t=!0),this.node.is_open?void 0:(this.node.is_open=!0,i=this.getButton(),i.removeClass("jqtree-closed"),i.html(this.tree_widget.options.openedIcon),r=function(){return u.getLi().removeClass("jqtree-closed"),n&&n(),u.tree_widget._triggerEvent("tree.open",{node:u.node})},t?this.getUl().slideDown("fast",r):(this.getUl().show(),r()))},i.prototype.close=function(n){var t,i,r=this;return n==null&&(n=!0),this.node.is_open?(this.node.is_open=!1,t=this.getButton(),t.addClass("jqtree-closed"),t.html(this.tree_widget.options.closedIcon),i=function(){return r.getLi().addClass("jqtree-closed"),r.tree_widget._triggerEvent("tree.close",{node:r.node})},n?this.getUl().slideUp("fast",i):(this.getUl().hide(),i())):void 0},i.prototype.getButton=function(){return this.$element.children(".jqtree-element").find("a.jqtree-toggler")},i.prototype.addDropHint=function(n){return this.node.is_open||n!==t.INSIDE?new v(this.node,this.$element,n):new a(this.$element)},i}(p);rt=function(n){return(""+n).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};k=function(n,t){for(var u,r,i=r=0,f=n.length;r<f;i=++r)if(u=n[i],u===t)return i;return-1};w=function(n,t){return n.indexOf?n.indexOf(t):k(n,t)};this.Tree.indexOf=w;this.Tree._indexOf=k;this.JSON!=null&&this.JSON.stringify!=null&&typeof this.JSON.stringify=="function"||(h=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,ut={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},b=function(n){return h.lastIndex=0,h.test(n)?'"'+n.replace(h,function(n){var t;return t=ut[n],typeof t=="string"?t:"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+n+'"'},c=function(n,t){var u,f,r,e,i,o,s;i=t[n];switch(typeof i){case"string":return b(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(r=[],Object.prototype.toString.apply(i)==="[object Array]"){for(u=o=0,s=i.length;o<s;u=++o)e=i[u],r[u]=c(u,i)||"null";return r.length===0?"[]":"["+r.join(",")+"]"}for(f in i)Object.prototype.hasOwnProperty.call(i,f)&&(e=c(f,i),e&&r.push(b(f)+":"+e));return r.length===0?"{}":"{"+r.join(",")+"}"}},this.JSON==null&&(this.JSON={}),this.JSON.stringify=function(n){return c("",{"":n})});e=function(){function t(n){this.tree_widget=n}return t.prototype.saveState=function(){var t;return(t=JSON.stringify(this.getState()),this.tree_widget.options.onSetStateFromStorage)?this.tree_widget.options.onSetStateFromStorage(t):this.supportsLocalStorage()?localStorage.setItem(this.getCookieName(),t):n.cookie?(n.cookie.raw=!0,n.cookie(this.getCookieName(),t,{path:"/"})):void 0},t.prototype.restoreState=function(){var t;return t=this.getStateFromStorage(),t?(this.setState(n.parseJSON(t)),!0):!1},t.prototype.getStateFromStorage=function(){return this.tree_widget.options.onGetStateFromStorage?this.tree_widget.options.onGetStateFromStorage():this.supportsLocalStorage()?localStorage.getItem(this.getCookieName()):n.cookie?(n.cookie.raw=!0,n.cookie(this.getCookieName())):null},t.prototype.getState=function(){var n,t,i,r=this;return n=[],this.tree_widget.tree.iterate(function(t){return t.is_open&&t.id&&t.hasChildren()&&n.push(t.id),!0}),t=this.tree_widget.getSelectedNode(),i=t?t.id:"",{open_nodes:n,selected_node:i}},t.prototype.setState=function(n){var r,t,i,u=this;if(n&&(r=n.open_nodes,i=n.selected_node,this.tree_widget.tree.iterate(function(n){return n.is_open=n.id&&n.hasChildren()&&w(r,n.id)>=0,!0}),i&&this.tree_widget.select_node_handler&&(this.tree_widget.select_node_handler.clear(),t=this.tree_widget.getNodeById(i),t)))return this.tree_widget.select_node_handler.addToSelection(t)},t.prototype.getCookieName=function(){return typeof this.tree_widget.options.saveState=="string"?this.tree_widget.options.saveState:"tree"},t.prototype.supportsLocalStorage=function(){var n;return n=function(){var t,n;if(typeof localStorage=="undefined"||localStorage===null)return!1;try{n="_storage_test";sessionStorage.setItem(n,!0);sessionStorage.removeItem(n)}catch(i){return t=i,!1}return!0},this._supportsLocalStorage==null&&(this._supportsLocalStorage=n()),this._supportsLocalStorage},t.prototype.getNodeIdToBeSelected=function(){var i,t;return t=this.getStateFromStorage(),t?(i=n.parseJSON(t),i.selected_node):null},t}();i=function(){function n(n){this.tree_widget=n;this.clear()}return n.prototype.getSelectedNode=function(){var n;return n=this.getSelectedNodes(),n.length?n[0]:!1},n.prototype.getSelectedNodes=function(){var i,n,t;if(this.selected_single_node)return[this.selected_single_node];t=[];for(i in this.selected_nodes)n=this.tree_widget.getNodeById(i),n&&t.push(n);return t},n.prototype.isNodeSelected=function(n){return n.id?this.selected_nodes[n.id]:this.selected_single_node?this.selected_single_node.element===n.element:!1},n.prototype.clear=function(){return this.selected_nodes={},this.selected_single_node=null},n.prototype.removeFromSelection=function(n,t){var i=this;if(t==null&&(t=!1),n.id){if(delete this.selected_nodes[n.id],t)return n.iterate(function(){return delete i.selected_nodes[n.id],!0})}else if(n.element===this.selected_single_node.element)return this.selected_single_node=null},n.prototype.addToSelection=function(n){return n.id?this.selected_nodes[n.id]=!0:this.selected_single_node=n},n}();u=function(){function i(n){this.tree_widget=n;this.hovered_area=null;this.$ghost=null;this.hit_areas=[];this.is_dragging=!1}return i.prototype.mouseCapture=function(t){var r,i;return(r=n(t.target),this.tree_widget.options.onIsMoveHandle&&!this.tree_widget.options.onIsMoveHandle(r))?null:(i=this.tree_widget._getNodeElement(r),i&&this.tree_widget.options.onCanMove&&(this.tree_widget.options.onCanMove(i.node)||(i=null)),this.current_item=i,this.current_item!==null)},i.prototype.mouseStart=function(t){var i;return this.refreshHitAreas(),i=n(t.target).offset(),this.drag_element=new d(this.current_item.node,t.page_x-i.left,t.page_y-i.top,this.tree_widget.element),this.is_dragging=!0,this.current_item.$element.addClass("jqtree-moving"),!0},i.prototype.mouseDrag=function(n){var t,i;return this.drag_element.move(n.page_x,n.page_y),t=this.findHoveredArea(n.page_x,n.page_y),i=this.canMoveToArea(t),t?this.hovered_area!==t&&(this.hovered_area=t,this.mustOpenFolderTimer(t)&&this.startOpenFolderTimer(t.node),i&&this.updateDropHint()):(this.removeHover(),this.removeDropHint(),this.stopOpenFolderTimer()),!0},i.prototype.canMoveToArea=function(n){var i;if(n){if(this.tree_widget.options.onCanMoveTo){i=t.getName(n.position);return this.tree_widget.options.onCanMoveTo(this.current_item.node,n.node,i)}return!0}return!1},i.prototype.mouseStop=function(n){return this.moveItem(n),this.clear(),this.removeHover(),this.removeDropHint(),this.removeHitAreas(),this.current_item&&this.current_item.$element.removeClass("jqtree-moving"),this.is_dragging=!1,!1},i.prototype.refreshHitAreas=function(){return this.removeHitAreas(),this.generateHitAreas()},i.prototype.removeHitAreas=function(){return this.hit_areas=[]},i.prototype.clear=function(){return this.drag_element.remove(),this.drag_element=null},i.prototype.removeDropHint=function(){if(this.previous_ghost)return this.previous_ghost.remove()},i.prototype.removeHover=function(){return this.hovered_area=null},i.prototype.generateHitAreas=function(){var n;return n=new g(this.tree_widget.tree,this.current_item.node,this.getTreeDimensions().bottom),this.hit_areas=n.generate()},i.prototype.findHoveredArea=function(n,t){var r,i,u,f,e;if(i=this.getTreeDimensions(),n<i.left||t<i.top||n>i.right||t>i.bottom)return null;for(f=0,u=this.hit_areas.length;f<u;)if(e=f+u>>1,r=this.hit_areas[e],t<r.top)u=e;else if(t>r.bottom)f=e+1;else return r;return null},i.prototype.mustOpenFolderTimer=function(n){var i;return i=n.node,i.isFolder()&&!i.is_open&&n.position===t.INSIDE},i.prototype.updateDropHint=function(){var n;if(this.hovered_area)return this.removeDropHint(),n=this.tree_widget._getNodeElementForNode(this.hovered_area.node),this.previous_ghost=n.addDropHint(this.hovered_area.position)},i.prototype.startOpenFolderTimer=function(n){var i,t=this;return i=function(){return t.tree_widget._openNode(n,t.tree_widget.options.slide,function(){return t.refreshHitAreas(),t.updateDropHint()})},this.open_folder_timer=setTimeout(i,500)},i.prototype.stopOpenFolderTimer=function(){if(this.open_folder_timer)return clearTimeout(this.open_folder_timer),this.open_folder_timer=null},i.prototype.moveItem=function(n){var u,o,i,r,s,f,e=this;if(this.hovered_area&&this.hovered_area.position!==t.NONE&&this.canMoveToArea(this.hovered_area)&&(i=this.current_item.node,f=this.hovered_area.node,r=this.hovered_area.position,s=i.parent,r===t.INSIDE&&(this.hovered_area.node.is_open=!0),u=function(){return e.tree_widget.tree.moveNode(i,f,r),e.tree_widget.element.empty(),e.tree_widget._refreshElements()},o=this.tree_widget._triggerEvent("tree.move",{move_info:{moved_node:i,target_node:f,position:t.getName(r),previous_parent:s,do_move:u,original_event:n.original_event}}),!o.isDefaultPrevented()))return u()},i.prototype.getTreeDimensions=function(){var n;return n=this.tree_widget.element.offset(),{left:n.left,top:n.top,right:n.left+this.tree_widget.element.width(),bottom:n.top+this.tree_widget.element.height()+16}},i}();it=function(){function t(n){this.tree=n}return t.prototype.iterate=function(){var r,i,t=this;return r=!0,i=function(u,f){var e,v,l,o,s,h,a,c;if(s=(u.is_open||!u.element)&&u.hasChildren(),u.element){if(e=n(u.element),!e.is(":visible"))return;r&&(t.handleFirstNode(u,e),r=!1);u.hasChildren()?u.is_open?t.handleOpenFolder(u,e)||(s=!1):t.handleClosedFolder(u,f,e):t.handleNode(u,f,e)}if(s){for(l=u.children.length,c=u.children,o=h=0,a=c.length;h<a;o=++h)v=c[o],o===l-1?i(u.children[o],null):i(u.children[o],u.children[o+1]);if(u.is_open)return t.handleAfterOpenFolder(u,f,e)}},i(this.tree,null)},t.prototype.handleNode=function(){},t.prototype.handleOpenFolder=function(){},t.prototype.handleClosedFolder=function(){},t.prototype.handleAfterOpenFolder=function(){},t.prototype.handleFirstNode=function(){},t}();g=function(i){function r(n,t,i){r.__super__.constructor.call(this,n);this.current_node=t;this.tree_bottom=i}return l(r,i),r.prototype.generate=function(){return this.positions=[],this.last_top=0,this.iterate(),this.generateHitAreas(this.positions)},r.prototype.getTop=function(n){return n.offset().top},r.prototype.addPosition=function(n,t,i){return this.positions.push({top:i,node:n,position:t}),this.last_top=i},r.prototype.handleNode=function(n,i,r){var u;return u=this.getTop(r),n===this.current_node?this.addPosition(n,t.NONE,u):this.addPosition(n,t.INSIDE,u),i===this.current_node||n===this.current_node?this.addPosition(n,t.NONE,u):this.addPosition(n,t.AFTER,u)},r.prototype.handleOpenFolder=function(n,i){return n===this.current_node?!1:(n.children[0]!==this.current_node&&this.addPosition(n,t.INSIDE,this.getTop(i)),!0)},r.prototype.handleClosedFolder=function(n,i,r){var u;return(u=this.getTop(r),n===this.current_node)?this.addPosition(n,t.NONE,u):(this.addPosition(n,t.INSIDE,u),i!==this.current_node)?this.addPosition(n,t.AFTER,u):void 0},r.prototype.handleAfterOpenFolder=function(n,i){return n===this.current_node||i===this.current_node?this.addPosition(n,t.NONE,this.last_top):this.addPosition(n,t.AFTER,this.last_top)},r.prototype.handleFirstNode=function(i){if(i!==this.current_node)return this.addPosition(i,t.BEFORE,this.getTop(n(i.element)))},r.prototype.generateHitAreas=function(n){var t,u,i,r,f,e;for(r=-1,t=[],u=[],f=0,e=n.length;f<e;f++)i=n[f],i.top!==r&&t.length&&(t.length&&this.generateHitAreasForGroup(u,t,r,i.top),r=i.top,t=[]),t.push(i);return this.generateHitAreasForGroup(u,t,r,this.tree_bottom),u},r.prototype.generateHitAreasForGroup=function(n,t,i,r){var e,u,o,f,s;for(e=(r-i)/t.length,u=i,f=0,s=t.length;f<s;f++)o=t[f],n.push({top:u,bottom:u+e,node:o.node,position:o.position}),u+=e;return null},r}(it);d=function(){function t(t,i,r,u){this.offset_x=i;this.offset_y=r;this.$element=n('<span class="jqtree-title jqtree-dragging">'+t.name+"<\/span>");this.$element.css("position","absolute");u.append(this.$element)}return t.prototype.move=function(n,t){return this.$element.offset({left:n-this.offset_x,top:t-this.offset_y})},t.prototype.remove=function(){return this.$element.remove()},t}();v=function(){function i(i,r,u){this.$element=r;this.node=i;this.$ghost=n('<li class="jqtree_common jqtree-ghost"><span class="jqtree_common jqtree-circle"><\/span><span class="jqtree_common jqtree-line"><\/span><\/li>');u===t.AFTER?this.moveAfter():u===t.BEFORE?this.moveBefore():u===t.INSIDE&&(i.isFolder()&&i.is_open?this.moveInsideOpenFolder():this.moveInside())}return i.prototype.remove=function(){return this.$ghost.remove()},i.prototype.moveAfter=function(){return this.$element.after(this.$ghost)},i.prototype.moveBefore=function(){return this.$element.before(this.$ghost)},i.prototype.moveInsideOpenFolder=function(){return n(this.node.children[0].element).before(this.$ghost)},i.prototype.moveInside=function(){return this.$element.after(this.$ghost),this.$ghost.addClass("jqtree-inside")},i}();a=function(){function t(t){var i,r;i=t.children(".jqtree-element");r=t.width()-4;this.$hint=n('<span class="jqtree-border"><\/span>');i.append(this.$hint);this.$hint.css({width:r,height:i.height()-4})}return t.prototype.remove=function(){return this.$hint.remove()},t}();o=function(){function t(n){this.tree_widget=n;this.previous_top=-1;this._initScrollParent()}return t.prototype._initScrollParent=function(){var t,u,i,r=this;return u=function(){var o,u,f,l,t,i,s,h,e,c;for(u=["overflow","overflow-y"],l=null,e=r.tree_widget.$el.parents(),t=0,s=e.length;t<s;t++)for(f=e[t],i=0,h=u.length;i<h;i++)if(o=u[i],(c=n.css(f,o))==="auto"||c==="scroll")return n(f);return null},i=function(){return r.scroll_parent_top=0,r.$scroll_parent=null},this.tree_widget.$el.css("position")==="fixed"&&i(),t=u(),t&&t.length&&t[0].tagName!=="HTML"?(this.$scroll_parent=t,this.scroll_parent_top=this.$scroll_parent.offset().top):i()},t.prototype.checkScrolling=function(){var n;return n=this.tree_widget.dnd_handler.hovered_area,n&&n.top!==this.previous_top?(this.previous_top=n.top,this.$scroll_parent?this._handleScrollingWithScrollParent(n):this._handleScrollingWithDocument(n)):void 0},t.prototype._handleScrollingWithScrollParent=function(n){var t;return(t=this.scroll_parent_top+this.$scroll_parent[0].offsetHeight-n.bottom,t<20)?(this.$scroll_parent[0].scrollTop+=20,this.tree_widget.refreshHitAreas(),this.previous_top=-1):n.top-this.scroll_parent_top<20?(this.$scroll_parent[0].scrollTop-=20,this.tree_widget.refreshHitAreas(),this.previous_top=-1):void 0},t.prototype._handleScrollingWithDocument=function(t){var i;return(i=t.top-n(document).scrollTop(),i<20)?n(document).scrollTop(n(document).scrollTop()-20):n(window).height()-(t.bottom-n(document).scrollTop())<20?n(document).scrollTop(n(document).scrollTop()+20):void 0},t.prototype.scrollTo=function(t){var i;return this.$scroll_parent?this.$scroll_parent[0].scrollTop=t:(i=this.tree_widget.$el.offset().top,n(document).scrollTop(t+i))},t.prototype.isScrolledIntoView=function(t){var i,f,r,e,u;return i=n(t),this.$scroll_parent?(u=0,e=this.$scroll_parent.height(),r=i.offset().top-this.scroll_parent_top,f=r+i.height()):(u=n(window).scrollTop(),e=u+n(window).height(),r=i.offset().top,f=r+i.height()),f<=e&&r>=u},t}();f=function(){function t(t){this.tree_widget=t;t.options.keyboardSupport&&n(document).bind("keydown.jqtree",n.proxy(this.handleKeyDown,this))}var i,r,u,f;return r=37,f=38,u=39,i=40,t.prototype.deinit=function(){return n(document).unbind("keydown.jqtree")},t.prototype.handleKeyDown=function(t){var e,h,c,l,a,v,s,o=this;if(n(document.activeElement).is("textarea,input"))return!0;if(e=this.tree_widget.getSelectedNode(),s=function(t){return t?(o.tree_widget.selectNode(t),o.tree_widget.scroll_handler&&!o.tree_widget.scroll_handler.isScrolledIntoView(n(t.element).find(".jqtree-element"))&&o.tree_widget.scrollToNode(t),!1):!0},c=function(){return s(o.getNextNode(e))},v=function(){return s(o.getPreviousNode(e))},a=function(){return e.hasChildren()&&!e.is_open?(o.tree_widget.openNode(e),!1):!0},l=function(){return e.hasChildren()&&e.is_open?(o.tree_widget.closeNode(e),!1):!0},e){h=t.which;switch(h){case i:return c();case f:return v();case u:return a();case r:return l()}}else return!0},t.prototype.getNextNode=function(n,t){var i;return t==null&&(t=!0),t&&n.hasChildren()&&n.is_open?n.children[0]:n.parent?(i=n.getNextSibling(),i?i:this.getNextNode(n.parent,!1)):null},t.prototype.getPreviousNode=function(n){var t;return n.parent?(t=n.getPreviousSibling(),t?t.hasChildren()&&t.is_open?this.getLastChild(t):t:n.parent.parent?n.parent:null):null},t.prototype.getLastChild=function(n){var t;return n.hasChildren()?(t=n.children[n.children.length-1],t.hasChildren()&&t.is_open?this.getLastChild(t):t):null},t}()}).call(this)