(function(g){var f=window.AmazonUIPageJS||window.P,l=f._namespace||f.attributeErrors,n=l?l("CustomerReviewsCommonAssets",""):f;n.guardFatal?n.guardFatal(g)(n,window):n.execute(function(){g(n,window)})})(function(g,f,l){function n(){}g.when("A","cr-log-utils","cr-streaming-utils").register("cr-ajax-model",function(b,d,c){function a(a){m[a]&&(m[a].abort(),delete m[a])}function e(t,h,p,q,r,u,g,l){h=h||{};h.params=h.params||{};u=u?u:v++;r=r?r:h.error||function(){};q=q?q:0;p=p?p:2;l=l?l:"FATAL";var A= "FATAL"===l?0:1,n=h.finallyCallback||function(){};g||(g="reviewsAjax"+k++,f.uet&&f.uet("tc",g));var x=b.state("cr-weblab-state"),w;for(w in x)x.hasOwnProperty(w)&&(h.params[w]=x[w]);h.params.scope=g;h.contentType=h.contentType||"application/x-www-form-urlencoded;charset\x3dUTF-8";var y=h.success||function(){};h.success=function(a){delete m[u];"function"===typeof y&&y(a);"function"===typeof n&&n(a)};h.error=function(k,b,c){k=k||{};var m=(k.http||{}).status||"[]";if(401===m){var v=k;var w=r,z=v.http.getResponseHeader("x-amz-re-authentication-url"); z?("function"===typeof w&&w(v),"function"===typeof n&&n(v),d.logCount("AjaxRedirectToReAuthenticationUrl",1),f.location=z,v=!0):v=!1;if(v)return;q=p}a(u);q++;q=0-c&&b.left>=0-c&&b.bottom<=d(f).height()+c&&b.right<=d(f).width()+c}return!1};b.compositeEventWrapper=function(a,e,d){var k=a;d&&(k=b.throttle(k,d,{trailing:!1}));return c.jsGuard(function(a){a&&(k(a),e&&a.$event&&a.$event.preventDefault())})}; b.freeze=function(a){return"undefined"!==typeof Object&&"function"===typeof Object.freeze?Object.freeze(a):a};b.isFrozen=function(a){return"undefined"!==typeof Object&&"function"===typeof Object.isFrozen?Object.isFrozen(a):!1};return b});"use strict";g.when("jQuery").register("cr-jQuery",function(b){return b});"use strict";g.declare("reviews-constants",{PUSH_STATE:!0,REPLACE_STATE:!1,RATING_SERVICE_CONTEXT_ID:"ReviewsConsumption",data:{REFTAG:"data-reftag",CSM_COUNTER:"data-csm-counter",getReviews:{STANDARD:"data-reviews-state-param", CHECKED:"data-reviews-param-checked",UNCHECKED:"data-reviews-param-unchecked"}},events:{CONTENT_CHANGED:"reviews:content-changed",RELOAD:"reviews:content-reload",RELOAD_COMPLETE:"reviews:content-reload-complete",AUTOSCROLL_COMPLETE:"reviews:autoscroll-complete",FILTER_FIRE_AGGREGATE:"reviews:filter-action:aggregate:trigger",FILTER_FIRE_UPDATE:"reviews:filter-action:trigger",FILTER_AGGREGATE:"reviews:filter-action:aggregate",FILTER_PUSH:"reviews:filter-action:push-state",FILTER_REPLACE:"reviews:filter-action:replace-state", PAGINATION:"reviews:page-action",SEARCH_TEXTBOX:"reviews:search-textbox",SEARCH_BUTTON:"reviews:search-button",VOTE:"reviews:vote-action",TOGGLE_CLASS_CLICK:"reviews:toggle-class:click",AJAX_POST:"reviews:ajax-post",SCROLL_TO_ELEMENT_CLICK:"reviews:scroll-to-element:click",OPEN_MASH_MODAL:"reviews:open-mash-modal",FILTER_APPLY:"reviews:filter-action:apply",FILTER_CHANGE:"reviews:filter-action:change",FILTER_TAB_CLICKED:"reviews:filter-action:tab-clicked",FILTER_APPLY_BEGIN:"reviews:filter-action:apply-begin", FILTER_APPLY_SUCCESS:"reviews:filter-action:apply-success",FILTER_APPLY_ERROR:"reviews:filter-action:apply-error",FILTER_APPLY_DONE:"reviews:filter-action:apply-done",INPUT_COMMENT:"reviews:input-comment",SUBMIT_COMMENT:"reviews:submit-comment",OPEN_SUBMISSION_COMMENT:"reviews:open-comment-submission",SORT_COMMENTS:"reviews:sort-comments",MORE_COMMENTS:"reviews:more-comments",EDIT_COMMENT:"reviews:edit-comment",CANCEL_EDIT_COMMENT:"reviews:cancel-edit-comment",DELETE_COMMENT:"reviews:delete-comment", SUBMIT_EDIT_COMMENT:"reviews:submit-edit-comment",MODIFY_EDIT_COMMENT:"reviews:modify-edit-comment",INPUT_PRODUCT_LINK:"reviews:input-product-link",SELECT_PRODUCT_LINK:"reviews:select-product-link",STAR_RATING_CLICK:"ryp:star-rating-click",STAR_RATING_CLEAR:"ryp:star-rating-clear-click",TRIGGER_WEBLAB:"reviews:trigger-weblab",REFTAG_TRIGGER:"reviews:trigger-reftag"},filterOptions:{SORT_KEY:"sortBy",HELPFUL:"helpful",RECENT:"recent",LEGACY_HELPFUL:"byRankDescending",LEGACY_RECENT:"bySubmissionDateDescending", MOBILE_HELPFUL:"sh",MOBILE_RECENT:"sd",STAR_KEY:"filterByStar",ALL_STARS:"all_stars",ONE_STAR:"one_star",TWO_STAR:"two_star",THREE_STAR:"three_star",FOUR_STAR:"four_star",FIVE_STAR:"five_star",POSTIVE:"positive",CRITICAL:"critical",FORMAT_KEY:"formatType",ALL_FORMATS:"all_formats",CURRENT_FORMAT:"current_format",AVP_KEY:"reviewerType",ALL_REVIEWS:"all_reviews",AVP_ONLY:"avp_only_reviews",MEDIA_KEY:"mediaType",ALL_CONTENTS:"all_contents",MEDIA_ONLY:"media_reviews_only",LANGUAGE_KEY:"filterByLanguage", HEIGHT_KEY:"filterByHeight",WEIGHT_KEY:"filterByWeight"},keycodes:{ENTER:13,BACK_SPACE:8,SPACE:32},aui:{HIDDEN:"aok-hidden",NOWRAP:"aok-nowrap"}});"use strict";g.when("A","cr-string-utils","cr-log-utils").register("cr-popup",function(b,d,c){function a(a){var e={};a&&a.data&&(e=a.data);var g=d.defaultIfBlank(e.url,a.$target.find("a").andSelf().filter("a").attr("href")),m=d.defaultIfBlank(e.title,"CustomerReviews");m=""+m;var t="";b.each({width:null,height:null,resizable:"1",scrollbars:"1",toolbar:"0", status:"1"},function(a,b){var c=e[b];a=null===c||c===l?a:c;null!==a&&(t+=b+"\x3d"+a+",")});t=t.slice(0,-1);var h=null;try{(h=f.open(g,m,t))?h.focus():c.logError("Unable to move focus to popup window with data: "+d.stringify(e),"ERROR"),a.$event.preventDefault()}catch(p){c.logError("Unable to open window with parameters: "+d.stringify(e),"FATAL",p)}return h}b.declarative("cr-popup",["click"],c.jsGuard(a));return{popup:a}});"use strict";g.when("A","cr-jQuery","reviews-constants","cr-ajax-model","cr-string-utils", "cr-global-view").register("cr-generic-declarative-actions",function(b,d,c,a,e,k){function g(a){h(a)&&a.data.selector&&a.data.cssClass&&(d(a.data.selector).toggleClass(a.data.cssClass),a.$event.preventDefault(),b.trigger("a:pageUpdate"))}function m(a){h(a)&&a.data.scrollToSelector&&(k.scrollTo(a.data.scrollToSelector,0),a.$event.preventDefault())}function f(c){if(h(c)&&c.data.url&&c.data.params){c.$event.preventDefault();b.declarative.remove(c.$currentTarget,q.AJAX_POST);c=c.data;var e=c.params,k= d(c.indicatorSelector)[0],m=p(d.fn.hide,c.hideOnSuccessSelector),r=p(d.fn.show,c.showOnFailureSelector);d(c.removeOnLoadSelector).remove();a.post(c.url,{params:e,indicator:k,success:m,error:r})}}function h(a){return a&&a.data&&a.$event&&"function"===typeof a.$event.preventDefault}function p(a,b){if(b&&"function"===typeof a)return function(){var c=d(b);0d?g:l)||"";d=[];-1q?(d++,da.indexOf(c[d])){a=!1;break a}a=!0}a&&(A(b),F=!0)})},toggleSeeAllView:l}});"use strict";h.when("A","cr-jQuery","cr-image-popover-data-fetcher","cr-ranking-see-all-images-controller").register("cr-ranking-image-popover-controller",function(f,b,e,c){function n(){for(var a= 0;aq?(a=B[c[d]],d++,da.indexOf(c[d])){a=!1;break a}a=!0}if(a){a=e.getReviewList();for(var m in a){d={};for(var k=0;ka.indexOf(d[e])&&x.push(d[e]);"function"===typeof k&&k(p,x);c.nextToken?n(a,b,c.csrfToken,k,A,c.nextToken):g=!0},error:function(a){e.logCount("ReviewWithImages-DataFetcher-Error");"function"===typeof A&&A()}})}var g=!1,x=[],p={},a= null;return{fetchData:n,getReviewList:function(){return p},getReviewIds:function(){return x},isDataLoaded:function(){return g},getCustomerImageAltText:function(){a||(a=b(".review-with-images-section .cr-customer-image-thumbnail")[0].getAttribute("alt"));return a}}});"use strict";h.when("A","cr-jQuery","cr-image-popover-data-fetcher").register("cr-see-all-images-controller",function(f,b,e){function c(a,c,d,m){a=b("\x3cdiv\x3e",{class:"cr-thumbnail-preview-tile",css:{background:"url("+a+") 50% 50% no-repeat"}, role:"img",alt:e.getCustomerImageAltText()});a.click(function(){m({popover:{$trigger:{context:{id:c+"-"+d}}}})});return a}function n(a,b,d){for(var m=e.getReviewList(),k=e.getReviewIds(),f=g;gb}function n(){return y.hasClass("cr-mg-image-popover-expand-full-cr")}function g(){c()?(v.removeClass("cr-mg-image-popover-reviews-expand-hide"),v.addClass("cr-mg-image-popover-reviews-expand-show")):(v.removeClass("cr-mg-image-popover-reviews-expand-show"),v.addClass("cr-mg-image-popover-reviews-expand-hide"))} function h(){F.removeClass("cr-mg-image-popover-reviews-content-expand-container-short")}function p(){y.removeClass("cr-mg-image-popover-expand-full-cr");h();B.scrollTop(0);L||A.removeClass("button-hide");M||k.removeClass("button-hide")}function a(){y.addClass("cr-mg-image-popover-expand-full-cr");h();c()||F.addClass("cr-mg-image-popover-reviews-content-expand-container-short");k.addClass("button-hide");A.addClass("button-hide")}function w(a,b){q.text(b[a].title);z.removeClass();z.addClass("cr-mg-image-popover-reviews-star-rating a-icon a-icon-star-small a-star-small-"+ b[a].starRating);G.text(b[a].reviewText);C.empty();C.append(b[a].richReviewText);D.empty();D.append('\x3cimg src\x3d"'+b[a].image+'" class\x3d"cr-mg-image-element" /\x3e');u.text(b[a].authorName);I.empty();I.append('\x3cimg src\x3d"'+b[a].authorAvatarImage+'" data-src\x3d"'+b[a].authorAvatarImage+'"/\x3e \x3cnoscript\x3e\x3cimg src\x3d"'+b[a].authorAvatarImage+'"/\x3e\x3c/noscript\x3e');H.attr("href",b[a].authorProfileLink);a+1==b.length?k.addClass("button-hide"):k.removeClass("button-hide");0==a? A.addClass("button-hide"):A.removeClass("button-hide");g()}function d(a){M=L=0;0==E&&(L=1);E+1==a.length&&(M=1)}function m(a,c){k.unbind("click");A.unbind("click");E=a;d(c);b(k).click(function(){e(E+1,c)&&(E++,w(E,c),d(c))});b(A).click(function(){e(E-1,c)&&(E--,w(E,c),d(c))})}var k,A,l,y,q,z,G,C,D,u,I,H,B,v,F,E,L,M;f.declarative("cr-mg-image-popover-expand-review-content","click",function(b){c()&&!n()&&a()});f.declarative("cr-mg-image-popover-reviews-collapse-review-content","click",function(a){p()}); f.on("resize",function(){var b=l?l.is(":visible"):!1;b&&(n()?(p(),g(),c()&&a()):g())});return{initializePopover:function(a,c){a=parseInt(a,10);e(a,c)&&(l=b("#cr-mg-immsersive-view-container-"+a),y=l.find(".cr-mg-image-popover-overlay"),k=l.find(".next-button-mobile"),A=l.find(".back-button-mobile"),q=l.find(".cr-mg-image-popover-review-title"),z=l.find(".cr-mg-image-popover-reviews-star-rating"),G=l.find(".cr-mg-image-popover-reviews-plain-text"),C=l.find(".cr-mg-image-popover-reviews-rich-text"), D=l.find(".cr-mg-image-view"),B=l.find(".cr-mg-image-popover-reviews-content-wrapper"),v=l.find(".cr-mg-image-popover-reviews-expand-container"),F=l.find(".cr-mg-image-popover-reviews-content-expand-container"),u=l.find(".cr-mg-image-popover-reviews-reviewer-text"),I=l.find(".a-profile-avatar"),H=l.find(".cr-mg-image-popover-reviews-author-profile-image"),w(a,c),m(a,c))}}});"use strict";h.when("cr-A","cr-jQuery","cr-streaming-utils","cr-media-gallery-view","cr-media-gallery-model").register("cr-media-gallery-controller", function(f,b,e,c,n){function g(){return 480d||f(".cr-filter-scroll-container").animate({scrollLeft:d},50)},enableDesktopDPFilterDropdown:function(){f("#cm-cr-dp-review-sort-type").removeClass("aok-hidden")}}});"use strict";g.when("A","jQuery","cr-log-utils").execute(function(e,f,a){e.$(".cr-filter-tab-button").live("click",function(){a.incrementCount("filters-tab-click")});e.$("#button-one_star").live("click", function(){a.incrementCount("starRating-one-star")});e.$("#button-two_star").live("click",function(){a.incrementCount("starRating-two-star")});e.$("#button-three_star").live("click",function(){a.incrementCount("starRating-three-star")});e.$("#button-four_star").live("click",function(){a.incrementCount("starRating-four-star")});e.$("#button-five_star").live("click",function(){a.incrementCount("starRating-five-star")});e.$("#button-positive").live("click",function(){a.incrementCount("starRating-positive")}); e.$("#button-critical").live("click",function(){a.incrementCount("starRating-critical")});e.$("#button-avp_only_reviews").live("click",function(){a.incrementCount("verified-purchases-click")});e.$("#button-media_reviews_only").live("click",function(){a.incrementCount("media-filter-click")})});"use strict";g.when("cr-A","cr-lighthut-terms-view","reviews-constants","cr-log-utils").register("cr-lighthut-terms-controller",function(e,f,a,c){function g(a){a&&a.filterByKeyword!==n&&(f.setSelected(a.filterByKeyword), c.incrementCount("LighthutTermClicked"))}e.on(a.events.FILTER_APPLY_BEGIN,e.compositeEventWrapper(function(a){a&&a.data&&g(a.data)}));return{onFilterApplied:g}});"use strict";g.when("A","cr-jQuery","ready").register("cr-lighthut-terms-view",function(e,f){return{setSelected:function(a){a=a.replace(/ /g,"_");var c=(a=f("#cr-lighthouse-term-"+a))&&a.hasClass("cr-lighthut-term-selected");f(".cr-lighthut-term-selected").removeClass("cr-lighthut-term-selected");c||a.addClass("cr-lighthut-term-selected")}}})}); /* ******** */ (function(c){var a=window.AmazonUIPageJS||window.P,d=a._namespace||a.attributeErrors,b=d?d("CustomerReviewsTwisterAssets",""):a;b.guardFatal?b.guardFatal(c)(b,window):b.execute(function(){c(b,window)})})(function(c,a,d){c.when().register("customer-reviews-twister-update",function(){return{getDisplayedASIN:function(){var b=document.querySelector("#ASIN");return b?b.value:a&&a.TwisterState&&a.TwisterState.asin?a.TwisterState.asin:""}}})}); /* ******** */ /* This software is used under the MIT license. URI.js - Mutating URLs Version: 1.14.1 Author: Rodney Rehm Web: http://medialize.github.io/URI.js/ Licensed under MIT License http://www.opensource.org/licenses/mit-license GPL v3 http://opensource.org/licenses/GPL-3.0 */ P.register("3p-urijs",function(){(function(n,t){"object"===typeof exports?module.exports=t(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],t):n.URI=t(n.punycode,n.IPv6,n.SecondLevelDomains,n)})(this,function(n,t,r,k){function d(a,b){if(!(this instanceof d))return new d(a,b);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==b?this.absoluteTo(b): this}function q(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function w(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function h(a){return"Array"===w(a)}function v(a,b){var c;if(h(b)){var d=0;for(c=b.length;d]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig;d.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/};d.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};d.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/;d.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",audio:"src",video:"src"};d.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();if("input"!==b||"image"===a.type)return d.domAttributes[b]}};d.encode=x;d.decode=decodeURIComponent;d.iso8859=function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=x;d.decode=decodeURIComponent};d.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig, map:{"%24":"$","%26":"\x26","%2B":"+","%2C":",","%3B":";","%3D":"\x3d","%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)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"\x26","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"\x3d"}}}};d.encodeQuery=function(a,b){a=d.encode(a+"");void 0===b&& (b=d.escapeQuerySpace);return b?a.replace(/%20/g,"+"):a};d.decodeQuery=function(a,b){a+="";void 0===b&&(b=d.escapeQuerySpace);try{return d.decode(b?a.replace(/\+/g,"%20"):a)}catch(c){return a}};d.recodePath=function(a){a=(a+"").split("/");for(var b=0,c=a.length;bd)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(d)||"/"!==b.charAt(d))d=a.substring(0,d).lastIndexOf("/");return a.substring(0,d+1)};d.withinString=function(a,b,c){c||(c={});var g=c.start||d.findUri.start,f=c.end||d.findUri.end,e=c.trim||d.findUri.trim,l=/[a-z0-9-]=["']?$/i;for(g.lastIndex=0;;){var m=g.exec(a);if(!m)break;m=m.index;if(c.ignoreHtml){var h= a.slice(Math.max(m-3,0),m);if(h&&l.test(h))continue}h=m+a.slice(m).search(f);var k=a.slice(m,h).replace(e,"");c.ignore&&c.ignore.test(k)||(h=m+k.length,k=b(k,m,h,a),a=a.slice(0,m)+k+a.slice(h),g.lastIndex=m+k.length)}g.lastIndex=0;return a};d.ensureValidHostname=function(a){if(a.match(d.invalid_hostname_characters)){if(!n)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(n.toASCII(a).match(d.invalid_hostname_characters))throw new TypeError('Hostname "'+ a+'" contains characters other than [A-Z0-9.-]');}};d.noConflict=function(a){if(a)return a={URI:this.noConflict()},k.URITemplate&&"function"===typeof k.URITemplate.noConflict&&(a.URITemplate=k.URITemplate.noConflict()),k.IPv6&&"function"===typeof k.IPv6.noConflict&&(a.IPv6=k.IPv6.noConflict()),k.SecondLevelDomains&&"function"===typeof k.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=k.SecondLevelDomains.noConflict()),a;k.URI===this&&(k.URI=E);return this};e.build=function(a){if(!0===a)this._deferred_build= !0;else if(void 0===a||this._deferred_build)this._string=d.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new d(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};e.protocol=u("protocol");e.username=u("username");e.password=u("password");e.hostname=u("hostname");e.port=u("port");e.query=A("query","?");e.fragment=A("fragment","#");e.search=function(a,b){a=this.query(a,b);return"string"===typeof a&&a.length?"?"+a:a};e.hash=function(a,b){a=this.fragment(a, b);return"string"===typeof a&&a.length?"#"+a:a};e.pathname=function(a,b){if(void 0===a||!0===a)return b=this._parts.path||(this._parts.hostname?"/":""),a?d.decodePath(b):b;this._parts.path=a?d.recodePath(a):"/";this.build(!b);return this};e.path=e.pathname;e.href=function(a,b){var c;if(void 0===a)return this.toString();this._string="";this._parts=d._parts();var g=a instanceof d,f="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(f=d.getDomAttribute(a),a=a[f]||"",f=!1);!g&&f&&void 0!== a.pathname&&(a=a.toString());if("string"===typeof a||a instanceof String)this._parts=d.parse(String(a),this._parts);else if(g||f)for(c in a=g?a._parts:a,a)p.call(this._parts,c)&&(this._parts[c]=a[c]);else throw new TypeError("invalid input");this.build(!b);return this};e.is=function(a){var b=!1,c=!1,g=!1,f=!1,e=!1,l=!1,h=!1,k=!this._parts.urn;this._parts.hostname&&(k=!1,c=d.ip4_expression.test(this._parts.hostname),g=d.ip6_expression.test(this._parts.hostname),b=c||g,e=(f=!b)&&r&&r.has(this._parts.hostname), l=f&&d.idn_expression.test(this._parts.hostname),h=f&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return k;case "absolute":return!k;case "domain":case "name":return f;case "sld":return e;case "ip":return b;case "ip4":case "ipv4":case "inet4":return c;case "ip6":case "ipv6":case "inet6":return g;case "idn":return l;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return h}return null};var F=e.protocol,G=e.port,H=e.hostname; e.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(d.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return F.call(this,a,b)};e.scheme=e.protocol;e.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 G.call(this,a,b)};e.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={};d.parseHost(a,c);a=c.hostname}return H.call(this,a,b)};e.host=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildHost(this._parts):"";d.parseHost(a,this._parts);this.build(!b);return this};e.authority=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts): "";d.parseAuthority(a,this._parts);this.build(!b);return this};e.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";a=d.buildUserinfo(this._parts);return a.substring(0,a.length-1)}"@"!==a[a.length-1]&&(a+="@");d.parseUserinfo(a,this._parts);this.build(!b);return this};e.resource=function(a,b){if(void 0===a)return this.path()+this.search()+this.hash();a=d.parse(a);this._parts.path=a.path;this._parts.query=a.query;this._parts.fragment= a.fragment;this.build(!b);return this};e.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"";a=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,a)||""}var c=this._parts.hostname.length-this.domain().length;c=this._parts.hostname.substring(0,c);c=new RegExp("^"+q(c));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&d.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(c, a);this.build(!b);return this};e.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";if((a=this._parts.hostname.match(/\./g))&&2>a.length)return this._parts.hostname;b=this._parts.hostname.length-this.tld(b).length-1;b=this._parts.hostname.lastIndexOf(".",b-1)+1;return this._parts.hostname.substring(b)||""}if(!a)throw new TypeError("cannot set domain empty");d.ensureValidHostname(a); if(!this._parts.hostname||this.is("IP"))this._parts.hostname=a;else{var c=new RegExp(q(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}this.build(!b);return this};e.tld=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";a=this._parts.hostname.lastIndexOf(".");a=this._parts.hostname.substring(a+1);return!0!==b&&r&&r.list[a.toLowerCase()]?r.get(this._parts.hostname)|| a:a}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(r&&r.is(a)){var c=new RegExp(q(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");c=new RegExp(q(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};e.directory= function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";b=this._parts.path.length-this.filename().length-1;b=this._parts.path.substring(0,b)||(this._parts.hostname?"/":"");return a?d.decodePath(b):b}var c=this._parts.path.length-this.filename().length;c=this._parts.path.substring(0,c);c=new RegExp("^"+q(c));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length- 1)&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(c,a);this.build(!b);return this};e.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";b=this._parts.path.lastIndexOf("/");b=this._parts.path.substring(b+1);return a?d.decodePathSegment(b):b}var c=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(c=!0);var g=new RegExp(q(this.filename())+"$");a=d.recodePath(a);this._parts.path= this._parts.path.replace(g,a);c?this.normalizePath(b):this.build(!b);return this};e.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";b=this.filename();var c=b.lastIndexOf(".");if(-1===c)return"";b=b.substring(c+1);b=/^[a-z0-9%]+$/i.test(b)?b:"";return a?d.decodePathSegment(b):b}"."===a.charAt(0)&&(a=a.substring(1));c=this.suffix();if(c)var g=a?new RegExp(q(c)+"$"):new RegExp(q("."+c)+"$");else{if(!a)return this; this._parts.path+="."+d.recodePath(a)}g&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(g,a));this.build(!b);return this};e.segment=function(a,b,c){var d=this._parts.urn?":":"/",f=this.path(),e="/"===f.substring(0,1);f=f.split(d);void 0!==a&&"number"!==typeof a&&(c=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');e&&f.shift();0>a&&(a=Math.max(f.length+a,0));if(void 0===b)return void 0===a?f:f[a];if(null===a||void 0===f[a])if(h(b)){f= [];a=0;for(var l=b.length;a