laipower/wp-content/plugins/easy-digital-downloads/assets/js/vendor/chosen.jquery.min.js

3 lines
34 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Chosen v2.1.0 | (c) 2011-2020 JJJ | MIT License, https://github.com/jjj/chosen/blob/master/LICENSE.md */
(function(){var e,t,s,i;(i=class{constructor(e){this.options_index=0,this.parsed=[],this.copy_data_attributes=e.copy_data_attributes||!1}add_node(e){return"OPTGROUP"===e.nodeName.toUpperCase()?this.add_group(e):this.add_option(e)}add_group(e){var t,s,i,h,l,r;for(t=this.parsed.length,this.parsed.push({array_index:t,group:!0,label:e.label,title:e.title?e.title:void 0,children:0,disabled:e.disabled,hidden:e.hidden,classes:e.className}),r=[],s=0,i=(l=e.childNodes).length;s<i;s++)h=l[s],r.push(this.add_option(h,t,e.disabled));return r}add_option(e,t,s){if("OPTION"===e.nodeName.toUpperCase())return""!==e.text?(null!=t&&(this.parsed[t].children+=1),this.parsed.push({options_index:this.options_index,value:e.value,text:e.text,html:e.innerHTML.replace(/^\s+|\s+$/g,""),title:e.title?e.title:void 0,selected:e.selected,disabled:!0===s?s:e.disabled,hidden:e.hidden,group_array_index:t,group_label:null!=t?this.parsed[t].label:null,classes:e.className,style:e.style.cssText,data:this.parse_data_attributes(e)})):this.parsed.push({options_index:this.options_index,empty:!0,data:this.parse_data_attributes(e)}),this.options_index+=1}parse_data_attributes(e){var t,s,i,h,l,r;if(i={"data-option-array-index":this.parsed.length,"data-value":e.value},this.copy_data_attributes&&e)for(h=0,l=(r=e.attributes).length;h<l;h++)s=(t=r[h]).nodeName,/data-.*/.test(s)&&(i[s]=t.nodeValue);return i}}).select_to_array=function(e,t){var s,h,l,r,a;for(r=new i(t),h=0,l=(a=e.childNodes).length;h<l;h++)s=a[h],r.add_node(s);return r.parsed},t=function(){class e{constructor(t,s={}){this.label_click_handler=this.label_click_handler.bind(this),this.form_field=t,this.options=s,e.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.can_select_by_group=null!==this.form_field.getAttribute("select-by-group"),this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}set_default_values(){return this.click_test_action=(e=>this.test_active_click(e)),this.activate_action=(e=>this.activate_field(e)),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.is_rtl=this.options.rtl||/\bchosen-rtl\b/.test(this.form_field.className),this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text&&this.options.allow_single_deselect,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null==this.options.enable_split_word_search||this.options.enable_split_word_search,this.group_search=null==this.options.group_search||this.options.group_search,this.search_in_values=this.options.search_in_values||!1,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null==this.options.single_backstroke_delete||this.options.single_backstroke_delete,this.max_selected_options=this.options.max_selected_options||Infinity,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.inherit_option_classes=this.options.inherit_option_classes||!1,this.display_selected_options=null==this.options.display_selected_options||this.options.display_selected_options,this.display_disabled_options=null==this.options.display_disabled_options||this.options.display_disabled_options,this.parser_config=this.options.parser_config||{},this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY,this.case_sensitive_search=this.options.case_sensitive_search||!1,this.hide_results_on_select=null==this.options.hide_results_on_select||this.options.hide_results_on_select,this.create_option=this.options.create_option||!1,this.persistent_create_option=this.options.persistent_create_option||!1,this.skip_no_results=this.options.skip_no_results||!1}set_default_text(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||e.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||e.default_single_text,this.default_text=this.escape_html(this.default_text),this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||e.default_no_result_text,this.create_option_text=this.form_field.getAttribute("data-create_option_text")||this.options.create_option_text||e.default_create_option_text}choice_label(e){return this.include_group_label_in_selected&&null!=e.group_label?`<b class='group-name'>${this.escape_html(e.group_label)}</b>${e.html}`:e.html}mouse_enter(){return this.mouse_on_container=!0}mouse_leave(){return this.mouse_on_container=!1}input_focus(e){if(this.is_multiple){if(!this.active_field)return setTimeout(()=>this.container_mousedown(),50)}else if(!this.active_field)return this.activate_field()}input_blur(e){if(!this.mouse_on_container)return this.active_field=!1,setTimeout(()=>this.blur_test(),100)}label_click_handler(e){return this.is_multiple?this.container_mousedown(e):this.activate_field()}results_option_build(e){var t,s,i,h,l,r,a;for(t="",a=0,h=0,l=(r=this.results_data).length;h<l&&(i="",""!==(i=(s=r[h]).group?this.result_add_group(s):this.result_add_option(s))&&(a++,t+=i),(null!=e?e.first:void 0)&&(s.selected&&this.is_multiple?this.choice_build(s):s.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(s))),!(a>=this.max_shown_results));h++);return t}result_add_option(e){var t,s,i;if(!e.search_match)return"";if(!this.include_option_in_results(e))return"";for(t in s=[],e.disabled||e.selected&&this.is_multiple||s.push("active-result"),!e.disabled||e.selected&&this.is_multiple||s.push("disabled-result"),e.selected&&s.push("result-selected"),null!=e.group_array_index&&s.push("group-option"),""!==e.classes&&s.push(e.classes),(i=document.createElement("li")).className=s.join(" "),e.style&&(i.style.cssText=e.style),e.data)e.data.hasOwnProperty(t)&&i.setAttribute(t,e.data[t]);return i.setAttribute("role","option"),i.innerHTML=e.highlighted_html||e.html,i.id=`${this.form_field.id}-chosen-search-result-${e.data["data-option-array-index"]}`,e.title&&(i.title=e.title),this.outerHTML(i)}result_add_group(e){var t,s;return(e.search_match||e.group_match)&&e.active_options>0?((t=[]).push("group-result"),e.classes&&t.push(e.classes),(s=document.createElement("li")).className=t.join(" "),s.innerHTML=e.highlighted_html||this.escape_html(e.label),e.title&&(s.title=e.title),this.outerHTML(s)):""}append_option(e){return this.select_append_option(e)}results_update_field(){if(this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing)return this.winnow_results()}reset_single_select_options(){var e,t,s,i,h;for(h=[],e=0,t=(s=this.results_data).length;e<t;e++)(i=s[e]).selected?h.push(i.selected=!1):h.push(void 0);return h}results_toggle(){return this.results_showing?this.results_hide():this.results_show()}results_search(e){return this.results_showing?this.winnow_results():this.results_show(),this.form_field_jq.trigger("chosen:search",{chosen:this})}winnow_results(e){var t,s,i,h,l,r,a,o,n,_,c,u,d,p,f,g,m,v;for(this.no_results_clear(),d=0,i=!1,a=!1,t=(_=this.get_search_text()).replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),u=this.get_search_regex(t),s=new RegExp(`^${t}$`),this.get_highlight_regex(t),l=0,r=(c=this.results_data).length;l<r;l++)(o=c[l]).search_match=!1,p=null,f=null,o.highlighted_html="",this.include_option_in_results(o)&&(o.group&&(o.group_match=!1,o.active_options=0),null!=o.group_array_index&&this.results_data[o.group_array_index]&&(0===(p=this.results_data[o.group_array_index]).active_options&&p.search_match&&(d+=1),p.active_options+=1),v=o.group?o.label:o.text,o.group&&!this.group_search||(f=this.search_string_match(v,u),o.search_match=null!=f,!o.search_match&&this.search_in_values&&(o.search_match=this.search_string_match(o.value,u),a=!0),o.search_match&&!o.group&&(d+=1),i=i||s.test(o.html),o.search_match?(_.length&&!a&&(g=f.index,n=v.slice(0,g),h=v.slice(g,g+_.length),m=v.slice(g+_.length),o.highlighted_html=`${this.escape_html(n)}<em>${this.escape_html(h)}</em>${this.escape_html(m)}`),null!=p&&(p.group_match=!0)):null!=o.group_array_index&&this.results_data[o.group_array_index].search_match&&(o.search_match=!0)));if(this.result_clear_highlight(),d<1&&_.length?(this.update_results_content(""),this.fire_search_updated(_),this.create_option&&this.skip_no_results||this.no_results(_)):(this.update_results_content(this.results_option_build()),this.fire_search_updated(_),(null!=e?e.skip_highlight:void 0)||this.winnow_results_set_highlight()),this.create_option&&(d<1||!i&&this.persistent_create_option)&&_.length)return this.show_create_option(_)}get_search_regex(e){var t,s;return s=this.search_contains?e:`(^|\\s|\\b)${e}[^\\s]*`,this.enable_split_word_search||this.search_contains||(s=`^${s}`),t=this.case_sensitive_search?"":"i",new RegExp(s,t)}get_highlight_regex(e){var t,s;return t=this.search_contains?"":"\\b",s=this.case_sensitive_search?"":"i",new RegExp(t+e,s)}get_list_special_char(){var e;return(e=[]).push({val:"ae",let:"(ä|æ|ǽ)"}),e.push({val:"oe",let:"(ö|œ)"}),e.push({val:"ue",let:"(ü)"}),e.push({val:"Ae",let:"(Ä)"}),e.push({val:"Ue",let:"(Ü)"}),e.push({val:"Oe",let:"(Ö)"}),e.push({val:"AE",let:"(Æ|Ǽ)"}),e.push({val:"ss",let:"(ß)"}),e.push({val:"IJ",let:"(IJ)"}),e.push({val:"ij",let:"(ij)"}),e.push({val:"OE",let:"(Œ)"}),e.push({val:"A",let:"(À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ)"}),e.push({val:"a",let:"(à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª)"}),e.push({val:"C",let:"(Ç|Ć|Ĉ|Ċ|Č)"}),e.push({val:"c",let:"(ç|ć|ĉ|ċ|č)"}),e.push({val:"D",let:"(Ð|Ď|Đ)"}),e.push({val:"d",let:"(ð|ď|đ)"}),e.push({val:"E",let:"(È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě)"}),e.push({val:"e",let:"(è|é|ê|ë|ē|ĕ|ė|ę|ě)"}),e.push({val:"G",let:"(Ĝ|Ğ|Ġ|Ģ)"}),e.push({val:"g",let:"(ĝ|ğ|ġ|ģ)"}),e.push({val:"H",let:"(Ĥ|Ħ)"}),e.push({val:"h",let:"(ĥ|ħ)"}),e.push({val:"I",let:"(Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ)"}),e.push({val:"i",let:"(ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı)"}),e.push({val:"J",let:"(Ĵ)"}),e.push({val:"j",let:"(ĵ)"}),e.push({val:"K",let:"(Ķ)"}),e.push({val:"k",let:"(ķ)"}),e.push({val:"L",let:"(Ĺ|Ļ|Ľ|Ŀ|Ł)"}),e.push({val:"l",let:"(ĺ|ļ|ľ|ŀ|ł)"}),e.push({val:"N",let:"(Ñ|Ń|Ņ|Ň)"}),e.push({val:"n",let:"(ñ|ń|ņ|ň|ʼn)"}),e.push({val:"O",let:"(Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ)"}),e.push({val:"o",let:"(ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º)"}),e.push({val:"R",let:"(Ŕ|Ŗ|Ř)"}),e.push({val:"r",let:"(ŕ|ŗ|ř)"}),e.push({val:"S",let:"(Ś|Ŝ|Ş|Š)"}),e.push({val:"s",let:"(ś|ŝ|ş|š|ſ)"}),e.push({val:"T",let:"(Ţ|Ť|Ŧ)"}),e.push({val:"t",let:"(ţ|ť|ŧ)"}),e.push({val:"U",let:"(Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ)"}),e.push({val:"u",let:"(ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ)"}),e.push({val:"Y",let:"(Ý|Ÿ|Ŷ)"}),e.push({val:"y",let:"(ý|ÿ|ŷ)"}),e.push({val:"W",let:"(Ŵ)"}),e.push({val:"w",let:"(ŵ)"}),e.push({val:"Z",let:"(Ź|Ż|Ž)"}),e.push({val:"z",let:"(ź|ż|ž)"}),e.push({val:"f",let:"(ƒ)"}),e}escape_special_char(e){var t,s,i,h;for(t=0,s=(h=this.get_list_special_char()).length;t<s;t++)i=h[t],e.replace(new RegExp(i.let,"g"),i.val);return e}search_string_match(e,t){var s;return s=t.exec(e),this.case_sensitive_search||null==s||(s=t.exec(this.escape_special_char(e))),!this.search_contains&&(null!=s?s[1]:void 0)&&(s.index+=1),s}choices_count(){var e,t,s;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,e=0,t=(s=this.form_field.options).length;e<t;e++)s[e].selected&&(this.selected_option_count+=1);return this.selected_option_count}choices_click(e){if(e.preventDefault(),this.activate_field(),!this.results_showing&&!this.is_disabled)return this.results_show()}mousedown_checker(e){var t,s,i,h;switch(t=null,(e=e||window.event).which||void 0===e.button||(e.which=null!=(s=1&e.button)?s:{1:null!=(i=2&e.button)?i:{3:null!=(h=4&e.button)?h:{2:0}}}),e.which){case 1:t="left";break;case 2:t="right";break;case 3:t="middle";break;default:t="other"}return t}keydown_checker(e){var t,s;switch(s=null!=(t=e.which)?t:e.keyCode,this.search_field_scale(),8!==s&&this.pending_backstroke&&this.clear_backstroke(),s){case 8:this.backstroke_length=this.get_search_field_value().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(e),this.mouse_on_container=!1;break;case 13:case 27:this.results_showing&&e.preventDefault();break;case 32:this.disable_search&&e.preventDefault();break;case 38:e.preventDefault(),this.keyup_arrow();break;case 40:e.preventDefault(),this.keydown_arrow()}}keyup_checker(e){var t,s;switch(s=null!=(t=e.which)?t:e.keyCode,this.search_field_scale(),s){case 8:this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0?this.keydown_backstroke():this.pending_backstroke||(this.result_clear_highlight(),this.results_search());break;case 13:e.preventDefault(),this.results_showing&&this.result_select(e);break;case 27:this.results_showing&&this.results_hide();break;case 9:case 16:case 17:case 18:case 38:case 40:case 91:break;default:this.results_search()}}clipboard_event_checker(e){if(!this.is_disabled)return setTimeout(()=>this.results_search(),50)}container_width(){return null!=this.options.width?this.options.width:this.form_field.offsetWidth>0?`${this.form_field.offsetWidth}px`:"auto"}include_option_in_results(e){return!(this.is_multiple&&!this.display_selected_options&&e.selected)&&(!(!this.display_disabled_options&&e.disabled)&&(!e.empty&&(!e.hidden&&(null==e.group_array_index||!this.results_data[e.group_array_index].hidden))))}search_results_touchstart(e){return this.touch_started=!0,this.search_results_mouseover(e)}search_results_touchmove(e){return this.touch_started=!1,this.search_results_mouseout(e)}search_results_touchend(e){if(this.touch_started)return this.search_results_mouseup(e)}outerHTML(e){var t;return e.outerHTML?e.outerHTML:((t=document.createElement("div")).appendChild(e),t.innerHTML)}get_single_html(){return`<a class="chosen-single chosen-default">\n <span>${this.default_text}</span>\n <div><b></b></div>\n</a>\n<div class="chosen-drop">\n <div class="chosen-search">\n <input class="chosen-search-input" type="text" autocomplete="off" role="combobox" aria-expanded="false" aria-haspopup="true" aria-autocomplete="list" autocomplete="off" />\n </div>\n <ul class="chosen-results" role="listbox"></ul>\n</div>`}get_multi_html(){return`<ul class="chosen-choices">\n <li class="search-field">\n <input class="chosen-search-input" type="text" autocomplete="off" role="combobox" placeholder="${this.default_text}" aria-expanded="false" aria-haspopup="true" aria-autocomplete="list" />\n </li>\n</ul>\n<div class="chosen-drop">\n <ul class="chosen-results" role="listbox"></ul>\n</div>`}get_no_results_html(e){return`<li class="no-results">\n ${this.results_none_found} <span>${this.escape_html(e)}</span>\n</li>`}get_option_html({value:e,text:t}){return`<option value="${e}" selected>${t}</option>`}get_create_option_html(e){return`<li class="create-option active-result" role="option"><a>${this.create_option_text}</a>: "${this.escape_html(e)}"</li>`}static browser_is_supported(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:!(/iP(od|hone)/i.test(window.navigator.userAgent)||/IEMobile/i.test(window.navigator.userAgent)||/Windows Phone/i.test(window.navigator.userAgent)||/BlackBerry/i.test(window.navigator.userAgent)||/BB10/i.test(window.navigator.userAgent)||/Android.*Mobile/i.test(window.navigator.userAgent))}}return e.default_multiple_text="Select Some Options",e.default_single_text="Select an Option",e.default_no_result_text="No results match",e.default_create_option_text="Add Option",e}.call(this),(e=jQuery).fn.extend({chosen:function(i){return t.browser_is_supported()?this.each(function(t){var h,l;l=(h=e(this)).data("chosen"),"destroy"!==i?l instanceof s||h.data("chosen",new s(this,i)):l instanceof s&&l.destroy()}):this}}),s=class extends t{setup(){return this.form_field_jq=e(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex}set_up_html(){var t,s;return(t=["chosen-container"]).push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&t.push(this.form_field.className),this.is_rtl&&t.push("chosen-rtl"),s={class:t.join(" "),title:this.form_field.title},this.form_field.id.length&&(s.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=e("<div />",s),this.container.width(this.container_width()),this.is_multiple?this.container.html(this.get_multi_html()):this.container.html(this.get_single_html()),this.form_field_jq.css("position","absolute").css("opacity",0).css("display","none").after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_results.attr("id",`${this.form_field.id}-chosen-search-results`),this.search_groups=this.container.find("li.group-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.set_aria_labels(),this.results_build(),this.set_tab_index(),this.set_label_behavior()}on_ready(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})}register_observers(){return this.container.on("touchstart.chosen",e=>{this.container_mousedown(e)}),this.container.on("touchend.chosen",e=>{this.container_mouseup(e)}),this.container.on("mousedown.chosen",e=>{this.container_mousedown(e)}),this.container.on("mouseup.chosen",e=>{this.container_mouseup(e)}),this.container.on("mouseenter.chosen",e=>{this.mouse_enter(e)}),this.container.on("mouseleave.chosen",e=>{this.mouse_leave(e)}),this.search_groups.bind("mouseup.chosen",e=>{this.search_results_mouseup(e)}),this.search_groups.bind("mouseover.chosen",e=>{this.search_results_mouseover(e)}),this.search_groups.bind("mouseout.chosen",e=>{this.search_results_mouseout(e)}),this.search_groups.bind("mousewheel.chosen DOMMouseScroll.chosen",e=>{this.search_results_mousewheel(e)}),this.search_results.on("mouseup.chosen",e=>{this.search_results_mouseup(e)}),this.search_results.on("mouseover.chosen",e=>{this.search_results_mouseover(e)}),this.search_results.on("mouseout.chosen",e=>{this.search_results_mouseout(e)}),this.search_results.on("mousewheel.chosen DOMMouseScroll.chosen",e=>{this.search_results_mousewheel(e)}),this.search_results.on("touchstart.chosen",e=>{this.search_results_touchstart(e)}),this.search_results.on("touchmove.chosen",e=>{this.search_results_touchmove(e)}),this.search_results.on("touchend.chosen",e=>{this.search_results_touchend(e)}),this.form_field_jq.on("chosen:updated.chosen",e=>{this.results_update_field(e)}),this.form_field_jq.on("chosen:activate.chosen",e=>{this.activate_field(e)}),this.form_field_jq.on("chosen:open.chosen",e=>{this.container_mousedown(e)}),this.form_field_jq.on("chosen:close.chosen",e=>{this.close_field(e)}),this.search_field.on("blur.chosen",e=>{this.input_blur(e)}),this.search_field.on("keyup.chosen",e=>{this.keyup_checker(e)}),this.search_field.on("keydown.chosen",e=>{this.keydown_checker(e)}),this.search_field.on("focus.chosen",e=>{this.input_focus(e)}),this.search_field.on("cut.chosen",e=>{this.clipboard_event_checker(e)}),this.search_field.on("paste.chosen",e=>{this.clipboard_event_checker(e)}),this.is_multiple?this.search_choices.on("click.chosen",e=>{this.choices_click(e)}):this.container.on("click.chosen",function(e){e.preventDefault()})}destroy(){return e(null!=this.container[0].getRootNode?this.container[0].getRootNode():this.container[0].ownerDocument).off("click.chosen",this.click_test_action),this.form_field_label.length>0&&this.form_field_label.off("click.chosen"),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()}set_aria_labels(){var e,t,s,i,h,l;if(this.search_field.attr("aria-owns",this.search_results.attr("id")),this.form_field.attributes["aria-label"]){if(this.search_field.attr("aria-label",this.form_field.attributes["aria-label"]),this.form_field.attributes["aria-labelledby"])return this.search_field.attr("aria-labelledby",this.form_field.attributes["aria-labelledby"])}else if(Object.prototype.hasOwnProperty.call(this.form_field,"labels")&&this.form_field.labels.length){for(i="",e=t=0,h=(l=this.form_field.labels).length;t<h;e=++t)""===(s=l[e]).id&&(s.id=`${this.form_field.id}-chosen-label-${e}`),i+=this.form_field.labels[e].id+" ";return this.search_field.attr("aria-labelledby",i)}}search_field_disabled(){return this.is_disabled=this.form_field.disabled||this.form_field_jq.parents("fieldset").is(":disabled"),this.container.toggleClass("chosen-disabled",this.is_disabled),this.search_field[0].disabled=this.is_disabled,this.is_multiple||this.selected_item.off("focus.chosen",this.activate_field),this.is_disabled?this.close_field():this.is_multiple?void 0:this.selected_item.on("focus.chosen",this.activate_field)}container_mousedown(t){var s;if(!this.is_disabled&&t&&"left"===this.mousedown_checker(t)&&t&&"mousedown"===t.type&&!this.results_showing&&t.preventDefault(),!t||"mousedown"!==(s=t.type)&&"touchstart"!==s||this.results_showing||t.preventDefault(),null==t||!e(t.target).hasClass("search-choice-close"))return this.active_field?this.is_multiple||!t||e(t.target)[0]!==this.selected_item[0]&&!e(t.target).parents("a.chosen-single").length||(t.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),e(null!=this.container[0].getRootNode?this.container[0].getRootNode():this.container[0].ownerDocument).on("click.chosen",this.click_test_action),this.results_show()),this.activate_field()}container_mouseup(t){if(!this.is_disabled&&this.allow_single_deselect&&e(t.target).hasClass("search-choice-close"))return this.results_reset(t)}search_results_mousewheel(e){var t;if(e.originalEvent&&(t=e.originalEvent.deltaY||-e.originalEvent.wheelDelta||e.originalEvent.detail),null!=t)return e.preventDefault(),"DOMMouseScroll"===e.type&&(t*=40),this.search_results.scrollTop(t+this.search_results.scrollTop())}blur_test(e){if(!this.active_field&&this.container.hasClass("chosen-container-active"))return this.close_field()}close_field(){return e(null!=this.container[0].getRootNode?this.container[0].getRootNode():this.container[0].ownerDocument).off("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.search_field.attr("aria-expanded",!1),this.container.removeClass("chosen-container-active"),this.container.removeClass("chosen-dropup"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale(),this.search_field.trigger("blur")}should_dropup(){var t,s;return s=e(window).height(),t=this.container.offset().top+this.container.height()-e(window).scrollTop(),this.dropdown.height()+t>s}activate_field(){if(!this.is_disabled)return this.container.addClass("chosen-container-active"),this.should_dropup()&&this.container.addClass("chosen-dropup"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.attr("aria-expanded",!0),this.search_results.attr("aria-busy",!1),this.search_field.trigger("focus")}test_active_click(t){var s;return s=e(t.target).closest(".chosen-container"),"left"===this.mousedown_checker(t)&&s.length&&this.container[0]===s[0]?this.active_field=!0:this.close_field()}results_build(){return this.parsing=!0,this.selected_option_count=null,this.results_data=i.select_to_array(this.form_field,this.parser_config),this.is_multiple?this.search_choices.find("li.search-choice").remove():(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold&&!this.create_option?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1}result_do_highlight(e){var t,s,i,h,l;if(e.length){if(this.result_clear_highlight(),this.result_highlight=e,this.result_highlight.addClass("highlighted"),this.search_field.attr("aria-activedescendant",this.result_highlight.attr("id")),h=(i=parseInt(this.search_results.css("maxHeight"),10))+(l=this.search_results.scrollTop()),(t=(s=this.result_highlight.position().top+this.search_results.scrollTop())+this.result_highlight.outerHeight())>=h)return this.search_results.scrollTop(t-i>0?t-i:0);if(s<l)return this.search_results.scrollTop(s)}}result_clear_highlight(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null}results_show(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.should_dropup()&&this.container.addClass("chosen-dropup"),this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.trigger("focus"),this.search_field.val(this.get_search_field_value()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))}update_results_content(e){return this.search_results.html(e)}fire_search_updated(e){return this.form_field_jq.trigger("chosen:search_updated",{chosen:this,search_term:e})}results_hide(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.container.removeClass("chosen-dropup"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1}set_tab_index(e){var t;if(this.form_field.tabIndex)return t=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=t}set_label_behavior(){if(this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=e(`label[for='${this.form_field.id}']`)),this.form_field_label.length>0)return this.form_field_label.on("click.chosen",this.label_click_handler)}set_search_field_placeholder(){return this.is_multiple&&this.choices_count()<1?this.search_field.attr("placeholder",this.default_text):this.search_field.attr("placeholder","")}show_search_field_default(){return this.search_field.val(""),this.set_search_field_placeholder(),this.is_multiple&&this.choices_count()<1&&!this.active_field?this.search_field.addClass("default"):this.search_field.removeClass("default")}search_results_mouseup(t){var s;if("left"===this.mousedown_checker(t)&&(s=e(t.target).is(".active-result,.group-result")?e(t.target):e(t.target).parents(".active-result").first()).length)return this.result_highlight=s,this.result_select(t),this.search_field.focus()}search_results_mouseover(t){var s;if(s=e(t.target).hasClass("active-result")?e(t.target):e(t.target).parents(".active-result").first())return this.result_do_highlight(s)}search_results_mouseout(t){if(e(t.target).hasClass("active-result")||e(t.target).parents(".active-result").first())return this.result_clear_highlight()}choice_build(t){var s,i;return s=e("<li />",{class:"search-choice","data-value":t.value,role:"option"}).html(`<span>${this.choice_label(t)}</span>`),t.disabled?s.addClass("search-choice-disabled"):((i=e("<button />",{type:"button",tabindex:-1,class:"search-choice-close","data-option-array-index":t.data["data-option-array-index"]})).on("click.chosen",e=>this.choice_destroy_link_click(e)),s.append(i)),this.inherit_option_classes&&t.classes&&s[0].classList.add(t.classes),this.search_container.before(s)}choice_destroy_link_click(t){if(t.preventDefault(),t.stopPropagation(),!this.is_disabled)return this.choice_destroy(e(t.target))}choice_destroy(e){if(this.result_deselect(e[0].getAttribute("data-option-array-index")))return this.active_field?this.search_field.trigger("focus"):this.show_search_field_default(),this.is_multiple&&this.hide_results_on_select&&this.choices_count()>0&&this.get_search_field_value().length<1&&this.results_hide(),e.parents("li").first().remove(),this.set_search_field_placeholder(),this.search_field_scale()}results_reset(){if(this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.trigger_form_field_change(),this.active_field)return this.results_hide()}results_reset_cleanup(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find(".search-choice-close").remove()}result_select(t){var s,i;if(e(t.target).hasClass("group-result")){if(!this.can_select_by_group)return;e(t.target).nextAll().each((s,i)=>{var h,l;return!e(i).hasClass("group-result")&&(h=e(i).attr("data-option-array-index"),l=!1,e("#pops_chosen > .chosen-choices").find(".search-choice-close").each((t,s)=>{if(e(s).attr("data-option-array-index")===h)return l=!0,!1}),l?void 0:(this.result_highlight=e(i),t.target=i,t.selected=!0,this.result_select(t)))})}else if(this.result_highlight)return(s=this.result_highlight).hasClass("create-option")?(this.select_create_option(this.search_field.val()),this.results_hide()):(this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?s.removeClass("active-result"):this.reset_single_select_options(),s.addClass("result-selected"),(i=this.results_data[s[0].getAttribute("data-option-array-index")]).selected=!0,this.form_field.options[i.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(i):this.single_set_selected_text(this.choice_label(i)),this.is_multiple&&(!this.hide_results_on_select||t.metaKey||t.ctrlKey)?t.metaKey||t.ctrlKey?this.winnow_results({skip_highlight:!0}):(this.search_field.val(""),this.winnow_results()):(this.results_hide(),this.show_search_field_default()),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.trigger_form_field_change({selected:this.form_field.options[i.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,t.preventDefault(),this.search_field_scale()))}single_set_selected_text(e=this.default_text){return e===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").html(e)}result_deselect(e){var t;return t=this.results_data[e],!this.form_field.options[t.options_index].disabled&&(t.selected=!1,this.form_field.options[t.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.trigger_form_field_change({deselected:this.form_field.options[t.options_index].value}),this.search_field_scale(),!0)}single_deselect_control_build(){if(this.allow_single_deselect)return this.selected_item.find(".search-choice-close").length||this.selected_item.find("span").first().after('<button type="button" tabindex="-1" class="search-choice-close"></button>'),this.selected_item.addClass("chosen-single-with-deselect")}get_search_field_value(){return this.search_field.val()}get_search_text(){return e.trim(this.get_search_field_value())}escape_html(t){return e("<div/>").text(t).html()}winnow_results_set_highlight(){var e,t;if(null!=(e=(t=this.is_multiple?[]:this.search_results.find(".result-selected.active-result")).length?t.first():this.search_results.find(".active-result").first()))return this.result_do_highlight(e)}no_results(e){var t;return t=this.get_no_results_html(e),this.search_results.append(t),this.form_field_jq.trigger("chosen:no_results",{chosen:this})}show_create_option(e){var t;return t=this.get_create_option_html(e),this.search_results.append(t)}create_option_clear(){return this.search_results.find(".create-option").remove()}select_create_option(t){return e.isFunction(this.create_option)?this.create_option.call(this,t):this.select_append_option({value:t,text:t})}select_append_option(e){var t;return t=this.get_option_html(e),this.form_field_jq.append(t),this.form_field_jq.trigger("chosen:updated"),this.form_field_jq.trigger("change"),this.search_field.trigger("focus")}no_results_clear(){return this.search_results.find(".no-results").remove()}keydown_arrow(){var e;return this.results_showing&&this.result_highlight?(e=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(e):void 0:this.results_showing&&this.create_option?this.result_do_highlight(this.search_results.find(".create-option")):this.results_show()}keyup_arrow(){var e;return this.results_showing||this.is_multiple?this.result_highlight?(e=this.result_highlight.prevAll("li.active-result")).length?this.result_do_highlight(e.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight()):void 0:this.results_show()}keydown_backstroke(){var e;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find(".search-choice-close").first()),this.clear_backstroke()):(e=this.search_container.siblings("li.search-choice").last()).length&&!e.hasClass("search-choice-disabled")?(this.pending_backstroke=e,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0}clear_backstroke(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null}search_field_scale(){var t,s,i,h,l,r,a;if(this.is_multiple){for(l={position:"absolute",left:"-1000px",top:"-1000px",display:"none",whiteSpace:"pre"},s=0,i=(r=["fontSize","fontStyle","fontWeight","fontFamily","lineHeight","textTransform","letterSpacing"]).length;s<i;s++)l[h=r[s]]=this.search_field.css(h);return(t=e("<div />").css(l)).text(this.get_search_field_value()||this.search_field.attr("placeholder")),e("body").append(t),a=t.width()+25,t.remove(),this.container.is(":visible")&&(a=Math.min(this.container.outerWidth()-10,a)),this.search_field.width(a)}}trigger_form_field_change(e){return this.form_field_jq.trigger("input",e),this.form_field_jq.trigger("change",e)}}}).call(this);