"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const integration_base_1 = require("@things-factory/integration-base");
const utils_1 = require("@things-factory/utils");
const get_tracking_workspace_1 = require("./get-tracking-workspace");
const debug = require('debug')('aidoop:robotics:ws-get-roi-count');
async function TrackingWorkspaceGetROICount(step, { logger, data, domain }) {
    var { connection, params: { accessor, cameraName } } = step;
    var object = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection) || {};
    if (!object) {
        throw new Error(`no connection : ${connection}`);
    }
    var roiName = accessor ? (0, utils_1.access)(accessor, data) : cameraName;
    logger.info(`accessor: ${accessor}, cameraName: ${cameraName}, roiName: ${roiName}`);
    var workspace = (0, get_tracking_workspace_1.getTrackingWorkspace)(domain);
    var { engine } = workspace;
    var { trackingStorage } = engine;
    return {
        data: trackingStorage.getROIState(roiName).length
    };
}
TrackingWorkspaceGetROICount.parameterSpec = [
    {
        type: 'scenario-step-input',
        label: 'accessor',
        name: 'accessor'
    },
    {
        type: 'string',
        label: 'camera name',
        name: 'cameraName'
    }
];
TrackingWorkspaceGetROICount.help = 'robotics/task/tracking-workspace-get-roi-count';
integration_base_1.TaskRegistry.registerTaskHandler('tracking-ws-get-roi-count', TrackingWorkspaceGetROICount);
//# sourceMappingURL=tracking-workspace-get-roi-count.js.map