sceyt-chat-react-uikit 1.6.9-beta.6 → 1.6.9-beta.7

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.modern.js CHANGED
@@ -23,8 +23,8 @@ import { useBasicTypeaheadTriggerMatch, LexicalTypeaheadMenuPlugin, MenuOption }
23
23
  import { $createOffsetView } from '@lexical/offset';
24
24
  import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
25
25
 
26
- /** A function that accepts a potential "extra argument" value to be injected later,
27
- * and returns an instance of the thunk middleware that uses that value
26
+ /** A function that accepts a potential "extra argument" value to be injected later,
27
+ * and returns an instance of the thunk middleware that uses that value
28
28
  */
29
29
  function createThunkMiddleware(extraArgument) {
30
30
  // Standard Redux middleware definition pattern:
@@ -55,523 +55,523 @@ var thunk = createThunkMiddleware(); // Attach the factory function so users can
55
55
 
56
56
  thunk.withExtraArgument = createThunkMiddleware;
57
57
 
58
- var __extends = (undefined && undefined.__extends) || (function () {
59
- var extendStatics = function (d, b) {
60
- extendStatics = Object.setPrototypeOf ||
61
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
62
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
63
- return extendStatics(d, b);
64
- };
65
- return function (d, b) {
66
- if (typeof b !== "function" && b !== null)
67
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
68
- extendStatics(d, b);
69
- function __() { this.constructor = d; }
70
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
71
- };
72
- })();
73
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
74
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
75
- to[j] = from[i];
76
- return to;
77
- };
78
- var __defProp = Object.defineProperty;
79
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
80
- var __hasOwnProp = Object.prototype.hasOwnProperty;
81
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
82
- var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
83
- var __spreadValues = function (a, b) {
84
- for (var prop in b || (b = {}))
85
- if (__hasOwnProp.call(b, prop))
86
- __defNormalProp(a, prop, b[prop]);
87
- if (__getOwnPropSymbols)
88
- for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
89
- var prop = _c[_i];
90
- if (__propIsEnum.call(b, prop))
91
- __defNormalProp(a, prop, b[prop]);
92
- }
93
- return a;
94
- };
95
- var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
96
- if (arguments.length === 0)
97
- return void 0;
98
- if (typeof arguments[0] === "object")
99
- return compose;
100
- return compose.apply(null, arguments);
101
- };
102
- // src/isPlainObject.ts
103
- function isPlainObject(value) {
104
- if (typeof value !== "object" || value === null)
105
- return false;
106
- var proto = Object.getPrototypeOf(value);
107
- if (proto === null)
108
- return true;
109
- var baseProto = proto;
110
- while (Object.getPrototypeOf(baseProto) !== null) {
111
- baseProto = Object.getPrototypeOf(baseProto);
112
- }
113
- return proto === baseProto;
114
- }
115
- // src/tsHelpers.ts
116
- var hasMatchFunction = function (v) {
117
- return v && typeof v.match === "function";
118
- };
119
- function isActionCreator(action) {
120
- return typeof action === "function" && "type" in action && hasMatchFunction(action);
121
- }
122
- // src/actionCreatorInvariantMiddleware.ts
123
- function getMessage(type) {
124
- var splitType = type ? ("" + type).split("/") : [];
125
- var actionName = splitType[splitType.length - 1] || "actionCreator";
126
- return "Detected an action creator with type \"" + (type || "unknown") + "\" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. `dispatch(" + actionName + "())` instead of `dispatch(" + actionName + ")`. This is necessary even if the action has no payload.";
127
- }
128
- function createActionCreatorInvariantMiddleware(options) {
129
- if (options === void 0) { options = {}; }
130
- if (process.env.NODE_ENV === "production") {
131
- return function () { return function (next) { return function (action) { return next(action); }; }; };
132
- }
133
- var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
134
- return function () { return function (next) { return function (action) {
135
- if (isActionCreator2(action)) {
136
- console.warn(getMessage(action.type));
137
- }
138
- return next(action);
139
- }; }; };
140
- }
141
- function getTimeMeasureUtils(maxDelay, fnName) {
142
- var elapsed = 0;
143
- return {
144
- measureTime: function (fn) {
145
- var started = Date.now();
146
- try {
147
- return fn();
148
- }
149
- finally {
150
- var finished = Date.now();
151
- elapsed += finished - started;
152
- }
153
- },
154
- warnIfExceeded: function () {
155
- if (elapsed > maxDelay) {
156
- console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
157
- }
158
- }
159
- };
160
- }
161
- var MiddlewareArray = /** @class */ (function (_super) {
162
- __extends(MiddlewareArray, _super);
163
- function MiddlewareArray() {
164
- var args = [];
165
- for (var _i = 0; _i < arguments.length; _i++) {
166
- args[_i] = arguments[_i];
167
- }
168
- var _this = _super.apply(this, args) || this;
169
- Object.setPrototypeOf(_this, MiddlewareArray.prototype);
170
- return _this;
171
- }
172
- Object.defineProperty(MiddlewareArray, Symbol.species, {
173
- get: function () {
174
- return MiddlewareArray;
175
- },
176
- enumerable: false,
177
- configurable: true
178
- });
179
- MiddlewareArray.prototype.concat = function () {
180
- var arr = [];
181
- for (var _i = 0; _i < arguments.length; _i++) {
182
- arr[_i] = arguments[_i];
183
- }
184
- return _super.prototype.concat.apply(this, arr);
185
- };
186
- MiddlewareArray.prototype.prepend = function () {
187
- var arr = [];
188
- for (var _i = 0; _i < arguments.length; _i++) {
189
- arr[_i] = arguments[_i];
190
- }
191
- if (arr.length === 1 && Array.isArray(arr[0])) {
192
- return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
193
- }
194
- return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
195
- };
196
- return MiddlewareArray;
197
- }(Array));
198
- var EnhancerArray = /** @class */ (function (_super) {
199
- __extends(EnhancerArray, _super);
200
- function EnhancerArray() {
201
- var args = [];
202
- for (var _i = 0; _i < arguments.length; _i++) {
203
- args[_i] = arguments[_i];
204
- }
205
- var _this = _super.apply(this, args) || this;
206
- Object.setPrototypeOf(_this, EnhancerArray.prototype);
207
- return _this;
208
- }
209
- Object.defineProperty(EnhancerArray, Symbol.species, {
210
- get: function () {
211
- return EnhancerArray;
212
- },
213
- enumerable: false,
214
- configurable: true
215
- });
216
- EnhancerArray.prototype.concat = function () {
217
- var arr = [];
218
- for (var _i = 0; _i < arguments.length; _i++) {
219
- arr[_i] = arguments[_i];
220
- }
221
- return _super.prototype.concat.apply(this, arr);
222
- };
223
- EnhancerArray.prototype.prepend = function () {
224
- var arr = [];
225
- for (var _i = 0; _i < arguments.length; _i++) {
226
- arr[_i] = arguments[_i];
227
- }
228
- if (arr.length === 1 && Array.isArray(arr[0])) {
229
- return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
230
- }
231
- return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
232
- };
233
- return EnhancerArray;
234
- }(Array));
235
- // src/immutableStateInvariantMiddleware.ts
236
- var isProduction = process.env.NODE_ENV === "production";
237
- var prefix = "Invariant failed";
238
- function invariant(condition, message) {
239
- if (condition) {
240
- return;
241
- }
242
- if (isProduction) {
243
- throw new Error(prefix);
244
- }
245
- throw new Error(prefix + ": " + (message || ""));
246
- }
247
- function stringify(obj, serializer, indent, decycler) {
248
- return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
249
- }
250
- function getSerialize(serializer, decycler) {
251
- var stack = [], keys = [];
252
- if (!decycler)
253
- decycler = function (_, value) {
254
- if (stack[0] === value)
255
- return "[Circular ~]";
256
- return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
257
- };
258
- return function (key, value) {
259
- if (stack.length > 0) {
260
- var thisPos = stack.indexOf(this);
261
- ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
262
- ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
263
- if (~stack.indexOf(value))
264
- value = decycler.call(this, key, value);
265
- }
266
- else
267
- stack.push(value);
268
- return serializer == null ? value : serializer.call(this, key, value);
269
- };
270
- }
271
- function isImmutableDefault(value) {
272
- return typeof value !== "object" || value == null || Object.isFrozen(value);
273
- }
274
- function trackForMutations(isImmutable, ignorePaths, obj) {
275
- var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
276
- return {
277
- detectMutations: function () {
278
- return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
279
- }
280
- };
281
- }
282
- function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
283
- if (ignorePaths === void 0) { ignorePaths = []; }
284
- if (path === void 0) { path = ""; }
285
- if (checkedObjects === void 0) { checkedObjects = new Set(); }
286
- var tracked = { value: obj };
287
- if (!isImmutable(obj) && !checkedObjects.has(obj)) {
288
- checkedObjects.add(obj);
289
- tracked.children = {};
290
- for (var key in obj) {
291
- var childPath = path ? path + "." + key : key;
292
- if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
293
- continue;
294
- }
295
- tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
296
- }
297
- }
298
- return tracked;
299
- }
300
- function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
301
- if (ignoredPaths === void 0) { ignoredPaths = []; }
302
- if (sameParentRef === void 0) { sameParentRef = false; }
303
- if (path === void 0) { path = ""; }
304
- var prevObj = trackedProperty ? trackedProperty.value : void 0;
305
- var sameRef = prevObj === obj;
306
- if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
307
- return { wasMutated: true, path: path };
308
- }
309
- if (isImmutable(prevObj) || isImmutable(obj)) {
310
- return { wasMutated: false };
311
- }
312
- var keysToDetect = {};
313
- for (var key in trackedProperty.children) {
314
- keysToDetect[key] = true;
315
- }
316
- for (var key in obj) {
317
- keysToDetect[key] = true;
318
- }
319
- var hasIgnoredPaths = ignoredPaths.length > 0;
320
- var _loop_1 = function (key) {
321
- var nestedPath = path ? path + "." + key : key;
322
- if (hasIgnoredPaths) {
323
- var hasMatches = ignoredPaths.some(function (ignored) {
324
- if (ignored instanceof RegExp) {
325
- return ignored.test(nestedPath);
326
- }
327
- return nestedPath === ignored;
328
- });
329
- if (hasMatches) {
330
- return "continue";
331
- }
332
- }
333
- var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
334
- if (result.wasMutated) {
335
- return { value: result };
336
- }
337
- };
338
- for (var key in keysToDetect) {
339
- var state_1 = _loop_1(key);
340
- if (typeof state_1 === "object")
341
- return state_1.value;
342
- }
343
- return { wasMutated: false };
344
- }
345
- function createImmutableStateInvariantMiddleware(options) {
346
- if (options === void 0) { options = {}; }
347
- if (process.env.NODE_ENV === "production") {
348
- return function () { return function (next) { return function (action) { return next(action); }; }; };
349
- }
350
- var _c = options.isImmutable, isImmutable = _c === void 0 ? isImmutableDefault : _c, ignoredPaths = options.ignoredPaths, _d = options.warnAfter, warnAfter = _d === void 0 ? 32 : _d, ignore = options.ignore;
351
- ignoredPaths = ignoredPaths || ignore;
352
- var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
353
- return function (_c) {
354
- var getState = _c.getState;
355
- var state = getState();
356
- var tracker = track(state);
357
- var result;
358
- return function (next) { return function (action) {
359
- var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
360
- measureUtils.measureTime(function () {
361
- state = getState();
362
- result = tracker.detectMutations();
363
- tracker = track(state);
364
- invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
365
- });
366
- var dispatchedAction = next(action);
367
- measureUtils.measureTime(function () {
368
- state = getState();
369
- result = tracker.detectMutations();
370
- tracker = track(state);
371
- result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
372
- });
373
- measureUtils.warnIfExceeded();
374
- return dispatchedAction;
375
- }; };
376
- };
377
- }
378
- // src/serializableStateInvariantMiddleware.ts
379
- function isPlain(val) {
380
- var type = typeof val;
381
- return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
382
- }
383
- function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
384
- if (path === void 0) { path = ""; }
385
- if (isSerializable === void 0) { isSerializable = isPlain; }
386
- if (ignoredPaths === void 0) { ignoredPaths = []; }
387
- var foundNestedSerializable;
388
- if (!isSerializable(value)) {
389
- return {
390
- keyPath: path || "<root>",
391
- value: value
392
- };
393
- }
394
- if (typeof value !== "object" || value === null) {
395
- return false;
396
- }
397
- if (cache == null ? void 0 : cache.has(value))
398
- return false;
399
- var entries = getEntries != null ? getEntries(value) : Object.entries(value);
400
- var hasIgnoredPaths = ignoredPaths.length > 0;
401
- var _loop_2 = function (key, nestedValue) {
402
- var nestedPath = path ? path + "." + key : key;
403
- if (hasIgnoredPaths) {
404
- var hasMatches = ignoredPaths.some(function (ignored) {
405
- if (ignored instanceof RegExp) {
406
- return ignored.test(nestedPath);
407
- }
408
- return nestedPath === ignored;
409
- });
410
- if (hasMatches) {
411
- return "continue";
412
- }
413
- }
414
- if (!isSerializable(nestedValue)) {
415
- return { value: {
416
- keyPath: nestedPath,
417
- value: nestedValue
418
- } };
419
- }
420
- if (typeof nestedValue === "object") {
421
- foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
422
- if (foundNestedSerializable) {
423
- return { value: foundNestedSerializable };
424
- }
425
- }
426
- };
427
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
428
- var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
429
- var state_2 = _loop_2(key, nestedValue);
430
- if (typeof state_2 === "object")
431
- return state_2.value;
432
- }
433
- if (cache && isNestedFrozen(value))
434
- cache.add(value);
435
- return false;
436
- }
437
- function isNestedFrozen(value) {
438
- if (!Object.isFrozen(value))
439
- return false;
440
- for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
441
- var nestedValue = _c[_i];
442
- if (typeof nestedValue !== "object" || nestedValue === null)
443
- continue;
444
- if (!isNestedFrozen(nestedValue))
445
- return false;
446
- }
447
- return true;
448
- }
449
- function createSerializableStateInvariantMiddleware(options) {
450
- if (options === void 0) { options = {}; }
451
- if (process.env.NODE_ENV === "production") {
452
- return function () { return function (next) { return function (action) { return next(action); }; }; };
453
- }
454
- var _c = options.isSerializable, isSerializable = _c === void 0 ? isPlain : _c, getEntries = options.getEntries, _d = options.ignoredActions, ignoredActions = _d === void 0 ? [] : _d, _e = options.ignoredActionPaths, ignoredActionPaths = _e === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _e, _f = options.ignoredPaths, ignoredPaths = _f === void 0 ? [] : _f, _g = options.warnAfter, warnAfter = _g === void 0 ? 32 : _g, _h = options.ignoreState, ignoreState = _h === void 0 ? false : _h, _j = options.ignoreActions, ignoreActions = _j === void 0 ? false : _j, _k = options.disableCache, disableCache = _k === void 0 ? false : _k;
455
- var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
456
- return function (storeAPI) { return function (next) { return function (action) {
457
- var result = next(action);
458
- var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
459
- if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
460
- measureUtils.measureTime(function () {
461
- var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
462
- if (foundActionNonSerializableValue) {
463
- var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
464
- console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
465
- }
466
- });
467
- }
468
- if (!ignoreState) {
469
- measureUtils.measureTime(function () {
470
- var state = storeAPI.getState();
471
- var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
472
- if (foundStateNonSerializableValue) {
473
- var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
474
- console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
475
- }
476
- });
477
- measureUtils.warnIfExceeded();
478
- }
479
- return result;
480
- }; }; };
481
- }
482
- // src/getDefaultMiddleware.ts
483
- function isBoolean(x) {
484
- return typeof x === "boolean";
485
- }
486
- function curryGetDefaultMiddleware() {
487
- return function curriedGetDefaultMiddleware(options) {
488
- return getDefaultMiddleware(options);
489
- };
490
- }
491
- function getDefaultMiddleware(options) {
492
- if (options === void 0) { options = {}; }
493
- var _c = options.thunk, thunk$1 = _c === void 0 ? true : _c, _d = options.immutableCheck, immutableCheck = _d === void 0 ? true : _d, _e = options.serializableCheck, serializableCheck = _e === void 0 ? true : _e, _f = options.actionCreatorCheck, actionCreatorCheck = _f === void 0 ? true : _f;
494
- var middlewareArray = new MiddlewareArray();
495
- if (thunk$1) {
496
- if (isBoolean(thunk$1)) {
497
- middlewareArray.push(thunk);
498
- }
499
- else {
500
- middlewareArray.push(thunk.withExtraArgument(thunk$1.extraArgument));
501
- }
502
- }
503
- if (process.env.NODE_ENV !== "production") {
504
- if (immutableCheck) {
505
- var immutableOptions = {};
506
- if (!isBoolean(immutableCheck)) {
507
- immutableOptions = immutableCheck;
508
- }
509
- middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
510
- }
511
- if (serializableCheck) {
512
- var serializableOptions = {};
513
- if (!isBoolean(serializableCheck)) {
514
- serializableOptions = serializableCheck;
515
- }
516
- middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
517
- }
518
- if (actionCreatorCheck) {
519
- var actionCreatorOptions = {};
520
- if (!isBoolean(actionCreatorCheck)) {
521
- actionCreatorOptions = actionCreatorCheck;
522
- }
523
- middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
524
- }
525
- }
526
- return middlewareArray;
527
- }
528
- // src/configureStore.ts
529
- var IS_PRODUCTION = process.env.NODE_ENV === "production";
530
- function configureStore(options) {
531
- var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
532
- var _c = options || {}, _d = _c.reducer, reducer = _d === void 0 ? void 0 : _d, _e = _c.middleware, middleware = _e === void 0 ? curriedGetDefaultMiddleware() : _e, _f = _c.devTools, devTools = _f === void 0 ? true : _f, _g = _c.preloadedState, preloadedState = _g === void 0 ? void 0 : _g, _h = _c.enhancers, enhancers = _h === void 0 ? void 0 : _h;
533
- var rootReducer;
534
- if (typeof reducer === "function") {
535
- rootReducer = reducer;
536
- }
537
- else if (isPlainObject(reducer)) {
538
- rootReducer = combineReducers(reducer);
539
- }
540
- else {
541
- throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
542
- }
543
- var finalMiddleware = middleware;
544
- if (typeof finalMiddleware === "function") {
545
- finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
546
- if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
547
- throw new Error("when using a middleware builder function, an array of middleware must be returned");
548
- }
549
- }
550
- if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
551
- throw new Error("each middleware provided to configureStore must be a function");
552
- }
553
- var middlewareEnhancer = applyMiddleware.apply(void 0, finalMiddleware);
554
- var finalCompose = compose;
555
- if (devTools) {
556
- finalCompose = composeWithDevTools(__spreadValues({
557
- trace: !IS_PRODUCTION
558
- }, typeof devTools === "object" && devTools));
559
- }
560
- var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
561
- var storeEnhancers = defaultEnhancers;
562
- if (Array.isArray(enhancers)) {
563
- storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
564
- }
565
- else if (typeof enhancers === "function") {
566
- storeEnhancers = enhancers(defaultEnhancers);
567
- }
568
- var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
569
- return createStore(rootReducer, preloadedState, composedEnhancer);
570
- }
571
- var promise;
572
- var queueMicrotaskShim = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : globalThis) : function (cb) { return (promise || (promise = Promise.resolve())).then(cb).catch(function (err) { return setTimeout(function () {
573
- throw err;
574
- }, 0); }); };
58
+ var __extends = (undefined && undefined.__extends) || (function () {
59
+ var extendStatics = function (d, b) {
60
+ extendStatics = Object.setPrototypeOf ||
61
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
62
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
63
+ return extendStatics(d, b);
64
+ };
65
+ return function (d, b) {
66
+ if (typeof b !== "function" && b !== null)
67
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
68
+ extendStatics(d, b);
69
+ function __() { this.constructor = d; }
70
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
71
+ };
72
+ })();
73
+ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
74
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
75
+ to[j] = from[i];
76
+ return to;
77
+ };
78
+ var __defProp = Object.defineProperty;
79
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
80
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
81
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
82
+ var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
83
+ var __spreadValues = function (a, b) {
84
+ for (var prop in b || (b = {}))
85
+ if (__hasOwnProp.call(b, prop))
86
+ __defNormalProp(a, prop, b[prop]);
87
+ if (__getOwnPropSymbols)
88
+ for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
89
+ var prop = _c[_i];
90
+ if (__propIsEnum.call(b, prop))
91
+ __defNormalProp(a, prop, b[prop]);
92
+ }
93
+ return a;
94
+ };
95
+ var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
96
+ if (arguments.length === 0)
97
+ return void 0;
98
+ if (typeof arguments[0] === "object")
99
+ return compose;
100
+ return compose.apply(null, arguments);
101
+ };
102
+ // src/isPlainObject.ts
103
+ function isPlainObject(value) {
104
+ if (typeof value !== "object" || value === null)
105
+ return false;
106
+ var proto = Object.getPrototypeOf(value);
107
+ if (proto === null)
108
+ return true;
109
+ var baseProto = proto;
110
+ while (Object.getPrototypeOf(baseProto) !== null) {
111
+ baseProto = Object.getPrototypeOf(baseProto);
112
+ }
113
+ return proto === baseProto;
114
+ }
115
+ // src/tsHelpers.ts
116
+ var hasMatchFunction = function (v) {
117
+ return v && typeof v.match === "function";
118
+ };
119
+ function isActionCreator(action) {
120
+ return typeof action === "function" && "type" in action && hasMatchFunction(action);
121
+ }
122
+ // src/actionCreatorInvariantMiddleware.ts
123
+ function getMessage(type) {
124
+ var splitType = type ? ("" + type).split("/") : [];
125
+ var actionName = splitType[splitType.length - 1] || "actionCreator";
126
+ return "Detected an action creator with type \"" + (type || "unknown") + "\" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. `dispatch(" + actionName + "())` instead of `dispatch(" + actionName + ")`. This is necessary even if the action has no payload.";
127
+ }
128
+ function createActionCreatorInvariantMiddleware(options) {
129
+ if (options === void 0) { options = {}; }
130
+ if (process.env.NODE_ENV === "production") {
131
+ return function () { return function (next) { return function (action) { return next(action); }; }; };
132
+ }
133
+ var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
134
+ return function () { return function (next) { return function (action) {
135
+ if (isActionCreator2(action)) {
136
+ console.warn(getMessage(action.type));
137
+ }
138
+ return next(action);
139
+ }; }; };
140
+ }
141
+ function getTimeMeasureUtils(maxDelay, fnName) {
142
+ var elapsed = 0;
143
+ return {
144
+ measureTime: function (fn) {
145
+ var started = Date.now();
146
+ try {
147
+ return fn();
148
+ }
149
+ finally {
150
+ var finished = Date.now();
151
+ elapsed += finished - started;
152
+ }
153
+ },
154
+ warnIfExceeded: function () {
155
+ if (elapsed > maxDelay) {
156
+ console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
157
+ }
158
+ }
159
+ };
160
+ }
161
+ var MiddlewareArray = /** @class */ (function (_super) {
162
+ __extends(MiddlewareArray, _super);
163
+ function MiddlewareArray() {
164
+ var args = [];
165
+ for (var _i = 0; _i < arguments.length; _i++) {
166
+ args[_i] = arguments[_i];
167
+ }
168
+ var _this = _super.apply(this, args) || this;
169
+ Object.setPrototypeOf(_this, MiddlewareArray.prototype);
170
+ return _this;
171
+ }
172
+ Object.defineProperty(MiddlewareArray, Symbol.species, {
173
+ get: function () {
174
+ return MiddlewareArray;
175
+ },
176
+ enumerable: false,
177
+ configurable: true
178
+ });
179
+ MiddlewareArray.prototype.concat = function () {
180
+ var arr = [];
181
+ for (var _i = 0; _i < arguments.length; _i++) {
182
+ arr[_i] = arguments[_i];
183
+ }
184
+ return _super.prototype.concat.apply(this, arr);
185
+ };
186
+ MiddlewareArray.prototype.prepend = function () {
187
+ var arr = [];
188
+ for (var _i = 0; _i < arguments.length; _i++) {
189
+ arr[_i] = arguments[_i];
190
+ }
191
+ if (arr.length === 1 && Array.isArray(arr[0])) {
192
+ return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
193
+ }
194
+ return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
195
+ };
196
+ return MiddlewareArray;
197
+ }(Array));
198
+ var EnhancerArray = /** @class */ (function (_super) {
199
+ __extends(EnhancerArray, _super);
200
+ function EnhancerArray() {
201
+ var args = [];
202
+ for (var _i = 0; _i < arguments.length; _i++) {
203
+ args[_i] = arguments[_i];
204
+ }
205
+ var _this = _super.apply(this, args) || this;
206
+ Object.setPrototypeOf(_this, EnhancerArray.prototype);
207
+ return _this;
208
+ }
209
+ Object.defineProperty(EnhancerArray, Symbol.species, {
210
+ get: function () {
211
+ return EnhancerArray;
212
+ },
213
+ enumerable: false,
214
+ configurable: true
215
+ });
216
+ EnhancerArray.prototype.concat = function () {
217
+ var arr = [];
218
+ for (var _i = 0; _i < arguments.length; _i++) {
219
+ arr[_i] = arguments[_i];
220
+ }
221
+ return _super.prototype.concat.apply(this, arr);
222
+ };
223
+ EnhancerArray.prototype.prepend = function () {
224
+ var arr = [];
225
+ for (var _i = 0; _i < arguments.length; _i++) {
226
+ arr[_i] = arguments[_i];
227
+ }
228
+ if (arr.length === 1 && Array.isArray(arr[0])) {
229
+ return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
230
+ }
231
+ return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
232
+ };
233
+ return EnhancerArray;
234
+ }(Array));
235
+ // src/immutableStateInvariantMiddleware.ts
236
+ var isProduction = process.env.NODE_ENV === "production";
237
+ var prefix = "Invariant failed";
238
+ function invariant(condition, message) {
239
+ if (condition) {
240
+ return;
241
+ }
242
+ if (isProduction) {
243
+ throw new Error(prefix);
244
+ }
245
+ throw new Error(prefix + ": " + (message || ""));
246
+ }
247
+ function stringify(obj, serializer, indent, decycler) {
248
+ return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
249
+ }
250
+ function getSerialize(serializer, decycler) {
251
+ var stack = [], keys = [];
252
+ if (!decycler)
253
+ decycler = function (_, value) {
254
+ if (stack[0] === value)
255
+ return "[Circular ~]";
256
+ return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
257
+ };
258
+ return function (key, value) {
259
+ if (stack.length > 0) {
260
+ var thisPos = stack.indexOf(this);
261
+ ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
262
+ ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
263
+ if (~stack.indexOf(value))
264
+ value = decycler.call(this, key, value);
265
+ }
266
+ else
267
+ stack.push(value);
268
+ return serializer == null ? value : serializer.call(this, key, value);
269
+ };
270
+ }
271
+ function isImmutableDefault(value) {
272
+ return typeof value !== "object" || value == null || Object.isFrozen(value);
273
+ }
274
+ function trackForMutations(isImmutable, ignorePaths, obj) {
275
+ var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
276
+ return {
277
+ detectMutations: function () {
278
+ return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
279
+ }
280
+ };
281
+ }
282
+ function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
283
+ if (ignorePaths === void 0) { ignorePaths = []; }
284
+ if (path === void 0) { path = ""; }
285
+ if (checkedObjects === void 0) { checkedObjects = new Set(); }
286
+ var tracked = { value: obj };
287
+ if (!isImmutable(obj) && !checkedObjects.has(obj)) {
288
+ checkedObjects.add(obj);
289
+ tracked.children = {};
290
+ for (var key in obj) {
291
+ var childPath = path ? path + "." + key : key;
292
+ if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
293
+ continue;
294
+ }
295
+ tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
296
+ }
297
+ }
298
+ return tracked;
299
+ }
300
+ function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
301
+ if (ignoredPaths === void 0) { ignoredPaths = []; }
302
+ if (sameParentRef === void 0) { sameParentRef = false; }
303
+ if (path === void 0) { path = ""; }
304
+ var prevObj = trackedProperty ? trackedProperty.value : void 0;
305
+ var sameRef = prevObj === obj;
306
+ if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
307
+ return { wasMutated: true, path: path };
308
+ }
309
+ if (isImmutable(prevObj) || isImmutable(obj)) {
310
+ return { wasMutated: false };
311
+ }
312
+ var keysToDetect = {};
313
+ for (var key in trackedProperty.children) {
314
+ keysToDetect[key] = true;
315
+ }
316
+ for (var key in obj) {
317
+ keysToDetect[key] = true;
318
+ }
319
+ var hasIgnoredPaths = ignoredPaths.length > 0;
320
+ var _loop_1 = function (key) {
321
+ var nestedPath = path ? path + "." + key : key;
322
+ if (hasIgnoredPaths) {
323
+ var hasMatches = ignoredPaths.some(function (ignored) {
324
+ if (ignored instanceof RegExp) {
325
+ return ignored.test(nestedPath);
326
+ }
327
+ return nestedPath === ignored;
328
+ });
329
+ if (hasMatches) {
330
+ return "continue";
331
+ }
332
+ }
333
+ var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
334
+ if (result.wasMutated) {
335
+ return { value: result };
336
+ }
337
+ };
338
+ for (var key in keysToDetect) {
339
+ var state_1 = _loop_1(key);
340
+ if (typeof state_1 === "object")
341
+ return state_1.value;
342
+ }
343
+ return { wasMutated: false };
344
+ }
345
+ function createImmutableStateInvariantMiddleware(options) {
346
+ if (options === void 0) { options = {}; }
347
+ if (process.env.NODE_ENV === "production") {
348
+ return function () { return function (next) { return function (action) { return next(action); }; }; };
349
+ }
350
+ var _c = options.isImmutable, isImmutable = _c === void 0 ? isImmutableDefault : _c, ignoredPaths = options.ignoredPaths, _d = options.warnAfter, warnAfter = _d === void 0 ? 32 : _d, ignore = options.ignore;
351
+ ignoredPaths = ignoredPaths || ignore;
352
+ var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
353
+ return function (_c) {
354
+ var getState = _c.getState;
355
+ var state = getState();
356
+ var tracker = track(state);
357
+ var result;
358
+ return function (next) { return function (action) {
359
+ var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
360
+ measureUtils.measureTime(function () {
361
+ state = getState();
362
+ result = tracker.detectMutations();
363
+ tracker = track(state);
364
+ invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
365
+ });
366
+ var dispatchedAction = next(action);
367
+ measureUtils.measureTime(function () {
368
+ state = getState();
369
+ result = tracker.detectMutations();
370
+ tracker = track(state);
371
+ result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
372
+ });
373
+ measureUtils.warnIfExceeded();
374
+ return dispatchedAction;
375
+ }; };
376
+ };
377
+ }
378
+ // src/serializableStateInvariantMiddleware.ts
379
+ function isPlain(val) {
380
+ var type = typeof val;
381
+ return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
382
+ }
383
+ function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
384
+ if (path === void 0) { path = ""; }
385
+ if (isSerializable === void 0) { isSerializable = isPlain; }
386
+ if (ignoredPaths === void 0) { ignoredPaths = []; }
387
+ var foundNestedSerializable;
388
+ if (!isSerializable(value)) {
389
+ return {
390
+ keyPath: path || "<root>",
391
+ value: value
392
+ };
393
+ }
394
+ if (typeof value !== "object" || value === null) {
395
+ return false;
396
+ }
397
+ if (cache == null ? void 0 : cache.has(value))
398
+ return false;
399
+ var entries = getEntries != null ? getEntries(value) : Object.entries(value);
400
+ var hasIgnoredPaths = ignoredPaths.length > 0;
401
+ var _loop_2 = function (key, nestedValue) {
402
+ var nestedPath = path ? path + "." + key : key;
403
+ if (hasIgnoredPaths) {
404
+ var hasMatches = ignoredPaths.some(function (ignored) {
405
+ if (ignored instanceof RegExp) {
406
+ return ignored.test(nestedPath);
407
+ }
408
+ return nestedPath === ignored;
409
+ });
410
+ if (hasMatches) {
411
+ return "continue";
412
+ }
413
+ }
414
+ if (!isSerializable(nestedValue)) {
415
+ return { value: {
416
+ keyPath: nestedPath,
417
+ value: nestedValue
418
+ } };
419
+ }
420
+ if (typeof nestedValue === "object") {
421
+ foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
422
+ if (foundNestedSerializable) {
423
+ return { value: foundNestedSerializable };
424
+ }
425
+ }
426
+ };
427
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
428
+ var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
429
+ var state_2 = _loop_2(key, nestedValue);
430
+ if (typeof state_2 === "object")
431
+ return state_2.value;
432
+ }
433
+ if (cache && isNestedFrozen(value))
434
+ cache.add(value);
435
+ return false;
436
+ }
437
+ function isNestedFrozen(value) {
438
+ if (!Object.isFrozen(value))
439
+ return false;
440
+ for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
441
+ var nestedValue = _c[_i];
442
+ if (typeof nestedValue !== "object" || nestedValue === null)
443
+ continue;
444
+ if (!isNestedFrozen(nestedValue))
445
+ return false;
446
+ }
447
+ return true;
448
+ }
449
+ function createSerializableStateInvariantMiddleware(options) {
450
+ if (options === void 0) { options = {}; }
451
+ if (process.env.NODE_ENV === "production") {
452
+ return function () { return function (next) { return function (action) { return next(action); }; }; };
453
+ }
454
+ var _c = options.isSerializable, isSerializable = _c === void 0 ? isPlain : _c, getEntries = options.getEntries, _d = options.ignoredActions, ignoredActions = _d === void 0 ? [] : _d, _e = options.ignoredActionPaths, ignoredActionPaths = _e === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _e, _f = options.ignoredPaths, ignoredPaths = _f === void 0 ? [] : _f, _g = options.warnAfter, warnAfter = _g === void 0 ? 32 : _g, _h = options.ignoreState, ignoreState = _h === void 0 ? false : _h, _j = options.ignoreActions, ignoreActions = _j === void 0 ? false : _j, _k = options.disableCache, disableCache = _k === void 0 ? false : _k;
455
+ var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
456
+ return function (storeAPI) { return function (next) { return function (action) {
457
+ var result = next(action);
458
+ var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
459
+ if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
460
+ measureUtils.measureTime(function () {
461
+ var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
462
+ if (foundActionNonSerializableValue) {
463
+ var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
464
+ console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
465
+ }
466
+ });
467
+ }
468
+ if (!ignoreState) {
469
+ measureUtils.measureTime(function () {
470
+ var state = storeAPI.getState();
471
+ var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
472
+ if (foundStateNonSerializableValue) {
473
+ var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
474
+ console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
475
+ }
476
+ });
477
+ measureUtils.warnIfExceeded();
478
+ }
479
+ return result;
480
+ }; }; };
481
+ }
482
+ // src/getDefaultMiddleware.ts
483
+ function isBoolean(x) {
484
+ return typeof x === "boolean";
485
+ }
486
+ function curryGetDefaultMiddleware() {
487
+ return function curriedGetDefaultMiddleware(options) {
488
+ return getDefaultMiddleware(options);
489
+ };
490
+ }
491
+ function getDefaultMiddleware(options) {
492
+ if (options === void 0) { options = {}; }
493
+ var _c = options.thunk, thunk$1 = _c === void 0 ? true : _c, _d = options.immutableCheck, immutableCheck = _d === void 0 ? true : _d, _e = options.serializableCheck, serializableCheck = _e === void 0 ? true : _e, _f = options.actionCreatorCheck, actionCreatorCheck = _f === void 0 ? true : _f;
494
+ var middlewareArray = new MiddlewareArray();
495
+ if (thunk$1) {
496
+ if (isBoolean(thunk$1)) {
497
+ middlewareArray.push(thunk);
498
+ }
499
+ else {
500
+ middlewareArray.push(thunk.withExtraArgument(thunk$1.extraArgument));
501
+ }
502
+ }
503
+ if (process.env.NODE_ENV !== "production") {
504
+ if (immutableCheck) {
505
+ var immutableOptions = {};
506
+ if (!isBoolean(immutableCheck)) {
507
+ immutableOptions = immutableCheck;
508
+ }
509
+ middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
510
+ }
511
+ if (serializableCheck) {
512
+ var serializableOptions = {};
513
+ if (!isBoolean(serializableCheck)) {
514
+ serializableOptions = serializableCheck;
515
+ }
516
+ middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
517
+ }
518
+ if (actionCreatorCheck) {
519
+ var actionCreatorOptions = {};
520
+ if (!isBoolean(actionCreatorCheck)) {
521
+ actionCreatorOptions = actionCreatorCheck;
522
+ }
523
+ middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
524
+ }
525
+ }
526
+ return middlewareArray;
527
+ }
528
+ // src/configureStore.ts
529
+ var IS_PRODUCTION = process.env.NODE_ENV === "production";
530
+ function configureStore(options) {
531
+ var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
532
+ var _c = options || {}, _d = _c.reducer, reducer = _d === void 0 ? void 0 : _d, _e = _c.middleware, middleware = _e === void 0 ? curriedGetDefaultMiddleware() : _e, _f = _c.devTools, devTools = _f === void 0 ? true : _f, _g = _c.preloadedState, preloadedState = _g === void 0 ? void 0 : _g, _h = _c.enhancers, enhancers = _h === void 0 ? void 0 : _h;
533
+ var rootReducer;
534
+ if (typeof reducer === "function") {
535
+ rootReducer = reducer;
536
+ }
537
+ else if (isPlainObject(reducer)) {
538
+ rootReducer = combineReducers(reducer);
539
+ }
540
+ else {
541
+ throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
542
+ }
543
+ var finalMiddleware = middleware;
544
+ if (typeof finalMiddleware === "function") {
545
+ finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
546
+ if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
547
+ throw new Error("when using a middleware builder function, an array of middleware must be returned");
548
+ }
549
+ }
550
+ if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
551
+ throw new Error("each middleware provided to configureStore must be a function");
552
+ }
553
+ var middlewareEnhancer = applyMiddleware.apply(void 0, finalMiddleware);
554
+ var finalCompose = compose;
555
+ if (devTools) {
556
+ finalCompose = composeWithDevTools(__spreadValues({
557
+ trace: !IS_PRODUCTION
558
+ }, typeof devTools === "object" && devTools));
559
+ }
560
+ var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
561
+ var storeEnhancers = defaultEnhancers;
562
+ if (Array.isArray(enhancers)) {
563
+ storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
564
+ }
565
+ else if (typeof enhancers === "function") {
566
+ storeEnhancers = enhancers(defaultEnhancers);
567
+ }
568
+ var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
569
+ return createStore(rootReducer, preloadedState, composedEnhancer);
570
+ }
571
+ var promise;
572
+ var queueMicrotaskShim = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : globalThis) : function (cb) { return (promise || (promise = Promise.resolve())).then(cb).catch(function (err) { return setTimeout(function () {
573
+ throw err;
574
+ }, 0); }); };
575
575
  //# sourceMappingURL=redux-toolkit.esm.js.map
576
576
 
577
577
  function _arrayLikeToArray(r, a) {
@@ -8313,15 +8313,25 @@ var getPendingMessagesMap = function getPendingMessagesMap() {
8313
8313
  return pendingMessagesMap;
8314
8314
  };
8315
8315
  var draftMessagesMap = {};
8316
+ var audioRecordingMap = {};
8316
8317
  var getDraftMessageFromMap = function getDraftMessageFromMap(channelId) {
8317
8318
  return draftMessagesMap[channelId];
8318
8319
  };
8320
+ var getAudioRecordingFromMap = function getAudioRecordingFromMap(channelId) {
8321
+ return audioRecordingMap[channelId];
8322
+ };
8319
8323
  var checkDraftMessagesIsEmpty = function checkDraftMessagesIsEmpty() {
8320
8324
  return Object.keys(draftMessagesMap).length === 0;
8321
8325
  };
8326
+ var setAudioRecordingToMap = function setAudioRecordingToMap(channelId, audioRecording) {
8327
+ audioRecordingMap[channelId] = audioRecording;
8328
+ };
8322
8329
  var removeDraftMessageFromMap = function removeDraftMessageFromMap(channelId) {
8323
8330
  delete draftMessagesMap[channelId];
8324
8331
  };
8332
+ var removeAudioRecordingFromMap = function removeAudioRecordingFromMap(channelId) {
8333
+ delete audioRecordingMap[channelId];
8334
+ };
8325
8335
  var setDraftMessageToMap = function setDraftMessageToMap(channelId, draftMessage) {
8326
8336
  draftMessagesMap[channelId] = draftMessage;
8327
8337
  };
@@ -19602,11 +19612,14 @@ var ChannelMessageText = function ChannelMessageText(_ref2) {
19602
19612
  typingOrRecording = _ref2.typingOrRecording,
19603
19613
  channel = _ref2.channel,
19604
19614
  isDirectChannel = _ref2.isDirectChannel;
19615
+ var audioRecording = useMemo(function () {
19616
+ return getAudioRecordingFromMap(channel.id);
19617
+ }, [channel.id, draftMessageText]);
19605
19618
  return /*#__PURE__*/React__default.createElement(MessageTextContainer, null, isTypingOrRecording && (/*#__PURE__*/React__default.createElement(TypingIndicator, null, !isDirectChannel && /*#__PURE__*/React__default.createElement(Points, {
19606
19619
  color: textPrimary
19607
19620
  }, ":"), typingOrRecording.isTyping ? 'typing' : 'recording', "...")), !isTypingOrRecording && (draftMessageText ? (/*#__PURE__*/React__default.createElement(DraftMessageText, {
19608
19621
  color: textSecondary
19609
- }, draftMessageText)) : lastMessage.state === MESSAGE_STATUS.DELETE ? 'Message was deleted.' : lastMessage.type === 'system' ? (lastMessage.user && (lastMessage.user.id === user.id ? 'You ' : makeUsername(lastMessage.user && contactsMap && contactsMap[lastMessage.user.id], lastMessage.user, getFromContacts))) + " " + (lastMessage.body === 'CC' ? 'created this channel' : lastMessage.body === 'CG' ? 'created this group' : lastMessage.body === 'AM' ? " added " + (lastMessageMetas && lastMessageMetas.m && lastMessageMetas.m.slice(0, 5).map(function (mem) {
19622
+ }, audioRecording && /*#__PURE__*/React__default.createElement(SvgVoiceIcon, null), draftMessageText)) : lastMessage.state === MESSAGE_STATUS.DELETE ? 'Message was deleted.' : lastMessage.type === 'system' ? (lastMessage.user && (lastMessage.user.id === user.id ? 'You ' : makeUsername(lastMessage.user && contactsMap && contactsMap[lastMessage.user.id], lastMessage.user, getFromContacts))) + " " + (lastMessage.body === 'CC' ? 'created this channel' : lastMessage.body === 'CG' ? 'created this group' : lastMessage.body === 'AM' ? " added " + (lastMessageMetas && lastMessageMetas.m && lastMessageMetas.m.slice(0, 5).map(function (mem) {
19610
19623
  return mem === user.id ? ' You' : " " + systemMessageUserName(mem, contactsMap && contactsMap[mem], lastMessage.mentionedUsers);
19611
19624
  })) + " " + (lastMessageMetas && lastMessageMetas.m && lastMessageMetas.m.length > 5 ? "and " + (lastMessageMetas.m.length - 5) + " more" : '') : lastMessage.body === 'RM' ? " removed " + (lastMessageMetas && lastMessageMetas.m && lastMessageMetas.m.slice(0, 5).map(function (mem) {
19612
19625
  return mem === user.id ? ' You' : " " + systemMessageUserName(mem, contactsMap && contactsMap[mem], lastMessage.mentionedUsers);
@@ -19700,8 +19713,13 @@ var Channel = function Channel(_ref3) {
19700
19713
  useEffect(function () {
19701
19714
  if (activeChannel.id !== channel.id) {
19702
19715
  var channelDraftMessage = getDraftMessageFromMap(channel.id);
19703
- if (channelDraftMessage) {
19704
- setDraftMessageText(channelDraftMessage.text);
19716
+ var draftAudioRecording = getAudioRecordingFromMap(channel.id);
19717
+ if (channelDraftMessage || draftAudioRecording) {
19718
+ if (channelDraftMessage) {
19719
+ setDraftMessageText(channelDraftMessage.text);
19720
+ } else if (draftAudioRecording) {
19721
+ setDraftMessageText('Voice');
19722
+ }
19705
19723
  } else if (draftMessageText) {
19706
19724
  setDraftMessageText(undefined);
19707
19725
  }
@@ -19911,7 +19929,7 @@ var Container$2 = styled.div(_templateObject6$1 || (_templateObject6$1 = _tagged
19911
19929
  var DraftMessageTitle = styled.span(_templateObject7$1 || (_templateObject7$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (props) {
19912
19930
  return props.color;
19913
19931
  });
19914
- var DraftMessageText = styled.span(_templateObject8$1 || (_templateObject8$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (props) {
19932
+ var DraftMessageText = styled.span(_templateObject8$1 || (_templateObject8$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n display: flex;\n align-items: flex-end;\n gap: 4px;\n"])), function (props) {
19915
19933
  return props.color;
19916
19934
  });
19917
19935
  var LastMessageAuthor = styled.div(_templateObject9$1 || (_templateObject9$1 = _taggedTemplateLiteralLoose(["\n max-width: 120px;\n font-weight: 500;\n color: ", ";\n\n ", "\n & > span {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 100%;\n }\n"])), function (props) {
@@ -33841,9 +33859,77 @@ function SvgRecordButton(props) {
33841
33859
  var _templateObject$G, _templateObject2$B, _templateObject3$u, _templateObject4$q, _templateObject5$m, _templateObject6$i, _templateObject7$g;
33842
33860
  var shouldDraw = false;
33843
33861
  var AudioRecord = function AudioRecord(_ref) {
33844
- var startRecording = function startRecording() {
33862
+ var sendRecordedFile = _ref.sendRecordedFile,
33863
+ setShowRecording = _ref.setShowRecording,
33864
+ showRecording = _ref.showRecording,
33865
+ channelId = _ref.channelId;
33866
+ var _useColor = useColors(),
33867
+ accentColor = _useColor[THEME_COLORS.ACCENT],
33868
+ textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
33869
+ warningColor = _useColor[THEME_COLORS.WARNING],
33870
+ iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
33871
+ surface1 = _useColor[THEME_COLORS.SURFACE_1];
33872
+ var _useState = useState(null),
33873
+ recording = _useState[0],
33874
+ setStartRecording = _useState[1];
33875
+ var _useState2 = useState(null),
33876
+ recorder = _useState2[0],
33877
+ setRecorder = _useState2[1];
33878
+ var _useState3 = useState(null),
33879
+ recordedFile = _useState3[0],
33880
+ setRecordedFile = _useState3[1];
33881
+ var _useState4 = useState(false),
33882
+ recordingIsReadyToPlay = _useState4[0],
33883
+ setRecordingIsReadyToPlay = _useState4[1];
33884
+ var _useState5 = useState(0),
33885
+ currentTime = _useState5[0],
33886
+ setCurrentTime = _useState5[1];
33887
+ var _useState6 = useState(null),
33888
+ sendingInterval = _useState6[0],
33889
+ setSendingInterval = _useState6[1];
33890
+ var _useState7 = useState(''),
33891
+ currentChannelId = _useState7[0],
33892
+ setCurrentChannelId = _useState7[1];
33893
+ var _useState8 = useState(false),
33894
+ playAudio = _useState8[0],
33895
+ setPlayAudio = _useState8[1];
33896
+ var wavesurferContainer = useRef(null);
33897
+ var recordButtonRef = useRef(null);
33898
+ var wavesurfer = useRef({});
33899
+ var intervalRef = useRef({});
33900
+ var currentRecordedFile = useMemo(function () {
33901
+ var current = getAudioRecordingFromMap(currentChannelId) || recordedFile;
33902
+ return current;
33903
+ }, [recordedFile, currentChannelId]);
33904
+ useEffect(function () {
33905
+ if (currentRecordedFile) {
33906
+ setRecordedFile(currentRecordedFile);
33907
+ }
33908
+ }, [currentRecordedFile]);
33909
+ var dispatch = useDispatch();
33910
+ var handleStartRecording = function handleStartRecording() {
33911
+ dispatch(sendRecordingAC(true));
33912
+ if (sendingInterval) {
33913
+ clearInterval(sendingInterval);
33914
+ setSendingInterval(null);
33915
+ return;
33916
+ }
33917
+ var interval = setInterval(function () {
33918
+ dispatch(sendRecordingAC(true));
33919
+ }, 1000);
33920
+ setSendingInterval(interval);
33921
+ };
33922
+ var handleStopRecording = function handleStopRecording() {
33923
+ dispatch(sendRecordingAC(false));
33924
+ if (sendingInterval) {
33925
+ clearInterval(sendingInterval);
33926
+ setSendingInterval(null);
33927
+ }
33928
+ };
33929
+ var startRecording = function startRecording(cId) {
33845
33930
  try {
33846
- var _temp3 = _catch(function () {
33931
+ var id = cId || currentChannelId;
33932
+ var _temp = _catch(function () {
33847
33933
  return Promise.resolve(navigator.permissions.query({
33848
33934
  name: 'microphone'
33849
33935
  })).then(function (permissionStatus) {
@@ -33853,18 +33939,27 @@ var AudioRecord = function AudioRecord(_ref) {
33853
33939
  recordButtonRef.current.style.pointerEvents = 'none';
33854
33940
  }
33855
33941
  if (recording) {
33856
- stopRecording(true);
33857
- } else if (recordedFile) {
33858
- sendRecordedFile(recordedFile);
33942
+ stopRecording(true, id, false, recorder);
33943
+ } else if (currentRecordedFile) {
33944
+ var _wavesurfer$current;
33945
+ removeAudioRecordingFromMap(id);
33859
33946
  setRecordedFile(null);
33860
33947
  setPlayAudio(false);
33861
- if (wavesurfer.current) {
33862
- wavesurfer.current.destroy();
33948
+ if ((_wavesurfer$current = wavesurfer.current) !== null && _wavesurfer$current !== void 0 && _wavesurfer$current[id]) {
33949
+ wavesurfer.current[id].destroy();
33863
33950
  }
33864
33951
  setStartRecording(false);
33865
33952
  setShowRecording(false);
33953
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
33954
+ sendRecordedFile(currentRecordedFile, id);
33866
33955
  } else {
33867
33956
  handleStartRecording();
33957
+ setAudioRecordingToMap(id, {
33958
+ file: null,
33959
+ objectUrl: null,
33960
+ thumb: null,
33961
+ dur: 0
33962
+ });
33868
33963
  recorder.start().then(function () {
33869
33964
  recordButtonRef.current.style.pointerEvents = 'initial';
33870
33965
  setShowRecording(true);
@@ -33872,8 +33967,8 @@ var AudioRecord = function AudioRecord(_ref) {
33872
33967
  shouldDraw = true;
33873
33968
  var stream = recorder.activeStream;
33874
33969
  var obj = {};
33875
- function init() {
33876
- obj.canvas = document.getElementById('waveform');
33970
+ var init = function init() {
33971
+ obj.canvas = document.getElementById("waveform-" + id);
33877
33972
  obj.ctx = obj.canvas.getContext('2d');
33878
33973
  obj.width = 360;
33879
33974
  obj.height = 28;
@@ -33881,10 +33976,10 @@ var AudioRecord = function AudioRecord(_ref) {
33881
33976
  obj.canvas.height = obj.height;
33882
33977
  obj.canvas.style.width = obj.width + 'px';
33883
33978
  obj.canvas.style.height = obj.height + 'px';
33884
- }
33979
+ };
33885
33980
  var timeOffset = 100;
33886
33981
  var now = parseInt(performance.now()) / timeOffset;
33887
- function loop() {
33982
+ var _loop = function loop() {
33888
33983
  if (!shouldDraw) {
33889
33984
  obj.x = 0;
33890
33985
  obj.ctx.clearRect(0, 0, obj.canvas.width, obj.canvas.height);
@@ -33912,10 +34007,10 @@ var AudioRecord = function AudioRecord(_ref) {
33912
34007
  });
33913
34008
  }
33914
34009
  draw();
33915
- requestAnimationFrame(loop);
33916
- }
34010
+ requestAnimationFrame(_loop);
34011
+ };
33917
34012
  obj.bars = [];
33918
- function draw() {
34013
+ var draw = function draw() {
33919
34014
  for (var i = 0; i < obj.bars.length; i++) {
33920
34015
  var bar = obj.bars[i];
33921
34016
  obj.ctx.fillStyle = textSecondary;
@@ -33925,8 +34020,8 @@ var AudioRecord = function AudioRecord(_ref) {
33925
34020
  obj.bars.splice(i, 1);
33926
34021
  }
33927
34022
  }
33928
- }
33929
- function soundAllowed(stream) {
34023
+ };
34024
+ var soundAllowed = function soundAllowed(stream) {
33930
34025
  var AudioContext = window.AudioContext || window.webkitAudioContext;
33931
34026
  var audioContent = new AudioContext();
33932
34027
  var streamSource = audioContent.createMediaStreamSource(stream);
@@ -33935,8 +34030,8 @@ var AudioRecord = function AudioRecord(_ref) {
33935
34030
  obj.analyser.fftSize = 512;
33936
34031
  obj.frequencyArray = new Float32Array(obj.analyser.fftSize);
33937
34032
  init();
33938
- loop();
33939
- }
34033
+ _loop();
34034
+ };
33940
34035
  soundAllowed(stream);
33941
34036
  })["catch"](function (e) {
33942
34037
  handleStopRecording();
@@ -33948,72 +34043,21 @@ var AudioRecord = function AudioRecord(_ref) {
33948
34043
  handleStopRecording();
33949
34044
  log.error(e);
33950
34045
  });
33951
- return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
34046
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
33952
34047
  } catch (e) {
33953
34048
  return Promise.reject(e);
33954
34049
  }
33955
34050
  };
33956
- var sendRecordedFile = _ref.sendRecordedFile,
33957
- setShowRecording = _ref.setShowRecording,
33958
- showRecording = _ref.showRecording;
33959
- var _useColor = useColors(),
33960
- accentColor = _useColor[THEME_COLORS.ACCENT],
33961
- textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
33962
- warningColor = _useColor[THEME_COLORS.WARNING],
33963
- iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
33964
- surface1 = _useColor[THEME_COLORS.SURFACE_1];
33965
- var _useState = useState(null),
33966
- recording = _useState[0],
33967
- setStartRecording = _useState[1];
33968
- var _useState2 = useState(null),
33969
- recorder = _useState2[0],
33970
- setRecorder = _useState2[1];
33971
- var _useState3 = useState(null),
33972
- recordedFile = _useState3[0],
33973
- setRecordedFile = _useState3[1];
33974
- var _useState4 = useState(false),
33975
- recordingIsReadyToPlay = _useState4[0],
33976
- setRecordingIsReadyToPlay = _useState4[1];
33977
- var _useState5 = useState(0),
33978
- currentTime = _useState5[0],
33979
- setCurrentTime = _useState5[1];
33980
- var _useState6 = useState(null),
33981
- sendingInterval = _useState6[0],
33982
- setSendingInterval = _useState6[1];
33983
- var _useState7 = useState(false),
33984
- playAudio = _useState7[0],
33985
- setPlayAudio = _useState7[1];
33986
- var wavesurfer = useRef(null);
33987
- var wavesurferContainer = useRef(null);
33988
- var intervalRef = useRef(null);
33989
- var recordButtonRef = useRef(null);
33990
- var dispatch = useDispatch();
33991
- var handleStartRecording = function handleStartRecording() {
33992
- dispatch(sendRecordingAC(true));
33993
- if (sendingInterval) {
33994
- clearInterval(sendingInterval);
33995
- setSendingInterval(null);
33996
- return;
33997
- }
33998
- var interval = setInterval(function () {
33999
- dispatch(sendRecordingAC(true));
34000
- }, 1000);
34001
- setSendingInterval(interval);
34002
- };
34003
- var handleStopRecording = function handleStopRecording() {
34004
- dispatch(sendRecordingAC(false));
34005
- if (sendingInterval) {
34006
- clearInterval(sendingInterval);
34007
- setSendingInterval(null);
34008
- }
34009
- };
34010
- function cancelRecording() {
34051
+ var cancelRecording = useCallback(function () {
34011
34052
  handleStopRecording();
34012
- if (recordedFile) {
34053
+ if (currentRecordedFile) {
34054
+ var _wavesurfer$current2;
34055
+ removeAudioRecordingFromMap(currentChannelId);
34056
+ dispatch(setChannelDraftMessageIsRemovedAC(currentChannelId));
34013
34057
  setRecordedFile(null);
34014
34058
  setPlayAudio(false);
34015
- if (wavesurfer.current) {
34016
- wavesurfer.current.destroy();
34059
+ if ((_wavesurfer$current2 = wavesurfer.current) !== null && _wavesurfer$current2 !== void 0 && _wavesurfer$current2[currentChannelId]) {
34060
+ wavesurfer.current[currentChannelId].destroy();
34017
34061
  }
34018
34062
  } else {
34019
34063
  shouldDraw = false;
@@ -34023,13 +34067,128 @@ var AudioRecord = function AudioRecord(_ref) {
34023
34067
  setStartRecording(false);
34024
34068
  setCurrentTime(0);
34025
34069
  setShowRecording(false);
34026
- }
34027
- function stopRecording(send) {
34070
+ }, [currentRecordedFile, currentChannelId, wavesurfer, setShowRecording, setRecordedFile]);
34071
+ var _initWaveSurfer = function initWaveSurfer(draft, cId, audioRecording, container) {
34072
+ try {
34073
+ var _exit = false;
34074
+ return Promise.resolve(_catch(function () {
34075
+ var _wavesurfer$current3;
34076
+ function _temp3(_result3) {
34077
+ if (_exit) return _result3;
34078
+ if (draft) {
34079
+ return;
34080
+ }
34081
+ wavesurfer.current[id].on('ready', function () {
34082
+ setRecordingIsReadyToPlay(true);
34083
+ var audioDuration = wavesurfer.current[id].getDuration();
34084
+ setCurrentTime(audioDuration);
34085
+ });
34086
+ wavesurfer.current[id].on('finish', function () {
34087
+ setPlayAudio(false);
34088
+ wavesurfer.current[id].seekTo(0);
34089
+ var audioDuration = wavesurfer.current[id].getDuration();
34090
+ setCurrentTime(audioDuration);
34091
+ clearInterval(intervalRef.current[id]);
34092
+ });
34093
+ wavesurfer.current[id].on('pause', function () {
34094
+ setPlayAudio(false);
34095
+ clearInterval(intervalRef.current[id]);
34096
+ });
34097
+ wavesurfer.current[id].on('interaction', function () {
34098
+ var currentTime = wavesurfer.current[id].getCurrentTime();
34099
+ setCurrentTime(currentTime);
34100
+ });
34101
+ }
34102
+ if (draft) {
34103
+ return;
34104
+ }
34105
+ var id = cId || currentChannelId;
34106
+ if ((_wavesurfer$current3 = wavesurfer.current) !== null && _wavesurfer$current3 !== void 0 && _wavesurfer$current3[id]) {
34107
+ setRecordingIsReadyToPlay(true);
34108
+ var audioDuration = wavesurfer.current[id].getDuration();
34109
+ setCurrentTime(audioDuration);
34110
+ }
34111
+ var _temp2 = function (_wavesurfer$current4) {
34112
+ if (!((_wavesurfer$current4 = wavesurfer.current) !== null && _wavesurfer$current4 !== void 0 && _wavesurfer$current4[id])) {
34113
+ var _ref2;
34114
+ var containerElement = wavesurferContainer.current || container;
34115
+ if (!containerElement) {
34116
+ setTimeout(function () {
34117
+ return _initWaveSurfer(draft, cId, audioRecording, container);
34118
+ }, 100);
34119
+ _exit = true;
34120
+ return;
34121
+ }
34122
+ var rect = containerElement.getBoundingClientRect();
34123
+ if (rect.width === 0 || rect.height === 0) {
34124
+ setTimeout(function () {
34125
+ return _initWaveSurfer(draft, cId, audioRecording, container);
34126
+ }, 100);
34127
+ _exit = true;
34128
+ return;
34129
+ }
34130
+ var ws = WaveSurfer.create({
34131
+ container: containerElement,
34132
+ waveColor: textSecondary,
34133
+ progressColor: accentColor,
34134
+ barWidth: 1,
34135
+ barHeight: 2,
34136
+ audioRate: 1,
34137
+ hideScrollbar: true,
34138
+ barRadius: 1.5,
34139
+ cursorWidth: 0,
34140
+ barGap: 2.5,
34141
+ height: 28
34142
+ });
34143
+ var peaks = [];
34144
+ if ((_ref2 = audioRecording || currentRecordedFile) !== null && _ref2 !== void 0 && _ref2.thumb) {
34145
+ var _ref3;
34146
+ var thumbData = (_ref3 = audioRecording || currentRecordedFile) === null || _ref3 === void 0 ? void 0 : _ref3.thumb;
34147
+ if (Array.isArray(thumbData) && thumbData.length > 0) {
34148
+ var maxVal = Math.max.apply(Math, thumbData);
34149
+ if (maxVal > 0 && isFinite(maxVal)) {
34150
+ var dec = maxVal / 100;
34151
+ peaks = thumbData.map(function (peak) {
34152
+ var normalizedPeak = peak / dec / 100;
34153
+ return isFinite(normalizedPeak) ? normalizedPeak : 0;
34154
+ }).filter(function (peak) {
34155
+ return isFinite(peak);
34156
+ });
34157
+ if (peaks.length === 0) {
34158
+ peaks = [];
34159
+ }
34160
+ }
34161
+ }
34162
+ }
34163
+ wavesurfer.current[id] = ws;
34164
+ return _catch(function () {
34165
+ var validPeaks = peaks.length > 0 ? peaks : undefined;
34166
+ return Promise.resolve(wavesurfer.current[id].loadBlob((audioRecording === null || audioRecording === void 0 ? void 0 : audioRecording.file) || (currentRecordedFile === null || currentRecordedFile === void 0 ? void 0 : currentRecordedFile.file), validPeaks)).then(function () {});
34167
+ }, function () {
34168
+ return _catch(function () {
34169
+ return Promise.resolve(wavesurfer.current[id].loadBlob((audioRecording === null || audioRecording === void 0 ? void 0 : audioRecording.file) || (currentRecordedFile === null || currentRecordedFile === void 0 ? void 0 : currentRecordedFile.file))).then(function () {});
34170
+ }, function (fallbackError) {
34171
+ console.error('Failed to load audio completely:', fallbackError);
34172
+ throw fallbackError;
34173
+ });
34174
+ });
34175
+ }
34176
+ }();
34177
+ return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
34178
+ }, function (e) {
34179
+ log.error('Failed to init wavesurfer', e);
34180
+ }));
34181
+ } catch (e) {
34182
+ return Promise.reject(e);
34183
+ }
34184
+ };
34185
+ var stopRecording = useCallback(function (send, cId, draft, recorder, container) {
34028
34186
  handleStopRecording();
34029
34187
  shouldDraw = false;
34030
- recorder.stop().getMp3().then(function (_ref2) {
34031
- var buffer = _ref2[0],
34032
- blob = _ref2[1];
34188
+ var id = cId || channelId;
34189
+ recorder.stop().getMp3().then(function (_ref4) {
34190
+ var buffer = _ref4[0],
34191
+ blob = _ref4[1];
34033
34192
  setCurrentTime(0);
34034
34193
  var file = new File(buffer, 'record.mp3', {
34035
34194
  type: blob.type,
@@ -34057,15 +34216,29 @@ var AudioRecord = function AudioRecord(_ref) {
34057
34216
  objectUrl: objectUrl,
34058
34217
  thumb: waveform,
34059
34218
  dur: audioBuffer.duration
34060
- });
34219
+ }, id);
34061
34220
  setShowRecording(false);
34221
+ removeAudioRecordingFromMap(id);
34222
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
34062
34223
  } else {
34063
- setRecordedFile({
34224
+ if (!draft) {
34225
+ setRecordedFile({
34226
+ file: file,
34227
+ objectUrl: objectUrl,
34228
+ thumb: waveform,
34229
+ dur: audioBuffer.duration
34230
+ });
34231
+ }
34232
+ var audioRecording = {
34064
34233
  file: file,
34065
34234
  objectUrl: objectUrl,
34066
34235
  thumb: waveform,
34067
34236
  dur: audioBuffer.duration
34068
- });
34237
+ };
34238
+ setAudioRecordingToMap(id, audioRecording);
34239
+ if (draft) {
34240
+ _initWaveSurfer(draft, id, audioRecording, container);
34241
+ }
34069
34242
  }
34070
34243
  }, function (e) {
34071
34244
  log.info('Error decoding audio data: ' + e.err);
@@ -34076,14 +34249,15 @@ var AudioRecord = function AudioRecord(_ref) {
34076
34249
  handleStopRecording();
34077
34250
  log.error(e);
34078
34251
  });
34079
- }
34080
- var handlePlayPause = function handlePlayPause() {
34081
- if (wavesurfer.current) {
34082
- if (!wavesurfer.current.isPlaying()) {
34252
+ }, [sendRecordedFile, setShowRecording, setAudioRecordingToMap, setRecordedFile, handleStopRecording, channelId]);
34253
+ var handlePlayPause = function handlePlayPause(cId) {
34254
+ var _wavesurfer$current5;
34255
+ if ((_wavesurfer$current5 = wavesurfer.current) !== null && _wavesurfer$current5 !== void 0 && _wavesurfer$current5[cId || currentChannelId]) {
34256
+ if (!wavesurfer.current[cId || currentChannelId].isPlaying()) {
34083
34257
  setPlayAudio(true);
34084
34258
  handleStartRecording();
34085
- intervalRef.current = setInterval(function () {
34086
- var currentTime = wavesurfer.current.getCurrentTime();
34259
+ intervalRef.current[cId || currentChannelId] = setInterval(function () {
34260
+ var currentTime = wavesurfer.current[cId || currentChannelId].getCurrentTime();
34087
34261
  if (currentTime >= 0) {
34088
34262
  setCurrentTime(currentTime);
34089
34263
  }
@@ -34091,7 +34265,7 @@ var AudioRecord = function AudioRecord(_ref) {
34091
34265
  } else {
34092
34266
  handleStopRecording();
34093
34267
  }
34094
- wavesurfer.current.playPause();
34268
+ wavesurfer.current[cId || currentChannelId].playPause();
34095
34269
  }
34096
34270
  };
34097
34271
  useEffect(function () {
@@ -34103,7 +34277,7 @@ var AudioRecord = function AudioRecord(_ref) {
34103
34277
  setCurrentTime(function (prevState) {
34104
34278
  if (prevState.recordingSeconds === MAX_RECORDER_TIME) {
34105
34279
  clearInterval(recordingInterval);
34106
- stopRecording();
34280
+ stopRecording(false, currentChannelId, false, recorder);
34107
34281
  return 0;
34108
34282
  }
34109
34283
  return prevState + 1;
@@ -34118,132 +34292,133 @@ var AudioRecord = function AudioRecord(_ref) {
34118
34292
  clearInterval(recordingInterval);
34119
34293
  };
34120
34294
  }, [recording]);
34121
- useDidUpdate(function () {
34122
- if (recordedFile) {
34123
- var initWaveSurfer = function initWaveSurfer() {
34124
- try {
34125
- try {
34126
- if (wavesurfer.current) {
34127
- wavesurfer.current.destroy();
34128
- }
34129
- wavesurfer.current = WaveSurfer.create({
34130
- container: wavesurferContainer.current,
34131
- waveColor: textSecondary,
34132
- progressColor: accentColor,
34133
- barWidth: 1,
34134
- barHeight: 2,
34135
- audioRate: 1,
34136
- hideScrollbar: true,
34137
- barRadius: 1.5,
34138
- cursorWidth: 0,
34139
- barGap: 2.5,
34140
- height: 28
34141
- });
34142
- wavesurfer.current.load(recordedFile.objectUrl);
34143
- wavesurfer.current.on('ready', function () {
34144
- setRecordingIsReadyToPlay(true);
34145
- var audioDuration = wavesurfer.current.getDuration();
34146
- setCurrentTime(audioDuration);
34147
- });
34148
- wavesurfer.current.on('finish', function () {
34149
- setPlayAudio(false);
34150
- wavesurfer.current.seekTo(0);
34151
- var audioDuration = wavesurfer.current.getDuration();
34152
- setCurrentTime(audioDuration);
34153
- clearInterval(intervalRef.current);
34154
- });
34155
- wavesurfer.current.on('pause', function () {
34156
- setPlayAudio(false);
34157
- clearInterval(intervalRef.current);
34158
- });
34159
- wavesurfer.current.on('interaction', function () {
34160
- var currentTime = wavesurfer.current.getCurrentTime();
34161
- setCurrentTime(currentTime);
34162
- });
34163
- } catch (e) {
34164
- log.error('Failed to init wavesurfer', e);
34165
- }
34166
- return Promise.resolve();
34167
- } catch (e) {
34168
- return Promise.reject(e);
34169
- }
34170
- };
34171
- initWaveSurfer();
34295
+ useEffect(function () {
34296
+ if (currentRecordedFile) {
34297
+ _initWaveSurfer();
34172
34298
  } else {
34299
+ var _wavesurfer$current6;
34173
34300
  setRecordingIsReadyToPlay(false);
34174
- clearInterval(intervalRef.current);
34175
- wavesurfer.current = null;
34301
+ if (intervalRef.current[currentChannelId]) {
34302
+ clearInterval(intervalRef.current[currentChannelId]);
34303
+ intervalRef.current[currentChannelId] = null;
34304
+ }
34305
+ if ((_wavesurfer$current6 = wavesurfer.current) !== null && _wavesurfer$current6 !== void 0 && _wavesurfer$current6[currentChannelId]) {
34306
+ wavesurfer.current[currentChannelId].destroy();
34307
+ wavesurfer.current[currentChannelId] = null;
34308
+ }
34176
34309
  }
34177
34310
  return function () {
34178
- clearInterval(intervalRef.current);
34311
+ for (var key in intervalRef.current) {
34312
+ if (intervalRef.current[key]) {
34313
+ clearInterval(intervalRef.current[key]);
34314
+ intervalRef.current[key] = null;
34315
+ }
34316
+ }
34317
+ for (var _key in wavesurfer.current) {
34318
+ if (wavesurfer.current[_key]) {
34319
+ wavesurfer.current[_key].destroy();
34320
+ wavesurfer.current[_key] = null;
34321
+ }
34322
+ }
34179
34323
  };
34180
- }, [recordedFile]);
34324
+ }, [currentRecordedFile, currentChannelId]);
34181
34325
  useEffect(function () {
34182
- (function () {
34183
- try {
34184
- var _temp2 = function () {
34185
- if (!recorder) {
34186
- var _temp = _catch(function () {
34187
- return Promise.resolve(import('mic-recorder-to-mp3')).then(function (MicRecorderModule) {
34188
- var MicRecorder = MicRecorderModule["default"];
34189
- var recorder = new MicRecorder({
34190
- bitRate: 128
34326
+ if (!currentRecordedFile) {
34327
+ (function () {
34328
+ try {
34329
+ var _temp5 = function () {
34330
+ if (!recorder) {
34331
+ var _temp4 = _catch(function () {
34332
+ return Promise.resolve(import('mic-recorder-to-mp3')).then(function (MicRecorderModule) {
34333
+ var MicRecorder = MicRecorderModule["default"];
34334
+ var recorder = new MicRecorder({
34335
+ bitRate: 128
34336
+ });
34337
+ setRecorder(recorder);
34191
34338
  });
34192
- setRecorder(recorder);
34339
+ }, function (e) {
34340
+ log.error('Failed to init mic-recorder-to-mp3', e);
34193
34341
  });
34194
- }, function (e) {
34195
- log.error('Failed to init mic-recorder-to-mp3', e);
34196
- });
34197
- if (_temp && _temp.then) return _temp.then(function () {});
34198
- }
34199
- }();
34200
- return _temp2 && _temp2.then ? _temp2.then(function () {}) : void 0;
34201
- } catch (e) {
34202
- Promise.reject(e);
34203
- }
34204
- })();
34205
- }, []);
34342
+ if (_temp4 && _temp4.then) return _temp4.then(function () {});
34343
+ }
34344
+ }();
34345
+ return _temp5 && _temp5.then ? _temp5.then(function () {}) : void 0;
34346
+ } catch (e) {
34347
+ Promise.reject(e);
34348
+ }
34349
+ })();
34350
+ }
34351
+ }, [currentRecordedFile]);
34206
34352
  useEffect(function () {
34207
34353
  return function () {
34208
34354
  handleStopRecording();
34209
34355
  };
34210
34356
  }, [showRecording]);
34357
+ useEffect(function () {
34358
+ if (channelId && (showRecording || currentRecordedFile)) {
34359
+ if (!currentRecordedFile) {
34360
+ stopRecording(false, currentChannelId, true, recorder, wavesurferContainer.current);
34361
+ }
34362
+ if (playAudio) {
34363
+ handlePlayPause(channelId);
34364
+ }
34365
+ for (var key in intervalRef.current) {
34366
+ clearInterval(intervalRef.current[key]);
34367
+ intervalRef.current[key] = null;
34368
+ }
34369
+ for (var _key2 in wavesurfer.current) {
34370
+ var _wavesurfer$current$_;
34371
+ (_wavesurfer$current$_ = wavesurfer.current[_key2]) === null || _wavesurfer$current$_ === void 0 ? void 0 : _wavesurfer$current$_.destroy();
34372
+ wavesurfer.current[_key2] = null;
34373
+ }
34374
+ setShowRecording(false);
34375
+ setStartRecording(false);
34376
+ setPlayAudio(false);
34377
+ setCurrentTime(0);
34378
+ var audioRecording = getAudioRecordingFromMap(channelId);
34379
+ setRecordedFile(audioRecording || null);
34380
+ setRecordingIsReadyToPlay(!!audioRecording);
34381
+ }
34382
+ setCurrentChannelId(channelId);
34383
+ }, [channelId]);
34211
34384
  return /*#__PURE__*/React__default.createElement(Container$j, {
34212
- recording: showRecording
34213
- }, showRecording && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34385
+ recording: showRecording || currentRecordedFile
34386
+ }, (showRecording || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34214
34387
  iconColor: iconPrimary,
34215
34388
  onClick: function onClick() {
34216
34389
  return cancelRecording();
34217
34390
  }
34218
34391
  }, /*#__PURE__*/React__default.createElement(SvgClose, null))), /*#__PURE__*/React__default.createElement(AudioWrapper, {
34219
34392
  backgroundColor: surface1,
34220
- recording: recording || recordedFile
34393
+ recording: recording || currentRecordedFile
34221
34394
  }, recording && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34222
34395
  iconColor: warningColor,
34223
34396
  onClick: function onClick() {
34224
- return stopRecording();
34397
+ return stopRecording(false, currentChannelId, false, recorder);
34225
34398
  }
34226
34399
  }, /*#__PURE__*/React__default.createElement(SvgStopRecord, null))), /*#__PURE__*/React__default.createElement(Canvas, {
34227
- hide: recordedFile,
34228
- id: 'waveform',
34400
+ hide: currentRecordedFile,
34401
+ id: "waveform-" + channelId,
34229
34402
  recording: recording
34230
34403
  }), recording && /*#__PURE__*/React__default.createElement(Timer$2, {
34231
34404
  color: textSecondary
34232
- }, formatAudioVideoTime(currentTime)), recordingIsReadyToPlay && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34405
+ }, formatAudioVideoTime(currentTime)), (recordingIsReadyToPlay || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34233
34406
  iconColor: accentColor,
34234
- onClick: handlePlayPause
34407
+ onClick: function onClick() {
34408
+ return handlePlayPause(channelId);
34409
+ }
34235
34410
  }, playAudio ? /*#__PURE__*/React__default.createElement(SvgPauseRecord, null) : /*#__PURE__*/React__default.createElement(SvgPlayRecord, null))), /*#__PURE__*/React__default.createElement(AudioVisualization$1, {
34236
34411
  ref: wavesurferContainer,
34237
- show: recordedFile
34238
- }), recordingIsReadyToPlay && /*#__PURE__*/React__default.createElement(Timer$2, {
34412
+ show: currentRecordedFile
34413
+ }), (recordingIsReadyToPlay || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(Timer$2, {
34239
34414
  color: textSecondary
34240
- }, formatAudioVideoTime(currentTime))), /*#__PURE__*/React__default.createElement(RecordIconWrapper, {
34415
+ }, formatAudioVideoTime(currentTime)))), /*#__PURE__*/React__default.createElement(RecordIconWrapper, {
34241
34416
  ref: recordButtonRef,
34242
34417
  onClick: function onClick() {
34243
- return startRecording();
34418
+ return startRecording(currentChannelId);
34244
34419
  },
34245
34420
  iconColor: accentColor
34246
- }, showRecording ? /*#__PURE__*/React__default.createElement(SvgSend, null) : /*#__PURE__*/React__default.createElement(SvgRecordButton, null)));
34421
+ }, showRecording || currentRecordedFile ? /*#__PURE__*/React__default.createElement(SvgSend, null) : /*#__PURE__*/React__default.createElement(SvgRecordButton, null)));
34247
34422
  };
34248
34423
  var Container$j = styled.div(_templateObject$G || (_templateObject$G = _taggedTemplateLiteralLoose(["\n width: 32px;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n ", ";\n transition: all 0.3s ease-in-out;\n"])), function (props) {
34249
34424
  return props.recording && "width: 400px";
@@ -34260,14 +34435,14 @@ var AudioWrapper = styled.div(_templateObject2$B || (_templateObject2$B = _tagge
34260
34435
  var RecordIconWrapper = styled.span(_templateObject3$u || (_templateObject3$u = _taggedTemplateLiteralLoose(["\n display: flex;\n cursor: pointer;\n > svg {\n color: ", ";\n }\n"])), function (props) {
34261
34436
  return props.iconColor;
34262
34437
  });
34263
- var AudioVisualization$1 = styled.div(_templateObject4$q || (_templateObject4$q = _taggedTemplateLiteralLoose(["\n position: absolute;\n opacity: ", ";\n z-index: ", ";\n visibility: ", ";\n width: 300px;\n height: 28px;\n max-width: calc(100% - 100px);\n left: 40px;\n background-color: ", ";\n"])), function (_ref3) {
34264
- var show = _ref3.show;
34438
+ var AudioVisualization$1 = styled.div(_templateObject4$q || (_templateObject4$q = _taggedTemplateLiteralLoose(["\n position: absolute;\n opacity: ", ";\n z-index: ", ";\n visibility: ", ";\n width: 300px;\n height: 28px;\n max-width: calc(100% - 100px);\n left: 40px;\n background-color: ", ";\n"])), function (_ref5) {
34439
+ var show = _ref5.show;
34265
34440
  return show ? '1' : '0';
34266
- }, function (_ref4) {
34267
- var show = _ref4.show;
34441
+ }, function (_ref6) {
34442
+ var show = _ref6.show;
34268
34443
  return !show && '-1';
34269
- }, function (_ref5) {
34270
- var show = _ref5.show;
34444
+ }, function (_ref7) {
34445
+ var show = _ref7.show;
34271
34446
  return show ? 'visible' : 'hidden';
34272
34447
  }, function (props) {
34273
34448
  return props.color;
@@ -34275,14 +34450,14 @@ var AudioVisualization$1 = styled.div(_templateObject4$q || (_templateObject4$q
34275
34450
  var PlayPause$1 = styled.div(_templateObject5$m || (_templateObject5$m = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n padding: 10px;\n > svg {\n color: ", ";\n }\n"])), function (props) {
34276
34451
  return props.iconColor;
34277
34452
  });
34278
- var Canvas = styled.canvas(_templateObject6$i || (_templateObject6$i = _taggedTemplateLiteralLoose(["\n height: 28px;\n width: ", ";\n max-width: calc(100% - 110px);\n position: absolute;\n opacity: ", ";\n z-index: ", ";\n left: 42px;\n"])), function (_ref6) {
34279
- var recording = _ref6.recording;
34453
+ var Canvas = styled.canvas(_templateObject6$i || (_templateObject6$i = _taggedTemplateLiteralLoose(["\n height: 28px;\n width: ", ";\n max-width: calc(100% - 110px);\n position: absolute;\n opacity: ", ";\n z-index: ", ";\n left: 42px;\n"])), function (_ref8) {
34454
+ var recording = _ref8.recording;
34280
34455
  return recording ? '300px' : '0';
34281
- }, function (_ref7) {
34282
- var hide = _ref7.hide;
34456
+ }, function (_ref9) {
34457
+ var hide = _ref9.hide;
34283
34458
  return hide ? '0' : '1';
34284
- }, function (_ref8) {
34285
- var hide = _ref8.hide;
34459
+ }, function (_ref0) {
34460
+ var hide = _ref0.hide;
34286
34461
  return hide && '-1';
34287
34462
  });
34288
34463
  var Timer$2 = styled.div(_templateObject7$g || (_templateObject7$g = _taggedTemplateLiteralLoose(["\n width: 40px;\n font-weight: 400;\n font-size: 16px;\n line-height: 12px;\n color: ", ";\n margin-left: auto;\n"])), function (props) {
@@ -34486,92 +34661,89 @@ var SendMessageInput = function SendMessageInput(_ref3) {
34486
34661
  var _useState = useState(false),
34487
34662
  showRecording = _useState[0],
34488
34663
  setShowRecording = _useState[1];
34489
- var _useState2 = useState(null),
34490
- recordedFile = _useState2[0],
34491
- setRecordedFile = _useState2[1];
34492
34664
  var _usePermissions = usePermissions(activeChannel.userRole),
34493
34665
  checkActionPermission = _usePermissions[0];
34494
- var _useState3 = useState(false),
34495
- listenerIsAdded = _useState3[0],
34496
- setListenerIsAdded = _useState3[1];
34666
+ var _useState2 = useState(false),
34667
+ listenerIsAdded = _useState2[0],
34668
+ setListenerIsAdded = _useState2[1];
34669
+ var _useState3 = useState(''),
34670
+ messageText = _useState3[0],
34671
+ setMessageText = _useState3[1];
34497
34672
  var _useState4 = useState(''),
34498
- messageText = _useState4[0],
34499
- setMessageText = _useState4[1];
34500
- var _useState5 = useState(''),
34501
- editMessageText = _useState5[0],
34502
- setEditMessageText = _useState5[1];
34503
- var _useState6 = useState({}),
34504
- readyVideoAttachments = _useState6[0],
34505
- setReadyVideoAttachments = _useState6[1];
34673
+ editMessageText = _useState4[0],
34674
+ setEditMessageText = _useState4[1];
34675
+ var _useState5 = useState({}),
34676
+ readyVideoAttachments = _useState5[0],
34677
+ setReadyVideoAttachments = _useState5[1];
34678
+ var _useState6 = useState(false),
34679
+ showChooseAttachmentType = _useState6[0],
34680
+ setShowChooseAttachmentType = _useState6[1];
34506
34681
  var _useState7 = useState(false),
34507
- showChooseAttachmentType = _useState7[0],
34508
- setShowChooseAttachmentType = _useState7[1];
34682
+ isEmojisOpened = _useState7[0],
34683
+ setIsEmojisOpened = _useState7[1];
34509
34684
  var _useState8 = useState(false),
34510
- isEmojisOpened = _useState8[0],
34511
- setIsEmojisOpened = _useState8[1];
34512
- var _useState9 = useState(false),
34513
- emojisInRightSide = _useState9[0],
34514
- setEmojisInRightSide = _useState9[1];
34685
+ emojisInRightSide = _useState8[0],
34686
+ setEmojisInRightSide = _useState8[1];
34687
+ var _useState9 = useState(0),
34688
+ emojisPopupLeftPosition = _useState9[0],
34689
+ setEmojisPopupLeftPosition = _useState9[1];
34515
34690
  var _useState0 = useState(0),
34516
- emojisPopupLeftPosition = _useState0[0],
34517
- setEmojisPopupLeftPosition = _useState0[1];
34518
- var _useState1 = useState(0),
34519
- emojisPopupBottomPosition = _useState1[0],
34520
- setEmojisPopupBottomPosition = _useState1[1];
34521
- var _useState10 = useState(false),
34522
- addAttachmentsInRightSide = _useState10[0],
34523
- setAddAttachmentsInRightSide = _useState10[1];
34524
- var _useState11 = useState({
34691
+ emojisPopupBottomPosition = _useState0[0],
34692
+ setEmojisPopupBottomPosition = _useState0[1];
34693
+ var _useState1 = useState(false),
34694
+ addAttachmentsInRightSide = _useState1[0],
34695
+ setAddAttachmentsInRightSide = _useState1[1];
34696
+ var _useState10 = useState({
34525
34697
  clear: false
34526
34698
  }),
34527
- shouldClearEditor = _useState11[0],
34528
- setShouldClearEditor = _useState11[1];
34699
+ shouldClearEditor = _useState10[0],
34700
+ setShouldClearEditor = _useState10[1];
34701
+ var _useState11 = useState([]),
34702
+ messageBodyAttributes = _useState11[0],
34703
+ setMessageBodyAttributes = _useState11[1];
34529
34704
  var _useState12 = useState([]),
34530
- messageBodyAttributes = _useState12[0],
34531
- setMessageBodyAttributes = _useState12[1];
34532
- var _useState13 = useState([]),
34533
- mentionedMembers = _useState13[0],
34534
- setMentionedMembers = _useState13[1];
34535
- var _useState14 = useState(''),
34536
- browser = _useState14[0],
34537
- setBrowser = _useState14[1];
34538
- var _useState15 = useState(false),
34539
- mentionsIsOpen = _useState15[0],
34540
- setMentionsIsOpen = _useState15[1];
34541
- var _useState16 = useState(),
34542
- inputContainerHeight = _useState16[0],
34543
- setInputContainerHeight = _useState16[1];
34705
+ mentionedMembers = _useState12[0],
34706
+ setMentionedMembers = _useState12[1];
34707
+ var _useState13 = useState(''),
34708
+ browser = _useState13[0],
34709
+ setBrowser = _useState13[1];
34710
+ var _useState14 = useState(false),
34711
+ mentionsIsOpen = _useState14[0],
34712
+ setMentionsIsOpen = _useState14[1];
34713
+ var _useState15 = useState(),
34714
+ inputContainerHeight = _useState15[0],
34715
+ setInputContainerHeight = _useState15[1];
34544
34716
  var selectedText = useRef(null);
34717
+ var _useState16 = useState(),
34718
+ typingTimout = _useState16[0],
34719
+ setTypingTimout = _useState16[1];
34545
34720
  var _useState17 = useState(),
34546
- typingTimout = _useState17[0],
34547
- setTypingTimout = _useState17[1];
34548
- var _useState18 = useState(),
34549
- inTypingStateTimout = _useState18[0],
34550
- setInTypingStateTimout = _useState18[1];
34721
+ inTypingStateTimout = _useState17[0],
34722
+ setInTypingStateTimout = _useState17[1];
34723
+ var _useState18 = useState(false),
34724
+ inTypingState = _useState18[0],
34725
+ setInTypingState = _useState18[1];
34551
34726
  var _useState19 = useState(false),
34552
- inTypingState = _useState19[0],
34553
- setInTypingState = _useState19[1];
34554
- var _useState20 = useState(false),
34555
- sendMessageIsActive = _useState20[0],
34556
- setSendMessageIsActive = _useState20[1];
34557
- var _useState21 = useState([]),
34558
- attachments = _useState21[0],
34559
- setAttachments = _useState21[1];
34727
+ sendMessageIsActive = _useState19[0],
34728
+ setSendMessageIsActive = _useState19[1];
34729
+ var _useState20 = useState([]),
34730
+ attachments = _useState20[0],
34731
+ setAttachments = _useState20[1];
34732
+ var _useState21 = useState(false),
34733
+ forwardPopupOpen = _useState21[0],
34734
+ setForwardPopupOpen = _useState21[1];
34560
34735
  var _useState22 = useState(false),
34561
- forwardPopupOpen = _useState22[0],
34562
- setForwardPopupOpen = _useState22[1];
34736
+ deletePopupOpen = _useState22[0],
34737
+ setDeletePopupOpen = _useState22[1];
34563
34738
  var _useState23 = useState(false),
34564
- deletePopupOpen = _useState23[0],
34565
- setDeletePopupOpen = _useState23[1];
34566
- var _useState24 = useState(false),
34567
- isIncomingMessage = _useState24[0],
34568
- setIsIncomingMessage = _useState24[1];
34569
- var _useState25 = useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
34570
- mediaExtensions = _useState25[0],
34571
- setMediaExtensions = _useState25[1];
34572
- var _useState26 = useState(''),
34573
- uploadErrorMessage = _useState26[0],
34574
- setUploadErrorMessage = _useState26[1];
34739
+ isIncomingMessage = _useState23[0],
34740
+ setIsIncomingMessage = _useState23[1];
34741
+ var _useState24 = useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
34742
+ mediaExtensions = _useState24[0],
34743
+ setMediaExtensions = _useState24[1];
34744
+ var _useState25 = useState(''),
34745
+ uploadErrorMessage = _useState25[0],
34746
+ setUploadErrorMessage = _useState25[1];
34575
34747
  var typingOrRecordingIndicator = useSelector(typingOrRecordingIndicatorArraySelector(activeChannel.id));
34576
34748
  var contactsMap = useSelector(contactsMapSelector);
34577
34749
  var connectionStatus = useSelector(connectionStatusSelector, shallowEqual);
@@ -34581,15 +34753,15 @@ var SendMessageInput = function SendMessageInput(_ref3) {
34581
34753
  var messageInputRef = useRef(null);
34582
34754
  var emojiBtnRef = useRef(null);
34583
34755
  var addAttachmentsBtnRef = useRef(null);
34584
- var _useState27 = useState(),
34585
- realEditorState = _useState27[0],
34586
- setRealEditorState = _useState27[1];
34587
- var _useState28 = useState(null),
34588
- floatingAnchorElem = _useState28[0],
34589
- setFloatingAnchorElem = _useState28[1];
34590
- var _useState29 = useState(false),
34591
- isSmallWidthViewport = _useState29[0],
34592
- setIsSmallWidthViewport = _useState29[1];
34756
+ var _useState26 = useState(),
34757
+ realEditorState = _useState26[0],
34758
+ setRealEditorState = _useState26[1];
34759
+ var _useState27 = useState(null),
34760
+ floatingAnchorElem = _useState27[0],
34761
+ setFloatingAnchorElem = _useState27[1];
34762
+ var _useState28 = useState(false),
34763
+ isSmallWidthViewport = _useState28[0],
34764
+ setIsSmallWidthViewport = _useState28[1];
34593
34765
  var addAttachmentByMenu = showChooseFileAttachment && showChooseMediaAttachment;
34594
34766
  function onChange(editorState) {
34595
34767
  setRealEditorState(editorState);
@@ -35307,7 +35479,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35307
35479
  dispatch(setDraggedAttachmentsAC([], ''));
35308
35480
  }
35309
35481
  }, [draggedAttachments]);
35310
- useEffect(function () {
35482
+ var sendRecordedFile = function sendRecordedFile(recordedFile, id) {
35311
35483
  if (recordedFile) {
35312
35484
  var tid = v4();
35313
35485
  var reader = new FileReader();
@@ -35347,7 +35519,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35347
35519
  }],
35348
35520
  type: 'text'
35349
35521
  };
35350
- dispatch(sendMessageAC(messageToSend, activeChannel.id, connectionStatus));
35522
+ dispatch(sendMessageAC(messageToSend, id, connectionStatus));
35351
35523
  });
35352
35524
  } catch (e) {
35353
35525
  return Promise.reject(e);
@@ -35358,7 +35530,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35358
35530
  };
35359
35531
  reader.readAsBinaryString(recordedFile.file);
35360
35532
  }
35361
- }, [recordedFile]);
35533
+ };
35362
35534
  useEffect(function () {
35363
35535
  var updateViewPortWidth = function updateViewPortWidth() {
35364
35536
  var isNextSmallWidthViewport = CAN_USE_DOM && window.matchMedia('(max-width: 1025px)').matches;
@@ -35745,7 +35917,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35745
35917
  onChange: handleFileUpload,
35746
35918
  multiple: true,
35747
35919
  type: 'file'
35748
- }), showRecording ? (/*#__PURE__*/React__default.createElement(AudioCont, null)) : (/*#__PURE__*/React__default.createElement(MessageInputWrapper, {
35920
+ }), showRecording || getAudioRecordingFromMap(activeChannel.id) ? (/*#__PURE__*/React__default.createElement(AudioCont, null)) : (/*#__PURE__*/React__default.createElement(MessageInputWrapper, {
35749
35921
  className: 'message_input_wrapper',
35750
35922
  borderRadius: messageForReply || messageToEdit ? borderRadiusOnOpenedEditReplyMessage : borderRadius,
35751
35923
  ref: inputWrapperRef,
@@ -35878,9 +36050,10 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35878
36050
  iconColor: accentColor,
35879
36051
  activeColor: accentColor
35880
36052
  }, /*#__PURE__*/React__default.createElement(AudioRecord, {
35881
- sendRecordedFile: setRecordedFile,
36053
+ sendRecordedFile: sendRecordedFile,
35882
36054
  setShowRecording: setShowRecording,
35883
- showRecording: showRecording
36055
+ showRecording: showRecording,
36056
+ channelId: activeChannel.id
35884
36057
  }))))))))));
35885
36058
  };
35886
36059
  var SendMessageWrapper = styled.div(_templateObject$I || (_templateObject$I = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n position: relative;\n z-index: 15;\n"])), function (props) {