@meetelise/chat 1.41.1 → 1.41.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.41.1",
3
+ "version": "1.41.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -6498,7 +6498,7 @@ xmlns="http://www.w3.org/2000/svg"
6498
6498
  </button>
6499
6499
  </div>
6500
6500
  </div>
6501
- `}};_s.styles=[xi,cs,us,ls,Ss],Es([le({type:Number})],_s.prototype,"right",void 0),Es([le({type:Number})],_s.prototype,"bottom",void 0),Es([le({type:Number})],_s.prototype,"top",void 0),Es([le({type:Number})],_s.prototype,"left",void 0),Es([le({attribute:!0})],_s.prototype,"onMount",void 0),Es([le({attribute:!0})],_s.prototype,"channel",void 0),Es([le({attribute:!0})],_s.prototype,"isHealthChat",void 0),Es([le({attribute:!0})],_s.prototype,"myPubnub",void 0),Es([le({attribute:!0})],_s.prototype,"orgSlug",void 0),Es([le({attribute:!0})],_s.prototype,"buildingSlug",void 0),Es([le({attribute:!0})],_s.prototype,"widgetType",void 0),Es([le({attribute:!0})],_s.prototype,"building",void 0),Es([le({attribute:!0})],_s.prototype,"primaryColor",void 0),Es([le({attribute:!0})],_s.prototype,"backgroundColor",void 0),Es([le({attribute:!0})],_s.prototype,"onClickExit",void 0),Es([le({attribute:!0})],_s.prototype,"requiresConsent",void 0),Es([ce("#message-input",!0)],_s.prototype,"messageInput",void 0),Es([ce("#conversation-body",!0)],_s.prototype,"messageBody",void 0),Es([ue()],_s.prototype,"messages",void 0),Es([ue()],_s.prototype,"isLoadingMessages",void 0),Es([ue()],_s.prototype,"hasReceivedConsent",void 0),Es([ue()],_s.prototype,"privacyPolicyUrl",void 0),Es([ue()],_s.prototype,"websitePreviewMapping",void 0),_s=Es([ae("pubnub-chat")],_s);const Os=(e,t)=>["floor plan","floorplan","floor plans","floorplans"].some((t=>e.toLowerCase().includes(t)))?`${t}/units`:t;var Ps=function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};let Ns=class extends oe{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.primaryColor=null,this.backgroundColor=null,this.foregroundColorOnPrimaryBackgroundColor=null,this.foregroundColorOnSecondaryBackgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.buildingWebchatView=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=on.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.LeadSourceClient=null,this.sampleRateToUse=.05,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Qs.Default,this.onWidgetLoaded=ba(),this.onSstClose=ba(),this.enabledChatWidgets={callDesktop:!1,callMobile:!1,chatMobile:!1,chatDesktop:!1,emailDesktop:!1,emailMobile:!1,textDesktop:!1,textMobile:!1,sstDesktop:!1,sstMobile:!1,calcDesktop:!1,calcMobile:!1},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=Ae(),this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await Un(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,i)=>{const n=window.rentgrata;if(!n)return;const o=n.Widget;if(!o)return;const r=o.config;if(!r)return;const a=r.widgetKey;a&&await t().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=i?i:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}await(async(e,i,n)=>{const o=.01;if(!e)return console.warn("MeetElise Chat will NOT appear. Building does NOT exist."),_o(n,i,!0,!1,"building_does_not_exist",o),!1;if(!e.launchedDateTime)return console.warn("MeetElise Chat will NOT appear. Building is NOT launched (based on launched date time)."),_o(n,i,!0,!1,"building_not_launched",o),!1;if(!e.active)return console.warn("MeetElise Chat will NOT appear. Building is NOT active."),_o(n,i,!0,!1,"building_not_active",o),!1;if(!e.webchatScopeConfigured)return console.warn("MeetElise Chat will NOT appear. Building is NOT webchat scope configured."),_o(n,i,!0,!1,"building_not_webchat_scope_configured",o),!1;const r=await async function(e){if(!e)return!1;try{return(await t().get(nn(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-leasing-in-maintenance-mode",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(i);return!r||(console.warn("MeetElise Chat will NOT appear. Chat is in maintenance mode."),_o(n,i,!0,!1,"building_in_maintenance_mode",o),!1)})(e,this.buildingSlug,this.orgSlug)&&(Sn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:(null==e?void 0:e.launchedDateTime)?.01:.05}),this.buildingWebchatView=e,await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1,"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0))},this.setBuildingDerivedInfo=async()=>{var e,i,n,o,r,a,s,l,u,c,d,h,p,f,g,m,b,v,y,w,C,x,A,S,k,T,E,_,O,P,N,M,I,D,U,L,R,B,j,H,F,$,z,Q,G,q,W,V;const Y=this.buildingWebchatView;if(!Y)return;Y&&this.orgSlug&&Is(this.orgSlug,null!==(i=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==i?i:null,this.sampleRateToUse,this.buildingSlug,null!==(o=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==o?o:null);const[K,X,Z,J,ee,te,ie]=await Promise.all([Eo(this.buildingSlug),Ba(this.orgSlug,this.buildingSlug),rn(this.buildingSlug),an(this.buildingSlug),sn(this.buildingSlug),ln(this.buildingSlug),un(this.buildingSlug)]);this.buildingWebchatView&&(this.buildingWebchatView.phoneNumber=_e(Y.phoneNumber)),this.designConcept=null!==(r=null==K?void 0:K.abTestType)&&void 0!==r?r:"",this.leadSources=X,this.featureFlagShowDropdown=Z;const ne=Y.textWithUsPhoneNumber?Y.textWithUsPhoneNumber:await(async e=>{try{const i="https://app.meetelise.com",n=await t().get(`${i}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return An({logType:xn.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug),oe=null!==(s=null===(a=this.buildingWebchatView)||void 0===a?void 0:a.shouldShowPricingCalculatorDesktop)&&void 0!==s&&s,re=null!==(u=null===(l=this.buildingWebchatView)||void 0===l?void 0:l.shouldShowPricingCalculatorMobile)&&void 0!==u&&u,ae={callDesktop:null!==(d=null===(c=this.buildingWebchatView)||void 0===c?void 0:c.shouldShowPhoneDesktop)&&void 0!==d&&d,callMobile:null!==(p=null===(h=this.buildingWebchatView)||void 0===h?void 0:h.shouldShowPhoneMobile)&&void 0!==p&&p,chatDesktop:null!==(g=null===(f=this.buildingWebchatView)||void 0===f?void 0:f.shouldShowChatDesktop)&&void 0!==g&&g,chatMobile:null!==(b=null===(m=this.buildingWebchatView)||void 0===m?void 0:m.shouldShowChatMobile)&&void 0!==b&&b,emailDesktop:null!==(y=null===(v=this.buildingWebchatView)||void 0===v?void 0:v.shouldShowEmailDesktop)&&void 0!==y&&y,emailMobile:null!==(C=null===(w=this.buildingWebchatView)||void 0===w?void 0:w.shouldShowEmailMobile)&&void 0!==C&&C,textDesktop:null!==(A=(null===(x=this.buildingWebchatView)||void 0===x?void 0:x.shouldShowTextDesktop)&&!!ne)&&void 0!==A&&A,textMobile:null!==(k=(null===(S=this.buildingWebchatView)||void 0===S?void 0:S.shouldShowTextMobile)&&!!ne)&&void 0!==k&&k,sstDesktop:null!==(E=null===(T=this.buildingWebchatView)||void 0===T?void 0:T.shouldShowSstDesktop)&&void 0!==E&&E,sstMobile:null!==(O=null===(_=this.buildingWebchatView)||void 0===_?void 0:_.shouldShowSstMobile)&&void 0!==O&&O,calcDesktop:oe,calcMobile:re};var se,le;this.enabledChatWidgets=(e=>{const t=window.location.hostname;if(!xa.includes(t))return e;const i=(e=>{if(!e)return{};try{return e.split(",").reduce(((e,t)=>{const[i,n]=t.split(":");return i&&n&&i in Aa&&(e[i]="true"===n.toLowerCase()),e}),{})}catch(e){return console.warn("Error parsing widget overrides:",e),{}}})(new URLSearchParams(window.location.search).get("widgets"));if(0===Object.keys(i).length)return e;const n={...e};return Object.entries(i).forEach((([e,t])=>{const i=Aa[e];i&&(n[i.desktop]=t,n[i.mobile]=t)})),console.info("Applied widget overrides:",i),n})(ae),this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(le=this.handleTourClicked,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");t&&t.startsWith("https://app.meetelise.com/")&&e.addEventListener("click",(e=>{e.preventDefault(),le(e)}))})),te&&(e=>{document.querySelectorAll('a[href$="schedule-a-tour"]').forEach((t=>{t&&t.addEventListener("click",(t=>{t.preventDefault(),e(t)}))}))})(this.handleTourClicked),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach((t=>{var i;if(!t)return;const n=document.createElement("a");n.innerHTML=t.innerHTML,n.style.cursor="pointer",n.addEventListener("click",(t=>{t.preventDefault(),e(t)})),null===(i=t.parentNode)||void 0===i||i.replaceChild(n,t)}))})(this.handleTourClicked)):(null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&(se=null!==(M=null===(N=this.LeadSourceClient)||void 0===N?void 0:N.leadSource)&&void 0!==M?M:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const i=t.includes("?")?"&":"?";e.setAttribute("href",t+i+`eliseParsedLeadSource=${encodeURIComponent(se)}`)}}))),this.buildingWebchatView&&(this.primaryColor=null!==(I=this.buildingWebchatView.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(D=this.buildingWebchatView.secondaryColor)&&void 0!==D?D:null,this.foregroundColorOnPrimaryBackgroundColor=null!==(U=this.buildingWebchatView.foregroundColorOnPrimaryBackgroundColor)&&void 0!==U?U:null,this.foregroundColorOnSecondaryBackgroundColor=null!==(L=this.buildingWebchatView.foregroundColorOnSecondaryBackgroundColor)&&void 0!==L?L:null,this.webchatConfigHasAutoOpenChat=null!==(R=this.buildingWebchatView.autoOpenChat)&&void 0!==R&&R,this.requiresConsent=null!==(B=this.buildingWebchatView.requiresConsentForChat)&&void 0!==B&&B,this.hideMobileFeatures=null!==(j=this.buildingWebchatView.collapseMobileFeatures)&&void 0!==j&&j,this.privacyPolicyUrl=null!==(H=this.buildingWebchatView.privacyPolicyUrlForChat)&&void 0!==H?H:this.privacyPolicyUrl,this.buildingWebchatView.displayStyle===Nn.MINIMIZED&&(this.isMinimized=!0),this.buildingWebchatView.displayStyle===Nn.PILLS&&(this.designConcept=null),this.buildingWebchatView.displayStyle===Nn.EMOJI&&(this.designConcept=Nn.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=Ie),null===this.backgroundColor&&(this.backgroundColor=De);const ue=null!==($=null===(F=this.buildingWebchatView)||void 0===F?void 0:F.phoneNumber)&&void 0!==$?$:"";let ce=null;if(J&&(ce=await async function(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${i}`);return n.data?{number:_e(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(Q=null===(z=this.LeadSourceClient)||void 0===z?void 0:z.leadSource)&&void 0!==Q?Q:null),ce&&!ce.isMatch&&(ce.number=ue),!(null===(G=this.LeadSourceClient)||void 0===G?void 0:G.leadSource)&&ce&&(ce.number=ue)),ee&&(null==ce?void 0:ce.number)){const e=rs(ce.number,this.orgSlug,this.buildingSlug);e>0&&Sn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const de=localStorage.getItem("eliseai_phone_number_devtest");de&&(console.info("Using dev test phone number: ",de),rs(de,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=ce||{number:ue,isMatch:!1,isPropertyWebsiteCatchall:!0};const he=null!==(W=null===(q=this.LeadSourceClient)||void 0===q?void 0:q.leadSource)&&void 0!==W?W:null;if(he&&(this.leadSources.includes(he)||this.leadSources.push(he)),Wi(Y.id),ie&&this.buildingSlug&&(null===(V=this.buildingWebchatView)||void 0===V?void 0:V.isLiveOnApplications)){const e=((e,t,i)=>{var n;const o=[/thehavenatgreenhill\.securecafe\.com\/onlineleasing\/the-haven-at-greenhill\/oleapplication\.aspx(\?.*)?$/,/securecafe\.com\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/vsc\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/,/vsc\.myresman\.com\/Portal\/Applicants\/New\/.*(\?.*)?$/],r=document.body.getElementsByTagName("a");let a=0;for(let s=0;s<r.length;s++){const l=r[s];if(l.nodeType===Node.ELEMENT_NODE&&o.some((e=>e.test(l.href)))){const o=l.getAttribute("href"),r=(null===(n=l.textContent)||void 0===n?void 0:n.toLowerCase())||"",s=Os(r,e);l.setAttribute("href",s),a++,An({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"link-replacement",oldHref:o,newHref:s,website:window.location.href},logType:xn.info,buildingSlug:i,orgSlug:t})}}return 0===a&&An({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"no-select-buttons-found",website:window.location.href},logType:xn.warn,buildingSlug:i,orgSlug:t}),a})(`https://applications.eliseai.com/building/${this.buildingSlug}`,this.orgSlug,this.buildingSlug);e>0&&Sn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_application_link_replacement_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}},this.initializeChatVariables=async()=>{var e,i,n,o,r,a,s,l;if(!this.buildingWebchatView)return;const u=Za(this.buildingSlug),c=Ja(this.buildingSlug,u)?u:Xa(this.buildingSlug,!1);if(!c.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,i,n,o)=>{const r=kn();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:r,referrer:document.referrer,parsedUtmSource:r?r.utm_source:null,campaignSources:Object.values(Cn()).filter((e=>e))},n)return;if(!o){const t=this.getLeadSourceBodyIfValid(e);if(t&&!vi(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Ni(t.timestamp)}}const a={leadSource:t,leadId:i,buildingSlug:e,timestamp:ki(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Ni(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const i=JSON.parse(t);if(i.buildingSlug===e&&i.leadSource&&i.leadId&&i.timestamp&&!vi(Ni(i.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=i.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return i}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:i,referrer:n,campaignSources:o}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:i,building_slug:e,referrer:n,campaign_sources:o})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:i}){var n,o,r,a,s,l,u;try{if(!this.chatId)return console.error("chatId is not set"),null;if(!this.orgSlug)return console.error("orgId is not set"),null;let c=null,d=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(c=e),d=null===(n=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===n?void 0:n.value}}catch(e){console.error("error getting cookie")}return await t().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:i,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteOrigin,website_search:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:_n()(c)?null:c,extras:null!=d?d:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim();if(n.startsWith(e+"="))return n.substring((e+"=").length,-1===n.indexOf(";")?void 0:n.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:i}){try{const n={queryParams:kn(),buildingSlug:i,referrer:document.referrer,campaignSources:Cn()};let o=!1;const r=i?this.getLeadSourceBodyIfValid(i):null;if(r){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=r.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(n);if(!e)return this.leadSource=r.leadSource,this.leadSource;this.leadSource=e,o=!0}}const a=await this.fetchCurrentParsedLeadSource(n);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=i,i&&!a){const e=this.getLeadSourceBodyIfValid(i);if(e)return this.leadSource=e.leadSource,this.leadSource}if(i){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(i,a,e,!t&&!o,o)}return a}catch(e){console.error(e)}return null}},this.myPubnub=new os(this.buildingSlug,this.buildingWebchatView,this.orgSlug,null,c.leadId,this.LeadSourceClient,this.widgetType),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(e=this.LeadSourceClient)||void 0===e?void 0:e.generateUserLeadSource({leadId:null!==(n=null===(i=this.myPubnub)||void 0===i?void 0:i.leadUserId)&&void 0!==n?n:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),console.log("EliseAI Mapped Lead Source source: ",null===(o=this.LeadSourceClient)||void 0===o?void 0:o.leadSource),"property-website"!==On(this.orgSlug)?this.myPubnub.leadSource=null!==(a=null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource)&&void 0!==a?a:On(this.orgSlug):this.myPubnub.leadSource=null!==(l=null===(s=this.LeadSourceClient)||void 0===s?void 0:s.leadSource)&&void 0!==l?l:null,c.initiatedChat&&await this.myPubnub.initializePubnub(u)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),i=!t||!(t&&!Oi(Ni(t)));return!!e&&!!i&&!bi()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",ki(function(e,t){je(2,arguments);var i=it(t);return nt(e,6e4*i)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,i;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(i=this.launcherRef.value)||void 0===i||i.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,i,n;const o=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!o)return;const r=null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"),a=null==r?void 0:r.getBoundingClientRect();a&&(o.style.left=`${a.left}px`,o.style.top=`${a.bottom}px`)},this.handleKeydownTab=e=>{var t,i,n,o,r,a,s,l,u,c,d,h,p,f,g,m,b,v,y,w;if("Tab"===e.key){const C=this.displayPubnubChat?null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"):null!==(g=null!==(u=null===(l=null===(s=null===(a=null===(r=null===(o=this.shadowRoot)||void 0===o?void 0:o.getElementById("meetelise-launcher"))||void 0===r?void 0:r.shadowRoot)||void 0===a?void 0:a.getElementById("email-us-window"))||void 0===s?void 0:s.shadowRoot)||void 0===l?void 0:l.getElementById("email-us-form"))&&void 0!==u?u:null===(f=null===(p=null===(h=null===(d=null===(c=this.shadowRoot)||void 0===c?void 0:c.getElementById("meetelise-launcher"))||void 0===d?void 0:d.shadowRoot)||void 0===h?void 0:h.getElementById("tour-scheduler-window"))||void 0===p?void 0:p.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==g?g:null===(w=null===(y=null===(v=null===(b=null===(m=this.shadowRoot)||void 0===m?void 0:m.getElementById("meetelise-launcher"))||void 0===b?void 0:b.shadowRoot)||void 0===v?void 0:v.getElementById("call-us-window"))||void 0===y?void 0:y.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!C)return;e.preventDefault();const x=C.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),A=Array.from(x),S=A.findIndex((e=>e.matches(":focus")));A[(S+1)%A.length].focus()}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized,this.showTourNextToChat=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,localStorage.setItem("isChatOpen","true")},e.onExitChat=this.onExitChat)},this.onExitChat=()=>{this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,localStorage.setItem("isChatOpen","false")}}async handleChatInitializeAnalytics(){var e,t,i,n;this.analytics=new wn(this.orgSlug,this.buildingSlug,null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.channel)&&void 0!==t?t:"",null!==(n=null===(i=this.LeadSourceClient)||void 0===i?void 0:i.leadSource)&&void 0!==n?n:null),Math.random()<.05&&this.analytics.ping("webchat_heartbeat")}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),Ka(this.buildingSlug),this.myPubnub=null,this.displayPubnubChat=!1,await this.setupWebchat(),this.hideLauncher=!1}show(){this.launcher&&(this.launcher.style.display="")}hide(){this.launcher&&(this.launcher.style.display="none")}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.adjustPositionChatAdditionalActions),window.addEventListener("keydown",this.handleKeydownTab)}getDeepActiveElement(){let e=document.activeElement,t=0;for(;(null==e?void 0:e.shadowRoot)&&(null==e?void 0:e.shadowRoot.activeElement);)if(t+=1,e=null==e?void 0:e.shadowRoot.activeElement,t>100){An({logType:xn.error,buildingSlug:this.buildingSlug,logTitle:"[ERROR_GETTING_DEEP_ELEMENT]",logData:{message:"error getting deep active element"}});break}return e}updated(){this.adjustPositionChatAdditionalActions()}disconnectedCallback(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),window.removeEventListener("resize",this.adjustPositionChatAdditionalActions),window.removeEventListener("keydown",this.handleKeydownTab),super.disconnectedCallback()}render(){var e,t,i,n,o,r,a,s,l,u,c,d,h,p,f,g,m,b,v,y,w,C,x,A,S,k,T,E,_,O,P,N,M,I,D,U;Ca();const L=this.hideLauncher&&!this.isLoading&&!bi();return R`
6501
+ `}};_s.styles=[xi,cs,us,ls,Ss],Es([le({type:Number})],_s.prototype,"right",void 0),Es([le({type:Number})],_s.prototype,"bottom",void 0),Es([le({type:Number})],_s.prototype,"top",void 0),Es([le({type:Number})],_s.prototype,"left",void 0),Es([le({attribute:!0})],_s.prototype,"onMount",void 0),Es([le({attribute:!0})],_s.prototype,"channel",void 0),Es([le({attribute:!0})],_s.prototype,"isHealthChat",void 0),Es([le({attribute:!0})],_s.prototype,"myPubnub",void 0),Es([le({attribute:!0})],_s.prototype,"orgSlug",void 0),Es([le({attribute:!0})],_s.prototype,"buildingSlug",void 0),Es([le({attribute:!0})],_s.prototype,"widgetType",void 0),Es([le({attribute:!0})],_s.prototype,"building",void 0),Es([le({attribute:!0})],_s.prototype,"primaryColor",void 0),Es([le({attribute:!0})],_s.prototype,"backgroundColor",void 0),Es([le({attribute:!0})],_s.prototype,"onClickExit",void 0),Es([le({attribute:!0})],_s.prototype,"requiresConsent",void 0),Es([ce("#message-input",!0)],_s.prototype,"messageInput",void 0),Es([ce("#conversation-body",!0)],_s.prototype,"messageBody",void 0),Es([ue()],_s.prototype,"messages",void 0),Es([ue()],_s.prototype,"isLoadingMessages",void 0),Es([ue()],_s.prototype,"hasReceivedConsent",void 0),Es([ue()],_s.prototype,"privacyPolicyUrl",void 0),Es([ue()],_s.prototype,"websitePreviewMapping",void 0),_s=Es([ae("pubnub-chat")],_s);const Os=(e,t)=>["floor plan","floorplan","floor plans","floorplans"].some((t=>e.toLowerCase().includes(t)))?`${t}/units`:t;var Ps=function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};let Ns=class extends oe{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.primaryColor=null,this.backgroundColor=null,this.foregroundColorOnPrimaryBackgroundColor=null,this.foregroundColorOnSecondaryBackgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.buildingWebchatView=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=on.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.LeadSourceClient=null,this.sampleRateToUse=.05,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Qs.Default,this.onWidgetLoaded=ba(),this.onSstClose=ba(),this.enabledChatWidgets={callDesktop:!1,callMobile:!1,chatMobile:!1,chatDesktop:!1,emailDesktop:!1,emailMobile:!1,textDesktop:!1,textMobile:!1,sstDesktop:!1,sstMobile:!1,calcDesktop:!1,calcMobile:!1},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=Ae(),this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await Un(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,i)=>{const n=window.rentgrata;if(!n)return;const o=n.Widget;if(!o)return;const r=o.config;if(!r)return;const a=r.widgetKey;a&&await t().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=i?i:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}await(async(e,i,n)=>{const o=.01;if(!e)return console.warn("MeetElise Chat will NOT appear. Building does NOT exist."),_o(n,i,!0,!1,"building_does_not_exist",o),!1;if(!e.launchedDateTime)return console.warn("MeetElise Chat will NOT appear. Building is NOT launched (based on launched date time)."),_o(n,i,!0,!1,"building_not_launched",o),!1;if(!e.active)return console.warn("MeetElise Chat will NOT appear. Building is NOT active."),_o(n,i,!0,!1,"building_not_active",o),!1;if(!e.webchatScopeConfigured)return console.warn("MeetElise Chat will NOT appear. Building is NOT webchat scope configured."),_o(n,i,!0,!1,"building_not_webchat_scope_configured",o),!1;const r=await async function(e){if(!e)return!1;try{return(await t().get(nn(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-leasing-in-maintenance-mode",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(i);return!r||(console.warn("MeetElise Chat will NOT appear. Chat is in maintenance mode."),_o(n,i,!0,!1,"building_in_maintenance_mode",o),!1)})(e,this.buildingSlug,this.orgSlug)&&(Sn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:(null==e?void 0:e.launchedDateTime)?.01:.05}),this.buildingWebchatView=e,await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1,"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0))},this.setBuildingDerivedInfo=async()=>{var e,i,n,o,r,a,s,l,u,c,d,h,p,f,g,m,b,v,y,w,C,x,A,S,k,T,E,_,O,P,N,M,I,D,U,L,R,B,j,H,F,$,z,Q,G,q,W;const V=this.buildingWebchatView;if(!V)return;V&&this.orgSlug&&Is(this.orgSlug,null!==(i=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==i?i:null,this.sampleRateToUse,this.buildingSlug,null!==(o=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==o?o:null);const[Y,K,X,Z,J,ee,te]=await Promise.all([Eo(this.buildingSlug),Ba(this.orgSlug,this.buildingSlug),rn(this.buildingSlug),an(this.buildingSlug),sn(this.buildingSlug),ln(this.buildingSlug),un(this.buildingSlug)]);this.buildingWebchatView&&(this.buildingWebchatView.phoneNumber=_e(V.phoneNumber)),this.designConcept=null!==(r=null==Y?void 0:Y.abTestType)&&void 0!==r?r:"",this.leadSources=K,this.featureFlagShowDropdown=X;const ie=V.textWithUsPhoneNumber?V.textWithUsPhoneNumber:await(async e=>{try{const i="https://app.meetelise.com",n=await t().get(`${i}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return An({logType:xn.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug),ne=null!==(s=null===(a=this.buildingWebchatView)||void 0===a?void 0:a.shouldShowPricingCalculatorDesktop)&&void 0!==s&&s,oe=null!==(u=null===(l=this.buildingWebchatView)||void 0===l?void 0:l.shouldShowPricingCalculatorMobile)&&void 0!==u&&u,re={callDesktop:null!==(d=null===(c=this.buildingWebchatView)||void 0===c?void 0:c.shouldShowPhoneDesktop)&&void 0!==d&&d,callMobile:null!==(p=null===(h=this.buildingWebchatView)||void 0===h?void 0:h.shouldShowPhoneMobile)&&void 0!==p&&p,chatDesktop:null!==(g=null===(f=this.buildingWebchatView)||void 0===f?void 0:f.shouldShowChatDesktop)&&void 0!==g&&g,chatMobile:null!==(b=null===(m=this.buildingWebchatView)||void 0===m?void 0:m.shouldShowChatMobile)&&void 0!==b&&b,emailDesktop:null!==(y=null===(v=this.buildingWebchatView)||void 0===v?void 0:v.shouldShowEmailDesktop)&&void 0!==y&&y,emailMobile:null!==(C=null===(w=this.buildingWebchatView)||void 0===w?void 0:w.shouldShowEmailMobile)&&void 0!==C&&C,textDesktop:null!==(A=(null===(x=this.buildingWebchatView)||void 0===x?void 0:x.shouldShowTextDesktop)&&!!ie)&&void 0!==A&&A,textMobile:null!==(k=(null===(S=this.buildingWebchatView)||void 0===S?void 0:S.shouldShowTextMobile)&&!!ie)&&void 0!==k&&k,sstDesktop:null!==(E=null===(T=this.buildingWebchatView)||void 0===T?void 0:T.shouldShowSstDesktop)&&void 0!==E&&E,sstMobile:null!==(O=null===(_=this.buildingWebchatView)||void 0===_?void 0:_.shouldShowSstMobile)&&void 0!==O&&O,calcDesktop:ne,calcMobile:oe};var ae,se;this.enabledChatWidgets=(e=>{const t=window.location.hostname;if(!xa.includes(t))return e;const i=(e=>{if(!e)return{};try{return e.split(",").reduce(((e,t)=>{const[i,n]=t.split(":");return i&&n&&i in Aa&&(e[i]="true"===n.toLowerCase()),e}),{})}catch(e){return console.warn("Error parsing widget overrides:",e),{}}})(new URLSearchParams(window.location.search).get("widgets"));if(0===Object.keys(i).length)return e;const n={...e};return Object.entries(i).forEach((([e,t])=>{const i=Aa[e];i&&(n[i.desktop]=t,n[i.mobile]=t)})),console.info("Applied widget overrides:",i),n})(re),this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(se=this.handleTourClicked,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");t&&t.startsWith("https://app.meetelise.com/")&&e.addEventListener("click",(e=>{e.preventDefault(),se(e)}))})),ee&&(e=>{document.querySelectorAll('a[href$="schedule-a-tour"]').forEach((t=>{t&&t.addEventListener("click",(t=>{t.preventDefault(),e(t)}))}))})(this.handleTourClicked),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach((t=>{var i;if(!t)return;const n=document.createElement("a");n.innerHTML=t.innerHTML,n.style.cursor="pointer",n.addEventListener("click",(t=>{t.preventDefault(),e(t)})),null===(i=t.parentNode)||void 0===i||i.replaceChild(n,t)}))})(this.handleTourClicked)):(null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&(ae=null!==(M=null===(N=this.LeadSourceClient)||void 0===N?void 0:N.leadSource)&&void 0!==M?M:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const i=t.includes("?")?"&":"?";e.setAttribute("href",t+i+`eliseParsedLeadSource=${encodeURIComponent(ae)}`)}}))),this.buildingWebchatView&&(this.primaryColor=null!==(I=this.buildingWebchatView.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(D=this.buildingWebchatView.secondaryColor)&&void 0!==D?D:null,this.foregroundColorOnPrimaryBackgroundColor=null!==(U=this.buildingWebchatView.foregroundColorOnPrimaryBackgroundColor)&&void 0!==U?U:null,this.foregroundColorOnSecondaryBackgroundColor=null!==(L=this.buildingWebchatView.foregroundColorOnSecondaryBackgroundColor)&&void 0!==L?L:null,this.webchatConfigHasAutoOpenChat=null!==(R=this.buildingWebchatView.autoOpenChat)&&void 0!==R&&R,this.requiresConsent=null!==(B=this.buildingWebchatView.requiresConsentForChat)&&void 0!==B&&B,this.hideMobileFeatures=null!==(j=this.buildingWebchatView.collapseMobileFeatures)&&void 0!==j&&j,this.privacyPolicyUrl=null!==(H=this.buildingWebchatView.privacyPolicyUrlForChat)&&void 0!==H?H:this.privacyPolicyUrl,this.buildingWebchatView.displayStyle===Nn.MINIMIZED&&(this.isMinimized=!0),this.buildingWebchatView.displayStyle===Nn.PILLS&&(this.designConcept=null),this.buildingWebchatView.displayStyle===Nn.EMOJI&&(this.designConcept=Nn.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=Ie),null===this.backgroundColor&&(this.backgroundColor=De);const le=null!==($=null===(F=this.buildingWebchatView)||void 0===F?void 0:F.phoneNumber)&&void 0!==$?$:"";let ue=null;if(Z&&(ue=await async function(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${i}`);return n.data?{number:_e(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(Q=null===(z=this.LeadSourceClient)||void 0===z?void 0:z.leadSource)&&void 0!==Q?Q:null),ue&&!ue.isMatch&&(ue.number=le)),J&&(null==ue?void 0:ue.number)){const e=rs(ue.number,this.orgSlug,this.buildingSlug);e>0&&Sn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const ce=localStorage.getItem("eliseai_phone_number_devtest");ce&&(console.info("Using dev test phone number: ",ce),rs(ce,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=ue||{number:le,isMatch:!1,isPropertyWebsiteCatchall:!0};const de=null!==(q=null===(G=this.LeadSourceClient)||void 0===G?void 0:G.leadSource)&&void 0!==q?q:null;if(de&&(this.leadSources.includes(de)||this.leadSources.push(de)),Wi(V.id),te&&this.buildingSlug&&(null===(W=this.buildingWebchatView)||void 0===W?void 0:W.isLiveOnApplications)){const e=((e,t,i)=>{var n;const o=[/thehavenatgreenhill\.securecafe\.com\/onlineleasing\/the-haven-at-greenhill\/oleapplication\.aspx(\?.*)?$/,/securecafe\.com\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/vsc\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/,/vsc\.myresman\.com\/Portal\/Applicants\/New\/.*(\?.*)?$/],r=document.body.getElementsByTagName("a");let a=0;for(let s=0;s<r.length;s++){const l=r[s];if(l.nodeType===Node.ELEMENT_NODE&&o.some((e=>e.test(l.href)))){const o=l.getAttribute("href"),r=(null===(n=l.textContent)||void 0===n?void 0:n.toLowerCase())||"",s=Os(r,e);l.setAttribute("href",s),a++,An({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"link-replacement",oldHref:o,newHref:s,website:window.location.href},logType:xn.info,buildingSlug:i,orgSlug:t})}}return 0===a&&An({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"no-select-buttons-found",website:window.location.href},logType:xn.warn,buildingSlug:i,orgSlug:t}),a})(`https://applications.eliseai.com/building/${this.buildingSlug}`,this.orgSlug,this.buildingSlug);e>0&&Sn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_application_link_replacement_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}},this.initializeChatVariables=async()=>{var e,i,n,o,r,a,s,l;if(!this.buildingWebchatView)return;const u=Za(this.buildingSlug),c=Ja(this.buildingSlug,u)?u:Xa(this.buildingSlug,!1);if(!c.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,i,n,o)=>{const r=kn();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:r,referrer:document.referrer,parsedUtmSource:r?r.utm_source:null,campaignSources:Object.values(Cn()).filter((e=>e))},n)return;if(!o){const t=this.getLeadSourceBodyIfValid(e);if(t&&!vi(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Ni(t.timestamp)}}const a={leadSource:t,leadId:i,buildingSlug:e,timestamp:ki(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Ni(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const i=JSON.parse(t);if(i.buildingSlug===e&&i.leadSource&&i.leadId&&i.timestamp&&!vi(Ni(i.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=i.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return i}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:i,referrer:n,campaignSources:o}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:i,building_slug:e,referrer:n,campaign_sources:o})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:i}){var n,o,r,a,s,l,u;try{if(!this.chatId)return console.error("chatId is not set"),null;if(!this.orgSlug)return console.error("orgId is not set"),null;let c=null,d=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(c=e),d=null===(n=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===n?void 0:n.value}}catch(e){console.error("error getting cookie")}return await t().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:i,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteOrigin,website_search:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:_n()(c)?null:c,extras:null!=d?d:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim();if(n.startsWith(e+"="))return n.substring((e+"=").length,-1===n.indexOf(";")?void 0:n.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:i}){try{const n={queryParams:kn(),buildingSlug:i,referrer:document.referrer,campaignSources:Cn()};let o=!1;const r=i?this.getLeadSourceBodyIfValid(i):null;if(r){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=r.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(n);if(!e)return this.leadSource=r.leadSource,this.leadSource;this.leadSource=e,o=!0}}const a=await this.fetchCurrentParsedLeadSource(n);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=i,i&&!a){const e=this.getLeadSourceBodyIfValid(i);if(e)return this.leadSource=e.leadSource,this.leadSource}if(i){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(i,a,e,!t&&!o,o)}return a}catch(e){console.error(e)}return null}},this.myPubnub=new os(this.buildingSlug,this.buildingWebchatView,this.orgSlug,null,c.leadId,this.LeadSourceClient,this.widgetType),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(e=this.LeadSourceClient)||void 0===e?void 0:e.generateUserLeadSource({leadId:null!==(n=null===(i=this.myPubnub)||void 0===i?void 0:i.leadUserId)&&void 0!==n?n:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),console.log("EliseAI Mapped Lead Source source: ",null===(o=this.LeadSourceClient)||void 0===o?void 0:o.leadSource),"property-website"!==On(this.orgSlug)?this.myPubnub.leadSource=null!==(a=null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource)&&void 0!==a?a:On(this.orgSlug):this.myPubnub.leadSource=null!==(l=null===(s=this.LeadSourceClient)||void 0===s?void 0:s.leadSource)&&void 0!==l?l:null,c.initiatedChat&&await this.myPubnub.initializePubnub(u)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),i=!t||!(t&&!Oi(Ni(t)));return!!e&&!!i&&!bi()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",ki(function(e,t){je(2,arguments);var i=it(t);return nt(e,6e4*i)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,i;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(i=this.launcherRef.value)||void 0===i||i.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,i,n;const o=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!o)return;const r=null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"),a=null==r?void 0:r.getBoundingClientRect();a&&(o.style.left=`${a.left}px`,o.style.top=`${a.bottom}px`)},this.handleKeydownTab=e=>{var t,i,n,o,r,a,s,l,u,c,d,h,p,f,g,m,b,v,y,w;if("Tab"===e.key){const C=this.displayPubnubChat?null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"):null!==(g=null!==(u=null===(l=null===(s=null===(a=null===(r=null===(o=this.shadowRoot)||void 0===o?void 0:o.getElementById("meetelise-launcher"))||void 0===r?void 0:r.shadowRoot)||void 0===a?void 0:a.getElementById("email-us-window"))||void 0===s?void 0:s.shadowRoot)||void 0===l?void 0:l.getElementById("email-us-form"))&&void 0!==u?u:null===(f=null===(p=null===(h=null===(d=null===(c=this.shadowRoot)||void 0===c?void 0:c.getElementById("meetelise-launcher"))||void 0===d?void 0:d.shadowRoot)||void 0===h?void 0:h.getElementById("tour-scheduler-window"))||void 0===p?void 0:p.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==g?g:null===(w=null===(y=null===(v=null===(b=null===(m=this.shadowRoot)||void 0===m?void 0:m.getElementById("meetelise-launcher"))||void 0===b?void 0:b.shadowRoot)||void 0===v?void 0:v.getElementById("call-us-window"))||void 0===y?void 0:y.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!C)return;e.preventDefault();const x=C.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),A=Array.from(x),S=A.findIndex((e=>e.matches(":focus")));A[(S+1)%A.length].focus()}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized,this.showTourNextToChat=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,localStorage.setItem("isChatOpen","true")},e.onExitChat=this.onExitChat)},this.onExitChat=()=>{this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,localStorage.setItem("isChatOpen","false")}}async handleChatInitializeAnalytics(){var e,t,i,n;this.analytics=new wn(this.orgSlug,this.buildingSlug,null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.channel)&&void 0!==t?t:"",null!==(n=null===(i=this.LeadSourceClient)||void 0===i?void 0:i.leadSource)&&void 0!==n?n:null),Math.random()<.05&&this.analytics.ping("webchat_heartbeat")}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),Ka(this.buildingSlug),this.myPubnub=null,this.displayPubnubChat=!1,await this.setupWebchat(),this.hideLauncher=!1}show(){this.launcher&&(this.launcher.style.display="")}hide(){this.launcher&&(this.launcher.style.display="none")}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.adjustPositionChatAdditionalActions),window.addEventListener("keydown",this.handleKeydownTab)}getDeepActiveElement(){let e=document.activeElement,t=0;for(;(null==e?void 0:e.shadowRoot)&&(null==e?void 0:e.shadowRoot.activeElement);)if(t+=1,e=null==e?void 0:e.shadowRoot.activeElement,t>100){An({logType:xn.error,buildingSlug:this.buildingSlug,logTitle:"[ERROR_GETTING_DEEP_ELEMENT]",logData:{message:"error getting deep active element"}});break}return e}updated(){this.adjustPositionChatAdditionalActions()}disconnectedCallback(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),window.removeEventListener("resize",this.adjustPositionChatAdditionalActions),window.removeEventListener("keydown",this.handleKeydownTab),super.disconnectedCallback()}render(){var e,t,i,n,o,r,a,s,l,u,c,d,h,p,f,g,m,b,v,y,w,C,x,A,S,k,T,E,_,O,P,N,M,I,D,U;Ca();const L=this.hideLauncher&&!this.isLoading&&!bi();return R`
6502
6502
  <meta name="viewport" content="width=device-width, initial-scale=1">
6503
6503
  <div id="aria-describe-info" style="display: none;">
6504
6504
  EliseAI widget that allows you to chat with a virtual assistant, book
@@ -455,9 +455,6 @@ export class MEChat extends LitElement {
455
455
  if (phoneNumberForSource && !phoneNumberForSource.isMatch) {
456
456
  phoneNumberForSource.number = buildingsPhoneNumber;
457
457
  }
458
- if (!this.LeadSourceClient?.leadSource && phoneNumberForSource) {
459
- phoneNumberForSource.number = buildingsPhoneNumber;
460
- }
461
458
  }
462
459
  if (featureFlagInsertDNIWebsite && phoneNumberForSource?.number) {
463
460
  const totalReplacements = insertDNIIntoWebsite(