jquery.inputmask.bundle.js 162 KB

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