var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
    function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
    var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
    var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
    var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
    var _, done = false;
    for (var i = decorators.length - 1; i >= 0; i--) {
        var context = {};
        for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
        for (var p in contextIn.access) context.access[p] = contextIn.access[p];
        context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
        var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
        if (kind === "accessor") {
            if (result === void 0) continue;
            if (result === null || typeof result !== "object") throw new TypeError("Object expected");
            if (_ = accept(result.get)) descriptor.get = _;
            if (_ = accept(result.set)) descriptor.set = _;
            if (_ = accept(result.init)) initializers.unshift(_);
        }
        else if (_ = accept(result)) {
            if (kind === "field") initializers.unshift(_);
            else descriptor[key] = _;
        }
    }
    if (target) Object.defineProperty(target, contextIn.name, descriptor);
    done = true;
};
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
    var useValue = arguments.length > 2;
    for (var i = 0; i < initializers.length; i++) {
        value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
    }
    return useValue ? value : void 0;
};
import * as plugins from '../../plugins.js';
import { DcRouterDb } from '../classes.dcrouter-db.js';
const getDb = () => DcRouterDb.getInstance().getDb();
let AccountingSessionDoc = (() => {
    let _classDecorators = [plugins.smartdata.Collection(() => getDb())];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = plugins.smartdata.SmartDataDbDoc;
    let _sessionId_decorators;
    let _sessionId_initializers = [];
    let _sessionId_extraInitializers = [];
    let _username_decorators;
    let _username_initializers = [];
    let _username_extraInitializers = [];
    let _macAddress_decorators;
    let _macAddress_initializers = [];
    let _macAddress_extraInitializers = [];
    let _nasIpAddress_decorators;
    let _nasIpAddress_initializers = [];
    let _nasIpAddress_extraInitializers = [];
    let _nasPort_decorators;
    let _nasPort_initializers = [];
    let _nasPort_extraInitializers = [];
    let _nasPortType_decorators;
    let _nasPortType_initializers = [];
    let _nasPortType_extraInitializers = [];
    let _nasIdentifier_decorators;
    let _nasIdentifier_initializers = [];
    let _nasIdentifier_extraInitializers = [];
    let _vlanId_decorators;
    let _vlanId_initializers = [];
    let _vlanId_extraInitializers = [];
    let _framedIpAddress_decorators;
    let _framedIpAddress_initializers = [];
    let _framedIpAddress_extraInitializers = [];
    let _calledStationId_decorators;
    let _calledStationId_initializers = [];
    let _calledStationId_extraInitializers = [];
    let _callingStationId_decorators;
    let _callingStationId_initializers = [];
    let _callingStationId_extraInitializers = [];
    let _startTime_decorators;
    let _startTime_initializers = [];
    let _startTime_extraInitializers = [];
    let _endTime_decorators;
    let _endTime_initializers = [];
    let _endTime_extraInitializers = [];
    let _lastUpdateTime_decorators;
    let _lastUpdateTime_initializers = [];
    let _lastUpdateTime_extraInitializers = [];
    let _status_decorators;
    let _status_initializers = [];
    let _status_extraInitializers = [];
    let _terminateCause_decorators;
    let _terminateCause_initializers = [];
    let _terminateCause_extraInitializers = [];
    let _inputOctets_decorators;
    let _inputOctets_initializers = [];
    let _inputOctets_extraInitializers = [];
    let _outputOctets_decorators;
    let _outputOctets_initializers = [];
    let _outputOctets_extraInitializers = [];
    let _inputPackets_decorators;
    let _inputPackets_initializers = [];
    let _inputPackets_extraInitializers = [];
    let _outputPackets_decorators;
    let _outputPackets_initializers = [];
    let _outputPackets_extraInitializers = [];
    let _sessionTime_decorators;
    let _sessionTime_initializers = [];
    let _sessionTime_extraInitializers = [];
    let _serviceType_decorators;
    let _serviceType_initializers = [];
    let _serviceType_extraInitializers = [];
    var AccountingSessionDoc = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _sessionId_decorators = [plugins.smartdata.unI(), plugins.smartdata.svDb()];
            _username_decorators = [plugins.smartdata.svDb()];
            _macAddress_decorators = [plugins.smartdata.svDb()];
            _nasIpAddress_decorators = [plugins.smartdata.svDb()];
            _nasPort_decorators = [plugins.smartdata.svDb()];
            _nasPortType_decorators = [plugins.smartdata.svDb()];
            _nasIdentifier_decorators = [plugins.smartdata.svDb()];
            _vlanId_decorators = [plugins.smartdata.svDb()];
            _framedIpAddress_decorators = [plugins.smartdata.svDb()];
            _calledStationId_decorators = [plugins.smartdata.svDb()];
            _callingStationId_decorators = [plugins.smartdata.svDb()];
            _startTime_decorators = [plugins.smartdata.svDb()];
            _endTime_decorators = [plugins.smartdata.svDb()];
            _lastUpdateTime_decorators = [plugins.smartdata.svDb()];
            _status_decorators = [plugins.smartdata.index(), plugins.smartdata.svDb()];
            _terminateCause_decorators = [plugins.smartdata.svDb()];
            _inputOctets_decorators = [plugins.smartdata.svDb()];
            _outputOctets_decorators = [plugins.smartdata.svDb()];
            _inputPackets_decorators = [plugins.smartdata.svDb()];
            _outputPackets_decorators = [plugins.smartdata.svDb()];
            _sessionTime_decorators = [plugins.smartdata.svDb()];
            _serviceType_decorators = [plugins.smartdata.svDb()];
            __esDecorate(null, null, _sessionId_decorators, { kind: "field", name: "sessionId", static: false, private: false, access: { has: obj => "sessionId" in obj, get: obj => obj.sessionId, set: (obj, value) => { obj.sessionId = value; } }, metadata: _metadata }, _sessionId_initializers, _sessionId_extraInitializers);
            __esDecorate(null, null, _username_decorators, { kind: "field", name: "username", static: false, private: false, access: { has: obj => "username" in obj, get: obj => obj.username, set: (obj, value) => { obj.username = value; } }, metadata: _metadata }, _username_initializers, _username_extraInitializers);
            __esDecorate(null, null, _macAddress_decorators, { kind: "field", name: "macAddress", static: false, private: false, access: { has: obj => "macAddress" in obj, get: obj => obj.macAddress, set: (obj, value) => { obj.macAddress = value; } }, metadata: _metadata }, _macAddress_initializers, _macAddress_extraInitializers);
            __esDecorate(null, null, _nasIpAddress_decorators, { kind: "field", name: "nasIpAddress", static: false, private: false, access: { has: obj => "nasIpAddress" in obj, get: obj => obj.nasIpAddress, set: (obj, value) => { obj.nasIpAddress = value; } }, metadata: _metadata }, _nasIpAddress_initializers, _nasIpAddress_extraInitializers);
            __esDecorate(null, null, _nasPort_decorators, { kind: "field", name: "nasPort", static: false, private: false, access: { has: obj => "nasPort" in obj, get: obj => obj.nasPort, set: (obj, value) => { obj.nasPort = value; } }, metadata: _metadata }, _nasPort_initializers, _nasPort_extraInitializers);
            __esDecorate(null, null, _nasPortType_decorators, { kind: "field", name: "nasPortType", static: false, private: false, access: { has: obj => "nasPortType" in obj, get: obj => obj.nasPortType, set: (obj, value) => { obj.nasPortType = value; } }, metadata: _metadata }, _nasPortType_initializers, _nasPortType_extraInitializers);
            __esDecorate(null, null, _nasIdentifier_decorators, { kind: "field", name: "nasIdentifier", static: false, private: false, access: { has: obj => "nasIdentifier" in obj, get: obj => obj.nasIdentifier, set: (obj, value) => { obj.nasIdentifier = value; } }, metadata: _metadata }, _nasIdentifier_initializers, _nasIdentifier_extraInitializers);
            __esDecorate(null, null, _vlanId_decorators, { kind: "field", name: "vlanId", static: false, private: false, access: { has: obj => "vlanId" in obj, get: obj => obj.vlanId, set: (obj, value) => { obj.vlanId = value; } }, metadata: _metadata }, _vlanId_initializers, _vlanId_extraInitializers);
            __esDecorate(null, null, _framedIpAddress_decorators, { kind: "field", name: "framedIpAddress", static: false, private: false, access: { has: obj => "framedIpAddress" in obj, get: obj => obj.framedIpAddress, set: (obj, value) => { obj.framedIpAddress = value; } }, metadata: _metadata }, _framedIpAddress_initializers, _framedIpAddress_extraInitializers);
            __esDecorate(null, null, _calledStationId_decorators, { kind: "field", name: "calledStationId", static: false, private: false, access: { has: obj => "calledStationId" in obj, get: obj => obj.calledStationId, set: (obj, value) => { obj.calledStationId = value; } }, metadata: _metadata }, _calledStationId_initializers, _calledStationId_extraInitializers);
            __esDecorate(null, null, _callingStationId_decorators, { kind: "field", name: "callingStationId", static: false, private: false, access: { has: obj => "callingStationId" in obj, get: obj => obj.callingStationId, set: (obj, value) => { obj.callingStationId = value; } }, metadata: _metadata }, _callingStationId_initializers, _callingStationId_extraInitializers);
            __esDecorate(null, null, _startTime_decorators, { kind: "field", name: "startTime", static: false, private: false, access: { has: obj => "startTime" in obj, get: obj => obj.startTime, set: (obj, value) => { obj.startTime = value; } }, metadata: _metadata }, _startTime_initializers, _startTime_extraInitializers);
            __esDecorate(null, null, _endTime_decorators, { kind: "field", name: "endTime", static: false, private: false, access: { has: obj => "endTime" in obj, get: obj => obj.endTime, set: (obj, value) => { obj.endTime = value; } }, metadata: _metadata }, _endTime_initializers, _endTime_extraInitializers);
            __esDecorate(null, null, _lastUpdateTime_decorators, { kind: "field", name: "lastUpdateTime", static: false, private: false, access: { has: obj => "lastUpdateTime" in obj, get: obj => obj.lastUpdateTime, set: (obj, value) => { obj.lastUpdateTime = value; } }, metadata: _metadata }, _lastUpdateTime_initializers, _lastUpdateTime_extraInitializers);
            __esDecorate(null, null, _status_decorators, { kind: "field", name: "status", static: false, private: false, access: { has: obj => "status" in obj, get: obj => obj.status, set: (obj, value) => { obj.status = value; } }, metadata: _metadata }, _status_initializers, _status_extraInitializers);
            __esDecorate(null, null, _terminateCause_decorators, { kind: "field", name: "terminateCause", static: false, private: false, access: { has: obj => "terminateCause" in obj, get: obj => obj.terminateCause, set: (obj, value) => { obj.terminateCause = value; } }, metadata: _metadata }, _terminateCause_initializers, _terminateCause_extraInitializers);
            __esDecorate(null, null, _inputOctets_decorators, { kind: "field", name: "inputOctets", static: false, private: false, access: { has: obj => "inputOctets" in obj, get: obj => obj.inputOctets, set: (obj, value) => { obj.inputOctets = value; } }, metadata: _metadata }, _inputOctets_initializers, _inputOctets_extraInitializers);
            __esDecorate(null, null, _outputOctets_decorators, { kind: "field", name: "outputOctets", static: false, private: false, access: { has: obj => "outputOctets" in obj, get: obj => obj.outputOctets, set: (obj, value) => { obj.outputOctets = value; } }, metadata: _metadata }, _outputOctets_initializers, _outputOctets_extraInitializers);
            __esDecorate(null, null, _inputPackets_decorators, { kind: "field", name: "inputPackets", static: false, private: false, access: { has: obj => "inputPackets" in obj, get: obj => obj.inputPackets, set: (obj, value) => { obj.inputPackets = value; } }, metadata: _metadata }, _inputPackets_initializers, _inputPackets_extraInitializers);
            __esDecorate(null, null, _outputPackets_decorators, { kind: "field", name: "outputPackets", static: false, private: false, access: { has: obj => "outputPackets" in obj, get: obj => obj.outputPackets, set: (obj, value) => { obj.outputPackets = value; } }, metadata: _metadata }, _outputPackets_initializers, _outputPackets_extraInitializers);
            __esDecorate(null, null, _sessionTime_decorators, { kind: "field", name: "sessionTime", static: false, private: false, access: { has: obj => "sessionTime" in obj, get: obj => obj.sessionTime, set: (obj, value) => { obj.sessionTime = value; } }, metadata: _metadata }, _sessionTime_initializers, _sessionTime_extraInitializers);
            __esDecorate(null, null, _serviceType_decorators, { kind: "field", name: "serviceType", static: false, private: false, access: { has: obj => "serviceType" in obj, get: obj => obj.serviceType, set: (obj, value) => { obj.serviceType = value; } }, metadata: _metadata }, _serviceType_initializers, _serviceType_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            AccountingSessionDoc = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
        sessionId = __runInitializers(this, _sessionId_initializers, void 0);
        username = (__runInitializers(this, _sessionId_extraInitializers), __runInitializers(this, _username_initializers, void 0));
        macAddress = (__runInitializers(this, _username_extraInitializers), __runInitializers(this, _macAddress_initializers, void 0));
        nasIpAddress = (__runInitializers(this, _macAddress_extraInitializers), __runInitializers(this, _nasIpAddress_initializers, void 0));
        nasPort = (__runInitializers(this, _nasIpAddress_extraInitializers), __runInitializers(this, _nasPort_initializers, void 0));
        nasPortType = (__runInitializers(this, _nasPort_extraInitializers), __runInitializers(this, _nasPortType_initializers, void 0));
        nasIdentifier = (__runInitializers(this, _nasPortType_extraInitializers), __runInitializers(this, _nasIdentifier_initializers, void 0));
        vlanId = (__runInitializers(this, _nasIdentifier_extraInitializers), __runInitializers(this, _vlanId_initializers, void 0));
        framedIpAddress = (__runInitializers(this, _vlanId_extraInitializers), __runInitializers(this, _framedIpAddress_initializers, void 0));
        calledStationId = (__runInitializers(this, _framedIpAddress_extraInitializers), __runInitializers(this, _calledStationId_initializers, void 0));
        callingStationId = (__runInitializers(this, _calledStationId_extraInitializers), __runInitializers(this, _callingStationId_initializers, void 0));
        startTime = (__runInitializers(this, _callingStationId_extraInitializers), __runInitializers(this, _startTime_initializers, void 0));
        endTime = (__runInitializers(this, _startTime_extraInitializers), __runInitializers(this, _endTime_initializers, void 0));
        lastUpdateTime = (__runInitializers(this, _endTime_extraInitializers), __runInitializers(this, _lastUpdateTime_initializers, void 0));
        status = (__runInitializers(this, _lastUpdateTime_extraInitializers), __runInitializers(this, _status_initializers, void 0));
        terminateCause = (__runInitializers(this, _status_extraInitializers), __runInitializers(this, _terminateCause_initializers, void 0));
        inputOctets = (__runInitializers(this, _terminateCause_extraInitializers), __runInitializers(this, _inputOctets_initializers, void 0));
        outputOctets = (__runInitializers(this, _inputOctets_extraInitializers), __runInitializers(this, _outputOctets_initializers, void 0));
        inputPackets = (__runInitializers(this, _outputOctets_extraInitializers), __runInitializers(this, _inputPackets_initializers, void 0));
        outputPackets = (__runInitializers(this, _inputPackets_extraInitializers), __runInitializers(this, _outputPackets_initializers, void 0));
        sessionTime = (__runInitializers(this, _outputPackets_extraInitializers), __runInitializers(this, _sessionTime_initializers, void 0));
        serviceType = (__runInitializers(this, _sessionTime_extraInitializers), __runInitializers(this, _serviceType_initializers, void 0));
        constructor() {
            super();
            __runInitializers(this, _serviceType_extraInitializers);
        }
        static async findBySessionId(sessionId) {
            return await AccountingSessionDoc.getInstance({ sessionId });
        }
        static async findActive() {
            return await AccountingSessionDoc.getInstances({ status: 'active' });
        }
        static async findByUsername(username) {
            return await AccountingSessionDoc.getInstances({ username });
        }
        static async findByNas(nasIpAddress) {
            return await AccountingSessionDoc.getInstances({ nasIpAddress });
        }
        static async findByVlan(vlanId) {
            return await AccountingSessionDoc.getInstances({ vlanId });
        }
        static async findStoppedBefore(cutoffTime) {
            return await AccountingSessionDoc.getInstances({
                status: { $in: ['stopped', 'terminated'] },
                endTime: { $lt: cutoffTime, $gt: 0 },
            });
        }
    };
    return AccountingSessionDoc = _classThis;
})();
export { AccountingSessionDoc };
//# sourceMappingURL=data:application/json;base64, 