{"version":3,"file":"typescript-package-length.mjs","sources":["../../../package/length/src/lib/length.class.ts","../../../package/length/src/public-api.ts","../../../package/length/src/typescript-package-length.ts"],"sourcesContent":["// Interface.\nimport { LengthOptions, LengthSettings } from '@typedly/length';\n/**\n * @description Represents a length value with optional minimum and maximum constraints.\n * @export\n * @class Length\n * @template {number | undefined} [Value=number | undefined] The type of the length value, which can be a number or undefined.\n * @template {number | undefined} [Min=number | undefined] The type of the minimum length value, which can be a number or undefined.\n * @template {number | undefined} [Max=number | undefined] The type of the maximum length value, which can be a number or undefined.\n */\nexport class Length<\n  Value extends number | undefined = number | undefined,\n  Min extends number | undefined = number | undefined,\n  Max extends number | undefined = number | undefined,\n>  {\n  /**\n   * @description The length value of generic type variable `Value`.\n   * @public\n   * @readonly\n   * @type {Value }\n   */\n  public get length(): Value {\n    return this.#value;\n  }\n\n  /**\n   * @description The maximum length value of generic type variable `Max`.\n   * @public\n   * @readonly\n   * @type {Max}\n   */\n  public get max(): Max {\n    return this.#max;\n  }\n\n  /**\n   * @description The minimum length value of generic type variable `Min`.\n   * @public\n   * @readonly\n   * @type {Min}\n   */\n  public get min(): Min {\n    return this.#min;\n  }\n\n  /**\n   * @description The configuration object containing the length, minimum, and maximum values.\n   * @public\n   * @readonly\n   * @type {LengthSettings<Value, Min, Max>}\n   */\n  public get config(): LengthSettings<Value, Min, Max> {\n    return {\n      value: this.#value,\n      min: this.#min,\n      max: this.#max,\n    };\n  }\n\n  \n  /**\n   * @description Privately stored maximum length value of generic type variable `Max`.\n   * @type {Max}\n   */\n  #max: Max;\n\n  /**\n   * @description Privately stored minimum length value of generic type variable `Min`.\n   * @type {Min}\n   */\n  #min: Min;\n\n  /**\n   * @description Privately stored length value of generic type variable `Value`.\n   * @type {Value}\n   */\n  #value: Value;\n\n  /**\n   * Creates an instance of `Length`.\n   * @constructor\n   * @param {?(Value | LengthOptions<Value, Min, Max>)} [length] The initial length value, which can be a number or an object containing min, max, and value properties.\n   */\n  constructor(length?: Value | LengthOptions<Value, Min, Max>) {\n    this.#value = typeof length === 'number'\n      ? length\n      : typeof length === 'object' ? length.value as Value : undefined as Value;\n    this.#max = typeof length === 'object' && 'max' in length ? length.max as Max : undefined as Max;\n    this.#min = typeof length === 'object' && 'min' in length ? length.min as Min : undefined as Min;\n  }\n\n  /**\n   * @description Checks whether the length is valid based on the defined minimum and maximum constraints.\n   * @public\n   * @returns {boolean} Returns the true if the length is valid, otherwise false.\n   */\n  public isValid(): boolean {\n    if (typeof this.length === 'number') {\n      if (typeof this.min === 'number' && this.length < this.min) return false;\n      if (typeof this.max === 'number' && this.length > this.max) return false;\n    }\n    return true;\n  }\n\n  /**\n   * @description Sets the length, minimum, and maximum values.\n   * @public\n   * @param {LengthOptions<Value, Min, Max>} [param0={}] \n   * @param {LengthOptions<Value, Min, Max>} param0.max Optional maximum length value.\n   * @param {LengthOptions<Value, Min, Max>} param0.min Optional minimum length value.\n   * @param {LengthOptions<Value, Min, Max>} param0.value Optional length value.\n   * @returns {this} The current instance of Length.\n   */\n  public set({ max, min, value }: LengthOptions<Value, Min, Max> = {}): this {\n    'max' in arguments[0] && this.setMax(max);\n    'min' in arguments[0] && this.setMin(min);\n    'value' in arguments[0] && this.setLength(value);\n    return this;\n  }\n\n  /**\n   * @description Sets the length value.\n   * @public\n   * @param {(Value | undefined)} value The length value to set.\n   * @returns {this} The current instance of Length.\n   */\n  public setLength(value: Value | undefined): this {\n    this.#value = value as Value;\n    return this;\n  }\n\n  /**\n   * @description Sets the maximum length value.\n   * @public\n   * @param {(Max | undefined)} max The maximum length value to set.\n   * @returns {this} The current instance of Length.\n   */\n  public setMax(max: Max | undefined): this {\n    this.#max = max as Max;\n    return this;\n  }\n\n  /**\n   * @description Sets the minimum length value.\n   * @public\n   * @param {(Min | undefined)} min The minimum length value to set.\n   * @returns {this} The current instance of Length.\n   */\n  public setMin(min: Min | undefined): this {\n    this.#min = min as Min;\n    return this;\n  }\n\n  /**\n   * @description Sets both the minimum and maximum length values.\n   * @public\n   * @param {Min | undefined} min The minimum length value to set.\n   * @param {Max | undefined} max The maximum length value to set.\n   * @returns {this} The current instance of Length.\n   */\n  public setMinMax(min: Min | undefined, max: Max | undefined): this {\n    this.setMax(max).setMin(min);\n    return this;\n  }\n}\n","/*\n * Public API Surface of length\n */\n\nexport {\n  Length\n} from './lib';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAEA;;;;;;;AAOG;MACU,MAAM,CAAA;AAKjB;;;;;AAKG;AACH,IAAA,IAAW,MAAM,GAAA;QACf,OAAO,IAAI,CAAC,MAAM;;AAGpB;;;;;AAKG;AACH,IAAA,IAAW,GAAG,GAAA;QACZ,OAAO,IAAI,CAAC,IAAI;;AAGlB;;;;;AAKG;AACH,IAAA,IAAW,GAAG,GAAA;QACZ,OAAO,IAAI,CAAC,IAAI;;AAGlB;;;;;AAKG;AACH,IAAA,IAAW,MAAM,GAAA;QACf,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,GAAG,EAAE,IAAI,CAAC,IAAI;YACd,GAAG,EAAE,IAAI,CAAC,IAAI;SACf;;AAIH;;;AAGG;AACH,IAAA,IAAI;AAEJ;;;AAGG;AACH,IAAA,IAAI;AAEJ;;;AAGG;AACH,IAAA,MAAM;AAEN;;;;AAIG;AACH,IAAA,WAAA,CAAY,MAA+C,EAAA;AACzD,QAAA,IAAI,CAAC,MAAM,GAAG,OAAO,MAAM,KAAK;AAC9B,cAAE;AACF,cAAE,OAAO,MAAM,KAAK,QAAQ,GAAG,MAAM,CAAC,KAAc,GAAG,SAAkB;QAC3E,IAAI,CAAC,IAAI,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,IAAI,MAAM,GAAG,MAAM,CAAC,GAAU,GAAG,SAAgB;QAChG,IAAI,CAAC,IAAI,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,IAAI,MAAM,GAAG,MAAM,CAAC,GAAU,GAAG,SAAgB;;AA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