define("clientKernelLogger", ["clientkernelLoaderApi", "clientkernelEventbusApi", "clientkernelModulesApi", "clientkernelLoggerApi"],
    function(clientkernelLoaderApi, clientkernelEventbusApi, clientkernelModulesApi, clientkernelLoggerApi) {
        "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 clientKernelLogger == 'undefined') {
            var clientKernelLogger = {};
        };
        clientKernelLogger.Activator = function() {};
        clientKernelLogger.Activator = ck_implements(clientKernelLogger.Activator, clientkernelModulesApi.IModuleActivator);
        clientKernelLogger.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        clientKernelLogger.Activator.__name__ = ["clientKernelLogger", "Activator"];
        clientKernelLogger.Activator.prototype.start = function(context) {
            var logserver = false;
            var loguser = "";
            if (window != null) {
                logserver = (function($this) {
                    var $r;
                    var this1 = $this.getParams();
                    $r = this1.get("kernel");
                    return $r;
                }(this)) != null && ((function($this) {
                    var $r;
                    var this2 = $this.getParams();
                    $r = this2.get("kernel");
                    return $r;
                }(this))).indexOf("l") != -1;
                if (logserver) {
                    var this3 = this.getParams();
                    loguser = this3.get("loguser");
                    if (loguser == null) loguser = "ND";
                }
            }
            context.registerService(new clientKernelLogger.LoggerFactory(logserver, loguser, context), clientkernelLoggerApi.ILoggerFactory, null);
        };
        clientKernelLogger.Activator.prototype.stop = function(context) {};
        clientKernelLogger.Activator.prototype.getParams = function() {
            var get;
            var _this = window.location.search;
            get = _hcmn_.HxOverrides.substr(_this, 1, null);
            var params = new _hcmn_.haxe_ds_StringMap();
            var _g = 0;
            var _g1 = new _hcmn_.EReg("[&;]", "g").split(get);
            while (_g < _g1.length) {
                var p = _g1[_g];
                ++_g;
                var pl = p.split("=");
                if (pl.length < 2) continue;
                var name = pl.shift();
                params.set(decodeURIComponent(name.split("+").join(" ")), _hcmn_.StringTools.urlDecode(pl.join("=")));
            }
            return params;
        };
        clientKernelLogger.Activator.main = function() {};
        clientKernelLogger.Activator.prototype.__class__ = clientKernelLogger.Activator;
        clientKernelLogger.Logger = function(modulename, logserver, loguser, context) {
            this.logurl = null;
            var _g = this;
            this.logserver = logserver;
            this.modulename = modulename;
            this.loguser = loguser;
            if (logserver) context.getServiceTracker([clientkernelLoaderApi.IAssetRegistry]).then(function(context1) {
                _g.assetRegistry = context1.getAnyService(clientkernelLoaderApi.IAssetRegistry);
                _g.updateUrl();
            });
        };
        clientKernelLogger.Logger = ck_implements(clientKernelLogger.Logger, clientkernelLoggerApi.ILogger);
        clientKernelLogger.Logger.__interfaces__ = [clientkernelLoggerApi.ILogger];
        clientKernelLogger.Logger.__name__ = ["clientKernelLogger", "Logger"];
        clientKernelLogger.Logger.prototype.modulename = null;
        clientKernelLogger.Logger.prototype.logserver = null;
        clientKernelLogger.Logger.prototype.logurl = null;
        clientKernelLogger.Logger.prototype.loguser = null;
        clientKernelLogger.Logger.prototype.assetRegistry = null;
        clientKernelLogger.Logger.prototype.updateUrl = function() {
            var _g = this;
            if (this.assetRegistry.getAsset("logger-impl") == null) {
                _hcmn_.haxe_Timer.delay($bind(this, this.updateUrl), 100);
                return;
            }
            this.assetRegistry.getAsset("logger-impl").getContent().then(function(data) {
                _g.logurl = _hcmn_.Reflect.field(data, "loggerUrl");
            });
        };
        clientKernelLogger.Logger.prototype.debug = function(message) {
            if (this.logserver) this.log("debug", message);
            else if (typeof(console.debug) == 'function') window.console.debug("[" + this.modulename + "] " + _hcmn_.Std.string(message));
            else window.console.log("[" + this.modulename + "] " + _hcmn_.Std.string(message));
        };
        clientKernelLogger.Logger.prototype.error = function(message) {
            if (this.logserver) this.log("error", message);
            else window.console.error("[" + this.modulename + "] " + _hcmn_.Std.string(message));
        };
        clientKernelLogger.Logger.prototype.info = function(message) {
            if (this.logserver) this.log("info", message);
            else window.console.info("[" + this.modulename + "] " + _hcmn_.Std.string(message));
        };
        clientKernelLogger.Logger.prototype.trace = function(message) {
            if (this.logserver) this.log("trace", message);
            else window.console.trace();
        };
        clientKernelLogger.Logger.prototype.warn = function(message) {
            if (this.logserver) this.log("warn", message);
            else window.console.warn("[" + this.modulename + "] " + _hcmn_.Std.string(message));
        };
        clientKernelLogger.Logger.prototype.log = function(level, message) {
            if (this.logurl != null) {
                var loader = new XMLHttpRequest();
                loader.open("GET", this.logurl + ("?level=" + level + "&module=" + this.modulename + "&message=" + message + "&user=" + this.loguser));
                loader.send();
            }
        };
        clientKernelLogger.Logger.prototype.__class__ = clientKernelLogger.Logger;
        clientKernelLogger.LoggerFactory = function(logserver, loguser, context) {
            this.context = context;
            this.logserver = logserver;
            this.loguser = loguser;
        };
        clientKernelLogger.LoggerFactory = ck_implements(clientKernelLogger.LoggerFactory, clientkernelModulesApi.IService);
        clientKernelLogger.LoggerFactory = ck_implements(clientKernelLogger.LoggerFactory, clientkernelLoggerApi.ILoggerFactory);
        clientKernelLogger.LoggerFactory.__interfaces__ = [clientkernelModulesApi.IService, clientkernelLoggerApi.ILoggerFactory];
        clientKernelLogger.LoggerFactory.__name__ = ["clientKernelLogger", "LoggerFactory"];
        clientKernelLogger.LoggerFactory.prototype.context = null;
        clientKernelLogger.LoggerFactory.prototype.logserver = null;
        clientKernelLogger.LoggerFactory.prototype.loguser = null;
        clientKernelLogger.LoggerFactory.prototype.getDefaultLogger = function() {
            return new clientKernelLogger.Logger(null, this.logserver, this.loguser, this.context);
        };
        clientKernelLogger.LoggerFactory.prototype.getLogger = function(modulename) {
            if (modulename != null && modulename != "") return new clientKernelLogger.Logger(modulename, this.logserver, this.loguser, this.context);
            return null;
        };
        clientKernelLogger.LoggerFactory.prototype.__class__ = clientKernelLogger.LoggerFactory;
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

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

            get: function(k) {
                return {
                    arguments: ["*"],
                    returns: "null"
                };
            }
        };
        return {
            exports: clientKernelLogger,
            activator: clientKernelLogger.Activator
        };
    });