PageSourceSearch

https://www.kayak.com/c/wp-content/plugins/r9-wishlist/r9-wishlist.js?ver=35848223867

js kayak.com collected 2026-09-24 07:34:15 UTC 18,547 bytes, 2 lines download raw bytes

1(()=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)}function i(t){var e="function"==typeof Map?new Map:void 0;return i=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return o(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},i(t)}function o(t,e,n){return o=s()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&a(i,n.prototype),i},o.apply(null,arguments)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}var c=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}(p,t);var i,o,c,l,f,h=(i=p,o=s(),function(){var t,e=u(i);if(o){var n=u(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return r(this,t)});function p(t){var e;n(this,p);for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return(e=h.call.apply(h,[this].concat(i))).errorData=t,e.name="WishlistAPIError",e.message=t.description,e.code=t.code,e}return c=p,l&&e(c.prototype,l),f&&e(c,f),Object.defineProperty(c,"prototype",{writable:!1}),c}(i(Error)),l=window.r9SnackbarService;function f(t){if(!l)return!1;var e=t.content,n=null;t.action&&(n='<a href="'.concat(t.action.url,'">').concat(t.action.title,"</a>"));var r=3e3;t.type&&"error"===t.type&&(r=1e4),l.createInstance().setMessage(e).setAction(n).setDuration(r).setParameters({position:"bottomCenter"}).open()}function h(t){return function(t){if(Array.isArray(t))return p(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return p(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function y(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var d=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.components=[],this.messengers=[],this.lastSubscribed=null,this.lastUpdated=null,this.lastAction=null,this.error=null,this.formToken=null,this.domain=e.domain,this.messages=e.messages,this.checkIfWishlistItemExists()&&(this.initBeforeSession(),document.addEventListener("r9.analytics.session.success",this.initAfterSession.bind(this)))}var e,n,r;return e=t,n=[{key:"apiWishList",get:function(){return this.lastUpdated||this.wishlistGetItems(),this._apiWishList},set:function(t){this._apiWishList=t,this.lastUpdated=Date.now(),this.onChange()}},{key:"uiWishList",get:function(){return!this.error&&this.formatResponseList(this.apiWishList)},set:function(t){}}
1,{key:"initBeforeSession",value:function(){this.messengers.push(f)}},{key:"checkIfWishlistItemExists",value:function(){return!!document.querySelector(".r9-wishlist-toggle-button")}},{key:"initAfterSession",value:function(){var t=this;this.setupFormToken().then((function(){t.wishlistGetItems(),t.emitEvent("r9.wishlist.ready"),t.enablePeriodicalWishlistGet()}))}},{key:"subscribe",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.components.push(t),this.lastSubscribed=Date.now(),e&&t(this.uiWishList)}},{key:"unsubscribe",value:function(t){this.components=this.components.filter((function(e){if(e!==t)return e}))}},{key:"onChange",value:function(){this.notifyComponents(),"wishlistAddItem"===this.lastAction&&this.notifyMessengers(this.messages.wishlistAddItem)}},{key:"onError",value:function(t){this.error=t,console.warn("WishlistService application error - ",t),"INVALID_SESSION"===t.code?this.pageReload():this.notifyMessengers(this.messages.defaultError)}},{key:"onSuccess",value:function(){this.error=null}},{key:"emitEvent",value:function(t){document.dispatchEvent(new CustomEvent(t))}},{key:"notifyComponents",value:function(){var t=this;this.components.forEach((function(e){e(t.uiWishList)}))}},{key:"notifyMessengers",value:function(t){this.messengers.forEach((function(e){e(t)}))}},{key:"wishlistAddItem",value:function(t){var e=this;this.lastAction="wishlistAddItem";var n="".concat(this.domain,"/i/api/trips/wishlist/v1/");fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF":this.formToken},body:JSON.stringify({destinationId:t})}).then((function(t){if(200===t.status)return t.json();e.handleResponseOnAPIError(t)})).then((function(t){e.onSuccess(),e.emitEvent("r9.wishlist.add");var n=t.summary;return e.apiWishList=[].concat(h(e.apiWishList),[n]),e.formatResponseList(n)})).catch((function(t){e.onError(t)}))}},{key:"wishlistRemoveItem",value:function(t){var e=this;this.lastAction="wishlistRemoveItem";var n=this.getFullEncodedTripParam(t),r="".concat(this.domain,"/i/api/trips/trip/v1/").concat(n);fetch(r,{method:"DELETE",headers:{"Content-Type":"application/json","X-CSRF":this.formToken}}).then((function(t){if(200===t.status)return t;e.handleResponseOnAPIError(t)})).then((function(){e.onSuccess(),e.emitEvent("r9.wishlist.remove"),e.apiWishList=e.apiWishList.filter((function(e){return e.destinationId!==t}))})).catch((function(t){e.onError(t)}))}},{key:"wishlistGetItems",value:function(){var t=this;this.lastAction="wishlistGetItems";var e="".concat(this.domain,"/i/api/trips/wishlist/v1/summaries");fetch(e,{method:"GET",headers:{"Content-Type":"application/json","X-CSRF":this.formToken}}).then((function(e){if(200===e.status)return e.json();t.handleResponseOnAPIError(e)})).then((function(e){t.onSuccess();var n=e.summaries;t.apiWishList=n})).catch((function(e){t.onError(e)}))}},{key:"enablePeriodicalWishlistGet",value:function(){var t=this;setInterval((function(){t.components.length>0&&t.wishlistGetItems()}),18e4)}},{key:"setupFormToken",value:function(){var t=this,e="".concat(this.domain,"/k/run/formtoken");return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"}}).then((function(e){if(200===e.status)return e.json();t.handleResponseOnAPIError(e)})).then((function(e){return t.formToken=e,e})).catch((function(e){t.onError(e)}))}},{key:"handleResponseOnAPIError",value:function(t){var e=this;t.json().then((function(t){var n=e.formatAPIErrorMessage(t);throw new c(n)})).catch((function(t){e.onError(t)}))}},{key:"formatAPIErrorMessage",value:function(t){if(t.errors)return t.errors[0]}},{key:"formatResponseList",value:function(t){return(t&&Array.isArray(t)?this.filterDestinationIdEntries(t):t)||[]}},{key:"filterDestinationIdEntries",value:function(t){return t.map((function(t){return t.destinationId})).filter((function(t){return!!t})).flat()}},{key:"getFullEncodedTripParam",value:function(t){var e=this.apiWishList.filter((function(e){return e.destinationId===t}));if(e.length>0){var n=e[0];
1return encodeURI(n.tripId+n.tripHash)}return""}},{key:"pageReload",value:function(){location.reload()}}],n&&y(e.prototype,n),r&&y(e,r),Object.defineProperty(e,"prototype",{writable:!1}),t}(),v=window.r9_wishlist_config,m=v&&v.product_domain?v.product_domain:null,b=v&&v.feature_path?v.feature_path:null;const g=new d({domain:m,messages:{wishlistAddItem:{type:"success",content:v&&v.translation_messenger_content_on_add?v.translation_messenger_content_on_add:"Item added",action:{title:v&&v.translation_messenger_action_on_add?v.translation_messenger_action_on_add:"View",url:"".concat(m).concat(b)}},defaultError:{type:"error",content:"Something went wrong.. Reloading the page might help"}}});function w(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var k=function(){function t(e,n,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.el=e,this.id=n,this.config=r,this.isMounted=!1,this.isActive=null,this.renderCallback=this.render.bind(this),this.register()}var e,n,r;return e=t,(n=[{key:"end",value:function(){this.unregister()}},{key:"mount",value:function(){throw this.isMounted=!0,new Error("You have to implement the method mount!")}},{key:"unmount",value:function(){throw this.isMounted=!1,new Error("You have to implement the method unmount!")}},{key:"register",value:function(){g.subscribe(this.renderCallback)}},{key:"unregister",value:function(){g.unsubscribe(this.renderCallback)}},{key:"render",value:function(t){throw t.includes(this.id)&&(this.isActive=!0),new Error("You have to implement the method render!")}},{key:"onTrigger",value:function(){throw new Error("You have to implement the method onTrigger!")}}])&&w(e.prototype,n),r&&w(e,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function C(t){return C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},C(t)}function E(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function S(t,e){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},S(t,e)}function _(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=I(t);if(e){var i=I(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O(this,n)}}function O(t,e){if(e&&("object"===C(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return A(t)}function A(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function I(t){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},I(t)}var j="button",T="button-icon-xx-small",P=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&S(t,e)}(o,t);var e,n,r,i=_(o);function o(t,e,n){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(r=i.call(this,t,e,n)).onTriggerCallback=r.onTrigger.bind(A(r)),r}return e=o,(n=[{key:"end",value:function(){this.unmount(),this.unregister()}},{key:"mount",value:function(){this.el.classList.add(j,T),this.el.setAttribute("tabindex",0),this.el.addEventListener("click",this.onTriggerCallback),this.el.addEventListener("keyup",this.onTriggerCallback),this.isMounted=!0}},{key:"unmount",value:function(){this.el.classList.remove(j,T),this.el.removeAttribute("tabindex"),this.el.removeEventListener("click",this.onTriggerCallback),this.el.removeEventListener("keyup",this.onTriggerCallback),this.el.innerHTML="",this.isMounted=!1}},{key:"render",value:function(t){if(this.isMounted||this.isServiceErrorState(t)||this.mount(),this.isMounted&&this.isServiceErrorState(t))return this.unmount(),!1;t&&t.includes(this.id)?(this.isActive=!0,this.el.innerHTML=this.config.contentOnActive):(this.isActive=!1,this.el.innerHTML=this.config.contentOnDefault)}},{key:"onTrigger",value:function(){event.preventDefault();var t="keyup"===event.type&&["Enter","Space"].includes(event.code),e="click"===event.type;
1(t||e)&&(this.isActive?g.wishlistRemoveItem(this.id):g.wishlistAddItem(this.id))}},{key:"isServiceErrorState",value:function(t){return!1===t}}])&&E(e.prototype,n),r&&E(e,r),Object.defineProperty(e,"prototype",{writable:!1}),o}(k);function R(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return L(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return L(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function M(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var W=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._tb=[];var e=window.r9_wishlist_config;this.config={contentOnDefault:(e&&e.translation_togglebutton_default?e.translation_togglebutton_default:"")+'\n<svg width="16" height="14" viewBox="0 0 16 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n    <path d="M8.0167 13.3996C7.7067 13.3996 7.40532 13.2963 7.14699 13.0982C6.01895 12.2113 4.81341 11.0574 3.44427 9.55911C1.72207 7.67331 0.84375 5.93389 0.84375 4.39252C0.84375 3.41087 1.22263 2.48089 1.92012 1.76617C2.609 1.06007 3.53038 0.646746 4.50342 0.603691C6.22561 0.526192 7.3881 1.56812 8.0167 2.37755C8.6453 1.56812 9.80778 0.526192 11.53 0.603691C12.5116 0.646746 13.4244 1.06007 14.1133 1.76617C14.8108 2.48089 15.1896 3.41087 15.1896 4.39252C15.1896 5.93389 14.3113 7.67331 12.5891 9.55911C11.22 11.0574 10.0058 12.2199 8.88641 13.0982C8.62808 13.3049 8.32669 13.3996 8.0167 13.3996ZM4.67564 1.87812C4.64119 1.87812 4.59814 1.87812 4.56369 1.87812C3.22038 1.93839 2.12679 3.06643 2.12679 4.39252C2.12679 5.58945 2.91039 7.07054 4.39147 8.6894C5.71757 10.136 6.87144 11.2469 7.94781 12.0907C7.99086 12.1252 8.05975 12.1252 8.10281 12.0907C9.17057 11.2469 10.3331 10.136 11.6591 8.6894C13.1402 7.07054 13.9238 5.58084 13.9238 4.39252C13.9238 3.06643 12.8302 1.93839 11.4869 1.87812C10.7205 1.84367 10.0144 2.14506 9.37723 2.77366C8.86918 3.28171 8.60224 3.81559 8.60224 3.8242C8.49891 4.04808 8.27503 4.18586 8.02531 4.18586C7.77559 4.18586 7.5517 4.04808 7.44837 3.8242C7.44837 3.8242 7.18143 3.29032 6.67338 2.78227C6.07062 2.1795 5.39896 1.87812 4.67564 1.87812Z" />\n</svg>',contentOnActive:(e&&e.translation_togglebutton_active?e.translation_togglebutton_active:"")+'\n<svg width="16" height="14" viewBox="0 0 16 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n    <path d="M14.1133 1.76617C13.4244 1.06007 12.503 0.646746 11.53 0.603691C9.80778 0.526192 8.6453 1.56812 8.0167 2.37755C7.3881 1.56812 6.22561 0.526192 4.50342 0.603691C3.52177 0.646746 2.609 1.06007 1.92012 1.76617C1.22263 2.48089 0.84375 3.41087 0.84375 4.39252C0.84375 5.93389 1.72207 7.67331 3.44427 9.55911C4.81341 11.0574 6.02756 12.2113 7.14699 13.0982C7.40532 13.2963 7.71531 13.3996 8.0167 13.3996C8.32669 13.3996 8.62808 13.2963 8.88641 13.0982C10.0144 12.2113 11.22 11.0574 12.5891 9.55911C14.3113 7.67331 15.1896 5.93389 15.1896 4.39252C15.1896 3.41087 14.8108 2.48089 14.1133 1.76617Z" />\n</svg>'},this.refresh(),document.addEventListener("r9-flexi-multi-swiper-js-init-with-autoplay",this.refresh.bind(this))}var e,n,r;return e=t,(n=[{key:"toggleButtons",get:function(){return this._tb},set:function(t){if(null===t){var e,n=R(this._tb);try{for(n.s();!(e=n.n()).done;){var r=e.value;r.end(),r=null}}catch(t){n.e(t)}finally{n.f()}}else this._tb=t}},{key:"refresh",value:function(){this.reCreateToggleButtons()}},{key:"reCreateToggleButtons",value:function(){var t=this,e=this.queryElements();e&&(this.toggleButtons=null);var n=[];[].forEach.call(e,(function(e){var r=e.dataset.destinationId;n.push(new P(e,r,t.config))})),this.toggleButtons=n}},{key:"queryElements",value:function(){return document.querySelectorAll(".r9-wishlist-toggle-button")}}])&&M(e.prototype,n),r&&M(e,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();new W,window.r9_wishlistservice=g})();
2//# sourceMappingURL=r9-wishlist.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.