@ethora/chat-component 26.9.5 → 26.9.8
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/README.md +45 -1
- package/dist/{ChatProfileModal-Pr4--RdW.js → ChatProfileModal-3UH0H5Ec.js} +725 -714
- package/dist/{FilePreviewModal-CYHlKzRc.js → FilePreviewModal-Cgj1iHry.js} +161 -161
- package/dist/{ManageDataModal-BE1eGlYh.js → ManageDataModal-BblTuE9g.js} +14 -14
- package/dist/{MarkdownBody-G0_J0NL6.js → MarkdownBody-RMEx8yW2.js} +1 -1
- package/dist/MessageSearchModal-CrYR2EH8.js +381 -0
- package/dist/PublicChatsModal-Bi5r4mrV.js +202 -0
- package/dist/{SideDrawer-BG2m7Bcm.js → SideDrawer-CDAoobvX.js} +34 -34
- package/dist/{UserProfileModal-B2Hp5bAF.js → UserProfileModal-4Frgvam-.js} +3 -3
- package/dist/{UserSettingsModal-D871FDAT.js → UserSettingsModal-C-mb-9cb.js} +2 -2
- package/dist/{VideoCallOverlay-Br0ji0nZ.js → VideoCallOverlay-92dFLb9U.js} +1 -1
- package/dist/{VisibilityModal-DdFBV1_g.js → VisibilityModal-zIAV6dAP.js} +9 -9
- package/dist/assets/icons.d.ts +9 -0
- package/dist/components/InputComponents/MentionDropdown.d.ts +2 -0
- package/dist/components/InputComponents/Search.d.ts +4 -0
- package/dist/components/MainComponents/ArchivedMessageCard.d.ts +11 -0
- package/dist/components/MainComponents/scrollAnchor.d.ts +19 -0
- package/dist/components/MainComponents/useJumpToMessage.d.ts +94 -0
- package/dist/components/MainComponents/useScrollAnchor.d.ts +29 -0
- package/dist/components/MainComponents/useStickToBottom.d.ts +27 -0
- package/dist/components/Modals/MessageSearchModal/MessageHitResults.d.ts +27 -0
- package/dist/components/Modals/MessageSearchModal/MessageSearchModal.d.ts +6 -0
- package/dist/components/Modals/MessageSearchModal/resolveSender.d.ts +33 -0
- package/dist/components/Modals/MessageSearchModal/searchFilters.d.ts +34 -0
- package/dist/components/Modals/MessageSearchModal/snippet.d.ts +14 -0
- package/dist/components/Modals/MessageSearchModal/useMessageSearch.d.ts +22 -0
- package/dist/components/Modals/PublicChatsModal/PublicChatsModal.d.ts +13 -0
- package/dist/components/Modals/styledModalComponents.d.ts +0 -8
- package/dist/components/styled/RoomListComponents/index.d.ts +3 -0
- package/dist/context/ToastContext.d.ts +7 -0
- package/dist/firebase-messaging-sw.js +21 -3
- package/dist/{handleCopyClick-DPjxMoJn.js → handleCopyClick-BtXos0AJ.js} +1 -1
- package/dist/helpers/checkUniqueUsers.d.ts +2 -2
- package/dist/helpers/constants/MODAL_TYPES.d.ts +2 -0
- package/dist/helpers/dedupeMembers.d.ts +10 -0
- package/dist/helpers/historyPreloadConfig.d.ts +25 -0
- package/dist/helpers/historyPreloadScheduler.d.ts +3 -0
- package/dist/helpers/insertMessageWithDelimiter.d.ts +1 -0
- package/dist/helpers/isMessageSearchEnabled.d.ts +9 -0
- package/dist/helpers/jumpThread.d.ts +56 -0
- package/dist/helpers/jumpWindow.d.ts +73 -0
- package/dist/helpers/nanoToMs.d.ts +1 -1
- package/dist/helpers/openRoomAtMessage.d.ts +17 -0
- package/dist/helpers/openThreadForJump.d.ts +26 -0
- package/dist/helpers/pdf/loadPdfjs.d.ts +8 -1
- package/dist/helpers/roomUserCount.d.ts +19 -0
- package/dist/helpers/userResolver.d.ts +57 -0
- package/dist/helpers/xmppIdShape.d.ts +1 -1
- package/dist/hooks/useChatWrapperInit.d.ts +6 -0
- package/dist/hooks/useMessageSearchShortcut.d.ts +14 -0
- package/dist/hooks/usePdfThumbnail.d.ts +2 -1
- package/dist/hooks/useRoomDirectory.d.ts +11 -0
- package/dist/hooks/useRoomState.d.ts +1 -0
- package/dist/{main-BRIZ98KV.js → main-BnLtessp.js} +24764 -21859
- package/dist/main.css +1 -1
- package/dist/main.js +16 -16
- package/dist/networking/api-requests/messageSearch.api.d.ts +56 -0
- package/dist/networking/api-requests/publicChats.api.d.ts +23 -0
- package/dist/networking/api-requests/roomMembers.api.d.ts +18 -0
- package/dist/networking/api-requests/xmppToken.api.d.ts +1 -0
- package/dist/networking/ethoraEvents.d.ts +44 -0
- package/dist/networking/stanzaHandlers.d.ts +2 -2
- package/dist/networking/xmpp/allRoomPresences.xmpp.d.ts +18 -1
- package/dist/networking/xmpp/presenceInRoom.xmpp.d.ts +1 -1
- package/dist/networking/xmppClient.d.ts +58 -2
- package/dist/roomStore/Middleware/jumpThreadMiddleware.d.ts +2 -0
- package/dist/roomStore/chatSettingsSlice.d.ts +1 -1
- package/dist/roomStore/index.d.ts +12 -0
- package/dist/roomStore/roomsSlice.d.ts +70 -1
- package/dist/roomStore/safeKey.d.ts +12 -0
- package/dist/roomStore/usersSetCap.d.ts +15 -0
- package/dist/styles/classNames.d.ts +2 -0
- package/dist/types/models/config.model.d.ts +78 -0
- package/dist/types/models/room.model.d.ts +14 -0
- package/dist/types/models/xmpp.model.d.ts +21 -1
- package/dist/utils/notificationUtils.d.ts +12 -0
- package/dist/version.d.ts +1 -1
- package/package.json +2 -1
- package/public/firebase-messaging-sw.js +21 -3
- package/dist/components/Modals/NewChatModal/UpdNewChatModal.d.ts +0 -3
- package/dist/components/SortDropDown/index.d.ts +0 -8
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { jsx as l, jsxs as B } from "react/jsx-runtime";
|
|
2
2
|
import te, { useState as H, useRef as z, useEffect as O, useMemo as $, useCallback as k } from "react";
|
|
3
|
-
import { p as le, b as pe,
|
|
3
|
+
import { p as le, b as pe, aZ as we, ae as ve, x as X, B as V, a_ as xe, a$ as be, aE as ye, b0 as Ee, b1 as Le, b2 as ue, b3 as ne, a as Ce, aV as Me, u as Q, a5 as Pe, b4 as re, ay as Re, as as J, b5 as ke, b6 as Se, b7 as Ae, b8 as Te, b9 as Ie, ba as Xe, bb as Ye, bc as ze, bd as Oe, aF as De, be as Fe, bf as Ue, aD as Be, bg as He, w as Ne } from "./main-BnLtessp.js";
|
|
4
4
|
function oe(t, i) {
|
|
5
|
-
let
|
|
5
|
+
let n;
|
|
6
6
|
return (...E) => {
|
|
7
|
-
window.clearTimeout(
|
|
7
|
+
window.clearTimeout(n), n = window.setTimeout(() => t(...E), i);
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
function _e({ debounce: t, scroll: i, polyfill:
|
|
11
|
-
const L =
|
|
10
|
+
function _e({ debounce: t, scroll: i, polyfill: n, offsetSize: E } = { debounce: 0, scroll: !1, offsetSize: !1 }) {
|
|
11
|
+
const L = n || (typeof window > "u" ? class {
|
|
12
12
|
} : window.ResizeObserver);
|
|
13
13
|
if (!L) throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");
|
|
14
|
-
const [u, C] = H({ left: 0, top: 0, width: 0, height: 0, bottom: 0, right: 0, x: 0, y: 0 }),
|
|
15
|
-
O(() => (
|
|
16
|
-
|
|
14
|
+
const [u, C] = H({ left: 0, top: 0, width: 0, height: 0, bottom: 0, right: 0, x: 0, y: 0 }), r = z({ element: null, scrollContainers: null, resizeObserver: null, lastBounds: u, orientationHandler: null }), M = t ? typeof t == "number" ? t : t.scroll : null, p = t ? typeof t == "number" ? t : t.resize : null, A = z(!1);
|
|
15
|
+
O(() => (A.current = !0, () => {
|
|
16
|
+
A.current = !1;
|
|
17
17
|
}));
|
|
18
18
|
const [b, x, m] = $(() => {
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
const { left: g, top: w, width: v, height:
|
|
22
|
-
|
|
19
|
+
const o = () => {
|
|
20
|
+
if (!r.current.element) return;
|
|
21
|
+
const { left: g, top: w, width: v, height: U, bottom: S, right: P, x: f, y: h } = r.current.element.getBoundingClientRect(), T = { left: g, top: w, width: v, height: U, bottom: S, right: P, x: f, y: h };
|
|
22
|
+
r.current.element instanceof HTMLElement && E && (T.height = r.current.element.offsetHeight, T.width = r.current.element.offsetWidth), Object.freeze(T), A.current && !Ze(r.current.lastBounds, T) && C(r.current.lastBounds = T);
|
|
23
23
|
};
|
|
24
|
-
return [
|
|
25
|
-
}, [C, E,
|
|
24
|
+
return [o, p ? oe(o, p) : o, M ? oe(o, M) : o];
|
|
25
|
+
}, [C, E, M, p]);
|
|
26
26
|
function y() {
|
|
27
|
-
|
|
27
|
+
r.current.scrollContainers && (r.current.scrollContainers.forEach((o) => o.removeEventListener("scroll", m, !0)), r.current.scrollContainers = null), r.current.resizeObserver && (r.current.resizeObserver.disconnect(), r.current.resizeObserver = null), r.current.orientationHandler && ("orientation" in screen && "removeEventListener" in screen.orientation ? screen.orientation.removeEventListener("change", r.current.orientationHandler) : "onorientationchange" in window && window.removeEventListener("orientationchange", r.current.orientationHandler));
|
|
28
28
|
}
|
|
29
29
|
function Y() {
|
|
30
|
-
|
|
30
|
+
r.current.element && (r.current.resizeObserver = new L(m), r.current.resizeObserver.observe(r.current.element), i && r.current.scrollContainers && r.current.scrollContainers.forEach((o) => o.addEventListener("scroll", m, { capture: !0, passive: !0 })), r.current.orientationHandler = () => {
|
|
31
31
|
m();
|
|
32
|
-
}, "orientation" in screen && "addEventListener" in screen.orientation ? screen.orientation.addEventListener("change",
|
|
32
|
+
}, "orientation" in screen && "addEventListener" in screen.orientation ? screen.orientation.addEventListener("change", r.current.orientationHandler) : "onorientationchange" in window && window.addEventListener("orientationchange", r.current.orientationHandler));
|
|
33
33
|
}
|
|
34
|
-
const F = (
|
|
35
|
-
!
|
|
34
|
+
const F = (o) => {
|
|
35
|
+
!o || o === r.current.element || (y(), r.current.element = o, r.current.scrollContainers = de(o), Y());
|
|
36
36
|
};
|
|
37
37
|
return $e(m, !!i), je(x), O(() => {
|
|
38
38
|
y(), Y();
|
|
@@ -49,9 +49,9 @@ function je(t) {
|
|
|
49
49
|
function $e(t, i) {
|
|
50
50
|
O(() => {
|
|
51
51
|
if (i) {
|
|
52
|
-
const
|
|
53
|
-
return window.addEventListener("scroll",
|
|
54
|
-
window.removeEventListener("scroll",
|
|
52
|
+
const n = t;
|
|
53
|
+
return window.addEventListener("scroll", n, { capture: !0, passive: !0 }), () => {
|
|
54
|
+
window.removeEventListener("scroll", n, !0);
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
}, [t, i]);
|
|
@@ -59,10 +59,10 @@ function $e(t, i) {
|
|
|
59
59
|
function de(t) {
|
|
60
60
|
const i = [];
|
|
61
61
|
if (!t || t === document.body) return i;
|
|
62
|
-
const { overflow:
|
|
63
|
-
return [
|
|
62
|
+
const { overflow: n, overflowX: E, overflowY: L } = window.getComputedStyle(t);
|
|
63
|
+
return [n, E, L].some((u) => u === "auto" || u === "scroll") && i.push(t), [...i, ...de(t.parentElement)];
|
|
64
64
|
}
|
|
65
|
-
const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"],
|
|
65
|
+
const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], Ze = (t, i) => Ve.every((n) => t[n] === i[n]), ie = X.div`
|
|
66
66
|
display: flex;
|
|
67
67
|
flex-direction: column;
|
|
68
68
|
align-items: center;
|
|
@@ -70,7 +70,7 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
70
70
|
width: 100%;
|
|
71
71
|
height: 100%;
|
|
72
72
|
overflow: auto;
|
|
73
|
-
`,
|
|
73
|
+
`, We = X.div`
|
|
74
74
|
display: flex;
|
|
75
75
|
align-items: flex-start;
|
|
76
76
|
justify-content: center;
|
|
@@ -109,13 +109,13 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
109
109
|
a {
|
|
110
110
|
color: var(--ethora-color-primary-text, var(--ethora-color-primary, #0052cd));
|
|
111
111
|
}
|
|
112
|
-
`,
|
|
113
|
-
const i = le(), { config:
|
|
112
|
+
`, qe = ({ pdfUrl: t }) => {
|
|
113
|
+
const i = le(), { config: n } = pe(), [E, L] = _e(), u = z(null), C = z(null), r = z(null), [M, p] = H("loading"), [A, b] = H(0), [x, m] = H(1), y = Math.max(320, Math.floor(L.width || 0));
|
|
114
114
|
O(() => {
|
|
115
|
-
let
|
|
115
|
+
let o = !1, g;
|
|
116
116
|
return p("loading"), m(1), b(0), (async () => {
|
|
117
|
-
const w = await we(
|
|
118
|
-
if (!
|
|
117
|
+
const w = await we(n?.pdfPreview?.workerSrc, n?.pdfPreview?.libUrl);
|
|
118
|
+
if (!o) {
|
|
119
119
|
if (!w || !t) {
|
|
120
120
|
p("error");
|
|
121
121
|
return;
|
|
@@ -123,59 +123,59 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
123
123
|
try {
|
|
124
124
|
g = w.getDocument({ url: t, isEvalSupported: !1 });
|
|
125
125
|
const v = await g.promise;
|
|
126
|
-
if (
|
|
126
|
+
if (o) {
|
|
127
127
|
v.destroy().catch(() => {
|
|
128
128
|
});
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
C.current = v, b(v.numPages), p("ready");
|
|
132
132
|
} catch (v) {
|
|
133
|
-
|
|
133
|
+
o || (console.warn("[Ethora] PDF open failed:", v), p("error"));
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
})(), () => {
|
|
137
|
-
|
|
137
|
+
o = !0, r.current?.cancel(), r.current = null, C.current?.destroy?.().catch(() => {
|
|
138
138
|
}), C.current = null, g?.destroy?.().catch(() => {
|
|
139
139
|
});
|
|
140
140
|
};
|
|
141
|
-
}, [t,
|
|
142
|
-
const
|
|
143
|
-
if (
|
|
141
|
+
}, [t, n?.pdfPreview?.workerSrc, n?.pdfPreview?.libUrl]), O(() => {
|
|
142
|
+
const o = C.current, g = u.current;
|
|
143
|
+
if (M !== "ready" || !o || !g || y <= 0) return;
|
|
144
144
|
let w = !1;
|
|
145
145
|
return (async () => {
|
|
146
146
|
try {
|
|
147
|
-
const v = await
|
|
147
|
+
const v = await o.getPage(x);
|
|
148
148
|
if (w) return;
|
|
149
|
-
const
|
|
150
|
-
g.width = Math.max(1, Math.floor(
|
|
149
|
+
const U = v.getViewport({ scale: 1 }), S = U.width ? y / U.width : 1, P = v.getViewport({ scale: S });
|
|
150
|
+
g.width = Math.max(1, Math.floor(P.width)), g.height = Math.max(1, Math.floor(P.height));
|
|
151
151
|
const f = g.getContext("2d");
|
|
152
152
|
if (!f) {
|
|
153
153
|
p("error");
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
const h = v.render({ canvasContext: f, viewport:
|
|
158
|
-
|
|
156
|
+
r.current?.cancel();
|
|
157
|
+
const h = v.render({ canvasContext: f, viewport: P });
|
|
158
|
+
r.current = h, await h.promise, v.cleanup();
|
|
159
159
|
} catch (v) {
|
|
160
160
|
w || console.warn("[Ethora] PDF page render failed:", v);
|
|
161
161
|
}
|
|
162
162
|
})(), () => {
|
|
163
|
-
w = !0,
|
|
163
|
+
w = !0, r.current?.cancel(), r.current = null;
|
|
164
164
|
};
|
|
165
|
-
}, [
|
|
165
|
+
}, [M, x, y]);
|
|
166
166
|
const Y = k(
|
|
167
|
-
() => m((
|
|
167
|
+
() => m((o) => Math.max(1, o - 1)),
|
|
168
168
|
[]
|
|
169
169
|
), F = k(
|
|
170
|
-
() => m((
|
|
171
|
-
[
|
|
170
|
+
() => m((o) => Math.min(A || 1, o + 1)),
|
|
171
|
+
[A]
|
|
172
172
|
);
|
|
173
|
-
return
|
|
173
|
+
return M === "error" ? /* @__PURE__ */ l(ie, { children: /* @__PURE__ */ B(Ge, { children: [
|
|
174
174
|
/* @__PURE__ */ l("span", { children: i("modal.filePreview.pdfUnavailable") }),
|
|
175
175
|
/* @__PURE__ */ l("a", { href: t, target: "_blank", rel: "noopener noreferrer", children: i("modal.filePreview.openExternally") })
|
|
176
176
|
] }) }) : /* @__PURE__ */ B(ie, { children: [
|
|
177
|
-
/* @__PURE__ */ l(
|
|
178
|
-
|
|
177
|
+
/* @__PURE__ */ l(We, { ref: E, children: M === "loading" ? /* @__PURE__ */ l(ve, { color: n?.colors?.primary }) : /* @__PURE__ */ l("canvas", { ref: u }) }),
|
|
178
|
+
A > 1 && /* @__PURE__ */ B(Ke, { children: [
|
|
179
179
|
/* @__PURE__ */ l(
|
|
180
180
|
ae,
|
|
181
181
|
{
|
|
@@ -188,20 +188,20 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
188
188
|
/* @__PURE__ */ B("span", { children: [
|
|
189
189
|
x,
|
|
190
190
|
" / ",
|
|
191
|
-
|
|
191
|
+
A
|
|
192
192
|
] }),
|
|
193
193
|
/* @__PURE__ */ l(
|
|
194
194
|
ae,
|
|
195
195
|
{
|
|
196
196
|
onClick: F,
|
|
197
|
-
disabled: x >=
|
|
197
|
+
disabled: x >= A,
|
|
198
198
|
text: "›",
|
|
199
199
|
"aria-label": i("modal.filePreview.nextPage")
|
|
200
200
|
}
|
|
201
201
|
)
|
|
202
202
|
] })
|
|
203
203
|
] });
|
|
204
|
-
}, I = 1, ee = 6,
|
|
204
|
+
}, I = 1, ee = 6, Qe = 2.5, Je = 50, et = 300, se = 24, tt = 16e-4, G = (t, i, n) => Math.min(n, Math.max(i, t)), nt = X.div`
|
|
205
205
|
position: relative;
|
|
206
206
|
/* An explicit height, not flex growth alone: the parent lays its children
|
|
207
207
|
out in a row and centres them, so the viewport would otherwise be sized
|
|
@@ -234,38 +234,38 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
234
234
|
transition: ${({ $animate: t }) => t ? `transform ${xe} ${be}` : "none"};
|
|
235
235
|
${ye}
|
|
236
236
|
`, fe = te.forwardRef(
|
|
237
|
-
({ src: t, alt: i, onSwipeLeft:
|
|
238
|
-
const
|
|
239
|
-
|
|
237
|
+
({ src: t, alt: i, onSwipeLeft: n, onSwipeRight: E, onError: L, onScaleChange: u }, C) => {
|
|
238
|
+
const r = z(null), M = z(null), [p, A] = H(I), [b, x] = H({ x: 0, y: 0 }), [m, y] = H(!1), [Y, F] = H(!1), o = z({ scale: I, offset: { x: 0, y: 0 } });
|
|
239
|
+
o.current = { scale: p, offset: b };
|
|
240
240
|
const g = z(null), w = z(null), v = z(
|
|
241
241
|
null
|
|
242
|
-
),
|
|
243
|
-
const e =
|
|
242
|
+
), U = k((a) => {
|
|
243
|
+
const e = r.current, c = M.current;
|
|
244
244
|
if (!e) return { x: 0, y: 0 };
|
|
245
|
-
const s = e.clientWidth, d = e.clientHeight,
|
|
246
|
-
let j = s,
|
|
247
|
-
if (
|
|
248
|
-
const K = Math.min(s /
|
|
249
|
-
j =
|
|
245
|
+
const s = e.clientWidth, d = e.clientHeight, R = c?.naturalWidth || 0, D = c?.naturalHeight || 0;
|
|
246
|
+
let j = s, W = d;
|
|
247
|
+
if (R > 0 && D > 0 && s > 0 && d > 0) {
|
|
248
|
+
const K = Math.min(s / R, d / D);
|
|
249
|
+
j = R * K, W = D * K;
|
|
250
250
|
}
|
|
251
251
|
return {
|
|
252
252
|
x: Math.max(0, (j * a - s) / 2),
|
|
253
|
-
y: Math.max(0, (
|
|
253
|
+
y: Math.max(0, (W * a - d) / 2)
|
|
254
254
|
};
|
|
255
255
|
}, []), S = k(
|
|
256
256
|
(a, e, c) => {
|
|
257
|
-
const s = G(a, I, ee), d =
|
|
258
|
-
y(c),
|
|
257
|
+
const s = G(a, I, ee), d = U(s);
|
|
258
|
+
y(c), A(s), x({
|
|
259
259
|
x: G(e.x, -d.x, d.x),
|
|
260
260
|
y: G(e.y, -d.y, d.y)
|
|
261
261
|
});
|
|
262
262
|
},
|
|
263
|
-
[
|
|
264
|
-
),
|
|
263
|
+
[U]
|
|
264
|
+
), P = k(
|
|
265
265
|
(a, e, c, s) => {
|
|
266
|
-
const d =
|
|
266
|
+
const d = o.current, R = G(a, I, ee), D = R / d.scale;
|
|
267
267
|
S(
|
|
268
|
-
|
|
268
|
+
R,
|
|
269
269
|
{
|
|
270
270
|
x: e - (e - d.offset.x) * D,
|
|
271
271
|
y: c - (c - d.offset.y) * D
|
|
@@ -278,9 +278,9 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
278
278
|
S(I, { x: 0, y: 0 }, !0);
|
|
279
279
|
}, [S]), h = k(
|
|
280
280
|
(a) => {
|
|
281
|
-
|
|
281
|
+
P(o.current.scale * a, 0, 0, !0);
|
|
282
282
|
},
|
|
283
|
-
[
|
|
283
|
+
[P]
|
|
284
284
|
);
|
|
285
285
|
te.useImperativeHandle(
|
|
286
286
|
C,
|
|
@@ -291,45 +291,45 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
291
291
|
}),
|
|
292
292
|
[h, f]
|
|
293
293
|
), O(() => {
|
|
294
|
-
y(!1),
|
|
294
|
+
y(!1), A(I), x({ x: 0, y: 0 });
|
|
295
295
|
}, [t]), O(() => {
|
|
296
296
|
u?.(p);
|
|
297
297
|
}, [p, u]), O(() => {
|
|
298
|
-
const a =
|
|
298
|
+
const a = r.current;
|
|
299
299
|
if (!a) return;
|
|
300
300
|
const e = (c) => {
|
|
301
301
|
c.preventDefault();
|
|
302
|
-
const s = a.getBoundingClientRect(), d = c.clientX - s.left - s.width / 2,
|
|
303
|
-
|
|
302
|
+
const s = a.getBoundingClientRect(), d = c.clientX - s.left - s.width / 2, R = c.clientY - s.top - s.height / 2, D = Math.exp(-c.deltaY * tt);
|
|
303
|
+
P(o.current.scale * D, d, R, !1);
|
|
304
304
|
};
|
|
305
305
|
return a.addEventListener("wheel", e, { passive: !1 }), () => a.removeEventListener("wheel", e);
|
|
306
|
-
}, [
|
|
307
|
-
const
|
|
306
|
+
}, [P]);
|
|
307
|
+
const T = k(
|
|
308
308
|
(a, e) => {
|
|
309
|
-
const c =
|
|
309
|
+
const c = r.current;
|
|
310
310
|
if (!c) return;
|
|
311
|
-
if (
|
|
311
|
+
if (o.current.scale > I) {
|
|
312
312
|
f();
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
315
|
const s = c.getBoundingClientRect();
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
P(
|
|
317
|
+
Qe,
|
|
318
318
|
a - s.left - s.width / 2,
|
|
319
319
|
e - s.top - s.height / 2,
|
|
320
320
|
!0
|
|
321
321
|
);
|
|
322
322
|
},
|
|
323
|
-
[f,
|
|
323
|
+
[f, P]
|
|
324
324
|
), _ = k((a) => {
|
|
325
|
-
a.button === 0 && (
|
|
325
|
+
a.button === 0 && (o.current.scale <= I || (a.preventDefault(), g.current = { x: a.clientX, y: a.clientY }, F(!0)));
|
|
326
326
|
}, []);
|
|
327
327
|
O(() => {
|
|
328
328
|
if (!Y || typeof window > "u") return;
|
|
329
329
|
const a = (c) => {
|
|
330
330
|
const s = g.current;
|
|
331
331
|
if (!s) return;
|
|
332
|
-
const d =
|
|
332
|
+
const d = o.current;
|
|
333
333
|
S(
|
|
334
334
|
d.scale,
|
|
335
335
|
{
|
|
@@ -345,7 +345,7 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
345
345
|
window.removeEventListener("mousemove", a), window.removeEventListener("mouseup", e);
|
|
346
346
|
};
|
|
347
347
|
}, [Y, S]);
|
|
348
|
-
const
|
|
348
|
+
const q = k((a) => {
|
|
349
349
|
if (a.touches.length === 2) {
|
|
350
350
|
const [c, s] = [a.touches[0], a.touches[1]];
|
|
351
351
|
w.current = {
|
|
@@ -357,7 +357,7 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
357
357
|
c.clientX - s.clientX,
|
|
358
358
|
c.clientY - s.clientY
|
|
359
359
|
),
|
|
360
|
-
pinchScale:
|
|
360
|
+
pinchScale: o.current.scale,
|
|
361
361
|
panning: !1,
|
|
362
362
|
moved: !1
|
|
363
363
|
};
|
|
@@ -370,24 +370,24 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
370
370
|
lastX: e.clientX,
|
|
371
371
|
lastY: e.clientY,
|
|
372
372
|
pinchDistance: 0,
|
|
373
|
-
pinchScale:
|
|
374
|
-
panning:
|
|
373
|
+
pinchScale: o.current.scale,
|
|
374
|
+
panning: o.current.scale > I,
|
|
375
375
|
moved: !1
|
|
376
376
|
});
|
|
377
|
-
}, []),
|
|
377
|
+
}, []), Z = k(
|
|
378
378
|
(a) => {
|
|
379
379
|
const e = w.current;
|
|
380
380
|
if (!e) return;
|
|
381
381
|
if (a.touches.length === 2 && e.pinchDistance > 0) {
|
|
382
|
-
const [s, d] = [a.touches[0], a.touches[1]],
|
|
382
|
+
const [s, d] = [a.touches[0], a.touches[1]], R = Math.hypot(
|
|
383
383
|
s.clientX - d.clientX,
|
|
384
384
|
s.clientY - d.clientY
|
|
385
|
-
), D =
|
|
386
|
-
if (!D ||
|
|
387
|
-
const j = D.getBoundingClientRect(),
|
|
388
|
-
e.moved = !0,
|
|
389
|
-
e.pinchScale *
|
|
390
|
-
|
|
385
|
+
), D = r.current;
|
|
386
|
+
if (!D || R <= 0) return;
|
|
387
|
+
const j = D.getBoundingClientRect(), W = (s.clientX + d.clientX) / 2 - j.left - j.width / 2, K = (s.clientY + d.clientY) / 2 - j.top - j.height / 2;
|
|
388
|
+
e.moved = !0, P(
|
|
389
|
+
e.pinchScale * R / e.pinchDistance,
|
|
390
|
+
W,
|
|
391
391
|
K,
|
|
392
392
|
!1
|
|
393
393
|
);
|
|
@@ -396,7 +396,7 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
396
396
|
const c = a.touches[0];
|
|
397
397
|
if (c) {
|
|
398
398
|
if ((Math.abs(c.clientX - e.startX) > 6 || Math.abs(c.clientY - e.startY) > 6) && (e.moved = !0), e.panning) {
|
|
399
|
-
const s =
|
|
399
|
+
const s = o.current;
|
|
400
400
|
S(
|
|
401
401
|
s.scale,
|
|
402
402
|
{
|
|
@@ -409,15 +409,15 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
409
409
|
e.lastX = c.clientX, e.lastY = c.clientY;
|
|
410
410
|
}
|
|
411
411
|
},
|
|
412
|
-
[S,
|
|
413
|
-
),
|
|
412
|
+
[S, P]
|
|
413
|
+
), N = k(
|
|
414
414
|
(a) => {
|
|
415
415
|
const e = w.current;
|
|
416
416
|
if (!e || a.touches.length > 0) return;
|
|
417
417
|
if (w.current = null, !e.moved && e.pinchDistance === 0) {
|
|
418
|
-
const d = Date.now(),
|
|
419
|
-
if (
|
|
420
|
-
v.current = null,
|
|
418
|
+
const d = Date.now(), R = v.current;
|
|
419
|
+
if (R && d - R.time < et && Math.abs(R.x - e.startX) < se && Math.abs(R.y - e.startY) < se) {
|
|
420
|
+
v.current = null, T(e.startX, e.startY);
|
|
421
421
|
return;
|
|
422
422
|
}
|
|
423
423
|
v.current = {
|
|
@@ -427,16 +427,16 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
427
427
|
};
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
|
-
if (e.panning || e.pinchDistance > 0 ||
|
|
430
|
+
if (e.panning || e.pinchDistance > 0 || o.current.scale > I) return;
|
|
431
431
|
const c = e.lastX - e.startX, s = e.lastY - e.startY;
|
|
432
|
-
Math.abs(c) < Je || Math.abs(c) <= Math.abs(s) || (c < 0 ?
|
|
432
|
+
Math.abs(c) < Je || Math.abs(c) <= Math.abs(s) || (c < 0 ? n?.() : E?.());
|
|
433
433
|
},
|
|
434
|
-
[
|
|
434
|
+
[n, E, T]
|
|
435
435
|
), me = k(
|
|
436
436
|
(a) => {
|
|
437
|
-
|
|
437
|
+
T(a.clientX, a.clientY);
|
|
438
438
|
},
|
|
439
|
-
[
|
|
439
|
+
[T]
|
|
440
440
|
), ge = $(
|
|
441
441
|
() => `translate(${b.x}px, ${b.y}px) scale(${p})`,
|
|
442
442
|
[b.x, b.y, p]
|
|
@@ -444,18 +444,18 @@ const Ve = ["x", "y", "top", "bottom", "left", "right", "width", "height"], We =
|
|
|
444
444
|
return /* @__PURE__ */ l(
|
|
445
445
|
nt,
|
|
446
446
|
{
|
|
447
|
-
ref:
|
|
447
|
+
ref: r,
|
|
448
448
|
"data-testid": "image-lightbox-viewport",
|
|
449
449
|
onMouseDown: _,
|
|
450
450
|
onDoubleClick: me,
|
|
451
|
-
onTouchStart:
|
|
452
|
-
onTouchMove:
|
|
453
|
-
onTouchEnd:
|
|
454
|
-
onTouchCancel:
|
|
451
|
+
onTouchStart: q,
|
|
452
|
+
onTouchMove: Z,
|
|
453
|
+
onTouchEnd: N,
|
|
454
|
+
onTouchCancel: N,
|
|
455
455
|
children: /* @__PURE__ */ l(
|
|
456
456
|
rt,
|
|
457
457
|
{
|
|
458
|
-
ref:
|
|
458
|
+
ref: M,
|
|
459
459
|
"data-testid": "image-lightbox-image",
|
|
460
460
|
src: t,
|
|
461
461
|
alt: i,
|
|
@@ -475,12 +475,12 @@ fe.displayName = "ImageLightbox";
|
|
|
475
475
|
const ot = (t) => {
|
|
476
476
|
if (!Array.isArray(t)) return [];
|
|
477
477
|
const i = [];
|
|
478
|
-
return t.forEach((
|
|
479
|
-
!
|
|
478
|
+
return t.forEach((n, E) => {
|
|
479
|
+
!n || n.isDeleted || n.id !== "delimiter-new" && Ee(n).forEach((L, u) => {
|
|
480
480
|
if (!L.location) return;
|
|
481
481
|
const C = Le(L);
|
|
482
482
|
ue(L.mimetype, C) === "image" && i.push({
|
|
483
|
-
key: `${
|
|
483
|
+
key: `${n.id ?? E}:${u}`,
|
|
484
484
|
fileName: C,
|
|
485
485
|
fileURL: L.location,
|
|
486
486
|
mimetype: L.mimetype || ""
|
|
@@ -489,9 +489,9 @@ const ot = (t) => {
|
|
|
489
489
|
}), i;
|
|
490
490
|
}, it = (t, i) => {
|
|
491
491
|
if (!i?.fileURL) return -1;
|
|
492
|
-
const
|
|
492
|
+
const n = ne(i.fileURL);
|
|
493
493
|
return t.findIndex(
|
|
494
|
-
(E) => ne(E.fileURL) ===
|
|
494
|
+
(E) => ne(E.fileURL) === n
|
|
495
495
|
);
|
|
496
496
|
}, ce = "https://as2.ftcdn.net/v2/jpg/02/51/95/53/1000_F_251955356_FAQH0U1y1TZw3ZcdPGybwUkH90a3VAhb.jpg", at = X.div`
|
|
497
497
|
position: relative;
|
|
@@ -536,19 +536,19 @@ const ot = (t) => {
|
|
|
536
536
|
`, gt = ({
|
|
537
537
|
handleCloseModal: t
|
|
538
538
|
}) => {
|
|
539
|
-
const i = Ce(),
|
|
539
|
+
const i = Ce(), n = le(), E = Me(), { activeFile: L } = Q(
|
|
540
540
|
(f) => f.chatSettingStore
|
|
541
541
|
), u = $(
|
|
542
542
|
() => L ?? { fileName: "", fileURL: "", mimetype: "" },
|
|
543
543
|
[L]
|
|
544
|
-
), C =
|
|
544
|
+
), C = Q(
|
|
545
545
|
(f) => f.chatSettingStore.user?.fileToken || ""
|
|
546
|
-
),
|
|
547
|
-
(f) =>
|
|
548
|
-
),
|
|
546
|
+
), r = Q(
|
|
547
|
+
(f) => Pe(f)?.messages
|
|
548
|
+
), M = z(null), [p, A] = H(I), b = ue(u?.mimetype, u?.fileName), x = $(() => ot(r), [r]), m = $(
|
|
549
549
|
() => b === "image" ? it(x, u) : -1,
|
|
550
550
|
[x, u, b]
|
|
551
|
-
), y = m >= 0 && x.length > 1, Y = y && m > 0, F = y && m < x.length - 1,
|
|
551
|
+
), y = m >= 0 && x.length > 1, Y = y && m > 0, F = y && m < x.length - 1, o = k(
|
|
552
552
|
(f) => {
|
|
553
553
|
const h = x[f];
|
|
554
554
|
h && i(
|
|
@@ -561,16 +561,16 @@ const ot = (t) => {
|
|
|
561
561
|
},
|
|
562
562
|
[i, x]
|
|
563
563
|
), g = k(() => {
|
|
564
|
-
Y &&
|
|
565
|
-
}, [
|
|
566
|
-
F &&
|
|
567
|
-
}, [
|
|
564
|
+
Y && o(m - 1);
|
|
565
|
+
}, [o, Y, m]), w = k(() => {
|
|
566
|
+
F && o(m + 1);
|
|
567
|
+
}, [o, F, m]);
|
|
568
568
|
O(() => {
|
|
569
569
|
if (!y || typeof document > "u") return;
|
|
570
570
|
const f = (h) => {
|
|
571
571
|
if (h.key !== "ArrowLeft" && h.key !== "ArrowRight" || h.defaultPrevented || h.altKey || h.ctrlKey || h.metaKey) return;
|
|
572
|
-
const
|
|
573
|
-
_ === "INPUT" || _ === "TEXTAREA" || _ === "SELECT" ||
|
|
572
|
+
const T = h.target, _ = T?.tagName;
|
|
573
|
+
_ === "INPUT" || _ === "TEXTAREA" || _ === "SELECT" || T?.isContentEditable || (h.preventDefault(), h.key === "ArrowLeft" ? g() : w());
|
|
574
574
|
};
|
|
575
575
|
return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
|
|
576
576
|
}, [y, g, w]);
|
|
@@ -580,31 +580,31 @@ const ot = (t) => {
|
|
|
580
580
|
headers: {}
|
|
581
581
|
}).then((f) => {
|
|
582
582
|
const _ = !!He(u.fileName) ? u.fileName : `MEDIA-ETHORA.${b === "image" ? "png" : b === "video" ? "mp4" : "bin"}`;
|
|
583
|
-
f.arrayBuffer().then(function(
|
|
583
|
+
f.arrayBuffer().then(function(q) {
|
|
584
584
|
if (typeof window > "u")
|
|
585
585
|
return;
|
|
586
|
-
const
|
|
587
|
-
|
|
586
|
+
const Z = window.URL.createObjectURL(new Blob([q])), N = document.createElement("a");
|
|
587
|
+
N.href = Z, N.setAttribute("download", _), document.body.appendChild(N), N.click(), N.remove(), window.URL.revokeObjectURL(Z);
|
|
588
588
|
});
|
|
589
589
|
}).catch((f) => {
|
|
590
|
-
|
|
590
|
+
Ne.log(f);
|
|
591
591
|
});
|
|
592
|
-
},
|
|
592
|
+
}, U = () => {
|
|
593
593
|
i(re(void 0)), t?.();
|
|
594
|
-
}, S = u?.fileName ||
|
|
594
|
+
}, S = u?.fileName || n("modal.filePreview.imageAlt"), P = $(() => {
|
|
595
595
|
switch (b) {
|
|
596
596
|
case "image":
|
|
597
597
|
return /* @__PURE__ */ l(
|
|
598
598
|
fe,
|
|
599
599
|
{
|
|
600
|
-
ref:
|
|
600
|
+
ref: M,
|
|
601
601
|
src: J(u.fileURL, C) || ce,
|
|
602
602
|
alt: S,
|
|
603
|
-
onScaleChange:
|
|
603
|
+
onScaleChange: A,
|
|
604
604
|
onSwipeLeft: w,
|
|
605
605
|
onSwipeRight: g,
|
|
606
606
|
onError: (f) => {
|
|
607
|
-
Se(u.fileURL) &&
|
|
607
|
+
Se(u.fileURL) && Ae(), f.target.src = ce;
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
610
|
);
|
|
@@ -618,7 +618,7 @@ const ot = (t) => {
|
|
|
618
618
|
}
|
|
619
619
|
);
|
|
620
620
|
case "pdf":
|
|
621
|
-
return /* @__PURE__ */ l(
|
|
621
|
+
return /* @__PURE__ */ l(qe, { pdfUrl: J(u.fileURL, C) });
|
|
622
622
|
default:
|
|
623
623
|
return /* @__PURE__ */ B(
|
|
624
624
|
"div",
|
|
@@ -630,7 +630,7 @@ const ot = (t) => {
|
|
|
630
630
|
alignItems: "center"
|
|
631
631
|
},
|
|
632
632
|
children: [
|
|
633
|
-
/* @__PURE__ */ l(
|
|
633
|
+
/* @__PURE__ */ l(Re, { style: { minWidth: "100px", minHeight: "100px" } }),
|
|
634
634
|
/* @__PURE__ */ l(
|
|
635
635
|
"div",
|
|
636
636
|
{
|
|
@@ -641,27 +641,27 @@ const ot = (t) => {
|
|
|
641
641
|
padding: "16px",
|
|
642
642
|
color: "var(--ethora-color-text, #141414)"
|
|
643
643
|
},
|
|
644
|
-
children:
|
|
644
|
+
children: n("modal.filePreview.unsupported")
|
|
645
645
|
}
|
|
646
646
|
)
|
|
647
647
|
]
|
|
648
648
|
}
|
|
649
649
|
);
|
|
650
650
|
}
|
|
651
|
-
}, [u, C, S, b, w, g,
|
|
651
|
+
}, [u, C, S, b, w, g, n]);
|
|
652
652
|
return /* @__PURE__ */ B(
|
|
653
|
-
|
|
653
|
+
Te,
|
|
654
654
|
{
|
|
655
|
-
"aria-label":
|
|
655
|
+
"aria-label": n("modal.filePreview.title"),
|
|
656
656
|
$closing: E,
|
|
657
657
|
children: [
|
|
658
658
|
/* @__PURE__ */ l(
|
|
659
659
|
Ie,
|
|
660
660
|
{
|
|
661
|
-
handleCloseModal:
|
|
662
|
-
headerTitle:
|
|
661
|
+
handleCloseModal: U,
|
|
662
|
+
headerTitle: n("modal.filePreview.title"),
|
|
663
663
|
rightMenu: /* @__PURE__ */ B(lt, { children: [
|
|
664
|
-
y && /* @__PURE__ */ l(dt, { "data-testid": "lightbox-position", "aria-live": "polite", children:
|
|
664
|
+
y && /* @__PURE__ */ l(dt, { "data-testid": "lightbox-position", "aria-live": "polite", children: n("modal.filePreview.position", {
|
|
665
665
|
current: m + 1,
|
|
666
666
|
total: x.length
|
|
667
667
|
}) }),
|
|
@@ -669,32 +669,32 @@ const ot = (t) => {
|
|
|
669
669
|
/* @__PURE__ */ l(
|
|
670
670
|
V,
|
|
671
671
|
{
|
|
672
|
-
onClick: () =>
|
|
672
|
+
onClick: () => M.current?.zoomOut(),
|
|
673
673
|
disabled: p <= I,
|
|
674
|
-
"aria-label":
|
|
674
|
+
"aria-label": n("modal.filePreview.zoomOut"),
|
|
675
675
|
children: /* @__PURE__ */ l(Xe, {})
|
|
676
676
|
}
|
|
677
677
|
),
|
|
678
678
|
/* @__PURE__ */ l(
|
|
679
679
|
V,
|
|
680
680
|
{
|
|
681
|
-
onClick: () =>
|
|
681
|
+
onClick: () => M.current?.zoomIn(),
|
|
682
682
|
disabled: p >= ee,
|
|
683
|
-
"aria-label":
|
|
683
|
+
"aria-label": n("modal.filePreview.zoomIn"),
|
|
684
684
|
children: /* @__PURE__ */ l(Ye, {})
|
|
685
685
|
}
|
|
686
686
|
),
|
|
687
687
|
/* @__PURE__ */ l(
|
|
688
688
|
V,
|
|
689
689
|
{
|
|
690
|
-
onClick: () =>
|
|
690
|
+
onClick: () => M.current?.reset(),
|
|
691
691
|
disabled: p <= I,
|
|
692
|
-
"aria-label":
|
|
692
|
+
"aria-label": n("modal.filePreview.resetZoom"),
|
|
693
693
|
children: /* @__PURE__ */ l(ze, {})
|
|
694
694
|
}
|
|
695
695
|
)
|
|
696
696
|
] }),
|
|
697
|
-
/* @__PURE__ */ l(V, { onClick: v, "aria-label":
|
|
697
|
+
/* @__PURE__ */ l(V, { onClick: v, "aria-label": n("action.save"), children: /* @__PURE__ */ l(Oe, {}) })
|
|
698
698
|
] })
|
|
699
699
|
}
|
|
700
700
|
),
|
|
@@ -717,18 +717,18 @@ const ot = (t) => {
|
|
|
717
717
|
{
|
|
718
718
|
onClick: g,
|
|
719
719
|
disabled: !Y,
|
|
720
|
-
"aria-label":
|
|
720
|
+
"aria-label": n("modal.filePreview.previousImage"),
|
|
721
721
|
children: /* @__PURE__ */ l(Fe, {})
|
|
722
722
|
}
|
|
723
723
|
),
|
|
724
|
-
|
|
724
|
+
P,
|
|
725
725
|
y && /* @__PURE__ */ l(
|
|
726
726
|
ct,
|
|
727
727
|
{
|
|
728
728
|
onClick: w,
|
|
729
729
|
disabled: !F,
|
|
730
|
-
"aria-label":
|
|
731
|
-
children: /* @__PURE__ */ l(
|
|
730
|
+
"aria-label": n("modal.filePreview.nextImage"),
|
|
731
|
+
children: /* @__PURE__ */ l(Ue, {})
|
|
732
732
|
}
|
|
733
733
|
)
|
|
734
734
|
] })
|