text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["blendr-loader"]=t():e["blendr-loader"]=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o=n(1),s=r(o);window.BlendrLoader=s.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function e(t,n,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,n,r)}if("value"in o)return o.value;var a=o.get;if(void 0!==a)return a.call(r)},c=n(2),l=r(c),f=n(3),p=r(f),d=n(6),h=r(d),v=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default;o(this,t);var r=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n));return r.serverUrl=e,r.path="assets/",r.loaders=[],r}return a(t,e),i(t,[{key:"init",value:function(){var e,n,r=this,o=new Promise(function(t,r){e=t,n=r}),s=this.serverUrl+"manifest.json";return u(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"load",this).call(this,{type:"json",src:s}).then(function(){r.manifest=r.cache.get(s),e()}),o}},{key:"registerLoader",value:function(e,t){this.loaders[e]=t}},{key:"load",value:function(e,n){var r=this,o=void 0,s=void 0,a=new Promise(function(e,t){o=e,s=t});Array.isArray(e)||(e=[e]);for(var i=function t(n){var o=r.manifest.packs[n];if(o.dependencies)for(var s=0;s<o.dependencies.length;s++){var a=o.dependencies[s];e.indexOf(a)<0&&(e.unshift(a),t(a))}if(o.includes)for(var i=0;i<o.includes.length;i++){var u=o.includes[i];e.indexOf(u)<0&&(e.push(u),t(u))}},c=0;c<e.length;c++){var l=e[c];i(l)}for(var f={},p={},d=0;d<e.length;d++){var v=e[d],y=this.manifest.packs[v];this.loaders[y.type]||console.warn("unknown pack type: "+y.type),f[v]=[],p[v]=[];var g=new h.default(y,this.loaders[y.type],v);if(p[v].push(g),y.files)for(var x in y.files){var m=y.files[x],b=""+this.serverUrl+m;g.addFile(x,b),f[v].push({src:b,type:this.manifest.files[m].type})}}var k=0,w=function s(){k<e.length?!function(){var o=e[k++],a=f[o];u(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"load",r).call(r,a,function(e,t,s,i){for(var u=p[o],c=0;c<u.length;c++){var l=u[c];l.update(a),l.isComplete()&&l.onComplete(a,r,o)}n&&n(e,t,s,i)}).then(function(){s()})}():o()};return w(),a}},{key:"unload",value:function(e){for(var t in this.loaders){var n=this.loaders[t];n.unload(e,this.cache)}}},{key:"_extractPacks",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,o=this.manifest.pack[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){var s=r.value,a=this._getPending(this.serverUrl+("assets/pack/"+s+".json")).response,i=this._getPending(this.serverUrl+("assets/pack/"+s+".pack")).response,u=new Unpacker(i,a);this.packs[s]=u}}catch(e){t=!0,n=e}finally{try{!e&&o.return&&o.return()}finally{if(t)throw n}}}},{key:"_extractAudiosprites",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,o=this.manifest.audiosprite[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){var s=r.value,a=this._getPending(this.serverUrl+("assets/audiosprite/"+s+".json")).response;this.audiosprites[s]={urls:["assets/audiosprite/"+s+".ogg","assets/audiosprite/"+s+".mp3"],sprite:a.sprite}}}catch(e){t=!0,n=e}finally{try{!e&&o.return&&o.return()}finally{if(t)throw n}}}},{key:"getPack",value:function(e){return this.packs[e]}},{key:"getAudiosprite",value:function(e){return this.audiosprites[e]}}]),t}(p.default);t.default=v},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){n(this,e),this.cache=[]}return r(e,[{key:"get",value:function(e){return this.cache[e]}},{key:"set",value:function(e,t){return this.cache[e]=t,t}},{key:"remove",value:function(e){var t=this.cache[e];return delete this.cache[e],t}},{key:"clear",value:function(){this.cache=[]}}]),e}();t.default=o},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(2),i=(r(a),n(4)),u=r(i),c=n(5),l=r(c),f=function(){function e(t){o(this,e),this.maxConcurrents=4,this.cache=t,window.Worker?this.worker=new Worker(window.URL.createObjectURL(new Blob([u.default]))):this.worker=new l.default(window.URL.createObjectURL(new Blob([u.default]))),this.worker.postMessage({proxy:"max",data:this.maxConcurrents}),this.pendings=[]}return s(e,[{key:"load",value:function(e,t){var n=this;Array.isArray(e)||(e=[e]),this.worker.postMessage({proxy:"abort"}),this.complete=!1,this.initComplete=!1,this.pendings=[],this.onUpdate=t;var r=new Promise(function(e,t){n.promiseResolve=e,n.promiseReject=t});this.worker.onmessage=function(e){var t=e.data,r=n._getPending(t.data.src);switch(t.proxy){case"filesize":r.total=t.data.total,n._update();break;case"onprogress":r.loaded=t.data.loaded,n._update();break;case"oncomplete":r.loaded=r.total,r.response=t.data.response,r.complete=!0,n.cache&&n.cache.set(r.src,r.response),n._update(!0)}},this.worker.onerror=function(e){console.log(e)},this.initComplete=!0;for(var o=0;o<e.length;o++)this._requestFile(e[o]);return this._update(!0),r}},{key:"_requestFile",value:function(e){var t=this;if(!this._getPending(e.src)){var n={src:e.src,loaded:0,total:e.size?e.size:0};if(e.pending=n,this.pendings.push(n),this.cache){var r=this.cache.get(e.src);if(r)return n.loaded=n.total,n.complete=!0,void(n.response=r)}"image"==e.type?!function(){var r=new Image;r.onload=function(){n.loaded=n.total,n.response=r,n.complete=!0,t.cache.set(e.src,r),t._update(!0)},r.src=e.src}():"manual"==e.type||this.worker.postMessage({proxy:"load",data:{src:e.src,type:e.type}})}}},{key:"_getPending",value:function(e){for(var t=0;t<this.pendings.length;t++){var n=this.pendings[t];if(n.src==e)return n}return null}},{key:"_forceLoaded",value:function(e,t){for(var n=0;n<this.pendings.length;n++){var r=this.pendings[n];if(r.src==e){r.loaded=r.total,r.response=t,r.complete=!0,this.cache&&t&&this.cache.set(r.src,r.response),this._update(!0);break}}}},{key:"_update",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=0,n=0,r=0,o=0,s=0;s<this.pendings.length;s++){var a=this.pendings[s];(a.total>0||a.complete)&&(t+=a.loaded,n+=a.total,o++,a.loaded>=a.total&&r++)}this.onUpdate&&this.initComplete&&!this.complete&&o==this.pendings.length&&this.onUpdate(r,this.pendings.length,t,n),r==this.pendings.length&&e&&!this.complete&&(this.complete=!0,this.promiseResolve())}}]),e}();t.default=f},function(e,t){e.exports="\"use strict\";\n\nvar maxConcurrents = 1;\n\nself.onmessage = function (e) {\n\tswitch (e.data.proxy) {\n\t\tcase \"load\":\n\t\t\tpending.push(e.data.data);\n\t\t\tcheckPendingRequests();\n\t\t\tbreak;\n\t\tcase \"abort\":\n\t\t\tonAbort(e.data);\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tmaxConcurrents = e.data.data;\n\t}\n};\n\nfunction checkPendingRequests() {\n\twhile (xhrs.length < maxConcurrents && pending.length > 0) {\n\t\tvar data = pending.shift();\n\n\t\tnew XHRRequest(data, onComplete);\n\t}\n}\n\nvar xhrs = [];\nvar pending = [];\n\nfunction onComplete(xhr, response) {\n\tfor (var i = 0, l = xhrs.length; i < l; i++) {\n\t\tif (xhrs[i].src == xhr.url) {\n\t\t\txhrs.splice(i, 1);\n\t\t\tvar message = JSON.parse(JSON.stringify({ proxy: \"oncomplete\", data: { src: xhr.url } }));\n\t\t\tmessage.data.response = response;\n\t\t\tself.postMessage(message);\n\n\t\t\tcheckPendingRequests();\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction onAbort(event) {\n\tvar i = xhrs.length;\n\twhile (i--) {\n\t\tif (!event.file || xhrs[i].src == event.file.src) {\n\t\t\txhrs[i].xhr.abort();\n\t\t\txhrs.splice(i, 1);\n\t\t}\n\t}\n\n\tpending = [];\n}\n\nfunction XHRRequest(data, callback) {\n\t/*\n  //x = new(XMLHttpRequest)();// || ActiveXObject)('MSXML2.XMLHTTP.3.0');\n  var x = new XMLHttpRequest();\n  x.open('GET', data.src, 1);\n  x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n  x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n  x.onreadystatechange = function () {\n  console.log(this.readyState);\n  //x.readyState > 3 && callback && callback(x.responseText, x);\n  };\n  x.send(null);\n  */\n\tvar url = data.src;\n\tthis.url = url;\n\n\tvar xhr = void 0;\n\ttry {\n\t\txhr = new XDomainRequest();\n\t} catch (e) {\n\t\txhr = new XMLHttpRequest();\n\t}\n\n\txhrs.push({ src: data.src, xhr: xhr });\n\n\tvar clean = function clean() {\n\t\txhr.onload = null;\n\t\txhr.onabort = null;\n\t\txhr.onprogress = null;\n\t\tcallback = null;\n\t\txhr = null;\n\t};\n\n\txhr.open(\"GET\", data.src, true);\n\n\t// check if supports json\n\tvar supportsJson = true;\n\tif (data.type && data.type.toLowerCase() == 'json') {\n\t\txhr.responseType = 'json';\n\t\tsupportsJson = 'response' in xhr && xhr.responseType == 'json';\n\t}\n\n\txhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n\txhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n\txhr.onprogress = function (event) {\n\t\tvar obj = JSON.parse(JSON.stringify({ proxy: \"onprogress\", data: { loaded: event.loaded, total: event.total, src: event.target.url } }));\n\t\tself.postMessage(obj);\n\t};\n\txhr.onload = function () {\n\t\tif (xhr.readyState < 4 || xhr.status !== 200) {\n\t\t\tclean();\n\t\t\treturn;\n\t\t}\n\t\tif (xhr.readyState === 4 && callback) {\n\t\t\tvar response = xhr.response;\n\n\t\t\t// type json but not supported\n\t\t\tif (!supportsJson) {\n\t\t\t\tresponse = JSON.parse(xhr.responseText);\n\t\t\t}\n\n\t\t\tcallback(xhr, response);\n\t\t\tclean();\n\t\t}\n\t};\n\txhr.onabort = function () {\n\t\tclean();\n\t};\n\txhr.url = url;\n\n\t// handle filesize\n\txhr.onreadystatechange = function () {\n\t\tif (this.readyState == 2) {\n\t\t\tvar filesize = parseInt(xhr.getResponseHeader(\"Content-Length\"));\n\n\t\t\tvar obj = JSON.parse(JSON.stringify({ proxy: \"filesize\", data: { loaded: 0, total: filesize, src: url } }));\n\t\t\tself.postMessage(obj);\n\t\t}\n\t};\n\n\txhr.responseType = data.type || 'text';\n\txhr.send(null);\n}"},function(module,exports){(function(global){"use strict";function doEval(self,__pseudoworker_script){(function(){eval(__pseudoworker_script)}).call(global)}function PseudoWorker(e){function t(e,t){for(var n=-1;++n<e.length;)e[n]&&t(e[n])}function n(e){return function(t){t({type:"error",error:e,message:e.message})}}function r(e,t){"message"===e?d.push(t):"error"===e&&h.push(t)}function o(e,t){var n;if("message"===e)n=d;else{if("error"!==e)return;n=h}for(var r=-1;++r<n.length;){var o=n[r];if(o===t){delete n[r];break}}}function s(e){var r=n(e);"function"==typeof m.onerror&&r(m.onerror),p&&"function"==typeof p.onerror&&r(p.onerror),t(h,r),t(y,r)}function a(e){function n(t){try{t({data:e})}catch(e){s(e)}}p&&"function"==typeof p.onmessage&&n(p.onmessage),t(v,n)}function i(e){if("undefined"==typeof e)throw new Error("postMessage() requires an argument");if(!x)return f?void a(e):void g.push(e)}function u(){x=!0}function c(e){function n(t){t({data:e})}"function"==typeof m.onmessage&&n(m.onmessage),t(d,n)}function l(e,t){"message"===e?v.push(t):"error"===e&&y.push(t)}var f,p,d=[],h=[],v=[],y=[],g=[],x=!1,m=this,b=new XMLHttpRequest;return b.open("GET",e),b.onreadystatechange=function(){if(4===b.readyState)if(b.status>=200&&b.status<400){f=b.responseText,p={postMessage:c,addEventListener:l},doEval(p,f);var t=g;g=[];for(var n=0;n<t.length;n++)a(t[n])}else s(new Error("cannot find script "+e))},b.send(),m.postMessage=i,m.addEventListener=r,m.removeEventListener=o,m.terminate=u,m}module.exports=PseudoWorker}).call(exports,function(){return this}())},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(t,r){n(this,e),this.type=t,this.loader=r,this.files={}}return r(e,[{key:"unload",value:function(){}},{key:"update",value:function(e){if(!this.end){var t=!0;for(var n in this.files)for(var r=0;r<e.length;r++)n==e[r].src&&(e[r].pending.complete||(t=!1));this.complete=t}}},{key:"addFile",value:function(e,t){this.files[t]=e}},{key:"onComplete",value:function(e,t,n){if(this.loader&&!this.end){this.end=!0;for(var r={},o=0;o<e.length;o++){var s=e[o];this.files[s.src]&&(r[this.files[s.src]]=e[o].pending.response)}this.loader.unpack?this.loader.unpack(n,r,t.cache,t.manifest,t):this.loader.onComplete(r,t,n)}}},{key:"isComplete",value:function(){return this.complete}}]),e}();t.default=o}])});
  //# sourceMappingURL=blendr-loader.min.js.map
  