@meetelise/chat 1.20.75 → 1.20.76

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.20.75",
3
+ "version": "1.20.76",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -472,7 +472,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
472
472
  .option.active {
473
473
  background-color: var(--active-option-color);
474
474
  }
475
- `,Zt],$t([de({attribute:!1})],en.prototype,"options",void 0),$t([de({type:String})],en.prototype,"placeholder",void 0),$t([de({type:String})],en.prototype,"value",void 0),$t([ce()],en.prototype,"activeOption",void 0),$t([ce()],en.prototype,"isOpen",void 0),$t([pe("#select",!0)],en.prototype,"meSelect",void 0),en=$t([ue("me-select")],en);var nn=n(9991),rn=n(7739),on=n.n(rn);function an(e){return Ue(1,arguments),Be(e).getTime()<Date.now()}Math.pow(10,8);var sn=36e5;function un(e,t){Ue(1,arguments);var n=t||{},i=null==n.additionalDigits?2:et(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r,o=fn(e);if(o.date){var a=hn(o.date,i);r=mn(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=gn(o.time),isNaN(l)))return new Date(NaN);if(!o.timezone){var d=new Date(u+l),c=new Date(0);return c.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),c.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),c}return s=bn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var ln={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},dn=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,cn=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,pn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function fn(e){var t,n={},i=e.split(ln.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],ln.timeZoneDelimiter.test(n.date)&&(n.date=e.split(ln.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=ln.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function hn(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=e.match(n);if(!i)return{year:NaN,restDateString:""};var r=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:null===o?r:100*o,restDateString:e.slice((i[1]||i[2]).length)}}function mn(e,t){if(null===t)return new Date(NaN);var n=e.match(dn);if(!n)return new Date(NaN);var i=!!n[4],r=vn(n[1]),o=vn(n[2])-1,a=vn(n[3]),s=vn(n[4]),u=vn(n[5])-1;if(i)return function(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}(0,s,u)?function(e,t,n){var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*(t-1)+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}(t,s,u):new Date(NaN);var l=new Date(0);return function(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(wn[t]||(Sn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(Sn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function vn(e){return e?parseInt(e):1}function gn(e){var t=e.match(cn);if(!t)return NaN;var n=yn(t[1]),i=yn(t[2]),r=yn(t[3]);return function(e,t,n){return 24===e?0===t&&0===n:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}(n,i,r)?n*sn+6e4*i+1e3*r:NaN}function yn(e){return e&&parseFloat(e.replace(",","."))||0}function bn(e){if("Z"===e)return 0;var t=e.match(pn);if(!t)return 0;var n="+"===t[1]?-1:1,i=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,r)?n*(i*sn+6e4*r):NaN}var wn=[31,null,31,30,31,30,31,31,30,31,30,31];function Sn(e){return e%400==0||e%4==0&&e%100!=0}const Tn={buildingId:null,availabilities:{}},An=async e=>{e&&(Tn.buildingId=e);const n=Tn.buildingId;if(!n)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const i=Tn.availabilities;if(i[n])return i[n];const r=function(e){Ue(1,arguments);var t=Be(e);return t.setHours(0,0,0,0),t}(Date.now()),o=tn(function(e){Ue(1,arguments);var t=Be(e);return t.setHours(23,59,59,999),t}(function(e,t){Ue(2,arguments);var n=Be(e),i=et(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(r,30))),a=`https://app.meetelise.com/api/pub/v1/buildings/${n}/tour/availabilities?startTime=${tn(r)}&endTime=${o}`,s=await t().get(a);return Tn.availabilities[n]=s.data,s.data},xn=async(e,t)=>{var n,i;const r=await An(t),o=(null===(n=r.availability)||void 0===n?void 0:n[e])?null===(i=r.availability)||void 0===i?void 0:i[e].availableTourStartTimes:[];return r.availability?{...r.availability[e],availableTourStartTimes:o}:null},On=async(e,t)=>{var n,i;const r=await xn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>Le(un(e))&&!an(un(e)))):[])||void 0===n?void 0:n.map((e=>Cn(e)))};return on()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>kt(new Date(e.datetime),"yyyy-MM-dd")))},Cn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});var In=n(6486),Nn=n(4184),Rn=n.n(Nn);async function En({chatId:e,website:n,referrer:i,buildingSlug:r,selectedLeadSource:o}){try{return(await t().post("https://app.meetelise.com/platformApi/webchat/lead-sourced",{chat_id:e,website:n,referrer:i,query_params:Fn(),building_slug:r,timestamp:new Date,selected_lead_source:o})).data}catch(e){return null}}function Fn(){return Object.fromEntries(new URLSearchParams(window.location.search))}const _n=e=>`https://app.meetelise.com/platformApi/webchat/${e}/chat-ui-feature-flag`;var Mn;async function Pn(e){try{const n=await t().get(_n(e),{params:{building_slug:e,flag_type:"string",feature_flag:"webchat-marketing-source-dropdown-configuration",default_str:"always",default_bool:!0}});return"on-attribution-failure"===n.data?Mn.onAttributionFailure:"never"===n.data?Mn.never:Mn.always}catch(e){return Mn.always}}async function Dn(e){try{return(await t().get(_n(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-dni-phone-number-by-source",default_str:null,default_bool:!1}})).data}catch(e){return!1}}!function(e){e.onAttributionFailure="on-attribution-failure",e.never="never",e.always="always"}(Mn||(Mn={}));const qn=(e,t={})=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:e,...t})};var Un=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 Bn=class extends ae{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.tourType=null,this.shouldShowTourType={[Jn.Guided]:!0,[Jn.Self]:!0,[Jn.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.leadSources=[],this.currentLeadSource="",this.featureFlagShowDropdown="",this.firstUpdated=async()=>{const e=await(async()=>{var e,t,n,i,r,o;return{[Jn.Guided]:!!(null===(t=null===(e=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[Jn.Self]:!!(null===(i=null===(n=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[Jn.Virtual]:!!(null===(o=null===(r=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})();this.shouldShowTourType={[Jn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[Jn.Guided],[Jn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[Jn.Self],[Jn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[Jn.Virtual]},1===Object.values(this.shouldShowTourType).reduce(((e,t)=>!0===t?e+1:e),0)&&(this.tourType=Object.keys(this.shouldShowTourType).find((e=>this.shouldShowTourType[e]))),null!==this.tourType?(this.availabilitiesGroupedByDay=await On(kn[this.tourType]),this.waitingForAvailabilities=!1):this.waitingForAvailabilities=!1},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await On(kn[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Me(e)){if("Backspace"===e.key){if(Me(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ee(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Me(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ee(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ee(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,n;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const i=new URLSearchParams(window.location.search),r=this.selectedLeadSource&&this.selectedLeadSource.value?this.selectedLeadSource.value:this.currentLeadSource,o=[...new Set(r?[r,"property-website"]:["property-website"])];qn("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,firstName:this.firstNameInput.value,lastName:this.lastNameInput.value,tourType:Ln[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unitNumbers:this.unitTypeSelect&&this.unitTypeSelect.value?[this.unitTypeSelect.value]:null,originatingSource:o.find((e=>"property-website"!==e))||null});const a={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(n=this.phoneNumber.match(/\d/g))||void 0===n?void 0:n.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:Ln[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unit_numbers:this.unitTypeSelect&&this.unitTypeSelect.value?[this.unitTypeSelect.value]:null,lead_sources:[...new Set(r?[r,"property-website"]:["property-website"])],query_params:Object.fromEntries(i.entries())};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/scheduleMe",a,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),await En({chatId:this.chatId,website:window.location.origin,referrer:document.referrer,buildingSlug:this.buildingSlug,selectedLeadSource:null!=r?r:""}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>J`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>J`${this.dateAndTimeMenu(!0)}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>J`<action-confirm-button
475
+ `,Zt],$t([de({attribute:!1})],en.prototype,"options",void 0),$t([de({type:String})],en.prototype,"placeholder",void 0),$t([de({type:String})],en.prototype,"value",void 0),$t([ce()],en.prototype,"activeOption",void 0),$t([ce()],en.prototype,"isOpen",void 0),$t([pe("#select",!0)],en.prototype,"meSelect",void 0),en=$t([ue("me-select")],en);var nn=n(9991),rn=n(7739),on=n.n(rn);function an(e){return Ue(1,arguments),Be(e).getTime()<Date.now()}Math.pow(10,8);var sn=36e5;function un(e,t){Ue(1,arguments);var n=t||{},i=null==n.additionalDigits?2:et(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r,o=fn(e);if(o.date){var a=hn(o.date,i);r=mn(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=gn(o.time),isNaN(l)))return new Date(NaN);if(!o.timezone){var d=new Date(u+l),c=new Date(0);return c.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),c.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),c}return s=bn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var ln={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},dn=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,cn=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,pn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function fn(e){var t,n={},i=e.split(ln.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],ln.timeZoneDelimiter.test(n.date)&&(n.date=e.split(ln.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=ln.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function hn(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=e.match(n);if(!i)return{year:NaN,restDateString:""};var r=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:null===o?r:100*o,restDateString:e.slice((i[1]||i[2]).length)}}function mn(e,t){if(null===t)return new Date(NaN);var n=e.match(dn);if(!n)return new Date(NaN);var i=!!n[4],r=vn(n[1]),o=vn(n[2])-1,a=vn(n[3]),s=vn(n[4]),u=vn(n[5])-1;if(i)return function(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}(0,s,u)?function(e,t,n){var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*(t-1)+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}(t,s,u):new Date(NaN);var l=new Date(0);return function(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(wn[t]||(Sn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(Sn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function vn(e){return e?parseInt(e):1}function gn(e){var t=e.match(cn);if(!t)return NaN;var n=yn(t[1]),i=yn(t[2]),r=yn(t[3]);return function(e,t,n){return 24===e?0===t&&0===n:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}(n,i,r)?n*sn+6e4*i+1e3*r:NaN}function yn(e){return e&&parseFloat(e.replace(",","."))||0}function bn(e){if("Z"===e)return 0;var t=e.match(pn);if(!t)return 0;var n="+"===t[1]?-1:1,i=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,r)?n*(i*sn+6e4*r):NaN}var wn=[31,null,31,30,31,30,31,31,30,31,30,31];function Sn(e){return e%400==0||e%4==0&&e%100!=0}const Tn={buildingId:null,availabilities:{}},An=async e=>{e&&(Tn.buildingId=e);const n=Tn.buildingId;if(!n)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const i=Tn.availabilities;if(i[n])return i[n];const r=function(e){Ue(1,arguments);var t=Be(e);return t.setHours(0,0,0,0),t}(Date.now()),o=tn(function(e){Ue(1,arguments);var t=Be(e);return t.setHours(23,59,59,999),t}(function(e,t){Ue(2,arguments);var n=Be(e),i=et(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(r,30))),a=`https://app.meetelise.com/api/pub/v1/buildings/${n}/tour/availabilities?startTime=${tn(r)}&endTime=${o}`,s=await t().get(a);return Tn.availabilities[n]=s.data,s.data},xn=async(e,t)=>{var n,i;const r=await An(t),o=(null===(n=r.availability)||void 0===n?void 0:n[e])?null===(i=r.availability)||void 0===i?void 0:i[e].availableTourStartTimes:[];return r.availability?{...r.availability[e],availableTourStartTimes:o}:null},On=async(e,t)=>{var n,i;const r=await xn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>Le(un(e))&&!an(un(e)))):[])||void 0===n?void 0:n.map((e=>Cn(e)))};return on()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>kt(new Date(e.datetime),"yyyy-MM-dd")))},Cn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});var In=n(6486),Nn=n(4184),Rn=n.n(Nn);async function En({chatId:e,website:n,referrer:i,buildingSlug:r,selectedLeadSource:o}){try{return(await t().post("https://app.meetelise.com/platformApi/webchat/lead-sourced",{chat_id:e,website:n,referrer:i,query_params:Fn(),building_slug:r,timestamp:new Date,selected_lead_source:o})).data}catch(e){return null}}function Fn(){return Object.fromEntries(new URLSearchParams(window.location.search))}const _n=e=>`https://app.meetelise.com/platformApi/webchat/${e}/chat-ui-feature-flag`;var Mn;async function Pn(e){try{const n=await t().get(_n(e),{params:{building_slug:e,flag_type:"string",feature_flag:"webchat-marketing-source-dropdown-configuration",default_str:"always",default_bool:!0}});return"on-attribution-failure"===n.data?Mn.onAttributionFailure:"never"===n.data?Mn.never:Mn.always}catch(e){return Mn.always}}async function Dn(e){try{return(await t().get(_n(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-dni-phone-number-by-source",default_str:null,default_bool:!1}})).data}catch(e){return!1}}!function(e){e.onAttributionFailure="on-attribution-failure",e.never="never",e.always="always"}(Mn||(Mn={}));const qn=(e,t={})=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:e,...t})};var Un=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 Bn=class extends ae{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.tourType=null,this.shouldShowTourType={[Jn.Guided]:!0,[Jn.Self]:!0,[Jn.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.leadSources=[],this.currentLeadSource="",this.featureFlagShowDropdown="",this.firstUpdated=async()=>{const e=await(async()=>{var e,t,n,i,r,o;return{[Jn.Guided]:!!(null===(t=null===(e=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[Jn.Self]:!!(null===(i=null===(n=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[Jn.Virtual]:!!(null===(o=null===(r=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})();this.shouldShowTourType={[Jn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[Jn.Guided],[Jn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[Jn.Self],[Jn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[Jn.Virtual]},1===Object.values(this.shouldShowTourType).reduce(((e,t)=>!0===t?e+1:e),0)&&(this.tourType=Object.keys(this.shouldShowTourType).find((e=>this.shouldShowTourType[e]))),null!==this.tourType?(this.availabilitiesGroupedByDay=await On(kn[this.tourType]),this.waitingForAvailabilities=!1):this.waitingForAvailabilities=!1},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await On(kn[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Me(e)){if("Backspace"===e.key){if(Me(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ee(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Me(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ee(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ee(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,n;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const i=new URLSearchParams(window.location.search),r=this.selectedLeadSource&&this.selectedLeadSource.value?this.selectedLeadSource.value:this.currentLeadSource,o=[...new Set(r?[r,"property-website"]:["property-website"])];qn("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,firstName:this.firstNameInput.value,lastName:this.lastNameInput.value,tourType:Ln[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unitNumbers:this.unitTypeSelect&&this.unitTypeSelect.value?[this.unitTypeSelect.value]:null,originatingSource:o.find((e=>"property-website"!==e))||null});const a={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(n=this.phoneNumber.match(/\d/g))||void 0===n?void 0:n.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:Ln[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unit_numbers:this.unitTypeSelect&&this.unitTypeSelect.value?[this.unitTypeSelect.value]:null,lead_sources:[...new Set(r?[r,"property-website"]:["property-website"])],query_params:Object.fromEntries(i.entries())};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",a,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),await En({chatId:this.chatId,website:window.location.origin,referrer:document.referrer,buildingSlug:this.buildingSlug,selectedLeadSource:null!=r?r:""}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>J`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>J`${this.dateAndTimeMenu(!0)}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>J`<action-confirm-button
476
476
  id="schedule"
477
477
  .onClick=${this.submit}
478
478
  .isLoading=${this.isSubmitting}
@@ -425,7 +425,7 @@ export class TourScheduler extends LitElement {
425
425
  // @ts-ignore
426
426
  query_params: Object.fromEntries(queryParams.entries()),
427
427
  };
428
- const url = `https://app.meetelise.com/platformApi/state/create/scheduleMe`;
428
+ const url = `https://app.meetelise.com/platformApi/state/create/v2/scheduleMe`;
429
429
  this.isSubmitting = true;
430
430
 
431
431
  try {