@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.d.ts +2 -0
- package/index.js +1 -9
- package/index.mjs +1140 -1006
- package/models/titles.d.ts +1 -0
- package/package.json +9 -7
- package/index.css +0 -1
package/index.mjs
CHANGED
|
@@ -1,120 +1,115 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { cloneDeep as
|
|
5
|
-
import { Popup as
|
|
6
|
-
import { IconCheck as je, IconCopy as
|
|
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
|
|
9
|
-
import { SHARE_CONVERSATION_ROUTE as
|
|
10
|
-
var
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
[
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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(
|
|
37
|
-
}, rt = (
|
|
38
|
-
const
|
|
39
|
-
return Math.floor(
|
|
40
|
-
},
|
|
41
|
-
const
|
|
42
|
-
for (const
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
let
|
|
46
|
-
Me(
|
|
47
|
-
(
|
|
48
|
-
) ||
|
|
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
|
|
51
|
-
},
|
|
52
|
-
(
|
|
53
|
-
),
|
|
54
|
-
onCloseModal:
|
|
55
|
-
disableModalDividers:
|
|
56
|
-
deleteConversation:
|
|
57
|
-
isSmallButton:
|
|
58
|
-
titles:
|
|
59
|
-
locale:
|
|
60
|
-
}) => /* @__PURE__ */
|
|
61
|
-
|
|
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:
|
|
59
|
+
heading: c?.deleteTitle ?? "Delete conversation",
|
|
64
60
|
portalId: "delete-conversation",
|
|
65
61
|
containerClassName: "delete-conversation-popup",
|
|
66
|
-
size:
|
|
67
|
-
dividers: !
|
|
68
|
-
onClose:
|
|
69
|
-
closeButtonTitle:
|
|
62
|
+
size: le.SM,
|
|
63
|
+
dividers: !s,
|
|
64
|
+
onClose: o,
|
|
65
|
+
closeButtonTitle: c?.close ?? "Cancel",
|
|
70
66
|
children: [
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
|
|
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:
|
|
78
|
-
isSmallButton:
|
|
79
|
-
onClick: (
|
|
80
|
-
|
|
73
|
+
title: c?.cancel ?? "Cancel",
|
|
74
|
+
isSmallButton: l,
|
|
75
|
+
onClick: (f) => {
|
|
76
|
+
f.stopPropagation(), o();
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
),
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
|
|
80
|
+
/* @__PURE__ */ m(
|
|
81
|
+
Q,
|
|
86
82
|
{
|
|
87
83
|
buttonClassName: "text-button-primary text-button-primary-error",
|
|
88
|
-
title:
|
|
89
|
-
isSmallButton:
|
|
90
|
-
onClick: (
|
|
91
|
-
|
|
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
|
-
),
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
114
|
-
(
|
|
108
|
+
r,
|
|
109
|
+
(l) => te(l.relativePath, l.name)
|
|
115
110
|
);
|
|
116
|
-
},
|
|
117
|
-
const
|
|
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((
|
|
129
|
-
}, ut = (
|
|
130
|
-
const
|
|
131
|
-
...
|
|
132
|
-
),
|
|
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:
|
|
135
|
-
name:
|
|
129
|
+
absolutePath: s.slice(0, r),
|
|
130
|
+
name: s.slice(r + 1)
|
|
136
131
|
};
|
|
137
|
-
},
|
|
138
|
-
if (!
|
|
132
|
+
}, ht = (o) => o ? o.map((s) => {
|
|
133
|
+
if (!s.url || dt(s.url) || ct(s.url))
|
|
139
134
|
return null;
|
|
140
|
-
const { absolutePath:
|
|
135
|
+
const { absolutePath: r, name: l } = ut(s.url);
|
|
141
136
|
return {
|
|
142
|
-
id:
|
|
143
|
-
name:
|
|
144
|
-
contentType:
|
|
145
|
-
folderId:
|
|
146
|
-
absolutePath:
|
|
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
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
const e = encodeURI(te(
|
|
153
|
-
|
|
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
|
|
150
|
+
const c = {
|
|
156
151
|
version: 5,
|
|
157
|
-
history: [
|
|
152
|
+
history: [o].map(pt) || [],
|
|
158
153
|
folders: []
|
|
159
|
-
},
|
|
160
|
-
return
|
|
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 = (
|
|
163
|
-
const
|
|
164
|
-
return
|
|
165
|
-
},
|
|
166
|
-
function
|
|
167
|
-
const
|
|
168
|
-
|
|
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
|
|
171
|
-
for (var
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
for (var
|
|
175
|
-
|
|
176
|
-
return
|
|
177
|
-
},
|
|
178
|
-
var
|
|
179
|
-
for (var
|
|
180
|
-
|
|
181
|
-
if (
|
|
182
|
-
for (var
|
|
183
|
-
|
|
184
|
-
return
|
|
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
|
-
|
|
188
|
-
|
|
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,
|
|
200
|
-
if (this.version = e, this.errorCorrectionLevel = n, this.modules = [], this.isFunction = [], e <
|
|
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
|
|
206
|
-
for (let
|
|
207
|
-
|
|
208
|
-
for (let
|
|
209
|
-
this.modules.push(
|
|
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
|
|
212
|
-
if (this.drawCodewords(
|
|
213
|
-
let
|
|
214
|
-
for (let
|
|
215
|
-
this.applyMask(
|
|
216
|
-
const
|
|
217
|
-
|
|
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
|
-
|
|
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
|
|
230
|
-
return
|
|
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
|
|
238
|
-
return
|
|
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,
|
|
251
|
-
if (!(
|
|
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
|
|
254
|
-
for (
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
|
|
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 (
|
|
250
|
+
if (u >= i)
|
|
261
251
|
throw new RangeError("Data too long");
|
|
262
252
|
}
|
|
263
|
-
for (const
|
|
264
|
-
|
|
265
|
-
let
|
|
266
|
-
for (const
|
|
267
|
-
|
|
268
|
-
for (const
|
|
269
|
-
|
|
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
|
-
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
for (let
|
|
275
|
-
|
|
276
|
-
let
|
|
277
|
-
for (;
|
|
278
|
-
|
|
279
|
-
return
|
|
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
|
|
296
|
-
this.setFunctionModule(6,
|
|
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
|
|
289
|
+
for (let t = 0; t < n; t++)
|
|
300
290
|
for (let i = 0; i < n; i++)
|
|
301
|
-
|
|
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
|
|
309
|
-
for (let
|
|
310
|
-
|
|
311
|
-
const i = (n << 10 |
|
|
312
|
-
|
|
313
|
-
for (let
|
|
314
|
-
this.setFunctionModule(8,
|
|
315
|
-
this.setFunctionModule(8, 7,
|
|
316
|
-
for (let
|
|
317
|
-
this.setFunctionModule(14 -
|
|
318
|
-
for (let
|
|
319
|
-
this.setFunctionModule(this.size - 1 -
|
|
320
|
-
for (let
|
|
321
|
-
this.setFunctionModule(8, this.size - 15 +
|
|
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
|
|
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
|
-
|
|
334
|
-
for (let
|
|
335
|
-
const i =
|
|
336
|
-
this.setFunctionModule(
|
|
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
|
|
332
|
+
for (let t = -4; t <= 4; t++)
|
|
343
333
|
for (let i = -4; i <= 4; i++) {
|
|
344
|
-
const
|
|
345
|
-
0 <=
|
|
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
|
|
341
|
+
for (let t = -2; t <= 2; t++)
|
|
352
342
|
for (let i = -2; i <= 2; i++)
|
|
353
|
-
this.setFunctionModule(e + i, n +
|
|
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,
|
|
358
|
-
this.modules[n][e] =
|
|
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,
|
|
365
|
-
if (e.length !=
|
|
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 =
|
|
368
|
-
let
|
|
369
|
-
const
|
|
370
|
-
for (let
|
|
371
|
-
let
|
|
372
|
-
|
|
373
|
-
const
|
|
374
|
-
|
|
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
|
|
377
|
-
for (let
|
|
378
|
-
|
|
379
|
-
(
|
|
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
|
|
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(
|
|
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
|
|
390
|
-
|
|
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
|
|
393
|
-
const
|
|
394
|
-
!this.isFunction[
|
|
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
|
-
|
|
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
|
|
398
|
+
for (let t = 0; t < this.size; t++) {
|
|
409
399
|
let i;
|
|
410
400
|
switch (e) {
|
|
411
401
|
case 0:
|
|
412
|
-
i = (
|
|
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 =
|
|
408
|
+
i = t % 3 == 0;
|
|
419
409
|
break;
|
|
420
410
|
case 3:
|
|
421
|
-
i = (
|
|
411
|
+
i = (t + n) % 3 == 0;
|
|
422
412
|
break;
|
|
423
413
|
case 4:
|
|
424
|
-
i = (Math.floor(
|
|
414
|
+
i = (Math.floor(t / 3) + Math.floor(n / 2)) % 2 == 0;
|
|
425
415
|
break;
|
|
426
416
|
case 5:
|
|
427
|
-
i =
|
|
417
|
+
i = t * n % 2 + t * n % 3 == 0;
|
|
428
418
|
break;
|
|
429
419
|
case 6:
|
|
430
|
-
i = (
|
|
420
|
+
i = (t * n % 2 + t * n % 3) % 2 == 0;
|
|
431
421
|
break;
|
|
432
422
|
case 7:
|
|
433
|
-
i = ((
|
|
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][
|
|
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
|
|
446
|
-
let
|
|
447
|
-
for (let
|
|
448
|
-
this.modules[
|
|
449
|
-
e += this.finderPenaltyTerminateAndCount(
|
|
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
|
|
452
|
-
let
|
|
453
|
-
for (let
|
|
454
|
-
this.modules[
|
|
455
|
-
e += this.finderPenaltyTerminateAndCount(
|
|
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
|
|
458
|
-
for (let
|
|
459
|
-
const
|
|
460
|
-
|
|
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
|
|
464
|
-
n =
|
|
465
|
-
const
|
|
466
|
-
return
|
|
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
|
|
478
|
-
for (let i = this.size - 7;
|
|
479
|
-
|
|
480
|
-
return
|
|
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 <
|
|
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
|
|
492
|
-
n -= (25 *
|
|
481
|
+
const t = Math.floor(e / 7) + 2;
|
|
482
|
+
n -= (25 * t - 10) * t - 55, e >= 7 && (n -= 36);
|
|
493
483
|
}
|
|
494
|
-
return
|
|
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(
|
|
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
|
|
501
|
+
let t = 1;
|
|
512
502
|
for (let i = 0; i < e; i++) {
|
|
513
|
-
for (let
|
|
514
|
-
n[
|
|
515
|
-
|
|
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
|
|
511
|
+
let t = n.map((i) => 0);
|
|
522
512
|
for (const i of e) {
|
|
523
|
-
const
|
|
524
|
-
|
|
513
|
+
const a = i ^ t.shift();
|
|
514
|
+
t.push(0), n.forEach((h, u) => t[u] ^= w.reedSolomonMultiply(h, a));
|
|
525
515
|
}
|
|
526
|
-
return
|
|
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
|
|
523
|
+
let t = 0;
|
|
534
524
|
for (let i = 7; i >= 0; i--)
|
|
535
|
-
|
|
536
|
-
return
|
|
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
|
-
|
|
543
|
-
const
|
|
544
|
-
return (
|
|
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,
|
|
548
|
-
return e && (this.finderPenaltyAddHistory(n,
|
|
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
|
-
|
|
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
|
-
],
|
|
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
|
-
],
|
|
578
|
-
function
|
|
579
|
-
if (e < 0 || e > 31 ||
|
|
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
|
|
582
|
-
n.push(
|
|
571
|
+
for (let t = e - 1; t >= 0; t--)
|
|
572
|
+
n.push(p >>> t & 1);
|
|
583
573
|
}
|
|
584
|
-
function
|
|
585
|
-
return (
|
|
574
|
+
function l(p, e) {
|
|
575
|
+
return (p >>> e & 1) != 0;
|
|
586
576
|
}
|
|
587
|
-
function
|
|
588
|
-
if (!
|
|
577
|
+
function c(p) {
|
|
578
|
+
if (!p)
|
|
589
579
|
throw new Error("Assertion error");
|
|
590
580
|
}
|
|
591
|
-
const
|
|
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,
|
|
597
|
-
if (this.mode = e, this.numChars = n, this.bitData =
|
|
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 =
|
|
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
|
|
608
|
-
|
|
609
|
-
return new
|
|
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 (!
|
|
603
|
+
if (!I.isNumeric(e))
|
|
614
604
|
throw new RangeError("String contains non-numeric characters");
|
|
615
605
|
let n = [];
|
|
616
|
-
for (let
|
|
617
|
-
const i = Math.min(e.length -
|
|
618
|
-
|
|
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
|
|
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 (!
|
|
616
|
+
if (!I.isAlphanumeric(e))
|
|
627
617
|
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
628
|
-
let n = [],
|
|
629
|
-
for (
|
|
630
|
-
let i =
|
|
631
|
-
i +=
|
|
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
|
|
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 == "" ? [] :
|
|
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
|
-
|
|
637
|
+
r(e, 8, n);
|
|
648
638
|
else if (e < 16384)
|
|
649
|
-
|
|
639
|
+
r(2, 2, n), r(e, 14, n);
|
|
650
640
|
else if (e < 1e6)
|
|
651
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
665
|
+
let t = 0;
|
|
676
666
|
for (const i of e) {
|
|
677
|
-
const
|
|
678
|
-
if (i.numChars >= 1 <<
|
|
667
|
+
const a = i.mode.numCharCountBits(n);
|
|
668
|
+
if (i.numChars >= 1 << a)
|
|
679
669
|
return 1 / 0;
|
|
680
|
-
|
|
670
|
+
t += 4 + a + i.bitData.length;
|
|
681
671
|
}
|
|
682
|
-
return
|
|
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
|
|
689
|
-
e.charAt(
|
|
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
|
-
|
|
694
|
-
let
|
|
695
|
-
|
|
696
|
-
})(
|
|
697
|
-
((
|
|
698
|
-
((
|
|
699
|
-
const
|
|
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(
|
|
703
|
-
this.ordinal =
|
|
692
|
+
constructor(c, d) {
|
|
693
|
+
this.ordinal = c, this.formatBits = d;
|
|
704
694
|
}
|
|
705
695
|
};
|
|
706
|
-
|
|
707
|
-
})(
|
|
708
|
-
})(
|
|
709
|
-
((
|
|
710
|
-
((
|
|
711
|
-
const
|
|
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(
|
|
714
|
-
this.modeBits =
|
|
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(
|
|
720
|
-
return this.numBitsCharCount[Math.floor((
|
|
709
|
+
numCharCountBits(c) {
|
|
710
|
+
return this.numBitsCharCount[Math.floor((c + 7) / 17)];
|
|
721
711
|
}
|
|
722
712
|
};
|
|
723
|
-
|
|
724
|
-
})(
|
|
725
|
-
})(
|
|
726
|
-
var Z =
|
|
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,
|
|
738
|
-
function
|
|
739
|
-
const
|
|
740
|
-
return
|
|
741
|
-
let
|
|
742
|
-
|
|
743
|
-
if (!
|
|
744
|
-
|
|
745
|
-
`M${
|
|
746
|
-
),
|
|
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 (
|
|
750
|
-
if (!
|
|
734
|
+
if (p === l.length - 1) {
|
|
735
|
+
if (!f)
|
|
751
736
|
return;
|
|
752
|
-
|
|
753
|
-
`M${
|
|
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
|
-
|
|
742
|
+
f && d === null && (d = p);
|
|
758
743
|
});
|
|
759
|
-
}),
|
|
744
|
+
}), r.join("");
|
|
760
745
|
}
|
|
761
|
-
function Le(
|
|
762
|
-
return
|
|
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
|
|
765
|
-
if (
|
|
749
|
+
function vt(o, s, r, l) {
|
|
750
|
+
if (l == null)
|
|
766
751
|
return null;
|
|
767
|
-
const
|
|
768
|
-
let
|
|
769
|
-
if (
|
|
770
|
-
let
|
|
771
|
-
|
|
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
|
|
774
|
-
return { x: n, y:
|
|
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
|
|
777
|
-
return
|
|
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:
|
|
781
|
-
level:
|
|
782
|
-
minVersion:
|
|
783
|
-
includeMargin:
|
|
784
|
-
marginSize:
|
|
785
|
-
imageSettings:
|
|
786
|
-
size:
|
|
787
|
-
boostLevel:
|
|
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 =
|
|
790
|
-
const
|
|
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
|
-
|
|
793
|
-
Et[
|
|
794
|
-
|
|
777
|
+
u,
|
|
778
|
+
Et[s],
|
|
779
|
+
r,
|
|
795
780
|
void 0,
|
|
796
781
|
void 0,
|
|
797
|
-
|
|
782
|
+
p
|
|
798
783
|
);
|
|
799
|
-
}, [
|
|
800
|
-
const { cells: n, margin:
|
|
801
|
-
let
|
|
802
|
-
const
|
|
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
|
-
|
|
805
|
-
d
|
|
806
|
-
a
|
|
790
|
+
u,
|
|
791
|
+
d
|
|
807
792
|
);
|
|
808
793
|
return {
|
|
809
|
-
cells:
|
|
810
|
-
margin:
|
|
811
|
-
numCells:
|
|
812
|
-
calculatedImageSettings:
|
|
794
|
+
cells: h,
|
|
795
|
+
margin: u,
|
|
796
|
+
numCells: E,
|
|
797
|
+
calculatedImageSettings: g
|
|
813
798
|
};
|
|
814
|
-
}, [e,
|
|
799
|
+
}, [e, f, d, l, c]);
|
|
815
800
|
return {
|
|
816
801
|
qrcode: e,
|
|
817
|
-
margin:
|
|
802
|
+
margin: t,
|
|
818
803
|
cells: n,
|
|
819
804
|
numCells: i,
|
|
820
|
-
calculatedImageSettings:
|
|
805
|
+
calculatedImageSettings: a
|
|
821
806
|
};
|
|
822
807
|
}
|
|
823
|
-
var
|
|
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 =
|
|
831
|
-
function(
|
|
832
|
-
const
|
|
833
|
-
value:
|
|
834
|
-
size:
|
|
835
|
-
level:
|
|
836
|
-
bgColor:
|
|
837
|
-
fgColor: e =
|
|
838
|
-
includeMargin: n =
|
|
839
|
-
minVersion:
|
|
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:
|
|
842
|
-
imageSettings:
|
|
843
|
-
} =
|
|
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:
|
|
855
|
-
(
|
|
856
|
-
|
|
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
|
-
[
|
|
859
|
-
), [
|
|
860
|
-
value:
|
|
861
|
-
level:
|
|
862
|
-
minVersion:
|
|
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:
|
|
866
|
-
imageSettings:
|
|
867
|
-
size:
|
|
850
|
+
marginSize: a,
|
|
851
|
+
imageSettings: h,
|
|
852
|
+
size: d
|
|
868
853
|
});
|
|
869
|
-
|
|
870
|
-
if (
|
|
871
|
-
const
|
|
854
|
+
x.useEffect(() => {
|
|
855
|
+
if (C.current != null) {
|
|
856
|
+
const _ = C.current, M = _.getContext("2d");
|
|
872
857
|
if (!M)
|
|
873
858
|
return;
|
|
874
|
-
let
|
|
875
|
-
const L =
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
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
|
-
|
|
882
|
-
const
|
|
883
|
-
M.scale(
|
|
884
|
-
V.forEach(function(
|
|
885
|
-
|
|
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
|
-
}),
|
|
872
|
+
}), P && (M.globalAlpha = P.opacity), W && M.drawImage(
|
|
888
873
|
L,
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
874
|
+
P.x + O,
|
|
875
|
+
P.y + O,
|
|
876
|
+
P.w,
|
|
877
|
+
P.h
|
|
893
878
|
);
|
|
894
879
|
}
|
|
895
|
-
}),
|
|
896
|
-
|
|
897
|
-
}, [
|
|
898
|
-
const
|
|
899
|
-
let
|
|
900
|
-
return
|
|
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:
|
|
904
|
-
key:
|
|
888
|
+
src: N,
|
|
889
|
+
key: N,
|
|
905
890
|
style: { display: "none" },
|
|
906
891
|
onLoad: () => {
|
|
907
|
-
|
|
892
|
+
A(!0);
|
|
908
893
|
},
|
|
909
|
-
ref:
|
|
910
|
-
crossOrigin:
|
|
894
|
+
ref: R,
|
|
895
|
+
crossOrigin: P?.crossOrigin
|
|
911
896
|
}
|
|
912
|
-
)), /* @__PURE__ */
|
|
897
|
+
)), /* @__PURE__ */ x.createElement(x.Fragment, null, /* @__PURE__ */ x.createElement(
|
|
913
898
|
"canvas",
|
|
914
|
-
|
|
915
|
-
style:
|
|
916
|
-
height:
|
|
917
|
-
width:
|
|
918
|
-
ref:
|
|
899
|
+
he({
|
|
900
|
+
style: Y,
|
|
901
|
+
height: d,
|
|
902
|
+
width: d,
|
|
903
|
+
ref: S,
|
|
919
904
|
role: "img"
|
|
920
|
-
},
|
|
921
|
-
),
|
|
905
|
+
}, v)
|
|
906
|
+
), j);
|
|
922
907
|
}
|
|
923
908
|
);
|
|
924
909
|
At.displayName = "QRCodeCanvas";
|
|
925
|
-
var
|
|
926
|
-
function(
|
|
927
|
-
const
|
|
928
|
-
value:
|
|
929
|
-
size:
|
|
930
|
-
level:
|
|
931
|
-
bgColor:
|
|
932
|
-
fgColor: e =
|
|
933
|
-
includeMargin: n =
|
|
934
|
-
minVersion:
|
|
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:
|
|
937
|
-
marginSize:
|
|
938
|
-
imageSettings:
|
|
939
|
-
} =
|
|
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:
|
|
952
|
-
value:
|
|
953
|
-
level:
|
|
954
|
-
minVersion:
|
|
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:
|
|
958
|
-
imageSettings:
|
|
959
|
-
size:
|
|
942
|
+
marginSize: h,
|
|
943
|
+
imageSettings: u,
|
|
944
|
+
size: d
|
|
960
945
|
});
|
|
961
|
-
let
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
)),
|
|
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:
|
|
969
|
-
height:
|
|
970
|
-
width:
|
|
971
|
-
x:
|
|
972
|
-
y:
|
|
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:
|
|
975
|
-
crossOrigin:
|
|
959
|
+
opacity: C.opacity,
|
|
960
|
+
crossOrigin: C.crossOrigin
|
|
976
961
|
}
|
|
977
962
|
));
|
|
978
|
-
const
|
|
979
|
-
return /* @__PURE__ */
|
|
963
|
+
const D = Te(R, g);
|
|
964
|
+
return /* @__PURE__ */ x.createElement(
|
|
980
965
|
"svg",
|
|
981
|
-
|
|
982
|
-
height:
|
|
983
|
-
width:
|
|
984
|
-
viewBox: `0 0 ${
|
|
985
|
-
ref:
|
|
966
|
+
he({
|
|
967
|
+
height: d,
|
|
968
|
+
width: d,
|
|
969
|
+
viewBox: `0 0 ${N} ${N}`,
|
|
970
|
+
ref: r,
|
|
986
971
|
role: "img"
|
|
987
|
-
},
|
|
988
|
-
!!
|
|
989
|
-
/* @__PURE__ */
|
|
972
|
+
}, E),
|
|
973
|
+
!!a && /* @__PURE__ */ x.createElement("title", null, a),
|
|
974
|
+
/* @__PURE__ */ x.createElement(
|
|
990
975
|
"path",
|
|
991
976
|
{
|
|
992
|
-
fill:
|
|
993
|
-
d: `M0,0 h${
|
|
977
|
+
fill: p,
|
|
978
|
+
d: `M0,0 h${N}v${N}H0z`,
|
|
994
979
|
shapeRendering: "crispEdges"
|
|
995
980
|
}
|
|
996
981
|
),
|
|
997
|
-
/* @__PURE__ */
|
|
998
|
-
|
|
982
|
+
/* @__PURE__ */ x.createElement("path", { fill: e, d: D, shapeRendering: "crispEdges" }),
|
|
983
|
+
S
|
|
999
984
|
);
|
|
1000
985
|
}
|
|
1001
986
|
);
|
|
1002
|
-
|
|
1003
|
-
const
|
|
987
|
+
ke.displayName = "QRCodeSVG";
|
|
988
|
+
const It = (o, s) => ({
|
|
1004
989
|
invitationType: qe.LINK,
|
|
1005
990
|
resources: [
|
|
1006
991
|
{
|
|
1007
|
-
url: `conversations/${encodeURI(
|
|
992
|
+
url: `conversations/${encodeURI(o)}`
|
|
1008
993
|
},
|
|
1009
|
-
...
|
|
994
|
+
...s
|
|
1010
995
|
]
|
|
1011
|
-
}),
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
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:
|
|
1017
|
+
shareLink: t,
|
|
1045
1018
|
shareCopyLink: i,
|
|
1046
|
-
shareCopiedLink:
|
|
1047
|
-
shareDescription:
|
|
1048
|
-
shareRemoveAccessToUsers:
|
|
1049
|
-
chatName:
|
|
1050
|
-
getSharedConversations:
|
|
1051
|
-
revokeSharedConversations:
|
|
1052
|
-
baseUrl:
|
|
1053
|
-
id:
|
|
1054
|
-
clientSharedPage:
|
|
1055
|
-
clientSharedProp:
|
|
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 [
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
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}/${
|
|
1065
|
-
}, [
|
|
1036
|
+
return `${V}/${s}${D}`;
|
|
1037
|
+
}, [N, D, s, R, S]);
|
|
1066
1038
|
ee(() => {
|
|
1067
1039
|
(async () => {
|
|
1068
1040
|
try {
|
|
1069
|
-
const G = decodeURI(
|
|
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
|
-
|
|
1072
|
-
),
|
|
1073
|
-
|
|
1074
|
-
)
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
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
|
-
|
|
1054
|
+
P(!1), console.error("Error sharing conversation", G);
|
|
1083
1055
|
}
|
|
1084
1056
|
})();
|
|
1085
1057
|
}, [
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1058
|
+
o,
|
|
1059
|
+
d,
|
|
1060
|
+
c,
|
|
1061
|
+
g,
|
|
1062
|
+
C,
|
|
1063
|
+
s
|
|
1092
1064
|
]);
|
|
1093
|
-
const L =
|
|
1094
|
-
|
|
1095
|
-
}, [
|
|
1096
|
-
|
|
1097
|
-
}, [
|
|
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),
|
|
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
|
-
},
|
|
1104
|
-
|
|
1075
|
+
}, oe = B(() => /* @__PURE__ */ m(
|
|
1076
|
+
Q,
|
|
1105
1077
|
{
|
|
1106
|
-
buttonClassName:
|
|
1107
|
-
iconBefore:
|
|
1108
|
-
title:
|
|
1109
|
-
disabled:
|
|
1110
|
-
onClick:
|
|
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
|
-
), [
|
|
1113
|
-
return /* @__PURE__ */
|
|
1114
|
-
|
|
1084
|
+
), [Y, W, a, i]);
|
|
1085
|
+
return /* @__PURE__ */ y(
|
|
1086
|
+
ae,
|
|
1115
1087
|
{
|
|
1116
|
-
heading:
|
|
1088
|
+
heading: t ?? "Share link",
|
|
1117
1089
|
portalId: "share",
|
|
1118
|
-
size:
|
|
1119
|
-
dividers:
|
|
1090
|
+
size: le.SM,
|
|
1091
|
+
dividers: l,
|
|
1120
1092
|
onClose: L,
|
|
1121
1093
|
closeButtonTitle: e ?? "Close",
|
|
1122
1094
|
children: [
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
/* @__PURE__ */
|
|
1126
|
-
/* @__PURE__ */
|
|
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:
|
|
1131
|
-
children:
|
|
1102
|
+
title: o?.name,
|
|
1103
|
+
children: o?.name
|
|
1132
1104
|
}
|
|
1133
1105
|
)
|
|
1134
1106
|
] }) : null,
|
|
1135
|
-
/* @__PURE__ */
|
|
1136
|
-
/* @__PURE__ */
|
|
1137
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
1111
|
+
p ?? "days"
|
|
1140
1112
|
] })
|
|
1141
1113
|
] }),
|
|
1142
|
-
/* @__PURE__ */
|
|
1143
|
-
|
|
1114
|
+
/* @__PURE__ */ m(
|
|
1115
|
+
ke,
|
|
1144
1116
|
{
|
|
1145
1117
|
className: "self-center border border-neutrals-600 p-2 rounded min-h-[200px]",
|
|
1146
|
-
value:
|
|
1118
|
+
value: b,
|
|
1147
1119
|
size: 200
|
|
1148
1120
|
}
|
|
1149
1121
|
),
|
|
1150
|
-
/* @__PURE__ */
|
|
1151
|
-
/* @__PURE__ */
|
|
1152
|
-
|
|
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:
|
|
1158
|
-
value:
|
|
1129
|
+
placeholder: b,
|
|
1130
|
+
value: b,
|
|
1159
1131
|
inputId: "conversationLink",
|
|
1160
|
-
iconAfterInput:
|
|
1132
|
+
iconAfterInput: oe()
|
|
1161
1133
|
}
|
|
1162
1134
|
)
|
|
1163
|
-
] }) : /* @__PURE__ */
|
|
1164
|
-
|
|
1165
|
-
|
|
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:
|
|
1139
|
+
title: u ?? "Remove access to all users",
|
|
1168
1140
|
buttonClassName: "remove-access-button py-3 px-4",
|
|
1169
1141
|
isSmallButton: !0,
|
|
1170
|
-
disabled:
|
|
1142
|
+
disabled: _,
|
|
1171
1143
|
onClick: ne
|
|
1172
1144
|
}
|
|
1173
|
-
) }) : /* @__PURE__ */
|
|
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
|
-
},
|
|
1178
|
-
conversation:
|
|
1179
|
-
onCloseModal:
|
|
1180
|
-
renameConversation:
|
|
1181
|
-
locale:
|
|
1182
|
-
disableModalDividers:
|
|
1183
|
-
titles:
|
|
1184
|
-
isSmallButton:
|
|
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 [
|
|
1158
|
+
const [p, e] = T(o?.name || ""), n = (i) => {
|
|
1187
1159
|
e(i);
|
|
1188
|
-
},
|
|
1189
|
-
const i = `${
|
|
1190
|
-
|
|
1191
|
-
`conversations/${
|
|
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__ */
|
|
1196
|
-
|
|
1167
|
+
return /* @__PURE__ */ y(
|
|
1168
|
+
ae,
|
|
1197
1169
|
{
|
|
1198
|
-
heading:
|
|
1170
|
+
heading: d?.renameTitle ?? "Rename conversation",
|
|
1199
1171
|
portalId: "rename-conversation",
|
|
1200
1172
|
containerClassName: "rename-conversation-popup",
|
|
1201
|
-
size:
|
|
1202
|
-
dividers: !
|
|
1203
|
-
onClose:
|
|
1204
|
-
closeButtonTitle:
|
|
1173
|
+
size: le.SM,
|
|
1174
|
+
dividers: !c,
|
|
1175
|
+
onClose: s,
|
|
1176
|
+
closeButtonTitle: d?.close ?? "Cancel",
|
|
1205
1177
|
children: [
|
|
1206
|
-
/* @__PURE__ */
|
|
1207
|
-
|
|
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:
|
|
1182
|
+
value: p,
|
|
1211
1183
|
onChange: n,
|
|
1212
1184
|
cssClass: "w-full"
|
|
1213
1185
|
}
|
|
1214
1186
|
) }),
|
|
1215
|
-
/* @__PURE__ */
|
|
1216
|
-
/* @__PURE__ */
|
|
1217
|
-
|
|
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:
|
|
1221
|
-
isSmallButton:
|
|
1192
|
+
title: d?.cancel ?? "Cancel",
|
|
1193
|
+
isSmallButton: f,
|
|
1222
1194
|
onClick: (i) => {
|
|
1223
|
-
i.stopPropagation(),
|
|
1195
|
+
i.stopPropagation(), s();
|
|
1224
1196
|
}
|
|
1225
1197
|
}
|
|
1226
1198
|
),
|
|
1227
|
-
/* @__PURE__ */
|
|
1228
|
-
|
|
1199
|
+
/* @__PURE__ */ m(
|
|
1200
|
+
Q,
|
|
1229
1201
|
{
|
|
1230
1202
|
buttonClassName: "text-button-primary text-button-primary",
|
|
1231
|
-
title:
|
|
1232
|
-
isSmallButton:
|
|
1233
|
-
disabled: !
|
|
1203
|
+
title: d?.save ?? "Rename",
|
|
1204
|
+
isSmallButton: f,
|
|
1205
|
+
disabled: !p,
|
|
1234
1206
|
onClick: (i) => {
|
|
1235
|
-
i.stopPropagation(),
|
|
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
|
-
},
|
|
1244
|
-
conversation:
|
|
1245
|
-
conversationStyles:
|
|
1246
|
-
shareConversationProps:
|
|
1247
|
-
onConversationDelete:
|
|
1248
|
-
getConversation:
|
|
1249
|
-
getFileBlob:
|
|
1250
|
-
renameConversation:
|
|
1251
|
-
triggerButton:
|
|
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
|
-
|
|
1255
|
-
|
|
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:
|
|
1260
|
-
title:
|
|
1261
|
-
icon:
|
|
1230
|
+
key: U.DELETE,
|
|
1231
|
+
title: s?.titles?.delete ?? "Delete",
|
|
1232
|
+
icon: s.actionsIcons?.[U.DELETE]
|
|
1262
1233
|
}
|
|
1263
1234
|
];
|
|
1264
|
-
return
|
|
1265
|
-
...
|
|
1235
|
+
return o?.model?.id?.endsWith(et) ? A : [
|
|
1236
|
+
...o.isShared ? [] : [
|
|
1266
1237
|
{
|
|
1267
|
-
key:
|
|
1268
|
-
title:
|
|
1269
|
-
icon:
|
|
1238
|
+
key: U.SHARE,
|
|
1239
|
+
title: s?.titles?.share ?? "Share",
|
|
1240
|
+
icon: s.actionsIcons?.[U.SHARE]
|
|
1270
1241
|
},
|
|
1271
1242
|
{
|
|
1272
|
-
key:
|
|
1273
|
-
title:
|
|
1274
|
-
icon:
|
|
1243
|
+
key: U.RENAME,
|
|
1244
|
+
title: s?.titles?.rename ?? "Rename",
|
|
1245
|
+
icon: s.actionsIcons?.[U.RENAME]
|
|
1275
1246
|
}
|
|
1276
1247
|
],
|
|
1277
1248
|
{
|
|
1278
|
-
key:
|
|
1279
|
-
title:
|
|
1280
|
-
icon:
|
|
1249
|
+
key: U.EXPORT,
|
|
1250
|
+
title: s?.titles?.export ?? "Export",
|
|
1251
|
+
icon: s.actionsIcons?.[U.EXPORT]
|
|
1281
1252
|
},
|
|
1282
|
-
...
|
|
1253
|
+
...A
|
|
1283
1254
|
];
|
|
1284
1255
|
}, [
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
]), [
|
|
1290
|
-
|
|
1291
|
-
}, [
|
|
1292
|
-
|
|
1293
|
-
}, [
|
|
1294
|
-
|
|
1295
|
-
}, [
|
|
1296
|
-
|
|
1297
|
-
}, [
|
|
1298
|
-
(
|
|
1299
|
-
|
|
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
|
-
[
|
|
1272
|
+
[f, C]
|
|
1302
1273
|
);
|
|
1303
|
-
return /* @__PURE__ */
|
|
1304
|
-
/* @__PURE__ */
|
|
1305
|
-
|
|
1274
|
+
return /* @__PURE__ */ y(q, { children: [
|
|
1275
|
+
/* @__PURE__ */ m(
|
|
1276
|
+
Re,
|
|
1306
1277
|
{
|
|
1307
|
-
containerClassName: "
|
|
1308
|
-
triggerButton:
|
|
1309
|
-
options:
|
|
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: (
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
`data:application/zip;base64,${
|
|
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
|
-
|
|
1324
|
-
|
|
1295
|
+
i === z.Opened && /* @__PURE__ */ m(
|
|
1296
|
+
at,
|
|
1325
1297
|
{
|
|
1326
|
-
titles:
|
|
1298
|
+
titles: s.titles,
|
|
1327
1299
|
locale: e,
|
|
1328
|
-
disableModalDividers:
|
|
1329
|
-
isSmallButton:
|
|
1330
|
-
deleteConversation:
|
|
1331
|
-
onCloseModal:
|
|
1300
|
+
disableModalDividers: s.disableModalDividers,
|
|
1301
|
+
isSmallButton: s.isSmallModalButton,
|
|
1302
|
+
deleteConversation: R,
|
|
1303
|
+
onCloseModal: v
|
|
1332
1304
|
}
|
|
1333
1305
|
),
|
|
1334
|
-
|
|
1335
|
-
|
|
1306
|
+
h === z.Opened && /* @__PURE__ */ m(
|
|
1307
|
+
Pt,
|
|
1336
1308
|
{
|
|
1337
|
-
conversation:
|
|
1309
|
+
conversation: o,
|
|
1338
1310
|
locale: e,
|
|
1339
|
-
onCloseModal:
|
|
1340
|
-
...
|
|
1311
|
+
onCloseModal: N,
|
|
1312
|
+
...r
|
|
1341
1313
|
}
|
|
1342
1314
|
),
|
|
1343
|
-
|
|
1344
|
-
|
|
1315
|
+
E === z.Opened && /* @__PURE__ */ m(
|
|
1316
|
+
Dt,
|
|
1345
1317
|
{
|
|
1346
|
-
conversation:
|
|
1318
|
+
conversation: o,
|
|
1347
1319
|
locale: e,
|
|
1348
|
-
titles:
|
|
1349
|
-
renameConversation:
|
|
1350
|
-
onCloseModal:
|
|
1351
|
-
disableModalDividers:
|
|
1352
|
-
isSmallButton:
|
|
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
|
-
},
|
|
1357
|
-
|
|
1328
|
+
}, Tt = ({ disabled: o }) => /* @__PURE__ */ m(
|
|
1329
|
+
"div",
|
|
1358
1330
|
{
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
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
|
-
)
|
|
1365
|
-
conversation:
|
|
1366
|
-
selectedConversationId:
|
|
1367
|
-
searchQuery:
|
|
1368
|
-
onConversationClick:
|
|
1369
|
-
actions:
|
|
1370
|
-
locale:
|
|
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:
|
|
1354
|
+
shareConversationProps: e
|
|
1373
1355
|
}) => {
|
|
1374
|
-
const
|
|
1356
|
+
const n = ze(null), t = fe(o?.name);
|
|
1375
1357
|
return ee(() => {
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
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
|
-
}, [
|
|
1368
|
+
}, [o, s]), /* @__PURE__ */ y(
|
|
1388
1369
|
"div",
|
|
1389
1370
|
{
|
|
1390
|
-
ref:
|
|
1391
|
-
className:
|
|
1392
|
-
"flex justify-between items-center py-2 px-3 border-transparent relative group
|
|
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
|
-
|
|
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: () =>
|
|
1397
|
-
title:
|
|
1378
|
+
onClick: () => !f && l(o.folderId, o?.id),
|
|
1379
|
+
title: f ? p?.titles?.noActionsAllowed : t,
|
|
1398
1380
|
children: [
|
|
1399
|
-
/* @__PURE__ */
|
|
1381
|
+
/* @__PURE__ */ y("div", { className: "flex flex-1 min-w-0 items-center", children: [
|
|
1400
1382
|
p.conversationItemIcon ? p.conversationItemIcon : null,
|
|
1401
|
-
/* @__PURE__ */
|
|
1383
|
+
/* @__PURE__ */ m(
|
|
1402
1384
|
"h3",
|
|
1403
1385
|
{
|
|
1404
|
-
className:
|
|
1386
|
+
className: k(
|
|
1405
1387
|
"truncate font-semibold text-neutrals-1000 sm:body-2",
|
|
1406
1388
|
"conversation-item-text",
|
|
1407
|
-
|
|
1389
|
+
s === o?.id ? "conversation-item-text-active" : ""
|
|
1408
1390
|
),
|
|
1409
|
-
title:
|
|
1410
|
-
children:
|
|
1391
|
+
title: f ? p?.titles?.noActionsAllowed : t,
|
|
1392
|
+
children: r?.length ? /* @__PURE__ */ m(
|
|
1411
1393
|
Qe,
|
|
1412
1394
|
{
|
|
1413
|
-
text:
|
|
1414
|
-
highlightText:
|
|
1395
|
+
text: t,
|
|
1396
|
+
highlightText: r
|
|
1415
1397
|
}
|
|
1416
|
-
) :
|
|
1398
|
+
) : t
|
|
1417
1399
|
}
|
|
1418
1400
|
)
|
|
1419
1401
|
] }),
|
|
1420
|
-
/* @__PURE__ */
|
|
1421
|
-
|
|
1402
|
+
/* @__PURE__ */ m(
|
|
1403
|
+
Ot,
|
|
1422
1404
|
{
|
|
1423
|
-
locale:
|
|
1405
|
+
locale: d,
|
|
1424
1406
|
conversationStyles: p,
|
|
1425
|
-
conversation:
|
|
1426
|
-
onConversationDelete:
|
|
1427
|
-
getConversation:
|
|
1428
|
-
getFileBlob:
|
|
1429
|
-
renameConversation:
|
|
1430
|
-
shareConversationProps:
|
|
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
|
-
},
|
|
1437
|
-
handleConversationClick:
|
|
1438
|
-
actions:
|
|
1439
|
-
selectedConversationId:
|
|
1440
|
-
groupLabel:
|
|
1441
|
-
conversationStyles:
|
|
1442
|
-
groupedConversations:
|
|
1443
|
-
shareConversationProps:
|
|
1444
|
-
locale:
|
|
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 [
|
|
1447
|
-
|
|
1448
|
-
}, [
|
|
1449
|
-
return /* @__PURE__ */
|
|
1450
|
-
/* @__PURE__ */
|
|
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:
|
|
1438
|
+
onClick: i,
|
|
1455
1439
|
children: [
|
|
1456
|
-
/* @__PURE__ */
|
|
1457
|
-
|
|
1440
|
+
/* @__PURE__ */ m(
|
|
1441
|
+
Xe,
|
|
1458
1442
|
{
|
|
1459
|
-
className:
|
|
1443
|
+
className: k(
|
|
1460
1444
|
"w-3 h-3 conversation-group-items-arrow",
|
|
1461
|
-
|
|
1445
|
+
n ? "rotate-[90deg]" : "rotate-0"
|
|
1462
1446
|
)
|
|
1463
1447
|
}
|
|
1464
1448
|
),
|
|
1465
|
-
/* @__PURE__ */
|
|
1449
|
+
/* @__PURE__ */ m("span", { className: "body-3 conversation-group-items-title-text", children: it(l, c?.titles) })
|
|
1466
1450
|
]
|
|
1467
1451
|
}
|
|
1468
1452
|
),
|
|
1469
|
-
!
|
|
1453
|
+
!n && /* @__PURE__ */ m(
|
|
1470
1454
|
"div",
|
|
1471
1455
|
{
|
|
1472
|
-
className:
|
|
1456
|
+
className: k(
|
|
1473
1457
|
"flex flex-col gap-y-3",
|
|
1474
1458
|
"conversation-group-items"
|
|
1475
1459
|
),
|
|
1476
|
-
children:
|
|
1477
|
-
(
|
|
1460
|
+
children: ye(d).map(
|
|
1461
|
+
(a) => /* @__PURE__ */ m(
|
|
1478
1462
|
Fe,
|
|
1479
1463
|
{
|
|
1480
|
-
locale:
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
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
|
-
|
|
1473
|
+
a.id || a.name
|
|
1489
1474
|
)
|
|
1490
1475
|
)
|
|
1491
1476
|
}
|
|
1492
1477
|
)
|
|
1493
|
-
] },
|
|
1494
|
-
},
|
|
1495
|
-
searchQuery:
|
|
1496
|
-
isExpandedSearch:
|
|
1497
|
-
titles:
|
|
1498
|
-
searchIcon:
|
|
1499
|
-
onSearchConversations:
|
|
1500
|
-
toggleSearchField:
|
|
1501
|
-
}) => /* @__PURE__ */
|
|
1502
|
-
|
|
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:
|
|
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:
|
|
1509
|
-
iconAfterInput: /* @__PURE__ */
|
|
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:
|
|
1514
|
-
icon: /* @__PURE__ */
|
|
1498
|
+
onClick: d,
|
|
1499
|
+
icon: /* @__PURE__ */ m(Ke, {})
|
|
1515
1500
|
}
|
|
1516
1501
|
),
|
|
1517
|
-
onChange:
|
|
1502
|
+
onChange: c
|
|
1518
1503
|
}
|
|
1519
|
-
) : /* @__PURE__ */
|
|
1520
|
-
|
|
1504
|
+
) : /* @__PURE__ */ m(
|
|
1505
|
+
Q,
|
|
1521
1506
|
{
|
|
1522
1507
|
buttonClassName: "text-button-tertiary p-0 search-button",
|
|
1523
|
-
iconBefore:
|
|
1524
|
-
onClick:
|
|
1508
|
+
iconBefore: l || /* @__PURE__ */ m(Ze, { className: "w-5 h-5" }),
|
|
1509
|
+
onClick: d
|
|
1525
1510
|
}
|
|
1526
|
-
) }),
|
|
1527
|
-
conversations:
|
|
1528
|
-
selectedConversationId:
|
|
1529
|
-
searchQuery:
|
|
1530
|
-
conversationStyles:
|
|
1531
|
-
handleConversationClick:
|
|
1532
|
-
actions:
|
|
1533
|
-
locale:
|
|
1534
|
-
shareConversationProps:
|
|
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
|
-
|
|
1537
|
-
const [e, n] = F([]);
|
|
1521
|
+
const [e, n] = T([]);
|
|
1538
1522
|
return ee(() => {
|
|
1539
1523
|
n(
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
(
|
|
1543
|
-
|
|
1544
|
-
|
|
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
|
-
}, [
|
|
1532
|
+
}, [o, r]), /* @__PURE__ */ m(q, { children: e?.length ? e.map((t) => /* @__PURE__ */ m(
|
|
1552
1533
|
Fe,
|
|
1553
1534
|
{
|
|
1554
|
-
locale:
|
|
1555
|
-
conversationStyles:
|
|
1556
|
-
conversation:
|
|
1557
|
-
searchQuery:
|
|
1558
|
-
selectedConversationId:
|
|
1559
|
-
onConversationClick:
|
|
1560
|
-
actions:
|
|
1561
|
-
shareConversationProps:
|
|
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
|
-
|
|
1564
|
-
)) : /* @__PURE__ */
|
|
1565
|
-
},
|
|
1566
|
-
/* @__PURE__ */
|
|
1567
|
-
/* @__PURE__ */
|
|
1568
|
-
] }),
|
|
1569
|
-
handleConversationClick:
|
|
1570
|
-
selectedConversationId:
|
|
1571
|
-
actions:
|
|
1572
|
-
children:
|
|
1573
|
-
isCollapsed:
|
|
1574
|
-
|
|
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:
|
|
1577
|
-
sharedConversations:
|
|
1578
|
-
setConversations:
|
|
1579
|
-
setSharedConversations:
|
|
1580
|
-
shareConversationProps:
|
|
1581
|
-
handleSelectedConversationRemove:
|
|
1558
|
+
locale: e,
|
|
1559
|
+
sharedConversations: n,
|
|
1560
|
+
setConversations: t,
|
|
1561
|
+
setSharedConversations: i,
|
|
1562
|
+
shareConversationProps: a,
|
|
1563
|
+
handleSelectedConversationRemove: h
|
|
1582
1564
|
}) => {
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
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
|
-
|
|
1592
|
-
...
|
|
1593
|
-
...
|
|
1572
|
+
E({
|
|
1573
|
+
...tt(n),
|
|
1574
|
+
...st(p)
|
|
1594
1575
|
});
|
|
1595
|
-
}, [p,
|
|
1576
|
+
}, [p, n]), ee(() => {
|
|
1596
1577
|
async function M() {
|
|
1597
1578
|
try {
|
|
1598
|
-
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1579
|
+
v(!0);
|
|
1580
|
+
const b = await D(e), L = await A(
|
|
1581
|
+
re(se.ME)
|
|
1601
1582
|
);
|
|
1602
|
-
|
|
1583
|
+
t(K(b)), i(
|
|
1603
1584
|
K(
|
|
1604
|
-
|
|
1585
|
+
ue(L, e)
|
|
1605
1586
|
)
|
|
1606
1587
|
);
|
|
1607
|
-
} catch (
|
|
1608
|
-
console.error("Error loading conversation",
|
|
1588
|
+
} catch (b) {
|
|
1589
|
+
console.error("Error loading conversation", b);
|
|
1609
1590
|
} finally {
|
|
1610
|
-
|
|
1591
|
+
v(!1);
|
|
1611
1592
|
}
|
|
1612
1593
|
}
|
|
1613
1594
|
M();
|
|
1614
1595
|
}, [
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
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
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1605
|
+
await O(M);
|
|
1606
|
+
const b = await D(e), L = await A(
|
|
1607
|
+
re(se.ME)
|
|
1627
1608
|
);
|
|
1628
|
-
|
|
1609
|
+
t(K(b)), i(
|
|
1629
1610
|
K(
|
|
1630
|
-
|
|
1611
|
+
ue(L, e)
|
|
1631
1612
|
)
|
|
1632
|
-
),
|
|
1633
|
-
} catch (
|
|
1634
|
-
console.error("Error deleting conversation",
|
|
1613
|
+
), s === M?.id && h();
|
|
1614
|
+
} catch (b) {
|
|
1615
|
+
console.error("Error deleting conversation", b);
|
|
1635
1616
|
}
|
|
1636
1617
|
},
|
|
1637
1618
|
[
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1619
|
+
O,
|
|
1620
|
+
D,
|
|
1621
|
+
e,
|
|
1622
|
+
A,
|
|
1623
|
+
t,
|
|
1624
|
+
i,
|
|
1625
|
+
s,
|
|
1626
|
+
h
|
|
1646
1627
|
]
|
|
1647
|
-
),
|
|
1648
|
-
async (M,
|
|
1628
|
+
), Y = B(
|
|
1629
|
+
async (M, b) => {
|
|
1649
1630
|
try {
|
|
1650
|
-
|
|
1651
|
-
const L = await
|
|
1652
|
-
|
|
1631
|
+
v(!0), await $(M, b);
|
|
1632
|
+
const L = await D(e), W = await A(
|
|
1633
|
+
re(se.ME)
|
|
1653
1634
|
);
|
|
1654
|
-
|
|
1635
|
+
t(K(L)), i(
|
|
1655
1636
|
K(
|
|
1656
|
-
|
|
1637
|
+
ue(W, e)
|
|
1657
1638
|
)
|
|
1658
1639
|
);
|
|
1659
1640
|
} catch (L) {
|
|
1660
1641
|
console.error("Error renaming conversation", L);
|
|
1661
1642
|
} finally {
|
|
1662
|
-
|
|
1643
|
+
v(!1);
|
|
1663
1644
|
}
|
|
1664
1645
|
},
|
|
1665
1646
|
[
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1647
|
+
D,
|
|
1648
|
+
e,
|
|
1649
|
+
A,
|
|
1650
|
+
t,
|
|
1651
|
+
i,
|
|
1652
|
+
$
|
|
1672
1653
|
]
|
|
1673
|
-
),
|
|
1654
|
+
), j = B(
|
|
1674
1655
|
(M) => {
|
|
1675
|
-
|
|
1656
|
+
C(M);
|
|
1676
1657
|
},
|
|
1677
|
-
[
|
|
1678
|
-
),
|
|
1679
|
-
|
|
1680
|
-
}, [
|
|
1681
|
-
return
|
|
1682
|
-
!
|
|
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:
|
|
1666
|
+
className: k(
|
|
1686
1667
|
"flex justify-between items-center",
|
|
1687
|
-
|
|
1668
|
+
R ? " pt-4 pb-0 sm:pt-10" : " pt-6 pb-2 sm:pt-10"
|
|
1688
1669
|
),
|
|
1689
1670
|
children: [
|
|
1690
|
-
!
|
|
1691
|
-
/* @__PURE__ */
|
|
1692
|
-
|
|
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:
|
|
1695
|
-
searchIcon:
|
|
1696
|
-
titles:
|
|
1697
|
-
isExpandedSearch:
|
|
1698
|
-
onSearchConversations:
|
|
1699
|
-
toggleSearchField:
|
|
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__ */
|
|
1686
|
+
/* @__PURE__ */ m(
|
|
1706
1687
|
"div",
|
|
1707
1688
|
{
|
|
1708
|
-
className:
|
|
1689
|
+
className: k(
|
|
1709
1690
|
"overflow-y-auto flex flex-col mt-4 flex-1 min-h-0 pr-2",
|
|
1710
|
-
|
|
1691
|
+
H ? "gap-y-1" : "gap-y-6"
|
|
1711
1692
|
),
|
|
1712
|
-
children:
|
|
1713
|
-
|
|
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:
|
|
1716
|
-
conversationStyles:
|
|
1717
|
-
conversations: [...
|
|
1718
|
-
searchQuery:
|
|
1719
|
-
selectedConversationId:
|
|
1720
|
-
handleConversationClick:
|
|
1721
|
-
shareConversationProps:
|
|
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
|
-
...
|
|
1724
|
-
deleteConversation:
|
|
1704
|
+
...r,
|
|
1705
|
+
deleteConversation: P
|
|
1725
1706
|
}
|
|
1726
1707
|
}
|
|
1727
|
-
) : Object.entries(
|
|
1728
|
-
([M,
|
|
1729
|
-
|
|
1708
|
+
) : Object.entries(u).map(
|
|
1709
|
+
([M, b]) => b?.length > 0 && /* @__PURE__ */ m(
|
|
1710
|
+
Lt,
|
|
1730
1711
|
{
|
|
1731
|
-
locale:
|
|
1712
|
+
locale: e,
|
|
1713
|
+
isDisabled: d,
|
|
1732
1714
|
groupLabel: M,
|
|
1733
|
-
conversationStyles:
|
|
1734
|
-
groupedConversations:
|
|
1735
|
-
handleConversationClick:
|
|
1715
|
+
conversationStyles: f,
|
|
1716
|
+
groupedConversations: b,
|
|
1717
|
+
handleConversationClick: o,
|
|
1736
1718
|
actions: {
|
|
1737
|
-
...
|
|
1738
|
-
deleteConversation:
|
|
1739
|
-
renameConversation:
|
|
1719
|
+
...r,
|
|
1720
|
+
deleteConversation: P,
|
|
1721
|
+
renameConversation: Y
|
|
1740
1722
|
},
|
|
1741
|
-
shareConversationProps:
|
|
1742
|
-
selectedConversationId:
|
|
1723
|
+
shareConversationProps: a,
|
|
1724
|
+
selectedConversationId: s
|
|
1743
1725
|
},
|
|
1744
1726
|
M
|
|
1745
1727
|
)
|
|
1746
1728
|
) })
|
|
1747
1729
|
}
|
|
1748
1730
|
),
|
|
1749
|
-
|
|
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
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
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
|
};
|