this.select2=function(){var l=function(a,c){var b=document.getElementById(a).orgoptions,d=$("#"+a),n=d.val(),f=[];for(i=0;i<b.length;i++)if(""==c)f.push($(b[i]).prop("outerHTML"));else if("OPTGROUP"==b[i].tagName){var e=$(b[i]).children(),g=!1,h=null;if(e){for(j=0;j<e.length;j++)0<=e[j].innerText.indexOf(c)&&(g||(g=!0,h=$("<optgroup> </optgroup>").prop("label",b[i].label)),$(e[j]).prop("disabled")||h.append($(e[j]).prop("outerHTML")));g&&f.push($(h).prop("outerHTML"))}}else 0<=b[i].innerText.indexOf(c)&&
!$(b[i]).prop("disabled")&&f.push($(b[i]).prop("outerHTML"));$("#"+a).children().remove();d.append(f.join(" ")).val(n);null==d.val()&&d.prop("selectedIndex",0)},m=function(a){setTimeout(function(){l(a,"");$(document.getElementById(a+"sel2outer")).remove()},100)},k=function(a){var c=$(a).children();a.orgoptions=c.clone();$(a).after("<span class='select2' targetId='"+a.id+"'>*</span>");$(a).on("change",function(){m(a.id)})};select2.sel2create=k;$("SELECT.sel2sel").each(function(a){k(this)});$(document).on("click",
".select2",function(a){var c=this.getAttribute("targetId"),b=c+"sel2",d=c+"sel2outer";document.getElementById(b)?m(c):($("body").append("<div id='"+d+"' style='position:absolute;background-color:silver;'> <input size='7' name='dummy' id='"+b+"' class='sel2input' targetId='"+c+"' /><span class='select2' style='cursor:default' targetId='"+c+"'>\u00d7</span></div>"),$("#"+d).css("top",a.pageY-30+"px").css("left",a.pageX+-60+"px").children("input")[0].trigger("focus"))});$(document).on("keyup",".sel2input",
function(a){13==a.keyCode?(a=this.getAttribute("targetId"),$(this).trigger("change"),$("#"+a).trigger("focus")):(a=this.getAttribute("targetId"),l(a,this.value))});(new MutationObserver(function(a){a.forEach(c=>{c.addedNodes.forEach(b=>{"SELECT"===b.tagName&&$(b).hasClass("sel2sel")&&k(b)})})})).observe(document,{childList:!0,subtree:!0})};$(document).ready(function(){select2()});
