{"version":3,"names":["Annotations","constructor","_annotations","add","obj","push","has","prop","find","hasOwnProperty","keys","Object","assign","get","getAll","propName","filter","map","squash"],"sources":["annotations.js"],"sourcesContent":["/**\n *\n * @class Annotations\n * @classdesc Stores and combines multiple plain JavaScript objects for configuration or preferences.\n * @example Usage of the Annotations utility\n * import Annotations from 'src/client/reactive/active-expressions/active-expressions/src/annotations.js';\n *\n * const ann = new Annotations();\n * ann.add({ name: 'Lively4' });\n * ann.add({ name: 'Annotations', color: 'green' });\n *\n * ann.keys(); // ['name', 'color']\n * ann.has('name'); // true\n * ann.get('name'); // 'Lively4'\n * ann.getAll('name'); // ['Lively4', 'Annotations']\n */\nexport default class Annotations {\n  constructor() {\n    this._annotations = [];\n  }\n\n  /**\n   * Stores a new annotation object.\n   * @function Annotations#add\n   * @param {Object} obj - A plain JavaScript object to add as annotation.\n   */\n  add(obj) {\n    this._annotations.push(obj);\n  }\n\n  /**\n   * Checks whether there is some value stored for a given property.\n   * @function Annotations#has\n   * @param {String} prop - The property name we search values for.\n   * @return {Boolean} True, if there is a value for the key, false otherwise.\n   */\n  has(prop) {\n    return !!this._annotations.find(obj => obj.hasOwnProperty(prop));\n  }\n\n  /**\n   * Get all properties for which we have at least one value.\n   * @function Annotations#keys\n   * @return {Array<String>} An array containing all properties for which values are currently defined.\n   */\n  keys() {\n    return Object.keys(Object.assign({}, ...this._annotations));\n  }\n\n  /**\n   * Get a value associated to the given property.\n   * @function Annotations#get\n   * @param {String} prop - The property name we search values for.\n   * @return {any} A value previously added to the property, or undefined if no value was defined previously.\n   */\n  get(prop) {\n    return this.getAll(prop)[0];\n  }\n\n  /**\n   * Get all values associated to the given property.\n   * @function Annotations#getAll\n   * @param {String} propName - The property name we search values for.\n   * @return {Array<any>} An array containing all values associated to the property.\n   */\n  getAll(propName) {\n    return this._annotations\n      .filter(obj => obj.hasOwnProperty(propName))\n      .map(obj => obj[propName]);\n  }\n\n  squash() {\n    return Object.assign({}, ...this._annotations);\n  }\n}\n"],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