(()=>{var e={919:(e,t,n)=>{var i;!function(){"use strict";var s,r={name:"doT",version:"1.1.1",templateSettings:{evaluate:/\{\{([\s\S]+?(\}?)+)\}\}/g,interpolate:/\{\{=([\s\S]+?)\}\}/g,encode:/\{\{!([\s\S]+?)\}\}/g,use:/\{\{#([\s\S]+?)\}\}/g,useParams:/(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g,define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,defineParams:/^\s*([\w$]+):([\s\S]+)/,conditional:/\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,iterate:/\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,varname:"it",strip:!0,append:!0,selfcontained:!1,doNotSkipEncoded:!1},template:void 0,compile:void 0,log:!0,encodeHTMLSource:function(e){var t={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},n=e?/[&<>"'\/]/g:/&(?!#?\w+;)|<|>|"|'|\//g;return function(e){return e?e.toString().replace(n,(function(e){return t[e]||e})):""}}};s=function(){return this||(0,eval)("this")}(),e.exports?e.exports=r:void 0===(i=function(){return r}.call(t,n,t,e))||(e.exports=i);var o={append:{start:"'+(",end:")+'",startencode:"'+encodeHTML("},split:{start:"';out+=(",end:");out+='",startencode:"';out+=encodeHTML("}},a=/$^/;function l(e,t,n){return("string"==typeof t?t:t.toString()).replace(e.define||a,(function(t,i,s,r){return 0===i.indexOf("def.")&&(i=i.substring(4)),i in n||(":"===s?(e.defineParams&&r.replace(e.defineParams,(function(e,t,s){n[i]={arg:t,text:s}})),i in n||(n[i]=r)):new Function("def","def['"+i+"']="+r)(n)),""})).replace(e.use||a,(function(t,i){e.useParams&&(i=i.replace(e.useParams,(function(e,t,i,s){if(n[i]&&n[i].arg&&s){var r=(i+":"+s).replace(/'|\\/g,"_");return n.__exp=n.__exp||{},n.__exp[r]=n[i].text.replace(new RegExp("(^|[^\\w$])"+n[i].arg+"([^\\w$])","g"),"$1"+s+"$2"),t+"def.__exp['"+r+"']"}})));var s=new Function("def","return "+i)(n);return s?l(e,s,n):s}))}function c(e){return e.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ")}r.template=function(e,t,n){var i,u,d=(t=t||r.templateSettings).append?o.append:o.split,p=0,h=t.use||t.define?l(t,e,n||{}):e;h=("var out='"+(t.strip?h.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""):h).replace(/'|\\/g,"\\$&").replace(t.interpolate||a,(function(e,t){return d.start+c(t)+d.end})).replace(t.encode||a,(function(e,t){return i=!0,d.startencode+c(t)+d.end})).replace(t.conditional||a,(function(e,t,n){return t?n?"';}else if("+c(n)+"){out+='":"';}else{out+='":n?"';if("+c(n)+"){out+='":"';}out+='"})).replace(t.iterate||a,(function(e,t,n,i){return t?(p+=1,u=i||"i"+p,t=c(t),"';var arr"+p+"="+t+";if(arr"+p+"){var "+n+","+u+"=-1,l"+p+"=arr"+p+".length-1;while("+u+"{"use strict";n.d(t,{A:()=>i});const i="{{#def.trigger:it}}\n{{#def.popup:it}}"},806:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});const i='{{? it.topList && it.topList.length }}\n {{ \n it.options = it.topList; \n it.title = it.locales.topCurrencies;\n it.showTitle = true;\n }}\n {{#def.options:it}}\n{{?}}\n{{? it.allList.length }}\n {{ \n it.options = it.allList; \n it.title = it.resultsTitle || it.locales.allCurrencies;\n it.showTitle = (it.topList && it.topList.length)? true : false;\n it.showTitle = (it.filtered && it.allList.length)? true : it.showTitle;\n }}\n {{#def.options:it}}\n{{??}}\n

{{=it.locales.noResults}}

\n{{?}}'},284:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});const i='{{##def.options:it:\n{{? it.showTitle }}\n

{{=it.title}}

\n{{?}}\n\n#}}'},660:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});const i='{{##def.popup:it:\n\n#}}'},790:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});const i='{{##def.trigger:it:\n\n#}}'}},t={};function n(i){var s=t[i];if(void 0!==s)return s.exports;var r=t[i]={exports:{}};return e[i](r,r.exports,n),r.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";let e={keys:{default:"tc-cs-default",all:"tc-cs-all"},save:(e,t)=>{sessionStorage.setItem(e,JSON.stringify(t))},get:e=>{let t=sessionStorage.getItem(e);if(t)return JSON.parse(t)},saveAllCurrencies:function(e,t){return this.save(`${this.keys.all}-${e}`,t)},getAllCurrencies:function(e){return this.get(`${this.keys.all}-${e}`)},saveDefaultCurrency:function(e){return this.save(this.keys.default,e)},getDefaultCurrency:function(){return this.get(this.keys.default)}};async function t(e){return window.GalaxyHelpers.proxy({method:"GET",url:`/tc/entity/v1/hotel/${e}/info/currencies`})}async function i(e){return window.GalaxyHelpers.proxy({method:"GET",url:`/tc/entity/v1/chain/${e}/info/currencies`})}async function s(){let e={"X-Galaxy-Key":galaxyInfo.proxy_key},t=new URL(galaxyInfo.proxy_url+"/tc/crs-globals-data/v1/currency/geo-location");const n=await function(e,t,n,i){return new Promise((function(t,n){let s=new XMLHttpRequest;s.onreadystatechange=function(){if(4==s.readyState&&200==s.status){let e=JSON.parse(s.responseText);t(e)}else 4==s.readyState&&200!==s.status&&n()},s.open("GET",e);for(const e in i)s.setRequestHeader(e,i[e]);s.send(null)}))}(t.toString(),0,0,e);return n}let r=[],o=!0,a=e=>null!=e&&e.isChain?e.chainCode:e.hotelId;const l=(e,t)=>{let n={allList:[],topList:t.topCurrencies,default:t.defaultCurrency};return r=c(e.hotelCurrencies.currencies),n.allList=u(t.topCurrencies),n.default=p(e.currencyGeoLocation,t.defaultCurrency),n.topList=d(t.topCurrencies),n},c=e=>e.map((e=>({code:e.currencyCode,default:e.isDefaultCurrency,symbol:e.currencySymbol}))).sort(((e,t)=>e.code>t.code?1:-1)),u=e=>r.filter((t=>!e.includes(t.code))),d=e=>r.filter((t=>e.includes(t.code))),p=function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=h();return i||(i=e.getDefaultCurrency()),!i&&!1!==t&&"currencyCode"in t&&(i=r.find((e=>e.code===t.currencyCode))),i||(i=r.find((e=>e.default))),!i&&n&&(i={code:n,default:!0,symbol:n}),i},h=()=>{let e=!1,t=new URL(window.location.href).searchParams.get("currency");return t&&(e=r.find((e=>e.code===t))),e},g={getAll:n=>o?(o=!1,new Promise(((r,o)=>{let c,u=a(n),d=e.getAllCurrencies(u);d?(c=l({hotelCurrencies:d,currencyGeoLocation:!1},n),r(c)):async function(e){return{hotelCurrencies:null!=e&&e.isChain?await i(e.chainCode):await t(e.hotelId),currencyGeoLocation:!!e.geolocation&&await s()}}(n).then((t=>{t.hotelCurrencies.currencies&&t.hotelCurrencies.currencies.length&&(e.saveAllCurrencies(u,t.hotelCurrencies),c=l(t,n),r(c)),o("no currencies available")})).catch((e=>o(e)))}))):new Promise(((t,i)=>{let s,r=5;const o=setInterval((()=>{let c=a(n),u=e.getAllCurrencies(c);u?(s=l({hotelCurrencies:u,currencyGeoLocation:!1},n),clearInterval(o),t(s)):r<=1&&(clearInterval(o),i("no currencies available / subset")),r--}),200)})),getFiltered:e=>({allList:r.filter((t=>t.code.toLowerCase().indexOf(e.toLowerCase())>=0))}),getUnfiltered:e=>({allList:u(e.topCurrencies),topList:d(e.topCurrencies)}),storeDefault:t=>{let n=r.find((e=>e.code===t));if(n)return e.saveDefaultCurrency(n),n},getDefault:p};var v=n(919),f=n.n(v);const m={evaluate:/\{\{([\s\S]+?(\}?)+)\}\}/g,interpolate:/\{\{=([\s\S]+?)\}\}/g,encode:/\{\{!([\s\S]+?)\}\}/g,use:/\{\{#([\s\S]+?)\}\}/g,useParams:/(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g,define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,defineParams:/^\s*([\w$]+):([\s\S]+)/,conditional:/\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,iterate:/\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,varname:"it",strip:!0,append:!0,selfcontained:!1,doNotSkipEncoded:!1};let C={init:{main:n(704).A,trigger:n(790).A,popup:n(660).A,list:n(284).A},filtered:{main:n(806).A,list:n(284).A}};const w=e=>{e.removeButton.classList.remove("active")},b=()=>`cs-uid-${Math.round(1e3*(Math.random()+Number.EPSILON))}-${Math.round(100*(Math.random()+Number.EPSILON))}`,y={open:e=>{e.trigger.setAttribute("aria-expanded","true"),e.popup.setAttribute("aria-hidden","false")},close:e=>{e.trigger.setAttribute("aria-expanded","false"),e.popup.setAttribute("aria-hidden","true")},showRemoveButton:e=>{e.removeButton.classList.add("active")},hideRemoveButton:w,enableSwitcher:e=>{e.trigger.removeAttribute("disabled"),e.triggerIcon.classList.remove("hide-icon")},disableSwitcher:e=>{e.trigger.disabled=!0,e.triggerIcon.classList.add("hide-icon")},emptySearchInput:e=>{e.searchInput.value="",e.searchInput.focus(),w(e)},renderInit:(e,t)=>{let n=Object.keys(C.init).map((e=>C.init[e])).join(""),i=f().template(n,m,{main:n});t.ariaTriggerLabelID=b(),t.ariaSelectedCurrencyID=b(),e&&(e.innerHTML=i(t))},renderResults:(e,t)=>{let n=Object.keys(C.filtered).map((e=>C.filtered[e])).join(""),i=f().template(n,m,{main:n});t.filtered&&(t.resultsTitle=t.allList.length?t.locales.results:t.locales.noResults),e&&(e.innerHTML=i(t))},renderDefault:(e,t)=>{e&&(e.innerHTML=t.code)}},S={control:"EVT_AMA_HOS_CURRENCY_CONTROL",selected:"EVT_AMA_HOS_CURRENCY_SELECTED",selected_geo:"EVT_AMA_HOS_GEO_CURRENCY_SELECTED",change:"EVT_AMA_HOS_CURRENCY_CHANGE",initialized:"EVT_AMA_HOS_CURRENCY_INITIALIZED"},L=class{constructor(e,t){this.status={enabled:!0,opened:!1},this.context=e,this.settings=t,this.view=y,this.model=g,this.initialize()}async initialize(){try{const e=await this.model.getAll(this.settings);this.exposeCurrency();const t={...e,locales:this.settings.locales};this.model.storeDefault(e.default.code),this.view.renderInit(this.context,t),this.elements(),this.bindEvents(),this.onGeoCurrencyEnabled()}catch(e){console.error("[Currency Switcher: error on initialize instance]",e)}}elements(){this.elements={trigger:this.context.querySelector(".cs-trigger"),triggerSpan:this.context.querySelector(".cs-trigger span"),triggerClose:this.context.querySelector(".cs-popup-close"),triggerIcon:this.context.querySelector(".cs-trigger .cs-icon-arrow-bottom"),popup:this.context.querySelector(".cs-popup"),popupOptions:this.context.querySelector(".cs-options"),searchInput:this.context.querySelector(".cs-popup-search-input"),removeButton:this.context.querySelector(".cs-popup-search-remove"),backButton:this.context.querySelector(".cs-back")}}bindEvents(){this.bindClickOnTrigger(),this.bindClickOnClosetrigger(),this.bindClickOnGoBack(),this.bindKeyUpOnSearchInput(),this.bindClickOnRemoveButton(),this.bindClickOutsideContext(),this.bindKeyDownOnContext(),this.bindClickOnCurrencyButtons(),this.bindControl(),this.bindSelect(),this.bindChange()}bindClickOnTrigger(){this.elements.trigger.addEventListener("click",(()=>{this.status.enabled&&(this.status.opened?this.onClose():this.onOpen())}))}bindClickOnClosetrigger(){this.elements.triggerClose.addEventListener("click",(()=>this.onClose()))}bindClickOnGoBack(){this.elements.backButton.addEventListener("click",(()=>this.onClose()))}bindKeyUpOnSearchInput(){this.elements.searchInput.addEventListener("keyup",(()=>{this.onAddInputText()}))}bindClickOnRemoveButton(){this.elements.removeButton.addEventListener("click",(()=>{this.onRemoveInputText()}))}bindKeyDownOnContext(){this.context.addEventListener("keydown",(e=>{"Escape"===e.key&&this.onClose()}))}bindClickOutsideContext(){document.addEventListener("click",(e=>{this.context.contains(e.target)||this.onClose()}));let e=!1;window.addEventListener("blur",(t=>{e&&this.onClose()})),document.querySelectorAll("iframe").forEach((t=>{t.addEventListener("mouseover",(()=>{e=!0})),t.addEventListener("mouseout",(()=>{e=!1}))}))}bindClickOnCurrencyButtons(){this.context.querySelectorAll(".cs-popup-option button").forEach((e=>{e.addEventListener("click",(e=>this.onClickOnCurrencyButtons(e)))}))}bindSelect(){document.addEventListener(S.selected,(e=>{e.detail&&this.onSelect(e.detail)}))}bindControl(){document.addEventListener(S.control,(e=>{e.detail&&("enabled"===e.detail.value&&this.onEnabled(),"disabled"===e.detail.value&&this.onDisabled())}))}bindChange(){document.addEventListener(S.change,(e=>{if(!e.detail&&!e.detail.code)return;const t=this.context.querySelector(`.cs-popup-option button[data-code="${e.detail.code}"]`);t&&t.dispatchEvent(new Event("click"))}))}onOpen(){this.status.opened=!0,this.view.open(this.elements),this.elements.searchInput.focus()}onClose(){this.status.opened=!1,this.view.close(this.elements)}onAddInputText(){let e={};this.elements.searchInput.value.length?(this.view.showRemoveButton(this.elements),e=this.model.getFiltered(this.elements.searchInput.value),this.renderPopupOptions(e),this.bindClickOnCurrencyButtons()):(this.view.hideRemoveButton(this.elements),this.restartPopupOptions())}onRemoveInputText(){this.view.emptySearchInput(this.elements),this.restartPopupOptions()}onClickOnCurrencyButtons(e){let t=e.target.dataset.code,n=this.model.storeDefault(t);this.onClose(),this.onRemoveInputText(),this.elements.trigger.focus();let i=new CustomEvent(S.selected,{detail:n});document.dispatchEvent(i)}onGeoCurrencyEnabled(){if(!0!==this.settings.geolocation)return;let e=this.model.getDefault(!0),t=new CustomEvent(S.selected_geo,{detail:e});document.dispatchEvent(t)}onSelect(e){this.view.renderDefault(this.elements.triggerSpan,e),this.model.storeDefault(e.code)}restartPopupOptions(){let e=this.model.getUnfiltered(this.settings);this.renderPopupOptions(e,!1),this.bindClickOnCurrencyButtons()}renderPopupOptions(e){let t={...e,filtered:!(arguments.length>1&&void 0!==arguments[1])||arguments[1],locales:this.settings.locales};this.view.renderResults(this.elements.popupOptions,t)}disable(){const e=new CustomEvent(S.control,{detail:{value:"disabled"}});document.dispatchEvent(e)}onDisabled(){this.status.enabled=!1,this.view.disableSwitcher(this.elements)}enable(){const e=new CustomEvent(S.control,{detail:{value:"enabled"}});document.dispatchEvent(e)}onEnabled(){this.status.enabled=!0,this.view.enableSwitcher(this.elements)}exposeCurrency(){window.GLXExtensions.currencySwitcher.getDefault=this.model.getDefault,window.GLXExtensions.currencySwitcher.events=S;let e=new CustomEvent(S.initialized);document.dispatchEvent(e)}};(new class{constructor(){this.settings=window.GLXExtensions.currencySwitcher}init(){try{var e,t,n,i,s,r;if(void 0===window.tcCurrencySwitcherActivated)throw new Error("Active not defined");if(!0!==window.tcCurrencySwitcherActivated)throw new Error("Active is not true");if(!(null!==(e=this.settings)&&void 0!==e&&e.isChain||null!==(t=this.settings)&&void 0!==t&&null!==(n=t.hotelId)&&void 0!==n&&n.length))throw new Error("HotelId not provided");if(null!==(i=this.settings)&&void 0!==i&&i.isChain&&(null===(s=this.settings)||void 0===s||null===(r=s.chainCode)||void 0===r||!r.length))throw new Error("ChainId (chainCode) not provided");let o=[];document.querySelectorAll(".cs-container").forEach(((e,t)=>{o[t]=new L(e,this.settings)}))}catch(e){console.error("[Currency Switcher: error on initialize]",e)}}bindEvents(){return document.addEventListener("EVT_AMA_HOS_CURRENCY_BUILD",(()=>{this.init()})),this}}).bindEvents().init()})()})();