{"version":3,"names":["Stack","__SystemJSRewritingHack","_export","setters","execute","_recorder_","_src_client_reactive_utils_stack_js","constructor","arr","push","element","pop","length","top","withElement","el","callback","context","call","findUp","args","reverse","find","findDown","Object","defineProperty","get","set","thisIsVererySecretVariableName","enumerable","configurable"],"sources":["stack.js"],"sourcesContent":["/**\n * @class Stack\n *\n * @example\n * import Stack from 'stack-es2015-module';\n *\n * let stack = new Stack();\n *\n * stack.push(42);\n * stack.push(17);\n * stack.top(); // 17\n * stack.pop();\n * stack.top(); // 42\n * stack.withElement(33, () => {\n *   stack.top(); // 33\n * });\n */\nexport default class Stack {\n  /**\n   * Initializes a new empty `Stack`.\n   * @method constructor\n   */\n  constructor() {\n    this.arr = [];\n  };\n\n  /**\n   * Pushes the `element` at the top of the stack.\n   * @method push\n   * @param {any} element - The element to be pushed on top of the stack.\n   */\n  push(element) {\n    this.arr.push(element);\n  }\n\n  /**\n   * Pops the top element of the stack.\n   * @method pop\n   */\n  pop() {\n    this.arr.length--;\n  }\n\n  /**\n   * Returns the top element of the stack.\n   * @method top\n   * @return {any} The value on top of the stack.\n   */\n  top() {\n    // TODO: .last() not defined in older node versions\n    // return this.arr.last();\n    return this.arr[this.arr.length - 1];\n  }\n\n  /**\n   * Pushes the `element` at the top of the stack and executes the `callback` with the optional `context`.\n   * After successfully returning from the `callback` or upon an uncatched error, the top element is poped from the stack.\n   * @method withElement\n   * @param {any} el - The element temporarily on stack.\n   * @param {function} callback - The function to be called.\n   * @param {Object} context - The this reference use for the call.\n   */\n  withElement(el, callback, context) {\n    this.push(el);\n    try {\n      callback.call(context);\n    } finally {\n      this.pop();\n    }\n  }\n\n  /**\n   * Returns an element from the stack that satisfies the given condition, search fron bottom to top.\n   * @method findUp\n   * @param {function} callback - The condition to be called.\n   * @param {any} thisArg - This object passed as `this` into the `callback`.\n   * @return {any} The element satisfying the condition.\n   */\n  findUp(...args) {\n    return this.arr.reverse().find(...args);\n  }\n\n  /**\n   * Returns an element from the stack that satisfies the given condition, search from top to bottom.\n   * @method findDown\n   * @param {function} callback - The condition to be called.\n   * @param {any} thisArg - This object passed as `this` into the `callback`.\n   * @return {any} The element satisfying the condition.\n   */\n  findDown(...args) {\n    return this.arr.find(...args);\n  }\n\n}\n"],"mappings":";;;MAiBqBA,KAAK,EAAAC,uBAAA;EAAAC,OAAA;EAAA;IAAAC,OAAA;IAAAC,OAAA,WAAAA,CAAA;MAAAH,uBAAA;MAAAI,UAAA,CAAAC,mCAAA,GAAAD,UAAA,CAAAC,mCAAA;MAjB1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MAhBAJ,OAAA,YAiBqBF,KAAK,GAAX,MAAMA,KAAK,CAAC;QACzB;AACF;AACA;AACA;QACEO,WAAWA,CAAA,EAAG;UACZ,IAAI,CAACC,GAAG,GAAG,EAAE;QACf;QAEA;AACF;AACA;AACA;AACA;QACEC,IAAIA,CAACC,OAAO,EAAE;UACZ,IAAI,CAACF,GAAG,CAACC,IAAI,CAACC,OAAO,CAAC;QACxB;;QAEA;AACF;AACA;AACA;QACEC,GAAGA,CAAA,EAAG;UACJ,IAAI,CAACH,GAAG,CAACI,MAAM,EAAE;QACnB;;QAEA;AACF;AACA;AACA;AACA;QACEC,GAAGA,CAAA,EAAG;UACJ;UACA;UACA,OAAO,IAAI,CAACL,GAAG,CAAC,IAAI,CAACA,GAAG,CAACI,MAAM,GAAG,CAAC,CAAC;QACtC;;QAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;QACEE,WAAWA,CAACC,EAAE,EAAEC,QAAQ,EAAEC,OAAO,EAAE;UACjC,IAAI,CAACR,IAAI,CAACM,EAAE,CAAC;UACb,IAAI;YACFC,QAAQ,CAACE,IAAI,CAACD,OAAO,CAAC;UACxB,CAAC,SAAS;YACR,IAAI,CAACN,GAAG,CAAC,CAAC;UACZ;QACF;;QAEA;AACF;AACA;AACA;AACA;AACA;AACA;QACEQ,MAAMA,CAAC,GAA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