Skip to content

Instantly share code, notes, and snippets.

@grimen
Created November 17, 2013 23:33
Show Gist options
  • Save grimen/7519806 to your computer and use it in GitHub Desktop.
Save grimen/7519806 to your computer and use it in GitHub Desktop.
/*! rasterizeHTML.js - v0.5.1 - 2013-11-14
* http://www.github.com/cburgmer/rasterizeHTML.js
* Copyright (c) 2013 Christoph Burgmer;
/* Integrated dependencies:
* URI.js (MIT License/GPL v3),
* CSSOM (MIT License),
* xmlserializer (MIT License) */
!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.CSSOM=a():"undefined"!=typeof global?global.CSSOM=a():"undefined"!=typeof self&&(self.CSSOM=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule,MatcherList:a("./MatcherList").MatcherList};d.CSSDocumentRule=function(){d.CSSRule.call(this),this.matcher=new d.MatcherList,this.cssRules=[]},d.CSSDocumentRule.prototype=new d.CSSRule,d.CSSDocumentRule.prototype.constructor=d.CSSDocumentRule,d.CSSDocumentRule.prototype.type=10,Object.defineProperty(d.CSSDocumentRule.prototype,"cssText",{get:function(){for(var a=[],b=0,c=this.cssRules.length;c>b;b++)a.push(this.cssRules[b].cssText);return"@-moz-document "+this.matcher.matcherText+" {"+a.join("")+"}"}}),c.CSSDocumentRule=d.CSSDocumentRule},{"./CSSRule":7,"./MatcherList":13}],2:[function(a,b,c){var d={CSSStyleDeclaration:a("./CSSStyleDeclaration").CSSStyleDeclaration,CSSRule:a("./CSSRule").CSSRule};d.CSSFontFaceRule=function(){d.CSSRule.call(this),this.style=new d.CSSStyleDeclaration,this.style.parentRule=this},d.CSSFontFaceRule.prototype=new d.CSSRule,d.CSSFontFaceRule.prototype.constructor=d.CSSFontFaceRule,d.CSSFontFaceRule.prototype.type=5,Object.defineProperty(d.CSSFontFaceRule.prototype,"cssText",{get:function(){return"@font-face {"+this.style.cssText+"}"}}),c.CSSFontFaceRule=d.CSSFontFaceRule},{"./CSSRule":7,"./CSSStyleDeclaration":8}],3:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule,CSSStyleSheet:a("./CSSStyleSheet").CSSStyleSheet,MediaList:a("./MediaList").MediaList};d.CSSImportRule=function(){d.CSSRule.call(this),this.href="",this.media=new d.MediaList,this.styleSheet=new d.CSSStyleSheet},d.CSSImportRule.prototype=new d.CSSRule,d.CSSImportRule.prototype.constructor=d.CSSImportRule,d.CSSImportRule.prototype.type=3,Object.defineProperty(d.CSSImportRule.prototype,"cssText",{get:function(){var a=this.media.mediaText;return"@import url("+this.href+")"+(a?" "+a:"")+";"},set:function(a){for(var b,c,d=0,e="",f="";c=a.charAt(d);d++)switch(c){case" ":case" ":case"\r":case"\n":case"\f":"after-import"===e?e="url":f+=c;break;case"@":e||a.indexOf("@import",d)!==d||(e="after-import",d+="import".length,f="");break;case"u":if("url"===e&&a.indexOf("url(",d)===d){if(b=a.indexOf(")",d+1),-1===b)throw d+': ")" not found';d+="url(".length;var g=a.slice(d,b);g[0]===g[g.length-1]&&('"'===g[0]||"'"===g[0])&&(g=g.slice(1,-1)),this.href=g,d=b,e="media"}break;case'"':if("url"===e){if(b=a.indexOf('"',d+1),!b)throw d+": '\"' not found";this.href=a.slice(d+1,b),d=b,e="media"}break;case"'":if("url"===e){if(b=a.indexOf("'",d+1),!b)throw d+': "\'" not found';this.href=a.slice(d+1,b),d=b,e="media"}break;case";":"media"===e&&f&&(this.media.mediaText=f.trim());break;default:"media"===e&&(f+=c)}}}),c.CSSImportRule=d.CSSImportRule},{"./CSSRule":7,"./CSSStyleSheet":10,"./MediaList":14}],4:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule,CSSStyleDeclaration:a("./CSSStyleDeclaration").CSSStyleDeclaration};d.CSSKeyframeRule=function(){d.CSSRule.call(this),this.keyText="",this.style=new d.CSSStyleDeclaration,this.style.parentRule=this},d.CSSKeyframeRule.prototype=new d.CSSRule,d.CSSKeyframeRule.prototype.constructor=d.CSSKeyframeRule,d.CSSKeyframeRule.prototype.type=9,Object.defineProperty(d.CSSKeyframeRule.prototype,"cssText",{get:function(){return this.keyText+" {"+this.style.cssText+"} "}}),c.CSSKeyframeRule=d.CSSKeyframeRule},{"./CSSRule":7,"./CSSStyleDeclaration":8}],5:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule};d.CSSKeyframesRule=function(){d.CSSRule.call(this),this.name="",this.cssRules=[]},d.CSSKeyframesRule.prototype=new d.CSSRule,d.CSSKeyframesRule.prototype.constructor=d.CSSKeyframesRule,d.CSSKeyframesRule.prototype.type=8,Object.defineProperty(d.CSSKeyframesRule.prototype,"cssText",{get:function(){for(var a=[],b=0,c=this.cssRules.length;c>b;b++)a.push(" "+this.cssRules[b].cssText);return"@"+(this._vendorPrefix||"")+"keyframes "+this.name+" { \n"+a.join("\n")+"\n}"}}),c.CSSKeyframesRule=d.CSSKeyframesRule},{"./CSSRule":7}],6:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule,MediaList:a("./MediaList").MediaList};d.CSSMediaRule=function(){d.CSSRule.call(this),this.media=new d.MediaList,this.cssRules=[]},d.CSSMediaRule.prototype=new d.CSSRule,d.CSSMediaRule.prototype.constructor=d.CSSMediaRule,d.CSSMediaRule.prototype.type=4,Object.defineProperty(d.CSSMediaRule.prototype,"cssText",{get:function(){for(var a=[],b=0,c=this.cssRules.length;c>b;b++)a.push(this.cssRules[b].cssText);return"@media "+this.media.mediaText+" {"+a.join("")+"}"}}),c.CSSMediaRule=d.CSSMediaRule},{"./CSSRule":7,"./MediaList":14}],7:[function(a,b,c){var d={};d.CSSRule=function(){this.parentRule=null,this.parentStyleSheet=null},d.CSSRule.STYLE_RULE=1,d.CSSRule.IMPORT_RULE=3,d.CSSRule.MEDIA_RULE=4,d.CSSRule.FONT_FACE_RULE=5,d.CSSRule.PAGE_RULE=6,d.CSSRule.WEBKIT_KEYFRAMES_RULE=8,d.CSSRule.WEBKIT_KEYFRAME_RULE=9,d.CSSRule.prototype={constructor:d.CSSRule},c.CSSRule=d.CSSRule},{}],8:[function(a,b,c){var d={};d.CSSStyleDeclaration=function(){this.length=0,this.parentRule=null,this._importants={}},d.CSSStyleDeclaration.prototype={constructor:d.CSSStyleDeclaration,getPropertyValue:function(a){return this[a]||""},setProperty:function(a,b,c){if(this[a]){var d=Array.prototype.indexOf.call(this,a);0>d&&(this[this.length]=a,this.length++)}else this[this.length]=a,this.length++;this[a]=b,this._importants[a]=c},removeProperty:function(a){if(!(a in this))return"";var b=Array.prototype.indexOf.call(this,a);if(0>b)return"";var c=this[a];return this[a]="",Array.prototype.splice.call(this,b,1),c},getPropertyCSSValue:function(){},getPropertyPriority:function(a){return this._importants[a]||""},getPropertyShorthand:function(){},isPropertyImplicit:function(){},get cssText(){for(var a=[],b=0,c=this.length;c>b;++b){var d=this[b],e=this.getPropertyValue(d),f=this.getPropertyPriority(d);f&&(f=" !"+f),a[b]=d+": "+e+f+";"}return a.join(" ")},set cssText(a){var b,c;for(b=this.length;b--;)c=this[b],this[c]="";Array.prototype.splice.call(this,0,this.length),this._importants={};var e=d.parse("#bogus{"+a+"}").cssRules[0].style,f=e.length;for(b=0;f>b;++b)c=e[b],this.setProperty(e[b],e.getPropertyValue(c),e.getPropertyPriority(c))}},c.CSSStyleDeclaration=d.CSSStyleDeclaration,d.parse=a("./parse").parse},{"./parse":18}],9:[function(a,b,c){var d={CSSStyleDeclaration:a("./CSSStyleDeclaration").CSSStyleDeclaration,CSSRule:a("./CSSRule").CSSRule};d.CSSStyleRule=function(){d.CSSRule.call(this),this.selectorText="",this.style=new d.CSSStyleDeclaration,this.style.parentRule=this},d.CSSStyleRule.prototype=new d.CSSRule,d.CSSStyleRule.prototype.constructor=d.CSSStyleRule,d.CSSStyleRule.prototype.type=1,Object.defineProperty(d.CSSStyleRule.prototype,"cssText",{get:function(){var a;return a=this.selectorText?this.selectorText+" {"+this.style.cssText+"}":""},set:function(a){var b=d.CSSStyleRule.parse(a);this.style=b.style,this.selectorText=b.selectorText}}),d.CSSStyleRule.parse=function(a){for(var b,c,e,f=0,g="selector",h=f,i="",j={selector:!0,value:!0},k=new d.CSSStyleRule,l="";e=a.charAt(f);f++)switch(e){case" ":case" ":case"\r":case"\n":case"\f":if(j[g])switch(a.charAt(f-1)){case" ":case" ":case"\r":case"\n":case"\f":break;default:i+=" "}break;case'"':if(h=f+1,b=a.indexOf('"',h)+1,!b)throw'" is missing';i+=a.slice(f,b),f=b-1;break;case"'":if(h=f+1,b=a.indexOf("'",h)+1,!b)throw"' is missing";i+=a.slice(f,b),f=b-1;break;case"/":if("*"===a.charAt(f+1)){if(f+=2,b=a.indexOf("*/",f),-1===b)throw new SyntaxError("Missing */");f=b+1}else i+=e;break;case"{":"selector"===g&&(k.selectorText=i.trim(),i="",g="name");break;case":":"name"===g?(c=i.trim(),i="",g="value"):i+=e;break;case"!":"value"===g&&a.indexOf("!important",f)===f?(l="important",f+="important".length):i+=e;break;case";":"value"===g?(k.style.setProperty(c,i.trim(),l),l="",i="",g="name"):i+=e;break;case"}":if("value"===g)k.style.setProperty(c,i.trim(),l),l="",i="";else{if("name"===g)break;i+=e}g="selector";break;default:i+=e}return k},c.CSSStyleRule=d.CSSStyleRule},{"./CSSRule":7,"./CSSStyleDeclaration":8}],10:[function(a,b,c){var d={StyleSheet:a("./StyleSheet").StyleSheet,CSSStyleRule:a("./CSSStyleRule").CSSStyleRule};d.CSSStyleSheet=function(){d.StyleSheet.call(this),this.cssRules=[]},d.CSSStyleSheet.prototype=new d.StyleSheet,d.CSSStyleSheet.prototype.constructor=d.CSSStyleSheet,d.CSSStyleSheet.prototype.insertRule=function(a,b){if(0>b||b>this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");var c=d.parse(a).cssRules[0];return c.parentStyleSheet=this,this.cssRules.splice(b,0,c),b},d.CSSStyleSheet.prototype.deleteRule=function(a){if(0>a||a>=this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");this.cssRules.splice(a,1)},d.CSSStyleSheet.prototype.toString=function(){for(var a="",b=this.cssRules,c=0;c<b.length;c++)a+=b[c].cssText+"\n";return a},c.CSSStyleSheet=d.CSSStyleSheet,d.parse=a("./parse").parse},{"./CSSStyleRule":9,"./StyleSheet":15,"./parse":18}],11:[function(a,b,c){var d={};d.CSSValue=function(){},d.CSSValue.prototype={constructor:d.CSSValue,set cssText(a){var b=this._getConstructorName();throw new Exception('DOMException: property "cssText" of "'+b+'" is readonly!')},get cssText(){var a=this._getConstructorName();throw new Exception('getter "cssText" of "'+a+'" is not implemented!')},_getConstructorName:function(){var a=this.constructor.toString(),b=a.match(/function\s([^\(]+)/),c=b[1];return c}},c.CSSValue=d.CSSValue},{}],12:[function(a,b,c){var d={CSSValue:a("./CSSValue").CSSValue};d.CSSValueExpression=function(a,b){this._token=a,this._idx=b},d.CSSValueExpression.prototype=new d.CSSValue,d.CSSValueExpression.prototype.constructor=d.CSSValueExpression,d.CSSValueExpression.prototype.parse=function(){for(var a,b=this._token,c=this._idx,d="",e="",f="",g=[];;++c){if(d=b.charAt(c),""==d){f="css expression error: unfinished expression!";break}switch(d){case"(":g.push(d),e+=d;break;case")":g.pop(d),e+=d;break;case"/":(a=this._parseJSComment(b,c))?a.error?f="css expression error: unfinished comment in expression!":c=a.idx:(a=this._parseJSRexExp(b,c))?(c=a.idx,e+=a.text):e+=d;break;case"'":case'"':a=this._parseJSString(b,c,d),a?(c=a.idx,e+=a.text):e+=d;break;default:e+=d}if(f)break;if(0==g.length)break}var h;return h=f?{error:f}:{idx:c,expression:e}},d.CSSValueExpression.prototype._parseJSComment=function(a,b){var c,d=a.charAt(b+1);if("/"==d||"*"==d){var e,f,g=b;return"/"==d?f="\n":"*"==d&&(f="*/"),e=a.indexOf(f,g+1+1),-1!==e?(e=e+f.length-1,c=a.substring(b,e+1),{idx:e,text:c}):(error="css expression error: unfinished comment in expression!",{error:error})}return!1},d.CSSValueExpression.prototype._parseJSString=function(a,b,c){var d,e=this._findMatchedIdx(a,b,c);return-1===e?!1:(d=a.substring(b,e+c.length),{idx:e,text:d})},d.CSSValueExpression.prototype._parseJSRexExp=function(a,b){var c=a.substring(0,b).replace(/\s+$/,""),d=[/^$/,/\($/,/\[$/,/\!$/,/\+$/,/\-$/,/\*$/,/\/\s+/,/\%$/,/\=$/,/\>$/,/\<$/,/\&$/,/\|$/,/\^$/,/\~$/,/\?$/,/\,$/,/delete$/,/in$/,/instanceof$/,/new$/,/typeof$/,/void$/],e=d.some(function(a){return a.test(c)});if(e){var f="/";return this._parseJSString(a,b,f)}return!1},d.CSSValueExpression.prototype._findMatchedIdx=function(a,b,c){for(var d,e=b,f=-1;;){if(d=a.indexOf(c,e+1),-1===d){d=f;break}var g=a.substring(b+1,d),h=g.match(/\\+$/);if(!h||h[0]%2==0)break;e=d}var i=a.indexOf("\n",b+1);return d>i&&(d=f),d},c.CSSValueExpression=d.CSSValueExpression},{"./CSSValue":11}],13:[function(a,b,c){var d={};d.MatcherList=function(){this.length=0},d.MatcherList.prototype={constructor:d.MatcherList,get matcherText(){return Array.prototype.join.call(this,", ")},set matcherText(a){for(var b=a.split(","),c=this.length=b.length,d=0;c>d;d++)this[d]=b[d].trim()},appendMatcher:function(a){-1===Array.prototype.indexOf.call(this,a)&&(this[this.length]=a,this.length++)},deleteMatcher:function(a){var b=Array.prototype.indexOf.call(this,a);-1!==b&&Array.prototype.splice.call(this,b,1)}},c.MatcherList=d.MatcherList},{}],14:[function(a,b,c){var d={};d.MediaList=function(){this.length=0},d.MediaList.prototype={constructor:d.MediaList,get mediaText(){return Array.prototype.join.call(this,", ")},set mediaText(a){for(var b=a.split(","),c=this.length=b.length,d=0;c>d;d++)this[d]=b[d].trim()},appendMedium:function(a){-1===Array.prototype.indexOf.call(this,a)&&(this[this.length]=a,this.length++)},deleteMedium:function(a){var b=Array.prototype.indexOf.call(this,a);-1!==b&&Array.prototype.splice.call(this,b,1)}},c.MediaList=d.MediaList},{}],15:[function(a,b,c){var d={};d.StyleSheet=function(){this.parentStyleSheet=null},c.StyleSheet=d.StyleSheet},{}],16:[function(a,b,c){var d={CSSStyleSheet:a("./CSSStyleSheet").CSSStyleSheet,CSSStyleRule:a("./CSSStyleRule").CSSStyleRule,CSSMediaRule:a("./CSSMediaRule").CSSMediaRule,CSSStyleDeclaration:a("./CSSStyleDeclaration").CSSStyleDeclaration,CSSKeyframeRule:a("./CSSKeyframeRule").CSSKeyframeRule,CSSKeyframesRule:a("./CSSKeyframesRule").CSSKeyframesRule};d.clone=function e(a){var b=new d.CSSStyleSheet,c=a.cssRules;if(!c)return b;for(var f={1:d.CSSStyleRule,4:d.CSSMediaRule,8:d.CSSKeyframesRule,9:d.CSSKeyframeRule},g=0,h=c.length;h>g;g++){var i=c[g],j=b.cssRules[g]=new f[i.type],k=i.style;if(k){for(var l=j.style=new d.CSSStyleDeclaration,m=0,n=k.length;n>m;m++){var o=l[m]=k[m];l[o]=k[o],l._importants[o]=k.getPropertyPriority(o)}l.length=k.length}i.hasOwnProperty("keyText")&&(j.keyText=i.keyText),i.hasOwnProperty("selectorText")&&(j.selectorText=i.selectorText),i.hasOwnProperty("mediaText")&&(j.mediaText=i.mediaText),i.hasOwnProperty("cssRules")&&(j.cssRules=e(i).cssRules)}return b},c.clone=d.clone},{"./CSSKeyframeRule":4,"./CSSKeyframesRule":5,"./CSSMediaRule":6,"./CSSStyleDeclaration":8,"./CSSStyleRule":9,"./CSSStyleSheet":10}],17:[function(a,b,c){"use strict";c.CSSStyleDeclaration=a("./CSSStyleDeclaration").CSSStyleDeclaration,c.CSSRule=a("./CSSRule").CSSRule,c.CSSStyleRule=a("./CSSStyleRule").CSSStyleRule,c.MediaList=a("./MediaList").MediaList,c.CSSMediaRule=a("./CSSMediaRule").CSSMediaRule,c.CSSImportRule=a("./CSSImportRule").CSSImportRule,c.CSSFontFaceRule=a("./CSSFontFaceRule").CSSFontFaceRule,c.StyleSheet=a("./StyleSheet").StyleSheet,c.CSSStyleSheet=a("./CSSStyleSheet").CSSStyleSheet,c.CSSKeyframesRule=a("./CSSKeyframesRule").CSSKeyframesRule,c.CSSKeyframeRule=a("./CSSKeyframeRule").CSSKeyframeRule,c.MatcherList=a("./MatcherList").MatcherList,c.CSSDocumentRule=a("./CSSDocumentRule").CSSDocumentRule,c.CSSValue=a("./CSSValue").CSSValue,c.CSSValueExpression=a("./CSSValueExpression").CSSValueExpression,c.parse=a("./parse").parse,c.clone=a("./clone").clone},{"./CSSDocumentRule":1,"./CSSFontFaceRule":2,"./CSSImportRule":3,"./CSSKeyframeRule":4,"./CSSKeyframesRule":5,"./CSSMediaRule":6,"./CSSRule":7,"./CSSStyleDeclaration":8,"./CSSStyleRule":9,"./CSSStyleSheet":10,"./CSSValue":11,"./CSSValueExpression":12,"./MatcherList":13,"./MediaList":14,"./StyleSheet":15,"./clone":16,"./parse":18}],18:[function(a,b,c){var d={};d.parse=function(a){for(var b,c,e,f,g,h,i,j,k,l,m=0,n="before-selector",o="",p={selector:!0,value:!0,atRule:!0,"importRule-begin":!0,importRule:!0,atBlock:!0,"documentRule-begin":!0},q=new d.CSSStyleSheet,r=q,s="",t=/@(-(?:\w+-)+)?keyframes/g,u=function(b){var c=a.substring(0,m).split("\n"),d=c.length,e=c.pop().length+1,f=new Error(b+" (line "+d+", char "+e+")");throw f.line=d,f.char=e,f.styleSheet=q,f};l=a.charAt(m);m++)switch(l){case" ":case" ":case"\r":case"\n":case"\f":p[n]&&(o+=l);break;case'"':b=m+1;do b=a.indexOf('"',b)+1,b||u('Unmatched "');while("\\"===a[b-2]);switch(o+=a.slice(m,b),m=b-1,n){case"before-value":n="value";break;case"importRule-begin":n="importRule"}break;case"'":b=m+1;do b=a.indexOf("'",b)+1,b||u("Unmatched '");while("\\"===a[b-2]);switch(o+=a.slice(m,b),m=b-1,n){case"before-value":n="value";break;case"importRule-begin":n="importRule"}break;case"/":"*"===a.charAt(m+1)?(m+=2,b=a.indexOf("*/",m),-1===b?u("Missing */"):m=b+1):o+=l,"importRule-begin"===n&&(o+=" ",n="importRule");break;case"@":if(a.indexOf("@-moz-document",m)===m){n="documentRule-begin",k=new d.CSSDocumentRule,k.__starts=m,m+="-moz-document".length,o="";break}if(a.indexOf("@media",m)===m){n="atBlock",g=new d.CSSMediaRule,g.__starts=m,m+="media".length,o="";break}if(a.indexOf("@import",m)===m){n="importRule-begin",m+="import".length,o+="@import";break}if(a.indexOf("@font-face",m)===m){n="fontFaceRule-begin",m+="font-face".length,i=new d.CSSFontFaceRule,i.__starts=m,o="";break}t.lastIndex=m;var v=t.exec(a);if(v&&v.index===m){n="keyframesRule-begin",j=new d.CSSKeyframesRule,j.__starts=m,j._vendorPrefix=v[1],m+=v[0].length-1,o="";break}"selector"==n&&(n="atRule"),o+=l;break;case"{":"selector"===n||"atRule"===n?(f.selectorText=o.trim(),f.style.__starts=m,o="",n="before-name"):"atBlock"===n?(g.media.mediaText=o.trim(),r=c=g,g.parentStyleSheet=q,o="",n="before-selector"):"fontFaceRule-begin"===n?(c&&(i.parentRule=c),i.parentStyleSheet=q,f=i,o="",n="before-name"):"keyframesRule-begin"===n?(j.name=o.trim(),c&&(j.parentRule=c),j.parentStyleSheet=q,r=c=j,o="",n="keyframeRule-begin"):"keyframeRule-begin"===n?(f=new d.CSSKeyframeRule,f.keyText=o.trim(),f.__starts=m,o="",n="before-name"):"documentRule-begin"===n&&(k.matcher.matcherText=o.trim(),c&&(k.parentRule=c),r=c=k,k.parentStyleSheet=q,o="",n="before-selector");break;case":":"name"===n?(e=o.trim(),o="",n="before-value"):o+=l;break;case"(":if("value"===n)if("expression"==o.trim()){var w=new d.CSSValueExpression(a,m).parse();w.error?u(w.error):(o+=w.expression,m=w.idx)}else b=a.indexOf(")",m+1),-1===b&&u('Unmatched "("'),o+=a.slice(m,b+1),m=b;else o+=l;break;case"!":"value"===n&&a.indexOf("!important",m)===m?(s="important",m+="important".length):o+=l;break;case";":switch(n){case"value":f.style.setProperty(e,o.trim(),s),s="",o="",n="before-name";break;case"atRule":o="",n="before-selector";break;case"importRule":h=new d.CSSImportRule,h.parentStyleSheet=h.styleSheet.parentStyleSheet=q,h.cssText=o+l,q.cssRules.push(h),o="",n="before-selector";break;default:o+=l}break;case"}":switch(n){case"value":f.style.setProperty(e,o.trim(),s),s="";case"before-name":case"name":f.__ends=m+1,c&&(f.parentRule=c),f.parentStyleSheet=q,r.cssRules.push(f),o="",n=r.constructor===d.CSSKeyframesRule?"keyframeRule-begin":"before-selector";break;case"keyframeRule-begin":case"before-selector":case"selector":c||u("Unexpected }"),r.__ends=m+1,q.cssRules.push(r),r=q,c=null,o="",n="before-selector"}break;default:switch(n){case"before-selector":n="selector",f=new d.CSSStyleRule,f.__starts=m;break;case"before-name":n="name";break;case"before-value":n="value";break;case"importRule-begin":n="importRule"}o+=l}return q},c.parse=d.parse,d.CSSStyleSheet=a("./CSSStyleSheet").CSSStyleSheet,d.CSSStyleRule=a("./CSSStyleRule").CSSStyleRule,d.CSSImportRule=a("./CSSImportRule").CSSImportRule,d.CSSMediaRule=a("./CSSMediaRule").CSSMediaRule,d.CSSFontFaceRule=a("./CSSFontFaceRule").CSSFontFaceRule,d.CSSStyleDeclaration=a("./CSSStyleDeclaration").CSSStyleDeclaration,d.CSSKeyframeRule=a("./CSSKeyframeRule").CSSKeyframeRule,d.CSSKeyframesRule=a("./CSSKeyframesRule").CSSKeyframesRule,d.CSSValueExpression=a("./CSSValueExpression").CSSValueExpression,d.CSSDocumentRule=a("./CSSDocumentRule").CSSDocumentRule},{"./CSSDocumentRule":1,"./CSSFontFaceRule":2,"./CSSImportRule":3,"./CSSKeyframeRule":4,"./CSSKeyframesRule":5,"./CSSMediaRule":6,"./CSSStyleDeclaration":8,"./CSSStyleRule":9,"./CSSStyleSheet":10,"./CSSValueExpression":12}]},{},[17])(17)}),!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.URI=a():"undefined"!=typeof global?global.URI=a():"undefined"!=typeof self&&(self.URI=a())}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(b,c,d){!function(b,e){"object"==typeof d?c.exports=e():"function"==typeof a&&a.amd?a(e):b.IPv6=e(b)}(this,function(a){"use strict";function b(a){var b=a.toLowerCase(),c=b.split(":"),d=c.length,e=8;""===c[0]&&""===c[1]&&""===c[2]?(c.shift(),c.shift()):""===c[0]&&""===c[1]?c.shift():""===c[d-1]&&""===c[d-2]&&c.pop(),d=c.length,-1!==c[d-1].indexOf(".")&&(e=7);var f;for(f=0;d>f&&""!==c[f];f++);if(e>f){for(c.splice(f,1,"0000");c.length<e;)c.splice(f,0,"0000");d=c.length}for(var g,h=0;e>h;h++){g=c[h].split("");for(var i=0;3>i&&("0"===g[0]&&g.length>1);i++)g.splice(0,1);c[h]=g.join("")}var j=-1,k=0,l=0,m=-1,n=!1;for(h=0;e>h;h++)n?"0"===c[h]?l+=1:(n=!1,l>k&&(j=m,k=l)):"0"==c[h]&&(n=!0,m=h,l=1);l>k&&(j=m,k=l),k>1&&c.splice(j,k,""),d=c.length;var o="";for(""===c[0]&&(beststr=":"),h=0;d>h&&(o+=c[h],h!==d-1);h++)o+=":";return""===c[d-1]&&(o+=":"),o}function c(){return a.IPv6===this&&(a.IPv6=d),this}var d=a&&a.IPv6;return{best:b,noConflict:c}})},{}],2:[function(b,c,d){!function(b,e){"object"==typeof d?c.exports=e():"function"==typeof a&&a.amd?a(e):b.SecondLevelDomains=e(b)}(this,function(a){"use strict";var b=a&&a.SecondLevelDomains,c=Object.prototype.hasOwnProperty,d={list:{ac:"com|gov|mil|net|org",ae:"ac|co|gov|mil|name|net|org|pro|sch",af:"com|edu|gov|net|org",al:"com|edu|gov|mil|net|org",ao:"co|ed|gv|it|og|pb",ar:"com|edu|gob|gov|int|mil|net|org|tur",at:"ac|co|gv|or",au:"asn|com|csiro|edu|gov|id|net|org",ba:"co|com|edu|gov|mil|net|org|rs|unbi|unmo|unsa|untz|unze",bb:"biz|co|com|edu|gov|info|net|org|store|tv",bh:"biz|cc|com|edu|gov|info|net|org",bn:"com|edu|gov|net|org",bo:"com|edu|gob|gov|int|mil|net|org|tv",br:"adm|adv|agr|am|arq|art|ato|b|bio|blog|bmd|cim|cng|cnt|com|coop|ecn|edu|eng|esp|etc|eti|far|flog|fm|fnd|fot|fst|g12|ggf|gov|imb|ind|inf|jor|jus|lel|mat|med|mil|mus|net|nom|not|ntr|odo|org|ppg|pro|psc|psi|qsl|rec|slg|srv|tmp|trd|tur|tv|vet|vlog|wiki|zlg",bs:"com|edu|gov|net|org",bz:"du|et|om|ov|rg",ca:"ab|bc|mb|nb|nf|nl|ns|nt|nu|on|pe|qc|sk|yk",ck:"biz|co|edu|gen|gov|info|net|org",cn:"ac|ah|bj|com|cq|edu|fj|gd|gov|gs|gx|gz|ha|hb|he|hi|hl|hn|jl|js|jx|ln|mil|net|nm|nx|org|qh|sc|sd|sh|sn|sx|tj|tw|xj|xz|yn|zj",co:"com|edu|gov|mil|net|nom|org",cr:"ac|c|co|ed|fi|go|or|sa",cy:"ac|biz|com|ekloges|gov|ltd|name|net|org|parliament|press|pro|tm","do":"art|com|edu|gob|gov|mil|net|org|sld|web",dz:"art|asso|com|edu|gov|net|org|pol",ec:"com|edu|fin|gov|info|med|mil|net|org|pro",eg:"com|edu|eun|gov|mil|name|net|org|sci",er:"com|edu|gov|ind|mil|net|org|rochest|w",es:"com|edu|gob|nom|org",et:"biz|com|edu|gov|info|name|net|org",fj:"ac|biz|com|info|mil|name|net|org|pro",fk:"ac|co|gov|net|nom|org",fr:"asso|com|f|gouv|nom|prd|presse|tm",gg:"co|net|org",gh:"com|edu|gov|mil|org",gn:"ac|com|gov|net|org",gr:"com|edu|gov|mil|net|org",gt:"com|edu|gob|ind|mil|net|org",gu:"com|edu|gov|net|org",hk:"com|edu|gov|idv|net|org",id:"ac|co|go|mil|net|or|sch|web",il:"ac|co|gov|idf|k12|muni|net|org","in":"ac|co|edu|ernet|firm|gen|gov|i|ind|mil|net|nic|org|res",iq:"com|edu|gov|i|mil|net|org",ir:"ac|co|dnssec|gov|i|id|net|org|sch",it:"edu|gov",je:"co|net|org",jo:"com|edu|gov|mil|name|net|org|sch",jp:"ac|ad|co|ed|go|gr|lg|ne|or",ke:"ac|co|go|info|me|mobi|ne|or|sc",kh:"com|edu|gov|mil|net|org|per",ki:"biz|com|de|edu|gov|info|mob|net|org|tel",km:"asso|com|coop|edu|gouv|k|medecin|mil|nom|notaires|pharmaciens|presse|tm|veterinaire",kn:"edu|gov|net|org",kr:"ac|busan|chungbuk|chungnam|co|daegu|daejeon|es|gangwon|go|gwangju|gyeongbuk|gyeonggi|gyeongnam|hs|incheon|jeju|jeonbuk|jeonnam|k|kg|mil|ms|ne|or|pe|re|sc|seoul|ulsan",kw:"com|edu|gov|net|org",ky:"com|edu|gov|net|org",kz:"com|edu|gov|mil|net|org",lb:"com|edu|gov|net|org",lk:"assn|com|edu|gov|grp|hotel|int|ltd|net|ngo|org|sch|soc|web",lr:"com|edu|gov|net|org",lv:"asn|com|conf|edu|gov|id|mil|net|org",ly:"com|edu|gov|id|med|net|org|plc|sch",ma:"ac|co|gov|m|net|org|press",mc:"asso|tm",me:"ac|co|edu|gov|its|net|org|priv",mg:"com|edu|gov|mil|nom|org|prd|tm",mk:"com|edu|gov|inf|name|net|org|pro",ml:"com|edu|gov|net|org|presse",mn:"edu|gov|org",mo:"com|edu|gov|net|org",mt:"com|edu|gov|net|org",mv:"aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro",mw:"ac|co|com|coop|edu|gov|int|museum|net|org",mx:"com|edu|gob|net|org",my:"com|edu|gov|mil|name|net|org|sch",nf:"arts|com|firm|info|net|other|per|rec|store|web",ng:"biz|com|edu|gov|mil|mobi|name|net|org|sch",ni:"ac|co|com|edu|gob|mil|net|nom|org",np:"com|edu|gov|mil|net|org",nr:"biz|com|edu|gov|info|net|org",om:"ac|biz|co|com|edu|gov|med|mil|museum|net|org|pro|sch",pe:"com|edu|gob|mil|net|nom|org|sld",ph:"com|edu|gov|i|mil|net|ngo|org",pk:"biz|com|edu|fam|gob|gok|gon|gop|gos|gov|net|org|web",pl:"art|bialystok|biz|com|edu|gda|gdansk|gorzow|gov|info|katowice|krakow|lodz|lublin|mil|net|ngo|olsztyn|org|poznan|pwr|radom|slupsk|szczecin|torun|warszawa|waw|wroc|wroclaw|zgora",pr:"ac|biz|com|edu|est|gov|info|isla|name|net|org|pro|prof",ps:"com|edu|gov|net|org|plo|sec",pw:"belau|co|ed|go|ne|or",ro:"arts|com|firm|info|nom|nt|org|rec|store|tm|www",rs:"ac|co|edu|gov|in|org",sb:"com|edu|gov|net|org",sc:"com|edu|gov|net|org",sh:"co|com|edu|gov|net|nom|org",sl:"com|edu|gov|net|org",st:"co|com|consulado|edu|embaixada|gov|mil|net|org|principe|saotome|store",sv:"com|edu|gob|org|red",sz:"ac|co|org",tr:"av|bbs|bel|biz|com|dr|edu|gen|gov|info|k12|name|net|org|pol|tel|tsk|tv|web",tt:"aero|biz|cat|co|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel",tw:"club|com|ebiz|edu|game|gov|idv|mil|net|org",mu:"ac|co|com|gov|net|or|org",mz:"ac|co|edu|gov|org",na:"co|com",nz:"ac|co|cri|geek|gen|govt|health|iwi|maori|mil|net|org|parliament|school",pa:"abo|ac|com|edu|gob|ing|med|net|nom|org|sld",pt:"com|edu|gov|int|net|nome|org|publ",py:"com|edu|gov|mil|net|org",qa:"com|edu|gov|mil|net|org",re:"asso|com|nom",ru:"ac|adygeya|altai|amur|arkhangelsk|astrakhan|bashkiria|belgorod|bir|bryansk|buryatia|cbg|chel|chelyabinsk|chita|chukotka|chuvashia|com|dagestan|e-burg|edu|gov|grozny|int|irkutsk|ivanovo|izhevsk|jar|joshkar-ola|kalmykia|kaluga|kamchatka|karelia|kazan|kchr|kemerovo|khabarovsk|khakassia|khv|kirov|koenig|komi|kostroma|kranoyarsk|kuban|kurgan|kursk|lipetsk|magadan|mari|mari-el|marine|mil|mordovia|mosreg|msk|murmansk|nalchik|net|nnov|nov|novosibirsk|nsk|omsk|orenburg|org|oryol|penza|perm|pp|pskov|ptz|rnd|ryazan|sakhalin|samara|saratov|simbirsk|smolensk|spb|stavropol|stv|surgut|tambov|tatarstan|tom|tomsk|tsaritsyn|tsk|tula|tuva|tver|tyumen|udm|udmurtia|ulan-ude|vladikavkaz|vladimir|vladivostok|volgograd|vologda|voronezh|vrn|vyatka|yakutia|yamal|yekaterinburg|yuzhno-sakhalinsk",rw:"ac|co|com|edu|gouv|gov|int|mil|net",sa:"com|edu|gov|med|net|org|pub|sch",sd:"com|edu|gov|info|med|net|org|tv",se:"a|ac|b|bd|c|d|e|f|g|h|i|k|l|m|n|o|org|p|parti|pp|press|r|s|t|tm|u|w|x|y|z",sg:"com|edu|gov|idn|net|org|per",sn:"art|com|edu|gouv|org|perso|univ",sy:"com|edu|gov|mil|net|news|org",th:"ac|co|go|in|mi|net|or",tj:"ac|biz|co|com|edu|go|gov|info|int|mil|name|net|nic|org|test|web",tn:"agrinet|com|defense|edunet|ens|fin|gov|ind|info|intl|mincom|nat|net|org|perso|rnrt|rns|rnu|tourism",tz:"ac|co|go|ne|or",ua:"biz|cherkassy|chernigov|chernovtsy|ck|cn|co|com|crimea|cv|dn|dnepropetrovsk|donetsk|dp|edu|gov|if|in|ivano-frankivsk|kh|kharkov|kherson|khmelnitskiy|kiev|kirovograd|km|kr|ks|kv|lg|lugansk|lutsk|lviv|me|mk|net|nikolaev|od|odessa|org|pl|poltava|pp|rovno|rv|sebastopol|sumy|te|ternopil|uzhgorod|vinnica|vn|zaporizhzhe|zhitomir|zp|zt",ug:"ac|co|go|ne|or|org|sc",uk:"ac|bl|british-library|co|cym|gov|govt|icnet|jet|lea|ltd|me|mil|mod|national-library-scotland|nel|net|nhs|nic|nls|org|orgn|parliament|plc|police|sch|scot|soc",us:"dni|fed|isa|kids|nsn",uy:"com|edu|gub|mil|net|org",ve:"co|com|edu|gob|info|mil|net|org|web",vi:"co|com|k12|net|org",vn:"ac|biz|com|edu|gov|health|info|int|name|net|org|pro",ye:"co|com|gov|ltd|me|net|org|plc",yu:"ac|co|edu|gov|org",za:"ac|agric|alt|bourse|city|co|cybernet|db|edu|gov|grondar|iaccess|imt|inca|landesign|law|mil|net|ngo|nis|nom|olivetti|org|pix|school|tm|web",zm:"ac|co|com|edu|gov|net|org|sch"},has_expression:null,is_expression:null,has:function(a){return!!a.match(d.has_expression)},is:function(a){return!!a.match(d.is_expression)},get:function(a){var b=a.match(d.has_expression);return b&&b[1]||null},noConflict:function(){return a.SecondLevelDomains===this&&(a.SecondLevelDomains=b),this},init:function(){var a="";for(var b in d.list)if(c.call(d.list,b)){var e="("+d.list[b]+")."+b;a+="|("+e+")"}d.has_expression=new RegExp("\\.("+a.substr(1)+")$","i"),d.is_expression=new RegExp("^("+a.substr(1)+")$","i")}};return d.init(),d})},{}],3:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=f(b("./punycode"),b("./IPv6"),b("./SecondLevelDomains")):"function"==typeof a&&a.amd?a(["./punycode","./IPv6","./SecondLevelDomains"],f):e.URI=f(e.punycode,e.IPv6,e.SecondLevelDomains,e)}(this,function(a,b,c,d){"use strict";function e(a,b){return this instanceof e?(void 0===a&&(a="undefined"!=typeof location?location.href+"":""),this.href(a),void 0!==b?this.absoluteTo(b):this):new e(a,b)}function f(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function g(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function h(a){return"Array"===g(a)}function i(a,b){var c,d,e={};if(h(b))for(c=0,d=b.length;d>c;c++)e[b[c]]=!0;else e[b]=!0;for(c=0,d=a.length;d>c;c++)void 0!==e[a[c]]&&(a.splice(c,1),d--,c--);return a}function j(a,b){var c,d;if(h(b)){for(c=0,d=b.length;d>c;c++)if(!j(a,b[c]))return!1;return!0}var e=g(b);for(c=0,d=a.length;d>c;c++)if("RegExp"===e){if("string"==typeof a[c]&&a[c].match(b))return!0}else if(a[c]===b)return!0;return!1}function k(a,b){if(!h(a)||!h(b))return!1;if(a.length!==b.length)return!1;a.sort(),b.sort();for(var c=0,d=a.length;d>c;c++)if(a[c]!==b[c])return!1;return!0}function l(a){return escape(a)}function m(a){return encodeURIComponent(a).replace(/[!'()*]/g,l).replace(/\*/g,"%2A")}var n=d&&d.URI,o=e.prototype,p=Object.prototype.hasOwnProperty;e._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:e.duplicateQueryParameters,escapeQuerySpace:e.escapeQuerySpace}},e.duplicateQueryParameters=!1,e.escapeQuerySpace=!0,e.protocol_expression=/^[a-z][a-z0-9-+-]*$/i,e.idn_expression=/[^a-z0-9\.-]/i,e.punycode_expression=/(xn--)/i,e.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,e.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,e.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,e.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},e.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,e.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src"},e.getDomAttribute=function(a){if(!a||!a.nodeName)return void 0;
var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:e.domAttributes[b]},e.encode=m,e.decode=decodeURIComponent,e.iso8859=function(){e.encode=escape,e.decode=unescape},e.unicode=function(){e.encode=m,e.decode=decodeURIComponent},e.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}}},e.encodeQuery=function(a,b){var c=e.encode(a+"");return b?c.replace(/%20/g,"+"):c},e.decodeQuery=function(a,b){a+="";try{return e.decode(b?a.replace(/\+/g,"%20"):a)}catch(c){return a}},e.recodePath=function(a){for(var b=(a+"").split("/"),c=0,d=b.length;d>c;c++)b[c]=e.encodePathSegment(e.decode(b[c]));return b.join("/")},e.decodePath=function(a){for(var b=(a+"").split("/"),c=0,d=b.length;d>c;c++)b[c]=e.decodePathSegment(b[c]);return b.join("/")};var q,r={encode:"encode",decode:"decode"},s=function(a,b){return function(c){return e[b](c+"").replace(e.characters[a][b].expression,function(c){return e.characters[a][b].map[c]})}};for(q in r)e[q+"PathSegment"]=s("pathname",r[q]);e.encodeReserved=s("reserved","encode"),e.parse=function(a,b){var c;return b||(b={}),c=a.indexOf("#"),c>-1&&(b.fragment=a.substring(c+1)||null,a=a.substring(0,c)),c=a.indexOf("?"),c>-1&&(b.query=a.substring(c+1)||null,a=a.substring(0,c)),"//"===a.substring(0,2)?(b.protocol=null,a=a.substring(2),a=e.parseAuthority(a,b)):(c=a.indexOf(":"),c>-1&&(b.protocol=a.substring(0,c)||null,b.protocol&&!b.protocol.match(e.protocol_expression)?b.protocol=void 0:"file"===b.protocol?a=a.substring(c+3):"//"===a.substring(c+1,c+3)?(a=a.substring(c+3),a=e.parseAuthority(a,b)):(a=a.substring(c+1),b.urn=!0))),b.path=a,b},e.parseHost=function(a,b){var c,d,e=a.indexOf("/");return-1===e&&(e=a.length),"["===a.charAt(0)?(c=a.indexOf("]"),b.hostname=a.substring(1,c)||null,b.port=a.substring(c+2,e)||null):a.indexOf(":")!==a.lastIndexOf(":")?(b.hostname=a.substring(0,e)||null,b.port=null):(d=a.substring(0,e).split(":"),b.hostname=d[0]||null,b.port=d[1]||null),b.hostname&&"/"!==a.substring(e).charAt(0)&&(e++,a="/"+a),a.substring(e)||"/"},e.parseAuthority=function(a,b){return a=e.parseUserinfo(a,b),e.parseHost(a,b)},e.parseUserinfo=function(a,b){var c,d=a.indexOf("/"),f=d>-1?a.lastIndexOf("@",d):a.indexOf("@");return f>-1&&(-1===d||d>f)?(c=a.substring(0,f).split(":"),b.username=c[0]?e.decode(c[0]):null,c.shift(),b.password=c[0]?e.decode(c.join(":")):null,a=a.substring(f+1)):(b.username=null,b.password=null),a},e.parseQuery=function(a,b){if(!a)return{};if(a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!a)return{};for(var c,d,f,g={},h=a.split("&"),i=h.length,j=0;i>j;j++)c=h[j].split("="),d=e.decodeQuery(c.shift(),b),f=c.length?e.decodeQuery(c.join("="),b):null,g[d]?("string"==typeof g[d]&&(g[d]=[g[d]]),g[d].push(f)):g[d]=f;return g},e.build=function(a){var b="";return a.protocol&&(b+=a.protocol+":"),a.urn||!b&&!a.hostname||(b+="//"),b+=e.buildAuthority(a)||"","string"==typeof a.path&&("/"!==a.path.charAt(0)&&"string"==typeof a.hostname&&(b+="/"),b+=a.path),"string"==typeof a.query&&a.query&&(b+="?"+a.query),"string"==typeof a.fragment&&a.fragment&&(b+="#"+a.fragment),b},e.buildHost=function(a){var b="";return a.hostname?(e.ip6_expression.test(a.hostname)?b+=a.port?"["+a.hostname+"]:"+a.port:a.hostname:(b+=a.hostname,a.port&&(b+=":"+a.port)),b):""},e.buildAuthority=function(a){return e.buildUserinfo(a)+e.buildHost(a)},e.buildUserinfo=function(a){var b="";return a.username&&(b+=e.encode(a.username),a.password&&(b+=":"+e.encode(a.password)),b+="@"),b},e.buildQuery=function(a,b,c){var d,f,g,i,j="";for(f in a)if(p.call(a,f)&&f)if(h(a[f]))for(d={},g=0,i=a[f].length;i>g;g++)void 0!==a[f][g]&&void 0===d[a[f][g]+""]&&(j+="&"+e.buildQueryParameter(f,a[f][g],c),b!==!0&&(d[a[f][g]+""]=!0));else void 0!==a[f]&&(j+="&"+e.buildQueryParameter(f,a[f],c));return j.substring(1)},e.buildQueryParameter=function(a,b,c){return e.encodeQuery(a,c)+(null!==b?"="+e.encodeQuery(b,c):"")},e.addQuery=function(a,b,c){if("object"==typeof b)for(var d in b)p.call(b,d)&&e.addQuery(a,d,b[d]);else{if("string"!=typeof b)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");if(void 0===a[b])return a[b]=c,void 0;"string"==typeof a[b]&&(a[b]=[a[b]]),h(c)||(c=[c]),a[b]=a[b].concat(c)}},e.removeQuery=function(a,b,c){var d,f,g;if(h(b))for(d=0,f=b.length;f>d;d++)a[b[d]]=void 0;else if("object"==typeof b)for(g in b)p.call(b,g)&&e.removeQuery(a,g,b[g]);else{if("string"!=typeof b)throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");void 0!==c?a[b]===c?a[b]=void 0:h(a[b])&&(a[b]=i(a[b],c)):a[b]=void 0}},e.hasQuery=function(a,b,c,d){if("object"==typeof b){for(var f in b)if(p.call(b,f)&&!e.hasQuery(a,f,b[f]))return!1;return!0}if("string"!=typeof b)throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter");switch(g(c)){case"Undefined":return b in a;case"Boolean":var i=Boolean(h(a[b])?a[b].length:a[b]);return c===i;case"Function":return!!c(a[b],b,a);case"Array":if(!h(a[b]))return!1;var l=d?j:k;return l(a[b],c);case"RegExp":return h(a[b])?d?j(a[b],c):!1:Boolean(a[b]&&a[b].match(c));case"Number":c=String(c);case"String":return h(a[b])?d?j(a[b],c):!1:a[b]===c;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}},e.commonPath=function(a,b){var c,d=Math.min(a.length,b.length);for(c=0;d>c;c++)if(a.charAt(c)!==b.charAt(c)){c--;break}return 1>c?a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"":(("/"!==a.charAt(c)||"/"!==b.charAt(c))&&(c=a.substring(0,c).lastIndexOf("/")),a.substring(0,c+1))},e.withinString=function(a,b){return a.replace(e.find_uri_expression,b)},e.ensureValidHostname=function(b){if(b.match(e.invalid_hostname_characters)){if(!a)throw new TypeError("Hostname '"+b+"' contains characters other than [A-Z0-9.-] and Punycode.js is not available");if(a.toASCII(b).match(e.invalid_hostname_characters))throw new TypeError("Hostname '"+b+"' contains characters other than [A-Z0-9.-]")}},e.noConflict=function(a){if(a){var c={URI:this.noConflict()};return URITemplate&&"function"==typeof URITemplate.noConflict&&(c.URITemplate=URITemplate.noConflict()),b&&"function"==typeof b.noConflict&&(c.IPv6=b.noConflict()),SecondLevelDomains&&"function"==typeof SecondLevelDomains.noConflict&&(c.SecondLevelDomains=SecondLevelDomains.noConflict()),c}return d.URI===this&&(d.URI=n),this},o.build=function(a){return a===!0?this._deferred_build=!0:(void 0===a||this._deferred_build)&&(this._string=e.build(this._parts),this._deferred_build=!1),this},o.clone=function(){return new e(this)},o.valueOf=o.toString=function(){return this.build(!1)._string},r={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"},s=function(a){return function(b,c){return void 0===b?this._parts[a]||"":(this._parts[a]=b||null,this.build(!c),this)}};for(q in r)o[q]=s(r[q]);r={query:"?",fragment:"#"},s=function(a,b){return function(c,d){return void 0===c?this._parts[a]||"":(null!==c&&(c+="",c.charAt(0)===b&&(c=c.substring(1))),this._parts[a]=c,this.build(!d),this)}};for(q in r)o[q]=s(q,r[q]);r={search:["?","query"],hash:["#","fragment"]},s=function(a,b){return function(c,d){var e=this[a](c,d);return"string"==typeof e&&e.length?b+e:e}};for(q in r)o[q]=s(r[q][1],r[q][0]);o.pathname=function(a,b){if(void 0===a||a===!0){var c=this._parts.path||(this._parts.hostname?"/":"");return a?e.decodePath(c):c}return this._parts.path=a?e.recodePath(a):"/",this.build(!b),this},o.path=o.pathname,o.href=function(a,b){var c;if(void 0===a)return this.toString();this._string="",this._parts=e._parts();var d=a instanceof e,f="object"==typeof a&&(a.hostname||a.path||a.pathname);if(a.nodeName){var g=e.getDomAttribute(a);a=a[g]||"",f=!1}if(!d&&f&&void 0!==a.pathname&&(a=a.toString()),"string"==typeof a)this._parts=e.parse(a,this._parts);else{if(!d&&!f)throw new TypeError("invalid input");var h=d?a._parts:a;for(c in h)p.call(this._parts,c)&&(this._parts[c]=h[c])}return this.build(!b),this},o.is=function(a){var b=!1,d=!1,f=!1,g=!1,h=!1,i=!1,j=!1,k=!this._parts.urn;switch(this._parts.hostname&&(k=!1,d=e.ip4_expression.test(this._parts.hostname),f=e.ip6_expression.test(this._parts.hostname),b=d||f,g=!b,h=g&&c&&c.has(this._parts.hostname),i=g&&e.idn_expression.test(this._parts.hostname),j=g&&e.punycode_expression.test(this._parts.hostname)),a.toLowerCase()){case"relative":return k;case"absolute":return!k;case"domain":case"name":return g;case"sld":return h;case"ip":return b;case"ip4":case"ipv4":case"inet4":return d;case"ip6":case"ipv6":case"inet6":return f;case"idn":return i;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return j}return null};var t=o.protocol,u=o.port,v=o.hostname;o.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),a.match(/[^a-zA-z0-9\.+-]/)))throw new TypeError("Protocol '"+a+"' contains characters other than [A-Z0-9.+-]");return t.call(this,a,b)},o.scheme=o.protocol,o.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError("Port '"+a+"' contains characters other than [0-9]");return u.call(this,a,b)},o.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={};e.parseHost(a,c),a=c.hostname}return v.call(this,a,b)},o.host=function(a,b){return this._parts.urn?void 0===a?"":this:void 0===a?this._parts.hostname?e.buildHost(this._parts):"":(e.parseHost(a,this._parts),this.build(!b),this)},o.authority=function(a,b){return this._parts.urn?void 0===a?"":this:void 0===a?this._parts.hostname?e.buildAuthority(this._parts):"":(e.parseAuthority(a,this._parts),this.build(!b),this)},o.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var c=e.buildUserinfo(this._parts);return c.substring(0,c.length-1)}return"@"!==a[a.length-1]&&(a+="@"),e.parseUserinfo(a,this._parts),this.build(!b),this},o.resource=function(a,b){var c;return void 0===a?this.path()+this.search()+this.hash():(c=e.parse(a),this._parts.path=c.path,this._parts.query=c.query,this._parts.fragment=c.fragment,this.build(!b),this)},o.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,c)||""}var d=this._parts.hostname.length-this.domain().length,g=this._parts.hostname.substring(0,d),h=new RegExp("^"+f(g));return a&&"."!==a.charAt(a.length-1)&&(a+="."),a&&e.ensureValidHostname(a),this._parts.hostname=this._parts.hostname.replace(h,a),this.build(!b),this},o.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if("boolean"==typeof a&&(b=a,a=void 0),void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.match(/\./g);if(c&&c.length<2)return this._parts.hostname;var d=this._parts.hostname.length-this.tld(b).length-1;return d=this._parts.hostname.lastIndexOf(".",d-1)+1,this._parts.hostname.substring(d)||""}if(!a)throw new TypeError("cannot set domain empty");if(e.ensureValidHostname(a),!this._parts.hostname||this.is("IP"))this._parts.hostname=a;else{var g=new RegExp(f(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(g,a)}return this.build(!b),this},o.tld=function(a,b){if(this._parts.urn)return void 0===a?"":this;if("boolean"==typeof a&&(b=a,a=void 0),void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.lastIndexOf("."),e=this._parts.hostname.substring(d+1);return b!==!0&&c&&c.list[e.toLowerCase()]?c.get(this._parts.hostname)||e:e}var g;if(!a)throw new TypeError("cannot set TLD empty");if(a.match(/[^a-zA-Z0-9-]/)){if(!c||!c.is(a))throw new TypeError("TLD '"+a+"' contains characters other than [A-Z0-9]");g=new RegExp(f(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(g,a)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");g=new RegExp(f(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(g,a)}return this.build(!b),this},o.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||a===!0){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var c=this._parts.path.length-this.filename().length-1,d=this._parts.path.substring(0,c)||(this._parts.hostname?"/":"");return a?e.decodePath(d):d}var g=this._parts.path.length-this.filename().length,h=this._parts.path.substring(0,g),i=new RegExp("^"+f(h));return this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a)),a&&"/"!==a.charAt(a.length-1)&&(a+="/"),a=e.recodePath(a),this._parts.path=this._parts.path.replace(i,a),this.build(!b),this},o.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||a===!0){if(!this._parts.path||"/"===this._parts.path)return"";var c=this._parts.path.lastIndexOf("/"),d=this._parts.path.substring(c+1);return a?e.decodePathSegment(d):d}var g=!1;"/"===a.charAt(0)&&(a=a.substring(1)),a.match(/\.?\//)&&(g=!0);var h=new RegExp(f(this.filename())+"$");return a=e.recodePath(a),this._parts.path=this._parts.path.replace(h,a),g?this.normalizePath(b):this.build(!b),this},o.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||a===!0){if(!this._parts.path||"/"===this._parts.path)return"";var c,d,g=this.filename(),h=g.lastIndexOf(".");return-1===h?"":(c=g.substring(h+1),d=/^[a-z0-9%]+$/i.test(c)?c:"",a?e.decodePathSegment(d):d)}"."===a.charAt(0)&&(a=a.substring(1));var i,j=this.suffix();if(j)i=a?new RegExp(f(j)+"$"):new RegExp(f("."+j)+"$");else{if(!a)return this;this._parts.path+="."+e.recodePath(a)}return i&&(a=e.recodePath(a),this._parts.path=this._parts.path.replace(i,a)),this.build(!b),this},o.segment=function(a,b,c){var d=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),g=e.split(d);if(void 0!==a&&"number"!=typeof a&&(c=b,b=a,a=void 0),void 0!==a&&"number"!=typeof a)throw new Error("Bad segment '"+a+"', must be 0-based integer");if(f&&g.shift(),0>a&&(a=Math.max(g.length+a,0)),void 0===b)return void 0===a?g:g[a];if(null===a||void 0===g[a])if(h(b)){g=[];for(var i=0,j=b.length;j>i;i++)(b[i].length||g.length&&g[g.length-1].length)&&(g.length&&!g[g.length-1].length&&g.pop(),g.push(b[i]))}else(b||"string"==typeof b)&&(""===g[g.length-1]?g[g.length-1]=b:g.push(b));else b||"string"==typeof b&&b.length?g[a]=b:g.splice(a,1);return f&&g.unshift(""),this.path(g.join(d),c)},o.segmentCoded=function(a,b,c){var d,f,g;if("number"!=typeof a&&(c=b,b=a,a=void 0),void 0===b){if(d=this.segment(a,b,c),h(d))for(f=0,g=d.length;g>f;f++)d[f]=e.decode(d[f]);else d=void 0!==d?e.decode(d):void 0;return d}if(h(b))for(f=0,g=b.length;g>f;f++)b[f]=e.decode(b[f]);else b="string"==typeof b?e.encode(b):b;return this.segment(a,b,c)};var w=o.query;return o.query=function(a,b){if(a===!0)return e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof a){var c=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace),d=a.call(this,c);return this._parts.query=e.buildQuery(d||c,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!b),this}return void 0!==a&&"string"!=typeof a?(this._parts.query=e.buildQuery(a,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!b),this):w.call(this,a,b)},o.setQuery=function(a,b,c){var d=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("object"==typeof a)for(var f in a)p.call(a,f)&&(d[f]=a[f]);else{if("string"!=typeof a)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");d[a]=void 0!==b?b:null}return this._parts.query=e.buildQuery(d,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof a&&(c=b),this.build(!c),this},o.addQuery=function(a,b,c){var d=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return e.addQuery(d,a,void 0===b?null:b),this._parts.query=e.buildQuery(d,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof a&&(c=b),this.build(!c),this},o.removeQuery=function(a,b,c){var d=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return e.removeQuery(d,a,b),this._parts.query=e.buildQuery(d,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof a&&(c=b),this.build(!c),this},o.hasQuery=function(a,b,c){var d=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return e.hasQuery(d,a,b,c)},o.setSearch=o.setQuery,o.addSearch=o.addQuery,o.removeSearch=o.removeQuery,o.hasSearch=o.hasQuery,o.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},o.normalizeProtocol=function(a){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a)),this},o.normalizeHostname=function(c){return this._parts.hostname&&(this.is("IDN")&&a?this._parts.hostname=a.toASCII(this._parts.hostname):this.is("IPv6")&&b&&(this._parts.hostname=b.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!c)),this},o.normalizePort=function(a){return"string"==typeof this._parts.protocol&&this._parts.port===e.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a)),this},o.normalizePath=function(a){if(this._parts.urn)return this;if(!this._parts.path||"/"===this._parts.path)return this;var b,c,d,f=this._parts.path;for("/"!==f.charAt(0)&&(b=!0,f="/"+f),f=f.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");;){if(c=f.indexOf("/../"),-1===c)break;if(0===c){f=f.substring(3);break}d=f.substring(0,c).lastIndexOf("/"),-1===d&&(d=c),f=f.substring(0,d)+f.substring(c+3)}return b&&this.is("relative")&&(f=f.substring(1)),f=e.recodePath(f),this._parts.path=f,this.build(!a),this},o.normalizePathname=o.normalizePath,o.normalizeQuery=function(a){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(e.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!a)),this},o.normalizeFragment=function(a){return this._parts.fragment||(this._parts.fragment=null,this.build(!a)),this},o.normalizeSearch=o.normalizeQuery,o.normalizeHash=o.normalizeFragment,o.iso8859=function(){var a=e.encode,b=e.decode;return e.encode=escape,e.decode=decodeURIComponent,this.normalize(),e.encode=a,e.decode=b,this},o.unicode=function(){var a=e.encode,b=e.decode;return e.encode=m,e.decode=unescape,this.normalize(),e.encode=a,e.decode=b,this},o.readable=function(){var b=this.clone();b.username("").password("").normalize();var c="";if(b._parts.protocol&&(c+=b._parts.protocol+"://"),b._parts.hostname&&(b.is("punycode")&&a?(c+=a.toUnicode(b._parts.hostname),b._parts.port&&(c+=":"+b._parts.port)):c+=b.host()),b._parts.hostname&&b._parts.path&&"/"!==b._parts.path.charAt(0)&&(c+="/"),c+=b.path(!0),b._parts.query){for(var d="",f=0,g=b._parts.query.split("&"),h=g.length;h>f;f++){var i=(g[f]||"").split("=");d+="&"+e.decodeQuery(i[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"),void 0!==i[1]&&(d+="="+e.decodeQuery(i[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}c+="?"+d.substring(1)}return c+=e.decodeQuery(b.hash(),!0)},o.absoluteTo=function(a){var b,c,d,f=this.clone(),g=["protocol","username","password","hostname","port"];if(this._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(a instanceof e||(a=new e(a)),f._parts.protocol||(f._parts.protocol=a._parts.protocol),this._parts.hostname)return f;for(c=0;d=g[c];c++)f._parts[d]=a._parts[d];for(g=["query","path"],c=0;d=g[c];c++)!f._parts[d]&&a._parts[d]&&(f._parts[d]=a._parts[d]);return"/"!==f.path().charAt(0)&&(b=a.directory(),f._parts.path=(b?b+"/":"")+f._parts.path,f.normalizePath()),f.build(),f},o.relativeTo=function(a){var b,c,d,f,g,h=this.clone().normalize();if(h._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(a=new e(a).normalize(),b=h._parts,c=a._parts,f=h.path(),g=a.path(),"/"!==f.charAt(0))throw new Error("URI is already relative");if("/"!==g.charAt(0))throw new Error("Cannot calculate a URI relative to another relative URI");if(b.protocol===c.protocol&&(b.protocol=null),b.username!==c.username||b.password!==c.password)return h.build();if(null!==b.protocol||null!==b.username||null!==b.password)return h.build();if(b.hostname!==c.hostname||b.port!==c.port)return h.build();if(b.hostname=null,b.port=null,f===g)return b.path="",h.build();if(d=e.commonPath(h.path(),a.path()),!d)return h.build();var i=c.path.substring(d.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");return b.path=i+b.path.substring(d.length),h.build()},o.equals=function(a){var b,c,d,f=this.clone(),g=new e(a),i={},j={},l={};if(f.normalize(),g.normalize(),f.toString()===g.toString())return!0;if(b=f.query(),c=g.query(),f.query(""),g.query(""),f.toString()!==g.toString())return!1;if(b.length!==c.length)return!1;i=e.parseQuery(b,this._parts.escapeQuerySpace),j=e.parseQuery(c,this._parts.escapeQuerySpace);for(d in i)if(p.call(i,d)){if(h(i[d])){if(!k(i[d],j[d]))return!1}else if(i[d]!==j[d])return!1;l[d]=!0}for(d in j)if(p.call(j,d)&&!l[d])return!1;return!0},o.duplicateQueryParameters=function(a){return this._parts.duplicateQueryParameters=!!a,this},o.escapeQuerySpace=function(a){return this._parts.escapeQuerySpace=!!a,this},e})},{"./IPv6":1,"./SecondLevelDomains":2,"./punycode":4}],4:[function(b,c,d){var e="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};!function(b){function f(a){throw RangeError(I[a])}function g(a,b){for(var c=a.length;c--;)a[c]=b(a[c]);return a}function h(a,b){return g(a.split(H),b).join(".")}function i(a){for(var b,c,d=[],e=0,f=a.length;f>e;)b=a.charCodeAt(e++),b>=55296&&56319>=b&&f>e?(c=a.charCodeAt(e++),56320==(64512&c)?d.push(((1023&b)<<10)+(1023&c)+65536):(d.push(b),e--)):d.push(b);return d}function j(a){return g(a,function(a){var b="";return a>65535&&(a-=65536,b+=L(a>>>10&1023|55296),a=56320|1023&a),b+=L(a)}).join("")}function k(a){return 10>a-48?a-22:26>a-65?a-65:26>a-97?a-97:x}function l(a,b){return a+22+75*(26>a)-((0!=b)<<5)}function m(a,b,c){var d=0;for(a=c?K(a/B):a>>1,a+=K(a/b);a>J*z>>1;d+=x)a=K(a/J);return K(d+(J+1)*a/(a+A))}function n(a){var b,c,d,e,g,h,i,l,n,o,p=[],q=a.length,r=0,s=D,t=C;for(c=a.lastIndexOf(E),0>c&&(c=0),d=0;c>d;++d)a.charCodeAt(d)>=128&&f("not-basic"),p.push(a.charCodeAt(d));for(e=c>0?c+1:0;q>e;){for(g=r,h=1,i=x;e>=q&&f("invalid-input"),l=k(a.charCodeAt(e++)),(l>=x||l>K((w-r)/h))&&f("overflow"),r+=l*h,n=t>=i?y:i>=t+z?z:i-t,!(n>l);i+=x)o=x-n,h>K(w/o)&&f("overflow"),h*=o;b=p.length+1,t=m(r-g,b,0==g),K(r/b)>w-s&&f("overflow"),s+=K(r/b),r%=b,p.splice(r++,0,s)}return j(p)}function o(a){var b,c,d,e,g,h,j,k,n,o,p,q,r,s,t,u=[];for(a=i(a),q=a.length,b=D,c=0,g=C,h=0;q>h;++h)p=a[h],128>p&&u.push(L(p));for(d=e=u.length,e&&u.push(E);q>d;){for(j=w,h=0;q>h;++h)p=a[h],p>=b&&j>p&&(j=p);for(r=d+1,j-b>K((w-c)/r)&&f("overflow"),c+=(j-b)*r,b=j,h=0;q>h;++h)if(p=a[h],b>p&&++c>w&&f("overflow"),p==b){for(k=c,n=x;o=g>=n?y:n>=g+z?z:n-g,!(o>k);n+=x)t=k-o,s=x-o,u.push(L(l(o+t%s,0))),k=K(t/s);u.push(L(l(k,0))),g=m(c,r,d==e),c=0,++d}++c,++b}return u.join("")}function p(a){return h(a,function(a){return F.test(a)?n(a.slice(4).toLowerCase()):a})}function q(a){return h(a,function(a){return G.test(a)?"xn--"+o(a):a})}var r="object"==typeof d&&d,s="object"==typeof c&&c&&c.exports==r&&c,t="object"==typeof e&&e;(t.global===t||t.window===t)&&(b=t);var u,v,w=2147483647,x=36,y=1,z=26,A=38,B=700,C=72,D=128,E="-",F=/^xn--/,G=/[^ -~]/,H=/\x2E|\u3002|\uFF0E|\uFF61/g,I={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},J=x-y,K=Math.floor,L=String.fromCharCode;if(u={version:"1.2.3",ucs2:{decode:i,encode:j},decode:n,encode:o,toASCII:q,toUnicode:p},"function"==typeof a&&"object"==typeof a.amd&&a.amd)a(function(){return u});else if(r&&!r.nodeType)if(s)s.exports=u;else for(v in u)u.hasOwnProperty(v)&&(r[v]=u[v]);else b.punycode=u}(this)},{}]},{},[3])(3)}),!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.xmlserializer=a():"undefined"!=typeof global?global.xmlserializer=a():"undefined"!=typeof self&&(self.xmlserializer=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){var d=["script","style"],e=function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")},f=function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},g=function(a){var b=a.value;return" "+a.name+'="'+e(b)+'"'},h=function(a){var b=Array.prototype.map.call(a.attributes||a.attrs,function(a){return a.name}).indexOf("xmlns")>=0;return"html"!==a.tagName.toLowerCase()||b?"":' xmlns="'+a.namespaceURI+'"'},i=function(a,b){return Array.prototype.map.call(a.childNodes,function(a){return m(a,b)}).join("")},j=function(a){var b="<"+a.tagName.toLowerCase();return b+=h(a),Array.prototype.forEach.call(a.attributes||a.attrs,function(a){b+=g(a)}),a.childNodes.length>0?(b+=">",d.indexOf(a.tagName.toLowerCase())>=0?(b+="<![CDATA[\n",b+=i(a,!0),b+="\n]]>"):b+=i(a),b+="</"+a.tagName.toLowerCase()+">"):b+="/>",b},k=function(a,b){var c=a.nodeValue||a.value||"";return b||(c=f(c)),c},l=function(a){return"<!--"+a.data.replace(/-/g,"&#45;")+"-->"},m=function(a,b){return"#document"===a.nodeName||"#document-fragment"===a.nodeName?i(a):a.tagName?j(a):"#text"===a.nodeName?k(a,b):"#comment"===a.nodeName?l(a):void 0};c.serializeToString=function(a){return m(a)}},{}]},{},[1])(1)}),window.rasterizeHTMLInline=function(a){"use strict";var b=function(b,c,d,e){var f=b.attributes.src?b.attributes.src.nodeValue:null,g=a.util.getDocumentBaseUrl(b.ownerDocument),h=a.util.clone(c);return null===f||a.util.isDataUri(f)?(d(),void 0):(!h.baseUrl&&g&&(h.baseUrl=g),a.util.getDataURIForImageURL(f,h,function(a){b.attributes.src.nodeValue=a,d()},function(){e(a.util.joinUrl(h.baseUrl,f))}),void 0)},c=function(a){var b=[];return Array.prototype.forEach.call(a,function(a){"image"===a.type&&b.push(a)}),b};a.loadAndInlineImages=function(d,e,f){var g=a.util.parseOptionalParameters(e,f),h=d.getElementsByTagName("img"),i=d.getElementsByTagName("input"),j=[],k=[];j=Array.prototype.slice.call(h),j=j.concat(c(i)),a.util.map(j,function(a,c){b(a,g.options,c,function(a){k.push({resourceType:"image",url:a,msg:"Unable to load image "+a}),c()})},function(){g.callback&&g.callback(k)})};var d=function(b){return a.util.joinUrl(b,".")},e=function(a,b,c){var e=d(b);if("object"!=typeof a)throw new Error("cacheBucket is not an object");return a.inlineCssCache=a.inlineCssCache||{},a.inlineCssCache[e]=a.inlineCssCache[e]||{},a.inlineCssCache[e][c]},f=function(a,b,c,e){var f=d(b);a.inlineCssCache=a.inlineCssCache||{},a.inlineCssCache[f]=a.inlineCssCache[f]||{},a.inlineCssCache[f][c]=e},g=function(b,c,d,e){var f=a.css.rulesForCssText(b);a.css.loadCSSImportsForRules(f,d,c,function(d,g){a.css.loadAndInlineCSSResourcesForRules(f,c,function(c,h){var i=g.concat(h),j=d||c;j&&(b=a.css.cssRulesToText(f)),e(j,b,i)})})},h=function(b,c,d,h){var i,j=b.textContent;return l(c)&&(i=e(c.cacheBucket,c.baseUrl,j))?(i.hasChanges&&(b.childNodes[0].nodeValue=i.content),h(i.errors),void 0):(g(j,c,d,function(d,e,g){d&&(b.childNodes[0].nodeValue=e),l(c)&&f(c.cacheBucket,c.baseUrl,j,{content:e,hasChanges:d,errors:a.util.cloneArray(g)}),h(g)}),void 0)},i=function(a){return Array.prototype.slice.call(a)},j=function(a){var b=i(a.getElementsByTagName("style")),c=[];return b.forEach(function(a){a.attributes.type&&"text/css"!==a.attributes.type.nodeValue||c.push(a)}),c};a.loadAndInlineStyles=function(b,c,d){var e,f=a.util.parseOptionalParameters(c,d),g=j(b),i=[],k=[];e=a.util.clone(f.options),e.baseUrl=e.baseUrl||a.util.getDocumentBaseUrl(b),a.util.map(g,function(a,b){h(a,e,k,function(a){i=i.concat(a),b()})},function(){f.callback(i)})};var k=function(a,b){var c,d=a.parentNode;b=b.trim(),b&&(c=a.ownerDocument.createElement("style"),c.type="text/css",c.appendChild(a.ownerDocument.createTextNode(b)),d.insertBefore(c,a)),d.removeChild(a)},l=function(a){return a.cache!==!1&&"none"!==a.cache&&a.cacheBucket},m=function(b,c,d){var e=a.util.joinUrl(c,d);if("object"!=typeof b)throw new Error("cacheBucket is not an object");return b.linkedCssCache=b.linkedCssCache||{},b.linkedCssCache[e]},n=function(b,c,d,e){var f=a.util.joinUrl(c,d);b.linkedCssCache=b.linkedCssCache||{},b.linkedCssCache[f]=e},o=function(b,c,d,e){a.util.ajax(b,c,function(e){var f,g=a.css.rulesForCssText(e);f=a.css.adjustPathsOfCssResources(b,g),a.css.loadCSSImportsForRules(g,[],c,function(b,h){a.css.loadAndInlineCSSResourcesForRules(g,c,function(c,i){var j=h.concat(i);(f||b||c)&&(e=a.css.cssRulesToText(g)),d(e,j)})})},e)},p=function(b,c,d,e){var f,g=b.attributes.href.nodeValue,h=a.util.getDocumentBaseUrl(b.ownerDocument),i=a.util.clone(c);return!i.baseUrl&&h&&(i.baseUrl=h),l(c)&&(f=m(c.cacheBucket,i.baseUrl,g))?(d(f.content,f.errors),void 0):(o(g,i,function(b,e){l(c)&&n(c.cacheBucket,i.baseUrl,g,{content:b,errors:a.util.cloneArray(e)}),d(b,e)},function(){e(a.util.joinUrl(i.baseUrl,g))}),void 0)};a.loadAndInlineCssLinks=function(b,c,d){var e=a.util.parseOptionalParameters(c,d),f=b.getElementsByTagName("link"),g=[];a.util.map(f,function(a,b){!a.attributes.rel||"stylesheet"!==a.attributes.rel.nodeValue||a.attributes.type&&"text/css"!==a.attributes.type.nodeValue?b():p(a,e.options,function(c,d){k(a,c+"\n"),g=g.concat(d),b()},function(a){g.push({resourceType:"stylesheet",url:a,msg:"Unable to load stylesheet "+a}),b()})},function(){e.callback&&e.callback(g)})};var q=function(b,c,d,e){var f=b.attributes.src.nodeValue,g=a.util.getDocumentBaseUrl(b.ownerDocument),h=a.util.clone(c);!h.baseUrl&&g&&(h.baseUrl=g),a.util.ajax(f,h,d,function(){e(a.util.joinUrl(h.baseUrl,f))})},r=function(a){return a.replace(/<\//g,"<\\/")},s=function(a,b){var c=a.ownerDocument.createElement("script"),d=a.parentNode;a.attributes.type&&(c.type=a.attributes.type.nodeValue),b=r(b),c.appendChild(a.ownerDocument.createTextNode(b)),d.insertBefore(c,a),d.removeChild(a)};return a.loadAndInlineScript=function(b,c,d){var e=a.util.parseOptionalParameters(c,d),f=b.getElementsByTagName("script"),g=[];a.util.map(f,function(a,b){a.attributes.src?q(a,e.options,function(c){s(a,c),b()},function(a){g.push({resourceType:"script",url:a,msg:"Unable to load script "+a}),b()}):b()},function(){e.callback&&e.callback(g)})},a.inlineReferences=function(b,c,d){var e=[];a.loadAndInlineImages(b,c,function(f){e=e.concat(f),a.loadAndInlineStyles(b,c,function(f){e=e.concat(f),a.loadAndInlineCssLinks(b,c,function(f){e=e.concat(f),c.inlineScripts===!1?d(e):a.loadAndInlineScript(b,c,function(a){e=e.concat(a),d(e)})})})})},a}(window.rasterizeHTMLInline||{}),window.rasterizeHTMLInline=function(a,b,c){"use strict";a.css={};var d=function(a){return Array.prototype.slice.call(a)},e=function(a){var b,c=document.implementation.createHTMLDocument(""),e=document.createElement("style");
return e.textContent=a,c.body.appendChild(e),b=e.sheet.cssRules,d(b)},f=function(){var a=e("a{background:url(i)}");return!a.length||a[0].cssText.indexOf("url()")>=0}();a.css.rulesForCssText=function(a){return f&&c.parse?c.parse(a).cssRules:e(a)};var g=function(a){var c=[];return a.forEach(function(a){a.type===b.CSSRule.STYLE_RULE&&(a.style.getPropertyValue("background-image")||a.style.getPropertyValue("background"))&&c.push(a)}),c},h=function(a){var c=[];return a.forEach(function(a){a.type===b.CSSRule.FONT_FACE_RULE&&a.style.getPropertyValue("src")&&c.push(a)}),c};a.css.cssRulesToText=function(a){var b="";return a.forEach(function(a){b+=a.cssText}),b};var i=function(a){var b=/^"(.*)"$/,c=/^'(.*)'$/;return b.test(a)?a.replace(b,"$1"):c.test(a)?a.replace(c,"$1"):a},j=function(a){var b=/^[\t\r\f\n ]*(.+?)[\t\r\f\n ]*$/;return a.replace(b,"$1")};a.css.extractCssUrl=function(a){var b,c=/^url\(([^\)]+)\)/;if(!c.test(a))throw new Error("Invalid url");return b=c.exec(a)[1],i(j(b))};var k=function(a){var b,c=/^format\(([^\)]+)\)/;return c.test(a)?(b=c.exec(a)[1],i(b)):null},l=function(b){var c,d=null;try{return c=a.css.extractCssUrl(b[0]),b[1]&&(d=k(b[1])),{url:c,format:d}}catch(e){}},m=function(a,b,c){var d=a.indexOf(b),e="@font-face { font-family: "+b.style.getPropertyValue("font-family")+"; src: "+c+"}",f=b.parentStyleSheet;f.insertRule(e,d+1),f.deleteRule(d),a[d]=f.cssRules[d]};a.css.adjustPathsOfCssResources=function(b,c){var d,e=!1;return g(c).forEach(function(c){var f=c.style.getPropertyValue("background-image")||c.style.getPropertyValue("background"),g=r(f),h=!1;g.forEach(function(c){var d,e=s(c);e&&!a.util.isDataUri(e.url)&&(d=a.util.joinUrl(b,e.url),c[e.idx]='url("'+d+'")',h=!0)}),d=t(g),c.style.getPropertyValue("background-image")?c.style.setProperty("background-image",d):c.style.setProperty("background",d),e=e||h}),h(c).forEach(function(d){var f=w(d.style.getPropertyValue("src")),g=!1;f.forEach(function(c){var d,e=l(c);e&&!a.util.isDataUri(e.url)&&(d=a.util.joinUrl(b,e.url),c[0]='url("'+d+'")',g=!0)}),g&&m(c,d,x(f)),e=e||g}),e};var n=function(a){var c=[];return a.forEach(function(a){a.type===b.CSSRule.IMPORT_RULE&&a.href&&c.push(a)}),c},o=function(a,b,c){var d=a.indexOf(b);a.splice(d,1),c.forEach(function(b,c){a.splice(d+c,0,b)})},p=function(a){var b=/^"(.*)"$/,c=/^'(.*)'$/;return b.test(a)||c.test(a)},q=function(b,c,d,e,f,g){var h,j=c.href;return p(j)&&(j=i(j)),h=a.util.joinUrl(e.baseUrl,j),d.indexOf(h)>=0?(o(b,c,[]),f([]),void 0):(d.push(h),a.util.ajax(j,e,function(g){var h=a.css.rulesForCssText(g);a.css.loadCSSImportsForRules(h,d,e,function(d,e){a.css.adjustPathsOfCssResources(j,h),o(b,c,h),f(e)})},function(){g(h)}),void 0)};a.css.loadCSSImportsForRules=function(b,c,d,e){var f,g=[];f=n(b),a.util.map(f,function(a,e){q(b,a,c,d,function(a){g=g.concat(a),e(!0)},function(a){g.push({resourceType:"stylesheet",url:a,msg:"Unable to load stylesheet "+a}),e(!1)})},function(a){var b=a.indexOf(!0)>=0;e(b,g)})};var r=function(a){var b,c="\\s*(?:\"[^\"]*\"|'[^']*'|[^\\(]+)\\s*",d="(url\\("+c+"\\)|[^,\\s]+)",e="(?:\\s*"+d+")+",f="^\\s*("+e+")(?:\\s*,\\s*("+e+"))*\\s*$",g=new RegExp(e,"g"),h=[],i=function(a){var b,c=new RegExp(d,"g"),e=[];for(b=c.exec(a);b;)e.push(b[1]),b=c.exec(a);return e};if(a.match(new RegExp(f))){for(b=g.exec(a);b;)h.push(i(b[0])),b=g.exec(a);return h}return[]},s=function(b){var c,d;for(c=0;c<b.length;c++)try{return d=a.css.extractCssUrl(b[c]),{url:d,idx:c}}catch(e){}},t=function(a){var b=[];return a.forEach(function(a){b.push(a.join(" "))}),b.join(", ")},u=function(b,c,d){var e,f,g=[],h=b.style.getPropertyValue("background-image")||b.style.getPropertyValue("background");e=r(h),a.util.map(e,function(b,d){var e=s(b);return!e||a.util.isDataUri(e.url)?(d(!1),void 0):(a.util.getDataURIForImageURL(e.url,c,function(a){b[e.idx]='url("'+a+'")',d(!0)},function(){g.push(a.util.joinUrl(c.baseUrl,e.url)),d(!1)}),void 0)},function(a){var c=a.indexOf(!0)>=0;c&&(f=t(e),b.style.getPropertyValue("background-image")?b.style.setProperty("background-image",f):b.style.setProperty("background",f)),d(c,g)})},v=function(b,c,d){var e,f=g(b),h=[];a.util.map(f,function(a,b){u(a,c,function(a,c){c.forEach(function(a){h.push({resourceType:"backgroundImage",url:a,msg:"Unable to load background-image "+a})}),b(a)})},function(a){e=a.indexOf(!0)>=0,d(e,h)})},w=function(a){var b,c="\\s*(?:\"[^\"]*\"|'[^']*'|[^\\(]+)\\s*",d="(local\\("+c+"\\))|(url\\("+c+"\\))(?:\\s+(format\\("+c+"\\)))?",e="^\\s*("+d+")(?:\\s*,\\s*("+d+"))*\\s*$",f=new RegExp(d,"g"),g=[],h=function(a){var b=[];return a.slice(1).forEach(function(a){a&&b.push(a)}),b};if(a.match(new RegExp(e))){for(b=f.exec(a);b;)g.push(h(b)),b=f.exec(a);return g}return[]},x=function(a){var b=[];return a.forEach(function(a){b.push(a.join(" "))}),b.join(", ")},y=function(b,c,d,e){var f,g,h,i,j=[];f=w(c.style.getPropertyValue("src")),a.util.map(f,function(b,c){return g=l(b),!g||a.util.isDataUri(g.url)?(c(!1),void 0):(h=g.format||"woff",a.util.binaryAjax(g.url,d,function(a){i=btoa(a),b[0]='url("data:font/'+h+";base64,"+i+'")',c(!0)},function(){j.push(a.util.joinUrl(d.baseUrl,g.url)),c(!1)}),void 0)},function(a){var d=a.indexOf(!0)>=0;d&&m(b,c,x(f)),e(d,j)})},z=function(b,c,d){var e,f=h(b),g=[];a.util.map(f,function(a,d){y(b,a,c,function(a,b){b.forEach(function(a){g.push({resourceType:"fontFace",url:a,msg:"Unable to load font-face "+a})}),d(a)})},function(a){e=a.indexOf(!0)>=0,d(e,g)})};return a.css.loadAndInlineCSSResourcesForRules=function(a,b,c){v(a,b,function(d,e){z(a,b,function(a,b){var f=d||a;c(f,e.concat(b))})})},a}(window.rasterizeHTMLInline||{},window,window.CSSOM||{}),window.rasterizeHTMLInline=function(a,b,c){"use strict";a.util={},a.util.getDocumentBaseUrl=function(a){return"about:blank"!==a.baseURI?a.baseURI:null},a.util.clone=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c},a.util.cloneArray=function(a){return Array.prototype.slice.apply(a,[0])},a.util.joinUrl=function(a,b){var d=new c(b);return a&&d.is("relative")&&(d=d.absoluteTo(a)),d.toString()},a.util.isDataUri=function(a){return/^data:/.test(a)},a.util.map=function(b,c,d){var e,f=0,g=a.util.cloneArray(b),h=[];0===g.length&&d(h);var i=function(a){function b(b){f+=1,h[a]=b,f===g.length&&d(h)}c(g[a],b)};for(e=0;e<g.length;e++)i(e)};var d=null,e=function(a,b){return b===!1||"none"===b||"repeated"===b?((null===d||"repeated"!==b)&&(d=Date.now()),a+"?_="+d):a};a.util.ajax=function(c,d,f,g){var h,i=new b.XMLHttpRequest,j=a.util.joinUrl(d.baseUrl,c);h=e(j,d.cache),i.addEventListener("load",function(){200===i.status||0===i.status?f(i.response):g()},!1),i.addEventListener("error",function(){g()},!1);try{i.open("GET",h,!0),i.overrideMimeType(d.mimeType),i.send(null)}catch(k){g()}},a.util.binaryAjax=function(b,c,d,e){var f="",g=a.util.clone(c);g.mimeType="text/plain; charset=x-user-defined",a.util.ajax(b,g,function(a){for(var b=0;b<a.length;b++)f+=String.fromCharCode(255&a.charCodeAt(b));d(f)},e)};var f=function(a){var b=function(a,b){return a.substring(0,b.length)===b};return b(a,"<?xml")||b(a,"<svg")?"image/svg+xml":"image/png"};a.util.getDataURIForImageURL=function(b,c,d,e){var g,h;a.util.binaryAjax(b,c,function(a){g=btoa(a),h=f(a),d("data:"+h+";base64,"+g)},function(){e()})};var g=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c},h=function(a){return"function"==typeof a};return a.util.parseOptionalParameters=function(){var a={options:{},callback:null};return h(arguments[0])?a.callback=arguments[0]:(a.options=g(arguments[0]),a.callback=arguments[1]||null),a},a}(window.rasterizeHTMLInline||{},window,URI),window.rasterizeHTML=function(a,b,c){"use strict";var d={},e=[];d.util={},d.util.getConstantUniqueIdFor=function(a){return e.indexOf(a)<0&&e.push(a),e.indexOf(a)},d.util.log=function(a){c.console&&c.console.log&&c.console.log(a)};var f=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c},g=function(a){return"object"==typeof a&&null!==a},h=function(a){return g(a)&&Object.prototype.toString.apply(a).match(/\[object (Canvas|HTMLCanvasElement)\]/i)},i=function(a){return"function"==typeof a};d.util.parseOptionalParameters=function(){var a={canvas:null,options:{},callback:null};return i(arguments[0])?a.callback=arguments[0]:null==arguments[0]||h(arguments[0])?(a.canvas=arguments[0]||null,i(arguments[1])?a.callback=arguments[1]:(a.options=f(arguments[1]),a.callback=arguments[2]||null)):(a.options=f(arguments[0]),a.callback=arguments[1]||null),a};var j=function(a){return(""+function(a){window.parent.rasterizeHTML.util.reportIframeJsError("put_unique_id_here",a)}).replace("put_unique_id_here",a)},k={};d.util.reportIframeJsError=function(a,b){var c=k[a]||[];c.push(b),k[a]=c};var l=function(a){var b=[];return k[a]&&k[a].forEach(function(a){b.push({resourceType:"scriptExecution",msg:a})}),b};d.util.executeJavascript=function(a,b,e){var f=r(c.document,"iframe"),g=a.documentElement.outerHTML,h=d.util.getConstantUniqueIdFor(a),i="<script>window.onerror = "+j(h)+";</script>",k=function(){var a=f.contentDocument;c.document.getElementsByTagName("body")[0].removeChild(f),e(a,l(h))};f.onload=b>0?function(){setTimeout(k,b)}:k,f.contentDocument.open(),f.contentDocument.write(i+g),f.contentDocument.close()};var m=function(a,b){var d,e,f,g,h=/<html((?:\s+[^>]*)?)>/im.exec(b),i=c.document.implementation.createHTMLDocument("");if(h)for(d="<div"+h[1]+"></div>",i.documentElement.innerHTML=d,f=i.querySelector("div"),e=0;e<f.attributes.length;e++)g=f.attributes[e],a.documentElement.setAttribute(g.name,g.value)};d.util.parseHTML=function(a){var b;return(new DOMParser).parseFromString("<a></a>","text/html")?b=(new DOMParser).parseFromString(a,"text/html"):(b=c.document.implementation.createHTMLDocument(""),b.documentElement.innerHTML=a,m(b,a)),b};var n=function(){if(c.navigator.userAgent.indexOf("WebKit")>=0&&c.navigator.userAgent.indexOf("Chrome")<0)return!1;if(c.BlobBuilder||c.MozBlobBuilder||c.WebKitBlobBuilder)return!0;if(c.Blob)try{return new c.Blob(["<b></b>"],{type:"text/xml"}),!0}catch(a){return!1}return!1},o=function(a){var b,d="image/svg+xml;charset=utf-8",e=c.BlobBuilder||c.MozBlobBuilder||c.WebKitBlobBuilder;return e?(b=new e,b.append(a),b.getBlob(d)):new c.Blob([a],{type:d})},p=function(a){var b=c.URL||c.webkitURL||window;return n()?b.createObjectURL(o(a)):"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(a)},q=function(a){var b=c.URL||c.webkitURL||window;n()&&b.revokeObjectURL(a)},r=function(a,b){var c=a.createElement(b);return c.style.visibility="hidden",c.style.width="0px",c.style.height="0px",c.style.position="absolute",c.style.top="-10000px",c.style.left="-10000px",a.getElementsByTagName("body")[0].appendChild(c),c},s=function(a,b){var c=a.getElementById(b);return c||(c=r(a,"div"),c.id=b),c},t="rasterizeHTML_js_FirefoxWorkaround",u=function(){var a=c.navigator.userAgent.match(/Firefox\/(\d+).0/);return!a||!a[1]||parseInt(a[1],10)<17},v=function(a,b){var e,f=d.util.getConstantUniqueIdFor(a),g=b?b.ownerDocument:c.document;u()&&(e=s(g,t+f),e.innerHTML=a,e.className=t)},w=function(a){window.navigator.userAgent.indexOf("WebKit")>=0&&Array.prototype.forEach.call(a.getElementsByTagName("style"),function(a){a.textContent="span {}\n"+a.textContent})},x=function(a,b){var e=d.util.getConstantUniqueIdFor(a),f=b?b.ownerDocument:c.document,g=f.getElementById(t+e);g&&g.parentNode.removeChild(g)};d.getSvgForDocument=function(a,c,d){var e;return w(a),e=b.serializeToString(a),'<svg xmlns="http://www.w3.org/2000/svg" width="'+c+'" height="'+d+'"><foreignObject width="100%" height="100%">'+e+"</foreignObject></svg>"},d.renderSvg=function(a,b,d,e){var f,g,h=function(){g.onload=null,g.onerror=null},i=function(){f&&q(f),x(a,b)};v(a,b),f=p(a),g=new c.Image,g.onload=function(){h(),i(),d(g)},g.onerror=function(){i(),e()},g.src=f},d.drawImageOnCanvas=function(a,b){try{b.getContext("2d").drawImage(a,0,0)}catch(c){return!1}return!0};var y=function(a,b,c,e,f,g){var h,i=d.getSvgForDocument(a,b,c),j=function(a){a.push({resourceType:"document",msg:"Error rendering page"})};d.renderSvg(i,e,function(a){e&&(h=d.drawImageOnCanvas(a,e),h||(j(g),a=null)),f&&f(a,g)},function(){j(g),f&&f(null,g)})};return d.drawDocument=function(b,c,e,f){var g,h=d.util.parseOptionalParameters(c,e,f),i=h.canvas?h.canvas.width:300,j=h.canvas?h.canvas.height:200,k=void 0!==h.options.width?h.options.width:i,l=void 0!==h.options.height?h.options.height:j,m=h.options.executeJsTimeout||0;g=a.util.clone(h.options),g.inlineScripts=h.options.executeJs===!0,a.inlineReferences(b,g,function(a){h.options.executeJs?d.util.executeJavascript(b,m,function(b,c){y(b,k,l,h.canvas,h.callback,a.concat(c))}):y(b,k,l,h.canvas,h.callback,a)})},d.drawHTML=function(a,b,c,e){var f=d.util.parseOptionalParameters(b,c,e),g=d.util.parseHTML(a);d.drawDocument(g,f.canvas,f.options,f.callback)},d.drawURL=function(b,c,e,f){var g,h=d.util.parseOptionalParameters(c,e,f);g=a.util.clone(h.options),g.baseUrl=b,a.util.ajax(b,h.options,function(a){d.drawHTML(a,h.canvas,g,h.callback)},function(){h.callback&&h.callback(null,[{resourceType:"page",url:b,msg:"Unable to load page "+b}])})},d}(window.rasterizeHTMLInline,window.xmlserializer,window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment