"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const APINotImplementedError_1 = require("../../../../../exception/APINotImplementedError");
const ImageCapture_1 = require("../../../../../wrap/ImageCapture");
const _ids_1 = require("../../../../_ids");
class ImageCapture_ extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['init', 'track'],
            fo: ['camera'],
            i: [],
            o: [],
        }, {
            input: {
                track: {
                    ref: true,
                },
            },
            output: {
                camera: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_IMAGE_CAPTURE);
    }
    async f({ init, track }, done, fail) {
        const { api: { window: { ImageCapture }, }, } = this.__system;
        if (!ImageCapture) {
            fail((0, APINotImplementedError_1.apiNotSupportedError)('Image Capture'));
            return;
        }
        const _track = await track.mediaStreamTrack();
        _track.onmute = () => {
            // console.log('onmute')
        };
        _track.onunmute = () => {
            // console.log('onunmute')
        };
        _track.onended = () => {
            // console.log('onended')
        };
        // @ts-ignore
        const imageCapture = new ImageCapture(_track);
        const camera = (0, ImageCapture_1.wrapImageCapture)(imageCapture, this.__system);
        done({ camera });
    }
}
exports.default = ImageCapture_;
//# sourceMappingURL=index.js.map