jquery.inputmask.bundle.js 172 KB

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