inputmask.js 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  1. /*!
  2. * inputmask.js
  3. * http://github.com/RobinHerbots/jquery.inputmask
  4. * Copyright (c) 2010 - 2015 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 3.2.6-7
  7. */
  8. !function(factory) {
  9. "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
  10. }(function($) {
  11. function Inputmask(alias, options) {
  12. return this instanceof Inputmask ? ("object" == typeof alias ? options = alias : (options = options || {},
  13. options.alias = alias), this.el = void 0, this.opts = $.extend(!0, {}, this.defaults, options),
  14. this.noMasksCache = options && void 0 !== options.definitions, this.userOptions = options || {},
  15. void resolveAlias(this.opts.alias, options, this.opts)) : new Inputmask(alias, options);
  16. }
  17. function isInputEventSupported(eventName) {
  18. var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
  19. return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
  20. el = null, isSupported;
  21. }
  22. function isInputTypeSupported(inputType) {
  23. var isSupported = "text" === inputType || "tel" === inputType || "password" === inputType;
  24. if (!isSupported) {
  25. var el = document.createElement("input");
  26. el.setAttribute("type", inputType), isSupported = "text" === el.type, el = null;
  27. }
  28. return isSupported;
  29. }
  30. function resolveAlias(aliasStr, options, opts) {
  31. var aliasDefinition = opts.aliases[aliasStr];
  32. return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts),
  33. $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr),
  34. !1);
  35. }
  36. function importAttributeOptions(npt, opts, userOptions) {
  37. function importOption(option, optionData) {
  38. optionData = void 0 !== optionData ? optionData : npt.getAttribute("data-inputmask-" + option),
  39. null !== optionData && ("string" == typeof optionData && (0 === option.indexOf("on") ? optionData = window[optionData] : "false" === optionData ? optionData = !1 : "true" === optionData && (optionData = !0)),
  40. userOptions[option] = optionData);
  41. }
  42. var option, dataoptions, optionData, p, attrOptions = npt.getAttribute("data-inputmask");
  43. if (attrOptions && "" !== attrOptions && (attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'),
  44. dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) {
  45. optionData = void 0;
  46. for (p in dataoptions) if ("alias" === p.toLowerCase()) {
  47. optionData = dataoptions[p];
  48. break;
  49. }
  50. }
  51. importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts);
  52. for (option in opts) {
  53. if (dataoptions) {
  54. optionData = void 0;
  55. for (p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
  56. optionData = dataoptions[p];
  57. break;
  58. }
  59. }
  60. importOption(option, optionData);
  61. }
  62. return $.extend(!0, opts, userOptions), opts;
  63. }
  64. function generateMaskSet(opts, nocache) {
  65. function analyseMask(mask) {
  66. function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
  67. this.matches = [], this.isGroup = isGroup || !1, this.isOptional = isOptional || !1,
  68. this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
  69. this.quantifier = {
  70. min: 1,
  71. max: 1
  72. };
  73. }
  74. function insertTestDefinition(mtoken, element, position) {
  75. var maskdef = opts.definitions[element];
  76. position = void 0 !== position ? position : mtoken.matches.length;
  77. var prevMatch = mtoken.matches[position - 1];
  78. if (maskdef && !escaped) {
  79. maskdef.placeholder = $.isFunction(maskdef.placeholder) ? maskdef.placeholder(opts) : maskdef.placeholder;
  80. for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
  81. var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
  82. mtoken.matches.splice(position++, 0, {
  83. fn: validator ? "string" == typeof validator ? new RegExp(validator) : new function() {
  84. this.test = validator;
  85. }() : new RegExp("."),
  86. cardinality: cardinality ? cardinality : 1,
  87. optionality: mtoken.isOptional,
  88. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  89. casing: maskdef.casing,
  90. def: maskdef.definitionSymbol || element,
  91. placeholder: maskdef.placeholder,
  92. mask: element
  93. }), prevMatch = mtoken.matches[position - 1];
  94. }
  95. mtoken.matches.splice(position++, 0, {
  96. fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator) : new function() {
  97. this.test = maskdef.validator;
  98. }() : new RegExp("."),
  99. cardinality: maskdef.cardinality,
  100. optionality: mtoken.isOptional,
  101. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  102. casing: maskdef.casing,
  103. def: maskdef.definitionSymbol || element,
  104. placeholder: maskdef.placeholder,
  105. mask: element
  106. });
  107. } else mtoken.matches.splice(position++, 0, {
  108. fn: null,
  109. cardinality: 0,
  110. optionality: mtoken.isOptional,
  111. newBlockMarker: void 0 === prevMatch || prevMatch.def !== element,
  112. casing: null,
  113. def: opts.staticDefinitionSymbol || element,
  114. placeholder: void 0 !== opts.staticDefinitionSymbol ? element : void 0,
  115. mask: element
  116. }), escaped = !1;
  117. }
  118. function verifyGroupMarker(lastMatch, isOpenGroup) {
  119. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  120. isOpenGroup !== !0 && insertTestDefinition(lastMatch, opts.groupmarker.end));
  121. }
  122. function maskCurrentToken(m, currentToken, lastMatch, extraCondition) {
  123. currentToken.matches.length > 0 && (void 0 === extraCondition || extraCondition) && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  124. verifyGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
  125. }
  126. function defaultCase() {
  127. if (openenings.length > 0) {
  128. if (currentOpeningToken = openenings[openenings.length - 1], maskCurrentToken(m, currentOpeningToken, lastMatch, !currentOpeningToken.isAlternator),
  129. currentOpeningToken.isAlternator) {
  130. alternator = openenings.pop();
  131. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  132. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  133. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  134. }
  135. } else maskCurrentToken(m, currentToken, lastMatch);
  136. }
  137. function reverseTokens(maskToken) {
  138. function reverseStatic(st) {
  139. return st === opts.optionalmarker.start ? st = opts.optionalmarker.end : st === opts.optionalmarker.end ? st = opts.optionalmarker.start : st === opts.groupmarker.start ? st = opts.groupmarker.end : st === opts.groupmarker.end && (st = opts.groupmarker.start),
  140. st;
  141. }
  142. maskToken.matches = maskToken.matches.reverse();
  143. for (var match in maskToken.matches) {
  144. var intMatch = parseInt(match);
  145. if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) {
  146. var qt = maskToken.matches[match];
  147. maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt);
  148. }
  149. void 0 !== maskToken.matches[match].matches ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
  150. }
  151. return maskToken;
  152. }
  153. for (var match, m, openingToken, currentOpeningToken, alternator, lastMatch, groupToken, tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g, escaped = !1, currentToken = new MaskToken(), openenings = [], maskTokens = []; match = tokenizer.exec(mask); ) if (m = match[0],
  154. escaped) defaultCase(); else switch (m.charAt(0)) {
  155. case opts.escapeChar:
  156. escaped = !0;
  157. break;
  158. case opts.optionalmarker.end:
  159. case opts.groupmarker.end:
  160. if (openingToken = openenings.pop(), void 0 !== openingToken) if (openenings.length > 0) {
  161. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
  162. currentOpeningToken.isAlternator) {
  163. alternator = openenings.pop();
  164. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  165. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  166. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  167. }
  168. } else currentToken.matches.push(openingToken); else defaultCase();
  169. break;
  170. case opts.optionalmarker.start:
  171. openenings.push(new MaskToken(!1, !0));
  172. break;
  173. case opts.groupmarker.start:
  174. openenings.push(new MaskToken(!0));
  175. break;
  176. case opts.quantifiermarker.start:
  177. var quantifier = new MaskToken(!1, !1, !0);
  178. m = m.replace(/[{}]/g, "");
  179. var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 === mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);
  180. if (("*" === mq1 || "+" === mq1) && (mq0 = "*" === mq1 ? 0 : 1), quantifier.quantifier = {
  181. min: mq0,
  182. max: mq1
  183. }, openenings.length > 0) {
  184. var matches = openenings[openenings.length - 1].matches;
  185. match = matches.pop(), match.isGroup || (groupToken = new MaskToken(!0), groupToken.matches.push(match),
  186. match = groupToken), matches.push(match), matches.push(quantifier);
  187. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new MaskToken(!0),
  188. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  189. currentToken.matches.push(quantifier);
  190. break;
  191. case opts.alternatormarker:
  192. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  193. lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(),
  194. lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new MaskToken(!1, !1, !1, !0),
  195. alternator.matches.push(lastMatch), openenings.push(alternator));
  196. break;
  197. default:
  198. defaultCase();
  199. }
  200. for (;openenings.length > 0; ) openingToken = openenings.pop(), verifyGroupMarker(openingToken, !0),
  201. currentToken.matches.push(openingToken);
  202. return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  203. verifyGroupMarker(lastMatch), maskTokens.push(currentToken)), opts.numericInput && reverseTokens(maskTokens[0]),
  204. maskTokens;
  205. }
  206. function generateMask(mask, metadata) {
  207. if (null === mask || "" === mask) return void 0;
  208. if (1 === mask.length && opts.greedy === !1 && 0 !== opts.repeat && (opts.placeholder = ""),
  209. opts.repeat > 0 || "*" === opts.repeat || "+" === opts.repeat) {
  210. var repeatStart = "*" === opts.repeat ? 0 : "+" === opts.repeat ? 1 : opts.repeat;
  211. mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
  212. }
  213. var masksetDefinition;
  214. return void 0 === Inputmask.prototype.masksCache[mask] || nocache === !0 ? (masksetDefinition = {
  215. mask: mask,
  216. maskToken: analyseMask(mask),
  217. validPositions: {},
  218. _buffer: void 0,
  219. buffer: void 0,
  220. tests: {},
  221. metadata: metadata
  222. }, nocache !== !0 && (Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask] = masksetDefinition,
  223. masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask]))) : masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask]),
  224. masksetDefinition;
  225. }
  226. function preProcessMask(mask) {
  227. return mask = mask.toString();
  228. }
  229. var ms;
  230. if ($.isFunction(opts.mask) && (opts.mask = opts.mask(opts)), $.isArray(opts.mask)) {
  231. if (opts.mask.length > 1) {
  232. opts.keepStatic = null === opts.keepStatic ? !0 : opts.keepStatic;
  233. var altMask = "(";
  234. return $.each(opts.numericInput ? opts.mask.reverse() : opts.mask, function(ndx, msk) {
  235. altMask.length > 1 && (altMask += ")|("), altMask += preProcessMask(void 0 === msk.mask || $.isFunction(msk.mask) ? msk : msk.mask);
  236. }), altMask += ")", generateMask(altMask, opts.mask);
  237. }
  238. opts.mask = opts.mask.pop();
  239. }
  240. return opts.mask && (ms = void 0 === opts.mask.mask || $.isFunction(opts.mask.mask) ? generateMask(preProcessMask(opts.mask), opts.mask) : generateMask(preProcessMask(opts.mask.mask), opts.mask)),
  241. ms;
  242. }
  243. function maskScope(actionObj, maskset, opts) {
  244. function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
  245. minimalPos = minimalPos || 0;
  246. var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0;
  247. do {
  248. if (baseOnInput === !0 && getMaskSet().validPositions[pos]) {
  249. var validPos = getMaskSet().validPositions[pos];
  250. test = validPos.match, ndxIntlzr = validPos.locator.slice(), maskTemplate.push(includeInput === !0 ? validPos.input : getPlaceholder(pos, test));
  251. } else testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), test = testPos.match,
  252. ndxIntlzr = testPos.locator.slice(), maskTemplate.push(getPlaceholder(pos, test));
  253. pos++;
  254. } while ((void 0 === maxLength || maxLength > pos - 1) && null !== test.fn || null === test.fn && "" !== test.def || minimalPos >= pos);
  255. return maskTemplate.pop(), maskTemplate;
  256. }
  257. function getMaskSet() {
  258. return maskset;
  259. }
  260. function resetMaskSet(soft) {
  261. var maskset = getMaskSet();
  262. maskset.buffer = void 0, soft !== !0 && (maskset.tests = {}, maskset._buffer = void 0,
  263. maskset.validPositions = {}, maskset.p = 0);
  264. }
  265. function getLastValidPosition(closestTo, strict) {
  266. var maskset = getMaskSet(), lastValidPosition = -1, valids = maskset.validPositions;
  267. void 0 === closestTo && (closestTo = -1);
  268. var before = lastValidPosition, after = lastValidPosition;
  269. for (var posNdx in valids) {
  270. var psNdx = parseInt(posNdx);
  271. valids[psNdx] && (strict || null !== valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx),
  272. psNdx >= closestTo && (after = psNdx));
  273. }
  274. return lastValidPosition = -1 !== before && closestTo - before > 1 || closestTo > after ? before : after;
  275. }
  276. function setValidPosition(pos, validTest, fromSetValid) {
  277. if (opts.insertMode && void 0 !== getMaskSet().validPositions[pos] && void 0 === fromSetValid) {
  278. var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition();
  279. for (i = pos; lvp >= i; i++) delete getMaskSet().validPositions[i];
  280. getMaskSet().validPositions[pos] = validTest;
  281. var j, valid = !0, vps = getMaskSet().validPositions;
  282. for (i = j = pos; lvp >= i; i++) {
  283. var t = positionsClone[i];
  284. if (void 0 !== t) for (var posMatch = j, prevPosMatch = -1; posMatch < getMaskLength() && (null == t.match.fn && vps[i] && (vps[i].match.optionalQuantifier === !0 || vps[i].match.optionality === !0) || null != t.match.fn); ) {
  285. if (null === t.match.fn || !opts.keepStatic && vps[i] && (void 0 !== vps[i + 1] && getTests(i + 1, vps[i].locator.slice(), i).length > 1 || void 0 !== vps[i].alternation) ? posMatch++ : posMatch = seekNext(j),
  286. positionCanMatchDefinition(posMatch, t.match.def)) {
  287. valid = isValid(posMatch, t.input, !0, !0) !== !1, j = posMatch;
  288. break;
  289. }
  290. if (valid = null == t.match.fn, prevPosMatch === posMatch) break;
  291. prevPosMatch = posMatch;
  292. }
  293. if (!valid) break;
  294. }
  295. if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  296. resetMaskSet(!0), !1;
  297. } else getMaskSet().validPositions[pos] = validTest;
  298. return resetMaskSet(!0), !0;
  299. }
  300. function stripValidPositions(start, end, nocheck, strict) {
  301. var i, startPos = start;
  302. for (getMaskSet().p = start, i = startPos; end > i; i++) void 0 !== getMaskSet().validPositions[i] && (nocheck === !0 || opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts) !== !1) && delete getMaskSet().validPositions[i];
  303. for (i = startPos + 1; i <= getLastValidPosition(); ) {
  304. for (;void 0 !== getMaskSet().validPositions[startPos]; ) startPos++;
  305. var s = getMaskSet().validPositions[startPos];
  306. if (startPos > i && (i = startPos + 1), void 0 === getMaskSet().validPositions[i] && isMask(i) || void 0 !== s) i++; else {
  307. var t = getTestTemplate(i);
  308. positionCanMatchDefinition(startPos, t.match.def) ? isValid(startPos, t.input || getPlaceholder(i), !0) !== !1 && (delete getMaskSet().validPositions[i],
  309. i++) : isMask(i) || (i++, startPos--), startPos++;
  310. }
  311. }
  312. var lvp = getLastValidPosition(), ml = getMaskLength();
  313. for (strict !== !0 && nocheck !== !0 && void 0 !== getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input === opts.radixPoint && delete getMaskSet().validPositions[lvp],
  314. i = lvp + 1; ml >= i; i++) getMaskSet().validPositions[i] && delete getMaskSet().validPositions[i];
  315. resetMaskSet(!0);
  316. }
  317. function getTestTemplate(pos, ndxIntlzr, tstPs) {
  318. var testPos = getMaskSet().validPositions[pos];
  319. if (void 0 === testPos) for (var testPositions = getTests(pos, ndxIntlzr, tstPs), lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp] || getTests(0)[0], lvTestAltArr = void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation].toString().split(",") : [], ndx = 0; ndx < testPositions.length && (testPos = testPositions[ndx],
  320. !(testPos.match && (opts.greedy && testPos.match.optionalQuantifier !== !0 || (testPos.match.optionality === !1 || testPos.match.newBlockMarker === !1) && testPos.match.optionalQuantifier !== !0) && (void 0 === lvTest.alternation || lvTest.alternation !== testPos.alternation || void 0 !== testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAltArr)))); ndx++) ;
  321. return testPos;
  322. }
  323. function getTest(pos) {
  324. return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos].match : getTests(pos)[0].match;
  325. }
  326. function positionCanMatchDefinition(pos, def) {
  327. for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def === def) {
  328. valid = !0;
  329. break;
  330. }
  331. return valid;
  332. }
  333. function getTests(pos, ndxIntlzr, tstPs, cacheable) {
  334. function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
  335. function handleMatch(match, loopNdx, quantifierRecurse) {
  336. function resolveNdxInitializer(pos, alternateNdx) {
  337. var previousMatch, indexPos;
  338. return (getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) && $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function(ndx, lmnt) {
  339. var ndxPos = lmnt.alternation ? lmnt.locator[lmnt.alternation].toString().indexOf(alternateNdx) : -1;
  340. (void 0 === indexPos || indexPos > ndxPos && -1 !== ndxPos) && (previousMatch = lmnt,
  341. indexPos = ndxPos);
  342. }), previousMatch ? previousMatch.locator.slice(previousMatch.alternation + 1) : [];
  343. }
  344. if (testPos > 1e4) 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. " + getMaskSet().mask;
  345. if (testPos === pos && void 0 === match.matches) return matches.push({
  346. match: match,
  347. locator: loopNdx.reverse()
  348. }), !0;
  349. if (void 0 !== match.matches) {
  350. if (match.isGroup && quantifierRecurse !== match) {
  351. if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx)) return !0;
  352. } else if (match.isOptional) {
  353. var optionalToken = match;
  354. if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
  355. if (latestMatch = matches[matches.length - 1].match, isFirstMatch = 0 === $.inArray(latestMatch, optionalToken.matches),
  356. !isFirstMatch) return !0;
  357. insertStop = !0, testPos = pos;
  358. }
  359. } else if (match.isAlternator) {
  360. var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
  361. if (-1 === altIndex || "string" == typeof altIndex) {
  362. var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
  363. if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
  364. for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
  365. if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx),
  366. match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match,
  367. match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
  368. var ntndx = maskToken.matches.indexOf(match) + 1;
  369. maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse),
  370. match && (altIndexArr.push(ntndx.toString()), $.each(matches, function(ndx, lmnt) {
  371. lmnt.alternation = loopNdx.length - 1;
  372. })));
  373. }
  374. maltMatches = matches.slice(), testPos = currentPos, matches = [];
  375. for (var i = 0; i < ndxInitializerClone.length; i++) ndxInitializer[i] = ndxInitializerClone[i];
  376. for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
  377. var altMatch = maltMatches[ndx1];
  378. altMatch.alternation = altMatch.alternation || loopNdxCnt;
  379. for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
  380. var altMatch2 = malternateMatches[ndx2];
  381. if (altMatch.match.def === altMatch2.match.def && ("string" != typeof altIndex || -1 !== $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr))) {
  382. altMatch.match.mask === altMatch2.match.mask && (maltMatches.splice(ndx1, 1), ndx1--),
  383. -1 === altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation],
  384. altMatch2.alternation = altMatch.alternation);
  385. break;
  386. }
  387. }
  388. }
  389. malternateMatches = malternateMatches.concat(maltMatches);
  390. }
  391. "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
  392. if (isFinite(ndx)) {
  393. var mamatch, alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
  394. lmnt.locator[alternation] = void 0, lmnt.alternation = void 0;
  395. for (var alndx = 0; alndx < altLocArr.length; alndx++) mamatch = -1 !== $.inArray(altLocArr[alndx], altIndexArr),
  396. mamatch && (void 0 !== lmnt.locator[alternation] ? (lmnt.locator[alternation] += ",",
  397. lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]),
  398. lmnt.alternation = alternation);
  399. if (void 0 !== lmnt.locator[alternation]) return lmnt;
  400. }
  401. })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0;
  402. } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
  403. if (match) return !0;
  404. } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && pos >= testPos; qndx++) {
  405. var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
  406. if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
  407. if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1,
  408. isFirstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches)) {
  409. if (qndx > qt.quantifier.min - 1) {
  410. insertStop = !0, testPos = pos;
  411. break;
  412. }
  413. return !0;
  414. }
  415. return !0;
  416. }
  417. } else if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0;
  418. } else testPos++;
  419. }
  420. for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (maskToken.matches[tndx].isQuantifier !== !0) {
  421. var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
  422. if (match && testPos === pos) return match;
  423. if (testPos > pos) break;
  424. }
  425. }
  426. var latestMatch, isFirstMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
  427. if (pos > -1) {
  428. if (cacheable === !0 && getMaskSet().tests[pos]) return getMaskSet().tests[pos];
  429. if (void 0 === ndxIntlzr) {
  430. for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos]) && previousPos > -1 && (!getMaskSet().tests[previousPos] || void 0 === (test = getMaskSet().tests[previousPos][0])); ) previousPos--;
  431. void 0 !== test && previousPos > -1 && (testPos = previousPos, ndxInitializer = test.locator.slice());
  432. }
  433. for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
  434. var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
  435. if (match && testPos === pos || testPos > pos) break;
  436. }
  437. return (0 === matches.length || insertStop) && matches.push({
  438. match: {
  439. fn: null,
  440. cardinality: 0,
  441. optionality: !0,
  442. casing: null,
  443. def: ""
  444. },
  445. locator: []
  446. }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
  447. }
  448. }
  449. function getBufferTemplate() {
  450. return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)),
  451. getMaskSet()._buffer;
  452. }
  453. function getBuffer(noCache) {
  454. if (void 0 === getMaskSet().buffer || noCache === !0) {
  455. if (noCache === !0) for (var testNdx in getMaskSet().tests) void 0 === getMaskSet().validPositions[testNdx] && delete getMaskSet().tests[testNdx];
  456. getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0);
  457. }
  458. return getMaskSet().buffer;
  459. }
  460. function refreshFromBuffer(start, end, buffer) {
  461. var i;
  462. if (buffer = buffer, start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; end > i; i++) delete getMaskSet().validPositions[i],
  463. delete getMaskSet().tests[i];
  464. for (i = start; end > i; i++) resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
  465. }
  466. function casing(elem, test) {
  467. switch (test.casing) {
  468. case "upper":
  469. elem = elem.toUpperCase();
  470. break;
  471. case "lower":
  472. elem = elem.toLowerCase();
  473. }
  474. return elem;
  475. }
  476. function checkAlternationMatch(altArr1, altArr2) {
  477. for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if (-1 !== $.inArray(altArr1[alndx], altArrC)) {
  478. isMatch = !0;
  479. break;
  480. }
  481. return isMatch;
  482. }
  483. function isValid(pos, c, strict, fromSetValid) {
  484. function _isValid(position, c, strict, fromSetValid) {
  485. var rslt = !1;
  486. return $.each(getTests(position), function(ndx, tst) {
  487. for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = test.cardinality; i > loopend; i--) chrs += getBufferElement(position - (i - 1));
  488. if (c && (chrs += c), getBuffer(!0), rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts) : c !== test.def && c !== opts.skipOptionalPartCharacter || "" === test.def ? !1 : {
  489. c: test.placeholder || test.def,
  490. pos: position
  491. }, rslt !== !1) {
  492. var elem = void 0 !== rslt.c ? rslt.c : c;
  493. elem = elem === opts.skipOptionalPartCharacter && null === test.fn ? test.placeholder || test.def : elem;
  494. var validatedPos = position, possibleModifiedBuffer = getBuffer();
  495. if (void 0 !== rslt.remove && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]),
  496. $.each(rslt.remove.sort(function(a, b) {
  497. return b - a;
  498. }), function(ndx, lmnt) {
  499. stripValidPositions(lmnt, lmnt + 1, !0);
  500. })), void 0 !== rslt.insert && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]),
  501. $.each(rslt.insert.sort(function(a, b) {
  502. return a - b;
  503. }), function(ndx, lmnt) {
  504. isValid(lmnt.pos, lmnt.c, !0);
  505. })), rslt.refreshFromBuffer) {
  506. var refresh = rslt.refreshFromBuffer;
  507. if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer),
  508. void 0 === rslt.pos && void 0 === rslt.c) return rslt.pos = getLastValidPosition(),
  509. !1;
  510. if (validatedPos = void 0 !== rslt.pos ? rslt.pos : position, validatedPos !== position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  511. !1;
  512. } else if (rslt !== !0 && void 0 !== rslt.pos && rslt.pos !== position && (validatedPos = rslt.pos,
  513. refreshFromBuffer(position, validatedPos, getBuffer().slice()), validatedPos !== position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  514. !1;
  515. return rslt !== !0 && void 0 === rslt.pos && void 0 === rslt.c ? !1 : (ndx > 0 && resetMaskSet(!0),
  516. setValidPosition(validatedPos, $.extend({}, tst, {
  517. input: casing(elem, test)
  518. }), fromSetValid) || (rslt = !1), !1);
  519. }
  520. }), rslt;
  521. }
  522. function alternate(pos, c, strict, fromSetValid) {
  523. for (var lastAlt, alternation, isValidRslt, altPos, i, validPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), lAlt = getLastValidPosition(); lAlt >= 0 && (altPos = getMaskSet().validPositions[lAlt],
  524. !altPos || void 0 === altPos.alternation || (lastAlt = lAlt, alternation = getMaskSet().validPositions[lastAlt].alternation,
  525. getTestTemplate(lastAlt).locator[altPos.alternation] === altPos.locator[altPos.alternation])); lAlt--) ;
  526. if (void 0 !== alternation) {
  527. lastAlt = parseInt(lastAlt);
  528. for (var decisionPos in getMaskSet().validPositions) if (decisionPos = parseInt(decisionPos),
  529. altPos = getMaskSet().validPositions[decisionPos], decisionPos >= lastAlt && void 0 !== altPos.alternation) {
  530. var altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].toString().split(","), decisionTaker = void 0 !== altPos.locator[alternation] ? altPos.locator[alternation] : altNdxs[0];
  531. decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
  532. for (var mndx = 0; mndx < altNdxs.length; mndx++) if (decisionTaker < altNdxs[mndx]) {
  533. for (var possibilityPos, possibilities, dp = decisionPos; dp >= 0; dp--) if (possibilityPos = getMaskSet().validPositions[dp],
  534. void 0 !== possibilityPos) {
  535. possibilities = possibilityPos.locator[alternation], possibilityPos.locator[alternation] = parseInt(altNdxs[mndx]);
  536. break;
  537. }
  538. if (decisionTaker !== possibilityPos.locator[alternation]) {
  539. var validInputs = [], staticInputsBeforePos = 0;
  540. for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i],
  541. validPos && null != validPos.match.fn ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++,
  542. delete getMaskSet().validPositions[i], delete getMaskSet().tests[i];
  543. for (resetMaskSet(!0), opts.keepStatic = !opts.keepStatic, isValidRslt = !0; validInputs.length > 0; ) {
  544. var input = validInputs.shift();
  545. if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition() + 1, input, !1, !0))) break;
  546. }
  547. if (possibilityPos.alternation = alternation, possibilityPos.locator[alternation] = possibilities,
  548. isValidRslt) {
  549. var targetLvp = getLastValidPosition(pos) + 1, staticInputsBeforePosAlternate = 0;
  550. for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i],
  551. (void 0 === validPos || null == validPos.match.fn) && pos > i && staticInputsBeforePosAlternate++;
  552. pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid);
  553. }
  554. if (opts.keepStatic = !opts.keepStatic, isValidRslt) return isValidRslt;
  555. resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
  556. }
  557. }
  558. break;
  559. }
  560. }
  561. return !1;
  562. }
  563. function trackbackAlternations(originalPos, newPos) {
  564. for (var vp = getMaskSet().validPositions[newPos], targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; newPos > ps; ps++) if (!isMask(ps, !0)) {
  565. var tests = getTests(ps), bestMatch = tests[0], equality = -1;
  566. $.each(tests, function(ndx, tst) {
  567. for (var i = 0; tll > i && (void 0 !== tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","))); i++) i > equality && (equality = i,
  568. bestMatch = tst);
  569. }), setValidPosition(ps, $.extend({}, bestMatch, {
  570. input: bestMatch.match.def
  571. }), !0);
  572. }
  573. }
  574. strict = strict === !0;
  575. for (var buffer = getBuffer(), pndx = pos - 1; pndx > -1 && !getMaskSet().validPositions[pndx]; pndx--) ;
  576. for (pndx++; pos > pndx; pndx++) void 0 === getMaskSet().validPositions[pndx] && ((!isMask(pndx) || buffer[pndx] !== getPlaceholder(pndx)) && getTests(pndx).length > 1 || buffer[pndx] === opts.radixPoint || "0" === buffer[pndx] && $.inArray(opts.radixPoint, buffer) < pndx) && _isValid(pndx, buffer[pndx], !0);
  577. var maskPos = pos, result = !1, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  578. if (maskPos < getMaskLength() && (result = _isValid(maskPos, c, strict, fromSetValid),
  579. (!strict || fromSetValid) && result === !1)) {
  580. var currentPosValid = getMaskSet().validPositions[maskPos];
  581. if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
  582. if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid),
  583. result !== !1) {
  584. trackbackAlternations(maskPos, nPos), maskPos = nPos;
  585. break;
  586. }
  587. } else result = {
  588. caret: seekNext(maskPos)
  589. };
  590. }
  591. if (result === !1 && opts.keepStatic && (result = alternate(pos, c, strict, fromSetValid)),
  592. result === !0 && (result = {
  593. pos: maskPos
  594. }), $.isFunction(opts.postValidation) && result !== !1 && !strict) {
  595. var postValidResult = opts.postValidation(getBuffer(!0), opts);
  596. if (postValidResult) {
  597. if (postValidResult.refreshFromBuffer) {
  598. var refresh = postValidResult.refreshFromBuffer;
  599. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, postValidResult.buffer),
  600. resetMaskSet(!0), result = postValidResult;
  601. }
  602. } else resetMaskSet(!0), getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  603. result = !1;
  604. }
  605. return result;
  606. }
  607. function isMask(pos, strict) {
  608. var test = getTest(pos);
  609. if (null != test.fn) return test.fn;
  610. if (strict !== !0 && pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  611. var tests = getTests(pos, void 0, void 0, !0);
  612. return tests.length > 2;
  613. }
  614. return !1;
  615. }
  616. function getMaskLength() {
  617. var maskLength;
  618. maxLength = void 0 !== el ? el.maxLength : void 0, -1 === maxLength && (maxLength = void 0);
  619. var pos, lvp = getLastValidPosition(), testPos = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== testPos ? testPos.locator.slice() : void 0;
  620. for (pos = lvp + 1; void 0 === testPos || null !== testPos.match.fn || null === testPos.match.fn && "" !== testPos.match.def; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  621. ndxIntlzr = testPos.locator.slice();
  622. var lastTest = getTest(pos - 1);
  623. return maskLength = "" !== lastTest.def ? pos : pos - 1, void 0 === maxLength || maxLength > maskLength ? maskLength : maxLength;
  624. }
  625. function seekNext(pos, newBlock) {
  626. var maskL = getMaskLength();
  627. if (pos >= maskL) return maskL;
  628. for (var position = pos; ++position < maskL && (newBlock === !0 && (getTest(position).newBlockMarker !== !0 || !isMask(position)) || newBlock !== !0 && !isMask(position) && (opts.nojumps !== !0 || opts.nojumpsThreshold > position)); ) ;
  629. return position;
  630. }
  631. function seekPrevious(pos, newBlock) {
  632. var position = pos;
  633. if (0 >= position) return 0;
  634. for (;--position > 0 && (newBlock === !0 && getTest(position).newBlockMarker !== !0 || newBlock !== !0 && !isMask(position)); ) ;
  635. return position;
  636. }
  637. function getBufferElement(position) {
  638. return void 0 === getMaskSet().validPositions[position] ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
  639. }
  640. function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
  641. if (event && $.isFunction(opts.onBeforeWrite)) {
  642. var result = opts.onBeforeWrite(event, buffer, caretPos, opts);
  643. if (result) {
  644. if (result.refreshFromBuffer) {
  645. var refresh = result.refreshFromBuffer;
  646. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer || buffer),
  647. buffer = getBuffer(!0);
  648. }
  649. void 0 !== caretPos && (caretPos = void 0 !== result.caret ? result.caret : caretPos);
  650. }
  651. }
  652. input.inputmask._valueSet(buffer.join("")), void 0 === caretPos || void 0 !== event && "blur" === event.type || caret(input, caretPos),
  653. triggerInputEvent === !0 && (skipInputEvent = !0, $(input).trigger("input"));
  654. }
  655. function getPlaceholder(pos, test) {
  656. if (test = test || getTest(pos), void 0 !== test.placeholder) return test.placeholder;
  657. if (null === test.fn) {
  658. if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  659. var prevTest, tests = getTests(pos), staticAlternations = 0;
  660. if (tests.length > 2) for (var i = 0; i < tests.length; i++) if (tests[i].match.optionality !== !0 && tests[i].match.optionalQuantifier !== !0 && (null === tests[i].match.fn || void 0 === prevTest || tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, !0, opts) !== !1) && (staticAlternations++,
  661. null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations > 1)) return opts.placeholder.charAt(pos % opts.placeholder.length);
  662. }
  663. return test.def;
  664. }
  665. return opts.placeholder.charAt(pos % opts.placeholder.length);
  666. }
  667. function checkVal(input, writeOut, strict, nptvl) {
  668. function isTemplateMatch() {
  669. var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
  670. if (-1 !== charCodeNdx && !isMask(initialNdx)) {
  671. isMatch = !0;
  672. for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " !== bufferTemplateArr[i]) {
  673. isMatch = !1;
  674. break;
  675. }
  676. }
  677. return isMatch;
  678. }
  679. var inputValue = nptvl.slice(), charCodes = "", initialNdx = 0;
  680. if (resetMaskSet(), getMaskSet().p = seekNext(-1), !strict) if (opts.autoUnmask !== !0) {
  681. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
  682. matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length),
  683. initialNdx = seekNext(initialNdx));
  684. } else initialNdx = seekNext(initialNdx);
  685. $.each(inputValue, function(ndx, charCode) {
  686. var keypress = $.Event("keypress");
  687. keypress.which = charCode.charCodeAt(0), charCodes += charCode;
  688. var lvp = getLastValidPosition(void 0, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
  689. if (!isTemplateMatch() || strict || opts.autoUnmask) {
  690. var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
  691. keypressEvent.call(input, keypress, !0, !1, strict, pos), initialNdx = pos + 1,
  692. charCodes = "";
  693. } else keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
  694. }), writeOut && writeBuffer(input, getBuffer(), document.activeElement === input ? seekNext(getLastValidPosition(0)) : void 0, $.Event("checkval"));
  695. }
  696. function unmaskedvalue(input) {
  697. if (input && void 0 === input.inputmask) return input.value;
  698. var umValue = [], vps = getMaskSet().validPositions;
  699. for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
  700. var unmaskedValue = 0 === umValue.length ? null : (isRTL ? umValue.reverse() : umValue).join("");
  701. if (null !== unmaskedValue) {
  702. var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  703. $.isFunction(opts.onUnMask) && (unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts) || unmaskedValue);
  704. }
  705. return unmaskedValue;
  706. }
  707. function caret(input, begin, end) {
  708. function translatePosition(pos) {
  709. if (isRTL && "number" == typeof pos && (!opts.greedy || "" !== opts.placeholder)) {
  710. var bffrLght = getBuffer().join("").length;
  711. pos = bffrLght - pos;
  712. }
  713. return pos;
  714. }
  715. var range;
  716. if ("number" != typeof begin) return input.setSelectionRange ? (begin = input.selectionStart,
  717. end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0),
  718. (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) && (begin = range.startOffset,
  719. end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  720. begin = 0 - range.duplicate().moveStart("character", -1e5), end = begin + range.text.length),
  721. {
  722. begin: translatePosition(begin),
  723. end: translatePosition(end)
  724. };
  725. begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin;
  726. var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
  727. if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, androidchrome || opts.insertMode !== !1 || begin !== end || end++,
  728. input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) {
  729. if (range = document.createRange(), void 0 === input.firstChild) {
  730. var textNode = document.createTextNode("");
  731. input.appendChild(textNode);
  732. }
  733. range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length),
  734. range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length),
  735. range.collapse(!0);
  736. var sel = window.getSelection();
  737. sel.removeAllRanges(), sel.addRange(range);
  738. } else input.createTextRange && (range = input.createTextRange(), range.collapse(!0),
  739. range.moveEnd("character", end), range.moveStart("character", begin), range.select());
  740. }
  741. function determineLastRequiredPosition(returnDefinition) {
  742. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== lvTest ? lvTest.locator.slice() : void 0;
  743. for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  744. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  745. var lvTestAlt = lvTest && void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation] : void 0;
  746. for (pos = bl - 1; pos > lvp && (testPos = positions[pos], (testPos.match.optionality || testPos.match.optionalQuantifier || lvTestAlt && (lvTestAlt !== positions[pos].locator[lvTest.alternation] && null != testPos.match.fn || null === testPos.match.fn && testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) && "" !== getTests(pos)[0].def)) && buffer[pos] === getPlaceholder(pos, testPos.match)); pos--) bl--;
  747. return returnDefinition ? {
  748. l: bl,
  749. def: positions[bl] ? positions[bl].match : void 0
  750. } : bl;
  751. }
  752. function clearOptionalTail(buffer) {
  753. for (var rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  754. return buffer.splice(rl, lmib + 1 - rl), buffer;
  755. }
  756. function isComplete(buffer) {
  757. if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
  758. if ("*" === opts.repeat) return void 0;
  759. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
  760. if (void 0 === lrp.def || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
  761. complete = !0;
  762. for (var i = 0; aml >= i; i++) {
  763. var test = getTestTemplate(i).match;
  764. if (null !== test.fn && void 0 === getMaskSet().validPositions[i] && test.optionality !== !0 && test.optionalQuantifier !== !0 || null === test.fn && buffer[i] !== getPlaceholder(i, test)) {
  765. complete = !1;
  766. break;
  767. }
  768. }
  769. }
  770. return complete;
  771. }
  772. function isSelection(begin, end) {
  773. return isRTL ? begin - end > 1 || begin - end === 1 && opts.insertMode : end - begin > 1 || end - begin === 1 && opts.insertMode;
  774. }
  775. function wrapEventRuler(eventHandler) {
  776. return function(e) {
  777. var inComposition = !1, keydownPressed = !1;
  778. if (void 0 === this.inputmask) {
  779. var imOpts = $.data(this, "_inputmask_opts");
  780. imOpts ? new Inputmask(imOpts).mask(this) : $(this).off(".inputmask");
  781. } else {
  782. if ("setvalue" === e.type || !(this.disabled || this.readOnly && !("keydown" === e.type && e.ctrlKey && 67 === e.keyCode || opts.tabThrough === !1 && e.keyCode === Inputmask.keyCode.TAB))) {
  783. switch (e.type) {
  784. case "input":
  785. if (skipInputEvent === !0 || inComposition === !0) return skipInputEvent = !1, e.preventDefault();
  786. keydownPressed = !1;
  787. break;
  788. case "keydown":
  789. skipKeyPressEvent = !1, inComposition = !1, keydownPressed = !0;
  790. break;
  791. case "keypress":
  792. if (skipKeyPressEvent === !0) return e.preventDefault();
  793. skipKeyPressEvent = !0;
  794. break;
  795. case "compositionstart":
  796. inComposition = !0;
  797. break;
  798. case "compositionupdate":
  799. skipInputEvent = keydownPressed;
  800. break;
  801. case "compositionend":
  802. inComposition = !1, keydownPressed = !1;
  803. break;
  804. case "cut":
  805. skipInputEvent = !0;
  806. }
  807. return eventHandler.apply(this, arguments);
  808. }
  809. e.preventDefault();
  810. }
  811. };
  812. }
  813. function patchValueProperty(npt) {
  814. function patchValhook(type) {
  815. if ($.valHooks && (void 0 === $.valHooks[type] || $.valHooks[type].inputmaskpatch !== !0)) {
  816. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  817. return elem.value;
  818. }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  819. return elem.value = value, elem;
  820. };
  821. $.valHooks[type] = {
  822. get: function(elem) {
  823. if (elem.inputmask) {
  824. if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue();
  825. var result = valhookGet(elem), maskset = elem.inputmask.maskset, bufferTemplate = maskset._buffer;
  826. return bufferTemplate = bufferTemplate ? bufferTemplate.join("") : "", result !== bufferTemplate ? result : "";
  827. }
  828. return valhookGet(elem);
  829. },
  830. set: function(elem, value) {
  831. var result, $elem = $(elem);
  832. return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue.inputmask"),
  833. result;
  834. },
  835. inputmaskpatch: !0
  836. };
  837. }
  838. }
  839. function getter() {
  840. return this.inputmask ? this.inputmask.opts.autoUnmask ? this.inputmask.unmaskedvalue() : valueGet.call(this) !== getBufferTemplate().join("") ? document.activeElement === this && opts.clearMaskOnLostFocus ? (isRTL ? clearOptionalTail(getBuffer().slice()).reverse() : clearOptionalTail(getBuffer().slice())).join("") : valueGet.call(this) : "" : valueGet.call(this);
  841. }
  842. function setter(value) {
  843. valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue.inputmask");
  844. }
  845. function installNativeValueSetFallback(npt) {
  846. $(npt).on("mouseenter.inputmask", wrapEventRuler(function(event) {
  847. var $input = $(this), input = this, value = input.inputmask._valueGet();
  848. "" !== value && value !== getBuffer().join("") && $input.trigger("setvalue.inputmask");
  849. }));
  850. }
  851. var valueGet, valueSet;
  852. npt.inputmask.__valueGet || (Object.getOwnPropertyDescriptor && void 0 === npt.value ? (valueGet = function() {
  853. return this.textContent;
  854. }, valueSet = function(value) {
  855. this.textContent = value;
  856. }, Object.defineProperty(npt, "value", {
  857. get: getter,
  858. set: setter
  859. })) : document.__lookupGetter__ && npt.__lookupGetter__("value") ? (valueGet = npt.__lookupGetter__("value"),
  860. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  861. npt.__defineSetter__("value", setter)) : (valueGet = function() {
  862. return npt.value;
  863. }, valueSet = function(value) {
  864. npt.value = value;
  865. }, patchValhook(npt.type), installNativeValueSetFallback(npt)), npt.inputmask.__valueGet = valueGet,
  866. npt.inputmask._valueGet = function(overruleRTL) {
  867. return isRTL && overruleRTL !== !0 ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
  868. }, npt.inputmask.__valueSet = valueSet, npt.inputmask._valueSet = function(value, overruleRTL) {
  869. valueSet.call(this.el, null === value || void 0 === value ? "" : overruleRTL !== !0 && isRTL ? value.split("").reverse().join("") : value);
  870. });
  871. }
  872. function handleRemove(input, k, pos, strict) {
  873. function generalize() {
  874. if (opts.keepStatic) {
  875. resetMaskSet(!0);
  876. var lastAlt, validInputs = [], positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  877. for (lastAlt = getLastValidPosition(); lastAlt >= 0; lastAlt--) {
  878. var validPos = getMaskSet().validPositions[lastAlt];
  879. if (validPos && (null != validPos.match.fn && validInputs.push(validPos.input),
  880. delete getMaskSet().validPositions[lastAlt], void 0 !== validPos.alternation && validPos.locator[validPos.alternation] === getTestTemplate(lastAlt).locator[validPos.alternation])) break;
  881. }
  882. if (lastAlt > -1) for (;validInputs.length > 0; ) {
  883. getMaskSet().p = seekNext(getLastValidPosition());
  884. var keypress = $.Event("keypress");
  885. keypress.which = validInputs.pop().charCodeAt(0), keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  886. } else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
  887. }
  888. }
  889. if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE),
  890. isRTL)) {
  891. var pend = pos.end;
  892. pos.end = pos.begin, pos.begin = pend;
  893. }
  894. k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === !1) ? (pos.begin = seekPrevious(pos.begin),
  895. void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end) ? pos.end + 1 : seekNext(pos.end) + 1,
  896. void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++),
  897. stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0 && generalize();
  898. var lvp = getLastValidPosition(pos.begin);
  899. lvp < pos.begin ? (-1 === lvp && resetMaskSet(), getMaskSet().p = seekNext(lvp)) : strict !== !0 && (getMaskSet().p = pos.begin);
  900. }
  901. function keydownEvent(e) {
  902. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  903. k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && 127 === k || e.ctrlKey && 88 === k && !isInputEventSupported("cut") ? (e.preventDefault(),
  904. 88 === k && (undoValue = getBuffer().join("")), handleRemove(input, k, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  905. input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  906. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask)) : k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN ? setTimeout(function() {
  907. var caretPos = seekNext(getLastValidPosition());
  908. opts.insertMode || caretPos !== getMaskLength() || e.shiftKey || caretPos--, caret(input, e.shiftKey ? pos.begin : caretPos, caretPos);
  909. }, 0) : k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? caret(input, 0, e.shiftKey ? pos.begin : 0) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || 90 === k && e.ctrlKey) && e.altKey !== !0 ? (checkVal(input, !0, !1, undoValue.split("")),
  910. $input.trigger("click")) : k !== Inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? opts.tabThrough === !0 && k === Inputmask.keyCode.TAB ? (e.shiftKey === !0 ? (null === getTest(pos.begin).fn && (pos.begin = seekNext(pos.begin)),
  911. pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
  912. pos.end = seekNext(pos.begin, !0), pos.end < getMaskLength() && pos.end--), pos.begin < getMaskLength() && (e.preventDefault(),
  913. caret(input, pos.begin, pos.end))) : opts.insertMode !== !1 || e.shiftKey || (k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
  914. var caretPos = caret(input);
  915. caret(input, caretPos.begin);
  916. }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
  917. var caretPos = caret(input);
  918. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  919. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskLength() ? pos.begin : pos.begin - 1)),
  920. opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = -1 !== $.inArray(k, opts.ignorables);
  921. }
  922. function keypressEvent(e, checkval, writeOut, strict, ndx) {
  923. var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
  924. if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
  925. e.preventDefault(), setTimeout(function() {
  926. $input.trigger("change");
  927. }, 0)), !0;
  928. if (k) {
  929. 46 === k && e.shiftKey === !1 && "," === opts.radixPoint && (k = 44);
  930. var forwardPosition, pos = checkval ? {
  931. begin: ndx,
  932. end: ndx
  933. } : caret(input), c = String.fromCharCode(k), isSlctn = isSelection(pos.begin, pos.end);
  934. isSlctn && (getMaskSet().undoPositions = $.extend(!0, {}, getMaskSet().validPositions),
  935. handleRemove(input, Inputmask.keyCode.DELETE, pos, !0), pos.begin = getMaskSet().p,
  936. opts.insertMode || (opts.insertMode = !opts.insertMode, setValidPosition(pos.begin, strict),
  937. opts.insertMode = !opts.insertMode), isSlctn = !opts.multi), getMaskSet().writeOutBuffer = !0;
  938. var p = isRTL && !isSlctn ? pos.end : pos.begin, valResult = isValid(p, c, strict);
  939. if (valResult !== !1) {
  940. if (valResult !== !0 && (p = void 0 !== valResult.pos ? valResult.pos : p, c = void 0 !== valResult.c ? valResult.c : c),
  941. resetMaskSet(!0), void 0 !== valResult.caret) forwardPosition = valResult.caret; else {
  942. var vps = getMaskSet().validPositions;
  943. forwardPosition = !opts.keepStatic && (void 0 !== vps[p + 1] && getTests(p + 1, vps[p].locator.slice(), p).length > 1 || void 0 !== vps[p].alternation) ? p + 1 : seekNext(p);
  944. }
  945. getMaskSet().p = forwardPosition;
  946. }
  947. if (writeOut !== !1) {
  948. var self = this;
  949. if (setTimeout(function() {
  950. opts.onKeyValidation.call(self, k, valResult, opts);
  951. }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
  952. var buffer = getBuffer();
  953. writeBuffer(input, buffer, checkval ? void 0 : opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
  954. checkval !== !0 && setTimeout(function() {
  955. isComplete(buffer) === !0 && $input.trigger("complete");
  956. }, 0);
  957. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  958. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  959. if (opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask), checkval && $.isFunction(opts.onBeforeWrite)) {
  960. var result = opts.onBeforeWrite(e, getBuffer(), forwardPosition, opts);
  961. if (result && result.refreshFromBuffer) {
  962. var refresh = result.refreshFromBuffer;
  963. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer),
  964. resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret);
  965. }
  966. }
  967. if (e.preventDefault(), checkval) return valResult;
  968. }
  969. }
  970. function pasteEvent(e) {
  971. var input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
  972. if ("propertychange" === e.type && input.inputmask._valueGet().length <= getMaskLength()) return !0;
  973. if ("paste" === e.type) {
  974. var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
  975. valueBeforeCaret === getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
  976. valueAfterCaret === getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""),
  977. window.clipboardData && window.clipboardData.getData ? inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret : ev.clipboardData && ev.clipboardData.getData && (inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret);
  978. }
  979. var pasteValue = inputValue;
  980. if ($.isFunction(opts.onBeforePaste)) {
  981. if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) return e.preventDefault(),
  982. !1;
  983. pasteValue || (pasteValue = inputValue);
  984. }
  985. return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
  986. writeBuffer(input, getBuffer(), void 0, e, !0), $input.trigger("click"), isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  987. !1;
  988. }
  989. function inputFallBackEvent(e) {
  990. var input = this;
  991. checkVal(input, !0, !1, input.inputmask._valueGet().split("")), isComplete(getBuffer()) === !0 && $(input).trigger("complete"),
  992. e.preventDefault();
  993. }
  994. function mobileInputEvent(e) {
  995. var input = this, caretPos = caret(input), currentValue = input.inputmask._valueGet();
  996. currentValue = currentValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
  997. caretPos.begin > currentValue.length && (caret(input, currentValue.length), caretPos = caret(input)),
  998. getBuffer().length - currentValue.length !== 1 || currentValue.charAt(caretPos.begin) === getBuffer()[caretPos.begin] || currentValue.charAt(caretPos.begin + 1) === getBuffer()[caretPos.begin] || isMask(caretPos.begin) ? inputFallBackEvent.call(this, e) : (e.keyCode = opts.keyCode.BACKSPACE,
  999. keydownEvent.call(input, e)), e.preventDefault();
  1000. }
  1001. function compositionStartEvent(e) {
  1002. var ev = e.originalEvent || e;
  1003. undoValue = getBuffer().join(""), "" === compositionData || 0 !== ev.data.indexOf(compositionData);
  1004. }
  1005. function compositionUpdateEvent(e) {
  1006. var input = this, ev = e.originalEvent || e;
  1007. 0 === ev.data.indexOf(compositionData) && (resetMaskSet(), getMaskSet().p = seekNext(-1),
  1008. skipInputEvent = !0);
  1009. for (var newData = ev.data, i = 0; i < newData.length; i++) {
  1010. var keypress = $.Event("keypress");
  1011. keypress.which = newData.charCodeAt(i), skipKeyPressEvent = !1, ignorable = !1,
  1012. keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  1013. }
  1014. setTimeout(function() {
  1015. var forwardPosition = getMaskSet().p;
  1016. writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
  1017. }, 0), compositionData = ev.data;
  1018. }
  1019. function compositionEndEvent(e) {}
  1020. function setValueEvent(e) {
  1021. var input = this, value = input.inputmask._valueGet();
  1022. checkVal(input, !0, !1, ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(value, opts) || value : value).split("")),
  1023. undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
  1024. }
  1025. function focusEvent(e) {
  1026. var input = this, nptValue = input.inputmask._valueGet();
  1027. opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) ? input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition())),
  1028. opts.positionCaretOnTab === !0 && setTimeout(function() {
  1029. caret(input, seekNext(getLastValidPosition()));
  1030. }, 0), undoValue = getBuffer().join("");
  1031. }
  1032. function mouseleaveEvent(e) {
  1033. var input = this;
  1034. if (mouseEnter = !1, opts.clearMaskOnLostFocus) {
  1035. var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
  1036. document.activeElement !== input && nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
  1037. writeBuffer(input, buffer));
  1038. }
  1039. }
  1040. function clickEvent(e) {
  1041. function doRadixFocus(clickPos) {
  1042. if (opts.radixFocus && "" !== opts.radixPoint) {
  1043. var vps = getMaskSet().validPositions;
  1044. if (void 0 === vps[clickPos] || vps[clickPos].input === getPlaceholder(clickPos)) {
  1045. if (clickPos < seekNext(-1)) return !0;
  1046. var radixPos = $.inArray(opts.radixPoint, getBuffer());
  1047. if (-1 !== radixPos) {
  1048. for (var vp in vps) if (vp > radixPos && vps[vp].input !== getPlaceholder(vp)) return !1;
  1049. return !0;
  1050. }
  1051. }
  1052. }
  1053. return !1;
  1054. }
  1055. var input = this;
  1056. if (document.activeElement === input) {
  1057. var selectedCaret = caret(input);
  1058. if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, $.inArray(opts.radixPoint, getBuffer())); else {
  1059. var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
  1060. lastPosition > clickPosition ? caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)) : ((getBuffer()[lastPosition] !== getPlaceholder(lastPosition) || !isMask(lastPosition, !0) && getTest(lastPosition).def === getPlaceholder(lastPosition)) && (lastPosition = seekNext(lastPosition)),
  1061. caret(input, lastPosition));
  1062. }
  1063. }
  1064. }
  1065. function dblclickEvent(e) {
  1066. var input = this;
  1067. setTimeout(function() {
  1068. caret(input, 0, seekNext(getLastValidPosition()));
  1069. }, 0);
  1070. }
  1071. function cutEvent(e) {
  1072. var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e, clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
  1073. clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
  1074. document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
  1075. writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  1076. input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"),
  1077. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
  1078. }
  1079. function blurEvent(e) {
  1080. var $input = $(this), input = this;
  1081. if (input.inputmask) {
  1082. var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
  1083. undoValue !== buffer.join("") && setTimeout(function() {
  1084. $input.trigger("change"), undoValue = buffer.join("");
  1085. }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1086. isComplete(buffer) === !1 && (setTimeout(function() {
  1087. $input.trigger("incomplete");
  1088. }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
  1089. writeBuffer(input, buffer, void 0, e));
  1090. }
  1091. }
  1092. function mouseenterEvent(e) {
  1093. var input = this;
  1094. mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
  1095. }
  1096. function submitEvent(e) {
  1097. undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && -1 === getLastValidPosition() && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
  1098. opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
  1099. setTimeout(function() {
  1100. writeBuffer(el, getBuffer());
  1101. }, 0));
  1102. }
  1103. function resetEvent(e) {
  1104. setTimeout(function() {
  1105. $el.trigger("setvalue.inputmask");
  1106. }, 0);
  1107. }
  1108. function mask(elem) {
  1109. if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask),
  1110. ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"), ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr",
  1111. el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), $el.off(".inputmask"),
  1112. patchValueProperty(el), ("INPUT" === el.tagName && isInputTypeSupported(el.getAttribute("type")) || el.isContentEditable || "TEXTAREA" === el.tagName) && ($(el.form).on("submit.inputmask", submitEvent).on("reset.inputmask", resetEvent),
  1113. $el.on("mouseenter.inputmask", wrapEventRuler(mouseenterEvent)).on("blur.inputmask", wrapEventRuler(blurEvent)).on("focus.inputmask", wrapEventRuler(focusEvent)).on("mouseleave.inputmask", wrapEventRuler(mouseleaveEvent)).on("click.inputmask", wrapEventRuler(clickEvent)).on("dblclick.inputmask", wrapEventRuler(dblclickEvent)).on(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", wrapEventRuler(pasteEvent)).on("cut.inputmask", wrapEventRuler(cutEvent)).on("complete.inputmask", wrapEventRuler(opts.oncomplete)).on("incomplete.inputmask", wrapEventRuler(opts.onincomplete)).on("cleared.inputmask", wrapEventRuler(opts.oncleared)).on("keydown.inputmask", wrapEventRuler(keydownEvent)).on("keypress.inputmask", wrapEventRuler(keypressEvent)),
  1114. androidfirefox || $el.on("compositionstart.inputmask", wrapEventRuler(compositionStartEvent)).on("compositionupdate.inputmask", wrapEventRuler(compositionUpdateEvent)).on("compositionend.inputmask", wrapEventRuler(compositionEndEvent)),
  1115. "paste" === PasteEventType && $el.on("input.inputmask", wrapEventRuler(inputFallBackEvent)),
  1116. (android || androidfirefox || androidchrome || kindle) && ($el.off("input.inputmask"),
  1117. $el.on("input.inputmask", wrapEventRuler(mobileInputEvent)))), $el.on("setvalue.inputmask", wrapEventRuler(setValueEvent)),
  1118. "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1) {
  1119. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
  1120. checkVal(el, !0, !1, initialValue.split(""));
  1121. var buffer = getBuffer().slice();
  1122. undoValue = buffer.join(""), isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(),
  1123. opts.clearMaskOnLostFocus && (buffer.join("") === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1124. writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
  1125. }
  1126. }
  1127. var undoValue, compositionData, el, $el, maxLength, valueBuffer, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !0;
  1128. if (void 0 !== actionObj) switch (actionObj.action) {
  1129. case "isComplete":
  1130. return el = actionObj.el, isComplete(getBuffer());
  1131. case "unmaskedvalue":
  1132. return el = actionObj.el, void 0 !== el && void 0 !== el.inputmask ? (maskset = el.inputmask.maskset,
  1133. opts = el.inputmask.opts, isRTL = el.inputmask.isRTL) : (valueBuffer = actionObj.value,
  1134. opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
  1135. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts)),
  1136. unmaskedvalue(el);
  1137. case "mask":
  1138. el = actionObj.el, maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL,
  1139. undoValue = getBuffer().join(""), mask(el);
  1140. break;
  1141. case "format":
  1142. return opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
  1143. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts),
  1144. actionObj.metadata ? {
  1145. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  1146. metadata: maskScope({
  1147. action: "getmetadata"
  1148. }, maskset, opts)
  1149. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  1150. case "isValid":
  1151. opts.numericInput && (isRTL = !0), actionObj.value ? (valueBuffer = actionObj.value.split(""),
  1152. checkVal(void 0, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
  1153. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  1154. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
  1155. case "getemptymask":
  1156. return getBufferTemplate();
  1157. case "remove":
  1158. el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts,
  1159. el.inputmask._valueSet(unmaskedvalue(el)), $el.off(".inputmask");
  1160. var valueProperty;
  1161. Object.getOwnPropertyDescriptor && (valueProperty = Object.getOwnPropertyDescriptor(el, "value")),
  1162. valueProperty && valueProperty.get ? el.inputmask.__valueGet && Object.defineProperty(el, "value", {
  1163. get: el.inputmask.__valueGet,
  1164. set: el.inputmask.__valueSet
  1165. }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
  1166. el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = void 0;
  1167. break;
  1168. case "getmetadata":
  1169. if ($.isArray(maskset.metadata)) {
  1170. for (var alternation, lvp = getLastValidPosition(), firstAlt = lvp; firstAlt >= 0; firstAlt--) if (getMaskSet().validPositions[firstAlt] && void 0 !== getMaskSet().validPositions[firstAlt].alternation) {
  1171. alternation = getMaskSet().validPositions[firstAlt].alternation;
  1172. break;
  1173. }
  1174. return void 0 !== alternation ? maskset.metadata[getMaskSet().validPositions[lvp].locator[alternation]] : maskset.metadata[0];
  1175. }
  1176. return maskset.metadata;
  1177. }
  1178. }
  1179. Inputmask.prototype = {
  1180. defaults: {
  1181. placeholder: "_",
  1182. optionalmarker: {
  1183. start: "[",
  1184. end: "]"
  1185. },
  1186. quantifiermarker: {
  1187. start: "{",
  1188. end: "}"
  1189. },
  1190. groupmarker: {
  1191. start: "(",
  1192. end: ")"
  1193. },
  1194. alternatormarker: "|",
  1195. escapeChar: "\\",
  1196. mask: null,
  1197. oncomplete: $.noop,
  1198. onincomplete: $.noop,
  1199. oncleared: $.noop,
  1200. repeat: 0,
  1201. greedy: !0,
  1202. autoUnmask: !1,
  1203. removeMaskOnSubmit: !1,
  1204. clearMaskOnLostFocus: !0,
  1205. insertMode: !0,
  1206. clearIncomplete: !1,
  1207. aliases: {},
  1208. alias: null,
  1209. onKeyDown: $.noop,
  1210. onBeforeMask: null,
  1211. onBeforePaste: function(pastedValue, opts) {
  1212. return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(pastedValue, opts) : pastedValue;
  1213. },
  1214. onBeforeWrite: null,
  1215. onUnMask: null,
  1216. showMaskOnFocus: !0,
  1217. showMaskOnHover: !0,
  1218. onKeyValidation: $.noop,
  1219. skipOptionalPartCharacter: " ",
  1220. showTooltip: !1,
  1221. tooltip: void 0,
  1222. numericInput: !1,
  1223. rightAlign: !1,
  1224. undoOnEscape: !0,
  1225. radixPoint: "",
  1226. groupSeparator: "",
  1227. radixFocus: !1,
  1228. nojumps: !1,
  1229. nojumpsThreshold: 0,
  1230. keepStatic: null,
  1231. positionCaretOnTab: !1,
  1232. tabThrough: !1,
  1233. supportsInputType: [],
  1234. definitions: {
  1235. "9": {
  1236. validator: "[0-9]",
  1237. cardinality: 1,
  1238. definitionSymbol: "*"
  1239. },
  1240. a: {
  1241. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1242. cardinality: 1,
  1243. definitionSymbol: "*"
  1244. },
  1245. "*": {
  1246. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1247. cardinality: 1
  1248. }
  1249. },
  1250. 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 ],
  1251. isComplete: null,
  1252. canClearPosition: $.noop,
  1253. postValidation: null,
  1254. staticDefinitionSymbol: void 0
  1255. },
  1256. masksCache: {},
  1257. mask: function(elems) {
  1258. var that = this;
  1259. return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)),
  1260. elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
  1261. var scopedOpts = $.extend(!0, {}, that.opts);
  1262. importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
  1263. var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
  1264. void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(),
  1265. el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
  1266. el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts),
  1267. maskScope({
  1268. action: "mask",
  1269. el: el
  1270. }));
  1271. }), elems ? elems[0].inputmask || this : this;
  1272. },
  1273. option: function(options) {
  1274. return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.opts, options),
  1275. $.extend(this.userOptions, options), this.el && (void 0 !== options.mask || void 0 !== options.alias ? this.mask(this.el) : ($.data(this.el, "_inputmask_opts", this.opts),
  1276. maskScope({
  1277. action: "mask",
  1278. el: this.el
  1279. }))), this) : void 0;
  1280. },
  1281. unmaskedvalue: function(value) {
  1282. return maskScope({
  1283. action: "unmaskedvalue",
  1284. el: this.el,
  1285. value: value
  1286. }, this.el && this.el.inputmask ? this.el.inputmask.maskset : generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1287. },
  1288. remove: function() {
  1289. return this.el ? (maskScope({
  1290. action: "remove",
  1291. el: this.el
  1292. }), this.el.inputmask = void 0, this.el) : void 0;
  1293. },
  1294. getemptymask: function() {
  1295. return maskScope({
  1296. action: "getemptymask"
  1297. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1298. },
  1299. hasMaskedValue: function() {
  1300. return !this.opts.autoUnmask;
  1301. },
  1302. isComplete: function() {
  1303. return maskScope({
  1304. action: "isComplete",
  1305. el: this.el
  1306. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1307. },
  1308. getmetadata: function() {
  1309. return maskScope({
  1310. action: "getmetadata"
  1311. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1312. },
  1313. isValid: function(value) {
  1314. return maskScope({
  1315. action: "isValid",
  1316. value: value
  1317. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1318. },
  1319. format: function(value, metadata) {
  1320. return maskScope({
  1321. action: "format",
  1322. value: value,
  1323. metadata: metadata
  1324. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1325. }
  1326. }, Inputmask.extendDefaults = function(options) {
  1327. $.extend(!0, Inputmask.prototype.defaults, options);
  1328. }, Inputmask.extendDefinitions = function(definition) {
  1329. $.extend(!0, Inputmask.prototype.defaults.definitions, definition);
  1330. }, Inputmask.extendAliases = function(alias) {
  1331. $.extend(!0, Inputmask.prototype.defaults.aliases, alias);
  1332. }, Inputmask.format = function(value, options, metadata) {
  1333. return Inputmask(options).format(value, metadata);
  1334. }, Inputmask.unmask = function(value, options) {
  1335. return Inputmask(options).unmaskedvalue(value);
  1336. }, Inputmask.isValid = function(value, options) {
  1337. return Inputmask(options).isValid(value);
  1338. }, Inputmask.remove = function(elems) {
  1339. $.each(elems, function(ndx, el) {
  1340. el.inputmask && el.inputmask.remove();
  1341. });
  1342. }, Inputmask.escapeRegex = function(str) {
  1343. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
  1344. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1345. }, Inputmask.keyCode = {
  1346. ALT: 18,
  1347. BACKSPACE: 8,
  1348. CAPS_LOCK: 20,
  1349. COMMA: 188,
  1350. COMMAND: 91,
  1351. COMMAND_LEFT: 91,
  1352. COMMAND_RIGHT: 93,
  1353. CONTROL: 17,
  1354. DELETE: 46,
  1355. DOWN: 40,
  1356. END: 35,
  1357. ENTER: 13,
  1358. ESCAPE: 27,
  1359. HOME: 36,
  1360. INSERT: 45,
  1361. LEFT: 37,
  1362. MENU: 93,
  1363. NUMPAD_ADD: 107,
  1364. NUMPAD_DECIMAL: 110,
  1365. NUMPAD_DIVIDE: 111,
  1366. NUMPAD_ENTER: 108,
  1367. NUMPAD_MULTIPLY: 106,
  1368. NUMPAD_SUBTRACT: 109,
  1369. PAGE_DOWN: 34,
  1370. PAGE_UP: 33,
  1371. PERIOD: 190,
  1372. RIGHT: 39,
  1373. SHIFT: 16,
  1374. SPACE: 32,
  1375. TAB: 9,
  1376. UP: 38,
  1377. WINDOWS: 91
  1378. };
  1379. var ua = navigator.userAgent, iphone = null !== ua.match(new RegExp("iphone", "i")), android = null !== ua.match(new RegExp("android.*safari.*", "i")), androidchrome = null !== ua.match(new RegExp("android.*chrome.*", "i")), androidfirefox = null !== ua.match(new RegExp("android.*firefox.*", "i")), kindle = /Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua), PasteEventType = isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange";
  1380. return window.Inputmask = Inputmask, Inputmask;
  1381. });