!function(w,C,A,P){"use strict";w.isFunction=w.isFunction||function(e){return"function"==typeofe&&"number"!=typeofe.nodeType},C=void0!==C&&C.Math==Math?C:"undefined"!=typeofself&&self.Math==Math?self:Function("return this")(),w.fn.state=function(v){varg,b=w(this),x=b.selector||"",p=(newDate).getTime(),h=[],m=v,T="string"==typeofm,y=[].slice.call(arguments,1);returnb.each(function(){vari=w.isPlainObject(v)?w.extend(!0,{},w.fn.state.settings,v):w.extend({},w.fn.state.settings),c=i.error,n=i.metadata,t=i.className,e=i.namespace,a=i.states,o=i.text,s="."+e,r=e+"-module",l=w(this),u=this,d=l.data(r),f={initialize:function(){f.verbose("Initializing module"),i.automatic&&f.add.defaults(),i.context&&""!==x?([C,A].indexOf(i.context)<0?w(A).find(i.context):w(i.context)).on(x,"mouseenter"+s,f.change.text).on(x,"mouseleave"+s,f.reset.text).on(x,"click"+s,f.toggle.state):l.on("mouseenter"+s,f.change.text).on("mouseleave"+s,f.reset.text).on("click"+s,f.toggle.state),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),d=f,l.data(r,f)},destroy:function(){f.verbose("Destroying previous module",d),l.off(s).removeData(r)},refresh:function(){f.verbose("Refreshing selector cache"),l=w(u)},add:{defaults:function(){varn=v&&w.isPlainObject(v.states)?v.states:{};w.each(i.defaults,function(e,t){f.is[e]!==P&&f.is[e]()&&(f.verbose("Adding default states",e,u),w.extend(i.states,t,n))})}},is:{active:function(){returnl.hasClass(t.active)},loading:function(){returnl.hasClass(t.loading)},inactive:function(){return!l.hasClass(t.active)},state:function(e){returnt[e]!==P&&l.hasClass(t[e])},enabled:function(){return!l.is(i.filter.active)},disabled:function(){returnl.is(i.filter.active)},textEnabled:function(){return!l.is(i.filter.text)},button:function(){returnl.is(".button:not(a, .submit)")},input:function(){returnl.is("input")},progress:function(){returnl.is(".ui.progress")}},allow:function(e){f.debug("Now allowing state",e),a[e]=!0},disallow:function(e){f.debug("No longer allowing",e),a[e]=!1},allows:function(e){returna[e]||!1},enable:function(){l.removeClass(t.disabled)},disable:function(){l.addClass(t.disabled)},setState:function(e){f.allows(e)&&l.addClass(t[e])},removeState:function(e){f.allows(e)&&l.removeClass(t[e])},toggle:{state:function(){vare;if(f.allows("active")&&f.is.enabled()){if(f.refresh(),w.fn.api!==P)if(e=l.api("get request"),l.api("was cancelled"))f.debug("API Request cancelled by beforesend"),i.activateTest=function(){return!1},i.deactivateTest=function(){return!1};elseif(e)returnvoidf.listenTo(e);f.change.state()}}},listenTo:function(e){f.debug("API request detected, waiting for state signal",e),e&&(o.loading&&f.update.text(o.loading),w.when(e).then(function(){"resolved"==e.state()?(f.debug("API request succeeded"),i.activateTest=function(){return!0},i.deactivateTest=function(){return!0}):(f.debug("API request failed"),i.activateTest=function(){return!1},i.deactivateTest=function(){return!1}),f.change.state()}))},change:{state:function(){f.debug("Determining state change direction"),f.is.inactive()?f.activate():f.deactivate(),i.sync&&f.sync(),i.onChange.call(u)},text:function(){f.is.textEnabled()&&(f.is.disabled()?(f.verbose("Changing text to disabled text",o.hover),f.update.text(o.disabled)):f.is.active()?o.hover?(f.verbose("Changing text to hover text",o.hover),f.update.text(o.hover)):o.deactivate&&(f.verbose("Changing text to deactivating text",o.deactivate),f.update.text(o.deactivate)):o.hover?(f.verbose("Changing text to hover text",o.hover),f.update.text(o.hover)):o.activate&&(f.verbose("Changing text to activating text",o.activate),f.update.text(o.activate)))}},activate:function(){i.activateTest.call(u)&&(f.debug("Setting state to active"),l.addClass(t.active),f.update.text(o.active),i.onActivate.call(u))},deactivate:function(){i.deactivateTest.call(u)&&(f.debug("Setting state to inactive"),l.removeClass(t.active),f.update.text(o.inactive),i.onDeactivate.call(u))},sync:function(){f.verbose("Syncing other buttons to current state"),f.is.active()?b.not(l).state("activate"):b.no