sceyt-chat-react-uikit 1.6.9-beta.5 → 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.js CHANGED
@@ -47,8 +47,8 @@ var LexicalTypeaheadMenuPlugin = require('@lexical/react/LexicalTypeaheadMenuPlu
47
47
  var offset = require('@lexical/offset');
48
48
  var LexicalHistoryPlugin = require('@lexical/react/LexicalHistoryPlugin');
49
49
 
50
- /** A function that accepts a potential "extra argument" value to be injected later,
51
- * and returns an instance of the thunk middleware that uses that value
50
+ /** A function that accepts a potential "extra argument" value to be injected later,
51
+ * and returns an instance of the thunk middleware that uses that value
52
52
  */
53
53
  function createThunkMiddleware(extraArgument) {
54
54
  // Standard Redux middleware definition pattern:
@@ -79,522 +79,522 @@ var thunk = createThunkMiddleware(); // Attach the factory function so users can
79
79
 
80
80
  thunk.withExtraArgument = createThunkMiddleware;
81
81
 
82
- var __extends = (undefined && undefined.__extends) || (function () {
83
- var extendStatics = function (d, b) {
84
- extendStatics = Object.setPrototypeOf ||
85
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
86
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
87
- return extendStatics(d, b);
88
- };
89
- return function (d, b) {
90
- if (typeof b !== "function" && b !== null)
91
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
92
- extendStatics(d, b);
93
- function __() { this.constructor = d; }
94
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
95
- };
96
- })();
97
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
98
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
99
- to[j] = from[i];
100
- return to;
101
- };
102
- var __defProp = Object.defineProperty;
103
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
104
- var __hasOwnProp = Object.prototype.hasOwnProperty;
105
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
106
- var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
107
- var __spreadValues = function (a, b) {
108
- for (var prop in b || (b = {}))
109
- if (__hasOwnProp.call(b, prop))
110
- __defNormalProp(a, prop, b[prop]);
111
- if (__getOwnPropSymbols)
112
- for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
113
- var prop = _c[_i];
114
- if (__propIsEnum.call(b, prop))
115
- __defNormalProp(a, prop, b[prop]);
116
- }
117
- return a;
118
- };
119
- var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
120
- if (arguments.length === 0)
121
- return void 0;
122
- if (typeof arguments[0] === "object")
123
- return redux.compose;
124
- return redux.compose.apply(null, arguments);
125
- };
126
- // src/isPlainObject.ts
127
- function isPlainObject(value) {
128
- if (typeof value !== "object" || value === null)
129
- return false;
130
- var proto = Object.getPrototypeOf(value);
131
- if (proto === null)
132
- return true;
133
- var baseProto = proto;
134
- while (Object.getPrototypeOf(baseProto) !== null) {
135
- baseProto = Object.getPrototypeOf(baseProto);
136
- }
137
- return proto === baseProto;
138
- }
139
- // src/tsHelpers.ts
140
- var hasMatchFunction = function (v) {
141
- return v && typeof v.match === "function";
142
- };
143
- function isActionCreator(action) {
144
- return typeof action === "function" && "type" in action && hasMatchFunction(action);
145
- }
146
- // src/actionCreatorInvariantMiddleware.ts
147
- function getMessage(type) {
148
- var splitType = type ? ("" + type).split("/") : [];
149
- var actionName = splitType[splitType.length - 1] || "actionCreator";
150
- 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.";
151
- }
152
- function createActionCreatorInvariantMiddleware(options) {
153
- if (options === void 0) { options = {}; }
154
- if (process.env.NODE_ENV === "production") {
155
- return function () { return function (next) { return function (action) { return next(action); }; }; };
156
- }
157
- var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
158
- return function () { return function (next) { return function (action) {
159
- if (isActionCreator2(action)) {
160
- console.warn(getMessage(action.type));
161
- }
162
- return next(action);
163
- }; }; };
164
- }
165
- function getTimeMeasureUtils(maxDelay, fnName) {
166
- var elapsed = 0;
167
- return {
168
- measureTime: function (fn) {
169
- var started = Date.now();
170
- try {
171
- return fn();
172
- }
173
- finally {
174
- var finished = Date.now();
175
- elapsed += finished - started;
176
- }
177
- },
178
- warnIfExceeded: function () {
179
- if (elapsed > maxDelay) {
180
- 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.");
181
- }
182
- }
183
- };
184
- }
185
- var MiddlewareArray = /** @class */ (function (_super) {
186
- __extends(MiddlewareArray, _super);
187
- function MiddlewareArray() {
188
- var args = [];
189
- for (var _i = 0; _i < arguments.length; _i++) {
190
- args[_i] = arguments[_i];
191
- }
192
- var _this = _super.apply(this, args) || this;
193
- Object.setPrototypeOf(_this, MiddlewareArray.prototype);
194
- return _this;
195
- }
196
- Object.defineProperty(MiddlewareArray, Symbol.species, {
197
- get: function () {
198
- return MiddlewareArray;
199
- },
200
- enumerable: false,
201
- configurable: true
202
- });
203
- MiddlewareArray.prototype.concat = function () {
204
- var arr = [];
205
- for (var _i = 0; _i < arguments.length; _i++) {
206
- arr[_i] = arguments[_i];
207
- }
208
- return _super.prototype.concat.apply(this, arr);
209
- };
210
- MiddlewareArray.prototype.prepend = function () {
211
- var arr = [];
212
- for (var _i = 0; _i < arguments.length; _i++) {
213
- arr[_i] = arguments[_i];
214
- }
215
- if (arr.length === 1 && Array.isArray(arr[0])) {
216
- return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
217
- }
218
- return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
219
- };
220
- return MiddlewareArray;
221
- }(Array));
222
- var EnhancerArray = /** @class */ (function (_super) {
223
- __extends(EnhancerArray, _super);
224
- function EnhancerArray() {
225
- var args = [];
226
- for (var _i = 0; _i < arguments.length; _i++) {
227
- args[_i] = arguments[_i];
228
- }
229
- var _this = _super.apply(this, args) || this;
230
- Object.setPrototypeOf(_this, EnhancerArray.prototype);
231
- return _this;
232
- }
233
- Object.defineProperty(EnhancerArray, Symbol.species, {
234
- get: function () {
235
- return EnhancerArray;
236
- },
237
- enumerable: false,
238
- configurable: true
239
- });
240
- EnhancerArray.prototype.concat = function () {
241
- var arr = [];
242
- for (var _i = 0; _i < arguments.length; _i++) {
243
- arr[_i] = arguments[_i];
244
- }
245
- return _super.prototype.concat.apply(this, arr);
246
- };
247
- EnhancerArray.prototype.prepend = function () {
248
- var arr = [];
249
- for (var _i = 0; _i < arguments.length; _i++) {
250
- arr[_i] = arguments[_i];
251
- }
252
- if (arr.length === 1 && Array.isArray(arr[0])) {
253
- return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
254
- }
255
- return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
256
- };
257
- return EnhancerArray;
258
- }(Array));
259
- // src/immutableStateInvariantMiddleware.ts
260
- var isProduction = process.env.NODE_ENV === "production";
261
- var prefix = "Invariant failed";
262
- function invariant(condition, message) {
263
- if (condition) {
264
- return;
265
- }
266
- if (isProduction) {
267
- throw new Error(prefix);
268
- }
269
- throw new Error(prefix + ": " + (message || ""));
270
- }
271
- function stringify(obj, serializer, indent, decycler) {
272
- return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
273
- }
274
- function getSerialize(serializer, decycler) {
275
- var stack = [], keys = [];
276
- if (!decycler)
277
- decycler = function (_, value) {
278
- if (stack[0] === value)
279
- return "[Circular ~]";
280
- return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
281
- };
282
- return function (key, value) {
283
- if (stack.length > 0) {
284
- var thisPos = stack.indexOf(this);
285
- ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
286
- ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
287
- if (~stack.indexOf(value))
288
- value = decycler.call(this, key, value);
289
- }
290
- else
291
- stack.push(value);
292
- return serializer == null ? value : serializer.call(this, key, value);
293
- };
294
- }
295
- function isImmutableDefault(value) {
296
- return typeof value !== "object" || value == null || Object.isFrozen(value);
297
- }
298
- function trackForMutations(isImmutable, ignorePaths, obj) {
299
- var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
300
- return {
301
- detectMutations: function () {
302
- return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
303
- }
304
- };
305
- }
306
- function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
307
- if (ignorePaths === void 0) { ignorePaths = []; }
308
- if (path === void 0) { path = ""; }
309
- if (checkedObjects === void 0) { checkedObjects = new Set(); }
310
- var tracked = { value: obj };
311
- if (!isImmutable(obj) && !checkedObjects.has(obj)) {
312
- checkedObjects.add(obj);
313
- tracked.children = {};
314
- for (var key in obj) {
315
- var childPath = path ? path + "." + key : key;
316
- if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
317
- continue;
318
- }
319
- tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
320
- }
321
- }
322
- return tracked;
323
- }
324
- function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
325
- if (ignoredPaths === void 0) { ignoredPaths = []; }
326
- if (sameParentRef === void 0) { sameParentRef = false; }
327
- if (path === void 0) { path = ""; }
328
- var prevObj = trackedProperty ? trackedProperty.value : void 0;
329
- var sameRef = prevObj === obj;
330
- if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
331
- return { wasMutated: true, path: path };
332
- }
333
- if (isImmutable(prevObj) || isImmutable(obj)) {
334
- return { wasMutated: false };
335
- }
336
- var keysToDetect = {};
337
- for (var key in trackedProperty.children) {
338
- keysToDetect[key] = true;
339
- }
340
- for (var key in obj) {
341
- keysToDetect[key] = true;
342
- }
343
- var hasIgnoredPaths = ignoredPaths.length > 0;
344
- var _loop_1 = function (key) {
345
- var nestedPath = path ? path + "." + key : key;
346
- if (hasIgnoredPaths) {
347
- var hasMatches = ignoredPaths.some(function (ignored) {
348
- if (ignored instanceof RegExp) {
349
- return ignored.test(nestedPath);
350
- }
351
- return nestedPath === ignored;
352
- });
353
- if (hasMatches) {
354
- return "continue";
355
- }
356
- }
357
- var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
358
- if (result.wasMutated) {
359
- return { value: result };
360
- }
361
- };
362
- for (var key in keysToDetect) {
363
- var state_1 = _loop_1(key);
364
- if (typeof state_1 === "object")
365
- return state_1.value;
366
- }
367
- return { wasMutated: false };
368
- }
369
- function createImmutableStateInvariantMiddleware(options) {
370
- if (options === void 0) { options = {}; }
371
- if (process.env.NODE_ENV === "production") {
372
- return function () { return function (next) { return function (action) { return next(action); }; }; };
373
- }
374
- 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;
375
- ignoredPaths = ignoredPaths || ignore;
376
- var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
377
- return function (_c) {
378
- var getState = _c.getState;
379
- var state = getState();
380
- var tracker = track(state);
381
- var result;
382
- return function (next) { return function (action) {
383
- var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
384
- measureUtils.measureTime(function () {
385
- state = getState();
386
- result = tracker.detectMutations();
387
- tracker = track(state);
388
- 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)");
389
- });
390
- var dispatchedAction = next(action);
391
- measureUtils.measureTime(function () {
392
- state = getState();
393
- result = tracker.detectMutations();
394
- tracker = track(state);
395
- 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)");
396
- });
397
- measureUtils.warnIfExceeded();
398
- return dispatchedAction;
399
- }; };
400
- };
401
- }
402
- // src/serializableStateInvariantMiddleware.ts
403
- function isPlain(val) {
404
- var type = typeof val;
405
- return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
406
- }
407
- function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
408
- if (path === void 0) { path = ""; }
409
- if (isSerializable === void 0) { isSerializable = isPlain; }
410
- if (ignoredPaths === void 0) { ignoredPaths = []; }
411
- var foundNestedSerializable;
412
- if (!isSerializable(value)) {
413
- return {
414
- keyPath: path || "<root>",
415
- value: value
416
- };
417
- }
418
- if (typeof value !== "object" || value === null) {
419
- return false;
420
- }
421
- if (cache == null ? void 0 : cache.has(value))
422
- return false;
423
- var entries = getEntries != null ? getEntries(value) : Object.entries(value);
424
- var hasIgnoredPaths = ignoredPaths.length > 0;
425
- var _loop_2 = function (key, nestedValue) {
426
- var nestedPath = path ? path + "." + key : key;
427
- if (hasIgnoredPaths) {
428
- var hasMatches = ignoredPaths.some(function (ignored) {
429
- if (ignored instanceof RegExp) {
430
- return ignored.test(nestedPath);
431
- }
432
- return nestedPath === ignored;
433
- });
434
- if (hasMatches) {
435
- return "continue";
436
- }
437
- }
438
- if (!isSerializable(nestedValue)) {
439
- return { value: {
440
- keyPath: nestedPath,
441
- value: nestedValue
442
- } };
443
- }
444
- if (typeof nestedValue === "object") {
445
- foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
446
- if (foundNestedSerializable) {
447
- return { value: foundNestedSerializable };
448
- }
449
- }
450
- };
451
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
452
- var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
453
- var state_2 = _loop_2(key, nestedValue);
454
- if (typeof state_2 === "object")
455
- return state_2.value;
456
- }
457
- if (cache && isNestedFrozen(value))
458
- cache.add(value);
459
- return false;
460
- }
461
- function isNestedFrozen(value) {
462
- if (!Object.isFrozen(value))
463
- return false;
464
- for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
465
- var nestedValue = _c[_i];
466
- if (typeof nestedValue !== "object" || nestedValue === null)
467
- continue;
468
- if (!isNestedFrozen(nestedValue))
469
- return false;
470
- }
471
- return true;
472
- }
473
- function createSerializableStateInvariantMiddleware(options) {
474
- if (options === void 0) { options = {}; }
475
- if (process.env.NODE_ENV === "production") {
476
- return function () { return function (next) { return function (action) { return next(action); }; }; };
477
- }
478
- 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;
479
- var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
480
- return function (storeAPI) { return function (next) { return function (action) {
481
- var result = next(action);
482
- var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
483
- if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
484
- measureUtils.measureTime(function () {
485
- var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
486
- if (foundActionNonSerializableValue) {
487
- var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
488
- 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)");
489
- }
490
- });
491
- }
492
- if (!ignoreState) {
493
- measureUtils.measureTime(function () {
494
- var state = storeAPI.getState();
495
- var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
496
- if (foundStateNonSerializableValue) {
497
- var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
498
- 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)");
499
- }
500
- });
501
- measureUtils.warnIfExceeded();
502
- }
503
- return result;
504
- }; }; };
505
- }
506
- // src/getDefaultMiddleware.ts
507
- function isBoolean(x) {
508
- return typeof x === "boolean";
509
- }
510
- function curryGetDefaultMiddleware() {
511
- return function curriedGetDefaultMiddleware(options) {
512
- return getDefaultMiddleware(options);
513
- };
514
- }
515
- function getDefaultMiddleware(options) {
516
- if (options === void 0) { options = {}; }
517
- 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;
518
- var middlewareArray = new MiddlewareArray();
519
- if (thunk$1) {
520
- if (isBoolean(thunk$1)) {
521
- middlewareArray.push(thunk);
522
- }
523
- else {
524
- middlewareArray.push(thunk.withExtraArgument(thunk$1.extraArgument));
525
- }
526
- }
527
- if (process.env.NODE_ENV !== "production") {
528
- if (immutableCheck) {
529
- var immutableOptions = {};
530
- if (!isBoolean(immutableCheck)) {
531
- immutableOptions = immutableCheck;
532
- }
533
- middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
534
- }
535
- if (serializableCheck) {
536
- var serializableOptions = {};
537
- if (!isBoolean(serializableCheck)) {
538
- serializableOptions = serializableCheck;
539
- }
540
- middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
541
- }
542
- if (actionCreatorCheck) {
543
- var actionCreatorOptions = {};
544
- if (!isBoolean(actionCreatorCheck)) {
545
- actionCreatorOptions = actionCreatorCheck;
546
- }
547
- middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
548
- }
549
- }
550
- return middlewareArray;
551
- }
552
- // src/configureStore.ts
553
- var IS_PRODUCTION = process.env.NODE_ENV === "production";
554
- function configureStore(options) {
555
- var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
556
- 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;
557
- var rootReducer;
558
- if (typeof reducer === "function") {
559
- rootReducer = reducer;
560
- }
561
- else if (isPlainObject(reducer)) {
562
- rootReducer = redux.combineReducers(reducer);
563
- }
564
- else {
565
- throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
566
- }
567
- var finalMiddleware = middleware;
568
- if (typeof finalMiddleware === "function") {
569
- finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
570
- if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
571
- throw new Error("when using a middleware builder function, an array of middleware must be returned");
572
- }
573
- }
574
- if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
575
- throw new Error("each middleware provided to configureStore must be a function");
576
- }
577
- var middlewareEnhancer = redux.applyMiddleware.apply(void 0, finalMiddleware);
578
- var finalCompose = redux.compose;
579
- if (devTools) {
580
- finalCompose = composeWithDevTools(__spreadValues({
581
- trace: !IS_PRODUCTION
582
- }, typeof devTools === "object" && devTools));
583
- }
584
- var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
585
- var storeEnhancers = defaultEnhancers;
586
- if (Array.isArray(enhancers)) {
587
- storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
588
- }
589
- else if (typeof enhancers === "function") {
590
- storeEnhancers = enhancers(defaultEnhancers);
591
- }
592
- var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
593
- return redux.createStore(rootReducer, preloadedState, composedEnhancer);
594
- }
595
- var promise;
596
- 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 () {
597
- throw err;
82
+ var __extends = (undefined && undefined.__extends) || (function () {
83
+ var extendStatics = function (d, b) {
84
+ extendStatics = Object.setPrototypeOf ||
85
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
86
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
87
+ return extendStatics(d, b);
88
+ };
89
+ return function (d, b) {
90
+ if (typeof b !== "function" && b !== null)
91
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
92
+ extendStatics(d, b);
93
+ function __() { this.constructor = d; }
94
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
95
+ };
96
+ })();
97
+ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
98
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
99
+ to[j] = from[i];
100
+ return to;
101
+ };
102
+ var __defProp = Object.defineProperty;
103
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
104
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
105
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
106
+ var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
107
+ var __spreadValues = function (a, b) {
108
+ for (var prop in b || (b = {}))
109
+ if (__hasOwnProp.call(b, prop))
110
+ __defNormalProp(a, prop, b[prop]);
111
+ if (__getOwnPropSymbols)
112
+ for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
113
+ var prop = _c[_i];
114
+ if (__propIsEnum.call(b, prop))
115
+ __defNormalProp(a, prop, b[prop]);
116
+ }
117
+ return a;
118
+ };
119
+ var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
120
+ if (arguments.length === 0)
121
+ return void 0;
122
+ if (typeof arguments[0] === "object")
123
+ return redux.compose;
124
+ return redux.compose.apply(null, arguments);
125
+ };
126
+ // src/isPlainObject.ts
127
+ function isPlainObject(value) {
128
+ if (typeof value !== "object" || value === null)
129
+ return false;
130
+ var proto = Object.getPrototypeOf(value);
131
+ if (proto === null)
132
+ return true;
133
+ var baseProto = proto;
134
+ while (Object.getPrototypeOf(baseProto) !== null) {
135
+ baseProto = Object.getPrototypeOf(baseProto);
136
+ }
137
+ return proto === baseProto;
138
+ }
139
+ // src/tsHelpers.ts
140
+ var hasMatchFunction = function (v) {
141
+ return v && typeof v.match === "function";
142
+ };
143
+ function isActionCreator(action) {
144
+ return typeof action === "function" && "type" in action && hasMatchFunction(action);
145
+ }
146
+ // src/actionCreatorInvariantMiddleware.ts
147
+ function getMessage(type) {
148
+ var splitType = type ? ("" + type).split("/") : [];
149
+ var actionName = splitType[splitType.length - 1] || "actionCreator";
150
+ 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.";
151
+ }
152
+ function createActionCreatorInvariantMiddleware(options) {
153
+ if (options === void 0) { options = {}; }
154
+ if (process.env.NODE_ENV === "production") {
155
+ return function () { return function (next) { return function (action) { return next(action); }; }; };
156
+ }
157
+ var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
158
+ return function () { return function (next) { return function (action) {
159
+ if (isActionCreator2(action)) {
160
+ console.warn(getMessage(action.type));
161
+ }
162
+ return next(action);
163
+ }; }; };
164
+ }
165
+ function getTimeMeasureUtils(maxDelay, fnName) {
166
+ var elapsed = 0;
167
+ return {
168
+ measureTime: function (fn) {
169
+ var started = Date.now();
170
+ try {
171
+ return fn();
172
+ }
173
+ finally {
174
+ var finished = Date.now();
175
+ elapsed += finished - started;
176
+ }
177
+ },
178
+ warnIfExceeded: function () {
179
+ if (elapsed > maxDelay) {
180
+ 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.");
181
+ }
182
+ }
183
+ };
184
+ }
185
+ var MiddlewareArray = /** @class */ (function (_super) {
186
+ __extends(MiddlewareArray, _super);
187
+ function MiddlewareArray() {
188
+ var args = [];
189
+ for (var _i = 0; _i < arguments.length; _i++) {
190
+ args[_i] = arguments[_i];
191
+ }
192
+ var _this = _super.apply(this, args) || this;
193
+ Object.setPrototypeOf(_this, MiddlewareArray.prototype);
194
+ return _this;
195
+ }
196
+ Object.defineProperty(MiddlewareArray, Symbol.species, {
197
+ get: function () {
198
+ return MiddlewareArray;
199
+ },
200
+ enumerable: false,
201
+ configurable: true
202
+ });
203
+ MiddlewareArray.prototype.concat = function () {
204
+ var arr = [];
205
+ for (var _i = 0; _i < arguments.length; _i++) {
206
+ arr[_i] = arguments[_i];
207
+ }
208
+ return _super.prototype.concat.apply(this, arr);
209
+ };
210
+ MiddlewareArray.prototype.prepend = function () {
211
+ var arr = [];
212
+ for (var _i = 0; _i < arguments.length; _i++) {
213
+ arr[_i] = arguments[_i];
214
+ }
215
+ if (arr.length === 1 && Array.isArray(arr[0])) {
216
+ return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
217
+ }
218
+ return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
219
+ };
220
+ return MiddlewareArray;
221
+ }(Array));
222
+ var EnhancerArray = /** @class */ (function (_super) {
223
+ __extends(EnhancerArray, _super);
224
+ function EnhancerArray() {
225
+ var args = [];
226
+ for (var _i = 0; _i < arguments.length; _i++) {
227
+ args[_i] = arguments[_i];
228
+ }
229
+ var _this = _super.apply(this, args) || this;
230
+ Object.setPrototypeOf(_this, EnhancerArray.prototype);
231
+ return _this;
232
+ }
233
+ Object.defineProperty(EnhancerArray, Symbol.species, {
234
+ get: function () {
235
+ return EnhancerArray;
236
+ },
237
+ enumerable: false,
238
+ configurable: true
239
+ });
240
+ EnhancerArray.prototype.concat = function () {
241
+ var arr = [];
242
+ for (var _i = 0; _i < arguments.length; _i++) {
243
+ arr[_i] = arguments[_i];
244
+ }
245
+ return _super.prototype.concat.apply(this, arr);
246
+ };
247
+ EnhancerArray.prototype.prepend = function () {
248
+ var arr = [];
249
+ for (var _i = 0; _i < arguments.length; _i++) {
250
+ arr[_i] = arguments[_i];
251
+ }
252
+ if (arr.length === 1 && Array.isArray(arr[0])) {
253
+ return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
254
+ }
255
+ return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
256
+ };
257
+ return EnhancerArray;
258
+ }(Array));
259
+ // src/immutableStateInvariantMiddleware.ts
260
+ var isProduction = process.env.NODE_ENV === "production";
261
+ var prefix = "Invariant failed";
262
+ function invariant(condition, message) {
263
+ if (condition) {
264
+ return;
265
+ }
266
+ if (isProduction) {
267
+ throw new Error(prefix);
268
+ }
269
+ throw new Error(prefix + ": " + (message || ""));
270
+ }
271
+ function stringify(obj, serializer, indent, decycler) {
272
+ return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
273
+ }
274
+ function getSerialize(serializer, decycler) {
275
+ var stack = [], keys = [];
276
+ if (!decycler)
277
+ decycler = function (_, value) {
278
+ if (stack[0] === value)
279
+ return "[Circular ~]";
280
+ return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
281
+ };
282
+ return function (key, value) {
283
+ if (stack.length > 0) {
284
+ var thisPos = stack.indexOf(this);
285
+ ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
286
+ ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
287
+ if (~stack.indexOf(value))
288
+ value = decycler.call(this, key, value);
289
+ }
290
+ else
291
+ stack.push(value);
292
+ return serializer == null ? value : serializer.call(this, key, value);
293
+ };
294
+ }
295
+ function isImmutableDefault(value) {
296
+ return typeof value !== "object" || value == null || Object.isFrozen(value);
297
+ }
298
+ function trackForMutations(isImmutable, ignorePaths, obj) {
299
+ var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
300
+ return {
301
+ detectMutations: function () {
302
+ return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
303
+ }
304
+ };
305
+ }
306
+ function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
307
+ if (ignorePaths === void 0) { ignorePaths = []; }
308
+ if (path === void 0) { path = ""; }
309
+ if (checkedObjects === void 0) { checkedObjects = new Set(); }
310
+ var tracked = { value: obj };
311
+ if (!isImmutable(obj) && !checkedObjects.has(obj)) {
312
+ checkedObjects.add(obj);
313
+ tracked.children = {};
314
+ for (var key in obj) {
315
+ var childPath = path ? path + "." + key : key;
316
+ if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
317
+ continue;
318
+ }
319
+ tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
320
+ }
321
+ }
322
+ return tracked;
323
+ }
324
+ function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
325
+ if (ignoredPaths === void 0) { ignoredPaths = []; }
326
+ if (sameParentRef === void 0) { sameParentRef = false; }
327
+ if (path === void 0) { path = ""; }
328
+ var prevObj = trackedProperty ? trackedProperty.value : void 0;
329
+ var sameRef = prevObj === obj;
330
+ if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
331
+ return { wasMutated: true, path: path };
332
+ }
333
+ if (isImmutable(prevObj) || isImmutable(obj)) {
334
+ return { wasMutated: false };
335
+ }
336
+ var keysToDetect = {};
337
+ for (var key in trackedProperty.children) {
338
+ keysToDetect[key] = true;
339
+ }
340
+ for (var key in obj) {
341
+ keysToDetect[key] = true;
342
+ }
343
+ var hasIgnoredPaths = ignoredPaths.length > 0;
344
+ var _loop_1 = function (key) {
345
+ var nestedPath = path ? path + "." + key : key;
346
+ if (hasIgnoredPaths) {
347
+ var hasMatches = ignoredPaths.some(function (ignored) {
348
+ if (ignored instanceof RegExp) {
349
+ return ignored.test(nestedPath);
350
+ }
351
+ return nestedPath === ignored;
352
+ });
353
+ if (hasMatches) {
354
+ return "continue";
355
+ }
356
+ }
357
+ var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
358
+ if (result.wasMutated) {
359
+ return { value: result };
360
+ }
361
+ };
362
+ for (var key in keysToDetect) {
363
+ var state_1 = _loop_1(key);
364
+ if (typeof state_1 === "object")
365
+ return state_1.value;
366
+ }
367
+ return { wasMutated: false };
368
+ }
369
+ function createImmutableStateInvariantMiddleware(options) {
370
+ if (options === void 0) { options = {}; }
371
+ if (process.env.NODE_ENV === "production") {
372
+ return function () { return function (next) { return function (action) { return next(action); }; }; };
373
+ }
374
+ 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;
375
+ ignoredPaths = ignoredPaths || ignore;
376
+ var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
377
+ return function (_c) {
378
+ var getState = _c.getState;
379
+ var state = getState();
380
+ var tracker = track(state);
381
+ var result;
382
+ return function (next) { return function (action) {
383
+ var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
384
+ measureUtils.measureTime(function () {
385
+ state = getState();
386
+ result = tracker.detectMutations();
387
+ tracker = track(state);
388
+ 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)");
389
+ });
390
+ var dispatchedAction = next(action);
391
+ measureUtils.measureTime(function () {
392
+ state = getState();
393
+ result = tracker.detectMutations();
394
+ tracker = track(state);
395
+ 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)");
396
+ });
397
+ measureUtils.warnIfExceeded();
398
+ return dispatchedAction;
399
+ }; };
400
+ };
401
+ }
402
+ // src/serializableStateInvariantMiddleware.ts
403
+ function isPlain(val) {
404
+ var type = typeof val;
405
+ return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
406
+ }
407
+ function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
408
+ if (path === void 0) { path = ""; }
409
+ if (isSerializable === void 0) { isSerializable = isPlain; }
410
+ if (ignoredPaths === void 0) { ignoredPaths = []; }
411
+ var foundNestedSerializable;
412
+ if (!isSerializable(value)) {
413
+ return {
414
+ keyPath: path || "<root>",
415
+ value: value
416
+ };
417
+ }
418
+ if (typeof value !== "object" || value === null) {
419
+ return false;
420
+ }
421
+ if (cache == null ? void 0 : cache.has(value))
422
+ return false;
423
+ var entries = getEntries != null ? getEntries(value) : Object.entries(value);
424
+ var hasIgnoredPaths = ignoredPaths.length > 0;
425
+ var _loop_2 = function (key, nestedValue) {
426
+ var nestedPath = path ? path + "." + key : key;
427
+ if (hasIgnoredPaths) {
428
+ var hasMatches = ignoredPaths.some(function (ignored) {
429
+ if (ignored instanceof RegExp) {
430
+ return ignored.test(nestedPath);
431
+ }
432
+ return nestedPath === ignored;
433
+ });
434
+ if (hasMatches) {
435
+ return "continue";
436
+ }
437
+ }
438
+ if (!isSerializable(nestedValue)) {
439
+ return { value: {
440
+ keyPath: nestedPath,
441
+ value: nestedValue
442
+ } };
443
+ }
444
+ if (typeof nestedValue === "object") {
445
+ foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
446
+ if (foundNestedSerializable) {
447
+ return { value: foundNestedSerializable };
448
+ }
449
+ }
450
+ };
451
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
452
+ var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
453
+ var state_2 = _loop_2(key, nestedValue);
454
+ if (typeof state_2 === "object")
455
+ return state_2.value;
456
+ }
457
+ if (cache && isNestedFrozen(value))
458
+ cache.add(value);
459
+ return false;
460
+ }
461
+ function isNestedFrozen(value) {
462
+ if (!Object.isFrozen(value))
463
+ return false;
464
+ for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
465
+ var nestedValue = _c[_i];
466
+ if (typeof nestedValue !== "object" || nestedValue === null)
467
+ continue;
468
+ if (!isNestedFrozen(nestedValue))
469
+ return false;
470
+ }
471
+ return true;
472
+ }
473
+ function createSerializableStateInvariantMiddleware(options) {
474
+ if (options === void 0) { options = {}; }
475
+ if (process.env.NODE_ENV === "production") {
476
+ return function () { return function (next) { return function (action) { return next(action); }; }; };
477
+ }
478
+ 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;
479
+ var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
480
+ return function (storeAPI) { return function (next) { return function (action) {
481
+ var result = next(action);
482
+ var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
483
+ if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
484
+ measureUtils.measureTime(function () {
485
+ var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
486
+ if (foundActionNonSerializableValue) {
487
+ var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
488
+ 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)");
489
+ }
490
+ });
491
+ }
492
+ if (!ignoreState) {
493
+ measureUtils.measureTime(function () {
494
+ var state = storeAPI.getState();
495
+ var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
496
+ if (foundStateNonSerializableValue) {
497
+ var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
498
+ 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)");
499
+ }
500
+ });
501
+ measureUtils.warnIfExceeded();
502
+ }
503
+ return result;
504
+ }; }; };
505
+ }
506
+ // src/getDefaultMiddleware.ts
507
+ function isBoolean(x) {
508
+ return typeof x === "boolean";
509
+ }
510
+ function curryGetDefaultMiddleware() {
511
+ return function curriedGetDefaultMiddleware(options) {
512
+ return getDefaultMiddleware(options);
513
+ };
514
+ }
515
+ function getDefaultMiddleware(options) {
516
+ if (options === void 0) { options = {}; }
517
+ 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;
518
+ var middlewareArray = new MiddlewareArray();
519
+ if (thunk$1) {
520
+ if (isBoolean(thunk$1)) {
521
+ middlewareArray.push(thunk);
522
+ }
523
+ else {
524
+ middlewareArray.push(thunk.withExtraArgument(thunk$1.extraArgument));
525
+ }
526
+ }
527
+ if (process.env.NODE_ENV !== "production") {
528
+ if (immutableCheck) {
529
+ var immutableOptions = {};
530
+ if (!isBoolean(immutableCheck)) {
531
+ immutableOptions = immutableCheck;
532
+ }
533
+ middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
534
+ }
535
+ if (serializableCheck) {
536
+ var serializableOptions = {};
537
+ if (!isBoolean(serializableCheck)) {
538
+ serializableOptions = serializableCheck;
539
+ }
540
+ middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
541
+ }
542
+ if (actionCreatorCheck) {
543
+ var actionCreatorOptions = {};
544
+ if (!isBoolean(actionCreatorCheck)) {
545
+ actionCreatorOptions = actionCreatorCheck;
546
+ }
547
+ middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
548
+ }
549
+ }
550
+ return middlewareArray;
551
+ }
552
+ // src/configureStore.ts
553
+ var IS_PRODUCTION = process.env.NODE_ENV === "production";
554
+ function configureStore(options) {
555
+ var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
556
+ 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;
557
+ var rootReducer;
558
+ if (typeof reducer === "function") {
559
+ rootReducer = reducer;
560
+ }
561
+ else if (isPlainObject(reducer)) {
562
+ rootReducer = redux.combineReducers(reducer);
563
+ }
564
+ else {
565
+ throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
566
+ }
567
+ var finalMiddleware = middleware;
568
+ if (typeof finalMiddleware === "function") {
569
+ finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
570
+ if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
571
+ throw new Error("when using a middleware builder function, an array of middleware must be returned");
572
+ }
573
+ }
574
+ if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
575
+ throw new Error("each middleware provided to configureStore must be a function");
576
+ }
577
+ var middlewareEnhancer = redux.applyMiddleware.apply(void 0, finalMiddleware);
578
+ var finalCompose = redux.compose;
579
+ if (devTools) {
580
+ finalCompose = composeWithDevTools(__spreadValues({
581
+ trace: !IS_PRODUCTION
582
+ }, typeof devTools === "object" && devTools));
583
+ }
584
+ var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
585
+ var storeEnhancers = defaultEnhancers;
586
+ if (Array.isArray(enhancers)) {
587
+ storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
588
+ }
589
+ else if (typeof enhancers === "function") {
590
+ storeEnhancers = enhancers(defaultEnhancers);
591
+ }
592
+ var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
593
+ return redux.createStore(rootReducer, preloadedState, composedEnhancer);
594
+ }
595
+ var promise;
596
+ 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 () {
597
+ throw err;
598
598
  }, 0); }); };
599
599
 
600
600
  function _arrayLikeToArray(r, a) {
@@ -8336,15 +8336,25 @@ var getPendingMessagesMap = function getPendingMessagesMap() {
8336
8336
  return pendingMessagesMap;
8337
8337
  };
8338
8338
  var draftMessagesMap = {};
8339
+ var audioRecordingMap = {};
8339
8340
  var getDraftMessageFromMap = function getDraftMessageFromMap(channelId) {
8340
8341
  return draftMessagesMap[channelId];
8341
8342
  };
8343
+ var getAudioRecordingFromMap = function getAudioRecordingFromMap(channelId) {
8344
+ return audioRecordingMap[channelId];
8345
+ };
8342
8346
  var checkDraftMessagesIsEmpty = function checkDraftMessagesIsEmpty() {
8343
8347
  return Object.keys(draftMessagesMap).length === 0;
8344
8348
  };
8349
+ var setAudioRecordingToMap = function setAudioRecordingToMap(channelId, audioRecording) {
8350
+ audioRecordingMap[channelId] = audioRecording;
8351
+ };
8345
8352
  var removeDraftMessageFromMap = function removeDraftMessageFromMap(channelId) {
8346
8353
  delete draftMessagesMap[channelId];
8347
8354
  };
8355
+ var removeAudioRecordingFromMap = function removeAudioRecordingFromMap(channelId) {
8356
+ delete audioRecordingMap[channelId];
8357
+ };
8348
8358
  var setDraftMessageToMap = function setDraftMessageToMap(channelId, draftMessage) {
8349
8359
  draftMessagesMap[channelId] = draftMessage;
8350
8360
  };
@@ -16303,7 +16313,7 @@ function sendMessage(action) {
16303
16313
  }, _marked$3, null, [[2, 80]]);
16304
16314
  }
16305
16315
  function sendTextMessage(action) {
16306
- var payload, message, connectionState, channelId, channel, sendMessageTid, SceytChatClient, createChannelData, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, messageToSend, pendingMessage, hasNextMessages, messagesToAdd, messageResponse, messageUpdateData, messageToUpdate, channelUpdateParam;
16316
+ var payload, message, connectionState, channelId, channel, sendMessageTid, SceytChatClient, createChannelData, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, messageToSend, pendingMessage, messagesToAdd, messageResponse, messageUpdateData, messageToUpdate, channelUpdateParam;
16307
16317
  return _regeneratorRuntime().wrap(function sendTextMessage$(_context4) {
16308
16318
  while (1) switch (_context4.prev = _context4.next) {
16309
16319
  case 0:
@@ -16375,51 +16385,32 @@ function sendTextMessage(action) {
16375
16385
  pendingMessage.metadata = JSON.parse(pendingMessage.metadata);
16376
16386
  }
16377
16387
  _context4.next = 35;
16378
- return effects.select(messagesHasNextSelector);
16388
+ return effects.call(addPendingMessage, message, pendingMessage, channel);
16379
16389
  case 35:
16380
- hasNextMessages = _context4.sent;
16381
- if (getHasNextCached()) {
16382
- _context4.next = 44;
16383
- break;
16384
- }
16385
- if (!hasNextMessages) {
16386
- _context4.next = 42;
16387
- break;
16388
- }
16389
- _context4.next = 40;
16390
- return effects.put(getMessagesAC(channel));
16391
- case 40:
16392
- _context4.next = 44;
16393
- break;
16394
- case 42:
16395
- _context4.next = 44;
16396
- return effects.put(addMessageAC(JSON.parse(JSON.stringify(pendingMessage))));
16397
- case 44:
16398
- addAllMessages([pendingMessage], MESSAGE_LOAD_DIRECTION.NEXT);
16399
16390
  messagesToAdd = getFromAllMessagesByMessageId('', '', true);
16400
- _context4.next = 48;
16391
+ _context4.next = 38;
16401
16392
  return effects.put(setMessagesAC(JSON.parse(JSON.stringify(messagesToAdd))));
16402
- case 48:
16393
+ case 38:
16403
16394
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
16404
- _context4.next = 74;
16395
+ _context4.next = 64;
16405
16396
  break;
16406
16397
  }
16407
16398
  if (!sendMessageHandler) {
16408
- _context4.next = 55;
16399
+ _context4.next = 45;
16409
16400
  break;
16410
16401
  }
16411
- _context4.next = 52;
16402
+ _context4.next = 42;
16412
16403
  return effects.call(sendMessageHandler, messageToSend, channel.id);
16413
- case 52:
16404
+ case 42:
16414
16405
  messageResponse = _context4.sent;
16415
- _context4.next = 58;
16406
+ _context4.next = 48;
16416
16407
  break;
16417
- case 55:
16418
- _context4.next = 57;
16408
+ case 45:
16409
+ _context4.next = 47;
16419
16410
  return effects.call(channel.sendMessage, messageToSend);
16420
- case 57:
16411
+ case 47:
16421
16412
  messageResponse = _context4.sent;
16422
- case 58:
16413
+ case 48:
16423
16414
  messageUpdateData = {
16424
16415
  id: messageResponse.id,
16425
16416
  body: messageResponse.body,
@@ -16435,9 +16426,9 @@ function sendTextMessage(action) {
16435
16426
  repliedInThread: messageResponse.repliedInThread,
16436
16427
  createdAt: messageResponse.createdAt
16437
16428
  };
16438
- _context4.next = 61;
16429
+ _context4.next = 51;
16439
16430
  return effects.put(updateMessageAC(messageToSend.tid, JSON.parse(JSON.stringify(messageUpdateData))));
16440
- case 61:
16431
+ case 51:
16441
16432
  updateMessageOnMap(channel.id, {
16442
16433
  messageId: messageToSend.tid,
16443
16434
  params: messageUpdateData
@@ -16449,32 +16440,32 @@ function sendTextMessage(action) {
16449
16440
  lastMessage: messageToUpdate,
16450
16441
  lastReactedMessage: null
16451
16442
  };
16452
- _context4.next = 68;
16443
+ _context4.next = 58;
16453
16444
  return effects.put(updateChannelDataAC(channel.id, channelUpdateParam, true));
16454
- case 68:
16445
+ case 58:
16455
16446
  updateChannelOnAllChannels(channel.id, channelUpdateParam);
16456
16447
  if (!channel.unread) {
16457
- _context4.next = 72;
16448
+ _context4.next = 62;
16458
16449
  break;
16459
16450
  }
16460
- _context4.next = 72;
16451
+ _context4.next = 62;
16461
16452
  return effects.put(markChannelAsReadAC(channel.id));
16462
- case 72:
16463
- _context4.next = 75;
16453
+ case 62:
16454
+ _context4.next = 65;
16464
16455
  break;
16465
- case 74:
16456
+ case 64:
16466
16457
  throw new Error('Connection required to send message');
16467
- case 75:
16468
- _context4.next = 77;
16458
+ case 65:
16459
+ _context4.next = 67;
16469
16460
  return effects.put(scrollToNewMessageAC(true));
16470
- case 77:
16471
- _context4.next = 79;
16461
+ case 67:
16462
+ _context4.next = 69;
16472
16463
  return effects.put(setMessagesLoadingStateAC(LOADING_STATE.LOADED));
16473
- case 79:
16474
- _context4.next = 90;
16464
+ case 69:
16465
+ _context4.next = 80;
16475
16466
  break;
16476
- case 81:
16477
- _context4.prev = 81;
16467
+ case 71:
16468
+ _context4.prev = 71;
16478
16469
  _context4.t0 = _context4["catch"](8);
16479
16470
  log.error('error on send text message ... ', _context4.t0);
16480
16471
  updateMessageOnMap(channel.id, {
@@ -16486,18 +16477,18 @@ function sendTextMessage(action) {
16486
16477
  updateMessageOnAllMessages(sendMessageTid, {
16487
16478
  state: MESSAGE_STATUS.FAILED
16488
16479
  });
16489
- _context4.next = 88;
16480
+ _context4.next = 78;
16490
16481
  return effects.put(updateMessageAC(sendMessageTid, {
16491
16482
  state: MESSAGE_STATUS.FAILED
16492
16483
  }));
16493
- case 88:
16494
- _context4.next = 90;
16484
+ case 78:
16485
+ _context4.next = 80;
16495
16486
  return effects.put(setMessagesLoadingStateAC(LOADING_STATE.LOADED));
16496
- case 90:
16487
+ case 80:
16497
16488
  case "end":
16498
16489
  return _context4.stop();
16499
16490
  }
16500
- }, _marked2$2, null, [[8, 81]]);
16491
+ }, _marked2$2, null, [[8, 71]]);
16501
16492
  }
16502
16493
  function forwardMessage(action) {
16503
16494
  var payload, message, channelId, connectionState, channel, SceytChatClient, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, messageToSend, pendingMessage, activeChannelId, isCachedChannel, hasNextMessages, messageResponse, messageUpdateData, messageToUpdate, channelUpdateParam;
@@ -19644,11 +19635,14 @@ var ChannelMessageText = function ChannelMessageText(_ref2) {
19644
19635
  typingOrRecording = _ref2.typingOrRecording,
19645
19636
  channel = _ref2.channel,
19646
19637
  isDirectChannel = _ref2.isDirectChannel;
19638
+ var audioRecording = React.useMemo(function () {
19639
+ return getAudioRecordingFromMap(channel.id);
19640
+ }, [channel.id, draftMessageText]);
19647
19641
  return /*#__PURE__*/React__default.createElement(MessageTextContainer, null, isTypingOrRecording && (/*#__PURE__*/React__default.createElement(TypingIndicator, null, !isDirectChannel && /*#__PURE__*/React__default.createElement(Points, {
19648
19642
  color: textPrimary
19649
19643
  }, ":"), typingOrRecording.isTyping ? 'typing' : 'recording', "...")), !isTypingOrRecording && (draftMessageText ? (/*#__PURE__*/React__default.createElement(DraftMessageText, {
19650
19644
  color: textSecondary
19651
- }, 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) {
19645
+ }, 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) {
19652
19646
  return mem === user.id ? ' You' : " " + systemMessageUserName(mem, contactsMap && contactsMap[mem], lastMessage.mentionedUsers);
19653
19647
  })) + " " + (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) {
19654
19648
  return mem === user.id ? ' You' : " " + systemMessageUserName(mem, contactsMap && contactsMap[mem], lastMessage.mentionedUsers);
@@ -19742,8 +19736,13 @@ var Channel = function Channel(_ref3) {
19742
19736
  React.useEffect(function () {
19743
19737
  if (activeChannel.id !== channel.id) {
19744
19738
  var channelDraftMessage = getDraftMessageFromMap(channel.id);
19745
- if (channelDraftMessage) {
19746
- setDraftMessageText(channelDraftMessage.text);
19739
+ var draftAudioRecording = getAudioRecordingFromMap(channel.id);
19740
+ if (channelDraftMessage || draftAudioRecording) {
19741
+ if (channelDraftMessage) {
19742
+ setDraftMessageText(channelDraftMessage.text);
19743
+ } else if (draftAudioRecording) {
19744
+ setDraftMessageText('Voice');
19745
+ }
19747
19746
  } else if (draftMessageText) {
19748
19747
  setDraftMessageText(undefined);
19749
19748
  }
@@ -19953,7 +19952,7 @@ var Container$2 = styled__default.div(_templateObject6$1 || (_templateObject6$1
19953
19952
  var DraftMessageTitle = styled__default.span(_templateObject7$1 || (_templateObject7$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (props) {
19954
19953
  return props.color;
19955
19954
  });
19956
- var DraftMessageText = styled__default.span(_templateObject8$1 || (_templateObject8$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (props) {
19955
+ var DraftMessageText = styled__default.span(_templateObject8$1 || (_templateObject8$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n display: flex;\n align-items: flex-end;\n gap: 4px;\n"])), function (props) {
19957
19956
  return props.color;
19958
19957
  });
19959
19958
  var LastMessageAuthor = styled__default.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) {
@@ -31305,9 +31304,11 @@ var MessageList = function MessageList(_ref2) {
31305
31304
  setIsDragging(false);
31306
31305
  if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
31307
31306
  var fileList = Object.values(e.dataTransfer.files);
31308
- var attachmentsFiles = [];
31309
31307
  new Promise(function (resolve) {
31310
- fileList.forEach(function (attachment, index) {
31308
+ var attachmentsFiles = [];
31309
+ var readFiles = 0;
31310
+ var errorCount = 0;
31311
+ fileList.forEach(function (attachment) {
31311
31312
  var fileReader = new FileReader();
31312
31313
  fileReader.onload = function (event) {
31313
31314
  var file = event.target.result;
@@ -31316,14 +31317,23 @@ var MessageList = function MessageList(_ref2) {
31316
31317
  data: file,
31317
31318
  type: attachment.type
31318
31319
  });
31319
- if (fileList.length - 1 === index) {
31320
- resolve();
31320
+ readFiles++;
31321
+ if (readFiles + errorCount === fileList.length) {
31322
+ resolve(attachmentsFiles);
31323
+ }
31324
+ };
31325
+ fileReader.onerror = function () {
31326
+ errorCount++;
31327
+ if (readFiles + errorCount === fileList.length) {
31328
+ resolve(attachmentsFiles);
31321
31329
  }
31322
31330
  };
31323
31331
  fileReader.readAsDataURL(attachment);
31324
31332
  });
31325
- }).then(function () {
31326
- dispatch(setDraggedAttachmentsAC(attachmentsFiles, 'file'));
31333
+ }).then(function (result) {
31334
+ dispatch(setDraggedAttachmentsAC(result, 'file'));
31335
+ })["catch"](function (error) {
31336
+ console.error('Error in handleDropFile:', error);
31327
31337
  });
31328
31338
  e.dataTransfer.clearData();
31329
31339
  }
@@ -31334,9 +31344,10 @@ var MessageList = function MessageList(_ref2) {
31334
31344
  setIsDragging(false);
31335
31345
  if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
31336
31346
  var fileList = Object.values(e.dataTransfer.files);
31337
- var attachmentsFiles = [];
31338
31347
  new Promise(function (resolve) {
31348
+ var attachmentsFiles = [];
31339
31349
  var readFiles = 0;
31350
+ var errorCount = 0;
31340
31351
  fileList.forEach(function (attachment) {
31341
31352
  var fileReader = new FileReader();
31342
31353
  fileReader.onload = function (event) {
@@ -31347,14 +31358,22 @@ var MessageList = function MessageList(_ref2) {
31347
31358
  type: attachment.type
31348
31359
  });
31349
31360
  readFiles++;
31350
- if (fileList.length === readFiles) {
31351
- resolve();
31361
+ if (readFiles + errorCount === fileList.length) {
31362
+ resolve(attachmentsFiles);
31363
+ }
31364
+ };
31365
+ fileReader.onerror = function () {
31366
+ errorCount++;
31367
+ if (readFiles + errorCount === fileList.length) {
31368
+ resolve(attachmentsFiles);
31352
31369
  }
31353
31370
  };
31354
31371
  fileReader.readAsDataURL(attachment);
31355
31372
  });
31356
- }).then(function () {
31357
- dispatch(setDraggedAttachmentsAC(attachmentsFiles, 'media'));
31373
+ }).then(function (result) {
31374
+ dispatch(setDraggedAttachmentsAC(result, 'media'));
31375
+ })["catch"](function (error) {
31376
+ console.error('Error in handleDropMedia:', error);
31358
31377
  });
31359
31378
  e.dataTransfer.clearData();
31360
31379
  }
@@ -31848,7 +31867,7 @@ var MessageList = function MessageList(_ref2) {
31848
31867
  attachmentsPreview: attachmentsPreview
31849
31868
  })))));
31850
31869
  };
31851
- var Container$h = styled__default.div(_templateObject$C || (_templateObject$C = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column-reverse;\n flex-grow: 1;\n position: relative;\n overflow: auto;\n scroll-behavior: smooth;\n will-change: left, top;\n background-color: ", ";\n\n &::-webkit-scrollbar {\n width: 8px;\n background: transparent;\n }\n &::-webkit-scrollbar-thumb {\n background: transparent;\n }\n\n &.show-scrollbar::-webkit-scrollbar-thumb {\n background: ", ";\n border-radius: 4px;\n }\n &.show-scrollbar::-webkit-scrollbar-track {\n background: transparent;\n }\n"])), function (props) {
31870
+ var Container$h = styled__default.div(_templateObject$C || (_templateObject$C = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column-reverse;\n flex-grow: 1;\n position: relative;\n overflow: auto;\n scroll-behavior: smooth;\n will-change: left, top;\n background-color: ", ";\n overflow-x: hidden;\n\n &::-webkit-scrollbar {\n width: 8px;\n background: transparent;\n }\n &::-webkit-scrollbar-thumb {\n background: transparent;\n }\n\n &.show-scrollbar::-webkit-scrollbar-thumb {\n background: ", ";\n border-radius: 4px;\n }\n &.show-scrollbar::-webkit-scrollbar-track {\n background: transparent;\n }\n"])), function (props) {
31852
31871
  return props.backgroundColor;
31853
31872
  }, function (props) {
31854
31873
  return props.thumbColor;
@@ -33863,9 +33882,77 @@ function SvgRecordButton(props) {
33863
33882
  var _templateObject$G, _templateObject2$B, _templateObject3$u, _templateObject4$q, _templateObject5$m, _templateObject6$i, _templateObject7$g;
33864
33883
  var shouldDraw = false;
33865
33884
  var AudioRecord = function AudioRecord(_ref) {
33866
- var startRecording = function startRecording() {
33885
+ var sendRecordedFile = _ref.sendRecordedFile,
33886
+ setShowRecording = _ref.setShowRecording,
33887
+ showRecording = _ref.showRecording,
33888
+ channelId = _ref.channelId;
33889
+ var _useColor = useColors(),
33890
+ accentColor = _useColor[THEME_COLORS.ACCENT],
33891
+ textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
33892
+ warningColor = _useColor[THEME_COLORS.WARNING],
33893
+ iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
33894
+ surface1 = _useColor[THEME_COLORS.SURFACE_1];
33895
+ var _useState = React.useState(null),
33896
+ recording = _useState[0],
33897
+ setStartRecording = _useState[1];
33898
+ var _useState2 = React.useState(null),
33899
+ recorder = _useState2[0],
33900
+ setRecorder = _useState2[1];
33901
+ var _useState3 = React.useState(null),
33902
+ recordedFile = _useState3[0],
33903
+ setRecordedFile = _useState3[1];
33904
+ var _useState4 = React.useState(false),
33905
+ recordingIsReadyToPlay = _useState4[0],
33906
+ setRecordingIsReadyToPlay = _useState4[1];
33907
+ var _useState5 = React.useState(0),
33908
+ currentTime = _useState5[0],
33909
+ setCurrentTime = _useState5[1];
33910
+ var _useState6 = React.useState(null),
33911
+ sendingInterval = _useState6[0],
33912
+ setSendingInterval = _useState6[1];
33913
+ var _useState7 = React.useState(''),
33914
+ currentChannelId = _useState7[0],
33915
+ setCurrentChannelId = _useState7[1];
33916
+ var _useState8 = React.useState(false),
33917
+ playAudio = _useState8[0],
33918
+ setPlayAudio = _useState8[1];
33919
+ var wavesurferContainer = React.useRef(null);
33920
+ var recordButtonRef = React.useRef(null);
33921
+ var wavesurfer = React.useRef({});
33922
+ var intervalRef = React.useRef({});
33923
+ var currentRecordedFile = React.useMemo(function () {
33924
+ var current = getAudioRecordingFromMap(currentChannelId) || recordedFile;
33925
+ return current;
33926
+ }, [recordedFile, currentChannelId]);
33927
+ React.useEffect(function () {
33928
+ if (currentRecordedFile) {
33929
+ setRecordedFile(currentRecordedFile);
33930
+ }
33931
+ }, [currentRecordedFile]);
33932
+ var dispatch = reactRedux.useDispatch();
33933
+ var handleStartRecording = function handleStartRecording() {
33934
+ dispatch(sendRecordingAC(true));
33935
+ if (sendingInterval) {
33936
+ clearInterval(sendingInterval);
33937
+ setSendingInterval(null);
33938
+ return;
33939
+ }
33940
+ var interval = setInterval(function () {
33941
+ dispatch(sendRecordingAC(true));
33942
+ }, 1000);
33943
+ setSendingInterval(interval);
33944
+ };
33945
+ var handleStopRecording = function handleStopRecording() {
33946
+ dispatch(sendRecordingAC(false));
33947
+ if (sendingInterval) {
33948
+ clearInterval(sendingInterval);
33949
+ setSendingInterval(null);
33950
+ }
33951
+ };
33952
+ var startRecording = function startRecording(cId) {
33867
33953
  try {
33868
- var _temp3 = _catch(function () {
33954
+ var id = cId || currentChannelId;
33955
+ var _temp = _catch(function () {
33869
33956
  return Promise.resolve(navigator.permissions.query({
33870
33957
  name: 'microphone'
33871
33958
  })).then(function (permissionStatus) {
@@ -33875,18 +33962,27 @@ var AudioRecord = function AudioRecord(_ref) {
33875
33962
  recordButtonRef.current.style.pointerEvents = 'none';
33876
33963
  }
33877
33964
  if (recording) {
33878
- stopRecording(true);
33879
- } else if (recordedFile) {
33880
- sendRecordedFile(recordedFile);
33965
+ stopRecording(true, id, false, recorder);
33966
+ } else if (currentRecordedFile) {
33967
+ var _wavesurfer$current;
33968
+ removeAudioRecordingFromMap(id);
33881
33969
  setRecordedFile(null);
33882
33970
  setPlayAudio(false);
33883
- if (wavesurfer.current) {
33884
- wavesurfer.current.destroy();
33971
+ if ((_wavesurfer$current = wavesurfer.current) !== null && _wavesurfer$current !== void 0 && _wavesurfer$current[id]) {
33972
+ wavesurfer.current[id].destroy();
33885
33973
  }
33886
33974
  setStartRecording(false);
33887
33975
  setShowRecording(false);
33976
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
33977
+ sendRecordedFile(currentRecordedFile, id);
33888
33978
  } else {
33889
33979
  handleStartRecording();
33980
+ setAudioRecordingToMap(id, {
33981
+ file: null,
33982
+ objectUrl: null,
33983
+ thumb: null,
33984
+ dur: 0
33985
+ });
33890
33986
  recorder.start().then(function () {
33891
33987
  recordButtonRef.current.style.pointerEvents = 'initial';
33892
33988
  setShowRecording(true);
@@ -33894,8 +33990,8 @@ var AudioRecord = function AudioRecord(_ref) {
33894
33990
  shouldDraw = true;
33895
33991
  var stream = recorder.activeStream;
33896
33992
  var obj = {};
33897
- function init() {
33898
- obj.canvas = document.getElementById('waveform');
33993
+ var init = function init() {
33994
+ obj.canvas = document.getElementById("waveform-" + id);
33899
33995
  obj.ctx = obj.canvas.getContext('2d');
33900
33996
  obj.width = 360;
33901
33997
  obj.height = 28;
@@ -33903,10 +33999,10 @@ var AudioRecord = function AudioRecord(_ref) {
33903
33999
  obj.canvas.height = obj.height;
33904
34000
  obj.canvas.style.width = obj.width + 'px';
33905
34001
  obj.canvas.style.height = obj.height + 'px';
33906
- }
34002
+ };
33907
34003
  var timeOffset = 100;
33908
34004
  var now = parseInt(performance.now()) / timeOffset;
33909
- function loop() {
34005
+ var _loop = function loop() {
33910
34006
  if (!shouldDraw) {
33911
34007
  obj.x = 0;
33912
34008
  obj.ctx.clearRect(0, 0, obj.canvas.width, obj.canvas.height);
@@ -33934,10 +34030,10 @@ var AudioRecord = function AudioRecord(_ref) {
33934
34030
  });
33935
34031
  }
33936
34032
  draw();
33937
- requestAnimationFrame(loop);
33938
- }
34033
+ requestAnimationFrame(_loop);
34034
+ };
33939
34035
  obj.bars = [];
33940
- function draw() {
34036
+ var draw = function draw() {
33941
34037
  for (var i = 0; i < obj.bars.length; i++) {
33942
34038
  var bar = obj.bars[i];
33943
34039
  obj.ctx.fillStyle = textSecondary;
@@ -33947,8 +34043,8 @@ var AudioRecord = function AudioRecord(_ref) {
33947
34043
  obj.bars.splice(i, 1);
33948
34044
  }
33949
34045
  }
33950
- }
33951
- function soundAllowed(stream) {
34046
+ };
34047
+ var soundAllowed = function soundAllowed(stream) {
33952
34048
  var AudioContext = window.AudioContext || window.webkitAudioContext;
33953
34049
  var audioContent = new AudioContext();
33954
34050
  var streamSource = audioContent.createMediaStreamSource(stream);
@@ -33957,8 +34053,8 @@ var AudioRecord = function AudioRecord(_ref) {
33957
34053
  obj.analyser.fftSize = 512;
33958
34054
  obj.frequencyArray = new Float32Array(obj.analyser.fftSize);
33959
34055
  init();
33960
- loop();
33961
- }
34056
+ _loop();
34057
+ };
33962
34058
  soundAllowed(stream);
33963
34059
  })["catch"](function (e) {
33964
34060
  handleStopRecording();
@@ -33970,72 +34066,21 @@ var AudioRecord = function AudioRecord(_ref) {
33970
34066
  handleStopRecording();
33971
34067
  log.error(e);
33972
34068
  });
33973
- return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
34069
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
33974
34070
  } catch (e) {
33975
34071
  return Promise.reject(e);
33976
34072
  }
33977
34073
  };
33978
- var sendRecordedFile = _ref.sendRecordedFile,
33979
- setShowRecording = _ref.setShowRecording,
33980
- showRecording = _ref.showRecording;
33981
- var _useColor = useColors(),
33982
- accentColor = _useColor[THEME_COLORS.ACCENT],
33983
- textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
33984
- warningColor = _useColor[THEME_COLORS.WARNING],
33985
- iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
33986
- surface1 = _useColor[THEME_COLORS.SURFACE_1];
33987
- var _useState = React.useState(null),
33988
- recording = _useState[0],
33989
- setStartRecording = _useState[1];
33990
- var _useState2 = React.useState(null),
33991
- recorder = _useState2[0],
33992
- setRecorder = _useState2[1];
33993
- var _useState3 = React.useState(null),
33994
- recordedFile = _useState3[0],
33995
- setRecordedFile = _useState3[1];
33996
- var _useState4 = React.useState(false),
33997
- recordingIsReadyToPlay = _useState4[0],
33998
- setRecordingIsReadyToPlay = _useState4[1];
33999
- var _useState5 = React.useState(0),
34000
- currentTime = _useState5[0],
34001
- setCurrentTime = _useState5[1];
34002
- var _useState6 = React.useState(null),
34003
- sendingInterval = _useState6[0],
34004
- setSendingInterval = _useState6[1];
34005
- var _useState7 = React.useState(false),
34006
- playAudio = _useState7[0],
34007
- setPlayAudio = _useState7[1];
34008
- var wavesurfer = React.useRef(null);
34009
- var wavesurferContainer = React.useRef(null);
34010
- var intervalRef = React.useRef(null);
34011
- var recordButtonRef = React.useRef(null);
34012
- var dispatch = reactRedux.useDispatch();
34013
- var handleStartRecording = function handleStartRecording() {
34014
- dispatch(sendRecordingAC(true));
34015
- if (sendingInterval) {
34016
- clearInterval(sendingInterval);
34017
- setSendingInterval(null);
34018
- return;
34019
- }
34020
- var interval = setInterval(function () {
34021
- dispatch(sendRecordingAC(true));
34022
- }, 1000);
34023
- setSendingInterval(interval);
34024
- };
34025
- var handleStopRecording = function handleStopRecording() {
34026
- dispatch(sendRecordingAC(false));
34027
- if (sendingInterval) {
34028
- clearInterval(sendingInterval);
34029
- setSendingInterval(null);
34030
- }
34031
- };
34032
- function cancelRecording() {
34074
+ var cancelRecording = React.useCallback(function () {
34033
34075
  handleStopRecording();
34034
- if (recordedFile) {
34076
+ if (currentRecordedFile) {
34077
+ var _wavesurfer$current2;
34078
+ removeAudioRecordingFromMap(currentChannelId);
34079
+ dispatch(setChannelDraftMessageIsRemovedAC(currentChannelId));
34035
34080
  setRecordedFile(null);
34036
34081
  setPlayAudio(false);
34037
- if (wavesurfer.current) {
34038
- wavesurfer.current.destroy();
34082
+ if ((_wavesurfer$current2 = wavesurfer.current) !== null && _wavesurfer$current2 !== void 0 && _wavesurfer$current2[currentChannelId]) {
34083
+ wavesurfer.current[currentChannelId].destroy();
34039
34084
  }
34040
34085
  } else {
34041
34086
  shouldDraw = false;
@@ -34045,13 +34090,128 @@ var AudioRecord = function AudioRecord(_ref) {
34045
34090
  setStartRecording(false);
34046
34091
  setCurrentTime(0);
34047
34092
  setShowRecording(false);
34048
- }
34049
- function stopRecording(send) {
34093
+ }, [currentRecordedFile, currentChannelId, wavesurfer, setShowRecording, setRecordedFile]);
34094
+ var _initWaveSurfer = function initWaveSurfer(draft, cId, audioRecording, container) {
34095
+ try {
34096
+ var _exit = false;
34097
+ return Promise.resolve(_catch(function () {
34098
+ var _wavesurfer$current3;
34099
+ function _temp3(_result3) {
34100
+ if (_exit) return _result3;
34101
+ if (draft) {
34102
+ return;
34103
+ }
34104
+ wavesurfer.current[id].on('ready', function () {
34105
+ setRecordingIsReadyToPlay(true);
34106
+ var audioDuration = wavesurfer.current[id].getDuration();
34107
+ setCurrentTime(audioDuration);
34108
+ });
34109
+ wavesurfer.current[id].on('finish', function () {
34110
+ setPlayAudio(false);
34111
+ wavesurfer.current[id].seekTo(0);
34112
+ var audioDuration = wavesurfer.current[id].getDuration();
34113
+ setCurrentTime(audioDuration);
34114
+ clearInterval(intervalRef.current[id]);
34115
+ });
34116
+ wavesurfer.current[id].on('pause', function () {
34117
+ setPlayAudio(false);
34118
+ clearInterval(intervalRef.current[id]);
34119
+ });
34120
+ wavesurfer.current[id].on('interaction', function () {
34121
+ var currentTime = wavesurfer.current[id].getCurrentTime();
34122
+ setCurrentTime(currentTime);
34123
+ });
34124
+ }
34125
+ if (draft) {
34126
+ return;
34127
+ }
34128
+ var id = cId || currentChannelId;
34129
+ if ((_wavesurfer$current3 = wavesurfer.current) !== null && _wavesurfer$current3 !== void 0 && _wavesurfer$current3[id]) {
34130
+ setRecordingIsReadyToPlay(true);
34131
+ var audioDuration = wavesurfer.current[id].getDuration();
34132
+ setCurrentTime(audioDuration);
34133
+ }
34134
+ var _temp2 = function (_wavesurfer$current4) {
34135
+ if (!((_wavesurfer$current4 = wavesurfer.current) !== null && _wavesurfer$current4 !== void 0 && _wavesurfer$current4[id])) {
34136
+ var _ref2;
34137
+ var containerElement = wavesurferContainer.current || container;
34138
+ if (!containerElement) {
34139
+ setTimeout(function () {
34140
+ return _initWaveSurfer(draft, cId, audioRecording, container);
34141
+ }, 100);
34142
+ _exit = true;
34143
+ return;
34144
+ }
34145
+ var rect = containerElement.getBoundingClientRect();
34146
+ if (rect.width === 0 || rect.height === 0) {
34147
+ setTimeout(function () {
34148
+ return _initWaveSurfer(draft, cId, audioRecording, container);
34149
+ }, 100);
34150
+ _exit = true;
34151
+ return;
34152
+ }
34153
+ var ws = WaveSurfer.create({
34154
+ container: containerElement,
34155
+ waveColor: textSecondary,
34156
+ progressColor: accentColor,
34157
+ barWidth: 1,
34158
+ barHeight: 2,
34159
+ audioRate: 1,
34160
+ hideScrollbar: true,
34161
+ barRadius: 1.5,
34162
+ cursorWidth: 0,
34163
+ barGap: 2.5,
34164
+ height: 28
34165
+ });
34166
+ var peaks = [];
34167
+ if ((_ref2 = audioRecording || currentRecordedFile) !== null && _ref2 !== void 0 && _ref2.thumb) {
34168
+ var _ref3;
34169
+ var thumbData = (_ref3 = audioRecording || currentRecordedFile) === null || _ref3 === void 0 ? void 0 : _ref3.thumb;
34170
+ if (Array.isArray(thumbData) && thumbData.length > 0) {
34171
+ var maxVal = Math.max.apply(Math, thumbData);
34172
+ if (maxVal > 0 && isFinite(maxVal)) {
34173
+ var dec = maxVal / 100;
34174
+ peaks = thumbData.map(function (peak) {
34175
+ var normalizedPeak = peak / dec / 100;
34176
+ return isFinite(normalizedPeak) ? normalizedPeak : 0;
34177
+ }).filter(function (peak) {
34178
+ return isFinite(peak);
34179
+ });
34180
+ if (peaks.length === 0) {
34181
+ peaks = [];
34182
+ }
34183
+ }
34184
+ }
34185
+ }
34186
+ wavesurfer.current[id] = ws;
34187
+ return _catch(function () {
34188
+ var validPeaks = peaks.length > 0 ? peaks : undefined;
34189
+ 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 () {});
34190
+ }, function () {
34191
+ return _catch(function () {
34192
+ 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 () {});
34193
+ }, function (fallbackError) {
34194
+ console.error('Failed to load audio completely:', fallbackError);
34195
+ throw fallbackError;
34196
+ });
34197
+ });
34198
+ }
34199
+ }();
34200
+ return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
34201
+ }, function (e) {
34202
+ log.error('Failed to init wavesurfer', e);
34203
+ }));
34204
+ } catch (e) {
34205
+ return Promise.reject(e);
34206
+ }
34207
+ };
34208
+ var stopRecording = React.useCallback(function (send, cId, draft, recorder, container) {
34050
34209
  handleStopRecording();
34051
34210
  shouldDraw = false;
34052
- recorder.stop().getMp3().then(function (_ref2) {
34053
- var buffer = _ref2[0],
34054
- blob = _ref2[1];
34211
+ var id = cId || channelId;
34212
+ recorder.stop().getMp3().then(function (_ref4) {
34213
+ var buffer = _ref4[0],
34214
+ blob = _ref4[1];
34055
34215
  setCurrentTime(0);
34056
34216
  var file = new File(buffer, 'record.mp3', {
34057
34217
  type: blob.type,
@@ -34079,15 +34239,29 @@ var AudioRecord = function AudioRecord(_ref) {
34079
34239
  objectUrl: objectUrl,
34080
34240
  thumb: waveform,
34081
34241
  dur: audioBuffer.duration
34082
- });
34242
+ }, id);
34083
34243
  setShowRecording(false);
34244
+ removeAudioRecordingFromMap(id);
34245
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
34084
34246
  } else {
34085
- setRecordedFile({
34247
+ if (!draft) {
34248
+ setRecordedFile({
34249
+ file: file,
34250
+ objectUrl: objectUrl,
34251
+ thumb: waveform,
34252
+ dur: audioBuffer.duration
34253
+ });
34254
+ }
34255
+ var audioRecording = {
34086
34256
  file: file,
34087
34257
  objectUrl: objectUrl,
34088
34258
  thumb: waveform,
34089
34259
  dur: audioBuffer.duration
34090
- });
34260
+ };
34261
+ setAudioRecordingToMap(id, audioRecording);
34262
+ if (draft) {
34263
+ _initWaveSurfer(draft, id, audioRecording, container);
34264
+ }
34091
34265
  }
34092
34266
  }, function (e) {
34093
34267
  log.info('Error decoding audio data: ' + e.err);
@@ -34098,14 +34272,15 @@ var AudioRecord = function AudioRecord(_ref) {
34098
34272
  handleStopRecording();
34099
34273
  log.error(e);
34100
34274
  });
34101
- }
34102
- var handlePlayPause = function handlePlayPause() {
34103
- if (wavesurfer.current) {
34104
- if (!wavesurfer.current.isPlaying()) {
34275
+ }, [sendRecordedFile, setShowRecording, setAudioRecordingToMap, setRecordedFile, handleStopRecording, channelId]);
34276
+ var handlePlayPause = function handlePlayPause(cId) {
34277
+ var _wavesurfer$current5;
34278
+ if ((_wavesurfer$current5 = wavesurfer.current) !== null && _wavesurfer$current5 !== void 0 && _wavesurfer$current5[cId || currentChannelId]) {
34279
+ if (!wavesurfer.current[cId || currentChannelId].isPlaying()) {
34105
34280
  setPlayAudio(true);
34106
34281
  handleStartRecording();
34107
- intervalRef.current = setInterval(function () {
34108
- var currentTime = wavesurfer.current.getCurrentTime();
34282
+ intervalRef.current[cId || currentChannelId] = setInterval(function () {
34283
+ var currentTime = wavesurfer.current[cId || currentChannelId].getCurrentTime();
34109
34284
  if (currentTime >= 0) {
34110
34285
  setCurrentTime(currentTime);
34111
34286
  }
@@ -34113,7 +34288,7 @@ var AudioRecord = function AudioRecord(_ref) {
34113
34288
  } else {
34114
34289
  handleStopRecording();
34115
34290
  }
34116
- wavesurfer.current.playPause();
34291
+ wavesurfer.current[cId || currentChannelId].playPause();
34117
34292
  }
34118
34293
  };
34119
34294
  React.useEffect(function () {
@@ -34125,7 +34300,7 @@ var AudioRecord = function AudioRecord(_ref) {
34125
34300
  setCurrentTime(function (prevState) {
34126
34301
  if (prevState.recordingSeconds === MAX_RECORDER_TIME) {
34127
34302
  clearInterval(recordingInterval);
34128
- stopRecording();
34303
+ stopRecording(false, currentChannelId, false, recorder);
34129
34304
  return 0;
34130
34305
  }
34131
34306
  return prevState + 1;
@@ -34140,132 +34315,133 @@ var AudioRecord = function AudioRecord(_ref) {
34140
34315
  clearInterval(recordingInterval);
34141
34316
  };
34142
34317
  }, [recording]);
34143
- useDidUpdate(function () {
34144
- if (recordedFile) {
34145
- var initWaveSurfer = function initWaveSurfer() {
34146
- try {
34147
- try {
34148
- if (wavesurfer.current) {
34149
- wavesurfer.current.destroy();
34150
- }
34151
- wavesurfer.current = WaveSurfer.create({
34152
- container: wavesurferContainer.current,
34153
- waveColor: textSecondary,
34154
- progressColor: accentColor,
34155
- barWidth: 1,
34156
- barHeight: 2,
34157
- audioRate: 1,
34158
- hideScrollbar: true,
34159
- barRadius: 1.5,
34160
- cursorWidth: 0,
34161
- barGap: 2.5,
34162
- height: 28
34163
- });
34164
- wavesurfer.current.load(recordedFile.objectUrl);
34165
- wavesurfer.current.on('ready', function () {
34166
- setRecordingIsReadyToPlay(true);
34167
- var audioDuration = wavesurfer.current.getDuration();
34168
- setCurrentTime(audioDuration);
34169
- });
34170
- wavesurfer.current.on('finish', function () {
34171
- setPlayAudio(false);
34172
- wavesurfer.current.seekTo(0);
34173
- var audioDuration = wavesurfer.current.getDuration();
34174
- setCurrentTime(audioDuration);
34175
- clearInterval(intervalRef.current);
34176
- });
34177
- wavesurfer.current.on('pause', function () {
34178
- setPlayAudio(false);
34179
- clearInterval(intervalRef.current);
34180
- });
34181
- wavesurfer.current.on('interaction', function () {
34182
- var currentTime = wavesurfer.current.getCurrentTime();
34183
- setCurrentTime(currentTime);
34184
- });
34185
- } catch (e) {
34186
- log.error('Failed to init wavesurfer', e);
34187
- }
34188
- return Promise.resolve();
34189
- } catch (e) {
34190
- return Promise.reject(e);
34191
- }
34192
- };
34193
- initWaveSurfer();
34318
+ React.useEffect(function () {
34319
+ if (currentRecordedFile) {
34320
+ _initWaveSurfer();
34194
34321
  } else {
34322
+ var _wavesurfer$current6;
34195
34323
  setRecordingIsReadyToPlay(false);
34196
- clearInterval(intervalRef.current);
34197
- wavesurfer.current = null;
34324
+ if (intervalRef.current[currentChannelId]) {
34325
+ clearInterval(intervalRef.current[currentChannelId]);
34326
+ intervalRef.current[currentChannelId] = null;
34327
+ }
34328
+ if ((_wavesurfer$current6 = wavesurfer.current) !== null && _wavesurfer$current6 !== void 0 && _wavesurfer$current6[currentChannelId]) {
34329
+ wavesurfer.current[currentChannelId].destroy();
34330
+ wavesurfer.current[currentChannelId] = null;
34331
+ }
34198
34332
  }
34199
34333
  return function () {
34200
- clearInterval(intervalRef.current);
34334
+ for (var key in intervalRef.current) {
34335
+ if (intervalRef.current[key]) {
34336
+ clearInterval(intervalRef.current[key]);
34337
+ intervalRef.current[key] = null;
34338
+ }
34339
+ }
34340
+ for (var _key in wavesurfer.current) {
34341
+ if (wavesurfer.current[_key]) {
34342
+ wavesurfer.current[_key].destroy();
34343
+ wavesurfer.current[_key] = null;
34344
+ }
34345
+ }
34201
34346
  };
34202
- }, [recordedFile]);
34347
+ }, [currentRecordedFile, currentChannelId]);
34203
34348
  React.useEffect(function () {
34204
- (function () {
34205
- try {
34206
- var _temp2 = function () {
34207
- if (!recorder) {
34208
- var _temp = _catch(function () {
34209
- return Promise.resolve(new Promise(function (resolve) { resolve(_interopNamespace(require('mic-recorder-to-mp3'))); })).then(function (MicRecorderModule) {
34210
- var MicRecorder = MicRecorderModule["default"];
34211
- var recorder = new MicRecorder({
34212
- bitRate: 128
34349
+ if (!currentRecordedFile) {
34350
+ (function () {
34351
+ try {
34352
+ var _temp5 = function () {
34353
+ if (!recorder) {
34354
+ var _temp4 = _catch(function () {
34355
+ return Promise.resolve(new Promise(function (resolve) { resolve(_interopNamespace(require('mic-recorder-to-mp3'))); })).then(function (MicRecorderModule) {
34356
+ var MicRecorder = MicRecorderModule["default"];
34357
+ var recorder = new MicRecorder({
34358
+ bitRate: 128
34359
+ });
34360
+ setRecorder(recorder);
34213
34361
  });
34214
- setRecorder(recorder);
34362
+ }, function (e) {
34363
+ log.error('Failed to init mic-recorder-to-mp3', e);
34215
34364
  });
34216
- }, function (e) {
34217
- log.error('Failed to init mic-recorder-to-mp3', e);
34218
- });
34219
- if (_temp && _temp.then) return _temp.then(function () {});
34220
- }
34221
- }();
34222
- return _temp2 && _temp2.then ? _temp2.then(function () {}) : void 0;
34223
- } catch (e) {
34224
- Promise.reject(e);
34225
- }
34226
- })();
34227
- }, []);
34365
+ if (_temp4 && _temp4.then) return _temp4.then(function () {});
34366
+ }
34367
+ }();
34368
+ return _temp5 && _temp5.then ? _temp5.then(function () {}) : void 0;
34369
+ } catch (e) {
34370
+ Promise.reject(e);
34371
+ }
34372
+ })();
34373
+ }
34374
+ }, [currentRecordedFile]);
34228
34375
  React.useEffect(function () {
34229
34376
  return function () {
34230
34377
  handleStopRecording();
34231
34378
  };
34232
34379
  }, [showRecording]);
34380
+ React.useEffect(function () {
34381
+ if (channelId && (showRecording || currentRecordedFile)) {
34382
+ if (!currentRecordedFile) {
34383
+ stopRecording(false, currentChannelId, true, recorder, wavesurferContainer.current);
34384
+ }
34385
+ if (playAudio) {
34386
+ handlePlayPause(channelId);
34387
+ }
34388
+ for (var key in intervalRef.current) {
34389
+ clearInterval(intervalRef.current[key]);
34390
+ intervalRef.current[key] = null;
34391
+ }
34392
+ for (var _key2 in wavesurfer.current) {
34393
+ var _wavesurfer$current$_;
34394
+ (_wavesurfer$current$_ = wavesurfer.current[_key2]) === null || _wavesurfer$current$_ === void 0 ? void 0 : _wavesurfer$current$_.destroy();
34395
+ wavesurfer.current[_key2] = null;
34396
+ }
34397
+ setShowRecording(false);
34398
+ setStartRecording(false);
34399
+ setPlayAudio(false);
34400
+ setCurrentTime(0);
34401
+ var audioRecording = getAudioRecordingFromMap(channelId);
34402
+ setRecordedFile(audioRecording || null);
34403
+ setRecordingIsReadyToPlay(!!audioRecording);
34404
+ }
34405
+ setCurrentChannelId(channelId);
34406
+ }, [channelId]);
34233
34407
  return /*#__PURE__*/React__default.createElement(Container$j, {
34234
- recording: showRecording
34235
- }, showRecording && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34408
+ recording: showRecording || currentRecordedFile
34409
+ }, (showRecording || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34236
34410
  iconColor: iconPrimary,
34237
34411
  onClick: function onClick() {
34238
34412
  return cancelRecording();
34239
34413
  }
34240
34414
  }, /*#__PURE__*/React__default.createElement(SvgClose, null))), /*#__PURE__*/React__default.createElement(AudioWrapper, {
34241
34415
  backgroundColor: surface1,
34242
- recording: recording || recordedFile
34416
+ recording: recording || currentRecordedFile
34243
34417
  }, recording && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34244
34418
  iconColor: warningColor,
34245
34419
  onClick: function onClick() {
34246
- return stopRecording();
34420
+ return stopRecording(false, currentChannelId, false, recorder);
34247
34421
  }
34248
34422
  }, /*#__PURE__*/React__default.createElement(SvgStopRecord, null))), /*#__PURE__*/React__default.createElement(Canvas, {
34249
- hide: recordedFile,
34250
- id: 'waveform',
34423
+ hide: currentRecordedFile,
34424
+ id: "waveform-" + channelId,
34251
34425
  recording: recording
34252
34426
  }), recording && /*#__PURE__*/React__default.createElement(Timer$2, {
34253
34427
  color: textSecondary
34254
- }, formatAudioVideoTime(currentTime)), recordingIsReadyToPlay && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34428
+ }, formatAudioVideoTime(currentTime)), (recordingIsReadyToPlay || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34255
34429
  iconColor: accentColor,
34256
- onClick: handlePlayPause
34430
+ onClick: function onClick() {
34431
+ return handlePlayPause(channelId);
34432
+ }
34257
34433
  }, playAudio ? /*#__PURE__*/React__default.createElement(SvgPauseRecord, null) : /*#__PURE__*/React__default.createElement(SvgPlayRecord, null))), /*#__PURE__*/React__default.createElement(AudioVisualization$1, {
34258
34434
  ref: wavesurferContainer,
34259
- show: recordedFile
34260
- }), recordingIsReadyToPlay && /*#__PURE__*/React__default.createElement(Timer$2, {
34435
+ show: currentRecordedFile
34436
+ }), (recordingIsReadyToPlay || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(Timer$2, {
34261
34437
  color: textSecondary
34262
- }, formatAudioVideoTime(currentTime))), /*#__PURE__*/React__default.createElement(RecordIconWrapper, {
34438
+ }, formatAudioVideoTime(currentTime)))), /*#__PURE__*/React__default.createElement(RecordIconWrapper, {
34263
34439
  ref: recordButtonRef,
34264
34440
  onClick: function onClick() {
34265
- return startRecording();
34441
+ return startRecording(currentChannelId);
34266
34442
  },
34267
34443
  iconColor: accentColor
34268
- }, showRecording ? /*#__PURE__*/React__default.createElement(SvgSend, null) : /*#__PURE__*/React__default.createElement(SvgRecordButton, null)));
34444
+ }, showRecording || currentRecordedFile ? /*#__PURE__*/React__default.createElement(SvgSend, null) : /*#__PURE__*/React__default.createElement(SvgRecordButton, null)));
34269
34445
  };
34270
34446
  var Container$j = styled__default.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) {
34271
34447
  return props.recording && "width: 400px";
@@ -34282,14 +34458,14 @@ var AudioWrapper = styled__default.div(_templateObject2$B || (_templateObject2$B
34282
34458
  var RecordIconWrapper = styled__default.span(_templateObject3$u || (_templateObject3$u = _taggedTemplateLiteralLoose(["\n display: flex;\n cursor: pointer;\n > svg {\n color: ", ";\n }\n"])), function (props) {
34283
34459
  return props.iconColor;
34284
34460
  });
34285
- var AudioVisualization$1 = styled__default.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) {
34286
- var show = _ref3.show;
34461
+ var AudioVisualization$1 = styled__default.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) {
34462
+ var show = _ref5.show;
34287
34463
  return show ? '1' : '0';
34288
- }, function (_ref4) {
34289
- var show = _ref4.show;
34464
+ }, function (_ref6) {
34465
+ var show = _ref6.show;
34290
34466
  return !show && '-1';
34291
- }, function (_ref5) {
34292
- var show = _ref5.show;
34467
+ }, function (_ref7) {
34468
+ var show = _ref7.show;
34293
34469
  return show ? 'visible' : 'hidden';
34294
34470
  }, function (props) {
34295
34471
  return props.color;
@@ -34297,14 +34473,14 @@ var AudioVisualization$1 = styled__default.div(_templateObject4$q || (_templateO
34297
34473
  var PlayPause$1 = styled__default.div(_templateObject5$m || (_templateObject5$m = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n padding: 10px;\n > svg {\n color: ", ";\n }\n"])), function (props) {
34298
34474
  return props.iconColor;
34299
34475
  });
34300
- var Canvas = styled__default.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) {
34301
- var recording = _ref6.recording;
34476
+ var Canvas = styled__default.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) {
34477
+ var recording = _ref8.recording;
34302
34478
  return recording ? '300px' : '0';
34303
- }, function (_ref7) {
34304
- var hide = _ref7.hide;
34479
+ }, function (_ref9) {
34480
+ var hide = _ref9.hide;
34305
34481
  return hide ? '0' : '1';
34306
- }, function (_ref8) {
34307
- var hide = _ref8.hide;
34482
+ }, function (_ref0) {
34483
+ var hide = _ref0.hide;
34308
34484
  return hide && '-1';
34309
34485
  });
34310
34486
  var Timer$2 = styled__default.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) {
@@ -34508,92 +34684,89 @@ var SendMessageInput = function SendMessageInput(_ref3) {
34508
34684
  var _useState = React.useState(false),
34509
34685
  showRecording = _useState[0],
34510
34686
  setShowRecording = _useState[1];
34511
- var _useState2 = React.useState(null),
34512
- recordedFile = _useState2[0],
34513
- setRecordedFile = _useState2[1];
34514
34687
  var _usePermissions = usePermissions(activeChannel.userRole),
34515
34688
  checkActionPermission = _usePermissions[0];
34516
- var _useState3 = React.useState(false),
34517
- listenerIsAdded = _useState3[0],
34518
- setListenerIsAdded = _useState3[1];
34689
+ var _useState2 = React.useState(false),
34690
+ listenerIsAdded = _useState2[0],
34691
+ setListenerIsAdded = _useState2[1];
34692
+ var _useState3 = React.useState(''),
34693
+ messageText = _useState3[0],
34694
+ setMessageText = _useState3[1];
34519
34695
  var _useState4 = React.useState(''),
34520
- messageText = _useState4[0],
34521
- setMessageText = _useState4[1];
34522
- var _useState5 = React.useState(''),
34523
- editMessageText = _useState5[0],
34524
- setEditMessageText = _useState5[1];
34525
- var _useState6 = React.useState({}),
34526
- readyVideoAttachments = _useState6[0],
34527
- setReadyVideoAttachments = _useState6[1];
34696
+ editMessageText = _useState4[0],
34697
+ setEditMessageText = _useState4[1];
34698
+ var _useState5 = React.useState({}),
34699
+ readyVideoAttachments = _useState5[0],
34700
+ setReadyVideoAttachments = _useState5[1];
34701
+ var _useState6 = React.useState(false),
34702
+ showChooseAttachmentType = _useState6[0],
34703
+ setShowChooseAttachmentType = _useState6[1];
34528
34704
  var _useState7 = React.useState(false),
34529
- showChooseAttachmentType = _useState7[0],
34530
- setShowChooseAttachmentType = _useState7[1];
34705
+ isEmojisOpened = _useState7[0],
34706
+ setIsEmojisOpened = _useState7[1];
34531
34707
  var _useState8 = React.useState(false),
34532
- isEmojisOpened = _useState8[0],
34533
- setIsEmojisOpened = _useState8[1];
34534
- var _useState9 = React.useState(false),
34535
- emojisInRightSide = _useState9[0],
34536
- setEmojisInRightSide = _useState9[1];
34708
+ emojisInRightSide = _useState8[0],
34709
+ setEmojisInRightSide = _useState8[1];
34710
+ var _useState9 = React.useState(0),
34711
+ emojisPopupLeftPosition = _useState9[0],
34712
+ setEmojisPopupLeftPosition = _useState9[1];
34537
34713
  var _useState0 = React.useState(0),
34538
- emojisPopupLeftPosition = _useState0[0],
34539
- setEmojisPopupLeftPosition = _useState0[1];
34540
- var _useState1 = React.useState(0),
34541
- emojisPopupBottomPosition = _useState1[0],
34542
- setEmojisPopupBottomPosition = _useState1[1];
34543
- var _useState10 = React.useState(false),
34544
- addAttachmentsInRightSide = _useState10[0],
34545
- setAddAttachmentsInRightSide = _useState10[1];
34546
- var _useState11 = React.useState({
34714
+ emojisPopupBottomPosition = _useState0[0],
34715
+ setEmojisPopupBottomPosition = _useState0[1];
34716
+ var _useState1 = React.useState(false),
34717
+ addAttachmentsInRightSide = _useState1[0],
34718
+ setAddAttachmentsInRightSide = _useState1[1];
34719
+ var _useState10 = React.useState({
34547
34720
  clear: false
34548
34721
  }),
34549
- shouldClearEditor = _useState11[0],
34550
- setShouldClearEditor = _useState11[1];
34722
+ shouldClearEditor = _useState10[0],
34723
+ setShouldClearEditor = _useState10[1];
34724
+ var _useState11 = React.useState([]),
34725
+ messageBodyAttributes = _useState11[0],
34726
+ setMessageBodyAttributes = _useState11[1];
34551
34727
  var _useState12 = React.useState([]),
34552
- messageBodyAttributes = _useState12[0],
34553
- setMessageBodyAttributes = _useState12[1];
34554
- var _useState13 = React.useState([]),
34555
- mentionedMembers = _useState13[0],
34556
- setMentionedMembers = _useState13[1];
34557
- var _useState14 = React.useState(''),
34558
- browser = _useState14[0],
34559
- setBrowser = _useState14[1];
34560
- var _useState15 = React.useState(false),
34561
- mentionsIsOpen = _useState15[0],
34562
- setMentionsIsOpen = _useState15[1];
34563
- var _useState16 = React.useState(),
34564
- inputContainerHeight = _useState16[0],
34565
- setInputContainerHeight = _useState16[1];
34728
+ mentionedMembers = _useState12[0],
34729
+ setMentionedMembers = _useState12[1];
34730
+ var _useState13 = React.useState(''),
34731
+ browser = _useState13[0],
34732
+ setBrowser = _useState13[1];
34733
+ var _useState14 = React.useState(false),
34734
+ mentionsIsOpen = _useState14[0],
34735
+ setMentionsIsOpen = _useState14[1];
34736
+ var _useState15 = React.useState(),
34737
+ inputContainerHeight = _useState15[0],
34738
+ setInputContainerHeight = _useState15[1];
34566
34739
  var selectedText = React.useRef(null);
34740
+ var _useState16 = React.useState(),
34741
+ typingTimout = _useState16[0],
34742
+ setTypingTimout = _useState16[1];
34567
34743
  var _useState17 = React.useState(),
34568
- typingTimout = _useState17[0],
34569
- setTypingTimout = _useState17[1];
34570
- var _useState18 = React.useState(),
34571
- inTypingStateTimout = _useState18[0],
34572
- setInTypingStateTimout = _useState18[1];
34744
+ inTypingStateTimout = _useState17[0],
34745
+ setInTypingStateTimout = _useState17[1];
34746
+ var _useState18 = React.useState(false),
34747
+ inTypingState = _useState18[0],
34748
+ setInTypingState = _useState18[1];
34573
34749
  var _useState19 = React.useState(false),
34574
- inTypingState = _useState19[0],
34575
- setInTypingState = _useState19[1];
34576
- var _useState20 = React.useState(false),
34577
- sendMessageIsActive = _useState20[0],
34578
- setSendMessageIsActive = _useState20[1];
34579
- var _useState21 = React.useState([]),
34580
- attachments = _useState21[0],
34581
- setAttachments = _useState21[1];
34750
+ sendMessageIsActive = _useState19[0],
34751
+ setSendMessageIsActive = _useState19[1];
34752
+ var _useState20 = React.useState([]),
34753
+ attachments = _useState20[0],
34754
+ setAttachments = _useState20[1];
34755
+ var _useState21 = React.useState(false),
34756
+ forwardPopupOpen = _useState21[0],
34757
+ setForwardPopupOpen = _useState21[1];
34582
34758
  var _useState22 = React.useState(false),
34583
- forwardPopupOpen = _useState22[0],
34584
- setForwardPopupOpen = _useState22[1];
34759
+ deletePopupOpen = _useState22[0],
34760
+ setDeletePopupOpen = _useState22[1];
34585
34761
  var _useState23 = React.useState(false),
34586
- deletePopupOpen = _useState23[0],
34587
- setDeletePopupOpen = _useState23[1];
34588
- var _useState24 = React.useState(false),
34589
- isIncomingMessage = _useState24[0],
34590
- setIsIncomingMessage = _useState24[1];
34591
- var _useState25 = React.useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
34592
- mediaExtensions = _useState25[0],
34593
- setMediaExtensions = _useState25[1];
34594
- var _useState26 = React.useState(''),
34595
- uploadErrorMessage = _useState26[0],
34596
- setUploadErrorMessage = _useState26[1];
34762
+ isIncomingMessage = _useState23[0],
34763
+ setIsIncomingMessage = _useState23[1];
34764
+ var _useState24 = React.useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
34765
+ mediaExtensions = _useState24[0],
34766
+ setMediaExtensions = _useState24[1];
34767
+ var _useState25 = React.useState(''),
34768
+ uploadErrorMessage = _useState25[0],
34769
+ setUploadErrorMessage = _useState25[1];
34597
34770
  var typingOrRecordingIndicator = reactRedux.useSelector(typingOrRecordingIndicatorArraySelector(activeChannel.id));
34598
34771
  var contactsMap = reactRedux.useSelector(contactsMapSelector);
34599
34772
  var connectionStatus = reactRedux.useSelector(connectionStatusSelector, reactRedux.shallowEqual);
@@ -34603,15 +34776,15 @@ var SendMessageInput = function SendMessageInput(_ref3) {
34603
34776
  var messageInputRef = React.useRef(null);
34604
34777
  var emojiBtnRef = React.useRef(null);
34605
34778
  var addAttachmentsBtnRef = React.useRef(null);
34606
- var _useState27 = React.useState(),
34607
- realEditorState = _useState27[0],
34608
- setRealEditorState = _useState27[1];
34609
- var _useState28 = React.useState(null),
34610
- floatingAnchorElem = _useState28[0],
34611
- setFloatingAnchorElem = _useState28[1];
34612
- var _useState29 = React.useState(false),
34613
- isSmallWidthViewport = _useState29[0],
34614
- setIsSmallWidthViewport = _useState29[1];
34779
+ var _useState26 = React.useState(),
34780
+ realEditorState = _useState26[0],
34781
+ setRealEditorState = _useState26[1];
34782
+ var _useState27 = React.useState(null),
34783
+ floatingAnchorElem = _useState27[0],
34784
+ setFloatingAnchorElem = _useState27[1];
34785
+ var _useState28 = React.useState(false),
34786
+ isSmallWidthViewport = _useState28[0],
34787
+ setIsSmallWidthViewport = _useState28[1];
34615
34788
  var addAttachmentByMenu = showChooseFileAttachment && showChooseMediaAttachment;
34616
34789
  function onChange(editorState) {
34617
34790
  setRealEditorState(editorState);
@@ -35329,7 +35502,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35329
35502
  dispatch(setDraggedAttachmentsAC([], ''));
35330
35503
  }
35331
35504
  }, [draggedAttachments]);
35332
- React.useEffect(function () {
35505
+ var sendRecordedFile = function sendRecordedFile(recordedFile, id) {
35333
35506
  if (recordedFile) {
35334
35507
  var tid = uuid.v4();
35335
35508
  var reader = new FileReader();
@@ -35369,7 +35542,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35369
35542
  }],
35370
35543
  type: 'text'
35371
35544
  };
35372
- dispatch(sendMessageAC(messageToSend, activeChannel.id, connectionStatus));
35545
+ dispatch(sendMessageAC(messageToSend, id, connectionStatus));
35373
35546
  });
35374
35547
  } catch (e) {
35375
35548
  return Promise.reject(e);
@@ -35380,7 +35553,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35380
35553
  };
35381
35554
  reader.readAsBinaryString(recordedFile.file);
35382
35555
  }
35383
- }, [recordedFile]);
35556
+ };
35384
35557
  React.useEffect(function () {
35385
35558
  var updateViewPortWidth = function updateViewPortWidth() {
35386
35559
  var isNextSmallWidthViewport = CAN_USE_DOM && window.matchMedia('(max-width: 1025px)').matches;
@@ -35767,7 +35940,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35767
35940
  onChange: handleFileUpload,
35768
35941
  multiple: true,
35769
35942
  type: 'file'
35770
- }), showRecording ? (/*#__PURE__*/React__default.createElement(AudioCont, null)) : (/*#__PURE__*/React__default.createElement(MessageInputWrapper, {
35943
+ }), showRecording || getAudioRecordingFromMap(activeChannel.id) ? (/*#__PURE__*/React__default.createElement(AudioCont, null)) : (/*#__PURE__*/React__default.createElement(MessageInputWrapper, {
35771
35944
  className: 'message_input_wrapper',
35772
35945
  borderRadius: messageForReply || messageToEdit ? borderRadiusOnOpenedEditReplyMessage : borderRadius,
35773
35946
  ref: inputWrapperRef,
@@ -35900,9 +36073,10 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35900
36073
  iconColor: accentColor,
35901
36074
  activeColor: accentColor
35902
36075
  }, /*#__PURE__*/React__default.createElement(AudioRecord, {
35903
- sendRecordedFile: setRecordedFile,
36076
+ sendRecordedFile: sendRecordedFile,
35904
36077
  setShowRecording: setShowRecording,
35905
- showRecording: showRecording
36078
+ showRecording: showRecording,
36079
+ channelId: activeChannel.id
35906
36080
  }))))))))));
35907
36081
  };
35908
36082
  var SendMessageWrapper = styled__default.div(_templateObject$I || (_templateObject$I = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n position: relative;\n z-index: 15;\n"])), function (props) {