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"!=typeofdocument.contains&&(Document.prototype.contains=function(a){returna===this||a.parentNode===this?!0:this.documentElement.contains(a)}),function(a,b,c,d,e,f,g,h,i){"use strict";functionj(a){varb=newh;returnnewc.Promise(function(c,d){b.addEventListener("load",function(a){c(a.target.result)}),b.addEventListener("error",d),b.readAsDataURL(a)},function(){b.abort()})}functionk(a){functionb(b,c){functiond(){try{0===e.readyState?c(e):4===e.readyState&&(e.status<200||e.status>=300||!/^text\/html[;]?/.test(e.getResponseHeader("Content-Type")||"")?c(e):b(e))}catch(a){c(a)}}e=newXMLHttpRequest,e.open("GET",a),e.onreadystatechange=d,e.setRequestHeader("Accept","text/html"),e.withCredentials=!0,e.send()}functiond(){void0!==e&&e.readyState!==e.DONE&&e.abort()}vare;returnnewc.Promise(b,d)}functionl(a){varb=a.indexOf("#");returnb>0&&(a=a.substring(0,b)),a}functionm(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)}functionn(a){if(this.name="resolved",void0!==a&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Default Message"}functiono(){returnthisinstanceofo?void0:newo}functionp(a){void0!==a.__monitor&&a.__monitor.cancel(),a.__monitor=newE,a.__monitor.fail(function(b){returnbinstanceofc.CancellationError?void0:a.aq_reportServiceError(b)}).fail(function(a){returnm(a)})}functionq(a){a.__sub_gadget_dict={},p(a)}functionr(a){varb,d,e,f,g,h=a.__element.querySelectorAll("[data-gadget-url]"),i=[];for(g=0;g<h.length;g+=1)b=h[g],d=b.getAttribute("data-gadget-scope"),e=b.getAttribute("data-gadget-url"),f=b.getAttribute("data-gadget-sandbox"),null!==e&&i.push(a.declareGadget(e,{element:b,scope:d||void0,sandbox:f||void0}));returnc.all(i)}functions(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))}))}functiont(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]);thrownewD.AcquisitionError("aq_dynamic is not defined")}).push(void0,function(a){if(ainstanceofD.AcquisitionError)returng.__aq_parent(b,d);throwa})}functionu(a,b){a.__aq_parent=function(c,d){returnt.apply(b,[a,c,d])}}functionv(){returnthisinstanceofv?voido.call(this):newv}functionw(b,d,e){functionf(a,b){returnfunction(){returna(b)}}varg;returnvoid0===d.element&&(d.element=a.createElement("div")),(newc.Queue).push(function(){returnD.declareGadgetKlass(b)}).push(function(a){varb,f=a.__template_element.body.childNodes;for(B=a,g=newa,g.__element=d.element,b=0;b<f.length;b+=1)g.__element.appendChild(f[b].cloneNode(!0));returnu(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(D.declareJS,a[0][b]));for(b=0;b<a[1].length;b+=1)d.push(f(D.declareCSS,a[1][b]));returnd}).push(function(){returng})}functionx(){returnthisinstanceofx?voido.call(this):newx}functiony(b,d,f){varg,h,i=c.defer();if(void0===d.element)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=newx,u(g,f),h=a.createElement("iframe"),h.setAttribute("src",b),g.__path=b,g.__element=d.element,d.element.appendChild(h),g.__chan=e.build({window:h.contentWindow,origin:"*",scope:"renderJS"}),g.__chan.bind("declareMethod",function(a,b){returng[b]=function(){vara=arguments,d=newc.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)}})});return(newc.Queue).push(function(){returnd})},"OK"}),g.__chan.bind("ready",function(a){returni.resolve(g),"OK"}),g.__chan.bind("failed",function(a,b){returni.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([i.promise,c.timeout(5e3)])}functionz(a,b,e){return(newc.Queue).push(function(){returnk(a)}).push(function(b){varc,e=(newd).parseFromString(b.responseText,"text/html"),f=e.createElement("base");returnf.href=a,e.head.insertBefore(f,e.head.firstChild),c=newi([e.documentElement.outerHTML],{type:"text/html;charset=UTF-8"}),j(c)}).push(function(a){returny(a,b,e)})}functionA(){vard,h,i,j,k,n,q,r,t=l(b.location.href),w=newc.Queue,x=0,y=!1,z=[],A=!1,E=!1;if(F.hasOwnProperty(t))thrownewError("bootstrap should not be called twice");C=newc.Promise(function(l,w){functionC(){varb,e,i=D.parseGadgetHTMLDocument(a,t);for(eini)i.hasOwnProperty(e)&&(d.prototype["__"+e]=i[e]);for(d.__template_element=a.createElement("div"),h.__element=a.body,b=0;b<h.__element.childNodes.length;b+=1)d.__template_element.appendChild(h.__element.childNodes[b].cloneNode(!0));c.all([h.getRequiredJSList(),h.getRequiredCSSList()]).then(function(a){varb,c=a[0],d=a[1];for(b=0;b<c.length;b+=1)G[c[b]]=null;for(b=0;b<d.length;b+=1)H[d[b]]=null;B=void0}).then(function(){varb=a.querySelector("body"),c=newf(function(b){varc,d,e,f,h,i;b.forEach(function(b){if("childList"===b.type){for(e=b.removedNodes.length,c=0;e>c;c+=1)if(h=b.removedNodes[c],h.nodeType===g.ELEMENT_NODE)for(h.hasAttribute("data-gadget-url")&&void0!==h._gadget&&p(h._gadget),i=h.querySelectorAll("[data-gadget-url]"),f=i.length,d=0;f>d;d+=1)h=i[d],void0!==h._gadget&&p(h._gadget);for(e=b.addedNodes.length,c=0;e>c;c+=1)if(h=b.addedNodes[c],h.nodeType===g.ELEMENT_NODE)for(h.hasAttribute("data-gadget-url")&&void0!==h._gadget&&a.contains(h)&&s(h._gadget),i=h.querySelectorAll("[data-gadget-url]"),f=i.length,d=0;f>d;d+=1)h=i[d],a.contains(h)&&void0!==h._gadget&&s(h._gadget)}})}),d={childList:!0,subtree:!0,attributes:!1,characterData:!1};returnc.observe(b,d),h}).then(l,function(a){throww(a),console.error(a),a})}q=newo,q.__acquired_method_dict={getTopURL:function(){returnt},reportServiceError:function(a){m(a[0])}},q.__aq_parent=function(a){thrownewD.AcquisitionError("No gadget provides "+a)},b.self===b.top?(d=function(){o.call(this)},d.declareMethod=o.declareMethod,d.declareAcquiredMethod=o.declareAcquiredMethod,d.allowPublicAcquisition=o.allowPublicAcquisition,d.__ready_list=o.__ready_list.slice(),d.ready=o.ready,d.__service_list=o.__service_list.slice(),d.declareService=o.declareService,d.prototype=newo,d.prototype.constructor=d,d.prototype.__path=t,F[t]=d,h=newF[t],u(h,q)):(d=v,d.__ready_list=o.__ready_list.slice(),d.__service_list=o.__service_list.slice(),d.prototype.__path=t,h=newv,u(h,q),i=e.build({window:b.parent,origin:"*",scope:"renderJS",onReady:function(){varb;for(n=!1,h.__aq_parent=d.prototype.__aq_parent=function(a,b,d){returnnewc.Promise(function(c,e){i.call({method:"acquire",params:[a,b],success:function(a){c(a)},error:function(a){e(a)},timeout:d})})},k=function(a){x+=1,i.call({method:"declareMethod",params:a,success:function(){x-=1,j()},error:function(){x-=1}})},b=0;b<z.length;b+=1)k(z[b]);returnz=[],A?voidi.notify({method:"failed",params:r}):d.prototype.__aq_parent("getTopURL",[]).then(function(b){varc=a.createElement("base");c.href=b,c.target="_top",a.head.appendChild(c),E=!0,j(),i.bind("methodCall",function(a,b){h[b[0]].apply(h,b[1]).then(function(b){a.complete(b)}).fail(function(b){a.error(b.toString())}),a.delayReturn(!0)})}).fail(function(a){throwa})}}),j=function(){0===x&&y===!0&&i.notify({method:"ready"})},k=function(a){z.push(a)},k("getInterfaceList"),k("getRequiredCSSList"),k("getRequiredJSList"),k("getPath"),k("getTitle"),d.declareMethod=function(a,b){varc=o.declareMethod.apply(this,[a,b]);returnk(a),c},d.declareService=o.declareService,d.declareAcquiredMethod=o.declareAcquiredMethod,d.allowPublicAcquisition=o.allowPublicAcquisition,n=!0),d.prototype.__acquired_method_dict={},B=d,a.addEventListener("DOMContentLoaded",C,!1)}),w.push(function(){returnC}).push(function(a){functionb(){returna}varc;for(d.ready(function(a){returns(a)}),w.push(b),c=0;c<d.__ready_list.length;c+=1)w.push(d.__ready_list[c]).push(b)}),b.self===b.top?w.fail(function(a){throwm(a),a}):w.then(function(){y=!0,E&&j()}).fail(function(a){thrown?(A=!0,r=a.toString(),m(a)):i.notify({method:"failed",params:a.toString()}),a})}varB,C,D,E,F={},G={},H={},I=0,J=newRegExp("^(?:[a-z]+:)?//|data:","i");n.prototype=newError,n.prototype.constructor=n,E=function(){functiona(){vara,b=h.length;for(a=0;b>a;a+=1)h[a].cancel();h=[]}varb,d,e,f,g=this,h=[];returnthisinstanceofE?(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)},void(g.monitor=function(a){if(f)thrownewn;varb=(newc.Queue).push(function(){returna}).push(function(a){varb,c,d=h.length,e=[];for(c=0;d>c;c+=1)b=h[c],b.isFulfilled||b.isRejected||e.push(b);h=e},function(b){throwbinstanceofc.CancellationError&&(a.isFulfilled&&a.isRejected||a.cancel()),d(b),b},function(a){returne(a),a});returnh.push(b),this})):newE},E.prototype=Object.create(c.Promise.prototype),E.prototype.constructor=E,o.prototype.__title="",o.prototype.__interface_list=[],o.prototype.__path="",o.prototype.__html="",o.prototype.__required_css_list=[],o.prototype.__required_js_list=[],o.__ready_list=[q,r],o.ready=function(a){returnthis.__ready_list.push(a),this},o.__service_list=[],o.declareService=function(a){returnthis.__service_list.push(a),this},o.declareMethod=function(a,b){returnthis.prototype[a]=function(){vara=this,d=arguments;return(newc.Queue).push(function(){returnb.apply(a,d)})},this},o.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(void0===this.__element)thrownewError("No element defined");returnthis.__element}),o.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},o.declareAcquiredMethod("aq_reportServiceError","reportServiceError"),o.allowPublicAcquisition=function(a,b){returnthis.prototype.__acquired_method_dict[a]=b,this},v.__ready_list=o.__ready_list.slice(),v.__service_list=o.__service_list.slice(),v.ready=o.ready,v.declareService=o.declareService,v.prototype=newo,v.prototype.constructor=v,x.__ready_list=o.__ready_list.slice(),x.ready=o.ready,x.__service_list=o.__service_list.slice(),x.declareService=o.declareService,x.prototype=newo,x.prototype.constructor=x,o.declareMethod("declareGadget",function(b,d){vare,f,g=this,h=C;returnvoid0===d&&(d={}),void0===d.sandbox&&(d.sandbox="public"),b=D.getAbsoluteURL(b,this.__path),C=(newc.Queue).push(function(){returnh}).push(void0,function(){}).push(function(){vara;if("public"===d.sandbox)a=w;elseif("iframe"===d.sandbox)a=y;else{if("dataurl"!==d.sandbox)thrownewError("Unsupported sandbox options '"+d.sandbox+"'");a=z}returna(b,d,g)}).push(function(a){returnB=void0,a}).push(void0,function(a){throwB=void0,a}),f=C,e=(newc.Queue).push(function(){returnf}).push(function(c){functionf(){returnc}varh,i;for(h=0;h<c.constructor.__ready_list.length;h+=1)e.push(c.constructor.__ready_list[h]),e.push(f);if(i=d.scope,void0===i)for(i="RJS_"+I,I+=1;g.__sub_gadget_dict.hasOwnProperty(i);)i="RJS_"+I,I+=1;returng.__sub_gadget_dict[i]=c,c.__element.setAttribute("data-gadget-scope",i),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(s),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]}),D=function(a){varc;if(a===b&&(c=B),void0===c)thrownewError("Unknown selector '"+a+"'");returnc},D.AcquisitionError=function(a){if(this.name="AcquisitionError",void0!==a&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Acquisition failed"},D.AcquisitionError.prototype=newError,D.AcquisitionError.prototype.constructor=D.AcquisitionError,D.getAbsoluteURL=function(a,b){varc,e,f,g="<!doctype><html><head></head></html>";returna&&b&&!J.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},D.declareJS=function(b){vard;returnd=G.hasOwnProperty(b)?c.resolve():newc.Promise(function(c,d){vare;e=a.createElement("script"),e.type="text/javascript",e.src=b,e.onload=function(){G[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},D.declareCSS=function(b){vard;returnd=H.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(){H[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},D.declareGadgetKlass=function(a){functionb(b){varc,e,f;if(!F.hasOwnProperty(a)){c=function(){o.call(this)},c.__ready_list=o.__ready_list.slice(),c.__service_list=o.__service_list.slice(),c.declareMethod=o.declareMethod,c.declareAcquiredMethod=o.declareAcquiredMethod,c.allowPublicAcquisition=o.allowPublicAcquisition,c.ready=o.ready,c.declareService=o.declareService,c.prototype=newo,c.prototype.constructor=c,c.prototype.__path=a,c.prototype.__acquired_method_dict={},c.__template_element=(newd).parseFromString(b.responseText,"text/html"),f=D.parseGadgetHTMLDocument(c.__template_element,a);for(einf)f.hasOwnProperty(e)&&(c.prototype["__"+e]=f[e]);F[a]=c}returnF[a]}vare;returne=F.hasOwnProperty(a)?c.resolve(F[a]):(newc.Queue).push(function(){returnk(a)}).push(function(a){returnb(a)})},D.clearGadgetKlassList=function(){F={},G={},H={}},D.parseGadgetHTMLDocument=function(a,b){varc,d,e={title:"",interface_list:[],required_css_list:[],required_js_list:[]};if(!b||!J.test(b))thrownewError("The url should be absolute: "+b);if(9!==a.nodeType)thrownewError("The first parameter should be an HTMLDocument");if(e.title=a.title,null!==a.head)for(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(D.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(D.getAbsoluteURL(d.getAttribute("href"),b)):e.required_js_list.push(D.getAbsoluteURL(d.getAttribute("src"),b)));returne},b.rJS=b.renderJS=D,b.__RenderJSGadget=o,b.__RenderJSEmbeddedGadget=v,b.__RenderJSIframeGadget=x,A()}(document,window,RSVP,DOMParser,Channel,MutationObserver,Node,FileReader,Blob);
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"!=typeofdocument.contains&&(Document.prototype.contains=function(a){returna===this||a.parentNode===this?!0:this.documentElement.contains(a)}),function(a,b,c,d,e,f,g,h,i){"use strict";functionj(a){varb=newh;returnnewc.Promise(function(c,d){b.addEventListener("load",function(a){c(a.target.result)}),b.addEventListener("error",d),b.readAsDataURL(a)},function(){b.abort()})}functionk(a){functionb(b,c){functiond(){try{0===e.readyState?c(e):4===e.readyState&&(e.status<200||e.status>=300||!/^text\/html[;]?/.test(e.getResponseHeader("Content-Type")||"")?c(e):b(e))}catch(a){c(a)}}e=newXMLHttpRequest,e.open("GET",a),e.onreadystatechange=d,e.setRequestHeader("Accept","text/html"),e.withCredentials=!0,e.send()}functiond(){void0!==e&&e.readyState!==e.DONE&&e.abort()}vare;returnnewc.Promise(b,d)}functionl(a){varb=a.indexOf("#");returnb>0&&(a=a.substring(0,b)),a}functionm(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)}functionn(a){if(this.name="resolved",void0!==a&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Default Message"}functiono(){returnthisinstanceofo?void0:newo}functionp(a){void0!==a.__monitor&&a.__monitor.cancel(),a.__monitor=newE,a.__monitor.fail(function(b){returnbinstanceofc.CancellationError?void0:a.aq_reportServiceError(b)}).fail(function(a){returnm(a)})}functionq(a){a.__sub_gadget_dict={},p(a)}functionr(a){varb,d,e,f,g,h=a.__element.querySelectorAll("[data-gadget-url]"),i=[];for(g=0;g<h.length;g+=1)b=h[g],d=b.getAttribute("data-gadget-scope"),e=b.getAttribute("data-gadget-url"),f=b.getAttribute("data-gadget-sandbox"),null!==e&&i.push(a.declareGadget(e,{element:b,scope:d||void0,sandbox:f||void0}));returnc.all(i)}functions(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))}))}functiont(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]);thrownewD.AcquisitionError("aq_dynamic is not defined")}).push(void0,function(a){if(ainstanceofD.AcquisitionError)returng.__aq_parent(b,d);throwa})}functionu(a,b){a.__aq_parent=function(c,d){returnt.apply(b,[a,c,d])}}functionv(){returnthisinstanceofv?voido.call(this):newv}functionw(b,d,e){functionf(a,b){returnfunction(){returna(b)}}varg;returnvoid0===d.element&&(d.element=a.createElement("div")),(newc.Queue).push(function(){returnD.declareGadgetKlass(b)}).push(function(a){varb,f=a.__template_element.body.childNodes;for(B=a,g=newa,g.__element=d.element,b=0;b<f.length;b+=1)g.__element.appendChild(f[b].cloneNode(!0));returnu(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(D.declareJS,a[0][b]));for(b=0;b<a[1].length;b+=1)d.push(f(D.declareCSS,a[1][b]));returnd}).push(function(){returng})}functionx(){returnthisinstanceofx?voido.call(this):newx}functiony(b,d,f){varg,h,i=c.defer();if(void0===d.element)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=newx,u(g,f),h=a.createElement("iframe"),h.setAttribute("src",b),g.__path=b,g.__element=d.element,d.element.appendChild(h),g.__chan=e.build({window:h.contentWindow,origin:"*",scope:"renderJS"}),g.__chan.bind("declareMethod",function(a,b){returng[b]=function(){vara=arguments,d=newc.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)}})});return(newc.Queue).push(function(){returnd})},"OK"}),g.__chan.bind("ready",function(a){returni.resolve(g),"OK"}),g.__chan.bind("failed",function(a,b){returni.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([i.promise,c.timeout(5e3)])}functionz(a,b,e){return(newc.Queue).push(function(){returnk(a)}).push(function(b){varc,e=(newd).parseFromString(b.responseText,"text/html"),f=e.createElement("base");returnf.href=a,e.head.insertBefore(f,e.head.firstChild),c=newi([e.documentElement.outerHTML],{type:"text/html;charset=UTF-8"}),j(c)}).push(function(a){returny(a,b,e)})}functionA(){vard,h,i,j,k,n,q,r=l(b.location.href),t=newc.Queue,w=0,x=!1;if(F.hasOwnProperty(r))thrownewError("bootstrap should not be called twice");C=newc.Promise(function(l,n){functiont(){varb,e,i=D.parseGadgetHTMLDocument(a,r);for(eini)i.hasOwnProperty(e)&&(d.prototype["__"+e]=i[e]);for(d.__template_element=a.createElement("div"),h.__element=a.body,b=0;b<h.__element.childNodes.length;b+=1)d.__template_element.appendChild(h.__element.childNodes[b].cloneNode(!0));c.all([h.getRequiredJSList(),h.getRequiredCSSList()]).then(function(a){varb,c=a[0],d=a[1];for(b=0;b<c.length;b+=1)G[c[b]]=null;for(b=0;b<d.length;b+=1)H[d[b]]=null;B=void0}).then(function(){varb=a.querySelector("body"),c=newf(function(b){varc,d,e,f,h,i;b.forEach(function(b){if("childList"===b.type){for(e=b.removedNodes.length,c=0;e>c;c+=1)if(h=b.removedNodes[c],h.nodeType===g.ELEMENT_NODE)for(h.hasAttribute("data-gadget-url")&&void0!==h._gadget&&p(h._gadget),i=h.querySelectorAll("[data-gadget-url]"),f=i.length,d=0;f>d;d+=1)h=i[d],void0!==h._gadget&&p(h._gadget);for(e=b.addedNodes.length,c=0;e>c;c+=1)if(h=b.addedNodes[c],h.nodeType===g.ELEMENT_NODE)for(h.hasAttribute("data-gadget-url")&&void0!==h._gadget&&a.contains(h)&&s(h._gadget),i=h.querySelectorAll("[data-gadget-url]"),f=i.length,d=0;f>d;d+=1)h=i[d],a.contains(h)&&void0!==h._gadget&&s(h._gadget)}})}),d={childList:!0,subtree:!0,attributes:!1,characterData:!1};returnc.observe(b,d),h}).then(l,function(a){thrown(a),console.error(a),a})}q=newo,q.__acquired_method_dict={getTopURL:function(){returnr},reportServiceError:function(a){m(a[0])}},q.__aq_parent=function(a){thrownewD.AcquisitionError("No gadget provides "+a)},b.self===b.top?(d=function(){o.call(this)},d.declareMethod=o.declareMethod,d.declareAcquiredMethod=o.declareAcquiredMethod,d.allowPublicAcquisition=o.allowPublicAcquisition,d.__ready_list=o.__ready_list.slice(),d.ready=o.ready,d.__service_list=o.__service_list.slice(),d.declareService=o.declareService,d.prototype=newo,d.prototype.constructor=d,d.prototype.__path=r,F[r]=d,h=newF[r],u(h,q)):(i=e.build({window:b.parent,origin:"*",scope:"renderJS"}),d=v,d.__ready_list=o.__ready_list.slice(),d.__service_list=o.__service_list.slice(),d.prototype.__path=r,h=newv,j=function(){0===w&&x===!0&&i.notify({method:"ready"})},k=function(a){w+=1,i.call({method:"declareMethod",params:a,success:function(){w-=1,j()},error:function(){w-=1}})},k("getInterfaceList"),k("getRequiredCSSList"),k("getRequiredJSList"),k("getPath"),k("getTitle"),d.declareMethod=function(a,b){varc=o.declareMethod.apply(this,[a,b]);returnk(a),c},d.declareService=o.declareService,d.declareAcquiredMethod=o.declareAcquiredMethod,d.allowPublicAcquisition=o.allowPublicAcquisition,d.prototype.__aq_parent=function(a,b,d){returnnewc.Promise(function(c,e){i.call({method:"acquire",params:[a,b],success:function(a){c(a)},error:function(a){e(a)},timeout:d})})}),d.prototype.__acquired_method_dict={},B=d,a.addEventListener("DOMContentLoaded",t,!1)}),t.push(function(){returnC}).push(function(c){functione(){returnc}varf;for(b.top!==b.self&&d.__ready_list.splice(1,0,function(){returnc.__aq_parent("getTopURL",[],100).then(function(b){vard=a.createElement("base");d.href=b,d.target="_top",a.head.appendChild(d),i.bind("methodCall",function(a,b){c[b[0]].apply(c,b[1]).then(function(b){a.complete(b)}).fail(function(b){a.error(b.toString())}),a.delayReturn(!0)})}).fail(function(a){if("timeout_error"!==a)throwa;n=!0,u(c,q)})}),d.ready(function(a){returns(a)}),t.push(e),f=0;f<d.__ready_list.length;f+=1)t.push(d.__ready_list[f]).push(e)}),b.self===b.top?t.fail(function(a){throwm(a),a}):t.then(function(){x=!0,j()}).fail(function(a){thrown?m(a):i.notify({method:"failed",params:a.toString()}),a})}varB,C,D,E,F={},G={},H={},I=0,J=newRegExp("^(?:[a-z]+:)?//|data:","i");n.prototype=newError,n.prototype.constructor=n,E=function(){functiona(){vara,b=h.length;for(a=0;b>a;a+=1)h[a].cancel();h=[]}varb,d,e,f,g=this,h=[];returnthisinstanceofE?(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)},void(g.monitor=function(a){if(f)thrownewn;varb=(newc.Queue).push(function(){returna}).push(function(a){varb,c,d=h.length,e=[];for(c=0;d>c;c+=1)b=h[c],b.isFulfilled||b.isRejected||e.push(b);h=e},function(b){throwbinstanceofc.CancellationError&&(a.isFulfilled&&a.isRejected||a.cancel()),d(b),b},function(a){returne(a),a});returnh.push(b),this})):newE},E.prototype=Object.create(c.Promise.prototype),E.prototype.constructor=E,o.prototype.__title="",o.prototype.__interface_list=[],o.prototype.__path="",o.prototype.__html="",o.prototype.__required_css_list=[],o.prototype.__required_js_list=[],o.__ready_list=[q,r],o.ready=function(a){returnthis.__ready_list.push(a),this},o.__service_list=[],o.declareService=function(a){returnthis.__service_list.push(a),this},o.declareMethod=function(a,b){returnthis.prototype[a]=function(){vara=this,d=arguments;return(newc.Queue).push(function(){returnb.apply(a,d)})},this},o.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(void0===this.__element)thrownewError("No element defined");returnthis.__element}),o.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},o.declareAcquiredMethod("aq_reportServiceError","reportServiceError"),o.allowPublicAcquisition=function(a,b){returnthis.prototype.__acquired_method_dict[a]=b,this},v.__ready_list=o.__ready_list.slice(),v.__service_list=o.__service_list.slice(),v.ready=o.ready,v.declareService=o.declareService,v.prototype=newo,v.prototype.constructor=v,x.__ready_list=o.__ready_list.slice(),x.ready=o.ready,x.__service_list=o.__service_list.slice(),x.declareService=o.declareService,x.prototype=newo,x.prototype.constructor=x,o.declareMethod("declareGadget",function(b,d){vare,f,g=this,h=C;returnvoid0===d&&(d={}),void0===d.sandbox&&(d.sandbox="public"),b=D.getAbsoluteURL(b,this.__path),C=(newc.Queue).push(function(){returnh}).push(void0,function(){}).push(function(){vara;if("public"===d.sandbox)a=w;elseif("iframe"===d.sandbox)a=y;else{if("dataurl"!==d.sandbox)thrownewError("Unsupported sandbox options '"+d.sandbox+"'");a=z}returna(b,d,g)}).push(function(a){returnB=void0,a}).push(void0,function(a){throwB=void0,a}),f=C,e=(newc.Queue).push(function(){returnf}).push(function(c){functionf(){returnc}varh,i;for(h=0;h<c.constructor.__ready_list.length;h+=1)e.push(c.constructor.__ready_list[h]),e.push(f);if(i=d.scope,void0===i)for(i="RJS_"+I,I+=1;g.__sub_gadget_dict.hasOwnProperty(i);)i="RJS_"+I,I+=1;returng.__sub_gadget_dict[i]=c,c.__element.setAttribute("data-gadget-scope",i),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(s),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]}),D=function(a){varc;if(a===b&&(c=B),void0===c)thrownewError("Unknown selector '"+a+"'");returnc},D.AcquisitionError=function(a){if(this.name="AcquisitionError",void0!==a&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Acquisition failed"},D.AcquisitionError.prototype=newError,D.AcquisitionError.prototype.constructor=D.AcquisitionError,D.getAbsoluteURL=function(a,b){varc,e,f,g="<!doctype><html><head></head></html>";returna&&b&&!J.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},D.declareJS=function(b){vard;returnd=G.hasOwnProperty(b)?c.resolve():newc.Promise(function(c,d){vare;e=a.createElement("script"),e.type="text/javascript",e.src=b,e.onload=function(){G[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},D.declareCSS=function(b){vard;returnd=H.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(){H[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},D.declareGadgetKlass=function(a){functionb(b){varc,e,f;if(!F.hasOwnProperty(a)){c=function(){o.call(this)},c.__ready_list=o.__ready_list.slice(),c.__service_list=o.__service_list.slice(),c.declareMethod=o.declareMethod,c.declareAcquiredMethod=o.declareAcquiredMethod,c.allowPublicAcquisition=o.allowPublicAcquisition,c.ready=o.ready,c.declareService=o.declareService,c.prototype=newo,c.prototype.constructor=c,c.prototype.__path=a,c.prototype.__acquired_method_dict={},c.__template_element=(newd).parseFromString(b.responseText,"text/html"),f=D.parseGadgetHTMLDocument(c.__template_element,a);for(einf)f.hasOwnProperty(e)&&(c.prototype["__"+e]=f[e]);F[a]=c}returnF[a]}vare;returne=F.hasOwnProperty(a)?c.resolve(F[a]):(newc.Queue).push(function(){returnk(a)}).push(function(a){returnb(a)})},D.clearGadgetKlassList=function(){F={},G={},H={}},D.parseGadgetHTMLDocument=function(a,b){varc,d,e={title:"",interface_list:[],required_css_list:[],required_js_list:[]};if(!b||!J.test(b))thrownewError("The url should be absolute: "+b);if(9!==a.nodeType)thrownewError("The first parameter should be an HTMLDocument");if(e.title=a.title,null!==a.head)for(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(D.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(D.getAbsoluteURL(d.getAttribute("href"),b)):e.required_js_list.push(D.getAbsoluteURL(d.getAttribute("src"),b)));returne},b.rJS=b.renderJS=D,b.__RenderJSGadget=o,b.__RenderJSEmbeddedGadget=v,b.__RenderJSIframeGadget=x,A()}(document,window,RSVP,DOMParser,Channel,MutationObserver,Node,FileReader,Blob);
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"!=typeofdocument.contains&&(Document.prototype.contains=function(a){returna===this||a.parentNode===this?!0:this.documentElement.contains(a)}),function(a,b,c,d,e,f,g,h,i){"use strict";functionj(a){varb=newh;returnnewc.Promise(function(c,d){b.addEventListener("load",function(a){c(a.target.result)}),b.addEventListener("error",d),b.readAsDataURL(a)},function(){b.abort()})}functionk(a){functionb(b,c){functiond(){try{0===e.readyState?c(e):4===e.readyState&&(e.status<200||e.status>=300||!/^text\/html[;]?/.test(e.getResponseHeader("Content-Type")||"")?c(e):b(e))}catch(a){c(a)}}e=newXMLHttpRequest,e.open("GET",a),e.onreadystatechange=d,e.setRequestHeader("Accept","text/html"),e.withCredentials=!0,e.send()}functiond(){void0!==e&&e.readyState!==e.DONE&&e.abort()}vare;returnnewc.Promise(b,d)}functionl(a){varb=a.indexOf("#");returnb>0&&(a=a.substring(0,b)),a}functionm(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)}functionn(a){if(this.name="resolved",void0!==a&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Default Message"}functiono(){returnthisinstanceofo?void0:newo}functionp(a){void0!==a.__monitor&&a.__monitor.cancel(),a.__monitor=newE,a.__monitor.fail(function(b){returnbinstanceofc.CancellationError?void0:a.aq_reportServiceError(b)}).fail(function(a){returnm(a)})}functionq(a){a.__sub_gadget_dict={},p(a)}functionr(a){varb,d,e,f,g,h=a.__element.querySelectorAll("[data-gadget-url]"),i=[];for(g=0;g<h.length;g+=1)b=h[g],d=b.getAttribute("data-gadget-scope"),e=b.getAttribute("data-gadget-url"),f=b.getAttribute("data-gadget-sandbox"),null!==e&&i.push(a.declareGadget(e,{element:b,scope:d||void0,sandbox:f||void0}));returnc.all(i)}functions(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))}))}functiont(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]);thrownewD.AcquisitionError("aq_dynamic is not defined")}).push(void0,function(a){if(ainstanceofD.AcquisitionError)returng.__aq_parent(b,d);throwa})}functionu(a,b){a.__aq_parent=function(c,d){returnt.apply(b,[a,c,d])}}functionv(){returnthisinstanceofv?voido.call(this):newv}functionw(b,d,e){functionf(a,b){returnfunction(){returna(b)}}varg;returnvoid0===d.element&&(d.element=a.createElement("div")),(newc.Queue).push(function(){returnD.declareGadgetKlass(b)}).push(function(a){varb,f=a.__template_element.body.childNodes;for(B=a,g=newa,g.__element=d.element,b=0;b<f.length;b+=1)g.__element.appendChild(f[b].cloneNode(!0));returnu(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(D.declareJS,a[0][b]));for(b=0;b<a[1].length;b+=1)d.push(f(D.declareCSS,a[1][b]));returnd}).push(function(){returng})}functionx(){returnthisinstanceofx?voido.call(this):newx}functiony(b,d,f){varg,h,i=c.defer();if(void0===d.element)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=newx,u(g,f),h=a.createElement("iframe"),h.setAttribute("src",b),g.__path=b,g.__element=d.element,d.element.appendChild(h),g.__chan=e.build({window:h.contentWindow,origin:"*",scope:"renderJS"}),g.__chan.bind("declareMethod",function(a,b){returng[b]=function(){vara=arguments,d=newc.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)}})});return(newc.Queue).push(function(){returnd})},"OK"}),g.__chan.bind("ready",function(a){returni.resolve(g),"OK"}),g.__chan.bind("failed",function(a,b){returni.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([i.promise,c.timeout(5e3)])}functionz(a,b,e){return(newc.Queue).push(function(){returnk(a)}).push(function(b){varc,e=(newd).parseFromString(b.responseText,"text/html"),f=e.createElement("base");returnf.href=a,e.head.insertBefore(f,e.head.firstChild),c=newi([e.documentElement.outerHTML],{type:"text/html;charset=UTF-8"}),j(c)}).push(function(a){returny(a,b,e)})}functionA(){vard,h,i,j,k,n,q,r,t=l(b.location.href),w=newc.Queue,x=0,y=!1,z=[],A=!1,E=!1;if(F.hasOwnProperty(t))thrownewError("bootstrap should not be called twice");C=newc.Promise(function(l,w){functionC(){varb,e,i=D.parseGadgetHTMLDocument(a,t);for(eini)i.hasOwnProperty(e)&&(d.prototype["__"+e]=i[e]);for(d.__template_element=a.createElement("div"),h.__element=a.body,b=0;b<h.__element.childNodes.length;b+=1)d.__template_element.appendChild(h.__element.childNodes[b].cloneNode(!0));c.all([h.getRequiredJSList(),h.getRequiredCSSList()]).then(function(a){varb,c=a[0],d=a[1];for(b=0;b<c.length;b+=1)G[c[b]]=null;for(b=0;b<d.length;b+=1)H[d[b]]=null;B=void0}).then(function(){varb=a.querySelector("body"),c=newf(function(b){varc,d,e,f,h,i;b.forEach(function(b){if("childList"===b.type){for(e=b.removedNodes.length,c=0;e>c;c+=1)if(h=b.removedNodes[c],h.nodeType===g.ELEMENT_NODE)for(h.hasAttribute("data-gadget-url")&&void0!==h._gadget&&p(h._gadget),i=h.querySelectorAll("[data-gadget-url]"),f=i.length,d=0;f>d;d+=1)h=i[d],void0!==h._gadget&&p(h._gadget);for(e=b.addedNodes.length,c=0;e>c;c+=1)if(h=b.addedNodes[c],h.nodeType===g.ELEMENT_NODE)for(h.hasAttribute("data-gadget-url")&&void0!==h._gadget&&a.contains(h)&&s(h._gadget),i=h.querySelectorAll("[data-gadget-url]"),f=i.length,d=0;f>d;d+=1)h=i[d],a.contains(h)&&void0!==h._gadget&&s(h._gadget)}})}),d={childList:!0,subtree:!0,attributes:!1,characterData:!1};returnc.observe(b,d),h}).then(l,function(a){throww(a),console.error(a),a})}q=newo,q.__acquired_method_dict={getTopURL:function(){returnt},reportServiceError:function(a){m(a[0])}},q.__aq_parent=function(a){thrownewD.AcquisitionError("No gadget provides "+a)},b.self===b.top?(d=function(){o.call(this)},d.declareMethod=o.declareMethod,d.declareAcquiredMethod=o.declareAcquiredMethod,d.allowPublicAcquisition=o.allowPublicAcquisition,d.__ready_list=o.__ready_list.slice(),d.ready=o.ready,d.__service_list=o.__service_list.slice(),d.declareService=o.declareService,d.prototype=newo,d.prototype.constructor=d,d.prototype.__path=t,F[t]=d,h=newF[t],u(h,q)):(d=v,d.__ready_list=o.__ready_list.slice(),d.__service_list=o.__service_list.slice(),d.prototype.__path=t,h=newv,u(h,q),i=e.build({window:b.parent,origin:"*",scope:"renderJS",onReady:function(){varb;for(n=!1,h.__aq_parent=d.prototype.__aq_parent=function(a,b,d){returnnewc.Promise(function(c,e){i.call({method:"acquire",params:[a,b],success:function(a){c(a)},error:function(a){e(a)},timeout:d})})},k=function(a){x+=1,i.call({method:"declareMethod",params:a,success:function(){x-=1,j()},error:function(){x-=1}})},b=0;b<z.length;b+=1)k(z[b]);returnz=[],A?voidi.notify({method:"failed",params:r}):d.prototype.__aq_parent("getTopURL",[]).then(function(b){varc=a.createElement("base");c.href=b,c.target="_top",a.head.appendChild(c),E=!0,j(),i.bind("methodCall",function(a,b){h[b[0]].apply(h,b[1]).then(function(b){a.complete(b)}).fail(function(b){a.error(b.toString())}),a.delayReturn(!0)})}).fail(function(a){throwa})}}),j=function(){0===x&&y===!0&&i.notify({method:"ready"})},k=function(a){z.push(a)},k("getInterfaceList"),k("getRequiredCSSList"),k("getRequiredJSList"),k("getPath"),k("getTitle"),d.declareMethod=function(a,b){varc=o.declareMethod.apply(this,[a,b]);returnk(a),c},d.declareService=o.declareService,d.declareAcquiredMethod=o.declareAcquiredMethod,d.allowPublicAcquisition=o.allowPublicAcquisition,n=!0),d.prototype.__acquired_method_dict={},B=d,a.addEventListener("DOMContentLoaded",C,!1)}),w.push(function(){returnC}).push(function(a){functionb(){returna}varc;for(d.ready(function(a){returns(a)}),w.push(b),c=0;c<d.__ready_list.length;c+=1)w.push(d.__ready_list[c]).push(b)}),b.self===b.top?w.fail(function(a){throwm(a),a}):w.then(function(){y=!0,E&&j()}).fail(function(a){thrown?(A=!0,r=a.toString(),m(a)):i.notify({method:"failed",params:a.toString()}),a})}varB,C,D,E,F={},G={},H={},I=0,J=newRegExp("^(?:[a-z]+:)?//|data:","i");n.prototype=newError,n.prototype.constructor=n,E=function(){functiona(){vara,b=h.length;for(a=0;b>a;a+=1)h[a].cancel();h=[]}varb,d,e,f,g=this,h=[];returnthisinstanceofE?(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)},void(g.monitor=function(a){if(f)thrownewn;varb=(newc.Queue).push(function(){returna}).push(function(a){varb,c,d=h.length,e=[];for(c=0;d>c;c+=1)b=h[c],b.isFulfilled||b.isRejected||e.push(b);h=e},function(b){throwbinstanceofc.CancellationError&&(a.isFulfilled&&a.isRejected||a.cancel()),d(b),b},function(a){returne(a),a});returnh.push(b),this})):newE},E.prototype=Object.create(c.Promise.prototype),E.prototype.constructor=E,o.prototype.__title="",o.prototype.__interface_list=[],o.prototype.__path="",o.prototype.__html="",o.prototype.__required_css_list=[],o.prototype.__required_js_list=[],o.__ready_list=[q,r],o.ready=function(a){returnthis.__ready_list.push(a),this},o.__service_list=[],o.declareService=function(a){returnthis.__service_list.push(a),this},o.declareMethod=function(a,b){returnthis.prototype[a]=function(){vara=this,d=arguments;return(newc.Queue).push(function(){returnb.apply(a,d)})},this},o.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(void0===this.__element)thrownewError("No element defined");returnthis.__element}),o.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},o.declareAcquiredMethod("aq_reportServiceError","reportServiceError"),o.allowPublicAcquisition=function(a,b){returnthis.prototype.__acquired_method_dict[a]=b,this},v.__ready_list=o.__ready_list.slice(),v.__service_list=o.__service_list.slice(),v.ready=o.ready,v.declareService=o.declareService,v.prototype=newo,v.prototype.constructor=v,x.__ready_list=o.__ready_list.slice(),x.ready=o.ready,x.__service_list=o.__service_list.slice(),x.declareService=o.declareService,x.prototype=newo,x.prototype.constructor=x,o.declareMethod("declareGadget",function(b,d){vare,f,g=this,h=C;returnvoid0===d&&(d={}),void0===d.sandbox&&(d.sandbox="public"),b=D.getAbsoluteURL(b,this.__path),C=(newc.Queue).push(function(){returnh}).push(void0,function(){}).push(function(){vara;if("public"===d.sandbox)a=w;elseif("iframe"===d.sandbox)a=y;else{if("dataurl"!==d.sandbox)thrownewError("Unsupported sandbox options '"+d.sandbox+"'");a=z}returna(b,d,g)}).push(function(a){returnB=void0,a}).push(void0,function(a){throwB=void0,a}),f=C,e=(newc.Queue).push(function(){returnf}).push(function(c){functionf(){returnc}varh,i;for(h=0;h<c.constructor.__ready_list.length;h+=1)e.push(c.constructor.__ready_list[h]),e.push(f);if(i=d.scope,void0===i)for(i="RJS_"+I,I+=1;g.__sub_gadget_dict.hasOwnProperty(i);)i="RJS_"+I,I+=1;returng.__sub_gadget_dict[i]=c,c.__element.setAttribute("data-gadget-scope",i),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(s),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]}),D=function(a){varc;if(a===b&&(c=B),void0===c)thrownewError("Unknown selector '"+a+"'");returnc},D.AcquisitionError=function(a){if(this.name="AcquisitionError",void0!==a&&"string"!=typeofa)thrownewTypeError("You must pass a string.");this.message=a||"Acquisition failed"},D.AcquisitionError.prototype=newError,D.AcquisitionError.prototype.constructor=D.AcquisitionError,D.getAbsoluteURL=function(a,b){varc,e,f,g="<!doctype><html><head></head></html>";returna&&b&&!J.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},D.declareJS=function(b){vard;returnd=G.hasOwnProperty(b)?c.resolve():newc.Promise(function(c,d){vare;e=a.createElement("script"),e.type="text/javascript",e.src=b,e.onload=function(){G[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},D.declareCSS=function(b){vard;returnd=H.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(){H[b]=null,c()},e.onerror=function(a){d(a)},a.head.appendChild(e)})},D.declareGadgetKlass=function(a){functionb(b){varc,e,f;if(!F.hasOwnProperty(a)){c=function(){o.call(this)},c.__ready_list=o.__ready_list.slice(),c.__service_list=o.__service_list.slice(),c.declareMethod=o.declareMethod,c.declareAcquiredMethod=o.declareAcquiredMethod,c.allowPublicAcquisition=o.allowPublicAcquisition,c.ready=o.ready,c.declareService=o.declareService,c.prototype=newo,c.prototype.constructor=c,c.prototype.__path=a,c.prototype.__acquired_method_dict={},c.__template_element=(newd).parseFromString(b.responseText,"text/html"),f=D.parseGadgetHTMLDocument(c.__template_element,a);for(einf)f.hasOwnProperty(e)&&(c.prototype["__"+e]=f[e]);F[a]=c}returnF[a]}vare;returne=F.hasOwnProperty(a)?c.resolve(F[a]):(newc.Queue).push(function(){returnk(a)}).push(function(a){returnb(a)})},D.clearGadgetKlassList=function(){F={},G={},H={}},D.parseGadgetHTMLDocument=function(a,b){varc,d,e={title:"",interface_list:[],required_css_list:[],required_js_list:[]};if(!b||!J.test(b))thrownewError("The url should be absolute: "+b);if(9!==a.nodeType)thrownewError("The first parameter should be an HTMLDocument");if(e.title=a.title,null!==a.head)for(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(D.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(D.getAbsoluteURL(d.getAttribute("href"),b)):e.required_js_list.push(D.getAbsoluteURL(d.getAttribute("src"),b)));returne},b.rJS=b.renderJS=D,b.__RenderJSGadget=o,b.__RenderJSEmbeddedGadget=v,b.__RenderJSIframeGadget=x,A()}(document,window,RSVP,DOMParser,Channel,MutationObserver,Node,FileReader,Blob);