(function(a,b,c,d,e,f,g){functionh(a,b,c,d){returno(a,a,c,d,b).then(function(e){E("Document cloned");varf="["+Qb+"='true']";a.querySelector(f).removeAttribute(Qb);varg=e.contentWindow,h=g.document.querySelector(f);returni(h,e,b,c,d)})}functioni(a,c,d,e,f){varg=c.contentWindow,h=newGb(g.document),i=newC(d,h),n=M(a),o=null!=d.width?d.width:"view"===d.type?Math.min(n.width,e):l(g.document),p=null!=d.height?d.height:"view"===d.type?Math.min(n.height,f):m(g.document),q=newOb(o,p,i,d,b),r=newO(a,q,h,i,d);returnr.ready.then(function(){E("Finished rendering");varb="view"===d.type||a!==g.document.body&&a!==g.document.documentElement&&null==d.canvas?k(q.canvas,{width:o,height:p,top:n.top,left:n.left}):q.canvas;returnj(c,d),b})}functionj(a,b){b.removeContainer&&(a.parentNode.removeChild(a),E("Cleaned up container"))}functionk(a,c){vard=b.createElement("canvas"),e=Math.min(a.width-1,Math.max(0,c.left)),f=Math.min(a.width,Math.max(1,c.left+c.width)),g=Math.min(a.height-1,Math.max(0,c.top)),h=Math.min(a.height,Math.max(1,c.top+c.height)),i=d.width=f-e,j=d.height=h-g;returnE("Cropping canvas at:","left:",c.left,"top:",c.top,"width:",c.width,"height:",c.height),E("Resulting crop with width",i,"and height",j," with x",e,"and y",g),d.getContext("2d").drawImage(a,e,g,i,j,0,0,i,j),d}functionl(a){returnMath.max(Math.max(a.body.scrollWidth,a.documentElement.scrollWidth),Math.max(a.body.offsetWidth,a.documentElement.offsetWidth),Math.max(a.body.clientWidth,a.documentElement.clientWidth))}functionm(a){returnMath.max(Math.max(a.body.scrollHeight,a.documentElement.scrollHeight),Math.max(a.body.offsetHeight,a.documentElement.offsetHeight),Math.max(a.body.clientHeight,a.documentElement.clientHeight))}functionn(){return"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}functiono(b,c,d,e,f){r(b);varg=b.documentElement.cloneNode(!0),h=c.createElement("iframe");returnh.style.visibility="hidden",h.style.position="absolute",h.style.left=h.style.top="-10000px",h.width=d,h.height=e,h.scrolling="no",c.body.appendChild(h),newPromise(function(c){vard=h.contentWindow.document;h.contentWindow.onload=h.onload=function(){vara=setInterval(function(){d.body.childNodes.length>0&&(s(b,d),clearInterval(a),c(h))},50)},d.open(),d.write("<!DOCTYPE html>"),d.close(),d.replaceChild(f.javascriptEnabled===!0?d.adoptNode(g):t(d.adoptNode(g)),d.documentElement),"view"===f.type&&h.contentWindow.scrollTo(a.pageXOffset,a.pageYOffset)})}functionp(b,c,d,e,f,g){returnnewxb(b,c,a.document).then(q(b)).then(function(a){returno(a,d,e,f,g)})}functionq(a){returnfunction(c){vard,e=newDOMParser;try{d=e.parseFromString(c,"text/html")}catch(f){E("DOMParser not supported, falling back to createHTMLDocument"),d=b.implementation.createHTMLDocument("");try{d.open(),d.write(c),d.close()}catch(g){E("createHTMLDocument write not supported, falling back to document.body.innerHTML"),d.body.innerHTML=c}}varh=d.querySelector("base");if(!h||!h.href.host){vari=d.createElement("base");i.href=a,d.head.insertBefore(i,d.head.firstChild)}returnd}}functionr(a){[].slice.call(a.querySelectorAll("canvas"),0).forEach(function(a){a.setAttribute(Rb,"canvas-"+Sb++)})}functions(a,b){[].slice.call(a.querySelectorAll("["+Rb+"]"),0).forEach(function(a){try{varc=b.querySelector("["+Rb+'="'+a.getAttribute(Rb)+'"]');c&&(c.width=a.width,c.height=a.height,c.getContext("2d").putImageData(a.getContext("2d").getImageData(0,0,a.width,a.height),0,0))}catch(d){E("Unable to copy canvas content from",a,d)}a.removeAttribute(Rb)})}functiont(a){return[].slice.call(a.childNodes,0).filter(u).forEach(function(b){"SCRIPT"===b.tagName?a.removeChild(b):t(b)}),a}functionu(a){returna.nodeType===Node.ELEMENT_NODE}functionv(a){varc=b.createElement("a");returnc.href=a,c.href=c.href,c}functionw(a){if(this.src=a,E("DummyImageContainer for",a),!this.promise||!this.image){E("Initiating DummyImageContainer"),w.prototype.image=newImage;varb=this.image;w.prototype.promise=newPromise(function(a,c){b.onload=a,b.onerror=c,b.src=n(),b.complete===!0&&a(b)})}}functionx(a,c){var