"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Primitive_1 = require("../../../Primitive");
const Window_1 = require("../../../wrap/Window");
const _ids_1 = require("../../_ids");
class Document_ extends Primitive_1.Primitive {
    constructor(system) {
        super({
            i: ['src', 'srcdoc'],
            o: ['window'],
        }, {}, system, _ids_1.ID_DOCUMENT);
        this.__ = ['U'];
        this._iframe_el = this.__system.api.document.createElement('iframe');
        this._iframe_el.addEventListener('load', () => {
            const window = (0, Window_1.wrapWindow)(this._iframe_el.contentWindow, this.__system);
            this._output.window.push(window);
        });
        if (this.__system.foreground.void) {
            this.__system.foreground.void.appendChild(this._iframe_el);
        }
    }
    send(data) {
        this._iframe_el.contentWindow.postMessage(data, '*');
        return;
    }
    onDataInputData(name, data) {
        // console.log('Iframe', 'onDataInputData', 'name', name, 'data', data)
        super.onDataInputData(name, data);
        if (name === 'src') {
            this._iframe_el.src = data;
        }
        else if (name === 'srcdoc') {
            this._iframe_el.srcdoc = data;
        }
    }
}
exports.default = Document_;
//# sourceMappingURL=index.js.map