jquery.inputmask.bundle.js 171 KB

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