"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const BroadcastChannel_1 = require("../../../../../wrap/BroadcastChannel");
const _ids_1 = require("../../../../_ids");
class BroadcastChannel_ extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['name'],
            fo: ['channel'],
            i: [],
            o: [],
        }, {
            output: {
                port: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_BROADCAST_CHANNEL, 'close');
    }
    f({ name }, done) {
        const { api: { window: { BroadcastChannel }, }, } = this.__system;
        this._bc = new BroadcastChannel(name);
        const channel = (0, BroadcastChannel_1.wrapBroadcastChannel)(this._bc, this.__system);
        done({ channel });
    }
    d() {
        if (this._bc) {
            this._bc.close();
        }
    }
}
exports.default = BroadcastChannel_;
//# sourceMappingURL=index.js.map