{"version":3,"file":"imask.min.js","sources":["../src/core/utils.ts","../src/core/action-details.ts","../src/core/holder.ts","../src/masked/factory.ts","../src/controls/mask-element.ts","../src/controls/html-mask-element.ts","../src/controls/html-input-mask-element.ts","../src/controls/html-contenteditable-mask-element.ts","../src/controls/input.ts","../src/core/change-details.ts","../src/core/continuous-tail-details.ts","../src/masked/base.ts","../src/masked/pattern/chunk-tail-details.ts","../src/masked/pattern/cursor.ts","../src/masked/pattern/fixed-definition.ts","../src/masked/pattern/input-definition.ts","../src/masked/regexp.ts","../src/masked/pattern.ts","../src/masked/range.ts","../src/masked/date.ts","../src/masked/dynamic.ts","../src/masked/enum.ts","../src/masked/function.ts","../src/masked/number.ts","../src/masked/pipe.ts","../src/index.ts"],"sourcesContent":["/** Checks if value is string */\nexport\nfunction isString (str: unknown): str is string {\n return typeof str === 'string' || str instanceof String;\n}\n\n/** Checks if value is object */\nexport\nfunction isObject (obj: unknown): obj is object {\n return typeof obj === 'object' && obj != null && obj?.constructor?.name === 'Object';\n}\n\nexport\nfunction pick, K extends keyof T, V extends T[keyof T]> (\n obj: T,\n keys: K[] | ((v: V, k: K) => boolean),\n): Pick {\n if (Array.isArray(keys)) return pick(obj, (_, k) => keys.includes(k));\n return (Object.entries(obj) as unknown as Array<[K, V]>)\n .reduce((acc, [k, v]) => {\n if (keys(v, k)) acc[k] = v;\n return acc;\n }, {} as any);\n}\n\n/** Direction */\nexport\nconst DIRECTION = {\n NONE: 'NONE',\n LEFT: 'LEFT',\n FORCE_LEFT: 'FORCE_LEFT',\n RIGHT: 'RIGHT',\n FORCE_RIGHT: 'FORCE_RIGHT',\n} as const;\n\n/** Direction */\nexport\ntype Direction = typeof DIRECTION[keyof typeof DIRECTION];\n\nexport\nfunction forceDirection (direction: Direction): Direction {\n switch (direction) {\n case DIRECTION.LEFT:\n return DIRECTION.FORCE_LEFT;\n case DIRECTION.RIGHT:\n return DIRECTION.FORCE_RIGHT;\n default:\n return direction;\n }\n}\n\n/** Escapes regular expression control chars */\nexport\nfunction escapeRegExp (str: string): string {\n return str.replace(/([.*+?^=!:${}()|[\\]/\\\\])/g, '\\\\$1');\n}\n\n// cloned from https://github.com/epoberezkin/fast-deep-equal with small changes\nexport\nfunction objectIncludes (b: any, a: any): boolean {\n if (a === b) return true;\n\n const arrA = Array.isArray(a), arrB = Array.isArray(b);\n let i;\n\n if (arrA && arrB) {\n if (a.length != b.length) return false;\n for (i = 0; i < a.length; i++)\n if (!objectIncludes(a[i], b[i])) return false;\n return true;\n }\n\n if (arrA != arrB) return false;\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const dateA = a instanceof Date, dateB = b instanceof Date;\n if (dateA && dateB) return a.getTime() == b.getTime();\n if (dateA != dateB) return false;\n\n const regexpA = a instanceof RegExp, regexpB = b instanceof RegExp;\n if (regexpA && regexpB) return a.toString() == b.toString();\n if (regexpA != regexpB) return false;\n\n const keys = Object.keys(a);\n // if (keys.length !== Object.keys(b).length) return false;\n\n for (i = 0; i < keys.length; i++)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = 0; i < keys.length; i++)\n if(!objectIncludes(b[keys[i]], a[keys[i]])) return false;\n\n return true;\n } else if (a && b && typeof a === 'function' && typeof b === 'function') {\n return a.toString() === b.toString()\n }\n\n return false;\n}\n\n/** Selection range */\nexport\ntype Selection = {\n start: number;\n end: number;\n};\n","import { type Direction, type Selection, DIRECTION } from './utils';\n\nexport\ntype ActionDetailsOptions = Pick;\n\n\n/** Provides details of changing input */\nexport default\nclass ActionDetails {\n /** Current input value */\n declare value: string;\n /** Current cursor position */\n declare cursorPos: number;\n /** Old input value */\n declare oldValue: string;\n /** Old selection */\n declare oldSelection: Selection;\n\n constructor (opts: ActionDetailsOptions) {\n Object.assign(this, opts);\n\n // double check if left part was changed (autofilling, other non-standard input triggers)\n while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {\n --this.oldSelection.start;\n }\n }\n\n /** Start changing position */\n get startChangePos (): number {\n return Math.min(this.cursorPos, this.oldSelection.start);\n }\n\n /** Inserted symbols count */\n get insertedCount (): number {\n return this.cursorPos - this.startChangePos;\n }\n\n /** Inserted symbols */\n get inserted (): string {\n return this.value.substr(this.startChangePos, this.insertedCount);\n }\n\n /** Removed symbols count */\n get removedCount (): number {\n // Math.max for opposite operation\n return Math.max((this.oldSelection.end - this.startChangePos) ||\n // for Delete\n this.oldValue.length - this.value.length, 0);\n }\n\n /** Removed symbols */\n get removed (): string {\n return this.oldValue.substr(this.startChangePos, this.removedCount);\n }\n\n /** Unchanged head symbols */\n get head (): string {\n return this.value.substring(0, this.startChangePos);\n }\n\n /** Unchanged tail symbols */\n get tail (): string {\n return this.value.substring(this.startChangePos + this.insertedCount);\n }\n\n /** Remove direction */\n get removeDirection (): Direction {\n if (!this.removedCount || this.insertedCount) return DIRECTION.NONE;\n\n // align right if delete at right\n return (\n (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) &&\n // if not range removed (event with backspace)\n this.oldSelection.end === this.oldSelection.start\n ) ?\n DIRECTION.RIGHT :\n DIRECTION.LEFT;\n }\n}\n","import type { default as _InputMask, InputMaskElement as _InputMaskElement } from '../controls/input';\nimport type { default as _Masked } from '../masked/base';\nimport type { default as _MaskedPattern } from '../masked/pattern';\nimport type { default as _MaskedDate } from '../masked/date';\nimport type { default as _MaskedDynamic } from '../masked/dynamic';\nimport type { default as _MaskedEnum } from '../masked/enum';\nimport type { default as _MaskedRange } from '../masked/range';\nimport type { default as _MaskedNumber } from '../masked/number';\nimport type { default as _MaskedFunction } from '../masked/function';\nimport type { default as _MaskedRegExp } from '../masked/regexp';\nimport type {\n default as _createMask,\n FactoryArg,\n} from '../masked/factory';\nimport type { default as _ChangeDetails } from './change-details';\n\nimport type { default as _MaskElement } from '../controls/mask-element';\nimport type { default as _HTMLMaskElement } from '../controls/html-mask-element';\nimport type { default as _HTMLContenteditableMaskElement } from '../controls/html-contenteditable-mask-element';\nimport type {\n createPipe as _createPipe,\n pipe as _pipe,\n PIPE_TYPE as _PIPE_TYPE\n} from '../masked/pipe';\n\n\n/** Applies mask on element */\nfunction IMask (el: _InputMaskElement, opts: Opts): _InputMask {\n // currently available only for input-like elements\n return new IMask.InputMask(el, opts);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\ndeclare namespace IMask {\n export let InputMask: typeof _InputMask;\n export let createMask: typeof _createMask;\n export let Masked: typeof _Masked;\n export let MaskedPattern: typeof _MaskedPattern;\n export let MaskedDate: typeof _MaskedDate;\n export let MaskedDynamic: typeof _MaskedDynamic;\n export let MaskedEnum: typeof _MaskedEnum;\n export let MaskedRange: typeof _MaskedRange;\n export let MaskedNumber: typeof _MaskedNumber;\n export let MaskedFunction: typeof _MaskedFunction;\n export let MaskedRegExp: typeof _MaskedRegExp;\n export let ChangeDetails: typeof _ChangeDetails;\n export let MaskElement: typeof _MaskElement;\n export let HTMLMaskElement: typeof _HTMLMaskElement;\n export let HTMLContenteditableMaskElement: typeof _HTMLContenteditableMaskElement;\n export let createPipe: typeof _createPipe;\n export let pipe: typeof _pipe;\n export let PIPE_TYPE: typeof _PIPE_TYPE;\n}\n\nexport default IMask;\n","import { isString, pick, isObject } from '../core/utils';\nimport type Masked from './base';\nimport { type MaskedOptions } from './base';\nimport IMask from '../core/holder';\n\nimport type MaskedRegExp from './regexp';\nimport type MaskedPattern from './pattern';\nimport type MaskedFunction from './function';\nimport type MaskedDate from './date';\nimport type MaskedNumber from './number';\nimport type MaskedDynamic from './dynamic';\nimport type MaskedRange from './range';\nimport type MaskedEnum from './enum';\n\nimport { type MaskedEnumOptions } from './enum';\nimport { type MaskedRangeOptions } from './range';\nimport { type MaskedDynamicOptions } from './dynamic';\nimport { type MaskedPatternOptions } from './pattern';\nimport { type MaskedNumberOptions } from './number';\nimport { type MaskedRegExpOptions } from './regexp';\nimport { type MaskedFunctionOptions } from './function';\nimport { type MaskedDateOptions } from './date';\n\ntype MaskedDateFactoryOptions = Omit & { mask: DateConstructor };\n\nexport\ntype FactoryStaticOpts =\n | MaskedDateFactoryOptions\n | MaskedNumberOptions\n | MaskedPatternOptions\n | MaskedDynamicOptions\n | MaskedRegExpOptions\n | MaskedFunctionOptions\n;\n\nexport\ntype AllFactoryStaticOpts =\n & MaskedDateFactoryOptions\n & MaskedNumberOptions\n & MaskedPatternOptions\n & MaskedDynamicOptions\n & MaskedRegExpOptions\n & MaskedFunctionOptions\n & MaskedEnumOptions\n & MaskedRangeOptions\n;\n\nexport\ntype FactoryStaticReturnMasked =\n Opts extends MaskedDateFactoryOptions ? MaskedDate :\n Opts extends MaskedNumberOptions ? MaskedNumber :\n Opts extends MaskedPatternOptions ? MaskedPattern :\n Opts extends MaskedDynamicOptions ? MaskedDynamic :\n Opts extends MaskedRegExpOptions ? MaskedRegExp :\n Opts extends MaskedFunctionOptions ? MaskedFunction :\n never\n;\n\nexport\ntype FactoryStaticMaskReturnMasked =\n Mask extends MaskedDateFactoryOptions['mask'] ? MaskedDate :\n Mask extends MaskedNumberOptions['mask'] ? MaskedNumber :\n Mask extends MaskedPatternOptions['mask'] ? MaskedPattern :\n Mask extends MaskedDynamicOptions['mask'] ? MaskedDynamic :\n Mask extends MaskedRegExpOptions['mask'] ? MaskedRegExp :\n Mask extends MaskedFunctionOptions['mask'] ? MaskedFunction :\n never\n;\n\n\nexport\ntype FactoryInstanceOpts = MaskedOptions & { mask: Masked };\n\nexport\ntype FactoryInstanceReturnMasked = Opts extends { mask: infer M } ? M : never;\n\nexport\ntype FactoryConstructorOpts = MaskedOptions & { mask:\n | typeof Masked\n | typeof MaskedDate\n | typeof MaskedNumber\n | typeof MaskedEnum\n | typeof MaskedRange\n | typeof MaskedRegExp\n | typeof MaskedFunction\n | typeof MaskedPattern\n | typeof MaskedDynamic\n | typeof MaskedRegExp\n};\n \nexport\ntype FactoryConstructorReturnMasked =\n Opts extends { mask: typeof MaskedDate } ? MaskedDate :\n Opts extends { mask: typeof MaskedNumber } ? MaskedNumber :\n Opts extends { mask: typeof MaskedEnum } ? MaskedEnum :\n Opts extends { mask: typeof MaskedRange } ? MaskedRange :\n Opts extends { mask: typeof MaskedRegExp } ? MaskedRegExp :\n Opts extends { mask: typeof MaskedFunction } ? MaskedFunction :\n Opts extends { mask: typeof MaskedPattern } ? MaskedPattern :\n Opts extends { mask: typeof MaskedDynamic } ? MaskedDynamic :\n Masked\n;\n\nexport\ntype FactoryOpts = FactoryConstructorOpts | FactoryInstanceOpts | FactoryStaticOpts;\n\nexport\ntype FactoryArg = Masked | FactoryOpts | FactoryStaticOpts['mask'];\n\nexport\ntype ExtendFactoryArgOptions =\n Masked | FactoryOpts & Opts | FactoryStaticOpts['mask']\n;\n\nexport\ntype UpdateStaticOpts =\n Opts extends MaskedEnumOptions ? MaskedEnumOptions :\n Opts extends MaskedRangeOptions ? MaskedRangeOptions :\n Opts extends MaskedDynamicOptions ? MaskedDynamicOptions :\n Opts extends MaskedPatternOptions ? MaskedPatternOptions :\n Opts extends MaskedDateOptions ? MaskedDateOptions :\n Opts extends MaskedNumberOptions ? MaskedNumberOptions :\n Opts extends MaskedRegExpOptions ? MaskedRegExpOptions :\n Opts extends MaskedFunctionOptions ? MaskedFunctionOptions :\n never\n;\n\ntype UpdateAnyOpts = Record;\n\nexport\ntype UpdateInstanceOpts =\n M extends MaskedRegExp ? MaskedRegExpOptions :\n M extends MaskedFunction ? MaskedFunctionOptions :\n M extends MaskedDate ? MaskedDateOptions :\n M extends MaskedNumber ? MaskedNumberOptions :\n M extends MaskedDynamic ? MaskedDynamicOptions :\n M extends MaskedRange ? MaskedRangeOptions :\n M extends MaskedEnum ? MaskedEnumOptions :\n M extends MaskedPattern ? MaskedPatternOptions :\n UpdateAnyOpts\n;\n\nexport\ntype UpdateConstructorOpts =\n M extends { mask: typeof MaskedDate } ? MaskedDateOptions :\n M extends { mask: typeof MaskedNumber } ? MaskedNumberOptions :\n M extends { mask: typeof MaskedEnum } ? MaskedEnumOptions :\n M extends { mask: typeof MaskedRange } ? MaskedRangeOptions :\n M extends { mask: typeof MaskedRegExp } ? MaskedRegExpOptions :\n M extends { mask: typeof MaskedFunction } ? MaskedFunctionOptions :\n M extends { mask: typeof MaskedPattern } ? MaskedPatternOptions :\n M extends { mask: typeof MaskedDynamic } ? MaskedDynamicOptions :\n UpdateAnyOpts\n;\n\nexport\ntype UpdateStaticMaskOpts =\n M extends MaskedDateFactoryOptions['mask'] ? MaskedDateOptions :\n M extends MaskedNumberOptions['mask'] ? MaskedNumberOptions :\n M extends MaskedPatternOptions['mask'] ? MaskedPatternOptions :\n M extends MaskedDynamicOptions['mask'] ? MaskedDynamicOptions :\n M extends MaskedRegExpOptions['mask'] ? MaskedRegExpOptions :\n M extends MaskedFunctionOptions['mask'] ? MaskedFunctionOptions :\n never\n;\n\nexport\ntype UpdateOpts = Partial<\n Opts extends Masked ? UpdateInstanceOpts :\n Opts extends FactoryStaticOpts['mask'] ? UpdateStaticMaskOpts :\n Opts extends FactoryStaticOpts ? UpdateStaticOpts :\n Opts extends FactoryInstanceOpts ? UpdateInstanceOpts :\n Opts extends FactoryConstructorOpts ? UpdateConstructorOpts :\n UpdateAnyOpts\n>;\n\nexport\ntype FactoryReturnMasked =\n Opts extends Masked ? Opts :\n Opts extends FactoryStaticOpts['mask'] ? FactoryStaticMaskReturnMasked :\n Opts extends FactoryConstructorOpts ? FactoryConstructorReturnMasked :\n Opts extends FactoryInstanceOpts ? FactoryInstanceReturnMasked :\n Opts extends FactoryStaticOpts ? FactoryStaticReturnMasked :\n never\n;\n\n\n\n// TODO can't use overloads here because of https://github.com/microsoft/TypeScript/issues/50754\n// export function maskedClass(mask: string): typeof MaskedPattern;\n// export function maskedClass(mask: DateConstructor): typeof MaskedDate;\n// export function maskedClass(mask: NumberConstructor): typeof MaskedNumber;\n// export function maskedClass(mask: Array | ArrayConstructor): typeof MaskedDynamic;\n// export function maskedClass(mask: MaskedDate): typeof MaskedDate;\n// export function maskedClass(mask: MaskedNumber): typeof MaskedNumber;\n// export function maskedClass(mask: MaskedEnum): typeof MaskedEnum;\n// export function maskedClass(mask: MaskedRange): typeof MaskedRange;\n// export function maskedClass(mask: MaskedRegExp): typeof MaskedRegExp;\n// export function maskedClass(mask: MaskedFunction): typeof MaskedFunction;\n// export function maskedClass(mask: MaskedPattern): typeof MaskedPattern;\n// export function maskedClass(mask: MaskedDynamic): typeof MaskedDynamic;\n// export function maskedClass(mask: Masked): typeof Masked;\n// export function maskedClass(mask: typeof Masked): typeof Masked;\n// export function maskedClass(mask: typeof MaskedDate): typeof MaskedDate;\n// export function maskedClass(mask: typeof MaskedNumber): typeof MaskedNumber;\n// export function maskedClass(mask: typeof MaskedEnum): typeof MaskedEnum;\n// export function maskedClass(mask: typeof MaskedRange): typeof MaskedRange;\n// export function maskedClass(mask: typeof MaskedRegExp): typeof MaskedRegExp;\n// export function maskedClass(mask: typeof MaskedFunction): typeof MaskedFunction;\n// export function maskedClass(mask: typeof MaskedPattern): typeof MaskedPattern;\n// export function maskedClass(mask: typeof MaskedDynamic): typeof MaskedDynamic;\n// export function maskedClass (mask: Mask): Mask;\n// export function maskedClass(mask: RegExp): typeof MaskedRegExp;\n// export function maskedClass(mask: (value: string, ...args: any[]) => boolean): typeof MaskedFunction;\n\n/** Get Masked class by mask type */\nexport function maskedClass (mask: Masked | FactoryOpts['mask']): any /* TODO */ {\n if (mask == null) throw new Error('mask property should be defined');\n\n if (mask instanceof RegExp) return IMask.MaskedRegExp;\n if (isString(mask)) return IMask.MaskedPattern;\n if (mask === Date) return IMask.MaskedDate;\n if (mask === Number) return IMask.MaskedNumber;\n if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;\n if (IMask.Masked && (mask as any).prototype instanceof IMask.Masked) return mask;\n if (IMask.Masked && mask instanceof IMask.Masked) return mask.constructor;\n if (mask instanceof Function) return IMask.MaskedFunction;\n\n console.warn('Mask not found for mask', mask); // eslint-disable-line no-console\n return IMask.Masked;\n}\n\ntype MaskedClassOf =\n M extends MaskedDate ? typeof MaskedDate :\n M extends MaskedNumber ? typeof MaskedNumber :\n M extends MaskedEnum ? typeof MaskedEnum :\n M extends MaskedRange ? typeof MaskedRange :\n M extends MaskedRegExp ? typeof MaskedRegExp :\n M extends MaskedFunction ? typeof MaskedFunction :\n M extends MaskedPattern ? typeof MaskedPattern :\n M extends MaskedDynamic ? typeof MaskedDynamic :\n any\n;\n\n\ntype NormalizedMaskedOpts = Omit & {\n _mask: Opts,\n mask: MaskedClassOf,\n};\n\ntype NormalizedInstanceOpts =\n Omit &\n NormalizedMaskedOpts\n;\n\nexport\ntype NormalizedOpts =\n Opts extends FactoryStaticOpts['mask'] ? { mask: Opts } :\n Opts extends Masked ? NormalizedMaskedOpts :\n Opts extends FactoryInstanceOpts ? NormalizedInstanceOpts :\n Opts extends FactoryStaticOpts | FactoryConstructorOpts ? Opts :\n { mask: Opts }\n;\n\nexport\nfunction normalizeOpts (opts: Opts): NormalizedOpts {\n if (!opts) throw new Error('Options in not defined');\n\n if (IMask.Masked) {\n if ((opts as any).prototype instanceof IMask.Masked) return { mask: opts } as NormalizedOpts;\n\n /*\n handle cases like:\n 1) opts = Masked\n 2) opts = { mask: Masked, ...instanceOpts }\n */\n const { mask=undefined, ...instanceOpts } =\n opts instanceof IMask.Masked ? { mask: opts } :\n isObject(opts) && (opts as FactoryInstanceOpts).mask instanceof IMask.Masked ? (opts as FactoryInstanceOpts) : {};\n\n if (mask) {\n const _mask = (mask as Masked).mask;\n\n return {\n ...pick(mask, (_, k: string) => !k.startsWith('_')),\n mask: mask.constructor,\n _mask,\n ...instanceOpts,\n } as NormalizedOpts;\n }\n }\n\n if (!isObject(opts)) return { mask: opts } as unknown as NormalizedOpts;\n\n return { ...opts } as unknown as NormalizedOpts;\n}\n\n// TODO can't use overloads here because of https://github.com/microsoft/TypeScript/issues/50754\n\n// From masked\n// export default function createMask (opts: Opts): ReturnMasked;\n// // From masked class\n// export default function createMask, ReturnMasked extends Masked=InstanceType> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedDate=MaskedDate> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedNumber=MaskedNumber> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedEnum=MaskedEnum> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedRange=MaskedRange> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedRegExp=MaskedRegExp> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedFunction=MaskedFunction> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedPattern=MaskedPattern> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedDynamic=MaskedDynamic> (opts: Opts): ReturnMasked;\n// // From mask opts\n// export default function createMask, ReturnMasked=Opts extends MaskedOptions ? M : never> (opts: Opts): ReturnMasked;\n// export default function createMask> (opts: Opts): ReturnMasked;\n// export default function createMask> (opts: Opts): ReturnMasked;\n// export default function createMask> (opts: Opts): ReturnMasked;\n// export default function createMask> (opts: Opts): ReturnMasked;\n// export default function createMask> (opts: Opts): ReturnMasked;\n// export default function createMask> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedRegExp=MaskedRegExp> (opts: Opts): ReturnMasked;\n// export default function createMask, ReturnMasked extends MaskedFunction=MaskedFunction> (opts: Opts): ReturnMasked;\n\n/** Creates new {@link Masked} depending on mask type */\nexport default\nfunction createMask (opts: Opts): FactoryReturnMasked {\n if (IMask.Masked && (opts instanceof IMask.Masked)) return opts as FactoryReturnMasked;\n const nOpts = normalizeOpts(opts);\n\n const MaskedClass = maskedClass(nOpts.mask);\n if (!MaskedClass) throw new Error('Masked class is not found for provided mask, appropriate module needs to be imported manually before creating mask.');\n\n if (nOpts.mask === MaskedClass) delete nOpts.mask;\n if ((nOpts as any)._mask) { nOpts.mask = (nOpts as any)._mask; delete (nOpts as any)._mask; }\n return new MaskedClass(nOpts);\n}\n\n\nIMask.createMask = createMask;\n","import IMask from '../core/holder';\n\n\nexport\ntype ElementEvent =\n 'selectionChange' |\n 'input' |\n 'drop' |\n 'click' |\n 'focus' |\n 'commit';\n\n/** Generic element API to use with mask */\nexport default\nabstract class MaskElement {\n /** */\n abstract _unsafeSelectionStart: number | null;\n /** */\n abstract _unsafeSelectionEnd: number | null;\n /** */\n abstract value: string;\n\n /** Safely returns selection start */\n get selectionStart (): number {\n let start;\n try {\n start = this._unsafeSelectionStart;\n } catch {}\n\n return start != null ?\n start :\n this.value.length;\n }\n\n /** Safely returns selection end */\n get selectionEnd (): number {\n let end;\n try {\n end = this._unsafeSelectionEnd;\n } catch {}\n\n return end != null ?\n end :\n this.value.length;\n }\n\n /** Safely sets element selection */\n select (start: number, end: number) {\n if (start == null || end == null ||\n start === this.selectionStart && end === this.selectionEnd) return;\n\n try {\n this._unsafeSelect(start, end);\n } catch {}\n }\n\n /** */\n get isActive (): boolean { return false; }\n /** */\n abstract _unsafeSelect (start: number, end: number): void;\n /** */\n abstract bindEvents (handlers: {[key in ElementEvent]: Function}): void;\n /** */\n abstract unbindEvents (): void\n}\n\n\nIMask.MaskElement = MaskElement;\n","import MaskElement, { type ElementEvent } from './mask-element';\nimport IMask from '../core/holder';\n\n\n/** Bridge between HTMLElement and {@link Masked} */\nexport default\nabstract class HTMLMaskElement extends MaskElement {\n /** Mapping between HTMLElement events and mask internal events */\n static EVENTS_MAP = {\n selectionChange: 'keydown',\n input: 'input',\n drop: 'drop',\n click: 'click',\n focus: 'focus',\n commit: 'blur',\n } as const;\n /** HTMLElement to use mask on */\n declare input: HTMLElement;\n declare _handlers: {[k: string]: EventListener};\n abstract value: string;\n\n constructor (input: HTMLElement) {\n super();\n this.input = input;\n this._handlers = {};\n }\n\n get rootElement (): HTMLDocument {\n return (this.input.getRootNode?.() ?? document) as HTMLDocument;\n }\n\n /**\n Is element in focus\n */\n get isActive (): boolean {\n return this.input === this.rootElement.activeElement;\n }\n\n /**\n Binds HTMLElement events to mask internal events\n */\n override bindEvents (handlers: {[key in ElementEvent]: EventListener}) {\n (Object.keys(handlers) as Array)\n .forEach(event => this._toggleEventHandler(HTMLMaskElement.EVENTS_MAP[event], handlers[event]));\n }\n\n /**\n Unbinds HTMLElement events to mask internal events\n */\n override unbindEvents () {\n Object.keys(this._handlers)\n .forEach(event => this._toggleEventHandler(event));\n }\n\n _toggleEventHandler (event: string, handler?: EventListener): void {\n if (this._handlers[event]) {\n this.input.removeEventListener(event, this._handlers[event]);\n delete this._handlers[event];\n }\n\n if (handler) {\n this.input.addEventListener(event, handler);\n this._handlers[event] = handler;\n }\n }\n}\n\n\nIMask.HTMLMaskElement = HTMLMaskElement;\n","import HTMLMaskElement from './html-mask-element';\nimport IMask from '../core/holder';\n\nexport\ntype InputElement = HTMLTextAreaElement | HTMLInputElement;\n\n/** Bridge between InputElement and {@link Masked} */\nexport default\nclass HTMLInputMaskElement extends HTMLMaskElement {\n /** InputElement to use mask on */\n declare input: InputElement;\n\n constructor (input: InputElement) {\n super(input);\n this.input = input;\n this._handlers = {};\n }\n\n /** Returns InputElement selection start */\n override get _unsafeSelectionStart (): number | null {\n return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;\n }\n\n /** Returns InputElement selection end */\n override get _unsafeSelectionEnd (): number | null {\n return this.input.selectionEnd;\n }\n\n /** Sets InputElement selection */\n _unsafeSelect (start: number, end: number) {\n this.input.setSelectionRange(start, end);\n }\n\n override get value (): string {\n return this.input.value;\n }\n override set value (value: string) {\n this.input.value = value;\n }\n}\n\n\nIMask.HTMLMaskElement = HTMLMaskElement;\n","import HTMLMaskElement from './html-mask-element';\nimport IMask from '../core/holder';\n\n\nexport default\nclass HTMLContenteditableMaskElement extends HTMLMaskElement {\n declare input: HTMLElement;\n /** Returns HTMLElement selection start */\n override get _unsafeSelectionStart (): number | null {\n const root = this.rootElement;\n const selection = root.getSelection && root.getSelection();\n const anchorOffset = selection && selection.anchorOffset;\n const focusOffset = selection && selection.focusOffset;\n if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {\n return anchorOffset;\n }\n return focusOffset;\n }\n\n /** Returns HTMLElement selection end */\n override get _unsafeSelectionEnd (): number | null {\n const root = this.rootElement;\n const selection = root.getSelection && root.getSelection();\n const anchorOffset = selection && selection.anchorOffset;\n const focusOffset = selection && selection.focusOffset;\n if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {\n return anchorOffset;\n }\n return focusOffset;\n }\n\n /** Sets HTMLElement selection */\n override _unsafeSelect (start: number, end: number) {\n if (!this.rootElement.createRange) return;\n\n const range = this.rootElement.createRange();\n range.setStart(this.input.firstChild || this.input, start);\n range.setEnd(this.input.lastChild || this.input, end);\n const root = this.rootElement;\n const selection = root.getSelection && root.getSelection();\n if (selection) {\n selection.removeAllRanges();\n selection.addRange(range);\n }\n }\n\n /** HTMLElement value */\n override get value (): string {\n return this.input.textContent || '';\n }\n override set value (value: string) {\n this.input.textContent = value;\n }\n}\n\n\nIMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;\n","import { objectIncludes, DIRECTION, type Selection } from '../core/utils';\nimport ActionDetails from '../core/action-details';\nimport createMask, { type UpdateOpts, maskedClass, type FactoryArg, type FactoryReturnMasked } from '../masked/factory';\nimport Masked from '../masked/base';\nimport MaskElement from './mask-element';\nimport HTMLInputMaskElement, { type InputElement } from './html-input-mask-element';\nimport HTMLContenteditableMaskElement from './html-contenteditable-mask-element';\nimport IMask from '../core/holder';\n\n\nexport\ntype InputMaskElement = MaskElement | InputElement | HTMLElement;\n\nexport\ntype InputMaskEventListener = (e?: InputEvent) => void;\n\n/** Listens to element events and controls changes between element and {@link Masked} */\nexport default\nclass InputMask {\n /**\n View element\n */\n declare el: MaskElement;\n\n /** Internal {@link Masked} model */\n declare masked: FactoryReturnMasked;\n\n declare _listeners: Record>;\n declare _value: string;\n declare _changingCursorPos: number;\n declare _unmaskedValue: string;\n declare _selection: Selection;\n declare _cursorChanging?: ReturnType;\n declare _inputEvent?: InputEvent;\n\n constructor (el: InputMaskElement, opts: Opts) {\n this.el =\n (el instanceof MaskElement) ? el :\n (el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA') ? new HTMLContenteditableMaskElement(el) :\n new HTMLInputMaskElement(el as InputElement);\n\n this.masked = createMask(opts);\n\n this._listeners = {};\n this._value = '';\n this._unmaskedValue = '';\n\n this._saveSelection = this._saveSelection.bind(this);\n this._onInput = this._onInput.bind(this);\n this._onChange = this._onChange.bind(this);\n this._onDrop = this._onDrop.bind(this);\n this._onFocus = this._onFocus.bind(this);\n this._onClick = this._onClick.bind(this);\n this.alignCursor = this.alignCursor.bind(this);\n this.alignCursorFriendly = this.alignCursorFriendly.bind(this);\n\n this._bindEvents();\n\n // refresh\n this.updateValue();\n this._onChange();\n }\n\n maskEquals (mask: any): boolean {\n return mask == null || this.masked?.maskEquals(mask);\n }\n\n /** Masked */\n get mask (): FactoryReturnMasked['mask'] {\n return this.masked.mask;\n }\n set mask (mask: any) {\n if (this.maskEquals(mask)) return;\n\n if (!((mask as Masked) instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask as Masked)) {\n // TODO \"any\" no idea\n this.masked.updateOptions({ mask } as any);\n return;\n }\n\n const masked = (mask instanceof IMask.Masked ? mask : createMask({ mask } as Opts)) as FactoryReturnMasked;\n masked.unmaskedValue = this.masked.unmaskedValue;\n this.masked = masked;\n }\n\n /** Raw value */\n get value (): string {\n return this._value;\n }\n\n set value (str: string) {\n if (this.value === str) return;\n\n this.masked.value = str;\n this.updateControl();\n this.alignCursor();\n }\n\n /** Unmasked value */\n get unmaskedValue (): string {\n return this._unmaskedValue;\n }\n\n set unmaskedValue (str: string) {\n if (this.unmaskedValue === str) return;\n\n this.masked.unmaskedValue = str;\n this.updateControl();\n this.alignCursor();\n }\n\n /** Typed unmasked value */\n get typedValue (): FactoryReturnMasked['typedValue'] {\n return this.masked.typedValue;\n }\n\n set typedValue (val: FactoryReturnMasked['typedValue']) {\n if (this.masked.typedValueEquals(val)) return;\n\n this.masked.typedValue = val;\n this.updateControl();\n this.alignCursor();\n }\n\n /** Display value */\n get displayValue (): string {\n return this.masked.displayValue;\n }\n\n /** Starts listening to element events */\n _bindEvents () {\n this.el.bindEvents({\n selectionChange: this._saveSelection,\n input: this._onInput,\n drop: this._onDrop,\n click: this._onClick,\n focus: this._onFocus,\n commit: this._onChange,\n });\n }\n\n /** Stops listening to element events */\n _unbindEvents () {\n if (this.el) this.el.unbindEvents();\n }\n\n /** Fires custom event */\n _fireEvent (ev: string, e?: InputEvent) {\n const listeners = this._listeners[ev];\n if (!listeners) return;\n\n listeners.forEach(l => l(e));\n }\n\n /** Current selection start */\n get selectionStart (): number {\n return this._cursorChanging ?\n this._changingCursorPos :\n\n this.el.selectionStart;\n }\n\n /** Current cursor position */\n get cursorPos (): number {\n return this._cursorChanging ?\n this._changingCursorPos :\n\n this.el.selectionEnd;\n }\n set cursorPos (pos: number) {\n if (!this.el || !this.el.isActive) return;\n\n this.el.select(pos, pos);\n this._saveSelection();\n }\n\n /** Stores current selection */\n _saveSelection (/* ev */) {\n if (this.displayValue !== this.el.value) {\n console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.'); // eslint-disable-line no-console\n }\n this._selection = {\n start: this.selectionStart,\n end: this.cursorPos,\n };\n }\n\n /** Syncronizes model value from view */\n updateValue () {\n this.masked.value = this.el.value;\n this._value = this.masked.value;\n }\n\n /** Syncronizes view from model value, fires change events */\n updateControl () {\n const newUnmaskedValue = this.masked.unmaskedValue;\n const newValue = this.masked.value;\n const newDisplayValue = this.displayValue;\n const isChanged = (this.unmaskedValue !== newUnmaskedValue ||\n this.value !== newValue);\n\n this._unmaskedValue = newUnmaskedValue;\n this._value = newValue;\n\n if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue;\n if (isChanged) this._fireChangeEvents();\n }\n\n /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */\n updateOptions(opts: UpdateOpts) {\n const { mask, ...restOpts } = opts;\n\n const updateMask = !this.maskEquals(mask);\n const updateOpts = !objectIncludes(this.masked, restOpts);\n\n if (updateMask) this.mask = mask;\n if (updateOpts) this.masked.updateOptions(restOpts); // TODO\n\n if (updateMask || updateOpts) this.updateControl();\n }\n\n /** Updates cursor */\n updateCursor (cursorPos: number) {\n if (cursorPos == null) return;\n this.cursorPos = cursorPos;\n\n // also queue change cursor for mobile browsers\n this._delayUpdateCursor(cursorPos);\n }\n\n /** Delays cursor update to support mobile browsers */\n _delayUpdateCursor (cursorPos: number) {\n this._abortUpdateCursor();\n this._changingCursorPos = cursorPos;\n this._cursorChanging = setTimeout(() => {\n if (!this.el) return; // if was destroyed\n this.cursorPos = this._changingCursorPos;\n this._abortUpdateCursor();\n }, 10);\n }\n\n /** Fires custom events */\n _fireChangeEvents () {\n this._fireEvent('accept', this._inputEvent);\n if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);\n }\n\n /** Aborts delayed cursor update */\n _abortUpdateCursor () {\n if (this._cursorChanging) {\n clearTimeout(this._cursorChanging);\n delete this._cursorChanging;\n }\n }\n\n /** Aligns cursor to nearest available position */\n alignCursor () {\n this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));\n }\n\n /** Aligns cursor only if selection is empty */\n alignCursorFriendly () {\n if (this.selectionStart !== this.cursorPos) return; // skip if range is selected\n this.alignCursor();\n }\n\n /** Adds listener on custom event */\n on (ev: string, handler: InputMaskEventListener): this {\n if (!this._listeners[ev]) this._listeners[ev] = [];\n this._listeners[ev].push(handler);\n return this;\n }\n\n /** Removes custom event listener */\n off (ev: string, handler: InputMaskEventListener): this {\n if (!this._listeners[ev]) return this;\n if (!handler) {\n delete this._listeners[ev];\n return this;\n }\n const hIndex = this._listeners[ev].indexOf(handler);\n if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);\n return this;\n }\n\n /** Handles view input event */\n _onInput (e: InputEvent): void {\n this._inputEvent = e;\n this._abortUpdateCursor();\n\n // fix strange IE behavior\n if (!this._selection) return this.updateValue();\n\n const details = new ActionDetails({\n // new state\n value: this.el.value,\n cursorPos: this.cursorPos,\n\n // old state\n oldValue: this.displayValue,\n oldSelection: this._selection,\n });\n\n const oldRawValue = this.masked.rawInputValue;\n\n const offset = this.masked.splice(\n details.startChangePos,\n details.removed.length,\n details.inserted,\n details.removeDirection,\n { input: true, raw: true },\n ).offset;\n\n // force align in remove direction only if no input chars were removed\n // otherwise we still need to align with NONE (to get out from fixed symbols for instance)\n const removeDirection = oldRawValue === this.masked.rawInputValue ?\n details.removeDirection :\n DIRECTION.NONE;\n\n let cursorPos = this.masked.nearestInputPos(\n details.startChangePos + offset,\n removeDirection,\n );\n if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);\n\n this.updateControl();\n this.updateCursor(cursorPos);\n delete this._inputEvent;\n }\n\n /** Handles view change event and commits model value */\n _onChange () {\n if (this.displayValue !== this.el.value) {\n this.updateValue();\n }\n this.masked.doCommit();\n this.updateControl();\n this._saveSelection();\n }\n\n /** Handles view drop event, prevents by default */\n _onDrop (ev: Event) {\n ev.preventDefault();\n ev.stopPropagation();\n }\n\n /** Restore last selection on focus */\n _onFocus (ev: Event) {\n this.alignCursorFriendly();\n }\n\n /** Restore last selection on focus */\n _onClick (ev: Event) {\n this.alignCursorFriendly();\n }\n\n /** Unbind view events and removes element reference */\n destroy () {\n this._unbindEvents();\n (this._listeners as any).length = 0;\n delete (this as any).el;\n }\n}\n\n\nIMask.InputMask = InputMask;\n","import IMask from \"./holder\";\n\n\nexport\ntype ChangeDetailsOptions = Pick;\n\n/** Provides details of changing model value */\nexport default\nclass ChangeDetails {\n /** Inserted symbols */\n declare inserted: string;\n /** Can skip chars */\n declare skip: boolean;\n /** Additional offset if any changes occurred before tail */\n declare tailShift: number;\n /** Raw inserted is used by dynamic mask */\n declare rawInserted: string;\n\n static normalize (prep: string | [string, ChangeDetails]): [string, ChangeDetails] {\n return Array.isArray(prep) ? prep : [\n prep,\n new ChangeDetails(),\n ];\n }\n\n constructor (details?: Partial) {\n Object.assign(this, {\n inserted: '',\n rawInserted: '',\n skip: false,\n tailShift: 0,\n }, details);\n }\n\n /** Aggregate changes */\n aggregate (details: ChangeDetails): this {\n this.rawInserted += details.rawInserted;\n this.skip = this.skip || details.skip;\n this.inserted += details.inserted;\n this.tailShift += details.tailShift;\n return this;\n }\n\n /** Total offset considering all changes */\n get offset (): number {\n return this.tailShift + this.inserted.length;\n }\n}\n\n\nIMask.ChangeDetails = ChangeDetails;\n","import type { TailDetails, AppendTail } from './tail-details';\nimport type ChangeDetails from './change-details';\n\n\ntype ContinuousTailState = Pick;\n\n/** Provides details of continuous extracted tail */\nexport default\nclass ContinuousTailDetails implements TailDetails {\n /** Tail value as string */\n declare value: string;\n /** Tail start position */\n declare from: number;\n /** Start position */\n declare stop?: number;\n\n constructor (value: string='', from: number=0, stop?: number) {\n this.value = value;\n this.from = from;\n this.stop = stop;\n }\n\n toString (): string { return this.value; }\n\n extend (tail: string | TailDetails): void {\n this.value += String(tail);\n }\n\n appendTo (masked: AppendTail): ChangeDetails {\n return masked.append(this.toString(), { tail: true })\n .aggregate(masked._appendPlaceholder());\n }\n\n get state (): ContinuousTailState {\n return {\n value: this.value,\n from: this.from,\n stop: this.stop,\n };\n }\n\n set state (state: ContinuousTailState) {\n Object.assign(this, state);\n }\n\n unshift (beforePos?: number): string {\n if (!this.value.length || (beforePos != null && this.from >= beforePos)) return '';\n\n const shiftChar = this.value[0];\n this.value = this.value.slice(1);\n return shiftChar;\n }\n\n shift (): string {\n if (!this.value.length) return '';\n\n const shiftChar = this.value[this.value.length-1];\n this.value = this.value.slice(0, -1);\n return shiftChar;\n }\n}\n","import ChangeDetails from '../core/change-details';\nimport ContinuousTailDetails from '../core/continuous-tail-details';\nimport { type Direction, DIRECTION, isString, forceDirection } from '../core/utils';\nimport { type TailDetails } from '../core/tail-details';\nimport IMask from '../core/holder';\n\n\nexport\ntype MaskedState = {\n _value: string,\n _rawInputValue: string,\n};\n\n/** Append flags */\nexport\ntype AppendFlags = {\n input?: boolean,\n tail?: boolean,\n raw?: boolean,\n _beforeTailState?: State,\n};\n\n/** Extract flags */\nexport\ntype ExtractFlags = {\n raw?: boolean\n};\n\n// see https://github.com/microsoft/TypeScript/issues/6223\n\nexport\ntype MaskedOptions = Partial>;\n\n\n/** Provides common masking stuff */\nexport default\nabstract class Masked {\n static DEFAULTS: Record = {\n skipInvalid: true,\n } satisfies Partial;\n static EMPTY_VALUES: Array = [undefined, null, ''];\n\n /** */\n declare mask: unknown;\n /** */\n declare parent?: Masked;\n /** Transforms value before mask processing */\n declare prepare?: (chars: string, masked: Masked, flags: AppendFlags) => string | [string, ChangeDetails];\n /** Transforms each char before mask processing */\n declare prepareChar?: (chars: string, masked: Masked, flags: AppendFlags) => string | [string, ChangeDetails];\n /** Validates if value is acceptable */\n declare validate?: (value: string, masked: Masked, flags: AppendFlags) => boolean;\n /** Does additional processing at the end of editing */\n declare commit?: (value: string, masked: Masked) => void;\n /** Format typed value to string */\n declare format?: (value: Value, masked: Masked) => string;\n /** Parse string to get typed value */\n declare parse?: (str: string, masked: Masked) => Value;\n /** Enable characters overwriting */\n abstract overwrite?: boolean | 'shift' | undefined;\n /** */\n abstract eager?: boolean | 'remove' | 'append' | undefined;\n /** */\n abstract skipInvalid?: boolean | undefined;\n\n /** */\n declare _initialized: boolean;\n\n declare _value: string;\n declare _refreshing?: boolean;\n declare _isolated?: boolean;\n\n constructor (opts: MaskedOptions) {\n this._value = '';\n this._update({\n ...Masked.DEFAULTS,\n ...opts,\n });\n this._initialized = true;\n }\n\n /** Sets and applies new options */\n updateOptions (opts: Partial) {\n if (!Object.keys(opts).length) return;\n\n this.withValueRefresh(this._update.bind(this, opts));\n }\n\n /** Sets new options */\n _update (opts: Partial) {\n Object.assign(this, opts);\n }\n\n /** Mask state */\n get state (): MaskedState {\n return {\n _value: this.value,\n _rawInputValue: this.rawInputValue,\n };\n }\n\n set state (state: MaskedState) {\n this._value = state._value;\n }\n\n /** Resets value */\n reset () {\n this._value = '';\n }\n\n get value (): string {\n return this._value;\n }\n\n set value (value: string) {\n this.resolve(value, { input: true });\n }\n\n /** Resolve new value */\n resolve (value: string, flags: AppendFlags={ input: true }): void {\n this.reset();\n this.append(value, flags, '');\n this.doCommit();\n }\n\n get unmaskedValue (): string {\n return this.value;\n }\n\n set unmaskedValue (value: string) {\n this.resolve(value, {});\n }\n\n get typedValue (): Value {\n return this.parse ? this.parse(this.value, this) : this.unmaskedValue as Value;\n }\n\n set typedValue (value: Value) {\n if (this.format) {\n this.value = this.format(value, this);\n } else {\n this.unmaskedValue = String(value);\n }\n }\n\n /** Value that includes raw user input */\n get rawInputValue (): string {\n return this.extractInput(0, this.displayValue.length, {raw: true});\n }\n\n set rawInputValue (value: string) {\n this.resolve(value, { raw: true });\n }\n\n get displayValue (): string {\n return this.value;\n }\n\n get isComplete (): boolean {\n return true;\n }\n\n get isFilled (): boolean {\n return this.isComplete;\n }\n\n /** Finds nearest input position in direction */\n nearestInputPos (cursorPos: number, direction?: Direction): number {\n return cursorPos;\n }\n\n totalInputPositions (fromPos: number=0, toPos: number=this.displayValue.length): number {\n return Math.min(this.displayValue.length, toPos - fromPos);\n }\n\n /** Extracts value in range considering flags */\n extractInput (fromPos: number=0, toPos: number=this.displayValue.length, flags?: ExtractFlags): string {\n return this.displayValue.slice(fromPos, toPos);\n }\n\n /** Extracts tail in range */\n extractTail (fromPos: number=0, toPos: number=this.displayValue.length): TailDetails {\n return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);\n }\n\n /** Appends tail */\n appendTail (tail: string | String | TailDetails): ChangeDetails {\n if (isString(tail)) tail = new ContinuousTailDetails(String(tail));\n\n return (tail as TailDetails).appendTo(this);\n }\n\n /** Appends char */\n _appendCharRaw (ch: string, flags: AppendFlags={}): ChangeDetails {\n if (!ch) return new ChangeDetails();\n\n this._value += ch;\n return new ChangeDetails({\n inserted: ch,\n rawInserted: ch,\n });\n }\n\n /** Appends char */\n _appendChar (ch: string, flags: AppendFlags={}, checkTail?: TailDetails): ChangeDetails {\n const consistentState: MaskedState = this.state;\n let details: ChangeDetails;\n [ch, details] = this.doPrepareChar(ch, flags);\n\n details = details.aggregate(this._appendCharRaw(ch, flags));\n\n if (details.inserted) {\n let consistentTail;\n let appended = this.doValidate(flags) !== false;\n\n if (appended && checkTail != null) {\n // validation ok, check tail\n const beforeTailState = this.state;\n if (this.overwrite === true) {\n consistentTail = checkTail.state;\n checkTail.unshift(this.displayValue.length - details.tailShift);\n }\n\n let tailDetails = this.appendTail(checkTail);\n appended = tailDetails.rawInserted === checkTail.toString();\n\n // not ok, try shift\n if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {\n this.state = beforeTailState;\n consistentTail = checkTail.state;\n checkTail.shift();\n\n tailDetails = this.appendTail(checkTail);\n appended = tailDetails.rawInserted === checkTail.toString();\n }\n\n // if ok, rollback state after tail\n if (appended && tailDetails.inserted) this.state = beforeTailState;\n }\n\n // revert all if something went wrong\n if (!appended) {\n details = new ChangeDetails();\n this.state = consistentState;\n if (checkTail && consistentTail) checkTail.state = consistentTail;\n }\n }\n return details;\n }\n\n /** Appends optional placeholder at the end */\n _appendPlaceholder (): ChangeDetails {\n return new ChangeDetails();\n }\n\n /** Appends optional eager placeholder at the end */\n _appendEager (): ChangeDetails {\n return new ChangeDetails();\n }\n\n /** Appends symbols considering flags */\n append (str: string, flags?: AppendFlags, tail?: string | String | TailDetails): ChangeDetails {\n if (!isString(str)) throw new Error('value should be string');\n const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail as TailDetails;\n if (flags?.tail) flags._beforeTailState = this.state;\n\n let details;\n [str, details] = this.doPrepare(str, flags);\n\n for (let ci=0; ci(fn: () => T): T {\n if (this._refreshing || !this._initialized) return fn();\n this._refreshing = true;\n\n const rawInput = this.rawInputValue;\n const value = this.value;\n\n const ret = fn();\n\n this.rawInputValue = rawInput;\n // append lost trailing chars at the end\n if (this.value && this.value !== value && value.indexOf(this.value) === 0) {\n this.append(value.slice(this.displayValue.length), {}, '');\n }\n\n delete this._refreshing;\n return ret;\n }\n\n runIsolated(fn: (masked: this) => T): T {\n if (this._isolated || !this._initialized) return fn(this);\n this._isolated = true;\n const state = this.state;\n\n const ret = fn(this);\n\n this.state = state;\n delete this._isolated;\n\n return ret;\n }\n\n doSkipInvalid (ch: string, flags: AppendFlags={}, checkTail?: TailDetails): boolean {\n return Boolean(this.skipInvalid);\n }\n\n /** Prepares string before mask processing */\n doPrepare (str: string, flags: AppendFlags={}): [string, ChangeDetails] {\n return ChangeDetails.normalize(this.prepare ?\n this.prepare(str, this, flags) :\n str);\n }\n\n /** Prepares each char before mask processing */\n doPrepareChar (str: string, flags: AppendFlags={}): [string, ChangeDetails] {\n return ChangeDetails.normalize(this.prepareChar ?\n this.prepareChar(str, this, flags) :\n str);\n }\n\n /** Validates if value is acceptable */\n doValidate (flags: AppendFlags): boolean {\n return (!this.validate || this.validate(this.value, this, flags)) &&\n (!this.parent || this.parent.doValidate(flags));\n }\n\n /** Does additional processing at the end of editing */\n doCommit () {\n if (this.commit) this.commit(this.value, this);\n }\n\n splice (start: number, deleteCount: number, inserted: string, removeDirection: Direction = DIRECTION.NONE, flags: AppendFlags = { input: true }): ChangeDetails {\n const tailPos: number = start + deleteCount;\n const tail: TailDetails = this.extractTail(tailPos);\n\n const eagerRemove = this.eager === true || this.eager === 'remove';\n\n let oldRawValue;\n if (eagerRemove) {\n removeDirection = forceDirection(removeDirection);\n oldRawValue = this.extractInput(0, tailPos, {raw: true});\n }\n\n let startChangePos: number = start;\n const details: ChangeDetails = new ChangeDetails();\n\n // if it is just deletion without insertion\n if (removeDirection !== DIRECTION.NONE) {\n startChangePos = this.nearestInputPos(start,\n deleteCount > 1 && start !== 0 && !eagerRemove ?\n DIRECTION.NONE :\n removeDirection\n );\n\n // adjust tailShift if start was aligned\n details.tailShift = startChangePos - start;\n }\n\n details.aggregate(this.remove(startChangePos));\n\n if (eagerRemove && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {\n if (removeDirection === DIRECTION.FORCE_LEFT) {\n let valLength;\n while (oldRawValue === this.rawInputValue && (valLength = this.displayValue.length)) {\n details\n .aggregate(new ChangeDetails({ tailShift: -1 }))\n .aggregate(this.remove(valLength-1));\n }\n } else if (removeDirection === DIRECTION.FORCE_RIGHT) {\n tail.unshift();\n }\n }\n\n return details.aggregate(this.append(inserted, flags, tail));\n }\n\n maskEquals (mask: any): boolean {\n return this.mask === mask;\n }\n\n typedValueEquals (value: any): boolean {\n const tval = this.typedValue;\n\n return value === tval ||\n Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) ||\n (this.format ? this.format(value, this) === this.format(this.typedValue, this) : false);\n }\n}\n\n\nIMask.Masked = Masked;\n","import type { TailDetails, AppendTail } from '../../core/tail-details';\nimport ChangeDetails from '../../core/change-details';\nimport { isString } from '../../core/utils';\nimport ContinuousTailDetails from '../../core/continuous-tail-details';\nimport IMask from '../../core/holder';\nimport type MaskedPattern from '../pattern';\n\n\nexport\ntype ChunksTailState = Pick & { chunks: Array };\n\nexport default\nclass ChunksTailDetails implements TailDetails {\n declare chunks: Array;\n declare from: number;\n declare stop?: number;\n /** */\n declare blockIndex?: number;\n\n constructor (chunks: Array=[], from: number=0) {\n this.chunks = chunks;\n this.from = from;\n }\n\n toString (): string {\n return this.chunks.map(String).join('');\n }\n\n extend (tailChunk: string | String | TailDetails): void {\n if (!String(tailChunk)) return;\n tailChunk = (isString(tailChunk) ? new ContinuousTailDetails(String(tailChunk)) : tailChunk) as TailDetails;\n\n const lastChunk = this.chunks[this.chunks.length-1];\n const extendLast = lastChunk &&\n // if stops are same or tail has no stop\n (lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&\n // if tail chunk goes just after last chunk\n tailChunk.from === (lastChunk.from + lastChunk.toString().length);\n\n if (tailChunk instanceof ContinuousTailDetails) {\n // check the ability to extend previous chunk\n if (extendLast) {\n // extend previous chunk\n lastChunk.extend(tailChunk.toString());\n } else {\n // append new chunk\n this.chunks.push(tailChunk);\n }\n } else if (tailChunk instanceof ChunksTailDetails) {\n if (tailChunk.stop == null) {\n // unwrap floating chunks to parent, keeping `from` pos\n let firstTailChunk;\n while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {\n firstTailChunk = tailChunk.chunks.shift() as TailDetails; // not possible to be `undefined` because length was checked above\n firstTailChunk.from += tailChunk.from;\n this.extend(firstTailChunk);\n }\n }\n\n // if tail chunk still has value\n if (tailChunk.toString()) {\n // if chunks contains stops, then popup stop to container\n tailChunk.stop = tailChunk.blockIndex;\n this.chunks.push(tailChunk);\n }\n }\n }\n\n appendTo (masked: AppendTail | MaskedPattern): ChangeDetails {\n if (!(masked instanceof IMask.MaskedPattern)) {\n const tail = new ContinuousTailDetails(this.toString());\n return tail.appendTo(masked);\n }\n\n const details = new ChangeDetails();\n\n for (let ci=0; ci < this.chunks.length && !details.skip; ++ci) {\n const chunk = this.chunks[ci];\n\n const lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);\n const stop = chunk.stop;\n let chunkBlock;\n if (stop != null &&\n // if block not found or stop is behind lastBlock\n (!lastBlockIter || lastBlockIter.index <= stop)\n ) {\n if (\n chunk instanceof ChunksTailDetails ||\n // for continuous block also check if stop is exist\n masked._stops.indexOf(stop) >= 0\n ) {\n const phDetails = masked._appendPlaceholder(stop);\n details.aggregate(phDetails);\n }\n chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];\n }\n\n if (chunkBlock) {\n const tailDetails = chunkBlock.appendTail(chunk);\n tailDetails.skip = false; // always ignore skip, it will be set on last\n details.aggregate(tailDetails);\n masked._value += tailDetails.inserted;\n\n // get not inserted chars\n const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);\n if (remainChars) details.aggregate(masked.append(remainChars, { tail: true }));\n } else {\n details.aggregate(masked.append(chunk.toString(), { tail: true }));\n }\n }\n\n return details;\n }\n\n get state (): ChunksTailState {\n return {\n chunks: this.chunks.map(c => c.state),\n from: this.from,\n stop: this.stop,\n blockIndex: this.blockIndex,\n };\n }\n\n set state (state: ChunksTailState) {\n const { chunks, ...props } = state;\n Object.assign(this, props);\n this.chunks = chunks.map(cstate => {\n const chunk = \"chunks\" in cstate ?\n new ChunksTailDetails() :\n new ContinuousTailDetails();\n chunk.state = cstate;\n return chunk;\n });\n }\n\n unshift (beforePos?: number): string {\n if (!this.chunks.length || (beforePos != null && this.from >= beforePos)) return '';\n\n const chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;\n let ci=0;\n while (ci < this.chunks.length) {\n const chunk = this.chunks[ci];\n const shiftChar = chunk.unshift(chunkShiftPos);\n\n if (chunk.toString()) {\n // chunk still contains value\n // but not shifted - means no more available chars to shift\n if (!shiftChar) break;\n ++ci;\n } else {\n // clean if chunk has no value\n this.chunks.splice(ci, 1);\n }\n\n if (shiftChar) return shiftChar;\n }\n\n return '';\n }\n\n shift (): string {\n if (!this.chunks.length) return '';\n\n let ci=this.chunks.length-1;\n while (0 <= ci) {\n const chunk = this.chunks[ci];\n const shiftChar = chunk.shift();\n\n if (chunk.toString()) {\n // chunk still contains value\n // but not shifted - means no more available chars to shift\n if (!shiftChar) break;\n --ci;\n } else {\n // clean if chunk has no value\n this.chunks.splice(ci, 1);\n }\n\n if (shiftChar) return shiftChar;\n }\n\n return '';\n }\n}\n","import { DIRECTION } from '../../core/utils';\nimport type MaskedPattern from '../pattern';\nimport type PatternBlock from './block';\n\n\ntype PatternCursorState = { offset: number, index: number, ok: boolean };\n\nexport default\nclass PatternCursor {\n declare masked: MaskedPattern;\n declare offset: number;\n declare index: number;\n declare ok: boolean;\n declare _log: PatternCursorState[];\n\n constructor (masked: MaskedPattern, pos: number) {\n this.masked = masked;\n this._log = [];\n\n const { offset, index } = masked._mapPosToBlock(pos) || (\n pos < 0 ?\n // first\n { index: 0, offset: 0 } :\n // last\n { index: this.masked._blocks.length, offset: 0 }\n );\n this.offset = offset;\n this.index = index;\n this.ok = false;\n }\n\n get block (): PatternBlock {\n return this.masked._blocks[this.index];\n }\n\n get pos (): number {\n return this.masked._blockStartPos(this.index) + this.offset;\n }\n\n get state (): PatternCursorState {\n return { index: this.index, offset: this.offset, ok: this.ok };\n }\n\n set state (s: PatternCursorState) {\n Object.assign(this, s);\n }\n\n pushState () {\n this._log.push(this.state);\n }\n\n popState (): PatternCursorState | undefined {\n const s = this._log.pop();\n if (s) this.state = s;\n return s;\n }\n\n bindBlock () {\n if (this.block) return;\n if (this.index < 0) {\n this.index = 0;\n this.offset = 0;\n }\n if (this.index >= this.masked._blocks.length) {\n this.index = this.masked._blocks.length - 1;\n this.offset = (this.block as unknown as PatternBlock).displayValue.length; // TODO this is stupid type error, `block` depends on index that was changed above\n }\n }\n\n _pushLeft(fn: () => boolean | undefined): boolean {\n this.pushState();\n for (this.bindBlock(); 0<=this.index; --this.index, this.offset=this.block?.displayValue.length || 0) {\n if (fn()) return this.ok = true;\n }\n\n return this.ok = false;\n }\n\n _pushRight (fn: () => boolean | undefined): boolean {\n this.pushState();\n for (this.bindBlock(); this.index {\n if (this.block.isFixed || !this.block.value) return;\n\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_LEFT);\n if (this.offset !== 0) return true;\n });\n }\n\n pushLeftBeforeInput (): boolean {\n // cases:\n // filled input: 00|\n // optional empty input: 00[]|\n // nested block: XX<[]>|\n return this._pushLeft(() => {\n if (this.block.isFixed) return;\n\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);\n return true;\n });\n }\n\n pushLeftBeforeRequired (): boolean {\n return this._pushLeft(() => {\n if (this.block.isFixed || this.block.isOptional && !this.block.value) return;\n\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);\n return true;\n });\n }\n\n pushRightBeforeFilled (): boolean {\n return this._pushRight(() => {\n if (this.block.isFixed || !this.block.value) return;\n\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_RIGHT);\n if (this.offset !== this.block.value.length) return true;\n });\n }\n\n pushRightBeforeInput (): boolean {\n return this._pushRight(() => {\n if (this.block.isFixed) return;\n\n // const o = this.offset;\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);\n // HACK cases like (STILL DOES NOT WORK FOR NESTED)\n // aa|X\n // aaX_ - this will not work\n // if (o && o === this.offset && this.block instanceof PatternInputDefinition) continue;\n return true;\n });\n }\n\n pushRightBeforeRequired (): boolean {\n return this._pushRight(() => {\n if (this.block.isFixed || this.block.isOptional && !this.block.value) return;\n\n // TODO check |[*]XX_\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);\n return true;\n });\n }\n}\n","import ChangeDetails from '../../core/change-details';\nimport { DIRECTION, type Direction, isString } from '../../core/utils';\nimport { type TailDetails } from '../../core/tail-details';\nimport ContinuousTailDetails from '../../core/continuous-tail-details';\nimport { type ExtractFlags, type AppendFlags, type MaskedState } from '../base';\nimport type PatternBlock from './block';\n\n\nexport\ntype PatternFixedDefinitionOptions = Pick;\n\n\nexport default\nclass PatternFixedDefinition implements PatternBlock {\n /** */\n declare _value: string;\n /** */\n declare char: string;\n /** */\n declare isUnmasking?: boolean;\n /** */\n declare eager: boolean | 'remove' | 'append' | undefined;\n /** */\n declare _isRawInput?: boolean;\n /** */\n declare isFixed: boolean;\n\n constructor(opts: PatternFixedDefinitionOptions) {\n Object.assign(this, opts);\n this._value = '';\n this.isFixed = true;\n }\n\n get value (): string {\n return this._value;\n }\n\n get unmaskedValue (): string {\n return this.isUnmasking ? this.value : '';\n }\n\n get rawInputValue (): string {\n return this._isRawInput ? this.value : '';\n }\n\n get displayValue (): string {\n return this.value;\n }\n\n reset () {\n this._isRawInput = false;\n this._value = '';\n }\n\n remove (fromPos: number=0, toPos: number=this._value.length): ChangeDetails {\n this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);\n if (!this._value) this._isRawInput = false;\n\n return new ChangeDetails();\n }\n\n nearestInputPos (cursorPos: number, direction: Direction=DIRECTION.NONE): number {\n const minPos = 0;\n const maxPos = this._value.length;\n\n switch (direction) {\n case DIRECTION.LEFT:\n case DIRECTION.FORCE_LEFT:\n return minPos;\n case DIRECTION.NONE:\n case DIRECTION.RIGHT:\n case DIRECTION.FORCE_RIGHT:\n default:\n return maxPos;\n }\n }\n\n totalInputPositions (fromPos: number=0, toPos: number=this._value.length): number {\n return this._isRawInput ? (toPos - fromPos) : 0;\n }\n\n extractInput (fromPos: number=0, toPos: number=this._value.length, flags: ExtractFlags={}): string {\n return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';\n }\n\n get isComplete (): boolean {\n return true;\n }\n\n get isFilled (): boolean {\n return Boolean(this._value);\n }\n\n _appendChar (ch: string, flags: AppendFlags={}): ChangeDetails {\n const details = new ChangeDetails();\n\n if (this.isFilled) return details;\n const appendEager = this.eager === true || this.eager === 'append';\n\n const appended = this.char === ch;\n const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;\n if (isResolved) details.rawInserted = this.char;\n this._value = details.inserted = this.char;\n this._isRawInput = isResolved && (flags.raw || flags.input);\n\n return details;\n }\n\n _appendEager (): ChangeDetails {\n return this._appendChar(this.char, { tail: true });\n }\n\n _appendPlaceholder (): ChangeDetails {\n const details = new ChangeDetails();\n if (this.isFilled) return details;\n\n this._value = details.inserted = this.char;\n return details;\n }\n\n extractTail (): TailDetails {\n return new ContinuousTailDetails('');\n }\n\n appendTail (tail: string | String | TailDetails): ChangeDetails {\n if (isString(tail)) tail = new ContinuousTailDetails(String(tail));\n\n return (tail as TailDetails).appendTo(this);\n }\n\n append (str: string, flags?: AppendFlags, tail?: TailDetails): ChangeDetails {\n const details = this._appendChar(str[0], flags);\n\n if (tail != null) {\n details.tailShift += this.appendTail(tail).tailShift;\n }\n\n return details;\n }\n\n doCommit () {}\n\n get state (): MaskedState {\n return {\n _value: this._value,\n _rawInputValue: this.rawInputValue,\n };\n }\n\n set state (state: MaskedState) {\n this._value = state._value;\n this._isRawInput = Boolean(state._rawInputValue);\n }\n}\n","import createMask, { type FactoryArg, type FactoryOpts, type FactoryReturnMasked } from '../factory';\nimport type Masked from '../base';\nimport type MaskedPattern from '../pattern';\nimport { type TailDetails } from '../../core/tail-details';\nimport { type ExtractFlags, type AppendFlags, type MaskedState } from '../base';\nimport ChangeDetails from '../../core/change-details';\nimport { DIRECTION, type Direction } from '../../core/utils';\nimport type PatternBlock from './block';\n\n\nexport\ntype PatternInputDefinitionOptions =\n Omit &\n Partial>;\n\nexport\ntype PatternInputDefinitionState = MaskedState & {\n masked: FactoryReturnMasked['state'],\n isFilled: boolean,\n};\n\n\nexport default\nclass PatternInputDefinition implements PatternBlock> {\n static DEFAULT_DEFINITIONS: { [k: string]: RegExp } = {\n '0': /\\d/,\n '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\\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\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]/, // http://stackoverflow.com/a/22075070\n '*': /./\n }\n\n /** */\n declare readonly masked: FactoryReturnMasked;\n /** */\n declare parent: Masked;\n /** */\n declare isOptional: boolean;\n /** */\n declare isFilled: boolean;\n /** */\n declare lazy: MaskedPattern['lazy'];\n /** */\n declare eager: MaskedPattern['eager'];\n /** */\n declare placeholderChar: MaskedPattern['placeholderChar'];\n /** */\n declare displayChar: MaskedPattern['displayChar'];\n\n constructor(opts: PatternInputDefinitionOptions) {\n const { parent, isOptional, placeholderChar, displayChar, lazy, eager, ...maskOpts } = opts;\n\n this.masked = createMask(maskOpts as Opts);\n Object.assign(this, { parent, isOptional, placeholderChar, displayChar, lazy, eager });\n }\n\n reset () {\n this.isFilled = false;\n this.masked.reset();\n }\n\n remove (fromPos: number=0, toPos: number=this.value.length): ChangeDetails {\n if (fromPos === 0 && toPos >= 1) {\n this.isFilled = false;\n return this.masked.remove(fromPos, toPos);\n }\n\n return new ChangeDetails();\n }\n\n get value (): string {\n return this.masked.value ||\n (this.isFilled && !this.isOptional ?\n this.placeholderChar :\n '');\n }\n\n get unmaskedValue (): string {\n return this.masked.unmaskedValue;\n }\n\n get rawInputValue (): string {\n return this.masked.rawInputValue;\n }\n\n get displayValue (): string {\n return this.masked.value && this.displayChar || this.value;\n }\n\n get isComplete (): boolean {\n return Boolean(this.masked.value) || this.isOptional;\n }\n\n _appendChar (ch: string, flags: AppendFlags>={}): ChangeDetails {\n if (this.isFilled) return new ChangeDetails();\n\n const state = this.masked.state;\n // simulate input\n const details = this.masked._appendChar(ch, this.currentMaskFlags(flags));\n\n if (details.inserted && this.doValidate(flags) === false) {\n details.inserted = details.rawInserted = '';\n this.masked.state = state;\n }\n\n if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {\n details.inserted = this.placeholderChar;\n }\n details.skip = !details.inserted && !this.isOptional;\n this.isFilled = Boolean(details.inserted);\n\n return details;\n }\n\n append (str: string, flags?: AppendFlags>, tail?: TailDetails): ChangeDetails {\n // TODO probably should be done via _appendChar\n return this.masked.append(str, this.currentMaskFlags(flags), tail);\n }\n\n _appendPlaceholder (): ChangeDetails {\n const details = new ChangeDetails();\n\n if (this.isFilled || this.isOptional) return details;\n\n this.isFilled = true;\n details.inserted = this.placeholderChar;\n return details;\n }\n\n _appendEager (): ChangeDetails {\n return new ChangeDetails();\n }\n\n extractTail (fromPos?: number, toPos?: number): TailDetails {\n return this.masked.extractTail(fromPos, toPos);\n }\n\n appendTail (tail: string | TailDetails): ChangeDetails {\n return this.masked.appendTail(tail);\n }\n\n extractInput (fromPos: number=0, toPos: number=this.value.length, flags?: ExtractFlags): string {\n return this.masked.extractInput(fromPos, toPos, flags);\n }\n\n nearestInputPos (cursorPos: number, direction: Direction=DIRECTION.NONE): number {\n const minPos = 0;\n const maxPos = this.value.length;\n const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);\n\n switch (direction) {\n case DIRECTION.LEFT:\n case DIRECTION.FORCE_LEFT:\n return this.isComplete ? boundPos : minPos;\n case DIRECTION.RIGHT:\n case DIRECTION.FORCE_RIGHT:\n return this.isComplete ? boundPos : maxPos;\n case DIRECTION.NONE:\n default: return boundPos;\n }\n }\n\n totalInputPositions (fromPos: number=0, toPos: number=this.value.length): number {\n return this.value.slice(fromPos, toPos).length;\n }\n\n doValidate (flags: AppendFlags>): boolean {\n return this.masked.doValidate(this.currentMaskFlags(flags)) && (\n !this.parent || this.parent.doValidate(this.currentMaskFlags(flags)));\n }\n\n doCommit () {\n this.masked.doCommit();\n }\n\n get state (): PatternInputDefinitionState {\n return {\n _value: this.value,\n _rawInputValue: this.rawInputValue,\n masked: this.masked.state,\n isFilled: this.isFilled,\n };\n }\n\n set state (state: PatternInputDefinitionState) {\n this.masked.state = state.masked;\n this.isFilled = state.isFilled;\n }\n\n currentMaskFlags (flags?: AppendFlags>): AppendFlags {\n return {\n ...flags,\n _beforeTailState: flags?._beforeTailState?.masked || flags?._beforeTailState as unknown as MaskedState,\n };\n }\n}\n","import Masked, { type MaskedOptions } from './base';\nimport IMask from '../core/holder';\n\n\nexport\ntype MaskedRegExpOptions = MaskedOptions;\n\n/** Masking by RegExp */\nexport default\nclass MaskedRegExp extends Masked {\n /** */\n declare mask: RegExp;\n /** Enable characters overwriting */\n declare overwrite?: boolean | 'shift' | undefined;\n /** */\n declare eager?: boolean | 'remove' | 'append' | undefined;\n /** */\n declare skipInvalid?: boolean | undefined;\n\n override updateOptions (opts: Partial) {\n super.updateOptions(opts);\n }\n\n override _update (opts: Partial) {\n const mask = opts.mask;\n if (mask) opts.validate = (value) => value.search(mask) >= 0;\n super._update(opts);\n }\n}\n\n\nIMask.MaskedRegExp = MaskedRegExp;\n","import ChangeDetails from '../core/change-details';\nimport IMask from '../core/holder';\nimport { type TailDetails } from '../core/tail-details';\nimport { DIRECTION, type Direction } from '../core/utils';\nimport Masked, { type AppendFlags, type ExtractFlags, type MaskedOptions, type MaskedState } from './base';\nimport createMask, { type FactoryArg, normalizeOpts, type ExtendFactoryArgOptions, NormalizedOpts } from './factory';\nimport type PatternBlock from './pattern/block';\nimport ChunksTailDetails from './pattern/chunk-tail-details';\nimport PatternCursor from './pattern/cursor';\nimport PatternFixedDefinition from './pattern/fixed-definition';\nimport PatternInputDefinition from './pattern/input-definition';\nimport './regexp'; // support for default definitions which are regexp's\n\n\nexport\ntype MaskedPatternOptions<\n Value=string,\n M extends MaskedPattern=MaskedPattern,\n Props extends keyof M=never,\n> = MaskedOptions;\n\nexport\ntype Definitions = {\n [k: string]: FactoryArg,\n};\n\nexport\ntype MaskedPatternState = MaskedState & {\n _blocks: Array,\n};\n\nexport\ntype BlockPosData = {\n index: number,\n offset: number,\n};\n\n\n/** Pattern mask */\nexport default\nclass MaskedPattern extends Masked {\n static DEFAULTS: Record = {\n lazy: true,\n placeholderChar: '_'\n } satisfies Partial;\n static STOP_CHAR = '`';\n static ESCAPE_CHAR = '\\\\';\n static InputDefinition = PatternInputDefinition;\n static FixedDefinition = PatternFixedDefinition;\n\n declare mask: string;\n /** */\n declare blocks: { [key: string]: ExtendFactoryArgOptions<{ expose?: boolean }> };\n /** */\n declare definitions: Definitions;\n /** Single char for empty input */\n declare placeholderChar: string;\n /** Single char for filled input */\n declare displayChar: string;\n /** Show placeholder only when needed */\n declare lazy: boolean;\n /** Enable characters overwriting */\n declare overwrite?: boolean | 'shift' | undefined;\n /** */\n declare eager?: boolean | 'remove' | 'append' | undefined;\n /** */\n declare skipInvalid?: boolean | undefined;\n\n declare _blocks: Array;\n declare _maskedBlocks: {[key: string]: Array};\n declare _stops: Array;\n declare exposeBlock?: Masked;\n\n constructor (opts: MaskedPatternOptions) {\n super({\n ...MaskedPattern.DEFAULTS,\n ...opts,\n definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts?.definitions),\n } as MaskedOptions);\n }\n\n override updateOptions (opts: Partial>) {\n super.updateOptions(opts);\n }\n\n override _update (opts: Partial>) {\n opts.definitions = Object.assign({}, this.definitions, opts.definitions);\n super._update(opts);\n this._rebuildMask();\n }\n\n _rebuildMask () {\n const defs = this.definitions;\n this._blocks = []; this.exposeBlock = undefined;\n this._stops = [];\n this._maskedBlocks = {};\n\n const pattern = this.mask;\n if (!pattern || !defs) return;\n\n let unmaskingBlock = false;\n let optionalBlock = false;\n\n for (let i=0; i p.indexOf(bName) === 0);\n // order by key length\n bNames.sort((a, b) => b.length - a.length);\n // use block name with max length\n const bName = bNames[0];\n if (bName) {\n const { expose, ...blockOpts } = normalizeOpts(this.blocks[bName]) as NormalizedOpts & { expose?: boolean };\n const maskedBlock = createMask({\n lazy: this.lazy,\n eager: this.eager,\n placeholderChar: this.placeholderChar,\n displayChar: this.displayChar,\n overwrite: this.overwrite,\n ...blockOpts,\n parent: this,\n });\n\n if (maskedBlock) {\n this._blocks.push(maskedBlock);\n if (expose) this.exposeBlock = maskedBlock;\n\n // store block index\n if (!this._maskedBlocks[bName]) this._maskedBlocks[bName] = [];\n this._maskedBlocks[bName].push(this._blocks.length - 1);\n }\n\n i += bName.length - 1;\n continue;\n }\n }\n\n let char = pattern[i];\n let isInput = char in defs;\n\n if (char === MaskedPattern.STOP_CHAR) {\n this._stops.push(this._blocks.length);\n continue;\n }\n\n if (char === '{' || char === '}') {\n unmaskingBlock = !unmaskingBlock;\n continue;\n }\n\n if (char === '[' || char === ']') {\n optionalBlock = !optionalBlock;\n continue;\n }\n\n if (char === MaskedPattern.ESCAPE_CHAR) {\n ++i;\n char = pattern[i];\n if (!char) break;\n isInput = false;\n }\n\n const def = isInput ?\n new PatternInputDefinition({\n isOptional: optionalBlock,\n lazy: this.lazy,\n eager: this.eager,\n placeholderChar: this.placeholderChar,\n displayChar: this.displayChar,\n ...normalizeOpts(defs[char]),\n parent: this,\n }) as PatternBlock :\n new PatternFixedDefinition({\n char,\n eager: this.eager,\n isUnmasking: unmaskingBlock,\n });\n\n this._blocks.push(def);\n }\n }\n\n get state (): MaskedPatternState {\n return {\n ...super.state,\n _blocks: this._blocks.map(b => b.state),\n };\n }\n\n set state (state: MaskedPatternState) {\n const {_blocks, ...maskedState} = state;\n this._blocks.forEach((b, bi) => b.state = _blocks[bi]);\n super.state = maskedState;\n }\n\n reset () {\n super.reset();\n this._blocks.forEach(b => b.reset());\n }\n\n get isComplete (): boolean {\n return this.exposeBlock ? this.exposeBlock.isComplete :\n this._blocks.every(b => b.isComplete);\n }\n\n get isFilled (): boolean {\n return this._blocks.every(b => b.isFilled);\n }\n\n get isFixed (): boolean {\n return this._blocks.every(b => b.isFixed);\n }\n\n get isOptional (): boolean {\n return this._blocks.every(b => b.isOptional);\n }\n\n doCommit () {\n this._blocks.forEach(b => b.doCommit());\n super.doCommit();\n }\n\n get unmaskedValue (): string {\n return this.exposeBlock ? this.exposeBlock.unmaskedValue :\n this._blocks.reduce((str, b) => str += b.unmaskedValue, '');\n }\n\n set unmaskedValue (unmaskedValue: string) {\n if (this.exposeBlock) {\n const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);\n this.exposeBlock.unmaskedValue = unmaskedValue;\n this.appendTail(tail);\n this.doCommit();\n }\n else super.unmaskedValue = unmaskedValue;\n }\n\n get value (): string {\n return this.exposeBlock ? this.exposeBlock.value :\n // TODO return _value when not in change?\n this._blocks.reduce((str, b) => str += b.value, '');\n }\n\n set value (value: string) {\n if (this.exposeBlock) {\n const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);\n this.exposeBlock.value = value;\n this.appendTail(tail);\n this.doCommit();\n }\n else super.value = value;\n }\n\n get typedValue (): Value {\n return this.exposeBlock ? this.exposeBlock.typedValue :\n super.typedValue;\n }\n\n set typedValue (value: Value) {\n if (this.exposeBlock) {\n const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);\n this.exposeBlock.typedValue = value;\n this.appendTail(tail);\n this.doCommit();\n }\n else super.typedValue = value;\n }\n\n get displayValue (): string {\n return this._blocks.reduce((str, b) => str += b.displayValue, '');\n }\n\n appendTail (tail: string | String | TailDetails): ChangeDetails {\n return super.appendTail(tail).aggregate(this._appendPlaceholder());\n }\n\n _appendEager (): ChangeDetails {\n const details = new ChangeDetails();\n\n let startBlockIndex = this._mapPosToBlock(this.displayValue.length)?.index;\n if (startBlockIndex == null) return details;\n\n // TODO test if it works for nested pattern masks\n if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;\n\n for (let bi=startBlockIndex; bi={}): ChangeDetails {\n const blockIter = this._mapPosToBlock(this.displayValue.length);\n const details = new ChangeDetails();\n if (!blockIter) return details;\n\n for (let bi=blockIter.index; ; ++bi) {\n const block = this._blocks[bi];\n if (!block) break;\n\n const blockDetails = block._appendChar(ch, { ...flags, _beforeTailState: flags._beforeTailState?._blocks?.[bi] });\n\n const skip = blockDetails.skip;\n details.aggregate(blockDetails);\n\n if (skip || blockDetails.rawInserted) break; // go next char\n }\n\n return details;\n }\n\n extractTail (fromPos: number=0, toPos: number=this.displayValue.length): ChunksTailDetails {\n const chunkTail = new ChunksTailDetails();\n if (fromPos === toPos) return chunkTail;\n\n this._forEachBlocksInRange(fromPos, toPos, (b, bi, bFromPos, bToPos) => {\n const blockChunk = b.extractTail(bFromPos, bToPos);\n blockChunk.stop = this._findStopBefore(bi);\n blockChunk.from = this._blockStartPos(bi);\n if (blockChunk instanceof ChunksTailDetails) blockChunk.blockIndex = bi;\n\n chunkTail.extend(blockChunk);\n });\n\n return chunkTail;\n }\n\n extractInput (fromPos: number=0, toPos: number=this.displayValue.length, flags: ExtractFlags={}): string {\n if (fromPos === toPos) return '';\n\n let input = '';\n\n this._forEachBlocksInRange(fromPos, toPos, (b, _, fromPos, toPos) => {\n input += b.extractInput(fromPos, toPos, flags);\n });\n\n return input;\n }\n\n _findStopBefore (blockIndex: number): number | undefined {\n let stopBefore;\n for (let si=0; si {\n if (!b.lazy || toBlockIndex != null) {\n const bDetails = b._appendPlaceholder((b as MaskedPattern)._blocks?.length);\n this._value += bDetails.inserted;\n details.aggregate(bDetails);\n }\n });\n\n return details;\n }\n\n /** Finds block in pos */\n _mapPosToBlock (pos: number): BlockPosData | undefined {\n let accVal = '';\n for (let bi=0; bi pos += b.displayValue.length, 0);\n }\n\n _forEachBlocksInRange (fromPos: number, toPos: number=this.displayValue.length, fn: (block: PatternBlock, blockIndex: number, fromPos: number, toPos: number) => void) {\n const fromBlockIter = this._mapPosToBlock(fromPos);\n\n if (fromBlockIter) {\n const toBlockIter = this._mapPosToBlock(toPos);\n // process first block\n const isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;\n const fromBlockStartPos = fromBlockIter.offset;\n const fromBlockEndPos = toBlockIter && isSameBlock ?\n toBlockIter.offset :\n this._blocks[fromBlockIter.index].displayValue.length;\n fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);\n\n if (toBlockIter && !isSameBlock) {\n // process intermediate blocks\n for (let bi=fromBlockIter.index+1; bi {\n removeDetails.aggregate(b.remove(bFromPos, bToPos));\n });\n return removeDetails;\n }\n\n nearestInputPos (cursorPos: number, direction: Direction=DIRECTION.NONE): number {\n if (!this._blocks.length) return 0;\n const cursor = new PatternCursor(this, cursorPos);\n\n if (direction === DIRECTION.NONE) {\n // -------------------------------------------------\n // NONE should only go out from fixed to the right!\n // -------------------------------------------------\n if (cursor.pushRightBeforeInput()) return cursor.pos;\n cursor.popState();\n if (cursor.pushLeftBeforeInput()) return cursor.pos;\n return this.displayValue.length;\n }\n\n // FORCE is only about a|* otherwise is 0\n if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {\n // try to break fast when *|a\n if (direction === DIRECTION.LEFT) {\n cursor.pushRightBeforeFilled();\n if (cursor.ok && cursor.pos === cursorPos) return cursorPos;\n cursor.popState();\n }\n\n // forward flow\n cursor.pushLeftBeforeInput();\n cursor.pushLeftBeforeRequired();\n cursor.pushLeftBeforeFilled();\n\n // backward flow\n if (direction === DIRECTION.LEFT) {\n cursor.pushRightBeforeInput();\n cursor.pushRightBeforeRequired();\n if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;\n cursor.popState();\n if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;\n cursor.popState();\n }\n if (cursor.ok) return cursor.pos;\n if (direction === DIRECTION.FORCE_LEFT) return 0;\n\n cursor.popState();\n if (cursor.ok) return cursor.pos;\n\n cursor.popState();\n if (cursor.ok) return cursor.pos;\n\n return 0;\n }\n\n if (direction === DIRECTION.RIGHT || direction === DIRECTION.FORCE_RIGHT) {\n // forward flow\n cursor.pushRightBeforeInput();\n cursor.pushRightBeforeRequired();\n\n if (cursor.pushRightBeforeFilled()) return cursor.pos;\n if (direction === DIRECTION.FORCE_RIGHT) return this.displayValue.length;\n\n // backward flow\n cursor.popState();\n if (cursor.ok) return cursor.pos;\n\n cursor.popState();\n if (cursor.ok) return cursor.pos;\n\n return this.nearestInputPos(cursorPos, DIRECTION.LEFT);\n }\n\n return cursorPos;\n }\n\n totalInputPositions (fromPos: number=0, toPos: number=this.displayValue.length): number {\n let total = 0;\n this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {\n total += b.totalInputPositions(bFromPos, bToPos);\n });\n return total;\n }\n\n /** Get block by name */\n maskedBlock (name: string): PatternBlock | undefined {\n return this.maskedBlocks(name)[0];\n }\n\n /** Get all blocks by name */\n maskedBlocks (name: string): Array {\n const indices = this._maskedBlocks[name];\n if (!indices) return [];\n return indices.map(gi => this._blocks[gi]);\n }\n}\n\n\nIMask.MaskedPattern = MaskedPattern;\n","import ChangeDetails from '../core/change-details';\nimport IMask from '../core/holder';\nimport { type AppendFlags } from './base';\nimport MaskedPattern, { type MaskedPatternOptions } from './pattern';\n\n\ntype MaskedRangePatternOptions = MaskedPatternOptions &\n Pick &\n Partial>;\n\nexport\ntype MaskedRangeOptions = Omit;\n\n\n/** Pattern which accepts ranges */\nexport default\nclass MaskedRange extends MaskedPattern {\n /**\n Optionally sets max length of pattern.\n Used when pattern length is longer then `to` param length. Pads zeros at start in this case.\n */\n declare maxLength: number;\n /** Min bound */\n declare from: number;\n /** Max bound */\n declare to: number;\n /** */\n declare autofix?: boolean | 'pad';\n\n get _matchFrom (): number {\n return this.maxLength - String(this.from).length;\n }\n\n constructor (opts?: MaskedRangeOptions) {\n super(opts as MaskedPatternOptions); // mask will be created in _update\n }\n\n override updateOptions (opts: Partial) {\n super.updateOptions(opts);\n }\n\n override _update (opts: Partial) {\n const {\n to=this.to || 0,\n from=this.from || 0,\n maxLength=this.maxLength || 0,\n autofix=this.autofix,\n ...patternOpts\n }: Partial = opts;\n\n this.to = to;\n this.from = from;\n this.maxLength = Math.max(String(to).length, maxLength);\n this.autofix = autofix;\n\n const fromStr = String(this.from).padStart(this.maxLength, '0');\n const toStr = String(this.to).padStart(this.maxLength, '0');\n let sameCharsCount = 0;\n while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) ++sameCharsCount;\n patternOpts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\\\0') + '0'.repeat(this.maxLength - sameCharsCount);\n\n super._update(patternOpts);\n }\n\n override get isComplete (): boolean {\n return super.isComplete && Boolean(this.value);\n }\n\n boundaries (str: string): [string, string] {\n let minstr = '';\n let maxstr = '';\n\n const [, placeholder, num] = str.match(/^(\\D*)(\\d*)(\\D*)/) || [];\n if (num) {\n minstr = '0'.repeat(placeholder.length) + num;\n maxstr = '9'.repeat(placeholder.length) + num;\n }\n minstr = minstr.padEnd(this.maxLength, '0');\n maxstr = maxstr.padEnd(this.maxLength, '9');\n\n return [minstr, maxstr];\n }\n\n override doPrepareChar (ch: string, flags: AppendFlags={}): [string, ChangeDetails] {\n let details: ChangeDetails;\n [ch, details] = super.doPrepareChar(ch.replace(/\\D/g, ''), flags);\n\n if (!this.autofix || !ch) return [ch, details];\n\n const fromStr = String(this.from).padStart(this.maxLength, '0');\n const toStr = String(this.to).padStart(this.maxLength, '0');\n\n const nextVal = this.value + ch;\n if (nextVal.length > this.maxLength) return ['', details];\n\n const [minstr, maxstr] = this.boundaries(nextVal);\n\n if (Number(maxstr) < this.from) return [fromStr[nextVal.length - 1], details];\n\n if (Number(minstr) > this.to) {\n if (this.autofix === 'pad' && nextVal.length < this.maxLength) {\n return ['', details.aggregate(this.append(fromStr[nextVal.length - 1]+ch, flags))];\n }\n return [toStr[nextVal.length - 1], details];\n }\n\n return [ch, details];\n }\n\n override doValidate (flags: AppendFlags): boolean {\n const str = this.value;\n\n const firstNonZero = str.search(/[^0]/);\n if (firstNonZero === -1 && str.length <= this._matchFrom) return true;\n\n const [minstr, maxstr] = this.boundaries(str);\n\n return this.from <= Number(maxstr) && Number(minstr) <= this.to &&\n super.doValidate(flags);\n }\n}\n\n\nIMask.MaskedRange = MaskedRange;\n","import MaskedPattern, { type MaskedPatternOptions } from './pattern';\nimport { type MaskedRangeOptions } from './range';\nimport MaskedRange from './range';\nimport IMask from '../core/holder';\nimport type Masked from './base';\nimport { type AppendFlags } from './base';\nimport { isString } from '../core/utils';\n\n\nexport\ntype DateMaskType = DateConstructor;\n\ntype DateOptionsKeys =\n | 'pattern'\n | 'min'\n | 'max'\n | 'autofix'\n;\n\nexport\ntype DateValue = Date | null;\n\nexport\ntype MaskedDateOptions =\n Omit, 'mask'> &\n Partial> &\n { mask?: string | DateMaskType }\n;\n\n/** Date mask */\nexport default\nclass MaskedDate extends MaskedPattern {\n static GET_DEFAULT_BLOCKS: () => { [k: string]: MaskedRangeOptions } = () => ({\n d: {\n mask: MaskedRange,\n from: 1,\n to: 31,\n maxLength: 2,\n },\n m: {\n mask: MaskedRange,\n from: 1,\n to: 12,\n maxLength: 2,\n },\n Y: {\n mask: MaskedRange,\n from: 1900,\n to: 9999,\n }\n });\n static DEFAULTS: Record = {\n mask: Date,\n pattern: 'd{.}`m{.}`Y',\n format: (date: DateValue, masked: Masked): string => {\n if (!date) return '';\n\n const day = String(date.getDate()).padStart(2, '0');\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const year = date.getFullYear();\n\n return [day, month, year].join('.');\n },\n parse: (str: string, masked: Masked): DateValue => {\n const [day, month, year] = str.split('.').map(Number);\n return new Date(year, month - 1, day);\n },\n } satisfies Partial;\n\n /** Pattern mask for date according to {@link MaskedDate#format} */\n declare pattern: string;\n /** Start date */\n declare min?: Date;\n /** End date */\n declare max?: Date;\n /** */\n declare autofix?: boolean | 'pad' | undefined;\n /** Format typed value to string */\n declare format: (value: DateValue, masked: Masked) => string;\n /** Parse string to get typed value */\n declare parse: (str: string, masked: Masked) => DateValue;\n\n constructor (opts?: MaskedDateOptions) {\n const { mask, pattern, ...patternOpts } = {\n ...(MaskedDate.DEFAULTS as MaskedDateOptions),\n ...opts,\n };\n\n super({\n ...patternOpts,\n mask: isString(mask) ? mask : pattern,\n });\n }\n\n override updateOptions (opts: Partial) {\n super.updateOptions(opts as Partial>);\n }\n\n override _update (opts: Partial) {\n const { mask, pattern, blocks, ...patternOpts } = {\n ...MaskedDate.DEFAULTS,\n ...opts,\n };\n\n const patternBlocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());\n // adjust year block\n if (opts.min) patternBlocks.Y.from = opts.min.getFullYear();\n if (opts.max) patternBlocks.Y.to = opts.max.getFullYear();\n if (opts.min && opts.max && patternBlocks.Y.from === patternBlocks.Y.to\n ) {\n patternBlocks.m.from = opts.min.getMonth() + 1;\n patternBlocks.m.to = opts.max.getMonth() + 1;\n\n if (patternBlocks.m.from === patternBlocks.m.to) {\n patternBlocks.d.from = opts.min.getDate();\n patternBlocks.d.to = opts.max.getDate();\n }\n }\n Object.assign(patternBlocks, this.blocks, blocks);\n\n // add autofix\n Object.keys(patternBlocks).forEach(bk => {\n const b = patternBlocks[bk];\n if (!('autofix' in b) && 'autofix' in opts) b.autofix = opts.autofix;\n });\n\n super._update({\n ...patternOpts,\n mask: isString(mask) ? mask : pattern,\n blocks: patternBlocks,\n });\n }\n\n override doValidate (flags: AppendFlags): boolean {\n const date = this.date;\n\n return super.doValidate(flags) &&\n (!this.isComplete ||\n this.isDateExist(this.value) && date != null &&\n (this.min == null || this.min <= date) &&\n (this.max == null || date <= this.max));\n }\n\n /** Checks if date is exists */\n isDateExist (str: string): boolean {\n return this.format(this.parse(str, this), this).indexOf(str) >= 0;\n }\n\n /** Parsed Date */\n get date (): DateValue {\n return this.typedValue;\n }\n set date (date: DateValue) {\n this.typedValue = date;\n }\n\n override get typedValue (): DateValue {\n return this.isComplete ? super.typedValue : null;\n }\n override set typedValue (value: DateValue) {\n super.typedValue = value;\n }\n\n override maskEquals (mask: any): boolean {\n return mask === Date || super.maskEquals(mask);\n }\n}\n\n\nIMask.MaskedDate = MaskedDate;\n","import { objectIncludes } from '../core/utils';\nimport ChangeDetails from '../core/change-details';\nimport createMask, { type FactoryArg, type ExtendFactoryArgOptions, type NormalizedOpts, normalizeOpts } from './factory';\nimport Masked, { type AppendFlags, type MaskedState, type MaskedOptions, type ExtractFlags } from './base';\nimport { DIRECTION, type Direction } from '../core/utils';\nimport { type TailDetails } from '../core/tail-details';\nimport IMask from '../core/holder';\n\n\ntype MaskedDynamicNoRefState = MaskedState & {\n compiledMasks: Array\n};\n\ntype MaskedDynamicRefState = MaskedDynamicNoRefState & {\n currentMaskRef: Masked,\n currentMask: MaskedState,\n};\n\nexport\ntype MaskedDynamicState = MaskedDynamicNoRefState | MaskedDynamicRefState;\n\nexport\ntype DynamicMaskType = Array> | ArrayConstructor;\n\nexport\ntype MaskedDynamicOptions = MaskedOptions;\n\ntype HandleState = MaskedDynamicState | MaskedState;\n\n/** Dynamic mask for choosing appropriate mask in run-time */\nexport default\nclass MaskedDynamic extends Masked {\n static DEFAULTS: Partial;\n\n declare mask: DynamicMaskType;\n /** Currently chosen mask */\n declare currentMask?: Masked;\n /** Currently chosen mask */\n declare exposeMask?: Masked;\n /** Compliled {@link Masked} options */\n declare compiledMasks: Array;\n /** Chooses {@link Masked} depending on input value */\n declare dispatch: (appended: string, masked: MaskedDynamic, flags: AppendFlags, tail: string | String | TailDetails) => (Masked | undefined);\n\n declare _overwrite?: this['overwrite'];\n declare _eager?: this['eager'];\n declare _skipInvalid?: this['skipInvalid'];\n\n constructor (opts?: MaskedDynamicOptions) {\n super({\n ...MaskedDynamic.DEFAULTS,\n ...opts\n });\n\n this.currentMask = undefined;\n }\n\n override updateOptions (opts: Partial) {\n super.updateOptions(opts);\n }\n\n override _update (opts: Partial) {\n super._update(opts);\n\n if ('mask' in opts) {\n this.exposeMask = undefined;\n // mask could be totally dynamic with only `dispatch` option\n this.compiledMasks = Array.isArray(opts.mask) ?\n opts.mask.map(m => {\n const { expose, ...maskOpts } = normalizeOpts(m) as NormalizedOpts & { expose?: boolean };\n\n const masked = createMask({\n overwrite: this._overwrite,\n eager: this._eager,\n skipInvalid: this._skipInvalid,\n ...maskOpts,\n });\n\n if (expose) this.exposeMask = masked;\n\n return masked;\n }) :\n [];\n\n // this.currentMask = this.doDispatch(''); // probably not needed but lets see\n }\n }\n\n override _appendCharRaw (ch: string, flags: AppendFlags={}): ChangeDetails {\n const details = this._applyDispatch(ch, flags);\n\n if (this.currentMask) {\n details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));\n }\n\n return details;\n }\n\n _applyDispatch (appended: string='', flags: AppendFlags={}, tail: string | String | TailDetails = ''): ChangeDetails {\n const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ?\n flags._beforeTailState._value :\n this.value;\n const inputValue = this.rawInputValue;\n const insertValue = flags.tail && flags._beforeTailState != null ?\n flags._beforeTailState._rawInputValue :\n inputValue;\n const tailValue = inputValue.slice(insertValue.length);\n const prevMask = this.currentMask;\n const details = new ChangeDetails();\n\n const prevMaskState = prevMask?.state;\n\n // clone flags to prevent overwriting `_beforeTailState`\n this.currentMask = this.doDispatch(appended, { ...flags }, tail);\n\n // restore state after dispatch\n if (this.currentMask) {\n if (this.currentMask !== prevMask) {\n // if mask changed reapply input\n this.currentMask.reset();\n\n if (insertValue) {\n const d = this.currentMask.append(insertValue, {raw: true});\n details.tailShift = d.inserted.length - prevValueBeforeTail.length;\n }\n\n if (tailValue) {\n details.tailShift += this.currentMask.append(tailValue, {raw: true, tail: true}).tailShift;\n }\n } else if (prevMaskState) {\n // Dispatch can do something bad with state, so\n // restore prev mask state\n this.currentMask.state = prevMaskState;\n }\n }\n\n return details;\n }\n\n override _appendPlaceholder (): ChangeDetails {\n const details = this._applyDispatch();\n\n if (this.currentMask) {\n details.aggregate(this.currentMask._appendPlaceholder());\n }\n\n return details;\n }\n\n override _appendEager (): ChangeDetails {\n const details = this._applyDispatch();\n\n if (this.currentMask) {\n details.aggregate(this.currentMask._appendEager());\n }\n\n return details;\n }\n\n override appendTail (tail: string | String | TailDetails): ChangeDetails {\n const details = new ChangeDetails();\n if (tail) details.aggregate(this._applyDispatch('', {}, tail));\n\n return details.aggregate(this.currentMask ?\n this.currentMask.appendTail(tail) :\n super.appendTail(tail));\n }\n\n currentMaskFlags (flags: AppendFlags): AppendFlags {\n return {\n ...flags,\n _beforeTailState:\n (flags._beforeTailState as MaskedDynamicRefState)?.currentMaskRef === this.currentMask &&\n (flags._beforeTailState as MaskedDynamicRefState)?.currentMask ||\n flags._beforeTailState,\n };\n }\n\n doDispatch(appended: string, flags: AppendFlags={}, tail: string | String | TailDetails=''): Masked | undefined {\n return this.dispatch(appended, this, flags, tail);\n }\n\n override doValidate (flags: AppendFlags): boolean {\n return super.doValidate(flags) && (\n !this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags))\n );\n }\n\n override doPrepare (str: string, flags: AppendFlags={}): [string, ChangeDetails] {\n let [s, details] = super.doPrepare(str, flags);\n\n if (this.currentMask) {\n let currentDetails;\n ([s, currentDetails] = super.doPrepare(s, this.currentMaskFlags(flags)));\n details = details.aggregate(currentDetails);\n }\n\n return [s, details];\n }\n\n override doPrepareChar (str: string, flags: AppendFlags={}): [string, ChangeDetails] {\n let [s, details] = super.doPrepareChar(str, flags);\n\n if (this.currentMask) {\n let currentDetails;\n ([s, currentDetails] = super.doPrepareChar(s, this.currentMaskFlags(flags)));\n details = details.aggregate(currentDetails);\n }\n\n return [s, details];\n }\n\n override reset () {\n this.currentMask?.reset();\n this.compiledMasks.forEach(m => m.reset());\n }\n\n override get value (): string {\n return this.exposeMask ? this.exposeMask.value :\n this.currentMask ? this.currentMask.value :\n '';\n }\n\n override set value (value: string) {\n if (this.exposeMask) {\n this.exposeMask.value = value;\n this.currentMask = this.exposeMask;\n this._applyDispatch();\n }\n else super.value = value;\n }\n\n override get unmaskedValue (): string {\n return this.exposeMask ? this.exposeMask.unmaskedValue :\n this.currentMask ? this.currentMask.unmaskedValue :\n '';\n }\n\n override set unmaskedValue (unmaskedValue: string) {\n if (this.exposeMask) {\n this.exposeMask.unmaskedValue = unmaskedValue;\n this.currentMask = this.exposeMask;\n this._applyDispatch();\n }\n else super.unmaskedValue = unmaskedValue;\n }\n\n override get typedValue (): Value {\n return this.exposeMask ? this.exposeMask.typedValue :\n this.currentMask ? this.currentMask.typedValue :\n '';\n }\n\n override set typedValue (typedValue: Value) {\n if (this.exposeMask) {\n this.exposeMask.typedValue = typedValue;\n this.currentMask = this.exposeMask;\n this._applyDispatch();\n return;\n }\n\n let unmaskedValue = String(typedValue);\n\n // double check it\n if (this.currentMask) {\n this.currentMask.typedValue = typedValue;\n unmaskedValue = this.currentMask.unmaskedValue;\n }\n this.unmaskedValue = unmaskedValue;\n }\n\n override get displayValue (): string {\n return this.currentMask ? this.currentMask.displayValue : '';\n }\n\n override get isComplete (): boolean {\n return Boolean(this.currentMask?.isComplete);\n }\n\n override get isFilled (): boolean {\n return Boolean(this.currentMask?.isFilled);\n }\n\n override remove (fromPos?: number, toPos?: number): ChangeDetails {\n const details: ChangeDetails = new ChangeDetails();\n if (this.currentMask) {\n details.aggregate(this.currentMask.remove(fromPos, toPos))\n // update with dispatch\n .aggregate(this._applyDispatch());\n }\n\n return details;\n }\n\n override get state (): MaskedDynamicState {\n return {\n ...super.state,\n _rawInputValue: this.rawInputValue,\n compiledMasks: this.compiledMasks.map(m => m.state),\n currentMaskRef: this.currentMask,\n currentMask: this.currentMask?.state,\n };\n }\n\n override set state (state: HandleState) {\n const { compiledMasks, currentMaskRef, currentMask, ...maskedState } = state as MaskedDynamicRefState;\n if (compiledMasks) this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);\n if (currentMaskRef != null) {\n this.currentMask = currentMaskRef;\n this.currentMask.state = currentMask;\n }\n super.state = maskedState;\n }\n\n override extractInput (fromPos?: number, toPos?: number, flags?: ExtractFlags): string {\n return this.currentMask ?\n this.currentMask.extractInput(fromPos, toPos, flags) :\n '';\n }\n\n override extractTail (fromPos?: number, toPos?: number): TailDetails {\n return this.currentMask ?\n this.currentMask.extractTail(fromPos, toPos) :\n super.extractTail(fromPos, toPos);\n }\n\n override doCommit () {\n if (this.currentMask) this.currentMask.doCommit();\n super.doCommit();\n }\n\n override nearestInputPos(cursorPos: number, direction?: Direction): number {\n return this.currentMask ?\n this.currentMask.nearestInputPos(cursorPos, direction) :\n super.nearestInputPos(cursorPos, direction);\n }\n\n override get overwrite (): boolean | 'shift' | undefined {\n return this.currentMask ?\n this.currentMask.overwrite :\n this._overwrite;\n }\n\n override set overwrite (overwrite: boolean | 'shift' | undefined) {\n this._overwrite = overwrite;\n }\n\n override get eager (): boolean | 'remove' | 'append' | undefined {\n return this.currentMask ?\n this.currentMask.eager :\n this._eager;\n }\n\n override set eager (eager: boolean | 'remove' | 'append' | undefined) {\n this._eager = eager;\n }\n\n override get skipInvalid (): boolean | undefined {\n return this.currentMask ?\n this.currentMask.skipInvalid :\n this._skipInvalid;\n }\n\n override set skipInvalid (skipInvalid: boolean | undefined) {\n this._skipInvalid = skipInvalid;\n }\n\n override maskEquals (mask: any): boolean {\n return Array.isArray(mask) ?\n this.compiledMasks.every((m, mi) => {\n if (!mask[mi]) return;\n\n const { mask: oldMask, ...restOpts } = mask[mi];\n return objectIncludes(m, restOpts) && m.maskEquals(oldMask);\n }) : super.maskEquals(mask);\n }\n\n override typedValueEquals (value: any): boolean {\n return Boolean(this.currentMask?.typedValueEquals(value));\n }\n}\n\nMaskedDynamic.DEFAULTS = {\n dispatch: (appended, masked, flags, tail) => {\n if (!masked.compiledMasks.length) return;\n\n const inputValue = masked.rawInputValue;\n\n // simulate input\n const inputs = masked.compiledMasks.map((m, index) => {\n const isCurrent = masked.currentMask === m;\n const startInputPos = isCurrent ? m.displayValue.length : m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT);\n\n if (m.rawInputValue !== inputValue) {\n m.reset();\n m.append(inputValue, { raw: true });\n } else if (!isCurrent) {\n m.remove(startInputPos);\n }\n m.append(appended, masked.currentMaskFlags(flags));\n m.appendTail(tail);\n\n return {\n index,\n weight: m.rawInputValue.length,\n totalInputPositions: m.totalInputPositions(\n 0,\n Math.max(startInputPos, m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT)),\n ),\n };\n });\n\n // pop masks with longer values first\n inputs.sort((i1, i2) => i2.weight - i1.weight || i2.totalInputPositions - i1.totalInputPositions);\n\n return masked.compiledMasks[inputs[0].index];\n }\n};\n\n\nIMask.MaskedDynamic = MaskedDynamic;\n","import MaskedPattern, { type MaskedPatternOptions } from './pattern';\nimport { AppendFlags } from './base';\nimport IMask from '../core/holder';\n\n\nexport\ntype MaskedEnumOptions = Omit & Pick;\n\nexport\ntype MaskedEnumPatternOptions = MaskedPatternOptions & Partial>;\n\n\n/** Pattern which validates enum values */\nexport default\nclass MaskedEnum extends MaskedPattern {\n declare enum: Array;\n\n constructor (opts?: MaskedEnumOptions) {\n super(opts as MaskedPatternOptions); // mask will be created in _update\n }\n\n override updateOptions (opts: Partial) {\n super.updateOptions(opts);\n }\n\n override _update (opts: Partial) {\n const { enum: _enum, ...eopts }: MaskedEnumPatternOptions = opts;\n\n if (_enum) {\n const lengths = _enum.map(e => e.length);\n const requiredLength = Math.min(...lengths);\n const optionalLength = Math.max(...lengths) - requiredLength;\n\n eopts.mask = '*'.repeat(requiredLength);\n if (optionalLength) eopts.mask += '[' + '*'.repeat(optionalLength) + ']';\n\n this.enum = _enum;\n }\n\n super._update(eopts);\n }\n\n override doValidate (flags: AppendFlags): boolean {\n return this.enum.some(e => e.indexOf(this.unmaskedValue) === 0) &&\n super.doValidate(flags);\n }\n}\n\n\nIMask.MaskedEnum = MaskedEnum;\n","import Masked, { type MaskedOptions } from './base';\nimport IMask from '../core/holder';\n\n\nexport\ntype MaskedFunctionOptions = MaskedOptions;\n\n/** Masking by custom Function */\nexport default\nclass MaskedFunction extends Masked {\n /** */\n declare mask: (value: string, masked: Masked) => boolean;\n /** Enable characters overwriting */\n declare overwrite?: boolean | 'shift' | undefined;\n /** */\n declare eager?: boolean | 'remove' | 'append' | undefined;\n /** */\n declare skipInvalid?: boolean | undefined;\n\n override updateOptions (opts: Partial) {\n super.updateOptions(opts);\n }\n\n override _update (opts: Partial) {\n super._update({\n ...opts,\n validate: opts.mask,\n });\n }\n}\n\n\nIMask.MaskedFunction = MaskedFunction;\n","import { escapeRegExp, type Direction, DIRECTION } from '../core/utils';\nimport ChangeDetails from '../core/change-details';\nimport { type TailDetails } from '../core/tail-details';\n\nimport Masked, { type MaskedOptions, type ExtractFlags, type AppendFlags } from './base';\nimport IMask from '../core/holder';\n\n\nexport\ntype MaskedNumberOptions = MaskedOptions;\n\n/** Number mask */\nexport default\nclass MaskedNumber extends Masked {\n static UNMASKED_RADIX = '.';\n static EMPTY_VALUES: Array = [...Masked.EMPTY_VALUES, 0];\n static DEFAULTS: Partial = {\n mask: Number,\n radix: ',',\n thousandsSeparator: '',\n mapToRadix: [MaskedNumber.UNMASKED_RADIX],\n min: Number.MIN_SAFE_INTEGER,\n max: Number.MAX_SAFE_INTEGER,\n scale: 2,\n normalizeZeros: true,\n padFractionalZeros: false,\n parse: Number,\n format: (n: number) => n.toLocaleString('en-US', { useGrouping: false, maximumFractionDigits: 20 }),\n };\n\n declare mask: NumberConstructor;\n /** Single char */\n declare radix: string;\n /** Single char */\n declare thousandsSeparator: string;\n /** Array of single chars */\n declare mapToRadix: Array;\n /** */\n declare min: number;\n /** */\n declare max: number;\n /** Digits after point */\n declare scale: number;\n /** Flag to remove leading and trailing zeros in the end of editing */\n declare normalizeZeros: boolean;\n /** Flag to pad trailing zeros after point in the end of editing */\n declare padFractionalZeros: boolean;\n /** Enable characters overwriting */\n declare overwrite?: boolean | 'shift' | undefined;\n /** */\n declare eager?: boolean | 'remove' | 'append' | undefined;\n /** */\n declare skipInvalid?: boolean | undefined;\n /** Format typed value to string */\n declare format: (value: number, masked: Masked) => string;\n /** Parse string to get typed value */\n declare parse: (str: string, masked: Masked) => number;\n\n declare _numberRegExp: RegExp;\n declare _thousandsSeparatorRegExp: RegExp;\n declare _mapToRadixRegExp: RegExp;\n declare _separatorsProcessed: boolean;\n\n constructor (opts?: MaskedNumberOptions) {\n super({\n ...MaskedNumber.DEFAULTS,\n ...opts,\n });\n }\n\n override updateOptions (opts: Partial) {\n super.updateOptions(opts);\n }\n\n override _update (opts: Partial) {\n super._update(opts);\n this._updateRegExps();\n }\n\n _updateRegExps () {\n const start = '^' + (this.allowNegative ? '[+|\\\\-]?' : '');\n const mid = '\\\\d*';\n const end = (this.scale ?\n `(${escapeRegExp(this.radix)}\\\\d{0,${this.scale}})?` :\n '') + '$';\n\n this._numberRegExp = new RegExp(start + mid + end);\n this._mapToRadixRegExp = new RegExp(`[${this.mapToRadix.map(escapeRegExp).join('')}]`, 'g');\n this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');\n }\n\n _removeThousandsSeparators (value: string): string {\n return value.replace(this._thousandsSeparatorRegExp, '');\n }\n\n _insertThousandsSeparators (value: string): string {\n // https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript\n const parts = value.split(this.radix);\n parts[0] = parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, this.thousandsSeparator);\n return parts.join(this.radix);\n }\n\n override doPrepareChar (ch: string, flags: AppendFlags={}): [string, ChangeDetails] {\n const [prepCh, details] = super.doPrepareChar(this._removeThousandsSeparators(\n this.scale && this.mapToRadix.length && (\n /*\n radix should be mapped when\n 1) input is done from keyboard = flags.input && flags.raw\n 2) unmasked value is set = !flags.input && !flags.raw\n and should not be mapped when\n 1) value is set = flags.input && !flags.raw\n 2) raw value is set = !flags.input && flags.raw\n */\n flags.input && flags.raw ||\n !flags.input && !flags.raw\n ) ? ch.replace(this._mapToRadixRegExp, this.radix) : ch\n ), flags);\n if (ch && !prepCh) details.skip = true;\n\n if (prepCh && !this.allowPositive && !this.value && prepCh !== '-') details.aggregate(this._appendChar('-'));\n\n return [prepCh, details];\n }\n\n _separatorsCount (to: number, extendOnSeparators: boolean=false): number {\n let count = 0;\n\n for (let pos = 0; pos < to; ++pos) {\n if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {\n ++count;\n if (extendOnSeparators) to += this.thousandsSeparator.length;\n }\n }\n\n return count;\n }\n\n _separatorsCountFromSlice (slice: string=this._value): number {\n return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);\n }\n\n override extractInput (fromPos: number=0, toPos: number=this.displayValue.length, flags?: ExtractFlags): string {\n [fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);\n\n return this._removeThousandsSeparators(super.extractInput(fromPos, toPos, flags));\n }\n\n \n override _appendCharRaw (ch: string, flags: AppendFlags={}): ChangeDetails {\n if (!this.thousandsSeparator) return super._appendCharRaw(ch, flags);\n\n const prevBeforeTailValue = flags.tail && flags._beforeTailState ?\n flags._beforeTailState._value :\n this._value;\n const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);\n this._value = this._removeThousandsSeparators(this.value);\n\n const appendDetails = super._appendCharRaw(ch, flags);\n\n this._value = this._insertThousandsSeparators(this._value);\n const beforeTailValue = flags.tail && flags._beforeTailState ?\n flags._beforeTailState._value :\n this._value;\n const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);\n\n appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;\n appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;\n return appendDetails;\n }\n\n _findSeparatorAround (pos: number): number {\n if (this.thousandsSeparator) {\n const searchFrom = pos - this.thousandsSeparator.length + 1;\n const separatorPos = this.value.indexOf(this.thousandsSeparator, searchFrom);\n if (separatorPos <= pos) return separatorPos;\n }\n\n return -1;\n }\n\n _adjustRangeWithSeparators (from: number, to: number): [number, number] {\n const separatorAroundFromPos = this._findSeparatorAround(from);\n if (separatorAroundFromPos >= 0) from = separatorAroundFromPos;\n\n const separatorAroundToPos = this._findSeparatorAround(to);\n if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;\n return [from, to];\n }\n\n \n override remove (fromPos: number=0, toPos: number=this.displayValue.length): ChangeDetails {\n [fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);\n\n const valueBeforePos = this.value.slice(0, fromPos);\n const valueAfterPos = this.value.slice(toPos);\n\n const prevBeforeTailSeparatorsCount = this._separatorsCount(valueBeforePos.length);\n this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(valueBeforePos + valueAfterPos));\n const beforeTailSeparatorsCount = this._separatorsCountFromSlice(valueBeforePos);\n\n return new ChangeDetails({\n tailShift: (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length,\n });\n }\n\n override nearestInputPos (cursorPos: number, direction?: Direction): number {\n if (!this.thousandsSeparator) return cursorPos;\n\n switch (direction) {\n case DIRECTION.NONE:\n case DIRECTION.LEFT:\n case DIRECTION.FORCE_LEFT: {\n const separatorAtLeftPos = this._findSeparatorAround(cursorPos - 1);\n if (separatorAtLeftPos >= 0) {\n const separatorAtLeftEndPos = separatorAtLeftPos + this.thousandsSeparator.length;\n if (cursorPos < separatorAtLeftEndPos ||\n this.value.length <= separatorAtLeftEndPos ||\n direction === DIRECTION.FORCE_LEFT\n ) {\n return separatorAtLeftPos;\n }\n }\n break;\n }\n case DIRECTION.RIGHT:\n case DIRECTION.FORCE_RIGHT: {\n const separatorAtRightPos = this._findSeparatorAround(cursorPos);\n if (separatorAtRightPos >= 0) {\n return separatorAtRightPos + this.thousandsSeparator.length;\n }\n }\n }\n\n return cursorPos;\n }\n\n override doValidate (flags: AppendFlags): boolean {\n // validate as string\n let valid = Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));\n\n if (valid) {\n // validate as number\n const number = this.number;\n valid = valid && !isNaN(number) &&\n // check min bound for negative values\n (this.min == null || this.min >= 0 || this.min <= this.number) &&\n // check max bound for positive values\n (this.max == null || this.max <= 0 || this.number <= this.max);\n }\n\n return valid && super.doValidate(flags);\n }\n\n override doCommit () {\n if (this.value) {\n const number = this.number;\n let validnum = number;\n\n // check bounds\n if (this.min != null) validnum = Math.max(validnum, this.min);\n if (this.max != null) validnum = Math.min(validnum, this.max);\n\n if (validnum !== number) this.unmaskedValue = this.format(validnum, this);\n\n let formatted = this.value;\n\n if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);\n if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);\n\n this._value = formatted;\n }\n\n super.doCommit();\n }\n\n _normalizeZeros (value: string): string {\n const parts = this._removeThousandsSeparators(value).split(this.radix);\n\n // remove leading zeros\n parts[0] = parts[0].replace(/^(\\D*)(0*)(\\d*)/, (match, sign, zeros, num) => sign + num);\n // add leading zero\n if (value.length && !/\\d$/.test(parts[0])) parts[0] = parts[0] + '0';\n\n if (parts.length > 1) {\n parts[1] = parts[1].replace(/0*$/, ''); // remove trailing zeros\n if (!parts[1].length) parts.length = 1; // remove fractional\n }\n\n return this._insertThousandsSeparators(parts.join(this.radix));\n }\n\n _padFractionalZeros (value: string): string {\n if (!value) return value;\n\n const parts = value.split(this.radix);\n if (parts.length < 2) parts.push('');\n parts[1] = parts[1].padEnd(this.scale, '0');\n return parts.join(this.radix);\n }\n\n doSkipInvalid (ch: string, flags: AppendFlags={}, checkTail?: TailDetails): boolean {\n const dropFractional = this.scale === 0 && ch !== this.thousandsSeparator && (\n ch === this.radix ||\n ch === MaskedNumber.UNMASKED_RADIX ||\n this.mapToRadix.includes(ch)\n )\n return super.doSkipInvalid(ch, flags, checkTail) && !dropFractional;\n }\n\n override get unmaskedValue (): string {\n return this._removeThousandsSeparators(\n this._normalizeZeros(\n this.value))\n .replace(this.radix, MaskedNumber.UNMASKED_RADIX);\n }\n\n override set unmaskedValue (unmaskedValue: string) {\n super.unmaskedValue = unmaskedValue;\n }\n\n override get typedValue (): number {\n return this.parse(this.unmaskedValue, this);\n }\n\n override set typedValue (n: number) {\n this.rawInputValue = this.format(n, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);\n }\n\n /** Parsed Number */\n get number (): number {\n return this.typedValue;\n }\n\n set number (number: number) {\n this.typedValue = number;\n }\n\n /**\n Is negative allowed\n */\n get allowNegative (): boolean {\n return (this.min != null && this.min < 0) || (this.max != null && this.max < 0);\n }\n\n /**\n Is positive allowed\n */\n get allowPositive (): boolean {\n return (this.min != null && this.min > 0) || (this.max != null && this.max > 0);\n }\n\n override typedValueEquals (value: any): boolean {\n // handle 0 -> '' case (typed = 0 even if value = '')\n // for details see https://github.com/uNmAnNeR/imaskjs/issues/134\n return (\n super.typedValueEquals(value) ||\n MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)\n ) && !(value === 0 && this.value === '');\n }\n}\n\n\nIMask.MaskedNumber = MaskedNumber;\n","import createMask, { type FactoryArg, type FactoryReturnMasked } from './factory';\nimport IMask from '../core/holder';\n\n\n/** Mask pipe source and destination types */\nexport\nconst PIPE_TYPE = {\n MASKED: 'value',\n UNMASKED: 'unmaskedValue',\n TYPED: 'typedValue',\n} as const;\n\ntype ValueOf = T[keyof T];\n\ntype TypedValueOf<\n Opts extends FactoryArg,\n Type extends ValueOf\n> = Type extends (typeof PIPE_TYPE.MASKED | typeof PIPE_TYPE.UNMASKED) ?\n string :\n FactoryReturnMasked['typedValue']\n;\n\n/** Creates new pipe function depending on mask type, source and destination options */\nexport\nfunction createPipe<\n Arg extends FactoryArg,\n From extends ValueOf = typeof PIPE_TYPE.MASKED,\n To extends ValueOf = typeof PIPE_TYPE.MASKED,\n> (\n arg: Arg,\n from: From=PIPE_TYPE.MASKED as From,\n to: To=PIPE_TYPE.MASKED as To,\n) {\n const masked = createMask(arg);\n return (value: TypedValueOf) => masked.runIsolated(m => {\n m[from] = value;\n return m[to] as TypedValueOf;\n });\n}\n\n/** Pipes value through mask depending on mask type, source and destination options */\nexport\nfunction pipe<\n Arg extends FactoryArg,\n From extends ValueOf = typeof PIPE_TYPE.MASKED,\n To extends ValueOf = typeof PIPE_TYPE.MASKED,\n> (\n value: TypedValueOf,\n mask: Arg,\n from?: From,\n to?: To,\n) {\n return createPipe(mask, from, to)(value);\n}\n\n\nIMask.PIPE_TYPE = PIPE_TYPE;\nIMask.createPipe = createPipe;\nIMask.pipe = pipe;\n","import IMask from './imask';\nexport { default as HTMLContenteditableMaskElement } from './controls/html-contenteditable-mask-element';\nexport { default as HTMLInputMaskElement, type InputElement } from './controls/html-input-mask-element';\nexport { default as HTMLMaskElement } from './controls/html-mask-element';\nexport { default as InputMask, type InputMaskElement } from './controls/input';\nexport { default as MaskElement } from './controls/mask-element';\nexport { default as ChangeDetails, type ChangeDetailsOptions } from './core/change-details';\nexport { type AppendTail, type TailDetails } from './core/tail-details';\nexport { DIRECTION, forceDirection, type Direction, type Selection } from './core/utils';\nexport { default as Masked, type AppendFlags, type ExtractFlags, type MaskedOptions, type MaskedState } from './masked/base';\nexport { default as MaskedDate, type DateMaskType, type MaskedDateOptions } from './masked/date';\nexport { default as MaskedDynamic, type DynamicMaskType, type MaskedDynamicOptions, type MaskedDynamicState } from './masked/dynamic';\nexport { default as MaskedEnum, type MaskedEnumOptions } from './masked/enum';\nexport {\n default as createMask,\n normalizeOpts,\n type AllFactoryStaticOpts,\n type FactoryArg,\n type FactoryConstructorOpts,\n type FactoryConstructorReturnMasked,\n type FactoryInstanceOpts,\n type FactoryInstanceReturnMasked,\n type FactoryOpts,\n type FactoryReturnMasked,\n type FactoryStaticOpts,\n type FactoryStaticReturnMasked,\n type NormalizedOpts,\n type UpdateOpts,\n} from './masked/factory';\nexport { default as MaskedFunction, type MaskedFunctionOptions } from './masked/function';\nexport { default as MaskedNumber, type MaskedNumberOptions } from './masked/number';\nexport { default as MaskedPattern, type BlockPosData, type Definitions, type MaskedPatternOptions, type MaskedPatternState } from './masked/pattern';\nexport { type default as PatternBlock } from './masked/pattern/block';\nexport { default as ChunksTailDetails, type ChunksTailState } from './masked/pattern/chunk-tail-details';\nexport { default as PatternFixedDefinition, type PatternFixedDefinitionOptions } from './masked/pattern/fixed-definition';\nexport { default as PatternInputDefinition, type PatternInputDefinitionOptions, type PatternInputDefinitionState } from './masked/pattern/input-definition';\nexport { createPipe, pipe, PIPE_TYPE } from './masked/pipe';\nexport { default as MaskedRange, type MaskedRangeOptions } from './masked/range';\nexport { default as MaskedRegExp, type MaskedRegExpOptions } from './masked/regexp';\n\ntry { (globalThis as any).IMask = IMask; } catch {}\nexport default IMask;\n"],"names":["isString","str","String","isObject","obj","_obj$constructor","constructor","name","pick","keys","Array","isArray","_","k","includes","Object","entries","reduce","acc","_ref","v","DIRECTION","NONE","LEFT","FORCE_LEFT","RIGHT","FORCE_RIGHT","forceDirection","direction","escapeRegExp","replace","objectIncludes","b","a","arrA","arrB","i","length","dateA","Date","dateB","getTime","regexpA","RegExp","regexpB","toString","prototype","hasOwnProperty","call","ActionDetails","opts","assign","this","value","slice","startChangePos","oldValue","oldSelection","start","Math","min","cursorPos","insertedCount","inserted","substr","removedCount","max","end","removed","head","substring","tail","removeDirection","IMask","el","InputMask","maskedClass","mask","Error","MaskedRegExp","MaskedPattern","MaskedDate","Number","MaskedNumber","MaskedDynamic","Masked","Function","MaskedFunction","console","warn","normalizeOpts","instanceOpts","_mask","startsWith","createMask","nOpts","MaskedClass","MaskElement","selectionStart","_unsafeSelectionStart","selectionEnd","_unsafeSelectionEnd","select","_unsafeSelect","isActive","HTMLMaskElement","input","super","_handlers","rootElement","_this$input$getRootNo","_this$input$getRootNo2","_this$input","getRootNode","document","activeElement","bindEvents","handlers","forEach","event","_toggleEventHandler","EVENTS_MAP","unbindEvents","handler","removeEventListener","addEventListener","selectionChange","drop","click","focus","commit","HTMLInputMaskElement","setSelectionRange","HTMLContenteditableMaskElement","root","selection","getSelection","anchorOffset","focusOffset","createRange","range","setStart","firstChild","setEnd","lastChild","removeAllRanges","addRange","textContent","isContentEditable","tagName","masked","_listeners","_value","_unmaskedValue","_saveSelection","bind","_onInput","_onChange","_onDrop","_onFocus","_onClick","alignCursor","alignCursorFriendly","_bindEvents","updateValue","maskEquals","_this$masked","updateOptions","unmaskedValue","updateControl","typedValue","val","typedValueEquals","displayValue","_unbindEvents","_fireEvent","ev","e","listeners","l","_cursorChanging","_changingCursorPos","pos","_selection","newUnmaskedValue","newValue","newDisplayValue","isChanged","_fireChangeEvents","restOpts","updateMask","updateOpts","updateCursor","_delayUpdateCursor","_abortUpdateCursor","setTimeout","_inputEvent","isComplete","clearTimeout","nearestInputPos","on","push","off","hIndex","indexOf","splice","details","oldRawValue","rawInputValue","offset","raw","doCommit","preventDefault","stopPropagation","destroy","ChangeDetails","static","prep","rawInserted","skip","tailShift","aggregate","ContinuousTailDetails","from","stop","extend","appendTo","append","_appendPlaceholder","state","unshift","beforePos","shiftChar","shift","_update","DEFAULTS","_initialized","withValueRefresh","_rawInputValue","reset","resolve","flags","parse","format","extractInput","isFilled","totalInputPositions","fromPos","toPos","extractTail","appendTail","_appendCharRaw","ch","_appendChar","checkTail","consistentState","doPrepareChar","consistentTail","appended","doValidate","beforeTailState","overwrite","tailDetails","_appendEager","_beforeTailState","doPrepare","ci","d","doSkipInvalid","eager","remove","fn","_refreshing","rawInput","ret","runIsolated","_isolated","Boolean","skipInvalid","normalize","prepare","prepareChar","validate","parent","deleteCount","tailPos","eagerRemove","valLength","tval","EMPTY_VALUES","undefined","ChunksTailDetails","chunks","map","join","tailChunk","lastChunk","extendLast","firstTailChunk","blockIndex","chunk","lastBlockIter","_mapPosToBlock","chunkBlock","index","_stops","phDetails","_blocks","remainChars","c","props","cstate","chunkShiftPos","PatternCursor","_log","ok","block","_blockStartPos","s","pushState","popState","pop","bindBlock","_pushLeft","_this$block","_pushRight","pushLeftBeforeFilled","isFixed","pushLeftBeforeInput","pushLeftBeforeRequired","isOptional","pushRightBeforeFilled","pushRightBeforeInput","pushRightBeforeRequired","PatternFixedDefinition","isUnmasking","_isRawInput","maxPos","appendEager","isResolved","char","PatternInputDefinition","placeholderChar","displayChar","lazy","maskOpts","currentMaskFlags","boundPos","_flags$_beforeTailSta","DEFAULT_DEFINITIONS","search","definitions","_rebuildMask","defs","exposeBlock","_maskedBlocks","pattern","unmaskingBlock","optionalBlock","blocks","p","bNames","filter","bName","sort","expose","blockOpts","maskedBlock","isInput","STOP_CHAR","ESCAPE_CHAR","def","maskedState","bi","every","_this$_mapPosToBlock","startBlockIndex","blockIter","blockDetails","chunkTail","_forEachBlocksInRange","bFromPos","bToPos","blockChunk","_findStopBefore","stopBefore","si","toBlockIndex","startBlockIter","endBlockIndex","_blocks2","bDetails","accVal","blockStartPos","fromBlockIter","toBlockIter","isSameBlock","fromBlockStartPos","fromBlockEndPos","removeDetails","cursor","total","maskedBlocks","indices","gi","InputDefinition","FixedDefinition","MaskedRange","_matchFrom","maxLength","to","autofix","patternOpts","fromStr","padStart","toStr","sameCharsCount","repeat","boundaries","minstr","maxstr","placeholder","num","match","padEnd","nextVal","patternBlocks","GET_DEFAULT_BLOCKS","Y","getFullYear","m","getMonth","getDate","bk","date","isDateExist","day","month","year","split","currentMask","exposeMask","compiledMasks","_overwrite","_eager","_skipInvalid","_applyDispatch","prevValueBeforeTail","inputValue","insertValue","tailValue","prevMask","prevMaskState","doDispatch","_flags$_beforeTailSta2","currentMaskRef","dispatch","currentDetails","_this$currentMask","_this$currentMask2","_this$currentMask3","_this$currentMask4","mi","oldMask","_this$currentMask5","inputs","isCurrent","startInputPos","weight","i1","i2","MaskedEnum","enum","_enum","eopts","lengths","requiredLength","optionalLength","some","_updateRegExps","allowNegative","scale","radix","_numberRegExp","_mapToRadixRegExp","mapToRadix","_thousandsSeparatorRegExp","thousandsSeparator","_removeThousandsSeparators","_insertThousandsSeparators","parts","prepCh","allowPositive","_separatorsCount","extendOnSeparators","count","_separatorsCountFromSlice","_adjustRangeWithSeparators","prevBeforeTailValue","prevBeforeTailSeparatorsCount","appendDetails","beforeTailValue","beforeTailSeparatorsCount","_findSeparatorAround","searchFrom","separatorPos","separatorAroundFromPos","separatorAroundToPos","valueBeforePos","valueAfterPos","separatorAtLeftPos","separatorAtLeftEndPos","separatorAtRightPos","valid","number","isNaN","validnum","formatted","normalizeZeros","_normalizeZeros","padFractionalZeros","_padFractionalZeros","sign","zeros","test","dropFractional","UNMASKED_RADIX","n","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","toLocaleString","useGrouping","maximumFractionDigits","PIPE_TYPE","MASKED","UNMASKED","TYPED","createPipe","arg","pipe","globalThis"],"mappings":"6OAEA,SAASA,EAAUC,GACjB,MAAsB,iBAARA,GAAoBA,aAAeC,MACnD,CAIA,SAASC,EAAUC,GAA6B,IAAAC,EAC9C,MAAsB,iBAARD,GAA2B,MAAPA,GAA0C,kBAA3BA,UAAGC,EAAHD,EAAKE,oBAALD,EAAkBE,KACrE,CAGA,SAASC,EACPJ,EACAK,GAEA,OAAIC,MAAMC,QAAQF,GAAcD,EAAKJ,GAAK,CAACQ,EAAGC,IAAMJ,EAAKK,SAASD,KAC1DE,OAAOC,QAAQZ,GACpBa,QAAO,CAACC,EAAGC,KAAa,IAAVN,EAAGO,GAAED,EAElB,OADIV,EAAKW,EAAGP,KAAIK,EAAIL,GAAKO,GAClBF,CAAG,GACT,CAAS,EAChB,CAIA,MAAMG,EAAY,CAChBC,KAAM,OACNC,KAAM,OACNC,WAAY,aACZC,MAAO,QACPC,YAAa,eAQf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