@trycourier/courier-ui-inbox 1.0.1-beta → 1.0.3-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/courier-inbox-list-item.d.ts +1 -1
- package/dist/components/courier-inbox-list.d.ts +1 -1
- package/dist/datastore/datastore.d.ts +27 -7
- package/dist/datastore/datatore-events.d.ts +1 -1
- package/dist/index.es.js +1744 -813
- package/dist/index.umd.js +199 -69
- package/dist/types/factories.d.ts +1 -1
- package/dist/types/inbox-data-set.d.ts +1 -1
- package/dist/utils/extensions.d.ts +1 -1
- package/package.json +5 -4
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,910 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var a = (
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var qo = Object.defineProperty;
|
|
2
|
+
var Vo = (h, t, e) => t in h ? qo(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e;
|
|
3
|
+
var a = (h, t, e) => Vo(h, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
var jo = Object.defineProperty, Zo = (h, t, e) => t in h ? jo(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, T = (h, t, e) => Zo(h, typeof t != "symbol" ? t + "" : t, e);
|
|
5
|
+
const ko = class wo {
|
|
6
|
+
constructor(t, e) {
|
|
7
|
+
T(this, "webSocket", null), T(this, "pingInterval", null), T(this, "onOpen"), T(this, "onMessageReceived"), T(this, "onClose"), T(this, "onError"), T(this, "url"), T(this, "options"), this.url = t, this.options = e;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Dynamically checks if the WebSocket is connected
|
|
11
|
+
*/
|
|
12
|
+
get isConnected() {
|
|
13
|
+
return this.webSocket !== null;
|
|
14
|
+
}
|
|
15
|
+
async connect() {
|
|
16
|
+
return this.disconnect(), new Promise((t, e) => {
|
|
17
|
+
try {
|
|
18
|
+
this.webSocket = new WebSocket(this.url), this.webSocket.onopen = () => {
|
|
19
|
+
var i;
|
|
20
|
+
(i = this.onOpen) == null || i.call(this), t();
|
|
21
|
+
}, this.webSocket.onmessage = (i) => {
|
|
22
|
+
var s;
|
|
23
|
+
(s = this.onMessageReceived) == null || s.call(this, i.data);
|
|
24
|
+
}, this.webSocket.onclose = (i) => {
|
|
25
|
+
var s;
|
|
26
|
+
this.webSocket = null, (s = this.onClose) == null || s.call(this, i.code, i.reason);
|
|
27
|
+
}, this.webSocket.onerror = (i) => {
|
|
28
|
+
var s;
|
|
29
|
+
this.webSocket = null;
|
|
30
|
+
const o = new Error("Courier Socket connection failed");
|
|
31
|
+
o.originalEvent = i, (s = this.onError) == null || s.call(this, o), e(o);
|
|
32
|
+
};
|
|
33
|
+
} catch (i) {
|
|
34
|
+
this.webSocket = null, e(i);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
disconnect() {
|
|
39
|
+
this.stopPing(), this.webSocket && (this.webSocket.close(wo.NORMAL_CLOSURE_STATUS), this.webSocket = null);
|
|
40
|
+
}
|
|
41
|
+
async send(t) {
|
|
42
|
+
if (!this.webSocket)
|
|
43
|
+
return !1;
|
|
44
|
+
const e = JSON.stringify(t);
|
|
45
|
+
return this.webSocket.send(e) !== void 0;
|
|
46
|
+
}
|
|
47
|
+
keepAlive(t) {
|
|
48
|
+
this.stopPing(), this.pingInterval = setInterval(async () => {
|
|
49
|
+
var e;
|
|
50
|
+
try {
|
|
51
|
+
await this.send({ action: "keepAlive" });
|
|
52
|
+
} catch (i) {
|
|
53
|
+
(e = this.options.logger) == null || e.error("Error occurred on Keep Alive:", i);
|
|
54
|
+
}
|
|
55
|
+
}, (t == null ? void 0 : t.intervalInMillis) ?? 3e5);
|
|
56
|
+
}
|
|
57
|
+
stopPing() {
|
|
58
|
+
this.pingInterval && (clearInterval(this.pingInterval), this.pingInterval = null);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
T(ko, "NORMAL_CLOSURE_STATUS", 1e3);
|
|
62
|
+
let Jo = ko;
|
|
63
|
+
const yo = (h) => ({
|
|
64
|
+
courier: {
|
|
65
|
+
rest: (h == null ? void 0 : h.courier.rest) || "https://api.courier.com",
|
|
66
|
+
graphql: (h == null ? void 0 : h.courier.graphql) || "https://api.courier.com/client/q"
|
|
67
|
+
},
|
|
68
|
+
inbox: {
|
|
69
|
+
graphql: (h == null ? void 0 : h.inbox.graphql) || "https://inbox.courier.com/q",
|
|
70
|
+
webSocket: (h == null ? void 0 : h.inbox.webSocket) || "wss://realtime.courier.com"
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
class Go {
|
|
74
|
+
constructor(t) {
|
|
75
|
+
T(this, "PREFIX", "[COURIER]"), this.showLogs = t;
|
|
76
|
+
}
|
|
77
|
+
warn(t, ...e) {
|
|
78
|
+
this.showLogs && console.warn(`${this.PREFIX} ${t}`, ...e);
|
|
79
|
+
}
|
|
80
|
+
log(t, ...e) {
|
|
81
|
+
this.showLogs && console.log(`${this.PREFIX} ${t}`, ...e);
|
|
82
|
+
}
|
|
83
|
+
error(t, ...e) {
|
|
84
|
+
this.showLogs && console.error(`${this.PREFIX} ${t}`, ...e);
|
|
85
|
+
}
|
|
86
|
+
debug(t, ...e) {
|
|
87
|
+
this.showLogs && console.debug(`${this.PREFIX} ${t}`, ...e);
|
|
88
|
+
}
|
|
89
|
+
info(t, ...e) {
|
|
90
|
+
this.showLogs && console.info(`${this.PREFIX} ${t}`, ...e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
class Ae {
|
|
94
|
+
static generate(t) {
|
|
95
|
+
const e = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
96
|
+
return t ? t + e : e;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
class Pe extends Error {
|
|
100
|
+
constructor(t, e, i) {
|
|
101
|
+
super(e), this.code = t, this.type = i, this.name = "CourierRequestError";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function So(h, t, e, i) {
|
|
105
|
+
h.log(`
|
|
106
|
+
📡 New Courier ${e} Request: ${t}
|
|
107
|
+
URL: ${i.url}
|
|
108
|
+
${i.method ? `Method: ${i.method}` : ""}
|
|
109
|
+
${i.query ? `Query: ${i.query}` : ""}
|
|
110
|
+
${i.variables ? `Variables: ${JSON.stringify(i.variables, null, 2)}` : ""}
|
|
111
|
+
Headers: ${JSON.stringify(i.headers, null, 2)}
|
|
112
|
+
Body: ${i.body ? JSON.stringify(i.body, null, 2) : "Empty"}
|
|
113
|
+
`);
|
|
114
|
+
}
|
|
115
|
+
function Io(h, t, e, i) {
|
|
116
|
+
h.log(`
|
|
117
|
+
📡 New Courier ${e} Response: ${t}
|
|
118
|
+
Status Code: ${i.status}
|
|
119
|
+
Response JSON: ${JSON.stringify(i.response, null, 2)}
|
|
120
|
+
`);
|
|
121
|
+
}
|
|
122
|
+
async function K(h) {
|
|
123
|
+
const t = h.validCodes ?? [200], e = h.options.showLogs ? Ae.generate() : void 0, i = new Request(h.url, {
|
|
124
|
+
method: h.method,
|
|
125
|
+
headers: {
|
|
126
|
+
"Content-Type": "application/json",
|
|
127
|
+
...h.headers
|
|
128
|
+
},
|
|
129
|
+
body: h.body ? JSON.stringify(h.body) : void 0
|
|
130
|
+
});
|
|
131
|
+
e && So(h.options.logger, e, "HTTP", {
|
|
132
|
+
url: i.url,
|
|
133
|
+
method: i.method,
|
|
134
|
+
headers: Object.fromEntries(i.headers.entries()),
|
|
135
|
+
body: h.body
|
|
136
|
+
});
|
|
137
|
+
const s = await fetch(i);
|
|
138
|
+
if (s.status === 204)
|
|
139
|
+
return;
|
|
140
|
+
let o;
|
|
141
|
+
try {
|
|
142
|
+
o = await s.json();
|
|
143
|
+
} catch {
|
|
144
|
+
if (s.status === 200)
|
|
145
|
+
return;
|
|
146
|
+
throw new Pe(
|
|
147
|
+
s.status,
|
|
148
|
+
"Failed to parse response as JSON",
|
|
149
|
+
"PARSE_ERROR"
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
if (e && Io(h.options.logger, e, "HTTP", {
|
|
153
|
+
status: s.status,
|
|
154
|
+
response: o
|
|
155
|
+
}), !t.includes(s.status))
|
|
156
|
+
throw new Pe(
|
|
157
|
+
s.status,
|
|
158
|
+
(o == null ? void 0 : o.message) || "Unknown Error",
|
|
159
|
+
o == null ? void 0 : o.type
|
|
160
|
+
);
|
|
161
|
+
return o;
|
|
162
|
+
}
|
|
163
|
+
async function Z(h) {
|
|
164
|
+
const t = h.options.showLogs ? Ae.generate() : void 0;
|
|
165
|
+
t && So(h.options.logger, t, "GraphQL", {
|
|
166
|
+
url: h.url,
|
|
167
|
+
headers: h.headers,
|
|
168
|
+
query: h.query,
|
|
169
|
+
variables: h.variables
|
|
170
|
+
});
|
|
171
|
+
const e = await fetch(h.url, {
|
|
172
|
+
method: "POST",
|
|
173
|
+
headers: {
|
|
174
|
+
"Content-Type": "application/json",
|
|
175
|
+
...h.headers
|
|
176
|
+
},
|
|
177
|
+
body: JSON.stringify({
|
|
178
|
+
query: h.query,
|
|
179
|
+
variables: h.variables
|
|
180
|
+
})
|
|
181
|
+
});
|
|
182
|
+
let i;
|
|
183
|
+
try {
|
|
184
|
+
i = await e.json();
|
|
185
|
+
} catch {
|
|
186
|
+
throw new Pe(
|
|
187
|
+
e.status,
|
|
188
|
+
"Failed to parse response as JSON",
|
|
189
|
+
"PARSE_ERROR"
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
if (t && Io(h.options.logger, t, "GraphQL", {
|
|
193
|
+
status: e.status,
|
|
194
|
+
response: i
|
|
195
|
+
}), !e.ok)
|
|
196
|
+
throw new Pe(
|
|
197
|
+
e.status,
|
|
198
|
+
(i == null ? void 0 : i.message) || "Unknown Error",
|
|
199
|
+
i == null ? void 0 : i.type
|
|
200
|
+
);
|
|
201
|
+
return i;
|
|
202
|
+
}
|
|
203
|
+
class re {
|
|
204
|
+
constructor(t) {
|
|
205
|
+
this.options = t;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
class Wo extends re {
|
|
209
|
+
/**
|
|
210
|
+
* Get a brand by ID using GraphQL
|
|
211
|
+
* @param brandId - The ID of the brand to retrieve
|
|
212
|
+
* @returns Promise resolving to the requested brand
|
|
213
|
+
*/
|
|
214
|
+
async getBrand(t) {
|
|
215
|
+
const e = `
|
|
216
|
+
query GetBrand {
|
|
217
|
+
brand(brandId: "${t.brandId}") {
|
|
218
|
+
settings {
|
|
219
|
+
colors {
|
|
220
|
+
primary
|
|
221
|
+
secondary
|
|
222
|
+
tertiary
|
|
223
|
+
}
|
|
224
|
+
inapp {
|
|
225
|
+
borderRadius
|
|
226
|
+
disableCourierFooter
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
`;
|
|
232
|
+
return (await Z({
|
|
233
|
+
options: this.options,
|
|
234
|
+
url: this.options.apiUrls.courier.graphql,
|
|
235
|
+
headers: {
|
|
236
|
+
"x-courier-user-id": this.options.userId,
|
|
237
|
+
"x-courier-client-key": "empty",
|
|
238
|
+
// Empty for now. Will be removed in future.
|
|
239
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
240
|
+
},
|
|
241
|
+
query: e,
|
|
242
|
+
variables: { brandId: t.brandId }
|
|
243
|
+
})).data.brand;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
class ze extends Jo {
|
|
247
|
+
constructor(t) {
|
|
248
|
+
const e = ze.buildUrl(t);
|
|
249
|
+
super(e, t), T(this, "receivedMessage"), T(this, "receivedMessageEvent"), this.onMessageReceived = (i) => this.convertToType(i);
|
|
250
|
+
}
|
|
251
|
+
convertToType(t) {
|
|
252
|
+
var e, i, s, o;
|
|
253
|
+
try {
|
|
254
|
+
switch (JSON.parse(t).type) {
|
|
255
|
+
case "event":
|
|
256
|
+
const c = JSON.parse(t);
|
|
257
|
+
(e = this.receivedMessageEvent) == null || e.call(this, c);
|
|
258
|
+
break;
|
|
259
|
+
case "message":
|
|
260
|
+
const d = JSON.parse(t);
|
|
261
|
+
(i = this.receivedMessage) == null || i.call(this, d);
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
} catch (n) {
|
|
265
|
+
(s = this.options.logger) == null || s.error("Error parsing socket message", n), n instanceof Error && ((o = this.onError) == null || o.call(this, n));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async sendSubscribe(t) {
|
|
269
|
+
var e;
|
|
270
|
+
const i = {
|
|
271
|
+
action: "subscribe",
|
|
272
|
+
data: {
|
|
273
|
+
userAgent: "courier-js",
|
|
274
|
+
// TODO: Equivalent to Courier.agent.value()
|
|
275
|
+
channel: this.options.userId,
|
|
276
|
+
event: "*",
|
|
277
|
+
version: (t == null ? void 0 : t.version) ?? 5
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
this.options.connectionId && (i.data.clientSourceId = this.options.connectionId), this.options.tenantId && (i.data.accountId = this.options.tenantId), (e = this.options.logger) == null || e.debug("Sending subscribe request", i), await this.send(i);
|
|
281
|
+
}
|
|
282
|
+
static buildUrl(t) {
|
|
283
|
+
var e;
|
|
284
|
+
let i = ((e = t.apiUrls) == null ? void 0 : e.inbox.webSocket) ?? "";
|
|
285
|
+
return t.accessToken && (i += `/?auth=${t.accessToken}`), i;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
class Ko extends re {
|
|
289
|
+
constructor(t) {
|
|
290
|
+
super(t), T(this, "socket"), this.socket = new ze(t);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Get paginated messages
|
|
294
|
+
* @param paginationLimit - Number of messages to return per page (default: 24)
|
|
295
|
+
* @param startCursor - Cursor for pagination
|
|
296
|
+
* @returns Promise resolving to paginated messages response
|
|
297
|
+
*/
|
|
298
|
+
async getMessages(t) {
|
|
299
|
+
const e = `
|
|
300
|
+
query GetInboxMessages(
|
|
301
|
+
$params: FilterParamsInput = { ${this.options.tenantId ? `accountId: "${this.options.tenantId}"` : ""} }
|
|
302
|
+
$limit: Int = ${(t == null ? void 0 : t.paginationLimit) ?? 24}
|
|
303
|
+
$after: String ${t != null && t.startCursor ? `= "${t.startCursor}"` : ""}
|
|
304
|
+
) {
|
|
305
|
+
count(params: $params)
|
|
306
|
+
messages(params: $params, limit: $limit, after: $after) {
|
|
307
|
+
totalCount
|
|
308
|
+
pageInfo {
|
|
309
|
+
startCursor
|
|
310
|
+
hasNextPage
|
|
311
|
+
}
|
|
312
|
+
nodes {
|
|
313
|
+
messageId
|
|
314
|
+
read
|
|
315
|
+
archived
|
|
316
|
+
created
|
|
317
|
+
opened
|
|
318
|
+
title
|
|
319
|
+
preview
|
|
320
|
+
data
|
|
321
|
+
tags
|
|
322
|
+
trackingIds {
|
|
323
|
+
clickTrackingId
|
|
324
|
+
}
|
|
325
|
+
actions {
|
|
326
|
+
content
|
|
327
|
+
data
|
|
328
|
+
href
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
`;
|
|
334
|
+
return await Z({
|
|
335
|
+
options: this.options,
|
|
336
|
+
query: e,
|
|
337
|
+
headers: {
|
|
338
|
+
"x-courier-user-id": this.options.userId,
|
|
339
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
340
|
+
},
|
|
341
|
+
url: this.options.apiUrls.inbox.graphql
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Get paginated archived messages
|
|
346
|
+
* @param paginationLimit - Number of messages to return per page (default: 24)
|
|
347
|
+
* @param startCursor - Cursor for pagination
|
|
348
|
+
* @returns Promise resolving to paginated archived messages response
|
|
349
|
+
*/
|
|
350
|
+
async getArchivedMessages(t) {
|
|
351
|
+
const e = `
|
|
352
|
+
query GetInboxMessages(
|
|
353
|
+
$params: FilterParamsInput = { ${this.options.tenantId ? `accountId: "${this.options.tenantId}"` : ""}, archived: true }
|
|
354
|
+
$limit: Int = ${(t == null ? void 0 : t.paginationLimit) ?? 24}
|
|
355
|
+
$after: String ${t != null && t.startCursor ? `= "${t.startCursor}"` : ""}
|
|
356
|
+
) {
|
|
357
|
+
count(params: $params)
|
|
358
|
+
messages(params: $params, limit: $limit, after: $after) {
|
|
359
|
+
totalCount
|
|
360
|
+
pageInfo {
|
|
361
|
+
startCursor
|
|
362
|
+
hasNextPage
|
|
363
|
+
}
|
|
364
|
+
nodes {
|
|
365
|
+
messageId
|
|
366
|
+
read
|
|
367
|
+
archived
|
|
368
|
+
created
|
|
369
|
+
opened
|
|
370
|
+
title
|
|
371
|
+
preview
|
|
372
|
+
data
|
|
373
|
+
tags
|
|
374
|
+
trackingIds {
|
|
375
|
+
clickTrackingId
|
|
376
|
+
}
|
|
377
|
+
actions {
|
|
378
|
+
content
|
|
379
|
+
data
|
|
380
|
+
href
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
`;
|
|
386
|
+
return Z({
|
|
387
|
+
options: this.options,
|
|
388
|
+
query: e,
|
|
389
|
+
headers: {
|
|
390
|
+
"x-courier-user-id": this.options.userId,
|
|
391
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
392
|
+
},
|
|
393
|
+
url: this.options.apiUrls.inbox.graphql
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Get unread message count
|
|
398
|
+
* @returns Promise resolving to number of unread messages
|
|
399
|
+
*/
|
|
400
|
+
async getUnreadMessageCount() {
|
|
401
|
+
var t;
|
|
402
|
+
const e = `
|
|
403
|
+
query GetMessages {
|
|
404
|
+
count(params: { status: "unread" ${this.options.tenantId ? `, accountId: "${this.options.tenantId}"` : ""} })
|
|
405
|
+
}
|
|
406
|
+
`;
|
|
407
|
+
return ((t = (await Z({
|
|
408
|
+
options: this.options,
|
|
409
|
+
query: e,
|
|
410
|
+
headers: {
|
|
411
|
+
"x-courier-user-id": this.options.userId,
|
|
412
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
413
|
+
},
|
|
414
|
+
url: this.options.apiUrls.inbox.graphql
|
|
415
|
+
})).data) == null ? void 0 : t.count) ?? 0;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Track a click event
|
|
419
|
+
* @param messageId - ID of the message
|
|
420
|
+
* @param trackingId - ID for tracking the click
|
|
421
|
+
* @returns Promise resolving when click is tracked
|
|
422
|
+
*/
|
|
423
|
+
async click(t) {
|
|
424
|
+
const e = `
|
|
425
|
+
mutation TrackEvent {
|
|
426
|
+
clicked(messageId: "${t.messageId}", trackingId: "${t.trackingId}")
|
|
427
|
+
}
|
|
428
|
+
`, i = {
|
|
429
|
+
"x-courier-user-id": this.options.userId,
|
|
430
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
431
|
+
};
|
|
432
|
+
this.options.connectionId && (i["x-courier-client-source-id"] = this.options.connectionId), await Z({
|
|
433
|
+
options: this.options,
|
|
434
|
+
query: e,
|
|
435
|
+
headers: i,
|
|
436
|
+
url: this.options.apiUrls.inbox.graphql
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Mark a message as read
|
|
441
|
+
* @param messageId - ID of the message to mark as read
|
|
442
|
+
* @returns Promise resolving when message is marked as read
|
|
443
|
+
*/
|
|
444
|
+
async read(t) {
|
|
445
|
+
const e = `
|
|
446
|
+
mutation TrackEvent {
|
|
447
|
+
read(messageId: "${t.messageId}")
|
|
448
|
+
}
|
|
449
|
+
`, i = {
|
|
450
|
+
"x-courier-user-id": this.options.userId,
|
|
451
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
452
|
+
};
|
|
453
|
+
this.options.connectionId && (i["x-courier-client-source-id"] = this.options.connectionId), await Z({
|
|
454
|
+
options: this.options,
|
|
455
|
+
query: e,
|
|
456
|
+
headers: i,
|
|
457
|
+
url: this.options.apiUrls.inbox.graphql
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Mark a message as unread
|
|
462
|
+
* @param messageId - ID of the message to mark as unread
|
|
463
|
+
* @returns Promise resolving when message is marked as unread
|
|
464
|
+
*/
|
|
465
|
+
async unread(t) {
|
|
466
|
+
const e = `
|
|
467
|
+
mutation TrackEvent {
|
|
468
|
+
unread(messageId: "${t.messageId}")
|
|
469
|
+
}
|
|
470
|
+
`, i = {
|
|
471
|
+
"x-courier-user-id": this.options.userId,
|
|
472
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
473
|
+
};
|
|
474
|
+
this.options.connectionId && (i["x-courier-client-source-id"] = this.options.connectionId), await Z({
|
|
475
|
+
options: this.options,
|
|
476
|
+
query: e,
|
|
477
|
+
headers: i,
|
|
478
|
+
url: this.options.apiUrls.inbox.graphql
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Mark all messages as read
|
|
483
|
+
* @returns Promise resolving when all messages are marked as read
|
|
484
|
+
*/
|
|
485
|
+
async readAll() {
|
|
486
|
+
const t = `
|
|
487
|
+
mutation TrackEvent {
|
|
488
|
+
markAllRead
|
|
489
|
+
}
|
|
490
|
+
`, e = {
|
|
491
|
+
"x-courier-user-id": this.options.userId,
|
|
492
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
493
|
+
};
|
|
494
|
+
this.options.connectionId && (e["x-courier-client-source-id"] = this.options.connectionId), await Z({
|
|
495
|
+
options: this.options,
|
|
496
|
+
query: t,
|
|
497
|
+
headers: e,
|
|
498
|
+
url: this.options.apiUrls.inbox.graphql
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Mark a message as opened
|
|
503
|
+
* @param messageId - ID of the message to mark as opened
|
|
504
|
+
* @returns Promise resolving when message is marked as opened
|
|
505
|
+
*/
|
|
506
|
+
async open(t) {
|
|
507
|
+
const e = `
|
|
508
|
+
mutation TrackEvent {
|
|
509
|
+
opened(messageId: "${t.messageId}")
|
|
510
|
+
}
|
|
511
|
+
`, i = {
|
|
512
|
+
"x-courier-user-id": this.options.userId,
|
|
513
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
514
|
+
};
|
|
515
|
+
this.options.connectionId && (i["x-courier-client-source-id"] = this.options.connectionId), await Z({
|
|
516
|
+
options: this.options,
|
|
517
|
+
query: e,
|
|
518
|
+
headers: i,
|
|
519
|
+
url: this.options.apiUrls.inbox.graphql
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Archive a message
|
|
524
|
+
* @param messageId - ID of the message to archive
|
|
525
|
+
* @returns Promise resolving when message is archived
|
|
526
|
+
*/
|
|
527
|
+
async archive(t) {
|
|
528
|
+
const e = `
|
|
529
|
+
mutation TrackEvent {
|
|
530
|
+
archive(messageId: "${t.messageId}")
|
|
531
|
+
}
|
|
532
|
+
`, i = {
|
|
533
|
+
"x-courier-user-id": this.options.userId,
|
|
534
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
535
|
+
};
|
|
536
|
+
this.options.connectionId && (i["x-courier-client-source-id"] = this.options.connectionId), await Z({
|
|
537
|
+
options: this.options,
|
|
538
|
+
query: e,
|
|
539
|
+
headers: i,
|
|
540
|
+
url: this.options.apiUrls.inbox.graphql
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Archive all read messages.
|
|
545
|
+
*/
|
|
546
|
+
async archiveRead() {
|
|
547
|
+
const t = `
|
|
548
|
+
mutation TrackEvent {
|
|
549
|
+
archiveRead
|
|
550
|
+
}
|
|
551
|
+
`, e = {
|
|
552
|
+
"x-courier-user-id": this.options.userId,
|
|
553
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
554
|
+
};
|
|
555
|
+
this.options.connectionId && (e["x-courier-client-source-id"] = this.options.connectionId), await Z({
|
|
556
|
+
options: this.options,
|
|
557
|
+
query: t,
|
|
558
|
+
headers: e,
|
|
559
|
+
url: this.options.apiUrls.inbox.graphql
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
class Xo {
|
|
564
|
+
/**
|
|
565
|
+
* Transforms a single API response item to the CourierUserPreferencesTopic type
|
|
566
|
+
* @param item - The API response item
|
|
567
|
+
* @returns A CourierUserPreferencesTopic object
|
|
568
|
+
*/
|
|
569
|
+
transformItem(t) {
|
|
570
|
+
return {
|
|
571
|
+
topicId: t.topic_id,
|
|
572
|
+
topicName: t.topic_name,
|
|
573
|
+
sectionId: t.section_id,
|
|
574
|
+
sectionName: t.section_name,
|
|
575
|
+
status: t.status,
|
|
576
|
+
defaultStatus: t.default_status,
|
|
577
|
+
hasCustomRouting: t.has_custom_routing,
|
|
578
|
+
customRouting: t.custom_routing || []
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Transforms an array of API response items to CourierUserPreferencesTopic objects
|
|
583
|
+
* @param items - The API response items
|
|
584
|
+
* @returns A generator of CourierUserPreferencesTopic objects
|
|
585
|
+
*/
|
|
586
|
+
*transform(t) {
|
|
587
|
+
for (const e of t)
|
|
588
|
+
yield this.transformItem(e);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
function Qo(h) {
|
|
592
|
+
const t = atob(h), e = new Uint8Array(t.length);
|
|
593
|
+
for (let i = 0; i < t.length; i++)
|
|
594
|
+
e[i] = t.charCodeAt(i);
|
|
595
|
+
return String.fromCharCode(...e);
|
|
596
|
+
}
|
|
597
|
+
function Yo(h) {
|
|
598
|
+
const t = new Uint8Array(h.length);
|
|
599
|
+
for (let e = 0; e < h.length; e++)
|
|
600
|
+
t[e] = h.charCodeAt(e);
|
|
601
|
+
return btoa(String.fromCharCode(...t));
|
|
602
|
+
}
|
|
603
|
+
class en extends re {
|
|
604
|
+
constructor() {
|
|
605
|
+
super(...arguments), T(this, "transformer", new Xo());
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Get all preferences for a user
|
|
609
|
+
* @param paginationCursor - Optional cursor for pagination
|
|
610
|
+
* @returns Promise resolving to user preferences
|
|
611
|
+
* @see https://www.courier.com/docs/reference/user-preferences/list-all-user-preferences
|
|
612
|
+
*/
|
|
613
|
+
async getUserPreferences(t) {
|
|
614
|
+
let e = `${this.options.apiUrls.courier.rest}/users/${this.options.userId}/preferences`;
|
|
615
|
+
t != null && t.paginationCursor && (e += `?cursor=${t.paginationCursor}`);
|
|
616
|
+
const s = await K({
|
|
617
|
+
options: this.options,
|
|
618
|
+
url: e,
|
|
619
|
+
method: "GET",
|
|
620
|
+
headers: {
|
|
621
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
return {
|
|
625
|
+
items: [...this.transformer.transform(s.items)],
|
|
626
|
+
paging: s.paging
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Get preferences for a specific topic
|
|
631
|
+
* @param topicId - The ID of the topic to get preferences for
|
|
632
|
+
* @returns Promise resolving to topic preferences
|
|
633
|
+
* @see https://www.courier.com/docs/reference/user-preferences/get-subscription-topic-preferences
|
|
634
|
+
*/
|
|
635
|
+
async getUserPreferenceTopic(t) {
|
|
636
|
+
const i = await K({
|
|
637
|
+
options: this.options,
|
|
638
|
+
url: `${this.options.apiUrls.courier.rest}/users/${this.options.userId}/preferences/${t.topicId}`,
|
|
639
|
+
method: "GET",
|
|
640
|
+
headers: {
|
|
641
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
return this.transformer.transformItem(i.topic);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Update preferences for a specific topic
|
|
648
|
+
* @param topicId - The ID of the topic to update preferences for
|
|
649
|
+
* @param status - The new status for the topic
|
|
650
|
+
* @param hasCustomRouting - Whether the topic has custom routing
|
|
651
|
+
* @param customRouting - The custom routing channels for the topic
|
|
652
|
+
* @returns Promise resolving when update is complete
|
|
653
|
+
* @see https://www.courier.com/docs/reference/user-preferences/update-subscription-topic-preferences
|
|
654
|
+
*/
|
|
655
|
+
async putUserPreferenceTopic(t) {
|
|
656
|
+
const e = {
|
|
657
|
+
topic: {
|
|
658
|
+
status: t.status,
|
|
659
|
+
has_custom_routing: t.hasCustomRouting,
|
|
660
|
+
custom_routing: t.customRouting
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
await K({
|
|
664
|
+
options: this.options,
|
|
665
|
+
url: `${this.options.apiUrls.courier.rest}/users/${this.options.userId}/preferences/${t.topicId}`,
|
|
666
|
+
method: "PUT",
|
|
667
|
+
headers: {
|
|
668
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
669
|
+
},
|
|
670
|
+
body: e
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Get the notification center URL
|
|
675
|
+
* @param clientKey - The client key to use for the URL
|
|
676
|
+
* @returns The notification center URL
|
|
677
|
+
*/
|
|
678
|
+
getNotificationCenterUrl(t) {
|
|
679
|
+
const e = Qo(t.clientKey);
|
|
680
|
+
return `https://view.notificationcenter.app/p/${Yo(`${e}#${this.options.userId}${this.options.tenantId ? `#${this.options.tenantId}` : ""}#false`)}`;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
class tn extends re {
|
|
684
|
+
/**
|
|
685
|
+
* Store a push notification token for a user
|
|
686
|
+
* @param token - The push notification token
|
|
687
|
+
* @param provider - The provider of the token
|
|
688
|
+
* @param device - The device information
|
|
689
|
+
* @see https://www.courier.com/docs/reference/token-management/put-token
|
|
690
|
+
*/
|
|
691
|
+
async putUserToken(t) {
|
|
692
|
+
const e = {
|
|
693
|
+
provider_key: t.provider,
|
|
694
|
+
...t.device && {
|
|
695
|
+
device: {
|
|
696
|
+
app_id: t.device.appId,
|
|
697
|
+
ad_id: t.device.adId,
|
|
698
|
+
device_id: t.device.deviceId,
|
|
699
|
+
platform: t.device.platform,
|
|
700
|
+
manufacturer: t.device.manufacturer,
|
|
701
|
+
model: t.device.model
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
await K({
|
|
706
|
+
options: this.options,
|
|
707
|
+
url: `${this.options.apiUrls.courier.rest}/users/${this.options.userId}/tokens/${t.token}`,
|
|
708
|
+
method: "PUT",
|
|
709
|
+
headers: {
|
|
710
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
711
|
+
},
|
|
712
|
+
body: e,
|
|
713
|
+
validCodes: [200, 204]
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Delete a push notification token for a user
|
|
718
|
+
* @param token - The push notification token
|
|
719
|
+
* @returns Promise resolving when token is deleted
|
|
720
|
+
*/
|
|
721
|
+
async deleteUserToken(t) {
|
|
722
|
+
await K({
|
|
723
|
+
options: this.options,
|
|
724
|
+
url: `${this.options.apiUrls.courier.rest}/users/${this.options.userId}/tokens/${t.token}`,
|
|
725
|
+
method: "DELETE",
|
|
726
|
+
headers: {
|
|
727
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
728
|
+
},
|
|
729
|
+
validCodes: [200, 204]
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
class sn extends re {
|
|
734
|
+
/**
|
|
735
|
+
* Subscribe a user to a list
|
|
736
|
+
* @param listId - The ID of the list to subscribe to
|
|
737
|
+
* @returns Promise resolving when subscription is complete
|
|
738
|
+
* @see https://www.courier.com/docs/reference/lists/recipient-subscribe
|
|
739
|
+
*/
|
|
740
|
+
async putSubscription(t) {
|
|
741
|
+
return await K({
|
|
742
|
+
url: `${this.options.apiUrls.courier.rest}/lists/${t.listId}/subscriptions/${this.options.userId}`,
|
|
743
|
+
options: this.options,
|
|
744
|
+
method: "PUT",
|
|
745
|
+
headers: {
|
|
746
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Unsubscribe a user from a list
|
|
752
|
+
* @param listId - The ID of the list to unsubscribe from
|
|
753
|
+
* @returns Promise resolving when unsubscription is complete
|
|
754
|
+
* @see https://www.courier.com/docs/reference/lists/delete-subscription
|
|
755
|
+
*/
|
|
756
|
+
async deleteSubscription(t) {
|
|
757
|
+
return await K({
|
|
758
|
+
url: `${this.options.apiUrls.courier.rest}/lists/${t.listId}/subscriptions/${this.options.userId}`,
|
|
759
|
+
options: this.options,
|
|
760
|
+
method: "DELETE",
|
|
761
|
+
headers: {
|
|
762
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
class on extends re {
|
|
768
|
+
/**
|
|
769
|
+
* Post an inbound courier event
|
|
770
|
+
* @param event - The event type: Example: "New Order Placed"
|
|
771
|
+
* @param messageId - The message ID
|
|
772
|
+
* @param type - The type of event: Available options: "track"
|
|
773
|
+
* @param properties - The properties of the event
|
|
774
|
+
* @returns Promise resolving to the message ID
|
|
775
|
+
* @see https://www.courier.com/docs/reference/inbound/courier-track-event
|
|
776
|
+
*/
|
|
777
|
+
async postInboundCourier(t) {
|
|
778
|
+
return await K({
|
|
779
|
+
url: `${this.options.apiUrls.courier.rest}/inbound/courier`,
|
|
780
|
+
options: this.options,
|
|
781
|
+
method: "POST",
|
|
782
|
+
headers: {
|
|
783
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
784
|
+
},
|
|
785
|
+
body: {
|
|
786
|
+
...t,
|
|
787
|
+
userId: this.options.userId
|
|
788
|
+
},
|
|
789
|
+
validCodes: [200, 202]
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Post a tracking URL event
|
|
794
|
+
* These urls are found in messages sent from Courier
|
|
795
|
+
* @param url - The URL to post the event to
|
|
796
|
+
* @param event - The event type: Available options: "click", "open", "unsubscribe"
|
|
797
|
+
* @returns Promise resolving when the event is posted
|
|
798
|
+
*/
|
|
799
|
+
async postTrackingUrl(t) {
|
|
800
|
+
return await K({
|
|
801
|
+
url: t.url,
|
|
802
|
+
options: this.options,
|
|
803
|
+
method: "POST",
|
|
804
|
+
body: {
|
|
805
|
+
event: t.event
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
class nn extends re {
|
|
811
|
+
constructor(t) {
|
|
812
|
+
var e, i;
|
|
813
|
+
const s = t.showLogs !== void 0 ? t.showLogs : process.env.NODE_ENV === "development", o = {
|
|
814
|
+
...t,
|
|
815
|
+
showLogs: s,
|
|
816
|
+
apiUrls: t.apiUrls || yo(),
|
|
817
|
+
accessToken: t.jwt ?? t.publicApiKey
|
|
818
|
+
};
|
|
819
|
+
super({
|
|
820
|
+
...o,
|
|
821
|
+
logger: new Go(o.showLogs),
|
|
822
|
+
apiUrls: yo(o.apiUrls)
|
|
823
|
+
}), T(this, "tokens"), T(this, "brands"), T(this, "preferences"), T(this, "inbox"), T(this, "lists"), T(this, "tracking"), this.tokens = new tn(this.options), this.brands = new Wo(this.options), this.preferences = new en(this.options), this.inbox = new Ko(this.options), this.lists = new sn(this.options), this.tracking = new on(this.options), !this.options.jwt && !this.options.publicApiKey && this.options.logger.warn("Courier Client initialized with no authentication method. Please provide a JWT or public API key."), this.options.publicApiKey && ((e = this.options.logger) == null || e.warn(
|
|
824
|
+
`Courier Warning: Public API Keys are for testing only. Please use JWTs for production.
|
|
825
|
+
You can generate a JWT with this endpoint: https://www.courier.com/docs/reference/auth/issue-token
|
|
826
|
+
This endpoint should be called from your backend server, not the SDK.`
|
|
827
|
+
)), this.options.jwt && this.options.publicApiKey && ((i = this.options.logger) == null || i.warn(
|
|
828
|
+
"Courier Warning: Both a JWT and a Public API Key were provided. The Public API Key will be ignored."
|
|
829
|
+
));
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
class rn {
|
|
833
|
+
constructor(t) {
|
|
834
|
+
T(this, "callback"), this.callback = t;
|
|
835
|
+
}
|
|
836
|
+
remove() {
|
|
837
|
+
v.shared.removeAuthenticationListener(this);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
const Eo = class Me {
|
|
841
|
+
constructor() {
|
|
842
|
+
T(this, "id", Ae.generate()), T(this, "instanceClient"), T(this, "_paginationLimit", 24), T(this, "authenticationListeners", []);
|
|
843
|
+
}
|
|
844
|
+
get paginationLimit() {
|
|
845
|
+
return this._paginationLimit;
|
|
846
|
+
}
|
|
847
|
+
set paginationLimit(t) {
|
|
848
|
+
this._paginationLimit = Math.min(Math.max(t, 1), 100);
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Get the Courier client instance
|
|
852
|
+
* @returns The Courier client instance or undefined if not signed in
|
|
853
|
+
*/
|
|
854
|
+
get client() {
|
|
855
|
+
return this.instanceClient;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Get the shared Courier instance
|
|
859
|
+
* @returns The shared Courier instance
|
|
860
|
+
*/
|
|
861
|
+
static get shared() {
|
|
862
|
+
return Me.instance || (Me.instance = new Me()), Me.instance;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Sign in to Courier
|
|
866
|
+
* @param options - The options for the Courier client
|
|
867
|
+
*/
|
|
868
|
+
signIn(t) {
|
|
869
|
+
const e = t.connectionId ?? Ae.generate();
|
|
870
|
+
this.instanceClient = new nn({ ...t, connectionId: e }), this.notifyAuthenticationListeners({ userId: t.userId });
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Sign out of Courier
|
|
874
|
+
*/
|
|
875
|
+
signOut() {
|
|
876
|
+
this.instanceClient = void 0, this.notifyAuthenticationListeners({ userId: void 0 });
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Register a callback to be notified of authentication state changes
|
|
880
|
+
* @param callback - Function to be called when authentication state changes
|
|
881
|
+
* @returns AuthenticationListener instance that can be used to remove the listener
|
|
882
|
+
*/
|
|
883
|
+
addAuthenticationListener(t) {
|
|
884
|
+
var e;
|
|
885
|
+
(e = this.instanceClient) == null || e.options.logger.info("Adding authentication listener");
|
|
886
|
+
const i = new rn(t);
|
|
887
|
+
return this.authenticationListeners.push(i), i;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Unregister an authentication state change listener
|
|
891
|
+
* @param listener - The AuthenticationListener instance to remove
|
|
892
|
+
*/
|
|
893
|
+
removeAuthenticationListener(t) {
|
|
894
|
+
var e;
|
|
895
|
+
(e = this.instanceClient) == null || e.options.logger.info("Removing authentication listener"), this.authenticationListeners = this.authenticationListeners.filter((i) => i !== t);
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Notify all authentication listeners
|
|
899
|
+
* @param props - The props to notify the listeners with
|
|
900
|
+
*/
|
|
901
|
+
notifyAuthenticationListeners(t) {
|
|
902
|
+
this.authenticationListeners.forEach((e) => e.callback(t));
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
T(Eo, "instance");
|
|
906
|
+
let v = Eo;
|
|
907
|
+
var an = Object.defineProperty, hn = (h, t, e) => t in h ? an(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, $ = (h, t, e) => hn(h, typeof t != "symbol" ? t + "" : t, e);
|
|
6
908
|
const r = {
|
|
7
909
|
black: {
|
|
8
910
|
500: "#171717",
|
|
@@ -24,7 +926,7 @@ const r = {
|
|
|
24
926
|
400: "#60A5FA",
|
|
25
927
|
500: "#2563EB"
|
|
26
928
|
}
|
|
27
|
-
},
|
|
929
|
+
}, W = {
|
|
28
930
|
light: {
|
|
29
931
|
colors: {
|
|
30
932
|
primary: r.black[500],
|
|
@@ -49,21 +951,21 @@ const r = {
|
|
|
49
951
|
cornerRadius: "4px"
|
|
50
952
|
}
|
|
51
953
|
}
|
|
52
|
-
},
|
|
954
|
+
}, Mo = () => typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", To = (h) => {
|
|
53
955
|
if (typeof window > "u")
|
|
54
956
|
return () => {
|
|
55
957
|
};
|
|
56
|
-
const
|
|
57
|
-
|
|
958
|
+
const t = window.matchMedia("(prefers-color-scheme: dark)"), e = (i) => {
|
|
959
|
+
h(i.matches ? "dark" : "light");
|
|
58
960
|
};
|
|
59
|
-
return
|
|
60
|
-
|
|
961
|
+
return t.addEventListener("change", e), () => {
|
|
962
|
+
t.removeEventListener("change", e);
|
|
61
963
|
};
|
|
62
964
|
};
|
|
63
|
-
class
|
|
965
|
+
class $o extends HTMLElement {
|
|
64
966
|
constructor() {
|
|
65
|
-
super(),
|
|
66
|
-
this._currentSystemTheme =
|
|
967
|
+
super(), $(this, "_currentSystemTheme"), $(this, "_systemThemeCleanup"), this._currentSystemTheme = Mo(), this._systemThemeCleanup = To((t) => {
|
|
968
|
+
this._currentSystemTheme = t, this.onSystemThemeChange(t);
|
|
67
969
|
});
|
|
68
970
|
}
|
|
69
971
|
get currentSystemTheme() {
|
|
@@ -72,47 +974,47 @@ class bo extends HTMLElement {
|
|
|
72
974
|
disconnectedCallback() {
|
|
73
975
|
this._systemThemeCleanup && this._systemThemeCleanup();
|
|
74
976
|
}
|
|
75
|
-
onSystemThemeChange(
|
|
977
|
+
onSystemThemeChange(t) {
|
|
76
978
|
}
|
|
77
979
|
}
|
|
78
|
-
const
|
|
980
|
+
const Fe = {
|
|
79
981
|
borderRadius: "4px",
|
|
80
982
|
fontSize: "14px"
|
|
81
|
-
},
|
|
82
|
-
primary: (
|
|
83
|
-
...
|
|
84
|
-
backgroundColor:
|
|
85
|
-
textColor:
|
|
983
|
+
}, se = {
|
|
984
|
+
primary: (h) => ({
|
|
985
|
+
...Fe,
|
|
986
|
+
backgroundColor: W[h].colors.primary,
|
|
987
|
+
textColor: W[h].colors.secondary,
|
|
86
988
|
fontWeight: "500",
|
|
87
989
|
shadow: "none"
|
|
88
990
|
}),
|
|
89
|
-
secondary: (
|
|
90
|
-
...
|
|
91
|
-
backgroundColor:
|
|
92
|
-
textColor:
|
|
991
|
+
secondary: (h) => ({
|
|
992
|
+
...Fe,
|
|
993
|
+
backgroundColor: W[h].colors.secondary,
|
|
994
|
+
textColor: W[h].colors.primary,
|
|
93
995
|
fontWeight: "500",
|
|
94
|
-
border: `1px solid ${
|
|
95
|
-
shadow:
|
|
996
|
+
border: `1px solid ${W[h].colors.border}`,
|
|
997
|
+
shadow: h === "light" ? "0px 1px 2px 0px rgba(0, 0, 0, 0.06)" : "0px 1px 2px 0px rgba(255, 255, 255, 0.1)"
|
|
96
998
|
}),
|
|
97
|
-
tertiary: (
|
|
98
|
-
...
|
|
99
|
-
backgroundColor:
|
|
100
|
-
textColor:
|
|
999
|
+
tertiary: (h) => ({
|
|
1000
|
+
...Fe,
|
|
1001
|
+
backgroundColor: W[h].colors.border,
|
|
1002
|
+
textColor: W[h].colors.primary,
|
|
101
1003
|
fontWeight: "500",
|
|
102
1004
|
border: "none",
|
|
103
1005
|
shadow: "none"
|
|
104
1006
|
})
|
|
105
1007
|
};
|
|
106
|
-
class
|
|
107
|
-
constructor(
|
|
108
|
-
super(),
|
|
1008
|
+
class Re extends $o {
|
|
1009
|
+
constructor(t) {
|
|
1010
|
+
super(), $(this, "_button"), $(this, "_style");
|
|
109
1011
|
const e = this.attachShadow({ mode: "open" });
|
|
110
|
-
this._button = document.createElement("button"), this._button.setAttribute("part", "button"), this._style = document.createElement("style"), this._style.textContent = this.getStyles(
|
|
111
|
-
|
|
1012
|
+
this._button = document.createElement("button"), this._button.setAttribute("part", "button"), this._style = document.createElement("style"), this._style.textContent = this.getStyles(t), e.appendChild(this._style), e.appendChild(this._button), this.updateButton(t), this._button.addEventListener("click", (i) => {
|
|
1013
|
+
i.preventDefault(), i.stopPropagation(), t.onClick && t.onClick();
|
|
112
1014
|
});
|
|
113
1015
|
}
|
|
114
|
-
getStyles(
|
|
115
|
-
const e = () =>
|
|
1016
|
+
getStyles(t) {
|
|
1017
|
+
const e = () => se.secondary(this.currentSystemTheme).textColor, i = () => se.secondary(this.currentSystemTheme).backgroundColor, s = () => se.secondary(this.currentSystemTheme).border, o = () => se.secondary(this.currentSystemTheme).shadow, n = () => se.secondary(this.currentSystemTheme).borderRadius, c = () => se.secondary(this.currentSystemTheme).fontSize, d = () => se.secondary(this.currentSystemTheme).fontWeight;
|
|
116
1018
|
return `
|
|
117
1019
|
:host {
|
|
118
1020
|
display: inline-block;
|
|
@@ -120,27 +1022,27 @@ class Ie extends bo {
|
|
|
120
1022
|
|
|
121
1023
|
button {
|
|
122
1024
|
border: none;
|
|
123
|
-
border-radius: ${
|
|
124
|
-
font-weight: ${
|
|
125
|
-
font-family: ${
|
|
126
|
-
font-size: ${
|
|
1025
|
+
border-radius: ${t.borderRadius ?? n()};
|
|
1026
|
+
font-weight: ${t.fontWeight ?? d()};
|
|
1027
|
+
font-family: ${t.fontFamily ?? "inherit"};
|
|
1028
|
+
font-size: ${t.fontSize ?? c()};
|
|
127
1029
|
padding: 6px 10px;
|
|
128
1030
|
cursor: pointer;
|
|
129
1031
|
width: 100%;
|
|
130
1032
|
height: 100%;
|
|
131
|
-
background-color: ${
|
|
132
|
-
color: ${
|
|
133
|
-
border: ${
|
|
134
|
-
box-shadow: ${
|
|
1033
|
+
background-color: ${t.backgroundColor ?? i()};
|
|
1034
|
+
color: ${t.textColor ?? e()};
|
|
1035
|
+
border: ${t.border ?? s()};
|
|
1036
|
+
box-shadow: ${t.shadow ?? o()};
|
|
135
1037
|
touch-action: manipulation;
|
|
136
1038
|
}
|
|
137
1039
|
|
|
138
1040
|
button:hover {
|
|
139
|
-
${
|
|
1041
|
+
${t.hoverBackgroundColor ? `background-color: ${t.hoverBackgroundColor};` : "filter: brightness(0.9);"}
|
|
140
1042
|
}
|
|
141
1043
|
|
|
142
1044
|
button:active {
|
|
143
|
-
${
|
|
1045
|
+
${t.activeBackgroundColor ? `background-color: ${t.activeBackgroundColor};` : "filter: brightness(0.8);"}
|
|
144
1046
|
}
|
|
145
1047
|
|
|
146
1048
|
button:disabled {
|
|
@@ -149,12 +1051,12 @@ class Ie extends bo {
|
|
|
149
1051
|
}
|
|
150
1052
|
`;
|
|
151
1053
|
}
|
|
152
|
-
updateButton(
|
|
153
|
-
|
|
1054
|
+
updateButton(t) {
|
|
1055
|
+
t.text && (this._button.textContent = t.text), this._style.textContent = this.getStyles(t);
|
|
154
1056
|
}
|
|
155
1057
|
}
|
|
156
|
-
customElements.get("courier-button") || customElements.define("courier-button",
|
|
157
|
-
const
|
|
1058
|
+
customElements.get("courier-button") || customElements.define("courier-button", Re);
|
|
1059
|
+
const x = {
|
|
158
1060
|
inbox: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
159
1061
|
<path d="M5.5 14.5V17C5.5 17.2812 5.71875 17.5 6 17.5H18C18.25 17.5 18.5 17.2812 18.5 17V14.5H15.9375L15.2812 15.8125C15.0938 16.25 14.6562 16.5 14.1875 16.5H9.78125C9.3125 16.5 8.875 16.25 8.6875 15.8125L8.03125 14.5H5.5ZM18.1875 13L16.6562 6.90625C16.5938 6.65625 16.4062 6.5 16.1875 6.5H7.8125C7.5625 6.5 7.375 6.65625 7.3125 6.90625L5.78125 13H8.1875C8.65625 13 9.09375 13.2812 9.3125 13.7188L9.9375 15H14.0312L14.6875 13.7188C14.875 13.2812 15.3125 13 15.7812 13H18.1875ZM4 14.25C4 14.0938 4 13.9375 4.03125 13.7812L5.84375 6.53125C6.09375 5.625 6.875 5 7.8125 5H16.1875C17.0938 5 17.9062 5.625 18.125 6.53125L19.9375 13.7812C19.9688 13.9375 20 14.0938 20 14.25V17C20 18.125 19.0938 19 18 19H6C4.875 19 4 18.125 4 17V14.25Z" fill="currentColor"/>
|
|
160
1062
|
</svg>`,
|
|
@@ -183,13 +1085,13 @@ const f = {
|
|
|
183
1085
|
<path d="M5.5 11C5.0625 11 4.75 10.6875 4.75 10.25V5.75C4.75 5.34375 5.0625 5 5.5 5C5.90625 5 6.25 5.34375 6.25 5.75V8.28125L6.875 7.53125C8.15625 6 10.0625 5 12.25 5C16.0938 5 19.25 8.15625 19.25 12C19.25 15.875 16.0938 19 12.25 19C10.6562 19 9.21875 18.5 8.03125 17.625C7.71875 17.375 7.625 16.9062 7.875 16.5625C8.125 16.2188 8.59375 16.1562 8.9375 16.4062C9.84375 17.0938 11 17.5 12.25 17.5C15.2812 17.5 17.75 15.0625 17.75 12C17.75 8.96875 15.2812 6.5 12.25 6.5C10.5312 6.5 9.03125 7.28125 8 8.5L7.15625 9.5H10C10.4062 9.5 10.75 9.84375 10.75 10.25C10.75 10.6875 10.4062 11 10 11H5.5Z" fill="currentColor"/>
|
|
184
1086
|
</svg>`
|
|
185
1087
|
};
|
|
186
|
-
class
|
|
187
|
-
constructor(
|
|
188
|
-
super(),
|
|
189
|
-
const
|
|
190
|
-
this._iconContainer = document.createElement("div"),
|
|
1088
|
+
class ne extends HTMLElement {
|
|
1089
|
+
constructor(t, e) {
|
|
1090
|
+
super(), $(this, "_color"), $(this, "_svg"), $(this, "_iconContainer"), $(this, "_style"), this._color = t ?? r.black[500], this._svg = e;
|
|
1091
|
+
const i = this.attachShadow({ mode: "open" });
|
|
1092
|
+
this._iconContainer = document.createElement("div"), i.appendChild(this._iconContainer), this._style = document.createElement("style"), this._style.textContent = this.getStyles(this._color), i.appendChild(this._style), this.refresh();
|
|
191
1093
|
}
|
|
192
|
-
getStyles(
|
|
1094
|
+
getStyles(t) {
|
|
193
1095
|
return `
|
|
194
1096
|
:host {
|
|
195
1097
|
display: inline-block;
|
|
@@ -202,25 +1104,25 @@ class ie extends HTMLElement {
|
|
|
202
1104
|
svg {
|
|
203
1105
|
width: 24px;
|
|
204
1106
|
height: 24px;
|
|
205
|
-
color: ${
|
|
1107
|
+
color: ${t};
|
|
206
1108
|
}
|
|
207
1109
|
`;
|
|
208
1110
|
}
|
|
209
1111
|
refresh() {
|
|
210
1112
|
this._svg && (this._iconContainer.innerHTML = this._svg), this._color && (this._style.textContent = this.getStyles(this._color));
|
|
211
1113
|
}
|
|
212
|
-
updateColor(
|
|
213
|
-
this._color =
|
|
1114
|
+
updateColor(t) {
|
|
1115
|
+
this._color = t, this.refresh();
|
|
214
1116
|
}
|
|
215
|
-
updateSVG(
|
|
216
|
-
this._svg =
|
|
1117
|
+
updateSVG(t) {
|
|
1118
|
+
this._svg = t, this.refresh();
|
|
217
1119
|
}
|
|
218
1120
|
}
|
|
219
|
-
customElements.get("courier-icon") || customElements.define("courier-icon",
|
|
220
|
-
class
|
|
1121
|
+
customElements.get("courier-icon") || customElements.define("courier-icon", ne);
|
|
1122
|
+
class Ue extends HTMLElement {
|
|
221
1123
|
constructor() {
|
|
222
|
-
super(),
|
|
223
|
-
const
|
|
1124
|
+
super(), $(this, "link");
|
|
1125
|
+
const t = this.attachShadow({ mode: "open" });
|
|
224
1126
|
this.link = document.createElement("a"), this.link.setAttribute("part", "link");
|
|
225
1127
|
const e = document.createElement("style");
|
|
226
1128
|
e.textContent = `
|
|
@@ -240,7 +1142,7 @@ class Pe extends HTMLElement {
|
|
|
240
1142
|
|
|
241
1143
|
/* Variants */
|
|
242
1144
|
a[data-variant="primary"][data-mode="light"] {
|
|
243
|
-
color: var(--courier-link-color, ${
|
|
1145
|
+
color: var(--courier-link-color, ${W.light.colors.link});
|
|
244
1146
|
}
|
|
245
1147
|
|
|
246
1148
|
a[data-variant="primary"][data-mode="light"]:hover {
|
|
@@ -252,7 +1154,7 @@ class Pe extends HTMLElement {
|
|
|
252
1154
|
}
|
|
253
1155
|
|
|
254
1156
|
a[data-variant="primary"][data-mode="dark"] {
|
|
255
|
-
color: var(--courier-link-color, ${
|
|
1157
|
+
color: var(--courier-link-color, ${W.dark.colors.link});
|
|
256
1158
|
}
|
|
257
1159
|
|
|
258
1160
|
a[data-variant="primary"][data-mode="dark"]:hover {
|
|
@@ -272,15 +1174,15 @@ class Pe extends HTMLElement {
|
|
|
272
1174
|
cursor: not-allowed;
|
|
273
1175
|
pointer-events: none;
|
|
274
1176
|
}
|
|
275
|
-
`,
|
|
1177
|
+
`, t.appendChild(e), t.appendChild(this.link), this.updateVariant(), this.updateUnderline(), this.updateMode();
|
|
276
1178
|
}
|
|
277
1179
|
connectedCallback() {
|
|
278
|
-
const
|
|
279
|
-
this.link.appendChild(
|
|
1180
|
+
const t = document.createElement("slot");
|
|
1181
|
+
this.link.appendChild(t), this.updateHref();
|
|
280
1182
|
}
|
|
281
|
-
attributeChangedCallback(
|
|
282
|
-
if (e !==
|
|
283
|
-
switch (
|
|
1183
|
+
attributeChangedCallback(t, e, i) {
|
|
1184
|
+
if (e !== i)
|
|
1185
|
+
switch (t) {
|
|
284
1186
|
case "href":
|
|
285
1187
|
this.updateHref();
|
|
286
1188
|
break;
|
|
@@ -309,39 +1211,39 @@ class Pe extends HTMLElement {
|
|
|
309
1211
|
}
|
|
310
1212
|
}
|
|
311
1213
|
updateHref() {
|
|
312
|
-
const
|
|
313
|
-
|
|
1214
|
+
const t = this.getAttribute("href");
|
|
1215
|
+
t && (this.link.href = t);
|
|
314
1216
|
}
|
|
315
1217
|
updateVariant() {
|
|
316
|
-
const
|
|
317
|
-
this.link.setAttribute("data-variant",
|
|
1218
|
+
const t = this.getAttribute("variant") || "primary", e = this.getAttribute("mode") || "light";
|
|
1219
|
+
this.link.setAttribute("data-variant", t), this.link.setAttribute("data-mode", e);
|
|
318
1220
|
}
|
|
319
1221
|
updateColor() {
|
|
320
|
-
const
|
|
321
|
-
|
|
1222
|
+
const t = this.getAttribute("color");
|
|
1223
|
+
t ? this.link.style.setProperty("--courier-link-color", t) : this.link.style.removeProperty("--courier-link-color");
|
|
322
1224
|
}
|
|
323
1225
|
updateUnderline() {
|
|
324
|
-
const
|
|
325
|
-
this.link.setAttribute("data-underline",
|
|
1226
|
+
const t = this.getAttribute("underline") === "true";
|
|
1227
|
+
this.link.setAttribute("data-underline", t.toString());
|
|
326
1228
|
}
|
|
327
1229
|
updateMode() {
|
|
328
|
-
const
|
|
329
|
-
this.link.setAttribute("data-mode",
|
|
1230
|
+
const t = this.getAttribute("mode") || "light";
|
|
1231
|
+
this.link.setAttribute("data-mode", t);
|
|
330
1232
|
}
|
|
331
1233
|
updateTarget() {
|
|
332
|
-
const
|
|
333
|
-
|
|
1234
|
+
const t = this.getAttribute("target");
|
|
1235
|
+
t && (this.link.target = t);
|
|
334
1236
|
}
|
|
335
1237
|
updateFontFamily() {
|
|
336
|
-
const
|
|
337
|
-
|
|
1238
|
+
const t = this.getAttribute("font-family");
|
|
1239
|
+
t ? this.link.style.setProperty("--courier-link-font-family", t) : this.link.style.removeProperty("--courier-link-font-family");
|
|
338
1240
|
}
|
|
339
1241
|
updateFontSize() {
|
|
340
|
-
const
|
|
341
|
-
|
|
1242
|
+
const t = this.getAttribute("font-size");
|
|
1243
|
+
t ? this.link.style.setProperty("--courier-link-font-size", t) : this.link.style.removeProperty("--courier-link-font-size");
|
|
342
1244
|
}
|
|
343
1245
|
}
|
|
344
|
-
|
|
1246
|
+
$(Ue, "observedAttributes", [
|
|
345
1247
|
"href",
|
|
346
1248
|
"variant",
|
|
347
1249
|
"disabled",
|
|
@@ -352,46 +1254,46 @@ L(Pe, "observedAttributes", [
|
|
|
352
1254
|
"font-family",
|
|
353
1255
|
"font-size"
|
|
354
1256
|
]);
|
|
355
|
-
customElements.get("courier-link") || customElements.define("courier-link",
|
|
356
|
-
class
|
|
1257
|
+
customElements.get("courier-link") || customElements.define("courier-link", Ue);
|
|
1258
|
+
class De extends $o {
|
|
357
1259
|
constructor() {
|
|
358
|
-
super(),
|
|
1260
|
+
super(), $(this, "shadow"), this.shadow = this.attachShadow({ mode: "open" });
|
|
359
1261
|
}
|
|
360
1262
|
// Build the element with a factory function
|
|
361
|
-
build(
|
|
362
|
-
if (
|
|
1263
|
+
build(t) {
|
|
1264
|
+
if (t === null) {
|
|
363
1265
|
this.shadow.replaceChildren();
|
|
364
1266
|
return;
|
|
365
1267
|
}
|
|
366
|
-
const e =
|
|
1268
|
+
const e = t ?? this.defaultElement();
|
|
367
1269
|
this.shadow.replaceChildren(e);
|
|
368
1270
|
}
|
|
369
1271
|
// Default element to be used if no factory is provided
|
|
370
1272
|
defaultElement() {
|
|
371
|
-
const
|
|
372
|
-
return
|
|
1273
|
+
const t = document.createElement("div");
|
|
1274
|
+
return t.textContent = "Default Element Factory", t.style.cssText = `
|
|
373
1275
|
background-color: red;
|
|
374
1276
|
text-align: center;
|
|
375
1277
|
padding: 12px;
|
|
376
|
-
`,
|
|
1278
|
+
`, t;
|
|
377
1279
|
}
|
|
378
1280
|
}
|
|
379
|
-
class
|
|
380
|
-
constructor(
|
|
381
|
-
super(),
|
|
1281
|
+
class Be extends De {
|
|
1282
|
+
constructor(t) {
|
|
1283
|
+
super(), $(this, "_props"), $(this, "_title"), $(this, "_button"), $(this, "_style"), $(this, "_buttonClickCallback", null), this._props = t;
|
|
382
1284
|
}
|
|
383
1285
|
defaultElement() {
|
|
384
|
-
var
|
|
385
|
-
const
|
|
386
|
-
return this._title = document.createElement("h2"), (
|
|
1286
|
+
var t, e;
|
|
1287
|
+
const i = document.createElement("div");
|
|
1288
|
+
return this._title = document.createElement("h2"), (t = this._props.title) != null && t.text && (this._title.textContent = this._props.title.text), this._button = new Re(this._props.button ?? se.secondary(this.currentSystemTheme)), this._style = document.createElement("style"), this._style.textContent = this.getStyles(this._props), i.className = "container", i.appendChild(this._style), i.appendChild(this._title), i.appendChild(this._button), this.shadow.appendChild(i), (e = this._button) == null || e.addEventListener("click", () => {
|
|
387
1289
|
this._buttonClickCallback && this._buttonClickCallback();
|
|
388
|
-
}),
|
|
1290
|
+
}), i;
|
|
389
1291
|
}
|
|
390
|
-
onSystemThemeChange(
|
|
1292
|
+
onSystemThemeChange(t) {
|
|
391
1293
|
this.updateStyles(this._props);
|
|
392
1294
|
}
|
|
393
|
-
getStyles(
|
|
394
|
-
var e,
|
|
1295
|
+
getStyles(t) {
|
|
1296
|
+
var e, i, s, o;
|
|
395
1297
|
return `
|
|
396
1298
|
:host {
|
|
397
1299
|
display: flex;
|
|
@@ -413,26 +1315,26 @@ class Me extends Le {
|
|
|
413
1315
|
|
|
414
1316
|
.container h2 {
|
|
415
1317
|
margin: 0;
|
|
416
|
-
color: ${((e =
|
|
417
|
-
font-size: ${((
|
|
418
|
-
font-weight: ${((s =
|
|
419
|
-
font-family: ${((o =
|
|
1318
|
+
color: ${((e = t.title) == null ? void 0 : e.textColor) ?? "red"};
|
|
1319
|
+
font-size: ${((i = t.title) == null ? void 0 : i.fontSize) ?? "16px"};
|
|
1320
|
+
font-weight: ${((s = t.title) == null ? void 0 : s.fontWeight) ?? "500"};
|
|
1321
|
+
font-family: ${((o = t.title) == null ? void 0 : o.fontFamily) ?? "inherit"};
|
|
420
1322
|
}
|
|
421
1323
|
`;
|
|
422
1324
|
}
|
|
423
|
-
updateStyles(
|
|
424
|
-
this._props =
|
|
1325
|
+
updateStyles(t) {
|
|
1326
|
+
this._props = t, this._style && (this._style.textContent = this.getStyles(t)), this._button && this._button.updateButton(t.button);
|
|
425
1327
|
}
|
|
426
|
-
setButtonClickCallback(
|
|
427
|
-
this._buttonClickCallback =
|
|
1328
|
+
setButtonClickCallback(t) {
|
|
1329
|
+
this._buttonClickCallback = t;
|
|
428
1330
|
}
|
|
429
1331
|
}
|
|
430
|
-
customElements.get("courier-info-state") || customElements.define("courier-info-state",
|
|
431
|
-
class
|
|
432
|
-
constructor(
|
|
433
|
-
super(),
|
|
434
|
-
const
|
|
435
|
-
this._button = document.createElement("button"), this._button.setAttribute("part", "button"), this._icon = new
|
|
1332
|
+
customElements.get("courier-info-state") || customElements.define("courier-info-state", Be);
|
|
1333
|
+
class $e extends HTMLElement {
|
|
1334
|
+
constructor(t, e, i, s, o, n, c, d) {
|
|
1335
|
+
super(), $(this, "_backgroundColor"), $(this, "_hoverBackgroundColor"), $(this, "_activeBackgroundColor"), $(this, "_borderRadius"), $(this, "_height"), $(this, "_width"), $(this, "_style"), $(this, "_button"), $(this, "_icon"), this._borderRadius = n, this._backgroundColor = i, this._hoverBackgroundColor = s, this._activeBackgroundColor = o, this._height = c, this._width = d;
|
|
1336
|
+
const l = this.attachShadow({ mode: "open" });
|
|
1337
|
+
this._button = document.createElement("button"), this._button.setAttribute("part", "button"), this._icon = new ne(e, t), this._style = document.createElement("style"), this.refresh(), l.appendChild(this._style), this._button.appendChild(this._icon), l.appendChild(this._button);
|
|
436
1338
|
}
|
|
437
1339
|
refresh() {
|
|
438
1340
|
this._style.textContent = this.getStyles();
|
|
@@ -480,34 +1382,34 @@ class Se extends HTMLElement {
|
|
|
480
1382
|
}
|
|
481
1383
|
`;
|
|
482
1384
|
}
|
|
483
|
-
updateIconColor(
|
|
484
|
-
this._icon.updateColor(
|
|
1385
|
+
updateIconColor(t) {
|
|
1386
|
+
this._icon.updateColor(t);
|
|
485
1387
|
}
|
|
486
|
-
updateIconSVG(
|
|
487
|
-
this._icon.updateSVG(
|
|
1388
|
+
updateIconSVG(t) {
|
|
1389
|
+
this._icon.updateSVG(t);
|
|
488
1390
|
}
|
|
489
|
-
updateBackgroundColor(
|
|
490
|
-
this._backgroundColor =
|
|
1391
|
+
updateBackgroundColor(t) {
|
|
1392
|
+
this._backgroundColor = t, this.refresh();
|
|
491
1393
|
}
|
|
492
|
-
updateHoverBackgroundColor(
|
|
493
|
-
this._hoverBackgroundColor =
|
|
1394
|
+
updateHoverBackgroundColor(t) {
|
|
1395
|
+
this._hoverBackgroundColor = t, this.refresh();
|
|
494
1396
|
}
|
|
495
|
-
updateActiveBackgroundColor(
|
|
496
|
-
this._activeBackgroundColor =
|
|
1397
|
+
updateActiveBackgroundColor(t) {
|
|
1398
|
+
this._activeBackgroundColor = t, this.refresh();
|
|
497
1399
|
}
|
|
498
1400
|
}
|
|
499
|
-
customElements.get("courier-icon-button") || customElements.define("courier-icon-button",
|
|
500
|
-
const
|
|
501
|
-
{ name: "courier-button", class:
|
|
502
|
-
{ name: "courier-icon", class:
|
|
503
|
-
{ name: "courier-link", class:
|
|
504
|
-
{ name: "courier-info-state", class:
|
|
505
|
-
{ name: "courier-icon-button", class:
|
|
1401
|
+
customElements.get("courier-icon-button") || customElements.define("courier-icon-button", $e);
|
|
1402
|
+
const cn = [
|
|
1403
|
+
{ name: "courier-button", class: Re },
|
|
1404
|
+
{ name: "courier-icon", class: ne },
|
|
1405
|
+
{ name: "courier-link", class: Ue },
|
|
1406
|
+
{ name: "courier-info-state", class: Be },
|
|
1407
|
+
{ name: "courier-icon-button", class: $e }
|
|
506
1408
|
];
|
|
507
|
-
|
|
508
|
-
customElements.get(
|
|
1409
|
+
cn.forEach(({ name: h, class: t }) => {
|
|
1410
|
+
customElements.get(h) || customElements.define(h, t);
|
|
509
1411
|
});
|
|
510
|
-
const
|
|
1412
|
+
const oe = class oe {
|
|
511
1413
|
constructor() {
|
|
512
1414
|
a(this, "_inboxDataSet");
|
|
513
1415
|
a(this, "_archiveDataSet");
|
|
@@ -517,7 +1419,7 @@ const te = class te {
|
|
|
517
1419
|
a(this, "isPaginatingArchive", !1);
|
|
518
1420
|
}
|
|
519
1421
|
static get shared() {
|
|
520
|
-
return
|
|
1422
|
+
return oe.instance || (oe.instance = new oe()), oe.instance;
|
|
521
1423
|
}
|
|
522
1424
|
get unreadCount() {
|
|
523
1425
|
return this._unreadCount ?? 0;
|
|
@@ -528,16 +1430,16 @@ const te = class te {
|
|
|
528
1430
|
get archiveDataSet() {
|
|
529
1431
|
return this._archiveDataSet ?? { messages: [], canPaginate: !1, paginationCursor: null };
|
|
530
1432
|
}
|
|
531
|
-
addDataStoreListener(
|
|
532
|
-
this._dataStoreListeners.push(
|
|
1433
|
+
addDataStoreListener(t) {
|
|
1434
|
+
this._dataStoreListeners.push(t);
|
|
533
1435
|
}
|
|
534
|
-
removeDataStoreListener(
|
|
535
|
-
this._dataStoreListeners = this._dataStoreListeners.filter((e) => e !==
|
|
1436
|
+
removeDataStoreListener(t) {
|
|
1437
|
+
this._dataStoreListeners = this._dataStoreListeners.filter((e) => e !== t);
|
|
536
1438
|
}
|
|
537
|
-
async fetchDataSet(
|
|
538
|
-
var
|
|
539
|
-
if (
|
|
540
|
-
switch (
|
|
1439
|
+
async fetchDataSet(t) {
|
|
1440
|
+
var i, s, o, n, c, d, l, p, m, g;
|
|
1441
|
+
if (t.canUseCache)
|
|
1442
|
+
switch (t.feedType) {
|
|
541
1443
|
case "inbox":
|
|
542
1444
|
if (this._inboxDataSet)
|
|
543
1445
|
return this._inboxDataSet;
|
|
@@ -547,23 +1449,23 @@ const te = class te {
|
|
|
547
1449
|
return this._archiveDataSet;
|
|
548
1450
|
break;
|
|
549
1451
|
}
|
|
550
|
-
const e =
|
|
1452
|
+
const e = t.feedType === "inbox" ? await ((i = v.shared.client) == null ? void 0 : i.inbox.getMessages()) : await ((s = v.shared.client) == null ? void 0 : s.inbox.getArchivedMessages());
|
|
551
1453
|
return {
|
|
552
1454
|
messages: ((n = (o = e == null ? void 0 : e.data) == null ? void 0 : o.messages) == null ? void 0 : n.nodes) ?? [],
|
|
553
|
-
canPaginate: ((
|
|
554
|
-
paginationCursor: ((
|
|
1455
|
+
canPaginate: ((l = (d = (c = e == null ? void 0 : e.data) == null ? void 0 : c.messages) == null ? void 0 : d.pageInfo) == null ? void 0 : l.hasNextPage) ?? !1,
|
|
1456
|
+
paginationCursor: ((g = (m = (p = e == null ? void 0 : e.data) == null ? void 0 : p.messages) == null ? void 0 : m.pageInfo) == null ? void 0 : g.startCursor) ?? null
|
|
555
1457
|
};
|
|
556
1458
|
}
|
|
557
|
-
async fetchUnreadCount(
|
|
558
|
-
var
|
|
559
|
-
return
|
|
1459
|
+
async fetchUnreadCount(t) {
|
|
1460
|
+
var i;
|
|
1461
|
+
return t.canUseCache && this._unreadCount !== void 0 ? this._unreadCount : await ((i = v.shared.client) == null ? void 0 : i.inbox.getUnreadMessageCount()) ?? 0;
|
|
560
1462
|
}
|
|
561
|
-
async load(
|
|
562
|
-
var e,
|
|
1463
|
+
async load(t) {
|
|
1464
|
+
var e, i, s;
|
|
563
1465
|
try {
|
|
564
|
-
if (!((e =
|
|
1466
|
+
if (!((e = v.shared.client) != null && e.options.userId))
|
|
565
1467
|
throw new Error("User is not signed in");
|
|
566
|
-
const o =
|
|
1468
|
+
const o = t ?? { feedType: "inbox", canUseCache: !0 }, [n, c] = await Promise.all([
|
|
567
1469
|
this.fetchDataSet(o),
|
|
568
1470
|
this.fetchUnreadCount(o)
|
|
569
1471
|
]);
|
|
@@ -575,85 +1477,88 @@ const te = class te {
|
|
|
575
1477
|
this._archiveDataSet = n;
|
|
576
1478
|
break;
|
|
577
1479
|
}
|
|
578
|
-
this._unreadCount =
|
|
579
|
-
var
|
|
580
|
-
(
|
|
1480
|
+
this._unreadCount = c, this._dataStoreListeners.forEach((d) => {
|
|
1481
|
+
var l, p, m, g;
|
|
1482
|
+
(p = (l = d.events).onDataSetChange) == null || p.call(l, n, o.feedType), (g = (m = d.events).onUnreadCountChange) == null || g.call(m, this._unreadCount ?? 0);
|
|
581
1483
|
}), await this.connectSocket();
|
|
582
1484
|
} catch (o) {
|
|
583
|
-
(s = (
|
|
584
|
-
var
|
|
585
|
-
(d = (
|
|
1485
|
+
(s = (i = v.shared.client) == null ? void 0 : i.options.logger) == null || s.error("Error loading inbox:", o), this._dataStoreListeners.forEach((n) => {
|
|
1486
|
+
var c, d;
|
|
1487
|
+
(d = (c = n.events).onError) == null || d.call(c, o);
|
|
586
1488
|
});
|
|
587
1489
|
}
|
|
588
1490
|
}
|
|
589
1491
|
async connectSocket() {
|
|
590
|
-
var e,
|
|
591
|
-
const
|
|
1492
|
+
var e, i, s, o, n, c, d, l, p, m, g, f;
|
|
1493
|
+
const t = (e = v.shared.client) == null ? void 0 : e.inbox.socket;
|
|
592
1494
|
try {
|
|
593
|
-
if (!
|
|
594
|
-
(s = (
|
|
1495
|
+
if (!t) {
|
|
1496
|
+
(s = (i = v.shared.client) == null ? void 0 : i.options.logger) == null || s.info("CourierInbox socket not available");
|
|
595
1497
|
return;
|
|
596
1498
|
}
|
|
597
|
-
if ((
|
|
598
|
-
(
|
|
1499
|
+
if ((c = (o = v.shared.client) == null ? void 0 : o.options.logger) == null || c.info("CourierInbox socket connectionId:", (n = v.shared.client) == null ? void 0 : n.options.connectionId), t.isConnected) {
|
|
1500
|
+
(l = (d = v.shared.client) == null ? void 0 : d.options.logger) == null || l.info("CourierInbox socket already connected. Socket will not attempt reconnection.");
|
|
599
1501
|
return;
|
|
600
1502
|
}
|
|
601
|
-
|
|
1503
|
+
t.receivedMessage = (_) => {
|
|
602
1504
|
this.addMessage(_, 0, "inbox");
|
|
603
|
-
},
|
|
1505
|
+
}, t.receivedMessageEvent = (_) => {
|
|
604
1506
|
let b;
|
|
605
1507
|
switch (_.messageId && (b = this.getMessage({ messageId: _.messageId })), _.event) {
|
|
606
1508
|
case "mark-all-read":
|
|
607
|
-
this.readAllMessages();
|
|
1509
|
+
this.readAllMessages({ canCallApi: !1 });
|
|
608
1510
|
break;
|
|
609
1511
|
case "read":
|
|
610
|
-
b && this.readMessage(b, !1);
|
|
1512
|
+
b && this.readMessage({ message: b, canCallApi: !1 });
|
|
611
1513
|
break;
|
|
612
1514
|
case "unread":
|
|
613
|
-
b && this.unreadMessage(b, !1);
|
|
1515
|
+
b && this.unreadMessage({ message: b, canCallApi: !1 });
|
|
614
1516
|
break;
|
|
615
1517
|
case "opened":
|
|
616
|
-
b && this.openMessage(b, !1);
|
|
1518
|
+
b && this.openMessage({ message: b, canCallApi: !1 });
|
|
617
1519
|
break;
|
|
618
1520
|
case "archive":
|
|
619
|
-
b && this.archiveMessage(b, !1);
|
|
1521
|
+
b && this.archiveMessage({ message: b, canCallApi: !1 });
|
|
1522
|
+
break;
|
|
1523
|
+
case "archive-read":
|
|
1524
|
+
this.archiveReadMessages({ canCallApi: !1 });
|
|
620
1525
|
break;
|
|
621
1526
|
case "click":
|
|
622
|
-
b && this.clickMessage(b, !1);
|
|
1527
|
+
b && this.clickMessage({ message: b, canCallApi: !1 });
|
|
623
1528
|
break;
|
|
624
1529
|
case "unopened":
|
|
625
1530
|
case "unarchive":
|
|
626
1531
|
break;
|
|
627
1532
|
}
|
|
628
|
-
}, await
|
|
1533
|
+
}, await t.connect(), await t.sendSubscribe(), t.keepAlive(), (m = (p = v.shared.client) == null ? void 0 : p.options.logger) == null || m.info("CourierInbox socket connected");
|
|
629
1534
|
} catch (_) {
|
|
630
|
-
(
|
|
1535
|
+
(f = (g = v.shared.client) == null ? void 0 : g.options.logger) == null || f.error("Failed to connect socket:", _);
|
|
631
1536
|
}
|
|
632
1537
|
}
|
|
633
|
-
getMessage(
|
|
634
|
-
var e,
|
|
635
|
-
return ((e = this._inboxDataSet) == null ? void 0 : e.messages.find((s) => s.messageId ===
|
|
1538
|
+
getMessage(t) {
|
|
1539
|
+
var e, i;
|
|
1540
|
+
return ((e = this._inboxDataSet) == null ? void 0 : e.messages.find((s) => s.messageId === t.messageId)) ?? ((i = this._archiveDataSet) == null ? void 0 : i.messages.find((s) => s.messageId === t.messageId));
|
|
636
1541
|
}
|
|
637
|
-
async fetchNextPageOfMessages(
|
|
638
|
-
var e,
|
|
639
|
-
switch (
|
|
1542
|
+
async fetchNextPageOfMessages(t) {
|
|
1543
|
+
var e, i, s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I, E, M, L, R, D;
|
|
1544
|
+
switch (t.feedType) {
|
|
640
1545
|
case "inbox":
|
|
641
1546
|
if (this.isPaginatingInbox)
|
|
642
1547
|
return null;
|
|
643
1548
|
if ((e = this._inboxDataSet) != null && e.canPaginate && this._inboxDataSet.paginationCursor)
|
|
644
1549
|
try {
|
|
645
1550
|
this.isPaginatingInbox = !0;
|
|
646
|
-
const y = await ((
|
|
647
|
-
paginationLimit:
|
|
1551
|
+
const y = await ((i = v.shared.client) == null ? void 0 : i.inbox.getMessages({
|
|
1552
|
+
paginationLimit: v.shared.paginationLimit,
|
|
648
1553
|
startCursor: this._inboxDataSet.paginationCursor
|
|
649
|
-
})),
|
|
1554
|
+
})), A = {
|
|
650
1555
|
messages: ((o = (s = y == null ? void 0 : y.data) == null ? void 0 : s.messages) == null ? void 0 : o.nodes) ?? [],
|
|
651
|
-
canPaginate: ((d = (
|
|
652
|
-
paginationCursor: ((m = (
|
|
1556
|
+
canPaginate: ((d = (c = (n = y == null ? void 0 : y.data) == null ? void 0 : n.messages) == null ? void 0 : c.pageInfo) == null ? void 0 : d.hasNextPage) ?? !1,
|
|
1557
|
+
paginationCursor: ((m = (p = (l = y == null ? void 0 : y.data) == null ? void 0 : l.messages) == null ? void 0 : p.pageInfo) == null ? void 0 : m.startCursor) ?? null
|
|
653
1558
|
};
|
|
654
|
-
return this.addPage(
|
|
1559
|
+
return this.addPage(A, "inbox"), A;
|
|
655
1560
|
} catch (y) {
|
|
656
|
-
return (
|
|
1561
|
+
return (f = (g = v.shared.client) == null ? void 0 : g.options.logger) == null || f.error("Error fetching next page of inbox messages:", y), null;
|
|
657
1562
|
} finally {
|
|
658
1563
|
this.isPaginatingInbox = !1;
|
|
659
1564
|
}
|
|
@@ -664,17 +1569,17 @@ const te = class te {
|
|
|
664
1569
|
if ((_ = this._archiveDataSet) != null && _.canPaginate && this._archiveDataSet.paginationCursor)
|
|
665
1570
|
try {
|
|
666
1571
|
this.isPaginatingArchive = !0;
|
|
667
|
-
const y = await ((b =
|
|
668
|
-
paginationLimit:
|
|
1572
|
+
const y = await ((b = v.shared.client) == null ? void 0 : b.inbox.getArchivedMessages({
|
|
1573
|
+
paginationLimit: v.shared.paginationLimit,
|
|
669
1574
|
startCursor: this._archiveDataSet.paginationCursor
|
|
670
|
-
})),
|
|
671
|
-
messages: ((k = (
|
|
672
|
-
canPaginate: ((
|
|
673
|
-
paginationCursor: ((
|
|
1575
|
+
})), A = {
|
|
1576
|
+
messages: ((k = (C = y == null ? void 0 : y.data) == null ? void 0 : C.messages) == null ? void 0 : k.nodes) ?? [],
|
|
1577
|
+
canPaginate: ((I = (S = (w = y == null ? void 0 : y.data) == null ? void 0 : w.messages) == null ? void 0 : S.pageInfo) == null ? void 0 : I.hasNextPage) ?? !1,
|
|
1578
|
+
paginationCursor: ((L = (M = (E = y == null ? void 0 : y.data) == null ? void 0 : E.messages) == null ? void 0 : M.pageInfo) == null ? void 0 : L.startCursor) ?? null
|
|
674
1579
|
};
|
|
675
|
-
return this.addPage(
|
|
1580
|
+
return this.addPage(A, "archive"), A;
|
|
676
1581
|
} catch (y) {
|
|
677
|
-
return (D = (
|
|
1582
|
+
return (D = (R = v.shared.client) == null ? void 0 : R.options.logger) == null || D.error("Error fetching next page of archived messages:", y), null;
|
|
678
1583
|
} finally {
|
|
679
1584
|
this.isPaginatingArchive = !1;
|
|
680
1585
|
}
|
|
@@ -682,201 +1587,227 @@ const te = class te {
|
|
|
682
1587
|
}
|
|
683
1588
|
return null;
|
|
684
1589
|
}
|
|
685
|
-
applyLocalMessageChange(
|
|
686
|
-
for (const [
|
|
687
|
-
s !== void 0 && this.updateMessage(
|
|
1590
|
+
applyLocalMessageChange(t, e) {
|
|
1591
|
+
for (const [i, s] of Object.entries(e))
|
|
1592
|
+
s !== void 0 && this.updateMessage(t, s, i);
|
|
688
1593
|
}
|
|
689
|
-
async readMessage(
|
|
690
|
-
var o, n,
|
|
691
|
-
if (!
|
|
1594
|
+
async readMessage({ message: t, canCallApi: e = !0 }) {
|
|
1595
|
+
var o, n, c, d;
|
|
1596
|
+
if (!v.shared.client)
|
|
692
1597
|
return;
|
|
693
|
-
const
|
|
694
|
-
if (
|
|
1598
|
+
const i = t;
|
|
1599
|
+
if (i.read)
|
|
695
1600
|
return;
|
|
696
1601
|
const s = {
|
|
697
|
-
inbox: (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((
|
|
698
|
-
archive: (n = this._archiveDataSet) == null ? void 0 : n.messages.findIndex((
|
|
1602
|
+
inbox: (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((l) => l.messageId === t.messageId),
|
|
1603
|
+
archive: (n = this._archiveDataSet) == null ? void 0 : n.messages.findIndex((l) => l.messageId === t.messageId)
|
|
699
1604
|
};
|
|
700
1605
|
try {
|
|
701
|
-
|
|
702
|
-
} catch (
|
|
703
|
-
this.applyLocalMessageChange(
|
|
1606
|
+
t.read = (/* @__PURE__ */ new Date()).toISOString(), this.applyLocalMessageChange(t, s), e && await v.shared.client.inbox.read({ messageId: t.messageId });
|
|
1607
|
+
} catch (l) {
|
|
1608
|
+
this.applyLocalMessageChange(i, s), (d = (c = v.shared.client) == null ? void 0 : c.options.logger) == null || d.error("Error reading message:", l);
|
|
704
1609
|
}
|
|
705
1610
|
}
|
|
706
|
-
async unreadMessage(
|
|
707
|
-
var o, n,
|
|
708
|
-
if (!
|
|
1611
|
+
async unreadMessage({ message: t, canCallApi: e = !0 }) {
|
|
1612
|
+
var o, n, c, d;
|
|
1613
|
+
if (!v.shared.client)
|
|
709
1614
|
return;
|
|
710
|
-
const
|
|
711
|
-
if (!
|
|
1615
|
+
const i = t;
|
|
1616
|
+
if (!i.read)
|
|
712
1617
|
return;
|
|
713
1618
|
const s = {
|
|
714
|
-
inbox: (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((
|
|
715
|
-
archive: (n = this._archiveDataSet) == null ? void 0 : n.messages.findIndex((
|
|
1619
|
+
inbox: (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((l) => l.messageId === t.messageId),
|
|
1620
|
+
archive: (n = this._archiveDataSet) == null ? void 0 : n.messages.findIndex((l) => l.messageId === t.messageId)
|
|
716
1621
|
};
|
|
717
1622
|
try {
|
|
718
|
-
|
|
719
|
-
} catch (
|
|
720
|
-
this.applyLocalMessageChange(
|
|
1623
|
+
t.read = void 0, this.applyLocalMessageChange(t, s), e && await v.shared.client.inbox.unread({ messageId: t.messageId });
|
|
1624
|
+
} catch (l) {
|
|
1625
|
+
this.applyLocalMessageChange(i, s), (d = (c = v.shared.client) == null ? void 0 : c.options.logger) == null || d.error("Error unreading message:", l);
|
|
721
1626
|
}
|
|
722
1627
|
}
|
|
723
|
-
async openMessage(
|
|
724
|
-
var o, n,
|
|
725
|
-
if (!
|
|
1628
|
+
async openMessage({ message: t, canCallApi: e = !0 }) {
|
|
1629
|
+
var o, n, c, d;
|
|
1630
|
+
if (!v.shared.client)
|
|
726
1631
|
return;
|
|
727
|
-
const
|
|
728
|
-
inbox: (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((
|
|
729
|
-
archive: (n = this._archiveDataSet) == null ? void 0 : n.messages.findIndex((
|
|
1632
|
+
const i = t, s = {
|
|
1633
|
+
inbox: (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((l) => l.messageId === t.messageId),
|
|
1634
|
+
archive: (n = this._archiveDataSet) == null ? void 0 : n.messages.findIndex((l) => l.messageId === t.messageId)
|
|
730
1635
|
};
|
|
731
|
-
if (!(!s.inbox && !s.archive) && !
|
|
1636
|
+
if (!(!s.inbox && !s.archive) && !i.opened)
|
|
732
1637
|
try {
|
|
733
|
-
|
|
734
|
-
} catch (
|
|
735
|
-
this.applyLocalMessageChange(
|
|
1638
|
+
t.opened = (/* @__PURE__ */ new Date()).toISOString(), this.applyLocalMessageChange(t, s), e && await v.shared.client.inbox.open({ messageId: t.messageId });
|
|
1639
|
+
} catch (l) {
|
|
1640
|
+
this.applyLocalMessageChange(i, s), (d = (c = v.shared.client) == null ? void 0 : c.options.logger) == null || d.error("Error opening message:", l);
|
|
736
1641
|
}
|
|
737
1642
|
}
|
|
738
|
-
async clickMessage(
|
|
739
|
-
var
|
|
740
|
-
if (
|
|
1643
|
+
async clickMessage({ message: t, canCallApi: e = !0 }) {
|
|
1644
|
+
var i, s, o, n;
|
|
1645
|
+
if (v.shared.client)
|
|
741
1646
|
try {
|
|
742
|
-
(
|
|
743
|
-
messageId:
|
|
744
|
-
trackingId: (s =
|
|
1647
|
+
(i = t.trackingIds) != null && i.clickTrackingId && e && await v.shared.client.inbox.click({
|
|
1648
|
+
messageId: t.messageId,
|
|
1649
|
+
trackingId: (s = t.trackingIds) == null ? void 0 : s.clickTrackingId
|
|
745
1650
|
});
|
|
746
|
-
} catch (
|
|
747
|
-
(n = (o =
|
|
1651
|
+
} catch (c) {
|
|
1652
|
+
(n = (o = v.shared.client) == null ? void 0 : o.options.logger) == null || n.error("Error clicking message:", c);
|
|
748
1653
|
}
|
|
749
1654
|
}
|
|
750
|
-
async archiveMessage(
|
|
1655
|
+
async archiveMessage({ message: t, canCallApi: e = !0 }) {
|
|
751
1656
|
var o, n;
|
|
752
|
-
if (!
|
|
1657
|
+
if (!v.shared.client)
|
|
753
1658
|
return;
|
|
754
|
-
const
|
|
1659
|
+
const i = t, s = (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((c) => c.messageId === t.messageId);
|
|
755
1660
|
if (s !== void 0)
|
|
756
1661
|
try {
|
|
757
|
-
if (this.removeMessage(
|
|
758
|
-
const
|
|
759
|
-
|
|
1662
|
+
if (this.removeMessage(t, s, "inbox"), (n = this._archiveDataSet) != null && n.messages) {
|
|
1663
|
+
const c = this.findInsertIndex(t, this._archiveDataSet.messages);
|
|
1664
|
+
t.archived = (/* @__PURE__ */ new Date()).toISOString(), this.addMessage(t, c, "archive");
|
|
760
1665
|
}
|
|
761
|
-
e && await
|
|
1666
|
+
e && await v.shared.client.inbox.archive({ messageId: t.messageId });
|
|
762
1667
|
} catch {
|
|
763
|
-
this.addMessage(
|
|
1668
|
+
this.addMessage(i, s, "inbox"), t.archived = void 0, this.removeMessage(t, s, "archive");
|
|
764
1669
|
}
|
|
765
1670
|
}
|
|
766
|
-
async
|
|
767
|
-
var
|
|
768
|
-
if (!
|
|
1671
|
+
async archiveReadMessages({ canCallApi: t = !0 } = {}) {
|
|
1672
|
+
var s;
|
|
1673
|
+
if (!v.shared.client)
|
|
1674
|
+
return;
|
|
1675
|
+
const e = this._inboxDataSet, i = this._archiveDataSet;
|
|
1676
|
+
try {
|
|
1677
|
+
(s = this._inboxDataSet) == null || s.messages.forEach((o) => {
|
|
1678
|
+
var c, d;
|
|
1679
|
+
if (!o.read)
|
|
1680
|
+
return;
|
|
1681
|
+
const n = (c = this._inboxDataSet) == null ? void 0 : c.messages.findIndex((l) => l.messageId === o.messageId);
|
|
1682
|
+
if (n !== void 0 && (this.removeMessage(o, n, "inbox"), (d = this._archiveDataSet) != null && d.messages)) {
|
|
1683
|
+
const l = this.findInsertIndex(o, this._archiveDataSet.messages);
|
|
1684
|
+
o.archived = (/* @__PURE__ */ new Date()).toISOString(), this.addMessage(o, l, "archive");
|
|
1685
|
+
}
|
|
1686
|
+
}), this._dataStoreListeners.forEach((o) => {
|
|
1687
|
+
var n, c, d, l;
|
|
1688
|
+
this._inboxDataSet && ((c = (n = o.events).onDataSetChange) == null || c.call(n, this._inboxDataSet, "inbox")), this._archiveDataSet && ((l = (d = o.events).onDataSetChange) == null || l.call(d, this._archiveDataSet, "archive"));
|
|
1689
|
+
}), t && await v.shared.client.inbox.archiveRead();
|
|
1690
|
+
} catch (o) {
|
|
1691
|
+
console.error("Error archiving read messages:", o), this._inboxDataSet && e && (this._inboxDataSet.messages = e.messages), this._archiveDataSet && i && (this._archiveDataSet.messages = i.messages), this._dataStoreListeners.forEach((n) => {
|
|
1692
|
+
var c, d, l, p;
|
|
1693
|
+
this._inboxDataSet && ((d = (c = n.events).onDataSetChange) == null || d.call(c, this._inboxDataSet, "inbox")), this._archiveDataSet && ((p = (l = n.events).onDataSetChange) == null || p.call(l, this._archiveDataSet, "archive"));
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
async readAllMessages({ canCallApi: t = !0 } = {}) {
|
|
1698
|
+
var o, n, c, d;
|
|
1699
|
+
if (!v.shared.client)
|
|
769
1700
|
return;
|
|
770
|
-
const e = this._inboxDataSet,
|
|
1701
|
+
const e = this._inboxDataSet, i = this._archiveDataSet, s = this._unreadCount;
|
|
771
1702
|
try {
|
|
772
|
-
(o = this._inboxDataSet) == null || o.messages.forEach((
|
|
773
|
-
|
|
774
|
-
}), (n = this._archiveDataSet) == null || n.messages.forEach((
|
|
775
|
-
|
|
776
|
-
}), this._unreadCount = 0, this._dataStoreListeners.forEach((
|
|
777
|
-
var
|
|
778
|
-
this._inboxDataSet && ((m = (
|
|
779
|
-
}),
|
|
780
|
-
} catch (
|
|
781
|
-
(d = (
|
|
782
|
-
var m,
|
|
783
|
-
this._inboxDataSet && ((
|
|
1703
|
+
(o = this._inboxDataSet) == null || o.messages.forEach((l) => {
|
|
1704
|
+
l.read || (l.read = (/* @__PURE__ */ new Date()).toISOString());
|
|
1705
|
+
}), (n = this._archiveDataSet) == null || n.messages.forEach((l) => {
|
|
1706
|
+
l.read || (l.read = (/* @__PURE__ */ new Date()).toISOString());
|
|
1707
|
+
}), this._unreadCount = 0, this._dataStoreListeners.forEach((l) => {
|
|
1708
|
+
var p, m, g, f, _, b;
|
|
1709
|
+
this._inboxDataSet && ((m = (p = l.events).onDataSetChange) == null || m.call(p, this._inboxDataSet, "inbox")), this._archiveDataSet && ((f = (g = l.events).onDataSetChange) == null || f.call(g, this._archiveDataSet, "archive")), (b = (_ = l.events).onUnreadCountChange) == null || b.call(_, this._unreadCount);
|
|
1710
|
+
}), t && await v.shared.client.inbox.readAll();
|
|
1711
|
+
} catch (l) {
|
|
1712
|
+
(d = (c = v.shared.client) == null ? void 0 : c.options.logger) == null || d.error("Error reading all messages:", l), this._inboxDataSet && e && (this._inboxDataSet.messages = e.messages), this._archiveDataSet && i && (this._archiveDataSet.messages = i.messages), this._unreadCount = s, this._dataStoreListeners.forEach((p) => {
|
|
1713
|
+
var m, g, f, _, b, C;
|
|
1714
|
+
this._inboxDataSet && ((g = (m = p.events).onDataSetChange) == null || g.call(m, this._inboxDataSet, "inbox")), this._archiveDataSet && ((_ = (f = p.events).onDataSetChange) == null || _.call(f, this._archiveDataSet, "archive")), (C = (b = p.events).onUnreadCountChange) == null || C.call(b, this._unreadCount);
|
|
784
1715
|
});
|
|
785
1716
|
}
|
|
786
1717
|
}
|
|
787
|
-
findInsertIndex(
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
const
|
|
791
|
-
return new Date(n.created ?? Date.now()).getTime() -
|
|
1718
|
+
findInsertIndex(t, e) {
|
|
1719
|
+
const i = [...e];
|
|
1720
|
+
i.push(t), i.sort((o, n) => {
|
|
1721
|
+
const c = new Date(o.created ?? Date.now()).getTime();
|
|
1722
|
+
return new Date(n.created ?? Date.now()).getTime() - c;
|
|
792
1723
|
});
|
|
793
|
-
const s =
|
|
1724
|
+
const s = i.findIndex((o) => o.messageId === t.messageId);
|
|
794
1725
|
return Math.max(s - 1, 0);
|
|
795
1726
|
}
|
|
796
|
-
addPage(
|
|
1727
|
+
addPage(t, e) {
|
|
797
1728
|
switch (e) {
|
|
798
1729
|
case "inbox":
|
|
799
|
-
this._inboxDataSet && (this._inboxDataSet.canPaginate =
|
|
1730
|
+
this._inboxDataSet && (this._inboxDataSet.canPaginate = t.canPaginate, this._inboxDataSet.paginationCursor = t.paginationCursor, this._inboxDataSet.messages = [...this._inboxDataSet.messages, ...t.messages]);
|
|
800
1731
|
break;
|
|
801
1732
|
case "archive":
|
|
802
|
-
this._archiveDataSet && (this._archiveDataSet.canPaginate =
|
|
1733
|
+
this._archiveDataSet && (this._archiveDataSet.canPaginate = t.canPaginate, this._archiveDataSet.paginationCursor = t.paginationCursor, this._archiveDataSet.messages = [...this._archiveDataSet.messages, ...t.messages]);
|
|
803
1734
|
break;
|
|
804
1735
|
}
|
|
805
1736
|
this._dataStoreListeners.forEach(
|
|
806
|
-
(
|
|
1737
|
+
(i) => {
|
|
807
1738
|
var s, o;
|
|
808
|
-
return (o = (s =
|
|
1739
|
+
return (o = (s = i.events).onPageAdded) == null ? void 0 : o.call(s, t, e);
|
|
809
1740
|
}
|
|
810
1741
|
);
|
|
811
1742
|
}
|
|
812
|
-
addMessage(
|
|
1743
|
+
addMessage(t, e, i) {
|
|
813
1744
|
var s, o;
|
|
814
|
-
switch (
|
|
1745
|
+
switch (i) {
|
|
815
1746
|
case "inbox":
|
|
816
|
-
!
|
|
1747
|
+
!t.read && this._unreadCount !== void 0 && (this._unreadCount = this._unreadCount + 1), (s = this._inboxDataSet) == null || s.messages.splice(e, 0, t);
|
|
817
1748
|
break;
|
|
818
1749
|
case "archive":
|
|
819
|
-
(o = this._archiveDataSet) == null || o.messages.splice(e, 0,
|
|
1750
|
+
(o = this._archiveDataSet) == null || o.messages.splice(e, 0, t);
|
|
820
1751
|
break;
|
|
821
1752
|
}
|
|
822
1753
|
this._dataStoreListeners.forEach((n) => {
|
|
823
|
-
var
|
|
824
|
-
(d = (
|
|
1754
|
+
var c, d, l, p;
|
|
1755
|
+
(d = (c = n.events).onMessageAdd) == null || d.call(c, t, e, i), (p = (l = n.events).onUnreadCountChange) == null || p.call(l, this._unreadCount ?? 0);
|
|
825
1756
|
});
|
|
826
1757
|
}
|
|
827
|
-
removeMessage(
|
|
1758
|
+
removeMessage(t, e, i) {
|
|
828
1759
|
var s, o;
|
|
829
|
-
switch (
|
|
1760
|
+
switch (i) {
|
|
830
1761
|
case "inbox":
|
|
831
|
-
!
|
|
1762
|
+
!t.read && this._unreadCount !== void 0 && (this._unreadCount = this._unreadCount - 1), (s = this._inboxDataSet) == null || s.messages.splice(e, 1);
|
|
832
1763
|
break;
|
|
833
1764
|
case "archive":
|
|
834
1765
|
(o = this._archiveDataSet) == null || o.messages.splice(e, 1);
|
|
835
1766
|
break;
|
|
836
1767
|
}
|
|
837
1768
|
this._dataStoreListeners.forEach((n) => {
|
|
838
|
-
var
|
|
839
|
-
(d = (
|
|
1769
|
+
var c, d, l, p;
|
|
1770
|
+
(d = (c = n.events).onMessageRemove) == null || d.call(c, t, e, i), (p = (l = n.events).onUnreadCountChange) == null || p.call(l, this._unreadCount ?? 0);
|
|
840
1771
|
});
|
|
841
1772
|
}
|
|
842
|
-
updateMessage(
|
|
843
|
-
switch (
|
|
1773
|
+
updateMessage(t, e, i) {
|
|
1774
|
+
switch (i) {
|
|
844
1775
|
case "inbox":
|
|
845
|
-
this._unreadCount !== void 0 && !
|
|
1776
|
+
this._unreadCount !== void 0 && !t.archived && (t.read && (this._unreadCount = Math.max(0, this._unreadCount - 1)), t.read || (this._unreadCount = this._unreadCount + 1)), this._inboxDataSet && (this._inboxDataSet.messages[e] = t);
|
|
846
1777
|
break;
|
|
847
1778
|
case "archive":
|
|
848
|
-
this._archiveDataSet && (this._archiveDataSet.messages[e] =
|
|
1779
|
+
this._archiveDataSet && (this._archiveDataSet.messages[e] = t);
|
|
849
1780
|
break;
|
|
850
1781
|
}
|
|
851
1782
|
this._dataStoreListeners.forEach((s) => {
|
|
852
|
-
var o, n,
|
|
853
|
-
(n = (o = s.events).onMessageUpdate) == null || n.call(o,
|
|
1783
|
+
var o, n, c, d;
|
|
1784
|
+
(n = (o = s.events).onMessageUpdate) == null || n.call(o, t, e, i), (d = (c = s.events).onUnreadCountChange) == null || d.call(c, this._unreadCount ?? 0);
|
|
854
1785
|
});
|
|
855
1786
|
}
|
|
856
1787
|
};
|
|
857
|
-
a(
|
|
858
|
-
let
|
|
859
|
-
function
|
|
860
|
-
return
|
|
1788
|
+
a(oe, "instance");
|
|
1789
|
+
let P = oe;
|
|
1790
|
+
function gn(h) {
|
|
1791
|
+
return P.shared.readMessage({ message: h });
|
|
861
1792
|
}
|
|
862
|
-
function
|
|
863
|
-
return
|
|
1793
|
+
function mn(h) {
|
|
1794
|
+
return P.shared.unreadMessage({ message: h });
|
|
864
1795
|
}
|
|
865
|
-
function
|
|
866
|
-
return
|
|
1796
|
+
function bn(h) {
|
|
1797
|
+
return P.shared.clickMessage({ message: h });
|
|
867
1798
|
}
|
|
868
|
-
function
|
|
869
|
-
return
|
|
1799
|
+
function _n(h) {
|
|
1800
|
+
return P.shared.archiveMessage({ message: h });
|
|
870
1801
|
}
|
|
871
|
-
function
|
|
872
|
-
return
|
|
1802
|
+
function fn(h) {
|
|
1803
|
+
return P.shared.openMessage({ message: h });
|
|
873
1804
|
}
|
|
874
|
-
function
|
|
875
|
-
if (!
|
|
876
|
-
const
|
|
877
|
-
return
|
|
1805
|
+
function ln(h) {
|
|
1806
|
+
if (!h.created) return "Now";
|
|
1807
|
+
const t = /* @__PURE__ */ new Date(), e = new Date(h.created), i = Math.floor((t.getTime() - e.getTime()) / 1e3);
|
|
1808
|
+
return i < 60 ? `${i}s` : i < 3600 ? `${Math.floor(i / 60)}m` : i < 86400 ? `${Math.floor(i / 3600)}h` : i < 604800 ? `${Math.floor(i / 86400)}d` : i < 31536e3 ? `${Math.floor(i / 604800)}w` : `${Math.floor(i / 31536e3)}y`;
|
|
878
1809
|
}
|
|
879
|
-
class
|
|
1810
|
+
class Lo extends HTMLElement {
|
|
880
1811
|
constructor(e) {
|
|
881
1812
|
super();
|
|
882
1813
|
// State
|
|
@@ -885,14 +1816,14 @@ class _o extends HTMLElement {
|
|
|
885
1816
|
// Components
|
|
886
1817
|
a(this, "_style");
|
|
887
1818
|
this._theme = e;
|
|
888
|
-
const
|
|
889
|
-
this._style = document.createElement("style"), this._style.textContent = this.getStyles(),
|
|
1819
|
+
const i = this.attachShadow({ mode: "open" });
|
|
1820
|
+
this._style = document.createElement("style"), this._style.textContent = this.getStyles(), i.appendChild(this._style);
|
|
890
1821
|
const s = document.createElement("ul");
|
|
891
|
-
s.className = "menu",
|
|
1822
|
+
s.className = "menu", i.appendChild(s);
|
|
892
1823
|
}
|
|
893
1824
|
getStyles() {
|
|
894
|
-
var
|
|
895
|
-
const e = (o = (s = (
|
|
1825
|
+
var i, s, o;
|
|
1826
|
+
const e = (o = (s = (i = this._theme.inbox) == null ? void 0 : i.list) == null ? void 0 : s.item) == null ? void 0 : o.menu;
|
|
896
1827
|
return `
|
|
897
1828
|
:host {
|
|
898
1829
|
display: block;
|
|
@@ -935,19 +1866,19 @@ class _o extends HTMLElement {
|
|
|
935
1866
|
this._options = e, this.renderMenu();
|
|
936
1867
|
}
|
|
937
1868
|
renderMenu() {
|
|
938
|
-
var o, n,
|
|
1869
|
+
var o, n, c, d;
|
|
939
1870
|
const e = (o = this.shadowRoot) == null ? void 0 : o.querySelector("ul.menu");
|
|
940
1871
|
if (!e) return;
|
|
941
1872
|
e.innerHTML = "";
|
|
942
|
-
const
|
|
943
|
-
|
|
1873
|
+
const i = (d = (c = (n = this._theme.inbox) == null ? void 0 : n.list) == null ? void 0 : c.item) == null ? void 0 : d.menu, s = (l) => {
|
|
1874
|
+
l.stopPropagation(), l.preventDefault();
|
|
944
1875
|
};
|
|
945
|
-
this._options.forEach((
|
|
946
|
-
var
|
|
947
|
-
const
|
|
948
|
-
s(b),
|
|
1876
|
+
this._options.forEach((l) => {
|
|
1877
|
+
var g, f, _;
|
|
1878
|
+
const p = new $e(l.icon.svg, l.icon.color, i == null ? void 0 : i.backgroundColor, (g = i == null ? void 0 : i.item) == null ? void 0 : g.hoverBackgroundColor, (f = i == null ? void 0 : i.item) == null ? void 0 : f.activeBackgroundColor, (_ = i == null ? void 0 : i.item) == null ? void 0 : _.borderRadius), m = (b) => {
|
|
1879
|
+
s(b), l.onClick();
|
|
949
1880
|
};
|
|
950
|
-
|
|
1881
|
+
p.addEventListener("click", m), p.addEventListener("touchstart", s), p.addEventListener("touchend", m), p.addEventListener("touchmove", s), p.addEventListener("mousedown", s), p.addEventListener("mouseup", s), e.appendChild(p);
|
|
951
1882
|
});
|
|
952
1883
|
}
|
|
953
1884
|
show() {
|
|
@@ -957,8 +1888,8 @@ class _o extends HTMLElement {
|
|
|
957
1888
|
this.classList.remove("visible");
|
|
958
1889
|
}
|
|
959
1890
|
}
|
|
960
|
-
customElements.get("courier-list-item-menu") || customElements.define("courier-list-item-menu",
|
|
961
|
-
class
|
|
1891
|
+
customElements.get("courier-list-item-menu") || customElements.define("courier-list-item-menu", Lo);
|
|
1892
|
+
class Ao extends HTMLElement {
|
|
962
1893
|
constructor(e) {
|
|
963
1894
|
super();
|
|
964
1895
|
// State
|
|
@@ -982,13 +1913,13 @@ class xo extends HTMLElement {
|
|
|
982
1913
|
a(this, "onItemLongPress", null);
|
|
983
1914
|
a(this, "onItemActionClick", null);
|
|
984
1915
|
this._theme = e, this._isMobile = "ontouchstart" in window;
|
|
985
|
-
const
|
|
986
|
-
s.className = "content-container", this._titleElement = document.createElement("p"), this._titleElement.setAttribute("part", "title"), this._subtitleElement = document.createElement("p"), this._subtitleElement.setAttribute("part", "subtitle"), this._actionsContainer = document.createElement("div"), this._actionsContainer.className = "actions-container", s.appendChild(this._titleElement), s.appendChild(this._subtitleElement), s.appendChild(this._actionsContainer), this._timeElement = document.createElement("p"), this._timeElement.setAttribute("part", "time"), this._unreadIndicator = document.createElement("div"), this._unreadIndicator.className = "unread-indicator", this._style = document.createElement("style"), this._refreshStyles(), this._menu = new
|
|
1916
|
+
const i = this.attachShadow({ mode: "open" }), s = document.createElement("div");
|
|
1917
|
+
s.className = "content-container", this._titleElement = document.createElement("p"), this._titleElement.setAttribute("part", "title"), this._subtitleElement = document.createElement("p"), this._subtitleElement.setAttribute("part", "subtitle"), this._actionsContainer = document.createElement("div"), this._actionsContainer.className = "actions-container", s.appendChild(this._titleElement), s.appendChild(this._subtitleElement), s.appendChild(this._actionsContainer), this._timeElement = document.createElement("p"), this._timeElement.setAttribute("part", "time"), this._unreadIndicator = document.createElement("div"), this._unreadIndicator.className = "unread-indicator", this._style = document.createElement("style"), this._refreshStyles(), this._menu = new Lo(this._theme), this._menu.setOptions(this._getMenuOptions()), i.append(this._style, this._unreadIndicator, s, this._timeElement, this._menu);
|
|
987
1918
|
const o = (n) => {
|
|
988
1919
|
n.stopPropagation(), n.preventDefault();
|
|
989
1920
|
};
|
|
990
1921
|
this._menu.addEventListener("mousedown", o), this._menu.addEventListener("pointerdown", o), this._menu.addEventListener("click", o), this.addEventListener("click", (n) => {
|
|
991
|
-
this._menu.contains(n.target) || n.composedPath().includes(this._menu) || this._message && this.onItemClick && !(n.target instanceof
|
|
1922
|
+
this._menu.contains(n.target) || n.composedPath().includes(this._menu) || this._message && this.onItemClick && !(n.target instanceof ne) && !this._isLongPress && this.onItemClick(this._message);
|
|
992
1923
|
}), this._setupHoverBehavior(), this._setupLongPressBehavior();
|
|
993
1924
|
}
|
|
994
1925
|
_setupHoverBehavior() {
|
|
@@ -1001,14 +1932,14 @@ class xo extends HTMLElement {
|
|
|
1001
1932
|
const e = (n = (o = (s = this._theme.inbox) == null ? void 0 : s.list) == null ? void 0 : o.item) == null ? void 0 : n.menu;
|
|
1002
1933
|
if (!(e != null && e.enabled))
|
|
1003
1934
|
return;
|
|
1004
|
-
const
|
|
1935
|
+
const i = e.longPress;
|
|
1005
1936
|
this.addEventListener(
|
|
1006
1937
|
"touchstart",
|
|
1007
1938
|
() => {
|
|
1008
1939
|
this._longPressTimeout = window.setTimeout(() => {
|
|
1009
|
-
this._isLongPress = !0, this._showMenu(), this._message && this.onItemLongPress && (this.onItemLongPress(this._message), navigator.vibrate && navigator.vibrate((
|
|
1940
|
+
this._isLongPress = !0, this._showMenu(), this._message && this.onItemLongPress && (this.onItemLongPress(this._message), navigator.vibrate && navigator.vibrate((i == null ? void 0 : i.vibrationDuration) ?? 50)), setTimeout(() => {
|
|
1010
1941
|
this._hideMenu(), this._isLongPress = !1;
|
|
1011
|
-
}, (
|
|
1942
|
+
}, (i == null ? void 0 : i.displayDuration) ?? 2e3);
|
|
1012
1943
|
}, 650);
|
|
1013
1944
|
},
|
|
1014
1945
|
{ passive: !0 }
|
|
@@ -1021,43 +1952,43 @@ class xo extends HTMLElement {
|
|
|
1021
1952
|
}
|
|
1022
1953
|
// Helpers
|
|
1023
1954
|
_getMenuOptions() {
|
|
1024
|
-
var s, o, n,
|
|
1025
|
-
const e = (
|
|
1026
|
-
let
|
|
1027
|
-
return (d = this._message) != null && d.archived ||
|
|
1028
|
-
id: (
|
|
1955
|
+
var s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I, E, M;
|
|
1956
|
+
const e = (c = (n = (o = (s = this._theme.inbox) == null ? void 0 : s.list) == null ? void 0 : o.item) == null ? void 0 : n.menu) == null ? void 0 : c.item;
|
|
1957
|
+
let i = [];
|
|
1958
|
+
return (d = this._message) != null && d.archived || i.push({
|
|
1959
|
+
id: (l = this._message) != null && l.read ? "unread" : "read",
|
|
1029
1960
|
icon: {
|
|
1030
|
-
svg: (
|
|
1031
|
-
color: (
|
|
1961
|
+
svg: (p = this._message) != null && p.read ? (m = e == null ? void 0 : e.unread) == null ? void 0 : m.svg : (g = e == null ? void 0 : e.read) == null ? void 0 : g.svg,
|
|
1962
|
+
color: (f = this._message) != null && f.read ? (_ = e == null ? void 0 : e.unread) == null ? void 0 : _.color : ((b = e == null ? void 0 : e.read) == null ? void 0 : b.color) ?? "red"
|
|
1032
1963
|
},
|
|
1033
1964
|
onClick: () => {
|
|
1034
|
-
this._message && (this._message.read ?
|
|
1965
|
+
this._message && (this._message.read ? P.shared.unreadMessage({ message: this._message }) : P.shared.readMessage({ message: this._message }));
|
|
1035
1966
|
}
|
|
1036
|
-
}),
|
|
1037
|
-
id: (
|
|
1967
|
+
}), i.push({
|
|
1968
|
+
id: (C = this._message) != null && C.archived ? "unarchive" : "archive",
|
|
1038
1969
|
icon: {
|
|
1039
1970
|
svg: (k = this._message) != null && k.archived ? (w = e == null ? void 0 : e.unarchive) == null ? void 0 : w.svg : (S = e == null ? void 0 : e.archive) == null ? void 0 : S.svg,
|
|
1040
|
-
color: (
|
|
1971
|
+
color: (I = this._message) != null && I.archived ? (E = e == null ? void 0 : e.unarchive) == null ? void 0 : E.color : ((M = e == null ? void 0 : e.archive) == null ? void 0 : M.color) ?? "red"
|
|
1041
1972
|
},
|
|
1042
1973
|
onClick: () => {
|
|
1043
|
-
this._message && (this._message.archived ? alert("unarchive") :
|
|
1974
|
+
this._message && (this._message.archived ? alert("unarchive") : P.shared.archiveMessage({ message: this._message }));
|
|
1044
1975
|
}
|
|
1045
|
-
}),
|
|
1976
|
+
}), i;
|
|
1046
1977
|
}
|
|
1047
1978
|
// Menu visibility helpers
|
|
1048
1979
|
_showMenu() {
|
|
1049
|
-
var
|
|
1050
|
-
const e = (o = (s = (
|
|
1980
|
+
var i, s, o;
|
|
1981
|
+
const e = (o = (s = (i = this._theme.inbox) == null ? void 0 : i.list) == null ? void 0 : s.item) == null ? void 0 : o.menu;
|
|
1051
1982
|
e && e.enabled && (this._menu.setOptions(this._getMenuOptions()), this._menu.style.display = "block", this._menu.show(), this._timeElement.style.opacity = "0");
|
|
1052
1983
|
}
|
|
1053
1984
|
_hideMenu() {
|
|
1054
|
-
var
|
|
1055
|
-
const e = (o = (s = (
|
|
1985
|
+
var i, s, o;
|
|
1986
|
+
const e = (o = (s = (i = this._theme.inbox) == null ? void 0 : i.list) == null ? void 0 : s.item) == null ? void 0 : o.menu;
|
|
1056
1987
|
e && e.enabled && (this._menu.hide(), this._menu.style.display = "none", this._timeElement.style.opacity = "1");
|
|
1057
1988
|
}
|
|
1058
1989
|
_getStyles() {
|
|
1059
|
-
var
|
|
1060
|
-
const e = (s = (
|
|
1990
|
+
var i, s, o, n, c, d, l, p, m, g, f;
|
|
1991
|
+
const e = (s = (i = this._theme.inbox) == null ? void 0 : i.list) == null ? void 0 : s.item;
|
|
1061
1992
|
return `
|
|
1062
1993
|
:host {
|
|
1063
1994
|
display: flex;
|
|
@@ -1143,20 +2074,20 @@ class xo extends HTMLElement {
|
|
|
1143
2074
|
p[part='title'] {
|
|
1144
2075
|
font-family: ${((o = e == null ? void 0 : e.title) == null ? void 0 : o.family) ?? "inherit"};
|
|
1145
2076
|
font-size: ${((n = e == null ? void 0 : e.title) == null ? void 0 : n.size) ?? "14px"};
|
|
1146
|
-
color: ${((
|
|
2077
|
+
color: ${((c = e == null ? void 0 : e.title) == null ? void 0 : c.color) ?? "red"};
|
|
1147
2078
|
margin-bottom: 4px;
|
|
1148
2079
|
}
|
|
1149
2080
|
|
|
1150
2081
|
p[part='subtitle'] {
|
|
1151
2082
|
font-family: ${((d = e == null ? void 0 : e.subtitle) == null ? void 0 : d.family) ?? "inherit"};
|
|
1152
|
-
font-size: ${((
|
|
1153
|
-
color: ${((
|
|
2083
|
+
font-size: ${((l = e == null ? void 0 : e.subtitle) == null ? void 0 : l.size) ?? "14px"};
|
|
2084
|
+
color: ${((p = e == null ? void 0 : e.subtitle) == null ? void 0 : p.color) ?? "red"};
|
|
1154
2085
|
}
|
|
1155
2086
|
|
|
1156
2087
|
p[part='time'] {
|
|
1157
2088
|
font-family: ${((m = e == null ? void 0 : e.time) == null ? void 0 : m.family) ?? "inherit"};
|
|
1158
|
-
font-size: ${((
|
|
1159
|
-
color: ${((
|
|
2089
|
+
font-size: ${((g = e == null ? void 0 : e.time) == null ? void 0 : g.size) ?? "14px"};
|
|
2090
|
+
color: ${((f = e == null ? void 0 : e.time) == null ? void 0 : f.color) ?? "red"};
|
|
1160
2091
|
text-align: right;
|
|
1161
2092
|
white-space: nowrap;
|
|
1162
2093
|
}
|
|
@@ -1187,17 +2118,17 @@ class xo extends HTMLElement {
|
|
|
1187
2118
|
// Lifecycle hooks
|
|
1188
2119
|
connectedCallback() {
|
|
1189
2120
|
var s, o;
|
|
1190
|
-
const e = this.getAttribute("message"),
|
|
1191
|
-
if (
|
|
2121
|
+
const e = this.getAttribute("message"), i = this.getAttribute("feed-type");
|
|
2122
|
+
if (i && (this._feedType = i), e)
|
|
1192
2123
|
try {
|
|
1193
2124
|
this._message = JSON.parse(e), this._updateContent();
|
|
1194
2125
|
} catch (n) {
|
|
1195
|
-
(o = (s =
|
|
2126
|
+
(o = (s = v.shared.client) == null ? void 0 : s.options.logger) == null || o.error("CourierListItem – failed to parse message:", n);
|
|
1196
2127
|
}
|
|
1197
2128
|
}
|
|
1198
2129
|
// Public API
|
|
1199
|
-
setMessage(e,
|
|
1200
|
-
this._message = e, this._feedType =
|
|
2130
|
+
setMessage(e, i) {
|
|
2131
|
+
this._message = e, this._feedType = i, this._updateContent();
|
|
1201
2132
|
}
|
|
1202
2133
|
setOnItemClick(e) {
|
|
1203
2134
|
this.onItemClick = e;
|
|
@@ -1210,49 +2141,49 @@ class xo extends HTMLElement {
|
|
|
1210
2141
|
}
|
|
1211
2142
|
// Content rendering
|
|
1212
2143
|
_updateContent() {
|
|
1213
|
-
var s, o, n,
|
|
2144
|
+
var s, o, n, c, d, l;
|
|
1214
2145
|
if (!this._message) {
|
|
1215
2146
|
this._titleElement.textContent = "", this._subtitleElement.textContent = "";
|
|
1216
2147
|
return;
|
|
1217
2148
|
}
|
|
1218
|
-
this.classList.toggle("unread", !this._message.read && this._feedType !== "archive"), this._titleElement.textContent = this._message.title || "Untitled Message", this._subtitleElement.textContent = this._message.preview || this._message.body || "", this._timeElement.textContent =
|
|
2149
|
+
this.classList.toggle("unread", !this._message.read && this._feedType !== "archive"), this._titleElement.textContent = this._message.title || "Untitled Message", this._subtitleElement.textContent = this._message.preview || this._message.body || "", this._timeElement.textContent = ln(this._message), this._menu.setOptions(this._getMenuOptions());
|
|
1219
2150
|
const e = ((s = this._message) == null ? void 0 : s.actions) && this._message.actions.length > 0;
|
|
1220
2151
|
this._actionsContainer.style.display = e ? "flex" : "none";
|
|
1221
|
-
const
|
|
1222
|
-
(
|
|
1223
|
-
var
|
|
1224
|
-
const m = new
|
|
1225
|
-
text:
|
|
2152
|
+
const i = (c = (n = (o = this._theme.inbox) == null ? void 0 : o.list) == null ? void 0 : n.item) == null ? void 0 : c.actions;
|
|
2153
|
+
(l = (d = this._message) == null ? void 0 : d.actions) == null || l.forEach((p) => {
|
|
2154
|
+
var g, f, _, b;
|
|
2155
|
+
const m = new Re({
|
|
2156
|
+
text: p.content,
|
|
1226
2157
|
variant: "secondary",
|
|
1227
|
-
backgroundColor:
|
|
1228
|
-
hoverBackgroundColor:
|
|
1229
|
-
activeBackgroundColor:
|
|
1230
|
-
border:
|
|
1231
|
-
borderRadius:
|
|
1232
|
-
shadow:
|
|
1233
|
-
fontFamily: (
|
|
1234
|
-
fontSize: (
|
|
1235
|
-
fontWeight: (_ =
|
|
1236
|
-
textColor: (b =
|
|
2158
|
+
backgroundColor: i == null ? void 0 : i.backgroundColor,
|
|
2159
|
+
hoverBackgroundColor: i == null ? void 0 : i.hoverBackgroundColor,
|
|
2160
|
+
activeBackgroundColor: i == null ? void 0 : i.activeBackgroundColor,
|
|
2161
|
+
border: i == null ? void 0 : i.border,
|
|
2162
|
+
borderRadius: i == null ? void 0 : i.borderRadius,
|
|
2163
|
+
shadow: i == null ? void 0 : i.shadow,
|
|
2164
|
+
fontFamily: (g = i == null ? void 0 : i.font) == null ? void 0 : g.family,
|
|
2165
|
+
fontSize: (f = i == null ? void 0 : i.font) == null ? void 0 : f.size,
|
|
2166
|
+
fontWeight: (_ = i == null ? void 0 : i.font) == null ? void 0 : _.weight,
|
|
2167
|
+
textColor: (b = i == null ? void 0 : i.font) == null ? void 0 : b.color,
|
|
1237
2168
|
onClick: () => {
|
|
1238
|
-
this._message && this.onItemActionClick && this.onItemActionClick(this._message,
|
|
2169
|
+
this._message && this.onItemActionClick && this.onItemActionClick(this._message, p);
|
|
1239
2170
|
}
|
|
1240
2171
|
});
|
|
1241
2172
|
this._actionsContainer.appendChild(m);
|
|
1242
2173
|
});
|
|
1243
2174
|
}
|
|
1244
2175
|
}
|
|
1245
|
-
customElements.get("courier-list-item") || customElements.define("courier-list-item",
|
|
1246
|
-
class
|
|
1247
|
-
constructor(e,
|
|
2176
|
+
customElements.get("courier-list-item") || customElements.define("courier-list-item", Ao);
|
|
2177
|
+
class Po extends HTMLElement {
|
|
2178
|
+
constructor(e, i) {
|
|
1248
2179
|
super();
|
|
1249
2180
|
// Shadow root
|
|
1250
2181
|
a(this, "_shadow");
|
|
1251
2182
|
this._shadow = this.attachShadow({ mode: "open" });
|
|
1252
2183
|
const s = document.createElement("style");
|
|
1253
|
-
s.textContent = this.getStyles(
|
|
1254
|
-
const o = new
|
|
1255
|
-
this._shadow.appendChild(o), this._shadow.appendChild(n), this._shadow.appendChild(
|
|
2184
|
+
s.textContent = this.getStyles(i), this._shadow.appendChild(s);
|
|
2185
|
+
const o = new Le(e, 35), n = new Le(e, 100), c = new Le(e, 82);
|
|
2186
|
+
this._shadow.appendChild(o), this._shadow.appendChild(n), this._shadow.appendChild(c);
|
|
1256
2187
|
}
|
|
1257
2188
|
getStyles(e) {
|
|
1258
2189
|
return `
|
|
@@ -1268,41 +2199,41 @@ class fo extends HTMLElement {
|
|
|
1268
2199
|
`;
|
|
1269
2200
|
}
|
|
1270
2201
|
}
|
|
1271
|
-
customElements.get("courier-inbox-skeleton-list-item") || customElements.define("courier-inbox-skeleton-list-item",
|
|
1272
|
-
class
|
|
1273
|
-
constructor(e,
|
|
2202
|
+
customElements.get("courier-inbox-skeleton-list-item") || customElements.define("courier-inbox-skeleton-list-item", Po);
|
|
2203
|
+
class Le extends HTMLElement {
|
|
2204
|
+
constructor(e, i) {
|
|
1274
2205
|
super();
|
|
1275
2206
|
a(this, "_shadow");
|
|
1276
2207
|
this._shadow = this.attachShadow({ mode: "open" });
|
|
1277
2208
|
const s = document.createElement("style");
|
|
1278
|
-
s.textContent = this.getStyles(e,
|
|
2209
|
+
s.textContent = this.getStyles(e, i), this._shadow.appendChild(s);
|
|
1279
2210
|
const o = document.createElement("div");
|
|
1280
2211
|
o.className = "skeleton-item", this._shadow.appendChild(o);
|
|
1281
2212
|
}
|
|
1282
|
-
getStyles(e,
|
|
1283
|
-
var m,
|
|
1284
|
-
const s = ((
|
|
2213
|
+
getStyles(e, i) {
|
|
2214
|
+
var m, g, f, _, b, C, k, w, S, I, E, M;
|
|
2215
|
+
const s = ((f = (g = (m = e.inbox) == null ? void 0 : m.loading) == null ? void 0 : g.animation) == null ? void 0 : f.barColor) ?? "#000", o = s.length === 4 ? `#${s[1]}${s[1]}${s[2]}${s[2]}${s[3]}${s[3]}` : s, n = parseInt(o.slice(1, 3), 16), c = parseInt(o.slice(3, 5), 16), d = parseInt(o.slice(5, 7), 16), l = `rgba(${n}, ${c}, ${d}, 0.8)`, p = `rgba(${n}, ${c}, ${d}, 0.4)`;
|
|
1285
2216
|
return `
|
|
1286
2217
|
:host {
|
|
1287
2218
|
display: flex;
|
|
1288
2219
|
height: 100%;
|
|
1289
|
-
width: ${
|
|
2220
|
+
width: ${i}%;
|
|
1290
2221
|
align-items: flex-start;
|
|
1291
2222
|
justify-content: flex-start;
|
|
1292
2223
|
}
|
|
1293
2224
|
|
|
1294
2225
|
.skeleton-item {
|
|
1295
|
-
height: ${((
|
|
2226
|
+
height: ${((C = (b = (_ = e.inbox) == null ? void 0 : _.loading) == null ? void 0 : b.animation) == null ? void 0 : C.barHeight) ?? "14px"};
|
|
1296
2227
|
width: 100%;
|
|
1297
2228
|
background: linear-gradient(
|
|
1298
2229
|
90deg,
|
|
1299
|
-
${
|
|
1300
|
-
${
|
|
1301
|
-
${
|
|
2230
|
+
${l} 25%,
|
|
2231
|
+
${p} 50%,
|
|
2232
|
+
${l} 75%
|
|
1302
2233
|
);
|
|
1303
2234
|
background-size: 200% 100%;
|
|
1304
2235
|
animation: shimmer ${((S = (w = (k = e.inbox) == null ? void 0 : k.loading) == null ? void 0 : w.animation) == null ? void 0 : S.duration) ?? "2s"} ease-in-out infinite;
|
|
1305
|
-
border-radius: ${((
|
|
2236
|
+
border-radius: ${((M = (E = (I = e.inbox) == null ? void 0 : I.loading) == null ? void 0 : E.animation) == null ? void 0 : M.barBorderRadius) ?? "14px"};
|
|
1306
2237
|
}
|
|
1307
2238
|
|
|
1308
2239
|
@keyframes shimmer {
|
|
@@ -1316,8 +2247,8 @@ class Ee extends HTMLElement {
|
|
|
1316
2247
|
`;
|
|
1317
2248
|
}
|
|
1318
2249
|
}
|
|
1319
|
-
customElements.get("courier-skeleton-animated-row") || customElements.define("courier-skeleton-animated-row",
|
|
1320
|
-
class
|
|
2250
|
+
customElements.get("courier-skeleton-animated-row") || customElements.define("courier-skeleton-animated-row", Le);
|
|
2251
|
+
class Ne extends De {
|
|
1321
2252
|
constructor(e) {
|
|
1322
2253
|
super();
|
|
1323
2254
|
a(this, "_theme");
|
|
@@ -1326,16 +2257,16 @@ class $e extends Le {
|
|
|
1326
2257
|
defaultElement() {
|
|
1327
2258
|
const e = document.createElement("div");
|
|
1328
2259
|
e.className = "list";
|
|
1329
|
-
const
|
|
1330
|
-
|
|
2260
|
+
const i = document.createElement("style");
|
|
2261
|
+
i.textContent = this.getStyles(), e.appendChild(i);
|
|
1331
2262
|
for (let s = 0; s < 3; s++) {
|
|
1332
|
-
const o = new
|
|
2263
|
+
const o = new Po(this._theme, 1 / (s + 1));
|
|
1333
2264
|
e.appendChild(o);
|
|
1334
2265
|
}
|
|
1335
2266
|
return this.shadow.appendChild(e), e;
|
|
1336
2267
|
}
|
|
1337
2268
|
getStyles() {
|
|
1338
|
-
var e,
|
|
2269
|
+
var e, i;
|
|
1339
2270
|
return `
|
|
1340
2271
|
:host {
|
|
1341
2272
|
display: flex;
|
|
@@ -1355,7 +2286,7 @@ class $e extends Le {
|
|
|
1355
2286
|
}
|
|
1356
2287
|
|
|
1357
2288
|
.list > * {
|
|
1358
|
-
border-bottom: ${((
|
|
2289
|
+
border-bottom: ${((i = (e = this._theme.inbox) == null ? void 0 : e.loading) == null ? void 0 : i.divider) ?? "1px solid red"};
|
|
1359
2290
|
}
|
|
1360
2291
|
|
|
1361
2292
|
.list > *:last-child {
|
|
@@ -1364,8 +2295,8 @@ class $e extends Le {
|
|
|
1364
2295
|
`;
|
|
1365
2296
|
}
|
|
1366
2297
|
}
|
|
1367
|
-
customElements.get("courier-inbox-skeleton-list") || customElements.define("courier-inbox-skeleton-list",
|
|
1368
|
-
class
|
|
2298
|
+
customElements.get("courier-inbox-skeleton-list") || customElements.define("courier-inbox-skeleton-list", Ne);
|
|
2299
|
+
class Bo extends HTMLElement {
|
|
1369
2300
|
constructor(e) {
|
|
1370
2301
|
super();
|
|
1371
2302
|
// Components
|
|
@@ -1375,12 +2306,12 @@ class Co extends HTMLElement {
|
|
|
1375
2306
|
// Handlers
|
|
1376
2307
|
a(this, "onPaginationTrigger");
|
|
1377
2308
|
this.onPaginationTrigger = e.onPaginationTrigger, this.customItem = e.customItem;
|
|
1378
|
-
const
|
|
1379
|
-
if (s.textContent = this.getStyles(),
|
|
1380
|
-
|
|
2309
|
+
const i = this.attachShadow({ mode: "open" }), s = document.createElement("style");
|
|
2310
|
+
if (s.textContent = this.getStyles(), i.appendChild(s), this.customItem)
|
|
2311
|
+
i.appendChild(this.customItem);
|
|
1381
2312
|
else {
|
|
1382
2313
|
const o = document.createElement("div");
|
|
1383
|
-
o.className = "skeleton-container", this.skeletonLoadingList = new
|
|
2314
|
+
o.className = "skeleton-container", this.skeletonLoadingList = new Ne(e.theme), this.skeletonLoadingList.build(void 0), o.appendChild(this.skeletonLoadingList), i.appendChild(o);
|
|
1384
2315
|
}
|
|
1385
2316
|
this.observer = new IntersectionObserver((o) => {
|
|
1386
2317
|
o.forEach((n) => {
|
|
@@ -1405,8 +2336,8 @@ class Co extends HTMLElement {
|
|
|
1405
2336
|
this.observer.disconnect();
|
|
1406
2337
|
}
|
|
1407
2338
|
}
|
|
1408
|
-
customElements.get("courier-inbox-pagination-list-item") || customElements.define("courier-inbox-pagination-list-item",
|
|
1409
|
-
class
|
|
2339
|
+
customElements.get("courier-inbox-pagination-list-item") || customElements.define("courier-inbox-pagination-list-item", Bo);
|
|
2340
|
+
class Ro extends HTMLElement {
|
|
1410
2341
|
constructor(e) {
|
|
1411
2342
|
super();
|
|
1412
2343
|
// Theme
|
|
@@ -1432,16 +2363,16 @@ class vo extends HTMLElement {
|
|
|
1432
2363
|
this._themeSubscription = e.themeManager.subscribe((o) => {
|
|
1433
2364
|
this.refreshTheme();
|
|
1434
2365
|
}), this._onRefresh = e.onRefresh, this._onPaginationTrigger = e.onPaginationTrigger, this._onMessageClick = e.onMessageClick, this._onMessageActionClick = e.onMessageActionClick, this._onMessageLongPress = e.onMessageLongPress;
|
|
1435
|
-
const
|
|
1436
|
-
s.textContent = this.getStyles(),
|
|
2366
|
+
const i = this.attachShadow({ mode: "open" }), s = document.createElement("style");
|
|
2367
|
+
s.textContent = this.getStyles(), i.appendChild(s);
|
|
1437
2368
|
}
|
|
1438
2369
|
// Getters
|
|
1439
2370
|
get messages() {
|
|
1440
2371
|
return this._messages;
|
|
1441
2372
|
}
|
|
1442
2373
|
getStyles() {
|
|
1443
|
-
var
|
|
1444
|
-
const e = (
|
|
2374
|
+
var i;
|
|
2375
|
+
const e = (i = this._themeSubscription.manager.getTheme().inbox) == null ? void 0 : i.list;
|
|
1445
2376
|
return `
|
|
1446
2377
|
:host {
|
|
1447
2378
|
flex: 1;
|
|
@@ -1458,8 +2389,8 @@ class vo extends HTMLElement {
|
|
|
1458
2389
|
`;
|
|
1459
2390
|
}
|
|
1460
2391
|
reset() {
|
|
1461
|
-
var
|
|
1462
|
-
for (; (
|
|
2392
|
+
var i, s;
|
|
2393
|
+
for (; (i = this.shadowRoot) != null && i.firstChild; )
|
|
1463
2394
|
this.shadowRoot.removeChild(this.shadowRoot.firstChild);
|
|
1464
2395
|
const e = document.createElement("style");
|
|
1465
2396
|
e.textContent = this.getStyles(), (s = this.shadowRoot) == null || s.appendChild(e);
|
|
@@ -1470,14 +2401,14 @@ class vo extends HTMLElement {
|
|
|
1470
2401
|
addPage(e) {
|
|
1471
2402
|
this._messages = [...this._messages, ...e.messages], this._canPaginate = !!e.canPaginate, this._error = null, this._isLoading = !1, this.render();
|
|
1472
2403
|
}
|
|
1473
|
-
addMessage(e,
|
|
1474
|
-
this._messages.splice(
|
|
2404
|
+
addMessage(e, i = 0) {
|
|
2405
|
+
this._messages.splice(i, 0, e), this.render();
|
|
1475
2406
|
}
|
|
1476
2407
|
removeMessage(e = 0) {
|
|
1477
2408
|
this._messages.splice(e, 1), this.render();
|
|
1478
2409
|
}
|
|
1479
|
-
updateMessage(e,
|
|
1480
|
-
this._messages[
|
|
2410
|
+
updateMessage(e, i = 0) {
|
|
2411
|
+
this._messages[i] = e, this.render();
|
|
1481
2412
|
}
|
|
1482
2413
|
setFeedType(e) {
|
|
1483
2414
|
this._feedType = e, this._error = null, this._isLoading = !0, this.render();
|
|
@@ -1498,93 +2429,93 @@ class vo extends HTMLElement {
|
|
|
1498
2429
|
this._onRefresh();
|
|
1499
2430
|
}
|
|
1500
2431
|
render() {
|
|
1501
|
-
var s, o, n,
|
|
2432
|
+
var s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I, E, M, L, R, D, y, A, F, H, O, z, U, N, q, V, j, X, Q, Y, ee, G, ae, he, ce, le, de, ue, pe, ge, me, be, _e, fe, xe, ve, Ce, ye, ke, we, Se, Ie;
|
|
1502
2433
|
this.reset();
|
|
1503
2434
|
const e = this._themeSubscription.manager.getTheme();
|
|
1504
2435
|
if (this._error) {
|
|
1505
|
-
const
|
|
2436
|
+
const u = (s = e.inbox) == null ? void 0 : s.error, B = new Be({
|
|
1506
2437
|
title: {
|
|
1507
|
-
text: ((o =
|
|
1508
|
-
textColor: (
|
|
1509
|
-
fontFamily: (
|
|
1510
|
-
fontSize: (m = (
|
|
1511
|
-
fontWeight: (
|
|
2438
|
+
text: ((o = u == null ? void 0 : u.title) == null ? void 0 : o.text) ?? this._error.message,
|
|
2439
|
+
textColor: (c = (n = u == null ? void 0 : u.title) == null ? void 0 : n.font) == null ? void 0 : c.color,
|
|
2440
|
+
fontFamily: (l = (d = u == null ? void 0 : u.title) == null ? void 0 : d.font) == null ? void 0 : l.family,
|
|
2441
|
+
fontSize: (m = (p = u == null ? void 0 : u.title) == null ? void 0 : p.font) == null ? void 0 : m.size,
|
|
2442
|
+
fontWeight: (f = (g = u == null ? void 0 : u.title) == null ? void 0 : g.font) == null ? void 0 : f.weight
|
|
1512
2443
|
},
|
|
1513
2444
|
button: {
|
|
1514
|
-
text: (_ =
|
|
1515
|
-
backgroundColor: (b =
|
|
1516
|
-
hoverBackgroundColor: (
|
|
1517
|
-
activeBackgroundColor: (k =
|
|
1518
|
-
textColor: (S = (w =
|
|
1519
|
-
fontFamily: (
|
|
1520
|
-
fontSize: (
|
|
1521
|
-
fontWeight: (D = (
|
|
1522
|
-
shadow: (y =
|
|
1523
|
-
border: (
|
|
1524
|
-
borderRadius: (F =
|
|
2445
|
+
text: (_ = u == null ? void 0 : u.button) == null ? void 0 : _.text,
|
|
2446
|
+
backgroundColor: (b = u == null ? void 0 : u.button) == null ? void 0 : b.backgroundColor,
|
|
2447
|
+
hoverBackgroundColor: (C = u == null ? void 0 : u.button) == null ? void 0 : C.hoverBackgroundColor,
|
|
2448
|
+
activeBackgroundColor: (k = u == null ? void 0 : u.button) == null ? void 0 : k.activeBackgroundColor,
|
|
2449
|
+
textColor: (S = (w = u == null ? void 0 : u.button) == null ? void 0 : w.font) == null ? void 0 : S.color,
|
|
2450
|
+
fontFamily: (E = (I = u == null ? void 0 : u.button) == null ? void 0 : I.font) == null ? void 0 : E.family,
|
|
2451
|
+
fontSize: (L = (M = u == null ? void 0 : u.button) == null ? void 0 : M.font) == null ? void 0 : L.size,
|
|
2452
|
+
fontWeight: (D = (R = u == null ? void 0 : u.button) == null ? void 0 : R.font) == null ? void 0 : D.weight,
|
|
2453
|
+
shadow: (y = u == null ? void 0 : u.button) == null ? void 0 : y.shadow,
|
|
2454
|
+
border: (A = u == null ? void 0 : u.button) == null ? void 0 : A.border,
|
|
2455
|
+
borderRadius: (F = u == null ? void 0 : u.button) == null ? void 0 : F.borderRadius
|
|
1525
2456
|
}
|
|
1526
2457
|
});
|
|
1527
|
-
|
|
2458
|
+
B.build((H = this._errorStateFactory) == null ? void 0 : H.call(this, { feedType: this._feedType, error: this._error })), B.setButtonClickCallback(() => this.handleRetry()), (O = this.shadowRoot) == null || O.appendChild(B);
|
|
1528
2459
|
return;
|
|
1529
2460
|
}
|
|
1530
2461
|
if (this._isLoading) {
|
|
1531
|
-
const
|
|
1532
|
-
|
|
2462
|
+
const u = new Ne(e);
|
|
2463
|
+
u.build((z = this._loadingStateFactory) == null ? void 0 : z.call(this, { feedType: this._feedType })), (U = this.shadowRoot) == null || U.appendChild(u);
|
|
1533
2464
|
return;
|
|
1534
2465
|
}
|
|
1535
2466
|
if (this._messages.length === 0) {
|
|
1536
|
-
const
|
|
2467
|
+
const u = (N = e.inbox) == null ? void 0 : N.empty, B = new Be({
|
|
1537
2468
|
title: {
|
|
1538
|
-
text: ((
|
|
1539
|
-
textColor: (
|
|
1540
|
-
fontFamily: (
|
|
1541
|
-
fontSize: (
|
|
1542
|
-
fontWeight: (
|
|
2469
|
+
text: ((q = u == null ? void 0 : u.title) == null ? void 0 : q.text) ?? `No ${this._feedType} messages yet`,
|
|
2470
|
+
textColor: (j = (V = u == null ? void 0 : u.title) == null ? void 0 : V.font) == null ? void 0 : j.color,
|
|
2471
|
+
fontFamily: (Q = (X = u == null ? void 0 : u.title) == null ? void 0 : X.font) == null ? void 0 : Q.family,
|
|
2472
|
+
fontSize: (ee = (Y = u == null ? void 0 : u.title) == null ? void 0 : Y.font) == null ? void 0 : ee.size,
|
|
2473
|
+
fontWeight: (ae = (G = u == null ? void 0 : u.title) == null ? void 0 : G.font) == null ? void 0 : ae.weight
|
|
1543
2474
|
},
|
|
1544
2475
|
button: {
|
|
1545
|
-
text: (
|
|
1546
|
-
backgroundColor: (
|
|
1547
|
-
hoverBackgroundColor: (
|
|
1548
|
-
activeBackgroundColor: (
|
|
1549
|
-
textColor: (
|
|
1550
|
-
fontFamily: (
|
|
1551
|
-
fontSize: (
|
|
1552
|
-
fontWeight: (
|
|
1553
|
-
shadow: (
|
|
1554
|
-
border: (
|
|
1555
|
-
borderRadius: (
|
|
2476
|
+
text: (he = u == null ? void 0 : u.button) == null ? void 0 : he.text,
|
|
2477
|
+
backgroundColor: (ce = u == null ? void 0 : u.button) == null ? void 0 : ce.backgroundColor,
|
|
2478
|
+
hoverBackgroundColor: (le = u == null ? void 0 : u.button) == null ? void 0 : le.hoverBackgroundColor,
|
|
2479
|
+
activeBackgroundColor: (de = u == null ? void 0 : u.button) == null ? void 0 : de.activeBackgroundColor,
|
|
2480
|
+
textColor: (pe = (ue = u == null ? void 0 : u.button) == null ? void 0 : ue.font) == null ? void 0 : pe.color,
|
|
2481
|
+
fontFamily: (me = (ge = u == null ? void 0 : u.button) == null ? void 0 : ge.font) == null ? void 0 : me.family,
|
|
2482
|
+
fontSize: (_e = (be = u == null ? void 0 : u.button) == null ? void 0 : be.font) == null ? void 0 : _e.size,
|
|
2483
|
+
fontWeight: (xe = (fe = u == null ? void 0 : u.button) == null ? void 0 : fe.font) == null ? void 0 : xe.weight,
|
|
2484
|
+
shadow: (ve = u == null ? void 0 : u.button) == null ? void 0 : ve.shadow,
|
|
2485
|
+
border: (Ce = u == null ? void 0 : u.button) == null ? void 0 : Ce.border,
|
|
2486
|
+
borderRadius: (ye = u == null ? void 0 : u.button) == null ? void 0 : ye.borderRadius
|
|
1556
2487
|
}
|
|
1557
2488
|
});
|
|
1558
|
-
|
|
2489
|
+
B.build((ke = this._emptyStateFactory) == null ? void 0 : ke.call(this, { feedType: this._feedType })), B.setButtonClickCallback(() => this.handleRefresh()), (we = this.shadowRoot) == null || we.appendChild(B);
|
|
1559
2490
|
return;
|
|
1560
2491
|
}
|
|
1561
|
-
const
|
|
1562
|
-
if ((
|
|
2492
|
+
const i = document.createElement("ul");
|
|
2493
|
+
if ((Se = this.shadowRoot) == null || Se.appendChild(i), this._messages.forEach((u, B) => {
|
|
1563
2494
|
if (this._listItemFactory) {
|
|
1564
|
-
|
|
2495
|
+
i.appendChild(this._listItemFactory({ message: u, index: B }));
|
|
1565
2496
|
return;
|
|
1566
2497
|
}
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1569
|
-
var
|
|
1570
|
-
return (
|
|
1571
|
-
}),
|
|
1572
|
-
var
|
|
1573
|
-
return (
|
|
1574
|
-
}),
|
|
1575
|
-
var
|
|
1576
|
-
return (
|
|
1577
|
-
}),
|
|
2498
|
+
const te = new Ao(e);
|
|
2499
|
+
te.setMessage(u, this._feedType), te.setOnItemClick((ie) => {
|
|
2500
|
+
var J;
|
|
2501
|
+
return (J = this._onMessageClick) == null ? void 0 : J.call(this, ie, B);
|
|
2502
|
+
}), te.setOnItemActionClick((ie, J) => {
|
|
2503
|
+
var Ee;
|
|
2504
|
+
return (Ee = this._onMessageActionClick) == null ? void 0 : Ee.call(this, ie, J, B);
|
|
2505
|
+
}), te.setOnItemLongPress((ie) => {
|
|
2506
|
+
var J;
|
|
2507
|
+
return (J = this._onMessageLongPress) == null ? void 0 : J.call(this, ie, B);
|
|
2508
|
+
}), i.appendChild(te);
|
|
1578
2509
|
}), this._canPaginate) {
|
|
1579
|
-
const
|
|
2510
|
+
const u = new Bo({
|
|
1580
2511
|
theme: e,
|
|
1581
|
-
customItem: (
|
|
2512
|
+
customItem: (Ie = this._paginationItemFactory) == null ? void 0 : Ie.call(this, { feedType: this._feedType }),
|
|
1582
2513
|
onPaginationTrigger: () => {
|
|
1583
|
-
var
|
|
1584
|
-
return (
|
|
2514
|
+
var B;
|
|
2515
|
+
return (B = this._onPaginationTrigger) == null ? void 0 : B.call(this, this._feedType);
|
|
1585
2516
|
}
|
|
1586
2517
|
});
|
|
1587
|
-
|
|
2518
|
+
i.appendChild(u);
|
|
1588
2519
|
}
|
|
1589
2520
|
}
|
|
1590
2521
|
// Factories
|
|
@@ -1611,8 +2542,8 @@ class vo extends HTMLElement {
|
|
|
1611
2542
|
this._themeSubscription.unsubscribe();
|
|
1612
2543
|
}
|
|
1613
2544
|
}
|
|
1614
|
-
customElements.get("courier-inbox-list") || customElements.define("courier-inbox-list",
|
|
1615
|
-
class
|
|
2545
|
+
customElements.get("courier-inbox-list") || customElements.define("courier-inbox-list", Ro);
|
|
2546
|
+
class Do extends HTMLElement {
|
|
1616
2547
|
constructor(e) {
|
|
1617
2548
|
super();
|
|
1618
2549
|
// State
|
|
@@ -1627,13 +2558,13 @@ class yo extends HTMLElement {
|
|
|
1627
2558
|
// Theme
|
|
1628
2559
|
a(this, "_themeManager");
|
|
1629
2560
|
this._option = e.option, this._isSelected = e.isSelected, this._themeManager = e.themeManager;
|
|
1630
|
-
const
|
|
1631
|
-
this._style = document.createElement("style"), this._content = document.createElement("div"), this._content.className = "menu-item", this._itemIcon = new
|
|
2561
|
+
const i = this.attachShadow({ mode: "open" });
|
|
2562
|
+
this._style = document.createElement("style"), this._content = document.createElement("div"), this._content.className = "menu-item", this._itemIcon = new ne(this._option.icon.svg ?? x.inbox), this._itemIcon.setAttribute("size", "16"), this._title = document.createElement("p"), this._title.textContent = this._option.text;
|
|
1632
2563
|
const s = document.createElement("div");
|
|
1633
|
-
s.className = "spacer", this._selectionIcon = new
|
|
2564
|
+
s.className = "spacer", this._selectionIcon = new ne(x.check), this._content.appendChild(this._itemIcon), this._content.appendChild(this._title), this._content.appendChild(s), e.selectable && this._content.appendChild(this._selectionIcon), i.appendChild(this._style), i.appendChild(this._content), this._selectionIcon.style.display = this._isSelected ? "block" : "none", this.refreshTheme();
|
|
1634
2565
|
}
|
|
1635
2566
|
getStyles() {
|
|
1636
|
-
var
|
|
2567
|
+
var i, s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I, E, M, L, R, D, y, A, F, H, O, z, U, N, q, V, j;
|
|
1637
2568
|
const e = this._themeManager.getTheme();
|
|
1638
2569
|
return `
|
|
1639
2570
|
:host {
|
|
@@ -1644,11 +2575,11 @@ class yo extends HTMLElement {
|
|
|
1644
2575
|
}
|
|
1645
2576
|
|
|
1646
2577
|
:host(:hover) {
|
|
1647
|
-
background-color: ${((
|
|
2578
|
+
background-color: ${((c = (n = (o = (s = (i = e.inbox) == null ? void 0 : i.header) == null ? void 0 : s.menus) == null ? void 0 : o.popup) == null ? void 0 : n.list) == null ? void 0 : c.hoverBackgroundColor) ?? "red"};
|
|
1648
2579
|
}
|
|
1649
2580
|
|
|
1650
2581
|
:host(:active) {
|
|
1651
|
-
background-color: ${((
|
|
2582
|
+
background-color: ${((g = (m = (p = (l = (d = e.inbox) == null ? void 0 : d.header) == null ? void 0 : l.menus) == null ? void 0 : p.popup) == null ? void 0 : m.list) == null ? void 0 : g.activeBackgroundColor) ?? "red"};
|
|
1652
2583
|
}
|
|
1653
2584
|
|
|
1654
2585
|
.menu-item {
|
|
@@ -1664,10 +2595,10 @@ class yo extends HTMLElement {
|
|
|
1664
2595
|
|
|
1665
2596
|
p {
|
|
1666
2597
|
margin: 0;
|
|
1667
|
-
font-family: ${((w = (k = (
|
|
1668
|
-
font-weight: ${((
|
|
1669
|
-
font-size: ${((
|
|
1670
|
-
color: ${((
|
|
2598
|
+
font-family: ${((w = (k = (C = (b = (_ = (f = e.inbox) == null ? void 0 : f.header) == null ? void 0 : _.menus) == null ? void 0 : b.popup) == null ? void 0 : C.list) == null ? void 0 : k.font) == null ? void 0 : w.family) ?? "inherit"};
|
|
2599
|
+
font-weight: ${((R = (L = (M = (E = (I = (S = e.inbox) == null ? void 0 : S.header) == null ? void 0 : I.menus) == null ? void 0 : E.popup) == null ? void 0 : M.list) == null ? void 0 : L.font) == null ? void 0 : R.weight) ?? "inherit"};
|
|
2600
|
+
font-size: ${((O = (H = (F = (A = (y = (D = e.inbox) == null ? void 0 : D.header) == null ? void 0 : y.menus) == null ? void 0 : A.popup) == null ? void 0 : F.list) == null ? void 0 : H.font) == null ? void 0 : O.size) ?? "14px"};
|
|
2601
|
+
color: ${((j = (V = (q = (N = (U = (z = e.inbox) == null ? void 0 : z.header) == null ? void 0 : U.menus) == null ? void 0 : N.popup) == null ? void 0 : q.list) == null ? void 0 : V.font) == null ? void 0 : j.color) ?? "red"};
|
|
1671
2602
|
white-space: nowrap;
|
|
1672
2603
|
}
|
|
1673
2604
|
|
|
@@ -1677,13 +2608,13 @@ class yo extends HTMLElement {
|
|
|
1677
2608
|
`;
|
|
1678
2609
|
}
|
|
1679
2610
|
refreshTheme() {
|
|
1680
|
-
var e,
|
|
1681
|
-
this._style.textContent = this.getStyles(), this._selectionIcon.updateColor(((e = this._option.selectionIcon) == null ? void 0 : e.color) ?? "red"), this._selectionIcon.updateSVG(((
|
|
2611
|
+
var e, i, s, o;
|
|
2612
|
+
this._style.textContent = this.getStyles(), this._selectionIcon.updateColor(((e = this._option.selectionIcon) == null ? void 0 : e.color) ?? "red"), this._selectionIcon.updateSVG(((i = this._option.selectionIcon) == null ? void 0 : i.svg) ?? x.check), this._title.textContent = this._option.text ?? "Missing Text", this._itemIcon.updateColor(((s = this._option.icon) == null ? void 0 : s.color) ?? "red"), this._itemIcon.updateSVG(((o = this._option.icon) == null ? void 0 : o.svg) ?? x.inbox);
|
|
1682
2613
|
}
|
|
1683
2614
|
}
|
|
1684
|
-
customElements.get("courier-inbox-filter-menu-item") || customElements.define("courier-inbox-filter-menu-item",
|
|
1685
|
-
class
|
|
1686
|
-
constructor(e,
|
|
2615
|
+
customElements.get("courier-inbox-filter-menu-item") || customElements.define("courier-inbox-filter-menu-item", Do);
|
|
2616
|
+
class He extends HTMLElement {
|
|
2617
|
+
constructor(e, i, s, o, n) {
|
|
1687
2618
|
super();
|
|
1688
2619
|
// Theme
|
|
1689
2620
|
a(this, "_themeSubscription");
|
|
@@ -1697,14 +2628,14 @@ class Be extends HTMLElement {
|
|
|
1697
2628
|
a(this, "_menuButton");
|
|
1698
2629
|
a(this, "_menu");
|
|
1699
2630
|
a(this, "_style");
|
|
1700
|
-
this._type =
|
|
1701
|
-
const
|
|
1702
|
-
this._menuButton = new
|
|
2631
|
+
this._type = i, this._selectable = s, this._options = o, this._selectedIndex = 0, this._onMenuOpen = n;
|
|
2632
|
+
const c = this.attachShadow({ mode: "open" });
|
|
2633
|
+
this._menuButton = new $e(i === "filters" ? x.filter : x.overflow), this._menu = document.createElement("div"), this._menu.className = `menu ${i}`, this._style = document.createElement("style"), c.appendChild(this._style), c.appendChild(this._menuButton), c.appendChild(this._menu), this._menuButton.addEventListener("click", this.toggleMenu.bind(this)), document.addEventListener("click", this.handleOutsideClick.bind(this)), this._themeSubscription = e.subscribe((d) => {
|
|
1703
2634
|
this.refreshTheme();
|
|
1704
2635
|
}), this.refreshTheme();
|
|
1705
2636
|
}
|
|
1706
2637
|
getStyles() {
|
|
1707
|
-
var
|
|
2638
|
+
var i, s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I, E, M, L;
|
|
1708
2639
|
const e = this._themeSubscription.manager.getTheme();
|
|
1709
2640
|
return `
|
|
1710
2641
|
:host {
|
|
@@ -1717,10 +2648,10 @@ class Be extends HTMLElement {
|
|
|
1717
2648
|
position: absolute;
|
|
1718
2649
|
top: 42px;
|
|
1719
2650
|
right: -6px;
|
|
1720
|
-
border-radius: ${((n = (o = (s = (
|
|
1721
|
-
border: ${((
|
|
1722
|
-
background: ${((_ = (
|
|
1723
|
-
box-shadow: ${((w = (k = (
|
|
2651
|
+
border-radius: ${((n = (o = (s = (i = e.inbox) == null ? void 0 : i.header) == null ? void 0 : s.menus) == null ? void 0 : o.popup) == null ? void 0 : n.borderRadius) ?? "6px"};
|
|
2652
|
+
border: ${((p = (l = (d = (c = e.inbox) == null ? void 0 : c.header) == null ? void 0 : d.menus) == null ? void 0 : l.popup) == null ? void 0 : p.border) ?? "1px solid red"};
|
|
2653
|
+
background: ${((_ = (f = (g = (m = e.inbox) == null ? void 0 : m.header) == null ? void 0 : g.menus) == null ? void 0 : f.popup) == null ? void 0 : _.backgroundColor) ?? "red"};
|
|
2654
|
+
box-shadow: ${((w = (k = (C = (b = e.inbox) == null ? void 0 : b.header) == null ? void 0 : C.menus) == null ? void 0 : k.popup) == null ? void 0 : w.shadow) ?? "0 4px 12px 0 red"};
|
|
1724
2655
|
z-index: 1000;
|
|
1725
2656
|
min-width: 200px;
|
|
1726
2657
|
overflow: hidden;
|
|
@@ -1728,7 +2659,7 @@ class Be extends HTMLElement {
|
|
|
1728
2659
|
}
|
|
1729
2660
|
|
|
1730
2661
|
courier-inbox-filter-menu-item {
|
|
1731
|
-
border-bottom: ${((
|
|
2662
|
+
border-bottom: ${((L = (M = (E = (I = (S = e.inbox) == null ? void 0 : S.header) == null ? void 0 : I.menus) == null ? void 0 : E.popup) == null ? void 0 : M.list) == null ? void 0 : L.divider) ?? "none"};
|
|
1732
2663
|
}
|
|
1733
2664
|
|
|
1734
2665
|
courier-inbox-filter-menu-item:last-child {
|
|
@@ -1737,31 +2668,31 @@ class Be extends HTMLElement {
|
|
|
1737
2668
|
`;
|
|
1738
2669
|
}
|
|
1739
2670
|
refreshTheme() {
|
|
1740
|
-
var
|
|
2671
|
+
var c, d, l, p, m, g;
|
|
1741
2672
|
this._style.textContent = this.getStyles();
|
|
1742
|
-
const
|
|
1743
|
-
this._menuButton.updateIconSVG(((m = o == null ? void 0 : o.icon) == null ? void 0 : m.svg) ?? n), this._menuButton.updateIconColor(((
|
|
2673
|
+
const i = (d = (c = this._themeSubscription.manager.getTheme().inbox) == null ? void 0 : c.header) == null ? void 0 : d.menus, s = this._type === "filters", o = s ? (l = i == null ? void 0 : i.filters) == null ? void 0 : l.button : (p = i == null ? void 0 : i.actions) == null ? void 0 : p.button, n = s ? x.filter : x.overflow;
|
|
2674
|
+
this._menuButton.updateIconSVG(((m = o == null ? void 0 : o.icon) == null ? void 0 : m.svg) ?? n), this._menuButton.updateIconColor(((g = o == null ? void 0 : o.icon) == null ? void 0 : g.color) ?? "red"), this._menuButton.updateBackgroundColor((o == null ? void 0 : o.backgroundColor) ?? "transparent"), this._menuButton.updateHoverBackgroundColor((o == null ? void 0 : o.hoverBackgroundColor) ?? "red"), this._menuButton.updateActiveBackgroundColor((o == null ? void 0 : o.activeBackgroundColor) ?? "red"), this.refreshMenuItems();
|
|
1744
2675
|
}
|
|
1745
2676
|
setOptions(e) {
|
|
1746
2677
|
this._options = e, this.refreshMenuItems();
|
|
1747
2678
|
}
|
|
1748
2679
|
refreshMenuItems() {
|
|
1749
|
-
this._menu.innerHTML = "", this._options.forEach((e,
|
|
1750
|
-
const s = new
|
|
2680
|
+
this._menu.innerHTML = "", this._options.forEach((e, i) => {
|
|
2681
|
+
const s = new Do({
|
|
1751
2682
|
option: e,
|
|
1752
2683
|
selectable: this._selectable,
|
|
1753
|
-
isSelected: this._selectedIndex ===
|
|
2684
|
+
isSelected: this._selectedIndex === i,
|
|
1754
2685
|
themeManager: this._themeSubscription.manager
|
|
1755
2686
|
});
|
|
1756
2687
|
s.addEventListener("click", () => {
|
|
1757
|
-
this._selectedIndex =
|
|
2688
|
+
this._selectedIndex = i, e.onClick(e), this.refreshMenuItems(), this.closeMenu();
|
|
1758
2689
|
}), this._menu.appendChild(s);
|
|
1759
2690
|
});
|
|
1760
2691
|
}
|
|
1761
2692
|
toggleMenu(e) {
|
|
1762
2693
|
e.stopPropagation();
|
|
1763
|
-
const
|
|
1764
|
-
this._menu.style.display =
|
|
2694
|
+
const i = this._menu.style.display !== "block";
|
|
2695
|
+
this._menu.style.display = i ? "block" : "none", i && this._onMenuOpen();
|
|
1765
2696
|
}
|
|
1766
2697
|
handleOutsideClick(e) {
|
|
1767
2698
|
this.contains(e.target) || this.closeMenu();
|
|
@@ -1770,14 +2701,14 @@ class Be extends HTMLElement {
|
|
|
1770
2701
|
this._menu.style.display = "none";
|
|
1771
2702
|
}
|
|
1772
2703
|
selectOption(e) {
|
|
1773
|
-
this._selectedIndex = this._options.findIndex((
|
|
2704
|
+
this._selectedIndex = this._options.findIndex((i) => i.id === e.id), this.refreshMenuItems();
|
|
1774
2705
|
}
|
|
1775
2706
|
disconnectedCallback() {
|
|
1776
2707
|
this._themeSubscription.unsubscribe();
|
|
1777
2708
|
}
|
|
1778
2709
|
}
|
|
1779
|
-
customElements.get("courier-inbox-option-menu") || customElements.define("courier-inbox-option-menu",
|
|
1780
|
-
class
|
|
2710
|
+
customElements.get("courier-inbox-option-menu") || customElements.define("courier-inbox-option-menu", He);
|
|
2711
|
+
class qe extends HTMLElement {
|
|
1781
2712
|
constructor(e) {
|
|
1782
2713
|
super();
|
|
1783
2714
|
// Theme
|
|
@@ -1791,12 +2722,12 @@ class De extends HTMLElement {
|
|
|
1791
2722
|
this._location = e.location, this._themeSubscription = e.themeBus.subscribe((s) => {
|
|
1792
2723
|
this.refreshTheme(this._location);
|
|
1793
2724
|
});
|
|
1794
|
-
const
|
|
1795
|
-
this._badge = document.createElement("span"), this._badge.className = "unread-badge", this._style = document.createElement("style"), this._style.textContent = this.getStyles(this._location),
|
|
2725
|
+
const i = this.attachShadow({ mode: "open" });
|
|
2726
|
+
this._badge = document.createElement("span"), this._badge.className = "unread-badge", this._style = document.createElement("style"), this._style.textContent = this.getStyles(this._location), i.appendChild(this._style), i.appendChild(this._badge);
|
|
1796
2727
|
}
|
|
1797
2728
|
getStyles(e) {
|
|
1798
|
-
var
|
|
1799
|
-
const
|
|
2729
|
+
var l, p, m, g, f, _, b;
|
|
2730
|
+
const i = this._themeSubscription.manager.getTheme(), s = e === "button" ? (p = (l = i.popup) == null ? void 0 : l.button) == null ? void 0 : p.unreadIndicator : (f = (g = (m = i.inbox) == null ? void 0 : m.header) == null ? void 0 : g.filters) == null ? void 0 : f.unreadIndicator, o = s == null ? void 0 : s.backgroundColor, n = s == null ? void 0 : s.borderRadius, c = (_ = s == null ? void 0 : s.font) == null ? void 0 : _.color, d = (b = s == null ? void 0 : s.font) == null ? void 0 : b.size;
|
|
1800
2731
|
return `
|
|
1801
2732
|
:host {
|
|
1802
2733
|
display: inline-block;
|
|
@@ -1804,7 +2735,7 @@ class De extends HTMLElement {
|
|
|
1804
2735
|
|
|
1805
2736
|
.unread-badge {
|
|
1806
2737
|
background-color: ${o};
|
|
1807
|
-
color: ${
|
|
2738
|
+
color: ${c};
|
|
1808
2739
|
border-radius: ${n};
|
|
1809
2740
|
padding: 4px 8px;
|
|
1810
2741
|
font-size: ${d};
|
|
@@ -1827,9 +2758,9 @@ class De extends HTMLElement {
|
|
|
1827
2758
|
this._themeSubscription.unsubscribe();
|
|
1828
2759
|
}
|
|
1829
2760
|
}
|
|
1830
|
-
customElements.get("courier-unread-count-badge") || customElements.define("courier-unread-count-badge",
|
|
1831
|
-
class
|
|
1832
|
-
constructor(e,
|
|
2761
|
+
customElements.get("courier-unread-count-badge") || customElements.define("courier-unread-count-badge", qe);
|
|
2762
|
+
class Fo extends HTMLElement {
|
|
2763
|
+
constructor(e, i) {
|
|
1833
2764
|
super();
|
|
1834
2765
|
// Theme
|
|
1835
2766
|
a(this, "_themeSubscription");
|
|
@@ -1842,9 +2773,9 @@ class ko extends HTMLElement {
|
|
|
1842
2773
|
a(this, "_unreadBadge");
|
|
1843
2774
|
a(this, "_container");
|
|
1844
2775
|
a(this, "_style");
|
|
1845
|
-
this._option =
|
|
2776
|
+
this._option = i;
|
|
1846
2777
|
const s = this.attachShadow({ mode: "open" });
|
|
1847
|
-
this._style = document.createElement("style"), this._container = document.createElement("div"), this._container.className = "title-section", this._iconElement = new
|
|
2778
|
+
this._style = document.createElement("style"), this._container = document.createElement("div"), this._container.className = "title-section", this._iconElement = new ne(void 0, this._option.icon.svg), this._titleElement = document.createElement("h2"), this._unreadBadge = new qe({
|
|
1848
2779
|
themeBus: e,
|
|
1849
2780
|
location: "header"
|
|
1850
2781
|
}), this._container.appendChild(this._iconElement), this._container.appendChild(this._titleElement), this._container.appendChild(this._unreadBadge), s.appendChild(this._style), s.appendChild(this._container), this._themeSubscription = e.subscribe((o) => {
|
|
@@ -1852,7 +2783,7 @@ class ko extends HTMLElement {
|
|
|
1852
2783
|
}), this.refreshTheme(this._feedType ?? "inbox");
|
|
1853
2784
|
}
|
|
1854
2785
|
getStyles() {
|
|
1855
|
-
var
|
|
2786
|
+
var i, s, o, n, c, d, l, p, m, g, f, _, b, C, k, w;
|
|
1856
2787
|
const e = this._themeSubscription.manager.getTheme();
|
|
1857
2788
|
return `
|
|
1858
2789
|
.title-section {
|
|
@@ -1869,10 +2800,10 @@ class ko extends HTMLElement {
|
|
|
1869
2800
|
|
|
1870
2801
|
h2 {
|
|
1871
2802
|
margin: 0;
|
|
1872
|
-
font-family: ${((n = (o = (s = (
|
|
1873
|
-
font-size: ${((
|
|
1874
|
-
font-weight: ${((_ = (
|
|
1875
|
-
color: ${((w = (k = (
|
|
2803
|
+
font-family: ${((n = (o = (s = (i = e.inbox) == null ? void 0 : i.header) == null ? void 0 : s.filters) == null ? void 0 : o.font) == null ? void 0 : n.family) ?? "inherit"};
|
|
2804
|
+
font-size: ${((p = (l = (d = (c = e.inbox) == null ? void 0 : c.header) == null ? void 0 : d.filters) == null ? void 0 : l.font) == null ? void 0 : p.size) ?? "18px"};
|
|
2805
|
+
font-weight: ${((_ = (f = (g = (m = e.inbox) == null ? void 0 : m.header) == null ? void 0 : g.filters) == null ? void 0 : f.font) == null ? void 0 : _.weight) ?? "500"};
|
|
2806
|
+
color: ${((w = (k = (C = (b = e.inbox) == null ? void 0 : b.header) == null ? void 0 : C.filters) == null ? void 0 : k.font) == null ? void 0 : w.color) ?? "red"};
|
|
1876
2807
|
}
|
|
1877
2808
|
|
|
1878
2809
|
courier-unread-count-badge {
|
|
@@ -1883,18 +2814,18 @@ class ko extends HTMLElement {
|
|
|
1883
2814
|
refreshTheme(e) {
|
|
1884
2815
|
this._feedType = e, this._style.textContent = this.getStyles(), this._unreadBadge.refreshTheme("header"), this.updateFilter();
|
|
1885
2816
|
}
|
|
1886
|
-
updateSelectedOption(e,
|
|
1887
|
-
this._option = e, this._feedType =
|
|
2817
|
+
updateSelectedOption(e, i, s) {
|
|
2818
|
+
this._option = e, this._feedType = i, this._unreadBadge.setCount(s), this.updateFilter();
|
|
1888
2819
|
}
|
|
1889
2820
|
updateFilter() {
|
|
1890
|
-
var
|
|
2821
|
+
var i, s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I, E, M, L, R, D, y, A, F, H, O;
|
|
1891
2822
|
const e = this._themeSubscription.manager.getTheme();
|
|
1892
2823
|
switch (this._feedType) {
|
|
1893
2824
|
case "inbox":
|
|
1894
|
-
this._titleElement.textContent = ((n = (o = (s = (
|
|
2825
|
+
this._titleElement.textContent = ((n = (o = (s = (i = e.inbox) == null ? void 0 : i.header) == null ? void 0 : s.filters) == null ? void 0 : o.inbox) == null ? void 0 : n.text) ?? "Inbox", this._iconElement.updateSVG(((m = (p = (l = (d = (c = e.inbox) == null ? void 0 : c.header) == null ? void 0 : d.filters) == null ? void 0 : l.inbox) == null ? void 0 : p.icon) == null ? void 0 : m.svg) ?? x.inbox), this._iconElement.updateColor(((C = (b = (_ = (f = (g = e.inbox) == null ? void 0 : g.header) == null ? void 0 : f.filters) == null ? void 0 : _.inbox) == null ? void 0 : b.icon) == null ? void 0 : C.color) ?? "red");
|
|
1895
2826
|
break;
|
|
1896
2827
|
case "archive":
|
|
1897
|
-
this._titleElement.textContent = ((
|
|
2828
|
+
this._titleElement.textContent = ((I = (S = (w = (k = e.inbox) == null ? void 0 : k.header) == null ? void 0 : w.filters) == null ? void 0 : S.archive) == null ? void 0 : I.text) ?? "Archive", this._iconElement.updateSVG(((D = (R = (L = (M = (E = e.inbox) == null ? void 0 : E.header) == null ? void 0 : M.filters) == null ? void 0 : L.archive) == null ? void 0 : R.icon) == null ? void 0 : D.svg) ?? x.archive), this._iconElement.updateColor(((O = (H = (F = (A = (y = e.inbox) == null ? void 0 : y.header) == null ? void 0 : A.filters) == null ? void 0 : F.archive) == null ? void 0 : H.icon) == null ? void 0 : O.color) ?? "red");
|
|
1898
2829
|
break;
|
|
1899
2830
|
}
|
|
1900
2831
|
}
|
|
@@ -1903,8 +2834,8 @@ class ko extends HTMLElement {
|
|
|
1903
2834
|
this._themeSubscription.unsubscribe();
|
|
1904
2835
|
}
|
|
1905
2836
|
}
|
|
1906
|
-
customElements.get("courier-inbox-header-title") || customElements.define("courier-inbox-header-title",
|
|
1907
|
-
class
|
|
2837
|
+
customElements.get("courier-inbox-header-title") || customElements.define("courier-inbox-header-title", Fo);
|
|
2838
|
+
class Ho extends De {
|
|
1908
2839
|
constructor(e) {
|
|
1909
2840
|
super();
|
|
1910
2841
|
// Theme
|
|
@@ -1919,86 +2850,86 @@ class wo extends Le {
|
|
|
1919
2850
|
a(this, "_style");
|
|
1920
2851
|
// Callbacks
|
|
1921
2852
|
a(this, "_onFeedTypeChange");
|
|
1922
|
-
this._themeSubscription = e.themeManager.subscribe((
|
|
2853
|
+
this._themeSubscription = e.themeManager.subscribe((i) => {
|
|
1923
2854
|
this.refreshTheme();
|
|
1924
2855
|
}), this._onFeedTypeChange = e.onFeedTypeChange;
|
|
1925
2856
|
}
|
|
1926
2857
|
// Menu options
|
|
1927
2858
|
getFilterOptions() {
|
|
1928
|
-
var s, o, n,
|
|
1929
|
-
const e = this._themeSubscription.manager.getTheme(),
|
|
2859
|
+
var s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I, E, M, L, R, D, y, A, F, H, O, z, U, N, q, V, j, X, Q, Y, ee;
|
|
2860
|
+
const e = this._themeSubscription.manager.getTheme(), i = (n = (o = (s = e.inbox) == null ? void 0 : s.header) == null ? void 0 : o.menus) == null ? void 0 : n.filters;
|
|
1930
2861
|
return [
|
|
1931
2862
|
{
|
|
1932
2863
|
id: "inbox",
|
|
1933
|
-
text: ((
|
|
2864
|
+
text: ((c = i == null ? void 0 : i.inbox) == null ? void 0 : c.text) ?? "Inbox",
|
|
1934
2865
|
icon: {
|
|
1935
|
-
color: ((
|
|
1936
|
-
svg: ((m = (
|
|
2866
|
+
color: ((l = (d = i == null ? void 0 : i.inbox) == null ? void 0 : d.icon) == null ? void 0 : l.color) ?? "red",
|
|
2867
|
+
svg: ((m = (p = i == null ? void 0 : i.inbox) == null ? void 0 : p.icon) == null ? void 0 : m.svg) ?? x.inbox
|
|
1937
2868
|
},
|
|
1938
2869
|
selectionIcon: {
|
|
1939
|
-
color: ((k = (
|
|
1940
|
-
svg: ((
|
|
2870
|
+
color: ((k = (C = (b = (_ = (f = (g = e.inbox) == null ? void 0 : g.header) == null ? void 0 : f.menus) == null ? void 0 : _.popup) == null ? void 0 : b.list) == null ? void 0 : C.selectionIcon) == null ? void 0 : k.color) ?? "red",
|
|
2871
|
+
svg: ((L = (M = (E = (I = (S = (w = e.inbox) == null ? void 0 : w.header) == null ? void 0 : S.menus) == null ? void 0 : I.popup) == null ? void 0 : E.list) == null ? void 0 : M.selectionIcon) == null ? void 0 : L.svg) ?? x.check
|
|
1941
2872
|
},
|
|
1942
|
-
onClick: (
|
|
1943
|
-
this.handleOptionMenuItemClick("inbox",
|
|
2873
|
+
onClick: (G) => {
|
|
2874
|
+
this.handleOptionMenuItemClick("inbox", G);
|
|
1944
2875
|
}
|
|
1945
2876
|
},
|
|
1946
2877
|
{
|
|
1947
2878
|
id: "archive",
|
|
1948
|
-
text: ((
|
|
2879
|
+
text: ((R = i == null ? void 0 : i.archive) == null ? void 0 : R.text) ?? "Archive",
|
|
1949
2880
|
icon: {
|
|
1950
|
-
color: ((y = (D =
|
|
1951
|
-
svg: ((F = (
|
|
2881
|
+
color: ((y = (D = i == null ? void 0 : i.archive) == null ? void 0 : D.icon) == null ? void 0 : y.color) ?? "red",
|
|
2882
|
+
svg: ((F = (A = i == null ? void 0 : i.archive) == null ? void 0 : A.icon) == null ? void 0 : F.svg) ?? x.archive
|
|
1952
2883
|
},
|
|
1953
2884
|
selectionIcon: {
|
|
1954
|
-
color: ((
|
|
1955
|
-
svg: ((
|
|
2885
|
+
color: ((q = (N = (U = (z = (O = (H = e.inbox) == null ? void 0 : H.header) == null ? void 0 : O.menus) == null ? void 0 : z.popup) == null ? void 0 : U.list) == null ? void 0 : N.selectionIcon) == null ? void 0 : q.color) ?? "red",
|
|
2886
|
+
svg: ((ee = (Y = (Q = (X = (j = (V = e.inbox) == null ? void 0 : V.header) == null ? void 0 : j.menus) == null ? void 0 : X.popup) == null ? void 0 : Q.list) == null ? void 0 : Y.selectionIcon) == null ? void 0 : ee.svg) ?? x.check
|
|
1956
2887
|
},
|
|
1957
|
-
onClick: (
|
|
1958
|
-
this.handleOptionMenuItemClick("archive",
|
|
2888
|
+
onClick: (G) => {
|
|
2889
|
+
this.handleOptionMenuItemClick("archive", G);
|
|
1959
2890
|
}
|
|
1960
2891
|
}
|
|
1961
2892
|
];
|
|
1962
2893
|
}
|
|
1963
2894
|
getActionOptions() {
|
|
1964
|
-
var s, o, n,
|
|
1965
|
-
const
|
|
2895
|
+
var s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I, E;
|
|
2896
|
+
const i = (n = (o = (s = this._themeSubscription.manager.getTheme().inbox) == null ? void 0 : s.header) == null ? void 0 : o.menus) == null ? void 0 : n.actions;
|
|
1966
2897
|
return [
|
|
1967
2898
|
{
|
|
1968
2899
|
id: "markAllRead",
|
|
1969
|
-
text: ((
|
|
2900
|
+
text: ((c = i == null ? void 0 : i.markAllRead) == null ? void 0 : c.text) ?? "Mark All as Read",
|
|
1970
2901
|
icon: {
|
|
1971
|
-
color: ((
|
|
1972
|
-
svg: ((m = (
|
|
2902
|
+
color: ((l = (d = i == null ? void 0 : i.markAllRead) == null ? void 0 : d.icon) == null ? void 0 : l.color) ?? "red",
|
|
2903
|
+
svg: ((m = (p = i == null ? void 0 : i.markAllRead) == null ? void 0 : p.icon) == null ? void 0 : m.svg) ?? x.inbox
|
|
1973
2904
|
},
|
|
1974
2905
|
selectionIcon: null,
|
|
1975
|
-
onClick: (
|
|
1976
|
-
|
|
2906
|
+
onClick: (M) => {
|
|
2907
|
+
P.shared.readAllMessages({ canCallApi: !0 });
|
|
1977
2908
|
}
|
|
1978
2909
|
},
|
|
1979
2910
|
{
|
|
1980
2911
|
id: "archiveAll",
|
|
1981
|
-
text: ((
|
|
2912
|
+
text: ((g = i == null ? void 0 : i.archiveAll) == null ? void 0 : g.text) ?? "Archive All",
|
|
1982
2913
|
icon: {
|
|
1983
|
-
color: ((_ = (
|
|
1984
|
-
svg: ((
|
|
2914
|
+
color: ((_ = (f = i == null ? void 0 : i.archiveAll) == null ? void 0 : f.icon) == null ? void 0 : _.color) ?? "red",
|
|
2915
|
+
svg: ((C = (b = i == null ? void 0 : i.archiveAll) == null ? void 0 : b.icon) == null ? void 0 : C.svg) ?? x.archive
|
|
1985
2916
|
},
|
|
1986
2917
|
selectionIcon: null,
|
|
1987
|
-
onClick: (
|
|
1988
|
-
var
|
|
1989
|
-
alert(JSON.stringify((
|
|
2918
|
+
onClick: (M) => {
|
|
2919
|
+
var L;
|
|
2920
|
+
alert(JSON.stringify((L = v.shared.client) == null ? void 0 : L.options));
|
|
1990
2921
|
}
|
|
1991
2922
|
},
|
|
1992
2923
|
{
|
|
1993
2924
|
id: "archiveRead",
|
|
1994
|
-
text: ((k =
|
|
2925
|
+
text: ((k = i == null ? void 0 : i.archiveRead) == null ? void 0 : k.text) ?? "Archive Read",
|
|
1995
2926
|
icon: {
|
|
1996
|
-
color: ((S = (w =
|
|
1997
|
-
svg: ((
|
|
2927
|
+
color: ((S = (w = i == null ? void 0 : i.archiveRead) == null ? void 0 : w.icon) == null ? void 0 : S.color) ?? "red",
|
|
2928
|
+
svg: ((E = (I = i == null ? void 0 : i.archiveRead) == null ? void 0 : I.icon) == null ? void 0 : E.svg) ?? x.archive
|
|
1998
2929
|
},
|
|
1999
2930
|
selectionIcon: null,
|
|
2000
|
-
onClick: (
|
|
2001
|
-
|
|
2931
|
+
onClick: (M) => {
|
|
2932
|
+
P.shared.archiveReadMessages({ canCallApi: !0 });
|
|
2002
2933
|
}
|
|
2003
2934
|
}
|
|
2004
2935
|
];
|
|
@@ -2007,40 +2938,40 @@ class wo extends Le {
|
|
|
2007
2938
|
return ["icon", "title", "feed-type"];
|
|
2008
2939
|
}
|
|
2009
2940
|
refreshTheme() {
|
|
2010
|
-
var s, o, n,
|
|
2011
|
-
const e = this._themeSubscription.manager.getTheme(),
|
|
2012
|
-
|
|
2941
|
+
var s, o, n, c, d, l, p;
|
|
2942
|
+
const e = this._themeSubscription.manager.getTheme(), i = (s = this.shadow) == null ? void 0 : s.querySelector(".courier-inbox-header");
|
|
2943
|
+
i && (i.style.backgroundColor = ((n = (o = e.inbox) == null ? void 0 : o.header) == null ? void 0 : n.backgroundColor) ?? r.white[500], i.style.boxShadow = ((d = (c = e.inbox) == null ? void 0 : c.header) == null ? void 0 : d.shadow) ?? `0px 1px 0px 0px ${r.gray[500]}`), (l = this._filterMenu) == null || l.setOptions(this.getFilterOptions()), (p = this._actionMenu) == null || p.setOptions(this.getActionOptions());
|
|
2013
2944
|
}
|
|
2014
|
-
handleOptionMenuItemClick(e,
|
|
2015
|
-
this._feedType = e, this._titleSection && this._titleSection.updateSelectedOption(
|
|
2945
|
+
handleOptionMenuItemClick(e, i) {
|
|
2946
|
+
this._feedType = e, this._titleSection && this._titleSection.updateSelectedOption(i, this._feedType, this._feedType === "inbox" ? this._unreadCount : 0), this._onFeedTypeChange(e);
|
|
2016
2947
|
}
|
|
2017
2948
|
render(e) {
|
|
2018
2949
|
this._feedType = e.feedType, this._unreadCount = e.unreadCount, this.refreshTitleSection();
|
|
2019
2950
|
}
|
|
2020
2951
|
refreshTitleSection() {
|
|
2021
|
-
var
|
|
2952
|
+
var i, s;
|
|
2022
2953
|
const e = this.getFilterOptions().find((o) => ["inbox", "archive"].includes(o.id) && o.id === this._feedType);
|
|
2023
|
-
e && ((
|
|
2954
|
+
e && ((i = this._titleSection) == null || i.updateSelectedOption(e, this._feedType, this._feedType === "inbox" ? this._unreadCount : 0), (s = this._filterMenu) == null || s.selectOption(e));
|
|
2024
2955
|
}
|
|
2025
2956
|
build(e) {
|
|
2026
|
-
var
|
|
2027
|
-
super.build(e), this._style = document.createElement("style"), this._style.textContent = this.getStyles(), (
|
|
2957
|
+
var i;
|
|
2958
|
+
super.build(e), this._style = document.createElement("style"), this._style.textContent = this.getStyles(), (i = this.shadow) == null || i.appendChild(this._style), this.refreshTheme();
|
|
2028
2959
|
}
|
|
2029
2960
|
defaultElement() {
|
|
2030
2961
|
const e = this.getFilterOptions();
|
|
2031
|
-
this._titleSection = new
|
|
2962
|
+
this._titleSection = new Fo(this._themeSubscription.manager, e[0]), this._filterMenu = new He(this._themeSubscription.manager, "filters", !0, e, () => {
|
|
2032
2963
|
var n;
|
|
2033
2964
|
(n = this._actionMenu) == null || n.closeMenu();
|
|
2034
|
-
}), this._actionMenu = new
|
|
2965
|
+
}), this._actionMenu = new He(this._themeSubscription.manager, "actions", !1, this.getActionOptions(), () => {
|
|
2035
2966
|
var n;
|
|
2036
2967
|
(n = this._filterMenu) == null || n.closeMenu();
|
|
2037
2968
|
}), this._filterMenu.selectOption(e[0]);
|
|
2038
|
-
const
|
|
2039
|
-
|
|
2969
|
+
const i = document.createElement("div");
|
|
2970
|
+
i.className = "spacer";
|
|
2040
2971
|
const s = document.createElement("div");
|
|
2041
2972
|
s.className = "actions", s.appendChild(this._filterMenu), s.appendChild(this._actionMenu);
|
|
2042
2973
|
const o = document.createElement("div");
|
|
2043
|
-
return o.className = "courier-inbox-header", o.appendChild(this._titleSection), o.appendChild(
|
|
2974
|
+
return o.className = "courier-inbox-header", o.appendChild(this._titleSection), o.appendChild(i), o.appendChild(s), o;
|
|
2044
2975
|
}
|
|
2045
2976
|
getStyles() {
|
|
2046
2977
|
return `
|
|
@@ -2079,22 +3010,22 @@ class wo extends Le {
|
|
|
2079
3010
|
this._themeSubscription.unsubscribe();
|
|
2080
3011
|
}
|
|
2081
3012
|
}
|
|
2082
|
-
customElements.get("courier-inbox-header") || customElements.define("courier-inbox-header",
|
|
2083
|
-
class
|
|
2084
|
-
constructor(
|
|
3013
|
+
customElements.get("courier-inbox-header") || customElements.define("courier-inbox-header", Ho);
|
|
3014
|
+
class Oo {
|
|
3015
|
+
constructor(t) {
|
|
2085
3016
|
a(this, "events");
|
|
2086
|
-
this.events =
|
|
3017
|
+
this.events = t;
|
|
2087
3018
|
}
|
|
2088
3019
|
remove() {
|
|
2089
|
-
|
|
3020
|
+
P.shared.removeDataStoreListener(this);
|
|
2090
3021
|
}
|
|
2091
3022
|
}
|
|
2092
|
-
const
|
|
3023
|
+
const Te = {
|
|
2093
3024
|
popup: {
|
|
2094
3025
|
button: {
|
|
2095
3026
|
icon: {
|
|
2096
3027
|
color: r.black[500],
|
|
2097
|
-
svg:
|
|
3028
|
+
svg: x.inbox
|
|
2098
3029
|
},
|
|
2099
3030
|
backgroundColor: "transparent",
|
|
2100
3031
|
hoverBackgroundColor: r.black[50010],
|
|
@@ -2130,14 +3061,14 @@ const we = {
|
|
|
2130
3061
|
inbox: {
|
|
2131
3062
|
icon: {
|
|
2132
3063
|
color: r.black[500],
|
|
2133
|
-
svg:
|
|
3064
|
+
svg: x.inbox
|
|
2134
3065
|
},
|
|
2135
3066
|
text: "Inbox"
|
|
2136
3067
|
},
|
|
2137
3068
|
archive: {
|
|
2138
3069
|
icon: {
|
|
2139
3070
|
color: r.black[500],
|
|
2140
|
-
svg:
|
|
3071
|
+
svg: x.archive
|
|
2141
3072
|
},
|
|
2142
3073
|
text: "Archive"
|
|
2143
3074
|
},
|
|
@@ -2168,7 +3099,7 @@ const we = {
|
|
|
2168
3099
|
},
|
|
2169
3100
|
selectionIcon: {
|
|
2170
3101
|
color: r.black[500],
|
|
2171
|
-
svg:
|
|
3102
|
+
svg: x.check
|
|
2172
3103
|
}
|
|
2173
3104
|
}
|
|
2174
3105
|
},
|
|
@@ -2176,7 +3107,7 @@ const we = {
|
|
|
2176
3107
|
button: {
|
|
2177
3108
|
icon: {
|
|
2178
3109
|
color: r.black[500],
|
|
2179
|
-
svg:
|
|
3110
|
+
svg: x.filter
|
|
2180
3111
|
},
|
|
2181
3112
|
backgroundColor: "transparent",
|
|
2182
3113
|
hoverBackgroundColor: r.black[50010],
|
|
@@ -2185,14 +3116,14 @@ const we = {
|
|
|
2185
3116
|
inbox: {
|
|
2186
3117
|
icon: {
|
|
2187
3118
|
color: r.black[500],
|
|
2188
|
-
svg:
|
|
3119
|
+
svg: x.inbox
|
|
2189
3120
|
},
|
|
2190
3121
|
text: "Inbox"
|
|
2191
3122
|
},
|
|
2192
3123
|
archive: {
|
|
2193
3124
|
icon: {
|
|
2194
3125
|
color: r.black[500],
|
|
2195
|
-
svg:
|
|
3126
|
+
svg: x.archive
|
|
2196
3127
|
},
|
|
2197
3128
|
text: "Archive"
|
|
2198
3129
|
}
|
|
@@ -2201,7 +3132,7 @@ const we = {
|
|
|
2201
3132
|
button: {
|
|
2202
3133
|
icon: {
|
|
2203
3134
|
color: r.black[500],
|
|
2204
|
-
svg:
|
|
3135
|
+
svg: x.overflow
|
|
2205
3136
|
},
|
|
2206
3137
|
backgroundColor: "transparent",
|
|
2207
3138
|
hoverBackgroundColor: r.black[50010],
|
|
@@ -2210,21 +3141,21 @@ const we = {
|
|
|
2210
3141
|
markAllRead: {
|
|
2211
3142
|
icon: {
|
|
2212
3143
|
color: r.black[500],
|
|
2213
|
-
svg:
|
|
3144
|
+
svg: x.read
|
|
2214
3145
|
},
|
|
2215
3146
|
text: "Mark All as Read"
|
|
2216
3147
|
},
|
|
2217
3148
|
archiveAll: {
|
|
2218
3149
|
icon: {
|
|
2219
3150
|
color: r.black[500],
|
|
2220
|
-
svg:
|
|
3151
|
+
svg: x.archive
|
|
2221
3152
|
},
|
|
2222
3153
|
text: "Archive All"
|
|
2223
3154
|
},
|
|
2224
3155
|
archiveRead: {
|
|
2225
3156
|
icon: {
|
|
2226
3157
|
color: r.black[500],
|
|
2227
|
-
svg:
|
|
3158
|
+
svg: x.archiveRead
|
|
2228
3159
|
},
|
|
2229
3160
|
text: "Archive Read"
|
|
2230
3161
|
}
|
|
@@ -2283,19 +3214,19 @@ const we = {
|
|
|
2283
3214
|
borderRadius: "0px",
|
|
2284
3215
|
read: {
|
|
2285
3216
|
color: r.black[500],
|
|
2286
|
-
svg:
|
|
3217
|
+
svg: x.read
|
|
2287
3218
|
},
|
|
2288
3219
|
unread: {
|
|
2289
3220
|
color: r.black[500],
|
|
2290
|
-
svg:
|
|
3221
|
+
svg: x.unread
|
|
2291
3222
|
},
|
|
2292
3223
|
archive: {
|
|
2293
3224
|
color: r.black[500],
|
|
2294
|
-
svg:
|
|
3225
|
+
svg: x.archive
|
|
2295
3226
|
},
|
|
2296
3227
|
unarchive: {
|
|
2297
3228
|
color: r.black[500],
|
|
2298
|
-
svg:
|
|
3229
|
+
svg: x.unarchive
|
|
2299
3230
|
}
|
|
2300
3231
|
}
|
|
2301
3232
|
}
|
|
@@ -2335,12 +3266,12 @@ const we = {
|
|
|
2335
3266
|
}
|
|
2336
3267
|
}
|
|
2337
3268
|
}
|
|
2338
|
-
},
|
|
3269
|
+
}, Oe = {
|
|
2339
3270
|
popup: {
|
|
2340
3271
|
button: {
|
|
2341
3272
|
icon: {
|
|
2342
3273
|
color: r.white[500],
|
|
2343
|
-
svg:
|
|
3274
|
+
svg: x.inbox
|
|
2344
3275
|
},
|
|
2345
3276
|
backgroundColor: "transparent",
|
|
2346
3277
|
hoverBackgroundColor: r.white[50010],
|
|
@@ -2376,14 +3307,14 @@ const we = {
|
|
|
2376
3307
|
inbox: {
|
|
2377
3308
|
icon: {
|
|
2378
3309
|
color: r.white[500],
|
|
2379
|
-
svg:
|
|
3310
|
+
svg: x.inbox
|
|
2380
3311
|
},
|
|
2381
3312
|
text: "Inbox"
|
|
2382
3313
|
},
|
|
2383
3314
|
archive: {
|
|
2384
3315
|
icon: {
|
|
2385
3316
|
color: r.white[500],
|
|
2386
|
-
svg:
|
|
3317
|
+
svg: x.archive
|
|
2387
3318
|
},
|
|
2388
3319
|
text: "Archive"
|
|
2389
3320
|
},
|
|
@@ -2414,7 +3345,7 @@ const we = {
|
|
|
2414
3345
|
},
|
|
2415
3346
|
selectionIcon: {
|
|
2416
3347
|
color: r.white[500],
|
|
2417
|
-
svg:
|
|
3348
|
+
svg: x.check
|
|
2418
3349
|
}
|
|
2419
3350
|
}
|
|
2420
3351
|
},
|
|
@@ -2422,7 +3353,7 @@ const we = {
|
|
|
2422
3353
|
button: {
|
|
2423
3354
|
icon: {
|
|
2424
3355
|
color: r.white[500],
|
|
2425
|
-
svg:
|
|
3356
|
+
svg: x.filter
|
|
2426
3357
|
},
|
|
2427
3358
|
backgroundColor: "transparent",
|
|
2428
3359
|
hoverBackgroundColor: r.white[50010],
|
|
@@ -2431,14 +3362,14 @@ const we = {
|
|
|
2431
3362
|
inbox: {
|
|
2432
3363
|
icon: {
|
|
2433
3364
|
color: r.white[500],
|
|
2434
|
-
svg:
|
|
3365
|
+
svg: x.inbox
|
|
2435
3366
|
},
|
|
2436
3367
|
text: "Inbox"
|
|
2437
3368
|
},
|
|
2438
3369
|
archive: {
|
|
2439
3370
|
icon: {
|
|
2440
3371
|
color: r.white[500],
|
|
2441
|
-
svg:
|
|
3372
|
+
svg: x.archive
|
|
2442
3373
|
},
|
|
2443
3374
|
text: "Archive"
|
|
2444
3375
|
}
|
|
@@ -2447,7 +3378,7 @@ const we = {
|
|
|
2447
3378
|
button: {
|
|
2448
3379
|
icon: {
|
|
2449
3380
|
color: r.white[500],
|
|
2450
|
-
svg:
|
|
3381
|
+
svg: x.overflow
|
|
2451
3382
|
},
|
|
2452
3383
|
backgroundColor: "transparent",
|
|
2453
3384
|
hoverBackgroundColor: r.white[50010],
|
|
@@ -2456,21 +3387,21 @@ const we = {
|
|
|
2456
3387
|
markAllRead: {
|
|
2457
3388
|
icon: {
|
|
2458
3389
|
color: r.white[500],
|
|
2459
|
-
svg:
|
|
3390
|
+
svg: x.read
|
|
2460
3391
|
},
|
|
2461
3392
|
text: "Mark All as Read"
|
|
2462
3393
|
},
|
|
2463
3394
|
archiveAll: {
|
|
2464
3395
|
icon: {
|
|
2465
3396
|
color: r.white[500],
|
|
2466
|
-
svg:
|
|
3397
|
+
svg: x.archive
|
|
2467
3398
|
},
|
|
2468
3399
|
text: "Archive All"
|
|
2469
3400
|
},
|
|
2470
3401
|
archiveRead: {
|
|
2471
3402
|
icon: {
|
|
2472
3403
|
color: r.white[500],
|
|
2473
|
-
svg:
|
|
3404
|
+
svg: x.archiveRead
|
|
2474
3405
|
},
|
|
2475
3406
|
text: "Archive Read"
|
|
2476
3407
|
}
|
|
@@ -2529,19 +3460,19 @@ const we = {
|
|
|
2529
3460
|
borderRadius: "0px",
|
|
2530
3461
|
read: {
|
|
2531
3462
|
color: r.white[500],
|
|
2532
|
-
svg:
|
|
3463
|
+
svg: x.read
|
|
2533
3464
|
},
|
|
2534
3465
|
unread: {
|
|
2535
3466
|
color: r.white[500],
|
|
2536
|
-
svg:
|
|
3467
|
+
svg: x.unread
|
|
2537
3468
|
},
|
|
2538
3469
|
archive: {
|
|
2539
3470
|
color: r.white[500],
|
|
2540
|
-
svg:
|
|
3471
|
+
svg: x.archive
|
|
2541
3472
|
},
|
|
2542
3473
|
unarchive: {
|
|
2543
3474
|
color: r.white[500],
|
|
2544
|
-
svg:
|
|
3475
|
+
svg: x.unarchive
|
|
2545
3476
|
}
|
|
2546
3477
|
}
|
|
2547
3478
|
}
|
|
@@ -2581,195 +3512,195 @@ const we = {
|
|
|
2581
3512
|
}
|
|
2582
3513
|
}
|
|
2583
3514
|
}
|
|
2584
|
-
},
|
|
2585
|
-
var
|
|
2586
|
-
const e =
|
|
3515
|
+
}, dn = (h, t) => {
|
|
3516
|
+
var i, s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I, E, M, L, R, D, y, A, F, H, O, z, U, N, q, V, j, X, Q, Y, ee, G, ae, he, ce, le, de, ue, pe, ge, me, be, _e, fe, xe, ve, Ce, ye, ke, we, Se, Ie, u, B, te, ie, J, Ee, Ve, je, Ze, Je, Ge, We, Ke, Xe, Qe, Ye, et, tt, it, st, ot, nt, rt, at, ht, ct, lt, dt, ut, pt, gt, mt, bt, _t, ft, xt, vt, Ct, yt, kt, wt, St, It, Et, Mt, Tt, $t, Lt, At, Pt, Bt, Rt, Dt, Ft, Ht, Ot, zt, Ut, Nt, qt, Vt, jt, Zt, Jt, Gt, Wt, Kt, Xt, Qt, Yt, ei, ti, ii, si, oi, ni, ri, ai, hi, ci, li, di, ui, pi, gi, mi, bi, _i, fi, xi, vi, Ci, yi, ki, wi, Si, Ii, Ei, Mi, Ti, $i, Li, Ai, Pi, Bi, Ri, Di, Fi, Hi, Oi, zi, Ui, Ni, qi, Vi, ji, Zi, Ji, Gi, Wi, Ki, Xi, Qi, Yi, es, ts, is, ss, os, ns, rs, as, hs, cs, ls, ds, us, ps, gs, ms, bs, _s, fs, xs, vs, Cs, ys, ks, ws, Ss, Is, Es, Ms, Ts, $s, Ls, As, Ps, Bs, Rs, Ds, Fs, Hs, Os, zs, Us, Ns, qs, Vs, js, Zs, Js, Gs, Ws, Ks, Xs, Qs, Ys, eo, to, io, so, oo, no, ro, ao, ho, co, lo, uo, po, go, mo, bo, _o, fo, xo, vo, Co;
|
|
3517
|
+
const e = h === "light" ? Te : Oe;
|
|
2587
3518
|
return {
|
|
2588
3519
|
popup: {
|
|
2589
3520
|
button: {
|
|
2590
|
-
...(
|
|
2591
|
-
...(s =
|
|
3521
|
+
...(i = e.popup) == null ? void 0 : i.button,
|
|
3522
|
+
...(s = t.popup) == null ? void 0 : s.button,
|
|
2592
3523
|
icon: {
|
|
2593
3524
|
...(n = (o = e.popup) == null ? void 0 : o.button) == null ? void 0 : n.icon,
|
|
2594
|
-
...(d = (
|
|
3525
|
+
...(d = (c = t.popup) == null ? void 0 : c.button) == null ? void 0 : d.icon
|
|
2595
3526
|
},
|
|
2596
3527
|
unreadIndicator: {
|
|
2597
|
-
...(
|
|
2598
|
-
...(
|
|
3528
|
+
...(p = (l = e.popup) == null ? void 0 : l.button) == null ? void 0 : p.unreadIndicator,
|
|
3529
|
+
...(g = (m = t.popup) == null ? void 0 : m.button) == null ? void 0 : g.unreadIndicator
|
|
2599
3530
|
}
|
|
2600
3531
|
},
|
|
2601
3532
|
window: {
|
|
2602
|
-
...(
|
|
2603
|
-
...(_ =
|
|
3533
|
+
...(f = e.popup) == null ? void 0 : f.window,
|
|
3534
|
+
...(_ = t.popup) == null ? void 0 : _.window
|
|
2604
3535
|
}
|
|
2605
3536
|
},
|
|
2606
3537
|
inbox: {
|
|
2607
3538
|
header: {
|
|
2608
3539
|
...(b = e.inbox) == null ? void 0 : b.header,
|
|
2609
|
-
...(
|
|
3540
|
+
...(C = t.inbox) == null ? void 0 : C.header,
|
|
2610
3541
|
filters: {
|
|
2611
3542
|
...(w = (k = e.inbox) == null ? void 0 : k.header) == null ? void 0 : w.filters,
|
|
2612
|
-
...(
|
|
3543
|
+
...(I = (S = t.inbox) == null ? void 0 : S.header) == null ? void 0 : I.filters,
|
|
2613
3544
|
inbox: {
|
|
2614
|
-
...(
|
|
2615
|
-
...(y = (D = (
|
|
3545
|
+
...(L = (M = (E = e.inbox) == null ? void 0 : E.header) == null ? void 0 : M.filters) == null ? void 0 : L.inbox,
|
|
3546
|
+
...(y = (D = (R = t.inbox) == null ? void 0 : R.header) == null ? void 0 : D.filters) == null ? void 0 : y.inbox,
|
|
2616
3547
|
icon: {
|
|
2617
|
-
...(
|
|
2618
|
-
...(
|
|
3548
|
+
...(O = (H = (F = (A = e.inbox) == null ? void 0 : A.header) == null ? void 0 : F.filters) == null ? void 0 : H.inbox) == null ? void 0 : O.icon,
|
|
3549
|
+
...(q = (N = (U = (z = t.inbox) == null ? void 0 : z.header) == null ? void 0 : U.filters) == null ? void 0 : N.inbox) == null ? void 0 : q.icon
|
|
2619
3550
|
}
|
|
2620
3551
|
},
|
|
2621
3552
|
archive: {
|
|
2622
|
-
...(
|
|
2623
|
-
...(
|
|
3553
|
+
...(X = (j = (V = e.inbox) == null ? void 0 : V.header) == null ? void 0 : j.filters) == null ? void 0 : X.archive,
|
|
3554
|
+
...(ee = (Y = (Q = t.inbox) == null ? void 0 : Q.header) == null ? void 0 : Y.filters) == null ? void 0 : ee.archive,
|
|
2624
3555
|
icon: {
|
|
2625
|
-
...(
|
|
2626
|
-
...(
|
|
3556
|
+
...(ce = (he = (ae = (G = e.inbox) == null ? void 0 : G.header) == null ? void 0 : ae.filters) == null ? void 0 : he.archive) == null ? void 0 : ce.icon,
|
|
3557
|
+
...(pe = (ue = (de = (le = t.inbox) == null ? void 0 : le.header) == null ? void 0 : de.filters) == null ? void 0 : ue.archive) == null ? void 0 : pe.icon
|
|
2627
3558
|
}
|
|
2628
3559
|
},
|
|
2629
3560
|
unreadIndicator: {
|
|
2630
|
-
...(
|
|
2631
|
-
...(
|
|
3561
|
+
...(be = (me = (ge = e.inbox) == null ? void 0 : ge.header) == null ? void 0 : me.filters) == null ? void 0 : be.unreadIndicator,
|
|
3562
|
+
...(xe = (fe = (_e = t.inbox) == null ? void 0 : _e.header) == null ? void 0 : fe.filters) == null ? void 0 : xe.unreadIndicator
|
|
2632
3563
|
}
|
|
2633
3564
|
},
|
|
2634
3565
|
menus: {
|
|
2635
|
-
...(
|
|
2636
|
-
...(
|
|
3566
|
+
...(Ce = (ve = e.inbox) == null ? void 0 : ve.header) == null ? void 0 : Ce.menus,
|
|
3567
|
+
...(ke = (ye = t.inbox) == null ? void 0 : ye.header) == null ? void 0 : ke.menus,
|
|
2637
3568
|
popup: {
|
|
2638
|
-
...(
|
|
2639
|
-
...(
|
|
3569
|
+
...(Ie = (Se = (we = e.inbox) == null ? void 0 : we.header) == null ? void 0 : Se.menus) == null ? void 0 : Ie.popup,
|
|
3570
|
+
...(te = (B = (u = t.inbox) == null ? void 0 : u.header) == null ? void 0 : B.menus) == null ? void 0 : te.popup,
|
|
2640
3571
|
list: {
|
|
2641
|
-
...(
|
|
2642
|
-
...(
|
|
3572
|
+
...(Ve = (Ee = (J = (ie = e.inbox) == null ? void 0 : ie.header) == null ? void 0 : J.menus) == null ? void 0 : Ee.popup) == null ? void 0 : Ve.list,
|
|
3573
|
+
...(Ge = (Je = (Ze = (je = t.inbox) == null ? void 0 : je.header) == null ? void 0 : Ze.menus) == null ? void 0 : Je.popup) == null ? void 0 : Ge.list,
|
|
2643
3574
|
font: {
|
|
2644
|
-
...(
|
|
2645
|
-
...(
|
|
3575
|
+
...(Ye = (Qe = (Xe = (Ke = (We = e.inbox) == null ? void 0 : We.header) == null ? void 0 : Ke.menus) == null ? void 0 : Xe.popup) == null ? void 0 : Qe.list) == null ? void 0 : Ye.font,
|
|
3576
|
+
...(ot = (st = (it = (tt = (et = t.inbox) == null ? void 0 : et.header) == null ? void 0 : tt.menus) == null ? void 0 : it.popup) == null ? void 0 : st.list) == null ? void 0 : ot.font
|
|
2646
3577
|
},
|
|
2647
3578
|
selectionIcon: {
|
|
2648
|
-
...(
|
|
2649
|
-
...(
|
|
3579
|
+
...(ct = (ht = (at = (rt = (nt = e.inbox) == null ? void 0 : nt.header) == null ? void 0 : rt.menus) == null ? void 0 : at.popup) == null ? void 0 : ht.list) == null ? void 0 : ct.selectionIcon,
|
|
3580
|
+
...(gt = (pt = (ut = (dt = (lt = t.inbox) == null ? void 0 : lt.header) == null ? void 0 : dt.menus) == null ? void 0 : ut.popup) == null ? void 0 : pt.list) == null ? void 0 : gt.selectionIcon
|
|
2650
3581
|
}
|
|
2651
3582
|
}
|
|
2652
3583
|
},
|
|
2653
3584
|
filters: {
|
|
2654
|
-
...(
|
|
2655
|
-
...(
|
|
3585
|
+
...(_t = (bt = (mt = e.inbox) == null ? void 0 : mt.header) == null ? void 0 : bt.menus) == null ? void 0 : _t.filters,
|
|
3586
|
+
...(vt = (xt = (ft = t.inbox) == null ? void 0 : ft.header) == null ? void 0 : xt.menus) == null ? void 0 : vt.filters,
|
|
2656
3587
|
inbox: {
|
|
2657
|
-
...(
|
|
2658
|
-
...(
|
|
3588
|
+
...(wt = (kt = (yt = (Ct = e.inbox) == null ? void 0 : Ct.header) == null ? void 0 : yt.menus) == null ? void 0 : kt.filters) == null ? void 0 : wt.inbox,
|
|
3589
|
+
...(Mt = (Et = (It = (St = t.inbox) == null ? void 0 : St.header) == null ? void 0 : It.menus) == null ? void 0 : Et.filters) == null ? void 0 : Mt.inbox,
|
|
2659
3590
|
icon: {
|
|
2660
|
-
...(
|
|
2661
|
-
...(
|
|
3591
|
+
...(Pt = (At = (Lt = ($t = (Tt = e.inbox) == null ? void 0 : Tt.header) == null ? void 0 : $t.menus) == null ? void 0 : Lt.filters) == null ? void 0 : At.inbox) == null ? void 0 : Pt.icon,
|
|
3592
|
+
...(Ht = (Ft = (Dt = (Rt = (Bt = t.inbox) == null ? void 0 : Bt.header) == null ? void 0 : Rt.menus) == null ? void 0 : Dt.filters) == null ? void 0 : Ft.inbox) == null ? void 0 : Ht.icon
|
|
2662
3593
|
}
|
|
2663
3594
|
},
|
|
2664
3595
|
archive: {
|
|
2665
|
-
...(
|
|
2666
|
-
...(
|
|
3596
|
+
...(Nt = (Ut = (zt = (Ot = e.inbox) == null ? void 0 : Ot.header) == null ? void 0 : zt.menus) == null ? void 0 : Ut.filters) == null ? void 0 : Nt.archive,
|
|
3597
|
+
...(Zt = (jt = (Vt = (qt = t.inbox) == null ? void 0 : qt.header) == null ? void 0 : Vt.menus) == null ? void 0 : jt.filters) == null ? void 0 : Zt.archive,
|
|
2667
3598
|
icon: {
|
|
2668
|
-
...(
|
|
2669
|
-
...(
|
|
3599
|
+
...(Xt = (Kt = (Wt = (Gt = (Jt = e.inbox) == null ? void 0 : Jt.header) == null ? void 0 : Gt.menus) == null ? void 0 : Wt.filters) == null ? void 0 : Kt.archive) == null ? void 0 : Xt.icon,
|
|
3600
|
+
...(ii = (ti = (ei = (Yt = (Qt = t.inbox) == null ? void 0 : Qt.header) == null ? void 0 : Yt.menus) == null ? void 0 : ei.filters) == null ? void 0 : ti.archive) == null ? void 0 : ii.icon
|
|
2670
3601
|
}
|
|
2671
3602
|
}
|
|
2672
3603
|
},
|
|
2673
3604
|
actions: {
|
|
2674
|
-
...(
|
|
2675
|
-
...(
|
|
3605
|
+
...(ni = (oi = (si = e.inbox) == null ? void 0 : si.header) == null ? void 0 : oi.menus) == null ? void 0 : ni.actions,
|
|
3606
|
+
...(hi = (ai = (ri = t.inbox) == null ? void 0 : ri.header) == null ? void 0 : ai.menus) == null ? void 0 : hi.actions,
|
|
2676
3607
|
markAllRead: {
|
|
2677
|
-
...(
|
|
2678
|
-
...(
|
|
3608
|
+
...(ui = (di = (li = (ci = e.inbox) == null ? void 0 : ci.header) == null ? void 0 : li.menus) == null ? void 0 : di.actions) == null ? void 0 : ui.markAllRead,
|
|
3609
|
+
...(bi = (mi = (gi = (pi = t.inbox) == null ? void 0 : pi.header) == null ? void 0 : gi.menus) == null ? void 0 : mi.actions) == null ? void 0 : bi.markAllRead,
|
|
2679
3610
|
icon: {
|
|
2680
|
-
...(
|
|
2681
|
-
...(
|
|
3611
|
+
...(Ci = (vi = (xi = (fi = (_i = e.inbox) == null ? void 0 : _i.header) == null ? void 0 : fi.menus) == null ? void 0 : xi.actions) == null ? void 0 : vi.markAllRead) == null ? void 0 : Ci.icon,
|
|
3612
|
+
...(Ii = (Si = (wi = (ki = (yi = t.inbox) == null ? void 0 : yi.header) == null ? void 0 : ki.menus) == null ? void 0 : wi.actions) == null ? void 0 : Si.markAllRead) == null ? void 0 : Ii.icon
|
|
2682
3613
|
}
|
|
2683
3614
|
},
|
|
2684
3615
|
archiveAll: {
|
|
2685
|
-
...(
|
|
2686
|
-
...(
|
|
3616
|
+
...($i = (Ti = (Mi = (Ei = e.inbox) == null ? void 0 : Ei.header) == null ? void 0 : Mi.menus) == null ? void 0 : Ti.actions) == null ? void 0 : $i.archiveAll,
|
|
3617
|
+
...(Bi = (Pi = (Ai = (Li = t.inbox) == null ? void 0 : Li.header) == null ? void 0 : Ai.menus) == null ? void 0 : Pi.actions) == null ? void 0 : Bi.archiveAll,
|
|
2687
3618
|
icon: {
|
|
2688
|
-
...(
|
|
2689
|
-
...(
|
|
3619
|
+
...(Oi = (Hi = (Fi = (Di = (Ri = e.inbox) == null ? void 0 : Ri.header) == null ? void 0 : Di.menus) == null ? void 0 : Fi.actions) == null ? void 0 : Hi.archiveAll) == null ? void 0 : Oi.icon,
|
|
3620
|
+
...(Vi = (qi = (Ni = (Ui = (zi = t.inbox) == null ? void 0 : zi.header) == null ? void 0 : Ui.menus) == null ? void 0 : Ni.actions) == null ? void 0 : qi.archiveAll) == null ? void 0 : Vi.icon
|
|
2690
3621
|
}
|
|
2691
3622
|
},
|
|
2692
3623
|
archiveRead: {
|
|
2693
|
-
...(
|
|
2694
|
-
...(
|
|
3624
|
+
...(Gi = (Ji = (Zi = (ji = e.inbox) == null ? void 0 : ji.header) == null ? void 0 : Zi.menus) == null ? void 0 : Ji.actions) == null ? void 0 : Gi.archiveRead,
|
|
3625
|
+
...(Qi = (Xi = (Ki = (Wi = t.inbox) == null ? void 0 : Wi.header) == null ? void 0 : Ki.menus) == null ? void 0 : Xi.actions) == null ? void 0 : Qi.archiveRead,
|
|
2695
3626
|
icon: {
|
|
2696
|
-
...(
|
|
2697
|
-
...(
|
|
3627
|
+
...(ss = (is = (ts = (es = (Yi = e.inbox) == null ? void 0 : Yi.header) == null ? void 0 : es.menus) == null ? void 0 : ts.actions) == null ? void 0 : is.archiveRead) == null ? void 0 : ss.icon,
|
|
3628
|
+
...(hs = (as = (rs = (ns = (os = t.inbox) == null ? void 0 : os.header) == null ? void 0 : ns.menus) == null ? void 0 : rs.actions) == null ? void 0 : as.archiveRead) == null ? void 0 : hs.icon
|
|
2698
3629
|
}
|
|
2699
3630
|
}
|
|
2700
3631
|
}
|
|
2701
3632
|
}
|
|
2702
3633
|
},
|
|
2703
3634
|
list: {
|
|
2704
|
-
...(
|
|
2705
|
-
...(
|
|
3635
|
+
...(cs = e.inbox) == null ? void 0 : cs.list,
|
|
3636
|
+
...(ls = t.inbox) == null ? void 0 : ls.list,
|
|
2706
3637
|
item: {
|
|
2707
|
-
...(
|
|
2708
|
-
...(
|
|
3638
|
+
...(us = (ds = e.inbox) == null ? void 0 : ds.list) == null ? void 0 : us.item,
|
|
3639
|
+
...(gs = (ps = t.inbox) == null ? void 0 : ps.list) == null ? void 0 : gs.item,
|
|
2709
3640
|
menu: {
|
|
2710
|
-
...(
|
|
2711
|
-
...(
|
|
3641
|
+
...(_s = (bs = (ms = e.inbox) == null ? void 0 : ms.list) == null ? void 0 : bs.item) == null ? void 0 : _s.menu,
|
|
3642
|
+
...(vs = (xs = (fs = t.inbox) == null ? void 0 : fs.list) == null ? void 0 : xs.item) == null ? void 0 : vs.menu,
|
|
2712
3643
|
item: {
|
|
2713
|
-
...(
|
|
2714
|
-
...(
|
|
3644
|
+
...(ws = (ks = (ys = (Cs = e.inbox) == null ? void 0 : Cs.list) == null ? void 0 : ys.item) == null ? void 0 : ks.menu) == null ? void 0 : ws.item,
|
|
3645
|
+
...(Ms = (Es = (Is = (Ss = t.inbox) == null ? void 0 : Ss.list) == null ? void 0 : Is.item) == null ? void 0 : Es.menu) == null ? void 0 : Ms.item,
|
|
2715
3646
|
read: {
|
|
2716
|
-
...(
|
|
2717
|
-
...(
|
|
3647
|
+
...(Ps = (As = (Ls = ($s = (Ts = e.inbox) == null ? void 0 : Ts.list) == null ? void 0 : $s.item) == null ? void 0 : Ls.menu) == null ? void 0 : As.item) == null ? void 0 : Ps.read,
|
|
3648
|
+
...(Hs = (Fs = (Ds = (Rs = (Bs = t.inbox) == null ? void 0 : Bs.list) == null ? void 0 : Rs.item) == null ? void 0 : Ds.menu) == null ? void 0 : Fs.item) == null ? void 0 : Hs.read
|
|
2718
3649
|
},
|
|
2719
3650
|
unread: {
|
|
2720
|
-
...(
|
|
2721
|
-
...(
|
|
3651
|
+
...(qs = (Ns = (Us = (zs = (Os = e.inbox) == null ? void 0 : Os.list) == null ? void 0 : zs.item) == null ? void 0 : Us.menu) == null ? void 0 : Ns.item) == null ? void 0 : qs.unread,
|
|
3652
|
+
...(Gs = (Js = (Zs = (js = (Vs = t.inbox) == null ? void 0 : Vs.list) == null ? void 0 : js.item) == null ? void 0 : Zs.menu) == null ? void 0 : Js.item) == null ? void 0 : Gs.unread
|
|
2722
3653
|
},
|
|
2723
3654
|
archive: {
|
|
2724
|
-
...(
|
|
2725
|
-
...(
|
|
3655
|
+
...(Ys = (Qs = (Xs = (Ks = (Ws = e.inbox) == null ? void 0 : Ws.list) == null ? void 0 : Ks.item) == null ? void 0 : Xs.menu) == null ? void 0 : Qs.item) == null ? void 0 : Ys.archive,
|
|
3656
|
+
...(oo = (so = (io = (to = (eo = t.inbox) == null ? void 0 : eo.list) == null ? void 0 : to.item) == null ? void 0 : io.menu) == null ? void 0 : so.item) == null ? void 0 : oo.archive
|
|
2726
3657
|
},
|
|
2727
3658
|
unarchive: {
|
|
2728
|
-
...(
|
|
2729
|
-
...(
|
|
3659
|
+
...(co = (ho = (ao = (ro = (no = e.inbox) == null ? void 0 : no.list) == null ? void 0 : ro.item) == null ? void 0 : ao.menu) == null ? void 0 : ho.item) == null ? void 0 : co.unarchive,
|
|
3660
|
+
...(mo = (go = (po = (uo = (lo = t.inbox) == null ? void 0 : lo.list) == null ? void 0 : uo.item) == null ? void 0 : po.menu) == null ? void 0 : go.item) == null ? void 0 : mo.unarchive
|
|
2730
3661
|
}
|
|
2731
3662
|
}
|
|
2732
3663
|
}
|
|
2733
3664
|
}
|
|
2734
3665
|
},
|
|
2735
3666
|
loading: {
|
|
2736
|
-
...(
|
|
2737
|
-
...(
|
|
3667
|
+
...(bo = e.inbox) == null ? void 0 : bo.loading,
|
|
3668
|
+
...(_o = t.inbox) == null ? void 0 : _o.loading
|
|
2738
3669
|
},
|
|
2739
3670
|
empty: {
|
|
2740
|
-
...(
|
|
2741
|
-
...(
|
|
3671
|
+
...(fo = e.inbox) == null ? void 0 : fo.empty,
|
|
3672
|
+
...(xo = t.inbox) == null ? void 0 : xo.empty
|
|
2742
3673
|
},
|
|
2743
3674
|
error: {
|
|
2744
|
-
...(
|
|
2745
|
-
...(
|
|
3675
|
+
...(vo = e.inbox) == null ? void 0 : vo.error,
|
|
3676
|
+
...(Co = t.inbox) == null ? void 0 : Co.error
|
|
2746
3677
|
}
|
|
2747
3678
|
}
|
|
2748
3679
|
};
|
|
2749
3680
|
};
|
|
2750
|
-
class
|
|
2751
|
-
constructor(
|
|
3681
|
+
class zo {
|
|
3682
|
+
constructor(t) {
|
|
2752
3683
|
// Event IDs
|
|
2753
3684
|
a(this, "THEME_CHANGE_EVENT", "courier_inbox_theme_change");
|
|
2754
3685
|
// State
|
|
2755
3686
|
a(this, "_theme");
|
|
2756
|
-
a(this, "_lightTheme",
|
|
2757
|
-
a(this, "_darkTheme",
|
|
3687
|
+
a(this, "_lightTheme", Te);
|
|
3688
|
+
a(this, "_darkTheme", Oe);
|
|
2758
3689
|
a(this, "_target");
|
|
2759
3690
|
a(this, "_subscriptions", []);
|
|
2760
3691
|
// System theme
|
|
2761
3692
|
a(this, "_userMode");
|
|
2762
3693
|
a(this, "_systemMode");
|
|
2763
3694
|
a(this, "_systemThemeCleanup");
|
|
2764
|
-
this._theme =
|
|
3695
|
+
this._theme = t, this._target = new EventTarget(), this._userMode = "system", this._systemMode = Mo(), this.setLightTheme(Te), this.setDarkTheme(Oe), this._systemThemeCleanup = To((e) => {
|
|
2765
3696
|
this._systemMode = e, this.updateTheme();
|
|
2766
3697
|
});
|
|
2767
3698
|
}
|
|
2768
|
-
setLightTheme(
|
|
2769
|
-
this._lightTheme =
|
|
3699
|
+
setLightTheme(t) {
|
|
3700
|
+
this._lightTheme = t, this._systemMode === "light" && this.updateTheme();
|
|
2770
3701
|
}
|
|
2771
|
-
setDarkTheme(
|
|
2772
|
-
this._darkTheme =
|
|
3702
|
+
setDarkTheme(t) {
|
|
3703
|
+
this._darkTheme = t, this._systemMode === "dark" && this.updateTheme();
|
|
2773
3704
|
}
|
|
2774
3705
|
/**
|
|
2775
3706
|
* Get the current system theme
|
|
@@ -2787,53 +3718,53 @@ class Eo {
|
|
|
2787
3718
|
* Update the theme
|
|
2788
3719
|
*/
|
|
2789
3720
|
updateTheme() {
|
|
2790
|
-
const
|
|
2791
|
-
this.setTheme(
|
|
3721
|
+
const t = this._userMode === "system" ? this._systemMode : this._userMode, e = t === "light" ? this._lightTheme : this._darkTheme, i = dn(t, e);
|
|
3722
|
+
this.setTheme(i);
|
|
2792
3723
|
}
|
|
2793
3724
|
/**
|
|
2794
3725
|
* Set the theme and notify all listeners
|
|
2795
3726
|
*/
|
|
2796
|
-
setTheme(
|
|
2797
|
-
|
|
2798
|
-
detail: { theme:
|
|
3727
|
+
setTheme(t) {
|
|
3728
|
+
t !== this._theme && (this._theme = t, this._target.dispatchEvent(new CustomEvent(this.THEME_CHANGE_EVENT, {
|
|
3729
|
+
detail: { theme: t }
|
|
2799
3730
|
})));
|
|
2800
3731
|
}
|
|
2801
3732
|
/**
|
|
2802
3733
|
* Set the mode and notify all listeners
|
|
2803
3734
|
*/
|
|
2804
|
-
setMode(
|
|
2805
|
-
this._userMode =
|
|
3735
|
+
setMode(t) {
|
|
3736
|
+
this._userMode = t, this.updateTheme();
|
|
2806
3737
|
}
|
|
2807
3738
|
/**
|
|
2808
3739
|
* Subscribe to theme changes
|
|
2809
3740
|
* @param {Function} callback - Function to run when the theme changes
|
|
2810
3741
|
* @returns {CourierInboxThemeSubscription} - Object with remove method to stop listening
|
|
2811
3742
|
*/
|
|
2812
|
-
subscribe(
|
|
3743
|
+
subscribe(t) {
|
|
2813
3744
|
const e = new AbortController();
|
|
2814
3745
|
this._target.addEventListener(this.THEME_CHANGE_EVENT, (s) => {
|
|
2815
|
-
|
|
3746
|
+
t(s.detail.theme);
|
|
2816
3747
|
}, { signal: e.signal });
|
|
2817
|
-
const
|
|
3748
|
+
const i = {
|
|
2818
3749
|
manager: this,
|
|
2819
3750
|
unsubscribe: () => {
|
|
2820
3751
|
e.abort();
|
|
2821
|
-
const s = this._subscriptions.indexOf(
|
|
3752
|
+
const s = this._subscriptions.indexOf(i);
|
|
2822
3753
|
s > -1 && this._subscriptions.splice(s, 1);
|
|
2823
3754
|
}
|
|
2824
3755
|
};
|
|
2825
|
-
return this._subscriptions.push(
|
|
3756
|
+
return this._subscriptions.push(i), i;
|
|
2826
3757
|
}
|
|
2827
3758
|
/**
|
|
2828
3759
|
* Clean up event listeners
|
|
2829
3760
|
*/
|
|
2830
3761
|
cleanup() {
|
|
2831
|
-
this._systemThemeCleanup && this._systemThemeCleanup(), this._subscriptions.forEach((
|
|
3762
|
+
this._systemThemeCleanup && this._systemThemeCleanup(), this._subscriptions.forEach((t) => t.unsubscribe()), this._subscriptions = [];
|
|
2832
3763
|
}
|
|
2833
3764
|
}
|
|
2834
|
-
class
|
|
3765
|
+
class Uo extends HTMLElement {
|
|
2835
3766
|
constructor(e) {
|
|
2836
|
-
var
|
|
3767
|
+
var i;
|
|
2837
3768
|
super();
|
|
2838
3769
|
// State
|
|
2839
3770
|
a(this, "_currentFeed", "inbox");
|
|
@@ -2855,16 +3786,16 @@ class Mo extends HTMLElement {
|
|
|
2855
3786
|
// Default props
|
|
2856
3787
|
a(this, "_defaultProps", {
|
|
2857
3788
|
title: "Inbox",
|
|
2858
|
-
icon:
|
|
3789
|
+
icon: x.inbox,
|
|
2859
3790
|
feedType: this._currentFeed,
|
|
2860
3791
|
height: "768px"
|
|
2861
3792
|
});
|
|
2862
|
-
this._shadow = this.attachShadow({ mode: "open" }), this._themeManager = e ?? new
|
|
3793
|
+
this._shadow = this.attachShadow({ mode: "open" }), this._themeManager = e ?? new zo(Te), this._header = new Ho({
|
|
2863
3794
|
themeManager: this._themeManager,
|
|
2864
3795
|
onFeedTypeChange: (s) => {
|
|
2865
3796
|
this.setFeedType(s);
|
|
2866
3797
|
}
|
|
2867
|
-
}), this._header.build(void 0), this._shadow.appendChild(this._header), this._list = new
|
|
3798
|
+
}), this._header.build(void 0), this._shadow.appendChild(this._header), this._list = new Ro({
|
|
2868
3799
|
themeManager: this._themeManager,
|
|
2869
3800
|
onRefresh: () => {
|
|
2870
3801
|
this.refresh();
|
|
@@ -2872,28 +3803,28 @@ class Mo extends HTMLElement {
|
|
|
2872
3803
|
onPaginationTrigger: async (s) => {
|
|
2873
3804
|
var o, n;
|
|
2874
3805
|
try {
|
|
2875
|
-
await
|
|
3806
|
+
await P.shared.fetchNextPageOfMessages({
|
|
2876
3807
|
feedType: s
|
|
2877
3808
|
});
|
|
2878
|
-
} catch (
|
|
2879
|
-
(n = (o =
|
|
3809
|
+
} catch (c) {
|
|
3810
|
+
(n = (o = v.shared.client) == null ? void 0 : o.options.logger) == null || n.error("Failed to fetch next page of messages:", c);
|
|
2880
3811
|
}
|
|
2881
3812
|
},
|
|
2882
3813
|
onMessageClick: (s, o) => {
|
|
2883
3814
|
var n;
|
|
2884
|
-
|
|
3815
|
+
P.shared.clickMessage({ message: s }), this.dispatchEvent(new CustomEvent("message-click", {
|
|
2885
3816
|
detail: { message: s, index: o },
|
|
2886
3817
|
bubbles: !0,
|
|
2887
3818
|
composed: !0
|
|
2888
3819
|
})), (n = this._onMessageClick) == null || n.call(this, { message: s, index: o });
|
|
2889
3820
|
},
|
|
2890
3821
|
onMessageActionClick: (s, o, n) => {
|
|
2891
|
-
var
|
|
3822
|
+
var c;
|
|
2892
3823
|
this.dispatchEvent(new CustomEvent("message-action-click", {
|
|
2893
3824
|
detail: { message: s, action: o, index: n },
|
|
2894
3825
|
bubbles: !0,
|
|
2895
3826
|
composed: !0
|
|
2896
|
-
})), (
|
|
3827
|
+
})), (c = this._onMessageActionClick) == null || c.call(this, { message: s, action: o, index: n });
|
|
2897
3828
|
},
|
|
2898
3829
|
onMessageLongPress: (s, o) => {
|
|
2899
3830
|
var n;
|
|
@@ -2903,7 +3834,7 @@ class Mo extends HTMLElement {
|
|
|
2903
3834
|
composed: !0
|
|
2904
3835
|
})), (n = this._onMessageLongPress) == null || n.call(this, { message: s, index: o });
|
|
2905
3836
|
}
|
|
2906
|
-
}), this._style = document.createElement("style"), this.refreshTheme(), this._shadow.appendChild(this._style), this._shadow.appendChild(this._list), this._datastoreListener = new
|
|
3837
|
+
}), this._style = document.createElement("style"), this.refreshTheme(), this._shadow.appendChild(this._style), this._shadow.appendChild(this._list), this._datastoreListener = new Oo({
|
|
2907
3838
|
onError: (s) => {
|
|
2908
3839
|
this._list.setError(s);
|
|
2909
3840
|
},
|
|
@@ -2925,11 +3856,11 @@ class Mo extends HTMLElement {
|
|
|
2925
3856
|
onUnreadCountChange: (s) => {
|
|
2926
3857
|
this.updateHeader();
|
|
2927
3858
|
}
|
|
2928
|
-
}),
|
|
3859
|
+
}), P.shared.addDataStoreListener(this._datastoreListener), this._themeManager.subscribe((s) => {
|
|
2929
3860
|
this.refreshTheme();
|
|
2930
|
-
}), this._authListener =
|
|
3861
|
+
}), this._authListener = v.shared.addAuthenticationListener((s) => {
|
|
2931
3862
|
this.refresh();
|
|
2932
|
-
}), (
|
|
3863
|
+
}), (i = v.shared.client) != null && i.options.userId && this.refresh();
|
|
2933
3864
|
}
|
|
2934
3865
|
get theme() {
|
|
2935
3866
|
return this._themeManager.getTheme();
|
|
@@ -3005,7 +3936,7 @@ class Mo extends HTMLElement {
|
|
|
3005
3936
|
updateHeader() {
|
|
3006
3937
|
const e = {
|
|
3007
3938
|
feedType: this._currentFeed,
|
|
3008
|
-
unreadCount:
|
|
3939
|
+
unreadCount: P.shared.unreadCount,
|
|
3009
3940
|
messageCount: this._list.messages.length
|
|
3010
3941
|
};
|
|
3011
3942
|
switch (this._headerFactory) {
|
|
@@ -3016,13 +3947,13 @@ class Mo extends HTMLElement {
|
|
|
3016
3947
|
this._header.build(null);
|
|
3017
3948
|
break;
|
|
3018
3949
|
default:
|
|
3019
|
-
const
|
|
3020
|
-
this._header.build(
|
|
3950
|
+
const i = this._headerFactory(e);
|
|
3951
|
+
this._header.build(i);
|
|
3021
3952
|
break;
|
|
3022
3953
|
}
|
|
3023
3954
|
}
|
|
3024
3955
|
async load(e) {
|
|
3025
|
-
await
|
|
3956
|
+
await P.shared.load(e);
|
|
3026
3957
|
}
|
|
3027
3958
|
refresh() {
|
|
3028
3959
|
this.load({
|
|
@@ -3034,12 +3965,12 @@ class Mo extends HTMLElement {
|
|
|
3034
3965
|
this.refresh();
|
|
3035
3966
|
}
|
|
3036
3967
|
disconnectedCallback() {
|
|
3037
|
-
var e,
|
|
3038
|
-
this._themeManager.cleanup(), (e = this._datastoreListener) == null || e.remove(), (
|
|
3968
|
+
var e, i;
|
|
3969
|
+
this._themeManager.cleanup(), (e = this._datastoreListener) == null || e.remove(), (i = this._authListener) == null || i.remove();
|
|
3039
3970
|
}
|
|
3040
|
-
attributeChangedCallback(e,
|
|
3041
|
-
var o, n,
|
|
3042
|
-
if (
|
|
3971
|
+
attributeChangedCallback(e, i, s) {
|
|
3972
|
+
var o, n, c, d, l, p;
|
|
3973
|
+
if (i !== s)
|
|
3043
3974
|
switch (e) {
|
|
3044
3975
|
case "height":
|
|
3045
3976
|
const m = s || this._defaultProps.height;
|
|
@@ -3049,8 +3980,8 @@ class Mo extends HTMLElement {
|
|
|
3049
3980
|
if (s)
|
|
3050
3981
|
try {
|
|
3051
3982
|
this._onMessageClick = new Function("props", s);
|
|
3052
|
-
} catch (
|
|
3053
|
-
(n = (o =
|
|
3983
|
+
} catch (g) {
|
|
3984
|
+
(n = (o = v.shared.client) == null ? void 0 : o.options.logger) == null || n.error("Failed to parse message-click handler:", g);
|
|
3054
3985
|
}
|
|
3055
3986
|
else
|
|
3056
3987
|
this._onMessageClick = void 0;
|
|
@@ -3059,8 +3990,8 @@ class Mo extends HTMLElement {
|
|
|
3059
3990
|
if (s)
|
|
3060
3991
|
try {
|
|
3061
3992
|
this._onMessageActionClick = new Function("props", s);
|
|
3062
|
-
} catch (
|
|
3063
|
-
(d = (
|
|
3993
|
+
} catch (g) {
|
|
3994
|
+
(d = (c = v.shared.client) == null ? void 0 : c.options.logger) == null || d.error("Failed to parse message-action-click handler:", g);
|
|
3064
3995
|
}
|
|
3065
3996
|
else
|
|
3066
3997
|
this._onMessageActionClick = void 0;
|
|
@@ -3069,8 +4000,8 @@ class Mo extends HTMLElement {
|
|
|
3069
4000
|
if (s)
|
|
3070
4001
|
try {
|
|
3071
4002
|
this._onMessageLongPress = new Function("props", s);
|
|
3072
|
-
} catch (
|
|
3073
|
-
(
|
|
4003
|
+
} catch (g) {
|
|
4004
|
+
(p = (l = v.shared.client) == null ? void 0 : l.options.logger) == null || p.error("Failed to parse message-long-press handler:", g);
|
|
3074
4005
|
}
|
|
3075
4006
|
else
|
|
3076
4007
|
this._onMessageLongPress = void 0;
|
|
@@ -3087,8 +4018,8 @@ class Mo extends HTMLElement {
|
|
|
3087
4018
|
}
|
|
3088
4019
|
}
|
|
3089
4020
|
}
|
|
3090
|
-
customElements.get("courier-inbox") || customElements.define("courier-inbox",
|
|
3091
|
-
class
|
|
4021
|
+
customElements.get("courier-inbox") || customElements.define("courier-inbox", Uo);
|
|
4022
|
+
class No extends De {
|
|
3092
4023
|
constructor(e) {
|
|
3093
4024
|
super();
|
|
3094
4025
|
// Theme
|
|
@@ -3097,12 +4028,12 @@ class Io extends Le {
|
|
|
3097
4028
|
a(this, "_container");
|
|
3098
4029
|
a(this, "_triggerButton");
|
|
3099
4030
|
a(this, "_unreadCountBadge");
|
|
3100
|
-
this._themeSubscription = e.subscribe((
|
|
4031
|
+
this._themeSubscription = e.subscribe((i) => {
|
|
3101
4032
|
this.updateTheme();
|
|
3102
4033
|
});
|
|
3103
4034
|
}
|
|
3104
4035
|
defaultElement() {
|
|
3105
|
-
this._container = document.createElement("div"), this._container.className = "menu-button-container", this._triggerButton = new
|
|
4036
|
+
this._container = document.createElement("div"), this._container.className = "menu-button-container", this._triggerButton = new $e(x.inbox), this._unreadCountBadge = new qe({
|
|
3106
4037
|
themeBus: this._themeSubscription.manager,
|
|
3107
4038
|
location: "button"
|
|
3108
4039
|
}), this._unreadCountBadge.id = "unread-badge";
|
|
@@ -3125,20 +4056,20 @@ class Io extends Le {
|
|
|
3125
4056
|
`;
|
|
3126
4057
|
}
|
|
3127
4058
|
onUnreadCountChange(e) {
|
|
3128
|
-
var
|
|
3129
|
-
(
|
|
4059
|
+
var i;
|
|
4060
|
+
(i = this._unreadCountBadge) == null || i.setCount(e), this.updateTheme();
|
|
3130
4061
|
}
|
|
3131
4062
|
updateTheme() {
|
|
3132
|
-
var
|
|
4063
|
+
var i, s, o, n, c, d, l, p, m, g, f, _, b, C, k, w, S, I;
|
|
3133
4064
|
const e = this._themeSubscription.manager.getTheme();
|
|
3134
|
-
(n = this._triggerButton) == null || n.updateIconColor(((o = (s = (
|
|
4065
|
+
(n = this._triggerButton) == null || n.updateIconColor(((o = (s = (i = e == null ? void 0 : e.popup) == null ? void 0 : i.button) == null ? void 0 : s.icon) == null ? void 0 : o.color) ?? r.black[500]), (p = this._triggerButton) == null || p.updateIconSVG(((l = (d = (c = e == null ? void 0 : e.popup) == null ? void 0 : c.button) == null ? void 0 : d.icon) == null ? void 0 : l.svg) ?? x.inbox), (f = this._triggerButton) == null || f.updateBackgroundColor(((g = (m = e == null ? void 0 : e.popup) == null ? void 0 : m.button) == null ? void 0 : g.backgroundColor) ?? "transparent"), (C = this._triggerButton) == null || C.updateHoverBackgroundColor(((b = (_ = e == null ? void 0 : e.popup) == null ? void 0 : _.button) == null ? void 0 : b.hoverBackgroundColor) ?? r.black[50010]), (S = this._triggerButton) == null || S.updateActiveBackgroundColor(((w = (k = e == null ? void 0 : e.popup) == null ? void 0 : k.button) == null ? void 0 : w.activeBackgroundColor) ?? r.black[50020]), (I = this._unreadCountBadge) == null || I.refreshTheme("button");
|
|
3135
4066
|
}
|
|
3136
4067
|
disconnectedCallback() {
|
|
3137
4068
|
this._themeSubscription.unsubscribe();
|
|
3138
4069
|
}
|
|
3139
4070
|
}
|
|
3140
|
-
customElements.get("courier-inbox-menu-button") || customElements.define("courier-inbox-menu-button",
|
|
3141
|
-
class
|
|
4071
|
+
customElements.get("courier-inbox-menu-button") || customElements.define("courier-inbox-menu-button", No);
|
|
4072
|
+
class un extends HTMLElement {
|
|
3142
4073
|
constructor() {
|
|
3143
4074
|
super();
|
|
3144
4075
|
// State
|
|
@@ -3150,7 +4081,7 @@ class Fo extends HTMLElement {
|
|
|
3150
4081
|
a(this, "_bottom", "40px");
|
|
3151
4082
|
a(this, "_left", "0");
|
|
3152
4083
|
// Theming
|
|
3153
|
-
a(this, "_themeManager", new
|
|
4084
|
+
a(this, "_themeManager", new zo(Te));
|
|
3154
4085
|
// Components
|
|
3155
4086
|
a(this, "_triggerButton");
|
|
3156
4087
|
a(this, "_popup");
|
|
@@ -3161,7 +4092,7 @@ class Fo extends HTMLElement {
|
|
|
3161
4092
|
// Factories
|
|
3162
4093
|
a(this, "_popupMenuButtonFactory");
|
|
3163
4094
|
const e = this.attachShadow({ mode: "open" });
|
|
3164
|
-
this._triggerButton = new
|
|
4095
|
+
this._triggerButton = new No(this._themeManager), this._triggerButton.build(void 0), this._popup = document.createElement("div"), this._popup.className = "popup", this._inbox = new Uo(this._themeManager), this._inbox.setAttribute("height", "100%"), this._style = document.createElement("style"), this.refreshTheme(), e.appendChild(this._style), e.appendChild(this._triggerButton), e.appendChild(this._popup), this._popup.appendChild(this._inbox), this._triggerButton.addEventListener("click", this.togglePopup.bind(this)), document.addEventListener("click", this.handleOutsideClick.bind(this)), this.updatePopupPosition(), this._datastoreListener = new Oo(this), P.shared.addDataStoreListener(this._datastoreListener), this._themeManager.subscribe((i) => {
|
|
3165
4096
|
this.refreshTheme();
|
|
3166
4097
|
});
|
|
3167
4098
|
}
|
|
@@ -3181,7 +4112,7 @@ class Fo extends HTMLElement {
|
|
|
3181
4112
|
this._style.textContent = this.getStyles();
|
|
3182
4113
|
}
|
|
3183
4114
|
getStyles() {
|
|
3184
|
-
var e,
|
|
4115
|
+
var e, i, s, o, n, c, d, l;
|
|
3185
4116
|
return `
|
|
3186
4117
|
:host {
|
|
3187
4118
|
display: inline-block;
|
|
@@ -3196,10 +4127,10 @@ class Fo extends HTMLElement {
|
|
|
3196
4127
|
.popup {
|
|
3197
4128
|
display: none;
|
|
3198
4129
|
position: absolute;
|
|
3199
|
-
background: ${((
|
|
4130
|
+
background: ${((i = (e = this.theme.popup) == null ? void 0 : e.window) == null ? void 0 : i.backgroundColor) ?? "red"};
|
|
3200
4131
|
border-radius: ${((o = (s = this.theme.popup) == null ? void 0 : s.window) == null ? void 0 : o.borderRadius) ?? "8px"};
|
|
3201
|
-
border: ${((
|
|
3202
|
-
box-shadow: ${((
|
|
4132
|
+
border: ${((c = (n = this.theme.popup) == null ? void 0 : n.window) == null ? void 0 : c.border) ?? "1px solid red"};
|
|
4133
|
+
box-shadow: ${((l = (d = this.theme.popup) == null ? void 0 : d.window) == null ? void 0 : l.shadow) ?? "0px 8px 16px -4px red"};
|
|
3203
4134
|
z-index: 1000;
|
|
3204
4135
|
width: ${this._width};
|
|
3205
4136
|
height: ${this._height};
|
|
@@ -3220,7 +4151,7 @@ class Fo extends HTMLElement {
|
|
|
3220
4151
|
}
|
|
3221
4152
|
`;
|
|
3222
4153
|
}
|
|
3223
|
-
attributeChangedCallback(e,
|
|
4154
|
+
attributeChangedCallback(e, i, s) {
|
|
3224
4155
|
switch (e) {
|
|
3225
4156
|
case "popup-alignment":
|
|
3226
4157
|
this.isValidPosition(s) && (this._popupAlignment = s, this.updatePopupPosition());
|
|
@@ -3319,12 +4250,12 @@ class Fo extends HTMLElement {
|
|
|
3319
4250
|
setContent(e) {
|
|
3320
4251
|
this._inbox.innerHTML = "", this._inbox.appendChild(e);
|
|
3321
4252
|
}
|
|
3322
|
-
setSize(e,
|
|
3323
|
-
this._width = e, this._height =
|
|
4253
|
+
setSize(e, i) {
|
|
4254
|
+
this._width = e, this._height = i, this._popup.style.width = e, this._popup.style.height = i;
|
|
3324
4255
|
}
|
|
3325
4256
|
setPosition(e) {
|
|
3326
|
-
var
|
|
3327
|
-
this.isValidPosition(e) ? (this._popupAlignment = e, this.updatePopupPosition()) : (s = (
|
|
4257
|
+
var i, s;
|
|
4258
|
+
this.isValidPosition(e) ? (this._popupAlignment = e, this.updatePopupPosition()) : (s = (i = v.shared.client) == null ? void 0 : i.options.logger) == null || s.error(`Invalid position: ${e}`);
|
|
3328
4259
|
}
|
|
3329
4260
|
setFeedType(e) {
|
|
3330
4261
|
this._inbox.setFeedType(e);
|
|
@@ -3355,15 +4286,15 @@ class Fo extends HTMLElement {
|
|
|
3355
4286
|
this._popupMenuButtonFactory = e, this.render();
|
|
3356
4287
|
}
|
|
3357
4288
|
render() {
|
|
3358
|
-
const e =
|
|
4289
|
+
const e = P.shared.unreadCount;
|
|
3359
4290
|
switch (this._popupMenuButtonFactory) {
|
|
3360
4291
|
case void 0:
|
|
3361
4292
|
case null:
|
|
3362
4293
|
this._triggerButton.build(void 0), this._triggerButton.onUnreadCountChange(e);
|
|
3363
4294
|
break;
|
|
3364
4295
|
default:
|
|
3365
|
-
const
|
|
3366
|
-
this._triggerButton.build(
|
|
4296
|
+
const i = this._popupMenuButtonFactory({ unreadCount: e });
|
|
4297
|
+
this._triggerButton.build(i);
|
|
3367
4298
|
break;
|
|
3368
4299
|
}
|
|
3369
4300
|
}
|
|
@@ -3372,39 +4303,39 @@ class Fo extends HTMLElement {
|
|
|
3372
4303
|
(e = this._datastoreListener) == null || e.remove(), this._themeManager.cleanup();
|
|
3373
4304
|
}
|
|
3374
4305
|
}
|
|
3375
|
-
customElements.get("courier-inbox-menu") || customElements.define("courier-inbox-menu",
|
|
3376
|
-
class
|
|
3377
|
-
onDataSetChange(
|
|
4306
|
+
customElements.get("courier-inbox-menu") || customElements.define("courier-inbox-menu", un);
|
|
4307
|
+
class xn {
|
|
4308
|
+
onDataSetChange(t, e) {
|
|
3378
4309
|
}
|
|
3379
|
-
onPageAdded(
|
|
4310
|
+
onPageAdded(t, e) {
|
|
3380
4311
|
}
|
|
3381
|
-
onUnreadCountChange(
|
|
4312
|
+
onUnreadCountChange(t) {
|
|
3382
4313
|
}
|
|
3383
|
-
onMessageAdd(
|
|
4314
|
+
onMessageAdd(t, e, i) {
|
|
3384
4315
|
}
|
|
3385
|
-
onMessageRemove(
|
|
4316
|
+
onMessageRemove(t, e, i) {
|
|
3386
4317
|
}
|
|
3387
|
-
onMessageUpdate(
|
|
4318
|
+
onMessageUpdate(t, e, i) {
|
|
3388
4319
|
}
|
|
3389
|
-
onError(
|
|
4320
|
+
onError(t) {
|
|
3390
4321
|
}
|
|
3391
4322
|
}
|
|
3392
4323
|
export {
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
4324
|
+
Uo as CourierInbox,
|
|
4325
|
+
Oo as CourierInboxDataStoreListener,
|
|
4326
|
+
P as CourierInboxDatastore,
|
|
4327
|
+
xn as CourierInboxDatastoreEvents,
|
|
4328
|
+
Ho as CourierInboxHeader,
|
|
4329
|
+
un as CourierInboxMenu,
|
|
4330
|
+
zo as CourierInboxThemeManager,
|
|
4331
|
+
Ao as CourierListItem,
|
|
4332
|
+
_n as archiveMessage,
|
|
4333
|
+
bn as clickMessage,
|
|
4334
|
+
Oe as defaultDarkTheme,
|
|
4335
|
+
Te as defaultLightTheme,
|
|
4336
|
+
ln as getMessageTime,
|
|
4337
|
+
gn as markAsRead,
|
|
4338
|
+
mn as markAsUnread,
|
|
4339
|
+
dn as mergeTheme,
|
|
4340
|
+
fn as openMessage
|
|
3410
4341
|
};
|