Socket
Socket
Sign inDemoInstall

imask

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imask - npm Package Compare versions

Comparing version 6.5.0 to 6.5.1-alpha.0

esm/_rollupPluginBabelHelpers-6b3bd404.js

2

dist/imask.min.js

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).IMask={})}(this,(function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,y(i.key),i)}}function u(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function o(t,e){if(null==t)return{};var n,i,u=function(t,e){if(null==t)return{};var n,i,u={},s=Object.keys(t);for(i=0;i<s.length;i++)n=s[i],e.indexOf(n)>=0||(u[n]=t[n]);return u}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i<s.length;i++)n=s[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(u[n]=t[n])}return u}function l(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=r(t);if(e){var u=r(this).constructor;n=Reflect.construct(i,arguments,u)}else n=i.apply(this,arguments);return l(this,n)}}function c(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}function f(){return f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=c(t,e);if(i){var u=Object.getOwnPropertyDescriptor(i,e);return u.get?u.get.call(arguments.length<3?t:n):u.value}},f.apply(this,arguments)}function p(t,e,n,i){return p="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,e,n,i){var u,s=c(t,e);if(s){if((u=Object.getOwnPropertyDescriptor(s,e)).set)return u.set.call(i,n),!0;if(!u.writable)return!1}if(u=Object.getOwnPropertyDescriptor(i,e)){if(!u.writable)return!1;u.value=n,Object.defineProperty(i,e,u)}else!function(t,e,n){(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n}(i,e,n);return!0},p(t,e,n,i)}function d(t,e,n,i,u){if(!p(t,e,n,i||t)&&u)throw new TypeError("failed to set property");return n}function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,u,s,r,a=[],o=!0,l=!1;try{if(s=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;o=!1}else for(;!(o=(i=s.call(n)).done)&&(a.push(i.value),a.length!==e);o=!0);}catch(t){l=!0,u=t}finally{try{if(!o&&null!=n.return&&(r=n.return(),Object(r)!==r))return}finally{if(l)throw u}}return a}}(t,e)||k(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(t,e){if(t){if("string"==typeof t)return g(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(t,e):void 0}}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function y(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var m=function(){function t(e){n(this,t),Object.assign(this,{inserted:"",rawInserted:"",skip:!1,tailShift:0},e)}return u(t,[{key:"aggregate",value:function(t){return this.rawInserted+=t.rawInserted,this.skip=this.skip||t.skip,this.inserted+=t.inserted,this.tailShift+=t.tailShift,this}},{key:"offset",get:function(){return this.tailShift+this.inserted.length}}]),t}();function _(t){return"string"==typeof t||t instanceof String}var E={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function A(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function F(t){return Array.isArray(t)?t:[t,new m]}function C(t,n){if(n===t)return!0;var i,u=Array.isArray(n),s=Array.isArray(t);if(u&&s){if(n.length!=t.length)return!1;for(i=0;i<n.length;i++)if(!C(n[i],t[i]))return!1;return!0}if(u!=s)return!1;if(n&&t&&"object"===e(n)&&"object"===e(t)){var r=n instanceof Date,a=t instanceof Date;if(r&&a)return n.getTime()==t.getTime();if(r!=a)return!1;var o=n instanceof RegExp,l=t instanceof RegExp;if(o&&l)return n.toString()==t.toString();if(o!=l)return!1;var h=Object.keys(n);for(i=0;i<h.length;i++)if(!Object.prototype.hasOwnProperty.call(t,h[i]))return!1;for(i=0;i<h.length;i++)if(!C(t[h[i]],n[h[i]]))return!1;return!0}return!(!n||!t||"function"!=typeof n||"function"!=typeof t)&&n.toString()===t.toString()}var b=function(){function t(e,i,u,s){for(n(this,t),this.value=e,this.cursorPos=i,this.oldValue=u,this.oldSelection=s;this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start}return u(t,[{key:"startChangePos",get:function(){return Math.min(this.cursorPos,this.oldSelection.start)}},{key:"insertedCount",get:function(){return this.cursorPos-this.startChangePos}},{key:"inserted",get:function(){return this.value.substr(this.startChangePos,this.insertedCount)}},{key:"removedCount",get:function(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}},{key:"removed",get:function(){return this.oldValue.substr(this.startChangePos,this.removedCount)}},{key:"head",get:function(){return this.value.substring(0,this.startChangePos)}},{key:"tail",get:function(){return this.value.substring(this.startChangePos+this.insertedCount)}},{key:"removeDirection",get:function(){return!this.removedCount||this.insertedCount?E.NONE:this.oldSelection.end!==this.cursorPos&&this.oldSelection.start!==this.cursorPos||this.oldSelection.end!==this.oldSelection.start?E.LEFT:E.RIGHT}}]),t}(),S=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,u=arguments.length>2?arguments[2]:void 0;n(this,t),this.value=e,this.from=i,this.stop=u}return u(t,[{key:"toString",value:function(){return this.value}},{key:"extend",value:function(t){this.value+=String(t)}},{key:"appendTo",value:function(t){return t.append(this.toString(),{tail:!0}).aggregate(t._appendPlaceholder())}},{key:"state",get:function(){return{value:this.value,from:this.from,stop:this.stop}},set:function(t){Object.assign(this,t)}},{key:"unshift",value:function(t){if(!this.value.length||null!=t&&this.from>=t)return"";var e=this.value[0];return this.value=this.value.slice(1),e}},{key:"shift",value:function(){if(!this.value.length)return"";var t=this.value[this.value.length-1];return this.value=this.value.slice(0,-1),t}}]),t}();function D(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new D.InputMask(t,e)}var B=function(){function t(e){n(this,t),this._value="",this._update(Object.assign({},t.DEFAULTS,e)),this.isInitialized=!0}return u(t,[{key:"updateOptions",value:function(t){Object.keys(t).length&&this.withValueRefresh(this._update.bind(this,t))}},{key:"_update",value:function(t){Object.assign(this,t)}},{key:"state",get:function(){return{_value:this.value}},set:function(t){this._value=t._value}},{key:"reset",value:function(){this._value=""}},{key:"value",get:function(){return this._value},set:function(t){this.resolve(t)}},{key:"resolve",value:function(t){return this.reset(),this.append(t,{input:!0},""),this.doCommit(),this.value}},{key:"unmaskedValue",get:function(){return this.value},set:function(t){this.reset(),this.append(t,{},""),this.doCommit()}},{key:"typedValue",get:function(){return this.doParse(this.value)},set:function(t){this.value=this.doFormat(t)}},{key:"rawInputValue",get:function(){return this.extractInput(0,this.value.length,{raw:!0})},set:function(t){this.reset(),this.append(t,{raw:!0},""),this.doCommit()}},{key:"isComplete",get:function(){return!0}},{key:"isFilled",get:function(){return this.isComplete}},{key:"nearestInputPos",value:function(t,e){return t}},{key:"extractInput",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this.value.slice(t,e)}},{key:"extractTail",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return new S(this.extractInput(t,e),t)}},{key:"appendTail",value:function(t){return _(t)&&(t=new S(String(t))),t.appendTo(this)}},{key:"_appendCharRaw",value:function(t){return t?(this._value+=t,new m({inserted:t,rawInserted:t})):new m}},{key:"_appendChar",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0,u=this.state,s=v(F(this.doPrepare(t,n)),2);if(t=s[0],(e=(e=s[1]).aggregate(this._appendCharRaw(t,n))).inserted){var r,a=!1!==this.doValidate(n);if(a&&null!=i){var o=this.state;!0===this.overwrite&&(r=i.state,i.unshift(this.value.length-e.tailShift));var l=this.appendTail(i);(a=l.rawInserted===i.toString())&&l.inserted||"shift"!==this.overwrite||(this.state=o,r=i.state,i.shift(),a=(l=this.appendTail(i)).rawInserted===i.toString()),a&&l.inserted&&(this.state=o)}a||(e=new m,this.state=u,i&&r&&(i.state=r))}return e}},{key:"_appendPlaceholder",value:function(){return new m}},{key:"_appendEager",value:function(){return new m}},{key:"append",value:function(t,e,n){if(!_(t))throw new Error("value should be string");var i=new m,u=_(n)?new S(String(n)):n;null!=e&&e.tail&&(e._beforeTailState=this.state);for(var s=0;s<t.length;++s){var r=this._appendChar(t[s],e,u);if(!r.rawInserted&&!this.doSkipInvalid(t[s],e,u))break;i.aggregate(r)}return null!=u&&(i.tailShift+=this.appendTail(u).tailShift),(!0===this.eager||"append"===this.eager)&&null!=e&&e.input&&t&&i.aggregate(this._appendEager()),i}},{key:"remove",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this._value=this.value.slice(0,t)+this.value.slice(e),new m}},{key:"withValueRefresh",value:function(t){if(this._refreshing||!this.isInitialized)return t();this._refreshing=!0;var e=this.rawInputValue,n=this.value,i=t();return this.rawInputValue=e,this.value&&this.value!==n&&0===n.indexOf(this.value)&&this.append(n.slice(this.value.length),{},""),delete this._refreshing,i}},{key:"runIsolated",value:function(t){if(this._isolated||!this.isInitialized)return t(this);this._isolated=!0;var e=this.state,n=t(this);return this.state=e,delete this._isolated,n}},{key:"doSkipInvalid",value:function(t){return this.skipInvalid}},{key:"doPrepare",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.prepare?this.prepare(t,this,e):t}},{key:"doValidate",value:function(t){return(!this.validate||this.validate(this.value,this,t))&&(!this.parent||this.parent.doValidate(t))}},{key:"doCommit",value:function(){this.commit&&this.commit(this.value,this)}},{key:"doFormat",value:function(t){return this.format?this.format(t,this):t}},{key:"doParse",value:function(t){return this.parse?this.parse(t,this):t}},{key:"splice",value:function(t,e,n,i){var u,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{input:!0},r=t+e,a=this.extractTail(r),o=!0===this.eager||"remove"===this.eager;o&&(i=function(t){switch(t){case E.LEFT:return E.FORCE_LEFT;case E.RIGHT:return E.FORCE_RIGHT;default:return t}}(i),u=this.extractInput(0,r,{raw:!0}));var l=t,h=new m;if(i!==E.NONE&&(l=this.nearestInputPos(t,e>1&&0!==t&&!o?E.NONE:i),h.tailShift=l-t),h.aggregate(this.remove(l)),o&&i!==E.NONE&&u===this.rawInputValue)if(i===E.FORCE_LEFT)for(var c;u===this.rawInputValue&&(c=this.value.length);)h.aggregate(new m({tailShift:-1})).aggregate(this.remove(c-1));else i===E.FORCE_RIGHT&&a.unshift();return h.aggregate(this.append(n,s,a))}},{key:"maskEquals",value:function(t){return this.mask===t}},{key:"typedValueEquals",value:function(e){var n=this.typedValue;return e===n||t.EMPTY_VALUES.includes(e)&&t.EMPTY_VALUES.includes(n)||this.doFormat(e)===this.doFormat(this.typedValue)}}]),t}();function w(t){if(null==t)throw new Error("mask property should be defined");return t instanceof RegExp?D.MaskedRegExp:_(t)?D.MaskedPattern:t instanceof Date||t===Date?D.MaskedDate:t instanceof Number||"number"==typeof t||t===Number?D.MaskedNumber:Array.isArray(t)||t===Array?D.MaskedDynamic:D.Masked&&t.prototype instanceof D.Masked?t:t instanceof D.Masked?t.constructor:t instanceof Function?D.MaskedFunction:(console.warn("Mask not found for mask",t),D.Masked)}function x(t){if(D.Masked&&t instanceof D.Masked)return t;var e=(t=Object.assign({},t)).mask;if(D.Masked&&e instanceof D.Masked)return e;var n=w(e);if(!n)throw new Error("Masked class is not found for provided mask, appropriate module needs to be import manually before creating mask.");return new n(t)}B.DEFAULTS={format:String,parse:function(t){return t},skipInvalid:!0},B.EMPTY_VALUES=[void 0,null,""],D.Masked=B,D.createMask=x;var M=["mask"],T={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./},O=function(){function t(e){n(this,t);var i=e.mask,u=o(e,M);this.masked=x({mask:i}),Object.assign(this,u)}return u(t,[{key:"reset",value:function(){this.isFilled=!1,this.masked.reset()}},{key:"remove",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return 0===t&&e>=1?(this.isFilled=!1,this.masked.remove(t,e)):new m}},{key:"value",get:function(){return this.masked.value||(this.isFilled&&!this.isOptional?this.placeholderChar:"")}},{key:"unmaskedValue",get:function(){return this.masked.unmaskedValue}},{key:"isComplete",get:function(){return Boolean(this.masked.value)||this.isOptional}},{key:"_appendChar",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isFilled)return new m;var n=this.masked.state,i=this.masked._appendChar(t,e);return i.inserted&&!1===this.doValidate(e)&&(i.inserted=i.rawInserted="",this.masked.state=n),i.inserted||this.isOptional||this.lazy||e.input||(i.inserted=this.placeholderChar),i.skip=!i.inserted&&!this.isOptional,this.isFilled=Boolean(i.inserted),i}},{key:"append",value:function(){var t;return(t=this.masked).append.apply(t,arguments)}},{key:"_appendPlaceholder",value:function(){var t=new m;return this.isFilled||this.isOptional||(this.isFilled=!0,t.inserted=this.placeholderChar),t}},{key:"_appendEager",value:function(){return new m}},{key:"extractTail",value:function(){var t;return(t=this.masked).extractTail.apply(t,arguments)}},{key:"appendTail",value:function(){var t;return(t=this.masked).appendTail.apply(t,arguments)}},{key:"extractInput",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,n=arguments.length>2?arguments[2]:void 0;return this.masked.extractInput(t,e,n)}},{key:"nearestInputPos",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E.NONE,n=this.value.length,i=Math.min(Math.max(t,0),n);switch(e){case E.LEFT:case E.FORCE_LEFT:return this.isComplete?i:0;case E.RIGHT:case E.FORCE_RIGHT:return this.isComplete?i:n;case E.NONE:default:return i}}},{key:"doValidate",value:function(){var t,e;return(t=this.masked).doValidate.apply(t,arguments)&&(!this.parent||(e=this.parent).doValidate.apply(e,arguments))}},{key:"doCommit",value:function(){this.masked.doCommit()}},{key:"state",get:function(){return{masked:this.masked.state,isFilled:this.isFilled}},set:function(t){this.masked.state=t.masked,this.isFilled=t.isFilled}}]),t}(),I=function(){function t(e){n(this,t),Object.assign(this,e),this._value="",this.isFixed=!0}return u(t,[{key:"value",get:function(){return this._value}},{key:"unmaskedValue",get:function(){return this.isUnmasking?this.value:""}},{key:"reset",value:function(){this._isRawInput=!1,this._value=""}},{key:"remove",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._value.length;return this._value=this._value.slice(0,t)+this._value.slice(e),this._value||(this._isRawInput=!1),new m}},{key:"nearestInputPos",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E.NONE,n=this._value.length;switch(e){case E.LEFT:case E.FORCE_LEFT:return 0;case E.NONE:case E.RIGHT:case E.FORCE_RIGHT:default:return n}}},{key:"extractInput",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._value.length;return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).raw&&this._isRawInput&&this._value.slice(t,e)||""}},{key:"isComplete",get:function(){return!0}},{key:"isFilled",get:function(){return Boolean(this._value)}},{key:"_appendChar",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new m;if(this._value)return n;var i=!0===this.eager||"append"===this.eager,u=this.char===t&&(this.isUnmasking||e.input||e.raw)&&(!e.raw||!i)&&!e.tail;return u&&(n.rawInserted=this.char),this._value=n.inserted=this.char,this._isRawInput=u&&(e.raw||e.input),n}},{key:"_appendEager",value:function(){return this._appendChar(this.char,{tail:!0})}},{key:"_appendPlaceholder",value:function(){var t=new m;return this._value||(this._value=t.inserted=this.char),t}},{key:"extractTail",value:function(){return arguments.length>1&&void 0!==arguments[1]||this.value.length,new S("")}},{key:"appendTail",value:function(t){return _(t)&&(t=new S(String(t))),t.appendTo(this)}},{key:"append",value:function(t,e,n){var i=this._appendChar(t[0],e);return null!=n&&(i.tailShift+=this.appendTail(n).tailShift),i}},{key:"doCommit",value:function(){}},{key:"state",get:function(){return{_value:this._value,_isRawInput:this._isRawInput}},set:function(t){Object.assign(this,t)}}]),t}(),R=["chunks"],P=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;n(this,t),this.chunks=e,this.from=i}return u(t,[{key:"toString",value:function(){return this.chunks.map(String).join("")}},{key:"extend",value:function(e){if(String(e)){_(e)&&(e=new S(String(e)));var n=this.chunks[this.chunks.length-1],i=n&&(n.stop===e.stop||null==e.stop)&&e.from===n.from+n.toString().length;if(e instanceof S)i?n.extend(e.toString()):this.chunks.push(e);else if(e instanceof t){if(null==e.stop)for(var u;e.chunks.length&&null==e.chunks[0].stop;)(u=e.chunks.shift()).from+=e.from,this.extend(u);e.toString()&&(e.stop=e.blockIndex,this.chunks.push(e))}}}},{key:"appendTo",value:function(e){if(!(e instanceof D.MaskedPattern))return new S(this.toString()).appendTo(e);for(var n=new m,i=0;i<this.chunks.length&&!n.skip;++i){var u=this.chunks[i],s=e._mapPosToBlock(e.value.length),r=u.stop,a=void 0;if(null!=r&&(!s||s.index<=r)&&((u instanceof t||e._stops.indexOf(r)>=0)&&n.aggregate(e._appendPlaceholder(r)),a=u instanceof t&&e._blocks[r]),a){var o=a.appendTail(u);o.skip=!1,n.aggregate(o),e._value+=o.inserted;var l=u.toString().slice(o.rawInserted.length);l&&n.aggregate(e.append(l,{tail:!0}))}else n.aggregate(e.append(u.toString(),{tail:!0}))}return n}},{key:"state",get:function(){return{chunks:this.chunks.map((function(t){return t.state})),from:this.from,stop:this.stop,blockIndex:this.blockIndex}},set:function(e){var n=e.chunks,i=o(e,R);Object.assign(this,i),this.chunks=n.map((function(e){var n="chunks"in e?new t:new S;return n.state=e,n}))}},{key:"unshift",value:function(t){if(!this.chunks.length||null!=t&&this.from>=t)return"";for(var e=null!=t?t-this.from:t,n=0;n<this.chunks.length;){var i=this.chunks[n],u=i.unshift(e);if(i.toString()){if(!u)break;++n}else this.chunks.splice(n,1);if(u)return u}return""}},{key:"shift",value:function(){if(!this.chunks.length)return"";for(var t=this.chunks.length-1;0<=t;){var e=this.chunks[t],n=e.shift();if(e.toString()){if(!n)break;--t}else this.chunks.splice(t,1);if(n)return n}return""}}]),t}(),V=function(){function t(e,i){n(this,t),this.masked=e,this._log=[];var u=e._mapPosToBlock(i)||(i<0?{index:0,offset:0}:{index:this.masked._blocks.length,offset:0}),s=u.offset,r=u.index;this.offset=s,this.index=r,this.ok=!1}return u(t,[{key:"block",get:function(){return this.masked._blocks[this.index]}},{key:"pos",get:function(){return this.masked._blockStartPos(this.index)+this.offset}},{key:"state",get:function(){return{index:this.index,offset:this.offset,ok:this.ok}},set:function(t){Object.assign(this,t)}},{key:"pushState",value:function(){this._log.push(this.state)}},{key:"popState",value:function(){var t=this._log.pop();return this.state=t,t}},{key:"bindBlock",value:function(){this.block||(this.index<0&&(this.index=0,this.offset=0),this.index>=this.masked._blocks.length&&(this.index=this.masked._blocks.length-1,this.offset=this.block.value.length))}},{key:"_pushLeft",value:function(t){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=(null===(e=this.block)||void 0===e?void 0:e.value.length)||0){var e;if(t())return this.ok=!0}return this.ok=!1}},{key:"_pushRight",value:function(t){for(this.pushState(),this.bindBlock();this.index<this.masked._blocks.length;++this.index,this.offset=0)if(t())return this.ok=!0;return this.ok=!1}},{key:"pushLeftBeforeFilled",value:function(){var t=this;return this._pushLeft((function(){if(!t.block.isFixed&&t.block.value)return t.offset=t.block.nearestInputPos(t.offset,E.FORCE_LEFT),0!==t.offset||void 0}))}},{key:"pushLeftBeforeInput",value:function(){var t=this;return this._pushLeft((function(){if(!t.block.isFixed)return t.offset=t.block.nearestInputPos(t.offset,E.LEFT),!0}))}},{key:"pushLeftBeforeRequired",value:function(){var t=this;return this._pushLeft((function(){if(!(t.block.isFixed||t.block.isOptional&&!t.block.value))return t.offset=t.block.nearestInputPos(t.offset,E.LEFT),!0}))}},{key:"pushRightBeforeFilled",value:function(){var t=this;return this._pushRight((function(){if(!t.block.isFixed&&t.block.value)return t.offset=t.block.nearestInputPos(t.offset,E.FORCE_RIGHT),t.offset!==t.block.value.length||void 0}))}},{key:"pushRightBeforeInput",value:function(){var t=this;return this._pushRight((function(){if(!t.block.isFixed)return t.offset=t.block.nearestInputPos(t.offset,E.NONE),!0}))}},{key:"pushRightBeforeRequired",value:function(){var t=this;return this._pushRight((function(){if(!(t.block.isFixed||t.block.isOptional&&!t.block.value))return t.offset=t.block.nearestInputPos(t.offset,E.NONE),!0}))}}]),t}(),L=function(t){s(i,t);var e=h(i);function i(){return n(this,i),e.apply(this,arguments)}return u(i,[{key:"_update",value:function(t){t.mask&&(t.validate=function(e){return e.search(t.mask)>=0}),f(r(i.prototype),"_update",this).call(this,t)}}]),i}(B);D.MaskedRegExp=L;var j=["_blocks"],N=function(t){s(i,t);var e=h(i);function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,i),t.definitions=Object.assign({},T,t.definitions),e.call(this,Object.assign({},i.DEFAULTS,t))}return u(i,[{key:"_update",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.definitions=Object.assign({},this.definitions,t.definitions),f(r(i.prototype),"_update",this).call(this,t),this._rebuildMask()}},{key:"_rebuildMask",value:function(){var t=this,e=this.definitions;this._blocks=[],this._stops=[],this._maskedBlocks={};var n=this.mask;if(n&&e)for(var u=!1,s=!1,r=function(r){if(t.blocks){var o=n.slice(r),l=Object.keys(t.blocks).filter((function(t){return 0===o.indexOf(t)}));l.sort((function(t,e){return e.length-t.length}));var h=l[0];if(h){var c=x(Object.assign({parent:t,lazy:t.lazy,eager:t.eager,placeholderChar:t.placeholderChar,overwrite:t.overwrite},t.blocks[h]));return c&&(t._blocks.push(c),t._maskedBlocks[h]||(t._maskedBlocks[h]=[]),t._maskedBlocks[h].push(t._blocks.length-1)),r+=h.length-1,a=r,"continue"}}var f=n[r],p=f in e;if(f===i.STOP_CHAR)return t._stops.push(t._blocks.length),a=r,"continue";if("{"===f||"}"===f)return u=!u,a=r,"continue";if("["===f||"]"===f)return s=!s,a=r,"continue";if(f===i.ESCAPE_CHAR){if(++r,!(f=n[r]))return a=r,"break";p=!1}var d=p?new O({parent:t,lazy:t.lazy,eager:t.eager,placeholderChar:t.placeholderChar,mask:e[f],isOptional:s}):new I({char:f,eager:t.eager,isUnmasking:u});t._blocks.push(d),a=r},a=0;a<n.length;++a){var o=r(a);if("continue"!==o&&"break"===o)break}}},{key:"state",get:function(){return Object.assign({},f(r(i.prototype),"state",this),{_blocks:this._blocks.map((function(t){return t.state}))})},set:function(t){var e=t._blocks,n=o(t,j);this._blocks.forEach((function(t,n){return t.state=e[n]})),d(r(i.prototype),"state",n,this,!0)}},{key:"reset",value:function(){f(r(i.prototype),"reset",this).call(this),this._blocks.forEach((function(t){return t.reset()}))}},{key:"isComplete",get:function(){return this._blocks.every((function(t){return t.isComplete}))}},{key:"isFilled",get:function(){return this._blocks.every((function(t){return t.isFilled}))}},{key:"isFixed",get:function(){return this._blocks.every((function(t){return t.isFixed}))}},{key:"isOptional",get:function(){return this._blocks.every((function(t){return t.isOptional}))}},{key:"doCommit",value:function(){this._blocks.forEach((function(t){return t.doCommit()})),f(r(i.prototype),"doCommit",this).call(this)}},{key:"unmaskedValue",get:function(){return this._blocks.reduce((function(t,e){return t+e.unmaskedValue}),"")},set:function(t){d(r(i.prototype),"unmaskedValue",t,this,!0)}},{key:"value",get:function(){return this._blocks.reduce((function(t,e){return t+e.value}),"")},set:function(t){d(r(i.prototype),"value",t,this,!0)}},{key:"appendTail",value:function(t){return f(r(i.prototype),"appendTail",this).call(this,t).aggregate(this._appendPlaceholder())}},{key:"_appendEager",value:function(){var t,e=new m,n=null===(t=this._mapPosToBlock(this.value.length))||void 0===t?void 0:t.index;if(null==n)return e;this._blocks[n].isFilled&&++n;for(var i=n;i<this._blocks.length;++i){var u=this._blocks[i]._appendEager();if(!u.inserted)break;e.aggregate(u)}return e}},{key:"_appendCharRaw",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this._mapPosToBlock(this.value.length),i=new m;if(!n)return i;for(var u=n.index;;++u){var s,r,a=this._blocks[u];if(!a)break;var o=a._appendChar(t,Object.assign({},e,{_beforeTailState:null===(s=e._beforeTailState)||void 0===s||null===(r=s._blocks)||void 0===r?void 0:r[u]})),l=o.skip;if(i.aggregate(o),l||o.rawInserted)break}return i}},{key:"extractTail",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,i=new P;return e===n||this._forEachBlocksInRange(e,n,(function(e,n,u,s){var r=e.extractTail(u,s);r.stop=t._findStopBefore(n),r.from=t._blockStartPos(n),r instanceof P&&(r.blockIndex=n),i.extend(r)})),i}},{key:"extractInput",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t===e)return"";var i="";return this._forEachBlocksInRange(t,e,(function(t,e,u,s){i+=t.extractInput(u,s,n)})),i}},{key:"_findStopBefore",value:function(t){for(var e,n=0;n<this._stops.length;++n){var i=this._stops[n];if(!(i<=t))break;e=i}return e}},{key:"_appendPlaceholder",value:function(t){var e=this,n=new m;if(this.lazy&&null==t)return n;var i=this._mapPosToBlock(this.value.length);if(!i)return n;var u=i.index,s=null!=t?t:this._blocks.length;return this._blocks.slice(u,s).forEach((function(i){if(!i.lazy||null!=t){var u=null!=i._blocks?[i._blocks.length]:[],s=i._appendPlaceholder.apply(i,u);e._value+=s.inserted,n.aggregate(s)}})),n}},{key:"_mapPosToBlock",value:function(t){for(var e="",n=0;n<this._blocks.length;++n){var i=this._blocks[n],u=e.length;if(t<=(e+=i.value).length)return{index:n,offset:t-u}}}},{key:"_blockStartPos",value:function(t){return this._blocks.slice(0,t).reduce((function(t,e){return t+e.value.length}),0)}},{key:"_forEachBlocksInRange",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,n=arguments.length>2?arguments[2]:void 0,i=this._mapPosToBlock(t);if(i){var u=this._mapPosToBlock(e),s=u&&i.index===u.index,r=i.offset,a=u&&s?u.offset:this._blocks[i.index].value.length;if(n(this._blocks[i.index],i.index,r,a),u&&!s){for(var o=i.index+1;o<u.index;++o)n(this._blocks[o],o,0,this._blocks[o].value.length);n(this._blocks[u.index],u.index,0,u.offset)}}}},{key:"remove",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,n=f(r(i.prototype),"remove",this).call(this,t,e);return this._forEachBlocksInRange(t,e,(function(t,e,i,u){n.aggregate(t.remove(i,u))})),n}},{key:"nearestInputPos",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E.NONE;if(!this._blocks.length)return 0;var n=new V(this,t);if(e===E.NONE)return n.pushRightBeforeInput()?n.pos:(n.popState(),n.pushLeftBeforeInput()?n.pos:this.value.length);if(e===E.LEFT||e===E.FORCE_LEFT){if(e===E.LEFT){if(n.pushRightBeforeFilled(),n.ok&&n.pos===t)return t;n.popState()}if(n.pushLeftBeforeInput(),n.pushLeftBeforeRequired(),n.pushLeftBeforeFilled(),e===E.LEFT){if(n.pushRightBeforeInput(),n.pushRightBeforeRequired(),n.ok&&n.pos<=t)return n.pos;if(n.popState(),n.ok&&n.pos<=t)return n.pos;n.popState()}return n.ok?n.pos:e===E.FORCE_LEFT?0:(n.popState(),n.ok?n.pos:(n.popState(),n.ok?n.pos:0))}return e===E.RIGHT||e===E.FORCE_RIGHT?(n.pushRightBeforeInput(),n.pushRightBeforeRequired(),n.pushRightBeforeFilled()?n.pos:e===E.FORCE_RIGHT?this.value.length:(n.popState(),n.ok?n.pos:(n.popState(),n.ok?n.pos:this.nearestInputPos(t,E.LEFT)))):t}},{key:"maskedBlock",value:function(t){return this.maskedBlocks(t)[0]}},{key:"maskedBlocks",value:function(t){var e=this,n=this._maskedBlocks[t];return n?n.map((function(t){return e._blocks[t]})):[]}}]),i}(B);N.DEFAULTS={lazy:!0,placeholderChar:"_"},N.STOP_CHAR="`",N.ESCAPE_CHAR="\\",N.InputDefinition=O,N.FixedDefinition=I,D.MaskedPattern=N;var U=function(t){s(i,t);var e=h(i);function i(){return n(this,i),e.apply(this,arguments)}return u(i,[{key:"_matchFrom",get:function(){return this.maxLength-String(this.from).length}},{key:"_update",value:function(t){t=Object.assign({to:this.to||0,from:this.from||0,maxLength:this.maxLength||0},t);var e=String(t.to).length;null!=t.maxLength&&(e=Math.max(e,t.maxLength)),t.maxLength=e;for(var n=String(t.from).padStart(e,"0"),u=String(t.to).padStart(e,"0"),s=0;s<u.length&&u[s]===n[s];)++s;t.mask=u.slice(0,s).replace(/0/g,"\\0")+"0".repeat(e-s),f(r(i.prototype),"_update",this).call(this,t)}},{key:"isComplete",get:function(){return f(r(i.prototype),"isComplete",this)&&Boolean(this.value)}},{key:"boundaries",value:function(t){var e="",n="",i=v(t.match(/^(\D*)(\d*)(\D*)/)||[],3),u=i[1],s=i[2];return s&&(e="0".repeat(u.length)+s,n="9".repeat(u.length)+s),[e=e.padEnd(this.maxLength,"0"),n=n.padEnd(this.maxLength,"9")]}},{key:"doPrepare",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=v(F(f(r(i.prototype),"doPrepare",this).call(this,t.replace(/\D/g,""),n)),2);if(t=u[0],e=u[1],!this.autofix||!t)return t;var s=String(this.from).padStart(this.maxLength,"0"),a=String(this.to).padStart(this.maxLength,"0"),o=this.value+t;if(o.length>this.maxLength)return"";var l=v(this.boundaries(o),2),h=l[0],c=l[1];return Number(c)<this.from?s[o.length-1]:Number(h)>this.to?"pad"===this.autofix&&o.length<this.maxLength?["",e.aggregate(this.append(s[o.length-1]+t,n))]:a[o.length-1]:t}},{key:"doValidate",value:function(){var t,e=this.value;if(-1===e.search(/[^0]/)&&e.length<=this._matchFrom)return!0;for(var n=v(this.boundaries(e),2),u=n[0],s=n[1],a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];return this.from<=Number(s)&&Number(u)<=this.to&&(t=f(r(i.prototype),"doValidate",this)).call.apply(t,[this].concat(o))}}]),i}(N);D.MaskedRange=U;var H=function(t){s(i,t);var e=h(i);function i(t){return n(this,i),e.call(this,Object.assign({},i.DEFAULTS,t))}return u(i,[{key:"_update",value:function(t){t.mask===Date&&delete t.mask,t.pattern&&(t.mask=t.pattern);var e=t.blocks;t.blocks=Object.assign({},i.GET_DEFAULT_BLOCKS()),t.min&&(t.blocks.Y.from=t.min.getFullYear()),t.max&&(t.blocks.Y.to=t.max.getFullYear()),t.min&&t.max&&t.blocks.Y.from===t.blocks.Y.to&&(t.blocks.m.from=t.min.getMonth()+1,t.blocks.m.to=t.max.getMonth()+1,t.blocks.m.from===t.blocks.m.to&&(t.blocks.d.from=t.min.getDate(),t.blocks.d.to=t.max.getDate())),Object.assign(t.blocks,this.blocks,e),Object.keys(t.blocks).forEach((function(e){var n=t.blocks[e];!("autofix"in n)&&"autofix"in t&&(n.autofix=t.autofix)})),f(r(i.prototype),"_update",this).call(this,t)}},{key:"doValidate",value:function(){for(var t,e=this.date,n=arguments.length,u=new Array(n),s=0;s<n;s++)u[s]=arguments[s];return(t=f(r(i.prototype),"doValidate",this)).call.apply(t,[this].concat(u))&&(!this.isComplete||this.isDateExist(this.value)&&null!=e&&(null==this.min||this.min<=e)&&(null==this.max||e<=this.max))}},{key:"isDateExist",value:function(t){return this.format(this.parse(t,this),this).indexOf(t)>=0}},{key:"date",get:function(){return this.typedValue},set:function(t){this.typedValue=t}},{key:"typedValue",get:function(){return this.isComplete?f(r(i.prototype),"typedValue",this):null},set:function(t){d(r(i.prototype),"typedValue",t,this,!0)}},{key:"maskEquals",value:function(t){return t===Date||f(r(i.prototype),"maskEquals",this).call(this,t)}}]),i}(N);H.DEFAULTS={pattern:"d{.}`m{.}`Y",format:function(t){return t?[String(t.getDate()).padStart(2,"0"),String(t.getMonth()+1).padStart(2,"0"),t.getFullYear()].join("."):""},parse:function(t){var e=v(t.split("."),3),n=e[0],i=e[1],u=e[2];return new Date(u,i-1,n)}},H.GET_DEFAULT_BLOCKS=function(){return{d:{mask:U,from:1,to:31,maxLength:2},m:{mask:U,from:1,to:12,maxLength:2},Y:{mask:U,from:1900,to:9999}}},D.MaskedDate=H;var G=function(){function t(){n(this,t)}return u(t,[{key:"selectionStart",get:function(){var t;try{t=this._unsafeSelectionStart}catch(t){}return null!=t?t:this.value.length}},{key:"selectionEnd",get:function(){var t;try{t=this._unsafeSelectionEnd}catch(t){}return null!=t?t:this.value.length}},{key:"select",value:function(t,e){if(null!=t&&null!=e&&(t!==this.selectionStart||e!==this.selectionEnd))try{this._unsafeSelect(t,e)}catch(t){}}},{key:"_unsafeSelect",value:function(t,e){}},{key:"isActive",get:function(){return!1}},{key:"bindEvents",value:function(t){}},{key:"unbindEvents",value:function(){}}]),t}();D.MaskElement=G;var q=function(t){s(i,t);var e=h(i);function i(t){var u;return n(this,i),(u=e.call(this)).input=t,u._handlers={},u}return u(i,[{key:"rootElement",get:function(){var t,e,n;return null!==(t=null===(e=(n=this.input).getRootNode)||void 0===e?void 0:e.call(n))&&void 0!==t?t:document}},{key:"isActive",get:function(){return this.input===this.rootElement.activeElement}},{key:"_unsafeSelectionStart",get:function(){return this.input.selectionStart}},{key:"_unsafeSelectionEnd",get:function(){return this.input.selectionEnd}},{key:"_unsafeSelect",value:function(t,e){this.input.setSelectionRange(t,e)}},{key:"value",get:function(){return this.input.value},set:function(t){this.input.value=t}},{key:"bindEvents",value:function(t){var e=this;Object.keys(t).forEach((function(n){return e._toggleEventHandler(i.EVENTS_MAP[n],t[n])}))}},{key:"unbindEvents",value:function(){var t=this;Object.keys(this._handlers).forEach((function(e){return t._toggleEventHandler(e)}))}},{key:"_toggleEventHandler",value:function(t,e){this._handlers[t]&&(this.input.removeEventListener(t,this._handlers[t]),delete this._handlers[t]),e&&(this.input.addEventListener(t,e),this._handlers[t]=e)}}]),i}(G);q.EVENTS_MAP={selectionChange:"keydown",input:"input",drop:"drop",click:"click",focus:"focus",commit:"blur"},D.HTMLMaskElement=q;var Y=function(t){s(i,t);var e=h(i);function i(){return n(this,i),e.apply(this,arguments)}return u(i,[{key:"_unsafeSelectionStart",get:function(){var t=this.rootElement,e=t.getSelection&&t.getSelection(),n=e&&e.anchorOffset,i=e&&e.focusOffset;return null==i||null==n||n<i?n:i}},{key:"_unsafeSelectionEnd",get:function(){var t=this.rootElement,e=t.getSelection&&t.getSelection(),n=e&&e.anchorOffset,i=e&&e.focusOffset;return null==i||null==n||n>i?n:i}},{key:"_unsafeSelect",value:function(t,e){if(this.rootElement.createRange){var n=this.rootElement.createRange();n.setStart(this.input.firstChild||this.input,t),n.setEnd(this.input.lastChild||this.input,e);var i=this.rootElement,u=i.getSelection&&i.getSelection();u&&(u.removeAllRanges(),u.addRange(n))}}},{key:"value",get:function(){return this.input.textContent},set:function(t){this.input.textContent=t}}]),i}(q);D.HTMLContenteditableMaskElement=Y;var z=["mask"],K=function(){function t(e,i){n(this,t),this.el=e instanceof G?e:e.isContentEditable&&"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?new Y(e):new q(e),this.masked=x(i),this._listeners={},this._value="",this._unmaskedValue="",this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._onFocus=this._onFocus.bind(this),this._onClick=this._onClick.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}return u(t,[{key:"mask",get:function(){return this.masked.mask},set:function(t){if(!this.maskEquals(t))if(t instanceof D.Masked||this.masked.constructor!==w(t)){var e=x({mask:t});e.unmaskedValue=this.masked.unmaskedValue,this.masked=e}else this.masked.updateOptions({mask:t})}},{key:"maskEquals",value:function(t){var e;return null==t||(null===(e=this.masked)||void 0===e?void 0:e.maskEquals(t))}},{key:"value",get:function(){return this._value},set:function(t){this.value!==t&&(this.masked.value=t,this.updateControl(),this.alignCursor())}},{key:"unmaskedValue",get:function(){return this._unmaskedValue},set:function(t){this.unmaskedValue!==t&&(this.masked.unmaskedValue=t,this.updateControl(),this.alignCursor())}},{key:"typedValue",get:function(){return this.masked.typedValue},set:function(t){this.masked.typedValueEquals(t)||(this.masked.typedValue=t,this.updateControl(),this.alignCursor())}},{key:"_bindEvents",value:function(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange})}},{key:"_unbindEvents",value:function(){this.el&&this.el.unbindEvents()}},{key:"_fireEvent",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];var u=this._listeners[t];u&&u.forEach((function(t){return t.apply(void 0,n)}))}},{key:"selectionStart",get:function(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}},{key:"cursorPos",get:function(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd},set:function(t){this.el&&this.el.isActive&&(this.el.select(t,t),this._saveSelection())}},{key:"_saveSelection",value:function(){this.value!==this.el.value&&console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."),this._selection={start:this.selectionStart,end:this.cursorPos}}},{key:"updateValue",value:function(){this.masked.value=this.el.value,this._value=this.masked.value}},{key:"updateControl",value:function(){var t=this.masked.unmaskedValue,e=this.masked.value,n=this.unmaskedValue!==t||this.value!==e;this._unmaskedValue=t,this._value=e,this.el.value!==e&&(this.el.value=e),n&&this._fireChangeEvents()}},{key:"updateOptions",value:function(t){var e=t.mask,n=o(t,z),i=!this.maskEquals(e),u=!C(this.masked,n);i&&(this.mask=e),u&&this.masked.updateOptions(n),(i||u)&&this.updateControl()}},{key:"updateCursor",value:function(t){null!=t&&(this.cursorPos=t,this._delayUpdateCursor(t))}},{key:"_delayUpdateCursor",value:function(t){var e=this;this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout((function(){e.el&&(e.cursorPos=e._changingCursorPos,e._abortUpdateCursor())}),10)}},{key:"_fireChangeEvents",value:function(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}},{key:"_abortUpdateCursor",value:function(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}},{key:"alignCursor",value:function(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,E.LEFT))}},{key:"alignCursorFriendly",value:function(){this.selectionStart===this.cursorPos&&this.alignCursor()}},{key:"on",value:function(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this}},{key:"off",value:function(t,e){if(!this._listeners[t])return this;if(!e)return delete this._listeners[t],this;var n=this._listeners[t].indexOf(e);return n>=0&&this._listeners[t].splice(n,1),this}},{key:"_onInput",value:function(t){if(this._inputEvent=t,this._abortUpdateCursor(),!this._selection)return this.updateValue();var e=new b(this.el.value,this.cursorPos,this.value,this._selection),n=this.masked.rawInputValue,i=this.masked.splice(e.startChangePos,e.removed.length,e.inserted,e.removeDirection,{input:!0,raw:!0}).offset,u=n===this.masked.rawInputValue?e.removeDirection:E.NONE,s=this.masked.nearestInputPos(e.startChangePos+i,u);u!==E.NONE&&(s=this.masked.nearestInputPos(s,E.NONE)),this.updateControl(),this.updateCursor(s),delete this._inputEvent}},{key:"_onChange",value:function(){this.value!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl(),this._saveSelection()}},{key:"_onDrop",value:function(t){t.preventDefault(),t.stopPropagation()}},{key:"_onFocus",value:function(t){this.alignCursorFriendly()}},{key:"_onClick",value:function(t){this.alignCursorFriendly()}},{key:"destroy",value:function(){this._unbindEvents(),this._listeners.length=0,delete this.el}}]),t}();D.InputMask=K;var Z=function(t){s(i,t);var e=h(i);function i(){return n(this,i),e.apply(this,arguments)}return u(i,[{key:"_update",value:function(t){t.enum&&(t.mask="*".repeat(t.enum[0].length)),f(r(i.prototype),"_update",this).call(this,t)}},{key:"doValidate",value:function(){for(var t,e=this,n=arguments.length,u=new Array(n),s=0;s<n;s++)u[s]=arguments[s];return this.enum.some((function(t){return t.indexOf(e.unmaskedValue)>=0}))&&(t=f(r(i.prototype),"doValidate",this)).call.apply(t,[this].concat(u))}}]),i}(N);D.MaskedEnum=Z;var X,$=function(t){s(i,t);var e=h(i);function i(t){return n(this,i),e.call(this,Object.assign({},i.DEFAULTS,t))}return u(i,[{key:"_update",value:function(t){f(r(i.prototype),"_update",this).call(this,t),this._updateRegExps()}},{key:"_updateRegExps",value:function(){var t="^"+(this.allowNegative?"[+|\\-]?":""),e=(this.scale?"(".concat(A(this.radix),"\\d{0,").concat(this.scale,"})?"):"")+"$";this._numberRegExp=new RegExp(t+"\\d*"+e),this._mapToRadixRegExp=new RegExp("[".concat(this.mapToRadix.map(A).join(""),"]"),"g"),this._thousandsSeparatorRegExp=new RegExp(A(this.thousandsSeparator),"g")}},{key:"_removeThousandsSeparators",value:function(t){return t.replace(this._thousandsSeparatorRegExp,"")}},{key:"_insertThousandsSeparators",value:function(t){var e=t.split(this.radix);return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),e.join(this.radix)}},{key:"doPrepare",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t=this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&e.raw?t.replace(this._mapToRadixRegExp,this.radix):t);var n=v(F(f(r(i.prototype),"doPrepare",this).call(this,t,e)),2),u=n[0],s=n[1];return t&&!u&&(s.skip=!0),[u,s]}},{key:"_separatorsCount",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=0,i=0;i<t;++i)this._value.indexOf(this.thousandsSeparator,i)===i&&(++n,e&&(t+=this.thousandsSeparator.length));return n}},{key:"_separatorsCountFromSlice",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._value;return this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}},{key:"extractInput",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,n=arguments.length>2?arguments[2]:void 0,u=v(this._adjustRangeWithSeparators(t,e),2);return t=u[0],e=u[1],this._removeThousandsSeparators(f(r(i.prototype),"extractInput",this).call(this,t,e,n))}},{key:"_appendCharRaw",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.thousandsSeparator)return f(r(i.prototype),"_appendCharRaw",this).call(this,t,e);var n=e.tail&&e._beforeTailState?e._beforeTailState._value:this._value,u=this._separatorsCountFromSlice(n);this._value=this._removeThousandsSeparators(this.value);var s=f(r(i.prototype),"_appendCharRaw",this).call(this,t,e);this._value=this._insertThousandsSeparators(this._value);var a=e.tail&&e._beforeTailState?e._beforeTailState._value:this._value,o=this._separatorsCountFromSlice(a);return s.tailShift+=(o-u)*this.thousandsSeparator.length,s.skip=!s.rawInserted&&t===this.thousandsSeparator,s}},{key:"_findSeparatorAround",value:function(t){if(this.thousandsSeparator){var e=t-this.thousandsSeparator.length+1,n=this.value.indexOf(this.thousandsSeparator,e);if(n<=t)return n}return-1}},{key:"_adjustRangeWithSeparators",value:function(t,e){var n=this._findSeparatorAround(t);n>=0&&(t=n);var i=this._findSeparatorAround(e);return i>=0&&(e=i+this.thousandsSeparator.length),[t,e]}},{key:"remove",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,n=v(this._adjustRangeWithSeparators(t,e),2);t=n[0],e=n[1];var i=this.value.slice(0,t),u=this.value.slice(e),s=this._separatorsCount(i.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(i+u));var r=this._separatorsCountFromSlice(i);return new m({tailShift:(r-s)*this.thousandsSeparator.length})}},{key:"nearestInputPos",value:function(t,e){if(!this.thousandsSeparator)return t;switch(e){case E.NONE:case E.LEFT:case E.FORCE_LEFT:var n=this._findSeparatorAround(t-1);if(n>=0){var i=n+this.thousandsSeparator.length;if(t<i||this.value.length<=i||e===E.FORCE_LEFT)return n}break;case E.RIGHT:case E.FORCE_RIGHT:var u=this._findSeparatorAround(t);if(u>=0)return u+this.thousandsSeparator.length}return t}},{key:"doValidate",value:function(t){var e=Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));if(e){var n=this.number;e=e&&!isNaN(n)&&(null==this.min||this.min>=0||this.min<=this.number)&&(null==this.max||this.max<=0||this.number<=this.max)}return e&&f(r(i.prototype),"doValidate",this).call(this,t)}},{key:"doCommit",value:function(){if(this.value){var t=this.number,e=t;null!=this.min&&(e=Math.max(e,this.min)),null!=this.max&&(e=Math.min(e,this.max)),e!==t&&(this.unmaskedValue=this.doFormat(e));var n=this.value;this.normalizeZeros&&(n=this._normalizeZeros(n)),this.padFractionalZeros&&this.scale>0&&(n=this._padFractionalZeros(n)),this._value=n}f(r(i.prototype),"doCommit",this).call(this)}},{key:"_normalizeZeros",value:function(t){var e=this._removeThousandsSeparators(t).split(this.radix);return e[0]=e[0].replace(/^(\D*)(0*)(\d*)/,(function(t,e,n,i){return e+i})),t.length&&!/\d$/.test(e[0])&&(e[0]=e[0]+"0"),e.length>1&&(e[1]=e[1].replace(/0*$/,""),e[1].length||(e.length=1)),this._insertThousandsSeparators(e.join(this.radix))}},{key:"_padFractionalZeros",value:function(t){if(!t)return t;var e=t.split(this.radix);return e.length<2&&e.push(""),e[1]=e[1].padEnd(this.scale,"0"),e.join(this.radix)}},{key:"doSkipInvalid",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,u=0===this.scale&&t!==this.thousandsSeparator&&(t===this.radix||t===i.UNMASKED_RADIX||this.mapToRadix.includes(t));return f(r(i.prototype),"doSkipInvalid",this).call(this,t,e,n)&&!u}},{key:"unmaskedValue",get:function(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,i.UNMASKED_RADIX)},set:function(t){d(r(i.prototype),"unmaskedValue",t.replace(i.UNMASKED_RADIX,this.radix),this,!0)}},{key:"typedValue",get:function(){return this.doParse(this.unmaskedValue)},set:function(t){this.rawInputValue=this.doFormat(t).replace(i.UNMASKED_RADIX,this.radix)}},{key:"number",get:function(){return this.typedValue},set:function(t){this.typedValue=t}},{key:"allowNegative",get:function(){return this.signed||null!=this.min&&this.min<0||null!=this.max&&this.max<0}},{key:"typedValueEquals",value:function(t){return(f(r(i.prototype),"typedValueEquals",this).call(this,t)||i.EMPTY_VALUES.includes(t)&&i.EMPTY_VALUES.includes(this.typedValue))&&!(0===t&&""===this.value)}}]),i}(B);$.UNMASKED_RADIX=".",$.DEFAULTS={radix:",",thousandsSeparator:"",mapToRadix:[$.UNMASKED_RADIX],scale:2,signed:!1,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:function(t){return t.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})}},$.EMPTY_VALUES=[].concat(function(t){if(Array.isArray(t))return g(t)}(X=B.EMPTY_VALUES)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(X)||k(X)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[0]),D.MaskedNumber=$;var W=function(t){s(i,t);var e=h(i);function i(){return n(this,i),e.apply(this,arguments)}return u(i,[{key:"_update",value:function(t){t.mask&&(t.validate=t.mask),f(r(i.prototype),"_update",this).call(this,t)}}]),i}(B);D.MaskedFunction=W;var J=["compiledMasks","currentMaskRef","currentMask"],Q=function(t){s(i,t);var e=h(i);function i(t){var u;return n(this,i),(u=e.call(this,Object.assign({},i.DEFAULTS,t))).currentMask=null,u}return u(i,[{key:"_update",value:function(t){f(r(i.prototype),"_update",this).call(this,t),"mask"in t&&(this.compiledMasks=Array.isArray(t.mask)?t.mask.map((function(t){return x(t)})):[])}},{key:"_appendCharRaw",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this._applyDispatch(t,e);return this.currentMask&&n.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(e))),n}},{key:"_applyDispatch",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.tail&&null!=e._beforeTailState?e._beforeTailState._value:this.value,i=this.rawInputValue,u=e.tail&&null!=e._beforeTailState?e._beforeTailState._rawInputValue:i,s=i.slice(u.length),r=this.currentMask,a=new m,o=null==r?void 0:r.state;if(this.currentMask=this.doDispatch(t,Object.assign({},e)),this.currentMask)if(this.currentMask!==r){if(this.currentMask.reset(),u){var l=this.currentMask.append(u,{raw:!0});a.tailShift=l.inserted.length-n.length}s&&(a.tailShift+=this.currentMask.append(s,{raw:!0,tail:!0}).tailShift)}else this.currentMask.state=o;return a}},{key:"_appendPlaceholder",value:function(){var t=this._applyDispatch.apply(this,arguments);return this.currentMask&&t.aggregate(this.currentMask._appendPlaceholder()),t}},{key:"_appendEager",value:function(){var t=this._applyDispatch.apply(this,arguments);return this.currentMask&&t.aggregate(this.currentMask._appendEager()),t}},{key:"currentMaskFlags",value:function(t){var e,n;return Object.assign({},t,{_beforeTailState:(null===(e=t._beforeTailState)||void 0===e?void 0:e.currentMaskRef)===this.currentMask&&(null===(n=t._beforeTailState)||void 0===n?void 0:n.currentMask)||t._beforeTailState})}},{key:"doDispatch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.dispatch(t,this,e)}},{key:"doValidate",value:function(t){return f(r(i.prototype),"doValidate",this).call(this,t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}},{key:"doPrepare",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=v(F(f(r(i.prototype),"doPrepare",this).call(this,t,e)),2),u=n[0],s=n[1];if(this.currentMask){var a,o=v(F(f(r(i.prototype),"doPrepare",this).call(this,u,this.currentMaskFlags(e))),2);u=o[0],a=o[1],s=s.aggregate(a)}return[u,s]}},{key:"reset",value:function(){var t;null===(t=this.currentMask)||void 0===t||t.reset(),this.compiledMasks.forEach((function(t){return t.reset()}))}},{key:"value",get:function(){return this.currentMask?this.currentMask.value:""},set:function(t){d(r(i.prototype),"value",t,this,!0)}},{key:"unmaskedValue",get:function(){return this.currentMask?this.currentMask.unmaskedValue:""},set:function(t){d(r(i.prototype),"unmaskedValue",t,this,!0)}},{key:"typedValue",get:function(){return this.currentMask?this.currentMask.typedValue:""},set:function(t){var e=String(t);this.currentMask&&(this.currentMask.typedValue=t,e=this.currentMask.unmaskedValue),this.unmaskedValue=e}},{key:"isComplete",get:function(){var t;return Boolean(null===(t=this.currentMask)||void 0===t?void 0:t.isComplete)}},{key:"isFilled",get:function(){var t;return Boolean(null===(t=this.currentMask)||void 0===t?void 0:t.isFilled)}},{key:"remove",value:function(){var t,e=new m;this.currentMask&&e.aggregate((t=this.currentMask).remove.apply(t,arguments)).aggregate(this._applyDispatch());return e}},{key:"state",get:function(){var t;return Object.assign({},f(r(i.prototype),"state",this),{_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map((function(t){return t.state})),currentMaskRef:this.currentMask,currentMask:null===(t=this.currentMask)||void 0===t?void 0:t.state})},set:function(t){var e=t.compiledMasks,n=t.currentMaskRef,u=t.currentMask,s=o(t,J);this.compiledMasks.forEach((function(t,n){return t.state=e[n]})),null!=n&&(this.currentMask=n,this.currentMask.state=u),d(r(i.prototype),"state",s,this,!0)}},{key:"extractInput",value:function(){var t;return this.currentMask?(t=this.currentMask).extractInput.apply(t,arguments):""}},{key:"extractTail",value:function(){for(var t,e,n=arguments.length,u=new Array(n),s=0;s<n;s++)u[s]=arguments[s];return this.currentMask?(t=this.currentMask).extractTail.apply(t,u):(e=f(r(i.prototype),"extractTail",this)).call.apply(e,[this].concat(u))}},{key:"doCommit",value:function(){this.currentMask&&this.currentMask.doCommit(),f(r(i.prototype),"doCommit",this).call(this)}},{key:"nearestInputPos",value:function(){for(var t,e,n=arguments.length,u=new Array(n),s=0;s<n;s++)u[s]=arguments[s];return this.currentMask?(t=this.currentMask).nearestInputPos.apply(t,u):(e=f(r(i.prototype),"nearestInputPos",this)).call.apply(e,[this].concat(u))}},{key:"overwrite",get:function(){return this.currentMask?this.currentMask.overwrite:f(r(i.prototype),"overwrite",this)},set:function(t){console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings')}},{key:"eager",get:function(){return this.currentMask?this.currentMask.eager:f(r(i.prototype),"eager",this)},set:function(t){console.warn('"eager" option is not available in dynamic mask, use this option in siblings')}},{key:"skipInvalid",get:function(){return this.currentMask?this.currentMask.skipInvalid:f(r(i.prototype),"skipInvalid",this)},set:function(t){console.warn('"skipInvalid" option is not available in dynamic mask, use this option in siblings')}},{key:"maskEquals",value:function(t){return Array.isArray(t)&&this.compiledMasks.every((function(e,n){var i;return e.maskEquals(null===(i=t[n])||void 0===i?void 0:i.mask)}))}},{key:"typedValueEquals",value:function(t){var e;return Boolean(null===(e=this.currentMask)||void 0===e?void 0:e.typedValueEquals(t))}}]),i}(B);Q.DEFAULTS={dispatch:function(t,e,n){if(e.compiledMasks.length){var i=e.rawInputValue,u=e.compiledMasks.map((function(u,s){return u.reset(),u.append(i,{raw:!0}),u.append(t,e.currentMaskFlags(n)),{weight:u.rawInputValue.length,index:s}}));return u.sort((function(t,e){return e.weight-t.weight})),e.compiledMasks[u[0].index]}}},D.MaskedDynamic=Q;var tt={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function et(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tt.MASKED,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:tt.MASKED,i=x(t);return function(t){return i.runIsolated((function(i){return i[e]=t,i[n]}))}}function nt(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return et.apply(void 0,n)(t)}D.PIPE_TYPE=tt,D.createPipe=et,D.pipe=nt;try{globalThis.IMask=D}catch(t){}t.ChangeDetails=m,t.HTMLContenteditableMaskElement=Y,t.HTMLMaskElement=q,t.InputMask=K,t.MaskElement=G,t.Masked=B,t.MaskedDate=H,t.MaskedDynamic=Q,t.MaskedEnum=Z,t.MaskedFunction=W,t.MaskedNumber=$,t.MaskedPattern=N,t.MaskedRange=U,t.MaskedRegExp=L,t.PIPE_TYPE=tt,t.createMask=x,t.createPipe=et,t.default=D,t.pipe=nt,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).IMask={})}(this,(function(t){"use strict";function e(t,e){if(null==t)return{};var s,i,u={},a=Object.keys(t);for(i=0;i<a.length;i++)s=a[i],e.indexOf(s)>=0||(u[s]=t[s]);return u}class s{constructor(t){Object.assign(this,{inserted:"",rawInserted:"",skip:!1,tailShift:0},t)}aggregate(t){return this.rawInserted+=t.rawInserted,this.skip=this.skip||t.skip,this.inserted+=t.inserted,this.tailShift+=t.tailShift,this}get offset(){return this.tailShift+this.inserted.length}}function i(t){return"string"==typeof t||t instanceof String}const u={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function a(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function n(t){return Array.isArray(t)?t:[t,new s]}function r(t,e){if(e===t)return!0;var s,i=Array.isArray(e),u=Array.isArray(t);if(i&&u){if(e.length!=t.length)return!1;for(s=0;s<e.length;s++)if(!r(e[s],t[s]))return!1;return!0}if(i!=u)return!1;if(e&&t&&"object"==typeof e&&"object"==typeof t){var a=e instanceof Date,n=t instanceof Date;if(a&&n)return e.getTime()==t.getTime();if(a!=n)return!1;var h=e instanceof RegExp,o=t instanceof RegExp;if(h&&o)return e.toString()==t.toString();if(h!=o)return!1;var l=Object.keys(e);for(s=0;s<l.length;s++)if(!Object.prototype.hasOwnProperty.call(t,l[s]))return!1;for(s=0;s<l.length;s++)if(!r(t[l[s]],e[l[s]]))return!1;return!0}return!(!e||!t||"function"!=typeof e||"function"!=typeof t)&&e.toString()===t.toString()}class h{constructor(t,e,s,i){for(this.value=t,this.cursorPos=e,this.oldValue=s,this.oldSelection=i;this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start}get startChangePos(){return Math.min(this.cursorPos,this.oldSelection.start)}get insertedCount(){return this.cursorPos-this.startChangePos}get inserted(){return this.value.substr(this.startChangePos,this.insertedCount)}get removedCount(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}get removed(){return this.oldValue.substr(this.startChangePos,this.removedCount)}get head(){return this.value.substring(0,this.startChangePos)}get tail(){return this.value.substring(this.startChangePos+this.insertedCount)}get removeDirection(){return!this.removedCount||this.insertedCount?u.NONE:this.oldSelection.end!==this.cursorPos&&this.oldSelection.start!==this.cursorPos||this.oldSelection.end!==this.oldSelection.start?u.LEFT:u.RIGHT}}class o{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2?arguments[2]:void 0;this.value=t,this.from=e,this.stop=s}toString(){return this.value}extend(t){this.value+=String(t)}appendTo(t){return t.append(this.toString(),{tail:!0}).aggregate(t._appendPlaceholder())}get state(){return{value:this.value,from:this.from,stop:this.stop}}set state(t){Object.assign(this,t)}unshift(t){if(!this.value.length||null!=t&&this.from>=t)return"";const e=this.value[0];return this.value=this.value.slice(1),e}shift(){if(!this.value.length)return"";const t=this.value[this.value.length-1];return this.value=this.value.slice(0,-1),t}}function l(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new l.InputMask(t,e)}class d{constructor(t){this._value="",this._update(Object.assign({},d.DEFAULTS,t)),this.isInitialized=!0}updateOptions(t){Object.keys(t).length&&this.withValueRefresh(this._update.bind(this,t))}_update(t){Object.assign(this,t)}get state(){return{_value:this.value}}set state(t){this._value=t._value}reset(){this._value=""}get value(){return this._value}set value(t){this.resolve(t)}resolve(t){return this.reset(),this.append(t,{input:!0},""),this.doCommit(),this.value}get unmaskedValue(){return this.value}set unmaskedValue(t){this.reset(),this.append(t,{},""),this.doCommit()}get typedValue(){return this.doParse(this.value)}set typedValue(t){this.value=this.doFormat(t)}get rawInputValue(){return this.extractInput(0,this.value.length,{raw:!0})}set rawInputValue(t){this.reset(),this.append(t,{raw:!0},""),this.doCommit()}get isComplete(){return!0}get isFilled(){return this.isComplete}nearestInputPos(t,e){return t}extractInput(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this.value.slice(t,e)}extractTail(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return new o(this.extractInput(t,e),t)}appendTail(t){return i(t)&&(t=new o(String(t))),t.appendTo(this)}_appendCharRaw(t){return t?(this._value+=t,new s({inserted:t,rawInserted:t})):new s}_appendChar(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const u=this.state;let a;if([t,a]=n(this.doPrepare(t,e)),a=a.aggregate(this._appendCharRaw(t,e)),a.inserted){let t,n=!1!==this.doValidate(e);if(n&&null!=i){const e=this.state;!0===this.overwrite&&(t=i.state,i.unshift(this.value.length-a.tailShift));let s=this.appendTail(i);n=s.rawInserted===i.toString(),n&&s.inserted||"shift"!==this.overwrite||(this.state=e,t=i.state,i.shift(),s=this.appendTail(i),n=s.rawInserted===i.toString()),n&&s.inserted&&(this.state=e)}n||(a=new s,this.state=u,i&&t&&(i.state=t))}return a}_appendPlaceholder(){return new s}_appendEager(){return new s}append(t,e,u){if(!i(t))throw new Error("value should be string");const a=new s,n=i(u)?new o(String(u)):u;null!=e&&e.tail&&(e._beforeTailState=this.state);for(let s=0;s<t.length;++s){const i=this._appendChar(t[s],e,n);if(!i.rawInserted&&!this.doSkipInvalid(t[s],e,n))break;a.aggregate(i)}return null!=n&&(a.tailShift+=this.appendTail(n).tailShift),(!0===this.eager||"append"===this.eager)&&null!=e&&e.input&&t&&a.aggregate(this._appendEager()),a}remove(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this._value=this.value.slice(0,t)+this.value.slice(e),new s}withValueRefresh(t){if(this._refreshing||!this.isInitialized)return t();this._refreshing=!0;const e=this.rawInputValue,s=this.value,i=t();return this.rawInputValue=e,this.value&&this.value!==s&&0===s.indexOf(this.value)&&this.append(s.slice(this.value.length),{},""),delete this._refreshing,i}runIsolated(t){if(this._isolated||!this.isInitialized)return t(this);this._isolated=!0;const e=this.state,s=t(this);return this.state=e,delete this._isolated,s}doSkipInvalid(t){return this.skipInvalid}doPrepare(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.prepare?this.prepare(t,this,e):t}doValidate(t){return(!this.validate||this.validate(this.value,this,t))&&(!this.parent||this.parent.doValidate(t))}doCommit(){this.commit&&this.commit(this.value,this)}doFormat(t){return this.format?this.format(t,this):t}doParse(t){return this.parse?this.parse(t,this):t}splice(t,e,i,a){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{input:!0};const r=t+e,h=this.extractTail(r),o=!0===this.eager||"remove"===this.eager;let l;o&&(a=function(t){switch(t){case u.LEFT:return u.FORCE_LEFT;case u.RIGHT:return u.FORCE_RIGHT;default:return t}}(a),l=this.extractInput(0,r,{raw:!0}));let d=t;const c=new s;if(a!==u.NONE&&(d=this.nearestInputPos(t,e>1&&0!==t&&!o?u.NONE:a),c.tailShift=d-t),c.aggregate(this.remove(d)),o&&a!==u.NONE&&l===this.rawInputValue)if(a===u.FORCE_LEFT){let t;for(;l===this.rawInputValue&&(t=this.value.length);)c.aggregate(new s({tailShift:-1})).aggregate(this.remove(t-1))}else a===u.FORCE_RIGHT&&h.unshift();return c.aggregate(this.append(i,n,h))}maskEquals(t){return this.mask===t}typedValueEquals(t){const e=this.typedValue;return t===e||d.EMPTY_VALUES.includes(t)&&d.EMPTY_VALUES.includes(e)||this.doFormat(t)===this.doFormat(this.typedValue)}}function c(t){if(null==t)throw new Error("mask property should be defined");return t instanceof RegExp?l.MaskedRegExp:i(t)?l.MaskedPattern:t instanceof Date||t===Date?l.MaskedDate:t instanceof Number||"number"==typeof t||t===Number?l.MaskedNumber:Array.isArray(t)||t===Array?l.MaskedDynamic:l.Masked&&t.prototype instanceof l.Masked?t:t instanceof l.Masked?t.constructor:t instanceof Function?l.MaskedFunction:(console.warn("Mask not found for mask",t),l.Masked)}function p(t){if(l.Masked&&t instanceof l.Masked)return t;const e=(t=Object.assign({},t)).mask;if(l.Masked&&e instanceof l.Masked)return e;const s=c(e);if(!s)throw new Error("Masked class is not found for provided mask, appropriate module needs to be import manually before creating mask.");return new s(t)}d.DEFAULTS={format:String,parse:t=>t,skipInvalid:!0},d.EMPTY_VALUES=[void 0,null,""],l.Masked=d,l.createMask=p;const g=["mask"],k={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./};class f{constructor(t){const{mask:s}=t,i=e(t,g);this.masked=p({mask:s}),Object.assign(this,i)}reset(){this.isFilled=!1,this.masked.reset()}remove(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return 0===t&&e>=1?(this.isFilled=!1,this.masked.remove(t,e)):new s}get value(){return this.masked.value||(this.isFilled&&!this.isOptional?this.placeholderChar:"")}get unmaskedValue(){return this.masked.unmaskedValue}get isComplete(){return Boolean(this.masked.value)||this.isOptional}_appendChar(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isFilled)return new s;const i=this.masked.state,u=this.masked._appendChar(t,e);return u.inserted&&!1===this.doValidate(e)&&(u.inserted=u.rawInserted="",this.masked.state=i),u.inserted||this.isOptional||this.lazy||e.input||(u.inserted=this.placeholderChar),u.skip=!u.inserted&&!this.isOptional,this.isFilled=Boolean(u.inserted),u}append(){return this.masked.append(...arguments)}_appendPlaceholder(){const t=new s;return this.isFilled||this.isOptional||(this.isFilled=!0,t.inserted=this.placeholderChar),t}_appendEager(){return new s}extractTail(){return this.masked.extractTail(...arguments)}appendTail(){return this.masked.appendTail(...arguments)}extractInput(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,s=arguments.length>2?arguments[2]:void 0;return this.masked.extractInput(t,e,s)}nearestInputPos(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.NONE;const s=this.value.length,i=Math.min(Math.max(t,0),s);switch(e){case u.LEFT:case u.FORCE_LEFT:return this.isComplete?i:0;case u.RIGHT:case u.FORCE_RIGHT:return this.isComplete?i:s;case u.NONE:default:return i}}doValidate(){return this.masked.doValidate(...arguments)&&(!this.parent||this.parent.doValidate(...arguments))}doCommit(){this.masked.doCommit()}get state(){return{masked:this.masked.state,isFilled:this.isFilled}}set state(t){this.masked.state=t.masked,this.isFilled=t.isFilled}}class m{constructor(t){Object.assign(this,t),this._value="",this.isFixed=!0}get value(){return this._value}get unmaskedValue(){return this.isUnmasking?this.value:""}reset(){this._isRawInput=!1,this._value=""}remove(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._value.length;return this._value=this._value.slice(0,t)+this._value.slice(e),this._value||(this._isRawInput=!1),new s}nearestInputPos(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.NONE;const s=this._value.length;switch(e){case u.LEFT:case u.FORCE_LEFT:return 0;case u.NONE:case u.RIGHT:case u.FORCE_RIGHT:default:return s}}extractInput(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._value.length;return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).raw&&this._isRawInput&&this._value.slice(t,e)||""}get isComplete(){return!0}get isFilled(){return Boolean(this._value)}_appendChar(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new s;if(this._value)return i;const u=!0===this.eager||"append"===this.eager,a=this.char===t&&(this.isUnmasking||e.input||e.raw)&&(!e.raw||!u)&&!e.tail;return a&&(i.rawInserted=this.char),this._value=i.inserted=this.char,this._isRawInput=a&&(e.raw||e.input),i}_appendEager(){return this._appendChar(this.char,{tail:!0})}_appendPlaceholder(){const t=new s;return this._value||(this._value=t.inserted=this.char),t}extractTail(){return arguments.length>1&&void 0!==arguments[1]||this.value.length,new o("")}appendTail(t){return i(t)&&(t=new o(String(t))),t.appendTo(this)}append(t,e,s){const i=this._appendChar(t[0],e);return null!=s&&(i.tailShift+=this.appendTail(s).tailShift),i}doCommit(){}get state(){return{_value:this._value,_isRawInput:this._isRawInput}}set state(t){Object.assign(this,t)}}const _=["chunks"];class v{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.chunks=t,this.from=e}toString(){return this.chunks.map(String).join("")}extend(t){if(!String(t))return;i(t)&&(t=new o(String(t)));const e=this.chunks[this.chunks.length-1],s=e&&(e.stop===t.stop||null==t.stop)&&t.from===e.from+e.toString().length;if(t instanceof o)s?e.extend(t.toString()):this.chunks.push(t);else if(t instanceof v){if(null==t.stop){let e;for(;t.chunks.length&&null==t.chunks[0].stop;)e=t.chunks.shift(),e.from+=t.from,this.extend(e)}t.toString()&&(t.stop=t.blockIndex,this.chunks.push(t))}}appendTo(t){if(!(t instanceof l.MaskedPattern)){return new o(this.toString()).appendTo(t)}const e=new s;for(let s=0;s<this.chunks.length&&!e.skip;++s){const i=this.chunks[s],u=t._mapPosToBlock(t.value.length),a=i.stop;let n;if(null!=a&&(!u||u.index<=a)&&((i instanceof v||t._stops.indexOf(a)>=0)&&e.aggregate(t._appendPlaceholder(a)),n=i instanceof v&&t._blocks[a]),n){const s=n.appendTail(i);s.skip=!1,e.aggregate(s),t._value+=s.inserted;const u=i.toString().slice(s.rawInserted.length);u&&e.aggregate(t.append(u,{tail:!0}))}else e.aggregate(t.append(i.toString(),{tail:!0}))}return e}get state(){return{chunks:this.chunks.map((t=>t.state)),from:this.from,stop:this.stop,blockIndex:this.blockIndex}}set state(t){const{chunks:s}=t,i=e(t,_);Object.assign(this,i),this.chunks=s.map((t=>{const e="chunks"in t?new v:new o;return e.state=t,e}))}unshift(t){if(!this.chunks.length||null!=t&&this.from>=t)return"";const e=null!=t?t-this.from:t;let s=0;for(;s<this.chunks.length;){const t=this.chunks[s],i=t.unshift(e);if(t.toString()){if(!i)break;++s}else this.chunks.splice(s,1);if(i)return i}return""}shift(){if(!this.chunks.length)return"";let t=this.chunks.length-1;for(;0<=t;){const e=this.chunks[t],s=e.shift();if(e.toString()){if(!s)break;--t}else this.chunks.splice(t,1);if(s)return s}return""}}class E{constructor(t,e){this.masked=t,this._log=[];const{offset:s,index:i}=t._mapPosToBlock(e)||(e<0?{index:0,offset:0}:{index:this.masked._blocks.length,offset:0});this.offset=s,this.index=i,this.ok=!1}get block(){return this.masked._blocks[this.index]}get pos(){return this.masked._blockStartPos(this.index)+this.offset}get state(){return{index:this.index,offset:this.offset,ok:this.ok}}set state(t){Object.assign(this,t)}pushState(){this._log.push(this.state)}popState(){const t=this._log.pop();return this.state=t,t}bindBlock(){this.block||(this.index<0&&(this.index=0,this.offset=0),this.index>=this.masked._blocks.length&&(this.index=this.masked._blocks.length-1,this.offset=this.block.value.length))}_pushLeft(t){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=(null===(e=this.block)||void 0===e?void 0:e.value.length)||0){var e;if(t())return this.ok=!0}return this.ok=!1}_pushRight(t){for(this.pushState(),this.bindBlock();this.index<this.masked._blocks.length;++this.index,this.offset=0)if(t())return this.ok=!0;return this.ok=!1}pushLeftBeforeFilled(){return this._pushLeft((()=>{if(!this.block.isFixed&&this.block.value)return this.offset=this.block.nearestInputPos(this.offset,u.FORCE_LEFT),0!==this.offset||void 0}))}pushLeftBeforeInput(){return this._pushLeft((()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,u.LEFT),!0}))}pushLeftBeforeRequired(){return this._pushLeft((()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,u.LEFT),!0}))}pushRightBeforeFilled(){return this._pushRight((()=>{if(!this.block.isFixed&&this.block.value)return this.offset=this.block.nearestInputPos(this.offset,u.FORCE_RIGHT),this.offset!==this.block.value.length||void 0}))}pushRightBeforeInput(){return this._pushRight((()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,u.NONE),!0}))}pushRightBeforeRequired(){return this._pushRight((()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,u.NONE),!0}))}}class A extends d{_update(t){t.mask&&(t.validate=e=>e.search(t.mask)>=0),super._update(t)}}l.MaskedRegExp=A;const F=["_blocks"];class C extends d{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.definitions=Object.assign({},k,t.definitions),super(Object.assign({},C.DEFAULTS,t))}_update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.definitions=Object.assign({},this.definitions,t.definitions),super._update(t),this._rebuildMask()}_rebuildMask(){const t=this.definitions;this._blocks=[],this._stops=[],this._maskedBlocks={};let e=this.mask;if(!e||!t)return;let s=!1,i=!1;for(let u=0;u<e.length;++u){if(this.blocks){const t=e.slice(u),s=Object.keys(this.blocks).filter((e=>0===t.indexOf(e)));s.sort(((t,e)=>e.length-t.length));const i=s[0];if(i){const t=p(Object.assign({parent:this,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,overwrite:this.overwrite},this.blocks[i]));t&&(this._blocks.push(t),this._maskedBlocks[i]||(this._maskedBlocks[i]=[]),this._maskedBlocks[i].push(this._blocks.length-1)),u+=i.length-1;continue}}let a=e[u],n=a in t;if(a===C.STOP_CHAR){this._stops.push(this._blocks.length);continue}if("{"===a||"}"===a){s=!s;continue}if("["===a||"]"===a){i=!i;continue}if(a===C.ESCAPE_CHAR){if(++u,a=e[u],!a)break;n=!1}const r=n?new f({parent:this,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,mask:t[a],isOptional:i}):new m({char:a,eager:this.eager,isUnmasking:s});this._blocks.push(r)}}get state(){return Object.assign({},super.state,{_blocks:this._blocks.map((t=>t.state))})}set state(t){const{_blocks:s}=t,i=e(t,F);this._blocks.forEach(((t,e)=>t.state=s[e])),super.state=i}reset(){super.reset(),this._blocks.forEach((t=>t.reset()))}get isComplete(){return this._blocks.every((t=>t.isComplete))}get isFilled(){return this._blocks.every((t=>t.isFilled))}get isFixed(){return this._blocks.every((t=>t.isFixed))}get isOptional(){return this._blocks.every((t=>t.isOptional))}doCommit(){this._blocks.forEach((t=>t.doCommit())),super.doCommit()}get unmaskedValue(){return this._blocks.reduce(((t,e)=>t+e.unmaskedValue),"")}set unmaskedValue(t){super.unmaskedValue=t}get value(){return this._blocks.reduce(((t,e)=>t+e.value),"")}set value(t){super.value=t}appendTail(t){return super.appendTail(t).aggregate(this._appendPlaceholder())}_appendEager(){var t;const e=new s;let i=null===(t=this._mapPosToBlock(this.value.length))||void 0===t?void 0:t.index;if(null==i)return e;this._blocks[i].isFilled&&++i;for(let t=i;t<this._blocks.length;++t){const s=this._blocks[t]._appendEager();if(!s.inserted)break;e.aggregate(s)}return e}_appendCharRaw(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this._mapPosToBlock(this.value.length),u=new s;if(!i)return u;for(let s=i.index;;++s){var a,n;const i=this._blocks[s];if(!i)break;const r=i._appendChar(t,Object.assign({},e,{_beforeTailState:null===(a=e._beforeTailState)||void 0===a||null===(n=a._blocks)||void 0===n?void 0:n[s]})),h=r.skip;if(u.aggregate(r),h||r.rawInserted)break}return u}extractTail(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;const s=new v;return t===e||this._forEachBlocksInRange(t,e,((t,e,i,u)=>{const a=t.extractTail(i,u);a.stop=this._findStopBefore(e),a.from=this._blockStartPos(e),a instanceof v&&(a.blockIndex=e),s.extend(a)})),s}extractInput(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t===e)return"";let i="";return this._forEachBlocksInRange(t,e,((t,e,u,a)=>{i+=t.extractInput(u,a,s)})),i}_findStopBefore(t){let e;for(let s=0;s<this._stops.length;++s){const i=this._stops[s];if(!(i<=t))break;e=i}return e}_appendPlaceholder(t){const e=new s;if(this.lazy&&null==t)return e;const i=this._mapPosToBlock(this.value.length);if(!i)return e;const u=i.index,a=null!=t?t:this._blocks.length;return this._blocks.slice(u,a).forEach((s=>{if(!s.lazy||null!=t){const t=null!=s._blocks?[s._blocks.length]:[],i=s._appendPlaceholder(...t);this._value+=i.inserted,e.aggregate(i)}})),e}_mapPosToBlock(t){let e="";for(let s=0;s<this._blocks.length;++s){const i=this._blocks[s],u=e.length;if(e+=i.value,t<=e.length)return{index:s,offset:t-u}}}_blockStartPos(t){return this._blocks.slice(0,t).reduce(((t,e)=>t+e.value.length),0)}_forEachBlocksInRange(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,s=arguments.length>2?arguments[2]:void 0;const i=this._mapPosToBlock(t);if(i){const t=this._mapPosToBlock(e),u=t&&i.index===t.index,a=i.offset,n=t&&u?t.offset:this._blocks[i.index].value.length;if(s(this._blocks[i.index],i.index,a,n),t&&!u){for(let e=i.index+1;e<t.index;++e)s(this._blocks[e],e,0,this._blocks[e].value.length);s(this._blocks[t.index],t.index,0,t.offset)}}}remove(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;const s=super.remove(t,e);return this._forEachBlocksInRange(t,e,((t,e,i,u)=>{s.aggregate(t.remove(i,u))})),s}nearestInputPos(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.NONE;if(!this._blocks.length)return 0;const s=new E(this,t);if(e===u.NONE)return s.pushRightBeforeInput()?s.pos:(s.popState(),s.pushLeftBeforeInput()?s.pos:this.value.length);if(e===u.LEFT||e===u.FORCE_LEFT){if(e===u.LEFT){if(s.pushRightBeforeFilled(),s.ok&&s.pos===t)return t;s.popState()}if(s.pushLeftBeforeInput(),s.pushLeftBeforeRequired(),s.pushLeftBeforeFilled(),e===u.LEFT){if(s.pushRightBeforeInput(),s.pushRightBeforeRequired(),s.ok&&s.pos<=t)return s.pos;if(s.popState(),s.ok&&s.pos<=t)return s.pos;s.popState()}return s.ok?s.pos:e===u.FORCE_LEFT?0:(s.popState(),s.ok?s.pos:(s.popState(),s.ok?s.pos:0))}return e===u.RIGHT||e===u.FORCE_RIGHT?(s.pushRightBeforeInput(),s.pushRightBeforeRequired(),s.pushRightBeforeFilled()?s.pos:e===u.FORCE_RIGHT?this.value.length:(s.popState(),s.ok?s.pos:(s.popState(),s.ok?s.pos:this.nearestInputPos(t,u.LEFT)))):t}maskedBlock(t){return this.maskedBlocks(t)[0]}maskedBlocks(t){const e=this._maskedBlocks[t];return e?e.map((t=>this._blocks[t])):[]}}C.DEFAULTS={lazy:!0,placeholderChar:"_"},C.STOP_CHAR="`",C.ESCAPE_CHAR="\\",C.InputDefinition=f,C.FixedDefinition=m,l.MaskedPattern=C;class b extends C{get _matchFrom(){return this.maxLength-String(this.from).length}_update(t){t=Object.assign({to:this.to||0,from:this.from||0,maxLength:this.maxLength||0},t);let e=String(t.to).length;null!=t.maxLength&&(e=Math.max(e,t.maxLength)),t.maxLength=e;const s=String(t.from).padStart(e,"0"),i=String(t.to).padStart(e,"0");let u=0;for(;u<i.length&&i[u]===s[u];)++u;t.mask=i.slice(0,u).replace(/0/g,"\\0")+"0".repeat(e-u),super._update(t)}get isComplete(){return super.isComplete&&Boolean(this.value)}boundaries(t){let e="",s="";const[,i,u]=t.match(/^(\D*)(\d*)(\D*)/)||[];return u&&(e="0".repeat(i.length)+u,s="9".repeat(i.length)+u),e=e.padEnd(this.maxLength,"0"),s=s.padEnd(this.maxLength,"9"),[e,s]}doPrepare(t){let e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if([t,e]=n(super.doPrepare(t.replace(/\D/g,""),s)),!this.autofix||!t)return t;const i=String(this.from).padStart(this.maxLength,"0"),u=String(this.to).padStart(this.maxLength,"0");let a=this.value+t;if(a.length>this.maxLength)return"";const[r,h]=this.boundaries(a);return Number(h)<this.from?i[a.length-1]:Number(r)>this.to?"pad"===this.autofix&&a.length<this.maxLength?["",e.aggregate(this.append(i[a.length-1]+t,s))]:u[a.length-1]:t}doValidate(){const t=this.value;if(-1===t.search(/[^0]/)&&t.length<=this._matchFrom)return!0;const[e,s]=this.boundaries(t);return this.from<=Number(s)&&Number(e)<=this.to&&super.doValidate(...arguments)}}l.MaskedRange=b;class S extends C{constructor(t){super(Object.assign({},S.DEFAULTS,t))}_update(t){t.mask===Date&&delete t.mask,t.pattern&&(t.mask=t.pattern);const e=t.blocks;t.blocks=Object.assign({},S.GET_DEFAULT_BLOCKS()),t.min&&(t.blocks.Y.from=t.min.getFullYear()),t.max&&(t.blocks.Y.to=t.max.getFullYear()),t.min&&t.max&&t.blocks.Y.from===t.blocks.Y.to&&(t.blocks.m.from=t.min.getMonth()+1,t.blocks.m.to=t.max.getMonth()+1,t.blocks.m.from===t.blocks.m.to&&(t.blocks.d.from=t.min.getDate(),t.blocks.d.to=t.max.getDate())),Object.assign(t.blocks,this.blocks,e),Object.keys(t.blocks).forEach((e=>{const s=t.blocks[e];!("autofix"in s)&&"autofix"in t&&(s.autofix=t.autofix)})),super._update(t)}doValidate(){const t=this.date;return super.doValidate(...arguments)&&(!this.isComplete||this.isDateExist(this.value)&&null!=t&&(null==this.min||this.min<=t)&&(null==this.max||t<=this.max))}isDateExist(t){return this.format(this.parse(t,this),this).indexOf(t)>=0}get date(){return this.typedValue}set date(t){this.typedValue=t}get typedValue(){return this.isComplete?super.typedValue:null}set typedValue(t){super.typedValue=t}maskEquals(t){return t===Date||super.maskEquals(t)}}S.DEFAULTS={pattern:"d{.}`m{.}`Y",format:t=>{if(!t)return"";return[String(t.getDate()).padStart(2,"0"),String(t.getMonth()+1).padStart(2,"0"),t.getFullYear()].join(".")},parse:t=>{const[e,s,i]=t.split(".");return new Date(i,s-1,e)}},S.GET_DEFAULT_BLOCKS=()=>({d:{mask:b,from:1,to:31,maxLength:2},m:{mask:b,from:1,to:12,maxLength:2},Y:{mask:b,from:1900,to:9999}}),l.MaskedDate=S;class D{get selectionStart(){let t;try{t=this._unsafeSelectionStart}catch(t){}return null!=t?t:this.value.length}get selectionEnd(){let t;try{t=this._unsafeSelectionEnd}catch(t){}return null!=t?t:this.value.length}select(t,e){if(null!=t&&null!=e&&(t!==this.selectionStart||e!==this.selectionEnd))try{this._unsafeSelect(t,e)}catch(t){}}_unsafeSelect(t,e){}get isActive(){return!1}bindEvents(t){}unbindEvents(){}}l.MaskElement=D;class B extends D{constructor(t){super(),this.input=t,this._handlers={}}get rootElement(){var t,e,s;return null!==(t=null===(e=(s=this.input).getRootNode)||void 0===e?void 0:e.call(s))&&void 0!==t?t:document}get isActive(){return this.input===this.rootElement.activeElement}get _unsafeSelectionStart(){return this.input.selectionStart}get _unsafeSelectionEnd(){return this.input.selectionEnd}_unsafeSelect(t,e){this.input.setSelectionRange(t,e)}get value(){return this.input.value}set value(t){this.input.value=t}bindEvents(t){Object.keys(t).forEach((e=>this._toggleEventHandler(B.EVENTS_MAP[e],t[e])))}unbindEvents(){Object.keys(this._handlers).forEach((t=>this._toggleEventHandler(t)))}_toggleEventHandler(t,e){this._handlers[t]&&(this.input.removeEventListener(t,this._handlers[t]),delete this._handlers[t]),e&&(this.input.addEventListener(t,e),this._handlers[t]=e)}}B.EVENTS_MAP={selectionChange:"keydown",input:"input",drop:"drop",click:"click",focus:"focus",commit:"blur"},l.HTMLMaskElement=B;class x extends B{get _unsafeSelectionStart(){const t=this.rootElement,e=t.getSelection&&t.getSelection(),s=e&&e.anchorOffset,i=e&&e.focusOffset;return null==i||null==s||s<i?s:i}get _unsafeSelectionEnd(){const t=this.rootElement,e=t.getSelection&&t.getSelection(),s=e&&e.anchorOffset,i=e&&e.focusOffset;return null==i||null==s||s>i?s:i}_unsafeSelect(t,e){if(!this.rootElement.createRange)return;const s=this.rootElement.createRange();s.setStart(this.input.firstChild||this.input,t),s.setEnd(this.input.lastChild||this.input,e);const i=this.rootElement,u=i.getSelection&&i.getSelection();u&&(u.removeAllRanges(),u.addRange(s))}get value(){return this.input.textContent}set value(t){this.input.textContent=t}}l.HTMLContenteditableMaskElement=x;const M=["mask"];class T{constructor(t,e){this.el=t instanceof D?t:t.isContentEditable&&"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName?new x(t):new B(t),this.masked=p(e),this._listeners={},this._value="",this._unmaskedValue="",this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._onFocus=this._onFocus.bind(this),this._onClick=this._onClick.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}get mask(){return this.masked.mask}maskEquals(t){var e;return null==t||(null===(e=this.masked)||void 0===e?void 0:e.maskEquals(t))}set mask(t){if(this.maskEquals(t))return;if(!(t instanceof l.Masked)&&this.masked.constructor===c(t))return void this.masked.updateOptions({mask:t});const e=p({mask:t});e.unmaskedValue=this.masked.unmaskedValue,this.masked=e}get value(){return this._value}set value(t){this.value!==t&&(this.masked.value=t,this.updateControl(),this.alignCursor())}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.unmaskedValue!==t&&(this.masked.unmaskedValue=t,this.updateControl(),this.alignCursor())}get typedValue(){return this.masked.typedValue}set typedValue(t){this.masked.typedValueEquals(t)||(this.masked.typedValue=t,this.updateControl(),this.alignCursor())}_bindEvents(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange})}_unbindEvents(){this.el&&this.el.unbindEvents()}_fireEvent(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];const u=this._listeners[t];u&&u.forEach((t=>t(...s)))}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}get cursorPos(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd}set cursorPos(t){this.el&&this.el.isActive&&(this.el.select(t,t),this._saveSelection())}_saveSelection(){this.value!==this.el.value&&console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."),this._selection={start:this.selectionStart,end:this.cursorPos}}updateValue(){this.masked.value=this.el.value,this._value=this.masked.value}updateControl(){const t=this.masked.unmaskedValue,e=this.masked.value,s=this.unmaskedValue!==t||this.value!==e;this._unmaskedValue=t,this._value=e,this.el.value!==e&&(this.el.value=e),s&&this._fireChangeEvents()}updateOptions(t){const{mask:s}=t,i=e(t,M),u=!this.maskEquals(s),a=!r(this.masked,i);u&&(this.mask=s),a&&this.masked.updateOptions(i),(u||a)&&this.updateControl()}updateCursor(t){null!=t&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout((()=>{this.el&&(this.cursorPos=this._changingCursorPos,this._abortUpdateCursor())}),10)}_fireChangeEvents(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,u.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this}off(t,e){if(!this._listeners[t])return this;if(!e)return delete this._listeners[t],this;const s=this._listeners[t].indexOf(e);return s>=0&&this._listeners[t].splice(s,1),this}_onInput(t){if(this._inputEvent=t,this._abortUpdateCursor(),!this._selection)return this.updateValue();const e=new h(this.el.value,this.cursorPos,this.value,this._selection),s=this.masked.rawInputValue,i=this.masked.splice(e.startChangePos,e.removed.length,e.inserted,e.removeDirection,{input:!0,raw:!0}).offset,a=s===this.masked.rawInputValue?e.removeDirection:u.NONE;let n=this.masked.nearestInputPos(e.startChangePos+i,a);a!==u.NONE&&(n=this.masked.nearestInputPos(n,u.NONE)),this.updateControl(),this.updateCursor(n),delete this._inputEvent}_onChange(){this.value!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl(),this._saveSelection()}_onDrop(t){t.preventDefault(),t.stopPropagation()}_onFocus(t){this.alignCursorFriendly()}_onClick(t){this.alignCursorFriendly()}destroy(){this._unbindEvents(),this._listeners.length=0,delete this.el}}l.InputMask=T;class w extends C{_update(t){t.enum&&(t.mask="*".repeat(t.enum[0].length)),super._update(t)}doValidate(){return this.enum.some((t=>t.indexOf(this.unmaskedValue)>=0))&&super.doValidate(...arguments)}}l.MaskedEnum=w;class I extends d{constructor(t){super(Object.assign({},I.DEFAULTS,t))}_update(t){super._update(t),this._updateRegExps()}_updateRegExps(){let t="^"+(this.allowNegative?"[+|\\-]?":""),e=(this.scale?"(".concat(a(this.radix),"\\d{0,").concat(this.scale,"})?"):"")+"$";this._numberRegExp=new RegExp(t+"\\d*"+e),this._mapToRadixRegExp=new RegExp("[".concat(this.mapToRadix.map(a).join(""),"]"),"g"),this._thousandsSeparatorRegExp=new RegExp(a(this.thousandsSeparator),"g")}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const e=t.split(this.radix);return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),e.join(this.radix)}doPrepare(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t=this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(e.input&&e.raw||!e.input&&!e.raw)?t.replace(this._mapToRadixRegExp,this.radix):t);const[s,i]=n(super.doPrepare(t,e));return t&&!s&&(i.skip=!0),[s,i]}_separatorsCount(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=0;for(let i=0;i<t;++i)this._value.indexOf(this.thousandsSeparator,i)===i&&(++s,e&&(t+=this.thousandsSeparator.length));return s}_separatorsCountFromSlice(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._value;return this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}extractInput(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,s=arguments.length>2?arguments[2]:void 0;return[t,e]=this._adjustRangeWithSeparators(t,e),this._removeThousandsSeparators(super.extractInput(t,e,s))}_appendCharRaw(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.thousandsSeparator)return super._appendCharRaw(t,e);const s=e.tail&&e._beforeTailState?e._beforeTailState._value:this._value,i=this._separatorsCountFromSlice(s);this._value=this._removeThousandsSeparators(this.value);const u=super._appendCharRaw(t,e);this._value=this._insertThousandsSeparators(this._value);const a=e.tail&&e._beforeTailState?e._beforeTailState._value:this._value,n=this._separatorsCountFromSlice(a);return u.tailShift+=(n-i)*this.thousandsSeparator.length,u.skip=!u.rawInserted&&t===this.thousandsSeparator,u}_findSeparatorAround(t){if(this.thousandsSeparator){const e=t-this.thousandsSeparator.length+1,s=this.value.indexOf(this.thousandsSeparator,e);if(s<=t)return s}return-1}_adjustRangeWithSeparators(t,e){const s=this._findSeparatorAround(t);s>=0&&(t=s);const i=this._findSeparatorAround(e);return i>=0&&(e=i+this.thousandsSeparator.length),[t,e]}remove(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;[t,e]=this._adjustRangeWithSeparators(t,e);const i=this.value.slice(0,t),u=this.value.slice(e),a=this._separatorsCount(i.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(i+u));const n=this._separatorsCountFromSlice(i);return new s({tailShift:(n-a)*this.thousandsSeparator.length})}nearestInputPos(t,e){if(!this.thousandsSeparator)return t;switch(e){case u.NONE:case u.LEFT:case u.FORCE_LEFT:{const s=this._findSeparatorAround(t-1);if(s>=0){const i=s+this.thousandsSeparator.length;if(t<i||this.value.length<=i||e===u.FORCE_LEFT)return s}break}case u.RIGHT:case u.FORCE_RIGHT:{const e=this._findSeparatorAround(t);if(e>=0)return e+this.thousandsSeparator.length}}return t}doValidate(t){let e=Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));if(e){const t=this.number;e=e&&!isNaN(t)&&(null==this.min||this.min>=0||this.min<=this.number)&&(null==this.max||this.max<=0||this.number<=this.max)}return e&&super.doValidate(t)}doCommit(){if(this.value){const t=this.number;let e=t;null!=this.min&&(e=Math.max(e,this.min)),null!=this.max&&(e=Math.min(e,this.max)),e!==t&&(this.unmaskedValue=this.doFormat(e));let s=this.value;this.normalizeZeros&&(s=this._normalizeZeros(s)),this.padFractionalZeros&&this.scale>0&&(s=this._padFractionalZeros(s)),this._value=s}super.doCommit()}_normalizeZeros(t){const e=this._removeThousandsSeparators(t).split(this.radix);return e[0]=e[0].replace(/^(\D*)(0*)(\d*)/,((t,e,s,i)=>e+i)),t.length&&!/\d$/.test(e[0])&&(e[0]=e[0]+"0"),e.length>1&&(e[1]=e[1].replace(/0*$/,""),e[1].length||(e.length=1)),this._insertThousandsSeparators(e.join(this.radix))}_padFractionalZeros(t){if(!t)return t;const e=t.split(this.radix);return e.length<2&&e.push(""),e[1]=e[1].padEnd(this.scale,"0"),e.join(this.radix)}doSkipInvalid(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;const i=0===this.scale&&t!==this.thousandsSeparator&&(t===this.radix||t===I.UNMASKED_RADIX||this.mapToRadix.includes(t));return super.doSkipInvalid(t,e,s)&&!i}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,I.UNMASKED_RADIX)}set unmaskedValue(t){super.unmaskedValue=t}get typedValue(){return this.doParse(this.unmaskedValue)}set typedValue(t){this.rawInputValue=this.doFormat(t).replace(I.UNMASKED_RADIX,this.radix)}get number(){return this.typedValue}set number(t){this.typedValue=t}get allowNegative(){return this.signed||null!=this.min&&this.min<0||null!=this.max&&this.max<0}typedValueEquals(t){return(super.typedValueEquals(t)||I.EMPTY_VALUES.includes(t)&&I.EMPTY_VALUES.includes(this.typedValue))&&!(0===t&&""===this.value)}}I.UNMASKED_RADIX=".",I.DEFAULTS={radix:",",thousandsSeparator:"",mapToRadix:[I.UNMASKED_RADIX],scale:2,signed:!1,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:t=>t.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},I.EMPTY_VALUES=[...d.EMPTY_VALUES,0],l.MaskedNumber=I;class R extends d{_update(t){t.mask&&(t.validate=t.mask),super._update(t)}}l.MaskedFunction=R;const V=["compiledMasks","currentMaskRef","currentMask"];class P extends d{constructor(t){super(Object.assign({},P.DEFAULTS,t)),this.currentMask=null}_update(t){super._update(t),"mask"in t&&(this.compiledMasks=Array.isArray(t.mask)?t.mask.map((t=>p(t))):[])}_appendCharRaw(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this._applyDispatch(t,e);return this.currentMask&&s.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(e))),s}_applyDispatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=e.tail&&null!=e._beforeTailState?e._beforeTailState._value:this.value,u=this.rawInputValue,a=e.tail&&null!=e._beforeTailState?e._beforeTailState._rawInputValue:u,n=u.slice(a.length),r=this.currentMask,h=new s,o=null==r?void 0:r.state;if(this.currentMask=this.doDispatch(t,Object.assign({},e)),this.currentMask)if(this.currentMask!==r){if(this.currentMask.reset(),a){const t=this.currentMask.append(a,{raw:!0});h.tailShift=t.inserted.length-i.length}n&&(h.tailShift+=this.currentMask.append(n,{raw:!0,tail:!0}).tailShift)}else this.currentMask.state=o;return h}_appendPlaceholder(){const t=this._applyDispatch(...arguments);return this.currentMask&&t.aggregate(this.currentMask._appendPlaceholder()),t}_appendEager(){const t=this._applyDispatch(...arguments);return this.currentMask&&t.aggregate(this.currentMask._appendEager()),t}currentMaskFlags(t){var e,s;return Object.assign({},t,{_beforeTailState:(null===(e=t._beforeTailState)||void 0===e?void 0:e.currentMaskRef)===this.currentMask&&(null===(s=t._beforeTailState)||void 0===s?void 0:s.currentMask)||t._beforeTailState})}doDispatch(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.dispatch(t,this,e)}doValidate(t){return super.doValidate(t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}doPrepare(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},[s,i]=n(super.doPrepare(t,e));if(this.currentMask){let t;[s,t]=n(super.doPrepare(s,this.currentMaskFlags(e))),i=i.aggregate(t)}return[s,i]}reset(){var t;null===(t=this.currentMask)||void 0===t||t.reset(),this.compiledMasks.forEach((t=>t.reset()))}get value(){return this.currentMask?this.currentMask.value:""}set value(t){super.value=t}get unmaskedValue(){return this.currentMask?this.currentMask.unmaskedValue:""}set unmaskedValue(t){super.unmaskedValue=t}get typedValue(){return this.currentMask?this.currentMask.typedValue:""}set typedValue(t){let e=String(t);this.currentMask&&(this.currentMask.typedValue=t,e=this.currentMask.unmaskedValue),this.unmaskedValue=e}get isComplete(){var t;return Boolean(null===(t=this.currentMask)||void 0===t?void 0:t.isComplete)}get isFilled(){var t;return Boolean(null===(t=this.currentMask)||void 0===t?void 0:t.isFilled)}remove(){const t=new s;return this.currentMask&&t.aggregate(this.currentMask.remove(...arguments)).aggregate(this._applyDispatch()),t}get state(){var t;return Object.assign({},super.state,{_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map((t=>t.state)),currentMaskRef:this.currentMask,currentMask:null===(t=this.currentMask)||void 0===t?void 0:t.state})}set state(t){const{compiledMasks:s,currentMaskRef:i,currentMask:u}=t,a=e(t,V);this.compiledMasks.forEach(((t,e)=>t.state=s[e])),null!=i&&(this.currentMask=i,this.currentMask.state=u),super.state=a}extractInput(){return this.currentMask?this.currentMask.extractInput(...arguments):""}extractTail(){return this.currentMask?this.currentMask.extractTail(...arguments):super.extractTail(...arguments)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(){return this.currentMask?this.currentMask.nearestInputPos(...arguments):super.nearestInputPos(...arguments)}get overwrite(){return this.currentMask?this.currentMask.overwrite:super.overwrite}set overwrite(t){console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings')}get eager(){return this.currentMask?this.currentMask.eager:super.eager}set eager(t){console.warn('"eager" option is not available in dynamic mask, use this option in siblings')}get skipInvalid(){return this.currentMask?this.currentMask.skipInvalid:super.skipInvalid}set skipInvalid(t){console.warn('"skipInvalid" option is not available in dynamic mask, use this option in siblings')}maskEquals(t){return Array.isArray(t)&&this.compiledMasks.every(((e,s)=>{var i;return e.maskEquals(null===(i=t[s])||void 0===i?void 0:i.mask)}))}typedValueEquals(t){var e;return Boolean(null===(e=this.currentMask)||void 0===e?void 0:e.typedValueEquals(t))}}P.DEFAULTS={dispatch:(t,e,s)=>{if(!e.compiledMasks.length)return;const i=e.rawInputValue,u=e.compiledMasks.map(((u,a)=>{u.reset(),u.append(i,{raw:!0}),u.append(t,e.currentMaskFlags(s));return{weight:u.rawInputValue.length,index:a}}));return u.sort(((t,e)=>e.weight-t.weight)),e.compiledMasks[u[0].index]}},l.MaskedDynamic=P;const y={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function O(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:y.MASKED,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:y.MASKED;const i=p(t);return t=>i.runIsolated((i=>(i[e]=t,i[s])))}function L(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];return O(...s)(t)}l.PIPE_TYPE=y,l.createPipe=O,l.pipe=L;try{globalThis.IMask=l}catch(t){}t.ChangeDetails=s,t.HTMLContenteditableMaskElement=x,t.HTMLMaskElement=B,t.InputMask=T,t.MaskElement=D,t.Masked=d,t.MaskedDate=S,t.MaskedDynamic=P,t.MaskedEnum=w,t.MaskedFunction=R,t.MaskedNumber=I,t.MaskedPattern=C,t.MaskedRange=b,t.MaskedRegExp=A,t.PIPE_TYPE=y,t.createMask=p,t.createPipe=O,t.default=l,t.pipe=L,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=imask.min.js.map

@@ -1,2 +0,1 @@

import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import HTMLMaskElement from './html-mask-element.js';

@@ -6,81 +5,64 @@ import IMask from '../core/holder.js';

var HTMLContenteditableMaskElement = /*#__PURE__*/function (_HTMLMaskElement) {
_inherits(HTMLContenteditableMaskElement, _HTMLMaskElement);
var _super = _createSuper(HTMLContenteditableMaskElement);
function HTMLContenteditableMaskElement() {
_classCallCheck(this, HTMLContenteditableMaskElement);
return _super.apply(this, arguments);
class HTMLContenteditableMaskElement extends HTMLMaskElement {
/**
Returns HTMLElement selection start
@override
*/
get _unsafeSelectionStart() {
const root = this.rootElement;
const selection = root.getSelection && root.getSelection();
const anchorOffset = selection && selection.anchorOffset;
const focusOffset = selection && selection.focusOffset;
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
return anchorOffset;
}
return focusOffset;
}
_createClass(HTMLContenteditableMaskElement, [{
key: "_unsafeSelectionStart",
get:
/**
Returns HTMLElement selection start
@override
*/
function get() {
var root = this.rootElement;
var selection = root.getSelection && root.getSelection();
var anchorOffset = selection && selection.anchorOffset;
var focusOffset = selection && selection.focusOffset;
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
return anchorOffset;
}
return focusOffset;
}
/**
Returns HTMLElement selection end
@override
*/
}, {
key: "_unsafeSelectionEnd",
get: function get() {
var root = this.rootElement;
var selection = root.getSelection && root.getSelection();
var anchorOffset = selection && selection.anchorOffset;
var focusOffset = selection && selection.focusOffset;
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
return anchorOffset;
}
return focusOffset;
/**
Returns HTMLElement selection end
@override
*/
get _unsafeSelectionEnd() {
const root = this.rootElement;
const selection = root.getSelection && root.getSelection();
const anchorOffset = selection && selection.anchorOffset;
const focusOffset = selection && selection.focusOffset;
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
return anchorOffset;
}
return focusOffset;
}
/**
Sets HTMLElement selection
@override
*/
}, {
key: "_unsafeSelect",
value: function _unsafeSelect(start, end) {
if (!this.rootElement.createRange) return;
var range = this.rootElement.createRange();
range.setStart(this.input.firstChild || this.input, start);
range.setEnd(this.input.lastChild || this.input, end);
var root = this.rootElement;
var selection = root.getSelection && root.getSelection();
if (selection) {
selection.removeAllRanges();
selection.addRange(range);
}
/**
Sets HTMLElement selection
@override
*/
_unsafeSelect(start, end) {
if (!this.rootElement.createRange) return;
const range = this.rootElement.createRange();
range.setStart(this.input.firstChild || this.input, start);
range.setEnd(this.input.lastChild || this.input, end);
const root = this.rootElement;
const selection = root.getSelection && root.getSelection();
if (selection) {
selection.removeAllRanges();
selection.addRange(range);
}
}
/**
HTMLElement value
@override
*/
}, {
key: "value",
get: function get() {
// $FlowFixMe
return this.input.textContent;
},
set: function set(value) {
this.input.textContent = value;
}
}]);
return HTMLContenteditableMaskElement;
}(HTMLMaskElement);
/**
HTMLElement value
@override
*/
get value() {
// $FlowFixMe
return this.input.textContent;
}
set value(value) {
this.input.textContent = value;
}
}
IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
export { HTMLContenteditableMaskElement as default };

@@ -1,2 +0,1 @@

import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import MaskElement from './mask-element.js';

@@ -6,5 +5,3 @@ import IMask from '../core/holder.js';

/** Bridge between HTMLElement and {@link Masked} */
var HTMLMaskElement = /*#__PURE__*/function (_MaskElement) {
_inherits(HTMLMaskElement, _MaskElement);
var _super = _createSuper(HTMLMaskElement);
class HTMLMaskElement extends MaskElement {
/** Mapping between HTMLElement events and mask internal events */

@@ -17,9 +14,6 @@

*/
function HTMLMaskElement(input) {
var _this;
_classCallCheck(this, HTMLMaskElement);
_this = _super.call(this);
_this.input = input;
_this._handlers = {};
return _this;
constructor(input) {
super();
this.input = input;
this._handlers = {};
}

@@ -29,105 +23,79 @@

// $FlowFixMe https://github.com/facebook/flow/issues/2839
_createClass(HTMLMaskElement, [{
key: "rootElement",
get: function get() {
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) === null || _this$input$getRootNo2 === void 0 ? void 0 : _this$input$getRootNo2.call(_this$input)) !== null && _this$input$getRootNo !== void 0 ? _this$input$getRootNo : document;
}
get rootElement() {
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) === null || _this$input$getRootNo2 === void 0 ? void 0 : _this$input$getRootNo2.call(_this$input)) !== null && _this$input$getRootNo !== void 0 ? _this$input$getRootNo : document;
}
/**
Is element in focus
@readonly
*/
}, {
key: "isActive",
get: function get() {
//$FlowFixMe
return this.input === this.rootElement.activeElement;
}
/**
Is element in focus
@readonly
*/
get isActive() {
//$FlowFixMe
return this.input === this.rootElement.activeElement;
}
/**
Returns HTMLElement selection start
@override
*/
}, {
key: "_unsafeSelectionStart",
get: function get() {
return this.input.selectionStart;
}
/**
Returns HTMLElement selection start
@override
*/
get _unsafeSelectionStart() {
return this.input.selectionStart;
}
/**
Returns HTMLElement selection end
@override
*/
}, {
key: "_unsafeSelectionEnd",
get: function get() {
return this.input.selectionEnd;
}
/**
Returns HTMLElement selection end
@override
*/
get _unsafeSelectionEnd() {
return this.input.selectionEnd;
}
/**
Sets HTMLElement selection
@override
*/
}, {
key: "_unsafeSelect",
value: function _unsafeSelect(start, end) {
this.input.setSelectionRange(start, end);
}
/**
Sets HTMLElement selection
@override
*/
_unsafeSelect(start, end) {
this.input.setSelectionRange(start, end);
}
/**
HTMLElement value
@override
*/
}, {
key: "value",
get: function get() {
return this.input.value;
},
set: function set(value) {
this.input.value = value;
}
/**
HTMLElement value
@override
*/
get value() {
return this.input.value;
}
set value(value) {
this.input.value = value;
}
/**
Binds HTMLElement events to mask internal events
@override
*/
}, {
key: "bindEvents",
value: function bindEvents(handlers) {
var _this2 = this;
Object.keys(handlers).forEach(function (event) {
return _this2._toggleEventHandler(HTMLMaskElement.EVENTS_MAP[event], handlers[event]);
});
}
/**
Binds HTMLElement events to mask internal events
@override
*/
bindEvents(handlers) {
Object.keys(handlers).forEach(event => this._toggleEventHandler(HTMLMaskElement.EVENTS_MAP[event], handlers[event]));
}
/**
Unbinds HTMLElement events to mask internal events
@override
*/
}, {
key: "unbindEvents",
value: function unbindEvents() {
var _this3 = this;
Object.keys(this._handlers).forEach(function (event) {
return _this3._toggleEventHandler(event);
});
}
/**
Unbinds HTMLElement events to mask internal events
@override
*/
unbindEvents() {
Object.keys(this._handlers).forEach(event => this._toggleEventHandler(event));
}
/** */
}, {
key: "_toggleEventHandler",
value: function _toggleEventHandler(event, handler) {
if (this._handlers[event]) {
this.input.removeEventListener(event, this._handlers[event]);
delete this._handlers[event];
}
if (handler) {
this.input.addEventListener(event, handler);
this._handlers[event] = handler;
}
/** */
_toggleEventHandler(event, handler) {
if (this._handlers[event]) {
this.input.removeEventListener(event, this._handlers[event]);
delete this._handlers[event];
}
}]);
return HTMLMaskElement;
}(MaskElement);
if (handler) {
this.input.addEventListener(event, handler);
this._handlers[event] = handler;
}
}
}
HTMLMaskElement.EVENTS_MAP = {

@@ -134,0 +102,0 @@ selectionChange: 'keydown',

@@ -1,2 +0,2 @@

import { _ as _createClass, a as _classCallCheck, b as _objectWithoutProperties } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import { _ as _objectWithoutPropertiesLoose } from '../_rollupPluginBabelHelpers-6b3bd404.js';
import { objectIncludes, DIRECTION } from '../core/utils.js';

@@ -21,6 +21,6 @@ import ActionDetails from '../core/action-details.js';

var _excluded = ["mask"];
const _excluded = ["mask"];
/** Listens to element events and controls changes between element and {@link Masked} */
var InputMask = /*#__PURE__*/function () {
class InputMask {
/**

@@ -40,4 +40,3 @@ View element

*/
function InputMask(el, opts) {
_classCallCheck(this, InputMask);
constructor(el, opts) {
this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLMaskElement(el);

@@ -64,356 +63,297 @@ this.masked = createMask(opts);

/** Read or update mask */
_createClass(InputMask, [{
key: "mask",
get: function get() {
return this.masked.mask;
},
set: function set(mask) {
if (this.maskEquals(mask)) return;
get mask() {
return this.masked.mask;
}
maskEquals(mask) {
var _this$masked;
return mask == null || ((_this$masked = this.masked) === null || _this$masked === void 0 ? void 0 : _this$masked.maskEquals(mask));
}
set mask(mask) {
if (this.maskEquals(mask)) return;
// $FlowFixMe No ideas ... after update
if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {
this.masked.updateOptions({
mask: mask
});
return;
}
var masked = createMask({
mask: mask
// $FlowFixMe No ideas ... after update
if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {
this.masked.updateOptions({
mask
});
masked.unmaskedValue = this.masked.unmaskedValue;
this.masked = masked;
return;
}
const masked = createMask({
mask
});
masked.unmaskedValue = this.masked.unmaskedValue;
this.masked = masked;
}
/** Raw value */
}, {
key: "maskEquals",
value: function maskEquals(mask) {
var _this$masked;
return mask == null || ((_this$masked = this.masked) === null || _this$masked === void 0 ? void 0 : _this$masked.maskEquals(mask));
}
}, {
key: "value",
get: function get() {
return this._value;
},
set: function set(str) {
if (this.value === str) return;
this.masked.value = str;
this.updateControl();
this.alignCursor();
}
/** Raw value */
get value() {
return this._value;
}
set value(str) {
if (this.value === str) return;
this.masked.value = str;
this.updateControl();
this.alignCursor();
}
/** Unmasked value */
}, {
key: "unmaskedValue",
get: function get() {
return this._unmaskedValue;
},
set: function set(str) {
if (this.unmaskedValue === str) return;
this.masked.unmaskedValue = str;
this.updateControl();
this.alignCursor();
}
/** Unmasked value */
get unmaskedValue() {
return this._unmaskedValue;
}
set unmaskedValue(str) {
if (this.unmaskedValue === str) return;
this.masked.unmaskedValue = str;
this.updateControl();
this.alignCursor();
}
/** Typed unmasked value */
}, {
key: "typedValue",
get: function get() {
return this.masked.typedValue;
},
set: function set(val) {
if (this.masked.typedValueEquals(val)) return;
this.masked.typedValue = val;
this.updateControl();
this.alignCursor();
}
/** Typed unmasked value */
get typedValue() {
return this.masked.typedValue;
}
set typedValue(val) {
if (this.masked.typedValueEquals(val)) return;
this.masked.typedValue = val;
this.updateControl();
this.alignCursor();
}
/**
Starts listening to element events
@protected
*/
}, {
key: "_bindEvents",
value: function _bindEvents() {
this.el.bindEvents({
selectionChange: this._saveSelection,
input: this._onInput,
drop: this._onDrop,
click: this._onClick,
focus: this._onFocus,
commit: this._onChange
});
}
/**
Starts listening to element events
@protected
*/
_bindEvents() {
this.el.bindEvents({
selectionChange: this._saveSelection,
input: this._onInput,
drop: this._onDrop,
click: this._onClick,
focus: this._onFocus,
commit: this._onChange
});
}
/**
Stops listening to element events
@protected
*/
}, {
key: "_unbindEvents",
value: function _unbindEvents() {
if (this.el) this.el.unbindEvents();
}
/**
Stops listening to element events
@protected
*/
_unbindEvents() {
if (this.el) this.el.unbindEvents();
}
/**
Fires custom event
@protected
*/
}, {
key: "_fireEvent",
value: function _fireEvent(ev) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var listeners = this._listeners[ev];
if (!listeners) return;
listeners.forEach(function (l) {
return l.apply(void 0, args);
});
/**
Fires custom event
@protected
*/
_fireEvent(ev) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
const listeners = this._listeners[ev];
if (!listeners) return;
listeners.forEach(l => l(...args));
}
/**
Current selection start
@readonly
*/
}, {
key: "selectionStart",
get: function get() {
return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
}
/**
Current selection start
@readonly
*/
get selectionStart() {
return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
}
/** Current cursor position */
}, {
key: "cursorPos",
get: function get() {
return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
},
set: function set(pos) {
if (!this.el || !this.el.isActive) return;
this.el.select(pos, pos);
this._saveSelection();
/** Current cursor position */
get cursorPos() {
return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
}
set cursorPos(pos) {
if (!this.el || !this.el.isActive) return;
this.el.select(pos, pos);
this._saveSelection();
}
/**
Stores current selection
@protected
*/
_saveSelection( /* ev */
) {
if (this.value !== this.el.value) {
console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.'); // eslint-disable-line no-console
}
/**
Stores current selection
@protected
*/
}, {
key: "_saveSelection",
value: function _saveSelection( /* ev */
) {
if (this.value !== this.el.value) {
console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.'); // eslint-disable-line no-console
}
this._selection = {
start: this.selectionStart,
end: this.cursorPos
};
}
this._selection = {
start: this.selectionStart,
end: this.cursorPos
};
}
/** Syncronizes model value from view */
updateValue() {
this.masked.value = this.el.value;
this._value = this.masked.value;
}
/** Syncronizes model value from view */
}, {
key: "updateValue",
value: function updateValue() {
this.masked.value = this.el.value;
this._value = this.masked.value;
}
/** Syncronizes view from model value, fires change events */
updateControl() {
const newUnmaskedValue = this.masked.unmaskedValue;
const newValue = this.masked.value;
const isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue;
this._unmaskedValue = newUnmaskedValue;
this._value = newValue;
if (this.el.value !== newValue) this.el.value = newValue;
if (isChanged) this._fireChangeEvents();
}
/** Syncronizes view from model value, fires change events */
}, {
key: "updateControl",
value: function updateControl() {
var newUnmaskedValue = this.masked.unmaskedValue;
var newValue = this.masked.value;
var isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue;
this._unmaskedValue = newUnmaskedValue;
this._value = newValue;
if (this.el.value !== newValue) this.el.value = newValue;
if (isChanged) this._fireChangeEvents();
}
/** Updates options with deep equal check, recreates @{link Masked} model if mask type changes */
updateOptions(opts) {
const {
mask
} = opts,
restOpts = _objectWithoutPropertiesLoose(opts, _excluded);
const updateMask = !this.maskEquals(mask);
const updateOpts = !objectIncludes(this.masked, restOpts);
if (updateMask) this.mask = mask;
if (updateOpts) this.masked.updateOptions(restOpts);
if (updateMask || updateOpts) this.updateControl();
}
/** Updates options with deep equal check, recreates @{link Masked} model if mask type changes */
}, {
key: "updateOptions",
value: function updateOptions(opts) {
var mask = opts.mask,
restOpts = _objectWithoutProperties(opts, _excluded);
var updateMask = !this.maskEquals(mask);
var updateOpts = !objectIncludes(this.masked, restOpts);
if (updateMask) this.mask = mask;
if (updateOpts) this.masked.updateOptions(restOpts);
if (updateMask || updateOpts) this.updateControl();
}
/** Updates cursor */
updateCursor(cursorPos) {
if (cursorPos == null) return;
this.cursorPos = cursorPos;
/** Updates cursor */
}, {
key: "updateCursor",
value: function updateCursor(cursorPos) {
if (cursorPos == null) return;
this.cursorPos = cursorPos;
// also queue change cursor for mobile browsers
this._delayUpdateCursor(cursorPos);
}
// also queue change cursor for mobile browsers
this._delayUpdateCursor(cursorPos);
}
/**
Delays cursor update to support mobile browsers
@private
*/
}, {
key: "_delayUpdateCursor",
value: function _delayUpdateCursor(cursorPos) {
var _this = this;
/**
Delays cursor update to support mobile browsers
@private
*/
_delayUpdateCursor(cursorPos) {
this._abortUpdateCursor();
this._changingCursorPos = cursorPos;
this._cursorChanging = setTimeout(() => {
if (!this.el) return; // if was destroyed
this.cursorPos = this._changingCursorPos;
this._abortUpdateCursor();
this._changingCursorPos = cursorPos;
this._cursorChanging = setTimeout(function () {
if (!_this.el) return; // if was destroyed
_this.cursorPos = _this._changingCursorPos;
_this._abortUpdateCursor();
}, 10);
}
}, 10);
}
/**
Fires custom events
@protected
*/
}, {
key: "_fireChangeEvents",
value: function _fireChangeEvents() {
this._fireEvent('accept', this._inputEvent);
if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
}
/**
Fires custom events
@protected
*/
_fireChangeEvents() {
this._fireEvent('accept', this._inputEvent);
if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
}
/**
Aborts delayed cursor update
@private
*/
}, {
key: "_abortUpdateCursor",
value: function _abortUpdateCursor() {
if (this._cursorChanging) {
clearTimeout(this._cursorChanging);
delete this._cursorChanging;
}
/**
Aborts delayed cursor update
@private
*/
_abortUpdateCursor() {
if (this._cursorChanging) {
clearTimeout(this._cursorChanging);
delete this._cursorChanging;
}
}
/** Aligns cursor to nearest available position */
}, {
key: "alignCursor",
value: function alignCursor() {
this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
}
/** Aligns cursor to nearest available position */
alignCursor() {
this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
}
/** Aligns cursor only if selection is empty */
}, {
key: "alignCursorFriendly",
value: function alignCursorFriendly() {
if (this.selectionStart !== this.cursorPos) return; // skip if range is selected
this.alignCursor();
}
/** Aligns cursor only if selection is empty */
alignCursorFriendly() {
if (this.selectionStart !== this.cursorPos) return; // skip if range is selected
this.alignCursor();
}
/** Adds listener on custom event */
}, {
key: "on",
value: function on(ev, handler) {
if (!this._listeners[ev]) this._listeners[ev] = [];
this._listeners[ev].push(handler);
return this;
}
/** Adds listener on custom event */
on(ev, handler) {
if (!this._listeners[ev]) this._listeners[ev] = [];
this._listeners[ev].push(handler);
return this;
}
/** Removes custom event listener */
}, {
key: "off",
value: function off(ev, handler) {
if (!this._listeners[ev]) return this;
if (!handler) {
delete this._listeners[ev];
return this;
}
var hIndex = this._listeners[ev].indexOf(handler);
if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);
/** Removes custom event listener */
off(ev, handler) {
if (!this._listeners[ev]) return this;
if (!handler) {
delete this._listeners[ev];
return this;
}
const hIndex = this._listeners[ev].indexOf(handler);
if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);
return this;
}
/** Handles view input event */
}, {
key: "_onInput",
value: function _onInput(e) {
this._inputEvent = e;
this._abortUpdateCursor();
/** Handles view input event */
_onInput(e) {
this._inputEvent = e;
this._abortUpdateCursor();
// fix strange IE behavior
if (!this._selection) return this.updateValue();
var details = new ActionDetails(
// new state
this.el.value, this.cursorPos,
// old state
this.value, this._selection);
var oldRawValue = this.masked.rawInputValue;
var offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
input: true,
raw: true
}).offset;
// fix strange IE behavior
if (!this._selection) return this.updateValue();
const details = new ActionDetails(
// new state
this.el.value, this.cursorPos,
// old state
this.value, this._selection);
const oldRawValue = this.masked.rawInputValue;
const offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
input: true,
raw: true
}).offset;
// force align in remove direction only if no input chars were removed
// otherwise we still need to align with NONE (to get out from fixed symbols for instance)
var removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
var cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
this.updateControl();
this.updateCursor(cursorPos);
delete this._inputEvent;
}
// force align in remove direction only if no input chars were removed
// otherwise we still need to align with NONE (to get out from fixed symbols for instance)
const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
this.updateControl();
this.updateCursor(cursorPos);
delete this._inputEvent;
}
/** Handles view change event and commits model value */
}, {
key: "_onChange",
value: function _onChange() {
if (this.value !== this.el.value) {
this.updateValue();
}
this.masked.doCommit();
this.updateControl();
this._saveSelection();
/** Handles view change event and commits model value */
_onChange() {
if (this.value !== this.el.value) {
this.updateValue();
}
this.masked.doCommit();
this.updateControl();
this._saveSelection();
}
/** Handles view drop event, prevents by default */
}, {
key: "_onDrop",
value: function _onDrop(ev) {
ev.preventDefault();
ev.stopPropagation();
}
/** Handles view drop event, prevents by default */
_onDrop(ev) {
ev.preventDefault();
ev.stopPropagation();
}
/** Restore last selection on focus */
}, {
key: "_onFocus",
value: function _onFocus(ev) {
this.alignCursorFriendly();
}
/** Restore last selection on focus */
_onFocus(ev) {
this.alignCursorFriendly();
}
/** Restore last selection on focus */
}, {
key: "_onClick",
value: function _onClick(ev) {
this.alignCursorFriendly();
}
/** Restore last selection on focus */
_onClick(ev) {
this.alignCursorFriendly();
}
/** Unbind view events and removes element reference */
}, {
key: "destroy",
value: function destroy() {
this._unbindEvents();
// $FlowFixMe why not do so?
this._listeners.length = 0;
// $FlowFixMe
delete this.el;
}
}]);
return InputMask;
}();
/** Unbind view events and removes element reference */
destroy() {
this._unbindEvents();
// $FlowFixMe why not do so?
this._listeners.length = 0;
// $FlowFixMe
delete this.el;
}
}
IMask.InputMask = InputMask;
export { InputMask as default };

@@ -1,2 +0,1 @@

import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import IMask from '../core/holder.js';

@@ -8,67 +7,48 @@

*/
var MaskElement = /*#__PURE__*/function () {
function MaskElement() {
_classCallCheck(this, MaskElement);
}
_createClass(MaskElement, [{
key: "selectionStart",
get: /** */
class MaskElement {
/** */
/** */
/** */
/** */
/** */
/** Safely returns selection start */
function get() {
var start;
try {
start = this._unsafeSelectionStart;
} catch (e) {}
return start != null ? start : this.value.length;
}
/** Safely returns selection start */
get selectionStart() {
let start;
try {
start = this._unsafeSelectionStart;
} catch (e) {}
return start != null ? start : this.value.length;
}
/** Safely returns selection end */
}, {
key: "selectionEnd",
get: function get() {
var end;
try {
end = this._unsafeSelectionEnd;
} catch (e) {}
return end != null ? end : this.value.length;
}
/** Safely returns selection end */
get selectionEnd() {
let end;
try {
end = this._unsafeSelectionEnd;
} catch (e) {}
return end != null ? end : this.value.length;
}
/** Safely sets element selection */
}, {
key: "select",
value: function select(start, end) {
if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
try {
this._unsafeSelect(start, end);
} catch (e) {}
}
/** Safely sets element selection */
select(start, end) {
if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
try {
this._unsafeSelect(start, end);
} catch (e) {}
}
/** Should be overriden in subclasses */
}, {
key: "_unsafeSelect",
value: function _unsafeSelect(start, end) {}
/** Should be overriden in subclasses */
}, {
key: "isActive",
get: function get() {
return false;
}
/** Should be overriden in subclasses */
}, {
key: "bindEvents",
value: function bindEvents(handlers) {}
/** Should be overriden in subclasses */
}, {
key: "unbindEvents",
value: function unbindEvents() {}
}]);
return MaskElement;
}();
/** Should be overriden in subclasses */
_unsafeSelect(start, end) {}
/** Should be overriden in subclasses */
get isActive() {
return false;
}
/** Should be overriden in subclasses */
bindEvents(handlers) {}
/** Should be overriden in subclasses */
unbindEvents() {}
}
IMask.MaskElement = MaskElement;
export { MaskElement as default };

@@ -1,2 +0,1 @@

import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import { DIRECTION } from './utils.js';

@@ -6,3 +5,3 @@ import './change-details.js';

/** Provides details of changing input */
var ActionDetails = /*#__PURE__*/function () {
class ActionDetails {
/** Current input value */

@@ -16,4 +15,3 @@

function ActionDetails(value, cursorPos, oldValue, oldSelection) {
_classCallCheck(this, ActionDetails);
constructor(value, cursorPos, oldValue, oldSelection) {
this.value = value;

@@ -34,89 +32,71 @@ this.cursorPos = cursorPos;

*/
_createClass(ActionDetails, [{
key: "startChangePos",
get: function get() {
return Math.min(this.cursorPos, this.oldSelection.start);
}
get startChangePos() {
return Math.min(this.cursorPos, this.oldSelection.start);
}
/**
Inserted symbols count
@readonly
*/
}, {
key: "insertedCount",
get: function get() {
return this.cursorPos - this.startChangePos;
}
/**
Inserted symbols count
@readonly
*/
get insertedCount() {
return this.cursorPos - this.startChangePos;
}
/**
Inserted symbols
@readonly
*/
}, {
key: "inserted",
get: function get() {
return this.value.substr(this.startChangePos, this.insertedCount);
}
/**
Inserted symbols
@readonly
*/
get inserted() {
return this.value.substr(this.startChangePos, this.insertedCount);
}
/**
Removed symbols count
@readonly
*/
}, {
key: "removedCount",
get: function get() {
// Math.max for opposite operation
return Math.max(this.oldSelection.end - this.startChangePos ||
// for Delete
this.oldValue.length - this.value.length, 0);
}
/**
Removed symbols count
@readonly
*/
get removedCount() {
// Math.max for opposite operation
return Math.max(this.oldSelection.end - this.startChangePos ||
// for Delete
this.oldValue.length - this.value.length, 0);
}
/**
Removed symbols
@readonly
*/
}, {
key: "removed",
get: function get() {
return this.oldValue.substr(this.startChangePos, this.removedCount);
}
/**
Removed symbols
@readonly
*/
get removed() {
return this.oldValue.substr(this.startChangePos, this.removedCount);
}
/**
Unchanged head symbols
@readonly
*/
}, {
key: "head",
get: function get() {
return this.value.substring(0, this.startChangePos);
}
/**
Unchanged head symbols
@readonly
*/
get head() {
return this.value.substring(0, this.startChangePos);
}
/**
Unchanged tail symbols
@readonly
*/
}, {
key: "tail",
get: function get() {
return this.value.substring(this.startChangePos + this.insertedCount);
}
/**
Unchanged tail symbols
@readonly
*/
get tail() {
return this.value.substring(this.startChangePos + this.insertedCount);
}
/**
Remove direction
@readonly
*/
}, {
key: "removeDirection",
get: function get() {
if (!this.removedCount || this.insertedCount) return DIRECTION.NONE;
/**
Remove direction
@readonly
*/
get removeDirection() {
if (!this.removedCount || this.insertedCount) return DIRECTION.NONE;
// align right if delete at right
return (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) &&
// if not range removed (event with backspace)
this.oldSelection.end === this.oldSelection.start ? DIRECTION.RIGHT : DIRECTION.LEFT;
}
}]);
return ActionDetails;
}();
// align right if delete at right
return (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) &&
// if not range removed (event with backspace)
this.oldSelection.end === this.oldSelection.start ? DIRECTION.RIGHT : DIRECTION.LEFT;
}
}
export { ActionDetails as default };

@@ -1,3 +0,1 @@

import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-30a49e9e.js';
/**

@@ -11,3 +9,3 @@ Provides details of changing model value

*/
var ChangeDetails = /*#__PURE__*/function () {
class ChangeDetails {
/** Inserted symbols */

@@ -21,4 +19,3 @@

function ChangeDetails(details) {
_classCallCheck(this, ChangeDetails);
constructor(details) {
Object.assign(this, {

@@ -36,22 +33,16 @@ inserted: '',

*/
_createClass(ChangeDetails, [{
key: "aggregate",
value: function aggregate(details) {
this.rawInserted += details.rawInserted;
this.skip = this.skip || details.skip;
this.inserted += details.inserted;
this.tailShift += details.tailShift;
return this;
}
aggregate(details) {
this.rawInserted += details.rawInserted;
this.skip = this.skip || details.skip;
this.inserted += details.inserted;
this.tailShift += details.tailShift;
return this;
}
/** Total offset considering all changes */
}, {
key: "offset",
get: function get() {
return this.tailShift + this.inserted.length;
}
}]);
return ChangeDetails;
}();
/** Total offset considering all changes */
get offset() {
return this.tailShift + this.inserted.length;
}
}
export { ChangeDetails as default };

@@ -1,5 +0,3 @@

import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-30a49e9e.js';
/** Provides details of continuous extracted tail */
var ContinuousTailDetails = /*#__PURE__*/function () {
class ContinuousTailDetails {
/** Tail value as string */

@@ -11,7 +9,6 @@

function ContinuousTailDetails() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var stop = arguments.length > 2 ? arguments[2] : undefined;
_classCallCheck(this, ContinuousTailDetails);
constructor() {
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
let stop = arguments.length > 2 ? arguments[2] : undefined;
this.value = value;

@@ -21,51 +18,37 @@ this.from = from;

}
_createClass(ContinuousTailDetails, [{
key: "toString",
value: function toString() {
return this.value;
}
}, {
key: "extend",
value: function extend(tail) {
this.value += String(tail);
}
}, {
key: "appendTo",
value: function appendTo(masked) {
return masked.append(this.toString(), {
tail: true
}).aggregate(masked._appendPlaceholder());
}
}, {
key: "state",
get: function get() {
return {
value: this.value,
from: this.from,
stop: this.stop
};
},
set: function set(state) {
Object.assign(this, state);
}
}, {
key: "unshift",
value: function unshift(beforePos) {
if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
var shiftChar = this.value[0];
this.value = this.value.slice(1);
return shiftChar;
}
}, {
key: "shift",
value: function shift() {
if (!this.value.length) return '';
var shiftChar = this.value[this.value.length - 1];
this.value = this.value.slice(0, -1);
return shiftChar;
}
}]);
return ContinuousTailDetails;
}();
toString() {
return this.value;
}
extend(tail) {
this.value += String(tail);
}
appendTo(masked) {
return masked.append(this.toString(), {
tail: true
}).aggregate(masked._appendPlaceholder());
}
get state() {
return {
value: this.value,
from: this.from,
stop: this.stop
};
}
set state(state) {
Object.assign(this, state);
}
unshift(beforePos) {
if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
const shiftChar = this.value[0];
this.value = this.value.slice(1);
return shiftChar;
}
shift() {
if (!this.value.length) return '';
const shiftChar = this.value[this.value.length - 1];
this.value = this.value.slice(0, -1);
return shiftChar;
}
}
export { ContinuousTailDetails as default };

@@ -9,3 +9,3 @@ /**

function IMask(el) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// currently available only for input-like elements

@@ -12,0 +12,0 @@ return new IMask.InputMask(el, opts);

@@ -1,2 +0,1 @@

import { c as _typeof } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import ChangeDetails from './change-details.js';

@@ -17,3 +16,3 @@

*/
var DIRECTION = {
const DIRECTION = {
NONE: 'NONE',

@@ -82,3 +81,3 @@ LEFT: 'LEFT',

if (arrA != arrB) return false;
if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
if (a && b && typeof a === 'object' && typeof b === 'object') {
var dateA = a instanceof Date,

@@ -85,0 +84,0 @@ dateB = b instanceof Date;

import './controls/input.js';
import IMask from './core/holder.js';
export { default } from './core/holder.js';
import './_rollupPluginBabelHelpers-30a49e9e.js';
import './_rollupPluginBabelHelpers-6b3bd404.js';
import './core/utils.js';

@@ -6,0 +6,0 @@ import './core/change-details.js';

@@ -19,3 +19,3 @@ export { default as InputMask } from './controls/input.js';

export { default as ChangeDetails } from './core/change-details.js';
import './_rollupPluginBabelHelpers-30a49e9e.js';
import './_rollupPluginBabelHelpers-6b3bd404.js';
import './core/utils.js';

@@ -22,0 +22,0 @@ import './core/action-details.js';

@@ -1,10 +0,14 @@

import { _ as _createClass, a as _classCallCheck, f as _slicedToArray } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import ChangeDetails from '../core/change-details.js';
import ContinuousTailDetails from '../core/continuous-tail-details.js';
import { isString, normalizePrepare, forceDirection, DIRECTION } from '../core/utils.js';
import { isString, normalizePrepare, DIRECTION, forceDirection } from '../core/utils.js';
import IMask from '../core/holder.js';
/** Supported mask type */
/** Append flags */
/** Extract flags */
/** Provides common masking stuff */
var Masked = /*#__PURE__*/function () {
class Masked {
// $Shape<MaskedOptions>; TODO after fix https://github.com/facebook/flow/issues/4773

@@ -15,23 +19,12 @@

/** */ // $FlowFixMe no ideas
/** Transforms value before mask processing */
/** Validates if value is acceptable */
/** Does additional processing in the end of editing */
/** Format typed value to string */
/** Parse strgin to get typed value */
/** Enable characters overwriting */
/** */
/** */
/** */
function Masked(opts) {
_classCallCheck(this, Masked);
constructor(opts) {
this._value = '';

@@ -43,405 +36,334 @@ this._update(Object.assign({}, Masked.DEFAULTS, opts));

/** Sets and applies new options */
_createClass(Masked, [{
key: "updateOptions",
value: function updateOptions(opts) {
if (!Object.keys(opts).length) return;
// $FlowFixMe
this.withValueRefresh(this._update.bind(this, opts));
}
updateOptions(opts) {
if (!Object.keys(opts).length) return;
// $FlowFixMe
this.withValueRefresh(this._update.bind(this, opts));
}
/**
Sets new options
@protected
*/
}, {
key: "_update",
value: function _update(opts) {
Object.assign(this, opts);
}
/**
Sets new options
@protected
*/
_update(opts) {
Object.assign(this, opts);
}
/** Mask state */
}, {
key: "state",
get: function get() {
return {
_value: this.value
};
},
set: function set(state) {
this._value = state._value;
}
/** Mask state */
get state() {
return {
_value: this.value
};
}
set state(state) {
this._value = state._value;
}
/** Resets value */
}, {
key: "reset",
value: function reset() {
this._value = '';
}
/** Resets value */
reset() {
this._value = '';
}
/** */
}, {
key: "value",
get: function get() {
return this._value;
},
set: function set(value) {
this.resolve(value);
}
/** */
get value() {
return this._value;
}
set value(value) {
this.resolve(value);
}
/** Resolve new value */
}, {
key: "resolve",
value: function resolve(value) {
this.reset();
this.append(value, {
input: true
}, '');
this.doCommit();
return this.value;
}
/** Resolve new value */
resolve(value) {
this.reset();
this.append(value, {
input: true
}, '');
this.doCommit();
return this.value;
}
/** */
}, {
key: "unmaskedValue",
get: function get() {
return this.value;
},
set: function set(value) {
this.reset();
this.append(value, {}, '');
this.doCommit();
}
/** */
get unmaskedValue() {
return this.value;
}
set unmaskedValue(value) {
this.reset();
this.append(value, {}, '');
this.doCommit();
}
/** */
}, {
key: "typedValue",
get: function get() {
return this.doParse(this.value);
},
set: function set(value) {
this.value = this.doFormat(value);
}
/** */
get typedValue() {
return this.doParse(this.value);
}
set typedValue(value) {
this.value = this.doFormat(value);
}
/** Value that includes raw user input */
}, {
key: "rawInputValue",
get: function get() {
return this.extractInput(0, this.value.length, {
raw: true
});
},
set: function set(value) {
this.reset();
this.append(value, {
raw: true
}, '');
this.doCommit();
}
/** Value that includes raw user input */
get rawInputValue() {
return this.extractInput(0, this.value.length, {
raw: true
});
}
set rawInputValue(value) {
this.reset();
this.append(value, {
raw: true
}, '');
this.doCommit();
}
/** */
}, {
key: "isComplete",
get: function get() {
return true;
}
/** */
get isComplete() {
return true;
}
/** */
}, {
key: "isFilled",
get: function get() {
return this.isComplete;
}
/** */
get isFilled() {
return this.isComplete;
}
/** Finds nearest input position in direction */
}, {
key: "nearestInputPos",
value: function nearestInputPos(cursorPos, direction) {
return cursorPos;
}
/** Finds nearest input position in direction */
nearestInputPos(cursorPos, direction) {
return cursorPos;
}
/** Extracts value in range considering flags */
}, {
key: "extractInput",
value: function extractInput() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
return this.value.slice(fromPos, toPos);
}
/** Extracts value in range considering flags */
extractInput() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
return this.value.slice(fromPos, toPos);
}
/** Extracts tail in range */
}, {
key: "extractTail",
value: function extractTail() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);
}
/** Extracts tail in range */
extractTail() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);
}
/** Appends tail */
// $FlowFixMe no ideas
}, {
key: "appendTail",
value: function appendTail(tail) {
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
return tail.appendTo(this);
}
/** Appends tail */
// $FlowFixMe no ideas
appendTail(tail) {
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
return tail.appendTo(this);
}
/** Appends char */
}, {
key: "_appendCharRaw",
value: function _appendCharRaw(ch) {
if (!ch) return new ChangeDetails();
this._value += ch;
return new ChangeDetails({
inserted: ch,
rawInserted: ch
});
}
/** Appends char */
_appendCharRaw(ch) {
if (!ch) return new ChangeDetails();
this._value += ch;
return new ChangeDetails({
inserted: ch,
rawInserted: ch
});
}
/** Appends char */
}, {
key: "_appendChar",
value: function _appendChar(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var checkTail = arguments.length > 2 ? arguments[2] : undefined;
var consistentState = this.state;
var details;
var _normalizePrepare = normalizePrepare(this.doPrepare(ch, flags));
var _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2);
ch = _normalizePrepare2[0];
details = _normalizePrepare2[1];
details = details.aggregate(this._appendCharRaw(ch, flags));
if (details.inserted) {
var consistentTail;
var appended = this.doValidate(flags) !== false;
if (appended && checkTail != null) {
// validation ok, check tail
var beforeTailState = this.state;
if (this.overwrite === true) {
consistentTail = checkTail.state;
checkTail.unshift(this.value.length - details.tailShift);
}
var tailDetails = this.appendTail(checkTail);
/** Appends char */
_appendChar(ch) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let checkTail = arguments.length > 2 ? arguments[2] : undefined;
const consistentState = this.state;
let details;
[ch, details] = normalizePrepare(this.doPrepare(ch, flags));
details = details.aggregate(this._appendCharRaw(ch, flags));
if (details.inserted) {
let consistentTail;
let appended = this.doValidate(flags) !== false;
if (appended && checkTail != null) {
// validation ok, check tail
const beforeTailState = this.state;
if (this.overwrite === true) {
consistentTail = checkTail.state;
checkTail.unshift(this.value.length - details.tailShift);
}
let tailDetails = this.appendTail(checkTail);
appended = tailDetails.rawInserted === checkTail.toString();
// not ok, try shift
if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
this.state = beforeTailState;
consistentTail = checkTail.state;
checkTail.shift();
tailDetails = this.appendTail(checkTail);
appended = tailDetails.rawInserted === checkTail.toString();
// not ok, try shift
if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
this.state = beforeTailState;
consistentTail = checkTail.state;
checkTail.shift();
tailDetails = this.appendTail(checkTail);
appended = tailDetails.rawInserted === checkTail.toString();
}
// if ok, rollback state after tail
if (appended && tailDetails.inserted) this.state = beforeTailState;
}
// revert all if something went wrong
if (!appended) {
details = new ChangeDetails();
this.state = consistentState;
if (checkTail && consistentTail) checkTail.state = consistentTail;
}
// if ok, rollback state after tail
if (appended && tailDetails.inserted) this.state = beforeTailState;
}
return details;
}
/** Appends optional placeholder at end */
}, {
key: "_appendPlaceholder",
value: function _appendPlaceholder() {
return new ChangeDetails();
// revert all if something went wrong
if (!appended) {
details = new ChangeDetails();
this.state = consistentState;
if (checkTail && consistentTail) checkTail.state = consistentTail;
}
}
return details;
}
/** Appends optional eager placeholder at end */
}, {
key: "_appendEager",
value: function _appendEager() {
return new ChangeDetails();
}
/** Appends optional placeholder at end */
_appendPlaceholder() {
return new ChangeDetails();
}
/** Appends symbols considering flags */
// $FlowFixMe no ideas
}, {
key: "append",
value: function append(str, flags, tail) {
if (!isString(str)) throw new Error('value should be string');
var details = new ChangeDetails();
var checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
if (flags !== null && flags !== void 0 && flags.tail) flags._beforeTailState = this.state;
for (var ci = 0; ci < str.length; ++ci) {
var d = this._appendChar(str[ci], flags, checkTail);
if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
details.aggregate(d);
}
/** Appends optional eager placeholder at end */
_appendEager() {
return new ChangeDetails();
}
// append tail but aggregate only tailShift
if (checkTail != null) {
details.tailShift += this.appendTail(checkTail).tailShift;
// TODO it's a good idea to clear state after appending ends
// but it causes bugs when one append calls another (when dynamic dispatch set rawInputValue)
// this._resetBeforeTailState();
}
if ((this.eager === true || this.eager === 'append') && flags !== null && flags !== void 0 && flags.input && str) {
details.aggregate(this._appendEager());
}
return details;
/** Appends symbols considering flags */
// $FlowFixMe no ideas
append(str, flags, tail) {
if (!isString(str)) throw new Error('value should be string');
const details = new ChangeDetails();
const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
if (flags !== null && flags !== void 0 && flags.tail) flags._beforeTailState = this.state;
for (let ci = 0; ci < str.length; ++ci) {
const d = this._appendChar(str[ci], flags, checkTail);
if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
details.aggregate(d);
}
/** */
}, {
key: "remove",
value: function remove() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
this._value = this.value.slice(0, fromPos) + this.value.slice(toPos);
return new ChangeDetails();
// append tail but aggregate only tailShift
if (checkTail != null) {
details.tailShift += this.appendTail(checkTail).tailShift;
// TODO it's a good idea to clear state after appending ends
// but it causes bugs when one append calls another (when dynamic dispatch set rawInputValue)
// this._resetBeforeTailState();
}
/** Calls function and reapplies current value */
}, {
key: "withValueRefresh",
value: function withValueRefresh(fn) {
if (this._refreshing || !this.isInitialized) return fn();
this._refreshing = true;
var rawInput = this.rawInputValue;
var value = this.value;
var ret = fn();
this.rawInputValue = rawInput;
// append lost trailing chars at end
if (this.value && this.value !== value && value.indexOf(this.value) === 0) {
this.append(value.slice(this.value.length), {}, '');
}
delete this._refreshing;
return ret;
if ((this.eager === true || this.eager === 'append') && flags !== null && flags !== void 0 && flags.input && str) {
details.aggregate(this._appendEager());
}
return details;
}
/** */
}, {
key: "runIsolated",
value: function runIsolated(fn) {
if (this._isolated || !this.isInitialized) return fn(this);
this._isolated = true;
var state = this.state;
var ret = fn(this);
this.state = state;
delete this._isolated;
return ret;
}
/** */
remove() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
this._value = this.value.slice(0, fromPos) + this.value.slice(toPos);
return new ChangeDetails();
}
/** */
}, {
key: "doSkipInvalid",
value: function doSkipInvalid(ch) {
return this.skipInvalid;
/** Calls function and reapplies current value */
withValueRefresh(fn) {
if (this._refreshing || !this.isInitialized) return fn();
this._refreshing = true;
const rawInput = this.rawInputValue;
const value = this.value;
const ret = fn();
this.rawInputValue = rawInput;
// append lost trailing chars at end
if (this.value && this.value !== value && value.indexOf(this.value) === 0) {
this.append(value.slice(this.value.length), {}, '');
}
delete this._refreshing;
return ret;
}
/**
Prepares string before mask processing
@protected
*/
}, {
key: "doPrepare",
value: function doPrepare(str) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return this.prepare ? this.prepare(str, this, flags) : str;
}
/** */
runIsolated(fn) {
if (this._isolated || !this.isInitialized) return fn(this);
this._isolated = true;
const state = this.state;
const ret = fn(this);
this.state = state;
delete this._isolated;
return ret;
}
/**
Validates if value is acceptable
@protected
*/
}, {
key: "doValidate",
value: function doValidate(flags) {
return (!this.validate || this.validate(this.value, this, flags)) && (!this.parent || this.parent.doValidate(flags));
}
/** */
doSkipInvalid(ch) {
return this.skipInvalid;
}
/**
Does additional processing in the end of editing
@protected
*/
}, {
key: "doCommit",
value: function doCommit() {
if (this.commit) this.commit(this.value, this);
}
/**
Prepares string before mask processing
@protected
*/
doPrepare(str) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return this.prepare ? this.prepare(str, this, flags) : str;
}
/** */
}, {
key: "doFormat",
value: function doFormat(value) {
return this.format ? this.format(value, this) : value;
}
/**
Validates if value is acceptable
@protected
*/
doValidate(flags) {
return (!this.validate || this.validate(this.value, this, flags)) && (!this.parent || this.parent.doValidate(flags));
}
/** */
}, {
key: "doParse",
value: function doParse(str) {
return this.parse ? this.parse(str, this) : str;
/**
Does additional processing in the end of editing
@protected
*/
doCommit() {
if (this.commit) this.commit(this.value, this);
}
/** */
doFormat(value) {
return this.format ? this.format(value, this) : value;
}
/** */
doParse(str) {
return this.parse ? this.parse(str, this) : str;
}
/** */
splice(start, deleteCount, inserted, removeDirection) {
let flags = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
input: true
};
const tailPos = start + deleteCount;
const tail = this.extractTail(tailPos);
const eagerRemove = this.eager === true || this.eager === 'remove';
let oldRawValue;
if (eagerRemove) {
removeDirection = forceDirection(removeDirection);
oldRawValue = this.extractInput(0, tailPos, {
raw: true
});
}
let startChangePos = start;
const details = new ChangeDetails();
/** */
}, {
key: "splice",
value: function splice(start, deleteCount, inserted, removeDirection) {
var flags = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
input: true
};
var tailPos = start + deleteCount;
var tail = this.extractTail(tailPos);
var eagerRemove = this.eager === true || this.eager === 'remove';
var oldRawValue;
if (eagerRemove) {
removeDirection = forceDirection(removeDirection);
oldRawValue = this.extractInput(0, tailPos, {
raw: true
});
}
var startChangePos = start;
var details = new ChangeDetails();
// if it is just deletion without insertion
if (removeDirection !== DIRECTION.NONE) {
startChangePos = this.nearestInputPos(start, deleteCount > 1 && start !== 0 && !eagerRemove ? DIRECTION.NONE : removeDirection);
// if it is just deletion without insertion
if (removeDirection !== DIRECTION.NONE) {
startChangePos = this.nearestInputPos(start, deleteCount > 1 && start !== 0 && !eagerRemove ? DIRECTION.NONE : removeDirection);
// adjust tailShift if start was aligned
details.tailShift = startChangePos - start;
}
details.aggregate(this.remove(startChangePos));
if (eagerRemove && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
if (removeDirection === DIRECTION.FORCE_LEFT) {
var valLength;
while (oldRawValue === this.rawInputValue && (valLength = this.value.length)) {
details.aggregate(new ChangeDetails({
tailShift: -1
})).aggregate(this.remove(valLength - 1));
}
} else if (removeDirection === DIRECTION.FORCE_RIGHT) {
tail.unshift();
// adjust tailShift if start was aligned
details.tailShift = startChangePos - start;
}
details.aggregate(this.remove(startChangePos));
if (eagerRemove && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
if (removeDirection === DIRECTION.FORCE_LEFT) {
let valLength;
while (oldRawValue === this.rawInputValue && (valLength = this.value.length)) {
details.aggregate(new ChangeDetails({
tailShift: -1
})).aggregate(this.remove(valLength - 1));
}
} else if (removeDirection === DIRECTION.FORCE_RIGHT) {
tail.unshift();
}
return details.aggregate(this.append(inserted, flags, tail));
}
}, {
key: "maskEquals",
value: function maskEquals(mask) {
return this.mask === mask;
}
}, {
key: "typedValueEquals",
value: function typedValueEquals(value) {
var tval = this.typedValue;
return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || this.doFormat(value) === this.doFormat(this.typedValue);
}
}]);
return Masked;
}();
return details.aggregate(this.append(inserted, flags, tail));
}
maskEquals(mask) {
return this.mask === mask;
}
typedValueEquals(value) {
const tval = this.typedValue;
return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || this.doFormat(value) === this.doFormat(this.typedValue);
}
}
Masked.DEFAULTS = {
format: String,
parse: function parse(v) {
return v;
},
parse: v => v,
skipInvalid: true

@@ -448,0 +370,0 @@ };

@@ -1,5 +0,5 @@

import { d as _inherits, e as _createSuper, _ as _createClass, f as _slicedToArray, a as _classCallCheck, g as _get, h as _getPrototypeOf, i as _set } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import MaskedPattern from './pattern.js';
import MaskedRange from './range.js';
import IMask from '../core/holder.js';
import '../_rollupPluginBabelHelpers-6b3bd404.js';
import '../core/utils.js';

@@ -17,5 +17,3 @@ import '../core/change-details.js';

/** Date mask */
var MaskedDate = /*#__PURE__*/function (_MaskedPattern) {
_inherits(MaskedDate, _MaskedPattern);
var _super = _createSuper(MaskedDate);
class MaskedDate extends MaskedPattern {
/** Pattern mask for date according to {@link MaskedDate#format} */

@@ -32,5 +30,4 @@

*/
function MaskedDate(opts) {
_classCallCheck(this, MaskedDate);
return _super.call(this, Object.assign({}, MaskedDate.DEFAULTS, opts));
constructor(opts) {
super(Object.assign({}, MaskedDate.DEFAULTS, opts));
}

@@ -41,125 +38,101 @@

*/
_createClass(MaskedDate, [{
key: "_update",
value: function _update(opts) {
if (opts.mask === Date) delete opts.mask;
if (opts.pattern) opts.mask = opts.pattern;
var blocks = opts.blocks;
opts.blocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
// adjust year block
if (opts.min) opts.blocks.Y.from = opts.min.getFullYear();
if (opts.max) opts.blocks.Y.to = opts.max.getFullYear();
if (opts.min && opts.max && opts.blocks.Y.from === opts.blocks.Y.to) {
opts.blocks.m.from = opts.min.getMonth() + 1;
opts.blocks.m.to = opts.max.getMonth() + 1;
if (opts.blocks.m.from === opts.blocks.m.to) {
opts.blocks.d.from = opts.min.getDate();
opts.blocks.d.to = opts.max.getDate();
}
_update(opts) {
if (opts.mask === Date) delete opts.mask;
if (opts.pattern) opts.mask = opts.pattern;
const blocks = opts.blocks;
opts.blocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
// adjust year block
if (opts.min) opts.blocks.Y.from = opts.min.getFullYear();
if (opts.max) opts.blocks.Y.to = opts.max.getFullYear();
if (opts.min && opts.max && opts.blocks.Y.from === opts.blocks.Y.to) {
opts.blocks.m.from = opts.min.getMonth() + 1;
opts.blocks.m.to = opts.max.getMonth() + 1;
if (opts.blocks.m.from === opts.blocks.m.to) {
opts.blocks.d.from = opts.min.getDate();
opts.blocks.d.to = opts.max.getDate();
}
Object.assign(opts.blocks, this.blocks, blocks);
// add autofix
Object.keys(opts.blocks).forEach(function (bk) {
var b = opts.blocks[bk];
if (!('autofix' in b) && 'autofix' in opts) b.autofix = opts.autofix;
});
_get(_getPrototypeOf(MaskedDate.prototype), "_update", this).call(this, opts);
}
Object.assign(opts.blocks, this.blocks, blocks);
/**
@override
*/
}, {
key: "doValidate",
value: function doValidate() {
var _get2;
var date = this.date;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return (_get2 = _get(_getPrototypeOf(MaskedDate.prototype), "doValidate", this)).call.apply(_get2, [this].concat(args)) && (!this.isComplete || this.isDateExist(this.value) && date != null && (this.min == null || this.min <= date) && (this.max == null || date <= this.max));
}
// add autofix
Object.keys(opts.blocks).forEach(bk => {
const b = opts.blocks[bk];
if (!('autofix' in b) && 'autofix' in opts) b.autofix = opts.autofix;
});
super._update(opts);
}
/** Checks if date is exists */
}, {
key: "isDateExist",
value: function isDateExist(str) {
return this.format(this.parse(str, this), this).indexOf(str) >= 0;
}
/**
@override
*/
doValidate() {
const date = this.date;
return super.doValidate(...arguments) && (!this.isComplete || this.isDateExist(this.value) && date != null && (this.min == null || this.min <= date) && (this.max == null || date <= this.max));
}
/** Parsed Date */
}, {
key: "date",
get: function get() {
return this.typedValue;
},
set: function set(date) {
this.typedValue = date;
}
/** Checks if date is exists */
isDateExist(str) {
return this.format(this.parse(str, this), this).indexOf(str) >= 0;
}
/**
@override
*/
}, {
key: "typedValue",
get: function get() {
return this.isComplete ? _get(_getPrototypeOf(MaskedDate.prototype), "typedValue", this) : null;
},
set: function set(value) {
_set(_getPrototypeOf(MaskedDate.prototype), "typedValue", value, this, true);
}
/** Parsed Date */
get date() {
return this.typedValue;
}
set date(date) {
this.typedValue = date;
}
/**
@override
*/
}, {
key: "maskEquals",
value: function maskEquals(mask) {
return mask === Date || _get(_getPrototypeOf(MaskedDate.prototype), "maskEquals", this).call(this, mask);
}
}]);
return MaskedDate;
}(MaskedPattern);
/**
@override
*/
get typedValue() {
return this.isComplete ? super.typedValue : null;
}
set typedValue(value) {
super.typedValue = value;
}
/**
@override
*/
maskEquals(mask) {
return mask === Date || super.maskEquals(mask);
}
}
MaskedDate.DEFAULTS = {
pattern: 'd{.}`m{.}`Y',
format: function format(date) {
format: date => {
if (!date) return '';
var day = String(date.getDate()).padStart(2, '0');
var month = String(date.getMonth() + 1).padStart(2, '0');
var year = date.getFullYear();
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const year = date.getFullYear();
return [day, month, year].join('.');
},
parse: function parse(str) {
var _str$split = str.split('.'),
_str$split2 = _slicedToArray(_str$split, 3),
day = _str$split2[0],
month = _str$split2[1],
year = _str$split2[2];
parse: str => {
const [day, month, year] = str.split('.');
return new Date(year, month - 1, day);
}
};
MaskedDate.GET_DEFAULT_BLOCKS = function () {
return {
d: {
mask: MaskedRange,
from: 1,
to: 31,
maxLength: 2
},
m: {
mask: MaskedRange,
from: 1,
to: 12,
maxLength: 2
},
Y: {
mask: MaskedRange,
from: 1900,
to: 9999
}
};
};
MaskedDate.GET_DEFAULT_BLOCKS = () => ({
d: {
mask: MaskedRange,
from: 1,
to: 31,
maxLength: 2
},
m: {
mask: MaskedRange,
from: 1,
to: 12,
maxLength: 2
},
Y: {
mask: MaskedRange,
from: 1900,
to: 9999
}
});
IMask.MaskedDate = MaskedDate;
export { MaskedDate as default };

@@ -1,2 +0,2 @@

import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck, g as _get, h as _getPrototypeOf, f as _slicedToArray, i as _set, b as _objectWithoutProperties } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import { _ as _objectWithoutPropertiesLoose } from '../_rollupPluginBabelHelpers-6b3bd404.js';
import ChangeDetails from '../core/change-details.js';

@@ -9,7 +9,5 @@ import createMask from './factory.js';

var _excluded = ["compiledMasks", "currentMaskRef", "currentMask"];
const _excluded = ["compiledMasks", "currentMaskRef", "currentMask"];
/** Dynamic mask for choosing apropriate mask in run-time */
var MaskedDynamic = /*#__PURE__*/function (_Masked) {
_inherits(MaskedDynamic, _Masked);
var _super = _createSuper(MaskedDynamic);
class MaskedDynamic extends Masked {
/** Currently chosen mask */

@@ -24,8 +22,5 @@

*/
function MaskedDynamic(opts) {
var _this;
_classCallCheck(this, MaskedDynamic);
_this = _super.call(this, Object.assign({}, MaskedDynamic.DEFAULTS, opts));
_this.currentMask = null;
return _this;
constructor(opts) {
super(Object.assign({}, MaskedDynamic.DEFAULTS, opts));
this.currentMask = null;
}

@@ -36,371 +31,294 @@

*/
_createClass(MaskedDynamic, [{
key: "_update",
value: function _update(opts) {
_get(_getPrototypeOf(MaskedDynamic.prototype), "_update", this).call(this, opts);
if ('mask' in opts) {
// mask could be totally dynamic with only `dispatch` option
this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(function (m) {
return createMask(m);
}) : [];
}
_update(opts) {
super._update(opts);
if ('mask' in opts) {
// mask could be totally dynamic with only `dispatch` option
this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(m => createMask(m)) : [];
}
}
/**
@override
*/
}, {
key: "_appendCharRaw",
value: function _appendCharRaw(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var details = this._applyDispatch(ch, flags);
if (this.currentMask) {
details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));
}
return details;
/**
@override
*/
_appendCharRaw(ch) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const details = this._applyDispatch(ch, flags);
if (this.currentMask) {
details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));
}
}, {
key: "_applyDispatch",
value: function _applyDispatch() {
var appended = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
var inputValue = this.rawInputValue;
var insertValue = flags.tail && flags._beforeTailState != null ?
// $FlowFixMe - tired to fight with type system
flags._beforeTailState._rawInputValue : inputValue;
var tailValue = inputValue.slice(insertValue.length);
var prevMask = this.currentMask;
var details = new ChangeDetails();
var prevMaskState = prevMask === null || prevMask === void 0 ? void 0 : prevMask.state;
return details;
}
_applyDispatch() {
let appended = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
const inputValue = this.rawInputValue;
const insertValue = flags.tail && flags._beforeTailState != null ?
// $FlowFixMe - tired to fight with type system
flags._beforeTailState._rawInputValue : inputValue;
const tailValue = inputValue.slice(insertValue.length);
const prevMask = this.currentMask;
const details = new ChangeDetails();
const prevMaskState = prevMask === null || prevMask === void 0 ? void 0 : prevMask.state;
// clone flags to prevent overwriting `_beforeTailState`
this.currentMask = this.doDispatch(appended, Object.assign({}, flags));
// clone flags to prevent overwriting `_beforeTailState`
this.currentMask = this.doDispatch(appended, Object.assign({}, flags));
// restore state after dispatch
if (this.currentMask) {
if (this.currentMask !== prevMask) {
// if mask changed reapply input
this.currentMask.reset();
if (insertValue) {
// $FlowFixMe - it's ok, we don't change current mask above
var d = this.currentMask.append(insertValue, {
raw: true
});
details.tailShift = d.inserted.length - prevValueBeforeTail.length;
}
if (tailValue) {
// $FlowFixMe - it's ok, we don't change current mask above
details.tailShift += this.currentMask.append(tailValue, {
raw: true,
tail: true
}).tailShift;
}
} else {
// Dispatch can do something bad with state, so
// restore prev mask state
this.currentMask.state = prevMaskState;
// restore state after dispatch
if (this.currentMask) {
if (this.currentMask !== prevMask) {
// if mask changed reapply input
this.currentMask.reset();
if (insertValue) {
// $FlowFixMe - it's ok, we don't change current mask above
const d = this.currentMask.append(insertValue, {
raw: true
});
details.tailShift = d.inserted.length - prevValueBeforeTail.length;
}
if (tailValue) {
// $FlowFixMe - it's ok, we don't change current mask above
details.tailShift += this.currentMask.append(tailValue, {
raw: true,
tail: true
}).tailShift;
}
} else {
// Dispatch can do something bad with state, so
// restore prev mask state
this.currentMask.state = prevMaskState;
}
return details;
}
}, {
key: "_appendPlaceholder",
value: function _appendPlaceholder() {
var details = this._applyDispatch.apply(this, arguments);
if (this.currentMask) {
details.aggregate(this.currentMask._appendPlaceholder());
}
return details;
return details;
}
_appendPlaceholder() {
const details = this._applyDispatch(...arguments);
if (this.currentMask) {
details.aggregate(this.currentMask._appendPlaceholder());
}
return details;
}
/**
@override
*/
}, {
key: "_appendEager",
value: function _appendEager() {
var details = this._applyDispatch.apply(this, arguments);
if (this.currentMask) {
details.aggregate(this.currentMask._appendEager());
}
return details;
/**
@override
*/
_appendEager() {
const details = this._applyDispatch(...arguments);
if (this.currentMask) {
details.aggregate(this.currentMask._appendEager());
}
}, {
key: "currentMaskFlags",
value: function currentMaskFlags(flags) {
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
return Object.assign({}, flags, {
_beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) === null || _flags$_beforeTailSta2 === void 0 ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
});
}
return details;
}
currentMaskFlags(flags) {
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
return Object.assign({}, flags, {
_beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) === null || _flags$_beforeTailSta2 === void 0 ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
});
}
/**
@override
*/
}, {
key: "doDispatch",
value: function doDispatch(appended) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return this.dispatch(appended, this, flags);
}
/**
@override
*/
doDispatch(appended) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return this.dispatch(appended, this, flags);
}
/**
@override
*/
}, {
key: "doValidate",
value: function doValidate(flags) {
return _get(_getPrototypeOf(MaskedDynamic.prototype), "doValidate", this).call(this, flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
}
/**
@override
*/
doValidate(flags) {
return super.doValidate(flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
}
/**
@override
*/
}, {
key: "doPrepare",
value: function doPrepare(str) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _normalizePrepare = normalizePrepare(_get(_getPrototypeOf(MaskedDynamic.prototype), "doPrepare", this).call(this, str, flags)),
_normalizePrepare2 = _slicedToArray(_normalizePrepare, 2),
s = _normalizePrepare2[0],
details = _normalizePrepare2[1];
if (this.currentMask) {
var currentDetails;
var _normalizePrepare3 = normalizePrepare(_get(_getPrototypeOf(MaskedDynamic.prototype), "doPrepare", this).call(this, s, this.currentMaskFlags(flags)));
var _normalizePrepare4 = _slicedToArray(_normalizePrepare3, 2);
s = _normalizePrepare4[0];
currentDetails = _normalizePrepare4[1];
details = details.aggregate(currentDetails);
}
return [s, details];
/**
@override
*/
doPrepare(str) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let [s, details] = normalizePrepare(super.doPrepare(str, flags));
if (this.currentMask) {
let currentDetails;
[s, currentDetails] = normalizePrepare(super.doPrepare(s, this.currentMaskFlags(flags)));
details = details.aggregate(currentDetails);
}
return [s, details];
}
/**
@override
*/
}, {
key: "reset",
value: function reset() {
var _this$currentMask;
(_this$currentMask = this.currentMask) === null || _this$currentMask === void 0 ? void 0 : _this$currentMask.reset();
this.compiledMasks.forEach(function (m) {
return m.reset();
});
}
/**
@override
*/
reset() {
var _this$currentMask;
(_this$currentMask = this.currentMask) === null || _this$currentMask === void 0 ? void 0 : _this$currentMask.reset();
this.compiledMasks.forEach(m => m.reset());
}
/**
@override
*/
}, {
key: "value",
get: function get() {
return this.currentMask ? this.currentMask.value : '';
},
set: function set(value) {
_set(_getPrototypeOf(MaskedDynamic.prototype), "value", value, this, true);
}
/**
@override
*/
get value() {
return this.currentMask ? this.currentMask.value : '';
}
set value(value) {
super.value = value;
}
/**
@override
*/
}, {
key: "unmaskedValue",
get: function get() {
return this.currentMask ? this.currentMask.unmaskedValue : '';
},
set: function set(unmaskedValue) {
_set(_getPrototypeOf(MaskedDynamic.prototype), "unmaskedValue", unmaskedValue, this, true);
}
/**
@override
*/
get unmaskedValue() {
return this.currentMask ? this.currentMask.unmaskedValue : '';
}
set unmaskedValue(unmaskedValue) {
super.unmaskedValue = unmaskedValue;
}
/**
@override
*/
}, {
key: "typedValue",
get: function get() {
return this.currentMask ? this.currentMask.typedValue : '';
}
/**
@override
*/
get typedValue() {
return this.currentMask ? this.currentMask.typedValue : '';
}
// probably typedValue should not be used with dynamic
,
set: function set(value) {
var unmaskedValue = String(value);
// probably typedValue should not be used with dynamic
set typedValue(value) {
let unmaskedValue = String(value);
// double check it
if (this.currentMask) {
this.currentMask.typedValue = value;
unmaskedValue = this.currentMask.unmaskedValue;
}
this.unmaskedValue = unmaskedValue;
// double check it
if (this.currentMask) {
this.currentMask.typedValue = value;
unmaskedValue = this.currentMask.unmaskedValue;
}
this.unmaskedValue = unmaskedValue;
}
/**
@override
*/
}, {
key: "isComplete",
get: function get() {
var _this$currentMask2;
return Boolean((_this$currentMask2 = this.currentMask) === null || _this$currentMask2 === void 0 ? void 0 : _this$currentMask2.isComplete);
}
/**
@override
*/
get isComplete() {
var _this$currentMask2;
return Boolean((_this$currentMask2 = this.currentMask) === null || _this$currentMask2 === void 0 ? void 0 : _this$currentMask2.isComplete);
}
/**
@override
*/
}, {
key: "isFilled",
get: function get() {
var _this$currentMask3;
return Boolean((_this$currentMask3 = this.currentMask) === null || _this$currentMask3 === void 0 ? void 0 : _this$currentMask3.isFilled);
}
/**
@override
*/
get isFilled() {
var _this$currentMask3;
return Boolean((_this$currentMask3 = this.currentMask) === null || _this$currentMask3 === void 0 ? void 0 : _this$currentMask3.isFilled);
}
/**
@override
*/
}, {
key: "remove",
value: function remove() {
var details = new ChangeDetails();
if (this.currentMask) {
var _this$currentMask4;
details.aggregate((_this$currentMask4 = this.currentMask).remove.apply(_this$currentMask4, arguments))
// update with dispatch
.aggregate(this._applyDispatch());
}
return details;
/**
@override
*/
remove() {
const details = new ChangeDetails();
if (this.currentMask) {
details.aggregate(this.currentMask.remove(...arguments))
// update with dispatch
.aggregate(this._applyDispatch());
}
return details;
}
/**
@override
*/
}, {
key: "state",
get: function get() {
var _this$currentMask5;
return Object.assign({}, _get(_getPrototypeOf(MaskedDynamic.prototype), "state", this), {
_rawInputValue: this.rawInputValue,
compiledMasks: this.compiledMasks.map(function (m) {
return m.state;
}),
currentMaskRef: this.currentMask,
currentMask: (_this$currentMask5 = this.currentMask) === null || _this$currentMask5 === void 0 ? void 0 : _this$currentMask5.state
});
},
set: function set(state) {
var compiledMasks = state.compiledMasks,
currentMaskRef = state.currentMaskRef,
currentMask = state.currentMask,
maskedState = _objectWithoutProperties(state, _excluded);
this.compiledMasks.forEach(function (m, mi) {
return m.state = compiledMasks[mi];
});
if (currentMaskRef != null) {
this.currentMask = currentMaskRef;
this.currentMask.state = currentMask;
}
_set(_getPrototypeOf(MaskedDynamic.prototype), "state", maskedState, this, true);
/**
@override
*/
get state() {
var _this$currentMask4;
return Object.assign({}, super.state, {
_rawInputValue: this.rawInputValue,
compiledMasks: this.compiledMasks.map(m => m.state),
currentMaskRef: this.currentMask,
currentMask: (_this$currentMask4 = this.currentMask) === null || _this$currentMask4 === void 0 ? void 0 : _this$currentMask4.state
});
}
set state(state) {
const {
compiledMasks,
currentMaskRef,
currentMask
} = state,
maskedState = _objectWithoutPropertiesLoose(state, _excluded);
this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
if (currentMaskRef != null) {
this.currentMask = currentMaskRef;
this.currentMask.state = currentMask;
}
super.state = maskedState;
}
/**
@override
*/
}, {
key: "extractInput",
value: function extractInput() {
var _this$currentMask6;
return this.currentMask ? (_this$currentMask6 = this.currentMask).extractInput.apply(_this$currentMask6, arguments) : '';
}
/**
@override
*/
extractInput() {
return this.currentMask ? this.currentMask.extractInput(...arguments) : '';
}
/**
@override
*/
}, {
key: "extractTail",
value: function extractTail() {
var _this$currentMask7, _get2;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return this.currentMask ? (_this$currentMask7 = this.currentMask).extractTail.apply(_this$currentMask7, args) : (_get2 = _get(_getPrototypeOf(MaskedDynamic.prototype), "extractTail", this)).call.apply(_get2, [this].concat(args));
}
/**
@override
*/
extractTail() {
return this.currentMask ? this.currentMask.extractTail(...arguments) : super.extractTail(...arguments);
}
/**
@override
*/
}, {
key: "doCommit",
value: function doCommit() {
if (this.currentMask) this.currentMask.doCommit();
_get(_getPrototypeOf(MaskedDynamic.prototype), "doCommit", this).call(this);
}
/**
@override
*/
doCommit() {
if (this.currentMask) this.currentMask.doCommit();
super.doCommit();
}
/**
@override
*/
}, {
key: "nearestInputPos",
value: function nearestInputPos() {
var _this$currentMask8, _get3;
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return this.currentMask ? (_this$currentMask8 = this.currentMask).nearestInputPos.apply(_this$currentMask8, args) : (_get3 = _get(_getPrototypeOf(MaskedDynamic.prototype), "nearestInputPos", this)).call.apply(_get3, [this].concat(args));
}
}, {
key: "overwrite",
get: function get() {
return this.currentMask ? this.currentMask.overwrite : _get(_getPrototypeOf(MaskedDynamic.prototype), "overwrite", this);
},
set: function set(overwrite) {
console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings');
}
}, {
key: "eager",
get: function get() {
return this.currentMask ? this.currentMask.eager : _get(_getPrototypeOf(MaskedDynamic.prototype), "eager", this);
},
set: function set(eager) {
console.warn('"eager" option is not available in dynamic mask, use this option in siblings');
}
}, {
key: "skipInvalid",
get: function get() {
return this.currentMask ? this.currentMask.skipInvalid : _get(_getPrototypeOf(MaskedDynamic.prototype), "skipInvalid", this);
},
set: function set(skipInvalid) {
console.warn('"skipInvalid" option is not available in dynamic mask, use this option in siblings');
}
/**
@override
*/
nearestInputPos() {
return this.currentMask ? this.currentMask.nearestInputPos(...arguments) : super.nearestInputPos(...arguments);
}
get overwrite() {
return this.currentMask ? this.currentMask.overwrite : super.overwrite;
}
set overwrite(overwrite) {
console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings');
}
get eager() {
return this.currentMask ? this.currentMask.eager : super.eager;
}
set eager(eager) {
console.warn('"eager" option is not available in dynamic mask, use this option in siblings');
}
get skipInvalid() {
return this.currentMask ? this.currentMask.skipInvalid : super.skipInvalid;
}
set skipInvalid(skipInvalid) {
console.warn('"skipInvalid" option is not available in dynamic mask, use this option in siblings');
}
/**
@override
*/
}, {
key: "maskEquals",
value: function maskEquals(mask) {
return Array.isArray(mask) && this.compiledMasks.every(function (m, mi) {
var _mask$mi;
return m.maskEquals((_mask$mi = mask[mi]) === null || _mask$mi === void 0 ? void 0 : _mask$mi.mask);
});
}
/**
@override
*/
maskEquals(mask) {
return Array.isArray(mask) && this.compiledMasks.every((m, mi) => {
var _mask$mi;
return m.maskEquals((_mask$mi = mask[mi]) === null || _mask$mi === void 0 ? void 0 : _mask$mi.mask);
});
}
/**
@override
*/
}, {
key: "typedValueEquals",
value: function typedValueEquals(value) {
var _this$currentMask9;
return Boolean((_this$currentMask9 = this.currentMask) === null || _this$currentMask9 === void 0 ? void 0 : _this$currentMask9.typedValueEquals(value));
}
}]);
return MaskedDynamic;
}(Masked);
/**
@override
*/
typedValueEquals(value) {
var _this$currentMask5;
return Boolean((_this$currentMask5 = this.currentMask) === null || _this$currentMask5 === void 0 ? void 0 : _this$currentMask5.typedValueEquals(value));
}
}
MaskedDynamic.DEFAULTS = {
dispatch: function dispatch(appended, masked, flags) {
dispatch: (appended, masked, flags) => {
if (!masked.compiledMasks.length) return;
var inputValue = masked.rawInputValue;
const inputValue = masked.rawInputValue;
// simulate input
var inputs = masked.compiledMasks.map(function (m, index) {
const inputs = masked.compiledMasks.map((m, index) => {
m.reset();

@@ -411,6 +329,6 @@ m.append(inputValue, {

m.append(appended, masked.currentMaskFlags(flags));
var weight = m.rawInputValue.length;
const weight = m.rawInputValue.length;
return {
weight: weight,
index: index
weight,
index
};

@@ -420,5 +338,3 @@ });

// pop masks with longer values first
inputs.sort(function (i1, i2) {
return i2.weight - i1.weight;
});
inputs.sort((i1, i2) => i2.weight - i1.weight);
return masked.compiledMasks[inputs[0].index];

@@ -425,0 +341,0 @@ }

@@ -1,4 +0,4 @@

import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck, g as _get, h as _getPrototypeOf } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import MaskedPattern from './pattern.js';
import IMask from '../core/holder.js';
import '../_rollupPluginBabelHelpers-6b3bd404.js';
import '../core/utils.js';

@@ -16,42 +16,22 @@ import '../core/change-details.js';

/** Pattern which validates enum values */
var MaskedEnum = /*#__PURE__*/function (_MaskedPattern) {
_inherits(MaskedEnum, _MaskedPattern);
var _super = _createSuper(MaskedEnum);
function MaskedEnum() {
_classCallCheck(this, MaskedEnum);
return _super.apply(this, arguments);
class MaskedEnum extends MaskedPattern {
/**
@override
@param {Object} opts
*/
_update(opts) {
// TODO type
if (opts.enum) opts.mask = '*'.repeat(opts.enum[0].length);
super._update(opts);
}
_createClass(MaskedEnum, [{
key: "_update",
value:
/**
@override
@param {Object} opts
*/
function _update(opts) {
// TODO type
if (opts.enum) opts.mask = '*'.repeat(opts.enum[0].length);
_get(_getPrototypeOf(MaskedEnum.prototype), "_update", this).call(this, opts);
}
/**
@override
*/
}, {
key: "doValidate",
value: function doValidate() {
var _this = this,
_get2;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return this.enum.some(function (e) {
return e.indexOf(_this.unmaskedValue) >= 0;
}) && (_get2 = _get(_getPrototypeOf(MaskedEnum.prototype), "doValidate", this)).call.apply(_get2, [this].concat(args));
}
}]);
return MaskedEnum;
}(MaskedPattern);
/**
@override
*/
doValidate() {
return this.enum.some(e => e.indexOf(this.unmaskedValue) >= 0) && super.doValidate(...arguments);
}
}
IMask.MaskedEnum = MaskedEnum;
export { MaskedEnum as default };
import { isString } from '../core/utils.js';
import IMask from '../core/holder.js';
import '../_rollupPluginBabelHelpers-30a49e9e.js';
import '../core/change-details.js';

@@ -38,7 +37,7 @@

opts = Object.assign({}, opts);
var mask = opts.mask;
const mask = opts.mask;
// $FlowFixMe
if (IMask.Masked && mask instanceof IMask.Masked) return mask;
var MaskedClass = maskedClass(mask);
const MaskedClass = maskedClass(mask);
if (!MaskedClass) throw new Error('Masked class is not found for provided mask, appropriate module needs to be import manually before creating mask.');

@@ -45,0 +44,0 @@ return new MaskedClass(opts);

@@ -1,2 +0,1 @@

import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck, g as _get, h as _getPrototypeOf } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import Masked from './base.js';

@@ -9,25 +8,14 @@ import IMask from '../core/holder.js';

/** Masking by custom Function */
var MaskedFunction = /*#__PURE__*/function (_Masked) {
_inherits(MaskedFunction, _Masked);
var _super = _createSuper(MaskedFunction);
function MaskedFunction() {
_classCallCheck(this, MaskedFunction);
return _super.apply(this, arguments);
class MaskedFunction extends Masked {
/**
@override
@param {Object} opts
*/
_update(opts) {
if (opts.mask) opts.validate = opts.mask;
super._update(opts);
}
_createClass(MaskedFunction, [{
key: "_update",
value:
/**
@override
@param {Object} opts
*/
function _update(opts) {
if (opts.mask) opts.validate = opts.mask;
_get(_getPrototypeOf(MaskedFunction.prototype), "_update", this).call(this, opts);
}
}]);
return MaskedFunction;
}(Masked);
}
IMask.MaskedFunction = MaskedFunction;
export { MaskedFunction as default };

@@ -1,2 +0,1 @@

import { j as _toConsumableArray, d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck, g as _get, h as _getPrototypeOf, f as _slicedToArray, i as _set } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import { escapeRegExp, normalizePrepare, DIRECTION } from '../core/utils.js';

@@ -21,5 +20,3 @@ import ChangeDetails from '../core/change-details.js';

*/
var MaskedNumber = /*#__PURE__*/function (_Masked) {
_inherits(MaskedNumber, _Masked);
var _super = _createSuper(MaskedNumber);
class MaskedNumber extends Masked {
/** Single char */

@@ -43,5 +40,4 @@

function MaskedNumber(opts) {
_classCallCheck(this, MaskedNumber);
return _super.call(this, Object.assign({}, MaskedNumber.DEFAULTS, opts));
constructor(opts) {
super(Object.assign({}, MaskedNumber.DEFAULTS, opts));
}

@@ -52,329 +48,279 @@

*/
_createClass(MaskedNumber, [{
key: "_update",
value: function _update(opts) {
_get(_getPrototypeOf(MaskedNumber.prototype), "_update", this).call(this, opts);
this._updateRegExps();
}
_update(opts) {
super._update(opts);
this._updateRegExps();
}
/** */
}, {
key: "_updateRegExps",
value: function _updateRegExps() {
var start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
var mid = '\\d*';
var end = (this.scale ? "(".concat(escapeRegExp(this.radix), "\\d{0,").concat(this.scale, "})?") : '') + '$';
this._numberRegExp = new RegExp(start + mid + end);
this._mapToRadixRegExp = new RegExp("[".concat(this.mapToRadix.map(escapeRegExp).join(''), "]"), 'g');
this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
}
/** */
_updateRegExps() {
let start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
let mid = '\\d*';
let end = (this.scale ? "(".concat(escapeRegExp(this.radix), "\\d{0,").concat(this.scale, "})?") : '') + '$';
this._numberRegExp = new RegExp(start + mid + end);
this._mapToRadixRegExp = new RegExp("[".concat(this.mapToRadix.map(escapeRegExp).join(''), "]"), 'g');
this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
}
/** */
}, {
key: "_removeThousandsSeparators",
value: function _removeThousandsSeparators(value) {
return value.replace(this._thousandsSeparatorRegExp, '');
}
/** */
_removeThousandsSeparators(value) {
return value.replace(this._thousandsSeparatorRegExp, '');
}
/** */
}, {
key: "_insertThousandsSeparators",
value: function _insertThousandsSeparators(value) {
// https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
var parts = value.split(this.radix);
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
return parts.join(this.radix);
}
/** */
_insertThousandsSeparators(value) {
// https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
const parts = value.split(this.radix);
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
return parts.join(this.radix);
}
/**
@override
/**
@override
*/
doPrepare(ch) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
ch = this._removeThousandsSeparators(this.scale && this.mapToRadix.length && (
/*
radix should be mapped when
1) input is done from keyboard = flags.input && flags.raw
2) unmasked value is set = !flags.input && !flags.raw
and should not be mapped when
1) value is set = flags.input && !flags.raw
2) raw value is set = !flags.input && flags.raw
*/
}, {
key: "doPrepare",
value: function doPrepare(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
ch = this._removeThousandsSeparators(this.scale && this.mapToRadix.length && flags.raw ? ch.replace(this._mapToRadixRegExp, this.radix) : ch);
var _normalizePrepare = normalizePrepare(_get(_getPrototypeOf(MaskedNumber.prototype), "doPrepare", this).call(this, ch, flags)),
_normalizePrepare2 = _slicedToArray(_normalizePrepare, 2),
prepCh = _normalizePrepare2[0],
details = _normalizePrepare2[1];
if (ch && !prepCh) details.skip = true;
return [prepCh, details];
}
flags.input && flags.raw || !flags.input && !flags.raw) ? ch.replace(this._mapToRadixRegExp, this.radix) : ch);
const [prepCh, details] = normalizePrepare(super.doPrepare(ch, flags));
if (ch && !prepCh) details.skip = true;
return [prepCh, details];
}
/** */
}, {
key: "_separatorsCount",
value: function _separatorsCount(to) {
var extendOnSeparators = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var count = 0;
for (var pos = 0; pos < to; ++pos) {
if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
++count;
if (extendOnSeparators) to += this.thousandsSeparator.length;
}
/** */
_separatorsCount(to) {
let extendOnSeparators = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
let count = 0;
for (let pos = 0; pos < to; ++pos) {
if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
++count;
if (extendOnSeparators) to += this.thousandsSeparator.length;
}
return count;
}
return count;
}
/** */
}, {
key: "_separatorsCountFromSlice",
value: function _separatorsCountFromSlice() {
var slice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._value;
return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
}
/** */
_separatorsCountFromSlice() {
let slice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._value;
return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
}
/**
@override
*/
}, {
key: "extractInput",
value: function extractInput() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
var flags = arguments.length > 2 ? arguments[2] : undefined;
var _this$_adjustRangeWit = this._adjustRangeWithSeparators(fromPos, toPos);
var _this$_adjustRangeWit2 = _slicedToArray(_this$_adjustRangeWit, 2);
fromPos = _this$_adjustRangeWit2[0];
toPos = _this$_adjustRangeWit2[1];
return this._removeThousandsSeparators(_get(_getPrototypeOf(MaskedNumber.prototype), "extractInput", this).call(this, fromPos, toPos, flags));
}
/**
@override
*/
extractInput() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
let flags = arguments.length > 2 ? arguments[2] : undefined;
[fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
return this._removeThousandsSeparators(super.extractInput(fromPos, toPos, flags));
}
/**
@override
*/
}, {
key: "_appendCharRaw",
value: function _appendCharRaw(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!this.thousandsSeparator) return _get(_getPrototypeOf(MaskedNumber.prototype), "_appendCharRaw", this).call(this, ch, flags);
var prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
var prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
this._value = this._removeThousandsSeparators(this.value);
var appendDetails = _get(_getPrototypeOf(MaskedNumber.prototype), "_appendCharRaw", this).call(this, ch, flags);
this._value = this._insertThousandsSeparators(this._value);
var beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
var beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
return appendDetails;
}
/**
@override
*/
_appendCharRaw(ch) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!this.thousandsSeparator) return super._appendCharRaw(ch, flags);
const prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
this._value = this._removeThousandsSeparators(this.value);
const appendDetails = super._appendCharRaw(ch, flags);
this._value = this._insertThousandsSeparators(this._value);
const beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
return appendDetails;
}
/** */
}, {
key: "_findSeparatorAround",
value: function _findSeparatorAround(pos) {
if (this.thousandsSeparator) {
var searchFrom = pos - this.thousandsSeparator.length + 1;
var separatorPos = this.value.indexOf(this.thousandsSeparator, searchFrom);
if (separatorPos <= pos) return separatorPos;
}
return -1;
/** */
_findSeparatorAround(pos) {
if (this.thousandsSeparator) {
const searchFrom = pos - this.thousandsSeparator.length + 1;
const separatorPos = this.value.indexOf(this.thousandsSeparator, searchFrom);
if (separatorPos <= pos) return separatorPos;
}
}, {
key: "_adjustRangeWithSeparators",
value: function _adjustRangeWithSeparators(from, to) {
var separatorAroundFromPos = this._findSeparatorAround(from);
if (separatorAroundFromPos >= 0) from = separatorAroundFromPos;
var separatorAroundToPos = this._findSeparatorAround(to);
if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
return [from, to];
}
return -1;
}
_adjustRangeWithSeparators(from, to) {
const separatorAroundFromPos = this._findSeparatorAround(from);
if (separatorAroundFromPos >= 0) from = separatorAroundFromPos;
const separatorAroundToPos = this._findSeparatorAround(to);
if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
return [from, to];
}
/**
@override
*/
}, {
key: "remove",
value: function remove() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
var _this$_adjustRangeWit3 = this._adjustRangeWithSeparators(fromPos, toPos);
var _this$_adjustRangeWit4 = _slicedToArray(_this$_adjustRangeWit3, 2);
fromPos = _this$_adjustRangeWit4[0];
toPos = _this$_adjustRangeWit4[1];
var valueBeforePos = this.value.slice(0, fromPos);
var valueAfterPos = this.value.slice(toPos);
var prevBeforeTailSeparatorsCount = this._separatorsCount(valueBeforePos.length);
this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(valueBeforePos + valueAfterPos));
var beforeTailSeparatorsCount = this._separatorsCountFromSlice(valueBeforePos);
return new ChangeDetails({
tailShift: (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length
});
}
/**
@override
*/
remove() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
[fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
const valueBeforePos = this.value.slice(0, fromPos);
const valueAfterPos = this.value.slice(toPos);
const prevBeforeTailSeparatorsCount = this._separatorsCount(valueBeforePos.length);
this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(valueBeforePos + valueAfterPos));
const beforeTailSeparatorsCount = this._separatorsCountFromSlice(valueBeforePos);
return new ChangeDetails({
tailShift: (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length
});
}
/**
@override
*/
}, {
key: "nearestInputPos",
value: function nearestInputPos(cursorPos, direction) {
if (!this.thousandsSeparator) return cursorPos;
switch (direction) {
case DIRECTION.NONE:
case DIRECTION.LEFT:
case DIRECTION.FORCE_LEFT:
{
var separatorAtLeftPos = this._findSeparatorAround(cursorPos - 1);
if (separatorAtLeftPos >= 0) {
var separatorAtLeftEndPos = separatorAtLeftPos + this.thousandsSeparator.length;
if (cursorPos < separatorAtLeftEndPos || this.value.length <= separatorAtLeftEndPos || direction === DIRECTION.FORCE_LEFT) {
return separatorAtLeftPos;
}
/**
@override
*/
nearestInputPos(cursorPos, direction) {
if (!this.thousandsSeparator) return cursorPos;
switch (direction) {
case DIRECTION.NONE:
case DIRECTION.LEFT:
case DIRECTION.FORCE_LEFT:
{
const separatorAtLeftPos = this._findSeparatorAround(cursorPos - 1);
if (separatorAtLeftPos >= 0) {
const separatorAtLeftEndPos = separatorAtLeftPos + this.thousandsSeparator.length;
if (cursorPos < separatorAtLeftEndPos || this.value.length <= separatorAtLeftEndPos || direction === DIRECTION.FORCE_LEFT) {
return separatorAtLeftPos;
}
break;
}
case DIRECTION.RIGHT:
case DIRECTION.FORCE_RIGHT:
{
var separatorAtRightPos = this._findSeparatorAround(cursorPos);
if (separatorAtRightPos >= 0) {
return separatorAtRightPos + this.thousandsSeparator.length;
}
break;
}
case DIRECTION.RIGHT:
case DIRECTION.FORCE_RIGHT:
{
const separatorAtRightPos = this._findSeparatorAround(cursorPos);
if (separatorAtRightPos >= 0) {
return separatorAtRightPos + this.thousandsSeparator.length;
}
}
return cursorPos;
}
}
return cursorPos;
}
/**
@override
*/
}, {
key: "doValidate",
value: function doValidate(flags) {
// validate as string
var valid = Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));
if (valid) {
// validate as number
var number = this.number;
valid = valid && !isNaN(number) && (
// check min bound for negative values
this.min == null || this.min >= 0 || this.min <= this.number) && (
// check max bound for positive values
this.max == null || this.max <= 0 || this.number <= this.max);
}
return valid && _get(_getPrototypeOf(MaskedNumber.prototype), "doValidate", this).call(this, flags);
/**
@override
*/
doValidate(flags) {
// validate as string
let valid = Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));
if (valid) {
// validate as number
const number = this.number;
valid = valid && !isNaN(number) && (
// check min bound for negative values
this.min == null || this.min >= 0 || this.min <= this.number) && (
// check max bound for positive values
this.max == null || this.max <= 0 || this.number <= this.max);
}
return valid && super.doValidate(flags);
}
/**
@override
*/
}, {
key: "doCommit",
value: function doCommit() {
if (this.value) {
var number = this.number;
var validnum = number;
/**
@override
*/
doCommit() {
if (this.value) {
const number = this.number;
let validnum = number;
// check bounds
if (this.min != null) validnum = Math.max(validnum, this.min);
if (this.max != null) validnum = Math.min(validnum, this.max);
if (validnum !== number) this.unmaskedValue = this.doFormat(validnum);
var formatted = this.value;
if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
this._value = formatted;
}
_get(_getPrototypeOf(MaskedNumber.prototype), "doCommit", this).call(this);
// check bounds
if (this.min != null) validnum = Math.max(validnum, this.min);
if (this.max != null) validnum = Math.min(validnum, this.max);
if (validnum !== number) this.unmaskedValue = this.doFormat(validnum);
let formatted = this.value;
if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
this._value = formatted;
}
super.doCommit();
}
/** */
}, {
key: "_normalizeZeros",
value: function _normalizeZeros(value) {
var parts = this._removeThousandsSeparators(value).split(this.radix);
/** */
_normalizeZeros(value) {
const parts = this._removeThousandsSeparators(value).split(this.radix);
// remove leading zeros
parts[0] = parts[0].replace(/^(\D*)(0*)(\d*)/, function (match, sign, zeros, num) {
return sign + num;
});
// add leading zero
if (value.length && !/\d$/.test(parts[0])) parts[0] = parts[0] + '0';
if (parts.length > 1) {
parts[1] = parts[1].replace(/0*$/, ''); // remove trailing zeros
if (!parts[1].length) parts.length = 1; // remove fractional
}
return this._insertThousandsSeparators(parts.join(this.radix));
// remove leading zeros
parts[0] = parts[0].replace(/^(\D*)(0*)(\d*)/, (match, sign, zeros, num) => sign + num);
// add leading zero
if (value.length && !/\d$/.test(parts[0])) parts[0] = parts[0] + '0';
if (parts.length > 1) {
parts[1] = parts[1].replace(/0*$/, ''); // remove trailing zeros
if (!parts[1].length) parts.length = 1; // remove fractional
}
/** */
}, {
key: "_padFractionalZeros",
value: function _padFractionalZeros(value) {
if (!value) return value;
var parts = value.split(this.radix);
if (parts.length < 2) parts.push('');
parts[1] = parts[1].padEnd(this.scale, '0');
return parts.join(this.radix);
}
return this._insertThousandsSeparators(parts.join(this.radix));
}
/** */
}, {
key: "doSkipInvalid",
value: function doSkipInvalid(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var checkTail = arguments.length > 2 ? arguments[2] : undefined;
var dropFractional = this.scale === 0 && ch !== this.thousandsSeparator && (ch === this.radix || ch === MaskedNumber.UNMASKED_RADIX || this.mapToRadix.includes(ch));
return _get(_getPrototypeOf(MaskedNumber.prototype), "doSkipInvalid", this).call(this, ch, flags, checkTail) && !dropFractional;
}
/** */
_padFractionalZeros(value) {
if (!value) return value;
const parts = value.split(this.radix);
if (parts.length < 2) parts.push('');
parts[1] = parts[1].padEnd(this.scale, '0');
return parts.join(this.radix);
}
/**
@override
*/
}, {
key: "unmaskedValue",
get: function get() {
return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, MaskedNumber.UNMASKED_RADIX);
},
set: function set(unmaskedValue) {
_set(_getPrototypeOf(MaskedNumber.prototype), "unmaskedValue", unmaskedValue.replace(MaskedNumber.UNMASKED_RADIX, this.radix), this, true);
}
/** */
doSkipInvalid(ch) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let checkTail = arguments.length > 2 ? arguments[2] : undefined;
const dropFractional = this.scale === 0 && ch !== this.thousandsSeparator && (ch === this.radix || ch === MaskedNumber.UNMASKED_RADIX || this.mapToRadix.includes(ch));
return super.doSkipInvalid(ch, flags, checkTail) && !dropFractional;
}
/**
@override
*/
}, {
key: "typedValue",
get: function get() {
return this.doParse(this.unmaskedValue);
},
set: function set(n) {
this.rawInputValue = this.doFormat(n).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
}
/**
@override
*/
get unmaskedValue() {
return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, MaskedNumber.UNMASKED_RADIX);
}
set unmaskedValue(unmaskedValue) {
super.unmaskedValue = unmaskedValue;
}
/** Parsed Number */
}, {
key: "number",
get: function get() {
return this.typedValue;
},
set: function set(number) {
this.typedValue = number;
}
/**
@override
*/
get typedValue() {
return this.doParse(this.unmaskedValue);
}
set typedValue(n) {
this.rawInputValue = this.doFormat(n).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
}
/**
Is negative allowed
@readonly
*/
}, {
key: "allowNegative",
get: function get() {
return this.signed || this.min != null && this.min < 0 || this.max != null && this.max < 0;
}
/** Parsed Number */
get number() {
return this.typedValue;
}
set number(number) {
this.typedValue = number;
}
/**
@override
*/
}, {
key: "typedValueEquals",
value: function typedValueEquals(value) {
// handle 0 -> '' case (typed = 0 even if value = '')
// for details see https://github.com/uNmAnNeR/imaskjs/issues/134
return (_get(_getPrototypeOf(MaskedNumber.prototype), "typedValueEquals", this).call(this, value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
}
}]);
return MaskedNumber;
}(Masked);
/**
Is negative allowed
@readonly
*/
get allowNegative() {
return this.signed || this.min != null && this.min < 0 || this.max != null && this.max < 0;
}
/**
@override
*/
typedValueEquals(value) {
// handle 0 -> '' case (typed = 0 even if value = '')
// for details see https://github.com/uNmAnNeR/imaskjs/issues/134
return (super.typedValueEquals(value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
}
}
MaskedNumber.UNMASKED_RADIX = '.';

@@ -390,12 +336,10 @@ MaskedNumber.DEFAULTS = {

parse: Number,
format: function format(n) {
return n.toLocaleString('en-US', {
useGrouping: false,
maximumFractionDigits: 20
});
}
format: n => n.toLocaleString('en-US', {
useGrouping: false,
maximumFractionDigits: 20
})
};
MaskedNumber.EMPTY_VALUES = [].concat(_toConsumableArray(Masked.EMPTY_VALUES), [0]);
MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
IMask.MaskedNumber = MaskedNumber;
export { MaskedNumber as default };

@@ -1,2 +0,2 @@

import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck, g as _get, h as _getPrototypeOf, b as _objectWithoutProperties, i as _set } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import { _ as _objectWithoutPropertiesLoose } from '../_rollupPluginBabelHelpers-6b3bd404.js';
import { DIRECTION } from '../core/utils.js';

@@ -14,3 +14,4 @@ import ChangeDetails from '../core/change-details.js';

var _excluded = ["_blocks"];
const _excluded = ["_blocks"];
/**

@@ -24,5 +25,3 @@ Pattern mask

*/
var MaskedPattern = /*#__PURE__*/function (_Masked) {
_inherits(MaskedPattern, _Masked);
var _super = _createSuper(MaskedPattern);
class MaskedPattern extends Masked {
/** */

@@ -36,8 +35,7 @@

function MaskedPattern() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, MaskedPattern);
constructor() {
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// TODO type $Shape<MaskedPatternOptions>={} does not work
opts.definitions = Object.assign({}, DEFAULT_INPUT_DEFINITIONS, opts.definitions);
return _super.call(this, Object.assign({}, MaskedPattern.DEFAULTS, opts));
super(Object.assign({}, MaskedPattern.DEFAULTS, opts));
}

@@ -49,505 +47,410 @@

*/
_createClass(MaskedPattern, [{
key: "_update",
value: function _update() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
opts.definitions = Object.assign({}, this.definitions, opts.definitions);
_get(_getPrototypeOf(MaskedPattern.prototype), "_update", this).call(this, opts);
this._rebuildMask();
}
_update() {
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
opts.definitions = Object.assign({}, this.definitions, opts.definitions);
super._update(opts);
this._rebuildMask();
}
/** */
}, {
key: "_rebuildMask",
value: function _rebuildMask() {
var _this = this;
var defs = this.definitions;
this._blocks = [];
this._stops = [];
this._maskedBlocks = {};
var pattern = this.mask;
if (!pattern || !defs) return;
var unmaskingBlock = false;
var optionalBlock = false;
var _loop = function _loop(_i) {
if (_this.blocks) {
var p = pattern.slice(_i);
var bNames = Object.keys(_this.blocks).filter(function (bName) {
return p.indexOf(bName) === 0;
});
// order by key length
bNames.sort(function (a, b) {
return b.length - a.length;
});
// use block name with max length
var bName = bNames[0];
if (bName) {
// $FlowFixMe no ideas
var maskedBlock = createMask(Object.assign({
parent: _this,
lazy: _this.lazy,
eager: _this.eager,
placeholderChar: _this.placeholderChar,
overwrite: _this.overwrite
}, _this.blocks[bName]));
if (maskedBlock) {
_this._blocks.push(maskedBlock);
/** */
_rebuildMask() {
const defs = this.definitions;
this._blocks = [];
this._stops = [];
this._maskedBlocks = {};
let pattern = this.mask;
if (!pattern || !defs) return;
let unmaskingBlock = false;
let optionalBlock = false;
for (let i = 0; i < pattern.length; ++i) {
if (this.blocks) {
const p = pattern.slice(i);
const bNames = Object.keys(this.blocks).filter(bName => p.indexOf(bName) === 0);
// order by key length
bNames.sort((a, b) => b.length - a.length);
// use block name with max length
const bName = bNames[0];
if (bName) {
// $FlowFixMe no ideas
const maskedBlock = createMask(Object.assign({
parent: this,
lazy: this.lazy,
eager: this.eager,
placeholderChar: this.placeholderChar,
overwrite: this.overwrite
}, this.blocks[bName]));
if (maskedBlock) {
this._blocks.push(maskedBlock);
// store block index
if (!_this._maskedBlocks[bName]) _this._maskedBlocks[bName] = [];
_this._maskedBlocks[bName].push(_this._blocks.length - 1);
}
_i += bName.length - 1;
i = _i;
return "continue";
// store block index
if (!this._maskedBlocks[bName]) this._maskedBlocks[bName] = [];
this._maskedBlocks[bName].push(this._blocks.length - 1);
}
i += bName.length - 1;
continue;
}
var char = pattern[_i];
var isInput = (char in defs);
if (char === MaskedPattern.STOP_CHAR) {
_this._stops.push(_this._blocks.length);
i = _i;
return "continue";
}
if (char === '{' || char === '}') {
unmaskingBlock = !unmaskingBlock;
i = _i;
return "continue";
}
if (char === '[' || char === ']') {
optionalBlock = !optionalBlock;
i = _i;
return "continue";
}
if (char === MaskedPattern.ESCAPE_CHAR) {
++_i;
char = pattern[_i];
if (!char) {
i = _i;
return "break";
}
isInput = false;
}
var def = isInput ? new PatternInputDefinition({
parent: _this,
lazy: _this.lazy,
eager: _this.eager,
placeholderChar: _this.placeholderChar,
mask: defs[char],
isOptional: optionalBlock
}) : new PatternFixedDefinition({
char: char,
eager: _this.eager,
isUnmasking: unmaskingBlock
});
_this._blocks.push(def);
i = _i;
};
for (var i = 0; i < pattern.length; ++i) {
var _ret = _loop(i);
if (_ret === "continue") continue;
if (_ret === "break") break;
}
}
/**
@override
*/
}, {
key: "state",
get: function get() {
return Object.assign({}, _get(_getPrototypeOf(MaskedPattern.prototype), "state", this), {
_blocks: this._blocks.map(function (b) {
return b.state;
})
let char = pattern[i];
let isInput = (char in defs);
if (char === MaskedPattern.STOP_CHAR) {
this._stops.push(this._blocks.length);
continue;
}
if (char === '{' || char === '}') {
unmaskingBlock = !unmaskingBlock;
continue;
}
if (char === '[' || char === ']') {
optionalBlock = !optionalBlock;
continue;
}
if (char === MaskedPattern.ESCAPE_CHAR) {
++i;
char = pattern[i];
if (!char) break;
isInput = false;
}
const def = isInput ? new PatternInputDefinition({
parent: this,
lazy: this.lazy,
eager: this.eager,
placeholderChar: this.placeholderChar,
mask: defs[char],
isOptional: optionalBlock
}) : new PatternFixedDefinition({
char,
eager: this.eager,
isUnmasking: unmaskingBlock
});
},
set: function set(state) {
var _blocks = state._blocks,
maskedState = _objectWithoutProperties(state, _excluded);
this._blocks.forEach(function (b, bi) {
return b.state = _blocks[bi];
});
_set(_getPrototypeOf(MaskedPattern.prototype), "state", maskedState, this, true);
this._blocks.push(def);
}
}
/**
@override
*/
}, {
key: "reset",
value: function reset() {
_get(_getPrototypeOf(MaskedPattern.prototype), "reset", this).call(this);
this._blocks.forEach(function (b) {
return b.reset();
});
}
/**
@override
*/
get state() {
return Object.assign({}, super.state, {
_blocks: this._blocks.map(b => b.state)
});
}
set state(state) {
const {
_blocks
} = state,
maskedState = _objectWithoutPropertiesLoose(state, _excluded);
this._blocks.forEach((b, bi) => b.state = _blocks[bi]);
super.state = maskedState;
}
/**
@override
*/
}, {
key: "isComplete",
get: function get() {
return this._blocks.every(function (b) {
return b.isComplete;
});
}
/**
@override
*/
reset() {
super.reset();
this._blocks.forEach(b => b.reset());
}
/**
@override
*/
}, {
key: "isFilled",
get: function get() {
return this._blocks.every(function (b) {
return b.isFilled;
});
}
}, {
key: "isFixed",
get: function get() {
return this._blocks.every(function (b) {
return b.isFixed;
});
}
}, {
key: "isOptional",
get: function get() {
return this._blocks.every(function (b) {
return b.isOptional;
});
}
/**
@override
*/
get isComplete() {
return this._blocks.every(b => b.isComplete);
}
/**
@override
*/
}, {
key: "doCommit",
value: function doCommit() {
this._blocks.forEach(function (b) {
return b.doCommit();
});
_get(_getPrototypeOf(MaskedPattern.prototype), "doCommit", this).call(this);
}
/**
@override
*/
get isFilled() {
return this._blocks.every(b => b.isFilled);
}
get isFixed() {
return this._blocks.every(b => b.isFixed);
}
get isOptional() {
return this._blocks.every(b => b.isOptional);
}
/**
@override
*/
}, {
key: "unmaskedValue",
get: function get() {
return this._blocks.reduce(function (str, b) {
return str += b.unmaskedValue;
}, '');
},
set: function set(unmaskedValue) {
_set(_getPrototypeOf(MaskedPattern.prototype), "unmaskedValue", unmaskedValue, this, true);
}
/**
@override
*/
doCommit() {
this._blocks.forEach(b => b.doCommit());
super.doCommit();
}
/**
@override
*/
}, {
key: "value",
get: function get() {
// TODO return _value when not in change?
return this._blocks.reduce(function (str, b) {
return str += b.value;
}, '');
},
set: function set(value) {
_set(_getPrototypeOf(MaskedPattern.prototype), "value", value, this, true);
}
/**
@override
*/
get unmaskedValue() {
return this._blocks.reduce((str, b) => str += b.unmaskedValue, '');
}
set unmaskedValue(unmaskedValue) {
super.unmaskedValue = unmaskedValue;
}
/**
@override
*/
}, {
key: "appendTail",
value: function appendTail(tail) {
return _get(_getPrototypeOf(MaskedPattern.prototype), "appendTail", this).call(this, tail).aggregate(this._appendPlaceholder());
}
/**
@override
*/
get value() {
// TODO return _value when not in change?
return this._blocks.reduce((str, b) => str += b.value, '');
}
set value(value) {
super.value = value;
}
/**
@override
*/
}, {
key: "_appendEager",
value: function _appendEager() {
var _this$_mapPosToBlock;
var details = new ChangeDetails();
var startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.value.length)) === null || _this$_mapPosToBlock === void 0 ? void 0 : _this$_mapPosToBlock.index;
if (startBlockIndex == null) return details;
/**
@override
*/
appendTail(tail) {
return super.appendTail(tail).aggregate(this._appendPlaceholder());
}
// TODO test if it works for nested pattern masks
if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
for (var bi = startBlockIndex; bi < this._blocks.length; ++bi) {
var d = this._blocks[bi]._appendEager();
if (!d.inserted) break;
details.aggregate(d);
}
return details;
}
/**
@override
*/
_appendEager() {
var _this$_mapPosToBlock;
const details = new ChangeDetails();
let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.value.length)) === null || _this$_mapPosToBlock === void 0 ? void 0 : _this$_mapPosToBlock.index;
if (startBlockIndex == null) return details;
/**
@override
*/
}, {
key: "_appendCharRaw",
value: function _appendCharRaw(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var blockIter = this._mapPosToBlock(this.value.length);
var details = new ChangeDetails();
if (!blockIter) return details;
for (var bi = blockIter.index;; ++bi) {
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
var _block = this._blocks[bi];
if (!_block) break;
var blockDetails = _block._appendChar(ch, Object.assign({}, flags, {
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : (_flags$_beforeTailSta2 = _flags$_beforeTailSta._blocks) === null || _flags$_beforeTailSta2 === void 0 ? void 0 : _flags$_beforeTailSta2[bi]
}));
var skip = blockDetails.skip;
details.aggregate(blockDetails);
if (skip || blockDetails.rawInserted) break; // go next char
}
return details;
// TODO test if it works for nested pattern masks
if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
for (let bi = startBlockIndex; bi < this._blocks.length; ++bi) {
const d = this._blocks[bi]._appendEager();
if (!d.inserted) break;
details.aggregate(d);
}
return details;
}
/**
@override
*/
}, {
key: "extractTail",
value: function extractTail() {
var _this2 = this;
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
var chunkTail = new ChunksTailDetails();
if (fromPos === toPos) return chunkTail;
this._forEachBlocksInRange(fromPos, toPos, function (b, bi, bFromPos, bToPos) {
var blockChunk = b.extractTail(bFromPos, bToPos);
blockChunk.stop = _this2._findStopBefore(bi);
blockChunk.from = _this2._blockStartPos(bi);
if (blockChunk instanceof ChunksTailDetails) blockChunk.blockIndex = bi;
chunkTail.extend(blockChunk);
});
return chunkTail;
/**
@override
*/
_appendCharRaw(ch) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const blockIter = this._mapPosToBlock(this.value.length);
const details = new ChangeDetails();
if (!blockIter) return details;
for (let bi = blockIter.index;; ++bi) {
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
const block = this._blocks[bi];
if (!block) break;
const blockDetails = block._appendChar(ch, Object.assign({}, flags, {
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : (_flags$_beforeTailSta2 = _flags$_beforeTailSta._blocks) === null || _flags$_beforeTailSta2 === void 0 ? void 0 : _flags$_beforeTailSta2[bi]
}));
const skip = blockDetails.skip;
details.aggregate(blockDetails);
if (skip || blockDetails.rawInserted) break; // go next char
}
/**
@override
*/
}, {
key: "extractInput",
value: function extractInput() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
var flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (fromPos === toPos) return '';
var input = '';
this._forEachBlocksInRange(fromPos, toPos, function (b, _, fromPos, toPos) {
input += b.extractInput(fromPos, toPos, flags);
});
return input;
}
}, {
key: "_findStopBefore",
value: function _findStopBefore(blockIndex) {
var stopBefore;
for (var si = 0; si < this._stops.length; ++si) {
var stop = this._stops[si];
if (stop <= blockIndex) stopBefore = stop;else break;
}
return stopBefore;
}
return details;
}
/** Appends placeholder depending on laziness */
}, {
key: "_appendPlaceholder",
value: function _appendPlaceholder(toBlockIndex) {
var _this3 = this;
var details = new ChangeDetails();
if (this.lazy && toBlockIndex == null) return details;
var startBlockIter = this._mapPosToBlock(this.value.length);
if (!startBlockIter) return details;
var startBlockIndex = startBlockIter.index;
var endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
this._blocks.slice(startBlockIndex, endBlockIndex).forEach(function (b) {
if (!b.lazy || toBlockIndex != null) {
// $FlowFixMe `_blocks` may not be present
var args = b._blocks != null ? [b._blocks.length] : [];
var bDetails = b._appendPlaceholder.apply(b, args);
_this3._value += bDetails.inserted;
details.aggregate(bDetails);
}
});
return details;
/**
@override
*/
extractTail() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
const chunkTail = new ChunksTailDetails();
if (fromPos === toPos) return chunkTail;
this._forEachBlocksInRange(fromPos, toPos, (b, bi, bFromPos, bToPos) => {
const blockChunk = b.extractTail(bFromPos, bToPos);
blockChunk.stop = this._findStopBefore(bi);
blockChunk.from = this._blockStartPos(bi);
if (blockChunk instanceof ChunksTailDetails) blockChunk.blockIndex = bi;
chunkTail.extend(blockChunk);
});
return chunkTail;
}
/**
@override
*/
extractInput() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
let flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (fromPos === toPos) return '';
let input = '';
this._forEachBlocksInRange(fromPos, toPos, (b, _, fromPos, toPos) => {
input += b.extractInput(fromPos, toPos, flags);
});
return input;
}
_findStopBefore(blockIndex) {
let stopBefore;
for (let si = 0; si < this._stops.length; ++si) {
const stop = this._stops[si];
if (stop <= blockIndex) stopBefore = stop;else break;
}
return stopBefore;
}
/** Finds block in pos */
}, {
key: "_mapPosToBlock",
value: function _mapPosToBlock(pos) {
var accVal = '';
for (var bi = 0; bi < this._blocks.length; ++bi) {
var _block2 = this._blocks[bi];
var blockStartPos = accVal.length;
accVal += _block2.value;
if (pos <= accVal.length) {
return {
index: bi,
offset: pos - blockStartPos
};
}
/** Appends placeholder depending on laziness */
_appendPlaceholder(toBlockIndex) {
const details = new ChangeDetails();
if (this.lazy && toBlockIndex == null) return details;
const startBlockIter = this._mapPosToBlock(this.value.length);
if (!startBlockIter) return details;
const startBlockIndex = startBlockIter.index;
const endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
this._blocks.slice(startBlockIndex, endBlockIndex).forEach(b => {
if (!b.lazy || toBlockIndex != null) {
// $FlowFixMe `_blocks` may not be present
const args = b._blocks != null ? [b._blocks.length] : [];
const bDetails = b._appendPlaceholder(...args);
this._value += bDetails.inserted;
details.aggregate(bDetails);
}
}
});
return details;
}
/** */
}, {
key: "_blockStartPos",
value: function _blockStartPos(blockIndex) {
return this._blocks.slice(0, blockIndex).reduce(function (pos, b) {
return pos += b.value.length;
}, 0);
/** Finds block in pos */
_mapPosToBlock(pos) {
let accVal = '';
for (let bi = 0; bi < this._blocks.length; ++bi) {
const block = this._blocks[bi];
const blockStartPos = accVal.length;
accVal += block.value;
if (pos <= accVal.length) {
return {
index: bi,
offset: pos - blockStartPos
};
}
}
}
/** */
}, {
key: "_forEachBlocksInRange",
value: function _forEachBlocksInRange(fromPos) {
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
var fn = arguments.length > 2 ? arguments[2] : undefined;
var fromBlockIter = this._mapPosToBlock(fromPos);
if (fromBlockIter) {
var toBlockIter = this._mapPosToBlock(toPos);
// process first block
var isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;
var fromBlockStartPos = fromBlockIter.offset;
var fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].value.length;
fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);
if (toBlockIter && !isSameBlock) {
// process intermediate blocks
for (var bi = fromBlockIter.index + 1; bi < toBlockIter.index; ++bi) {
fn(this._blocks[bi], bi, 0, this._blocks[bi].value.length);
}
/** */
_blockStartPos(blockIndex) {
return this._blocks.slice(0, blockIndex).reduce((pos, b) => pos += b.value.length, 0);
}
// process last block
fn(this._blocks[toBlockIter.index], toBlockIter.index, 0, toBlockIter.offset);
/** */
_forEachBlocksInRange(fromPos) {
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
let fn = arguments.length > 2 ? arguments[2] : undefined;
const fromBlockIter = this._mapPosToBlock(fromPos);
if (fromBlockIter) {
const toBlockIter = this._mapPosToBlock(toPos);
// process first block
const isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;
const fromBlockStartPos = fromBlockIter.offset;
const fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].value.length;
fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);
if (toBlockIter && !isSameBlock) {
// process intermediate blocks
for (let bi = fromBlockIter.index + 1; bi < toBlockIter.index; ++bi) {
fn(this._blocks[bi], bi, 0, this._blocks[bi].value.length);
}
// process last block
fn(this._blocks[toBlockIter.index], toBlockIter.index, 0, toBlockIter.offset);
}
}
}
/**
@override
*/
}, {
key: "remove",
value: function remove() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
var removeDetails = _get(_getPrototypeOf(MaskedPattern.prototype), "remove", this).call(this, fromPos, toPos);
this._forEachBlocksInRange(fromPos, toPos, function (b, _, bFromPos, bToPos) {
removeDetails.aggregate(b.remove(bFromPos, bToPos));
});
return removeDetails;
/**
@override
*/
remove() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
const removeDetails = super.remove(fromPos, toPos);
this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
removeDetails.aggregate(b.remove(bFromPos, bToPos));
});
return removeDetails;
}
/**
@override
*/
nearestInputPos(cursorPos) {
let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
if (!this._blocks.length) return 0;
const cursor = new PatternCursor(this, cursorPos);
if (direction === DIRECTION.NONE) {
// -------------------------------------------------
// NONE should only go out from fixed to the right!
// -------------------------------------------------
if (cursor.pushRightBeforeInput()) return cursor.pos;
cursor.popState();
if (cursor.pushLeftBeforeInput()) return cursor.pos;
return this.value.length;
}
/**
@override
*/
}, {
key: "nearestInputPos",
value: function nearestInputPos(cursorPos) {
var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
if (!this._blocks.length) return 0;
var cursor = new PatternCursor(this, cursorPos);
if (direction === DIRECTION.NONE) {
// -------------------------------------------------
// NONE should only go out from fixed to the right!
// -------------------------------------------------
if (cursor.pushRightBeforeInput()) return cursor.pos;
// FORCE is only about a|* otherwise is 0
if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
// try to break fast when *|a
if (direction === DIRECTION.LEFT) {
cursor.pushRightBeforeFilled();
if (cursor.ok && cursor.pos === cursorPos) return cursorPos;
cursor.popState();
if (cursor.pushLeftBeforeInput()) return cursor.pos;
return this.value.length;
}
// FORCE is only about a|* otherwise is 0
if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
// try to break fast when *|a
if (direction === DIRECTION.LEFT) {
cursor.pushRightBeforeFilled();
if (cursor.ok && cursor.pos === cursorPos) return cursorPos;
cursor.popState();
}
// forward flow
cursor.pushLeftBeforeInput();
cursor.pushLeftBeforeRequired();
cursor.pushLeftBeforeFilled();
// forward flow
cursor.pushLeftBeforeInput();
cursor.pushLeftBeforeRequired();
cursor.pushLeftBeforeFilled();
// backward flow
if (direction === DIRECTION.LEFT) {
cursor.pushRightBeforeInput();
cursor.pushRightBeforeRequired();
if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
cursor.popState();
if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
cursor.popState();
}
if (cursor.ok) return cursor.pos;
if (direction === DIRECTION.FORCE_LEFT) return 0;
cursor.popState();
if (cursor.ok) return cursor.pos;
cursor.popState();
if (cursor.ok) return cursor.pos;
// cursor.popState();
// if (
// cursor.pushRightBeforeInput() &&
// // TODO HACK for lazy if has aligned left inside fixed and has came to the start - use start position
// (!this.lazy || this.extractInput())
// ) return cursor.pos;
return 0;
}
if (direction === DIRECTION.RIGHT || direction === DIRECTION.FORCE_RIGHT) {
// forward flow
// backward flow
if (direction === DIRECTION.LEFT) {
cursor.pushRightBeforeInput();
cursor.pushRightBeforeRequired();
if (cursor.pushRightBeforeFilled()) return cursor.pos;
if (direction === DIRECTION.FORCE_RIGHT) return this.value.length;
// backward flow
if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
cursor.popState();
if (cursor.ok) return cursor.pos;
if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
cursor.popState();
if (cursor.ok) return cursor.pos;
return this.nearestInputPos(cursorPos, DIRECTION.LEFT);
}
return cursorPos;
if (cursor.ok) return cursor.pos;
if (direction === DIRECTION.FORCE_LEFT) return 0;
cursor.popState();
if (cursor.ok) return cursor.pos;
cursor.popState();
if (cursor.ok) return cursor.pos;
// cursor.popState();
// if (
// cursor.pushRightBeforeInput() &&
// // TODO HACK for lazy if has aligned left inside fixed and has came to the start - use start position
// (!this.lazy || this.extractInput())
// ) return cursor.pos;
return 0;
}
if (direction === DIRECTION.RIGHT || direction === DIRECTION.FORCE_RIGHT) {
// forward flow
cursor.pushRightBeforeInput();
cursor.pushRightBeforeRequired();
if (cursor.pushRightBeforeFilled()) return cursor.pos;
if (direction === DIRECTION.FORCE_RIGHT) return this.value.length;
/** Get block by name */
}, {
key: "maskedBlock",
value: function maskedBlock(name) {
return this.maskedBlocks(name)[0];
// backward flow
cursor.popState();
if (cursor.ok) return cursor.pos;
cursor.popState();
if (cursor.ok) return cursor.pos;
return this.nearestInputPos(cursorPos, DIRECTION.LEFT);
}
return cursorPos;
}
/** Get all blocks by name */
}, {
key: "maskedBlocks",
value: function maskedBlocks(name) {
var _this4 = this;
var indices = this._maskedBlocks[name];
if (!indices) return [];
return indices.map(function (gi) {
return _this4._blocks[gi];
});
}
}]);
return MaskedPattern;
}(Masked);
/** Get block by name */
maskedBlock(name) {
return this.maskedBlocks(name)[0];
}
/** Get all blocks by name */
maskedBlocks(name) {
const indices = this._maskedBlocks[name];
if (!indices) return [];
return indices.map(gi => this._blocks[gi]);
}
}
MaskedPattern.DEFAULTS = {

@@ -554,0 +457,0 @@ lazy: true,

@@ -1,2 +0,2 @@

import { _ as _createClass, a as _classCallCheck, b as _objectWithoutProperties } from '../../_rollupPluginBabelHelpers-30a49e9e.js';
import { _ as _objectWithoutPropertiesLoose } from '../../_rollupPluginBabelHelpers-6b3bd404.js';
import ChangeDetails from '../../core/change-details.js';

@@ -7,172 +7,157 @@ import { isString } from '../../core/utils.js';

var _excluded = ["chunks"];
var ChunksTailDetails = /*#__PURE__*/function () {
const _excluded = ["chunks"];
class ChunksTailDetails {
/** */
function ChunksTailDetails() {
var chunks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
_classCallCheck(this, ChunksTailDetails);
constructor() {
let chunks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
this.chunks = chunks;
this.from = from;
}
_createClass(ChunksTailDetails, [{
key: "toString",
value: function toString() {
return this.chunks.map(String).join('');
}
toString() {
return this.chunks.map(String).join('');
}
// $FlowFixMe no ideas
}, {
key: "extend",
value: function extend(tailChunk) {
if (!String(tailChunk)) return;
if (isString(tailChunk)) tailChunk = new ContinuousTailDetails(String(tailChunk));
var lastChunk = this.chunks[this.chunks.length - 1];
var extendLast = lastChunk && (
// if stops are same or tail has no stop
lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
// if tail chunk goes just after last chunk
tailChunk.from === lastChunk.from + lastChunk.toString().length;
if (tailChunk instanceof ContinuousTailDetails) {
// check the ability to extend previous chunk
if (extendLast) {
// extend previous chunk
lastChunk.extend(tailChunk.toString());
} else {
// append new chunk
this.chunks.push(tailChunk);
// $FlowFixMe no ideas
extend(tailChunk) {
if (!String(tailChunk)) return;
if (isString(tailChunk)) tailChunk = new ContinuousTailDetails(String(tailChunk));
const lastChunk = this.chunks[this.chunks.length - 1];
const extendLast = lastChunk && (
// if stops are same or tail has no stop
lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
// if tail chunk goes just after last chunk
tailChunk.from === lastChunk.from + lastChunk.toString().length;
if (tailChunk instanceof ContinuousTailDetails) {
// check the ability to extend previous chunk
if (extendLast) {
// extend previous chunk
lastChunk.extend(tailChunk.toString());
} else {
// append new chunk
this.chunks.push(tailChunk);
}
} else if (tailChunk instanceof ChunksTailDetails) {
if (tailChunk.stop == null) {
// unwrap floating chunks to parent, keeping `from` pos
let firstTailChunk;
while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {
firstTailChunk = tailChunk.chunks.shift();
firstTailChunk.from += tailChunk.from;
this.extend(firstTailChunk);
}
} else if (tailChunk instanceof ChunksTailDetails) {
if (tailChunk.stop == null) {
// unwrap floating chunks to parent, keeping `from` pos
var firstTailChunk;
while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {
firstTailChunk = tailChunk.chunks.shift();
firstTailChunk.from += tailChunk.from;
this.extend(firstTailChunk);
}
}
}
// if tail chunk still has value
if (tailChunk.toString()) {
// if chunks contains stops, then popup stop to container
tailChunk.stop = tailChunk.blockIndex;
this.chunks.push(tailChunk);
}
// if tail chunk still has value
if (tailChunk.toString()) {
// if chunks contains stops, then popup stop to container
tailChunk.stop = tailChunk.blockIndex;
this.chunks.push(tailChunk);
}
}
}, {
key: "appendTo",
value: function appendTo(masked) {
// $FlowFixMe
if (!(masked instanceof IMask.MaskedPattern)) {
var tail = new ContinuousTailDetails(this.toString());
return tail.appendTo(masked);
}
appendTo(masked) {
// $FlowFixMe
if (!(masked instanceof IMask.MaskedPattern)) {
const tail = new ContinuousTailDetails(this.toString());
return tail.appendTo(masked);
}
const details = new ChangeDetails();
for (let ci = 0; ci < this.chunks.length && !details.skip; ++ci) {
const chunk = this.chunks[ci];
const lastBlockIter = masked._mapPosToBlock(masked.value.length);
const stop = chunk.stop;
let chunkBlock;
if (stop != null && (
// if block not found or stop is behind lastBlock
!lastBlockIter || lastBlockIter.index <= stop)) {
if (chunk instanceof ChunksTailDetails ||
// for continuous block also check if stop is exist
masked._stops.indexOf(stop) >= 0) {
details.aggregate(masked._appendPlaceholder(stop));
}
chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
}
var details = new ChangeDetails();
for (var ci = 0; ci < this.chunks.length && !details.skip; ++ci) {
var chunk = this.chunks[ci];
var lastBlockIter = masked._mapPosToBlock(masked.value.length);
var stop = chunk.stop;
var chunkBlock = void 0;
if (stop != null && (
// if block not found or stop is behind lastBlock
!lastBlockIter || lastBlockIter.index <= stop)) {
if (chunk instanceof ChunksTailDetails ||
// for continuous block also check if stop is exist
masked._stops.indexOf(stop) >= 0) {
details.aggregate(masked._appendPlaceholder(stop));
}
chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
}
if (chunkBlock) {
var tailDetails = chunkBlock.appendTail(chunk);
tailDetails.skip = false; // always ignore skip, it will be set on last
details.aggregate(tailDetails);
masked._value += tailDetails.inserted;
if (chunkBlock) {
const tailDetails = chunkBlock.appendTail(chunk);
tailDetails.skip = false; // always ignore skip, it will be set on last
details.aggregate(tailDetails);
masked._value += tailDetails.inserted;
// get not inserted chars
var remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
if (remainChars) details.aggregate(masked.append(remainChars, {
tail: true
}));
} else {
details.aggregate(masked.append(chunk.toString(), {
tail: true
}));
}
// get not inserted chars
const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
if (remainChars) details.aggregate(masked.append(remainChars, {
tail: true
}));
} else {
details.aggregate(masked.append(chunk.toString(), {
tail: true
}));
}
return details;
}
}, {
key: "state",
get: function get() {
return {
chunks: this.chunks.map(function (c) {
return c.state;
}),
from: this.from,
stop: this.stop,
blockIndex: this.blockIndex
};
},
set: function set(state) {
var chunks = state.chunks,
props = _objectWithoutProperties(state, _excluded);
Object.assign(this, props);
this.chunks = chunks.map(function (cstate) {
var chunk = "chunks" in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
// $FlowFixMe already checked above
chunk.state = cstate;
return chunk;
});
}
}, {
key: "unshift",
value: function unshift(beforePos) {
if (!this.chunks.length || beforePos != null && this.from >= beforePos) return '';
var chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
var ci = 0;
while (ci < this.chunks.length) {
var chunk = this.chunks[ci];
var shiftChar = chunk.unshift(chunkShiftPos);
if (chunk.toString()) {
// chunk still contains value
// but not shifted - means no more available chars to shift
if (!shiftChar) break;
++ci;
} else {
// clean if chunk has no value
this.chunks.splice(ci, 1);
}
if (shiftChar) return shiftChar;
return details;
}
get state() {
return {
chunks: this.chunks.map(c => c.state),
from: this.from,
stop: this.stop,
blockIndex: this.blockIndex
};
}
set state(state) {
const {
chunks
} = state,
props = _objectWithoutPropertiesLoose(state, _excluded);
Object.assign(this, props);
this.chunks = chunks.map(cstate => {
const chunk = "chunks" in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
// $FlowFixMe already checked above
chunk.state = cstate;
return chunk;
});
}
unshift(beforePos) {
if (!this.chunks.length || beforePos != null && this.from >= beforePos) return '';
const chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
let ci = 0;
while (ci < this.chunks.length) {
const chunk = this.chunks[ci];
const shiftChar = chunk.unshift(chunkShiftPos);
if (chunk.toString()) {
// chunk still contains value
// but not shifted - means no more available chars to shift
if (!shiftChar) break;
++ci;
} else {
// clean if chunk has no value
this.chunks.splice(ci, 1);
}
return '';
if (shiftChar) return shiftChar;
}
}, {
key: "shift",
value: function shift() {
if (!this.chunks.length) return '';
var ci = this.chunks.length - 1;
while (0 <= ci) {
var chunk = this.chunks[ci];
var shiftChar = chunk.shift();
if (chunk.toString()) {
// chunk still contains value
// but not shifted - means no more available chars to shift
if (!shiftChar) break;
--ci;
} else {
// clean if chunk has no value
this.chunks.splice(ci, 1);
}
if (shiftChar) return shiftChar;
return '';
}
shift() {
if (!this.chunks.length) return '';
let ci = this.chunks.length - 1;
while (0 <= ci) {
const chunk = this.chunks[ci];
const shiftChar = chunk.shift();
if (chunk.toString()) {
// chunk still contains value
// but not shifted - means no more available chars to shift
if (!shiftChar) break;
--ci;
} else {
// clean if chunk has no value
this.chunks.splice(ci, 1);
}
return '';
if (shiftChar) return shiftChar;
}
}]);
return ChunksTailDetails;
}();
return '';
}
}
export { ChunksTailDetails as default };

@@ -1,23 +0,22 @@

import { _ as _createClass, a as _classCallCheck } from '../../_rollupPluginBabelHelpers-30a49e9e.js';
import { DIRECTION } from '../../core/utils.js';
import '../../core/change-details.js';
var PatternCursor = /*#__PURE__*/function () {
function PatternCursor(masked, pos) {
_classCallCheck(this, PatternCursor);
class PatternCursor {
constructor(masked, pos) {
this.masked = masked;
this._log = [];
var _ref = masked._mapPosToBlock(pos) || (pos < 0 ?
// first
{
index: 0,
offset: 0
} :
// last
{
index: this.masked._blocks.length,
offset: 0
}),
offset = _ref.offset,
index = _ref.index;
const {
offset,
index
} = masked._mapPosToBlock(pos) || (pos < 0 ?
// first
{
index: 0,
offset: 0
} :
// last
{
index: this.masked._blocks.length,
offset: 0
});
this.offset = offset;

@@ -27,144 +26,108 @@ this.index = index;

}
_createClass(PatternCursor, [{
key: "block",
get: function get() {
return this.masked._blocks[this.index];
get block() {
return this.masked._blocks[this.index];
}
get pos() {
return this.masked._blockStartPos(this.index) + this.offset;
}
get state() {
return {
index: this.index,
offset: this.offset,
ok: this.ok
};
}
set state(s) {
Object.assign(this, s);
}
pushState() {
this._log.push(this.state);
}
popState() {
const s = this._log.pop();
this.state = s;
return s;
}
bindBlock() {
if (this.block) return;
if (this.index < 0) {
this.index = 0;
this.offset = 0;
}
}, {
key: "pos",
get: function get() {
return this.masked._blockStartPos(this.index) + this.offset;
if (this.index >= this.masked._blocks.length) {
this.index = this.masked._blocks.length - 1;
this.offset = this.block.value.length;
}
}, {
key: "state",
get: function get() {
return {
index: this.index,
offset: this.offset,
ok: this.ok
};
},
set: function set(s) {
Object.assign(this, s);
}
_pushLeft(fn) {
this.pushState();
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) === null || _this$block === void 0 ? void 0 : _this$block.value.length) || 0) {
var _this$block;
if (fn()) return this.ok = true;
}
}, {
key: "pushState",
value: function pushState() {
this._log.push(this.state);
return this.ok = false;
}
_pushRight(fn) {
this.pushState();
for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {
if (fn()) return this.ok = true;
}
}, {
key: "popState",
value: function popState() {
var s = this._log.pop();
this.state = s;
return s;
}
}, {
key: "bindBlock",
value: function bindBlock() {
if (this.block) return;
if (this.index < 0) {
this.index = 0;
this.offset = 0;
}
if (this.index >= this.masked._blocks.length) {
this.index = this.masked._blocks.length - 1;
this.offset = this.block.value.length;
}
}
}, {
key: "_pushLeft",
value: function _pushLeft(fn) {
this.pushState();
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) === null || _this$block === void 0 ? void 0 : _this$block.value.length) || 0) {
var _this$block;
if (fn()) return this.ok = true;
}
return this.ok = false;
}
}, {
key: "_pushRight",
value: function _pushRight(fn) {
this.pushState();
for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {
if (fn()) return this.ok = true;
}
return this.ok = false;
}
}, {
key: "pushLeftBeforeFilled",
value: function pushLeftBeforeFilled() {
var _this = this;
return this._pushLeft(function () {
if (_this.block.isFixed || !_this.block.value) return;
_this.offset = _this.block.nearestInputPos(_this.offset, DIRECTION.FORCE_LEFT);
if (_this.offset !== 0) return true;
});
}
}, {
key: "pushLeftBeforeInput",
value: function pushLeftBeforeInput() {
var _this2 = this;
// cases:
// filled input: 00|
// optional empty input: 00[]|
// nested block: XX<[]>|
return this._pushLeft(function () {
if (_this2.block.isFixed) return;
_this2.offset = _this2.block.nearestInputPos(_this2.offset, DIRECTION.LEFT);
return true;
});
}
}, {
key: "pushLeftBeforeRequired",
value: function pushLeftBeforeRequired() {
var _this3 = this;
return this._pushLeft(function () {
if (_this3.block.isFixed || _this3.block.isOptional && !_this3.block.value) return;
_this3.offset = _this3.block.nearestInputPos(_this3.offset, DIRECTION.LEFT);
return true;
});
}
}, {
key: "pushRightBeforeFilled",
value: function pushRightBeforeFilled() {
var _this4 = this;
return this._pushRight(function () {
if (_this4.block.isFixed || !_this4.block.value) return;
_this4.offset = _this4.block.nearestInputPos(_this4.offset, DIRECTION.FORCE_RIGHT);
if (_this4.offset !== _this4.block.value.length) return true;
});
}
}, {
key: "pushRightBeforeInput",
value: function pushRightBeforeInput() {
var _this5 = this;
return this._pushRight(function () {
if (_this5.block.isFixed) return;
return this.ok = false;
}
pushLeftBeforeFilled() {
return this._pushLeft(() => {
if (this.block.isFixed || !this.block.value) return;
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_LEFT);
if (this.offset !== 0) return true;
});
}
pushLeftBeforeInput() {
// cases:
// filled input: 00|
// optional empty input: 00[]|
// nested block: XX<[]>|
return this._pushLeft(() => {
if (this.block.isFixed) return;
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
return true;
});
}
pushLeftBeforeRequired() {
return this._pushLeft(() => {
if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
return true;
});
}
pushRightBeforeFilled() {
return this._pushRight(() => {
if (this.block.isFixed || !this.block.value) return;
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_RIGHT);
if (this.offset !== this.block.value.length) return true;
});
}
pushRightBeforeInput() {
return this._pushRight(() => {
if (this.block.isFixed) return;
// const o = this.offset;
_this5.offset = _this5.block.nearestInputPos(_this5.offset, DIRECTION.NONE);
// HACK cases like (STILL DOES NOT WORK FOR NESTED)
// aa|X
// aa<X|[]>X_ - this will not work
// if (o && o === this.offset && this.block instanceof PatternInputDefinition) continue;
return true;
});
}
}, {
key: "pushRightBeforeRequired",
value: function pushRightBeforeRequired() {
var _this6 = this;
return this._pushRight(function () {
if (_this6.block.isFixed || _this6.block.isOptional && !_this6.block.value) return;
// const o = this.offset;
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
// HACK cases like (STILL DOES NOT WORK FOR NESTED)
// aa|X
// aa<X|[]>X_ - this will not work
// if (o && o === this.offset && this.block instanceof PatternInputDefinition) continue;
return true;
});
}
pushRightBeforeRequired() {
return this._pushRight(() => {
if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
// TODO check |[*]XX_
_this6.offset = _this6.block.nearestInputPos(_this6.offset, DIRECTION.NONE);
return true;
});
}
}]);
return PatternCursor;
}();
// TODO check |[*]XX_
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
return true;
});
}
}
export { PatternCursor as default };

@@ -1,2 +0,1 @@

import { _ as _createClass, a as _classCallCheck } from '../../_rollupPluginBabelHelpers-30a49e9e.js';
import ChangeDetails from '../../core/change-details.js';

@@ -6,3 +5,5 @@ import { DIRECTION, isString } from '../../core/utils.js';

var PatternFixedDefinition = /*#__PURE__*/function () {
/** */
class PatternFixedDefinition {
/** */

@@ -20,4 +21,3 @@

function PatternFixedDefinition(opts) {
_classCallCheck(this, PatternFixedDefinition);
constructor(opts) {
Object.assign(this, opts);

@@ -27,132 +27,98 @@ this._value = '';

}
_createClass(PatternFixedDefinition, [{
key: "value",
get: function get() {
return this._value;
get value() {
return this._value;
}
get unmaskedValue() {
return this.isUnmasking ? this.value : '';
}
reset() {
this._isRawInput = false;
this._value = '';
}
remove() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
if (!this._value) this._isRawInput = false;
return new ChangeDetails();
}
nearestInputPos(cursorPos) {
let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
const minPos = 0;
const maxPos = this._value.length;
switch (direction) {
case DIRECTION.LEFT:
case DIRECTION.FORCE_LEFT:
return minPos;
case DIRECTION.NONE:
case DIRECTION.RIGHT:
case DIRECTION.FORCE_RIGHT:
default:
return maxPos;
}
}, {
key: "unmaskedValue",
get: function get() {
return this.isUnmasking ? this.value : '';
}
}, {
key: "reset",
value: function reset() {
this._isRawInput = false;
this._value = '';
}
}, {
key: "remove",
value: function remove() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
if (!this._value) this._isRawInput = false;
return new ChangeDetails();
}
}, {
key: "nearestInputPos",
value: function nearestInputPos(cursorPos) {
var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
var minPos = 0;
var maxPos = this._value.length;
switch (direction) {
case DIRECTION.LEFT:
case DIRECTION.FORCE_LEFT:
return minPos;
case DIRECTION.NONE:
case DIRECTION.RIGHT:
case DIRECTION.FORCE_RIGHT:
default:
return maxPos;
}
}
}, {
key: "extractInput",
value: function extractInput() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
var flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
}
}, {
key: "isComplete",
get: function get() {
return true;
}
}, {
key: "isFilled",
get: function get() {
return Boolean(this._value);
}
}, {
key: "_appendChar",
value: function _appendChar(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var details = new ChangeDetails();
if (this._value) return details;
var appendEager = this.eager === true || this.eager === 'append';
var appended = this.char === ch;
var isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
if (isResolved) details.rawInserted = this.char;
this._value = details.inserted = this.char;
this._isRawInput = isResolved && (flags.raw || flags.input);
return details;
}
}, {
key: "_appendEager",
value: function _appendEager() {
return this._appendChar(this.char, {
tail: true
});
}
}, {
key: "_appendPlaceholder",
value: function _appendPlaceholder() {
var details = new ChangeDetails();
if (this._value) return details;
this._value = details.inserted = this.char;
return details;
}
}, {
key: "extractTail",
value: function extractTail() {
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
return new ContinuousTailDetails('');
}
}
extractInput() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
let flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
}
get isComplete() {
return true;
}
get isFilled() {
return Boolean(this._value);
}
_appendChar(ch) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const details = new ChangeDetails();
if (this._value) return details;
const appendEager = this.eager === true || this.eager === 'append';
const appended = this.char === ch;
const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
if (isResolved) details.rawInserted = this.char;
this._value = details.inserted = this.char;
this._isRawInput = isResolved && (flags.raw || flags.input);
return details;
}
_appendEager() {
return this._appendChar(this.char, {
tail: true
});
}
_appendPlaceholder() {
const details = new ChangeDetails();
if (this._value) return details;
this._value = details.inserted = this.char;
return details;
}
extractTail() {
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
return new ContinuousTailDetails('');
}
// $FlowFixMe no ideas
}, {
key: "appendTail",
value: function appendTail(tail) {
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
return tail.appendTo(this);
// $FlowFixMe no ideas
appendTail(tail) {
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
return tail.appendTo(this);
}
append(str, flags, tail) {
const details = this._appendChar(str[0], flags);
if (tail != null) {
details.tailShift += this.appendTail(tail).tailShift;
}
}, {
key: "append",
value: function append(str, flags, tail) {
var details = this._appendChar(str[0], flags);
if (tail != null) {
details.tailShift += this.appendTail(tail).tailShift;
}
return details;
}
}, {
key: "doCommit",
value: function doCommit() {}
}, {
key: "state",
get: function get() {
return {
_value: this._value,
_isRawInput: this._isRawInput
};
},
set: function set(state) {
Object.assign(this, state);
}
}]);
return PatternFixedDefinition;
}();
return details;
}
doCommit() {}
get state() {
return {
_value: this._value,
_isRawInput: this._isRawInput
};
}
set state(state) {
Object.assign(this, state);
}
}
export { PatternFixedDefinition as default };

@@ -1,2 +0,2 @@

import { _ as _createClass, a as _classCallCheck, b as _objectWithoutProperties } from '../../_rollupPluginBabelHelpers-30a49e9e.js';
import { _ as _objectWithoutPropertiesLoose } from '../../_rollupPluginBabelHelpers-6b3bd404.js';
import createMask from '../factory.js';

@@ -7,4 +7,7 @@ import ChangeDetails from '../../core/change-details.js';

var _excluded = ["mask"];
var DEFAULT_INPUT_DEFINITIONS = {
const _excluded = ["mask"];
/** */
const DEFAULT_INPUT_DEFINITIONS = {
'0': /\d/,

@@ -17,3 +20,3 @@ 'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,

/** */
var PatternInputDefinition = /*#__PURE__*/function () {
class PatternInputDefinition {
/** */

@@ -33,149 +36,112 @@

function PatternInputDefinition(opts) {
_classCallCheck(this, PatternInputDefinition);
var mask = opts.mask,
blockOpts = _objectWithoutProperties(opts, _excluded);
constructor(opts) {
const {
mask
} = opts,
blockOpts = _objectWithoutPropertiesLoose(opts, _excluded);
this.masked = createMask({
mask: mask
mask
});
Object.assign(this, blockOpts);
}
_createClass(PatternInputDefinition, [{
key: "reset",
value: function reset() {
reset() {
this.isFilled = false;
this.masked.reset();
}
remove() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
if (fromPos === 0 && toPos >= 1) {
this.isFilled = false;
this.masked.reset();
return this.masked.remove(fromPos, toPos);
}
}, {
key: "remove",
value: function remove() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
if (fromPos === 0 && toPos >= 1) {
this.isFilled = false;
return this.masked.remove(fromPos, toPos);
}
return new ChangeDetails();
return new ChangeDetails();
}
get value() {
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
}
get unmaskedValue() {
return this.masked.unmaskedValue;
}
get isComplete() {
return Boolean(this.masked.value) || this.isOptional;
}
_appendChar(ch) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (this.isFilled) return new ChangeDetails();
const state = this.masked.state;
// simulate input
const details = this.masked._appendChar(ch, flags);
if (details.inserted && this.doValidate(flags) === false) {
details.inserted = details.rawInserted = '';
this.masked.state = state;
}
}, {
key: "value",
get: function get() {
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
}
}, {
key: "unmaskedValue",
get: function get() {
return this.masked.unmaskedValue;
}
}, {
key: "isComplete",
get: function get() {
return Boolean(this.masked.value) || this.isOptional;
}
}, {
key: "_appendChar",
value: function _appendChar(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (this.isFilled) return new ChangeDetails();
var state = this.masked.state;
// simulate input
var details = this.masked._appendChar(ch, flags);
if (details.inserted && this.doValidate(flags) === false) {
details.inserted = details.rawInserted = '';
this.masked.state = state;
}
if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
details.inserted = this.placeholderChar;
}
details.skip = !details.inserted && !this.isOptional;
this.isFilled = Boolean(details.inserted);
return details;
}
}, {
key: "append",
value: function append() {
var _this$masked;
// TODO probably should be done via _appendChar
return (_this$masked = this.masked).append.apply(_this$masked, arguments);
}
}, {
key: "_appendPlaceholder",
value: function _appendPlaceholder() {
var details = new ChangeDetails();
if (this.isFilled || this.isOptional) return details;
this.isFilled = true;
if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
details.inserted = this.placeholderChar;
return details;
}
}, {
key: "_appendEager",
value: function _appendEager() {
return new ChangeDetails();
details.skip = !details.inserted && !this.isOptional;
this.isFilled = Boolean(details.inserted);
return details;
}
append() {
// TODO probably should be done via _appendChar
return this.masked.append(...arguments);
}
_appendPlaceholder() {
const details = new ChangeDetails();
if (this.isFilled || this.isOptional) return details;
this.isFilled = true;
details.inserted = this.placeholderChar;
return details;
}
_appendEager() {
return new ChangeDetails();
}
extractTail() {
return this.masked.extractTail(...arguments);
}
appendTail() {
return this.masked.appendTail(...arguments);
}
extractInput() {
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
let flags = arguments.length > 2 ? arguments[2] : undefined;
return this.masked.extractInput(fromPos, toPos, flags);
}
nearestInputPos(cursorPos) {
let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
const minPos = 0;
const maxPos = this.value.length;
const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
switch (direction) {
case DIRECTION.LEFT:
case DIRECTION.FORCE_LEFT:
return this.isComplete ? boundPos : minPos;
case DIRECTION.RIGHT:
case DIRECTION.FORCE_RIGHT:
return this.isComplete ? boundPos : maxPos;
case DIRECTION.NONE:
default:
return boundPos;
}
}, {
key: "extractTail",
value: function extractTail() {
var _this$masked2;
return (_this$masked2 = this.masked).extractTail.apply(_this$masked2, arguments);
}
}, {
key: "appendTail",
value: function appendTail() {
var _this$masked3;
return (_this$masked3 = this.masked).appendTail.apply(_this$masked3, arguments);
}
}, {
key: "extractInput",
value: function extractInput() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
var flags = arguments.length > 2 ? arguments[2] : undefined;
return this.masked.extractInput(fromPos, toPos, flags);
}
}, {
key: "nearestInputPos",
value: function nearestInputPos(cursorPos) {
var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
var minPos = 0;
var maxPos = this.value.length;
var boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
switch (direction) {
case DIRECTION.LEFT:
case DIRECTION.FORCE_LEFT:
return this.isComplete ? boundPos : minPos;
case DIRECTION.RIGHT:
case DIRECTION.FORCE_RIGHT:
return this.isComplete ? boundPos : maxPos;
case DIRECTION.NONE:
default:
return boundPos;
}
}
}, {
key: "doValidate",
value: function doValidate() {
var _this$masked4, _this$parent;
return (_this$masked4 = this.masked).doValidate.apply(_this$masked4, arguments) && (!this.parent || (_this$parent = this.parent).doValidate.apply(_this$parent, arguments));
}
}, {
key: "doCommit",
value: function doCommit() {
this.masked.doCommit();
}
}, {
key: "state",
get: function get() {
return {
masked: this.masked.state,
isFilled: this.isFilled
};
},
set: function set(state) {
this.masked.state = state.masked;
this.isFilled = state.isFilled;
}
}]);
return PatternInputDefinition;
}();
}
doValidate() {
return this.masked.doValidate(...arguments) && (!this.parent || this.parent.doValidate(...arguments));
}
doCommit() {
this.masked.doCommit();
}
get state() {
return {
masked: this.masked.state,
isFilled: this.isFilled
};
}
set state(state) {
this.masked.state = state.masked;
this.isFilled = state.isFilled;
}
}
export { DEFAULT_INPUT_DEFINITIONS, PatternInputDefinition as default };
import createMask from './factory.js';
import IMask from '../core/holder.js';
import '../core/utils.js';
import '../_rollupPluginBabelHelpers-30a49e9e.js';
import '../core/change-details.js';
/** Mask pipe source and destination types */
var PIPE_TYPE = {
const PIPE_TYPE = {
MASKED: 'value',

@@ -16,11 +15,9 @@ UNMASKED: 'unmaskedValue',

function createPipe(mask) {
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PIPE_TYPE.MASKED;
var to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PIPE_TYPE.MASKED;
var masked = createMask(mask);
return function (value) {
return masked.runIsolated(function (m) {
m[from] = value;
return m[to];
});
};
let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PIPE_TYPE.MASKED;
let to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PIPE_TYPE.MASKED;
const masked = createMask(mask);
return value => masked.runIsolated(m => {
m[from] = value;
return m[to];
});
}

@@ -33,3 +30,3 @@

}
return createPipe.apply(void 0, pipeArgs)(value);
return createPipe(...pipeArgs)(value);
}

@@ -36,0 +33,0 @@ IMask.PIPE_TYPE = PIPE_TYPE;

@@ -1,5 +0,5 @@

import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck, g as _get, h as _getPrototypeOf, f as _slicedToArray } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import MaskedPattern from './pattern.js';
import { normalizePrepare } from '../core/utils.js';
import IMask from '../core/holder.js';
import '../_rollupPluginBabelHelpers-6b3bd404.js';
import '../core/change-details.js';

@@ -16,132 +16,95 @@ import './base.js';

/** Pattern which accepts ranges */
var MaskedRange = /*#__PURE__*/function (_MaskedPattern) {
_inherits(MaskedRange, _MaskedPattern);
var _super = _createSuper(MaskedRange);
function MaskedRange() {
_classCallCheck(this, MaskedRange);
return _super.apply(this, arguments);
}
_createClass(MaskedRange, [{
key: "_matchFrom",
get:
/**
Optionally sets max length of pattern.
Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
*/
class MaskedRange extends MaskedPattern {
/**
Optionally sets max length of pattern.
Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
*/
/** Min bound */
/** Min bound */
/** Max bound */
/** Max bound */
/** */
/** */
function get() {
return this.maxLength - String(this.from).length;
}
get _matchFrom() {
return this.maxLength - String(this.from).length;
}
/**
@override
*/
}, {
key: "_update",
value: function _update(opts) {
// TODO type
opts = Object.assign({
to: this.to || 0,
from: this.from || 0,
maxLength: this.maxLength || 0
}, opts);
var maxLength = String(opts.to).length;
if (opts.maxLength != null) maxLength = Math.max(maxLength, opts.maxLength);
opts.maxLength = maxLength;
var fromStr = String(opts.from).padStart(maxLength, '0');
var toStr = String(opts.to).padStart(maxLength, '0');
var sameCharsCount = 0;
while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) ++sameCharsCount;
opts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\0') + '0'.repeat(maxLength - sameCharsCount);
_get(_getPrototypeOf(MaskedRange.prototype), "_update", this).call(this, opts);
}
/**
@override
*/
_update(opts) {
// TODO type
opts = Object.assign({
to: this.to || 0,
from: this.from || 0,
maxLength: this.maxLength || 0
}, opts);
let maxLength = String(opts.to).length;
if (opts.maxLength != null) maxLength = Math.max(maxLength, opts.maxLength);
opts.maxLength = maxLength;
const fromStr = String(opts.from).padStart(maxLength, '0');
const toStr = String(opts.to).padStart(maxLength, '0');
let sameCharsCount = 0;
while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) ++sameCharsCount;
opts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\0') + '0'.repeat(maxLength - sameCharsCount);
super._update(opts);
}
/**
@override
*/
}, {
key: "isComplete",
get: function get() {
return _get(_getPrototypeOf(MaskedRange.prototype), "isComplete", this) && Boolean(this.value);
/**
@override
*/
get isComplete() {
return super.isComplete && Boolean(this.value);
}
boundaries(str) {
let minstr = '';
let maxstr = '';
const [, placeholder, num] = str.match(/^(\D*)(\d*)(\D*)/) || [];
if (num) {
minstr = '0'.repeat(placeholder.length) + num;
maxstr = '9'.repeat(placeholder.length) + num;
}
}, {
key: "boundaries",
value: function boundaries(str) {
var minstr = '';
var maxstr = '';
var _ref = str.match(/^(\D*)(\d*)(\D*)/) || [],
_ref2 = _slicedToArray(_ref, 3),
placeholder = _ref2[1],
num = _ref2[2];
if (num) {
minstr = '0'.repeat(placeholder.length) + num;
maxstr = '9'.repeat(placeholder.length) + num;
}
minstr = minstr.padEnd(this.maxLength, '0');
maxstr = maxstr.padEnd(this.maxLength, '9');
return [minstr, maxstr];
}
minstr = minstr.padEnd(this.maxLength, '0');
maxstr = maxstr.padEnd(this.maxLength, '9');
return [minstr, maxstr];
}
// TODO str is a single char everytime
/**
@override
*/
}, {
key: "doPrepare",
value: function doPrepare(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var details;
var _normalizePrepare = normalizePrepare(_get(_getPrototypeOf(MaskedRange.prototype), "doPrepare", this).call(this, ch.replace(/\D/g, ''), flags));
var _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2);
ch = _normalizePrepare2[0];
details = _normalizePrepare2[1];
if (!this.autofix || !ch) return ch;
var fromStr = String(this.from).padStart(this.maxLength, '0');
var toStr = String(this.to).padStart(this.maxLength, '0');
var nextVal = this.value + ch;
if (nextVal.length > this.maxLength) return '';
var _this$boundaries = this.boundaries(nextVal),
_this$boundaries2 = _slicedToArray(_this$boundaries, 2),
minstr = _this$boundaries2[0],
maxstr = _this$boundaries2[1];
if (Number(maxstr) < this.from) return fromStr[nextVal.length - 1];
if (Number(minstr) > this.to) {
if (this.autofix === 'pad' && nextVal.length < this.maxLength) {
return ['', details.aggregate(this.append(fromStr[nextVal.length - 1] + ch, flags))];
}
return toStr[nextVal.length - 1];
// TODO str is a single char everytime
/**
@override
*/
doPrepare(ch) {
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let details;
[ch, details] = normalizePrepare(super.doPrepare(ch.replace(/\D/g, ''), flags));
if (!this.autofix || !ch) return ch;
const fromStr = String(this.from).padStart(this.maxLength, '0');
const toStr = String(this.to).padStart(this.maxLength, '0');
let nextVal = this.value + ch;
if (nextVal.length > this.maxLength) return '';
const [minstr, maxstr] = this.boundaries(nextVal);
if (Number(maxstr) < this.from) return fromStr[nextVal.length - 1];
if (Number(minstr) > this.to) {
if (this.autofix === 'pad' && nextVal.length < this.maxLength) {
return ['', details.aggregate(this.append(fromStr[nextVal.length - 1] + ch, flags))];
}
return ch;
return toStr[nextVal.length - 1];
}
return ch;
}
/**
@override
*/
}, {
key: "doValidate",
value: function doValidate() {
var _get2;
var str = this.value;
var firstNonZero = str.search(/[^0]/);
if (firstNonZero === -1 && str.length <= this._matchFrom) return true;
var _this$boundaries3 = this.boundaries(str),
_this$boundaries4 = _slicedToArray(_this$boundaries3, 2),
minstr = _this$boundaries4[0],
maxstr = _this$boundaries4[1];
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return this.from <= Number(maxstr) && Number(minstr) <= this.to && (_get2 = _get(_getPrototypeOf(MaskedRange.prototype), "doValidate", this)).call.apply(_get2, [this].concat(args));
}
}]);
return MaskedRange;
}(MaskedPattern);
/**
@override
*/
doValidate() {
const str = this.value;
const firstNonZero = str.search(/[^0]/);
if (firstNonZero === -1 && str.length <= this._matchFrom) return true;
const [minstr, maxstr] = this.boundaries(str);
return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(...arguments);
}
}
IMask.MaskedRange = MaskedRange;
export { MaskedRange as default };

@@ -1,2 +0,1 @@

import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck, g as _get, h as _getPrototypeOf } from '../_rollupPluginBabelHelpers-30a49e9e.js';
import Masked from './base.js';

@@ -9,27 +8,14 @@ import IMask from '../core/holder.js';

/** Masking by RegExp */
var MaskedRegExp = /*#__PURE__*/function (_Masked) {
_inherits(MaskedRegExp, _Masked);
var _super = _createSuper(MaskedRegExp);
function MaskedRegExp() {
_classCallCheck(this, MaskedRegExp);
return _super.apply(this, arguments);
class MaskedRegExp extends Masked {
/**
@override
@param {Object} opts
*/
_update(opts) {
if (opts.mask) opts.validate = value => value.search(opts.mask) >= 0;
super._update(opts);
}
_createClass(MaskedRegExp, [{
key: "_update",
value:
/**
@override
@param {Object} opts
*/
function _update(opts) {
if (opts.mask) opts.validate = function (value) {
return value.search(opts.mask) >= 0;
};
_get(_getPrototypeOf(MaskedRegExp.prototype), "_update", this).call(this, opts);
}
}]);
return MaskedRegExp;
}(Masked);
}
IMask.MaskedRegExp = MaskedRegExp;
export { MaskedRegExp as default };

@@ -1,61 +0,1 @@

var $$3 = require('../internals/export');
var assign = require('../internals/object-assign');
// `Object.assign` method
// https://tc39.es/ecma262/#sec-object.assign
// eslint-disable-next-line es/no-object-assign -- required for testing
$$3({
target: 'Object',
stat: true,
arity: 2,
forced: Object.assign !== assign
}, {
assign: assign
});
var $$2 = require('../internals/export');
var repeat = require('../internals/string-repeat');
// `String.prototype.repeat` method
// https://tc39.es/ecma262/#sec-string.prototype.repeat
$$2({
target: 'String',
proto: true
}, {
repeat: repeat
});
var $$1 = require('../internals/export');
var $padStart = require('../internals/string-pad').start;
var WEBKIT_BUG$1 = require('../internals/string-pad-webkit-bug');
// `String.prototype.padStart` method
// https://tc39.es/ecma262/#sec-string.prototype.padstart
$$1({
target: 'String',
proto: true,
forced: WEBKIT_BUG$1
}, {
padStart: function padStart(maxLength /* , fillString = ' ' */) {
return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
}
});
var $ = require('../internals/export');
var $padEnd = require('../internals/string-pad').end;
var WEBKIT_BUG = require('../internals/string-pad-webkit-bug');
// `String.prototype.padEnd` method
// https://tc39.es/ecma262/#sec-string.prototype.padend
$({
target: 'String',
proto: true,
forced: WEBKIT_BUG
}, {
padEnd: function padEnd(maxLength /* , fillString = ' ' */) {
return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
}
});
// TODO: Remove from `core-js@4`
require('../modules/es.global-this');
{
"name": "imask",
"version": "6.5.0",
"version": "6.5.1-alpha.0",
"author": "Alexey Kryazhev",

@@ -31,3 +31,3 @@ "license": "MIT",

],
"gitHead": "acad8efa189ad24f47932eaecf654b00d36f7ce7"
"gitHead": "6d48a02bf6ecff7c39f52400a85638d42485288d"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc