{"version":3,"file":"CommonMethods.min.mjs","names":[],"sources":["../../src/CommonMethods.ts"],"sourcesContent":["import { Observable } from './Observable';\n\nexport class CommonMethods<EventSpec> extends Observable<EventSpec> {\n  /**\n   * Sets object's properties from options, for initialization only\n   * @protected\n   * @param {Object} [options] Options object\n   */\n  protected _setOptions(options: any = {}) {\n    for (const prop in options) {\n      this.set(prop, options[prop]);\n    }\n  }\n\n  /**\n   * @private\n   */\n  _setObject(obj: Record<string, any>) {\n    for (const prop in obj) {\n      this._set(prop, obj[prop]);\n    }\n  }\n\n  /**\n   * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`.\n   * @param {String|Object} key Property name or object (if object, iterate over the object properties)\n   * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one)\n   */\n  set(key: string | Record<string, any>, value?: any) {\n    if (typeof key === 'object') {\n      this._setObject(key);\n    } else {\n      this._set(key, value);\n    }\n    return this;\n  }\n\n  _set(key: string, value: any) {\n    this[key as keyof this] = value;\n  }\n\n  /**\n   * Toggles specified property from `true` to `false` or from `false` to `true`\n   * @param {String} property Property to toggle\n   */\n  toggle(property: string) {\n    const value = this.get(property);\n    if (typeof value === 'boolean') {\n      this.set(property, !value);\n    }\n    return this;\n  }\n\n  /**\n   * Basic getter\n   * @param {String} property Property name\n   * @return {*} value of a property\n   */\n  get(property: string): any {\n    return this[property as keyof this];\n  }\n}\n"],"mappings":"kDAEA,IAAa,EAAb,cAA8C,CAAA,CAM5C,YAAsB,EAAe,EAAA,CAAA,CACnC,IAAK,IAAM,KAAQ,EACjB,KAAK,IAAI,EAAM,EAAQ,GAAA,CAO3B,WAAW,EAAA,CACT,IAAK,IAAM,KAAQ,EACjB,KAAK,KAAK,EAAM,EAAI,GAAA,CASxB,IAAI,EAAmC,EAAA,CAMrC,OALmB,OAAR,GAAQ,SACjB,KAAK,WAAW,EAAA,CAEhB,KAAK,KAAK,EAAK,EAAA,CAEV,KAGT,KAAK,EAAa,EAAA,CAChB,KAAK,GAAqB,EAO5B,OAAO,EAAA,CACL,IAAM,EAAQ,KAAK,IAAI,EAAA,CAIvB,OAHqB,OAAV,GAAU,WACnB,KAAK,IAAI,EAAA,CAAW,EAAA,CAEf,KAQT,IAAI,EAAA,CACF,OAAO,KAAK,KAAA,OAAA,KAAA"}