'use strict';
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var reactDom = require("react-dom");
var React = require("react");
// import * as builderReact from '@builder.io/react'
var emotionCore = require("@emotion/core");
var emotionStyled = require("@emotion/styled");
var mobx = require("mobx");
var mobxReact = require("mobx-react");
var mst = require("@builder.io/mobx-state-tree");
var mui = require("@material-ui/core");
var muiIcons = require("@material-ui/icons");
var builder = require("@builder.io/sdk");
require("systemjs/dist/system.js");
require("systemjs/dist/extras/named-register.js");
// Ugh, webpack...
exports.system = eval('System');
console.log('hi from worker');
if (typeof self !== 'undefined') {
    self.addEventListener('message', function (event) {
        var data = event.data;
        if (data && data.type === 'builder.loadPlugin') {
            console.log('loadPluginMessage', event.data);
            var plugin = '@buider.io/plugin-cloudinary';
            var pluginUrl = plugin.startsWith('http') ? plugin : 'https://unpkg.com/' + plugin;
            exports.system.import(pluginUrl);
            var editor = builder.Builder.editors[0];
            if (editor.component) {
                // TODO: bind value, onchange, context
                reactDom.render(React.createElement(editor.component), document.body);
            }
        }
    });
}
var exposePackages = {
    react: React,
    'react-dom': reactDom,
    '@builder.io/sdk': builder,
    // '@builder.io/react': builderReact,
    '@emotion/core': emotionCore,
    '@emotion/styled': emotionStyled,
    mobx: mobx,
    'mobx-state-tree': mst,
    'mobx-react': mobxReact,
    '@material-ui/core': mui,
    '@material-ui/icons': muiIcons
};
var _loop_1 = function (packageName) {
    exports.system.register(packageName, [], function (_export) {
        return {
            execute: function () {
                var content = exposePackages[packageName];
                _export(__assign(__assign({}, content), { default: content }));
            }
        };
    });
};
for (var packageName in exposePackages) {
    _loop_1(packageName);
}
//# sourceMappingURL=plugin-loader.js.map