varChannel=function(){"use strict";functiona(a,b,c,d){functionf(b){for(varc=0;c<b.length;c++)if(b[c].win===a)return!0;return!1}varg=!1;if("*"===b){for(varhine)if(e.hasOwnProperty(h)&&"*"!==h&&"object"==typeofe[h][c]&&(g=f(e[h][c])))break}elsee["*"]&&e["*"][c]&&(g=f(e["*"][c])),!g&&e[b]&&e[b][c]&&(g=f(e[b][c]));if(g)throw"A channel is already bound to the same window which overlaps with origin '"+b+"' and has scope '"+c+"'";"object"!=typeofe[b]&&(e[b]={}),"object"!=typeofe[b][c]&&(e[b][c]=[]),e[b][c].push({win:a,handler:d})}functionb(a,b,c){for(vard=e[b][c],f=0;f<d.length;f++)d[f].win===a&&d.splice(f,1);0===e[b][c].length&&deletee[b][c]}functionc(a){returnArray.isArray?Array.isArray(a):-1!=a.constructor.toString().indexOf("Array")}vard=Math.floor(1000001*Math.random()),e={},f={},g=function(a){try{varb=JSON.parse(a.data);if("object"!=typeofb||null===b)throw"malformed"}catch(a){return}varc,d,g,h=a.source,i=a.origin;if("string"==typeofb.method){varj=b.method.split("::");2==j.length?(c=j[0],g=j[1]):g=b.method}if("undefined"!=typeofb.id&&(d=b.id),"string"==typeofg){vark=!1;if(e[i]&&e[i][c])for(varl=0;l<e[i][c].length;l++)if(e[i][c][l].win===h){e[i][c][l].handler(i,g,b),k=!0;break}if(!k&&e["*"]&&e["*"][c])for(varl=0;l<e["*"][c].length;l++)if(e["*"][c][l].win===h){e["*"][c][l].handler(i,g,b);break}}else"undefined"!=typeofd&&f[d]&&f[d](i,g,b)};returnwindow.addEventListener?window.addEventListener("message",g,!1):window.attachEvent&&window.attachEvent("onmessage",g),{build:function(e){varg=function(a){if(e.debugOutput&&window.console&&window.console.log){try{"string"!=typeofa&&(a=JSON.stringify(a))}catch(b){}console.log("["+j+"] "+a)}};if(!window.postMessage)throw"jschannel cannot run this browser, no postMessage";if(!window.JSON||!window.JSON.stringify||!window.JSON.parse)throw"jschannel cannot run this browser, no JSON parsing/serialization";if("object"!=typeofe)throw"Channel build invoked without a proper object argument";if(!e.window||!e.window.postMessage)throw"Channel.build() called without a valid window argument";if(window===e.window)throw"target window is same as present window -- not allowed";varh=!1;if("string"==typeofe.origin){vari;"*"===e.origin?h=!0:null!==(i=e.origin.match(/^https?:\/\/(?:[-a-zA-Z0-9_\.])+(?::\d+)?/))&&(e.origin=i[0].toLowerCase(),h=!0)}if(!h)throw"Channel.build() called with an invalid origin";if("undefined"!=typeofe.scope){if("string"!=typeofe.scope)throw"scope, when specified, must be a string";if(e.scope.split("::").length>1)throw"scope may not contain double colons: '::'"}varj=function(){for(vara="",b="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",c=0;5>c;c++)a+=b.charAt(Math.floor(Math.random()*b.length));returna}(),k={},l={},m={},n=!1,o=[],p=function(a,b,c){vard=!1,e=!1;return{origin:b,invoke:function(b,d){if(!m[a])throw"attempting to invoke a callback of a nonexistent transaction: "+a;for(vare=!1,f=0;f<c.length;f++)if(b===c[f]){e=!0;break}if(!e)throw"request supports no such callback '"+b+"'";t({id:a,callback:b,params:d})},error:function(b,c){if(e=!0,!m[a])throw"error called for nonexistent message: "+a;deletem[a],t({id:a,error:b,message:c})},complete:function(b){if(e=!0,!m[a])throw"complete called for nonexistent message: "+a;deletem[a],t({id:a,result:b})},delayReturn:function(a){return"boolean"==typeofa&&(d=a===!0),d},completed:function(){returne}}},q=function(a,b,c){returnwindow.setTimeout(function(){if(l[a]){vard="timeout ("+b+"ms) exceeded on method '"+c+"'";l[a].error("timeout_error",d),deletel[a],deletef[a]}},b)},r=function(a,b,d){if("function"==typeofe.gotMessageObserver)try{e.gotMessageObserver(a,d)}catch(h){g("gotMessageObserver() raised an exception: "+h.toString())}if(d.id&&b){if(k[b]){vari=p(d.id,a,d.callbacks?d.callbacks:[]);m[d.id]={};try{if(d.callbacks&&c(d.callbacks)&&d.callbacks.length>0)for(varj=0;j<d.callbacks.length;j++){for(varn=d.callbacks[j],o=d.params,q=n.split("/"),r=0;r<q.length-1;r++){vars=q[r];"object"!=typeofo[s]&&(o[s]={}),o=o[s]}o[q[q.length-1]]=function(){vara=n;returnfunction(b){returni.invoke(a,b)}}()}vart=k[b](i,d.params);i.delayReturn()||i.completed()||i.complete(t)}catch(h){varu="runtime_error",v=null;if("string"==typeofh?v=h:"object"==typeofh&&(h&&c(h)&&2==h.length?(u=h[0],v=h[1]):"string"==typeofh.error&&(u=h.error,h.message?"string"==typeofh.message?v=h.message:h=h.message:v="")),null===v)try{v=JSON.stringify(h),"undefined"==typeofv&&(v=h.toString())}catch(w){v=h.toString()}i.error(u,v)}}}elsed.id&&d.callback?l[d.id]&&l[d.id].callbacks&&l[d.id].callbacks[d.callback]?l[d.id].callbacks[d.callback](d.params):g("ignoring invalid callback, id:"+d.id+" ("+d.callback+")"):d.id?l[d.id]?(d.error?l[d.id].error(d.error,d.message):void0!==d.result?l[d.id].success(d.result):l[d.id].success(),deletel[d.id],deletef[d.id]):g("ignoring invalid response: "+d.id):b&&k[b]&&k[b]({origin:a},d.params)};a(e.window,e.origin,"string"==typeofe.scope?e.scope:"",r);vars=function(a){return"string"==typeofe.scope&&e.scope.length&&(a=[e.scope,a].join("::")),a},t=function(a,b){if(!a)throw"postMessage called with null message";varc=n?"post ":"queue ";if(g(c+" message: "+JSON.stringify(a)),b||n){if("function"==typeofe.postMessageObserver)try{e.postMessageObserver(e.origin,a)}catch(d){g("postMessageObserver() raised an exception: "+d.toString())}e.window.postMessage(JSON.stringify(a),e.origin)}elseo.push(a)},u=function(a,b){if(g("ready msg received"),n)throw"received ready message while in ready state. help!";for(j+="ping"===b?"-R":"-L",v.unbind("__ready"),n=!0,g("ready msg accepted."),"ping"===b&&v.notify({method:"__ready",params:"pong"});o.length;)t(o.pop());"function"==typeofe.onReady&&e.onReady(v)},v={unbind:function(a){if(k[a]){if(!deletek[a])throw"can't delete method: "+a;return!0}return!1},bind:function(a,b){if(!a||"string"!=typeofa)throw"'method' argument to bind must be string";if(!b||"function"!=typeofb)throw"callback missing from bind params";if(k[a])throw"method '"+a+"' is already bound!";returnk[a]=b,this},call:function(a){if(!a)throw"missing arguments to call function";if(!a.method||"string"!=typeofa.method)throw"'method' argument to call must be string";if(!a.success||"function"!=typeofa.success)throw"'success' callback missing from call";varb={},c=[],e=function(a,d){if("object"==typeofd)for(varfind)if(d.hasOwnProperty(f)){varg=a+(a.length?"/":"")+f;"function"==typeofd[f]?(b[g]=d[f],c.push(g),deleted[f]):"object"==typeofd[f]&&e(g,d[f])}};e("",a.params);varg={id:d,method:s(a.method),params:a.params};c.length&&(g.callbacks=c),a.timeout&&q(d,a.timeout,s(a.method)),l[d]={callbacks:b,error:a.error,success:a.success},f[d]=r,d++,t(g)},notify:function(a){if(!a)throw"missing arguments to notify function";if(!a.method||"string"!=typeofa.method)throw"'method' argument to notify must be string";t({method:s(a.method),params:a.params})},destroy:function(){b(e.window,e.origin,"string"==typeofe.scope?e.scope:""),window.removeEventListener?window.removeEventListener("message",r,!1):window.detachEvent&&window.detachEvent("onmessage",r),n=!1,k={},m={},l={},e.origin=null,o=[],g("channel destroyed"),j=""}};returnv.bind("__ready",u),setTimeout(function(){t({method:s("__ready"),params:"ping"},!0)},0),v}}}();!function(a){"use strict";varb=a.prototype,c=b.parseFromString;try{if((newa).parseFromString("","text/html"))return}catch(d){}b.parseFromString=function(a,b){vard,e,f,g;return/^\s*text\/html\s*(?:;|$)/i.test(b)?(e=document.implementation.createHTMLDocument(""),f=e.documentElement,f.innerHTML=a,g=f.firstElementChild,1===f.childElementCount&&"html"===g.localName.toLowerCase()&&e.replaceChild(g,f),d=e):d=c.apply(this,arguments),d}}(DOMParser),function(a,b,c,d,e,f,g,h){"use strict";functioni(a){varb=a.indexOf("#");returnb>0&&(a=a.substring(0,b)),a}functionj(b){if(b.constructor===XMLHttpRequest&&(b={readyState:b.readyState,status:b.status,statusText:b.statusText,response_headers:b.getAllResponseHeaders()}),b.constructor===Array||b.constructor===String||b.constructor===Object)try{b=JSON.stringify(b)}catch(c){}a.getElementsByTagName("body")[0].textContent=b,console.error(b.stack),console.error(b)}functionk(a){if(this.name="resolved",a!==h&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Default Message"}functionl(){returnthisinstanceofl?void0:newl}functionm(a){a.__monitor!==h&&a.__monitor.cancel(),a.__monitor=newA,a.__monitor.fail(function(b){returnbinstanceofc.CancellationError?void0:a.aq_reportServiceError(b)}).fail(function(a){returnj(a)})}functionn(a){a.__sub_gadget_dict={},m(a)}functiono(a){varb,d,e,f,g,i=a.__element.querySelectorAll("[data-gadget-scope]"),j=[];for(g=0;g<i.length;g+=1)b=i[g],d=b.getAttribute("data-gadget-scope"),e=b.getAttribute("data-gadget-url"),f=b.getAttribute("data-gadget-sandbox"),null!==d&&null!==e&&j.push(a.declareGadget(e,{element:b,scope:d||h,sandbox:f||h}));returnc.all(j)}functionp(a){a.__monitor.monitor((newc.Queue).push(function(){varb,c=a.constructor.__service_list;for(b=0;b<c.length;b+=1)a.__monitor.monitor(c[b].apply(a))}))}functionq(a,b,d){vare,f,g=this;for(eing.__sub_gadget_dict)g.__sub_gadget_dict.hasOwnProperty(e)&&g.__sub_gadget_dict[e]===a&&(f=e);return(newc.Queue).push(function(){vara=g.__acquired_method_dict||{};if(a.hasOwnProperty(b))returna[b].apply(g,[d,f]);thrownewz.AcquisitionError("aq_dynamic is not defined")}).push(h,function(a){if(ainstanceofz.AcquisitionError)returng.__aq_parent(b,d);throwa})}functionr(a,b){a.__aq_parent=function(c,d){returnq.apply(b,[a,c,d])}}functions(){returnthisinstanceofs?(l.call(this),void0):news}functiont(b,d,e){functionf(a,b){returnfunction(){returna(b)}}varg;returnd.element===h&&(d.element=a.createElement("div")),(newc.Queue).push(function(){returnz.declareGadgetKlass(b)}).push(function(a){varb,f=a.__template_element.body.childNodes;for(x=a,g=newa,g.__element=d.element,b=0;b<f.length;b+=1)g.__element.appendChild(f[b].cloneNode(!0));returnr(g,e),c.all([g.getRequiredJSList(),g.getRequiredCSSList()])}).push(function(a){varb,d=newc.Queue;for(b=0;b<a[0].length;b+=1)d.push(f(z.declareJS,a[0][b]));for(b=0;b<a[1].length;b+=1)d.push(f(z.declareCSS,a[1][b]));returnd}).push(function(){returng})}functionu(){returnthisinstanceofu?(l.call(this),void0):newu}functionv(b,d,f){varg,i,j=c.defer();if(d.element===h)thrownewError("DOM element is required to create Iframe Gadget "+b);if(!a.contains(d.element))thrownewError("The parent element is not attached to the DOM for "+b);returng=newu,r(g,f),i=a.createElement("iframe"),i.setAttribute("src",b),g.__path=b,g.__element=d.element,d.element.appendChild(i),g.__chan=e.build({window:i.contentWindow,origin:"*",scope:"renderJS"}),g.__chan.bind("declareMethod",function(a,b){returng[b]=function(){vara=arguments;returnnewc.Promise(function(c,d){g.__chan.call({method:"methodCall",params:[b,Array.prototype.slice.call(a,0)],success:function(a){c(a)},error:function(a){d(a)}})})},"OK"}),g.__chan.bind("ready",function(){returnj.resolve(g),"OK"}),g.__chan.bind("failed",function(a,b){returnj.reject(b),"OK"}),g.__chan.bind("acquire",function(a,b){g.__aq_parent.apply(g,b).then(function(b){a.complete(b)}).fail(function(b){a.error(b.toString())}),a.delayReturn(!0)}),c.any([j.promise,c.timeout(5e3)])}functionw(){vard,k,n,o,q,t,u=i(b.location.href),v=newc.Queue,w=0,A=!1;if(B.hasOwnProperty(u))thrownewError("bootstrap should not be called twice");y=newc.Promise(function(i,v){functiony(){varb,e,j=z.parseGadgetHTMLDocument(a,u);for(einj)j.hasOwnProperty(e)&&(d.prototype["__"+e]=j[e]);for(d.__template_element=a.createElement("div"),k.__element=a.body,b=0;b<k.__element.childNodes.length;b+=1)d.__template_element.appendChild(k.__element.childNodes[b].cloneNode(!0));c.all([k.getRequiredJSList(),k.getRequiredCSSList()]).then(function(a){varb,c=a[0],d=a[1];for(b=0;b<c.length;b+=1)C[c[b]]=null;for(b=0;b<d.length;b+=1)D[d[b]]=null;x=h}).then(function(){varb=a.querySelector("body"),c=newf(function(b){varc,d,e,f,i,j;b.forEach(function(b){if("childList"===b.type){for(e=b.removedNodes.length,c=0;e>c;c+=1)if(i=b.removedNodes[c],i.nodeType===g.ELEMENT_NODE)for(i.hasAttribute("data-gadget-url")&&i._gadget!==h&&m(i._gadget),j=i.querySelectorAll("[data-gadget-url]"),f=j.length,d=0;f>d;d+=1)i=j[d],i._gadget!==h&&m(i._gadget);for(e=b.addedNodes.length,c=0;e>c;c+=1)if(i=b.addedNodes[c],i.nodeType===g.ELEMENT_NODE)for(i.hasAttribute("data-gadget-url")&&i._gadget!==h&&a.contains(i)&&p(i._gadget),j=i.querySelectorAll("[data-gadget-url]"),f=j.length,d=0;f>d;d+=1)i=j[d],a.contains(i)&&i._gadget!==h&&p(i._gadget)}})}),d={childList:!0,subtree:!0,attributes:!1,characterData:!1};returnc.observe(b,d),k}).then(i,function(a){throwv(a),console.error(a),a})}b.self===b.top?(t=newl,t.__acquired_method_dict={getTopURL:function(){returnu},reportServiceError:function(a){j(a[0])}},t.__aq_parent=function(a){thrownewz.AcquisitionError("No gadget provides "+a)},d=function(){l.call(this)},d.declareMethod=l.declareMethod,d.declareAcquiredMethod=l.declareAcquiredMethod,d.allowPublicAcquisition=l.allowPublicAcquisition,d.__ready_list=l.__ready_list.slice(),d.ready=l.ready,d.__service_list=l.__service_list.slice(),d.declareService=l.declareService,d.prototype=newl,d.prototype.constructor=d,d.prototype.__path=u,B[u]=d,k=newB[u],r(k,t)):(n=e.build({window:b.parent,origin:"*",scope:"renderJS"}),d=s,d.__ready_list=l.__ready_list.slice(),d.__service_list=l.__service_list.slice(),d.prototype.__path=u,k=news,n.bind("methodCall",function(a,b){k[b[0]].apply(k,b[1]).then(function(b){a.complete(b)}).fail(function(b){a.error(b.toString())}),a.delayReturn(!0)}),o=function(){0===w&&A===!0&&n.notify({method:"ready"})},q=function(a){w+=1,n.call({method:"declareMethod",params:a,success:function(){w-=1,o()},error:function(){w-=1}})},q("getInterfaceList"),q("getRequiredCSSList"),q("getRequiredJSList"),q("getPath"),q("getTitle"),d.declareMethod=function(a,b){varc=l.declareMethod.apply(this,[a,b]);returnq(a),c},d.declareService=l.declareService,d.declareAcquiredMethod=l.declareAcquiredMethod,d.allowPublicAcquisition=l.allowPublicAcquisition,d.prototype.__aq_parent=function(a,b){returnnewc.Promise(function(c,d){n.call({method:"acquire",params:[a,b],success:function(a){c(a)},error:function(a){d(a)}})})}),d.prototype.__acquired_method_dict={},x=d,a.addEventListener("DOMContentLoaded",y,!1)}),v.push(function(){returny}).push(function(c){functione(){returnc}varf;for(b.top!==b.self&&d.ready(function(){varb=a.createElement("base");returnc.__aq_parent("getTopURL",[]).then(function(c){b.href=c,b.target="_top",a.head.appendChild(b)})}),d.ready(function(a){returnp(a)}),v.push(e),f=0;f<d.__ready_list.length;f+=1)v.push(d.__ready_list[f]).push(e)}),b.self===b.top?v.fail(function(a){throwj(a),a}):v.then(function(){A=!0,o()}).fail(function(a){thrown.notify({method:"failed",params:a.toString()}),a})}varx,y,z,A,B={},C={},D={};k.prototype=newError,k.prototype.constructor=k,A=function(){functiona(){vara,b=h.length;for(a=0;b>a;a+=1)h[a].cancel();h=[]}varb,d,e,f,g=this,h=[];returnthisinstanceofA?(b=newc.Promise(function(b,c,h){d=function(b){returnf?void0:(g.isRejected=!0,g.rejectedReason=b,f=!0,a(),c(b))},e=h},a),g.cancel=function(){f||(f=!0,b.cancel(),b.fail(function(a){g.isRejected=!0,g.rejectedReason=a}))},g.then=function(){returnb.then.apply(b,arguments)},g.fail=function(){returnb.fail.apply(b,arguments)},g.monitor=function(a){if(f)thrownewk;varb=(newc.Queue).push(function(){returna}).push(function(){vara,b,c=h.length,d=[];for(b=0;c>b;b+=1)a=h[b],a.isFulfilled||a.isRejected||d.push(a);h=d},function(b){throwbinstanceofc.CancellationError&&(a.isFulfilled&&a.isRejected||a.cancel()),d(b),b},function(a){returne(a),a});returnh.push(b),this},void0):newA},A.prototype=Object.create(Promise.prototype),A.prototype.constructor=A,l.prototype.__title="",l.prototype.__interface_list=[],l.prototype.__path="",l.prototype.__html="",l.prototype.__required_css_list=[],l.prototype.__required_js_list=[],l.__ready_list=[n,o],l.ready=function(a){returnthis.__ready_list.push(a),this},l.__service_list=[],l.declareService=function(a){returnthis.__service_list.push(a),this},l.declareMethod=function(a,b){returnthis.prototype[a]=function(){vara=this,d=arguments;return(newc.Queue).push(function(){returnb.apply(a,d)})},this},l.declareMethod("getInterfaceList",function(){returnthis.__interface_list}).declareMethod("getRequiredCSSList",function(){returnthis.__required_css_list}).declareMethod("getRequiredJSList",function(){returnthis.__required_js_list}).declareMethod("getPath",function(){returnthis.__path}).declareMethod("getTitle",function(){returnthis.__title}).declareMethod("getElement",function(){if(this.__element===h)thrownewError("No element defined");returnthis.__element}),l.declareAcquiredMethod=function(a,b){returnthis.prototype[a]=function(){vara=Array.prototype.slice.call(arguments,0),d=this;return(newc.Queue).push(function(){returnd.__aq_parent(b,a)})},this},l.declareAcquiredMethod("aq_reportServiceError","reportServiceError"),l.allowPublicAcquisition=function(a,b){returnthis.prototype.__acquired_method_dict[a]=b,this},s.__ready_list=l.__ready_list.slice(),s.__service_list=l.__service_list.slice(),s.ready=l.ready,s.declareService=l.declareService,s.prototype=newl,s.prototype.constructor=s,u.__ready_list=l.__ready_list.slice(),u.ready=l.ready,u.__service_list=l.__service_list.slice(),u.declareService=l.declareService,u.prototype=newl,u.prototype.constructor=u,l.declareMethod("declareGadget",function(b,d){vare,f,g=this,i=y;returnd===h&&(d={}),d.sandbox===h&&(d.sandbox="public"),b=z.getAbsoluteURL(b,this.__path),y=(newc.Queue).push(function(){returni}).push(h,function(){}).push(function(){vara;if("public"===d.sandbox)a=t;else{if("iframe"!==d.sandbox)thrownewError("Unsupported sandbox options '"+d.sandbox+"'");a=v}returna(b,d,g)}).push(function(a){returnx=h,a}).push(h,function(a){throwx=h,a}),f=y,e=(newc.Queue).push(function(){returnf}).push(function(c){functionf(){returnc}vari;for(i=0;i<c.constructor.__ready_list.length;i+=1)e.push(c.constructor.__ready_list[i]),e.push(f);returnd.scope!==h&&(g.__sub_gadget_dict[d.scope]=c,c.__element.setAttribute("data-gadget-scope",d.scope)),c.__element.setAttribute("data-gadget-url",b),c.__element.setAttribute("data-gadget-sandbox",d.sandbox),c.__element._gadget=c,a.contains(c.__element)&&e.push(p),e.push(f),c})}).declareMethod("getDeclaredGadget",function(a){if(!this.__sub_gadget_dict.hasOwnProperty(a))thrownewError("Gadget scope '"+a+"' is not known.");returnthis.__sub_gadget_dict[a]}).declareMethod("dropGadget",function(a){if(!this.__sub_gadget_dict.hasOwnProperty(a))thrownewError("Gadget scope '"+a+"' is not known.");deletethis.__sub_gadget_dict[a]}),z=function(a){varc;if(a===b&&(c=x),c===h)thrownewError("Unknown selector '"+a+"'");returnc},z.AcquisitionError=function(a){if(this.name="AcquisitionError",a!==h&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Acquisition failed"},z.AcquisitionError.prototype=newError,z.AcquisitionError.prototype.constructor=z.AcquisitionError,z.getAbsoluteURL=function(a,b){varc,e,f,g="<!doctype><html><head></head></html>",h=newRegExp("^(?:[a-z]+:)?//|data:","i");returna&&b&&!h.test(a)?(c=(newd).parseFromString(g,"text/html"),e=c.createElement("base"),f=c.createElement("link"),c.head.appendChild(e),c.head.appendChild(f),e.href=b,f.href=a,f.href):a},z.declareJS=function(b){vard;returnd=C.hasOwnProperty(b)?c.resolve():newc.Promise(function(c,d){vare;e=a.createElement("script"),e.type="text/javascript",e.src=b,e.onload=function(){C[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},z.declareCSS=function(b){vard;returnd=D.hasOwnProperty(b)?c.resolve():newc.Promise(function(c,d){vare;e=a.createElement("link"),e.rel="stylesheet",e.type="text/css",e.href=b,e.onload=function(){D[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},z.declareGadgetKlass=function(a){functionb(){varb,c,e;if(!B.hasOwnProperty(a)){b=function(){l.call(this)},b.__ready_list=l.__ready_list.slice(),b.__service_list=l.__service_list.slice(),b.declareMethod=l.declareMethod,b.declareAcquiredMethod=l.declareAcquiredMethod,b.allowPublicAcquisition=l.allowPublicAcquisition,b.ready=l.ready,b.declareService=l.declareService,b.prototype=newl,b.prototype.constructor=b,b.prototype.__path=a,b.prototype.__acquired_method_dict={},b.__template_element=(newd).parseFromString(i.responseText,"text/html"),e=z.parseGadgetHTMLDocument(b.__template_element,a);for(cine)e.hasOwnProperty(c)&&(b.prototype["__"+c]=e[c]);B[a]=b}returnB[a]}functione(c,d){functione(){vara;try{0===i.readyState?d(i):4===i.readyState&&(i.status<200||i.status>=300||!/^text\/html[;]?/.test(i.getResponseHeader("Content-Type")||"")?d(i):(a=b(),c(a)))}catch(e){d(e)}}i=newXMLHttpRequest,i.open("GET",a),i.onreadystatechange=e,i.setRequestHeader("Accept","text/html"),i.withCredentials=!0,i.send()}functionf(){i!==h&&i.readyState!==i.DONE&&i.abort()}varg,i;returng=B.hasOwnProperty(a)?c.resolve(B[a]):newc.Promise(e,f)},z.clearGadgetKlassList=function(){B={},C={},D={}},z.parseGadgetHTMLDocument=function(a,b){varc,d,e={title:"",interface_list:[],required_css_list:[],required_js_list:[]},f=newRegExp("^(?:[a-z]+:)?//","i");if(!b||!f.test(b))thrownewError("The url should be absolute: "+b);if(9!==a.nodeType)thrownewError("The first parameter should be an HTMLDocument");for(e.title=a.title,c=0;c<a.head.children.length;c+=1)d=a.head.children[c],null!==d.href&&("stylesheet"===d.rel?e.required_css_list.push(z.getAbsoluteURL(d.getAttribute("href"),b)):"SCRIPT"!==d.nodeName||"text/javascript"!==d.type&&d.type?"http://www.renderjs.org/rel/interface"===d.rel&&e.interface_list.push(z.getAbsoluteURL(d.getAttribute("href"),b)):e.required_js_list.push(z.getAbsoluteURL(d.getAttribute("src"),b)));returne},b.rJS=b.renderJS=z,b.__RenderJSGadget=l,b.__RenderJSEmbeddedGadget=s,b.__RenderJSIframeGadget=u,w()}(document,window,RSVP,DOMParser,Channel,MutationObserver,Node);
varChannel=function(){"use strict";functiona(a,b,c,d){functionf(b){for(varc=0;c<b.length;c++)if(b[c].win===a)return!0;return!1}varg=!1;if("*"===b){for(varhine)if(e.hasOwnProperty(h)&&"*"!==h&&"object"==typeofe[h][c]&&(g=f(e[h][c])))break}elsee["*"]&&e["*"][c]&&(g=f(e["*"][c])),!g&&e[b]&&e[b][c]&&(g=f(e[b][c]));if(g)throw"A channel is already bound to the same window which overlaps with origin '"+b+"' and has scope '"+c+"'";"object"!=typeofe[b]&&(e[b]={}),"object"!=typeofe[b][c]&&(e[b][c]=[]),e[b][c].push({win:a,handler:d})}functionb(a,b,c){for(vard=e[b][c],f=0;f<d.length;f++)d[f].win===a&&d.splice(f,1);0===e[b][c].length&&deletee[b][c]}functionc(a){returnArray.isArray?Array.isArray(a):-1!=a.constructor.toString().indexOf("Array")}vard=Math.floor(1000001*Math.random()),e={},f={},g=function(a){try{varb=JSON.parse(a.data);if("object"!=typeofb||null===b)throw"malformed"}catch(a){return}varc,d,g,h=a.source,i=a.origin;if("string"==typeofb.method){varj=b.method.split("::");2==j.length?(c=j[0],g=j[1]):g=b.method}if("undefined"!=typeofb.id&&(d=b.id),"string"==typeofg){vark=!1;if(e[i]&&e[i][c])for(varl=0;l<e[i][c].length;l++)if(e[i][c][l].win===h){e[i][c][l].handler(i,g,b),k=!0;break}if(!k&&e["*"]&&e["*"][c])for(varl=0;l<e["*"][c].length;l++)if(e["*"][c][l].win===h){e["*"][c][l].handler(i,g,b);break}}else"undefined"!=typeofd&&f[d]&&f[d](i,g,b)};returnwindow.addEventListener?window.addEventListener("message",g,!1):window.attachEvent&&window.attachEvent("onmessage",g),{build:function(e){varg=function(a){if(e.debugOutput&&window.console&&window.console.log){try{"string"!=typeofa&&(a=JSON.stringify(a))}catch(b){}console.log("["+j+"] "+a)}};if(!window.postMessage)throw"jschannel cannot run this browser, no postMessage";if(!window.JSON||!window.JSON.stringify||!window.JSON.parse)throw"jschannel cannot run this browser, no JSON parsing/serialization";if("object"!=typeofe)throw"Channel build invoked without a proper object argument";if(!e.window||!e.window.postMessage)throw"Channel.build() called without a valid window argument";if(window===e.window)throw"target window is same as present window -- not allowed";varh=!1;if("string"==typeofe.origin){vari;"*"===e.origin?h=!0:null!==(i=e.origin.match(/^https?:\/\/(?:[-a-zA-Z0-9_\.])+(?::\d+)?/))&&(e.origin=i[0].toLowerCase(),h=!0)}if(!h)throw"Channel.build() called with an invalid origin";if("undefined"!=typeofe.scope){if("string"!=typeofe.scope)throw"scope, when specified, must be a string";if(e.scope.split("::").length>1)throw"scope may not contain double colons: '::'"}varj=function(){for(vara="",b="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",c=0;5>c;c++)a+=b.charAt(Math.floor(Math.random()*b.length));returna}(),k={},l={},m={},n=!1,o=[],p=function(a,b,c){vard=!1,e=!1;return{origin:b,invoke:function(b,d){if(!m[a])throw"attempting to invoke a callback of a nonexistent transaction: "+a;for(vare=!1,f=0;f<c.length;f++)if(b===c[f]){e=!0;break}if(!e)throw"request supports no such callback '"+b+"'";t({id:a,callback:b,params:d})},error:function(b,c){if(e=!0,!m[a])throw"error called for nonexistent message: "+a;deletem[a],t({id:a,error:b,message:c})},complete:function(b){if(e=!0,!m[a])throw"complete called for nonexistent message: "+a;deletem[a],t({id:a,result:b})},delayReturn:function(a){return"boolean"==typeofa&&(d=a===!0),d},completed:function(){returne}}},q=function(a,b,c){returnwindow.setTimeout(function(){if(l[a]){vard="timeout ("+b+"ms) exceeded on method '"+c+"'";l[a].error("timeout_error",d),deletel[a],deletef[a]}},b)},r=function(a,b,d){if("function"==typeofe.gotMessageObserver)try{e.gotMessageObserver(a,d)}catch(h){g("gotMessageObserver() raised an exception: "+h.toString())}if(d.id&&b){if(k[b]){vari=p(d.id,a,d.callbacks?d.callbacks:[]);m[d.id]={};try{if(d.callbacks&&c(d.callbacks)&&d.callbacks.length>0)for(varj=0;j<d.callbacks.length;j++){for(varn=d.callbacks[j],o=d.params,q=n.split("/"),r=0;r<q.length-1;r++){vars=q[r];"object"!=typeofo[s]&&(o[s]={}),o=o[s]}o[q[q.length-1]]=function(){vara=n;returnfunction(b){returni.invoke(a,b)}}()}vart=k[b](i,d.params);i.delayReturn()||i.completed()||i.complete(t)}catch(h){varu="runtime_error",v=null;if("string"==typeofh?v=h:"object"==typeofh&&(h&&c(h)&&2==h.length?(u=h[0],v=h[1]):"string"==typeofh.error&&(u=h.error,h.message?"string"==typeofh.message?v=h.message:h=h.message:v="")),null===v)try{v=JSON.stringify(h),"undefined"==typeofv&&(v=h.toString())}catch(w){v=h.toString()}i.error(u,v)}}}elsed.id&&d.callback?l[d.id]&&l[d.id].callbacks&&l[d.id].callbacks[d.callback]?l[d.id].callbacks[d.callback](d.params):g("ignoring invalid callback, id:"+d.id+" ("+d.callback+")"):d.id?l[d.id]?(d.error?l[d.id].error(d.error,d.message):void0!==d.result?l[d.id].success(d.result):l[d.id].success(),deletel[d.id],deletef[d.id]):g("ignoring invalid response: "+d.id):b&&k[b]&&k[b]({origin:a},d.params)};a(e.window,e.origin,"string"==typeofe.scope?e.scope:"",r);vars=function(a){return"string"==typeofe.scope&&e.scope.length&&(a=[e.scope,a].join("::")),a},t=function(a,b){if(!a)throw"postMessage called with null message";varc=n?"post ":"queue ";if(g(c+" message: "+JSON.stringify(a)),b||n){if("function"==typeofe.postMessageObserver)try{e.postMessageObserver(e.origin,a)}catch(d){g("postMessageObserver() raised an exception: "+d.toString())}e.window.postMessage(JSON.stringify(a),e.origin)}elseo.push(a)},u=function(a,b){if(g("ready msg received"),n)throw"received ready message while in ready state. help!";for(j+="ping"===b?"-R":"-L",v.unbind("__ready"),n=!0,g("ready msg accepted."),"ping"===b&&v.notify({method:"__ready",params:"pong"});o.length;)t(o.pop());"function"==typeofe.onReady&&e.onReady(v)},v={unbind:function(a){if(k[a]){if(!deletek[a])throw"can't delete method: "+a;return!0}return!1},bind:function(a,b){if(!a||"string"!=typeofa)throw"'method' argument to bind must be string";if(!b||"function"!=typeofb)throw"callback missing from bind params";if(k[a])throw"method '"+a+"' is already bound!";returnk[a]=b,this},call:function(a){if(!a)throw"missing arguments to call function";if(!a.method||"string"!=typeofa.method)throw"'method' argument to call must be string";if(!a.success||"function"!=typeofa.success)throw"'success' callback missing from call";varb={},c=[],e=function(a,d){if("object"==typeofd)for(varfind)if(d.hasOwnProperty(f)){varg=a+(a.length?"/":"")+f;"function"==typeofd[f]?(b[g]=d[f],c.push(g),deleted[f]):"object"==typeofd[f]&&e(g,d[f])}};e("",a.params);varg={id:d,method:s(a.method),params:a.params};c.length&&(g.callbacks=c),a.timeout&&q(d,a.timeout,s(a.method)),l[d]={callbacks:b,error:a.error,success:a.success},f[d]=r,d++,t(g)},notify:function(a){if(!a)throw"missing arguments to notify function";if(!a.method||"string"!=typeofa.method)throw"'method' argument to notify must be string";t({method:s(a.method),params:a.params})},destroy:function(){b(e.window,e.origin,"string"==typeofe.scope?e.scope:""),window.removeEventListener?window.removeEventListener("message",r,!1):window.detachEvent&&window.detachEvent("onmessage",r),n=!1,k={},m={},l={},e.origin=null,o=[],g("channel destroyed"),j=""}};returnv.bind("__ready",u),setTimeout(function(){t({method:s("__ready"),params:"ping"},!0)},0),v}}}();!function(a){"use strict";varb=a.prototype,c=b.parseFromString;try{if((newa).parseFromString("","text/html"))return}catch(d){}b.parseFromString=function(a,b){vard,e,f,g;return/^\s*text\/html\s*(?:;|$)/i.test(b)?(e=document.implementation.createHTMLDocument(""),f=e.documentElement,f.innerHTML=a,g=f.firstElementChild,1===f.childElementCount&&"html"===g.localName.toLowerCase()&&e.replaceChild(g,f),d=e):d=c.apply(this,arguments),d}}(DOMParser),function(a,b,c,d,e,f){"use strict";functiong(a){varb=a.indexOf("#");returnb>0&&(a=a.substring(0,b)),a}functionh(){returnthisinstanceofh?void0:newh}functioni(a){a.__sub_gadget_dict={}}functionj(a){varb,d,e,g,h,i=a.__element.querySelectorAll("[data-gadget-scope]"),j=[];for(h=0;h<i.length;h+=1)b=i[h],d=b.getAttribute("data-gadget-scope"),e=b.getAttribute("data-gadget-url"),g=b.getAttribute("data-gadget-sandbox"),null!==d&&null!==e&&j.push(a.declareGadget(e,{element:b,scope:d||f,sandbox:g||f}));returnc.all(j)}functionk(a,b,d){vare,g,h=this;for(einh.__sub_gadget_dict)h.__sub_gadget_dict.hasOwnProperty(e)&&h.__sub_gadget_dict[e]===a&&(g=e);return(newc.Queue).push(function(){vara=h.__acquired_method_dict||{};if(a.hasOwnProperty(b))returna[b].apply(h,[d,g]);thrownewt.AcquisitionError("aq_dynamic is not defined")}).push(f,function(a){if(ainstanceoft.AcquisitionError)returnh.__aq_parent(b,d);throwa})}functionl(a,b){a.__aq_parent=function(c,d){returnk.apply(b,[a,c,d])}}functionm(){returnthisinstanceofm?(h.call(this),void0):newm}functionn(b,d,e){functiong(a,b){returnfunction(){returna(b)}}varh;returnd.element===f&&(d.element=a.createElement("div")),(newc.Queue).push(function(){returnt.declareGadgetKlass(b)}).push(function(a){varb,f=a.__template_element.body.childNodes;for(r=a,h=newa,h.__element=d.element,b=0;b<f.length;b+=1)h.__element.appendChild(f[b].cloneNode(!0));returnl(h,e),c.all([h.getRequiredJSList(),h.getRequiredCSSList()])}).push(function(a){varb,d=newc.Queue;for(b=0;b<a[0].length;b+=1)d.push(g(t.declareJS,a[0][b]));for(b=0;b<a[1].length;b+=1)d.push(g(t.declareCSS,a[1][b]));returnd}).push(function(){returnh})}functiono(){returnthisinstanceofo?(h.call(this),void0):newo}functionp(b,d,g){varh,i,j,k=c.defer();if(d.element===f)thrownewError("DOM element is required to create Iframe Gadget "+b);for(j=d.element.parentNode;null!==j&&j!==a;)j=j.parentNode;if(null===j)thrownewError("The parent element is not attached to the DOM for "+b);returnh=newo,l(h,g),i=a.createElement("iframe"),i.setAttribute("src",b),h.__path=b,h.__element=d.element,d.element.appendChild(i),h.__chan=e.build({window:i.contentWindow,origin:"*",scope:"renderJS"}),h.__chan.bind("declareMethod",function(a,b){returnh[b]=function(){vara=arguments;returnnewc.Promise(function(c,d){h.__chan.call({method:"methodCall",params:[b,Array.prototype.slice.call(a,0)],success:function(a){c(a)},error:function(a){d(a)}})})},"OK"}),h.__chan.bind("ready",function(){returnk.resolve(h),"OK"}),h.__chan.bind("failed",function(a,b){returnk.reject(b),"OK"}),h.__chan.bind("acquire",function(a,b){h.__aq_parent.apply(h,b).then(function(b){a.complete(b)}).fail(function(b){a.error(b.toString())}),a.delayReturn(!0)}),c.any([k.promise,c.timeout(5e3)])}functionq(){vard,i,j,k,n,o,p=g(b.location.href),q=newc.Queue,x=0,y=!1;if(u.hasOwnProperty(p))thrownewError("bootstrap should not be called twice");s=newc.Promise(function(g,q){functions(){varb,e,h=t.parseGadgetHTMLDocument(a,p);for(einh)h.hasOwnProperty(e)&&(d.prototype["__"+e]=h[e]);for(d.__template_element=a.createElement("div"),i.__element=a.body,b=0;b<i.__element.childNodes.length;b+=1)d.__template_element.appendChild(i.__element.childNodes[b].cloneNode(!0));c.all([i.getRequiredJSList(),i.getRequiredCSSList()]).then(function(a){varb,c=a[0],d=a[1];for(b=0;b<c.length;b+=1)v[c[b]]=null;for(b=0;b<d.length;b+=1)w[d[b]]=null;returnr=f,i}).then(g,function(a){throwq(a),console.error(a),a})}b.self===b.top?(o=newh,o.__acquired_method_dict={getTopURL:function(){returnp}},o.__aq_parent=function(a){thrownewt.AcquisitionError("No gadget provides "+a)},d=function(){h.call(this)},d.declareMethod=h.declareMethod,d.declareAcquiredMethod=h.declareAcquiredMethod,d.allowPublicAcquisition=h.allowPublicAcquisition,d.__ready_list=h.__ready_list.slice(),d.ready=h.ready,d.prototype=newh,d.prototype.constructor=d,d.prototype.__path=p,u[p]=d,i=newu[p],l(i,o)):(j=e.build({window:b.parent,origin:"*",scope:"renderJS"}),d=m,d.__ready_list=h.__ready_list.slice(),d.prototype.__path=p,i=newm,j.bind("methodCall",function(a,b){i[b[0]].apply(i,b[1]).then(function(b){a.complete(b)}).fail(function(b){a.error(b.toString())}),a.delayReturn(!0)}),k=function(){0===x&&y===!0&&j.notify({method:"ready"})},n=function(a){x+=1,j.call({method:"declareMethod",params:a,success:function(){x-=1,k()},error:function(){x-=1}})},n("getInterfaceList"),n("getRequiredCSSList"),n("getRequiredJSList"),n("getPath"),n("getTitle"),d.declareMethod=function(a,b){varc=h.declareMethod.apply(this,[a,b]);returnn(a),c},d.declareAcquiredMethod=h.declareAcquiredMethod,d.allowPublicAcquisition=h.allowPublicAcquisition,d.prototype.__aq_parent=function(a,b){returnnewc.Promise(function(c,d){j.call({method:"acquire",params:[a,b],success:function(a){c(a)},error:function(a){d(a)}})})}),d.prototype.__acquired_method_dict={},r=d,a.addEventListener("DOMContentLoaded",s,!1)}),q.push(function(){returns}).push(function(c){functione(){returnc}varf;for(b.top!==b.self&&d.ready(function(){varb=a.createElement("base");returnc.__aq_parent("getTopURL",[]).then(function(c){b.href=c,b.target="_top",a.head.appendChild(b)})}),q.push(e),f=0;f<d.__ready_list.length;f+=1)q.push(d.__ready_list[f]).push(e)}),b.self!==b.top&&q.then(function(){y=!0,k()}).fail(function(a){throwj.notify({method:"failed",params:a.toString()}),a})}varr,s,t,u={},v={},w={};h.prototype.__title="",h.prototype.__interface_list=[],h.prototype.__path="",h.prototype.__html="",h.prototype.__required_css_list=[],h.prototype.__required_js_list=[],h.__ready_list=[i,j],h.ready=function(a){returnthis.__ready_list.push(a),this},h.declareMethod=function(a,b){returnthis.prototype[a]=function(){vara=this,d=arguments;return(newc.Queue).push(function(){returnb.apply(a,d)})},this},h.declareMethod("getInterfaceList",function(){returnthis.__interface_list}).declareMethod("getRequiredCSSList",function(){returnthis.__required_css_list}).declareMethod("getRequiredJSList",function(){returnthis.__required_js_list}).declareMethod("getPath",function(){returnthis.__path}).declareMethod("getTitle",function(){returnthis.__title}).declareMethod("getElement",function(){if(this.__element===f)thrownewError("No element defined");returnthis.__element}),h.declareAcquiredMethod=function(a,b){returnthis.prototype[a]=function(){vara=Array.prototype.slice.call(arguments,0),d=this;return(newc.Queue).push(function(){returnd.__aq_parent(b,a)})},this},h.allowPublicAcquisition=function(a,b){returnthis.prototype.__acquired_method_dict[a]=b,this},m.__ready_list=h.__ready_list.slice(),m.ready=h.ready,m.prototype=newh,m.prototype.constructor=m,o.__ready_list=h.__ready_list.slice(),o.ready=h.ready,o.prototype=newh,o.prototype.constructor=o,h.declareMethod("declareGadget",function(a,b){vard,e,g=this,h=s;returnb===f&&(b={}),b.sandbox===f&&(b.sandbox="public"),a=t.getAbsoluteURL(a,this.__path),s=(newc.Queue).push(function(){returnh}).push(f,function(){}).push(function(){varc;if("public"===b.sandbox)c=n;else{if("iframe"!==b.sandbox)thrownewError("Unsupported sandbox options '"+b.sandbox+"'");c=p}returnc(a,b,g)}).push(function(a){returnr=f,a}).push(f,function(a){throwr=f,a}),e=s,d=(newc.Queue).push(function(){returne}).push(function(c){functione(){returnc}varh;for(h=0;h<c.constructor.__ready_list.length;h+=1)d.push(c.constructor.__ready_list[h]),d.push(e);returnb.scope!==f&&(g.__sub_gadget_dict[b.scope]=c,c.__element.setAttribute("data-gadget-scope",b.scope)),c.__element.setAttribute("data-gadget-url",a),c.__element.setAttribute("data-gadget-sandbox",b.sandbox),c})}).declareMethod("getDeclaredGadget",function(a){if(!this.__sub_gadget_dict.hasOwnProperty(a))thrownewError("Gadget scope '"+a+"' is not known.");returnthis.__sub_gadget_dict[a]}).declareMethod("dropGadget",function(a){if(!this.__sub_gadget_dict.hasOwnProperty(a))thrownewError("Gadget scope '"+a+"' is not known.");deletethis.__sub_gadget_dict[a]}),t=function(a){varc;if(a===b&&(c=r),c===f)thrownewError("Unknown selector '"+a+"'");returnc},t.AcquisitionError=function(a){if(this.name="AcquisitionError",a!==f&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Acquisition failed"},t.AcquisitionError.prototype=newError,t.AcquisitionError.prototype.constructor=t.AcquisitionError,t.getAbsoluteURL=function(a,b){varc,e,f,g="<!doctype><html><head></head></html>",h=newRegExp("^(?:[a-z]+:)?//|data:","i");returna&&b&&!h.test(a)?(c=(newd).parseFromString(g,"text/html"),e=c.createElement("base"),f=c.createElement("link"),c.head.appendChild(e),c.head.appendChild(f),e.href=b,f.href=a,f.href):a},t.declareJS=function(b){vard;returnd=v.hasOwnProperty(b)?c.resolve():newc.Promise(function(c,d){vare;e=a.createElement("script"),e.type="text/javascript",e.src=b,e.onload=function(){v[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},t.declareCSS=function(b){vard;returnd=w.hasOwnProperty(b)?c.resolve():newc.Promise(function(c,d){vare;e=a.createElement("link"),e.rel="stylesheet",e.type="text/css",e.href=b,e.onload=function(){w[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},t.declareGadgetKlass=function(a){functionb(){varb,c,e;if(!u.hasOwnProperty(a)){b=function(){h.call(this)},b.__ready_list=h.__ready_list.slice(),b.declareMethod=h.declareMethod,b.declareAcquiredMethod=h.declareAcquiredMethod,b.allowPublicAcquisition=h.allowPublicAcquisition,b.ready=h.ready,b.prototype=newh,b.prototype.constructor=b,b.prototype.__path=a,b.prototype.__acquired_method_dict={},b.__template_element=(newd).parseFromString(j.responseText,"text/html"),e=t.parseGadgetHTMLDocument(b.__template_element,a);for(cine)e.hasOwnProperty(c)&&(b.prototype["__"+c]=e[c]);u[a]=b}returnu[a]}functione(c,d){functione(){vara;try{0===j.readyState?d(j):4===j.readyState&&(j.status<200||j.status>=300||!/^text\/html[;]?/.test(j.getResponseHeader("Content-Type")||"")?d(j):(a=b(),c(a)))}catch(e){d(e)}}j=newXMLHttpRequest,j.open("GET",a),j.onreadystatechange=e,j.setRequestHeader("Accept","text/html"),j.withCredentials=!0,j.send()}functiong(){j!==f&&j.readyState!==j.DONE&&j.abort()}vari,j;returni=u.hasOwnProperty(a)?c.resolve(u[a]):newc.Promise(e,g)},t.clearGadgetKlassList=function(){u={},v={},w={}},t.parseGadgetHTMLDocument=function(a,b){varc,d,e={title:"",interface_list:[],required_css_list:[],required_js_list:[]},f=newRegExp("^(?:[a-z]+:)?//","i");if(!b||!f.test(b))thrownewError("The url should be absolute: "+b);if(9!==a.nodeType)thrownewError("The first parameter should be an HTMLDocument");for(e.title=a.title,c=0;c<a.head.children.length;c+=1)d=a.head.children[c],null!==d.href&&("stylesheet"===d.rel?e.required_css_list.push(t.getAbsoluteURL(d.getAttribute("href"),b)):"SCRIPT"!==d.nodeName||"text/javascript"!==d.type&&d.type?"http://www.renderjs.org/rel/interface"===d.rel&&e.interface_list.push(t.getAbsoluteURL(d.getAttribute("href"),b)):e.required_js_list.push(t.getAbsoluteURL(d.getAttribute("src"),b)));returne},b.rJS=b.renderJS=t,b.__RenderJSGadget=h,b.__RenderJSEmbeddedGadget=m,b.__RenderJSIframeGadget=o,q()}(document,window,RSVP,DOMParser,Channel);
\ No newline at end of file
varChannel=function(){"use strict";functiona(a,b,c,d){functionf(b){for(varc=0;c<b.length;c++)if(b[c].win===a)return!0;return!1}varg=!1;if("*"===b){for(varhine)if(e.hasOwnProperty(h)&&"*"!==h&&"object"==typeofe[h][c]&&(g=f(e[h][c])))break}elsee["*"]&&e["*"][c]&&(g=f(e["*"][c])),!g&&e[b]&&e[b][c]&&(g=f(e[b][c]));if(g)throw"A channel is already bound to the same window which overlaps with origin '"+b+"' and has scope '"+c+"'";"object"!=typeofe[b]&&(e[b]={}),"object"!=typeofe[b][c]&&(e[b][c]=[]),e[b][c].push({win:a,handler:d})}functionb(a,b,c){for(vard=e[b][c],f=0;f<d.length;f++)d[f].win===a&&d.splice(f,1);0===e[b][c].length&&deletee[b][c]}functionc(a){returnArray.isArray?Array.isArray(a):-1!=a.constructor.toString().indexOf("Array")}vard=Math.floor(1000001*Math.random()),e={},f={},g=function(a){try{varb=JSON.parse(a.data);if("object"!=typeofb||null===b)throw"malformed"}catch(a){return}varc,d,g,h=a.source,i=a.origin;if("string"==typeofb.method){varj=b.method.split("::");2==j.length?(c=j[0],g=j[1]):g=b.method}if("undefined"!=typeofb.id&&(d=b.id),"string"==typeofg){vark=!1;if(e[i]&&e[i][c])for(varl=0;l<e[i][c].length;l++)if(e[i][c][l].win===h){e[i][c][l].handler(i,g,b),k=!0;break}if(!k&&e["*"]&&e["*"][c])for(varl=0;l<e["*"][c].length;l++)if(e["*"][c][l].win===h){e["*"][c][l].handler(i,g,b);break}}else"undefined"!=typeofd&&f[d]&&f[d](i,g,b)};returnwindow.addEventListener?window.addEventListener("message",g,!1):window.attachEvent&&window.attachEvent("onmessage",g),{build:function(e){varg=function(a){if(e.debugOutput&&window.console&&window.console.log){try{"string"!=typeofa&&(a=JSON.stringify(a))}catch(b){}console.log("["+j+"] "+a)}};if(!window.postMessage)throw"jschannel cannot run this browser, no postMessage";if(!window.JSON||!window.JSON.stringify||!window.JSON.parse)throw"jschannel cannot run this browser, no JSON parsing/serialization";if("object"!=typeofe)throw"Channel build invoked without a proper object argument";if(!e.window||!e.window.postMessage)throw"Channel.build() called without a valid window argument";if(window===e.window)throw"target window is same as present window -- not allowed";varh=!1;if("string"==typeofe.origin){vari;"*"===e.origin?h=!0:null!==(i=e.origin.match(/^https?:\/\/(?:[-a-zA-Z0-9_\.])+(?::\d+)?/))&&(e.origin=i[0].toLowerCase(),h=!0)}if(!h)throw"Channel.build() called with an invalid origin";if("undefined"!=typeofe.scope){if("string"!=typeofe.scope)throw"scope, when specified, must be a string";if(e.scope.split("::").length>1)throw"scope may not contain double colons: '::'"}varj=function(){for(vara="",b="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",c=0;5>c;c++)a+=b.charAt(Math.floor(Math.random()*b.length));returna}(),k={},l={},m={},n=!1,o=[],p=function(a,b,c){vard=!1,e=!1;return{origin:b,invoke:function(b,d){if(!m[a])throw"attempting to invoke a callback of a nonexistent transaction: "+a;for(vare=!1,f=0;f<c.length;f++)if(b===c[f]){e=!0;break}if(!e)throw"request supports no such callback '"+b+"'";t({id:a,callback:b,params:d})},error:function(b,c){if(e=!0,!m[a])throw"error called for nonexistent message: "+a;deletem[a],t({id:a,error:b,message:c})},complete:function(b){if(e=!0,!m[a])throw"complete called for nonexistent message: "+a;deletem[a],t({id:a,result:b})},delayReturn:function(a){return"boolean"==typeofa&&(d=a===!0),d},completed:function(){returne}}},q=function(a,b,c){returnwindow.setTimeout(function(){if(l[a]){vard="timeout ("+b+"ms) exceeded on method '"+c+"'";l[a].error("timeout_error",d),deletel[a],deletef[a]}},b)},r=function(a,b,d){if("function"==typeofe.gotMessageObserver)try{e.gotMessageObserver(a,d)}catch(h){g("gotMessageObserver() raised an exception: "+h.toString())}if(d.id&&b){if(k[b]){vari=p(d.id,a,d.callbacks?d.callbacks:[]);m[d.id]={};try{if(d.callbacks&&c(d.callbacks)&&d.callbacks.length>0)for(varj=0;j<d.callbacks.length;j++){for(varn=d.callbacks[j],o=d.params,q=n.split("/"),r=0;r<q.length-1;r++){vars=q[r];"object"!=typeofo[s]&&(o[s]={}),o=o[s]}o[q[q.length-1]]=function(){vara=n;returnfunction(b){returni.invoke(a,b)}}()}vart=k[b](i,d.params);i.delayReturn()||i.completed()||i.complete(t)}catch(h){varu="runtime_error",v=null;if("string"==typeofh?v=h:"object"==typeofh&&(h&&c(h)&&2==h.length?(u=h[0],v=h[1]):"string"==typeofh.error&&(u=h.error,h.message?"string"==typeofh.message?v=h.message:h=h.message:v="")),null===v)try{v=JSON.stringify(h),"undefined"==typeofv&&(v=h.toString())}catch(w){v=h.toString()}i.error(u,v)}}}elsed.id&&d.callback?l[d.id]&&l[d.id].callbacks&&l[d.id].callbacks[d.callback]?l[d.id].callbacks[d.callback](d.params):g("ignoring invalid callback, id:"+d.id+" ("+d.callback+")"):d.id?l[d.id]?(d.error?l[d.id].error(d.error,d.message):void0!==d.result?l[d.id].success(d.result):l[d.id].success(),deletel[d.id],deletef[d.id]):g("ignoring invalid response: "+d.id):b&&k[b]&&k[b]({origin:a},d.params)};a(e.window,e.origin,"string"==typeofe.scope?e.scope:"",r);vars=function(a){return"string"==typeofe.scope&&e.scope.length&&(a=[e.scope,a].join("::")),a},t=function(a,b){if(!a)throw"postMessage called with null message";varc=n?"post ":"queue ";if(g(c+" message: "+JSON.stringify(a)),b||n){if("function"==typeofe.postMessageObserver)try{e.postMessageObserver(e.origin,a)}catch(d){g("postMessageObserver() raised an exception: "+d.toString())}e.window.postMessage(JSON.stringify(a),e.origin)}elseo.push(a)},u=function(a,b){if(g("ready msg received"),n)throw"received ready message while in ready state. help!";for(j+="ping"===b?"-R":"-L",v.unbind("__ready"),n=!0,g("ready msg accepted."),"ping"===b&&v.notify({method:"__ready",params:"pong"});o.length;)t(o.pop());"function"==typeofe.onReady&&e.onReady(v)},v={unbind:function(a){if(k[a]){if(!deletek[a])throw"can't delete method: "+a;return!0}return!1},bind:function(a,b){if(!a||"string"!=typeofa)throw"'method' argument to bind must be string";if(!b||"function"!=typeofb)throw"callback missing from bind params";if(k[a])throw"method '"+a+"' is already bound!";returnk[a]=b,this},call:function(a){if(!a)throw"missing arguments to call function";if(!a.method||"string"!=typeofa.method)throw"'method' argument to call must be string";if(!a.success||"function"!=typeofa.success)throw"'success' callback missing from call";varb={},c=[],e=function(a,d){if("object"==typeofd)for(varfind)if(d.hasOwnProperty(f)){varg=a+(a.length?"/":"")+f;"function"==typeofd[f]?(b[g]=d[f],c.push(g),deleted[f]):"object"==typeofd[f]&&e(g,d[f])}};e("",a.params);varg={id:d,method:s(a.method),params:a.params};c.length&&(g.callbacks=c),a.timeout&&q(d,a.timeout,s(a.method)),l[d]={callbacks:b,error:a.error,success:a.success},f[d]=r,d++,t(g)},notify:function(a){if(!a)throw"missing arguments to notify function";if(!a.method||"string"!=typeofa.method)throw"'method' argument to notify must be string";t({method:s(a.method),params:a.params})},destroy:function(){b(e.window,e.origin,"string"==typeofe.scope?e.scope:""),window.removeEventListener?window.removeEventListener("message",r,!1):window.detachEvent&&window.detachEvent("onmessage",r),n=!1,k={},m={},l={},e.origin=null,o=[],g("channel destroyed"),j=""}};returnv.bind("__ready",u),setTimeout(function(){t({method:s("__ready"),params:"ping"},!0)},0),v}}}();!function(a){"use strict";varb=a.prototype,c=b.parseFromString;try{if((newa).parseFromString("","text/html"))return}catch(d){}b.parseFromString=function(a,b){vard,e,f,g;return/^\s*text\/html\s*(?:;|$)/i.test(b)?(e=document.implementation.createHTMLDocument(""),f=e.documentElement,f.innerHTML=a,g=f.firstElementChild,1===f.childElementCount&&"html"===g.localName.toLowerCase()&&e.replaceChild(g,f),d=e):d=c.apply(this,arguments),d}}(DOMParser),function(a,b,c,d,e,f,g,h){"use strict";functioni(a){varb=a.indexOf("#");returnb>0&&(a=a.substring(0,b)),a}functionj(b){if(b.constructor===XMLHttpRequest&&(b={readyState:b.readyState,status:b.status,statusText:b.statusText,response_headers:b.getAllResponseHeaders()}),b.constructor===Array||b.constructor===String||b.constructor===Object)try{b=JSON.stringify(b)}catch(c){}a.getElementsByTagName("body")[0].textContent=b,console.error(b.stack),console.error(b)}functionk(a){if(this.name="resolved",a!==h&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Default Message"}functionl(){returnthisinstanceofl?void0:newl}functionm(a){a.__monitor!==h&&a.__monitor.cancel(),a.__monitor=newA,a.__monitor.fail(function(b){returnbinstanceofc.CancellationError?void0:a.aq_reportServiceError(b)}).fail(function(a){returnj(a)})}functionn(a){a.__sub_gadget_dict={},m(a)}functiono(a){varb,d,e,f,g,i=a.__element.querySelectorAll("[data-gadget-scope]"),j=[];for(g=0;g<i.length;g+=1)b=i[g],d=b.getAttribute("data-gadget-scope"),e=b.getAttribute("data-gadget-url"),f=b.getAttribute("data-gadget-sandbox"),null!==d&&null!==e&&j.push(a.declareGadget(e,{element:b,scope:d||h,sandbox:f||h}));returnc.all(j)}functionp(a){a.__monitor.monitor((newc.Queue).push(function(){varb,c=a.constructor.__service_list;for(b=0;b<c.length;b+=1)a.__monitor.monitor(c[b].apply(a))}))}functionq(a,b,d){vare,f,g=this;for(eing.__sub_gadget_dict)g.__sub_gadget_dict.hasOwnProperty(e)&&g.__sub_gadget_dict[e]===a&&(f=e);return(newc.Queue).push(function(){vara=g.__acquired_method_dict||{};if(a.hasOwnProperty(b))returna[b].apply(g,[d,f]);thrownewz.AcquisitionError("aq_dynamic is not defined")}).push(h,function(a){if(ainstanceofz.AcquisitionError)returng.__aq_parent(b,d);throwa})}functionr(a,b){a.__aq_parent=function(c,d){returnq.apply(b,[a,c,d])}}functions(){returnthisinstanceofs?(l.call(this),void0):news}functiont(b,d,e){functionf(a,b){returnfunction(){returna(b)}}varg;returnd.element===h&&(d.element=a.createElement("div")),(newc.Queue).push(function(){returnz.declareGadgetKlass(b)}).push(function(a){varb,f=a.__template_element.body.childNodes;for(x=a,g=newa,g.__element=d.element,b=0;b<f.length;b+=1)g.__element.appendChild(f[b].cloneNode(!0));returnr(g,e),c.all([g.getRequiredJSList(),g.getRequiredCSSList()])}).push(function(a){varb,d=newc.Queue;for(b=0;b<a[0].length;b+=1)d.push(f(z.declareJS,a[0][b]));for(b=0;b<a[1].length;b+=1)d.push(f(z.declareCSS,a[1][b]));returnd}).push(function(){returng})}functionu(){returnthisinstanceofu?(l.call(this),void0):newu}functionv(b,d,f){varg,i,j=c.defer();if(d.element===h)thrownewError("DOM element is required to create Iframe Gadget "+b);if(!a.contains(d.element))thrownewError("The parent element is not attached to the DOM for "+b);returng=newu,r(g,f),i=a.createElement("iframe"),i.setAttribute("src",b),g.__path=b,g.__element=d.element,d.element.appendChild(i),g.__chan=e.build({window:i.contentWindow,origin:"*",scope:"renderJS"}),g.__chan.bind("declareMethod",function(a,b){returng[b]=function(){vara=arguments;returnnewc.Promise(function(c,d){g.__chan.call({method:"methodCall",params:[b,Array.prototype.slice.call(a,0)],success:function(a){c(a)},error:function(a){d(a)}})})},"OK"}),g.__chan.bind("ready",function(){returnj.resolve(g),"OK"}),g.__chan.bind("failed",function(a,b){returnj.reject(b),"OK"}),g.__chan.bind("acquire",function(a,b){g.__aq_parent.apply(g,b).then(function(b){a.complete(b)}).fail(function(b){a.error(b.toString())}),a.delayReturn(!0)}),c.any([j.promise,c.timeout(5e3)])}functionw(){vard,k,n,o,q,t,u=i(b.location.href),v=newc.Queue,w=0,A=!1;if(B.hasOwnProperty(u))thrownewError("bootstrap should not be called twice");y=newc.Promise(function(i,v){functiony(){varb,e,j=z.parseGadgetHTMLDocument(a,u);for(einj)j.hasOwnProperty(e)&&(d.prototype["__"+e]=j[e]);for(d.__template_element=a.createElement("div"),k.__element=a.body,b=0;b<k.__element.childNodes.length;b+=1)d.__template_element.appendChild(k.__element.childNodes[b].cloneNode(!0));c.all([k.getRequiredJSList(),k.getRequiredCSSList()]).then(function(a){varb,c=a[0],d=a[1];for(b=0;b<c.length;b+=1)C[c[b]]=null;for(b=0;b<d.length;b+=1)D[d[b]]=null;x=h}).then(function(){varb=a.querySelector("body"),c=newf(function(b){varc,d,e,f,i,j;b.forEach(function(b){if("childList"===b.type){for(e=b.removedNodes.length,c=0;e>c;c+=1)if(i=b.removedNodes[c],i.nodeType===g.ELEMENT_NODE)for(i.hasAttribute("data-gadget-url")&&i._gadget!==h&&m(i._gadget),j=i.querySelectorAll("[data-gadget-url]"),f=j.length,d=0;f>d;d+=1)i=j[d],i._gadget!==h&&m(i._gadget);for(e=b.addedNodes.length,c=0;e>c;c+=1)if(i=b.addedNodes[c],i.nodeType===g.ELEMENT_NODE)for(i.hasAttribute("data-gadget-url")&&i._gadget!==h&&a.contains(i)&&p(i._gadget),j=i.querySelectorAll("[data-gadget-url]"),f=j.length,d=0;f>d;d+=1)i=j[d],a.contains(i)&&i._gadget!==h&&p(i._gadget)}})}),d={childList:!0,subtree:!0,attributes:!1,characterData:!1};returnc.observe(b,d),k}).then(i,function(a){throwv(a),console.error(a),a})}b.self===b.top?(t=newl,t.__acquired_method_dict={getTopURL:function(){returnu},reportServiceError:function(a){j(a[0])}},t.__aq_parent=function(a){thrownewz.AcquisitionError("No gadget provides "+a)},d=function(){l.call(this)},d.declareMethod=l.declareMethod,d.declareAcquiredMethod=l.declareAcquiredMethod,d.allowPublicAcquisition=l.allowPublicAcquisition,d.__ready_list=l.__ready_list.slice(),d.ready=l.ready,d.__service_list=l.__service_list.slice(),d.declareService=l.declareService,d.prototype=newl,d.prototype.constructor=d,d.prototype.__path=u,B[u]=d,k=newB[u],r(k,t)):(n=e.build({window:b.parent,origin:"*",scope:"renderJS"}),d=s,d.__ready_list=l.__ready_list.slice(),d.__service_list=l.__service_list.slice(),d.prototype.__path=u,k=news,n.bind("methodCall",function(a,b){k[b[0]].apply(k,b[1]).then(function(b){a.complete(b)}).fail(function(b){a.error(b.toString())}),a.delayReturn(!0)}),o=function(){0===w&&A===!0&&n.notify({method:"ready"})},q=function(a){w+=1,n.call({method:"declareMethod",params:a,success:function(){w-=1,o()},error:function(){w-=1}})},q("getInterfaceList"),q("getRequiredCSSList"),q("getRequiredJSList"),q("getPath"),q("getTitle"),d.declareMethod=function(a,b){varc=l.declareMethod.apply(this,[a,b]);returnq(a),c},d.declareService=l.declareService,d.declareAcquiredMethod=l.declareAcquiredMethod,d.allowPublicAcquisition=l.allowPublicAcquisition,d.prototype.__aq_parent=function(a,b){returnnewc.Promise(function(c,d){n.call({method:"acquire",params:[a,b],success:function(a){c(a)},error:function(a){d(a)}})})}),d.prototype.__acquired_method_dict={},x=d,a.addEventListener("DOMContentLoaded",y,!1)}),v.push(function(){returny}).push(function(c){functione(){returnc}varf;for(b.top!==b.self&&d.ready(function(){varb=a.createElement("base");returnc.__aq_parent("getTopURL",[]).then(function(c){b.href=c,b.target="_top",a.head.appendChild(b)})}),d.ready(function(a){returnp(a)}),v.push(e),f=0;f<d.__ready_list.length;f+=1)v.push(d.__ready_list[f]).push(e)}),b.self===b.top?v.fail(function(a){throwj(a),a}):v.then(function(){A=!0,o()}).fail(function(a){thrown.notify({method:"failed",params:a.toString()}),a})}varx,y,z,A,B={},C={},D={};k.prototype=newError,k.prototype.constructor=k,A=function(){functiona(){vara,b=h.length;for(a=0;b>a;a+=1)h[a].cancel();h=[]}varb,d,e,f,g=this,h=[];returnthisinstanceofA?(b=newc.Promise(function(b,c,h){d=function(b){returnf?void0:(g.isRejected=!0,g.rejectedReason=b,f=!0,a(),c(b))},e=h},a),g.cancel=function(){f||(f=!0,b.cancel(),b.fail(function(a){g.isRejected=!0,g.rejectedReason=a}))},g.then=function(){returnb.then.apply(b,arguments)},g.fail=function(){returnb.fail.apply(b,arguments)},g.monitor=function(a){if(f)thrownewk;varb=(newc.Queue).push(function(){returna}).push(function(){vara,b,c=h.length,d=[];for(b=0;c>b;b+=1)a=h[b],a.isFulfilled||a.isRejected||d.push(a);h=d},function(b){throwbinstanceofc.CancellationError&&(a.isFulfilled&&a.isRejected||a.cancel()),d(b),b},function(a){returne(a),a});returnh.push(b),this},void0):newA},A.prototype=Object.create(Promise.prototype),A.prototype.constructor=A,l.prototype.__title="",l.prototype.__interface_list=[],l.prototype.__path="",l.prototype.__html="",l.prototype.__required_css_list=[],l.prototype.__required_js_list=[],l.__ready_list=[n,o],l.ready=function(a){returnthis.__ready_list.push(a),this},l.__service_list=[],l.declareService=function(a){returnthis.__service_list.push(a),this},l.declareMethod=function(a,b){returnthis.prototype[a]=function(){vara=this,d=arguments;return(newc.Queue).push(function(){returnb.apply(a,d)})},this},l.declareMethod("getInterfaceList",function(){returnthis.__interface_list}).declareMethod("getRequiredCSSList",function(){returnthis.__required_css_list}).declareMethod("getRequiredJSList",function(){returnthis.__required_js_list}).declareMethod("getPath",function(){returnthis.__path}).declareMethod("getTitle",function(){returnthis.__title}).declareMethod("getElement",function(){if(this.__element===h)thrownewError("No element defined");returnthis.__element}),l.declareAcquiredMethod=function(a,b){returnthis.prototype[a]=function(){vara=Array.prototype.slice.call(arguments,0),d=this;return(newc.Queue).push(function(){returnd.__aq_parent(b,a)})},this},l.declareAcquiredMethod("aq_reportServiceError","reportServiceError"),l.allowPublicAcquisition=function(a,b){returnthis.prototype.__acquired_method_dict[a]=b,this},s.__ready_list=l.__ready_list.slice(),s.__service_list=l.__service_list.slice(),s.ready=l.ready,s.declareService=l.declareService,s.prototype=newl,s.prototype.constructor=s,u.__ready_list=l.__ready_list.slice(),u.ready=l.ready,u.__service_list=l.__service_list.slice(),u.declareService=l.declareService,u.prototype=newl,u.prototype.constructor=u,l.declareMethod("declareGadget",function(b,d){vare,f,g=this,i=y;returnd===h&&(d={}),d.sandbox===h&&(d.sandbox="public"),b=z.getAbsoluteURL(b,this.__path),y=(newc.Queue).push(function(){returni}).push(h,function(){}).push(function(){vara;if("public"===d.sandbox)a=t;else{if("iframe"!==d.sandbox)thrownewError("Unsupported sandbox options '"+d.sandbox+"'");a=v}returna(b,d,g)}).push(function(a){returnx=h,a}).push(h,function(a){throwx=h,a}),f=y,e=(newc.Queue).push(function(){returnf}).push(function(c){functionf(){returnc}vari;for(i=0;i<c.constructor.__ready_list.length;i+=1)e.push(c.constructor.__ready_list[i]),e.push(f);returnd.scope!==h&&(g.__sub_gadget_dict[d.scope]=c,c.__element.setAttribute("data-gadget-scope",d.scope)),c.__element.setAttribute("data-gadget-url",b),c.__element.setAttribute("data-gadget-sandbox",d.sandbox),c.__element._gadget=c,a.contains(c.__element)&&e.push(p),e.push(f),c})}).declareMethod("getDeclaredGadget",function(a){if(!this.__sub_gadget_dict.hasOwnProperty(a))thrownewError("Gadget scope '"+a+"' is not known.");returnthis.__sub_gadget_dict[a]}).declareMethod("dropGadget",function(a){if(!this.__sub_gadget_dict.hasOwnProperty(a))thrownewError("Gadget scope '"+a+"' is not known.");deletethis.__sub_gadget_dict[a]}),z=function(a){varc;if(a===b&&(c=x),c===h)thrownewError("Unknown selector '"+a+"'");returnc},z.AcquisitionError=function(a){if(this.name="AcquisitionError",a!==h&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Acquisition failed"},z.AcquisitionError.prototype=newError,z.AcquisitionError.prototype.constructor=z.AcquisitionError,z.getAbsoluteURL=function(a,b){varc,e,f,g="<!doctype><html><head></head></html>",h=newRegExp("^(?:[a-z]+:)?//|data:","i");returna&&b&&!h.test(a)?(c=(newd).parseFromString(g,"text/html"),e=c.createElement("base"),f=c.createElement("link"),c.head.appendChild(e),c.head.appendChild(f),e.href=b,f.href=a,f.href):a},z.declareJS=function(b){vard;returnd=C.hasOwnProperty(b)?c.resolve():newc.Promise(function(c,d){vare;e=a.createElement("script"),e.type="text/javascript",e.src=b,e.onload=function(){C[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},z.declareCSS=function(b){vard;returnd=D.hasOwnProperty(b)?c.resolve():newc.Promise(function(c,d){vare;e=a.createElement("link"),e.rel="stylesheet",e.type="text/css",e.href=b,e.onload=function(){D[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},z.declareGadgetKlass=function(a){functionb(){varb,c,e;if(!B.hasOwnProperty(a)){b=function(){l.call(this)},b.__ready_list=l.__ready_list.slice(),b.__service_list=l.__service_list.slice(),b.declareMethod=l.declareMethod,b.declareAcquiredMethod=l.declareAcquiredMethod,b.allowPublicAcquisition=l.allowPublicAcquisition,b.ready=l.ready,b.declareService=l.declareService,b.prototype=newl,b.prototype.constructor=b,b.prototype.__path=a,b.prototype.__acquired_method_dict={},b.__template_element=(newd).parseFromString(i.responseText,"text/html"),e=z.parseGadgetHTMLDocument(b.__template_element,a);for(cine)e.hasOwnProperty(c)&&(b.prototype["__"+c]=e[c]);B[a]=b}returnB[a]}functione(c,d){functione(){vara;try{0===i.readyState?d(i):4===i.readyState&&(i.status<200||i.status>=300||!/^text\/html[;]?/.test(i.getResponseHeader("Content-Type")||"")?d(i):(a=b(),c(a)))}catch(e){d(e)}}i=newXMLHttpRequest,i.open("GET",a),i.onreadystatechange=e,i.setRequestHeader("Accept","text/html"),i.withCredentials=!0,i.send()}functionf(){i!==h&&i.readyState!==i.DONE&&i.abort()}varg,i;returng=B.hasOwnProperty(a)?c.resolve(B[a]):newc.Promise(e,f)},z.clearGadgetKlassList=function(){B={},C={},D={}},z.parseGadgetHTMLDocument=function(a,b){varc,d,e={title:"",interface_list:[],required_css_list:[],required_js_list:[]},f=newRegExp("^(?:[a-z]+:)?//","i");if(!b||!f.test(b))thrownewError("The url should be absolute: "+b);if(9!==a.nodeType)thrownewError("The first parameter should be an HTMLDocument");for(e.title=a.title,c=0;c<a.head.children.length;c+=1)d=a.head.children[c],null!==d.href&&("stylesheet"===d.rel?e.required_css_list.push(z.getAbsoluteURL(d.getAttribute("href"),b)):"SCRIPT"!==d.nodeName||"text/javascript"!==d.type&&d.type?"http://www.renderjs.org/rel/interface"===d.rel&&e.interface_list.push(z.getAbsoluteURL(d.getAttribute("href"),b)):e.required_js_list.push(z.getAbsoluteURL(d.getAttribute("src"),b)));returne},b.rJS=b.renderJS=z,b.__RenderJSGadget=l,b.__RenderJSEmbeddedGadget=s,b.__RenderJSIframeGadget=u,w()}(document,window,RSVP,DOMParser,Channel,MutationObserver,Node);