@epam/statgpt-conversation-list 0.2.0-rc.8 → 0.2.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.
package/index.mjs CHANGED
@@ -1,120 +1,115 @@
1
- import { jsxs as B, jsx as g, Fragment as v } from "react/jsx-runtime";
2
- import J from "classnames";
3
- import O, { useState as F, useMemo as he, useEffect as ee, useCallback as _, useRef as ze } from "react";
4
- import { cloneDeep as ke, omit as _e, uniqBy as $e } from "lodash";
5
- import { Popup as fe, PopUpSize as me, Button as X, Loader as Ce, InputWithIcon as Re, Input as He, PopUpState as Y, Dropdown as Ye, HighlightText as Qe, IconButton as Ge } from "@epam/statgpt-ui-components";
6
- import { IconCheck as je, IconCopy as Ve, IconDotsVertical as Xe, IconCaretRightFilled as We, IconX as Ke, IconSearch as Ze } from "@tabler/icons-react";
1
+ import { jsxs as y, jsx as m, Fragment as q } from "react/jsx-runtime";
2
+ import k from "classnames";
3
+ import x, { useState as T, useMemo as J, useEffect as ee, useCallback as B, useRef as ze } from "react";
4
+ import { cloneDeep as _e, uniqBy as $e, omit as He } from "lodash";
5
+ import { Popup as ae, PopUpSize as le, Button as Q, Loader as we, InputWithIcon as Ne, Input as Ye, PopUpState as z, Dropdown as Re, HighlightText as Qe, IconButton as Ge } from "@epam/statgpt-ui-components";
6
+ import { IconCheck as je, IconCopy as We, IconDotsVertical as Ve, IconCaretRightFilled as Xe, IconX as Ke, IconSearch as Ze } from "@tabler/icons-react";
7
7
  import Je from "jszip";
8
- import { InvitationType as qe, getSharedConversationsRequest as le, ShareTarget as ie } from "@epam/statgpt-dial-toolkit";
9
- import { SHARE_CONVERSATION_ROUTE as we, getClearedConversationName as pe, ONBOARDING_MODEL_POSTFIX as ve, cleanConversationNames as K } from "@epam/statgpt-shared-toolkit";
10
- var k = /* @__PURE__ */ ((t) => (t.DELETE = "delete", t.EXPORT = "export", t.SHARE = "share", t.RENAME = "rename", t))(k || {}), U = /* @__PURE__ */ ((t) => (t.SHARED = "shared", t.TODAY = "today", t.YESTERDAY = "yesterday", t.WEEK = "week", t.EARLIER = "earlier", t))(U || {});
11
- const ce = (t, r) => {
12
- var l, c;
13
- return ((c = (l = t == null ? void 0 : t.resources) == null ? void 0 : l.filter((s) => (s == null ? void 0 : s.parentPath) === r)) == null ? void 0 : c.map((s) => {
14
- var h, e, n;
15
- const a = `${s == null ? void 0 : s.bucket}/${r}`, p = (n = (e = (h = s == null ? void 0 : s.url) == null ? void 0 : h.split("/")) == null ? void 0 : e.slice(1)) == null ? void 0 : n.join("/");
16
- return {
17
- ...s,
18
- folderId: a,
19
- id: p,
20
- isShared: !0
21
- };
22
- })) || [];
23
- }, et = (t) => ({
24
- [U.SHARED]: t
25
- }), tt = {
26
- [U.TODAY]: [],
27
- [U.YESTERDAY]: [],
28
- [U.WEEK]: [],
29
- [U.EARLIER]: []
30
- }, Me = (t, r) => t.toDateString() === r.toDateString(), nt = (t, r) => {
31
- const l = new Date(
32
- t.getFullYear(),
33
- t.getMonth(),
34
- t.getDate() - 1
8
+ import { InvitationType as qe, getSharedConversationsRequest as re, ShareTarget as se } from "@epam/statgpt-dial-toolkit";
9
+ import { SHARE_CONVERSATION_ROUTE as ve, getClearedConversationName as fe, ONBOARDING_MODEL_POSTFIX as et, cleanConversationNames as K } from "@epam/statgpt-shared-toolkit";
10
+ var U = /* @__PURE__ */ ((o) => (o.DELETE = "delete", o.EXPORT = "export", o.SHARE = "share", o.RENAME = "rename", o))(U || {}), F = /* @__PURE__ */ ((o) => (o.SHARED = "shared", o.TODAY = "today", o.YESTERDAY = "yesterday", o.WEEK = "week", o.EARLIER = "earlier", o))(F || {});
11
+ const ue = (o, s) => o?.resources?.filter((r) => r?.parentPath === s)?.map((r) => {
12
+ const l = `${r?.bucket}/${s}`, c = r?.url?.split("/")?.slice(1)?.join("/");
13
+ return {
14
+ ...r,
15
+ folderId: l,
16
+ id: c,
17
+ isShared: !0
18
+ };
19
+ }) || [], tt = (o) => ({
20
+ [F.SHARED]: o
21
+ }), nt = {
22
+ [F.TODAY]: [],
23
+ [F.YESTERDAY]: [],
24
+ [F.WEEK]: [],
25
+ [F.EARLIER]: []
26
+ }, Me = (o, s) => o.toDateString() === s.toDateString(), ot = (o, s) => {
27
+ const r = new Date(
28
+ o.getFullYear(),
29
+ o.getMonth(),
30
+ o.getDate() - 1
35
31
  );
36
- return Me(r, l);
37
- }, rt = (t, r) => {
38
- const l = t.getTime() - r.getTime();
39
- return Math.floor(l / (1e3 * 60 * 60 * 24));
40
- }, ot = (t) => {
41
- const r = /* @__PURE__ */ new Date(), l = ke(tt);
42
- for (const c of t)
43
- if (c.updatedAt) {
44
- const s = new Date(c.updatedAt);
45
- let a;
46
- Me(r, s) ? a = l[U.TODAY] : nt(r, s) ? a = l[U.YESTERDAY] : rt(r, s) <= 7 ? a = l[U.WEEK] : a = l[U.EARLIER], a != null && a.some(
47
- (p) => p.id === c.id
48
- ) || a.push(c);
32
+ return Me(s, r);
33
+ }, rt = (o, s) => {
34
+ const r = o.getTime() - s.getTime();
35
+ return Math.floor(r / (1e3 * 60 * 60 * 24));
36
+ }, Ce = (o) => o.updatedAt || Number(o.id?.split("-").pop()), st = (o) => {
37
+ const s = /* @__PURE__ */ new Date(), r = _e(nt);
38
+ for (const l of o)
39
+ if (l.updatedAt) {
40
+ const c = new Date(l.updatedAt);
41
+ let d;
42
+ Me(s, c) ? d = r[F.TODAY] : ot(s, c) ? d = r[F.YESTERDAY] : rt(s, c) <= 7 ? d = r[F.WEEK] : d = r[F.EARLIER], d?.some(
43
+ (f) => f.id === l.id
44
+ ) || d.push(l);
49
45
  }
50
- return l;
51
- }, Ne = (t) => t == null ? void 0 : t.sort(
52
- (r, l) => ((l == null ? void 0 : l.updatedAt) || 0) - ((r == null ? void 0 : r.updatedAt) || 0)
53
- ), lt = (t, r) => t === U.SHARED ? (r == null ? void 0 : r.shared) || "Shared" : t === U.TODAY ? (r == null ? void 0 : r.today) || "Today" : t === U.YESTERDAY ? (r == null ? void 0 : r.yesterday) || "Yesterday" : t === U.WEEK ? (r == null ? void 0 : r.lastWeek) || "Last week" : (r == null ? void 0 : r.earlier) || "Earlier", it = ({
54
- onCloseModal: t,
55
- disableModalDividers: r,
56
- deleteConversation: l,
57
- isSmallButton: c,
58
- titles: s,
59
- locale: a
60
- }) => /* @__PURE__ */ B(
61
- fe,
46
+ return r;
47
+ }, ye = (o) => o?.sort(
48
+ (s, r) => (Ce(r) || 0) - (Ce(s) || 0)
49
+ ), it = (o, s) => o === F.SHARED ? s?.shared || "Shared" : o === F.TODAY ? s?.today || "Today" : o === F.YESTERDAY ? s?.yesterday || "Yesterday" : o === F.WEEK ? s?.lastWeek || "Last week" : s?.earlier || "Earlier", at = ({
50
+ onCloseModal: o,
51
+ disableModalDividers: s,
52
+ deleteConversation: r,
53
+ isSmallButton: l,
54
+ titles: c,
55
+ locale: d
56
+ }) => /* @__PURE__ */ y(
57
+ ae,
62
58
  {
63
- heading: (s == null ? void 0 : s.deleteTitle) ?? "Delete conversation",
59
+ heading: c?.deleteTitle ?? "Delete conversation",
64
60
  portalId: "delete-conversation",
65
61
  containerClassName: "delete-conversation-popup",
66
- size: me.SM,
67
- dividers: !r,
68
- onClose: t,
69
- closeButtonTitle: (s == null ? void 0 : s.close) ?? "Cancel",
62
+ size: le.SM,
63
+ dividers: !s,
64
+ onClose: o,
65
+ closeButtonTitle: c?.close ?? "Cancel",
70
66
  children: [
71
- /* @__PURE__ */ g("div", { className: "py-4 px-6 sm:px-0", lang: a, children: (s == null ? void 0 : s.deleteMessage) ?? "Are you sure you want to delete this conversation? This action cannot be undone." }),
72
- /* @__PURE__ */ B("div", { className: "flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer", children: [
73
- /* @__PURE__ */ g(
74
- X,
67
+ /* @__PURE__ */ m("div", { className: "py-4 px-6 sm:px-0", lang: d, children: c?.deleteMessage ?? "Are you sure you want to delete this conversation? This action cannot be undone." }),
68
+ /* @__PURE__ */ y("div", { className: "flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer", children: [
69
+ /* @__PURE__ */ m(
70
+ Q,
75
71
  {
76
72
  buttonClassName: "cancel-button",
77
- title: (s == null ? void 0 : s.cancel) ?? "Cancel",
78
- isSmallButton: c,
79
- onClick: (p) => {
80
- p.stopPropagation(), t();
73
+ title: c?.cancel ?? "Cancel",
74
+ isSmallButton: l,
75
+ onClick: (f) => {
76
+ f.stopPropagation(), o();
81
77
  }
82
78
  }
83
79
  ),
84
- /* @__PURE__ */ g(
85
- X,
80
+ /* @__PURE__ */ m(
81
+ Q,
86
82
  {
87
83
  buttonClassName: "text-button-primary text-button-primary-error",
88
- title: (s == null ? void 0 : s.delete) ?? "Delete",
89
- isSmallButton: c,
90
- onClick: (p) => {
91
- p.stopPropagation(), l();
84
+ title: c?.delete ?? "Delete",
85
+ isSmallButton: l,
86
+ onClick: (f) => {
87
+ f.stopPropagation(), r();
92
88
  }
93
89
  }
94
90
  )
95
91
  ] })
96
92
  ]
97
93
  }
98
- ), st = (t) => {
99
- const r = t.messages.flatMap((c) => {
100
- var p, h, e;
101
- const s = ((p = c.custom_content) == null ? void 0 : p.attachments) || [], a = ((e = (h = c.custom_content) == null ? void 0 : h.stages) == null ? void 0 : e.flatMap(
102
- ({ attachments: n }) => n ?? []
103
- )) || [];
104
- return [...s, ...a];
105
- }) || [], l = dt(r).map(
106
- (c) => ({
107
- ...c,
94
+ ), lt = (o) => {
95
+ const s = o.messages.flatMap((l) => {
96
+ const c = l.custom_content?.attachments || [], d = l.custom_content?.stages?.flatMap(
97
+ ({ attachments: f }) => f ?? []
98
+ ) || [];
99
+ return [...c, ...d];
100
+ }) || [], r = ht(s).map(
101
+ (l) => ({
102
+ ...l,
108
103
  relativePath: "",
109
104
  contentLength: 0
110
105
  })
111
106
  );
112
107
  return $e(
113
- l,
114
- (c) => te(c.relativePath, c.name)
108
+ r,
109
+ (l) => te(l.relativePath, l.name)
115
110
  );
116
- }, at = (t) => t.endsWith("/"), ct = (t) => {
117
- const r = t.toLowerCase();
111
+ }, ct = (o) => o.endsWith("/"), dt = (o) => {
112
+ const s = o.toLowerCase();
118
113
  return [
119
114
  "data:",
120
115
  "//",
@@ -125,99 +120,94 @@ const ce = (t, r) => {
125
120
  "mailto:",
126
121
  "telnet://",
127
122
  "api/files"
128
- ].some((l) => r.startsWith(l));
129
- }, ut = (t) => {
130
- const r = te(
131
- ...t.split("/").map((c) => decodeURIComponent(c))
132
- ), l = r.lastIndexOf("/");
123
+ ].some((r) => s.startsWith(r));
124
+ }, ut = (o) => {
125
+ const s = te(
126
+ ...o.split("/").map((l) => decodeURIComponent(l))
127
+ ), r = s.lastIndexOf("/");
133
128
  return {
134
- absolutePath: r.slice(0, l),
135
- name: r.slice(l + 1)
129
+ absolutePath: s.slice(0, r),
130
+ name: s.slice(r + 1)
136
131
  };
137
- }, dt = (t) => t ? t.map((r) => {
138
- if (!r.url || ct(r.url) || at(r.url))
132
+ }, ht = (o) => o ? o.map((s) => {
133
+ if (!s.url || dt(s.url) || ct(s.url))
139
134
  return null;
140
- const { absolutePath: l, name: c } = ut(r.url);
135
+ const { absolutePath: r, name: l } = ut(s.url);
141
136
  return {
142
- id: r.url,
143
- name: c,
144
- contentType: r.type,
145
- folderId: l,
146
- absolutePath: l
137
+ id: s.url,
138
+ name: l,
139
+ contentType: s.type,
140
+ folderId: r,
141
+ absolutePath: r
147
142
  };
148
143
  }).filter(Boolean) : [];
149
- async function ht(t, r) {
150
- const l = st(t), c = new Je();
151
- l.forEach((h) => {
152
- const e = encodeURI(te(h.absolutePath, h.name)), n = r(`${e}`.replace("files/", "")), o = ft(h.folderId), i = te("res", o, h.name);
153
- c.file(i, n);
144
+ async function mt(o, s) {
145
+ const r = lt(o), l = new Je();
146
+ r.forEach((p) => {
147
+ const e = encodeURI(te(p.absolutePath, p.name)), n = s(`${e}`.replace("files/", "")), t = ft(p.folderId), i = te("res", t, p.name);
148
+ l.file(i, n);
154
149
  });
155
- const s = {
150
+ const c = {
156
151
  version: 5,
157
- history: [t].map(mt) || [],
152
+ history: [o].map(pt) || [],
158
153
  folders: []
159
- }, a = JSON.stringify(s, null, 2);
160
- return c.file("conversations/conversations_history.json", a), await c.generateAsync({ type: "base64" });
154
+ }, d = JSON.stringify(c, null, 2);
155
+ return l.file("conversations/conversations_history.json", d), await l.generateAsync({ type: "base64" });
161
156
  }
162
- const ft = (t) => {
163
- const r = t.split("/");
164
- return r.length > 2 ? te(...r.slice(2)) : void 0;
165
- }, mt = (t) => _e(t, ["publicationInfo"]), te = (...t) => t.filter(Boolean).join("/");
166
- function pt(t, r) {
167
- const l = document.createElement("a");
168
- l.download = r, l.href = t, l.style.display = "none", document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(t);
157
+ const ft = (o) => {
158
+ const s = o.split("/");
159
+ return s.length > 2 ? te(...s.slice(2)) : void 0;
160
+ }, pt = (o) => He(o, ["publicationInfo"]), te = (...o) => o.filter(Boolean).join("/");
161
+ function gt(o, s) {
162
+ const r = document.createElement("a");
163
+ r.download = s, r.href = o, r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(o);
169
164
  }
170
- var gt = Object.defineProperty, se = Object.getOwnPropertySymbols, Ie = Object.prototype.hasOwnProperty, Ae = Object.prototype.propertyIsEnumerable, Ee = (t, r, l) => r in t ? gt(t, r, { enumerable: !0, configurable: !0, writable: !0, value: l }) : t[r] = l, ue = (t, r) => {
171
- for (var l in r || (r = {}))
172
- Ie.call(r, l) && Ee(t, l, r[l]);
173
- if (se)
174
- for (var l of se(r))
175
- Ae.call(r, l) && Ee(t, l, r[l]);
176
- return t;
177
- }, de = (t, r) => {
178
- var l = {};
179
- for (var c in t)
180
- Ie.call(t, c) && r.indexOf(c) < 0 && (l[c] = t[c]);
181
- if (t != null && se)
182
- for (var c of se(t))
183
- r.indexOf(c) < 0 && Ae.call(t, c) && (l[c] = t[c]);
184
- return l;
165
+ var Ct = Object.defineProperty, ie = Object.getOwnPropertySymbols, Ae = Object.prototype.hasOwnProperty, Ie = Object.prototype.propertyIsEnumerable, Ee = (o, s, r) => s in o ? Ct(o, s, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[s] = r, he = (o, s) => {
166
+ for (var r in s || (s = {}))
167
+ Ae.call(s, r) && Ee(o, r, s[r]);
168
+ if (ie)
169
+ for (var r of ie(s))
170
+ Ie.call(s, r) && Ee(o, r, s[r]);
171
+ return o;
172
+ }, me = (o, s) => {
173
+ var r = {};
174
+ for (var l in o)
175
+ Ae.call(o, l) && s.indexOf(l) < 0 && (r[l] = o[l]);
176
+ if (o != null && ie)
177
+ for (var l of ie(o))
178
+ s.indexOf(l) < 0 && Ie.call(o, l) && (r[l] = o[l]);
179
+ return r;
185
180
  };
186
- /**
187
- * @license QR Code generator library (TypeScript)
188
- * Copyright (c) Project Nayuki.
189
- * SPDX-License-Identifier: MIT
190
- */
191
- var W;
192
- ((t) => {
193
- const r = class R {
181
+ var X;
182
+ ((o) => {
183
+ const s = class w {
194
184
  /*-- Constructor (low level) and fields --*/
195
185
  // Creates a new QR Code with the given version number,
196
186
  // error correction level, data codeword bytes, and mask number.
197
187
  // This is a low-level API that most users should not use directly.
198
188
  // A mid-level API is the encodeSegments() function.
199
- constructor(e, n, o, i) {
200
- if (this.version = e, this.errorCorrectionLevel = n, this.modules = [], this.isFunction = [], e < R.MIN_VERSION || e > R.MAX_VERSION)
189
+ constructor(e, n, t, i) {
190
+ if (this.version = e, this.errorCorrectionLevel = n, this.modules = [], this.isFunction = [], e < w.MIN_VERSION || e > w.MAX_VERSION)
201
191
  throw new RangeError("Version value out of range");
202
192
  if (i < -1 || i > 7)
203
193
  throw new RangeError("Mask value out of range");
204
194
  this.size = e * 4 + 17;
205
- let u = [];
206
- for (let d = 0; d < this.size; d++)
207
- u.push(!1);
208
- for (let d = 0; d < this.size; d++)
209
- this.modules.push(u.slice()), this.isFunction.push(u.slice());
195
+ let a = [];
196
+ for (let u = 0; u < this.size; u++)
197
+ a.push(!1);
198
+ for (let u = 0; u < this.size; u++)
199
+ this.modules.push(a.slice()), this.isFunction.push(a.slice());
210
200
  this.drawFunctionPatterns();
211
- const f = this.addEccAndInterleave(o);
212
- if (this.drawCodewords(f), i == -1) {
213
- let d = 1e9;
214
- for (let C = 0; C < 8; C++) {
215
- this.applyMask(C), this.drawFormatBits(C);
216
- const m = this.getPenaltyScore();
217
- m < d && (i = C, d = m), this.applyMask(C);
201
+ const h = this.addEccAndInterleave(t);
202
+ if (this.drawCodewords(h), i == -1) {
203
+ let u = 1e9;
204
+ for (let E = 0; E < 8; E++) {
205
+ this.applyMask(E), this.drawFormatBits(E);
206
+ const g = this.getPenaltyScore();
207
+ g < u && (i = E, u = g), this.applyMask(E);
218
208
  }
219
209
  }
220
- s(0 <= i && i <= 7), this.mask = i, this.applyMask(i), this.drawFormatBits(i), this.isFunction = [];
210
+ c(0 <= i && i <= 7), this.mask = i, this.applyMask(i), this.drawFormatBits(i), this.isFunction = [];
221
211
  }
222
212
  /*-- Static factory functions (high level) --*/
223
213
  // Returns a QR Code representing the given Unicode text string at the given error correction level.
@@ -226,16 +216,16 @@ var W;
226
216
  // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
227
217
  // ecl argument if it can be done without increasing the version.
228
218
  static encodeText(e, n) {
229
- const o = t.QrSegment.makeSegments(e);
230
- return R.encodeSegments(o, n);
219
+ const t = o.QrSegment.makeSegments(e);
220
+ return w.encodeSegments(t, n);
231
221
  }
232
222
  // Returns a QR Code representing the given binary data at the given error correction level.
233
223
  // This function always encodes using the binary segment mode, not any text mode. The maximum number of
234
224
  // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
235
225
  // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
236
226
  static encodeBinary(e, n) {
237
- const o = t.QrSegment.makeBytes(e);
238
- return R.encodeSegments([o], n);
227
+ const t = o.QrSegment.makeBytes(e);
228
+ return w.encodeSegments([t], n);
239
229
  }
240
230
  /*-- Static factory functions (mid level) --*/
241
231
  // Returns a QR Code representing the given segments with the given encoding parameters.
@@ -247,36 +237,36 @@ var W;
247
237
  // This function allows the user to create a custom sequence of segments that switches
248
238
  // between modes (such as alphanumeric and byte) to encode text in less space.
249
239
  // This is a mid-level API; the high-level API is encodeText() and encodeBinary().
250
- static encodeSegments(e, n, o = 1, i = 40, u = -1, f = !0) {
251
- if (!(R.MIN_VERSION <= o && o <= i && i <= R.MAX_VERSION) || u < -1 || u > 7)
240
+ static encodeSegments(e, n, t = 1, i = 40, a = -1, h = !0) {
241
+ if (!(w.MIN_VERSION <= t && t <= i && i <= w.MAX_VERSION) || a < -1 || a > 7)
252
242
  throw new RangeError("Invalid value");
253
- let d, C;
254
- for (d = o; ; d++) {
255
- const E = R.getNumDataCodewords(d, n) * 8, N = p.getTotalBits(e, d);
256
- if (N <= E) {
257
- C = N;
243
+ let u, E;
244
+ for (u = t; ; u++) {
245
+ const C = w.getNumDataCodewords(u, n) * 8, R = f.getTotalBits(e, u);
246
+ if (R <= C) {
247
+ E = R;
258
248
  break;
259
249
  }
260
- if (d >= i)
250
+ if (u >= i)
261
251
  throw new RangeError("Data too long");
262
252
  }
263
- for (const E of [R.Ecc.MEDIUM, R.Ecc.QUARTILE, R.Ecc.HIGH])
264
- f && C <= R.getNumDataCodewords(d, E) * 8 && (n = E);
265
- let m = [];
266
- for (const E of e) {
267
- l(E.mode.modeBits, 4, m), l(E.numChars, E.mode.numCharCountBits(d), m);
268
- for (const N of E.getData())
269
- m.push(N);
253
+ for (const C of [w.Ecc.MEDIUM, w.Ecc.QUARTILE, w.Ecc.HIGH])
254
+ h && E <= w.getNumDataCodewords(u, C) * 8 && (n = C);
255
+ let g = [];
256
+ for (const C of e) {
257
+ r(C.mode.modeBits, 4, g), r(C.numChars, C.mode.numCharCountBits(u), g);
258
+ for (const R of C.getData())
259
+ g.push(R);
270
260
  }
271
- s(m.length == C);
272
- const I = R.getNumDataCodewords(d, n) * 8;
273
- s(m.length <= I), l(0, Math.min(4, I - m.length), m), l(0, (8 - m.length % 8) % 8, m), s(m.length % 8 == 0);
274
- for (let E = 236; m.length < I; E ^= 253)
275
- l(E, 8, m);
276
- let w = [];
277
- for (; w.length * 8 < m.length; )
278
- w.push(0);
279
- return m.forEach((E, N) => w[N >>> 3] |= E << 7 - (N & 7)), new R(d, n, w, u);
261
+ c(g.length == E);
262
+ const v = w.getNumDataCodewords(u, n) * 8;
263
+ c(g.length <= v), r(0, Math.min(4, v - g.length), g), r(0, (8 - g.length % 8) % 8, g), c(g.length % 8 == 0);
264
+ for (let C = 236; g.length < v; C ^= 253)
265
+ r(C, 8, g);
266
+ let N = [];
267
+ for (; N.length * 8 < g.length; )
268
+ N.push(0);
269
+ return g.forEach((C, R) => N[R >>> 3] |= C << 7 - (R & 7)), new w(u, n, N, a);
280
270
  }
281
271
  /*-- Accessor methods --*/
282
272
  // Returns the color of the module (pixel) at the given coordinates, which is false
@@ -292,33 +282,33 @@ var W;
292
282
  /*-- Private helper methods for constructor: Drawing function modules --*/
293
283
  // Reads this object's version field, and draws and marks all function modules.
294
284
  drawFunctionPatterns() {
295
- for (let o = 0; o < this.size; o++)
296
- this.setFunctionModule(6, o, o % 2 == 0), this.setFunctionModule(o, 6, o % 2 == 0);
285
+ for (let t = 0; t < this.size; t++)
286
+ this.setFunctionModule(6, t, t % 2 == 0), this.setFunctionModule(t, 6, t % 2 == 0);
297
287
  this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
298
288
  const e = this.getAlignmentPatternPositions(), n = e.length;
299
- for (let o = 0; o < n; o++)
289
+ for (let t = 0; t < n; t++)
300
290
  for (let i = 0; i < n; i++)
301
- o == 0 && i == 0 || o == 0 && i == n - 1 || o == n - 1 && i == 0 || this.drawAlignmentPattern(e[o], e[i]);
291
+ t == 0 && i == 0 || t == 0 && i == n - 1 || t == n - 1 && i == 0 || this.drawAlignmentPattern(e[t], e[i]);
302
292
  this.drawFormatBits(0), this.drawVersion();
303
293
  }
304
294
  // Draws two copies of the format bits (with its own error correction code)
305
295
  // based on the given mask and this object's error correction level field.
306
296
  drawFormatBits(e) {
307
297
  const n = this.errorCorrectionLevel.formatBits << 3 | e;
308
- let o = n;
309
- for (let u = 0; u < 10; u++)
310
- o = o << 1 ^ (o >>> 9) * 1335;
311
- const i = (n << 10 | o) ^ 21522;
312
- s(i >>> 15 == 0);
313
- for (let u = 0; u <= 5; u++)
314
- this.setFunctionModule(8, u, c(i, u));
315
- this.setFunctionModule(8, 7, c(i, 6)), this.setFunctionModule(8, 8, c(i, 7)), this.setFunctionModule(7, 8, c(i, 8));
316
- for (let u = 9; u < 15; u++)
317
- this.setFunctionModule(14 - u, 8, c(i, u));
318
- for (let u = 0; u < 8; u++)
319
- this.setFunctionModule(this.size - 1 - u, 8, c(i, u));
320
- for (let u = 8; u < 15; u++)
321
- this.setFunctionModule(8, this.size - 15 + u, c(i, u));
298
+ let t = n;
299
+ for (let a = 0; a < 10; a++)
300
+ t = t << 1 ^ (t >>> 9) * 1335;
301
+ const i = (n << 10 | t) ^ 21522;
302
+ c(i >>> 15 == 0);
303
+ for (let a = 0; a <= 5; a++)
304
+ this.setFunctionModule(8, a, l(i, a));
305
+ this.setFunctionModule(8, 7, l(i, 6)), this.setFunctionModule(8, 8, l(i, 7)), this.setFunctionModule(7, 8, l(i, 8));
306
+ for (let a = 9; a < 15; a++)
307
+ this.setFunctionModule(14 - a, 8, l(i, a));
308
+ for (let a = 0; a < 8; a++)
309
+ this.setFunctionModule(this.size - 1 - a, 8, l(i, a));
310
+ for (let a = 8; a < 15; a++)
311
+ this.setFunctionModule(8, this.size - 15 + a, l(i, a));
322
312
  this.setFunctionModule(8, this.size - 8, !0);
323
313
  }
324
314
  // Draws two copies of the version bits (with its own error correction code),
@@ -327,74 +317,74 @@ var W;
327
317
  if (this.version < 7)
328
318
  return;
329
319
  let e = this.version;
330
- for (let o = 0; o < 12; o++)
320
+ for (let t = 0; t < 12; t++)
331
321
  e = e << 1 ^ (e >>> 11) * 7973;
332
322
  const n = this.version << 12 | e;
333
- s(n >>> 18 == 0);
334
- for (let o = 0; o < 18; o++) {
335
- const i = c(n, o), u = this.size - 11 + o % 3, f = Math.floor(o / 3);
336
- this.setFunctionModule(u, f, i), this.setFunctionModule(f, u, i);
323
+ c(n >>> 18 == 0);
324
+ for (let t = 0; t < 18; t++) {
325
+ const i = l(n, t), a = this.size - 11 + t % 3, h = Math.floor(t / 3);
326
+ this.setFunctionModule(a, h, i), this.setFunctionModule(h, a, i);
337
327
  }
338
328
  }
339
329
  // Draws a 9*9 finder pattern including the border separator,
340
330
  // with the center module at (x, y). Modules can be out of bounds.
341
331
  drawFinderPattern(e, n) {
342
- for (let o = -4; o <= 4; o++)
332
+ for (let t = -4; t <= 4; t++)
343
333
  for (let i = -4; i <= 4; i++) {
344
- const u = Math.max(Math.abs(i), Math.abs(o)), f = e + i, d = n + o;
345
- 0 <= f && f < this.size && 0 <= d && d < this.size && this.setFunctionModule(f, d, u != 2 && u != 4);
334
+ const a = Math.max(Math.abs(i), Math.abs(t)), h = e + i, u = n + t;
335
+ 0 <= h && h < this.size && 0 <= u && u < this.size && this.setFunctionModule(h, u, a != 2 && a != 4);
346
336
  }
347
337
  }
348
338
  // Draws a 5*5 alignment pattern, with the center module
349
339
  // at (x, y). All modules must be in bounds.
350
340
  drawAlignmentPattern(e, n) {
351
- for (let o = -2; o <= 2; o++)
341
+ for (let t = -2; t <= 2; t++)
352
342
  for (let i = -2; i <= 2; i++)
353
- this.setFunctionModule(e + i, n + o, Math.max(Math.abs(i), Math.abs(o)) != 1);
343
+ this.setFunctionModule(e + i, n + t, Math.max(Math.abs(i), Math.abs(t)) != 1);
354
344
  }
355
345
  // Sets the color of a module and marks it as a function module.
356
346
  // Only used by the constructor. Coordinates must be in bounds.
357
- setFunctionModule(e, n, o) {
358
- this.modules[n][e] = o, this.isFunction[n][e] = !0;
347
+ setFunctionModule(e, n, t) {
348
+ this.modules[n][e] = t, this.isFunction[n][e] = !0;
359
349
  }
360
350
  /*-- Private helper methods for constructor: Codewords and masking --*/
361
351
  // Returns a new byte string representing the given data with the appropriate error correction
362
352
  // codewords appended to it, based on this object's version and error correction level.
363
353
  addEccAndInterleave(e) {
364
- const n = this.version, o = this.errorCorrectionLevel;
365
- if (e.length != R.getNumDataCodewords(n, o))
354
+ const n = this.version, t = this.errorCorrectionLevel;
355
+ if (e.length != w.getNumDataCodewords(n, t))
366
356
  throw new RangeError("Invalid argument");
367
- const i = R.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][n], u = R.ECC_CODEWORDS_PER_BLOCK[o.ordinal][n], f = Math.floor(R.getNumRawDataModules(n) / 8), d = i - f % i, C = Math.floor(f / i);
368
- let m = [];
369
- const I = R.reedSolomonComputeDivisor(u);
370
- for (let E = 0, N = 0; E < i; E++) {
371
- let b = e.slice(N, N + C - u + (E < d ? 0 : 1));
372
- N += b.length;
373
- const P = R.reedSolomonComputeRemainder(b, I);
374
- E < d && b.push(0), m.push(b.concat(P));
357
+ const i = w.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][n], a = w.ECC_CODEWORDS_PER_BLOCK[t.ordinal][n], h = Math.floor(w.getNumRawDataModules(n) / 8), u = i - h % i, E = Math.floor(h / i);
358
+ let g = [];
359
+ const v = w.reedSolomonComputeDivisor(a);
360
+ for (let C = 0, R = 0; C < i; C++) {
361
+ let S = e.slice(R, R + E - a + (C < u ? 0 : 1));
362
+ R += S.length;
363
+ const D = w.reedSolomonComputeRemainder(S, v);
364
+ C < u && S.push(0), g.push(S.concat(D));
375
365
  }
376
- let w = [];
377
- for (let E = 0; E < m[0].length; E++)
378
- m.forEach((N, b) => {
379
- (E != C - u || b >= d) && w.push(N[E]);
366
+ let N = [];
367
+ for (let C = 0; C < g[0].length; C++)
368
+ g.forEach((R, S) => {
369
+ (C != E - a || S >= u) && N.push(R[C]);
380
370
  });
381
- return s(w.length == f), w;
371
+ return c(N.length == h), N;
382
372
  }
383
373
  // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
384
374
  // data area of this QR Code. Function modules need to be marked off before this is called.
385
375
  drawCodewords(e) {
386
- if (e.length != Math.floor(R.getNumRawDataModules(this.version) / 8))
376
+ if (e.length != Math.floor(w.getNumRawDataModules(this.version) / 8))
387
377
  throw new RangeError("Invalid argument");
388
378
  let n = 0;
389
- for (let o = this.size - 1; o >= 1; o -= 2) {
390
- o == 6 && (o = 5);
379
+ for (let t = this.size - 1; t >= 1; t -= 2) {
380
+ t == 6 && (t = 5);
391
381
  for (let i = 0; i < this.size; i++)
392
- for (let u = 0; u < 2; u++) {
393
- const f = o - u, C = (o + 1 & 2) == 0 ? this.size - 1 - i : i;
394
- !this.isFunction[C][f] && n < e.length * 8 && (this.modules[C][f] = c(e[n >>> 3], 7 - (n & 7)), n++);
382
+ for (let a = 0; a < 2; a++) {
383
+ const h = t - a, E = (t + 1 & 2) == 0 ? this.size - 1 - i : i;
384
+ !this.isFunction[E][h] && n < e.length * 8 && (this.modules[E][h] = l(e[n >>> 3], 7 - (n & 7)), n++);
395
385
  }
396
386
  }
397
- s(n == e.length * 8);
387
+ c(n == e.length * 8);
398
388
  }
399
389
  // XORs the codeword modules in this QR Code with the given mask pattern.
400
390
  // The function modules must be marked and the codeword bits must be drawn
@@ -405,65 +395,65 @@ var W;
405
395
  if (e < 0 || e > 7)
406
396
  throw new RangeError("Mask value out of range");
407
397
  for (let n = 0; n < this.size; n++)
408
- for (let o = 0; o < this.size; o++) {
398
+ for (let t = 0; t < this.size; t++) {
409
399
  let i;
410
400
  switch (e) {
411
401
  case 0:
412
- i = (o + n) % 2 == 0;
402
+ i = (t + n) % 2 == 0;
413
403
  break;
414
404
  case 1:
415
405
  i = n % 2 == 0;
416
406
  break;
417
407
  case 2:
418
- i = o % 3 == 0;
408
+ i = t % 3 == 0;
419
409
  break;
420
410
  case 3:
421
- i = (o + n) % 3 == 0;
411
+ i = (t + n) % 3 == 0;
422
412
  break;
423
413
  case 4:
424
- i = (Math.floor(o / 3) + Math.floor(n / 2)) % 2 == 0;
414
+ i = (Math.floor(t / 3) + Math.floor(n / 2)) % 2 == 0;
425
415
  break;
426
416
  case 5:
427
- i = o * n % 2 + o * n % 3 == 0;
417
+ i = t * n % 2 + t * n % 3 == 0;
428
418
  break;
429
419
  case 6:
430
- i = (o * n % 2 + o * n % 3) % 2 == 0;
420
+ i = (t * n % 2 + t * n % 3) % 2 == 0;
431
421
  break;
432
422
  case 7:
433
- i = ((o + n) % 2 + o * n % 3) % 2 == 0;
423
+ i = ((t + n) % 2 + t * n % 3) % 2 == 0;
434
424
  break;
435
425
  default:
436
426
  throw new Error("Unreachable");
437
427
  }
438
- !this.isFunction[n][o] && i && (this.modules[n][o] = !this.modules[n][o]);
428
+ !this.isFunction[n][t] && i && (this.modules[n][t] = !this.modules[n][t]);
439
429
  }
440
430
  }
441
431
  // Calculates and returns the penalty score based on state of this QR Code's current modules.
442
432
  // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
443
433
  getPenaltyScore() {
444
434
  let e = 0;
445
- for (let u = 0; u < this.size; u++) {
446
- let f = !1, d = 0, C = [0, 0, 0, 0, 0, 0, 0];
447
- for (let m = 0; m < this.size; m++)
448
- this.modules[u][m] == f ? (d++, d == 5 ? e += R.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, C), f || (e += this.finderPenaltyCountPatterns(C) * R.PENALTY_N3), f = this.modules[u][m], d = 1);
449
- e += this.finderPenaltyTerminateAndCount(f, d, C) * R.PENALTY_N3;
435
+ for (let a = 0; a < this.size; a++) {
436
+ let h = !1, u = 0, E = [0, 0, 0, 0, 0, 0, 0];
437
+ for (let g = 0; g < this.size; g++)
438
+ this.modules[a][g] == h ? (u++, u == 5 ? e += w.PENALTY_N1 : u > 5 && e++) : (this.finderPenaltyAddHistory(u, E), h || (e += this.finderPenaltyCountPatterns(E) * w.PENALTY_N3), h = this.modules[a][g], u = 1);
439
+ e += this.finderPenaltyTerminateAndCount(h, u, E) * w.PENALTY_N3;
450
440
  }
451
- for (let u = 0; u < this.size; u++) {
452
- let f = !1, d = 0, C = [0, 0, 0, 0, 0, 0, 0];
453
- for (let m = 0; m < this.size; m++)
454
- this.modules[m][u] == f ? (d++, d == 5 ? e += R.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, C), f || (e += this.finderPenaltyCountPatterns(C) * R.PENALTY_N3), f = this.modules[m][u], d = 1);
455
- e += this.finderPenaltyTerminateAndCount(f, d, C) * R.PENALTY_N3;
441
+ for (let a = 0; a < this.size; a++) {
442
+ let h = !1, u = 0, E = [0, 0, 0, 0, 0, 0, 0];
443
+ for (let g = 0; g < this.size; g++)
444
+ this.modules[g][a] == h ? (u++, u == 5 ? e += w.PENALTY_N1 : u > 5 && e++) : (this.finderPenaltyAddHistory(u, E), h || (e += this.finderPenaltyCountPatterns(E) * w.PENALTY_N3), h = this.modules[g][a], u = 1);
445
+ e += this.finderPenaltyTerminateAndCount(h, u, E) * w.PENALTY_N3;
456
446
  }
457
- for (let u = 0; u < this.size - 1; u++)
458
- for (let f = 0; f < this.size - 1; f++) {
459
- const d = this.modules[u][f];
460
- d == this.modules[u][f + 1] && d == this.modules[u + 1][f] && d == this.modules[u + 1][f + 1] && (e += R.PENALTY_N2);
447
+ for (let a = 0; a < this.size - 1; a++)
448
+ for (let h = 0; h < this.size - 1; h++) {
449
+ const u = this.modules[a][h];
450
+ u == this.modules[a][h + 1] && u == this.modules[a + 1][h] && u == this.modules[a + 1][h + 1] && (e += w.PENALTY_N2);
461
451
  }
462
452
  let n = 0;
463
- for (const u of this.modules)
464
- n = u.reduce((f, d) => f + (d ? 1 : 0), n);
465
- const o = this.size * this.size, i = Math.ceil(Math.abs(n * 20 - o * 10) / o) - 1;
466
- return s(0 <= i && i <= 9), e += i * R.PENALTY_N4, s(0 <= e && e <= 2568888), e;
453
+ for (const a of this.modules)
454
+ n = a.reduce((h, u) => h + (u ? 1 : 0), n);
455
+ const t = this.size * this.size, i = Math.ceil(Math.abs(n * 20 - t * 10) / t) - 1;
456
+ return c(0 <= i && i <= 9), e += i * w.PENALTY_N4, c(0 <= e && e <= 2568888), e;
467
457
  }
468
458
  /*-- Private helper functions --*/
469
459
  // Returns an ascending list of positions of alignment patterns for this version number.
@@ -474,30 +464,30 @@ var W;
474
464
  return [];
475
465
  {
476
466
  const e = Math.floor(this.version / 7) + 2, n = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2;
477
- let o = [6];
478
- for (let i = this.size - 7; o.length < e; i -= n)
479
- o.splice(1, 0, i);
480
- return o;
467
+ let t = [6];
468
+ for (let i = this.size - 7; t.length < e; i -= n)
469
+ t.splice(1, 0, i);
470
+ return t;
481
471
  }
482
472
  }
483
473
  // Returns the number of data bits that can be stored in a QR Code of the given version number, after
484
474
  // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
485
475
  // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
486
476
  static getNumRawDataModules(e) {
487
- if (e < R.MIN_VERSION || e > R.MAX_VERSION)
477
+ if (e < w.MIN_VERSION || e > w.MAX_VERSION)
488
478
  throw new RangeError("Version number out of range");
489
479
  let n = (16 * e + 128) * e + 64;
490
480
  if (e >= 2) {
491
- const o = Math.floor(e / 7) + 2;
492
- n -= (25 * o - 10) * o - 55, e >= 7 && (n -= 36);
481
+ const t = Math.floor(e / 7) + 2;
482
+ n -= (25 * t - 10) * t - 55, e >= 7 && (n -= 36);
493
483
  }
494
- return s(208 <= n && n <= 29648), n;
484
+ return c(208 <= n && n <= 29648), n;
495
485
  }
496
486
  // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
497
487
  // QR Code of the given version number and error correction level, with remainder bits discarded.
498
488
  // This stateless pure function could be implemented as a (40*4)-cell lookup table.
499
489
  static getNumDataCodewords(e, n) {
500
- return Math.floor(R.getNumRawDataModules(e) / 8) - R.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e] * R.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e];
490
+ return Math.floor(w.getNumRawDataModules(e) / 8) - w.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e] * w.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e];
501
491
  }
502
492
  // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
503
493
  // implemented as a lookup table over all possible parameter values, instead of as an algorithm.
@@ -508,51 +498,51 @@ var W;
508
498
  for (let i = 0; i < e - 1; i++)
509
499
  n.push(0);
510
500
  n.push(1);
511
- let o = 1;
501
+ let t = 1;
512
502
  for (let i = 0; i < e; i++) {
513
- for (let u = 0; u < n.length; u++)
514
- n[u] = R.reedSolomonMultiply(n[u], o), u + 1 < n.length && (n[u] ^= n[u + 1]);
515
- o = R.reedSolomonMultiply(o, 2);
503
+ for (let a = 0; a < n.length; a++)
504
+ n[a] = w.reedSolomonMultiply(n[a], t), a + 1 < n.length && (n[a] ^= n[a + 1]);
505
+ t = w.reedSolomonMultiply(t, 2);
516
506
  }
517
507
  return n;
518
508
  }
519
509
  // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
520
510
  static reedSolomonComputeRemainder(e, n) {
521
- let o = n.map((i) => 0);
511
+ let t = n.map((i) => 0);
522
512
  for (const i of e) {
523
- const u = i ^ o.shift();
524
- o.push(0), n.forEach((f, d) => o[d] ^= R.reedSolomonMultiply(f, u));
513
+ const a = i ^ t.shift();
514
+ t.push(0), n.forEach((h, u) => t[u] ^= w.reedSolomonMultiply(h, a));
525
515
  }
526
- return o;
516
+ return t;
527
517
  }
528
518
  // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
529
519
  // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
530
520
  static reedSolomonMultiply(e, n) {
531
521
  if (e >>> 8 || n >>> 8)
532
522
  throw new RangeError("Byte out of range");
533
- let o = 0;
523
+ let t = 0;
534
524
  for (let i = 7; i >= 0; i--)
535
- o = o << 1 ^ (o >>> 7) * 285, o ^= (n >>> i & 1) * e;
536
- return s(o >>> 8 == 0), o;
525
+ t = t << 1 ^ (t >>> 7) * 285, t ^= (n >>> i & 1) * e;
526
+ return c(t >>> 8 == 0), t;
537
527
  }
538
528
  // Can only be called immediately after a light run is added, and
539
529
  // returns either 0, 1, or 2. A helper function for getPenaltyScore().
540
530
  finderPenaltyCountPatterns(e) {
541
531
  const n = e[1];
542
- s(n <= this.size * 3);
543
- const o = n > 0 && e[2] == n && e[3] == n * 3 && e[4] == n && e[5] == n;
544
- return (o && e[0] >= n * 4 && e[6] >= n ? 1 : 0) + (o && e[6] >= n * 4 && e[0] >= n ? 1 : 0);
532
+ c(n <= this.size * 3);
533
+ const t = n > 0 && e[2] == n && e[3] == n * 3 && e[4] == n && e[5] == n;
534
+ return (t && e[0] >= n * 4 && e[6] >= n ? 1 : 0) + (t && e[6] >= n * 4 && e[0] >= n ? 1 : 0);
545
535
  }
546
536
  // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
547
- finderPenaltyTerminateAndCount(e, n, o) {
548
- return e && (this.finderPenaltyAddHistory(n, o), n = 0), n += this.size, this.finderPenaltyAddHistory(n, o), this.finderPenaltyCountPatterns(o);
537
+ finderPenaltyTerminateAndCount(e, n, t) {
538
+ return e && (this.finderPenaltyAddHistory(n, t), n = 0), n += this.size, this.finderPenaltyAddHistory(n, t), this.finderPenaltyCountPatterns(t);
549
539
  }
550
540
  // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
551
541
  finderPenaltyAddHistory(e, n) {
552
542
  n[0] == 0 && (e += this.size), n.pop(), n.unshift(e);
553
543
  }
554
544
  };
555
- r.MIN_VERSION = 1, r.MAX_VERSION = 40, r.PENALTY_N1 = 3, r.PENALTY_N2 = 3, r.PENALTY_N3 = 40, r.PENALTY_N4 = 10, r.ECC_CODEWORDS_PER_BLOCK = [
545
+ s.MIN_VERSION = 1, s.MAX_VERSION = 40, s.PENALTY_N1 = 3, s.PENALTY_N2 = 3, s.PENALTY_N3 = 40, s.PENALTY_N4 = 10, s.ECC_CODEWORDS_PER_BLOCK = [
556
546
  // Version: (note that index 0 is for padding, and is set to an illegal value)
557
547
  //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
558
548
  [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
@@ -563,7 +553,7 @@ var W;
563
553
  // Quartile
564
554
  [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
565
555
  // High
566
- ], r.NUM_ERROR_CORRECTION_BLOCKS = [
556
+ ], s.NUM_ERROR_CORRECTION_BLOCKS = [
567
557
  // Version: (note that index 0 is for padding, and is set to an illegal value)
568
558
  //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
569
559
  [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
@@ -574,29 +564,29 @@ var W;
574
564
  // Quartile
575
565
  [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
576
566
  // High
577
- ], t.QrCode = r;
578
- function l(h, e, n) {
579
- if (e < 0 || e > 31 || h >>> e)
567
+ ], o.QrCode = s;
568
+ function r(p, e, n) {
569
+ if (e < 0 || e > 31 || p >>> e)
580
570
  throw new RangeError("Value out of range");
581
- for (let o = e - 1; o >= 0; o--)
582
- n.push(h >>> o & 1);
571
+ for (let t = e - 1; t >= 0; t--)
572
+ n.push(p >>> t & 1);
583
573
  }
584
- function c(h, e) {
585
- return (h >>> e & 1) != 0;
574
+ function l(p, e) {
575
+ return (p >>> e & 1) != 0;
586
576
  }
587
- function s(h) {
588
- if (!h)
577
+ function c(p) {
578
+ if (!p)
589
579
  throw new Error("Assertion error");
590
580
  }
591
- const a = class y {
581
+ const d = class I {
592
582
  /*-- Constructor (low level) and fields --*/
593
583
  // Creates a new QR Code segment with the given attributes and data.
594
584
  // The character count (numChars) must agree with the mode and the bit buffer length,
595
585
  // but the constraint isn't checked. The given bit buffer is cloned and stored.
596
- constructor(e, n, o) {
597
- if (this.mode = e, this.numChars = n, this.bitData = o, n < 0)
586
+ constructor(e, n, t) {
587
+ if (this.mode = e, this.numChars = n, this.bitData = t, n < 0)
598
588
  throw new RangeError("Invalid argument");
599
- this.bitData = o.slice();
589
+ this.bitData = t.slice();
600
590
  }
601
591
  /*-- Static factory functions (mid level) --*/
602
592
  // Returns a segment representing the given binary data encoded in
@@ -604,38 +594,38 @@ var W;
604
594
  // can be converted to UTF-8 bytes and encoded as a byte mode segment.
605
595
  static makeBytes(e) {
606
596
  let n = [];
607
- for (const o of e)
608
- l(o, 8, n);
609
- return new y(y.Mode.BYTE, e.length, n);
597
+ for (const t of e)
598
+ r(t, 8, n);
599
+ return new I(I.Mode.BYTE, e.length, n);
610
600
  }
611
601
  // Returns a segment representing the given string of decimal digits encoded in numeric mode.
612
602
  static makeNumeric(e) {
613
- if (!y.isNumeric(e))
603
+ if (!I.isNumeric(e))
614
604
  throw new RangeError("String contains non-numeric characters");
615
605
  let n = [];
616
- for (let o = 0; o < e.length; ) {
617
- const i = Math.min(e.length - o, 3);
618
- l(parseInt(e.substring(o, o + i), 10), i * 3 + 1, n), o += i;
606
+ for (let t = 0; t < e.length; ) {
607
+ const i = Math.min(e.length - t, 3);
608
+ r(parseInt(e.substring(t, t + i), 10), i * 3 + 1, n), t += i;
619
609
  }
620
- return new y(y.Mode.NUMERIC, e.length, n);
610
+ return new I(I.Mode.NUMERIC, e.length, n);
621
611
  }
622
612
  // Returns a segment representing the given text string encoded in alphanumeric mode.
623
613
  // The characters allowed are: 0 to 9, A to Z (uppercase only), space,
624
614
  // dollar, percent, asterisk, plus, hyphen, period, slash, colon.
625
615
  static makeAlphanumeric(e) {
626
- if (!y.isAlphanumeric(e))
616
+ if (!I.isAlphanumeric(e))
627
617
  throw new RangeError("String contains unencodable characters in alphanumeric mode");
628
- let n = [], o;
629
- for (o = 0; o + 2 <= e.length; o += 2) {
630
- let i = y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)) * 45;
631
- i += y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o + 1)), l(i, 11, n);
618
+ let n = [], t;
619
+ for (t = 0; t + 2 <= e.length; t += 2) {
620
+ let i = I.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)) * 45;
621
+ i += I.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t + 1)), r(i, 11, n);
632
622
  }
633
- return o < e.length && l(y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)), 6, n), new y(y.Mode.ALPHANUMERIC, e.length, n);
623
+ return t < e.length && r(I.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)), 6, n), new I(I.Mode.ALPHANUMERIC, e.length, n);
634
624
  }
635
625
  // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
636
626
  // The result may use various segment modes and switch modes to optimize the length of the bit stream.
637
627
  static makeSegments(e) {
638
- return e == "" ? [] : y.isNumeric(e) ? [y.makeNumeric(e)] : y.isAlphanumeric(e) ? [y.makeAlphanumeric(e)] : [y.makeBytes(y.toUtf8ByteArray(e))];
628
+ return e == "" ? [] : I.isNumeric(e) ? [I.makeNumeric(e)] : I.isAlphanumeric(e) ? [I.makeAlphanumeric(e)] : [I.makeBytes(I.toUtf8ByteArray(e))];
639
629
  }
640
630
  // Returns a segment representing an Extended Channel Interpretation
641
631
  // (ECI) designator with the given assignment value.
@@ -644,25 +634,25 @@ var W;
644
634
  if (e < 0)
645
635
  throw new RangeError("ECI assignment value out of range");
646
636
  if (e < 128)
647
- l(e, 8, n);
637
+ r(e, 8, n);
648
638
  else if (e < 16384)
649
- l(2, 2, n), l(e, 14, n);
639
+ r(2, 2, n), r(e, 14, n);
650
640
  else if (e < 1e6)
651
- l(6, 3, n), l(e, 21, n);
641
+ r(6, 3, n), r(e, 21, n);
652
642
  else
653
643
  throw new RangeError("ECI assignment value out of range");
654
- return new y(y.Mode.ECI, 0, n);
644
+ return new I(I.Mode.ECI, 0, n);
655
645
  }
656
646
  // Tests whether the given string can be encoded as a segment in numeric mode.
657
647
  // A string is encodable iff each character is in the range 0 to 9.
658
648
  static isNumeric(e) {
659
- return y.NUMERIC_REGEX.test(e);
649
+ return I.NUMERIC_REGEX.test(e);
660
650
  }
661
651
  // Tests whether the given string can be encoded as a segment in alphanumeric mode.
662
652
  // A string is encodable iff each character is in the following set: 0 to 9, A to Z
663
653
  // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
664
654
  static isAlphanumeric(e) {
665
- return y.ALPHANUMERIC_REGEX.test(e);
655
+ return I.ALPHANUMERIC_REGEX.test(e);
666
656
  }
667
657
  /*-- Methods --*/
668
658
  // Returns a new copy of the data bits of this segment.
@@ -672,175 +662,170 @@ var W;
672
662
  // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
673
663
  // the given version. The result is infinity if a segment has too many characters to fit its length field.
674
664
  static getTotalBits(e, n) {
675
- let o = 0;
665
+ let t = 0;
676
666
  for (const i of e) {
677
- const u = i.mode.numCharCountBits(n);
678
- if (i.numChars >= 1 << u)
667
+ const a = i.mode.numCharCountBits(n);
668
+ if (i.numChars >= 1 << a)
679
669
  return 1 / 0;
680
- o += 4 + u + i.bitData.length;
670
+ t += 4 + a + i.bitData.length;
681
671
  }
682
- return o;
672
+ return t;
683
673
  }
684
674
  // Returns a new array of bytes representing the given string encoded in UTF-8.
685
675
  static toUtf8ByteArray(e) {
686
676
  e = encodeURI(e);
687
677
  let n = [];
688
- for (let o = 0; o < e.length; o++)
689
- e.charAt(o) != "%" ? n.push(e.charCodeAt(o)) : (n.push(parseInt(e.substring(o + 1, o + 3), 16)), o += 2);
678
+ for (let t = 0; t < e.length; t++)
679
+ e.charAt(t) != "%" ? n.push(e.charCodeAt(t)) : (n.push(parseInt(e.substring(t + 1, t + 3), 16)), t += 2);
690
680
  return n;
691
681
  }
692
682
  };
693
- a.NUMERIC_REGEX = /^[0-9]*$/, a.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, a.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
694
- let p = a;
695
- t.QrSegment = a;
696
- })(W || (W = {}));
697
- ((t) => {
698
- ((r) => {
699
- const l = class {
683
+ d.NUMERIC_REGEX = /^[0-9]*$/, d.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, d.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
684
+ let f = d;
685
+ o.QrSegment = d;
686
+ })(X || (X = {}));
687
+ ((o) => {
688
+ ((s) => {
689
+ const r = class {
700
690
  // The QR Code can tolerate about 30% erroneous codewords
701
691
  /*-- Constructor and fields --*/
702
- constructor(s, a) {
703
- this.ordinal = s, this.formatBits = a;
692
+ constructor(c, d) {
693
+ this.ordinal = c, this.formatBits = d;
704
694
  }
705
695
  };
706
- l.LOW = new l(0, 1), l.MEDIUM = new l(1, 0), l.QUARTILE = new l(2, 3), l.HIGH = new l(3, 2), r.Ecc = l;
707
- })(t.QrCode || (t.QrCode = {}));
708
- })(W || (W = {}));
709
- ((t) => {
710
- ((r) => {
711
- const l = class {
696
+ r.LOW = new r(0, 1), r.MEDIUM = new r(1, 0), r.QUARTILE = new r(2, 3), r.HIGH = new r(3, 2), s.Ecc = r;
697
+ })(o.QrCode || (o.QrCode = {}));
698
+ })(X || (X = {}));
699
+ ((o) => {
700
+ ((s) => {
701
+ const r = class {
712
702
  /*-- Constructor and fields --*/
713
- constructor(s, a) {
714
- this.modeBits = s, this.numBitsCharCount = a;
703
+ constructor(c, d) {
704
+ this.modeBits = c, this.numBitsCharCount = d;
715
705
  }
716
706
  /*-- Method --*/
717
707
  // (Package-private) Returns the bit width of the character count field for a segment in
718
708
  // this mode in a QR Code at the given version number. The result is in the range [0, 16].
719
- numCharCountBits(s) {
720
- return this.numBitsCharCount[Math.floor((s + 7) / 17)];
709
+ numCharCountBits(c) {
710
+ return this.numBitsCharCount[Math.floor((c + 7) / 17)];
721
711
  }
722
712
  };
723
- l.NUMERIC = new l(1, [10, 12, 14]), l.ALPHANUMERIC = new l(2, [9, 11, 13]), l.BYTE = new l(4, [8, 16, 16]), l.KANJI = new l(8, [8, 10, 12]), l.ECI = new l(7, [0, 0, 0]), r.Mode = l;
724
- })(t.QrSegment || (t.QrSegment = {}));
725
- })(W || (W = {}));
726
- var Z = W;
727
- /**
728
- * @license qrcode.react
729
- * Copyright (c) Paul O'Shannessy
730
- * SPDX-License-Identifier: ISC
731
- */
713
+ r.NUMERIC = new r(1, [10, 12, 14]), r.ALPHANUMERIC = new r(2, [9, 11, 13]), r.BYTE = new r(4, [8, 16, 16]), r.KANJI = new r(8, [8, 10, 12]), r.ECI = new r(7, [0, 0, 0]), s.Mode = r;
714
+ })(o.QrSegment || (o.QrSegment = {}));
715
+ })(X || (X = {}));
716
+ var Z = X;
732
717
  var Et = {
733
718
  L: Z.QrCode.Ecc.LOW,
734
719
  M: Z.QrCode.Ecc.MEDIUM,
735
720
  Q: Z.QrCode.Ecc.QUARTILE,
736
721
  H: Z.QrCode.Ecc.HIGH
737
- }, be = 128, ye = "L", Pe = "#FFFFFF", De = "#000000", Te = !1, Oe = 1, Ct = 4, Rt = 0, wt = 0.1;
738
- function xe(t, r = 0) {
739
- const l = [];
740
- return t.forEach(function(c, s) {
741
- let a = null;
742
- c.forEach(function(p, h) {
743
- if (!p && a !== null) {
744
- l.push(
745
- `M${a + r} ${s + r}h${h - a}v1H${a + r}z`
746
- ), a = null;
722
+ }, be = 128, Se = "L", xe = "#FFFFFF", Pe = "#000000", De = !1, Oe = 1, wt = 4, Nt = 0, Rt = 0.1;
723
+ function Te(o, s = 0) {
724
+ const r = [];
725
+ return o.forEach(function(l, c) {
726
+ let d = null;
727
+ l.forEach(function(f, p) {
728
+ if (!f && d !== null) {
729
+ r.push(
730
+ `M${d + s} ${c + s}h${p - d}v1H${d + s}z`
731
+ ), d = null;
747
732
  return;
748
733
  }
749
- if (h === c.length - 1) {
750
- if (!p)
734
+ if (p === l.length - 1) {
735
+ if (!f)
751
736
  return;
752
- a === null ? l.push(`M${h + r},${s + r} h1v1H${h + r}z`) : l.push(
753
- `M${a + r},${s + r} h${h + 1 - a}v1H${a + r}z`
737
+ d === null ? r.push(`M${p + s},${c + s} h1v1H${p + s}z`) : r.push(
738
+ `M${d + s},${c + s} h${p + 1 - d}v1H${d + s}z`
754
739
  );
755
740
  return;
756
741
  }
757
- p && a === null && (a = h);
742
+ f && d === null && (d = p);
758
743
  });
759
- }), l.join("");
744
+ }), r.join("");
760
745
  }
761
- function Le(t, r) {
762
- return t.slice().map((l, c) => c < r.y || c >= r.y + r.h ? l : l.map((s, a) => a < r.x || a >= r.x + r.w ? s : !1));
746
+ function Le(o, s) {
747
+ return o.slice().map((r, l) => l < s.y || l >= s.y + s.h ? r : r.map((c, d) => d < s.x || d >= s.x + s.w ? c : !1));
763
748
  }
764
- function Mt(t, r, l, c) {
765
- if (c == null)
749
+ function vt(o, s, r, l) {
750
+ if (l == null)
766
751
  return null;
767
- const s = t.length + l * 2, a = Math.floor(r * wt), p = s / r, h = (c.width || a) * p, e = (c.height || a) * p, n = c.x == null ? t.length / 2 - h / 2 : c.x * p, o = c.y == null ? t.length / 2 - e / 2 : c.y * p, i = c.opacity == null ? 1 : c.opacity;
768
- let u = null;
769
- if (c.excavate) {
770
- let d = Math.floor(n), C = Math.floor(o), m = Math.ceil(h + n - d), I = Math.ceil(e + o - C);
771
- u = { x: d, y: C, w: m, h: I };
752
+ const c = o.length + r * 2, d = Math.floor(s * Rt), f = c / s, p = (l.width || d) * f, e = (l.height || d) * f, n = l.x == null ? o.length / 2 - p / 2 : l.x * f, t = l.y == null ? o.length / 2 - e / 2 : l.y * f, i = l.opacity == null ? 1 : l.opacity;
753
+ let a = null;
754
+ if (l.excavate) {
755
+ let u = Math.floor(n), E = Math.floor(t), g = Math.ceil(p + n - u), v = Math.ceil(e + t - E);
756
+ a = { x: u, y: E, w: g, h: v };
772
757
  }
773
- const f = c.crossOrigin;
774
- return { x: n, y: o, h: e, w: h, excavation: u, opacity: i, crossOrigin: f };
758
+ const h = l.crossOrigin;
759
+ return { x: n, y: t, h: e, w: p, excavation: a, opacity: i, crossOrigin: h };
775
760
  }
776
- function Nt(t, r) {
777
- return r != null ? Math.max(Math.floor(r), 0) : t ? Ct : Rt;
761
+ function Mt(o, s) {
762
+ return s != null ? Math.max(Math.floor(s), 0) : o ? wt : Nt;
778
763
  }
779
764
  function Be({
780
- value: t,
781
- level: r,
782
- minVersion: l,
783
- includeMargin: c,
784
- marginSize: s,
785
- imageSettings: a,
786
- size: p,
787
- boostLevel: h
765
+ value: o,
766
+ level: s,
767
+ minVersion: r,
768
+ includeMargin: l,
769
+ marginSize: c,
770
+ imageSettings: d,
771
+ size: f,
772
+ boostLevel: p
788
773
  }) {
789
- let e = O.useMemo(() => {
790
- const d = (Array.isArray(t) ? t : [t]).reduce((C, m) => (C.push(...Z.QrSegment.makeSegments(m)), C), []);
774
+ let e = x.useMemo(() => {
775
+ const u = (Array.isArray(o) ? o : [o]).reduce((E, g) => (E.push(...Z.QrSegment.makeSegments(g)), E), []);
791
776
  return Z.QrCode.encodeSegments(
792
- d,
793
- Et[r],
794
- l,
777
+ u,
778
+ Et[s],
779
+ r,
795
780
  void 0,
796
781
  void 0,
797
- h
782
+ p
798
783
  );
799
- }, [t, r, l, h]);
800
- const { cells: n, margin: o, numCells: i, calculatedImageSettings: u } = O.useMemo(() => {
801
- let f = e.getModules();
802
- const d = Nt(c, s), C = f.length + d * 2, m = Mt(
784
+ }, [o, s, r, p]);
785
+ const { cells: n, margin: t, numCells: i, calculatedImageSettings: a } = x.useMemo(() => {
786
+ let h = e.getModules();
787
+ const u = Mt(l, c), E = h.length + u * 2, g = vt(
788
+ h,
803
789
  f,
804
- p,
805
- d,
806
- a
790
+ u,
791
+ d
807
792
  );
808
793
  return {
809
- cells: f,
810
- margin: d,
811
- numCells: C,
812
- calculatedImageSettings: m
794
+ cells: h,
795
+ margin: u,
796
+ numCells: E,
797
+ calculatedImageSettings: g
813
798
  };
814
- }, [e, p, a, c, s]);
799
+ }, [e, f, d, l, c]);
815
800
  return {
816
801
  qrcode: e,
817
- margin: o,
802
+ margin: t,
818
803
  cells: n,
819
804
  numCells: i,
820
- calculatedImageSettings: u
805
+ calculatedImageSettings: a
821
806
  };
822
807
  }
823
- var It = (function() {
808
+ var yt = (function() {
824
809
  try {
825
810
  new Path2D().addPath(new Path2D());
826
811
  } catch {
827
812
  return !1;
828
813
  }
829
814
  return !0;
830
- })(), At = O.forwardRef(
831
- function(r, l) {
832
- const c = r, {
833
- value: s,
834
- size: a = be,
835
- level: p = ye,
836
- bgColor: h = Pe,
837
- fgColor: e = De,
838
- includeMargin: n = Te,
839
- minVersion: o = Oe,
815
+ })(), At = x.forwardRef(
816
+ function(s, r) {
817
+ const l = s, {
818
+ value: c,
819
+ size: d = be,
820
+ level: f = Se,
821
+ bgColor: p = xe,
822
+ fgColor: e = Pe,
823
+ includeMargin: n = De,
824
+ minVersion: t = Oe,
840
825
  boostLevel: i,
841
- marginSize: u,
842
- imageSettings: f
843
- } = c, C = de(c, [
826
+ marginSize: a,
827
+ imageSettings: h
828
+ } = l, E = me(l, [
844
829
  "value",
845
830
  "size",
846
831
  "level",
@@ -851,92 +836,92 @@ var It = (function() {
851
836
  "boostLevel",
852
837
  "marginSize",
853
838
  "imageSettings"
854
- ]), { style: m } = C, I = de(C, ["style"]), w = f == null ? void 0 : f.src, E = O.useRef(null), N = O.useRef(null), b = O.useCallback(
855
- (S) => {
856
- E.current = S, typeof l == "function" ? l(S) : l && (l.current = S);
839
+ ]), { style: g } = E, v = me(E, ["style"]), N = h?.src, C = x.useRef(null), R = x.useRef(null), S = x.useCallback(
840
+ (_) => {
841
+ C.current = _, typeof r == "function" ? r(_) : r && (r.current = _);
857
842
  },
858
- [l]
859
- ), [P, x] = O.useState(!1), { margin: T, cells: z, numCells: $, calculatedImageSettings: D } = Be({
860
- value: s,
861
- level: p,
862
- minVersion: o,
843
+ [r]
844
+ ), [D, A] = x.useState(!1), { margin: O, cells: $, numCells: H, calculatedImageSettings: P } = Be({
845
+ value: c,
846
+ level: f,
847
+ minVersion: t,
863
848
  boostLevel: i,
864
849
  includeMargin: n,
865
- marginSize: u,
866
- imageSettings: f,
867
- size: a
850
+ marginSize: a,
851
+ imageSettings: h,
852
+ size: d
868
853
  });
869
- O.useEffect(() => {
870
- if (E.current != null) {
871
- const S = E.current, M = S.getContext("2d");
854
+ x.useEffect(() => {
855
+ if (C.current != null) {
856
+ const _ = C.current, M = _.getContext("2d");
872
857
  if (!M)
873
858
  return;
874
- let A = z;
875
- const L = N.current, j = D != null && L !== null && L.complete && L.naturalHeight !== 0 && L.naturalWidth !== 0;
876
- j && D.excavation != null && (A = Le(
877
- z,
878
- D.excavation
859
+ let b = $;
860
+ const L = R.current, W = P != null && L !== null && L.complete && L.naturalHeight !== 0 && L.naturalWidth !== 0;
861
+ W && P.excavation != null && (b = Le(
862
+ $,
863
+ P.excavation
879
864
  ));
880
865
  const ne = window.devicePixelRatio || 1;
881
- S.height = S.width = a * ne;
882
- const re = a / $ * ne;
883
- M.scale(re, re), M.fillStyle = h, M.fillRect(0, 0, $, $), M.fillStyle = e, It ? M.fill(new Path2D(xe(A, T))) : z.forEach(function(V, G) {
884
- V.forEach(function(q, ae) {
885
- q && M.fillRect(ae + T, G + T, 1, 1);
866
+ _.height = _.width = d * ne;
867
+ const oe = d / H * ne;
868
+ M.scale(oe, oe), M.fillStyle = p, M.fillRect(0, 0, H, H), M.fillStyle = e, yt ? M.fill(new Path2D(Te(b, O))) : $.forEach(function(V, G) {
869
+ V.forEach(function(ce, de) {
870
+ ce && M.fillRect(de + O, G + O, 1, 1);
886
871
  });
887
- }), D && (M.globalAlpha = D.opacity), j && M.drawImage(
872
+ }), P && (M.globalAlpha = P.opacity), W && M.drawImage(
888
873
  L,
889
- D.x + T,
890
- D.y + T,
891
- D.w,
892
- D.h
874
+ P.x + O,
875
+ P.y + O,
876
+ P.w,
877
+ P.h
893
878
  );
894
879
  }
895
- }), O.useEffect(() => {
896
- x(!1);
897
- }, [w]);
898
- const H = ue({ height: a, width: a }, m);
899
- let Q = null;
900
- return w != null && (Q = /* @__PURE__ */ O.createElement(
880
+ }), x.useEffect(() => {
881
+ A(!1);
882
+ }, [N]);
883
+ const Y = he({ height: d, width: d }, g);
884
+ let j = null;
885
+ return N != null && (j = /* @__PURE__ */ x.createElement(
901
886
  "img",
902
887
  {
903
- src: w,
904
- key: w,
888
+ src: N,
889
+ key: N,
905
890
  style: { display: "none" },
906
891
  onLoad: () => {
907
- x(!0);
892
+ A(!0);
908
893
  },
909
- ref: N,
910
- crossOrigin: D == null ? void 0 : D.crossOrigin
894
+ ref: R,
895
+ crossOrigin: P?.crossOrigin
911
896
  }
912
- )), /* @__PURE__ */ O.createElement(O.Fragment, null, /* @__PURE__ */ O.createElement(
897
+ )), /* @__PURE__ */ x.createElement(x.Fragment, null, /* @__PURE__ */ x.createElement(
913
898
  "canvas",
914
- ue({
915
- style: H,
916
- height: a,
917
- width: a,
918
- ref: b,
899
+ he({
900
+ style: Y,
901
+ height: d,
902
+ width: d,
903
+ ref: S,
919
904
  role: "img"
920
- }, I)
921
- ), Q);
905
+ }, v)
906
+ ), j);
922
907
  }
923
908
  );
924
909
  At.displayName = "QRCodeCanvas";
925
- var Se = O.forwardRef(
926
- function(r, l) {
927
- const c = r, {
928
- value: s,
929
- size: a = be,
930
- level: p = ye,
931
- bgColor: h = Pe,
932
- fgColor: e = De,
933
- includeMargin: n = Te,
934
- minVersion: o = Oe,
910
+ var ke = x.forwardRef(
911
+ function(s, r) {
912
+ const l = s, {
913
+ value: c,
914
+ size: d = be,
915
+ level: f = Se,
916
+ bgColor: p = xe,
917
+ fgColor: e = Pe,
918
+ includeMargin: n = De,
919
+ minVersion: t = Oe,
935
920
  boostLevel: i,
936
- title: u,
937
- marginSize: f,
938
- imageSettings: d
939
- } = c, C = de(c, [
921
+ title: a,
922
+ marginSize: h,
923
+ imageSettings: u
924
+ } = l, E = me(l, [
940
925
  "value",
941
926
  "size",
942
927
  "level",
@@ -948,291 +933,278 @@ var Se = O.forwardRef(
948
933
  "title",
949
934
  "marginSize",
950
935
  "imageSettings"
951
- ]), { margin: m, cells: I, numCells: w, calculatedImageSettings: E } = Be({
952
- value: s,
953
- level: p,
954
- minVersion: o,
936
+ ]), { margin: g, cells: v, numCells: N, calculatedImageSettings: C } = Be({
937
+ value: c,
938
+ level: f,
939
+ minVersion: t,
955
940
  boostLevel: i,
956
941
  includeMargin: n,
957
- marginSize: f,
958
- imageSettings: d,
959
- size: a
942
+ marginSize: h,
943
+ imageSettings: u,
944
+ size: d
960
945
  });
961
- let N = I, b = null;
962
- d != null && E != null && (E.excavation != null && (N = Le(
963
- I,
964
- E.excavation
965
- )), b = /* @__PURE__ */ O.createElement(
946
+ let R = v, S = null;
947
+ u != null && C != null && (C.excavation != null && (R = Le(
948
+ v,
949
+ C.excavation
950
+ )), S = /* @__PURE__ */ x.createElement(
966
951
  "image",
967
952
  {
968
- href: d.src,
969
- height: E.h,
970
- width: E.w,
971
- x: E.x + m,
972
- y: E.y + m,
953
+ href: u.src,
954
+ height: C.h,
955
+ width: C.w,
956
+ x: C.x + g,
957
+ y: C.y + g,
973
958
  preserveAspectRatio: "none",
974
- opacity: E.opacity,
975
- crossOrigin: E.crossOrigin
959
+ opacity: C.opacity,
960
+ crossOrigin: C.crossOrigin
976
961
  }
977
962
  ));
978
- const P = xe(N, m);
979
- return /* @__PURE__ */ O.createElement(
963
+ const D = Te(R, g);
964
+ return /* @__PURE__ */ x.createElement(
980
965
  "svg",
981
- ue({
982
- height: a,
983
- width: a,
984
- viewBox: `0 0 ${w} ${w}`,
985
- ref: l,
966
+ he({
967
+ height: d,
968
+ width: d,
969
+ viewBox: `0 0 ${N} ${N}`,
970
+ ref: r,
986
971
  role: "img"
987
- }, C),
988
- !!u && /* @__PURE__ */ O.createElement("title", null, u),
989
- /* @__PURE__ */ O.createElement(
972
+ }, E),
973
+ !!a && /* @__PURE__ */ x.createElement("title", null, a),
974
+ /* @__PURE__ */ x.createElement(
990
975
  "path",
991
976
  {
992
- fill: h,
993
- d: `M0,0 h${w}v${w}H0z`,
977
+ fill: p,
978
+ d: `M0,0 h${N}v${N}H0z`,
994
979
  shapeRendering: "crispEdges"
995
980
  }
996
981
  ),
997
- /* @__PURE__ */ O.createElement("path", { fill: e, d: P, shapeRendering: "crispEdges" }),
998
- b
982
+ /* @__PURE__ */ x.createElement("path", { fill: e, d: D, shapeRendering: "crispEdges" }),
983
+ S
999
984
  );
1000
985
  }
1001
986
  );
1002
- Se.displayName = "QRCodeSVG";
1003
- const bt = (t, r) => ({
987
+ ke.displayName = "QRCodeSVG";
988
+ const It = (o, s) => ({
1004
989
  invitationType: qe.LINK,
1005
990
  resources: [
1006
991
  {
1007
- url: `conversations/${encodeURI(t)}`
992
+ url: `conversations/${encodeURI(o)}`
1008
993
  },
1009
- ...r
994
+ ...s
1010
995
  ]
1011
- }), yt = (t) => {
1012
- var l;
1013
- const r = ((l = t == null ? void 0 : t.invitationLink) == null ? void 0 : l.split("/").at(-1)) || "";
1014
- return `/${we}/${r}`;
1015
- }, Pt = (t, r) => r == null ? void 0 : r.find((l) => {
1016
- var a, p, h, e;
1017
- const c = (p = (a = t == null ? void 0 : t.id) == null ? void 0 : a.split("/")) == null ? void 0 : p.pop(), s = ((e = (h = l == null ? void 0 : l.url) == null ? void 0 : h.split("/")) == null ? void 0 : e.pop()) || "";
1018
- return s === c || decodeURI(s) === c;
1019
- }), Dt = (t) => {
1020
- var l, c;
1021
- const r = (l = t == null ? void 0 : t.messages) == null ? void 0 : l.filter(
1022
- (s) => {
1023
- var a;
1024
- return !!((a = s == null ? void 0 : s.custom_content) != null && a.attachments);
1025
- }
1026
- );
1027
- return ((c = r == null ? void 0 : r.flatMap((s) => {
1028
- var a, p;
1029
- return ((p = (a = s == null ? void 0 : s.custom_content) == null ? void 0 : a.attachments) == null ? void 0 : p.map((h) => ({
1030
- url: (h == null ? void 0 : h.url) || ""
1031
- }))) || [];
1032
- })) == null ? void 0 : c.filter((s) => !!(s != null && s.url))) || [];
1033
- }, Tt = ({
1034
- conversation: t,
1035
- locale: r,
1036
- onCloseModal: l,
1037
- modalDividers: c,
1038
- getConversation: s,
1039
- generateConversationLink: a,
1040
- chatExpiration: p,
1041
- chatExpirationDays: h,
996
+ }), bt = (o) => {
997
+ const s = o?.invitationLink?.split("/").at(-1) || "";
998
+ return `/${ve}/${s}`;
999
+ }, St = (o, s) => s?.find((r) => {
1000
+ const l = o?.id?.split("/")?.pop(), c = r?.url?.split("/")?.pop() || "";
1001
+ return c === l || decodeURI(c) === l;
1002
+ }), xt = (o) => o?.messages?.filter(
1003
+ (r) => !!r?.custom_content?.attachments
1004
+ )?.flatMap((r) => r?.custom_content?.attachments?.map((l) => ({
1005
+ url: l?.url || ""
1006
+ })) || [])?.filter((r) => !!r?.url) || [], Pt = ({
1007
+ conversation: o,
1008
+ locale: s,
1009
+ onCloseModal: r,
1010
+ modalDividers: l,
1011
+ getConversation: c,
1012
+ generateConversationLink: d,
1013
+ chatExpiration: f,
1014
+ chatExpirationDays: p,
1042
1015
  close: e,
1043
1016
  chatWarning: n,
1044
- shareLink: o,
1017
+ shareLink: t,
1045
1018
  shareCopyLink: i,
1046
- shareCopiedLink: u,
1047
- shareDescription: f,
1048
- shareRemoveAccessToUsers: d,
1049
- chatName: C,
1050
- getSharedConversations: m,
1051
- revokeSharedConversations: I,
1052
- baseUrl: w,
1053
- id: E,
1054
- clientSharedPage: N,
1055
- clientSharedProp: b
1019
+ shareCopiedLink: a,
1020
+ shareDescription: h,
1021
+ shareRemoveAccessToUsers: u,
1022
+ chatName: E,
1023
+ getSharedConversations: g,
1024
+ revokeSharedConversations: v,
1025
+ baseUrl: N,
1026
+ id: C,
1027
+ clientSharedPage: R,
1028
+ clientSharedProp: S
1056
1029
  }) => {
1057
- const [P, x] = F(null), [T, z] = F(), [$, D] = F(!1), [H, Q] = F(!1), [S, M] = F(), A = he(() => {
1058
- var G;
1059
- const V = w || window.location.origin;
1060
- if (w && w !== window.location.origin && N && b) {
1061
- const q = (G = P == null ? void 0 : P.split(`/${we}/`)) == null ? void 0 : G[1];
1062
- return `${V}/${N}?${b}=${q}`;
1030
+ const [D, A] = T(null), [O, $] = T(), [H, P] = T(!1), [Y, j] = T(!1), [_, M] = T(), b = J(() => {
1031
+ const V = N || window.location.origin;
1032
+ if (N && N !== window.location.origin && R && S) {
1033
+ const G = D?.split(`/${ve}/`)?.[1];
1034
+ return `${V}/${R}?${S}=${G}`;
1063
1035
  }
1064
- return `${V}/${r}${P}`;
1065
- }, [w, P, r, N, b]);
1036
+ return `${V}/${s}${D}`;
1037
+ }, [N, D, s, R, S]);
1066
1038
  ee(() => {
1067
1039
  (async () => {
1068
1040
  try {
1069
- const G = decodeURI(t ? t == null ? void 0 : t.id : `${E == null ? void 0 : E[0]}/${r}/${E == null ? void 0 : E[1]}`), q = `${decodeURI(G)}`, ae = await (s == null ? void 0 : s(q)), Ue = bt(
1041
+ const G = decodeURI(o ? o?.id : `${C?.[0]}/${s}/${C?.[1]}`), ce = `${decodeURI(G)}`, de = await c?.(ce), Ue = It(
1070
1042
  G,
1071
- Dt(ae)
1072
- ), ge = await (a == null ? void 0 : a(Ue)), oe = await (m == null ? void 0 : m(
1073
- le(ie.OTHERS)
1074
- ));
1075
- ge && oe && (D(!0), x(yt(ge)), z(
1076
- Pt(
1077
- t,
1078
- oe == null ? void 0 : oe.resources
1043
+ xt(de)
1044
+ ), pe = await d?.(Ue), ge = await g?.(
1045
+ re(se.OTHERS)
1046
+ );
1047
+ pe && ge && (P(!0), A(bt(pe)), $(
1048
+ St(
1049
+ o,
1050
+ ge?.resources
1079
1051
  )
1080
1052
  ));
1081
1053
  } catch (G) {
1082
- D(!1), console.error("Error sharing conversation", G);
1054
+ P(!1), console.error("Error sharing conversation", G);
1083
1055
  }
1084
1056
  })();
1085
1057
  }, [
1086
- t,
1087
- a,
1088
- s,
1089
- m,
1090
- E,
1091
- r
1058
+ o,
1059
+ d,
1060
+ c,
1061
+ g,
1062
+ C,
1063
+ s
1092
1064
  ]);
1093
- const L = _(() => {
1094
- l(), x(null), D(!1), Q(!1);
1095
- }, [l]), j = _(() => {
1096
- Q(!0), navigator.clipboard.writeText(A || "");
1097
- }, [A]), ne = async () => {
1065
+ const L = B(() => {
1066
+ r(), A(null), P(!1), j(!1);
1067
+ }, [r]), W = B(() => {
1068
+ j(!0), navigator.clipboard.writeText(b || "");
1069
+ }, [b]), ne = async () => {
1098
1070
  try {
1099
- M(!0), T && await (I == null ? void 0 : I({ resources: [T] }));
1071
+ M(!0), O && await v?.({ resources: [O] });
1100
1072
  } catch (V) {
1101
1073
  M(!1), console.error("Error revoking shared conversation", V);
1102
1074
  }
1103
- }, re = _(() => /* @__PURE__ */ g(
1104
- X,
1075
+ }, oe = B(() => /* @__PURE__ */ m(
1076
+ Q,
1105
1077
  {
1106
- buttonClassName: H ? "text-button-secondary" : "text-button-primary",
1107
- iconBefore: H ? /* @__PURE__ */ g(je, { width: 20, height: 20 }) : /* @__PURE__ */ g(Ve, { width: 20, height: 20 }),
1108
- title: H ? u ?? "Copied" : i ?? "Copy link",
1109
- disabled: H,
1110
- onClick: j
1078
+ buttonClassName: Y ? "text-button-secondary" : "text-button-primary",
1079
+ iconBefore: Y ? /* @__PURE__ */ m(je, { width: 20, height: 20 }) : /* @__PURE__ */ m(We, { width: 20, height: 20 }),
1080
+ title: Y ? a ?? "Copied" : i ?? "Copy link",
1081
+ disabled: Y,
1082
+ onClick: W
1111
1083
  }
1112
- ), [H, j, u, i]);
1113
- return /* @__PURE__ */ B(
1114
- fe,
1084
+ ), [Y, W, a, i]);
1085
+ return /* @__PURE__ */ y(
1086
+ ae,
1115
1087
  {
1116
- heading: o ?? "Share link",
1088
+ heading: t ?? "Share link",
1117
1089
  portalId: "share",
1118
- size: me.SM,
1119
- dividers: c,
1090
+ size: le.SM,
1091
+ dividers: l,
1120
1092
  onClose: L,
1121
1093
  closeButtonTitle: e ?? "Close",
1122
1094
  children: [
1123
- $ ? /* @__PURE__ */ B("div", { className: "share flex flex-col gap-y-4 px-6 pb-6 overflow-auto sm:p-0", children: [
1124
- t != null && t.name ? /* @__PURE__ */ B("div", { className: "flex share-info w-full", children: [
1125
- /* @__PURE__ */ g("p", { className: "share-info-title text-neutrals-800 mr-1 body-1", children: C ?? "Chat name:" }),
1126
- /* @__PURE__ */ g(
1095
+ H ? /* @__PURE__ */ y("div", { className: "share flex flex-col gap-y-4 px-6 pb-6 overflow-auto sm:p-0", children: [
1096
+ o?.name ? /* @__PURE__ */ y("div", { className: "flex share-info w-full", children: [
1097
+ /* @__PURE__ */ m("p", { className: "share-info-title text-neutrals-800 mr-1 body-1", children: E ?? "Chat name:" }),
1098
+ /* @__PURE__ */ m(
1127
1099
  "h3",
1128
1100
  {
1129
1101
  className: "flex-1 min-w-0 truncate",
1130
- title: t == null ? void 0 : t.name,
1131
- children: t == null ? void 0 : t.name
1102
+ title: o?.name,
1103
+ children: o?.name
1132
1104
  }
1133
1105
  )
1134
1106
  ] }) : null,
1135
- /* @__PURE__ */ B("div", { className: "flex share-info", children: [
1136
- /* @__PURE__ */ g("p", { className: "share-info-title text-neutrals-800 mr-1 body-1", children: p ?? "Link expiration date:" }),
1137
- /* @__PURE__ */ B("h3", { children: [
1107
+ /* @__PURE__ */ y("div", { className: "flex share-info", children: [
1108
+ /* @__PURE__ */ m("p", { className: "share-info-title text-neutrals-800 mr-1 body-1", children: f ?? "Link expiration date:" }),
1109
+ /* @__PURE__ */ y("h3", { children: [
1138
1110
  "3 ",
1139
- h ?? "days"
1111
+ p ?? "days"
1140
1112
  ] })
1141
1113
  ] }),
1142
- /* @__PURE__ */ g(
1143
- Se,
1114
+ /* @__PURE__ */ m(
1115
+ ke,
1144
1116
  {
1145
1117
  className: "self-center border border-neutrals-600 p-2 rounded min-h-[200px]",
1146
- value: A,
1118
+ value: b,
1147
1119
  size: 200
1148
1120
  }
1149
1121
  ),
1150
- /* @__PURE__ */ g("p", { className: "body-2 text-neutrals-1000", children: f ?? "Your name, special instructions, and any messages you add after sharing remain confidential." }),
1151
- /* @__PURE__ */ g(
1152
- Re,
1122
+ /* @__PURE__ */ m("p", { className: "body-2 text-neutrals-1000", children: h ?? "Your name, special instructions, and any messages you add after sharing remain confidential." }),
1123
+ /* @__PURE__ */ m(
1124
+ Ne,
1153
1125
  {
1154
1126
  containerClasses: "share-input-container",
1155
1127
  cssClass: "share-input",
1156
1128
  readonly: !0,
1157
- placeholder: A,
1158
- value: A,
1129
+ placeholder: b,
1130
+ value: b,
1159
1131
  inputId: "conversationLink",
1160
- iconAfterInput: re()
1132
+ iconAfterInput: oe()
1161
1133
  }
1162
1134
  )
1163
- ] }) : /* @__PURE__ */ g("div", { className: "flex justify-center items-center py-6 px-6", children: /* @__PURE__ */ g(Ce, {}) }),
1164
- $ ? t && T ? /* @__PURE__ */ g("div", { className: "remove-access", children: /* @__PURE__ */ g(
1165
- X,
1135
+ ] }) : /* @__PURE__ */ m("div", { className: "flex justify-center items-center py-6 px-6", children: /* @__PURE__ */ m(we, {}) }),
1136
+ H ? o && O ? /* @__PURE__ */ m("div", { className: "remove-access", children: /* @__PURE__ */ m(
1137
+ Q,
1166
1138
  {
1167
- title: d ?? "Remove access to all users",
1139
+ title: u ?? "Remove access to all users",
1168
1140
  buttonClassName: "remove-access-button py-3 px-4",
1169
1141
  isSmallButton: !0,
1170
- disabled: S,
1142
+ disabled: _,
1171
1143
  onClick: ne
1172
1144
  }
1173
- ) }) : /* @__PURE__ */ g("p", { className: "body-2 text-neutrals-800 share-footer", children: n ?? "This chat has not been shared with anyone yet." }) : /* @__PURE__ */ g("div", {})
1145
+ ) }) : /* @__PURE__ */ m("p", { className: "body-2 text-neutrals-800 share-footer", children: n ?? "This chat has not been shared with anyone yet." }) : /* @__PURE__ */ m("div", {})
1174
1146
  ]
1175
1147
  }
1176
1148
  );
1177
- }, Ot = ({
1178
- conversation: t,
1179
- onCloseModal: r,
1180
- renameConversation: l,
1181
- locale: c,
1182
- disableModalDividers: s,
1183
- titles: a,
1184
- isSmallButton: p
1149
+ }, Dt = ({
1150
+ conversation: o,
1151
+ onCloseModal: s,
1152
+ renameConversation: r,
1153
+ locale: l,
1154
+ disableModalDividers: c,
1155
+ titles: d,
1156
+ isSmallButton: f
1185
1157
  }) => {
1186
- const [h, e] = F((t == null ? void 0 : t.name) || ""), n = (i) => {
1158
+ const [p, e] = T(o?.name || ""), n = (i) => {
1187
1159
  e(i);
1188
- }, o = () => {
1189
- const i = `${t == null ? void 0 : t.folderId}/${encodeURIComponent(pe(h))}-${(/* @__PURE__ */ new Date()).getTime()}`;
1190
- l(
1191
- `conversations/${t.id}`,
1160
+ }, t = () => {
1161
+ const i = `${o?.folderId}/${encodeURIComponent(fe(p))}-${(/* @__PURE__ */ new Date()).getTime()}`;
1162
+ r(
1163
+ `conversations/${o.id}`,
1192
1164
  `conversations/${i}`
1193
1165
  );
1194
1166
  };
1195
- return /* @__PURE__ */ B(
1196
- fe,
1167
+ return /* @__PURE__ */ y(
1168
+ ae,
1197
1169
  {
1198
- heading: (a == null ? void 0 : a.renameTitle) ?? "Rename conversation",
1170
+ heading: d?.renameTitle ?? "Rename conversation",
1199
1171
  portalId: "rename-conversation",
1200
1172
  containerClassName: "rename-conversation-popup",
1201
- size: me.SM,
1202
- dividers: !s,
1203
- onClose: r,
1204
- closeButtonTitle: (a == null ? void 0 : a.close) ?? "Cancel",
1173
+ size: le.SM,
1174
+ dividers: !c,
1175
+ onClose: s,
1176
+ closeButtonTitle: d?.close ?? "Cancel",
1205
1177
  children: [
1206
- /* @__PURE__ */ g("div", { className: "py-4 px-6 sm:px-0", lang: c, children: /* @__PURE__ */ g(
1207
- He,
1178
+ /* @__PURE__ */ m("div", { className: "py-4 px-6 sm:px-0", lang: l, children: /* @__PURE__ */ m(
1179
+ Ye,
1208
1180
  {
1209
1181
  inputId: "rename",
1210
- value: h,
1182
+ value: p,
1211
1183
  onChange: n,
1212
1184
  cssClass: "w-full"
1213
1185
  }
1214
1186
  ) }),
1215
- /* @__PURE__ */ B("div", { className: "flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer", children: [
1216
- /* @__PURE__ */ g(
1217
- X,
1187
+ /* @__PURE__ */ y("div", { className: "flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer", children: [
1188
+ /* @__PURE__ */ m(
1189
+ Q,
1218
1190
  {
1219
1191
  buttonClassName: "cancel-button",
1220
- title: (a == null ? void 0 : a.cancel) ?? "Cancel",
1221
- isSmallButton: p,
1192
+ title: d?.cancel ?? "Cancel",
1193
+ isSmallButton: f,
1222
1194
  onClick: (i) => {
1223
- i.stopPropagation(), r();
1195
+ i.stopPropagation(), s();
1224
1196
  }
1225
1197
  }
1226
1198
  ),
1227
- /* @__PURE__ */ g(
1228
- X,
1199
+ /* @__PURE__ */ m(
1200
+ Q,
1229
1201
  {
1230
1202
  buttonClassName: "text-button-primary text-button-primary",
1231
- title: (a == null ? void 0 : a.save) ?? "Rename",
1232
- isSmallButton: p,
1233
- disabled: !h,
1203
+ title: d?.save ?? "Rename",
1204
+ isSmallButton: f,
1205
+ disabled: !p,
1234
1206
  onClick: (i) => {
1235
- i.stopPropagation(), o();
1207
+ i.stopPropagation(), t();
1236
1208
  }
1237
1209
  }
1238
1210
  )
@@ -1240,519 +1212,681 @@ const bt = (t, r) => ({
1240
1212
  ]
1241
1213
  }
1242
1214
  );
1243
- }, xt = ({
1244
- conversation: t,
1245
- conversationStyles: r,
1246
- shareConversationProps: l,
1247
- onConversationDelete: c,
1248
- getConversation: s,
1249
- getFileBlob: a,
1250
- renameConversation: p,
1251
- triggerButton: h,
1252
- locale: e
1215
+ }, Ot = ({
1216
+ conversation: o,
1217
+ conversationStyles: s,
1218
+ shareConversationProps: r,
1219
+ onConversationDelete: l,
1220
+ getConversation: c,
1221
+ getFileBlob: d,
1222
+ renameConversation: f,
1223
+ triggerButton: p,
1224
+ locale: e,
1225
+ isDisabled: n
1253
1226
  }) => {
1254
- var P;
1255
- const n = he(() => {
1256
- var T, z, $, D, H, Q, S, M, A, L;
1257
- const x = [
1227
+ const t = J(() => {
1228
+ const A = [
1258
1229
  {
1259
- key: k.DELETE,
1260
- title: ((T = r == null ? void 0 : r.titles) == null ? void 0 : T.delete) ?? "Delete",
1261
- icon: (z = r.actionsIcons) == null ? void 0 : z[k.DELETE]
1230
+ key: U.DELETE,
1231
+ title: s?.titles?.delete ?? "Delete",
1232
+ icon: s.actionsIcons?.[U.DELETE]
1262
1233
  }
1263
1234
  ];
1264
- return (D = ($ = t == null ? void 0 : t.model) == null ? void 0 : $.id) != null && D.endsWith(ve) ? x : [
1265
- ...t.isShared ? [] : [
1235
+ return o?.model?.id?.endsWith(et) ? A : [
1236
+ ...o.isShared ? [] : [
1266
1237
  {
1267
- key: k.SHARE,
1268
- title: ((H = r == null ? void 0 : r.titles) == null ? void 0 : H.share) ?? "Share",
1269
- icon: (Q = r.actionsIcons) == null ? void 0 : Q[k.SHARE]
1238
+ key: U.SHARE,
1239
+ title: s?.titles?.share ?? "Share",
1240
+ icon: s.actionsIcons?.[U.SHARE]
1270
1241
  },
1271
1242
  {
1272
- key: k.RENAME,
1273
- title: ((S = r == null ? void 0 : r.titles) == null ? void 0 : S.rename) ?? "Rename",
1274
- icon: (M = r.actionsIcons) == null ? void 0 : M[k.RENAME]
1243
+ key: U.RENAME,
1244
+ title: s?.titles?.rename ?? "Rename",
1245
+ icon: s.actionsIcons?.[U.RENAME]
1275
1246
  }
1276
1247
  ],
1277
1248
  {
1278
- key: k.EXPORT,
1279
- title: ((A = r == null ? void 0 : r.titles) == null ? void 0 : A.export) ?? "Export",
1280
- icon: (L = r.actionsIcons) == null ? void 0 : L[k.EXPORT]
1249
+ key: U.EXPORT,
1250
+ title: s?.titles?.export ?? "Export",
1251
+ icon: s.actionsIcons?.[U.EXPORT]
1281
1252
  },
1282
- ...x
1253
+ ...A
1283
1254
  ];
1284
1255
  }, [
1285
- t.isShared,
1286
- (P = t == null ? void 0 : t.model) == null ? void 0 : P.id,
1287
- r.titles,
1288
- r.actionsIcons
1289
- ]), [o, i] = F(Y.Closed), [u, f] = F(Y.Closed), [d, C] = F(Y.Closed), m = _(() => {
1290
- i(Y.Closed);
1291
- }, [i]), I = _(() => {
1292
- f(Y.Closed);
1293
- }, [f]), w = _(() => {
1294
- C(Y.Closed);
1295
- }, [C]), E = _(() => {
1296
- c(t), m();
1297
- }, [t, c, m]), N = _(
1298
- (x, T) => {
1299
- p(x, T), w();
1256
+ o.isShared,
1257
+ o?.model?.id,
1258
+ s.titles,
1259
+ s.actionsIcons
1260
+ ]), [i, a] = T(z.Closed), [h, u] = T(z.Closed), [E, g] = T(z.Closed), v = B(() => {
1261
+ a(z.Closed);
1262
+ }, [a]), N = B(() => {
1263
+ u(z.Closed);
1264
+ }, [u]), C = B(() => {
1265
+ g(z.Closed);
1266
+ }, [g]), R = B(() => {
1267
+ l(o), v();
1268
+ }, [o, l, v]), S = B(
1269
+ (A, O) => {
1270
+ f(A, O), C();
1300
1271
  },
1301
- [p, w]
1272
+ [f, C]
1302
1273
  );
1303
- return /* @__PURE__ */ B(v, { children: [
1304
- /* @__PURE__ */ g(
1305
- Ye,
1274
+ return /* @__PURE__ */ y(q, { children: [
1275
+ /* @__PURE__ */ m(
1276
+ Re,
1306
1277
  {
1307
- containerClassName: "invisible ml-3 group-hover:visible",
1308
- triggerButton: h ?? /* @__PURE__ */ g(Lt, {}),
1309
- options: n,
1278
+ containerClassName: "ml-3 group-hover:visible",
1279
+ triggerButton: p ?? /* @__PURE__ */ m(Tt, { disabled: n }),
1280
+ options: t,
1310
1281
  openedClassName: "action-menu-opened",
1311
- onOptionSelect: (x) => {
1312
- x === k.DELETE && i(Y.Opened), x === k.SHARE && f(Y.Opened), x === k.RENAME && C(Y.Opened), x === k.EXPORT && s(decodeURI(t.id)).then((T) => {
1313
- ht(T, a).then((z) => {
1314
- pt(
1315
- `data:application/zip;base64,${z}`,
1282
+ onOptionSelect: (A) => {
1283
+ A === U.DELETE && a(z.Opened), A === U.SHARE && u(z.Opened), A === U.RENAME && g(z.Opened), A === U.EXPORT && c(decodeURI(o.id)).then((O) => {
1284
+ mt(O, d).then(($) => {
1285
+ gt(
1286
+ `data:application/zip;base64,${$}`,
1316
1287
  `chat_with_attachments_${(/* @__PURE__ */ new Date()).toLocaleDateString()}.dial`
1317
1288
  );
1318
1289
  });
1319
1290
  });
1320
- }
1291
+ },
1292
+ disabled: n
1321
1293
  }
1322
1294
  ),
1323
- o === Y.Opened && /* @__PURE__ */ g(
1324
- it,
1295
+ i === z.Opened && /* @__PURE__ */ m(
1296
+ at,
1325
1297
  {
1326
- titles: r.titles,
1298
+ titles: s.titles,
1327
1299
  locale: e,
1328
- disableModalDividers: r.disableModalDividers,
1329
- isSmallButton: r.isSmallModalButton,
1330
- deleteConversation: E,
1331
- onCloseModal: m
1300
+ disableModalDividers: s.disableModalDividers,
1301
+ isSmallButton: s.isSmallModalButton,
1302
+ deleteConversation: R,
1303
+ onCloseModal: v
1332
1304
  }
1333
1305
  ),
1334
- u === Y.Opened && /* @__PURE__ */ g(
1335
- Tt,
1306
+ h === z.Opened && /* @__PURE__ */ m(
1307
+ Pt,
1336
1308
  {
1337
- conversation: t,
1309
+ conversation: o,
1338
1310
  locale: e,
1339
- onCloseModal: I,
1340
- ...l
1311
+ onCloseModal: N,
1312
+ ...r
1341
1313
  }
1342
1314
  ),
1343
- d === Y.Opened && /* @__PURE__ */ g(
1344
- Ot,
1315
+ E === z.Opened && /* @__PURE__ */ m(
1316
+ Dt,
1345
1317
  {
1346
- conversation: t,
1318
+ conversation: o,
1347
1319
  locale: e,
1348
- titles: r.titles,
1349
- renameConversation: N,
1350
- onCloseModal: w,
1351
- disableModalDividers: r.disableModalDividers,
1352
- isSmallButton: r.isSmallModalButton
1320
+ titles: s.titles,
1321
+ renameConversation: S,
1322
+ onCloseModal: C,
1323
+ disableModalDividers: s.disableModalDividers,
1324
+ isSmallButton: s.isSmallModalButton
1353
1325
  }
1354
1326
  )
1355
1327
  ] });
1356
- }, Lt = () => /* @__PURE__ */ g("div", { className: "cursor-pointer flex items-center justify-center w-[24px]", children: /* @__PURE__ */ g(
1357
- Xe,
1328
+ }, Tt = ({ disabled: o }) => /* @__PURE__ */ m(
1329
+ "div",
1358
1330
  {
1359
- width: 20,
1360
- height: 20,
1361
- stroke: 2,
1362
- className: "text-primary"
1331
+ className: k(
1332
+ "flex items-center justify-center w-[24px]",
1333
+ o ? "cursor-not-allowed" : "cursor-pointer"
1334
+ ),
1335
+ children: /* @__PURE__ */ m(
1336
+ Ve,
1337
+ {
1338
+ width: 20,
1339
+ height: 20,
1340
+ stroke: 2,
1341
+ className: "text-primary"
1342
+ }
1343
+ )
1363
1344
  }
1364
- ) }), Fe = ({
1365
- conversation: t,
1366
- selectedConversationId: r,
1367
- searchQuery: l,
1368
- onConversationClick: c,
1369
- actions: s,
1370
- locale: a,
1345
+ ), Fe = ({
1346
+ conversation: o,
1347
+ selectedConversationId: s,
1348
+ searchQuery: r,
1349
+ onConversationClick: l,
1350
+ actions: c,
1351
+ locale: d,
1352
+ isDisabled: f,
1371
1353
  conversationStyles: p,
1372
- shareConversationProps: h
1354
+ shareConversationProps: e
1373
1355
  }) => {
1374
- const e = ze(null), n = pe(t == null ? void 0 : t.name);
1356
+ const n = ze(null), t = fe(o?.name);
1375
1357
  return ee(() => {
1376
- var o, i;
1377
- if ((t == null ? void 0 : t.id) === r && e != null && e.current) {
1378
- const u = (i = (o = e.current.parentElement) == null ? void 0 : o.parentElement) == null ? void 0 : i.parentElement;
1379
- if (u) {
1380
- const f = e.current.getBoundingClientRect(), d = u.getBoundingClientRect(), C = f.height, m = d.height, w = f.top - d.top + u.scrollTop - (m / 2 - C / 2);
1381
- u.scrollTo({
1382
- top: w,
1358
+ if (o?.id === s && n?.current) {
1359
+ const i = n.current.parentElement?.parentElement?.parentElement;
1360
+ if (i) {
1361
+ const a = n.current.getBoundingClientRect(), h = i.getBoundingClientRect(), u = a.height, E = h.height, v = a.top - h.top + i.scrollTop - (E / 2 - u / 2);
1362
+ i.scrollTo({
1363
+ top: v,
1383
1364
  behavior: "smooth"
1384
1365
  });
1385
1366
  }
1386
1367
  }
1387
- }, [t, r]), /* @__PURE__ */ B(
1368
+ }, [o, s]), /* @__PURE__ */ y(
1388
1369
  "div",
1389
1370
  {
1390
- ref: e,
1391
- className: J(
1392
- "flex justify-between items-center py-2 px-3 border-transparent relative group cursor-pointer border hover:border-hues-600",
1371
+ ref: n,
1372
+ className: k(
1373
+ "flex justify-between items-center py-2 px-3 border-transparent relative group border",
1393
1374
  "conversation-item",
1394
- r === (t == null ? void 0 : t.id) && "bg-hues-100 conversation-item-active"
1375
+ s === o?.id && "bg-hues-100 conversation-item-active",
1376
+ f ? "cursor-not-allowed" : "cursor-pointer hover:border-hues-600"
1395
1377
  ),
1396
- onClick: () => c(t.folderId, t == null ? void 0 : t.id),
1397
- title: n,
1378
+ onClick: () => !f && l(o.folderId, o?.id),
1379
+ title: f ? p?.titles?.noActionsAllowed : t,
1398
1380
  children: [
1399
- /* @__PURE__ */ B("div", { className: "flex flex-1 min-w-0 items-center", children: [
1381
+ /* @__PURE__ */ y("div", { className: "flex flex-1 min-w-0 items-center", children: [
1400
1382
  p.conversationItemIcon ? p.conversationItemIcon : null,
1401
- /* @__PURE__ */ g(
1383
+ /* @__PURE__ */ m(
1402
1384
  "h3",
1403
1385
  {
1404
- className: J(
1386
+ className: k(
1405
1387
  "truncate font-semibold text-neutrals-1000 sm:body-2",
1406
1388
  "conversation-item-text",
1407
- r === (t == null ? void 0 : t.id) ? "conversation-item-text-active" : ""
1389
+ s === o?.id ? "conversation-item-text-active" : ""
1408
1390
  ),
1409
- title: n,
1410
- children: l != null && l.length ? /* @__PURE__ */ g(
1391
+ title: f ? p?.titles?.noActionsAllowed : t,
1392
+ children: r?.length ? /* @__PURE__ */ m(
1411
1393
  Qe,
1412
1394
  {
1413
- text: n,
1414
- highlightText: l
1395
+ text: t,
1396
+ highlightText: r
1415
1397
  }
1416
- ) : n
1398
+ ) : t
1417
1399
  }
1418
1400
  )
1419
1401
  ] }),
1420
- /* @__PURE__ */ g(
1421
- xt,
1402
+ /* @__PURE__ */ m(
1403
+ Ot,
1422
1404
  {
1423
- locale: a,
1405
+ locale: d,
1424
1406
  conversationStyles: p,
1425
- conversation: t,
1426
- onConversationDelete: s.deleteConversation,
1427
- getConversation: s.getConversation,
1428
- getFileBlob: s.getFileBlob,
1429
- renameConversation: s.renameConversation,
1430
- shareConversationProps: h
1407
+ conversation: o,
1408
+ onConversationDelete: c.deleteConversation,
1409
+ getConversation: c.getConversation,
1410
+ getFileBlob: c.getFileBlob,
1411
+ renameConversation: c.renameConversation,
1412
+ shareConversationProps: e,
1413
+ isDisabled: f
1431
1414
  }
1432
1415
  )
1433
1416
  ]
1434
1417
  }
1435
1418
  );
1436
- }, Bt = ({
1437
- handleConversationClick: t,
1438
- actions: r,
1439
- selectedConversationId: l,
1440
- groupLabel: c,
1441
- conversationStyles: s,
1442
- groupedConversations: a,
1443
- shareConversationProps: p,
1444
- locale: h
1419
+ }, Lt = ({
1420
+ handleConversationClick: o,
1421
+ actions: s,
1422
+ selectedConversationId: r,
1423
+ groupLabel: l,
1424
+ conversationStyles: c,
1425
+ groupedConversations: d,
1426
+ shareConversationProps: f,
1427
+ locale: p,
1428
+ isDisabled: e
1445
1429
  }) => {
1446
- const [e, n] = F(!1), o = _(() => {
1447
- n((i) => !i);
1448
- }, [n]);
1449
- return /* @__PURE__ */ B("div", { children: [
1450
- /* @__PURE__ */ B(
1430
+ const [n, t] = T(!1), i = B(() => {
1431
+ t((a) => !a);
1432
+ }, [t]);
1433
+ return /* @__PURE__ */ y("div", { children: [
1434
+ /* @__PURE__ */ y(
1451
1435
  "div",
1452
1436
  {
1453
1437
  className: "inline-flex gap-1 items-center text-neutrals-700 mb-3 cursor-pointer conversation-group-items-title",
1454
- onClick: o,
1438
+ onClick: i,
1455
1439
  children: [
1456
- /* @__PURE__ */ g(
1457
- We,
1440
+ /* @__PURE__ */ m(
1441
+ Xe,
1458
1442
  {
1459
- className: J(
1443
+ className: k(
1460
1444
  "w-3 h-3 conversation-group-items-arrow",
1461
- e ? "rotate-[90deg]" : "rotate-0"
1445
+ n ? "rotate-[90deg]" : "rotate-0"
1462
1446
  )
1463
1447
  }
1464
1448
  ),
1465
- /* @__PURE__ */ g("span", { className: "body-3 conversation-group-items-title-text", children: lt(c, s == null ? void 0 : s.titles) })
1449
+ /* @__PURE__ */ m("span", { className: "body-3 conversation-group-items-title-text", children: it(l, c?.titles) })
1466
1450
  ]
1467
1451
  }
1468
1452
  ),
1469
- !e && /* @__PURE__ */ g(
1453
+ !n && /* @__PURE__ */ m(
1470
1454
  "div",
1471
1455
  {
1472
- className: J(
1456
+ className: k(
1473
1457
  "flex flex-col gap-y-3",
1474
1458
  "conversation-group-items"
1475
1459
  ),
1476
- children: Ne(a).map(
1477
- (i) => /* @__PURE__ */ g(
1460
+ children: ye(d).map(
1461
+ (a) => /* @__PURE__ */ m(
1478
1462
  Fe,
1479
1463
  {
1480
- locale: h,
1481
- conversationStyles: s,
1482
- conversation: i,
1483
- selectedConversationId: l,
1484
- onConversationClick: t,
1485
- actions: r,
1486
- shareConversationProps: p
1464
+ locale: p,
1465
+ isDisabled: e,
1466
+ conversationStyles: c,
1467
+ conversation: a,
1468
+ selectedConversationId: r,
1469
+ onConversationClick: o,
1470
+ actions: s,
1471
+ shareConversationProps: f
1487
1472
  },
1488
- i.id || i.name
1473
+ a.id || a.name
1489
1474
  )
1490
1475
  )
1491
1476
  }
1492
1477
  )
1493
- ] }, c);
1494
- }, St = ({
1495
- searchQuery: t,
1496
- isExpandedSearch: r,
1497
- titles: l,
1498
- searchIcon: c,
1499
- onSearchConversations: s,
1500
- toggleSearchField: a
1501
- }) => /* @__PURE__ */ g(v, { children: r ? /* @__PURE__ */ g(
1502
- Re,
1478
+ ] }, l);
1479
+ }, Bt = ({
1480
+ searchQuery: o,
1481
+ isExpandedSearch: s,
1482
+ titles: r,
1483
+ searchIcon: l,
1484
+ onSearchConversations: c,
1485
+ toggleSearchField: d
1486
+ }) => /* @__PURE__ */ m(q, { children: s ? /* @__PURE__ */ m(
1487
+ Ne,
1503
1488
  {
1504
1489
  inputId: "conversations-search",
1505
- placeholder: (l == null ? void 0 : l.searchPlaceholder) ?? "Search",
1490
+ placeholder: r?.searchPlaceholder ?? "Search",
1506
1491
  containerClasses: "conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",
1507
1492
  cssClass: "h-auto",
1508
- value: t,
1509
- iconAfterInput: /* @__PURE__ */ g(
1493
+ value: o,
1494
+ iconAfterInput: /* @__PURE__ */ m(
1510
1495
  Ge,
1511
1496
  {
1512
1497
  buttonClassName: "text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",
1513
- onClick: a,
1514
- icon: /* @__PURE__ */ g(Ke, {})
1498
+ onClick: d,
1499
+ icon: /* @__PURE__ */ m(Ke, {})
1515
1500
  }
1516
1501
  ),
1517
- onChange: s
1502
+ onChange: c
1518
1503
  }
1519
- ) : /* @__PURE__ */ g(
1520
- X,
1504
+ ) : /* @__PURE__ */ m(
1505
+ Q,
1521
1506
  {
1522
1507
  buttonClassName: "text-button-tertiary p-0 search-button",
1523
- iconBefore: c || /* @__PURE__ */ g(Ze, { className: "w-5 h-5" }),
1524
- onClick: a
1508
+ iconBefore: l || /* @__PURE__ */ m(Ze, { className: "w-5 h-5" }),
1509
+ onClick: d
1525
1510
  }
1526
- ) }), Ft = ({
1527
- conversations: t,
1528
- selectedConversationId: r,
1529
- searchQuery: l,
1530
- conversationStyles: c,
1531
- handleConversationClick: s,
1532
- actions: a,
1533
- locale: p,
1534
- shareConversationProps: h
1511
+ ) }), kt = ({
1512
+ conversations: o,
1513
+ selectedConversationId: s,
1514
+ searchQuery: r,
1515
+ conversationStyles: l,
1516
+ handleConversationClick: c,
1517
+ actions: d,
1518
+ locale: f,
1519
+ shareConversationProps: p
1535
1520
  }) => {
1536
- var o;
1537
- const [e, n] = F([]);
1521
+ const [e, n] = T([]);
1538
1522
  return ee(() => {
1539
1523
  n(
1540
- Ne(
1541
- t == null ? void 0 : t.filter(
1542
- (i) => {
1543
- var u;
1544
- return (u = pe(i == null ? void 0 : i.name)) == null ? void 0 : u.includes(
1545
- l || ""
1546
- );
1547
- }
1524
+ ye(
1525
+ o?.filter(
1526
+ (t) => fe(t?.name)?.includes(
1527
+ r || ""
1528
+ )
1548
1529
  )
1549
1530
  )
1550
1531
  );
1551
- }, [t, l]), /* @__PURE__ */ g(v, { children: e != null && e.length ? e.map((i) => /* @__PURE__ */ g(
1532
+ }, [o, r]), /* @__PURE__ */ m(q, { children: e?.length ? e.map((t) => /* @__PURE__ */ m(
1552
1533
  Fe,
1553
1534
  {
1554
- locale: p,
1555
- conversationStyles: c,
1556
- conversation: i,
1557
- searchQuery: l,
1558
- selectedConversationId: r,
1559
- onConversationClick: s,
1560
- actions: a,
1561
- shareConversationProps: h
1535
+ locale: f,
1536
+ conversationStyles: l,
1537
+ conversation: t,
1538
+ searchQuery: r,
1539
+ selectedConversationId: s,
1540
+ onConversationClick: c,
1541
+ actions: d,
1542
+ shareConversationProps: p
1562
1543
  },
1563
- i.id
1564
- )) : /* @__PURE__ */ g("h3", { className: "text-neutrals-800", children: ((o = c == null ? void 0 : c.titles) == null ? void 0 : o.noConversation) ?? "No conversations yet" }) });
1565
- }, Ut = ({ titles: t }) => /* @__PURE__ */ B("div", { className: "p-8 text-center flex flex-col", children: [
1566
- /* @__PURE__ */ g("p", { className: "text-neutrals-800", children: (t == null ? void 0 : t.noConversation) ?? "No conversations yet" }),
1567
- /* @__PURE__ */ g("p", { className: "text-sm text-neutrals-800 mt-2", children: (t == null ? void 0 : t.clickNewChat) ?? 'Click "New Chat" to start a conversation' })
1568
- ] }), Wt = ({
1569
- handleConversationClick: t,
1570
- selectedConversationId: r,
1571
- actions: l,
1572
- children: c,
1573
- isCollapsed: s,
1574
- conversationStyles: a,
1544
+ t.id
1545
+ )) : /* @__PURE__ */ m("h3", { className: "text-neutrals-800", children: l?.titles?.noConversation ?? "No conversations yet" }) });
1546
+ }, Ft = ({ titles: o }) => /* @__PURE__ */ y("div", { className: "p-8 text-center flex flex-col", children: [
1547
+ /* @__PURE__ */ m("p", { className: "text-neutrals-800", children: o?.noConversation ?? "No conversations yet" }),
1548
+ /* @__PURE__ */ m("p", { className: "text-sm text-neutrals-800 mt-2", children: o?.clickNewChat ?? 'Click "New Chat" to start a conversation' })
1549
+ ] }), Kt = ({
1550
+ handleConversationClick: o,
1551
+ selectedConversationId: s,
1552
+ actions: r,
1553
+ children: l,
1554
+ isCollapsed: c,
1555
+ isStreaming: d,
1556
+ conversationStyles: f,
1575
1557
  conversations: p,
1576
- locale: h,
1577
- sharedConversations: e,
1578
- setConversations: n,
1579
- setSharedConversations: o,
1580
- shareConversationProps: i,
1581
- handleSelectedConversationRemove: u
1558
+ locale: e,
1559
+ sharedConversations: n,
1560
+ setConversations: t,
1561
+ setSharedConversations: i,
1562
+ shareConversationProps: a,
1563
+ handleSelectedConversationRemove: h
1582
1564
  }) => {
1583
- var S;
1584
- const [f, d] = F({}), [C, m] = F(!0), [I, w] = F(""), [E, N] = F(!1), {
1585
- getConversations: b,
1586
- getSharedConversations: P,
1587
- deleteConversation: x,
1588
- renameConversation: T
1589
- } = l, z = he(() => !!(I != null && I.length), [I]);
1565
+ const [u, E] = T({}), [g, v] = T(!0), [N, C] = T(""), [R, S] = T(!1), {
1566
+ getConversations: D,
1567
+ getSharedConversations: A,
1568
+ deleteConversation: O,
1569
+ renameConversation: $
1570
+ } = r, H = J(() => !!N?.length, [N]);
1590
1571
  ee(() => {
1591
- d({
1592
- ...et(e),
1593
- ...ot(p)
1572
+ E({
1573
+ ...tt(n),
1574
+ ...st(p)
1594
1575
  });
1595
- }, [p, e]), ee(() => {
1576
+ }, [p, n]), ee(() => {
1596
1577
  async function M() {
1597
1578
  try {
1598
- m(!0);
1599
- const A = await b(h), L = await P(
1600
- le(ie.ME)
1579
+ v(!0);
1580
+ const b = await D(e), L = await A(
1581
+ re(se.ME)
1601
1582
  );
1602
- n(K(A)), o(
1583
+ t(K(b)), i(
1603
1584
  K(
1604
- ce(L, h)
1585
+ ue(L, e)
1605
1586
  )
1606
1587
  );
1607
- } catch (A) {
1608
- console.error("Error loading conversation", A);
1588
+ } catch (b) {
1589
+ console.error("Error loading conversation", b);
1609
1590
  } finally {
1610
- m(!1);
1591
+ v(!1);
1611
1592
  }
1612
1593
  }
1613
1594
  M();
1614
1595
  }, [
1615
- b,
1616
- n,
1617
- h,
1618
- P,
1619
- o
1596
+ D,
1597
+ t,
1598
+ e,
1599
+ A,
1600
+ i
1620
1601
  ]);
1621
- const $ = _(
1602
+ const P = B(
1622
1603
  async (M) => {
1623
1604
  try {
1624
- await x(M);
1625
- const A = await b(h), L = await P(
1626
- le(ie.ME)
1605
+ await O(M);
1606
+ const b = await D(e), L = await A(
1607
+ re(se.ME)
1627
1608
  );
1628
- n(K(A)), o(
1609
+ t(K(b)), i(
1629
1610
  K(
1630
- ce(L, h)
1611
+ ue(L, e)
1631
1612
  )
1632
- ), r === (M == null ? void 0 : M.id) && u();
1633
- } catch (A) {
1634
- console.error("Error deleting conversation", A);
1613
+ ), s === M?.id && h();
1614
+ } catch (b) {
1615
+ console.error("Error deleting conversation", b);
1635
1616
  }
1636
1617
  },
1637
1618
  [
1638
- x,
1639
- b,
1640
- h,
1641
- P,
1642
- n,
1643
- o,
1644
- r,
1645
- u
1619
+ O,
1620
+ D,
1621
+ e,
1622
+ A,
1623
+ t,
1624
+ i,
1625
+ s,
1626
+ h
1646
1627
  ]
1647
- ), D = _(
1648
- async (M, A) => {
1628
+ ), Y = B(
1629
+ async (M, b) => {
1649
1630
  try {
1650
- m(!0), await T(M, A);
1651
- const L = await b(h), j = await P(
1652
- le(ie.ME)
1631
+ v(!0), await $(M, b);
1632
+ const L = await D(e), W = await A(
1633
+ re(se.ME)
1653
1634
  );
1654
- n(K(L)), o(
1635
+ t(K(L)), i(
1655
1636
  K(
1656
- ce(j, h)
1637
+ ue(W, e)
1657
1638
  )
1658
1639
  );
1659
1640
  } catch (L) {
1660
1641
  console.error("Error renaming conversation", L);
1661
1642
  } finally {
1662
- m(!1);
1643
+ v(!1);
1663
1644
  }
1664
1645
  },
1665
1646
  [
1666
- b,
1667
- h,
1668
- P,
1669
- n,
1670
- o,
1671
- T
1647
+ D,
1648
+ e,
1649
+ A,
1650
+ t,
1651
+ i,
1652
+ $
1672
1653
  ]
1673
- ), H = _(
1654
+ ), j = B(
1674
1655
  (M) => {
1675
- w(M);
1656
+ C(M);
1676
1657
  },
1677
- [w]
1678
- ), Q = _(() => {
1679
- N((M) => !M), w("");
1680
- }, [N]);
1681
- return C ? /* @__PURE__ */ g(Ce, {}) : /* @__PURE__ */ B(v, { children: [
1682
- !s && /* @__PURE__ */ B(
1658
+ [C]
1659
+ ), _ = B(() => {
1660
+ S((M) => !M), C("");
1661
+ }, [S]);
1662
+ return g ? /* @__PURE__ */ m(we, {}) : /* @__PURE__ */ y(q, { children: [
1663
+ !c && /* @__PURE__ */ y(
1683
1664
  "div",
1684
1665
  {
1685
- className: J(
1666
+ className: k(
1686
1667
  "flex justify-between items-center",
1687
- E ? " pt-4 pb-0 sm:pt-10" : " pt-6 pb-2 sm:pt-10"
1668
+ R ? " pt-4 pb-0 sm:pt-10" : " pt-6 pb-2 sm:pt-10"
1688
1669
  ),
1689
1670
  children: [
1690
- !E && /* @__PURE__ */ g("h3", { className: "text-neutrals-700 sm:body-2", children: ((S = a == null ? void 0 : a.titles) == null ? void 0 : S.allChats) ?? "All Chats" }),
1691
- /* @__PURE__ */ g(
1692
- St,
1671
+ !R && /* @__PURE__ */ m("h3", { className: "text-neutrals-700 sm:body-2", children: f?.titles?.allChats ?? "All Chats" }),
1672
+ /* @__PURE__ */ m(
1673
+ Bt,
1693
1674
  {
1694
- searchQuery: I,
1695
- searchIcon: a.searchIcon,
1696
- titles: a.titles,
1697
- isExpandedSearch: E,
1698
- onSearchConversations: H,
1699
- toggleSearchField: Q
1675
+ searchQuery: N,
1676
+ searchIcon: f.searchIcon,
1677
+ titles: f.titles,
1678
+ isExpandedSearch: R,
1679
+ onSearchConversations: j,
1680
+ toggleSearchField: _
1700
1681
  }
1701
1682
  )
1702
1683
  ]
1703
1684
  }
1704
1685
  ),
1705
- /* @__PURE__ */ g(
1686
+ /* @__PURE__ */ m(
1706
1687
  "div",
1707
1688
  {
1708
- className: J(
1689
+ className: k(
1709
1690
  "overflow-y-auto flex flex-col mt-4 flex-1 min-h-0 pr-2",
1710
- z ? "gap-y-1" : "gap-y-6"
1691
+ H ? "gap-y-1" : "gap-y-6"
1711
1692
  ),
1712
- children: s ? null : /* @__PURE__ */ g(v, { children: (p == null ? void 0 : p.length) === 0 && (e == null ? void 0 : e.length) === 0 ? /* @__PURE__ */ g(Ut, { titles: a.titles }) : z ? /* @__PURE__ */ g(
1713
- Ft,
1693
+ children: c ? null : /* @__PURE__ */ m(q, { children: p?.length === 0 && n?.length === 0 ? /* @__PURE__ */ m(Ft, { titles: f.titles }) : H ? /* @__PURE__ */ m(
1694
+ kt,
1714
1695
  {
1715
- locale: h,
1716
- conversationStyles: a,
1717
- conversations: [...e, ...p],
1718
- searchQuery: I,
1719
- selectedConversationId: r,
1720
- handleConversationClick: t,
1721
- shareConversationProps: i,
1696
+ locale: e,
1697
+ conversationStyles: f,
1698
+ conversations: [...n, ...p],
1699
+ searchQuery: N,
1700
+ selectedConversationId: s,
1701
+ handleConversationClick: o,
1702
+ shareConversationProps: a,
1722
1703
  actions: {
1723
- ...l,
1724
- deleteConversation: $
1704
+ ...r,
1705
+ deleteConversation: P
1725
1706
  }
1726
1707
  }
1727
- ) : Object.entries(f).map(
1728
- ([M, A]) => (A == null ? void 0 : A.length) > 0 && /* @__PURE__ */ g(
1729
- Bt,
1708
+ ) : Object.entries(u).map(
1709
+ ([M, b]) => b?.length > 0 && /* @__PURE__ */ m(
1710
+ Lt,
1730
1711
  {
1731
- locale: h,
1712
+ locale: e,
1713
+ isDisabled: d,
1732
1714
  groupLabel: M,
1733
- conversationStyles: a,
1734
- groupedConversations: A,
1735
- handleConversationClick: t,
1715
+ conversationStyles: f,
1716
+ groupedConversations: b,
1717
+ handleConversationClick: o,
1736
1718
  actions: {
1737
- ...l,
1738
- deleteConversation: $,
1739
- renameConversation: D
1719
+ ...r,
1720
+ deleteConversation: P,
1721
+ renameConversation: Y
1740
1722
  },
1741
- shareConversationProps: i,
1742
- selectedConversationId: r
1723
+ shareConversationProps: a,
1724
+ selectedConversationId: s
1743
1725
  },
1744
1726
  M
1745
1727
  )
1746
1728
  ) })
1747
1729
  }
1748
1730
  ),
1749
- c
1731
+ l
1750
1732
  ] });
1733
+ }, Ut = ({
1734
+ onCloseModal: o,
1735
+ disableModalDividers: s,
1736
+ signOut: r,
1737
+ isSmallButton: l,
1738
+ locale: c,
1739
+ titles: d
1740
+ }) => /* @__PURE__ */ y(
1741
+ ae,
1742
+ {
1743
+ heading: d?.popupTitle || "Log out?",
1744
+ portalId: "sign-out",
1745
+ containerClassName: "sign-out-popup",
1746
+ size: le.SM,
1747
+ dividers: !s,
1748
+ onClose: o,
1749
+ closeButtonTitle: "Cancel",
1750
+ children: [
1751
+ /* @__PURE__ */ m("div", { className: "py-4 px-6 sm:px-0", lang: c, children: d?.popupText }),
1752
+ /* @__PURE__ */ y("div", { className: "flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer", children: [
1753
+ /* @__PURE__ */ m(
1754
+ Q,
1755
+ {
1756
+ buttonClassName: "cancel-button",
1757
+ title: d?.popupCancel || "Cancel",
1758
+ isSmallButton: l,
1759
+ onClick: (f) => {
1760
+ f.stopPropagation(), o();
1761
+ }
1762
+ }
1763
+ ),
1764
+ /* @__PURE__ */ m(
1765
+ Q,
1766
+ {
1767
+ buttonClassName: "text-button-primary",
1768
+ title: d?.popupApply || "Sign Out",
1769
+ isSmallButton: l,
1770
+ onClick: (f) => {
1771
+ f.stopPropagation(), r?.();
1772
+ }
1773
+ }
1774
+ )
1775
+ ] })
1776
+ ]
1777
+ }
1778
+ ), Zt = ({
1779
+ userInfo: o,
1780
+ signOutAction: s,
1781
+ styles: r,
1782
+ locale: l,
1783
+ titles: c
1784
+ }) => {
1785
+ const d = (E) => E?.split(" ")?.map((g, v) => v < 2 ? g[0].toUpperCase() : "")?.join("") ?? "", f = J(
1786
+ () => o?.name ? d(o?.name) : o?.email?.[0].toUpperCase() ?? "",
1787
+ [o]
1788
+ ), [p, e] = T(!1), n = o?.name?.split(" "), t = n ? `${n?.[0] ?? ""} ${n?.[1]?.[0] ? n?.[1]?.[0] + "." : ""}` : o?.email ?? "", i = B(() => {
1789
+ e(!0);
1790
+ }, []), a = B(() => {
1791
+ e(!1);
1792
+ }, []), h = J(() => /* @__PURE__ */ y("div", { className: "flex items-center gap-2", children: [
1793
+ /* @__PURE__ */ m(
1794
+ "div",
1795
+ {
1796
+ className: k(
1797
+ "cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0",
1798
+ r?.initialStyles
1799
+ ),
1800
+ children: f
1801
+ }
1802
+ ),
1803
+ /* @__PURE__ */ m(
1804
+ "p",
1805
+ {
1806
+ className: k(
1807
+ "h3 cursor-pointer overflow-hidden text-ellipsis",
1808
+ r?.userNameStyles
1809
+ ),
1810
+ children: (r?.showShortName ? t : o?.name) ?? o?.email ?? ""
1811
+ }
1812
+ )
1813
+ ] }), [f, t, r, o]), u = J(() => /* @__PURE__ */ y("div", { className: k("py-1", r?.dropDownStyles), children: [
1814
+ r?.settingsIcon && /* @__PURE__ */ y(
1815
+ "button",
1816
+ {
1817
+ className: k(
1818
+ "p-2 items-center flex gap-1 text-primary fill-primary body-1",
1819
+ r?.dropdownButtonStyles
1820
+ ),
1821
+ title: c?.settings,
1822
+ children: [
1823
+ r?.settingsIcon,
1824
+ c?.settings || "Settings"
1825
+ ]
1826
+ }
1827
+ ),
1828
+ /* @__PURE__ */ m(
1829
+ "div",
1830
+ {
1831
+ className: k(
1832
+ "h-0 border-t border-neutrals-600 my-2",
1833
+ r?.showSeparator ? "block" : "hidden"
1834
+ )
1835
+ }
1836
+ ),
1837
+ /* @__PURE__ */ y(
1838
+ "button",
1839
+ {
1840
+ className: k(
1841
+ "p-2 items-center flex gap-1 text-primary fill-primary body-1",
1842
+ r?.dropdownButtonStyles
1843
+ ),
1844
+ title: c?.signOut,
1845
+ onClick: i,
1846
+ children: [
1847
+ r?.signOutIcon,
1848
+ c?.signOut || "Sign out",
1849
+ p && /* @__PURE__ */ m(
1850
+ Ut,
1851
+ {
1852
+ onCloseModal: a,
1853
+ signOut: () => s?.(),
1854
+ locale: l,
1855
+ disableModalDividers: r?.disableModalDividers,
1856
+ titles: c
1857
+ }
1858
+ )
1859
+ ]
1860
+ }
1861
+ )
1862
+ ] }), [
1863
+ r,
1864
+ c,
1865
+ i,
1866
+ p,
1867
+ a,
1868
+ l,
1869
+ s
1870
+ ]);
1871
+ if (o)
1872
+ return /* @__PURE__ */ m(
1873
+ Re,
1874
+ {
1875
+ containerClassName: k(
1876
+ "transition-opacity group-hover:opacity-100 shrink w-full",
1877
+ r?.dropdownContainerClassName
1878
+ ),
1879
+ triggerButton: h,
1880
+ content: u,
1881
+ openedClassName: "action-menu-opened"
1882
+ }
1883
+ );
1751
1884
  };
1752
1885
  export {
1753
- xt as ActionMenu,
1754
- k as ActionMenuItem,
1755
- Wt as ConversationList,
1756
- et as getSharedConversationsGroup,
1757
- ce as transformSharedConversations
1886
+ Ot as ActionMenu,
1887
+ U as ActionMenuItem,
1888
+ Kt as ConversationList,
1889
+ Zt as User,
1890
+ tt as getSharedConversationsGroup,
1891
+ ue as transformSharedConversations
1758
1892
  };