/******************************* ImportJS Version 3.0.2 A basic package-structuring import system for JavaScript Objects. The MIT License (MIT) Copyright (c) 2015 Greg McLeod Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. It is requested that you maintain all or part of this copyright notice even in the minified version. *******************************/ var ImportJS=function(){var e=[],t=function(e,t,n){this.id=e,this.instance=t,this.src=n,this.compiled=!1,this.completed=!1};t.prototype.id=null,t.prototype.instance=null,t.prototype.src=null,t.prototype.cache=null,t.prototype.context=null,t.prototype.injector=null,t.prototype.compiled=!1,t.prototype.completed=!1;var n=function(e){this.pkg=e};n.prototype.pkg=null,n.prototype["import"]=function(e){return this.pkg.instance.unpack.call(this.pkg.instance,e)},n.prototype.plugin=function(e){return this.pkg.instance.plugin.call(this.pkg.instance,e)},n.prototype.inject=function(e){"function"==typeof e&&(this.pkg.injector=e)};var r=function(e){e=e||{},this._settings={debug:e.debug||!1},this._map={packages:{},plugins:{}},this._dependencies={packages:[],plugins:[]},this._main=null,this._packBuffer=[]};r.prototype._settings=null,r.prototype._map=null,r.prototype._dependencies=null,r.prototype._main=null,r.prototype._packBuffer=null;var i=function(e,t){var n,r=/this.import\(['"](.*?)['"]\)/g,i=/this.plugin\(['"](.*?)['"]\)/g,a=t.match(r)||[],o=t.match(i)||[],p=null;for(n=0;n0;)i(this._packBuffer[0].instance,this._packBuffer[0].src.toString()),this._packBuffer.splice(0,1)},r.prototype._debug=function(){this._settings.debug&&console.log("[ImportJS]",arguments)},r.prototype.pack=function(n,r){var i=e[0]||this;i._map.packages[n]||(i._dependencies.packages.push(n),i._map.packages[n]=new t(n,i,r),i._packBuffer.push(i._map.packages[n]))},r.prototype.hasPackage=function(e,t){return t=t===!0?!0:!1,(t?this._map.packages[e]:"undefined"!=typeof this._map.packages[e])?!0:!1},r.prototype.unpack=function(e){var t=this._map.packages[e];if(t){if(t.cache){if(t.compiled)return t.cache.exports;throw new Error("Error, package "+e+" has not yet been compiled.")}var r=new n(t);return t.cache=t.cache||{exports:{}},t.src.call(r,t.cache,t.cache.exports),t.compiled=!0,t.context=r,t.cache.exports}throw new Error("Error, package "+e+" does not exist.")},r.prototype.plugin=function(e){if(this._map.plugins[e])return this._map.plugins[e].unpack(e);throw new Error("ImportJS Error: Plugin "+e+" does not exist.")},r.prototype.compile=function(){var e,t;for(e=0;e1?(i._main=r,"new"===t[1]?i._main=new r:(i._main=r,r[t[1]]())):i._main=r}"function"==typeof n.ready&&n.ready(s)}else"function"==typeof n.error&&n.error(l)};0===d&&m(!0);var _=function(){for(;n.plugins.length>0;)"undefined"==typeof i._map.plugins[n.plugins[0]]&&i._dependencies.plugins.push(n.plugins[0]),n.plugins.splice(0,1);for(var e=g;e=i._dependencies.plugins.length?(m(!0),i._debug("Plugin batch load completed.")):o()};return function(e){n(e)}},a=function(t){var n=function(){i._debug("Error loading plugin: "+t),u.push(t),e.shift(),m(!1),i._debug("Plugin batch load failed.")};return function(e){n(e)}},o=function(){var o=i._dependencies.plugins[c.length];i._debug("Preparing to load plugin "+n.baseUrl+"/plugins/"+o),e.unshift(new r(i._settings)),i._map.plugins[o]=e[0],e[0].preload({baseUrl:n.baseUrl+"/plugins/"+o,removeTags:n.removeTags,strict:!1,timeout:n.timeout,autoCompile:!0,packages:[o+".js"],ready:t(o),error:a(o)})};o()},y=function(e,t){var r,a,o,p=!1,c=i.hasPackage(t,!0);c?i._debug("Already loaded dependency: ",e,t):i._debug("Now loading dependency: ",e,t);var u=function(){if(!c&&o&&clearTimeout(o),a&&n.removeTags&&r.removeChild(a),p=!0,t&&n.strict&&!i.hasPackage(t))throw new Error("ImportJS Error: Invalid or missing package definition for "+t+" (using strict)");if(s.push(e),d--,n.parse&&i._flushPackBuffer(),_(),0===d)if(i._debug("Finished loading self dependencies"),i._dependencies.plugins.length<=0)i._debug("No plugins specified."),m(!0),i._debug("Preload job complete");else{if(c)return;k()}},g=function(){a&&n.removeTags&&r.removeChild(a),l.push(e),d--,clearTimeout(o),0===d&&(m(!1),i._debug("Error: Could not preload the following files: ["+l.join(", ")+"]"))};if(n.require){try{"/"!==e.charAt(0)&&"."!==e.charAt(0)&&(e="./"+e);{c?null:n.require(e)}if(i._debug("Successfully required source file: "+e),t&&n.strict&&!i.hasPackage(t))throw new Error("ImportJS Error: Invalid or missing package definition for "+t+" (using strict)")}catch(h){return i._debug(h.stack),i._debug("Error requiring source file: "+e),void g()}u()}else c?u():(r=document.getElementsByTagName("head")[0],a=document.createElement("script"),o=null,a.type="text/javascript",o=setTimeout(function(){i._debug("Error: Timed out on file: "+e),g()},n.timeout),a.onreadystatechange=function(){p||a.readyState&&"complete"!==this.readyState&&"loaded"!==this.readyState||u()},a.onload=u,a.onerror=g,a.src=e,r.appendChild(a))},b=function(){for(var e=0;e0){var v,w,E=0,j=function(e,t,r){i._debug("Loading library: "+e),i.preload({baseUrl:n.baseUrl,removeTags:n.removeTags,strict:!1,timeout:n.timeout,autoCompile:!1,packages:[e],ready:t,error:r,parse:!1})};v=function(e){i._debug("Finished loading library: "+e[0]),s.push(e[0]),d--,E