import { __esDecorate, __runInitializers } from "tslib";
import { Bytes } from "@zwave-js/shared";
import { NVMFile, gotDeserializationOptions, nvmFileID, nvmSection, } from "./NVMFile.js";
export class VersionFile extends NVMFile {
    constructor(options) {
        super(options);
        if (gotDeserializationOptions(options)) {
            this.format = this.payload[3];
            this.major = this.payload[2];
            this.minor = this.payload[1];
            this.patch = this.payload[0];
        }
        else {
            this.format = options.format;
            this.major = options.major;
            this.minor = options.minor;
            this.patch = options.patch;
        }
    }
    format;
    major;
    minor;
    patch;
    serialize() {
        this.payload = Bytes.from([
            this.patch,
            this.minor,
            this.major,
            this.format,
        ]);
        return super.serialize();
    }
    // oxlint-disable-next-line typescript/explicit-module-boundary-types
    toJSON() {
        return {
            ...super.toJSON(),
            format: this.format,
            version: `${this.major}.${this.minor}.${this.patch}`,
        };
    }
}
export const ApplicationVersionFileID = 0x51000;
let ApplicationVersionFile = (() => {
    let _classDecorators = [nvmFileID(ApplicationVersionFileID), nvmSection("application")];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = VersionFile;
    var ApplicationVersionFile = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            ApplicationVersionFile = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return ApplicationVersionFile = _classThis;
})();
export { ApplicationVersionFile };
// The 800 series has a shared application/protocol file system
// and uses a different ID for the application version file
export const ApplicationVersionFile800ID = 0x41000;
let ApplicationVersionFile800 = (() => {
    let _classDecorators = [nvmFileID(ApplicationVersionFile800ID), nvmSection("application")];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = VersionFile;
    var ApplicationVersionFile800 = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            ApplicationVersionFile800 = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return ApplicationVersionFile800 = _classThis;
})();
export { ApplicationVersionFile800 };
export const ProtocolVersionFileID = 0x50000;
let ProtocolVersionFile = (() => {
    let _classDecorators = [nvmFileID(ProtocolVersionFileID), nvmSection("protocol")];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = VersionFile;
    var ProtocolVersionFile = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            ProtocolVersionFile = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return ProtocolVersionFile = _classThis;
})();
export { ProtocolVersionFile };
//# sourceMappingURL=VersionFiles.js.map