!function(a,b){"use strict";"object"==typeof exports?module.exports=b(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"==typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],b):a.URI=b(a.punycode,a.IPv6,a.SecondLevelDomains,a)}(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;e.version="1.13.2";var 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.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/},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 void 0===b&&(b=e.escapeQuerySpace),b?c.replace(/%20/g,"+"):c},e.decodeQuery=function(a,b){a+="",void 0===b&&(b=e.escapeQuerySpace);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,"/"===b.port&&(b.port=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?(b+=e.ip6_expression.test(a.hostname)?"["+a.hostname+"]":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 void(a[b]=c);"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,c){c||(c={});var d=c.start||e.findUri.start,f=c.end||e.findUri.end,g=c.trim||e.findUri.trim,h=/[a-z0-9-]=["']?$/i;for(d.lastIndex=0;;){var i=d.exec(a);if(!i)break;var j=i.index;if(c.ignoreHtml){var k=a.slice(Math.max(j-3,0),j);if(k&&h.test(k))continue}var l=j+a.slice(j).search(f),m=a.slice(j,l).replace(g,"");if(!c.ignore||!c.ignore.test(m)){l=j+m.length;var n=b(m,j,l,a);a=a.slice(0,j)+n+a.slice(l),d.lastIndex=j+n.length}}return d.lastIndex=0,a},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 b={URI:this.noConflict()};return d.URITemplate&&"function"==typeof d.URITemplate.noConflict&&(b.URITemplate=d.URITemplate.noConflict()),d.IPv6&&"function"==typeof d.IPv6.noConflict&&(b.IPv6=d.IPv6.noConflict()),d.SecondLevelDomains&&"function"==typeof d.SecondLevelDomains.noConflict&&(b.SecondLevelDomains=d.SecondLevelDomains.noConflict()),b}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(e.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");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=new RegExp(a?f(j)+"$":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,g="";for("/"!==f.charAt(0)&&(b=!0,f="/"+f),f=f.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),b&&(g=f.substring(1).match(/^(\.\.\/)+/)||"",g&&(g=g[0]));;){if(c=f.indexOf("/.."),-1===c)break;0!==c?(d=f.substring(0,c).lastIndexOf("/"),-1===d&&(d=c),f=f.substring(0,d)+f.substring(c+3)):f=f.substring(3)}return b&&this.is("relative")&&(f=g+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];return f._parts.path?".."===f._parts.path.substring(-2)&&(f._parts.path+="/"):(f._parts.path=a._parts.path,f._parts.query||(f._parts.query=a._parts.query)),"/"!==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}),function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b=a.length,c=_.type(a);return"function"===c||_.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}function d(a,b,c){if(_.isFunction(b))return _.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return _.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(hb.test(b))return _.filter(b,a,c);b=_.filter(b,a)}return _.grep(a,function(a){return U.call(b,a)>=0!==c})}function e(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function f(a){var b=ob[a]={};return _.each(a.match(nb)||[],function(a,c){b[c]=!0}),b}function g(){Z.removeEventListener("DOMContentLoaded",g,!1),a.removeEventListener("load",g,!1),_.ready()}function h(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=_.expando+Math.random()}function i(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(ub,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:tb.test(c)?_.parseJSON(c):c}catch(e){}sb.set(a,b,c)}else c=void 0;return c}function j(){return!0}function k(){return!1}function l(){try{return Z.activeElement}catch(a){}}function m(a,b){return _.nodeName(a,"table")&&_.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function n(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function o(a){var b=Kb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function p(a,b){for(var c=0,d=a.length;d>c;c++)rb.set(a[c],"globalEval",!b||rb.get(b[c],"globalEval"))}function q(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(rb.hasData(a)&&(f=rb.access(a),g=rb.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)_.event.add(b,e,j[e][c])}sb.hasData(a)&&(h=sb.access(a),i=_.extend({},h),sb.set(b,i))}}function r(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&_.nodeName(a,b)?_.merge([a],c):c}function s(a,b){var c=b.nodeName.toLowerCase();"input"===c&&yb.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function t(b,c){var d,e=_(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:_.css(e[0],"display");return e.detach(),f}function u(a){var b=Z,c=Ob[a];return c||(c=t(a,b),"none"!==c&&c||(Nb=(Nb||_("