!function(a,b,c){functiond(a,b,c,d){returnk(a,a,c,d,b).then(function(f){A("Document cloned");varg="["+Kb+"='true']";a.querySelector(g).removeAttribute(Kb);varh=f.contentWindow,i=h.document.querySelector(g);returne(i,f,b,c,d)})}functione(a,c,d,e,j){vark=c.contentWindow,l=newAb(k.document),m=newy(d,l),n=I(a),o=null!=d.width?d.width:"view"===d.type?Math.min(n.width,e):h(k.document),p=null!=d.height?d.height:"view"===d.type?Math.min(n.height,j):i(k.document),q=newIb(o,p,m,d,b),r=newK(a,q,l,m,d);returnr.ready.then(function(){A("Finished rendering");varb="view"===d.type||a!==k.document.body&&a!==k.document.documentElement?g(q.canvas,{width:o,height:p,top:n.top,left:n.left}):q.canvas;returnf(c,d),b})}functionf(a,b){b.removeContainer&&(a.parentNode.removeChild(a),A("Cleaned up container"))}functiong(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;returnA("Cropping canvas at:","left:",c.left,"top:",c.top,"width:",c.width,"height:",c.height),A("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}functionh(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))}functioni(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))}functionj(){return"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}functionk(b,c,d,e,f){n(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&&(o(b,d),clearInterval(a),c(h))},50)},d.open(),d.write("<!DOCTYPE html>"),d.close(),d.replaceChild(f.javascriptEnabled===!0?d.adoptNode(g):p(d.adoptNode(g)),d.documentElement),"view"===f.type&&h.contentWindow.scrollTo(a.pageXOffset,a.pageYOffset)})}functionl(b,c,d,e,f,g){returnnewsb(b,c,a.document).then(m(b)).then(function(a){returnk(a,d,e,f,g)})}functionm(a){returnfunction(c){vard,e=newDOMParser;try{d=e.parseFromString(c,"text/html")}catch(f){A("DOMParser not supported, falling back to createHTMLDocument"),d=b.implementation.createHTMLDocument("");try{d.open(),d.write(c),d.close()}catch(g){A("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}}functionn(a){[].slice.call(a.querySelectorAll("canvas"),0).forEach(function(a){a.setAttribute(Lb,"canvas-"+Mb++)})}functiono(a,b){[].slice.call(a.querySelectorAll("["+Lb+"]"),0).forEach(function(a){try{varc=b.querySelector("["+Lb+'="'+a.getAttribute(Lb)+'"]');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){A("Unable to copy canvas content from",a,d)}a.removeAttribute(Lb)})}functionp(a){return[].slice.call(a.childNodes,0).filter(q).forEach(function(b){"SCRIPT"===b.tagName?a.removeChild(b):p(b)}),a}functionq(a){returna.nodeType===Node.ELEMENT_NODE}functionr(a){varc=b.createElement("a");returnc.href=a,c.href=c.href,c}functions(a){if(this.src=a,A("DummyImageContainer for",a),!this.promise||!this.image){A("Initiating DummyImageContainer"),s.prototype.image=newImage;varb=this.image;s.prototype.promise=newPromise(function(a,c){b.onload=a,b.onerror=c,b.src=j(),b.complete===!0&&a(b)})}}functiont(a,c){vard,e,f=b.createElement("