/*
	Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

//>>built
define("dojo/request/script","module ./watch ./util ../_base/kernel ../_base/array ../_base/lang ../on ../dom ../dom-construct ../has ../_base/window".split(" "),function(t,u,h,v,w,x,p,y,z,q,A){function B(a,b){a.canDelete&&g._remove(a.id,b.options.frameDoc,!0)}function C(a){k&&k.length&&(w.forEach(k,function(b){g._remove(b.id,b.frameDoc);b.frameDoc=null}),k=[]);return a.options.jsonp?!a.data:!0}function D(a){return!!this.scriptLoaded}function E(a){return(a=a.options.checkString)&&eval("typeof("+a+
') !\x3d\x3d "undefined"')}function F(a,b){if(this.canDelete){var d=this.response.options;k.push({id:this.id,frameDoc:d.ioArgs?d.ioArgs.frameDoc:d.frameDoc});d.ioArgs&&(d.ioArgs.frameDoc=null);d.frameDoc=null}b?this.reject(b):this.resolve(a)}function g(a,b,d){var e=h.parseArgs(a,h.deepCopy({},b));a=e.url;b=e.options;var c=h.deferred(e,B,C,b.jsonp?null:b.checkString?E:D,F);x.mixin(c,{id:m+G++,canDelete:!1});b.jsonp&&((new RegExp("[?\x26]"+b.jsonp+"\x3d")).test(a)||(a+=(~a.indexOf("?")?"\x26":"?")+
b.jsonp+"\x3d"+(b.frameDoc?"parent.":"")+m+"_callbacks."+c.id),c.canDelete=!0,l[c.id]=function(f){e.data=f;c.handleResponse(e)});h.notify&&h.notify.emit("send",e,c.promise.cancel);if(!b.canAttach||b.canAttach(c)){var n=g._attach(c.id,a,b.frameDoc,function(f){if(!(f instanceof Error)){var r=Error("Error loading "+(f.target?f.target.src:"script"));r.source=f;f=r}c.reject(f);g._remove(c.id,b.frameDoc,!0)});if(!b.jsonp&&!b.checkString)var J=p(n,H,function(f){if("load"===f.type||I.test(n.readyState))J.remove(),
c.scriptLoaded=f})}u(c);return d?c:c.promise}q.add("script-readystatechange",function(a,b){return"undefined"!==typeof b.createElement("script").onreadystatechange&&("undefined"===typeof a.opera||"[object Opera]"!==a.opera.toString())});var m=t.id.replace(/[\/\.\-]/g,"_"),G=0,H=q("script-readystatechange")?"readystatechange":"load",I=/complete|loaded/,l=v.global[m+"_callbacks"]={},k=[];g.get=g;g._attach=function(a,b,d,e){d=d||A.doc;var c=d.createElement("script");if(e)p.once(c,"error",e);c.type="text/javascript";
try{c.src=b}catch(n){e&&e(c)}c.id=a;c.async=!0;c.charset="utf-8";return d.getElementsByTagName("head")[0].appendChild(c)};g._remove=function(a,b,d){z.destroy(y.byId(a,b));l[a]&&(d?l[a]=function(){delete l[a]}:delete l[a])};g._callbacksProperty=m+"_callbacks";return g});