Function.prototype.bind = function(object) {
  var fn = this;
  return (function $boundMethod() {
    return fn.apply(object,arguments);
  });
};

(function(theGlobalObject){
  // defined here to avoid global name space pollution and unneccessary closures:
  function clone(object) {
    var empty = function(){ };
    empty.prototype =  object;
    return new empty();
  };
  function createGetQualified(create) {
    return (function(name) {
      var object = theGlobalObject;
      if (name) {
        var parts = name.split(".");
        for (var i=0; i<parts.length; ++i) {
          var subobject = object[parts[i]];
          if (!subobject) {
            if (create) {
              subobject = object[parts[i]] = {};
            } else {
              return null;
            }
          }
          object = subobject;
        }
      }
      return object;
    });
  }

  theGlobalObject.joo = {
    getOrCreatePackage: createGetQualified(true),
    getQualifiedObject: createGetQualified(false),
    classLoader: {
      prepare: function(packageDef, directives, classDef, memberFactory) {
        var classMatch = classDef.match(/^\s*((public|internal|final|dynamic)\s+)*class\s+([A-Za-z][a-zA-Z$_0-9]*)(\s+extends\s+([a-zA-Z$_0-9.]+))?(\s+implements\s+([a-zA-Z$_0-9.,\s]+))?\s*$/);
        var className = classMatch[3];
        var $extends = classMatch[5];
        var constructor;
        var publicConstructor = joo[className] = function() {
          constructor.apply(this, arguments);
        };
        var superConstructor;
        if ($extends) {
          superConstructor = joo[$extends];
          publicConstructor.prototype = clone(superConstructor.prototype);
        } else {
          superConstructor = Object;
          $extends = "Object";
        }
        publicConstructor.prototype[$extends] = superConstructor;
        var members = memberFactory(publicConstructor, {$super: $extends});
        var staticInitializer;
        for (var i = 0; i < members.length; ++i) {
          var memberDeclaration = members[i];
          switch (typeof memberDeclaration) {
            case "function": staticInitializer = memberDeclaration; break;
            case "string":
              var isStatic = memberDeclaration.match(/\bstatic\b/);
              var target = isStatic ? publicConstructor : publicConstructor.prototype;
              var member = members[++i];
              if (typeof member == "function") {
                var methodName = memberDeclaration.match(/function\s+([a-zA-Z$_0-9]+)/)[1];
                if (methodName == className) {
                  constructor = member;
                } else {
                  target[methodName] = member;
                }
              } else {
                for (var m in member) {
                  target[m] = member[m];
                }
              }
          }
        }
        if (staticInitializer) {
          staticInitializer();
        }
      },
      init: function() {
        // ignore
      }
    }
  };
})(this);// function assert(cond : Object, file : String, line : uint, column : uint) : void
joo.assert = function joo$assert(cond, file, line, column) {
  if (!cond)
    throw new Error(file+"("+line+":"+column+"): assertion failed");
};
// function trace(msg : String) : void
joo.trace = function joo$trace(msg) {
  if (window["console"]) {
    window["console"].log("AS3: "+msg);
  }
};
joo.classLoader.prepare("package joo",[""],"public class MemberDeclaration",function($jooPublic,$jooPrivate){with(joo)with($jooPublic)with($jooPrivate)return["public static const",{METHOD_TYPE_GET:"get",METHOD_TYPE_SET:"set",MEMBER_TYPE_VAR:"var",MEMBER_TYPE_CONST:"const",MEMBER_TYPE_FUNCTION:"function",NAMESPACE_PRIVATE:"private",NAMESPACE_INTERNAL:"internal",NAMESPACE_PROTECTED:"protected",NAMESPACE_PUBLIC:"public",STATIC:"static",FINAL:"final",NATIVE:"native",BOUND:"bound",OVERRIDE:"override"},"private static var",{SUPPORTS_GETTERS_SETTERS: undefined},function(){SUPPORTS_GETTERS_SETTERS="__defineGetter__"in Object.prototype;},"internal var",{_namespace:"internal",_static:false,_final:false,_native:false,_bound:false,_override:false,memberType: undefined,getterOrSetter: undefined,memberName: undefined,slot: undefined,value: undefined,_cloneFactory: undefined},"public function MemberDeclaration",function(memberDeclarationStr){this[$super]();var tokens=memberDeclarationStr.split(/\s+/);for(var j=0;j<tokens.length;++j){var token=tokens[j];if(!this.memberType){switch(token){case STATIC:case FINAL:case NATIVE:case BOUND:case OVERRIDE:this["_"+token]=true;break;case MEMBER_TYPE_VAR:case MEMBER_TYPE_CONST:case MEMBER_TYPE_FUNCTION:this.memberType=token;break;default:this._namespace=token;}}else{if(this.isMethod()&&(this.memberName==METHOD_TYPE_GET||this.memberName==METHOD_TYPE_SET)){this.getterOrSetter=this.memberName;}this.memberName=token;}}if(!this.memberType){throw new Error("Missing member type in declaration '"+memberDeclarationStr+"'.");}},"public function getQualifiedName",function(){return this._namespace+"::"+this.memberName;},"public function isPrivate",function(){return this._namespace==NAMESPACE_PRIVATE;},"public function isStatic",function(){return this._static;},"public function isFinal",function(){return this._final;},"public function isNative",function(){return this._native;},"public function isOverride",function(){return this._override;},"public function isBound",function(){return this._bound;},"public function isMethod",function(){return this.memberType==MEMBER_TYPE_FUNCTION;},"internal function setSlot",function(slot){this.slot=slot;},"internal function getSlot",function(){return this.slot||this.memberName;},"internal function getNativeMember",function(publicConstructor){var target=this.isStatic()?publicConstructor:publicConstructor.prototype;if(this.memberType==MEMBER_TYPE_FUNCTION&&this.getterOrSetter){this.memberType=MEMBER_TYPE_VAR;this.getterOrSetter=null;}var member=target[this.memberName];if(typeof member!="function"){var memberObject={};memberObject[this.memberName]=member;member=memberObject;}return member;},"internal function retrieveMember",function(target,fromSuper){var slot=this.getSlot();if(this.getterOrSetter){if(SUPPORTS_GETTERS_SETTERS){return target[this.getterOrSetter==METHOD_TYPE_GET?"__lookupGetter__":"__lookupSetter__"](slot);}else{slot=this.getterOrSetter+"$"+slot;}}return fromSuper||!target.hasOwnProperty||target.hasOwnProperty(slot)?target[slot]:undefined;},"internal function storeMember",function(target){if(!this.isNative()){var slot=this.getSlot();if(this.getterOrSetter){if(SUPPORTS_GETTERS_SETTERS){target[this.getterOrSetter==METHOD_TYPE_GET?"__defineGetter__":"__defineSetter__"](slot,this.value);return;}else{slot=this.getterOrSetter+"$"+slot;}}target[slot]=this.value;}},"public function hasInitializer",function(){return this.memberType!=MEMBER_TYPE_FUNCTION&&typeof this.value=="function"&&this.value.constructor!==RegExp;},"public function initMember",function(target){var slot=this.getSlot();if(this.isBound()){target[slot]=target[slot].bind(target);}else{target[slot]=target[slot]();}},"public function _getCloneFactory",function(){if(!this._cloneFactory){this._cloneFactory=function(){};this._cloneFactory.prototype=this;}return this._cloneFactory;},"public function clone",function(changedProperties){var CloneFactory=this._getCloneFactory();var clone=new CloneFactory();for(var m in changedProperties){clone[m]=changedProperties[m];}return clone;},"public function toString",function(){var sb=[this._namespace];if(this._static)sb.push(STATIC);if(this._override)sb.push(OVERRIDE);if(this._bound)sb.push(BOUND);sb.push(this.memberType);sb.push(this.memberName);return sb.join(" ");},];},[]);joo.classLoader.prepare("package joo",[""],"public class NativeClassDeclaration",function($jooPublic,$jooPrivate){with(joo)with($jooPublic)with($jooPrivate)return["internal static function createEmptyConstructor",function(constructor_){var emptyConstructor=function(){this.constructor=constructor_;};emptyConstructor.prototype=constructor_.prototype;return emptyConstructor;},"internal var",{level:-1,fullClassName: undefined,constructor_: undefined,publicConstructor: undefined,completed:false,inited:false,Public: undefined,superClassDeclaration: undefined,interfaces: undefined},"public function NativeClassDeclaration",function(fullClassName,publicConstructor){this[$super]();this.fullClassName=fullClassName;this.publicConstructor=publicConstructor;this.publicConstructor.$class=this;},"internal function complete",function(){if(!this.completed){this.completed=true;this.doComplete();}return this;},"internal function doComplete",function(){this.interfaces=[];this.constructor_=this.publicConstructor;this.Public=createEmptyConstructor(this.publicConstructor);},"internal function init",function(){if(!this.inited){this.inited=true;this.complete();this.doInit();}return this;},"internal function doInit",function(){},"public function isInstance",function(object){return object instanceof this.constructor_||object&&object.constructor===this.constructor_;},"public function getQualifiedName",function(){return this.fullClassName.replace(/\.([^\.]+)^/,"::");},"public function toString",function(){return this.fullClassName;},];},[]);joo.classLoader.prepare("package joo",[""],"public class SystemClassDeclaration extends NativeClassDeclaration",function($jooPublic,$jooPrivate){with(joo)with($jooPublic)with($jooPrivate)return[function(){joo.classLoader.init(MemberDeclaration);},"internal static function createDefaultConstructor",function(superName){return(function $DefaultConstructor(){this[superName].apply(this,arguments);});},"internal static function createPublicConstructor",function(cd){return function joo$SystemClassDeclaration$constructor(){this.constructor=cd.publicConstructor;cd.constructor_.apply(this,arguments);};},"private static function is_",function(object,type){if(!type||object===undefined||object===null)return false;if(type["$class"]){return(type["$class"]).isInstance(object);}return object instanceof type||object.constructor===type;},function(){joo["is"]=is_;},"internal var",{package_: undefined,isInterface:false,namespace_:"intern",className: undefined,native_:false,extends_:"Object",privateStatics: undefined,memberDeclarations: undefined,memberDeclarationsByQualifiedName: undefined,initializers: undefined,staticInitializers: undefined,boundMethods: undefined,publicStaticMethodNames: undefined},"public function SystemClassDeclaration",function(packageDef,directives,classDef,memberDeclarations,publicStaticMethodNames){var packageName=packageDef.split(/\s+/)[1]||"";this.package_=joo.getOrCreatePackage(packageName);this.parseDirectives(directives);var classMatch=classDef.match(/^\s*((public|internal|final|dynamic)\s+)*class\s+([A-Za-z][a-zA-Z$_0-9]*)(\s+extends\s+([a-zA-Z$_0-9.]+))?(\s+implements\s+([a-zA-Z$_0-9.,\s]+))?\s*$/);var interfaces;if(classMatch){if(classMatch[5]){this.extends_=classMatch[5];}interfaces=classMatch[7];}else{classMatch=classDef.match(/^\s*((public|internal)\s+)?interface\s+([A-Za-z][a-zA-Z$_0-9]*)(\s+extends\s+([a-zA-Z$_0-9.,\s]+))?\s*$/);this.isInterface=true;interfaces=classMatch[5];}if(!classMatch){throw new Error("SyntaxError: \""+classDef+"\" does not match.");}this.namespace_=classMatch[2];this.className=classMatch[3];var fullClassName=this.className;if(packageName){fullClassName=packageName+"."+this.className;}this.interfaces=interfaces?interfaces.split(/\s*,\s*/):[];this.memberDeclarations=memberDeclarations;this.publicStaticMethodNames=publicStaticMethodNames;var publicConstructor=joo.getQualifiedObject(fullClassName);if(publicConstructor){this.native_=true;}else{publicConstructor=createPublicConstructor(this);this.package_[this.className]=publicConstructor;}this[$super](fullClassName,publicConstructor);this.privateStatics={"assert":joo["assert"],"is":is_};},"internal function parseDirectives",function(directives){},"internal override function doComplete",function(){this.superClassDeclaration=joo.classLoader.getRequiredClassDeclaration(this.extends_);this.superClassDeclaration.complete();this.level=this.superClassDeclaration.level+1;this.privateStatics.$super=this.level+"super";var Super=this.superClassDeclaration.Public;if(!this.native_){this.publicConstructor.prototype=new Super();}this.Public=NativeClassDeclaration.createEmptyConstructor(this.publicConstructor);},"internal function initMembers",function(){this.initializers=[];this.staticInitializers=[];this.boundMethods=[];var memberDeclarations=this.memberDeclarations(this.publicConstructor,this.privateStatics);this.memberDeclarations=[];this.memberDeclarationsByQualifiedName={};this.constructor_=null;for(var i=0;i<memberDeclarations.length;++i){var item=memberDeclarations[i];switch(typeof item){case"undefined":continue;case"function":this.staticInitializers.push(item);break;case"string":var memberDeclaration=new MemberDeclaration(item);if(!memberDeclaration.isNative()){if(++i>=memberDeclarations.length){throw new Error(this+": Member expected after modifiers '"+item+"'.");}var member=memberDeclarations[i];}if(memberDeclaration.memberType=="function"){this.initMethod(memberDeclaration,member);}else{for(var memberName in member){this._storeMember(memberDeclaration.clone({memberName:memberName}),member[memberName]);}}}}var defaultConstructor=this.native_?this.publicConstructor:this.publicConstructor.prototype[this.level+"super"]=this.initializers.length==0&&this.boundMethods.length==0?this.superClassDeclaration.constructor_:createSuperCall(this);if(!this.constructor_){this.constructor_=defaultConstructor;}this.privateStatics[this.className]=this.publicConstructor;},"private static function createSuperCall",function(cd){if(cd.extends_=="Object"){return function $super(){initObject(this,cd.boundMethods);initObject(this,cd.initializers);};}return function $super(){initObject(this,cd.boundMethods);cd.superClassDeclaration.constructor_.apply(this,arguments);initObject(this,cd.initializers);};},"internal function initMethod",function(memberDeclaration,member){if(memberDeclaration.memberName==this.className&&!memberDeclaration.isStatic()){if(memberDeclaration.getterOrSetter){throw new Error(this+": Class name cannot be used for getter or setter: "+memberDeclaration);}this.constructor_=memberDeclaration.isNative()?this.publicConstructor:member;}else{if(memberDeclaration.isNative()){member=memberDeclaration.getNativeMember(this.publicConstructor);}if(memberDeclaration.isBound()){this.boundMethods.push(memberDeclaration);}if(this.extends_!="Object"){var superMethod=memberDeclaration.retrieveMember(this.superClassDeclaration.Public.prototype,true);}var overrides=! !superMethod&&superMethod!==Object.prototype[memberDeclaration.memberName];if(overrides!==memberDeclaration.isOverride()){var msg=overrides?"Method overrides without 'override' modifier":"Method with 'override' modifier does not override";throw new Error(this+": "+msg+": "+memberDeclaration);}if(overrides){this._storeMember(memberDeclaration.clone({_namespace:MemberDeclaration.NAMESPACE_PRIVATE}),superMethod);}this._storeMember(memberDeclaration,member);}},"internal function _storeMember",function(memberDeclaration,value){this.memberDeclarations.push(memberDeclaration);this.memberDeclarationsByQualifiedName[memberDeclaration.getQualifiedName()]=memberDeclaration;memberDeclaration.value=value;var _static=memberDeclaration.isStatic();var _private=memberDeclaration.isPrivate();if(!_static&&_private){var slot=this.level+memberDeclaration.memberName;this.privateStatics["$"+memberDeclaration.memberName]=slot;memberDeclaration.setSlot(slot);}var target=_static?_private?this.privateStatics:this.publicConstructor:this.publicConstructor.prototype;if(!memberDeclaration.retrieveMember(target,false)){memberDeclaration.storeMember(target);if(memberDeclaration.hasInitializer()){var initTarget=_static?this.staticInitializers:this.initializers;initTarget.push(memberDeclaration);}}},"internal override function doInit",function(){this.superClassDeclaration.init();this.initMembers();for(var i=0;i<this.staticInitializers.length;++i){var staticInitializer=this.staticInitializers[i];if(typeof staticInitializer=="function"){staticInitializer();}else{staticInitializer.initMember(staticInitializer.isPrivate()?this.privateStatics:this.publicConstructor);}}},"private static function initObject",function(object,memberDeclarations){for(var i=0;i<memberDeclarations.length;++i){(memberDeclarations[i]).initMember(object);}},"public function getMemberDeclaration",function(namespace_,memberName){return this.memberDeclarationsByQualifiedName[namespace_+"::"+memberName];},];},[]);joo.classLoader.prepare("package joo",[""],"public class SystemClassLoader",function($jooPublic,$jooPrivate){with(joo)with($jooPublic)with($jooPrivate)return[function(){joo.classLoader=new SystemClassLoader();},"public static const",{classDeclarationsByName:function(){return({});}},"public var",{debug:false},"public function SystemClassLoader",function(){this[$super]();},"public function prepare",function(packageDef,directives,classDef,memberFactory,publicStaticMethodNames){var cd=this.createClassDeclaration(packageDef,directives,classDef,memberFactory,publicStaticMethodNames);classDeclarationsByName[cd.fullClassName]=cd;},"internal function createClassDeclaration",function(packageDef,directives,classDef,memberFactory,publicStaticMethodNames){return new SystemClassDeclaration(packageDef,directives,classDef,memberFactory,publicStaticMethodNames).init();},"public function getClassDeclaration",function(fullClassName){var cd=classDeclarationsByName[fullClassName];if(!cd){var constructor_=joo.getQualifiedObject(fullClassName);if(constructor_){if(!constructor_.$class){cd=this.createNativeClassDeclaration(fullClassName,constructor_).init();classDeclarationsByName[fullClassName]=cd;}else{cd=constructor_.$class;}}}return cd;},"public function getRequiredClassDeclaration",function(className){var cd=this.getClassDeclaration(className);if(!cd){throw new Error("Class not found: "+className);}return cd;},"protected function createNativeClassDeclaration",function(fullClassName,nativeClass){return new NativeClassDeclaration(fullClassName,nativeClass);},];},[]);joo.classLoader.prepare("package",[""],"public class Array extends Object",function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return["public static const",{CASEINSENSITIVE:1},"public static const",{DESCENDING:2},"public static const",{NUMERIC:16},"public static const",{RETURNINDEXEDARRAY:8},"public static const",{UNIQUESORT:4},"public native function get length","public native function set length","public native function Array","public native function concat","public function every",function(callback,thisObject){if(arguments.length<2){thisObject=null;}var i=0,j=this.length;if(thisObject){for(;i<j;i++){if(i in this){if(!callback.call(thisObject,this[i],i,this)){return false;}}}}else{for(;i<j;i++){if(i in this){if(!callback(this[i],i,this)){return false;}}}}return true;},"public function filter",function(callback,thisObject){var len=this.length;var res=[];var i=0;var val;if(thisObject){for(;i<len;i++){if(i in this){val=this[i];if(callback.call(thisObject,val,i,this)){res.push(val);}}}}else{for(;i<len;i++){if(i in this){val=this[i];if(callback(val,i,this)){res.push(val);}}}}return res;},"public function forEach",function(callback,thisObject){var i=0,j=this.length;if(thisObject){for(;i<j;i++){if(i in this){callback.call(thisObject,this[i],i,this);}}}else{for(;i<j;i++){if(i in this){callback(this[i],i,this);}}}},"public function indexOf",function(searchElement,fromIndex){if(arguments.length<2){fromIndex=0;}var len=this.length;for(var i=(fromIndex<0)?Math.max(0,len+fromIndex):fromIndex||0;i<len;i++){if(searchElement===this[i])return i;}return-1;},"public native function join","public function lastIndexOf",function(searchElement,fromIndex){if(arguments.length<2){fromIndex=0x7fffffff;}var len=this.length;for(var i=((fromIndex<0)?Math.max(len,len-fromIndex):fromIndex||len)-1;i>=0;i--){if(searchElement===this[i])return i;}return-1;},"public function map",function(callback,thisObject){if(arguments.length<2){thisObject=null;}var results=[];var i=0,j=this.length;if(thisObject){for(;i<j;i++){results[i]=callback.call(thisObject,this[i],i,this);}}else{for(;i<j;i++){results[i]=callback(this[i],i,this);}}return results;},"public native function pop","public native function push","public native function reverse","public native function shift","public native function slice","public function some",function(callback,thisObject){if(arguments.length<2){thisObject=null;}var i=0,j=this.length;if(thisObject){for(;i<j;i++){if(i in this){if(callback.call(thisObject,this[i],i,this)){return true;}}}}else{for(;i<j;i++){if(i in this){if(callback(this[i],i,this)){return true;}}}}return false;},"public native function sort","public function sortOn",function(fieldName,options){if(arguments.length<2){options=null;}return null;},"public native function splice","public native function toLocaleString","public native function toString","public native function unshift",];},[]);joo.classLoader.prepare("package joo",[""],"internal class ImportMap",function($jooPublic,$jooPrivate){with(joo)with($jooPublic)with($jooPrivate)return["private var",{importsByName: undefined},"private var",{importedPackages: undefined},"internal function ImportMap",function(){this[$super]();this[$importsByName]={};this[$importedPackages]=[""];},"internal function addImport",function(fullClassName){var afterLastDotIndex=fullClassName.lastIndexOf(".")+1;var packageName=fullClassName.substring(0,afterLastDotIndex);var className=fullClassName.substring(afterLastDotIndex);if(className=="*"){this[$importedPackages].push(packageName);}else{if(className in this[$importsByName]&&this[$importsByName][className]!=fullClassName){delete this[$importsByName][className];}else{this[$importsByName][className]=fullClassName;}}},"internal function getImports",function(){var imports=[];for(var $1 in this[$importsByName]){var im=this[$importsByName][$1];imports.push(im);}return imports;},"internal function findQualifiedName",function(className){if(className.indexOf(".")<0){var fqn=this[$importsByName][className];if(fqn){return fqn;}var packages=this[$importedPackages];for(var i=packages.length-1;i>=0;--i){fqn=packages[i]+className;if(joo.classLoader.getClassDeclaration(fqn)){return fqn;}}}return className;},"internal function addToMap",function(map){for(var im in this[$importsByName]){map[im]=(joo.classLoader).getRequiredClassDeclaration(this[$importsByName][im]).publicConstructor;}return map;},"internal function init",function(){for(var im in this[$importsByName]){(joo.classLoader).getRequiredClassDeclaration(this[$importsByName][im]).init();}},];},[]);joo.classLoader.prepare("package joo",[""],"public class ClassDeclaration extends joo.SystemClassDeclaration",function($jooPublic,$jooPrivate){with(joo)with($jooPublic)with($jooPrivate)return["private var",{importMap: undefined},"public function ClassDeclaration",function(packageDef,directives,classDef,memberDeclarations,publicStaticMethods){this[$super](packageDef,directives,classDef,memberDeclarations,publicStaticMethods);},"internal function getDependencies",function(){var dependencies=this[$importMap].getImports();dependencies.push(this[$importMap].findQualifiedName(this.extends_));return dependencies;},"override internal function parseDirectives",function(directives){this[$parseDirectives](directives);this[$importMap]=new ImportMap();directives.forEach(this[$parseDirective]);},"private bound function parseDirective",function(directive){var importMatch=directive.match(/^\s*import\s+(([a-zA-Z$_0-9]+\.)*(\*|[a-zA-Z$_0-9]+))\s*$/);if(importMatch){this[$importMap].addImport(importMatch[1]);}},"override internal function doComplete",function(){this.extends_=this[$importMap].findQualifiedName(this.extends_);this[$doComplete]();for(var i=0;i<this.interfaces.length;++i){this.interfaces[i]=this[$importMap].findQualifiedName(this.interfaces[i]);}this[$importMap].addToMap(this.privateStatics);createInitializingConstructor(this);this.publicStaticMethodNames.forEach(this[$createInitializingStaticMethod]);},"private static function createInitializingConstructor",function(classDeclaration){classDeclaration.constructor_=function(){classDeclaration.init();classDeclaration.constructor_.apply(this,arguments);};},"private bound function createInitializingStaticMethod",function(methodName){var classDeclaration=this;classDeclaration.publicConstructor[methodName]=function(){classDeclaration.init();return classDeclaration.publicConstructor[methodName].apply(null,arguments);};},"private bound function deleteInitializingStaticMethod",function(methodName){delete this.publicConstructor[methodName];},"internal override function doInit",function(){this.publicStaticMethodNames.forEach(this[$deleteInitializingStaticMethod]);this[$doInit]();this.interfaces.forEach(function(interface_,i,interfaces){interfaces[i]=joo.classLoader.getRequiredClassDeclaration(interface_);});},"public override function isInstance",function(object){return typeof object=="object"&&object.constructor.$class?this.isAssignableFrom(object.constructor.$class):false;},"internal bound function isAssignableFrom",function(cd){do{if(this===cd){return true;}if(this.isInterface){if(cd.interfaces.some(this.isAssignableFrom)){return true;}}cd=cd.superClassDeclaration;}while(cd);return false;},];},[]);joo.classLoader.prepare("package joo",[""],"public class ClassLoader extends joo.SystemClassLoader",function($jooPublic,$jooPrivate){with(joo)with($jooPublic)with($jooPrivate)return["private static var",{classDeclarations:function(){return([]);}},"private var",{importMap: undefined},"public function ClassLoader",function(){this[$super]();this[$importMap]=new ImportMap();},"override internal function createClassDeclaration",function(packageDef,directives,classDef,memberFactory,publicStaticMethodNames){var cd=new ClassDeclaration(packageDef,directives,classDef,memberFactory,publicStaticMethodNames);classDeclarations.push(cd);if(cd.native_){cd.init();}return cd;},"public function loadScript",function(uri){var script=window.document.createElement("script");script.type="text/javascript";window.document.body.appendChild(script);script.src=uri;},"public function import_",function(fullClassName){this[$importMap].addImport(fullClassName);},"public function run",function(mainClassName){var args=Array.prototype.slice.call(arguments,1);this.complete(function(){var mainClass=this.getRequiredClassDeclaration(mainClassName);mainClass.init();mainClass.publicConstructor["main"].apply(null,args);}.bind(this));},"public function init",function(){var clazz;for(var i=0;i<arguments.length;++i){if(arguments[i].$class){((clazz=arguments[i]).$class).init();}}return clazz;},"public function complete",function(onCompleteCallback){this.completeAll();this.doCompleteCallback(onCompleteCallback);},"protected function completeAll",function(){classDeclarations.forEach(function(classDeclaration){classDeclaration.complete();});},"protected function doCompleteCallback",function(onCompleteCallback){if(onCompleteCallback){this[$importMap].init();onCompleteCallback(this[$importMap].addToMap({}));}},];},[]);joo.classLoader.prepare("package joo",[""],"public class DynamicClassLoader extends joo.ClassLoader",function($jooPublic,$jooPrivate){with(joo)with($jooPublic)with($jooPrivate)return["private static function isEmpty",function(object){for(var m in object){return false;}return true;},"public var",{classLoadTimeoutMS:0,urlPrefix:""},"private var",{loadCheckTimer: undefined,onCompleteCallback: undefined},"private var",{pendingClassState:function(){return({});}},"override internal function createClassDeclaration",function(packageDef,directives,classDef,memberFactory,publicStaticMethodNames){var cd=this[$createClassDeclaration](packageDef,directives,classDef,memberFactory,publicStaticMethodNames);var dependencies=cd.getDependencies();for(var i=0;i<dependencies.length;++i){this[$load](dependencies[i]);}if(delete this[$pendingClassState][cd.fullClassName]){if(this.debug){trace("prepared class "+cd.fullClassName+", removed from pending classes.");}if(this[$onCompleteCallback]){if(this[$loadCheckTimer]){window.clearTimeout(this[$loadCheckTimer]);this[$loadCheckTimer]=undefined;}if(isEmpty(this[$pendingClassState])){var onCompleteCallback=this[$onCompleteCallback];this[$onCompleteCallback]=null;window.setTimeout(function(){this.completeAll();this.doCompleteCallback(onCompleteCallback);}.bind(this),0);}else if(this.classLoadTimeoutMS){this[$loadCheckTimer]=window.setTimeout(this[$throwMissingClassesError],this.classLoadTimeoutMS);}}}return cd;},"private bound function throwMissingClassesError",function(){var sb=[];for(var loading in this[$pendingClassState]){if(this[$pendingClassState][loading]){sb.push(loading);}}if(sb.length>0){throw new Error("The following classes were not loaded after "+this.classLoadTimeoutMS+" milliseconds: "+sb.join(", "));}},"public override function import_",function(fullClassName){this[$import_](fullClassName);this[$load](fullClassName);},"override public function run",function(mainClassName){var args=Array.prototype.slice.call(arguments,1);this[$load](mainClassName);args.splice(0,0,mainClassName);this[$run].apply(this,args);},"private function load",function(fullClassName){if(!this.getClassDeclaration(fullClassName)){if(!this[$onCompleteCallback]){if(this[$pendingClassState][fullClassName]===undefined){this[$pendingClassState][fullClassName]=false;if(this.debug){trace("added to pending classes: "+fullClassName+".");}}}else{if(this[$pendingClassState][fullClassName]!==true){this[$pendingClassState][fullClassName]=true;var url=this.getUri(fullClassName);joo.classLoader.loadScript(url);if(this.debug){trace("triggered loading class "+fullClassName+" from URL "+url+".");}}}}},"protected function getBaseUri",function(){var baseUri=window.document.location.href;return baseUri.substring(0,baseUri.lastIndexOf("/")+1)+this.urlPrefix;},"protected function getUri",function(fullClassName){var baseUri=this.getBaseUri();return baseUri+fullClassName.replace(/\./g,"/")+".js";},"public override function complete",function(onCompleteCallback){if(isEmpty(this[$pendingClassState])){this[$complete](onCompleteCallback);}else{this[$onCompleteCallback]=onCompleteCallback||defaultOnCompleteCallback;for(var c in this[$pendingClassState]){this[$load](c);}}},"private static function defaultOnCompleteCallback",function(){trace("All classes loaded!");},];},[]);joo.classLoader = new joo.DynamicClassLoader();
