jquery.inputmask.bundle.js 159 KB

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