diff --git a/third_party/inputmask/bundle.js b/third_party/inputmask/bundle.js index 9c0b34a0c1a23..f8a4d3fdb0d2a 100644 --- a/third_party/inputmask/bundle.js +++ b/third_party/inputmask/bundle.js @@ -2,12 +2,12 @@ "use strict";var _inputmask=require("./inputmask.dependencyLib"),_inputmask2=require("./inputmask"),_inputmaskDate=require("./inputmask.date.extensions");function factory(e){var n=e.ownerDocument,t=n.defaultView,i=(0,_inputmask.factory)(t,n),a=(0,_inputmask2.factory)(i,t,n,void 0);return(0,_inputmaskDate.factory)(a),a}(window.AMP=window.AMP||[]).push(function(e){(e.dependencies=e.dependencies||{}).inputmaskFactory=factory}); },{"./inputmask":4,"./inputmask.date.extensions":2,"./inputmask.dependencyLib":3}],2:[function(require,module,exports){ -"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function factory(t){var e=t.dependencyLib,r={d:["[1-9]|[12][0-9]|3[01]",Date.prototype.setDate,"day",Date.prototype.getDate],dd:["0[1-9]|[12][0-9]|3[01]",Date.prototype.setDate,"day",function(){return i(Date.prototype.getDate.call(this),2)}],ddd:[""],dddd:[""],m:["[1-9]|1[012]",Date.prototype.setMonth,"month",function(){return Date.prototype.getMonth.call(this)+1}],mm:["0[1-9]|1[012]",Date.prototype.setMonth,"month",function(){return i(Date.prototype.getMonth.call(this)+1,2)}],mmm:[""],mmmm:[""],yy:["[0-9]{2}",Date.prototype.setFullYear,"year",function(){return i(Date.prototype.getFullYear.call(this),2)}],yyyy:["[0-9]{4}",Date.prototype.setFullYear,"year",function(){return i(Date.prototype.getFullYear.call(this),4)}],h:["[1-9]|1[0-2]",Date.prototype.setHours,"hours",Date.prototype.getHours],hh:["0[1-9]|1[0-2]",Date.prototype.setHours,"hours",function(){return i(Date.prototype.getHours.call(this),2)}],hhh:["[0-9]+",Date.prototype.setHours,"hours",Date.prototype.getHours],H:["1?[0-9]|2[0-3]",Date.prototype.setHours,"hours",Date.prototype.getHours],HH:["[01][0-9]|2[0-3]",Date.prototype.setHours,"hours",function(){return i(Date.prototype.getHours.call(this),2)}],HHH:["[0-9]+",Date.prototype.setHours,"hours",Date.prototype.getHours],M:["[1-5]?[0-9]",Date.prototype.setMinutes,"minutes",Date.prototype.getMinutes],MM:["[0-5][0-9]",Date.prototype.setMinutes,"minutes",function(){return i(Date.prototype.getMinutes.call(this),2)}],s:["[1-5]?[0-9]",Date.prototype.setSeconds,"seconds",Date.prototype.getSeconds],ss:["[0-5][0-9]",Date.prototype.setSeconds,"seconds",function(){return i(Date.prototype.getSeconds.call(this),2)}],l:["[0-9]{3}",Date.prototype.setMilliseconds,"milliseconds",function(){return i(Date.prototype.getMilliseconds.call(this),3)}],L:["[0-9]{2}",Date.prototype.setMilliseconds,"milliseconds",function(){return i(Date.prototype.getMilliseconds.call(this),2)}],t:["[ap]"],tt:["[ap]m"],T:["[AP]"],TT:["[AP]M"],Z:[""],o:[""],S:[""]},o={isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};function n(t){if(!t.tokenizer){var e=[];for(var o in r)-1===e.indexOf(o[0])&&e.push(o[0]);t.tokenizer="("+e.join("+|")+")+?|.",t.tokenizer=new RegExp(t.tokenizer,"g")}return t.tokenizer}function a(e,o,a,i){for(var s,u="";s=n(a).exec(e);){if(void 0===o)if(r[s[0]])u+="("+r[s[0]][0]+")";else switch(s[0]){case"[":u+="(";break;case"]":u+=")?";break;default:u+=t.escapeRegex(s[0])}else if(r[s[0]])if(!0!==i&&r[s[0]][3])u+=r[s[0]][3].call(o.date);else r[s[0]][2]?u+=o["raw"+r[s[0]][2]]:u+=s[0];else u+=s[0]}return u}function i(t,e){for(t=String(t),e=e||2;t.lengthi.slice(0,r.length)?i.slice(r.length):e.toString().slice(r.length))}return e}function y(t,e,r){t[a]=l(e),t["raw"+a]=e,void 0!==s&&s.call(t.date,"month"==a?parseInt(t[a])-1:t[a])}if("string"==typeof p){for(;i=n(o).exec(e);){var m=p.slice(0,i[0].length);r.hasOwnProperty(i[0])&&(r[i[0]][0],a=r[i[0]][2],s=r[i[0]][1],y(u,m)),p=p.slice(m.length)}return u}if(p&&"object"===_typeof(p)&&p.hasOwnProperty("date"))return p}return t.extendAliases({datetime:{mask:function(t){return r.S=t.i18n.ordinalSuffix.join("|"),t.inputFormat=o[t.inputFormat]||t.inputFormat,t.displayFormat=o[t.displayFormat]||t.displayFormat||t.inputFormat,t.outputFormat=o[t.outputFormat]||t.outputFormat||t.inputFormat,t.placeholder=""!==t.placeholder?t.placeholder:t.inputFormat.replace(/[\[\]]/,""),t.regex=a(t.inputFormat,void 0,t),null},placeholder:"",inputFormat:"isoDateTime",displayFormat:void 0,outputFormat:void 0,min:null,max:null,i18n:{dayNames:["Mon","Tue","Wed","Thu","Fri","Sat","Sun","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"],ordinalSuffix:["st","nd","rd","th"]},postValidation:function(t,e,r,o,n){o.min=s(o.min,o.inputFormat,o),o.max=s(o.max,o.inputFormat,o);var i=r,u=s(t.join(""),o.inputFormat,o);if(i&&u.date.getTime()==u.date.getTime()){var p=(i=function(t,e){return(!isFinite(t.rawday)||"29"==t.day&&!isFinite(t.rawyear)||t.year.length<4||new Date(t.date.getFullYear(),isFinite(t.rawmonth)?t.month:t.date.getMonth()+1,0).getDate()>=t.day)&&e}(u,i))&&function(t,e){var r=!0;if(!t.rawyear||!t.rawmonth||!t.rawday)return!1;if(e.min){if(t.rawyear){var o=t.rawyear.replace(/[^0-9]/g,"");r=e.min.year.substr(0,o.length)<=o}t.year===t.rawyear&&e.min.date.getTime()==e.min.date.getTime()&&(r=e.min.date.getTime()<=t.date.getTime())}return r&&e.max&&e.max.date.getTime()==e.max.date.getTime()&&(r=e.max.date.getTime()>=t.date.getTime()),r}(u,o);if(e&&p&&r.pos!==e)return{buffer:a(o.inputFormat,u,o),refreshFromBuffer:{start:e,end:r.pos}}}var l=t.length,y=n.tests[l];if(!y)return i;var m=y.map(function(t){return t.match}).filter(function(t){return/^[-\/]$/.test(t.def)});if(1===m.length){var c=m[0].def;return{buffer:t.concat([c]),refreshFromBuffer:{start:e,end:t.length+1}}}return i},onKeyDown:function(r,o,a,s){var u=this;if(r.ctrlKey&&r.keyCode===t.keyCode.RIGHT){for(var p,l=new Date,y="";p=n(s).exec(s.inputFormat);)"d"===p[0].charAt(0)?y+=i(l.getDate(),p[0].length):"m"===p[0].charAt(0)?y+=i(l.getMonth()+1,p[0].length):"yyyy"===p[0]?y+=l.getFullYear().toString():"y"===p[0].charAt(0)&&(y+=i(l.getYear(),p[0].length));u.inputmask._valueSet(y),e(u).trigger("setvalue")}if(r.keyCode===t.keyCode.BACKSPACE){var m=u.value.length,c=u.selectionStart!=m&&u.selectionEnd!=m;if(m>0&&c){var d=u.inputmask;u.inputmask.remove(),u.addEventListener("input",function t(){0==u.value.length&&(u.removeEventListener("input",t),d.mask(u))})}}},onUnMask:function(t,e,r){return a(r.outputFormat,s(t,r.inputFormat,r),r,!0)},casing:function(t,e,r,o){return 0==e.nativeDef.indexOf("[ap]")?t.toLowerCase():0==e.nativeDef.indexOf("[AP]")?t.toUpperCase():t},insertMode:!1,shiftPositions:!1}}),t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.factory=factory; +"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function factory(e){var t=e.dependencyLib,r={d:["[1-9]|[12][0-9]|3[01]",Date.prototype.setDate,"day",Date.prototype.getDate],dd:["0[1-9]|[12][0-9]|3[01]",Date.prototype.setDate,"day",function(){return i(Date.prototype.getDate.call(this),2)}],ddd:[""],dddd:[""],m:["[1-9]|1[012]",Date.prototype.setMonth,"month",function(){return Date.prototype.getMonth.call(this)+1}],mm:["0[1-9]|1[012]",Date.prototype.setMonth,"month",function(){return i(Date.prototype.getMonth.call(this)+1,2)}],mmm:[""],mmmm:[""],yy:["[0-9]{2}",Date.prototype.setFullYear,"year",function(){return i(Date.prototype.getFullYear.call(this),2)}],yyyy:["[0-9]{4}",Date.prototype.setFullYear,"year",function(){return i(Date.prototype.getFullYear.call(this),4)}],h:["[1-9]|1[0-2]",Date.prototype.setHours,"hours",Date.prototype.getHours],hh:["0[1-9]|1[0-2]",Date.prototype.setHours,"hours",function(){return i(Date.prototype.getHours.call(this),2)}],hhh:["[0-9]+",Date.prototype.setHours,"hours",Date.prototype.getHours],H:["1?[0-9]|2[0-3]",Date.prototype.setHours,"hours",Date.prototype.getHours],HH:["[01][0-9]|2[0-3]",Date.prototype.setHours,"hours",function(){return i(Date.prototype.getHours.call(this),2)}],HHH:["[0-9]+",Date.prototype.setHours,"hours",Date.prototype.getHours],M:["[1-5]?[0-9]",Date.prototype.setMinutes,"minutes",Date.prototype.getMinutes],MM:["[0-5][0-9]",Date.prototype.setMinutes,"minutes",function(){return i(Date.prototype.getMinutes.call(this),2)}],s:["[1-5]?[0-9]",Date.prototype.setSeconds,"seconds",Date.prototype.getSeconds],ss:["[0-5][0-9]",Date.prototype.setSeconds,"seconds",function(){return i(Date.prototype.getSeconds.call(this),2)}],l:["[0-9]{3}",Date.prototype.setMilliseconds,"milliseconds",function(){return i(Date.prototype.getMilliseconds.call(this),3)}],L:["[0-9]{2}",Date.prototype.setMilliseconds,"milliseconds",function(){return i(Date.prototype.getMilliseconds.call(this),2)}],t:["[ap]"],tt:["[ap]m"],T:["[AP]"],TT:["[AP]M"],Z:[""],o:[""],S:[""]},o={isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};function a(e){if(!e.tokenizer){var t=[];for(var o in r)-1===t.indexOf(o[0])&&t.push(o[0]);e.tokenizer="("+t.join("+|")+")+?|.",e.tokenizer=new RegExp(e.tokenizer,"g")}return e.tokenizer}function n(t,o,n,i){for(var s,u="";s=a(n).exec(t);){if(void 0===o)if(r[s[0]])u+="("+r[s[0]][0]+")";else switch(s[0]){case"[":u+="(";break;case"]":u+=")?";break;default:u+=e.escapeRegex(s[0])}else if(r[s[0]])if(!0!==i&&r[s[0]][3])u+=r[s[0]][3].call(o.date);else r[s[0]][2]?u+=o["raw"+r[s[0]][2]]:u+=s[0];else u+=s[0]}return u}function i(e,t){for(e=String(e),t=t||2;e.lengthi.slice(0,r.length)?i.slice(r.length):t.toString().slice(r.length))}return t}function y(e,t,r){e[n]=p(t),e["raw"+n]=t,void 0!==s&&s.call(e.date,"month"==n?parseInt(e[n])-1:e[n])}if("string"==typeof l){for(;i=a(o).exec(t);){var c=l.slice(0,i[0].length);r.hasOwnProperty(i[0])&&(r[i[0]][0],n=r[i[0]][2],s=r[i[0]][1],y(u,c)),l=l.slice(c.length)}return u}if(l&&"object"===_typeof(l)&&l.hasOwnProperty("date"))return l}function u(e){var t=e.inputmask;e.inputmask.remove(),e.addEventListener("input",function r(){0==e.value.length&&(e.removeEventListener("input",r),t.mask(e))})}return e.extendAliases({datetime:{mask:function(e){return r.S=e.i18n.ordinalSuffix.join("|"),e.inputFormat=o[e.inputFormat]||e.inputFormat,e.displayFormat=o[e.displayFormat]||e.displayFormat||e.inputFormat,e.outputFormat=o[e.outputFormat]||e.outputFormat||e.inputFormat,e.placeholder=""!==e.placeholder?e.placeholder:e.inputFormat.replace(/[\[\]]/,""),e.regex=n(e.inputFormat,void 0,e),null},placeholder:"",inputFormat:"isoDateTime",displayFormat:void 0,outputFormat:void 0,min:null,max:null,i18n:{dayNames:["Mon","Tue","Wed","Thu","Fri","Sat","Sun","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"],ordinalSuffix:["st","nd","rd","th"]},postValidation:function(e,t,r,o,a){o.min=s(o.min,o.inputFormat,o),o.max=s(o.max,o.inputFormat,o);var i=r,u=s(e.join(""),o.inputFormat,o);if(i&&u.date.getTime()==u.date.getTime()){var l=(i=function(e,t){return(!isFinite(e.rawday)||"29"==e.day&&!isFinite(e.rawyear)||e.year.length<4||new Date(e.date.getFullYear(),isFinite(e.rawmonth)?e.month:e.date.getMonth()+1,0).getDate()>=e.day)&&t}(u,i))&&function(e,t){var r=!0;if(!e.rawyear||!e.rawmonth||!e.rawday)return!1;if(t.min){if(e.rawyear){var o=e.rawyear.replace(/[^0-9]/g,"");r=t.min.year.substr(0,o.length)<=o}e.year===e.rawyear&&t.min.date.getTime()==t.min.date.getTime()&&(r=t.min.date.getTime()<=e.date.getTime())}return r&&t.max&&t.max.date.getTime()==t.max.date.getTime()&&(r=t.max.date.getTime()>=e.date.getTime()),r}(u,o);if(t&&l&&r.pos!==t)return{buffer:n(o.inputFormat,u,o),refreshFromBuffer:{start:t,end:r.pos}}}var p=e.length,y=a.tests[p];if(!y)return i;var c=y.map(function(e){return e.match}).filter(function(e){return/^[-\/]$/.test(e.def)});if(1===c.length){var d=c[0].def;return{buffer:e.concat([d]),refreshFromBuffer:{start:t,end:e.length+1}}}return i},onKeyDown:function(r,o,n,s,l,p){var y=this;if(r.ctrlKey&&r.keyCode===e.keyCode.RIGHT){for(var c,d=new Date,m="";c=a(s).exec(s.inputFormat);)"d"===c[0].charAt(0)?m+=i(d.getDate(),c[0].length):"m"===c[0].charAt(0)?m+=i(d.getMonth()+1,c[0].length):"yyyy"===c[0]?m+=d.getFullYear().toString():"y"===c[0].charAt(0)&&(m+=i(d.getYear(),c[0].length));y.inputmask._valueSet(m),t(y).trigger("setvalue")}var f=p.begin,h=p.end;if(r.keyCode===e.keyCode.BACKSPACE||r.keyCode===e.keyCode.DELETE||(r.metaKey||r.ctrlKey)&&r.keyCode==="X".charCodeAt(0)){var g=y.value.length,D=y.selectionStart!=g&&y.selectionEnd!=g;if(g>0&&D){u(y);var v=h-f;if(r.keyCode===e.keyCode.BACKSPACE){var F=0==v?f-1:f;y.value=l.slice(0,F)+l.slice(h),y.setSelectionRange(F,F)}else if(r.keyCode===e.keyCode.DELETE){var M=0==v?h+1:h;y.value=l.slice(0,f)+l.slice(M),y.setSelectionRange(f,f)}}}else if(p.begin!=p.end){if((r.metaKey||r.ctrlKey)&&r.keyCode==="V".charCodeAt(0))return void u(y);if(r.metaKey||r.ctrlKey)return;var S=String.fromCharCode(r.keyCode),T=r.shiftKey?S.toLocaleUpperCase():S.toLocaleLowerCase();/\s/.test(T)||(u(y),setTimeout(function(){y.value=l.slice(0,f)+T+l.slice(h),y.setSelectionRange(f+1,f+1)},0))}},onUnMask:function(e,t,r){return n(r.outputFormat,s(e,r.inputFormat,r),r,!0)},casing:function(e,t,r,o){return 0==t.nativeDef.indexOf("[ap]")?e.toLowerCase():0==t.nativeDef.indexOf("[AP]")?e.toUpperCase():e},insertMode:!1,shiftPositions:!1}}),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.factory=factory; },{}],3:[function(require,module,exports){ "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function factory(e,t){function n(e){return null!=e&&e===e.window}function o(t){return t instanceof e.Element}function i(n){return n instanceof i?n:this instanceof i?void(null!=n&&n!==e&&(this[0]=n.nodeName?n:void 0!==n[0]&&n[0].nodeName?n[0]:t.querySelector(n),void 0!==this[0]&&null!==this[0]&&(this[0].eventRegistry=this[0].eventRegistry||{}))):new i(n)}return i.prototype={on:function(e,t){if(o(this[0]))for(var n=function(e,n){r.addEventListener?r.addEventListener(e,t,!1):r.attachEvent&&r.attachEvent("on"+e,t),i[e]=i[e]||{},i[e][n]=i[e][n]||[],i[e][n].push(t)},i=this[0].eventRegistry,r=this[0],a=e.split(" "),l=0;l0)if(void 0===t)for(o=0,i=r[e][n].length;o0?n:"global",handler:r[e][n][o]});else a.push({ev:e,namespace:n&&n.length>0?n:"global",handler:t});else if(n.length>0)for(var l in r)for(var f in r[l])if(f===n)if(void 0===t)for(o=0,i=r[l][f].length;o-1?new Event(s,p):new CustomEvent(s,p)}catch(e){(u=t.createEvent("CustomEvent")).initCustomEvent(s,p.bubbles,p.cancelable,p.detail)}e.type&&i.extend(u,e),r.dispatchEvent(u)}else(u=t.createEventObject()).eventType=s,u.detail=arguments[1],e.type&&i.extend(u,e),r.fireEvent("on"+u.eventType,u)}else if(void 0!==n[s])if(arguments[0]=arguments[0].type?arguments[0]:i.Event(arguments[0]),"global"===c)for(var y in n[s])for(v=0;v0&&t-1 in e)}(e))for(var i=e.length;o0||a.indexOf("Trident/")>0,o=p("touchstart"),s=/iemobile/i.test(a),l=/iphone/i.test(a)&&!s;function c(t,n,a){if(!(this instanceof c))return new c(t,n,a);this.el=i,this.events={},this.maskset=i,this.refreshValue=!1,!0!==a&&(e.isPlainObject(t)?n=t:(n=n||{},t&&(n.alias=t)),this.opts=e.extend(!0,{},this.defaults,n),this.noMasksCache=n&&n.definitions!==i,this.userOptions=n||{},this.isRTL=this.opts.numericInput,u(this.opts.alias,n,this.opts))}function u(t,n,a){var r=c.prototype.aliases[t];return r?(r.alias&&u(r.alias,i,a),e.extend(!0,a,r),e.extend(!0,a,n),!0):(null===a.mask&&(a.mask=t),!1)}function f(t,n){function a(t,a,r){var o=!1;if(null!==t&&""!==t||((o=null!==r.regex)?t=(t=r.regex).replace(/^(\^)(.*)(\$)$/,"$2"):(o=!0,t=".*")),1===t.length&&!1===r.greedy&&0!==r.repeat&&(r.placeholder=""),r.repeat>0||"*"===r.repeat||"+"===r.repeat){var s="*"===r.repeat?0:"+"===r.repeat?1:r.repeat;t=r.groupmarker[0]+t+r.groupmarker[1]+r.quantifiermarker[0]+s+","+r.repeat+r.quantifiermarker[1]}var l,u=o?"regex_"+r.regex:r.numericInput?t.split("").reverse().join(""):t;return c.prototype.masksCache[u]===i||!0===n?(l={mask:t,maskToken:c.prototype.analyseMask(t,o,r),validPositions:{},_buffer:i,buffer:i,tests:{},excludes:{},metadata:a,maskLength:i,jitOffset:{}},!0!==n&&(c.prototype.masksCache[u]=l,l=e.extend(!0,{},c.prototype.masksCache[u]))):l=e.extend(!0,{},c.prototype.masksCache[u]),l}if(e.isFunction(t.mask)&&(t.mask=t.mask(t)),e.isArray(t.mask)){if(t.mask.length>1){if(null===t.keepStatic){t.keepStatic="auto";for(var r=0;r1&&(o+=t.groupmarker[1]+t.alternatormarker+t.groupmarker[0]),a.mask===i||e.isFunction(a.mask)?o+=a:o+=a.mask}),a(o+=t.groupmarker[1],t.mask,t)}t.mask=t.mask.pop()}return t.mask&&t.mask.mask!==i&&!e.isFunction(t.mask.mask)?a(t.mask.mask,t.mask,t):a(t.mask,t.mask,t)}function p(e){var t=n.createElement("input"),i="on"+e,a=i in t;return a||(t.setAttribute(i,"return;"),a="function"==typeof t[i]),t=null,a}function h(a,u,f){u=u||this.maskset,f=f||this.opts;var m,d,v,k,g,b=this,y=this.el,P=this.isRTL,E=!1,C=!1,x=!1,_=!1;function A(e,t,n,a,r){var o=f.greedy;r&&(f.greedy=!1),t=t||0;var s,l,c,u=[],p=0;S();do{if(!0===e&&w().validPositions[p])l=(c=r&&!0===w().validPositions[p].match.optionality&&w().validPositions[p+1]===i&&(!0===w().validPositions[p].generatedInput||w().validPositions[p].input==f.skipOptionalPartCharacter&&p>0)?D(p,I(p,s,p-1)):w().validPositions[p]).match,s=c.locator.slice(),u.push(!0===n?c.input:!1===n?l.nativeDef:X(p,l));else{l=(c=G(p,s,p-1)).match,s=c.locator.slice();var h=!0!==a&&(!1!==f.jitMasking?f.jitMasking:l.jit);(!1===h||h===i||"number"==typeof h&&isFinite(h)&&h>p)&&u.push(!1===n?l.nativeDef:X(p,l))}"auto"===f.keepStatic&&l.newBlockMarker&&null!==l.fn&&(f.keepStatic=p-1),p++}while((v===i||pp);return""===u[u.length-1]&&u.pop(),!1===n&&w().maskLength!==i||(w().maskLength=p-1),f.greedy=o,u}function w(){return u}function O(e){var t=w();t.buffer=i,!0!==e&&(t.validPositions={},t.p=0)}function S(e,t,n){var a=-1,r=-1,o=n||w().validPositions;for(var s in e===i&&(e=-1),o){var l=parseInt(s);o[l]&&(t||!0!==o[l].generatedInput)&&(l<=e&&(a=l),l>=e&&(r=l))}return-1===a||a==e?r:-1==r?a:e-a0&&(t=t.split(",")[0]),t!==i?t.toString():""}function M(e,t){var n=(e.alternation!=i?e.mloc[j(e)]:e.locator).join("");if(""!==n)for(;n.length0?e-1:0)),s=0;s500&&d!==i)throw"Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. "+w().mask;if(s===t&&o.matches===i)return c.push({match:o,locator:l.reverse(),cd:p,mloc:{}}),!0;if(o.matches!==i){if(o.isGroup&&d!==o){if(o=m(n.matches[e.inArray(o,n.matches)+1],l,d))return!0}else if(o.isOptional){var y=o;if(o=h(o,a,l,d)){if(e.each(c,function(e,t){t.match.optionality=!0}),r=c[c.length-1].match,d!==i||!v(r,y))return!0;u=!0,s=t}}else if(o.isAlternator){var P,E=o,C=[],x=c.slice(),_=l.length,A=a.length>0?a.shift():-1;if(-1===A||"string"==typeof A){var O,S=s,j=a.slice(),M=[];if("string"==typeof A)M=A.split(",");else for(O=0;O=f.keepStatic)&&(M=M.slice(0,1));for(var B=!1,I=0;I0,o=C.length>0,a=j.slice()}else o=m(E.matches[A]||n.matches[A],[A].concat(l),d);if(o)return!0}else if(o.isQuantifier&&d!==n.matches[e.inArray(o,n.matches)-1])for(var V=o,H=a.length>0?a.shift():0;H<(isNaN(V.quantifier.max)?H+1:V.quantifier.max)&&s<=t;H++){var U=n.matches[e.inArray(V,n.matches)-1];if(o=m(U,[H].concat(l),U)){if((r=c[c.length-1].match).optionalQuantifier=H>=V.quantifier.min,r.jit=(H||1)*U.matches.indexOf(r)>=V.quantifier.jit,r.optionalQuantifier&&v(r,U)){u=!0,s=t;break}return r.jit&&(w().jitOffset[t]=U.matches.indexOf(r)),!0}}else if(o=h(o,a,l,d))return!0}else s++;var Q,q}for(var d=a.length>0?a.shift():0;dt)break}}if(t>-1){if(n===i){for(var m,d=t-1;(m=w().validPositions[d]||w().tests[d])===i&&d>-1;)d--;m!==i&&d>-1&&(l=function(t,n){var a=[];return e.isArray(n)||(n=[n]),n.length>0&&(n[0].alternation===i?0===(a=D(t,n.slice()).locator.slice()).length&&(a=n[0].locator.slice()):e.each(n,function(e,t){if(""!==t.def)if(0===a.length)a=t.locator.slice();else for(var n=0;nt)break}}return(0===c.length||u)&&c.push({match:{fn:null,optionality:!1,casing:null,def:"",placeholder:""},locator:[],mloc:{},cd:p}),n!==i&&w().tests[t]?e.extend(!0,[],c):(w().tests[t]=e.extend(!0,[],c),w().tests[t])}function L(){return w()._buffer===i&&(w()._buffer=A(!1,1),w().buffer===i&&(w().buffer=w()._buffer.slice())),w()._buffer}function F(e){return w().buffer!==i&&!0!==e||(w().buffer=A(!0,S(),!0),w()._buffer===i&&(w()._buffer=w().buffer.slice())),w().buffer}function N(e,t,n){var a,r;if(!0===e)O(),e=0,t=n.length;else for(a=e;a=0;v--)if((c=w().validPositions[v])&&c.alternation!==i){if(u&&u.locator[c.alternation]!==c.locator[c.alternation])break;s=v,l=w().validPositions[s].alternation,u=c}if(l!==i){h=parseInt(s),w().excludes[h]=w().excludes[h]||[],!0!==t&&w().excludes[h].push(j(u));var k=[],g=0;for(f=h;f0;){var P=y.shift();if(!(d=H(S(i,!0)+1,P,!1,r,!0)))break}if(d&&n!==i){var E=S(t)+1;for(f=h;fE?E:t,n,a,r,!0)}if(d)break;if(O(),u=T(h),w().validPositions=e.extend(!0,{},m),!w().excludes[h]){d=V(t,n,a,r,h-1);break}var C=j(u);if(-1!==w().excludes[h].indexOf(C)){d=V(t,n,a,r,h-1);break}for(w().excludes[h].push(C),f=h;f1||e.begin-e.end==1:e.end-e.begin>1||e.end-e.begin==1}a=!0===a;var c=t;function u(n,a,o){var s=!1;return e.each(I(n),function(c,u){var p=u.match;if(F(!0),!1!==(s=null!=p.fn?p.fn.test(a,w(),n,o,f,l(t)):(a===p.def||a===f.skipOptionalPartCharacter)&&""!==p.def&&{c:X(n,p,!0)||p.def,pos:n})){var h=s.c!==i?s.c:a,m=n;return h=h===f.skipOptionalPartCharacter&&null===p.fn?X(n,p,!0)||p.def:h,s.remove!==i&&(e.isArray(s.remove)||(s.remove=[s.remove]),e.each(s.remove.sort(function(e,t){return t-e}),function(e,t){Q({begin:t,end:t+1})})),s.insert!==i&&(e.isArray(s.insert)||(s.insert=[s.insert]),e.each(s.insert.sort(function(e,t){return e-t}),function(e,t){H(t.pos,t.c,!0,r)})),!0!==s&&s.pos!==i&&s.pos!==n&&(m=s.pos),!0!==s&&s.pos===i&&s.c===i?!1:(Q(t,e.extend({},u,{input:R(h,p,m)}),r,m)||(s=!1),!1)}}),s}t.begin!==i&&(c=P?t.end:t.begin);var p=!0,h=e.extend(!0,{},w().validPositions);if(e.isFunction(f.preValidation)&&!a&&!0!==r&&!0!==s&&(p=f.preValidation(F(),c,n,l(t),f,w())),!0===p){if(U(i,c,!0),(v===i||c0&&!w().validPositions[t];t--);for(var o=t;oe+1?t[e+1]&&null===t[e+1].match.fn&&t[e+1]:t[e+1];return r&&o}return!1}var s=t.begin!==i?t.begin:t,l=t.end!==i?t.end:t;if(t.begin>t.end&&(s=t.end,l=t.begin),r=r!==i?r:s,s!==l||f.insertMode&&w().validPositions[r]!==i&&a===i){var c=e.extend(!0,{},w().validPositions),u=S(i,!0);for(w().p=s,v=u;v>=s;v--)w().validPositions[v]&&"+"===w().validPositions[v].match.nativeDef&&(f.isNegative=!1),delete w().validPositions[v];var p=!0,h=r,m=(w().validPositions,!1),d=h,v=h;for(n&&(w().validPositions[r]=e.extend(!0,{},n),d++,h++,s=l||v>=s&&!0!==k.generatedInput&&o(v,c,{begin:s,end:l}))){for(;""!==T(d).match.def;){if(!1===m&&c[d]&&c[d].match.nativeDef===k.match.nativeDef)w().validPositions[d]=e.extend(!0,{},c[d]),w().validPositions[d].input=k.input,U(i,d,!0),h=d+1,p=!0;else if(f.shiftPositions&&B(d,k.match.def)){var g=H(d,k.input,!0,!0);p=!1!==g,h=g.caret||g.insert?S():d+1,m=!0}else p=!0===k.generatedInput||k.input===f.radixPoint&&!0===f.numericInput;if(p)break;if(!p&&d>l&&q(d,!0)&&(null!==k.match.fn||d>w().maskLength))break;d++}""==T(d).match.def&&(p=!1),d=h}if(!p)break}if(!p)return w().validPositions=e.extend(!0,{},c),O(!0),!1}else n&&(w().validPositions[r]=e.extend(!0,{},n));return O(!0),!0}function q(e,t){var n=G(e).match;if(""===n.def&&(n=T(e).match),null!=n.fn)return n.fn;if(!0!==t&&e>-1){var i=I(e);return i.length>1+(""===i[i.length-1].match.def?1:0)}return!1}function W(e,t){for(var n=e+1;""!==T(n).match.def&&(!0===t&&(!0!==T(n).match.newBlockMarker||!q(n))||!0!==t&&!q(n));)n++;return n}function $(e,t){var n,i=e;if(i<=0)return 0;for(;--i>0&&(!0===t&&!0!==T(i).match.newBlockMarker||!0!==t&&!q(i)&&((n=I(i)).length<2||2===n.length&&""===n[1].match.def)););return i}function z(t,n,a,r,o){if(r&&e.isFunction(f.onBeforeWrite)){var s=f.onBeforeWrite.call(b,r,n,a,f);if(s){if(s.refreshFromBuffer){var l=s.refreshFromBuffer;N(!0===l?l:l.start,l.end,s.buffer||n),n=F(!0)}a!==i&&(a=s.caret!==i?s.caret:a)}}if(t!==i&&(t.inputmask._valueSet(n.join("")),a===i||r!==i&&"blur"===r.type?ce(t,a,0===n.length):ie(t,a),!0===o)){var c=e(t),u=t.inputmask._valueGet();C=!0,c.trigger("input"),setTimeout(function(){u===L().join("")?c.trigger("cleared"):!0===oe(n)&&c.trigger("complete")},0)}}function X(t,n,a){if((n=n||T(t).match).placeholder!==i||!0===a)return e.isFunction(n.placeholder)?n.placeholder(f):n.placeholder;if(null===n.fn){if(t>-1&&w().validPositions[t]===i){var r,o=I(t),s=[];if(o.length>1+(""===o[o.length-1].match.def?1:0))for(var l=0;l1&&/[0-9a-bA-Z]/.test(s[0].match.def)))return f.placeholder.charAt(t%f.placeholder.length)}return n.def}return f.placeholder.charAt(t%f.placeholder.length)}function Z(e,t){if(r){if(e.inputmask._valueGet()!==t){var n=F().slice(),i=e.inputmask._valueGet();if(i!==t){var a=S();-1===a&&i===L().join("")?n=[]:-1!==a&&re(n),z(e,n)}}}else e.placeholder!==t&&(e.placeholder=t,""===e.placeholder&&e.removeAttribute("placeholder"))}var J,Y={on:function(t,n,a){var r=function(t){var n=this;if(n.inputmask===i&&"FORM"!==this.nodeName){var r=e.data(n,"_inputmask_opts");r?new c(r).mask(n):Y.off(n)}else{if("setvalue"===t.type||"FORM"===this.nodeName||!(n.disabled||n.readOnly&&!("keydown"===t.type&&t.ctrlKey&&67===t.keyCode||!1===f.tabThrough&&t.keyCode===c.keyCode.TAB))){switch(t.type){case"input":if(!0===C)return C=!1,t.preventDefault();if(o){var u=arguments;return setTimeout(function(){a.apply(n,u),ie(n,n.inputmask.caretPos,i,!0)},0),!1}break;case"keydown":E=!1,C=!1;break;case"keypress":if(!0===E)return t.preventDefault();E=!0;break;case"click":if(s||l){u=arguments;return setTimeout(function(){a.apply(n,u)},0),!1}}var p=a.apply(n,arguments);return!1===p&&(t.preventDefault(),t.stopPropagation()),p}t.preventDefault()}};t.inputmask.events[n]=t.inputmask.events[n]||[],t.inputmask.events[n].push(r),-1!==e.inArray(n,["submit","reset"])?null!==t.form&&e(t.form).on(n,r):e(t).on(n,r)},off:function(t,n){var i;t.inputmask&&t.inputmask.events&&(n?(i=[])[n]=t.inputmask.events[n]:i=t.inputmask.events,e.each(i,function(n,i){for(;i.length>0;){var a=i.pop();-1!==e.inArray(n,["submit","reset"])?null!==t.form&&e(t.form).off(n,a):e(t).off(n,a)}delete t.inputmask.events[n]}))}},ee={keydownEvent:function(t){var n=e(this),i=t.keyCode,a=ie(this);if(i===c.keyCode.BACKSPACE||i===c.keyCode.DELETE||l&&i===c.keyCode.BACKSPACE_SAFARI||(t.ctrlKey||t.metaKey)&&i===c.keyCode.X&&!p("cut"))t.preventDefault(),(t.metaKey||t.ctrlKey)&&(a.begin=0),se(this,i,a),a.end-a.begin==this.value.length&&O(!1),z(this,F(!0),w().p,t,this.inputmask._valueGet()!==F().join(""));else if(i===c.keyCode.END||i===c.keyCode.PAGE_DOWN){t.preventDefault();var r=W(S());ie(this,t.shiftKey?a.begin:r,r,!0)}else i===c.keyCode.HOME&&!t.shiftKey||i===c.keyCode.PAGE_UP?(t.preventDefault(),ie(this,0,t.shiftKey?a.begin:0,!0)):(f.undoOnEscape&&i===c.keyCode.ESCAPE||90===i&&t.ctrlKey)&&!0!==t.altKey?(te(this,!0,!1,m.split("")),n.trigger("click")):i!==c.keyCode.INSERT||t.shiftKey||t.ctrlKey?!0===f.tabThrough&&i===c.keyCode.TAB&&(!0===t.shiftKey?(null===T(a.begin).match.fn&&(a.begin=W(a.begin)),a.end=$(a.begin,!0),a.begin=$(a.end,!0)):(a.begin=W(a.begin,!0),a.end=W(a.begin,!0),a.endr.length?-1:0,l=i.substr(0,a.begin),u=i.substr(a.begin),p=r.substr(0,a.begin+o),h=r.substr(a.begin+o),m=a,d="",v=!1;if(l!==p){var k,g=(v=l.length>=p.length)?l.length:p.length;for(k=0;l.charAt(k)===p.charAt(k)&&kh.length?d+=u.slice(0,1):u.length0)e.each(d.split(""),function(t,i){var a=new e.Event("keypress");a.which=i.charCodeAt(0),x=!1,ee.keypressEvent.call(n,a)});else{m.begin===m.end-1&&(m.begin=$(m.begin+1),m.begin===m.end-1?ie(n,m.begin):ie(n,m.begin,m.end));var b=new e.Event("keydown");b.keyCode=f.numericInput?c.keyCode.BACKSPACE:c.keyCode.DELETE,ee.keydownEvent.call(n,b)}t.preventDefault()}}},beforeInputEvent:function(t){if(t.cancelable){var n=this;switch(t.inputType){case"insertText":return e.each(t.data.split(""),function(t,i){var a=new e.Event("keypress");a.which=i.charCodeAt(0),x=!1,ee.keypressEvent.call(n,a)}),t.preventDefault();case"deleteContentBackward":return(i=new e.Event("keydown")).keyCode=c.keyCode.BACKSPACE,ee.keydownEvent.call(n,i),t.preventDefault();case"deleteContentForward":var i;return(i=new e.Event("keydown")).keyCode=c.keyCode.DELETE,ee.keydownEvent.call(n,i),t.preventDefault()}}},setValueEvent:function(t){this.inputmask.refreshValue=!1;var n=(n=t&&t.detail?t.detail[0]:arguments[1])||this.inputmask._valueGet(!0);e.isFunction(f.onBeforeMask)&&(n=f.onBeforeMask.call(b,n,f)||n),te(this,!0,!1,n=n.split("")),m=F().join(""),(f.clearMaskOnLostFocus||f.clearIncomplete)&&this.inputmask._valueGet()===L().join("")&&this.inputmask._valueSet("")},focusEvent:function(e){var t=this.inputmask._valueGet();f.showMaskOnFocus&&(t!==F().join("")?z(this,F(),W(S())):!1===_&&ie(this,W(S()))),!0===f.positionCaretOnTab&&!1===_&&ee.clickEvent.apply(this,[e,!0]),m=F().join("")},mouseleaveEvent:function(e){_=!1,f.clearMaskOnLostFocus&&n.activeElement!==this&&Z(this,g)},clickEvent:function(t,a){var r=this;setTimeout(function(){if(n.activeElement===r){var t=ie(r);if(a&&(P?t.end=t.begin:t.begin=t.end),t.begin===t.end)switch(f.positionCaretOnClick){case"none":break;case"select":ie(r,0,F().length);break;case"ignore":ie(r,W(S()));break;case"radixFocus":if(function(t){if(""!==f.radixPoint){var n=w().validPositions;if(n[t]===i||n[t].input===X(t)){if(t=m||s===c)&&(c=m)}ie(r,c)}}}},0)},cutEvent:function(i){e(this);var a=ie(this),r=i.originalEvent||i,o=t.clipboardData||r.clipboardData,s=P?F().slice(a.end,a.begin):F().slice(a.begin,a.end);o.setData("text",P?s.reverse().join(""):s.join("")),n.execCommand&&n.execCommand("copy"),(i.metaKey||i.ctrlKey)&&(a.begin=0),se(this,c.keyCode.DELETE,a),a.end-a.begin==this.value.length&&O(!1),z(this,F(),w().p,i,m!==F().join(""))},blurEvent:function(t){var n=e(this);if(this.inputmask){Z(this,g);var a=this.inputmask._valueGet(),r=F().slice();""===a&&k===i||(f.clearMaskOnLostFocus&&(-1===S()&&a===L().join("")?r=[]:re(r)),!1===oe(r)&&(setTimeout(function(){n.trigger("incomplete")},0),f.clearIncomplete&&(O(),r=f.clearMaskOnLostFocus?[]:L().slice())),z(this,r,i,t)),m!==F().join("")&&(m=r.join(""),n.trigger("change"))}},mouseenterEvent:function(e){_=!0,n.activeElement!==this&&f.showMaskOnHover&&Z(this,(P?F().slice().reverse():F()).join(""))},submitEvent:function(e){m!==F().join("")&&d.trigger("change"),f.clearMaskOnLostFocus&&-1===S()&&y.inputmask._valueGet&&y.inputmask._valueGet()===L().join("")&&y.inputmask._valueSet(""),f.clearIncomplete&&!1===oe(F())&&y.inputmask._valueSet(""),f.removeMaskOnSubmit&&(y.inputmask._valueSet(y.inputmask.unmaskedvalue(),!0),setTimeout(function(){z(y,F())},0))},resetEvent:function(e){y.inputmask.refreshValue=!0,setTimeout(function(){d.trigger("setvalue")},0)}};function te(t,n,a,r,o){var s=this||t.inputmask,l=r.slice(),u="",p=-1,h=i;if(O(),a||!0===f.autoUnmask)p=W(p);else{var m=L().slice(0,W(-1)).join(""),d=l.join("").match(new RegExp("^"+c.escapeRegex(m),"g"));d&&d.length>0&&(l.splice(0,d.length*m.length),p=W(p))}-1===p?(w().p=W(p),p=0):w().p=p,s.caretPos={begin:p},e.each(l,function(n,r){if(r!==i)if(w().validPositions[n]===i&&l[n]===X(n)&&q(n,!0)&&!1===H(n,l[n],!0,i,i,!0))w().p++;else{var o=new e.Event("_checkval");o.which=r.charCodeAt(0),u+=r;var c=S(i,!0);!function(e,t){return-1!==A(!0,0,!1).slice(e,W(e)).join("").replace(/'/g,"").indexOf(t)&&!q(e)&&(T(e).match.nativeDef===t.charAt(0)||null===T(e).match.fn&&T(e).match.nativeDef==="'"+t.charAt(0)||" "===T(e).match.nativeDef&&(T(e+1).match.nativeDef===t.charAt(0)||null===T(e+1).match.fn&&T(e+1).match.nativeDef==="'"+t.charAt(0)))}(p,u)?(h=ee.keypressEvent.call(t,o,!0,!1,a,s.caretPos.begin))&&(p=s.caretPos.begin+1,u=""):h=ee.keypressEvent.call(t,o,!0,!1,a,c+1),h&&(z(i,F(),h.forwardPosition,o,!1),s.caretPos={begin:h.forwardPosition,end:h.forwardPosition})}}),n&&z(t,F(),h?h.forwardPosition:i,o||new e.Event("checkval"),o&&"input"===o.type)}function ne(t){if(t){if(t.inputmask===i)return t.value;t.inputmask&&t.inputmask.refreshValue&&ee.setValueEvent.call(t)}var n=[],a=w().validPositions;for(var r in a)a[r].match&&null!=a[r].match.fn&&n.push(a[r].input);var o=0===n.length?"":(P?n.reverse():n).join("");if(e.isFunction(f.onUnMask)){var s=(P?F().slice().reverse():F()).join("");o=f.onUnMask.call(b,s,o,f)}return o}function ie(a,r,o,s){function l(e){return!P||"number"!=typeof e||f.greedy&&""===f.placeholder||!y||(e=y.inputmask._valueGet().length-e),e}var c;if(r===i)return"selectionStart"in a?(r=a.selectionStart,o=a.selectionEnd):t.getSelection?(c=t.getSelection().getRangeAt(0)).commonAncestorContainer.parentNode!==a&&c.commonAncestorContainer!==a||(r=c.startOffset,o=c.endOffset):n.selection&&n.selection.createRange&&(o=(r=0-(c=n.selection.createRange()).duplicate().moveStart("character",-a.inputmask._valueGet().length))+c.text.length),{begin:s?r:l(r),end:s?o:l(o)};if(e.isArray(r)&&(o=P?r[0]:r[1],r=P?r[1]:r[0]),r.begin!==i&&(o=P?r.begin:r.end,r=P?r.end:r.begin),"number"==typeof r){r=s?r:l(r),o="number"==typeof(o=s?o:l(o))?o:r;var u=parseInt(((a.ownerDocument.defaultView||t).getComputedStyle?(a.ownerDocument.defaultView||t).getComputedStyle(a,null):a.currentStyle).fontSize)*o;if(a.scrollLeft=u>a.scrollWidth?u:0,a.inputmask.caretPos={begin:r,end:o},a===n.activeElement){if("selectionStart"in a)a.selectionStart=r,a.selectionEnd=o;else if(t.getSelection){if(c=n.createRange(),a.firstChild===i||null===a.firstChild){var p=n.createTextNode("");a.appendChild(p)}c.setStart(a.firstChild,rs&&(((a=l[n]).match.optionality||a.match.optionalQuantifier&&a.match.newBlockMarker||f&&(f!==l[n].locator[c.alternation]&&null!=a.match.fn||null===a.match.fn&&a.locator[c.alternation]&&K(a.locator[c.alternation].toString().split(","),f.toString().split(","))&&""!==I(n)[0].def))&&r[n]===X(n,a.match));n--)o--;return t?{l:o,def:l[o]?l[o].match:i}:o}function re(e){e.length=0;for(var t,n=A(!0,0,!0,i,!0);(t=n.shift())!==i;)e.push(t);return e}function oe(t){if(e.isFunction(f.isComplete))return f.isComplete(t,f);if("*"===f.repeat)return i;var n=!1,a=ae(!0),r=$(a.l);if(a.def===i||a.def.newBlockMarker||a.def.optionality||a.def.optionalQuantifier){n=!0;for(var o=0;o<=r;o++){var s=G(o).match;if(null!==s.fn&&w().validPositions[o]===i&&!0!==s.optionality&&!0!==s.optionalQuantifier||null===s.fn&&t[o]!==X(o,s)){n=!1;break}}}return n}function se(e,t,n,a,r){if((f.numericInput||P)&&(t===c.keyCode.BACKSPACE?t=c.keyCode.DELETE:t===c.keyCode.DELETE&&(t=c.keyCode.BACKSPACE),P)){var o=n.end;n.end=n.begin,n.begin=o}if(t===c.keyCode.BACKSPACE&&n.end-n.begin<1?(n.begin=$(n.begin),w().validPositions[n.begin]!==i&&w().validPositions[n.begin].input===f.groupSeparator&&n.begin--):t===c.keyCode.DELETE&&n.begin===n.end&&(n.end=q(n.end,!0)&&w().validPositions[n.end]&&w().validPositions[n.end].input!==f.radixPoint?n.end+1:W(n.end)+1,w().validPositions[n.begin]!==i&&w().validPositions[n.begin].input===f.groupSeparator&&n.end++),Q(n),!0!==a&&!1!==f.keepStatic||null!==f.regex){var s=V(!0);if(s){var l=s.caret!==i?s.caret:s.pos?W(s.pos.begin?s.pos.begin:s.pos):S(-1,!0);(t!==c.keyCode.DELETE||n.begin>l)&&n.begin}}var u=S(n.begin,!0);if(u=e){var u=e-c,f=r.offsetWidth-e;r.innerHTML=l.charAt(t),t=(u-=r.offsetWidth/3)",l.push(e)}else l.push(e);else c=!0,l.push(""+e)}if(k!==i){var h=F();if(t===i?t=ie(e):t.begin===i&&(t={begin:t,end:t}),!0!==a){var m=S();do{w().validPositions[u]?(o=w().validPositions[u],r=o.match,s=o.locator.slice(),p(h[u])):(o=G(u,s,u-1),r=o.match,s=o.locator.slice(),!1===f.jitMasking||uu?p(X(u,r)):c=!1),u++}while((v===i||uu||c);c&&p(),n.activeElement===e&&(l.splice(t.begin,0,t.begin===t.end||t.end>w().maskLength?'':''),l.splice(t.end+1,0,""))}var d=k.getElementsByTagName("div")[0];d.innerHTML=l.join(""),e.inputmask.positionColorMask(e,d)}}if(c.prototype.positionColorMask=function(e,t){e.style.left=t.offsetLeft+"px"},a!==i)switch(a.action){case"isComplete":return y=a.el,oe(F());case"unmaskedvalue":return y!==i&&a.value===i||(J=a.value,J=(e.isFunction(f.onBeforeMask)&&f.onBeforeMask.call(b,J,f)||J).split(""),te.call(this,i,!1,!1,J),e.isFunction(f.onBeforeWrite)&&f.onBeforeWrite.call(b,i,F(),0,f)),ne(y);case"mask":!function(t){Y.off(t);var a=function(t,a){var r=t.getAttribute("type"),o="INPUT"===t.tagName&&-1!==e.inArray(r,a.supportsInputType)||t.isContentEditable||"TEXTAREA"===t.tagName;if(!o)if("INPUT"===t.tagName){var s=n.createElement("input");s.setAttribute("type",r),o="text"===s.type,s=null}else o="partial";return!1!==o?function(t){var r,o;function s(){return this.inputmask?this.inputmask.opts.autoUnmask?this.inputmask.unmaskedvalue():-1!==S()||!0!==a.nullable?n.activeElement===this&&a.clearMaskOnLostFocus?(P?re(F().slice()).reverse():re(F().slice())).join(""):r.call(this):"":r.call(this)}function l(t){o.call(this,t),this.inputmask&&e(this).trigger("setvalue",[t])}if(!t.inputmask.__valueGet){if(!0!==a.noValuePatching){if(Object.getOwnPropertyDescriptor){"function"!=typeof Object.getPrototypeOf&&(Object.getPrototypeOf="object"===_typeof("test".__proto__)?function(e){return e.__proto__}:function(e){return e.constructor.prototype});var c=Object.getPrototypeOf?Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value"):i;c&&c.get&&c.set?(r=c.get,o=c.set,Object.defineProperty(t,"value",{get:s,set:l,configurable:!0})):"INPUT"!==t.tagName&&(r=function(){return this.textContent},o=function(e){this.textContent=e},Object.defineProperty(t,"value",{get:s,set:l,configurable:!0}))}else n.__lookupGetter__&&t.__lookupGetter__("value")&&(r=t.__lookupGetter__("value"),o=t.__lookupSetter__("value"),t.__defineGetter__("value",s),t.__defineSetter__("value",l));t.inputmask.__valueGet=r,t.inputmask.__valueSet=o}t.inputmask._valueGet=function(e){return P&&!0!==e?r.call(this.el).split("").reverse().join(""):r.call(this.el)},t.inputmask._valueSet=function(e,t){o.call(this.el,null===e||e===i?"":!0!==t&&P?e.split("").reverse().join(""):e)},r===i&&(r=function(){return this.value},o=function(e){this.value=e},function(t){if(e.valHooks&&(e.valHooks[t]===i||!0!==e.valHooks[t].inputmaskpatch)){var n=e.valHooks[t]&&e.valHooks[t].get?e.valHooks[t].get:function(e){return e.value},r=e.valHooks[t]&&e.valHooks[t].set?e.valHooks[t].set:function(e,t){return e.value=t,e};e.valHooks[t]={get:function(e){if(e.inputmask){if(e.inputmask.opts.autoUnmask)return e.inputmask.unmaskedvalue();var t=n(e);return-1!==S(i,i,e.inputmask.maskset.validPositions)||!0!==a.nullable?t:""}return n(e)},set:function(t,n){var i,a=e(t);return i=r(t,n),t.inputmask&&a.trigger("setvalue",[n]),i},inputmaskpatch:!0}}}(t.type),function(t){Y.on(t,"mouseenter",function(t){var n=e(this),i=this.inputmask._valueGet();a.showMaskOnHover&&i!==F().join("")&&n.trigger("setvalue")})}(t))}}(t):t.inputmask=i,o}(t,f);if(!1!==a&&(d=e(y=t),g=y.placeholder,-1===(v=y!==i?y.maxLength:i)&&(v=i),!0===f.colorMask&&le(y),o&&("inputmode"in y&&(y.inputmode=f.inputmode,y.setAttribute("inputmode",f.inputmode)),!0===f.disablePredictiveText&&("autocorrect"in y?y.autocorrect=!1:(!0!==f.colorMask&&le(y),y.type="password"))),!0===a&&(y.setAttribute("im-insert",f.insertMode),Y.on(y,"submit",ee.submitEvent),Y.on(y,"reset",ee.resetEvent),Y.on(y,"blur",ee.blurEvent),Y.on(y,"focus",ee.focusEvent),!0!==f.colorMask&&(Y.on(y,"click",ee.clickEvent),Y.on(y,"mouseleave",ee.mouseleaveEvent),Y.on(y,"mouseenter",ee.mouseenterEvent)),Y.on(y,"paste",ee.pasteEvent),Y.on(y,"cut",ee.cutEvent),Y.on(y,"complete",f.oncomplete),Y.on(y,"incomplete",f.onincomplete),Y.on(y,"cleared",f.oncleared),o||!0===f.inputEventOnly?y.removeAttribute("maxLength"):(Y.on(y,"keydown",ee.keydownEvent),Y.on(y,"keypress",ee.keypressEvent)),Y.on(y,"input",ee.inputFallBackEvent),Y.on(y,"beforeinput",ee.beforeInputEvent)),Y.on(y,"setvalue",ee.setValueEvent),m=L().join(""),""!==y.inputmask._valueGet(!0)||!1===f.clearMaskOnLostFocus||n.activeElement===y)){var r=e.isFunction(f.onBeforeMask)&&f.onBeforeMask.call(b,y.inputmask._valueGet(!0),f)||y.inputmask._valueGet(!0);""!==r&&te(y,!0,!1,r.split(""));var s=F().slice();m=s.join(""),!1===oe(s)&&f.clearIncomplete&&O(),f.clearMaskOnLostFocus&&n.activeElement!==y&&(-1===S()?s=[]:re(s)),(!1===f.clearMaskOnLostFocus||f.showMaskOnFocus&&n.activeElement===y||""!==y.inputmask._valueGet(!0))&&z(y,s),n.activeElement===y&&ie(y,W(S()))}}(y);break;case"format":return J=(e.isFunction(f.onBeforeMask)&&f.onBeforeMask.call(b,a.value,f)||a.value).split(""),te.call(this,i,!0,!1,J),a.metadata?{value:P?F().slice().reverse().join(""):F().join(""),metadata:h.call(this,{action:"getmetadata"},u,f)}:P?F().slice().reverse().join(""):F().join("");case"isValid":a.value?(J=a.value.split(""),te.call(this,i,!0,!0,J)):a.value=F().join("");for(var ue=F(),fe=ae(),pe=ue.length-1;pe>fe&&!q(pe);pe--);return ue.splice(fe,pe+1-fe),oe(ue)&&a.value===F().join("");case"getemptymask":return L().join("");case"remove":if(y&&y.inputmask)e.data(y,"_inputmask_opts",null),d=e(y),y.inputmask._valueSet(f.autoUnmask?ne(y):y.inputmask._valueGet(!0)),Y.off(y),y.inputmask.colorMask&&((k=y.inputmask.colorMask).removeChild(y),k.parentNode.insertBefore(y,k),k.parentNode.removeChild(k)),Object.getOwnPropertyDescriptor&&Object.getPrototypeOf?Object.getOwnPropertyDescriptor(Object.getPrototypeOf(y),"value")&&y.inputmask.__valueGet&&Object.defineProperty(y,"value",{get:y.inputmask.__valueGet,set:y.inputmask.__valueSet,configurable:!0}):n.__lookupGetter__&&y.__lookupGetter__("value")&&y.inputmask.__valueGet&&(y.__defineGetter__("value",y.inputmask.__valueGet),y.__defineSetter__("value",y.inputmask.__valueSet)),y.inputmask=i;return y;case"getmetadata":if(e.isArray(u.metadata)){var he=A(!0,0,!1).join("");return e.each(u.metadata,function(e,t){if(t.mask===he)return he=t,!1}),he}return u.metadata}}return c.prototype={dataAttribute:"data-inputmask",defaults:{placeholder:"_",optionalmarker:["[","]"],quantifiermarker:["{","}"],groupmarker:["(",")"],alternatormarker:"|",escapeChar:"\\",mask:null,regex:null,oncomplete:e.noop,onincomplete:e.noop,oncleared:e.noop,repeat:0,greedy:!1,autoUnmask:!1,removeMaskOnSubmit:!1,clearMaskOnLostFocus:!0,insertMode:!0,clearIncomplete:!1,alias:null,onKeyDown:e.noop,onBeforeMask:null,onBeforePaste:function(t,n){return e.isFunction(n.onBeforeMask)?n.onBeforeMask.call(this,t,n):t},onBeforeWrite:null,onUnMask:null,showMaskOnFocus:!0,showMaskOnHover:!0,onKeyValidation:e.noop,skipOptionalPartCharacter:" ",numericInput:!1,rightAlign:!1,undoOnEscape:!0,radixPoint:"",_radixDance:!1,groupSeparator:"",keepStatic:null,positionCaretOnTab:!0,tabThrough:!1,supportsInputType:["text","tel","url","password","search"],ignorables:[8,9,13,19,27,33,34,35,36,37,38,39,40,45,46,93,112,113,114,115,116,117,118,119,120,121,122,123,0,229],isComplete:null,preValidation:null,postValidation:null,staticDefinitionSymbol:i,jitMasking:!1,nullable:!0,inputEventOnly:!1,noValuePatching:!1,positionCaretOnClick:"lvp",casing:null,inputmode:"verbatim",colorMask:!1,disablePredictiveText:!1,importDataAttributes:!0,shiftPositions:!0},definitions:{9:{validator:"[0-91-9]",definitionSymbol:"*"},a:{validator:"[A-Za-zА-яЁёÀ-ÿµ]",definitionSymbol:"*"},"?":{validator:".",cardinality:1,definitionSymbol:"*"},"*":{validator:"[0-91-9A-Za-zА-яЁёÀ-ÿµ]"}},aliases:{},masksCache:{},mask:function(a){var r=this;return"string"==typeof a&&(a=n.getElementById(a)||n.querySelectorAll(a)),a=a.nodeName?[a]:a,e.each(a,function(n,a){var o=e.extend(!0,{},r.opts);if(function(n,a,r,o){if(!0===a.importDataAttributes){var s,l,c,f,p=function(e,a){null!==(a=a!==i?a:n.getAttribute(o+"-"+e))&&("string"==typeof a&&(0===e.indexOf("on")?a=t[a]:"false"===a?a=!1:"true"===a&&(a=!0)),r[e]=a)},h=n.getAttribute(o);if(h&&""!==h&&(h=h.replace(/'/g,'"'),l=JSON.parse("{"+h+"}")),l)for(f in c=i,l)if("alias"===f.toLowerCase()){c=l[f];break}for(s in p("alias",c),r.alias&&u(r.alias,r,a),a){if(l)for(f in c=i,l)if(f.toLowerCase()===s.toLowerCase()){c=l[f];break}p(s,c)}}return e.extend(!0,a,r),("rtl"===n.dir||a.rightAlign)&&(n.style.textAlign="right"),("rtl"===n.dir||a.numericInput)&&(n.dir="ltr",n.removeAttribute("dir"),a.isRTL=!0),Object.keys(r).length}(a,o,e.extend(!0,{},r.userOptions),r.dataAttribute)){var s=f(o,r.noMasksCache);s!==i&&(a.inputmask!==i&&(a.inputmask.opts.autoUnmask=a.inputmask.opts.autoUnmask,a.inputmask.remove()),a.inputmask=new c(i,i,!0),a.inputmask.opts=o,a.inputmask.noMasksCache=r.noMasksCache,a.inputmask.userOptions=e.extend(!0,{},r.userOptions),a.inputmask.isRTL=o.isRTL||o.numericInput,a.inputmask.el=a,a.inputmask.maskset=s,e.data(a,"_inputmask_opts",o),h.call(a.inputmask,{action:"mask"}))}}),a&&a[0]&&a[0].inputmask||this},option:function(t,n){return"string"==typeof t?this.opts[t]:"object"===_typeof(t)?(e.extend(this.userOptions,t),this.el&&!0!==n&&this.mask(this.el),this):void 0},unmaskedvalue:function(e){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"unmaskedvalue",value:e})},remove:function(){return h.call(this,{action:"remove"})},getemptymask:function(){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"getemptymask"})},hasMaskedValue:function(){return!this.opts.autoUnmask},isComplete:function(){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"isComplete"})},getmetadata:function(){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"getmetadata"})},isValid:function(e){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"isValid",value:e})},format:function(e,t){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"format",value:e,metadata:t})},setValue:function(t){this.el&&e(this.el).trigger("setvalue",[t])},analyseMask:function(t,n,a){var r,o,s,l,u,f,p=/(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?(?:\|[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g,h=/\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,m=!1,d=new g,v=[],k=[];function g(e,t,n,i){this.matches=[],this.openGroup=e||!1,this.alternatorGroup=!1,this.isGroup=e||!1,this.isOptional=t||!1,this.isQuantifier=n||!1,this.isAlternator=i||!1,this.quantifier={min:1,max:1}}function b(t,r,o){o=o!==i?o:t.matches.length;var s=t.matches[o-1];if(n)0===r.indexOf("[")||m&&/\\d|\\s|\\w]/i.test(r)||"."===r?t.matches.splice(o++,0,{fn:new RegExp(r,a.casing?"i":""),optionality:!1,newBlockMarker:s===i?"master":s.def!==r,casing:null,def:r,placeholder:i,nativeDef:r}):(m&&(r=r[r.length-1]),e.each(r.split(""),function(e,n){s=t.matches[o-1],t.matches.splice(o++,0,{fn:null,optionality:!1,newBlockMarker:s===i?"master":s.def!==n&&null!==s.fn,casing:null,def:a.staticDefinitionSymbol||n,placeholder:a.staticDefinitionSymbol!==i?n:i,nativeDef:(m?"'":"")+n})})),m=!1;else{var l=(a.definitions?a.definitions[r]:i)||c.prototype.definitions[r];if(l&&!m){for(var u=l.prevalidator,f=u?u.length:0,p=1;p=p?u[p-1]:[],d=h.validator,v=h.cardinality;t.matches.splice(o++,0,{fn:d?"string"==typeof d?new RegExp(d,a.casing?"i":""):new function(){this.test=d}:new RegExp("."),cardinality:v||1,optionality:t.isOptional,newBlockMarker:s===i||s.def!==(l.definitionSymbol||r),casing:l.casing,def:l.definitionSymbol||r,placeholder:l.placeholder,nativeDef:r}),s=t.matches[o-1]}t.matches.splice(o++,0,{fn:l.validator?"string"==typeof l.validator?new RegExp(l.validator,a.casing?"i":""):new function(){this.test=l.validator}:new RegExp("."),optionality:!1,newBlockMarker:s===i?"master":s.def!==(l.definitionSymbol||r),casing:l.casing,def:l.definitionSymbol||r,placeholder:l.placeholder,nativeDef:r})}else t.matches.splice(o++,0,{fn:null,optionality:!1,newBlockMarker:s===i?"master":s.def!==r&&null!==s.fn,casing:null,def:a.staticDefinitionSymbol||r,placeholder:a.staticDefinitionSymbol!==i?r:i,nativeDef:(m?"'":"")+r}),m=!1}}function y(){if(v.length>0){if(b(l=v[v.length-1],o),l.isAlternator){u=v.pop();for(var e=0;e0?(l=v[v.length-1]).matches.push(u):d.matches.push(u)}}else b(d,o)}function P(e){var t=new g(!0);return t.openGroup=!1,t.matches=e,t}for(n&&(a.optionalmarker[0]=i,a.optionalmarker[1]=i);r=n?h.exec(t):p.exec(t);){if(o=r[0],n)switch(o.charAt(0)){case"?":o="{0,1}";break;case"+":case"*":o="{"+o+"}"}if(m)y();else switch(o.charAt(0)){case"(?=":case"(?!":case"(?<=":case"(?0){if((l=v[v.length-1]).matches.push(s),l.isAlternator){u=v.pop();for(var E=0;E0?(l=v[v.length-1]).matches.push(u):d.matches.push(u)}}else d.matches.push(s);else y();break;case a.optionalmarker[0]:v.push(new g(!1,!0));break;case a.groupmarker[0]:v.push(new g(!0));break;case a.quantifiermarker[0]:var C=new g(!1,!1,!0),x=(o=o.replace(/[{}]/g,"")).split("|"),_=x[0].split(","),A=isNaN(_[0])?_[0]:parseInt(_[0]),w=1===_.length?A:isNaN(_[1])?_[1]:parseInt(_[1]);"*"!==A&&"+"!==A||(A="*"===w?0:1),C.quantifier={min:A,max:w,jit:x[1]};var O=v.length>0?v[v.length-1].matches:d.matches;if((r=O.pop()).isAlternator){O.push(r),O=r.matches;var S=new g(!0),j=O.pop();O.push(S),O=S.matches,r=j}r.isGroup||(r=P([r])),O.push(r),O.push(C);break;case a.alternatormarker:var M=function(e){var t=e.pop();return t.isQuantifier&&(t=P([e.pop(),t])),t};if(v.length>0){var D=(l=v[v.length-1]).matches[l.matches.length-1];f=l.openGroup&&(D.matches===i||!1===D.isGroup&&!1===D.isAlternator)?v.pop():M(l.matches)}else f=M(d.matches);if(f.isAlternator)v.push(f);else if(f.alternatorGroup?(u=v.pop(),f.alternatorGroup=!1):u=new g(!1,!1,!1,!0),u.matches.push(f),v.push(u),f.openGroup){f.openGroup=!1;var G=new g(!0);G.alternatorGroup=!0,v.push(G)}break;default:y()}}for(;v.length>0;)s=v.pop(),d.matches.push(s);return d.matches.length>0&&(!function t(r){r&&r.matches&&e.each(r.matches,function(e,o){var s=r.matches[e+1];(s===i||s.matches===i||!1===s.isQuantifier)&&o&&o.isGroup&&(o.isGroup=!1,n||(b(o,a.groupmarker[0],0),!0!==o.openGroup&&b(o,a.groupmarker[1]))),t(o)})}(d),k.push(d)),(a.numericInput||a.isRTL)&&function e(t){for(var n in t.matches=t.matches.reverse(),t.matches)if(t.matches.hasOwnProperty(n)){var r=parseInt(n);if(t.matches[n].isQuantifier&&t.matches[r+1]&&t.matches[r+1].isGroup){var o=t.matches[n];t.matches.splice(n,1),t.matches.splice(r+1,0,o)}t.matches[n].matches!==i?t.matches[n]=e(t.matches[n]):t.matches[n]=((s=t.matches[n])===a.optionalmarker[0]?s=a.optionalmarker[1]:s===a.optionalmarker[1]?s=a.optionalmarker[0]:s===a.groupmarker[0]?s=a.groupmarker[1]:s===a.groupmarker[1]&&(s=a.groupmarker[0]),s)}var s;return t}(k[0]),k}},c.extendDefaults=function(t){e.extend(!0,c.prototype.defaults,t)},c.extendDefinitions=function(t){e.extend(!0,c.prototype.definitions,t)},c.extendAliases=function(t){e.extend(!0,c.prototype.aliases,t)},c.format=function(e,t,n){return c(t).format(e,n)},c.unmask=function(e,t){return c(t).unmaskedvalue(e)},c.isValid=function(e,t){return c(t).isValid(e)},c.remove=function(t){"string"==typeof t&&(t=n.getElementById(t)||n.querySelectorAll(t)),t=t.nodeName?[t]:t,e.each(t,function(e,t){t.inputmask&&t.inputmask.remove()})},c.setValue=function(t,i){"string"==typeof t&&(t=n.getElementById(t)||n.querySelectorAll(t)),t=t.nodeName?[t]:t,e.each(t,function(t,n){n.inputmask?n.inputmask.setValue(i):e(n).trigger("setvalue",[i])})},c.escapeRegex=function(e){return e.replace(new RegExp("(\\"+["/",".","*","+","?","|","(",")","[","]","{","}","\\","$","^"].join("|\\")+")","gim"),"\\$1")},c.keyCode={BACKSPACE:8,BACKSPACE_SAFARI:127,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,RIGHT:39,SPACE:32,TAB:9,UP:38,X:88,CONTROL:17},c.dependencyLib=e,c}Object.defineProperty(exports,"__esModule",{value:!0}),exports.factory=factory; +"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function factory(e,t,n,i){var a=navigator.userAgent,r=a.indexOf("MSIE ")>0||a.indexOf("Trident/")>0,o=p("touchstart"),s=/iemobile/i.test(a),l=/iphone/i.test(a)&&!s;function c(t,n,a){if(!(this instanceof c))return new c(t,n,a);this.el=i,this.events={},this.maskset=i,this.refreshValue=!1,!0!==a&&(e.isPlainObject(t)?n=t:(n=n||{},t&&(n.alias=t)),this.opts=e.extend(!0,{},this.defaults,n),this.noMasksCache=n&&n.definitions!==i,this.userOptions=n||{},this.isRTL=this.opts.numericInput,u(this.opts.alias,n,this.opts))}function u(t,n,a){var r=c.prototype.aliases[t];return r?(r.alias&&u(r.alias,i,a),e.extend(!0,a,r),e.extend(!0,a,n),!0):(null===a.mask&&(a.mask=t),!1)}function f(t,n){function a(t,a,r){var o=!1;if(null!==t&&""!==t||((o=null!==r.regex)?t=(t=r.regex).replace(/^(\^)(.*)(\$)$/,"$2"):(o=!0,t=".*")),1===t.length&&!1===r.greedy&&0!==r.repeat&&(r.placeholder=""),r.repeat>0||"*"===r.repeat||"+"===r.repeat){var s="*"===r.repeat?0:"+"===r.repeat?1:r.repeat;t=r.groupmarker[0]+t+r.groupmarker[1]+r.quantifiermarker[0]+s+","+r.repeat+r.quantifiermarker[1]}var l,u=o?"regex_"+r.regex:r.numericInput?t.split("").reverse().join(""):t;return c.prototype.masksCache[u]===i||!0===n?(l={mask:t,maskToken:c.prototype.analyseMask(t,o,r),validPositions:{},_buffer:i,buffer:i,tests:{},excludes:{},metadata:a,maskLength:i,jitOffset:{}},!0!==n&&(c.prototype.masksCache[u]=l,l=e.extend(!0,{},c.prototype.masksCache[u]))):l=e.extend(!0,{},c.prototype.masksCache[u]),l}if(e.isFunction(t.mask)&&(t.mask=t.mask(t)),e.isArray(t.mask)){if(t.mask.length>1){if(null===t.keepStatic){t.keepStatic="auto";for(var r=0;r1&&(o+=t.groupmarker[1]+t.alternatormarker+t.groupmarker[0]),a.mask===i||e.isFunction(a.mask)?o+=a:o+=a.mask}),a(o+=t.groupmarker[1],t.mask,t)}t.mask=t.mask.pop()}return t.mask&&t.mask.mask!==i&&!e.isFunction(t.mask.mask)?a(t.mask.mask,t.mask,t):a(t.mask,t.mask,t)}function p(e){var t=n.createElement("input"),i="on"+e,a=i in t;return a||(t.setAttribute(i,"return;"),a="function"==typeof t[i]),t=null,a}function h(a,u,f){u=u||this.maskset,f=f||this.opts;var m,d,v,k,g,b=this,y=this.el,P=this.isRTL,E=!1,C=!1,x=!1,_=!1;function A(e,t,n,a,r){var o=f.greedy;r&&(f.greedy=!1),t=t||0;var s,l,c,u=[],p=0;S();do{if(!0===e&&w().validPositions[p])l=(c=r&&!0===w().validPositions[p].match.optionality&&w().validPositions[p+1]===i&&(!0===w().validPositions[p].generatedInput||w().validPositions[p].input==f.skipOptionalPartCharacter&&p>0)?D(p,I(p,s,p-1)):w().validPositions[p]).match,s=c.locator.slice(),u.push(!0===n?c.input:!1===n?l.nativeDef:X(p,l));else{l=(c=G(p,s,p-1)).match,s=c.locator.slice();var h=!0!==a&&(!1!==f.jitMasking?f.jitMasking:l.jit);(!1===h||h===i||"number"==typeof h&&isFinite(h)&&h>p)&&u.push(!1===n?l.nativeDef:X(p,l))}"auto"===f.keepStatic&&l.newBlockMarker&&null!==l.fn&&(f.keepStatic=p-1),p++}while((v===i||pp);return""===u[u.length-1]&&u.pop(),!1===n&&w().maskLength!==i||(w().maskLength=p-1),f.greedy=o,u}function w(){return u}function O(e){var t=w();t.buffer=i,!0!==e&&(t.validPositions={},t.p=0)}function S(e,t,n){var a=-1,r=-1,o=n||w().validPositions;for(var s in e===i&&(e=-1),o){var l=parseInt(s);o[l]&&(t||!0!==o[l].generatedInput)&&(l<=e&&(a=l),l>=e&&(r=l))}return-1===a||a==e?r:-1==r?a:e-a0&&(t=t.split(",")[0]),t!==i?t.toString():""}function M(e,t){var n=(e.alternation!=i?e.mloc[j(e)]:e.locator).join("");if(""!==n)for(;n.length0?e-1:0)),s=0;s500&&d!==i)throw"Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. "+w().mask;if(s===t&&o.matches===i)return c.push({match:o,locator:l.reverse(),cd:p,mloc:{}}),!0;if(o.matches!==i){if(o.isGroup&&d!==o){if(o=m(n.matches[e.inArray(o,n.matches)+1],l,d))return!0}else if(o.isOptional){var y=o;if(o=h(o,a,l,d)){if(e.each(c,function(e,t){t.match.optionality=!0}),r=c[c.length-1].match,d!==i||!v(r,y))return!0;u=!0,s=t}}else if(o.isAlternator){var P,E=o,C=[],x=c.slice(),_=l.length,A=a.length>0?a.shift():-1;if(-1===A||"string"==typeof A){var O,S=s,j=a.slice(),M=[];if("string"==typeof A)M=A.split(",");else for(O=0;O=f.keepStatic)&&(M=M.slice(0,1));for(var B=!1,I=0;I0,o=C.length>0,a=j.slice()}else o=m(E.matches[A]||n.matches[A],[A].concat(l),d);if(o)return!0}else if(o.isQuantifier&&d!==n.matches[e.inArray(o,n.matches)-1])for(var V=o,H=a.length>0?a.shift():0;H<(isNaN(V.quantifier.max)?H+1:V.quantifier.max)&&s<=t;H++){var U=n.matches[e.inArray(V,n.matches)-1];if(o=m(U,[H].concat(l),U)){if((r=c[c.length-1].match).optionalQuantifier=H>=V.quantifier.min,r.jit=(H||1)*U.matches.indexOf(r)>=V.quantifier.jit,r.optionalQuantifier&&v(r,U)){u=!0,s=t;break}return r.jit&&(w().jitOffset[t]=U.matches.indexOf(r)),!0}}else if(o=h(o,a,l,d))return!0}else s++;var Q,q}for(var d=a.length>0?a.shift():0;dt)break}}if(t>-1){if(n===i){for(var m,d=t-1;(m=w().validPositions[d]||w().tests[d])===i&&d>-1;)d--;m!==i&&d>-1&&(l=function(t,n){var a=[];return e.isArray(n)||(n=[n]),n.length>0&&(n[0].alternation===i?0===(a=D(t,n.slice()).locator.slice()).length&&(a=n[0].locator.slice()):e.each(n,function(e,t){if(""!==t.def)if(0===a.length)a=t.locator.slice();else for(var n=0;nt)break}}return(0===c.length||u)&&c.push({match:{fn:null,optionality:!1,casing:null,def:"",placeholder:""},locator:[],mloc:{},cd:p}),n!==i&&w().tests[t]?e.extend(!0,[],c):(w().tests[t]=e.extend(!0,[],c),w().tests[t])}function L(){return w()._buffer===i&&(w()._buffer=A(!1,1),w().buffer===i&&(w().buffer=w()._buffer.slice())),w()._buffer}function F(e){return w().buffer!==i&&!0!==e||(w().buffer=A(!0,S(),!0),w()._buffer===i&&(w()._buffer=w().buffer.slice())),w().buffer}function N(e,t,n){var a,r;if(!0===e)O(),e=0,t=n.length;else for(a=e;a=0;v--)if((c=w().validPositions[v])&&c.alternation!==i){if(u&&u.locator[c.alternation]!==c.locator[c.alternation])break;s=v,l=w().validPositions[s].alternation,u=c}if(l!==i){h=parseInt(s),w().excludes[h]=w().excludes[h]||[],!0!==t&&w().excludes[h].push(j(u));var k=[],g=0;for(f=h;f0;){var P=y.shift();if(!(d=H(S(i,!0)+1,P,!1,r,!0)))break}if(d&&n!==i){var E=S(t)+1;for(f=h;fE?E:t,n,a,r,!0)}if(d)break;if(O(),u=T(h),w().validPositions=e.extend(!0,{},m),!w().excludes[h]){d=V(t,n,a,r,h-1);break}var C=j(u);if(-1!==w().excludes[h].indexOf(C)){d=V(t,n,a,r,h-1);break}for(w().excludes[h].push(C),f=h;f1||e.begin-e.end==1:e.end-e.begin>1||e.end-e.begin==1}a=!0===a;var c=t;function u(n,a,o){var s=!1;return e.each(I(n),function(c,u){var p=u.match;if(F(!0),!1!==(s=null!=p.fn?p.fn.test(a,w(),n,o,f,l(t)):(a===p.def||a===f.skipOptionalPartCharacter)&&""!==p.def&&{c:X(n,p,!0)||p.def,pos:n})){var h=s.c!==i?s.c:a,m=n;return h=h===f.skipOptionalPartCharacter&&null===p.fn?X(n,p,!0)||p.def:h,s.remove!==i&&(e.isArray(s.remove)||(s.remove=[s.remove]),e.each(s.remove.sort(function(e,t){return t-e}),function(e,t){Q({begin:t,end:t+1})})),s.insert!==i&&(e.isArray(s.insert)||(s.insert=[s.insert]),e.each(s.insert.sort(function(e,t){return e-t}),function(e,t){H(t.pos,t.c,!0,r)})),!0!==s&&s.pos!==i&&s.pos!==n&&(m=s.pos),!0!==s&&s.pos===i&&s.c===i?!1:(Q(t,e.extend({},u,{input:R(h,p,m)}),r,m)||(s=!1),!1)}}),s}t.begin!==i&&(c=P?t.end:t.begin);var p=!0,h=e.extend(!0,{},w().validPositions);if(e.isFunction(f.preValidation)&&!a&&!0!==r&&!0!==s&&(p=f.preValidation(F(),c,n,l(t),f,w())),!0===p){if(U(i,c,!0),(v===i||c0&&!w().validPositions[t];t--);for(var o=t;oe+1?t[e+1]&&null===t[e+1].match.fn&&t[e+1]:t[e+1];return r&&o}return!1}var s=t.begin!==i?t.begin:t,l=t.end!==i?t.end:t;if(t.begin>t.end&&(s=t.end,l=t.begin),r=r!==i?r:s,s!==l||f.insertMode&&w().validPositions[r]!==i&&a===i){var c=e.extend(!0,{},w().validPositions),u=S(i,!0);for(w().p=s,v=u;v>=s;v--)w().validPositions[v]&&"+"===w().validPositions[v].match.nativeDef&&(f.isNegative=!1),delete w().validPositions[v];var p=!0,h=r,m=(w().validPositions,!1),d=h,v=h;for(n&&(w().validPositions[r]=e.extend(!0,{},n),d++,h++,s=l||v>=s&&!0!==k.generatedInput&&o(v,c,{begin:s,end:l}))){for(;""!==T(d).match.def;){if(!1===m&&c[d]&&c[d].match.nativeDef===k.match.nativeDef)w().validPositions[d]=e.extend(!0,{},c[d]),w().validPositions[d].input=k.input,U(i,d,!0),h=d+1,p=!0;else if(f.shiftPositions&&B(d,k.match.def)){var g=H(d,k.input,!0,!0);p=!1!==g,h=g.caret||g.insert?S():d+1,m=!0}else p=!0===k.generatedInput||k.input===f.radixPoint&&!0===f.numericInput;if(p)break;if(!p&&d>l&&q(d,!0)&&(null!==k.match.fn||d>w().maskLength))break;d++}""==T(d).match.def&&(p=!1),d=h}if(!p)break}if(!p)return w().validPositions=e.extend(!0,{},c),O(!0),!1}else n&&(w().validPositions[r]=e.extend(!0,{},n));return O(!0),!0}function q(e,t){var n=G(e).match;if(""===n.def&&(n=T(e).match),null!=n.fn)return n.fn;if(!0!==t&&e>-1){var i=I(e);return i.length>1+(""===i[i.length-1].match.def?1:0)}return!1}function W(e,t){for(var n=e+1;""!==T(n).match.def&&(!0===t&&(!0!==T(n).match.newBlockMarker||!q(n))||!0!==t&&!q(n));)n++;return n}function $(e,t){var n,i=e;if(i<=0)return 0;for(;--i>0&&(!0===t&&!0!==T(i).match.newBlockMarker||!0!==t&&!q(i)&&((n=I(i)).length<2||2===n.length&&""===n[1].match.def)););return i}function z(t,n,a,r,o){if(r&&e.isFunction(f.onBeforeWrite)){var s=f.onBeforeWrite.call(b,r,n,a,f);if(s){if(s.refreshFromBuffer){var l=s.refreshFromBuffer;N(!0===l?l:l.start,l.end,s.buffer||n),n=F(!0)}a!==i&&(a=s.caret!==i?s.caret:a)}}if(t!==i&&(t.inputmask._valueSet(n.join("")),a===i||r!==i&&"blur"===r.type?ce(t,a,0===n.length):ie(t,a),!0===o)){var c=e(t),u=t.inputmask._valueGet();C=!0,c.trigger("input"),setTimeout(function(){u===L().join("")?c.trigger("cleared"):!0===oe(n)&&c.trigger("complete")},0)}}function X(t,n,a){if((n=n||T(t).match).placeholder!==i||!0===a)return e.isFunction(n.placeholder)?n.placeholder(f):n.placeholder;if(null===n.fn){if(t>-1&&w().validPositions[t]===i){var r,o=I(t),s=[];if(o.length>1+(""===o[o.length-1].match.def?1:0))for(var l=0;l1&&/[0-9a-bA-Z]/.test(s[0].match.def)))return f.placeholder.charAt(t%f.placeholder.length)}return n.def}return f.placeholder.charAt(t%f.placeholder.length)}function Z(e,t){if(r){if(e.inputmask._valueGet()!==t){var n=F().slice(),i=e.inputmask._valueGet();if(i!==t){var a=S();-1===a&&i===L().join("")?n=[]:-1!==a&&re(n),z(e,n)}}}else e.placeholder!==t&&(e.placeholder=t,""===e.placeholder&&e.removeAttribute("placeholder"))}var J,Y={on:function(t,n,a){var r=function(t){var n=this;if(n.inputmask===i&&"FORM"!==this.nodeName){var r=e.data(n,"_inputmask_opts");r?new c(r).mask(n):Y.off(n)}else{if("setvalue"===t.type||"FORM"===this.nodeName||!(n.disabled||n.readOnly&&!("keydown"===t.type&&t.ctrlKey&&67===t.keyCode||!1===f.tabThrough&&t.keyCode===c.keyCode.TAB))){switch(t.type){case"input":if(!0===C)return C=!1,t.preventDefault();if(o){var u=arguments;return setTimeout(function(){a.apply(n,u),ie(n,n.inputmask.caretPos,i,!0)},0),!1}break;case"keydown":E=!1,C=!1;break;case"keypress":if(!0===E)return t.preventDefault();E=!0;break;case"click":if(s||l){u=arguments;return setTimeout(function(){a.apply(n,u)},0),!1}}var p=a.apply(n,arguments);return!1===p&&(t.preventDefault(),t.stopPropagation()),p}t.preventDefault()}};t.inputmask.events[n]=t.inputmask.events[n]||[],t.inputmask.events[n].push(r),-1!==e.inArray(n,["submit","reset"])?null!==t.form&&e(t.form).on(n,r):e(t).on(n,r)},off:function(t,n){var i;t.inputmask&&t.inputmask.events&&(n?(i=[])[n]=t.inputmask.events[n]:i=t.inputmask.events,e.each(i,function(n,i){for(;i.length>0;){var a=i.pop();-1!==e.inArray(n,["submit","reset"])?null!==t.form&&e(t.form).off(n,a):e(t).off(n,a)}delete t.inputmask.events[n]}))}},ee={keydownEvent:function(t){var n=e(this),i=t.keyCode,a=ie(this),r={begin:this.selectionStart,end:this.selectionEnd},o=this.value;if(i===c.keyCode.BACKSPACE||i===c.keyCode.DELETE||l&&i===c.keyCode.BACKSPACE_SAFARI||(t.ctrlKey||t.metaKey)&&i===c.keyCode.X&&!p("cut"))t.preventDefault(),(t.metaKey||t.ctrlKey)&&(a.begin=0),se(this,i,a),a.end-a.begin==this.value.length&&O(!1),z(this,F(!0),w().p,t,this.inputmask._valueGet()!==F().join(""));else if(i===c.keyCode.END||i===c.keyCode.PAGE_DOWN){t.preventDefault();var s=W(S());ie(this,t.shiftKey?a.begin:s,s,!0)}else i===c.keyCode.HOME&&!t.shiftKey||i===c.keyCode.PAGE_UP?(t.preventDefault(),ie(this,0,t.shiftKey?a.begin:0,!0)):(f.undoOnEscape&&i===c.keyCode.ESCAPE||90===i&&t.ctrlKey)&&!0!==t.altKey?(te(this,!0,!1,m.split("")),n.trigger("click")):i!==c.keyCode.INSERT||t.shiftKey||t.ctrlKey?!0===f.tabThrough&&i===c.keyCode.TAB&&(!0===t.shiftKey?(null===T(a.begin).match.fn&&(a.begin=W(a.begin)),a.end=$(a.begin,!0),a.begin=$(a.end,!0)):(a.begin=W(a.begin,!0),a.end=W(a.begin,!0),a.endr.length?-1:0,l=i.substr(0,a.begin),u=i.substr(a.begin),p=r.substr(0,a.begin+o),h=r.substr(a.begin+o),m=a,d="",v=!1;if(l!==p){var k,g=(v=l.length>=p.length)?l.length:p.length;for(k=0;l.charAt(k)===p.charAt(k)&&kh.length?d+=u.slice(0,1):u.length0)e.each(d.split(""),function(t,i){var a=new e.Event("keypress");a.which=i.charCodeAt(0),x=!1,ee.keypressEvent.call(n,a)});else{m.begin===m.end-1&&(m.begin=$(m.begin+1),m.begin===m.end-1?ie(n,m.begin):ie(n,m.begin,m.end));var b=new e.Event("keydown");b.keyCode=f.numericInput?c.keyCode.BACKSPACE:c.keyCode.DELETE,ee.keydownEvent.call(n,b)}t.preventDefault()}}},beforeInputEvent:function(t){if(t.cancelable){var n=this;switch(t.inputType){case"insertText":return e.each(t.data.split(""),function(t,i){var a=new e.Event("keypress");a.which=i.charCodeAt(0),x=!1,ee.keypressEvent.call(n,a)}),t.preventDefault();case"deleteContentBackward":return(i=new e.Event("keydown")).keyCode=c.keyCode.BACKSPACE,ee.keydownEvent.call(n,i),t.preventDefault();case"deleteContentForward":var i;return(i=new e.Event("keydown")).keyCode=c.keyCode.DELETE,ee.keydownEvent.call(n,i),t.preventDefault()}}},setValueEvent:function(t){this.inputmask.refreshValue=!1;var n=(n=t&&t.detail?t.detail[0]:arguments[1])||this.inputmask._valueGet(!0);e.isFunction(f.onBeforeMask)&&(n=f.onBeforeMask.call(b,n,f)||n),te(this,!0,!1,n=n.split("")),m=F().join(""),(f.clearMaskOnLostFocus||f.clearIncomplete)&&this.inputmask._valueGet()===L().join("")&&this.inputmask._valueSet("")},focusEvent:function(e){var t=this.inputmask._valueGet();f.showMaskOnFocus&&(t!==F().join("")?z(this,F(),W(S())):!1===_&&ie(this,W(S()))),!0===f.positionCaretOnTab&&!1===_&&ee.clickEvent.apply(this,[e,!0]),m=F().join("")},mouseleaveEvent:function(e){_=!1,f.clearMaskOnLostFocus&&n.activeElement!==this&&Z(this,g)},clickEvent:function(t,a){var r=this;setTimeout(function(){if(n.activeElement===r){var t=ie(r);if(a&&(P?t.end=t.begin:t.begin=t.end),t.begin===t.end)switch(f.positionCaretOnClick){case"none":break;case"select":ie(r,0,F().length);break;case"ignore":ie(r,W(S()));break;case"radixFocus":if(function(t){if(""!==f.radixPoint){var n=w().validPositions;if(n[t]===i||n[t].input===X(t)){if(t=m||s===c)&&(c=m)}ie(r,c)}}}},0)},cutEvent:function(i){e(this);var a=ie(this),r=i.originalEvent||i,o=t.clipboardData||r.clipboardData,s=P?F().slice(a.end,a.begin):F().slice(a.begin,a.end);o.setData("text",P?s.reverse().join(""):s.join("")),n.execCommand&&n.execCommand("copy"),(i.metaKey||i.ctrlKey)&&(a.begin=0),se(this,c.keyCode.DELETE,a),a.end-a.begin==this.value.length&&O(!1),z(this,F(),w().p,i,m!==F().join(""))},blurEvent:function(t){var n=e(this);if(this.inputmask){Z(this,g);var a=this.inputmask._valueGet(),r=F().slice();""===a&&k===i||(f.clearMaskOnLostFocus&&(-1===S()&&a===L().join("")?r=[]:re(r)),!1===oe(r)&&(setTimeout(function(){n.trigger("incomplete")},0),f.clearIncomplete&&(O(),r=f.clearMaskOnLostFocus?[]:L().slice())),z(this,r,i,t)),m!==F().join("")&&(m=r.join(""),n.trigger("change"))}},mouseenterEvent:function(e){_=!0,n.activeElement!==this&&f.showMaskOnHover&&Z(this,(P?F().slice().reverse():F()).join(""))},submitEvent:function(e){m!==F().join("")&&d.trigger("change"),f.clearMaskOnLostFocus&&-1===S()&&y.inputmask._valueGet&&y.inputmask._valueGet()===L().join("")&&y.inputmask._valueSet(""),f.clearIncomplete&&!1===oe(F())&&y.inputmask._valueSet(""),f.removeMaskOnSubmit&&(y.inputmask._valueSet(y.inputmask.unmaskedvalue(),!0),setTimeout(function(){z(y,F())},0))},resetEvent:function(e){y.inputmask.refreshValue=!0,setTimeout(function(){d.trigger("setvalue")},0)}};function te(t,n,a,r,o){var s=this||t.inputmask,l=r.slice(),u="",p=-1,h=i;if(O(),a||!0===f.autoUnmask)p=W(p);else{var m=L().slice(0,W(-1)).join(""),d=l.join("").match(new RegExp("^"+c.escapeRegex(m),"g"));d&&d.length>0&&(l.splice(0,d.length*m.length),p=W(p))}-1===p?(w().p=W(p),p=0):w().p=p,s.caretPos={begin:p},e.each(l,function(n,r){if(r!==i)if(w().validPositions[n]===i&&l[n]===X(n)&&q(n,!0)&&!1===H(n,l[n],!0,i,i,!0))w().p++;else{var o=new e.Event("_checkval");o.which=r.charCodeAt(0),u+=r;var c=S(i,!0);!function(e,t){return-1!==A(!0,0,!1).slice(e,W(e)).join("").replace(/'/g,"").indexOf(t)&&!q(e)&&(T(e).match.nativeDef===t.charAt(0)||null===T(e).match.fn&&T(e).match.nativeDef==="'"+t.charAt(0)||" "===T(e).match.nativeDef&&(T(e+1).match.nativeDef===t.charAt(0)||null===T(e+1).match.fn&&T(e+1).match.nativeDef==="'"+t.charAt(0)))}(p,u)?(h=ee.keypressEvent.call(t,o,!0,!1,a,s.caretPos.begin))&&(p=s.caretPos.begin+1,u=""):h=ee.keypressEvent.call(t,o,!0,!1,a,c+1),h&&(z(i,F(),h.forwardPosition,o,!1),s.caretPos={begin:h.forwardPosition,end:h.forwardPosition})}}),n&&z(t,F(),h?h.forwardPosition:i,o||new e.Event("checkval"),o&&"input"===o.type)}function ne(t){if(t){if(t.inputmask===i)return t.value;t.inputmask&&t.inputmask.refreshValue&&ee.setValueEvent.call(t)}var n=[],a=w().validPositions;for(var r in a)a[r].match&&null!=a[r].match.fn&&n.push(a[r].input);var o=0===n.length?"":(P?n.reverse():n).join("");if(e.isFunction(f.onUnMask)){var s=(P?F().slice().reverse():F()).join("");o=f.onUnMask.call(b,s,o,f)}return o}function ie(a,r,o,s){function l(e){return!P||"number"!=typeof e||f.greedy&&""===f.placeholder||!y||(e=y.inputmask._valueGet().length-e),e}var c;if(r===i)return"selectionStart"in a?(r=a.selectionStart,o=a.selectionEnd):t.getSelection?(c=t.getSelection().getRangeAt(0)).commonAncestorContainer.parentNode!==a&&c.commonAncestorContainer!==a||(r=c.startOffset,o=c.endOffset):n.selection&&n.selection.createRange&&(o=(r=0-(c=n.selection.createRange()).duplicate().moveStart("character",-a.inputmask._valueGet().length))+c.text.length),{begin:s?r:l(r),end:s?o:l(o)};if(e.isArray(r)&&(o=P?r[0]:r[1],r=P?r[1]:r[0]),r.begin!==i&&(o=P?r.begin:r.end,r=P?r.end:r.begin),"number"==typeof r){r=s?r:l(r),o="number"==typeof(o=s?o:l(o))?o:r;var u=parseInt(((a.ownerDocument.defaultView||t).getComputedStyle?(a.ownerDocument.defaultView||t).getComputedStyle(a,null):a.currentStyle).fontSize)*o;if(a.scrollLeft=u>a.scrollWidth?u:0,a.inputmask.caretPos={begin:r,end:o},a===n.activeElement){if("selectionStart"in a)a.selectionStart=r,a.selectionEnd=o;else if(t.getSelection){if(c=n.createRange(),a.firstChild===i||null===a.firstChild){var p=n.createTextNode("");a.appendChild(p)}c.setStart(a.firstChild,rs&&(((a=l[n]).match.optionality||a.match.optionalQuantifier&&a.match.newBlockMarker||f&&(f!==l[n].locator[c.alternation]&&null!=a.match.fn||null===a.match.fn&&a.locator[c.alternation]&&K(a.locator[c.alternation].toString().split(","),f.toString().split(","))&&""!==I(n)[0].def))&&r[n]===X(n,a.match));n--)o--;return t?{l:o,def:l[o]?l[o].match:i}:o}function re(e){e.length=0;for(var t,n=A(!0,0,!0,i,!0);(t=n.shift())!==i;)e.push(t);return e}function oe(t){if(e.isFunction(f.isComplete))return f.isComplete(t,f);if("*"===f.repeat)return i;var n=!1,a=ae(!0),r=$(a.l);if(a.def===i||a.def.newBlockMarker||a.def.optionality||a.def.optionalQuantifier){n=!0;for(var o=0;o<=r;o++){var s=G(o).match;if(null!==s.fn&&w().validPositions[o]===i&&!0!==s.optionality&&!0!==s.optionalQuantifier||null===s.fn&&t[o]!==X(o,s)){n=!1;break}}}return n}function se(e,t,n,a,r){if((f.numericInput||P)&&(t===c.keyCode.BACKSPACE?t=c.keyCode.DELETE:t===c.keyCode.DELETE&&(t=c.keyCode.BACKSPACE),P)){var o=n.end;n.end=n.begin,n.begin=o}if(t===c.keyCode.BACKSPACE&&n.end-n.begin<1?(n.begin=$(n.begin),w().validPositions[n.begin]!==i&&w().validPositions[n.begin].input===f.groupSeparator&&n.begin--):t===c.keyCode.DELETE&&n.begin===n.end&&(n.end=q(n.end,!0)&&w().validPositions[n.end]&&w().validPositions[n.end].input!==f.radixPoint?n.end+1:W(n.end)+1,w().validPositions[n.begin]!==i&&w().validPositions[n.begin].input===f.groupSeparator&&n.end++),Q(n),!0!==a&&!1!==f.keepStatic||null!==f.regex){var s=V(!0);if(s){var l=s.caret!==i?s.caret:s.pos?W(s.pos.begin?s.pos.begin:s.pos):S(-1,!0);(t!==c.keyCode.DELETE||n.begin>l)&&n.begin}}var u=S(n.begin,!0);if(u=e){var u=e-c,f=r.offsetWidth-e;r.innerHTML=l.charAt(t),t=(u-=r.offsetWidth/3)",l.push(e)}else l.push(e);else c=!0,l.push(""+e)}if(k!==i){var h=F();if(t===i?t=ie(e):t.begin===i&&(t={begin:t,end:t}),!0!==a){var m=S();do{w().validPositions[u]?(o=w().validPositions[u],r=o.match,s=o.locator.slice(),p(h[u])):(o=G(u,s,u-1),r=o.match,s=o.locator.slice(),!1===f.jitMasking||uu?p(X(u,r)):c=!1),u++}while((v===i||uu||c);c&&p(),n.activeElement===e&&(l.splice(t.begin,0,t.begin===t.end||t.end>w().maskLength?'':''),l.splice(t.end+1,0,""))}var d=k.getElementsByTagName("div")[0];d.innerHTML=l.join(""),e.inputmask.positionColorMask(e,d)}}if(c.prototype.positionColorMask=function(e,t){e.style.left=t.offsetLeft+"px"},a!==i)switch(a.action){case"isComplete":return y=a.el,oe(F());case"unmaskedvalue":return y!==i&&a.value===i||(J=a.value,J=(e.isFunction(f.onBeforeMask)&&f.onBeforeMask.call(b,J,f)||J).split(""),te.call(this,i,!1,!1,J),e.isFunction(f.onBeforeWrite)&&f.onBeforeWrite.call(b,i,F(),0,f)),ne(y);case"mask":!function(t){Y.off(t);var a=function(t,a){var r=t.getAttribute("type"),o="INPUT"===t.tagName&&-1!==e.inArray(r,a.supportsInputType)||t.isContentEditable||"TEXTAREA"===t.tagName;if(!o)if("INPUT"===t.tagName){var s=n.createElement("input");s.setAttribute("type",r),o="text"===s.type,s=null}else o="partial";return!1!==o?function(t){var r,o;function s(){return this.inputmask?this.inputmask.opts.autoUnmask?this.inputmask.unmaskedvalue():-1!==S()||!0!==a.nullable?n.activeElement===this&&a.clearMaskOnLostFocus?(P?re(F().slice()).reverse():re(F().slice())).join(""):r.call(this):"":r.call(this)}function l(t){o.call(this,t),this.inputmask&&e(this).trigger("setvalue",[t])}if(!t.inputmask.__valueGet){if(!0!==a.noValuePatching){if(Object.getOwnPropertyDescriptor){"function"!=typeof Object.getPrototypeOf&&(Object.getPrototypeOf="object"===_typeof("test".__proto__)?function(e){return e.__proto__}:function(e){return e.constructor.prototype});var c=Object.getPrototypeOf?Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value"):i;c&&c.get&&c.set?(r=c.get,o=c.set,Object.defineProperty(t,"value",{get:s,set:l,configurable:!0})):"INPUT"!==t.tagName&&(r=function(){return this.textContent},o=function(e){this.textContent=e},Object.defineProperty(t,"value",{get:s,set:l,configurable:!0}))}else n.__lookupGetter__&&t.__lookupGetter__("value")&&(r=t.__lookupGetter__("value"),o=t.__lookupSetter__("value"),t.__defineGetter__("value",s),t.__defineSetter__("value",l));t.inputmask.__valueGet=r,t.inputmask.__valueSet=o}t.inputmask._valueGet=function(e){return P&&!0!==e?r.call(this.el).split("").reverse().join(""):r.call(this.el)},t.inputmask._valueSet=function(e,t){o.call(this.el,null===e||e===i?"":!0!==t&&P?e.split("").reverse().join(""):e)},r===i&&(r=function(){return this.value},o=function(e){this.value=e},function(t){if(e.valHooks&&(e.valHooks[t]===i||!0!==e.valHooks[t].inputmaskpatch)){var n=e.valHooks[t]&&e.valHooks[t].get?e.valHooks[t].get:function(e){return e.value},r=e.valHooks[t]&&e.valHooks[t].set?e.valHooks[t].set:function(e,t){return e.value=t,e};e.valHooks[t]={get:function(e){if(e.inputmask){if(e.inputmask.opts.autoUnmask)return e.inputmask.unmaskedvalue();var t=n(e);return-1!==S(i,i,e.inputmask.maskset.validPositions)||!0!==a.nullable?t:""}return n(e)},set:function(t,n){var i,a=e(t);return i=r(t,n),t.inputmask&&a.trigger("setvalue",[n]),i},inputmaskpatch:!0}}}(t.type),function(t){Y.on(t,"mouseenter",function(t){var n=e(this),i=this.inputmask._valueGet();a.showMaskOnHover&&i!==F().join("")&&n.trigger("setvalue")})}(t))}}(t):t.inputmask=i,o}(t,f);if(!1!==a&&(d=e(y=t),g=y.placeholder,-1===(v=y!==i?y.maxLength:i)&&(v=i),!0===f.colorMask&&le(y),o&&("inputmode"in y&&(y.inputmode=f.inputmode,y.setAttribute("inputmode",f.inputmode)),!0===f.disablePredictiveText&&("autocorrect"in y?y.autocorrect=!1:(!0!==f.colorMask&&le(y),y.type="password"))),!0===a&&(y.setAttribute("im-insert",f.insertMode),Y.on(y,"submit",ee.submitEvent),Y.on(y,"reset",ee.resetEvent),Y.on(y,"blur",ee.blurEvent),Y.on(y,"focus",ee.focusEvent),!0!==f.colorMask&&(Y.on(y,"click",ee.clickEvent),Y.on(y,"mouseleave",ee.mouseleaveEvent),Y.on(y,"mouseenter",ee.mouseenterEvent)),Y.on(y,"paste",ee.pasteEvent),Y.on(y,"cut",ee.cutEvent),Y.on(y,"complete",f.oncomplete),Y.on(y,"incomplete",f.onincomplete),Y.on(y,"cleared",f.oncleared),o||!0===f.inputEventOnly?y.removeAttribute("maxLength"):(Y.on(y,"keydown",ee.keydownEvent),Y.on(y,"keypress",ee.keypressEvent)),Y.on(y,"input",ee.inputFallBackEvent),Y.on(y,"beforeinput",ee.beforeInputEvent)),Y.on(y,"setvalue",ee.setValueEvent),m=L().join(""),""!==y.inputmask._valueGet(!0)||!1===f.clearMaskOnLostFocus||n.activeElement===y)){var r=e.isFunction(f.onBeforeMask)&&f.onBeforeMask.call(b,y.inputmask._valueGet(!0),f)||y.inputmask._valueGet(!0);""!==r&&te(y,!0,!1,r.split(""));var s=F().slice();m=s.join(""),!1===oe(s)&&f.clearIncomplete&&O(),f.clearMaskOnLostFocus&&n.activeElement!==y&&(-1===S()?s=[]:re(s)),(!1===f.clearMaskOnLostFocus||f.showMaskOnFocus&&n.activeElement===y||""!==y.inputmask._valueGet(!0))&&z(y,s),n.activeElement===y&&ie(y,W(S()))}}(y);break;case"format":return J=(e.isFunction(f.onBeforeMask)&&f.onBeforeMask.call(b,a.value,f)||a.value).split(""),te.call(this,i,!0,!1,J),a.metadata?{value:P?F().slice().reverse().join(""):F().join(""),metadata:h.call(this,{action:"getmetadata"},u,f)}:P?F().slice().reverse().join(""):F().join("");case"isValid":a.value?(J=a.value.split(""),te.call(this,i,!0,!0,J)):a.value=F().join("");for(var ue=F(),fe=ae(),pe=ue.length-1;pe>fe&&!q(pe);pe--);return ue.splice(fe,pe+1-fe),oe(ue)&&a.value===F().join("");case"getemptymask":return L().join("");case"remove":if(y&&y.inputmask)e.data(y,"_inputmask_opts",null),d=e(y),y.inputmask._valueSet(f.autoUnmask?ne(y):y.inputmask._valueGet(!0)),Y.off(y),y.inputmask.colorMask&&((k=y.inputmask.colorMask).removeChild(y),k.parentNode.insertBefore(y,k),k.parentNode.removeChild(k)),Object.getOwnPropertyDescriptor&&Object.getPrototypeOf?Object.getOwnPropertyDescriptor(Object.getPrototypeOf(y),"value")&&y.inputmask.__valueGet&&Object.defineProperty(y,"value",{get:y.inputmask.__valueGet,set:y.inputmask.__valueSet,configurable:!0}):n.__lookupGetter__&&y.__lookupGetter__("value")&&y.inputmask.__valueGet&&(y.__defineGetter__("value",y.inputmask.__valueGet),y.__defineSetter__("value",y.inputmask.__valueSet)),y.inputmask=i;return y;case"getmetadata":if(e.isArray(u.metadata)){var he=A(!0,0,!1).join("");return e.each(u.metadata,function(e,t){if(t.mask===he)return he=t,!1}),he}return u.metadata}}return c.prototype={dataAttribute:"data-inputmask",defaults:{placeholder:"_",optionalmarker:["[","]"],quantifiermarker:["{","}"],groupmarker:["(",")"],alternatormarker:"|",escapeChar:"\\",mask:null,regex:null,oncomplete:e.noop,onincomplete:e.noop,oncleared:e.noop,repeat:0,greedy:!1,autoUnmask:!1,removeMaskOnSubmit:!1,clearMaskOnLostFocus:!0,insertMode:!0,clearIncomplete:!1,alias:null,onKeyDown:e.noop,onBeforeMask:null,onBeforePaste:function(t,n){return e.isFunction(n.onBeforeMask)?n.onBeforeMask.call(this,t,n):t},onBeforeWrite:null,onUnMask:null,showMaskOnFocus:!0,showMaskOnHover:!0,onKeyValidation:e.noop,skipOptionalPartCharacter:" ",numericInput:!1,rightAlign:!1,undoOnEscape:!0,radixPoint:"",_radixDance:!1,groupSeparator:"",keepStatic:null,positionCaretOnTab:!0,tabThrough:!1,supportsInputType:["text","tel","url","password","search"],ignorables:[8,9,13,19,27,33,34,35,36,37,38,39,40,45,46,93,112,113,114,115,116,117,118,119,120,121,122,123,0,229],isComplete:null,preValidation:null,postValidation:null,staticDefinitionSymbol:i,jitMasking:!1,nullable:!0,inputEventOnly:!1,noValuePatching:!1,positionCaretOnClick:"lvp",casing:null,inputmode:"verbatim",colorMask:!1,disablePredictiveText:!1,importDataAttributes:!0,shiftPositions:!0},definitions:{9:{validator:"[0-91-9]",definitionSymbol:"*"},a:{validator:"[A-Za-zА-яЁёÀ-ÿµ]",definitionSymbol:"*"},"?":{validator:".",cardinality:1,definitionSymbol:"*"},"*":{validator:"[0-91-9A-Za-zА-яЁёÀ-ÿµ]"}},aliases:{},masksCache:{},mask:function(a){var r=this;return"string"==typeof a&&(a=n.getElementById(a)||n.querySelectorAll(a)),a=a.nodeName?[a]:a,e.each(a,function(n,a){var o=e.extend(!0,{},r.opts);if(function(n,a,r,o){if(!0===a.importDataAttributes){var s,l,c,f,p=function(e,a){null!==(a=a!==i?a:n.getAttribute(o+"-"+e))&&("string"==typeof a&&(0===e.indexOf("on")?a=t[a]:"false"===a?a=!1:"true"===a&&(a=!0)),r[e]=a)},h=n.getAttribute(o);if(h&&""!==h&&(h=h.replace(/'/g,'"'),l=JSON.parse("{"+h+"}")),l)for(f in c=i,l)if("alias"===f.toLowerCase()){c=l[f];break}for(s in p("alias",c),r.alias&&u(r.alias,r,a),a){if(l)for(f in c=i,l)if(f.toLowerCase()===s.toLowerCase()){c=l[f];break}p(s,c)}}return e.extend(!0,a,r),("rtl"===n.dir||a.rightAlign)&&(n.style.textAlign="right"),("rtl"===n.dir||a.numericInput)&&(n.dir="ltr",n.removeAttribute("dir"),a.isRTL=!0),Object.keys(r).length}(a,o,e.extend(!0,{},r.userOptions),r.dataAttribute)){var s=f(o,r.noMasksCache);s!==i&&(a.inputmask!==i&&(a.inputmask.opts.autoUnmask=a.inputmask.opts.autoUnmask,a.inputmask.remove()),a.inputmask=new c(i,i,!0),a.inputmask.opts=o,a.inputmask.noMasksCache=r.noMasksCache,a.inputmask.userOptions=e.extend(!0,{},r.userOptions),a.inputmask.isRTL=o.isRTL||o.numericInput,a.inputmask.el=a,a.inputmask.maskset=s,e.data(a,"_inputmask_opts",o),h.call(a.inputmask,{action:"mask"}))}}),a&&a[0]&&a[0].inputmask||this},option:function(t,n){return"string"==typeof t?this.opts[t]:"object"===_typeof(t)?(e.extend(this.userOptions,t),this.el&&!0!==n&&this.mask(this.el),this):void 0},unmaskedvalue:function(e){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"unmaskedvalue",value:e})},remove:function(){return h.call(this,{action:"remove"})},getemptymask:function(){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"getemptymask"})},hasMaskedValue:function(){return!this.opts.autoUnmask},isComplete:function(){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"isComplete"})},getmetadata:function(){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"getmetadata"})},isValid:function(e){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"isValid",value:e})},format:function(e,t){return this.maskset=this.maskset||f(this.opts,this.noMasksCache),h.call(this,{action:"format",value:e,metadata:t})},setValue:function(t){this.el&&e(this.el).trigger("setvalue",[t])},analyseMask:function(t,n,a){var r,o,s,l,u,f,p=/(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?(?:\|[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g,h=/\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,m=!1,d=new g,v=[],k=[];function g(e,t,n,i){this.matches=[],this.openGroup=e||!1,this.alternatorGroup=!1,this.isGroup=e||!1,this.isOptional=t||!1,this.isQuantifier=n||!1,this.isAlternator=i||!1,this.quantifier={min:1,max:1}}function b(t,r,o){o=o!==i?o:t.matches.length;var s=t.matches[o-1];if(n)0===r.indexOf("[")||m&&/\\d|\\s|\\w]/i.test(r)||"."===r?t.matches.splice(o++,0,{fn:new RegExp(r,a.casing?"i":""),optionality:!1,newBlockMarker:s===i?"master":s.def!==r,casing:null,def:r,placeholder:i,nativeDef:r}):(m&&(r=r[r.length-1]),e.each(r.split(""),function(e,n){s=t.matches[o-1],t.matches.splice(o++,0,{fn:null,optionality:!1,newBlockMarker:s===i?"master":s.def!==n&&null!==s.fn,casing:null,def:a.staticDefinitionSymbol||n,placeholder:a.staticDefinitionSymbol!==i?n:i,nativeDef:(m?"'":"")+n})})),m=!1;else{var l=(a.definitions?a.definitions[r]:i)||c.prototype.definitions[r];if(l&&!m){for(var u=l.prevalidator,f=u?u.length:0,p=1;p=p?u[p-1]:[],d=h.validator,v=h.cardinality;t.matches.splice(o++,0,{fn:d?"string"==typeof d?new RegExp(d,a.casing?"i":""):new function(){this.test=d}:new RegExp("."),cardinality:v||1,optionality:t.isOptional,newBlockMarker:s===i||s.def!==(l.definitionSymbol||r),casing:l.casing,def:l.definitionSymbol||r,placeholder:l.placeholder,nativeDef:r}),s=t.matches[o-1]}t.matches.splice(o++,0,{fn:l.validator?"string"==typeof l.validator?new RegExp(l.validator,a.casing?"i":""):new function(){this.test=l.validator}:new RegExp("."),optionality:!1,newBlockMarker:s===i?"master":s.def!==(l.definitionSymbol||r),casing:l.casing,def:l.definitionSymbol||r,placeholder:l.placeholder,nativeDef:r})}else t.matches.splice(o++,0,{fn:null,optionality:!1,newBlockMarker:s===i?"master":s.def!==r&&null!==s.fn,casing:null,def:a.staticDefinitionSymbol||r,placeholder:a.staticDefinitionSymbol!==i?r:i,nativeDef:(m?"'":"")+r}),m=!1}}function y(){if(v.length>0){if(b(l=v[v.length-1],o),l.isAlternator){u=v.pop();for(var e=0;e0?(l=v[v.length-1]).matches.push(u):d.matches.push(u)}}else b(d,o)}function P(e){var t=new g(!0);return t.openGroup=!1,t.matches=e,t}for(n&&(a.optionalmarker[0]=i,a.optionalmarker[1]=i);r=n?h.exec(t):p.exec(t);){if(o=r[0],n)switch(o.charAt(0)){case"?":o="{0,1}";break;case"+":case"*":o="{"+o+"}"}if(m)y();else switch(o.charAt(0)){case"(?=":case"(?!":case"(?<=":case"(?0){if((l=v[v.length-1]).matches.push(s),l.isAlternator){u=v.pop();for(var E=0;E0?(l=v[v.length-1]).matches.push(u):d.matches.push(u)}}else d.matches.push(s);else y();break;case a.optionalmarker[0]:v.push(new g(!1,!0));break;case a.groupmarker[0]:v.push(new g(!0));break;case a.quantifiermarker[0]:var C=new g(!1,!1,!0),x=(o=o.replace(/[{}]/g,"")).split("|"),_=x[0].split(","),A=isNaN(_[0])?_[0]:parseInt(_[0]),w=1===_.length?A:isNaN(_[1])?_[1]:parseInt(_[1]);"*"!==A&&"+"!==A||(A="*"===w?0:1),C.quantifier={min:A,max:w,jit:x[1]};var O=v.length>0?v[v.length-1].matches:d.matches;if((r=O.pop()).isAlternator){O.push(r),O=r.matches;var S=new g(!0),j=O.pop();O.push(S),O=S.matches,r=j}r.isGroup||(r=P([r])),O.push(r),O.push(C);break;case a.alternatormarker:var M=function(e){var t=e.pop();return t.isQuantifier&&(t=P([e.pop(),t])),t};if(v.length>0){var D=(l=v[v.length-1]).matches[l.matches.length-1];f=l.openGroup&&(D.matches===i||!1===D.isGroup&&!1===D.isAlternator)?v.pop():M(l.matches)}else f=M(d.matches);if(f.isAlternator)v.push(f);else if(f.alternatorGroup?(u=v.pop(),f.alternatorGroup=!1):u=new g(!1,!1,!1,!0),u.matches.push(f),v.push(u),f.openGroup){f.openGroup=!1;var G=new g(!0);G.alternatorGroup=!0,v.push(G)}break;default:y()}}for(;v.length>0;)s=v.pop(),d.matches.push(s);return d.matches.length>0&&(!function t(r){r&&r.matches&&e.each(r.matches,function(e,o){var s=r.matches[e+1];(s===i||s.matches===i||!1===s.isQuantifier)&&o&&o.isGroup&&(o.isGroup=!1,n||(b(o,a.groupmarker[0],0),!0!==o.openGroup&&b(o,a.groupmarker[1]))),t(o)})}(d),k.push(d)),(a.numericInput||a.isRTL)&&function e(t){for(var n in t.matches=t.matches.reverse(),t.matches)if(t.matches.hasOwnProperty(n)){var r=parseInt(n);if(t.matches[n].isQuantifier&&t.matches[r+1]&&t.matches[r+1].isGroup){var o=t.matches[n];t.matches.splice(n,1),t.matches.splice(r+1,0,o)}t.matches[n].matches!==i?t.matches[n]=e(t.matches[n]):t.matches[n]=((s=t.matches[n])===a.optionalmarker[0]?s=a.optionalmarker[1]:s===a.optionalmarker[1]?s=a.optionalmarker[0]:s===a.groupmarker[0]?s=a.groupmarker[1]:s===a.groupmarker[1]&&(s=a.groupmarker[0]),s)}var s;return t}(k[0]),k}},c.extendDefaults=function(t){e.extend(!0,c.prototype.defaults,t)},c.extendDefinitions=function(t){e.extend(!0,c.prototype.definitions,t)},c.extendAliases=function(t){e.extend(!0,c.prototype.aliases,t)},c.format=function(e,t,n){return c(t).format(e,n)},c.unmask=function(e,t){return c(t).unmaskedvalue(e)},c.isValid=function(e,t){return c(t).isValid(e)},c.remove=function(t){"string"==typeof t&&(t=n.getElementById(t)||n.querySelectorAll(t)),t=t.nodeName?[t]:t,e.each(t,function(e,t){t.inputmask&&t.inputmask.remove()})},c.setValue=function(t,i){"string"==typeof t&&(t=n.getElementById(t)||n.querySelectorAll(t)),t=t.nodeName?[t]:t,e.each(t,function(t,n){n.inputmask?n.inputmask.setValue(i):e(n).trigger("setvalue",[i])})},c.escapeRegex=function(e){return e.replace(new RegExp("(\\"+["/",".","*","+","?","|","(",")","[","]","{","}","\\","$","^"].join("|\\")+")","gim"),"\\$1")},c.keyCode={BACKSPACE:8,BACKSPACE_SAFARI:127,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,RIGHT:39,SPACE:32,TAB:9,UP:38,X:88,CONTROL:17},c.dependencyLib=e,c}Object.defineProperty(exports,"__esModule",{value:!0}),exports.factory=factory; },{}]},{},[1]); diff --git a/third_party/inputmask/inputmask.date.extensions.js b/third_party/inputmask/inputmask.date.extensions.js index ea5f730fb95eb..fb45ed966b1ad 100755 --- a/third_party/inputmask/inputmask.date.extensions.js +++ b/third_party/inputmask/inputmask.date.extensions.js @@ -234,7 +234,7 @@ export function factory(Inputmask) { } return result; }, - onKeyDown: function(e, buffer, caretPos, opts) { + onKeyDown: function(e, buffer, caretPos, opts, initial, previousPos) { var input = this; if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) { var today = new Date(), match, date = ""; @@ -253,21 +253,77 @@ export function factory(Inputmask) { $(input).trigger("setvalue"); } + const {begin, end} = previousPos; // If the user presses backspace in the middle of the input // value, stop masking until the field is cleared. - if (e.keyCode === Inputmask.keyCode.BACKSPACE) { + if (e.keyCode === Inputmask.keyCode.BACKSPACE || + e.keyCode === Inputmask.keyCode.DELETE || + ((e.metaKey || e.ctrlKey) && e.keyCode === 'X'.charCodeAt(0))) { const length = input.value.length; const cursorIsInMiddle = input.selectionStart != length && input.selectionEnd != length; if (length > 0 && cursorIsInMiddle) { - const cachedController = input.inputmask; - input.inputmask.remove(); - input.addEventListener('input', function onclear() { - if (input.value.length == 0) { - input.removeEventListener('input', onclear); - cachedController.mask(input); - } - }); + disableMaskingUntilClear(input); + + // The library tries to be smart about moving the cursor + // and autofilling values, but here we want to just + // delete the text that was selected like a normal + // input. + // So we take the original selection and the origina + // value before the library auto-changed them, + // and apply the edits ourselves here. + const difference = end - begin; + if (e.keyCode === Inputmask.keyCode.BACKSPACE) { + const selectionBegin = + difference == 0 ? begin - 1 : begin; + input.value = + initial.slice(0, selectionBegin) + + initial.slice(end); + input.setSelectionRange( + selectionBegin, selectionBegin); + } else if (e.keyCode === Inputmask.keyCode.DELETE) { // delete + const selectionEnd = + difference == 0 ? end + 1 : end; + input.value = + initial.slice(0, begin) + + initial.slice(selectionEnd); + input.setSelectionRange(begin, begin); + } + } + return; + } + + // If the user enters text with a selection and causes delete... + if (previousPos.begin != previousPos.end) { + // ... via paste + if ((e.metaKey || e.ctrlKey) && e.keyCode === 'V'.charCodeAt(0)) { + disableMaskingUntilClear(input); + return; + } + + // Don't handle CTRL+C/CMD+C or CTRL or CMD alone + if (e.metaKey || e.ctrlKey) { + return; + } + + // ... via typing a char + const fromCharCode = String.fromCharCode(e.keyCode); + const char = e.shiftKey ? + fromCharCode.toLocaleUpperCase() : + fromCharCode.toLocaleLowerCase(); + if (!/\s/.test(char)) { + disableMaskingUntilClear(input); + // The library still sets the value after the keydown + // handler returns, so we need to asynchronously + // set the value here. + setTimeout(() => { + input.value = + initial.slice(0, begin) + + char + + initial.slice(end); + input.setSelectionRange( + begin + 1, begin + 1); + }, 0); } } }, @@ -283,5 +339,21 @@ export function factory(Inputmask) { shiftPositions: false } }); + + /** + * When the user clears the input, reapply the + * inputmask behavior. + * @param {!Element} input + */ + function disableMaskingUntilClear(input) { + const cachedController = input.inputmask; + input.inputmask.remove(); + input.addEventListener('input', function onclear() { + if (input.value.length == 0) { + input.removeEventListener('input', onclear); + cachedController.mask(input); + } + }); + } return Inputmask; } diff --git a/third_party/inputmask/inputmask.js b/third_party/inputmask/inputmask.js index 6ab796f7e6b59..7539512c5b048 100644 --- a/third_party/inputmask/inputmask.js +++ b/third_party/inputmask/inputmask.js @@ -1699,6 +1699,8 @@ export function factory($, window, document, undefined) { var EventHandlers = { keydownEvent: function(e) { var input = this, $input = $(input), k = e.keyCode, pos = caret(input); + const originalPos = {begin: input.selectionStart, end: input.selectionEnd}; + const initial = input.value; if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || (e.ctrlKey || e.metaKey) && k === Inputmask.keyCode.X && !isInputEventSupported("cut")) { e.preventDefault(); @@ -1745,7 +1747,7 @@ export function factory($, window, document, undefined) { caret(input, pos.begin, pos.end); } } - opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts); + opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts, initial, originalPos); ignorable = $.inArray(k, opts.ignorables) !== -1; }, keypressEvent: function(e, checkval, writeOut, strict, ndx) { diff --git a/third_party/inputmask/patches/0014-delete-middle-date.patch b/third_party/inputmask/patches/0014-delete-middle-date.patch new file mode 100644 index 0000000000000..5c4b5341503a7 --- /dev/null +++ b/third_party/inputmask/patches/0014-delete-middle-date.patch @@ -0,0 +1,144 @@ +diff --git a/third_party/inputmask/inputmask.date.extensions.js b/third_party/inputmask/inputmask.date.extensions.js +index ea5f730fb..fb45ed966 100755 +--- a/third_party/inputmask/inputmask.date.extensions.js ++++ b/third_party/inputmask/inputmask.date.extensions.js +@@ -234,7 +234,7 @@ export function factory(Inputmask) { + } + return result; + }, +- onKeyDown: function(e, buffer, caretPos, opts) { ++ onKeyDown: function(e, buffer, caretPos, opts, initial, previousPos) { + var input = this; + if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) { + var today = new Date(), match, date = ""; +@@ -253,21 +253,77 @@ export function factory(Inputmask) { + $(input).trigger("setvalue"); + } + ++ const {begin, end} = previousPos; + // If the user presses backspace in the middle of the input + // value, stop masking until the field is cleared. +- if (e.keyCode === Inputmask.keyCode.BACKSPACE) { ++ if (e.keyCode === Inputmask.keyCode.BACKSPACE || ++ e.keyCode === Inputmask.keyCode.DELETE || ++ ((e.metaKey || e.ctrlKey) && e.keyCode === 'X'.charCodeAt(0))) { + const length = input.value.length; + const cursorIsInMiddle = input.selectionStart != length && + input.selectionEnd != length; + if (length > 0 && cursorIsInMiddle) { +- const cachedController = input.inputmask; +- input.inputmask.remove(); +- input.addEventListener('input', function onclear() { +- if (input.value.length == 0) { +- input.removeEventListener('input', onclear); +- cachedController.mask(input); +- } +- }); ++ disableMaskingUntilClear(input); ++ ++ // The library tries to be smart about moving the cursor ++ // and autofilling values, but here we want to just ++ // delete the text that was selected like a normal ++ // input. ++ // So we take the original selection and the origina ++ // value before the library auto-changed them, ++ // and apply the edits ourselves here. ++ const difference = end - begin; ++ if (e.keyCode === Inputmask.keyCode.BACKSPACE) { ++ const selectionBegin = ++ difference == 0 ? begin - 1 : begin; ++ input.value = ++ initial.slice(0, selectionBegin) + ++ initial.slice(end); ++ input.setSelectionRange( ++ selectionBegin, selectionBegin); ++ } else if (e.keyCode === Inputmask.keyCode.DELETE) { // delete ++ const selectionEnd = ++ difference == 0 ? end + 1 : end; ++ input.value = ++ initial.slice(0, begin) + ++ initial.slice(selectionEnd); ++ input.setSelectionRange(begin, begin); ++ } ++ } ++ return; ++ } ++ ++ // If the user enters text with a selection and causes delete... ++ if (previousPos.begin != previousPos.end) { ++ // ... via paste ++ if ((e.metaKey || e.ctrlKey) && e.keyCode === 'V'.charCodeAt(0)) { ++ disableMaskingUntilClear(input); ++ return; ++ } ++ ++ // Don't handle CTRL+C/CMD+C or CTRL or CMD alone ++ if (e.metaKey || e.ctrlKey) { ++ return; ++ } ++ ++ // ... via typing a char ++ const fromCharCode = String.fromCharCode(e.keyCode); ++ const char = e.shiftKey ? ++ fromCharCode.toLocaleUpperCase() : ++ fromCharCode.toLocaleLowerCase(); ++ if (!/\s/.test(char)) { ++ disableMaskingUntilClear(input); ++ // The library still sets the value after the keydown ++ // handler returns, so we need to asynchronously ++ // set the value here. ++ setTimeout(() => { ++ input.value = ++ initial.slice(0, begin) + ++ char + ++ initial.slice(end); ++ input.setSelectionRange( ++ begin + 1, begin + 1); ++ }, 0); + } + } + }, +@@ -283,5 +339,21 @@ export function factory(Inputmask) { + shiftPositions: false + } + }); ++ ++ /** ++ * When the user clears the input, reapply the ++ * inputmask behavior. ++ * @param {!Element} input ++ */ ++ function disableMaskingUntilClear(input) { ++ const cachedController = input.inputmask; ++ input.inputmask.remove(); ++ input.addEventListener('input', function onclear() { ++ if (input.value.length == 0) { ++ input.removeEventListener('input', onclear); ++ cachedController.mask(input); ++ } ++ }); ++ } + return Inputmask; + } +diff --git a/third_party/inputmask/inputmask.js b/third_party/inputmask/inputmask.js +index 6ab796f7e..7539512c5 100644 +--- a/third_party/inputmask/inputmask.js ++++ b/third_party/inputmask/inputmask.js +@@ -1699,6 +1699,8 @@ export function factory($, window, document, undefined) { + var EventHandlers = { + keydownEvent: function(e) { + var input = this, $input = $(input), k = e.keyCode, pos = caret(input); ++ const originalPos = {begin: input.selectionStart, end: input.selectionEnd}; ++ const initial = input.value; + if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || (e.ctrlKey || e.metaKey) && k === Inputmask.keyCode.X && !isInputEventSupported("cut")) { + e.preventDefault(); + +@@ -1745,7 +1747,7 @@ export function factory($, window, document, undefined) { + caret(input, pos.begin, pos.end); + } + } +- opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts); ++ opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts, initial, originalPos); + ignorable = $.inArray(k, opts.ignorables) !== -1; + }, + keypressEvent: function(e, checkval, writeOut, strict, ndx) {