define("displayEngineLoader", ["clientkernelLoaderApi", "clientkernelLoaderApiPlugins", "displayEngineApi", "PIXI", "BABYLON", "clientkernelEventbusApi", "clientkernelModulesApi"],
    function(clientkernelLoaderApi, clientkernelLoaderApiPlugins, displayEngineApi, PIXI, BABYLON, clientkernelEventbusApi, clientkernelModulesApi) {
        "use strict";

        function $iterator(o) {
            if (o instanceof Array) return function() {
                return {
                    cur: 0,
                    arr: o,
                    hasNext: function() {
                        return this.cur < this.arr.length;
                    },
                    next: function() {
                        return this.arr[this.cur++];
                    }
                };
            };
            return typeof(o.iterator) == 'function' ? $bind(o, o.iterator) : o.iterator;
        };;
        var $fid = 0;

        function $bind(o, m) {
            if (m == null) return null;
            if (m.__id__ == null) m.__id__ = $fid++;
            var f;
            if (o.hx__closures__ == null) o.hx__closures__ = {};
            else f = o.hx__closures__[m.__id__];
            if (f == null) {
                f = function() {
                    return f.method.apply(f.scope, arguments);
                };
                f.scope = o;
                f.method = m;
                o.hx__closures__[m.__id__] = f;
            }
            return f;
        };
        var $_;
        var $estr = function() {
            return _hcmn_.js_Boot.__string_rec(this, '');
        };
        if (typeof displayEngineLoader == 'undefined') {
            var displayEngineLoader = {};
        };
        displayEngineLoader.Activator = function(context) {};
        displayEngineLoader.Activator = ck_implements(displayEngineLoader.Activator, clientkernelModulesApi.IModuleActivator);
        displayEngineLoader.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        displayEngineLoader.Activator.__name__ = ["displayEngineLoader", "Activator"];
        displayEngineLoader.Activator.prototype.start = function(context) {
            context.getServiceTracker([displayEngineApi.IDisplayProvider]).then(function(context1) {
                displayEngineLoader.ExternalService.initialize(context1);
                context1.registerService(new displayEngineLoader.BabylonLoaderPlugin(), clientkernelLoaderApiPlugins.IAssetPlugin, null);
                context1.registerService(new displayEngineLoader.PixiBitmapFontLoaderPlugin(), clientkernelLoaderApiPlugins.IAssetPlugin, null);
                context1.registerService(new displayEngineLoader.PixiAnimateLoaderPlugin(), clientkernelLoaderApiPlugins.IAssetPlugin, null);
            });
        };
        displayEngineLoader.Activator.prototype.stop = function(context) {};
        displayEngineLoader.Activator.main = function() {};
        displayEngineLoader.Activator.prototype.__class__ = displayEngineLoader.Activator;
        displayEngineLoader.BabylonLoader = function() {};
        displayEngineLoader.BabylonLoader = ck_implements(displayEngineLoader.BabylonLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        displayEngineLoader.BabylonLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        displayEngineLoader.BabylonLoader.__name__ = ["displayEngineLoader", "BabylonLoader"];
        displayEngineLoader.BabylonLoader.prototype.lc = null;
        displayEngineLoader.BabylonLoader.prototype.id = null;
        displayEngineLoader.BabylonLoader.prototype.type = null;
        displayEngineLoader.BabylonLoader.prototype.url = null;
        displayEngineLoader.BabylonLoader.prototype.config = null;
        displayEngineLoader.BabylonLoader.prototype.onrequest = null;
        displayEngineLoader.BabylonLoader.prototype.onfinish = null;
        displayEngineLoader.BabylonLoader.prototype.asset = null;
        displayEngineLoader.BabylonLoader.prototype.items = null;
        displayEngineLoader.BabylonLoader.prototype.task = null;
        displayEngineLoader.BabylonLoader.prototype.stage = null;
        displayEngineLoader.BabylonLoader.prototype.assetManager = null;
        displayEngineLoader.BabylonLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.url = url;
            this.lc = lc;
            this.id = id;
            this.config = config;
            this.asset = lc.getAssets().add(id, url, type, onrequest, this.items);
        };
        displayEngineLoader.BabylonLoader.prototype.load = function(onfinish) {
            this.onfinish = onfinish;
            this.stage = this.createStage3D(this.id, 300, 200);
            var scene = this.stage.getScene();
            this.assetManager = new BABYLON.AssetsManager(scene);
            var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 100, new BABYLON.Vector3(0, 10, 0), scene);
            this.stage.setPos(0, 0);
            var tasks = [];
            var _g1 = 0;
            var _g = this.config.loader.length;
            while (_g1 < _g) {
                var l = _g1++;
                tasks.push(this.loadTask(this.config.loader[l]));
            }
            Promise.all(tasks).then($bind(this, this.handleComplete))["catch"]($bind(this, this.handleError));
            this.assetManager.load();
        };
        displayEngineLoader.BabylonLoader.prototype.createStage3D = function(id, width, height) {
            return displayEngineLoader.ExternalService.displayProvider.getFactory().createStage3D(id, width, height);
        };
        displayEngineLoader.BabylonLoader.prototype.loadTask = function(loader) {
            var url;
            if (this.url != null) url = this.url + _hcmn_.Std.string(loader.url);
            else url = loader.url;
            var task;
            var _g = loader.config.task;
            switch (_g) {
                case "mesh":
                    task = this.assetManager.addMeshTask(loader.id, null, "", url);
                    break;
                case "binary":
                    task = this.assetManager.addBinaryFileTask(loader.id, url);
                    break;
                case "cubeTexture":
                    task = this.assetManager.addCubeTextureTask(loader.id, url);
                    break;
                case "hdrCubeTexture":
                    task = this.assetManager.addHDRCubeTextureTask(loader.id, url);
                    break;
                case "image":
                    task = this.assetManager.addImageTask(loader.id, url);
                    break;
                case "textFile":
                    task = this.assetManager.addTextFileTask(loader.id, url);
                    break;
                case "texture":
                    task = this.assetManager.addTextureTask(loader.id, url);
                    break;
                default:
                    task = null;
            }
            return new Promise(function(res, rej) {
                task.onSuccess = res;
                task.onError = rej;
            });
        };
        displayEngineLoader.BabylonLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        displayEngineLoader.BabylonLoader.prototype.handleProgress = function(event) {};
        displayEngineLoader.BabylonLoader.prototype.handleComplete = function(data) {
            this.asset.setContent(this.stage);
            if (this.onfinish != null) this.onfinish();
        };
        displayEngineLoader.BabylonLoader.prototype.handleError = function(data) {
            throw new Error("Error loading task id: " + _hcmn_.Std.string(data.name));
        };
        displayEngineLoader.BabylonLoader.prototype.__class__ = displayEngineLoader.BabylonLoader;
        displayEngineLoader.BabylonLoaderPlugin = function() {};
        displayEngineLoader.BabylonLoaderPlugin = ck_implements(displayEngineLoader.BabylonLoaderPlugin, clientkernelModulesApi.IService);
        displayEngineLoader.BabylonLoaderPlugin = ck_implements(displayEngineLoader.BabylonLoaderPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        displayEngineLoader.BabylonLoaderPlugin.__interfaces__ = [clientkernelModulesApi.IService, clientkernelLoaderApiPlugins.IAssetPlugin];
        displayEngineLoader.BabylonLoaderPlugin.__name__ = ["displayEngineLoader", "BabylonLoaderPlugin"];
        displayEngineLoader.BabylonLoaderPlugin.prototype.getAssetTypes = function() {
            return ["babylon", "babylon-asset"];
        };
        displayEngineLoader.BabylonLoaderPlugin.prototype.createLoader = function() {
            return new displayEngineLoader.BabylonLoader();
        };
        displayEngineLoader.BabylonLoaderPlugin.prototype.__class__ = displayEngineLoader.BabylonLoaderPlugin;
        displayEngineLoader.ExternalService = function() {};
        displayEngineLoader.ExternalService.__name__ = ["displayEngineLoader", "ExternalService"];
        displayEngineLoader.ExternalService.displayProvider = null;
        displayEngineLoader.ExternalService.initialize = function(context) {
            displayEngineLoader.ExternalService.displayProvider = context.getAnyService(displayEngineApi.IDisplayProvider, null);
        };
        displayEngineLoader.ExternalService.prototype.__class__ = displayEngineLoader.ExternalService;
        displayEngineLoader.PixiAnimateLoader = function() {};
        displayEngineLoader.PixiAnimateLoader = ck_implements(displayEngineLoader.PixiAnimateLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        displayEngineLoader.PixiAnimateLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        displayEngineLoader.PixiAnimateLoader.__name__ = ["displayEngineLoader", "PixiAnimateLoader"];
        displayEngineLoader.PixiAnimateLoader.prototype.lc = null;
        displayEngineLoader.PixiAnimateLoader.prototype.id = null;
        displayEngineLoader.PixiAnimateLoader.prototype.type = null;
        displayEngineLoader.PixiAnimateLoader.prototype.url = null;
        displayEngineLoader.PixiAnimateLoader.prototype.config = null;
        displayEngineLoader.PixiAnimateLoader.prototype.onrequest = null;
        displayEngineLoader.PixiAnimateLoader.prototype.onfinish = null;
        displayEngineLoader.PixiAnimateLoader.prototype.asset = null;
        displayEngineLoader.PixiAnimateLoader.prototype.items = null;
        displayEngineLoader.PixiAnimateLoader.prototype.task = null;
        displayEngineLoader.PixiAnimateLoader.prototype.oStage = null;
        displayEngineLoader.PixiAnimateLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.url = url;
            this.lc = lc;
            this.id = id;
            this.config = config;
            this.asset = lc.getAssets().add(id, url, type, onrequest, this.items);
        };
        displayEngineLoader.PixiAnimateLoader.prototype.load = function(onfinish) {
            this.onfinish = onfinish;
            var script;
            var _this = window.document;
            script = _this.createElement("script");
            script.onload = $bind(this, this.handleComplete);
            script.src = this.url;
            window.document.body.appendChild(script);
        };
        displayEngineLoader.PixiAnimateLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        displayEngineLoader.PixiAnimateLoader.prototype.handleProgress = function(event) {};
        displayEngineLoader.PixiAnimateLoader.prototype.handleComplete = function(data) {
            var _g = this;
            this.oStage = displayEngineLoader.ExternalService.displayProvider.getFactory().createOffscreenStage(this.config.width, this.config.height, false, displayEngineApi.TimingMode.ONCE);
            var scene = new PIXI.animate.Scene(this.config.width, this.config.height, {
                view: this.oStage.getCanvas(),
                backgroundColor: 16777215,
                antialias: true
            }, true);
            scene.load(lib.stage, function() {
                _g.oStage._stage = scene.instance;
                _g.asset.setContent(scene.instance);
                if (_g.onfinish != null) _g.onfinish();
            });
        };
        displayEngineLoader.PixiAnimateLoader.prototype.handleError = function(data) {
            throw new Error("Error loading task id: " + _hcmn_.Std.string(data.name));
        };
        displayEngineLoader.PixiAnimateLoader.prototype.__class__ = displayEngineLoader.PixiAnimateLoader;
        displayEngineLoader.PixiAnimateLoaderPlugin = function() {};
        displayEngineLoader.PixiAnimateLoaderPlugin = ck_implements(displayEngineLoader.PixiAnimateLoaderPlugin, clientkernelModulesApi.IService);
        displayEngineLoader.PixiAnimateLoaderPlugin = ck_implements(displayEngineLoader.PixiAnimateLoaderPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        displayEngineLoader.PixiAnimateLoaderPlugin.__interfaces__ = [clientkernelModulesApi.IService, clientkernelLoaderApiPlugins.IAssetPlugin];
        displayEngineLoader.PixiAnimateLoaderPlugin.__name__ = ["displayEngineLoader", "PixiAnimateLoaderPlugin"];
        displayEngineLoader.PixiAnimateLoaderPlugin.prototype.getAssetTypes = function() {
            return ["pixianimate"];
        };
        displayEngineLoader.PixiAnimateLoaderPlugin.prototype.createLoader = function() {
            return new displayEngineLoader.PixiAnimateLoader();
        };
        displayEngineLoader.PixiAnimateLoaderPlugin.prototype.__class__ = displayEngineLoader.PixiAnimateLoaderPlugin;
        displayEngineLoader.PixiBitmapFontLoader = function() {};
        displayEngineLoader.PixiBitmapFontLoader = ck_implements(displayEngineLoader.PixiBitmapFontLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        displayEngineLoader.PixiBitmapFontLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        displayEngineLoader.PixiBitmapFontLoader.__name__ = ["displayEngineLoader", "PixiBitmapFontLoader"];
        displayEngineLoader.PixiBitmapFontLoader.prototype.lc = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.id = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.type = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.url = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.config = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.onrequest = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.onfinish = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.asset = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.items = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.task = null;
        displayEngineLoader.PixiBitmapFontLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.url = url;
            this.lc = lc;
            this.id = id;
            this.config = config;
            this.asset = lc.getAssets().add(id, url, type, onrequest, this.items);
        };
        displayEngineLoader.PixiBitmapFontLoader.prototype.load = function(onfinish) {
            this.onfinish = onfinish;
            var PIXI = window.PIXI;
            var task = PIXI.loader.add(this.id, this.url);
            task.onError = $bind(this, this.handleError);
            task.load($bind(this, this.handleComplete));
        };
        displayEngineLoader.PixiBitmapFontLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        displayEngineLoader.PixiBitmapFontLoader.prototype.handleProgress = function(event) {};
        displayEngineLoader.PixiBitmapFontLoader.prototype.handleComplete = function(data) {
            if (this.onfinish != null) this.onfinish();
        };
        displayEngineLoader.PixiBitmapFontLoader.prototype.handleError = function(data) {
            throw new Error("Error loading task id: " + _hcmn_.Std.string(data.name));
        };
        displayEngineLoader.PixiBitmapFontLoader.prototype.__class__ = displayEngineLoader.PixiBitmapFontLoader;
        displayEngineLoader.PixiBitmapFontLoaderPlugin = function() {};
        displayEngineLoader.PixiBitmapFontLoaderPlugin = ck_implements(displayEngineLoader.PixiBitmapFontLoaderPlugin, clientkernelModulesApi.IService);
        displayEngineLoader.PixiBitmapFontLoaderPlugin = ck_implements(displayEngineLoader.PixiBitmapFontLoaderPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        displayEngineLoader.PixiBitmapFontLoaderPlugin.__interfaces__ = [clientkernelModulesApi.IService, clientkernelLoaderApiPlugins.IAssetPlugin];
        displayEngineLoader.PixiBitmapFontLoaderPlugin.__name__ = ["displayEngineLoader", "PixiBitmapFontLoaderPlugin"];
        displayEngineLoader.PixiBitmapFontLoaderPlugin.prototype.getAssetTypes = function() {
            return ["bitmapfont"];
        };
        displayEngineLoader.PixiBitmapFontLoaderPlugin.prototype.createLoader = function() {
            return new displayEngineLoader.PixiBitmapFontLoader();
        };
        displayEngineLoader.PixiBitmapFontLoaderPlugin.prototype.__class__ = displayEngineLoader.PixiBitmapFontLoaderPlugin;
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

        haxe.IMap = function() {}
        haxe.IMap.prototype = {

        };
        return {
            exports: displayEngineLoader,
            activator: displayEngineLoader.Activator
        };
    });