!function(o,a){o.fn.yith_wccl=function(){var t=this,e=(t.data("last_change"),t.find(".variations select"));return this.clean=function(){return t.find(".select_box").remove(),this},this.generateOutput=function(){return e.each(function(){var i=o(this),c=o(this).data("type"),s=o("<div />",{class:"select_box_"+c+" select_box "+i.attr("name")}).insertAfter(i);i.removeData("last_content"),i.find("option").each(function(){if(o(this).data("value")){var t="select_option_"+c+" select_option",e=o(this).data("value"),n=o(this),a=o("<div/>",{class:t}).data("value",o(this).attr("value")).data("option",n.clone(!0)).appendTo(s).off("click").on("click",function(t){o(this).hasClass("selected")?i.val("").change():(t.preventDefault(),i.val(n.val()).change())});"colorpicker"==c?a.append(o("<span/>",{css:{background:e}})):"image"==c?a.append(o("<img/>",{src:e})):"label"==c&&a.append(o("<span/>",{text:e}))}})}).filter(function(){return"select"!=o(this).data("type")}).hide(),t},this.onSelect=function(){return e.each(function(){var t=o(this).val(),e=o(this).next(".select_box");e.length||(e=o(this).siblings(".select_box")),e=e.find(".select_option").removeClass("selected"),t&&e.filter(function(){return o(this).data("value")==t}).addClass("selected")}),t},this.updateOptions=function(){return"undefined"!=typeof yith_wccl_arg&&t.find(".variations select").each(function(t,e){var n=o(this),a=n.val(),i=n.data("active_options")?n.data("active_options"):n.data("attribute_options");if(!i)return!1;""!=a?o.each(i,function(t,e){n.append(e)}):n.data("active_options",n.find("option").get())}),t},this.updateOptions().clean().generateOutput().onSelect()},jQuery(function(t){var e=t(".variations_form"),n=e.find(".variations select");t(a).on("yith_wccl_change check_variations",e,function(){t(this).yith_wccl()}).trigger("yith_wccl_change"),t(a).on("change",n,function(){e.data("last_change",t(this).attr("name")),t(this).data("last_content",t(this).siblings(".select_box").clone(!0))}),t(a).on("click",".reset_variations",function(){n.removeData("last_content"),e.removeData("last_change")}),n.trigger("focusin")})}(jQuery,(window,document));