You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3007 lines
175 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. /* !
  2. * jquery.inputmask.bundle.js
  3. * http://github.com/RobinHerbots/jquery.inputmask
  4. * Copyright (c) 2010 - 2016 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 3.2.7
  7. */
  8. !(function ($) {
  9. function Inputmask (alias, options) {
  10. return this instanceof Inputmask ? ($.isPlainObject(alias) ? options = alias : (options = options || {},
  11. options.alias = alias), this.el = void 0, this.opts = $.extend(!0, {}, this.defaults, options),
  12. this.noMasksCache = options && void 0 !== options.definitions, this.userOptions = options || {},
  13. this.events = {}, void resolveAlias(this.opts.alias, options, this.opts)) : new Inputmask(alias, options);
  14. }
  15. function isInputEventSupported (eventName) {
  16. var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
  17. return isSupported || (el.setAttribute(evName, "return;"), isSupported = typeof el[evName] === "function"),
  18. el = null, isSupported;
  19. }
  20. function isElementTypeSupported (input, opts) {
  21. var elementType = input.getAttribute("type"), isSupported = input.tagName === "INPUT" && $.inArray(elementType, opts.supportsInputType) !== -1 || input.isContentEditable || input.tagName === "TEXTAREA";
  22. if (!isSupported) {
  23. var el = document.createElement("input");
  24. el.setAttribute("type", elementType), isSupported = el.type === "text", el = null;
  25. }
  26. return isSupported;
  27. }
  28. function resolveAlias (aliasStr, options, opts) {
  29. var aliasDefinition = opts.aliases[aliasStr];
  30. return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts),
  31. $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (opts.mask === null && (opts.mask = aliasStr),
  32. !1);
  33. }
  34. function importAttributeOptions (npt, opts, userOptions) {
  35. function importOption (option, optionData) {
  36. optionData = void 0 !== optionData ? optionData : npt.getAttribute("data-inputmask-" + option),
  37. optionData !== null && (typeof optionData === "string" && (option.indexOf("on") === 0 ? optionData = window[optionData] : optionData === "false" ? optionData = !1 : optionData === "true" && (optionData = !0)),
  38. userOptions[option] = optionData);
  39. }
  40. var option, dataoptions, optionData, p, attrOptions = npt.getAttribute("data-inputmask");
  41. if (attrOptions && attrOptions !== "" && (attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'),
  42. dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) {
  43. optionData = void 0;
  44. for (p in dataoptions) {
  45. if (p.toLowerCase() === "alias") {
  46. optionData = dataoptions[p];
  47. break;
  48. }
  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) {
  56. if (p.toLowerCase() === option.toLowerCase()) {
  57. optionData = dataoptions[p];
  58. break;
  59. }
  60. }
  61. }
  62. importOption(option, optionData);
  63. }
  64. return $.extend(!0, opts, userOptions), opts;
  65. }
  66. function generateMaskSet (opts, nocache) {
  67. function analyseMask (mask) {
  68. function MaskToken (isGroup, isOptional, isQuantifier, isAlternator) {
  69. this.matches = [], this.isGroup = isGroup || !1, this.isOptional = isOptional || !1,
  70. this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
  71. this.quantifier = {
  72. min: 1,
  73. max: 1,
  74. };
  75. }
  76. function insertTestDefinition (mtoken, element, position) {
  77. var maskdef = opts.definitions[element];
  78. position = void 0 !== position ? position : mtoken.matches.length;
  79. var prevMatch = mtoken.matches[position - 1];
  80. if (maskdef && !escaped) {
  81. maskdef.placeholder = $.isFunction(maskdef.placeholder) ? maskdef.placeholder(opts) : maskdef.placeholder;
  82. for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
  83. var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
  84. mtoken.matches.splice(position++, 0, {
  85. fn: validator ? typeof validator === "string" ? new RegExp(validator) : new function () {
  86. this.test = validator;
  87. }() : new RegExp("."),
  88. cardinality: cardinality ? cardinality : 1,
  89. optionality: mtoken.isOptional,
  90. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  91. casing: maskdef.casing,
  92. def: maskdef.definitionSymbol || element,
  93. placeholder: maskdef.placeholder,
  94. mask: element,
  95. }), prevMatch = mtoken.matches[position - 1];
  96. }
  97. mtoken.matches.splice(position++, 0, {
  98. fn: maskdef.validator ? typeof maskdef.validator === "string" ? new RegExp(maskdef.validator) : new function () {
  99. this.test = maskdef.validator;
  100. }() : new RegExp("."),
  101. cardinality: maskdef.cardinality,
  102. optionality: mtoken.isOptional,
  103. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  104. casing: maskdef.casing,
  105. def: maskdef.definitionSymbol || element,
  106. placeholder: maskdef.placeholder,
  107. mask: element,
  108. });
  109. } else {
  110. mtoken.matches.splice(position++, 0, {
  111. fn: null,
  112. cardinality: 0,
  113. optionality: mtoken.isOptional,
  114. newBlockMarker: void 0 === prevMatch || prevMatch.def !== element,
  115. casing: null,
  116. def: opts.staticDefinitionSymbol || element,
  117. placeholder: void 0 !== opts.staticDefinitionSymbol ? element : void 0,
  118. mask: element,
  119. }), escaped = !1;
  120. }
  121. }
  122. function verifyGroupMarker (lastMatch, isOpenGroup) {
  123. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  124. isOpenGroup !== !0 && insertTestDefinition(lastMatch, opts.groupmarker.end));
  125. }
  126. function maskCurrentToken (m, currentToken, lastMatch, extraCondition) {
  127. currentToken.matches.length > 0 && (void 0 === extraCondition || extraCondition) && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  128. verifyGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
  129. }
  130. function defaultCase () {
  131. if (openenings.length > 0) {
  132. if (currentOpeningToken = openenings[openenings.length - 1], maskCurrentToken(m, currentOpeningToken, lastMatch, !currentOpeningToken.isAlternator),
  133. currentOpeningToken.isAlternator) {
  134. alternator = openenings.pop();
  135. for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
  136. alternator.matches[mndx].isGroup = !1;
  137. }
  138. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  139. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  140. }
  141. } else {
  142. maskCurrentToken(m, currentToken, lastMatch);
  143. }
  144. }
  145. function reverseTokens (maskToken) {
  146. function reverseStatic (st) {
  147. 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),
  148. st;
  149. }
  150. maskToken.matches = maskToken.matches.reverse();
  151. for (var match in maskToken.matches) {
  152. var intMatch = parseInt(match);
  153. if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) {
  154. var qt = maskToken.matches[match];
  155. maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt);
  156. }
  157. void 0 !== maskToken.matches[match].matches ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
  158. }
  159. return maskToken;
  160. }
  161. 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); ) {
  162. if (m = match[0],
  163. escaped) {
  164. defaultCase();
  165. } else {
  166. switch (m.charAt(0)) {
  167. case opts.escapeChar:
  168. escaped = !0;
  169. break;
  170. case opts.optionalmarker.end:
  171. case opts.groupmarker.end:
  172. if (openingToken = openenings.pop(), void 0 !== openingToken) {
  173. if (openenings.length > 0) {
  174. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
  175. currentOpeningToken.isAlternator) {
  176. alternator = openenings.pop();
  177. for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
  178. alternator.matches[mndx].isGroup = !1;
  179. }
  180. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  181. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  182. }
  183. } else {
  184. currentToken.matches.push(openingToken);
  185. }
  186. } else {
  187. defaultCase();
  188. }
  189. break;
  190. case opts.optionalmarker.start:
  191. openenings.push(new MaskToken(!1, !0));
  192. break;
  193. case opts.groupmarker.start:
  194. openenings.push(new MaskToken(!0));
  195. break;
  196. case opts.quantifiermarker.start:
  197. var quantifier = new MaskToken(!1, !1, !0);
  198. m = m.replace(/[{}]/g, "");
  199. var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = mq.length === 1 ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);
  200. if ((mq1 === "*" || mq1 === "+") && (mq0 = mq1 === "*" ? 0 : 1), quantifier.quantifier = {
  201. min: mq0,
  202. max: mq1,
  203. }, openenings.length > 0) {
  204. var matches = openenings[openenings.length - 1].matches;
  205. match = matches.pop(), match.isGroup || (groupToken = new MaskToken(!0), groupToken.matches.push(match),
  206. match = groupToken), matches.push(match), matches.push(quantifier);
  207. } else {
  208. match = currentToken.matches.pop(), match.isGroup || (groupToken = new MaskToken(!0),
  209. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  210. currentToken.matches.push(quantifier);
  211. }
  212. break;
  213. case opts.alternatormarker:
  214. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  215. lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(),
  216. lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new MaskToken(!1, !1, !1, !0),
  217. alternator.matches.push(lastMatch), openenings.push(alternator));
  218. break;
  219. default:
  220. defaultCase();
  221. }
  222. }
  223. }
  224. for (;openenings.length > 0; ) {
  225. openingToken = openenings.pop(), verifyGroupMarker(openingToken, !0),
  226. currentToken.matches.push(openingToken);
  227. }
  228. return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  229. verifyGroupMarker(lastMatch), maskTokens.push(currentToken)), opts.numericInput && reverseTokens(maskTokens[0]),
  230. maskTokens;
  231. }
  232. function generateMask (mask, metadata) {
  233. if (mask === null || mask === "") {
  234. return void 0;
  235. }
  236. if (mask.length === 1 && opts.greedy === !1 && opts.repeat !== 0 && (opts.placeholder = ""),
  237. opts.repeat > 0 || opts.repeat === "*" || opts.repeat === "+") {
  238. var repeatStart = opts.repeat === "*" ? 0 : opts.repeat === "+" ? 1 : opts.repeat;
  239. mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
  240. }
  241. var masksetDefinition;
  242. return void 0 === Inputmask.prototype.masksCache[mask] || nocache === !0 ? (masksetDefinition = {
  243. mask: mask,
  244. maskToken: analyseMask(mask),
  245. validPositions: {},
  246. _buffer: void 0,
  247. buffer: void 0,
  248. tests: {},
  249. metadata: metadata,
  250. }, nocache !== !0 && (Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask] = masksetDefinition,
  251. 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]),
  252. masksetDefinition;
  253. }
  254. function preProcessMask (mask) {
  255. return mask = mask.toString();
  256. }
  257. var ms;
  258. if ($.isFunction(opts.mask) && (opts.mask = opts.mask(opts)), $.isArray(opts.mask)) {
  259. if (opts.mask.length > 1) {
  260. opts.keepStatic = opts.keepStatic === null ? !0 : opts.keepStatic;
  261. var altMask = "(";
  262. return $.each(opts.numericInput ? opts.mask.reverse() : opts.mask, function (ndx, msk) {
  263. altMask.length > 1 && (altMask += ")|("), altMask += preProcessMask(void 0 === msk.mask || $.isFunction(msk.mask) ? msk : msk.mask);
  264. }), altMask += ")", generateMask(altMask, opts.mask);
  265. }
  266. opts.mask = opts.mask.pop();
  267. }
  268. 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)),
  269. ms;
  270. }
  271. function maskScope (actionObj, maskset, opts) {
  272. function getMaskTemplate (baseOnInput, minimalPos, includeInput) {
  273. minimalPos = minimalPos || 0;
  274. var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0, lvp = getLastValidPosition();
  275. do {
  276. if (baseOnInput === !0 && getMaskSet().validPositions[pos]) {
  277. var validPos = getMaskSet().validPositions[pos];
  278. test = validPos.match, ndxIntlzr = validPos.locator.slice(), maskTemplate.push(includeInput === !0 ? validPos.input : getPlaceholder(pos, test));
  279. } else {
  280. testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), test = testPos.match,
  281. ndxIntlzr = testPos.locator.slice(), (opts.jitMasking === !1 || lvp > pos || isFinite(opts.jitMasking) && opts.jitMasking > pos) && maskTemplate.push(getPlaceholder(pos, test));
  282. }
  283. pos++;
  284. } while ((void 0 === maxLength || maxLength > pos - 1) && test.fn !== null || test.fn === null && test.def !== "" || minimalPos >= pos);
  285. return maskTemplate[maskTemplate.length - 1] === "" && maskTemplate.pop(), maskTemplate;
  286. }
  287. function getMaskSet () {
  288. return maskset;
  289. }
  290. function resetMaskSet (soft) {
  291. var maskset = getMaskSet();
  292. maskset.buffer = void 0, soft !== !0 && (maskset.tests = {}, maskset._buffer = void 0,
  293. maskset.validPositions = {}, maskset.p = 0);
  294. }
  295. function getLastValidPosition (closestTo, strict) {
  296. var before = -1, after = -1, valids = getMaskSet().validPositions;
  297. void 0 === closestTo && (closestTo = -1);
  298. for (var posNdx in valids) {
  299. var psNdx = parseInt(posNdx);
  300. valids[psNdx] && (strict || valids[psNdx].match.fn !== null) && (closestTo >= psNdx && (before = psNdx),
  301. psNdx >= closestTo && (after = psNdx));
  302. }
  303. return before !== -1 && closestTo - before > 1 || closestTo > after ? before : after;
  304. }
  305. function setValidPosition (pos, validTest, fromSetValid) {
  306. if (opts.insertMode && void 0 !== getMaskSet().validPositions[pos] && void 0 === fromSetValid) {
  307. var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition();
  308. for (i = pos; lvp >= i; i++) {
  309. delete getMaskSet().validPositions[i];
  310. }
  311. getMaskSet().validPositions[pos] = validTest;
  312. var j, valid = !0, vps = getMaskSet().validPositions;
  313. for (i = j = pos; lvp >= i; i++) {
  314. var t = positionsClone[i];
  315. if (void 0 !== t) {
  316. for (var posMatch = j, prevPosMatch = -1; posMatch < getMaskLength() && (t.match.fn == null && vps[i] && (vps[i].match.optionalQuantifier === !0 || vps[i].match.optionality === !0) || t.match.fn != null); ) {
  317. if (t.match.fn === null || !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),
  318. positionCanMatchDefinition(posMatch, t.match.def)) {
  319. var result = isValid(posMatch, t.input, !0, !0);
  320. valid = result !== !1, j = result.caret || result.insert ? getLastValidPosition() : posMatch;
  321. break;
  322. }
  323. if (valid = t.match.fn == null, prevPosMatch === posMatch) {
  324. break;
  325. }
  326. prevPosMatch = posMatch;
  327. }
  328. }
  329. if (!valid) {
  330. break;
  331. }
  332. }
  333. if (!valid) {
  334. return getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  335. resetMaskSet(!0), !1;
  336. }
  337. } else {
  338. getMaskSet().validPositions[pos] = validTest;
  339. }
  340. return resetMaskSet(!0), !0;
  341. }
  342. function stripValidPositions (start, end, nocheck, strict) {
  343. var i, startPos = start;
  344. for (getMaskSet().p = start, i = startPos; end > i; i++) {
  345. void 0 !== getMaskSet().validPositions[i] && (nocheck === !0 || opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts) !== !1) && delete getMaskSet().validPositions[i];
  346. }
  347. for (i = startPos + 1; i <= getLastValidPosition(); ) {
  348. for (;void 0 !== getMaskSet().validPositions[startPos]; ) {
  349. startPos++;
  350. }
  351. var s = getMaskSet().validPositions[startPos];
  352. if (startPos > i && (i = startPos + 1), void 0 === getMaskSet().validPositions[i] && isMask(i) || void 0 !== s) {
  353. i++;
  354. } else {
  355. var t = getTestTemplate(i);
  356. positionCanMatchDefinition(startPos, t.match.def) ? isValid(startPos, t.input || getPlaceholder(i), !0) !== !1 && (delete getMaskSet().validPositions[i],
  357. i++) : isMask(i) || (i++, startPos--), startPos++;
  358. }
  359. }
  360. var lvp = getLastValidPosition(), ml = getMaskLength();
  361. for (strict !== !0 && nocheck !== !0 && void 0 !== getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input === opts.radixPoint && delete getMaskSet().validPositions[lvp],
  362. i = lvp + 1; ml >= i; i++) {
  363. getMaskSet().validPositions[i] && delete getMaskSet().validPositions[i];
  364. }
  365. resetMaskSet(!0);
  366. }
  367. function getTestTemplate (pos, ndxIntlzr, tstPs) {
  368. var testPos = getMaskSet().validPositions[pos];
  369. if (void 0 === testPos) {
  370. 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],
  371. !(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++) {}
  372. }
  373. return testPos;
  374. }
  375. function getTest (pos) {
  376. return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos].match : getTests(pos)[0].match;
  377. }
  378. function positionCanMatchDefinition (pos, def) {
  379. for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) {
  380. if (tests[tndx].match && tests[tndx].match.def === def) {
  381. valid = !0;
  382. break;
  383. }
  384. }
  385. return valid;
  386. }
  387. function selectBestMatch (pos, alternateNdx) {
  388. var bestMatch, indexPos;
  389. return (getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) && $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function (ndx, lmnt) {
  390. var ndxPos = lmnt.alternation ? lmnt.locator[lmnt.alternation].toString().indexOf(alternateNdx) : -1;
  391. (void 0 === indexPos || indexPos > ndxPos) && ndxPos !== -1 && (bestMatch = lmnt,
  392. indexPos = ndxPos);
  393. }), bestMatch;
  394. }
  395. function getTests (pos, ndxIntlzr, tstPs) {
  396. function resolveTestFromToken (maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
  397. function handleMatch (match, loopNdx, quantifierRecurse) {
  398. function isFirstMatch (latestMatch, tokenGroup) {
  399. var firstMatch = $.inArray(latestMatch, tokenGroup.matches) === 0;
  400. return firstMatch || $.each(tokenGroup.matches, function (ndx, match) {
  401. return match.isQuantifier === !0 && (firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1])) ? !1 : void 0;
  402. }), firstMatch;
  403. }
  404. function resolveNdxInitializer (pos, alternateNdx) {
  405. var bestMatch = selectBestMatch(pos, alternateNdx);
  406. return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : [];
  407. }
  408. if (testPos > 1e4) {
  409. 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;
  410. }
  411. if (testPos === pos && void 0 === match.matches) {
  412. return matches.push({
  413. match: match,
  414. locator: loopNdx.reverse(),
  415. cd: cacheDependency,
  416. }), !0;
  417. }
  418. if (void 0 !== match.matches) {
  419. if (match.isGroup && quantifierRecurse !== match) {
  420. if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx)) {
  421. return !0;
  422. }
  423. } else if (match.isOptional) {
  424. var optionalToken = match;
  425. if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
  426. if (latestMatch = matches[matches.length - 1].match, !isFirstMatch(latestMatch, optionalToken)) {
  427. return !0;
  428. }
  429. insertStop = !0, testPos = pos;
  430. }
  431. } else if (match.isAlternator) {
  432. var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
  433. if (altIndex === -1 || typeof altIndex === "string") {
  434. var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
  435. if (typeof altIndex === "string") {
  436. altIndexArr = altIndex.split(",");
  437. } else {
  438. for (amndx = 0; amndx < alternateToken.matches.length; amndx++) {
  439. altIndexArr.push(amndx);
  440. }
  441. }
  442. for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
  443. if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx),
  444. match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match,
  445. match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
  446. var ntndx = $.inArray(match, maskToken.matches) + 1;
  447. maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse),
  448. match && (altIndexArr.push(ntndx.toString()), $.each(matches, function (ndx, lmnt) {
  449. lmnt.alternation = loopNdx.length - 1;
  450. })));
  451. }
  452. maltMatches = matches.slice(), testPos = currentPos, matches = [];
  453. for (var i = 0; i < ndxInitializerClone.length; i++) {
  454. ndxInitializer[i] = ndxInitializerClone[i];
  455. }
  456. for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
  457. var altMatch = maltMatches[ndx1];
  458. altMatch.alternation = altMatch.alternation || loopNdxCnt;
  459. for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
  460. var altMatch2 = malternateMatches[ndx2];
  461. if (altMatch.match.def === altMatch2.match.def && (typeof altIndex !== "string" || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1)) {
  462. altMatch.match.mask === altMatch2.match.mask && (maltMatches.splice(ndx1, 1), ndx1--),
  463. altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1 && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation],
  464. altMatch2.alternation = altMatch.alternation);
  465. break;
  466. }
  467. }
  468. }
  469. malternateMatches = malternateMatches.concat(maltMatches);
  470. }
  471. typeof altIndex === "string" && (malternateMatches = $.map(malternateMatches, function (lmnt, ndx) {
  472. if (isFinite(ndx)) {
  473. var mamatch, alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
  474. lmnt.locator[alternation] = void 0, lmnt.alternation = void 0;
  475. for (var alndx = 0; alndx < altLocArr.length; alndx++) {
  476. mamatch = $.inArray(altLocArr[alndx], altIndexArr) !== -1,
  477. mamatch && (void 0 !== lmnt.locator[alternation] ? (lmnt.locator[alternation] += ",",
  478. lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]),
  479. lmnt.alternation = alternation);
  480. }
  481. if (void 0 !== lmnt.locator[alternation]) {
  482. return lmnt;
  483. }
  484. }
  485. })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0;
  486. } else {
  487. match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
  488. }
  489. if (match) {
  490. return !0;
  491. }
  492. } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) {
  493. for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && pos >= testPos; qndx++) {
  494. var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
  495. if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
  496. if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1,
  497. isFirstMatch(latestMatch, tokenGroup)) {
  498. if (qndx > qt.quantifier.min - 1) {
  499. insertStop = !0, testPos = pos;
  500. break;
  501. }
  502. return !0;
  503. }
  504. return !0;
  505. }
  506. }
  507. } else if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
  508. return !0;
  509. }
  510. } else {
  511. testPos++;
  512. }
  513. }
  514. for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) {
  515. if (maskToken.matches[tndx].isQuantifier !== !0) {
  516. var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
  517. if (match && testPos === pos) {
  518. return match;
  519. }
  520. if (testPos > pos) {
  521. break;
  522. }
  523. }
  524. }
  525. }
  526. function mergeLocators (tests) {
  527. var test = tests[0] || tests;
  528. return test.locator.slice();
  529. }
  530. var latestMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1, cacheDependency = ndxIntlzr ? ndxIntlzr.join("") : "";
  531. if (pos > -1) {
  532. if (void 0 === ndxIntlzr) {
  533. for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos] || getMaskSet().tests[previousPos]) && previousPos > -1; ) {
  534. previousPos--;
  535. }
  536. void 0 !== test && previousPos > -1 && (ndxInitializer = mergeLocators(test), cacheDependency = ndxInitializer.join(""),
  537. test = test[0] || test, testPos = previousPos);
  538. }
  539. if (getMaskSet().tests[pos] && getMaskSet().tests[pos][0].cd === cacheDependency) {
  540. return getMaskSet().tests[pos];
  541. }
  542. for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
  543. var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
  544. if (match && testPos === pos || testPos > pos) {
  545. break;
  546. }
  547. }
  548. }
  549. return (matches.length === 0 || insertStop) && matches.push({
  550. match: {
  551. fn: null,
  552. cardinality: 0,
  553. optionality: !0,
  554. casing: null,
  555. def: "",
  556. },
  557. locator: [],
  558. }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
  559. }
  560. function getBufferTemplate () {
  561. return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)),
  562. getMaskSet()._buffer;
  563. }
  564. function getBuffer (noCache) {
  565. if (void 0 === getMaskSet().buffer || noCache === !0) {
  566. if (noCache === !0) {
  567. for (var testNdx in getMaskSet().tests) {
  568. void 0 === getMaskSet().validPositions[testNdx] && delete getMaskSet().tests[testNdx];
  569. }
  570. }
  571. getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0);
  572. }
  573. return getMaskSet().buffer;
  574. }
  575. function refreshFromBuffer (start, end, buffer) {
  576. var i;
  577. if (buffer = buffer, start === !0) {
  578. resetMaskSet(), start = 0, end = buffer.length;
  579. } else {
  580. for (i = start; end > i; i++) {
  581. delete getMaskSet().validPositions[i],
  582. delete getMaskSet().tests[i];
  583. }
  584. }
  585. for (i = start; end > i; i++) {
  586. resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
  587. }
  588. }
  589. function casing (elem, test) {
  590. switch (test.casing) {
  591. case "upper":
  592. elem = elem.toUpperCase();
  593. break;
  594. case "lower":
  595. elem = elem.toLowerCase();
  596. }
  597. return elem;
  598. }
  599. function checkAlternationMatch (altArr1, altArr2) {
  600. for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) {
  601. if ($.inArray(altArr1[alndx], altArrC) !== -1) {
  602. isMatch = !0;
  603. break;
  604. }
  605. }
  606. return isMatch;
  607. }
  608. function isValid (pos, c, strict, fromSetValid) {
  609. function _isValid (position, c, strict, fromSetValid) {
  610. var rslt = !1;
  611. return $.each(getTests(position), function (ndx, tst) {
  612. for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = test.cardinality; i > loopend; i--) {
  613. chrs += getBufferElement(position - (i - 1));
  614. }
  615. if (c && (chrs += c), getBuffer(!0), rslt = test.fn != null ? test.fn.test(chrs, getMaskSet(), position, strict, opts) : c !== test.def && c !== opts.skipOptionalPartCharacter || test.def === "" ? !1 : {
  616. c: test.placeholder || test.def,
  617. pos: position,
  618. }, rslt !== !1) {
  619. var elem = void 0 !== rslt.c ? rslt.c : c;
  620. elem = elem === opts.skipOptionalPartCharacter && test.fn === null ? test.placeholder || test.def : elem;
  621. var validatedPos = position, possibleModifiedBuffer = getBuffer();
  622. if (void 0 !== rslt.remove && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]),
  623. $.each(rslt.remove.sort(function (a, b) {
  624. return b - a;
  625. }), function (ndx, lmnt) {
  626. stripValidPositions(lmnt, lmnt + 1, !0);
  627. })), void 0 !== rslt.insert && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]),
  628. $.each(rslt.insert.sort(function (a, b) {
  629. return a - b;
  630. }), function (ndx, lmnt) {
  631. isValid(lmnt.pos, lmnt.c, !1, fromSetValid);
  632. })), rslt.refreshFromBuffer) {
  633. var refresh = rslt.refreshFromBuffer;
  634. if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer),
  635. void 0 === rslt.pos && void 0 === rslt.c) {
  636. return rslt.pos = getLastValidPosition(),
  637. !1;
  638. }
  639. if (validatedPos = void 0 !== rslt.pos ? rslt.pos : position, validatedPos !== position) {
  640. return rslt = $.extend(rslt, isValid(validatedPos, elem, !0, fromSetValid)),
  641. !1;
  642. }
  643. } else if (rslt !== !0 && void 0 !== rslt.pos && rslt.pos !== position && (validatedPos = rslt.pos,
  644. refreshFromBuffer(position, validatedPos, getBuffer().slice()), validatedPos !== position)) {
  645. return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  646. !1;
  647. }
  648. return rslt !== !0 && void 0 === rslt.pos && void 0 === rslt.c ? !1 : (ndx > 0 && resetMaskSet(!0),
  649. setValidPosition(validatedPos, $.extend({}, tst, {
  650. input: casing(elem, test),
  651. }), fromSetValid) || (rslt = !1), !1);
  652. }
  653. }), rslt;
  654. }
  655. function alternate (pos, c, strict, fromSetValid) {
  656. for (var lastAlt, alternation, isValidRslt, altPos, i, validPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), testsClone = $.extend(!0, {}, getMaskSet().tests), lAlt = getLastValidPosition(); lAlt >= 0 && (altPos = getMaskSet().validPositions[lAlt],
  657. !altPos || void 0 === altPos.alternation || (lastAlt = lAlt, alternation = getMaskSet().validPositions[lastAlt].alternation,
  658. getTestTemplate(lastAlt).locator[altPos.alternation] === altPos.locator[altPos.alternation])); lAlt--) {}
  659. if (void 0 !== alternation) {
  660. lastAlt = parseInt(lastAlt);
  661. for (var decisionPos in getMaskSet().validPositions) {
  662. if (decisionPos = parseInt(decisionPos),
  663. altPos = getMaskSet().validPositions[decisionPos], decisionPos >= lastAlt && void 0 !== altPos.alternation) {
  664. var altNdxs;
  665. lastAlt === 0 ? (altNdxs = [], $.each(getMaskSet().tests[lastAlt], function (ndx, test) {
  666. void 0 !== test.locator[alternation] && (altNdxs = altNdxs.concat(test.locator[alternation].toString().split(",")));
  667. })) : altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].toString().split(",");
  668. var decisionTaker = void 0 !== altPos.locator[alternation] ? altPos.locator[alternation] : altNdxs[0];
  669. decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
  670. for (var mndx = 0; mndx < altNdxs.length; mndx++) {
  671. var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0;
  672. if (decisionTaker < altNdxs[mndx]) {
  673. for (var possibilityPos, possibilities, dp = decisionPos; dp >= 0; dp--) {
  674. if (possibilityPos = getMaskSet().validPositions[dp],
  675. void 0 !== possibilityPos) {
  676. var bestMatch = selectBestMatch(dp, altNdxs[mndx]);
  677. getMaskSet().validPositions[dp].match.def !== bestMatch.match.def && (validInputs.push(getMaskSet().validPositions[dp].input),
  678. getMaskSet().validPositions[dp] = bestMatch, getMaskSet().validPositions[dp].input = getPlaceholder(dp),
  679. getMaskSet().validPositions[dp].match.fn === null && staticInputsBeforePosAlternate++,
  680. possibilityPos = bestMatch), possibilities = possibilityPos.locator[alternation],
  681. possibilityPos.locator[alternation] = parseInt(altNdxs[mndx]);
  682. break;
  683. }
  684. }
  685. if (decisionTaker !== possibilityPos.locator[alternation]) {
  686. for (i = decisionPos + 1; i < getLastValidPosition(void 0, !0) + 1; i++) {
  687. validPos = getMaskSet().validPositions[i],
  688. validPos && validPos.match.fn != null ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++,
  689. delete getMaskSet().validPositions[i], delete getMaskSet().tests[i];
  690. }
  691. for (resetMaskSet(!0), opts.keepStatic = !opts.keepStatic, isValidRslt = !0; validInputs.length > 0; ) {
  692. var input = validInputs.shift();
  693. if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(void 0, !0) + 1, input, !1, fromSetValid))) {
  694. break;
  695. }
  696. }
  697. if (possibilityPos.alternation = alternation, possibilityPos.locator[alternation] = possibilities,
  698. isValidRslt) {
  699. var targetLvp = getLastValidPosition(pos) + 1;
  700. for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) {
  701. validPos = getMaskSet().validPositions[i],
  702. (void 0 === validPos || validPos.match.fn == null) && pos > i && staticInputsBeforePosAlternate++;
  703. }
  704. pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid);
  705. }
  706. if (opts.keepStatic = !opts.keepStatic, isValidRslt) {
  707. return isValidRslt;
  708. }
  709. resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone), getMaskSet().tests = $.extend(!0, {}, testsClone);
  710. }
  711. }
  712. }
  713. break;
  714. }
  715. }
  716. }
  717. return !1;
  718. }
  719. function trackbackAlternations (originalPos, newPos) {
  720. for (var vp = getMaskSet().validPositions[newPos], targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; newPos > ps; ps++) {
  721. if (void 0 === getMaskSet().validPositions[ps] && !isMask(ps, !0)) {
  722. var tests = getTests(ps), bestMatch = tests[0], equality = -1;
  723. $.each(tests, function (ndx, tst) {
  724. for (var i = 0; tll > i && (void 0 !== tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","))); i++) {
  725. i > equality && (equality = i,
  726. bestMatch = tst);
  727. }
  728. }), setValidPosition(ps, $.extend({}, bestMatch, {
  729. input: bestMatch.match.placeholder || bestMatch.match.def,
  730. }), !0);
  731. }
  732. }
  733. }
  734. strict = strict === !0;
  735. for (var buffer = getBuffer(), pndx = pos - 1; pndx > -1 && !getMaskSet().validPositions[pndx]; pndx--) {}
  736. for (pndx++; pos > pndx; pndx++) {
  737. void 0 === getMaskSet().validPositions[pndx] && ((!isMask(pndx) || buffer[pndx] !== getPlaceholder(pndx)) && getTests(pndx).length > 1 || buffer[pndx] === opts.radixPoint || buffer[pndx] === "0" && $.inArray(opts.radixPoint, buffer) < pndx) && _isValid(pndx, buffer[pndx], !0, fromSetValid);
  738. }
  739. var maskPos = pos, result = !1, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  740. if (maskPos < getMaskLength() && (result = _isValid(maskPos, c, strict, fromSetValid),
  741. (!strict || fromSetValid === !0) && result === !1)) {
  742. var currentPosValid = getMaskSet().validPositions[maskPos];
  743. if (!currentPosValid || currentPosValid.match.fn !== null || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
  744. if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) {
  745. var staticChar = getTestTemplate(maskPos).match, staticChar = staticChar.placeholder || staticChar.def;
  746. _isValid(maskPos, staticChar, strict, fromSetValid);
  747. for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) {
  748. if (result = _isValid(nPos, c, strict, fromSetValid),
  749. result !== !1) {
  750. trackbackAlternations(maskPos, nPos), maskPos = nPos;
  751. break;
  752. }
  753. }
  754. }
  755. } else {
  756. result = {
  757. caret: seekNext(maskPos),
  758. };
  759. }
  760. }
  761. if (result === !1 && opts.keepStatic && (result = alternate(pos, c, strict, fromSetValid)),
  762. result === !0 && (result = {
  763. pos: maskPos,
  764. }), $.isFunction(opts.postValidation) && result !== !1 && !strict && fromSetValid !== !0) {
  765. var postValidResult = opts.postValidation(getBuffer(!0), result, opts);
  766. if (postValidResult) {
  767. if (postValidResult.refreshFromBuffer) {
  768. var refresh = postValidResult.refreshFromBuffer;
  769. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, postValidResult.buffer),
  770. resetMaskSet(!0), result = postValidResult;
  771. }
  772. } else {
  773. resetMaskSet(!0), getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  774. result = !1;
  775. }
  776. }
  777. return result;
  778. }
  779. function isMask (pos, strict) {
  780. var test;
  781. if (strict ? (test = getTestTemplate(pos).match, test.def == "" && (test = getTest(pos))) : test = getTest(pos),
  782. test.fn != null) {
  783. return test.fn;
  784. }
  785. if (strict !== !0 && pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  786. var tests = getTests(pos);
  787. return tests.length > 2;
  788. }
  789. return !1;
  790. }
  791. function getMaskLength () {
  792. var maskLength;
  793. maxLength = void 0 !== el ? el.maxLength : void 0, maxLength === -1 && (maxLength = void 0);
  794. var pos, lvp = getLastValidPosition(), testPos = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== testPos ? testPos.locator.slice() : void 0;
  795. for (pos = lvp + 1; void 0 === testPos || testPos.match.fn !== null || testPos.match.fn === null && testPos.match.def !== ""; pos++) {
  796. testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  797. ndxIntlzr = testPos.locator.slice();
  798. }
  799. var lastTest = getTest(pos - 1);
  800. return maskLength = lastTest.def !== "" ? pos : pos - 1, void 0 === maxLength || maxLength > maskLength ? maskLength : maxLength;
  801. }
  802. function seekNext (pos, newBlock) {
  803. var maskL = getMaskLength();
  804. if (pos >= maskL) {
  805. return maskL;
  806. }
  807. for (var position = pos; ++position < maskL && (newBlock === !0 && (getTest(position).newBlockMarker !== !0 || !isMask(position)) || newBlock !== !0 && !isMask(position) && (opts.nojumps !== !0 || opts.nojumpsThreshold > position)); ) {}
  808. return position;
  809. }
  810. function seekPrevious (pos, newBlock) {
  811. var position = pos;
  812. if (position <= 0) {
  813. return 0;
  814. }
  815. for (;--position > 0 && (newBlock === !0 && getTest(position).newBlockMarker !== !0 || newBlock !== !0 && !isMask(position)); ) {}
  816. return position;
  817. }
  818. function getBufferElement (position) {
  819. return void 0 === getMaskSet().validPositions[position] ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
  820. }
  821. function writeBuffer (input, buffer, caretPos, event, triggerInputEvent) {
  822. if (event && $.isFunction(opts.onBeforeWrite)) {
  823. var result = opts.onBeforeWrite(event, buffer, caretPos, opts);
  824. if (result) {
  825. if (result.refreshFromBuffer) {
  826. var refresh = result.refreshFromBuffer;
  827. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer || buffer),
  828. buffer = getBuffer(!0);
  829. }
  830. void 0 !== caretPos && (caretPos = void 0 !== result.caret ? result.caret : caretPos);
  831. }
  832. }
  833. input.inputmask._valueSet(buffer.join("")), void 0 === caretPos || void 0 !== event && event.type === "blur" || caret(input, caretPos),
  834. triggerInputEvent === !0 && (skipInputEvent = !0, $(input).trigger("input"));
  835. }
  836. function getPlaceholder (pos, test) {
  837. if (test = test || getTest(pos), void 0 !== test.placeholder) {
  838. return test.placeholder;
  839. }
  840. if (test.fn === null) {
  841. if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  842. var prevTest, tests = getTests(pos), staticAlternations = 0;
  843. if (tests.length > 2) {
  844. for (var i = 0; i < tests.length; i++) {
  845. if (tests[i].match.optionality !== !0 && tests[i].match.optionalQuantifier !== !0 && (tests[i].match.fn === null || void 0 === prevTest || tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, !0, opts) !== !1) && (staticAlternations++,
  846. tests[i].match.fn === null && (prevTest = tests[i]), staticAlternations > 1)) {
  847. return opts.placeholder.charAt(pos % opts.placeholder.length);
  848. }
  849. }
  850. }
  851. }
  852. return test.def;
  853. }
  854. return opts.placeholder.charAt(pos % opts.placeholder.length);
  855. }
  856. function checkVal (input, writeOut, strict, nptvl) {
  857. function isTemplateMatch () {
  858. var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
  859. if (charCodeNdx !== -1 && !isMask(initialNdx)) {
  860. isMatch = !0;
  861. for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) {
  862. if (bufferTemplateArr[i] !== " ") {
  863. isMatch = !1;
  864. break;
  865. }
  866. }
  867. }
  868. return isMatch;
  869. }
  870. var inputValue = nptvl.slice(), charCodes = "", initialNdx = 0;
  871. if (resetMaskSet(), getMaskSet().p = seekNext(-1), !strict) {
  872. if (opts.autoUnmask !== !0) {
  873. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
  874. matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length),
  875. initialNdx = seekNext(initialNdx));
  876. } else {
  877. initialNdx = seekNext(initialNdx);
  878. }
  879. }
  880. $.each(inputValue, function (ndx, charCode) {
  881. if (void 0 !== charCode) {
  882. var keypress = new $.Event("keypress");
  883. keypress.which = charCode.charCodeAt(0), charCodes += charCode;
  884. var lvp = getLastValidPosition(void 0, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
  885. if (!isTemplateMatch() || strict || opts.autoUnmask) {
  886. var pos = strict ? ndx : nextTest.match.fn == null && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
  887. keypressEvent.call(input, keypress, !0, !1, strict, pos), initialNdx = pos + 1,
  888. charCodes = "";
  889. } else {
  890. keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
  891. }
  892. }
  893. }), writeOut && writeBuffer(input, getBuffer(), document.activeElement === input ? seekNext(getLastValidPosition(0)) : void 0, new $.Event("checkval"));
  894. }
  895. function unmaskedvalue (input) {
  896. if (input && void 0 === input.inputmask) {
  897. return input.value;
  898. }
  899. var umValue = [], vps = getMaskSet().validPositions;
  900. for (var pndx in vps) {
  901. vps[pndx].match && vps[pndx].match.fn != null && umValue.push(vps[pndx].input);
  902. }
  903. var unmaskedValue = umValue.length === 0 ? null : (isRTL ? umValue.reverse() : umValue).join("");
  904. if (unmaskedValue !== null) {
  905. var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  906. $.isFunction(opts.onUnMask) && (unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts) || unmaskedValue);
  907. }
  908. return unmaskedValue;
  909. }
  910. function caret (input, begin, end, notranslate) {
  911. function translatePosition (pos) {
  912. if (notranslate !== !0 && isRTL && typeof pos === "number" && (!opts.greedy || opts.placeholder !== "")) {
  913. var bffrLght = getBuffer().join("").length;
  914. pos = bffrLght - pos;
  915. }
  916. return pos;
  917. }
  918. var range;
  919. if (typeof begin !== "number") {
  920. return input.setSelectionRange ? (begin = input.selectionStart,
  921. end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0),
  922. (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) && (begin = range.startOffset,
  923. end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  924. begin = 0 - range.duplicate().moveStart("character", -1e5), end = begin + range.text.length),
  925. {
  926. begin: translatePosition(begin),
  927. end: translatePosition(end),
  928. };
  929. }
  930. begin = translatePosition(begin), end = translatePosition(end), end = typeof end === "number" ? end : begin;
  931. var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
  932. if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, mobile || opts.insertMode !== !1 || begin !== end || end++,
  933. input.setSelectionRange) {
  934. input.selectionStart = begin, input.selectionEnd = end;
  935. } else if (window.getSelection) {
  936. if (range = document.createRange(), void 0 === input.firstChild || input.firstChild === null) {
  937. var textNode = document.createTextNode("");
  938. input.appendChild(textNode);
  939. }
  940. range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length),
  941. range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length),
  942. range.collapse(!0);
  943. var sel = window.getSelection();
  944. sel.removeAllRanges(), sel.addRange(range);
  945. } else {
  946. input.createTextRange && (range = input.createTextRange(), range.collapse(!0),
  947. range.moveEnd("character", end), range.moveStart("character", begin), range.select());
  948. }
  949. }
  950. function determineLastRequiredPosition (returnDefinition) {
  951. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== lvTest ? lvTest.locator.slice() : void 0;
  952. for (pos = lvp + 1; pos < buffer.length; pos++) {
  953. testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  954. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  955. }
  956. var lvTestAlt = lvTest && void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation] : void 0;
  957. for (pos = bl - 1; pos > lvp && (testPos = positions[pos], (testPos.match.optionality || testPos.match.optionalQuantifier || lvTestAlt && (lvTestAlt !== positions[pos].locator[lvTest.alternation] && testPos.match.fn != null || testPos.match.fn === null && 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--) {
  958. bl--;
  959. }
  960. return returnDefinition ? {
  961. l: bl,
  962. def: positions[bl] ? positions[bl].match : void 0,
  963. } : bl;
  964. }
  965. function clearOptionalTail (buffer) {
  966. for (var rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) {}
  967. return buffer.splice(rl, lmib + 1 - rl), buffer;
  968. }
  969. function isComplete (buffer) {
  970. if ($.isFunction(opts.isComplete)) {
  971. return opts.isComplete(buffer, opts);
  972. }
  973. if (opts.repeat === "*") {
  974. return void 0;
  975. }
  976. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
  977. if (void 0 === lrp.def || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
  978. complete = !0;
  979. for (var i = 0; aml >= i; i++) {
  980. var test = getTestTemplate(i).match;
  981. if (test.fn !== null && void 0 === getMaskSet().validPositions[i] && test.optionality !== !0 && test.optionalQuantifier !== !0 || test.fn === null && buffer[i] !== getPlaceholder(i, test)) {
  982. complete = !1;
  983. break;
  984. }
  985. }
  986. }
  987. return complete;
  988. }
  989. function isSelection (begin, end) {
  990. return isRTL ? begin - end > 1 || begin - end === 1 && opts.insertMode : end - begin > 1 || end - begin === 1 && opts.insertMode;
  991. }
  992. function patchValueProperty (npt) {
  993. function patchValhook (type) {
  994. if ($.valHooks && (void 0 === $.valHooks[type] || $.valHooks[type].inputmaskpatch !== !0)) {
  995. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function (elem) {
  996. return elem.value;
  997. }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function (elem, value) {
  998. return elem.value = value, elem;
  999. };
  1000. $.valHooks[type] = {
  1001. get: function (elem) {
  1002. if (elem.inputmask) {
  1003. if (elem.inputmask.opts.autoUnmask) {
  1004. return elem.inputmask.unmaskedvalue();
  1005. }
  1006. var result = valhookGet(elem), maskset = elem.inputmask.maskset, bufferTemplate = maskset._buffer;
  1007. return bufferTemplate = bufferTemplate ? bufferTemplate.join("") : "", result !== bufferTemplate ? result : "";
  1008. }
  1009. return valhookGet(elem);
  1010. },
  1011. set: function (elem, value) {
  1012. var result, $elem = $(elem);
  1013. return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue"),
  1014. result;
  1015. },
  1016. inputmaskpatch: !0,
  1017. };
  1018. }
  1019. }
  1020. function getter () {
  1021. 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);
  1022. }
  1023. function setter (value) {
  1024. valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue");
  1025. }
  1026. function installNativeValueSetFallback (npt) {
  1027. EventRuler.on(npt, "mouseenter", function (event) {
  1028. var $input = $(this), input = this, value = input.inputmask._valueGet();
  1029. value !== getBuffer().join("") && getLastValidPosition() > 0 && $input.trigger("setvalue");
  1030. });
  1031. }
  1032. var valueGet, valueSet;
  1033. npt.inputmask.__valueGet || (Object.getOwnPropertyDescriptor && void 0 === npt.value ? (valueGet = function () {
  1034. return this.textContent;
  1035. }, valueSet = function (value) {
  1036. this.textContent = value;
  1037. }, Object.defineProperty(npt, "value", {
  1038. get: getter,
  1039. set: setter,
  1040. })) : document.__lookupGetter__ && npt.__lookupGetter__("value") ? (valueGet = npt.__lookupGetter__("value"),
  1041. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  1042. npt.__defineSetter__("value", setter)) : (valueGet = function () {
  1043. return npt.value;
  1044. }, valueSet = function (value) {
  1045. npt.value = value;
  1046. }, patchValhook(npt.type), installNativeValueSetFallback(npt)), npt.inputmask.__valueGet = valueGet,
  1047. npt.inputmask._valueGet = function (overruleRTL) {
  1048. return isRTL && overruleRTL !== !0 ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
  1049. }, npt.inputmask.__valueSet = valueSet, npt.inputmask._valueSet = function (value, overruleRTL) {
  1050. valueSet.call(this.el, value === null || void 0 === value ? "" : overruleRTL !== !0 && isRTL ? value.split("").reverse().join("") : value);
  1051. });
  1052. }
  1053. function handleRemove (input, k, pos, strict) {
  1054. function generalize () {
  1055. if (opts.keepStatic) {
  1056. resetMaskSet(!0);
  1057. var lastAlt, validInputs = [], positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  1058. for (lastAlt = getLastValidPosition(); lastAlt >= 0; lastAlt--) {
  1059. var validPos = getMaskSet().validPositions[lastAlt];
  1060. if (validPos && (validPos.match.fn != null && validInputs.push(validPos.input),
  1061. delete getMaskSet().validPositions[lastAlt], void 0 !== validPos.alternation && validPos.locator[validPos.alternation] === getTestTemplate(lastAlt).locator[validPos.alternation])) {
  1062. break;
  1063. }
  1064. }
  1065. if (lastAlt > -1) {
  1066. for (;validInputs.length > 0; ) {
  1067. getMaskSet().p = seekNext(getLastValidPosition());
  1068. var keypress = new $.Event("keypress");
  1069. keypress.which = validInputs.pop().charCodeAt(0), keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  1070. }
  1071. } else {
  1072. getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
  1073. }
  1074. }
  1075. }
  1076. if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE),
  1077. isRTL)) {
  1078. var pend = pos.end;
  1079. pos.end = pos.begin, pos.begin = pend;
  1080. }
  1081. k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === !1) ? (pos.begin = seekPrevious(pos.begin),
  1082. 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,
  1083. void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++),
  1084. stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0 && generalize();
  1085. var lvp = getLastValidPosition(pos.begin);
  1086. lvp < pos.begin ? (lvp === -1 && resetMaskSet(), getMaskSet().p = seekNext(lvp)) : strict !== !0 && (getMaskSet().p = pos.begin);
  1087. }
  1088. function keydownEvent (e) {
  1089. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  1090. if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === 127 || e.ctrlKey && k === 88 && !isInputEventSupported("cut")) {
  1091. e.preventDefault(),
  1092. k === 88 && (undoValue = getBuffer().join("")), handleRemove(input, k, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  1093. input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  1094. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
  1095. } else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) {
  1096. e.preventDefault();
  1097. var caretPos = seekNext(getLastValidPosition());
  1098. opts.insertMode || caretPos !== getMaskLength() || e.shiftKey || caretPos--, caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0);
  1099. } else {
  1100. k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(),
  1101. caret(input, 0, e.shiftKey ? pos.begin : 0, !0)) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || k === 90 && e.ctrlKey) && e.altKey !== !0 ? (checkVal(input, !0, !1, undoValue.split("")),
  1102. $input.trigger("click")) : k !== Inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? opts.tabThrough === !0 && k === Inputmask.keyCode.TAB ? (e.shiftKey === !0 ? (getTest(pos.begin).fn === null && (pos.begin = seekNext(pos.begin)),
  1103. pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
  1104. pos.end = seekNext(pos.begin, !0), pos.end < getMaskLength() && pos.end--), pos.begin < getMaskLength() && (e.preventDefault(),
  1105. caret(input, pos.begin, pos.end))) : opts.insertMode !== !1 || e.shiftKey || (k === Inputmask.keyCode.RIGHT ? setTimeout(function () {
  1106. var caretPos = caret(input);
  1107. caret(input, caretPos.begin);
  1108. }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function () {
  1109. var caretPos = caret(input);
  1110. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  1111. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskLength() ? pos.begin : pos.begin - 1));
  1112. }
  1113. opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = $.inArray(k, opts.ignorables) !== -1;
  1114. }
  1115. function keypressEvent (e, checkval, writeOut, strict, ndx) {
  1116. var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
  1117. if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) {
  1118. return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
  1119. setTimeout(function () {
  1120. $input.trigger("change");
  1121. }, 0)), !0;
  1122. }
  1123. if (k) {
  1124. k === 46 && e.shiftKey === !1 && opts.radixPoint === "," && (k = 44);
  1125. var forwardPosition, pos = checkval ? {
  1126. begin: ndx,
  1127. end: ndx,
  1128. } : caret(input), c = String.fromCharCode(k), isSlctn = isSelection(pos.begin, pos.end);
  1129. isSlctn && (getMaskSet().undoPositions = $.extend(!0, {}, getMaskSet().validPositions),
  1130. handleRemove(input, Inputmask.keyCode.DELETE, pos, !0), pos.begin = getMaskSet().p,
  1131. opts.insertMode || (opts.insertMode = !opts.insertMode, setValidPosition(pos.begin, strict),
  1132. opts.insertMode = !opts.insertMode), isSlctn = !opts.multi), getMaskSet().writeOutBuffer = !0;
  1133. var p = isRTL && !isSlctn ? pos.end : pos.begin, valResult = isValid(p, c, strict);
  1134. if (valResult !== !1) {
  1135. if (valResult !== !0 && (p = void 0 !== valResult.pos ? valResult.pos : p, c = void 0 !== valResult.c ? valResult.c : c),
  1136. resetMaskSet(!0), void 0 !== valResult.caret) {
  1137. forwardPosition = valResult.caret;
  1138. } else {
  1139. var vps = getMaskSet().validPositions;
  1140. 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);
  1141. }
  1142. getMaskSet().p = forwardPosition;
  1143. }
  1144. if (writeOut !== !1) {
  1145. var self = this;
  1146. if (setTimeout(function () {
  1147. opts.onKeyValidation.call(self, k, valResult, opts);
  1148. }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
  1149. var buffer = getBuffer();
  1150. writeBuffer(input, buffer, opts.numericInput && void 0 === valResult.caret ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
  1151. checkval !== !0 && setTimeout(function () {
  1152. isComplete(buffer) === !0 && $input.trigger("complete");
  1153. }, 0);
  1154. } else {
  1155. isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  1156. }
  1157. } else {
  1158. isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  1159. }
  1160. if (opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask), checkval && $.isFunction(opts.onBeforeWrite)) {
  1161. var result = opts.onBeforeWrite(e, getBuffer(), forwardPosition, opts);
  1162. if (result && result.refreshFromBuffer) {
  1163. var refresh = result.refreshFromBuffer;
  1164. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer),
  1165. resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret);
  1166. }
  1167. }
  1168. if (e.preventDefault(), checkval) {
  1169. return valResult;
  1170. }
  1171. }
  1172. }
  1173. function pasteEvent (e) {
  1174. var input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input), valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
  1175. valueBeforeCaret === getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
  1176. valueAfterCaret === getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""),
  1177. 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);
  1178. var pasteValue = inputValue;
  1179. if ($.isFunction(opts.onBeforePaste)) {
  1180. if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) {
  1181. return e.preventDefault(),
  1182. !1;
  1183. }
  1184. pasteValue || (pasteValue = inputValue);
  1185. }
  1186. return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
  1187. writeBuffer(input, getBuffer(), void 0, e, !0), $input.trigger("click"), isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  1188. !1;
  1189. }
  1190. function inputFallBackEvent (e) {
  1191. var input = this, inputValue = input.inputmask._valueGet();
  1192. if (getBuffer().join("") !== inputValue) {
  1193. var caretPos = caret(input);
  1194. if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
  1195. iemobile) {
  1196. var inputChar = inputValue.replace(getBuffer().join(""), "");
  1197. if (inputChar.length === 1) {
  1198. var keypress = new $.Event("keypress");
  1199. return keypress.which = inputChar.charCodeAt(0), keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1),
  1200. !1;
  1201. }
  1202. }
  1203. if (caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input)),
  1204. getBuffer().length - inputValue.length !== 1 || inputValue.charAt(caretPos.begin) === getBuffer()[caretPos.begin] || inputValue.charAt(caretPos.begin + 1) === getBuffer()[caretPos.begin] || isMask(caretPos.begin)) {
  1205. for (var lvp = getLastValidPosition() + 1, bufferTemplate = getBuffer().slice(lvp).join(""); inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$") === null; ) {
  1206. bufferTemplate = bufferTemplate.slice(1);
  1207. }
  1208. inputValue = inputValue.replace(bufferTemplate, ""), inputValue = inputValue.split(""),
  1209. checkVal(input, !0, !1, inputValue), isComplete(getBuffer()) === !0 && $(input).trigger("complete");
  1210. } else {
  1211. e.keyCode = Inputmask.keyCode.BACKSPACE, keydownEvent.call(input, e);
  1212. }
  1213. e.preventDefault();
  1214. }
  1215. }
  1216. function compositionStartEvent (e) {
  1217. var ev = e.originalEvent || e;
  1218. undoValue = getBuffer().join(""), compositionData === "" || ev.data.indexOf(compositionData) !== 0;
  1219. }
  1220. function compositionUpdateEvent (e) {
  1221. var input = this, ev = e.originalEvent || e, inputBuffer = getBuffer().join("");
  1222. ev.data.indexOf(compositionData) === 0 && (resetMaskSet(), getMaskSet().p = seekNext(-1));
  1223. for (var newData = ev.data, i = 0; i < newData.length; i++) {
  1224. var keypress = new $.Event("keypress");
  1225. keypress.which = newData.charCodeAt(i), skipKeyPressEvent = !1, ignorable = !1,
  1226. keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  1227. }
  1228. inputBuffer !== getBuffer().join("") && setTimeout(function () {
  1229. var forwardPosition = getMaskSet().p;
  1230. writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
  1231. }, 0), compositionData = ev.data;
  1232. }
  1233. function compositionEndEvent (e) {}
  1234. function setValueEvent (e) {
  1235. var input = this, value = input.inputmask._valueGet();
  1236. checkVal(input, !0, !1, ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(value, opts) || value : value).split("")),
  1237. undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
  1238. }
  1239. function focusEvent (e) {
  1240. var input = this, nptValue = input.inputmask._valueGet();
  1241. opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && nptValue === "") ? input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition())),
  1242. opts.positionCaretOnTab === !0 && setTimeout(function () {
  1243. caret(input, seekNext(getLastValidPosition()));
  1244. }, 0), undoValue = getBuffer().join("");
  1245. }
  1246. function mouseleaveEvent (e) {
  1247. var input = this;
  1248. if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== input) {
  1249. var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
  1250. nptValue !== input.getAttribute("placeholder") && nptValue !== "" && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
  1251. writeBuffer(input, buffer));
  1252. }
  1253. }
  1254. function clickEvent (e) {
  1255. function doRadixFocus (clickPos) {
  1256. if (opts.radixFocus && opts.radixPoint !== "") {
  1257. var vps = getMaskSet().validPositions;
  1258. if (void 0 === vps[clickPos] || vps[clickPos].input === getPlaceholder(clickPos)) {
  1259. if (clickPos < seekNext(-1)) {
  1260. return !0;
  1261. }
  1262. var radixPos = $.inArray(opts.radixPoint, getBuffer());
  1263. if (radixPos !== -1) {
  1264. for (var vp in vps) {
  1265. if (vp > radixPos && vps[vp].input !== getPlaceholder(vp)) {
  1266. return !1;
  1267. }
  1268. }
  1269. return !0;
  1270. }
  1271. }
  1272. }
  1273. return !1;
  1274. }
  1275. var input = this;
  1276. if (document.activeElement === input) {
  1277. var selectedCaret = caret(input);
  1278. if (selectedCaret.begin === selectedCaret.end) {
  1279. if (doRadixFocus(selectedCaret.begin)) {
  1280. caret(input, opts.numericInput ? seekNext($.inArray(opts.radixPoint, getBuffer())) : $.inArray(opts.radixPoint, getBuffer()));
  1281. } else {
  1282. var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
  1283. 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)),
  1284. caret(input, lastPosition));
  1285. }
  1286. }
  1287. }
  1288. }
  1289. function dblclickEvent (e) {
  1290. var input = this;
  1291. setTimeout(function () {
  1292. caret(input, 0, seekNext(getLastValidPosition()));
  1293. }, 0);
  1294. }
  1295. function cutEvent (e) {
  1296. 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);
  1297. clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
  1298. document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
  1299. writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  1300. input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"),
  1301. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
  1302. }
  1303. function blurEvent (e) {
  1304. var $input = $(this), input = this;
  1305. if (input.inputmask) {
  1306. var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
  1307. undoValue !== buffer.join("") && setTimeout(function () {
  1308. $input.trigger("change"), undoValue = buffer.join("");
  1309. }, 0), nptValue !== "" && (opts.clearMaskOnLostFocus && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1310. isComplete(buffer) === !1 && (setTimeout(function () {
  1311. $input.trigger("incomplete");
  1312. }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
  1313. writeBuffer(input, buffer, void 0, e));
  1314. }
  1315. }
  1316. function mouseenterEvent (e) {
  1317. var input = this;
  1318. mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
  1319. }
  1320. function submitEvent (e) {
  1321. undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && getLastValidPosition() === -1 && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
  1322. opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
  1323. setTimeout(function () {
  1324. writeBuffer(el, getBuffer());
  1325. }, 0));
  1326. }
  1327. function resetEvent (e) {
  1328. setTimeout(function () {
  1329. $el.trigger("setvalue");
  1330. }, 0);
  1331. }
  1332. function mask (elem) {
  1333. if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask),
  1334. (el.dir === "rtl" || opts.rightAlign) && (el.style.textAlign = "right"), (el.dir === "rtl" || opts.numericInput) && (el.dir = "ltr",
  1335. el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), EventRuler.off(el),
  1336. patchValueProperty(el), isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent),
  1337. EventRuler.on(el, "reset", resetEvent), EventRuler.on(el, "mouseenter", mouseenterEvent),
  1338. EventRuler.on(el, "blur", blurEvent), EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent),
  1339. EventRuler.on(el, "click", clickEvent), EventRuler.on(el, "dblclick", dblclickEvent),
  1340. EventRuler.on(el, "paste", pasteEvent), EventRuler.on(el, "dragdrop", pasteEvent),
  1341. EventRuler.on(el, "drop", pasteEvent), EventRuler.on(el, "cut", cutEvent), EventRuler.on(el, "complete", opts.oncomplete),
  1342. EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared),
  1343. EventRuler.on(el, "keydown", keydownEvent), EventRuler.on(el, "keypress", keypressEvent),
  1344. EventRuler.on(el, "input", inputFallBackEvent), mobile || (EventRuler.on(el, "compositionstart", compositionStartEvent),
  1345. EventRuler.on(el, "compositionupdate", compositionUpdateEvent), EventRuler.on(el, "compositionend", compositionEndEvent))),
  1346. EventRuler.on(el, "setvalue", setValueEvent), el.inputmask._valueGet() !== "" || opts.clearMaskOnLostFocus === !1) {
  1347. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
  1348. checkVal(el, !0, !1, initialValue.split(""));
  1349. var buffer = getBuffer().slice();
  1350. undoValue = buffer.join(""), isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(),
  1351. opts.clearMaskOnLostFocus && (buffer.join("") === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1352. writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
  1353. }
  1354. }
  1355. var undoValue, compositionData, el, $el, maxLength, valueBuffer, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !0, inComposition = !1, EventRuler = {
  1356. on: function (input, eventName, eventHandler) {
  1357. var ev = function (e) {
  1358. if (void 0 === this.inputmask && this.nodeName !== "FORM") {
  1359. var imOpts = $.data(this, "_inputmask_opts");
  1360. imOpts ? new Inputmask(imOpts).mask(this) : EventRuler.off(this);
  1361. } else {
  1362. if (e.type === "setvalue" || !(this.disabled || this.readOnly && !(e.type === "keydown" && e.ctrlKey && e.keyCode === 67 || opts.tabThrough === !1 && e.keyCode === Inputmask.keyCode.TAB))) {
  1363. switch (e.type) {
  1364. case "input":
  1365. if (skipInputEvent === !0 || inComposition === !0) {
  1366. return skipInputEvent = inComposition,
  1367. e.preventDefault();
  1368. }
  1369. break;
  1370. case "keydown":
  1371. skipKeyPressEvent = !1, skipInputEvent = !1, inComposition = !1;
  1372. break;
  1373. case "keypress":
  1374. if (skipKeyPressEvent === !0) {
  1375. return e.preventDefault();
  1376. }
  1377. skipKeyPressEvent = !0;
  1378. break;
  1379. case "compositionstart":
  1380. inComposition = !0;
  1381. break;
  1382. case "compositionupdate":
  1383. skipInputEvent = !0;
  1384. break;
  1385. case "compositionend":
  1386. inComposition = !1;
  1387. break;
  1388. case "cut":
  1389. skipInputEvent = !0;
  1390. break;
  1391. case "click":
  1392. if (iemobile) {
  1393. var that = this;
  1394. return setTimeout(function () {
  1395. eventHandler.apply(that, arguments);
  1396. }, 0), !1;
  1397. }
  1398. }
  1399. return eventHandler.apply(this, arguments);
  1400. }
  1401. e.preventDefault();
  1402. }
  1403. };
  1404. input.inputmask.events[eventName] = input.inputmask.events[eventName] || [], input.inputmask.events[eventName].push(ev),
  1405. $.inArray(eventName, [ "submit", "reset" ]) !== -1 ? input.form != null && $(input.form).on(eventName, ev) : $(input).on(eventName, ev);
  1406. },
  1407. off: function (input, event) {
  1408. if (input.inputmask && input.inputmask.events) {
  1409. var events;
  1410. event ? (events = [], events[event] = input.inputmask.events[event]) : events = input.inputmask.events,
  1411. $.each(events, function (eventName, evArr) {
  1412. for (;evArr.length > 0; ) {
  1413. var ev = evArr.pop();
  1414. $.inArray(eventName, [ "submit", "reset" ]) !== -1 ? input.form != null && $(input.form).off(eventName, ev) : $(input).off(eventName, ev);
  1415. }
  1416. delete input.inputmask.events[eventName];
  1417. });
  1418. }
  1419. },
  1420. };
  1421. if (void 0 !== actionObj) {
  1422. switch (actionObj.action) {
  1423. case "isComplete":
  1424. return el = actionObj.el, isComplete(getBuffer());
  1425. case "unmaskedvalue":
  1426. return el = actionObj.el, void 0 !== el && void 0 !== el.inputmask ? (maskset = el.inputmask.maskset,
  1427. opts = el.inputmask.opts, isRTL = el.inputmask.isRTL) : (valueBuffer = actionObj.value,
  1428. opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
  1429. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts)),
  1430. unmaskedvalue(el);
  1431. case "mask":
  1432. el = actionObj.el, maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL,
  1433. undoValue = getBuffer().join(""), mask(el);
  1434. break;
  1435. case "format":
  1436. return opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
  1437. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts),
  1438. actionObj.metadata ? {
  1439. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  1440. metadata: maskScope({
  1441. action: "getmetadata",
  1442. }, maskset, opts),
  1443. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  1444. case "isValid":
  1445. opts.numericInput && (isRTL = !0), actionObj.value ? (valueBuffer = actionObj.value.split(""),
  1446. checkVal(void 0, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
  1447. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) {}
  1448. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
  1449. case "getemptymask":
  1450. return getBufferTemplate();
  1451. case "remove":
  1452. el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts,
  1453. el.inputmask._valueSet(unmaskedvalue(el)), EventRuler.off(el);
  1454. var valueProperty;
  1455. Object.getOwnPropertyDescriptor && (valueProperty = Object.getOwnPropertyDescriptor(el, "value")),
  1456. valueProperty && valueProperty.get ? el.inputmask.__valueGet && Object.defineProperty(el, "value", {
  1457. get: el.inputmask.__valueGet,
  1458. set: el.inputmask.__valueSet,
  1459. }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
  1460. el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = void 0;
  1461. break;
  1462. case "getmetadata":
  1463. if ($.isArray(maskset.metadata)) {
  1464. for (var alternation, lvp = getLastValidPosition(), firstAlt = lvp; firstAlt >= 0; firstAlt--) {
  1465. if (getMaskSet().validPositions[firstAlt] && void 0 !== getMaskSet().validPositions[firstAlt].alternation) {
  1466. alternation = getMaskSet().validPositions[firstAlt].alternation;
  1467. break;
  1468. }
  1469. }
  1470. return void 0 !== alternation ? maskset.metadata[getMaskSet().validPositions[lvp].locator[alternation]] : maskset.metadata[0];
  1471. }
  1472. return maskset.metadata;
  1473. }
  1474. }
  1475. }
  1476. Inputmask.prototype = {
  1477. defaults: {
  1478. placeholder: "_",
  1479. optionalmarker: {
  1480. start: "[",
  1481. end: "]",
  1482. },
  1483. quantifiermarker: {
  1484. start: "{",
  1485. end: "}",
  1486. },
  1487. groupmarker: {
  1488. start: "(",
  1489. end: ")",
  1490. },
  1491. alternatormarker: "|",
  1492. escapeChar: "\\",
  1493. mask: null,
  1494. oncomplete: $.noop,
  1495. onincomplete: $.noop,
  1496. oncleared: $.noop,
  1497. repeat: 0,
  1498. greedy: !0,
  1499. autoUnmask: !1,
  1500. removeMaskOnSubmit: !1,
  1501. clearMaskOnLostFocus: !0,
  1502. insertMode: !0,
  1503. clearIncomplete: !1,
  1504. aliases: {},
  1505. alias: null,
  1506. onKeyDown: $.noop,
  1507. onBeforeMask: null,
  1508. onBeforePaste: function (pastedValue, opts) {
  1509. return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(pastedValue, opts) : pastedValue;
  1510. },
  1511. onBeforeWrite: null,
  1512. onUnMask: null,
  1513. showMaskOnFocus: !0,
  1514. showMaskOnHover: !0,
  1515. onKeyValidation: $.noop,
  1516. skipOptionalPartCharacter: " ",
  1517. showTooltip: !1,
  1518. tooltip: void 0,
  1519. numericInput: !1,
  1520. rightAlign: !1,
  1521. undoOnEscape: !0,
  1522. radixPoint: "",
  1523. groupSeparator: "",
  1524. radixFocus: !1,
  1525. nojumps: !1,
  1526. nojumpsThreshold: 0,
  1527. keepStatic: null,
  1528. positionCaretOnTab: !1,
  1529. tabThrough: !1,
  1530. supportsInputType: [ "text", "tel", "password" ],
  1531. definitions: {
  1532. "9": {
  1533. validator: "[0-9]",
  1534. cardinality: 1,
  1535. definitionSymbol: "*",
  1536. },
  1537. a: {
  1538. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1539. cardinality: 1,
  1540. definitionSymbol: "*",
  1541. },
  1542. "*": {
  1543. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1544. cardinality: 1,
  1545. },
  1546. },
  1547. 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 ],
  1548. isComplete: null,
  1549. canClearPosition: $.noop,
  1550. postValidation: null,
  1551. staticDefinitionSymbol: void 0,
  1552. jitMasking: !1,
  1553. },
  1554. masksCache: {},
  1555. mask: function (elems) {
  1556. var that = this;
  1557. return typeof elems === "string" && (elems = document.getElementById(elems) || document.querySelectorAll(elems)),
  1558. elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function (ndx, el) {
  1559. var scopedOpts = $.extend(!0, {}, that.opts);
  1560. importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
  1561. var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
  1562. void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(),
  1563. el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
  1564. el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts),
  1565. maskScope({
  1566. action: "mask",
  1567. el: el,
  1568. }));
  1569. }), elems && elems[0] ? elems[0].inputmask || this : this;
  1570. },
  1571. option: function (options) {
  1572. return typeof options === "string" ? this.opts[options] : typeof options === "object" ? ($.extend(this.opts, options),
  1573. $.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),
  1574. maskScope({
  1575. action: "mask",
  1576. el: this.el,
  1577. }))), this) : void 0;
  1578. },
  1579. unmaskedvalue: function (value) {
  1580. return maskScope({
  1581. action: "unmaskedvalue",
  1582. el: this.el,
  1583. value: value,
  1584. }, this.el && this.el.inputmask ? this.el.inputmask.maskset : generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1585. },
  1586. remove: function () {
  1587. return this.el ? (maskScope({
  1588. action: "remove",
  1589. el: this.el,
  1590. }), this.el.inputmask = void 0, this.el) : void 0;
  1591. },
  1592. getemptymask: function () {
  1593. return maskScope({
  1594. action: "getemptymask",
  1595. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1596. },
  1597. hasMaskedValue: function () {
  1598. return !this.opts.autoUnmask;
  1599. },
  1600. isComplete: function () {
  1601. return maskScope({
  1602. action: "isComplete",
  1603. el: this.el,
  1604. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1605. },
  1606. getmetadata: function () {
  1607. return maskScope({
  1608. action: "getmetadata",
  1609. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1610. },
  1611. isValid: function (value) {
  1612. return maskScope({
  1613. action: "isValid",
  1614. value: value,
  1615. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1616. },
  1617. format: function (value, metadata) {
  1618. return maskScope({
  1619. action: "format",
  1620. value: value,
  1621. metadata: metadata,
  1622. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1623. },
  1624. }, Inputmask.extendDefaults = function (options) {
  1625. $.extend(!0, Inputmask.prototype.defaults, options);
  1626. }, Inputmask.extendDefinitions = function (definition) {
  1627. $.extend(!0, Inputmask.prototype.defaults.definitions, definition);
  1628. }, Inputmask.extendAliases = function (alias) {
  1629. $.extend(!0, Inputmask.prototype.defaults.aliases, alias);
  1630. }, Inputmask.format = function (value, options, metadata) {
  1631. return Inputmask(options).format(value, metadata);
  1632. }, Inputmask.unmask = function (value, options) {
  1633. return Inputmask(options).unmaskedvalue(value);
  1634. }, Inputmask.isValid = function (value, options) {
  1635. return Inputmask(options).isValid(value);
  1636. }, Inputmask.remove = function (elems) {
  1637. $.each(elems, function (ndx, el) {
  1638. el.inputmask && el.inputmask.remove();
  1639. });
  1640. }, Inputmask.escapeRegex = function (str) {
  1641. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
  1642. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1643. }, Inputmask.keyCode = {
  1644. ALT: 18,
  1645. BACKSPACE: 8,
  1646. CAPS_LOCK: 20,
  1647. COMMA: 188,
  1648. COMMAND: 91,
  1649. COMMAND_LEFT: 91,
  1650. COMMAND_RIGHT: 93,
  1651. CONTROL: 17,
  1652. DELETE: 46,
  1653. DOWN: 40,
  1654. END: 35,
  1655. ENTER: 13,
  1656. ESCAPE: 27,
  1657. HOME: 36,
  1658. INSERT: 45,
  1659. LEFT: 37,
  1660. MENU: 93,
  1661. NUMPAD_ADD: 107,
  1662. NUMPAD_DECIMAL: 110,
  1663. NUMPAD_DIVIDE: 111,
  1664. NUMPAD_ENTER: 108,
  1665. NUMPAD_MULTIPLY: 106,
  1666. NUMPAD_SUBTRACT: 109,
  1667. PAGE_DOWN: 34,
  1668. PAGE_UP: 33,
  1669. PERIOD: 190,
  1670. RIGHT: 39,
  1671. SHIFT: 16,
  1672. SPACE: 32,
  1673. TAB: 9,
  1674. UP: 38,
  1675. WINDOWS: 91,
  1676. };
  1677. var ua = navigator.userAgent, mobile = (/mobile/i).test(ua), iemobile = (/iemobile/i).test(ua), iphone = (/iphone/i).test(ua) && !iemobile;
  1678. (/android.*safari.*/i).test(ua) && !iemobile;
  1679. return window.Inputmask = Inputmask, Inputmask;
  1680. }(jQuery)), (function ($, Inputmask) {
  1681. return void 0 === $.fn.inputmask && ($.fn.inputmask = function (fn, options) {
  1682. var nptmask, input = this[0];
  1683. if (options = options || {}, typeof fn === "string") {
  1684. switch (fn) {
  1685. case "unmaskedvalue":
  1686. return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
  1687. case "remove":
  1688. return this.each(function () {
  1689. this.inputmask && this.inputmask.remove();
  1690. });
  1691. case "getemptymask":
  1692. return input && input.inputmask ? input.inputmask.getemptymask() : "";
  1693. case "hasMaskedValue":
  1694. return input && input.inputmask ? input.inputmask.hasMaskedValue() : !1;
  1695. case "isComplete":
  1696. return input && input.inputmask ? input.inputmask.isComplete() : !0;
  1697. case "getmetadata":
  1698. return input && input.inputmask ? input.inputmask.getmetadata() : void 0;
  1699. case "setvalue":
  1700. $(input).val(options), input && void 0 !== input.inputmask && $(input).triggerHandler("setvalue");
  1701. break;
  1702. case "option":
  1703. if (typeof options !== "string") {
  1704. return this.each(function () {
  1705. return void 0 !== this.inputmask ? this.inputmask.option(options) : void 0;
  1706. });
  1707. }
  1708. if (input && void 0 !== input.inputmask) {
  1709. return input.inputmask.option(options);
  1710. }
  1711. break;
  1712. default:
  1713. return options.alias = fn, nptmask = new Inputmask(options), this.each(function () {
  1714. nptmask.mask(this);
  1715. });
  1716. }
  1717. } else {
  1718. if (typeof fn === "object") {
  1719. return nptmask = new Inputmask(fn), void 0 === fn.mask && void 0 === fn.alias ? this.each(function () {
  1720. return void 0 !== this.inputmask ? this.inputmask.option(fn) : void nptmask.mask(this);
  1721. }) : this.each(function () {
  1722. nptmask.mask(this);
  1723. });
  1724. }
  1725. if (void 0 === fn) {
  1726. return this.each(function () {
  1727. nptmask = new Inputmask(options), nptmask.mask(this);
  1728. });
  1729. }
  1730. }
  1731. }), $.fn.inputmask;
  1732. }(jQuery, Inputmask)), (function ($, Inputmask) {
  1733. return Inputmask.extendDefinitions({
  1734. h: {
  1735. validator: "[01][0-9]|2[0-3]",
  1736. cardinality: 2,
  1737. prevalidator: [ {
  1738. validator: "[0-2]",
  1739. cardinality: 1,
  1740. } ],
  1741. },
  1742. s: {
  1743. validator: "[0-5][0-9]",
  1744. cardinality: 2,
  1745. prevalidator: [ {
  1746. validator: "[0-5]",
  1747. cardinality: 1,
  1748. } ],
  1749. },
  1750. d: {
  1751. validator: "0[1-9]|[12][0-9]|3[01]",
  1752. cardinality: 2,
  1753. prevalidator: [ {
  1754. validator: "[0-3]",
  1755. cardinality: 1,
  1756. } ],
  1757. },
  1758. m: {
  1759. validator: "0[1-9]|1[012]",
  1760. cardinality: 2,
  1761. prevalidator: [ {
  1762. validator: "[01]",
  1763. cardinality: 1,
  1764. } ],
  1765. },
  1766. y: {
  1767. validator: "(19|20)\\d{2}",
  1768. cardinality: 4,
  1769. prevalidator: [ {
  1770. validator: "[12]",
  1771. cardinality: 1,
  1772. }, {
  1773. validator: "(19|20)",
  1774. cardinality: 2,
  1775. }, {
  1776. validator: "(19|20)\\d",
  1777. cardinality: 3,
  1778. } ],
  1779. },
  1780. }), Inputmask.extendAliases({
  1781. "dd/mm/yyyy": {
  1782. mask: "1/2/y",
  1783. placeholder: "dd/mm/yyyy",
  1784. regex: {
  1785. val1pre: new RegExp("[0-3]"),
  1786. val1: new RegExp("0[1-9]|[12][0-9]|3[01]"),
  1787. val2pre: function (separator) {
  1788. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1789. return new RegExp("((0[1-9]|[12][0-9]|3[01])" + escapedSeparator + "[01])");
  1790. },
  1791. val2: function (separator) {
  1792. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1793. return new RegExp("((0[1-9]|[12][0-9])" + escapedSeparator + "(0[1-9]|1[012]))|(30" + escapedSeparator + "(0[13-9]|1[012]))|(31" + escapedSeparator + "(0[13578]|1[02]))");
  1794. },
  1795. },
  1796. leapday: "29/02/",
  1797. separator: "/",
  1798. yearrange: {
  1799. minyear: 1900,
  1800. maxyear: 2099,
  1801. },
  1802. isInYearRange: function (chrs, minyear, maxyear) {
  1803. if (isNaN(chrs)) {
  1804. return !1;
  1805. }
  1806. var enteredyear = parseInt(chrs.concat(minyear.toString().slice(chrs.length))), enteredyear2 = parseInt(chrs.concat(maxyear.toString().slice(chrs.length)));
  1807. return (isNaN(enteredyear) ? !1 : enteredyear >= minyear && maxyear >= enteredyear) || (isNaN(enteredyear2) ? !1 : enteredyear2 >= minyear && maxyear >= enteredyear2);
  1808. },
  1809. determinebaseyear: function (minyear, maxyear, hint) {
  1810. var currentyear = new Date().getFullYear();
  1811. if (minyear > currentyear) {
  1812. return minyear;
  1813. }
  1814. if (currentyear > maxyear) {
  1815. for (var maxYearPrefix = maxyear.toString().slice(0, 2), maxYearPostfix = maxyear.toString().slice(2, 4); maxYearPrefix + hint > maxyear; ) {
  1816. maxYearPrefix--;
  1817. }
  1818. var maxxYear = maxYearPrefix + maxYearPostfix;
  1819. return minyear > maxxYear ? minyear : maxxYear;
  1820. }
  1821. return currentyear;
  1822. },
  1823. onKeyDown: function (e, buffer, caretPos, opts) {
  1824. var $input = $(this);
  1825. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1826. var today = new Date();
  1827. $input.val(today.getDate().toString() + (today.getMonth() + 1).toString() + today.getFullYear().toString()),
  1828. $input.trigger("setvalue");
  1829. }
  1830. },
  1831. getFrontValue: function (mask, buffer, opts) {
  1832. for (var start = 0, length = 0, i = 0; i < mask.length && mask.charAt(i) !== "2"; i++) {
  1833. var definition = opts.definitions[mask.charAt(i)];
  1834. definition ? (start += length, length = definition.cardinality) : length++;
  1835. }
  1836. return buffer.join("").substr(start, length);
  1837. },
  1838. definitions: {
  1839. "1": {
  1840. validator: function (chrs, maskset, pos, strict, opts) {
  1841. var isValid = opts.regex.val1.test(chrs);
  1842. return strict || isValid || chrs.charAt(1) !== opts.separator && "-./".indexOf(chrs.charAt(1)) === -1 || !(isValid = opts.regex.val1.test("0" + chrs.charAt(0))) ? isValid : (maskset.buffer[pos - 1] = "0",
  1843. {
  1844. refreshFromBuffer: {
  1845. start: pos - 1,
  1846. end: pos,
  1847. },
  1848. pos: pos,
  1849. c: chrs.charAt(0),
  1850. });
  1851. },
  1852. cardinality: 2,
  1853. prevalidator: [ {
  1854. validator: function (chrs, maskset, pos, strict, opts) {
  1855. var pchrs = chrs;
  1856. isNaN(maskset.buffer[pos + 1]) || (pchrs += maskset.buffer[pos + 1]);
  1857. var isValid = pchrs.length === 1 ? opts.regex.val1pre.test(pchrs) : opts.regex.val1.test(pchrs);
  1858. if (!strict && !isValid) {
  1859. if (isValid = opts.regex.val1.test(chrs + "0")) {
  1860. return maskset.buffer[pos] = chrs,
  1861. maskset.buffer[++pos] = "0", {
  1862. pos: pos,
  1863. c: "0",
  1864. };
  1865. }
  1866. if (isValid = opts.regex.val1.test("0" + chrs)) {
  1867. return maskset.buffer[pos] = "0",
  1868. pos++, {
  1869. pos: pos,
  1870. };
  1871. }
  1872. }
  1873. return isValid;
  1874. },
  1875. cardinality: 1,
  1876. } ],
  1877. },
  1878. "2": {
  1879. validator: function (chrs, maskset, pos, strict, opts) {
  1880. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1881. frontValue.indexOf(opts.placeholder[0]) !== -1 && (frontValue = "01" + opts.separator);
  1882. var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
  1883. if (!strict && !isValid && (chrs.charAt(1) === opts.separator || "-./".indexOf(chrs.charAt(1)) !== -1) && (isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0)))) {
  1884. return maskset.buffer[pos - 1] = "0",
  1885. {
  1886. refreshFromBuffer: {
  1887. start: pos - 1,
  1888. end: pos,
  1889. },
  1890. pos: pos,
  1891. c: chrs.charAt(0),
  1892. };
  1893. }
  1894. if (opts.mask.indexOf("2") === opts.mask.length - 1 && isValid) {
  1895. var dayMonthValue = maskset.buffer.join("").substr(4, 4) + chrs;
  1896. if (dayMonthValue !== opts.leapday) {
  1897. return !0;
  1898. }
  1899. var year = parseInt(maskset.buffer.join("").substr(0, 4), 10);
  1900. return year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
  1901. }
  1902. return isValid;
  1903. },
  1904. cardinality: 2,
  1905. prevalidator: [ {
  1906. validator: function (chrs, maskset, pos, strict, opts) {
  1907. isNaN(maskset.buffer[pos + 1]) || (chrs += maskset.buffer[pos + 1]);
  1908. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1909. frontValue.indexOf(opts.placeholder[0]) !== -1 && (frontValue = "01" + opts.separator);
  1910. var isValid = chrs.length === 1 ? opts.regex.val2pre(opts.separator).test(frontValue + chrs) : opts.regex.val2(opts.separator).test(frontValue + chrs);
  1911. return strict || isValid || !(isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1912. pos++, {
  1913. pos: pos,
  1914. });
  1915. },
  1916. cardinality: 1,
  1917. } ],
  1918. },
  1919. y: {
  1920. validator: function (chrs, maskset, pos, strict, opts) {
  1921. if (opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1922. var dayMonthValue = maskset.buffer.join("").substr(0, 6);
  1923. if (dayMonthValue !== opts.leapday) {
  1924. return !0;
  1925. }
  1926. var year = parseInt(chrs, 10);
  1927. return year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
  1928. }
  1929. return !1;
  1930. },
  1931. cardinality: 4,
  1932. prevalidator: [ {
  1933. validator: function (chrs, maskset, pos, strict, opts) {
  1934. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1935. if (!strict && !isValid) {
  1936. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 1);
  1937. if (isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1938. return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1939. {
  1940. pos: pos,
  1941. };
  1942. }
  1943. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 2),
  1944. isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1945. return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1946. maskset.buffer[pos++] = yearPrefix.charAt(1), {
  1947. pos: pos,
  1948. };
  1949. }
  1950. }
  1951. return isValid;
  1952. },
  1953. cardinality: 1,
  1954. }, {
  1955. validator: function (chrs, maskset, pos, strict, opts) {
  1956. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1957. if (!strict && !isValid) {
  1958. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2);
  1959. if (isValid = opts.isInYearRange(chrs[0] + yearPrefix[1] + chrs[1], opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1960. return maskset.buffer[pos++] = yearPrefix.charAt(1),
  1961. {
  1962. pos: pos,
  1963. };
  1964. }
  1965. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2),
  1966. opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1967. var dayMonthValue = maskset.buffer.join("").substr(0, 6);
  1968. if (dayMonthValue !== opts.leapday) {
  1969. isValid = !0;
  1970. } else {
  1971. var year = parseInt(chrs, 10);
  1972. isValid = year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
  1973. }
  1974. } else {
  1975. isValid = !1;
  1976. }
  1977. if (isValid) {
  1978. return maskset.buffer[pos - 1] = yearPrefix.charAt(0), maskset.buffer[pos++] = yearPrefix.charAt(1),
  1979. maskset.buffer[pos++] = chrs.charAt(0), {
  1980. refreshFromBuffer: {
  1981. start: pos - 3,
  1982. end: pos,
  1983. },
  1984. pos: pos,
  1985. };
  1986. }
  1987. }
  1988. return isValid;
  1989. },
  1990. cardinality: 2,
  1991. }, {
  1992. validator: function (chrs, maskset, pos, strict, opts) {
  1993. return opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1994. },
  1995. cardinality: 3,
  1996. } ],
  1997. },
  1998. },
  1999. insertMode: !1,
  2000. autoUnmask: !1,
  2001. },
  2002. "mm/dd/yyyy": {
  2003. placeholder: "mm/dd/yyyy",
  2004. alias: "dd/mm/yyyy",
  2005. regex: {
  2006. val2pre: function (separator) {
  2007. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2008. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  2009. },
  2010. val2: function (separator) {
  2011. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2012. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[13-9]|1[012])" + escapedSeparator + "30)|((0[13578]|1[02])" + escapedSeparator + "31)");
  2013. },
  2014. val1pre: new RegExp("[01]"),
  2015. val1: new RegExp("0[1-9]|1[012]"),
  2016. },
  2017. leapday: "02/29/",
  2018. onKeyDown: function (e, buffer, caretPos, opts) {
  2019. var $input = $(this);
  2020. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  2021. var today = new Date();
  2022. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  2023. $input.trigger("setvalue");
  2024. }
  2025. },
  2026. },
  2027. "yyyy/mm/dd": {
  2028. mask: "y/1/2",
  2029. placeholder: "yyyy/mm/dd",
  2030. alias: "mm/dd/yyyy",
  2031. leapday: "/02/29",
  2032. onKeyDown: function (e, buffer, caretPos, opts) {
  2033. var $input = $(this);
  2034. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  2035. var today = new Date();
  2036. $input.val(today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDate().toString()),
  2037. $input.trigger("setvalue");
  2038. }
  2039. },
  2040. },
  2041. "dd.mm.yyyy": {
  2042. mask: "1.2.y",
  2043. placeholder: "dd.mm.yyyy",
  2044. leapday: "29.02.",
  2045. separator: ".",
  2046. alias: "dd/mm/yyyy",
  2047. },
  2048. "dd-mm-yyyy": {
  2049. mask: "1-2-y",
  2050. placeholder: "dd-mm-yyyy",
  2051. leapday: "29-02-",
  2052. separator: "-",
  2053. alias: "dd/mm/yyyy",
  2054. },
  2055. "mm.dd.yyyy": {
  2056. mask: "1.2.y",
  2057. placeholder: "mm.dd.yyyy",
  2058. leapday: "02.29.",
  2059. separator: ".",
  2060. alias: "mm/dd/yyyy",
  2061. },
  2062. "mm-dd-yyyy": {
  2063. mask: "1-2-y",
  2064. placeholder: "mm-dd-yyyy",
  2065. leapday: "02-29-",
  2066. separator: "-",
  2067. alias: "mm/dd/yyyy",
  2068. },
  2069. "yyyy.mm.dd": {
  2070. mask: "y.1.2",
  2071. placeholder: "yyyy.mm.dd",
  2072. leapday: ".02.29",
  2073. separator: ".",
  2074. alias: "yyyy/mm/dd",
  2075. },
  2076. "yyyy-mm-dd": {
  2077. mask: "y-1-2",
  2078. placeholder: "yyyy-mm-dd",
  2079. leapday: "-02-29",
  2080. separator: "-",
  2081. alias: "yyyy/mm/dd",
  2082. },
  2083. datetime: {
  2084. mask: "1/2/y h:s",
  2085. placeholder: "dd/mm/yyyy hh:mm",
  2086. alias: "dd/mm/yyyy",
  2087. regex: {
  2088. hrspre: new RegExp("[012]"),
  2089. hrs24: new RegExp("2[0-4]|1[3-9]"),
  2090. hrs: new RegExp("[01][0-9]|2[0-4]"),
  2091. ampm: new RegExp("^[a|p|A|P][m|M]"),
  2092. mspre: new RegExp("[0-5]"),
  2093. ms: new RegExp("[0-5][0-9]"),
  2094. },
  2095. timeseparator: ":",
  2096. hourFormat: "24",
  2097. definitions: {
  2098. h: {
  2099. validator: function (chrs, maskset, pos, strict, opts) {
  2100. if (opts.hourFormat === "24" && parseInt(chrs, 10) === 24) {
  2101. return maskset.buffer[pos - 1] = "0",
  2102. maskset.buffer[pos] = "0", {
  2103. refreshFromBuffer: {
  2104. start: pos - 1,
  2105. end: pos,
  2106. },
  2107. c: "0",
  2108. };
  2109. }
  2110. var isValid = opts.regex.hrs.test(chrs);
  2111. if (!strict && !isValid && (chrs.charAt(1) === opts.timeseparator || "-.:".indexOf(chrs.charAt(1)) !== -1) && (isValid = opts.regex.hrs.test("0" + chrs.charAt(0)))) {
  2112. return maskset.buffer[pos - 1] = "0",
  2113. maskset.buffer[pos] = chrs.charAt(0), pos++, {
  2114. refreshFromBuffer: {
  2115. start: pos - 2,
  2116. end: pos,
  2117. },
  2118. pos: pos,
  2119. c: opts.timeseparator,
  2120. };
  2121. }
  2122. if (isValid && opts.hourFormat !== "24" && opts.regex.hrs24.test(chrs)) {
  2123. var tmp = parseInt(chrs, 10);
  2124. return tmp === 24 ? (maskset.buffer[pos + 5] = "a", maskset.buffer[pos + 6] = "m") : (maskset.buffer[pos + 5] = "p",
  2125. maskset.buffer[pos + 6] = "m"), tmp -= 12, tmp < 10 ? (maskset.buffer[pos] = tmp.toString(),
  2126. maskset.buffer[pos - 1] = "0") : (maskset.buffer[pos] = tmp.toString().charAt(1),
  2127. maskset.buffer[pos - 1] = tmp.toString().charAt(0)), {
  2128. refreshFromBuffer: {
  2129. start: pos - 1,
  2130. end: pos + 6,
  2131. },
  2132. c: maskset.buffer[pos],
  2133. };
  2134. }
  2135. return isValid;
  2136. },
  2137. cardinality: 2,
  2138. prevalidator: [ {
  2139. validator: function (chrs, maskset, pos, strict, opts) {
  2140. var isValid = opts.regex.hrspre.test(chrs);
  2141. return strict || isValid || !(isValid = opts.regex.hrs.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  2142. pos++, {
  2143. pos: pos,
  2144. });
  2145. },
  2146. cardinality: 1,
  2147. } ],
  2148. },
  2149. s: {
  2150. validator: "[0-5][0-9]",
  2151. cardinality: 2,
  2152. prevalidator: [ {
  2153. validator: function (chrs, maskset, pos, strict, opts) {
  2154. var isValid = opts.regex.mspre.test(chrs);
  2155. return strict || isValid || !(isValid = opts.regex.ms.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  2156. pos++, {
  2157. pos: pos,
  2158. });
  2159. },
  2160. cardinality: 1,
  2161. } ],
  2162. },
  2163. t: {
  2164. validator: function (chrs, maskset, pos, strict, opts) {
  2165. return opts.regex.ampm.test(chrs + "m");
  2166. },
  2167. casing: "lower",
  2168. cardinality: 1,
  2169. },
  2170. },
  2171. insertMode: !1,
  2172. autoUnmask: !1,
  2173. },
  2174. datetime12: {
  2175. mask: "1/2/y h:s t\\m",
  2176. placeholder: "dd/mm/yyyy hh:mm xm",
  2177. alias: "datetime",
  2178. hourFormat: "12",
  2179. },
  2180. "mm/dd/yyyy hh:mm xm": {
  2181. mask: "1/2/y h:s t\\m",
  2182. placeholder: "mm/dd/yyyy hh:mm xm",
  2183. alias: "datetime12",
  2184. regex: {
  2185. val2pre: function (separator) {
  2186. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2187. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  2188. },
  2189. val2: function (separator) {
  2190. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2191. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[13-9]|1[012])" + escapedSeparator + "30)|((0[13578]|1[02])" + escapedSeparator + "31)");
  2192. },
  2193. val1pre: new RegExp("[01]"),
  2194. val1: new RegExp("0[1-9]|1[012]"),
  2195. },
  2196. leapday: "02/29/",
  2197. onKeyDown: function (e, buffer, caretPos, opts) {
  2198. var $input = $(this);
  2199. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  2200. var today = new Date();
  2201. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  2202. $input.trigger("setvalue");
  2203. }
  2204. },
  2205. },
  2206. "hh:mm t": {
  2207. mask: "h:s t\\m",
  2208. placeholder: "hh:mm xm",
  2209. alias: "datetime",
  2210. hourFormat: "12",
  2211. },
  2212. "h:s t": {
  2213. mask: "h:s t\\m",
  2214. placeholder: "hh:mm xm",
  2215. alias: "datetime",
  2216. hourFormat: "12",
  2217. },
  2218. "hh:mm:ss": {
  2219. mask: "h:s:s",
  2220. placeholder: "hh:mm:ss",
  2221. alias: "datetime",
  2222. autoUnmask: !1,
  2223. },
  2224. "hh:mm": {
  2225. mask: "h:s",
  2226. placeholder: "hh:mm",
  2227. alias: "datetime",
  2228. autoUnmask: !1,
  2229. },
  2230. date: {
  2231. alias: "dd/mm/yyyy",
  2232. },
  2233. "mm/yyyy": {
  2234. mask: "1/y",
  2235. placeholder: "mm/yyyy",
  2236. leapday: "donotuse",
  2237. separator: "/",
  2238. alias: "mm/dd/yyyy",
  2239. },
  2240. shamsi: {
  2241. regex: {
  2242. val2pre: function (separator) {
  2243. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2244. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "[0-3])");
  2245. },
  2246. val2: function (separator) {
  2247. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2248. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[1-9]|1[012])" + escapedSeparator + "30)|((0[1-6])" + escapedSeparator + "31)");
  2249. },
  2250. val1pre: new RegExp("[01]"),
  2251. val1: new RegExp("0[1-9]|1[012]"),
  2252. },
  2253. yearrange: {
  2254. minyear: 1300,
  2255. maxyear: 1499,
  2256. },
  2257. mask: "y/1/2",
  2258. leapday: "/12/30",
  2259. placeholder: "yyyy/mm/dd",
  2260. alias: "mm/dd/yyyy",
  2261. clearIncomplete: !0,
  2262. },
  2263. }), Inputmask;
  2264. }(jQuery, Inputmask)), (function ($, Inputmask) {
  2265. return Inputmask.extendDefinitions({
  2266. A: {
  2267. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  2268. cardinality: 1,
  2269. casing: "upper",
  2270. },
  2271. "&": {
  2272. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  2273. cardinality: 1,
  2274. casing: "upper",
  2275. },
  2276. "#": {
  2277. validator: "[0-9A-Fa-f]",
  2278. cardinality: 1,
  2279. casing: "upper",
  2280. },
  2281. }), Inputmask.extendAliases({
  2282. url: {
  2283. definitions: {
  2284. i: {
  2285. validator: ".",
  2286. cardinality: 1,
  2287. },
  2288. },
  2289. mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)i{+}",
  2290. insertMode: !1,
  2291. autoUnmask: !1,
  2292. },
  2293. ip: {
  2294. mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]",
  2295. definitions: {
  2296. i: {
  2297. validator: function (chrs, maskset, pos, strict, opts) {
  2298. return pos - 1 > -1 && maskset.buffer[pos - 1] !== "." ? (chrs = maskset.buffer[pos - 1] + chrs,
  2299. chrs = pos - 2 > -1 && maskset.buffer[pos - 2] !== "." ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs,
  2300. new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
  2301. },
  2302. cardinality: 1,
  2303. },
  2304. },
  2305. onUnMask: function (maskedValue, unmaskedValue, opts) {
  2306. return maskedValue;
  2307. },
  2308. },
  2309. email: {
  2310. mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,64}]@*{1,64}[.*{2,64}][.*{2,6}][.*{1,2}]",
  2311. greedy: !1,
  2312. onBeforePaste: function (pastedValue, opts) {
  2313. return pastedValue = pastedValue.toLowerCase(), pastedValue.replace("mailto:", "");
  2314. },
  2315. definitions: {
  2316. "*": {
  2317. validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",
  2318. cardinality: 1,
  2319. casing: "lower",
  2320. },
  2321. },
  2322. onUnMask: function (maskedValue, unmaskedValue, opts) {
  2323. return maskedValue;
  2324. },
  2325. },
  2326. mac: {
  2327. mask: "##:##:##:##:##:##",
  2328. },
  2329. }), Inputmask;
  2330. }(jQuery, Inputmask)), (function ($, Inputmask) {
  2331. return Inputmask.extendAliases({
  2332. numeric: {
  2333. mask: function (opts) {
  2334. function autoEscape (txt) {
  2335. for (var escapedTxt = "", i = 0; i < txt.length; i++) {
  2336. escapedTxt += opts.definitions[txt.charAt(i)] ? "\\" + txt.charAt(i) : txt.charAt(i);
  2337. }
  2338. return escapedTxt;
  2339. }
  2340. if (opts.repeat !== 0 && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat),
  2341. opts.repeat = 0, opts.groupSeparator === opts.radixPoint && (opts.radixPoint === "." ? opts.groupSeparator = "," : opts.radixPoint === "," ? opts.groupSeparator = "." : opts.groupSeparator = ""),
  2342. opts.groupSeparator === " " && (opts.skipOptionalPartCharacter = void 0), opts.autoGroup = opts.autoGroup && opts.groupSeparator !== "",
  2343. opts.autoGroup && (typeof opts.groupSize === "string" && isFinite(opts.groupSize) && (opts.groupSize = parseInt(opts.groupSize)),
  2344. isFinite(opts.integerDigits))) {
  2345. var seps = Math.floor(opts.integerDigits / opts.groupSize), mod = opts.integerDigits % opts.groupSize;
  2346. opts.integerDigits = parseInt(opts.integerDigits) + (mod === 0 ? seps - 1 : seps),
  2347. opts.integerDigits < 1 && (opts.integerDigits = "*");
  2348. }
  2349. opts.placeholder.length > 1 && (opts.placeholder = opts.placeholder.charAt(0)),
  2350. opts.radixFocus = opts.radixFocus && opts.placeholder !== "" && opts.integerOptional === !0,
  2351. opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~",
  2352. opts.numericInput == 1 && (opts.radixFocus = !1, opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2),
  2353. opts.decimalProtect = !1);
  2354. var mask = autoEscape(opts.prefix);
  2355. return mask += "[+]", mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}",
  2356. void 0 !== opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{1," + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}"),
  2357. opts.negationSymbol.back !== "" && (mask += "[-]"), mask += autoEscape(opts.suffix),
  2358. opts.greedy = !1, mask;
  2359. },
  2360. placeholder: "",
  2361. greedy: !1,
  2362. digits: "*",
  2363. digitsOptional: !0,
  2364. radixPoint: ".",
  2365. radixFocus: !0,
  2366. groupSize: 3,
  2367. groupSeparator: "",
  2368. autoGroup: !1,
  2369. allowPlus: !0,
  2370. allowMinus: !0,
  2371. negationSymbol: {
  2372. front: "-",
  2373. back: "",
  2374. },
  2375. integerDigits: "+",
  2376. integerOptional: !0,
  2377. prefix: "",
  2378. suffix: "",
  2379. rightAlign: !0,
  2380. decimalProtect: !0,
  2381. min: null,
  2382. max: null,
  2383. step: 1,
  2384. insertMode: !0,
  2385. autoUnmask: !1,
  2386. unmaskAsNumber: !1,
  2387. postFormat: function (buffer, pos, reformatOnly, opts) {
  2388. opts.numericInput === !0 && (buffer = buffer.reverse(), isFinite(pos) && (pos = buffer.join("").length - pos - 1));
  2389. var i, l, suffixStripped = !1;
  2390. buffer.length >= opts.suffix.length && buffer.join("").indexOf(opts.suffix) === buffer.length - opts.suffix.length && (buffer.length -= opts.suffix.length,
  2391. suffixStripped = !0), pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
  2392. var needsRefresh = !1, charAtPos = buffer[pos];
  2393. if (opts.groupSeparator === "" || opts.numericInput !== !0 && $.inArray(opts.radixPoint, buffer) !== -1 && pos > $.inArray(opts.radixPoint, buffer) || new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]").test(charAtPos)) {
  2394. if (suffixStripped) {
  2395. for (i = 0, l = opts.suffix.length; l > i; i++) {
  2396. buffer.push(opts.suffix.charAt(i));
  2397. }
  2398. }
  2399. return {
  2400. pos: pos,
  2401. };
  2402. }
  2403. var cbuf = buffer.slice();
  2404. charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]),
  2405. reformatOnly ? charAtPos !== opts.radixPoint && (cbuf[pos] = "?") : cbuf.splice(pos, 0, "?");
  2406. var bufVal = cbuf.join(""), bufValOrigin = bufVal;
  2407. if (bufVal.length > 0 && opts.autoGroup || reformatOnly && bufVal.indexOf(opts.groupSeparator) !== -1) {
  2408. var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
  2409. needsRefresh = bufVal.indexOf(opts.groupSeparator) === 0, bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
  2410. var radixSplit = bufVal.split(opts.radixPoint);
  2411. if (bufVal = opts.radixPoint === "" ? bufVal : radixSplit[0], bufVal !== opts.prefix + "?0" && bufVal.length >= opts.groupSize + opts.prefix.length) {
  2412. for (var reg = new RegExp("([-+]?[\\d?]+)([\\d?]{" + opts.groupSize + "})"); reg.test(bufVal); ) {
  2413. bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2"),
  2414. bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
  2415. }
  2416. }
  2417. opts.radixPoint !== "" && radixSplit.length > 1 && (bufVal += opts.radixPoint + radixSplit[1]);
  2418. }
  2419. for (needsRefresh = bufValOrigin !== bufVal, buffer.length = bufVal.length, i = 0,
  2420. l = bufVal.length; l > i; i++) {
  2421. buffer[i] = bufVal.charAt(i);
  2422. }
  2423. var newPos = $.inArray("?", buffer);
  2424. if (newPos === -1 && charAtPos === opts.radixPoint && (newPos = $.inArray(opts.radixPoint, buffer)),
  2425. reformatOnly ? buffer[newPos] = charAtPos : buffer.splice(newPos, 1), !needsRefresh && suffixStripped) {
  2426. for (i = 0,
  2427. l = opts.suffix.length; l > i; i++) {
  2428. buffer.push(opts.suffix.charAt(i));
  2429. }
  2430. }
  2431. return newPos = opts.numericInput && isFinite(pos) ? buffer.join("").length - newPos - 1 : newPos,
  2432. opts.numericInput && (buffer = buffer.reverse(), $.inArray(opts.radixPoint, buffer) < newPos && buffer.join("").length - opts.suffix.length !== newPos && (newPos -= 1)),
  2433. {
  2434. pos: newPos,
  2435. refreshFromBuffer: needsRefresh,
  2436. buffer: buffer,
  2437. };
  2438. },
  2439. onBeforeWrite: function (e, buffer, caretPos, opts) {
  2440. if (e && (e.type === "blur" || e.type === "checkval")) {
  2441. var maskedValue = buffer.join(""), processValue = maskedValue.replace(opts.prefix, "");
  2442. if (processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2443. opts.radixPoint === "," && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  2444. isFinite(processValue) && isFinite(opts.min) && parseFloat(processValue) < parseFloat(opts.min)) {
  2445. return $.extend(!0, {
  2446. refreshFromBuffer: !0,
  2447. buffer: (opts.prefix + opts.min).split(""),
  2448. }, opts.postFormat((opts.prefix + opts.min).split(""), 0, !0, opts));
  2449. }
  2450. if (opts.numericInput !== !0) {
  2451. var tmpBufSplit = opts.radixPoint !== "" ? buffer.join("").split(opts.radixPoint) : [ buffer.join("") ], matchRslt = tmpBufSplit[0].match(opts.regex.integerPart(opts)), matchRsltDigits = tmpBufSplit.length === 2 ? tmpBufSplit[1].match(opts.regex.integerNPart(opts)) : void 0;
  2452. if (matchRslt) {
  2453. matchRslt[0] !== opts.negationSymbol.front + "0" && matchRslt[0] !== opts.negationSymbol.front && matchRslt[0] !== "+" || void 0 !== matchRsltDigits && !matchRsltDigits[0].match(/^0+$/) || buffer.splice(matchRslt.index, 1);
  2454. var radixPosition = $.inArray(opts.radixPoint, buffer);
  2455. if (radixPosition !== -1) {
  2456. if (isFinite(opts.digits) && !opts.digitsOptional) {
  2457. for (var i = 1; i <= opts.digits; i++) {
  2458. (void 0 === buffer[radixPosition + i] || buffer[radixPosition + i] === opts.placeholder.charAt(0)) && (buffer[radixPosition + i] = "0");
  2459. }
  2460. return {
  2461. refreshFromBuffer: maskedValue !== buffer.join(""),
  2462. buffer: buffer,
  2463. };
  2464. }
  2465. if (radixPosition === buffer.length - opts.suffix.length - 1) {
  2466. return buffer.splice(radixPosition, 1),
  2467. {
  2468. refreshFromBuffer: !0,
  2469. buffer: buffer,
  2470. };
  2471. }
  2472. }
  2473. }
  2474. }
  2475. }
  2476. if (opts.autoGroup) {
  2477. var rslt = opts.postFormat(buffer, opts.numericInput ? caretPos : caretPos - 1, !0, opts);
  2478. return rslt.caret = caretPos <= opts.prefix.length ? rslt.pos : rslt.pos + 1, rslt;
  2479. }
  2480. },
  2481. regex: {
  2482. integerPart: function (opts) {
  2483. return new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+");
  2484. },
  2485. integerNPart: function (opts) {
  2486. return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + "]+");
  2487. },
  2488. },
  2489. signHandler: function (chrs, maskset, pos, strict, opts) {
  2490. if (!strict && opts.allowMinus && chrs === "-" || opts.allowPlus && chrs === "+") {
  2491. var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
  2492. if (matchRslt && matchRslt[0].length > 0) {
  2493. return maskset.buffer[matchRslt.index] === (chrs === "-" ? "+" : opts.negationSymbol.front) ? chrs === "-" ? opts.negationSymbol.back !== "" ? {
  2494. pos: matchRslt.index,
  2495. c: opts.negationSymbol.front,
  2496. remove: matchRslt.index,
  2497. caret: pos,
  2498. insert: {
  2499. pos: maskset.buffer.length - opts.suffix.length - 1,
  2500. c: opts.negationSymbol.back,
  2501. },
  2502. } : {
  2503. pos: matchRslt.index,
  2504. c: opts.negationSymbol.front,
  2505. remove: matchRslt.index,
  2506. caret: pos,
  2507. } : opts.negationSymbol.back !== "" ? {
  2508. pos: matchRslt.index,
  2509. c: "+",
  2510. remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
  2511. caret: pos,
  2512. } : {
  2513. pos: matchRslt.index,
  2514. c: "+",
  2515. remove: matchRslt.index,
  2516. caret: pos,
  2517. } : maskset.buffer[matchRslt.index] === (chrs === "-" ? opts.negationSymbol.front : "+") ? chrs === "-" && opts.negationSymbol.back !== "" ? {
  2518. remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
  2519. caret: pos - 1,
  2520. } : {
  2521. remove: matchRslt.index,
  2522. caret: pos - 1,
  2523. } : chrs === "-" ? opts.negationSymbol.back !== "" ? {
  2524. pos: matchRslt.index,
  2525. c: opts.negationSymbol.front,
  2526. caret: pos + 1,
  2527. insert: {
  2528. pos: maskset.buffer.length - opts.suffix.length,
  2529. c: opts.negationSymbol.back,
  2530. },
  2531. } : {
  2532. pos: matchRslt.index,
  2533. c: opts.negationSymbol.front,
  2534. caret: pos + 1,
  2535. } : {
  2536. pos: matchRslt.index,
  2537. c: chrs,
  2538. caret: pos + 1,
  2539. };
  2540. }
  2541. }
  2542. return !1;
  2543. },
  2544. radixHandler: function (chrs, maskset, pos, strict, opts) {
  2545. if (!strict && ($.inArray(chrs, [ ",", "." ]) !== -1 && (chrs = opts.radixPoint),
  2546. chrs === opts.radixPoint && void 0 !== opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0))) {
  2547. var radixPos = $.inArray(opts.radixPoint, maskset.buffer), integerValue = maskset.buffer.join("").match(opts.regex.integerPart(opts));
  2548. if (radixPos !== -1 && maskset.validPositions[radixPos]) {
  2549. return maskset.validPositions[radixPos - 1] ? {
  2550. caret: radixPos + 1,
  2551. } : {
  2552. pos: integerValue.index,
  2553. c: integerValue[0],
  2554. caret: radixPos + 1,
  2555. };
  2556. }
  2557. if (!integerValue || integerValue[0] === "0" && integerValue.index + 1 !== pos) {
  2558. return maskset.buffer[integerValue ? integerValue.index : pos] = "0",
  2559. {
  2560. pos: (integerValue ? integerValue.index : pos) + 1,
  2561. c: opts.radixPoint,
  2562. };
  2563. }
  2564. }
  2565. return !1;
  2566. },
  2567. leadingZeroHandler: function (chrs, maskset, pos, strict, opts) {
  2568. if (opts.numericInput === !0) {
  2569. if (maskset.buffer[maskset.buffer.length - opts.prefix.length - 1] === "0") {
  2570. return {
  2571. pos: pos,
  2572. remove: maskset.buffer.length - opts.prefix.length - 1,
  2573. };
  2574. }
  2575. } else {
  2576. var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
  2577. if (matchRslt && !strict && (radixPosition === -1 || radixPosition >= pos)) {
  2578. if (matchRslt[0].indexOf("0") === 0) {
  2579. pos < opts.prefix.length && (pos = matchRslt.index);
  2580. var _radixPosition = $.inArray(opts.radixPoint, maskset._buffer), digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") === maskset._buffer.slice(_radixPosition).join("") || parseInt(maskset.buffer.slice(radixPosition + 1).join("")) === 0, integerMatch = maskset._buffer && maskset.buffer.slice(matchRslt.index, radixPosition).join("") === maskset._buffer.slice(opts.prefix.length, _radixPosition).join("") || maskset.buffer.slice(matchRslt.index, radixPosition).join("") === "0";
  2581. if (radixPosition === -1 || digitsMatch && integerMatch) {
  2582. return maskset.buffer.splice(matchRslt.index, 1),
  2583. pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
  2584. pos: pos,
  2585. remove: matchRslt.index,
  2586. };
  2587. }
  2588. if (matchRslt.index + 1 === pos || chrs === "0") {
  2589. return maskset.buffer.splice(matchRslt.index, 1),
  2590. pos = matchRslt.index, {
  2591. pos: pos,
  2592. remove: matchRslt.index,
  2593. };
  2594. }
  2595. } else if (chrs === "0" && pos <= matchRslt.index && matchRslt[0] !== opts.groupSeparator) {
  2596. return !1;
  2597. }
  2598. }
  2599. }
  2600. return !0;
  2601. },
  2602. postValidation: function (buffer, currentResult, opts) {
  2603. var isValid = !0, maskedValue = opts.numericInput ? buffer.slice().reverse().join("") : buffer.join(""), processValue = maskedValue.replace(opts.prefix, "");
  2604. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2605. opts.radixPoint === "," && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  2606. processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-"),
  2607. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
  2608. processValue = processValue === opts.negationSymbol.front ? processValue + "0" : processValue,
  2609. isFinite(processValue) && (opts.max !== null && isFinite(opts.max) && (processValue = parseFloat(processValue) > parseFloat(opts.max) ? opts.max : processValue,
  2610. isValid = opts.postFormat((opts.prefix + processValue).split(""), 0, !0, opts)),
  2611. opts.min !== null && isFinite(opts.min) && (processValue = parseFloat(processValue) < parseFloat(opts.min) ? opts.min : processValue,
  2612. isValid = opts.postFormat((opts.prefix + processValue).split(""), 0, !0, opts))),
  2613. isValid;
  2614. },
  2615. definitions: {
  2616. "~": {
  2617. validator: function (chrs, maskset, pos, strict, opts) {
  2618. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2619. if (!isValid && (isValid = opts.radixHandler(chrs, maskset, pos, strict, opts),
  2620. !isValid && (isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs),
  2621. isValid === !0 && (isValid = opts.leadingZeroHandler(chrs, maskset, pos, strict, opts),
  2622. isValid === !0)))) {
  2623. var radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
  2624. isValid = radixPosition !== -1 && opts.digitsOptional === !1 && opts.numericInput !== !0 && pos > radixPosition && !strict ? {
  2625. pos: pos,
  2626. remove: pos,
  2627. } : {
  2628. pos: pos,
  2629. };
  2630. }
  2631. return isValid;
  2632. },
  2633. cardinality: 1,
  2634. prevalidator: null,
  2635. },
  2636. "+": {
  2637. validator: function (chrs, maskset, pos, strict, opts) {
  2638. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2639. return !isValid && (strict && opts.allowMinus && chrs === opts.negationSymbol.front || opts.allowMinus && chrs === "-" || opts.allowPlus && chrs === "+") && (isValid = chrs === "-" ? opts.negationSymbol.back !== "" ? {
  2640. pos: pos,
  2641. c: chrs === "-" ? opts.negationSymbol.front : "+",
  2642. caret: pos + 1,
  2643. insert: {
  2644. pos: maskset.buffer.length,
  2645. c: opts.negationSymbol.back,
  2646. },
  2647. } : {
  2648. pos: pos,
  2649. c: chrs === "-" ? opts.negationSymbol.front : "+",
  2650. caret: pos + 1,
  2651. } : !0), isValid;
  2652. },
  2653. cardinality: 1,
  2654. prevalidator: null,
  2655. placeholder: "",
  2656. },
  2657. "-": {
  2658. validator: function (chrs, maskset, pos, strict, opts) {
  2659. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2660. return !isValid && strict && opts.allowMinus && chrs === opts.negationSymbol.back && (isValid = !0),
  2661. isValid;
  2662. },
  2663. cardinality: 1,
  2664. prevalidator: null,
  2665. placeholder: "",
  2666. },
  2667. ":": {
  2668. validator: function (chrs, maskset, pos, strict, opts) {
  2669. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2670. if (!isValid) {
  2671. var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + ",\\.]";
  2672. isValid = new RegExp(radix).test(chrs), isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint && (isValid = {
  2673. caret: pos + 1,
  2674. });
  2675. }
  2676. return isValid ? {
  2677. c: opts.radixPoint,
  2678. } : isValid;
  2679. },
  2680. cardinality: 1,
  2681. prevalidator: null,
  2682. placeholder: function (opts) {
  2683. return opts.radixPoint;
  2684. },
  2685. },
  2686. },
  2687. onUnMask: function (maskedValue, unmaskedValue, opts) {
  2688. var processValue = maskedValue.replace(opts.prefix, "");
  2689. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2690. opts.unmaskAsNumber ? (opts.radixPoint !== "" && processValue.indexOf(opts.radixPoint) !== -1 && (processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".")),
  2691. Number(processValue)) : processValue;
  2692. },
  2693. isComplete: function (buffer, opts) {
  2694. var maskedValue = buffer.join(""), bufClone = buffer.slice();
  2695. if (opts.postFormat(bufClone, 0, !0, opts), bufClone.join("") !== maskedValue) {
  2696. return !1;
  2697. }
  2698. var processValue = maskedValue.replace(opts.prefix, "");
  2699. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2700. opts.radixPoint === "," && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  2701. isFinite(processValue);
  2702. },
  2703. onBeforeMask: function (initialValue, opts) {
  2704. if (opts.radixPoint !== "" && isFinite(initialValue)) {
  2705. initialValue = initialValue.toString().replace(".", opts.radixPoint);
  2706. } else {
  2707. var kommaMatches = initialValue.match(/,/g), dotMatches = initialValue.match(/\./g);
  2708. dotMatches && kommaMatches ? dotMatches.length > kommaMatches.length ? (initialValue = initialValue.replace(/\./g, ""),
  2709. initialValue = initialValue.replace(",", opts.radixPoint)) : kommaMatches.length > dotMatches.length ? (initialValue = initialValue.replace(/,/g, ""),
  2710. initialValue = initialValue.replace(".", opts.radixPoint)) : initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue = initialValue.replace(/,/g, "") : initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
  2711. }
  2712. if (opts.digits === 0 && (initialValue.indexOf(".") !== -1 ? initialValue = initialValue.substring(0, initialValue.indexOf(".")) : initialValue.indexOf(",") !== -1 && (initialValue = initialValue.substring(0, initialValue.indexOf(",")))),
  2713. opts.radixPoint !== "" && isFinite(opts.digits) && initialValue.indexOf(opts.radixPoint) !== -1) {
  2714. var valueParts = initialValue.split(opts.radixPoint), decPart = valueParts[1].match(new RegExp("\\d*"))[0];
  2715. if (parseInt(opts.digits) < decPart.toString().length) {
  2716. var digitsFactor = Math.pow(10, parseInt(opts.digits));
  2717. initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."),
  2718. initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor,
  2719. initialValue = initialValue.toString().replace(".", opts.radixPoint);
  2720. }
  2721. }
  2722. return initialValue.toString();
  2723. },
  2724. canClearPosition: function (maskset, position, lvp, strict, opts) {
  2725. var positionInput = maskset.validPositions[position].input, canClear = positionInput !== opts.radixPoint || maskset.validPositions[position].match.fn !== null && opts.decimalProtect === !1 || isFinite(positionInput) || position === lvp || positionInput === opts.groupSeparator || positionInput === opts.negationSymbol.front || positionInput === opts.negationSymbol.back;
  2726. if (canClear && isFinite(positionInput)) {
  2727. var matchRslt, radixPos = $.inArray(opts.radixPoint, maskset.buffer), radixInjection = !1;
  2728. if (void 0 === maskset.validPositions[radixPos] && (maskset.validPositions[radixPos] = {
  2729. input: opts.radixPoint,
  2730. }, radixInjection = !0), !strict && maskset.buffer) {
  2731. matchRslt = maskset.buffer.join("").substr(0, position).match(opts.regex.integerNPart(opts));
  2732. var pos = position + 1, isNull = matchRslt == null || parseInt(matchRslt[0].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "")) === 0;
  2733. if (isNull) {
  2734. for (;maskset.validPositions[pos] && (maskset.validPositions[pos].input === opts.groupSeparator || maskset.validPositions[pos].input === "0"); ) {
  2735. delete maskset.validPositions[pos],
  2736. pos++;
  2737. }
  2738. }
  2739. }
  2740. var buffer = [];
  2741. for (var vp in maskset.validPositions) {
  2742. void 0 !== maskset.validPositions[vp].input && buffer.push(maskset.validPositions[vp].input);
  2743. }
  2744. if (radixInjection && delete maskset.validPositions[radixPos], radixPos > 0) {
  2745. var bufVal = buffer.join("");
  2746. if (matchRslt = bufVal.match(opts.regex.integerNPart(opts))) {
  2747. if (radixPos >= position) {
  2748. if (matchRslt[0].indexOf("0") === 0) {
  2749. canClear = matchRslt.index !== position || opts.placeholder === "0";
  2750. } else {
  2751. var intPart = parseInt(matchRslt[0].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "")), radixPart = parseInt(bufVal.split(opts.radixPoint)[1]);
  2752. intPart < 10 && maskset.validPositions[position] && (opts.placeholder !== "0" || radixPart > 0) && (maskset.validPositions[position].input = "0",
  2753. maskset.p = opts.prefix.length + 1, canClear = !1);
  2754. }
  2755. } else {
  2756. matchRslt[0].indexOf("0") === 0 && bufVal.length === 3 && (maskset.validPositions = {},
  2757. canClear = !1);
  2758. }
  2759. }
  2760. }
  2761. }
  2762. return canClear;
  2763. },
  2764. onKeyDown: function (e, buffer, caretPos, opts) {
  2765. var $input = $(this);
  2766. if (e.ctrlKey) {
  2767. switch (e.keyCode) {
  2768. case Inputmask.keyCode.UP:
  2769. $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step)), $input.trigger("setvalue");
  2770. break;
  2771. case Inputmask.keyCode.DOWN:
  2772. $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step)), $input.trigger("setvalue");
  2773. }
  2774. }
  2775. },
  2776. },
  2777. currency: {
  2778. prefix: "$ ",
  2779. groupSeparator: ",",
  2780. alias: "numeric",
  2781. placeholder: "0",
  2782. autoGroup: !0,
  2783. digits: 2,
  2784. digitsOptional: !1,
  2785. clearMaskOnLostFocus: !1,
  2786. },
  2787. decimal: {
  2788. alias: "numeric",
  2789. },
  2790. integer: {
  2791. alias: "numeric",
  2792. digits: 0,
  2793. radixPoint: "",
  2794. },
  2795. percentage: {
  2796. alias: "numeric",
  2797. digits: 2,
  2798. radixPoint: ".",
  2799. placeholder: "0",
  2800. autoGroup: !1,
  2801. min: 0,
  2802. max: 100,
  2803. suffix: " %",
  2804. allowPlus: !1,
  2805. allowMinus: !1,
  2806. },
  2807. }), Inputmask;
  2808. }(jQuery, Inputmask)), (function ($, Inputmask) {
  2809. return Inputmask.extendAliases({
  2810. phone: {
  2811. url: "/defiline/static/src/lib/phone-codes/phone-codes.js",
  2812. countrycode: "",
  2813. phoneCodeCache: {},
  2814. mask: function (opts) {
  2815. if (void 0 === opts.phoneCodeCache[opts.url]) {
  2816. var maskList = [];
  2817. opts.definitions["#"] = opts.definitions[9], $.ajax({
  2818. url: opts.url,
  2819. async: !1,
  2820. type: "get",
  2821. dataType: "json",
  2822. success: function (response) {
  2823. maskList = response;
  2824. },
  2825. error: function (xhr, ajaxOptions, thrownError) {
  2826. alert(thrownError + " - " + opts.url);
  2827. },
  2828. }), opts.phoneCodeCache[opts.url] = maskList.sort(function (a, b) {
  2829. return (a.mask || a) < (b.mask || b) ? -1 : 1;
  2830. });
  2831. }
  2832. return opts.phoneCodeCache[opts.url];
  2833. },
  2834. keepStatic: !1,
  2835. nojumps: !0,
  2836. nojumpsThreshold: 1,
  2837. onBeforeMask: function (value, opts) {
  2838. var processedValue = value.replace(/^0{1,2}/, "").replace(/[\s]/g, "");
  2839. return (processedValue.indexOf(opts.countrycode) > 1 || processedValue.indexOf(opts.countrycode) === -1) && (processedValue = "+" + opts.countrycode + processedValue),
  2840. processedValue;
  2841. },
  2842. },
  2843. phonebe: {
  2844. alias: "phone",
  2845. url: "/defiline/static/src/lib/phone-codes/phone-be.js",
  2846. countrycode: "32",
  2847. nojumpsThreshold: 4,
  2848. },
  2849. }), Inputmask;
  2850. }(jQuery, Inputmask)), (function ($, Inputmask) {
  2851. return Inputmask.extendAliases({
  2852. Regex: {
  2853. mask: "r",
  2854. greedy: !1,
  2855. repeat: "*",
  2856. regex: null,
  2857. regexTokens: null,
  2858. tokenizer: /\[\^?]?(?:[^\\\]]+|\\[\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,
  2859. quantifierFilter: /[0-9]+[^,]/,
  2860. isComplete: function (buffer, opts) {
  2861. return new RegExp(opts.regex).test(buffer.join(""));
  2862. },
  2863. definitions: {
  2864. r: {
  2865. validator: function (chrs, maskset, pos, strict, opts) {
  2866. function RegexToken (isGroup, isQuantifier) {
  2867. this.matches = [], this.isGroup = isGroup || !1, this.isQuantifier = isQuantifier || !1,
  2868. this.quantifier = {
  2869. min: 1,
  2870. max: 1,
  2871. }, this.repeaterPart = void 0;
  2872. }
  2873. function analyseRegex () {
  2874. var match, m, currentToken = new RegexToken(), opengroups = [];
  2875. for (opts.regexTokens = []; match = opts.tokenizer.exec(opts.regex); ) {
  2876. switch (m = match[0],
  2877. m.charAt(0)) {
  2878. case "(":
  2879. opengroups.push(new RegexToken(!0));
  2880. break;
  2881. case ")":
  2882. groupToken = opengroups.pop(), opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);
  2883. break;
  2884. case "{":
  2885. case "+":
  2886. case "*":
  2887. var quantifierToken = new RegexToken(!1, !0);
  2888. m = m.replace(/[{}]/g, "");
  2889. var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = mq.length === 1 ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);
  2890. if (quantifierToken.quantifier = {
  2891. min: mq0,
  2892. max: mq1,
  2893. }, opengroups.length > 0) {
  2894. var matches = opengroups[opengroups.length - 1].matches;
  2895. match = matches.pop(), match.isGroup || (groupToken = new RegexToken(!0), groupToken.matches.push(match),
  2896. match = groupToken), matches.push(match), matches.push(quantifierToken);
  2897. } else {
  2898. match = currentToken.matches.pop(), match.isGroup || (groupToken = new RegexToken(!0),
  2899. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  2900. currentToken.matches.push(quantifierToken);
  2901. }
  2902. break;
  2903. default:
  2904. opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(m) : currentToken.matches.push(m);
  2905. }
  2906. }
  2907. currentToken.matches.length > 0 && opts.regexTokens.push(currentToken);
  2908. }
  2909. function validateRegexToken (token, fromGroup) {
  2910. var isvalid = !1;
  2911. fromGroup && (regexPart += "(", openGroupCount++);
  2912. for (var mndx = 0; mndx < token.matches.length; mndx++) {
  2913. var matchToken = token.matches[mndx];
  2914. if (matchToken.isGroup === !0) {
  2915. isvalid = validateRegexToken(matchToken, !0);
  2916. } else if (matchToken.isQuantifier === !0) {
  2917. var crrntndx = $.inArray(matchToken, token.matches), matchGroup = token.matches[crrntndx - 1], regexPartBak = regexPart;
  2918. if (isNaN(matchToken.quantifier.max)) {
  2919. for (;matchToken.repeaterPart && matchToken.repeaterPart !== regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) {}
  2920. isvalid = isvalid || validateRegexToken(matchGroup, !0), isvalid && (matchToken.repeaterPart = regexPart),
  2921. regexPart = regexPartBak + matchToken.quantifier.max;
  2922. } else {
  2923. for (var i = 0, qm = matchToken.quantifier.max - 1; qm > i && !(isvalid = validateRegexToken(matchGroup, !0)); i++) {}
  2924. regexPart = regexPartBak + "{" + matchToken.quantifier.min + "," + matchToken.quantifier.max + "}";
  2925. }
  2926. } else if (void 0 !== matchToken.matches) {
  2927. for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) {}
  2928. } else {
  2929. var testExp;
  2930. if (matchToken.charAt(0) == "[") {
  2931. testExp = regexPart, testExp += matchToken;
  2932. for (var j = 0; openGroupCount > j; j++) {
  2933. testExp += ")";
  2934. }
  2935. var exp = new RegExp("^(" + testExp + ")$");
  2936. isvalid = exp.test(bufferStr);
  2937. } else {
  2938. for (var l = 0, tl = matchToken.length; tl > l; l++) {
  2939. if (matchToken.charAt(l) !== "\\") {
  2940. testExp = regexPart, testExp += matchToken.substr(0, l + 1), testExp = testExp.replace(/\|$/, "");
  2941. for (var j = 0; openGroupCount > j; j++) {
  2942. testExp += ")";
  2943. }
  2944. var exp = new RegExp("^(" + testExp + ")$");
  2945. if (isvalid = exp.test(bufferStr)) {
  2946. break;
  2947. }
  2948. }
  2949. }
  2950. }
  2951. regexPart += matchToken;
  2952. }
  2953. if (isvalid) {
  2954. break;
  2955. }
  2956. }
  2957. return fromGroup && (regexPart += ")", openGroupCount--), isvalid;
  2958. }
  2959. var bufferStr, groupToken, cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;
  2960. opts.regexTokens === null && analyseRegex(), cbuffer.splice(pos, 0, chrs), bufferStr = cbuffer.join("");
  2961. for (var i = 0; i < opts.regexTokens.length; i++) {
  2962. var regexToken = opts.regexTokens[i];
  2963. if (isValid = validateRegexToken(regexToken, regexToken.isGroup)) {
  2964. break;
  2965. }
  2966. }
  2967. return isValid;
  2968. },
  2969. cardinality: 1,
  2970. },
  2971. },
  2972. },
  2973. }), Inputmask;
  2974. }(jQuery, Inputmask));