jquery.inputmask.bundle.js 171 KB

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