"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Semifunctional_1 = require("../../../../../Class/Semifunctional");
const _ids_1 = require("../../../../_ids");
class SetPointerCapture extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({
            fi: ['element', 'pointerId'],
            fo: [],
            i: ['done'],
            o: [],
        }, {
            input: {
                element: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_SET_POINTER_CAPTURE);
        this._capturing = false;
        this._element = null;
        this._release = () => {
            if (this._capturing) {
                const pointerId = this._pointerId;
                this._done();
                this._input.done.pull();
                this._element.emit('call', {
                    method: 'releasePointerCapture',
                    data: [pointerId],
                });
                this._capturing = false;
                this._pointerId = undefined;
                this._element = null;
            }
        };
    }
    f({ element, pointerId }) {
        if (!this._capturing) {
            this._release();
            this._capturing = true;
            this._pointerId = pointerId;
            this._element = element;
            element.emit('call', {
                method: 'setPointerCapture',
                data: [pointerId],
            });
        }
    }
    onIterDataInputData(name, value) {
        // console.log('SetPointerCapture', 'onIterDataInputData', name, value)
        this._release();
    }
}
exports.default = SetPointerCapture;
//# sourceMappingURL=index.js.map