jquery.inputmask.bundle.js 162 KB

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