(function(b){b.fn.each2===void 0&&b.fn.extend({each2:function(a){for(var h=b([0]),g=-1,f=this.length;f>++g&&(h.context=h[0]=this[g])&&a.call(h[0],g,h)!==!1;){}return this}})})(jQuery),function(an,am){function ad(f,e){for(var h=0,g=e.length;g>h;h+=1){if(ac(f,e[h])){return h}}return -1}function ac(b,d){return b===d?!0:b===am||d===am?!1:null===b||null===d?!1:b.constructor===String?b+""==d+"":d.constructor===String?d+""==b+"":!1}function ab(a,j){var i,h,g;if(null===a||1>a.length){return[]}for(i=a.split(j),h=0,g=i.length;g>h;h+=1){i[h]=an.trim(i[h])}return i}function aa(b){return b.outerWidth(!1)-b.width()}function Z(b){var a="keyup-change-value";b.bind("keydown",function(){an.data(b,a)===am&&an.data(b,a,b.val())}),b.bind("keyup",function(){var c=an.data(b,a);c!==am&&b.val()!==c&&(an.removeData(b,a),b.trigger("keyup-change"))})}function Y(a){a.bind("mousemove",function(e){var b=af;(b===am||b.x!==e.pageX||b.y!==e.pageY)&&an(e.target).trigger("mousemove-filtered",e)})}function W(b,h,g){g=g||am;var f;return function(){var a=arguments;window.clearTimeout(f),f=window.setTimeout(function(){h.apply(g,a)},b)}}function U(e){var f,d=!1;return function(){return d===!1&&(f=e(),d=!0),f}}function S(e,d){var f=W(e,function(b){d.trigger("scroll-debounced",b)});d.bind("scroll",function(b){ad(b.target,d.get())>=0&&f(b)})}function Q(b){b[0]!==document.activeElement&&window.setTimeout(function(){var e,a=b[0],f=b.val().length;b.focus(),b.is(":visible")&&a===document.activeElement&&(a.setSelectionRange?a.setSelectionRange(f,f):a.createTextRange&&(e=a.createTextRange(),e.collapse(!1),e.select()))},0)}function O(b){b.preventDefault(),b.stopPropagation()}function M(b){b.preventDefault(),b.stopImmediatePropagation()}function K(a){if(!ag){var d=a[0].currentStyle||window.getComputedStyle(a[0],null);ag=an(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:d.fontSize,fontFamily:d.fontFamily,fontStyle:d.fontStyle,fontWeight:d.fontWeight,letterSpacing:d.letterSpacing,textTransform:d.textTransform,whiteSpace:"nowrap"}),ag.attr("class","select2-sizer"),an("body").append(ag)}return ag.text(a.val()),ag.width()}function J(a,l,k){var j,h,i=[];j=a.attr("class"),j&&(j=""+j,an(j.split(" ")).each2(function(){0===this.indexOf("select2-")&&i.push(this)})),j=l.attr("class"),j&&(j=""+j,an(j.split(" ")).each2(function(){0!==this.indexOf("select2-")&&(h=k(this),h&&i.push(this))})),a.attr("class",i.join(" "))}function I(b,l,k,j){var i=b.toUpperCase().indexOf(l.toUpperCase()),h=l.length;return 0>i?(k.push(j(b)),am):(k.push(j(b.substring(0,i))),k.push(""),k.push(j(b.substring(i,i+h))),k.push(""),k.push(j(b.substring(i+h,b.length))),am)}function H(a){var n,m=0,l=null,k=a.quietMillis||100,j=a.url,i=this;return function(b){window.clearTimeout(n),n=window.setTimeout(function(){m+=1;var p=m,o=a.data,h=j,g=a.transport||an.ajax,e=a.type||"GET",d={};o=o?o.call(i,b.term,b.page,b.context):null,h="function"==typeof h?h.call(i,b.term,b.page,b.context):h,null!==l&&l.abort(),a.params&&(an.isFunction(a.params)?an.extend(d,a.params.call(i)):an.extend(d,a.params)),an.extend(d,{url:h,dataType:a.dataType,data:o,type:e,cache:!1,success:function(c){if(!(m>p)){var f=a.results(c,b.page);b.callback(f)}}}),l=g.call(i,d)},k)}}function X(l){var j,i,k=l,b=function(c){return""+c.text};an.isArray(k)&&(i=k,k={results:i}),an.isFunction(k)===!1&&(i=k,k=function(){return i});var a=k();return a.text&&(b=a.text,an.isFunction(b)||(j=k.text,b=function(c){return c[j]})),function(n){var d,m=n.term,g={results:[]};return""===m?(n.callback(k()),am):(d=function(c,o){var h,e;if(c=c[0],c.children){h={};for(e in c){c.hasOwnProperty(e)&&(h[e]=c[e])}h.children=[],an(c.children).each2(function(p,f){d(f,h.children)}),(h.children.length||n.matcher(m,b(h),c))&&o.push(h)}else{n.matcher(m,b(c),c)&&o.push(c)}},an(k().results).each2(function(e,c){d(c,g.results)}),n.callback(g),am)}}function V(b){var a=an.isFunction(b);return function(h){var d=h.term,c={results:[]};an(a?b():b).each(function(){var e=this.text!==am,f=e?this.text:this;(""===d||h.matcher(d,f))&&c.results.push(e?this:{id:this,text:this})}),h.callback(c)}}function T(a){if(an.isFunction(a)){return !0}if(!a){return !1}throw Error("formatterName must be a function or a falsy value")}function R(a){return an.isFunction(a)?a():a}function P(a){var d=0;return an.each(a,function(e,c){c.children?d+=P(c.children):d++}),d}function N(v,u,t,s){var p,o,n,l,b,r=v,q=!1;if(!s.createSearchChoice||!s.tokenSeparators||1>s.tokenSeparators.length){return am}for(;;){for(o=-1,n=0,l=s.tokenSeparators.length;l>n&&(b=s.tokenSeparators[n],o=v.indexOf(b),!(o>=0));n++){}if(0>o){break}if(p=v.substring(0,o),v=v.substring(o+b.length),p.length>0&&(p=s.createSearchChoice(p,u),p!==am&&null!==p&&s.id(p)!==am&&null!==s.id(p))){for(q=!1,n=0,l=u.length;l>n;n++){if(ac(s.id(p),s.id(u[n]))){q=!0;break}}q||t(p)}}return r!==v?v:am}function L(a,f){var e=function(){};return e.prototype=new a,e.prototype.constructor=e,e.prototype.parent=a.prototype,e.prototype=an.extend(e.prototype,f),e}if(window.Select2===am){var al,ak,aj,ai,ah,ag,af,ae;al={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(b){switch(b=b.which?b.which:b){case al.LEFT:case al.RIGHT:case al.UP:case al.DOWN:return !0}return !1},isControl:function(d){var c=d.which;switch(c){case al.SHIFT:case al.CTRL:case al.ALT:return !0}return d.metaKey?!0:!1},isFunctionKey:function(b){return b=b.which?b.which:b,b>=112&&123>=b}},ae=an(document),ah=function(){var b=1;return function(){return b++}}(),ae.bind("mousemove",function(b){af={x:b.pageX,y:b.pageY}}),ak=L(Object,{bind:function(d){var c=this;return function(){d.apply(c,arguments)}},init:function(h){var g,b,a=".select2-results";this.opts=h=this.prepareOpts(h),this.id=h.id,h.element.data("select2")!==am&&null!==h.element.data("select2")&&this.destroy(),this.enabled=!0,this.container=this.createContainer(),this.containerId="s2id_"+(h.element.attr("id")||"autogen"+ah()),this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.body=U(function(){return h.element.closest("body")}),J(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.css(R(h.containerCss)),this.container.addClass(R(h.containerCssClass)),this.elementTabIndex=this.opts.element.attr("tabIndex"),this.opts.element.data("select2",this).addClass("select2-offscreen").bind("focus.select2",function(){an(this).select2("focus")}).attr("tabIndex","-1").before(this.container),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),this.dropdown.addClass(R(h.dropdownCssClass)),this.dropdown.data("select2",this),this.results=g=this.container.find(a),this.search=b=this.container.find("input.select2-input"),b.attr("tabIndex",this.elementTabIndex),this.resultsPage=0,this.context=null,this.initContainer(),Y(this.results),this.dropdown.delegate(a,"mousemove-filtered touchstart touchmove touchend",this.bind(this.highlightUnderEvent)),S(80,this.results),this.dropdown.delegate(a,"scroll-debounced",this.bind(this.loadMoreIfNeeded)),an.fn.mousewheel&&g.mousewheel(function(i,d,l,k){var j=g.scrollTop();k>0&&0>=j-k?(g.scrollTop(0),O(i)):0>k&&g.get(0).scrollHeight-g.scrollTop()+k<=g.height()&&(g.scrollTop(g.get(0).scrollHeight-g.height()),O(i))}),Z(b),b.bind("keyup-change input paste",this.bind(this.updateResults)),b.bind("focus",function(){b.addClass("select2-focused")}),b.bind("blur",function(){b.removeClass("select2-focused")}),this.dropdown.delegate(a,"mouseup",this.bind(function(c){an(c.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(c),this.selectHighlighted(c))})),this.dropdown.bind("click mouseup mousedown",function(c){c.stopPropagation()}),an.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),(h.element.is(":disabled")||h.element.is("[readonly='readonly']"))&&this.disable()},destroy:function(){var b=this.opts.element.data("select2");this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),b!==am&&(b.container.remove(),b.dropdown.remove(),b.opts.element.removeClass("select2-offscreen").removeData("select2").unbind(".select2").attr({tabIndex:this.elementTabIndex}).show())},prepareOpts:function(j){var i,h,b,a;if(i=j.element,"select"===i.get(0).tagName.toLowerCase()&&(this.select=h=j.element),h&&an.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in j){throw Error("Option '"+this+"' is not allowed for Select2 when attached to a ",""].join(""));return a},disable:function(){this.enabled&&(this.parent.disable.apply(this,arguments),this.focusser.attr("disabled","disabled"))},enable:function(){this.enabled||(this.parent.enable.apply(this,arguments),this.focusser.removeAttr("disabled"))},opening:function(){this.parent.opening.apply(this,arguments),this.focusser.attr("disabled","disabled"),this.opts.element.trigger(an.Event("open"))},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.focusser.removeAttr("disabled"),Q(this.focusser))},focus:function(){this.opened()?this.close():(this.focusser.removeAttr("disabled"),this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.removeAttr("disabled"),this.focusser.focus()},initContainer:function(){var g,c=this.container,b=this.dropdown,a=!1;this.showSearch(this.opts.minimumResultsForSearch>=0),this.selection=g=c.find(".select2-choice"),this.focusser=c.find(".select2-focusser"),this.focusser.attr("id","s2id_autogen"+ah()),an("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.focusser.attr("id")),this.search.bind("keydown",this.bind(function(d){if(this.enabled){if(d.which===al.PAGE_UP||d.which===al.PAGE_DOWN){return O(d),am}switch(d.which){case al.UP:case al.DOWN:return this.moveHighlight(d.which===al.UP?-1:1),O(d),am;case al.TAB:case al.ENTER:return this.selectHighlighted(),O(d),am;case al.ESC:return this.cancel(d),O(d),am}}})),this.search.bind("blur",this.bind(function(){document.activeElement===this.body().get(0)&&window.setTimeout(this.bind(function(){this.search.focus()}),0)})),this.focusser.bind("keydown",this.bind(function(d){return !this.enabled||d.which===al.TAB||al.isControl(d)||al.isFunctionKey(d)||d.which===al.ESC?am:this.opts.openOnEnter===!1&&d.which===al.ENTER?(O(d),am):d.which==al.DOWN||d.which==al.UP||d.which==al.ENTER&&this.opts.openOnEnter?(this.open(),O(d),am):d.which==al.DELETE||d.which==al.BACKSPACE?(this.opts.allowClear&&this.clear(),O(d),am):am})),Z(this.focusser),this.focusser.bind("keyup-change input",this.bind(function(d){this.opened()||(this.open(),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.focusser.val(""),O(d))})),g.delegate("abbr","mousedown",this.bind(function(d){this.enabled&&(this.clear(),M(d),this.close(),this.selection.focus())})),g.bind("mousedown",this.bind(function(d){a=!0,this.opened()?this.close():this.enabled&&this.open(),O(d),a=!1})),b.bind("mousedown",this.bind(function(){this.search.focus()})),g.bind("focus",this.bind(function(d){O(d)})),this.focusser.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")})).bind("blur",this.bind(function(){this.opened()||this.container.removeClass("select2-container-active")})),this.search.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.setPlaceholder()},clear:function(d){var c=this.selection.data("select2-data");c&&(this.opts.element.val(""),this.selection.find("span").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),d!==!1&&(this.opts.element.trigger({type:"removed",val:this.id(c),choice:c}),this.triggerChange({removed:c})))},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()){this.close(),this.setPlaceholder()}else{var a=this;this.opts.initSelection.call(null,this.opts.element,function(b){b!==am&&null!==b&&(a.updateSelection(b),a.close(),a.setPlaceholder())})}},prepareOpts:function(){var a=this.parent.prepareOpts.apply(this,arguments);return"select"===a.element.get(0).tagName.toLowerCase()?a.initSelection=function(e,g){var f=e.find(":selected");an.isFunction(g)&&g({id:f.attr("value"),text:f.text(),element:f})}:"data" in a&&(a.initSelection=a.initSelection||function(i,h){var g=i.val(),b=null;a.query({matcher:function(e,k,j){var f=ac(g,a.id(j));return f&&(b=j),f},callback:an.isFunction(h)?function(){h(b)}:an.noop})}),a},getPlaceholder:function(){return this.select&&""!==this.select.find("option").first().text()?am:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var b=this.getPlaceholder();if(""===this.opts.element.val()&&b!==am){if(this.select&&""!==this.select.find("option:first").text()){return}this.selection.find("span").html(this.opts.escapeMarkup(b)),this.selection.addClass("select2-default"),this.selection.find("abbr").hide()}},postprocessResults:function(b,n,m){var l=0,k=this,j=!0;if(this.findHighlightableChoices().each2(function(d,e){return ac(k.id(e.data("select2-data")),k.opts.element.val())?(l=d,!1):am}),m!==!1&&this.highlight(l),n===!0){var i=this.opts.minimumResultsForSearch;j=0>i?!1:P(b.results)>=i,this.showSearch(j)}},showSearch:function(a){this.showSearchInput=a,this.dropdown.find(".select2-search")[a?"removeClass":"addClass"]("select2-search-hidden"),an(this.dropdown,this.container)[a?"addClass":"removeClass"]("select2-with-searchbox")},onSelect:function(e,d){var f=this.opts.element.val();this.opts.element.val(this.id(e)),this.updateSelection(e),this.opts.element.trigger({type:"selected",val:this.id(e),choice:e}),this.close(),d&&d.noFocus||this.selection.focus(),ac(f,this.id(e))||this.triggerChange()},updateSelection:function(b){var e,f=this.selection.find("span");this.selection.data("select2-data",b),f.empty(),e=this.opts.formatSelection(b,f),e!==am&&f.append(this.opts.escapeMarkup(e)),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==am&&this.selection.find("abbr").show()},val:function(){var b,h=!1,g=null,f=this;if(0===arguments.length){return this.opts.element.val()}if(b=arguments[0],arguments.length>1&&(h=arguments[1]),this.select){this.select.val(b).find(":selected").each2(function(d,c){return g={id:c.attr("value"),text:c.text(),element:c.get(0)},!1}),this.updateSelection(g),this.setPlaceholder(),h&&this.triggerChange()}else{if(this.opts.initSelection===am){throw Error("cannot call val() if initSelection() is not defined")}if(!b&&0!==b){return this.clear(h),h&&this.triggerChange(),am}this.opts.element.val(b),this.opts.initSelection(this.opts.element,function(c){f.opts.element.val(c?f.id(c):""),f.updateSelection(c),f.setPlaceholder(),h&&f.triggerChange()})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(b){var d;return 0===arguments.length?(d=this.selection.data("select2-data"),d==am&&(d=null),d):(b&&""!==b?(this.opts.element.val(b?this.id(b):""),this.updateSelection(b)):this.clear(),am)}}),ai=L(ak,{createContainer:function(){var a=an(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html([" ",""].join(""));return a},prepareOpts:function(){var a=this.parent.prepareOpts.apply(this,arguments);return"select"===a.element.get(0).tagName.toLowerCase()?a.initSelection=function(e,d){var f=[];e.find(":selected").each2(function(g,c){f.push({id:c.attr("value"),text:c.text(),element:c[0]})}),d(f)}:"data" in a&&(a.initSelection=a.initSelection||function(i,h){var g=ab(i.val(),a.separator),b=[];a.query({matcher:function(k,j,f){var e=an.grep(g,function(c){return ac(c,a.id(f))}).length;return e&&b.push(f),e},callback:an.isFunction(h)?function(){h(b)}:an.noop})}),a},initContainer:function(){var a,b=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=a=this.container.find(b),this.search.attr("id","s2id_autogen"+ah()),an("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.search.attr("id")),this.search.bind("input paste",this.bind(function(){this.enabled&&(this.opened()||this.open())})),this.search.bind("keydown",this.bind(function(c){if(this.enabled){if(c.which===al.BACKSPACE&&""===this.search.val()){this.close();var g,e=a.find(".select2-search-choice-focus");if(e.length>0){return this.unselect(e.first()),this.search.width(10),O(c),am}g=a.find(".select2-search-choice:not(.select2-locked)"),g.length>0&&g.last().addClass("select2-search-choice-focus")}else{a.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")}if(this.opened()){switch(c.which){case al.UP:case al.DOWN:return this.moveHighlight(c.which===al.UP?-1:1),O(c),am;case al.ENTER:case al.TAB:return this.selectHighlighted(),O(c),am;case al.ESC:return this.cancel(c),O(c),am}}if(c.which!==al.TAB&&!al.isControl(c)&&!al.isFunctionKey(c)&&c.which!==al.BACKSPACE&&c.which!==al.ESC){if(c.which===al.ENTER){if(this.opts.openOnEnter===!1){return}if(c.altKey||c.ctrlKey||c.shiftKey||c.metaKey){return}}this.open(),(c.which===al.PAGE_UP||c.which===al.PAGE_DOWN)&&O(c),c.which===al.ENTER&&O(c)}}})),this.search.bind("keyup",this.bind(this.resizeSearch)),this.search.bind("blur",this.bind(function(c){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.opened()||this.clearSearch(),c.stopImmediatePropagation()})),this.container.delegate(b,"mousedown",this.bind(function(c){this.enabled&&(an(c.target).closest(".select2-search-choice").length>0||(this.clearPlaceholder(),this.open(),this.focusSearch(),c.preventDefault()))})),this.container.delegate(b,"focus",this.bind(function(){this.enabled&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.clearSearch()},enable:function(){this.enabled||(this.parent.enable.apply(this,arguments),this.search.removeAttr("disabled"))},disable:function(){this.enabled&&(this.parent.disable.apply(this,arguments),this.search.attr("disabled",!0))},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var a=this;this.opts.initSelection.call(null,this.opts.element,function(b){b!==am&&null!==b&&(a.updateSelection(b),a.close(),a.clearSearch())})}},clearSearch:function(){var b=this.getPlaceholder();b!==am&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(b).addClass("select2-default"),this.search.width(this.getMaxSearchWidth())):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),this.opts.element.trigger(an.Event("open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(a){var h=[],g=[],f=this;an(a).each(function(){0>ad(f.id(this),h)&&(h.push(f.id(this)),g.push(this))}),a=g,this.selection.find(".select2-search-choice").remove(),an(a).each(function(){f.addSelectedChoice(this)}),f.postprocessResults()},tokenize:function(){var b=this.search.val();b=this.opts.tokenizer(b,this.data(),this.bind(this.onSelect),this.opts),null!=b&&b!=am&&(this.search.val(b),b.length>0&&this.open())},onSelect:function(d,c){this.addSelectedChoice(d),this.opts.element.trigger({type:"selected",val:this.id(d),choice:d}),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()&&this.updateResults(!0),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:d}),c&&c.noFocus||this.focusSearch()},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(p){var a,o=!p.locked,n=an("
  • "),m=an("
  • "),l=o?n:m,k=this.id(p),b=this.getVal();a=this.opts.formatSelection(p,l.find("div")),a!=am&&l.find("div").replaceWith("
    "+this.opts.escapeMarkup(a)+"
    "),o&&l.find(".select2-search-choice-close").bind("mousedown",O).bind("click dblclick",this.bind(function(c){this.enabled&&(an(c.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(an(c.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),this.close(),this.focusSearch()})).dequeue(),O(c))})).bind("focus",this.bind(function(){this.enabled&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),l.data("select2-data",p),l.insertBefore(this.searchContainer),b.push(k),this.setVal(b)},unselect:function(f){var h,g,e=this.getVal();if(f=f.closest(".select2-search-choice"),0===f.length){throw"Invalid argument: "+f+". Must be .select2-search-choice"}h=f.data("select2-data"),h&&(g=ad(this.id(h),e),g>=0&&(e.splice(g,1),this.setVal(e),this.select&&this.postprocessResults()),f.remove(),this.opts.element.trigger({type:"removed",val:this.id(h),choice:h}),this.triggerChange({removed:h}))},postprocessResults:function(){var f=this.getVal(),e=this.results.find(".select2-result"),h=this.results.find(".select2-result-with-children"),g=this;e.each2(function(a,i){var d=g.id(i.data("select2-data"));ad(d,f)>=0&&(i.addClass("select2-selected"),i.find(".select2-result-selectable").addClass("select2-selected"))}),h.each2(function(d,c){c.is(".select2-result-selectable")||0!==c.find(".select2-result-selectable:not(.select2-selected)").length||c.addClass("select2-selected")}),-1==this.highlight()&&g.highlight(0)},getMaxSearchWidth:function(){return this.selection.width()-aa(this.search)},resizeSearch:function(){var h,g,l,k,j,i=aa(this.search);h=K(this.search)+10,g=this.search.offset().left,l=this.selection.width(),k=this.selection.offset().left,j=l-(g-k)-i,h>j&&(j=l-i),40>j&&(j=l-i),0>=j&&(j=h),this.search.width(j)},getVal:function(){var b;return this.select?(b=this.select.val(),null===b?[]:b):(b=this.opts.element.val(),ab(b,this.opts.separator))},setVal:function(a){var d;this.select?this.select.val(a):(d=[],an(a).each(function(){0>ad(this,d)&&d.push(this)}),this.opts.element.val(0===d.length?"":d.join(this.opts.separator)))},val:function(){var e,b=!1,a=this;if(0===arguments.length){return this.getVal()}if(e=arguments[0],arguments.length>1&&(b=arguments[1]),!e&&0!==e){return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),b&&this.triggerChange(),am}if(this.setVal(e),this.select){this.opts.initSelection(this.select,this.bind(this.updateSelection)),b&&this.triggerChange()}else{if(this.opts.initSelection===am){throw Error("val() cannot be called if initSelection() is not defined")}this.opts.initSelection(this.opts.element,function(d){var f=an(d).map(a.id);a.setVal(f),a.updateSelection(d),a.clearSearch(),b&&a.triggerChange()})}this.clearSearch()},onSortStart:function(){if(this.select){throw Error("Sorting of elements is not supported when attached to instead.")}this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var a=[],d=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){a.push(d.opts.id(an(this).data("select2-data")))}),this.setVal(a),this.triggerChange()},data:function(f){var a,b=this;return 0===arguments.length?this.selection.find(".select2-search-choice").map(function(){return an(this).data("select2-data")}).get():(f||(f=[]),a=an.map(f,function(c){return b.opts.id(c)}),this.setVal(a),this.updateSelection(f),this.clearSearch(),am)}}),an.fn.select2=function(){var k,f,e,b,l=Array.prototype.slice.call(arguments,0),a=["val","destroy","opened","open","close","focus","isFocused","container","onSortStart","onSortEnd","enable","disable","positionDropdown","data"];return this.each(function(){if(0===l.length||"object"==typeof l[0]){k=0===l.length?{}:an.extend({},l[0]),k.element=an(this),"select"===k.element.get(0).tagName.toLowerCase()?b=k.element.attr("multiple"):(b=k.multiple||!1,"tags" in k&&(k.multiple=b=!0)),f=b?new ai:new aj,f.init(k)}else{if("string"!=typeof l[0]){throw"Invalid arguments to select2 plugin: "+l}if(0>ad(l[0],a)){throw"Unknown method: "+l[0]}if(e=am,f=an(this).data("select2"),f===am){return}if(e="container"===l[0]?f.container:f[l[0]].apply(f,l.slice(1)),e!==am){return !1}}}),e===am?this:e},an.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(g,f,j,i){var h=[];return I(g.text,j.term,h,i),h.join("")},formatSelection:function(b){return b?b.text:am},sortResults:function(b){return b},formatResultCssClass:function(){return am},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(e,d){var f=d-e.length;return"Please enter "+f+" more character"+(1==f?"":"s")},formatInputTooLong:function(e,d){var f=e.length-d;return"Please delete "+f+" character"+(1==f?"":"s")},formatSelectionTooBig:function(b){return"You can only select "+b+" item"+(1==b?"":"s")},formatLoadMore:function(){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(b){return b.id},matcher:function(d,c){return(""+c).toUpperCase().indexOf((""+d).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:N,escapeMarkup:function(d){var c={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return(d+"").replace(/[&<>"'\/\\]/g,function(b){return c[b[0]]})},blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(b){return b},adaptDropdownCssClass:function(){return null}},window.Select2={query:{ajax:H,local:X,tags:V},util:{debounce:W,markMatch:I},"class":{"abstract":ak,single:aj,multi:ai}}}}(jQuery);