"use strict";
// Copyright (c) Rotorz Limited and portions by original markdown-it-video authors
// Licensed under the MIT license. See LICENSE file in the project root.
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const YouTubeService_1 = __importDefault(require("./services/YouTubeService"));
const VimeoService_1 = __importDefault(require("./services/VimeoService"));
const VineService_1 = __importDefault(require("./services/VineService"));
const PreziService_1 = __importDefault(require("./services/PreziService"));
const SlideShareService_1 = __importDefault(require("./services/SlideShareService"));
const PowerPointOnlineService_1 = __importDefault(require("./services/PowerPointOnlineService"));
class PluginEnvironment {
    constructor(md, options) {
        this.services = {};
        this.md = md;
        this.options = Object.assign(this.getDefaultOptions(), options);
        this._initServices();
    }
    _initServices() {
        const defaultServiceBindings = {
            'youtube': YouTubeService_1.default,
            'vimeo': VimeoService_1.default,
            'vine': VineService_1.default,
            'prezi': PreziService_1.default,
            'slideshare': SlideShareService_1.default,
            'powerpoint': PowerPointOnlineService_1.default,
        };
        let serviceBindings = Object.assign({}, defaultServiceBindings, this.options.services);
        let services = {};
        for (let serviceName of Object.keys(serviceBindings)) {
            let _serviceClass = serviceBindings[serviceName];
            const ActualConstructor = _serviceClass.default || _serviceClass;
            if (typeof ActualConstructor === 'function') {
                services[serviceName] = new ActualConstructor(serviceName, this.options[serviceName], this);
            }
            else {
                console.error(`BlockEmbed Error: Service "${serviceName}" is not a valid constructor.`);
            }
        }
        this.services = services;
    }
    getDefaultOptions() {
        return {
            containerClassName: 'block-embed',
            serviceClassPrefix: 'block-embed-service-',
            outputPlayerSize: true,
            allowFullScreen: true,
            filterUrl: null
        };
    }
}
exports.default = PluginEnvironment;
//# sourceMappingURL=PluginEnvironment.js.map