jQuery(function(c){c(document.body).on("wcv-select-init",function(){c(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var e,t,n={allowClear:!!c(this).data("allow_clear"),placeholder:c(this).data("placeholder"),minimumInputLength:1,escapeMarkup:function(t){return t},ajax:{url:wcv_product_select_params.ajax_url,dataType:"json",delay:250,data:function(t){return{term:t.term,action:c(this).data("action")||"wcv_json_search_products",security:wcv_product_select_params.nonce}},processResults:function(t){var n=[];return t&&c.each(t,function(t,e){n.push({id:t,text:e})}),{results:n}},cache:!0}},n=c.extend(n,{formatMatches:function(t){return 1===t?wcv_product_select_params.i18n_matches_1:wcv_product_select_params.i18n_matches_n.replace("%qty%",t)},formatNoMatches:function(){return wcv_product_select_params.i18n_no_matches},formatAjaxError:function(t,e,n){return wcv_product_select_params.i18n_ajax_error},formatInputTooShort:function(t,e){e-=t.length;return 1==e?wcv_product_select_params.i18n_input_too_short_1:wcv_product_select_params.i18n_input_too_short_n.replace("%qty%",e)},formatInputTooLong:function(t,e){t=t.length-e;return 1==t?wcv_product_select_params.i18n_input_too_long_1:wcv_product_select_params.i18n_input_too_long_n.replace("%qty%",t)},formatSelectionTooBig:function(t){return 1===t?wcv_product_select_params.i18n_selection_too_long_1:wcv_product_select_params.i18n_selection_too_long_n.replace("%qty%",t)},formatLoadMore:function(t){return wcv_product_select_params.i18n_load_more},formatSearching:function(){return wcv_product_select_params.i18n_searching}});c(this).select2(n).addClass("enhanced"),c(this).data("sortable")?(e=c(this),(t=c(this).next(".select2-container").find("ul.select2-selection__rendered")).sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){c(t.find(".select2-selection__choice").get().reverse()).each(function(){var t=c(this).data("data").id,t=e.find('option[value="'+t+'"]')[0];e.prepend(t)})}})):c(this).prop("multiple")&&c(this).on("change",function(){var t=c(this).children();t.sort(function(t,e){t=t.text.toLowerCase(),e=e.text.toLowerCase();return e<t?1:t<e?-1:0}),c(this).html(t)})})}),c(document).ready(function(){c(document.body).trigger("wcv-select-init")})});