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.

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