@nylas/react 1.0.0-prealpha1 → 1.0.2-canary.0

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 (129) hide show
  1. package/dist/add-circle-icon_13.entry-6dccb5e5.cjs +1 -0
  2. package/dist/add-circle-icon_13.entry-ab84be80.js +1050 -0
  3. package/dist/{archive-icon_7.entry-8c90815a.cjs → archive-icon_7.entry-0deb31c2.cjs} +1 -1
  4. package/dist/{archive-icon_7.entry-53aede1b.js → archive-icon_7.entry-187a3484.js} +20 -20
  5. package/dist/arrow-icon.entry-b782e05a.js +15 -0
  6. package/dist/{arrow-icon.entry-a2f53919.cjs → arrow-icon.entry-fb0ebc89.cjs} +1 -1
  7. package/dist/auth-store-764d3768-3e9c24a0.js +66 -0
  8. package/dist/auth-store-764d3768-ce84fc6a.cjs +1 -0
  9. package/dist/{bold-icon_3.entry-e0bc6774.cjs → bold-icon_3.entry-49e5a1d0.cjs} +1 -1
  10. package/dist/{bold-icon_3.entry-ad806730.js → bold-icon_3.entry-8aebbbdb.js} +6 -6
  11. package/dist/{calendar-cancel-icon.entry-74051835.js → calendar-cancel-icon.entry-305c099c.js} +5 -5
  12. package/dist/{calendar-cancel-icon.entry-546b7bd4.cjs → calendar-cancel-icon.entry-3f4d6cf2.cjs} +1 -1
  13. package/dist/calendar-check-icon_2.entry-1bf4163c.js +25 -0
  14. package/dist/calendar-check-icon_2.entry-fa7c033a.cjs +1 -0
  15. package/dist/{calendar-icon.entry-25474b1e.cjs → calendar-icon.entry-78433555.cjs} +1 -1
  16. package/dist/{calendar-icon.entry-c751873f.js → calendar-icon.entry-b5678535.js} +4 -4
  17. package/dist/{chevron-icon.entry-97e4621e.cjs → chevron-icon.entry-49b0d3e7.cjs} +1 -1
  18. package/dist/chevron-icon.entry-f484c9a3.js +15 -0
  19. package/dist/close-icon.entry-24d5c268.js +15 -0
  20. package/dist/close-icon.entry-37965d55.cjs +1 -0
  21. package/dist/{nylas-booked-event-card_9.entry-d995d7cb.js → constants-d93cf397-dd67263d.js} +1381 -2230
  22. package/dist/{nylas-booked-event-card_9.entry-ea02f083.cjs → constants-d93cf397-e3587f5c.cjs} +6 -139
  23. package/dist/document-refresh-icon.entry-0e8935fa.cjs +1 -0
  24. package/dist/document-refresh-icon.entry-8791ab16.js +15 -0
  25. package/dist/elements/index.d.ts +20 -0
  26. package/dist/{elements-60ebdb01-24595598.cjs → elements-dc5b338e-81a0319c.cjs} +577 -555
  27. package/dist/{elements-60ebdb01-5d144002.js → elements-dc5b338e-fb5dbfb5.js} +3339 -2763
  28. package/dist/{forward-icon_6.entry-725d1be4.cjs → forward-icon_6.entry-903ccd33.cjs} +2 -2
  29. package/dist/{forward-icon_6.entry-dc8f7235.js → forward-icon_6.entry-cb605bfc.js} +63 -63
  30. package/dist/globe-icon_3.entry-71d83904.js +109 -0
  31. package/dist/globe-icon_3.entry-c6aefc52.cjs +1 -0
  32. package/dist/{index-2b85580a-f9211f23.js → index-10914bc1-1a809477.js} +5 -10
  33. package/dist/{index-2b85580a-bfc3ceac.cjs → index-10914bc1-93ff6f46.cjs} +1 -1
  34. package/dist/index-cee193d2.cjs +30 -0
  35. package/dist/index-e834697b.js +1562 -0
  36. package/dist/index.d.ts +1 -1
  37. package/dist/info-icon.entry-3774a4e3.js +15 -0
  38. package/dist/info-icon.entry-85bf3fbc.cjs +1 -0
  39. package/dist/loading-icon.entry-8941102c.js +15 -0
  40. package/dist/loading-icon.entry-ae6c7b74.cjs +1 -0
  41. package/dist/mailbox-store-6b9425dc-a0366cf2.cjs +1 -0
  42. package/dist/{mailbox-store-0019772c-06d31a90.js → mailbox-store-6b9425dc-c249fa99.js} +59 -121
  43. package/dist/nylas-booked-event-card_10.entry-a166d51d.js +739 -0
  44. package/dist/nylas-booked-event-card_10.entry-b181a874.cjs +1 -0
  45. package/dist/nylas-form-card.entry-7173dd4a.js +56 -0
  46. package/dist/nylas-form-card.entry-8fdbefa6.cjs +1 -0
  47. package/dist/nylas-if-state_3.entry-2093c593.cjs +1 -0
  48. package/dist/{nylas-if-state_3.entry-ce816adb.js → nylas-if-state_3.entry-e7b615a1.js} +12 -10
  49. package/dist/{nylas-list-folders.entry-8134344b.js → nylas-list-folders.entry-744293ae.js} +9 -8
  50. package/dist/nylas-list-folders.entry-dff7a835.cjs +1 -0
  51. package/dist/{nylas-list-threads.entry-1367fe30.js → nylas-list-threads.entry-85ad1b74.js} +5 -4
  52. package/dist/nylas-list-threads.entry-edb1d265.cjs +1 -0
  53. package/dist/{nylas-mailbox-pagination.entry-568ac217.js → nylas-mailbox-pagination.entry-55ef4b8c.js} +4 -3
  54. package/dist/nylas-mailbox-pagination.entry-5b888a0e.cjs +1 -0
  55. package/dist/nylas-mailbox-toolbar-button.entry-bb42156a.cjs +1 -0
  56. package/dist/{nylas-mailbox-toolbar-button.entry-9214b283.js → nylas-mailbox-toolbar-button.entry-bdcf7d17.js} +10 -9
  57. package/dist/nylas-open-hours-picker.entry-0f4f34f6.cjs +1 -0
  58. package/dist/{nylas-open-hours-picker.entry-109f13f5.js → nylas-open-hours-picker.entry-7e7060fe.js} +3 -2
  59. package/dist/nylas-provider.entry-1dc58829.js +155 -0
  60. package/dist/nylas-provider.entry-cb1ef04e.cjs +1 -0
  61. package/dist/nylas-scheduler-config.entry-2382ac1b.js +114 -0
  62. package/dist/nylas-scheduler-config.entry-477d2171.cjs +1 -0
  63. package/dist/nylas-scheduler-editor.entry-1a95d313.cjs +1 -0
  64. package/dist/nylas-scheduler-editor.entry-c0479087.js +140 -0
  65. package/dist/nylas-scheduler.entry-69ecc3ae.cjs +1 -0
  66. package/dist/nylas-scheduler.entry-7084c148.js +231 -0
  67. package/dist/nylas-threads-refresh.entry-b35f1b68.cjs +1 -0
  68. package/dist/{nylas-threads-refresh.entry-9111a403.js → nylas-threads-refresh.entry-ef5d6dfd.js} +13 -12
  69. package/dist/nylas-threads-search.entry-2dda7524.cjs +1 -0
  70. package/dist/{nylas-threads-search.entry-2124f663.js → nylas-threads-search.entry-e570bf8e.js} +6 -5
  71. package/dist/nylas-view-thread.entry-1ee0680f.cjs +1 -0
  72. package/dist/{nylas-view-thread.entry-fe51c1f6.js → nylas-view-thread.entry-3939c913.js} +5 -4
  73. package/dist/people-icon.entry-4a88822e.cjs +1 -0
  74. package/dist/people-icon.entry-69465395.js +15 -0
  75. package/dist/play-icon_2.entry-bc24fda7.js +25 -0
  76. package/dist/play-icon_2.entry-bd9f650e.cjs +1 -0
  77. package/dist/react.cjs +1 -1
  78. package/dist/react.js +77 -57
  79. package/dist/{refresh-icon.entry-9f24e833.cjs → refresh-icon.entry-678f92e7.cjs} +1 -1
  80. package/dist/{refresh-icon.entry-4ddd53b0.js → refresh-icon.entry-bd2bf7ce.js} +2 -2
  81. package/dist/{register-component-55376f31-5eaf8954.js → register-component-486ea571-1f151779.js} +2 -2
  82. package/dist/{register-component-55376f31-8d6ddee4.cjs → register-component-486ea571-cdfe1ef9.cjs} +1 -1
  83. package/dist/scheduler-config-store-a059f30b-06c1aa21.cjs +1 -0
  84. package/dist/scheduler-config-store-a059f30b-ff3efc00.js +33 -0
  85. package/dist/scheduler-store-81058220-263a5f44.js +297 -0
  86. package/dist/scheduler-store-81058220-a20698af.cjs +1 -0
  87. package/dist/{translate-icon.entry-0cd24de4.cjs → translate-icon.entry-0c0dbba6.cjs} +1 -1
  88. package/dist/{translate-icon.entry-db2cdf1d.js → translate-icon.entry-c1fcd2f8.js} +4 -4
  89. package/dist/utils-df5c1963-1c47e21c.cjs +8 -0
  90. package/dist/utils-df5c1963-d9833bcb.js +2114 -0
  91. package/dist/warning-icon.entry-9631cd2e.js +15 -0
  92. package/dist/warning-icon.entry-dbd44cdb.cjs +1 -0
  93. package/package.json +6 -3
  94. package/dist/arrow-icon.entry-2867f4fb.js +0 -15
  95. package/dist/calendar-check-icon_3.entry-42bab0b4.js +0 -35
  96. package/dist/calendar-check-icon_3.entry-f5846fee.cjs +0 -1
  97. package/dist/chevron-icon.entry-60842fb6.js +0 -15
  98. package/dist/close-icon_2.entry-aa015993.cjs +0 -1
  99. package/dist/close-icon_2.entry-ef03bd27.js +0 -25
  100. package/dist/document-refresh-icon.entry-b27207eb.js +0 -15
  101. package/dist/document-refresh-icon.entry-ca2ef29e.cjs +0 -1
  102. package/dist/globe-icon.entry-796d3f48.js +0 -15
  103. package/dist/globe-icon.entry-918cfd35.cjs +0 -1
  104. package/dist/index-29d0e781.cjs +0 -30
  105. package/dist/index-4f65b6f9.js +0 -1489
  106. package/dist/loading-icon.entry-8e49fab0.js +0 -15
  107. package/dist/loading-icon.entry-b2534e3e.cjs +0 -1
  108. package/dist/mailbox-store-0019772c-d1254c5c.cjs +0 -1
  109. package/dist/nylas-if-state_3.entry-e8c831b7.cjs +0 -1
  110. package/dist/nylas-list-folders.entry-de8cca60.cjs +0 -1
  111. package/dist/nylas-list-threads.entry-93b70a1a.cjs +0 -1
  112. package/dist/nylas-mailbox-pagination.entry-6bb0ee37.cjs +0 -1
  113. package/dist/nylas-mailbox-toolbar-button.entry-d4ad5c15.cjs +0 -1
  114. package/dist/nylas-open-hours-picker.entry-2c19643f.cjs +0 -1
  115. package/dist/nylas-provider.entry-2cfe5f0e.js +0 -134
  116. package/dist/nylas-provider.entry-87fa9276.cjs +0 -1
  117. package/dist/nylas-scheduler.entry-6ec8e574.js +0 -195
  118. package/dist/nylas-scheduler.entry-b41cbf99.cjs +0 -1
  119. package/dist/nylas-threads-refresh.entry-6d61a689.cjs +0 -1
  120. package/dist/nylas-threads-search.entry-03073490.cjs +0 -1
  121. package/dist/nylas-view-thread.entry-4ecbcd78.cjs +0 -1
  122. package/dist/play-icon_2.entry-8e156535.js +0 -25
  123. package/dist/play-icon_2.entry-cf1cbc8d.cjs +0 -1
  124. package/dist/property-0065dde7-83dc9cc4.cjs +0 -23
  125. package/dist/property-0065dde7-c57b8fa3.js +0 -589
  126. package/dist/scheduler-store-5a39585a-117668e3.js +0 -173
  127. package/dist/scheduler-store-5a39585a-2c848bec.cjs +0 -1
  128. package/dist/utils-5074a070-ce33ee6b.js +0 -119
  129. package/dist/utils-5074a070-d5ba6add.cjs +0 -2
@@ -1,173 +0,0 @@
1
- import { d as v } from "./utils-5074a070-ce33ee6b.js";
2
- import { c as T } from "./index-2b85580a-f9211f23.js";
3
- class w {
4
- constructor({ schedulerAPIURL: t, schedulerStore: e, sessionId: s }) {
5
- this.schedulerStore = e, this.schedulerAPIURL = t, this.sessionId = s;
6
- }
7
- async makeAPIRequest(t, e, s, r = {}) {
8
- try {
9
- const i = new URL(this.schedulerAPIURL);
10
- i.pathname = t;
11
- const n = await fetch(decodeURIComponent(i.toString()), {
12
- method: e,
13
- headers: {
14
- "Content-Type": "application/json",
15
- ...r
16
- },
17
- body: s
18
- });
19
- return n.status === 204 ? { data: null } : await n.json();
20
- } catch (i) {
21
- return { error: i };
22
- }
23
- }
24
- selectDate(t) {
25
- this.schedulerStore.set("selectedDate", t), this.schedulerStore.set("selectedTimeslot", null);
26
- }
27
- selectTime(t) {
28
- this.schedulerStore.set("selectedTimeslot", t);
29
- }
30
- selectTimezone(t) {
31
- this.schedulerStore.set("selectedTimezone", t);
32
- }
33
- toggleAdditionalData(t) {
34
- this.schedulerStore.set("showBookingForm", t);
35
- }
36
- setParticipantName(t) {
37
- const { bookingInfo: e } = this.schedulerStore.state;
38
- this.schedulerStore.set("bookingInfo", {
39
- ...e,
40
- primaryParticipant: {
41
- ...e == null ? void 0 : e.primaryParticipant,
42
- name: t
43
- }
44
- });
45
- }
46
- setParticipantEmail(t) {
47
- const { bookingInfo: e } = this.schedulerStore.state;
48
- this.schedulerStore.set("bookingInfo", {
49
- ...e,
50
- primaryParticipant: {
51
- ...e == null ? void 0 : e.primaryParticipant,
52
- email: t
53
- }
54
- });
55
- }
56
- async setReschedule(t) {
57
- const e = /* @__PURE__ */ new Date();
58
- this.schedulerStore.set("rescheduleId", t), this.schedulerStore.set("selectedTimeslot", null), this.schedulerStore.set("showThankYouMessage", !1), this.schedulerStore.set("showBookingForm", !1);
59
- const s = new Date(e.getFullYear(), e.getMonth(), 1).getTime() / 1e3, r = new Date(e.getFullYear(), e.getMonth() + 1, 1).getTime() / 1e3;
60
- await this.getAvailability(s, r);
61
- const i = this.schedulerStore.get("availability").find((c) => new Date(c.start_time) > /* @__PURE__ */ new Date());
62
- let n = e;
63
- i && (n = i.start_time), this.schedulerStore.set("selectedDate", n);
64
- }
65
- async bookTimeslot(t) {
66
- this.schedulerStore.set("bookedEventLoading", !0), this.schedulerStore.set("bookedEventError", null);
67
- const { selectedTimeslot: e, bookingInfo: s } = this.schedulerStore.state;
68
- if (!t && !s)
69
- return { error: { message: "No booking info provided" } };
70
- const r = (t == null ? void 0 : t.timeslot) || e;
71
- if (!r)
72
- return { error: { message: "No time slot selected" } };
73
- const i = t ? t == null ? void 0 : t.primaryParticipant : s == null ? void 0 : s.primaryParticipant, n = t ? (t == null ? void 0 : t.guests) || [] : (s == null ? void 0 : s.guests) || [], c = t ? { ...t == null ? void 0 : t.additionalFields } : { ...s == null ? void 0 : s.additionalFields }, u = {
74
- Authorization: `Bearer ${this.sessionId}`
75
- }, a = "/schedule/bookings", o = await this.makeAPIRequest(decodeURIComponent(a), "POST", JSON.stringify({
76
- participants: [i, ...n],
77
- additional_fields: c,
78
- start_time: r.start_time.getTime() / 1e3,
79
- end_time: r.end_time.getTime() / 1e3
80
- }), u);
81
- return "error" in o && this.schedulerStore.set("bookedEventError", o == null ? void 0 : o.error), "data" in o && this.schedulerStore.set("eventInfo", o == null ? void 0 : o.data), this.schedulerStore.set("bookedEventLoading", !1), o;
82
- }
83
- async getAvailability(t = 0, e = 0) {
84
- var o, m;
85
- this.schedulerStore.set("loadingState", { api: "availability" });
86
- const s = new URLSearchParams(), i = (/* @__PURE__ */ new Date()).getTime();
87
- if (e && e < i / 1e3) {
88
- const h = { title: "Availability error", message: "endTime should be in the future", category: "vaidation" };
89
- return this.schedulerStore.set("availabilityTimeslotsError", h), { error: h };
90
- }
91
- t && s.append("start_time", encodeURIComponent(t)), e && s.append("end_time", encodeURIComponent(e));
92
- const n = s.toString(), c = `/schedule/availability${n ? `?${n}` : ""}`, u = {
93
- Authorization: `Bearer ${this.sessionId}`
94
- }, a = await this.makeAPIRequest(decodeURIComponent(c), "GET", void 0, u);
95
- if ("error" in a && this.schedulerStore.set("availability", []), "data" in a) {
96
- const S = (((m = (o = a.data) == null ? void 0 : o.time_slots) == null ? void 0 : m.map((d) => ({
97
- ...d,
98
- start_time: new Date(d.start_time * 1e3),
99
- end_time: new Date(d.end_time * 1e3)
100
- }))) || []).filter((d) => d.start_time.getTime() > i);
101
- this.schedulerStore.set("availability", S);
102
- }
103
- return this.schedulerStore.set("loadingState", null), a;
104
- }
105
- async cancelBooking(t) {
106
- this.schedulerStore.set("bookedEventLoading", !0), this.schedulerStore.set("bookedEventError", null);
107
- const e = `/schedule/bookings/${t}`, s = {
108
- Authorization: `Bearer ${this.sessionId}`
109
- }, r = await this.makeAPIRequest(decodeURIComponent(e), "PUT", JSON.stringify({
110
- action: "cancel"
111
- }), s);
112
- return "error" in r && this.schedulerStore.set("bookedEventError", r == null ? void 0 : r.error), "data" in r && this.schedulerStore.set("cancelledEvent", r == null ? void 0 : r.data), this.schedulerStore.set("bookedEventLoading", !1), r;
113
- }
114
- async rescheduleBooking(t, e) {
115
- this.schedulerStore.set("bookedEventLoading", !0), this.schedulerStore.set("bookedEventError", null);
116
- const { bookingInfo: s, selectedTimeslot: r, selectedTimezone: i } = this.schedulerStore.state, { startTime: n, endTime: c, timezone: u } = e, a = n || (r == null ? void 0 : r.start_time), o = { error: { title: "Reschedule error", message: "", type: "validation" } };
117
- if (!a)
118
- return { error: { ...o, message: "Please pass 'startTime' in data or set 'selectedTimeslot in the defaultSchedulerStoreState." } };
119
- const m = c || (r == null ? void 0 : r.end_time);
120
- if (!m)
121
- return { error: { ...o, message: "Please pass 'endTime' in data or set 'selectedTimeslot' in the defaultSchedulerStoreState." } };
122
- const h = u || i;
123
- if (!h)
124
- return { error: { ...o, message: "Please pass 'timezone' in data or set 'selectedTimezone' in the defaultSchedulerStoreState." } };
125
- const S = e ? e == null ? void 0 : e.primaryParticipant : s == null ? void 0 : s.primaryParticipant, d = e ? (e == null ? void 0 : e.guests) || [] : (s == null ? void 0 : s.guests) || [], p = e ? { ...e == null ? void 0 : e.additionalFields } : { ...s == null ? void 0 : s.additionalFields }, y = `/schedule/bookings/${t}`, f = {
126
- Authorization: `Bearer ${this.sessionId}`
127
- }, l = await this.makeAPIRequest(decodeURIComponent(y), "PATCH", JSON.stringify({
128
- start_time: a.getTime() / 1e3,
129
- end_time: m.getTime() / 1e3,
130
- time_zone: h,
131
- participants: [S, ...d],
132
- additional_fields: p
133
- }), f);
134
- return "error" in l && this.schedulerStore.set("bookedEventError", { error: { ...l == null ? void 0 : l.error, category: "api" } }), "data" in l && this.schedulerStore.set("eventInfo", l == null ? void 0 : l.data), this.schedulerStore.set("bookedEventLoading", !1), l;
135
- }
136
- }
137
- function P(g = {}) {
138
- const t = {
139
- selectedDate: null,
140
- selectedLanguage: navigator.language,
141
- selectedTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
142
- selectedTimeslot: null,
143
- showBookingForm: !1,
144
- showThankYouMessage: !1,
145
- selectableDates: null,
146
- availability: [],
147
- availabilityTimeslotsError: null,
148
- state: "ready",
149
- eventInfo: null,
150
- cancelledEvent: null,
151
- bookedEventError: null,
152
- bookedEventLoading: !1,
153
- loadingState: null,
154
- ...g
155
- };
156
- v("[defaultNylasStoreState]: ", t);
157
- const e = T(t);
158
- return e.onChange("availability", (s) => {
159
- const r = s.map((i) => i.start_time);
160
- e.set("selectableDates", r);
161
- }), e.onChange("rescheduleId", (s) => {
162
- s ? e.set("bookingFlow", "rescheduling") : e.set("bookingFlow", "booking");
163
- }), e.reset = () => {
164
- for (const s in t) {
165
- const r = t[s];
166
- e.set(s, r);
167
- }
168
- }, e;
169
- }
170
- export {
171
- P as C,
172
- w as N
173
- };
@@ -1 +0,0 @@
1
- "use strict";const f=require("./utils-5074a070-d5ba6add.cjs"),b=require("./index-2b85580a-bfc3ceac.cjs");class T{constructor({schedulerAPIURL:t,schedulerStore:e,sessionId:s}){this.schedulerStore=e,this.schedulerAPIURL=t,this.sessionId=s}async makeAPIRequest(t,e,s,r={}){try{const i=new URL(this.schedulerAPIURL);i.pathname=t;const n=await fetch(decodeURIComponent(i.toString()),{method:e,headers:{"Content-Type":"application/json",...r},body:s});return n.status===204?{data:null}:await n.json()}catch(i){return{error:i}}}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)}toggleAdditionalData(t){this.schedulerStore.set("showBookingForm",t)}setParticipantName(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e==null?void 0:e.primaryParticipant,name:t}})}setParticipantEmail(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e==null?void 0:e.primaryParticipant,email:t}})}async setReschedule(t){const e=new Date;this.schedulerStore.set("rescheduleId",t),this.schedulerStore.set("selectedTimeslot",null),this.schedulerStore.set("showThankYouMessage",!1),this.schedulerStore.set("showBookingForm",!1);const s=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3,r=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;await this.getAvailability(s,r);const i=this.schedulerStore.get("availability").find(c=>new Date(c.start_time)>new Date);let n=e;i&&(n=i.start_time),this.schedulerStore.set("selectedDate",n)}async bookTimeslot(t){this.schedulerStore.set("bookedEventLoading",!0),this.schedulerStore.set("bookedEventError",null);const{selectedTimeslot:e,bookingInfo:s}=this.schedulerStore.state;if(!t&&!s)return{error:{message:"No booking info provided"}};const r=(t==null?void 0:t.timeslot)||e;if(!r)return{error:{message:"No time slot selected"}};const i=t?t==null?void 0:t.primaryParticipant:s==null?void 0:s.primaryParticipant,n=t?(t==null?void 0:t.guests)||[]:(s==null?void 0:s.guests)||[],c=t?{...t==null?void 0:t.additionalFields}:{...s==null?void 0:s.additionalFields},u={Authorization:`Bearer ${this.sessionId}`},a="/schedule/bookings",o=await this.makeAPIRequest(decodeURIComponent(a),"POST",JSON.stringify({participants:[i,...n],additional_fields:c,start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3}),u);return"error"in o&&this.schedulerStore.set("bookedEventError",o==null?void 0:o.error),"data"in o&&this.schedulerStore.set("eventInfo",o==null?void 0:o.data),this.schedulerStore.set("bookedEventLoading",!1),o}async getAvailability(t=0,e=0){var o,m;this.schedulerStore.set("loadingState",{api:"availability"});const s=new URLSearchParams,i=new Date().getTime();if(e&&e<i/1e3){const h={title:"Availability error",message:"endTime should be in the future",category:"vaidation"};return this.schedulerStore.set("availabilityTimeslotsError",h),{error:h}}t&&s.append("start_time",encodeURIComponent(t)),e&&s.append("end_time",encodeURIComponent(e));const n=s.toString(),c=`/schedule/availability${n?`?${n}`:""}`,u={Authorization:`Bearer ${this.sessionId}`},a=await this.makeAPIRequest(decodeURIComponent(c),"GET",void 0,u);if("error"in a&&this.schedulerStore.set("availability",[]),"data"in a){const S=(((m=(o=a.data)==null?void 0:o.time_slots)==null?void 0:m.map(d=>({...d,start_time:new Date(d.start_time*1e3),end_time:new Date(d.end_time*1e3)})))||[]).filter(d=>d.start_time.getTime()>i);this.schedulerStore.set("availability",S)}return this.schedulerStore.set("loadingState",null),a}async cancelBooking(t){this.schedulerStore.set("bookedEventLoading",!0),this.schedulerStore.set("bookedEventError",null);const e=`/schedule/bookings/${t}`,s={Authorization:`Bearer ${this.sessionId}`},r=await this.makeAPIRequest(decodeURIComponent(e),"PUT",JSON.stringify({action:"cancel"}),s);return"error"in r&&this.schedulerStore.set("bookedEventError",r==null?void 0:r.error),"data"in r&&this.schedulerStore.set("cancelledEvent",r==null?void 0:r.data),this.schedulerStore.set("bookedEventLoading",!1),r}async rescheduleBooking(t,e){this.schedulerStore.set("bookedEventLoading",!0),this.schedulerStore.set("bookedEventError",null);const{bookingInfo:s,selectedTimeslot:r,selectedTimezone:i}=this.schedulerStore.state,{startTime:n,endTime:c,timezone:u}=e,a=n||(r==null?void 0:r.start_time),o={error:{title:"Reschedule error",message:"",type:"validation"}};if(!a)return{error:{...o,message:"Please pass 'startTime' in data or set 'selectedTimeslot in the defaultSchedulerStoreState."}};const m=c||(r==null?void 0:r.end_time);if(!m)return{error:{...o,message:"Please pass 'endTime' in data or set 'selectedTimeslot' in the defaultSchedulerStoreState."}};const h=u||i;if(!h)return{error:{...o,message:"Please pass 'timezone' in data or set 'selectedTimezone' in the defaultSchedulerStoreState."}};const S=e?e==null?void 0:e.primaryParticipant:s==null?void 0:s.primaryParticipant,d=e?(e==null?void 0:e.guests)||[]:(s==null?void 0:s.guests)||[],y=e?{...e==null?void 0:e.additionalFields}:{...s==null?void 0:s.additionalFields},p=`/schedule/bookings/${t}`,v={Authorization:`Bearer ${this.sessionId}`},l=await this.makeAPIRequest(decodeURIComponent(p),"PATCH",JSON.stringify({start_time:a.getTime()/1e3,end_time:m.getTime()/1e3,time_zone:h,participants:[S,...d],additional_fields:y}),v);return"error"in l&&this.schedulerStore.set("bookedEventError",{error:{...l==null?void 0:l.error,category:"api"}}),"data"in l&&this.schedulerStore.set("eventInfo",l==null?void 0:l.data),this.schedulerStore.set("bookedEventLoading",!1),l}}function E(g={}){const t={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:!1,showThankYouMessage:!1,selectableDates:null,availability:[],availabilityTimeslotsError:null,state:"ready",eventInfo:null,cancelledEvent:null,bookedEventError:null,bookedEventLoading:!1,loadingState:null,...g};f.debug("[defaultNylasStoreState]: ",t);const e=b.createStore(t);return e.onChange("availability",s=>{const r=s.map(i=>i.start_time);e.set("selectableDates",r)}),e.onChange("rescheduleId",s=>{s?e.set("bookingFlow","rescheduling"):e.set("bookingFlow","booking")}),e.reset=()=>{for(const s in t){const r=t[s];e.set(s,r)}},e}exports.CreateNylasSchedulerStore=E;exports.NylaSchedulerAPIConnector=T;
@@ -1,119 +0,0 @@
1
- function f(...t) {
2
- window && window.localStorage && window.localStorage.getItem("debug") && console.debug(...t);
3
- }
4
- function g(...t) {
5
- console.error(...t);
6
- }
7
- function h() {
8
- return Math.random().toString(36).substr(2, 9);
9
- }
10
- function p(t) {
11
- return t.toString().replace(/^on/, "");
12
- }
13
- function d(t) {
14
- const e = new Date(t * 1e3), a = /* @__PURE__ */ new Date(), n = new Date(a.getFullYear(), a.getMonth(), a.getDate());
15
- return e >= n ? new Intl.DateTimeFormat("default", {
16
- hour: "numeric",
17
- minute: "numeric",
18
- hour12: !0
19
- }).format(e) : new Intl.DateTimeFormat("default", {
20
- month: "short",
21
- day: "numeric"
22
- }).format(e);
23
- }
24
- function w(t) {
25
- return t.name ? `${t.name} - ${t.email}` : t.email;
26
- }
27
- function T(t, e = "", a = 1, n = 3) {
28
- const r = t.find((i) => {
29
- var m;
30
- return ((m = i.email) == null ? void 0 : m.toLowerCase()) === e.toLowerCase();
31
- }), o = t.filter((i) => {
32
- var m;
33
- return ((m = i.email) == null ? void 0 : m.toLowerCase()) !== e.toLowerCase();
34
- }), s = o.length, u = o.slice(0, n).map((i) => i.name || i.email).join(", ");
35
- return s === 0 ? r ? "me" : "" : s === 1 ? r && a > 1 ? `me, ${u}` : u : s === 2 ? r ? `me, ${u}` : `${u}` : r ? `me, ${u}, +${s - n}` : `${u}, +${s - n}`;
36
- }
37
- const l = [
38
- { amount: 60, name: "seconds" },
39
- { amount: 60, name: "minutes" },
40
- { amount: 24, name: "hours" },
41
- { amount: 7, name: "days" },
42
- { amount: 4.34524, name: "weeks" },
43
- { amount: 12, name: "months" },
44
- { amount: Number.POSITIVE_INFINITY, name: "years" }
45
- ], D = (t) => {
46
- const e = new Intl.RelativeTimeFormat(void 0, {
47
- numeric: "auto"
48
- }), a = /* @__PURE__ */ new Date();
49
- let n = (t.getTime() - a.getTime()) / 1e3;
50
- for (let r = 0; r <= l.length; r++) {
51
- const o = l[r];
52
- if (Math.abs(n) < o.amount)
53
- return e.format(Math.round(n), o.name);
54
- n /= o.amount;
55
- }
56
- };
57
- function M(t) {
58
- return new Date(t.getFullYear(), t.getMonth() + 1, 0);
59
- }
60
- function I(t) {
61
- return new Date(t.getFullYear(), t.getMonth(), 1);
62
- }
63
- function S(t, e) {
64
- return t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth() && t.getDate() === e.getDate();
65
- }
66
- function F(t, e) {
67
- return t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth();
68
- }
69
- function $(t) {
70
- return t.replace(/\w\S*/g, (e) => e.charAt(0).toUpperCase() + e.substr(1).toLowerCase());
71
- }
72
- function y(t) {
73
- return t.replace("CATEGORY_", "").replace(/_/g, " ");
74
- }
75
- function c(t) {
76
- return /<[^>]*>/g.test(t) ? "html" : "plain";
77
- }
78
- function b(t) {
79
- var r, o;
80
- const e = t.headers, a = e && ((r = e.find((s) => s.name === "Content-Type")) == null ? void 0 : r.value) || "", n = e && ((o = e.find((s) => s.name === "Content-Disposition")) == null ? void 0 : o.value) || "";
81
- return !!(a.includes("text/html") || n.includes("inline") || t.body && c(t.body) === "html");
82
- }
83
- function C(t) {
84
- let n = t.split(`
85
- `).filter((o) => o.trim().length > 0).map((o) => `<p>${o}</p>`).join("");
86
- const r = /((?:https?|ftp):\/\/[^\s]+)/g;
87
- return n = n.replace(r, '<a href="$1">$1</a>'), n;
88
- }
89
- function L(t) {
90
- return new DOMParser().parseFromString(t, "text/html").body.textContent || "";
91
- }
92
- function Y(t) {
93
- return `${t.getHours().toString().padStart(2, "0")}:${t.getMinutes().toString().padStart(2, "0")}`;
94
- }
95
- function O() {
96
- return Intl.DateTimeFormat().resolvedOptions().timeZone;
97
- }
98
- export {
99
- T as a,
100
- d as b,
101
- O as c,
102
- f as d,
103
- p as e,
104
- y as f,
105
- Y as g,
106
- D as h,
107
- w as i,
108
- b as j,
109
- c as k,
110
- L as l,
111
- M as m,
112
- I as n,
113
- S as o,
114
- C as p,
115
- F as q,
116
- g as r,
117
- $ as t,
118
- h as u
119
- };
@@ -1,2 +0,0 @@
1
- "use strict";function f(...t){window&&window.localStorage&&window.localStorage.getItem("debug")&&console.debug(...t)}function g(...t){console.error(...t)}function h(){return Math.random().toString(36).substr(2,9)}function T(t){return t.toString().replace(/^on/,"")}function d(t){const e=new Date(t*1e3),a=new Date,n=new Date(a.getFullYear(),a.getMonth(),a.getDate());return e>=n?new Intl.DateTimeFormat("default",{hour:"numeric",minute:"numeric",hour12:!0}).format(e):new Intl.DateTimeFormat("default",{month:"short",day:"numeric"}).format(e)}function p(t){return t.name?`${t.name} - ${t.email}`:t.email}function w(t,e="",a=1,n=3){const r=t.find(s=>{var m;return((m=s.email)==null?void 0:m.toLowerCase())===e.toLowerCase()}),o=t.filter(s=>{var m;return((m=s.email)==null?void 0:m.toLowerCase())!==e.toLowerCase()}),i=o.length,u=o.slice(0,n).map(s=>s.name||s.email).join(", ");return i===0?r?"me":"":i===1?r&&a>1?`me, ${u}`:u:i===2?r?`me, ${u}`:`${u}`:r?`me, ${u}, +${i-n}`:`${u}, +${i-n}`}const l=[{amount:60,name:"seconds"},{amount:60,name:"minutes"},{amount:24,name:"hours"},{amount:7,name:"days"},{amount:4.34524,name:"weeks"},{amount:12,name:"months"},{amount:Number.POSITIVE_INFINITY,name:"years"}],D=t=>{const e=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}),a=new Date;let n=(t.getTime()-a.getTime())/1e3;for(let r=0;r<=l.length;r++){const o=l[r];if(Math.abs(n)<o.amount)return e.format(Math.round(n),o.name);n/=o.amount}};function M(t){return new Date(t.getFullYear(),t.getMonth()+1,0)}function I(t){return new Date(t.getFullYear(),t.getMonth(),1)}function S(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function F(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()}function y(t){return t.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function $(t){return t.replace("CATEGORY_","").replace(/_/g," ")}function c(t){return/<[^>]*>/g.test(t)?"html":"plain"}function C(t){var r,o;const e=t.headers,a=e&&((r=e.find(i=>i.name==="Content-Type"))==null?void 0:r.value)||"",n=e&&((o=e.find(i=>i.name==="Content-Disposition"))==null?void 0:o.value)||"";return!!(a.includes("text/html")||n.includes("inline")||t.body&&c(t.body)==="html")}function L(t){let n=t.split(`
2
- `).filter(o=>o.trim().length>0).map(o=>`<p>${o}</p>`).join("");const r=/((?:https?|ftp):\/\/[^\s]+)/g;return n=n.replace(r,'<a href="$1">$1</a>'),n}function b(t){return new DOMParser().parseFromString(t,"text/html").body.textContent||""}function P(t){return`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function O(){return Intl.DateTimeFormat().resolvedOptions().timeZone}exports.debug=f;exports.detectHTMLOrPlainText=c;exports.detectIfMessageIsHTML=C;exports.error=g;exports.formatDateTime=d;exports.formatEventName=T;exports.formatFolderName=$;exports.formatParticipants=w;exports.formatRecipient=p;exports.formatTimeAgo=D;exports.get24HourTime=P;exports.getFirstDayOfMonth=I;exports.getLastDayOfMonth=M;exports.getUserTimezone=O;exports.htmlToPlainText=b;exports.isSameDay=S;exports.isSameMonth=F;exports.parsePlainTextToHTML=L;exports.toTitleCase=y;exports.uniqueID=h;