jquery.inputmask.bundle.js 177 KB

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