@nylas/web-elements 0.0.0-canary-20250318134614 → 0.0.0-test-20250319204140

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.
Files changed (34) hide show
  1. package/dist/cdn/input-color-picker/input-color-picker.es.js +699 -0
  2. package/dist/cdn/nylas-scheduler-editor/nylas-scheduler-editor.es.js +4 -4
  3. package/dist/cdn/nylas-scheduling/nylas-scheduling.es.js +3 -3
  4. package/dist/cjs/google-logo-icon_6.cjs.entry.js +4 -4
  5. package/dist/cjs/nylas-event-calendar_3.cjs.entry.js.map +1 -1
  6. package/dist/cjs/nylas-provider.cjs.entry.js +1 -1
  7. package/dist/cjs/nylas-scheduling.cjs.entry.js +3 -3
  8. package/dist/cjs/{scheduler-store-599282e9.js → scheduler-store-c1fc5cf3.js} +2 -2
  9. package/dist/cjs/{scheduler-store-599282e9.js.map → scheduler-store-c1fc5cf3.js.map} +1 -1
  10. package/dist/collection/components/scheduler-editor/nylas-event-calendar/nylas-event-calendar.js +2 -2
  11. package/dist/collection/components/scheduler-editor/nylas-event-calendar/nylas-event-calendar.js.map +1 -1
  12. package/dist/components/nylas-editor-tabs-group2.js +2 -2
  13. package/dist/components/nylas-editor-tabs2.js +2 -2
  14. package/dist/components/nylas-event-calendar2.js.map +1 -1
  15. package/dist/components/nylas-scheduling.js +2 -2
  16. package/dist/components/scheduler-store.js +1 -1
  17. package/dist/esm/google-logo-icon_6.entry.js +4 -4
  18. package/dist/esm/nylas-event-calendar_3.entry.js.map +1 -1
  19. package/dist/esm/nylas-provider.entry.js +1 -1
  20. package/dist/esm/nylas-scheduling.entry.js +3 -3
  21. package/dist/esm/{scheduler-store-59b3f29b.js → scheduler-store-bbb4cf8d.js} +2 -2
  22. package/dist/esm/{scheduler-store-59b3f29b.js.map → scheduler-store-bbb4cf8d.js.map} +1 -1
  23. package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
  24. package/dist/nylas-web-elements/{p-a6fbfec1.entry.js → p-14569ed8.entry.js} +2 -2
  25. package/dist/nylas-web-elements/p-4e20f21a.entry.js.map +1 -1
  26. package/dist/nylas-web-elements/{p-ef506ab3.entry.js → p-91bc630c.entry.js} +2 -2
  27. package/dist/nylas-web-elements/{p-790c6070.js → p-f0c25e38.js} +2 -2
  28. package/dist/nylas-web-elements/{p-8841358d.entry.js → p-f7ea608d.entry.js} +2 -2
  29. package/dist/types/components/scheduler-editor/nylas-event-calendar/nylas-event-calendar.d.ts +1 -2
  30. package/package.json +2 -2
  31. /package/dist/nylas-web-elements/{p-a6fbfec1.entry.js.map → p-14569ed8.entry.js.map} +0 -0
  32. /package/dist/nylas-web-elements/{p-ef506ab3.entry.js.map → p-91bc630c.entry.js.map} +0 -0
  33. /package/dist/nylas-web-elements/{p-790c6070.js.map → p-f0c25e38.js.map} +0 -0
  34. /package/dist/nylas-web-elements/{p-8841358d.entry.js.map → p-f7ea608d.entry.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{i as t,b as e,a as i}from"./p-77e4b56c.js";import{c as n}from"./p-fc5bc07b.js";var s;(function(t){t["Component"]="component";t["Api"]="api";t["Auth"]="auth"})(s||(s={}));var o;(function(t){t["endtime_not_in_future"]="endtime_not_in_future";t["no_booking_info"]="no_booking_info";t["no_timeslot_selected"]="no_timeslot_selected";t["no_timezone_selected"]="no_timezone_selected";t["no_booking_id"]="no_booking_id";t["no_salt"]="no_salt";t["invalid_start_time"]="invalid_start_time";t["invalid_end_time"]="invalid_end_time";t["invalid_timezone"]="invalid_timezone";t["no_config_id"]="no_config_id"})(o||(o={}));var r;(function(t){t["invalid_session"]="invalid_session";t["general_error"]="general_error";t["internal_error"]="internal_error";t["invalid_request_error"]="invalid_request_error";t["timeslot_not_available"]="timeslot_not_available";t["provider_error"]="provider_error";t["not_found_error"]="not_found_error"})(r||(r={}));class a{constructor(){this.component=t=>{const e=s.Component;const i=`${t} Error`;return{endtime_not_in_future:(t='"endtime" can not be in the future')=>({title:i,message:t,category:e}),no_booking_info:(t="No booking info provided")=>({title:i,message:t,category:e}),no_timeslot_selected:(t="No timeslot selected")=>({title:i,message:t,category:e}),no_timezone_selected:(t="No timezone selected")=>({title:i,message:t,category:e}),no_booking_id:(t="No booking id provided")=>({title:i,message:t,category:e}),no_salt:(t="No salt provided")=>({title:i,message:t,category:e}),invalid_start_time:(t="Invalid start time")=>({title:i,message:t,category:e}),invalid_end_time:(t="Invalid end time")=>({title:i,message:t,category:e}),invalid_timezone:(t="Invalid timezone")=>({title:i,message:t,category:e}),no_config_id:(t="No configuration id provided")=>({title:i,message:t,category:e})}};this.api=t=>{const e=s.Api;const i=`${t} Error`;return{invalid_session:t=>({title:i,message:t,category:e}),general_error:t=>({title:i,message:t,category:e}),internal_error:t=>({title:i,message:t,category:e}),invalid_request_error:t=>({title:i,message:t,category:e}),timeslot_not_available:t=>({title:i,message:t,category:e}),provider_error:t=>({title:i,message:t,category:e}),not_found_error:t=>({title:i,message:t,category:e})}}}}class l{constructor({schedulerAPIURL:t,schedulerStore:e,sessionId:i,configId:n,slug:s,clientId:o}){this.errors=new a;this.schedulerStore=e;this.schedulerAPIURL=t;this.sessionId=i;this.configId=n;this.slug=s;this.clientId=o}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(t,e,i,n={}){try{const s=new URL(this.schedulerAPIURL);const o="1.3.6";s.pathname=t;const r=await fetch(decodeURIComponent(s.toString()),{method:e,headers:{"Content-Type":"application/json",Origin:window.location.origin,"X-Source":"nylas-scheduling","X-Nylas-Web-Elements-Version":o,...n},body:i});const a=await r.json();return a}catch(t){return{error:{message:t.message,title:"API request failed",type:"api"}}}}getErrorMessage(t){let e=t?.message||t?.title||"Something went wrong";if(t?.type==="provider_error"){e=t?.provider_error?.error?.message||t?.provider_error?.error?.title||"Something went wrong"}return e}setConfigId(t){this.configId=t}selectDate(t){this.schedulerStore.set("selectedDate",t);this.schedulerStore.set("selectedTimeslot",null)}selectTime(t){this.schedulerStore.set("selectedTimeslot",t)}selectTimezone(t){this.schedulerStore.set("selectedTimezone",t)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e);t.changeLanguage(e)}async toggleAdditionalData(t){if(!t){await this.refetchAvailability()}this.schedulerStore.set("showBookingForm",t)}setParticipantName(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e?.primaryParticipant,name:t}})}setParticipantEmail(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e?.primaryParticipant,email:t}})}async refetchAvailability(){const t=new Date;const e=new Date(t.getFullYear(),t.getMonth(),1).getTime()/1e3;const i=e<t.getTime()/1e3?Math.floor(t.getTime()/1e3):e;const n=new Date(t.getFullYear(),t.getMonth()+1,1).getTime()/1e3;const s=await this.getAvailability(i,n);return s}async resetStoreStateAndFetchAvailability(){const t=new Date;const e=await this.refetchAvailability();const i=this.schedulerStore.get("availability").find((t=>new Date(t.start_time)>new Date));let n=t;if(i){n=i.start_time}this.schedulerStore.set("selectedDate",n);this.schedulerStore.set("eventInfo",null);this.schedulerStore.set("showBookingForm",false);this.schedulerStore.set("selectedTimeslot",null);return e}async setReschedule(t){this.schedulerStore.set("isLoading",true);const e=this.schedulerStore.state.eventInfo;if(e){this.schedulerStore.set("reschedulingEventInfo",e)}this.schedulerStore.set("rescheduleBookingId",t);await this.getUISettings();const i=await this.resetStoreStateAndFetchAvailability().finally((()=>{this.schedulerStore.set("isLoading",false)}));return i}async setCancel(t){this.schedulerStore.set("cancelBookingId",t)}async setReject(t){this.schedulerStore.set("rejectBookingId",t)}async resetCancel(){const t=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("cancelBookingId","");this.schedulerStore.set("rejectBookingId","");this.schedulerStore.set("cancelledEventInfo",null);return t}async goBack(){this.schedulerStore.set("cancelBookingId","");return}async resetConfirm(){const t=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("confirmedEventInfo",undefined);return t}async bookTimeslot(e){this.schedulerStore.set("isLoading",true);const{selectedTimeslot:i,selectedTimezone:n,bookingInfo:s,selectedLanguage:o}=this.schedulerStore.state;if(!e&&!s){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_booking_info()}}const r=e?.timeslot||i;if(!r){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_timeslot_selected()}}const a=e&&e?.timezone?e?.timezone:n;const l=o||"en-US";if(!a){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_timezone_selected()}}const c=[...this.schedulerStore.get("availabilityOrderEmails")];let d="";const h=r?.emails||[];const g={};Object.entries(s?.additionalFields||{}).forEach((([t,e])=>{g[t]=e.value}));const u=e?e?.primaryParticipant:s?.primaryParticipant;const f=e?e?.guests||[]:s?.guests||[];const m=e?e?.additionalFields:g;const _=this.getHeaders();const v=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const y=`/v3/scheduling/bookings${v}`;if(c.length===0){const t=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({additional_fields:m,additional_guests:f,guest:{...u},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:a,event_id:r?.event_id||undefined,master_id:r?.master_id||undefined,calendar_id:r?.calendar_id||undefined,email_language:this.getTwoLetterLanguageCode(l)}),_);this.schedulerStore.set("isLoading",false);if("data"in t){this.schedulerStore.set("eventInfo",t.data);return t}return{error:t.error}}while(c.length>0){d=c.shift();if(!h.includes(d)){continue}const e=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({participants:d?[{email:d}]:undefined,additional_fields:m,additional_guests:f,guest:{...u},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:a,email_language:this.getTwoLetterLanguageCode(l)}),_);if("data"in e){this.schedulerStore.set("isLoading",false);this.schedulerStore.set("eventInfo",e?.data);return e}else if(e.error?.message?.startsWith("The selected timeslot is unavailable")){continue}else{this.schedulerStore.set("isLoading",false);const i=e.error?.type;let n=e.error;if(i&&i in this.errors.api(t.t("createBookingErrorTitle"))){const e=this.getErrorMessage(n);n=this.errors.api(t.t("createBookingErrorTitle"))[i](e)}return{error:n}}}this.schedulerStore.set("isLoading",false);return{error:this.errors.api(t.t("createBookingErrorTitle")).timeslot_not_available("The selected timeslot is unavailable")}}async getUISettings(){this.schedulerStore.set("isLoading",true);const e=this.schedulerStore.get("rescheduleBookingId");const i=this.getHeaders();let n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";if(e&&!!n){n+=`&booking_id=${e}`}else if(e){n+=`?booking_id=${e}`}const s=`/v3/scheduling/ui-settings${n}`;const o=await this.makeAPIRequest(s,"GET",undefined,i);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let i=o.error;if(e&&e in this.errors.api(t.t("getUISettingErrorTitle"))){i=this.errors.api(t.t("getUISettingErrorTitle"))[e](i?.message||i?.title||"Something went wrong")}return{error:i}}if("data"in o){this.schedulerStore.set("configSettings",o.data)}this.schedulerStore.set("isLoading",false);return o}getTwoLetterLanguageCode(t){return t.split("-")[0]}getStartTimeWithMinBookingNotice(t){const e=this.schedulerStore.get("configSettings")?.scheduler;const i=e?.min_booking_notice;if(!i){return t}const n=(new Date).getTime();if(t<(n+i*60*1e3)/1e3){return Math.floor((n+i*60*1e3)/1e3)}else{return t}}getEndTimeForAvailableDaysInFuture(t){const i=new Date;const n=this.schedulerStore.get("configSettings")?.scheduler?.available_days_in_future;const s=Math.floor(e(i,n).getTime()/1e3);const o=Math.min(s,t);return o}async getAvailability(e=0,i=0){this.schedulerStore.set("isLoading",true);const n=new URLSearchParams;const s=new Date;const o=s.getTime();if(i&&i<o/1e3){this.schedulerStore.set("isLoading",false);const e=this.errors.component(t.t("getAvailabilityErrorTitle")).endtime_not_in_future();return{error:e}}if(!e){const t=new Date(s.getFullYear(),s.getMonth(),1);e=Math.floor(t.getTime()/1e3)}if(!i){const t=new Date(s.getFullYear(),s.getMonth()+1,0);i=Math.floor(t.getTime()/1e3)}i=this.getEndTimeForAvailableDaysInFuture(i);const r=this.getStartTimeWithMinBookingNotice(e);e=r;i=r>i?r+1:i;n.append("start_time",encodeURIComponent(e.toString()));n.append("end_time",encodeURIComponent(i.toString()));if(this.configId&&!this.sessionId){n.append("configuration_id",encodeURIComponent(this.configId))}else if(this.slug&&this.clientId&&!this.sessionId){n.append("slug",encodeURIComponent(this.slug));n.append("client_id",encodeURIComponent(this.clientId))}const a=this.schedulerStore.get("rescheduleBookingId");if(a){n.append("booking_id",encodeURIComponent(a))}const l=n.toString();const c=`/v3/scheduling/availability${l?`?${l}`:""}`;const d=this.getHeaders();const h=await this.makeAPIRequest(decodeURIComponent(c),"GET",undefined,d);if("error"in h){this.schedulerStore.set("availability",[]);this.schedulerStore.set("isLoading",false);const e=h.error?.type;let i=h.error;if(e&&e in this.errors.api(t.t("getAvailabilityErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("getAvailabilityErrorTitle"))[e](n)}return{error:i}}if("data"in h){const t=h.data?.time_slots?.map((t=>({...t,start_time:new Date(t.start_time*1e3),end_time:new Date(t.end_time*1e3)})))||[];const e=t.filter((t=>t.start_time.getTime()>o));const i=e.sort(((t,e)=>t.start_time.getTime()-e.start_time.getTime()));this.schedulerStore.set("availability",i);const n=h.data?.order||[];this.schedulerStore.set("availabilityOrderEmails",n)}this.schedulerStore.set("isLoading",false);return h}async cancelBooking(e,i){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(t.t("cancelBookingErrorTitle")).no_booking_id()}}const n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const s=`/v3/scheduling/bookings/${e}${n}`;const o=this.getHeaders();const r=await this.makeAPIRequest(decodeURIComponent(s),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:i}),o);if("error"in r){this.schedulerStore.set("isLoading",false);const e=r.error?.type;let i=r.error;if(e&&e in this.errors.api(t.t("cancelBookingErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("cancelBookingErrorTitle"))[e](n)}return{error:i}}this.schedulerStore.set("cancelledEventInfo",{booking_id:e});this.schedulerStore.set("rescheduleBookingId","");this.schedulerStore.set("isLoading",false);return r}async rescheduleBooking(e,i){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(t.t("rescheduleBookingErrorTitle")).no_booking_id()}}const n=this.errors.api(t.t("rescheduleBookingErrorTitle"));const s=this.errors.component(t.t("rescheduleBookingErrorTitle"));const{bookingInfo:o,selectedTimeslot:r,selectedTimezone:a,selectedLanguage:l}=this.schedulerStore.state;const{startTime:c,endTime:d,timezone:h}=i;const g=c||r?.start_time;if(!g){return{error:s.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const u=d||r?.end_time;if(!u){return{error:s.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const f=this.schedulerStore.get("availabilityOrderEmails");let m="";if(f.length>0){const t=r?.emails||[];for(let e=0;e<f.length;e++){if(t.includes(f[e])){m=f[e];break}}}const _=h||a;if(!_){return{error:s.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')}}const v={};Object.entries(o?.additionalFields||{}).forEach((([t,e])=>{v[t]=e.value}));const y=i?i?.primaryParticipant:o?.primaryParticipant;const I=i?i?.guests||[]:o?.guests||[];const T=i?i?.additionalFields:v;const k=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const b=`/v3/scheduling/bookings/${e}${k}`;const p=this.getHeaders();const w=await this.makeAPIRequest(decodeURIComponent(b),"PATCH",JSON.stringify({start_time:g.getTime()/1e3,end_time:u.getTime()/1e3,timezone:_,additional_fields:T,guest:{...y},additional_guests:I,participants:m?[{email:m}]:undefined,email_language:this.getTwoLetterLanguageCode(l)}),p);if("error"in w){this.schedulerStore.set("isLoading",false);const t=w.error?.type;let e=w.error;if(t&&t in n){const i=this.getErrorMessage(e);e=n[t](i)}return{error:e}}const E=this.schedulerStore.get("reschedulingEventInfo");if("data"in w){this.schedulerStore.set("eventInfo",w?.data)}else if(E){this.schedulerStore.set("eventInfo",E)}else{const t={booking_id:e};this.schedulerStore.set("eventInfo",t)}this.schedulerStore.set("isLoading",false);return w}async updateBooking(e){this.schedulerStore.set("isLoading",true);const{bookingId:i,status:n,reason:s}=e;const o=this.schedulerStore.get("organizerConfirmationSalt");const r=n==="confirmed"?t.t("confirmBookingErrorTitle"):t.t("rejectBookingErrorTitle");if(!i){return{error:this.errors.component(r).no_booking_id()}}if(!o){return{error:this.errors.component(r).no_salt()}}const a=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const l=`/v3/scheduling/bookings/${i}${a}`;const c=this.getHeaders();const d=await this.makeAPIRequest(decodeURIComponent(l),"PUT",JSON.stringify({status:n,cancellation_reason:s,salt:o}),c);if("error"in d){this.schedulerStore.set("isLoading",false);const t=d.error?.type;let e=d.error;if(t&&t in this.errors.api(r)){const i=this.getErrorMessage(e);e=this.errors.api(r)[t](i)}return{error:e}}if("data"in d&&n==="confirmed"){this.schedulerStore.set("confirmedEventInfo",d?.data)}else if("request_id"in d&&n==="cancelled"){this.schedulerStore.set("cancelledEventInfo",{booking_id:i})}this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("isLoading",false);return d}async validateGroupEventTimeslot(e){this.schedulerStore.set("isLoading",true);const i=this.schedulerStore.get("configSettings")?.configuration_id;if(!i){return{error:this.errors.component(t.t("validateTimeslotErrorTitle")).no_config_id()}}const n=this.getHeaders();const s=`/v3/scheduling/configurations/${i}/group-events/validate-timeslot`;const o=await this.makeAPIRequest(decodeURIComponent(s),"POST",JSON.stringify({...e,start_time:e.start_time.getTime()/1e3,end_time:e.end_time.getTime()/1e3}),n);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let i=o.error;if(e&&e in this.errors.api(t.t("validateTimeslotErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("validateTimeslotErrorTitle"))[e](n)}this.refetchAvailability();return{error:i}}this.schedulerStore.set("selectedTimeslot",e);this.schedulerStore.set("showBookingForm",true);this.schedulerStore.set("isLoading",false);return o}}function c(t={}){const e={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:false,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:false,nylasBranding:true,...t};i(`[defaultNylasStoreState]: `,e);const s=n(e);s.onChange("availability",(t=>{i(`[availability]: `,t);const e=t.map((t=>t.start_time));i(`[selectableDates]: `,e);s.set("selectableDates",e);const n=t[0];if(!n)return;const o=Math.floor((n.end_time.getTime()-n.start_time.getTime())/6e4);i(`[durationMinutes]: `,o);s.set("eventDuration",o)}));s.reset=()=>{for(const t in e){const i=e[t];s.set(t,i)}};return s}export{c as C,s as E,l as N};
2
- //# sourceMappingURL=p-790c6070.js.map
1
+ import{i as t,b as e,a as i}from"./p-77e4b56c.js";import{c as n}from"./p-fc5bc07b.js";var s;(function(t){t["Component"]="component";t["Api"]="api";t["Auth"]="auth"})(s||(s={}));var o;(function(t){t["endtime_not_in_future"]="endtime_not_in_future";t["no_booking_info"]="no_booking_info";t["no_timeslot_selected"]="no_timeslot_selected";t["no_timezone_selected"]="no_timezone_selected";t["no_booking_id"]="no_booking_id";t["no_salt"]="no_salt";t["invalid_start_time"]="invalid_start_time";t["invalid_end_time"]="invalid_end_time";t["invalid_timezone"]="invalid_timezone";t["no_config_id"]="no_config_id"})(o||(o={}));var r;(function(t){t["invalid_session"]="invalid_session";t["general_error"]="general_error";t["internal_error"]="internal_error";t["invalid_request_error"]="invalid_request_error";t["timeslot_not_available"]="timeslot_not_available";t["provider_error"]="provider_error";t["not_found_error"]="not_found_error"})(r||(r={}));class a{constructor(){this.component=t=>{const e=s.Component;const i=`${t} Error`;return{endtime_not_in_future:(t='"endtime" can not be in the future')=>({title:i,message:t,category:e}),no_booking_info:(t="No booking info provided")=>({title:i,message:t,category:e}),no_timeslot_selected:(t="No timeslot selected")=>({title:i,message:t,category:e}),no_timezone_selected:(t="No timezone selected")=>({title:i,message:t,category:e}),no_booking_id:(t="No booking id provided")=>({title:i,message:t,category:e}),no_salt:(t="No salt provided")=>({title:i,message:t,category:e}),invalid_start_time:(t="Invalid start time")=>({title:i,message:t,category:e}),invalid_end_time:(t="Invalid end time")=>({title:i,message:t,category:e}),invalid_timezone:(t="Invalid timezone")=>({title:i,message:t,category:e}),no_config_id:(t="No configuration id provided")=>({title:i,message:t,category:e})}};this.api=t=>{const e=s.Api;const i=`${t} Error`;return{invalid_session:t=>({title:i,message:t,category:e}),general_error:t=>({title:i,message:t,category:e}),internal_error:t=>({title:i,message:t,category:e}),invalid_request_error:t=>({title:i,message:t,category:e}),timeslot_not_available:t=>({title:i,message:t,category:e}),provider_error:t=>({title:i,message:t,category:e}),not_found_error:t=>({title:i,message:t,category:e})}}}}class l{constructor({schedulerAPIURL:t,schedulerStore:e,sessionId:i,configId:n,slug:s,clientId:o}){this.errors=new a;this.schedulerStore=e;this.schedulerAPIURL=t;this.sessionId=i;this.configId=n;this.slug=s;this.clientId=o}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(t,e,i,n={}){try{const s=new URL(this.schedulerAPIURL);const o="1.4.0";s.pathname=t;const r=await fetch(decodeURIComponent(s.toString()),{method:e,headers:{"Content-Type":"application/json",Origin:window.location.origin,"X-Source":"nylas-scheduling","X-Nylas-Web-Elements-Version":o,...n},body:i});const a=await r.json();return a}catch(t){return{error:{message:t.message,title:"API request failed",type:"api"}}}}getErrorMessage(t){let e=t?.message||t?.title||"Something went wrong";if(t?.type==="provider_error"){e=t?.provider_error?.error?.message||t?.provider_error?.error?.title||"Something went wrong"}return e}setConfigId(t){this.configId=t}selectDate(t){this.schedulerStore.set("selectedDate",t);this.schedulerStore.set("selectedTimeslot",null)}selectTime(t){this.schedulerStore.set("selectedTimeslot",t)}selectTimezone(t){this.schedulerStore.set("selectedTimezone",t)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e);t.changeLanguage(e)}async toggleAdditionalData(t){if(!t){await this.refetchAvailability()}this.schedulerStore.set("showBookingForm",t)}setParticipantName(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e?.primaryParticipant,name:t}})}setParticipantEmail(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e?.primaryParticipant,email:t}})}async refetchAvailability(){const t=new Date;const e=new Date(t.getFullYear(),t.getMonth(),1).getTime()/1e3;const i=e<t.getTime()/1e3?Math.floor(t.getTime()/1e3):e;const n=new Date(t.getFullYear(),t.getMonth()+1,1).getTime()/1e3;const s=await this.getAvailability(i,n);return s}async resetStoreStateAndFetchAvailability(){const t=new Date;const e=await this.refetchAvailability();const i=this.schedulerStore.get("availability").find((t=>new Date(t.start_time)>new Date));let n=t;if(i){n=i.start_time}this.schedulerStore.set("selectedDate",n);this.schedulerStore.set("eventInfo",null);this.schedulerStore.set("showBookingForm",false);this.schedulerStore.set("selectedTimeslot",null);return e}async setReschedule(t){this.schedulerStore.set("isLoading",true);const e=this.schedulerStore.state.eventInfo;if(e){this.schedulerStore.set("reschedulingEventInfo",e)}this.schedulerStore.set("rescheduleBookingId",t);await this.getUISettings();const i=await this.resetStoreStateAndFetchAvailability().finally((()=>{this.schedulerStore.set("isLoading",false)}));return i}async setCancel(t){this.schedulerStore.set("cancelBookingId",t)}async setReject(t){this.schedulerStore.set("rejectBookingId",t)}async resetCancel(){const t=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("cancelBookingId","");this.schedulerStore.set("rejectBookingId","");this.schedulerStore.set("cancelledEventInfo",null);return t}async goBack(){this.schedulerStore.set("cancelBookingId","");return}async resetConfirm(){const t=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("confirmedEventInfo",undefined);return t}async bookTimeslot(e){this.schedulerStore.set("isLoading",true);const{selectedTimeslot:i,selectedTimezone:n,bookingInfo:s,selectedLanguage:o}=this.schedulerStore.state;if(!e&&!s){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_booking_info()}}const r=e?.timeslot||i;if(!r){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_timeslot_selected()}}const a=e&&e?.timezone?e?.timezone:n;const l=o||"en-US";if(!a){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_timezone_selected()}}const c=[...this.schedulerStore.get("availabilityOrderEmails")];let d="";const h=r?.emails||[];const g={};Object.entries(s?.additionalFields||{}).forEach((([t,e])=>{g[t]=e.value}));const u=e?e?.primaryParticipant:s?.primaryParticipant;const f=e?e?.guests||[]:s?.guests||[];const m=e?e?.additionalFields:g;const _=this.getHeaders();const v=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const y=`/v3/scheduling/bookings${v}`;if(c.length===0){const t=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({additional_fields:m,additional_guests:f,guest:{...u},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:a,event_id:r?.event_id||undefined,master_id:r?.master_id||undefined,calendar_id:r?.calendar_id||undefined,email_language:this.getTwoLetterLanguageCode(l)}),_);this.schedulerStore.set("isLoading",false);if("data"in t){this.schedulerStore.set("eventInfo",t.data);return t}return{error:t.error}}while(c.length>0){d=c.shift();if(!h.includes(d)){continue}const e=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({participants:d?[{email:d}]:undefined,additional_fields:m,additional_guests:f,guest:{...u},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:a,email_language:this.getTwoLetterLanguageCode(l)}),_);if("data"in e){this.schedulerStore.set("isLoading",false);this.schedulerStore.set("eventInfo",e?.data);return e}else if(e.error?.message?.startsWith("The selected timeslot is unavailable")){continue}else{this.schedulerStore.set("isLoading",false);const i=e.error?.type;let n=e.error;if(i&&i in this.errors.api(t.t("createBookingErrorTitle"))){const e=this.getErrorMessage(n);n=this.errors.api(t.t("createBookingErrorTitle"))[i](e)}return{error:n}}}this.schedulerStore.set("isLoading",false);return{error:this.errors.api(t.t("createBookingErrorTitle")).timeslot_not_available("The selected timeslot is unavailable")}}async getUISettings(){this.schedulerStore.set("isLoading",true);const e=this.schedulerStore.get("rescheduleBookingId");const i=this.getHeaders();let n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";if(e&&!!n){n+=`&booking_id=${e}`}else if(e){n+=`?booking_id=${e}`}const s=`/v3/scheduling/ui-settings${n}`;const o=await this.makeAPIRequest(s,"GET",undefined,i);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let i=o.error;if(e&&e in this.errors.api(t.t("getUISettingErrorTitle"))){i=this.errors.api(t.t("getUISettingErrorTitle"))[e](i?.message||i?.title||"Something went wrong")}return{error:i}}if("data"in o){this.schedulerStore.set("configSettings",o.data)}this.schedulerStore.set("isLoading",false);return o}getTwoLetterLanguageCode(t){return t.split("-")[0]}getStartTimeWithMinBookingNotice(t){const e=this.schedulerStore.get("configSettings")?.scheduler;const i=e?.min_booking_notice;if(!i){return t}const n=(new Date).getTime();if(t<(n+i*60*1e3)/1e3){return Math.floor((n+i*60*1e3)/1e3)}else{return t}}getEndTimeForAvailableDaysInFuture(t){const i=new Date;const n=this.schedulerStore.get("configSettings")?.scheduler?.available_days_in_future;const s=Math.floor(e(i,n).getTime()/1e3);const o=Math.min(s,t);return o}async getAvailability(e=0,i=0){this.schedulerStore.set("isLoading",true);const n=new URLSearchParams;const s=new Date;const o=s.getTime();if(i&&i<o/1e3){this.schedulerStore.set("isLoading",false);const e=this.errors.component(t.t("getAvailabilityErrorTitle")).endtime_not_in_future();return{error:e}}if(!e){const t=new Date(s.getFullYear(),s.getMonth(),1);e=Math.floor(t.getTime()/1e3)}if(!i){const t=new Date(s.getFullYear(),s.getMonth()+1,0);i=Math.floor(t.getTime()/1e3)}i=this.getEndTimeForAvailableDaysInFuture(i);const r=this.getStartTimeWithMinBookingNotice(e);e=r;i=r>i?r+1:i;n.append("start_time",encodeURIComponent(e.toString()));n.append("end_time",encodeURIComponent(i.toString()));if(this.configId&&!this.sessionId){n.append("configuration_id",encodeURIComponent(this.configId))}else if(this.slug&&this.clientId&&!this.sessionId){n.append("slug",encodeURIComponent(this.slug));n.append("client_id",encodeURIComponent(this.clientId))}const a=this.schedulerStore.get("rescheduleBookingId");if(a){n.append("booking_id",encodeURIComponent(a))}const l=n.toString();const c=`/v3/scheduling/availability${l?`?${l}`:""}`;const d=this.getHeaders();const h=await this.makeAPIRequest(decodeURIComponent(c),"GET",undefined,d);if("error"in h){this.schedulerStore.set("availability",[]);this.schedulerStore.set("isLoading",false);const e=h.error?.type;let i=h.error;if(e&&e in this.errors.api(t.t("getAvailabilityErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("getAvailabilityErrorTitle"))[e](n)}return{error:i}}if("data"in h){const t=h.data?.time_slots?.map((t=>({...t,start_time:new Date(t.start_time*1e3),end_time:new Date(t.end_time*1e3)})))||[];const e=t.filter((t=>t.start_time.getTime()>o));const i=e.sort(((t,e)=>t.start_time.getTime()-e.start_time.getTime()));this.schedulerStore.set("availability",i);const n=h.data?.order||[];this.schedulerStore.set("availabilityOrderEmails",n)}this.schedulerStore.set("isLoading",false);return h}async cancelBooking(e,i){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(t.t("cancelBookingErrorTitle")).no_booking_id()}}const n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const s=`/v3/scheduling/bookings/${e}${n}`;const o=this.getHeaders();const r=await this.makeAPIRequest(decodeURIComponent(s),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:i}),o);if("error"in r){this.schedulerStore.set("isLoading",false);const e=r.error?.type;let i=r.error;if(e&&e in this.errors.api(t.t("cancelBookingErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("cancelBookingErrorTitle"))[e](n)}return{error:i}}this.schedulerStore.set("cancelledEventInfo",{booking_id:e});this.schedulerStore.set("rescheduleBookingId","");this.schedulerStore.set("isLoading",false);return r}async rescheduleBooking(e,i){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(t.t("rescheduleBookingErrorTitle")).no_booking_id()}}const n=this.errors.api(t.t("rescheduleBookingErrorTitle"));const s=this.errors.component(t.t("rescheduleBookingErrorTitle"));const{bookingInfo:o,selectedTimeslot:r,selectedTimezone:a,selectedLanguage:l}=this.schedulerStore.state;const{startTime:c,endTime:d,timezone:h}=i;const g=c||r?.start_time;if(!g){return{error:s.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const u=d||r?.end_time;if(!u){return{error:s.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const f=this.schedulerStore.get("availabilityOrderEmails");let m="";if(f.length>0){const t=r?.emails||[];for(let e=0;e<f.length;e++){if(t.includes(f[e])){m=f[e];break}}}const _=h||a;if(!_){return{error:s.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')}}const v={};Object.entries(o?.additionalFields||{}).forEach((([t,e])=>{v[t]=e.value}));const y=i?i?.primaryParticipant:o?.primaryParticipant;const I=i?i?.guests||[]:o?.guests||[];const T=i?i?.additionalFields:v;const k=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const b=`/v3/scheduling/bookings/${e}${k}`;const p=this.getHeaders();const w=await this.makeAPIRequest(decodeURIComponent(b),"PATCH",JSON.stringify({start_time:g.getTime()/1e3,end_time:u.getTime()/1e3,timezone:_,additional_fields:T,guest:{...y},additional_guests:I,participants:m?[{email:m}]:undefined,email_language:this.getTwoLetterLanguageCode(l)}),p);if("error"in w){this.schedulerStore.set("isLoading",false);const t=w.error?.type;let e=w.error;if(t&&t in n){const i=this.getErrorMessage(e);e=n[t](i)}return{error:e}}const E=this.schedulerStore.get("reschedulingEventInfo");if("data"in w){this.schedulerStore.set("eventInfo",w?.data)}else if(E){this.schedulerStore.set("eventInfo",E)}else{const t={booking_id:e};this.schedulerStore.set("eventInfo",t)}this.schedulerStore.set("isLoading",false);return w}async updateBooking(e){this.schedulerStore.set("isLoading",true);const{bookingId:i,status:n,reason:s}=e;const o=this.schedulerStore.get("organizerConfirmationSalt");const r=n==="confirmed"?t.t("confirmBookingErrorTitle"):t.t("rejectBookingErrorTitle");if(!i){return{error:this.errors.component(r).no_booking_id()}}if(!o){return{error:this.errors.component(r).no_salt()}}const a=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const l=`/v3/scheduling/bookings/${i}${a}`;const c=this.getHeaders();const d=await this.makeAPIRequest(decodeURIComponent(l),"PUT",JSON.stringify({status:n,cancellation_reason:s,salt:o}),c);if("error"in d){this.schedulerStore.set("isLoading",false);const t=d.error?.type;let e=d.error;if(t&&t in this.errors.api(r)){const i=this.getErrorMessage(e);e=this.errors.api(r)[t](i)}return{error:e}}if("data"in d&&n==="confirmed"){this.schedulerStore.set("confirmedEventInfo",d?.data)}else if("request_id"in d&&n==="cancelled"){this.schedulerStore.set("cancelledEventInfo",{booking_id:i})}this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("isLoading",false);return d}async validateGroupEventTimeslot(e){this.schedulerStore.set("isLoading",true);const i=this.schedulerStore.get("configSettings")?.configuration_id;if(!i){return{error:this.errors.component(t.t("validateTimeslotErrorTitle")).no_config_id()}}const n=this.getHeaders();const s=`/v3/scheduling/configurations/${i}/group-events/validate-timeslot`;const o=await this.makeAPIRequest(decodeURIComponent(s),"POST",JSON.stringify({...e,start_time:e.start_time.getTime()/1e3,end_time:e.end_time.getTime()/1e3}),n);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let i=o.error;if(e&&e in this.errors.api(t.t("validateTimeslotErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("validateTimeslotErrorTitle"))[e](n)}this.refetchAvailability();return{error:i}}this.schedulerStore.set("selectedTimeslot",e);this.schedulerStore.set("showBookingForm",true);this.schedulerStore.set("isLoading",false);return o}}function c(t={}){const e={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:false,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:false,nylasBranding:true,...t};i(`[defaultNylasStoreState]: `,e);const s=n(e);s.onChange("availability",(t=>{i(`[availability]: `,t);const e=t.map((t=>t.start_time));i(`[selectableDates]: `,e);s.set("selectableDates",e);const n=t[0];if(!n)return;const o=Math.floor((n.end_time.getTime()-n.start_time.getTime())/6e4);i(`[durationMinutes]: `,o);s.set("eventDuration",o)}));s.reset=()=>{for(const t in e){const i=e[t];s.set(t,i)}};return s}export{c as C,s as E,l as N};
2
+ //# sourceMappingURL=p-f0c25e38.js.map
@@ -1,2 +1,2 @@
1
- import{h as e,F as t,r as n,c as i,H as s,a}from"./p-6f5a3998.js";import{n as o,N as r}from"./p-c372bced.js";import{a as l,i as c,h as d,b as h,j as f}from"./p-77e4b56c.js";import{N as p,E as g,C as u}from"./p-790c6070.js";import{L as b,b as y}from"./p-6c2ba972.js";import{i as m,a as _,c as k,b as w,f as v}from"./p-64bc2c6f.js";import"./p-c79dcb59.js";import"./p-fc5bc07b.js";class x{constructor({schedulerAPIURL:e,nylasSchedulerStore:t,sessionId:n,configId:i,slug:s,clientId:a}){if(!e){throw new Error("schedulerAPIURL is required")}if(!t){throw new Error("nylasSchedulerStore is required")}if(!n&&!i&&!(s||a)){throw new Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.")}if(e==="/"){const t=new URL(window.location.href);e=t.origin}this.configId=i;this.sessionId=n;this.schedulerAPIURL=e;this.nylasSchedulerStore=t;this.slug=s;this.clientId=a}init(){l("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}get scheduler(){if(this._schedulerAPIConnector){return this._schedulerAPIConnector}this._schedulerAPIConnector=new p({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId,slug:this.slug,clientId:this.clientId});return this._schedulerAPIConnector}resetStores(){this.nylasSchedulerStore.reset()}}const I=(n,i)=>{const s=n.isLoading;const a=n.showNotification;const o=n.nylasBranding;return e(t,null,a&&e("nylas-notification",null),s&&e("div",{class:"loading"},e("div",{class:"left"},e("div",{class:"skeleton"})),e("div",{class:"right"},e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}))),!s&&i,e("div",{class:"footer"},o&&e("a",{href:"https://scheduler.nylas.com?utm_source=powered-by-nylas-logoutm_medium=link&utm_campaign=get-scheduler&utm_id=get-scheduler",class:"powered-by-nylas",target:"_blank",rel:"noreferrer noopener"},"Powered by ",e("span",{class:"sr-only"},"Nylas"),e("nylas-logo",{"aria-hidden":true}))))};const C=(t,n)=>e("div",{class:"message-banner"},n);const B=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 8px 2px rgba(0, 0, 0, 0.05), 0px 8px 16px -2px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;font-family:var(--nylas-font-family);font-optical-sizing:auto;font-style:normal;font-variation-settings:"slnt" 0}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}:root{font-family:inherit}.error{padding:8rem 12rem;color:var(--nylas-base-0);background-color:var(--nylas-error);margin:1.5rem;border-radius:var(--nylas-border-radius-2x)}.message-banner{text-align:right;color:var(--nylas-base-800);padding:1rem;border-bottom:1px solid var(--nylas-color-primary-200);margin:0}.loading{margin:1.5rem;display:flex;gap:1rem}.loading .skeleton{border-radius:var(--nylas-border-radius-2x);animation:pulsate 1.5s infinite}.loading .skeleton:nth-child(2){animation-delay:-100ms}.loading .skeleton:nth-child(3){animation-delay:-200ms}.loading .skeleton:nth-child(4){animation-delay:-300ms}.loading .skeleton:nth-child(5){animation-delay:-400ms}.loading .left .skeleton{height:100%;width:400px}.loading .right .skeleton{height:5rem;width:300px;margin-bottom:1rem}.loading .right .skeleton:last-child{margin-bottom:0}@keyframes pulsate{0%{background-color:var(--nylas-base-50)}50%{background-color:var(--nylas-base-100)}100%{background-color:var(--nylas-base-50)}}.select-date-page,.additional-data-page,.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{border-top-left-radius:var(--nylas-border-radius-2x);border-top-right-radius:var(--nylas-border-radius-2x)}.select-date-page,.additional-data-page{display:flex}@media screen and (max-width: 768px){.select-date-page,.additional-data-page{flex-direction:column}}.booked-event-page,.manual-confirmation-page{background-color:var(--nylas-base-50)}.cancelled-event-page,.manual-confirmation-page,.cancel-flow-page{padding:1rem;height:496px;display:flex;justify-content:center;align-items:center}.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:784px;background:var(--nylas-base-50)}@media screen and (max-width: 768px){.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:90%}}.left-panel{display:flex;flex-direction:column;min-width:424px;border-top-left-radius:inherit;background:var(--nylas-base-0);position:relative;padding:1rem 0 0 0;height:624px}@media screen and (max-width: 768px){.left-panel{border-top-right-radius:inherit;min-width:unset;height:auto}}@media screen and (max-width: 768px){.select-date-page .left-panel{height:624px}}.border{margin-left:-20px;margin-right:-20px;border-top-width:1px;height:0.5px;background-color:var(--nylas-base-200)}@media screen and (max-width: 768px){.border{display:none}}.right-panel{min-width:360px;width:360px;background-color:var(--nylas-base-50);height:624px;padding-top:16px;border-left:1px solid var(--nylas-base-200);border-top-right-radius:inherit}.right-panel.reschedule{border-top-right-radius:0px}@media screen and (max-width: 768px){.right-panel{border-top-right-radius:0px;width:inherit;min-width:unset;height:auto;border-left:none}}.right-panel h2{display:flex;margin:0;height:48px;gap:0.5rem;justify-content:center;align-items:center;width:auto;font-size:1.125rem;line-height:1.5rem;font-weight:500;text-align:center;color:var(--nylas-base-800)}.additional-data-page .left-panel{background-color:var(--nylas-base-50)}.additional-data-page .right-panel{background-color:var(--nylas-base-0)}nylas-selected-event-card{height:604px;padding:0 1rem}@media screen and (max-width: 768px){nylas-selected-event-card{height:250px}}.footer{display:flex;justify-content:flex-end;align-items:center;padding:16px;font-size:14px;font-weight:300;color:var(--nylas-base-500);border-top:1px solid var(--nylas-base-200);min-height:24px}.footer .powered-by-nylas{display:flex;align-items:center;text-decoration:none;color:var(--nylas-base-500)}.footer .powered-by-nylas:hover{color:var(--nylas-base-800)}.footer svg{fill:var(--nylas-base-500)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.footer svg{margin-top:1px}nylas-selected-event-card::part(nsec__timezone){position:absolute;bottom:0}nylas-notification{margin:1.5rem;width:-webkit-fill-available;width:-moz-available;position:absolute}nylas-locale-switch{position:absolute;padding:18px 20px;bottom:0;width:-webkit-fill-available;width:-moz-available;border-top:1px solid var(--nylas-base-200)}@media screen and (max-width: 768px){nylas-locale-switch{height:auto}}nylas-date-picker{padding:0 20px}button-component#report-issue{width:auto;position:absolute;bottom:4px;left:16px}nylas-feedback-form{position:absolute;top:0;height:100%;width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(0, 0, 0, 0.6);z-index:2;border-radius:inherit}';const D=B;const S={title:c.t("genericErrorTitle"),type:o.Error,category:g.Component};const T=class{constructor(e){n(this,e);this.init=i(this,"init",7);this.schedulerWillLoad=i(this,"schedulerWillLoad",7);this.schedulerDidLoad=i(this,"schedulerDidLoad",7);this.nylasSchedulerError=i(this,"nylasSchedulerError",7);this.nylasSchedulerInfo=i(this,"nylasSchedulerInfo",7);this.configSettingsLoaded=i(this,"configSettingsLoaded",7);this.bookingRefExtracted=i(this,"bookingRefExtracted",7);this.bookedEventInfo=i(this,"bookedEventInfo",7);this.mode="app";this.defaultSchedulerState=undefined;this.sessionId=undefined;this.schedulerApiUrl="https://api.us.nylas.com";this.bookingInfo=undefined;this.rescheduleBookingRef=undefined;this.cancelBookingRef=undefined;this.organizerConfirmationBookingRef=undefined;this.configurationId=undefined;this.slug=undefined;this.clientId=undefined;this.nylasBranding=true;this.eventOverrides={};this.isLoading=undefined;this.themeConfig=undefined;this.localization=undefined;this.showNotification=true;this.enableUserFeedback=true;this.hour12=undefined;this.automaticComponentRegistration=true;this.selectedDateLabel=(new Date).toLocaleDateString(undefined,{dateStyle:"full"})||`${c.t("noDateSelected")}`;this.refConfigId=undefined;this.language=navigator.language;this.showFeedbackModal=false;this.bookingInfoConfirmed=null}connectedCallback(){l(`[nylas-scheduler] connectedCallback`)}async componentWillLoad(){l(`[nylas-scheduler] Component will load`);if(this.enableUserFeedback&&!m()){_({dsn:"https://9d5731f1c77ca84c9ed3fb9b3ccf7ee1@o74852.ingest.us.sentry.io/4507889638178816",release:"1.3.6",integrations:e=>[...e.filter((e=>false)),v({colorScheme:"system",autoInject:false})],autoSessionTracking:false,beforeSend:()=>null})}const e=this.schedulerWillLoad.emit(this.host);if("schedulerWillLoad"in this.eventOverrides){await this.eventOverrides.schedulerWillLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}this.stores={scheduler:u({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,themeConfig:this.themeConfig,hour12:this.hour12,...this.defaultSchedulerState})};this.baseProvider=new r(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);this.refConfigId=this.configurationId;let t;if(this.rescheduleBookingRef){const[e,n,i]=d(this.rescheduleBookingRef);this.refConfigId=e;this.stores.scheduler.set("rescheduleBookingId",n);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n})}else if(this.cancelBookingRef){const[e,n,i]=d(this.cancelBookingRef);this.refConfigId=e;this.stores.scheduler.set("cancelBookingId",n);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n})}else if(this.organizerConfirmationBookingRef){const[e,n,i]=d(this.organizerConfirmationBookingRef);this.refConfigId=e;this.stores.scheduler.set("organizerConfirmationBookingId",n);this.stores.scheduler.set("organizerConfirmationSalt",i);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n,salt:i})}if("bookingRefExtracted"in this.eventOverrides){await this.eventOverrides.bookingRefExtracted(t,this.nylasSchedulerConnector);if(t.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}const n=this.baseProvider?.getStore("scheduler");this.nylasSchedulerConnector=new x({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:n});const i=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(i,this.nylasSchedulerConnector);if(i.defaultPrevented){return}}this.baseProvider?.componentWillLoad(this.nylasSchedulerConnector);this.applyThemeConfig(this.themeConfig)}async componentDidLoad(){this.baseProvider?.componentDidLoad();const e=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides){await this.eventOverrides.schedulerDidLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}this.localizationChanged(this.localization);const t=await(this.nylasSchedulerConnector?.scheduler.getUISettings());if(!t||"error"in t){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(t?.error)},host:this.host});return}else{if("data"in t&&t.data?.appearance){console.info("Appearance settings have been returned from the configuration used byt his scheduling page; please remember to grab them from the configSettingsLoaded event and apply them as desired.")}const e=this.configSettingsLoaded.emit({settings:t});if("configSettingsLoaded"in this.eventOverrides){await this.eventOverrides.configSettingsLoaded(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}}const n=this.baseProvider?.getStore("scheduler");const i=n?.get("configSettings")?.scheduler?.available_days_in_future;const s=n?.get("selectedTimeslot");if(s&&s?.start_time){if(!this.isTimeslotValid(s)){return}if(n?.get("showBookingForm")){n?.set("selectedDate",s.start_time);return}}const a=n?.get("selectedDate");const o=n?.get("availability");let r;if(o&&o.length>0){return}if(!a){const e=new Date;const{startTime:t,endTime:n,endTimeForAvailableDaysInFuture:s}=this.validateAvailableDaysInFuture(e,i||30);if(e.getTime()<s*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(t,n))}}else{const{startTime:e,endTime:t,endTimeForAvailableDaysInFuture:n}=this.validateAvailableDaysInFuture(a,i||30);if(a.getTime()<n*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(e,t))}}if(!r||"error"in r){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(r?.error)},host:this.host})}if(!a){let e=new Date;const t=n?.get("availability").find((e=>new Date(e.start_time)>new Date));if(t){e=t.start_time}n?.set("selectedDate",e)}}componentDisconnected(){this.baseProvider?.componentDisconnected()}bookingInfoChanged(e){this.stores?.scheduler.set("bookingInfo",e)}rescheduleBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("rescheduleBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}cancelBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("cancelBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}organizerConfirmationBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("organizerConfirmationBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}localizationChanged(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in b)){return}c.addResourceBundle(t,"translation",e[t],false,true)}))}themeConfigChanged(e){this.baseProvider?.getStore("scheduler")?.set("themeConfig",e);this.applyThemeConfig(e)}languageChanged(e){const t=e.detail;this.language=t;c.changeLanguage(t)}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}async monthChangedHandler(e){const t=e.detail;const n=this.nylasSchedulerConnector?.schedulerStore?.get("configSettings")?.scheduler?.available_days_in_future;const{startTime:i,endTime:s,endTimeForAvailableDaysInFuture:a}=this.validateAvailableDaysInFuture(t,n||30);if(e.defaultPrevented){return}if(i<a&&t.getTime()<a*1e3){const e=await(this.nylasSchedulerConnector?.scheduler.getAvailability(i,s));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const t=this.stores?.scheduler.get("selectableDates");if(t&&t.length>0){this.stores?.scheduler.set("selectedDate",t[0])}}}mapToBookingData(e){const t=this.stores?.scheduler.get("selectedTimeslot");const n=this.stores?.scheduler.get("selectedLanguage");const i=this.stores?.scheduler.get("selectedTimezone");const s=t?.start_time?new Date(t?.start_time).getTime()/1e3:"";const a=t?.end_time?new Date(t?.end_time).getTime()/1e3:"";return{additional_guests:e.guests,guest:{...e.primaryParticipant},additional_fields:{...e.additionalFields},start_time:s,end_time:a,email_language:n,timezone:i}}async bookButtonClickedHandler(e){if(e.defaultPrevented){return}const t=e.detail;const n=this.mapToBookingData(t);this.bookingInfoConfirmed=t;const i=this.nylasSchedulerConnector?.schedulerStore?.get("rescheduleBookingId");const s=i;if(s){const e=await(this.nylasSchedulerConnector?.scheduler.rescheduleBooking(s,t));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const i=e?.data;const a=this.bookedEventInfo.emit({...e,data:{...i,...n}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...i};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(a,this.nylasSchedulerConnector)}return}const a=await(this.nylasSchedulerConnector?.scheduler.bookTimeslot(t));if(!a||"error"in a){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(a?.error)},host:this.host})}const o=a?.data;const r=this.bookedEventInfo.emit({...a,data:{...o,...n}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...o};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(r,this.nylasSchedulerConnector)}}dateSelectedHandler(e){const t=e.detail;this.selectedDateLabel=t?t.toLocaleDateString(undefined,{dateStyle:"full"}):`${c.t("noDateSelected")}`}cancelBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}cancelBookedEventValidationErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}rescheduleBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}confirmBookingErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}feedbackModalClosedHandler(){this.showFeedbackModal=false}eventIsFullHandler(e){const t=e.detail.error;const n=e.detail.type;if(n==="error"){this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:t})},host:this.host})}else{this.nylasSchedulerInfo.emit({notification:{title:"Event is full",category:g.Component,type:o.Info,description:"The event you selected is full. Please try a different time.",id:(new Date).getTime().toString(),ttl:3e3},host:this.host})}}feedbackSubmittedHandler(e){const t=k("Scheduling Page User Feedback",{extra:{configId:this.configurationId,slug:this.slug}});const n={eventId:t,message:e.detail.feedback};w(n,{includeReplay:true,captureContext:{tags:{"nylas-web-element":"nylas-scheduling","nylas-web-element-version":"1.3.6","nylas-config-id":this.configurationId,"nylas-slug":this.slug,"host-url":window.location.href},extra:{configId:this.configurationId,slug:this.slug}}});this.showFeedbackModal=false}async getNylasSchedulerStore(){return this.baseProvider?.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(e){return{title:e?.title||S.title,category:e?.category||S.category,type:o.Error,description:e?.message||"",id:(new Date).getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(){if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){let e="";if(!this.sessionId){e+=c.t("sessionIdRequiredErrorMessage")}if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){e=c.t("sessionIdRequiredErrorMessage")+" "+c.t("publicConfigErrorMessage")}this.nylasSchedulerError.emit({notification:{title:c.t("schedulingComponentErrorTitle"),category:g.Component,type:o.Error,description:e,id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}isTimeslotValid(e){const t=new Date(e.start_time);if(t<new Date){this.nylasSchedulerError.emit({notification:{title:c.t("invalidTimeslotErrorTitle"),category:g.Component,type:o.Error,description:c.t("invalidTimeslotErrorMessage"),id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}validateAvailableDaysInFuture(e,t){const n=new Date;const i=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3;const s=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;const a=Math.floor(h(n,t).getTime()/1e3);const o=Math.min(a,s);const r=i<n.getTime()/1e3?Math.floor(n.getTime()/1e3):i;return{startTime:r,endTime:o,endTimeForAvailableDaysInFuture:a}}applyThemeConfig(e){if(e){for(const[t,n]of Object.entries(e)){this.host.style.setProperty(`${t}`,n)}}}onFeedbackClick(e){e.preventDefault();this.showFeedbackModal=true}redirectToCustomUrl(e){window.location.assign(e)}render(){const t=this.mode==="app";const n=this.baseProvider?.getStore("scheduler");const i=n?.get("eventInfo");const a=n?.get("showBookingForm");const o=n?.get("cancelledEventInfo");const r=n?.get("cancelBookingId");const l=n?.get("selectedTimeslot");const d=n?.get("rescheduleBookingId");const h=n?.get("organizerConfirmationBookingId");const p=n?.get("rejectBookingId");const g=n?.get("confirmedEventInfo");const u=n?.get("nylasBranding")||this.nylasBranding;const b=n?.get("selectedDate");const m=n?.get("configSettings")?.scheduler?.confirmation_redirect_url;this.selectedDateLabel=b&&this.language?f(b.toLocaleDateString(y[this.language],{dateStyle:"full"})):`${c.t("noDateSelected")}`;if(t&&(r||p)&&!o){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancel-flow-page",part:"cancel-flow-page"},e("nylas-cancel-booking-form",{selectedTimeslot:l,cancelBookingId:r,rejectBookingId:p,exportparts:"ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&h){return e(s,null,e(I,null,e("div",{class:"manual-confirmation-page",part:"manual-confirmation-page"},e("nylas-organizer-confirmation-card",{organizerConfirmationBookingId:h,exportparts:"nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&o){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"cancelled-event-page"},e("nylas-cancelled-event-card",{cancelledEventInfo:o,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&g){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"confirmed-event-page"},e("nylas-confirmed-event-card",{confirmedEventInfo:g,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&i&&m){const e=this.bookingInfoConfirmed?.primaryParticipant;const t=this.bookingInfoConfirmed?.location;const n=this.bookingInfoConfirmed?.booking_ref;const s=this.bookingInfoConfirmed?.additionalFields||{};if(this.bookingInfo&&typeof this.bookingInfo?.additionalFields!=="undefined"){const e=this.bookingInfo.additionalFields;Object.keys(e).forEach((t=>{if(!s[t]&&e?.[t]){s[t]=e[t].value}}))}const a=this.stores?.scheduler.get("selectedTimeslot");const o=this.stores?.scheduler.get("selectedTimezone");const r=this.stores?.scheduler.get("selectedLanguage");const l=this.stores?.scheduler.get("configSettings");const c=this.configurationId?this.configurationId:l?.configuration_id;const d=window.location.search;const h=new URLSearchParams(d);h.set("booking_id",i.booking_id);e?.name&&h.set("name",e.name);e?.email&&h.set("email",e.email);a?.start_time&&h.set("start_time",(new Date(a.start_time).getTime()/1e3).toString());a?.end_time&&h.set("end_time",(new Date(a.end_time).getTime()/1e3).toString());o&&h.set("tz",o);r&&h.set("language",r);s&&h.set("additional_values",JSON.stringify(s));this.slug&&h.set("page_slug",this.slug);c&&h.set("config_id",c);t&&h.set("location",t);n&&h.set("booking_ref",n);this.redirectToCustomUrl(`${m}?${h.toString()}`);return}if(t&&i){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"booked-event-page",part:"booked-event-page ns_booked-event-page"},e("nylas-booked-event-card",{selectedTimeslot:l,eventInfo:i,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&(!i||!!d)&&!a){const t=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},d&&e(C,null,`${c.t("rescheduleTitle")}`),e("div",{class:"select-date-page",part:"select-date-page ns_select-date-page"},e("div",{class:"left-panel",part:"ns_left-panel"},e("nylas-date-picker",{exportparts:"ndp, ndp__title, ndp__month-header, ndp__month-button, ndp__day, ndp__date, ndp__date--disabled, ndp__date--selected, ndp__date--current-day, ndp__date--current-month"}),e("nylas-locale-switch",{exportparts:"nls, nls__timezone, nls__timezone-dropdown, nls__timezone-drop-button, nls__timezone-drop-button-selected-label, nls__timezone-drop-content, nls__timezone-drop-label, nls__language, nls__language-dropdown, nls__language-drop-button, nls__language-drop-content, nls__language-drop-label"})),e("div",{class:`right-panel ${d?"reschedule":""}`,part:`ns_right-panel ${d?"ns_reschedule":""}`},e("h2",{part:"ns_right-panel__title"},e("calendar-icon",{part:"ns_right-panel__calendar-icon"}),e("span",{id:"selectedDate",part:"ns_right-panel__selected-date"},this.selectedDateLabel)),e("nylas-timeslot-picker",{exportparts:"ntp, ntp__time-picker-wrapper, ntp__timeslots, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},t&&e("span",{slot:"timeslot-picker-cta-label"},e("slot",{name:"timeslot-picker-cta-label"})))))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&!i&&a){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},d&&e(C,null,`${c.t("rescheduleTitle")}`),e("div",{class:"additional-data-page",part:"additional-data-page ns_additional-data-page"},e("div",{class:"left-panel ns_left-panel",part:"ns_left-panel"},e("div",{class:"wrapper",part:"ns_left-panel__wrapper"},e("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone"}))),e("div",{class:`right-panel ${d?"reschedule":""}`,part:`ns_right-panel ${d?"ns_reschedule":""}`},e("nylas-booking-form",{exportparts:"nbf, nbf__input-textfield, nbf__button-ghost, nbf__button-outline, nbf__button-primary, nbf__input-wrapper, nbf__checkbox-component, nbf__radio-button-group, nbf__textarea-component, nbf__dropdown, nbf__dropdown-button, nbf__dropdown-content"})))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}return e(s,null,e("slot",null))}get host(){return a(this)}static get watchers(){return{bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"],organizerConfirmationBookingRef:["organizerConfirmationBookingRefChanged"],localization:["localizationChanged"],themeConfig:["themeConfigChanged"]}}};T.style=D;export{T as nylas_scheduling};
2
- //# sourceMappingURL=p-8841358d.entry.js.map
1
+ import{h as e,F as t,r as n,c as i,H as s,a}from"./p-6f5a3998.js";import{n as o,N as r}from"./p-c372bced.js";import{a as l,i as c,h as d,b as h,j as f}from"./p-77e4b56c.js";import{N as p,E as g,C as u}from"./p-f0c25e38.js";import{L as b,b as y}from"./p-6c2ba972.js";import{i as m,a as _,c as k,b as w,f as v}from"./p-64bc2c6f.js";import"./p-c79dcb59.js";import"./p-fc5bc07b.js";class x{constructor({schedulerAPIURL:e,nylasSchedulerStore:t,sessionId:n,configId:i,slug:s,clientId:a}){if(!e){throw new Error("schedulerAPIURL is required")}if(!t){throw new Error("nylasSchedulerStore is required")}if(!n&&!i&&!(s||a)){throw new Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.")}if(e==="/"){const t=new URL(window.location.href);e=t.origin}this.configId=i;this.sessionId=n;this.schedulerAPIURL=e;this.nylasSchedulerStore=t;this.slug=s;this.clientId=a}init(){l("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}get scheduler(){if(this._schedulerAPIConnector){return this._schedulerAPIConnector}this._schedulerAPIConnector=new p({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId,slug:this.slug,clientId:this.clientId});return this._schedulerAPIConnector}resetStores(){this.nylasSchedulerStore.reset()}}const I=(n,i)=>{const s=n.isLoading;const a=n.showNotification;const o=n.nylasBranding;return e(t,null,a&&e("nylas-notification",null),s&&e("div",{class:"loading"},e("div",{class:"left"},e("div",{class:"skeleton"})),e("div",{class:"right"},e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}))),!s&&i,e("div",{class:"footer"},o&&e("a",{href:"https://scheduler.nylas.com?utm_source=powered-by-nylas-logoutm_medium=link&utm_campaign=get-scheduler&utm_id=get-scheduler",class:"powered-by-nylas",target:"_blank",rel:"noreferrer noopener"},"Powered by ",e("span",{class:"sr-only"},"Nylas"),e("nylas-logo",{"aria-hidden":true}))))};const C=(t,n)=>e("div",{class:"message-banner"},n);const B=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 8px 2px rgba(0, 0, 0, 0.05), 0px 8px 16px -2px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;font-family:var(--nylas-font-family);font-optical-sizing:auto;font-style:normal;font-variation-settings:"slnt" 0}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}:root{font-family:inherit}.error{padding:8rem 12rem;color:var(--nylas-base-0);background-color:var(--nylas-error);margin:1.5rem;border-radius:var(--nylas-border-radius-2x)}.message-banner{text-align:right;color:var(--nylas-base-800);padding:1rem;border-bottom:1px solid var(--nylas-color-primary-200);margin:0}.loading{margin:1.5rem;display:flex;gap:1rem}.loading .skeleton{border-radius:var(--nylas-border-radius-2x);animation:pulsate 1.5s infinite}.loading .skeleton:nth-child(2){animation-delay:-100ms}.loading .skeleton:nth-child(3){animation-delay:-200ms}.loading .skeleton:nth-child(4){animation-delay:-300ms}.loading .skeleton:nth-child(5){animation-delay:-400ms}.loading .left .skeleton{height:100%;width:400px}.loading .right .skeleton{height:5rem;width:300px;margin-bottom:1rem}.loading .right .skeleton:last-child{margin-bottom:0}@keyframes pulsate{0%{background-color:var(--nylas-base-50)}50%{background-color:var(--nylas-base-100)}100%{background-color:var(--nylas-base-50)}}.select-date-page,.additional-data-page,.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{border-top-left-radius:var(--nylas-border-radius-2x);border-top-right-radius:var(--nylas-border-radius-2x)}.select-date-page,.additional-data-page{display:flex}@media screen and (max-width: 768px){.select-date-page,.additional-data-page{flex-direction:column}}.booked-event-page,.manual-confirmation-page{background-color:var(--nylas-base-50)}.cancelled-event-page,.manual-confirmation-page,.cancel-flow-page{padding:1rem;height:496px;display:flex;justify-content:center;align-items:center}.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:784px;background:var(--nylas-base-50)}@media screen and (max-width: 768px){.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:90%}}.left-panel{display:flex;flex-direction:column;min-width:424px;border-top-left-radius:inherit;background:var(--nylas-base-0);position:relative;padding:1rem 0 0 0;height:624px}@media screen and (max-width: 768px){.left-panel{border-top-right-radius:inherit;min-width:unset;height:auto}}@media screen and (max-width: 768px){.select-date-page .left-panel{height:624px}}.border{margin-left:-20px;margin-right:-20px;border-top-width:1px;height:0.5px;background-color:var(--nylas-base-200)}@media screen and (max-width: 768px){.border{display:none}}.right-panel{min-width:360px;width:360px;background-color:var(--nylas-base-50);height:624px;padding-top:16px;border-left:1px solid var(--nylas-base-200);border-top-right-radius:inherit}.right-panel.reschedule{border-top-right-radius:0px}@media screen and (max-width: 768px){.right-panel{border-top-right-radius:0px;width:inherit;min-width:unset;height:auto;border-left:none}}.right-panel h2{display:flex;margin:0;height:48px;gap:0.5rem;justify-content:center;align-items:center;width:auto;font-size:1.125rem;line-height:1.5rem;font-weight:500;text-align:center;color:var(--nylas-base-800)}.additional-data-page .left-panel{background-color:var(--nylas-base-50)}.additional-data-page .right-panel{background-color:var(--nylas-base-0)}nylas-selected-event-card{height:604px;padding:0 1rem}@media screen and (max-width: 768px){nylas-selected-event-card{height:250px}}.footer{display:flex;justify-content:flex-end;align-items:center;padding:16px;font-size:14px;font-weight:300;color:var(--nylas-base-500);border-top:1px solid var(--nylas-base-200);min-height:24px}.footer .powered-by-nylas{display:flex;align-items:center;text-decoration:none;color:var(--nylas-base-500)}.footer .powered-by-nylas:hover{color:var(--nylas-base-800)}.footer svg{fill:var(--nylas-base-500)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.footer svg{margin-top:1px}nylas-selected-event-card::part(nsec__timezone){position:absolute;bottom:0}nylas-notification{margin:1.5rem;width:-webkit-fill-available;width:-moz-available;position:absolute}nylas-locale-switch{position:absolute;padding:18px 20px;bottom:0;width:-webkit-fill-available;width:-moz-available;border-top:1px solid var(--nylas-base-200)}@media screen and (max-width: 768px){nylas-locale-switch{height:auto}}nylas-date-picker{padding:0 20px}button-component#report-issue{width:auto;position:absolute;bottom:4px;left:16px}nylas-feedback-form{position:absolute;top:0;height:100%;width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(0, 0, 0, 0.6);z-index:2;border-radius:inherit}';const D=B;const S={title:c.t("genericErrorTitle"),type:o.Error,category:g.Component};const T=class{constructor(e){n(this,e);this.init=i(this,"init",7);this.schedulerWillLoad=i(this,"schedulerWillLoad",7);this.schedulerDidLoad=i(this,"schedulerDidLoad",7);this.nylasSchedulerError=i(this,"nylasSchedulerError",7);this.nylasSchedulerInfo=i(this,"nylasSchedulerInfo",7);this.configSettingsLoaded=i(this,"configSettingsLoaded",7);this.bookingRefExtracted=i(this,"bookingRefExtracted",7);this.bookedEventInfo=i(this,"bookedEventInfo",7);this.mode="app";this.defaultSchedulerState=undefined;this.sessionId=undefined;this.schedulerApiUrl="https://api.us.nylas.com";this.bookingInfo=undefined;this.rescheduleBookingRef=undefined;this.cancelBookingRef=undefined;this.organizerConfirmationBookingRef=undefined;this.configurationId=undefined;this.slug=undefined;this.clientId=undefined;this.nylasBranding=true;this.eventOverrides={};this.isLoading=undefined;this.themeConfig=undefined;this.localization=undefined;this.showNotification=true;this.enableUserFeedback=true;this.hour12=undefined;this.automaticComponentRegistration=true;this.selectedDateLabel=(new Date).toLocaleDateString(undefined,{dateStyle:"full"})||`${c.t("noDateSelected")}`;this.refConfigId=undefined;this.language=navigator.language;this.showFeedbackModal=false;this.bookingInfoConfirmed=null}connectedCallback(){l(`[nylas-scheduler] connectedCallback`)}async componentWillLoad(){l(`[nylas-scheduler] Component will load`);if(this.enableUserFeedback&&!m()){_({dsn:"https://9d5731f1c77ca84c9ed3fb9b3ccf7ee1@o74852.ingest.us.sentry.io/4507889638178816",release:"1.4.0",integrations:e=>[...e.filter((e=>false)),v({colorScheme:"system",autoInject:false})],autoSessionTracking:false,beforeSend:()=>null})}const e=this.schedulerWillLoad.emit(this.host);if("schedulerWillLoad"in this.eventOverrides){await this.eventOverrides.schedulerWillLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}this.stores={scheduler:u({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,themeConfig:this.themeConfig,hour12:this.hour12,...this.defaultSchedulerState})};this.baseProvider=new r(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);this.refConfigId=this.configurationId;let t;if(this.rescheduleBookingRef){const[e,n,i]=d(this.rescheduleBookingRef);this.refConfigId=e;this.stores.scheduler.set("rescheduleBookingId",n);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n})}else if(this.cancelBookingRef){const[e,n,i]=d(this.cancelBookingRef);this.refConfigId=e;this.stores.scheduler.set("cancelBookingId",n);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n})}else if(this.organizerConfirmationBookingRef){const[e,n,i]=d(this.organizerConfirmationBookingRef);this.refConfigId=e;this.stores.scheduler.set("organizerConfirmationBookingId",n);this.stores.scheduler.set("organizerConfirmationSalt",i);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n,salt:i})}if("bookingRefExtracted"in this.eventOverrides){await this.eventOverrides.bookingRefExtracted(t,this.nylasSchedulerConnector);if(t.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}const n=this.baseProvider?.getStore("scheduler");this.nylasSchedulerConnector=new x({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:n});const i=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(i,this.nylasSchedulerConnector);if(i.defaultPrevented){return}}this.baseProvider?.componentWillLoad(this.nylasSchedulerConnector);this.applyThemeConfig(this.themeConfig)}async componentDidLoad(){this.baseProvider?.componentDidLoad();const e=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides){await this.eventOverrides.schedulerDidLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}this.localizationChanged(this.localization);const t=await(this.nylasSchedulerConnector?.scheduler.getUISettings());if(!t||"error"in t){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(t?.error)},host:this.host});return}else{if("data"in t&&t.data?.appearance){console.info("Appearance settings have been returned from the configuration used byt his scheduling page; please remember to grab them from the configSettingsLoaded event and apply them as desired.")}const e=this.configSettingsLoaded.emit({settings:t});if("configSettingsLoaded"in this.eventOverrides){await this.eventOverrides.configSettingsLoaded(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}}const n=this.baseProvider?.getStore("scheduler");const i=n?.get("configSettings")?.scheduler?.available_days_in_future;const s=n?.get("selectedTimeslot");if(s&&s?.start_time){if(!this.isTimeslotValid(s)){return}if(n?.get("showBookingForm")){n?.set("selectedDate",s.start_time);return}}const a=n?.get("selectedDate");const o=n?.get("availability");let r;if(o&&o.length>0){return}if(!a){const e=new Date;const{startTime:t,endTime:n,endTimeForAvailableDaysInFuture:s}=this.validateAvailableDaysInFuture(e,i||30);if(e.getTime()<s*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(t,n))}}else{const{startTime:e,endTime:t,endTimeForAvailableDaysInFuture:n}=this.validateAvailableDaysInFuture(a,i||30);if(a.getTime()<n*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(e,t))}}if(!r||"error"in r){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(r?.error)},host:this.host})}if(!a){let e=new Date;const t=n?.get("availability").find((e=>new Date(e.start_time)>new Date));if(t){e=t.start_time}n?.set("selectedDate",e)}}componentDisconnected(){this.baseProvider?.componentDisconnected()}bookingInfoChanged(e){this.stores?.scheduler.set("bookingInfo",e)}rescheduleBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("rescheduleBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}cancelBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("cancelBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}organizerConfirmationBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("organizerConfirmationBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}localizationChanged(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in b)){return}c.addResourceBundle(t,"translation",e[t],false,true)}))}themeConfigChanged(e){this.baseProvider?.getStore("scheduler")?.set("themeConfig",e);this.applyThemeConfig(e)}languageChanged(e){const t=e.detail;this.language=t;c.changeLanguage(t)}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}async monthChangedHandler(e){const t=e.detail;const n=this.nylasSchedulerConnector?.schedulerStore?.get("configSettings")?.scheduler?.available_days_in_future;const{startTime:i,endTime:s,endTimeForAvailableDaysInFuture:a}=this.validateAvailableDaysInFuture(t,n||30);if(e.defaultPrevented){return}if(i<a&&t.getTime()<a*1e3){const e=await(this.nylasSchedulerConnector?.scheduler.getAvailability(i,s));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const t=this.stores?.scheduler.get("selectableDates");if(t&&t.length>0){this.stores?.scheduler.set("selectedDate",t[0])}}}mapToBookingData(e){const t=this.stores?.scheduler.get("selectedTimeslot");const n=this.stores?.scheduler.get("selectedLanguage");const i=this.stores?.scheduler.get("selectedTimezone");const s=t?.start_time?new Date(t?.start_time).getTime()/1e3:"";const a=t?.end_time?new Date(t?.end_time).getTime()/1e3:"";return{additional_guests:e.guests,guest:{...e.primaryParticipant},additional_fields:{...e.additionalFields},start_time:s,end_time:a,email_language:n,timezone:i}}async bookButtonClickedHandler(e){if(e.defaultPrevented){return}const t=e.detail;const n=this.mapToBookingData(t);this.bookingInfoConfirmed=t;const i=this.nylasSchedulerConnector?.schedulerStore?.get("rescheduleBookingId");const s=i;if(s){const e=await(this.nylasSchedulerConnector?.scheduler.rescheduleBooking(s,t));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const i=e?.data;const a=this.bookedEventInfo.emit({...e,data:{...i,...n}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...i};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(a,this.nylasSchedulerConnector)}return}const a=await(this.nylasSchedulerConnector?.scheduler.bookTimeslot(t));if(!a||"error"in a){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(a?.error)},host:this.host})}const o=a?.data;const r=this.bookedEventInfo.emit({...a,data:{...o,...n}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...o};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(r,this.nylasSchedulerConnector)}}dateSelectedHandler(e){const t=e.detail;this.selectedDateLabel=t?t.toLocaleDateString(undefined,{dateStyle:"full"}):`${c.t("noDateSelected")}`}cancelBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}cancelBookedEventValidationErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}rescheduleBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}confirmBookingErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}feedbackModalClosedHandler(){this.showFeedbackModal=false}eventIsFullHandler(e){const t=e.detail.error;const n=e.detail.type;if(n==="error"){this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:t})},host:this.host})}else{this.nylasSchedulerInfo.emit({notification:{title:"Event is full",category:g.Component,type:o.Info,description:"The event you selected is full. Please try a different time.",id:(new Date).getTime().toString(),ttl:3e3},host:this.host})}}feedbackSubmittedHandler(e){const t=k("Scheduling Page User Feedback",{extra:{configId:this.configurationId,slug:this.slug}});const n={eventId:t,message:e.detail.feedback};w(n,{includeReplay:true,captureContext:{tags:{"nylas-web-element":"nylas-scheduling","nylas-web-element-version":"1.4.0","nylas-config-id":this.configurationId,"nylas-slug":this.slug,"host-url":window.location.href},extra:{configId:this.configurationId,slug:this.slug}}});this.showFeedbackModal=false}async getNylasSchedulerStore(){return this.baseProvider?.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(e){return{title:e?.title||S.title,category:e?.category||S.category,type:o.Error,description:e?.message||"",id:(new Date).getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(){if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){let e="";if(!this.sessionId){e+=c.t("sessionIdRequiredErrorMessage")}if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){e=c.t("sessionIdRequiredErrorMessage")+" "+c.t("publicConfigErrorMessage")}this.nylasSchedulerError.emit({notification:{title:c.t("schedulingComponentErrorTitle"),category:g.Component,type:o.Error,description:e,id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}isTimeslotValid(e){const t=new Date(e.start_time);if(t<new Date){this.nylasSchedulerError.emit({notification:{title:c.t("invalidTimeslotErrorTitle"),category:g.Component,type:o.Error,description:c.t("invalidTimeslotErrorMessage"),id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}validateAvailableDaysInFuture(e,t){const n=new Date;const i=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3;const s=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;const a=Math.floor(h(n,t).getTime()/1e3);const o=Math.min(a,s);const r=i<n.getTime()/1e3?Math.floor(n.getTime()/1e3):i;return{startTime:r,endTime:o,endTimeForAvailableDaysInFuture:a}}applyThemeConfig(e){if(e){for(const[t,n]of Object.entries(e)){this.host.style.setProperty(`${t}`,n)}}}onFeedbackClick(e){e.preventDefault();this.showFeedbackModal=true}redirectToCustomUrl(e){window.location.assign(e)}render(){const t=this.mode==="app";const n=this.baseProvider?.getStore("scheduler");const i=n?.get("eventInfo");const a=n?.get("showBookingForm");const o=n?.get("cancelledEventInfo");const r=n?.get("cancelBookingId");const l=n?.get("selectedTimeslot");const d=n?.get("rescheduleBookingId");const h=n?.get("organizerConfirmationBookingId");const p=n?.get("rejectBookingId");const g=n?.get("confirmedEventInfo");const u=n?.get("nylasBranding")||this.nylasBranding;const b=n?.get("selectedDate");const m=n?.get("configSettings")?.scheduler?.confirmation_redirect_url;this.selectedDateLabel=b&&this.language?f(b.toLocaleDateString(y[this.language],{dateStyle:"full"})):`${c.t("noDateSelected")}`;if(t&&(r||p)&&!o){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancel-flow-page",part:"cancel-flow-page"},e("nylas-cancel-booking-form",{selectedTimeslot:l,cancelBookingId:r,rejectBookingId:p,exportparts:"ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&h){return e(s,null,e(I,null,e("div",{class:"manual-confirmation-page",part:"manual-confirmation-page"},e("nylas-organizer-confirmation-card",{organizerConfirmationBookingId:h,exportparts:"nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&o){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"cancelled-event-page"},e("nylas-cancelled-event-card",{cancelledEventInfo:o,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&g){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"confirmed-event-page"},e("nylas-confirmed-event-card",{confirmedEventInfo:g,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&i&&m){const e=this.bookingInfoConfirmed?.primaryParticipant;const t=this.bookingInfoConfirmed?.location;const n=this.bookingInfoConfirmed?.booking_ref;const s=this.bookingInfoConfirmed?.additionalFields||{};if(this.bookingInfo&&typeof this.bookingInfo?.additionalFields!=="undefined"){const e=this.bookingInfo.additionalFields;Object.keys(e).forEach((t=>{if(!s[t]&&e?.[t]){s[t]=e[t].value}}))}const a=this.stores?.scheduler.get("selectedTimeslot");const o=this.stores?.scheduler.get("selectedTimezone");const r=this.stores?.scheduler.get("selectedLanguage");const l=this.stores?.scheduler.get("configSettings");const c=this.configurationId?this.configurationId:l?.configuration_id;const d=window.location.search;const h=new URLSearchParams(d);h.set("booking_id",i.booking_id);e?.name&&h.set("name",e.name);e?.email&&h.set("email",e.email);a?.start_time&&h.set("start_time",(new Date(a.start_time).getTime()/1e3).toString());a?.end_time&&h.set("end_time",(new Date(a.end_time).getTime()/1e3).toString());o&&h.set("tz",o);r&&h.set("language",r);s&&h.set("additional_values",JSON.stringify(s));this.slug&&h.set("page_slug",this.slug);c&&h.set("config_id",c);t&&h.set("location",t);n&&h.set("booking_ref",n);this.redirectToCustomUrl(`${m}?${h.toString()}`);return}if(t&&i){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"booked-event-page",part:"booked-event-page ns_booked-event-page"},e("nylas-booked-event-card",{selectedTimeslot:l,eventInfo:i,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&(!i||!!d)&&!a){const t=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},d&&e(C,null,`${c.t("rescheduleTitle")}`),e("div",{class:"select-date-page",part:"select-date-page ns_select-date-page"},e("div",{class:"left-panel",part:"ns_left-panel"},e("nylas-date-picker",{exportparts:"ndp, ndp__title, ndp__month-header, ndp__month-button, ndp__day, ndp__date, ndp__date--disabled, ndp__date--selected, ndp__date--current-day, ndp__date--current-month"}),e("nylas-locale-switch",{exportparts:"nls, nls__timezone, nls__timezone-dropdown, nls__timezone-drop-button, nls__timezone-drop-button-selected-label, nls__timezone-drop-content, nls__timezone-drop-label, nls__language, nls__language-dropdown, nls__language-drop-button, nls__language-drop-content, nls__language-drop-label"})),e("div",{class:`right-panel ${d?"reschedule":""}`,part:`ns_right-panel ${d?"ns_reschedule":""}`},e("h2",{part:"ns_right-panel__title"},e("calendar-icon",{part:"ns_right-panel__calendar-icon"}),e("span",{id:"selectedDate",part:"ns_right-panel__selected-date"},this.selectedDateLabel)),e("nylas-timeslot-picker",{exportparts:"ntp, ntp__time-picker-wrapper, ntp__timeslots, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},t&&e("span",{slot:"timeslot-picker-cta-label"},e("slot",{name:"timeslot-picker-cta-label"})))))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&!i&&a){return e(s,null,e(I,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},d&&e(C,null,`${c.t("rescheduleTitle")}`),e("div",{class:"additional-data-page",part:"additional-data-page ns_additional-data-page"},e("div",{class:"left-panel ns_left-panel",part:"ns_left-panel"},e("div",{class:"wrapper",part:"ns_left-panel__wrapper"},e("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone"}))),e("div",{class:`right-panel ${d?"reschedule":""}`,part:`ns_right-panel ${d?"ns_reschedule":""}`},e("nylas-booking-form",{exportparts:"nbf, nbf__input-textfield, nbf__button-ghost, nbf__button-outline, nbf__button-primary, nbf__input-wrapper, nbf__checkbox-component, nbf__radio-button-group, nbf__textarea-component, nbf__dropdown, nbf__dropdown-button, nbf__dropdown-content"})))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}return e(s,null,e("slot",null))}get host(){return a(this)}static get watchers(){return{bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"],organizerConfirmationBookingRef:["organizerConfirmationBookingRefChanged"],localization:["localizationChanged"],themeConfig:["themeConfigChanged"]}}};T.style=D;export{T as nylas_scheduling};
2
+ //# sourceMappingURL=p-f7ea608d.entry.js.map
@@ -1,9 +1,8 @@
1
1
  import { EventEmitter } from '../../../stencil-public-runtime';
2
2
  import { Calendar } from '@fullcalendar/core';
3
3
  import { LANGUAGE_CODE } from "../../../common/constants";
4
- import { Conference, EventDetails, GroupConfiguration, GroupEventAPIData } from '@nylas/core';
4
+ import { Conference, EventDetails, GroupConfiguration, GroupEventAPIData, NylasCalendar } from '@nylas/core';
5
5
  import { User } from "../../../common/nylas-api-request";
6
- import { Calendar as NylasCalendar } from '@nylas/core';
7
6
  export type CreateGroupEventFormState = {
8
7
  title: string;
9
8
  description: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylas/web-elements",
3
- "version": "0.0.0-canary-20250318134614",
3
+ "version": "0.0.0-test-20250319204140",
4
4
  "description": "Nylas Web Elements",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -42,7 +42,7 @@
42
42
  "sanitize-html": "^2.13.0",
43
43
  "sortablejs": "^1.15.6",
44
44
  "@nylas/identity": "^3.0.0",
45
- "@nylas/core": "^0.0.0-canary-20250318134614"
45
+ "@nylas/core": "^0.0.0-test-20250319204140"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@playwright/test": "^1.50.1",