dispatch.to("Foundry/2.1 Core Plugins").at(function($){$.require=function(){var getFolderPath=function(path){return $.uri(path).setAnchor("").setQuery("").toPath("../").toString()},self=function(options){var batch=new self.batch(options);return self.batches[batch.id]=batch,batch};return $.extend(self,{defaultOptions:{path:function(){var path=$.scriptPath||$("[require-path]").attr("require-path")||getFolderPath($("script:last").attr("src"))||getFolderPath(window.location.href);return/^(\/|\.)/.test(path)&&(path=$.uri(window.location.href).toPath(path).toString()),path
}(),timeout:1e4,retry:3,verbose:"development"==$.environment},setup:function(options){$.extend(self.defaultOptions,options)},batches:{},batch:function(options){var batch=this;batch.id=$.uid(),batch.manager=$.Deferred(),batch.taskList=[],batch.tasksFinalized=!1,batch.options=$.extend({},self.defaultOptions,options)},status:function(){$.each(self.batches,function(i,batch){console.info(batch.id,batch.state(),batch),$.each(batch.taskList,function(i,task){console.log("	 ["+task.name+"]",task.state())})})},loaders:{},addLoader:function(name,factory){self[name]=factory,self.batch.prototype[name]=function(){var batch=this;
return factory.apply(batch,arguments),batch},self.loaders[name]=self[name]=factory},removeLoader:function(name){delete self.batch.prototype[name],delete self[name]}}),$.extend(self.batch.prototype,{addTask:function(task){var batch=this;if($.isDeferred(task)){if(batch.taskFinalized)return batch.options.verbose&&console.warn("$.require: "+task.name+" ignored because tasks of this batch are finalized.",task),void 0;task.batch=batch,task.then($.proxy(batch.taskDone,task),$.proxy(batch.taskFail,task),$.proxy(batch.taskProgress,task)),batch.taskList.push(task)
}},taskDone:function(){var task=this,batch=task.batch;batch.manager.notifyWith(batch,[task])},taskFail:function(){var task=this,batch=task.batch;batch.options.verbose&&console.error("$.require: "+task.name+" failed to load.",task),batch.manager.notifyWith(batch,[task])},taskProgress:function(){var task=this,batch=task.batch;batch.manager.notifyWith(batch,[task])},expand:function(args,opts){var args=$.makeArray(args),options=opts||{},names=[];return $.isPlainObject(args[0])?(options=$.extend(args[0],opts),names=args.slice(1)):names=args,{options:options,names:names}
},stat:function(){}}),$.each(["then","done","fail","always","pipe","progress"],function(i,func){self.batch.prototype[func]=function(){var batch=this;return batch.taskFinalized=!0,$.extend(batch,batch.manager.promise()),batch.tasks=$.when.apply(null,batch.taskList),batch.tasks.done(function(){batch.manager.resolve()}).fail(function(){batch.options.verbose&&console.info("$.require: Batch "+batch.id+" failed.",batch),batch.manager.reject()}),batch[func].apply(batch,arguments),batch}}),self}(),$.require.addLoader("script",function(){var ajaxHost=$.uri($.indexUrl).host(),documentHost=$.uri(document.location.href).host();
ajaxHost!==documentHost&&ajaxHost.match("xn--")&&($.support.cors=!0);var canAsync=document.createElement("script").async===!0||"MozAppearance"in document.documentElement.style||window.opera,self=function(){var options,names,batch=this,args=$.makeArray(arguments);$.isPlainObject(args[0])?(options=args[0],names=args.slice(1)):names=args,options=$.extend({},self.defaultOptions,batch.options,options,{batch:batch});var taskBefore;$.each(names,function(i,name){var task=new self.task(name,options,taskBefore);batch.addTask(task),options.serial&&void 0!==taskBefore?taskBefore.always(task.start):task.start(),taskBefore=task
})};return $.extend(self,{defaultOptions:{path:"",extension:"js",serial:!1,async:!1,xhr:!1,prefetch:!1},setup:function(){$.extend(self.defaultOptions,options)},scripts:{},task:function(name,options,taskBefore){var task=$.extend(this,$.Deferred());if(task.name=name,task.options=options,task.taskBefore=taskBefore,$.isArray(name)){task.name=name[0]+"@"+name[1],task.moduleName=name[0];var overrideModuleUrl=name[2];overrideModuleUrl||(task.defineModule=!0,$.module.registry[task.moduleName]&&console.warn("$.require.script: "+task.moduleName+" exists! Using existing module instead."),task.options.xhr=!0),name=name[1],task.module=$.module(task.moduleName)
}$.isUrl(name)?task.url=name:/^(\/|\.)/.test(name)?task.url=$.uri(task.options.path).toPath(name).toString():(task.url=$.uri(task.options.path).toPath("./"+name+"."+task.options.extension).toString(),task.module=$.module(name))}}),$.extend(self.task.prototype,{start:function(){var task=this,taskBefore=task.taskBefore;if(task.module){var moduleState=task.module.state();if("resolved"==moduleState)return task.resolve(),void 0;if("rejected"==moduleState)return task.rejected(),void 0}if(canAsync||task.options.xhr)task.load();
else{if(!task.options.prefetch)return task.load(),void 0;task.script=$.script({url:task.url,type:"text/cache"}),task.script.done(taskBefore?function(){taskBefore.done(function(){task.reload()})}:function(){task.reload()})}},reload:function(){var task=this;task.script.remove(),task.load()},load:function(){var task=this,taskBefore=task.taskBefore;task.script=self.scripts[task.url]||function(){var script=task.options.xhr?$.ajax({url:task.url,dataType:"text"}):$.script({url:task.url,type:"text/javascript",async:task.options.async,timeout:task.batch.options.timeout,retry:task.batch.options.retry,verbose:task.batch.options.verbose});
return self.scripts[task.url]=script}(),task.script.done(function(data){var resolveTask=function(){task.module?task.module.done(task.resolve).fail(task.reject):task.resolve()};return task.options.xhr&&(task.defineModule&&(task.module=$.module(task.moduleName,function(){var module=this;$.globalEval(data),module.resolveWith(data)})),!task.options.async||taskBefore)?(taskBefore.done(function(){$.globalEval(data),resolveTask()}),void 0):(resolveTask(),void 0)}).fail(function(){task.reject()})}}),self}()),$.require.addLoader("stylesheet",function(){var self=function(){var options,names,batch=this,args=$.makeArray(arguments);
$.isPlainObject(args[0])?(options=args[0],names=args.slice(1)):names=args,options=$.extend({},self.defaultOptions,batch.options,options,{batch:batch}),$.each(names,function(i,name){var task=new self.task(name,options),existingTask=self.stylesheets[task.url];task=existingTask||task,batch.addTask(task),existingTask||(self.stylesheets[task.url]=task,task.start())})};return $.extend(self,{defaultOptions:{path:"",extension:"css",xhr:!1},setup:function(){$.extend(self.defaultOptions,options)},stylesheets:{},task:function(name,options){var task=$.extend(this,$.Deferred());
task.name=name,task.options=options,task.url=$.isUrl(name)?name:/^(\/|\.)/.test(name)?$.uri(task.options.path).toPath(name).toString():$.uri(task.options.path).toPath("./"+name+"."+task.options.extension).toString(),task.options.url=task.url}}),$.extend(self.task.prototype,{start:function(){var task=this;$.stylesheet(task.options)?task.resolve():task.reject()}}),self}()),$.require.addLoader("template",function(){var self=function(){var options,names,batch=this,args=$.makeArray(arguments);$.isPlainObject(args[0])?(options=args[0],names=args.slice(1)):names=args,options=$.extend({},self.defaultOptions,batch.options,options,{batch:batch}),$.each(names,function(i,name){var task=new self.task(name,options);
batch.addTask(task),task.start()})};return $.extend(self,{defaultOptions:{path:"",extension:"htm"},setup:function(){$.extend(self.defaultOptions,options)},loaders:{},task:function(name,options){var task=$.extend(this,$.Deferred());task.name=name,task.options=options,$.isArray(name)&&(task.name=name[0],name=name[1]),task.url=$.isUrl(name)?name:/^(\/|\.)/.test(name)?$.uri(task.options.path).toPath(name).toString():$.uri(task.options.path).toPath("./"+name+"."+task.options.extension).toString()}}),$.extend(self.task.prototype,{start:function(){var task=this;
task.taskBefore,task.loader=self.loaders[task.url]||function(){var loader=$.Ajax({url:task.url,dataType:"text"});return self.loaders[task.url]=loader}(),task.loader.done(function(content){$.template(task.name,content),task.resolve()}).fail(function(){task.reject()})}}),self}()),$.require.addLoader("language",function(){var self=function(){var options,names,batch=this,args=$.makeArray(arguments);$.isPlainObject(args[0])?(options=args[0],names=args.slice(1)):names=args,options=$.extend({},self.defaultOptions,batch.options,options,{batch:batch});
var task=new self.task(names,options);batch.addTask(task),setTimeout(function(){task.start()},1e3)};return $.extend(self,{defaultOptions:{path:""},setup:function(){$.extend(self.defaultOptions,options)},loaders:{},task:function(names,options){var task=$.extend(this,$.Deferred());task.name=names.join(","),task.options=options,task.url=options.path,task.languages=names}}),$.extend(self.task.prototype,{start:function(){var task=this;task.taskBefore,task.loader=self.loaders[task.name]||function(){var loader=$.Ajax({url:task.url,type:"POST",data:{languages:task.languages}});
return self.loaders[task.name]=loader}(),task.loader.done(function(languages){$.language.add(languages),task.resolve()}).fail(function(){task.reject()})}}),self}()),$.require.addLoader("library",function(){var names,batch=this,args=$.makeArray(arguments),options={};return $.isPlainObject(args[0])?(options=args[0],names=args.slice(1)):names=args,$.extend(options,{path:$.scriptPath}),batch.script.apply(batch,[options].concat(names))}),$.require.addLoader("image",function(){var self=function(){var options,names,batch=this,args=$.makeArray(arguments);
$.isPlainObject(args[0])?(options=args[0],names=args.slice(1)):names=args,options=$.extend({},self.defaultOptions,batch.options,options,{batch:batch}),$.each(names,function(i,name){var task=new self.task(name,options),existingTask=self.images[task.url];task=existingTask||task,batch.addTask(task),existingTask||(self.images[task.url]=task,task.start())})};return $.extend(self,{defaultOptions:{path:""},setup:function(){$.extend(self.defaultOptions,options)},images:{},task:function(name,options){var task=$.extend(this,$.Deferred());
task.name=name,task.options=options,task.url=$.isUrl(name)?name:/^(\/|\.)/.test(name)?$.uri(task.options.path).toPath(name).toString():$.uri(task.options.path).toPath("./"+name).toString(),task.options.url=task.url}}),$.extend(self.task.prototype,{start:function(){var task=this;task.image=$(new Image).load(function(){task.resolve()}).error(function(){task.reject()}).attr("src",task.options.url)}}),self}())});