!function(e){e.fn.niceSelect=function(n){if("string"==typeof n)return"update"==n?this.each(function(){var n=e(this),a=e(this).next(".learny-nice-select"),t=a.hasClass("learny-open");a.length&&(a.remove(),l(n),t&&n.next().trigger("click"))}):"destroy"==n?(this.each(function(){var n=e(this),l=e(this).next(".learny-nice-select");l.length&&(l.remove(),n.css("display",""))}),0==e(".learny-nice-select").length&&e(document).off(".learny-nice_select")):console.log('Method "'+n+'" does not exist.'),this;function l(n){n.after(e("<div></div>").addClass("learny-nice-select").addClass(n.attr("class")||"").addClass(n.attr("disabled")?"disabled":"").attr("tabindex",n.attr("disabled")?null:"0").html('<span class="learny-current"></span><ul class="learny-list"></ul>'));var l=n.next(),a=n.find("option"),t=n.find("option:selected");l.find(".learny-current").html(t.data("display")||t.text()),a.each(function(n){var a=e(this),t=a.data("display");l.find("ul").append(e("<li></li>").attr("data-value",a.val()).attr("data-display",t||null).addClass("learny-option"+(a.is(":selected")?" selected":"")+(a.is(":disabled")?" disabled":"")).html(a.text()))})}this.hide(),this.each(function(){var n=e(this);n.next().hasClass("learny-nice-select")||l(n)}),e(document).off(".learny-nice_select"),e(document).on("click.learny-nice_select",".learny-nice-select",function(n){var l=e(this);e(".learny-nice-select").not(l).removeClass("learny-open"),l.toggleClass("learny-open"),l.hasClass("learny-open")?(l.find(".learny-option"),l.find(".learny-focus").removeClass("learny-focus"),l.find(".learny-selected").addClass("learny-focus")):l.focus()}),e(document).on("click.learny-nice_select",function(n){0===e(n.target).closest(".learny-nice-select").length&&e(".learny-nice-select").removeClass("learny-open").find(".learny-option")}),e(document).on("click.learny-nice_select",".learny-nice-select .learny-option:not(.learny-disabled)",function(n){var l=e(this),a=l.closest(".learny-nice-select");a.find(".learny-selected").removeClass("learny-selected"),l.addClass("learny-selected");var t=l.data("display")||l.text();a.find(".learny-current").text(t),a.prev("select").val(l.data("value")).trigger("change")}),e(document).on("keydown.learny-nice_select",".learny-nice-select",function(n){var l=e(this),a=e(l.find(".learny-focus")||l.find(".learny-list .learny-option.learny-selected"));if(32==n.keyCode||13==n.keyCode)return l.hasClass("learny-open")?a.trigger("click"):l.trigger("click"),!1;if(40==n.keyCode){if(l.hasClass("learny-open")){var t=a.nextAll(".learny-option:not(.learny-disabled)").first();t.length>0&&(l.find(".learny-focus").removeClass("learny-focus"),t.addClass("learny-focus"))}else l.trigger("learny-click");return!1}if(38==n.keyCode){if(l.hasClass("learny-open")){var s=a.prevAll(".learny-option:not(.learny-disabled)").first();s.length>0&&(l.find(".learny-focus").removeClass("learny-focus"),s.addClass("learny-focus"))}else l.trigger("click");return!1}if(27==n.keyCode)l.hasClass("learny-open")&&l.trigger("click");else if(9==n.keyCode&&l.hasClass("learny-open"))return!1});var a=document.createElement("a").style;return a.cssText="pointer-events:auto","auto"!==a.pointerEvents&&e("html").addClass("learny-no-csspointerevents"),this}}(jQuery);