@meetelise/chat 1.22.57 → 1.22.59
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 +1 -1
- package/public/demo/index.html +7 -2
- package/public/dist/index.js +2 -2
- package/src/WebComponent/me-chat.ts +33 -61
- package/src/fetchWebchatPreferences.ts +20 -23
package/package.json
CHANGED
package/public/demo/index.html
CHANGED
|
@@ -177,8 +177,13 @@
|
|
|
177
177
|
// organization: "conam",
|
|
178
178
|
// building: "b912c9ee-61f8-11ed-bbed-07208d4c2146",
|
|
179
179
|
|
|
180
|
-
organization: "test-company",
|
|
181
|
-
building: "3fc93384-91f5-11ed-98a3-43f5a2f42588",
|
|
180
|
+
// organization: "test-company",
|
|
181
|
+
// building: "3fc93384-91f5-11ed-98a3-43f5a2f42588",
|
|
182
|
+
|
|
183
|
+
// organization: "lincoln",
|
|
184
|
+
// building: "8c47ac2a-0485-11ed-ad73-e74957fe3493",
|
|
185
|
+
organization: "lincoln",
|
|
186
|
+
building: "97dbe0a2-9948-11ee-aa2c-8fdd8315b523",
|
|
182
187
|
|
|
183
188
|
// organization: "c259a157-cff3-470a-9ded-f6c5c8d917b8",
|
|
184
189
|
// building: "2c75381a-2286-11ee-a434-7bc2192a0c0e",
|
package/public/dist/index.js
CHANGED
|
@@ -1393,7 +1393,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
1393
1393
|
</div>
|
|
1394
1394
|
`}
|
|
1395
1395
|
</div>
|
|
1396
|
-
`}};var wi;bi.styles=[ai,gn],yi([le({attribute:!1})],bi.prototype,"tourTypeOptions",void 0),yi([le({attribute:!0})],bi.prototype,"chatId",void 0),yi([le({type:Number})],bi.prototype,"buildingId",void 0),yi([le({attribute:!0})],bi.prototype,"buildingSlug",void 0),yi([le({attribute:!0})],bi.prototype,"sgtUrl",void 0),yi([le({attribute:!0})],bi.prototype,"escortedToursLink",void 0),yi([le({attribute:!0})],bi.prototype,"virtualToursLink",void 0),yi([le({attribute:!0})],bi.prototype,"orgSlug",void 0),yi([le({attribute:!0})],bi.prototype,"hasDynamicSchedulingEnabled",void 0),yi([le({attribute:!0})],bi.prototype,"leadSourceClient",void 0),yi([le({attribute:!0})],bi.prototype,"buildingName",void 0),yi([ue()],bi.prototype,"tourType",void 0),yi([ue()],bi.prototype,"shouldShowTourType",void 0),yi([ue()],bi.prototype,"email",void 0),yi([ue()],bi.prototype,"phoneNumber",void 0),yi([ue()],bi.prototype,"availabilitiesGroupedByDay",void 0),yi([ue()],bi.prototype,"waitingForAvailabilities",void 0),yi([ue()],bi.prototype,"selectedDate",void 0),yi([ue()],bi.prototype,"selectedTime",void 0),yi([ue()],bi.prototype,"mobilePageIndex",void 0),yi([ue()],bi.prototype,"isSubmitting",void 0),yi([ue()],bi.prototype,"tourIsBooked",void 0),yi([ue()],bi.prototype,"shouldAllowScheduling",void 0),yi([ue()],bi.prototype,"shouldAllowScheduleLoading",void 0),yi([ue()],bi.prototype,"promptForReschedule",void 0),yi([ue()],bi.prototype,"canceledReschedule",void 0),yi([le({attribute:!1})],bi.prototype,"leadSources",void 0),yi([le({attribute:!0})],bi.prototype,"orgLegalName",void 0),yi([le({attribute:!0})],bi.prototype,"currentLeadSource",void 0),yi([le({attribute:!0})],bi.prototype,"featureFlagShowDropdown",void 0),yi([le({attribute:!0})],bi.prototype,"compactDesign",void 0),yi([le({attribute:!0})],bi.prototype,"primaryColor",void 0),yi([le({attribute:!0})],bi.prototype,"backgroundColor",void 0),yi([le({attribute:!0})],bi.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),yi([le({attribute:!0})],bi.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),yi([de(".nameContainer#firstName input")],bi.prototype,"firstNameInput",void 0),yi([de(".nameContainer#lastName input")],bi.prototype,"lastNameInput",void 0),yi([de(".inputContainer#email input")],bi.prototype,"emailInput",void 0),yi([de(".inputContainer#phone input")],bi.prototype,"phoneInput",void 0),yi([de("me-select#leadSource")],bi.prototype,"selectedLeadSource",void 0),yi([ue()],bi.prototype,"firstNameInputValue",void 0),yi([ue()],bi.prototype,"lastNameInputValue",void 0),yi([ue()],bi.prototype,"leadSourceInputValue",void 0),yi([ue()],bi.prototype,"errorGettingAvailabilities",void 0),bi=yi([ae("tour-scheduler")],bi),function(e){e.Guided="guided",e.Self="self",e.Virtual="virtual"}(wi||(wi={}));const Si={[wi.Guided]:Sn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent,[wi.Self]:Sn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided,[wi.Virtual]:Sn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing},Ti={[wi.Guided]:"escorted-tour",[wi.Self]:"self-guided-tour",[wi.Virtual]:"live-virtual-tour"};async function xi(e,n){var i;const r=`https://app.meetelise.com/api/pub/v1/organization/${e}/building/${n}`,o=(await t().get(r)).data;try{o.welcomeMessage=Ai(null!==(i=o.welcomeMessage)&&void 0!==i?i:"",o.userFirstName)}catch(e){console.error(e)}return o}const Ai=(e,t)=>e.replace(/elise/gi,t);var Ci,Oi;async function Ii(e){try{const n=await t().get(`https://app.meetelise.com/eliseCrmApi/webchat/config/building/${e}`);if(n.data)return cn(n.data)}catch(e){return null}return null}async function Ni(e){try{return(await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/ab-test-type`)).data}catch(e){return null}}!function(e){e.EMOJI="emoji",e.PILLS="pills",e.MINIMIZED="minimized"}(Ci||(Ci={})),function(e){e.ConceptEmoji="Concept 2 (Blue/White)"}(Oi||(Oi={}));const Ei=l`
|
|
1396
|
+
`}};var wi;bi.styles=[ai,gn],yi([le({attribute:!1})],bi.prototype,"tourTypeOptions",void 0),yi([le({attribute:!0})],bi.prototype,"chatId",void 0),yi([le({type:Number})],bi.prototype,"buildingId",void 0),yi([le({attribute:!0})],bi.prototype,"buildingSlug",void 0),yi([le({attribute:!0})],bi.prototype,"sgtUrl",void 0),yi([le({attribute:!0})],bi.prototype,"escortedToursLink",void 0),yi([le({attribute:!0})],bi.prototype,"virtualToursLink",void 0),yi([le({attribute:!0})],bi.prototype,"orgSlug",void 0),yi([le({attribute:!0})],bi.prototype,"hasDynamicSchedulingEnabled",void 0),yi([le({attribute:!0})],bi.prototype,"leadSourceClient",void 0),yi([le({attribute:!0})],bi.prototype,"buildingName",void 0),yi([ue()],bi.prototype,"tourType",void 0),yi([ue()],bi.prototype,"shouldShowTourType",void 0),yi([ue()],bi.prototype,"email",void 0),yi([ue()],bi.prototype,"phoneNumber",void 0),yi([ue()],bi.prototype,"availabilitiesGroupedByDay",void 0),yi([ue()],bi.prototype,"waitingForAvailabilities",void 0),yi([ue()],bi.prototype,"selectedDate",void 0),yi([ue()],bi.prototype,"selectedTime",void 0),yi([ue()],bi.prototype,"mobilePageIndex",void 0),yi([ue()],bi.prototype,"isSubmitting",void 0),yi([ue()],bi.prototype,"tourIsBooked",void 0),yi([ue()],bi.prototype,"shouldAllowScheduling",void 0),yi([ue()],bi.prototype,"shouldAllowScheduleLoading",void 0),yi([ue()],bi.prototype,"promptForReschedule",void 0),yi([ue()],bi.prototype,"canceledReschedule",void 0),yi([le({attribute:!1})],bi.prototype,"leadSources",void 0),yi([le({attribute:!0})],bi.prototype,"orgLegalName",void 0),yi([le({attribute:!0})],bi.prototype,"currentLeadSource",void 0),yi([le({attribute:!0})],bi.prototype,"featureFlagShowDropdown",void 0),yi([le({attribute:!0})],bi.prototype,"compactDesign",void 0),yi([le({attribute:!0})],bi.prototype,"primaryColor",void 0),yi([le({attribute:!0})],bi.prototype,"backgroundColor",void 0),yi([le({attribute:!0})],bi.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),yi([le({attribute:!0})],bi.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),yi([de(".nameContainer#firstName input")],bi.prototype,"firstNameInput",void 0),yi([de(".nameContainer#lastName input")],bi.prototype,"lastNameInput",void 0),yi([de(".inputContainer#email input")],bi.prototype,"emailInput",void 0),yi([de(".inputContainer#phone input")],bi.prototype,"phoneInput",void 0),yi([de("me-select#leadSource")],bi.prototype,"selectedLeadSource",void 0),yi([ue()],bi.prototype,"firstNameInputValue",void 0),yi([ue()],bi.prototype,"lastNameInputValue",void 0),yi([ue()],bi.prototype,"leadSourceInputValue",void 0),yi([ue()],bi.prototype,"errorGettingAvailabilities",void 0),bi=yi([ae("tour-scheduler")],bi),function(e){e.Guided="guided",e.Self="self",e.Virtual="virtual"}(wi||(wi={}));const Si={[wi.Guided]:Sn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent,[wi.Self]:Sn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided,[wi.Virtual]:Sn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing},Ti={[wi.Guided]:"escorted-tour",[wi.Self]:"self-guided-tour",[wi.Virtual]:"live-virtual-tour"};async function xi(e,n){var i;const r=`https://app.meetelise.com/api/pub/v1/organization/${e}/building/${n}`,o=(await t().get(r)).data;try{o.welcomeMessage=Ai(null!==(i=o.welcomeMessage)&&void 0!==i?i:"",o.userFirstName)}catch(e){console.error(e)}return o}const Ai=(e,t)=>e.replace(/elise/gi,t);var Ci,Oi;async function Ii(e){try{const n=await t().get(`https://app.meetelise.com/eliseCrmApi/webchat/config/v2/building/${e}`);if(n.data)return cn(n.data)}catch(e){return null}return null}async function Ni(e){try{return(await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/ab-test-type`)).data}catch(e){return null}}!function(e){e.EMOJI="emoji",e.PILLS="pills",e.MINIMIZED="minimized"}(Ci||(Ci={})),function(e){e.ConceptEmoji="Concept 2 (Blue/White)"}(Oi||(Oi={}));const Ei=l`
|
|
1397
1397
|
* {
|
|
1398
1398
|
font-family: "Helvetica Neue", Arial;
|
|
1399
1399
|
font-size: 14px;
|
|
@@ -4431,7 +4431,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
4431
4431
|
I agree
|
|
4432
4432
|
</button>
|
|
4433
4433
|
</div>
|
|
4434
|
-
`;var wo=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let So=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.primaryColor=null,this.backgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=$n.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=Fo.Default,this.onWidgetLoaded=rr(),this.onSstClose=rr(),this.enabledChatWidgets={callDesktop:!0,callMobile:!0,chatMobile:!0,chatDesktop:!0,emailDesktop:!0,emailMobile:!0,textDesktop:!0,textMobile:!0,sstDesktop:!0,sstMobile:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=xe(),this.firstUpdated=async()=>this.setupWebchat(),this.shouldShowWebchat=async(e,n)=>{if(!e)return console.warn("MeetElise Chat will NOT appear. Building does NOT exist."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_does_not_exist"}},sampleRate:this.sampleRateToUse}),!1;if(!e.launchedDateTime)return console.warn("MeetElise Chat will NOT appear. Building is NOT launched (based on launched date time)."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_launched"}},sampleRate:this.sampleRateToUse}),!1;if(!e.active)return console.warn("MeetElise Chat will NOT appear. Building is NOT active."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_active"}},sampleRate:this.sampleRateToUse}),!1;if(!e.webchatScopeConfigured)return console.warn("MeetElise Chat will NOT appear. Building is NOT webchat scope configured."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_webchat_scope_configured"}},sampleRate:this.sampleRateToUse}),!1;const i=await async function(e){if(!e)return!1;try{return(await t().get(Xn(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}}(n);return!i||(console.warn("MeetElise Chat will NOT appear. Chat is in maintenance mode."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_in_maintenance_mode"}},sampleRate:this.sampleRateToUse}),!1)},this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await xi(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,n)=>{const i=window.rentgrata;if(!i)return;const r=i.Widget;if(!r)return;const o=r.config;if(!o)return;const a=o.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!=n?n:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}this.sampleRateToUse=(null==e?void 0:e.launchedDateTime)?.02:.05,await this.shouldShowWebchat(e,this.buildingSlug)&&(ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:this.sampleRateToUse}),this.building=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,n,i,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,C,O,I,N,E,R,_,P,M,F,D,k,U;const B=this.building;if(!B)return;B&&this.orgSlug&&xo(this.orgSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==n?n:null,this.sampleRateToUse,this.buildingSlug,null!==(r=null===(i=this.LeadSourceClient)||void 0===i?void 0:i.leadSource)&&void 0!==r?r:null);const[L,q,J,j,H,G,z]=await Promise.all([Ni(this.buildingSlug),Ar(this.orgSlug,this.buildingSlug),Yn(this.buildingSlug),Zn(this.buildingSlug),Ii(B.id),ei(this.buildingSlug),ti(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(B.phoneNumber)),this.designConcept=null!==(o=null==L?void 0:L.abTestType)&&void 0!==o?o:"",this.leadSources=q,this.featureFlagShowDropdown=J;const W=B.textWithUsPhoneNumber?B.textWithUsPhoneNumber:await(async e=>{try{const n="https://app.meetelise.com",i=await t().get(`${n}/platformApi/webchat/${e}/phone-number`);if(i.data)return i.data}catch(t){return di({logType:ui.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var V,Q;this.enabledChatWidgets={callDesktop:!(null===(a=null==H?void 0:H.config.shouldShowPhone)||void 0===a||!a)||null!==(s=null==H?void 0:H.config.shouldShowPhoneDesktop)&&void 0!==s&&s,callMobile:!(null===(l=null==H?void 0:H.config.shouldShowPhone)||void 0===l||!l)||null!==(u=null==H?void 0:H.config.shouldShowPhoneMobile)&&void 0!==u&&u,chatDesktop:!(null===(d=null==H?void 0:H.config.shouldShowChat)||void 0===d||!d)||null!==(c=null==H?void 0:H.config.shouldShowChatDesktop)&&void 0!==c&&c,chatMobile:!(null===(p=null==H?void 0:H.config.shouldShowChat)||void 0===p||!p)||null!==(h=null==H?void 0:H.config.shouldShowChatMobile)&&void 0!==h&&h,emailDesktop:!(null===(f=null==H?void 0:H.config.shouldShowEmail)||void 0===f||!f)||null!==(m=null==H?void 0:H.config.shouldShowEmailDesktop)&&void 0!==m&&m,emailMobile:!(null===(g=null==H?void 0:H.config.shouldShowEmail)||void 0===g||!g)||null!==(v=null==H?void 0:H.config.shouldShowEmailMobile)&&void 0!==v&&v,textDesktop:(!(null===(y=null==H?void 0:H.config.shouldShowText)||void 0===y||!y)||null!==(b=null==H?void 0:H.config.shouldShowTextDesktop)&&void 0!==b&&b)&&!!W,textMobile:(!(null===(w=null==H?void 0:H.config.shouldShowText)||void 0===w||!w)||null!==(S=null==H?void 0:H.config.shouldShowTextMobile)&&void 0!==S&&S)&&!!W,sstDesktop:!(null===(T=null==H?void 0:H.config.shouldShowSst)||void 0===T||!T)||null!==(x=null==H?void 0:H.config.shouldShowSstDesktop)&&void 0!==x&&x,sstMobile:!(null===(A=null==H?void 0:H.config.shouldShowSst)||void 0===A||!A)||null!==(C=null==H?void 0:H.config.shouldShowSstMobile)&&void 0!==C&&C},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(Q=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(),Q(e)}))})),z&&(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 n;if(!t)return;const i=document.createElement("a");i.innerHTML=t.innerHTML,i.style.cursor="pointer",i.addEventListener("click",(t=>{t.preventDefault(),e(t)})),null===(n=t.parentNode)||void 0===n||n.replaceChild(i,t)}))})(this.handleTourClicked)):(null===(O=this.LeadSourceClient)||void 0===O?void 0:O.leadSource)&&(V=null!==(N=null===(I=this.LeadSourceClient)||void 0===I?void 0:I.leadSource)&&void 0!==N?N:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const n=t.includes("?")?"&":"?";e.setAttribute("href",t+n+`eliseParsedLeadSource=${encodeURIComponent(V)}`)}}))),H&&H.config&&(this.primaryColor=null!==(E=H.config.primaryColor)&&void 0!==E?E:null,this.backgroundColor=null!==(R=H.config.backgroundColor)&&void 0!==R?R:null,this.webchatConfigHasAutoOpenChat=H.config.autoOpenChat,this.requiresConsent=H.config.requiresConsent,this.hideMobileFeatures=H.config.hideMobileFeatures,this.privacyPolicyUrl=null!==(_=H.config.privacyPolicyUrl)&&void 0!==_?_:this.privacyPolicyUrl,H.config.displayStyle===Ci.MINIMIZED&&(this.isMinimized=!0),H.config.displayStyle===Ci.PILLS&&(this.designConcept=null),H.config.displayStyle===Ci.EMOJI&&(this.designConcept=Ci.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const K=null!==(M=null===(P=this.building)||void 0===P?void 0:P.phoneNumber)&&void 0!==M?M:"";let X=null;if(j&&(X=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Ne(i.data.number),isMatch:i.data.match,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(D=null===(F=this.LeadSourceClient)||void 0===F?void 0:F.leadSource)&&void 0!==D?D:null),X&&!X.isMatch&&(X.number=K)),G&&(null==X?void 0:X.number)){const e=zr(X.number,this.orgSlug,this.buildingSlug);e>0&&ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const $=localStorage.getItem("eliseai_phone_number_devtest");$&&(console.info("Using dev test phone number: ",$),zr($,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=X||{number:K,isMatch:!1,isPropertyWebsiteCatchall:!0};const Y=null!==(U=null===(k=this.LeadSourceClient)||void 0===k?void 0:k.leadSource)&&void 0!==U?U:null;Y&&(this.leadSources.includes(Y)||this.leadSources.push(Y)),Jn(B.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o,a,s,l;if(!this.building)return;const u=Br(this.buildingSlug),d=Lr(this.buildingSlug,u)?u:Ur(this.buildingSlug,!1);if(!d.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,n,i,r)=>{const o=pi();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(li()).filter((e=>e))},i)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t&&!hn(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:On(t.timestamp)}}const a={leadSource:t,leadId:n,buildingSlug:e,timestamp:bn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:On(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!hn(On(n.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=n.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return n}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:n,referrer:i,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:n,building_slug:e,referrer:i,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:n}){var i,r,o,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 d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(i=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===i?void 0:i.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:n,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.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:mi()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"="))return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:pi(),buildingSlug:n,referrer:document.referrer,campaignSources:li()};let r=!1;const o=n?this.getLeadSourceBodyIfValid(n):null;if(o){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=o.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(i);if(!e)return this.leadSource=o.leadSource,this.leadSource;this.leadSource=e,r=!0}}const a=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!a){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}if(n){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(n,a,e,!t&&!r,r)}return a}catch(e){console.error(e)}return null}},this.myPubnub=new Gr(this.buildingSlug,this.building,this.orgSlug,null,d.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!==(i=null===(n=this.myPubnub)||void 0===n?void 0:n.leadUserId)&&void 0!==i?i:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),console.log("EliseAI Mapped Lead Source source: ",null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource),"property-website"!==gi(this.orgSlug)?this.myPubnub.leadSource=null!==(a=null===(o=this.LeadSourceClient)||void 0===o?void 0:o.leadSource)&&void 0!==a?a:gi(this.orgSlug):this.myPubnub.leadSource=null!==(l=null===(s=this.LeadSourceClient)||void 0===s?void 0:s.leadSource)&&void 0!==l?l:null,d.initiatedChat&&await this.myPubnub.initializePubnub(u)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!An(On(t)));return!!e&&!!n&&!pn()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",bn(function(e,t){Le(2,arguments);var n=nt(t);return it(e,6e4*n)}(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,n;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===(n=this.launcherRef.value)||void 0===n||n.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,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.handleKeydownTab=e=>{var t,n,i,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w;if("Tab"===e.key){const S=this.displayPubnubChat?null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat-container"):null!==(m=null!==(u=null===(l=null===(s=null===(a=null===(o=null===(r=this.shadowRoot)||void 0===r?void 0:r.getElementById("meetelise-launcher"))||void 0===o?void 0:o.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===(h=null===(p=null===(c=null===(d=this.shadowRoot)||void 0===d?void 0:d.getElementById("meetelise-launcher"))||void 0===c?void 0:c.shadowRoot)||void 0===p?void 0:p.getElementById("tour-scheduler-window"))||void 0===h?void 0:h.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==m?m:null===(w=null===(b=null===(y=null===(v=null===(g=this.shadowRoot)||void 0===g?void 0:g.getElementById("meetelise-launcher"))||void 0===v?void 0:v.shadowRoot)||void 0===y?void 0:y.getElementById("call-us-window"))||void 0===b?void 0:b.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!S)return;e.preventDefault();const T=S.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),x=Array.from(T),A=x.findIndex((e=>e.matches(":focus")));x[(A+1)%x.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")},this.renderChatAdditionalActions=(e,t)=>{const n=this.building&&ke(this.building.orgId,this.building.id)&&this.primaryColor&&this.primaryColor!==Me?De(this.primaryColor,.6):"black";return U` <style>
|
|
4434
|
+
`;var wo=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let So=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.primaryColor=null,this.backgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=$n.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=Fo.Default,this.onWidgetLoaded=rr(),this.onSstClose=rr(),this.enabledChatWidgets={callDesktop:!1,callMobile:!1,chatMobile:!1,chatDesktop:!1,emailDesktop:!1,emailMobile:!1,textDesktop:!1,textMobile:!1,sstDesktop:!1,sstMobile:!1},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=xe(),this.firstUpdated=async()=>this.setupWebchat(),this.shouldShowWebchat=async(e,n)=>{if(!e)return console.warn("MeetElise Chat will NOT appear. Building does NOT exist."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_does_not_exist"}},sampleRate:this.sampleRateToUse}),!1;if(!e.launchedDateTime)return console.warn("MeetElise Chat will NOT appear. Building is NOT launched (based on launched date time)."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_launched"}},sampleRate:this.sampleRateToUse}),!1;if(!e.active)return console.warn("MeetElise Chat will NOT appear. Building is NOT active."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_active"}},sampleRate:this.sampleRateToUse}),!1;if(!e.webchatScopeConfigured)return console.warn("MeetElise Chat will NOT appear. Building is NOT webchat scope configured."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_webchat_scope_configured"}},sampleRate:this.sampleRateToUse}),!1;const i=await async function(e){if(!e)return!1;try{return(await t().get(Xn(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}}(n);return!i||(console.warn("MeetElise Chat will NOT appear. Chat is in maintenance mode."),ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_in_maintenance_mode"}},sampleRate:this.sampleRateToUse}),!1)},this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await xi(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,n)=>{const i=window.rentgrata;if(!i)return;const r=i.Widget;if(!r)return;const o=r.config;if(!o)return;const a=o.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!=n?n:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}this.sampleRateToUse=(null==e?void 0:e.launchedDateTime)?.05:.1,await this.shouldShowWebchat(e,this.buildingSlug)&&(ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:this.sampleRateToUse}),this.building=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,n,i,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,C,O,I;const N=this.building;if(!N)return;N&&this.orgSlug&&xo(this.orgSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==n?n:null,this.sampleRateToUse,this.buildingSlug,null!==(r=null===(i=this.LeadSourceClient)||void 0===i?void 0:i.leadSource)&&void 0!==r?r:null);const[E,R,_,P,M,F,D]=await Promise.all([Ni(this.buildingSlug),Ar(this.orgSlug,this.buildingSlug),Yn(this.buildingSlug),Zn(this.buildingSlug),Ii(N.id),ei(this.buildingSlug),ti(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(N.phoneNumber)),this.designConcept=null!==(o=null==E?void 0:E.abTestType)&&void 0!==o?o:"",this.leadSources=R,this.featureFlagShowDropdown=_;const k=N.textWithUsPhoneNumber?N.textWithUsPhoneNumber:await(async e=>{try{const n="https://app.meetelise.com",i=await t().get(`${n}/platformApi/webchat/${e}/phone-number`);if(i.data)return i.data}catch(t){return di({logType:ui.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var U,B;this.enabledChatWidgets={callDesktop:null!==(a=null==M?void 0:M.shouldShowPhoneDesktop)&&void 0!==a&&a,callMobile:null!==(s=null==M?void 0:M.shouldShowPhoneMobile)&&void 0!==s&&s,chatDesktop:null!==(l=null==M?void 0:M.shouldShowChatDesktop)&&void 0!==l&&l,chatMobile:null!==(u=null==M?void 0:M.shouldShowChatMobile)&&void 0!==u&&u,emailDesktop:null!==(d=null==M?void 0:M.shouldShowEmailDesktop)&&void 0!==d&&d,emailMobile:null!==(c=null==M?void 0:M.shouldShowEmailMobile)&&void 0!==c&&c,textDesktop:null!==(p=(null==M?void 0:M.shouldShowTextDesktop)&&!!k)&&void 0!==p&&p,textMobile:null!==(h=(null==M?void 0:M.shouldShowTextMobile)&&!!k)&&void 0!==h&&h,sstDesktop:null!==(f=null==M?void 0:M.shouldShowSstDesktop)&&void 0!==f&&f,sstMobile:null!==(m=null==M?void 0:M.shouldShowSstMobile)&&void 0!==m&&m},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(B=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(),B(e)}))})),D&&(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 n;if(!t)return;const i=document.createElement("a");i.innerHTML=t.innerHTML,i.style.cursor="pointer",i.addEventListener("click",(t=>{t.preventDefault(),e(t)})),null===(n=t.parentNode)||void 0===n||n.replaceChild(i,t)}))})(this.handleTourClicked)):(null===(g=this.LeadSourceClient)||void 0===g?void 0:g.leadSource)&&(U=null!==(y=null===(v=this.LeadSourceClient)||void 0===v?void 0:v.leadSource)&&void 0!==y?y:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const n=t.includes("?")?"&":"?";e.setAttribute("href",t+n+`eliseParsedLeadSource=${encodeURIComponent(U)}`)}}))),M&&(this.primaryColor=null!==(b=M.primaryColor)&&void 0!==b?b:null,this.backgroundColor=null!==(w=M.secondaryColor)&&void 0!==w?w:null,this.webchatConfigHasAutoOpenChat=M.autoOpenChat,this.requiresConsent=M.requiresConsentForChat,this.hideMobileFeatures=M.collapseMobileFeatures,this.privacyPolicyUrl=null!==(S=M.privacyPolicyUrlForChat)&&void 0!==S?S:this.privacyPolicyUrl,M.displayStyle===Ci.MINIMIZED&&(this.isMinimized=!0),M.displayStyle===Ci.PILLS&&(this.designConcept=null),M.displayStyle===Ci.EMOJI&&(this.designConcept=Ci.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const L=null!==(x=null===(T=this.building)||void 0===T?void 0:T.phoneNumber)&&void 0!==x?x:"";let q=null;if(P&&(q=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Ne(i.data.number),isMatch:i.data.match,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(C=null===(A=this.LeadSourceClient)||void 0===A?void 0:A.leadSource)&&void 0!==C?C:null),q&&!q.isMatch&&(q.number=L)),F&&(null==q?void 0:q.number)){const e=zr(q.number,this.orgSlug,this.buildingSlug);e>0&&ci({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const J=localStorage.getItem("eliseai_phone_number_devtest");J&&(console.info("Using dev test phone number: ",J),zr(J,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=q||{number:L,isMatch:!1,isPropertyWebsiteCatchall:!0};const j=null!==(I=null===(O=this.LeadSourceClient)||void 0===O?void 0:O.leadSource)&&void 0!==I?I:null;j&&(this.leadSources.includes(j)||this.leadSources.push(j)),Jn(N.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o,a,s,l;if(!this.building)return;const u=Br(this.buildingSlug),d=Lr(this.buildingSlug,u)?u:Ur(this.buildingSlug,!1);if(!d.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,n,i,r)=>{const o=pi();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(li()).filter((e=>e))},i)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t&&!hn(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:On(t.timestamp)}}const a={leadSource:t,leadId:n,buildingSlug:e,timestamp:bn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:On(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!hn(On(n.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=n.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return n}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:n,referrer:i,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:n,building_slug:e,referrer:i,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:n}){var i,r,o,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 d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(i=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===i?void 0:i.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:n,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.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:mi()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"="))return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:pi(),buildingSlug:n,referrer:document.referrer,campaignSources:li()};let r=!1;const o=n?this.getLeadSourceBodyIfValid(n):null;if(o){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=o.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(i);if(!e)return this.leadSource=o.leadSource,this.leadSource;this.leadSource=e,r=!0}}const a=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!a){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}if(n){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(n,a,e,!t&&!r,r)}return a}catch(e){console.error(e)}return null}},this.myPubnub=new Gr(this.buildingSlug,this.building,this.orgSlug,null,d.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!==(i=null===(n=this.myPubnub)||void 0===n?void 0:n.leadUserId)&&void 0!==i?i:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),console.log("EliseAI Mapped Lead Source source: ",null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource),"property-website"!==gi(this.orgSlug)?this.myPubnub.leadSource=null!==(a=null===(o=this.LeadSourceClient)||void 0===o?void 0:o.leadSource)&&void 0!==a?a:gi(this.orgSlug):this.myPubnub.leadSource=null!==(l=null===(s=this.LeadSourceClient)||void 0===s?void 0:s.leadSource)&&void 0!==l?l:null,d.initiatedChat&&await this.myPubnub.initializePubnub(u)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!An(On(t)));return!!e&&!!n&&!pn()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",bn(function(e,t){Le(2,arguments);var n=nt(t);return it(e,6e4*n)}(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,n;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===(n=this.launcherRef.value)||void 0===n||n.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,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.handleKeydownTab=e=>{var t,n,i,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w;if("Tab"===e.key){const S=this.displayPubnubChat?null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat-container"):null!==(m=null!==(u=null===(l=null===(s=null===(a=null===(o=null===(r=this.shadowRoot)||void 0===r?void 0:r.getElementById("meetelise-launcher"))||void 0===o?void 0:o.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===(h=null===(p=null===(c=null===(d=this.shadowRoot)||void 0===d?void 0:d.getElementById("meetelise-launcher"))||void 0===c?void 0:c.shadowRoot)||void 0===p?void 0:p.getElementById("tour-scheduler-window"))||void 0===h?void 0:h.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==m?m:null===(w=null===(b=null===(y=null===(v=null===(g=this.shadowRoot)||void 0===g?void 0:g.getElementById("meetelise-launcher"))||void 0===v?void 0:v.shadowRoot)||void 0===y?void 0:y.getElementById("call-us-window"))||void 0===b?void 0:b.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!S)return;e.preventDefault();const T=S.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),x=Array.from(T),A=x.findIndex((e=>e.matches(":focus")));x[(A+1)%x.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")},this.renderChatAdditionalActions=(e,t)=>{const n=this.building&&ke(this.building.orgId,this.building.id)&&this.primaryColor&&this.primaryColor!==Me?De(this.primaryColor,.6):"black";return U` <style>
|
|
4435
4435
|
#{id}::after {
|
|
4436
4436
|
border-right-color: ${n} !important;
|
|
4437
4437
|
}
|
|
@@ -217,16 +217,16 @@ export class MEChat extends LitElement {
|
|
|
217
217
|
sstDesktop: boolean;
|
|
218
218
|
sstMobile: boolean;
|
|
219
219
|
} = {
|
|
220
|
-
callDesktop:
|
|
221
|
-
callMobile:
|
|
222
|
-
chatMobile:
|
|
223
|
-
chatDesktop:
|
|
224
|
-
emailDesktop:
|
|
225
|
-
emailMobile:
|
|
226
|
-
textDesktop:
|
|
227
|
-
textMobile:
|
|
228
|
-
sstDesktop:
|
|
229
|
-
sstMobile:
|
|
220
|
+
callDesktop: false,
|
|
221
|
+
callMobile: false,
|
|
222
|
+
chatMobile: false,
|
|
223
|
+
chatDesktop: false,
|
|
224
|
+
emailDesktop: false,
|
|
225
|
+
emailMobile: false,
|
|
226
|
+
textDesktop: false,
|
|
227
|
+
textMobile: false,
|
|
228
|
+
sstDesktop: false,
|
|
229
|
+
sstMobile: false,
|
|
230
230
|
};
|
|
231
231
|
|
|
232
232
|
@state()
|
|
@@ -361,7 +361,7 @@ export class MEChat extends LitElement {
|
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
// We use a lower sample rate if not launched yet because likely still in onboarding process
|
|
364
|
-
this.sampleRateToUse = building?.launchedDateTime ? 0.
|
|
364
|
+
this.sampleRateToUse = building?.launchedDateTime ? 0.05 : 0.1;
|
|
365
365
|
|
|
366
366
|
const shouldShowWebchat = await this.shouldShowWebchat(
|
|
367
367
|
building,
|
|
@@ -451,48 +451,20 @@ export class MEChat extends LitElement {
|
|
|
451
451
|
: await getBuildingPhoneNumber(this.buildingSlug);
|
|
452
452
|
|
|
453
453
|
this.enabledChatWidgets = {
|
|
454
|
-
callDesktop:
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
? true
|
|
461
|
-
: webchatSettings?.config.shouldShowPhoneMobile ?? false,
|
|
462
|
-
chatDesktop:
|
|
463
|
-
webchatSettings?.config.shouldShowChat ?? false
|
|
464
|
-
? true
|
|
465
|
-
: webchatSettings?.config.shouldShowChatDesktop ?? false,
|
|
466
|
-
chatMobile:
|
|
467
|
-
webchatSettings?.config.shouldShowChat ?? false
|
|
468
|
-
? true
|
|
469
|
-
: webchatSettings?.config.shouldShowChatMobile ?? false,
|
|
470
|
-
emailDesktop:
|
|
471
|
-
webchatSettings?.config.shouldShowEmail ?? false
|
|
472
|
-
? true
|
|
473
|
-
: webchatSettings?.config.shouldShowEmailDesktop ?? false,
|
|
474
|
-
emailMobile:
|
|
475
|
-
webchatSettings?.config.shouldShowEmail ?? false
|
|
476
|
-
? true
|
|
477
|
-
: webchatSettings?.config.shouldShowEmailMobile ?? false,
|
|
454
|
+
callDesktop: webchatSettings?.shouldShowPhoneDesktop ?? false,
|
|
455
|
+
callMobile: webchatSettings?.shouldShowPhoneMobile ?? false,
|
|
456
|
+
chatDesktop: webchatSettings?.shouldShowChatDesktop ?? false,
|
|
457
|
+
chatMobile: webchatSettings?.shouldShowChatMobile ?? false,
|
|
458
|
+
emailDesktop: webchatSettings?.shouldShowEmailDesktop ?? false,
|
|
459
|
+
emailMobile: webchatSettings?.shouldShowEmailMobile ?? false,
|
|
478
460
|
textDesktop:
|
|
479
|
-
(webchatSettings?.
|
|
480
|
-
|
|
481
|
-
: webchatSettings?.config.shouldShowTextDesktop ?? false) &&
|
|
482
|
-
!!buildingPhoneNumber,
|
|
461
|
+
(webchatSettings?.shouldShowTextDesktop && !!buildingPhoneNumber) ??
|
|
462
|
+
false,
|
|
483
463
|
textMobile:
|
|
484
|
-
(webchatSettings?.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
sstDesktop:
|
|
489
|
-
webchatSettings?.config.shouldShowSst ?? false
|
|
490
|
-
? true
|
|
491
|
-
: webchatSettings?.config.shouldShowSstDesktop ?? false,
|
|
492
|
-
sstMobile:
|
|
493
|
-
webchatSettings?.config.shouldShowSst ?? false
|
|
494
|
-
? true
|
|
495
|
-
: webchatSettings?.config.shouldShowSstMobile ?? false,
|
|
464
|
+
(webchatSettings?.shouldShowTextMobile && !!buildingPhoneNumber) ??
|
|
465
|
+
false,
|
|
466
|
+
sstDesktop: webchatSettings?.shouldShowSstDesktop ?? false,
|
|
467
|
+
sstMobile: webchatSettings?.shouldShowSstMobile ?? false,
|
|
496
468
|
};
|
|
497
469
|
|
|
498
470
|
if (
|
|
@@ -515,23 +487,23 @@ export class MEChat extends LitElement {
|
|
|
515
487
|
}
|
|
516
488
|
}
|
|
517
489
|
|
|
518
|
-
if (webchatSettings
|
|
519
|
-
this.primaryColor = webchatSettings.
|
|
520
|
-
this.backgroundColor = webchatSettings.
|
|
521
|
-
this.webchatConfigHasAutoOpenChat = webchatSettings.
|
|
522
|
-
this.requiresConsent = webchatSettings.
|
|
523
|
-
this.hideMobileFeatures = webchatSettings.
|
|
490
|
+
if (webchatSettings) {
|
|
491
|
+
this.primaryColor = webchatSettings.primaryColor ?? null;
|
|
492
|
+
this.backgroundColor = webchatSettings.secondaryColor ?? null;
|
|
493
|
+
this.webchatConfigHasAutoOpenChat = webchatSettings.autoOpenChat;
|
|
494
|
+
this.requiresConsent = webchatSettings.requiresConsentForChat;
|
|
495
|
+
this.hideMobileFeatures = webchatSettings.collapseMobileFeatures;
|
|
524
496
|
this.privacyPolicyUrl =
|
|
525
|
-
webchatSettings.
|
|
497
|
+
webchatSettings.privacyPolicyUrlForChat ?? this.privacyPolicyUrl;
|
|
526
498
|
|
|
527
|
-
if (webchatSettings.
|
|
499
|
+
if (webchatSettings.displayStyle === DesignConcepts.MINIMIZED) {
|
|
528
500
|
// this.designConcept = DesignConcepts.MINIMIZED; // uncomment this if we want to remove the minimize/expand option
|
|
529
501
|
this.isMinimized = true;
|
|
530
502
|
}
|
|
531
|
-
if (webchatSettings.
|
|
503
|
+
if (webchatSettings.displayStyle === DesignConcepts.PILLS) {
|
|
532
504
|
this.designConcept = null; // default design concept is PILLS, no need to specify here
|
|
533
505
|
}
|
|
534
|
-
if (webchatSettings.
|
|
506
|
+
if (webchatSettings.displayStyle === DesignConcepts.EMOJI) {
|
|
535
507
|
this.designConcept = DesignConcepts.EMOJI;
|
|
536
508
|
}
|
|
537
509
|
|
|
@@ -2,33 +2,30 @@ import axios from "axios";
|
|
|
2
2
|
import { camelize } from "./utils";
|
|
3
3
|
|
|
4
4
|
export interface WebchatSettings {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
id: number;
|
|
6
|
+
orgId: number | null;
|
|
7
|
+
buildingId: number | null;
|
|
8
|
+
displayStyle: DesignConcepts | null;
|
|
9
|
+
primaryColor: string | null;
|
|
10
|
+
secondaryColor: string | null;
|
|
11
|
+
foregroundColorOnPrimaryBackgroundColor: string | null;
|
|
12
|
+
foregroundColorOnSecondaryBackgroundColor: string | null;
|
|
12
13
|
shouldShowChatDesktop: boolean;
|
|
13
14
|
shouldShowChatMobile: boolean;
|
|
14
|
-
shouldShowEmail: boolean;
|
|
15
|
-
shouldShowEmailDesktop: boolean;
|
|
16
|
-
shouldShowEmailMobile: boolean;
|
|
17
|
-
shouldShowPhone: boolean;
|
|
18
|
-
shouldShowPhoneDesktop: boolean;
|
|
19
|
-
shouldShowPhoneMobile: boolean;
|
|
20
|
-
shouldShowText: boolean;
|
|
21
15
|
shouldShowTextDesktop: boolean;
|
|
22
16
|
shouldShowTextMobile: boolean;
|
|
23
|
-
|
|
17
|
+
shouldShowPhoneDesktop: boolean;
|
|
18
|
+
shouldShowPhoneMobile: boolean;
|
|
19
|
+
shouldShowEmailDesktop: boolean;
|
|
20
|
+
shouldShowEmailMobile: boolean;
|
|
24
21
|
shouldShowSstDesktop: boolean;
|
|
25
22
|
shouldShowSstMobile: boolean;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
requiresConsentForChat: boolean;
|
|
24
|
+
privacyPolicyUrlForChat: string | null;
|
|
25
|
+
collapseMobileFeatures: boolean;
|
|
26
|
+
autoOpenChat: boolean;
|
|
27
|
+
isInheritingFromOrg: boolean;
|
|
28
|
+
isGlobalDefault: boolean;
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
export enum DesignConcepts {
|
|
@@ -43,11 +40,11 @@ export default async function fetchWebchatPreferences(
|
|
|
43
40
|
const host = "https://app.meetelise.com";
|
|
44
41
|
try {
|
|
45
42
|
const webchatPreferencesResponse = await axios.get(
|
|
46
|
-
`${host}/eliseCrmApi/webchat/config/building/${buildingId}`
|
|
43
|
+
`${host}/eliseCrmApi/webchat/config/v2/building/${buildingId}`
|
|
47
44
|
);
|
|
48
45
|
|
|
49
46
|
if (webchatPreferencesResponse.data) {
|
|
50
|
-
return camelize(webchatPreferencesResponse.data);
|
|
47
|
+
return camelize<WebchatSettings>(webchatPreferencesResponse.data);
|
|
51
48
|
}
|
|
52
49
|
} catch (_) {
|
|
53
50
|
return null;
|