@aws-amplify/ui-react 1.2.56-legacy-ui-tests.6 → 1.2.60-unstable.5

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/0.js.map +1 -1
  3. package/dist/1.js +52 -220
  4. package/dist/1.js.map +1 -1
  5. package/dist/10.js +1 -8
  6. package/dist/10.js.map +1 -1
  7. package/dist/11.js +11 -110
  8. package/dist/11.js.map +1 -1
  9. package/dist/12.js +3 -29
  10. package/dist/12.js.map +1 -1
  11. package/dist/13.js +60 -339
  12. package/dist/13.js.map +1 -1
  13. package/dist/14.js +1 -12
  14. package/dist/14.js.map +1 -1
  15. package/dist/15.js +1 -8
  16. package/dist/15.js.map +1 -1
  17. package/dist/16.js +9 -31
  18. package/dist/16.js.map +1 -1
  19. package/dist/17.js +3 -17
  20. package/dist/17.js.map +1 -1
  21. package/dist/18.js +10 -61
  22. package/dist/18.js.map +1 -1
  23. package/dist/19.js +1 -11
  24. package/dist/19.js.map +1 -1
  25. package/dist/2.js +129 -736
  26. package/dist/2.js.map +1 -1
  27. package/dist/20.js +1 -10
  28. package/dist/20.js.map +1 -1
  29. package/dist/21.js +3 -13
  30. package/dist/21.js.map +1 -1
  31. package/dist/22.js +1 -9
  32. package/dist/22.js.map +1 -1
  33. package/dist/23.js +19 -77
  34. package/dist/23.js.map +1 -1
  35. package/dist/24.js +1 -18
  36. package/dist/24.js.map +1 -1
  37. package/dist/25.js +1 -11
  38. package/dist/25.js.map +1 -1
  39. package/dist/26.js +25 -94
  40. package/dist/26.js.map +1 -1
  41. package/dist/27.js +1 -8
  42. package/dist/27.js.map +1 -1
  43. package/dist/28.js +1 -9
  44. package/dist/28.js.map +1 -1
  45. package/dist/29.js +13 -96
  46. package/dist/29.js.map +1 -1
  47. package/dist/3.js +235 -859
  48. package/dist/3.js.map +1 -1
  49. package/dist/30.js.map +1 -1
  50. package/dist/4.js +45 -214
  51. package/dist/4.js.map +1 -1
  52. package/dist/5.js +39 -169
  53. package/dist/5.js.map +1 -1
  54. package/dist/6.js +45 -187
  55. package/dist/6.js.map +1 -1
  56. package/dist/7.js +38 -164
  57. package/dist/7.js.map +1 -1
  58. package/dist/8.js +45 -187
  59. package/dist/8.js.map +1 -1
  60. package/dist/9.js +34 -189
  61. package/dist/9.js.map +1 -1
  62. package/dist/@aws-amplify/ui-react.js +293 -1150
  63. package/dist/@aws-amplify/ui-react.js.map +1 -1
  64. package/dist/aws-amplify-react.min.js.map +1 -1
  65. package/dist/polyfills-core-js.js +1774 -2129
  66. package/dist/polyfills-core-js.js.map +1 -1
  67. package/dist/polyfills-css-shim.js +47 -113
  68. package/dist/polyfills-css-shim.js.map +1 -1
  69. package/dist/polyfills-dom.js +122 -391
  70. package/dist/polyfills-dom.js.map +1 -1
  71. package/package.json +3 -3
  72. package/lib/components.d.ts +0 -56
  73. package/lib/index.d.ts +0 -2
  74. package/lib/react-component-lib/createComponent.d.ts +0 -2
  75. package/lib/react-component-lib/createControllerComponent.d.ts +0 -43
  76. package/lib/react-component-lib/createOverlayComponent.d.ts +0 -45
  77. package/lib/react-component-lib/index.d.ts +0 -3
  78. package/lib/react-component-lib/utils/attachEventProps.d.ts +0 -8
  79. package/lib/react-component-lib/utils/index.d.ts +0 -8
  80. package/lib/withAuthenticator.d.ts +0 -3
package/dist/13.js CHANGED
@@ -25,7 +25,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
25
25
  resolve(value);
26
26
  });
27
27
  }
28
-
29
28
  return new (P || (P = Promise))(function (resolve, reject) {
30
29
  function fulfilled(value) {
31
30
  try {
@@ -34,7 +33,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
34
33
  reject(e);
35
34
  }
36
35
  }
37
-
38
36
  function rejected(value) {
39
37
  try {
40
38
  step(generator["throw"](value));
@@ -42,29 +40,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
42
40
  reject(e);
43
41
  }
44
42
  }
45
-
46
43
  function step(result) {
47
44
  result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
48
45
  }
49
-
50
46
  step((generator = generator.apply(thisArg, _arguments || [])).next());
51
47
  });
52
48
  };
53
-
54
49
  var __generator = undefined && undefined.__generator || function (thisArg, body) {
55
50
  var _ = {
56
- label: 0,
57
- sent: function sent() {
58
- if (t[0] & 1) throw t[1];
59
- return t[1];
51
+ label: 0,
52
+ sent: function sent() {
53
+ if (t[0] & 1) throw t[1];
54
+ return t[1];
55
+ },
56
+ trys: [],
57
+ ops: []
60
58
  },
61
- trys: [],
62
- ops: []
63
- },
64
- f,
65
- y,
66
- t,
67
- g;
59
+ f,
60
+ y,
61
+ t,
62
+ g;
68
63
  return g = {
69
64
  next: verb(0),
70
65
  "throw": verb(1),
@@ -72,79 +67,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
72
67
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
73
68
  return this;
74
69
  }), g;
75
-
76
70
  function verb(n) {
77
71
  return function (v) {
78
72
  return step([n, v]);
79
73
  };
80
74
  }
81
-
82
75
  function step(op) {
83
76
  if (f) throw new TypeError("Generator is already executing.");
84
-
85
77
  while (_) {
86
78
  try {
87
79
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
88
80
  if (y = 0, t) op = [op[0] & 2, t.value];
89
-
90
81
  switch (op[0]) {
91
82
  case 0:
92
83
  case 1:
93
84
  t = op;
94
85
  break;
95
-
96
86
  case 4:
97
87
  _.label++;
98
88
  return {
99
89
  value: op[1],
100
90
  done: false
101
91
  };
102
-
103
92
  case 5:
104
93
  _.label++;
105
94
  y = op[1];
106
95
  op = [0];
107
96
  continue;
108
-
109
97
  case 7:
110
98
  op = _.ops.pop();
111
-
112
99
  _.trys.pop();
113
-
114
100
  continue;
115
-
116
101
  default:
117
102
  if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
118
103
  _ = 0;
119
104
  continue;
120
105
  }
121
-
122
106
  if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
123
107
  _.label = op[1];
124
108
  break;
125
109
  }
126
-
127
110
  if (op[0] === 6 && _.label < t[1]) {
128
111
  _.label = t[1];
129
112
  t = op;
130
113
  break;
131
114
  }
132
-
133
115
  if (t && _.label < t[2]) {
134
116
  _.label = t[2];
135
-
136
117
  _.ops.push(op);
137
-
138
118
  break;
139
119
  }
140
-
141
120
  if (t[2]) _.ops.pop();
142
-
143
121
  _.trys.pop();
144
-
145
122
  continue;
146
123
  }
147
-
148
124
  op = body.call(thisArg, _);
149
125
  } catch (e) {
150
126
  op = [6, e];
@@ -153,7 +129,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
153
129
  f = t = 0;
154
130
  }
155
131
  }
156
-
157
132
  if (op[0] & 5) throw op[1];
158
133
  return {
159
134
  value: op[0] ? op[1] : void 0,
@@ -161,18 +136,15 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
161
136
  };
162
137
  }
163
138
  };
164
-
165
139
  var __spreadArrays = undefined && undefined.__spreadArrays || function () {
166
140
  for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
167
141
  s += arguments[i].length;
168
142
  }
169
-
170
143
  for (var r = Array(s), k = 0, i = 0; i < il; i++) {
171
144
  for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
172
145
  r[k] = a[j];
173
146
  }
174
147
  }
175
-
176
148
  return r;
177
149
  };
178
150
 
@@ -181,74 +153,56 @@ var __spreadArrays = undefined && undefined.__spreadArrays || function () {
181
153
 
182
154
 
183
155
 
184
- // AudioRecorder settings
185
-
156
+ // AudioRecorder settings
186
157
  var RECORDER_EXPORT_MIME_TYPE = 'application/octet-stream';
187
158
  var DEFAULT_EXPORT_SAMPLE_RATE = 16000;
188
159
  var FFT_SIZE = 2048; // window size in samples for Fast Fourier Transform (FFT)
189
-
190
160
  var FFT_MAX_DECIBELS = -10; // maximum power value in the scaling range for the FFT analysis data
191
-
192
161
  var FFT_MIN_DECIBELS = -90; // minimum power value in the scaling range for the FFT analysis data
193
-
194
162
  var FFT_SMOOTHING_TIME_CONSTANT = 0.85; // averaging constant with the last analysis frame
195
-
196
163
  /**
197
164
  * Merges multiple buffers into one.
198
165
  */
199
-
200
166
  var mergeBuffers = function mergeBuffers(bufferArray, recLength) {
201
167
  var result = new Float32Array(recLength);
202
168
  var offset = 0;
203
-
204
169
  for (var i = 0; i < bufferArray.length; i++) {
205
170
  result.set(bufferArray[i], offset);
206
171
  offset += bufferArray[i].length;
207
172
  }
208
-
209
173
  return result;
210
174
  };
211
175
  /**
212
176
  * Downsamples audio to desired export sample rate.
213
177
  */
214
-
215
-
216
178
  var downsampleBuffer = function downsampleBuffer(buffer, recordSampleRate, exportSampleRate) {
217
179
  if (exportSampleRate === recordSampleRate) {
218
180
  return buffer;
219
181
  }
220
-
221
182
  var sampleRateRatio = recordSampleRate / exportSampleRate;
222
183
  var newLength = Math.round(buffer.length / sampleRateRatio);
223
184
  var result = new Float32Array(newLength);
224
185
  var offsetResult = 0;
225
186
  var offsetBuffer = 0;
226
-
227
187
  while (offsetResult < result.length) {
228
188
  var nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);
229
189
  var accum = 0,
230
- count = 0;
231
-
190
+ count = 0;
232
191
  for (var i = offsetBuffer; i < nextOffsetBuffer && i < buffer.length; i++) {
233
192
  accum += buffer[i];
234
193
  count++;
235
194
  }
236
-
237
195
  result[offsetResult] = accum / count;
238
196
  offsetResult++;
239
197
  offsetBuffer = nextOffsetBuffer;
240
198
  }
241
-
242
199
  return result;
243
200
  };
244
201
  /**
245
202
  * converts raw audio values to 16 bit pcm.
246
203
  */
247
-
248
-
249
204
  var floatTo16BitPCM = function floatTo16BitPCM(output, offset, input) {
250
205
  var byteOffset = offset;
251
-
252
206
  for (var i = 0; i < input.length; i++, byteOffset += 2) {
253
207
  var s = Math.max(-1, Math.min(1, input[i]));
254
208
  output.setInt16(byteOffset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
@@ -257,8 +211,6 @@ var floatTo16BitPCM = function floatTo16BitPCM(output, offset, input) {
257
211
  /**
258
212
  * Write given strings in big-endian order.
259
213
  */
260
-
261
-
262
214
  var writeString = function writeString(view, offset, string) {
263
215
  for (var i = 0; i < string.length; i++) {
264
216
  view.setUint8(offset + i, string.charCodeAt(i));
@@ -267,59 +219,37 @@ var writeString = function writeString(view, offset, string) {
267
219
  /**
268
220
  * Encodes raw pcm audio into a wav file.
269
221
  */
270
-
271
-
272
222
  var encodeWAV = function encodeWAV(samples, exportSampleRate) {
273
223
  /**
274
224
  * WAV file consists of three parts: RIFF header, WAVE subchunk, and data subchunk. We precompute the size of them.
275
225
  */
276
226
  var audioSize = samples.length * 2; // We use 16-bit samples, so we have (2 * sampleLength) bytes.
277
-
278
227
  var fmtSize = 24; // Byte size of the fmt subchunk: 24 bytes that the audio information that we'll set below.
279
-
280
228
  var dataSize = 8 + audioSize; // Byte size of the data subchunk: raw sound data plus 8 bytes for the subchunk descriptions.
281
-
282
229
  var totalByteSize = 12 + fmtSize + dataSize; // Byte size of the whole file, including the chunk header / descriptor.
283
230
  // create DataView object to write byte values into
284
-
285
231
  var buffer = new ArrayBuffer(totalByteSize); // buffer to write the chunk values in.
286
-
287
232
  var view = new DataView(buffer);
288
233
  /**
289
234
  * Start writing the .wav file. We write top to bottom, so byte offset (first numeric argument) increases strictly.
290
235
  */
291
236
  // RIFF header
292
-
293
237
  writeString(view, 0, 'RIFF'); // At offset 0, write the letters "RIFF"
294
-
295
238
  view.setUint32(4, fmtSize + dataSize, true); // At offset 4, write the size of fmt and data chunk size combined.
296
-
297
239
  writeString(view, 8, 'WAVE'); // At offset 8, write the format type "WAVE"
298
240
  // fmt subchunk
299
-
300
241
  writeString(view, 12, 'fmt '); //chunkdId 'fmt '
301
-
302
242
  view.setUint32(16, fmtSize - 8, true); // fmt subchunk size below this value. We set 8 bytes already, so subtract 8 bytes from fmtSize.
303
-
304
243
  view.setUint16(20, 1, true); // Audio format code, which is 1 for PCM.
305
-
306
244
  view.setUint16(22, 1, true); // Number of audio channels. We use mono, ie 1.
307
-
308
245
  view.setUint32(24, exportSampleRate, true); // Sample rate of the audio file.
309
-
310
246
  view.setUint32(28, exportSampleRate * 2, true); // Data rate, or # of data bytes per second. Since each sample is 2 bytes, this is 2 * sampleRate.
311
-
312
247
  view.setUint16(32, 2, true); // block align, # of bytes per sample including all channels, ie. 2 bytes.
313
-
314
248
  view.setUint16(34, 16, true); // bits per sample, ie. 16 bits
315
249
  // data subchunk
316
-
317
250
  writeString(view, 36, 'data'); // write the chunkId 'data'
318
-
319
251
  view.setUint32(40, audioSize, true); // Audio byte size
320
-
321
252
  floatTo16BitPCM(view, 44, samples); // raw pcm values then go here.
322
-
323
253
  return view;
324
254
  };
325
255
  /**
@@ -330,8 +260,6 @@ var encodeWAV = function encodeWAV(samples, exportSampleRate) {
330
260
  * @param recordSampleRate {number} - sample rate of the recorded audio
331
261
  * @param exportSampleRate {number} - desired sample rate of the exported file
332
262
  */
333
-
334
-
335
263
  var exportBuffer = function exportBuffer(recBuffer, recLength, recordSampleRate, exportSampleRate) {
336
264
  var mergedBuffers = mergeBuffers(recBuffer, recLength);
337
265
  var downsampledBuffer = downsampleBuffer(mergedBuffers, recordSampleRate, exportSampleRate);
@@ -341,12 +269,8 @@ var exportBuffer = function exportBuffer(recBuffer, recLength, recordSampleRate,
341
269
  });
342
270
  return audioBlob;
343
271
  };
344
-
345
272
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Logger"]('AudioRecorder');
346
-
347
- var AudioRecorder =
348
- /** @class */
349
- function () {
273
+ var AudioRecorder = /** @class */function () {
350
274
  function AudioRecorder(options) {
351
275
  // input mic stream is stored in a buffer
352
276
  this.streamBuffer = [];
@@ -358,50 +282,32 @@ function () {
358
282
  * This must be called first to enable audio context and request microphone access.
359
283
  * Once access granted, it connects all the necessary audio nodes to the context so that it can begin recording or playing.
360
284
  */
361
-
362
-
363
285
  AudioRecorder.prototype.init = function () {
364
286
  return __awaiter(this, void 0, void 0, function () {
365
287
  var _this = this;
366
-
367
288
  return __generator(this, function (_a) {
368
289
  switch (_a.label) {
369
290
  case 0:
370
- if (!Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["browserOrNode"])().isBrowser) return [3
371
- /*break*/
372
- , 2];
291
+ if (!Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["browserOrNode"])().isBrowser) return [3 /*break*/, 2];
373
292
  window.AudioContext = window.AudioContext || window.webkitAudioContext;
374
293
  this.audioContext = new AudioContext();
375
- return [4
376
- /*yield*/
377
- , navigator.mediaDevices.getUserMedia({
294
+ return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
378
295
  audio: true
379
296
  }).then(function (stream) {
380
297
  _this.audioSupported = true;
381
-
382
298
  _this.setupAudioNodes(stream);
383
299
  })["catch"](function () {
384
300
  _this.audioSupported = false;
385
301
  return Promise.reject('Audio is not supported');
386
302
  })];
387
-
388
303
  case 1:
389
304
  _a.sent();
390
-
391
- return [3
392
- /*break*/
393
- , 3];
394
-
305
+ return [3 /*break*/, 3];
395
306
  case 2:
396
307
  this.audioSupported = false;
397
- return [2
398
- /*return*/
399
- , Promise.reject('Audio is not supported')];
400
-
308
+ return [2 /*return*/, Promise.reject('Audio is not supported')];
401
309
  case 3:
402
- return [2
403
- /*return*/
404
- ];
310
+ return [2 /*return*/];
405
311
  }
406
312
  });
407
313
  });
@@ -409,53 +315,32 @@ function () {
409
315
  /**
410
316
  * Setup audio nodes after successful `init`.
411
317
  */
412
-
413
-
414
318
  AudioRecorder.prototype.setupAudioNodes = function (stream) {
415
319
  return __awaiter(this, void 0, void 0, function () {
416
320
  var err_1, sourceNode, processorNode, analyserNode;
417
-
418
321
  var _this = this;
419
-
420
322
  return __generator(this, function (_a) {
421
323
  switch (_a.label) {
422
324
  case 0:
423
325
  _a.trys.push([0, 2,, 3]);
424
-
425
- return [4
426
- /*yield*/
427
- , this.audioContext.resume()];
428
-
326
+ return [4 /*yield*/, this.audioContext.resume()];
429
327
  case 1:
430
328
  _a.sent();
431
-
432
- return [3
433
- /*break*/
434
- , 3];
435
-
329
+ return [3 /*break*/, 3];
436
330
  case 2:
437
331
  err_1 = _a.sent();
438
332
  logger.error(err_1);
439
- return [3
440
- /*break*/
441
- , 3];
442
-
333
+ return [3 /*break*/, 3];
443
334
  case 3:
444
335
  sourceNode = this.audioContext.createMediaStreamSource(stream);
445
336
  processorNode = this.audioContext.createScriptProcessor(4096, 1, 1);
446
-
447
337
  processorNode.onaudioprocess = function (audioProcessingEvent) {
448
338
  if (!_this.recording) return;
449
339
  var stream = audioProcessingEvent.inputBuffer.getChannelData(0);
450
-
451
340
  _this.streamBuffer.push(new Float32Array(stream)); // set to a copy of the stream
452
-
453
-
454
341
  _this.streamBufferLength += stream.length;
455
-
456
342
  _this.analyse();
457
343
  };
458
-
459
344
  analyserNode = this.audioContext.createAnalyser();
460
345
  analyserNode.minDecibels = FFT_MIN_DECIBELS;
461
346
  analyserNode.maxDecibels = FFT_MAX_DECIBELS;
@@ -464,9 +349,7 @@ function () {
464
349
  analyserNode.connect(processorNode);
465
350
  processorNode.connect(sourceNode.context.destination);
466
351
  this.analyserNode = analyserNode;
467
- return [2
468
- /*return*/
469
- ];
352
+ return [2 /*return*/];
470
353
  }
471
354
  });
472
355
  });
@@ -477,52 +360,31 @@ function () {
477
360
  * @param onSilence {SilenceHandler} - called whenever silence is detected
478
361
  * @param visualizer {Visualizer} - called with audio data on each audio process to be used for visualization.
479
362
  */
480
-
481
-
482
363
  AudioRecorder.prototype.startRecording = function (onSilence, visualizer) {
483
364
  return __awaiter(this, void 0, void 0, function () {
484
365
  var context, err_2;
485
366
  return __generator(this, function (_a) {
486
367
  switch (_a.label) {
487
368
  case 0:
488
- if (this.recording || !this.audioSupported) return [2
489
- /*return*/
490
- ];
491
-
369
+ if (this.recording || !this.audioSupported) return [2 /*return*/];
492
370
  this.onSilence = onSilence || function () {};
493
-
494
371
  this.visualizer = visualizer || function () {};
495
-
496
372
  context = this.audioContext;
497
373
  _a.label = 1;
498
-
499
374
  case 1:
500
375
  _a.trys.push([1, 3,, 4]);
501
-
502
- return [4
503
- /*yield*/
504
- , context.resume()];
505
-
376
+ return [4 /*yield*/, context.resume()];
506
377
  case 2:
507
378
  _a.sent();
508
-
509
- return [3
510
- /*break*/
511
- , 4];
512
-
379
+ return [3 /*break*/, 4];
513
380
  case 3:
514
381
  err_2 = _a.sent();
515
382
  logger.error(err_2);
516
- return [3
517
- /*break*/
518
- , 4];
519
-
383
+ return [3 /*break*/, 4];
520
384
  case 4:
521
385
  this.start = Date.now();
522
386
  this.recording = true;
523
- return [2
524
- /*return*/
525
- ];
387
+ return [2 /*return*/];
526
388
  }
527
389
  });
528
390
  });
@@ -530,8 +392,6 @@ function () {
530
392
  /**
531
393
  * Pause recording
532
394
  */
533
-
534
-
535
395
  AudioRecorder.prototype.stopRecording = function () {
536
396
  if (!this.audioSupported) return;
537
397
  this.recording = false;
@@ -539,8 +399,6 @@ function () {
539
399
  /**
540
400
  * Pause recording and clear audio buffer
541
401
  */
542
-
543
-
544
402
  AudioRecorder.prototype.clear = function () {
545
403
  this.stopRecording();
546
404
  this.streamBufferLength = 0;
@@ -551,52 +409,37 @@ function () {
551
409
  *
552
410
  * @param buffer {Uint8Array} - audioStream to be played
553
411
  */
554
-
555
-
556
412
  AudioRecorder.prototype.play = function (buffer) {
557
413
  var _this = this;
558
-
559
414
  if (!buffer || !this.audioSupported) return;
560
415
  var myBlob = new Blob([buffer]);
561
416
  return new Promise(function (res, rej) {
562
417
  var fileReader = new FileReader();
563
-
564
418
  fileReader.onload = function () {
565
419
  if (_this.playbackSource) _this.playbackSource.disconnect(); // disconnect previous playback source
566
-
567
420
  _this.playbackSource = _this.audioContext.createBufferSource();
568
-
569
421
  var successCallback = function successCallback(buf) {
570
422
  _this.playbackSource.buffer = buf;
571
-
572
423
  _this.playbackSource.connect(_this.audioContext.destination);
573
-
574
424
  _this.playbackSource.onended = function () {
575
425
  return res();
576
426
  };
577
-
578
427
  _this.playbackSource.start(0);
579
428
  };
580
-
581
429
  var errorCallback = function errorCallback(err) {
582
430
  return rej(err);
583
431
  };
584
-
585
432
  _this.audioContext.decodeAudioData(fileReader.result, successCallback, errorCallback);
586
433
  };
587
-
588
434
  fileReader.onerror = function () {
589
435
  return rej();
590
436
  };
591
-
592
437
  fileReader.readAsArrayBuffer(myBlob);
593
438
  });
594
439
  };
595
440
  /**
596
441
  * Stops playing audio if there's a playback source connected.
597
442
  */
598
-
599
-
600
443
  AudioRecorder.prototype.stop = function () {
601
444
  if (this.playbackSource) {
602
445
  this.playbackSource.stop();
@@ -605,8 +448,6 @@ function () {
605
448
  /**
606
449
  * Called after each audioProcess. Check for silence and give fft time domain data to visualizer.
607
450
  */
608
-
609
-
610
451
  AudioRecorder.prototype.analyse = function () {
611
452
  if (!this.audioSupported) return;
612
453
  var analyser = this.analyserNode;
@@ -617,19 +458,15 @@ function () {
617
458
  var time = this.options.time;
618
459
  analyser.getByteTimeDomainData(dataArray);
619
460
  this.visualizer(dataArray, bufferLength);
620
-
621
461
  for (var i = 0; i < bufferLength; i++) {
622
462
  // Normalize between -1 and 1.
623
463
  var curr_value_time = dataArray[i] / 128 - 1.0;
624
-
625
464
  if (curr_value_time > amplitude || curr_value_time < -1 * amplitude) {
626
465
  this.start = Date.now();
627
466
  }
628
467
  }
629
-
630
468
  var newtime = Date.now();
631
469
  var elapsedTime = newtime - this.start;
632
-
633
470
  if (elapsedTime > time) {
634
471
  this.onSilence();
635
472
  }
@@ -639,154 +476,114 @@ function () {
639
476
  *
640
477
  * @param exportSampleRate {number} - desired sample rate of the exported buffer
641
478
  */
642
-
643
-
644
479
  AudioRecorder.prototype.exportWAV = function (exportSampleRate) {
645
480
  if (exportSampleRate === void 0) {
646
481
  exportSampleRate = DEFAULT_EXPORT_SAMPLE_RATE;
647
482
  }
648
-
649
483
  return __awaiter(this, void 0, void 0, function () {
650
484
  var recordSampleRate, blob;
651
485
  return __generator(this, function (_a) {
652
- if (!this.audioSupported) return [2
653
- /*return*/
654
- ];
486
+ if (!this.audioSupported) return [2 /*return*/];
655
487
  recordSampleRate = this.audioContext.sampleRate;
656
488
  blob = exportBuffer(this.streamBuffer, this.streamBufferLength, recordSampleRate, exportSampleRate);
657
489
  this.clear();
658
- return [2
659
- /*return*/
660
- , blob];
490
+ return [2 /*return*/, blob];
661
491
  });
662
492
  });
663
493
  };
664
-
665
494
  return AudioRecorder;
666
495
  }();
667
-
668
496
  var visualize = function visualize(dataArray, bufferLength, canvas) {
669
497
  if (!canvas) return;
670
498
  if (!Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["browserOrNode"])().isBrowser) throw new Error('Visualization is not supported on non-browsers.');
671
-
672
499
  var _a = canvas.getBoundingClientRect(),
673
- width = _a.width,
674
- height = _a.height; // need to update the default canvas width and height
675
-
676
-
500
+ width = _a.width,
501
+ height = _a.height;
502
+ // need to update the default canvas width and height
677
503
  canvas.width = width;
678
504
  canvas.height = height;
679
505
  var canvasCtx = canvas.getContext('2d');
680
506
  canvasCtx.fillStyle = 'white';
681
507
  canvasCtx.clearRect(0, 0, width, height);
682
-
683
508
  var draw = function draw() {
684
509
  canvasCtx.fillRect(0, 0, width, height);
685
510
  canvasCtx.lineWidth = 1;
686
511
  var color = getComputedStyle(document.documentElement).getPropertyValue('--amplify-primary-color');
687
512
  canvasCtx.strokeStyle = !color || color === '' ? '#ff9900' : color; // TODO: try separate css variable
688
-
689
513
  canvasCtx.beginPath();
690
514
  var sliceWidth = width * 1.0 / bufferLength;
691
515
  var x = 0;
692
-
693
516
  for (var i = 0; i < bufferLength || i % 3 === 0; i++) {
694
517
  var value = dataArray[i] / 128.0;
695
518
  var y = value * height / 2;
696
-
697
519
  if (i === 0) {
698
520
  canvasCtx.moveTo(x, y);
699
521
  } else {
700
522
  canvasCtx.lineTo(x, y);
701
523
  }
702
-
703
524
  x += sliceWidth;
704
525
  }
705
-
706
526
  canvasCtx.lineTo(canvas.width, canvas.height / 2);
707
527
  canvasCtx.stroke();
708
- }; // Register our draw function with requestAnimationFrame.
709
-
710
-
528
+ };
529
+ // Register our draw function with requestAnimationFrame.
711
530
  requestAnimationFrame(draw);
712
531
  };
713
-
714
- var amplifyChatbotCss = ".bot .dot{background-color:var(--bot-dot-color)}.user .dot{background-color:var(--user-dot-color)}.dot-flashing{width:2.625rem}.dot-flashing .dot{display:inline-block;width:0.625rem;height:0.625rem;border-radius:10rem;opacity:0.65}.dot-flashing .left{-webkit-animation:dot-flashing 1s infinite alternate;animation:dot-flashing 1s infinite alternate;-webkit-animation-delay:0s;animation-delay:0s}.dot-flashing .middle{margin-left:0.375rem;margin-right:0.375rem;-webkit-animation:dot-flashing 1s infinite linear alternate;animation:dot-flashing 1s infinite linear alternate;-webkit-animation-delay:0.5s;animation-delay:0.5s}.dot-flashing .right{-webkit-animation:dot-flashing 1s infinite alternate;animation:dot-flashing 1s infinite alternate;-webkit-animation-delay:1s;animation-delay:1s}@-webkit-keyframes dot-flashing{0%{opacity:0.65}50%,100%{opacity:0.1}}@keyframes dot-flashing{0%{opacity:0.65}50%,100%{opacity:0.1}}:host{--width:28.75rem;--height:37.5rem;--header-color:var(--amplify-secondary-color);--header-size:var(--amplify-text-lg);--bot-background-color:rgb(230, 230, 230);--bot-text-color:black;--bot-dot-color:var(--bot-text-color);--user-background-color:var(--amplify-blue);--user-text-color:var(--amplify-white);--user-dot-color:var(--user-text-color)}.amplify-chatbot{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column;background-color:var(--background-color);border-radius:0.375rem;-webkit-box-shadow:0.0625rem 0rem 0.25rem 0 rgba(0, 0, 0, 0.15);box-shadow:0.0625rem 0rem 0.25rem 0 rgba(0, 0, 0, 0.15);-webkit-box-sizing:border-box;box-sizing:border-box;font-family:var(--amplify-font-family);margin-bottom:1rem;width:100%;height:var(--height);max-width:var(--width)}@media (min-width: 672px){.amplify-chatbot{width:var(--width)}}.header{padding:1.25rem 0.375rem 1.25rem 0.375rem;color:var(--header-color);font-size:var(--header-size);font-weight:bold;text-align:center;word-wrap:break-word}.body{border-top:0.0625rem solid rgba(0, 0, 0, 0.05);padding:1.5rem 1rem 0 1rem;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;-ms-flex-direction:column;flex-direction:column;overflow:auto}.bubble{max-width:100%;padding:0.8em 1.4em;text-align:left;word-wrap:break-word;margin-bottom:0.625rem}.bot{margin-right:auto;background-color:var(--bot-background-color);color:var(--bot-text-color);border-radius:1.5rem 1.5rem 1.5rem 0}.user{margin-left:auto;background-color:var(--user-background-color);color:var(--user-text-color);border-radius:1.5rem 1.5rem 0 1.5rem}.footer{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top:0.062rem solid rgba(0, 0, 0, 0.05);padding-right:0.625rem;min-height:3.125rem}.footer amplify-input{--border:none;--margin:0;-ms-flex-positive:1;flex-grow:1}canvas{margin-left:0.625rem;margin-right:0.625rem;-ms-flex-positive:1;flex-grow:1;height:3.125rem}.icon-button{--icon-height:1.25rem;--icon-fill:var(--amplify-primary-color);--padding:0.625rem;--width:auto}"; // enum for possible bot states
715
-
532
+ var amplifyChatbotCss = ".bot .dot{background-color:var(--bot-dot-color)}.user .dot{background-color:var(--user-dot-color)}.dot-flashing{width:2.625rem}.dot-flashing .dot{display:inline-block;width:0.625rem;height:0.625rem;border-radius:10rem;opacity:0.65}.dot-flashing .left{-webkit-animation:dot-flashing 1s infinite alternate;animation:dot-flashing 1s infinite alternate;-webkit-animation-delay:0s;animation-delay:0s}.dot-flashing .middle{margin-left:0.375rem;margin-right:0.375rem;-webkit-animation:dot-flashing 1s infinite linear alternate;animation:dot-flashing 1s infinite linear alternate;-webkit-animation-delay:0.5s;animation-delay:0.5s}.dot-flashing .right{-webkit-animation:dot-flashing 1s infinite alternate;animation:dot-flashing 1s infinite alternate;-webkit-animation-delay:1s;animation-delay:1s}@-webkit-keyframes dot-flashing{0%{opacity:0.65}50%,100%{opacity:0.1}}@keyframes dot-flashing{0%{opacity:0.65}50%,100%{opacity:0.1}}:host{--width:28.75rem;--height:37.5rem;--header-color:var(--amplify-secondary-color);--header-size:var(--amplify-text-lg);--bot-background-color:rgb(230, 230, 230);--bot-text-color:black;--bot-dot-color:var(--bot-text-color);--user-background-color:var(--amplify-blue);--user-text-color:var(--amplify-white);--user-dot-color:var(--user-text-color)}.amplify-chatbot{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column;background-color:var(--background-color);border-radius:0.375rem;-webkit-box-shadow:0.0625rem 0rem 0.25rem 0 rgba(0, 0, 0, 0.15);box-shadow:0.0625rem 0rem 0.25rem 0 rgba(0, 0, 0, 0.15);-webkit-box-sizing:border-box;box-sizing:border-box;font-family:var(--amplify-font-family);margin-bottom:1rem;width:100%;height:var(--height);max-width:var(--width)}@media (min-width: 672px){.amplify-chatbot{width:var(--width)}}.header{padding:1.25rem 0.375rem 1.25rem 0.375rem;color:var(--header-color);font-size:var(--header-size);font-weight:bold;text-align:center;word-wrap:break-word}.body{border-top:0.0625rem solid rgba(0, 0, 0, 0.05);padding:1.5rem 1rem 0 1rem;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;-ms-flex-direction:column;flex-direction:column;overflow:auto}.bubble{max-width:100%;padding:0.8em 1.4em;text-align:left;word-wrap:break-word;margin-bottom:0.625rem}.bot{margin-right:auto;background-color:var(--bot-background-color);color:var(--bot-text-color);border-radius:1.5rem 1.5rem 1.5rem 0}.user{margin-left:auto;background-color:var(--user-background-color);color:var(--user-text-color);border-radius:1.5rem 1.5rem 0 1.5rem}.footer{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top:0.062rem solid rgba(0, 0, 0, 0.05);padding-right:0.625rem;min-height:3.125rem}.footer amplify-input{--border:none;--margin:0;-ms-flex-positive:1;flex-grow:1}canvas{margin-left:0.625rem;margin-right:0.625rem;-ms-flex-positive:1;flex-grow:1;height:3.125rem}.icon-button{--icon-height:1.25rem;--icon-fill:var(--amplify-primary-color);--padding:0.625rem;--width:auto}";
533
+ // enum for possible bot states
716
534
  var ChatState;
717
-
718
535
  (function (ChatState) {
719
536
  ChatState[ChatState["Initial"] = 0] = "Initial";
720
537
  ChatState[ChatState["Listening"] = 1] = "Listening";
721
538
  ChatState[ChatState["SendingText"] = 2] = "SendingText";
722
539
  ChatState[ChatState["SendingVoice"] = 3] = "SendingVoice";
723
540
  ChatState[ChatState["Error"] = 4] = "Error";
724
- })(ChatState || (ChatState = {})); // Message types
725
-
726
-
541
+ })(ChatState || (ChatState = {}));
542
+ // Message types
727
543
  var MessageFrom;
728
-
729
544
  (function (MessageFrom) {
730
545
  MessageFrom["Bot"] = "bot";
731
546
  MessageFrom["User"] = "user";
732
- })(MessageFrom || (MessageFrom = {})); // Error types
733
-
734
-
547
+ })(MessageFrom || (MessageFrom = {}));
548
+ // Error types
735
549
  var ChatErrorType;
736
-
737
550
  (function (ChatErrorType) {
738
551
  ChatErrorType[ChatErrorType["Recoverable"] = 0] = "Recoverable";
739
552
  ChatErrorType[ChatErrorType["Unrecoverable"] = 1] = "Unrecoverable";
740
553
  })(ChatErrorType || (ChatErrorType = {}));
741
-
742
- var AmplifyChatbot =
743
- /** @class */
744
- function () {
554
+ var AmplifyChatbot = /** @class */function () {
745
555
  function class_1(hostRef) {
746
556
  var _this = this;
747
-
748
557
  Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
749
558
  /** Clear messages when conversation finishes */
750
-
751
559
  this.clearOnComplete = false;
752
560
  /** Continue listening to users after they send the message */
753
-
754
561
  this.conversationModeOn = false;
755
562
  /** Text placed in the top header */
756
-
757
563
  this.botTitle = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].CHATBOT_TITLE;
758
564
  /** Whether voice chat is enabled */
759
-
760
565
  this.voiceEnabled = false;
761
566
  /** Whether text chat is enabled */
762
-
763
567
  this.textEnabled = true;
764
568
  /** Amount of silence (in ms) to wait for */
765
-
766
569
  this.silenceTime = 1500;
767
570
  /** Noise threshold between -1 and 1. Anything below is considered a silence. */
768
-
769
571
  this.silenceThreshold = 0.2;
770
572
  /** Messages in current session */
771
-
772
573
  this.messages = [];
773
574
  /** Text input box value */
774
-
775
575
  this.text = '';
776
576
  /** Current app state */
777
-
778
577
  this.chatState = ChatState.Initial;
779
578
  /**
780
579
  * Rendering methods
781
580
  */
782
-
783
581
  this.messageJSX = function (messages) {
784
582
  var messageList = messages.map(function (message) {
785
583
  return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", {
786
584
  "class": "bubble " + message.from
787
585
  }, message.content);
788
586
  });
789
-
790
587
  if (_this.chatState === ChatState.SendingText || _this.chatState === ChatState.SendingVoice) {
791
588
  // if waiting for voice message, show animation on user side because app is waiting for transcript. Else put it on bot side.
792
589
  var client = _this.chatState === ChatState.SendingText ? MessageFrom.Bot : MessageFrom.User;
@@ -802,41 +599,31 @@ function () {
802
599
  "class": "dot right"
803
600
  }))));
804
601
  }
805
-
806
602
  return messageList;
807
603
  };
808
-
809
604
  this.chatCompleted = Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["c"])(this, "chatCompleted", 7);
810
- } // Occurs when user presses enter in input box
811
-
812
-
605
+ }
606
+ // Occurs when user presses enter in input box
813
607
  class_1.prototype.submitHandler = function (_event) {
814
608
  this.sendTextMessage();
815
609
  };
816
610
  /**
817
611
  * Lifecycle functions
818
612
  */
819
-
820
-
821
613
  class_1.prototype.componentWillLoad = function () {
822
614
  console.warn('Version `1.x` of Amplify UI has been deprecated and will be removed in a future major version of `aws-amplify`. Please visit https://ui.docs.amplify.aws/ for the current version of Amplify UI.');
823
-
824
615
  if (!_aws_amplify_interactions__WEBPACK_IMPORTED_MODULE_5__["Interactions"] || typeof _aws_amplify_interactions__WEBPACK_IMPORTED_MODULE_5__["Interactions"].onComplete !== 'function') {
825
616
  throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_4__["c"]);
826
617
  }
827
-
828
618
  this.validateProps();
829
619
  };
830
-
831
620
  class_1.prototype.componentDidRender = function () {
832
621
  // scroll to the bottom if necessary
833
622
  var body = this.element.shadowRoot.querySelector('.body');
834
623
  body.scrollTop = body.scrollHeight;
835
624
  };
836
-
837
625
  class_1.prototype.validateProps = function () {
838
626
  var _this = this;
839
-
840
627
  if (!this.voiceEnabled && !this.textEnabled) {
841
628
  this.setError(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].CHAT_DISABLED_ERROR, ChatErrorType.Unrecoverable);
842
629
  return;
@@ -844,9 +631,8 @@ function () {
844
631
  this.setError(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].NO_BOT_NAME_ERROR, ChatErrorType.Unrecoverable);
845
632
  return;
846
633
  }
847
-
848
- if (this.welcomeMessage) this.appendToChat(this.welcomeMessage, MessageFrom.Bot); // Initialize AudioRecorder if voice is enabled
849
-
634
+ if (this.welcomeMessage) this.appendToChat(this.welcomeMessage, MessageFrom.Bot);
635
+ // Initialize AudioRecorder if voice is enabled
850
636
  if (this.voiceEnabled) {
851
637
  this.audioRecorder = new AudioRecorder({
852
638
  time: this.silenceTime,
@@ -855,22 +641,19 @@ function () {
855
641
  this.audioRecorder.init()["catch"](function (err) {
856
642
  _this.setError(err, ChatErrorType.Recoverable);
857
643
  });
858
- } // Callback function to be called after chat is completed
859
-
860
-
644
+ }
645
+ // Callback function to be called after chat is completed
861
646
  var onComplete = function onComplete(err, data) {
862
647
  _this.chatCompleted.emit({
863
648
  data: data,
864
649
  err: err
865
650
  });
866
-
867
651
  if (_this.clearOnComplete) {
868
652
  _this.reset();
869
653
  } else {
870
654
  _this.chatState = ChatState.Initial;
871
655
  }
872
656
  };
873
-
874
657
  try {
875
658
  _aws_amplify_interactions__WEBPACK_IMPORTED_MODULE_5__["Interactions"].onComplete(this.botName, onComplete);
876
659
  } catch (err) {
@@ -880,16 +663,12 @@ function () {
880
663
  /**
881
664
  * Handlers
882
665
  */
883
-
884
-
885
666
  class_1.prototype.handleSubmit = function (event) {
886
667
  event.preventDefault();
887
668
  this.sendTextMessage();
888
669
  };
889
-
890
670
  class_1.prototype.handleMicButton = function () {
891
671
  var _this = this;
892
-
893
672
  if (this.chatState !== ChatState.Initial) return;
894
673
  this.audioRecorder.stop();
895
674
  this.chatState = ChatState.Listening;
@@ -899,31 +678,25 @@ function () {
899
678
  return _this.visualizer(data, length);
900
679
  });
901
680
  };
902
-
903
681
  class_1.prototype.handleSilence = function () {
904
682
  var _this = this;
905
-
906
683
  this.chatState = ChatState.SendingVoice;
907
684
  this.audioRecorder.stopRecording();
908
685
  this.audioRecorder.exportWAV().then(function (blob) {
909
686
  _this.sendVoiceMessage(blob);
910
687
  });
911
688
  };
912
-
913
689
  class_1.prototype.handleTextChange = function (event) {
914
690
  var target = event.target;
915
691
  this.text = target.value;
916
692
  };
917
-
918
693
  class_1.prototype.handleCancelButton = function () {
919
694
  this.audioRecorder.clear();
920
695
  this.chatState = ChatState.Initial;
921
696
  };
922
-
923
697
  class_1.prototype.handleToastClose = function (errorType) {
924
698
  this.error = undefined; // clear error
925
699
  // if error is recoverable, reset the app state to initial
926
-
927
700
  if (errorType === ChatErrorType.Recoverable) {
928
701
  this.chatState = ChatState.Initial;
929
702
  }
@@ -931,8 +704,6 @@ function () {
931
704
  /**
932
705
  * Visualization
933
706
  */
934
-
935
-
936
707
  class_1.prototype.visualizer = function (dataArray, bufferLength) {
937
708
  var canvas = this.element.shadowRoot.querySelector('canvas');
938
709
  visualize(dataArray, bufferLength, canvas);
@@ -940,52 +711,34 @@ function () {
940
711
  /**
941
712
  * Interactions helpers
942
713
  */
943
-
944
-
945
714
  class_1.prototype.sendTextMessage = function () {
946
715
  return __awaiter(this, void 0, void 0, function () {
947
716
  var text, response, err_3;
948
717
  return __generator(this, function (_a) {
949
718
  switch (_a.label) {
950
719
  case 0:
951
- if (this.text.length === 0 || this.chatState !== ChatState.Initial) return [2
952
- /*return*/
953
- ];
720
+ if (this.text.length === 0 || this.chatState !== ChatState.Initial) return [2 /*return*/];
954
721
  text = this.text;
955
722
  this.text = '';
956
723
  this.appendToChat(text, MessageFrom.User);
957
724
  this.chatState = ChatState.SendingText;
958
725
  _a.label = 1;
959
-
960
726
  case 1:
961
727
  _a.trys.push([1, 3,, 4]);
962
-
963
- return [4
964
- /*yield*/
965
- , _aws_amplify_interactions__WEBPACK_IMPORTED_MODULE_5__["Interactions"].send(this.botName, text)];
966
-
728
+ return [4 /*yield*/, _aws_amplify_interactions__WEBPACK_IMPORTED_MODULE_5__["Interactions"].send(this.botName, text)];
967
729
  case 2:
968
730
  response = _a.sent();
969
- return [3
970
- /*break*/
971
- , 4];
972
-
731
+ return [3 /*break*/, 4];
973
732
  case 3:
974
733
  err_3 = _a.sent();
975
734
  this.setError(err_3, ChatErrorType.Recoverable);
976
- return [2
977
- /*return*/
978
- ];
979
-
735
+ return [2 /*return*/];
980
736
  case 4:
981
737
  if (response.message) {
982
738
  this.appendToChat(response.message, MessageFrom.Bot);
983
739
  }
984
-
985
740
  this.chatState = ChatState.Initial;
986
- return [2
987
- /*return*/
988
- ];
741
+ return [2 /*return*/];
989
742
  }
990
743
  });
991
744
  });
@@ -994,9 +747,7 @@ function () {
994
747
  class_1.prototype.sendVoiceMessage = function (audioInput) {
995
748
  return __awaiter(this, void 0, void 0, function () {
996
749
  var interactionsMessage, response, err_4, dialogState;
997
-
998
750
  var _this = this;
999
-
1000
751
  return __generator(this, function (_a) {
1001
752
  switch (_a.label) {
1002
753
  case 0:
@@ -1007,35 +758,22 @@ function () {
1007
758
  }
1008
759
  };
1009
760
  _a.label = 1;
1010
-
1011
761
  case 1:
1012
762
  _a.trys.push([1, 3,, 4]);
1013
-
1014
- return [4
1015
- /*yield*/
1016
- , _aws_amplify_interactions__WEBPACK_IMPORTED_MODULE_5__["Interactions"].send(this.botName, interactionsMessage)];
1017
-
763
+ return [4 /*yield*/, _aws_amplify_interactions__WEBPACK_IMPORTED_MODULE_5__["Interactions"].send(this.botName, interactionsMessage)];
1018
764
  case 2:
1019
765
  response = _a.sent();
1020
- return [3
1021
- /*break*/
1022
- , 4];
1023
-
766
+ return [3 /*break*/, 4];
1024
767
  case 3:
1025
768
  err_4 = _a.sent();
1026
769
  this.setError(err_4, ChatErrorType.Recoverable);
1027
- return [2
1028
- /*return*/
1029
- ];
1030
-
770
+ return [2 /*return*/];
1031
771
  case 4:
1032
772
  this.chatState = ChatState.Initial;
1033
773
  dialogState = response.dialogState;
1034
774
  if (response.inputTranscript) this.appendToChat(response.inputTranscript, MessageFrom.User);
1035
775
  this.appendToChat(response.message, MessageFrom.Bot);
1036
- return [4
1037
- /*yield*/
1038
- , this.audioRecorder.play(response.audioStream).then(function () {
776
+ return [4 /*yield*/, this.audioRecorder.play(response.audioStream).then(function () {
1039
777
  // if conversationMode is on, chat is incomplete, and mic button isn't pressed yet, resume listening.
1040
778
  if (_this.conversationModeOn && dialogState !== 'Fulfilled' && dialogState !== 'Failed' && _this.chatState === ChatState.Initial) {
1041
779
  _this.handleMicButton();
@@ -1043,13 +781,9 @@ function () {
1043
781
  })["catch"](function (err) {
1044
782
  return _this.setError(err, ChatErrorType.Recoverable);
1045
783
  })];
1046
-
1047
784
  case 5:
1048
785
  _a.sent();
1049
-
1050
- return [2
1051
- /*return*/
1052
- ];
786
+ return [2 /*return*/];
1053
787
  }
1054
788
  });
1055
789
  });
@@ -1064,8 +798,6 @@ function () {
1064
798
  /**
1065
799
  * State control methods
1066
800
  */
1067
-
1068
-
1069
801
  class_1.prototype.setError = function (error, errorType) {
1070
802
  var message = typeof error === 'string' ? error : error.message;
1071
803
  this.chatState = ChatState.Error;
@@ -1074,7 +806,6 @@ function () {
1074
806
  errorType: errorType
1075
807
  };
1076
808
  };
1077
-
1078
809
  class_1.prototype.reset = function () {
1079
810
  this.chatState = ChatState.Initial;
1080
811
  this.text = '';
@@ -1083,10 +814,8 @@ function () {
1083
814
  if (this.welcomeMessage) this.appendToChat(this.welcomeMessage, MessageFrom.Bot);
1084
815
  this.audioRecorder && this.audioRecorder.clear();
1085
816
  };
1086
-
1087
817
  class_1.prototype.listeningFooterJSX = function () {
1088
818
  var _this = this;
1089
-
1090
819
  var visualization = Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("canvas", {
1091
820
  height: "50"
1092
821
  });
@@ -1101,10 +830,8 @@ function () {
1101
830
  });
1102
831
  return [visualization, cancelButton];
1103
832
  };
1104
-
1105
833
  class_1.prototype.footerJSX = function () {
1106
834
  var _this = this;
1107
-
1108
835
  if (this.chatState === ChatState.Listening) return this.listeningFooterJSX();
1109
836
  var inputPlaceholder = this.textEnabled ? _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].TEXT_INPUT_PLACEHOLDER : _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].VOICE_INPUT_PLACEHOLDER;
1110
837
  var textInput = Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-input", {
@@ -1138,14 +865,12 @@ function () {
1138
865
  });
1139
866
  return [textInput, micButton, sendButton];
1140
867
  };
1141
-
1142
868
  class_1.prototype.errorToast = function () {
1143
869
  var _this = this;
1144
-
1145
870
  if (!this.error) return;
1146
871
  var _a = this.error,
1147
- message = _a.message,
1148
- errorType = _a.errorType;
872
+ message = _a.message,
873
+ errorType = _a.errorType;
1149
874
  return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-toast", {
1150
875
  message: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(message),
1151
876
  handleClose: function handleClose() {
@@ -1153,10 +878,8 @@ function () {
1153
878
  }
1154
879
  });
1155
880
  };
1156
-
1157
881
  class_1.prototype.render = function () {
1158
882
  var _this = this;
1159
-
1160
883
  return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["H"], null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", {
1161
884
  "class": "amplify-chatbot"
1162
885
  }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
@@ -1176,7 +899,6 @@ function () {
1176
899
  "data-test": "chatbot-footer"
1177
900
  }, this.footerJSX())), this.errorToast()));
1178
901
  };
1179
-
1180
902
  Object.defineProperty(class_1.prototype, "element", {
1181
903
  get: function get() {
1182
904
  return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["g"])(this);
@@ -1186,7 +908,6 @@ function () {
1186
908
  });
1187
909
  return class_1;
1188
910
  }();
1189
-
1190
911
  AmplifyChatbot.style = amplifyChatbotCss;
1191
912
 
1192
913