!function(a,b,c,d){a.fn.modal=function(e){var f,g=a(this),h=a(b),i=a(c),j=a("body"),k=(new Date).getTime(),l=[],m=arguments[0],n="string"==typeof m,o=[].slice.call(arguments,1),p=b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame||function(a){setTimeout(a,0)};return g.each(function(){var q,r,s,t,u,v,w=a.isPlainObject(e)?a.extend(!0,{},a.fn.modal.settings,e):a.extend({},a.fn.modal.settings),x=w.selector,y=w.className,z=w.namespace,A=w.error,B="."+z,C="module-"+z,D=g.selector||"",E=a(this),F=a(w.context),G=E.find(x.close),H=this,I=E.data(C);v={initialize:function(){return v.verbose("Initializing dimmer",F),a.fn.dimmer===d?void v.error(A.dimmer):(t=F.dimmer({closable:!1,useCSS:!0,duration:{show:.9*w.duration,hide:1.1*w.duration}}),w.detachable&&t.dimmer("add content",E),u=t.dimmer("get dimmer"),v.refreshSelectors(),v.verbose("Attaching close events",G),G.on("click"+B,v.event.close),h.on("resize"+B,v.event.resize),void v.instantiate())},instantiate:function(){v.verbose("Storing instance of modal"),I=v,E.data(C,I)},destroy:function(){v.verbose("Destroying previous modal"),E.removeData(C).off(B),G.off(B),F.dimmer("destroy")},refresh:function(){v.remove.scrolling(),v.cacheSizes(),v.set.screenHeight(),v.set.type(),v.set.position()},refreshSelectors:function(){r=E.siblings(x.modal),q=r.add(E)},attachEvents:function(b,c){var d=a(b);c=a.isFunction(v[c])?v[c]:v.toggle,d.size()>0?(v.debug("Attaching modal events to element",b,c),d.off(B).on("click"+B,c)):v.error(A.notFound)},event:{close:function(){v.verbose("Closing element pressed"),a(this).is(x.approve)?a.proxy(w.onApprove,H)()!==!1?v.hide():v.verbose("Approve callback returned false cancelling hide"):a(this).is(x.deny)?a.proxy(w.onDeny,H)()!==!1?v.hide():v.verbose("Deny callback returned false cancelling hide"):v.hide()},click:function(b){0===a(b.target).closest(x.modal).size()&&(v.debug("Dimmer clicked, hiding all modals"),w.allowMultiple?v.hide():v.hideAll(),b.stopImmediatePropagation())},debounce:function(a,b){clearTimeout(v.timer),v.timer=setTimeout(a,b)},keyboard:function(a){var b=a.which,c=27;b==c&&(w.closable?(v.debug("Escape key pressed hiding modal"),v.hide()):v.debug("Escape key pressed, but closable is set to false"),a.preventDefault())},resize:function(){t.dimmer("is active")&&p(v.refresh)}},toggle:function(){v.is.active()?v.hide():v.show()},show:function(b){b=a.isFunction(b)?b:function(){},v.showDimmer(),v.showModal(b)},onlyVisible:function(){return v.refreshSelectors(),v.is.active()&&0===r.filter(":visible").size()},othersVisible:function(){return v.refreshSelectors(),r.filter(":visible").size()>0},showModal:function(b){if(v.is.active())return void v.debug("Modal is already visible");if(b=a.isFunction(b)?b:function(){},v.save.focus(),v.add.keyboardShortcuts(),v.cache===d&&v.cacheSizes(),v.set.position(),v.set.screenHeight(),v.set.type(),v.othersVisible()&&!w.allowMultiple)v.debug("Other modals visible, queueing show animation"),v.hideOthers(v.showModal);else{a.proxy(w.onShow,H)();var c=function(){v.set.active(),a.proxy(w.onVisible,H)(),b()};w.transition&&a.fn.transition!==d&&E.transition("is supported")?(v.debug("Showing modal with css animations"),E.transition(w.transition+" in",w.duration,c)):(v.debug("Showing modal with javascript"),E.fadeIn(w.duration,w.easing,c))}},showDimmer:function(){t.dimmer("is active")?v.debug("Dimmer is already visible"):(v.debug("Showing dimmer"),t.dimmer("show"))},hide:function(b){b=a.isFunction(b)?b:function(){},v.refreshSelectors(),v.onlyVisible()&&v.hideDimmer(),v.hideModal(b)},hideDimmer:function(){return v.is.active()?(v.debug("Hiding dimmer"),w.closable&&u.off("click"+B),void t.dimmer("hide",function(){w.transition&&a.fn.transition!==d&&E.transition("is supported")&&(E.transition("reset"),v.remove.screenHeight()),v.remove.active()})):void v.debug("Dimmer is already hidden")},hideModal:function(b){if(!v.is.active())return void v.debug("Modal is already hidden");b=a.isFunction(b)?b:function(){},v.restore.focus(),v.remove.keyboardShortcuts(),a.proxy(w.onHide,H)();var c=function(){v.remove.active(),a.proxy(w.onHidden,H)(),b()};w.transition&&a.fn.transition!==d&&E.transition("is supported")?(v.debug("Hiding modal with css animations"),E.transition(w.transition+" out",w.duration,c)):(v.debug("Hiding modal with javascript"),E.fadeOut(w.duration,w.easing,c))},hideAll:function(b){b=a.isFunction(b)?b:function(){},(E.is(":visible")||v.othersVisible())&&(v.debug("Hiding all visible modals"),v.hideDimmer(),q.filter(":visible").modal("hide modal",b))},hideOthers:function(b){b=a.isFunction(b)?b:function(){},v.othersVisible()&&(v.debug("Hiding other modals"),r.filter(":visible").modal("hide modal",b))},add:{keyboardShortcuts:function(){v.verbose("Adding keyboard shortcuts"),i.on("keyup"+B,v.event.keyboard)}},save:{focus:function(){s=a(c.activeElement).blur()}},restore:{focus:function(){s&&s.size()>0&&s.focus()}},remove:{active:function(){E.removeClass(y.active)},screenHeight:function(){v.cache.height>v.cache.pageHeight&&(v.debug("Removing page height"),j.css("height",""))},keyboardShortcuts:function(){v.verbose("Removing keyboard shortcuts"),i.off("keyup"+B)},scrolling:function(){t.removeClass(y.scrolling),E.removeClass(y.scrolling)}},cacheSizes:function(){v.cache={pageHeight:j.outerHeight(),height:E.outerHeight()+w.offset,contextHeight:"body"==w.context?a(b).height():t.height()},v.debug("Caching modal and container sizes",v.cache)},can:{fit:function(){return v.cache.heightv.cache.pageHeight&&(v.debug("Modal is taller than page content, resizing page height"),j.css("height",v.cache.height+w.padding))},active:function(){if(E.addClass(y.active),w.closable&&u.off("click"+B).on("click"+B,v.event.click),w.autofocus){var a=E.find(":input:visible"),b=a.filter("[autofocus]"),c=b.length?b:a;c.first().focus()}},scrolling:function(){t.addClass(y.scrolling),E.addClass(y.scrolling)},type:function(){v.can.fit()?(v.verbose("Modal fits on screen"),v.remove.scrolling()):(v.verbose("Modal cannot fit on screen setting to scrolling"),v.set.scrolling())},position:function(){v.verbose("Centering modal on page",v.cache),E.css(v.can.fit()?{top:"",marginTop:-(v.cache.height/2)}:{marginTop:"1em",top:i.scrollTop()})}},setting:function(b,c){if(v.debug("Changing setting",b,c),a.isPlainObject(b))a.extend(!0,w,b);else{if(c===d)return w[b];w[b]=c}},internal:function(b,c){if(a.isPlainObject(b))a.extend(!0,v,b);else{if(c===d)return v[b];v[b]=c}},debug:function(){w.debug&&(w.performance?v.performance.log(arguments):(v.debug=Function.prototype.bind.call(console.info,console,w.name+":"),v.debug.apply(console,arguments)))},verbose:function(){w.verbose&&w.debug&&(w.performance?v.performance.log(arguments):(v.verbose=Function.prototype.bind.call(console.info,console,w.name+":"),v.verbose.apply(console,arguments)))},error:function(){v.error=Function.prototype.bind.call(console.error,console,w.name+":"),v.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;w.performance&&(b=(new Date).getTime(),d=k||b,c=b-d,k=b,l.push({Element:H,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(v.performance.timer),v.performance.timer=setTimeout(v.performance.display,100)},display:function(){var b=w.name+":",c=0;k=!1,clearTimeout(v.performance.timer),a.each(l,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",D&&(b+=" '"+D+"'"),(console.group!==d||console.table!==d)&&l.length>0&&(console.groupCollapsed(b),console.table?console.table(l):a.each(l,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),l=[]}},invoke:function(b,c,e){var g,h,i,j=I;return c=c||o,e=H||e,"string"==typeof b&&j!==d&&(b=b.split(/[\. ]/),g=b.length-1,a.each(b,function(c,e){var f=c!=g?e+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(j[f])&&c!=g)j=j[f];else{if(j[f]!==d)return h=j[f],!1;if(!a.isPlainObject(j[e])||c==g)return j[e]!==d?(h=j[e],!1):!1;j=j[e]}})),a.isFunction(h)?i=h.apply(e,c):h!==d&&(i=h),a.isArray(f)?f.push(i):f!==d?f=[f,i]:i!==d&&(f=i),h}},n?(I===d&&v.initialize(),v.invoke(m)):(I!==d&&v.destroy(),v.initialize())}),f!==d?f:this},a.fn.modal.settings={name:"Modal",namespace:"modal",debug:!1,verbose:!0,performance:!0,allowMultiple:!0,detachable:!0,closable:!0,autofocus:!0,context:"body",duration:500,easing:"easeOutQuad",offset:0,transition:"scale",padding:30,onShow:function(){},onHide:function(){},onVisible:function(){},onHidden:function(){},onApprove:function(){return!0},onDeny:function(){return!0},selector:{close:".close, .actions .button",approve:".actions .positive, .actions .approve, .actions .ok",deny:".actions .negative, .actions .deny, .actions .cancel",modal:".ui.modal"},error:{dimmer:"UI Dimmer, a required component is not included in this page",method:"The method you called is not defined."},className:{active:"active",scrolling:"scrolling"}},a.extend(a.easing,{easeOutQuad:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c}})}(jQuery,window,document);