!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).VueMask={})}(this,(function(e){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(e){for(var r=1;r0&&void 0!==arguments[0]?arguments[0]:u,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i;if(!f(e))throw new Error("Text-mask:convertMaskToPlaceholder; The mask property must be an array.");if(-1!==e.indexOf(r))throw new Error("Placeholder character must not be used as part of the mask. Please specify a character that is not present in your mask as your placeholder character.\n\n"+"The placeholder character that was received is: ".concat(JSON.stringify(r),"\n\n")+"The mask that was received is: ".concat(JSON.stringify(e)));return e.map((function(e){return e instanceof RegExp?r:e})).join("")}function f(e){return Array.isArray&&Array.isArray(e)||e instanceof Array}function l(e){for(var r,t=[];-1!==(r=e.indexOf("[]"));)t.push(r),e.splice(r,1);return{maskWithoutCaretTraps:e,indexes:t}}var s=[],p="";function v(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!f(t)){if(r(t)!==a)throw new Error("Text-mask:conformToMask; The mask property must be an array.");t=l(t=t(e,n)).maskWithoutCaretTraps}var o=n.guide,u=void 0===o||o,v=n.previousConformedValue,d=void 0===v?p:v,h=n.placeholderChar,y=void 0===h?i:h,g=n.placeholder,m=void 0===g?c(t,y):g,b=n.currentCaretPosition,O=n.keepCharPositions,k=!1===u&&void 0!==d,w=e.length,j=d.length,x=m.length,E=t.length,P=w-j,T=P>0,V=b+(T?-P:0),A=V+Math.abs(P);if(!0===O&&!T){for(var M=p,S=V;S=V&&r=0;R--){var N=C[R].char;if(N!==y){var _=R>=V&&j===E;N===m[_?R-P:R]&&C.splice(R,1)}}var D=p,U=!1;e:for(var z=0;z0)for(;C.length>0;){var F=C.shift(),H=F.char,I=F.isNew;if(H===y&&!0!==k){D+=y;continue e}if(t[z].test(H)){if(!0===O&&!1!==I&&d!==p&&!1!==u&&T){for(var J=C.length,L=null,W=0;W-1?"\\".concat(e):e}(e),"]/"))}(e)};function m(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;return e.map((function(e,t,n){var o=r[e]||e,i=n[t-1],a=r[i]||i;return o===d?null:a===d?y(g(o)):o})).filter(Boolean)}function b(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;return m(e.split(""),r)}var O=function(e){return e instanceof HTMLInputElement?e:e.querySelector("input")||e},k=function(e){return"function"==typeof e},w=function(e){return"string"==typeof e};var j=function(){var e=new Map,r={previousValue:"",mask:[]};function t(t){return e.get(t)||o({},r)}return{partiallyUpdate:function(r,n){e.set(r,o(o({},t(r)),n))},remove:function(r){e.delete(r)},get:t}}();function x(e){!function(e,r){var t=document.createEvent("HTMLEvents");t.initEvent(r,!0,!0),e.dispatchEvent(t)}(e,"input")}function E(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=e.value,n=j.get(e),o=n.previousValue,i=n.mask,a=t!==o,u=t.length>o.length,c=t&&a&&u;if((r||c)&&i){var f=v(t,i,{guide:!1}),l=f.conformedValue;e.value=l,x(e)}j.partiallyUpdate(e,{previousValue:t})}function P(e,r,t){var n;n=Array.isArray(r)?function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;return m(e.map((function(e){return e instanceof RegExp?e:"string"==typeof e?e.split(""):null})).filter(Boolean).reduce((function(e,r){return e.concat(r)}),[]),r)}(r,t):k(r)?r:w(r)&&r.length>0?b(r,t):r,j.partiallyUpdate(e,{mask:n})}function T(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;return null===e||Array.isArray(e)||"object"!==r(e)?n:Object.keys(e).reduce((function(r,n){var i=e[n];return null===i||i instanceof RegExp?o(o({},r),{},t({},n,i)):r}),n)}function V(e){return(Array.isArray(e)?e:[e]).filter((function(e){return w(e)||e instanceof RegExp})).toString()}function A(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=T(e&&e.placeholders);return{bind:function(e,t){var n=t.value;P(e=O(e),n,r),E(e)},componentUpdated:function(e,t){var n=t.value,o=t.oldValue;e=O(e);var i=k(n)||V(o)!==V(n);i&&P(e,n,r),E(e,i)},unbind:function(e){e=O(e),j.remove(e)}}}var M=A(),S=function(e,r){var t=b(r);return w(e)||Number.isFinite(e)?v("".concat(e),t,{guide:!1}).conformedValue:e},C=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.directive("mask",A(r)),e.filter("VMask",S)};e.VueMaskDirective=M,e.VueMaskFilter=S,e.VueMaskPlugin=C,e.default=C,Object.defineProperty(e,"__esModule",{value:!0})}));