"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * The `sos.management.os` API groups together methods for retrieving information about the system.
 *
 *
 * <details>
 *     <summary>OS Management Capabilities</summary>
 * 		| Capability | Description |
 * 		|:------------|:-------------|
 * 		| `SYSTEM_CPU` | If device supports collecting CPU usage information |
 * 		| `SYSTEM_MEMORY` | If device supports collecting memory usage information |
 *
 * 		If you want to check if the device supports those capabilities, use [`sos.management.supports()`](https://developers.signageos.io/sdk/sos_management/#supports).
 * </details>
 */
class OS {
    messagePrefix;
    postMessage;
    /** @internal */
    constructor(messagePrefix, postMessage) {
        this.messagePrefix = messagePrefix;
        this.postMessage = postMessage;
    }
    /**
     * The `getInfo()` method returns info about the system of the device, such as what current version of it is installed on the device. Major
     * version of the current operating system. It's usually 1 or 2 digits, including or excluding dot notation.
     *
     * @returns {Promise<IOSInfo>} Resolves to an object containing information about the operating system.
     * @since 5.0.0
     *
     * @example
     * const osInfo = await sos.management.os.getInfo();
     * console.log(`Current OS version is: ${osInfo.version}`);
     */
    async getInfo() {
        const { osInfo } = await this.postMessage({
            type: this.getMessage('get_os_info'),
        });
        return osInfo;
    }
    /**
     * The `getCpuUsage()` method returns the current total CPU usage (ranging from 0 to 100%).
     *
     * @throws {Error} If the CPU usage is not supported.
     * @returns {Promise<number>} Resolves to the current CPU usage percentage.
     * @since 5.4.0
     *
     * @example
     * const cpuUsage = await sos.management.os.getCpuUsage();
     * console.log(`Current CPU usage is: ${cpuUsage}%`);
     */
    async getCpuUsage() {
        const { cpuUsage } = await this.postMessage({
            type: this.getMessage('get_cpu_usage'),
        });
        return cpuUsage;
    }
    /**
     * The `getMemoryUsage()` method returns the total memory amount in bytes, the currently used memory, and the remaining free memory.
     *
     * @throws {Error} If the memory usage is not supported.
     * @returns {Promise<SystemMemoryInfo>} Resolves to an object containing total, used, and free memory in bytes.
     * @since 5.4.0
     *
     * @example
     * const memoryUsage = await sos.management.os.getMemoryUsage();
     * console.log(`Memory usage: ${((memoryUsage.used / memoryUsage.total) * 100).toFixed(2)}%`);
     */
    async getMemoryUsage() {
        const { memoryUsage } = await this.postMessage({
            type: this.getMessage('get_memory_usage'),
        });
        return memoryUsage;
    }
    getMessage(name) {
        return this.messagePrefix + '.' + name;
    }
}
exports.default = OS;
//# sourceMappingURL=OS.js.map