(function(n){if(typeof n.fn.each2=="undefined"){n.extend(n.fn,{each2:function(e){var t=n([0]),s=-1,i=this.length;while(++s<i&&(t.context=t[0]=this[s])&&e.call(t[0],s,t)!==false);return this}})}})(jQuery);(function(T,S){"use strict";if(window.Select2!==S){return}var e,t,s,C,i,n={x:0,y:0},o,E,r={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(e){e=e.which?e.which:e;switch(e){case r.LEFT:case r.RIGHT:case r.UP:case r.DOWN:return true}return false},isControl:function(e){var t=e.which;switch(t){case r.SHIFT:case r.CTRL:case r.ALT:return true}if(e.metaKey)return true;return false},isFunctionKey:function(e){e=e.which?e.which:e;return e>=112&&e<=123}},a="<div class='select2-measure-scrollbar'></div>",l={"Ⓐ":"A","Ａ":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","Ｂ":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","Ｃ":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","Ｄ":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","Ǳ":"DZ","Ǆ":"DZ","ǲ":"Dz","ǅ":"Dz","Ⓔ":"E","Ｅ":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","Ｆ":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","Ｇ":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","Ｈ":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","Ｉ":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","Ｊ":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","Ｋ":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","Ｌ":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","Ǉ":"LJ","ǈ":"Lj","Ⓜ":"M","Ｍ":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","Ｎ":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","Ǌ":"NJ","ǋ":"Nj","Ⓞ":"O","Ｏ":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","Ｐ":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Ｑ":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","Ｒ":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","Ｓ":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","Ｔ":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","Ｕ":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","Ｖ":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","Ｗ":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","Ｘ":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Ｙ":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Ｚ":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","ａ":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","ｂ":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","ｃ":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","ｄ":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","ǳ":"dz","ǆ":"dz","ⓔ":"e","ｅ":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","ｆ":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","ｇ":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","ｈ":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","ｉ":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","ｊ":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","ｋ":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","ｌ":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","ǉ":"lj","ⓜ":"m","ｍ":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","ｎ":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ŉ":"n","ꞑ":"n","ꞥ":"n","ǌ":"nj","ⓞ":"o","ｏ":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","ｐ":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","ｑ":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","ｒ":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","ｓ":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","ｔ":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","ｕ":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","ｖ":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","ｗ":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","ｘ":"x","ẋ":"x","ẍ":"x","ⓨ":"y","ｙ":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","ｚ":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};o=T(document);C=function(){var e=1;return function(){return e++}}();function c(e){var t=T(document.createTextNode(""));e.before(t);t.before(e);t.remove()}function h(e){function t(e){return l[e]||e}return e.replace(/[^\u0000-\u007E]/g,t)}function u(e,t){var s=0,i=t.length;for(;s<i;s=s+1){if(d(e,t[s]))return s}return-1}function f(){var e=T(a);e.appendTo(document.body);var t={width:e.width()-e[0].clientWidth,height:e.height()-e[0].clientHeight};e.remove();return t}function d(e,t){if(e===t)return true;if(e===S||t===S)return false;if(e===null||t===null)return false;if(e.constructor===String)return e+""===t+"";if(t.constructor===String)return t+""===e+"";return false}function p(e,t,s){var i,n,o;if(e===null||e.length<1)return[];i=e.split(t);for(n=0,o=i.length;n<o;n=n+1)i[n]=s(i[n]);return i}function g(e){return e.outerWidth(false)-e.width()}function m(t){var s="keyup-change-value";t.on("keydown",function(){if(T.data(t,s)===S){T.data(t,s,t.val())}});t.on("keyup",function(){var e=T.data(t,s);if(e!==S&&t.val()!==e){T.removeData(t,s);t.trigger("keyup-change")}})}function v(e){e.on("mousemove",function(e){var t=n;if(t===S||t.x!==e.pageX||t.y!==e.pageY){T(e.target).trigger("mousemove-filtered",e)}})}function b(t,s,i){i=i||S;var n;return function(){var e=arguments;window.clearTimeout(n);n=window.setTimeout(function(){s.apply(i,e)},t)}}function w(e,t){var s=b(e,function(e){t.trigger("scroll-debounced",e)});t.on("scroll",function(e){if(u(e.target,t.get())>=0)s(e)})}function y(n){if(n[0]===document.activeElement)return;window.setTimeout(function(){var e=n[0],t=n.val().length,s;n.focus();var i=e.offsetWidth>0||e.offsetHeight>0;if(i&&e===document.activeElement){if(e.setSelectionRange){e.setSelectionRange(t,t)}else if(e.createTextRange){s=e.createTextRange();s.collapse(false);s.select()}}},0)}function x(e){e=T(e)[0];var t=0;var s=0;if("selectionStart"in e){t=e.selectionStart;s=e.selectionEnd-t}else if("selection"in document){e.focus();var i=document.selection.createRange();s=document.selection.createRange().text.length;i.moveStart("character",-e.value.length);t=i.text.length-s}return{offset:t,length:s}}function O(e){e.preventDefault();e.stopPropagation()}function I(e){e.preventDefault();e.stopImmediatePropagation()}function P(e){if(!i){var t=e[0].currentStyle||window.getComputedStyle(e[0],null);i=T(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:t.fontSize,fontFamily:t.fontFamily,fontStyle:t.fontStyle,fontWeight:t.fontWeight,letterSpacing:t.letterSpacing,textTransform:t.textTransform,whiteSpace:"nowrap"});i.attr("class","select2-sizer");T(document.body).append(i)}i.text(e.val());return i.width()}function k(e,t,s){var i,n=[],o;i=T.trim(e.attr("class"));if(i){i=""+i;T(i.split(/\s+/)).each2(function(){if(this.indexOf("select2-")===0){n.push(this)}})}i=T.trim(t.attr("class"));if(i){i=""+i;T(i.split(/\s+/)).each2(function(){if(this.indexOf("select2-")!==0){o=s(this);if(o){n.push(o)}}})}e.attr("class",n.join(" "))}function R(e,t,s,i){var n=h(e.toUpperCase()).indexOf(h(t.toUpperCase())),o=t.length;if(n<0){s.push(i(e));return}s.push(i(e.substring(0,n)));s.push("<span class='select2-match'>");s.push(i(e.substring(n,n+o)));s.push("</span>");s.push(i(e.substring(n+o,e.length)))}function A(e){var t={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})}function D(a){var e,r=null,t=a.quietMillis||100,l=a.url,c=this;return function(o){window.clearTimeout(e);e=window.setTimeout(function(){var e=a.data,t=l,s=a.transport||T.fn.select2.ajaxDefaults.transport,i={type:a.type||"GET",cache:a.cache||false,jsonpCallback:a.jsonpCallback||S,dataType:a.dataType||"json"},n=T.extend({},T.fn.select2.ajaxDefaults.params,i);e=e?e.call(c,o.term,o.page,o.context):null;t=typeof t==="function"?t.call(c,o.term,o.page,o.context):t;if(r&&typeof r.abort==="function"){r.abort()}if(a.params){if(T.isFunction(a.params)){T.extend(n,a.params.call(c))}else{T.extend(n,a.params)}}T.extend(n,{url:t,dataType:a.dataType,data:e,success:function(e){var t=a.results(e,o.page,o);o.callback(t)},error:function(e,t,s){var i={hasError:true,jqXHR:e,textStatus:t,errorThrown:s};o.callback(i)}});r=s.call(c,n)},t)}}function L(e){var t=e,s,i,r=function(e){return""+e.text};if(T.isArray(t)){i=t;t={results:i}}if(T.isFunction(t)===false){i=t;t=function(){return i}}var n=t();if(n.text){r=n.text;if(!T.isFunction(r)){s=n.text;r=function(e){return e[s]}}}return function(n){var o=n.term,s={results:[]},a;if(o===""){n.callback(t());return}a=function(e,t){var s,i;e=e[0];if(e.children){s={};for(i in e){if(e.hasOwnProperty(i))s[i]=e[i]}s.children=[];T(e.children).each2(function(e,t){a(t,s.children)});if(s.children.length||n.matcher(o,r(s),e)){t.push(s)}}else{if(n.matcher(o,r(e),e)){t.push(e)}}};T(t().results).each2(function(e,t){a(t,s.results)});n.callback(s)}}function M(t){var o=T.isFunction(t);return function(s){var i=s.term,n={results:[]};var e=o?t(s):t;if(T.isArray(e)){T(e).each(function(){var e=this.text!==S,t=e?this.text:this;if(i===""||s.matcher(i,t)){n.results.push(e?this:{id:this,text:this})}});s.callback(n)}}}function H(e,t){if(T.isFunction(e))return true;if(!e)return false;if(typeof e==="string")return true;throw new Error(t+" must be a string, function, or falsy value")}function N(e,t){if(T.isFunction(e)){var s=Array.prototype.slice.call(arguments,2);return e.apply(t,s)}return e}function F(e){var s=0;T.each(e,function(e,t){if(t.children){s+=F(t.children)}else{s++}});return s}function U(e,t,s,i){var n=e,o=false,a,r,l,c,h;if(!i.createSearchChoice||!i.tokenSeparators||i.tokenSeparators.length<1)return S;while(true){r=-1;for(l=0,c=i.tokenSeparators.length;l<c;l++){h=i.tokenSeparators[l];r=e.indexOf(h);if(r>=0)break}if(r<0)break;a=e.substring(0,r);e=e.substring(r+h.length);if(a.length>0){a=i.createSearchChoice.call(this,a,t);if(a!==S&&a!==null&&i.id(a)!==S&&i.id(a)!==null){o=false;for(l=0,c=t.length;l<c;l++){if(d(i.id(a),i.id(t[l]))){o=true;break}}if(!o)s(a)}}}if(n!==e)return e}function j(){var s=this;T.each(arguments,function(e,t){s[t].remove();s[t]=null})}function z(e,t){var s=function(){};s.prototype=new e;s.prototype.constructor=s;s.prototype.parent=e.prototype;s.prototype=T.extend(s.prototype,t);return s}e=z(Object,{bind:function(e){var t=this;return function(){e.apply(t,arguments)}},init:function(e){var o,t,s=".select2-results";this.opts=e=this.prepareOpts(e);this.id=e.id;if(e.element.data("select2")!==S&&e.element.data("select2")!==null){e.element.data("select2").destroy()}this.container=this.createContainer();this.liveRegion=T(".select2-hidden-accessible");if(this.liveRegion.length==0){this.liveRegion=T("<span>",{role:"status","aria-live":"polite"}).addClass("select2-hidden-accessible").appendTo(document.body)}this.containerId="s2id_"+(e.element.attr("id")||"autogen"+C());this.containerEventName=this.containerId.replace(/([.])/g,"_").replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1");this.container.attr("id",this.containerId);this.container.attr("title",e.element.attr("title"));this.body=T(document.body);k(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.attr("style",e.element.attr("style"));this.container.css(N(e.containerCss,this.opts.element));this.container.addClass(N(e.containerCssClass,this.opts.element));this.elementTabIndex=this.opts.element.attr("tabindex");this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",O);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");k(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass);this.dropdown.addClass(N(e.dropdownCssClass,this.opts.element));this.dropdown.data("select2",this);this.dropdown.on("click",O);this.results=o=this.container.find(s);this.search=t=this.container.find("input.select2-input");this.queryCount=0;this.resultsPage=0;this.context=null;this.initContainer();this.container.on("click",O);v(this.results);this.dropdown.on("mousemove-filtered",s,this.bind(this.highlightUnderEvent));this.dropdown.on("touchstart touchmove touchend",s,this.bind(function(e){this._touchEvent=true;this.highlightUnderEvent(e)}));this.dropdown.on("touchmove",s,this.bind(this.touchMoved));this.dropdown.on("touchstart touchend",s,this.bind(this.clearTouchMoved));this.dropdown.on("click",this.bind(function(e){if(this._touchEvent){this._touchEvent=false;this.selectHighlighted()}}));w(80,this.results);this.dropdown.on("scroll-debounced",s,this.bind(this.loadMoreIfNeeded));T(this.container).on("change",".select2-input",function(e){e.stopPropagation()});T(this.dropdown).on("change",".select2-input",function(e){e.stopPropagation()});if(T.fn.mousewheel){o.mousewheel(function(e,t,s,i){var n=o.scrollTop();if(i>0&&n-i<=0){o.scrollTop(0);O(e)}else if(i<0&&o.get(0).scrollHeight-o.scrollTop()+i<=o.height()){o.scrollTop(o.get(0).scrollHeight-o.height());O(e)}})}m(t);var i=false;t.on("compositionstart",function(e){i=true});t.on("compositionend",function(e){i=false;t.trigger("keyup-change")});t.on("keyup-change input",this.bind(function(e){if(!i)this.updateResults()}));t.on("paste",this.bind(this.updateResults));t.on("focus",function(){t.addClass("select2-focused")});t.on("blur",function(){t.removeClass("select2-focused")});this.dropdown.on("mouseup",s,this.bind(function(e){if(T(e.target).closest(".select2-result-selectable").length>0){this.highlightUnderEvent(e);this.selectHighlighted(e)}}));this.dropdown.on("click mouseup mousedown touchstart touchend focusin",function(e){e.stopPropagation()});this.lastSearchTerm=S;if(T.isFunction(this.opts.initSelection)){this.initSelection();this.monitorSource()}if(e.maximumInputLength!==null){this.search.attr("maxlength",e.maximumInputLength)}var n=e.element.prop("disabled");if(n===S)n=false;this.enable(!n);var a=e.element.prop("readonly");if(a===S)a=false;this.readonly(a);E=E||f();this.autofocus=e.element.prop("autofocus");e.element.prop("autofocus",false);if(this.autofocus)this.focus();this.search.attr("placeholder",e.searchInputPlaceholder)},destroy:function(){var e=this.opts.element,t=e.data("select2"),s=this;this.close();if(e.length&&e[0].detachEvent&&s._sync){e.each(function(){if(s._sync){this.detachEvent("onpropertychange",s._sync)}})}if(this.propertyObserver){this.propertyObserver.disconnect();this.propertyObserver=null}this._sync=null;if(t!==S){t.container.remove();t.liveRegion.remove();t.dropdown.remove();e.removeData("select2").off(".select2");if(!e.is("input[type='hidden']")){e.show().prop("autofocus",this.autofocus||false);if(this.elementTabIndex){e.attr({tabindex:this.elementTabIndex})}else{e.removeAttr("tabindex")}e.show()}else{e.css("display","")}}j.call(this,"container","liveRegion","dropdown","results","search")},optionToData:function(e){if(e.is("option")){return{id:e.prop("value"),text:e.text(),element:e.get(),css:e.attr("class"),disabled:e.prop("disabled"),locked:d(e.attr("locked"),"locked")||d(e.data("locked"),true)}}else if(e.is("optgroup")){return{text:e.attr("label"),children:[],element:e.get(),css:e.attr("class")}}},prepareOpts:function(b){var a,e,t,s,w=this;a=b.element;if(a.get(0).tagName.toLowerCase()==="select"){this.select=e=b.element}if(e){T.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in b){throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}})}b.debug=b.debug||T.fn.select2.defaults.debug;if(b.debug&&console&&console.warn){if(b.id!=null){console.warn("Select2: The `id` option has been removed in Select2 4.0.0, "+"consider renaming your `id` property or mapping the property before your data makes it to Select2. "+"You can read more at https://select2.github.io/announcements-4.0.html#changed-id")}if(b.text!=null){console.warn("Select2: The `text` option has been removed in Select2 4.0.0, "+"consider renaming your `text` property or mapping the property before your data makes it to Select2. "+"You can read more at https://select2.github.io/announcements-4.0.html#changed-id")}if(b.sortResults!=null){console.warn("Select2: the `sortResults` option has been renamed to `sorter` in Select2 4.0.0. ")}if(b.selectOnBlur!=null){console.warn("Select2: The `selectOnBlur` option has been renamed to `selectOnClose` in Select2 4.0.0.")}if(b.ajax!=null&&b.ajax.results!=null){console.warn("Select2: The `ajax.results` option has been renamed to `ajax.processResults` in Select2 4.0.0.")}if(b.formatNoResults!=null){console.warn("Select2: The `formatNoResults` option has been renamed to `language.noResults` in Select2 4.0.0.")}if(b.formatSearching!=null){console.warn("Select2: The `formatSearching` option has been renamed to `language.searching` in Select2 4.0.0.")}if(b.formatInputTooShort!=null){console.warn("Select2: The `formatInputTooShort` option has been renamed to `language.inputTooShort` in Select2 4.0.0.")}if(b.formatInputTooLong!=null){console.warn("Select2: The `formatInputTooLong` option has been renamed to `language.inputTooLong` in Select2 4.0.0.")}if(b.formatLoading!=null){console.warn("Select2: The `formatLoading` option has been renamed to `language.loadingMore` in Select2 4.0.0.")}if(b.formatSelectionTooBig!=null){console.warn("Select2: The `formatSelectionTooBig` option has been renamed to `language.maximumSelected` in Select2 4.0.0.")}if(b.element.data("select2Tags")){console.warn("Select2: The `data-select2-tags` attribute has been renamed to `data-tags` in Select2 4.0.0.")}}if(b.element.data("tags")!=null){var i=b.element.data("tags");if(!T.isArray(i)){i=[]}b.element.data("select2Tags",i)}if(b.sorter!=null){b.sortResults=b.sorter}if(b.selectOnClose!=null){b.selectOnBlur=b.selectOnClose}if(b.ajax!=null){if(T.isFunction(b.ajax.processResults)){b.ajax.results=b.ajax.processResults}}if(b.language!=null){var n=b.language;if(T.isFunction(n.noMatches)){b.formatNoMatches=n.noMatches}if(T.isFunction(n.searching)){b.formatSearching=n.searching}if(T.isFunction(n.inputTooShort)){b.formatInputTooShort=n.inputTooShort}if(T.isFunction(n.inputTooLong)){b.formatInputTooLong=n.inputTooLong}if(T.isFunction(n.loadingMore)){b.formatLoading=n.loadingMore}if(T.isFunction(n.maximumSelected)){b.formatSelectionTooBig=n.maximumSelected}}b=T.extend({},{populateResults:function(e,t,p){var g,m=this.opts.id,v=this.liveRegion;g=function(e,t,s){var i,n,o,a,r,l,c,h,u,f;e=b.sortResults(e,t,p);var d=[];for(i=0,n=e.length;i<n;i=i+1){o=e[i];r=o.disabled===true;a=!r&&m(o)!==S;l=o.children&&o.children.length>0;c=T("<li></li>");c.addClass("select2-results-dept-"+s);c.addClass("select2-result");c.addClass(a?"select2-result-selectable":"select2-result-unselectable");if(r){c.addClass("select2-disabled")}if(l){c.addClass("select2-result-with-children")}c.addClass(w.opts.formatResultCssClass(o));c.attr("role","presentation");h=T(document.createElement("div"));h.addClass("select2-result-label");h.attr("id","select2-result-label-"+C());h.attr("role","option");f=b.formatResult(o,h,p,w.opts.escapeMarkup);if(f!==S){h.html(f);c.append(h)}if(l){u=T("<ul></ul>");u.addClass("select2-result-sub");g(o.children,u,s+1);c.append(u)}c.data("select2-data",o);d.push(c[0])}t.append(d);v.text(b.formatMatches(e.length))};g(t,e,0)}},T.fn.select2.defaults,b);if(typeof b.id!=="function"){t=b.id;b.id=function(e){return e[t]}}if(T.isArray(b.element.data("select2Tags"))){if("tags"in b){throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+b.element.attr("id")}b.tags=b.element.data("select2Tags")}if(e){b.query=this.bind(function(i){var s={results:[],more:false},n=i.term,e,t,o;o=function(e,t){var s;if(e.is("option")){if(i.matcher(n,e.text(),e)){t.push(w.optionToData(e))}}else if(e.is("optgroup")){s=w.optionToData(e);e.children().each2(function(e,t){o(t,s.children)});if(s.children.length>0){t.push(s)}}};e=a.children();if(this.getPlaceholder()!==S&&e.length>0){t=this.getPlaceholderOption();if(t){e=e.not(t)}}e.each2(function(e,t){o(t,s.results)});i.callback(s)});b.id=function(e){return e.id}}else{if(!("query"in b)){if("ajax"in b){s=b.element.data("ajax-url");if(s&&s.length>0){b.ajax.url=s}b.query=D.call(b.element,b.ajax)}else if("data"in b){b.query=L(b.data)}else if("tags"in b){b.query=M(b.tags);if(b.createSearchChoice===S){b.createSearchChoice=function(e){return{id:T.trim(e),text:T.trim(e)}}}if(b.initSelection===S){b.initSelection=function(e,t){var s=[];T(p(e.val(),b.separator,b.transformVal)).each(function(){var e={id:this,text:this},t=b.tags;if(T.isFunction(t))t=t();T(t).each(function(){if(d(this.id,e.id)){e=this;return false}});s.push(e)});t(s)}}}}}if(typeof b.query!=="function"){throw"query function not defined for Select2 "+b.element.attr("id")}if(b.createSearchChoicePosition==="top"){b.createSearchChoicePosition=function(e,t){e.unshift(t)}}else if(b.createSearchChoicePosition==="bottom"){b.createSearchChoicePosition=function(e,t){e.push(t)}}else if(typeof b.createSearchChoicePosition!=="function"){throw"invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function"}return b},monitorSource:function(){var s=this.opts.element,e,t=this;s.on("change.select2",this.bind(function(e){if(this.opts.element.data("select2-change-triggered")!==true){this.initSelection()}}));this._sync=this.bind(function(){var e=s.prop("disabled");if(e===S)e=false;this.enable(!e);var t=s.prop("readonly");if(t===S)t=false;this.readonly(t);if(this.container){k(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.addClass(N(this.opts.containerCssClass,this.opts.element))}if(this.dropdown){k(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass);this.dropdown.addClass(N(this.opts.dropdownCssClass,this.opts.element))}});if(s.length&&s[0].attachEvent){s.each(function(){this.attachEvent("onpropertychange",t._sync)})}e=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;if(e!==S){if(this.propertyObserver){delete this.propertyObserver;this.propertyObserver=null}this.propertyObserver=new e(function(e){T.each(e,t._sync)});this.propertyObserver.observe(s.get(0),{attributes:true,subtree:false})}},triggerSelect:function(e){var t=T.Event("select2-selecting",{val:this.id(e),object:e,choice:e});this.opts.element.trigger(t);return!t.isDefaultPrevented()},triggerChange:function(e){e=e||{};e=T.extend({},e,{type:"change",val:this.val()});this.opts.element.data("select2-change-triggered",true);this.opts.element.trigger(e);this.opts.element.data("select2-change-triggered",false);this.opts.element.click();if(this.opts.blurOnChange)this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===true},enableInterface:function(){var e=this._enabled&&!this._readonly,t=!e;if(e===this.enabledInterface)return false;this.container.toggleClass("select2-container-disabled",t);this.close();this.enabledInterface=e;return true},enable:function(e){if(e===S)e=true;if(this._enabled===e)return;this._enabled=e;this.opts.element.prop("disabled",!e);this.enableInterface()},disable:function(){this.enable(false)},readonly:function(e){if(e===S)e=false;if(this._readonly===e)return;this._readonly=e;this.opts.element.prop("readonly",e);this.enableInterface()},opened:function(){return this.container?this.container.hasClass("select2-dropdown-open"):false},positionDropdown:function(){var e=this.dropdown,t=this.container,s=t.offset(),i=t.outerHeight(false),n=t.outerWidth(false),o=e.outerHeight(false),a=T(window),r=a.width(),l=a.height(),c=a.scrollLeft()+r,h=a.scrollTop()+l,u=s.top+i,f=s.left,d=u+o<=h,p=s.top-o>=a.scrollTop(),g=e.outerWidth(false),m=function(){return f+g<=c},v=function(){return s.left+c+t.outerWidth(false)>g},b=e.hasClass("select2-drop-above"),w,S,C,y,x;if(b){S=true;if(!p&&d){C=true;S=false}}else{S=false;if(!d&&p){C=true;S=true}}if(C){e.hide();s=this.container.offset();i=this.container.outerHeight(false);n=this.container.outerWidth(false);o=e.outerHeight(false);c=a.scrollLeft()+r;h=a.scrollTop()+l;u=s.top+i;f=s.left;g=e.outerWidth(false);e.show();this.focusSearch()}if(this.opts.dropdownAutoWidth){x=T(".select2-results",e)[0];e.addClass("select2-drop-auto-width");e.css("width","");g=e.outerWidth(false)+(x.scrollHeight===x.clientHeight?0:E.width);g>n?n=g:g=n;o=e.outerHeight(false)}else{this.container.removeClass("select2-drop-auto-width")}if(this.body.css("position")!=="static"){w=this.body.offset();u-=w.top;f-=w.left}if(!m()&&v()){f=s.left+this.container.outerWidth(false)-g}y={left:f,width:n};if(S){this.container.addClass("select2-drop-above");e.addClass("select2-drop-above");o=e.outerHeight(false);y.top=s.top-o;y.bottom="auto"}else{y.top=u;y.bottom="auto";this.container.removeClass("select2-drop-above");e.removeClass("select2-drop-above")}y=T.extend(y,N(this.opts.dropdownCss,this.opts.element));e.css(y)},shouldOpen:function(){var e;if(this.opened())return false;if(this._enabled===false||this._readonly===true)return false;e=T.Event("select2-opening");this.opts.element.trigger(e);return!e.isDefaultPrevented()},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above");this.dropdown.removeClass("select2-drop-above")},open:function(){if(!this.shouldOpen())return false;this.opening();o.on("mousemove.select2Event",function(e){n.x=e.pageX;n.y=e.pageY});return true},opening:function(){var e=this.containerEventName,t="scroll."+e,s="resize."+e,i="orientationchange."+e,n;this.container.addClass("select2-dropdown-open").addClass("select2-container-active");this.clearDropdownAlignmentPreference();if(this.dropdown[0]!==this.body.children().last()[0]){this.dropdown.detach().appendTo(this.body)}n=T("#select2-drop-mask");if(n.length===0){n=T(document.createElement("div"));n.attr("id","select2-drop-mask").attr("class","select2-drop-mask");n.hide();n.appendTo(this.body);n.on("mousedown touchstart click",function(e){c(n);var t=T("#select2-drop"),s;if(t.length>0){s=t.data("select2");if(s.opts.selectOnBlur){s.selectHighlighted({noFocus:true})}s.close();e.preventDefault();e.stopPropagation()}})}if(this.dropdown.prev()[0]!==n[0]){this.dropdown.before(n)}T("#select2-drop").removeAttr("id");this.dropdown.attr("id","select2-drop");n.show();this.positionDropdown();this.dropdown.show();this.positionDropdown();this.dropdown.addClass("select2-drop-active");var o=this;this.container.parents().add(window).each(function(){T(this).on(s+" "+t+" "+i,function(e){if(o.opened())o.positionDropdown()})})},close:function(){if(!this.opened())return;var e=this.containerEventName,t="scroll."+e,s="resize."+e,i="orientationchange."+e;this.container.parents().add(window).each(function(){T(this).off(t).off(s).off(i)});this.clearDropdownAlignmentPreference();T("#select2-drop-mask").hide();this.dropdown.removeAttr("id");this.dropdown.hide();this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");this.results.empty();o.off("mousemove.select2Event");this.clearSearch();this.search.removeClass("select2-active");this.search.removeAttr("aria-activedescendant");this.opts.element.trigger(T.Event("select2-close"))},externalSearch:function(e){this.open();this.search.val(e);this.updateResults(false)},clearSearch:function(){},prefillNextSearchTerm:function(){if(this.search.val()!==""){return false}var e=this.opts.nextSearchTerm(this.data(),this.lastSearchTerm);if(e!==S){this.search.val(e);this.search.select();return true}return false},getMaximumSelectionSize:function(){return N(this.opts.maximumSelectionSize,this.opts.element)},ensureHighlightVisible:function(){var e=this.results,t,s,i,n,o,a,r,l;s=this.highlight();if(s<0)return;if(s==0){e.scrollTop(0);return}t=this.findHighlightableChoices().find(".select2-result-label");i=T(t[s]);l=(i.offset()||{}).top||0;n=l+i.outerHeight(true);if(s===t.length-1){r=e.find("li.select2-more-results");if(r.length>0){n=r.offset().top+r.outerHeight(true)}}o=e.offset().top+e.outerHeight(false);if(n>o){e.scrollTop(e.scrollTop()+(n-o))}a=l-e.offset().top;if(a<0&&i.css("display")!="none"){e.scrollTop(e.scrollTop()+a)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)")},moveHighlight:function(e){var t=this.findHighlightableChoices(),s=this.highlight();while(s>-1&&s<t.length){s+=e;var i=T(t[s]);if(i.hasClass("select2-result-selectable")&&!i.hasClass("select2-disabled")&&!i.hasClass("select2-selected")){this.highlight(s);break}}},highlight:function(e){var t=this.findHighlightableChoices(),s,i;if(arguments.length===0){return u(t.filter(".select2-highlighted")[0],t.get())}if(e>=t.length)e=t.length-1;if(e<0)e=0;this.removeHighlight();s=T(t[e]);s.addClass("select2-highlighted");this.search.attr("aria-activedescendant",s.find(".select2-result-label").attr("id"));this.ensureHighlightVisible();this.liveRegion.text(s.text());i=s.data("select2-data");if(i){this.opts.element.trigger({type:"select2-highlight",val:this.id(i),choice:i})}},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},touchMoved:function(){this._touchMoved=true},clearTouchMoved:function(){this._touchMoved=false},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(e){var t=T(e.target).closest(".select2-result-selectable");if(t.length>0&&!t.is(".select2-highlighted")){var s=this.findHighlightableChoices();this.highlight(s.index(t))}else if(t.length==0){this.removeHighlight()}},loadMoreIfNeeded:function(){var t=this.results,s=t.find("li.select2-more-results"),e,i=this.resultsPage+1,n=this,o=this.search.val(),a=this.context;if(s.length===0)return;e=s.offset().top-t.offset().top-t.height();if(e<=this.opts.loadMorePadding){s.addClass("select2-active");this.opts.query({element:this.opts.element,term:o,page:i,context:a,matcher:this.opts.matcher,callback:this.bind(function(e){if(!n.opened())return;n.opts.populateResults.call(this,t,e.results,{term:o,page:i,context:a});n.postprocessResults(e,false,false);if(e.more===true){s.detach().appendTo(t).html(n.opts.escapeMarkup(N(n.opts.formatLoadMore,n.opts.element,i+1)));window.setTimeout(function(){n.loadMoreIfNeeded()},10)}else{s.remove()}n.positionDropdown();n.resultsPage=i;n.context=e.context;this.opts.element.trigger({type:"select2-loaded",items:e})})})}},tokenize:function(){},updateResults:function(s){var i=this.search,n=this.results,o=this.opts,e,a=this,t,r=i.val(),l=T.data(this.container,"select2-last-term"),c;if(s!==true&&l&&d(r,l))return;T.data(this.container,"select2-last-term",r);if(s!==true&&(this.showSearchInput===false||!this.opened())){return}function h(){i.removeClass("select2-active");a.positionDropdown();if(n.find(".select2-no-results,.select2-selection-limit,.select2-searching").length){a.liveRegion.text(n.text())}else{a.liveRegion.text(a.opts.formatMatches(n.find('.select2-result-selectable:not(".select2-selected")').length))}}function u(e){n.html(e);h()}c=++this.queryCount;var f=this.getMaximumSelectionSize();if(f>=1){e=this.data();if(T.isArray(e)&&e.length>=f&&H(o.formatSelectionTooBig,"formatSelectionTooBig")){u("<li class='select2-selection-limit'>"+N(o.formatSelectionTooBig,o.element,f)+"</li>");return}}if(i.val().length<o.minimumInputLength){if(H(o.formatInputTooShort,"formatInputTooShort")){u("<li class='select2-no-results'>"+N(o.formatInputTooShort,o.element,i.val(),o.minimumInputLength)+"</li>")}else{u("")}if(s&&this.showSearch)this.showSearch(true);return}if(o.maximumInputLength&&i.val().length>o.maximumInputLength){if(H(o.formatInputTooLong,"formatInputTooLong")){u("<li class='select2-no-results'>"+N(o.formatInputTooLong,o.element,i.val(),o.maximumInputLength)+"</li>")}else{u("")}return}if(o.formatSearching&&this.findHighlightableChoices().length===0){u("<li class='select2-searching'>"+N(o.formatSearching,o.element)+"</li>")}i.addClass("select2-active");this.removeHighlight();t=this.tokenize();if(t!=S&&t!=null){i.val(t)}this.resultsPage=1;o.query({element:o.element,term:i.val(),page:this.resultsPage,context:null,matcher:o.matcher,callback:this.bind(function(e){var t;if(c!=this.queryCount){return}if(!this.opened()){this.search.removeClass("select2-active");return}if(e.hasError!==S&&H(o.formatAjaxError,"formatAjaxError")){u("<li class='select2-ajax-error'>"+N(o.formatAjaxError,o.element,e.jqXHR,e.textStatus,e.errorThrown)+"</li>");return}this.context=e.context===S?null:e.context;if(this.opts.createSearchChoice&&i.val()!==""){t=this.opts.createSearchChoice.call(a,i.val(),e.results);if(t!==S&&t!==null&&a.id(t)!==S&&a.id(t)!==null){if(T(e.results).filter(function(){return d(a.id(this),a.id(t))}).length===0){this.opts.createSearchChoicePosition(e.results,t)}}}if(e.results.length===0&&H(o.formatNoMatches,"formatNoMatches")){u("<li class='select2-no-results'>"+N(o.formatNoMatches,o.element,i.val())+"</li>");if(this.showSearch){this.showSearch(i.val())}return}n.empty();a.opts.populateResults.call(this,n,e.results,{term:i.val(),page:this.resultsPage,context:null});if(e.more===true&&H(o.formatLoadMore,"formatLoadMore")){n.append("<li class='select2-more-results'>"+o.escapeMarkup(N(o.formatLoadMore,o.element,this.resultsPage))+"</li>");window.setTimeout(function(){a.loadMoreIfNeeded()},10)}this.postprocessResults(e,s);h();this.opts.element.trigger({type:"select2-loaded",items:e})})})},cancel:function(){this.close()},blur:function(){if(this.opts.selectOnBlur)this.selectHighlighted({noFocus:true});this.close();this.container.removeClass("select2-container-active");if(this.search[0]===document.activeElement){this.search.blur()}this.clearSearch();this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){y(this.search)},selectHighlighted:function(e){if(this._touchMoved){this.clearTouchMoved();return}var t=this.highlight(),s=this.results.find(".select2-highlighted"),i=s.closest(".select2-result").data("select2-data");if(i){this.highlight(t);this.onSelect(i,e)}else if(e&&e.noFocus){this.close()}},getPlaceholder:function(){var e;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((e=this.getPlaceholderOption())!==S?e.text():S)},getPlaceholderOption:function(){if(this.select){var e=this.select.children("option").first();if(this.opts.placeholderOption!==S){return this.opts.placeholderOption==="first"&&e||typeof this.opts.placeholderOption==="function"&&this.opts.placeholderOption(this.select)}else if(T.trim(e.text())===""&&e.val()===""){return e}}},initContainerWidth:function(){function e(){var e,t,s,i,n,o;if(this.opts.width==="off"){return null}else if(this.opts.width==="element"){return this.opts.element.outerWidth(false)===0?"auto":this.opts.element.outerWidth(false)+"px"}else if(this.opts.width==="copy"||this.opts.width==="resolve"){e=this.opts.element.attr("style");if(typeof e==="string"){t=e.split(";");for(i=0,n=t.length;i<n;i=i+1){o=t[i].replace(/\s/g,"");s=o.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);if(s!==null&&s.length>=1)return s[1]}}if(this.opts.width==="resolve"){e=this.opts.element.css("width");if(e.indexOf("%")>0)return e;return this.opts.element.outerWidth(false)===0?"auto":this.opts.element.outerWidth(false)+"px"}return null}else if(T.isFunction(this.opts.width)){return this.opts.width()}else{return this.opts.width}}var t=e.call(this);if(t!==null){this.container.css("width",t)}}});t=z(e,{createContainer:function(){var e=T(document.createElement("div")).attr({class:"select2-container"}).html(["<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>","   <span class='select2-chosen'>&#160;</span><abbr class='select2-search-choice-close'></abbr>","   <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>","</a>","<label for='' class='select2-offscreen'></label>","<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />","<div class='select2-drop select2-display-none'>","   <div class='select2-search'>","       <label for='' class='select2-offscreen'></label>","       <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'","       aria-autocomplete='list' />","   </div>","   <ul class='select2-results' role='listbox'>","   </ul>","</div>"].join(""));return e},enableInterface:function(){if(this.parent.enableInterface.apply(this,arguments)){this.focusser.prop("disabled",!this.isInterfaceEnabled())}},opening:function(){var e,t,s;if(this.opts.minimumResultsForSearch>=0){this.showSearch(true)}this.parent.opening.apply(this,arguments);if(this.showSearchInput!==false){this.search.val(this.focusser.val())}if(this.opts.shouldFocusInput(this)){this.search.focus();e=this.search.get(0);if(e.createTextRange){t=e.createTextRange();t.collapse(false);t.select()}else if(e.setSelectionRange){s=this.search.val().length;e.setSelectionRange(s,s)}}this.prefillNextSearchTerm();this.focusser.prop("disabled",true).val("");this.updateResults(true);this.opts.element.trigger(T.Event("select2-open"))},close:function(){if(!this.opened())return;this.parent.close.apply(this,arguments);this.focusser.prop("disabled",false);if(this.opts.shouldFocusInput(this)){this.focusser.focus()}},focus:function(){if(this.opened()){this.close()}else{this.focusser.prop("disabled",false);if(this.opts.shouldFocusInput(this)){this.focusser.focus()}}},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments);this.focusser.prop("disabled",false);if(this.opts.shouldFocusInput(this)){this.focusser.focus()}},destroy:function(){T("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id"));this.parent.destroy.apply(this,arguments);j.call(this,"selection","focusser")},initContainer:function(){var t,e=this.container,s=this.dropdown,i=C(),n;if(this.opts.minimumResultsForSearch<0){this.showSearch(false)}else{this.showSearch(true)}this.selection=t=e.find(".select2-choice");this.focusser=e.find(".select2-focusser");t.find(".select2-chosen").attr("id","select2-chosen-"+i);this.focusser.attr("aria-labelledby","select2-chosen-"+i);this.results.attr("id","select2-results-"+i);this.search.attr("aria-owns","select2-results-"+i);this.focusser.attr("id","s2id_autogen"+i);n=T("label[for='"+this.opts.element.attr("id")+"']");this.opts.element.on("focus.select2",this.bind(function(){this.focus()}));this.focusser.prev().text(n.text()).attr("for",this.focusser.attr("id"));var o=this.opts.element.attr("title");this.opts.element.attr("title",o||n.text());this.focusser.attr("tabindex",this.elementTabIndex);this.search.attr("id",this.focusser.attr("id")+"_search");this.search.prev().text(T("label[for='"+this.focusser.attr("id")+"']").text()).attr("for",this.search.attr("id"));this.search.on("keydown",this.bind(function(e){if(!this.isInterfaceEnabled())return;if(229==e.keyCode)return;if(e.which===r.PAGE_UP||e.which===r.PAGE_DOWN){O(e);return}switch(e.which){case r.UP:case r.DOWN:this.moveHighlight(e.which===r.UP?-1:1);O(e);return;case r.ENTER:this.selectHighlighted();O(e);return;case r.TAB:this.selectHighlighted({noFocus:true});return;case r.ESC:this.cancel(e);O(e);return}}));this.search.on("blur",this.bind(function(e){if(document.activeElement===this.body.get(0)){window.setTimeout(this.bind(function(){if(this.opened()&&this.results&&this.results.length>1){this.search.focus()}}),0)}}));this.focusser.on("keydown",this.bind(function(e){if(!this.isInterfaceEnabled())return;if(e.which===r.TAB||r.isControl(e)||r.isFunctionKey(e)||e.which===r.ESC){return}if(this.opts.openOnEnter===false&&e.which===r.ENTER){O(e);return}if(e.which==r.DOWN||e.which==r.UP||e.which==r.ENTER&&this.opts.openOnEnter){if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return;this.open();O(e);return}if(e.which==r.DELETE||e.which==r.BACKSPACE){if(this.opts.allowClear){this.clear()}O(e);return}}));m(this.focusser);this.focusser.on("keyup-change input",this.bind(function(e){if(this.opts.minimumResultsForSearch>=0){e.stopPropagation();if(this.opened())return;this.open()}}));t.on("mousedown touchstart","abbr",this.bind(function(e){if(!this.isInterfaceEnabled()){return}this.clear();I(e);this.close();if(this.selection){this.selection.focus()}}));t.on("mousedown touchstart",this.bind(function(e){c(t);if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(T.Event("select2-focus"))}if(this.opened()){this.close()}else if(this.isInterfaceEnabled()){this.open()}O(e)}));s.on("mousedown touchstart",this.bind(function(){if(this.opts.shouldFocusInput(this)){this.search.focus()}}));t.on("focus",this.bind(function(e){O(e)}));this.focusser.on("focus",this.bind(function(){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(T.Event("select2-focus"))}this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){if(!this.opened()){this.container.removeClass("select2-container-active");this.opts.element.trigger(T.Event("select2-blur"))}}));this.search.on("focus",this.bind(function(){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(T.Event("select2-focus"))}this.container.addClass("select2-container-active")}));this.initContainerWidth();this.opts.element.hide();this.setPlaceholder()},clear:function(e){var t=this.selection.data("select2-data");if(t){var s=T.Event("select2-clearing");this.opts.element.trigger(s);if(s.isDefaultPrevented()){return}var i=this.getPlaceholderOption();this.opts.element.val(i?i.val():"");this.selection.find(".select2-chosen").empty();this.selection.removeData("select2-data");this.setPlaceholder();if(e!==false){this.opts.element.trigger({type:"select2-removed",val:this.id(t),choice:t});this.triggerChange({removed:t})}}},initSelection:function(){var e;if(this.isPlaceholderOptionSelected()){this.updateSelection(null);this.close();this.setPlaceholder()}else{var t=this;this.opts.initSelection.call(null,this.opts.element,function(e){if(e!==S&&e!==null){t.updateSelection(e);t.close();t.setPlaceholder();t.lastSearchTerm=t.search.val()}})}},isPlaceholderOptionSelected:function(){var e;if(this.getPlaceholder()===S)return false;return(e=this.getPlaceholderOption())!==S&&e.prop("selected")||this.opts.element.val()===""||this.opts.element.val()===S||this.opts.element.val()===null},prepareOpts:function(){var a=this.parent.prepareOpts.apply(this,arguments),i=this;if(a.element.get(0).tagName.toLowerCase()==="select"){a.initSelection=function(e,t){var s=e.find("option").filter(function(){return this.selected&&!this.disabled});t(i.optionToData(s))}}else if("data"in a){a.initSelection=a.initSelection||function(e,t){var n=e.val();var o=null;a.query({matcher:function(e,t,s){var i=d(n,a.id(s));if(i){o=s}return i},callback:!T.isFunction(t)?T.noop:function(){t(o)}})}}return a},getPlaceholder:function(){if(this.select){if(this.getPlaceholderOption()===S){return S}}return this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var e=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&e!==S){if(this.select&&this.getPlaceholderOption()===S)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(e));this.selection.addClass("select2-default");this.container.removeClass("select2-allowclear")}},postprocessResults:function(e,t,s){var i=0,n=this,o=true;this.findHighlightableChoices().each2(function(e,t){if(d(n.id(t.data("select2-data")),n.opts.element.val())){i=e;return false}});if(s!==false){if(t===true&&i>=0){this.highlight(i)}else{this.highlight(0)}}if(t===true){var a=this.opts.minimumResultsForSearch;if(a>=0){this.showSearch(F(e.results)>=a)}}},showSearch:function(e){if(this.showSearchInput===e)return;this.showSearchInput=e;this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!e);this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!e);T(this.dropdown,this.container).toggleClass("select2-with-searchbox",e)},onSelect:function(e,t){if(!this.triggerSelect(e)){return}var s=this.opts.element.val(),i=this.data();this.opts.element.val(this.id(e));this.updateSelection(e);this.opts.element.trigger({type:"select2-selected",val:this.id(e),choice:e});this.lastSearchTerm=this.search.val();this.close();if((!t||!t.noFocus)&&this.opts.shouldFocusInput(this)){this.focusser.focus()}if(!d(s,this.id(e))){this.triggerChange({added:e,removed:i})}},updateSelection:function(e){var t=this.selection.find(".select2-chosen"),s,i;this.selection.data("select2-data",e);t.empty();if(e!==null){s=this.opts.formatSelection(e,t,this.opts.escapeMarkup)}if(s!==S){t.append(s)}i=this.opts.formatSelectionCssClass(e,t);if(i!==S){t.addClass(i)}this.selection.removeClass("select2-default");if(this.opts.allowClear&&this.getPlaceholder()!==S){this.container.addClass("select2-allowclear")}},val:function(){var e,t=false,s=null,i=this,n=this.data();if(arguments.length===0){return this.opts.element.val()}e=arguments[0];if(arguments.length>1){t=arguments[1];if(this.opts.debug&&console&&console.warn){console.warn('Select2: The second option to `select2("val")` is not supported in Select2 4.0.0. '+"The `change` event will always be triggered in 4.0.0.")}}if(this.select){if(this.opts.debug&&console&&console.warn){console.warn('Select2: Setting the value on a <select> using `select2("val")` is no longer supported in 4.0.0. '+'You can use the `.val(newValue).trigger("change")` method provided by jQuery instead.')}this.select.val(e).find("option").filter(function(){return this.selected}).each2(function(e,t){s=i.optionToData(t);return false});this.updateSelection(s);this.setPlaceholder();if(t){this.triggerChange({added:s,removed:n})}}else{if(!e&&e!==0){this.clear(t);return}if(this.opts.initSelection===S){throw new Error("cannot call val() if initSelection() is not defined")}this.opts.element.val(e);this.opts.initSelection(this.opts.element,function(e){i.opts.element.val(!e?"":i.id(e));i.updateSelection(e);i.setPlaceholder();if(t){i.triggerChange({added:e,removed:n})}})}},clearSearch:function(){this.search.val("");this.focusser.val("")},data:function(e){var t,s=false;if(arguments.length===0){t=this.selection.data("select2-data");if(t==S)t=null;return t}else{if(this.opts.debug&&console&&console.warn){console.warn('Select2: The `select2("data")` method can no longer set selected values in 4.0.0, '+"consider using the `.val()` method instead.")}if(arguments.length>1){s=arguments[1]}if(!e){this.clear(s)}else{t=this.data();this.opts.element.val(!e?"":this.id(e));this.updateSelection(e);if(s){this.triggerChange({added:e,removed:t})}}}}});s=z(e,{createContainer:function(){var e=T(document.createElement("div")).attr({class:"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>","  <li class='select2-search-field'>","    <label for='' class='select2-offscreen'></label>","    <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>","  </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>","   <ul class='select2-results'>","   </ul>","</div>"].join(""));return e},prepareOpts:function(){var l=this.parent.prepareOpts.apply(this,arguments),i=this;if(l.element.get(0).tagName.toLowerCase()==="select"){l.initSelection=function(e,t){var s=[];e.find("option").filter(function(){return this.selected&&!this.disabled}).each2(function(e,t){s.push(i.optionToData(t))});t(s)}}else if("data"in l){l.initSelection=l.initSelection||function(e,o){var a=p(e.val(),l.separator,l.transformVal);var r=[];l.query({matcher:function(e,t,s){var i=T.grep(a,function(e){return d(e,l.id(s))}).length;if(i){r.push(s)}return i},callback:!T.isFunction(o)?T.noop:function(){var e=[];for(var t=0;t<a.length;t++){var s=a[t];for(var i=0;i<r.length;i++){var n=r[i];if(d(s,l.id(n))){e.push(n);r.splice(i,1);break}}}o(e)}})}}return l},selectChoice:function(e){var t=this.container.find(".select2-search-choice-focus");if(t.length&&e&&e[0]==t[0]){}else{if(t.length){this.opts.element.trigger("choice-deselected",t)}t.removeClass("select2-search-choice-focus");if(e&&e.length){this.close();e.addClass("select2-search-choice-focus");this.opts.element.trigger("choice-selected",e)}}},destroy:function(){T("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id"));this.parent.destroy.apply(this,arguments);j.call(this,"searchContainer","selection")},initContainer:function(){var e=".select2-choices",a;this.searchContainer=this.container.find(".select2-search-field");this.selection=a=this.container.find(e);var t=this;this.selection.on("click",".select2-container:not(.select2-container-disabled) .select2-search-choice:not(.select2-locked)",function(e){t.search[0].focus();t.selectChoice(T(this))});this.search.attr("id","s2id_autogen"+C());this.search.prev().text(T("label[for='"+this.opts.element.attr("id")+"']").text()).attr("for",this.search.attr("id"));this.opts.element.on("focus.select2",this.bind(function(){this.focus()}));this.search.on("input paste",this.bind(function(){if(this.search.attr("placeholder")&&this.search.val().length==0)return;if(!this.isInterfaceEnabled())return;if(!this.opened()){this.open()}}));this.search.attr("tabindex",this.elementTabIndex);this.keydowns=0;this.search.on("keydown",this.bind(function(e){if(!this.isInterfaceEnabled())return;++this.keydowns;var t=a.find(".select2-search-choice-focus");var s=t.prev(".select2-search-choice:not(.select2-locked)");var i=t.next(".select2-search-choice:not(.select2-locked)");var n=x(this.search);if(t.length&&(e.which==r.LEFT||e.which==r.RIGHT||e.which==r.BACKSPACE||e.which==r.DELETE||e.which==r.ENTER)){var o=t;if(e.which==r.LEFT&&s.length){o=s}else if(e.which==r.RIGHT){o=i.length?i:null}else if(e.which===r.BACKSPACE){if(this.unselect(t.first())){this.search.width(10);o=s.length?s:i}}else if(e.which==r.DELETE){if(this.unselect(t.first())){this.search.width(10);o=i.length?i:null}}else if(e.which==r.ENTER){o=null}this.selectChoice(o);O(e);if(!o||!o.length){this.open()}return}else if((e.which===r.BACKSPACE&&this.keydowns==1||e.which==r.LEFT)&&(n.offset==0&&!n.length)){this.selectChoice(a.find(".select2-search-choice:not(.select2-locked)").last());O(e);return}else{this.selectChoice(null)}if(this.opened()){switch(e.which){case r.UP:case r.DOWN:this.moveHighlight(e.which===r.UP?-1:1);O(e);return;case r.ENTER:this.selectHighlighted();O(e);return;case r.TAB:this.selectHighlighted({noFocus:true});this.close();return;case r.ESC:this.cancel(e);O(e);return}}if(e.which===r.TAB||r.isControl(e)||r.isFunctionKey(e)||e.which===r.BACKSPACE||e.which===r.ESC){return}if(e.which===r.ENTER){if(this.opts.openOnEnter===false){return}else if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey){return}}this.open();if(e.which===r.PAGE_UP||e.which===r.PAGE_DOWN){O(e)}if(e.which===r.ENTER){O(e)}}));this.search.on("keyup",this.bind(function(e){this.keydowns=0;this.resizeSearch()}));this.search.on("blur",this.bind(function(e){this.container.removeClass("select2-container-active");this.search.removeClass("select2-focused");this.selectChoice(null);if(!this.opened())this.clearSearch();e.stopImmediatePropagation();this.opts.element.trigger(T.Event("select2-blur"))}));this.container.on("click",e,this.bind(function(e){if(!this.isInterfaceEnabled())return;if(T(e.target).closest(".select2-search-choice").length>0){return}this.selectChoice(null);this.clearPlaceholder();if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(T.Event("select2-focus"))}this.open();this.focusSearch();e.preventDefault()}));this.container.on("focus",e,this.bind(function(){if(!this.isInterfaceEnabled())return;if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(T.Event("select2-focus"))}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active");this.clearPlaceholder()}));this.initContainerWidth();this.opts.element.hide();this.clearSearch()},enableInterface:function(){if(this.parent.enableInterface.apply(this,arguments)){this.search.prop("disabled",!this.isInterfaceEnabled())}},initSelection:function(){var e;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.updateSelection([]);this.close();this.clearSearch()}if(this.select||this.opts.element.val()!==""){var t=this;this.opts.initSelection.call(null,this.opts.element,function(e){if(e!==S&&e!==null){t.updateSelection(e);t.close();t.clearSearch()}})}},clearSearch:function(){var e=this.getPlaceholder(),t=this.getMaxSearchWidth();if(e!==S&&this.getVal().length===0&&this.search.hasClass("select2-focused")===false){this.search.val(e).addClass("select2-default");this.search.width(t>0?t:this.container.css("width"))}else{this.search.val("").width(10)}},clearPlaceholder:function(){if(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.prefillNextSearchTerm();this.updateResults(true);if(this.opts.shouldFocusInput(this)){this.search.focus()}this.opts.element.trigger(T.Event("select2-open"))},close:function(){if(!this.opened())return;this.parent.close.apply(this,arguments)},focus:function(){this.close();this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(e){var t={},s=[],i=this;T(e).each(function(){if(!(i.id(this)in t)){t[i.id(this)]=0;s.push(this)}});this.selection.find(".select2-search-choice").remove();this.addSelectedChoice(s);i.postprocessResults()},tokenize:function(){var e=this.search.val();e=this.opts.tokenizer.call(this,e,this.data(),this.bind(this.onSelect),this.opts);if(e!=null&&e!=S){this.search.val(e);if(e.length>0){this.open()}}},onSelect:function(e,t){if(!this.triggerSelect(e)||e.text===""){return}this.addSelectedChoice(e);this.opts.element.trigger({type:"selected",val:this.id(e),choice:e});this.lastSearchTerm=this.search.val();this.clearSearch();this.updateResults();if(this.select||!this.opts.closeOnSelect)this.postprocessResults(e,false,this.opts.closeOnSelect===true);if(this.opts.closeOnSelect){this.close();this.search.width(10)}else{if(this.countSelectableResults()>0){this.search.width(10);this.resizeSearch();if(this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()){this.updateResults(true)}else{if(this.prefillNextSearchTerm()){this.updateResults()}}this.positionDropdown()}else{this.close();this.search.width(10)}}this.triggerChange({added:e});if(!t||!t.noFocus)this.focusSearch()},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(e){var t=this.getVal(),s=this;T(e).each(function(){t.push(s.createChoice(this))});this.setVal(t)},createChoice:function(e){var t=!e.locked,s=T("<li class='select2-search-choice'>"+"    <div></div>"+"    <a href='#' class='select2-search-choice-close' tabindex='-1'></a>"+"</li>"),i=T("<li class='select2-search-choice select2-locked'>"+"<div></div>"+"</li>");var n=t?s:i,o=this.id(e),a,r;a=this.opts.formatSelection(e,n.find("div"),this.opts.escapeMarkup);if(a!=S){n.find("div").replaceWith(T("<div></div>").html(a))}r=this.opts.formatSelectionCssClass(e,n.find("div"));if(r!=S){n.addClass(r)}if(t){n.find(".select2-search-choice-close").on("mousedown",O).on("click dblclick",this.bind(function(e){if(!this.isInterfaceEnabled())return;this.unselect(T(e.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");O(e);this.close();this.focusSearch()})).on("focus",this.bind(function(){if(!this.isInterfaceEnabled())return;this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active")}))}n.data("select2-data",e);n.insertBefore(this.searchContainer);return o},unselect:function(e){var t=this.getVal(),s,i;e=e.closest(".select2-search-choice");if(e.length===0){throw"Invalid argument: "+e+". Must be .select2-search-choice"}s=e.data("select2-data");if(!s){return}var n=T.Event("select2-removing");n.val=this.id(s);n.choice=s;this.opts.element.trigger(n);if(n.isDefaultPrevented()){return false}while((i=u(this.id(s),t))>=0){t.splice(i,1);this.setVal(t);if(this.select)this.postprocessResults()}e.remove();this.opts.element.trigger({type:"select2-removed",val:this.id(s),choice:s});this.triggerChange({removed:s});return true},postprocessResults:function(e,t,s){var i=this.getVal(),n=this.results.find(".select2-result"),o=this.results.find(".select2-result-with-children"),a=this;n.each2(function(e,t){var s=a.id(t.data("select2-data"));if(u(s,i)>=0){t.addClass("select2-selected");t.find(".select2-result-selectable").addClass("select2-selected")}});o.each2(function(e,t){if(!t.is(".select2-result-selectable")&&t.find(".select2-result-selectable:not(.select2-selected)").length===0){t.addClass("select2-selected")}});if(this.highlight()==-1&&s!==false&&this.opts.closeOnSelect===true){a.highlight(0)}if(!this.opts.createSearchChoice&&!n.filter(".select2-result:not(.select2-selected)").length>0){if(!e||e&&!e.more&&this.results.find(".select2-no-results").length===0){if(H(a.opts.formatNoMatches,"formatNoMatches")){this.results.append("<li class='select2-no-results'>"+N(a.opts.formatNoMatches,a.opts.element,a.search.val())+"</li>")}}}},getMaxSearchWidth:function(){return this.selection.width()-g(this.search)},resizeSearch:function(){var e,t,s,i,n,o=g(this.search);e=P(this.search)+10;t=this.search.offset().left;s=this.selection.width();i=this.selection.offset().left;n=s-(t-i)-o;if(n<e){n=s-o}if(n<40){n=s-o}if(n<=0){n=e}this.search.width(Math.floor(n))},getVal:function(){var e;if(this.select){e=this.select.val();return e===null?[]:e}else{e=this.opts.element.val();return p(e,this.opts.separator,this.opts.transformVal)}},setVal:function(e){if(this.select){this.select.val(e)}else{var t=[],s={};T(e).each(function(){if(!(this in s)){t.push(this);s[this]=0}});this.opts.element.val(t.length===0?"":t.join(this.opts.separator))}},buildChangeDetails:function(e,t){var t=t.slice(0),e=e.slice(0);for(var s=0;s<t.length;s++){for(var i=0;i<e.length;i++){if(d(this.opts.id(t[s]),this.opts.id(e[i]))){t.splice(s,1);s--;e.splice(i,1);break}}}return{added:t,removed:e}},val:function(e,s){var i,n=this;if(arguments.length===0){return this.getVal()}i=this.data();if(!i.length)i=[];if(!e&&e!==0){this.opts.element.val("");this.updateSelection([]);this.clearSearch();if(s){this.triggerChange({added:this.data(),removed:i})}return}this.setVal(e);if(this.select){this.opts.initSelection(this.select,this.bind(this.updateSelection));if(s){this.triggerChange(this.buildChangeDetails(i,this.data()))}}else{if(this.opts.initSelection===S){throw new Error("val() cannot be called if initSelection() is not defined")}this.opts.initSelection(this.opts.element,function(e){var t=T.map(e,n.id);n.setVal(t);n.updateSelection(e);n.clearSearch();if(s){n.triggerChange(n.buildChangeDetails(i,n.data()))}})}this.clearSearch()},onSortStart:function(){if(this.select){throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.")}this.search.width(0);this.searchContainer.hide()},onSortEnd:function(){var e=[],t=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch();this.selection.find(".select2-search-choice").each(function(){e.push(t.opts.id(T(this).data("select2-data")))});this.setVal(e);this.triggerChange()},data:function(e,t){var s=this,i,n;if(arguments.length===0){return this.selection.children(".select2-search-choice").map(function(){return T(this).data("select2-data")}).get()}else{n=this.data();if(!e){e=[]}i=T.map(e,function(e){return s.opts.id(e)});this.setVal(i);this.updateSelection(e);this.clearSearch();if(t){this.triggerChange(this.buildChangeDetails(n,this.data()))}}}});T.fn.select2=function(){var e=Array.prototype.slice.call(arguments,0),t,s,i,n,o,a=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],r=["opened","isFocused","container","dropdown"],l=["val","data"],c={search:"externalSearch"};this.each(function(){if(e.length===0||typeof e[0]==="object"){t=e.length===0?{}:T.extend({},e[0]);t.element=T(this);if(t.element.get(0).tagName.toLowerCase()==="select"){o=t.element.prop("multiple")}else{o=t.multiple||false;if("tags"in t){t.multiple=o=true}}s=o?new window.Select2["class"].multi:new window.Select2["class"].single;s.init(t)}else if(typeof e[0]==="string"){if(u(e[0],a)<0){throw"Unknown method: "+e[0]}n=S;s=T(this).data("select2");if(s===S)return;i=e[0];if(i==="container"){n=s.container}else if(i==="dropdown"){n=s.dropdown}else{if(c[i])i=c[i];n=s[i].apply(s,e.slice(1))}if(u(e[0],r)>=0||u(e[0],l)>=0&&e.length==1){return false}}else{throw"Invalid arguments to select2 plugin: "+e}});return n===S?this:n};T.fn.select2.defaults={debug:false,width:"copy",loadMorePadding:0,closeOnSelect:true,openOnEnter:true,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(e,t,s,i){var n=[];R(this.text(e),s.term,n,i);return n.join("")},transformVal:function(e){return T.trim(e)},formatSelection:function(e,t,s){return e?s(this.text(e)):S},sortResults:function(e,t,s){return e},formatResultCssClass:function(e){return e.css},formatSelectionCssClass:function(e,t){return S},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(e){return e==S?null:e.id},text:function(e){if(e&&this.data&&this.data.text){if(T.isFunction(this.data.text)){return this.data.text(e)}else{return e[this.data.text]}}else{return e.text}},matcher:function(e,t){return h(""+t).toUpperCase().indexOf(h(""+e).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:U,escapeMarkup:A,blurOnChange:false,selectOnBlur:false,adaptContainerCssClass:function(e){return e},adaptDropdownCssClass:function(e){return null},nextSearchTerm:function(e,t){return S},searchInputPlaceholder:"",createSearchChoicePosition:"top",shouldFocusInput:function(e){var t="ontouchstart"in window||navigator.msMaxTouchPoints>0;if(!t){return true}if(e.opts.minimumResultsForSearch<0){return false}return true}};T.fn.select2.locales=[];T.fn.select2.locales["en"]={formatMatches:function(e){if(e===1){return"One result is available, press enter to select it."}return e+" results are available, use up and down arrow keys to navigate."},formatNoMatches:function(){return"No matches found"},formatAjaxError:function(e,t,s){return"Loading failed"},formatInputTooShort:function(e,t){var s=t-e.length;return"Please enter "+s+" or more character"+(s==1?"":"s")},formatInputTooLong:function(e,t){var s=e.length-t;return"Please delete "+s+" character"+(s==1?"":"s")},formatSelectionTooBig:function(e){return"You can only select "+e+" item"+(e==1?"":"s")},formatLoadMore:function(e){return"Loading more results…"},formatSearching:function(){return"Searching…"}};T.extend(T.fn.select2.defaults,T.fn.select2.locales["en"]);T.fn.select2.ajaxDefaults={transport:T.ajax,params:{type:"GET",cache:false,dataType:"json"}};window.Select2={query:{ajax:D,local:L,tags:M},util:{debounce:b,markMatch:R,escapeMarkup:A,stripDiacritics:h},class:{abstract:e,single:t,multi:s}}})(jQuery);