@nylas/react 1.1.0-canary.9 → 1.1.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 (156) hide show
  1. package/README.md +110 -2
  2. package/dist/add-circle-icon_2.entry-7165bd0e.js +25 -0
  3. package/dist/add-circle-icon_2.entry-f1ddca18.cjs +1 -0
  4. package/dist/archive-icon_7.entry-7411c224.js +75 -0
  5. package/dist/archive-icon_7.entry-e3df60ed.cjs +1 -0
  6. package/dist/arrow-icon.entry-280e18b0.cjs +1 -0
  7. package/dist/arrow-icon.entry-38949317.js +15 -0
  8. package/dist/bold-icon_3.entry-5963945c.js +35 -0
  9. package/dist/bold-icon_3.entry-5dffbedd.cjs +1 -0
  10. package/dist/button-component_2.entry-237733b4.js +26 -0
  11. package/dist/button-component_2.entry-b29d2873.cjs +1 -0
  12. package/dist/calendar-agenda-fill-icon_48.entry-9afba869.js +5105 -0
  13. package/dist/calendar-agenda-fill-icon_48.entry-d3830dbb.cjs +7 -0
  14. package/dist/calendar-cancel-icon.entry-77ccf227.cjs +1 -0
  15. package/dist/calendar-cancel-icon.entry-780723a6.js +15 -0
  16. package/dist/calendar-check-icon_2.entry-2c89c230.js +25 -0
  17. package/dist/calendar-check-icon_2.entry-b37ac7f0.cjs +1 -0
  18. package/dist/calendar-icon.entry-02dd3990.js +15 -0
  19. package/dist/calendar-icon.entry-ffc93569.cjs +1 -0
  20. package/dist/checkbox-component_2.entry-00b6a1e9.cjs +1 -0
  21. package/dist/checkbox-component_2.entry-ee9d0e6c.js +56 -0
  22. package/dist/chevron-icon_3.entry-468abc26.cjs +1 -0
  23. package/dist/chevron-icon_3.entry-f62e9ef1.js +129 -0
  24. package/dist/clock-icon_4.entry-766a1b23.js +45 -0
  25. package/dist/clock-icon_4.entry-7dc2cc4a.cjs +1 -0
  26. package/dist/constants-50c3e067-8a40a5fe.js +3883 -0
  27. package/dist/constants-50c3e067-9f2a6372.cjs +15 -0
  28. package/dist/copy-icon.entry-2a841508.js +15 -0
  29. package/dist/copy-icon.entry-e5251410.cjs +1 -0
  30. package/dist/core-js-38e53e34.cjs +4 -0
  31. package/dist/core-js-a9d3b6e1.js +3297 -0
  32. package/dist/delete-icon_2.entry-1a5c39dc.cjs +1 -0
  33. package/dist/delete-icon_2.entry-64555a2f.js +25 -0
  34. package/dist/document-refresh-icon.entry-4bf6398b.js +15 -0
  35. package/dist/document-refresh-icon.entry-fdc7ddda.cjs +1 -0
  36. package/dist/dom-68f08be9.cjs +15 -0
  37. package/dist/dom-86e17616.js +664 -0
  38. package/dist/{types/elements → elements}/index.d.ts +47 -1
  39. package/dist/elements-dc5b338e-2da1fe61.js +28031 -0
  40. package/dist/elements-dc5b338e-c8016c3d.cjs +16516 -0
  41. package/dist/flow-40ff9cea-6f8c30e2.cjs +9 -0
  42. package/dist/flow-40ff9cea-ee70fdf5.js +505 -0
  43. package/dist/focus-visible-e8093c16-0a38a184.cjs +1 -0
  44. package/dist/focus-visible-e8093c16-9d0c98c0.js +84 -0
  45. package/dist/forward-icon_6.entry-390ef70a.js +953 -0
  46. package/dist/forward-icon_6.entry-7238ef38.cjs +3 -0
  47. package/dist/globe-icon.entry-81f42f89.cjs +1 -0
  48. package/dist/globe-icon.entry-8d106260.js +15 -0
  49. package/dist/google-logo-icon_4.entry-aabd3886.js +680 -0
  50. package/dist/google-logo-icon_4.entry-fa2b8999.cjs +1 -0
  51. package/dist/index-53420959-5fc8ad2b.js +5 -0
  52. package/dist/index-53420959-fcf45780.cjs +1 -0
  53. package/dist/index-5ccfd9df.js +7859 -0
  54. package/dist/index-6d9eeb53-58c8980a.js +4971 -0
  55. package/dist/index-6d9eeb53-b2a6d09f.cjs +41 -0
  56. package/dist/index-eb33703c.cjs +42 -0
  57. package/dist/index.es-c9454237-00ccd1e6.js +3135 -0
  58. package/dist/index.es-c9454237-b64161d1.cjs +7 -0
  59. package/dist/info-icon_2.entry-b2e11336.cjs +1 -0
  60. package/dist/info-icon_2.entry-bb8ed71c.js +34 -0
  61. package/dist/input-component.entry-378b1ccc.cjs +1 -0
  62. package/dist/input-component.entry-cb86170f.js +65 -0
  63. package/dist/input-dropdown.entry-98954c93.cjs +1 -0
  64. package/dist/input-dropdown.entry-a76c339e.js +134 -0
  65. package/dist/mailbox-store-edc386fc-156b7236.cjs +1 -0
  66. package/dist/mailbox-store-edc386fc-8bc7558b.js +380 -0
  67. package/dist/multi-select-dropdown.entry-40b855e1.cjs +1 -0
  68. package/dist/multi-select-dropdown.entry-6b686695.js +91 -0
  69. package/dist/nylas-booked-event-card_12.entry-9d693125.cjs +1 -0
  70. package/dist/nylas-booked-event-card_12.entry-e861bb16.js +1134 -0
  71. package/dist/nylas-form-card.entry-b158d789.js +57 -0
  72. package/dist/nylas-form-card.entry-ca4a8746.cjs +1 -0
  73. package/dist/nylas-if-state.entry-8e4d922c.js +94 -0
  74. package/dist/nylas-if-state.entry-95fac42d.cjs +1 -0
  75. package/dist/nylas-list-folders.entry-83c39684.js +120 -0
  76. package/dist/nylas-list-folders.entry-8a22e0c8.cjs +1 -0
  77. package/dist/nylas-list-threads.entry-54c582af.cjs +1 -0
  78. package/dist/nylas-list-threads.entry-7ea370e1.js +70 -0
  79. package/dist/nylas-login.entry-9115fd81.js +73 -0
  80. package/dist/nylas-login.entry-fb627e40.cjs +1 -0
  81. package/dist/nylas-mailbox-pagination.entry-04626d27.cjs +1 -0
  82. package/dist/nylas-mailbox-pagination.entry-3ff02cf9.js +101 -0
  83. package/dist/nylas-mailbox-toolbar-button.entry-8d00c789.cjs +1 -0
  84. package/dist/nylas-mailbox-toolbar-button.entry-f752e925.js +82 -0
  85. package/dist/nylas-mailbox.entry-99c27b6c.js +134 -0
  86. package/dist/nylas-mailbox.entry-b3974f4e.cjs +1 -0
  87. package/dist/nylas-provider.entry-a3ad02a5.cjs +1 -0
  88. package/dist/nylas-provider.entry-c206aa32.js +145 -0
  89. package/dist/nylas-reminder-emails.entry-414ce6fe.js +129 -0
  90. package/dist/nylas-reminder-emails.entry-59c07bfe.cjs +4 -0
  91. package/dist/nylas-reminder-time_2.entry-197d83a0.js +105 -0
  92. package/dist/nylas-reminder-time_2.entry-d79dcd85.cjs +1 -0
  93. package/dist/nylas-scheduler-editor.entry-7f389982.js +1447 -0
  94. package/dist/nylas-scheduler-editor.entry-f1c6964a.cjs +2 -0
  95. package/dist/nylas-scheduling.entry-1a8bd6fc.cjs +1 -0
  96. package/dist/nylas-scheduling.entry-4fa5381d.js +345 -0
  97. package/dist/nylas-threads-refresh.entry-20602e7b.js +74 -0
  98. package/dist/nylas-threads-refresh.entry-56b53449.cjs +1 -0
  99. package/dist/nylas-threads-search.entry-8872473c.js +69 -0
  100. package/dist/nylas-threads-search.entry-8e0ec3ae.cjs +1 -0
  101. package/dist/nylas-time-window-picker.entry-9ac542b7.js +316 -0
  102. package/dist/nylas-time-window-picker.entry-ca47f721.cjs +1 -0
  103. package/dist/nylas-view-thread.entry-1f758e43.cjs +1 -0
  104. package/dist/nylas-view-thread.entry-dcd3d5be.js +203 -0
  105. package/dist/person-icon.entry-63b28ace.cjs +1 -0
  106. package/dist/person-icon.entry-93130c05.js +15 -0
  107. package/dist/play-icon_2.entry-6a99c32d.js +25 -0
  108. package/dist/play-icon_2.entry-b67fb649.cjs +1 -0
  109. package/dist/react.cjs +1 -0
  110. package/dist/react.js +144 -0
  111. package/dist/refresh-icon.entry-84783c91.js +15 -0
  112. package/dist/refresh-icon.entry-b49792fc.cjs +1 -0
  113. package/dist/register-component-887199a9-003f96c5.cjs +1 -0
  114. package/dist/register-component-887199a9-b41dfa7a.js +109 -0
  115. package/dist/scheduler-config-store-2a3b403d-73610089.js +27 -0
  116. package/dist/scheduler-config-store-2a3b403d-a5e3433a.cjs +1 -0
  117. package/dist/scheduler-store-fe281404-bddb1b6a.js +469 -0
  118. package/dist/scheduler-store-fe281404-c3e477f6.cjs +1 -0
  119. package/dist/textarea-component.entry-28c4bc05.cjs +1 -0
  120. package/dist/textarea-component.entry-40e959e5.js +36 -0
  121. package/dist/time-period-selector.entry-af71523a.cjs +1 -0
  122. package/dist/time-period-selector.entry-da5d8652.js +93 -0
  123. package/dist/translate-icon.entry-92b83635.js +15 -0
  124. package/dist/translate-icon.entry-a2ed4f76.cjs +1 -0
  125. package/dist/warning-icon.entry-19f721c3.js +15 -0
  126. package/dist/warning-icon.entry-3ab9a59e.cjs +1 -0
  127. package/package.json +12 -8
  128. package/dist/elements/index.js +0 -92
  129. package/dist/elements/index.js.map +0 -1
  130. package/dist/elements/react-component-lib/createComponent.js +0 -65
  131. package/dist/elements/react-component-lib/createComponent.js.map +0 -1
  132. package/dist/elements/react-component-lib/createOverlayComponent.js +0 -98
  133. package/dist/elements/react-component-lib/createOverlayComponent.js.map +0 -1
  134. package/dist/elements/react-component-lib/index.js +0 -3
  135. package/dist/elements/react-component-lib/index.js.map +0 -1
  136. package/dist/elements/react-component-lib/interfaces.js +0 -2
  137. package/dist/elements/react-component-lib/interfaces.js.map +0 -1
  138. package/dist/elements/react-component-lib/utils/attachProps.js +0 -92
  139. package/dist/elements/react-component-lib/utils/attachProps.js.map +0 -1
  140. package/dist/elements/react-component-lib/utils/case.js +0 -7
  141. package/dist/elements/react-component-lib/utils/case.js.map +0 -1
  142. package/dist/elements/react-component-lib/utils/dev.js +0 -13
  143. package/dist/elements/react-component-lib/utils/dev.js.map +0 -1
  144. package/dist/elements/react-component-lib/utils/index.js +0 -31
  145. package/dist/elements/react-component-lib/utils/index.js.map +0 -1
  146. package/dist/index.js +0 -29
  147. package/dist/index.js.map +0 -1
  148. /package/dist/{types/elements → elements}/react-component-lib/createComponent.d.ts +0 -0
  149. /package/dist/{types/elements → elements}/react-component-lib/createOverlayComponent.d.ts +0 -0
  150. /package/dist/{types/elements → elements}/react-component-lib/index.d.ts +0 -0
  151. /package/dist/{types/elements → elements}/react-component-lib/interfaces.d.ts +0 -0
  152. /package/dist/{types/elements → elements}/react-component-lib/utils/attachProps.d.ts +0 -0
  153. /package/dist/{types/elements → elements}/react-component-lib/utils/case.d.ts +0 -0
  154. /package/dist/{types/elements → elements}/react-component-lib/utils/dev.d.ts +0 -0
  155. /package/dist/{types/elements → elements}/react-component-lib/utils/index.d.ts +0 -0
  156. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
@@ -0,0 +1,953 @@
1
+ import { r as ne, h as g, c as We, d as T, H as $e, g as Rt, i as yn, v as bn, w as En, x as Tn, F as An, y as _n } from "./index-5ccfd9df.js";
2
+ import { R as wn } from "./register-component-887199a9-b41dfa7a.js";
3
+ import "react";
4
+ import "react-dom";
5
+ const vn = ".sc-forward-icon-h{display:flex}", Sn = vn, Cn = class {
6
+ constructor(t) {
7
+ ne(this, t), this.width = "15", this.height = "15";
8
+ }
9
+ render() {
10
+ return g("svg", { key: "256bedcd1d16ce56abf8a1a9e256c3056df7982d", fill: "auto", width: this.width, height: this.height, viewBox: "0 0 1920 1920", xmlns: "http://www.w3.org/2000/svg" }, g("path", { key: "e9eff3ddff62ad3e805efe09a77e3c984dad8d2d", d: "m1246.246 64-90.496 90.496 477.952 477.952h-590.848C467.878 632.448.038 1100.416.038 1675.392v109.056h128v-109.056c0-504.576 410.368-914.944 914.816-914.944h590.848l-477.952 478.08 90.496 90.496 632.448-632.576L1246.246 64Z", "fill-rule": "evenodd" }));
11
+ }
12
+ };
13
+ Cn.style = Sn;
14
+ const Ln = ':host{display:grid;color:var(--nylas-color-primary-900)}.editor{position:relative;display:block;max-height:300px;overflow:auto;padding:1rem;border:1px solid var(--nylas-color-primary-300)}.editor blockquote{visibility:hidden;overflow:hidden;position:relative;transition:height 0.3s ease;margin:0}.editor blockquote::before{content:"...";visibility:visible;opacity:1;position:absolute;top:0;left:0;background-color:var(--nylas-color-primary-300);width:20px;text-align:center;color:var(--nylas-color-primary-800);vertical-align:middle;display:flex;justify-content:center;align-items:center;align-self:center;cursor:pointer}.editor .collapsed{height:20px}.editor .expanded{visibility:visible;opacity:1;height:auto;margin:0px 0px 0px 0.8ex;border-left:1px solid var(--nylas-color-primary-300);padding-left:1rem}.editor .expanded::before{display:none;}.buttons{display:flex;margin-top:1rem;justify-content:space-between}.buttons sp-button{border-radius:var(--nylas-border-radius);background-color:var(--nylas-color-primary-400);color:var(--nylas-color-primary-900);fill:var(--nylas-color-primary-900)}.buttons sp-button:hover{background-color:var(--nylas-color-primary-500)}.buttons sp-button:disabled{background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600);cursor:not-allowed}.buttons sp-button chevron-icon{display:inline-block}.buttons .close{justify-self:end}.toolbar{position:absolute;display:none;background-color:var(--nylas-color-primary-200);border-radius:var(--nylas-border-radius);z-index:1}.toolbar sp-button{border:0}', Rn = Ln, kn = class {
15
+ constructor(t) {
16
+ ne(this, t), this.close = We(this, "close", 7), this.send = We(this, "send", 7), this.closeComposer = (o) => {
17
+ this.close.emit(o);
18
+ }, this.sendComposer = (o) => {
19
+ var s;
20
+ if (!this.editorEl) {
21
+ T("no editor element");
22
+ return;
23
+ }
24
+ const u = this.editorEl.querySelector(".message-body");
25
+ if (!u) {
26
+ T("no message body");
27
+ return;
28
+ }
29
+ this.message && (this.send.emit({
30
+ message: this.message,
31
+ replyBody: ((s = u.querySelector(".message-body")) == null ? void 0 : s.innerHTML) || ""
32
+ }), this.close.emit(o), this.editorEl.innerHTML = "");
33
+ }, this.message = void 0, this.viewEmailElement = void 0;
34
+ }
35
+ connectedCallback() {
36
+ }
37
+ disconnectedCallback() {
38
+ this.editorEl && (this.editorEl.innerHTML = "");
39
+ }
40
+ componentWillLoad() {
41
+ }
42
+ async componentDidLoad() {
43
+ if (this.message && this.watchBody(this.message), !this.editorEl) {
44
+ T("[connectedCallback] no editor element");
45
+ return;
46
+ }
47
+ if (!this.toolbarEl) {
48
+ T("[connectedCallback] no toolbar element");
49
+ return;
50
+ }
51
+ const t = this.editorEl, o = this.toolbarEl;
52
+ t.addEventListener("mouseup", (u) => {
53
+ var W;
54
+ const s = (W = this.host.shadowRoot) == null ? void 0 : W.getSelection();
55
+ if (!s) {
56
+ T("no selection");
57
+ return;
58
+ }
59
+ const m = s.getRangeAt(0), a = s.toString();
60
+ if (!a) {
61
+ o.style.display = "none";
62
+ return;
63
+ }
64
+ const f = t.querySelector(".message-body");
65
+ if (!f) {
66
+ T("no message body");
67
+ return;
68
+ }
69
+ const l = m.commonAncestorContainer.parentElement;
70
+ if (!l)
71
+ return;
72
+ const E = f.getBoundingClientRect();
73
+ T("messageBodyRect", { messageBodyRect: E });
74
+ const _ = l.getBoundingClientRect();
75
+ T("foundRect", { foundRect: _ });
76
+ const de = (l.childNodes[0].textContent || "").indexOf(a), G = window.getComputedStyle(l).fontSize, X = parseInt(G.replace("px", ""), 10), oe = _.top - E.top - o.clientHeight, Ee = de * (1 / X) * 100;
77
+ o.style.top = `${oe}px`, o.style.left = `${Ee}px`, o.style.display = "block";
78
+ });
79
+ }
80
+ watchBody(t) {
81
+ var a;
82
+ if (!this.editorEl) {
83
+ T("no editor element");
84
+ return;
85
+ }
86
+ this.editorEl.querySelectorAll(".message-body").forEach((f) => f.remove());
87
+ const o = document.createElement("div");
88
+ o.classList.add("message-body");
89
+ const u = document.createElement("p");
90
+ u.innerHTML = " ", o.appendChild(u);
91
+ const s = document.createElement("br");
92
+ o.appendChild(s);
93
+ const m = document.createElement("div");
94
+ if (m.classList.add("reply-text"), m.innerText = `On ${new Date(t.date * 1e3).toLocaleDateString(void 0, { dateStyle: "full" })} <${(a = t.from) == null ? void 0 : a.map((f) => f.name || f.email).join(", ")}> wrote:`, o.appendChild(m), t.body) {
95
+ const f = document.createElement("html");
96
+ f.innerHTML = t.body;
97
+ const i = document.createElement("blockquote");
98
+ i.classList.add("collapsed"), i.classList.add("gmail_quote"), i.innerHTML = f.innerHTML, o.appendChild(i), T("replyContainer", { replyContainer: i });
99
+ }
100
+ this.editorEl.appendChild(o), this.editorEl.querySelectorAll("blockquote.collapsed").forEach((f) => {
101
+ f.addEventListener("click", function(i) {
102
+ i.preventDefault();
103
+ const l = i.target;
104
+ l.classList.remove("collapsed"), l.classList.add("expanded");
105
+ }, { once: !0 });
106
+ }), this.editorEl.focus();
107
+ }
108
+ render() {
109
+ return g($e, { key: "05d06e346d185690361a7a28b840fc2ab23e126e" }, g("sp-theme", { key: "777d476f2fe72825fdae33f947f0d2a23093a11a", scale: "medium", color: "dark" }, g("div", { key: "2aa6533429c21b308592a7251185b46630122c64", class: "editor", contentEditable: !0, ref: (t) => this.editorEl = t }, g("div", { key: "01fb8abaed3b30ee0285a9d01aa784915e582ecb", class: "toolbar", ref: (t) => this.toolbarEl = t, contentEditable: !1 }, g("sp-button", { key: "468e3fb7124061e37e647cbdce323a4581043ddc", quiet: !0, onClick: () => document.execCommand("bold") }, g("div", { key: "1a6ee78ed04d8d3e7516f894c679779acfda4f92", slot: "icon" }, g("bold-icon", { key: "16f13ee9609a2611a34108920a497c0b26d62cc5" })), g("div", { key: "83a1147bc6c0a59e70bb2a281f4a5fb9ec9256c2", slot: "label" }, "Bold")), g("sp-button", { key: "9d5fd28e07ed31d2837f61d126e3999150fcc8ce", quiet: !0, onClick: () => document.execCommand("underline") }, g("div", { key: "eb033d1607aed07a975d05dac449be7abfa7bfd1", slot: "icon" }, g("underline-icon", { key: "688868c4bd528fda5e5a954acee7a0f6d989f591" })), g("div", { key: "a005aaeae969d9db87436f13d524d211ca42894d", slot: "label" }, "Underline")), g("sp-button", { key: "51e1bdab4db4fca3c633b443d5e95a08c4dd9159", quiet: !0, onClick: () => document.execCommand("italic") }, g("div", { key: "1bdee462750ef763ddd3f936a14a639a46874ada", slot: "icon" }, g("italic-icon", { key: "3bb7f0512e91f45731de92bb29bf610fcf930cc6" })), g("div", { key: "d730402f3145f05350e31f3cc39a437633ab2dcd", slot: "label" }, "Italic")))), g("div", { key: "43136421703fad649d4e5a17be0a5df748d545e1", class: "buttons" }, g("sp-button", { key: "1e2c01908a0df6718b83e178241754fd76e225bf", onClick: this.sendComposer, class: "send" }, "Send"), g("sp-button", { key: "33d1ce61aff095ce440cdc04b2a4d89746eb5180", onClick: this.closeComposer, class: "close" }, "Close"))));
110
+ }
111
+ get host() {
112
+ return Rt(this);
113
+ }
114
+ static get watchers() {
115
+ return {
116
+ message: ["watchBody"]
117
+ };
118
+ }
119
+ };
120
+ kn.style = Rn;
121
+ const Mn = ":host{display:block}sp-button{padding:0;border:0;border-radius:var(--nylas-border-radius);min-block-size:50%;min-inline-size:2rem;background-color:var(--nylas-color-primary-300);fill:var(--nylas-color-primary-800)}sp-button:hover{background-color:var(--nylas-color-primary-400)}.summarize-button.stopped{animation:none}.summarize-button.playing{animation:pulse 2s infinite}.summarize-button.loading{display:flex;align-content:center;height:1.5rem;width:2rem;vertical-align:middle;animation:pulse 2s infinite;flex-wrap:wrap}.summarize-button.loading loading-icon{--dot-color:var(--nylas-color-primary-600)}@keyframes pulse{0%{transform:scale(1);box-shadow:0 0 0 0 var(--nylas-color-primary-300)}70%{transform:scale(1.05);box-shadow:0 0 0 10px rgba(255, 69, 0, 0)}100%{transform:scale(1);box-shadow:0 0 0 0 rgba(255, 69, 0, 0)}}@keyframes wave{0%{transform:translateX(0)}50%{transform:translateX(100%)}100%{transform:translateX(0)}}", Nn = Mn;
122
+ var xn = function(t, o, u, s) {
123
+ var m = arguments.length, a = m < 3 ? o : s === null ? s = Object.getOwnPropertyDescriptor(o, u) : s, f;
124
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
125
+ a = Reflect.decorate(t, o, u, s);
126
+ else
127
+ for (var i = t.length - 1; i >= 0; i--)
128
+ (f = t[i]) && (a = (m < 3 ? f(a) : m > 3 ? f(o, u, a) : f(o, u)) || a);
129
+ return m > 3 && a && Object.defineProperty(o, u, a), a;
130
+ }, Be = function(t, o) {
131
+ if (typeof Reflect == "object" && typeof Reflect.metadata == "function")
132
+ return Reflect.metadata(t, o);
133
+ };
134
+ const kt = class {
135
+ constructor(t) {
136
+ ne(this, t), this.summarize = We(this, "summarize", 7), this.abortController = new AbortController(), this.onClick = async (o) => {
137
+ var u, s;
138
+ o.preventDefault(), o.stopPropagation(), this.state === "stopped" ? this.message && (this.abortController = new AbortController(), this.summarize.emit({
139
+ abortController: this.abortController,
140
+ playAudio: this.playAudio,
141
+ message: this.message,
142
+ updateState: this.updateState
143
+ }).defaultPrevented || (T("[nylas-summarize-message-button] Default event not prevented, summarizing message"), this.audioRef && (await this.audioRef.play().then(() => {
144
+ var a;
145
+ return (a = this.audioRef) == null ? void 0 : a.pause();
146
+ }).catch((a) => console.error("Error playing audio:", a)), await this.audioRef.play().catch((a) => console.error("Error playing audio:", a))))) : this.state === "playing" ? ((u = this.abortController) == null || u.abort(), (s = this.audioRef) == null || s.pause()) : this.state = "stopped";
147
+ }, this.message = void 0, this.state = "stopped", this.playAudio = this.playAudio.bind(this), this.updateState = this.updateState.bind(this);
148
+ }
149
+ connectedCallback() {
150
+ }
151
+ disconnectedCallback() {
152
+ }
153
+ async componentWillLoad() {
154
+ T("[nylas-summarize-message-button] Component will load");
155
+ }
156
+ async componentDidLoad() {
157
+ T("[nylas-summarize-message-button] Component did load");
158
+ }
159
+ async updateState(t) {
160
+ this.state = t;
161
+ }
162
+ async playAudio(t) {
163
+ if (!this.audioRef) {
164
+ this.state = "stopped";
165
+ return;
166
+ }
167
+ if (!t) {
168
+ this.state = "stopped";
169
+ return;
170
+ }
171
+ const o = this.audioRef;
172
+ if (!("MediaSource" in window)) {
173
+ const i = await t;
174
+ if (i == null)
175
+ throw new Error("ReadableStream not yet supported in this browser.");
176
+ const l = i.getReader(), E = [];
177
+ await this.readChunk(l, E);
178
+ const _ = new Blob(E, { type: "audio/mpeg" }), N = URL.createObjectURL(_);
179
+ o.src = N;
180
+ return;
181
+ }
182
+ const u = new MediaSource();
183
+ let s, m = !1;
184
+ o.src = URL.createObjectURL(u), u.addEventListener("sourceopen", a);
185
+ async function a() {
186
+ s = u.addSourceBuffer("audio/mpeg"), s.addEventListener("updateend", f);
187
+ const i = await t;
188
+ if (i == null)
189
+ throw new Error("ReadableStream not yet supported in this browser.");
190
+ const l = i.getReader(), E = () => {
191
+ l.read().then(({ done: _, value: N }) => {
192
+ if (_) {
193
+ m = !0;
194
+ return;
195
+ }
196
+ s.updating || s.appendBuffer(N), E();
197
+ }).catch((_) => {
198
+ console.error("Error while fetching and appending chunks:", _);
199
+ });
200
+ };
201
+ E(), o.paused && o.play().catch((_) => console.error("Error playing audio:", _));
202
+ }
203
+ function f() {
204
+ if (m) {
205
+ u.endOfStream(), u.removeEventListener("sourceopen", a), u.removeEventListener("sourceclose", () => {
206
+ T("[nylas-summarize-message-button] Source closed");
207
+ }), s.removeEventListener("updateend", f);
208
+ return;
209
+ }
210
+ }
211
+ }
212
+ async readChunk(t, o) {
213
+ return t.read().then(({ done: u, value: s }) => u ? o : (o.push(s), this.readChunk(t, o)));
214
+ }
215
+ render() {
216
+ return g($e, { key: "5af7b7da7418a01f4a45b6edcf014d9497ff9f32" }, g("sp-theme", { key: "9f883f57c7269b1f7f3de1010ebca9a01cbff35d", scale: "medium", color: "dark" }, g("sp-button", { key: "e2bb3acc0622e8e99592f1111305d093d6e83ade", label: "Summarize email", "icon-only": !0, onClickCapture: this.onClick, class: {
217
+ "summarize-button": !0,
218
+ stopped: this.state === "stopped",
219
+ loading: this.state === "loading",
220
+ playing: this.state === "playing"
221
+ } }, this.state === "stopped" && g("play-icon", null), this.state === "loading" && g("loading-icon", null), this.state === "playing" && g("stop-icon", null)), g("audio", { key: "d30e40f1cf34afe76c8b01eaa65e33bf296f9540", ref: (t) => this.audioRef = t, autoPlay: !0, onPlaying: () => this.state = "playing", onPause: () => this.state = "stopped", onEnded: () => {
222
+ this.state = "stopped", T("[nylas-summarize-message-button] Audio ended");
223
+ } })));
224
+ }
225
+ };
226
+ xn([
227
+ wn({
228
+ name: "nylas-summarize-message-button",
229
+ eventToProps: {
230
+ summarize: async (t, o) => {
231
+ const { playAudio: u, updateState: s, abortController: m, message: a } = t.detail, f = _n(a.body || "");
232
+ await s("loading");
233
+ try {
234
+ const i = await o.messages.summarizeText(f), l = o.messages.textToSpeech(i, m);
235
+ await u(l);
236
+ } catch (i) {
237
+ await s("stopped"), console.error("Error summarizing message:", i);
238
+ }
239
+ }
240
+ },
241
+ fireRegisterEvent: !0
242
+ }),
243
+ Be("design:type", Function),
244
+ Be("design:paramtypes", []),
245
+ Be("design:returntype", void 0)
246
+ ], kt.prototype, "render", null);
247
+ kt.style = Nn;
248
+ function P(t) {
249
+ return !window.matchMedia("(prefers-color-scheme: dark)").matches || !t ? t : t === "transparent" ? "color" : t.startsWith("#") ? Dn(t) : t.startsWith("rgb") ? Mt(t) : t.startsWith("hsl") ? On(t) : In(t) ? Pn(t) : t;
250
+ }
251
+ function Dn(t) {
252
+ t.length < 7 && (t = "#" + t[1] + t[1] + t[2] + t[2] + t[3] + t[3]);
253
+ const o = (255 - parseInt(t.slice(1, 3), 16)).toString(16).padStart(2, "0"), u = (255 - parseInt(t.slice(3, 5), 16)).toString(16).padStart(2, "0"), s = (255 - parseInt(t.slice(5, 7), 16)).toString(16).padStart(2, "0");
254
+ return `#${o}${u}${s}`;
255
+ }
256
+ function Mt(t) {
257
+ var a;
258
+ const o = (a = t.match(/\d+/g)) == null ? void 0 : a.map(Number);
259
+ if (!o)
260
+ return t;
261
+ const [u, s, m] = o;
262
+ return `rgb(${255 - u}, ${255 - s}, ${255 - m})`;
263
+ }
264
+ function On(t) {
265
+ var a;
266
+ const o = (a = t.match(/\d+\.?\d*/g)) == null ? void 0 : a.map(Number);
267
+ if (!o)
268
+ return t;
269
+ const [u, s, m] = o;
270
+ return `hsl(${u}, ${s}%, ${100 - m}%)`;
271
+ }
272
+ function In(t) {
273
+ return /^[a-z]+$/i.test(t);
274
+ }
275
+ function Pn(t) {
276
+ return Mt(Un(t));
277
+ }
278
+ function Un(t) {
279
+ return t.toLowerCase() === "red" ? "rgb(255, 0, 0)" : "rgb(0, 0, 0)";
280
+ }
281
+ function Lt(t) {
282
+ if (t instanceof HTMLStyleElement) {
283
+ let o = t.textContent;
284
+ if (o) {
285
+ o = o.replaceAll(/@media\s*\(prefers-color-scheme:\s*(dark|light)\)\s*\{([^}]+)\}/g, "");
286
+ const u = o.matchAll(/border-color:\s*([^;]+)/g);
287
+ if (u)
288
+ for (const i of u) {
289
+ const [l, E] = i, _ = l.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
290
+ o = o.replaceAll(_, l.replace(E, P(E)));
291
+ }
292
+ const s = o.matchAll(/border:\s*([^;]+)/g);
293
+ if (s)
294
+ for (const i of s) {
295
+ const l = i[0].trim(), E = l.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), [_, N, U] = i[1].split(" ");
296
+ o = o.replaceAll(E, l.replace(U, P(U)));
297
+ }
298
+ const m = o.matchAll(/background-color:\s*([^;]+)/g);
299
+ if (m)
300
+ for (const i of m) {
301
+ const [l, E] = i, _ = l.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
302
+ o = o.replaceAll(_, l.replace(E, P(E))), T("backgroundColor", { fullMatch: l, replace: l.replace(E, P(E)), color: E, invertColor: P(E) });
303
+ }
304
+ const a = o.matchAll(/background:\s*([^;]+)/g);
305
+ if (a)
306
+ for (const i of a) {
307
+ const l = i[0].trim(), E = l.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), [_, N, U] = i[1].split(" ");
308
+ o = o.replaceAll(E, l.replace(U, P(U)));
309
+ }
310
+ const f = o.matchAll(/color:\s*([^;]+)/g);
311
+ if (f)
312
+ for (const i of f) {
313
+ const [l, E] = i, _ = l.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
314
+ o = o.replaceAll(_, l.replace(E, P(E)));
315
+ }
316
+ t.textContent = o;
317
+ }
318
+ }
319
+ if (t instanceof HTMLElement) {
320
+ const o = window.getComputedStyle(t), u = o.color || t.style.color, s = o.backgroundColor || t.style.backgroundColor, m = o.borderColor || t.style.borderColor;
321
+ u && !s ? t.style.color = "" : u && s ? (t.style.color = P(u), t.style.backgroundColor = P(s), T("element", t), T("computedStyle.color", u), T("computedStyle.backgroundColor", s), T("invertColor(color)", P(u)), T("invertColor(backgroundColor)", P(s))) : !u && s && (t.style.backgroundColor = ""), m && (T("borderColor", m), t.style.borderColor = P(m)), t.hasAttribute("bgcolor") && t.removeAttribute("bgcolor");
322
+ }
323
+ }
324
+ function zn(t) {
325
+ Lt(t), t.querySelectorAll("*").forEach((u) => Lt(u));
326
+ }
327
+ var Nt = { exports: {} };
328
+ /*! @license DOMPurify 3.0.8 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.8/LICENSE */
329
+ (function(t, o) {
330
+ (function(u, s) {
331
+ t.exports = s();
332
+ })(yn, function() {
333
+ const {
334
+ entries: u,
335
+ setPrototypeOf: s,
336
+ isFrozen: m,
337
+ getPrototypeOf: a,
338
+ getOwnPropertyDescriptor: f
339
+ } = Object;
340
+ let {
341
+ freeze: i,
342
+ seal: l,
343
+ create: E
344
+ } = Object, {
345
+ apply: _,
346
+ construct: N
347
+ } = typeof Reflect < "u" && Reflect;
348
+ i || (i = function(c) {
349
+ return c;
350
+ }), l || (l = function(c) {
351
+ return c;
352
+ }), _ || (_ = function(c, b, h) {
353
+ return c.apply(b, h);
354
+ }), N || (N = function(c, b) {
355
+ return new c(...b);
356
+ });
357
+ const U = I(Array.prototype.forEach), de = I(Array.prototype.pop), G = I(Array.prototype.push), X = I(String.prototype.toLowerCase), oe = I(String.prototype.toString), Ee = I(String.prototype.match), W = I(String.prototype.replace), xt = I(String.prototype.indexOf), Dt = I(String.prototype.trim), O = I(RegExp.prototype.test), ie = Ot(TypeError);
358
+ function I(y) {
359
+ return function(c) {
360
+ for (var b = arguments.length, h = new Array(b > 1 ? b - 1 : 0), k = 1; k < b; k++)
361
+ h[k - 1] = arguments[k];
362
+ return _(y, c, h);
363
+ };
364
+ }
365
+ function Ot(y) {
366
+ return function() {
367
+ for (var c = arguments.length, b = new Array(c), h = 0; h < c; h++)
368
+ b[h] = arguments[h];
369
+ return N(y, b);
370
+ };
371
+ }
372
+ function p(y, c) {
373
+ let b = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : X;
374
+ s && s(y, null);
375
+ let h = c.length;
376
+ for (; h--; ) {
377
+ let k = c[h];
378
+ if (typeof k == "string") {
379
+ const F = b(k);
380
+ F !== k && (m(c) || (c[h] = F), k = F);
381
+ }
382
+ y[k] = !0;
383
+ }
384
+ return y;
385
+ }
386
+ function It(y) {
387
+ for (let c = 0; c < y.length; c++)
388
+ f(y, c) === void 0 && (y[c] = null);
389
+ return y;
390
+ }
391
+ function $(y) {
392
+ const c = E(null);
393
+ for (const [b, h] of u(y))
394
+ f(y, b) !== void 0 && (Array.isArray(h) ? c[b] = It(h) : h && typeof h == "object" && h.constructor === Object ? c[b] = $(h) : c[b] = h);
395
+ return c;
396
+ }
397
+ function ue(y, c) {
398
+ for (; y !== null; ) {
399
+ const h = f(y, c);
400
+ if (h) {
401
+ if (h.get)
402
+ return I(h.get);
403
+ if (typeof h.value == "function")
404
+ return I(h.value);
405
+ }
406
+ y = a(y);
407
+ }
408
+ function b(h) {
409
+ return console.warn("fallback value for", h), null;
410
+ }
411
+ return b;
412
+ }
413
+ const qe = i(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "section", "select", "shadow", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Te = i(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Ae = i(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), Pt = i(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), _e = i(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), Ut = i(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Ye = i(["#text"]), je = i(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "pattern", "placeholder", "playsinline", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "xmlns", "slot"]), we = i(["accent-height", "accumulate", "additive", "alignment-baseline", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), Xe = i(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), fe = i(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), zt = l(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Ft = l(/<%[\w\W]*|[\w\W]*%>/gm), Ht = l(/\${[\w\W]*}/gm), Bt = l(/^data-[\-\w.\u00B7-\uFFFF]/), Wt = l(/^aria-[\-\w]+$/), Ve = l(
414
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
415
+ // eslint-disable-line no-useless-escape
416
+ ), Gt = l(/^(?:\w+script|data):/i), $t = l(
417
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
418
+ // eslint-disable-line no-control-regex
419
+ ), Ze = l(/^html$/i);
420
+ var Ke = /* @__PURE__ */ Object.freeze({
421
+ __proto__: null,
422
+ MUSTACHE_EXPR: zt,
423
+ ERB_EXPR: Ft,
424
+ TMPLIT_EXPR: Ht,
425
+ DATA_ATTR: Bt,
426
+ ARIA_ATTR: Wt,
427
+ IS_ALLOWED_URI: Ve,
428
+ IS_SCRIPT_OR_DATA: Gt,
429
+ ATTR_WHITESPACE: $t,
430
+ DOCTYPE_NAME: Ze
431
+ });
432
+ const qt = function() {
433
+ return typeof window > "u" ? null : window;
434
+ }, Yt = function(c, b) {
435
+ if (typeof c != "object" || typeof c.createPolicy != "function")
436
+ return null;
437
+ let h = null;
438
+ const k = "data-tt-policy-suffix";
439
+ b && b.hasAttribute(k) && (h = b.getAttribute(k));
440
+ const F = "dompurify" + (h ? "#" + h : "");
441
+ try {
442
+ return c.createPolicy(F, {
443
+ createHTML(V) {
444
+ return V;
445
+ },
446
+ createScriptURL(V) {
447
+ return V;
448
+ }
449
+ });
450
+ } catch {
451
+ return console.warn("TrustedTypes policy " + F + " could not be created."), null;
452
+ }
453
+ };
454
+ function Qe() {
455
+ let y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : qt();
456
+ const c = (d) => Qe(d);
457
+ if (c.version = "3.0.8", c.removed = [], !y || !y.document || y.document.nodeType !== 9)
458
+ return c.isSupported = !1, c;
459
+ let {
460
+ document: b
461
+ } = y;
462
+ const h = b, k = h.currentScript, {
463
+ DocumentFragment: F,
464
+ HTMLTemplateElement: V,
465
+ Node: ve,
466
+ Element: Je,
467
+ NodeFilter: Se,
468
+ NamedNodeMap: Xt = y.NamedNodeMap || y.MozNamedAttrMap,
469
+ HTMLFormElement: Vt,
470
+ DOMParser: Zt,
471
+ trustedTypes: me
472
+ } = y, pe = Je.prototype, Kt = ue(pe, "cloneNode"), Qt = ue(pe, "nextSibling"), Jt = ue(pe, "childNodes"), Ce = ue(pe, "parentNode");
473
+ if (typeof V == "function") {
474
+ const d = b.createElement("template");
475
+ d.content && d.content.ownerDocument && (b = d.content.ownerDocument);
476
+ }
477
+ let M, ae = "";
478
+ const {
479
+ implementation: Le,
480
+ createNodeIterator: en,
481
+ createDocumentFragment: tn,
482
+ getElementsByTagName: nn
483
+ } = b, {
484
+ importNode: on
485
+ } = h;
486
+ let z = {};
487
+ c.isSupported = typeof u == "function" && typeof Ce == "function" && Le && Le.createHTMLDocument !== void 0;
488
+ const {
489
+ MUSTACHE_EXPR: Re,
490
+ ERB_EXPR: ke,
491
+ TMPLIT_EXPR: Me,
492
+ DATA_ATTR: an,
493
+ ARIA_ATTR: rn,
494
+ IS_SCRIPT_OR_DATA: sn,
495
+ ATTR_WHITESPACE: et
496
+ } = Ke;
497
+ let {
498
+ IS_ALLOWED_URI: tt
499
+ } = Ke, v = null;
500
+ const nt = p({}, [...qe, ...Te, ...Ae, ..._e, ...Ye]);
501
+ let S = null;
502
+ const ot = p({}, [...je, ...we, ...Xe, ...fe]);
503
+ let w = Object.seal(E(null, {
504
+ tagNameCheck: {
505
+ writable: !0,
506
+ configurable: !1,
507
+ enumerable: !0,
508
+ value: null
509
+ },
510
+ attributeNameCheck: {
511
+ writable: !0,
512
+ configurable: !1,
513
+ enumerable: !0,
514
+ value: null
515
+ },
516
+ allowCustomizedBuiltInElements: {
517
+ writable: !0,
518
+ configurable: !1,
519
+ enumerable: !0,
520
+ value: !1
521
+ }
522
+ })), re = null, Ne = null, it = !0, xe = !0, at = !1, rt = !0, Z = !1, q = !1, De = !1, Oe = !1, K = !1, he = !1, ge = !1, st = !0, lt = !1;
523
+ const ln = "user-content-";
524
+ let Ie = !0, se = !1, Q = {}, J = null;
525
+ const ct = p({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
526
+ let dt = null;
527
+ const ut = p({}, ["audio", "video", "img", "source", "image", "track"]);
528
+ let Pe = null;
529
+ const ft = p({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), ye = "http://www.w3.org/1998/Math/MathML", be = "http://www.w3.org/2000/svg", H = "http://www.w3.org/1999/xhtml";
530
+ let ee = H, Ue = !1, ze = null;
531
+ const cn = p({}, [ye, be, H], oe);
532
+ let le = null;
533
+ const dn = ["application/xhtml+xml", "text/html"], un = "text/html";
534
+ let C = null, te = null;
535
+ const fn = b.createElement("form"), mt = function(e) {
536
+ return e instanceof RegExp || e instanceof Function;
537
+ }, Fe = function() {
538
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
539
+ if (!(te && te === e)) {
540
+ if ((!e || typeof e != "object") && (e = {}), e = $(e), le = // eslint-disable-next-line unicorn/prefer-includes
541
+ dn.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? un : e.PARSER_MEDIA_TYPE, C = le === "application/xhtml+xml" ? oe : X, v = "ALLOWED_TAGS" in e ? p({}, e.ALLOWED_TAGS, C) : nt, S = "ALLOWED_ATTR" in e ? p({}, e.ALLOWED_ATTR, C) : ot, ze = "ALLOWED_NAMESPACES" in e ? p({}, e.ALLOWED_NAMESPACES, oe) : cn, Pe = "ADD_URI_SAFE_ATTR" in e ? p(
542
+ $(ft),
543
+ // eslint-disable-line indent
544
+ e.ADD_URI_SAFE_ATTR,
545
+ // eslint-disable-line indent
546
+ C
547
+ // eslint-disable-line indent
548
+ ) : ft, dt = "ADD_DATA_URI_TAGS" in e ? p(
549
+ $(ut),
550
+ // eslint-disable-line indent
551
+ e.ADD_DATA_URI_TAGS,
552
+ // eslint-disable-line indent
553
+ C
554
+ // eslint-disable-line indent
555
+ ) : ut, J = "FORBID_CONTENTS" in e ? p({}, e.FORBID_CONTENTS, C) : ct, re = "FORBID_TAGS" in e ? p({}, e.FORBID_TAGS, C) : {}, Ne = "FORBID_ATTR" in e ? p({}, e.FORBID_ATTR, C) : {}, Q = "USE_PROFILES" in e ? e.USE_PROFILES : !1, it = e.ALLOW_ARIA_ATTR !== !1, xe = e.ALLOW_DATA_ATTR !== !1, at = e.ALLOW_UNKNOWN_PROTOCOLS || !1, rt = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, Z = e.SAFE_FOR_TEMPLATES || !1, q = e.WHOLE_DOCUMENT || !1, K = e.RETURN_DOM || !1, he = e.RETURN_DOM_FRAGMENT || !1, ge = e.RETURN_TRUSTED_TYPE || !1, Oe = e.FORCE_BODY || !1, st = e.SANITIZE_DOM !== !1, lt = e.SANITIZE_NAMED_PROPS || !1, Ie = e.KEEP_CONTENT !== !1, se = e.IN_PLACE || !1, tt = e.ALLOWED_URI_REGEXP || Ve, ee = e.NAMESPACE || H, w = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && mt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (w.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && mt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (w.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (w.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), Z && (xe = !1), he && (K = !0), Q && (v = p({}, Ye), S = [], Q.html === !0 && (p(v, qe), p(S, je)), Q.svg === !0 && (p(v, Te), p(S, we), p(S, fe)), Q.svgFilters === !0 && (p(v, Ae), p(S, we), p(S, fe)), Q.mathMl === !0 && (p(v, _e), p(S, Xe), p(S, fe))), e.ADD_TAGS && (v === nt && (v = $(v)), p(v, e.ADD_TAGS, C)), e.ADD_ATTR && (S === ot && (S = $(S)), p(S, e.ADD_ATTR, C)), e.ADD_URI_SAFE_ATTR && p(Pe, e.ADD_URI_SAFE_ATTR, C), e.FORBID_CONTENTS && (J === ct && (J = $(J)), p(J, e.FORBID_CONTENTS, C)), Ie && (v["#text"] = !0), q && p(v, ["html", "head", "body"]), v.table && (p(v, ["tbody"]), delete re.tbody), e.TRUSTED_TYPES_POLICY) {
556
+ if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function")
557
+ throw ie('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
558
+ if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function")
559
+ throw ie('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
560
+ M = e.TRUSTED_TYPES_POLICY, ae = M.createHTML("");
561
+ } else
562
+ M === void 0 && (M = Yt(me, k)), M !== null && typeof ae == "string" && (ae = M.createHTML(""));
563
+ i && i(e), te = e;
564
+ }
565
+ }, pt = p({}, ["mi", "mo", "mn", "ms", "mtext"]), ht = p({}, ["foreignobject", "desc", "title", "annotation-xml"]), mn = p({}, ["title", "style", "font", "a", "script"]), gt = p({}, [...Te, ...Ae, ...Pt]), yt = p({}, [..._e, ...Ut]), pn = function(e) {
566
+ let n = Ce(e);
567
+ (!n || !n.tagName) && (n = {
568
+ namespaceURI: ee,
569
+ tagName: "template"
570
+ });
571
+ const r = X(e.tagName), A = X(n.tagName);
572
+ return ze[e.namespaceURI] ? e.namespaceURI === be ? n.namespaceURI === H ? r === "svg" : n.namespaceURI === ye ? r === "svg" && (A === "annotation-xml" || pt[A]) : !!gt[r] : e.namespaceURI === ye ? n.namespaceURI === H ? r === "math" : n.namespaceURI === be ? r === "math" && ht[A] : !!yt[r] : e.namespaceURI === H ? n.namespaceURI === be && !ht[A] || n.namespaceURI === ye && !pt[A] ? !1 : !yt[r] && (mn[r] || !gt[r]) : !!(le === "application/xhtml+xml" && ze[e.namespaceURI]) : !1;
573
+ }, Y = function(e) {
574
+ G(c.removed, {
575
+ element: e
576
+ });
577
+ try {
578
+ e.parentNode.removeChild(e);
579
+ } catch {
580
+ e.remove();
581
+ }
582
+ }, He = function(e, n) {
583
+ try {
584
+ G(c.removed, {
585
+ attribute: n.getAttributeNode(e),
586
+ from: n
587
+ });
588
+ } catch {
589
+ G(c.removed, {
590
+ attribute: null,
591
+ from: n
592
+ });
593
+ }
594
+ if (n.removeAttribute(e), e === "is" && !S[e])
595
+ if (K || he)
596
+ try {
597
+ Y(n);
598
+ } catch {
599
+ }
600
+ else
601
+ try {
602
+ n.setAttribute(e, "");
603
+ } catch {
604
+ }
605
+ }, bt = function(e) {
606
+ let n = null, r = null;
607
+ if (Oe)
608
+ e = "<remove></remove>" + e;
609
+ else {
610
+ const R = Ee(e, /^[\r\n\t ]+/);
611
+ r = R && R[0];
612
+ }
613
+ le === "application/xhtml+xml" && ee === H && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>");
614
+ const A = M ? M.createHTML(e) : e;
615
+ if (ee === H)
616
+ try {
617
+ n = new Zt().parseFromString(A, le);
618
+ } catch {
619
+ }
620
+ if (!n || !n.documentElement) {
621
+ n = Le.createDocument(ee, "template", null);
622
+ try {
623
+ n.documentElement.innerHTML = Ue ? ae : A;
624
+ } catch {
625
+ }
626
+ }
627
+ const L = n.body || n.documentElement;
628
+ return e && r && L.insertBefore(b.createTextNode(r), L.childNodes[0] || null), ee === H ? nn.call(n, q ? "html" : "body")[0] : q ? n.documentElement : L;
629
+ }, Et = function(e) {
630
+ return en.call(
631
+ e.ownerDocument || e,
632
+ e,
633
+ // eslint-disable-next-line no-bitwise
634
+ Se.SHOW_ELEMENT | Se.SHOW_COMMENT | Se.SHOW_TEXT,
635
+ null
636
+ );
637
+ }, hn = function(e) {
638
+ return e instanceof Vt && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof Xt) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
639
+ }, Tt = function(e) {
640
+ return typeof ve == "function" && e instanceof ve;
641
+ }, B = function(e, n, r) {
642
+ z[e] && U(z[e], (A) => {
643
+ A.call(c, n, r, te);
644
+ });
645
+ }, At = function(e) {
646
+ let n = null;
647
+ if (B("beforeSanitizeElements", e, null), hn(e))
648
+ return Y(e), !0;
649
+ const r = C(e.nodeName);
650
+ if (B("uponSanitizeElement", e, {
651
+ tagName: r,
652
+ allowedTags: v
653
+ }), e.hasChildNodes() && !Tt(e.firstElementChild) && O(/<[/\w]/g, e.innerHTML) && O(/<[/\w]/g, e.textContent))
654
+ return Y(e), !0;
655
+ if (!v[r] || re[r]) {
656
+ if (!re[r] && wt(r) && (w.tagNameCheck instanceof RegExp && O(w.tagNameCheck, r) || w.tagNameCheck instanceof Function && w.tagNameCheck(r)))
657
+ return !1;
658
+ if (Ie && !J[r]) {
659
+ const A = Ce(e) || e.parentNode, L = Jt(e) || e.childNodes;
660
+ if (L && A) {
661
+ const R = L.length;
662
+ for (let x = R - 1; x >= 0; --x)
663
+ A.insertBefore(Kt(L[x], !0), Qt(e));
664
+ }
665
+ }
666
+ return Y(e), !0;
667
+ }
668
+ return e instanceof Je && !pn(e) || (r === "noscript" || r === "noembed" || r === "noframes") && O(/<\/no(script|embed|frames)/i, e.innerHTML) ? (Y(e), !0) : (Z && e.nodeType === 3 && (n = e.textContent, U([Re, ke, Me], (A) => {
669
+ n = W(n, A, " ");
670
+ }), e.textContent !== n && (G(c.removed, {
671
+ element: e.cloneNode()
672
+ }), e.textContent = n)), B("afterSanitizeElements", e, null), !1);
673
+ }, _t = function(e, n, r) {
674
+ if (st && (n === "id" || n === "name") && (r in b || r in fn))
675
+ return !1;
676
+ if (!(xe && !Ne[n] && O(an, n))) {
677
+ if (!(it && O(rn, n))) {
678
+ if (!S[n] || Ne[n]) {
679
+ if (
680
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
681
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
682
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
683
+ !(wt(e) && (w.tagNameCheck instanceof RegExp && O(w.tagNameCheck, e) || w.tagNameCheck instanceof Function && w.tagNameCheck(e)) && (w.attributeNameCheck instanceof RegExp && O(w.attributeNameCheck, n) || w.attributeNameCheck instanceof Function && w.attributeNameCheck(n)) || // Alternative, second condition checks if it's an `is`-attribute, AND
684
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
685
+ n === "is" && w.allowCustomizedBuiltInElements && (w.tagNameCheck instanceof RegExp && O(w.tagNameCheck, r) || w.tagNameCheck instanceof Function && w.tagNameCheck(r)))
686
+ )
687
+ return !1;
688
+ } else if (!Pe[n]) {
689
+ if (!O(tt, W(r, et, ""))) {
690
+ if (!((n === "src" || n === "xlink:href" || n === "href") && e !== "script" && xt(r, "data:") === 0 && dt[e])) {
691
+ if (!(at && !O(sn, W(r, et, "")))) {
692
+ if (r)
693
+ return !1;
694
+ }
695
+ }
696
+ }
697
+ }
698
+ }
699
+ }
700
+ return !0;
701
+ }, wt = function(e) {
702
+ return e.indexOf("-") > 0;
703
+ }, vt = function(e) {
704
+ B("beforeSanitizeAttributes", e, null);
705
+ const {
706
+ attributes: n
707
+ } = e;
708
+ if (!n)
709
+ return;
710
+ const r = {
711
+ attrName: "",
712
+ attrValue: "",
713
+ keepAttr: !0,
714
+ allowedAttributes: S
715
+ };
716
+ let A = n.length;
717
+ for (; A--; ) {
718
+ const L = n[A], {
719
+ name: R,
720
+ namespaceURI: x,
721
+ value: j
722
+ } = L, ce = C(R);
723
+ let D = R === "value" ? j : Dt(j);
724
+ if (r.attrName = ce, r.attrValue = D, r.keepAttr = !0, r.forceKeepAttr = void 0, B("uponSanitizeAttribute", e, r), D = r.attrValue, r.forceKeepAttr || (He(R, e), !r.keepAttr))
725
+ continue;
726
+ if (!rt && O(/\/>/i, D)) {
727
+ He(R, e);
728
+ continue;
729
+ }
730
+ Z && U([Re, ke, Me], (Ct) => {
731
+ D = W(D, Ct, " ");
732
+ });
733
+ const St = C(e.nodeName);
734
+ if (_t(St, ce, D)) {
735
+ if (lt && (ce === "id" || ce === "name") && (He(R, e), D = ln + D), M && typeof me == "object" && typeof me.getAttributeType == "function" && !x)
736
+ switch (me.getAttributeType(St, ce)) {
737
+ case "TrustedHTML": {
738
+ D = M.createHTML(D);
739
+ break;
740
+ }
741
+ case "TrustedScriptURL": {
742
+ D = M.createScriptURL(D);
743
+ break;
744
+ }
745
+ }
746
+ try {
747
+ x ? e.setAttributeNS(x, R, D) : e.setAttribute(R, D), de(c.removed);
748
+ } catch {
749
+ }
750
+ }
751
+ }
752
+ B("afterSanitizeAttributes", e, null);
753
+ }, gn = function d(e) {
754
+ let n = null;
755
+ const r = Et(e);
756
+ for (B("beforeSanitizeShadowDOM", e, null); n = r.nextNode(); )
757
+ B("uponSanitizeShadowNode", n, null), !At(n) && (n.content instanceof F && d(n.content), vt(n));
758
+ B("afterSanitizeShadowDOM", e, null);
759
+ };
760
+ return c.sanitize = function(d) {
761
+ let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = null, r = null, A = null, L = null;
762
+ if (Ue = !d, Ue && (d = "<!-->"), typeof d != "string" && !Tt(d))
763
+ if (typeof d.toString == "function") {
764
+ if (d = d.toString(), typeof d != "string")
765
+ throw ie("dirty is not a string, aborting");
766
+ } else
767
+ throw ie("toString is not a function");
768
+ if (!c.isSupported)
769
+ return d;
770
+ if (De || Fe(e), c.removed = [], typeof d == "string" && (se = !1), se) {
771
+ if (d.nodeName) {
772
+ const j = C(d.nodeName);
773
+ if (!v[j] || re[j])
774
+ throw ie("root node is forbidden and cannot be sanitized in-place");
775
+ }
776
+ } else if (d instanceof ve)
777
+ n = bt("<!---->"), r = n.ownerDocument.importNode(d, !0), r.nodeType === 1 && r.nodeName === "BODY" || r.nodeName === "HTML" ? n = r : n.appendChild(r);
778
+ else {
779
+ if (!K && !Z && !q && // eslint-disable-next-line unicorn/prefer-includes
780
+ d.indexOf("<") === -1)
781
+ return M && ge ? M.createHTML(d) : d;
782
+ if (n = bt(d), !n)
783
+ return K ? null : ge ? ae : "";
784
+ }
785
+ n && Oe && Y(n.firstChild);
786
+ const R = Et(se ? d : n);
787
+ for (; A = R.nextNode(); )
788
+ At(A) || (A.content instanceof F && gn(A.content), vt(A));
789
+ if (se)
790
+ return d;
791
+ if (K) {
792
+ if (he)
793
+ for (L = tn.call(n.ownerDocument); n.firstChild; )
794
+ L.appendChild(n.firstChild);
795
+ else
796
+ L = n;
797
+ return (S.shadowroot || S.shadowrootmode) && (L = on.call(h, L, !0)), L;
798
+ }
799
+ let x = q ? n.outerHTML : n.innerHTML;
800
+ return q && v["!doctype"] && n.ownerDocument && n.ownerDocument.doctype && n.ownerDocument.doctype.name && O(Ze, n.ownerDocument.doctype.name) && (x = "<!DOCTYPE " + n.ownerDocument.doctype.name + `>
801
+ ` + x), Z && U([Re, ke, Me], (j) => {
802
+ x = W(x, j, " ");
803
+ }), M && ge ? M.createHTML(x) : x;
804
+ }, c.setConfig = function() {
805
+ let d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
806
+ Fe(d), De = !0;
807
+ }, c.clearConfig = function() {
808
+ te = null, De = !1;
809
+ }, c.isValidAttribute = function(d, e, n) {
810
+ te || Fe({});
811
+ const r = C(d), A = C(e);
812
+ return _t(r, A, n);
813
+ }, c.addHook = function(d, e) {
814
+ typeof e == "function" && (z[d] = z[d] || [], G(z[d], e));
815
+ }, c.removeHook = function(d) {
816
+ if (z[d])
817
+ return de(z[d]);
818
+ }, c.removeHooks = function(d) {
819
+ z[d] && (z[d] = []);
820
+ }, c.removeAllHooks = function() {
821
+ z = {};
822
+ }, c;
823
+ }
824
+ var jt = Qe();
825
+ return jt;
826
+ });
827
+ })(Nt);
828
+ const Ge = Nt.exports, Fn = ":host{display:inline-grid;overflow:hidden;width:100%}.view-email{width:100%}.view-email div.gmail_quote{display:none;color:var(--nylas-color-primary-400)}.view-email div.gmail_quote.show{display:block}.view-email blockquote{border-color:var(--nylas-color-primary-500) !important}.view-email .nylas-view-email-toggle-button{display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600);border:0;border-radius:2px;font-size:14px;font-weight:500;line-height:1.5;transition:all 0.2s ease-in-out}.view-email .nylas-view-email-toggle-button:hover{background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600)}", Hn = Fn;
829
+ Ge.addHook("afterSanitizeAttributes", function(t) {
830
+ "target" in t && (t.setAttribute("target", "_blank"), t.setAttribute("rel", "noopener"));
831
+ });
832
+ const Bn = class {
833
+ constructor(t) {
834
+ ne(this, t), this.htmlElement = document.createElement("html"), this.setBody = (o) => {
835
+ var m;
836
+ this.state = "loading", this.styles = [], this.hoistedFontURLs = /* @__PURE__ */ new Map(), this.sanitizedBody = "", document.querySelectorAll(".nylas-view-email-font").forEach((a) => {
837
+ a.remove();
838
+ }), (this.message ? bn(this.message) : En(o)) || (o = `<html><body>${Tn(o)}</body></html>`), this.htmlElement.innerHTML = o, this.detectDarkMode && zn(this.htmlElement), this.htmlElement.querySelectorAll("link").forEach((a) => {
839
+ if (console.debug(`[nylas-view-email] Hoisting link: ${a.getAttribute("href")}`), a.getAttribute("rel") === "stylesheet" && a.getAttribute("href")) {
840
+ const f = a.getAttribute("href");
841
+ if (f) {
842
+ const i = new URL(f, window.location.href);
843
+ (i.protocol === "https:" || i.protocol === "http:") && this.hoistedFontURLs.set(i.href, i.href);
844
+ }
845
+ }
846
+ }), this.htmlElement.querySelectorAll("style").forEach((a) => {
847
+ a.innerHTML.split(`
848
+ `).forEach((f) => {
849
+ const i = f.match(/@import url\((.*)\)/);
850
+ if (i) {
851
+ const l = new URL(i[1], window.location.href);
852
+ (l.protocol === "https:" || l.protocol === "http:") && this.hoistedFontURLs.set(l.href, l.href);
853
+ }
854
+ }), a.innerHTML = a.innerHTML.replace("body", ":host"), this.styles.push(a), a.remove();
855
+ }), this.htmlElement.querySelectorAll("a").forEach((a) => {
856
+ a.setAttribute("target", "_blank");
857
+ });
858
+ const s = this.htmlElement.querySelector(".gmail_quote");
859
+ if (s) {
860
+ const a = document.createElement("button");
861
+ a.classList.add("nylas-view-email-toggle-button"), a.setAttribute("aria-label", "Show quoted text"), a.innerText = "...", (m = s.parentElement) == null || m.insertBefore(a, s);
862
+ }
863
+ this.sanitizedBody = Ge.sanitize(this.htmlElement.innerHTML), this.hoistedFontURLs.forEach((a, f) => {
864
+ const i = document.createElement("link");
865
+ i.setAttribute("rel", "stylesheet"), i.setAttribute("href", a), i.classList.add("nylas-view-email-font"), document.head.appendChild(i);
866
+ }), this.state = "ready";
867
+ }, this.handleMobileSize = () => {
868
+ var u, s, m, a;
869
+ const o = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
870
+ if (o <= 768) {
871
+ const f = (u = this.viewEmailElement) == null ? void 0 : u.getBoundingClientRect();
872
+ if (f && this.viewEmailElement && this.parent && f.width > o) {
873
+ const i = this.parent, l = i == null ? void 0 : i.getBoundingClientRect();
874
+ T("Parent width:", l == null ? void 0 : l.width, "Parent height:", l == null ? void 0 : l.height), T("Parent client width:", i.clientWidth, "Parent client height:", i.clientHeight);
875
+ const E = l.width / f.width, _ = l.height / f.height, N = Math.min(E, _);
876
+ T("Scale:", N), this.viewEmailElement.style.setProperty("transform", `scale(${N})`), this.viewEmailElement.style.setProperty("transform-origin", "top left"), this.viewEmailElement.style.setProperty("height", `${f.height * N}px`);
877
+ }
878
+ } else
879
+ (s = this.viewEmailElement) == null || s.style.removeProperty("transform"), (m = this.viewEmailElement) == null || m.style.removeProperty("transform-origin"), (a = this.viewEmailElement) == null || a.style.removeProperty("height");
880
+ }, this.message = void 0, this.parent = void 0, this.attachments = [], this.detectDarkMode = !0, this.state = "loading", this.sanitizedBody = "", this.styles = [], this.viewEmailElement = void 0, this.hoistedFontURLs = /* @__PURE__ */ new Map();
881
+ }
882
+ connectedCallback() {
883
+ }
884
+ disconnectedCallback() {
885
+ T("[nylas-view-email] Component disconnected"), this.state = "loading", this.styles = [], this.hoistedFontURLs = /* @__PURE__ */ new Map(), this.sanitizedBody = "", document.querySelectorAll(".nylas-view-email-font").forEach((t) => {
886
+ t.remove();
887
+ });
888
+ }
889
+ async componentWillLoad() {
890
+ var t;
891
+ T("[nylas-view-email] component loaded"), this.setBody(((t = this.message) == null ? void 0 : t.body) ?? "");
892
+ }
893
+ async componentDidLoad() {
894
+ T("[nylas-view-thread] Component did load"), this.handleMobileSize();
895
+ }
896
+ async messageChanged() {
897
+ var t;
898
+ T("[nylas-view-thread] Message changed", { message: this.message }), this.setBody(((t = this.message) == null ? void 0 : t.body) ?? "");
899
+ }
900
+ handleScroll() {
901
+ this.handleMobileSize();
902
+ }
903
+ viewEmailElementChanged() {
904
+ var o;
905
+ const t = (o = this.viewEmailElement) == null ? void 0 : o.querySelectorAll(".nylas-view-email-toggle-button");
906
+ t && t.forEach((u) => {
907
+ u.addEventListener("click", () => {
908
+ var m;
909
+ const s = (m = this.viewEmailElement) == null ? void 0 : m.querySelector(".gmail_quote");
910
+ s && s.classList.toggle("show");
911
+ });
912
+ });
913
+ }
914
+ render() {
915
+ return console.debug("[nylas-view-email] render", { hoistedFontURLs: this.hoistedFontURLs }), g($e, { key: "ecedadf6b878ff1d039cae3e925090e0e4d1dc44" }, this.state === "loading" && g("div", null, "Loading..."), this.state === "ready" && g(An, null, this.styles.map((t) => g("style", null, Ge.sanitize(t.innerHTML))), g("div", { class: "view-email", part: "view-email", innerHTML: this.sanitizedBody, ref: (t) => this.viewEmailElement = t })));
916
+ }
917
+ get host() {
918
+ return Rt(this);
919
+ }
920
+ static get watchers() {
921
+ return {
922
+ message: ["messageChanged"],
923
+ viewEmailElement: ["viewEmailElementChanged"]
924
+ };
925
+ }
926
+ };
927
+ Bn.style = Hn;
928
+ const Wn = ".sc-reply-all-icon-h{display:flex}", Gn = Wn, $n = class {
929
+ constructor(t) {
930
+ ne(this, t), this.width = "15", this.height = "15";
931
+ }
932
+ render() {
933
+ return g("svg", { key: "b8fb356885e07f48e1a5537d0dacf54f867be2a7", fill: "auto", width: this.width, height: this.height, viewBox: "0 0 1920 1920", xmlns: "http://www.w3.org/2000/svg" }, g("path", { key: "8a28c9e8999c13ad06db8efab5536a439b9f9372", d: "m1030.975 188 81.249 81.249-429.228 429.228h300.747c516.223 0 936.257 420.034 936.257 936.257v98.028h-114.92v-98.028c0-452.901-368.436-821.337-821.337-821.337H682.996l429.228 429.229-81.25 81.248-567.936-567.937L1030.975 188Zm-463.038.011 81.249 81.25-486.688 486.688 486.688 486.688-81.249 81.249L0 755.949 567.937 188.01Z", "fill-rule": "evenodd" }));
934
+ }
935
+ };
936
+ $n.style = Gn;
937
+ const qn = ".sc-reply-icon-h{display:flex}", Yn = qn, jn = class {
938
+ constructor(t) {
939
+ ne(this, t), this.width = "15", this.height = "15";
940
+ }
941
+ render() {
942
+ return g("svg", { key: "a3dc84638dff446a5230e2b90b1ae62122e13758", fill: "auto", width: this.width, height: this.height, viewBox: "0 0 1920 1920", xmlns: "http://www.w3.org/2000/svg" }, g("path", { key: "1e1413257b4753f020e961ce56f0681f4eb597a7", d: "M835.942 632.563H244.966l478.08-478.08-90.496-90.496L-.026 696.563 632.55 1329.14l90.496-90.496-478.08-478.08h590.976c504.448 0 914.816 410.368 914.816 914.816v109.184h128V1675.38c0-574.976-467.84-1042.816-1042.816-1042.816", "fill-rule": "evenodd" }));
943
+ }
944
+ };
945
+ jn.style = Yn;
946
+ export {
947
+ Cn as forward_icon,
948
+ kn as nylas_composer,
949
+ kt as nylas_summarize_message_button,
950
+ Bn as nylas_view_email,
951
+ $n as reply_all_icon,
952
+ jn as reply_icon
953
+ };