!function(T,e,D,O){"use strict";e=void 0!==e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),T.fn.form=function(x){var k,E=T(this),w=E.selector||"",C=(new Date).getTime(),V=[],R=x,F=arguments[1],S="string"==typeof R,A=[].slice.call(arguments,1);return E.each(function(){var n,s,t,e,d,u,c,f,p,r,l,i,a,m,g,h,o=T(this),v=this,b=[],y=!1;(h={initialize:function(){h.get.settings(),S?(g===O&&h.instantiate(),h.invoke(R)):(g!==O&&g.invoke("destroy"),h.verbose("Initializing form validation",o,d),h.bindEvents(),h.set.defaults(),h.instantiate())},instantiate:function(){h.verbose("Storing instance of module",h),g=h,o.data(a,h)},destroy:function(){h.verbose("Destroying previous module",g),h.removeEvents(),o.removeData(a)},refresh:function(){h.verbose("Refreshing selector cache"),n=o.find(f.field),s=o.find(f.group),t=o.find(f.message),o.find(f.prompt),e=o.find(f.submit),o.find(f.clear),o.find(f.reset)},submit:function(){h.verbose("Submitting form",o),o.submit()},attachEvents:function(e,t){t=t||"submit",T(e).on("click"+m,function(e){h[t](),e.preventDefault()})},bindEvents:function(){h.verbose("Attaching form events"),o.on("submit"+m,h.validate.form).on("blur"+m,f.field,h.event.field.blur).on("click"+m,f.submit,h.submit).on("click"+m,f.reset,h.reset).on("click"+m,f.clear,h.clear),d.keyboardShortcuts&&o.on("keydown"+m,f.field,h.event.field.keydown),n.each(function(){var e=T(this),t=e.prop("type"),n=h.get.changeEvent(t,e);T(this).on(n+m,h.event.field.change)})},clear:function(){n.each(function(){var e=T(this),t=e.parent(),n=e.closest(s),r=n.find(f.prompt),i=e.data(c.defaultValue)||"",a=t.is(f.uiCheckbox),o=t.is(f.uiDropdown);n.hasClass(p.error)&&(h.verbose("Resetting error on field",n),n.removeClass(p.error),r.remove()),o?(h.verbose("Resetting dropdown value",t,i),t.dropdown("clear")):a?e.prop("checked",!1):(h.verbose("Resetting field value",e,i),e.val(""))})},reset:function(){n.each(function(){var e=T(this),t=e.parent(),n=e.closest(s),r=n.find(f.prompt),i=e.data(c.defaultValue),a=t.is(f.uiCheckbox),o=t.is(f.uiDropdown),l=n.hasClass(p.error);i!==O&&(l&&(h.verbose("Resetting error on field",n),n.removeClass(p.error),r.remove()),o?(h.verbose("Resetting dropdown value",t,i),t.dropdown("restore defaults")):a?(h.verbose("Resetting checkbox value",t,i),e.prop("checked",i)):(h.verbose("Resetting field value",e,i),e.val(i)))})},determine:{isValid:function(){var n=!0;return T.each(u,function(e,t){h.validate.field(t,e,!0)||(n=!1)}),n}},is:{bracketedRule:function(e){return e.type&&e.type.match(d.regExp.bracket)},shorthandFields:function(e){var t=e[Object.keys(e)[0]];return h.is.shorthandRules(t)},shorthandRules:function(e){return"string"==typeof e||T.isArray(e)},empty:function(e){return!e||0===e.length||(e.is('input[type="checkbox"]')?!e.is(":checked"):h.is.blank(e))},blank:function(e){return""===T.trim(e.val())},valid:function(e){var n=!0;return e?(h.verbose("Checking if field is valid",e),h.validate.field(u[e],e,!1)):(h.verbose("Checking if form is valid"),T.each(u,function(e,t){h.is.valid(e)||(n=!1)}),n)}},removeEvents:function(){o.off(m),n.off(m),e.off(m),n.off(m)},event:{field:{keydown:function(e){var t=T(this),n=e.which,r=t.is(f.input),i=t.is(f.checkbox),a=0")},fields:function(e){var n=T();return T.each(e,function(e,t){n=n.add(h.get.field(t))}),n},validation:function(n){var r,i;return!!u&&(T.each(u,function(e,t){i=t.identifier||e,h.get.field(i)[0]==n[0]&&(t.identifier=i,r=t)}),r||!1)},value:function(e){var t=[];return t.push(e),h.get.values.call(v,t)[e]},values:function(e){var t=T.isArray(e)?h.get.fields(e):n,u={};return t.each(function(e,t){var n=T(t),r=(n.prop("type"),n.prop("name")),i=n.val(),a=n.is(f.checkbox),o=n.is(f.radio),l=-1!==r.indexOf("[]"),s=!!a&&n.is(":checked");r&&(l?(r=r.replace("[]",""),u[r]||(u[r]=[]),a?s?u[r].push(i||!0):u[r].push(!1):u[r].push(i)):o?u[r]!==O&&0!=u[r]||(u[r]=!!s&&(i||!0)):u[r]=a?!!s&&(i||!0):i)}),u}},has:{field:function(e){return h.verbose("Checking for existence of a field with identifier",e),"string"!=typeof(e=h.escape.string(e))&&h.error(l.identifier,e),0"+t+""}),T(n+="")},prompt:function(e){return T("").addClass("ui basic red pointing prompt label").html(e[0])}},rules:{empty:function(e){return!(e===O||""===e||T.isArray(e)&&0===e.length)},checked:function(){return 0=t},length:function(e,t){return e!==O&&e.length>=t},exactLength:function(e,t){return e!==O&&e.length==t},maxLength:function(e,t){return e!==O&&e.length<=t},match:function(e,t){var n;T(this);return 0=t)},exactCount:function(e,t){return 0==t?""===e:1==t?""!==e&&-1===e.search(","):e.split(",").length==t},maxCount:function(e,t){return 0!=t&&(1==t?-1===e.search(","):e.split(",").length<=t)}}}}(jQuery,window,document);