jquery.inputmask.bundle.js 170 KB

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