!function(){"use strict";const t={siteUrl:"https://embed.guidegeek.com",apiHttpUrl:"https://api.guidegeek.com/chat/",apiSocketUrl:"wss://api.guidegeek.com/chat-socket",apiReconnectDelay:1e3,apiMaxReconnects:1e3,adminUrl:"https://ggadmin.guidegeek.com",introMessage:"Hi! I'm your travel assistant. Can I help you book your next trip?",markdown:!0,googleMaps:{key:"AIzaSyBMmFMXPyn286iYFF_Qkxu_lX5P4nQc1hc",mapId:"722eed0728469bdf"},unsplash:{appId:"813940"},stateBackend:"localStorage",brandsUrl:"https://brands.guidegeek.com"};function e(t){const e=document.createElement("template");return e.innerHTML=t,e.content.firstElementChild}const s={html:e,styleNode:function(t,s){const a=e(` `);return a.addEventListener("load",s,{once:!0}),a}};function a(e){return t.siteUrl+e}var i=Symbol.for("immer-nothing"),n=Symbol.for("immer-draftable"),o=Symbol.for("immer-state");function r(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var l=Object,c=l.getPrototypeOf,d="constructor",h="prototype",u="configurable",p="enumerable",m="writable",_="value",g=t=>!!t&&!!t[o];function f(t){return!!t&&(y(t)||C(t)||!!t[n]||!!t[d]?.[n]||M(t)||x(t))}var b=l[h][d].toString(),v=new WeakMap;function y(t){if(!t||!I(t))return!1;const e=c(t);if(null===e||e===l[h])return!0;const s=l.hasOwnProperty.call(e,d)&&e[d];if(s===Object)return!0;if(!A(s))return!1;let a=v.get(s);return void 0===a&&(a=Function.toString.call(s),v.set(s,a)),a===b}function w(t,e,s=!0){if(0===$(t)){(s?Reflect.ownKeys(t):l.keys(t)).forEach(s=>{e(s,t[s],t)})}else t.forEach((s,a)=>e(a,s,t))}function $(t){const e=t[o];return e?e.type_:C(t)?1:M(t)?2:x(t)?3:0}var k=(t,e,s=$(t))=>2===s?t.has(e):l[h].hasOwnProperty.call(t,e),S=(t,e,s=$(t))=>2===s?t.get(e):t[e],T=(t,e,s,a=$(t))=>{2===a?t.set(e,s):3===a?t.add(s):t[e]=s};var C=Array.isArray,M=t=>t instanceof Map,x=t=>t instanceof Set,I=t=>"object"==typeof t,A=t=>"function"==typeof t,L=t=>"boolean"==typeof t;var O=t=>t.copy_||t.base_,E=t=>t.modified_?t.copy_:t.base_;function D(t,e){if(M(t))return new Map(t);if(x(t))return new Set(t);if(C(t))return Array[h].slice.call(t);const s=y(t);if(!0===e||"class_only"===e&&!s){const e=l.getOwnPropertyDescriptors(t);delete e[o];let s=Reflect.ownKeys(e);for(let a=0;a1&&l.defineProperties(t,{set:U,add:U,clear:U,delete:U}),l.freeze(t),e&&w(t,(t,e)=>{P(e,!0)},!1)),t}var U={[_]:function(){r(2)}};function H(t){return null===t||!I(t)||l.isFrozen(t)}var N="MapSet",F="Patches",W="ArrayMethods",B={};function R(t){const e=B[t];return e||r(0),e}var q,z=t=>!!B[t];var j=()=>q;function G(t,e){e&&(t.patchPlugin_=R(F),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Y(t){V(t),t.drafts_.forEach(K),t.drafts_=null}function V(t){t===q&&(q=t.parent_)}var Q=t=>q={drafts_:[],parent_:q,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:z(N)?R(N):void 0,arrayMethodsPlugin_:z(W)?R(W):void 0};function K(t){const e=t[o];0===e.type_||1===e.type_?e.revoke_():e.revoked_=!0}function Z(t,e){e.unfinalizedDrafts_=e.drafts_.length;const s=e.drafts_[0];if(void 0!==t&&t!==s){s[o].modified_&&(Y(e),r(4)),f(t)&&(t=X(e,t));const{patchPlugin_:a}=e;a&&a.generateReplacementPatches_(s[o].base_,t,e)}else t=X(e,s);return function(t,e,s=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&P(e,s)}(e,t,!0),Y(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==i?t:void 0}function X(t,e){if(H(e))return e;const s=e[o];if(!s){return nt(e,t.handledSet_,t)}if(!tt(s,t))return e;if(!s.modified_)return s.base_;if(!s.finalized_){const{callbacks_:e}=s;if(e)for(;e.length>0;){e.pop()(t)}at(s,t)}return s.copy_}function J(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var tt=(t,e)=>t.scope_===e,et=[];function st(t,e,s,a){const i=O(t),n=t.type_;if(void 0!==a){if(S(i,a,n)===e)return void T(i,a,s,n)}if(!t.draftLocations_){const e=t.draftLocations_=new Map;w(i,(t,s)=>{if(g(s)){const a=e.get(s)||[];a.push(t),e.set(s,a)}})}const o=t.draftLocations_.get(e)??et;for(const t of o)T(i,t,s,n)}function at(t,e){if(t.modified_&&!t.finalized_&&(3===t.type_||1===t.type_&&t.allIndicesReassigned_||(t.assigned_?.size??0)>0)){const{patchPlugin_:s}=e;if(s){const a=s.getPath(t);a&&s.generatePatches_(t,a,e)}J(t)}}function it(t,e,s){const{scope_:a}=t;if(g(s)){const i=s[o];tt(i,a)&&i.callbacks_.push(function(){ht(t);const a=E(i);st(t,s,a,e)})}else f(s)&&t.callbacks_.push(function(){const i=O(t);3===t.type_?i.has(s)&&nt(s,a.handledSet_,a):S(i,e,t.type_)===s&&a.drafts_.length>1&&!0===(t.assigned_.get(e)??!1)&&t.copy_&&nt(S(t.copy_,e,t.type_),a.handledSet_,a)})}function nt(t,e,s){return!s.immer_.autoFreeze_&&s.unfinalizedDrafts_<1||g(t)||e.has(t)||!f(t)||H(t)||(e.add(t),w(t,(a,i)=>{if(g(i)){const e=i[o];if(tt(e,s)){const s=E(e);T(t,a,s,t.type_),J(e)}}else f(i)&&nt(i,e,s)})),t}var ot={get(t,e){if(e===o)return t;let s=t.scope_.arrayMethodsPlugin_;const a=1===t.type_&&"string"==typeof e;if(a&&s?.isArrayOperationMethod(e))return s.createMethodInterceptor(t,e);const i=O(t);if(!k(i,e,t.type_))return function(t,e,s){const a=ct(e,s);return a?_ in a?a[_]:a.get?.call(t.draft_):void 0}(t,i,e);const n=i[e];if(t.finalized_||!f(n))return n;if(a&&t.operationMethod&&s?.isMutatingArrayMethod(t.operationMethod)&&function(t){const e=+t;return Number.isInteger(e)&&String(e)===t}(e))return n;if(n===lt(t.base_,e)){ht(t);const s=1===t.type_?+e:e,a=ut(t.scope_,n,t,s);return t.copy_[s]=a}return n},has:(t,e)=>e in O(t),ownKeys:t=>Reflect.ownKeys(O(t)),set(t,e,s){const a=ct(O(t),e);if(a?.set)return a.set.call(t.draft_,s),!0;if(!t.modified_){const a=lt(O(t),e),i=a?.[o];if(i&&i.base_===s)return t.copy_[e]=s,t.assigned_.set(e,!1),!0;if(function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}(s,a)&&(void 0!==s||k(t.base_,e,t.type_)))return!0;ht(t),dt(t)}return t.copy_[e]===s&&(void 0!==s||e in t.copy_)||Number.isNaN(s)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=s,t.assigned_.set(e,!0),it(t,e,s)),!0},deleteProperty:(t,e)=>(ht(t),void 0!==lt(t.base_,e)||e in t.base_?(t.assigned_.set(e,!1),dt(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0),getOwnPropertyDescriptor(t,e){const s=O(t),a=Reflect.getOwnPropertyDescriptor(s,e);return a?{[m]:!0,[u]:1!==t.type_||"length"!==e,[p]:a[p],[_]:s[e]}:a},defineProperty(){r(11)},getPrototypeOf:t=>c(t.base_),setPrototypeOf(){r(12)}},rt={};for(let t in ot){let e=ot[t];rt[t]=function(){const t=arguments;return t[0]=t[0][0],e.apply(this,t)}}function lt(t,e){const s=t[o];return(s?O(s):t)[e]}function ct(t,e){if(!(e in t))return;let s=c(t);for(;s;){const t=Object.getOwnPropertyDescriptor(s,e);if(t)return t;s=c(s)}}function dt(t){t.modified_||(t.modified_=!0,t.parent_&&dt(t.parent_))}function ht(t){t.copy_||(t.assigned_=new Map,t.copy_=D(t.base_,t.scope_.immer_.useStrictShallowCopy_))}rt.deleteProperty=function(t,e){return rt.set.call(this,t,e,void 0)},rt.set=function(t,e,s){return ot.set.call(this,t[0],e,s,t[0])};function ut(t,e,s,a){const[i,n]=M(e)?R(N).proxyMap_(e,s):x(e)?R(N).proxySet_(e,s):function(t,e){const s=C(t),a={type_:s?1:0,scope_:e?e.scope_:j(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=a,n=ot;s&&(i=[a],n=rt);const{revoke:o,proxy:r}=Proxy.revocable(i,n);return a.draft_=r,a.revoke_=o,[r,a]}(e,s);return(s?.scope_??j()).drafts_.push(i),n.callbacks_=s?.callbacks_??[],n.key_=a,s&&void 0!==a?function(t,e,s){t.callbacks_.push(function(a){const i=e;if(!i||!tt(i,a))return;a.mapSetPlugin_?.fixSetContents(i);const n=E(i);st(t,i.draft_??i,n,s),at(i,a)})}(s,n,a):n.callbacks_.push(function(t){t.mapSetPlugin_?.fixSetContents(n);const{patchPlugin_:e}=t;n.modified_&&e&&e.generatePatches_(n,[],t)}),i}function pt(t){if(!f(t)||H(t))return t;const e=t[o];let s,a=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,s=D(t,e.scope_.immer_.useStrictShallowCopy_),a=e.scope_.immer_.shouldUseStrictIteration()}else s=D(t,!0);return w(s,(t,e)=>{T(s,t,pt(e))},a),e&&(e.finalized_=!1),s}var mt=new class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,e,s)=>{if(A(t)&&!A(e)){const s=e;e=t;const a=this;return function(t=s,...i){return a.produce(t,t=>e.call(this,t,...i))}}let a;if(A(e)||r(6),void 0===s||A(s)||r(7),f(t)){const i=Q(this),n=ut(i,t,void 0);let o=!0;try{a=e(n),o=!1}finally{o?Y(i):V(i)}return G(i,s),Z(a,i)}if(!t||!I(t)){if(a=e(t),void 0===a&&(a=t),a===i&&(a=void 0),this.autoFreeze_&&P(a,!0),s){const e=[],i=[];R(F).generateReplacementPatches_(t,a,{patches_:e,inversePatches_:i}),s(e,i)}return a}r(1)},this.produceWithPatches=(t,e)=>{if(A(t))return(e,...s)=>this.produceWithPatches(e,e=>t(e,...s));let s,a;const i=this.produce(t,e,(t,e)=>{s=t,a=e});return[i,s,a]},L(t?.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),L(t?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),L(t?.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){f(t)||r(8),g(t)&&(t=function(t){g(t)||r(10);return pt(t)}(t));const e=Q(this),s=ut(e,t,void 0);return s[o].isManual_=!0,V(e),s}finishDraft(t,e){const s=t&&t[o];s&&s.isManual_||r(9);const{scope_:a}=s;return G(a,e),Z(void 0,a)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let s;for(s=e.length-1;s>=0;s--){const a=e[s];if(0===a.path.length&&"replace"===a.op){t=a.value;break}}s>-1&&(e=e.slice(s+1));const a=R(F).applyPatches_;return g(t)?a(t,e):this.produce(t,t=>a(t,e))}},_t=mt.produce;function gt(t={},e={},s=!0){for(const a in e)"object"!=typeof e[a]||Array.isArray(e[a])||null===e[a]?void 0!==e[a]&&(!s&&t[a]||(t[a]=e[a])):(t[a]||(t[a]={}),gt(t[a],e[a],s));return t}function ft(t={},e=""){const s=e.split("."),a=s.pop(),i=s.reduce((t,e)=>t[e],t);return i?i[a]:void 0}function bt(t={},e=""){const s=e.split("."),a=s.pop();let i=t;for(const t of s){if(t.endsWith("[*]")){const e=i[t.slice(0,-3)];if(!Array.isArray(e))return;const n=[...s.slice(s.indexOf(t)+1),a].join(".");for(const t of e)bt(t,n);return}if(i=i[t],!i)return}if(a.endsWith("[*]")){delete i[a.slice(0,-3)]}else delete i[a]}function vt(t,e){return t.startsWith(e+".")}!function(){const t=new Set(["shift","unshift"]),e=new Set([...new Set(["push","pop"]),...t]),s=new Set(["reverse","sort"]),a=new Set([...e,...s,"splice"]),i=new Set(["find","findLast"]),n=new Set(["filter","slice","concat","flat",...i,"findIndex","findLastIndex","some","every","indexOf","lastIndexOf","includes","join","toString","toLocaleString"]);function o(t){return a.has(t)}function r(t,e,s=!0){ht(t);const a=e();return dt(t),s&&t.assigned_.set("length",!0),a}function l(t){t.allIndicesReassigned_=!0}function c(t,e){return t<0?Math.max(e+t,0):Math.min(t,e)}function d(t,e,s){for(let a=0;a=0&&e{const n=s.copy_.length,o=s.copy_[a](...i);return t.has(a)&&l(s),"push"===a&&i.length>0?d(s,n,i):"unshift"===a&&i.length>0&&d(s,0,i),e.has(a)?o:s.draft_})}(a,u,h);if(s.has(u))return function(t,e,s){return r(t,()=>(t.copy_[e](...s),l(t),t.draft_),!1)}(a,u,h);if("splice"===u){const t=r(a,()=>a.copy_.splice(...h));if(l(a),h.length>2){const t=c(h[0]??0,a.copy_.length);d(a,t,h.slice(2))}return t}}finally{!function(t){t.operationMethod=void 0}(a)}}},isArrayOperationMethod:function(t){return o(t)||function(t){return n.has(t)}(t)},isMutatingArrayMethod:o},B[h=W]||(B[h]=u)}();class yt{constructor(t={}){this._state={},this._updateHandlers=new Map,this._actionHandlers=new Map,this._queryHandlers=new Map,this._curBatch={prevState:null,reasons:[],payloads:[]},this._batchUpdateTimeout=null,this._trackPatches=t.trackPatches}get state(){return this._state}onUpdate(t,e,s){this._updateHandlers.set(t,{reason:e,paths:s})}offUpdate(t){this._updateHandlers.has(t)&&this._updateHandlers.delete(t)}onAction(t,e){this._actionHandlers.set(t,e)}offAction(t){this._actionHandlers.delete(t)}sendAction(t,e){const s=this._actionHandlers.get(t);if(s)return s(e)}onQuery(t,e){this._queryHandlers.set(t,e)}offQuery(t){this._queryHandlers.delete(t)}sendQuery(t,e,s){const a=this._queryHandlers.get(t);if(a)return a(e,s||(()=>{}))}merge(t,e="merged"){const s=this._state;this._state=gt(structuredClone(this._state),t),this._updateNow(s,[e],[null])}update(t,e="updated",s=null){this._trackPatches&&!this._patchPrevState&&(this._patchPrevState=this._state),this._batchUpdate(_t(this._state,t),e,s)}_batchUpdate(t,e,s){null===this._curBatch.prevState&&(this._curBatch.prevState=this._state),this._state=t,this._curBatch.reasons.push(e),this._curBatch.payloads.push(s),this._batchUpdateTimeout||(this._batchUpdateTimeout=setTimeout(()=>{const t=this._curBatch.prevState,e=this._curBatch.reasons,s=this._curBatch.payloads;this._curBatch.prevState=null,this._curBatch.reasons=[],this._curBatch.payloads=[],this._batchUpdateTimeout=null,this._updateNow(t,e,s)},0))}_updateNow(t,e,s){for(const[a,i]of this._updateHandlers){let n=null,o=null;if(i.reason){const t=e.lastIndexOf(i.reason);if(-1==t)continue;n=e[t],o=s[t]}else n=e[0],o=s[0];if(i.paths?.length){let e=!1;for(const s of i.paths){if(ft(this._state,s)!==ft(t,s)){e=!0;break}}if(!e)continue}a(this._state,t,n,o)}}drainPatches(){if(!this._patchPrevState)return[];const t=this._patchPrevState,e=this._state;this._patchPrevState=null;const s=[];for(const a in e){const i=t[a],n=e[a];if(i!==n)if(Array.isArray(n)){const t=n[0]||i[0];if(!Array.isArray(i)||!t?.id){s.push({op:"replace-collection",field:a,data:n});continue}const e=new Map;for(const t of i)e.set(t.id,t);for(const t of n){const i=e.get(t.id);i?i!==t&&s.push({op:"replace-item",field:a,item:t}):s.push({op:"add-item",field:a,item:t}),e.delete(t.id)}for(const[,t]of e)s.push({op:"remove-item",field:a,item:t})}else"object"==typeof n&&s.push({op:"replace-field",field:a,data:n})}return s}}class wt{_store=null;constructor(t){this._store=t}_queryLoading(){return{isLoading:!0,error:null,data:null}}_querySuccess(t){return{isLoading:!1,error:null,data:t}}_queryError(t,e="server"){if("abort"==e)return{isLoading:!1,error:null,data:null};return{isLoading:!1,error:{type:e,message:Array.isArray(t)?t.join(" "):t},data:null}}}const $t=/```(?:json\n)?(.*?)(?:\n)?```/gs;function kt(t){if("text"!=t.type||!t.body)return{cards:[],cardIds:[]};const e=function(t){const e=[];let s;for($t.lastIndex=0;null!=(s=$t.exec(t));)try{e.push(JSON.parse(s[1]))}catch(t){console.error(t)}return e}(t.body),s=new Map;for(const t of e){const e=t.template?.id;if(e&&s.set(e,t),"directions-card"===t.type){const e=t.template?.origin,a=t.template?.destination;if(e?.card?.template?.id&&s.set(e.card.template.id,e.card),a?.card?.template?.id&&s.set(a.card.template.id,a.card),t.template?.waypoints)for(const e of t.template.waypoints)e?.card?.template?.id&&s.set(e.card.template.id,e.card)}}return{cards:Array.from(s.values()),cardIds:Array.from(s.keys())}}function St(t,e){return t.findIndex(t=>t.id===e)}function Tt(t,e){return t.find(t=>t.id===e)}function Ct(t,e){for(let s=0;s{const s={};this._store.update(e=>{const a=[],i=new Map,n=new Map;for(const t of e.messages)t.apiMessageId&&n.set(t.apiMessageId,t.id);for(const e of t.messages){const t=It(e);n.has(t.apiMessageId)&&(t.id=n.get(t.apiMessageId)),a.push(t),i.set(t.id,t);const{cards:o,cardIds:r}=kt(t.content);t.cardIds=r,o.length&&(s[t.id]=o.map(Et))}const o=e.messages.filter(t=>!t.apiMessageId&&!i.has(t.id));e.messages=function(t,e){const s=[];let a=0,i=0;for(;a{console.error("[MessagesSlice] Failed to load messages:",t),e(this._queryError(t.errors,t.type))}),a}_handleAdd(t){if(Tt(this._store.state.messages,t.id))return;const{cards:e,cardIds:s}=kt(t.content),a={messageId:t.id,cards:e.map(Et)};this._store.update(e=>{t.cardIds=s,e.messages.push(t)},"message:added",a)}_handleReply({messageId:t,replyIndex:e,actionMessage:s}){const a=St(this._store.state.messages,t);if(-1==a)return;Tt(this._store.state.messages,s.id)||this._store.update(t=>{t.messages.push(s),t.messages[a].content.selectedReplies||(t.messages[a].content.selectedReplies=[]),t.messages[a].content.selectedReplies.push(e)})}_handleUpdate({messageId:t,apiMessageId:e,fields:s}){const a=t?St(this._store.state.messages,t):Ct(this._store.state.messages,e);-1!==a&&this._store.update(t=>{Object.assign(t.messages[a],s)})}_handleSocketAnswer({data:t}){const e=t.messageId,s=Ct(this._store.state.messages,e);if(-1!==s){const e=t.message,a=this._store.state.messages[s],i=e.delta?(a.content.body||"")+e.body:e.body,{cards:n,cardIds:o}=kt({...e,body:i});this._store.update(t=>{const a=t.messages[s];e.delta?(a.content.body=i,a.cardIds=o,a.isStreaming=!0):e.recovery?(a.content.body=e.body,a.cardIds=o,a.isStreaming=!0):(a.content=e,a.cardIds=o,a.isStreaming=!1)},"message:updated",{messageId:a.id,cards:n.map(Et)})}else this._handleAdd(function(t){return{id:Mt(),timestamp:t.timestamp,apiMessageId:t.messageId,langCode:t.langCode,from:"self"==t.from?"user":"agent",apiFrom:t.from,content:t.message,status:t.status,hideUserFeedback:t.hideUserFeedback,feedback:t.feedback}}(t))}}class Ut extends wt{constructor(t,e){super(t),this._ggHttp=e,this._store.onUpdate(this._handleLoadedMessages.bind(this),"messages:loaded"),this._store.onUpdate(this._handleMessageUpdate.bind(this),"message:added"),this._store.onUpdate(this._handleMessageUpdate.bind(this),"message:updated"),this._store.onUpdate(this._handleFavoritesLoaded.bind(this),"favorites:loaded"),this._store.onUpdate(this._handleFavoriteAdded.bind(this),"favorite:added"),this._store.onUpdate(this._handleFavoriteRemoved.bind(this),"favorite:removed")}_addFavoriteToCard(t,e){const s=e.template.id;t.cards[s]?(t.cards[s].sources.includes("favorite")||(t.cards[s].sources.push("favorite"),t.cards[s].isFavorited=!0),e.template.location&&(t.cards[s].template.location=e.template.location)):t.cards[s]={id:s,type:e.type,template:e.template,category:e.category,sources:["favorite"],isFavorited:!0}}_handleFavoritesLoaded(t,e,s,a){a?.cards?.length&&this._store.update(t=>{for(const e of a.cards)this._addFavoriteToCard(t,e)},"cards:favorites-loaded",{cards:a.cards})}_handleFavoriteAdded(t,e,s,a){const{card:i}=a;this._store.update(t=>{this._addFavoriteToCard(t,i)},"card:favorite-added",{cardId:i.template.id,card:i})}_handleFavoriteRemoved(t,e,s,a){const{cardId:i}=a;this._store.update(t=>{const e=t.cards[i];e&&(e.sources=e.sources.filter(t=>"favorite"!==t),e.isFavorited=!1,e.sources.length||delete t.cards[i])},"card:favorite-removed",{cardId:i})}_handleLoadedMessages(t,e,s,a){this._store.update(t=>{for(const e in a.messageCards){const s=a.messageCards[e];if(s.length)for(const e of s){if(!e.template?.id)continue;const s=e.template.id;t.cards[s]=Dt(e,t.cards[s])}}},"cards:messages-loaded",{messageCards:a.messageCards})}_handleMessageUpdate(t,e,s,a){a?.cards?.length&&this._processCards(a.messageId,a.cards)}_processCards(t,e){const s=this._store.state.cards,a=e.filter(t=>t.template?.id&&function(t,e){return!e?.sources.includes("message")||e.type!==t.type||JSON.stringify(e.template)!==JSON.stringify(t.template)}(t,s[t.template.id]));a.length&&this._store.update(t=>{for(const e of a)t.cards[e.template.id]=Dt(e,t.cards[e.template.id])},"cards:message-updated",{messageId:t,cards:a})}}class Ht extends wt{constructor(t,e){super(t),this._ggHttp=e,this._store.onQuery("favorites.load",this._load.bind(this)),this._store.onQuery("favorites.toggle",this._toggle.bind(this))}_load(t,e){e(this._queryLoading());const s=this._ggHttp.get("favorites",{sort:"desc"});return s.then(t=>{const s=[];this._store.update(e=>{e.favorites=t.favorites.map(t=>(s.push(Et(t.card)),{id:t.cardId,cardId:t.cardId,entityId:t.entityId}))},"favorites:loaded",{cards:s}),e(this._querySuccess(t.favorites))}).catch(t=>{console.error("[FavoritesSlice] Failed to load favorites:",t),e(this._queryError(t.errors,t.type))}),s}_toggle({cardId:t}){const e=this._store.state.cards[t];if(!e)return;const s=this._store.state.favorites.findIndex(e=>e.id===t),a=-1===s,i=e.template?.entityId,n=e.template?.place;this._store.update(e=>{a?e.favorites.unshift({id:t,cardId:t,entityId:i}):e.favorites.splice(s,1)},a?"favorite:added":"favorite:removed",{cardId:t,card:e});const o={cardId:t,isFavorited:a};i?o.entityId=i:n&&(o.placeId=n.id,o.placeType="get-your-guide"==n.type?"tour":n.type),this._ggHttp.post("toggle-favorite",o).catch(t=>{console.error("[FavoritesSlice] Failed to toggle favorite:",t)})}}class Nt extends wt{constructor(t,e){super(t),this._ggHttp=e,this._store.onQuery("place.load",this._load.bind(this)),this._store.onQuery("place.hotel-search",this._hotelSearch.bind(this))}_load(t,e){e(this._queryLoading());const s=t.entityId||t.place.id;let a;return this._store.update(t=>{t.place=null},"place:loading",{id:s}),a=t.entityId?this._ggHttp.get(`entity-details/${t.entityId}`):this._ggHttp.get(`places/${t.place.id}`,{type:"get-your-guide"==t.place.type?"tour":t.place.type,messageId:"none"}),a.then(a=>{const i=t.entityId?a.details:a.place,n=a.entityType||null;this._store.update(t=>{t.place=i,t.placeEntityType=n},"place:loaded",{id:s,place:i,entityType:n}),e(this._querySuccess({place:i,entityType:n}))}).catch(t=>{console.error("[PlaceSlice] Failed to load place:",t),e(this._queryError(t.errors,t.type))}),a}_hotelSearch(t,e){e(this._queryLoading());const s=this._ggHttp.post("hotel-booking-search",t);return s.then(t=>{e(this._querySuccess(t.result))}).catch(t=>{console.error("[PlaceSlice] Failed hotel search:",t),e(this._queryError(t.errors,t.type))}),s}}function Ft(t){return(t||window.innerWidth)<767.98}class Wt extends wt{constructor(t,e){super(t),this._ggHttp=e,this._store.onAction("layout.update",this.update.bind(this)),this._store.onUpdate(this._handleStateLoaded.bind(this),"loaded"),this._store.onUpdate(this._handleMapElementsLoadedOrAdded.bind(this),"map:elements-loaded"),this._store.onUpdate(this._handleMapElementsLoadedOrAdded.bind(this),"map:elements-added"),this._store.onUpdate(this._handleMessageAddedOrComposeMessageUpdated.bind(this),"message:added"),this._store.onUpdate(this._handleMessageAddedOrComposeMessageUpdated.bind(this),"compose-message:updated")}_handleStateLoaded(t){this._store.update(t=>{Ft()&&!t.layout.isIntroClosed&&(t.layout.isWindowOpen=!1)})}_handleMapElementsLoadedOrAdded(t,e,s,a){this._store.update(e=>{!Ft()&&t.theme?.autoLaunchMap&&(e.layout.isMapOpen=!0)})}_handleMessageAddedOrComposeMessageUpdated(t,e,s,a){this._store.update(t=>{Ft()&&(t.layout.isMapOpen=!1),t.layout.primaryTab="chat",t.layout.isPlaceOpen=!1,t.layout.isWindowOpen=!0})}update(t){this._store.update(e=>{t.primaryTab&&t.primaryTab!==e.layout.primaryTab&&(e.layout.isPlaceOpen=!1),t.primaryTab&&Ft()&&(e.layout.isMapOpen=!1),Object.assign(e.layout,t)},"layout:updated")}}function Bt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Rt,qt={exports:{}};var zt=(Rt||(Rt=1,qt.exports=function(){var t=1e3,e=6e4,s=36e5,a="millisecond",i="second",n="minute",o="hour",r="day",l="week",c="month",d="quarter",h="year",u="date",p="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,_=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],s=t%100;return"["+t+(e[(s-20)%10]||e[s]||e[0])+"]"}},f=function(t,e,s){var a=String(t);return!a||a.length>=e?t:""+Array(e+1-a.length).join(s)+t},b={s:f,z:function(t){var e=-t.utcOffset(),s=Math.abs(e),a=Math.floor(s/60),i=s%60;return(e<=0?"+":"-")+f(a,2,"0")+":"+f(i,2,"0")},m:function t(e,s){if(e.date()1)return t(o[0])}else{var r=e.name;y[r]=e,i=r}return!a&&i&&(v=i),i||!a&&v},S=function(t,e){if($(t))return t.clone();var s="object"==typeof e?e:{};return s.date=t,s.args=arguments,new C(s)},T=b;T.l=k,T.i=$,T.w=function(t,e){return S(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var C=function(){function g(t){this.$L=k(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[w]=!0}var f=g.prototype;return f.parse=function(t){this.$d=function(t){var e=t.date,s=t.utc;if(null===e)return new Date(NaN);if(T.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var a=e.match(m);if(a){var i=a[2]-1||0,n=(a[7]||"0").substring(0,3);return s?new Date(Date.UTC(a[1],i,a[3]||1,a[4]||0,a[5]||0,a[6]||0,n)):new Date(a[1],i,a[3]||1,a[4]||0,a[5]||0,a[6]||0,n)}}return new Date(e)}(t),this.init()},f.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},f.$utils=function(){return T},f.isValid=function(){return!(this.$d.toString()===p)},f.isSame=function(t,e){var s=S(t);return this.startOf(e)<=s&&s<=this.endOf(e)},f.isAfter=function(t,e){return S(t)=0&&(n[h]=parseInt(d,10))}var u=n[3],p=24===u?0:u,m=n[0]+"-"+n[1]+"-"+n[2]+" "+p+":"+n[4]+":"+n[5]+":000",_=+e;return(i.utc(m).valueOf()-(_-=_%1e3))/6e4},l=a.prototype;l.tz=function(t,e){void 0===t&&(t=n);var s,a=this.utcOffset(),o=this.toDate(),r=o.toLocaleString("en-US",{timeZone:t}),l=Math.round((o-new Date(r))/1e3/60),c=15*-Math.round(o.getTimezoneOffset()/15)-l;if(Number(c)){if(s=i(r,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(c,!0),e){var d=s.utcOffset();s=s.add(a-d,"minute")}}else s=this.utcOffset(0,e);return s.$x.$timezone=t,s},l.offsetName=function(t){var e=this.$x.$timezone||i.tz.guess(),s=o(this.valueOf(),e,{timeZoneName:t}).find(function(t){return"timezonename"===t.type.toLowerCase()});return s&&s.value};var c=l.startOf;l.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return c.call(this,t,e);var s=i(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return c.call(s,t,e).tz(this.$x.$timezone,!0)},i.tz=function(t,e,s){var a=s&&e,o=s||e||n,l=r(+i(),o);if("string"!=typeof t)return i(t).tz(o);var c=function(t,e,s){var a=t-60*e*1e3,i=r(a,s);if(e===i)return[a,e];var n=r(a-=60*(i-e)*1e3,s);return i===n?[a,i]:[t-60*Math.min(i,n)*1e3,Math.max(i,n)]}(i.utc(t,a).valueOf(),l,o),d=c[0],h=c[1],u=i(d).utcOffset(h);return u.$x.$timezone=o,u},i.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},i.tz.setDefault=function(t){n=t}}}()),Zt.exports);const Jt=Bt(Xt);function te(t,e){if(!t?.length||!e)return;if(1==t.length&&t[0].open&&!t[0].close)return{isOpen:!0,changeDate:null};const s=jt().tz(e);let a=!1,i=null;t:for(let e=0;e<7;e++){const n=s.add(e,"day").startOf("day"),o=n.day();for(const e of t){if(e.open.day!=o)continue;const t=n.hour(e.open.hour).minute(e.open.minute).second(0),r=(e.close.day-e.open.day+7)%7,l=t.add(r,"day").hour(e.close.hour).minute(e.close.minute).second(0);if(s>=t&&ss){i=t;break}}}return i&&i.diff(s,"hour")>=24&&(i=null),{isOpen:a,changeDate:i}}function ee(t=0){return"$".repeat(t)}function se(t=0,e=5){return`${Math.round(10*t)/10} / ${e}`}jt.extend(Qt),jt.extend(Jt);const ae=new Set(["car-rental-card","business-card","hotel-card","flight-card","ferry-card","tour-card","venue-card","directions-card","inline"]),ie=new Set(["flight-card","directions-card","ferry-card"]);function ne(t,e){const s=function(t){const e=[];for(const s of t)ae.has(s.type)&&s.template.id&&e.push(s);return e}(e),a=[],i=[];for(const e of s){const s=`card:${e.template.id}`,n=he(e);if(!n.length)continue;const o=[];for(const e of n)t.elements[e.id]?le(t.elements[e.id],e.options):(e.group=s,t.elements[e.id]=e),o.push(e.id),i.push(e.id);t.groups[s]?t.groups[s].elements=o:t.groups[s]={type:e.type,elements:o,isPeeky:ie.has(e.type)},a.push(s)}return{cardGroupIds:a,elementIds:i}}function oe(t,e,s=[]){if("agent"!=e.from||"text"!=e.content.type)return 0;const{cardGroupIds:a,elementIds:i}=ne(t,s);if(!a.length)return 0;const n=`message:${e.id}`;e.mapGroupId=n;const o=t.groups[n]?.groups||[];return t.groups[n]={type:"message",groups:Array.from(new Set(o.concat(a)))},i.length}function re(t,e=[]){const{cardGroupIds:s,elementIds:a}=ne(t,e);if(!s.length)return 0;const i=t.groups.favorites?.groups||[];return t.groups.favorites={type:"favorites",groups:Array.from(new Set(i.concat(s)))},a.length}function le(t,e){e.title&&(t.options.title=e.title),e.price&&(t.options.price=e.price)}function ce(t,e){const s=new Set;if("favorite"===e){const e=t.groups.favorites;if(e)for(const t of e.groups||[])s.add(t)}else for(const e in t.groups)if(e.startsWith("message:"))for(const a of t.groups[e].groups||[])s.add(a);return s}function de(t,e){const s=Object.keys(t.elements),a=ce(t,e),i=t[e].filter,n=t.selection.peekyGroupId;t.selection.visibleElementIds=s.filter(e=>{const s=t.elements[e];return!!a.has(s.group)&&((!t.groups[s.group]?.isPeeky||s.group===n)&&(!(i.categories.length&&!i.categories.includes(s.category))&&!!(!i.locations.length||s.locationId&&i.locations.includes(s.locationId))))}),t.selection.cardElementId&&!t.selection.visibleElementIds.includes(t.selection.cardElementId)&&t.selection.visibleElementIds.push(t.selection.cardElementId);const o=t.groups[n],r=new Set(o?.elements||[]);for(const e of s)t.elements[e].options.noCluster=r.has(e)}function he(t){const e=[],s=t.type,a=t.template;if("car-rental-card"===s||"business-card"===s||"hotel-card"===s||"venue-card"===s||"inline"===s){const s=a.id;if(!a.id||!a.lat||!a.lng)return e;const i=Et(t),n={type:"marker",id:s,category:i.category,cardId:a.id,locationId:a.location?.id||null,placeTypes:a.types||[],options:{position:{lat:a.lat,lng:a.lng},viewport:a.viewport||null,tooltip:a.title}};"business-card"==i.type?(n.options.format=a.businessType,"food-drink"==a.businessType&&(n.options.price=ee(a.priceLevel))):"hotel-card"==i.type?(n.options.price=a.priceValue,n.options.format="lodging"):"car-rental-card"==i.type?(n.options.tooltip=`${a.agency}: ${a.title}`,n.options.format="automotive"):"venue-card"==i.type&&(n.options.format="venue"),e.push(n)}else if("tour-card"===s){const{locations:s=[],meetingPointLocation:i}=a;let n=null;i?n={lat:i.lat,lng:i.long}:s[0]?n={lat:s[0].lat,lng:s[0].lng}:a.lat&&a.lng&&(n={lat:a.lat,lng:a.lng});const o=s.filter(t=>{return!(n&&(e={lat:t.lat,lng:t.lng},s=n,e.lat===s.lat&&e.lng===s.lng));var e,s});for(const t of o)e.push({type:"marker",id:t.id,options:{position:{lat:t.lat,lng:t.lng},tooltip:t.name}});if(n){const s={type:"marker",id:a.id,category:t.category||"tour",cardId:a.id,locationId:a.location?.id||null,placeTypes:a.types||[],options:{position:n,format:"tour",tooltip:a.title}};a.priceValue&&(s.options.price=a.priceValue),e.push(s)}}else if("flight-card"==s)for(const t of a.legs)for(let s=0;s=32);a+=1&r?~(r>>1):r>>1,o=0,r=0;do{n=t.charCodeAt(s++)-63,r|=(31&n)<=32);i+=1&r?~(r>>1):r>>1,e.push({lat:a/1e5,lng:i/1e5})}return e}(a.polyline);if(e.push({type:"line",id:`${a.id}:route`,category:"directions",options:{format:"directions",path:t}}),a.duration||a.distance){const s=t[Math.floor(t.length/2)];e.push({type:"marker",id:`${a.id}:summary`,category:"directions",options:{position:s,format:"label",label:{mode:a.mode,duration:a.duration,distance:a.distance}}})}}}}else"ferry-card"===s&&a.departureCoords?.lat&&a.departureCoords?.lng&&a.arrivalCoords?.lat&&a.arrivalCoords?.lng&&(e.push({type:"marker",id:`${a.id}:${a.departurePortCode}`,category:"ferry",options:{position:a.departureCoords,format:"ferry-start",title:a.departurePortCode}}),e.push({type:"marker",id:`${a.id}:${a.arrivalPortCode}`,category:"ferry",options:{position:a.arrivalCoords,format:"ferry-end",title:a.arrivalPortCode}}));return e}function ue(t,e,s,a){const i=s.card?.template.id;return i?{type:"marker",id:i,category:"directions",options:{}}:{type:"marker",id:`${t}:${e}`,category:"directions",options:{position:{lat:s.lat,lng:s.lng},format:a,tooltip:s.address}}}function pe(t,e){const s=ce(t,e);let a=0;for(const e in t.elements){const i=t.elements[e];s.has(i.group)&&(t.groups[i.group]?.isPeeky||a++)}return Math.max(a-t.selection.visibleElementIds.length,0)}function me(t,e){const s=function(t,e){if(!t[e])return[];const s=t[e],a=[s];if(s.groups)for(const e of s.groups)t[e]&&(t[e].isPeeky||a.push(t[e]));return a}(t,e);if(!s.length)return[];const a=new Set;for(const t of s)if(t.elements)for(const e of t.elements)a.add(e);return Array.from(a)}function _e(t,e,s){if(!e)return;const a=t[e];if(a?.elements){const t=new Set(s);for(const e of a.elements)t.has(e)||s.push(e)}}const ge=new Set(["administrative_area_level_2","administrative_area_level_1","country"]);class fe extends wt{constructor(t,e){super(t),this._ggHttp=e,this._store.onAction("map.select",this._handleMapSelect.bind(this)),this._store.onAction("map.highlight",this._handleMapHighlight.bind(this)),this._store.onAction("map.unselect",this._handleMapUnselect.bind(this)),this._store.onAction("map.cancel",this._handleMapCancel.bind(this)),this._store.onAction("map.slider-change",this._handleSliderChange.bind(this)),this._store.onAction("map.update-filter",this._handleUpdateFilter.bind(this)),this._store.onAction("map.focus-visible",this._handleFocusVisible.bind(this)),this._store.onUpdate(this._handleCardsLoadedFromMessages.bind(this),"cards:messages-loaded"),this._store.onUpdate(this._handleCardsLoadedFromFavorites.bind(this),"cards:favorites-loaded"),this._store.onUpdate(this._handleCardsChanged.bind(this),"cards:message-updated"),this._store.onUpdate(this._handleLayoutUpdated.bind(this),"layout:updated"),this._store.onUpdate(this._handleCardFavoriteAdded.bind(this),"card:favorite-added"),this._store.onUpdate(this._handleCardFavoriteRemoved.bind(this),"card:favorite-removed")}_handleMapUnselect(){const t=this._store.state.map.selection;"pin-preview"==t?.cardMode&&this._selectGroup(t.groupId)}_handleMapSelect({groupId:t,showCard:e,fitFocus:s}){this._selectGroup(t,e,s)}_handleMapHighlight({groupId:t,cardMode:e,fitFocus:s}){this._highlightGroup(t,e,s)}_handleMapCancel(){this._store.update(t=>{if(t.map.selection.groupId){const e=me(t.map.groups,t.map.selection.groupId);_e(t.map.groups,t.map.selection.peekyGroupId,e),t.map.selection.activeElementIds=e.slice(),t.map.selection.focusElementIds=e.slice()}else t.map.selection.activeElementIds=[],t.map.selection.focusElementIds=[];t.map.selection.sliderElementIds=[],t.map.selection.cardElementId=null,t.map.selection.cardMode=null,t.map.selection.fitFocus=null,de(t.map,t.layout.primaryTab)})}_handleSliderChange({cardGroupId:t}){this._store.update(e=>{const s=me(e.map.groups,t);e.map.selection.activeElementIds=s.slice(),e.map.selection.focusElementIds=s.slice(),e.map.selection.cardElementId=s[0]||null,e.map.selection.fitFocus="cluster",de(e.map,e.layout.primaryTab)})}_handleFocusVisible(){this._store.update(t=>{t.map.selection.focusElementIds=t.map.selection.visibleElementIds.slice(),t.map.selection.fitFocus="points"})}_handleUpdateFilter({filter:t,focusVisible:e}){this._store.update(e=>{e.map.selection.cardElementId=null,e.map.selection.cardMode=null,Object.assign(e.map[e.layout.primaryTab].filter,t),de(e.map,e.layout.primaryTab),e.map.selection.activeElementIds=e.map.selection.visibleElementIds.slice()}),e&&this._handleFocusVisible()}_selectGroup(t,e,s){this._store.update(a=>{const i=me(a.map.groups,t),n=function(t,e){const s=t[e];return s?.isPeeky?e:s?.groups&&s.groups.find(e=>t[e]?.isPeeky)||null}(a.map.groups,t);_e(a.map.groups,n,i);const o=i.slice(),r=this._filterLargeAreas(a.map.elements,i);a.map.selection.groupId=t,a.map.selection.peekyGroupId=n,"slider"==e?(a.map.selection.sliderElementIds=o.slice(),a.map.selection.cardElementId=o[0]||null,a.map.selection.cardMode="slider"):(a.map.selection.sliderElementIds=[],e&&o.length?(a.map.selection.cardElementId=o[0],a.map.selection.cardMode=e):(a.map.selection.cardElementId=null,a.map.selection.cardMode=null)),a.map.selection.activeElementIds=o,a.map.selection.focusElementIds=r,a.map.selection.fitFocus=s,de(a.map,a.layout.primaryTab)})}_highlightGroup(t,e,s){this._store.update(a=>{const i=a.map.groups[t],n=me(a.map.groups,t);i?.isPeeky&&(a.map.selection.peekyGroupId=t),a.map.selection.activeElementIds=n.slice(),a.map.selection.focusElementIds=n.slice(),a.map.selection.cardElementId=n[0]||null,a.map.selection.cardMode=e||null,a.map.selection.sliderElementIds="slider"==e?n.slice():[],a.map.selection.fitFocus=s,de(a.map,a.layout.primaryTab)})}_updateMapFromMessage(t,e,s=!0){const a={count:0};if(this._store.update(s=>{const i=s.messages[t];a.count=oe(s.map,i,e),de(s.map,s.layout.primaryTab)},"map:elements-added",a),s){const e=this._store.state.messages[t];this._selectGroup(e.mapGroupId,null,"points")}}_handleCardsLoadedFromMessages(t,e,s,a){const{messageCards:i}=a,n={count:0};let o=null;this._store.update(t=>{t.map.elements={},t.map.groups={};for(const e in i){const s=i[e];if(!s.length)continue;const a=St(t.messages,e);if(-1==a)continue;const r=t.messages[a];n.count+=oe(t.map,r,s),o=r.mapGroupId}de(t.map,t.layout.primaryTab)},"map:elements-loaded",n),o&&"chat"===t.layout.primaryTab&&this._selectGroup(o,null,"points")}_handleCardsLoadedFromFavorites(t,e,s,a){const{cards:i}=a;let n=0;this._store.update(t=>{n=re(t.map,i),de(t.map,t.layout.primaryTab)},"map:elements-loaded",{count:n}),n>0&&"favorite"===t.layout.primaryTab&&this._selectGroup("favorites",null,"points")}_handleCardsChanged(t,e,s,a){const{messageId:i,cards:n=[]}=a,o=St(t.messages,i);-1!==o&&n.length&&this._updateMapFromMessage(o,n,!0)}_handleLayoutUpdated(t,e){if(t.layout.primaryTab!==e.layout.primaryTab)if(this._store.update(e=>{de(e.map,e.layout.primaryTab),"favorite"===t.layout.primaryTab&&(e.map.selection.focusElementIds=e.map.selection.visibleElementIds.slice(),e.map.selection.fitFocus="points")}),"chat"===t.layout.primaryTab){for(let e=t.messages.length-1;e>=0;e--)if(t.messages[e].mapGroupId){this._selectGroup(t.messages[e].mapGroupId,null,"points");break}}else"favorite"===t.layout.primaryTab&&t.map.groups.favorites&&this._selectGroup("favorites",null,"points")}_handleCardFavoriteAdded(t,e,s,a){const{card:i}=a;this._store.update(t=>{re(t.map,[i]),de(t.map,t.layout.primaryTab)})}_handleCardFavoriteRemoved(t,e,s,a){const{cardId:i}=a;this._store.update(t=>{const e=t.map.groups.favorites;if(!e)return;const s=`card:${i}`;e.groups=e.groups.filter(t=>t!==s),e.groups.length||delete t.map.groups.favorites;const a=t.map.favorite.filter;if(a.categories.length){const e=ce(t.map,"favorite");let s=!1;for(const i of Object.values(t.map.elements))if(e.has(i.group)&&a.categories.includes(i.category)){s=!0;break}s||(a.categories=[])}de(t.map,t.layout.primaryTab)})}_filterLargeAreas(t,e){const s=e.filter(e=>{const s=t[e];if(!s)return;return!(s.placeTypes||[]).some(t=>ge.has(t))});return s.length>0?s:e}}class be extends wt{constructor(t,e){super(t),this._ggHttp=e,this._pendingLoad=null,this._store.onQuery("conversations.load",this._load.bind(this)),this._store.onAction("conversations.switch",this._switch.bind(this)),this._store.onQuery("conversations.create",this._create.bind(this)),this._store.onAction("conversations.updateTitle",this._updateTitle.bind(this)),this._store.onQuery("conversations.rename",this._rename.bind(this)),this._store.onQuery("conversations.delete",this._delete.bind(this))}_load(t,e){if(this._pendingLoad)return e(this._queryLoading()),this._pendingLoad.then(t=>e(this._querySuccess(t.conversations)),t=>e(this._queryError(t.errors,t.type))),this._pendingLoad;e(this._queryLoading());const s=this._ggHttp.get("conversations");return this._pendingLoad=s,s.then(t=>{this._store.update(e=>{e.conversations=t.conversations||[]}),e(this._querySuccess(t.conversations))}).catch(t=>{console.error("[ConversationsSlice] Failed to load conversations:",t),e(this._queryError(t.errors,t.type))}).finally(()=>{this._pendingLoad=null}),s}_switch({id:t}){this._store.update(e=>{const s=t?e.conversations.find(e=>e.id===t):null;e.api.conversationId=t||null,e.api.conversationTitle=s?.title||null,e.messages=[],e.cards={},e.favorites=[],e.chat.answerPhase=null,e.chat.answerStatus=null,e.layout.isPlaceOpen=!1,e.map.groups={},e.map.elements={},e.map.selection={groupId:null,peekyGroupId:null,visibleElementIds:[],activeElementIds:[],focusElementIds:[],sliderElementIds:[],cardElementId:null,cardMode:null,fitFocus:null},e.map.chat={filter:{categories:[],locations:[],markerPrice:!0}}})}_create(t,e){e(this._queryLoading()),this._ggHttp.post("create-conversation").then(t=>{this._store.update(e=>{e.conversations.unshift(t.conversation)}),e(this._querySuccess(t.conversation))}).catch(t=>{console.error("[ConversationsSlice] Failed to create conversation:",t),e(this._queryError(t.errors,t.type))})}_updateTitle({id:t,title:e}){this._store.update(s=>{const a=s.conversations.find(e=>e.id===t);a&&(a.title=e),s.api.conversationId===t&&(s.api.conversationTitle=e)})}_rename({id:t,title:e},s){s(this._queryLoading()),this._ggHttp.post("rename-conversation",{id:t,title:e}).then(()=>{this._store.update(s=>{const a=s.conversations.find(e=>e.id===t);a&&(a.title=e),s.api.conversationId===t&&(s.api.conversationTitle=e)}),s(this._querySuccess())}).catch(t=>{console.error("[ConversationsSlice] Failed to rename conversation:",t),s(this._queryError(t.errors,t.type))})}_delete({id:t},e){e(this._queryLoading()),this._ggHttp.post("delete-conversation",{id:t}).then(s=>{this._store.update(e=>{e.conversations=e.conversations.filter(e=>e.id!==t)}),e(this._querySuccess(s.conversation||this._store.state.conversations[0]))}).catch(t=>{console.error("[ConversationsSlice] Failed to delete conversation:",t),e(this._queryError(t.errors,t.type))})}}const ve={version:6,layout:{isHidden:!0,isWindowOpen:!1,isMapOpen:!1,isPlaceOpen:!1,isIntroClosed:!1,isMapExpanded:!1,primaryTab:"chat"},api:{contactId:"",token:"",userId:"",userToken:"",httpStatus:"disconnected",socketStatus:"closed",networkFailure:!1,conversationId:null,conversationTitle:null},theme:null,chat:{maxMessageLen:0,maxMessages:0,answerPhase:null,answerStatus:null,isNewChat:!1,isNewThread:!1},map:{defaultLocation:null,groups:{},elements:{},selection:{groupId:null,peekyGroupId:null,visibleElementIds:[],activeElementIds:[],focusElementIds:[],sliderElementIds:[],cardElementId:null,cardMode:null,fitFocus:null},chat:{filter:{categories:[],locations:[],markerPrice:!0}},favorite:{filter:{categories:[],locations:[],markerPrice:!0}}},messages:[],cards:{},favorites:[],place:null,composeMessage:null,customMessage:{body:null,triggerCount:0,triggered:!1},followUpMessage:{body:null,triggered:!1},conversations:[]},ye=new Set(["layout.isHidden","api.socketStatus","theme","composeMessage"]);class we extends yt{constructor(t,e={}){super(e),this._state=structuredClone(ve),this._slices={messages:new Pt(this,t),cards:new Ut(this,t),favorites:new Ht(this,t),place:new Nt(this,t),layout:new Wt(this,t),map:new fe(this,t),conversations:new be(this,t)}}merge(t,e){if(!t)return;let s=t;"loaded"==e&&(s=function(t){const e=structuredClone(ve);if(t.version<=2)return e.layout={isWindowOpen:t.isWindowOpen,isMapOpen:t.isMapOpen},e.api={contactId:t.apiContactId,userId:"",token:t.apiToken,httpStatus:t.apiHttpStatus},e.chat={maxMessageLen:t.apiMaxMessageLen,maxMessages:t.apiMaxMessages,answerPhase:t.isAnswerTyping?"typing":null,isNewChat:t.isNewChat,isNewThread:t.isNewThread},e.messages=t.messages,e.customMessage={body:t.customMessage,triggerCount:t.customMessageTriggerCount,triggered:t.customMessageTriggered},e.followUpMessage={body:t.followUpMessage,triggered:t.followUpMessageTriggered},e;if(t.version<6&&t.map?.filter){const e=t.map.filter;t.map.chat={filter:{categories:e.categories||[],locations:[],markerPrice:e.markerPrice}},t.map.favorite={filter:{categories:[],locations:e.locations||[],markerPrice:!0}},delete t.map.filter}return gt(e,t),e.version=ve.version,e}(t)),super.merge(s,e)}get persistentState(){const t=structuredClone(this._state);for(const e of ye)bt(t,e);return t}drainPatches(){const t=super.drainPatches(),e=[];for(const s of t){if(ye.has(s.field))continue;let t=!1;for(const e of ye)if(vt(e,s.field)){t=!0;break}if(t&&s.data&&"object"==typeof s.data){const t=structuredClone(s.data);for(const e of ye)vt(e,s.field)&&bt(t,e.substring(s.field.length+1));e.push({...s,data:t})}else e.push(s)}return e}}class $e{_itemName=null;_changeHandler=null;_storageHandler=null;constructor(t){this._itemName=t,this._storageHandler=t=>{this._changeHandler&&t.key==this._itemName&&this._changeHandler(this.load())},window.addEventListener("storage",this._storageHandler)}load(){let t=null;try{t=JSON.parse(localStorage.getItem(this._itemName))}catch(t){console.error("Failed to parse state from localStorage.",t)}return t}save(t){try{localStorage.setItem(this._itemName,JSON.stringify(t))}catch(t){console.error("Failed to save state to localStorage.",t)}}onChange(t){this._changeHandler=t}}class ke{_db=null;_dbName=null;_storeName="state";_collectionPrefix=null;_channel=null;_changeHandler=null;constructor(t){this._dbName=t,this._collectionPrefix=`${this._storeName}.`,this._channel=new BroadcastChannel(`gg-sync-${t}`),this._channel.onmessage=this._handleBroadcast.bind(this)}async save(t){const e=[],s=[];for(const[a,i]of Object.entries(t))Array.isArray(i)?e.push([a,i]):s.push([a,i]);const a=!this._db||this._db.version!=t.version;a&&(this._db&&(this._db.close(),this._db=null),await this._open(t=>{const s=Array.from(t.objectStoreNames);for(const e of s)t.deleteObjectStore(e);t.createObjectStore(this._storeName,{keyPath:"id"});for(const[s]of e){const e=`${this._collectionPrefix}${s}`;t.createObjectStore(e,{autoIncrement:!0}).createIndex("id","id",{unique:!0})}},t.version));try{const t=[this._storeName];for(const[s]of e)t.push(`${this._collectionPrefix}${s}`);const i=this._db.transaction(t,"readwrite");if(!a)for(const e of t)i.objectStore(e).clear();for(const[t,s]of e)this._saveCollection(i,`${this._collectionPrefix}${t}`,s);for(const[t,e]of s)this._replaceField(i,{field:t,data:e});await this._completeTx(i),this._notifyChange(null)}catch(t){console.error("[StateDB] Failed to save state:",t)}}async load(){if(await this._open(),this._db)try{const t=await this._loadSingletons();if(!Object.keys(t).length)return;for(const e of this._db.objectStoreNames)if(e.startsWith(this._collectionPrefix)){const s=e.substring(this._collectionPrefix.length),a=await this._loadCollection(e);a&&(t[s]=a)}return t}catch(t){console.error("[StateDB] Failed to load state:",t)}}async patch(t){if(this._db&&t.length)try{const e=new Set,s=new Set;e.add(this._storeName);for(const a of t)if(s.add(a.field),"replace-field"!=a.op){const t=`${this._collectionPrefix}${a.field}`;e.add(t)}const a=this._db.transaction(Array.from(e),"readwrite");for(const e of t)switch(e.op){case"add-item":this._addItem(a,e);break;case"replace-item":this._replaceItem(a,e);break;case"remove-item":this._removeItem(a,e);break;case"replace-collection":this._replaceCollection(a,e);break;case"replace-field":this._replaceField(a,e)}await this._completeTx(a),this._notifyChange(Array.from(s))}catch(t){console.error("[StateDB] Failed to patch state:",t)}}_getCollectionStore(t,e){const s=`${this._collectionPrefix}${e}`;return this._db.objectStoreNames.contains(s)?t.objectStore(s):null}_addItem(t,e){const s=this._getCollectionStore(t,e.field);if(!s)return;s.add(e.item).onerror=t=>{"ConstraintError"===t.target.error?.name&&(t.preventDefault(),t.stopPropagation())}}_replaceItem(t,e){const s=this._getCollectionStore(t,e.field);if(!s)return;const a=s.index("id").getKey(e.item.id);a.onsuccess=()=>{null!=a.result&&s.put(e.item,a.result)}}_removeItem(t,e){const s=this._getCollectionStore(t,e.field);if(!s)return;const a=s.index("id").getKey(e.item.id);a.onsuccess=()=>{null!=a.result&&s.delete(a.result)}}_replaceCollection(t,e){const s=this._getCollectionStore(t,e.field);if(!s)return;s.clear().onsuccess=()=>{for(const t of e.data)s.add(t)}}_replaceField(t,e){t.objectStore(this._storeName).put({id:e.field,data:e.data,timestamp:Date.now()})}onChange(t){this._changeHandler=t}destroy(){this._channel&&this._channel.close(),this._db&&this._db.close()}async _completeTx(t){return new Promise((e,s)=>{t.oncomplete=()=>e(),t.onerror=e=>{const a=e.target?.error||t.error;"ConstraintError"!==a?.name?s(a):e.preventDefault()},t.onabort=a=>{const i=a.target?.error||t.error;if("ConstraintError"===i?.name)return e();s(i)}})}async _request(t){return new Promise(e=>{t.onsuccess=()=>e(t.result),t.onerror=()=>e(null)})}async _open(t,e){this._db||(this._db=await new Promise((s,a)=>{const i=indexedDB.open(this._dbName,e);i.onerror=()=>{console.error("[StateDB] Failed to open IndexedDB:",i.error),a(i.error)},i.onblocked=()=>{console.warn("[StateDB] IndexedDB open blocked - another connection is preventing upgrade"),s(null)},i.onsuccess=()=>{const e=i.result;t||e.objectStoreNames.length?s(e):(e.close(),this._request(indexedDB.deleteDatabase(this._dbName)).then(()=>{s(null)}))},t&&(i.onupgradeneeded=e=>t(e.target.result))}))}_getStore(t,e){return this._db.transaction([t],e).objectStore(t)}async _loadSingletons(){return new Promise(t=>{const e=this._getStore(this._storeName,"readonly").getAll();e.onsuccess=()=>{const s=e.result||[],a={};for(const t of s)t.id&&(a[t.id]=t.data);t(a)},e.onerror=()=>t(null)})}async _loadFields(t){if(await this._open(),!this._db)return;const e={};for(const s of t){const t=`${this._collectionPrefix}${s}`;if(this._db.objectStoreNames.contains(t)){const a=await this._loadCollection(t);a&&(e[s]=a)}else{const t=await this._loadSingleton(s);void 0!==t&&(e[s]=t)}}return e}async _loadSingleton(t){const e=this._getStore(this._storeName,"readonly"),s=await this._request(e.get(t));if(s)return s.data}async _loadCollection(t){const e=this._getStore(t,"readonly");return await this._request(e.getAll())||[]}_saveCollection(t,e,s){const a=t.objectStore(e);for(const t of s)a.add(t)}_notifyChange(t){this._channel.postMessage({type:"state-changed",fields:t,timestamp:Date.now()})}async _handleBroadcast(t){if(this._changeHandler&&"state-changed"==t.data.type){const e=t.data.fields?await this._loadFields(t.data.fields):await this.load();e&&this._changeHandler(e)}}}class Se{_channel=null;_isLeader=!1;_leaderCheckResolve=null;constructor(t){this._channel=new BroadcastChannel(t),this._channel.onmessage=t=>this._onMessage(t.data)}get isLeader(){return this._isLeader}claimLeadership(){this._isLeader=!0,this._channel.postMessage({type:"leader-claim"})}ensureLeader(){return this._isLeader?Promise.resolve(!0):new Promise(t=>{this._leaderCheckResolve=t,setTimeout(()=>{this._leaderCheckResolve&&(this._leaderCheckResolve=null,this._isLeader=!0,this._channel.postMessage({type:"leader-claim"}),t(!0))},100),this._channel.postMessage({type:"leader-check"})})}destroy(){this._channel.close()}_onMessage({type:t}){switch(t){case"leader-check":this._isLeader&&this._channel.postMessage({type:"leader-claim"});break;case"leader-claim":this._leaderCheckResolve&&(this._leaderCheckResolve(!1),this._leaderCheckResolve=null),this._isLeader,this._isLeader=!1}}}class Te{_connectQueue=[];_saveStoreTimeout=null;_isSocketUpdate=!1;_socketReconnectCnt=0;_socketReconnectTimer=null;_isReconnecting=!1;constructor(t,e={}){this._mainStore=e.mainStore,this._ggHttp=e.ggHttp,this._ggSocket=e.ggSocket,this._onAnalytics=e.onAnalytics||null,this._config=e.config||{},this._options=e;const s=new URL(location.href);this._pageUrl=`${s.origin}${s.pathname}`,this._pageTitle=document.title,this._lastOpenIsIcebreaker=!1,this._handleVisibilityChange=this._handleVisibilityChange.bind(this),this._handleOffline=this._handleOffline.bind(this),this._handleOnline=this._handleOnline.bind(this),this._handleFocus=this._handleFocus.bind(this);let a=`gg-${t}`,i="widget"==t?"widgetState":a;e.company&&(a=`${a}-${e.company}`,i=`${i}-${e.company}`),this._chatId=a,this._legacyChatId=i,this._enableSync(a)}setLastOpenIsIcebreaker(t){this._lastOpenIsIcebreaker=t}async _enableMainStore(t,e=null){if("indexeddb"==this._config.stateBackend){this._stateStorage=new ke(t);const s=performance.now(),a=await this._stateStorage.load();if((performance.now()-s).toFixed(2),a)this._mainStore.merge(a,"loaded");else{const t=new $e(e).load();this._mainStore.merge(t,"loaded")}await this._stateStorage.save(this._mainStore.persistentState)}else{this._stateStorage=new $e(e);const t=performance.now(),s=this._stateStorage.load();this._mainStore.merge(s,"loaded"),(performance.now()-t).toFixed(2),this._config.stateBackend}this._updateHttpAuth(),this._stateStorage.onChange(t=>{this._mainStore.merge(t,"synced")}),this._mainStore.onUpdate((t,e,s)=>{"synced"==s?this._updateHttpAuth():this._saveStore()})}_updateHttpAuth(){const{api:t}=this._mainStore.state;t.userId&&t.userToken?this._ggHttp.setAuth(t.userId,t.userToken):t.contactId&&t.token&&this._ggHttp.setLegacyAuth(t.contactId,t.token),t.conversationId&&this._ggHttp.setConversationId(t.conversationId)}_enableSync(t){this._tabSync=new Se(`gg-sync-${t}`),window.addEventListener("focus",this._handleFocus),document.hasFocus()&&this._tabSync.claimLeadership()}_handleFocus(){this._tabSync.claimLeadership()}async _saveStore(){if(this._saveStoreTimeout)return;const t=await this._tabSync.ensureLeader();this._saveStoreTimeout=setTimeout(async()=>{if(this._isSocketUpdate||t){const t=performance.now();"indexeddb"==this._config.stateBackend?await this._stateStorage.patch(this._mainStore.drainPatches()):await this._stateStorage.save(this._mainStore.persistentState);(performance.now()-t).toFixed(2),this._config.stateBackend}else"indexeddb"==this._config.stateBackend&&this._mainStore.drainPatches();this._saveStoreTimeout=null,this._isSocketUpdate=!1},1e3)}_openSocket(){this._mainStore.update(t=>{t.api.socketStatus="opening"});const{api:t}=this._mainStore.state;this._ggSocket.open({token:t.userToken,userId:t.userId,conversationId:t.conversationId})}_reconnect(t=!1){clearTimeout(this._socketReconnectTimer);const{api:e,layout:s}=this._mainStore.state;if(s.isWindowOpen&&!e.networkFailure)if(t){if("error"!==e.socketStatus&&"closed"!==e.socketStatus&&"opening"!==e.socketStatus)return;this._socketReconnectCnt=0,this._isReconnecting=!0,"connected"===e.httpStatus?this._openSocket():this.connect()}else this._socketReconnectCnt>=this._config.apiMaxReconnects?(this._isReconnecting=!1,this._mainStore.update(t=>{t.api.socketStatus="error"})):(this._socketReconnectCnt++,this._isReconnecting=!0,this._socketReconnectCnt%10==0?(this._mainStore.update(t=>{t.api.httpStatus="disconnected"}),this.connect()):this._socketReconnectTimer=setTimeout(()=>this._openSocket(),this._getReconnectDelay()))}_getReconnectDelay(){const t=this._config.apiReconnectDelay*Math.pow(1.5,this._socketReconnectCnt-1);return Math.min(t,3e4)}_handleVisibilityChange(){document.hidden||this._reconnect(!0)}_handleOffline(){clearTimeout(this._socketReconnectTimer),this._socketReconnectTimer=null,this._socketReconnectCnt=0,this._isReconnecting=!1,this._mainStore.update(t=>{t.api.socketStatus="closed",t.api.networkFailure=!0})}_handleOnline(){this._mainStore.update(t=>{t.api.networkFailure=!1}),this._reconnect(!0)}_enableAutoReconnect(){document.addEventListener("visibilitychange",this._handleVisibilityChange),window.addEventListener("offline",this._handleOffline),window.addEventListener("online",this._handleOnline),this._mainStore.onUpdate(t=>{this._reconnect(!0)},null,["layout.isWindowOpen"])}_enableSocketApi(){this._ggSocket.onStatus(t=>{switch(this._mainStore.update(e=>{e.api.socketStatus="error"===t?"opening":t,e.chat.answerPhase=null}),t){case"opened":{this._socketReconnectCnt=0,this._isReconnecting=!1,clearTimeout(this._socketReconnectTimer),this._mainStore.state.chat.isNewChat&&document.hasFocus()?(this._ggSocket.send("ping"),this._ggHttp.post("user-question",{currentUrl:this._pageUrl,pageTitle:this._pageTitle,message:At(xt({type:"intro"}))}).catch(t=>{console.error("[ChatSDK] Failed to send intro message:",t)}),this._mainStore.update(t=>{t.chat.isNewChat=!1,t.chat.isNewThread=!1,t.customMessage.triggered=!1,t.followUpMessage.triggered=!1})):this._mainStore.state.chat.isNewThread&&document.hasFocus()&&(this._lastOpenIsIcebreaker||this._ggHttp.post("user-question",{currentUrl:this._pageUrl,pageTitle:this._pageTitle,message:At(xt({type:"intro:return"}))}).catch(t=>{console.error("[ChatSDK] Failed to send intro:return:",t)}),this._lastOpenIsIcebreaker=!1,this._mainStore.update(t=>{t.chat.isNewThread=!1,t.customMessage.triggered=!1,t.followUpMessage.triggered=!1}));const t=this._connectQueue.length>0?500:128;setTimeout(()=>this._handleConnect(),t);break}case"closed":this._isReconnecting?this._reconnect():this._socketReconnectCnt=0;break;case"error":this._reconnect()}}),this._ggSocket.onMessage(t=>{switch(t.type){case"answer:update":t.message&&(this._isSocketUpdate=!0,this._mainStore.update(e=>{e.chat.answerStatus=t.message}));break;case"answer:typing-start":"streaming"!==this._mainStore.state.chat.answerPhase&&(this._isSocketUpdate=!0,this._mainStore.update(t=>{t.chat.answerPhase="typing"}));break;case"answer:typing-stop":"streaming"!==this._mainStore.state.chat.answerPhase&&(this._isSocketUpdate=!0,this._mainStore.update(t=>{t.chat.answerPhase=null,t.chat.answerStatus=!1}));break;case"answer:question-received":t.questionId&&t.messageId&&(this._isSocketUpdate=!0,this._mainStore.sendAction("messages.update",{messageId:t.questionId,fields:{apiMessageId:t.messageId}}));break;case"answer:stopped":this._isSocketUpdate=!0,this._mainStore.update(t=>{t.chat.answerPhase=null,t.chat.answerStatus=!1}),t.messageId&&this._mainStore.sendAction("messages.update",{apiMessageId:t.messageId,fields:{stoppedByUser:!0}});break;case"answer":this._isSocketUpdate=!0,this._mainStore.update(e=>{e.chat.answerPhase=t.message?.delta||t.message?.recovery?"streaming":null}),this._mainStore.sendAction("messages.socket-answer",{data:t});break;case"conversation:title":this._isSocketUpdate=!0,this._mainStore.sendAction("conversations.updateTitle",{id:t.conversationId,title:t.title})}})}_handleConnect(){for(const t of this._connectQueue)t();this._connectQueue=[]}async load(){this._stateStorage||(await this._enableMainStore(this._chatId,this._legacyChatId),this._enableSocketApi(),this._enableAutoReconnect());try{return(await this._ggHttp.post("settings",{pageUrl:this._pageUrl})).chatbotSettings||{}}catch(t){return console.error("[ChatSDK] Failed to load settings:",t),null}}loadMessages(){this._mainStore.sendQuery("messages.load")}async connect(){const{api:t}=this._mainStore.state;if(!t.userId&&t.contactId&&"connected"==t.httpStatus&&this._mainStore.update(t=>{t.api.httpStatus="disconnected"}),"disconnected"==this._mainStore.state.api.httpStatus){this._mainStore.update(t=>{t.api.httpStatus="connecting"});try{const t=await this._ggHttp.post("user-connect");this._mainStore.update(e=>{e.api.contactId=t.contactId,e.api.token=t.token,e.api.userId=t.userId,e.api.userToken=t.userToken,e.api.conversationId=t.conversationId||null,e.api.conversationTitle=t.conversationTitle||null,e.api.httpStatus="connected",e.chat.isNewChat=t.isNewChat,e.chat.isNewThread=t.isNewThread,e.chat.maxMessageLen=t.maxMessageLen,e.chat.maxMessages=t.maxMessages,e.map.defaultLocation=t.defaultLocation?.lat&&t.defaultLocation?.lng?t.defaultLocation:null,e.customMessage.body=t.customMessage,e.customMessage.triggerCount=t.customMessageTriggerCount,e.followUpMessage.body=t.followUpMessage}),this._updateHttpAuth()}catch(t){console.error("[ChatSDK] Failed to connect:",t),this._mainStore.update(t=>{t.api.httpStatus="error"})}}"connected"==this._mainStore.state.api.httpStatus&&"closed"==this._mainStore.state.api.socketStatus&&this._openSocket()}switchConversation({id:t}={}){this.disconnect(),this._mainStore.sendAction("conversations.switch",{id:t}),this._updateHttpAuth(),this.connect()}disconnect(){this._mainStore.update(t=>{t.api.httpStatus="disconnected",t.api.socketStatus="closed"}),this._ggSocket.close()}async isTypingMessage(t){try{await this._ggHttp.post(t?"user-typing-start":"user-typing-stop")}catch(t){console.error("[ChatSDK] Failed to send typing status:",t)}}async readMessage(t,e){if(e)try{await this._ggHttp.post("user-answer-read",{messageId:e}),this._mainStore.sendAction("messages.update",{messageId:t,fields:{status:"read"}})}catch(t){console.error("[ChatSDK] Failed to mark message as read:",t)}}async feedback(t){this._mainStore.sendAction("messages.update",{messageId:t.message.id,fields:{feedback:t.feedback}});try{await this._ggHttp.post("user-feedback",{messageId:t.message.apiMessageId,feedback:t.feedback})}catch(t){console.error("[ChatSDK] Failed to send feedback:",t)}}async stopResponse(){this._mainStore.update(t=>{t.chat.answerPhase=null,t.chat.answerStatus=!1});try{await this._ggHttp.post("user-stop-answer")}catch(t){console.error("Failed to stop response:",t)}}composeMessage(t={}){this._mainStore.update(e=>{e.composeMessage={type:"text",body:t.body?t.body.trim():""}},"compose-message:updated")}async sendMessage(t={}){const e={};"reply"==t.type?(e.type="reply",e.title=t.title,e.payload=t.payload):"icebreaker"==t.type?(e.type="icebreaker",e.body=t.body?t.body.trim():""):(e.type="text",e.body=t.body?t.body.trim():""),t.entityId&&(e.entityId=t.entityId);const s=xt(e);if("opened"===this._mainStore.state.api.socketStatus&&(s.status="sending"),this._mainStore.sendAction("messages.add",s),"opened"===this._mainStore.state.api.socketStatus&&this._mainStore.update(t=>{t.chat.answerPhase="waiting"}),"opened"!=this._mainStore.state.api.socketStatus){if(this._connectQueue.length>=5)return this._mainStore.sendAction("messages.update",{messageId:s.id,fields:{status:"failed"}}),void console.warn("Message queue full (5 messages). Cannot queue more messages while offline.");this._connectQueue.push(()=>this._sendMessage(s))}else this._sendMessage(s)}async _sendMessage(t){this._mainStore.sendAction("messages.update",{messageId:t.id,fields:{status:"sending"}}),this._ggSocket.send("ping");try{const e=await this._ggHttp.post("user-question",{currentUrl:this._pageUrl,pageTitle:this._pageTitle,message:At(t)});e?.intentData&&this._sendIntentAnalytics(e.intentData,t.id,this._mainStore.state.api.userId),this._mainStore.sendAction("messages.update",{messageId:t.id,fields:{status:"sent"}})}catch(e){this._mainStore.sendAction("messages.update",{messageId:t.id,fields:{status:"failed"}}),console.error("Failed to send message:",e)}}_sendIntentAnalytics(t,e,s){this._onAnalytics&&this._onAnalytics({name:"message-intent",params:{intent:t,messageId:e,pageUrl:this._pageUrl,platform:"Web Chatbot",timestamp:(new Date).toISOString(),clientId:s}},{skipBackend:!0})}async replyMessage(t){const e=xt({type:"reply",title:t.title,payload:t.payload});this._mainStore.sendAction("messages.reply",{messageId:t.messageId,replyIndex:t.replyIndex,actionMessage:e}),this._ggSocket.send("ping");try{const s=await this._ggHttp.post("user-question",{currentUrl:this._pageUrl,pageTitle:this._pageTitle,message:At(e),replyMessageId:t.apiMessageId,replyIndex:t.replyIndex});s?.intentData&&this._sendIntentAnalytics(s.intentData,e.id,this._mainStore.state.api.userId),this._mainStore.sendAction("messages.update",{messageId:e.id,fields:{status:"sent"}})}catch(t){console.error("[ChatSDK] Failed to send reply message:",t)}}systemMessage(t){var e;this._mainStore.sendAction("messages.add",(e={type:"text",body:t.body},{id:Mt(),timestamp:Date.now(),from:"agent",apiFrom:null,content:e,status:"received"})),this._mainStore.update(e=>{"custom"==t.trigger?e.customMessage.triggered=!0:"follow-up"==t.trigger&&(e.followUpMessage.triggered=!0)})}}class Ce extends Error{constructor(t,e){super(e[0]||"Request failed"),this.name="HttpError",this.type=t,this.errors=e}}class Me{constructor(t){this._url=t.url||"",this._company=t.company||null,this._onNetworkError=t.onNetworkError||null,this._contactId=null,this._userId=null,this._token=null,this._conversationId=null}setLegacyAuth(t,e){this._contactId=t,this._token=e}setAuth(t,e){this._contactId=null,this._userId=t,this._token=e}setConversationId(t){this._conversationId=t}async post(t,e={}){const s=this._url+t;return this._send("POST",s,e)}async get(t,e={}){const s=new URL(this._url+t);return Object.keys(e).forEach(t=>{s.searchParams.append(t,e[t])}),this._send("GET",s.toString())}async _send(t,e,s){const a=new AbortController,i={"Content-Type":"application/json"};this._userId?i["X-User-Id"]=this._userId:this._contactId&&(i["X-Contact-Id"]=this._contactId),this._token&&(i["X-Token"]=this._token),this._conversationId&&(i["X-Conversation-Id"]=this._conversationId),this._company&&(i["X-Company"]=this._company);const n={signal:a.signal,method:t,headers:i};s&&(n.body=JSON.stringify(s));const o=new Promise((t,s)=>{fetch(e,n).then(async e=>{try{const a=await e.json();e.ok?t(a):s(new Ce("server",a.errors||["Request failed"]))}catch(t){s(new Ce("server",["Invalid JSON response"]))}}).catch(t=>{"AbortError"===t.name?s(new Ce("abort",[])):t instanceof Ce?s(t):(this._onNetworkError&&this._onNetworkError(t),s(new Ce("network",[t.message])))})});return o.cancel=()=>{a.abort()},o}}class xe{constructor(t){this._url=t.url||"",this._company=t.company||"",this._socket=null,this._connectTimer=null,this._errorEmitted=!1,this._statusListeners=new Set,this._messageListeners=new Set,this._onOpenHandler=this._onOpenHandler.bind(this),this._onCloseHandler=this._onCloseHandler.bind(this),this._onErrorHandler=this._onErrorHandler.bind(this),this._onMessageHandler=this._onMessageHandler.bind(this)}onStatus(t){this._statusListeners.add(t)}offStatus(t){this._statusListeners.delete(t)}_emitStatus(t){this._statusListeners.forEach(e=>e(t))}onMessage(t){this._messageListeners.add(t)}offMessage(t){this._messageListeners.delete(t)}open(t){this.close();const e=new URLSearchParams({token:t.token,"user-id":t.userId,"conversation-id":t.conversationId});this._company&&e.set("company",this._company);const s=`${this._url}?${e}`;this._errorEmitted=!1,this._socket=new WebSocket(s),this._socket.addEventListener("open",this._onOpenHandler),this._socket.addEventListener("close",this._onCloseHandler),this._socket.addEventListener("error",this._onErrorHandler),this._socket.addEventListener("message",this._onMessageHandler),this._connectTimer=setTimeout(()=>{this._connectTimer=null,this._socket.close()},1e4)}close(){clearTimeout(this._connectTimer),this._connectTimer=null,this._socket&&(this._socket.removeEventListener("open",this._onOpenHandler),this._socket.removeEventListener("close",this._onCloseHandler),this._socket.removeEventListener("error",this._onErrorHandler),this._socket.removeEventListener("message",this._onMessageHandler),this._socket.close(),this._socket=null)}send(t){if(this._socket)try{this._socket.send(JSON.stringify(t))}catch(t){console.error(t)}}_emitMessage(t){this._messageListeners.forEach(e=>e(t))}_onOpenHandler(){clearTimeout(this._connectTimer),this._connectTimer=null,this._emitStatus("opened")}_onCloseHandler(t){t.wasClean?this._emitStatus("closed"):this._errorEmitted||(this._errorEmitted=!0,this._emitStatus("error"))}_onErrorHandler(){this._errorEmitted||(this._errorEmitted=!0,this._emitStatus("error"))}_onMessageHandler(t){try{this._emitMessage(JSON.parse(t.data))}catch(t){console.error("GuideGeekSocket.message error",t)}}}function Ie(t={}){if(window.guidegeek)return;const e=t.config||{},s={};window.guidegeek={chat:function(t){if(!t)throw new Error("GuideGeek Chat ID is required.");if(!s[t]){const a=new Me({url:e.apiHttpUrl}),i=new xe({url:e.apiSocketUrl}),n=new we(a,{trackPatches:"indexeddb"==e.stateBackend}),o=new Te(t,{mainStore:n,ggHttp:a,ggSocket:i,config:e});a.onNetworkError=t=>o._handleNetworkError(t),s[t]=function(t,e){return t.onUpdate(t=>{"opened"==t.api.socketStatus&&"connected"==t.api.httpStatus&&e.loadMessages()},null,["api.socketStatus"]),{onUpdate:e=>{t.onUpdate((t,s)=>{e(Ae(t),Ae(s))}),e(Ae(t.state),{})},load:()=>e.load(),connect:()=>e.connect(),sendMessage:t=>e.sendMessage(t),replyMessage:t=>e.replyMessage(t)}}(n,o)}return s[t]},getChat:function(t){if(!t)throw new Error("GuideGeek Chat ID is required.");return s[t]},registerChat:function(t,e){if(s[t])throw new Error(`GuideGeek Chat '${t}' is already registered.`);s[t]=e,document.dispatchEvent(new CustomEvent("GuideGeekChatRegistered",{detail:{id:t,chat:e}}))},unregisterChat:function(t){s[t]&&(delete s[t],document.dispatchEvent(new CustomEvent("GuideGeekChatUnregistered",{detail:{id:t}})))}}}function Ae(t){return{apiHttpStatus:t.api?.httpStatus,apiSocketStatus:t.api?.socketStatus,apiMaxMessageLen:t.chat?.maxMessageLen,isAnswerTyping:Boolean(t.chat?.isAnswerTyping),messages:t.messages}}
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const Le=globalThis,Oe=Le.ShadowRoot&&(void 0===Le.ShadyCSS||Le.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ee=Symbol(),De=new WeakMap;let Pe=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==Ee)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(Oe&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=De.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&De.set(e,t))}return t}toString(){return this.cssText}};const Ue=Oe?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new Pe("string"==typeof t?t:t+"",void 0,Ee))(e)})(t):t,{is:He,defineProperty:Ne,getOwnPropertyDescriptor:Fe,getOwnPropertyNames:We,getOwnPropertySymbols:Be,getPrototypeOf:Re}=Object,qe=globalThis,ze=qe.trustedTypes,je=ze?ze.emptyScript:"",Ge=qe.reactiveElementPolyfillSupport,Ye=(t,e)=>t,Ve={toAttribute(t,e){switch(e){case Boolean:t=t?je:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},Qe=(t,e)=>!He(t,e),Ke={attribute:!0,type:String,converter:Ve,reflect:!1,useDefault:!1,hasChanged:Qe};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/Symbol.metadata??=Symbol("metadata"),qe.litPropertyMetadata??=new WeakMap;let Ze=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Ke){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),a=this.getPropertyDescriptor(t,s,e);void 0!==a&&Ne(this.prototype,t,a)}}static getPropertyDescriptor(t,e,s){const{get:a,set:i}=Fe(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:a,set(e){const n=a?.call(this);i?.call(this,e),this.requestUpdate(t,n,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Ke}static _$Ei(){if(this.hasOwnProperty(Ye("elementProperties")))return;const t=Re(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Ye("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ye("properties"))){const t=this.properties,e=[...We(t),...Be(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(Ue(t))}else void 0!==t&&e.push(Ue(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(Oe)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const s of e){const e=document.createElement("style"),a=Le.litNonce;void 0!==a&&e.setAttribute("nonce",a),e.textContent=s.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),a=this.constructor._$Eu(t,s);if(void 0!==a&&!0===s.reflect){const i=(void 0!==s.converter?.toAttribute?s.converter:Ve).toAttribute(e,s.type);this._$Em=t,null==i?this.removeAttribute(a):this.setAttribute(a,i),this._$Em=null}}_$AK(t,e){const s=this.constructor,a=s._$Eh.get(t);if(void 0!==a&&this._$Em!==a){const t=s.getPropertyOptions(a),i="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:Ve;this._$Em=a;const n=i.fromAttribute(e,t.type);this[a]=n??this._$Ej?.get(a)??n,this._$Em=null}}requestUpdate(t,e,s,a=!1,i){if(void 0!==t){const n=this.constructor;if(!1===a&&(i=this[t]),s??=n.getPropertyOptions(t),!((s.hasChanged??Qe)(i,e)||s.useDefault&&s.reflect&&i===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:a,wrapped:i},n){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,n??e??this[t]),!0!==i||void 0!==n)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===a&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,a=this[e];!0!==t||this._$AL.has(e)||void 0===a||this.C(e,void 0,s,a)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};Ze.elementStyles=[],Ze.shadowRootOptions={mode:"open"},Ze[Ye("elementProperties")]=new Map,Ze[Ye("finalized")]=new Map,Ge?.({ReactiveElement:Ze}),(qe.reactiveElementVersions??=[]).push("2.1.2");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const Xe=globalThis,Je=t=>t,ts=Xe.trustedTypes,es=ts?ts.createPolicy("lit-html",{createHTML:t=>t}):void 0,ss="$lit$",as=`lit$${Math.random().toFixed(9).slice(2)}$`,is="?"+as,ns=`<${is}>`,os=document,rs=()=>os.createComment(""),ls=t=>null===t||"object"!=typeof t&&"function"!=typeof t,cs=Array.isArray,ds="[ \t\n\f\r]",hs=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,us=/-->/g,ps=/>/g,ms=RegExp(`>|${ds}(?:([^\\s"'>=/]+)(${ds}*=${ds}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),_s=/'/g,gs=/"/g,fs=/^(?:script|style|textarea|title)$/i,bs=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),vs=Symbol.for("lit-noChange"),ys=Symbol.for("lit-nothing"),ws=new WeakMap,$s=os.createTreeWalker(os,129);function ks(t,e){if(!cs(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==es?es.createHTML(e):e}const Ss=(t,e)=>{const s=t.length-1,a=[];let i,n=2===e?"":3===e?"":"",o=hs;for(let e=0;e"===l[0]?(o=i??hs,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,r=l[1],o=void 0===l[3]?ms:'"'===l[3]?gs:_s):o===gs||o===_s?o=ms:o===us||o===ps?o=hs:(o=ms,i=void 0);const h=o===ms&&t[e+1].startsWith("/>")?" ":"";n+=o===hs?s+ns:c>=0?(a.push(r),s.slice(0,c)+ss+s.slice(c)+as+h):s+as+(-2===c?e:h)}return[ks(t,n+(t[s]||">")+(2===e?" ":3===e?"":"")),a]};let Ts=class t{constructor({strings:e,_$litType$:s},a){let i;this.parts=[];let n=0,o=0;const r=e.length-1,l=this.parts,[c,d]=Ss(e,s);if(this.el=t.createElement(c,a),$s.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=$s.nextNode())&&l.length0){i.textContent=ts?ts.emptyScript:"";for(let s=0;scs(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==ys&&ls(this._$AH)?this._$AA.nextSibling.data=t:this.T(os.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,a="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Ts.createElement(ks(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===a)this._$AH.p(e);else{const t=new Ms(a,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=ws.get(t.strings);return void 0===e&&ws.set(t.strings,e=new Ts(t)),e}k(e){cs(this._$AH)||(this._$AH=[],this._$AR());const s=this._$AH;let a,i=0;for(const n of e)i===s.length?s.push(a=new t(this.O(rs()),this.O(rs()),this,this.options)):a=s[i],a._$AI(n),i++;i2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=ys}_$AI(t,e=this,s,a){const i=this.strings;let n=!1;if(void 0===i)t=Cs(this,t,e,0),n=!ls(t)||t!==this._$AH&&t!==vs,n&&(this._$AH=t);else{const a=t;let o,r;for(t=i[0],o=0;o{const a=s?.renderBefore??e;let i=a._$litPart$;if(void 0===i){const t=s?.renderBefore??null;a._$litPart$=i=new xs(e.insertBefore(rs(),t),t,void 0,s??{})}return i._$AI(t),i
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/},Hs=globalThis;let Ns=class extends Ze{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Us(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return vs}};Ns._$litElement$=!0,Ns.finalized=!0,Hs.litElementHydrateSupport?.({LitElement:Ns});const Fs=Hs.litElementPolyfillSupport;Fs?.({LitElement:Ns}),(Hs.litElementVersions??=[]).push("4.2.2");class Ws{_ggHttp=null;_auth=null;set ggHttp(t){this._ggHttp=t}set auth(t){this._auth=t}async track(t,e={}){e.skipThirdParty||this._trackThirdParty(t),e.skipBackend||await this._trackBackend(t)}_trackThirdParty(t){const e=`mn-guidegeek:${t.name}`,s=t.params||{};"function"==typeof window.gtag?window.gtag("event",e,s):window.dataLayer&&window.dataLayer.push({...s,event:e}),window.utag&&window.utag.link({tealium_event:e,...s})}async _trackBackend(t){if(this._ggHttp&&this._auth?.contactId)try{await this._ggHttp.post("analytics",{contactId:this._auth.contactId,token:this._auth.token,event:t})}catch(t){console.error("AnalyticsClient track error",t)}}}function Bs(t){for(const e of t)customElements.get(e.name)||customElements.define(e.name,e.component)}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const Rs=2,qs=t=>(...e)=>({_$litDirective$:t,values:e});let zs=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const{I:js}=Ds,Gs=t=>t,Ys=()=>document.createComment(""),Vs=(t,e,s)=>{const a=t._$AA.parentNode,i=void 0===e?t._$AB:e._$AA;if(void 0===s){const e=a.insertBefore(Ys(),i),n=a.insertBefore(Ys(),i);s=new js(e,n,t,t.options)}else{const e=s._$AB.nextSibling,n=s._$AM,o=n!==t;if(o){let e;s._$AQ?.(t),s._$AM=t,void 0!==s._$AP&&(e=t._$AU)!==n._$AU&&s._$AP(e)}if(e!==i||o){let t=s._$AA;for(;t!==e;){const e=Gs(t).nextSibling;Gs(a).insertBefore(t,i),t=e}}}return s},Qs=(t,e,s=t)=>(t._$AI(e,s),t),Ks={},Zs=(t,e=Ks)=>t._$AH=e,Xs=t=>{t._$AR(),t._$AA.remove()},Js=(t,e,s)=>{const a=new Map;for(let i=e;i<=s;i++)a.set(t[i],i);return a},ta=qs(class extends zs{constructor(t){if(super(t),t.type!==Rs)throw Error("repeat() can only be used in text expressions")}dt(t,e,s){let a;void 0===s?s=e:void 0!==e&&(a=e);const i=[],n=[];let o=0;for(const e of t)i[o]=a?a(e,o):o,n[o]=s(e,o),o++;return{values:n,keys:i}}render(t,e,s){return this.dt(t,e,s).values}update(t,[e,s,a]){const i=(t=>t._$AH)(t),{values:n,keys:o}=this.dt(e,s,a);if(!Array.isArray(i))return this.ut=o,n;const r=this.ut??=[],l=[];let c,d,h=0,u=i.length-1,p=0,m=n.length-1;for(;h<=u&&p<=m;)if(null===i[h])h++;else if(null===i[u])u--;else if(r[h]===o[p])l[p]=Qs(i[h],n[p]),h++,p++;else if(r[u]===o[m])l[m]=Qs(i[u],n[m]),u--,m--;else if(r[h]===o[m])l[m]=Qs(i[h],n[m]),Vs(t,l[m+1],i[h]),h++,m--;else if(r[u]===o[p])l[p]=Qs(i[u],n[p]),Vs(t,i[h],i[u]),u--,p++;else if(void 0===c&&(c=Js(o,p,m),d=Js(r,h,u)),c.has(r[h]))if(c.has(r[u])){const e=d.get(o[p]),s=void 0!==e?i[e]:null;if(null===s){const e=Vs(t,i[h]);Qs(e,n[p]),l[p]=e}else l[p]=Qs(s,n[p]),Vs(t,i[h],s),i[e]=null;p++}else Xs(i[u]),u--;else Xs(i[h]),h++;for(;p<=m;){const e=Vs(t,l[m+1]);Qs(e,n[p]),l[p++]=e}for(;h<=u;){const t=i[h++];null!==t&&Xs(t)}return this.ut=o,Zs(t,l),vs}});
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
class ea extends zs{constructor(t){if(super(t),this.it=ys,t.type!==Rs)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===ys||null==t)return this._t=void 0,this.it=t;if(t===vs)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}ea.directiveName="unsafeHTML",ea.resultType=1;const sa=qs(ea);class aa extends Ns{_blockName=null;static properties={store:{attribute:!1},context:{attribute:!1}};constructor(){super(),this._contextHandlers=new Set,this._html=bs,this._unsafeHTML=sa,this._repeat=ta,this._storeHandlers=new Set,this._queryRequests=new Set}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.store&&this.context?(this._store=this.store,this._context=this.context):this._connectToParentElement()}disconnectedCallback(){if(super.disconnectedCallback(),this._store){for(const t of this._storeHandlers)this._store.offUpdate(t);this._storeHandlers.clear()}for(const t of this._queryRequests)t?.cancel&&t.cancel();this._queryRequests.clear()}set context(t){this._context=t;for(const t of this._contextHandlers)t(this._context);this.requestUpdate()}get context(){return this._context||{}}onContextChanged(t){this._contextHandlers.add(t)}get theme(){return this.context.theme||{}}get labels(){return this.theme.labels||{}}_connectToParentElement(){let t=this.parentElement;for(;t&&!(t instanceof aa);)t=t.parentElement;t&&(this._store=t._store,this._context=t._context,t.onContextChanged(t=>{this._context=t,this.requestUpdate()}))}_observe(t,e){this._store&&(this._storeHandlers.add(t),this._store.onUpdate(t,null,e),t(this._store.state,{},"initial"))}_action(t,e){if(this._store)return this._store.sendAction(t,e)}_query(t,e,s){if(!this._store)return;const a=this._store.sendQuery(t,e,t=>{"_isLoading"in this&&(this._isLoading=t.isLoading||!1),"_error"in this&&(this._error=t.error||null),s&&s(t)});return a?.then&&(this._queryRequests.add(a),a.finally(()=>{this._queryRequests.delete(a)})),a}__(...t){this._blockName||(this._blockName=this.classList[0]);const e=t.map(t=>`.${this._blockName}__${t}`).join(" ");return this.renderRoot.querySelector(e)}__all(...t){this._blockName||(this._blockName=this.classList[0]);const e=t.map(t=>`.${this._blockName}__${t}`).join(" ");return this.renderRoot.querySelectorAll(e)}_select(t){return this.renderRoot.querySelector(t)}_selectAll(t){return this.renderRoot.querySelectorAll(t)}_nlToParagraph(t){return t.split("\n").map(t=>bs`${t}
`)}}class ia extends aa{static properties={isLoading:{attribute:!1},error:{attribute:!1}};constructor(){super(),this.className="content-status-wrapper",this._blockName="content-status",this.isLoading=!1,this.error=null}render(){let t="";if(this.isLoading)t=this._html`
`;else if(this.error?.isOffline)t=this._html`
Offline - will load when connected
`;else if(this.error){const e=this.error.message||"An error occurred while loading.";t=this._html`
`}return t}}var na={};!function t(e,s,a,i){var n=!!(e.Worker&&e.Blob&&e.Promise&&e.OffscreenCanvas&&e.OffscreenCanvasRenderingContext2D&&e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype.transferControlToOffscreen&&e.URL&&e.URL.createObjectURL),o="function"==typeof Path2D&&"function"==typeof DOMMatrix,r=function(){if(!e.OffscreenCanvas)return!1;try{var t=new OffscreenCanvas(1,1),s=t.getContext("2d");s.fillRect(0,0,1,1);var a=t.transferToImageBitmap();s.createPattern(a,"no-repeat")}catch(t){return!1}return!0}();function l(){}function c(t){var a=s.exports.Promise,i=void 0!==a?a:e.Promise;return"function"==typeof i?new i(t):(t(l,l),null)}var d,h,u,p,m,_,g,f,b,v,y,w=(d=r,h=new Map,{transform:function(t){if(d)return t;if(h.has(t))return h.get(t);var e=new OffscreenCanvas(t.width,t.height);return e.getContext("2d").drawImage(t,0,0),h.set(t,e),e},clear:function(){h.clear()}}),$=(m=Math.floor(1e3/60),_={},g=0,"function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame?(u=function(t){var e=Math.random();return _[e]=requestAnimationFrame(function s(a){g===a||g+m-1
`}updated(t){this.setAttribute("aria-label",this.labels.modalWindow.dialogAria)}_handleFormChange(t){"radio"==t.target.type&&t.target.checked&&(this.querySelector(".content-form__submit-button").disabled=!1)}_handleFormSubmit(t){if(t.preventDefault(),!this.onSubmit)return;const e=t.target.querySelector("input[type=radio]:checked");if(!e)return;const s=e.parentElement.textContent.trim();this.context.chat.feedback({feedback:e.value,label:s,message:this.message});const[,a]=e.value.split(":");this.context.analytics.track({name:"message-feedback",params:{action:"thumbs down",reason:s||a,messageId:this.message.apiMessageId}}),this.onSubmit()}}}]);const ra={heading1:{stage:"block",pattern:/(?<=^|\n)[ \t]*(?<_hdn1_lvl>#{1,6}) (?<_hdn1_txt>\S.+?)(?=\n|$)/,matchGroup:"_hdn1_txt",token:t=>({type:"heading",props:{level:t._hdn1_lvl.length},text:t._hdn1_txt,contains:"phrasing"})},hrule:{stage:"block",pattern:/(?<=^|\n)[ \t]*(?<_hrle>---|___)[ \t]*(?=\n|$)/,matchGroup:"_hrle",token:()=>({type:"hrule"})},heading2:{stage:"block",pattern:/(?<=^|\n)[ \t]*(?<_hdn2_txt>\S[^\n]+?)\n[ \t]*(?<_hdn2_lne>[=-]{2,})(?=\n|$)/,matchGroup:"_hdn2_txt",token:t=>({type:"heading",props:{level:t._hdn2_lne.startsWith("=")?1:2},text:t._hdn2_txt,contains:"phrasing"})},list_item:{stage:"block",pattern:/(?<=^|\n)(?<_lst_ind>[ \t]*)(?<_lst_blt>[*-]|\d+\.) (?<_lst_txt>\S[^\n]*)(?=\n|$)/,matchGroup:"_lst_txt",token:t=>{const e={ordered:!1,bullet:t._lst_blt,indent:t._lst_ind.length};return"*"!==e.bullet&&"-"!==e.bullet&&(e.start=Number(e.bullet.substring(0,e.bullet.length-1)),e.ordered=!0),{type:"list_item",props:e,text:t._lst_txt,contains:"blocks"}},append:(t,e,s)=>"list_item"===e.type&&e.props.indent>t.props.indent||["block_quote","heading","hrule"].includes(e.type)?t.text+=`\n${s}`:"text_block"===e.type?t.text+=`\n${e.text}`:void 0,containerToken:t=>{const e={type:"list",props:{...t[0].props}};for(let s=0;s{if("white_space"===e.type&&1===e.props.lines&&"list_item"===s.type&&(e=s),"list_item"===e.type&&t.props.ordered===e.props.ordered)return t.props.ordered||t.props.bullet===e.props.bullet}},block_quote:{stage:"block",pattern:/(?<=^|\n)[ \t]*(?<_blqt_lvl>>+)(?: )?(?<_blqt_txt>(?:\S.*?)?)(?=\n|$)/,matchGroup:"_blqt_txt",token:t=>{const e={level:t._blqt_lvl.length};return{type:"block_quote",props:e,text:`${e.level>1?`${t._blqt_lvl.substring(1)} `:""}${t._blqt_txt}`,paragraphText:!0,contains:"blocks"}},append:(t,e,s)=>["block_quote","text_block"].includes(e.type)?t.text+=`\n${e.text}`:["list_item","heading","hrule"].includes(e.type)?t.text+=`\n${s}`:void 0},code_block:{stage:"block",pattern:/(?<=^|\n)[ \t]*[`]{3}(?<_cde_syn>\w*?)\n(?<_cde_txt>.+?)[`]{3}(?=\n|$)/,matchGroup:"_cde_txt",token:t=>({type:"code_block",props:{syntax:t._cde_syn||null},text:t._cde_txt,contains:"raw"})},text_block:{stage:"block",pattern:/(?<=^|\n)[ \t]*(?<_bltx_txt>\S.*?)(?=\n|$)/,matchGroup:"_bltx_txt",token:t=>({type:"text_block",text:t._bltx_txt.trim(),contains:"phrasing"}),append:(t,e)=>{if("text_block"===e.type)return t.text+=`\n${e.text}`}},white_space:{stage:"block",pattern:/(?:^|\n)(?<_whsp>[ \t\n]*)(?:\n|$)/,matchGroup:"_whsp",token:(t,e)=>{let s=e,a=0;for(let t=0;t[*_]{2}|~~)(?=\S)(?<_emi_txt>.+?)(?<=\S)(?)(?=[^*_]|$)/,matchGroup:"_emi_txt",token:t=>({type:"~~"===t._emi_tag?"strike_through":"bold",text:t._emi_txt,contains:"phrasing"})},emphasis_outer:{stage:"inline",pattern:/(?[*_]{1})(?=\S)(?<_emo_txt>.+)(?<=\S)(?)(?=[^*_]|$)/,matchGroup:"_emo_txt",token:t=>({type:"italic",text:t._emo_txt,contains:"phrasing"})},auto_link:{stage:"inline",pattern:/(?<_atln>(?({type:"link",props:{url:t._atln},text:t._atln,contains:"text"})},link:{stage:"inline",pattern:/<(?<_lnk_url>((https?:\/\/|[\/\w.\-+%?&]+@)[:@\/\w.\-+%?&;=#,~$*]+))>/,matchGroup:"_lnk_url",token:t=>({type:"link",props:{url:t._lnk_url.startsWith("http")?t._lnk_url:`mailto:${t._lnk_url}`},text:t._lnk_url,contains:"text"})},object:{stage:"inline",pattern:/((?<_obj_img>!)?\[(?<_obj_txt>.*?)\])?\((?<_obj_url>((https?:\/\/|mailto:)[:@\/\w.\-+%?&;=#,~$*]+))( "(?<_obj_tle>.*?)")?\)/,matchGroup:"_obj_url",token:t=>t._obj_img?{type:"image",props:{url:t._obj_url,alt:t._obj_txt,title:t._obj_tle}}:{type:"link",props:{url:t._obj_url,title:t._obj_tle},text:t._obj_txt,contains:"text"}},code:{stage:"inline",opaque:!0,pattern:/(?<_cde_tag>`{1,3})(?=[^\s`])(?<_cde_txt>.+?)(?<=[^\s`])(\k<_cde_tag>)/,matchGroup:"_cde_txt",token:t=>({type:"code",text:t._cde_txt,contains:"raw"})},line_break:{stage:"inline",pattern:/(?<_lnbr>\n| {2}\n| )/,matchGroup:"_lnbr",token:()=>({type:"line_break"})}},la=/\\([\\`*_{}[\]<>()#+-.!|~])/g,ca=t=>({type:"text",props:{value:t?-1===t.indexOf("\\")?t:t.replace(la,"$1"):""}}),da=t=>({type:"root",text:t,paragraphText:!0,contains:"blocks"});function ha(t,e,s=[]){for(const a in e)s.includes(a)||(t[a]=e[a])}function ua(t,e){const s=[],a=[],i=[],n=[];for(const o in t){const r=t[o];r.stage===e&&r.pattern&&(r.opaque?(i.push(r),n.push(r.pattern.source)):(s.push({matchGroup:r.matchGroup,token:r.token,append:r.append}),a.push(r.pattern.source)))}let o=null;return n.length&&(o=new RegExp(n.join("|"),"gs"),s.push({matchGroup:"_opq",token:()=>({type:"_opaque"})}),a.push("(?<_opq>\\x00)")),{schemaList:s,patterns:a,opaqueRegex:o,opaqueSchemas:i}}function pa(t,e=null){const{schemaList:s,patterns:a}=t,i=new RegExp(a.join("|"),"gs"),n=s.length;return t=>{const a=t.text,o=[];let r,l,c,d=0;for(;null!==(r=i.exec(a));){if(0===r[0].length){i.lastIndex=r.index+1;continue}const t=r.index;e&&d${t}
`;break;case"line_break":s+=" ";break;case"heading":{const e=`h${a.props.level}`;s+=`<${e}>${t}${e}>`}break;case"block_quote":e.pretty?s+=`\n${t} `:s+=`${t} `;break;case"code_block":s+=`${t} `;break;case"list":if(a.props.ordered){let i="";a.props.start>1&&(i+=` start="${a.props.start}"`),e.pretty?s+=`\n${t} `:s+=`${t} `}else e.pretty?s+=``:s+=``;break;case"list_item":s+=`${t} `;break;case"bold":s+=`${t} `;break;case"italic":s+=`${t} `;break;case"strike_through":s+=`${t}`;break;case"hrule":s+=" ";break;case"link":{let i="";a.props.title&&(i+=` title="${a.props.title}"`),e.linkTarget&&(i+=` target="${e.linkTarget}"`),s+=`${t} `}break;case"image":{let t="";a.props.alt&&(t+=` alt="${a.props.alt}"`),a.props.title&&(t+=` title="${a.props.title}"`),s+=` `}break;case"code":s+=`${t}`;break;case"text":s+=fa(a.props.value)}e.pretty&&ma.has(a.type)&&(s+="\n")}return s}function ga(t,e,s=0){if(!t)return"";let a="";for(const i of t){const t=i.children?ga(i.children,e,s+1):null;if(e.element?.[i.type]){const n=e.element[i.type](i.props,t,s);if(void 0!==n){a+=n;continue}}switch(i.type){case"paragraph":t&&(a+=`${t}\n\n`);break;case"line_break":a+="\n";break;case"heading":a+=`${t}\n\n`;break;case"block_quote":a+=`${t}`;break;case"code_block":a+=`${t.trim()}\n\n`;break;case"list":a+=0===s?`${t.replace(/{{list_item_start}}/g,"\n\n").trim()}\n\n`:t;break;case"list_item":{let e=i.props.bullet;"*"!==e&&"-"!==e||(e="•"),a+=`{{list_item_start}}${e} ${t.replace(/\n/g," ")}`}break;case"bold":case"italic":case"strike_through":case"code":a+=t;break;case"hrule":a+="---\n\n";break;case"link":t!==i.props.url?a+=`${t}: ${i.props.url}`:a+=i.props.url;break;case"text":a+=i.props.value}}return 0===s?a.trim():a}function fa(t){let e=!1;for(let s=0;s"===a){e=!0;break}}if(!e)return t;let s="";for(let e=0;e"===a?">":a}return s}const ba={create:function(t={}){const e=function(t){const e={},s=[];t.autoLink||s.push("auto_link");ha(e,ra,s),ha(e,t.schemas);const a=pa(ua(e,"block")),i=ua(e,"inline"),n=pa(i,ca),{opaqueRegex:o,opaqueSchemas:r}=i;function l(t){return"blocks"===t.contains?{type:t.type,props:t.props,children:h(t,a(t))}:("phrasing"===t.contains&&o&&function(t,e,s){const a=[];e.lastIndex=0,t.text=t.text.replace(e,(t,...e)=>{const i=e[e.length-1];for(const e of s)if(void 0!==i[e.matchGroup])return a.push(e.token(i,t)),"\0";return t}),a.length&&(t.opaqueQueue=a)}(t,o,r),c(t,t.opaqueQueue))}function c(t,e){const s={type:t.type,props:t.props};return"phrasing"===t.contains?s.children=u(n(t),e):"raw"===t.contains?s.children=[{type:"text",props:{value:t.text||""}}]:"text"===t.contains&&(s.children=[ca(t.text)]),s}function d(t,e){const s=t.containerToken(e),a={type:s.type,props:s.props,children:[]};for(const t of e)t.paragraphText=s.paragraphText,a.children.push(l(t));return a}function h(t,s){const a=[],i=s.length;let n;const o=[];for(let r=0;rt?l(da(t)).children:""}}(t);return{parse:(t,s)=>{const a=e.parse(t);return s?s(a):a}}},html:function(t={}){return e=>_a(e,t)},plain:function(t={}){return e=>ga(e,t)}},va='\n \n \n \n ';function ya(t,e){if(!e||!t)return!1;try{return new URL(t).hostname===e}catch{return!1}}function wa(t,e,s={}){const{alt:a="",className:i="",usePicture:n=!1}=s,o=ya(t,e);if(n)return o?` `:` `;return`
`}function $a(t,e,s){let a="";try{const t=JSON.parse(e);switch(t.type){case"business-card":case"hotel-card":case"tour-card":case"car-rental-card":case"venue-card":a=Sa(t.type,t.template,s);break;case"article-card":case"event-card":a=function(t,e,s={}){let a=null;e.imageUrl?a=e.imageUrl:e.images?.length&&(a=e.images[0]);const i=a?wa(a,s.imgCdnDomain,{alt:"Card image",className:"gg-wide-card__image"}):"",n=[];e.dateLabel&&n.push(`${e.dateLabel}
`);e.priceValue&&n.push(`${e.priceValue}
`);return`\n\n`.trim()}(t.type,t.template);break;case"flight-card":a=function(t,e){const s=e.legs&&e.legs[0],a=s?.segments&&s.segments[0],i=s?.segments&&s.segments[s.segments.length-1],n={"data-type":t,"data-id":e.id||"","data-title":String(e.title||"").replace(/"/g,"""),"data-flight-from":a?.originAirport||"","data-flight-to":i?.destinationAirport||"","data-flight-from-city":a?.originLocation||"","data-flight-to-city":i?.destinationLocation||"","data-flight-date":a?.departureDateShort||"","data-flight-airline":a?.carrierName||"","data-flight-departure-time":a?.departureTime||"","data-flight-arrival-time":i?.arrivalTime||"","data-flight-is-direct":1===s?.segments?.length?"true":"false","data-flight-stops":s?.numStops||"0","data-flight-price":e.priceValue||"","data-flight-qualifier":e.qualifier||""};return`\n`${t}="${e}"`).join(" ")} aria-live="off">\n\t
\n\t\t${e.legs.map(Ma).join("")}\n\t\t
\n\t\t\t
\n\t\t\t\t
${e.priceValue}
\n\t\t\t\t
${o=e.priceLabel,o&&"string"==typeof o?o.replace(/^\w+/,t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()):o}
\n\t\t\t
\n\t\t\t
${e.bookLabel} \n\t\t
\n\t
\n
\n`.trim();var o}(t.type,t.template);break;case"ferry-card":a=function(t,e){const s=e.companyIconUrl?``:Ia,a=e.accommodation?`${e.accommodation}
`:"",i=e.vessel?`${e.vessel} • `:"";return`\n\n\t
\n\t\t\n\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
${e.departureTime}
\n\t\t\t\t\t
\n\t\t\t\t\t
${e.arrivalTime}
\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
${e.departurePort}
\n\t\t\t\t\t
${e.arrivalPort}
\n\t\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t\t${i}${e.operator} • ${e.duration}\n\t\t\t
\n\t\t\t${a}\n\t\t
\n\t\t
\n\t
\n
\n`.trim()}(t.type,t.template);break;case"inline":a=function(t,e){const s="hotel"===e.businessType?"lodging":e.businessType,a=` `;return`\n\n\t${a} \n\t${e.title} \n \n`.trim()}(t.type,t.template)}}catch(t){console.error("Code block failed to parse JSON",t)}return a}function ka(t,e,s){const a={id:e.id,place:e.place,hasPlace:!(!e.entityId&&!e.place),title:e.title,images:e.images,rating:e.rating};if(e.imageUrl&&(a.images=[e.imageUrl]),a.images||(a.images=[]),"business-card"==t){if(a.category=e.businessType,a.categoryLabel=[e.businessTypeLabel,ee(e.priceLevel)].filter(Boolean).join(" "),"CLOSED_PERMANENTLY"===e.businessStatus)a.status={isOpen:!1,nowLabel:s.labels.closedPermanently||"Permanently Closed",changeLabel:""};else if("CLOSED_TEMPORARILY"===e.businessStatus)a.status={isOpen:!1,nowLabel:s.labels.closedTemporarily||"Temporarily Closed",changeLabel:""};else if(e.hours?.length&&e.timeZone){const t=te(e.hours,e.timeZone);let i=null,n=null;t.isOpen?(i=s.labels.openNow,n=s.labels.openChange):(i=s.labels.closedNow,n=s.labels.closedChange),i&&n&&(n=t.changeDate?n.replace("{{date}}",t.changeDate.format("h:mm A")):"",a.status={isOpen:t.isOpen,nowLabel:i,changeLabel:n})}}else"hotel-card"==t?(a.category="lodging",a.categoryLabel=e.roomName):"car-rental-card"==t?(a.category="automotive",a.categoryLabel=e.agency):"tour-card"==t?(a.category="tour",a.categoryLabel=e.duration):"venue-card"==t&&(a.category="venue",a.categoryLabel=e.capacity||e.venueType||"");return"book"==s.cardActionButton?e.bookUrl?(a.actionUrl=e.bookUrl,e.priceValue?a.actionLabel=`${s.labels.bookLabel} ${e.priceValue}`:a.actionLabel=s.labels.bookLabel):e.webUrl&&(a.actionUrl=e.webUrl,a.actionLabel=s.labels.website):"more"==s.cardActionButton&&(a.actionLabel=s.labels.actionLabel),a}function Sa(t,e,s){const a=ka(t,e,s);let i="";return a.actionLabel&&(i=a.actionUrl?`${a.actionLabel} `:`${a.actionLabel}
`),`\n\n\t
\n\t\t${a.images.map(t=>wa(t,s.imgCdnDomain,{alt:a.title,className:"gg-wide-neo-card__image"})).join("")}\n\t
\n\t
\n\t\t\n\t\t${Ta(a)}\n\t\t
${i}
\n\t
\n
\n`.trim()}function Ta(t){let e="gg-wide-neo-card__category";t.category&&(e+=` gg-wide-neo-card__category--${t.category}`);const s=[`\n\t\t\n\t`];if(t.status){let e="gg-wide-neo-card__status-now";t.status.isOpen&&(e+=" gg-wide-neo-card__status-now--open");const a=t.status.changeLabel?`${t.status.changeLabel}
`:"";s.push(`\n\t\t\t\n\t\t`)}return`\n\n\t${s.join("")}\n
\n`.trim()}function Ca(t,e){if(!e.cardFavoriteButton||!t.hasPlace)return"";let s=e.isFavorited;e.getCardFavorited&&(s=e.getCardFavorited(t.id));let a="gg-wide-neo-card__favorite-button";return s&&(a+=" gg-wide-neo-card__favorite-button--active"),`
`}function Ma(t){const e=1==t.segments.length,s=t.segments[0],a=t.segments[t.segments.length-1],i=La(s.carrierImageUrl,e),n=t.segments.map(t=>t.originAirport);n.push(a.destinationAirport),n.length>4&&n.splice(2,n.length-3,"…");let o="gg-flight-card__leg";e||(o+=" gg-flight-card__leg--indirect");return`\n\n\t\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\t
${s.departureTime}
\n\t\t\t\t
\n\n\t\t\t\t
${a.arrivalTime} ${t.numDays?" +"+t.numDays:""}
\n\t\t\t
\n\t\t\t
\n\t\t\t\t
${s.originLocation}
\n\t\t\t\t
${a.destinationLocation}
\n\t\t\t
\n\t\t
\n
\n ${s.carrierName} • ${t.cabinClass} • ${e?"Non-stop":`${t.numStops} `} • ${t.duration}\n
\n\n\t
\n\t${e?"":(r=t.segments,`
${r.map(xa).join("")}
`)}\n
\n`.trim();var r}function xa(t){let e="";return t.layover&&(e=`\n ${t.layover} Connect in airport \n
`),`\n\n\t
\n
\n\t${t.carrierName}\n\t
\n\t
\n\t\t
\n\t\t
\n\t\t\t
${t.departureTime} (${t.originAirport}) ${t.originLocation}
\n\t\t\t
${t.duration}
\n\t\t\t
${t.arrivalTime} (${t.destinationAirport}) ${t.destinationLocation}
\n\t\t
\n\t
\n\t${e}\n
\n`.trim()}const Ia='\n \n \n ';function Aa(t){t&&(t.onerror=null,t.outerHTML=Ia)}function La(t,e){return e?t||"data:image/svg+xml;charset=UTF-8,"+encodeURIComponent(va):"https://cdn1.matadornetwork.com/gg-assets/images/carrier-logo.png"}function Oa(t){return t?t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">"):""}function Ea(t){t&&(t.onerror=null,t.outerHTML=va)}function Da(t,e,s,a={}){const{alt:i="",className:n="",onClick:o}=a,r=ya(e,s)?`background-image: url('${e}?format=jpg'); background-image: image-set(url('${e}') type('image/webp'), url('${e}?format=jpg') type('image/jpeg'));`:`background-image: url('${e}');`;return o?t`
`:t`
`}"undefined"!=typeof window?window.ferryLogoFallback=Aa:"undefined"!=typeof global&&(global.ferryLogoFallback=Aa),"undefined"!=typeof window?window.carrierFallback=Ea:"undefined"!=typeof global&&(global.carrierFallback=Ea);const Pa=["gg-wide-neo-card__action-button","gg-tall-neo-card__action-button"],Ua=new Set(["flight-card","car-rental-card","ferry-card","directions-card"]);function Ha(t){return{id:t.dataset.id,type:t.dataset.type,title:t.dataset.title,place:t.dataset.place||null}}const Na=new Set(["directions-card"]);function Fa(t,e){if(t.__isSetup)return;if(Na.has(t.dataset.type))return void(t.__isSetup=!0);let s=null;e.onHoverIn&&!Ft()&&t.addEventListener("mouseenter",()=>{clearTimeout(s),s=setTimeout(()=>{e.onHoverIn(Ha(t))},300)}),e.onHoverOut&&!Ft()&&t.addEventListener("mouseleave",()=>{clearTimeout(s),s=setTimeout(()=>{e.onHoverOut(Ha(t))},300)}),t.addEventListener("click",s=>{if(s.target.classList.contains("gg-wide-neo-card__favorite-button")){s.preventDefault(),s.stopImmediatePropagation();const a=Ha(t);if(!a.place)return;return void(e.onFavoriteClick&&e.onFavoriteClick(a))}if(function(t){return Pa.some(e=>t.classList.contains(e))&&"A"===t.tagName}(s.target))return;const a=Ha(t);Ua.has(a.type)||a.place&&e.onClick&&(s.preventDefault(),s.stopImmediatePropagation(),e.onClick(a,s))}),t.__isSetup=!0}function Wa(t,e){const s=t.querySelectorAll(".gg-inline, .gg-wide-neo-card, .gg-tall-neo-card, .gg-flight-card, .gg-ferry-card, .gg-directions-card");for(const t of s)Fa(t,e)}function Ba(t,e={}){return{onHoverIn(e){t._action("map.highlight",{groupId:`card:${e.id}`,cardMode:"pin-stick",fitFocus:"cluster"})},onHoverOut(e){t._action("map.unselect")},onClick(s){Ua.has(s.type)||(Ft()||t._action("map.highlight",{groupId:`card:${s.id}`,cardMode:"pin-stick",fitFocus:"cluster"}),t._action("layout.update",{isMapOpen:!Ft(),isPlaceOpen:{cardGroupId:`card:${s.id}`}}),t.context.analytics.track({name:"link-clicked",params:{card_type:s.type,card_id:s.id,title:s.title||s.id,url:"",button_text:"",messageId:e.messageId}}),t.context.analytics.track({name:"card-map-clicked",params:{card_type:s.type||"unknown",title:s.title||"unknown",messageId:e.messageId}}))},onFavoriteClick(e){e.place&&t._query("favorites.toggle",{cardId:e.id})}}}const Ra=ba.create({autoLink:!0});Bs([{name:"gg-message-actions",component:class extends aa{static properties={message:{attribute:!1},onMapButtonClick:{attribute:!1}};render(){return this._html`
${this._feedbackButtonsTemplate()}
${this._mapButtonTemplate()}
`}_getFeedbackValue(t){return"string"!=typeof t?null:"positive"==t?"positive":t.startsWith("negative:")?"negative":void 0}_feedbackButtonsTemplate(){if(!this.theme.withUserFeedback||this.message.hideUserFeedback||!this.message.apiMessageId)return;const t=this._getFeedbackValue(this.message.feedback);let e="context-button context-button--thumbs-up",s="context-button context-button--thumbs-down",a=!1,i=!1;return"positive"==t?(e+=" context-button--active",i=!0):"negative"==t&&(s+=" context-button--active",a=!0),this._html`
`}_handleThumbsUpClick(t){const e=this._getFeedbackValue(this.message.feedback);if("negative"==e)return;const s=e?null:"positive",a=t.target.getBoundingClientRect();"positive"===s&&oa({particleCount:25,zIndex:this.theme.zIndex,spread:50,ticks:80,startVelocity:15,origin:{x:(a.left+a.width/2)/window.innerWidth,y:(a.top+a.height/2)/window.innerHeight}}),this.context.chat.feedback({feedback:s,message:this.message});const i="positive"===s?"thumbs up:selected":"thumbs up:unselected";this.context.analytics.track({name:"message-feedback",params:{action:i,messageId:this.message.apiMessageId||null}})}_handleThumbsDownClick(){this._getFeedbackValue(this.message.feedback)||this.context._openModal("gg-feedback-modal",{attributes:{message:this.message}})}_mapButtonTemplate(){if(this.theme.withMap&&this.message.mapGroupId)return this._html`
`}}},{name:"gg-carousel-message",component:class extends aa{static properties={cards:{attribute:!1},onCardHoverIn:{attribute:!1},onCardHoverOut:{attribute:!1},onCardClick:{attribute:!1}};_curCardIndex=0;_touchStartX=null;_touchStartY=null;_swipeDir=null;_numCardsInView=3;_hoverTimeout=null;constructor(){super(),this.className="carousel-message"}render(){return this._html`
${this.cards.map(this._cardTemplate.bind(this))}
this._offsetScroll(-1)}">
this._offsetScroll(1)}">
`}_cardTemplate(t){const e=t.template?.images?.[0],s=t.template?.title||"";return this._html`
${e?this._html`
`:""}
${s?this._html`
${s}
`:""}
`}updated(t){this._curCardIndex=0,this._offsetScroll(0)}_handleSlideListTouchStart(t){this._touchStartX=t.touches[0].clientX,this._touchStartY=t.touches[0].clientY,this._swipeDir=null}_handleSlideListTouchMove(t){if(this._swipeDir)return;const e=t.touches[0].clientX-this._touchStartX,s=t.touches[0].clientY-this._touchStartY;Math.abs(e)>Math.abs(s)?(t.preventDefault(),this._swipeDir="x"):Math.abs(s)>Math.abs(e)&&(this._swipeDir="y")}_handleSlideListTouchEnd(t){if("x"!=this._swipeDir)return;const e=t.changedTouches[0].clientX-this._touchStartX;Math.abs(e)>5&&this._offsetScroll(e>0?-1:1)}_scrollTo(t){const e=this.__("card-list"),s=e.children.length-1,a=Math.min(s,Math.max(0,t));if(a!=this._curCardIndex){const t=e.children[a];e.scrollTo({left:t.offsetLeft,behavior:"smooth"}),this._curCardIndex=a}this.__("prev").disabled=this._curCardIndex<=0,this.__("next").disabled=this._curCardIndex>=s-(this._numCardsInView-1)}_offsetScroll(t){this._scrollTo(this._curCardIndex+t)}_handleCardHoverIn(t){this.onCardHoverIn&&(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{this.onCardHoverIn(t)},300))}_handleCardHoverOut(t){this.onCardHoverOut&&(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{this.onCardHoverOut(t)},300))}}}]);const qa="gg-chat-scroll-position";Bs([{name:"gg-chat-message",component:class extends aa{static properties={message:{attribute:!1},cards:{attribute:!1},isAnswerTyping:{attribute:!1},answerStatus:{attribute:!1}};_contentMessage=null;constructor(){super(),this.className="chat-message"}render(){let t="";const e=this.message.content.body;if(!("agent"===this.message.from&&"text"===this.message.content.type&&this.message.isStreaming&&!e))switch(this.message.content.type){case"text":case"icebreaker":case"reply":{const e=[];if(this.message.cardIds)for(const t of this.message.cardIds){const s=this.cards?.[t];s&&e.push(s)}t=this._html` `;break}}let s="";this.message.content.replies?.length&&!this.message.isStreaming&&(s=this._html`
${this.message.content.replies.map((t,e)=>this._html`
${t.title}
`)}
`);let a="";if(this.isAnswerTyping){let t="chat-message__answer-status",e=null;this.answerStatus?e=this.answerStatus:(t+=" chat-message__answer-status--hidden",e=this.labels.chatMessageList.typingStatus),a=this._html`
`}return this._html`
${t}
${s}
${a}
`}updated(t){this.classList.add(`chat-message--${this.message.from}`),this.classList.add(`chat-message--${this.message.content.type}`),this.classList.remove("chat-message--queued","chat-message--sending","chat-message--sent","chat-message--failed","chat-message--read","chat-message--received"),this.message.status&&this.classList.add(`chat-message--${this.message.status}`)}_handleReplyButtonClick(t,e){this.context.chat.replyMessage({messageId:this.message.id,apiMessageId:this.message.apiMessageId,replyIndex:t,title:e.title,payload:e.payload}),this.context.analytics.track({name:"quick-reply-clicked",params:{title:e.title,messageId:this.message.apiMessageId||null}})}}},{name:"gg-text-message",component:class extends aa{static properties={message:{attribute:!1},cards:{attribute:!1}};constructor(){super(),this.className="text-message",this.classList.toggle("text-message--markdown",t.markdown),this._cardHandlers=null}willUpdate(t){super.willUpdate(t),!this._cardHandlers&&this.theme.withMap&&(this._cardHandlers=Ba(this,{messageId:this.message.id})),this.message?.isStreaming&&(this._cachedImages=new Map,this.querySelectorAll("img").forEach(t=>{t.complete&&this._cachedImages.set(t.src,t)}))}render(){let e="",s="",a="",i="",n="";if(this.message.content)if(this._isAiMessage()){if(e=t.markdown?this._unsafeHTML(Ra.parse(this.message.content.body,function(t={}){const e=t.imgCdnDomain;return t.cardActionButton||(t.cardActionButton="book"),ba.html({linkTarget:"_blank",element:{image:(t,s)=>wa(t.url,e,{alt:t.alt||"",className:"markdown-image",usePicture:!0}),link:(t,e)=>{if("c:btn"==t.title)return`${e} `},code:(e,s)=>$a(0,s,t),code_block:(e,s)=>$a(0,s,t)}})}({labels:this.labels.placeWindow,imgCdnDomain:this.theme.imgCdnDomain,cardFavoriteButton:this.theme.withFavorites,getCardFavorited:t=>{const e=this.cards?.find(e=>e.template.id===t);return e?.isFavorited}}))):this._unsafeHTML(Ra.parse(this.message.content.body,ba.encode({linkTarget:"_blank"}))),!this.message.isStreaming)if(this.message.stoppedByUser)n=this._html`
⏹
Response stopped
`;else{const t=this.cards?.filter(t=>t.template?.images?.length&&!Ua.has(t.type));t?.length&&this.theme.placeCarouselEnabled&&(s=this._html`
this._cardHandlers.onHoverIn({id:t}):null}
.onCardHoverOut=${this._cardHandlers?t=>this._cardHandlers.onHoverOut({id:t}):null}
.onCardClick=${this._cardHandlers?t=>this._cardHandlers.onClick({id:t,type:"carousel",title:""}):null}/>`),this._hasDirectionsCard()&&(a=this._html`
View Route Map
`),i=this._html`
`}}else e="reply"==this.message.content.type?this.message.content.title:this.message.content.body;return this._html`
${e}
${n}
${s}
${a}
${i}
`}updated(t){this._cachedImages?.size&&(this.querySelectorAll("img").forEach(t=>{const e=this._cachedImages.get(t.src);e&&t.replaceWith(e)}),this._cachedImages=null),this._cardHandlers&&this._isAiMessage()&&Wa(this.__("content"),this._cardHandlers)}_isAiMessage(){return"agent"==this.message.from}_handleContentClick(t){"A"==t.target.tagName&&this.context.analytics.track({name:"link-clicked",params:{card_type:"text-link",card_id:"text-link",title:t.target.textContent.trim(),url:t.target.href,button_text:t.target.textContent.trim(),messageId:this.message.apiMessageId}})}_hasDirectionsCard(){return this.theme.withMap&&this.cards?.some(t=>"directions-card"===t.type)}_handleViewRouteClick(){const t=this.cards?.find(t=>"directions-card"===t.type);t&&(this._action("map.select",{groupId:`card:${t.template.id}`,showCard:Ft()?"slider":null,fitFocus:"points"}),this._action("layout.update",{isMapOpen:!0,isPlaceOpen:!1}))}_handleActionMapClick(){this._action("map.select",{groupId:this.message.mapGroupId,showCard:Ft()?"slider":null,fitFocus:"points"}),this._action("layout.update",{isMapOpen:!0,isPlaceOpen:!1})}}}]);Bs([{name:"gg-content-status",component:ia},{name:"gg-chat-message-list",component:class extends aa{static properties={isWindowOpen:{attribute:!1},isMapOpen:{attribute:!1},answerPhase:{attribute:!1},answerStatus:{attribute:!1},messages:{attribute:!1},cards:{attribute:!1},onScrollUp:{attribute:!1},onScrollDown:{attribute:!1},onScrollBottom:{attribute:!1}};_prevScrollTop=0;_scrollChangeTimeout=null;_scrollToBottomTimeout=null;_isUserScrollControlled=!1;_saveScrollTimeout=null;_scrollToTopTimeout=null;_currentMinHeightMessageId=null;constructor(){super(),this.className="chat-message-list",this.setAttribute("role","log"),this.setAttribute("aria-atomic","false"),this.setAttribute("aria-relevant","additions"),this.setAttribute("tabindex","-1"),this._updateScrollBottom=this._updateScrollBottom.bind(this),this._createMessageTemplate=this._createMessageTemplate.bind(this),this.addEventListener("scroll",this._handleScroll.bind(this),{passive:!0}),this.addEventListener("wheel",this._handleWheelOrTouchMove.bind(this),{passive:!0}),this.addEventListener("touchmove",this._handleWheelOrTouchMove.bind(this),{passive:!0}),this.addEventListener("keydown",this._handleKeydown.bind(this))}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._updateScrollBottom)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._updateScrollBottom),clearTimeout(this._scrollToBottomTimeout),clearTimeout(this._saveScrollTimeout),clearTimeout(this._scrollToTopTimeout)}render(){return this._html`
${this._repeat(this.messages,t=>t.id,this._createMessageTemplate)}
`}updated(t){if(t.has("isWindowOpen")&&this.isWindowOpen&&(this._getSavedScrollPosition()?this._restoreScrollPosition():this.scrollToBottom()),t.has("answerPhase")&&"streaming"===this.answerPhase){const t=this.scrollTop;requestAnimationFrame(()=>{Math.abs(this.scrollTop-t)>1&&(this.scrollTop=t),this.resumeBottomSentinelObserver&&this.resumeBottomSentinelObserver()})}if(t.has("messages")){const e=t.get("messages")||[],s=new Set(e.map(t=>t.id));for(const t of this.messages)s.has(t.id)||"agent"==t.from&&"read"!=t.status&&this.context.chat.readMessage(t.id,t.apiMessageId);if(0===e.length&&this.messages.length>0)this._clearSavedScrollPosition(),this.scrollToBottom();else{const t=this.messages[this.messages.length-1];t&&!s.has(t.id)&&this._handleNewMessage(t,e)}}}_createMessageTemplate(t,e){const s=e==this.messages.length-1;return this._html`
`}_handleNewMessage(t,e){this._isUserScrollControlled=!1,clearTimeout(this._scrollToTopTimeout),this.pauseBottomSentinelObserver&&this.pauseBottomSentinelObserver(),requestAnimationFrame(()=>{const e=this._getMessageElement(t.id);e&&("user"===t.from?(this._removeMinHeightFromAll(),this._handleNewUserMessage(e)):"agent"===t.from&&this._handleNewAgentMessage(e))})}_handleNewUserMessage(t){const e=t.querySelector(".chat-message__content");if(!e)return;const s=this.clientHeight,a=getComputedStyle(this),i=parseInt(a.paddingTop)||0,n=parseInt(a.paddingBottom)||0,o=e.offsetHeight,r=t.offsetTop,l=s-i-n;this._applyMinHeight(t,l);r>=this.scrollTop&&r+o<=this.scrollTop+s||this._scrollToShowContent(t,o),this._scrollToTopTimeout=setTimeout(()=>{this._animateScrollToShowMessageAtTop(t)},500)}_handleNewAgentMessage(t){const e=this.clientHeight,s=getComputedStyle(this),a=e-(parseInt(s.paddingTop)||0)-(parseInt(s.paddingBottom)||0),i=Array.from(this.querySelectorAll("gg-chat-message")),n=i.indexOf(t),o=n>0?i[n-1]:null;if(1===i.length)return;let r=a;const l=this.scrollTop;if(o?.classList.contains("chat-message--min-height")){const e=o.querySelector(".chat-message__content"),s=e?e.offsetHeight:0,i=getComputedStyle(o);r=a-(s+(parseInt(i.paddingTop)||0)+(parseInt(i.paddingBottom)||0)),r>0&&this._applyMinHeight(t,r),o.classList.remove("chat-message--min-height"),o.style.minHeight=""}else this._removeMinHeightFromAll(),r>0&&this._applyMinHeight(t,r);this.scrollTop=l,setTimeout(()=>{this.resumeBottomSentinelObserver&&this.resumeBottomSentinelObserver()},100)}_applyMinHeight(t,e){this._currentMinHeightMessageId=t.message?.id,t.classList.add("chat-message--min-height"),t.style.minHeight=e-1+"px"}_removeMinHeightFromAll(){this.querySelectorAll("gg-chat-message.chat-message--min-height").forEach(t=>{t.classList.remove("chat-message--min-height"),t.style.minHeight=""}),this._currentMinHeightMessageId=null}_getMessageElement(t){const e=this.querySelectorAll("gg-chat-message");for(const s of e)if(s.message?.id===t)return s;return null}_scrollToShowContent(t,e){const s=t.offsetTop-this.clientHeight+e+16;this.scrollTop=Math.max(0,s)}_animateScrollToShowMessageAtTop(t){const e=t.offsetTop,s=Math.max(0,e-16),a=this.scrollTop,i=s-a,n=performance.now(),o=t=>{const e=t-n,s=Math.min(e/300,1),r=1-Math.pow(1-s,3);this.scrollTop=a+i*r,s<1?requestAnimationFrame(o):(this._clearSavedScrollPosition(),this.resumeBottomSentinelObserver&&!this._currentMinHeightMessageId&&this.resumeBottomSentinelObserver())};requestAnimationFrame(o)}scrollToBottom(){clearTimeout(this._scrollToBottomTimeout),this._scrollToBottomTimeout=setTimeout(()=>{this.scrollTop=this.scrollHeight,this._clearSavedScrollPosition()},16)}_handleScroll(t){this._scrollChangeTimeout||(this._scrollChangeTimeout=setTimeout(()=>{const t=this.scrollHeight-this.clientHeight;let e=this.scrollTop;if(e<0?e=0:e>t&&(e=t),this._saveScrollPosition(),!this.isMapOpen){const t=e-this._prevScrollTop;Math.abs(t)>16&&(t<0?this.onScrollUp():this.onScrollDown())}this._updateScrollBottom(),this._prevScrollTop=e,this._scrollChangeTimeout=null},150))}_handleWheelOrTouchMove(){this._isUserScrollControlled=!0}_handleKeydown(t){"ArrowUp"!==t.key&&"ArrowDown"!==t.key&&"PageUp"!==t.key&&"PageDown"!==t.key&&"Home"!==t.key&&"End"!==t.key||(this._isUserScrollControlled=!0)}_updateScrollBottom(){let t=this.scrollHeight-64<=this.clientHeight;t||(t=this.scrollTop+this.clientHeight>=this.scrollHeight-64),t&&(this._isUserScrollControlled=!1),this.onScrollBottom&&this.onScrollBottom(t)}_saveScrollPosition(){clearTimeout(this._saveScrollTimeout),this._saveScrollTimeout=setTimeout(()=>{try{const t={scrollTop:this.scrollTop,scrollHeight:this.scrollHeight,timestamp:Date.now()};localStorage.setItem("gg-chat-scroll-position",JSON.stringify(t))}catch(t){console.warn("Failed to save scroll position:",t)}},500)}_getSavedScrollPosition(){try{const t=localStorage.getItem(qa);if(t){const e=JSON.parse(t);if(Date.now()-e.timestamp<36e5)return e}}catch(t){console.warn("Failed to get saved scroll position:",t)}return null}_restoreScrollPosition(){const t=this._getSavedScrollPosition();t&&setTimeout(()=>{const e=Math.abs(this.scrollHeight-t.scrollHeight),s=.3*t.scrollHeight,a=t.scrollTop<=this.scrollHeight;(e<=s||a)&&t.scrollTop>0?this.scrollTop=Math.min(t.scrollTop,this.scrollHeight-this.clientHeight):this.scrollToBottom()},50)}_clearSavedScrollPosition(){try{localStorage.removeItem(qa)}catch(t){console.warn("Failed to clear saved scroll position:",t)}}}},{name:"gg-map-button",component:class extends aa{static properties={count:{attribute:!1}};constructor(){super(),this.className="map-button",this.count=0}render(){return this._html`
${this.labels.chatConversation.mapButtonText}${this.count?this._html` ${this.count} `:""}
`}_handleClick(){this._action("layout.update",{isMapOpen:!0,isPlaceOpen:!1})}hide(){this.classList.add("map-button--hidden")}show(){this.classList.remove("map-button--hidden")}}}]);class za extends aa{constructor(){super(),this.className="chat-button"}render(){return this._html`
${this.labels.mapWindow.chatButton}
`}_handleClick(){this._action("layout.update",{primaryTab:"chat",isMapOpen:!1})}hide(){this.classList.add("chat-button--hidden")}show(){this.classList.remove("chat-button--hidden")}}class ja extends HTMLElement{_prevScrollTop=0;_scrollTimeout=null;onScrollUp=null;onScrollDown=null;constructor(){super(),this.addEventListener("scroll",this._handleScroll.bind(this),{passive:!0})}disconnectedCallback(){clearTimeout(this._scrollTimeout),this._scrollTimeout=null}_handleScroll(){this._scrollTimeout||(this._scrollTimeout=setTimeout(()=>{let t=this.scrollTop;const e=this.scrollHeight-this.clientHeight;t<0?t=0:t>e&&(t=e);const s=t-this._prevScrollTop;Math.abs(s)>16&&(s<0&&this.onScrollUp?this.onScrollUp():s>0&&this.onScrollDown&&this.onScrollDown()),this._prevScrollTop=t,this._scrollTimeout=null},150))}}const Ga=["region","hotel","restaurant","business","tour","car-rental"];Bs([{name:"gg-content-status",component:ia},{name:"gg-favorite-filter-modal",component:class extends aa{static properties={locations:{attribute:!1},selectedLocations:{attribute:!1},onClose:{attribute:!1},onSubmit:{attribute:!1},_formData:{state:!0}};connectedCallback(){super.connectedCallback(),this.className="modal-dialog modal-dialog--open",this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this._handleRootClick=this._handleRootClick.bind(this),this.addEventListener("click",this._handleRootClick),this._formData={locations:this.selectedLocations||[]}}render(){return this._html`
`}_formInnerTemplate(){return this._html`
${this.locations.map(t=>this._html`
${t.name}
`)}
${this.labels.modalWindow.resetButton}
${this.labels.modalWindow.updateButton}
`}_handleRootClick(t){if(t.target==this)return this.onSubmit?void this.onSubmit(this._formData):this.onClose()}_handleResetClick(){this._formData={locations:[]}}_handleFormChange(t){const e=new FormData(t.target.form);this._formData={locations:e.getAll("locations")}}_handleFormSubmit(t){t.preventDefault(),this.onSubmit&&this.onSubmit(this._formData)}}},{name:"gg-chat-button",component:za},{name:"gg-scroll-container",component:ja}]);Bs([{name:"gg-chat-window",component:class extends aa{static properties={_isLoading:{state:!0},_error:{state:!0},_isWindowOpen:{state:!0},_isMapOpen:{state:!0},_answerPhase:{state:!0},_answerStatus:{state:!0},_messages:{state:!0},_cards:{state:!0},_numMapLocations:{state:!0},_maxMessageLen:{state:!0},_socketStatus:{state:!0},_networkFailure:{state:!0},_showConnectionNotice:{state:!0},_inputError:{state:!0},_conversationId:{state:!0},_conversationTitle:{state:!0}};_minTextInputHeight=0;_maxTextInputHeight=0;_typingStatusTimeout=null;_connectionNoticeTimeout=null;_bottomSentinelObserver=null;_bottomSentinelPaused=!1;_pendingComposeBody=void 0;constructor(){super(),this.className="chat-window",this._isLoading=!0,this._error=null,this._isWindowOpen=!1,this._isMapOpen=!1,this._answerPhase=null,this._answerStatus=null,this._messages=[],this._cards={},this._numMapLocations=0,this._maxMessageLen=0,this._socketStatus="closed",this._networkFailure=!1,this._showConnectionNotice=!1,this._inputError=null,this._conversationId=null,this._conversationTitle=null,this._handleScrollUp=this._handleScrollUp.bind(this),this._handleScrollDown=this._handleScrollDown.bind(this)}connectedCallback(){super.connectedCallback(),this._setupBottomSentinelObserver(),this._observe(t=>{this._isMapOpen=t.layout.isMapOpen},["layout.isMapOpen"]),this._observe(t=>{this._isWindowOpen=t.layout.isWindowOpen,t.layout.isWindowOpen&&this._focusTextInput()},["layout.isWindowOpen"]),this._observe(t=>{this._socketStatus=t.api.socketStatus,this._networkFailure=t.api.networkFailure||!1,t.api.networkFailure?(this._showConnectionNotice=!0,clearTimeout(this._connectionNoticeTimeout),this._connectionNoticeTimeout=null):"opened"===t.api.socketStatus?(this._showConnectionNotice=!1,clearTimeout(this._connectionNoticeTimeout),this._connectionNoticeTimeout=null):"error"!==t.api.socketStatus&&"opening"!==t.api.socketStatus||this._connectionNoticeTimeout||(this._connectionNoticeTimeout=setTimeout(()=>{"error"!==this._socketStatus&&"opening"!==this._socketStatus||(this._showConnectionNotice=!0)},15e3))},["api"]),this._observe(t=>{this._answerPhase=t.chat.answerPhase,this._answerStatus=t.chat.answerStatus,this._maxMessageLen=t.chat.maxMessageLen},["chat"]),this._observe(t=>{t.composeMessage&&this._applyComposeBody(t.composeMessage.body)},["composeMessage"]),this._observe(t=>{this._numMapLocations=function(t){let e=0;for(const s of t.selection.visibleElementIds)"marker"===t.elements[s]?.type&&e++;return e}(t.map)},["map.selection.visibleElementIds"]),this._observe(t=>{this._messages=t.messages,this._cards=t.cards},["messages","cards"]),this._observe(t=>{this._conversationId=t.api.conversationId,this._conversationTitle=t.api.conversationTitle},["api.conversationId","api.conversationTitle"]),this._query("messages.load")}disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this._typingStatusTimeout),clearTimeout(this._connectionNoticeTimeout),this._bottomSentinelObserver&&(this._bottomSentinelObserver.disconnect(),this._bottomSentinelObserver=null)}render(){if(this._isLoading||this._error)return this._html`
`;let t="chat-conversation";"transparent"==this.theme.colorAgent&&(t+=" chat-conversation--agent-transparent"),"transparent"==this.theme.colorUser&&(t+=" chat-conversation--user-transparent");let e="";this.theme.withMap&&(t+=" chat-conversation--map-action",this._isMapOpen||(e=this._html` `));let s=null;if(this._showConnectionNotice){let t="",e=!1;this._networkFailure?t=this.labels.appWindow.connectionOffline:"error"===this._socketStatus?t=this.labels.appWindow.connectionFailed:"opening"===this._socketStatus&&(t=this.labels.appWindow.connectionConnecting,e=!0),t&&(s=this._html`
${e?this._html`
`:""}
${t}
`)}const a="opened"!==this._socketStatus||this._answerPhase||!this.__("action-text-input")?.value?.length,i="streaming"===this._answerPhase?this._html`{this._stopResponse()}}> `:this._html`{this._sendMessage()}}> `;let n="";return this._conversationTitle&&(n=this._html` `),this._html`
${n}
${s}
${this._inputError?this._html`${this._inputError}
`:""}
${i}
`}updated(){if(void 0!==this._pendingComposeBody){const t=this.__("action-text-input");t&&(t.value=this._pendingComposeBody,this._pendingComposeBody=void 0,this._handleTextareaInput())}}_applyComposeBody(t){const e=this.__("action-text-input");e?(e.value=t,this._handleTextareaInput()):this._pendingComposeBody=t}_handleTextareaKeydown(t){"opened"===this._socketStatus||this._showConnectionNotice||(this._showConnectionNotice=!0),"Enter"==t.key?(t.preventDefault(),t.shiftKey?this.__("action-text-input").value+="\n":this._answerPhase||this._sendMessage()):this._startTypingStatus()}_handleTextareaInput(){this._resizeTextarea(),this._updateSendButton(),this._clearInputErrorIfValid()}_clearInputErrorIfValid(){if(this._inputError){const t=this._maxMessageLen||1024;(this.__("action-text-input")?.value||"").length<=t&&(this._inputError=null)}}_resizeTextarea(){if(!this._minTextInputHeight){const t=this.__("action-text-input").getBoundingClientRect();this._minTextInputHeight=Math.ceil(t.height),this._maxTextInputHeight=Math.ceil(2*t.height)}this.__("action-text-input").style.height=`${this._minTextInputHeight}px`;const t=this.__("action-text-input").scrollHeight;if(t>this._minTextInputHeight){const e=t{const t=this.__("action-text-input");t&&t.focus({preventScroll:!0})})}_updateSendButton(){const t=this.__("action-send-button");if(t){const e="opened"!==this._socketStatus,s=this.__("action-text-input")?.value?.length>0;t.disabled=e||this._answerPhase||!s}}_sendMessage(){const t=this.__("action-text-input").value,e=this._maxMessageLen||1024;t.length>e?this._inputError=this.labels.chatWindow?.messageTooLong||`Message must be ${e} characters or less`:(this._inputError=null,t.length&&(this.context.chat.sendMessage({body:t}),this.context.analytics.track({name:"message-sent"},{skipBackend:!0}),this.__("action-text-input").value=""),this._resizeTextarea(),this._updateSendButton(),this._stopTypingStatus())}_stopResponse(){this.context.chat.stopResponse()}_startTypingStatus(){"opened"===this._socketStatus&&(this._typingStatusTimeout||this.context.chat.isTypingMessage(!0),clearTimeout(this._typingStatusTimeout),this._typingStatusTimeout=setTimeout(()=>{this._stopTypingStatus()},2500))}_stopTypingStatus(){this._typingStatusTimeout&&(clearTimeout(this._typingStatusTimeout),this._typingStatusTimeout=null,this.context.chat.isTypingMessage(!1))}_handleToBottomButtonClick(){this.querySelector("gg-chat-message-list").scrollToBottom()}_handleScrollUp(){this.querySelector("gg-map-button")?.hide()}_handleScrollDown(){this.querySelector("gg-map-button")?.show()}_pauseBottomSentinelObserver(){this._bottomSentinelPaused=!0}_resumeBottomSentinelObserver(){if(this._bottomSentinelPaused=!1,this._bottomSentinelObserver){const t=this.querySelector("gg-chat-message-list"),e=t?.querySelector(".chat-message-list__bottom-sentinel");e&&(this._bottomSentinelObserver.unobserve(e),this._bottomSentinelObserver.observe(e))}}_setupBottomSentinelObserver(){const t=this.querySelector("gg-chat-message-list");if(!t)return void requestAnimationFrame(()=>this._setupBottomSentinelObserver());t.pauseBottomSentinelObserver=()=>this._pauseBottomSentinelObserver(),t.resumeBottomSentinelObserver=()=>this._resumeBottomSentinelObserver(),this._bottomSentinelObserver=new IntersectionObserver(t=>{if(this._bottomSentinelPaused)return;const e=t[0].isIntersecting,s=this.querySelector(".chat-conversation__action-menu");s&&(e&&this.querySelector("gg-map-button")?.show(),s.classList.toggle("chat-conversation__action-menu--to-bottom--hidden",e))},{root:t,rootMargin:"0px",threshold:0});const e=t.querySelector(".chat-message-list__bottom-sentinel");if(e)this._bottomSentinelObserver.observe(e);else{const e=new MutationObserver(()=>{const s=t.querySelector(".chat-message-list__bottom-sentinel");s&&(e.disconnect(),this._bottomSentinelObserver.observe(s))});e.observe(t,{childList:!0,subtree:!0})}}}},{name:"gg-favorite-window",component:class extends aa{static properties={_isLoading:{state:!0},_error:{state:!0},_cards:{state:!0},_mapFilter:{state:!0}};constructor(){super(),this.className="favorite-window",this._isLoading=!0,this._error=null,this._cards=[],this._mapFilter=null,this._cardHandlers=null,this._createCardTemplate=this._createCardTemplate.bind(this),this._handleScrollUp=this._handleScrollUp.bind(this),this._handleScrollDown=this._handleScrollDown.bind(this)}connectedCallback(){super.connectedCallback(),this._observe((t,e,s)=>{this._cards=[];for(const e of t.favorites){const s=t.cards[e.cardId];s&&this._cards.push(s)}},["favorites","cards"]),this._observe(t=>{this._mapFilter=t.map.favorite.filter},["map.favorite.filter"]),this._query("favorites.load")}willUpdate(t){super.willUpdate(t),!this._cardHandlers&&this.theme.withMap&&(this._cardHandlers=Ba(this,{}))}render(){if(this._isLoading||this._error)return this._html`
`;let t=this._cards;if(this._mapFilter){const e=new Set(this._mapFilter.categories),s=new Set(this._mapFilter.locations);t=t.filter(t=>!(e.size&&!e.has(t.category))&&!(s.size&&!s.has(t.template.location?.id)))}return this._html`
${this._categoryTabsTemplate(this._cards)}
${this._locationFilterTemplate(t.length)}
${this._repeat(t,t=>t.id,this._createCardTemplate)}
`}updated(t){this.theme.withMap&&this._cardHandlers&&this.__("card-list")&&Wa(this.__("card-list"),this._cardHandlers)}_categoryTabsTemplate(t){if(!t.length)return;const e=new Set(t.map(t=>t.category)),s=Ga.filter(t=>e.has(t)),a=this._mapFilter?.categories[0]||null,i=this.labels.mapWindowFilter.categoryLabels;let n="favorite-window__category-tab";return a||(n+=" favorite-window__category-tab--active"),this._html`
this._handleCategoryTabClick(null)}>
${this.labels.mapWindowFilter.categoryAllLabel}
${s.map(t=>{let e="favorite-window__category-tab";return a===t&&(e+=" favorite-window__category-tab--active"),this._html`
this._handleCategoryTabClick(t)}>
${i[t]}
`})}
`}_handleCategoryTabClick(t){const e=this._mapFilter?.categories[0],s=t&&t!==e?[t]:[];this._action("map.update-filter",{filter:{categories:s},focusVisible:!0})}_locationFilterTemplate(t){if(!this._getUniqueLocations().length)return;let e="action-button action-button--sm action-button--filter action-button--auto-dark favorite-window__location-filter-button";return this._mapFilter?.locations.length&&(e+=" action-button--active"),this._html`
${t} ${1===t?this.labels.favoriteWindow.item:this.labels.favoriteWindow.items}
${this.labels.mapWindowFilter.modalHeadline}
`}_handleFilterButtonClick(){const t=this._getUniqueLocations();this.context._openModal("gg-favorite-filter-modal",{attributes:{locations:t,selectedLocations:this._mapFilter?.locations||[]},onSubmit:t=>{this._action("map.update-filter",{filter:{locations:t.locations},focusVisible:!0})}})}_getUniqueLocations(){const t={},e=[];for(const s of this._cards)s.template.location&&"city"===s.template.location.level&&!t[s.template.location.id]&&(t[s.template.location.id]=!0,e.push(s.template.location));return e}_mapButtonTemplate(){if(this.theme.withMap)return this._html`
`}_handleMapButtonClick(){this._action("layout.update",{isMapOpen:!0,isPlaceOpen:!1}),this._action("map.focus-visible")}_handleScrollUp(){this.querySelector("gg-chat-button")?.hide()}_handleScrollDown(){this.querySelector("gg-chat-button")?.show()}_createCardTemplate(t){return this._html`
${this._unsafeHTML(function(t,e,s){const a=ka(t,e,s);return`\n
\n\t
\n\t\t${a.images.length?wa(a.images[0],s.imgCdnDomain,{className:"gg-tall-neo-card__image"}):""}\n\t\t${Ca(a,s)}\n\t
\n\t
\n\t\t${e.location?.id?`
${e.location.name}
`:""}\n\t\t
${a.title}
\n\t\t${Ta(a)}\n\t
\n
\n\n`.trim()}(t.type,t.template,{labels:this.labels,imgCdnDomain:this.theme.imgCdnDomain,cardFavoriteButton:this.theme.withFavorites,isFavorited:t.isFavorited}))}
`}}}]);class Ya{_targetOrigin;_targetWindow;_messageListeners=new Set;_messagePromiseHandlers=new Map;constructor(t){this._targetOrigin=new URL(t.targetOrigin).origin,this._targetWindow=t.targetWindow,this._receiveMessage=this._receiveMessage.bind(this),window.addEventListener("message",this._receiveMessage)}destroy(){window.removeEventListener("message",this._receiveMessage),this._messageListeners.clear(),this._messagePromiseHandlers.clear(),this._targetWindow=null}_receiveMessage(t){if(t.origin==this._targetOrigin)if("__resolve__"==t.data.type){const e=this._messagePromiseHandlers.get(t.data.id);e&&(e.resolve(t.data.data),this._messagePromiseHandlers.delete(t.data.id))}else if("__reject__"==t.data.type){const e=this._messagePromiseHandlers.get(t.data.id);e&&(e.reject(t.data.data),this._messagePromiseHandlers.delete(t.data.id))}else{let e=null;e=t.data.id?{id:t.data.id,data:t.data.data}:t.data.data,this._messageListeners.forEach(s=>{s.type==t.data.type&&s.handler(e)})}}set targetWindow(t){this._targetWindow=t}onMessage(t,e){this._messageListeners.add({type:t,handler:e})}offMessage(t,e){for(const s of this._messageListeners)if(s.type===t&&s.handler===e){this._messageListeners.delete(s);break}}message(t,e){this._targetWindow&&this._targetWindow.postMessage({type:t,data:e},this._targetOrigin)}async promiseMessage(t,e){if(!this._targetWindow)return;const s=`${t}:${Date.now()}`;return this._targetWindow.postMessage({id:s,type:t,data:e},this._targetOrigin),new Promise((t,e)=>{this._messagePromiseHandlers.set(s,{resolve:t,reject:e})})}resolveMessage(t,e){if(!this._targetWindow)return;this._targetWindow.postMessage({id:t,type:"__resolve__",data:e},this._targetOrigin)}rejectMessage(t,e){if(!this._targetWindow)return;this._targetWindow.postMessage({id:t,type:"__reject__",data:e},this._targetOrigin)}}const Va=[{label:"region",icon:"map-pin",value:"region"},{label:"hotel",icon:"bed",value:"hotel"},{label:"restaurant",icon:"fork-knife",value:"restaurant"},{label:"business",icon:"building",value:"business"},{label:"tour",icon:"sign-post",value:"tour"},{label:"carRental",icon:"car-front",value:"car-rental"}];Bs([{name:"gg-card-slider",component:class extends aa{static properties={mapElements:{attribute:!1},onCardChange:{attribute:!1},onCardClick:{attribute:!1}};_curSlideIndex=0;_touchStartX=null;_touchStartY=null;_swipeDir=null;constructor(){super(),this.className="card-slider"}render(){return this._html`
${this.mapElements.map(t=>this._slideTemplate(t))}
this._offsetScroll(-1)}">
this._offsetScroll(1)}">
${this.mapElements.length>1?this._html`
`:""}
`}updated(t){this._elementsChanged(t.get("mapElements"))&&(this.__("slide-list").scrollLeft=0,this._curSlideIndex=0,this._offsetScroll(0),this.classList.toggle("card-slider--multi",this.mapElements.length>1)),this._setupCards()}_setupCards(){this.__all("slide").forEach(t=>{const e=t.querySelector(".gg-wide-neo-card");if(!e)return;const s={};this.onCardClick&&(s.onClick=e=>{this.onCardClick(t.dataset.group)}),s.onFavoriteClick=t=>{this._query("favorites.toggle",{cardId:t.id})},Fa(e,s)})}_slideTemplate(t){const e=t.options.card;return this._html`
${this._unsafeHTML(Sa(e.type,e.template,{cardActionButton:"more",labels:this.labels.placeWindow,imgCdnDomain:this.theme.imgCdnDomain,cardFavoriteButton:this.theme.withFavorites,isFavorited:e.isFavorited}))}
`}_handleSlideListTouchStart(t){this._touchStartX=t.touches[0].clientX,this._touchStartY=t.touches[0].clientY,this._swipeDir=null}_handleSlideListTouchMove(t){if(this._swipeDir)return;const e=t.touches[0].clientX-this._touchStartX,s=t.touches[0].clientY-this._touchStartY;Math.abs(e)>Math.abs(s)?(t.preventDefault(),this._swipeDir="x"):Math.abs(s)>Math.abs(e)&&(this._swipeDir="y")}_handleSlideListTouchEnd(t){if("x"!=this._swipeDir)return;const e=t.changedTouches[0].clientX-this._touchStartX;Math.abs(e)>50&&this._offsetScroll(e>0?-1:1)}_scrollTo(t){const e=this.__("slide-list"),s=e.children.length-1,a=Math.min(s,Math.max(0,t));if(a!=this._curSlideIndex){const t=e.children[a];e.scrollTo({left:t.offsetLeft,behavior:"smooth"}),this._curSlideIndex=a,this.onCardChange&&this.onCardChange(t.dataset.group)}this.__("nav-button--prev").disabled=0==this._curSlideIndex,this.__("nav-button--next").disabled=this._curSlideIndex==s,this.__all("pager-dot").forEach((t,e)=>{t.classList.toggle("card-slider__pager-dot--active",e==this._curSlideIndex)})}_offsetScroll(t){this._scrollTo(this._curSlideIndex+t)}_elementsChanged(t){return!t||t.length!==this.mapElements.length||t.some((t,e)=>t.id!==this.mapElements[e].id)}}},{name:"gg-chat-button",component:za},{name:"gg-map-filter-modal",component:class extends aa{static properties={target:{attribute:!1},categories:{attribute:!1},categoryCounts:{attribute:!1},markerPrice:{attribute:!1},onClose:{attribute:!1},onSubmit:{attribute:!1},_formData:{state:!0}};connectedCallback(){if(super.connectedCallback(),this.className="modal-dialog modal-dialog--open",this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this._handleRootClick=this._handleRootClick.bind(this),!Ft()){this.className+=" modal-dialog--popup";const t=this.target.getBoundingClientRect(),e=this.offsetParent.getBoundingClientRect(),s=e.right-t.right,a=t.bottom-e.top+8;this.style.setProperty("--modal-dialog-popup-right",`${s}px`),this.style.setProperty("--modal-dialog-popup-top",`${a}px`)}this.addEventListener("click",this._handleRootClick),this._formData={categories:this.categories||[],markerPrice:this.markerPrice||!1}}disconnectedCallback(){super.disconnectedCallback(),Ft()||this.removeEventListener("click",this._handleRootClick)}render(){return this._html`
`}_formInnerTemplate(){const t=this._html`
`;return Ft()?this._html`
${t}
${this.labels.modalWindow.updateButton}
`:this._html`
${this.labels.mapWindowFilter.categoryAllLabel}
${Va.map(t=>this._html`
${this._categoryCheckboxTemplate(t.value)}
${this.labels.mapWindowFilter.categoryLabels[t.label]}
${this._getCategoryCount(t.value)}
`)}
${t}
`}_handleRootClick(t){if(t.target==this)return this.onSubmit?void this.onSubmit(this._formData):this.onClose()}_categoryCheckboxTemplate(t){const e=!this._getCategoryCount(t),s=!e&&this._formData.categories.includes(t);return this._html` `}_getCategoryCount(t){return this.categoryCounts?.[t]||0}_handleFormChange(t){const e=new FormData(t.target.form);this._formData={categories:"categoryAll"==t.target.name?[]:e.getAll("categories"),markerPrice:e.has("markerPrice")}}_handleFormSubmit(t){t.preventDefault(),this.onSubmit&&this.onSubmit(this._formData)}}}]);var Qa,Ka={exports:{}};var Za=(Qa||(Qa=1,Ka.exports=function(t,e,s){t=t||{};var a=e.prototype,i={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function n(t,e,s,i){return a.fromToBase(t,e,s,i)}s.en.relativeTime=i,a.fromToBase=function(e,a,n,o,r){for(var l,c,d,h=n.$locale().relativeTime||i,u=t.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],p=u.length,m=0;m0,g<=_.r||!_.r){g<=1&&m>0&&(_=u[m-1]);var f=h[_.l];r&&(g=r(""+g)),c="string"==typeof f?f.replace("%d",g):f(g,a,_.l,d);break}}if(a)return c;var b=d?h.future:h.past;return"function"==typeof b?b(c):b.replace("%s",c)},a.to=function(t,e){return n(t,e,this,!0)},a.from=function(t,e){return n(t,e,this)};var o=function(t){return t.$u?s.utc():s()};a.toNow=function(t){return this.to(o(this),t)},a.fromNow=function(t){return this.from(o(this),t)}}),Ka.exports);const Xa=Bt(Za);function Ja(t){if(t?.attribution?.photoId)return t.attribution.photoId;if(t?.attribution?.unsplashUrl){const e=t.attribution.unsplashUrl.match(/\/photos\/([^?]+)/);return e?e[1]:null}return null}class ti{#t;#e=new Set;constructor(t){this.#t=t}get current(){return this.#t}set current(t){this.#t!=t&&(this.#t=t,this.#e.forEach(e=>e(t)))}on(t){return this.#e.add(t),()=>this.#e.delete(t)}}const ei=t=>new ti(t),si=Symbol.for("atomico.hooks");globalThis[si]=globalThis[si]||{};let ai=globalThis[si];const ii=Symbol.for("Atomico.suspense"),ni=Symbol.for("Atomico.effect"),oi=Symbol.for("Atomico.layoutEffect"),ri=Symbol.for("Atomico.insertionEffect"),li=(t,e,s)=>{const{i:a,hooks:i}=ai.c,n=i[a]=i[a]||{};return n.value=t(n.value),n.effect=e,n.tag=s,ai.c.i++,i[a].value},ci=t=>li((e=ei(t))=>e),di=()=>li((t=ei(ai.c.host))=>t),hi=()=>ai.c.update,ui=Symbol.for;function pi(t,e){const s=t.length;if(s!==e.length)return!1;for(let a=0;a"function"==typeof t,_i=t=>"object"==typeof t,{isArray:gi}=Array,fi=(t,e)=>(!e||t instanceof HTMLStyleElement)&&"hydrate"in(t?.dataset||{});function bi(t,e){let s;const a=t=>{let{length:i}=t;for(let n=0;n(t.addEventListener(e,s),()=>t.removeEventListener(e,s));class yi{constructor(t,e,s){this.message=e,this.target=t,this.value=s}}class wi extends yi{}class $i extends yi{}const ki="Custom",Si={true:1,"":1,1:1};function Ti(t,e,s,a,i){const{type:n,reflect:o,event:r,value:l,attr:c=Mi(e)}=s?.name!=ki&&_i(s)&&null!=s?s:{type:s},d=n?.name===ki&&n.map,h=null!=l?n!=Function&&mi(l)?l:()=>l:null;Object.defineProperty(t,e,{configurable:!0,set(t){const s=this[e];h&&n!=Boolean&&null==t&&(t=h());const{error:a,value:i}=(d?Ii:Ai)(n,t);if(a&&null!=i)throw new wi(this,`The value defined for prop '${e}' must be of type '${n.name}'`,i);s!=i&&(this._props[e]=i??void 0,this.update(),r&&Ci(this,r),this.updated.then(()=>{o&&(this._ignoreAttr=c,xi(this,n,c,this[e]),this._ignoreAttr=null)}))},get(){return this._props[e]}}),h&&(i[e]=h()),a[c]={prop:e,type:n}}const Ci=(t,{type:e,base:s=CustomEvent,...a})=>t.dispatchEvent(new s(e,a)),Mi=t=>t.replace(/([A-Z])/g,"-$1").toLowerCase(),xi=(t,e,s,a)=>null==a||e==Boolean&&!a?t.removeAttribute(s):t.setAttribute(s,e?.name===ki&&e?.serialize?e?.serialize(a):_i(a)?JSON.stringify(a):e==Boolean?"":a),Ii=({map:t},e)=>{try{return{value:t(e),error:!1}}catch{return{value:e,error:!0}}},Ai=(t,e)=>null==t||null==e?{value:e,error:!1}:t!=String&&""===e?{value:void 0,error:!1}:t==Object||t==Array||t==Symbol?{value:e,error:{}.toString.call(e)!==`[object ${t.name}]`}:e instanceof t?{value:e,error:t==Number&&Number.isNaN(e.valueOf())}:t==String||t==Number||t==Boolean?{value:e,error:t==Number?"number"!=typeof e||Number.isNaN(e):t==String?"string"!=typeof e:"boolean"!=typeof e}:{value:e,error:!0};let Li=0;const Oi=(t,e=HTMLElement)=>{const s={},a={},i="prototype"in e&&e.prototype instanceof Element,n=i?e:"base"in e?e.base:HTMLElement,{props:o,styles:r}=i?t:e;return class extends n{constructor(){super(),this._setup(),this._render=()=>t({...this._props});for(const t in a)this[t]=a[t]}static get styles(){return[super.styles,r]}async _setup(){if(this._props)return;let t,e;this._props={},this.mounted=new Promise(s=>this.mount=()=>{s(),t!=this.parentNode&&(e!=t?this.unmounted.then(this.update):this.update()),t=this.parentNode}),this.unmounted=new Promise(a=>this.unmount=()=>{a(),(t!=this.parentNode||!this.isConnected)&&(s.cleanEffects(!0)()(),e=this.parentNode,t=null)}),this.symbolId=this.symbolId||Symbol(),this.symbolIdParent=Symbol();const s=((t,e,s=0)=>{let a={},i=!1;const n=(t,e)=>{for(const s in a){const i=a[s];i.effect&&i.tag===t&&(i.value=i.effect(i.value,e))}};return{load:n=>{let o;ai.c={host:e,hooks:a,update:t,i:0,id:s};try{i=!1,o=n()}catch(t){if(t!==ii)throw t;i=!0}finally{ai.c=null}return o},cleanEffects:t=>(n(ri,t),()=>(n(oi,t),()=>{n(ni,t)})),isSuspense:()=>i}})(()=>this.update(),this,(t=>(t?.dataset||{})?.hydrate||"c"+Li++)(this));let a,i=!0;const n=fi(this);this.update=()=>(a||(a=!0,this.updated=(this.updated||this.mounted).then(()=>{try{const t=s.load(this._render),e=s.cleanEffects();return t&&t.render(this,this.symbolId,n),a=!1,i&&!s.isSuspense()&&(i=!1,!n&&function(t){const{styles:e}=t.constructor,{shadowRoot:s}=t;if(s&&e.length){const t=[];bi(e,e=>{e&&(e instanceof Element?s.appendChild(e.cloneNode(!0)):t.push(e))}),t.length&&(s.adoptedStyleSheets=t)}}(this)),e()}finally{a=!1}}).then(t=>{t&&t()})),this.updated),this.update()}connectedCallback(){this.mount(),super.connectedCallback&&super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),this.unmount()}attributeChangedCallback(t,e,a){if(s[t]){if(t===this._ignoreAttr||e===a)return;const{prop:i,type:n}=s[t];try{this[i]=((t,e)=>t==Boolean?!!Si[e]:t==Number?Number(e):t==String?e:t==Array||t==Object?JSON.parse(e):t.name==ki?e:new t(e))(n,a)}catch{throw new $i(this,`The value defined as attr '${t}' cannot be parsed by type '${n.name}'`,a)}}else super.attributeChangedCallback(t,e,a)}static get props(){return{...super.props,...o}}static get observedAttributes(){const t=super.observedAttributes||[];for(const t in o)Ti(this.prototype,t,o[t],s,a);return Object.keys(s).concat(t)}}};const Ei=t=>(e,s)=>{li(([t,e]=[])=>((e||!e)&&(e&&pi(e,s)?t=t||!0:(mi(t)&&t(),t=null)),[t,s]),([t,s],a)=>a?(mi(t)&&t(),[]):[t||e(),s],t)},Di=Ei(ni),Pi=Ei(ri);class Ui extends Array{constructor(t,e){let s=!0;const a=t=>{try{e(t,this,s)}finally{s=!1}};super(void 0,a,e),a(t)}}const Hi=t=>{const e=hi();return li((s=new Ui(t,(t,s,a)=>{(t=mi(t)?t(s[0]):t)!==s[0]&&(s[0]=t,a||e())}))=>s)},Ni=(t,e)=>{const[s]=li(([s,a,i=0]=[])=>((!a||a&&!pi(a,e))&&(s=t()),[s,e,i]));return s},Fi=t=>{const{current:e}=di();if(!(t in e))throw new wi(e,`For useProp("${t}"), the prop does not exist on the host.`,t);return li((s=new Ui(e[t],(s,a)=>{s=mi(s)?s(e[t]):s,e[t]=s}))=>(s[0]=e[t],s))},Wi=(t,e={})=>{const s=di();return s[t]||(s[t]=(a=e.detail)=>Ci(s.current,{type:t,...e,detail:a})),s[t]},Bi=ui("atomico/options");globalThis[Bi]=globalThis[Bi]||{sheet:!!document.adoptedStyleSheets};const Ri=globalThis[Bi],qi=new Promise(t=>{Ri.ssr||("loading"===document.readyState?vi(document,"DOMContentLoaded",t):t())}),zi={checked:1,value:1,selected:1},ji={list:1,type:1,size:1,form:1,width:1,height:1,src:1,href:1,slot:1},Gi={shadowDom:1,staticNode:1,cloneNode:1,children:1,key:1},Yi={},Vi=[];class Qi extends Text{}const Ki=ui("atomico/id"),Zi=ui("atomico/type"),Xi=ui("atomico/ref"),Ji=ui("atomico/vnode"),tn=()=>{};function en(t,e,s){return an(this,t,e,s)}const sn=(t,e,...s)=>{const a=e||Yi;let{children:i}=a;if(i=i??(s.length?s:Vi),t===tn)return i;const n=t?t instanceof Node?1:t.prototype instanceof HTMLElement&&2:0;if(!1===n&&t instanceof Function)return t(i!=Vi?{children:i,...a}:a);const o=Ri.render||en;return{[Zi]:Ji,type:t,props:a,children:i,key:a.key,shadow:a.shadowDom,static:a.staticNode,raw:n,is:a.is,clone:a.cloneNode,render:o}};function an(t,e,s=Ki,a,i){let n;if(e&&e[s]&&e[s].vnode==t||t[Zi]!=Ji)return e;(t||!e)&&(i=i||"svg"==t.type,n="host"!=t.type&&(1==t.raw?(e&&t.clone?e[Xi]:e)!=t.type:2==t.raw?!(e instanceof t.type):e?e[Xi]||e.localName!=t.type:!e),n&&null!=t.type&&(1==t.raw&&t.clone?(a=!0,(e=t.type.cloneNode(!0))[Xi]=t.type):e=1==t.raw?t.type:2==t.raw?new t.type:i?document.createElementNS("http://www.w3.org/2000/svg",t.type):document.createElement(t.type,t.is?{is:t.is}:void 0)));const o=e[s]?e[s]:Yi,{vnode:r=Yi,cycle:l=0}=o;let{fragment:c,handlers:d}=o;const{children:h=Vi,props:u=Yi}=r;if(d=n?{}:d||{},t.static&&!n)return e;if(t.shadow&&!e.shadowRoot&&e.attachShadow({mode:"open",...t.shadow}),t.props!=u&&function(t,e,s,a,i){for(const n in e)!(n in s)&&nn(t,n,e[n],null,i,a);for(const n in s)nn(t,n,e[n],s[n],i,a)}(e,u,t.props,d,i),t.children!==h){const n=t.shadow?e.shadowRoot:e;c=function(t,e,s,a,i,n){t=null==t?null:gi(t)?t:[t];const o=e||function(t,e){const s=new Qi(""),a=new Qi("");let i;if(t[e?"prepend":"append"](s),e){let{lastElementChild:e}=t;for(;e;){const{previousElementSibling:t}=e;if(fi(e,!0)&&!fi(t,!0)){i=e;break}e=t}}return i?i.before(a):t.append(a),{markStart:s,markEnd:a}}(s,i),{markStart:r,markEnd:l,keyes:c}=o;let d;const h=c&&new Set;let u=r;if(t&&bi(t,t=>{if("object"==typeof t&&!t[Zi])return;const e=t[Zi]&&t.key,o=c&&null!=e&&c.get(e);u!=l&&u===o?h.delete(u):u=u==l?l:u.nextSibling;const r=c?o:u;let p=r;if(t[Zi])p=an(t,r,a,i,n);else{const e=t+"";!(p instanceof Text)||p instanceof Qi?p=new Text(e):p.data!=e&&(p.data=e)}p!=u&&(c&&h.delete(p),!r||c?(s.insertBefore(p,u),c&&u!=l&&h.add(u)):r==l?s.insertBefore(p,l):(s.replaceChild(p,r),u=p)),null!=e&&(d=d||new Map,d.set(e,p))}),u=u==l?l:u.nextSibling,e&&u!=l)for(;u!=l;){const t=u;u=u.nextSibling,t.remove()}return h&&h.forEach(t=>t.remove()),o.keyes=d,o}(t.children,c,n,s,!l&&a,(!i||"foreignObject"!=t.type)&&i)}return e[s]={vnode:t,handlers:d,fragment:c,cycle:l+1},e}function nn(t,e,s,a,i,n){if(s=s??null,a=a??null,(e="class"!=e||i?e:"className")in t&&zi[e]&&(s=t[e]),a!==s&&!Gi[e]&&"_"!=e[0])if("slot"===t.localName&&"assignNode"===e&&"assign"in t)t.assign(a);else if("o"==e[0]&&"n"==e[1]&&(mi(a)||mi(s)))!function(t,e,s,a){if(a.handleEvent||(a.handleEvent=e=>a[e.type].call(t,e)),s){if(!a[e]){const i=s.capture||s.once||s.passive?Object.assign({},s):null;t.addEventListener(e,a,i)}a[e]=s}else a[e]&&(t.removeEventListener(e,a),delete a[e])}(t,e.slice(2),a,n);else if("ref"==e)a&&(mi(a)?a(t):a.current=t);else if("style"==e){const{style:e}=t;a=a||"";const i=_i(s=s||""),n=_i(a);if(i)for(const t in s){if(!n)break;!(t in a)&&on(e,t,null)}if(n)for(const t in a){const n=a[t];i&&s[t]===n||on(e,t,n)}else e.cssText=a}else{const n="$"==e[0]?e.slice(1):e;n===e&&(!i&&!ji[e]&&e in t||mi(a)||mi(s))?t[e]=a??"":null==a?t.removeAttribute(n):t.setAttribute(n,_i(a)?JSON.stringify(a):a)}}function on(t,e,s){let a="setProperty";null==s&&(a="removeProperty",s=null),~e.indexOf("-")?t[a](e,s):t[e]=s}const rn=sn("host",{style:"display: contents"}),ln="value",cn=t=>{const e=Wi("ConnectContext",{bubbles:!0,composed:!0}),[s,a]=Hi(()=>{if(Ri.ssr)return;let s;return e({id:t,connect(t){s=t}}),s}),i=hi();return Di(()=>{qi.then(()=>e({id:t,connect:a}))},[t]),Di(()=>{if(s)return s.on(i)},[s]),s?.current||t[ln]},dn=t=>{const e=Oi(({value:t})=>(((t,e)=>{const s=di(),a=ci();Pi(()=>vi(s.current,"ConnectContext",e=>{e.composedPath().at(0)!==e.currentTarget&&t===e.detail.id&&(e.stopPropagation(),e.detail.connect(a))}),[t]),a.current=e})(e,t),rn),{props:{value:{type:Object,value:()=>t}}});return e[ln]=t,e};dn({dispatch(t,e){}});const hn={};function un(t,...e){const s=(t.raw||t).reduce((t,s,a)=>t+s+(e[a]||""),"");return hn[s]=hn[s]||function(t){if(Ri.sheet){const e=new CSSStyleSheet;return e.replaceSync(t),e}{const e=document.createElement("style");return e.textContent=t,e}}(s)}const pn=(t,e,s)=>(null==e?e={key:s}:e.key=s,sn(t,e)),mn=pn,_n=un`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation;cursor:pointer;user-select:none}`,gn=un`.vh{position:absolute;transform:scale(0)}`;function fn(){const t=new Date;return new Mn(t.getFullYear(),t.getMonth()+1,t.getDate())}function bn(t){const e=Sn(t);e.setUTCDate(e.getUTCDate()+3-(e.getUTCDay()+6)%7);const s=new Date(Date.UTC(e.getUTCFullYear(),0,4));return 1+Math.round(((e.getTime()-s.getTime())/864e5-3+(s.getUTCDay()+6)%7)/7)}function vn(t,e=0){const s=Sn(t),a=s.getUTCDay(),i=(a0?s:t}const kn={days:1};function Sn(t){return new Date(Date.UTC(t.year,t.month-1,t.day??1))}const Tn=/^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/,Cn=(t,e)=>t.toString().padStart(e,"0");class Mn{constructor(t,e,s){this.year=t,this.month=e,this.day=s}add(t){const e=Sn(this);if("days"in t)return e.setUTCDate(this.day+t.days),Mn.from(e);let{year:s,month:a}=this;"months"in t?(a=this.month+t.months,e.setUTCMonth(a-1)):(s=this.year+t.years,e.setUTCFullYear(s));const i=Mn.from(Sn({year:s,month:a,day:1}));return $n(Mn.from(e),i,wn(i))}toString(){return`${Cn(this.year,4)}-${Cn(this.month,2)}-${Cn(this.day,2)}`}toPlainYearMonth(){return new xn(this.year,this.month)}equals(t){return 0===Mn.compare(this,t)}static compare(t,e){return t.yeare.year?1:t.monthe.month?1:t.daye.day?1:0}static from(t){if("string"==typeof t){const e=t.match(Tn);if(!e)throw new TypeError(t);const[,s,a,i]=e;return new Mn(parseInt(s,10),parseInt(a,10),parseInt(i,10))}return new Mn(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}}class xn{constructor(t,e){this.year=t,this.month=e}add(t){const e=Sn(this),s=(t.months??0)+12*(t.years??0);return e.setUTCMonth(e.getUTCMonth()+s),new xn(e.getUTCFullYear(),e.getUTCMonth()+1)}equals(t){return this.year===t.year&&this.month===t.month}toPlainDate(){return new Mn(this.year,this.month,1)}static compare(t,e){return t.yeare.year?1:t.monthe.month?1:0}}function In(t,e){if(e)try{return t.from(e)}catch{}}function An(t){const[e,s]=Fi(t);return[Ni(()=>In(Mn,e),[e]),t=>s(t?.toString())]}function Ln(t,e){return Ni(()=>new Intl.DateTimeFormat(e,{timeZone:"UTC",...t}),[e,t])}function On(t,e,s){const a=Ln(t,s);return Ni(()=>{const t=[],s=new Date;for(var i=0;i<7;i++){t[(s.getUTCDay()-e+7)%7]=a.format(s),s.setUTCDate(s.getUTCDate()+1)}return t},[e,a])}const En=(t,e,s)=>$n(t,e,s)===t,Dn=t=>t.target.matches(":dir(ltr)"),Pn={month:"long",day:"numeric"},Un={month:"long"},Hn={weekday:"long"},Nn={bubbles:!0};function Fn({props:t,context:e}){const{offset:s}=t,{firstDayOfWeek:a,isDateDisallowed:i,min:n,max:o,today:r,page:l,locale:c,focusedDate:d,formatWeekday:h}=e,u=r??fn(),p=On(Hn,a,c),m=On(Ni(()=>({weekday:h}),[h]),a,c),_=Ln(Pn,c),g=Ln(Un,c),f=Ni(()=>l.start.add({months:s}),[l,s]),b=Ni(()=>function(t,e=0){let s=vn(t.toPlainDate(),e);const a=yn(wn(t),e),i=[];for(;Mn.compare(s,a)<0;){const t=[];for(let e=0;e<7;e++)t.push(s),s=s.add(kn);i.push(t)}return i}(f,a),[f,a]),v=Wi("focusday",Nn),y=Wi("selectday",Nn),w=Wi("hoverday",Nn);function $(t){v($n(t,n,o))}function k(t){let e;switch(t.key){case"ArrowRight":e=d.add({days:Dn(t)?1:-1});break;case"ArrowLeft":e=d.add({days:Dn(t)?-1:1});break;case"ArrowDown":e=d.add({days:7});break;case"ArrowUp":e=d.add({days:-7});break;case"PageUp":e=d.add(t.shiftKey?{years:-1}:{months:-1});break;case"PageDown":e=d.add(t.shiftKey?{years:1}:{months:1});break;case"Home":e=vn(d,a);break;case"End":e=yn(d,a);break;default:return}$(e),t.preventDefault()}return{weeks:b,yearMonth:f,daysLong:p,daysVisible:m,formatter:g,getDayProps:function(t){const s=f.equals(t);if(!e.showOutsideDays&&!s)return;const a=t.equals(d),r=t.equals(u),l=Sn(t),c=i?.(l),h=!En(t,n,o);let p,m="";if("range"===e.type){const[s,a]=e.value,i=s?.equals(t),n=a?.equals(t);p=s&&a&&En(t,s,a),m=`${i?"range-start":""} ${n?"range-end":""} ${!p||i||n?"":"range-inner"}`}else p="multi"===e.type?e.value.some(e=>e.equals(t)):e.value?.equals(t);return{part:`button day day-${l.getUTCDay()} ${s?p?"selected":"":"outside"} ${c?"disallowed":""} ${r?"today":""} ${e.getDayParts?.(l)??""} ${m}`,tabindex:s&&a?0:-1,disabled:h,"aria-disabled":c?"true":void 0,"aria-pressed":s&&p,"aria-current":r?"date":void 0,"aria-label":_.format(l),onkeydown:k,onclick(){c||y(t),$(t)},onmouseover(){!c&&!h&&w(t)}}}}}const Wn=fn(),Bn=dn({type:"date",firstDayOfWeek:1,focusedDate:Wn,page:{start:Wn.toPlainYearMonth(),end:Wn.toPlainYearMonth()}});customElements.define("calendar-ctx",Bn);const Rn=(t,e)=>(e+t)%7,qn=Oi(t=>{const e=cn(Bn),s=ci(),a=Fn({props:t,context:e});return mn("host",{shadowDom:!0,focus:function(){s.current.querySelector("button[tabindex='0']")?.focus()},children:[pn("div",{id:"h",part:"heading",children:a.formatter.format(Sn(a.yearMonth))}),mn("table",{ref:s,"aria-labelledby":"h",part:"table",children:[mn("colgroup",{children:[e.showWeekNumbers&&pn("col",{part:"col-weeknumber"}),pn("col",{part:"col-1"}),pn("col",{part:"col-2"}),pn("col",{part:"col-3"}),pn("col",{part:"col-4"}),pn("col",{part:"col-5"}),pn("col",{part:"col-6"}),pn("col",{part:"col-7"})]}),pn("thead",{children:mn("tr",{part:"tr head",children:[e.showWeekNumbers&&pn("th",{part:"th weeknumber",children:mn("slot",{name:"weeknumber",children:[pn("span",{class:"vh",children:"Week"}),pn("span",{"aria-hidden":"true",children:"#"})]})}),a.daysLong.map((t,s)=>mn("th",{part:`th day day-${Rn(e.firstDayOfWeek,s)}`,scope:"col",children:[pn("span",{class:"vh",children:t}),pn("span",{"aria-hidden":"true",children:a.daysVisible[s]})]}))]})}),pn("tbody",{children:a.weeks.map((t,s)=>mn("tr",{part:"tr week",children:[e.showWeekNumbers&&pn("th",{class:"num",part:"th weeknumber",scope:"row",children:bn(t[0])}),t.map((t,e)=>{const s=a.getDayProps(t);return pn("td",{part:"td",children:s&&pn("button",{class:"num",...s,children:t.day})},e)})]},s))})]})]})},{props:{offset:{type:Number,value:0}},styles:[_n,gn,un`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;font-size:.875rem}th{inline-size:2.25rem;block-size:2.25rem}td{padding-inline:0}.num{font-variant-numeric:tabular-nums}button{color:inherit;font-size:inherit;background:transparent;border:0;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled,[aria-disabled])){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disallowed){cursor:default;opacity:.5}`]});function zn(t){return pn("button",{part:`button ${t.name} ${t.onclick?"":"disabled"}`,onclick:t.onclick,"aria-disabled":t.onclick?null:"true",children:pn("slot",{name:t.name,children:t.children})})}function jn(t){const e=Sn(t.page.start),s=Sn(t.page.end);return pn(Bn,{value:t,onselectday:t.onSelect,onfocusday:t.onFocus,onhoverday:t.onHover,children:mn("div",{role:"group","aria-labelledby":"h",part:"container",children:[pn("div",{id:"h",class:"vh","aria-live":"polite","aria-atomic":"true",children:t.formatVerbose.formatRange(e,s)}),mn("div",{part:"header",children:[pn(zn,{name:"previous",onclick:t.previous,children:"Previous"}),pn("slot",{part:"heading",name:"heading",children:pn("div",{"aria-hidden":"true",children:t.format.formatRange(e,s)})}),pn(zn,{name:"next",onclick:t.next,children:"Next"})]}),pn("slot",{part:"months"})]})})}customElements.define("calendar-month",qn);const Gn={value:{type:String,value:""},min:{type:String,value:""},max:{type:String,value:""},today:{type:String,value:""},isDateDisallowed:{type:Function,value:t=>!1},formatWeekday:{type:String,value:()=>"narrow"},getDayParts:{type:Function,value:t=>""},firstDayOfWeek:{type:Number,value:()=>1},showOutsideDays:{type:Boolean,value:!1},locale:{type:String,value:()=>{}},months:{type:Number,value:1},focusedDate:{type:String,value:()=>{}},pageBy:{type:String,value:()=>"months"},showWeekNumbers:{type:Boolean,value:!1}},Yn=[_n,gn,un`:host{display:block;inline-size:fit-content}:host::part(container){display:flex;flex-direction:column;gap:1em}:host::part(header){display:flex;align-items:center;justify-content:space-between}:host::part(heading){font-weight:700;font-size:1.25em}:host::part(button){display:flex;align-items:center;justify-content:center}:host::part(button disabled){cursor:default;opacity:.5}`],Vn={year:"numeric"},Qn={year:"numeric",month:"long"};function Kn(t,e){return 12*(e.year-t.year)+e.month-t.month}const Zn=(t,e)=>({start:t=12===e?new xn(t.year,1):t,end:t.add({months:e-1})});function Xn({months:t,pageBy:e,locale:s,focusedDate:a,setFocusedDate:i}){const[n]=An("min"),[o]=An("max"),[r]=An("today"),l=Wi("focusday"),c=Wi("change"),d=Ni(()=>$n(a??r??fn(),n,o),[a,r,n,o]);function h(t){i(t),l(Sn(t))}const{next:u,previous:p,page:m}=function({pageBy:t,focusedDate:e,months:s,max:a,min:i,goto:n}){const o="single"===t?1:s,[r,l]=Hi(()=>Zn(e.toPlainYearMonth(),s)),c=t=>l(Zn(r.start.add({months:t}),s)),d=t=>{const e=Kn(r.start,t.toPlainYearMonth());return e>=0&&e{if(d(e))return;const t=Kn(e.toPlainYearMonth(),r.start);n(e.add({months:t}))},[r.start]),Di(()=>{if(d(e))return;const t=Kn(r.start,e.toPlainYearMonth());c(-1===t?-o:t===s?o:Math.floor(t/s)*s)},[e,o,s]),{page:r,previous:i&&d(i)?void 0:()=>c(-o),next:a&&d(a)?void 0:()=>c(o)}}({pageBy:e,focusedDate:d,months:t,min:n,max:o,goto:h}),_=di();function g(t){const e=t?.target??"day";"day"===e?_.current.querySelectorAll("calendar-month").forEach(e=>e.focus(t)):_.current.shadowRoot.querySelector(`[part~='${e}']`).focus(t)}return{format:Ln(Vn,s),formatVerbose:Ln(Qn,s),page:m,focusedDate:d,dispatch:c,onFocus(t){t.stopPropagation(),h(t.detail),setTimeout(g)},min:n,max:o,today:r,next:u,previous:p,focus:g}}const Jn=Oi(t=>{const[e,s]=An("value"),[a=e,i]=An("focusedDate"),n=Xn({...t,focusedDate:a,setFocusedDate:i});return pn("host",{shadowDom:!0,focus:n.focus,children:pn(jn,{...t,...n,type:"date",value:e,onSelect:function(t){s(t.detail),n.dispatch()}})})},{props:Gn,styles:Yn});function to(t){return mn(tn,{children:[pn("label",{part:"label",for:"s",children:pn("slot",{name:"label",children:t.label})}),pn("select",{id:"s",part:"select",onchange:t.onChange,children:t.options.map(t=>pn("option",{part:"option",...t}))})]})}customElements.define("calendar-date",Jn);const eo=[_n,gn];function so(t){const{min:e,max:s,focusedDate:a}=cn(Bn),i=Wi("focusday",{bubbles:!0}),n=a.toPlainYearMonth(),o=n.year,r=Math.floor(t.maxYears/2),l=o-r,c=o+(t.maxYears-r-1),d=Math.max(l,e?.year??-1/0),h=function(t,e){return Array.from({length:t},(t,s)=>e(s))}(Math.min(c,s?.year??1/0)-d+1,t=>{const e=d+t;return{label:`${e}`,value:`${e}`,selected:e===n.year}});return{options:h,onChange:function(t){const e=parseInt(t.currentTarget.value)-n.year;i(a.add({years:e}))}}}const ao=Oi(t=>{const e=so(t);return pn("host",{shadowDom:!0,children:pn(to,{label:"Year",...e})})},{props:{maxYears:{type:Number,value:20}},styles:eo});customElements.define("calendar-select-year",ao);const io=Oi(t=>{const e=function(t){const{min:e,max:s,focusedDate:a,locale:i}=cn(Bn),n=Wi("focusday",{bubbles:!0}),o=Ln(Ni(()=>({month:t.formatMonth}),[t.formatMonth]),i),r=Ni(()=>{const t=[],e=new Date;e.setUTCDate(1);for(var s=0;s<12;s++)t[(e.getUTCMonth()+12)%12]=o.format(e),e.setUTCMonth(e.getUTCMonth()+1);return t},[o]),l=a.toPlainYearMonth(),c=r.map((t,a)=>{const i=a+1,n=l.add({months:i-l.month});return{label:t,value:`${i}`,disabled:null!=e&&xn.compare(n,e)<0||null!=s&&xn.compare(n,s)>0,selected:i===l.month}});return{options:c,onChange:function(t){const e=parseInt(t.currentTarget.value)-l.month;n(a.add({months:e}))}}}(t);return pn("host",{shadowDom:!0,children:pn(to,{label:"Month",...e})})},{props:{formatMonth:{type:String,value:()=>"long"}},styles:eo});customElements.define("calendar-select-month",io);const no=(t,e)=>Mn.compare(t,e)<0?[t,e]:[e,t],oo=Oi(t=>{const[e,s]=function(t){const[e="",s]=Fi(t);return[Ni(()=>{const[t,s]=e.split("/"),a=In(Mn,t),i=In(Mn,s);return a&&i?[a,i]:[]},[e]),t=>s(`${t[0]}/${t[1]}`)]}("value"),[a=e[0],i]=An("focusedDate"),n=Xn({...t,focusedDate:a,setFocusedDate:i}),o=Wi("rangestart"),r=Wi("rangeend"),[l,c]=An("tentative"),[d,h]=Hi();function u(t){t.stopPropagation(),l&&h(t.detail)}Di(()=>h(void 0),[l]);const p=l?no(l,d??l):e;return pn("host",{shadowDom:!0,focus:n.focus,children:pn(jn,{...t,...n,type:"range",value:p,onFocus:function(t){n.onFocus(t),u(t)},onHover:u,onSelect:function(t){const e=t.detail;t.stopPropagation(),l?(s(no(l,e)),c(void 0),r(Sn(e)),n.dispatch()):(c(e),o(Sn(e)))}})})},{props:{...Gn,tentative:{type:String,value:""}},styles:Yn});customElements.define("calendar-range",oo);const ro=Oi(t=>{const[e,s]=function(t){const[e="",s]=Fi(t);return[Ni(()=>{const t=[];for(const s of e.trim().split(/\s+/)){const e=In(Mn,s);e&&t.push(e)}return t},[e]),t=>s(t.join(" "))]}("value"),[a=e[0],i]=An("focusedDate"),n=Xn({...t,focusedDate:a,setFocusedDate:i});return pn("host",{shadowDom:!0,focus:n.focus,children:pn(jn,{...t,...n,type:"multi",value:e,onSelect:function(t){const a=[...e],i=e.findIndex(e=>e.equals(t.detail));i<0?a.push(t.detail):a.splice(i,1),s(a),n.dispatch()}})})},{props:Gn,styles:Yn});customElements.define("calendar-multi",ro);Bs([{name:"gg-stepper-form-control",component:class extends aa{static properties={name:{type:String},value:{type:Number},min:{type:Number},max:{type:Number}};connectedCallback(){super.connectedCallback(),this.className="content-form__control content-form__control--stepper"}render(){return this._html`
-
${this.value}
=this.max}>+
`}_updateValue(t){return()=>{let e=this.value+t;void 0!==this.min&ðis.max&&(e=this.max),this.value=e,this.dispatchEvent(new Event("change",{bubbles:!0}))}}}}]),Bs([{name:"gg-hotel-search-date-modal",component:class extends aa{static properties={checkInDate:{attribute:!1},checkOutDate:{attribute:!1},onClose:{attribute:!1},onSubmit:{attribute:!1}};connectedCallback(){super.connectedCallback(),this.className="modal-dialog modal-dialog--open",this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true")}render(){return this._html`
`}_handleFormSubmit(t){if(t.preventDefault(),!this.onSubmit)return;let[e,s]=this.querySelector("calendar-range").value.split("/");e&&e==s&&(s=jt(e).add(1,"day").format("YYYY-MM-DD")),this.onSubmit({checkInDate:e,checkOutDate:s})}}},{name:"gg-hotel-search-rooms-modal",component:class extends aa{static properties={rooms:{attribute:!1},onClose:{attribute:!1},onSubmit:{attribute:!1},_rooms:{state:!0}};_childAgeOptions=Array.from({length:18},(t,e)=>e);constructor(){super(),this._rooms=[{numAdults:1,childrenAges:[]}]}connectedCallback(){super.connectedCallback(),this.className="modal-dialog modal-dialog--open",this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.rooms?.length&&(this._rooms=this.rooms.map(t=>({numAdults:t.numAdults||1,childrenAges:t.childrenAges.slice()||[]})))}render(){return this._html`
`}_handleAddRoomClick(){this._rooms.length>=4||(this._rooms=[...this._rooms,{numAdults:1,childrenAges:[]}])}_handleRemoveRoomClick(t){if(this._rooms.length<=1)return;const e=t.target.closest(".content-form__section[data-room-section]"),s=parseInt(e.getAttribute("data-room-section"),10);this._rooms=this._rooms.filter((t,e)=>e!=s)}_handleFormChange(t){const e=this.querySelectorAll(".content-form__section[data-room-section]");this._rooms=Array.from(e).map((t,e)=>{const s=t.querySelector('gg-stepper-form-control[name="adults"]'),a=parseInt(s.value,10)||1,i=t.querySelector('gg-stepper-form-control[name="children"]'),n=parseInt(i.value,10)||0,o=t.querySelectorAll(".content-form__field[data-child-age-field]"),r=Array.from(o).map((t,e)=>{const s=t.querySelector(`select[name="child_age_type_${e}"]`);return parseInt(s.value,10)||0});if(r.length=2){const e=this.images.slice(0,5);t=this._html`
${e.map((t,e)=>{const s="string"==typeof t?t:t.md;return Da(this._html,s,this.theme?.imgCdnDomain,{alt:`Mosaic image ${e+1}`,className:"image-slider__mosaic-image",onClick:()=>this._scrollTo(e+1)})})}
`}return this._html`
${t}
${this.images.map((t,e)=>{const s="string"==typeof t?t:t.md,a="object"==typeof t&&"unsplash"===t.source&&t.attribution;return this._html`
${Da(this._html,s,this.theme?.imgCdnDomain,{alt:`Slide image ${e+1}`,className:"image-slider__slide-image"})}
${a?this._attributionTemplate(t.attribution):""}
`})}
this._offsetScroll(-1)}">
this._offsetScroll(1)}">
`}_attributionTemplate(t){return this._html`
`}updated(t){this._curSlideIndex=0,this._offsetScroll(0),t.has("images")&&this.images?.length&&this._trackUnsplashImageViews()}_trackUnsplashImageViews(){const e=[];for(const t of this.images)if("object"==typeof t&&"unsplash"===t.source&&t.attribution){const s=Ja(t);s&&!this._trackedPhotoIds.has(s)&&(e.push(s),this._trackedPhotoIds.add(s))}e.length>0&&function(e){if(!e||0===e.length)return;const s=[...new Set(e.filter(t=>t))];if(0!==s.length)for(let e=0;e{})}}(e)}_handleSlideListTouchStart(t){this._touchStartX=t.touches[0].clientX,this._touchStartY=t.touches[0].clientY,this._swipeDir=null}_handleSlideListTouchMove(t){if(this._swipeDir)return;const e=t.touches[0].clientX-this._touchStartX,s=t.touches[0].clientY-this._touchStartY;Math.abs(e)>Math.abs(s)?(t.preventDefault(),this._swipeDir="x"):Math.abs(s)>Math.abs(e)&&(this._swipeDir="y")}_handleSlideListTouchEnd(t){if("x"!=this._swipeDir)return;const e=t.changedTouches[0].clientX-this._touchStartX;Math.abs(e)>5&&this._offsetScroll(e>0?-1:1)}_scrollTo(t){const e=this.__("slide-list"),s=e.children.length-1,a=Math.min(s,Math.max(0,t));if(a!=this._curSlideIndex){const t=e.children[a];e.scrollTo({left:t.offsetLeft,behavior:"smooth"}),this._curSlideIndex=a}this.__("nav-button--prev").disabled=0==this._curSlideIndex,this.__("nav-button--next").disabled=this._curSlideIndex==s}_offsetScroll(t){this._scrollTo(this._curSlideIndex+t)}}},{name:"gg-place-hotel-search",component:class extends aa{static properties={placeAddress:{attribute:!1},placeProviders:{attribute:!1},entityId:{attribute:!1},cardTemplate:{attribute:!1},_request:{state:!0},_hasResultProvider:{state:!1},_isLoading:{state:!0},_error:{state:!0},_result:{state:!0}};_placeSearchAction=null;_modalRoot=null;constructor(){super(),this.className="place-search__wrapper",this._request=null,this._hasResultProvider=!1,this._isLoading=!1,this._error=null,this._result=null}render(){if(!this._hasResultProvider)return this._html``;let t="place-search";this._result?.provider&&(t+=` place-search__${this._result.provider}`),this._isLoading&&(t+=" place-search--loading");let e=null,s=null,a=null;if(this._request){const t=[];this._request.checkInDate&&t.push(this._formatDate(this._request.checkInDate)),this._request.checkOutDate&&t.push(this._formatDate(this._request.checkOutDate)),t.length&&(s=t.join(" — "));let e=0,i=0;if(this._request.rooms.length)for(const t of this._request.rooms)e+=t.numAdults||0,i+=t.childrenAges?.length||0;e>0&&(a=`${e} ${1==e?this.labels.placeWindow.adult:this.labels.placeWindow.adults}`,i>0&&(a+=`, ${i} ${1==i?this.labels.placeWindow.child:this.labels.placeWindow.children}`))}if(this._result)e=this._html`
${this._result.roomName?this._html`
${this._result.roomName}
`:""}
${this.labels.placeWindow.hotelBookLabel}
${this._result.priceValue?this._html`
${this._result.priceValue} ${this.labels.placeWindow.hotelPriceLabel}
`:""}
`;else if(this._request){let t="",s=null;"server"==this._error?.type?(t=this._html`
${this.labels.placeWindow.searchAltLabel}
`,s=this._error.message):(t=this._html`
${this._isLoading?this._html` `:""}${this.labels.placeWindow.hotelSearchLabel}
`,"network"==this._error?.type&&(s=this.labels.placeWindow.errorMessage)),e=this._html`
`}return this._html`
${this.labels.placeWindow.bookLabel}
${e}
`}updated(t){t.has("cardTemplate")&&(this.cardTemplate.request&&(this._request={...this.cardTemplate.request}),this._placeSearchAction&&this._placeSearchAction.cancel(),this._placeSearchAction=null,this._isLoading=!1,this._error=null,this.cardTemplate.bookUrl?this._result={provider:this.cardTemplate.provider||null,roomName:this.cardTemplate.roomName||null,priceValue:this.cardTemplate.priceValue||null,bookUrl:this.cardTemplate.bookUrl||null}:this._result=null),t.has("placeProviders")&&(this._request||(this._request={checkInDate:jt().add(30,"day").format("YYYY-MM-DD"),checkOutDate:jt().add(31,"day").format("YYYY-MM-DD"),rooms:[{numAdults:2,childrenAges:[]}]}),this._hasResultProvider=this._isProviderAvailable())}_isProviderAvailable(){return!!this.placeProviders?.kayak?.length||(!!this.placeProviders?.vio?.length||(!!this.placeProviders?.ripe?.length||void 0))}_handleHotelSearchDateControlClick(){this.context._openModal("gg-hotel-search-date-modal",{attributes:{checkInDate:this._request.checkInDate,checkOutDate:this._request.checkOutDate},onSubmit:t=>{this._updateRequest(t)}})}_handleHotelSearchRoomsControlClick(){this.context._openModal("gg-hotel-search-rooms-modal",{attributes:{rooms:this._request.rooms},onSubmit:t=>{this._updateRequest(t)}})}_updateRequest(t){const e={...this._request,...t};JSON.stringify(e)!==JSON.stringify(this._request)&&(this._request=e,this._isLoading=!1,this._error=null,this._result=null)}_handleHotelSearchSubmitClick(){this._placeSearchAction=this._query("place.hotel-search",{entityId:this.entityId,query:this._request},t=>{t.data&&(this._result=t.data)})}_handleHotelSearchQuestionSubmitClick(){const t=[];this._request.rooms.forEach(e=>{let s=`a room for ${e.numAdults} ${1==e.numAdults?"adult":"adults"}`;if(e.childrenAges.length){const t=e.childrenAges.map(t=>`aged ${t}`).join(" and ");s+=` and ${e.childrenAges.length} ${1==e.childrenAges.length?"child":"children"} ${t}`}t.push(s)});const e=`Find me hotels near ${this.placeAddress} from ${this._formatDate(this._request.checkInDate)} to ${this._formatDate(this._request.checkOutDate)} with ${t.join(" and ")}`;this.context.chat.sendMessage({body:e})}_formatDate(t){const e=jt(t);return e.year()===jt().year()?e.toDate().toLocaleDateString(void 0,{month:"short",day:"numeric"}):e.toDate().toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}}},{name:"gg-place-tour-search",component:class extends aa{static properties={placeProviders:{attribute:!1},cardTemplate:{attribute:!1}};constructor(){super(),this.className="place-search__wrapper"}render(){return this._html`
${this.labels.placeWindow.bookLabel}
${this.cardTemplate.duration?this._html`
${this.cardTemplate.duration}
`:""}
${this.cardTemplate.address?this._html`
${this.cardTemplate.address}
`:""}
${this.labels.placeWindow.bookLabel}
${this.cardTemplate.priceValue?this._html`
${this.cardTemplate.priceValue} ${this.cardTemplate.priceLabel}
`:""}
`}}}]);Bs([{name:"gg-content-status",component:ia},{name:"gg-place-window-content",component:class extends aa{static properties={place:{attribute:!1},cardType:{attribute:!1},entityType:{attribute:!1},cardTemplate:{attribute:!1},mapMarker:{attribute:!1},isFavorited:{attribute:!1}};_blockName="place-window";_mapInteractionAllowed=!1;_abort=null;constructor(){super(),this.className="place-window__content"}connectedCallback(){super.connectedCallback();const t=this._scrollKey();if(t){const e=this._read(t);e>0&&(this.scrollTop=e,requestAnimationFrame(()=>{this.scrollTop=e}))}this._abort=new AbortController;const{signal:e}=this._abort;this.addEventListener("scroll",()=>{const t=this._scrollKey();t&&this._save(t,0|this.scrollTop)},{passive:!0,signal:e})}disconnectedCallback(){super.disconnectedCallback();const t=this._scrollKey();t&&this._save(t,0|this.scrollTop),this._abort?.abort(),this._abort=null}_scrollKey(){const t=this.cardType||"place",e=this.place?.id||this.cardTemplate.place.id;return e?`gg:place-window:scroll:${t}:${e}`:null}_read(t){try{const e=this.context?.store?.state?.scroll?.placeInfo?.[t];return Number.isFinite(e)?e:0}catch{return 0}}_save(t,e){try{const s=this.context?.store;if(!s)return;s.update(s=>{s.scroll??={placeInfo:{}},s.scroll.placeInfo??={},s.scroll.placeInfo[t]=Math.max(0,0|e)})}catch{}}render(){const t=this._overviewSectionTemplate(),e=this._reviewSectionTemplate();let s="";return"hotel-card"===this.cardType||"business-card"===this.cardType&&"lodging"===this.cardTemplate?.businessType?s=this._html`
`:"tour-card"==this.cardType&&(s=this._html`
`),this._html`
${this.place.name}${this._favoriteButtonTemplate()}
${this._introMetaListTemplate()}
${this._featureSliderTemplate()}
${s}
${t&&e?this._html`
${this.labels.placeWindow.sectionOverview}
${this.labels.placeWindow.sectionReviews}
`:""}
${t}
${e}
`}updated(t){if(this.place){if(this.__("section-nav")){const t=this.__("section-nav").offsetHeight,e=this.offsetHeight;let s=Math.floor(100*(t/e-1));const a=["overview"];Number.isNaN(s)&&(s=-100);const i=new IntersectionObserver(t=>{t.forEach(t=>{const e=t.target.dataset.section;if(t.isIntersecting)a.includes(e)||(a.push(e),this._selectSectionButton(e));else{a[a.length-1]==e&&a.length>1&&(a.pop(),this._selectSectionButton(a[a.length-1]))}})},{root:this,rootMargin:`0px 0px ${s}% 0px`}),n=this.__all("section-button");for(const t of n){const e=t.dataset.section,s=this.__(`section[data-section="${e}"]`);s&&i.observe(s),t.onclick=()=>{this._selectSectionButton(e),this._scrollToSection(e)}}}this.__all("clamper").forEach(t=>{const e=t.querySelector(".place-window__clamp-text"),s=t.querySelector("button");e.scrollHeight>e.clientHeight?(s.style.display=null,s.onclick=()=>{t.classList.toggle("place-window__clamper--expanded"),s.style.display="none"}):s.style.display="none"}),this.__all("quick-reply-button").forEach(t=>{t.onclick=()=>{const e=t.dataset.message;this.context.chat.sendMessage({body:e,entityId:this.place.entityId}),this.context.analytics.track({name:"quick-reply-clicked",params:{title:"Entity Quick Reply",entityId:this.place.entityId,button_text:e}})}}),this.__all("booking-button").forEach(t=>{t.onclick=t=>{t.preventDefault(),this._handleBookingClick()}})}}_selectSectionButton(t){this.__all("section-button").forEach(e=>{e.classList.toggle("place-window__section-button--selected",e.dataset.section==t)})}_scrollToSection(t){const e=this.__(`section[data-section="${t}"]`);e&&this.scrollTo({top:e.offsetTop-this.__("section-nav").offsetHeight,behavior:"smooth"})}_favoriteButtonTemplate(){if(!this.theme.withFavorites)return;let t="action-button action-button--sm action-button--favorite place-window__favorite-button",e=this.labels.placeWindow.saveButton;return this.isFavorited&&(t+=" action-button--active",e=this.labels.placeWindow.savedButton),this._html`
${e}
`}_handleFavoriteButtonClick(){this._query("favorites.toggle",{cardId:this.cardTemplate.id})}_introMetaListTemplate(){const t=[];if(("venue"===this.entityType||"venue-card"===this.cardType)&&this.place.venueType&&t.push(this._html`${this.place.venueType} `),this.place.rating&&t.push(this._html`${se(this.place.rating,5)} `),this.place.priceLevel&&t.push(this._html`${ee(this.place.priceLevel)} `),t.length)return this._html`${t}
`}_featureSliderTemplate(){if(this.place.images?.length)return this._html`
`}_mapTemplate(){if(!this.mapMarker)return;const t=this._getDirectionsUrl(this.mapMarker.position.lat,this.mapMarker.position.lng,this.place.placeId,this.place.name),e={lat:this.mapMarker.position.lat,lng:this.mapMarker.position.lng,type:this.mapMarker.type||"",title:this.mapMarker.title||"",tooltip:this.mapMarker.tooltip||""};this.mapMarker.viewport&&(e.lowLat=this.mapMarker.viewport.low.latitude,e.lowLng=this.mapMarker.viewport.low.longitude,e.highLat=this.mapMarker.viewport.high.latitude,e.highLng=this.mapMarker.viewport.high.longitude);const s=a(`/simple-map.html?${new URLSearchParams(e)}`);return this._html`
${this.labels.placeWindow.location}
${this.place.address?this._html`
${this.place.address}
`:""}
`}_overviewSectionTemplate(){const t=this._descriptionTemplate(),e=this._quickRepliesTemplate(),s=this._mapTemplate(),a=this._infoListTemplate(),i="venue"===this.entityType||"venue-card"===this.cardType,n=i?this._venueAddressTemplate():"",o=i?this._venueContactTemplate():"",r=i?this._venueCapacityAndRoomsTemplate():"",l=i?this._venueAccommodationTemplate():"",c=i?this._venueRestaurantTemplate():"",d=i?this._venueAmenitiesTemplate():"",h=i?this._venueFloorPlansTemplate():"";if(t||e||a||s||r)return this._html`
${t}
${n}
${o}
${r}
${l}
${c}
${h}
${d}
${i?"":a}
${e}
${s}
`}_descriptionTemplate(){const t=this.place.summary||this.place.description;if(t)return this._html`
${this._nlToParagraph(t)}
${this.labels.placeWindow.showMore}
`}_venueAddressTemplate(){if(this.place.address)return this._html`
`}_venueContactTemplate(){const t=[];if(this.place.webUrl&&t.push(this._html`
`),this.place.phone&&t.push(this._html`
`),this.place.email&&t.push(this._html`
`),t.length)return this._html`${t}
`}_venueAmenitiesTemplate(){if(this.place.amenities?.length)return this._html`
${this.labels.placeWindow.amenities||"Amenities"}
${this.place.amenities.map(t=>this._html`
${t}
`)}
`}_venueCapacityAndRoomsTemplate(){const t=this.place.capacity,e=t?.max_seated||t?.max_standing,s=this.place.rooms?.length>0;if(!e&&!s)return;const a=[];return t?.max_seated&&a.push(this._html`
${t.max_seated.toLocaleString()}
${this.labels.placeWindow.capacitySeated||"seated"}
`),t?.max_standing&&a.push(this._html`
${t.max_standing.toLocaleString()}
${this.labels.placeWindow.capacityStanding||"standing"}
`),this._html`
${this.labels.placeWindow.meetingSpaces||"Meeting Spaces"}
${a.length?this._html`
${a}
`:""}
${s?this._html`
${this.place.rooms.map(t=>this._venueRoomTemplate(t))}
`:""}
`}_venueRoomTemplate(t){const e=t.maxCapacity||this._getRoomMaxCapacity(t),s=t.name||this.place.venueType||"",a=[];t.sqft&&a.push(`${t.sqft.toLocaleString()} sqft`),t.sqm&&a.push(`${Math.round(t.sqm).toLocaleString()} sqm`);const i=a.join(" / ");return this._html`
${s}
${i?this._html`${i} `:""}
${e?this._html`
${this.labels.placeWindow.maxCapacity||"Max"} ${e.toLocaleString()} `:""}
`}_getRoomMaxCapacity(t){if(!t.capacity)return null;const e=Object.values(t.capacity).filter(t=>"number"==typeof t);return e.length?Math.max(...e):null}_venueFloorPlansTemplate(){if(this.place.floorPlans?.length)return this._html`
${this.labels.placeWindow.floorPlans||"Floor Plans"}
`}_venueAccommodationTemplate(){const t=this.place.accommodation;if(!t?.sleeping_rooms)return;const e=[];return t.sleeping_rooms&&e.push({label:this.labels.placeWindow.guestRooms||"Guest Rooms",value:t.sleeping_rooms}),t.suites&&e.push({label:this.labels.placeWindow.suites||"Suites",value:t.suites}),t.ada_rooms&&e.push({label:this.labels.placeWindow.adaRooms||"ADA Rooms",value:t.ada_rooms}),e.length?this._html`
${this.labels.placeWindow.accommodation||"Accommodation"}
${e.map(t=>this._html`
${t.value.toLocaleString()}
${t.label}
`)}
`:void 0}_venueRestaurantTemplate(){const t=this.place.restaurantDetails;if(!t)return;const e=[];return t.cuisine&&e.push({icon:"cuisine",text:t.cuisine}),t.private_dining&&e.push({icon:"private",text:this.labels.placeWindow.privateDining||"Private Dining"}),t.outdoor_dining&&e.push({icon:"outdoor",text:this.labels.placeWindow.outdoorDining||"Outdoor Dining"}),t.buyout_available&&e.push({icon:"buyout",text:this.labels.placeWindow.buyoutAvailable||"Full Buyout Available"}),e.length?this._html`
${this.labels.placeWindow.diningDetails||"Dining"}
${e.map(t=>this._html`
${t.text}
`)}
`:void 0}_quickRepliesTemplate(){if(this.place.quickReplies?.length)return this._html`
${this.labels.placeWindow.keepExploring}
${this.place.quickReplies.map((t,e)=>this._html`
${t.question_long}
`)}
`}_infoListTemplate(){const t=[];this.place.duration&&t.push(this._html`
${this.labels.placeWindow.duration}
${this.place.duration}
`),this.place.address&&t.push(this._html`
`);const e=this._infoHoursTemplate();if(e&&t.push(e),this.place.webUrl&&t.push(this._html`
`),this.place.phone&&t.push(this._html`
`),t.length)return this._html`${t}
`}_infoHoursTemplate(){if("tour-card"===this.cardType)return;if("CLOSED_PERMANENTLY"===this.place?.businessStatus||"CLOSED_TEMPORARILY"===this.place?.businessStatus){const t="CLOSED_PERMANENTLY"===this.place?.businessStatus?this.labels.placeWindow.closedPermanently||"Permanently Closed":this.labels.placeWindow.closedTemporarily||"Temporarily Closed",e="place-window__info place-window__info--hours",s="place-window__info-status-now";return this._html`
${t}
`}if(!this.place?.openPeriods||!this.place?.timeZone)return;const t=te(this.place.openPeriods,this.place.timeZone);if(!t)return;let e=null,s=null;t.isOpen?(e=this.labels.placeWindow.openNow,s=this.labels.placeWindow.openChange):(e=this.labels.placeWindow.closedNow,s=this.labels.placeWindow.closedChange),e&&s&&(s=t.changeDate?s.replace("{{date}}",t.changeDate.format("h:mm A")):"");let a="place-window__info place-window__info--hours",i="place-window__info-status-now";t.isOpen&&(i+=" place-window__info-status-now--open");const n=s?this._html`${s} `:"",o=function(t,e){if(!t?.length||!e)return[];if(1==t.length&&t[0].open&&!t[0].close)return[];const s=[{label:"Sunday",hourLabels:[]},{label:"Monday",hourLabels:[]},{label:"Tuesday",hourLabels:[]},{label:"Wednesday",hourLabels:[]},{label:"Thursday",hourLabels:[]},{label:"Friday",hourLabels:[]},{label:"Saturday",hourLabels:[]}];for(const a of t){const t=jt().tz(e).hour(a.open.hour).minute(a.open.minute).second(0).format("h:mm A"),i=jt().tz(e).hour(a.close.hour).minute(a.close.minute).second(0).format("h:mm A");s[a.open.day].hourLabels.push(`${t} - ${i}`)}for(const t of s)t.hourLabels.length||t.hourLabels.push("closed");const a=jt().tz(e||"local").day(),i=[];for(let t=0;t
${o.map(t=>this._html`${t.label} ${t.hourLabels.join(", ")} `)}
`),this._html`
${e} ${n}
${r}
`}_reviewSectionTemplate(){if(this.place.rating&&this.place.reviews?.length)return this._html`
${this.place.reviewSummary?this._html`
${this.labels.placeWindow.reviewsSay}
${this.place.reviewSummary}
`:""}
${null!=this.place.rating?this._html`
${this.place.rating.toFixed(1)}
${this.place.numRatings} ${this.labels.placeWindow.reviews}
`:""}
${this.place.reviews.length?this._html`
${this.labels.placeWindow.mostHelpfulReviews}
${this.place.reviews.map(this._reviewTemplate.bind(this))}
`:""}
`}_reviewTemplate(t){const e=Math.round(t.rating/5*100);let s="place-window__review";return"google"==t.source&&(s+=" place-window__review--google"),this._html`
${this._nlToParagraph(t.content)}
${this.labels.placeWindow.showMore}
`}_getMapUrl(t,e){const s=encodeURIComponent(t),a=e?encodeURIComponent(e):"";return`https://maps.google.com/?q=${a?a+",":""}${s}`}_getDirectionsUrl(t,e,s,a){let i="https://www.google.com/maps/dir/?api=1";return null!=t&&null!=e&&(i+=`&destination=${t},${e}`),s&&(i+=`&destination_place_id=${s}`),!a||t&&e||(i+=`&destination=${encodeURIComponent(a)}`),i}_handleDirectionsClick(){this.context.analytics.track({name:"place-window-directions-clicked",params:{card_type:this.cardType,place_id:this.cardTemplate.place.id,title:`Clicked Get Directions: ${this.place.name}`,url:window.location.href,button_text:"Get directions"}})}_handleBookingClick(){const t="tour-card"===this.cardType?"Reserve Tour":"Reserve Room";this.context.analytics.track({name:"place-window-booking-clicked",params:{card_type:this.cardType,place_id:this.cardTemplate.place.id,title:`Clicked ${t}: ${this.place.name}`,url:window.location.href,button_text:t}}),this.place.bookUrl&&window.open(this.place.bookUrl,"_blank")}_handleMapClick(){this._mapInteractionAllowed||(this._mapInteractionAllowed=!0,this.__("map-frame").classList.remove("place-window__map-frame--disabled"))}_handleMapMouseLeave(){this._mapInteractionAllowed=!1,this.__("map-frame").classList.add("place-window__map-frame--disabled")}}}]);class lo extends aa{static properties={target:{attribute:!1},popupAlign:{attribute:!1},onClose:{attribute:!1},onSubmit:{attribute:!1}};connectedCallback(){if(super.connectedCallback(),this.className="modal-dialog modal-dialog--open",this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this._handleRootClick=this._handleRootClick.bind(this),this.addEventListener("click",this._handleRootClick),this.target&&!Ft()){this.className+=" modal-dialog--popup";const t=this.target.getBoundingClientRect(),e=this.offsetParent.getBoundingClientRect();if(this.style.setProperty("--modal-dialog-popup-top",t.bottom-e.top+4+"px"),"left"===this.popupAlign){this.className+=" modal-dialog--popup-left";const s=t.left-e.left;this.style.setProperty("--modal-dialog-popup-left",`${s}px`),this._popupLeft=s}else{const s=e.right-t.right;this.style.setProperty("--modal-dialog-popup-right",`${s}px`),this._popupRight=s}this._parentWidth=e.width}}firstUpdated(){if(!this._parentWidth)return;const t=this.querySelector(".modal-dialog__main");if(!t)return;const e=t.offsetWidth;if(null!=this._popupLeft){const t=this._parentWidth-e-16;this._popupLeft>t&&this.style.setProperty("--modal-dialog-popup-left",`${Math.max(16,t)}px`)}else if(null!=this._popupRight){const t=this._parentWidth-e-16;this._popupRight>t&&this.style.setProperty("--modal-dialog-popup-right",`${Math.max(0,t)}px`)}}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleRootClick)}_handleRootClick(t){t.target===this&&this.onClose()}}class co extends lo{static properties={...lo.properties,_conversations:{state:!0},_activeId:{state:!0},_searchQuery:{state:!0}};constructor(){super(),this._conversations=[],this._activeId=null,this._searchQuery=""}connectedCallback(){super.connectedCallback(),this._observe(t=>{this._conversations=t.conversations,this._activeId=t.api.conversationId},["conversations","api.conversationId"])}render(){let t=[...this._conversations].sort((t,e)=>(e.id===this._activeId)-(t.id===this._activeId));if(this._searchQuery.trim()){const e=this._searchQuery.trim().split(" "),s=new RegExp("^(?=.*(?:^| )"+e.join(")(?=.*(?:^| )")+")","gmi");t=t.filter(t=>{const e=(t.title||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"");return s.lastIndex=0,s.test(e)})}let e="";if(this._conversations.length){let s="";t.length&&(s=this._html`
${t.map(t=>this._html`
this._handleSelect(t)}">
${t.title}
`)}
`),e=this._html`
${s}
`}return this._html`
${e}
`}_handleNewChat(){this._query("conversations.create",{},t=>{t.data&&(this.context.analytics.track({name:"chat-created",params:{conversation_id:t.data.id}}),this.context.chat.switchConversation(t.data))}),this.onClose()}_handleSelect(t){t.id!==this._activeId&&(this.context.analytics.track({name:"chat-selected",params:{conversation_id:t.id,search_query:this._searchQuery||void 0}}),this.context.chat.switchConversation(t)),this.onClose()}_handleMenuClick(t,e){t.stopPropagation(),this.context.analytics.track({name:"chat-menu-opened",params:{conversation_id:e.id}}),this.context._openModal("gg-conversation-menu-modal",{attributes:{target:t.currentTarget},onSubmit:({action:t})=>{"rename"===t?this._openRenameModal(e):"delete"===t&&this._openDeleteModal(e)}})}_openRenameModal(t){this.context.analytics.track({name:"chat-rename-opened",params:{conversation_id:t.id}}),this.context._openModal("gg-conversation-edit-modal",{attributes:{conversationTitle:t.title},onSubmit:({title:e})=>{this.context.analytics.track({name:"chat-renamed",params:{conversation_id:t.id}}),this._query("conversations.rename",{id:t.id,title:e})}})}_openDeleteModal(t){this.context.analytics.track({name:"chat-delete-opened",params:{conversation_id:t.id}}),this.context._openModal("gg-confirm-modal",{attributes:{headline:this.labels.common.deleteChat,message:this.labels.conversationDelete.message,confirmLabel:this.labels.common.delete},onSubmit:()=>{this._query("conversations.delete",{id:t.id},e=>{e.error||e.isLoading||(this.context.analytics.track({name:"chat-deleted",params:{conversation_id:t.id}}),this.context.chat.switchConversation(e.data),e.data?.id!==t.id&&this.onClose())})}})}}class ho extends lo{static properties={...lo.properties,conversationTitle:{attribute:!1}};render(){return this._html`
`}_handleSubmit(t){t.preventDefault();const e=new FormData(t.target).get("title").trim();e&&this.onSubmit({title:e})}}class uo extends lo{static properties={...lo.properties,headline:{attribute:!1},message:{attribute:!1},confirmLabel:{attribute:!1}};render(){return this._html`
${this.message}
${this.labels.common.cancel}
${this.confirmLabel}
`}}Bs([{name:"gg-app-header",component:class extends aa{static properties={onMenuClick:{attribute:!1},primaryTab:{attribute:!1},conversationId:{attribute:!1},conversationTitle:{attribute:!1}};constructor(){super(),this.className="app-header",this.onMenuClick=null,this.primaryTab="chat",this.conversationId=null,this.conversationTitle=null}connectedCallback(){super.connectedCallback(),this.theme.logoSize&&this.classList.add(`app-header--${this.theme.logoSize}`)}render(){const e=this.theme.privacyUrl||"https://matadornetwork.com/content/privacypolicy/",s=this.theme.logoUrl||"https://cdn1.matadornetwork.com/guidegeek/a7c48528-b554-48b0-a56b-b78e7349ca5f.png";let a="";return"favorite"===this.primaryTab?a=this._html``:this.conversationTitle&&(a=this._html` `),this._html`
`}_handleBackClick(){this._action("layout.update",{primaryTab:"chat"})}_handleCloseClick(){this._action("layout.update",{isWindowOpen:!1})}_handleMenuClick(){this.onMenuClick&&this.onMenuClick()}}},{name:"gg-app-toolbar",component:class extends aa{static properties={primaryTab:{attribute:!1}};constructor(){super(),this.className="app-toolbar",this.primaryTab="chat"}render(){const e=this.theme.privacyUrl||"https://matadornetwork.com/content/privacypolicy/";let s="app-toolbar__chat-button",a="app-toolbar__favorite-button";"chat"===this.primaryTab?s+=" app-toolbar__chat-button--active":"favorite"===this.primaryTab&&(a+=" app-toolbar__favorite-button--active");const i=[];return this.theme.multiChat&&i.push(this._html`
`),this.theme.withFavorites&&(i.push(this._html`
this._handleTabClick("chat")}">
`),i.push(this._html`
this._handleTabClick("favorite")}">
`)),this._html`
${i}
`}_handleNewChat(){this._query("conversations.create",{},t=>{t.data&&(this.context.analytics.track({name:"chat-created",params:{conversation_id:t.data.id}}),this.context.chat.switchConversation(t.data))})}_handleTabClick(t){this.primaryTab!==t&&this._action("layout.update",{primaryTab:t})}}},{name:"gg-app-menu",component:class extends aa{static properties={primaryTab:{attribute:!1},onClose:{attribute:!1}};constructor(){super(),this.className="app-menu",this.primaryTab="chat",this.onClose=null,this.addEventListener("click",t=>{t.target===this&&this._handleCloseClick()})}render(){const e=this.theme.privacyUrl||"https://matadornetwork.com/content/privacypolicy/",s=this.theme.logoUrl||"https://cdn1.matadornetwork.com/guidegeek/a7c48528-b554-48b0-a56b-b78e7349ca5f.png";let a="app-menu__nav-button app-menu__nav-button--chat",i="app-menu__nav-button app-menu__nav-button--favorite";"chat"===this.primaryTab?a+=" app-menu__nav-button--active":"favorite"===this.primaryTab&&(i+=" app-menu__nav-button--active");const n=[];return this.theme.multiChat&&n.push(this._html`
`),this.theme.withFavorites&&(n.push(this._html`
this._handleNavClick("chat")}">Chat
`),n.push(this._html`
this._handleNavClick("favorite")}">Favorites
`)),this._html`
`}_handleNewChat(){this._query("conversations.create",{},t=>{t.data&&(this.context.analytics.track({name:"chat-created",params:{conversation_id:t.data.id}}),this.context.chat.switchConversation(t.data))}),this.onClose&&this.onClose()}_handleNavClick(t){this._action("layout.update",{primaryTab:t}),this.onClose&&this.onClose()}_handleCloseClick(){this.onClose&&this.onClose()}}},{name:"gg-primary-window",component:class extends aa{static properties={_primaryTab:{state:!0}};constructor(){super(),this.className="primary-window"}connectedCallback(){super.connectedCallback(),this._observe(t=>{this._primaryTab=t.layout.primaryTab},["layout.primaryTab"])}render(){if(!this.theme.withFavorites)return this._html`
`;const t=this._primaryTab||"chat";return this._html`
`}}},{name:"gg-map-window",component:class extends aa{static properties={_isWindowOpen:{state:!0},_isMapExpanded:{state:!0},_answerPhase:{state:!0},_primaryTab:{state:!0},_map:{state:!0},_notificationMessage:{state:!0}};_crossOrigin=null;_isIframeAttached=!1;_isMapReady=!1;_mapLinkHoverTimeout=null;_mapUpdateThrottle=null;_prevMapTotalHidden=0;constructor(){super(),this.className="map-window",this._isWindowOpen=!1,this._isMapExpanded=!1,this._answerPhase=null,this._handleMapSliderChange=this._handleMapSliderChange.bind(this),this._handleMapSliderClick=this._handleMapSliderClick.bind(this)}connectedCallback(){super.connectedCallback(),this._crossOrigin=new Ya({targetOrigin:t.siteUrl}),this._crossOrigin.onMessage("map:ready",()=>{this._isMapReady=!0,this.theme&&this._crossOrigin.message("map.theme",this.theme),this._map&&this._crossOrigin.message("map.update",this._buildMapData())}),this._crossOrigin.onMessage("map:cancel",()=>{this._action("map.cancel")}),this._crossOrigin.onMessage("map:marker-hover-in",t=>{Ft()||this._action("map.highlight",{groupId:t.cardGroupId,cardMode:"pin-preview"})}),this._crossOrigin.onMessage("map:marker-hover-out",t=>{Ft()||this._action("map.unselect")}),this._crossOrigin.onMessage("map:marker-pin-click",t=>{this._action("map.highlight",{groupId:t.cardGroupId,cardMode:Ft()?"slider":"pin-stick"}),Ft()||this._handleMarkerPlaceOpen(t)}),this._crossOrigin.onMessage("map:marker-card-click",t=>{this._action("map.highlight",{groupId:t.cardGroupId,cardMode:Ft()?"slider":"pin-stick"}),this._handleMarkerPlaceOpen(t)}),this._crossOrigin.onMessage("map:favorite-toggle",t=>{this._query("favorites.toggle",{cardId:t.cardId})}),this._observe(t=>{this._isWindowOpen=t.layout.isWindowOpen,this._isMapExpanded=t.layout.isMapExpanded,this._answerPhase=t.chat.answerPhase,this._primaryTab=t.layout.primaryTab},["layout.isWindowOpen","layout.isMapExpanded","chat.answerPhase","layout.primaryTab"]),this._observe(t=>{this._mapMessage("map.theme",t.theme)},["theme"]),this._observe(t=>{if(!t.map.selection.cardElementId){const e=pe(t.map,t.layout.primaryTab),s=this._isFocusedElementHidden(t.map);(e!=this._prevMapTotalHidden||s)&&this._showFilterNotification(e),this._prevMapTotalHidden=e}this._map=t.map,this._cards=t.cards,this._mapMessage("map.update")},["map","cards"]),this._observe(t=>{t.layout.isMapOpen&&this._showFilterNotification(pe(t.map,t.layout.primaryTab))},["layout.isMapOpen"])}disconnectedCallback(){super.disconnectedCallback(),this._crossOrigin.destroy(),this._isIframeAttached=!1,this._isMapReady=!1,clearTimeout(this._mapUpdateThrottle),this._mapUpdateThrottle=null}render(){let t="";if("chat"===this._primaryTab){let e="map-window__menu-button map-window__menu-button--filter";this._map?.chat.filter.categories.length&&(e+=" map-window__menu-button--active"),t=this._html` `}return this._html`
${this._isIframeAttached||this._isWindowOpen?this._html`
`:""}
${t}
${"favorite"!==this._primaryTab?this._html`
`:""}
${this._answerPhase&&"streaming"!==this._answerPhase?this._html`
`:""}
${this._notificationMessage?this._html`
${this._notificationMessage}
${this.labels.mapWindowFilter.showAllButton}
`:""}
${this._cardSliderTemplate()}
`}updated(t){this.classList.toggle("map-window--expanded",this._isMapExpanded),!this._isIframeAttached&&this.__("main iframe")&&(this._crossOrigin.targetWindow=this.__("main iframe").contentWindow,this._isIframeAttached=!0)}_handleNotificationShowAllClick(){this._action("map.update-filter",{filter:{categories:[],locations:[]}}),this._hideFilterNotification()}_isFocusedElementHidden(t){return t?t.selection.focusElementIds.some(e=>!t.selection.visibleElementIds.includes(e)):0}_showFilterNotification(t){t?(this._notificationMessage=this.labels.mapWindow.filterNotification.replace("{{total_hidden}}",t),this.updateComplete.then(()=>this._autoCloseFilterNotification())):this._hideFilterNotification()}_hideFilterNotification(){this._notificationMessage=null}_autoCloseFilterNotification(){clearTimeout(this._notifyTimeout),this._notifyTimeout=setTimeout(()=>{this._hideFilterNotification()},3e3)}_cardSliderTemplate(){const t=[];if(this._map?.selection.sliderElementIds.length)for(const e of this._map.selection.sliderElementIds){const s=this._map.elements[e];if(!s?.cardId||!this._cards?.[s.cardId])continue;const a=this._cards[s.cardId],i={...s,options:{...s.options,card:{type:a.type,template:a.template,isFavorited:a.isFavorited}}};t.push(i)}if(t.length)return this._html`
`}_handleMapSliderChange(t){this._action("map.slider-change",{cardGroupId:t})}_handleMapSliderClick(t){this._handleMarkerPlaceOpen({cardGroupId:t})}_handleCloseClick(){this._action("layout.update",{isMapOpen:!1})}_handleExpandToggleClick(){this._action("layout.update",{isMapExpanded:!this._isMapExpanded})}_handleZoomInClick(){this._mapMessage("map.zoom-in")}_handleZoomOutClick(){this._mapMessage("map.zoom-out")}_handleFilterButtonClick(t){const e=this._map[this._primaryTab].filter,s=function(t,e){const s=ce(t,e),a=t[e].filter,i={};for(const e in t.elements){const n=t.elements[e];s.has(n.group)&&(!a.locations.length||n.locationId&&a.locations.includes(n.locationId))&&n.category&&(i[n.category]||(i[n.category]=0),i[n.category]++)}return i}(this._map,this._primaryTab);this.context._openModal("gg-map-filter-modal",{attributes:{target:t.target,categories:e.categories,categoryCounts:s,markerPrice:e.markerPrice},onSubmit:t=>{this.context.analytics.track({name:"map-filtered",params:t},{skipThirdParty:!0}),this._action("map.update-filter",{filter:t})}})}_handleMarkerPlaceOpen(t){const e=this._map?.groups?.[t.cardGroupId];if(e?.elements?.length){const t=e.elements[0],s=this._map.elements[t],a=this._cards?.[s?.cardId];if(Ua.has(a?.type))return}this._action("layout.update",{isPlaceOpen:t})}_buildMapData(){const t=this._map[this._primaryTab]?.filter,e={};for(const t in this._map.elements){const s=this._map.elements[t].cardId;s&&this._cards[s]&&(e[s]=this._cards[s])}return{defaultLocation:this._map.defaultLocation,elements:this._map.elements,selection:this._map.selection,filter:{markerPrice:t?.markerPrice},cards:e}}_mapMessage(t,e){this._isMapReady&&("map.update"===t?(this._mapUpdateThrottle?clearTimeout(this._mapUpdateThrottle):this._crossOrigin.message("map.update",this._buildMapData()),this._mapUpdateThrottle=setTimeout(()=>{this._mapUpdateThrottle=null,this._crossOrigin.message("map.update",this._buildMapData())},300)):this._crossOrigin.message(t,e))}}},{name:"gg-place-window",component:class extends aa{static properties={_isLoading:{state:!0},_error:{state:!0},_place:{state:!0},_placeEntityType:{state:!0},_card:{state:!0},_mapElement:{state:!0}};_cardId=null;constructor(){super(),this.className="place-window",this._isLoading=!1,this._error=null,this._place=null,this._placeEntityType=null,this._card=null,this._mapElement=null}connectedCallback(){super.connectedCallback(),this._observe(t=>{const e=t.layout.isPlaceOpen?.cardGroupId;if(e){const s=e?.substring(5),a=s!==this._cardId;this._card=t.cards[s],a&&this._card&&!this._isLoading&&(this._cardId=s,this._mapElement=t.map.elements[s],this._loadPlace())}},["layout.isPlaceOpen","cards"]),this._observe(t=>{this._place=t.place,this._placeEntityType=t.placeEntityType},["place","placeEntityType"])}_loadPlace(){const t=this._card.template;this._query("place.load",{place:t.place,entityId:t.entityId})}render(){const t=this._html`
`;let e="";if(this._isLoading||this._error)e=this._html`
`;else if(this._place&&this._card){const t=this._mapElement?{position:this._mapElement.options.position,type:this._mapElement.options.format||"",title:this._mapElement.options.title||"",tooltip:this._mapElement.options.tooltip||"",viewport:this._mapElement.options.viewport}:null;e=this._html`
`}return this._html`
${t}
${e}
`}_handleCloseButtonClick(t){t.preventDefault(),t.stopPropagation(),this._action("layout.update",{isPlaceOpen:!1})}}},{name:"gg-content-status",component:ia},{name:"gg-conversation-menu-modal",component:class extends lo{render(){return this._html`
this.onSubmit({action:"rename"})}">
${this.labels.common.renameChat}
this.onSubmit({action:"delete"})}">
${this.labels.common.deleteChat}
`}}},{name:"gg-conversation-modal",component:co},{name:"gg-conversation-edit-modal",component:ho},{name:"gg-confirm-modal",component:uo},{name:"gg-conversation-title-button",component:class extends aa{static properties={conversationId:{attribute:!1},conversationTitle:{attribute:!1},float:{attribute:!1}};constructor(){super(),this.className="conversation-title-button",this.float=!1}connectedCallback(){super.connectedCallback(),this.float&&this.classList.add("conversation-title-button--float")}render(){return this._html`
${this.conversationTitle}
`}_handleClick(t){this.context.analytics.track({name:"chat-panel-opened",params:{conversation_id:this.conversationId}}),this.context._openModal("gg-conversation-modal",{attributes:{target:t.currentTarget,popupAlign:"left"}})}}}]);const po=new class{inactivityTimer=null;storageKeyGuard="__ggSystemMsgStorageListenerAdded";constructor({getTodayString:t,keys:e}){this.getTodayString=t,this.keys=e,"undefined"==typeof window||window[this.storageKeyGuard]||(window.addEventListener("storage",t=>{t.key!==this.keys.custom&&t.key!==this.keys.followup||t.newValue!==this.getTodayString()||this.clear()}),window[this.storageKeyGuard]=!0)}schedule(t,e){this.clear(),this.inactivityTimer=setTimeout(t,e)}clear(){this.inactivityTimer&&(clearTimeout(this.inactivityTimer),this.inactivityTimer=null)}}({getTodayString:()=>(new Date).toISOString().split("T")[0],keys:{custom:"gg-custom-message-date",followup:"gg-followup-message-date"}});Bs([{name:"gg-app-window",component:class extends aa{static properties={_isLoading:{state:!0},_error:{state:!0},_isWindowOpen:{state:!0},_isWindowOpening:{state:!0},_isPlaceOpen:{state:!0},_primaryTab:{state:!0},_isMenuOpen:{state:!0},_conversationId:{state:!0},_conversationTitle:{state:!0}};_modalNode=null;constructor(){super(),this.className="app-window",this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.setAttribute("aria-label","AI Travel Assistant"),this._isLoading=!0,this._error=null,this._isWindowOpen=!1,this._isWindowOpening=!1,this._isPlaceOpen=!1,this._primaryTab="chat",this._isMenuOpen=!1,this._conversationId=null,this._conversationTitle=null}connectedCallback(){super.connectedCallback(),this._observe(t=>{"error"==t.api.httpStatus?(this._isLoading=!1,this._error={message:this.labels.appWindow.connectionFatalError}):"connected"==t.api.httpStatus?(this._isLoading=!1,this._error=null,this._query("conversations.load")):(this._isLoading=!0,this._error=null)},["api.httpStatus","api.socketStatus"]),this._observe(t=>{this._conversationId=t.api.conversationId,this._conversationTitle=t.api.conversationTitle},["api.conversationId","api.conversationTitle"]),this._observe(t=>{t.layout.isWindowOpen!=this._isWindowOpen&&(this._isWindowOpen=!1,this._isWindowOpening=t.layout.isWindowOpen),this._isPlaceOpen=t.layout.isPlaceOpen,this._primaryTab=t.layout.primaryTab},["layout.isWindowOpen","layout.isPlaceOpen","layout.primaryTab"]),this.context._openModal=(t,e)=>{if(!this._modalNode)return;const s=document.createElement(t);Object.assign(s,e.attributes),s.onClose=()=>{e.onClose&&e.onClose(),this._modalNode.removeChild(s)},s.onSubmit=t=>{e.onSubmit&&e.onSubmit(t),this._modalNode.removeChild(s)},this._modalNode.appendChild(s)}}render(){let t="",e="";"contain"!=this.theme.layout&&(t=this._html`
this._isMenuOpen=!0}>
`,this._isMenuOpen&&(e=this._html`
this._isMenuOpen=!1}>
`));let s="";if(this._isLoading||this._error)s=this._html`
`;else{let t="";this._isPlaceOpen&&(t=this._html` `),s=this._html`
${t}
`}return this._html`
${t}
${s}
${e}
`}firstUpdated(){this._modalNode=this.querySelector(".app-window__modal")}updated(t){this.classList.toggle("app-window--opening",this._isWindowOpening),this.classList.toggle("app-window--open",this._isWindowOpen),this._isWindowOpening&&requestAnimationFrame(()=>{this._isWindowOpen=!0,this._isWindowOpening=!1})}}},{name:"gg-chat-toggle",component:class extends aa{static properties={layout:{attribute:!1},_isIcebreakersScrollGood:{state:!0},_isIcebreakersDelayDone:{state:!0},_areIcebreakersClosed:{state:!0}};constructor(){super(),this.className="chat-toggle",this._handleWindowScroll=this._handleWindowScroll.bind(this),this._handleWindowResize=this._handleWindowResize.bind(this),this._isIcebreakersScrollGood=!1,this._isIcebreakersDelayDone=!1,this._areIcebreakersClosed=!1,this._icebreakerDelayTimer=null}connectedCallback(){super.connectedCallback(),window.addEventListener("scroll",this._handleWindowScroll,{passive:!0}),window.addEventListener("resize",this._handleWindowResize,{passive:!0}),this._handleWindowScroll()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("scroll",this._handleWindowScroll),window.removeEventListener("resize",this._handleWindowResize),this._icebreakerDelayTimer&&(clearTimeout(this._icebreakerDelayTimer),this._icebreakerDelayTimer=null)}_handleWindowScroll(){if(!this.theme.icebreakerPageDepth)return;const t=parseInt(this.theme.icebreakerPageDepth||0,10)/100,e=document.documentElement.scrollTop/(document.documentElement.scrollHeight-document.documentElement.clientHeight);this._isIcebreakersScrollGood=e>t}_handleWindowResize(){this.requestUpdate()}render(){let t="";const e=this._getCurrentToggleStyle();e&&("bookmark"!==e&&"island"!==e&&"dock"!==e||(t=this.theme.toggleText));const s=this.theme.showIntroText&&!this.layout?.isIntroClosed,a=this._isIcebreakersVisible()&&!this._areIcebreakersClosed;return this._html`
${s?this._introTemplate():""}
${a?this._icebreakersTemplate():""}
${t}
`}updated(t){const e=this._getCurrentToggleStyle();this.classList.toggle("chat-toggle--closed",this.layout.isWindowOpen),this.classList.toggle("chat-toggle--default","default"==e),this.classList.toggle("chat-toggle--dock","dock"==e),this.classList.toggle("chat-toggle--island","island"==e),this.classList.toggle("chat-toggle--bookmark","bookmark"==e),this.classList.toggle("chat-toggle--xlarge","xlarge"===this.theme.toggleIconSize),this.classList.toggle("chat-toggle--large","large"===this.theme.toggleIconSize),this.classList.toggle("chat-toggle--small","small"===this.theme.toggleIconSize),this._isIcebreakersDelayDone||(this.theme.icebreakerDelay?(this._icebreakerDelayTimer&&clearTimeout(this._icebreakerDelayTimer),this._icebreakerDelayTimer=setTimeout(()=>{this._isIcebreakersDelayDone=!0,this._icebreakerDelayTimer=null},1e3*this.theme.icebreakerDelay)):this._isIcebreakersDelayDone=!0),!1===this._isIcebreakersScrollGood&&(this.theme.icebreakerPageDepth?this._handleWindowScroll():this._isIcebreakersScrollGood=!0)}_isIcebreakersVisible(){return(!(window.innerWidth<768)||!this.theme.hideIcebreakersOnMobile)&&(this.theme.icebreakersEnabled&&this.theme.icebreakers?.length&&this._isIcebreakersScrollGood&&this._isIcebreakersDelayDone)}_getCurrentToggleStyle(){return window.innerWidth<768&&this.theme.toggleStyleMobile?this.theme.toggleStyleMobile:this.theme.toggleStyle||"default"}_introTemplate(){return this._html`
${this.theme.showIntroTextAvatar?this._html`
`:""}
${this.theme.introText}
`}_handleIntroClick(){this._action("layout.update",{isWindowOpen:!0}),this.theme.introTextSendMessage&&(this.context.chat.sendMessage({body:this.theme.introText}),this.context.analytics.track({name:"message-sent"},{skipBackend:!0}))}_handleIntroClose=t=>{t.stopPropagation(),this._action("layout.update",{isIntroClosed:!0})};_icebreakersTemplate(){const t=[...this.theme.icebreakers||[]];return this._html`
${this.layout?.isIntroClosed?this._html`
`:""}
${t.map((t,e)=>this._html`
{this.context.chat.sendMessage({type:"icebreaker",body:t.long_text||t.text}),this.context.analytics.track({name:"message-sent"},{skipBackend:!0}),this.context.chat.setLastOpenIsIcebreaker(!0)}}">
${t.text}
`)}
`}_handleIcebreakersClose=t=>{t.stopPropagation(),this._areIcebreakersClosed=!0};_handleOpenButtonClick(){this._action("layout.update",{isWindowOpen:!0})}}}]);function mo(t){return[parseInt(t[1]+t[2],16),parseInt(t[3]+t[4],16),parseInt(t[5]+t[6],16)]}function _o(t){return t.reduce((t,e)=>t+e,0)/255/3}function go(t){return _o(t)<=.5}const fo={strToHex:function(t){const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,e.fillStyle},hexToRgb:mo,hexIsDark:function(t){return go(mo(t))},rgbLightness:_o,rgbIsDark:go};function bo(e,s={}){return{introText:t.introMessage,...e,...s}}function vo(t){const e={introText:t.introText,introTextId:t.introTextId||"default_intro",isAiGenerated:t.isAiGenerated||!1,introTextSendMessage:t.introTextSendMessage,showIntroText:void 0===t.showIntroText||t.showIntroText,placeholderText:t.placeholderText,align:t.align,logoSize:t.logoSize,iconType:t.icon,toggleIconSize:t.iconSize,windowSize:t.chatWindowSize,offsetTop:t.offsetTop,offsetBottom:t.offsetBottom,messageAvatar:t.messageAvatar,zIndex:t.zIndex,privacyUrl:t.privacyUrl,fontFamily:t.fontFamily,darkMode:void 0!==t.darkMode,layout:t.containerId?"contain":"toggle",colorLink:t.colorLink,toggleStyle:t.toggleStyle||"default",toggleStyleMobile:t.toggleStyleMobile,toggleText:t.toggleText||"AI Travel Assistant",icebreakers:t.icebreakers||[],icebreakerDelay:void 0!==t.icebreakerDelay?t.icebreakerDelay:0,icebreakerPageDepth:void 0!==t.icebreakerPageDepth?t.icebreakerPageDepth:0,icebreakersEnabled:t.icebreakersEnabled,hideIcebreakersOnMobile:t.hideIcebreakersOnMobile||!1,showIntroTextAvatar:t.showIntroTextAvatar,withUserFeedback:t.userFeedback,withMap:t.map,withFavorites:t.favorites,placeCarouselEnabled:t.placeCarouselEnabled,disableChatToggle:t.disableChatToggle||!1,autoLaunchMap:t.autoLaunchMap||!1,companyName:t.companyName||"GuideGeek",labels:t.labels||{},imgCdnDomain:t.imgCdnDomain||null,multiChat:t.multiChat||!1};return function(t,e){let s=!1;e.colorPrimary&&(t.colorPrimary=fo.strToHex(e.colorPrimary),t.colorPrimaryRgb=fo.hexToRgb(t.colorPrimary),s=fo.hexIsDark(t.colorPrimary),t.colorPrimaryText=s?"white":"black");e.colorHeader&&(t.colorHeader=fo.strToHex(e.colorHeader),t.colorHeaderText=fo.hexIsDark(t.colorHeader)?"white":"black");e.colorAgent&&(t.colorAgent=e.colorAgent,"transparent"!=t.colorAgent&&(t.colorAgent=fo.strToHex(e.colorAgent),t.colorAgentText=fo.hexIsDark(t.colorAgent)?"white":"black"));e.colorUser&&(t.colorUser=e.colorUser,"transparent"!=t.colorUser&&(t.colorUser=fo.strToHex(e.colorUser),t.colorUserText=fo.hexIsDark(t.colorUser)?"white":"black"));e.chatToggleBgColor?t.chatToggleBgColor=e.chatToggleBgColor:e.colorToggle?t.chatToggleBgColor=fo.strToHex(e.colorToggle):t.colorPrimary&&(t.chatToggleBgColor=t.colorPrimary);e.colorAiMessage?(t.colorAiMessage=fo.strToHex(e.colorAiMessage),t.colorAiMessageRgb=fo.hexToRgb(t.colorAiMessage)):t.colorPrimary&&(t.colorAiMessage=t.colorPrimary,t.colorAiMessageRgb=t.colorPrimaryRgb);e.chatAvatarBgColor&&(t.chatAvatarBgColor=e.chatAvatarBgColor);"custom"==e.icon&&e.customChatIcon?(t.iconUrl=yo(e.customChatIcon),"bookmark"!==e.toggleStyle&&"island"!==e.toggleStyle&&"dock"!==e.toggleStyle||(t.invertIcon=s?1:0)):t.invertIcon=s?1:0}(e,t),function(t,e){e.logoUrl&&(t.logoUrl=yo(e.logoUrl));e.messageAvatar&&(t.messageAvatar=yo(e.messageAvatar))}(e,t),e}function yo(t){if(!t)return;return`https://cdn1.matadornetwork.com/guidegeek/${t.replace("https://cdn1.matadornetwork.com/guidegeek/","")}`}Bs([{name:"gg-app",component:class extends aa{static properties={_layout:{state:!0}};_renderedTheme=null;constructor(){super(),this.className="app",this.style.visibility="hidden",this._layout={}}connectedCallback(){super.connectedCallback(),this._observe(t=>{t.layout.isWindowOpen?this._context.chat.connect():this._context.chat.disconnect()},["layout.isWindowOpen"]),this._observe((t,e)=>{this._layout=t.layout,t.theme!==e.theme&&(this._context.theme=t.theme,this.context=this._context)},["layout","theme"]),this._observe(t=>{this._handleInactiveMessage(t)},["layout.isWindowOpen","chat.answerPhase","messages","customMessage","followUpMessage"])}render(){return this._html`
`}updated(){this.style.visibility=this._layout.isHidden?"hidden":"";const e=this.theme;e&&e!==this._renderedTheme&&(this._renderedTheme=e,this._setStyleVars({"--color-primary":e.colorPrimary,"--color-ai-message-rgb":e.colorAiMessageRgb?e.colorAiMessageRgb.join(","):null,"--color-primary-text":e.colorPrimaryText,"--color-header":e.colorHeader,"--color-header-text":e.colorHeaderText,"--color-agent":e.colorAgent,"--color-agent-text":e.colorAgentText,"--color-user":e.colorUser,"--color-user-text":e.colorUserText,"--color-link":e.colorLink,"--color-toggle-text":e.invertIcon?"white":"black","--invert-icon":e.invertIcon,"--logo-url":e.logoUrl?`url('${e.logoUrl}')`:null,"--icon-url":e.iconUrl?`url('${e.iconUrl}')`:null,"--font-family":e.fontFamily,"--chat-toggle-display":e.disableChatToggle?"none":"inherit","--chat-toggle-bg-color":e.chatToggleBgColor,"--chat-avatar-bg-color":"transparent"!=e.chatAvatarBgColor?`2px solid ${e.chatAvatarBgColor}`:"none","--offset-top":e.offsetTop?`${e.offsetTop}px`:null,"--offset-bottom":e.offsetBottom?`${e.offsetBottom}px`:null,"--z-index":e.zIndex?`${e.zIndex}`:null}),e.zIndex&&(this.style.zIndex=e.zIndex),this.className="app",e.withMap&&this.classList.add("app--with-map"),t.markdown&&this.classList.add("app--with-markdown"),e.align&&this.classList.add(`app--align-${e.align}`),e.windowSize&&this.classList.add(`app--${e.windowSize}`),e.darkMode&&this.classList.add("app--dark"),e.layout&&this.classList.add(`app--layout-${e.layout}`),e.iconType&&this.classList.add(`app--icon-${e.iconType}`),e.messageAvatar&&(this.classList.add("app--message-avatar"),this._setStyleVars({"--message-avatar":`url('${e.messageAvatar}')`})),e.toggleStyle&&this.classList.add(`app--style-${e.toggleStyle}`)),this.classList.toggle("app--map-open",this._layout.isMapOpen),this.classList.toggle("app--place-open",this._layout.isPlaceOpen),this.classList.toggle("app--map-expanded",this._layout.isMapExpanded)}_setStyleVars(t){for(const e in t)void 0!==t[e]?this.style.setProperty(e,t[e]):this.style.removeProperty(e)}_handleInactiveMessage(t){if(!(!t.customMessage.body||t.followUpMessage.body&&t.followUpMessage.triggered))if(t.layout.isWindowOpen&&!t.chat.answerPhase){let e=0,s="en";for(const a of t.messages)"user"===a.from?e++:"agent"===a.from&&a.langCode&&(s=a.langCode);if(t.customMessage.triggered){if(!t.followUpMessage.triggered&&t.followUpMessage.body){const e="string"==typeof t.followUpMessage.body?t.followUpMessage.body:t.followUpMessage.body?.[s];this._startInactiveMessageTimer("follow-up",e,3e4)}}else if(e>=t.customMessage.triggerCount){const e="string"==typeof t.customMessage.body?t.customMessage.body:t.customMessage.body?.[s];this._startInactiveMessageTimer("custom",e,3e3)}}else this._stopInactiveMessageTimer()}_startInactiveMessageTimer(t,e,s){const a=(new Date).toISOString().split("T")[0],i="custom"===t?"gg-custom-message-date":"gg-followup-message-date";if(localStorage.getItem(i)===a)return;const n=localStorage.getItem(i);(n?Math.floor((new Date(a)-new Date(n))/864e5):1/0)<("custom"===t?30:1)||po.schedule(()=>{localStorage.getItem(i)!==a&&(this._context.chat.systemMessage({trigger:t,body:e}),localStorage.setItem(i,a))},s)}_stopInactiveMessageTimer(){po.clear()}}}]);const wo="widget",$o=a("/widget.css");function ko(e,a,i){const{store:n,chat:o,analytics:r}=function(e){const s=new Me({url:t.apiHttpUrl,company:e.company,onNetworkError:null}),a=new xe({url:t.apiSocketUrl,company:e.company}),i=new we(s,{trackPatches:"indexeddb"==t.stateBackend}),n=new Ws;n.ggHttp=s;const o=new Te(wo,{company:e.company,mainStore:i,ggHttp:s,ggSocket:a,onAnalytics:n.track.bind(n),config:t});return s.onNetworkError=t=>o._handleNetworkError(t),{store:i,chat:o,analytics:n}}(a);e.appendChild(s.styleNode($o,()=>{o.load().then(s=>{if(!s)return;const l=function(t,e){const s={...e};return void 0!==s.map&&(s.map="no"!=s.map),bo(t,s)}(s,a),c=vo(l);!function(t,e,s){t.update(t=>{"contain"==s.layout&&(t.layout.isWindowOpen=!0),!s.withMap&&t.layout.isMapOpen&&(t.layout.isMapOpen=!1,t.layout.isPlaceOpen=!1),t.layout.isHidden=void 0!==e.hidden,t.theme=s})}(n,l,c),function(e,s,a,i,n,o){const r=function(e,s,a,i,n,o){const r=new Map,l={admin:(s,i={})=>{if(window.location.origin!=t.adminUrl)throw new Error("Admin commands can only be executed from the admin site.");switch(s){case"updateTheme":e.update(t=>{t.theme=vo(bo(a,i))});break;case"unshrinkToggle":e.update(t=>{t.layout.isIntroClosed=!1})}},command:(t,s={})=>{let a=null;switch(t){case"show":e.update(t=>{t.layout.isHidden=!1});break;case"hide":e.update(t=>{t.layout.isHidden=!0});break;case"openWindow":"toggle"==i.layout&&(n.track({name:"api-window-opened"},{skipBackend:!0}),e.update(t=>{t.layout.isWindowOpen=!0}));break;case"closeWindow":"toggle"==i.layout&&(n.track({name:"api-window-closed"},{skipBackend:!0}),e.update(t=>{t.layout.isWindowOpen=!1}));break;case"detach":o.detach();break;case"attach":{o.attach(s.containerId);const t=s.containerId?"contain":"toggle";e.update(e=>{e.theme.layout=t,"contain"==t&&(e.layout.isWindowOpen=!0)});break}case"theme":"introText"==s?a=i.introText:"icebreakerText"==s?.name&&i.icebreakers[s.index]&&(a=i.icebreakers[s.index].long_text)}return a},composeMessage:t=>(n.track({name:"api-message-composed"},{skipBackend:!0}),s.composeMessage(t)),sendMessage:t=>(n.track({name:"api-message-sent"},{skipBackend:!0}),s.sendMessage(t)),on:(t,e)=>{r.has(t)||r.set(t,new Set),r.get(t).add(e)},off:(t,e)=>{r.has(t)&&r.get(t).delete(e)},emit:(t,e)=>{if(r.has(t))for(const s of r.get(t))try{s(e)}catch(e){console.error(`Error in event handler for ${t}:`,e)}}};return l}(e,s,a,i,n,o);(function(t,e){t.onUpdate(t=>{t.layout.isWindowOpen?(t.chat.isNewChat?e.track({name:"chat-started"},{skipBackend:!0}):t.chat.isNewThread&&e.track({name:"chat-continued"},{skipBackend:!0}),t.layout.isIntroClosed?e.track({name:"window-opened"}):e.track({name:"window-opened",params:{is_ai_generated:t.theme?.isAiGenerated,intro_text_id:t.theme?.introTextId,intro_text_content:t.theme?.introText,page_url:window.location.href}})):e.track({name:"window-closed"})},null,["layout.isWindowOpen"]),t.onUpdate(t=>{t.layout.isIntroClosed&&e.track({name:"cta-closed",params:{intro_text_content:t.theme?.introText||null,intro_text_id:t.theme?.introTextId||null,page_url:window.location.href}})},null,["layout.isIntroClosed"]),t.onUpdate(t=>{let s={};if(t.messages?.length>0){const e=t.messages[t.messages.length-1];"agent"===e.from&&(s.messageId=e.apiMessageId)}t.layout.isMapOpen?e.track({name:"map-opened",params:s}):e.track({name:"map-closed",params:s})},null,["layout.isMapOpen"])})(e,n),function(t,e,s,a){const i=document.querySelectorAll(".mn-guidegeek-button");for(const n of i){const i=n.dataset;i.text&&(n.textContent=So(i.text,s)),n.addEventListener("click",()=>{a.track({name:"api-window-opened"},{skipBackend:!0}),t.update(t=>{t.layout.isWindowOpen=!0,t.layout.isHidden=!1}),i.compose?(a.track({name:"api-message-composed"},{skipBackend:!0}),e.composeMessage({body:So(i.compose,s)})):i.send&&(a.track({name:"api-message-sent"},{skipBackend:!0}),e.sendMessage({body:So(i.send,s)}))}),n.disabled=!1}}(e,s,i,n),e.onUpdate(t=>{n.auth={contactId:t.api.contactId,token:t.api.token,userId:t.api.userId,userToken:t.api.userToken}},null,["api.contactId","api.token","api.userId","api.userToken"]),e.onUpdate(t=>{t.layout.isWindowOpen?r.emit("WindowOpened",{}):r.emit("WindowClosed",{})},null,["layout.isWindowOpen"]),window.guidegeek.registerChat(wo,r)}(n,o,l,c,r,i),Us(bs` `,e)})}))}function So(t,e){return t.replaceAll(/{{(intro_text|icebreaker_([1-5])_text)}}/g,(t,s,a)=>{let i="";if("intro_text"==s)e.introText&&(i=e.introText);else if(s.startsWith("icebreaker_")){const t=parseInt(a)-1;e.icebreakers?.[t]&&(i=e.icebreakers[t].long_text)}return i})}const To=document.currentScript.dataset,Co="mn-guidegeek-widget",Mo=a("/widget-fonts.css");let xo=null;function Io(){if(document.getElementById(Co))return;Ie({config:t}),xo=s.html(`
`);const e=s.styleNode(Mo,()=>{ko(xo.attachShadow({mode:"closed"}),To,{attach:Lo,detach:Ao})});xo.appendChild(e),Lo(To.containerId)}function Ao(){xo?.parentNode&&xo.parentNode.removeChild(xo)}function Lo(t){if(xo)if(Ao(),t){const e=document.getElementById(t);if(!e)return void console.error(`Container element ${t} not found`);xo.style.width="100%",xo.style.height="100%",e.appendChild(xo)}else xo.style.width="",xo.style.height="",document.body.appendChild(xo)}"loading"==document.readyState?document.addEventListener("DOMContentLoaded",Io):Io()}();