// jQuery Mask Plugin v1.5.2
// github.com/igorescobar/jQuery-Mask-Plugin
(function(g){var y=function(a,h,d){var k=this,x;a=g(a);h="function"===typeof h?h(a.val(),void 0,a,d):h;k.init=function(){d=d||{};k.byPassKeys=[9,16,17,18,36,37,38,39,40,91];k.translation={0:{pattern:/\d/},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,recursive:!0},A:{pattern:/[a-zA-Z0-9]/},S:{pattern:/[a-zA-Z]/}};k.translation=g.extend({},k.translation,d.translation);k=g.extend(!0,{},k,d);a.each(function(){!1!==d.maxlength&&a.attr("maxlength",h.length);a.attr("autocomplete","off");c.destroyEvents();
c.events();c.val(c.getMasked())})};var c={getCaret:function(){var e;e=0;var b=a.get(0),c=document.selection,f=b.selectionStart;if(c&&-1===navigator.appVersion.indexOf("MSIE 10"))b.focus(),e=c.createRange(),e.moveStart("character",-b.value.length),e=e.text.length;else if(f||"0"===f)e=f;return e},setCaret:function(e){var b;b=a.get(0);b.setSelectionRange?(b.focus(),b.setSelectionRange(e,e)):b.createTextRange&&(b=b.createTextRange(),b.collapse(!0),b.moveEnd("character",e),b.moveStart("character",e),b.select())},
events:function(){a.on("keydown.mask",function(){x=c.val()});a.on("keyup.mask",c.behaviour);a.on("paste.mask",function(){setTimeout(function(){a.keydown().keyup()},100)})},destroyEvents:function(){a.off("keydown.mask keyup.mask paste.mask")},val:function(e){var b="input"===a.get(0).tagName.toLowerCase();return 0<arguments.length?b?a.val(e):a.text(e):b?a.val():a.text()},behaviour:function(a){a=a||window.event;if(-1===g.inArray(a.keyCode||a.which,k.byPassKeys)){var b,d=c.getCaret();d<c.val().length&&
(b=!0);c.val(c.getMasked());b&&c.setCaret(d);return c.callbacks(a)}},getMasked:function(a){var b=[],g=c.val(),f=0,p=h.length,l=0,s=g.length,m=1,t="push",q=-1,n,u;d.reverse?(t="unshift",m=-1,n=0,f=p-1,l=s-1,u=function(){return-1<f&&-1<l}):(n=p-1,u=function(){return f<p&&l<s});for(;u();){var v=h.charAt(f),w=g.charAt(l),r=k.translation[v];if(r)w.match(r.pattern)?(b[t](w),r.recursive&&(-1===q?q=f:f===n&&(f=q-m),n===q&&(f-=m)),f+=m):r.optional&&(f+=m,l-=m),l+=m;else{if(!a)b[t](v);w===v&&(l+=m);f+=m}}a=
h.charAt(n);p!==s+1||k.translation[a]||b.push(a);return b.join("")},callbacks:function(e){var b=c.val(),g=c.val()!==x;if(!0===g&&"function"===typeof d.onChange)d.onChange(b,e,a,d);if(!0===g&&"function"===typeof d.onKeyPress)d.onKeyPress(b,e,a,d);if("function"===typeof d.onComplete&&b.length===h.length)d.onComplete(b,e,a,d)}};k.remove=function(){c.destroyEvents();c.val(k.getCleanVal()).removeAttr("maxlength")};k.getCleanVal=function(){return c.getMasked(!0)};k.init()};g.fn.mask=function(a,h){return this.each(function(){g(this).data("mask",
new y(this,a,h))})};g.fn.unmask=function(){return this.each(function(){try{g(this).data("mask").remove()}catch(a){}})};g.fn.cleanVal=function(){return g(this).data("mask").getCleanVal()};g("input[data-mask]").each(function(){var a=g(this),h={};"true"===a.attr("data-mask-reverse")&&(h.reverse=!0);"false"===a.attr("data-mask-maxlength")&&(h.maxlength=!1);a.mask(a.attr("data-mask"),h)})})(window.jQuery||window.Zepto);
