jquery.inputmask.bundle.js 161 KB

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