text: /*
   * jQuery Cookie Plugin v1.1
   * https://github.com/carhartl/jquery-cookie
   *
   * Copyright 2011, Klaus Hartl
   * Dual licensed under the MIT or GPL Version 2 licenses.
   * http://www.opensource.org/licenses/mit-license.php
   * http://www.opensource.org/licenses/GPL-2.0
   */
  (function(e,b){var a=/\+/g;function d(f){return f}function c(f){return decodeURIComponent(f.replace(a," "))}e.cookie=function(k,j,o){if(arguments.length>1&&(!/Object/.test(Object.prototype.toString.call(j))||j==null)){o=e.extend({},e.cookie.defaults,o);if(j==null){o.expires=-1}if(typeof o.expires==="number"){var l=o.expires,n=o.expires=new Date();n.setDate(n.getDate()+l)}j=String(j);return(b.cookie=[encodeURIComponent(k),"=",o.raw?j:encodeURIComponent(j),o.expires?"; expires="+o.expires.toUTCString():"",o.path?"; path="+o.path:"",o.domain?"; domain="+o.domain:"",o.secure?"; secure":""].join(""))}o=j||e.cookie.defaults||{};var f=o.raw?d:c;var m=b.cookie.split("; ");for(var h=0,g;(g=m[h]&&m[h].split("="));h++){if(f(g.shift())===k){return f(g.join("="))}}return null};e.cookie.defaults={}})(jQuery,document);
  /*
   * jQuery hashchange event - v1.3 - 7/21/2010
   * http://benalman.com/projects/jquery-hashchange-plugin/
   * 
   * Copyright (c) 2010 "Cowboy" Ben Alman
   * Dual licensed under the MIT and GPL licenses.
   * http://benalman.com/about/license/
   */
  (function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this);(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof module!=="undefined"&&module.exports){module.exports=a(require("jquery"))}else{a(jQuery)}}}(function(i,e){
  /*
   * jsTree 3.2.1
   * http://jstree.com/
   *
   * Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
   *
   * Licensed same as jquery - under the terms of the MIT License
   *   http://www.opensource.org/licenses/mit-license.php
   */
  /*
   * if using jslint please allow for the jQuery global and use following options:
   * jslint: browser: true, ass: true, bitwise: true, continue: true, nomen: true, plusplus: true, regexp: true, unparam: true, todo: true, white: true
   */
  if(i.jstree){return}var c=0,d=false,l=false,j=false,n=[],a=i("script:last").attr("src"),o=window.document,q=o.createElement("LI"),g,f;q.setAttribute("role","treeitem");g=o.createElement("I");g.className="jstree-icon jstree-ocl";g.setAttribute("role","presentation");q.appendChild(g);g=o.createElement("A");g.className="jstree-anchor";g.setAttribute("href","#");g.setAttribute("tabindex","-1");f=o.createElement("I");f.className="jstree-icon jstree-themeicon";f.setAttribute("role","presentation");g.appendChild(f);q.appendChild(g);g=f=null;i.jstree={version:"3.2.1",defaults:{plugins:[]},plugins:{},path:a&&a.indexOf("/")!==-1?a.replace(/\/[^\/]+$/,""):"",idregex:/[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,root:"#"};i.jstree.create=function(u,r){var t=new i.jstree.core(++c),s=r;r=i.extend(true,{},i.jstree.defaults,r);if(s&&s.plugins){r.plugins=s.plugins}i.each(r.plugins,function(w,v){if(w!=="core"){t=t.plugin(v,r[v])}});i(u).data("jstree",t);t.init(u,r);return t};i.jstree.destroy=function(){i(".jstree:jstree").jstree("destroy");i(o).off(".jstree")};i.jstree.core=function(r){this._id=r;this._cnt=0;this._wrk=null;this._data={core:{themes:{name:false,dots:false,icons:false},selected:[],last_error:{},working:false,worker_queue:[],focused:null}}};i.jstree.reference=function(t){var r=null,s=null;if(t&&t.id&&(!t.tagName||!t.nodeType)){t=t.id}if(!s||!s.length){try{s=i(t)}catch(u){}}if(!s||!s.length){try{s=i("#"+t.replace(i.jstree.idregex,"\\$&"))}catch(u){}}if(s&&s.length&&(s=s.closest(".jstree")).length&&(s=s.data("jstree"))){r=s}else{i(".jstree").each(function(){var v=i(this).data("jstree");if(v&&v._model.data[t]){r=v;return false}})}return r};i.fn.jstree=function(s){var u=(typeof s==="string"),t=Array.prototype.slice.call(arguments,1),r=null;if(s===true&&!this.length){return false}this.each(function(){var v=i.jstree.reference(this),w=u&&v?v[s]:null;r=u&&w?w.apply(v,t):null;if(!v&&!u&&(s===e||i.isPlainObject(s))){i.jstree.create(this,s)}if((v&&!u)||s===true){r=v||false}if(r!==null&&r!==e){return false}});return r!==null&&r!==e?r:this};i.expr[":"].jstree=i.expr.createPseudo(function(r){return function(s){return i(s).hasClass("jstree")&&i(s).data("jstree")!==e}});i.jstree.defaults.core={data:false,strings:false,check_callback:false,error:i.noop,animation:200,multiple:true,themes:{name:false,url:false,dir:false,dots:true,icons:true,stripes:false,variant:false,responsive:false},expand_selected_onload:true,worker:true,force_text:false,dblclick_toggle:true};i.jstree.core.prototype={plugin:function(t,s){var r=i.jstree.plugins[t];if(r){this._data[t]={};r.prototype=this;return new r(s,this)}return this},init:function(s,r){this._model={data:{},changed:[],force_full_redraw:false,redraw_timeout:false,default_state:{loaded:true,opened:false,selected:false,disabled:false}};this._model.data[i.jstree.root]={id:i.jstree.root,parent:null,parents:[],children:[],children_d:[],state:{loaded:false}};this.element=i(s).addClass("jstree jstree-"+this._id);this.settings=r;this._data.core.ready=false;this._data.core.loaded=false;this._data.core.rtl=(this.element.css("direction")==="rtl");this.element[this._data.core.rtl?"addClass":"removeClass"]("jstree-rtl");this.element.attr("role","tree");if(this.settings.core.multiple){this.element.attr("aria-multiselectable",true)}if(!this.element.attr("tabindex")){this.element.attr("tabindex","0")}this.bind();this.trigger("init");this._data.core.original_container_html=this.element.find(" > ul > li").clone(true);this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return this.nodeType===3&&(!this.nodeValue||/^\s+$/.test(this.nodeValue))}).remove();this.element.html("<ul class='jstree-container-ul jstree-children' role='group'><li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='tree-item'><i class='jstree-icon jstree-ocl'></i><a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>"+this.get_string("Loading ...")+"</a></li></ul>");this.element.attr("aria-activedescendant","j"+this._id+"_loading");this._data.core.li_height=this.get_container_ul().children("li").first().height()||24;this.trigger("loading");this.load_node(i.jstree.root)},destroy:function(r){if(this._wrk){try{window.URL.revokeObjectURL(this._wrk);this._wrk=null}catch(s){}}if(!r){this.element.empty()}this.teardown()},teardown:function(){this.unbind();this.element.removeClass("jstree").removeData("jstree").find("[class^='jstree']").addBack().attr("class",function(){return this.className.replace(/jstree[^ ]*|$/ig,"")});this.element=null},bind:function(){var s="",r=null,t=0;this.element.on("dblclick.jstree",function(v){if(v.target.tagName&&v.target.tagName.toLowerCase()==="input"){return true}if(o.selection&&o.selection.empty){o.selection.empty()}else{if(window.getSelection){var u=window.getSelection();try{u.removeAllRanges();u.collapse()}catch(w){}}}}).on("mousedown.jstree",i.proxy(function(u){if(u.target===this.element[0]){u.preventDefault();t=+(new Date())}},this)).on("mousedown.jstree",".jstree-ocl",function(u){u.preventDefault()}).on("click.jstree",".jstree-ocl",i.proxy(function(u){this.toggle_node(u.target)},this)).on("dblclick.jstree",".jstree-anchor",i.proxy(function(u){if(u.target.tagName&&u.target.tagName.toLowerCase()==="input"){return true}if(this.settings.core.dblclick_toggle){this.toggle_node(u.target)}},this)).on("click.jstree",".jstree-anchor",i.proxy(function(u){u.preventDefault();if(u.currentTarget!==o.activeElement){i(u.currentTarget).focus()}this.activate_node(u.currentTarget,u)},this)).on("keydown.jstree",".jstree-anchor",i.proxy(function(u){if(u.target.tagName&&u.target.tagName.toLowerCase()==="input"){return true}if(u.which!==32&&u.which!==13&&(u.shiftKey||u.ctrlKey||u.altKey||u.metaKey)){return true}var v=null;if(this._data.core.rtl){if(u.which===37){u.which=39}else{if(u.which===39){u.which=37}}}switch(u.which){case 32:if(u.ctrlKey){u.type="click";i(u.currentTarget).trigger(u)}break;case 13:u.type="click";i(u.currentTarget).trigger(u);break;case 37:u.preventDefault();if(this.is_open(u.currentTarget)){this.close_node(u.currentTarget)}else{v=this.get_parent(u.currentTarget);if(v&&v.id!==i.jstree.root){this.get_node(v,true).children(".jstree-anchor").focus()}}break;case 38:u.preventDefault();v=this.get_prev_dom(u.currentTarget);if(v&&v.length){v.children(".jstree-anchor").focus()}break;case 39:u.preventDefault();if(this.is_closed(u.currentTarget)){this.open_node(u.currentTarget,function(w){this.get_node(w,true).children(".jstree-anchor").focus()})}else{if(this.is_open(u.currentTarget)){v=this.get_node(u.currentTarget,true).children(".jstree-children")[0];if(v){i(this._firstChild(v)).children(".jstree-anchor").focus()}}}break;case 40:u.preventDefault();v=this.get_next_dom(u.currentTarget);if(v&&v.length){v.children(".jstree-anchor").focus()}break;case 106:this.open_all();break;case 36:u.preventDefault();v=this._firstChild(this.get_container_ul()[0]);if(v){i(v).children(".jstree-anchor").filter(":visible").focus()}break;case 35:u.preventDefault();this.element.find(".jstree-anchor").filter(":visible").last().focus();break;
  /*
  							// delete
  							case 46:
  								e.preventDefault();
  								o = this.get_node(e.currentTarget);
  								if(o && o.id && o.id !== $.jstree.root) {
  									o = this.is_selected(o) ? this.get_selected() : o;
  									this.delete_node(o);
  								}
  								break;
  							// f2
  							case 113:
  								e.preventDefault();
  								o = this.get_node(e.currentTarget);
  								if(o && o.id && o.id !== $.jstree.root) {
  									// this.edit(o);
  								}
  								break;
  							default:
  								// console.log(e.which);
  								break;
  							*/
  }},this)).on("load_node.jstree",i.proxy(function(v,u){if(u.status){if(u.node.id===i.jstree.root&&!this._data.core.loaded){this._data.core.loaded=true;if(this._firstChild(this.get_container_ul()[0])){this.element.attr("aria-activedescendant",this._firstChild(this.get_container_ul()[0]).id)}this.trigger("loaded")}if(!this._data.core.ready){setTimeout(i.proxy(function(){if(this.element&&!this.get_container_ul().find(".jstree-loading").length){this._data.core.ready=true;if(this._data.core.selected.length){if(this.settings.core.expand_selected_onload){var y=[],x,w;for(x=0,w=this._data.core.selected.length;x<w;x++){y=y.concat(this._model.data[this._data.core.selected[x]].parents)}y=i.vakata.array_unique(y);for(x=0,w=y.length;x<w;x++){this.open_node(y[x],false,0)}}this.trigger("changed",{action:"ready",selected:this._data.core.selected})}this.trigger("ready")}},this),0)}}},this)).on("keypress.jstree",i.proxy(function(y){if(y.target.tagName&&y.target.tagName.toLowerCase()==="input"){return true}if(r){clearTimeout(r)}r=setTimeout(function(){s=""},500);var w=String.fromCharCode(y.which).toLowerCase(),v=this.element.find(".jstree-anchor").filter(":visible"),x=v.index(o.activeElement)||0,u=false;s+=w;if(s.length>1){v.slice(x).each(i.proxy(function(A,z){if(i(z).text().toLowerCase().indexOf(s)===0){i(z).focus();u=true;return false}},this));if(u){return}v.slice(0,x).each(i.proxy(function(A,z){if(i(z).text().toLowerCase().indexOf(s)===0){i(z).focus();u=true;return false}},this));if(u){return}}if(new RegExp("^"+w.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")+"+$").test(s)){v.slice(x+1).each(i.proxy(function(A,z){if(i(z).text().toLowerCase().charAt(0)===w){i(z).focus();u=true;return false}},this));if(u){return}v.slice(0,x+1).each(i.proxy(function(A,z){if(i(z).text().toLowerCase().charAt(0)===w){i(z).focus();u=true;return false}},this));if(u){return}}},this)).on("init.jstree",i.proxy(function(){var u=this.settings.core.themes;this._data.core.themes.dots=u.dots;this._data.core.themes.stripes=u.stripes;this._data.core.themes.icons=u.icons;this.set_theme(u.name||"default",u.url);this.set_theme_variant(u.variant)},this)).on("loading.jstree",i.proxy(function(){this[this._data.core.themes.dots?"show_dots":"hide_dots"]();this[this._data.core.themes.icons?"show_icons":"hide_icons"]();this[this._data.core.themes.stripes?"show_stripes":"hide_stripes"]()},this)).on("blur.jstree",".jstree-anchor",i.proxy(function(u){this._data.core.focused=null;i(u.currentTarget).filter(".jstree-hovered").mouseleave();this.element.attr("tabindex","0")},this)).on("focus.jstree",".jstree-anchor",i.proxy(function(v){var u=this.get_node(v.currentTarget);if(u&&u.id){this._data.core.focused=u.id}this.element.find(".jstree-hovered").not(v.currentTarget).mouseleave();i(v.currentTarget).mouseenter();this.element.attr("tabindex","-1")},this)).on("focus.jstree",i.proxy(function(){if(+(new Date())-t>500&&!this._data.core.focused){t=0;var u=this.get_node(this.element.attr("aria-activedescendant"),true);if(u){u.find("> .jstree-anchor").focus()}}},this)).on("mouseenter.jstree",".jstree-anchor",i.proxy(function(u){this.hover_node(u.currentTarget)},this)).on("mouseleave.jstree",".jstree-anchor",i.proxy(function(u){this.dehover_node(u.currentTarget)},this))},unbind:function(){this.element.off(".jstree");i(o).off(".jstree-"+this._id)},trigger:function(r,s){if(!s){s={}}s.instance=this;this.element.triggerHandler(r.replace(".jstree","")+".jstree",s)},get_container:function(){return this.element},get_container_ul:function(){return this.element.children(".jstree-children").first()},get_string:function(s){var r=this.settings.core.strings;if(i.isFunction(r)){return r.call(this,s)}if(r&&r[s]){return r[s]}return s},_firstChild:function(r){r=r?r.firstChild:null;while(r!==null&&r.nodeType!==1){r=r.nextSibling}return r},_nextSibling:function(r){r=r?r.nextSibling:null;while(r!==null&&r.nodeType!==1){r=r.nextSibling}return r},_previousSibling:function(r){r=r?r.previousSibling:null;while(r!==null&&r.nodeType!==1){r=r.previousSibling}return r},get_node:function(t,r){if(t&&t.id){t=t.id}var u;try{if(this._model.data[t]){t=this._model.data[t]}else{if(typeof t==="string"&&this._model.data[t.replace(/^#/,"")]){t=this._model.data[t.replace(/^#/,"")]}else{if(typeof t==="string"&&(u=i("#"+t.replace(i.jstree.idregex,"\\$&"),this.element)).length&&this._model.data[u.closest(".jstree-node").attr("id")]){t=this._model.data[u.closest(".jstree-node").attr("id")]}else{if((u=i(t,this.element)).length&&this._model.data[u.closest(".jstree-node").attr("id")]){t=this._model.data[u.closest(".jstree-node").attr("id")]}else{if((u=i(t,this.element)).length&&u.hasClass("jstree")){t=this._model.data[i.jstree.root]}else{return false}}}}}if(r){t=t.id===i.jstree.root?this.element:i("#"+t.id.replace(i.jstree.idregex,"\\$&"),this.element)}return t}catch(s){return false}},get_path:function(w,u,t){w=w.parents?w:this.get_node(w);if(!w||w.id===i.jstree.root||!w.parents){return false}var s,r,v=[];v.push(t?w.id:w.text);for(s=0,r=w.parents.length;s<r;s++){v.push(t?w.parents[s]:this.get_text(w.parents[s]))}v=v.reverse().slice(1);return u?v.join(u):v},get_next_dom:function(t,r){var s;t=this.get_node(t,true);if(t[0]===this.element[0]){s=this._firstChild(this.get_container_ul()[0]);while(s&&s.offsetHeight===0){s=this._nextSibling(s)}return s?i(s):false}if(!t||!t.length){return false}if(r){s=t[0];do{s=this._nextSibling(s)}while(s&&s.offsetHeight===0);return s?i(s):false}if(t.hasClass("jstree-open")){s=this._firstChild(t.children(".jstree-children")[0]);while(s&&s.offsetHeight===0){s=this._nextSibling(s)}if(s!==null){return i(s)}}s=t[0];do{s=this._nextSibling(s)}while(s&&s.offsetHeight===0);if(s!==null){return i(s)}return t.parentsUntil(".jstree",".jstree-node").nextAll(".jstree-node:visible").first()},get_prev_dom:function(t,r){var s;t=this.get_node(t,true);if(t[0]===this.element[0]){s=this.get_container_ul()[0].lastChild;while(s&&s.offsetHeight===0){s=this._previousSibling(s)}return s?i(s):false}if(!t||!t.length){return false}if(r){s=t[0];do{s=this._previousSibling(s)}while(s&&s.offsetHeight===0);return s?i(s):false}s=t[0];do{s=this._previousSibling(s)}while(s&&s.offsetHeight===0);if(s!==null){t=i(s);while(t.hasClass("jstree-open")){t=t.children(".jstree-children").first().children(".jstree-node:visible:last")}return t}s=t[0].parentNode.parentNode;return s&&s.className&&s.className.indexOf("jstree-node")!==-1?i(s):false},get_parent:function(r){r=this.get_node(r);if(!r||r.id===i.jstree.root){return false}return r.parent},get_children_dom:function(r){r=this.get_node(r,true);if(r[0]===this.element[0]){return this.get_container_ul().children(".jstree-node")}if(!r||!r.length){return false}return r.children(".jstree-children").children(".jstree-node")},is_parent:function(r){r=this.get_node(r);return r&&(r.state.loaded===false||r.children.length>0)},is_loaded:function(r){r=this.get_node(r);return r&&r.state.loaded},is_loading:function(r){r=this.get_node(r);return r&&r.state&&r.state.loading},is_open:function(r){r=this.get_node(r);return r&&r.state.opened},is_closed:function(r){r=this.get_node(r);return r&&this.is_parent(r)&&!r.state.opened},is_leaf:function(r){return !this.is_parent(r)},load_node:function(v,x){var s,r,u,t,w;if(i.isArray(v)){this._load_nodes(v.slice(),x);return true}v=this.get_node(v);if(!v){if(x){x.call(this,v,false)}return false}if(v.state.loaded){v.state.loaded=false;for(s=0,r=v.children_d.length;s<r;s++){for(u=0,t=v.parents.length;u<t;u++){this._model.data[v.parents[u]].children_d=i.vakata.array_remove_item(this._model.data[v.parents[u]].children_d,v.children_d[s])}if(this._model.data[v.children_d[s]].state.selected){w=true;this._data.core.selected=i.vakata.array_remove_item(this._data.core.selected,v.children_d[s])}delete this._model.data[v.children_d[s]]}v.children=[];v.children_d=[];if(w){this.trigger("changed",{action:"load_node",node:v,selected:this._data.core.selected})}}v.state.failed=false;v.state.loading=true;this.get_node(v,true).addClass("jstree-loading").attr("aria-busy",true);this._load_node(v,i.proxy(function(z){v=this._model.data[v.id];v.state.loading=false;v.state.loaded=z;v.state.failed=!v.state.loaded;var D=this.get_node(v,true),C=0,A=0,y=this._model.data,B=false;for(C=0,A=v.children.length;C<A;C++){if(y[v.children[C]]&&!y[v.children[C]].state.hidden){B=true;break}}if(v.state.loaded&&!B&&D&&D.length&&!D.hasClass("jstree-leaf")){D.removeClass("jstree-closed jstree-open").addClass("jstree-leaf")}D.removeClass("jstree-loading").attr("aria-busy",false);this.trigger("load_node",{node:v,status:z});if(x){x.call(this,v,z)}},this));return true},_load_nodes:function(t,A,z){var s=true,y=function(){this._load_nodes(t,A,true)},u=this._model.data,x,v,w=[];for(x=0,v=t.length;x<v;x++){if(u[t[x]]&&((!u[t[x]].state.loaded&&!u[t[x]].state.failed)||!z)){if(!this.is_loading(t[x])){this.load_node(t[x],y)}s=false}}if(s){for(x=0,v=t.length;x<v;x++){if(u[t[x]]&&u[t[x]].state.loaded){w.push(t[x])}}if(A&&!A.done){A.call(this,w);A.done=true}}},load_all:function(v,x){if(!v){v=i.jstree.root}v=this.get_node(v);if(!v){return false}var u=[],r=this._model.data,w=r[v.id].children_d,t,s;if(v.state&&!v.state.loaded){u.push(v.id)}for(t=0,s=w.length;t<s;t++){if(r[w[t]]&&r[w[t]].state&&!r[w[t]].state.loaded){u.push(w[t])}}if(u.length){this._load_nodes(u,function(){this.load_all(v,x)})}else{if(x){x.call(this,v)}this.trigger("load_all",{node:v})}},_load_node:function(v,w){var u=this.settings.core.data,r;if(!u){if(v.id===i.jstree.root){return this._append_html_data(v,this._data.core.original_container_html.clone(true),function(s){w.call(this,s)})}else{return w.call(this,false)}}if(i.isFunction(u)){return u.call(this,v,i.proxy(function(s){if(s===false){w.call(this,false)}this[typeof s==="string"?"_append_html_data":"_append_json_data"](v,typeof s==="string"?i(i.parseHTML(s)).filter(function(){return this.nodeType!==3}):s,function(t){w.call(this,t)})},this))}if(typeof u==="object"){if(u.url){u=i.extend(true,{},u);if(i.isFunction(u.url)){u.url=u.url.call(this,v)}if(i.isFunction(u.data)){u.data=u.data.call(this,v)}return i.ajax(u).done(i.proxy(function(A,y,s){var z=s.getResponseHeader("Content-Type");if((z&&z.indexOf("json")!==-1)||typeof A==="object"){return this._append_json_data(v,A,function(t){w.call(this,t)})}if((z&&z.indexOf("html")!==-1)||typeof A==="string"){return this._append_html_data(v,i(i.parseHTML(A)).filter(function(){return this.nodeType!==3}),function(t){w.call(this,t)})}this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:v.id,xhr:s})};this.settings.core.error.call(this,this._data.core.last_error);return w.call(this,false)},this)).fail(i.proxy(function(s){w.call(this,false);this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:v.id,xhr:s})};this.settings.core.error.call(this,this._data.core.last_error)},this))}r=(i.isArray(u)||i.isPlainObject(u))?JSON.parse(JSON.stringify(u)):u;if(v.id===i.jstree.root){return this._append_json_data(v,r,function(s){w.call(this,s)})}else{this._data.core.last_error={error:"nodata",plugin:"core",id:"core_05",reason:"Could not load node",data:JSON.stringify({id:v.id})};this.settings.core.error.call(this,this._data.core.last_error);return w.call(this,false)}}if(typeof u==="string"){if(v.id===i.jstree.root){return this._append_html_data(v,i(i.parseHTML(u)).filter(function(){return this.nodeType!==3}),function(s){w.call(this,s)})}else{this._data.core.last_error={error:"nodata",plugin:"core",id:"core_06",reason:"Could not load node",data:JSON.stringify({id:v.id})};this.settings.core.error.call(this,this._data.core.last_error);return w.call(this,false)}}return w.call(this,false)},_node_changed:function(r){r=this.get_node(r);if(r){this._model.changed.push(r.id)}},_append_html_data:function(w,z,u){w=this.get_node(w);w.children=[];w.children_d=[];var C=z.is("ul")?z.children():z,B=w.id,E=[],A=[],t=this._model.data,r=t[B],D=this._data.core.selected.length,y,x,v;C.each(i.proxy(function(F,s){y=this._parse_model_from_html(i(s),B,r.parents.concat());if(y){E.push(y);A.push(y);if(t[y].children_d.length){A=A.concat(t[y].children_d)}}},this));r.children=E;r.children_d=A;for(x=0,v=r.parents.length;x<v;x++){t[r.parents[x]].children_d=t[r.parents[x]].children_d.concat(A)}this.trigger("model",{nodes:A,parent:B});if(B!==i.jstree.root){this._node_changed(B);this.redraw()}else{this.get_container_ul().children(".jstree-initial-node").remove();this.redraw(true)}if(this._data.core.selected.length!==D){this.trigger("changed",{action:"model",selected:this._data.core.selected})}u.call(this,true)},_append_json_data:function(t,u,s,v){if(this.element===null){return}t=this.get_node(t);t.children=[];t.children_d=[];if(u.d){u=u.d;if(typeof u==="string"){u=JSON.parse(u)}}if(!i.isArray(u)){u=[u]}var A=null,y={df:this._model.default_state,dat:u,par:t.id,m:this._model.data,t_id:this._id,t_cnt:this._cnt,sel:this._data.core.selected},r=function(S,B){if(S.data){S=S.data}var N=S.dat,G=S.par,w=[],C=[],H=[],O=S.df,E=S.t_id,F=S.t_cnt,J=S.m,I=J[G],K=S.sel,Q,M,L,P,R=function(aa,U,T){if(!T){T=[]}else{T=T.concat()}if(U){T.unshift(U)}var V=aa.id.toString(),Y,W,ab,Z,X={id:V,text:aa.text||"",icon:aa.icon!==B?aa.icon:true,parent:U,parents:T,children:aa.children||[],children_d:aa.children_d||[],data:aa.data,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};for(Y in O){if(O.hasOwnProperty(Y)){X.state[Y]=O[Y]}}if(aa&&aa.data&&aa.data.jstree&&aa.data.jstree.icon){X.icon=aa.data.jstree.icon}if(X.icon===B||X.icon===null||X.icon===""){X.icon=true}if(aa&&aa.data){X.data=aa.data;if(aa.data.jstree){for(Y in aa.data.jstree){if(aa.data.jstree.hasOwnProperty(Y)){X.state[Y]=aa.data.jstree[Y]}}}}if(aa&&typeof aa.state==="object"){for(Y in aa.state){if(aa.state.hasOwnProperty(Y)){X.state[Y]=aa.state[Y]}}}if(aa&&typeof aa.li_attr==="object"){for(Y in aa.li_attr){if(aa.li_attr.hasOwnProperty(Y)){X.li_attr[Y]=aa.li_attr[Y]}}}if(!X.li_attr.id){X.li_attr.id=V}if(aa&&typeof aa.a_attr==="object"){for(Y in aa.a_attr){if(aa.a_attr.hasOwnProperty(Y)){X.a_attr[Y]=aa.a_attr[Y]}}}if(aa&&aa.children&&aa.children===true){X.state.loaded=false;X.children=[];X.children_d=[]}J[X.id]=X;for(Y=0,W=X.children.length;Y<W;Y++){ab=R(J[X.children[Y]],X.id,T);Z=J[ab];X.children_d.push(ab);if(Z.children_d.length){X.children_d=X.children_d.concat(Z.children_d)}}delete aa.data;delete aa.children;J[X.id].original=aa;if(X.state.selected){H.push(X.id)}return X.id},D=function(aa,U,T){if(!T){T=[]}else{T=T.concat()}if(U){T.unshift(U)}var V=false,Y,W,ab,Z,X;do{V="j"+E+"_"+(++F)}while(J[V]);X={id:false,text:typeof aa==="string"?aa:"",icon:typeof aa==="object"&&aa.icon!==B?aa.icon:true,parent:U,parents:T,children:[],children_d:[],data:null,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};for(Y in O){if(O.hasOwnProperty(Y)){X.state[Y]=O[Y]}}if(aa&&aa.id){X.id=aa.id.toString()}if(aa&&aa.text){X.text=aa.text}if(aa&&aa.data&&aa.data.jstree&&aa.data.jstree.icon){X.icon=aa.data.jstree.icon}if(X.icon===B||X.icon===null||X.icon===""){X.icon=true}if(aa&&aa.data){X.data=aa.data;if(aa.data.jstree){for(Y in aa.data.jstree){if(aa.data.jstree.hasOwnProperty(Y)){X.state[Y]=aa.data.jstree[Y]}}}}if(aa&&typeof aa.state==="object"){for(Y in aa.state){if(aa.state.hasOwnProperty(Y)){X.state[Y]=aa.state[Y]}}}if(aa&&typeof aa.li_attr==="object"){for(Y in aa.li_attr){if(aa.li_attr.hasOwnProperty(Y)){X.li_attr[Y]=aa.li_attr[Y]}}}if(X.li_attr.id&&!X.id){X.id=X.li_attr.id.toString()}if(!X.id){X.id=V}if(!X.li_attr.id){X.li_attr.id=X.id}if(aa&&typeof aa.a_attr==="object"){for(Y in aa.a_attr){if(aa.a_attr.hasOwnProperty(Y)){X.a_attr[Y]=aa.a_attr[Y]}}}if(aa&&aa.children&&aa.children.length){for(Y=0,W=aa.children.length;Y<W;Y++){ab=D(aa.children[Y],X.id,T);Z=J[ab];X.children.push(ab);if(Z.children_d.length){X.children_d=X.children_d.concat(Z.children_d)}}X.children_d=X.children_d.concat(X.children)}if(aa&&aa.children&&aa.children===true){X.state.loaded=false;X.children=[];X.children_d=[]}delete aa.data;delete aa.children;X.original=aa;J[X.id]=X;if(X.state.selected){H.push(X.id)}return X.id};if(N.length&&N[0].id!==B&&N[0].parent!==B){for(M=0,L=N.length;M<L;M++){if(!N[M].children){N[M].children=[]}J[N[M].id.toString()]=N[M]}for(M=0,L=N.length;M<L;M++){J[N[M].parent.toString()].children.push(N[M].id.toString());I.children_d.push(N[M].id.toString())}for(M=0,L=I.children.length;M<L;M++){Q=R(J[I.children[M]],G,I.parents.concat());C.push(Q);if(J[Q].children_d.length){C=C.concat(J[Q].children_d)}}for(M=0,L=I.parents.length;M<L;M++){J[I.parents[M]].children_d=J[I.parents[M]].children_d.concat(C)}P={cnt:F,mod:J,sel:K,par:G,dpc:C,add:H}}else{for(M=0,L=N.length;M<L;M++){Q=D(N[M],G,I.parents.concat());if(Q){w.push(Q);C.push(Q);if(J[Q].children_d.length){C=C.concat(J[Q].children_d)}}}I.children=w;I.children_d=C;for(M=0,L=I.parents.length;M<L;M++){J[I.parents[M]].children_d=J[I.parents[M]].children_d.concat(C)}P={cnt:F,mod:J,sel:K,par:G,dpc:C,add:H}}if(typeof window==="undefined"||typeof window.document==="undefined"){postMessage(P)}else{return P}},z=function(C,H){if(this.element===null){return}this._cnt=C.cnt;this._model.data=C.mod;if(H){var E,D,B=C.add,G=C.sel,F=this._data.core.selected.slice(),w=this._model.data;if(G.length!==F.length||i.vakata.array_unique(G.concat(F)).length!==G.length){for(E=0,D=G.length;E<D;E++){if(i.inArray(G[E],B)===-1&&i.inArray(G[E],F)===-1){w[G[E]].state.selected=false}}for(E=0,D=F.length;E<D;E++){if(i.inArray(F[E],G)===-1){w[F[E]].state.selected=true}}}}if(C.add.length){this._data.core.selected=this._data.core.selected.concat(C.add)}this.trigger("model",{nodes:C.dpc,parent:C.par});if(C.par!==i.jstree.root){this._node_changed(C.par);this.redraw()}else{this.redraw(true)}if(C.add.length){this.trigger("changed",{action:"model",selected:this._data.core.selected})}s.call(this,true)};if(this.settings.core.worker&&window.Blob&&window.URL&&window.Worker){try{if(this._wrk===null){this._wrk=window.URL.createObjectURL(new window.Blob(["self.onmessage = "+r.toString()],{type:"text/javascript"}))}if(!this._data.core.working||v){this._data.core.working=true;A=new window.Worker(this._wrk);A.onmessage=i.proxy(function(w){z.call(this,w.data,true);try{A.terminate();A=null}catch(B){}if(this._data.core.worker_queue.length){this._append_json_data.apply(this,this._data.core.worker_queue.shift())}else{this._data.core.working=false}},this);if(!y.par){if(this._data.core.worker_queue.length){this._append_json_data.apply(this,this._data.core.worker_queue.shift())}else{this._data.core.working=false}}else{A.postMessage(y)}}else{this._data.core.worker_queue.push([t,u,s,true])}}catch(x){z.call(this,r(y),false);if(this._data.core.worker_queue.length){this._append_json_data.apply(this,this._data.core.worker_queue.shift())}else{this._data.core.working=false}}}else{z.call(this,r(y),false)}},_parse_model_from_html:function(z,s,r){if(!r){r=[]}else{r=[].concat(r)}if(s){r.unshift(s)}var A,y,t=this._model.data,w={id:false,text:false,icon:true,parent:s,parents:r,children:[],children_d:[],data:null,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false},x,v,u;for(x in this._model.default_state){if(this._model.default_state.hasOwnProperty(x)){w.state[x]=this._model.default_state[x]}}v=i.vakata.attributes(z,true);i.each(v,function(C,B){B=i.trim(B);if(!B.length){return true}w.li_attr[C]=B;if(C==="id"){w.id=B.toString()}});v=z.children("a").first();if(v.length){v=i.vakata.attributes(v,true);i.each(v,function(C,B){B=i.trim(B);if(B.length){w.a_attr[C]=B}})}v=z.children("a").first().length?z.children("a").first().clone():z.clone();v.children("ins, i, ul").remove();v=v.html();v=i("<div />").html(v);w.text=this.settings.core.force_text?v.text():v.html();v=z.data();w.data=v?i.extend(true,{},v):null;w.state.opened=z.hasClass("jstree-open");w.state.selected=z.children("a").hasClass("jstree-clicked");w.state.disabled=z.children("a").hasClass("jstree-disabled");if(w.data&&w.data.jstree){for(x in w.data.jstree){if(w.data.jstree.hasOwnProperty(x)){w.state[x]=w.data.jstree[x]}}}v=z.children("a").children(".jstree-themeicon");if(v.length){w.icon=v.hasClass("jstree-themeicon-hidden")?false:v.attr("rel")}if(w.state.icon!==e){w.icon=w.state.icon}if(w.icon===e||w.icon===null||w.icon===""){w.icon=true}v=z.children("ul").children("li");do{u="j"+this._id+"_"+(++this._cnt)}while(t[u]);w.id=w.li_attr.id?w.li_attr.id.toString():u;if(v.length){v.each(i.proxy(function(C,B){A=this._parse_model_from_html(i(B),w.id,r);y=this._model.data[A];w.children.push(A);if(y.children_d.length){w.children_d=w.children_d.concat(y.children_d)}},this));w.children_d=w.children_d.concat(w.children)}else{if(z.hasClass("jstree-closed")){w.state.loaded=false}}if(w.li_attr["class"]){w.li_attr["class"]=w.li_attr["class"].replace("jstree-closed","").replace("jstree-open","")}if(w.a_attr["class"]){w.a_attr["class"]=w.a_attr["class"].replace("jstree-clicked","").replace("jstree-disabled","")}t[w.id]=w;if(w.state.selected){this._data.core.selected.push(w.id)}return w.id},_parse_model_from_flat_json:function(z,s,r){if(!r){r=[]}else{r=r.concat()}if(s){r.unshift(s)}var u=z.id.toString(),t=this._model.data,B=this._model.default_state,x,v,A,y,w={id:u,text:z.text||"",icon:z.icon!==e?z.icon:true,parent:s,parents:r,children:z.children||[],children_d:z.children_d||[],data:z.data,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};for(x in B){if(B.hasOwnProperty(x)){w.state[x]=B[x]}}if(z&&z.data&&z.data.jstree&&z.data.jstree.icon){w.icon=z.data.jstree.icon}if(w.icon===e||w.icon===null||w.icon===""){w.icon=true}if(z&&z.data){w.data=z.data;if(z.data.jstree){for(x in z.data.jstree){if(z.data.jstree.hasOwnProperty(x)){w.state[x]=z.data.jstree[x]}}}}if(z&&typeof z.state==="object"){for(x in z.state){if(z.state.hasOwnProperty(x)){w.state[x]=z.state[x]}}}if(z&&typeof z.li_attr==="object"){for(x in z.li_attr){if(z.li_attr.hasOwnProperty(x)){w.li_attr[x]=z.li_attr[x]}}}if(!w.li_attr.id){w.li_attr.id=u}if(z&&typeof z.a_attr==="object"){for(x in z.a_attr){if(z.a_attr.hasOwnProperty(x)){w.a_attr[x]=z.a_attr[x]}}}if(z&&z.children&&z.children===true){w.state.loaded=false;w.children=[];w.children_d=[]}t[w.id]=w;for(x=0,v=w.children.length;x<v;x++){A=this._parse_model_from_flat_json(t[w.children[x]],w.id,r);y=t[A];w.children_d.push(A);if(y.children_d.length){w.children_d=w.children_d.concat(y.children_d)}}delete z.data;delete z.children;t[w.id].original=z;if(w.state.selected){this._data.core.selected.push(w.id)}return w.id},_parse_model_from_json:function(z,s,r){if(!r){r=[]}else{r=r.concat()}if(s){r.unshift(s)}var u=false,x,v,A,y,t=this._model.data,B=this._model.default_state,w;do{u="j"+this._id+"_"+(++this._cnt)}while(t[u]);w={id:false,text:typeof z==="string"?z:"",icon:typeof z==="object"&&z.icon!==e?z.icon:true,parent:s,parents:r,children:[],children_d:[],data:null,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};for(x in B){if(B.hasOwnProperty(x)){w.state[x]=B[x]}}if(z&&z.id){w.id=z.id.toString()}if(z&&z.text){w.text=z.text}if(z&&z.data&&z.data.jstree&&z.data.jstree.icon){w.icon=z.data.jstree.icon}if(w.icon===e||w.icon===null||w.icon===""){w.icon=true}if(z&&z.data){w.data=z.data;if(z.data.jstree){for(x in z.data.jstree){if(z.data.jstree.hasOwnProperty(x)){w.state[x]=z.data.jstree[x]}}}}if(z&&typeof z.state==="object"){for(x in z.state){if(z.state.hasOwnProperty(x)){w.state[x]=z.state[x]}}}if(z&&typeof z.li_attr==="object"){for(x in z.li_attr){if(z.li_attr.hasOwnProperty(x)){w.li_attr[x]=z.li_attr[x]}}}if(w.li_attr.id&&!w.id){w.id=w.li_attr.id.toString()}if(!w.id){w.id=u}if(!w.li_attr.id){w.li_attr.id=w.id}if(z&&typeof z.a_attr==="object"){for(x in z.a_attr){if(z.a_attr.hasOwnProperty(x)){w.a_attr[x]=z.a_attr[x]}}}if(z&&z.children&&z.children.length){for(x=0,v=z.children.length;x<v;x++){A=this._parse_model_from_json(z.children[x],w.id,r);y=t[A];w.children.push(A);if(y.children_d.length){w.children_d=w.children_d.concat(y.children_d)}}w.children_d=w.children_d.concat(w.children)}if(z&&z.children&&z.children===true){w.state.loaded=false;w.children=[];w.children_d=[]}delete z.data;delete z.children;w.original=z;t[w.id]=w;if(w.state.selected){this._data.core.selected.push(w.id)}return w.id},_redraw:function(){var r=this._model.force_full_redraw?this._model.data[i.jstree.root].children.concat([]):this._model.changed.concat([]),w=o.createElement("UL"),v,u,t,s=this._data.core.focused;for(u=0,t=r.length;u<t;u++){v=this.redraw_node(r[u],true,this._model.force_full_redraw);if(v&&this._model.force_full_redraw){w.appendChild(v)}}if(this._model.force_full_redraw){w.className=this.get_container_ul()[0].className;w.setAttribute("role","group");this.element.empty().append(w)}if(s!==null){v=this.get_node(s,true);if(v&&v.length&&v.children(".jstree-anchor")[0]!==o.activeElement){v.children(".jstree-anchor").focus()}else{this._data.core.focused=null}}this._model.force_full_redraw=false;this._model.changed=[];this.trigger("redraw",{nodes:r})},redraw:function(r){if(r){this._model.force_full_redraw=true}this._redraw()},draw_children:function(u){var v=this.get_node(u),t=false,s=false,r=false,w=o;if(!v){return false}if(v.id===i.jstree.root){return this.redraw(true)}u=this.get_node(u,true);if(!u||!u.length){return false}u.children(".jstree-children").remove();u=u[0];if(v.children.length&&v.state.loaded){r=w.createElement("UL");r.setAttribute("role","group");r.className="jstree-children";for(t=0,s=v.children.length;t<s;t++){r.appendChild(this.redraw_node(v.children[t],true,true))}u.appendChild(r)}},redraw_node:function(C,H,u,K){var x=this.get_node(C),B=false,w=false,r=false,I=false,G=false,F=false,M="",L=o,D=this._model.data,J=false,A=false,N=null,y=0,E=0,z=false,v=false;if(!x){return false}if(x.id===i.jstree.root){return this.redraw(true)}H=H||x.children.length===0;C=!o.querySelector?o.getElementById(x.id):this.element[0].querySelector("#"+("0123456789".indexOf(x.id[0])!==-1?"\\3"+x.id[0]+" "+x.id.substr(1).replace(i.jstree.idregex,"\\$&"):x.id.replace(i.jstree.idregex,"\\$&")));if(!C){H=true;if(!u){B=x.parent!==i.jstree.root?i("#"+x.parent.replace(i.jstree.idregex,"\\$&"),this.element)[0]:null;if(B!==null&&(!B||!D[x.parent].state.opened)){return false}w=i.inArray(x.id,B===null?D[i.jstree.root].children:D[x.parent].children)}}else{C=i(C);if(!u){B=C.parent().parent()[0];if(B===this.element[0]){B=null}w=C.index()}if(!H&&x.children.length&&!C.children(".jstree-children").length){H=true}if(!H){r=C.children(".jstree-children")[0]}J=C.children(".jstree-anchor")[0]===o.activeElement;C.remove()}C=q.cloneNode(true);M="jstree-node ";for(I in x.li_attr){if(x.li_attr.hasOwnProperty(I)){if(I==="id"){continue}if(I!=="class"){C.setAttribute(I,x.li_attr[I])}else{M+=x.li_attr[I]}}}if(!x.a_attr.id){x.a_attr.id=x.id+"_anchor"}C.setAttribute("aria-selected",!!x.state.selected);C.setAttribute("aria-level",x.parents.length);C.setAttribute("aria-labelledby",x.a_attr.id);if(x.state.disabled){C.setAttribute("aria-disabled",true)}for(I=0,G=x.children.length;I<G;I++){if(!D[x.children[I]].state.hidden){z=true;break}}if(x.parent!==null&&D[x.parent]&&!x.state.hidden){I=i.inArray(x.id,D[x.parent].children);v=x.id;if(I!==-1){I++;for(G=D[x.parent].children.length;I<G;I++){if(!D[D[x.parent].children[I]].state.hidden){v=D[x.parent].children[I]}if(v!==x.id){break}}}}if(x.state.hidden){M+=" jstree-hidden"}if(x.state.loaded&&!z){M+=" jstree-leaf"}else{M+=x.state.opened&&x.state.loaded?" jstree-open":" jstree-closed";C.setAttribute("aria-expanded",(x.state.opened&&x.state.loaded))}if(v===x.id){M+=" jstree-last"}C.id=x.id;C.className=M;M=(x.state.selected?" jstree-clicked":"")+(x.state.disabled?" jstree-disabled":"");for(G in x.a_attr){if(x.a_attr.hasOwnProperty(G)){if(G==="href"&&x.a_attr[G]==="#"){continue}if(G!=="class"){C.childNodes[1].setAttribute(G,x.a_attr[G])}else{M+=" "+x.a_attr[G]}}}if(M.length){C.childNodes[1].className="jstree-anchor "+M}if((x.icon&&x.icon!==true)||x.icon===false){if(x.icon===false){C.childNodes[1].childNodes[0].className+=" jstree-themeicon-hidden"}else{if(x.icon.indexOf("/")===-1&&x.icon.indexOf(".")===-1){C.childNodes[1].childNodes[0].className+=" "+x.icon+" jstree-themeicon-custom"}else{C.childNodes[1].childNodes[0].style.backgroundImage="url("+x.icon+")";C.childNodes[1].childNodes[0].style.backgroundPosition="center center";C.childNodes[1].childNodes[0].style.backgroundSize="auto";C.childNodes[1].childNodes[0].className+=" jstree-themeicon-custom"}}}if(this.settings.core.force_text){C.childNodes[1].appendChild(L.createTextNode(x.text))}else{C.childNodes[1].innerHTML+=x.text}if(H&&x.children.length&&(x.state.opened||K)&&x.state.loaded){F=L.createElement("UL");F.setAttribute("role","group");F.className="jstree-children";for(I=0,G=x.children.length;I<G;I++){F.appendChild(this.redraw_node(x.children[I],H,true))}C.appendChild(F)}if(r){C.appendChild(r)}if(!u){if(!B){B=this.element[0]}for(I=0,G=B.childNodes.length;I<G;I++){if(B.childNodes[I]&&B.childNodes[I].className&&B.childNodes[I].className.indexOf("jstree-children")!==-1){N=B.childNodes[I];break}}if(!N){N=L.createElement("UL");N.setAttribute("role","group");N.className="jstree-children";B.appendChild(N)}B=N;if(w<B.childNodes.length){B.insertBefore(C,B.childNodes[w])}else{B.appendChild(C)}if(J){y=this.element[0].scrollTop;E=this.element[0].scrollLeft;C.childNodes[1].focus();this.element[0].scrollTop=y;this.element[0].scrollLeft=E}}if(x.state.opened&&!x.state.loaded){x.state.opened=false;setTimeout(i.proxy(function(){this.open_node(x.id,false,0)},this),0)}return C},open_node:function(w,y,v){var u,s,x,r;if(i.isArray(w)){w=w.slice();for(u=0,s=w.length;u<s;u++){this.open_node(w[u],y,v)}return true}w=this.get_node(w);if(!w||w.id===i.jstree.root){return false}v=v===e?this.settings.core.animation:v;if(!this.is_closed(w)){if(y){y.call(this,w,false)}return false}if(!this.is_loaded(w)){if(this.is_loading(w)){return setTimeout(i.proxy(function(){this.open_node(w,y,v)},this),500)}this.load_node(w,function(z,t){return t?this.open_node(z,y,v):(y?y.call(this,z,false):false)})}else{x=this.get_node(w,true);r=this;if(x.length){if(v&&x.children(".jstree-children").length){x.children(".jstree-children").stop(true,true)}if(w.children.length&&!this._firstChild(x.children(".jstree-children")[0])){this.draw_children(w)}if(!v){this.trigger("before_open",{node:w});x[0].className=x[0].className.replace("jstree-closed","jstree-open");x[0].setAttribute("aria-expanded",true)}else{this.trigger("before_open",{node:w});x.children(".jstree-children").css("display","none").end().removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded",true).children(".jstree-children").stop(true,true).slideDown(v,function(){this.style.display="";r.trigger("after_open",{node:w})})}}w.state.opened=true;if(y){y.call(this,w,true)}if(!x.length){this.trigger("before_open",{node:w})}this.trigger("open_node",{node:w});if(!v||!x.length){this.trigger("after_open",{node:w})}return true}},_open_to:function(u){u=this.get_node(u);if(!u||u.id===i.jstree.root){return false}var s,r,t=u.parents;for(s=0,r=t.length;s<r;s+=1){if(s!==i.jstree.root){this.open_node(t[s],false,0)}}return i("#"+u.id.replace(i.jstree.idregex,"\\$&"),this.element)},close_node:function(w,v){var u,s,r,x;if(i.isArray(w)){w=w.slice();for(u=0,s=w.length;u<s;u++){this.close_node(w[u],v)}return true}w=this.get_node(w);if(!w||w.id===i.jstree.root){return false}if(this.is_closed(w)){return false}v=v===e?this.settings.core.animation:v;r=this;x=this.get_node(w,true);if(x.length){if(!v){x[0].className=x[0].className.replace("jstree-open","jstree-closed");x.attr("aria-expanded",false).children(".jstree-children").remove()}else{x.children(".jstree-children").attr("style","display:block !important").end().removeClass("jstree-open").addClass("jstree-closed").attr("aria-expanded",false).children(".jstree-children").stop(true,true).slideUp(v,function(){this.style.display="";x.children(".jstree-children").remove();r.trigger("after_close",{node:w})})}}w.state.opened=false;this.trigger("close_node",{node:w});if(!v||!x.length){this.trigger("after_close",{node:w})}},toggle_node:function(t){var s,r;if(i.isArray(t)){t=t.slice();for(s=0,r=t.length;s<r;s++){this.toggle_node(t[s])}return true}if(this.is_closed(t)){return this.open_node(t)}if(this.is_open(t)){return this.close_node(t)}},open_all:function(v,u,r){if(!v){v=i.jstree.root}v=this.get_node(v);if(!v){return false}var w=v.id===i.jstree.root?this.get_container_ul():this.get_node(v,true),t,s,x;if(!w.length){for(t=0,s=v.children_d.length;t<s;t++){if(this.is_closed(this._model.data[v.children_d[t]])){this._model.data[v.children_d[t]].state.opened=true}}return this.trigger("open_all",{node:v})}r=r||w;x=this;w=this.is_closed(v)?w.find(".jstree-closed").addBack():w.find(".jstree-closed");w.each(function(){x.open_node(this,function(z,y){if(y&&this.is_parent(z)){this.open_all(z,u,r)}},u||0)});if(r.find(".jstree-closed").length===0){this.trigger("open_all",{node:this.get_node(r)})}},close_all:function(u,t){if(!u){u=i.jstree.root}u=this.get_node(u);if(!u){return false}var v=u.id===i.jstree.root?this.get_container_ul():this.get_node(u,true),w=this,s,r;if(v.length){v=this.is_open(u)?v.find(".jstree-open").addBack():v.find(".jstree-open");i(v.get().reverse()).each(function(){w.close_node(this,t||0)})}for(s=0,r=u.children_d.length;s<r;s++){this._model.data[u.children_d[s]].state.opened=false}this.trigger("close_all",{node:u})},is_disabled:function(r){r=this.get_node(r);return r&&r.state&&r.state.disabled},enable_node:function(t){var s,r;if(i.isArray(t)){t=t.slice();for(s=0,r=t.length;s<r;s++){this.enable_node(t[s])}return true}t=this.get_node(t);if(!t||t.id===i.jstree.root){return false}t.state.disabled=false;this.get_node(t,true).children(".jstree-anchor").removeClass("jstree-disabled").attr("aria-disabled",false);this.trigger("enable_node",{node:t})},disable_node:function(t){var s,r;if(i.isArray(t)){t=t.slice();for(s=0,r=t.length;s<r;s++){this.disable_node(t[s])}return true}t=this.get_node(t);if(!t||t.id===i.jstree.root){return false}t.state.disabled=true;this.get_node(t,true).children(".jstree-anchor").addClass("jstree-disabled").attr("aria-disabled",true);this.trigger("disable_node",{node:t})},hide_node:function(u,t){var s,r;if(i.isArray(u)){u=u.slice();for(s=0,r=u.length;s<r;s++){this.hide_node(u[s],true)}this.redraw();return true}u=this.get_node(u);if(!u||u.id===i.jstree.root){return false}if(!u.state.hidden){u.state.hidden=true;this._node_changed(u.parent);if(!t){this.redraw()}this.trigger("hide_node",{node:u})}},show_node:function(u,t){var s,r;if(i.isArray(u)){u=u.slice();for(s=0,r=u.length;s<r;s++){this.show_node(u[s],true)}this.redraw();return true}u=this.get_node(u);if(!u||u.id===i.jstree.root){return false}if(u.state.hidden){u.state.hidden=false;this._node_changed(u.parent);if(!t){this.redraw()}this.trigger("show_node",{node:u})}},hide_all:function(u){var s,r=this._model.data,t=[];for(s in r){if(r.hasOwnProperty(s)&&s!==i.jstree.root&&!r[s].state.hidden){r[s].state.hidden=true;t.push(s)}}this._model.force_full_redraw=true;if(!u){this.redraw()}this.trigger("hide_all",{nodes:t});return t},show_all:function(u){var s,r=this._model.data,t=[];for(s in r){if(r.hasOwnProperty(s)&&s!==i.jstree.root&&r[s].state.hidden){r[s].state.hidden=false;t.push(s)}}this._model.force_full_redraw=true;if(!u){this.redraw()}this.trigger("show_all",{nodes:t});return t},activate_node:function(w,v){if(this.is_disabled(w)){return false}if(!v||typeof v!=="object"){v={}}this._data.core.last_clicked=this._data.core.last_clicked&&this._data.core.last_clicked.id!==e?this.get_node(this._data.core.last_clicked.id):null;if(this._data.core.last_clicked&&!this._data.core.last_clicked.state.selected){this._data.core.last_clicked=null}if(!this._data.core.last_clicked&&this._data.core.selected.length){this._data.core.last_clicked=this.get_node(this._data.core.selected[this._data.core.selected.length-1])}if(!this.settings.core.multiple||(!v.metaKey&&!v.ctrlKey&&!v.shiftKey)||(v.shiftKey&&(!this._data.core.last_clicked||!this.get_parent(w)||this.get_parent(w)!==this._data.core.last_clicked.parent))){if(!this.settings.core.multiple&&(v.metaKey||v.ctrlKey||v.shiftKey)&&this.is_selected(w)){this.deselect_node(w,false,v)}else{this.deselect_all(true);this.select_node(w,false,false,v);this._data.core.last_clicked=this.get_node(w)}}else{if(v.shiftKey){var x=this.get_node(w).id,r=this._data.core.last_clicked.id,u=this.get_node(this._data.core.last_clicked.parent).children,y=false,t,s;for(t=0,s=u.length;t<s;t+=1){if(u[t]===x){y=!y}if(u[t]===r){y=!y}if(!this.is_disabled(u[t])&&(y||u[t]===x||u[t]===r)){this.select_node(u[t],true,false,v)}else{this.deselect_node(u[t],true,v)}}this.trigger("changed",{action:"select_node",node:this.get_node(w),selected:this._data.core.selected,event:v})}else{if(!this.is_selected(w)){this.select_node(w,false,false,v)}else{this.deselect_node(w,false,v)}}}this.trigger("activate_node",{node:this.get_node(w),event:v})},hover_node:function(s){s=this.get_node(s,true);if(!s||!s.length||s.children(".jstree-hovered").length){return false}var u=this.element.find(".jstree-hovered"),r=this.element;if(u&&u.length){this.dehover_node(u)}s.children(".jstree-anchor").addClass("jstree-hovered");this.trigger("hover_node",{node:this.get_node(s)});setTimeout(function(){r.attr("aria-activedescendant",s[0].id)},0)},dehover_node:function(r){r=this.get_node(r,true);if(!r||!r.length||!r.children(".jstree-hovered").length){return false}r.children(".jstree-anchor").removeClass("jstree-hovered");this.trigger("dehover_node",{node:this.get_node(r)})},select_node:function(w,y,r,v){var x,u,s,t;if(i.isArray(w)){w=w.slice();for(u=0,s=w.length;u<s;u++){this.select_node(w[u],y,r,v)}return true}w=this.get_node(w);if(!w||w.id===i.jstree.root){return false}x=this.get_node(w,true);if(!w.state.selected){w.state.selected=true;this._data.core.selected.push(w.id);if(!r){x=this._open_to(w)}if(x&&x.length){x.attr("aria-selected",true).children(".jstree-anchor").addClass("jstree-clicked")}this.trigger("select_node",{node:w,selected:this._data.core.selected,event:v});if(!y){this.trigger("changed",{action:"select_node",node:w,selected:this._data.core.selected,event:v})}}},deselect_node:function(u,w,t){var s,r,v;if(i.isArray(u)){u=u.slice();for(s=0,r=u.length;s<r;s++){this.deselect_node(u[s],w,t)}return true}u=this.get_node(u);if(!u||u.id===i.jstree.root){return false}v=this.get_node(u,true);if(u.state.selected){u.state.selected=false;this._data.core.selected=i.vakata.array_remove_item(this._data.core.selected,u.id);if(v.length){v.attr("aria-selected",false).children(".jstree-anchor").removeClass("jstree-clicked")}this.trigger("deselect_node",{node:u,selected:this._data.core.selected,event:t});if(!w){this.trigger("changed",{action:"deselect_node",node:u,selected:this._data.core.selected,event:t})}}},select_all:function(u){var t=this._data.core.selected.concat([]),s,r;this._data.core.selected=this._model.data[i.jstree.root].children_d.concat();for(s=0,r=this._data.core.selected.length;s<r;s++){if(this._model.data[this._data.core.selected[s]]){this._model.data[this._data.core.selected[s]].state.selected=true}}this.redraw(true);this.trigger("select_all",{selected:this._data.core.selected});if(!u){this.trigger("changed",{action:"select_all",selected:this._data.core.selected,old_selection:t})}},deselect_all:function(u){var t=this._data.core.selected.concat([]),s,r;for(s=0,r=this._data.core.selected.length;s<r;s++){if(this._model.data[this._data.core.selected[s]]){this._model.data[this._data.core.selected[s]].state.selected=false}}this._data.core.selected=[];this.element.find(".jstree-clicked").removeClass("jstree-clicked").parent().attr("aria-selected",false);this.trigger("deselect_all",{selected:this._data.core.selected,node:t});if(!u){this.trigger("changed",{action:"deselect_all",selected:this._data.core.selected,old_selection:t})}},is_selected:function(r){r=this.get_node(r);if(!r||r.id===i.jstree.root){return false}return r.state.selected},get_selected:function(r){return r?i.map(this._data.core.selected,i.proxy(function(s){return this.get_node(s)},this)):this._data.core.selected.slice()},get_top_selected:function(w){var v=this.get_selected(true),x={},u,t,s,r;for(u=0,t=v.length;u<t;u++){x[v[u].id]=v[u]}for(u=0,t=v.length;u<t;u++){for(s=0,r=v[u].children_d.length;s<r;s++){if(x[v[u].children_d[s]]){delete x[v[u].children_d[s]]}}}v=[];for(u in x){if(x.hasOwnProperty(u)){v.push(u)}}return w?i.map(v,i.proxy(function(y){return this.get_node(y)},this)):v},get_bottom_selected:function(u){var t=this.get_selected(true),v=[],s,r;for(s=0,r=t.length;s<r;s++){if(!t[s].children.length){v.push(t[s].id)}}return u?i.map(v,i.proxy(function(w){return this.get_node(w)},this)):v},get_state:function(){var s={core:{open:[],scroll:{left:this.element.scrollLeft(),top:this.element.scrollTop()},
  /*
  					'themes' : {
  						'name' : this.get_theme(),
  						'icons' : this._data.core.themes.icons,
  						'dots' : this._data.core.themes.dots
  					},
  					*/
  selected:[]}},r;for(r in this._model.data){if(this._model.data.hasOwnProperty(r)){if(r!==i.jstree.root){if(this._model.data[r].state.opened){s.core.open.push(r)}if(this._model.data[r].state.selected){s.core.selected.push(r)}}}}return s},set_state:function(v,y){if(v){if(v.core){var u,x,s,w,r;if(v.core.open){if(!i.isArray(v.core.open)||!v.core.open.length){delete v.core.open;this.set_state(v,y)}else{this._load_nodes(v.core.open,function(t){this.open_node(t,false,0);delete v.core.open;this.set_state(v,y)},true)}return false}if(v.core.scroll){if(v.core.scroll&&v.core.scroll.left!==e){this.element.scrollLeft(v.core.scroll.left)}if(v.core.scroll&&v.core.scroll.top!==e){this.element.scrollTop(v.core.scroll.top)}delete v.core.scroll;this.set_state(v,y);return false}if(v.core.selected){w=this;this.deselect_all();i.each(v.core.selected,function(z,t){w.select_node(t,false,true)});delete v.core.selected;this.set_state(v,y);return false}for(r in v){if(v.hasOwnProperty(r)&&r!=="core"&&i.inArray(r,this.settings.plugins)===-1){delete v[r]}}if(i.isEmptyObject(v.core)){delete v.core;this.set_state(v,y);return false}}if(i.isEmptyObject(v)){v=null;if(y){y.call(this)}this.trigger("set_state");return false}return true}return false},refresh:function(s,r){this._data.core.state=r===true?{}:this.get_state();if(r&&i.isFunction(r)){this._data.core.state=r.call(this,this._data.core.state)}this._cnt=0;this._model.data={};this._model.data[i.jstree.root]={id:i.jstree.root,parent:null,parents:[],children:[],children_d:[],state:{loaded:false}};this._data.core.selected=[];this._data.core.last_clicked=null;this._data.core.focused=null;var t=this.get_container_ul()[0].className;if(!s){this.element.html("<ul class='"+t+"' role='group'><li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='treeitem' id='j"+this._id+"_loading'><i class='jstree-icon jstree-ocl'></i><a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>"+this.get_string("Loading ...")+"</a></li></ul>");this.element.attr("aria-activedescendant","j"+this._id+"_loading")}this.load_node(i.jstree.root,function(v,u){if(u){this.get_container_ul()[0].className=t;if(this._firstChild(this.get_container_ul()[0])){this.element.attr("aria-activedescendant",this._firstChild(this.get_container_ul()[0]).id)}this.set_state(i.extend(true,{},this._data.core.state),function(){this.trigger("refresh")})}this._data.core.state=null})},refresh_node:function(u){u=this.get_node(u);if(!u||u.id===i.jstree.root){return false}var v=[],r=[],t=this._data.core.selected.concat([]);r.push(u.id);if(u.state.opened===true){v.push(u.id)}this.get_node(u,true).find(".jstree-open").each(function(){v.push(this.id)});this._load_nodes(r,i.proxy(function(s){this.open_node(v,false,0);this.select_node(this._data.core.selected);this.trigger("refresh_node",{node:u,nodes:s})},this))},set_id:function(u,v){u=this.get_node(u);if(!u||u.id===i.jstree.root){return false}var t,s,r=this._model.data;v=v.toString();r[u.parent].children[i.inArray(u.id,r[u.parent].children)]=v;for(t=0,s=u.parents.length;t<s;t++){r[u.parents[t]].children_d[i.inArray(u.id,r[u.parents[t]].children_d)]=v}for(t=0,s=u.children.length;t<s;t++){r[u.children[t]].parent=v}for(t=0,s=u.children_d.length;t<s;t++){r[u.children_d[t]].parents[i.inArray(u.id,r[u.children_d[t]].parents)]=v}t=i.inArray(u.id,this._data.core.selected);if(t!==-1){this._data.core.selected[t]=v}t=this.get_node(u.id,true);if(t){t.attr("id",v).children(".jstree-anchor").attr("id",v+"_anchor").end().attr("aria-labelledby",v+"_anchor");if(this.element.attr("aria-activedescendant")===u.id){this.element.attr("aria-activedescendant",v)}}delete r[u.id];u.id=v;u.li_attr.id=v;r[v]=u;return true},get_text:function(r){r=this.get_node(r);return(!r||r.id===i.jstree.root)?false:r.text},set_text:function(t,u){var s,r;if(i.isArray(t)){t=t.slice();for(s=0,r=t.length;s<r;s++){this.set_text(t[s],u)}return true}t=this.get_node(t);if(!t||t.id===i.jstree.root){return false}t.text=u;if(this.get_node(t,true).length){this.redraw_node(t.id)}this.trigger("set_text",{obj:t,text:u});return true},get_json:function(v,s,w){v=this.get_node(v||i.jstree.root);if(!v){return false}if(s&&s.flat&&!w){w=[]}var u={id:v.id,text:v.text,icon:this.get_icon(v),li_attr:i.extend(true,{},v.li_attr),a_attr:i.extend(true,{},v.a_attr),state:{},data:s&&s.no_data?false:i.extend(true,{},v.data)},t,r;if(s&&s.flat){u.parent=v.parent}else{u.children=[]}if(!s||!s.no_state){for(t in v.state){if(v.state.hasOwnProperty(t)){u.state[t]=v.state[t]}}}if(s&&s.no_id){delete u.id;if(u.li_attr&&u.li_attr.id){delete u.li_attr.id}if(u.a_attr&&u.a_attr.id){delete u.a_attr.id}}if(s&&s.flat&&v.id!==i.jstree.root){w.push(u)}if(!s||!s.no_children){for(t=0,r=v.children.length;t<r;t++){if(s&&s.flat){this.get_json(v.children[t],s,w)}else{u.children.push(this.get_json(v.children[t],s))}}}return s&&s.flat?w:(v.id===i.jstree.root?u.children:u)},create_node:function(w,r,y,z,x){if(w===null){w=i.jstree.root}w=this.get_node(w);if(!w){return false}y=y===e?"last":y;if(!y.toString().match(/^(before|after)$/)&&!x&&!this.is_loaded(w)){return this.load_node(w,function(){this.create_node(w,r,y,z,true)})}if(!r){r={text:this.get_string("New node")}}if(typeof r==="string"){r={text:r}}if(r.text===e){r.text=this.get_string("New node")}var t,v,u,s;if(w.id===i.jstree.root){if(y==="before"){y="first"}if(y==="after"){y="last"}}switch(y){case"before":t=this.get_node(w.parent);y=i.inArray(w.id,t.children);w=t;break;case"after":t=this.get_node(w.parent);y=i.inArray(w.id,t.children)+1;w=t;break;case"inside":case"first":y=0;break;case"last":y=w.children.length;break;default:if(!y){y=0}break}if(y>w.children.length){y=w.children.length}if(!r.id){r.id=true}if(!this.check("create_node",r,w,y)){this.settings.core.error.call(this,this._data.core.last_error);return false}if(r.id===true){delete r.id}r=this._parse_model_from_json(r,w.id,w.parents.concat());if(!r){return false}t=this.get_node(r);v=[];v.push(r);v=v.concat(t.children_d);this.trigger("model",{nodes:v,parent:w.id});w.children_d=w.children_d.concat(v);for(u=0,s=w.parents.length;u<s;u++){this._model.data[w.parents[u]].children_d=this._model.data[w.parents[u]].children_d.concat(v)}r=t;t=[];for(u=0,s=w.children.length;u<s;u++){t[u>=y?u+1:u]=w.children[u]}t[y]=r.id;w.children=t;this.redraw_node(w,true);if(z){z.call(this,this.get_node(r))}this.trigger("create_node",{node:this.get_node(r),parent:w.id,position:y});return r.id},rename_node:function(u,v){var t,s,r;if(i.isArray(u)){u=u.slice();for(t=0,s=u.length;t<s;t++){this.rename_node(u[t],v)}return true}u=this.get_node(u);if(!u||u.id===i.jstree.root){return false}r=u.text;if(!this.check("rename_node",u,this.get_parent(u),v)){this.settings.core.error.call(this,this._data.core.last_error);return false}this.set_text(u,v);this.trigger("rename_node",{node:u,text:v,old:r});return true},delete_node:function(u){var y,x,z,C,v,w,t,s,r,A,B,D;if(i.isArray(u)){u=u.slice();for(y=0,x=u.length;y<x;y++){this.delete_node(u[y])}return true}u=this.get_node(u);if(!u||u.id===i.jstree.root){return false}z=this.get_node(u.parent);C=i.inArray(u.id,z.children);A=false;if(!this.check("delete_node",u,z,C)){this.settings.core.error.call(this,this._data.core.last_error);return false}if(C!==-1){z.children=i.vakata.array_remove(z.children,C)}v=u.children_d.concat([]);v.push(u.id);for(s=0,r=v.length;s<r;s++){for(w=0,t=u.parents.length;w<t;w++){C=i.inArray(v[s],this._model.data[u.parents[w]].children_d);if(C!==-1){this._model.data[u.parents[w]].children_d=i.vakata.array_remove(this._model.data[u.parents[w]].children_d,C)}}if(this._model.data[v[s]].state.selected){A=true;C=i.inArray(v[s],this._data.core.selected);if(C!==-1){this._data.core.selected=i.vakata.array_remove(this._data.core.selected,C)}}}this.trigger("delete_node",{node:u,parent:z.id});if(A){this.trigger("changed",{action:"delete_node",node:u,selected:this._data.core.selected,parent:z.id})}for(s=0,r=v.length;s<r;s++){delete this._model.data[v[s]]}if(i.inArray(this._data.core.focused,v)!==-1){this._data.core.focused=null;B=this.element[0].scrollTop;D=this.element[0].scrollLeft;if(z.id===i.jstree.root){this.get_node(this._model.data[i.jstree.root].children[0],true).children(".jstree-anchor").focus()}else{this.get_node(z,true).children(".jstree-anchor").focus()}this.element[0].scrollTop=B;this.element[0].scrollLeft=D}this.redraw_node(z,true);return true},check:function(r,v,u,x,t){v=v&&v.id?v:this.get_node(v);u=u&&u.id?u:this.get_node(u);var s=r.match(/^move_node|copy_node|create_node$/i)?u:v,w=this.settings.core.check_callback;if(r==="move_node"||r==="copy_node"){if((!t||!t.is_multi)&&(v.id===u.id||i.inArray(v.id,u.children)===x||i.inArray(u.id,v.children_d)!==-1)){this._data.core.last_error={error:"check",plugin:"core",id:"core_01",reason:"Moving parent inside child",data:JSON.stringify({chk:r,pos:x,obj:v&&v.id?v.id:false,par:u&&u.id?u.id:false})};return false}}if(s&&s.data){s=s.data}if(s&&s.functions&&(s.functions[r]===false||s.functions[r]===true)){if(s.functions[r]===false){this._data.core.last_error={error:"check",plugin:"core",id:"core_02",reason:"Node data prevents function: "+r,data:JSON.stringify({chk:r,pos:x,obj:v&&v.id?v.id:false,par:u&&u.id?u.id:false})}}return s.functions[r]}if(w===false||(i.isFunction(w)&&w.call(this,r,v,u,x,t)===false)||(w&&w[r]===false)){this._data.core.last_error={error:"check",plugin:"core",id:"core_03",reason:"User config for core.check_callback prevents function: "+r,data:JSON.stringify({chk:r,pos:x,obj:v&&v.id?v.id:false,par:u&&u.id?u.id:false})};return false}return true},last_error:function(){return this._data.core.last_error},move_node:function(z,B,u,s,A,H,K){var x,w,y,r,J,L,t,v,I,G,F,E,D,C;B=this.get_node(B);u=u===e?0:u;if(!B){return false}if(!u.toString().match(/^(before|after)$/)&&!A&&!this.is_loaded(B)){return this.load_node(B,function(){this.move_node(z,B,u,s,true,false,K)})}if(i.isArray(z)){if(z.length===1){z=z[0]}else{for(x=0,w=z.length;x<w;x++){if((I=this.move_node(z[x],B,u,s,A,false,K))){B=I;u="after"}}this.redraw();return true}}z=z&&z.id?z:this.get_node(z);if(!z||z.id===i.jstree.root){return false}y=(z.parent||i.jstree.root).toString();J=(!u.toString().match(/^(before|after)$/)||B.id===i.jstree.root)?B:this.get_node(B.parent);L=K?K:(this._model.data[z.id]?this:i.jstree.reference(z.id));t=!L||!L._id||(this._id!==L._id);r=L&&L._id&&y&&L._model.data[y]&&L._model.data[y].children?i.inArray(z.id,L._model.data[y].children):-1;if(L&&L._id){z=L._model.data[z.id]}if(t){if((I=this.copy_node(z,B,u,s,A,false,K))){if(L){L.delete_node(z)}return I}return false}if(B.id===i.jstree.root){if(u==="before"){u="first"}if(u==="after"){u="last"}}switch(u){case"before":u=i.inArray(B.id,J.children);break;case"after":u=i.inArray(B.id,J.children)+1;break;case"inside":case"first":u=0;break;case"last":u=J.children.length;break;default:if(!u){u=0}break}if(u>J.children.length){u=J.children.length}if(!this.check("move_node",z,J,u,{core:true,origin:K,is_multi:(L&&L._id&&L._id!==this._id),is_foreign:(!L||!L._id)})){this.settings.core.error.call(this,this._data.core.last_error);return false}if(z.parent===J.id){v=J.children.concat();I=i.inArray(z.id,v);if(I!==-1){v=i.vakata.array_remove(v,I);if(u>I){u--}}I=[];for(G=0,F=v.length;G<F;G++){I[G>=u?G+1:G]=v[G]}I[u]=z.id;J.children=I;this._node_changed(J.id);this.redraw(J.id===i.jstree.root)}else{I=z.children_d.concat();I.push(z.id);for(G=0,F=z.parents.length;G<F;G++){v=[];C=L._model.data[z.parents[G]].children_d;for(E=0,D=C.length;E<D;E++){if(i.inArray(C[E],I)===-1){v.push(C[E])}}L._model.data[z.parents[G]].children_d=v}L._model.data[y].children=i.vakata.array_remove_item(L._model.data[y].children,z.id);for(G=0,F=J.parents.length;G<F;G++){this._model.data[J.parents[G]].children_d=this._model.data[J.parents[G]].children_d.concat(I)}v=[];for(G=0,F=J.children.length;G<F;G++){v[G>=u?G+1:G]=J.children[G]}v[u]=z.id;J.children=v;J.children_d.push(z.id);J.children_d=J.children_d.concat(z.children_d);z.parent=J.id;I=J.parents.concat();I.unshift(J.id);C=z.parents.length;z.parents=I;I=I.concat();for(G=0,F=z.children_d.length;G<F;G++){this._model.data[z.children_d[G]].parents=this._model.data[z.children_d[G]].parents.slice(0,C*-1);Array.prototype.push.apply(this._model.data[z.children_d[G]].parents,I)}if(y===i.jstree.root||J.id===i.jstree.root){this._model.force_full_redraw=true}if(!this._model.force_full_redraw){this._node_changed(y);this._node_changed(J.id)}if(!H){this.redraw()}}if(s){s.call(this,z,J,u)}this.trigger("move_node",{node:z,parent:J.id,position:u,old_parent:y,old_position:r,is_multi:(L&&L._id&&L._id!==this._id),is_foreign:(!L||!L._id),old_instance:L,new_instance:this});return z.id},copy_node:function(y,A,t,s,z,E,H){var w,v,u,F,D,C,B,x,G,I,r;A=this.get_node(A);t=t===e?0:t;if(!A){return false}if(!t.toString().match(/^(before|after)$/)&&!z&&!this.is_loaded(A)){return this.load_node(A,function(){this.copy_node(y,A,t,s,true,false,H)})}if(i.isArray(y)){if(y.length===1){y=y[0]}else{for(w=0,v=y.length;w<v;w++){if((F=this.copy_node(y[w],A,t,s,z,true,H))){A=F;t="after"}}this.redraw();return true}}y=y&&y.id?y:this.get_node(y);if(!y||y.id===i.jstree.root){return false}x=(y.parent||i.jstree.root).toString();G=(!t.toString().match(/^(before|after)$/)||A.id===i.jstree.root)?A:this.get_node(A.parent);I=H?H:(this._model.data[y.id]?this:i.jstree.reference(y.id));r=!I||!I._id||(this._id!==I._id);if(I&&I._id){y=I._model.data[y.id]}if(A.id===i.jstree.root){if(t==="before"){t="first"}if(t==="after"){t="last"}}switch(t){case"before":t=i.inArray(A.id,G.children);break;case"after":t=i.inArray(A.id,G.children)+1;break;case"inside":case"first":t=0;break;case"last":t=G.children.length;break;default:if(!t){t=0}break}if(t>G.children.length){t=G.children.length}if(!this.check("copy_node",y,G,t,{core:true,origin:H,is_multi:(I&&I._id&&I._id!==this._id),is_foreign:(!I||!I._id)})){this.settings.core.error.call(this,this._data.core.last_error);return false}B=I?I.get_json(y,{no_id:true,no_data:true,no_state:true}):y;if(!B){return false}if(B.id===true){delete B.id}B=this._parse_model_from_json(B,G.id,G.parents.concat());if(!B){return false}F=this.get_node(B);if(y&&y.state&&y.state.loaded===false){F.state.loaded=false}u=[];u.push(B);u=u.concat(F.children_d);this.trigger("model",{nodes:u,parent:G.id});for(D=0,C=G.parents.length;D<C;D++){this._model.data[G.parents[D]].children_d=this._model.data[G.parents[D]].children_d.concat(u)}u=[];for(D=0,C=G.children.length;D<C;D++){u[D>=t?D+1:D]=G.children[D]}u[t]=F.id;G.children=u;G.children_d.push(F.id);G.children_d=G.children_d.concat(F.children_d);if(G.id===i.jstree.root){this._model.force_full_redraw=true}if(!this._model.force_full_redraw){this._node_changed(G.id)}if(!E){this.redraw(G.id===i.jstree.root)}if(s){s.call(this,F,G,t)}this.trigger("copy_node",{node:F,original:y,parent:G.id,position:t,old_parent:x,old_position:I&&I._id&&x&&I._model.data[x]&&I._model.data[x].children?i.inArray(y.id,I._model.data[x].children):-1,is_multi:(I&&I._id&&I._id!==this._id),is_foreign:(!I||!I._id),old_instance:I,new_instance:this});return F.id},cut:function(u){if(!u){u=this._data.core.selected.concat()}if(!i.isArray(u)){u=[u]}if(!u.length){return false}var r=[],v,t,s;for(t=0,s=u.length;t<s;t++){v=this.get_node(u[t]);if(v&&v.id&&v.id!==i.jstree.root){r.push(v)}}if(!r.length){return false}d=r;j=this;l="move_node";this.trigger("cut",{node:u})},copy:function(u){if(!u){u=this._data.core.selected.concat()}if(!i.isArray(u)){u=[u]}if(!u.length){return false}var r=[],v,t,s;for(t=0,s=u.length;t<s;t++){v=this.get_node(u[t]);if(v&&v.id&&v.id!==i.jstree.root){r.push(v)}}if(!r.length){return false}d=r;j=this;l="copy_node";this.trigger("copy",{node:u})},get_buffer:function(){return{mode:l,node:d,inst:j}},can_paste:function(){return l!==false&&d!==false},paste:function(r,s){r=this.get_node(r);if(!r||!l||!l.match(/^(copy_node|move_node)$/)||!d){return false}if(this[l](d,r,s,false,false,false,j)){this.trigger("paste",{parent:r.id,node:d,mode:l})}d=false;l=false;j=false},clear_buffer:function(){d=false;l=false;j=false;this.trigger("clear_buffer")},edit:function(u,A,D){var z,C,B,G,F,x,v,y,r,E=false;u=this.get_node(u);if(!u){return false}if(this.settings.core.check_callback===false){this._data.core.last_error={error:"check",plugin:"core",id:"core_07",reason:"Could not edit node because of check_callback"};this.settings.core.error.call(this,this._data.core.last_error);return false}r=u;A=typeof A==="string"?A:u.text;this.set_text(u,"");u=this._open_to(u);r.text=A;z=this._data.core.rtl;C=this.element.width();this._data.core.focused=r.id;B=u.children(".jstree-anchor").focus();G=i("<span>");
  /*
  			oi = obj.children("i:visible"),
  			ai = a.children("i:visible"),
  			w1 = oi.width() * oi.length,
  			w2 = ai.width() * ai.length,
  			*/
  F=A;x=i("<div />",{css:{position:"absolute",top:"-200px",left:(z?"0px":"-1000px"),visibility:"hidden"}}).appendTo("body");v=i("<input />",{value:F,"class":"jstree-rename-input",css:{padding:"0",border:"1px solid silver","box-sizing":"border-box",display:"inline-block",height:(this._data.core.li_height)+"px",lineHeight:(this._data.core.li_height)+"px",width:"150px"},blur:i.proxy(function(I){I.stopImmediatePropagation();I.preventDefault();var w=G.children(".jstree-rename-input"),t=w.val(),H=this.settings.core.force_text,s;if(t===""){t=F}x.remove();G.replaceWith(B);G.remove();F=H?F:i("<div></div>").append(i.parseHTML(F)).html();this.set_text(u,F);s=!!this.rename_node(u,H?i("<div></div>").text(t).text():i("<div></div>").append(i.parseHTML(t)).html());if(!s){this.set_text(u,F)}this._data.core.focused=r.id;setTimeout(i.proxy(function(){var J=this.get_node(r.id,true);if(J.length){this._data.core.focused=r.id;J.children(".jstree-anchor").focus()}},this),0);if(D){D.call(this,r,s,E)}},this),keydown:function(t){var s=t.which;if(s===27){E=true;this.value=F}if(s===27||s===13||s===37||s===38||s===39||s===40||s===32){t.stopImmediatePropagation()}if(s===27||s===13){t.preventDefault();this.blur()}},click:function(s){s.stopImmediatePropagation()},mousedown:function(s){s.stopImmediatePropagation()},keyup:function(s){v.width(Math.min(x.text("pW"+this.value).width(),C))},keypress:function(s){if(s.which===13){return false}}});y={fontFamily:B.css("fontFamily")||"",fontSize:B.css("fontSize")||"",fontWeight:B.css("fontWeight")||"",fontStyle:B.css("fontStyle")||"",fontStretch:B.css("fontStretch")||"",fontVariant:B.css("fontVariant")||"",letterSpacing:B.css("letterSpacing")||"",wordSpacing:B.css("wordSpacing")||""};G.attr("class",B.attr("class")).append(B.contents().clone()).append(v);B.replaceWith(G);x.css(y);v.css(y).width(Math.min(x.text("pW"+v[0].value).width(),C))[0].select()},set_theme:function(t,r){if(!t){return false}if(r===true){var s=this.settings.core.themes.dir;if(!s){s=i.jstree.path+"/themes"}r=s+"/"+t+"/style.css"}if(r&&i.inArray(r,n)===-1){i("head").append('<link rel="stylesheet" href="'+r+'" type="text/css" />');n.push(r)}if(this._data.core.themes.name){this.element.removeClass("jstree-"+this._data.core.themes.name)}this._data.core.themes.name=t;this.element.addClass("jstree-"+t);this.element[this.settings.core.themes.responsive?"addClass":"removeClass"]("jstree-"+t+"-responsive");this.trigger("set_theme",{theme:t})},get_theme:function(){return this._data.core.themes.name},set_theme_variant:function(r){if(this._data.core.themes.variant){this.element.removeClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant)}this._data.core.themes.variant=r;if(r){this.element.addClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant)}},get_theme_variant:function(){return this._data.core.themes.variant},show_stripes:function(){this._data.core.themes.stripes=true;this.get_container_ul().addClass("jstree-striped")},hide_stripes:function(){this._data.core.themes.stripes=false;this.get_container_ul().removeClass("jstree-striped")},toggle_stripes:function(){if(this._data.core.themes.stripes){this.hide_stripes()}else{this.show_stripes()}},show_dots:function(){this._data.core.themes.dots=true;this.get_container_ul().removeClass("jstree-no-dots")},hide_dots:function(){this._data.core.themes.dots=false;this.get_container_ul().addClass("jstree-no-dots")},toggle_dots:function(){if(this._data.core.themes.dots){this.hide_dots()}else{this.show_dots()}},show_icons:function(){this._data.core.themes.icons=true;this.get_container_ul().removeClass("jstree-no-icons")},hide_icons:function(){this._data.core.themes.icons=false;this.get_container_ul().addClass("jstree-no-icons")},toggle_icons:function(){if(this._data.core.themes.icons){this.hide_icons()}else{this.show_icons()}},set_icon:function(v,t){var u,s,w,r;if(i.isArray(v)){v=v.slice();for(u=0,s=v.length;u<s;u++){this.set_icon(v[u],t)}return true}v=this.get_node(v);if(!v||v.id===i.jstree.root){return false}r=v.icon;v.icon=t===true||t===null||t===e||t===""?true:t;w=this.get_node(v,true).children(".jstree-anchor").children(".jstree-themeicon");if(t===false){this.hide_icon(v)}else{if(t===true||t===null||t===e||t===""){w.removeClass("jstree-themeicon-custom "+r).css("background","").removeAttr("rel");if(r===false){this.show_icon(v)}}else{if(t.indexOf("/")===-1&&t.indexOf(".")===-1){w.removeClass(r).css("background","");w.addClass(t+" jstree-themeicon-custom").attr("rel",t);if(r===false){this.show_icon(v)}}else{w.removeClass(r).css("background","");w.addClass("jstree-themeicon-custom").css("background","url('"+t+"') center center no-repeat").attr("rel",t);if(r===false){this.show_icon(v)}}}}return true},get_icon:function(r){r=this.get_node(r);return(!r||r.id===i.jstree.root)?false:r.icon},hide_icon:function(t){var s,r;if(i.isArray(t)){t=t.slice();for(s=0,r=t.length;s<r;s++){this.hide_icon(t[s])}return true}t=this.get_node(t);if(!t||t===i.jstree.root){return false}t.icon=false;this.get_node(t,true).children(".jstree-anchor").children(".jstree-themeicon").addClass("jstree-themeicon-hidden");return true},show_icon:function(t){var s,r,u;if(i.isArray(t)){t=t.slice();for(s=0,r=t.length;s<r;s++){this.show_icon(t[s])}return true}t=this.get_node(t);if(!t||t===i.jstree.root){return false}u=this.get_node(t,true);t.icon=u.length?u.children(".jstree-anchor").children(".jstree-themeicon").attr("rel"):true;if(!t.icon){t.icon=true}u.children(".jstree-anchor").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden");return true}};i.vakata={};i.vakata.attributes=function(s,t){s=i(s)[0];var r=t?{}:[];if(s&&s.attributes){i.each(s.attributes,function(w,u){if(i.inArray(u.name.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])!==-1){return}if(u.value!==null&&i.trim(u.value)!==""){if(t){r[u.name]=u.value}else{r.push(u.name)}}})}return r};i.vakata.array_unique=function(w){var s=[],u,t,r,v={};for(u=0,r=w.length;u<r;u++){if(v[w[u]]===e){s.push(w[u]);v[w[u]]=true}}return s};i.vakata.array_remove=function(u,t,s){var r=u.slice((s||t)+1||u.length);u.length=t<0?u.length+t:t;u.push.apply(u,r);return u};i.vakata.array_remove_item=function(t,s){var r=i.inArray(s,t);return r!==-1?i.vakata.array_remove(t,r):t};i.jstree.plugins.changed=function(r,s){var t=[];this.trigger=function(x,y){var w,u;if(!y){y={}}if(x.replace(".jstree","")==="changed"){y.changed={selected:[],deselected:[]};var v={};for(w=0,u=t.length;w<u;w++){v[t[w]]=1}for(w=0,u=y.selected.length;w<u;w++){if(!v[y.selected[w]]){y.changed.selected.push(y.selected[w])}else{v[y.selected[w]]=2}}for(w=0,u=t.length;w<u;w++){if(v[t[w]]===1){y.changed.deselected.push(t[w])}}t=y.selected.slice()}s.trigger.call(this,x,y)};this.refresh=function(v,u){t=[];return s.refresh.apply(this,arguments)}};var h=o.createElement("I");h.className="jstree-icon jstree-checkbox";h.setAttribute("role","presentation");i.jstree.defaults.checkbox={visible:true,three_state:true,whole_node:true,keep_selected_style:true,cascade:"",tie_selection:true};i.jstree.plugins.checkbox=function(r,s){this.bind=function(){s.bind.call(this);this._data.checkbox.uto=false;this._data.checkbox.selected=[];if(this.settings.checkbox.three_state){this.settings.checkbox.cascade="up+down+undetermined"}this.element.on("init.jstree",i.proxy(function(){this._data.checkbox.visible=this.settings.checkbox.visible;if(!this.settings.checkbox.keep_selected_style){this.element.addClass("jstree-checkbox-no-clicked")}if(this.settings.checkbox.tie_selection){this.element.addClass("jstree-checkbox-selection")}},this)).on("loading.jstree",i.proxy(function(){this[this._data.checkbox.visible?"show_checkboxes":"hide_checkboxes"]()},this));if(this.settings.checkbox.cascade.indexOf("undetermined")!==-1){this.element.on("changed.jstree uncheck_node.jstree check_node.jstree uncheck_all.jstree check_all.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree",i.proxy(function(){if(this._data.checkbox.uto){clearTimeout(this._data.checkbox.uto)}this._data.checkbox.uto=setTimeout(i.proxy(this._undetermined,this),50)},this))}if(!this.settings.checkbox.tie_selection){this.element.on("model.jstree",i.proxy(function(y,w){var t=this._model.data,x=t[w.parent],z=w.nodes,v,u;for(v=0,u=z.length;v<u;v++){t[z[v]].state.checked=t[z[v]].state.checked||(t[z[v]].original&&t[z[v]].original.state&&t[z[v]].original.state.checked);if(t[z[v]].state.checked){this._data.checkbox.selected.push(z[v])}}},this))}if(this.settings.checkbox.cascade.indexOf("up")!==-1||this.settings.checkbox.cascade.indexOf("down")!==-1){this.element.on("model.jstree",i.proxy(function(D,A){var v=this._model.data,u=v[A.parent],C=A.nodes,H=[],E,B,y,x,w,z,G=this.settings.checkbox.cascade,F=this.settings.checkbox.tie_selection;if(G.indexOf("down")!==-1){if(u.state[F?"selected":"checked"]){for(B=0,y=C.length;B<y;B++){v[C[B]].state[F?"selected":"checked"]=true}this._data[F?"core":"checkbox"].selected=this._data[F?"core":"checkbox"].selected.concat(C)}else{for(B=0,y=C.length;B<y;B++){if(v[C[B]].state[F?"selected":"checked"]){for(x=0,w=v[C[B]].children_d.length;x<w;x++){v[v[C[B]].children_d[x]].state[F?"selected":"checked"]=true}this._data[F?"core":"checkbox"].selected=this._data[F?"core":"checkbox"].selected.concat(v[C[B]].children_d)}}}}if(G.indexOf("up")!==-1){for(B=0,y=u.children_d.length;B<y;B++){if(!v[u.children_d[B]].children.length){H.push(v[u.children_d[B]].parent)}}H=i.vakata.array_unique(H);for(x=0,w=H.length;x<w;x++){u=v[H[x]];while(u&&u.id!==i.jstree.root){E=0;for(B=0,y=u.children.length;B<y;B++){E+=v[u.children[B]].state[F?"selected":"checked"]}if(E===y){u.state[F?"selected":"checked"]=true;this._data[F?"core":"checkbox"].selected.push(u.id);z=this.get_node(u,true);if(z&&z.length){z.attr("aria-selected",true).children(".jstree-anchor").addClass(F?"jstree-clicked":"jstree-checked")}}else{break}u=this.get_node(u.parent)}}}this._data[F?"core":"checkbox"].selected=i.vakata.array_unique(this._data[F?"core":"checkbox"].selected)},this)).on(this.settings.checkbox.tie_selection?"select_node.jstree":"check_node.jstree",i.proxy(function(B,z){var y=z.node,u=this._model.data,C=this.get_node(y.parent),v=this.get_node(y,true),A,w,D,x,F=this.settings.checkbox.cascade,E=this.settings.checkbox.tie_selection;if(F.indexOf("down")!==-1){this._data[E?"core":"checkbox"].selected=i.vakata.array_unique(this._data[E?"core":"checkbox"].selected.concat(y.children_d));for(A=0,w=y.children_d.length;A<w;A++){x=u[y.children_d[A]];x.state[E?"selected":"checked"]=true;if(x&&x.original&&x.original.state&&x.original.state.undetermined){x.original.state.undetermined=false}}}if(F.indexOf("up")!==-1){while(C&&C.id!==i.jstree.root){D=0;for(A=0,w=C.children.length;A<w;A++){D+=u[C.children[A]].state[E?"selected":"checked"]}if(D===w){C.state[E?"selected":"checked"]=true;this._data[E?"core":"checkbox"].selected.push(C.id);x=this.get_node(C,true);if(x&&x.length){x.attr("aria-selected",true).children(".jstree-anchor").addClass(E?"jstree-clicked":"jstree-checked")}}else{break}C=this.get_node(C.parent)}}if(F.indexOf("down")!==-1&&v.length){v.find(".jstree-anchor").addClass(E?"jstree-clicked":"jstree-checked").parent().attr("aria-selected",true)}},this)).on(this.settings.checkbox.tie_selection?"deselect_all.jstree":"uncheck_all.jstree",i.proxy(function(z,x){var y=this.get_node(i.jstree.root),t=this._model.data,w,u,v;for(w=0,u=y.children_d.length;w<u;w++){v=t[y.children_d[w]];if(v&&v.original&&v.original.state&&v.original.state.undetermined){v.original.state.undetermined=false}}},this)).on(this.settings.checkbox.tie_selection?"deselect_node.jstree":"uncheck_node.jstree",i.proxy(function(A,x){var w=x.node,u=this.get_node(w,true),y,v,z,C=this.settings.checkbox.cascade,B=this.settings.checkbox.tie_selection;if(w&&w.original&&w.original.state&&w.original.state.undetermined){w.original.state.undetermined=false}if(C.indexOf("down")!==-1){for(y=0,v=w.children_d.length;y<v;y++){z=this._model.data[w.children_d[y]];z.state[B?"selected":"checked"]=false;if(z&&z.original&&z.original.state&&z.original.state.undetermined){z.original.state.undetermined=false}}}if(C.indexOf("up")!==-1){for(y=0,v=w.parents.length;y<v;y++){z=this._model.data[w.parents[y]];z.state[B?"selected":"checked"]=false;if(z&&z.original&&z.original.state&&z.original.state.undetermined){z.original.state.undetermined=false}z=this.get_node(w.parents[y],true);if(z&&z.length){z.attr("aria-selected",false).children(".jstree-anchor").removeClass(B?"jstree-clicked":"jstree-checked")}}}z=[];for(y=0,v=this._data[B?"core":"checkbox"].selected.length;y<v;y++){if((C.indexOf("down")===-1||i.inArray(this._data[B?"core":"checkbox"].selected[y],w.children_d)===-1)&&(C.indexOf("up")===-1||i.inArray(this._data[B?"core":"checkbox"].selected[y],w.parents)===-1)){z.push(this._data[B?"core":"checkbox"].selected[y])}}this._data[B?"core":"checkbox"].selected=i.vakata.array_unique(z);if(C.indexOf("down")!==-1&&u.length){u.find(".jstree-anchor").removeClass(B?"jstree-clicked":"jstree-checked").parent().attr("aria-selected",false)}},this))}if(this.settings.checkbox.cascade.indexOf("up")!==-1){this.element.on("delete_node.jstree",i.proxy(function(A,x){var u=this.get_node(x.parent),v=this._model.data,y,w,B,z,C=this.settings.checkbox.tie_selection;while(u&&u.id!==i.jstree.root&&!u.state[C?"selected":"checked"]){B=0;for(y=0,w=u.children.length;y<w;y++){B+=v[u.children[y]].state[C?"selected":"checked"]}if(w>0&&B===w){u.state[C?"selected":"checked"]=true;this._data[C?"core":"checkbox"].selected.push(u.id);z=this.get_node(u,true);if(z&&z.length){z.attr("aria-selected",true).children(".jstree-anchor").addClass(C?"jstree-clicked":"jstree-checked")}}else{break}u=this.get_node(u.parent)}},this)).on("move_node.jstree",i.proxy(function(D,B){var x=B.is_multi,C=B.old_parent,u=this.get_node(B.parent),w=this._model.data,v,E,A,y,z,F=this.settings.checkbox.tie_selection;if(!x){v=this.get_node(C);while(v&&v.id!==i.jstree.root&&!v.state[F?"selected":"checked"]){E=0;for(A=0,y=v.children.length;A<y;A++){E+=w[v.children[A]].state[F?"selected":"checked"]}if(y>0&&E===y){v.state[F?"selected":"checked"]=true;this._data[F?"core":"checkbox"].selected.push(v.id);z=this.get_node(v,true);if(z&&z.length){z.attr("aria-selected",true).children(".jstree-anchor").addClass(F?"jstree-clicked":"jstree-checked")}}else{break}v=this.get_node(v.parent)}}v=u;while(v&&v.id!==i.jstree.root){E=0;for(A=0,y=v.children.length;A<y;A++){E+=w[v.children[A]].state[F?"selected":"checked"]}if(E===y){if(!v.state[F?"selected":"checked"]){v.state[F?"selected":"checked"]=true;this._data[F?"core":"checkbox"].selected.push(v.id);z=this.get_node(v,true);if(z&&z.length){z.attr("aria-selected",true).children(".jstree-anchor").addClass(F?"jstree-clicked":"jstree-checked")}}}else{if(v.state[F?"selected":"checked"]){v.state[F?"selected":"checked"]=false;this._data[F?"core":"checkbox"].selected=i.vakata.array_remove_item(this._data[F?"core":"checkbox"].selected,v.id);z=this.get_node(v,true);if(z&&z.length){z.attr("aria-selected",false).children(".jstree-anchor").removeClass(F?"jstree-clicked":"jstree-checked")}}else{break}}v=this.get_node(v.parent)}},this))}};this._undetermined=function(){if(this.element===null){return}var A,z,y,x,v={},w=this._model.data,C=this.settings.checkbox.tie_selection,D=this._data[C?"core":"checkbox"].selected,u=[],B=this;for(A=0,z=D.length;A<z;A++){if(w[D[A]]&&w[D[A]].parents){for(y=0,x=w[D[A]].parents.length;y<x;y++){if(v[w[D[A]].parents[y]]===e&&w[D[A]].parents[y]!==i.jstree.root){v[w[D[A]].parents[y]]=true;u.push(w[D[A]].parents[y])}}}}this.element.find(".jstree-closed").not(":has(.jstree-children)").each(function(){var t=B.get_node(this),E;if(!t.state.loaded){if(t.original&&t.original.state&&t.original.state.undetermined&&t.original.state.undetermined===true){if(v[t.id]===e&&t.id!==i.jstree.root){v[t.id]=true;u.push(t.id)}for(y=0,x=t.parents.length;y<x;y++){if(v[t.parents[y]]===e&&t.parents[y]!==i.jstree.root){v[t.parents[y]]=true;u.push(t.parents[y])}}}}else{for(A=0,z=t.children_d.length;A<z;A++){E=w[t.children_d[A]];if(!E.state.loaded&&E.original&&E.original.state&&E.original.state.undetermined&&E.original.state.undetermined===true){if(v[E.id]===e&&E.id!==i.jstree.root){v[E.id]=true;u.push(E.id)}for(y=0,x=E.parents.length;y<x;y++){if(v[E.parents[y]]===e&&E.parents[y]!==i.jstree.root){v[E.parents[y]]=true;u.push(E.parents[y])}}}}}});this.element.find(".jstree-undetermined").removeClass("jstree-undetermined");for(A=0,z=u.length;A<z;A++){if(!w[u[A]].state[C?"selected":"checked"]){D=this.get_node(u[A],true);if(D&&D.length){D.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-undetermined")}}}};this.redraw_node=function(A,t,x,z){A=s.redraw_node.apply(this,arguments);if(A){var w,u,v=null,y=null;for(w=0,u=A.childNodes.length;w<u;w++){if(A.childNodes[w]&&A.childNodes[w].className&&A.childNodes[w].className.indexOf("jstree-anchor")!==-1){v=A.childNodes[w];break}}if(v){if(!this.settings.checkbox.tie_selection&&this._model.data[A.id].state.checked){v.className+=" jstree-checked"}y=h.cloneNode(false);if(this._model.data[A.id].state.checkbox_disabled){y.className+=" jstree-checkbox-disabled"}v.insertBefore(y,v.childNodes[0])}}if(!x&&this.settings.checkbox.cascade.indexOf("undetermined")!==-1){if(this._data.checkbox.uto){clearTimeout(this._data.checkbox.uto)}this._data.checkbox.uto=setTimeout(i.proxy(this._undetermined,this),50)}return A};this.show_checkboxes=function(){this._data.core.themes.checkboxes=true;this.get_container_ul().removeClass("jstree-no-checkboxes")};this.hide_checkboxes=function(){this._data.core.themes.checkboxes=false;this.get_container_ul().addClass("jstree-no-checkboxes")};this.toggle_checkboxes=function(){if(this._data.core.themes.checkboxes){this.hide_checkboxes()}else{this.show_checkboxes()}};this.is_undetermined=function(z){z=this.get_node(z);var y=this.settings.checkbox.cascade,x,v,w=this.settings.checkbox.tie_selection,A=this._data[w?"core":"checkbox"].selected,u=this._model.data;if(!z||z.state[w?"selected":"checked"]===true||y.indexOf("undetermined")===-1||(y.indexOf("down")===-1&&y.indexOf("up")===-1)){return false}if(!z.state.loaded&&z.original.state.undetermined===true){return true}for(x=0,v=z.children_d.length;x<v;x++){if(i.inArray(z.children_d[x],A)!==-1||(!u[z.children_d[x]].state.loaded&&u[z.children_d[x]].original.state.undetermined)){return true}}return false};this.disable_checkbox=function(v){var u,t,w;if(i.isArray(v)){v=v.slice();for(u=0,t=v.length;u<t;u++){this.disable_checkbox(v[u])}return true}v=this.get_node(v);if(!v||v.id===i.jstree.root){return false}w=this.get_node(v,true);if(!v.state.checkbox_disabled){v.state.checkbox_disabled=true;if(w&&w.length){w.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-checkbox-disabled")}this.trigger("disable_checkbox",{node:v})}};this.enable_checkbox=function(v){var u,t,w;if(i.isArray(v)){v=v.slice();for(u=0,t=v.length;u<t;u++){this.enable_checkbox(v[u])}return true}v=this.get_node(v);if(!v||v.id===i.jstree.root){return false}w=this.get_node(v,true);if(v.state.checkbox_disabled){v.state.checkbox_disabled=false;if(w&&w.length){w.children(".jstree-anchor").children(".jstree-checkbox").removeClass("jstree-checkbox-disabled")}this.trigger("enable_checkbox",{node:v})}};this.activate_node=function(u,t){if(i(t.target).hasClass("jstree-checkbox-disabled")){return false}if(this.settings.checkbox.tie_selection&&(this.settings.checkbox.whole_node||i(t.target).hasClass("jstree-checkbox"))){t.ctrlKey=true}if(this.settings.checkbox.tie_selection||(!this.settings.checkbox.whole_node&&!i(t.target).hasClass("jstree-checkbox"))){return s.activate_node.call(this,u,t)}if(this.is_disabled(u)){return false}if(this.is_checked(u)){this.uncheck_node(u,t)}else{this.check_node(u,t)}this.trigger("activate_node",{node:this.get_node(u)})};this.check_node=function(x,w){if(this.settings.checkbox.tie_selection){return this.select_node(x,false,true,w)}var y,v,t,u;if(i.isArray(x)){x=x.slice();for(v=0,t=x.length;v<t;v++){this.check_node(x[v],w)}return true}x=this.get_node(x);if(!x||x.id===i.jstree.root){return false}y=this.get_node(x,true);if(!x.state.checked){x.state.checked=true;this._data.checkbox.selected.push(x.id);if(y&&y.length){y.children(".jstree-anchor").addClass("jstree-checked")}this.trigger("check_node",{node:x,selected:this._data.checkbox.selected,event:w})}};this.uncheck_node=function(w,v){if(this.settings.checkbox.tie_selection){return this.deselect_node(w,false,v)}var u,t,x;if(i.isArray(w)){w=w.slice();for(u=0,t=w.length;u<t;u++){this.uncheck_node(w[u],v)}return true}w=this.get_node(w);if(!w||w.id===i.jstree.root){return false}x=this.get_node(w,true);if(w.state.checked){w.state.checked=false;this._data.checkbox.selected=i.vakata.array_remove_item(this._data.checkbox.selected,w.id);if(x.length){x.children(".jstree-anchor").removeClass("jstree-checked")}this.trigger("uncheck_node",{node:w,selected:this._data.checkbox.selected,event:v})}};this.check_all=function(){if(this.settings.checkbox.tie_selection){return this.select_all()}var v=this._data.checkbox.selected.concat([]),u,t;this._data.checkbox.selected=this._model.data[i.jstree.root].children_d.concat();for(u=0,t=this._data.checkbox.selected.length;u<t;u++){if(this._model.data[this._data.checkbox.selected[u]]){this._model.data[this._data.checkbox.selected[u]].state.checked=true}}this.redraw(true);this.trigger("check_all",{selected:this._data.checkbox.selected})};this.uncheck_all=function(){if(this.settings.checkbox.tie_selection){return this.deselect_all()}var v=this._data.checkbox.selected.concat([]),u,t;for(u=0,t=this._data.checkbox.selected.length;u<t;u++){if(this._model.data[this._data.checkbox.selected[u]]){this._model.data[this._data.checkbox.selected[u]].state.checked=false}}this._data.checkbox.selected=[];this.element.find(".jstree-checked").removeClass("jstree-checked");this.trigger("uncheck_all",{selected:this._data.checkbox.selected,node:v})};this.is_checked=function(t){if(this.settings.checkbox.tie_selection){return this.is_selected(t)}t=this.get_node(t);if(!t||t.id===i.jstree.root){return false}return t.state.checked};this.get_checked=function(t){if(this.settings.checkbox.tie_selection){return this.get_selected(t)}return t?i.map(this._data.checkbox.selected,i.proxy(function(u){return this.get_node(u)},this)):this._data.checkbox.selected};this.get_top_checked=function(y){if(this.settings.checkbox.tie_selection){return this.get_top_selected(y)}var x=this.get_checked(true),z={},w,v,u,t;for(w=0,v=x.length;w<v;w++){z[x[w].id]=x[w]}for(w=0,v=x.length;w<v;w++){for(u=0,t=x[w].children_d.length;u<t;u++){if(z[x[w].children_d[u]]){delete z[x[w].children_d[u]]}}}x=[];for(w in z){if(z.hasOwnProperty(w)){x.push(w)}}return y?i.map(x,i.proxy(function(A){return this.get_node(A)},this)):x};this.get_bottom_checked=function(w){if(this.settings.checkbox.tie_selection){return this.get_bottom_selected(w)}var v=this.get_checked(true),x=[],u,t;for(u=0,t=v.length;u<t;u++){if(!v[u].children.length){x.push(v[u].id)}}return w?i.map(x,i.proxy(function(y){return this.get_node(y)},this)):x};this.load_node=function(y,A){var u,t,x,v,z,w;if(!i.isArray(y)&&!this.settings.checkbox.tie_selection){w=this.get_node(y);if(w&&w.state.loaded){for(u=0,t=w.children_d.length;u<t;u++){if(this._model.data[w.children_d[u]].state.checked){z=true;this._data.checkbox.selected=i.vakata.array_remove_item(this._data.checkbox.selected,w.children_d[u])}}}}return s.load_node.apply(this,arguments)};this.get_state=function(){var t=s.get_state.apply(this,arguments);if(this.settings.checkbox.tie_selection){return t}t.checkbox=this._data.checkbox.selected.slice();return t};this.set_state=function(u,w){var t=s.set_state.apply(this,arguments);if(t&&u.checkbox){if(!this.settings.checkbox.tie_selection){this.uncheck_all();var v=this;i.each(u.checkbox,function(y,x){v.check_node(x)})}delete u.checkbox;this.set_state(u,w);return false}return t};this.refresh=function(u,t){if(!this.settings.checkbox.tie_selection){this._data.checkbox.selected=[]}return s.refresh.apply(this,arguments)}};i.jstree.defaults.conditionalselect=function(){return true};i.jstree.plugins.conditionalselect=function(r,s){this.activate_node=function(u,t){if(this.settings.conditionalselect.call(this,this.get_node(u),t)){s.activate_node.call(this,u,t)}}};i.jstree.defaults.contextmenu={select_node:true,show_at_node:true,items:function(s,r){return{create:{separator_before:false,separator_after:true,_disabled:false,label:"Create",action:function(u){var t=i.jstree.reference(u.reference),v=t.get_node(u.reference);t.create_node(v,{},"last",function(w){setTimeout(function(){t.edit(w)},0)})}},rename:{separator_before:false,separator_after:false,_disabled:false,label:"Rename",
  /*
  					"shortcut"			: 113,
  					"shortcut_label"	: 'F2',
  					"icon"				: "glyphicon glyphicon-leaf",
  					*/
  action:function(u){var t=i.jstree.reference(u.reference),v=t.get_node(u.reference);t.edit(v)}},remove:{separator_before:false,icon:false,separator_after:false,_disabled:false,label:"Delete",action:function(u){var t=i.jstree.reference(u.reference),v=t.get_node(u.reference);if(t.is_selected(v)){t.delete_node(t.get_selected())}else{t.delete_node(v)}}},ccp:{separator_before:true,icon:false,separator_after:false,label:"Edit",action:false,submenu:{cut:{separator_before:false,separator_after:false,label:"Cut",action:function(u){var t=i.jstree.reference(u.reference),v=t.get_node(u.reference);if(t.is_selected(v)){t.cut(t.get_top_selected())}else{t.cut(v)}}},copy:{separator_before:false,icon:false,separator_after:false,label:"Copy",action:function(u){var t=i.jstree.reference(u.reference),v=t.get_node(u.reference);if(t.is_selected(v)){t.copy(t.get_top_selected())}else{t.copy(v)}}},paste:{separator_before:false,icon:false,_disabled:function(t){return !i.jstree.reference(t.reference).can_paste()},separator_after:false,label:"Paste",action:function(u){var t=i.jstree.reference(u.reference),v=t.get_node(u.reference);t.paste(v)}}}}}}};i.jstree.plugins.contextmenu=function(r,s){this.bind=function(){s.bind.call(this);var t=0,w=null,v,u;this.element.on("contextmenu.jstree",".jstree-anchor",i.proxy(function(y,x){y.preventDefault();t=y.ctrlKey?+new Date():0;if(x||w){t=(+new Date())+10000}if(w){clearTimeout(w)}if(!this.is_loading(y.currentTarget)){this.show_contextmenu(y.currentTarget,y.pageX,y.pageY,y)}},this)).on("click.jstree",".jstree-anchor",i.proxy(function(x){if(this._data.contextmenu.visible&&(!t||(+new Date())-t>250)){i.vakata.context.hide()}t=0},this)).on("touchstart.jstree",".jstree-anchor",function(x){if(!x.originalEvent||!x.originalEvent.changedTouches||!x.originalEvent.changedTouches[0]){return}v=x.pageX;u=x.pageY;w=setTimeout(function(){i(x.currentTarget).trigger("contextmenu",true)},750)}).on("touchmove.vakata.jstree",function(x){if(w&&x.originalEvent&&x.originalEvent.changedTouches&&x.originalEvent.changedTouches[0]&&(Math.abs(v-x.pageX)>50||Math.abs(u-x.pageY)>50)){clearTimeout(w)}}).on("touchend.vakata.jstree",function(x){if(w){clearTimeout(w)}});
  /*
  			if(!('oncontextmenu' in document.body) && ('ontouchstart' in document.body)) {
  				var el = null, tm = null;
  				this.element
  					.on("touchstart", ".jstree-anchor", function (e) {
  						el = e.currentTarget;
  						tm = +new Date();
  						$(document).one("touchend", function (e) {
  							e.target = document.elementFromPoint(e.originalEvent.targetTouches[0].pageX - window.pageXOffset, e.originalEvent.targetTouches[0].pageY - window.pageYOffset);
  							e.currentTarget = e.target;
  							tm = ((+(new Date())) - tm);
  							if(e.target === el && tm > 600 && tm < 1000) {
  								e.preventDefault();
  								$(el).trigger('contextmenu', e);
  							}
  							el = null;
  							tm = null;
  						});
  					});
  			}
  			*/
  i(o).on("context_hide.vakata.jstree",i.proxy(function(){this._data.contextmenu.visible=false},this))};this.teardown=function(){if(this._data.contextmenu.visible){i.vakata.context.hide()}s.teardown.call(this)};this.show_contextmenu=function(v,C,A,w){v=this.get_node(v);if(!v||v.id===i.jstree.root){return false}var D=this.settings.contextmenu,z=this.get_node(v,true),B=z.children(".jstree-anchor"),t=false,u=false;if(D.show_at_node||C===e||A===e){t=B.offset();C=t.left;A=t.top+this._data.core.li_height}if(this.settings.contextmenu.select_node&&!this.is_selected(v)){this.activate_node(v,w)}u=D.items;if(i.isFunction(u)){u=u.call(this,v,i.proxy(function(x){this._show_contextmenu(v,C,A,x)},this))}if(i.isPlainObject(u)){this._show_contextmenu(v,C,A,u)}};this._show_contextmenu=function(w,t,A,v){var z=this.get_node(w,true),u=z.children(".jstree-anchor");i(o).one("context_show.vakata.jstree",i.proxy(function(B,y){var x="jstree-contextmenu jstree-"+this.get_theme()+"-contextmenu";i(y.element).addClass(x)},this));this._data.contextmenu.visible=true;i.vakata.context.show(u,{x:t,y:A},v);this.trigger("show_contextmenu",{node:w,x:t,y:A})}};(function(s){var t=false,r={element:false,reference:false,position_x:0,position_y:0,items:[],html:"",is_visible:false};s.vakata.context={settings:{hide_onmouseleave:0,icons:true},_trigger:function(u){s(o).triggerHandler("context_"+u+".vakata",{reference:r.reference,element:r.element,position:{x:r.position_x,y:r.position_y}})},_execute:function(u){u=r.items[u];return u&&(!u._disabled||(s.isFunction(u._disabled)&&!u._disabled({item:u,reference:r.reference,element:r.element})))&&u.action?u.action.call(null,{item:u,reference:r.reference,element:r.element,position:{x:r.position_x,y:r.position_y}}):false},_parse:function(y,w){if(!y){return false}if(!w){r.html="";r.items=[]}var x="",u=false,v;if(w){x+="<ul>"}s.each(y,function(z,A){if(!A){return true}r.items.push(A);if(!u&&A.separator_before){x+="<li class='vakata-context-separator'><a href='#' "+(s.vakata.context.settings.icons?"":'style="margin-left:0px;"')+">&#160;</a></li>"}u=false;x+="<li class='"+(A._class||"")+(A._disabled===true||(s.isFunction(A._disabled)&&A._disabled({item:A,reference:r.reference,element:r.element}))?" vakata-contextmenu-disabled ":"")+"' "+(A.shortcut?" data-shortcut='"+A.shortcut+"' ":"")+">";x+="<a href='#' rel='"+(r.items.length-1)+"'>";if(s.vakata.context.settings.icons){x+="<i ";if(A.icon){if(A.icon.indexOf("/")!==-1||A.icon.indexOf(".")!==-1){x+=" style='background:url(\""+A.icon+"\") center center no-repeat' "}else{x+=" class='"+A.icon+"' "}}x+="></i><span class='vakata-contextmenu-sep'>&#160;</span>"}x+=(s.isFunction(A.label)?A.label({item:z,reference:r.reference,element:r.element}):A.label)+(A.shortcut?' <span class="vakata-contextmenu-shortcut vakata-contextmenu-shortcut-'+A.shortcut+'">'+(A.shortcut_label||"")+"</span>":"")+"</a>";if(A.submenu){v=s.vakata.context._parse(A.submenu,true);if(v){x+=v}}x+="</li>";if(A.separator_after){x+="<li class='vakata-context-separator'><a href='#' "+(s.vakata.context.settings.icons?"":'style="margin-left:0px;"')+">&#160;</a></li>";u=true}});x=x.replace(/<li class\='vakata-context-separator'\><\/li\>$/,"");if(w){x+="</ul>"}if(!w){r.html=x;s.vakata.context._trigger("parse")}return x.length>10?x:false},_show_submenu:function(D){D=s(D);if(!D.length||!D.children("ul").length){return}var C=D.children("ul"),u=D.offset().left+D.outerWidth(),E=D.offset().top,v=C.width(),A=C.height(),z=s(window).width()+s(window).scrollLeft(),B=s(window).height()+s(window).scrollTop();if(t){D[u-(v+10+D.outerWidth())<0?"addClass":"removeClass"]("vakata-context-left")}else{D[u+v+10>z?"addClass":"removeClass"]("vakata-context-right")}if(E+A+10>B){C.css("bottom","-1px")}C.show()},show:function(z,C,A){var v,D,H,G,I,B,u,F,E=true;if(r.element&&r.element.length){r.element.width("")}switch(E){case (!C&&!z):return false;case (!!C&&!!z):r.reference=z;r.position_x=C.x;r.position_y=C.y;break;case (!C&&!!z):r.reference=z;v=z.offset();r.position_x=v.left+z.outerHeight();r.position_y=v.top;break;case (!!C&&!z):r.position_x=C.x;r.position_y=C.y;break}if(!!z&&!A&&s(z).data("vakata_contextmenu")){A=s(z).data("vakata_contextmenu")}if(s.vakata.context._parse(A)){r.element.html(r.html)}if(r.items.length){r.element.appendTo("body");D=r.element;H=r.position_x;G=r.position_y;I=D.width();B=D.height();u=s(window).width()+s(window).scrollLeft();F=s(window).height()+s(window).scrollTop();if(t){H-=(D.outerWidth()-s(z).outerWidth());if(H<s(window).scrollLeft()+20){H=s(window).scrollLeft()+20}}if(H+I+20>u){H=u-(I+20)}if(G+B+20>F){G=F-(B+20)}r.element.css({left:H,top:G}).show().find("a").first().focus().parent().addClass("vakata-context-hover");r.is_visible=true;s.vakata.context._trigger("show")}},hide:function(){if(r.is_visible){r.element.hide().find("ul").hide().end().find(":focus").blur().end().detach();r.is_visible=false;s.vakata.context._trigger("hide")}}};s(function(){t=s("body").css("direction")==="rtl";var u=false;r.element=s("<ul class='vakata-context'></ul>");r.element.on("mouseenter","li",function(v){v.stopImmediatePropagation();if(s.contains(this,v.relatedTarget)){return}if(u){clearTimeout(u)}r.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end();s(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover");s.vakata.context._show_submenu(this)}).on("mouseleave","li",function(v){if(s.contains(this,v.relatedTarget)){return}s(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover")}).on("mouseleave",function(v){s(this).find(".vakata-context-hover").removeClass("vakata-context-hover");if(s.vakata.context.settings.hide_onmouseleave){u=setTimeout((function(w){return function(){s.vakata.context.hide()}}(this)),s.vakata.context.settings.hide_onmouseleave)}}).on("click","a",function(v){v.preventDefault();if(!s(this).blur().parent().hasClass("vakata-context-disabled")&&s.vakata.context._execute(s(this).attr("rel"))!==false){s.vakata.context.hide()}}).on("keydown","a",function(v){var w=null;switch(v.which){case 13:case 32:v.type="mouseup";v.preventDefault();s(v.currentTarget).trigger(v);break;case 37:if(r.is_visible){r.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children("a").focus();v.stopImmediatePropagation();v.preventDefault()}break;case 38:if(r.is_visible){w=r.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first();if(!w.length){w=r.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()}w.addClass("vakata-context-hover").children("a").focus();v.stopImmediatePropagation();v.preventDefault()}break;case 39:if(r.is_visible){r.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children("a").focus();v.stopImmediatePropagation();v.preventDefault()}break;case 40:if(r.is_visible){w=r.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first();if(!w.length){w=r.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()}w.addClass("vakata-context-hover").children("a").focus();v.stopImmediatePropagation();v.preventDefault()}break;case 27:s.vakata.context.hide();v.preventDefault();break;default:break}}).on("keydown",function(w){w.preventDefault();var v=r.element.find(".vakata-contextmenu-shortcut-"+w.which).parent();if(v.parent().not(".vakata-context-disabled")){v.click()}});s(o).on("mousedown.vakata.jstree",function(v){if(r.is_visible&&!s.contains(r.element[0],v.target)){s.vakata.context.hide()}}).on("context_show.vakata.jstree",function(w,v){r.element.find("li:has(ul)").children("a").addClass("vakata-context-parent");if(t){r.element.addClass("vakata-context-rtl").css("direction","rtl")}r.element.find("ul").hide().end()})})}(i));i.jstree.defaults.dnd={copy:true,open_timeout:500,is_draggable:true,check_while_dragging:true,always_copy:false,inside_pos:0,drag_selection:true,touch:true,large_drop_target:false,large_drag_target:false};i.jstree.plugins.dnd=function(r,s){this.bind=function(){s.bind.call(this);this.element.on("mousedown.jstree touchstart.jstree",this.settings.dnd.large_drag_target?".jstree-node":".jstree-anchor",i.proxy(function(w){if(this.settings.dnd.large_drag_target&&i(w.target).closest(".jstree-node")[0]!==w.currentTarget){return true}if(w.type==="touchstart"&&(!this.settings.dnd.touch||(this.settings.dnd.touch==="selected"&&!i(w.currentTarget).closest(".jstree-node").children(".jstree-anchor").hasClass("jstree-clicked")))){return true}var v=this.get_node(w.target),u=this.is_selected(v)&&this.settings.dnd.drag_selection?this.get_top_selected().length:1,t=(u>1?u+" "+this.get_string("nodes"):this.get_text(w.currentTarget));if(this.settings.core.force_text){t=i.vakata.html.escape(t)}if(v&&v.id&&v.id!==i.jstree.root&&(w.which===1||w.type==="touchstart")&&(this.settings.dnd.is_draggable===true||(i.isFunction(this.settings.dnd.is_draggable)&&this.settings.dnd.is_draggable.call(this,(u>1?this.get_top_selected(true):[v]),w)))){this.element.trigger("mousedown.jstree");return i.vakata.dnd.start(w,{jstree:true,origin:this,obj:this.get_node(v,true),nodes:u>1?this.get_top_selected():[v.id]},'<div id="jstree-dnd" class="jstree-'+this.get_theme()+" jstree-"+this.get_theme()+"-"+this.get_theme_variant()+" "+(this.settings.core.themes.responsive?" jstree-dnd-responsive":"")+'"><i class="jstree-icon jstree-er"></i>'+t+'<ins class="jstree-copy" style="display:none;">+</ins></div>')}},this))}};i(function(){var v=false,u=false,s=false,t=false,r=i('<div id="jstree-marker">&#160;</div>').hide();i(o).on("dnd_start.vakata.jstree",function(x,w){v=false;s=false;if(!w||!w.data||!w.data.jstree){return}r.appendTo("body")}).on("dnd_move.vakata.jstree",function(N,Q){if(t){clearTimeout(t)}if(!Q||!Q.data||!Q.data.jstree){return}if(Q.event.target.id&&Q.event.target.id==="jstree-marker"){return}s=Q.event;var w=i.jstree.reference(Q.event.target),z=false,P=false,x=false,O,K,F,M,G,L,H,E,D,C,B,I,J,A,y;if(w&&w._data&&w._data.dnd){r.attr("class","jstree-"+w.get_theme()+(w.settings.core.themes.responsive?" jstree-dnd-responsive":""));Q.helper.children().attr("class","jstree-"+w.get_theme()+" jstree-"+w.get_theme()+"-"+w.get_theme_variant()+" "+(w.settings.core.themes.responsive?" jstree-dnd-responsive":"")).find(".jstree-copy").first()[Q.data.origin&&(Q.data.origin.settings.dnd.always_copy||(Q.data.origin.settings.dnd.copy&&(Q.event.metaKey||Q.event.ctrlKey)))?"show":"hide"]();if((Q.event.target===w.element[0]||Q.event.target===w.get_container_ul()[0])&&w.get_container_ul().children().length===0){E=true;for(D=0,C=Q.data.nodes.length;D<C;D++){E=E&&w.check((Q.data.origin&&(Q.data.origin.settings.dnd.always_copy||(Q.data.origin.settings.dnd.copy&&(Q.event.metaKey||Q.event.ctrlKey)))?"copy_node":"move_node"),(Q.data.origin&&Q.data.origin!==w?Q.data.origin.get_node(Q.data.nodes[D]):Q.data.nodes[D]),i.jstree.root,"last",{dnd:true,ref:w.get_node(i.jstree.root),pos:"i",origin:Q.data.origin,is_multi:(Q.data.origin&&Q.data.origin!==w),is_foreign:(!Q.data.origin)});if(!E){break}}if(E){v={ins:w,par:i.jstree.root,pos:"last"};r.hide();Q.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok");return}}else{z=w.settings.dnd.large_drop_target?i(Q.event.target).closest(".jstree-node").children(".jstree-anchor"):i(Q.event.target).closest(".jstree-anchor");if(z&&z.length&&z.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")){P=z.offset();x=Q.event.pageY-P.top;M=z.outerHeight();if(x<M/3){H=["b","i","a"]}else{if(x>M-M/3){H=["a","i","b"]}else{H=x>M/2?["i","a","b"]:["i","b","a"]}}i.each(H,function(S,R){switch(R){case"b":K=P.left-6;F=P.top;G=w.get_parent(z);L=z.parent().index();break;case"i":A=w.settings.dnd.inside_pos;y=w.get_node(z.parent());K=P.left-2;F=P.top+M/2+1;G=y.id;L=A==="first"?0:(A==="last"?y.children.length:Math.min(A,y.children.length));break;case"a":K=P.left-6;F=P.top+M;G=w.get_parent(z);L=z.parent().index()+1;break}E=true;for(D=0,C=Q.data.nodes.length;D<C;D++){B=Q.data.origin&&(Q.data.origin.settings.dnd.always_copy||(Q.data.origin.settings.dnd.copy&&(Q.event.metaKey||Q.event.ctrlKey)))?"copy_node":"move_node";I=L;if(B==="move_node"&&R==="a"&&(Q.data.origin&&Q.data.origin===w)&&G===w.get_parent(Q.data.nodes[D])){J=w.get_node(G);if(I>i.inArray(Q.data.nodes[D],J.children)){I-=1}}E=E&&((w&&w.settings&&w.settings.dnd&&w.settings.dnd.check_while_dragging===false)||w.check(B,(Q.data.origin&&Q.data.origin!==w?Q.data.origin.get_node(Q.data.nodes[D]):Q.data.nodes[D]),G,I,{dnd:true,ref:w.get_node(z.parent()),pos:R,origin:Q.data.origin,is_multi:(Q.data.origin&&Q.data.origin!==w),is_foreign:(!Q.data.origin)}));if(!E){if(w&&w.last_error){u=w.last_error()}break}}if(R==="i"&&z.parent().is(".jstree-closed")&&w.settings.dnd.open_timeout){t=setTimeout((function(T,U){return function(){T.open_node(U)}}(w,z)),w.settings.dnd.open_timeout)}if(E){v={ins:w,par:G,pos:R==="i"&&A==="last"&&L===0&&!w.is_loaded(y)?"last":L};r.css({left:K+"px",top:F+"px"}).show();Q.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok");u={};H=true;return false}});if(H===true){return}}}}v=false;Q.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er");r.hide()}).on("dnd_scroll.vakata.jstree",function(x,w){if(!w||!w.data||!w.data.jstree){return}r.hide();v=false;s=false;w.helper.find(".jstree-icon").first().removeClass("jstree-ok").addClass("jstree-er")}).on("dnd_stop.vakata.jstree",function(A,z){if(t){clearTimeout(t)}if(!z||!z.data||!z.data.jstree){return}r.hide().detach();var y,x,w=[];if(v){for(y=0,x=z.data.nodes.length;y<x;y++){w[y]=z.data.origin?z.data.origin.get_node(z.data.nodes[y]):z.data.nodes[y]}v.ins[z.data.origin&&(z.data.origin.settings.dnd.always_copy||(z.data.origin.settings.dnd.copy&&(z.event.metaKey||z.event.ctrlKey)))?"copy_node":"move_node"](w,v.par,v.pos,false,false,false,z.data.origin)}else{y=i(z.event.target).closest(".jstree");if(y.length&&u&&u.error&&u.error==="check"){y=y.jstree(true);if(y){y.settings.core.error.call(this,u)}}}s=false;v=false}).on("keyup.jstree keydown.jstree",function(x,w){w=i.vakata.dnd._get();if(w&&w.data&&w.data.jstree){w.helper.find(".jstree-copy").first()[w.data.origin&&(w.data.origin.settings.dnd.always_copy||(w.data.origin.settings.dnd.copy&&(x.metaKey||x.ctrlKey)))?"show":"hide"]();if(s){s.metaKey=x.metaKey;s.ctrlKey=x.ctrlKey;i.vakata.dnd._trigger("move",s)}}})});(function(s){s.vakata.html={div:s("<div />"),escape:function(t){return s.vakata.html.div.text(t).html()},strip:function(t){return s.vakata.html.div.empty().append(s.parseHTML(t)).text()}};var r={element:false,target:false,is_down:false,is_drag:false,helper:false,helper_w:0,data:false,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:false,scroll_i:false,is_touch:false};s.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5,threshold_touch:50},_trigger:function(v,u){var t=s.vakata.dnd._get();t.event=u;s(o).triggerHandler("dnd_"+v+".vakata",t)},_get:function(){return{data:r.data,element:r.element,helper:r.helper}},_clean:function(){if(r.helper){r.helper.remove()}if(r.scroll_i){clearInterval(r.scroll_i);r.scroll_i=false}r={element:false,target:false,is_down:false,is_drag:false,helper:false,helper_w:0,data:false,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:false,scroll_i:false,is_touch:false};s(o).off("mousemove.vakata.jstree touchmove.vakata.jstree",s.vakata.dnd.drag);s(o).off("mouseup.vakata.jstree touchend.vakata.jstree",s.vakata.dnd.stop)},_scroll:function(v){if(!r.scroll_e||(!r.scroll_l&&!r.scroll_t)){if(r.scroll_i){clearInterval(r.scroll_i);r.scroll_i=false}return false}if(!r.scroll_i){r.scroll_i=setInterval(s.vakata.dnd._scroll,100);return false}if(v===true){return false}var u=r.scroll_e.scrollTop(),t=r.scroll_e.scrollLeft();r.scroll_e.scrollTop(u+r.scroll_t*s.vakata.dnd.settings.scroll_speed);r.scroll_e.scrollLeft(t+r.scroll_l*s.vakata.dnd.settings.scroll_speed);if(u!==r.scroll_e.scrollTop()||t!==r.scroll_e.scrollLeft()){s.vakata.dnd._trigger("scroll",r.scroll_e)}},start:function(v,u,t){if(v.type==="touchstart"&&v.originalEvent&&v.originalEvent.changedTouches&&v.originalEvent.changedTouches[0]){v.pageX=v.originalEvent.changedTouches[0].pageX;v.pageY=v.originalEvent.changedTouches[0].pageY;v.target=o.elementFromPoint(v.originalEvent.changedTouches[0].pageX-window.pageXOffset,v.originalEvent.changedTouches[0].pageY-window.pageYOffset)}if(r.is_drag){s.vakata.dnd.stop({})}try{v.currentTarget.unselectable="on";v.currentTarget.onselectstart=function(){return false};if(v.currentTarget.style){v.currentTarget.style.MozUserSelect="none"}}catch(w){}r.init_x=v.pageX;r.init_y=v.pageY;r.data=u;r.is_down=true;r.element=v.currentTarget;r.target=v.target;r.is_touch=v.type==="touchstart";if(t!==false){r.helper=s("<div id='vakata-dnd'></div>").html(t).css({display:"block",margin:"0",padding:"0",position:"absolute",top:"-2000px",lineHeight:"16px",zIndex:"10000"})}s(o).on("mousemove.vakata.jstree touchmove.vakata.jstree",s.vakata.dnd.drag);s(o).on("mouseup.vakata.jstree touchend.vakata.jstree",s.vakata.dnd.stop);return false},drag:function(A){if(A.type==="touchmove"&&A.originalEvent&&A.originalEvent.changedTouches&&A.originalEvent.changedTouches[0]){A.pageX=A.originalEvent.changedTouches[0].pageX;A.pageY=A.originalEvent.changedTouches[0].pageY;A.target=o.elementFromPoint(A.originalEvent.changedTouches[0].pageX-window.pageXOffset,A.originalEvent.changedTouches[0].pageY-window.pageYOffset)}if(!r.is_down){return}if(!r.is_drag){if(Math.abs(A.pageX-r.init_x)>(r.is_touch?s.vakata.dnd.settings.threshold_touch:s.vakata.dnd.settings.threshold)||Math.abs(A.pageY-r.init_y)>(r.is_touch?s.vakata.dnd.settings.threshold_touch:s.vakata.dnd.settings.threshold)){if(r.helper){r.helper.appendTo("body");r.helper_w=r.helper.outerWidth()}r.is_drag=true;s.vakata.dnd._trigger("start",A)}else{return}}var B=false,E=false,C=false,u=false,t=false,y=false,x=false,z=false,D=false,v=false;r.scroll_t=0;r.scroll_l=0;r.scroll_e=false;s(s(A.target).parentsUntil("body").addBack().get().reverse()).filter(function(){return(/^auto|scroll$/).test(s(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth)}).each(function(){var w=s(this),F=w.offset();if(this.scrollHeight>this.offsetHeight){if(F.top+w.height()-A.pageY<s.vakata.dnd.settings.scroll_proximity){r.scroll_t=1}if(A.pageY-F.top<s.vakata.dnd.settings.scroll_proximity){r.scroll_t=-1}}if(this.scrollWidth>this.offsetWidth){if(F.left+w.width()-A.pageX<s.vakata.dnd.settings.scroll_proximity){r.scroll_l=1}if(A.pageX-F.left<s.vakata.dnd.settings.scroll_proximity){r.scroll_l=-1}}if(r.scroll_t||r.scroll_l){r.scroll_e=s(this);return false}});if(!r.scroll_e){B=s(o);E=s(window);C=B.height();u=E.height();t=B.width();y=E.width();x=B.scrollTop();z=B.scrollLeft();if(C>u&&A.pageY-x<s.vakata.dnd.settings.scroll_proximity){r.scroll_t=-1}if(C>u&&u-(A.pageY-x)<s.vakata.dnd.settings.scroll_proximity){r.scroll_t=1}if(t>y&&A.pageX-z<s.vakata.dnd.settings.scroll_proximity){r.scroll_l=-1}if(t>y&&y-(A.pageX-z)<s.vakata.dnd.settings.scroll_proximity){r.scroll_l=1}if(r.scroll_t||r.scroll_l){r.scroll_e=B}}if(r.scroll_e){s.vakata.dnd._scroll(true)}if(r.helper){D=parseInt(A.pageY+s.vakata.dnd.settings.helper_top,10);v=parseInt(A.pageX+s.vakata.dnd.settings.helper_left,10);if(C&&D+25>C){D=C-50}if(t&&v+r.helper_w>t){v=t-(r.helper_w+2)}r.helper.css({left:v+"px",top:D+"px"})}s.vakata.dnd._trigger("move",A);return false},stop:function(t){if(t.type==="touchend"&&t.originalEvent&&t.originalEvent.changedTouches&&t.originalEvent.changedTouches[0]){t.pageX=t.originalEvent.changedTouches[0].pageX;t.pageY=t.originalEvent.changedTouches[0].pageY;t.target=o.elementFromPoint(t.originalEvent.changedTouches[0].pageX-window.pageXOffset,t.originalEvent.changedTouches[0].pageY-window.pageYOffset)}if(r.is_drag){s.vakata.dnd._trigger("stop",t)}else{if(t.type==="touchend"&&t.target===r.target){var u=setTimeout(function(){s(t.target).click()},100);s(t.target).one("click",function(){if(u){clearTimeout(u)}})}}s.vakata.dnd._clean();return false}}}(i));i.jstree.defaults.massload=null;i.jstree.plugins.massload=function(r,s){this.init=function(u,t){s.init.call(this,u,t);this._data.massload={}};this._load_nodes=function(t,w,u){var v=this.settings.massload;if(u&&!i.isEmptyObject(this._data.massload)){return s._load_nodes.call(this,t,w,u)}if(i.isFunction(v)){return v.call(this,t,i.proxy(function(y){if(y){for(var x in y){if(y.hasOwnProperty(x)){this._data.massload[x]=y[x]}}}s._load_nodes.call(this,t,w,u)},this))}if(typeof v==="object"&&v&&v.url){v=i.extend(true,{},v);if(i.isFunction(v.url)){v.url=v.url.call(this,t)}if(i.isFunction(v.data)){v.data=v.data.call(this,t)}return i.ajax(v).done(i.proxy(function(B,A,y){if(B){for(var z in B){if(B.hasOwnProperty(z)){this._data.massload[z]=B[z]}}}s._load_nodes.call(this,t,w,u)},this)).fail(i.proxy(function(x){s._load_nodes.call(this,t,w,u)},this))}return s._load_nodes.call(this,t,w,u)};this._load_node=function(t,v){var u=this._data.massload[t.id];if(u){return this[typeof u==="string"?"_append_html_data":"_append_json_data"](t,typeof u==="string"?i(i.parseHTML(u)).filter(function(){return this.nodeType!==3}):u,function(w){v.call(this,w);delete this._data.massload[t.id]})}return s._load_node.call(this,t,v)}};i.jstree.defaults.search={ajax:false,fuzzy:false,case_sensitive:false,show_only_matches:false,show_only_matches_children:false,close_opened_onclear:true,search_leaves_only:false,search_callback:false};i.jstree.plugins.search=function(r,s){this.bind=function(){s.bind.call(this);this._data.search.str="";this._data.search.dom=i();this._data.search.res=[];this._data.search.opn=[];this._data.search.som=false;this._data.search.smc=false;this._data.search.hdn=[];this.element.on("search.jstree",i.proxy(function(y,w){if(this._data.search.som&&w.res.length){var t=this._model.data,v,u,x=[];for(v=0,u=w.res.length;v<u;v++){if(t[w.res[v]]&&!t[w.res[v]].state.hidden){x.push(w.res[v]);x=x.concat(t[w.res[v]].parents);if(this._data.search.smc){x=x.concat(t[w.res[v]].children_d)}}}x=i.vakata.array_remove_item(i.vakata.array_unique(x),i.jstree.root);this._data.search.hdn=this.hide_all(true);this.show_node(x)}},this)).on("clear_search.jstree",i.proxy(function(u,t){if(this._data.search.som&&t.res.length){this.show_node(this._data.search.hdn)}},this))};this.search=function(D,F,w,y,v,z){if(D===false||i.trim(D.toString())===""){return this.clear_search()}y=this.get_node(y);y=y&&y.id?y.id:null;D=D.toString();var G=this.settings.search,E=G.ajax?G.ajax:false,x=this._model.data,C=null,t=[],u=[],B,A;if(this._data.search.res.length&&!v){this.clear_search()}if(w===e){w=G.show_only_matches}if(z===e){z=G.show_only_matches_children}if(!F&&E!==false){if(i.isFunction(E)){return E.call(this,D,i.proxy(function(H){if(H&&H.d){H=H.d}this._load_nodes(!i.isArray(H)?[]:i.vakata.array_unique(H),function(){this.search(D,true,w,y,v)},true)},this),y)}else{E=i.extend({},E);if(!E.data){E.data={}}E.data.str=D;if(y){E.data.inside=y}return i.ajax(E).fail(i.proxy(function(){this._data.core.last_error={error:"ajax",plugin:"search",id:"search_01",reason:"Could not load search parents",data:JSON.stringify(E)};this.settings.core.error.call(this,this._data.core.last_error)},this)).done(i.proxy(function(H){if(H&&H.d){H=H.d}this._load_nodes(!i.isArray(H)?[]:i.vakata.array_unique(H),function(){this.search(D,true,w,y,v)},true)},this))}}if(!v){this._data.search.str=D;this._data.search.dom=i();this._data.search.res=[];this._data.search.opn=[];this._data.search.som=w;this._data.search.smc=z}C=new i.vakata.search(D,true,{caseSensitive:G.case_sensitive,fuzzy:G.fuzzy});i.each(x[y?y:i.jstree.root].children_d,function(J,I){var H=x[I];if(H.text&&(!G.search_leaves_only||(H.state.loaded&&H.children.length===0))&&((G.search_callback&&G.search_callback.call(this,D,H))||(!G.search_callback&&C.search(H.text).isMatch))){t.push(I);u=u.concat(H.parents)}});if(t.length){u=i.vakata.array_unique(u);for(B=0,A=u.length;B<A;B++){if(u[B]!==i.jstree.root&&x[u[B]]&&this.open_node(u[B],null,0)===true){this._data.search.opn.push(u[B])}}if(!v){this._data.search.dom=i(this.element[0].querySelectorAll("#"+i.map(t,function(H){return"0123456789".indexOf(H[0])!==-1?"\\3"+H[0]+" "+H.substr(1).replace(i.jstree.idregex,"\\$&"):H.replace(i.jstree.idregex,"\\$&")}).join(", #")));this._data.search.res=t}else{this._data.search.dom=this._data.search.dom.add(i(this.element[0].querySelectorAll("#"+i.map(t,function(H){return"0123456789".indexOf(H[0])!==-1?"\\3"+H[0]+" "+H.substr(1).replace(i.jstree.idregex,"\\$&"):H.replace(i.jstree.idregex,"\\$&")}).join(", #"))));this._data.search.res=i.vakata.array_unique(this._data.search.res.concat(t))}this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:D,res:this._data.search.res,show_only_matches:w})};this.clear_search=function(){if(this.settings.search.close_opened_onclear){this.close_node(this._data.search.opn,0)}this.trigger("clear_search",{nodes:this._data.search.dom,str:this._data.search.str,res:this._data.search.res});if(this._data.search.res.length){this._data.search.dom=i(this.element[0].querySelectorAll("#"+i.map(this._data.search.res,function(t){return"0123456789".indexOf(t[0])!==-1?"\\3"+t[0]+" "+t.substr(1).replace(i.jstree.idregex,"\\$&"):t.replace(i.jstree.idregex,"\\$&")}).join(", #")));this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search")}this._data.search.str="";this._data.search.res=[];this._data.search.opn=[];this._data.search.dom=i()};this.redraw_node=function(y,t,z,x){y=s.redraw_node.apply(this,arguments);if(y){if(i.inArray(y.id,this._data.search.res)!==-1){var w,u,v=null;for(w=0,u=y.childNodes.length;w<u;w++){if(y.childNodes[w]&&y.childNodes[w].className&&y.childNodes[w].className.indexOf("jstree-anchor")!==-1){v=y.childNodes[w];break}}if(v){v.className+=" jstree-search"}}}return y}};(function(r){r.vakata.search=function(x,v,C){C=C||{};C=r.extend({},r.vakata.search.defaults,C);if(C.fuzzy!==false){C.fuzzy=true}x=C.caseSensitive?x:x.toLowerCase();var z=C.location,A=C.distance,y=C.threshold,s=x.length,t,u,w,B;if(s>32){C.fuzzy=false}if(C.fuzzy){t=1<<(s-1);u=(function(){var D={},E=0;for(E=0;E<s;E++){D[x.charAt(E)]=0}for(E=0;E<s;E++){D[x.charAt(E)]|=1<<(s-E-1)}return D}());w=function(G,D){var F=G/s,E=Math.abs(z-D);if(!A){return E?1:F}return F+(E/A)}}B=function(Q){Q=C.caseSensitive?Q:Q.toLowerCase();if(x===Q||Q.indexOf(x)!==-1){return{isMatch:true,score:0}}if(!C.fuzzy){return{isMatch:false,score:1}}var L,K,P=Q.length,H=y,J=Q.indexOf(x,z),N,G,E=s+P,D,F,O,S,R,I=1,M=[];if(J!==-1){H=Math.min(w(0,J),H);J=Q.lastIndexOf(x,z+s);if(J!==-1){H=Math.min(w(0,J),H)}}J=-1;for(L=0;L<s;L++){N=0;G=E;while(N<G){if(w(L,z+G)<=H){N=G}else{E=G}G=Math.floor((E-N)/2+N)}E=G;F=Math.max(1,z-G+1);O=Math.min(z+G,P)+s;S=new Array(O+2);S[O+1]=(1<<L)-1;for(K=O;K>=F;K--){R=u[Q.charAt(K-1)];if(L===0){S[K]=((S[K+1]<<1)|1)&R}else{S[K]=((S[K+1]<<1)|1)&R|(((D[K+1]|D[K])<<1)|1)|D[K+1]}if(S[K]&t){I=w(L,K-1);if(I<=H){H=I;J=K-1;M.push(J);if(J>z){F=Math.max(1,2*z-J)}else{break}}}}if(w(L+1,z)>H){break}D=S}return{isMatch:J>=0,score:I}};return v===true?{search:B}:B(v)};r.vakata.search.defaults={location:0,distance:100,threshold:0.6,fuzzy:false,caseSensitive:false}}(i));i.jstree.defaults.sort=function(s,r){return this.get_text(s)>this.get_text(r)?1:-1};i.jstree.plugins.sort=function(r,s){this.bind=function(){s.bind.call(this);this.element.on("model.jstree",i.proxy(function(u,t){this.sort(t.parent,true)},this)).on("rename_node.jstree create_node.jstree",i.proxy(function(u,t){this.sort(t.parent||t.node.parent,false);this.redraw_node(t.parent||t.node.parent,true)},this)).on("move_node.jstree copy_node.jstree",i.proxy(function(u,t){this.sort(t.parent,false);this.redraw_node(t.parent,true)},this))};this.sort=function(w,t){var v,u;w=this.get_node(w);if(w&&w.children&&w.children.length){w.children.sort(i.proxy(this.settings.sort,this));if(t){for(v=0,u=w.children_d.length;v<u;v++){this.sort(w.children_d[v],false)}}}}};var p=false;i.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree check_node.jstree uncheck_node.jstree",ttl:false,filter:false};i.jstree.plugins.state=function(r,s){this.bind=function(){s.bind.call(this);var t=i.proxy(function(){this.element.on(this.settings.state.events,i.proxy(function(){if(p){clearTimeout(p)}p=setTimeout(i.proxy(function(){this.save_state()},this),100)},this));this.trigger("state_ready")},this);this.element.on("ready.jstree",i.proxy(function(v,u){this.element.one("restore_state.jstree",t);if(!this.restore_state()){t()}},this))};this.save_state=function(){var t={state:this.get_state(),ttl:this.settings.state.ttl,sec:+(new Date())};i.vakata.storage.set(this.settings.state.key,JSON.stringify(t))};this.restore_state=function(){var t=i.vakata.storage.get(this.settings.state.key);if(!!t){try{t=JSON.parse(t)}catch(u){return false}}if(!!t&&t.ttl&&t.sec&&+(new Date())-t.sec>t.ttl){return false}if(!!t&&t.state){t=t.state}if(!!t&&i.isFunction(this.settings.state.filter)){t=this.settings.state.filter.call(this,t)}if(!!t){this.element.one("set_state.jstree",function(w,v){v.instance.trigger("restore_state",{state:i.extend(true,{},t)})});this.set_state(t);return true}return false};this.clear_state=function(){return i.vakata.storage.del(this.settings.state.key)}};(function(r,s){r.vakata.storage={set:function(t,u){return window.localStorage.setItem(t,u)},get:function(t){return window.localStorage.getItem(t)},del:function(t){return window.localStorage.removeItem(t)}}}(i));i.jstree.defaults.types={"default":{}};i.jstree.defaults.types[i.jstree.root]={};i.jstree.plugins.types=function(r,s){this.init=function(w,u){var v,t;if(u&&u.types&&u.types["default"]){for(v in u.types){if(v!=="default"&&v!==i.jstree.root&&u.types.hasOwnProperty(v)){for(t in u.types["default"]){if(u.types["default"].hasOwnProperty(t)&&u.types[v][t]===e){u.types[v][t]=u.types["default"][t]}}}}}s.init.call(this,w,u);this._model.data[i.jstree.root].type=i.jstree.root};this.refresh=function(u,t){s.refresh.call(this,u,t);this._model.data[i.jstree.root].type=i.jstree.root};this.bind=function(){this.element.on("model.jstree",i.proxy(function(z,y){var u=this._model.data,B=y.nodes,x=this.settings.types,w,v,A="default";for(w=0,v=B.length;w<v;w++){A="default";if(u[B[w]].original&&u[B[w]].original.type&&x[u[B[w]].original.type]){A=u[B[w]].original.type}if(u[B[w]].data&&u[B[w]].data.jstree&&u[B[w]].data.jstree.type&&x[u[B[w]].data.jstree.type]){A=u[B[w]].data.jstree.type}u[B[w]].type=A;if(u[B[w]].icon===true&&x[A].icon!==e){u[B[w]].icon=x[A].icon}}u[i.jstree.root].type=i.jstree.root},this));s.bind.call(this)};this.get_json=function(z,v,A){var y,u,t=this._model.data,x=v?i.extend(true,{},v,{no_id:false}):{},w=s.get_json.call(this,z,x,A);if(w===false){return false}if(i.isArray(w)){for(y=0,u=w.length;y<u;y++){w[y].type=w[y].id&&t[w[y].id]&&t[w[y].id].type?t[w[y].id].type:"default";if(v&&v.no_id){delete w[y].id;if(w[y].li_attr&&w[y].li_attr.id){delete w[y].li_attr.id}if(w[y].a_attr&&w[y].a_attr.id){delete w[y].a_attr.id}}}}else{w.type=w.id&&t[w.id]&&t[w.id].type?t[w.id].type:"default";if(v&&v.no_id){w=this._delete_ids(w)}}return w};this._delete_ids=function(v){if(i.isArray(v)){for(var u=0,t=v.length;u<t;u++){v[u]=this._delete_ids(v[u])}return v}delete v.id;if(v.li_attr&&v.li_attr.id){delete v.li_attr.id}if(v.a_attr&&v.a_attr.id){delete v.a_attr.id}if(v.children&&i.isArray(v.children)){v.children=this._delete_ids(v.children)}return v};this.check=function(B,w,z,C,A){if(s.check.call(this,B,w,z,C,A)===false){return false}w=w&&w.id?w:this.get_node(w);z=z&&z.id?z:this.get_node(z);var t=w&&w.id?(A&&A.origin?A.origin:i.jstree.reference(w.id)):null,x,y,v,u;t=t&&t._model&&t._model.data?t._model.data:null;switch(B){case"create_node":case"move_node":case"copy_node":if(B!=="move_node"||i.inArray(w.id,z.children)===-1){x=this.get_rules(z);if(x.max_children!==e&&x.max_children!==-1&&x.max_children===z.children.length){this._data.core.last_error={error:"check",plugin:"types",id:"types_01",reason:"max_children prevents function: "+B,data:JSON.stringify({chk:B,pos:C,obj:w&&w.id?w.id:false,par:z&&z.id?z.id:false})};return false}if(x.valid_children!==e&&x.valid_children!==-1&&i.inArray((w.type||"default"),x.valid_children)===-1){this._data.core.last_error={error:"check",plugin:"types",id:"types_02",reason:"valid_children prevents function: "+B,data:JSON.stringify({chk:B,pos:C,obj:w&&w.id?w.id:false,par:z&&z.id?z.id:false})};return false}if(t&&w.children_d&&w.parents){y=0;for(v=0,u=w.children_d.length;v<u;v++){y=Math.max(y,t[w.children_d[v]].parents.length)}y=y-w.parents.length+1}if(y<=0||y===e){y=1}do{if(x.max_depth!==e&&x.max_depth!==-1&&x.max_depth<y){this._data.core.last_error={error:"check",plugin:"types",id:"types_03",reason:"max_depth prevents function: "+B,data:JSON.stringify({chk:B,pos:C,obj:w&&w.id?w.id:false,par:z&&z.id?z.id:false})};return false}z=this.get_node(z.parent);x=this.get_rules(z);y++}while(z)}break}return true};this.get_rules=function(u){u=this.get_node(u);if(!u){return false}var t=this.get_type(u,true);if(t.max_depth===e){t.max_depth=-1}if(t.max_children===e){t.max_children=-1}if(t.valid_children===e){t.valid_children=-1}return t};this.get_type=function(t,u){t=this.get_node(t);return(!t)?false:(u?i.extend({type:t.type},this.settings.types[t.type]):t.type)};this.set_type=function(A,y){var w,z,x,v,u;if(i.isArray(A)){A=A.slice();for(z=0,x=A.length;z<x;z++){this.set_type(A[z],y)}return true}w=this.settings.types;A=this.get_node(A);if(!w[y]||!A){return false}v=A.type;u=this.get_icon(A);A.type=y;if(u===true||(w[v]&&w[v].icon!==e&&u===w[v].icon)){this.set_icon(A,w[y].icon!==e?w[y].icon:true)}return true}};i.jstree.defaults.unique={case_sensitive:false,duplicate:function(s,r){return s+" ("+r+")"}};i.jstree.plugins.unique=function(r,s){this.check=function(B,x,y,C,z){if(s.check.call(this,B,x,y,C,z)===false){return false}x=x&&x.id?x:this.get_node(x);y=y&&y.id?y:this.get_node(y);if(!y||!y.children){return true}var t=B==="rename_node"?C:x.text,A=[],D=this.settings.unique.case_sensitive,u=this._model.data,w,v;for(w=0,v=y.children.length;w<v;w++){A.push(D?u[y.children[w]].text:u[y.children[w]].text.toLowerCase())}if(!D){t=t.toLowerCase()}switch(B){case"delete_node":return true;case"rename_node":w=(i.inArray(t,A)===-1||(x.text&&x.text[D?"toString":"toLowerCase"]()===t));if(!w){this._data.core.last_error={error:"check",plugin:"unique",id:"unique_01",reason:"Child with name "+t+" already exists. Preventing: "+B,data:JSON.stringify({chk:B,pos:C,obj:x&&x.id?x.id:false,par:y&&y.id?y.id:false})}}return w;case"create_node":w=(i.inArray(t,A)===-1);if(!w){this._data.core.last_error={error:"check",plugin:"unique",id:"unique_04",reason:"Child with name "+t+" already exists. Preventing: "+B,data:JSON.stringify({chk:B,pos:C,obj:x&&x.id?x.id:false,par:y&&y.id?y.id:false})}}return w;case"copy_node":w=(i.inArray(t,A)===-1);if(!w){this._data.core.last_error={error:"check",plugin:"unique",id:"unique_02",reason:"Child with name "+t+" already exists. Preventing: "+B,data:JSON.stringify({chk:B,pos:C,obj:x&&x.id?x.id:false,par:y&&y.id?y.id:false})}}return w;case"move_node":w=((x.parent===y.id&&(!z||!z.is_multi))||i.inArray(t,A)===-1);if(!w){this._data.core.last_error={error:"check",plugin:"unique",id:"unique_03",reason:"Child with name "+t+" already exists. Preventing: "+B,data:JSON.stringify({chk:B,pos:C,obj:x&&x.id?x.id:false,par:y&&y.id?y.id:false})}}return w}return true};this.create_node=function(B,v,D,E,C){if(!v||v.text===e){if(B===null){B=i.jstree.root}B=this.get_node(B);if(!B){return s.create_node.call(this,B,v,D,E,C)}D=D===e?"last":D;if(!D.toString().match(/^(before|after)$/)&&!C&&!this.is_loaded(B)){return s.create_node.call(this,B,v,D,E,C)}if(!v){v={}}var z,t,A,y,x,u=this._model.data,F=this.settings.unique.case_sensitive,w=this.settings.unique.duplicate;t=z=this.get_string("New node");A=[];for(y=0,x=B.children.length;y<x;y++){A.push(F?u[B.children[y]].text:u[B.children[y]].text.toLowerCase())}y=1;while(i.inArray(F?t:t.toLowerCase(),A)!==-1){t=w.call(this,z,(++y)).toString()}v.text=t}return s.create_node.call(this,B,v,D,E,C)}};var b=o.createElement("DIV");b.setAttribute("unselectable","on");b.setAttribute("role","presentation");b.className="jstree-wholerow";b.innerHTML="&#160;";i.jstree.plugins.wholerow=function(r,s){this.bind=function(){s.bind.call(this);this.element.on("ready.jstree set_state.jstree",i.proxy(function(){this.hide_dots()},this)).on("init.jstree loading.jstree ready.jstree",i.proxy(function(){this.get_container_ul().addClass("jstree-wholerow-ul")},this)).on("deselect_all.jstree",i.proxy(function(u,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked")},this)).on("changed.jstree",i.proxy(function(x,w){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");var v=false,u,t;for(u=0,t=w.selected.length;u<t;u++){v=this.get_node(w.selected[u],true);if(v&&v.length){v.children(".jstree-wholerow").addClass("jstree-wholerow-clicked")}}},this)).on("open_node.jstree",i.proxy(function(u,t){this.get_node(t.node,true).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("hover_node.jstree dehover_node.jstree",i.proxy(function(u,t){if(u.type==="hover_node"&&this.is_disabled(t.node)){return}this.get_node(t.node,true).children(".jstree-wholerow")[u.type==="hover_node"?"addClass":"removeClass"]("jstree-wholerow-hovered")},this)).on("contextmenu.jstree",".jstree-wholerow",i.proxy(function(u){u.preventDefault();var t=i.Event("contextmenu",{metaKey:u.metaKey,ctrlKey:u.ctrlKey,altKey:u.altKey,shiftKey:u.shiftKey,pageX:u.pageX,pageY:u.pageY});i(u.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(t)},this))
  /*
  				.on("mousedown.jstree touchstart.jstree", ".jstree-wholerow", function (e) {
  						if(e.target === e.currentTarget) {
  							var a = $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor");
  							e.target = a[0];
  							a.trigger(e);
  						}
  					})
  				*/
  .on("click.jstree",".jstree-wholerow",function(u){u.stopImmediatePropagation();var t=i.Event("click",{metaKey:u.metaKey,ctrlKey:u.ctrlKey,altKey:u.altKey,shiftKey:u.shiftKey});i(u.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(t).focus()}).on("click.jstree",".jstree-leaf > .jstree-ocl",i.proxy(function(u){u.stopImmediatePropagation();var t=i.Event("click",{metaKey:u.metaKey,ctrlKey:u.ctrlKey,altKey:u.altKey,shiftKey:u.shiftKey});i(u.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(t).focus()},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",i.proxy(function(t){t.stopImmediatePropagation();if(!this.is_disabled(t.currentTarget)){this.hover_node(t.currentTarget)}return false},this)).on("mouseleave.jstree",".jstree-node",i.proxy(function(t){this.dehover_node(t.currentTarget)},this))};this.teardown=function(){if(this.settings.wholerow){this.element.find(".jstree-wholerow").remove()}s.teardown.call(this)};this.redraw_node=function(w,t,x,v){w=s.redraw_node.apply(this,arguments);if(w){var u=b.cloneNode(true);if(i.inArray(w.id,this._data.core.selected)!==-1){u.className+=" jstree-wholerow-clicked"}if(this._data.core.focused&&this._data.core.focused===w.id){u.className+=" jstree-wholerow-hovered"}w.insertBefore(u,w.childNodes[0])}return w}};if(o.registerElement&&Object&&Object.create){var k=Object.create(HTMLElement.prototype);k.createdCallback=function(){var s={core:{},plugins:[]},r;for(r in i.jstree.plugins){if(i.jstree.plugins.hasOwnProperty(r)&&this.attributes[r]){s.plugins.push(r);if(this.getAttribute(r)&&JSON.parse(this.getAttribute(r))){s[r]=JSON.parse(this.getAttribute(r))}}}for(r in i.jstree.defaults.core){if(i.jstree.defaults.core.hasOwnProperty(r)&&this.attributes[r]){s.core[r]=JSON.parse(this.getAttribute(r))||this.getAttribute(r)}}i(this).jstree(s)};try{o.registerElement("vakata-jstree",{prototype:k})}catch(m){}}}));(function(a){if(typeof define==="function"&&define.amd){define("jstree.primary_selected",["jquery","jstree"],a)}else{if(typeof exports==="object"){a(require("jquery"),require("jstree"))}else{a(jQuery,jQuery.jstree)}}}(function(b,a,c){if(b.jstree.plugins.primary_selected){return}b.jstree.plugins.primary_selected=function(d,e){this.ensure_sole_selected=function(f){f=this.get_node(f);if(this.get_selected()[0]==f.id){return}this.deselect_all();this.select_node(f)};this.primary=function(f){f(this.get_primary_selected(true))};this.get_primary_selected_dom=function(){return this.get_node(this.get_primary_selected(),true)};this.get_primary_selected=function(g){var f=this._data.core.primary_selected;if(typeof(f)==="undefined"){return false}return g?this.get_node(f):f};this.set_primary_selected=function(j,f){if(j==="#"){var h=this.get_node(j);j=h.children[0]}j=this.get_node(j);if(!j||j.id==="#"){return false}if(this._data.core.primary_selected){var g=this.get_node(this._data.core.primary_selected);if(g){g.state.primary_selected=false;var i=this.get_node(g,true);i.removeClass("primary-selected")}this._data.core.primary_selected=c}var k=this.get_node(j,true);if(!j.state.primary_selected){j.state.primary_selected=true;this._data.core.primary_selected=j.id;if(k&&k.length){k.addClass("primary-selected")}}this.ensure_sole_selected(j);if(typeof(f)!="undefined"){f(j)}};this.refresh_primary_selected=function(){this.set_primary_selected(this.get_primary_selected())}}}));(function(a){a.jstree.defaults.select_limit=20;a.jstree.plugins.select_limit=function(b,c){this.select_node=function(e,f,d){if(this.settings.select_limit>this.get_selected().length){c.select_node.call(this,e,f,d)}}}})(jQuery);$(function(){var p;var v=$("#archives_tree"),h=$("#object_container"),f=$("#archives_tree_toolbar");if(v.length===0){return}var G=[];var b=null;var s=[];$(document).bind("loadedrecordform.aspace",function(){if(!C.read_only){AS.tree_data.moveable=true}});if(v.length<1){return}var B;var C={root_object_id:v.data("root-id"),root:v.data("root"),root_node_type:v.data("root-node-type"),read_only:$(".archives-tree").data("read-only"),rules:$(".archives-tree").data("rules")};var t=function(O){h.html(O);var N=$("form",h);N.data("form_changed",false);$(".btn-primary",N).attr("disabled","disabled");$(".btn-cancel",N).attr("disabled","disabled");N.on("formchanged.aspace",function(){$(".btn-primary",N).removeAttr("disabled");$(".btn-cancel",N).removeAttr("disabled")});N.on("formreverted.aspace",function(P,Q){if($("form",h).data("form_changed")){var R=d(p.get_primary_selected());R.done(function(S){if(S){$(window).trigger("hashchange");$.scrollTo("header")}return})}});$(".btn-plus-one",N).click(function(P){P.preventDefault();P.stopImmediatePropagation();var Q=function(R,S){if(S.success){$(".archives-tree-container .add-sibling").trigger("click")}};N.data("createPlusOne",true);h.one("submitted",Q);N.triggerHandler("submit")});$(document).triggerHandler("loadedrecordform.aspace",[h]);$(".record-toolbar .revert-changes .btn",N).off().click(function(P){P.preventDefault();P.stopImmediatePropagation();N.trigger("formreverted.aspace")});$(".btn-cancel",N).html(AS.renderTemplate("tree_revert_changes_label_template")).off().click(function(P){P.preventDefault();P.stopImmediatePropagation();N.trigger("formreverted.aspace")});N.ajaxForm({data:{inline:true},beforeSubmit:function(P,Q){$(".btn-primary",Q).attr("disabled","disabled");if(Q.data("createPlusOne")){P.push({name:"plus_one",value:"true",required:false,type:"text"})}},success:function(R,P,S){var Q=t(R);if(Q.data("formErrors")){h.triggerHandler("submitted",{success:false});Q.data("form_changed",true);$(".btn-primary, .btn-cancel",Q).removeAttr("disabled")}else{Q.data("form_changed",false);h.triggerHandler("submitted",{success:true})}if(Q.data('"update-monitor-paused"')){Q.data("update-monitor-paused",false)}$.scrollTo("header")},error:function(R,Q,P){h.prepend("<div class='alert alert-error'><p>An error occurred saving this record.</p><pre>"+P+"</pre></div>");h.triggerHandler("submitted",{success:false});$(".btn-primary",N).removeAttr("disabled")}});AS.resetScrollSpy();return N};var n=function(){var N=$(AS.renderTemplate("tree_loading_notice_template"));N.hide();h.prepend(N);N.fadeIn();$(":input",h).attr("disabled","disabled")};var L=function(){$("#archives_tree_overlay").height("100%")};var E=function(){$("#archives_tree_overlay").height("0%")};var k=function(){$(".archives-tree-container .spinner").toggle()};var q=function(P,N){var O=N.match(/node_uri=([^&]*)/gm)[0].replace("node_uri=","");if(O==="root"){return P}else{if(O===P.record_uri){return(typeof(P.children)==="object"&&P.children.length>0)?P.children:[]}else{if(_.isUndefined(P)){return false}else{return q(_.find(P.children,function(Q){return(typeof(Q.children)==="object"&&Q.children.length>0)}),N)}}}};var F=function(){return p.get_primary_selected_dom()};var o=function(){return p.get_path(p.get_primary_selected(),false,true)};var A=function(P,O){P=P||false;var N=p.get_selected(P);if(P&&O){return _.sortBy(N,function(Q){return u(Q)})}else{return N}};var u=function(N){N=_.isString(N)?p.get_node(N):N;if(!N.parent){return false}return _(p.get_node(N.parent).children).findIndex(function(O){return O===N.id})};var c=function(){var N=$(".tree-loading-notice");N.fadeOut();N.remove();$(":input",h).removeAttr("disabled")};var D=function(N){N=_.isString(N)?p.get_node(N):N;return u(N)>(p.get_node(N.parent).children.length-2)};var w=function(N){return p.get_node(N.parent).children[u(N)-1]};var M=function(N){return p.get_node(N.parent).children[u(N)+1]};var r=function(O){var N=p.get_node(O,true);n();if(C.read_only){var R={};R.inline=true;R[C.root_node_type+"_id"]=C.root_object_id;$.ajax({url:APP_PATH+O.type+"s/"+O.id.replace(/.*_/,""),type:"GET",data:R,success:function(S){h.html(S);AS.resetScrollSpy();$(document).trigger("loadedrecordform.aspace",[h])},error:function(U,T,S){h.html("<div class='alert alert-error'><p>An error occurred loading this form.</p><pre>"+S+"</pre></div>")}});return}if(O.id==="new"){var P={inline:true};P[C.root_node_type+"_id"]=C.root_object_id;var Q=N.parents("li:first");if(Q.attr("rel")===N.attr("rel")){P[Q.attr("rel")+"_id"]=Q.data("id")}if(N.data("params")){P=$.extend({},P,N.data("params"))}$.ajax({url:APP_PATH+O.type+"s/new",data:P,type:"GET",success:function(S){t(S)},error:function(){h.html("<div class='alert alert-error'><p>An error occurred loading this form.</p><pre>"+errorDesc+"</pre></div>")}})}else{if(O.type){$.ajax({url:APP_PATH+O.type+"s/"+O.id.replace(/.*_/,"")+"/edit?inline=true",success:function(S){t(S)},error:function(U,T,S){h.html("<div class='alert alert-error'><p>An error occurred loading this record.</p><pre>"+S+"</pre></div>")}})}}};var J=function(P){var O=p.get_primary_selected(true);var Q={config:C};var N=u(O);if(N&&N!==0){Q.previous=w(O)}else{if(O.parent){Q.previous=O.parent}}if(O.children&&O.children.length>0){Q.next=O.children[0]}else{if(!D(O)){Q.next=M(O)}}$(".btn-toolbar",f).append(AS.renderTemplate("tree_nodenavigation_toolbar_template",Q))};var m=function(S){var S=p.get_node(S);var P=p.get_node(S,true);f.html(AS.renderTemplate("tree_toolbar_template"));J();if(C.read_only!==true&&P.attr("id")!="new"){var N={config:C,rules:C.rules[S.type],node_id:S.id.replace(/.*_/,""),root_object_id:C.root_object_id,up_level:S.parents.length>2};if(S.parent){var Q=p.get_node(p.get_parent(S));N.parent_id=Q.id;N.parent=Q;N.is_first=Q.children[0]===S.id;N.is_last=_.last(Q.children)===S.id;N.siblings=_(Q.children).filter(function(T){return T!=S.id}).map(function(T){T=p.get_node(T);return{id:T.id,title:T.original.title}}).value()}var O=$(AS.renderTemplate("tree_nodeactions_toolbar_template",N));$(".btn-toolbar",f).append(O);var R=$(AS.renderTemplate("tree_finish_action_template",N));$(".btn-success",R).click(function(U){U.preventDefault();U.stopImmediatePropagation();var T=$(this).attr("href");if($("form",h).data("form_changed")){var V=d(p.get_primary_selected_dom());V.done(function(W){if(W){window.location=T}})}else{window.location=T}});$(document).on("formclosed.aspace",function(){R.trigger("click")});$(".btn-toolbar",f).append(R);$("a",f).on("focus",function(){if($(this).parents("li.dropdown-submenu").length){$(".dropdown-menu",$(this).parent()).show()}else{$(".dropdown-submenu .dropdown-menu",$(this).parents(".nav")).css("display","")}});$(".dropdown-submenu > a",f).on("keyup",function(T){if(T.keyCode===39){$(".dropdown-menu a:first",$(this).parent()).focus()}});$(".dropdown-submenu > .dropdown-menu > li > a",f).on("keyup",function(){if(event.keyCode===37){$("> a",$(this).parents(".dropdown-submenu:first")).focus()}});if(v.data("clipboard")){if(!_.intersection(o(),v.data("clipboard")).length){$(".paste-node",f).removeAttr("disabled").removeClass("disabled")}}$(".cut-node",f).removeAttr("disabled").removeClass("disabled");e();$(document).trigger("loadedrecordform.aspace",[f])}};var z=function(N){if(N.indexOf("tree::")<0){tree_node_id="tree::"+N}else{tree_node_id=N}if(location.hash.length<1||location.hash==="#"+N||location.hash===N||location.hash===tree_node_id){j(tree_node_id)}else{location.hash=tree_node_id}};var j=function(N){$(window).data("ignore-hashchange",true);$(".locked").removeClass("locked");location.hash=N};var K=function(){var P;$(".locked").removeClass("locked");if($(":focus").length>0&&$(":focus").closest(f).length>0){P=$(":focus").attr("class")}if($(window).data("ignore-hashchange")){$(window).data("ignore-hashchange",false);return}if(!location.hash||location.hash.indexOf("tree::")===-1){return}var O=location.hash.replace("#tree::","");p.set_primary_selected(O,function(Q){if(!Q.state.opened){p.open_node(Q,function(R){r(R);m(R)})}else{r(Q);m(Q)}});if(P){var N=$("[class='"+P+"']");if(N.is("[disabled]")){$(".btn:not([disabled]):first",f).focus()}else{$("[class='"+P+"']").focus()}}};var I=function(P,S,Q,N){var O={id:"new",node_type:S,type:S,text:Q.record_label,icon:"glyphicon glyphicon-asterisk",a_attr:{href:"#new"},li_attr:{rel:S,"class":"new","data-params":N?N:""}};var R=p.create_node(P,O,"last");z("new")};var g=function(){var N=$("#archives_tree").parent().height()-f.outerHeight()-21;$("#archives_tree").height(N)};var e=function(){if(p.get_primary_selected(true).parents.length<3){$(".move-node-up-level",f).attr("disabled","disabled").addClass("disabled")}};var x=function(){$(".archives-tree-container").on("click",".add-child",function(){if(!p.get_primary_selected()){return}var N=p.get_primary_selected();var O=p.get_primary_selected(true).original.type;I(N,$(this).attr("rel"),C.rules[O].can_add_child)});$(".archives-tree-container").on("click",".add-sibling",function(){if(!p.get_primary_selected()){return}var O=p.get_primary_selected(true).parent;var N=p.get_primary_selected(true).type;var P=p.get_node(O).type;I(O,N,C.rules[P].can_add_child)});h.on("click",".btn-cancel",function(N){N.preventDefault();N.stopImmediatePropagation();if($(this).attr("disabled")){return}if(F().attr("id")==="new"){z(F().parents("li:first").attr("id"))}else{r(p.get_primary_selected(true))}});$(".archives-tree-container").on("click",".expand-tree .btn",function(){$(".archives-tree-container").addClass("expanded");$(".archives-tree-container").animate({width:$(".archives-tree-container").parents(".container:first").width()-5},500)});$(".archives-tree-container").on("click",".retract-tree .btn",function(){$(".archives-tree-container").animate({width:$(".archives-tree-container").parent().width()},500,function(){$(".archives-tree-container").removeClass("expanded");$(".archives-tree-container").css("width","auto")})});$(".archives-tree-container").on("click",".move-node",function(S){S.preventDefault();S.stopPropagation();var O;var P;var N=function(){O=A(true,true);P=O[0]};N();switch($(this).attr("rel")){case"down":if(P===undefined){N()}var Q=P.parent;var R=u(P)+O.length+1;p.move_node(O,Q,R);break;case"up":if(P===undefined){N()}var Q=P.parent;var R=u(P)-1;if(R>-1){p.move_node(O,Q,R)}break;case"down-into":var Q=$(this).data("target-node-id");p.move_node(O,Q,0);p.open_node(Q);break;case"up-level":var Q=p.get_path(P,false,true).slice(-3,-2);p.move_node(O,Q,0);break}});$(".archives-tree-container").on("click",".transfer-node",function(N){if($(".tree-transfer-form",".archives-tree-container")[0].style.display==="block"){$(".tree-transfer-form",".archives-tree-container").css("display","");$(".missing-ref-message",".archives-tree-container .tree-transfer-form form").hide();$(".token-input-dropdown").hide()}else{$(".tree-transfer-form",".archives-tree-container").css("display","block");$(".tree-transfer-form form",".archives-tree-container").unbind("submit").submit(function(O){if($(this).serializeObject()["transfer[ref]"]){return}else{O.stopPropagation();O.preventDefault();$(".missing-ref-message",".archives-tree-container .tree-transfer-form form").show();return true}});setTimeout(function(){$("#token-input-transfer_ref_",".archives-tree-container").focus()})}});$(".archives-tree-container").on("click",".tree-transfer-form :input",function(N){N.stopPropagation()});$(".archives-tree-container").on("click",".tree-transfer-form .dropdown-toggle",function(N){N.stopPropagation();$(this).parent().toggleClass("open")});$(".archives-tree-container").on("click",".tree-transfer-form .btn-cancel",function(N){$(".tree-transfer-form",".archives-tree-container").css("display","");$(".transfer-node",".archives-tree-container").parent().removeClass("open")});$(".archives-tree-container").on("click",".cut-node",function(N){N.preventDefault();if($(this).hasClass("disabled")){return}_.forEach(p.get_selected(),function(O){p.get_node(O,true).addClass("cut-to-clipboard")});$(".cut-to-clipboard",v).removeClass("cut-to-clipboard");v.data("clipboard",p.get_selected());$(this).addClass("disabled").addClass("btn-success")}).on("click",".paste-node",function(N){N.preventDefault();if($(this).hasClass("disabled")||!v.data("clipboard")){return}var O=p.get_primary_selected();p.move_node(v.data("clipboard"),O);v.data("clipboard",null);$(this).addClass("disabled");$(".cut-to-clipboard",v).removeClass("cut-to-clipboard")});$(".archives-tree-container").on("click",".add-children",function(){var N=F();if(N.length===0){return}$(document).triggerHandler("rdeshow.aspace",[N,$(this)])});$(".archives-tree-container").on("click",".refresh-tree",function(N){N.preventDefault();N.stopImmediatePropagation();p.refresh()});$(window).hashchange(K);$("#archives_tree").scroll(function(){if($(this).scrollTop()===0){$(this).removeClass("overflow")}else{$(this).addClass("overflow")}});if(AS.prefixed_cookie("archives-tree-container::height")){$(".archives-tree-container").height(AS.prefixed_cookie("archives-tree-container::height"))}else{$(".archives-tree-container").height(AS.DEFAULT_TREE_PANE_HEIGHT)}$(".archives-tree-container").resizable({handles:"s",minHeight:80,resize:function(N,O){AS.prefixed_cookie("archives-tree-container::height",O.size.height);g();$(window).triggerHandler("resize.tree")}})};var a=function(R){var Q;L();k();$(document).triggerHandler("lockform.aspace",[h]);if(typeof R[0]==="string"){R=_.map(R,function(U){return p.get_node(U)});Q=0}else{R=_.sortBy(R,function(U){return U.position});var P=R[0];Q=P.position;if((P.parent===P.old_parent)&&(P.position>P.old_position)){Q-=R.length-1}}var S=p.get_node(R[0].parent);var O=p.get_node(S,true);if(_.uniq(_.map(R,function(U){return U.parent})).length>1){return false}var N=_.map(R,function(U){if(_.has(U,"node")){return U.node.original.record_uri}else{return U.original.record_uri}});var T={children:N,index:Q};$.ajax({url:APP_PATH+S.type+"s/"+S.id.replace(/.*_/,"")+"/accept_children",type:"POST",data:T,success:function(W,U,V){if(T.index!==W.position){p.refresh();AS.openQuickModal(AS.renderTemplate("tree_unable_to_move_message_template"),V.responseText)}else{p.refresh_primary_selected();p.primary(function(aa){var X=p.get_node(aa,true);if(N.indexOf(aa.original.record_uri)>=0){var Z=$("input.hidden-parent-uri",h);if(S.type===aa.type){Z.attr("name",aa.type+"[parent][ref]");Z.val(S.original.record_uri)}else{Z.attr("name",aa.type+"[parent]");Z.val(null)}}$("#"+X.attr("rel")+"_position_",h).val(X.index());s=S.children;var Y=p.get_selected();setTimeout(function(){E();k();p.select_node(Y)},1000);if(S.parent==="#"){parent=p.get_node(p.get_parent(s[0]));p.refresh_node(parent)}else{p.refresh_node(S)}$(document).triggerHandler("unlockform.aspace",[h])})}},error:function(U,W,V){p.refresh();AS.openQuickModal(AS.renderTemplate("tree_unable_to_move_message_template"))}})};var d=function(Q){var P=p.get_node(Q);var N=p.get_node(P,true);var R=$.Deferred();var O;if(N.attr("id")==="new"){O=N.parents("li:first").attr("id")}AS.openCustomModal("saveYourChangesModal","Save Your Changes",AS.renderTemplate("save_changes_modal_template"));$("#saveChangesButton","#saveYourChangesModal").on("click",function(){var S=$("form",h);S.triggerHandler("submit");var T=function(){S.data("form_changed",false);z(P.id);$("#saveYourChangesModal").modal("hide");R.resolve(true)};var U=function(){$("#saveYourChangesModal").modal("hide");R.resolve(false)};h.one("submitted",function(V,W){if(W.success){T()}else{U()}})});$("#dismissChangesButton","#saveYourChangesModal").on("click",function(){$("form",h).data("form_changed",false);if(N.attr("id")!="new"){v.jstree("delete_node",$("#new",v))}$("#saveYourChangesModal").modal("hide");R.resolve(true)});$(".btn-cancel","#saveYourChangesModal").on("click",function(){if(N.attr("id")==="new"){v.jstree("delete_node",$("#new",v))}R.resolve(false)});return R.promise()};var y=function(){$(".selected",v).removeClass("selected");if(p.get_selected().length>1){$.each(p.get_selected(),function(O,P){$nodeEl=p.get_node(P,true);$nodeEl.addClass("selected");$(".selected-order",$nodeEl).html(O+1).show()});v.trigger("treemultipleselected.aspace")}else{if(p.get_selected().length===1){p.set_primary_selected(p.get_selected()[0]);var N=p.get_selected(true)[0];if(!N.state.opened){p.open_node(N)}if(N.id!="new"){p.delete_node("new")}z(p.get_primary_selected());$nodeEl=p.get_primary_selected_dom();$nodeEl.addClass("selected");$(".selected-order").empty();$(".selected-order:first",$nodeEl).html(1).show();p.hover_node(p.get_primary_selected());v.trigger("treesingleselected.aspace")}}};var H=function(){if(B){return B}if(location.hash){var P=location.hash.replace("tree::","");if(AS.tree_data.hasOwnProperty(P.replace("#",""))){B=[];var O=P.replace("#","");while(true){var N=AS.tree_data[O];B.push(O);if(N.hasOwnProperty("parent")){O=N.parent}else{B=B.reverse();B.pop();return B}}}}return[]};var i=function(N){if(_.isArray(N)){_.forEach(N,function(O){i(O)})}else{N.text=AS.renderTemplate("tree_node_"+N.node_type+"_template",{node:N});if(_.has(N,"children")&&_.isArray(N.children)){i(N.children)}}};var l=function(N){AS.tree_data={moveable:false};v.jstree({core:{data:function(Q,O){var P=v.data("tree-url");if(Q.id==="#"){P+="?node_uri=root&hash="+location.hash.replace("#","")}else{P+="?node_uri="+Q.original.record_uri}$.ajax(P,{success:function(R){_.tap(q(R,P),function(S){i(S);O(S)})}})},check_callback:function(O,P,R,Q){switch(O){case"create_node":return AS.tree_data.moveable;case"rename_node":return AS.tree_data.moveable;case"move_node":if(AS.tree_data.moveable){if(R.parent==null){return false}else{return true}}else{return false}case"delete_node":return P.id==="new";default:return AS.tree_data.moveable}},animation:0,html_titles:true},types:{"default":{icon:"glyphicon glyphicon-file"},archival_object:{icon:"glyphicon glyphicon-file"},resource:{icon:"glyphicon glyphicon-list-alt"},digital_object_component:{icon:"asicon icon-digital_object_component"},digital_object:{icon:"asicon icon-digital_object"},classification:{icon:"glyphicon glyphicon-file"},classification_term:{icon:"glyphicon glyphicon-file"}},themes:{name:"default",url:false,dots:true},dnd:{drop_target:false,drag_target:false},ui:{selected_parent_close:false,selected_parent_open:true,select_limit:-1,select_multiple_modifier:(navigator.appVersion.indexOf("Mac")!=-1)?"meta":"ctrl",disable_selecting_children:true},crrm:{move:{check_move:function(O){if(C.read_only){return false}if($(O.o[0]).hasClass(C.root_node_type)){return false}if($(O.np[0]).hasClass("archives-tree")){return false}return true}}},hotkeys:{up:false,down:false,"ctrl+up":function(){$(".move-node-up",f).trigger("click")},"shift+up":false,"ctrl+down":function(){$(".move-node-down",f).trigger("click")},"shift+down":false,"ctrl+left":function(){$(".move-node-up-level",f).trigger("click")},"shift+left":false,"ctrl+right":function(){$($(".move-node-down-into",f)[F().index()]).trigger("click")},"shift+right":false,space:false,"ctrl+space":false,"shift+space":false,f2:false,del:false,"return":function(){$(".jstree-hovered",v).trigger("click")}},plugins:["select_limit","primary_selected","types","themes","ui","html_data","crrm","dnd","hotkeys"]}).one("loaded.jstree",function(){p=v.jstree(true);AS._tree=p;if(location.hash){var O=location.hash.replace("#tree::","");p.select_node(O)}if(!p.get_primary_selected()){if(p.get_selected().length>0){p.set_primary_selected(p.get_selected()[0])}else{p.set_primary_selected("#")}}p.primary(function(P){p.open_node(P);m(P)});N()}).bind("select_node.jstree",function(O,P){if($("form",h).data("form_changed")&&P.node.id!=p.get_primary_selected()){var Q=d(p.get_primary_selected());Q.done(function(R){if(R){y()}else{p.refresh_primary_selected()}});Q.fail(function(R){console.log(R)})}else{y()}}).bind("deselect_node.jstree",function(P,Q){var O=v.jstree("get_node",Q.node,true);if(O.hasClass("primary-selected")){v.jstree("select_node",O)}else{O.removeClass("selected")}}).bind("move_node.jstree",function(O,P){if(b){clearTimeout(b)}G.push(P);b=setTimeout(function(){a(G);G=[];y()},50)}).bind("refreshtreenode.aspace",function(T,U){AS.tree_data.moveable=true;var P=U.title||U.text;U.text=AS.renderTemplate("tree_node_"+U.node_type+"_template",{node:U});U.type=U.node_type;var V=U.jsonmodel_type+"_"+U.id;if(U.replace_new_node){if(U.uri&&!U.record_uri){U.record_uri=U.uri}var O=("new"===p.get_primary_selected());var Q=p.get_node("new");var R=Q.parent;U.a_attr={href:"#"+V,title:P};U.li_attr={"data-id":U.id,"data-uri":U.uri,id:V,rel:U.node_type};U.id=V;p.delete_node(Q);var S=p.create_node(R,U,"last",function(W){if(O){p.set_primary_selected(W)}j("#tree::"+V);m(W)})}else{p.rename_node(V,U.text);$("a",p.get_node(V,true)).attr("title",P);p.refresh_primary_selected()}}).on("after_open.jstree",function(P,Q){var O=p.get_primary_selected_dom();if(O&&O.length){O.addClass("primary-selected")}}).on("click",".jstree-leaf a",function(O){if(typeof O.isTrigger=="undefined"){$(this).focus()}})};l(function(){g();p.primary(function(N){if(location.hash.length===0){$(window).data("ignore-hashchange",true)}r(N);setTimeout(function(){v.scrollTo($("#"+N.id),0,{offsetTop:v.height()/2})},0)})});x();AS.refreshTreeNode=function(N){v.triggerHandler("refreshtreenode.aspace",[N])};v.bind("refresh_node.jstree",function(N,O){if(s.length==0){return}var P=O.instance.get_node(O.node.id);happy_family=s.length==P.children.length&&s.every(function(R,Q){return R===P.children[Q]});if(happy_family===false){AS.openQuickModal(AS.renderTemplate("tree_move_ordering_problem_message_template"),s)}s=[]});$(document).bind("readonlytree.aspace",function(N){AS.tree_data.moveable=false});$(document).bind("formreverted.aspace",function(N){AS.tree_data.moveable=true;$(".refresh-tree").click()})});(function(d){var i={method:"GET",queryParam:"q",searchDelay:300,minChars:1,propertyToSearch:"name",jsonContainer:null,contentType:"json",prePopulate:null,processPrePopulate:false,hintText:"Type in a search term",noResultsText:"No results",searchingText:"Searching...",deleteText:"&times;",animateDropdown:true,theme:null,zindex:999,resultsLimit:null,enableHTML:true,resultsFormatter:function(l){var k=l[this.propertyToSearch];return"<li>"+(this.enableHTML?k:a(k))+"</li>"},tokenFormatter:function(l){var k=l[this.propertyToSearch];return"<li><p>"+(this.enableHTML?k:a(k))+"</p></li>"},tokenLimit:null,tokenDelimiter:",",preventDuplicates:false,tokenValue:"id",allowFreeTagging:false,onResult:null,onCachedResult:null,onAdd:null,onFreeTaggingAdd:null,onDelete:null,onReady:null,idPrefix:"token-input-",disabled:false,formatQueryParam:function(l,k){return l},caching:true};var f={tokenList:"token-input-list",token:"token-input-token",tokenReadOnly:"token-input-token-readonly",tokenDelete:"token-input-delete-token",selectedToken:"token-input-selected-token",highlightedToken:"token-input-highlighted-token",dropdown:"token-input-dropdown",dropdownItem:"token-input-dropdown-item",dropdownItem2:"token-input-dropdown-item2",selectedDropdownItem:"token-input-selected-dropdown-item",inputToken:"token-input-input-token",focused:"token-input-focused",disabled:"token-input-disabled"};var h={BEFORE:0,AFTER:1,END:2};var e={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,NUMPAD_ENTER:108,COMMA:null};var j={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"};var g=/[&<>"'\/]/g;function c(k){return String((k===null||k===undefined)?"":k)}function a(k){return c(k).replace(g,function(l){return j[l]})}var b={init:function(k,l){var m=d.extend({},i,l||{});return this.each(function(){d(this).data("settings",m);d(this).data("tokenInputObject",new d.TokenList(this,k,m))})},clear:function(){this.data("tokenInputObject").clear();return this},add:function(k){this.data("tokenInputObject").add(k);return this},remove:function(k){this.data("tokenInputObject").remove(k);return this},get:function(){return this.data("tokenInputObject").getTokens()},toggleDisabled:function(k){this.data("tokenInputObject").toggleDisabled(k);return this},setOptions:function(k){d(this).data("settings",d.extend({},d(this).data("settings"),k||{}));return this}};d.fn.tokenInput=function(k){if(b[k]){return b[k].apply(this,Array.prototype.slice.call(arguments,1))}else{return b.init.apply(this,arguments)}};d.TokenList=function(o,y,Z){if(d.type(y)==="string"||d.type(y)==="function"){d(o).data("settings").url=y;var s=D();if(d(o).data("settings").crossDomain===undefined&&typeof s==="string"){if(s.indexOf("://")===-1){d(o).data("settings").crossDomain=false}else{d(o).data("settings").crossDomain=(location.href.split(/\/+/g)[1]!==s.split(/\/+/g)[1])}}}else{if(typeof(y)==="object"){d(o).data("settings").local_data=y}}if(d(o).data("settings").classes){d(o).data("settings").classes=d.extend({},f,d(o).data("settings").classes)}else{if(d(o).data("settings").theme){d(o).data("settings").classes={};d.each(f,function(af,ag){d(o).data("settings").classes[af]=ag+"-"+d(o).data("settings").theme})}else{d(o).data("settings").classes=f}}var L=[];var B=0;var x=new d.TokenList.Cache();var X;var T;var F=d('<input type="text"  autocomplete="off">').css({outline:"none"}).attr("id",d(o).data("settings").idPrefix+o.id).focus(function(){if(d(o).data("settings").disabled){return false}else{if(d(o).data("settings").tokenLimit===null||d(o).data("settings").tokenLimit!==B){r()}}v.addClass(d(o).data("settings").classes.focused)}).blur(function(){M();d(this).val("");v.removeClass(d(o).data("settings").classes.focused);if(d(o).data("settings").allowFreeTagging){n()}else{d(this).val("")}v.removeClass(d(o).data("settings").classes.focused)}).bind("keyup keydown blur update",l).keydown(function(ag){var ai;var af;switch(ag.keyCode){case e.LEFT:return true;case e.RIGHT:return true;case e.UP:case e.DOWN:if(!d(this).val()){ai=t.prev();af=t.next();if((ai.length&&ai.get(0)===J)||(af.length&&af.get(0)===J)){if(ag.keyCode===e.LEFT||ag.keyCode===e.UP){Q(d(J),h.BEFORE)}else{Q(d(J),h.AFTER)}}else{if((ag.keyCode===e.LEFT||ag.keyCode===e.UP)&&ai.length){aa(d(ai.get(0)))}else{if((ag.keyCode===e.RIGHT||ag.keyCode===e.DOWN)&&af.length){aa(d(af.get(0)))}}}}else{var ah=null;if(ag.keyCode===e.DOWN||ag.keyCode===e.RIGHT){ah=d(V).next()}else{ah=d(V).prev()}if(ah.length){ad(ah)}}return false;case e.BACKSPACE:ai=t.prev();if(!d(this).val().length){if(J){q(d(J));K.change()}else{if(ai.length){aa(d(ai.get(0)))}}return false}else{if(d(this).val().length===1){M()}else{setTimeout(function(){I()},5)}}break;case e.TAB:return true;case e.ENTER:if(V){S(d(V).data("tokeninput"));K.change()}else{d(o).trigger("tokeninput.enter")}ag.stopPropagation();ag.preventDefault();break;case e.NUMPAD_ENTER:case e.COMMA:if(V){S(d(V).data("tokeninput"));K.change()}else{if(d(o).data("settings").allowFreeTagging){n()}ag.stopPropagation();ag.preventDefault()}return false;case e.ESCAPE:M();return true;default:if(String.fromCharCode(ag.which)){setTimeout(function(){I()},5)}break}});var K=d(o).hide().val("").focus(function(){ae(F)}).blur(function(){F.blur()});var J=null;var N=0;var V=null;var v=d("<ul />").addClass(d(o).data("settings").classes.tokenList).click(function(ag){var af=d(ag.target).closest("li");if(af&&af.get(0)&&d.data(af.get(0),"tokeninput")){ac(af)}else{if(J){Q(d(J),h.END)}ae(F)}}).mouseover(function(ag){var af=d(ag.target).closest("li");if(af&&J!==this){af.addClass(d(o).data("settings").classes.highlightedToken)}}).mouseout(function(ag){var af=d(ag.target).closest("li");if(af&&J!==this){af.removeClass(d(o).data("settings").classes.highlightedToken)}}).insertBefore(K);var t=d("<li />").addClass(d(o).data("settings").classes.inputToken).appendTo(v).append(F);var ab=d("<div>").addClass(d(o).data("settings").classes.dropdown).appendTo("body").hide();var R=d("<tester/>").insertAfter(F).css({position:"absolute",top:-9999,left:-9999,width:"auto",fontSize:F.css("fontSize"),fontFamily:F.css("fontFamily"),fontWeight:F.css("fontWeight"),letterSpacing:F.css("letterSpacing"),whiteSpace:"nowrap"});K.val("");var E=d(o).data("settings").prePopulate||K.data("pre");if(d(o).data("settings").processPrePopulate&&d.isFunction(d(o).data("settings").onResult)){E=d(o).data("settings").onResult.call(K,E)}if(E&&E.length){d.each(E,function(af,ag){p(ag);O()})}if(d(o).data("settings").disabled){H(true)}if(d.isFunction(d(o).data("settings").onReady)){d(o).data("settings").onReady.call()}this.clear=function(){v.children("li").each(function(){if(d(this).children("input").length===0){q(d(this))}})};this.add=function(af){S(af)};this.remove=function(af){v.children("li").each(function(){if(d(this).children("input").length===0){var ai=d(this).data("tokeninput");var ag=true;for(var ah in af){if(af[ah]!==ai[ah]){ag=false;break}}if(ag){q(d(this))}}})};this.getTokens=function(){return L};this.toggleDisabled=function(af){H(af)};function k(af){return d(o).data("settings").enableHTML?af:a(af)}function H(af){if(typeof af==="boolean"){d(o).data("settings").disabled=af}else{d(o).data("settings").disabled=!d(o).data("settings").disabled}F.attr("disabled",d(o).data("settings").disabled);v.toggleClass(d(o).data("settings").classes.disabled,d(o).data("settings").disabled);if(J){Q(d(J),h.END)}K.attr("disabled",d(o).data("settings").disabled)}function O(){if(d(o).data("settings").tokenLimit!==null&&B>=d(o).data("settings").tokenLimit){F.hide();M();return}}function l(){if(T===(T=F.val())){return}R.html(a(T));F.width(R.width()+30)}function Y(af){return((af>=48&&af<=90)||(af>=96&&af<=111)||(af>=186&&af<=192)||(af>=219&&af<=222))}function n(){var af=d.trim(F.val());var ag=af.split(d(o).data("settings").tokenDelimiter);d.each(ag,function(aj,ai){if(!ai){return}if(d.isFunction(d(o).data("settings").onFreeTaggingAdd)){ai=d(o).data("settings").onFreeTaggingAdd.call(K,ai)}var ah={};ah[d(o).data("settings").tokenValue]=ah[d(o).data("settings").propertyToSearch]=ai;S(ah)})}function p(ag){var ai=d(d(o).data("settings").tokenFormatter(ag));var af=ag.readonly===true?true:false;if(af){ai.addClass(d(o).data("settings").classes.tokenReadOnly)}ai.addClass(d(o).data("settings").classes.token).insertBefore(t);if(!af){d("<span>"+d(o).data("settings").deleteText+"</span>").addClass(d(o).data("settings").classes.tokenDelete).appendTo(ai).click(function(){if(!d(o).data("settings").disabled){q(d(this).parent());K.change();return false}})}var ah=ag;d.data(ai.get(0),"tokeninput",ag);L=L.slice(0,N).concat([ah]).concat(L.slice(N));N++;C(L,K);B+=1;if(d(o).data("settings").tokenLimit!==null&&B>=d(o).data("settings").tokenLimit){F.hide();M()}return ai}function S(af){var ah=d(o).data("settings").onAdd;if(B>0&&d(o).data("settings").preventDuplicates){var ag=null;v.children().each(function(){var aj=d(this);var ai=d.data(aj.get(0),"tokeninput");if(ai&&ai.id===af.id){ag=aj;return false}});if(ag){aa(ag);t.insertAfter(ag);ae(F);return}}if(d(o).data("settings").tokenLimit===null||B<d(o).data("settings").tokenLimit){p(af);O()}F.val("");M();if(d.isFunction(ah)){ah.call(K,af)}}function aa(af){if(!d(o).data("settings").disabled){af.addClass(d(o).data("settings").classes.selectedToken);J=af.get(0);F.val("");M()}}function Q(ag,af){ag.removeClass(d(o).data("settings").classes.selectedToken);J=null;if(af===h.BEFORE){t.insertBefore(ag);N--}else{if(af===h.AFTER){t.insertAfter(ag);N++}else{t.appendTo(v);N=B}}ae(F)}function ac(ag){var af=J;if(J){Q(d(J),h.END)}if(af===ag.get(0)){Q(ag,h.END)}else{aa(ag)}}function q(ag){var ah=d.data(ag.get(0),"tokeninput");var ai=d(o).data("settings").onDelete;var af=ag.prevAll().length;if(af>N){af--}ag.remove();J=null;ae(F);L=L.slice(0,af).concat(L.slice(af+1));if(af<N){N--}C(L,K);B-=1;if(d(o).data("settings").tokenLimit!==null){F.show().val("");ae(F)}if(d.isFunction(ai)){ai.call(K,ah)}}function C(ah,af){var ag=d.map(ah,function(ai){if(typeof d(o).data("settings").tokenValue=="function"){return d(o).data("settings").tokenValue.call(this,ai)}return ai[d(o).data("settings").tokenValue]});af.val(ag.join(d(o).data("settings").tokenDelimiter))}function M(){ab.hide().empty();V=null}function w(){ab.css({position:"absolute",top:d(v).offset().top+d(v).outerHeight(),left:d(v).offset().left,width:d(v).outerWidth(),"z-index":d(o).data("settings").zindex}).show()}function u(){if(d(o).data("settings").searchingText){ab.html("<p>"+k(d(o).data("settings").searchingText)+"</p>");w()}}function r(){if(d(o).data("settings").hintText){ab.html("<p>"+k(d(o).data("settings").hintText)+"</p>");w()}}var P=new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g");function W(af){return af.replace(P,"\\$&")}function A(ag,af){return ag.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+W(af)+")(?![^<>]*>)(?![^&;]+;)","gi"),function(ah,ai){return"<b>"+k(ai)+"</b>"})}function G(ag,ah,af){return ag.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+W(ah)+")(?![^<>]*>)(?![^&;]+;)","g"),A(ah,af))}function U(ah,af){if(af&&af.length){ab.empty();var ag=d("<ul>").appendTo(ab).mouseover(function(ai){ad(d(ai.target).closest("li"))}).mousedown(function(ai){S(d(ai.target).closest("li").data("tokeninput"));K.change();return false}).hide();if(d(o).data("settings").resultsLimit&&af.length>d(o).data("settings").resultsLimit){af=af.slice(0,d(o).data("settings").resultsLimit)}d.each(af,function(ai,aj){var ak=d(o).data("settings").resultsFormatter(aj);ak=G(ak,aj[d(o).data("settings").propertyToSearch],ah);ak=d(ak).appendTo(ag);if(ai%2){ak.addClass(d(o).data("settings").classes.dropdownItem)}else{ak.addClass(d(o).data("settings").classes.dropdownItem2)}if(ai===0){ad(ak)}d.data(ak.get(0),"tokeninput",aj)});w();if(d(o).data("settings").animateDropdown){ag.slideDown("fast")}else{ag.show()}}else{if(d(o).data("settings").noResultsText){ab.html("<p>"+k(d(o).data("settings").noResultsText)+"</p>");w()}}}function ad(af){if(af){if(V){m(d(V))}af.addClass(d(o).data("settings").classes.selectedDropdownItem);V=af.get(0)}}function m(af){af.removeClass(d(o).data("settings").classes.selectedDropdownItem);V=null}function I(){var af=F.val();if(af&&af.length){if(J){Q(d(J),h.AFTER)}if(af.length>=d(o).data("settings").minChars){u();clearTimeout(X);X=setTimeout(function(){z(af)},d(o).data("settings").searchDelay)}else{M()}}}function z(al){var ah=al+D();var af=x.get(ah);if(af){if(d.isFunction(d(o).data("settings").onCachedResult)){af=d(o).data("settings").onCachedResult.call(K,af)}U(al,af)}else{if(d(o).data("settings").url){var aj=D();var ai={};ai.data={};if(aj.indexOf("?")>-1){var am=aj.split("?");ai.url=am[0];var ag=am[1].split("&");d.each(ag,function(an,ap){var ao=ap.split("=");ai.data[ao[0]]=ao[1]})}else{ai.url=aj}ai.data[d(o).data("settings").queryParam]=d(o).data("settings").formatQueryParam(al,ai);ai.type=d(o).data("settings").method;ai.dataType=d(o).data("settings").contentType;if(d(o).data("settings").crossDomain){ai.dataType="jsonp"}ai.success=function(an){if(d(o).data("settings").caching){x.add(ah,d(o).data("settings").jsonContainer?an[d(o).data("settings").jsonContainer]:an)}if(d.isFunction(d(o).data("settings").onResult)){an=d(o).data("settings").onResult.call(K,an)}if(F.val()===al){U(al,d(o).data("settings").jsonContainer?an[d(o).data("settings").jsonContainer]:an)}};d.ajax(ai)}else{if(d(o).data("settings").local_data){var ak=d.grep(d(o).data("settings").local_data,function(an){return an[d(o).data("settings").propertyToSearch].toLowerCase().indexOf(al.toLowerCase())>-1});x.add(ah,ak);if(d.isFunction(d(o).data("settings").onResult)){ak=d(o).data("settings").onResult.call(K,ak)}U(al,ak)}}}}function D(){var af=d(o).data("settings").url;if(typeof d(o).data("settings").url=="function"){af=d(o).data("settings").url.call(d(o).data("settings"))}return af}function ae(af){setTimeout(function(){af.focus()},50)}};d.TokenList.Cache=function(l){var n=d.extend({max_size:500},l);var o={};var m=0;var k=function(){o={};m=0};this.add=function(q,p){if(m>n.max_size){k()}if(!o[q]){m+=1}o[q]=p};this.get=function(p){return o[p]}}}(jQuery));$(function(){$.fn.linker=function(){$(this).each(function(){var h=$(this);var l=h.parents(".linker-wrapper:first");if(h.hasClass("initialised")){return}h.addClass("initialised");$(".prelinker",l).remove();var a={url:decodeURIComponent(h.data("url")),browse_url:decodeURIComponent(h.data("browse-url")),format_template:h.data("format_template"),format_template_id:h.data("format_template_id"),format_property:h.data("format_property"),path:h.data("path"),name:h.data("name"),multiplicity:h.data("multiplicity")||"many",label:h.data("label"),label_plural:h.data("label_plural"),modal_id:h.data("modal_id")||(h.attr("id")+"_modal"),sortable:h.data("sortable")===true,types:h.data("types"),exclude_ids:h.data("exclude")||[]};a.allow_multiple=a.multiplicity==="many";if(a.format_template&&a.format_template.substring(0,2)!="${"){a.format_template="${"+a.format_template+"}"}var i=function(m){var n=$("#"+a.modal_id);var o=function(p){$(".linker-container",n).html(p);$("#createAndLinkButton",n).removeAttr("disabled");$("form",n).ajaxForm({data:{inline:true},beforeSubmit:function(){$("#createAndLinkButton",n).attr("disabled","disabled")},success:function(r,q,s){if($(r).is("form")){o(r)}else{if(a.multiplicity==="one"){e()}h.tokenInput("add",{id:r.uri,name:r.display_string||r.title,json:r});h.triggerHandler("change");n.modal("hide")}},error:function(s,r,q){$("#createAndLinkButton",n).removeAttr("disabled")}});n.scrollTo(".alert");n.trigger("resize");$(document).triggerHandler("loadedrecordform.aspace",[n])};$.ajax({url:m,success:o});$("#createAndLinkButton",n).click(function(){$("form",n).triggerHandler("submit")})};var f=function(){AS.openCustomModal(a.modal_id,"Create "+a.label,AS.renderTemplate("linker_createmodal_template",a),"large",{},this);if($(this).hasClass("linker-create-btn")){i($(this).data("target"))}else{i($(".linker-create-btn:first",l).data("target"))}return false};var j=function(){var o={};var n=function(p){$.each(h.tokenInput("get"),function(){o[this.id]=this.json});$.ajax({url:a.browse_url,data:{page:1,type:a.types,linker:true,exclude:a.exclude_ids,multiplicity:a.multiplicity},type:"GET",dataType:"html",success:function(s){var r=$("#"+a.modal_id);var t=$(".linker-container",r);var q=function(){$(":input[name=linker-item]",t).each(function(){var u=$(this);u.click(function(v){v.stopPropagation();if(!a.allow_multiple){o={};$("tr.selected",u.closest("table")).removeClass("selected")}if(o.hasOwnProperty(u.val())){delete o[u.val()];u.closest("tr").removeClass("selected")}else{o[u.val()]=u.data("object");u.closest("tr").addClass("selected")}});$("td",u.closest("tr")).click(function(v){v.preventDefault();u.trigger("click")})});$.each(o,function(u){$(":input[value='"+u+"']",t).attr("checked","checked").closest("tr").addClass("selected")});r.trigger("resize")};t.html(s);$(t).on("click","a",function(u){u.preventDefault();t.load(u.target.href,q)});$(t).on("submit","form",function(v){v.preventDefault();var u=$(v.target);var w=(u.attr("method")||"get").toUpperCase();if(w=="POST"){jQuery.post(u.attr("action")+".js",u.serializeArray(),function(x){t.html(x);q()})}else{t.load(u.attr("action")+".js?"+u.serialize(),q)}});q()}})};var m=function(){selectedItems=[];$(".token-input-delete-token",l).each(function(){$(this).triggerHandler("click")});$.each(o,function(q,p){h.tokenInput("add",{id:q,name:p.display_string||p.title,json:p})});$("#"+a.modal_id).modal("hide");h.triggerHandler("change")};AS.openCustomModal(a.modal_id,"Browse "+a.label_plural,AS.renderTemplate("linker_browsemodal_template",a),"large",{},this);n();$("#"+a.modal_id).on("click","#addSelectedButton",m);$("#"+a.modal_id).on("click",".linker-list .pagination .navigation a",function(){n($(this).attr("rel"))});return false};var g=function(o){var n=[];var m=[];$.each(h.tokenInput("get"),function(p){m.push(p.id)});$.each(o.search_data.results,function(p,q){if($.inArray(q.uri,m)===-1){n.push({name:q.display_string||q.title,id:q.id,json:q})}});return n};var b=function(){$(".linker-browse-btn",l).on("click",j);$(".linker-create-btn",l).on("click",f);l.one("mouseenter focus",".has-popover",function(){$(document).triggerHandler("init.popovers",[h.parent()])})};var e=function(){var o=$(".token-input-list",h.parent());for(var n=0;n<h.tokenInput("get").length;n++){var m=h.tokenInput("get")[n].id.replace(/\//g,"_");$("#"+m+" :input",o).remove()}h.tokenInput("clear")};var d=function(){if($(".token-input-list",l).data("sortable")){$(".token-input-list",l).sortable("destroy")}$(".token-input-list",l).sortable({items:"li.token-input-token"});$(".token-input-list",l).off("sortupdate").on("sortupdate",function(){h.parents("form:first").triggerHandler("formchanged.aspace")})};var c=function(){if(h.data("multiplicity")==="one"){if($.isEmptyObject(h.data("selected"))){return[]}return[{id:h.data("selected").uri,name:h.data("selected").display_string||h.data("selected").title,json:h.data("selected")}]}else{if(!h.data("selected")||h.data("selected").length===0){return[]}return h.data("selected").map(function(m){return{id:m.uri,name:m.display_string||m.title,json:m}})}};var k=function(){var m=$.extend({},AS.linker_locales,{animateDropdown:false,preventDuplicates:true,allowFreeTagging:false,tokenLimit:(a.multiplicity==="one"?1:null),caching:false,onCachedResult:g,onResult:g,zindex:1100,tokenFormatter:function(o){var n=$(AS.renderTemplate("linker_selectedtoken_template",{item:o,config:a}));$("input[name*=resolved]",n).val(JSON.stringify(o.json));return n},resultsFormatter:function(p){var o=p.name;var n=$("<span class='"+p.json.jsonmodel_type+"'>");n.text(o);n.prepend("<span class='icon-token'></span>");var q=$("<li>");q.append(n);return q[0].outerHTML},prePopulate:c(),onDelete:function(){h.triggerHandler("change")},onAdd:function(n){if(a.sortable&&a.allow_multiple){d()}$(document).triggerHandler("init.popovers",[h.parent()])},formatQueryParam:function(p,o){if(h.tokenInput("get").length>0||a.exclude_ids.length>0){var n=$.merge([],a.exclude_ids);$.each(h.tokenInput("get"),function(q,r){n.push(r.id)});o.data["exclude[]"]=n}if(a.types&&a.types.length>0){o.data.type=a.types}return(p+"*").toLowerCase()}});setTimeout(function(){h.tokenInput(a.url,m);$("> :input[type=text]",$(".token-input-input-token",h.parent())).attr("placeholder",AS.linker_locales.hintText);$("> :input[type=text]",$(".token-input-input-token",h.parent())).addClass("form-control");h.parent().addClass("multiplicity-"+a.multiplicity);if(a.sortable&&a.allow_multiple){d();l.addClass("sortable")}});b()};k()})}});$(document).ready(function(){$(document).bind("loadedrecordsubforms.aspace",function(a,b){$(".linker-wrapper:visible > .linker:not(.initialised)",b).linker();$("#archives_tree_toolbar .linker:not(.initialised)").linker()});$(document).bind("subrecordcreated.aspace",function(c,a,b){$(".linker:not(.initialised)",b).linker()})});$(function(){var a=function(){$("#merge-dropdown .linker:not(.initialised)").linker();$(".merge-form .btn-cancel").on("click",function(){$(".merge-action").trigger("click")});$(".merge-action").on("click",function(b){b.preventDefault();b.stopImmediatePropagation();if($(this).attr("disabled")){return}if($(".merge-form")[0].style.display==="block"){$(".merge-form").css("display","")}else{$(".merge-form").css("display","block")}});$(".merge-form").on("click",function(b){b.stopPropagation()});$(".merge-form .linker-wrapper .dropdown-toggle").on("click",function(b){b.stopPropagation();$(this).parent().toggleClass("open")});$(".merge-form .merge-button").on("click",function(c){var b=$(".merge-form").serializeObject();if(b["merge[ref]"]&&!b["merge[ref][]"]){b["merge[ref][]"]=b["merge[ref]"]}if(!b["merge[ref][]"]){$(".missing-ref-message",".merge-form").show();c.preventDefault();c.stopImmediatePropagation();return false}else{$(".missing-ref-message",".merge-form").hide();$(this).data("form-data",{refs:b["merge[ref][]"]})}})};if($(".merge-form").length>0){a()}else{$(document).bind("loadedrecordform.aspace",a)}});$(function(){var a=function(){$(".transfer-form .btn-cancel").on("click",function(){$(".transfer-action").trigger("click")});$(".transfer-action").on("click",function(b){b.preventDefault();b.stopImmediatePropagation();if($(this).attr("disabled")){return}if($(".transfer-form")[0].style.display==="block"){$(".transfer-form").css("display","")}else{$(".transfer-form").css("display","block")}});$(".transfer-form").on("click",function(b){b.stopPropagation()});$(".transfer-form .linker-wrapper .dropdown-toggle").on("click",function(b){b.stopPropagation();$(this).parent().toggleClass("open")});$(".transfer-form .transfer-button").on("click",function(c){var b=$(".transfer-form").serializeObject();if(!b["transfer[ref]"]){$(".missing-ref-message",".transfer-form").show();c.preventDefault();c.stopImmediatePropagation();return false}else{$(".missing-ref-message",".transfer-form").hide();$(this).data("form-data",{ref:b["transfer[ref]"]})}})};if($(".transfer-form").length>0){a()}else{$(document).bind("loadedrecordform.aspace",a)}});$(function(){var a=function(){$(".add-event-form .btn-close").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();$(".add-event-action").trigger("click")});$(".add-event-action").on("click",function(b){b.preventDefault();b.stopImmediatePropagation();if($(this).attr("disabled")){return}if($(".add-event-form")[0].style.display==="block"){$(".add-event-form").css("display","")}else{$(".add-event-form").css("display","block")}});$(".add-event-form").on("click",function(b){b.stopPropagation()});$(".add-event-form .add-event-button").on("click",function(c){c.stopPropagation();c.preventDefault();var b=AS.quickTemplate(decodeURIComponent($("#add-event-dropdown").data("add-event-url")),{event_type:$("#add_event_event_type").val()});location.href=b})};if($(".add-event-form").length>0){a()}else{$(document).bind("loadedrecordform.aspace",a)}});