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 IpIntelligenceDoc = (() => {
    let _classDecorators = [plugins.smartdata.Collection(() => getDb())];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = plugins.smartdata.SmartDataDbDoc;
    let _ipAddress_decorators;
    let _ipAddress_initializers = [];
    let _ipAddress_extraInitializers = [];
    let _asn_decorators;
    let _asn_initializers = [];
    let _asn_extraInitializers = [];
    let _asnOrg_decorators;
    let _asnOrg_initializers = [];
    let _asnOrg_extraInitializers = [];
    let _registrantOrg_decorators;
    let _registrantOrg_initializers = [];
    let _registrantOrg_extraInitializers = [];
    let _registrantCountry_decorators;
    let _registrantCountry_initializers = [];
    let _registrantCountry_extraInitializers = [];
    let _networkRange_decorators;
    let _networkRange_initializers = [];
    let _networkRange_extraInitializers = [];
    let _networkCidrs_decorators;
    let _networkCidrs_initializers = [];
    let _networkCidrs_extraInitializers = [];
    let _abuseContact_decorators;
    let _abuseContact_initializers = [];
    let _abuseContact_extraInitializers = [];
    let _country_decorators;
    let _country_initializers = [];
    let _country_extraInitializers = [];
    let _countryCode_decorators;
    let _countryCode_initializers = [];
    let _countryCode_extraInitializers = [];
    let _city_decorators;
    let _city_initializers = [];
    let _city_extraInitializers = [];
    let _latitude_decorators;
    let _latitude_initializers = [];
    let _latitude_extraInitializers = [];
    let _longitude_decorators;
    let _longitude_initializers = [];
    let _longitude_extraInitializers = [];
    let _accuracyRadius_decorators;
    let _accuracyRadius_initializers = [];
    let _accuracyRadius_extraInitializers = [];
    let _timezone_decorators;
    let _timezone_initializers = [];
    let _timezone_extraInitializers = [];
    let _firstSeenAt_decorators;
    let _firstSeenAt_initializers = [];
    let _firstSeenAt_extraInitializers = [];
    let _lastSeenAt_decorators;
    let _lastSeenAt_initializers = [];
    let _lastSeenAt_extraInitializers = [];
    let _updatedAt_decorators;
    let _updatedAt_initializers = [];
    let _updatedAt_extraInitializers = [];
    let _seenCount_decorators;
    let _seenCount_initializers = [];
    let _seenCount_extraInitializers = [];
    var IpIntelligenceDoc = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _ipAddress_decorators = [plugins.smartdata.unI(), plugins.smartdata.svDb()];
            _asn_decorators = [plugins.smartdata.svDb()];
            _asnOrg_decorators = [plugins.smartdata.svDb()];
            _registrantOrg_decorators = [plugins.smartdata.svDb()];
            _registrantCountry_decorators = [plugins.smartdata.svDb()];
            _networkRange_decorators = [plugins.smartdata.svDb()];
            _networkCidrs_decorators = [plugins.smartdata.svDb()];
            _abuseContact_decorators = [plugins.smartdata.svDb()];
            _country_decorators = [plugins.smartdata.svDb()];
            _countryCode_decorators = [plugins.smartdata.svDb()];
            _city_decorators = [plugins.smartdata.svDb()];
            _latitude_decorators = [plugins.smartdata.svDb()];
            _longitude_decorators = [plugins.smartdata.svDb()];
            _accuracyRadius_decorators = [plugins.smartdata.svDb()];
            _timezone_decorators = [plugins.smartdata.svDb()];
            _firstSeenAt_decorators = [plugins.smartdata.svDb()];
            _lastSeenAt_decorators = [plugins.smartdata.svDb()];
            _updatedAt_decorators = [plugins.smartdata.svDb()];
            _seenCount_decorators = [plugins.smartdata.svDb()];
            __esDecorate(null, null, _ipAddress_decorators, { kind: "field", name: "ipAddress", static: false, private: false, access: { has: obj => "ipAddress" in obj, get: obj => obj.ipAddress, set: (obj, value) => { obj.ipAddress = value; } }, metadata: _metadata }, _ipAddress_initializers, _ipAddress_extraInitializers);
            __esDecorate(null, null, _asn_decorators, { kind: "field", name: "asn", static: false, private: false, access: { has: obj => "asn" in obj, get: obj => obj.asn, set: (obj, value) => { obj.asn = value; } }, metadata: _metadata }, _asn_initializers, _asn_extraInitializers);
            __esDecorate(null, null, _asnOrg_decorators, { kind: "field", name: "asnOrg", static: false, private: false, access: { has: obj => "asnOrg" in obj, get: obj => obj.asnOrg, set: (obj, value) => { obj.asnOrg = value; } }, metadata: _metadata }, _asnOrg_initializers, _asnOrg_extraInitializers);
            __esDecorate(null, null, _registrantOrg_decorators, { kind: "field", name: "registrantOrg", static: false, private: false, access: { has: obj => "registrantOrg" in obj, get: obj => obj.registrantOrg, set: (obj, value) => { obj.registrantOrg = value; } }, metadata: _metadata }, _registrantOrg_initializers, _registrantOrg_extraInitializers);
            __esDecorate(null, null, _registrantCountry_decorators, { kind: "field", name: "registrantCountry", static: false, private: false, access: { has: obj => "registrantCountry" in obj, get: obj => obj.registrantCountry, set: (obj, value) => { obj.registrantCountry = value; } }, metadata: _metadata }, _registrantCountry_initializers, _registrantCountry_extraInitializers);
            __esDecorate(null, null, _networkRange_decorators, { kind: "field", name: "networkRange", static: false, private: false, access: { has: obj => "networkRange" in obj, get: obj => obj.networkRange, set: (obj, value) => { obj.networkRange = value; } }, metadata: _metadata }, _networkRange_initializers, _networkRange_extraInitializers);
            __esDecorate(null, null, _networkCidrs_decorators, { kind: "field", name: "networkCidrs", static: false, private: false, access: { has: obj => "networkCidrs" in obj, get: obj => obj.networkCidrs, set: (obj, value) => { obj.networkCidrs = value; } }, metadata: _metadata }, _networkCidrs_initializers, _networkCidrs_extraInitializers);
            __esDecorate(null, null, _abuseContact_decorators, { kind: "field", name: "abuseContact", static: false, private: false, access: { has: obj => "abuseContact" in obj, get: obj => obj.abuseContact, set: (obj, value) => { obj.abuseContact = value; } }, metadata: _metadata }, _abuseContact_initializers, _abuseContact_extraInitializers);
            __esDecorate(null, null, _country_decorators, { kind: "field", name: "country", static: false, private: false, access: { has: obj => "country" in obj, get: obj => obj.country, set: (obj, value) => { obj.country = value; } }, metadata: _metadata }, _country_initializers, _country_extraInitializers);
            __esDecorate(null, null, _countryCode_decorators, { kind: "field", name: "countryCode", static: false, private: false, access: { has: obj => "countryCode" in obj, get: obj => obj.countryCode, set: (obj, value) => { obj.countryCode = value; } }, metadata: _metadata }, _countryCode_initializers, _countryCode_extraInitializers);
            __esDecorate(null, null, _city_decorators, { kind: "field", name: "city", static: false, private: false, access: { has: obj => "city" in obj, get: obj => obj.city, set: (obj, value) => { obj.city = value; } }, metadata: _metadata }, _city_initializers, _city_extraInitializers);
            __esDecorate(null, null, _latitude_decorators, { kind: "field", name: "latitude", static: false, private: false, access: { has: obj => "latitude" in obj, get: obj => obj.latitude, set: (obj, value) => { obj.latitude = value; } }, metadata: _metadata }, _latitude_initializers, _latitude_extraInitializers);
            __esDecorate(null, null, _longitude_decorators, { kind: "field", name: "longitude", static: false, private: false, access: { has: obj => "longitude" in obj, get: obj => obj.longitude, set: (obj, value) => { obj.longitude = value; } }, metadata: _metadata }, _longitude_initializers, _longitude_extraInitializers);
            __esDecorate(null, null, _accuracyRadius_decorators, { kind: "field", name: "accuracyRadius", static: false, private: false, access: { has: obj => "accuracyRadius" in obj, get: obj => obj.accuracyRadius, set: (obj, value) => { obj.accuracyRadius = value; } }, metadata: _metadata }, _accuracyRadius_initializers, _accuracyRadius_extraInitializers);
            __esDecorate(null, null, _timezone_decorators, { kind: "field", name: "timezone", static: false, private: false, access: { has: obj => "timezone" in obj, get: obj => obj.timezone, set: (obj, value) => { obj.timezone = value; } }, metadata: _metadata }, _timezone_initializers, _timezone_extraInitializers);
            __esDecorate(null, null, _firstSeenAt_decorators, { kind: "field", name: "firstSeenAt", static: false, private: false, access: { has: obj => "firstSeenAt" in obj, get: obj => obj.firstSeenAt, set: (obj, value) => { obj.firstSeenAt = value; } }, metadata: _metadata }, _firstSeenAt_initializers, _firstSeenAt_extraInitializers);
            __esDecorate(null, null, _lastSeenAt_decorators, { kind: "field", name: "lastSeenAt", static: false, private: false, access: { has: obj => "lastSeenAt" in obj, get: obj => obj.lastSeenAt, set: (obj, value) => { obj.lastSeenAt = value; } }, metadata: _metadata }, _lastSeenAt_initializers, _lastSeenAt_extraInitializers);
            __esDecorate(null, null, _updatedAt_decorators, { kind: "field", name: "updatedAt", static: false, private: false, access: { has: obj => "updatedAt" in obj, get: obj => obj.updatedAt, set: (obj, value) => { obj.updatedAt = value; } }, metadata: _metadata }, _updatedAt_initializers, _updatedAt_extraInitializers);
            __esDecorate(null, null, _seenCount_decorators, { kind: "field", name: "seenCount", static: false, private: false, access: { has: obj => "seenCount" in obj, get: obj => obj.seenCount, set: (obj, value) => { obj.seenCount = value; } }, metadata: _metadata }, _seenCount_initializers, _seenCount_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            IpIntelligenceDoc = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
        ipAddress = __runInitializers(this, _ipAddress_initializers, void 0);
        asn = (__runInitializers(this, _ipAddress_extraInitializers), __runInitializers(this, _asn_initializers, null));
        asnOrg = (__runInitializers(this, _asn_extraInitializers), __runInitializers(this, _asnOrg_initializers, null));
        registrantOrg = (__runInitializers(this, _asnOrg_extraInitializers), __runInitializers(this, _registrantOrg_initializers, null));
        registrantCountry = (__runInitializers(this, _registrantOrg_extraInitializers), __runInitializers(this, _registrantCountry_initializers, null));
        networkRange = (__runInitializers(this, _registrantCountry_extraInitializers), __runInitializers(this, _networkRange_initializers, null));
        networkCidrs = (__runInitializers(this, _networkRange_extraInitializers), __runInitializers(this, _networkCidrs_initializers, null));
        abuseContact = (__runInitializers(this, _networkCidrs_extraInitializers), __runInitializers(this, _abuseContact_initializers, null));
        country = (__runInitializers(this, _abuseContact_extraInitializers), __runInitializers(this, _country_initializers, null));
        countryCode = (__runInitializers(this, _country_extraInitializers), __runInitializers(this, _countryCode_initializers, null));
        city = (__runInitializers(this, _countryCode_extraInitializers), __runInitializers(this, _city_initializers, null));
        latitude = (__runInitializers(this, _city_extraInitializers), __runInitializers(this, _latitude_initializers, null));
        longitude = (__runInitializers(this, _latitude_extraInitializers), __runInitializers(this, _longitude_initializers, null));
        accuracyRadius = (__runInitializers(this, _longitude_extraInitializers), __runInitializers(this, _accuracyRadius_initializers, null));
        timezone = (__runInitializers(this, _accuracyRadius_extraInitializers), __runInitializers(this, _timezone_initializers, null));
        firstSeenAt = (__runInitializers(this, _timezone_extraInitializers), __runInitializers(this, _firstSeenAt_initializers, Date.now()));
        lastSeenAt = (__runInitializers(this, _firstSeenAt_extraInitializers), __runInitializers(this, _lastSeenAt_initializers, Date.now()));
        updatedAt = (__runInitializers(this, _lastSeenAt_extraInitializers), __runInitializers(this, _updatedAt_initializers, Date.now()));
        seenCount = (__runInitializers(this, _updatedAt_extraInitializers), __runInitializers(this, _seenCount_initializers, 0));
        constructor() {
            super();
            __runInitializers(this, _seenCount_extraInitializers);
        }
        static async findByIp(ipAddress) {
            return await IpIntelligenceDoc.getInstance({ ipAddress });
        }
        static async findAll() {
            return await IpIntelligenceDoc.getInstances({});
        }
    };
    return IpIntelligenceDoc = _classThis;
})();
export { IpIntelligenceDoc };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5pcC1pbnRlbGxpZ2VuY2UuZG9jLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vdHMvZGIvZG9jdW1lbnRzL2NsYXNzZXMuaXAtaW50ZWxsaWdlbmNlLmRvYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxrQkFBa0IsQ0FBQztBQUM1QyxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFHdkQsTUFBTSxLQUFLLEdBQUcsR0FBRyxFQUFFLENBQUMsVUFBVSxDQUFDLFdBQVcsRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFDO0lBR3hDLGlCQUFpQjs0QkFEN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxVQUFVLENBQUMsR0FBRyxFQUFFLENBQUMsS0FBSyxFQUFFLENBQUM7Ozs7c0JBQ0wsT0FBTyxDQUFDLFNBQVMsQ0FBQyxjQUFjOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs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