@nylas/react 1.1.2 → 1.1.3

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 (127) hide show
  1. package/dist/{add-circle-icon_2.entry-f1383568.cjs → add-circle-icon_2.entry-b77120e5.cjs} +1 -1
  2. package/dist/{add-circle-icon_2.entry-611be49d.js → add-circle-icon_2.entry-fbc1e82b.js} +1 -1
  3. package/dist/{archive-icon_7.entry-5e6ba9e7.js → archive-icon_7.entry-30962e70.js} +13 -13
  4. package/dist/{archive-icon_7.entry-59cc6868.cjs → archive-icon_7.entry-dd8c7642.cjs} +1 -1
  5. package/dist/{arrow-icon.entry-a924df13.cjs → arrow-icon.entry-2dfd8319.cjs} +1 -1
  6. package/dist/{arrow-icon.entry-9c19a803.js → arrow-icon.entry-5b436054.js} +1 -1
  7. package/dist/{bold-icon_3.entry-2935a3df.js → bold-icon_3.entry-5120a9c8.js} +3 -3
  8. package/dist/{bold-icon_3.entry-ffe02f93.cjs → bold-icon_3.entry-da2d1270.cjs} +1 -1
  9. package/dist/{button-component_2.entry-b9d3f6a2.cjs → button-component_2.entry-27a504d9.cjs} +1 -1
  10. package/dist/{button-component_2.entry-93aa59a2.js → button-component_2.entry-697bf5ac.js} +7 -7
  11. package/dist/{calendar-agenda-fill-icon_48.entry-476bc4ef.js → calendar-agenda-fill-icon_51.entry-52b5bf31.js} +990 -910
  12. package/dist/calendar-agenda-fill-icon_51.entry-a25262b3.cjs +7 -0
  13. package/dist/{calendar-cancel-icon.entry-11bb8656.cjs → calendar-cancel-icon.entry-c6e2eed6.cjs} +1 -1
  14. package/dist/{calendar-cancel-icon.entry-ee0acc54.js → calendar-cancel-icon.entry-e6a433a2.js} +1 -1
  15. package/dist/{calendar-check-icon_2.entry-14548656.cjs → calendar-check-icon_2.entry-45cad6f1.cjs} +1 -1
  16. package/dist/{calendar-check-icon_2.entry-54a82e1e.js → calendar-check-icon_2.entry-d88307d6.js} +1 -1
  17. package/dist/{calendar-icon.entry-29f7003b.js → calendar-icon.entry-2badc962.js} +1 -1
  18. package/dist/{calendar-icon.entry-1a17f887.cjs → calendar-icon.entry-b2fffd21.cjs} +1 -1
  19. package/dist/{checkbox-component_2.entry-84a17232.cjs → checkbox-component_2.entry-3926b644.cjs} +1 -1
  20. package/dist/{checkbox-component_2.entry-dfec10cb.js → checkbox-component_2.entry-5ab55050.js} +3 -3
  21. package/dist/{chevron-icon_3.entry-5da08d02.cjs → chevron-icon_3.entry-1fe5d097.cjs} +1 -1
  22. package/dist/{chevron-icon_3.entry-826e81d4.js → chevron-icon_3.entry-664fae5d.js} +5 -5
  23. package/dist/{clock-icon_4.entry-dafdd895.cjs → clock-icon_4.entry-efec2c08.cjs} +1 -1
  24. package/dist/{clock-icon_4.entry-36d97f00.js → clock-icon_4.entry-f11f9dad.js} +13 -13
  25. package/dist/{constants-50c3e067-fed7fb48.js → constants-50c3e067-33cf0ffe.js} +1 -1
  26. package/dist/{constants-50c3e067-1fe54cf3.cjs → constants-50c3e067-5ec3f879.cjs} +1 -1
  27. package/dist/{copy-icon.entry-eec265da.cjs → copy-icon.entry-3965f206.cjs} +1 -1
  28. package/dist/{copy-icon.entry-6d1a649d.js → copy-icon.entry-70131e8e.js} +1 -1
  29. package/dist/{delete-icon_2.entry-160ba41e.cjs → delete-icon.entry-5d067fef.cjs} +1 -1
  30. package/dist/{delete-icon_2.entry-528a3879.js → delete-icon.entry-e003695d.js} +4 -14
  31. package/dist/{document-refresh-icon.entry-276704dc.cjs → document-refresh-icon.entry-30c974df.cjs} +1 -1
  32. package/dist/{document-refresh-icon.entry-6565f3b5.js → document-refresh-icon.entry-b4e01cd4.js} +1 -1
  33. package/dist/elements/index.d.ts +2 -0
  34. package/dist/{elements-dc5b338e-2d3857dc.js → elements-dc5b338e-55823d00.js} +1 -1
  35. package/dist/{elements-dc5b338e-b06b2857.cjs → elements-dc5b338e-6883a39e.cjs} +1 -1
  36. package/dist/feedbackSync-81d4c4d8-dd4d2e32.js +11735 -0
  37. package/dist/feedbackSync-81d4c4d8-f4e78902.cjs +455 -0
  38. package/dist/{focus-visible-e8093c16-47e61336.cjs → focus-visible-e8093c16-431bbe59.cjs} +1 -1
  39. package/dist/{focus-visible-e8093c16-6f68eb89.js → focus-visible-e8093c16-f403fee8.js} +1 -1
  40. package/dist/{forward-icon_6.entry-ed6ab66a.js → forward-icon_6.entry-3bb91d58.js} +7 -7
  41. package/dist/{forward-icon_6.entry-fed8994d.cjs → forward-icon_6.entry-ceec2371.cjs} +3 -3
  42. package/dist/{globe-icon.entry-154ccdb5.js → globe-icon.entry-6fc456c7.js} +5 -5
  43. package/dist/{globe-icon.entry-95fc0408.cjs → globe-icon.entry-8c3c9e48.cjs} +1 -1
  44. package/dist/google-logo-icon_4.entry-4eb16cd2.cjs +1 -0
  45. package/dist/{google-logo-icon_4.entry-68cfa3fe.js → google-logo-icon_4.entry-d6e0c4c0.js} +331 -289
  46. package/dist/index-11f33e47.cjs +82 -0
  47. package/dist/{index-1322d804.js → index-a282e817.js} +2890 -2792
  48. package/dist/{index.es-79f5b771-08cc349d.cjs → index.es-ab9affcc-18263b66.cjs} +1 -1
  49. package/dist/{index.es-79f5b771-04cd3414.js → index.es-ab9affcc-30461b18.js} +1 -1
  50. package/dist/{info-icon_2.entry-49261a0a.js → info-icon_2.entry-d20b975c.js} +5 -5
  51. package/dist/{info-icon_2.entry-2af880b8.cjs → info-icon_2.entry-e582ac10.cjs} +1 -1
  52. package/dist/{input-color-picker.entry-aefe0e26.js → input-color-picker.entry-27f4288f.js} +3 -3
  53. package/dist/{input-color-picker.entry-57adff77.cjs → input-color-picker.entry-c6a28671.cjs} +1 -1
  54. package/dist/{input-component.entry-09c3c9b6.cjs → input-component.entry-744fcec1.cjs} +1 -1
  55. package/dist/{input-component.entry-d7c2724b.js → input-component.entry-b6f1c417.js} +2 -2
  56. package/dist/{input-dropdown.entry-e573ade0.js → input-dropdown.entry-18744def.js} +2 -2
  57. package/dist/{input-dropdown.entry-e7d26273.cjs → input-dropdown.entry-f13234d7.cjs} +1 -1
  58. package/dist/{mailbox-store-9c52a3fa-6b39645f.cjs → mailbox-store-affca6de-9451094e.cjs} +1 -1
  59. package/dist/{mailbox-store-9c52a3fa-27f8f7e6.js → mailbox-store-affca6de-d601dc6b.js} +2 -2
  60. package/dist/{multi-select-dropdown.entry-15cacb87.js → multi-select-dropdown.entry-924809e1.js} +5 -5
  61. package/dist/{multi-select-dropdown.entry-46b2b1c9.cjs → multi-select-dropdown.entry-dde671d7.cjs} +1 -1
  62. package/dist/{nylas-booked-event-card_12.entry-3921071a.js → nylas-booked-event-card_12.entry-52c3111d.js} +62 -60
  63. package/dist/nylas-booked-event-card_12.entry-d89c1f9d.cjs +1 -0
  64. package/dist/{nylas-form-card.entry-db3f0e3b.cjs → nylas-form-card.entry-ab61fdc5.cjs} +1 -1
  65. package/dist/{nylas-form-card.entry-ca835017.js → nylas-form-card.entry-b0a2403f.js} +8 -8
  66. package/dist/{nylas-if-state.entry-4159d41d.js → nylas-if-state.entry-523fdc6b.js} +2 -2
  67. package/dist/{nylas-if-state.entry-5410607c.cjs → nylas-if-state.entry-53883c36.cjs} +1 -1
  68. package/dist/{nylas-list-folders.entry-0f143930.cjs → nylas-list-folders.entry-4ef6cb3d.cjs} +1 -1
  69. package/dist/{nylas-list-folders.entry-6b4a3d96.js → nylas-list-folders.entry-e37d069f.js} +8 -8
  70. package/dist/{nylas-list-threads.entry-68b6f32b.cjs → nylas-list-threads.entry-3be623e9.cjs} +1 -1
  71. package/dist/{nylas-list-threads.entry-62108562.js → nylas-list-threads.entry-8ba62db8.js} +3 -3
  72. package/dist/{nylas-login.entry-f1d7bc7d.cjs → nylas-login.entry-05e1df3e.cjs} +1 -1
  73. package/dist/{nylas-login.entry-590e7fba.js → nylas-login.entry-d9bf3974.js} +5 -5
  74. package/dist/{nylas-mailbox-pagination.entry-8377fdee.cjs → nylas-mailbox-pagination.entry-3dd05cf4.cjs} +1 -1
  75. package/dist/{nylas-mailbox-pagination.entry-ba1af8fb.js → nylas-mailbox-pagination.entry-50d9d9e3.js} +2 -2
  76. package/dist/{nylas-mailbox-toolbar-button.entry-4497acd0.js → nylas-mailbox-toolbar-button.entry-9a77d137.js} +2 -2
  77. package/dist/{nylas-mailbox-toolbar-button.entry-6a5d8387.cjs → nylas-mailbox-toolbar-button.entry-d87b55de.cjs} +1 -1
  78. package/dist/{nylas-mailbox.entry-917c22f5.js → nylas-mailbox.entry-cb7d1031.js} +3 -3
  79. package/dist/{nylas-mailbox.entry-a07652b4.cjs → nylas-mailbox.entry-f7db9aa8.cjs} +1 -1
  80. package/dist/{nylas-provider.entry-0e520ac3.cjs → nylas-provider.entry-1716bf48.cjs} +1 -1
  81. package/dist/{nylas-provider.entry-20c47b14.js → nylas-provider.entry-7aa46ea2.js} +37 -37
  82. package/dist/{nylas-reminder-emails.entry-69626e7f.cjs → nylas-reminder-emails.entry-88a862cd.cjs} +2 -2
  83. package/dist/{nylas-reminder-emails.entry-088ee120.js → nylas-reminder-emails.entry-a86231b7.js} +5 -5
  84. package/dist/{nylas-reminder-time_2.entry-0357f280.js → nylas-reminder-time_2.entry-9589d5f2.js} +4 -4
  85. package/dist/{nylas-reminder-time_2.entry-b5c181db.cjs → nylas-reminder-time_2.entry-bc76d4ab.cjs} +1 -1
  86. package/dist/{nylas-scheduler-editor.entry-d2c3bddc.cjs → nylas-scheduler-editor.entry-1a2f3ee0.cjs} +2 -2
  87. package/dist/{nylas-scheduler-editor.entry-6bb290ed.js → nylas-scheduler-editor.entry-b434b526.js} +7 -7
  88. package/dist/nylas-scheduling.entry-59e5e8c1.cjs +1 -0
  89. package/dist/nylas-scheduling.entry-b71080c8.js +400 -0
  90. package/dist/{nylas-threads-refresh.entry-45d7d171.js → nylas-threads-refresh.entry-544ca90a.js} +2 -2
  91. package/dist/{nylas-threads-refresh.entry-6636e7b1.cjs → nylas-threads-refresh.entry-7ada7b2d.cjs} +1 -1
  92. package/dist/{nylas-threads-search.entry-4460aa9b.js → nylas-threads-search.entry-181ba46a.js} +17 -17
  93. package/dist/{nylas-threads-search.entry-ae87695a.cjs → nylas-threads-search.entry-f1cb19e4.cjs} +1 -1
  94. package/dist/{nylas-time-window-picker.entry-1b449403.cjs → nylas-time-window-picker.entry-a6d1c648.cjs} +1 -1
  95. package/dist/{nylas-time-window-picker.entry-260f52a6.js → nylas-time-window-picker.entry-c1ee860a.js} +2 -2
  96. package/dist/{nylas-view-thread.entry-5a9b353a.cjs → nylas-view-thread.entry-6ae8dd64.cjs} +1 -1
  97. package/dist/{nylas-view-thread.entry-5821630b.js → nylas-view-thread.entry-c066f522.js} +6 -6
  98. package/dist/{person-icon.entry-b4ce06b7.cjs → person-icon.entry-80c9022e.cjs} +1 -1
  99. package/dist/{person-icon.entry-ed6786db.js → person-icon.entry-8833e3cc.js} +4 -4
  100. package/dist/{play-icon_2.entry-87fe39a9.cjs → play-icon_2.entry-801c85bc.cjs} +1 -1
  101. package/dist/{play-icon_2.entry-261ea828.js → play-icon_2.entry-efca8f00.js} +3 -3
  102. package/dist/react.cjs +1 -1
  103. package/dist/react.js +118 -116
  104. package/dist/{refresh-icon.entry-87af05b0.js → refresh-icon.entry-4d6791bd.js} +4 -4
  105. package/dist/{refresh-icon.entry-21ac359d.cjs → refresh-icon.entry-d4cc16b7.cjs} +1 -1
  106. package/dist/{register-component-ea95564d-a64ee107.cjs → register-component-a7ea27ad-2343f3df.cjs} +1 -1
  107. package/dist/{register-component-ea95564d-843da1da.js → register-component-a7ea27ad-fa2c4b17.js} +1 -1
  108. package/dist/{scheduler-config-store-2a3b403d-88840eb1.cjs → scheduler-config-store-2a3b403d-2263f999.cjs} +1 -1
  109. package/dist/{scheduler-config-store-2a3b403d-8553b685.js → scheduler-config-store-2a3b403d-5176cd45.js} +1 -1
  110. package/dist/{scheduler-store-9ff4914b-d1a624f8.js → scheduler-store-33ab8dea-9801357a.js} +2 -2
  111. package/dist/scheduler-store-33ab8dea-a0b39d36.cjs +1 -0
  112. package/dist/{textarea-component.entry-cbffb0b0.cjs → textarea-component.entry-019e75d0.cjs} +1 -1
  113. package/dist/{textarea-component.entry-dad42f20.js → textarea-component.entry-174089bc.js} +2 -2
  114. package/dist/{time-period-selector.entry-79c94da3.js → time-period-selector.entry-62c854d1.js} +4 -4
  115. package/dist/{time-period-selector.entry-e54d0989.cjs → time-period-selector.entry-8466d0f2.cjs} +1 -1
  116. package/dist/{translate-icon.entry-ef6266c4.js → translate-icon.entry-73f7127b.js} +4 -4
  117. package/dist/{translate-icon.entry-8e9eeeba.cjs → translate-icon.entry-7d5cf4b8.cjs} +1 -1
  118. package/dist/{warning-icon.entry-34c85de2.cjs → warning-icon.entry-92638eeb.cjs} +1 -1
  119. package/dist/{warning-icon.entry-adf18211.js → warning-icon.entry-abf896c3.js} +5 -5
  120. package/package.json +2 -2
  121. package/dist/calendar-agenda-fill-icon_48.entry-c4ea84b3.cjs +0 -7
  122. package/dist/google-logo-icon_4.entry-afffb209.cjs +0 -1
  123. package/dist/index-c4e817ef.cjs +0 -82
  124. package/dist/nylas-booked-event-card_12.entry-47c5381d.cjs +0 -1
  125. package/dist/nylas-scheduling.entry-bc9c25c5.js +0 -359
  126. package/dist/nylas-scheduling.entry-dc92d5e7.cjs +0 -1
  127. package/dist/scheduler-store-9ff4914b-63dc472a.cjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-c4e817ef.cjs"),I=require("./index.es-79f5b771-08cc349d.cjs"),k=require("./scheduler-store-9ff4914b-63dc472a.cjs"),w=require("./constants-50c3e067-1fe54cf3.cjs");require("react");require("react-dom");class B{constructor({schedulerAPIURL:e,nylasSchedulerStore:i,sessionId:a,configId:o,slug:r,clientId:d}){if(!e)throw new Error("schedulerAPIURL is required");if(!i)throw new Error("nylasSchedulerStore is required");if(!a&&!o&&!(r||d))throw new Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.");e==="/"&&(e=new URL(window.location.href).origin),this.configId=o,this.sessionId=a,this.schedulerAPIURL=e,this.nylasSchedulerStore=i,this.slug=r,this.clientId=d}init(){t.debug("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}get scheduler(){return this._schedulerAPIConnector?this._schedulerAPIConnector:(this._schedulerAPIConnector=new k.NylaSchedulerAPIConnector({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId,slug:this.slug,clientId:this.clientId}),this._schedulerAPIConnector)}resetStores(){this.nylasSchedulerStore.reset()}}const v=(n,e)=>{const i=n.isLoading,a=n.showNotification,o=n.nylasBranding;return t.h(t.Fragment,null,a&&t.h("nylas-notification",null),i&&t.h("div",{class:"loading"},t.h("div",{class:"left"},t.h("div",{class:"skeleton"})),t.h("div",{class:"right"},t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}))),!i&&e,t.h("div",{class:"footer"},o&&t.h(t.Fragment,null,"Powered by ",t.h("nylas-logo",null))))},C=(n,e)=>t.h("div",{class:"message-banner"},e),T=':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-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;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{padding:0.5rem 4px 0;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}}.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 svg{fill:var(--nylas-base-500)}.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}',L=T,x={title:t.instance.t("genericErrorTitle"),type:I.nr.Error,category:k.ErrorCategory.Component},E=class{constructor(n){t.registerInstance(this,n),this.init=t.createEvent(this,"init",7),this.schedulerWillLoad=t.createEvent(this,"schedulerWillLoad",7),this.schedulerDidLoad=t.createEvent(this,"schedulerDidLoad",7),this.nylasSchedulerError=t.createEvent(this,"nylasSchedulerError",7),this.configSettingsLoaded=t.createEvent(this,"configSettingsLoaded",7),this.bookingRefExtracted=t.createEvent(this,"bookingRefExtracted",7),this.bookedEventInfo=t.createEvent(this,"bookedEventInfo",7),this.mode="app",this.defaultSchedulerState=void 0,this.sessionId=void 0,this.schedulerApiUrl="https://api.us.nylas.com",this.bookingInfo=void 0,this.rescheduleBookingRef=void 0,this.cancelBookingRef=void 0,this.organizerConfirmationBookingRef=void 0,this.configurationId=void 0,this.slug=void 0,this.clientId=void 0,this.nylasBranding=!0,this.eventOverrides={},this.isLoading=void 0,this.themeConfig=void 0,this.localization=void 0,this.showNotification=!0,this.automaticComponentRegistration=!0,this.selectedDateLabel=new Date().toLocaleDateString(void 0,{dateStyle:"full"})||`${t.instance.t("noDateSelected")}`,this.refConfigId=void 0,this.language=navigator.language}connectedCallback(){t.debug("[nylas-scheduler] connectedCallback")}async componentWillLoad(){var o,r;t.debug("[nylas-scheduler] Component will load");const n=this.schedulerWillLoad.emit(this.host);if("schedulerWillLoad"in this.eventOverrides&&(await this.eventOverrides.schedulerWillLoad(n,this.nylasSchedulerConnector),n.defaultPrevented))return;this.stores={scheduler:k.CreateNylasSchedulerStore({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,...this.defaultSchedulerState})},this.baseProvider=new I.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.refConfigId=this.configurationId;let e;if(this.rescheduleBookingRef){const[d,s,l]=t.compactStringToUUIDs(this.rescheduleBookingRef);this.refConfigId=d,this.stores.scheduler.set("rescheduleBookingId",s),e=this.bookingRefExtracted.emit({configurationId:d,bookingId:s})}else if(this.cancelBookingRef){const[d,s,l]=t.compactStringToUUIDs(this.cancelBookingRef);this.refConfigId=d,this.stores.scheduler.set("cancelBookingId",s),e=this.bookingRefExtracted.emit({configurationId:d,bookingId:s})}else if(this.organizerConfirmationBookingRef){const[d,s,l]=t.compactStringToUUIDs(this.organizerConfirmationBookingRef);this.refConfigId=d,this.stores.scheduler.set("organizerConfirmationBookingId",s),this.stores.scheduler.set("organizerConfirmationSalt",l),e=this.bookingRefExtracted.emit({configurationId:d,bookingId:s,salt:l})}if("bookingRefExtracted"in this.eventOverrides&&(await this.eventOverrides.bookingRefExtracted(e,this.nylasSchedulerConnector),e.defaultPrevented)||!this.checkIfSessionIdOrConfigIdExists())return;const i=(o=this.baseProvider)==null?void 0:o.getStore("scheduler");this.nylasSchedulerConnector=new B({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:i});const a=this.init.emit(this.host);"init"in this.eventOverrides&&(await this.eventOverrides.init(a,this.nylasSchedulerConnector),a.defaultPrevented)||((r=this.baseProvider)==null||r.componentWillLoad(this.nylasSchedulerConnector),this.applyThemeConfig(this.themeConfig))}async componentDidLoad(){var l,u,p,h,c,g,m,y;(l=this.baseProvider)==null||l.componentDidLoad();const n=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides&&(await this.eventOverrides.schedulerDidLoad(n,this.nylasSchedulerConnector),n.defaultPrevented)||!this.checkIfSessionIdOrConfigIdExists())return;this.localizationChanged(this.localization);const e=await((u=this.nylasSchedulerConnector)==null?void 0:u.scheduler.getUISettings());if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e==null?void 0:e.error)},host:this.host});return}else{"data"in e&&((p=e.data)!=null&&p.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 f=this.configSettingsLoaded.emit({settings:e});if("configSettingsLoaded"in this.eventOverrides&&(await this.eventOverrides.configSettingsLoaded(f,this.nylasSchedulerConnector),f.defaultPrevented))return}const i=(h=this.baseProvider)==null?void 0:h.getStore("scheduler"),a=(g=(c=i==null?void 0:i.get("configSettings"))==null?void 0:c.scheduler)==null?void 0:g.available_days_in_future,o=i==null?void 0:i.get("selectedTimeslot");if(o&&(o!=null&&o.start_time)){if(!this.isTimeslotValid(o))return;if(i!=null&&i.get("showBookingForm")){i==null||i.set("selectedDate",o.start_time);return}}const r=i==null?void 0:i.get("selectedDate"),d=i==null?void 0:i.get("availability");let s;if(!(d&&d.length>0)){if(r){const{startTime:f,endTime:b,endTimeForAvailableDaysInFuture:_}=this.validateAvailableDaysInFuture(r,a||30);r.getTime()<_*1e3&&(s=await((y=this.nylasSchedulerConnector)==null?void 0:y.scheduler.getAvailability(f,b)))}else{const f=new Date,{startTime:b,endTime:_,endTimeForAvailableDaysInFuture:D}=this.validateAvailableDaysInFuture(f,a||30);f.getTime()<D*1e3&&(s=await((m=this.nylasSchedulerConnector)==null?void 0:m.scheduler.getAvailability(b,_)))}if((!s||"error"in s)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(s==null?void 0:s.error)},host:this.host}),!r){let f=new Date;const b=i==null?void 0:i.get("availability").find(_=>new Date(_.start_time)>new Date);b&&(f=b.start_time),i==null||i.set("selectedDate",f)}}}componentDisconnected(){var n;(n=this.baseProvider)==null||n.componentDisconnected()}bookingInfoChanged(n){var e;(e=this.stores)==null||e.scheduler.set("bookingInfo",n)}rescheduleBookingRefChanged(n){var e,i;if(n){const[a,o]=t.compactStringToUUIDs(n);(e=this.stores)==null||e.scheduler.set("rescheduleBookingId",o),this.refConfigId=a,(i=this.nylasSchedulerConnector)==null||i.scheduler.setConfigId(a)}}cancelBookingRefChanged(n){var e,i;if(n){const[a,o]=t.compactStringToUUIDs(n);(e=this.stores)==null||e.scheduler.set("cancelBookingId",o),this.refConfigId=a,(i=this.nylasSchedulerConnector)==null||i.scheduler.setConfigId(a)}}organizerConfirmationBookingRefChanged(n){var e,i;if(n){const[a,o]=t.compactStringToUUIDs(n);(e=this.stores)==null||e.scheduler.set("organizerConfirmationBookingId",o),this.refConfigId=a,(i=this.nylasSchedulerConnector)==null||i.scheduler.setConfigId(a)}}localizationChanged(n){n&&Object.keys(n).forEach(e=>{e in w.LANGUAGE_CODE&&(t.instance.addResourceBundle(e,"translation",n[e],!1,!0),this.language=this.language)})}themeConfigChanged(n){this.applyThemeConfig(n)}languageChanged(n){const e=n.detail;this.language=e,t.instance.changeLanguage(e)}async registerComponentHandler(n){var e;(e=this.baseProvider)==null||e.registerComponent(n.detail)}async unregisterComponentHandler(n){var e;(e=this.baseProvider)==null||e.unregisterComponent(n.detail)}async monthChangedHandler(n){var d,s,l,u,p,h,c;const e=n.detail,i=(u=(l=(s=(d=this.nylasSchedulerConnector)==null?void 0:d.schedulerStore)==null?void 0:s.get("configSettings"))==null?void 0:l.scheduler)==null?void 0:u.available_days_in_future,{startTime:a,endTime:o,endTimeForAvailableDaysInFuture:r}=this.validateAvailableDaysInFuture(e,i||30);if(a<r&&e.getTime()<r*1e3){const g=await((p=this.nylasSchedulerConnector)==null?void 0:p.scheduler.getAvailability(a,o));(!g||"error"in g)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(g==null?void 0:g.error)},host:this.host});const m=(h=this.stores)==null?void 0:h.scheduler.get("selectableDates");m&&m.length>0&&((c=this.stores)==null||c.scheduler.set("selectedDate",m[0]))}}mapToBookingData(n){var d,s,l;const e=(d=this.stores)==null?void 0:d.scheduler.get("selectedTimeslot"),i=(s=this.stores)==null?void 0:s.scheduler.get("selectedLanguage"),a=(l=this.stores)==null?void 0:l.scheduler.get("selectedTimezone"),o=e!=null&&e.start_time?new Date(e==null?void 0:e.start_time).getTime()/1e3:"",r=e!=null&&e.end_time?new Date(e==null?void 0:e.end_time).getTime()/1e3:"";return{additional_guests:n.guests,guest:n.primaryParticipant,additional_fields:n.additionalFields,start_time:o,end_time:r,email_language:i,timezone:a}}async bookButtonClickedHandler(n){var l,u,p,h;const e=n.detail,i=this.mapToBookingData(e),o=(u=(l=this.nylasSchedulerConnector)==null?void 0:l.schedulerStore)==null?void 0:u.get("rescheduleBookingId");if(o){const c=await((p=this.nylasSchedulerConnector)==null?void 0:p.scheduler.rescheduleBooking(o,e));(!c||"error"in c)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(c==null?void 0:c.error)},host:this.host});const g=c==null?void 0:c.data,m=this.bookedEventInfo.emit({...c,data:{...g,...i}});"bookedEventInfo"in this.eventOverrides&&await this.eventOverrides.bookedEventInfo(m,this.nylasSchedulerConnector);return}const r=await((h=this.nylasSchedulerConnector)==null?void 0:h.scheduler.bookTimeslot(e));(!r||"error"in r)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(r==null?void 0:r.error)},host:this.host});const d=r==null?void 0:r.data,s=this.bookedEventInfo.emit({...r,data:{...d,...i}});"bookedEventInfo"in this.eventOverrides&&await this.eventOverrides.bookedEventInfo(s,this.nylasSchedulerConnector)}dateSelectedHandler(n){const e=n.detail;this.selectedDateLabel=e?e.toLocaleDateString(void 0,{dateStyle:"full"}):`${t.instance.t("noDateSelected")}`}cancelBookedEventErrorHandler(n){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(n.detail.error)},host:this.host})}cancelBookedEventValidationErrorHandler(n){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(n.detail.error)},host:this.host})}rescheduleBookedEventErrorHandler(n){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(n.detail.error)},host:this.host})}confirmBookingErrorHandler(n){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(n.detail.error)},host:this.host})}async getNylasSchedulerStore(){var n;return(n=this.baseProvider)==null?void 0:n.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(n){return{title:(n==null?void 0:n.title)||x.title,category:(n==null?void 0:n.category)||x.category,type:I.nr.Error,description:(n==null?void 0:n.message)||"",id:new Date().getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(){if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){let n="";return this.sessionId||(n+=t.instance.t("sessionIdRequiredErrorMessage")),!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)&&(n=t.instance.t("sessionIdRequiredErrorMessage")+" "+t.instance.t("publicConfigErrorMessage")),this.nylasSchedulerError.emit({notification:{title:t.instance.t("schedulingComponentErrorTitle"),category:k.ErrorCategory.Component,type:I.nr.Error,description:n,id:new Date().getTime().toString(),ttl:"none"},host:this.host}),!1}return!0}isTimeslotValid(n){return new Date(n.start_time)<new Date?(this.nylasSchedulerError.emit({notification:{title:t.instance.t("invalidTimeslotErrorTitle"),category:k.ErrorCategory.Component,type:I.nr.Error,description:t.instance.t("invalidTimeslotErrorMessage"),id:new Date().getTime().toString(),ttl:"none"},host:this.host}),!1):!0}validateAvailableDaysInFuture(n,e){const i=new Date,a=new Date(n.getFullYear(),n.getMonth(),1).getTime()/1e3,o=new Date(n.getFullYear(),n.getMonth()+1,1).getTime()/1e3,r=Math.floor(t.addDaysToCurrentDate(i,e).getTime()/1e3),d=Math.min(r,o);return{startTime:a<i.getTime()/1e3?Math.floor(i.getTime()/1e3):a,endTime:d,endTimeForAvailableDaysInFuture:r}}applyThemeConfig(n){if(n)for(const[e,i]of Object.entries(n))this.host.style.setProperty(`${e}`,i)}render(){var m,y,f;const n=this.mode==="app",e=(m=this.baseProvider)==null?void 0:m.getStore("scheduler"),i=e==null?void 0:e.get("eventInfo"),a=e==null?void 0:e.get("showBookingForm"),o=e==null?void 0:e.get("cancelledEventInfo"),r=e==null?void 0:e.get("cancelBookingId"),d=e==null?void 0:e.get("selectedTimeslot"),s=e==null?void 0:e.get("rescheduleBookingId"),l=e==null?void 0:e.get("organizerConfirmationBookingId"),u=e==null?void 0:e.get("rejectBookingId"),p=e==null?void 0:e.get("confirmedEventInfo"),h=(e==null?void 0:e.get("nylasBranding"))||this.nylasBranding,c=e==null?void 0:e.get("selectedDate"),g=(f=(y=e==null?void 0:e.get("configSettings"))==null?void 0:y.scheduler)==null?void 0:f.confirmation_redirect_url;if(this.selectedDateLabel=c&&this.language?t.capitalizeFirstLetter(c.toLocaleDateString(w.LANGUAGE_CODE_MAP[this.language],{dateStyle:"full"})):`${t.instance.t("noDateSelected")}`,n&&(r||u)&&!o)return t.h(t.Host,null,t.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"cancel-flow-page",part:"cancel-flow-page"},t.h("nylas-cancel-booking-form",{selectedTimeslot:d,cancelBookingId:r,rejectBookingId:u,exportparts:"ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card"}))));if(n&&l)return t.h(t.Host,null,t.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"manual-confirmation-page",part:"manual-confirmation-page"},t.h("nylas-organizer-confirmation-card",{organizerConfirmationBookingId:l,exportparts:"nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline"}))));if(n&&o)return t.h(t.Host,null,t.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"cancelled-event-page",part:"cancelled-event-page"},t.h("nylas-cancelled-event-card",{cancelledEventInfo:o,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))));if(n&&p)return t.h(t.Host,null,t.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"cancelled-event-page",part:"confirmed-event-page"},t.h("nylas-confirmed-event-card",{confirmedEventInfo:p,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))));if(n&&i&&g){window.location.assign(g);return}if(n&&i)return t.h(t.Host,null,t.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"booked-event-page",part:"booked-event-page"},t.h("nylas-booked-event-card",{selectedTimeslot:d,eventInfo:i,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))));if(n&&(!i||s)&&!a){const b=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return t.h(t.Host,null,t.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},s&&t.h(C,null,`${t.instance.t("rescheduleTitle")}`),t.h("div",{class:"select-date-page",part:"select-date-page"},t.h("div",{class:"left-panel"},t.h("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"}),t.h("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"})),t.h("div",{class:`right-panel ${s?"reschedule":""}`},t.h("h2",null,t.h("calendar-icon",null),t.h("span",{id:"selectedDate"},this.selectedDateLabel)),t.h("nylas-timeslot-picker",{exportparts:"ntp, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},b&&t.h("span",{slot:"timeslot-picker-cta-label"},t.h("slot",{name:"timeslot-picker-cta-label"})))))))}return n&&!i&&a?t.h(t.Host,null,t.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},s&&t.h(C,null,`${t.instance.t("rescheduleTitle")}`),t.h("div",{class:"additional-data-page",part:"additional-data-page"},t.h("div",{class:"left-panel"},t.h("div",{class:"wrapper"},t.h("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone"}))),t.h("div",{class:`right-panel ${s?"reschedule":""}`},t.h("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"}))))):t.h(t.Host,null,t.h("slot",null))}get host(){return t.getElement(this)}static get watchers(){return{bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"],organizerConfirmationBookingRef:["organizerConfirmationBookingRefChanged"],localization:["localizationChanged"],themeConfig:["themeConfigChanged"]}}};E.style=L;exports.nylas_scheduling=E;
@@ -1 +0,0 @@
1
- "use strict";const l=require("./index-c4e817ef.cjs");exports.ErrorCategory=void 0;(function(a){a.Component="component",a.Api="api",a.Auth="auth"})(exports.ErrorCategory||(exports.ErrorCategory={}));var B;(function(a){a.endtime_not_in_future="endtime_not_in_future",a.no_booking_info="no_booking_info",a.no_timeslot_selected="no_timeslot_selected",a.no_timezone_selected="no_timezone_selected",a.no_booking_id="no_booking_id",a.no_salt="no_salt",a.invalid_start_time="invalid_start_time",a.invalid_end_time="invalid_end_time",a.invalid_timezone="invalid_timezone"})(B||(B={}));var E;(function(a){a.invalid_session="invalid_session",a.general_error="general_error",a.internal_error="internal_error",a.invalid_request_error="invalid_request_error",a.timeslot_not_available="timeslot_not_available",a.provider_error="provider_error",a.not_found_error="not_found_error"})(E||(E={}));class C{constructor(){this.component=e=>{const t=exports.ErrorCategory.Component,s=`${e} Error`;return{endtime_not_in_future:(i='"endtime" can not be in the future')=>({title:s,message:i,category:t}),no_booking_info:(i="No booking info provided")=>({title:s,message:i,category:t}),no_timeslot_selected:(i="No timeslot selected")=>({title:s,message:i,category:t}),no_timezone_selected:(i="No timezone selected")=>({title:s,message:i,category:t}),no_booking_id:(i="No booking id provided")=>({title:s,message:i,category:t}),no_salt:(i="No salt provided")=>({title:s,message:i,category:t}),invalid_start_time:(i="Invalid start time")=>({title:s,message:i,category:t}),invalid_end_time:(i="Invalid end time")=>({title:s,message:i,category:t}),invalid_timezone:(i="Invalid timezone")=>({title:s,message:i,category:t})}},this.api=e=>{const t=exports.ErrorCategory.Api,s=`${e} Error`;return{invalid_session:i=>({title:s,message:i,category:t}),general_error:i=>({title:s,message:i,category:t}),internal_error:i=>({title:s,message:i,category:t}),invalid_request_error:i=>({title:s,message:i,category:t}),timeslot_not_available:i=>({title:s,message:i,category:t}),provider_error:i=>({title:s,message:i,category:t}),not_found_error:i=>({title:s,message:i,category:t})}}}}class M{constructor({schedulerAPIURL:e,schedulerStore:t,sessionId:s,configId:i,slug:n,clientId:r}){this.errors=new C,this.schedulerStore=t,this.schedulerAPIURL=e,this.sessionId=s,this.configId=i,this.slug=n,this.clientId=r}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(e,t,s,i={}){try{const n=new URL(this.schedulerAPIURL);return n.pathname=e,await(await fetch(decodeURIComponent(n.toString()),{method:t,headers:{"Content-Type":"application/json",Origin:window.location.origin,...i},body:s})).json()}catch(n){return{error:{message:n.message,title:"API request failed",type:"api"}}}}getErrorMessage(e){var s,i,n,r;let t=(e==null?void 0:e.message)||(e==null?void 0:e.title)||"Something went wrong";return(e==null?void 0:e.type)==="provider_error"&&(t=((i=(s=e==null?void 0:e.provider_error)==null?void 0:s.error)==null?void 0:i.message)||((r=(n=e==null?void 0:e.provider_error)==null?void 0:n.error)==null?void 0:r.title)||"Something went wrong"),t}setConfigId(e){this.configId=e}selectDate(e){this.schedulerStore.set("selectedDate",e),this.schedulerStore.set("selectedTimeslot",null)}selectTime(e){this.schedulerStore.set("selectedTimeslot",e)}selectTimezone(e){this.schedulerStore.set("selectedTimezone",e)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e),l.instance.changeLanguage(e)}async toggleAdditionalData(e){e||await this.refetchAvailability(),this.schedulerStore.set("showBookingForm",e)}setParticipantName(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,name:e}})}setParticipantEmail(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,email:e}})}async refetchAvailability(){const e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3,s=t<e.getTime()/1e3?Math.floor(e.getTime()/1e3):t,i=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;return await this.getAvailability(s,i)}async resetStoreStateAndFetchAvailability(){const e=new Date,t=await this.refetchAvailability(),s=this.schedulerStore.get("availability").find(n=>new Date(n.start_time)>new Date);let i=e;return s&&(i=s.start_time),this.schedulerStore.set("selectedDate",i),this.schedulerStore.set("eventInfo",null),this.schedulerStore.set("showBookingForm",!1),this.schedulerStore.set("selectedTimeslot",null),t}async setReschedule(e){this.schedulerStore.set("isLoading",!0);const t=this.schedulerStore.state.eventInfo;return t&&this.schedulerStore.set("reschedulingEventInfo",t),this.schedulerStore.set("rescheduleBookingId",e),await this.resetStoreStateAndFetchAvailability().finally(()=>{this.schedulerStore.set("isLoading",!1)})}async setCancel(e){this.schedulerStore.set("cancelBookingId",e)}async setReject(e){this.schedulerStore.set("rejectBookingId",e)}async resetCancel(){const e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("cancelBookingId",""),this.schedulerStore.set("rejectBookingId",""),this.schedulerStore.set("cancelledEventInfo",null),e}async goBack(){this.schedulerStore.set("cancelBookingId","")}async resetConfirm(){const e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("organizerConfirmationBookingId",""),this.schedulerStore.set("confirmedEventInfo",void 0),e}async bookTimeslot(e){var I;this.schedulerStore.set("isLoading",!0);const{selectedTimeslot:t,selectedTimezone:s,bookingInfo:i,selectedLanguage:n}=this.schedulerStore.state;if(!e&&!i)return{error:this.errors.component(l.instance.t("createBookingErrorTitle")).no_booking_info()};const r=(e==null?void 0:e.timeslot)||t;if(!r)return{error:this.errors.component(l.instance.t("createBookingErrorTitle")).no_timeslot_selected()};const o=e&&(e!=null&&e.timezone)?e==null?void 0:e.timezone:s;if(!o)return{error:this.errors.component(l.instance.t("createBookingErrorTitle")).no_timezone_selected()};const u=this.schedulerStore.get("availabilityOrderEmails");let m="";if(u.length>0){const S=r.emails;for(let h=0;h<u.length;h++)if(S.includes(u[h])){m=u[h];break}}const d=e?e==null?void 0:e.primaryParticipant:i==null?void 0:i.primaryParticipant,g=e?(e==null?void 0:e.guests)||[]:(i==null?void 0:i.guests)||[],f=e?e==null?void 0:e.additionalFields:i==null?void 0:i.additionalFields,_=this.getHeaders(),v=`/v3/scheduling/bookings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:""}`,c=await this.makeAPIRequest(decodeURIComponent(v),"POST",JSON.stringify({participants:m?[{email:m}]:void 0,additional_fields:f,additional_guests:g,guest:{...d},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:o,email_language:this.getTwoLetterLanguageCode(n)}),_);if("error"in c){this.schedulerStore.set("isLoading",!1);const S=(I=c.error)==null?void 0:I.type;let h=c.error;if(S&&S in this.errors.api("Create Booking")){const T=this.getErrorMessage(h);h=this.errors.api("Create Booking")[S](T)}return{error:h}}return"data"in c&&this.schedulerStore.set("eventInfo",c==null?void 0:c.data),this.schedulerStore.set("isLoading",!1),c}async getUISettings(){var n;this.schedulerStore.set("isLoading",!0);const e=this.getHeaders(),s=`/v3/scheduling/ui-settings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:""}`,i=await this.makeAPIRequest(s,"GET",void 0,e);if("error"in i){this.schedulerStore.set("isLoading",!1);const r=(n=i.error)==null?void 0:n.type;let o=i.error;return r&&r in this.errors.api(l.instance.t("getUISettingErrorTitle"))&&(o=this.errors.api(l.instance.t("getUISettingErrorTitle"))[r]((o==null?void 0:o.message)||(o==null?void 0:o.title)||"Something went wrong")),{error:o}}return"data"in i&&this.schedulerStore.set("configSettings",i.data),this.schedulerStore.set("isLoading",!1),i}getTwoLetterLanguageCode(e){return e.split("-")[0]}getStartTimeWithMinBookingNotice(e){var n;const t=(n=this.schedulerStore.get("configSettings"))==null?void 0:n.scheduler,s=t==null?void 0:t.min_booking_notice;if(!s)return e;const i=new Date().getTime();return e<(i+s*60*1e3)/1e3?Math.floor((i+s*60*1e3)/1e3):e}getEndTimeForAvailableDaysInFuture(e){var r,o;const t=new Date,s=(o=(r=this.schedulerStore.get("configSettings"))==null?void 0:r.scheduler)==null?void 0:o.available_days_in_future,i=Math.floor(l.addDaysToCurrentDate(t,s).getTime()/1e3);return Math.min(i,e)}async getAvailability(e=0,t=0){var f,_,p,v;this.schedulerStore.set("isLoading",!0);const s=new URLSearchParams,i=new Date,n=i.getTime();if(t&&t<n/1e3)return this.schedulerStore.set("isLoading",!1),{error:this.errors.component(l.instance.t("getAvailabilityErrorTitle")).endtime_not_in_future()};if(!e){const c=new Date(i.getFullYear(),i.getMonth(),1);e=Math.floor(c.getTime()/1e3)}if(!t){const c=new Date(i.getFullYear(),i.getMonth()+1,0);t=Math.floor(c.getTime()/1e3)}t=this.getEndTimeForAvailableDaysInFuture(t);const r=this.getStartTimeWithMinBookingNotice(e);e=r,t=r>t?r+1:t,s.append("start_time",encodeURIComponent(e.toString())),s.append("end_time",encodeURIComponent(t.toString())),this.configId&&!this.sessionId?s.append("configuration_id",encodeURIComponent(this.configId)):this.slug&&this.clientId&&!this.sessionId&&(s.append("slug",encodeURIComponent(this.slug)),s.append("client_id",encodeURIComponent(this.clientId)));const o=this.schedulerStore.get("rescheduleBookingId");o&&s.append("booking_id",encodeURIComponent(o));const u=s.toString(),m=`/v3/scheduling/availability${u?`?${u}`:""}`,d=this.getHeaders(),g=await this.makeAPIRequest(decodeURIComponent(m),"GET",void 0,d);if("error"in g){this.schedulerStore.set("availability",[]),this.schedulerStore.set("isLoading",!1);const c=(f=g.error)==null?void 0:f.type;let I=g.error;if(c&&c in this.errors.api(l.instance.t("getAvailabilityErrorTitle"))){const S=this.getErrorMessage(I);I=this.errors.api(l.instance.t("getAvailabilityErrorTitle"))[c](S)}return{error:I}}if("data"in g){const I=(((p=(_=g.data)==null?void 0:_.time_slots)==null?void 0:p.map(h=>({...h,start_time:new Date(h.start_time*1e3),end_time:new Date(h.end_time*1e3)})))||[]).filter(h=>h.start_time.getTime()>n);this.schedulerStore.set("availability",I);const S=((v=g.data)==null?void 0:v.order)||[];this.schedulerStore.set("availabilityOrderEmails",S)}return this.schedulerStore.set("isLoading",!1),g}async cancelBooking(e,t){var o;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(l.instance.t("cancelBookingErrorTitle")).no_booking_id()};const s=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",i=`/v3/scheduling/bookings/${e}${s}`,n=this.getHeaders(),r=await this.makeAPIRequest(decodeURIComponent(i),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:t}),n);if("error"in r){this.schedulerStore.set("isLoading",!1);const u=(o=r.error)==null?void 0:o.type;let m=r.error;if(u&&u in this.errors.api(l.instance.t("cancelBookingErrorTitle"))){const d=this.getErrorMessage(m);m=this.errors.api(l.instance.t("cancelBookingErrorTitle"))[u](d)}return{error:m}}return this.schedulerStore.set("cancelledEventInfo",{booking_id:e}),this.schedulerStore.set("rescheduleBookingId",""),this.schedulerStore.set("isLoading",!1),r}async rescheduleBooking(e,t){var L;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(l.instance.t("rescheduleBookingErrorTitle")).no_booking_id()};const s=this.errors.api(l.instance.t("rescheduleBookingErrorTitle")),i=this.errors.component(l.instance.t("rescheduleBookingErrorTitle")),{bookingInfo:n,selectedTimeslot:r,selectedTimezone:o,selectedLanguage:u}=this.schedulerStore.state,{startTime:m,endTime:d,timezone:g}=t,f=m||(r==null?void 0:r.start_time);if(!f)return{error:i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const _=d||(r==null?void 0:r.end_time);if(!_)return{error:i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const p=this.schedulerStore.get("availabilityOrderEmails");let v="";if(p.length>0){const b=(r==null?void 0:r.emails)||[];for(let k=0;k<p.length;k++)if(b.includes(p[k])){v=p[k];break}}const c=g||o;if(!c)return{error:i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')};const I=t?t==null?void 0:t.primaryParticipant:n==null?void 0:n.primaryParticipant,S=t?(t==null?void 0:t.guests)||[]:(n==null?void 0:n.guests)||[],h=t?t==null?void 0:t.additionalFields:n==null?void 0:n.additionalFields,T=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",D=`/v3/scheduling/bookings/${e}${T}`,A=this.getHeaders(),y=await this.makeAPIRequest(decodeURIComponent(D),"PATCH",JSON.stringify({start_time:f.getTime()/1e3,end_time:_.getTime()/1e3,timezone:c,additional_fields:h,guest:{...I},additional_guests:S,participants:v?[{email:v}]:void 0,email_language:this.getTwoLetterLanguageCode(u)}),A);if("error"in y){this.schedulerStore.set("isLoading",!1);const b=(L=y.error)==null?void 0:L.type;let k=y.error;if(b&&b in s){const P=this.getErrorMessage(k);k=s[b](P)}return{error:k}}const w=this.schedulerStore.get("reschedulingEventInfo");if("data"in y)this.schedulerStore.set("eventInfo",y==null?void 0:y.data);else if(w)this.schedulerStore.set("eventInfo",w);else{const b={booking_id:e};this.schedulerStore.set("eventInfo",b)}return this.schedulerStore.set("isLoading",!1),y}async updateBooking(e){var g;this.schedulerStore.set("isLoading",!0);const{bookingId:t,status:s,reason:i}=e,n=this.schedulerStore.get("organizerConfirmationSalt"),r=s==="confirmed"?l.instance.t("confirmBookingErrorTitle"):l.instance.t("rejectBookingErrorTitle");if(!t)return{error:this.errors.component(r).no_booking_id()};if(!n)return{error:this.errors.component(r).no_salt()};const o=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",u=`/v3/scheduling/bookings/${t}${o}`,m=this.getHeaders(),d=await this.makeAPIRequest(decodeURIComponent(u),"PUT",JSON.stringify({status:s,cancellation_reason:i,salt:n}),m);if("error"in d){this.schedulerStore.set("isLoading",!1);const f=(g=d.error)==null?void 0:g.type;let _=d.error;if(f&&f in this.errors.api(r)){const p=this.getErrorMessage(_);_=this.errors.api(r)[f](p)}return{error:_}}return"data"in d&&s==="confirmed"?this.schedulerStore.set("confirmedEventInfo",d==null?void 0:d.data):"request_id"in d&&s==="cancelled"&&this.schedulerStore.set("cancelledEventInfo",{booking_id:t}),this.schedulerStore.set("organizerConfirmationBookingId",""),this.schedulerStore.set("isLoading",!1),d}}function z(a={}){const e={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:!1,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:!1,nylasBranding:!0,...a};l.debug("[defaultNylasStoreState]: ",e);const t=l.createStore(e);return t.onChange("availability",s=>{l.debug("[availability]: ",s);const i=s.map(o=>o.start_time);l.debug("[selectableDates]: ",i),t.set("selectableDates",i);const n=s[0];if(!n)return;const r=Math.floor((n.end_time.getTime()-n.start_time.getTime())/6e4);l.debug("[durationMinutes]: ",r),t.set("eventDuration",r)}),t.reset=()=>{for(const s in e){const i=e[s];t.set(s,i)}},t}exports.CreateNylasSchedulerStore=z;exports.NylaSchedulerAPIConnector=M;