define("clientkernelLoader", ["clientkernelLoaderApi", "clientkernelLoaderApiPlugins", "clientkernelEventbusApi", "clientkernelModulesApi", "preloadjs", "font"],
    function(clientkernelLoaderApi, clientkernelLoaderApiPlugins, clientkernelEventbusApi, clientkernelModulesApi, preloadjs, font) {
        "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 clientkernelLoader == 'undefined') {
            var clientkernelLoader = {};
        };
        clientkernelLoader.Activator = function() {};
        clientkernelLoader.Activator = ck_implements(clientkernelLoader.Activator, clientkernelModulesApi.IModuleActivator);
        clientkernelLoader.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        clientkernelLoader.Activator.__name__ = ["clientkernelLoader", "Activator"];
        clientkernelLoader.Activator.prototype.start = function(context) {
            var lc = new clientkernelLoader.LoaderContext(context);
            lc.initialize();
        };
        clientkernelLoader.Activator.prototype.stop = function(context) {};
        clientkernelLoader.Activator.main = function() {};
        clientkernelLoader.Activator.prototype.__class__ = clientkernelLoader.Activator;
        clientkernelLoader.LoaderConfiguration = function(lc) {
            this.lc = lc;
            this.sections = [];
            this.plugins = new _hcmn_.haxe_ds_StringMap();
        };
        clientkernelLoader.LoaderConfiguration.__name__ = ["clientkernelLoader", "LoaderConfiguration"];
        clientkernelLoader.LoaderConfiguration.prototype.sections = null;
        clientkernelLoader.LoaderConfiguration.prototype.plugins = null;
        clientkernelLoader.LoaderConfiguration.prototype.lc = null;
        clientkernelLoader.LoaderConfiguration.prototype.registerPlugin = function(plugin) {
            var key = plugin.getSection();
            this.plugins.set(key, plugin);
            if (ck_instanceof(plugin, clientkernelLoaderApiPlugins.ILoader)) {
                var x = ck_cast(plugin, clientkernelLoaderApiPlugins.ILoader);
                this.lc.installLoader(x);
            }
            this.resolvePendingSections();
        };
        clientkernelLoader.LoaderConfiguration.prototype.load = function(config) {
            var _g = 0;
            var _g1 = _hcmn_.Reflect.fields(config);
            while (_g < _g1.length) {
                var field = _g1[_g];
                ++_g;
                this.sections.push({
                    id: field,
                    content: _hcmn_.Reflect.field(config, field)
                });
            }
            this.resolvePendingSections();
        };
        clientkernelLoader.LoaderConfiguration.prototype.resolvePendingSections = function() {
            while (this.sections.length != 0)
                if (this.plugins.exists(this.sections[0].id)) {
                    this.plugins.get(this.sections[0].id).resolve(this.lc, this.sections[0].content);
                    this.sections.splice(0, 1);
                } else return;
        };
        clientkernelLoader.LoaderConfiguration.prototype.__class__ = clientkernelLoader.LoaderConfiguration;
        clientkernelLoader.Asset = function(parent, id, url, type, onrequest) {
            this.parent = parent;
            this.id = id;
            this.url = url;
            this.type = type;
            this.content = null;
            this.loaded = false;
            this.onrequest = onrequest;
            this.promisses = [];
            this.loadedSize = 0;
            this.totalSize = 0;
        };
        clientkernelLoader.Asset = ck_implements(clientkernelLoader.Asset, clientkernelLoaderApiPlugins.IAssetAccess);
        clientkernelLoader.Asset = ck_implements(clientkernelLoader.Asset, clientkernelLoaderApi.IAsset);
        clientkernelLoader.Asset.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetAccess, clientkernelLoaderApi.IAsset];
        clientkernelLoader.Asset.__name__ = ["clientkernelLoader", "Asset"];
        clientkernelLoader.Asset.prototype.id = null;
        clientkernelLoader.Asset.prototype.url = null;
        clientkernelLoader.Asset.prototype.type = null;
        clientkernelLoader.Asset.prototype.content = null;
        clientkernelLoader.Asset.prototype.loaded = null;
        clientkernelLoader.Asset.prototype.onrequest = null;
        clientkernelLoader.Asset.prototype.promisses = null;
        clientkernelLoader.Asset.prototype.parent = null;
        clientkernelLoader.Asset.prototype.loadedSize = null;
        clientkernelLoader.Asset.prototype.totalSize = null;
        clientkernelLoader.Asset.prototype.setup = function(url, type, onrequest) {
            this.url = url;
            this.type = type;
            this.loaded = false;
            this.onrequest = onrequest;
        };
        clientkernelLoader.Asset.prototype.setContent = function(content) {
            this.content = content;
            this.loaded = true;
            var _g = 0;
            var _g1 = this.promisses;
            while (_g < _g1.length) {
                var i = _g1[_g];
                ++_g;
                i(this.content);
            }
            this.parent.triggerAssetLoaded(this);
            if (this.totalSize != 0) {
                this.parent.updateProgress(this.totalSize - this.loadedSize, 1, 0, 0);
                this.loadedSize = this.totalSize;
            }
        };
        clientkernelLoader.Asset.prototype.isLoaded = function() {
            return this.loaded;
        };
        clientkernelLoader.Asset.prototype.getId = function() {
            return this.id;
        };
        clientkernelLoader.Asset.prototype.getType = function() {
            return this.type;
        };
        clientkernelLoader.Asset.prototype.getUrl = function() {
            return this.url;
        };
        clientkernelLoader.Asset.prototype.getContent = function() {
            var _g = this;
            return new Promise(function(resolve, reject) {
                if (_g.isLoaded()) resolve(_g.content);
                else {
                    if (_g.onrequest != null) {
                        _g.onrequest();
                        _g.onrequest = null;
                    }
                    _g.promisses.push(resolve);
                }
            });
        };
        clientkernelLoader.Asset.prototype.setProgress = function(loadedBytes, ofSize) {
            if (this.totalSize == 0 && ofSize == 0) return;
            var deltaSize = ofSize - this.totalSize;
            var deltaCount = 0;
            if (ofSize == 0) deltaCount = -1;
            if (this.totalSize == 0) deltaCount = 1;
            if (loadedBytes > ofSize) loadedBytes = ofSize;
            var deltaLoaded = loadedBytes - this.loadedSize;
            this.totalSize = ofSize;
            this.loadedSize = loadedBytes;
        };
        clientkernelLoader.Asset.prototype.add = function(id, url, type, onrequest) {
            return this.parent.add(this.id + "/" + id, url, type, onrequest);
        };
        clientkernelLoader.Asset.prototype.getAllContent = function() {
            return this.parent.getSubContent(this.id);
        };
        clientkernelLoader.Asset.prototype.getChildAsset = function(id) {
            return this.parent.getAsset(this.id + "/" + id);
        };
        clientkernelLoader.Asset.prototype.__class__ = clientkernelLoader.Asset;
        clientkernelLoader.AssetGroup = function(parent, id, asset) {
            this.parent = parent;
            if (asset != null) {
                this.asset = asset;
                this.group = null;
            } else {
                this.asset = new clientkernelLoader.Asset(parent, id);
                this.group = new _hcmn_.haxe_ds_StringMap();
            }
        };
        clientkernelLoader.AssetGroup.__name__ = ["clientkernelLoader", "AssetGroup"];
        clientkernelLoader.AssetGroup.prototype.asset = null;
        clientkernelLoader.AssetGroup.prototype.group = null;
        clientkernelLoader.AssetGroup.prototype.parent = null;
        clientkernelLoader.AssetGroup.prototype.createGroup = function() {
            this.group = new _hcmn_.haxe_ds_StringMap();
        };
        clientkernelLoader.AssetGroup.prototype.getAsset = function() {
            return this.asset;
        };
        clientkernelLoader.AssetGroup.prototype.ids = function() {
            if (this.group != null) {
                var ret = [];
                var $it0 = this.group.keys();
                while ($it0.hasNext()) {
                    var i = $it0.next();
                    ret.push(this.asset.getId() + "/" + i);
                }
                return ret;
            } else return [];
        };
        clientkernelLoader.AssetGroup.prototype.exists = function(id) {
            var g = this.locateGroup(id);
            if (g == null) return false;
            var key = this.simpleId(id);
            if (_hcmn_.__map_reserved[key] != null) return g.existsReserved(key);
            else return g.h.hasOwnProperty(key);
        };
        clientkernelLoader.AssetGroup.prototype.get = function(id, auto) {
            if (auto == null) auto = false;
            var this1 = this.locateGroup(id, auto);
            var key = this.simpleId(id);
            return this1.get(key);
        };
        clientkernelLoader.AssetGroup.prototype.add = function(id, asset) {
            var this1 = this.locateGroup(id, true);
            var key = this.simpleId(id);
            var value = new clientkernelLoader.AssetGroup(this.parent, null, asset);
            this1.set(key, value);
        };
        clientkernelLoader.AssetGroup.prototype.remove = function(id) {
            var this1 = this.locateGroup(id);
            var key = this.simpleId(id);
            this1.remove(key);
        };
        clientkernelLoader.AssetGroup.prototype.simpleId = function(id) {
            if (id.indexOf("/") == -1) return id;
            else return id.substring(id.lastIndexOf("/") + 1);
        };
        clientkernelLoader.AssetGroup.prototype.locateGroup = function(id, auto) {
            if (auto == null) auto = false;
            var ret = this.group;
            var ids = id.split("/");
            ids.pop();
            var myid = ids.join("/");
            while (ids.length > 0) {
                if (!ret.exists(ids[0])) {
                    var value = new clientkernelLoader.AssetGroup(this.parent);
                    ret.set(ids[0], value);
                }
                if (ret.get(ids[0]).group == null && auto) ret.get(ids[0]).createGroup();
                ret = ret.get(ids[0]).group;
                ids.splice(0, 1);
            }
            return ret;
        };
        clientkernelLoader.AssetGroup.prototype.__class__ = clientkernelLoader.AssetGroup;
        clientkernelLoader.Assets = function() {
            this.loadedCount = 0;
            this.group = new clientkernelLoader.AssetGroup(this, "");
            this.totalItems = -1;
            this.sizeLoaded = 0;
            this.loadedTopic = new clientkernelLoaderApi.AssetLoadedTopic();
            this.progressTopic = new clientkernelLoaderApi.LoadProgressTopic();
            this.earlyRequests = [];
        };
        clientkernelLoader.Assets = ck_implements(clientkernelLoader.Assets, clientkernelModulesApi.IService);
        clientkernelLoader.Assets = ck_implements(clientkernelLoader.Assets, clientkernelLoaderApiPlugins.IAssetRegistryAccess);
        clientkernelLoader.Assets = ck_implements(clientkernelLoader.Assets, clientkernelLoaderApi.IAssetRegistry);
        clientkernelLoader.Assets.__interfaces__ = [clientkernelModulesApi.IService, clientkernelLoaderApiPlugins.IAssetRegistryAccess, clientkernelLoaderApi.IAssetRegistry];
        clientkernelLoader.Assets.__name__ = ["clientkernelLoader", "Assets"];
        clientkernelLoader.Assets.prototype.group = null;
        clientkernelLoader.Assets.prototype.totalItems = null;
        clientkernelLoader.Assets.prototype.sizeLoaded = null;
        clientkernelLoader.Assets.prototype.channel = null;
        clientkernelLoader.Assets.prototype.pfKernelChannel = null;
        clientkernelLoader.Assets.prototype.loadedTopic = null;
        clientkernelLoader.Assets.prototype.progressTopic = null;
        clientkernelLoader.Assets.prototype.loadedCount = null;
        clientkernelLoader.Assets.prototype.earlyRequests = null;
        clientkernelLoader.Assets.prototype.connect = function(channel, pfKernelChannel) {
            this.channel = channel;
            this.pfKernelChannel = pfKernelChannel;
            this.loadedTopic.connect(channel);
            this.progressTopic.connect(pfKernelChannel);
        };
        clientkernelLoader.Assets.prototype.add = function(id, url, type, onrequest) {
            if (this.group.exists(id)) {
                var a = this.group.get(id).getAsset();
                a.setup(url, type, onrequest);
                return a;
            } else if (this.group.exists(this.simpleId(id)) && this.isRequestedEarly(id)) {
                var a1 = this.group.get(this.simpleId(id)).getAsset();
                a1.setup(url, type, onrequest);
                var asset = new clientkernelLoader.Asset(this, id, url, type, onrequest);
                this.group.add(id, asset);
                return a1;
            } else {
                var asset1 = new clientkernelLoader.Asset(this, id, url, type, onrequest);
                this.group.add(id, asset1);
                if (id != this.simpleId(id)) this.group.add(this.simpleId(id), asset1);
                return asset1;
            }
        };
        clientkernelLoader.Assets.prototype.isRequestedEarly = function(id) {
            return _hcmn_.HxOverrides.indexOf(this.earlyRequests, id, 0) >= 0 || (function($this) {
                var $r;
                var x = $this.simpleId(id);
                $r = _hcmn_.HxOverrides.indexOf($this.earlyRequests, x, 0);
                return $r;
            }(this)) >= 0;
        };
        clientkernelLoader.Assets.prototype.simpleId = function(id) {
            if (id.indexOf("/") == -1) return id;
            else return id.substring(id.lastIndexOf("/") + 1);
        };
        clientkernelLoader.Assets.prototype.remove = function(id) {
            this.group.remove(id);
        };
        clientkernelLoader.Assets.prototype.getAsset = function(id) {
            if (this.group.get(id, true) != null) return this.group.get(id).getAsset();
            else {
                var asset = new clientkernelLoader.Asset(this, id);
                this.group.add(id, asset);
                this.earlyRequests.push(id);
                if (id != this.simpleId(id)) {
                    this.group.add(this.simpleId(id), asset);
                    this.earlyRequests.push(this.simpleId(id));
                }
                return asset;
            }
        };
        clientkernelLoader.Assets.prototype.getAssetsContent = function(ids) {
            var _g2 = this;
            var assets = [];
            var _g = 0;
            while (_g < ids.length) {
                var i = ids[_g];
                ++_g;
                var a = this.getAsset(i);
                if (a != null) assets.push(a.getContent());
                else throw new js._Boot.HaxeError("asset does not exist:" + i);
            }
            return Promise.all(assets).then(function(content) {
                var ret = new _hcmn_.haxe_ds_StringMap();
                var _g1 = 0;
                var _g3 = ids.length;
                while (_g1 < _g3) {
                    var i1 = _g1++;
                    var key = _g2.simpleId(ids[i1]);
                    var value = content[i1];
                    ret.set(key, value);
                }
                return ret;
            });
        };
        clientkernelLoader.Assets.prototype.assetLoaded = function() {
            return this.loadedTopic;
        };
        clientkernelLoader.Assets.prototype.progress = function() {
            return this.progressTopic;
        };
        clientkernelLoader.Assets.prototype.triggerAssetLoaded = function(asset) {
            if (this.channel != null) this.loadedTopic.publish(asset.getId());
        };
        clientkernelLoader.Assets.prototype.updateProgress = function(deltaSizeLoaded, deltaFilesLoaded, deltaSize, deltaFiles) {
            this.sizeLoaded += deltaSizeLoaded;
            if (this.loadedCount < this.totalItems) this.loadedCount++;
            if (this.totalItems > 0 && this.pfKernelChannel != null) this.progressTopic.publish(new clientkernelLoader.LoadProgress("game", this.totalItems, this.loadedCount, false));
        };
        clientkernelLoader.Assets.prototype.getSubContent = function(id) {
            var ag = this.group.get(id);
            return this.getAssetsContent(ag.ids());
        };
        clientkernelLoader.Assets.prototype.setTotalItems = function(totalItems) {
            this.totalItems = totalItems;
        };
        clientkernelLoader.Assets.prototype.__class__ = clientkernelLoader.Assets;
        clientkernelLoader.LoadProgress = function(id, items, current, complete) {
            this.id = id;
            this.items = items;
            this.current = current;
            this.complete = complete;
        };
        clientkernelLoader.LoadProgress = ck_implements(clientkernelLoader.LoadProgress, clientkernelLoaderApi.ILoadProgress);
        clientkernelLoader.LoadProgress.__interfaces__ = [clientkernelLoaderApi.ILoadProgress];
        clientkernelLoader.LoadProgress.__name__ = ["clientkernelLoader", "LoadProgress"];
        clientkernelLoader.LoadProgress.prototype.id = null;
        clientkernelLoader.LoadProgress.prototype.items = null;
        clientkernelLoader.LoadProgress.prototype.current = null;
        clientkernelLoader.LoadProgress.prototype.complete = null;
        clientkernelLoader.LoadProgress.prototype.getId = function() {
            return this.id;
        };
        clientkernelLoader.LoadProgress.prototype.getItems = function() {
            return this.items;
        };
        clientkernelLoader.LoadProgress.prototype.getCurrent = function() {
            return this.current;
        };
        clientkernelLoader.LoadProgress.prototype.getComplete = function() {
            return this.complete;
        };
        clientkernelLoader.LoadProgress.prototype.__class__ = clientkernelLoader.LoadProgress;
        clientkernelLoader.LoaderAnimation = function() {
            this.wheel2 = 2;
            this.wheel1 = 0;
            window.addEventListener("load", $bind(this, this.startPreloader));
            window.addEventListener("resize", $bind(this, this.resize));
        };
        clientkernelLoader.LoaderAnimation.__name__ = ["clientkernelLoader", "LoaderAnimation"];
        clientkernelLoader.LoaderAnimation.prototype.preloader = null;
        clientkernelLoader.LoaderAnimation.prototype.timer = null;
        clientkernelLoader.LoaderAnimation.prototype.image = null;
        clientkernelLoader.LoaderAnimation.prototype.left = null;
        clientkernelLoader.LoaderAnimation.prototype.top = null;
        clientkernelLoader.LoaderAnimation.prototype.wheel1 = null;
        clientkernelLoader.LoaderAnimation.prototype.wheel2 = null;
        clientkernelLoader.LoaderAnimation.prototype.touchmove = function(e) {
            e.preventDefault();
        };
        clientkernelLoader.LoaderAnimation.prototype.startPreloader = function() {
            window.document.body.addEventListener("touchmove", $bind(this, this.touchmove));
            var _this = window.document;
            this.preloader = _this.createElement("canvas");
            this.image = window.document.getElementById("preloader");
            window.document.body.removeChild(this.image);
            this.preloader.id = "preloader";
            this.preloader.style.zIndex = "9999";
            this.preloader.addEventListener("touchmove", $bind(this, this.touchmove));
            this.resize();
            window.document.body.appendChild(this.preloader);
            this.timer = new _hcmn_.haxe_Timer(330);
            this.timer.run = $bind(this, this.draw);
        };
        clientkernelLoader.LoaderAnimation.prototype.resize = function() {
            this.preloader.width = window.innerWidth;
            this.preloader.height = window.innerHeight;
            var ctx = this.preloader.getContext("2d", null);
            ctx.fillStyle = "black";
            ctx.fillRect(0, 0, this.preloader.width, this.preloader.height);
            this.left = this.preloader.width / 2 - clientkernelLoader.LoaderAnimation.imagewidth / 2;
            this.top = this.preloader.height / 2 - clientkernelLoader.LoaderAnimation.imageheight;
            ctx.drawImage(this.image, 0, 0, clientkernelLoader.LoaderAnimation.imagewidth, clientkernelLoader.LoaderAnimation.imageheight, this.left, this.top, clientkernelLoader.LoaderAnimation.imagewidth, clientkernelLoader.LoaderAnimation.imageheight);
            this.draw();
        };
        clientkernelLoader.LoaderAnimation.prototype.draw = function() {
            if (this.preloader.width != window.innerWidth || this.preloader.height != window.innerHeight) this.resize();
            var ctx = this.preloader.getContext("2d", null);
            this.wheel1 = (this.wheel1 + 1) % 4;
            this.wheel2 = (this.wheel2 + 1) % 4;
            ctx.drawImage(this.image, clientkernelLoader.LoaderAnimation.wheels[this.wheel1][0], clientkernelLoader.LoaderAnimation.wheels[this.wheel1][1], 26, 22, this.left + 30, this.top + 15, 26, 22);
            ctx.drawImage(this.image, clientkernelLoader.LoaderAnimation.wheels[this.wheel2][0], clientkernelLoader.LoaderAnimation.wheels[this.wheel2][1], 26, 22, this.left + 135, this.top + 15, 26, 22);
        };
        clientkernelLoader.LoaderAnimation.prototype.hide = function() {
            if (this.timer != null) {
                window.removeEventListener("resize", $bind(this, this.resize));
                window.document.body.removeEventListener("touchmove", $bind(this, this.touchmove));
                this.preloader.removeEventListener("touchmove", $bind(this, this.touchmove));
                this.timer.stop();
                this.timer = null;
                this.preloader.style.display = "none";
                window.document.body.removeChild(this.preloader);
                this.preloader = null;
            }
        };
        clientkernelLoader.LoaderAnimation.prototype.__class__ = clientkernelLoader.LoaderAnimation;
        clientkernelLoader.LoaderContext = function(context) {
            this.vars = new clientkernelLoader.Variables();
            this.assets = new clientkernelLoader.Assets();
            this.loader = null;
            this.loaderConfiguration = new clientkernelLoader.LoaderConfiguration(this);
            this.context = context;
            this.loaderAnimation = new clientkernelLoader.LoaderAnimation();
        };
        clientkernelLoader.LoaderContext = ck_implements(clientkernelLoader.LoaderContext, clientkernelModulesApi.IServiceListener);
        clientkernelLoader.LoaderContext = ck_implements(clientkernelLoader.LoaderContext, clientkernelLoaderApiPlugins.ILoaderContext);
        clientkernelLoader.LoaderContext.__interfaces__ = [clientkernelModulesApi.IServiceListener, clientkernelLoaderApiPlugins.ILoaderContext];
        clientkernelLoader.LoaderContext.__name__ = ["clientkernelLoader", "LoaderContext"];
        clientkernelLoader.LoaderContext.prototype.loaderConfiguration = null;
        clientkernelLoader.LoaderContext.prototype.loaderPlugin = null;
        clientkernelLoader.LoaderContext.prototype.vars = null;
        clientkernelLoader.LoaderContext.prototype.assets = null;
        clientkernelLoader.LoaderContext.prototype.context = null;
        clientkernelLoader.LoaderContext.prototype.loader = null;
        clientkernelLoader.LoaderContext.prototype.loaderAnimation = null;
        clientkernelLoader.LoaderContext.prototype.initialize = function() {
            var _g = this;
            this.loaderConfiguration.registerPlugin(new clientkernelLoader.VariablesConfigurationPlugin());
            this.loaderConfiguration.registerPlugin(new clientkernelLoader.ImportUrlVariablesConfigurationPlugin());
            this.loaderConfiguration.registerPlugin(new clientkernelLoader.PreloadVariablesConfigurationPlugin());
            this.loaderConfiguration.registerPlugin(this.loaderPlugin = new clientkernelLoader.LoaderPlugin($bind(this, this.finishedLoading)));
            this.loaderPlugin.registerPlugin(new clientkernelLoader.JSPlugin());
            this.loaderPlugin.registerPlugin(new clientkernelLoader.PreloadJSPlugin());
            this.loaderPlugin.registerPlugin(new clientkernelLoader.FontsPlugin());
            this.loaderPlugin.registerPlugin(new clientkernelLoader.PackPlugin());
            this.loaderPlugin.registerPlugin(new clientkernelLoader.ConfigPlugin());
            this.context.addServiceListener(this);
            this.loadEnvironmentProperties();
            this.context.getServiceTracker([clientkernelEventbusApi.IEventBus]).then(function(context) {
                var eb = context.getAnyService(clientkernelEventbusApi.IEventBus);
                _g.assets.connect(eb.getChannel(clientkernelLoader.LoaderContext.LOADER_CHANNEL), eb.getChannel(clientkernelLoader.LoaderContext.PF_KERNEL_CHANNEL));
                var hdpt = new clientkernelLoaderApi.HideDefaultPreloaderTopic();
                hdpt.connect(eb.getChannel(clientkernelLoader.LoaderContext.LOADER_CHANNEL));
                hdpt.subscribe($bind(_g, _g.hidePreloader));
                context.registerService(_g.assets, clientkernelLoaderApi.IAssetRegistry, null);
                _g.loaderConfiguration.load({
                    loader: [{
                        id: "startup.config",
                        type: "config",
                        url: "startup.config.js",
                        loadtype: "block"
                    }]
                });
            });
        };
        clientkernelLoader.LoaderContext.prototype.loadEnvironmentProperties = function() {
            var _g = this;
            this.loaderConfiguration.load({
                loader: [{
                    id: "environment",
                    type: "preload-asset",
                    url: "environment.json",
                    loadtype: "block"
                }]
            });
            this.assets.getAsset("environment").getContent().then(function(data) {
                try {
                    _g.vars.set("postal.allowedOrigins", data.postal.allowedOrigins);
                    _g.vars.set("postal.defaultOrigin", data.postal.defaultOrigin);
                    _g.vars.set("postal.timeout", data.postal.timeout);
                } catch (e) {
                    if (e instanceof js._Boot.HaxeError) e = e.val;
                    if (_hcmn_.js_Boot.__instanceof(e, Error)) {
                        throw new Error("error parsing environment.json: " + e.message);
                    } else throw (e);
                }
                _g.context.registerService(_g.vars, clientkernelLoaderApi.IVariableRegistry, null);
            });
        };
        clientkernelLoader.LoaderContext.prototype.autoHidePreloader = function() {
            if (this.vars.get("auto.hide.preloader", "false") == "true") this.hidePreloader(null);
        };
        clientkernelLoader.LoaderContext.prototype.hidePreloader = function(ev) {
            this.loaderAnimation.hide();
        };
        clientkernelLoader.LoaderContext.prototype.finishedLoading = function() {
            this.autoHidePreloader();
        };
        clientkernelLoader.LoaderContext.prototype.serviceChanged = function(event) {
            if (event.getInterface() == clientkernelLoaderApiPlugins.IConfigurationPlugin) this.loaderConfiguration.registerPlugin(event.getService());
            else if (event.getInterface() == clientkernelLoaderApiPlugins.IAssetPlugin) this.loaderPlugin.registerPlugin(event.getService());
        };
        clientkernelLoader.LoaderContext.prototype.getVars = function() {
            return this.vars;
        };
        clientkernelLoader.LoaderContext.prototype.getAssets = function() {
            return this.assets;
        };
        clientkernelLoader.LoaderContext.prototype.getLoader = function() {
            return this.loader;
        };
        clientkernelLoader.LoaderContext.prototype.getModuleContext = function() {
            return this.context;
        };
        clientkernelLoader.LoaderContext.prototype.installLoader = function(loader) {
            if (this.loader == null) this.loader = loader;
            else throw new Error("multiple loader instances");
        };
        clientkernelLoader.LoaderContext.prototype.setTotalItems = function(totalItems) {
            this.assets.setTotalItems(totalItems);
        };
        clientkernelLoader.LoaderContext.prototype.__class__ = clientkernelLoader.LoaderContext;
        clientkernelLoader.Variables = function() {
            this.vars = new _hcmn_.haxe_ds_StringMap();
        };
        clientkernelLoader.Variables = ck_implements(clientkernelLoader.Variables, clientkernelModulesApi.IService);
        clientkernelLoader.Variables = ck_implements(clientkernelLoader.Variables, clientkernelLoaderApi.IVariableRegistry);
        clientkernelLoader.Variables = ck_implements(clientkernelLoader.Variables, clientkernelLoaderApiPlugins.IVariables);
        clientkernelLoader.Variables.__interfaces__ = [clientkernelModulesApi.IService, clientkernelLoaderApi.IVariableRegistry, clientkernelLoaderApiPlugins.IVariables];
        clientkernelLoader.Variables.__name__ = ["clientkernelLoader", "Variables"];
        clientkernelLoader.Variables.prototype.vars = null;
        clientkernelLoader.Variables.prototype.get = function(name, defaultValue) {
            if (this.vars.exists(name)) return this.vars.get(name);
            else return defaultValue;
        };
        clientkernelLoader.Variables.prototype.set = function(name, value) {
            this.vars.set(name, value);
        };
        clientkernelLoader.Variables.prototype.expand = function(value) {
            if (value == null) return null;
            var ret = value;
            var index = 0;
            var indexe;
            while ((index = ret.indexOf("${", index)) != -1) {
                if (ret.indexOf("}", index) == -1) return ret;
                var name = ret.substring(index + 2, indexe = ret.indexOf("}", index));
                if (this.vars.exists(name)) name = this.vars.get(name);
                else name = "${" + name + "}";
                var rl = ret.length;
                ret = _hcmn_.HxOverrides.substr(ret, 0, index) + name + _hcmn_.HxOverrides.substr(ret, indexe + 1, null);
                index = indexe - rl + ret.length;
            }
            return ret;
        };
        clientkernelLoader.Variables.prototype.__class__ = clientkernelLoader.Variables;
        clientkernelLoader.ImportUrlVariablesConfigurationPlugin = function() {};
        clientkernelLoader.ImportUrlVariablesConfigurationPlugin = ck_implements(clientkernelLoader.ImportUrlVariablesConfigurationPlugin, clientkernelLoaderApiPlugins.IConfigurationPlugin);
        clientkernelLoader.ImportUrlVariablesConfigurationPlugin.__interfaces__ = [clientkernelLoaderApiPlugins.IConfigurationPlugin];
        clientkernelLoader.ImportUrlVariablesConfigurationPlugin.__name__ = ["clientkernelLoader", "ImportUrlVariablesConfigurationPlugin"];
        clientkernelLoader.ImportUrlVariablesConfigurationPlugin.prototype.getSection = function() {
            return "importurlvariables";
        };
        clientkernelLoader.ImportUrlVariablesConfigurationPlugin.prototype.resolve = function(lc, config) {
            var querystring = window.document.location.search;
            if (querystring == null || querystring == "") return;
            querystring = _hcmn_.HxOverrides.substr(querystring, 1, null);
            querystring = querystring.split("?").join("&");
            var qsArray = querystring.split("&");
            var qsPart;
            var _g = 0;
            while (_g < qsArray.length) {
                var qsPart1 = qsArray[_g];
                ++_g;
                if (qsPart1 != "") {
                    var variableArray = qsPart1.split("=");
                    if (variableArray.length < 2) continue;
                    var valueDecoded = decodeURIComponent(variableArray[1].split("+").join(" "));
                    lc.getVars().set(variableArray[0], valueDecoded);
                }
            }
        };
        clientkernelLoader.ImportUrlVariablesConfigurationPlugin.prototype.__class__ = clientkernelLoader.ImportUrlVariablesConfigurationPlugin;
        clientkernelLoader.LoaderPlugin = function(onFinished) {
            this.loadedRemaining = 0;
            this.assetPlugins = new _hcmn_.haxe_ds_StringMap();
            this.onFinished = onFinished;
            this.queue = new clientkernelLoader.LoadingQueue(null, this, null);
            this.queues = [];
            this.queues.push(this.queue);
        };
        clientkernelLoader.LoaderPlugin = ck_implements(clientkernelLoader.LoaderPlugin, clientkernelLoaderApiPlugins.ILoader);
        clientkernelLoader.LoaderPlugin = ck_implements(clientkernelLoader.LoaderPlugin, clientkernelLoaderApiPlugins.IConfigurationPlugin);
        clientkernelLoader.LoaderPlugin.__interfaces__ = [clientkernelLoaderApiPlugins.ILoader, clientkernelLoaderApiPlugins.IConfigurationPlugin];
        clientkernelLoader.LoaderPlugin.__name__ = ["clientkernelLoader", "LoaderPlugin"];
        clientkernelLoader.LoaderPlugin.prototype.assetPlugins = null;
        clientkernelLoader.LoaderPlugin.prototype.queue = null;
        clientkernelLoader.LoaderPlugin.prototype.lc = null;
        clientkernelLoader.LoaderPlugin.prototype.onFinished = null;
        clientkernelLoader.LoaderPlugin.prototype.queues = null;
        clientkernelLoader.LoaderPlugin.prototype.loadedRemaining = null;
        clientkernelLoader.LoaderPlugin.prototype.getSection = function() {
            return "loader";
        };
        clientkernelLoader.LoaderPlugin.prototype.registerPlugin = function(alp) {
            var _g = 0;
            var _g1 = alp.getAssetTypes();
            while (_g < _g1.length) {
                var i = _g1[_g];
                ++_g;
                this.assetPlugins.set(i, alp);
                var _g2 = 0;
                var _g3 = this.queues;
                while (_g2 < _g3.length) {
                    var q = _g3[_g2];
                    ++_g2;
                    q.setPlugin(i, alp);
                }
            }
        };
        clientkernelLoader.LoaderPlugin.prototype.getAssetPlugin = function(type) {
            return this.assetPlugins.get(type);
        };
        clientkernelLoader.LoaderPlugin.prototype.resolve = function(lc, config) {
            this.lc = lc;
            this.queue.resolve(lc, config, this.onFinished);
        };
        clientkernelLoader.LoaderPlugin.prototype.addQueue = function(id, config, baseUrl, onFinished) {
            var _g = this;
            var q = new clientkernelLoader.LoadingQueue(id, this, baseUrl);
            this.queues.push(q);
            this.loadedRemaining++;
            var onFinishedCheck = function() {
                _g.loadedRemaining--;
                if (_g.loadedRemaining == 0) window.console.log("[ds] loaded");
                onFinished();
            };
            q.resolve(this.lc, config, onFinishedCheck);
        };
        clientkernelLoader.LoaderPlugin.prototype.__class__ = clientkernelLoader.LoaderPlugin;
        clientkernelLoader.LoadingAsset = function(lc, id, type, plugin, url, loadtype, condition, config, onLoaded, onRequested) {
            this.lc = lc;
            this.id = id;
            this.type = type;
            this.plugin = plugin;
            this.url = url;
            this.loadtype = loadtype;
            this.onLoaded = onLoaded;
            this.onRequested = onRequested;
            this.condition = condition;
            this.config = config;
            if (plugin != null) {
                this.loader = plugin.createLoader();
                this.loader.setup(lc, id, type, lc.getVars().expand(url), config, $bind(this, this.requested));
            } else this.loader = null;
        };
        clientkernelLoader.LoadingAsset.__name__ = ["clientkernelLoader", "LoadingAsset"];
        clientkernelLoader.LoadingAsset.prototype.id = null;
        clientkernelLoader.LoadingAsset.prototype.type = null;
        clientkernelLoader.LoadingAsset.prototype.plugin = null;
        clientkernelLoader.LoadingAsset.prototype.url = null;
        clientkernelLoader.LoadingAsset.prototype.loadtype = null;
        clientkernelLoader.LoadingAsset.prototype.condition = null;
        clientkernelLoader.LoadingAsset.prototype.config = null;
        clientkernelLoader.LoadingAsset.prototype.onLoaded = null;
        clientkernelLoader.LoadingAsset.prototype.onRequested = null;
        clientkernelLoader.LoadingAsset.prototype.lc = null;
        clientkernelLoader.LoadingAsset.prototype.loader = null;
        clientkernelLoader.LoadingAsset.prototype.getId = function() {
            return this.id;
        };
        clientkernelLoader.LoadingAsset.prototype.getType = function() {
            return this.type;
        };
        clientkernelLoader.LoadingAsset.prototype.getCondition = function() {
            if (this.condition == null || this.condition == "") return true;
            var c = this.lc.getVars().expand(this.condition);
            return eval(c);
        };
        clientkernelLoader.LoadingAsset.prototype.getPlugin = function() {
            return this.plugin;
        };
        clientkernelLoader.LoadingAsset.prototype.setPlugin = function(type, plugin) {
            if (this.plugin == null) {
                this.plugin = plugin;
                this.loader = this.plugin.createLoader();
                this.loader.setup(this.lc, this.id, type, this.lc.getVars().expand(this.url), this.config, $bind(this, this.requested));
            }
        };
        clientkernelLoader.LoadingAsset.prototype.getUrl = function() {
            return this.url;
        };
        clientkernelLoader.LoadingAsset.prototype.getLoadType = function() {
            return this.loadtype;
        };
        clientkernelLoader.LoadingAsset.prototype.load = function(loader) {
            if (loader != null) this.loader.load($bind(this, this.loaded));
        };
        clientkernelLoader.LoadingAsset.prototype.unload = function() {
            if (this.loader != null) this.loader.unload();
        };
        clientkernelLoader.LoadingAsset.prototype.loaded = function() {
            this.onLoaded(this);
        };
        clientkernelLoader.LoadingAsset.prototype.requested = function() {
            if (this.onRequested != null) this.onRequested(this);
        };
        clientkernelLoader.LoadingAsset.prototype.__class__ = clientkernelLoader.LoadingAsset;
        clientkernelLoader.LoadingQueue = function(id, lp, baseUrl) {
            this.max_parallel = 4;
            this.blocking = 0;
            if (id == null) this.id = "";
            else this.id = id;
            this.loaderPlugin = lp;
            this.queue = [];
            this.onRequestQueue = [];
            this.processing = [];
            this.baseUrl = baseUrl;
            if (this.baseUrl != null && this.baseUrl != "") {
                if (_hcmn_.HxOverrides.substr(this.baseUrl, this.baseUrl.length - 1, null) != "/") this.baseUrl += "/";
            }
        };
        clientkernelLoader.LoadingQueue.__name__ = ["clientkernelLoader", "LoadingQueue"];
        clientkernelLoader.LoadingQueue.prototype.loaderPlugin = null;
        clientkernelLoader.LoadingQueue.prototype.onRequestQueue = null;
        clientkernelLoader.LoadingQueue.prototype.queue = null;
        clientkernelLoader.LoadingQueue.prototype.processing = null;
        clientkernelLoader.LoadingQueue.prototype.blocking = null;
        clientkernelLoader.LoadingQueue.prototype.max_parallel = null;
        clientkernelLoader.LoadingQueue.prototype.onFinished = null;
        clientkernelLoader.LoadingQueue.prototype.baseUrl = null;
        clientkernelLoader.LoadingQueue.prototype.id = null;
        clientkernelLoader.LoadingQueue.prototype.resolve = function(lc, config, onFinished) {
            this.onFinished = onFinished;
            var addedToQueue = false;
            var cfg = config;
            var _g = 0;
            while (_g < cfg.length) {
                var i = cfg[_g];
                ++_g;
                var myid;
                if (this.id == "") myid = i.id;
                else myid = this.id + "/" + i.id;
                if (i.loadtype == "onrequest") this.onRequestQueue.push(new clientkernelLoader.LoadingAsset(lc, myid, i.type, this.loaderPlugin.getAssetPlugin(i.type), this.makeurl(i.url), i.loadtype, i.condition, i.config, $bind(this, this.finished), $bind(this, this.requested)));
                else {
                    addedToQueue = true;
                    this.queue.push(new clientkernelLoader.LoadingAsset(lc, myid, i.type, this.loaderPlugin.getAssetPlugin(i.type), this.makeurl(i.url), i.loadtype, i.condition, i.config, $bind(this, this.finished), null));
                }
            }
            if (addedToQueue) this.process();
        };
        clientkernelLoader.LoadingQueue.prototype.makeurl = function(url) {
            if (this.baseUrl == null) return url;
            if (url.indexOf("http:") == 0 || url.indexOf("https:") == 0 || url.indexOf("/") == 0) return url;
            return this.baseUrl + url;
        };
        clientkernelLoader.LoadingQueue.prototype.finished = function(la) {
            if (la.getLoadType() == "block") this.blocking--;
            _hcmn_.HxOverrides.remove(this.processing, la);
            this.process();
            if (this.queue.length == 0 && this.processing.length == 0 && this.onFinished != null) this.onFinished();
        };
        clientkernelLoader.LoadingQueue.prototype.requested = function(la) {
            if (_hcmn_.HxOverrides.indexOf(this.onRequestQueue, la, 0) != -1) {
                _hcmn_.HxOverrides.remove(this.onRequestQueue, la);
                this.queue.push(la);
            }
            this.process();
        };
        clientkernelLoader.LoadingQueue.prototype.process = function() {
            if (this.queue.length == 0) return;
            if (this.processing.length >= this.max_parallel) return;
            if (this.blocking > 0) return;
            var _g1 = 0;
            var _g = this.queue.length;
            while (_g1 < _g) {
                var index = _g1++;
                var i = this.queue[index];
                if (i.getPlugin() != null) {
                    if (i.getCondition()) {
                        var la = this.queue.splice(index, 1)[0];
                        if (la.getLoadType() == "block") this.blocking++;
                        this.processing.push(la);
                        la.load(this.loaderPlugin);
                        this.process();
                        return;
                    } else {
                        var la1 = this.queue.splice(index, 1)[0];
                        la1.unload();
                        this.finished(la1);
                        this.process();
                        return;
                    }
                } else if (i.getLoadType() == "block") return;
            }
        };
        clientkernelLoader.LoadingQueue.prototype.setPlugin = function(type, alp) {
            var _g = 0;
            var _g1 = this.queue;
            while (_g < _g1.length) {
                var i = _g1[_g];
                ++_g;
                if (i.getType() == type) i.setPlugin(type, alp);
            }
            var _g2 = 0;
            var _g11 = this.onRequestQueue;
            while (_g2 < _g11.length) {
                var j = _g11[_g2];
                ++_g2;
                if (j.getType() == type) j.setPlugin(type, alp);
            }
            this.process();
        };
        clientkernelLoader.LoadingQueue.prototype.__class__ = clientkernelLoader.LoadingQueue;
        clientkernelLoader.ConfigLoader = function() {
            this.isLoaded = false;
        };
        clientkernelLoader.ConfigLoader = ck_implements(clientkernelLoader.ConfigLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        clientkernelLoader.ConfigLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        clientkernelLoader.ConfigLoader.__name__ = ["clientkernelLoader", "ConfigLoader"];
        clientkernelLoader.ConfigLoader.prototype.lc = null;
        clientkernelLoader.ConfigLoader.prototype.id = null;
        clientkernelLoader.ConfigLoader.prototype.type = null;
        clientkernelLoader.ConfigLoader.prototype.url = null;
        clientkernelLoader.ConfigLoader.prototype.config = null;
        clientkernelLoader.ConfigLoader.prototype.onrequest = null;
        clientkernelLoader.ConfigLoader.prototype.onfinish = null;
        clientkernelLoader.ConfigLoader.prototype.isLoaded = null;
        clientkernelLoader.ConfigLoader.prototype.asset = null;
        clientkernelLoader.ConfigLoader.prototype.xmlloader = null;
        clientkernelLoader.ConfigLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.lc = lc;
            this.id = id;
            this.type = type;
            this.url = url;
            this.config = config;
            this.onrequest = onrequest;
            this.asset = lc.getAssets().add(id, url, type, onrequest);
        };
        clientkernelLoader.ConfigLoader.prototype.load = function(onfinish) {
            this.onfinish = onfinish;
            this.xmlloader = new XMLHttpRequest();
            this.xmlloader.onload = $bind(this, this.handleComplete);
            this.xmlloader.onerror = $bind(this, this.onFinished);
            this.xmlloader.open("GET", this.url);
            this.xmlloader.send();
        };
        clientkernelLoader.ConfigLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        clientkernelLoader.ConfigLoader.prototype.handleComplete = function(event) {
            var t = this.xmlloader.responseText;
            var config = null;
            eval('config=' + t);
            var cfg = config.variables;
            if (cfg != null) {
                var _g = 0;
                while (_g < cfg.length) {
                    var i = cfg[_g];
                    ++_g;
                    this.lc.getVars().set(i.name, i.value);
                }
            }
            if (config.importurlvariables != null) new clientkernelLoader.ImportUrlVariablesConfigurationPlugin().resolve(this.lc, null);
            if (config.preloadvariables != null) new clientkernelLoader.PreloadVariablesConfigurationPlugin().resolve(this.lc, config.preloadvariables);
            var baseUrl = this.url;
            baseUrl = baseUrl.split("?")[0];
            var len = baseUrl.lastIndexOf("/") + 1;
            baseUrl = _hcmn_.HxOverrides.substr(baseUrl, 0, len);
            this.lc.getLoader().addQueue(null, config.loader, baseUrl, $bind(this, this.onFinished));
        };
        clientkernelLoader.ConfigLoader.prototype.onFinished = function() {
            if (this.onfinish != null) {
                this.isLoaded = true;
                this.onfinish();
            }
        };
        clientkernelLoader.ConfigLoader.prototype.__class__ = clientkernelLoader.ConfigLoader;
        clientkernelLoader.ConfigPlugin = function() {};
        clientkernelLoader.ConfigPlugin = ck_implements(clientkernelLoader.ConfigPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        clientkernelLoader.ConfigPlugin.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetPlugin];
        clientkernelLoader.ConfigPlugin.__name__ = ["clientkernelLoader", "ConfigPlugin"];
        clientkernelLoader.ConfigPlugin.prototype.getAssetTypes = function() {
            return ["config"];
        };
        clientkernelLoader.ConfigPlugin.prototype.createLoader = function() {
            return new clientkernelLoader.ConfigLoader();
        };
        clientkernelLoader.ConfigPlugin.prototype.__class__ = clientkernelLoader.ConfigPlugin;
        clientkernelLoader.FontsLoader = function() {};
        clientkernelLoader.FontsLoader = ck_implements(clientkernelLoader.FontsLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        clientkernelLoader.FontsLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        clientkernelLoader.FontsLoader.__name__ = ["clientkernelLoader", "FontsLoader"];
        clientkernelLoader.FontsLoader.prototype.font = null;
        clientkernelLoader.FontsLoader.prototype.lc = null;
        clientkernelLoader.FontsLoader.prototype.id = null;
        clientkernelLoader.FontsLoader.prototype.onfinish = null;
        clientkernelLoader.FontsLoader.prototype.url = null;
        clientkernelLoader.FontsLoader.prototype.asset = null;
        clientkernelLoader.FontsLoader.prototype.fontFamily = null;
        clientkernelLoader.FontsLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.url = url;
            this.lc = lc;
            this.id = id;
            if (config != null) {
                if (Object.prototype.hasOwnProperty.call(config, "fontFamily")) this.fontFamily = _hcmn_.Reflect.field(config, "fontFamily");
            }
            this.asset = lc.getAssets().add(id, url, type, onrequest);
        };
        clientkernelLoader.FontsLoader.prototype.load = function(onfinish) {
            this.onfinish = onfinish;
            this.font = new font.Font();
            this.font.onload = $bind(this, this.handleComplete);
            this.font.src = this.url;
            this.font.fontFamily = this.fontFamily;
        };
        clientkernelLoader.FontsLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        clientkernelLoader.FontsLoader.prototype.handleProgress = function(event) {};
        clientkernelLoader.FontsLoader.prototype.handleComplete = function() {
            this.asset.setContent(this.font);
            if (this.onfinish != null) this.onfinish();
        };
        clientkernelLoader.FontsLoader.prototype.onFinished = function() {
            if (this.onfinish != null) this.onfinish();
        };
        clientkernelLoader.FontsLoader.prototype.handleError = function(event) {};
        clientkernelLoader.FontsLoader.prototype.__class__ = clientkernelLoader.FontsLoader;
        clientkernelLoader.FontsPlugin = function() {};
        clientkernelLoader.FontsPlugin = ck_implements(clientkernelLoader.FontsPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        clientkernelLoader.FontsPlugin.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetPlugin];
        clientkernelLoader.FontsPlugin.__name__ = ["clientkernelLoader", "FontsPlugin"];
        clientkernelLoader.FontsPlugin.prototype.getAssetTypes = function() {
            return ["font"];
        };
        clientkernelLoader.FontsPlugin.prototype.createLoader = function() {
            return new clientkernelLoader.FontsLoader();
        };
        clientkernelLoader.FontsPlugin.prototype.__class__ = clientkernelLoader.FontsPlugin;
        clientkernelLoader.JSLoader = function() {
            this.module = null;
            this.shim = null;
            this.tag = true;
        };
        clientkernelLoader.JSLoader = ck_implements(clientkernelLoader.JSLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        clientkernelLoader.JSLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        clientkernelLoader.JSLoader.__name__ = ["clientkernelLoader", "JSLoader"];
        clientkernelLoader.JSLoader.prototype.onfinish = null;
        clientkernelLoader.JSLoader.prototype.url = null;
        clientkernelLoader.JSLoader.prototype.tag = null;
        clientkernelLoader.JSLoader.prototype.shim = null;
        clientkernelLoader.JSLoader.prototype.module = null;
        clientkernelLoader.JSLoader.prototype.xmlloader = null;
        clientkernelLoader.JSLoader.prototype.asset = null;
        clientkernelLoader.JSLoader.prototype.lc = null;
        clientkernelLoader.JSLoader.prototype.id = null;
        clientkernelLoader.JSLoader.prototype.category = null;
        clientkernelLoader.JSLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.url = url;
            this.lc = lc;
            this.id = id;
            if (config != null) {
                if (Object.prototype.hasOwnProperty.call(config, "tag")) this.tag = _hcmn_.Reflect.field(config, "tag");
                if (Object.prototype.hasOwnProperty.call(config, "shim")) this.shim = _hcmn_.Reflect.field(config, "shim");
                if (Object.prototype.hasOwnProperty.call(config, "module")) this.module = _hcmn_.Reflect.field(config, "module");
                if (Object.prototype.hasOwnProperty.call(config, "category")) this.category = _hcmn_.Reflect.field(config, "category");
            }
            if (this.module != null || this.shim != null) this.tag = false;
            this.asset = lc.getAssets().add(id, url, type, null);
        };
        clientkernelLoader.JSLoader.prototype.load = function(onfinish) {
            if (this.lc.getVars().get("bundle") == "true" && this.category != "bundle") {
                onfinish();
                return;
            }
            this.onfinish = onfinish;
            if (this.tag) {
                var script;
                var _this = window.document;
                script = _this.createElement("script");
                script.async = true;
                script.onload = $bind(this, this.onLoadedTag);
                script.src = this.url;
                window.document.head.appendChild(script);
            } else {
                this.xmlloader = new XMLHttpRequest();
                this.xmlloader.onload = $bind(this, this.handleComplete);
                this.xmlloader.onerror = onfinish;
                this.xmlloader.open("GET", this.url);
                this.xmlloader.onprogress = $bind(this, this.handleProgress);
                this.xmlloader.send();
            }
        };
        clientkernelLoader.JSLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        clientkernelLoader.JSLoader.prototype.handleProgress = function(event) {
            if (event.lengthComputable) this.asset.setProgress(event.loaded, event.total);
            else this.asset.setProgress(0, 1);
        };
        clientkernelLoader.JSLoader.prototype.handleComplete = function(event) {
            var content = "";
            if (this.module != null) content += "define.amd.module=\"" + this.module + "\";";
            var shimaction = "";
            if (this.shim != null) {
                if (this.shim.indexOf(":") >= 0) {
                    var x = this.shim.split(":");
                    this.shim = x[1];
                    shimaction = x[0];
                }
                content += "define.amd.shim=\"" + this.shim + "\";";
            }
            content += this.xmlloader.responseText;
            if (this.shim != null) switch (shimaction) {
                case "import":
                    content += "define(function() {});";
                    break;
                default:
            }
            var script;
            var _this = window.document;
            script = _this.createElement("script");
            script.appendChild(window.document.createTextNode(content));
            window.document.head.appendChild(script);
            this.asset.setContent("<script/>");
            if (this.onfinish != null) this.onfinish();
        };
        clientkernelLoader.JSLoader.prototype.onFinished = function() {
            if (this.onfinish != null) this.onfinish();
        };
        clientkernelLoader.JSLoader.prototype.onLoadedTag = function() {
            if (this.onfinish != null) {
                this.asset.setContent("<script/>");
                this.onfinish();
            }
        };
        clientkernelLoader.JSLoader.prototype.__class__ = clientkernelLoader.JSLoader;
        clientkernelLoader.JSPlugin = function() {};
        clientkernelLoader.JSPlugin = ck_implements(clientkernelLoader.JSPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        clientkernelLoader.JSPlugin.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetPlugin];
        clientkernelLoader.JSPlugin.__name__ = ["clientkernelLoader", "JSPlugin"];
        clientkernelLoader.JSPlugin.prototype.getAssetTypes = function() {
            return ["javascript"];
        };
        clientkernelLoader.JSPlugin.prototype.createLoader = function() {
            return new clientkernelLoader.JSLoader();
        };
        clientkernelLoader.JSPlugin.prototype.__class__ = clientkernelLoader.JSPlugin;
        clientkernelLoader.PackLoader = function() {};
        clientkernelLoader.PackLoader = ck_implements(clientkernelLoader.PackLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        clientkernelLoader.PackLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        clientkernelLoader.PackLoader.__name__ = ["clientkernelLoader", "PackLoader"];
        clientkernelLoader.PackLoader.prototype.lc = null;
        clientkernelLoader.PackLoader.prototype.id = null;
        clientkernelLoader.PackLoader.prototype.type = null;
        clientkernelLoader.PackLoader.prototype.url = null;
        clientkernelLoader.PackLoader.prototype.config = null;
        clientkernelLoader.PackLoader.prototype.onrequest = null;
        clientkernelLoader.PackLoader.prototype.onfinish = null;
        clientkernelLoader.PackLoader.prototype.asset = null;
        clientkernelLoader.PackLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.lc = lc;
            this.id = id;
            this.type = type;
            this.url = url;
            this.config = config;
            this.onrequest = onrequest;
            this.asset = lc.getAssets().add(id, url, type, onrequest);
        };
        clientkernelLoader.PackLoader.prototype.load = function(onfinish) {
            this.onfinish = onfinish;
            this.lc.getLoader().addQueue(this.id, this.config.loader, this.url, $bind(this, this.onFinished));
        };
        clientkernelLoader.PackLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        clientkernelLoader.PackLoader.prototype.onFinished = function() {
            if (this.onfinish != null) {
                this.asset.setContent(null);
                this.onfinish();
            }
        };
        clientkernelLoader.PackLoader.prototype.__class__ = clientkernelLoader.PackLoader;
        clientkernelLoader.PackPlugin = function() {
            this.loaders = [];
        };
        clientkernelLoader.PackPlugin = ck_implements(clientkernelLoader.PackPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        clientkernelLoader.PackPlugin.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetPlugin];
        clientkernelLoader.PackPlugin.__name__ = ["clientkernelLoader", "PackPlugin"];
        clientkernelLoader.PackPlugin.prototype.loaders = null;
        clientkernelLoader.PackPlugin.prototype.getAssetTypes = function() {
            return ["pack"];
        };
        clientkernelLoader.PackPlugin.prototype.createLoader = function() {
            var loader = new clientkernelLoader.PackLoader();
            this.loaders.push(loader);
            return loader;
        };
        clientkernelLoader.PackPlugin.prototype.__class__ = clientkernelLoader.PackPlugin;
        clientkernelLoader.PreloadJSLoader = function() {};
        clientkernelLoader.PreloadJSLoader = ck_implements(clientkernelLoader.PreloadJSLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        clientkernelLoader.PreloadJSLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        clientkernelLoader.PreloadJSLoader.__name__ = ["clientkernelLoader", "PreloadJSLoader"];
        clientkernelLoader.PreloadJSLoader.prototype.lc = null;
        clientkernelLoader.PreloadJSLoader.prototype.id = null;
        clientkernelLoader.PreloadJSLoader.prototype.onfinish = null;
        clientkernelLoader.PreloadJSLoader.prototype.url = null;
        clientkernelLoader.PreloadJSLoader.prototype.loader = null;
        clientkernelLoader.PreloadJSLoader.prototype.asset = null;
        clientkernelLoader.PreloadJSLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.url = url;
            this.lc = lc;
            this.id = id;
            this.asset = lc.getAssets().add(id, url, type, onrequest);
        };
        clientkernelLoader.PreloadJSLoader.prototype.load = function(onfinish) {
            this.onfinish = onfinish;
            this.loader = new preloadjs.LoadQueue();
            var manifest = [{
                id: this.asset.getId(),
                src: this.asset.getUrl()
            }];
            this.loader.addEventListener("complete", $bind(this, this.handleComplete));
            this.loader.addEventListener("error", $bind(this, this.handleError));
            this.loader.loadManifest(manifest);
            var loaderDynamic = this.loader;
            var loaderConcrete = loaderDynamic._loadQueueBackup[0];
            if (loaderConcrete != null && loaderConcrete._request != null) loaderConcrete._request.addEventListener("progress", $bind(this, this.handleProgress));
        };
        clientkernelLoader.PreloadJSLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        clientkernelLoader.PreloadJSLoader.prototype.handleProgress = function(event) {
            if (event.lengthComputable) this.asset.setProgress(event.loaded, event.total);
            else this.asset.setProgress(0, 1);
        };
        clientkernelLoader.PreloadJSLoader.prototype.handleComplete = function(event) {
            this.asset.setContent(this.loader.getResult(this.asset.getId()));
            if (this.onfinish != null) this.onfinish();
        };
        clientkernelLoader.PreloadJSLoader.prototype.onFinished = function() {
            if (this.onfinish != null) this.onfinish();
        };
        clientkernelLoader.PreloadJSLoader.prototype.handleError = function(event) {};
        clientkernelLoader.PreloadJSLoader.prototype.__class__ = clientkernelLoader.PreloadJSLoader;
        clientkernelLoader.PreloadJSPlugin = function() {};
        clientkernelLoader.PreloadJSPlugin = ck_implements(clientkernelLoader.PreloadJSPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        clientkernelLoader.PreloadJSPlugin.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetPlugin];
        clientkernelLoader.PreloadJSPlugin.__name__ = ["clientkernelLoader", "PreloadJSPlugin"];
        clientkernelLoader.PreloadJSPlugin.prototype.getAssetTypes = function() {
            return ["preload-asset", "font"];
        };
        clientkernelLoader.PreloadJSPlugin.prototype.createLoader = function() {
            return new clientkernelLoader.PreloadJSLoader();
        };
        clientkernelLoader.PreloadJSPlugin.prototype.__class__ = clientkernelLoader.PreloadJSPlugin;
        clientkernelLoader.PreloadVariablesConfigurationPlugin = function() {
            this.lc = null;
        };
        clientkernelLoader.PreloadVariablesConfigurationPlugin = ck_implements(clientkernelLoader.PreloadVariablesConfigurationPlugin, clientkernelLoaderApiPlugins.IConfigurationPlugin);
        clientkernelLoader.PreloadVariablesConfigurationPlugin.__interfaces__ = [clientkernelLoaderApiPlugins.IConfigurationPlugin];
        clientkernelLoader.PreloadVariablesConfigurationPlugin.__name__ = ["clientkernelLoader", "PreloadVariablesConfigurationPlugin"];
        clientkernelLoader.PreloadVariablesConfigurationPlugin.prototype.lc = null;
        clientkernelLoader.PreloadVariablesConfigurationPlugin.prototype.getSection = function() {
            return "preloadvariables";
        };
        clientkernelLoader.PreloadVariablesConfigurationPlugin.prototype.resolve = function(lc, config) {
            this.lc = lc;
            var cfg = config;
            var _g = 0;
            while (_g < cfg.length) {
                var i = cfg[_g];
                ++_g;
                lc.getVars().set(i.name, i.value);
            }
            this.extractClientInfoVariables();
            this.setTotalItemsForLoadProgress();
        };
        clientkernelLoader.PreloadVariablesConfigurationPlugin.prototype.extractClientInfoVariables = function() {
            var fullHDw = 1920;
            var w;
            if (window.screen.width > window.outerWidth) w = window.screen.width;
            else w = window.outerWidth;
            var h;
            if (window.screen.height > window.outerHeight) h = window.screen.height;
            else h = window.outerHeight;
            w *= window.devicePixelRatio;
            h *= window.devicePixelRatio;
            var realScale = _hcmn_.Math.max(w, h) / fullHDw;
            var scaleOptionsVarName = "skin.scaleoptions";
            var scaleOptionsVar = this.lc.getVars().get(scaleOptionsVarName);
            if (scaleOptionsVar == null) {
                this.lc.getVars().set("skin.scalepath", "");
                return;
            }
            var scaleOptionsArray;
            if (scaleOptionsVar != null) scaleOptionsArray = scaleOptionsVar.split(",");
            else scaleOptionsArray = [];
            var defaultScaleId = this.lc.getVars().get(scaleOptionsVarName + ".default");
            var nearestScaleId = defaultScaleId;
            var _g = 0;
            while (_g < scaleOptionsArray.length) {
                var scaleId = scaleOptionsArray[_g];
                ++_g;
                var nearestScaleFloat = _hcmn_.Std.parseFloat(this.lc.getVars().get(scaleOptionsVarName + "." + nearestScaleId)) / 100;
                var valForScaleId = _hcmn_.Std.parseFloat(this.lc.getVars().get(scaleOptionsVarName + "." + scaleId)) / 100;
                if (_hcmn_.Math.abs(valForScaleId - realScale) < _hcmn_.Math.abs(nearestScaleFloat - realScale)) nearestScaleId = scaleId;
            }
            var scalePath = "";
            var defaultScale = this.lc.getVars().get(scaleOptionsVarName + defaultScaleId);
            scalePath = nearestScaleId + "/";
            this.lc.getVars().set("skin.scalepath", scalePath);
            var RAFfps = 60;
            var targetFPSValue = this.lc.getVars().get("skin.targetfps." + nearestScaleId);
            if (targetFPSValue == null) targetFPSValue = RAFfps + "";
            this.lc.getVars().set("targetFPS", targetFPSValue);
            null;
        };
        clientkernelLoader.PreloadVariablesConfigurationPlugin.prototype.setTotalItemsForLoadProgress = function() {
            var totalItems = -1;
            var totalItemsString;
            var skin = this.lc.getVars().get("skin");
            var assetPack = this.lc.getVars().get("assetPack");
            if (skin != null && skin != "") {
                totalItemsString = this.lc.getVars().get("totalItems." + skin);
                totalItems = _hcmn_.Std.parseInt(totalItemsString);
            }
            if (this.lc.getVars().get("assetPack") != null) {
                totalItemsString = this.lc.getVars().get("totalItems." + assetPack);
                totalItems = _hcmn_.Std.parseInt(totalItemsString);
            }
            if (totalItems > 0)(_hcmn_.js_Boot.__cast(this.lc.getAssets(), clientkernelLoader.Assets)).setTotalItems(totalItems);
        };
        clientkernelLoader.PreloadVariablesConfigurationPlugin.prototype.__class__ = clientkernelLoader.PreloadVariablesConfigurationPlugin;
        clientkernelLoader.VariablesConfigurationPlugin = function() {};
        clientkernelLoader.VariablesConfigurationPlugin = ck_implements(clientkernelLoader.VariablesConfigurationPlugin, clientkernelLoaderApiPlugins.IConfigurationPlugin);
        clientkernelLoader.VariablesConfigurationPlugin.__interfaces__ = [clientkernelLoaderApiPlugins.IConfigurationPlugin];
        clientkernelLoader.VariablesConfigurationPlugin.__name__ = ["clientkernelLoader", "VariablesConfigurationPlugin"];
        clientkernelLoader.VariablesConfigurationPlugin.prototype.getSection = function() {
            return "variables";
        };
        clientkernelLoader.VariablesConfigurationPlugin.prototype.resolve = function(lc, config) {
            var cfg = config;
            var _g = 0;
            while (_g < cfg.length) {
                var i = cfg[_g];
                ++_g;
                lc.getVars().set(i.name, i.value);
            }
        };
        clientkernelLoader.VariablesConfigurationPlugin.prototype.__class__ = clientkernelLoader.VariablesConfigurationPlugin;
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

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

            get: function(k) {
                return {
                    arguments: ["*"],
                    returns: "null"
                };
            },
            set: function(k, v) {
                return {
                    arguments: ["*", "*"],
                    returns: "void"
                };
            },
            remove: function(k) {
                return {
                    arguments: ["*"],
                    returns: "boolean"
                };
            }
        };
        if (typeof js == 'undefined') {
            var js = {};
        };
        if (!js._Boot) {
            js._Boot = {};
        };
        js._Boot.HaxeError = function(val) {
            Error.call(this);
            this.val = val;
            this.message = String(val);
            if (Error.captureStackTrace) Error.captureStackTrace(this, js._Boot.HaxeError);
        };
        js._Boot.HaxeError.__name__ = ["js", "_Boot", "HaxeError"];
        js._Boot.HaxeError.__super__ = Error;
        for (var k in Error.prototype) js._Boot.HaxeError.prototype[k] = Error.prototype[k];
        js._Boot.HaxeError.prototype.val = null;
        js._Boot.HaxeError.prototype.__class__ = js._Boot.HaxeError;
        clientkernelLoader.LoaderAnimation.imagewidth = 192;;
        clientkernelLoader.LoaderAnimation.imageheight = 15;;
        clientkernelLoader.LoaderAnimation.wheels = [
            [0, 16],
            [26, 16],
            [52, 16],
            [78, 16]
        ];;
        clientkernelLoader.LoaderContext.LOADER_CHANNEL = "loader";;
        clientkernelLoader.LoaderContext.PF_KERNEL_CHANNEL = "Kernel";;
        return {
            exports: clientkernelLoader,
            activator: clientkernelLoader.Activator
        };
    });
//# sourceURL=loader.js