@talkjs/core 1.5.9 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,7 +135,7 @@ let p = null;
135
135
  function f({ WebSocket: e2 }) {
136
136
  p = e2;
137
137
  }
138
- class m {
138
+ class g {
139
139
  constructor(e2, t2) {
140
140
  this.realtimeUrl = e2, this.handlers = t2, this.socket = null, this.stateMachine = new u("ReconnectingSocket", ["STOPPED", "CONNECTING", "READY", "DISCONNECTED", "TERMINATED"], { startWs: { from: ["STOPPED", "DISCONNECTED"], to: "CONNECTING", afterTransition: () => {
141
141
  const e3 = new (function() {
@@ -184,9 +184,9 @@ class m {
184
184
  this.stateMachine.transition("destroy");
185
185
  }
186
186
  }
187
- class g {
187
+ class m {
188
188
  constructor(e2, t2) {
189
- this.handlers = t2, this.socket = new m(e2, { onOpen: () => this.handlers.onOpen(), onClose: () => this.handlers.onClose(), onMessage: (e3) => this.onWebSocketMessage(e3) });
189
+ this.handlers = t2, this.socket = new g(e2, { onOpen: () => this.handlers.onOpen(), onClose: () => this.handlers.onClose(), onMessage: (e3) => this.onWebSocketMessage(e3) });
190
190
  }
191
191
  call(e2, t2, s2, n2) {
192
192
  const r2 = `/${s2.map((e3) => encodeURIComponent(e3)).join("/")}`, i2 = JSON.stringify([e2, t2, r2, n2]);
@@ -205,7 +205,7 @@ class g {
205
205
  this.socket.terminate();
206
206
  }
207
207
  onWebSocketMessage(e2) {
208
- if ("Auth token expired" !== e2.data) try {
208
+ try {
209
209
  const t2 = JSON.parse(e2.data);
210
210
  if ("PUBLISH" === t2[1]) {
211
211
  const e3 = t2[0], s2 = JSON.stringify([e3, "ACK"]);
@@ -220,7 +220,6 @@ class g {
220
220
  }
221
221
  } catch (e3) {
222
222
  }
223
- else this.handlers.onAuthExpired();
224
223
  }
225
224
  }
226
225
  class v {
@@ -249,7 +248,7 @@ class w {
249
248
  }
250
249
  class b {
251
250
  constructor(e2, t2) {
252
- this.handlers = t2, this.seqCounter = new w(), this.responseHandlers = {}, this.heartbeats = new y(this), this.socket = new g(e2, { onUpstreamRestarting: () => {
251
+ this.handlers = t2, this.seqCounter = new w(), this.responseHandlers = {}, this.heartbeats = new y(this), this.socket = new m(e2, { onUpstreamRestarting: () => {
253
252
  this.heartbeats.serverActive(), this.handlers.onUpstreamRestarting();
254
253
  }, onOpen: () => {
255
254
  this.heartbeats.clientActive(), this.heartbeats.serverActive(), this.handlers.onReady();
@@ -321,15 +320,15 @@ class C {
321
320
  this.authProvider = t2, this.handlers = s2, this.stateMachine = new u("AuthenticatedConnection", ["WAITING_FOR_WS", "LOGGING_IN", "RENEWING_SESSION", "READY", "TERMINATED"], { logIn: { from: ["WAITING_FOR_WS"], to: "LOGGING_IN", afterTransition: () => __async(this, null, function* () {
322
321
  yield this.renewSession();
323
322
  }) }, logInFailed: { from: ["LOGGING_IN"], to: "LOGGING_IN", afterTransition: () => __async(this, null, function* () {
324
- this.authProvider.refreshToken(), yield this.renewSession();
323
+ this.authProvider.invalidateAndRefresh(), yield this.renewSession();
325
324
  }) }, scheduledReauth: { from: ["READY"], to: "RENEWING_SESSION", afterTransition: () => __async(this, null, function* () {
326
325
  yield this.renewSession();
327
326
  }) }, scheduledReauthFailed: { from: ["RENEWING_SESSION"], to: "RENEWING_SESSION", afterTransition: () => __async(this, null, function* () {
328
- this.authProvider.refreshToken(), yield this.renewSession();
327
+ this.authProvider.invalidateAndRefresh(), yield this.renewSession();
329
328
  }) }, authenticated: { from: ["LOGGING_IN", "RENEWING_SESSION"], to: "READY", afterTransition: ({ from: e3 }) => {
330
329
  "LOGGING_IN" === e3 && this.handlers.onReady();
331
330
  } }, authExpired: { from: ["READY", "RENEWING_SESSION"], to: "LOGGING_IN", afterTransition: () => __async(this, null, function* () {
332
- this.handlers.onNotReady(), this.authProvider.refreshToken(), yield this.renewSession();
331
+ this.handlers.onNotReady(), this.authProvider.invalidateAndRefresh(), yield this.renewSession();
333
332
  }) }, wsDisconnected: { from: ["READY", "LOGGING_IN", "RENEWING_SESSION"], to: "WAITING_FOR_WS", afterTransition: ({ from: e3 }) => {
334
333
  "READY" !== e3 && "RENEWING_SESSION" !== e3 || this.handlers.onNotReady(), this.authProvider.clearScheduledRefresh();
335
334
  } }, destroy: { from: "ANY", to: "TERMINATED", afterTransition: () => {
@@ -361,7 +360,10 @@ class C {
361
360
  }
362
361
  renewSession() {
363
362
  return __async(this, null, function* () {
364
- const e2 = yield this.authProvider.getToken(), s2 = yield this.connection.call("POST", ["session", "renew"], { token: e2 });
363
+ const e2 = yield this.authProvider.getToken().catch(() => {
364
+ });
365
+ if (!e2) return;
366
+ const s2 = yield this.connection.call("POST", ["session", "renew"], { token: e2 });
365
367
  if (!s2.ok && "client" === s2.where) return;
366
368
  const n2 = s2.value;
367
369
  if (n2.status, 200 === n2.status) {
@@ -736,10 +738,10 @@ function P(e2) {
736
738
  }
737
739
  }(e3)));
738
740
  }
739
- function j(e2, t2) {
741
+ function U(e2, t2) {
740
742
  return void 0 === t2 ? e2 : t2;
741
743
  }
742
- function U(e2, t2) {
744
+ function j(e2, t2) {
743
745
  return void 0 === t2 ? e2 : _(t2);
744
746
  }
745
747
  function $(e2, t2) {
@@ -1115,7 +1117,7 @@ class ce extends z {
1115
1117
  this.mutate(e2, (s2) => {
1116
1118
  const n2 = s2.value.snapshot;
1117
1119
  if (null === n2) return console.warn("[TalkJS] Received a 'used edited' event for a user that we thought didn't exist."), s2;
1118
- return c({ snapshot: { id: n2.id, name: j(n2.name, t2.diff.name), custom: $(n2.custom, t2.diff.custom), locale: j(n2.locale, t2.diff.locale), photoUrl: j(n2.photoUrl, t2.diff.photoUrl), role: j(n2.role, t2.diff.role), welcomeMessage: j(n2.welcomeMessage, t2.diff.welcomeMessage) }, lastChanged: e2 });
1120
+ return c({ snapshot: { id: n2.id, name: U(n2.name, t2.diff.name), custom: $(n2.custom, t2.diff.custom), locale: U(n2.locale, t2.diff.locale), photoUrl: U(n2.photoUrl, t2.diff.photoUrl), role: U(n2.role, t2.diff.role), welcomeMessage: U(n2.welcomeMessage, t2.diff.welcomeMessage) }, lastChanged: e2 });
1119
1121
  });
1120
1122
  }
1121
1123
  getFromCache() {
@@ -1184,7 +1186,7 @@ class le extends G {
1184
1186
  const n2 = s2.value.data.content, r2 = (i2 = n2, void 0 === (a2 = t2.diff.content) ? i2 : O(a2));
1185
1187
  var i2, a2;
1186
1188
  const o2 = n2 === r2 ? s2.value.data.plaintext : re(r2, {});
1187
- return c({ lastChanged: e2, sender: s2.value.sender, data: { id: s2.value.data.id, type: s2.value.data.type, createdAt: s2.value.data.createdAt, origin: s2.value.data.origin, referencedMessageId: s2.value.data.referencedMessageId, editedAt: j(s2.value.data.editedAt, t2.diff.editedAt), custom: $(s2.value.data.custom, t2.diff.custom), plaintext: o2, content: r2, reactions: he(s2.value.data.reactions, t2.diff.reactions) } });
1189
+ return c({ lastChanged: e2, sender: s2.value.sender, data: { id: s2.value.data.id, type: s2.value.data.type, createdAt: s2.value.data.createdAt, origin: s2.value.data.origin, referencedMessageId: s2.value.data.referencedMessageId, editedAt: U(s2.value.data.editedAt, t2.diff.editedAt), custom: $(s2.value.data.custom, t2.diff.custom), plaintext: o2, content: r2, reactions: he(s2.value.data.reactions, t2.diff.reactions) } });
1188
1190
  });
1189
1191
  }
1190
1192
  messageDeleted(e2, t2) {
@@ -1209,7 +1211,7 @@ function he(e2, t2) {
1209
1211
  if (void 0 === t2) return e2;
1210
1212
  const s2 = e2.map((e3) => {
1211
1213
  const s3 = t2[e3.emoji];
1212
- return void 0 === s3 ? e3 : _(null === s3 ? __spreadProps(__spreadValues({}, e3), { count: 0 }) : { emoji: e3.emoji, count: j(e3.count, s3.count), currentUserReacted: j(e3.currentUserReacted, s3.currentUserReacted) });
1214
+ return void 0 === s3 ? e3 : _(null === s3 ? __spreadProps(__spreadValues({}, e3), { count: 0 }) : { emoji: e3.emoji, count: U(e3.count, s3.count), currentUserReacted: U(e3.currentUserReacted, s3.currentUserReacted) });
1213
1215
  }).filter((e3) => e3.count > 0), n2 = new Set(s2.map((e3) => e3.emoji));
1214
1216
  for (const e3 in t2) {
1215
1217
  const r2 = t2[e3];
@@ -1272,7 +1274,7 @@ class pe extends z {
1272
1274
  fetchInitial(e2) {
1273
1275
  return __async(this, null, function* () {
1274
1276
  const t2 = this.onlyUsedInternally ? 1 : 30, s2 = yield fe({ realtimeClient: this.realtimeClient, conversationId: this.conversationId, count: t2 });
1275
- return s2.ok ? null === s2.value.messages ? c({ lastChanged: e2, lastMessageChanged: e2, stores: null, inWindow: null, windowEnd: null }) : me({ seq: e2, messages: s2.value.messages, cursor: s2.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : s2;
1277
+ return s2.ok ? null === s2.value.messages ? c({ lastChanged: e2, lastMessageChanged: e2, stores: null, inWindow: null, windowEnd: null }) : ge({ seq: e2, messages: s2.value.messages, cursor: s2.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : s2;
1276
1278
  });
1277
1279
  }
1278
1280
  teardownNested(e2) {
@@ -1330,7 +1332,7 @@ class pe extends z {
1330
1332
  });
1331
1333
  }
1332
1334
  loadedMore(e2, t2) {
1333
- this.mutate(e2, (s2) => null === s2.value.windowEnd ? s2 : t2.data.ok ? null === t2.data.value.messages ? (console.warn("[TalkJS] When loading more messages, the conversation no longer existed. We should have been told about this."), s2) : me({ seq: e2, prevState: s2.value, messages: t2.data.value.messages, cursor: t2.data.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : t2.data);
1335
+ this.mutate(e2, (s2) => null === s2.value.windowEnd ? s2 : t2.data.ok ? null === t2.data.value.messages ? (console.warn("[TalkJS] When loading more messages, the conversation no longer existed. We should have been told about this."), s2) : ge({ seq: e2, prevState: s2.value, messages: t2.data.value.messages, cursor: t2.data.value.nextCursor, conversationId: this.conversationId, realtimeClient: this.realtimeClient }) : t2.data);
1334
1336
  }
1335
1337
  messageCreated(e2, t2) {
1336
1338
  this.mutate(e2, (s2) => {
@@ -1409,7 +1411,7 @@ function fe(_0) {
1409
1411
  return (i2.ok || "server" !== i2.where || 404 !== i2.value.status) && (i2.ok || "server" !== i2.where || 403 !== i2.value.status || "NOT_A_PARTICIPANT" !== i2.value.errorCode) ? i2 : c({ messages: null, nextCursor: null });
1410
1412
  });
1411
1413
  }
1412
- function me({ seq: e2, prevState: t2, messages: s2, cursor: n2, conversationId: r2, realtimeClient: i2 }) {
1414
+ function ge({ seq: e2, prevState: t2, messages: s2, cursor: n2, conversationId: r2, realtimeClient: i2 }) {
1413
1415
  var _a2, _b, _c, _d;
1414
1416
  const a2 = t2 ? __spreadValues({}, t2.stores) : {};
1415
1417
  for (const t3 of s2) if (void 0 === a2[t3.id]) {
@@ -1430,7 +1432,7 @@ function me({ seq: e2, prevState: t2, messages: s2, cursor: n2, conversationId:
1430
1432
  if (null === n2) return c({ lastChanged: e2, lastMessageChanged: h2, stores: a2, inWindow: o2, windowEnd: null });
1431
1433
  return c({ lastChanged: e2, lastMessageChanged: h2, stores: a2, inWindow: o2, windowEnd: { cursor: n2, oldestMessageTs: s2[s2.length - 1].createdAt } });
1432
1434
  }
1433
- class ge extends z {
1435
+ class me extends z {
1434
1436
  constructor(e2, t2, s2, n2, r2) {
1435
1437
  super(e2, n2, r2), this.convData = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 0;
1436
1438
  }
@@ -1581,7 +1583,7 @@ class ye extends G {
1581
1583
  participantEdited(e2, t2) {
1582
1584
  this.mutate(e2, (s2) => {
1583
1585
  if (null === s2.value.data) return s2;
1584
- return c({ lastChanged: e2, user: s2.value.user, data: { id: s2.value.data.id, access: j(s2.value.data.access, t2.diff.access), notify: j(s2.value.data.notify, t2.diff.notify), joinedAt: s2.value.data.joinedAt } });
1586
+ return c({ lastChanged: e2, user: s2.value.user, data: { id: s2.value.data.id, access: U(s2.value.data.access, t2.diff.access), notify: U(s2.value.data.notify, t2.diff.notify), joinedAt: s2.value.data.joinedAt } });
1585
1587
  });
1586
1588
  }
1587
1589
  participantDeleted(e2, t2) {
@@ -1906,7 +1908,7 @@ class Ie extends z {
1906
1908
  }
1907
1909
  function De(e2, t2) {
1908
1910
  const s2 = t2;
1909
- return { id: e2.id, createdAt: e2.createdAt, subject: j(e2.subject, s2.subject), photoUrl: j(e2.photoUrl, s2.photoUrl), welcomeMessages: U(e2.welcomeMessages, s2.welcomeMessages), custom: $(e2.custom, s2.custom), lastMessageAt: j(e2.lastMessageAt, s2.lastMessageAt), unreadMessageCount: j(e2.unreadMessageCount, s2.unreadMessageCount), isUnread: j(e2.isUnread, s2.isUnread), access: j(e2.access, s2.access), notify: j(e2.notify, s2.notify), readUntil: j(e2.readUntil, s2.readUntil), everyoneReadUntil: j(e2.everyoneReadUntil, s2.everyoneReadUntil), joinedAt: e2.joinedAt };
1911
+ return { id: e2.id, createdAt: e2.createdAt, subject: U(e2.subject, s2.subject), photoUrl: U(e2.photoUrl, s2.photoUrl), welcomeMessages: j(e2.welcomeMessages, s2.welcomeMessages), custom: $(e2.custom, s2.custom), lastMessageAt: U(e2.lastMessageAt, s2.lastMessageAt), unreadMessageCount: U(e2.unreadMessageCount, s2.unreadMessageCount), isUnread: U(e2.isUnread, s2.isUnread), access: U(e2.access, s2.access), notify: U(e2.notify, s2.notify), readUntil: U(e2.readUntil, s2.readUntil), everyoneReadUntil: U(e2.everyoneReadUntil, s2.everyoneReadUntil), joinedAt: e2.joinedAt };
1910
1912
  }
1911
1913
  class Se extends z {
1912
1914
  constructor(e2, t2, s2, n2, r2) {
@@ -2128,7 +2130,7 @@ class Me {
2128
2130
  }
2129
2131
  instantiateStore(e2, t2) {
2130
2132
  if (s(e2, ["users", "*"])) return new ce(this.virtualSeq, e2[1], this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2131
- if (s(e2, ["me", "conversations", "*"])) return new ge(this.virtualSeq, this.subscribeConvData(e2[2]), this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2133
+ if (s(e2, ["me", "conversations", "*"])) return new me(this.virtualSeq, this.subscribeConvData(e2[2]), this.realtimeClient, this.emitMutex, { onTeardown: t2 });
2132
2134
  if (s(e2, ["me", "conversations", "*", "messages"])) return new pe(this.virtualSeq, e2[2], this.realtimeClient, this.emitMutex, { onTeardown: t2, onLoadedMore: (e3) => this.onVirtualPublish(e3) });
2133
2135
  if (s(e2, ["me", "conversations", "*", "participants"])) return new Ce(this.virtualSeq, e2[2], this.realtimeClient, this.emitMutex, { onTeardown: t2, onLoadedMore: (e3) => this.onVirtualPublish(e3) });
2134
2136
  if (s(e2, ["me", "conversations", "*", "typing"])) return new be(this.virtualSeq, e2[2], this.realtimeClient, this.emitMutex, { onTeardown: t2 });
@@ -2322,7 +2324,7 @@ function Pe(e2) {
2322
2324
  if (20 != a2.length) throw new Error("Length should be 20.");
2323
2325
  return a2;
2324
2326
  }
2325
- const je = (e2, t2, s2 = void 0) => function(e3, t3) {
2327
+ const Ue = (e2, t2, s2 = void 0) => function(e3, t3) {
2326
2328
  return e3.reduce((e4, s3, n2) => e4.concat(t3(s3, n2)), []);
2327
2329
  }(e2, (e3) => {
2328
2330
  if ("string" == typeof e3) return t2(e3, s2);
@@ -2335,14 +2337,14 @@ const je = (e2, t2, s2 = void 0) => function(e3, t3) {
2335
2337
  case "bulletList":
2336
2338
  case "bulletpoint":
2337
2339
  case "bulletPoint":
2338
- return [{ type: e3.type, children: je(e3.children, t2, e3.type) }];
2340
+ return [{ type: e3.type, children: Ue(e3.children, t2, e3.type) }];
2339
2341
  case "link":
2340
- return [{ type: e3.type, url: e3.url, children: je(e3.children, t2, e3.type) }];
2342
+ return [{ type: e3.type, url: e3.url, children: Ue(e3.children, t2, e3.type) }];
2341
2343
  case "actionlink":
2342
2344
  case "actionLink":
2343
2345
  case "actionbutton":
2344
2346
  case "actionButton":
2345
- return [{ type: e3.type, action: e3.action, params: e3.params, children: je(e3.children, t2, e3.type) }];
2347
+ return [{ type: e3.type, action: e3.action, params: e3.params, children: Ue(e3.children, t2, e3.type) }];
2346
2348
  case "mention":
2347
2349
  case "autolink":
2348
2350
  case "autoLink":
@@ -2357,7 +2359,7 @@ const je = (e2, t2, s2 = void 0) => function(e3, t3) {
2357
2359
  return [e3];
2358
2360
  }
2359
2361
  });
2360
- function Ue(e2, t2) {
2362
+ function je(e2, t2) {
2361
2363
  return (s2) => {
2362
2364
  const n2 = s2;
2363
2365
  let r2 = 0;
@@ -2381,7 +2383,7 @@ function Le(e2) {
2381
2383
  }
2382
2384
  function Ge(e2, t2 = 0) {
2383
2385
  const s2 = qe[t2], n2 = s2 ? function(e3) {
2384
- const t3 = ze.getOrCompute(e3, () => new RegExp(`(?:^|[\\s${$e}])(?:${e3.source})(?=[\\s${$e}]|$)`, "g")), s3 = Ue(t3, (e4) => {
2386
+ const t3 = ze.getOrCompute(e3, () => new RegExp(`(?:^|[\\s${$e}])(?:${e3.source})(?=[\\s${$e}]|$)`, "g")), s3 = je(t3, (e4) => {
2385
2387
  const t4 = e4[0][1], s4 = e4[1] || e4[2] || e4[3] || e4[4] || e4[5] || e4[6];
2386
2388
  return [" ", { type: We[He[t4]], children: [s4] }];
2387
2389
  });
@@ -2390,7 +2392,7 @@ function Ge(e2, t2 = 0) {
2390
2392
  return t4.length > 1 && n3.unshift(t4.substring(1)), n3;
2391
2393
  };
2392
2394
  }(s2) : () => [e2];
2393
- return je(n2(e2), (e3, s3) => "bold" === s3 || "italic" === s3 || "strikethrough" === s3 ? Ge(e3, t2 | We[s3]) : [e3]);
2395
+ return Ue(n2(e2), (e3, s3) => "bold" === s3 || "italic" === s3 || "strikethrough" === s3 ? Ge(e3, t2 | We[s3]) : [e3]);
2394
2396
  }
2395
2397
  const ze = function() {
2396
2398
  const e2 = function() {
@@ -2695,7 +2697,7 @@ var tt, st = function() {
2695
2697
  }, t2;
2696
2698
  }(Ke), ut = function(e2) {
2697
2699
  this.__jsduckDummyDocProp = null, this.tagBuilder = e2.tagBuilder;
2698
- }, ct = /[A-Za-z]/, lt = /[\d]/, ht = /[\D]/, dt = /\s/, pt = /['"]/, ft = /[\x00-\x1F\x7F]/, mt = /A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC/.source, gt = mt + /\u2700-\u27bf\udde6-\uddff\ud800-\udbff\udc00-\udfff\ufe0e\ufe0f\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0\ud83c\udffb-\udfff\u200d\u3299\u3297\u303d\u3030\u24c2\ud83c\udd70-\udd71\udd7e-\udd7f\udd8e\udd91-\udd9a\udde6-\uddff\ude01-\ude02\ude1a\ude2f\ude32-\ude3a\ude50-\ude51\u203c\u2049\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe\u00a9\u00ae\u2122\u2139\udc04\u2600-\u26FF\u2b05\u2b06\u2b07\u2b1b\u2b1c\u2b50\u2b55\u231a\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\udccf\u2935\u2934\u2190-\u21ff/.source + /\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F/.source, vt = /0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19/.source, wt = gt + vt, bt = gt + vt, yt = "(?:[" + vt + "]{1,3}\\.){3}[" + vt + "]{1,3}", Ct = "[" + bt + "](?:[" + bt + "\\-]{0,61}[" + bt + "])?", At = function(e2) {
2700
+ }, ct = /[A-Za-z]/, lt = /[\d]/, ht = /[\D]/, dt = /\s/, pt = /['"]/, ft = /[\x00-\x1F\x7F]/, gt = /A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC/.source, mt = gt + /\u2700-\u27bf\udde6-\uddff\ud800-\udbff\udc00-\udfff\ufe0e\ufe0f\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0\ud83c\udffb-\udfff\u200d\u3299\u3297\u303d\u3030\u24c2\ud83c\udd70-\udd71\udd7e-\udd7f\udd8e\udd91-\udd9a\udde6-\uddff\ude01-\ude02\ude1a\ude2f\ude32-\ude3a\ude50-\ude51\u203c\u2049\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe\u00a9\u00ae\u2122\u2139\udc04\u2600-\u26FF\u2b05\u2b06\u2b07\u2b1b\u2b1c\u2b50\u2b55\u231a\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\udccf\u2935\u2934\u2190-\u21ff/.source + /\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F/.source, vt = /0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19/.source, wt = mt + vt, bt = mt + vt, yt = "(?:[" + vt + "]{1,3}\\.){3}[" + vt + "]{1,3}", Ct = "[" + bt + "](?:[" + bt + "\\-]{0,61}[" + bt + "])?", At = function(e2) {
2699
2701
  return "(?=(" + Ct + "))\\" + e2;
2700
2702
  }, Et = function(e2) {
2701
2703
  return "(?:" + At(e2) + "(?:\\." + At(e2 + 1) + "){0,126}|" + yt + ")";
@@ -2718,10 +2720,10 @@ var tt, st = function() {
2718
2720
  f2(h2);
2719
2721
  break;
2720
2722
  case 3:
2721
- m2(h2);
2723
+ g2(h2);
2722
2724
  break;
2723
2725
  case 4:
2724
- g2(h2);
2726
+ m2(h2);
2725
2727
  break;
2726
2728
  case 5:
2727
2729
  v2(h2);
@@ -2747,10 +2749,10 @@ var tt, st = function() {
2747
2749
  function f2(e4) {
2748
2750
  "." === e4 ? c2 = 3 : "@" === e4 ? c2 = 4 : s2.test(e4) || C2();
2749
2751
  }
2750
- function m2(e4) {
2752
+ function g2(e4) {
2751
2753
  "." === e4 || "@" === e4 ? C2() : s2.test(e4) ? c2 = 2 : C2();
2752
2754
  }
2753
- function g2(e4) {
2755
+ function m2(e4) {
2754
2756
  kt.test(e4) ? c2 = 5 : C2();
2755
2757
  }
2756
2758
  function v2(e4) {
@@ -2801,7 +2803,7 @@ var tt, st = function() {
2801
2803
  return !(!e3 || t2 && this.hasFullProtocolRegex.test(t2) || -1 !== e3.indexOf("."));
2802
2804
  }, e2.urlMatchDoesNotHaveAtLeastOneWordChar = function(e3, t2) {
2803
2805
  return !(!e3 || !t2) && (!this.hasFullProtocolRegex.test(t2) && !this.hasWordCharAfterProtocolRegex.test(e3));
2804
- }, e2.hasFullProtocolRegex = /^[A-Za-z][-.+A-Za-z0-9]*:\/\//, e2.uriSchemeRegex = /^[A-Za-z][-.+A-Za-z0-9]*:/, e2.hasWordCharAfterProtocolRegex = new RegExp(":[^\\s]*?[" + mt + "]"), e2.ipRegex = /[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?(:[0-9]*)?\/?$/, e2;
2806
+ }, e2.hasFullProtocolRegex = /^[A-Za-z][-.+A-Za-z0-9]*:\/\//, e2.uriSchemeRegex = /^[A-Za-z][-.+A-Za-z0-9]*:/, e2.hasWordCharAfterProtocolRegex = new RegExp(":[^\\s]*?[" + gt + "]"), e2.ipRegex = /[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?(:[0-9]*)?\/?$/, e2;
2805
2807
  }(), Ft = (tt = new RegExp("[/?#](?:[" + bt + "\\-+&@#/%=~_()|'$*\\[\\]{}?!:,.;^✓]*[" + bt + "\\-+&@#/%=~_()|'$*\\[\\]{}✓])?"), new RegExp(["(?:", "(", /(?:[A-Za-z][-.+A-Za-z0-9]{0,63}:(?![A-Za-z][-.+A-Za-z0-9]{0,63}:\/\/)(?!\d+\/?)(?:\/\/)?)/.source, Et(2), ")", "|", "(", "(//)?", /(?:www\.)/.source, Et(6), ")", "|", "(", "(//)?", Et(10) + "\\.", xt.source, "(?![-" + wt + "])", ")", ")", "(?::[0-9]+)?", "(?:" + tt.source + ")?"].join(""), "gi")), Bt = new RegExp("[" + bt + "]"), Rt = function(e2) {
2806
2808
  function t2(t3) {
2807
2809
  var s2 = e2.call(this, t3) || this;
@@ -2809,14 +2811,14 @@ var tt, st = function() {
2809
2811
  }
2810
2812
  return et(t2, e2), t2.prototype.parseMatches = function(e3) {
2811
2813
  for (var t3, s2 = this.matcherRegex, n2 = this.stripPrefix, r2 = this.stripTrailingSlash, i2 = this.decodePercentEncoding, a2 = this.tagBuilder, o2 = [], u2 = function() {
2812
- var s3 = t3[0], u3 = t3[1], l2 = t3[4], h2 = t3[5], d2 = t3[9], p2 = t3.index, f2 = h2 || d2, m2 = e3.charAt(p2 - 1);
2814
+ var s3 = t3[0], u3 = t3[1], l2 = t3[4], h2 = t3[5], d2 = t3[9], p2 = t3.index, f2 = h2 || d2, g2 = e3.charAt(p2 - 1);
2813
2815
  if (!Mt.isValid(s3, u3)) return "continue";
2814
- if (p2 > 0 && "@" === m2) return "continue";
2815
- if (p2 > 0 && f2 && c2.wordCharRegExp.test(m2)) return "continue";
2816
+ if (p2 > 0 && "@" === g2) return "continue";
2817
+ if (p2 > 0 && f2 && c2.wordCharRegExp.test(g2)) return "continue";
2816
2818
  if (/\?$/.test(s3) && (s3 = s3.substr(0, s3.length - 1)), c2.matchHasUnbalancedClosingParen(s3)) s3 = s3.substr(0, s3.length - 1);
2817
2819
  else {
2818
- var g2 = c2.matchHasInvalidCharAfterTld(s3, u3);
2819
- g2 > -1 && (s3 = s3.substr(0, g2));
2820
+ var m2 = c2.matchHasInvalidCharAfterTld(s3, u3);
2821
+ m2 > -1 && (s3 = s3.substr(0, m2));
2820
2822
  }
2821
2823
  var v2 = ["http://", "https://"].find(function(e4) {
2822
2824
  return !!u3 && -1 !== u3.indexOf(e4);
@@ -2864,7 +2866,7 @@ var tt, st = function() {
2864
2866
  }
2865
2867
  return a2;
2866
2868
  }, t2;
2867
- }(ut), Pt = new RegExp(/(?:(?:(?:(\+)?\d{1,3}[-\040.]?)?\(?\d{3}\)?[-\040.]?\d{3}[-\040.]?\d{4})|(?:(\+)(?:9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)[-\040.]?(?:\d[-\040.]?){6,12}\d+))([,;]+[0-9]+#?)*/.source + "|" + /(0([1-9]{1}-?[1-9]\d{3}|[1-9]{2}-?\d{3}|[1-9]{2}\d{1}-?\d{2}|[1-9]{2}\d{2}-?\d{1})-?\d{4}|0[789]0-?\d{4}-?\d{4}|050-?\d{4}-?\d{4})/.source, "g"), jt = function(e2) {
2869
+ }(ut), Pt = new RegExp(/(?:(?:(?:(\+)?\d{1,3}[-\040.]?)?\(?\d{3}\)?[-\040.]?\d{3}[-\040.]?\d{4})|(?:(\+)(?:9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)[-\040.]?(?:\d[-\040.]?){6,12}\d+))([,;]+[0-9]+#?)*/.source + "|" + /(0([1-9]{1}-?[1-9]\d{3}|[1-9]{2}-?\d{3}|[1-9]{2}\d{1}-?\d{2}|[1-9]{2}\d{2}-?\d{1})-?\d{4}|0[789]0-?\d{4}-?\d{4}|050-?\d{4}-?\d{4})/.source, "g"), Ut = function(e2) {
2868
2870
  function t2() {
2869
2871
  var t3 = null !== e2 && e2.apply(this, arguments) || this;
2870
2872
  return t3.matcherRegex = Pt, t3;
@@ -2878,10 +2880,10 @@ var tt, st = function() {
2878
2880
  }, t2.prototype.testMatch = function(e3) {
2879
2881
  return ht.test(e3);
2880
2882
  }, t2;
2881
- }(ut), Ut = new RegExp("@[_" + bt + "]{1,50}(?![_" + bt + "])", "g"), $t = new RegExp("@[_." + bt + "]{1,30}(?![_" + bt + "])", "g"), Wt = new RegExp("@[-_." + bt + "]{1,50}(?![-_" + bt + "])", "g"), qt = new RegExp("[^" + bt + "]"), Ht = function(e2) {
2883
+ }(ut), jt = new RegExp("@[_" + bt + "]{1,50}(?![_" + bt + "])", "g"), $t = new RegExp("@[_." + bt + "]{1,30}(?![_" + bt + "])", "g"), Wt = new RegExp("@[-_." + bt + "]{1,50}(?![-_" + bt + "])", "g"), qt = new RegExp("[^" + bt + "]"), Ht = function(e2) {
2882
2884
  function t2(t3) {
2883
2885
  var s2 = e2.call(this, t3) || this;
2884
- return s2.serviceName = "twitter", s2.matcherRegexes = { twitter: Ut, instagram: $t, soundcloud: Wt }, s2.nonWordCharRegex = qt, s2.serviceName = t3.serviceName, s2;
2886
+ return s2.serviceName = "twitter", s2.matcherRegexes = { twitter: jt, instagram: $t, soundcloud: Wt }, s2.nonWordCharRegex = qt, s2.serviceName = t3.serviceName, s2;
2885
2887
  }
2886
2888
  return et(t2, e2), t2.prototype.parseMatches = function(e3) {
2887
2889
  var t3, s2 = this.serviceName, n2 = this.matcherRegexes[this.serviceName], r2 = this.nonWordCharRegex, i2 = this.tagBuilder, a2 = [];
@@ -2901,10 +2903,10 @@ function Lt(e2, t2) {
2901
2903
  var f2 = e2.charAt(c2);
2902
2904
  switch (h2) {
2903
2905
  case 0:
2904
- m2(f2);
2906
+ g2(f2);
2905
2907
  break;
2906
2908
  case 1:
2907
- g2(f2);
2909
+ m2(f2);
2908
2910
  break;
2909
2911
  case 2:
2910
2912
  w2(f2);
@@ -2968,26 +2970,26 @@ function Lt(e2, t2) {
2968
2970
  }
2969
2971
  c2++;
2970
2972
  }
2971
- function m2(e3) {
2973
+ function g2(e3) {
2972
2974
  "<" === e3 && P2();
2973
2975
  }
2974
- function g2(e3) {
2976
+ function m2(e3) {
2975
2977
  "!" === e3 ? h2 = 13 : "/" === e3 ? (h2 = 2, p2 = new Gt(st(st({}, p2), { isClosing: true }))) : "<" === e3 ? P2() : ct.test(e3) ? (h2 = 3, p2 = new Gt(st(st({}, p2), { isOpening: true }))) : (h2 = 0, p2 = u2);
2976
2978
  }
2977
2979
  function v2(e3) {
2978
- dt.test(e3) ? (p2 = new Gt(st(st({}, p2), { name: U2() })), h2 = 4) : "<" === e3 ? P2() : "/" === e3 ? (p2 = new Gt(st(st({}, p2), { name: U2() })), h2 = 12) : ">" === e3 ? (p2 = new Gt(st(st({}, p2), { name: U2() })), j2()) : ct.test(e3) || lt.test(e3) || ":" === e3 || O2();
2980
+ dt.test(e3) ? (p2 = new Gt(st(st({}, p2), { name: j2() })), h2 = 4) : "<" === e3 ? P2() : "/" === e3 ? (p2 = new Gt(st(st({}, p2), { name: j2() })), h2 = 12) : ">" === e3 ? (p2 = new Gt(st(st({}, p2), { name: j2() })), U2()) : ct.test(e3) || lt.test(e3) || ":" === e3 || O2();
2979
2981
  }
2980
2982
  function w2(e3) {
2981
2983
  ">" === e3 ? O2() : ct.test(e3) ? h2 = 3 : O2();
2982
2984
  }
2983
2985
  function b2(e3) {
2984
- dt.test(e3) || ("/" === e3 ? h2 = 12 : ">" === e3 ? j2() : "<" === e3 ? P2() : "=" === e3 || pt.test(e3) || ft.test(e3) ? O2() : h2 = 5);
2986
+ dt.test(e3) || ("/" === e3 ? h2 = 12 : ">" === e3 ? U2() : "<" === e3 ? P2() : "=" === e3 || pt.test(e3) || ft.test(e3) ? O2() : h2 = 5);
2985
2987
  }
2986
2988
  function y2(e3) {
2987
- dt.test(e3) ? h2 = 6 : "/" === e3 ? h2 = 12 : "=" === e3 ? h2 = 7 : ">" === e3 ? j2() : "<" === e3 ? P2() : pt.test(e3) && O2();
2989
+ dt.test(e3) ? h2 = 6 : "/" === e3 ? h2 = 12 : "=" === e3 ? h2 = 7 : ">" === e3 ? U2() : "<" === e3 ? P2() : pt.test(e3) && O2();
2988
2990
  }
2989
2991
  function C2(e3) {
2990
- dt.test(e3) || ("/" === e3 ? h2 = 12 : "=" === e3 ? h2 = 7 : ">" === e3 ? j2() : "<" === e3 ? P2() : pt.test(e3) ? O2() : h2 = 5);
2992
+ dt.test(e3) || ("/" === e3 ? h2 = 12 : "=" === e3 ? h2 = 7 : ">" === e3 ? U2() : "<" === e3 ? P2() : pt.test(e3) ? O2() : h2 = 5);
2991
2993
  }
2992
2994
  function A2(e3) {
2993
2995
  dt.test(e3) || ('"' === e3 ? h2 = 8 : "'" === e3 ? h2 = 9 : /[>=`]/.test(e3) ? O2() : "<" === e3 ? P2() : h2 = 10);
@@ -2999,13 +3001,13 @@ function Lt(e2, t2) {
2999
3001
  "'" === e3 && (h2 = 11);
3000
3002
  }
3001
3003
  function x2(e3) {
3002
- dt.test(e3) ? h2 = 4 : ">" === e3 ? j2() : "<" === e3 && P2();
3004
+ dt.test(e3) ? h2 = 4 : ">" === e3 ? U2() : "<" === e3 && P2();
3003
3005
  }
3004
3006
  function T2(e3) {
3005
- dt.test(e3) ? h2 = 4 : "/" === e3 ? h2 = 12 : ">" === e3 ? j2() : "<" === e3 ? P2() : (h2 = 4, c2--);
3007
+ dt.test(e3) ? h2 = 4 : "/" === e3 ? h2 = 12 : ">" === e3 ? U2() : "<" === e3 ? P2() : (h2 = 4, c2--);
3006
3008
  }
3007
3009
  function I2(e3) {
3008
- ">" === e3 ? (p2 = new Gt(st(st({}, p2), { isClosing: true })), j2()) : h2 = 4;
3010
+ ">" === e3 ? (p2 = new Gt(st(st({}, p2), { isClosing: true })), U2()) : h2 = 4;
3009
3011
  }
3010
3012
  function D2(t3) {
3011
3013
  "--" === e2.substr(c2, 2) ? (c2 += 2, p2 = new Gt(st(st({}, p2), { type: "comment" })), h2 = 14) : "DOCTYPE" === e2.substr(c2, 7).toUpperCase() ? (c2 += 7, p2 = new Gt(st(st({}, p2), { type: "doctype" })), h2 = 20) : O2();
@@ -3023,13 +3025,13 @@ function Lt(e2, t2) {
3023
3025
  h2 = "-" === e3 ? 18 : 16;
3024
3026
  }
3025
3027
  function R2(e3) {
3026
- ">" === e3 ? j2() : "!" === e3 ? h2 = 19 : "-" === e3 || (h2 = 16);
3028
+ ">" === e3 ? U2() : "!" === e3 ? h2 = 19 : "-" === e3 || (h2 = 16);
3027
3029
  }
3028
3030
  function N2(e3) {
3029
- "-" === e3 ? h2 = 17 : ">" === e3 ? j2() : h2 = 16;
3031
+ "-" === e3 ? h2 = 17 : ">" === e3 ? U2() : h2 = 16;
3030
3032
  }
3031
3033
  function _2(e3) {
3032
- ">" === e3 ? j2() : "<" === e3 && P2();
3034
+ ">" === e3 ? U2() : "<" === e3 && P2();
3033
3035
  }
3034
3036
  function O2() {
3035
3037
  h2 = 0, p2 = u2;
@@ -3037,11 +3039,11 @@ function Lt(e2, t2) {
3037
3039
  function P2() {
3038
3040
  h2 = 1, p2 = new Gt({ idx: c2 });
3039
3041
  }
3040
- function j2() {
3042
+ function U2() {
3041
3043
  var t3 = e2.slice(d2, p2.idx);
3042
3044
  t3 && i2(t3, d2), "comment" === p2.type ? a2(p2.idx) : "doctype" === p2.type ? o2(p2.idx) : (p2.isOpening && n2(p2.name, p2.idx), p2.isClosing && r2(p2.name, p2.idx)), O2(), d2 = c2 + 1;
3043
3045
  }
3044
- function U2() {
3046
+ function j2() {
3045
3047
  var t3 = p2.idx + (p2.isClosing ? 2 : 1);
3046
3048
  return e2.slice(t3, c2).toLowerCase();
3047
3049
  }
@@ -3147,28 +3149,28 @@ var Gt = function(e2) {
3147
3149
  return this.replaceFn && (t2 = this.replaceFn.call(this.context, e3)), "string" == typeof t2 ? t2 : false === t2 ? e3.getMatchedText() : t2 instanceof Ve ? t2.toAnchorString() : e3.buildTag().toAnchorString();
3148
3150
  }, e2.prototype.getMatchers = function() {
3149
3151
  if (this.matchers) return this.matchers;
3150
- var e3 = this.getTagBuilder(), t2 = [new Ot({ tagBuilder: e3, serviceName: this.hashtag }), new Dt({ tagBuilder: e3 }), new jt({ tagBuilder: e3 }), new Ht({ tagBuilder: e3, serviceName: this.mention }), new Rt({ tagBuilder: e3, stripPrefix: this.stripPrefix, stripTrailingSlash: this.stripTrailingSlash, decodePercentEncoding: this.decodePercentEncoding })];
3152
+ var e3 = this.getTagBuilder(), t2 = [new Ot({ tagBuilder: e3, serviceName: this.hashtag }), new Dt({ tagBuilder: e3 }), new Ut({ tagBuilder: e3 }), new Ht({ tagBuilder: e3, serviceName: this.mention }), new Rt({ tagBuilder: e3, stripPrefix: this.stripPrefix, stripTrailingSlash: this.stripTrailingSlash, decodePercentEncoding: this.decodePercentEncoding })];
3151
3153
  return this.matchers = t2;
3152
3154
  }, e2.prototype.getTagBuilder = function() {
3153
3155
  var e3 = this.tagBuilder;
3154
3156
  return e3 || (e3 = this.tagBuilder = new Ze({ newWindow: this.newWindow, truncate: this.truncate, className: this.className })), e3;
3155
- }, e2.version = "3.14.3", e2.AnchorTagBuilder = Ze, e2.HtmlTag = Ve, e2.matcher = { Email: Dt, Hashtag: Ot, Matcher: ut, Mention: Ht, Phone: jt, Url: Rt }, e2.match = { Email: nt, Hashtag: rt, Match: Ke, Mention: it, Phone: at, Url: ot }, e2;
3157
+ }, e2.version = "3.14.3", e2.AnchorTagBuilder = Ze, e2.HtmlTag = Ve, e2.matcher = { Email: Dt, Hashtag: Ot, Matcher: ut, Mention: Ht, Phone: Ut, Url: Rt }, e2.match = { Email: nt, Hashtag: rt, Match: Ke, Mention: it, Phone: at, Url: ot }, e2;
3156
3158
  }();
3157
3159
  function Jt(e2, t2 = e2) {
3158
3160
  return { type: "autolink", url: e2, text: t2 };
3159
3161
  }
3160
- const Yt = Ue(/<!!mention:([^>\s]*?)\|(.*?)>/gm, ([e2, t2, s2]) => /* @__PURE__ */ function(e3, t3) {
3162
+ const Yt = je(/<!!mention:([^>\s]*?)\|(.*?)>/gm, ([e2, t2, s2]) => /* @__PURE__ */ function(e3, t3) {
3161
3163
  return { type: "mention", id: e3, text: t3 };
3162
- }(decodeURIComponent(t2), s2)), Qt = Ue(/<!!customemoji:(.*?)>/gm, ([e2, t2]) => /* @__PURE__ */ function(e3) {
3164
+ }(decodeURIComponent(t2), s2)), Qt = je(/<!!customemoji:(.*?)>/gm, ([e2, t2]) => /* @__PURE__ */ function(e3) {
3163
3165
  return { type: "customemoji", text: e3 };
3164
- }(t2)), Vt = Ue(/<((?:https?|mailto):.*?)\|(.*?)>/gi, ([e2, t2, s2]) => /* @__PURE__ */ function(e3, t3 = []) {
3166
+ }(t2)), Vt = je(/<((?:https?|mailto):.*?)\|(.*?)>/gi, ([e2, t2, s2]) => /* @__PURE__ */ function(e3, t3 = []) {
3165
3167
  return { type: "link", url: e3, children: t3 };
3166
- }(t2, [s2])), Zt = Ue(/<actionlink:([^|]+)[|]([^>]*)>/gi, ([e2, t2, s2]) => {
3168
+ }(t2, [s2])), Zt = je(/<actionlink:([^|]+)[|]([^>]*)>/gi, ([e2, t2, s2]) => {
3167
3169
  const { action: n2, params: r2 } = Xt(t2);
3168
3170
  return /* @__PURE__ */ function(e3, t3, s3 = []) {
3169
3171
  return { type: "actionlink", action: e3, params: t3, children: s3 };
3170
3172
  }(n2, r2, [s2]);
3171
- }), Kt = Ue(/<actionbutton:([^|]+)[|]([^>]*)>/gi, ([e2, t2, s2]) => {
3173
+ }), Kt = je(/<actionbutton:([^|]+)[|]([^>]*)>/gi, ([e2, t2, s2]) => {
3172
3174
  const { action: n2, params: r2 } = Xt(t2);
3173
3175
  return /* @__PURE__ */ function(e3, t3, s3 = []) {
3174
3176
  return { type: "actionbutton", action: e3, params: t3, children: s3 };
@@ -3179,9 +3181,9 @@ function Xt(e2) {
3179
3181
  if (-1 === t2) return { action: e2, params: {} };
3180
3182
  return { action: e2.slice(0, t2), params: Object.fromEntries(new URLSearchParams(e2.slice(t2))) };
3181
3183
  }
3182
- const es = Ue(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g, ([e2]) => /* @__PURE__ */ function(e3 = []) {
3184
+ const es = je(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g, ([e2]) => /* @__PURE__ */ function(e3 = []) {
3183
3185
  return { type: "bulletlist", children: e3 };
3184
- }([e2.startsWith("\n") ? e2.slice(1) : e2])), ts = Ue(/^\s*[-*+]\s+([^\n]+)(?:\n|$)/gm, ([e2, t2]) => ({ type: "bulletpoint", children: [t2] })), ss = (e2) => {
3186
+ }([e2.startsWith("\n") ? e2.slice(1) : e2])), ts = je(/^\s*[-*+]\s+([^\n]+)(?:\n|$)/gm, ([e2, t2]) => ({ type: "bulletpoint", children: [t2] })), ss = (e2) => {
3185
3187
  const t2 = /(?:^|[^-:/\w])([(+]?[0-9](?:[-_+ ().]?[0-9]){5,11}[0-9])(?:[^-:/\w]|$)/g;
3186
3188
  let s2 = 0;
3187
3189
  const n2 = [];
@@ -3205,7 +3207,7 @@ const es = Ue(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g, ([e2]) => /* @__PURE__
3205
3207
  function as(e2 = { except: [] }) {
3206
3208
  var _a2;
3207
3209
  const t2 = { multilineSteps: [], singlelineSteps: [] }, s2 = (_a2 = e2.except) != null ? _a2 : is.filter((t3) => !e2.only.includes(t3));
3208
- return s2.includes("BulletPoint") || t2.multilineSteps.push(es, ts), s2.includes("Mention") || t2.singlelineSteps.push(Yt), s2.includes("CustomEmoji") || t2.singlelineSteps.push(Qt), s2.includes("Codespan") || t2.multilineSteps.push(Ue(/```([^]+?)```/g, ([e3, t3]) => ({ type: "codespan", text: t3.replace(/<!!mention:.*?\|([^>]*)>/gim, "@$1").replace(/<!!customemoji:(.*?)>/gim, "$1") }))), s2.includes("FormattedLink") || t2.singlelineSteps.push(Vt), s2.includes("Actions") || (t2.singlelineSteps.push(Zt), t2.singlelineSteps.push(Kt)), s2.includes("Wikitext") || t2.singlelineSteps.push(Le), s2.includes("Autolink") || t2.singlelineSteps.push(ns, ss), t2;
3210
+ return s2.includes("BulletPoint") || t2.multilineSteps.push(es, ts), s2.includes("Mention") || t2.singlelineSteps.push(Yt), s2.includes("CustomEmoji") || t2.singlelineSteps.push(Qt), s2.includes("Codespan") || t2.multilineSteps.push(je(/```([^]+?)```/g, ([e3, t3]) => ({ type: "codespan", text: t3.replace(/<!!mention:.*?\|([^>]*)>/gim, "@$1").replace(/<!!customemoji:(.*?)>/gim, "$1") }))), s2.includes("FormattedLink") || t2.singlelineSteps.push(Vt), s2.includes("Actions") || (t2.singlelineSteps.push(Zt), t2.singlelineSteps.push(Kt)), s2.includes("Wikitext") || t2.singlelineSteps.push(Le), s2.includes("Autolink") || t2.singlelineSteps.push(ns, ss), t2;
3209
3211
  }
3210
3212
  const os = function(e2) {
3211
3213
  const t2 = RegExp(`[^${e2}]+${e2}?|${e2}`, "g");
@@ -3222,7 +3224,7 @@ function cs(e2) {
3222
3224
  return us(e2, { except: ["FormattedLink", "Actions"] });
3223
3225
  }
3224
3226
  function ls(e2, t2) {
3225
- return t2.reduce((e3, t3) => je(e3, t3), e2);
3227
+ return t2.reduce((e3, t3) => Ue(e3, t3), e2);
3226
3228
  }
3227
3229
  function hs(e2) {
3228
3230
  const t2 = [];
@@ -3293,7 +3295,7 @@ class fs {
3293
3295
  }
3294
3296
  edit(t2) {
3295
3297
  return __async(this, null, function* () {
3296
- const s2 = { content: ms(t2), custom: "string" == typeof t2 ? void 0 : t2.custom }, n2 = yield this._realtimeClient.call("PATCH", ["conversations", this.brandedConversationId, "messages", this.brandedId], s2);
3298
+ const s2 = { content: gs(t2), custom: "string" == typeof t2 ? void 0 : t2.custom }, n2 = yield this._realtimeClient.call("PATCH", ["conversations", this.brandedConversationId, "messages", this.brandedId], s2);
3297
3299
  e(`Edit message ${this.id} in conversation ${this.conversationId}`, n2);
3298
3300
  });
3299
3301
  }
@@ -3304,7 +3306,7 @@ class fs {
3304
3306
  });
3305
3307
  }
3306
3308
  }
3307
- function ms(e2) {
3309
+ function gs(e2) {
3308
3310
  if ("string" == typeof e2) {
3309
3311
  return [{ type: "text", children: us(e2) }];
3310
3312
  }
@@ -3313,7 +3315,7 @@ function ms(e2) {
3313
3315
  }
3314
3316
  if ("content" in e2 && e2.content) return e2.content;
3315
3317
  }
3316
- class gs {
3318
+ class ms {
3317
3319
  constructor(e2, t2) {
3318
3320
  this.id = e2, this._realtimeClient = t2, this.uselessObjForTypeCheck = { subject: null, photoUrl: null, welcomeMessages: null, custom: null, access: null, notify: null };
3319
3321
  }
@@ -3455,7 +3457,7 @@ class bs {
3455
3457
  function ys({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRetry: i2, authProvider: o2, errorTracker: u2 }) {
3456
3458
  var _a2;
3457
3459
  (!r2 || r2 <= 0) && (r2 = 1);
3458
- const c2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-11-04T15:29:42.017Z" };
3460
+ const c2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-12-05T12:12:52.344Z" };
3459
3461
  s2 instanceof FormData || (c2["Content-Type"] = (_a2 = n2 == null ? void 0 : n2.contentType) != null ? _a2 : "application/json");
3460
3462
  return a(r2, () => __async(this, null, function* () {
3461
3463
  if (o2) {
@@ -3467,7 +3469,7 @@ function ys({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRe
3467
3469
  throw e3;
3468
3470
  });
3469
3471
  }), { initialDelay: 0.2, log: void 0, shouldRetry: (s3) => __async(this, null, function* () {
3470
- return o2 && 401 === s3.status ? (u2 == null ? void 0 : u2.log(`401 error from ${e2} ${t2}, ${yield o2.getToken()}`), o2.refreshToken(), true) : i2 ? i2(s3) : !("status" in s3 && s3.status >= 400 && s3.status < 500);
3472
+ return o2 && 401 === s3.status ? (u2 == null ? void 0 : u2.log(`401 error from ${e2} ${t2}, ${yield o2.getToken()}`), o2.invalidateAndRefresh(), true) : i2 ? i2(s3) : !("status" in s3 && s3.status >= 400 && s3.status < 500);
3471
3473
  }) }).catch((s3) => {
3472
3474
  if (Math.random() < 0.1 && !t2.toString().startsWith("https://capture.trackjs.com")) {
3473
3475
  const n3 = `Network Error for ${e2} ${t2}`;
@@ -3484,7 +3486,7 @@ class Cs {
3484
3486
  __privateAdd(this, _e2);
3485
3487
  __privateAdd(this, _t2);
3486
3488
  var _a2, _b, _c, _d;
3487
- this._timeCreated = Date.now(), __privateSet(this, _e2, (_b = (_a2 = globalThis.document) == null ? void 0 : _a2.referrer) != null ? _b : ""), __privateSet(this, _t2, ((_d = (_c = globalThis.location) == null ? void 0 : _c.href) != null ? _d : globalThis.HermesInternal) ? "React Native Hermes" : ""), this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-11-04T15:29:42.017Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: __privateGet(this, _t2), referrer: __privateGet(this, _e2), userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: __privateGet(this, _t2), stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2025-11-04T15:29:42.017Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
3489
+ this._timeCreated = Date.now(), __privateSet(this, _e2, (_b = (_a2 = globalThis.document) == null ? void 0 : _a2.referrer) != null ? _b : ""), __privateSet(this, _t2, ((_d = (_c = globalThis.location) == null ? void 0 : _c.href) != null ? _d : globalThis.HermesInternal) ? "React Native Hermes" : ""), this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-12-05T12:12:52.344Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: __privateGet(this, _t2), referrer: __privateGet(this, _e2), userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: __privateGet(this, _t2), stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2025-12-05T12:12:52.344Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
3488
3490
  }
3489
3491
  setData({ appId: e2, meId: t2, sessionId: s2 }) {
3490
3492
  this._trackJSData.customer.userId = e2, this._trackJSData.customer.sessionId = `${e2}/${t2}`, this._trackJSData.customer.correlationId = s2;
@@ -3551,42 +3553,82 @@ class Es {
3551
3553
  }
3552
3554
  }
3553
3555
  class ks {
3554
- constructor(e2, t2, s2, n2, r2, i2) {
3555
- this.appId = t2, this.userId = s2, this.tokenFetcher = r2, this.usingBokens = false, this.requestInProgress = false, this.eventEmitter = new Es({ tokenChanged(e3) {
3556
+ constructor(e2) {
3557
+ this.handlers = e2, this.tokenResult = null, this.pendingToken = null;
3558
+ }
3559
+ getTokenResult() {
3560
+ return __async(this, null, function* () {
3561
+ if (this.tokenResult) return this.tokenResult;
3562
+ if (this.pendingToken) return this.pendingToken.promise;
3563
+ const e2 = o();
3564
+ return this.pendingToken = e2, this.handlers.onNeedToken(), e2.promise;
3565
+ });
3566
+ }
3567
+ setTokenResult(e2) {
3568
+ this.pendingToken && (this.pendingToken.resolve(e2), this.pendingToken = null), this.tokenResult = e2, this.handlers.onChange(e2);
3569
+ }
3570
+ refreshToken() {
3571
+ this.pendingToken || (this.pendingToken = o(), this.handlers.onNeedToken());
3572
+ }
3573
+ invalidateAndRefresh() {
3574
+ this.tokenResult = null, this.refreshToken();
3575
+ }
3576
+ }
3577
+ class xs {
3578
+ constructor(e2, t2, s2, n2) {
3579
+ this.apiUrls = e2, this.appId = t2, this.userId = s2, this.signature = n2, this.inner = new ks({ onChange: (e3) => {
3580
+ e3.ok ? this.eventEmitter.emit("tokenChanged", e3.value) : this.emitTokenRefreshFailed(e3.value);
3581
+ }, onNeedToken: () => __async(this, null, function* () {
3582
+ if (this._usingBokens) yield this.sendBokenRequest().then((e3) => this.inner.setTokenResult(c(e3))).catch((e3) => this.inner.setTokenResult(h(e3)));
3583
+ else if (this.onNeedToken) this.onNeedToken();
3584
+ else {
3585
+ const e3 = l("Cannot refresh token, no `onNeedToken` provided.");
3586
+ this.inner.setTokenResult(e3);
3587
+ }
3588
+ }) }), this._usingBokens = true, this.onNeedToken = void 0, this.eventEmitter = new Es({ tokenChanged(e3) {
3556
3589
  }, tokenRefreshFailed(e3) {
3557
3590
  }, tokenAccepted(e3) {
3558
3591
  } }), this.sessionExpiryWarningTimeoutId = void 0;
3559
- const a2 = "undefined" != typeof window && e2.restApiHttpUrl.includes("api.talkjs.com");
3560
- if (this.errorTracker = a2 ? new Cs("970cd0be0fb74630b75c8451051299dc") : As, i2 && (n2 || r2)) throw new Error("[TalkJS] If providing a signature for authentication, you must not provide a token or tokenFetcher.");
3561
- n2 ? this.fetchToken(() => n2) : (r2 || (this.usingBokens = true, this.tokenFetcher = () => this.sendBokenRequest(e2, i2)), this.refreshToken());
3592
+ const r2 = "undefined" != typeof window && e2.restApiHttpUrl.includes("api.talkjs.com");
3593
+ this.errorTracker = r2 ? new Cs("970cd0be0fb74630b75c8451051299dc") : As;
3562
3594
  }
3563
- get canRefreshToken() {
3564
- return this.usingBokens || !!this.tokenFetcher;
3595
+ get usingBokens() {
3596
+ return this._usingBokens;
3565
3597
  }
3566
3598
  getToken() {
3567
- return this.token;
3599
+ return __async(this, null, function* () {
3600
+ const e2 = yield this.inner.getTokenResult();
3601
+ if (e2.ok) return e2.value;
3602
+ throw e2.value;
3603
+ });
3604
+ }
3605
+ setToken(e2) {
3606
+ setTimeout(() => this.checkJwt(e2), 200), this._usingBokens = false, this.inner.setTokenResult(c(e2));
3607
+ }
3608
+ setTokenError(e2) {
3609
+ this._usingBokens = false, this.inner.setTokenResult(l(e2));
3568
3610
  }
3569
3611
  refreshToken() {
3570
- if (!this.requestInProgress) {
3571
- if (!this.tokenFetcher) throw this.emitTokenRefreshFailed("no `tokenFetcher` provided"), new Error("[TalkJS] Cannot refresh token, no `tokenFetcher` provided.");
3572
- this.fetchToken(this.tokenFetcher);
3573
- }
3612
+ this.inner.refreshToken();
3613
+ }
3614
+ invalidateAndRefresh() {
3615
+ this.inner.invalidateAndRefresh();
3616
+ }
3617
+ setOnNeedToken(e2) {
3618
+ this._usingBokens = false, this.onNeedToken = e2;
3574
3619
  }
3575
3620
  onTokenChanged(e2) {
3576
3621
  return this.eventEmitter.on("tokenChanged", e2), () => {
3577
3622
  this.eventEmitter.off("tokenChanged", e2);
3578
3623
  };
3579
3624
  }
3580
- emitTokenChanged(e2) {
3581
- this.eventEmitter.emit("tokenChanged", e2);
3582
- }
3583
3625
  onTokenRefreshFailed(e2) {
3584
3626
  return this.eventEmitter.on("tokenRefreshFailed", e2), () => {
3585
3627
  this.eventEmitter.off("tokenRefreshFailed", e2);
3586
3628
  };
3587
3629
  }
3588
3630
  emitTokenRefreshFailed(e2) {
3589
- this.eventEmitter.emit("tokenRefreshFailed", e2), console.error(`[TalkJS] Could not authenticate, cannot recover automatically: ${e2}`);
3631
+ this.eventEmitter.emit("tokenRefreshFailed", e2);
3590
3632
  }
3591
3633
  onTokenAccepted(e2) {
3592
3634
  return this.eventEmitter.on("tokenAccepted", e2), () => {
@@ -3601,38 +3643,12 @@ class ks {
3601
3643
  }
3602
3644
  scheduleRefresh(e2) {
3603
3645
  if (this.clearScheduledRefresh(), null === e2) return;
3604
- const t2 = void 0 !== this.tokenFetcher;
3605
- e2 < 120 && !t2 ? console.warn(`[TalkJS] TalkJS will stop working in ${e2} seconds due to auth token expiry. Token expires in ${e2} seconds, and cannot be refreshed because no \`tokenFetcher\` was provided when creating the session. Non-refreshable tokens are recommended to expire at least 24 hours in the future.`) : e2 < 120 && t2 ? console.warn(`[TalkJS] TalkJS auth token will expire and need to be refreshed in ${e2} seconds. Refreshable JWTs are recommended to expire at least 30 minutes in the future, to improve performance and reduce unnecessary refreshes.`) : e2 < 3300 && !t2 && console.warn(`[TalkJS debug] TalkJS will stop working in ${Math.round(e2 / 60)} minutes due to auth token expiry. Non-refreshable tokens are recommended to expire at least 24 hours in the future. Alternatively, provide a \`tokenFetcher\` when creating the session, so that tokens can be refreshed when they expire.`);
3606
- if (void 0 !== this.tokenFetcher) {
3607
- const t3 = e2 > 600 ? e2 - 300 : e2 / 2, s2 = Math.min(1728e6, 1e3 * t3);
3608
- this.sessionExpiryWarningTimeoutId = setTimeout(() => {
3609
- this.refreshToken();
3610
- }, s2);
3611
- } else e2 < 2e6 && (this.sessionExpiryWarningTimeoutId = setTimeout(() => {
3612
- this.emitTokenRefreshFailed("Token has expired and no `tokenFetcher` was provided when creating the session, so it cannot be refreshed.");
3613
- }, 1e3 * e2));
3614
- }
3615
- fetchToken(e2) {
3616
- return __async(this, null, function* () {
3617
- if (this.requestInProgress) return;
3618
- this.requestInProgress = true;
3619
- const t2 = () => __async(this, null, function* () {
3620
- const t3 = yield e2();
3621
- return this.checkJwt(t3), t3;
3622
- });
3623
- try {
3624
- const e3 = void 0 !== this.token;
3625
- this.token = t2(), yield this.token.then((t3) => {
3626
- e3 && this.emitTokenChanged(t3);
3627
- }).catch((e4) => {
3628
- this.emitTokenRefreshFailed(e4);
3629
- });
3630
- } catch (e3) {
3631
- this.emitTokenRefreshFailed(e3);
3632
- } finally {
3633
- this.requestInProgress = false;
3634
- }
3635
- });
3646
+ const t2 = void 0 !== this.onNeedToken;
3647
+ e2 < 120 && !t2 ? console.warn(`[TalkJS] TalkJS will stop working in ${e2} seconds due to auth token expiry. Token expires in ${e2} seconds, and cannot be refreshed because no \`onNeedToken\` callback was provided. Non-refreshable tokens are recommended to expire at least 24 hours in the future.`) : e2 < 120 && t2 ? console.warn(`[TalkJS] TalkJS auth token will expire and need to be refreshed in ${e2} seconds. Refreshable JWTs are recommended to expire at least 30 minutes in the future, to improve performance and reduce unnecessary refreshes.`) : e2 < 3300 && !t2 && console.warn(`[TalkJS debug] TalkJS will stop working in ${Math.round(e2 / 60)} minutes due to auth token expiry. Non-refreshable tokens are recommended to expire at least 24 hours in the future. Alternatively, set \`onNeedToken\` with a callback that will run whenever a new token is needed.`);
3648
+ const s2 = e2 > 600 ? e2 - 300 : e2 / 2, n2 = Math.min(1728e6, 1e3 * s2);
3649
+ this.sessionExpiryWarningTimeoutId = setTimeout(() => {
3650
+ void 0 !== this.onNeedToken && this.refreshToken();
3651
+ }, n2);
3636
3652
  }
3637
3653
  checkJwt(e2) {
3638
3654
  !function(e3) {
@@ -3646,7 +3662,7 @@ class ks {
3646
3662
  const e3 = function(e4) {
3647
3663
  const t3 = e4.split(".");
3648
3664
  if (3 !== t3.length) throw "Token does not contain exactly two `.`. Check that you generated your JWT correctly. It should be `<header>.<payload>.<signature>`.";
3649
- return { header: xs(t3[0]), payload: xs(t3[1]) };
3665
+ return { header: Ts(t3[0]), payload: Ts(t3[1]) };
3650
3666
  }(s2);
3651
3667
  n2 = e3.header, r2 = e3.payload;
3652
3668
  } catch (e3) {
@@ -3686,23 +3702,23 @@ class ks {
3686
3702
  const a2 = e2.nbf;
3687
3703
  return void 0 === a2 || ("number" != typeof a2 ? t2.push(`Token payload contains a \`nbf\` (not-before) claim, but \`nbf\` was ${typeof r2} instead of a number. If set, \`nbf\` should be the date when the JWT becomes valid, as a number of seconds since 1970-01-01.`) : a2 > 1e11 && t2.push(`Token payload contains a \`nbf\` (not-before) claim, but \`nbf\` is very large (${a2}, representing ${new Date(1e3 * a2).toLocaleDateString()}). If set, \`nbf\` should be the date when the JWT becomes valid, as a number of seconds since 1970-01-01. Double-check that you are using seconds and not milliseconds or nanoseconds.`)), t2;
3688
3704
  }
3689
- sendBokenRequest(e2, t2) {
3705
+ sendBokenRequest() {
3690
3706
  return __async(this, null, function* () {
3691
- let s2 = 0;
3692
- const n2 = e2.getBokensUrl(this.appId, this.userId, t2), r2 = yield ys({ method: "GET", url: n2, attempts: 1e4, shouldRetry: (e3) => {
3693
- if (e3 instanceof Error) return true;
3694
- if (401 === e3.status) throw "Check that you provided a valid signature.";
3695
- if (404 === e3.status) throw "Check that you specified the correct App ID.";
3696
- if (429 === e3.status || 502 === e3.status) return true;
3697
- if (e3.status >= 400 && e3.status < 500) throw `Unexpected HTTP ${e3.status} response when fetching auth token. Check that you configured the session correctly.`;
3698
- if (s2++, s2 >= 5) throw `Unexpected HTTP ${e3.status} response when fetching auth token, retrying did not help.`;
3707
+ let e2 = 0;
3708
+ const t2 = this.apiUrls.getBokensUrl(this.appId, this.userId, this.signature), s2 = yield ys({ method: "GET", url: t2, attempts: 1e4, shouldRetry: (t3) => {
3709
+ if (t3 instanceof Error) return true;
3710
+ if (401 === t3.status) throw "Check that you provided a valid signature.";
3711
+ if (404 === t3.status) throw "Check that you specified the correct App ID.";
3712
+ if (429 === t3.status || 502 === t3.status) return true;
3713
+ if (t3.status >= 400 && t3.status < 500) throw `Unexpected HTTP ${t3.status} response when fetching auth token. Check that you configured the session correctly.`;
3714
+ if (e2++, e2 >= 5) throw `Unexpected HTTP ${t3.status} response when fetching auth token, retrying did not help.`;
3699
3715
  return true;
3700
3716
  }, errorTracker: this.errorTracker });
3701
- return (yield r2.json()).boken;
3717
+ return (yield s2.json()).boken;
3702
3718
  });
3703
3719
  }
3704
3720
  }
3705
- function xs(e2) {
3721
+ function Ts(e2) {
3706
3722
  try {
3707
3723
  const t2 = e2.replace(/-/g, "+").replace(/_/g, "/"), s2 = decodeURIComponent(atob(t2).split("").map((e3) => "%" + ("00" + e3.charCodeAt(0).toString(16)).slice(-2)).join(""));
3708
3724
  return JSON.parse(s2);
@@ -3710,24 +3726,15 @@ function xs(e2) {
3710
3726
  throw `Could not base64-decode and JSON-parse token section: ${e2}. Check that you base-64 encoded the section correctly.`;
3711
3727
  }
3712
3728
  }
3713
- class Ts {
3714
- constructor(e2) {
3715
- this.target = e2;
3716
- }
3717
- deref() {
3718
- return this.target;
3719
- }
3720
- }
3721
3729
  const Is = new class {
3722
3730
  constructor() {
3723
3731
  this.registry = {};
3724
3732
  }
3725
3733
  getOrCreate(e2) {
3726
- var _a2;
3727
- const t2 = this.key(e2), s2 = (_a2 = this.registry[t2]) == null ? void 0 : _a2.deref();
3734
+ const t2 = this.key(e2), s2 = this.registry[t2];
3728
3735
  if (s2) return s2;
3729
- const n2 = new Ss(e2), r2 = globalThis.WeakRef ? new WeakRef(n2) : new Ts(n2);
3730
- return this.registry[t2] = r2, n2;
3736
+ const n2 = new Ss(e2);
3737
+ return this.registry[t2] = n2, n2;
3731
3738
  }
3732
3739
  deregister(e2, t2) {
3733
3740
  const s2 = this.key({ appId: e2, userId: t2 });
@@ -3743,21 +3750,30 @@ function Ds(e2) {
3743
3750
  }
3744
3751
  class Ss {
3745
3752
  constructor(e2) {
3746
- !function(e3) {
3753
+ this._onNeedToken = void 0, function(e3) {
3747
3754
  function t3(e4, t4) {
3748
3755
  if (!e4) throw new Error("[TalkJS] TalkSession: " + t4);
3749
3756
  }
3750
- t3(e3 && "object" == typeof e3, "Expected an object argument in TalkSession#constructor."), t3(e3.appId && "string" == typeof e3.appId, "The `appId` property of TalkSession#constructor is required and it must be a non-empty string."), t3("string" == typeof e3.userId, "The `userId` property of TalkSession#constructor is required and it must be a string."), void 0 !== e3.token && t3(e3.token && "string" == typeof e3.token, "The `token` property of TalkSession#constructor must be a non-empty string.");
3751
- void 0 !== e3.tokenFetcher && t3("function" == typeof e3.tokenFetcher, "The `tokenFetcher` property of TalkSession#constructor must be a function.");
3757
+ t3(e3 && "object" == typeof e3, "Expected an object argument in `getTalkSession`."), t3(e3.appId && "string" == typeof e3.appId, "The `appId` property of the `getTalkSession` options is required and it must be a non-empty string."), t3("string" == typeof e3.userId, "The `userId` property of the `getTalkSession` options is required and it must be a string."), void 0 !== e3.token && t3(e3.token && "string" == typeof e3.token, "The `token` property of the `getTalkSession` options must be a non-empty string.");
3758
+ void 0 !== e3.tokenFetcher && t3("function" == typeof e3.tokenFetcher, "The `tokenFetcher` property of the `getTalkSession` options must be a function.");
3752
3759
  }(e2);
3753
3760
  const { appId: t2, userId: s2, token: n2, tokenFetcher: r2, signature: i2 } = e2;
3754
- this._appId = t2, this._apiUrls = e2.apiUrls ? new bs(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) : bs.fromHost(e2.host), this._authProvider = new ks(this._apiUrls, t2, s2, n2, r2, i2);
3761
+ this._appId = t2, this._apiUrls = e2.apiUrls ? new bs(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) : bs.fromHost(e2.host), this._authProvider = new xs(this._apiUrls, t2, s2, i2), n2 && this._authProvider.setToken(n2), r2 && this._authProvider.setOnNeedToken(() => __async(this, null, function* () {
3762
+ try {
3763
+ const e3 = yield r2();
3764
+ this._authProvider.setToken(e3);
3765
+ } catch (e3) {
3766
+ this._authProvider.setTokenError(`${e3}`);
3767
+ }
3768
+ }));
3755
3769
  const a2 = Math.random().toString().split(".")[1];
3756
- this._realtimeClient = new Be(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.5.8", a2, e2.clientBuild), s2, this._authProvider), this.currentUser = new _e(this._realtimeClient.userId, this._realtimeClient), this._terminationReason = o(), this._terminationReason.promise.then((e3) => {
3757
- console.error(`[TalkSession] ${e3}`);
3758
- }), function(e3, t3, s3) {
3770
+ this._realtimeClient = new Be(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.5.9", a2, e2.clientBuild), s2, this._authProvider), this.currentUser = new _e(this._realtimeClient.userId, this._realtimeClient), this._terminationReason = o(), this._terminationReason.promise.then((e3) => {
3771
+ console.error(`[TalkJS] ${e3}`);
3772
+ }), function(e3, t3) {
3759
3773
  return __async(this, null, function* () {
3760
- return ys({ method: "GET", url: `${t3}/${e3}/app`, authProvider: s3, errorTracker: s3.errorTracker }).then((e4) => 200 === e4.status || 404 !== e4.status && (console.warn(`[TalkJS] Received unexpected ${e4.status} status code when validating app ID. Assuming that the app ID is valid.`), true)).catch((e4) => {
3774
+ return ys({ method: "GET", url: `${t3}/${e3}` }).then((e4) => __async(this, null, function* () {
3775
+ return 200 === e4.status || 404 !== e4.status && (console.warn(`[TalkJS] Received unexpected ${e4.status} status code when validating app ID. Assuming that the app ID is valid.`), true);
3776
+ })).catch((e4) => {
3761
3777
  if ("string" != typeof e4 && "status" in e4) {
3762
3778
  const t4 = e4;
3763
3779
  return 200 === t4.status || 404 !== t4.status && (console.warn(`[TalkJS] Received unexpected ${t4.status} status code when validating app ID. Assuming that the app ID is valid.`), true);
@@ -3765,12 +3781,27 @@ class Ss {
3765
3781
  return console.warn("[TalkJS] Encountered network issues when validating app ID. Assuming that the app ID is valid."), true;
3766
3782
  });
3767
3783
  });
3768
- }(this._appId, this._apiUrls.internalHttpApiUrl, this._authProvider).then((e3) => {
3784
+ }(this._appId, this._apiUrls.internalHttpApiUrl).then((e3) => {
3769
3785
  e3 || this.terminate(new Error(`The app ID ${this._appId} does not exist. Make sure you are using the correct app ID as found on the TalkJS dashboard. App IDs are case-sensitive.`));
3770
3786
  }), this._authProvider.onTokenRefreshFailed((e3) => {
3771
3787
  this.terminate(new Error(`Could not authenticate, cannot recover automatically: ${e3}`));
3772
3788
  });
3773
3789
  }
3790
+ setToken(e2) {
3791
+ this._authProvider.setToken(e2);
3792
+ }
3793
+ get onNeedToken() {
3794
+ return this._onNeedToken;
3795
+ }
3796
+ set onNeedToken(e2) {
3797
+ this._onNeedToken = e2, void 0 === e2 ? this._authProvider.setOnNeedToken(void 0) : this._authProvider.setOnNeedToken(() => {
3798
+ try {
3799
+ e2();
3800
+ } catch (e3) {
3801
+ console.error("[TalkJS] error when calling `onNeedToken` - your auth token will expire soon.", e3);
3802
+ }
3803
+ });
3804
+ }
3774
3805
  onError(e2) {
3775
3806
  const t2 = o();
3776
3807
  return Promise.race([t2.promise, this._terminationReason.promise]).then((t3) => {
@@ -3785,7 +3816,7 @@ class Ss {
3785
3816
  conversation(e2) {
3786
3817
  if ("string" != typeof e2) throw new Error(`Creating ConversationRef failed because ID "${e2}" is not a string`);
3787
3818
  if ("" === e2) throw new Error(`Creating ConversationRef failed because ID "${e2}" is an empty string`);
3788
- return new gs(e2, this._realtimeClient);
3819
+ return new ms(e2, this._realtimeClient);
3789
3820
  }
3790
3821
  subscribeConversations(e2) {
3791
3822
  return this._realtimeClient.subscribe(["me", "conversations"], e2);
@@ -3815,7 +3846,7 @@ class Ss {
3815
3846
  function Ms(_0, _1, _2, _3) {
3816
3847
  return __async(this, arguments, function* (e2, t2, s2, { subtype: n2, filename: r2, width: i2, height: a2, duration: o2 }) {
3817
3848
  const u2 = new FormData();
3818
- return u2.set("file", s2, r2), void 0 !== n2 && u2.set("subtype", n2), void 0 !== i2 && u2.set("width", i2.toString()), void 0 !== a2 && u2.set("height", a2.toString()), void 0 !== o2 && u2.set("duration", o2.toString()), ys({ method: "POST", url: e2, data: u2, authProvider: t2, errorTracker: t2.errorTracker }).then((e3) => e3.json()).then((e3) => e3.attachmentToken).catch((e3) => __async(this, null, function* () {
3849
+ return u2.set("file", s2, r2), void 0 !== n2 && u2.set("subtype", n2), void 0 !== i2 && u2.set("width", i2.toString()), void 0 !== a2 && u2.set("height", a2.toString()), void 0 !== o2 && u2.set("duration", o2.toString()), ys({ method: "POST", url: e2, data: u2, authProvider: t2, errorTracker: t2.errorTracker }).then((e3) => e3.json()).then((e3) => e3.fileToken).catch((e3) => __async(this, null, function* () {
3819
3850
  if (e3 instanceof Response) {
3820
3851
  const t3 = yield e3.json(), s3 = `Unexpected response when uploading file, status code ${e3.status} ${t3.errorCode}, ${t3.reasons}`;
3821
3852
  throw new Error(s3);