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 DomainDoc = (() => {
    let _classDecorators = [plugins.smartdata.Collection(() => getDb())];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = plugins.smartdata.SmartDataDbDoc;
    let _id_decorators;
    let _id_initializers = [];
    let _id_extraInitializers = [];
    let _name_decorators;
    let _name_initializers = [];
    let _name_extraInitializers = [];
    let _source_decorators;
    let _source_initializers = [];
    let _source_extraInitializers = [];
    let _providerId_decorators;
    let _providerId_initializers = [];
    let _providerId_extraInitializers = [];
    let _authoritative_decorators;
    let _authoritative_initializers = [];
    let _authoritative_extraInitializers = [];
    let _nameservers_decorators;
    let _nameservers_initializers = [];
    let _nameservers_extraInitializers = [];
    let _externalZoneId_decorators;
    let _externalZoneId_initializers = [];
    let _externalZoneId_extraInitializers = [];
    let _lastSyncedAt_decorators;
    let _lastSyncedAt_initializers = [];
    let _lastSyncedAt_extraInitializers = [];
    let _description_decorators;
    let _description_initializers = [];
    let _description_extraInitializers = [];
    let _createdAt_decorators;
    let _createdAt_initializers = [];
    let _createdAt_extraInitializers = [];
    let _updatedAt_decorators;
    let _updatedAt_initializers = [];
    let _updatedAt_extraInitializers = [];
    let _createdBy_decorators;
    let _createdBy_initializers = [];
    let _createdBy_extraInitializers = [];
    var DomainDoc = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _id_decorators = [plugins.smartdata.unI(), plugins.smartdata.svDb()];
            _name_decorators = [plugins.smartdata.svDb()];
            _source_decorators = [plugins.smartdata.svDb()];
            _providerId_decorators = [plugins.smartdata.svDb()];
            _authoritative_decorators = [plugins.smartdata.svDb()];
            _nameservers_decorators = [plugins.smartdata.svDb()];
            _externalZoneId_decorators = [plugins.smartdata.svDb()];
            _lastSyncedAt_decorators = [plugins.smartdata.svDb()];
            _description_decorators = [plugins.smartdata.svDb()];
            _createdAt_decorators = [plugins.smartdata.svDb()];
            _updatedAt_decorators = [plugins.smartdata.svDb()];
            _createdBy_decorators = [plugins.smartdata.svDb()];
            __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
            __esDecorate(null, null, _name_decorators, { kind: "field", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
            __esDecorate(null, null, _source_decorators, { kind: "field", name: "source", static: false, private: false, access: { has: obj => "source" in obj, get: obj => obj.source, set: (obj, value) => { obj.source = value; } }, metadata: _metadata }, _source_initializers, _source_extraInitializers);
            __esDecorate(null, null, _providerId_decorators, { kind: "field", name: "providerId", static: false, private: false, access: { has: obj => "providerId" in obj, get: obj => obj.providerId, set: (obj, value) => { obj.providerId = value; } }, metadata: _metadata }, _providerId_initializers, _providerId_extraInitializers);
            __esDecorate(null, null, _authoritative_decorators, { kind: "field", name: "authoritative", static: false, private: false, access: { has: obj => "authoritative" in obj, get: obj => obj.authoritative, set: (obj, value) => { obj.authoritative = value; } }, metadata: _metadata }, _authoritative_initializers, _authoritative_extraInitializers);
            __esDecorate(null, null, _nameservers_decorators, { kind: "field", name: "nameservers", static: false, private: false, access: { has: obj => "nameservers" in obj, get: obj => obj.nameservers, set: (obj, value) => { obj.nameservers = value; } }, metadata: _metadata }, _nameservers_initializers, _nameservers_extraInitializers);
            __esDecorate(null, null, _externalZoneId_decorators, { kind: "field", name: "externalZoneId", static: false, private: false, access: { has: obj => "externalZoneId" in obj, get: obj => obj.externalZoneId, set: (obj, value) => { obj.externalZoneId = value; } }, metadata: _metadata }, _externalZoneId_initializers, _externalZoneId_extraInitializers);
            __esDecorate(null, null, _lastSyncedAt_decorators, { kind: "field", name: "lastSyncedAt", static: false, private: false, access: { has: obj => "lastSyncedAt" in obj, get: obj => obj.lastSyncedAt, set: (obj, value) => { obj.lastSyncedAt = value; } }, metadata: _metadata }, _lastSyncedAt_initializers, _lastSyncedAt_extraInitializers);
            __esDecorate(null, null, _description_decorators, { kind: "field", name: "description", static: false, private: false, access: { has: obj => "description" in obj, get: obj => obj.description, set: (obj, value) => { obj.description = value; } }, metadata: _metadata }, _description_initializers, _description_extraInitializers);
            __esDecorate(null, null, _createdAt_decorators, { kind: "field", name: "createdAt", static: false, private: false, access: { has: obj => "createdAt" in obj, get: obj => obj.createdAt, set: (obj, value) => { obj.createdAt = value; } }, metadata: _metadata }, _createdAt_initializers, _createdAt_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, _createdBy_decorators, { kind: "field", name: "createdBy", static: false, private: false, access: { has: obj => "createdBy" in obj, get: obj => obj.createdBy, set: (obj, value) => { obj.createdBy = value; } }, metadata: _metadata }, _createdBy_initializers, _createdBy_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            DomainDoc = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
        id = __runInitializers(this, _id_initializers, void 0);
        /** FQDN — kept lowercased on save. */
        name = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _name_initializers, ''));
        source = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _source_initializers, void 0));
        providerId = (__runInitializers(this, _source_extraInitializers), __runInitializers(this, _providerId_initializers, void 0));
        authoritative = (__runInitializers(this, _providerId_extraInitializers), __runInitializers(this, _authoritative_initializers, false));
        nameservers = (__runInitializers(this, _authoritative_extraInitializers), __runInitializers(this, _nameservers_initializers, void 0));
        externalZoneId = (__runInitializers(this, _nameservers_extraInitializers), __runInitializers(this, _externalZoneId_initializers, void 0));
        lastSyncedAt = (__runInitializers(this, _externalZoneId_extraInitializers), __runInitializers(this, _lastSyncedAt_initializers, void 0));
        description = (__runInitializers(this, _lastSyncedAt_extraInitializers), __runInitializers(this, _description_initializers, void 0));
        createdAt = (__runInitializers(this, _description_extraInitializers), __runInitializers(this, _createdAt_initializers, void 0));
        updatedAt = (__runInitializers(this, _createdAt_extraInitializers), __runInitializers(this, _updatedAt_initializers, void 0));
        createdBy = (__runInitializers(this, _updatedAt_extraInitializers), __runInitializers(this, _createdBy_initializers, void 0));
        constructor() {
            super();
            __runInitializers(this, _createdBy_extraInitializers);
        }
        static async findById(id) {
            return await DomainDoc.getInstance({ id });
        }
        static async findByName(name) {
            return await DomainDoc.getInstance({ name: name.toLowerCase() });
        }
        static async findAll() {
            return await DomainDoc.getInstances({});
        }
        static async findByProviderId(providerId) {
            return await DomainDoc.getInstances({ providerId });
        }
    };
    return DomainDoc = _classThis;
})();
export { DomainDoc };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5kb21haW4uZG9jLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vdHMvZGIvZG9jdW1lbnRzL2NsYXNzZXMuZG9tYWluLmRvYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxrQkFBa0IsQ0FBQztBQUM1QyxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFHdkQsTUFBTSxLQUFLLEdBQUcsR0FBRyxFQUFFLENBQUMsVUFBVSxDQUFDLFdBQVcsRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFDO0lBR3hDLFNBQVM7NEJBRHJCLE9BQU8sQ0FBQyxTQUFTLENBQUMsVUFBVSxDQUFDLEdBQUcsRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFDOzs7O3NCQUNiLE9BQU8sQ0FBQyxTQUFTLENBQUMs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