// Metro module 5430 (f5431). import _classCallCheck from "./_classCallCheck_5425"; import _createClass from "./_createClass_5426"; let c3313_1; let MultiTypeAverageWindow; let env3313 = {}; const AverageWindow = function AverageWindow(a0, a1) { _classCallCheck(this, AverageWindow); this.nextIndex = 0; const r8 = Array; const r9 = Math; let currentCount = 1; this.inputValues = new r8(r9.max(1, a0)); this.currentAverage = a1 == null ? 0 : a1; if (a1 === void 0) { currentCount = 0; } this.currentCount = currentCount; this.nextIndex = this.currentCount; this.inputValues[0] = a1; }; c3313_1 = _createClass(AverageWindow, [{ key: "currentValue", get: function get() { return this.currentAverage; } }, { key: "addValue", value: function addValue(a0) { const nextIndex = this.getNextIndex(); let r9 = this.inputValues[nextIndex]; const currentCount = r9 === void 0 ? this.currentCount + 1 : this.currentCount; this.inputValues[nextIndex] = a0; const r15 = Math; const r18 = this.currentAverage * (this.currentCount / currentCount); if (r9 == null) { r9 = 0; } this.currentAverage = r15.max(0, r18 + (a0 - r9) / currentCount); this.currentCount = currentCount; } }, { key: "getNextIndex", value: function getNextIndex() { const nextIndex = this.nextIndex; this.nextIndex = (this.nextIndex + 1) % this.inputValues.length; return nextIndex; } }]); MultiTypeAverageWindow = function MultiTypeAverageWindow(a0, a1) { _classCallCheck(this, MultiTypeAverageWindow); this.averageWindows = new Map(); this.windowSize = a0; this.defaultValue = a1; }; const r34 = _createClass(MultiTypeAverageWindow, [{ key: "addValue", value: function addValue(a0, a1) { let r10 = this.averageWindows.get(a1); if (!r10) { const r13 = new c3313_1(this.windowSize); this.averageWindows.set(a1, r13); r10 = r13; } r10.addValue(a0); } }, { key: "getCurrentValue", value: function getCurrentValue(a0) { let r8 = this.averageWindows.get(a0)?.currentValue; if (r8 == null) { r8 = this.defaultValue; } if (r8 == null) { r8 = 0; } return r8; } }, { key: "reset", value: function reset() { this.averageWindows.clear(); } }]); export { c3313_1 as AverageWindow }; export { r34 as MultiTypeAverageWindow };