define("soundManagerLoader", ["cri", "clientkernelLoaderApi", "clientkernelLoaderApiPlugins", "howler", "clientkernelEventbusApi", "clientkernelModulesApi"],
    function(cri, clientkernelLoaderApi, clientkernelLoaderApiPlugins, howler, 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 haxe == 'undefined') {
            var haxe = {};
        };

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

        };
        if (typeof soundManagerLoader == 'undefined') {
            var soundManagerLoader = {};
        };
        soundManagerLoader.Activator = function(context) {};
        soundManagerLoader.Activator = ck_implements(soundManagerLoader.Activator, clientkernelModulesApi.IModuleActivator);
        soundManagerLoader.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        soundManagerLoader.Activator.__name__ = ["soundManagerLoader", "Activator"];
        soundManagerLoader.Activator.prototype.start = function(context) {
            context.registerService(new soundManagerLoader.SoundLoaderPlugin(), clientkernelLoaderApiPlugins.IAssetPlugin, null);
            context.registerService(new soundManagerLoader.SoundPackLoaderPlugin(), clientkernelLoaderApiPlugins.IAssetPlugin, null);
            context.registerService(new soundManagerLoader.CriwareSoundPlugin(), clientkernelLoaderApiPlugins.IAssetPlugin, null);
        };
        soundManagerLoader.Activator.prototype.stop = function(context) {};
        soundManagerLoader.Activator.main = function() {};
        soundManagerLoader.Activator.prototype.__class__ = soundManagerLoader.Activator;
        soundManagerLoader.CriwareSoundLoader = function() {
            this._acbFile = null;
            this.acbFiles = new _hcmn_.haxe_ds_StringMap();
        };
        soundManagerLoader.CriwareSoundLoader = ck_implements(soundManagerLoader.CriwareSoundLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        soundManagerLoader.CriwareSoundLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        soundManagerLoader.CriwareSoundLoader.__name__ = ["soundManagerLoader", "CriwareSoundLoader"];
        soundManagerLoader.CriwareSoundLoader.prototype.lc = null;
        soundManagerLoader.CriwareSoundLoader.prototype.id = null;
        soundManagerLoader.CriwareSoundLoader.prototype.onfinish = null;
        soundManagerLoader.CriwareSoundLoader.prototype.url = null;
        soundManagerLoader.CriwareSoundLoader.prototype.asset = null;
        soundManagerLoader.CriwareSoundLoader.prototype.config = null;
        soundManagerLoader.CriwareSoundLoader.prototype.acbFiles = null;
        soundManagerLoader.CriwareSoundLoader.prototype._acbFile = null;
        soundManagerLoader.CriwareSoundLoader.prototype.progressCheckTimer = null;
        soundManagerLoader.CriwareSoundLoader.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, 0);
        };
        soundManagerLoader.CriwareSoundLoader.prototype.load = function(onfinish) {
            var _g = this;
            this.onfinish = onfinish;
            if (_hcmn_.StringTools.endsWith(this.url, ".acb")) {
                this._acbFile = cri.AtomExAcb.loadAcbFile(this.url, null, function() {
                    var fileName = _hcmn_.StringTools.replace((function($this) {
                        var $r;
                        var pos = _g.url.lastIndexOf("/") + 1;
                        $r = _hcmn_.HxOverrides.substr(_g.url, pos, null);
                        return $r;
                    }(this)), ".acb", "");
                    var v = _g._acbFile;
                    _g.acbFiles.set(fileName, v);
                    v;
                    _g.asset.setContent(_g.acbFiles);
                    onfinish();
                    if (_g.progressCheckTimer != null) {
                        _g.progressCheckTimer.stop();
                        _g.progressCheckTimer = null;
                    }
                });
                this.progressCheckTimer = new _hcmn_.haxe_Timer(3000);
                this.progressCheckTimer.run = function() {
                    _g.handleProgress(_g._acbFile.getLoadProgress());
                };
            } else cri.AtomEx.registerAcfFile(this.url, function() {
                onfinish();
            });
        };
        soundManagerLoader.CriwareSoundLoader.prototype.handleProgress = function(progress) {
            this.asset.setProgress(0, 1);
        };
        soundManagerLoader.CriwareSoundLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        soundManagerLoader.CriwareSoundLoader.prototype.__class__ = soundManagerLoader.CriwareSoundLoader;
        soundManagerLoader.CriwareSoundPlugin = function() {};
        soundManagerLoader.CriwareSoundPlugin = ck_implements(soundManagerLoader.CriwareSoundPlugin, clientkernelModulesApi.IService);
        soundManagerLoader.CriwareSoundPlugin = ck_implements(soundManagerLoader.CriwareSoundPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        soundManagerLoader.CriwareSoundPlugin.__interfaces__ = [clientkernelModulesApi.IService, clientkernelLoaderApiPlugins.IAssetPlugin];
        soundManagerLoader.CriwareSoundPlugin.__name__ = ["soundManagerLoader", "CriwareSoundPlugin"];
        soundManagerLoader.CriwareSoundPlugin.prototype.getAssetTypes = function() {
            return ["criware-sound"];
        };
        soundManagerLoader.CriwareSoundPlugin.prototype.createLoader = function() {
            return new soundManagerLoader.CriwareSoundLoader();
        };
        soundManagerLoader.CriwareSoundPlugin.prototype.__class__ = soundManagerLoader.CriwareSoundPlugin;
        soundManagerLoader.SoundLoader = function() {
            this.types = ["mp3", "ogg"];
        };
        soundManagerLoader.SoundLoader = ck_implements(soundManagerLoader.SoundLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        soundManagerLoader.SoundLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        soundManagerLoader.SoundLoader.__name__ = ["soundManagerLoader", "SoundLoader"];
        soundManagerLoader.SoundLoader.prototype.lc = null;
        soundManagerLoader.SoundLoader.prototype.id = null;
        soundManagerLoader.SoundLoader.prototype.onfinish = null;
        soundManagerLoader.SoundLoader.prototype.url = null;
        soundManagerLoader.SoundLoader.prototype.asset = null;
        soundManagerLoader.SoundLoader.prototype.types = null;
        soundManagerLoader.SoundLoader.prototype.howl = null;
        soundManagerLoader.SoundLoader.prototype.progressCheckTimer = null;
        soundManagerLoader.SoundLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.url = url;
            this.lc = lc;
            this.id = id;
            lc.getAssets().add("soundmaps", url, "pack", null);
            this.asset = lc.getAssets().add(id, url, type, onrequest, 0);
            if (config != null) {
                if (Object.prototype.hasOwnProperty.call(config, "types")) this.types = _hcmn_.Reflect.field(config, "types");
            }
        };
        soundManagerLoader.SoundLoader.prototype.load = function(onfinish) {
            var _g = this;
            this.onfinish = onfinish;
            if (!this.checkIsIE()) this.lc.getLoader().addQueue("soundmaps", [{
                id: "soundmap",
                type: "preload-asset",
                url: this.url.substring(this.url.lastIndexOf("/") + 1) + ".soundmap.json"
            }], this.url.substring(0, this.url.lastIndexOf("/")), $bind(this, this.finishedMap));
            else _hcmn_.haxe_Timer.delay(function() {
                _g.howlCreateIE();
            }, 100);
        };
        soundManagerLoader.SoundLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        soundManagerLoader.SoundLoader.prototype.finishedMap = function() {
            var _g = this;
            this.lc.getAssets().getAsset("soundmap").getContent().then(function(map) {
                var urls = [];
                var _g1 = 0;
                var _g2 = _g.types;
                while (_g1 < _g2.length) {
                    var t = _g2[_g1];
                    ++_g1;
                    urls.push(_g.url + "." + t);
                }
                _g.howl = new howler.Howl({
                    src: urls,
                    sprite: map,
                    onload: $bind(_g, _g.handleComplete)
                });
                _g.progressCheckTimer = new _hcmn_.haxe_Timer(3000);
                _g.progressCheckTimer.run = function() {
                    _g.handleProgress();
                };
            });
        };
        soundManagerLoader.SoundLoader.prototype.handleProgress = function() {
            this.asset.setProgress(0, 1);
        };
        soundManagerLoader.SoundLoader.prototype.howlCreateIE = function() {
            var _g = this;
            var urls = [];
            var _g1 = 0;
            var _g11 = this.types;
            while (_g1 < _g11.length) {
                var t = _g11[_g1];
                ++_g1;
                urls.push(this.url + "." + t);
            }
            this.howl = new howler.Howl({
                src: urls,
                onload: $bind(this, this.handleComplete)
            });
            this.progressCheckTimer = new _hcmn_.haxe_Timer(3000);
            this.progressCheckTimer.run = function() {
                _g.handleProgress();
            };
            this.handleError();
        };
        soundManagerLoader.SoundLoader.prototype.handleComplete = function() {
            this.asset.setContent(this.howl);
            if (this.onfinish != null) this.onfinish();
            if (this.progressCheckTimer != null) {
                this.progressCheckTimer.stop();
                this.progressCheckTimer = null;
            }
        };
        soundManagerLoader.SoundLoader.prototype.checkIsIE = function() {
            return this.lc.getVars().get("browserIE") == "true";
        };
        soundManagerLoader.SoundLoader.prototype.handleError = function() {
            var _g = this;
            var audio;
            var _this = window.document;
            audio = _this.createElement("audio");
            audio.src = "data:audio/mp3;base64,//uQBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAAEewDb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb//////////////////////////////////////////////////////////////////8AAAA8TEFNRTMuOTlyBK8AAAAAAAAAADUgJAUORQABzAAABHvOhMioAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//uwBAABEKwATngAAAodIAl9AAABBZgvM+ekA6jEBeZ89IR1ElVohmCOAAAAHiI+DmWjB+b/9wiPwBuSNDYAADgBYMCco5b1h8u/DMuUc7///////6zTw7u0PLtv+CRCZI8goEpCp5C1cVkSaFksCJKsiyKjQWE2aKteFk//Nm3iiNGvTw8RDs//9JEJkScFKBKQabQ6qysiTFLADCllZE+BYVFhJSZpwqFCSkjjZssWCQ2bagAAAOP///////////+uTEFNRTMuOTkuM6qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xAE3o/wAAB/gAAACA3AGRMAAAEAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==";
            try {
                audio.play();
                audio.onerror = function(err) {
                    if (audio.error != null) _g.handleComplete();
                };
            } catch (err1) {
                this.handleComplete();
            }
        };
        soundManagerLoader.SoundLoader.prototype.__class__ = soundManagerLoader.SoundLoader;
        soundManagerLoader.SoundLoaderPlugin = function() {};
        soundManagerLoader.SoundLoaderPlugin = ck_implements(soundManagerLoader.SoundLoaderPlugin, clientkernelModulesApi.IService);
        soundManagerLoader.SoundLoaderPlugin = ck_implements(soundManagerLoader.SoundLoaderPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        soundManagerLoader.SoundLoaderPlugin.__interfaces__ = [clientkernelModulesApi.IService, clientkernelLoaderApiPlugins.IAssetPlugin];
        soundManagerLoader.SoundLoaderPlugin.__name__ = ["soundManagerLoader", "SoundLoaderPlugin"];
        soundManagerLoader.SoundLoaderPlugin.prototype.getAssetTypes = function() {
            return ["sound"];
        };
        soundManagerLoader.SoundLoaderPlugin.prototype.createLoader = function() {
            return new soundManagerLoader.SoundLoader();
        };
        soundManagerLoader.SoundLoaderPlugin.prototype.__class__ = soundManagerLoader.SoundLoaderPlugin;
        soundManagerLoader.SoundPackLoader = function() {};
        soundManagerLoader.SoundPackLoader = ck_implements(soundManagerLoader.SoundPackLoader, clientkernelLoaderApiPlugins.IAssetLoader);
        soundManagerLoader.SoundPackLoader.__interfaces__ = [clientkernelLoaderApiPlugins.IAssetLoader];
        soundManagerLoader.SoundPackLoader.__name__ = ["soundManagerLoader", "SoundPackLoader"];
        soundManagerLoader.SoundPackLoader.prototype.lc = null;
        soundManagerLoader.SoundPackLoader.prototype.id = null;
        soundManagerLoader.SoundPackLoader.prototype.url = null;
        soundManagerLoader.SoundPackLoader.prototype.config = null;
        soundManagerLoader.SoundPackLoader.prototype.onfinish = null;
        soundManagerLoader.SoundPackLoader.prototype.asset = null;
        soundManagerLoader.SoundPackLoader.prototype.soundMap = null;
        soundManagerLoader.SoundPackLoader.prototype.setup = function(lc, id, type, url, config, onrequest) {
            this.lc = lc;
            this.id = id;
            this.url = url;
            this.config = config;
            this.soundMap = new _hcmn_.haxe_ds_StringMap();
            this.asset = lc.getAssets().add(id, url, type, onrequest, 0);
            this.addSounds();
        };
        soundManagerLoader.SoundPackLoader.prototype.addSounds = function() {
            var _g = this;
            if (!this.config.loader.length) this.complete();
            else this.lc.getAssets().getAsset(this.config.loader[0].id).getContent().then(function(sound) {
                _g.soundMap.set(_g.config.loader[0].id, sound);
                _g.config.loader.shift();
                _g.addSounds();
            });
        };
        soundManagerLoader.SoundPackLoader.prototype.load = function(onfinish) {
            this.onfinish = onfinish;
            this.lc.getLoader().addQueue(this.id, this.config.loader, this.url, $bind(this, this.onFinished));
        };
        soundManagerLoader.SoundPackLoader.prototype.unload = function() {
            this.lc.getAssets().remove(this.id);
        };
        soundManagerLoader.SoundPackLoader.prototype.onFinished = function() {
            null;
        };
        soundManagerLoader.SoundPackLoader.prototype.complete = function() {
            this.asset.setContent(this.soundMap);
            this.onfinish();
        };
        soundManagerLoader.SoundPackLoader.prototype.__class__ = soundManagerLoader.SoundPackLoader;
        soundManagerLoader.SoundPackLoaderPlugin = function() {};
        soundManagerLoader.SoundPackLoaderPlugin = ck_implements(soundManagerLoader.SoundPackLoaderPlugin, clientkernelModulesApi.IService);
        soundManagerLoader.SoundPackLoaderPlugin = ck_implements(soundManagerLoader.SoundPackLoaderPlugin, clientkernelLoaderApiPlugins.IAssetPlugin);
        soundManagerLoader.SoundPackLoaderPlugin.__interfaces__ = [clientkernelModulesApi.IService, clientkernelLoaderApiPlugins.IAssetPlugin];
        soundManagerLoader.SoundPackLoaderPlugin.__name__ = ["soundManagerLoader", "SoundPackLoaderPlugin"];
        soundManagerLoader.SoundPackLoaderPlugin.prototype.getAssetTypes = function() {
            return ["sound-pack"];
        };
        soundManagerLoader.SoundPackLoaderPlugin.prototype.createLoader = function() {
            return new soundManagerLoader.SoundPackLoader();
        };
        soundManagerLoader.SoundPackLoaderPlugin.prototype.__class__ = soundManagerLoader.SoundPackLoaderPlugin;
        soundManagerLoader.SoundLoader.PROGRESS_UPDATE_INTERVAL = 3000;;
        return {
            exports: soundManagerLoader,
            activator: soundManagerLoader.Activator
        };
    });