{"version":3,"sources":["https://lively-kernel.org/lively4/swt1-debugging/src/client/reactive/utils/annotations.js"],"names":["Annotations","constructor","_annotations","add","obj","push","has","prop","find","hasOwnProperty","keys","Object","assign","get","getAll","propName","filter","map","squash"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;;AAgBe,YAAMA,WAAN,CAAkB;AAC/BC,sBAAc;AACZ,eAAKC,YAAL,GAAoB,EAApB;AACD;;AAED;;;;;AAKAC,YAAIC,GAAJ,EAAS;AACP,eAAKF,YAAL,CAAkBG,IAAlB,CAAuBD,GAAvB;AACD;;AAED;;;;;;AAMAE,YAAIC,IAAJ,EAAU;AACR,iBAAO,CAAC,CAAC,KAAKL,YAAL,CAAkBM,IAAlB,CAAuBJ,OAAOA,IAAIK,cAAJ,CAAmBF,IAAnB,CAA9B,CAAT;AACD;;AAED;;;;;AAKAG,eAAO;AACL,iBAAOC,OAAOD,IAAP,CAAYC,OAAOC,MAAP,CAAc,EAAd,EAAkB,GAAG,KAAKV,YAA1B,CAAZ,CAAP;AACD;;AAED;;;;;;AAMAW,YAAIN,IAAJ,EAAU;AACR,iBAAO,KAAKO,MAAL,CAAYP,IAAZ,EAAkB,CAAlB,CAAP;AACD;;AAED;;;;;;AAMAO,eAAOC,QAAP,EAAiB;AACf,iBAAO,KAAKb,YAAL,CACJc,MADI,CACGZ,OAAOA,IAAIK,cAAJ,CAAmBM,QAAnB,CADV,EAEJE,GAFI,CAEAb,OAAOA,IAAIW,QAAJ,CAFP,CAAP;AAGD;;AAEDG,iBAAS;AACP,iBAAOP,OAAOC,MAAP,CAAc,EAAd,EAAkB,GAAG,KAAKV,YAA1B,CAAP;AACD;AAzD8B;;yBAAZF,W","file":"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"]}