"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../../../Class/Functional");
const AudioContext_1 = require("../../../../../../wrap/AudioContext");
const _ids_1 = require("../../../../../_ids");
class AudioContext_ extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['opt'],
            o: ['ctx'],
        }, {
            output: {
                ctx: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_AUDIO_CONTEXT);
    }
    f({ opt }, done) {
        const { api: { window: { AudioContext }, }, } = this.__system;
        // @ts-ignore
        const _ctx = new AudioContext(opt);
        this._ctx = _ctx;
        const ctx = (0, AudioContext_1.wrapAudioContext)(_ctx, this.__system);
        done({
            ctx,
        });
    }
    d() {
        if (this._ctx) {
            this._ctx.close();
            this._ctx = undefined;
        }
    }
}
exports.default = AudioContext_;
//# sourceMappingURL=index.js.map