var init=!1,StarWidget={init:function(){if(init)return void alert("StarWidget already init");init=!0,$(document).on("click","[data-star-widget] .star",function(){var t=$(this).closest("[data-star-widget]"),a=$(this).attr("data-star"),i=t.StarWidget();return i.val()==a?i.val(0):i.val(a),!1});var t=function(t){var a=$(t);this.val=function(t){if(void 0==t)return parseInt(a.find("[data-value]").val());a.find("[data-value]").val(t),a.find(".star").removeClass("active").each(function(a,i){var r=parseInt($(i).attr("data-star"));t&&t>=r&&$(i).addClass("active")}),a.trigger("star-widget.change",[t])}};$.fn.extend({StarWidget:function(){return new t(this)}}),$("[data-star-widget]").each(function(t,a){var i=$(a);i.data("widget")||$(a).StarWidget().val(parseInt(i.find("[data-value]").val()))})}};module.exports=StarWidget;