UNPKG

522 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory(require("@aws-amplify/analytics"), require("@aws-amplify/api"), require("@aws-amplify/auth"), require("@aws-amplify/core"), require("@aws-amplify/interactions"), require("@aws-amplify/storage"), require("@aws-amplify/ui"), require("@aws-amplify/xr"), require("react"));
4 else if(typeof define === 'function' && define.amd)
5 define("aws_amplify_react", ["@aws-amplify/analytics", "@aws-amplify/api", "@aws-amplify/auth", "@aws-amplify/core", "@aws-amplify/interactions", "@aws-amplify/storage", "@aws-amplify/ui", "@aws-amplify/xr", "react"], factory);
6 else if(typeof exports === 'object')
7 exports["aws_amplify_react"] = factory(require("@aws-amplify/analytics"), require("@aws-amplify/api"), require("@aws-amplify/auth"), require("@aws-amplify/core"), require("@aws-amplify/interactions"), require("@aws-amplify/storage"), require("@aws-amplify/ui"), require("@aws-amplify/xr"), require("react"));
8 else
9 root["aws_amplify_react"] = factory(root["@aws-amplify/analytics"], root["@aws-amplify/api"], root["@aws-amplify/auth"], root["@aws-amplify/core"], root["@aws-amplify/interactions"], root["@aws-amplify/storage"], root["@aws-amplify/ui"], root["@aws-amplify/xr"], root["react"]);
10})(this, function(__WEBPACK_EXTERNAL_MODULE__aws_amplify_analytics__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_api__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_auth__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_core__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_interactions__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_storage__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_ui__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_xr__, __WEBPACK_EXTERNAL_MODULE_react__) {
11return /******/ (function(modules) { // webpackBootstrap
12/******/ // The module cache
13/******/ var installedModules = {};
14/******/
15/******/ // The require function
16/******/ function __webpack_require__(moduleId) {
17/******/
18/******/ // Check if module is in cache
19/******/ if(installedModules[moduleId]) {
20/******/ return installedModules[moduleId].exports;
21/******/ }
22/******/ // Create a new module (and put it into the cache)
23/******/ var module = installedModules[moduleId] = {
24/******/ i: moduleId,
25/******/ l: false,
26/******/ exports: {}
27/******/ };
28/******/
29/******/ // Execute the module function
30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31/******/
32/******/ // Flag the module as loaded
33/******/ module.l = true;
34/******/
35/******/ // Return the exports of the module
36/******/ return module.exports;
37/******/ }
38/******/
39/******/
40/******/ // expose the modules object (__webpack_modules__)
41/******/ __webpack_require__.m = modules;
42/******/
43/******/ // expose the module cache
44/******/ __webpack_require__.c = installedModules;
45/******/
46/******/ // define getter function for harmony exports
47/******/ __webpack_require__.d = function(exports, name, getter) {
48/******/ if(!__webpack_require__.o(exports, name)) {
49/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50/******/ }
51/******/ };
52/******/
53/******/ // define __esModule on exports
54/******/ __webpack_require__.r = function(exports) {
55/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57/******/ }
58/******/ Object.defineProperty(exports, '__esModule', { value: true });
59/******/ };
60/******/
61/******/ // create a fake namespace object
62/******/ // mode & 1: value is a module id, require it
63/******/ // mode & 2: merge all properties of value into the ns
64/******/ // mode & 4: return value when already ns object
65/******/ // mode & 8|1: behave like require
66/******/ __webpack_require__.t = function(value, mode) {
67/******/ if(mode & 1) value = __webpack_require__(value);
68/******/ if(mode & 8) return value;
69/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70/******/ var ns = Object.create(null);
71/******/ __webpack_require__.r(ns);
72/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74/******/ return ns;
75/******/ };
76/******/
77/******/ // getDefaultExport function for compatibility with non-harmony modules
78/******/ __webpack_require__.n = function(module) {
79/******/ var getter = module && module.__esModule ?
80/******/ function getDefault() { return module['default']; } :
81/******/ function getModuleExports() { return module; };
82/******/ __webpack_require__.d(getter, 'a', getter);
83/******/ return getter;
84/******/ };
85/******/
86/******/ // Object.prototype.hasOwnProperty.call
87/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88/******/
89/******/ // __webpack_public_path__
90/******/ __webpack_require__.p = "";
91/******/
92/******/
93/******/ // Load entry module and return exports
94/******/ return __webpack_require__(__webpack_require__.s = "./lib/index.js");
95/******/ })
96/************************************************************************/
97/******/ ({
98
99/***/ "../../node_modules/object-assign/index.js":
100/*!************************************************************!*\
101 !*** /root/amplify-js/node_modules/object-assign/index.js ***!
102 \************************************************************/
103/*! no static exports found */
104/***/ (function(module, exports, __webpack_require__) {
105
106"use strict";
107/*
108object-assign
109(c) Sindre Sorhus
110@license MIT
111*/
112
113
114/* eslint-disable no-unused-vars */
115var getOwnPropertySymbols = Object.getOwnPropertySymbols;
116var hasOwnProperty = Object.prototype.hasOwnProperty;
117var propIsEnumerable = Object.prototype.propertyIsEnumerable;
118
119function toObject(val) {
120 if (val === null || val === undefined) {
121 throw new TypeError('Object.assign cannot be called with null or undefined');
122 }
123
124 return Object(val);
125}
126
127function shouldUseNative() {
128 try {
129 if (!Object.assign) {
130 return false;
131 }
132
133 // Detect buggy property enumeration order in older V8 versions.
134
135 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
136 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
137 test1[5] = 'de';
138 if (Object.getOwnPropertyNames(test1)[0] === '5') {
139 return false;
140 }
141
142 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
143 var test2 = {};
144 for (var i = 0; i < 10; i++) {
145 test2['_' + String.fromCharCode(i)] = i;
146 }
147 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
148 return test2[n];
149 });
150 if (order2.join('') !== '0123456789') {
151 return false;
152 }
153
154 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
155 var test3 = {};
156 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
157 test3[letter] = letter;
158 });
159 if (Object.keys(Object.assign({}, test3)).join('') !==
160 'abcdefghijklmnopqrst') {
161 return false;
162 }
163
164 return true;
165 } catch (err) {
166 // We don't expect any of the above to throw, but better to be safe.
167 return false;
168 }
169}
170
171module.exports = shouldUseNative() ? Object.assign : function (target, source) {
172 var from;
173 var to = toObject(target);
174 var symbols;
175
176 for (var s = 1; s < arguments.length; s++) {
177 from = Object(arguments[s]);
178
179 for (var key in from) {
180 if (hasOwnProperty.call(from, key)) {
181 to[key] = from[key];
182 }
183 }
184
185 if (getOwnPropertySymbols) {
186 symbols = getOwnPropertySymbols(from);
187 for (var i = 0; i < symbols.length; i++) {
188 if (propIsEnumerable.call(from, symbols[i])) {
189 to[symbols[i]] = from[symbols[i]];
190 }
191 }
192 }
193 }
194
195 return to;
196};
197
198
199/***/ }),
200
201/***/ "../../node_modules/prop-types/checkPropTypes.js":
202/*!******************************************************************!*\
203 !*** /root/amplify-js/node_modules/prop-types/checkPropTypes.js ***!
204 \******************************************************************/
205/*! no static exports found */
206/***/ (function(module, exports, __webpack_require__) {
207
208"use strict";
209/**
210 * Copyright (c) 2013-present, Facebook, Inc.
211 *
212 * This source code is licensed under the MIT license found in the
213 * LICENSE file in the root directory of this source tree.
214 */
215
216
217
218var printWarning = function() {};
219
220if (true) {
221 var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js");
222 var loggedTypeFailures = {};
223 var has = Function.call.bind(Object.prototype.hasOwnProperty);
224
225 printWarning = function(text) {
226 var message = 'Warning: ' + text;
227 if (typeof console !== 'undefined') {
228 console.error(message);
229 }
230 try {
231 // --- Welcome to debugging React ---
232 // This error was thrown as a convenience so that you can use this stack
233 // to find the callsite that caused this warning to fire.
234 throw new Error(message);
235 } catch (x) {}
236 };
237}
238
239/**
240 * Assert that the values match with the type specs.
241 * Error messages are memorized and will only be shown once.
242 *
243 * @param {object} typeSpecs Map of name to a ReactPropType
244 * @param {object} values Runtime values that need to be type-checked
245 * @param {string} location e.g. "prop", "context", "child context"
246 * @param {string} componentName Name of the component for error messages.
247 * @param {?Function} getStack Returns the component stack.
248 * @private
249 */
250function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
251 if (true) {
252 for (var typeSpecName in typeSpecs) {
253 if (has(typeSpecs, typeSpecName)) {
254 var error;
255 // Prop type validation may throw. In case they do, we don't want to
256 // fail the render phase where it didn't fail before. So we log it.
257 // After these have been cleaned up, we'll let them throw.
258 try {
259 // This is intentionally an invariant that gets caught. It's the same
260 // behavior as without this statement except with a better message.
261 if (typeof typeSpecs[typeSpecName] !== 'function') {
262 var err = Error(
263 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
264 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
265 );
266 err.name = 'Invariant Violation';
267 throw err;
268 }
269 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
270 } catch (ex) {
271 error = ex;
272 }
273 if (error && !(error instanceof Error)) {
274 printWarning(
275 (componentName || 'React class') + ': type specification of ' +
276 location + ' `' + typeSpecName + '` is invalid; the type checker ' +
277 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
278 'You may have forgotten to pass an argument to the type checker ' +
279 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
280 'shape all require an argument).'
281 );
282 }
283 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
284 // Only monitor this failure once because there tends to be a lot of the
285 // same error.
286 loggedTypeFailures[error.message] = true;
287
288 var stack = getStack ? getStack() : '';
289
290 printWarning(
291 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
292 );
293 }
294 }
295 }
296 }
297}
298
299/**
300 * Resets warning cache when testing.
301 *
302 * @private
303 */
304checkPropTypes.resetWarningCache = function() {
305 if (true) {
306 loggedTypeFailures = {};
307 }
308}
309
310module.exports = checkPropTypes;
311
312
313/***/ }),
314
315/***/ "../../node_modules/prop-types/factoryWithTypeCheckers.js":
316/*!***************************************************************************!*\
317 !*** /root/amplify-js/node_modules/prop-types/factoryWithTypeCheckers.js ***!
318 \***************************************************************************/
319/*! no static exports found */
320/***/ (function(module, exports, __webpack_require__) {
321
322"use strict";
323/**
324 * Copyright (c) 2013-present, Facebook, Inc.
325 *
326 * This source code is licensed under the MIT license found in the
327 * LICENSE file in the root directory of this source tree.
328 */
329
330
331
332var ReactIs = __webpack_require__(/*! react-is */ "../../node_modules/react-is/index.js");
333var assign = __webpack_require__(/*! object-assign */ "../../node_modules/object-assign/index.js");
334
335var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js");
336var checkPropTypes = __webpack_require__(/*! ./checkPropTypes */ "../../node_modules/prop-types/checkPropTypes.js");
337
338var has = Function.call.bind(Object.prototype.hasOwnProperty);
339var printWarning = function() {};
340
341if (true) {
342 printWarning = function(text) {
343 var message = 'Warning: ' + text;
344 if (typeof console !== 'undefined') {
345 console.error(message);
346 }
347 try {
348 // --- Welcome to debugging React ---
349 // This error was thrown as a convenience so that you can use this stack
350 // to find the callsite that caused this warning to fire.
351 throw new Error(message);
352 } catch (x) {}
353 };
354}
355
356function emptyFunctionThatReturnsNull() {
357 return null;
358}
359
360module.exports = function(isValidElement, throwOnDirectAccess) {
361 /* global Symbol */
362 var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
363 var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
364
365 /**
366 * Returns the iterator method function contained on the iterable object.
367 *
368 * Be sure to invoke the function with the iterable as context:
369 *
370 * var iteratorFn = getIteratorFn(myIterable);
371 * if (iteratorFn) {
372 * var iterator = iteratorFn.call(myIterable);
373 * ...
374 * }
375 *
376 * @param {?object} maybeIterable
377 * @return {?function}
378 */
379 function getIteratorFn(maybeIterable) {
380 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
381 if (typeof iteratorFn === 'function') {
382 return iteratorFn;
383 }
384 }
385
386 /**
387 * Collection of methods that allow declaration and validation of props that are
388 * supplied to React components. Example usage:
389 *
390 * var Props = require('ReactPropTypes');
391 * var MyArticle = React.createClass({
392 * propTypes: {
393 * // An optional string prop named "description".
394 * description: Props.string,
395 *
396 * // A required enum prop named "category".
397 * category: Props.oneOf(['News','Photos']).isRequired,
398 *
399 * // A prop named "dialog" that requires an instance of Dialog.
400 * dialog: Props.instanceOf(Dialog).isRequired
401 * },
402 * render: function() { ... }
403 * });
404 *
405 * A more formal specification of how these methods are used:
406 *
407 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
408 * decl := ReactPropTypes.{type}(.isRequired)?
409 *
410 * Each and every declaration produces a function with the same signature. This
411 * allows the creation of custom validation functions. For example:
412 *
413 * var MyLink = React.createClass({
414 * propTypes: {
415 * // An optional string or URI prop named "href".
416 * href: function(props, propName, componentName) {
417 * var propValue = props[propName];
418 * if (propValue != null && typeof propValue !== 'string' &&
419 * !(propValue instanceof URI)) {
420 * return new Error(
421 * 'Expected a string or an URI for ' + propName + ' in ' +
422 * componentName
423 * );
424 * }
425 * }
426 * },
427 * render: function() {...}
428 * });
429 *
430 * @internal
431 */
432
433 var ANONYMOUS = '<<anonymous>>';
434
435 // Important!
436 // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
437 var ReactPropTypes = {
438 array: createPrimitiveTypeChecker('array'),
439 bool: createPrimitiveTypeChecker('boolean'),
440 func: createPrimitiveTypeChecker('function'),
441 number: createPrimitiveTypeChecker('number'),
442 object: createPrimitiveTypeChecker('object'),
443 string: createPrimitiveTypeChecker('string'),
444 symbol: createPrimitiveTypeChecker('symbol'),
445
446 any: createAnyTypeChecker(),
447 arrayOf: createArrayOfTypeChecker,
448 element: createElementTypeChecker(),
449 elementType: createElementTypeTypeChecker(),
450 instanceOf: createInstanceTypeChecker,
451 node: createNodeChecker(),
452 objectOf: createObjectOfTypeChecker,
453 oneOf: createEnumTypeChecker,
454 oneOfType: createUnionTypeChecker,
455 shape: createShapeTypeChecker,
456 exact: createStrictShapeTypeChecker,
457 };
458
459 /**
460 * inlined Object.is polyfill to avoid requiring consumers ship their own
461 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
462 */
463 /*eslint-disable no-self-compare*/
464 function is(x, y) {
465 // SameValue algorithm
466 if (x === y) {
467 // Steps 1-5, 7-10
468 // Steps 6.b-6.e: +0 != -0
469 return x !== 0 || 1 / x === 1 / y;
470 } else {
471 // Step 6.a: NaN == NaN
472 return x !== x && y !== y;
473 }
474 }
475 /*eslint-enable no-self-compare*/
476
477 /**
478 * We use an Error-like object for backward compatibility as people may call
479 * PropTypes directly and inspect their output. However, we don't use real
480 * Errors anymore. We don't inspect their stack anyway, and creating them
481 * is prohibitively expensive if they are created too often, such as what
482 * happens in oneOfType() for any type before the one that matched.
483 */
484 function PropTypeError(message) {
485 this.message = message;
486 this.stack = '';
487 }
488 // Make `instanceof Error` still work for returned errors.
489 PropTypeError.prototype = Error.prototype;
490
491 function createChainableTypeChecker(validate) {
492 if (true) {
493 var manualPropTypeCallCache = {};
494 var manualPropTypeWarningCount = 0;
495 }
496 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
497 componentName = componentName || ANONYMOUS;
498 propFullName = propFullName || propName;
499
500 if (secret !== ReactPropTypesSecret) {
501 if (throwOnDirectAccess) {
502 // New behavior only for users of `prop-types` package
503 var err = new Error(
504 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
505 'Use `PropTypes.checkPropTypes()` to call them. ' +
506 'Read more at http://fb.me/use-check-prop-types'
507 );
508 err.name = 'Invariant Violation';
509 throw err;
510 } else if ( true && typeof console !== 'undefined') {
511 // Old behavior for people using React.PropTypes
512 var cacheKey = componentName + ':' + propName;
513 if (
514 !manualPropTypeCallCache[cacheKey] &&
515 // Avoid spamming the console because they are often not actionable except for lib authors
516 manualPropTypeWarningCount < 3
517 ) {
518 printWarning(
519 'You are manually calling a React.PropTypes validation ' +
520 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
521 'and will throw in the standalone `prop-types` package. ' +
522 'You may be seeing this warning due to a third-party PropTypes ' +
523 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
524 );
525 manualPropTypeCallCache[cacheKey] = true;
526 manualPropTypeWarningCount++;
527 }
528 }
529 }
530 if (props[propName] == null) {
531 if (isRequired) {
532 if (props[propName] === null) {
533 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
534 }
535 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
536 }
537 return null;
538 } else {
539 return validate(props, propName, componentName, location, propFullName);
540 }
541 }
542
543 var chainedCheckType = checkType.bind(null, false);
544 chainedCheckType.isRequired = checkType.bind(null, true);
545
546 return chainedCheckType;
547 }
548
549 function createPrimitiveTypeChecker(expectedType) {
550 function validate(props, propName, componentName, location, propFullName, secret) {
551 var propValue = props[propName];
552 var propType = getPropType(propValue);
553 if (propType !== expectedType) {
554 // `propValue` being instance of, say, date/regexp, pass the 'object'
555 // check, but we can offer a more precise error message here rather than
556 // 'of type `object`'.
557 var preciseType = getPreciseType(propValue);
558
559 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
560 }
561 return null;
562 }
563 return createChainableTypeChecker(validate);
564 }
565
566 function createAnyTypeChecker() {
567 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
568 }
569
570 function createArrayOfTypeChecker(typeChecker) {
571 function validate(props, propName, componentName, location, propFullName) {
572 if (typeof typeChecker !== 'function') {
573 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
574 }
575 var propValue = props[propName];
576 if (!Array.isArray(propValue)) {
577 var propType = getPropType(propValue);
578 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
579 }
580 for (var i = 0; i < propValue.length; i++) {
581 var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
582 if (error instanceof Error) {
583 return error;
584 }
585 }
586 return null;
587 }
588 return createChainableTypeChecker(validate);
589 }
590
591 function createElementTypeChecker() {
592 function validate(props, propName, componentName, location, propFullName) {
593 var propValue = props[propName];
594 if (!isValidElement(propValue)) {
595 var propType = getPropType(propValue);
596 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
597 }
598 return null;
599 }
600 return createChainableTypeChecker(validate);
601 }
602
603 function createElementTypeTypeChecker() {
604 function validate(props, propName, componentName, location, propFullName) {
605 var propValue = props[propName];
606 if (!ReactIs.isValidElementType(propValue)) {
607 var propType = getPropType(propValue);
608 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
609 }
610 return null;
611 }
612 return createChainableTypeChecker(validate);
613 }
614
615 function createInstanceTypeChecker(expectedClass) {
616 function validate(props, propName, componentName, location, propFullName) {
617 if (!(props[propName] instanceof expectedClass)) {
618 var expectedClassName = expectedClass.name || ANONYMOUS;
619 var actualClassName = getClassName(props[propName]);
620 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
621 }
622 return null;
623 }
624 return createChainableTypeChecker(validate);
625 }
626
627 function createEnumTypeChecker(expectedValues) {
628 if (!Array.isArray(expectedValues)) {
629 if (true) {
630 if (arguments.length > 1) {
631 printWarning(
632 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
633 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
634 );
635 } else {
636 printWarning('Invalid argument supplied to oneOf, expected an array.');
637 }
638 }
639 return emptyFunctionThatReturnsNull;
640 }
641
642 function validate(props, propName, componentName, location, propFullName) {
643 var propValue = props[propName];
644 for (var i = 0; i < expectedValues.length; i++) {
645 if (is(propValue, expectedValues[i])) {
646 return null;
647 }
648 }
649
650 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
651 var type = getPreciseType(value);
652 if (type === 'symbol') {
653 return String(value);
654 }
655 return value;
656 });
657 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
658 }
659 return createChainableTypeChecker(validate);
660 }
661
662 function createObjectOfTypeChecker(typeChecker) {
663 function validate(props, propName, componentName, location, propFullName) {
664 if (typeof typeChecker !== 'function') {
665 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
666 }
667 var propValue = props[propName];
668 var propType = getPropType(propValue);
669 if (propType !== 'object') {
670 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
671 }
672 for (var key in propValue) {
673 if (has(propValue, key)) {
674 var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
675 if (error instanceof Error) {
676 return error;
677 }
678 }
679 }
680 return null;
681 }
682 return createChainableTypeChecker(validate);
683 }
684
685 function createUnionTypeChecker(arrayOfTypeCheckers) {
686 if (!Array.isArray(arrayOfTypeCheckers)) {
687 true ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : undefined;
688 return emptyFunctionThatReturnsNull;
689 }
690
691 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
692 var checker = arrayOfTypeCheckers[i];
693 if (typeof checker !== 'function') {
694 printWarning(
695 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
696 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
697 );
698 return emptyFunctionThatReturnsNull;
699 }
700 }
701
702 function validate(props, propName, componentName, location, propFullName) {
703 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
704 var checker = arrayOfTypeCheckers[i];
705 if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
706 return null;
707 }
708 }
709
710 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
711 }
712 return createChainableTypeChecker(validate);
713 }
714
715 function createNodeChecker() {
716 function validate(props, propName, componentName, location, propFullName) {
717 if (!isNode(props[propName])) {
718 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
719 }
720 return null;
721 }
722 return createChainableTypeChecker(validate);
723 }
724
725 function createShapeTypeChecker(shapeTypes) {
726 function validate(props, propName, componentName, location, propFullName) {
727 var propValue = props[propName];
728 var propType = getPropType(propValue);
729 if (propType !== 'object') {
730 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
731 }
732 for (var key in shapeTypes) {
733 var checker = shapeTypes[key];
734 if (!checker) {
735 continue;
736 }
737 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
738 if (error) {
739 return error;
740 }
741 }
742 return null;
743 }
744 return createChainableTypeChecker(validate);
745 }
746
747 function createStrictShapeTypeChecker(shapeTypes) {
748 function validate(props, propName, componentName, location, propFullName) {
749 var propValue = props[propName];
750 var propType = getPropType(propValue);
751 if (propType !== 'object') {
752 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
753 }
754 // We need to check all keys in case some are required but missing from
755 // props.
756 var allKeys = assign({}, props[propName], shapeTypes);
757 for (var key in allKeys) {
758 var checker = shapeTypes[key];
759 if (!checker) {
760 return new PropTypeError(
761 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
762 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
763 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
764 );
765 }
766 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
767 if (error) {
768 return error;
769 }
770 }
771 return null;
772 }
773
774 return createChainableTypeChecker(validate);
775 }
776
777 function isNode(propValue) {
778 switch (typeof propValue) {
779 case 'number':
780 case 'string':
781 case 'undefined':
782 return true;
783 case 'boolean':
784 return !propValue;
785 case 'object':
786 if (Array.isArray(propValue)) {
787 return propValue.every(isNode);
788 }
789 if (propValue === null || isValidElement(propValue)) {
790 return true;
791 }
792
793 var iteratorFn = getIteratorFn(propValue);
794 if (iteratorFn) {
795 var iterator = iteratorFn.call(propValue);
796 var step;
797 if (iteratorFn !== propValue.entries) {
798 while (!(step = iterator.next()).done) {
799 if (!isNode(step.value)) {
800 return false;
801 }
802 }
803 } else {
804 // Iterator will provide entry [k,v] tuples rather than values.
805 while (!(step = iterator.next()).done) {
806 var entry = step.value;
807 if (entry) {
808 if (!isNode(entry[1])) {
809 return false;
810 }
811 }
812 }
813 }
814 } else {
815 return false;
816 }
817
818 return true;
819 default:
820 return false;
821 }
822 }
823
824 function isSymbol(propType, propValue) {
825 // Native Symbol.
826 if (propType === 'symbol') {
827 return true;
828 }
829
830 // falsy value can't be a Symbol
831 if (!propValue) {
832 return false;
833 }
834
835 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
836 if (propValue['@@toStringTag'] === 'Symbol') {
837 return true;
838 }
839
840 // Fallback for non-spec compliant Symbols which are polyfilled.
841 if (typeof Symbol === 'function' && propValue instanceof Symbol) {
842 return true;
843 }
844
845 return false;
846 }
847
848 // Equivalent of `typeof` but with special handling for array and regexp.
849 function getPropType(propValue) {
850 var propType = typeof propValue;
851 if (Array.isArray(propValue)) {
852 return 'array';
853 }
854 if (propValue instanceof RegExp) {
855 // Old webkits (at least until Android 4.0) return 'function' rather than
856 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
857 // passes PropTypes.object.
858 return 'object';
859 }
860 if (isSymbol(propType, propValue)) {
861 return 'symbol';
862 }
863 return propType;
864 }
865
866 // This handles more types than `getPropType`. Only used for error messages.
867 // See `createPrimitiveTypeChecker`.
868 function getPreciseType(propValue) {
869 if (typeof propValue === 'undefined' || propValue === null) {
870 return '' + propValue;
871 }
872 var propType = getPropType(propValue);
873 if (propType === 'object') {
874 if (propValue instanceof Date) {
875 return 'date';
876 } else if (propValue instanceof RegExp) {
877 return 'regexp';
878 }
879 }
880 return propType;
881 }
882
883 // Returns a string that is postfixed to a warning about an invalid type.
884 // For example, "undefined" or "of type array"
885 function getPostfixForTypeWarning(value) {
886 var type = getPreciseType(value);
887 switch (type) {
888 case 'array':
889 case 'object':
890 return 'an ' + type;
891 case 'boolean':
892 case 'date':
893 case 'regexp':
894 return 'a ' + type;
895 default:
896 return type;
897 }
898 }
899
900 // Returns class name of the object, if any.
901 function getClassName(propValue) {
902 if (!propValue.constructor || !propValue.constructor.name) {
903 return ANONYMOUS;
904 }
905 return propValue.constructor.name;
906 }
907
908 ReactPropTypes.checkPropTypes = checkPropTypes;
909 ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
910 ReactPropTypes.PropTypes = ReactPropTypes;
911
912 return ReactPropTypes;
913};
914
915
916/***/ }),
917
918/***/ "../../node_modules/prop-types/index.js":
919/*!*********************************************************!*\
920 !*** /root/amplify-js/node_modules/prop-types/index.js ***!
921 \*********************************************************/
922/*! no static exports found */
923/***/ (function(module, exports, __webpack_require__) {
924
925/**
926 * Copyright (c) 2013-present, Facebook, Inc.
927 *
928 * This source code is licensed under the MIT license found in the
929 * LICENSE file in the root directory of this source tree.
930 */
931
932if (true) {
933 var ReactIs = __webpack_require__(/*! react-is */ "../../node_modules/react-is/index.js");
934
935 // By explicitly using `prop-types` you are opting into new development behavior.
936 // http://fb.me/prop-types-in-prod
937 var throwOnDirectAccess = true;
938 module.exports = __webpack_require__(/*! ./factoryWithTypeCheckers */ "../../node_modules/prop-types/factoryWithTypeCheckers.js")(ReactIs.isElement, throwOnDirectAccess);
939} else {}
940
941
942/***/ }),
943
944/***/ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js":
945/*!****************************************************************************!*\
946 !*** /root/amplify-js/node_modules/prop-types/lib/ReactPropTypesSecret.js ***!
947 \****************************************************************************/
948/*! no static exports found */
949/***/ (function(module, exports, __webpack_require__) {
950
951"use strict";
952/**
953 * Copyright (c) 2013-present, Facebook, Inc.
954 *
955 * This source code is licensed under the MIT license found in the
956 * LICENSE file in the root directory of this source tree.
957 */
958
959
960
961var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
962
963module.exports = ReactPropTypesSecret;
964
965
966/***/ }),
967
968/***/ "../../node_modules/qr.js/lib/8BitByte.js":
969/*!***********************************************************!*\
970 !*** /root/amplify-js/node_modules/qr.js/lib/8BitByte.js ***!
971 \***********************************************************/
972/*! no static exports found */
973/***/ (function(module, exports, __webpack_require__) {
974
975var mode = __webpack_require__(/*! ./mode */ "../../node_modules/qr.js/lib/mode.js");
976
977function QR8bitByte(data) {
978 this.mode = mode.MODE_8BIT_BYTE;
979 this.data = data;
980}
981
982QR8bitByte.prototype = {
983
984 getLength : function(buffer) {
985 return this.data.length;
986 },
987
988 write : function(buffer) {
989 for (var i = 0; i < this.data.length; i++) {
990 // not JIS ...
991 buffer.put(this.data.charCodeAt(i), 8);
992 }
993 }
994};
995
996module.exports = QR8bitByte;
997
998
999
1000/***/ }),
1001
1002/***/ "../../node_modules/qr.js/lib/BitBuffer.js":
1003/*!************************************************************!*\
1004 !*** /root/amplify-js/node_modules/qr.js/lib/BitBuffer.js ***!
1005 \************************************************************/
1006/*! no static exports found */
1007/***/ (function(module, exports) {
1008
1009function QRBitBuffer() {
1010 this.buffer = new Array();
1011 this.length = 0;
1012}
1013
1014QRBitBuffer.prototype = {
1015
1016 get : function(index) {
1017 var bufIndex = Math.floor(index / 8);
1018 return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
1019 },
1020
1021 put : function(num, length) {
1022 for (var i = 0; i < length; i++) {
1023 this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
1024 }
1025 },
1026
1027 getLengthInBits : function() {
1028 return this.length;
1029 },
1030
1031 putBit : function(bit) {
1032
1033 var bufIndex = Math.floor(this.length / 8);
1034 if (this.buffer.length <= bufIndex) {
1035 this.buffer.push(0);
1036 }
1037
1038 if (bit) {
1039 this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) );
1040 }
1041
1042 this.length++;
1043 }
1044};
1045
1046module.exports = QRBitBuffer;
1047
1048
1049/***/ }),
1050
1051/***/ "../../node_modules/qr.js/lib/ErrorCorrectLevel.js":
1052/*!********************************************************************!*\
1053 !*** /root/amplify-js/node_modules/qr.js/lib/ErrorCorrectLevel.js ***!
1054 \********************************************************************/
1055/*! no static exports found */
1056/***/ (function(module, exports) {
1057
1058module.exports = {
1059 L : 1,
1060 M : 0,
1061 Q : 3,
1062 H : 2
1063};
1064
1065
1066
1067/***/ }),
1068
1069/***/ "../../node_modules/qr.js/lib/Polynomial.js":
1070/*!*************************************************************!*\
1071 !*** /root/amplify-js/node_modules/qr.js/lib/Polynomial.js ***!
1072 \*************************************************************/
1073/*! no static exports found */
1074/***/ (function(module, exports, __webpack_require__) {
1075
1076var math = __webpack_require__(/*! ./math */ "../../node_modules/qr.js/lib/math.js");
1077
1078function QRPolynomial(num, shift) {
1079
1080 if (num.length == undefined) {
1081 throw new Error(num.length + "/" + shift);
1082 }
1083
1084 var offset = 0;
1085
1086 while (offset < num.length && num[offset] == 0) {
1087 offset++;
1088 }
1089
1090 this.num = new Array(num.length - offset + shift);
1091 for (var i = 0; i < num.length - offset; i++) {
1092 this.num[i] = num[i + offset];
1093 }
1094}
1095
1096QRPolynomial.prototype = {
1097
1098 get : function(index) {
1099 return this.num[index];
1100 },
1101
1102 getLength : function() {
1103 return this.num.length;
1104 },
1105
1106 multiply : function(e) {
1107
1108 var num = new Array(this.getLength() + e.getLength() - 1);
1109
1110 for (var i = 0; i < this.getLength(); i++) {
1111 for (var j = 0; j < e.getLength(); j++) {
1112 num[i + j] ^= math.gexp(math.glog(this.get(i) ) + math.glog(e.get(j) ) );
1113 }
1114 }
1115
1116 return new QRPolynomial(num, 0);
1117 },
1118
1119 mod : function(e) {
1120
1121 if (this.getLength() - e.getLength() < 0) {
1122 return this;
1123 }
1124
1125 var ratio = math.glog(this.get(0) ) - math.glog(e.get(0) );
1126
1127 var num = new Array(this.getLength() );
1128
1129 for (var i = 0; i < this.getLength(); i++) {
1130 num[i] = this.get(i);
1131 }
1132
1133 for (var i = 0; i < e.getLength(); i++) {
1134 num[i] ^= math.gexp(math.glog(e.get(i) ) + ratio);
1135 }
1136
1137 // recursive call
1138 return new QRPolynomial(num, 0).mod(e);
1139 }
1140};
1141
1142module.exports = QRPolynomial;
1143
1144
1145/***/ }),
1146
1147/***/ "../../node_modules/qr.js/lib/QRCode.js":
1148/*!*********************************************************!*\
1149 !*** /root/amplify-js/node_modules/qr.js/lib/QRCode.js ***!
1150 \*********************************************************/
1151/*! no static exports found */
1152/***/ (function(module, exports, __webpack_require__) {
1153
1154var BitByte = __webpack_require__(/*! ./8BitByte */ "../../node_modules/qr.js/lib/8BitByte.js");
1155var RSBlock = __webpack_require__(/*! ./RSBlock */ "../../node_modules/qr.js/lib/RSBlock.js");
1156var BitBuffer = __webpack_require__(/*! ./BitBuffer */ "../../node_modules/qr.js/lib/BitBuffer.js");
1157var util = __webpack_require__(/*! ./util */ "../../node_modules/qr.js/lib/util.js");
1158var Polynomial = __webpack_require__(/*! ./Polynomial */ "../../node_modules/qr.js/lib/Polynomial.js");
1159
1160function QRCode(typeNumber, errorCorrectLevel) {
1161 this.typeNumber = typeNumber;
1162 this.errorCorrectLevel = errorCorrectLevel;
1163 this.modules = null;
1164 this.moduleCount = 0;
1165 this.dataCache = null;
1166 this.dataList = [];
1167}
1168
1169// for client side minification
1170var proto = QRCode.prototype;
1171
1172proto.addData = function(data) {
1173 var newData = new BitByte(data);
1174 this.dataList.push(newData);
1175 this.dataCache = null;
1176};
1177
1178proto.isDark = function(row, col) {
1179 if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
1180 throw new Error(row + "," + col);
1181 }
1182 return this.modules[row][col];
1183};
1184
1185proto.getModuleCount = function() {
1186 return this.moduleCount;
1187};
1188
1189proto.make = function() {
1190 // Calculate automatically typeNumber if provided is < 1
1191 if (this.typeNumber < 1 ){
1192 var typeNumber = 1;
1193 for (typeNumber = 1; typeNumber < 40; typeNumber++) {
1194 var rsBlocks = RSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
1195
1196 var buffer = new BitBuffer();
1197 var totalDataCount = 0;
1198 for (var i = 0; i < rsBlocks.length; i++) {
1199 totalDataCount += rsBlocks[i].dataCount;
1200 }
1201
1202 for (var i = 0; i < this.dataList.length; i++) {
1203 var data = this.dataList[i];
1204 buffer.put(data.mode, 4);
1205 buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber) );
1206 data.write(buffer);
1207 }
1208 if (buffer.getLengthInBits() <= totalDataCount * 8)
1209 break;
1210 }
1211 this.typeNumber = typeNumber;
1212 }
1213 this.makeImpl(false, this.getBestMaskPattern() );
1214};
1215
1216proto.makeImpl = function(test, maskPattern) {
1217
1218 this.moduleCount = this.typeNumber * 4 + 17;
1219 this.modules = new Array(this.moduleCount);
1220
1221 for (var row = 0; row < this.moduleCount; row++) {
1222
1223 this.modules[row] = new Array(this.moduleCount);
1224
1225 for (var col = 0; col < this.moduleCount; col++) {
1226 this.modules[row][col] = null;//(col + row) % 3;
1227 }
1228 }
1229
1230 this.setupPositionProbePattern(0, 0);
1231 this.setupPositionProbePattern(this.moduleCount - 7, 0);
1232 this.setupPositionProbePattern(0, this.moduleCount - 7);
1233 this.setupPositionAdjustPattern();
1234 this.setupTimingPattern();
1235 this.setupTypeInfo(test, maskPattern);
1236
1237 if (this.typeNumber >= 7) {
1238 this.setupTypeNumber(test);
1239 }
1240
1241 if (this.dataCache == null) {
1242 this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
1243 }
1244
1245 this.mapData(this.dataCache, maskPattern);
1246};
1247
1248proto.setupPositionProbePattern = function(row, col) {
1249
1250 for (var r = -1; r <= 7; r++) {
1251
1252 if (row + r <= -1 || this.moduleCount <= row + r) continue;
1253
1254 for (var c = -1; c <= 7; c++) {
1255
1256 if (col + c <= -1 || this.moduleCount <= col + c) continue;
1257
1258 if ( (0 <= r && r <= 6 && (c == 0 || c == 6) )
1259 || (0 <= c && c <= 6 && (r == 0 || r == 6) )
1260 || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {
1261 this.modules[row + r][col + c] = true;
1262 } else {
1263 this.modules[row + r][col + c] = false;
1264 }
1265 }
1266 }
1267};
1268
1269proto.getBestMaskPattern = function() {
1270
1271 var minLostPoint = 0;
1272 var pattern = 0;
1273
1274 for (var i = 0; i < 8; i++) {
1275
1276 this.makeImpl(true, i);
1277
1278 var lostPoint = util.getLostPoint(this);
1279
1280 if (i == 0 || minLostPoint > lostPoint) {
1281 minLostPoint = lostPoint;
1282 pattern = i;
1283 }
1284 }
1285
1286 return pattern;
1287};
1288
1289proto.createMovieClip = function(target_mc, instance_name, depth) {
1290
1291 var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
1292 var cs = 1;
1293
1294 this.make();
1295
1296 for (var row = 0; row < this.modules.length; row++) {
1297
1298 var y = row * cs;
1299
1300 for (var col = 0; col < this.modules[row].length; col++) {
1301
1302 var x = col * cs;
1303 var dark = this.modules[row][col];
1304
1305 if (dark) {
1306 qr_mc.beginFill(0, 100);
1307 qr_mc.moveTo(x, y);
1308 qr_mc.lineTo(x + cs, y);
1309 qr_mc.lineTo(x + cs, y + cs);
1310 qr_mc.lineTo(x, y + cs);
1311 qr_mc.endFill();
1312 }
1313 }
1314 }
1315
1316 return qr_mc;
1317};
1318
1319proto.setupTimingPattern = function() {
1320
1321 for (var r = 8; r < this.moduleCount - 8; r++) {
1322 if (this.modules[r][6] != null) {
1323 continue;
1324 }
1325 this.modules[r][6] = (r % 2 == 0);
1326 }
1327
1328 for (var c = 8; c < this.moduleCount - 8; c++) {
1329 if (this.modules[6][c] != null) {
1330 continue;
1331 }
1332 this.modules[6][c] = (c % 2 == 0);
1333 }
1334};
1335
1336proto.setupPositionAdjustPattern = function() {
1337
1338 var pos = util.getPatternPosition(this.typeNumber);
1339
1340 for (var i = 0; i < pos.length; i++) {
1341
1342 for (var j = 0; j < pos.length; j++) {
1343
1344 var row = pos[i];
1345 var col = pos[j];
1346
1347 if (this.modules[row][col] != null) {
1348 continue;
1349 }
1350
1351 for (var r = -2; r <= 2; r++) {
1352
1353 for (var c = -2; c <= 2; c++) {
1354
1355 if (r == -2 || r == 2 || c == -2 || c == 2
1356 || (r == 0 && c == 0) ) {
1357 this.modules[row + r][col + c] = true;
1358 } else {
1359 this.modules[row + r][col + c] = false;
1360 }
1361 }
1362 }
1363 }
1364 }
1365};
1366
1367proto.setupTypeNumber = function(test) {
1368
1369 var bits = util.getBCHTypeNumber(this.typeNumber);
1370
1371 for (var i = 0; i < 18; i++) {
1372 var mod = (!test && ( (bits >> i) & 1) == 1);
1373 this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
1374 }
1375
1376 for (var i = 0; i < 18; i++) {
1377 var mod = (!test && ( (bits >> i) & 1) == 1);
1378 this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
1379 }
1380};
1381
1382proto.setupTypeInfo = function(test, maskPattern) {
1383
1384 var data = (this.errorCorrectLevel << 3) | maskPattern;
1385 var bits = util.getBCHTypeInfo(data);
1386
1387 // vertical
1388 for (var i = 0; i < 15; i++) {
1389
1390 var mod = (!test && ( (bits >> i) & 1) == 1);
1391
1392 if (i < 6) {
1393 this.modules[i][8] = mod;
1394 } else if (i < 8) {
1395 this.modules[i + 1][8] = mod;
1396 } else {
1397 this.modules[this.moduleCount - 15 + i][8] = mod;
1398 }
1399 }
1400
1401 // horizontal
1402 for (var i = 0; i < 15; i++) {
1403
1404 var mod = (!test && ( (bits >> i) & 1) == 1);
1405
1406 if (i < 8) {
1407 this.modules[8][this.moduleCount - i - 1] = mod;
1408 } else if (i < 9) {
1409 this.modules[8][15 - i - 1 + 1] = mod;
1410 } else {
1411 this.modules[8][15 - i - 1] = mod;
1412 }
1413 }
1414
1415 // fixed module
1416 this.modules[this.moduleCount - 8][8] = (!test);
1417};
1418
1419proto.mapData = function(data, maskPattern) {
1420
1421 var inc = -1;
1422 var row = this.moduleCount - 1;
1423 var bitIndex = 7;
1424 var byteIndex = 0;
1425
1426 for (var col = this.moduleCount - 1; col > 0; col -= 2) {
1427
1428 if (col == 6) col--;
1429
1430 while (true) {
1431
1432 for (var c = 0; c < 2; c++) {
1433
1434 if (this.modules[row][col - c] == null) {
1435
1436 var dark = false;
1437
1438 if (byteIndex < data.length) {
1439 dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);
1440 }
1441
1442 var mask = util.getMask(maskPattern, row, col - c);
1443
1444 if (mask) {
1445 dark = !dark;
1446 }
1447
1448 this.modules[row][col - c] = dark;
1449 bitIndex--;
1450
1451 if (bitIndex == -1) {
1452 byteIndex++;
1453 bitIndex = 7;
1454 }
1455 }
1456 }
1457
1458 row += inc;
1459
1460 if (row < 0 || this.moduleCount <= row) {
1461 row -= inc;
1462 inc = -inc;
1463 break;
1464 }
1465 }
1466 }
1467};
1468
1469QRCode.PAD0 = 0xEC;
1470QRCode.PAD1 = 0x11;
1471
1472QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) {
1473
1474 var rsBlocks = RSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
1475
1476 var buffer = new BitBuffer();
1477
1478 for (var i = 0; i < dataList.length; i++) {
1479 var data = dataList[i];
1480 buffer.put(data.mode, 4);
1481 buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber) );
1482 data.write(buffer);
1483 }
1484
1485 // calc num max data.
1486 var totalDataCount = 0;
1487 for (var i = 0; i < rsBlocks.length; i++) {
1488 totalDataCount += rsBlocks[i].dataCount;
1489 }
1490
1491 if (buffer.getLengthInBits() > totalDataCount * 8) {
1492 throw new Error("code length overflow. ("
1493 + buffer.getLengthInBits()
1494 + ">"
1495 + totalDataCount * 8
1496 + ")");
1497 }
1498
1499 // end code
1500 if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
1501 buffer.put(0, 4);
1502 }
1503
1504 // padding
1505 while (buffer.getLengthInBits() % 8 != 0) {
1506 buffer.putBit(false);
1507 }
1508
1509 // padding
1510 while (true) {
1511
1512 if (buffer.getLengthInBits() >= totalDataCount * 8) {
1513 break;
1514 }
1515 buffer.put(QRCode.PAD0, 8);
1516
1517 if (buffer.getLengthInBits() >= totalDataCount * 8) {
1518 break;
1519 }
1520 buffer.put(QRCode.PAD1, 8);
1521 }
1522
1523 return QRCode.createBytes(buffer, rsBlocks);
1524};
1525
1526QRCode.createBytes = function(buffer, rsBlocks) {
1527
1528 var offset = 0;
1529
1530 var maxDcCount = 0;
1531 var maxEcCount = 0;
1532
1533 var dcdata = new Array(rsBlocks.length);
1534 var ecdata = new Array(rsBlocks.length);
1535
1536 for (var r = 0; r < rsBlocks.length; r++) {
1537
1538 var dcCount = rsBlocks[r].dataCount;
1539 var ecCount = rsBlocks[r].totalCount - dcCount;
1540
1541 maxDcCount = Math.max(maxDcCount, dcCount);
1542 maxEcCount = Math.max(maxEcCount, ecCount);
1543
1544 dcdata[r] = new Array(dcCount);
1545
1546 for (var i = 0; i < dcdata[r].length; i++) {
1547 dcdata[r][i] = 0xff & buffer.buffer[i + offset];
1548 }
1549 offset += dcCount;
1550
1551 var rsPoly = util.getErrorCorrectPolynomial(ecCount);
1552 var rawPoly = new Polynomial(dcdata[r], rsPoly.getLength() - 1);
1553
1554 var modPoly = rawPoly.mod(rsPoly);
1555 ecdata[r] = new Array(rsPoly.getLength() - 1);
1556 for (var i = 0; i < ecdata[r].length; i++) {
1557 var modIndex = i + modPoly.getLength() - ecdata[r].length;
1558 ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0;
1559 }
1560
1561 }
1562
1563 var totalCodeCount = 0;
1564 for (var i = 0; i < rsBlocks.length; i++) {
1565 totalCodeCount += rsBlocks[i].totalCount;
1566 }
1567
1568 var data = new Array(totalCodeCount);
1569 var index = 0;
1570
1571 for (var i = 0; i < maxDcCount; i++) {
1572 for (var r = 0; r < rsBlocks.length; r++) {
1573 if (i < dcdata[r].length) {
1574 data[index++] = dcdata[r][i];
1575 }
1576 }
1577 }
1578
1579 for (var i = 0; i < maxEcCount; i++) {
1580 for (var r = 0; r < rsBlocks.length; r++) {
1581 if (i < ecdata[r].length) {
1582 data[index++] = ecdata[r][i];
1583 }
1584 }
1585 }
1586
1587 return data;
1588};
1589
1590module.exports = QRCode;
1591
1592
1593
1594/***/ }),
1595
1596/***/ "../../node_modules/qr.js/lib/RSBlock.js":
1597/*!**********************************************************!*\
1598 !*** /root/amplify-js/node_modules/qr.js/lib/RSBlock.js ***!
1599 \**********************************************************/
1600/*! no static exports found */
1601/***/ (function(module, exports, __webpack_require__) {
1602
1603// ErrorCorrectLevel
1604var ECL = __webpack_require__(/*! ./ErrorCorrectLevel */ "../../node_modules/qr.js/lib/ErrorCorrectLevel.js");
1605
1606function QRRSBlock(totalCount, dataCount) {
1607 this.totalCount = totalCount;
1608 this.dataCount = dataCount;
1609}
1610
1611QRRSBlock.RS_BLOCK_TABLE = [
1612
1613 // L
1614 // M
1615 // Q
1616 // H
1617
1618 // 1
1619 [1, 26, 19],
1620 [1, 26, 16],
1621 [1, 26, 13],
1622 [1, 26, 9],
1623
1624 // 2
1625 [1, 44, 34],
1626 [1, 44, 28],
1627 [1, 44, 22],
1628 [1, 44, 16],
1629
1630 // 3
1631 [1, 70, 55],
1632 [1, 70, 44],
1633 [2, 35, 17],
1634 [2, 35, 13],
1635
1636 // 4
1637 [1, 100, 80],
1638 [2, 50, 32],
1639 [2, 50, 24],
1640 [4, 25, 9],
1641
1642 // 5
1643 [1, 134, 108],
1644 [2, 67, 43],
1645 [2, 33, 15, 2, 34, 16],
1646 [2, 33, 11, 2, 34, 12],
1647
1648 // 6
1649 [2, 86, 68],
1650 [4, 43, 27],
1651 [4, 43, 19],
1652 [4, 43, 15],
1653
1654 // 7
1655 [2, 98, 78],
1656 [4, 49, 31],
1657 [2, 32, 14, 4, 33, 15],
1658 [4, 39, 13, 1, 40, 14],
1659
1660 // 8
1661 [2, 121, 97],
1662 [2, 60, 38, 2, 61, 39],
1663 [4, 40, 18, 2, 41, 19],
1664 [4, 40, 14, 2, 41, 15],
1665
1666 // 9
1667 [2, 146, 116],
1668 [3, 58, 36, 2, 59, 37],
1669 [4, 36, 16, 4, 37, 17],
1670 [4, 36, 12, 4, 37, 13],
1671
1672 // 10
1673 [2, 86, 68, 2, 87, 69],
1674 [4, 69, 43, 1, 70, 44],
1675 [6, 43, 19, 2, 44, 20],
1676 [6, 43, 15, 2, 44, 16],
1677
1678 // 11
1679 [4, 101, 81],
1680 [1, 80, 50, 4, 81, 51],
1681 [4, 50, 22, 4, 51, 23],
1682 [3, 36, 12, 8, 37, 13],
1683
1684 // 12
1685 [2, 116, 92, 2, 117, 93],
1686 [6, 58, 36, 2, 59, 37],
1687 [4, 46, 20, 6, 47, 21],
1688 [7, 42, 14, 4, 43, 15],
1689
1690 // 13
1691 [4, 133, 107],
1692 [8, 59, 37, 1, 60, 38],
1693 [8, 44, 20, 4, 45, 21],
1694 [12, 33, 11, 4, 34, 12],
1695
1696 // 14
1697 [3, 145, 115, 1, 146, 116],
1698 [4, 64, 40, 5, 65, 41],
1699 [11, 36, 16, 5, 37, 17],
1700 [11, 36, 12, 5, 37, 13],
1701
1702 // 15
1703 [5, 109, 87, 1, 110, 88],
1704 [5, 65, 41, 5, 66, 42],
1705 [5, 54, 24, 7, 55, 25],
1706 [11, 36, 12],
1707
1708 // 16
1709 [5, 122, 98, 1, 123, 99],
1710 [7, 73, 45, 3, 74, 46],
1711 [15, 43, 19, 2, 44, 20],
1712 [3, 45, 15, 13, 46, 16],
1713
1714 // 17
1715 [1, 135, 107, 5, 136, 108],
1716 [10, 74, 46, 1, 75, 47],
1717 [1, 50, 22, 15, 51, 23],
1718 [2, 42, 14, 17, 43, 15],
1719
1720 // 18
1721 [5, 150, 120, 1, 151, 121],
1722 [9, 69, 43, 4, 70, 44],
1723 [17, 50, 22, 1, 51, 23],
1724 [2, 42, 14, 19, 43, 15],
1725
1726 // 19
1727 [3, 141, 113, 4, 142, 114],
1728 [3, 70, 44, 11, 71, 45],
1729 [17, 47, 21, 4, 48, 22],
1730 [9, 39, 13, 16, 40, 14],
1731
1732 // 20
1733 [3, 135, 107, 5, 136, 108],
1734 [3, 67, 41, 13, 68, 42],
1735 [15, 54, 24, 5, 55, 25],
1736 [15, 43, 15, 10, 44, 16],
1737
1738 // 21
1739 [4, 144, 116, 4, 145, 117],
1740 [17, 68, 42],
1741 [17, 50, 22, 6, 51, 23],
1742 [19, 46, 16, 6, 47, 17],
1743
1744 // 22
1745 [2, 139, 111, 7, 140, 112],
1746 [17, 74, 46],
1747 [7, 54, 24, 16, 55, 25],
1748 [34, 37, 13],
1749
1750 // 23
1751 [4, 151, 121, 5, 152, 122],
1752 [4, 75, 47, 14, 76, 48],
1753 [11, 54, 24, 14, 55, 25],
1754 [16, 45, 15, 14, 46, 16],
1755
1756 // 24
1757 [6, 147, 117, 4, 148, 118],
1758 [6, 73, 45, 14, 74, 46],
1759 [11, 54, 24, 16, 55, 25],
1760 [30, 46, 16, 2, 47, 17],
1761
1762 // 25
1763 [8, 132, 106, 4, 133, 107],
1764 [8, 75, 47, 13, 76, 48],
1765 [7, 54, 24, 22, 55, 25],
1766 [22, 45, 15, 13, 46, 16],
1767
1768 // 26
1769 [10, 142, 114, 2, 143, 115],
1770 [19, 74, 46, 4, 75, 47],
1771 [28, 50, 22, 6, 51, 23],
1772 [33, 46, 16, 4, 47, 17],
1773
1774 // 27
1775 [8, 152, 122, 4, 153, 123],
1776 [22, 73, 45, 3, 74, 46],
1777 [8, 53, 23, 26, 54, 24],
1778 [12, 45, 15, 28, 46, 16],
1779
1780 // 28
1781 [3, 147, 117, 10, 148, 118],
1782 [3, 73, 45, 23, 74, 46],
1783 [4, 54, 24, 31, 55, 25],
1784 [11, 45, 15, 31, 46, 16],
1785
1786 // 29
1787 [7, 146, 116, 7, 147, 117],
1788 [21, 73, 45, 7, 74, 46],
1789 [1, 53, 23, 37, 54, 24],
1790 [19, 45, 15, 26, 46, 16],
1791
1792 // 30
1793 [5, 145, 115, 10, 146, 116],
1794 [19, 75, 47, 10, 76, 48],
1795 [15, 54, 24, 25, 55, 25],
1796 [23, 45, 15, 25, 46, 16],
1797
1798 // 31
1799 [13, 145, 115, 3, 146, 116],
1800 [2, 74, 46, 29, 75, 47],
1801 [42, 54, 24, 1, 55, 25],
1802 [23, 45, 15, 28, 46, 16],
1803
1804 // 32
1805 [17, 145, 115],
1806 [10, 74, 46, 23, 75, 47],
1807 [10, 54, 24, 35, 55, 25],
1808 [19, 45, 15, 35, 46, 16],
1809
1810 // 33
1811 [17, 145, 115, 1, 146, 116],
1812 [14, 74, 46, 21, 75, 47],
1813 [29, 54, 24, 19, 55, 25],
1814 [11, 45, 15, 46, 46, 16],
1815
1816 // 34
1817 [13, 145, 115, 6, 146, 116],
1818 [14, 74, 46, 23, 75, 47],
1819 [44, 54, 24, 7, 55, 25],
1820 [59, 46, 16, 1, 47, 17],
1821
1822 // 35
1823 [12, 151, 121, 7, 152, 122],
1824 [12, 75, 47, 26, 76, 48],
1825 [39, 54, 24, 14, 55, 25],
1826 [22, 45, 15, 41, 46, 16],
1827
1828 // 36
1829 [6, 151, 121, 14, 152, 122],
1830 [6, 75, 47, 34, 76, 48],
1831 [46, 54, 24, 10, 55, 25],
1832 [2, 45, 15, 64, 46, 16],
1833
1834 // 37
1835 [17, 152, 122, 4, 153, 123],
1836 [29, 74, 46, 14, 75, 47],
1837 [49, 54, 24, 10, 55, 25],
1838 [24, 45, 15, 46, 46, 16],
1839
1840 // 38
1841 [4, 152, 122, 18, 153, 123],
1842 [13, 74, 46, 32, 75, 47],
1843 [48, 54, 24, 14, 55, 25],
1844 [42, 45, 15, 32, 46, 16],
1845
1846 // 39
1847 [20, 147, 117, 4, 148, 118],
1848 [40, 75, 47, 7, 76, 48],
1849 [43, 54, 24, 22, 55, 25],
1850 [10, 45, 15, 67, 46, 16],
1851
1852 // 40
1853 [19, 148, 118, 6, 149, 119],
1854 [18, 75, 47, 31, 76, 48],
1855 [34, 54, 24, 34, 55, 25],
1856 [20, 45, 15, 61, 46, 16]
1857];
1858
1859QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
1860
1861 var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
1862
1863 if (rsBlock == undefined) {
1864 throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
1865 }
1866
1867 var length = rsBlock.length / 3;
1868
1869 var list = new Array();
1870
1871 for (var i = 0; i < length; i++) {
1872
1873 var count = rsBlock[i * 3 + 0];
1874 var totalCount = rsBlock[i * 3 + 1];
1875 var dataCount = rsBlock[i * 3 + 2];
1876
1877 for (var j = 0; j < count; j++) {
1878 list.push(new QRRSBlock(totalCount, dataCount) );
1879 }
1880 }
1881
1882 return list;
1883}
1884
1885QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
1886
1887 switch(errorCorrectLevel) {
1888 case ECL.L :
1889 return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
1890 case ECL.M :
1891 return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
1892 case ECL.Q :
1893 return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
1894 case ECL.H :
1895 return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
1896 default :
1897 return undefined;
1898 }
1899}
1900
1901module.exports = QRRSBlock;
1902
1903
1904/***/ }),
1905
1906/***/ "../../node_modules/qr.js/lib/math.js":
1907/*!*******************************************************!*\
1908 !*** /root/amplify-js/node_modules/qr.js/lib/math.js ***!
1909 \*******************************************************/
1910/*! no static exports found */
1911/***/ (function(module, exports) {
1912
1913var QRMath = {
1914
1915 glog : function(n) {
1916
1917 if (n < 1) {
1918 throw new Error("glog(" + n + ")");
1919 }
1920
1921 return QRMath.LOG_TABLE[n];
1922 },
1923
1924 gexp : function(n) {
1925
1926 while (n < 0) {
1927 n += 255;
1928 }
1929
1930 while (n >= 256) {
1931 n -= 255;
1932 }
1933
1934 return QRMath.EXP_TABLE[n];
1935 },
1936
1937 EXP_TABLE : new Array(256),
1938
1939 LOG_TABLE : new Array(256)
1940
1941};
1942
1943for (var i = 0; i < 8; i++) {
1944 QRMath.EXP_TABLE[i] = 1 << i;
1945}
1946for (var i = 8; i < 256; i++) {
1947 QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4]
1948 ^ QRMath.EXP_TABLE[i - 5]
1949 ^ QRMath.EXP_TABLE[i - 6]
1950 ^ QRMath.EXP_TABLE[i - 8];
1951}
1952for (var i = 0; i < 255; i++) {
1953 QRMath.LOG_TABLE[QRMath.EXP_TABLE[i] ] = i;
1954}
1955
1956module.exports = QRMath;
1957
1958
1959/***/ }),
1960
1961/***/ "../../node_modules/qr.js/lib/mode.js":
1962/*!*******************************************************!*\
1963 !*** /root/amplify-js/node_modules/qr.js/lib/mode.js ***!
1964 \*******************************************************/
1965/*! no static exports found */
1966/***/ (function(module, exports) {
1967
1968module.exports = {
1969 MODE_NUMBER : 1 << 0,
1970 MODE_ALPHA_NUM : 1 << 1,
1971 MODE_8BIT_BYTE : 1 << 2,
1972 MODE_KANJI : 1 << 3
1973};
1974
1975
1976/***/ }),
1977
1978/***/ "../../node_modules/qr.js/lib/util.js":
1979/*!*******************************************************!*\
1980 !*** /root/amplify-js/node_modules/qr.js/lib/util.js ***!
1981 \*******************************************************/
1982/*! no static exports found */
1983/***/ (function(module, exports, __webpack_require__) {
1984
1985var Mode = __webpack_require__(/*! ./mode */ "../../node_modules/qr.js/lib/mode.js");
1986var Polynomial = __webpack_require__(/*! ./Polynomial */ "../../node_modules/qr.js/lib/Polynomial.js");
1987var math = __webpack_require__(/*! ./math */ "../../node_modules/qr.js/lib/math.js");
1988
1989var QRMaskPattern = {
1990 PATTERN000 : 0,
1991 PATTERN001 : 1,
1992 PATTERN010 : 2,
1993 PATTERN011 : 3,
1994 PATTERN100 : 4,
1995 PATTERN101 : 5,
1996 PATTERN110 : 6,
1997 PATTERN111 : 7
1998};
1999
2000var QRUtil = {
2001
2002 PATTERN_POSITION_TABLE : [
2003 [],
2004 [6, 18],
2005 [6, 22],
2006 [6, 26],
2007 [6, 30],
2008 [6, 34],
2009 [6, 22, 38],
2010 [6, 24, 42],
2011 [6, 26, 46],
2012 [6, 28, 50],
2013 [6, 30, 54],
2014 [6, 32, 58],
2015 [6, 34, 62],
2016 [6, 26, 46, 66],
2017 [6, 26, 48, 70],
2018 [6, 26, 50, 74],
2019 [6, 30, 54, 78],
2020 [6, 30, 56, 82],
2021 [6, 30, 58, 86],
2022 [6, 34, 62, 90],
2023 [6, 28, 50, 72, 94],
2024 [6, 26, 50, 74, 98],
2025 [6, 30, 54, 78, 102],
2026 [6, 28, 54, 80, 106],
2027 [6, 32, 58, 84, 110],
2028 [6, 30, 58, 86, 114],
2029 [6, 34, 62, 90, 118],
2030 [6, 26, 50, 74, 98, 122],
2031 [6, 30, 54, 78, 102, 126],
2032 [6, 26, 52, 78, 104, 130],
2033 [6, 30, 56, 82, 108, 134],
2034 [6, 34, 60, 86, 112, 138],
2035 [6, 30, 58, 86, 114, 142],
2036 [6, 34, 62, 90, 118, 146],
2037 [6, 30, 54, 78, 102, 126, 150],
2038 [6, 24, 50, 76, 102, 128, 154],
2039 [6, 28, 54, 80, 106, 132, 158],
2040 [6, 32, 58, 84, 110, 136, 162],
2041 [6, 26, 54, 82, 110, 138, 166],
2042 [6, 30, 58, 86, 114, 142, 170]
2043 ],
2044
2045 G15 : (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0),
2046 G18 : (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0),
2047 G15_MASK : (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
2048
2049 getBCHTypeInfo : function(data) {
2050 var d = data << 10;
2051 while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
2052 d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) );
2053 }
2054 return ( (data << 10) | d) ^ QRUtil.G15_MASK;
2055 },
2056
2057 getBCHTypeNumber : function(data) {
2058 var d = data << 12;
2059 while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
2060 d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) );
2061 }
2062 return (data << 12) | d;
2063 },
2064
2065 getBCHDigit : function(data) {
2066
2067 var digit = 0;
2068
2069 while (data != 0) {
2070 digit++;
2071 data >>>= 1;
2072 }
2073
2074 return digit;
2075 },
2076
2077 getPatternPosition : function(typeNumber) {
2078 return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
2079 },
2080
2081 getMask : function(maskPattern, i, j) {
2082
2083 switch (maskPattern) {
2084
2085 case QRMaskPattern.PATTERN000 : return (i + j) % 2 == 0;
2086 case QRMaskPattern.PATTERN001 : return i % 2 == 0;
2087 case QRMaskPattern.PATTERN010 : return j % 3 == 0;
2088 case QRMaskPattern.PATTERN011 : return (i + j) % 3 == 0;
2089 case QRMaskPattern.PATTERN100 : return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0;
2090 case QRMaskPattern.PATTERN101 : return (i * j) % 2 + (i * j) % 3 == 0;
2091 case QRMaskPattern.PATTERN110 : return ( (i * j) % 2 + (i * j) % 3) % 2 == 0;
2092 case QRMaskPattern.PATTERN111 : return ( (i * j) % 3 + (i + j) % 2) % 2 == 0;
2093
2094 default :
2095 throw new Error("bad maskPattern:" + maskPattern);
2096 }
2097 },
2098
2099 getErrorCorrectPolynomial : function(errorCorrectLength) {
2100
2101 var a = new Polynomial([1], 0);
2102
2103 for (var i = 0; i < errorCorrectLength; i++) {
2104 a = a.multiply(new Polynomial([1, math.gexp(i)], 0) );
2105 }
2106
2107 return a;
2108 },
2109
2110 getLengthInBits : function(mode, type) {
2111
2112 if (1 <= type && type < 10) {
2113
2114 // 1 - 9
2115
2116 switch(mode) {
2117 case Mode.MODE_NUMBER : return 10;
2118 case Mode.MODE_ALPHA_NUM : return 9;
2119 case Mode.MODE_8BIT_BYTE : return 8;
2120 case Mode.MODE_KANJI : return 8;
2121 default :
2122 throw new Error("mode:" + mode);
2123 }
2124
2125 } else if (type < 27) {
2126
2127 // 10 - 26
2128
2129 switch(mode) {
2130 case Mode.MODE_NUMBER : return 12;
2131 case Mode.MODE_ALPHA_NUM : return 11;
2132 case Mode.MODE_8BIT_BYTE : return 16;
2133 case Mode.MODE_KANJI : return 10;
2134 default :
2135 throw new Error("mode:" + mode);
2136 }
2137
2138 } else if (type < 41) {
2139
2140 // 27 - 40
2141
2142 switch(mode) {
2143 case Mode.MODE_NUMBER : return 14;
2144 case Mode.MODE_ALPHA_NUM : return 13;
2145 case Mode.MODE_8BIT_BYTE : return 16;
2146 case Mode.MODE_KANJI : return 12;
2147 default :
2148 throw new Error("mode:" + mode);
2149 }
2150
2151 } else {
2152 throw new Error("type:" + type);
2153 }
2154 },
2155
2156 getLostPoint : function(qrCode) {
2157
2158 var moduleCount = qrCode.getModuleCount();
2159
2160 var lostPoint = 0;
2161
2162 // LEVEL1
2163
2164 for (var row = 0; row < moduleCount; row++) {
2165
2166 for (var col = 0; col < moduleCount; col++) {
2167
2168 var sameCount = 0;
2169 var dark = qrCode.isDark(row, col);
2170
2171 for (var r = -1; r <= 1; r++) {
2172
2173 if (row + r < 0 || moduleCount <= row + r) {
2174 continue;
2175 }
2176
2177 for (var c = -1; c <= 1; c++) {
2178
2179 if (col + c < 0 || moduleCount <= col + c) {
2180 continue;
2181 }
2182
2183 if (r == 0 && c == 0) {
2184 continue;
2185 }
2186
2187 if (dark == qrCode.isDark(row + r, col + c) ) {
2188 sameCount++;
2189 }
2190 }
2191 }
2192
2193 if (sameCount > 5) {
2194 lostPoint += (3 + sameCount - 5);
2195 }
2196 }
2197 }
2198
2199 // LEVEL2
2200
2201 for (var row = 0; row < moduleCount - 1; row++) {
2202 for (var col = 0; col < moduleCount - 1; col++) {
2203 var count = 0;
2204 if (qrCode.isDark(row, col ) ) count++;
2205 if (qrCode.isDark(row + 1, col ) ) count++;
2206 if (qrCode.isDark(row, col + 1) ) count++;
2207 if (qrCode.isDark(row + 1, col + 1) ) count++;
2208 if (count == 0 || count == 4) {
2209 lostPoint += 3;
2210 }
2211 }
2212 }
2213
2214 // LEVEL3
2215
2216 for (var row = 0; row < moduleCount; row++) {
2217 for (var col = 0; col < moduleCount - 6; col++) {
2218 if (qrCode.isDark(row, col)
2219 && !qrCode.isDark(row, col + 1)
2220 && qrCode.isDark(row, col + 2)
2221 && qrCode.isDark(row, col + 3)
2222 && qrCode.isDark(row, col + 4)
2223 && !qrCode.isDark(row, col + 5)
2224 && qrCode.isDark(row, col + 6) ) {
2225 lostPoint += 40;
2226 }
2227 }
2228 }
2229
2230 for (var col = 0; col < moduleCount; col++) {
2231 for (var row = 0; row < moduleCount - 6; row++) {
2232 if (qrCode.isDark(row, col)
2233 && !qrCode.isDark(row + 1, col)
2234 && qrCode.isDark(row + 2, col)
2235 && qrCode.isDark(row + 3, col)
2236 && qrCode.isDark(row + 4, col)
2237 && !qrCode.isDark(row + 5, col)
2238 && qrCode.isDark(row + 6, col) ) {
2239 lostPoint += 40;
2240 }
2241 }
2242 }
2243
2244 // LEVEL4
2245
2246 var darkCount = 0;
2247
2248 for (var col = 0; col < moduleCount; col++) {
2249 for (var row = 0; row < moduleCount; row++) {
2250 if (qrCode.isDark(row, col) ) {
2251 darkCount++;
2252 }
2253 }
2254 }
2255
2256 var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
2257 lostPoint += ratio * 10;
2258
2259 return lostPoint;
2260 }
2261};
2262
2263module.exports = QRUtil;
2264
2265
2266/***/ }),
2267
2268/***/ "../../node_modules/qrcode.react/lib/index.js":
2269/*!***************************************************************!*\
2270 !*** /root/amplify-js/node_modules/qrcode.react/lib/index.js ***!
2271 \***************************************************************/
2272/*! no static exports found */
2273/***/ (function(module, exports, __webpack_require__) {
2274
2275"use strict";
2276
2277
2278function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2279
2280function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2281
2282function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
2283
2284function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2285
2286function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2287
2288function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2289
2290function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2291
2292function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2293
2294function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2295
2296var React = __webpack_require__(/*! react */ "react");
2297
2298var PropTypes = __webpack_require__(/*! prop-types */ "../../node_modules/prop-types/index.js"); // qr.js doesn't handle error level of zero (M) so we need to do it right,
2299// thus the deep require.
2300
2301
2302var QRCodeImpl = __webpack_require__(/*! qr.js/lib/QRCode */ "../../node_modules/qr.js/lib/QRCode.js");
2303
2304var ErrorCorrectLevel = __webpack_require__(/*! qr.js/lib/ErrorCorrectLevel */ "../../node_modules/qr.js/lib/ErrorCorrectLevel.js");
2305
2306function getBackingStorePixelRatio(ctx) {
2307 return (// $FlowFixMe
2308 ctx.webkitBackingStorePixelRatio || // $FlowFixMe
2309 ctx.mozBackingStorePixelRatio || // $FlowFixMe
2310 ctx.msBackingStorePixelRatio || // $FlowFixMe
2311 ctx.oBackingStorePixelRatio || // $FlowFixMe
2312 ctx.backingStorePixelRatio || 1
2313 );
2314} // Convert from UTF-16, forcing the use of byte-mode encoding in our QR Code.
2315// This allows us to encode Hanji, Kanji, emoji, etc. Ideally we'd do more
2316// detection and not resort to byte-mode if possible, but we're trading off
2317// a smaller library for a smaller amount of data we can potentially encode.
2318// Based on http://jonisalonen.com/2012/from-utf-16-to-utf-8-in-javascript/
2319
2320
2321function convertStr(str) {
2322 var out = '';
2323
2324 for (var i = 0; i < str.length; i++) {
2325 var charcode = str.charCodeAt(i);
2326
2327 if (charcode < 0x0080) {
2328 out += String.fromCharCode(charcode);
2329 } else if (charcode < 0x0800) {
2330 out += String.fromCharCode(0xc0 | charcode >> 6);
2331 out += String.fromCharCode(0x80 | charcode & 0x3f);
2332 } else if (charcode < 0xd800 || charcode >= 0xe000) {
2333 out += String.fromCharCode(0xe0 | charcode >> 12);
2334 out += String.fromCharCode(0x80 | charcode >> 6 & 0x3f);
2335 out += String.fromCharCode(0x80 | charcode & 0x3f);
2336 } else {
2337 // This is a surrogate pair, so we'll reconsitute the pieces and work
2338 // from that
2339 i++;
2340 charcode = 0x10000 + ((charcode & 0x3ff) << 10 | str.charCodeAt(i) & 0x3ff);
2341 out += String.fromCharCode(0xf0 | charcode >> 18);
2342 out += String.fromCharCode(0x80 | charcode >> 12 & 0x3f);
2343 out += String.fromCharCode(0x80 | charcode >> 6 & 0x3f);
2344 out += String.fromCharCode(0x80 | charcode & 0x3f);
2345 }
2346 }
2347
2348 return out;
2349}
2350
2351var DEFAULT_PROPS = {
2352 size: 128,
2353 level: 'L',
2354 bgColor: '#FFFFFF',
2355 fgColor: '#000000'
2356};
2357var PROP_TYPES = {
2358 value: PropTypes.string.isRequired,
2359 size: PropTypes.number,
2360 level: PropTypes.oneOf(['L', 'M', 'Q', 'H']),
2361 bgColor: PropTypes.string,
2362 fgColor: PropTypes.string
2363};
2364
2365var QRCodeCanvas =
2366/*#__PURE__*/
2367function (_React$Component) {
2368 _inherits(QRCodeCanvas, _React$Component);
2369
2370 function QRCodeCanvas() {
2371 var _ref;
2372
2373 var _temp, _this;
2374
2375 _classCallCheck(this, QRCodeCanvas);
2376
2377 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2378 args[_key] = arguments[_key];
2379 }
2380
2381 return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = QRCodeCanvas.__proto__ || Object.getPrototypeOf(QRCodeCanvas)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "_canvas", {
2382 configurable: true,
2383 enumerable: true,
2384 writable: true,
2385 value: void 0
2386 }), _temp));
2387 }
2388
2389 _createClass(QRCodeCanvas, [{
2390 key: "shouldComponentUpdate",
2391 value: function shouldComponentUpdate(nextProps) {
2392 var _this2 = this;
2393
2394 return Object.keys(QRCodeCanvas.propTypes).some(function (k) {
2395 return _this2.props[k] !== nextProps[k];
2396 });
2397 }
2398 }, {
2399 key: "componentDidMount",
2400 value: function componentDidMount() {
2401 this.update();
2402 }
2403 }, {
2404 key: "componentDidUpdate",
2405 value: function componentDidUpdate() {
2406 this.update();
2407 }
2408 }, {
2409 key: "update",
2410 value: function update() {
2411 var _props = this.props,
2412 value = _props.value,
2413 size = _props.size,
2414 level = _props.level,
2415 bgColor = _props.bgColor,
2416 fgColor = _props.fgColor; // We'll use type===-1 to force QRCode to automatically pick the best type
2417
2418 var qrcode = new QRCodeImpl(-1, ErrorCorrectLevel[level]);
2419 qrcode.addData(convertStr(value));
2420 qrcode.make();
2421
2422 if (this._canvas != null) {
2423 var canvas = this._canvas;
2424 var ctx = canvas.getContext('2d');
2425
2426 if (!ctx) {
2427 return;
2428 }
2429
2430 var cells = qrcode.modules;
2431
2432 if (cells === null) {
2433 return;
2434 }
2435
2436 var tileW = size / cells.length;
2437 var tileH = size / cells.length;
2438 var scale = (window.devicePixelRatio || 1) / getBackingStorePixelRatio(ctx);
2439 canvas.height = canvas.width = size * scale;
2440 ctx.scale(scale, scale);
2441 cells.forEach(function (row, rdx) {
2442 row.forEach(function (cell, cdx) {
2443 ctx && (ctx.fillStyle = cell ? fgColor : bgColor);
2444 var w = Math.ceil((cdx + 1) * tileW) - Math.floor(cdx * tileW);
2445 var h = Math.ceil((rdx + 1) * tileH) - Math.floor(rdx * tileH);
2446 ctx && ctx.fillRect(Math.round(cdx * tileW), Math.round(rdx * tileH), w, h);
2447 });
2448 });
2449 }
2450 }
2451 }, {
2452 key: "render",
2453 value: function render() {
2454 var _this3 = this;
2455
2456 var _props2 = this.props,
2457 value = _props2.value,
2458 size = _props2.size,
2459 level = _props2.level,
2460 bgColor = _props2.bgColor,
2461 fgColor = _props2.fgColor,
2462 style = _props2.style,
2463 otherProps = _objectWithoutProperties(_props2, ["value", "size", "level", "bgColor", "fgColor", "style"]);
2464
2465 var canvasStyle = _extends({
2466 height: size,
2467 width: size
2468 }, style);
2469
2470 return React.createElement("canvas", _extends({
2471 style: canvasStyle,
2472 height: size,
2473 width: size,
2474 ref: function ref(_ref2) {
2475 return _this3._canvas = _ref2;
2476 }
2477 }, otherProps));
2478 }
2479 }]);
2480
2481 return QRCodeCanvas;
2482}(React.Component);
2483
2484Object.defineProperty(QRCodeCanvas, "defaultProps", {
2485 configurable: true,
2486 enumerable: true,
2487 writable: true,
2488 value: DEFAULT_PROPS
2489});
2490Object.defineProperty(QRCodeCanvas, "propTypes", {
2491 configurable: true,
2492 enumerable: true,
2493 writable: true,
2494 value: PROP_TYPES
2495});
2496
2497var QRCodeSVG =
2498/*#__PURE__*/
2499function (_React$Component2) {
2500 _inherits(QRCodeSVG, _React$Component2);
2501
2502 function QRCodeSVG() {
2503 _classCallCheck(this, QRCodeSVG);
2504
2505 return _possibleConstructorReturn(this, (QRCodeSVG.__proto__ || Object.getPrototypeOf(QRCodeSVG)).apply(this, arguments));
2506 }
2507
2508 _createClass(QRCodeSVG, [{
2509 key: "shouldComponentUpdate",
2510 value: function shouldComponentUpdate(nextProps) {
2511 var _this4 = this;
2512
2513 return Object.keys(QRCodeCanvas.propTypes).some(function (k) {
2514 return _this4.props[k] !== nextProps[k];
2515 });
2516 }
2517 }, {
2518 key: "render",
2519 value: function render() {
2520 var _props3 = this.props,
2521 value = _props3.value,
2522 size = _props3.size,
2523 level = _props3.level,
2524 bgColor = _props3.bgColor,
2525 fgColor = _props3.fgColor,
2526 otherProps = _objectWithoutProperties(_props3, ["value", "size", "level", "bgColor", "fgColor"]); // We'll use type===-1 to force QRCode to automatically pick the best type
2527
2528
2529 var qrcode = new QRCodeImpl(-1, ErrorCorrectLevel[level]);
2530 qrcode.addData(convertStr(value));
2531 qrcode.make();
2532 var cells = qrcode.modules;
2533
2534 if (cells === null) {
2535 return;
2536 } // Drawing strategy: instead of a rect per module, we're going to create a
2537 // single path for the dark modules and layer that on top of a light rect,
2538 // for a total of 2 DOM nodes. We pay a bit more in string concat but that's
2539 // way faster than DOM ops.
2540 // For level 1, 441 nodes -> 2
2541 // For level 40, 31329 -> 2
2542
2543
2544 var ops = [];
2545 cells.forEach(function (row, y) {
2546 var lastIsDark = false;
2547 var start = null;
2548 row.forEach(function (cell, x) {
2549 if (!cell && start !== null) {
2550 // M0 0h7v1H0z injects the space with the move and dropd the comma,
2551 // saving a char per operation
2552 ops.push("M".concat(start, " ").concat(y, "h").concat(x - start, "v1H").concat(start, "z"));
2553 start = null;
2554 return;
2555 } // end of row, clean up or skip
2556
2557
2558 if (x === row.length - 1) {
2559 if (!cell) {
2560 // We would have closed the op above already so this can only mean
2561 // 2+ light modules in a row.
2562 return;
2563 }
2564
2565 if (start === null) {
2566 // Just a single dark module.
2567 ops.push("M".concat(x, ",").concat(y, " h1v1H").concat(x, "z"));
2568 } else {
2569 // Otherwise finish the current line.
2570 ops.push("M".concat(start, ",").concat(y, " h").concat(x + 1 - start, "v1H").concat(start, "z"));
2571 }
2572
2573 return;
2574 }
2575
2576 if (cell && start === null) {
2577 start = x;
2578 }
2579 });
2580 });
2581 return React.createElement("svg", _extends({
2582 shapeRendering: "crispEdges",
2583 height: size,
2584 width: size,
2585 viewBox: "0 0 ".concat(cells.length, " ").concat(cells.length)
2586 }, otherProps), React.createElement("path", {
2587 fill: bgColor,
2588 d: "M0,0 h".concat(cells.length, "v").concat(cells.length, "H0z")
2589 }), React.createElement("path", {
2590 fill: fgColor,
2591 d: ops.join('')
2592 }));
2593 }
2594 }]);
2595
2596 return QRCodeSVG;
2597}(React.Component);
2598
2599Object.defineProperty(QRCodeSVG, "defaultProps", {
2600 configurable: true,
2601 enumerable: true,
2602 writable: true,
2603 value: DEFAULT_PROPS
2604});
2605Object.defineProperty(QRCodeSVG, "propTypes", {
2606 configurable: true,
2607 enumerable: true,
2608 writable: true,
2609 value: PROP_TYPES
2610});
2611
2612var QRCode = function QRCode(props) {
2613 var renderAs = props.renderAs,
2614 otherProps = _objectWithoutProperties(props, ["renderAs"]);
2615
2616 var Component = renderAs === 'svg' ? QRCodeSVG : QRCodeCanvas;
2617 return React.createElement(Component, otherProps);
2618};
2619
2620QRCode.defaultProps = _extends({
2621 renderAs: 'canvas'
2622}, DEFAULT_PROPS);
2623module.exports = QRCode;
2624
2625/***/ }),
2626
2627/***/ "../../node_modules/react-is/cjs/react-is.development.js":
2628/*!**************************************************************************!*\
2629 !*** /root/amplify-js/node_modules/react-is/cjs/react-is.development.js ***!
2630 \**************************************************************************/
2631/*! no static exports found */
2632/***/ (function(module, exports, __webpack_require__) {
2633
2634"use strict";
2635/** @license React v16.13.1
2636 * react-is.development.js
2637 *
2638 * Copyright (c) Facebook, Inc. and its affiliates.
2639 *
2640 * This source code is licensed under the MIT license found in the
2641 * LICENSE file in the root directory of this source tree.
2642 */
2643
2644
2645
2646
2647
2648if (true) {
2649 (function() {
2650'use strict';
2651
2652// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
2653// nor polyfill, then a plain number is used for performance.
2654var hasSymbol = typeof Symbol === 'function' && Symbol.for;
2655var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
2656var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
2657var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
2658var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
2659var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
2660var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
2661var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
2662// (unstable) APIs that have been removed. Can we remove the symbols?
2663
2664var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
2665var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
2666var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
2667var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
2668var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
2669var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
2670var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
2671var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
2672var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
2673var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
2674var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
2675
2676function isValidElementType(type) {
2677 return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
2678 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
2679}
2680
2681function typeOf(object) {
2682 if (typeof object === 'object' && object !== null) {
2683 var $$typeof = object.$$typeof;
2684
2685 switch ($$typeof) {
2686 case REACT_ELEMENT_TYPE:
2687 var type = object.type;
2688
2689 switch (type) {
2690 case REACT_ASYNC_MODE_TYPE:
2691 case REACT_CONCURRENT_MODE_TYPE:
2692 case REACT_FRAGMENT_TYPE:
2693 case REACT_PROFILER_TYPE:
2694 case REACT_STRICT_MODE_TYPE:
2695 case REACT_SUSPENSE_TYPE:
2696 return type;
2697
2698 default:
2699 var $$typeofType = type && type.$$typeof;
2700
2701 switch ($$typeofType) {
2702 case REACT_CONTEXT_TYPE:
2703 case REACT_FORWARD_REF_TYPE:
2704 case REACT_LAZY_TYPE:
2705 case REACT_MEMO_TYPE:
2706 case REACT_PROVIDER_TYPE:
2707 return $$typeofType;
2708
2709 default:
2710 return $$typeof;
2711 }
2712
2713 }
2714
2715 case REACT_PORTAL_TYPE:
2716 return $$typeof;
2717 }
2718 }
2719
2720 return undefined;
2721} // AsyncMode is deprecated along with isAsyncMode
2722
2723var AsyncMode = REACT_ASYNC_MODE_TYPE;
2724var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
2725var ContextConsumer = REACT_CONTEXT_TYPE;
2726var ContextProvider = REACT_PROVIDER_TYPE;
2727var Element = REACT_ELEMENT_TYPE;
2728var ForwardRef = REACT_FORWARD_REF_TYPE;
2729var Fragment = REACT_FRAGMENT_TYPE;
2730var Lazy = REACT_LAZY_TYPE;
2731var Memo = REACT_MEMO_TYPE;
2732var Portal = REACT_PORTAL_TYPE;
2733var Profiler = REACT_PROFILER_TYPE;
2734var StrictMode = REACT_STRICT_MODE_TYPE;
2735var Suspense = REACT_SUSPENSE_TYPE;
2736var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
2737
2738function isAsyncMode(object) {
2739 {
2740 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
2741 hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
2742
2743 console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
2744 }
2745 }
2746
2747 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
2748}
2749function isConcurrentMode(object) {
2750 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
2751}
2752function isContextConsumer(object) {
2753 return typeOf(object) === REACT_CONTEXT_TYPE;
2754}
2755function isContextProvider(object) {
2756 return typeOf(object) === REACT_PROVIDER_TYPE;
2757}
2758function isElement(object) {
2759 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2760}
2761function isForwardRef(object) {
2762 return typeOf(object) === REACT_FORWARD_REF_TYPE;
2763}
2764function isFragment(object) {
2765 return typeOf(object) === REACT_FRAGMENT_TYPE;
2766}
2767function isLazy(object) {
2768 return typeOf(object) === REACT_LAZY_TYPE;
2769}
2770function isMemo(object) {
2771 return typeOf(object) === REACT_MEMO_TYPE;
2772}
2773function isPortal(object) {
2774 return typeOf(object) === REACT_PORTAL_TYPE;
2775}
2776function isProfiler(object) {
2777 return typeOf(object) === REACT_PROFILER_TYPE;
2778}
2779function isStrictMode(object) {
2780 return typeOf(object) === REACT_STRICT_MODE_TYPE;
2781}
2782function isSuspense(object) {
2783 return typeOf(object) === REACT_SUSPENSE_TYPE;
2784}
2785
2786exports.AsyncMode = AsyncMode;
2787exports.ConcurrentMode = ConcurrentMode;
2788exports.ContextConsumer = ContextConsumer;
2789exports.ContextProvider = ContextProvider;
2790exports.Element = Element;
2791exports.ForwardRef = ForwardRef;
2792exports.Fragment = Fragment;
2793exports.Lazy = Lazy;
2794exports.Memo = Memo;
2795exports.Portal = Portal;
2796exports.Profiler = Profiler;
2797exports.StrictMode = StrictMode;
2798exports.Suspense = Suspense;
2799exports.isAsyncMode = isAsyncMode;
2800exports.isConcurrentMode = isConcurrentMode;
2801exports.isContextConsumer = isContextConsumer;
2802exports.isContextProvider = isContextProvider;
2803exports.isElement = isElement;
2804exports.isForwardRef = isForwardRef;
2805exports.isFragment = isFragment;
2806exports.isLazy = isLazy;
2807exports.isMemo = isMemo;
2808exports.isPortal = isPortal;
2809exports.isProfiler = isProfiler;
2810exports.isStrictMode = isStrictMode;
2811exports.isSuspense = isSuspense;
2812exports.isValidElementType = isValidElementType;
2813exports.typeOf = typeOf;
2814 })();
2815}
2816
2817
2818/***/ }),
2819
2820/***/ "../../node_modules/react-is/index.js":
2821/*!*******************************************************!*\
2822 !*** /root/amplify-js/node_modules/react-is/index.js ***!
2823 \*******************************************************/
2824/*! no static exports found */
2825/***/ (function(module, exports, __webpack_require__) {
2826
2827"use strict";
2828
2829
2830if (false) {} else {
2831 module.exports = __webpack_require__(/*! ./cjs/react-is.development.js */ "../../node_modules/react-is/cjs/react-is.development.js");
2832}
2833
2834
2835/***/ }),
2836
2837/***/ "../../node_modules/webpack/buildin/global.js":
2838/*!***********************************!*\
2839 !*** (webpack)/buildin/global.js ***!
2840 \***********************************/
2841/*! no static exports found */
2842/***/ (function(module, exports) {
2843
2844var g;
2845
2846// This works in non-strict mode
2847g = (function() {
2848 return this;
2849})();
2850
2851try {
2852 // This works if eval is allowed (see CSP)
2853 g = g || new Function("return this")();
2854} catch (e) {
2855 // This works if the window reference is available
2856 if (typeof window === "object") g = window;
2857}
2858
2859// g can still be undefined, but nothing to do about it...
2860// We return undefined, instead of nothing here, so it's
2861// easier to handle this case. if(!global) { ...}
2862
2863module.exports = g;
2864
2865
2866/***/ }),
2867
2868/***/ "./lib/API/GraphQL/Connect.js":
2869/*!************************************!*\
2870 !*** ./lib/API/GraphQL/Connect.js ***!
2871 \************************************/
2872/*! no static exports found */
2873/***/ (function(module, exports, __webpack_require__) {
2874
2875"use strict";
2876
2877
2878var __extends = this && this.__extends || function () {
2879 var _extendStatics = function extendStatics(d, b) {
2880 _extendStatics = Object.setPrototypeOf || {
2881 __proto__: []
2882 } instanceof Array && function (d, b) {
2883 d.__proto__ = b;
2884 } || function (d, b) {
2885 for (var p in b) {
2886 if (b.hasOwnProperty(p)) d[p] = b[p];
2887 }
2888 };
2889
2890 return _extendStatics(d, b);
2891 };
2892
2893 return function (d, b) {
2894 _extendStatics(d, b);
2895
2896 function __() {
2897 this.constructor = d;
2898 }
2899
2900 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2901 };
2902}();
2903
2904var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2905 function adopt(value) {
2906 return value instanceof P ? value : new P(function (resolve) {
2907 resolve(value);
2908 });
2909 }
2910
2911 return new (P || (P = Promise))(function (resolve, reject) {
2912 function fulfilled(value) {
2913 try {
2914 step(generator.next(value));
2915 } catch (e) {
2916 reject(e);
2917 }
2918 }
2919
2920 function rejected(value) {
2921 try {
2922 step(generator["throw"](value));
2923 } catch (e) {
2924 reject(e);
2925 }
2926 }
2927
2928 function step(result) {
2929 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
2930 }
2931
2932 step((generator = generator.apply(thisArg, _arguments || [])).next());
2933 });
2934};
2935
2936var __generator = this && this.__generator || function (thisArg, body) {
2937 var _ = {
2938 label: 0,
2939 sent: function sent() {
2940 if (t[0] & 1) throw t[1];
2941 return t[1];
2942 },
2943 trys: [],
2944 ops: []
2945 },
2946 f,
2947 y,
2948 t,
2949 g;
2950 return g = {
2951 next: verb(0),
2952 "throw": verb(1),
2953 "return": verb(2)
2954 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
2955 return this;
2956 }), g;
2957
2958 function verb(n) {
2959 return function (v) {
2960 return step([n, v]);
2961 };
2962 }
2963
2964 function step(op) {
2965 if (f) throw new TypeError("Generator is already executing.");
2966
2967 while (_) {
2968 try {
2969 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;
2970 if (y = 0, t) op = [op[0] & 2, t.value];
2971
2972 switch (op[0]) {
2973 case 0:
2974 case 1:
2975 t = op;
2976 break;
2977
2978 case 4:
2979 _.label++;
2980 return {
2981 value: op[1],
2982 done: false
2983 };
2984
2985 case 5:
2986 _.label++;
2987 y = op[1];
2988 op = [0];
2989 continue;
2990
2991 case 7:
2992 op = _.ops.pop();
2993
2994 _.trys.pop();
2995
2996 continue;
2997
2998 default:
2999 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
3000 _ = 0;
3001 continue;
3002 }
3003
3004 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
3005 _.label = op[1];
3006 break;
3007 }
3008
3009 if (op[0] === 6 && _.label < t[1]) {
3010 _.label = t[1];
3011 t = op;
3012 break;
3013 }
3014
3015 if (t && _.label < t[2]) {
3016 _.label = t[2];
3017
3018 _.ops.push(op);
3019
3020 break;
3021 }
3022
3023 if (t[2]) _.ops.pop();
3024
3025 _.trys.pop();
3026
3027 continue;
3028 }
3029
3030 op = body.call(thisArg, _);
3031 } catch (e) {
3032 op = [6, e];
3033 y = 0;
3034 } finally {
3035 f = t = 0;
3036 }
3037 }
3038
3039 if (op[0] & 5) throw op[1];
3040 return {
3041 value: op[0] ? op[1] : void 0,
3042 done: true
3043 };
3044 }
3045};
3046
3047var __importStar = this && this.__importStar || function (mod) {
3048 if (mod && mod.__esModule) return mod;
3049 var result = {};
3050 if (mod != null) for (var k in mod) {
3051 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
3052 }
3053 result["default"] = mod;
3054 return result;
3055};
3056
3057Object.defineProperty(exports, "__esModule", {
3058 value: true
3059});
3060
3061var React = __importStar(__webpack_require__(/*! react */ "react"));
3062
3063var api_1 = __webpack_require__(/*! @aws-amplify/api */ "@aws-amplify/api");
3064
3065var Connect =
3066/** @class */
3067function (_super) {
3068 __extends(Connect, _super);
3069
3070 function Connect(props) {
3071 var _this = _super.call(this, props) || this;
3072
3073 _this.state = _this.getInitialState();
3074 _this.subSubscription = null;
3075 return _this;
3076 }
3077
3078 Connect.prototype.getInitialState = function () {
3079 var query = this.props.query;
3080 return {
3081 loading: query && !!query.query,
3082 data: {},
3083 errors: [],
3084 mutation: function mutation() {
3085 return console.warn('Not implemented');
3086 }
3087 };
3088 };
3089
3090 Connect.prototype.getDefaultState = function () {
3091 return {
3092 loading: false,
3093 data: {},
3094 errors: [],
3095 mutation: function mutation() {
3096 return console.warn('Not implemented');
3097 }
3098 };
3099 };
3100
3101 Connect.prototype._fetchData = function () {
3102 return __awaiter(this, void 0, void 0, function () {
3103 var _a, _b, _c, query, _d, variables, _e, _f, mutation, _g, mutationVariables, subscription, _h, onSubscriptionMsg, _j, data, mutationProp, errors, hasValidQuery, hasValidMutation, hasValidSubscription, response, err_1, subsQuery, subsVars, observable;
3104
3105 var _this = this;
3106
3107 return __generator(this, function (_k) {
3108 switch (_k.label) {
3109 case 0:
3110 this._unsubscribe();
3111
3112 this.setState({
3113 loading: true
3114 });
3115 _a = this.props, _b = _a.query, _c = _b === void 0 ? {} : _b, query = _c.query, _d = _c.variables, variables = _d === void 0 ? {} : _d, _e = _a.mutation, _f = _e === void 0 ? {} : _e, mutation = _f.query, _g = _f.mutationVariables, mutationVariables = _g === void 0 ? {} : _g, subscription = _a.subscription, _h = _a.onSubscriptionMsg, onSubscriptionMsg = _h === void 0 ? function (prevData) {
3116 return prevData;
3117 } : _h;
3118 _j = this.getDefaultState(), data = _j.data, mutationProp = _j.mutation, errors = _j.errors;
3119
3120 if (!api_1.API || typeof api_1.API.graphql !== 'function' || typeof api_1.API.getGraphqlOperationType !== 'function') {
3121 throw new Error('No API module found, please ensure @aws-amplify/api is imported');
3122 }
3123
3124 hasValidQuery = query && api_1.API.getGraphqlOperationType(query) === 'query';
3125 hasValidMutation = mutation && api_1.API.getGraphqlOperationType(mutation) === 'mutation';
3126 hasValidSubscription = subscription && api_1.API.getGraphqlOperationType(subscription.query) === 'subscription';
3127
3128 if (!hasValidQuery && !hasValidMutation && !hasValidSubscription) {
3129 console.warn('No query, mutation or subscription was specified');
3130 }
3131
3132 if (!hasValidQuery) return [3
3133 /*break*/
3134 , 4];
3135 _k.label = 1;
3136
3137 case 1:
3138 _k.trys.push([1, 3,, 4]);
3139
3140 data = null;
3141 return [4
3142 /*yield*/
3143 , api_1.API.graphql({
3144 query: query,
3145 variables: variables
3146 })];
3147
3148 case 2:
3149 response = _k.sent(); // @ts-ignore
3150
3151 data = response.data;
3152 return [3
3153 /*break*/
3154 , 4];
3155
3156 case 3:
3157 err_1 = _k.sent();
3158 data = err_1.data;
3159 errors = err_1.errors;
3160 return [3
3161 /*break*/
3162 , 4];
3163
3164 case 4:
3165 if (hasValidMutation) {
3166 // @ts-ignore
3167 mutationProp = function mutationProp(variables) {
3168 return __awaiter(_this, void 0, void 0, function () {
3169 var result;
3170 return __generator(this, function (_a) {
3171 switch (_a.label) {
3172 case 0:
3173 return [4
3174 /*yield*/
3175 , api_1.API.graphql({
3176 query: mutation,
3177 variables: variables
3178 })];
3179
3180 case 1:
3181 result = _a.sent();
3182 this.forceUpdate();
3183 return [2
3184 /*return*/
3185 , result];
3186 }
3187 });
3188 });
3189 };
3190 }
3191
3192 if (hasValidSubscription) {
3193 subsQuery = subscription.query, subsVars = subscription.variables;
3194
3195 try {
3196 observable = api_1.API.graphql({
3197 query: subsQuery,
3198 variables: subsVars
3199 }); // @ts-ignore
3200
3201 this.subSubscription = observable.subscribe({
3202 next: function next(_a) {
3203 var data = _a.value.data;
3204 var prevData = _this.state.data; // @ts-ignore
3205
3206 var newData = onSubscriptionMsg(prevData, data);
3207
3208 if (_this.mounted) {
3209 _this.setState({
3210 data: newData
3211 });
3212 }
3213 },
3214 error: function error(err) {
3215 return console.error(err);
3216 }
3217 });
3218 } catch (err) {
3219 errors = err.errors;
3220 }
3221 }
3222
3223 this.setState({
3224 data: data,
3225 errors: errors,
3226 mutation: mutationProp,
3227 loading: false
3228 });
3229 return [2
3230 /*return*/
3231 ];
3232 }
3233 });
3234 });
3235 };
3236
3237 Connect.prototype._unsubscribe = function () {
3238 if (this.subSubscription) {
3239 this.subSubscription.unsubscribe();
3240 }
3241 };
3242
3243 Connect.prototype.componentDidMount = function () {
3244 return __awaiter(this, void 0, void 0, function () {
3245 return __generator(this, function (_a) {
3246 this._fetchData();
3247
3248 this.mounted = true;
3249 return [2
3250 /*return*/
3251 ];
3252 });
3253 });
3254 };
3255
3256 Connect.prototype.componentWillUnmount = function () {
3257 this._unsubscribe();
3258
3259 this.mounted = false;
3260 };
3261
3262 Connect.prototype.componentDidUpdate = function (prevProps) {
3263 var loading = this.state.loading;
3264 var _a = this.props,
3265 newQueryObj = _a.query,
3266 newMutationObj = _a.mutation;
3267 var prevQueryObj = prevProps.query,
3268 prevMutationObj = prevProps.mutation; // query
3269 // @ts-ignore
3270
3271 var _b = newQueryObj || {},
3272 newQuery = _b.query,
3273 newQueryVariables = _b.variables; // @ts-ignore
3274
3275
3276 var _c = prevQueryObj || {},
3277 prevQuery = _c.query,
3278 prevQueryVariables = _c.variables;
3279
3280 var queryChanged = prevQuery !== newQuery || JSON.stringify(prevQueryVariables) !== JSON.stringify(newQueryVariables); // mutation
3281 // @ts-ignore
3282
3283 var _d = newMutationObj || {},
3284 newMutation = _d.query,
3285 newMutationVariables = _d.variables; // @ts-ignore
3286
3287
3288 var _e = prevMutationObj || {},
3289 prevMutation = _e.query,
3290 prevMutationVariables = _e.variables;
3291
3292 var mutationChanged = prevMutation !== newMutation || JSON.stringify(prevMutationVariables) !== JSON.stringify(newMutationVariables);
3293
3294 if (!loading && (queryChanged || mutationChanged)) {
3295 this._fetchData();
3296 }
3297 };
3298
3299 Connect.prototype.render = function () {
3300 var _a = this.state,
3301 data = _a.data,
3302 loading = _a.loading,
3303 mutation = _a.mutation,
3304 errors = _a.errors; // @ts-ignore
3305
3306 return this.props.children({
3307 data: data,
3308 errors: errors,
3309 loading: loading,
3310 mutation: mutation
3311 }) || null;
3312 };
3313
3314 return Connect;
3315}(React.Component);
3316
3317exports.Connect = Connect;
3318/**
3319 * @deprecated use named import
3320 */
3321
3322exports["default"] = Connect;
3323
3324/***/ }),
3325
3326/***/ "./lib/API/GraphQL/index.js":
3327/*!**********************************!*\
3328 !*** ./lib/API/GraphQL/index.js ***!
3329 \**********************************/
3330/*! no static exports found */
3331/***/ (function(module, exports, __webpack_require__) {
3332
3333"use strict";
3334
3335/*
3336 * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3337 *
3338 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
3339 * the License. A copy of the License is located at
3340 *
3341 * http://aws.amazon.com/apache2.0/
3342 *
3343 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
3344 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
3345 * and limitations under the License.
3346 */
3347
3348Object.defineProperty(exports, "__esModule", {
3349 value: true
3350});
3351
3352var Connect_1 = __webpack_require__(/*! ./Connect */ "./lib/API/GraphQL/Connect.js");
3353
3354exports.Connect = Connect_1.Connect;
3355
3356/***/ }),
3357
3358/***/ "./lib/API/index.js":
3359/*!**************************!*\
3360 !*** ./lib/API/index.js ***!
3361 \**************************/
3362/*! no static exports found */
3363/***/ (function(module, exports, __webpack_require__) {
3364
3365"use strict";
3366
3367
3368function __export(m) {
3369 for (var p in m) {
3370 if (!exports.hasOwnProperty(p)) exports[p] = m[p];
3371 }
3372}
3373
3374Object.defineProperty(exports, "__esModule", {
3375 value: true
3376});
3377
3378__export(__webpack_require__(/*! ./GraphQL */ "./lib/API/GraphQL/index.js"));
3379
3380/***/ }),
3381
3382/***/ "./lib/Amplify-UI/Amplify-UI-Components-React.js":
3383/*!*******************************************************!*\
3384 !*** ./lib/Amplify-UI/Amplify-UI-Components-React.js ***!
3385 \*******************************************************/
3386/*! no static exports found */
3387/***/ (function(module, exports, __webpack_require__) {
3388
3389"use strict";
3390
3391
3392var __assign = this && this.__assign || function () {
3393 __assign = Object.assign || function (t) {
3394 for (var s, i = 1, n = arguments.length; i < n; i++) {
3395 s = arguments[i];
3396
3397 for (var p in s) {
3398 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3399 }
3400 }
3401
3402 return t;
3403 };
3404
3405 return __assign.apply(this, arguments);
3406};
3407
3408var __importStar = this && this.__importStar || function (mod) {
3409 if (mod && mod.__esModule) return mod;
3410 var result = {};
3411 if (mod != null) for (var k in mod) {
3412 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
3413 }
3414 result["default"] = mod;
3415 return result;
3416};
3417
3418var __importDefault = this && this.__importDefault || function (mod) {
3419 return mod && mod.__esModule ? mod : {
3420 "default": mod
3421 };
3422};
3423
3424Object.defineProperty(exports, "__esModule", {
3425 value: true
3426});
3427
3428var React = __importStar(__webpack_require__(/*! react */ "react"));
3429
3430var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
3431
3432var AmplifyUI = __importStar(__webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui"));
3433
3434var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ./Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
3435
3436exports.Container = function (props) {
3437 var theme = props.theme || Amplify_UI_Theme_1["default"];
3438 var style = exports.propStyle(props, theme.container);
3439 var p = core_1.objectLessAttributes(props, 'theme');
3440 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3441 className: AmplifyUI.container,
3442 style: style
3443 }), props.children));
3444};
3445
3446exports.FormContainer = function (props) {
3447 var theme = props.theme || Amplify_UI_Theme_1["default"];
3448 return exports.beforeAfter(React.createElement("div", {
3449 className: AmplifyUI.formContainer,
3450 style: theme.formContainer
3451 }, props.children));
3452};
3453
3454exports.FormSection = function (props) {
3455 var theme = props.theme || Amplify_UI_Theme_1["default"];
3456 var style = exports.propStyle(props, theme.formSection);
3457 return React.createElement(exports.FormContainer, {
3458 theme: theme
3459 }, exports.beforeAfter(React.createElement("div", {
3460 className: AmplifyUI.formSection,
3461 style: style
3462 }, props.children)));
3463};
3464
3465exports.SectionHeader = function (props) {
3466 var theme = props.theme || Amplify_UI_Theme_1["default"];
3467 var style = exports.propStyle(props, theme.sectionHeader);
3468 var p = core_1.objectLessAttributes(props, 'theme');
3469 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3470 className: AmplifyUI.sectionHeader,
3471 style: style
3472 }), React.createElement(exports.SectionHeaderContent, {
3473 theme: theme
3474 }, props.children, props.hint && React.createElement("div", {
3475 className: AmplifyUI.sectionHeaderHint
3476 }, props.hint))));
3477};
3478
3479exports.SectionHeaderContent = function (props) {
3480 var theme = props.theme || Amplify_UI_Theme_1["default"];
3481 var style = exports.propStyle(props, theme.sectionHeaderContent);
3482 return exports.beforeAfter(React.createElement("span", {
3483 className: AmplifyUI.sectionHeaderContent,
3484 style: style
3485 }, props.children));
3486};
3487
3488exports.SectionFooter = function (props) {
3489 var theme = props.theme || Amplify_UI_Theme_1["default"];
3490 var style = exports.propStyle(props, theme.sectionFooter);
3491 var p = core_1.objectLessAttributes(props, 'theme');
3492 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3493 className: AmplifyUI.sectionFooter,
3494 style: style
3495 }), props.children));
3496};
3497
3498exports.SectionFooterPrimaryContent = function (props) {
3499 var theme = props.theme || Amplify_UI_Theme_1["default"];
3500 var style = exports.propStyle(props, theme.sectionFooterPrimaryContent);
3501 return exports.beforeAfter(React.createElement("span", {
3502 className: AmplifyUI.sectionFooterPrimaryContent,
3503 style: style
3504 }, props.children));
3505};
3506
3507exports.SectionFooterSecondaryContent = function (props) {
3508 var theme = props.theme || Amplify_UI_Theme_1["default"];
3509 var style = exports.propStyle(props, theme.sectionFooterSecondaryContent);
3510 return exports.beforeAfter(React.createElement("span", {
3511 className: AmplifyUI.sectionFooterSecondaryContent,
3512 style: style
3513 }, props.children));
3514};
3515
3516exports.SectionBody = function (props) {
3517 var theme = props.theme || Amplify_UI_Theme_1["default"];
3518 var style = exports.propStyle(props, theme.sectionBody);
3519 var p = core_1.objectLessAttributes(props, 'theme');
3520 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3521 className: AmplifyUI.sectionBody,
3522 style: style
3523 }), props.children));
3524};
3525
3526exports.ActionRow = function (props) {
3527 var theme = props.theme || Amplify_UI_Theme_1["default"];
3528 var style = exports.propStyle(props, theme.actionRow);
3529 var p = core_1.objectLessAttributes(props, 'theme');
3530 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3531 className: "amplify-action-row",
3532 style: style
3533 }), props.children));
3534};
3535
3536exports.Strike = function (props) {
3537 var theme = props.theme || Amplify_UI_Theme_1["default"];
3538 var style = exports.propStyle(props, theme.strike);
3539 return exports.beforeAfter(React.createElement("div", {
3540 className: AmplifyUI.strike,
3541 style: style
3542 }, React.createElement(exports.StrikeContent, {
3543 theme: theme
3544 }, props.children)));
3545};
3546
3547exports.StrikeContent = function (props) {
3548 var theme = props.theme || Amplify_UI_Theme_1["default"];
3549 return exports.beforeAfter(React.createElement("span", {
3550 className: AmplifyUI.strikeContent,
3551 style: theme.strikeContent
3552 }, props.children));
3553};
3554
3555exports.FormRow = function (props) {
3556 var theme = props.theme || Amplify_UI_Theme_1["default"];
3557 var style = exports.propStyle(props, theme.formRow);
3558 var p = core_1.objectLessAttributes(props, 'theme');
3559 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3560 className: AmplifyUI.formRow,
3561 style: style
3562 }), props.children));
3563};
3564
3565exports.RadioRow = function (props) {
3566 var id = props.id || '_' + props.value;
3567 var theme = props.theme || Amplify_UI_Theme_1["default"];
3568 return React.createElement(exports.FormRow, {
3569 theme: theme
3570 }, React.createElement(exports.Radio, __assign({}, props, {
3571 id: id
3572 })), React.createElement(exports.Label, {
3573 htmlFor: id,
3574 theme: theme
3575 }, props.placeholder));
3576};
3577
3578exports.Radio = function (props) {
3579 var theme = props.theme || Amplify_UI_Theme_1["default"];
3580 var style = exports.propStyle(props, theme.radio);
3581 var p = core_1.objectLessAttributes(props, 'theme');
3582 return exports.beforeAfter(React.createElement("input", __assign({}, p, {
3583 type: "radio",
3584 className: AmplifyUI.radio,
3585 style: style
3586 })));
3587};
3588
3589exports.InputRow = function (props) {
3590 var theme = props.theme || Amplify_UI_Theme_1["default"];
3591 var style = exports.propStyle(props, theme.input);
3592 var p = core_1.objectLessAttributes(props, 'theme');
3593 return React.createElement(exports.FormRow, {
3594 theme: theme
3595 }, exports.beforeAfter(React.createElement("input", __assign({}, p, {
3596 className: AmplifyUI.input,
3597 style: style
3598 }))));
3599};
3600
3601exports.Input = function (props) {
3602 var theme = props.theme || Amplify_UI_Theme_1["default"];
3603 var style = exports.propStyle(props, theme.input);
3604 var p = core_1.objectLessAttributes(props, 'theme');
3605 return React.createElement("input", __assign({}, p, {
3606 className: AmplifyUI.input,
3607 style: style
3608 }));
3609};
3610
3611exports.SelectInput = function (props) {
3612 var theme = props.theme || Amplify_UI_Theme_1["default"];
3613 var style = exports.propStyle(props, theme.selectInput);
3614 return React.createElement("div", {
3615 className: AmplifyUI.selectInput,
3616 style: style
3617 }, props.children);
3618};
3619
3620exports.FormField = function (props) {
3621 var theme = props.theme || Amplify_UI_Theme_1["default"];
3622 var style = exports.propStyle(props, theme.formField);
3623 var p = core_1.objectLessAttributes(props, 'theme');
3624 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3625 className: AmplifyUI.formField,
3626 style: style
3627 }), props.children));
3628};
3629
3630exports.Button = function (props) {
3631 var theme = props.theme || Amplify_UI_Theme_1["default"];
3632 var style = exports.propStyle(props, theme.button);
3633 var disabled = props.disabled || false;
3634 var p = core_1.objectLessAttributes(props, 'theme');
3635 return exports.beforeAfter(React.createElement("button", __assign({}, p, {
3636 className: AmplifyUI.button,
3637 style: style,
3638 disabled: disabled
3639 }), props.children));
3640};
3641
3642exports.PhotoPickerButton = function (props) {
3643 var theme = props.theme || Amplify_UI_Theme_1["default"];
3644 var style = exports.propStyle(props, theme.photoPickerButton);
3645 var p = core_1.objectLessAttributes(props, 'theme');
3646 return React.createElement("button", __assign({}, p, {
3647 className: [AmplifyUI.photoPickerButton, AmplifyUI.button].join(' '),
3648 style: style
3649 }), props.children);
3650};
3651
3652exports.SignInButton = function (props) {
3653 var theme = props.theme || Amplify_UI_Theme_1["default"];
3654 var styles = Object.assign({}, theme.signInButton, theme[props.variant]);
3655 var p = core_1.objectLessAttributes(props, 'theme');
3656 return exports.beforeAfter(React.createElement("button", __assign({}, p, {
3657 className: AmplifyUI.signInButton,
3658 style: styles
3659 }), props.children));
3660};
3661
3662exports.SignInButtonIcon = function (props) {
3663 var theme = props.theme || Amplify_UI_Theme_1["default"];
3664 var style = exports.propStyle(props, theme.signInButtonIcon);
3665 var p = core_1.objectLessAttributes(props, 'theme');
3666 return exports.beforeAfter(React.createElement("span", __assign({}, p, {
3667 className: AmplifyUI.signInButtonIcon,
3668 style: style
3669 }), props.children));
3670};
3671
3672exports.SignInButtonContent = function (props) {
3673 var theme = props.theme || Amplify_UI_Theme_1["default"];
3674 var style = exports.propStyle(props, theme.signInButtonContent);
3675 return exports.beforeAfter(React.createElement("span", {
3676 className: AmplifyUI.signInButtonContent,
3677 style: style
3678 }, props.children));
3679};
3680
3681exports.Link = function (props) {
3682 var theme = props.theme || Amplify_UI_Theme_1["default"];
3683 var style = exports.propStyle(props, theme.a);
3684 var p = core_1.objectLessAttributes(props, 'theme');
3685 return exports.beforeAfter(React.createElement("a", __assign({}, p, {
3686 className: AmplifyUI.a,
3687 style: style
3688 }), props.children));
3689};
3690
3691exports.Label = function (props) {
3692 var theme = props.theme || Amplify_UI_Theme_1["default"];
3693 var style = exports.propStyle(props, theme.label);
3694 var p = core_1.objectLessAttributes(props, 'theme');
3695 return exports.beforeAfter(React.createElement("label", __assign({}, p, {
3696 className: AmplifyUI.label,
3697 style: style
3698 }), props.children));
3699};
3700
3701exports.Hint = function (props) {
3702 var theme = props.theme || Amplify_UI_Theme_1["default"];
3703 var style = exports.propStyle(props, theme.hint);
3704 return exports.beforeAfter(React.createElement("div", {
3705 className: AmplifyUI.hint,
3706 style: style
3707 }, props.children));
3708};
3709
3710exports.InputLabel = function (props) {
3711 var theme = props.theme || Amplify_UI_Theme_1["default"];
3712 var style = exports.propStyle(props, theme.inputLabel);
3713 return exports.beforeAfter(React.createElement("div", {
3714 className: AmplifyUI.inputLabel,
3715 style: style
3716 }, props.children));
3717};
3718
3719exports.NavBar = function (props) {
3720 var theme = props.theme || Amplify_UI_Theme_1["default"];
3721 var style = exports.propStyle(props, theme.navBar);
3722 var p = core_1.objectLessAttributes(props, 'theme');
3723 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3724 className: AmplifyUI.navBar,
3725 style: style
3726 }), props.children));
3727};
3728
3729exports.Nav = function (props) {
3730 var theme = props.theme || Amplify_UI_Theme_1["default"];
3731 var style = exports.propStyle(props, theme.nav);
3732 var p = core_1.objectLessAttributes(props, 'theme');
3733 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3734 className: AmplifyUI.nav,
3735 style: style
3736 }), props.children));
3737};
3738
3739exports.NavRight = function (props) {
3740 var theme = props.theme || Amplify_UI_Theme_1["default"];
3741 var style = exports.propStyle(props, theme.navRight);
3742 var p = core_1.objectLessAttributes(props, 'theme');
3743 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3744 className: AmplifyUI.navRight,
3745 style: style
3746 }), props.children));
3747};
3748
3749exports.NavItem = function (props) {
3750 var theme = props.theme || Amplify_UI_Theme_1["default"];
3751 var style = exports.propStyle(props, theme.navItem);
3752 var p = core_1.objectLessAttributes(props, 'theme');
3753 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
3754 className: AmplifyUI.navItem,
3755 style: style
3756 }), props.children));
3757};
3758
3759exports.NavButton = function (props) {
3760 var theme = props.theme || Amplify_UI_Theme_1["default"];
3761 var style = exports.propStyle(props, theme.navButton);
3762 var p = core_1.objectLessAttributes(props, 'theme');
3763 return exports.beforeAfter(React.createElement("button", __assign({}, p, {
3764 className: AmplifyUI.button,
3765 style: style
3766 }), exports.beforeAfter(React.createElement("span", null, props.children))));
3767};
3768
3769exports.Toast = function (props) {
3770 var onClose = props.onClose;
3771 var theme = props.theme || Amplify_UI_Theme_1["default"];
3772 return React.createElement("div", __assign({}, props, {
3773 theme: theme,
3774 className: AmplifyUI.toast,
3775 style: theme.toast
3776 }), React.createElement("span", null, props.children), React.createElement("a", {
3777 className: AmplifyUI.toastClose,
3778 onClick: onClose
3779 }));
3780}; // @ts-ignore
3781
3782
3783exports.Toast.defaultProps = {
3784 onClose: function onClose() {
3785 return void 0;
3786 }
3787};
3788
3789exports.PhotoPlaceholder = function (props) {
3790 var theme = props.theme || Amplify_UI_Theme_1["default"];
3791 var style = exports.propStyle(props, theme.photoPlaceholder);
3792 return React.createElement("div", {
3793 className: AmplifyUI.photoPlaceholder,
3794 style: style
3795 }, React.createElement("div", {
3796 className: AmplifyUI.photoPlaceholderIcon
3797 }, React.createElement("svg", {
3798 xmlns: "http://www.w3.org/2000/svg",
3799 width: "64",
3800 height: "64",
3801 viewBox: "0 0 24 24"
3802 }, React.createElement("circle", {
3803 cx: "12",
3804 cy: "12",
3805 r: "3.2"
3806 }), React.createElement("path", {
3807 d: "M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"
3808 }), React.createElement("path", {
3809 d: "M0 0h24v24H0z",
3810 fill: "none"
3811 }))));
3812};
3813
3814exports.beforeAfter = function (el) {
3815 var style = el.props.style || {};
3816 var before = style.before,
3817 after = style.after;
3818
3819 if (!before && !after) {
3820 return el;
3821 }
3822
3823 return React.createElement("span", {
3824 style: {
3825 position: 'relative'
3826 }
3827 }, before ? React.createElement("span", {
3828 style: before
3829 }, before.content) : null, el, after ? React.createElement("span", {
3830 style: after
3831 }, after.content) : null);
3832};
3833
3834exports.propStyle = function (props, themeStyle) {
3835 var id = props.id,
3836 style = props.style;
3837 var styl = Object.assign({}, style, themeStyle);
3838
3839 if (!id) {
3840 return styl;
3841 }
3842
3843 var selector = '#' + id;
3844 Object.assign(styl, styl[selector]);
3845 return styl;
3846};
3847
3848/***/ }),
3849
3850/***/ "./lib/Amplify-UI/Amplify-UI-Theme.js":
3851/*!********************************************!*\
3852 !*** ./lib/Amplify-UI/Amplify-UI-Theme.js ***!
3853 \********************************************/
3854/*! no static exports found */
3855/***/ (function(module, exports, __webpack_require__) {
3856
3857"use strict";
3858
3859/*
3860 * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3861 *
3862 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
3863 * the License. A copy of the License is located at
3864 *
3865 * http://aws.amazon.com/apache2.0/
3866 *
3867 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
3868 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
3869 * and limitations under the License.
3870 */
3871
3872Object.defineProperty(exports, "__esModule", {
3873 value: true
3874});
3875exports.Container = {};
3876exports.FormContainer = {};
3877exports.FormSection = {};
3878exports.FormField = {};
3879exports.SectionHeader = {};
3880exports.SectionBody = {};
3881exports.SectionFooter = {};
3882exports.SectionFooterPrimaryContent = {};
3883exports.SectionFooterSecondaryContent = {};
3884exports.Input = {};
3885exports.Button = {};
3886exports.PhotoPickerButton = {};
3887exports.PhotoPlaceholder = {};
3888exports.SignInButton = {};
3889exports.SignInButtonIcon = {};
3890exports.SignInButtonContent = {};
3891exports.Strike = {};
3892exports.StrikeContent = {};
3893exports.ActionRow = {};
3894exports.FormRow = {};
3895exports.A = {};
3896exports.Hint = {};
3897exports.Radio = {};
3898exports.Label = {};
3899exports.InputLabel = {};
3900exports.AmazonSignInButton = {};
3901exports.FacebookSignInButton = {};
3902exports.GoogleSignInButton = {};
3903exports.OAuthSignInButton = {};
3904exports.Toast = {};
3905exports.NavBar = {};
3906exports.NavRight = {};
3907exports.Nav = {};
3908exports.NavItem = {};
3909exports.NavButton = {};
3910var AmplifyTheme = {
3911 container: exports.Container,
3912 formContainer: exports.FormContainer,
3913 formSection: exports.FormSection,
3914 formField: exports.FormField,
3915 sectionHeader: exports.SectionHeader,
3916 sectionBody: exports.SectionBody,
3917 sectionFooter: exports.SectionFooter,
3918 sectionFooterPrimaryContent: exports.SectionFooterPrimaryContent,
3919 sectionFooterSecondaryContent: exports.SectionFooterSecondaryContent,
3920 input: exports.Input,
3921 button: exports.Button,
3922 photoPickerButton: exports.PhotoPickerButton,
3923 photoPlaceholder: exports.PhotoPlaceholder,
3924 signInButton: exports.SignInButton,
3925 signInButtonIcon: exports.SignInButtonIcon,
3926 signInButtonContent: exports.SignInButtonContent,
3927 amazonSignInButton: exports.AmazonSignInButton,
3928 facebookSignInButton: exports.FacebookSignInButton,
3929 googleSignInButton: exports.GoogleSignInButton,
3930 oAuthSignInButton: exports.OAuthSignInButton,
3931 formRow: exports.FormRow,
3932 strike: exports.Strike,
3933 strikeContent: exports.StrikeContent,
3934 actionRow: exports.ActionRow,
3935 a: exports.A,
3936 hint: exports.Hint,
3937 radio: exports.Radio,
3938 label: exports.Label,
3939 inputLabel: exports.InputLabel,
3940 toast: exports.Toast,
3941 navBar: exports.NavBar,
3942 nav: exports.Nav,
3943 navRight: exports.NavRight,
3944 navItem: exports.NavItem,
3945 navButton: exports.NavButton
3946};
3947exports["default"] = AmplifyTheme;
3948
3949/***/ }),
3950
3951/***/ "./lib/Amplify-UI/data-test-attributes.js":
3952/*!************************************************!*\
3953 !*** ./lib/Amplify-UI/data-test-attributes.js ***!
3954 \************************************************/
3955/*! no static exports found */
3956/***/ (function(module, exports, __webpack_require__) {
3957
3958"use strict";
3959
3960
3961Object.defineProperty(exports, "__esModule", {
3962 value: true
3963}); // Auth
3964
3965var signIn = {
3966 section: 'sign-in-section',
3967 headerSection: 'sign-in-header-section',
3968 bodySection: 'sign-in-body-section',
3969 footerSection: 'sign-in-footer-section',
3970 usernameInput: 'username-input',
3971 passwordInput: 'sign-in-password-input',
3972 forgotPasswordLink: 'sign-in-forgot-password-link',
3973 signInButton: 'sign-in-sign-in-button',
3974 createAccountLink: 'sign-in-create-account-link',
3975 signInError: 'authenticator-error'
3976};
3977var signOut = {
3978 button: 'sign-out-button',
3979 section: 'sign-out-section'
3980};
3981var signUp = {
3982 section: 'sign-up-section',
3983 headerSection: 'sign-up-header-section',
3984 bodySection: 'sign-up-body-section',
3985 nonPhoneNumberInput: 'sign-up-non-phone-number-input',
3986 phoneNumberInput: 'sign-up-phone-number-input',
3987 dialCodeSelect: 'sign-up-dial-code-select',
3988 footerSection: 'sign-up-footer-section',
3989 createAccountButton: 'sign-up-create-account-button',
3990 signInLink: 'sign-up-sign-in-link',
3991 signUpButton: 'sign-up-sign-up-button',
3992 signInButton: 'sign-up-sign-in-button',
3993 confirmButton: 'sign-up-confirm-button'
3994};
3995var verifyContact = {
3996 section: 'verify-contact-section',
3997 headerSection: 'verify-contact-header-section',
3998 bodySection: 'verify-contact-body-section',
3999 submitButton: 'verify-contact-submit-button',
4000 verifyButton: 'verify-contact-verify-button',
4001 skipLink: 'verify-contact-skip-link'
4002};
4003var TOTPSetup = {
4004 component: 'totp-setup-component'
4005};
4006var requireNewPassword = {
4007 section: 'require-new-password-section',
4008 headerSection: 'require-new-password-header-section',
4009 footerSection: 'require-new-password-footer-section',
4010 bodySection: 'require-new-password-body-section',
4011 newPasswordInput: 'require-new-password-new-password-input',
4012 backToSignInLink: 'require-new-password-back-to-sign-in-link',
4013 submitButton: 'require-new-password-submit-button'
4014};
4015var loading = {
4016 section: 'loading-secton'
4017};
4018var greetings = {
4019 navBar: 'greetings-nav-bar',
4020 nav: 'greetings-nav',
4021 navRight: 'greetings-nav-right'
4022}; // TODO: Change Angular Component (Greeting) to match React Component (Greetings)
4023
4024var greeting = {
4025 signOutButton: 'sign-out-button',
4026 signOutLink: 'greeting-sign-out-link',
4027 navRight: 'greetings-nav-right'
4028};
4029var federatedSignIn = {
4030 section: 'federated-sign-in-section',
4031 bodySection: 'federated-sign-in-body-section',
4032 signInButtons: 'federated-sign-in-buttons'
4033};
4034var confirmSignUp = {
4035 section: 'confirm-sign-up-section',
4036 headerSection: 'confirm-sign-up-header-section',
4037 bodySection: 'confirm-sign-up-body-section',
4038 usernameInput: 'confirm-sign-up-username-input',
4039 confirmationCodeInput: 'confirm-sign-up-confirmation-code-input',
4040 resendCodeLink: 'confirm-sign-up-resend-code-link',
4041 confirmButton: 'confirm-sign-up-confirm-button',
4042 backToSignInLink: 'confirm-sign-up-back-to-sign-in-link'
4043};
4044var confirmSignIn = {
4045 section: 'confirm-sign-in-section',
4046 headerSection: 'confirm-sign-in-header-section',
4047 bodySection: 'confirm-sign-in-body-section',
4048 codeInput: 'confirm-sign-in-code-input',
4049 confirmButton: 'confirm-sign-in-confirm-button',
4050 backToSignInLink: 'confirm-sign-in-back-to-sign-in-link'
4051};
4052var setMFAComp = {
4053 section: 'set-mfa-section',
4054 headerSection: 'set-mfa-header-section',
4055 bodySection: 'set-mfa-header-body-section',
4056 smsInput: 'set-mfa-sms-input',
4057 totpInput: 'set-mfa-totp-input',
4058 noMfaInput: 'set-mfa-nomfa-input',
4059 verificationCodeInput: 'set-mfa-verification-code-input',
4060 setMfaButton: 'set-mfa-set-mfa-button',
4061 verifyTotpTokenButton: 'set-mfa-verify-totp-token-button',
4062 cancelButton: 'set-mfa-cancel-button'
4063};
4064var forgotPassword = {
4065 section: 'forgot-password-section',
4066 headerSection: 'forgot-password-header-section',
4067 bodySection: 'forgot-password-body-section',
4068 submitButton: 'forgot-password-submit-button',
4069 sendCodeButton: 'forgot-password-send-code-button',
4070 resendCodeLink: 'forgot-password-resend-code-link',
4071 backToSignInLink: 'forgot-password-back-to-sign-in-link',
4072 usernameInput: 'username-input',
4073 codeInput: 'forgot-password-code-input',
4074 newPasswordInput: 'forgot-password-new-password-input'
4075};
4076exports.sumerianScene = {
4077 container: 'sumerian-scene-container',
4078 sumerianScene: 'sumerian-scene',
4079 loading: 'sumerian-scene-loading',
4080 loadingLogo: 'sumerian-scene-loading-logo',
4081 loadingSceneName: 'sumerian-scene-loading-scene-name',
4082 loadingBar: 'sumerian-scene-loading-bar',
4083 errorText: 'sumerian-scene-error-text',
4084 bar: 'sumerian-scene-bar',
4085 actions: 'sumerian-scene-actions'
4086};
4087exports.genericAttrs = {
4088 usernameInput: 'username-input',
4089 emailInput: 'email-input',
4090 phoneNumberInput: 'phone-number-input',
4091 dialCodeSelect: 'dial-code-select'
4092};
4093exports.chatBot = {
4094 title: 'chatbot-title',
4095 dialog: 'chatbot-dialog',
4096 messageInput: 'chatbot-message-input',
4097 sendMessageButton: 'chatbot-send-message-button'
4098};
4099exports.auth = {
4100 signIn: signIn,
4101 signOut: signOut,
4102 signUp: signUp,
4103 verifyContact: verifyContact,
4104 TOTPSetup: TOTPSetup,
4105 requireNewPassword: requireNewPassword,
4106 loading: loading,
4107 genericAttrs: exports.genericAttrs,
4108 greetings: greetings,
4109 greeting: greeting,
4110 federatedSignIn: federatedSignIn,
4111 confirmSignUp: confirmSignUp,
4112 confirmSignIn: confirmSignIn,
4113 setMFAComp: setMFAComp,
4114 forgotPassword: forgotPassword
4115};
4116
4117/***/ }),
4118
4119/***/ "./lib/AmplifyI18n.js":
4120/*!****************************!*\
4121 !*** ./lib/AmplifyI18n.js ***!
4122 \****************************/
4123/*! no static exports found */
4124/***/ (function(module, exports, __webpack_require__) {
4125
4126"use strict";
4127
4128/*
4129 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4130 *
4131 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
4132 * the License. A copy of the License is located at
4133 *
4134 * http://aws.amazon.com/apache2.0/
4135 *
4136 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
4137 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
4138 * and limitations under the License.
4139 */
4140
4141Object.defineProperty(exports, "__esModule", {
4142 value: true
4143});
4144exports.dict = {
4145 de: {
4146 'Sign In': 'Anmelden',
4147 'Sign Up': 'Registrieren',
4148 'Sign Out': 'Abmelden',
4149 'Sign in to your account': 'Melden Sie sich mit Ihrem Account an',
4150 Username: 'Benutzername',
4151 Password: 'Passwort',
4152 'Enter your username': 'Geben Sie Ihren Benutzernamen ein',
4153 'Enter your password': 'Geben Sie Ihr Passwort ein',
4154 'No account? ': 'Kein Account? ',
4155 'Forgot your password? ': 'Passwort vergessen? ',
4156 'Reset password': 'Passwort zurücksetzen',
4157 'User does not exist': 'Dieser Benutzer existiert nicht',
4158 'User already exists': 'Dieser Benutzer existiert bereits',
4159 'Incorrect username or password': 'Falscher Benutzername oder falsches Passwort',
4160 'Invalid password format': 'Ungültiges Passwort-Format',
4161 'Create account': 'Hier registrieren',
4162 'Forgot Password': 'Passwort vergessen',
4163 'Change Password': 'Passwort ändern',
4164 'New Password': 'Neues Passwort',
4165 Email: 'Email',
4166 'Phone Number': 'Telefonnummer',
4167 'Confirm a Code': 'Code bestätigen',
4168 'Confirm Sign In': 'Anmeldung bestätigen',
4169 'Confirm Sign Up': 'Registrierung bestätigen',
4170 'Back to Sign In': 'Zurück zur Anmeldung',
4171 'Send Code': 'Code senden',
4172 Confirm: 'Bestätigen',
4173 'Resend Code': 'Code erneut senden',
4174 Submit: 'Abschicken',
4175 Skip: 'Überspringen',
4176 Verify: 'Verifizieren',
4177 'Verify Contact': 'Kontakt verifizieren',
4178 Code: 'Code',
4179 'Confirmation Code': 'Bestätigungs-Code',
4180 'Lost your code? ': 'Code verloren? ',
4181 'Account recovery requires verified contact information': 'Zurücksetzen des Account benötigt einen verifizierten Account',
4182 'Invalid phone number format': "Ung\xFCltiges Telefonummern-Format.\n Benutze eine Nummer im Format: +12345678900",
4183 'Create Account': 'Account erstellen',
4184 'Have an account? ': 'Schon registriert? ',
4185 'Sign in': 'Anmelden',
4186 'Create a new account': 'Erstelle einen neuen Account',
4187 'Reset your password': 'Zurücksetzen des Passworts',
4188 'An account with the given email already exists.': 'Ein Account mit dieser Email existiert bereits.',
4189 'Username cannot be empty': 'Benutzername darf nicht leer sein',
4190 'Password attempts exceeded': 'Die maximale Anzahl der fehlerhaften Anmeldeversuche wurde erreicht'
4191 },
4192 fr: {
4193 Hello: 'Bonjour',
4194 'Loading...': 'Chargement...',
4195 'Sign In': 'Se connecter',
4196 'Sign In with Amazon': 'Se connecter avec Amazon',
4197 'Sign In with Facebook': 'Se connecter avec Facebook',
4198 'Sign In with Google': 'Se connecter avec Google',
4199 'Sign in with AWS': 'Se connecter avec AWS',
4200 'Sign Up': "S'inscrire",
4201 'Sign Out': 'Déconnexion',
4202 'Forgot Password': 'Mot de passe oublié',
4203 Username: "Nom d'utilisateur",
4204 Password: 'Mot de passe',
4205 'Change Password': 'Modifier le mot de passe',
4206 Change: 'Modifier',
4207 'New Password': 'Nouveau mot de passe',
4208 Email: 'Email',
4209 'Phone Number': 'Numéro de téléphone',
4210 'Confirm a Code': 'Confirmer un code',
4211 'Confirm Sign In': 'Confirmer la connexion',
4212 'Confirm Sign Up': "Confirmer l'inscription",
4213 'Back to Sign In': 'Retour à la connexion',
4214 Send: 'Envoyer',
4215 'Send Code': "M'envoyer un code",
4216 Confirm: 'Confirmer',
4217 SMS: 'SMS',
4218 'Confirm SMS Code': 'Confirmer le code SMS',
4219 'Confirm TOTP Code': 'Confirmer le code TOTP',
4220 'Resend a Code': 'Renvoyer un code',
4221 Submit: 'Soumettre',
4222 Skip: 'Passer',
4223 Verify: 'Vérifier',
4224 'Verify Contact': 'Vérifier le contact',
4225 Code: 'Code',
4226 'Confirmation Code': 'Code de confirmation',
4227 'Account recovery requires verified contact information': 'La récupération du compte nécessite des informations de contact vérifiées',
4228 'User does not exist': "L'utilisateur n'existe pas",
4229 'User already exists': "L'utilisateur existe déjà",
4230 'Incorrect username or password': 'Identifiant ou mot de passe incorrect',
4231 'Invalid password format': 'Format de mot de passe invalide',
4232 'Invalid phone number format': "Format de num\xE9ro de t\xE9l\xE9phone invalide. Veuillez utiliser un format +12345678900",
4233 'Username/client id combination not found.': "L'utilisateur n'existe pas",
4234 'Network error': 'Erreur réseau',
4235 'Sign in to your account': 'Connexion à votre compte',
4236 'Forgot your password? ': 'Mot de passe oublié ? ',
4237 'Reset password': 'Réinitialisez votre mot de passe',
4238 'No account? ': 'Pas de compte ? ',
4239 'Create account': 'Créer un compte',
4240 'Create Account': 'Créer un compte',
4241 'Have an account? ': 'Déjà un compte ? ',
4242 'Sign in': 'Se connecter',
4243 'Create a new account': 'Créer un nouveau compte',
4244 'Reset your password': 'Réinitialisez votre mot de passe',
4245 'Enter your username': "Saisissez votre nom d'utilisateur",
4246 'Enter your password': 'Saisissez votre mot de passe',
4247 'Enter your phone number': 'Saisissez votre numéro de téléphone',
4248 'Enter your email': 'Saisissez votre adresse email',
4249 'Enter your code': 'Saisissez cotre code de confirmation',
4250 'Lost your code? ': 'Vous avez perdu votre code ? ',
4251 'Resend Code': 'Renvoyer le code',
4252 or: 'ou',
4253 'An account with the given email already exists.': 'Un utilisateur avec cette adresse email existe déjà.',
4254 'Username cannot be empty': "Le nom d'utilisateur doit être renseigné"
4255 },
4256 es: {
4257 'Sign In': 'Registrarse',
4258 'Sign Up': 'Regístrate',
4259 'Sign Out': 'Desconectar',
4260 'Forgot Password': 'Se te olvidó tu contraseña',
4261 Username: 'Nombre de usuario',
4262 Password: 'Contraseña',
4263 'Change Password': 'Cambia la contraseña',
4264 'New Password': 'Nueva contraseña',
4265 Email: 'Email',
4266 'Phone Number': 'Número de teléfono',
4267 'Confirm a Code': 'Confirmar un código',
4268 'Confirm Sign In': 'Confirmar inicio de sesión',
4269 'Confirm Sign Up': 'Confirmar Registrarse',
4270 'Back to Sign In': 'Volver a Iniciar sesión',
4271 'Send Code': 'Enviar código',
4272 Confirm: 'Confirmar',
4273 'Resend a Code': 'Reenviar un código',
4274 Submit: 'Enviar',
4275 Skip: 'Omitir',
4276 Verify: 'Verificar',
4277 'Verify Contact': 'Verificar contacto',
4278 Code: 'Código',
4279 'Account recovery requires verified contact information': 'La recuperación de la cuenta requiere información de contacto verificada',
4280 'User does not exist': 'el usuario no existe',
4281 'User already exists': 'El usuario ya existe',
4282 'Incorrect username or password': 'Nombre de usuario o contraseña incorrecta',
4283 'Invalid password format': 'Formato de contraseña inválido',
4284 'Invalid phone number format': "Formato de n\xFAmero de tel\xE9fono inv\xE1lido.\nUtilice el formato de n\xFAmero de tel\xE9fono +12345678900"
4285 },
4286 it: {
4287 'Account recovery requires verified contact information': 'Ripristino del conto richiede un account verificati',
4288 'An account with the given email already exists.': 'Un account con questa email esiste già.',
4289 'Back to Sign In': 'Torna alla Accesso',
4290 'Change Password': 'Cambia la password',
4291 Code: 'Codice',
4292 Confirm: 'Conferma',
4293 'Confirm Sign In': 'Conferma di applicazione',
4294 'Confirm Sign Up': 'Registrazione Conferma',
4295 'Confirm a Code': 'Codice Conferma',
4296 'Confirmation Code': 'Codice di verifica',
4297 'Create Account': 'Crea account',
4298 'Create a new account': 'Creare un nuovo account',
4299 'Create account': 'Registrati',
4300 Email: 'E-mail',
4301 'Enter your password': 'Inserire la password',
4302 'Enter your username': 'Inserisci il tuo nome utente',
4303 'Forgot your password?': 'Password dimenticata?',
4304 'Forgot Password': 'Password dimenticata',
4305 'Have an account? ': 'Già registrato?',
4306 'Incorrect username or password': 'Nome utente o password errati',
4307 'Invalid password format': 'Formato della password non valido',
4308 'Invalid phone number format': 'Utilizzo non valido Telefonummern formattare un numero nel formato :. 12.345.678,9 mille',
4309 'Lost your code?': 'Perso codice?',
4310 'New Password': 'Nuova password',
4311 'No account? ': 'Nessun account?',
4312 Password: 'Password',
4313 'Password attempts exceeded': 'Il numero massimo di tentativi di accesso falliti è stato raggiunto',
4314 'Phone Number': 'Numero di telefono',
4315 'Resend Code': 'Codice Rispedisci',
4316 'Reset password': 'Ripristina password',
4317 'Reset your password': 'Resetta password',
4318 'Send Code': 'Invia codice',
4319 'Sign In': 'Accesso',
4320 'Sign Out': 'Esci',
4321 'Sign Up': 'Iscriviti',
4322 'Sign in': 'Accesso',
4323 'Sign in to your account': 'Accedi con il tuo account a',
4324 Skip: 'Salta',
4325 Submit: 'Sottoscrivi',
4326 'User already exists': 'Questo utente esiste già',
4327 'User does not exist': 'Questo utente non esiste',
4328 Username: 'Nome utente',
4329 'Username cannot be empty': 'Nome utente non può essere vuoto',
4330 Verify: 'Verifica',
4331 'Verify Contact': 'Contatto verifica'
4332 },
4333 zh: {
4334 'Sign In': '登录',
4335 'Sign Up': '注册',
4336 'Sign Out': '退出',
4337 'Forgot Password': '忘记密码',
4338 Username: '用户名',
4339 Password: '密码',
4340 'Change Password': '改变密码',
4341 'New Password': '新密码',
4342 Email: '邮箱',
4343 'Phone Number': '电话',
4344 'Confirm a Code': '确认码',
4345 'Confirm Sign In': '确认登录',
4346 'Confirm Sign Up': '确认注册',
4347 'Back to Sign In': '回到登录',
4348 'Send Code': '发送确认码',
4349 Confirm: '确认',
4350 'Resend a Code': '重发确认码',
4351 Submit: '提交',
4352 Skip: '跳过',
4353 Verify: '验证',
4354 'Verify Contact': '验证联系方式',
4355 Code: '确认码',
4356 'Account recovery requires verified contact information': '账户恢复需要验证过的联系方式',
4357 'User does not exist': '用户不存在',
4358 'User already exists': '用户已经存在',
4359 'Incorrect username or password': '用户名或密码错误',
4360 'Invalid password format': '密码格式错误',
4361 'Invalid phone number format': '电话格式错误,请使用格式 +12345678900'
4362 },
4363 ja: {
4364 'Sign In': 'サインイン ',
4365 'Sign Up': '登録 ',
4366 'Sign Out': 'サインアウト ',
4367 'Sign in to your account': 'アカウントにサインイン ',
4368 Username: 'ユーザー名 ',
4369 Password: 'パスワード ',
4370 'Enter your username': 'ユーザー名を入力 ',
4371 'Enter your password': 'パスワードを入力 ',
4372 'No account? ': 'アカウントが無いとき ',
4373 'Forgot your password? ': 'パスワードを忘れましたか? ',
4374 'Reset password': 'パスワードをリセット ',
4375 'User does not exist': 'ユーザーが存在しません ',
4376 'User already exists': '既にユーザーが存在しています ',
4377 'Incorrect username or password': 'ユーザー名かパスワードが異なります ',
4378 'Invalid password format': 'パスワードの形式が無効です ',
4379 'Create account': 'アカウントを作る ',
4380 'Forgot Password': 'パスワードを忘れた ',
4381 'Change Password': 'パスワードを変える ',
4382 'New Password': '新しいパスワード',
4383 Email: 'メールアドレス',
4384 'Phone Number': '電話番号',
4385 'Confirm a Code': 'コードを確認',
4386 'Confirm Sign In': 'サインインする',
4387 'Confirm Sign Up': '登録する',
4388 'Back to Sign In': 'サインインに戻る',
4389 'Send Code': 'コードを送信',
4390 Confirm: '確定',
4391 'Resend Code': 'コードを再送信',
4392 Submit: '送信',
4393 Skip: 'スキップ',
4394 Verify: '確認',
4395 'Verify Contact': '連絡先を確認',
4396 Code: 'コード',
4397 'Confirmation Code': '確認コード',
4398 'Lost your code? ': 'コードを失くしましたか?',
4399 'Account recovery requires verified contact information': 'アカウントの復旧には確認済みの連絡先が必要です',
4400 'Invalid phone number format': '不正な電話番号の形式です。\n+12345678900 の形式で入力してください',
4401 'Create Account': 'アカウントを作る',
4402 'Have an account? ': 'アカウントを持っていますか?',
4403 'Sign in': 'サインイン',
4404 'Create a new account': '新しいアカウントを作る',
4405 'Reset your password': 'パスワードをリセットする',
4406 'An account with the given email already exists.': '入力されたメールアドレスのアカウントが既に存在します',
4407 'Username cannot be empty': 'ユーザー名は入力必須です',
4408 'Password attempts exceeded': 'サインインの試行回数が上限に達しました',
4409 'Sign In with Google': 'Googleでサインイン',
4410 'Sign In with Facebook': 'Facebookでサインイン'
4411 }
4412};
4413
4414/***/ }),
4415
4416/***/ "./lib/AmplifyMessageMap.js":
4417/*!**********************************!*\
4418 !*** ./lib/AmplifyMessageMap.js ***!
4419 \**********************************/
4420/*! no static exports found */
4421/***/ (function(module, exports, __webpack_require__) {
4422
4423"use strict";
4424
4425/*
4426 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4427 *
4428 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
4429 * the License. A copy of the License is located at
4430 *
4431 * http://aws.amazon.com/apache2.0/
4432 *
4433 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
4434 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
4435 * and limitations under the License.
4436 */
4437
4438Object.defineProperty(exports, "__esModule", {
4439 value: true
4440});
4441
4442var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
4443
4444exports.MapEntries = [['User does not exist', /user.*not.*exist/i], ['User already exists', /user.*already.*exist/i], ['Incorrect username or password', /incorrect.*username.*password/i], ['Invalid password format', /validation.*password/i], ['Invalid phone number format', /invalid.*phone/i, 'Invalid phone number format. Please use a phone number format of +12345678900']];
4445
4446function AmplifyMessageMap(message) {
4447 // @ts-ignore
4448 var match = exports.MapEntries.filter(function (entry) {
4449 return entry[1].test(message);
4450 });
4451
4452 if (match.length === 0) {
4453 return message;
4454 }
4455
4456 var entry = match[0];
4457 var msg = entry.length > 2 ? entry[2] : entry[0];
4458 return core_1.I18n.get(entry[0], msg);
4459}
4460
4461exports.AmplifyMessageMap = AmplifyMessageMap;
4462
4463/***/ }),
4464
4465/***/ "./lib/AmplifyTheme.js":
4466/*!*****************************!*\
4467 !*** ./lib/AmplifyTheme.js ***!
4468 \*****************************/
4469/*! no static exports found */
4470/***/ (function(module, exports, __webpack_require__) {
4471
4472"use strict";
4473
4474
4475Object.defineProperty(exports, "__esModule", {
4476 value: true
4477});
4478/*
4479 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4480 *
4481 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
4482 * the License. A copy of the License is located at
4483 *
4484 * http://aws.amazon.com/apache2.0/
4485 *
4486 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
4487 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
4488 * and limitations under the License.
4489 */
4490
4491exports.Container = {
4492 fontFamily: "-apple-system,\n BlinkMacSystemFont,\n \"Segoe UI\",\n Roboto,\n \"Helvetica Neue\",\n Arial,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\"",
4493 fontWeight: '400',
4494 lineHeight: '1.5',
4495 color: '#212529',
4496 textAlign: 'left',
4497 paddingLeft: '15px',
4498 paddingRight: '15px'
4499};
4500exports.NavBar = {
4501 position: 'relative',
4502 border: '1px solid transparent',
4503 borderColor: '#e7e7e7'
4504};
4505exports.NavRight = {
4506 textAlign: 'right'
4507};
4508exports.Nav = {
4509 margin: '7.5px'
4510};
4511exports.NavItem = {
4512 display: 'inline-block',
4513 padding: '10px 5px',
4514 lineHeight: '20px'
4515};
4516exports.NavButton = {
4517 display: 'inline-block',
4518 padding: '6px 12px',
4519 marginTop: '8px',
4520 marginBottom: '8px',
4521 fontSize: '14px',
4522 fontWeight: 400,
4523 lineHeight: '1.42857143',
4524 textAlign: 'center',
4525 whiteSpace: 'nowrap',
4526 verticalAlign: 'middle',
4527 touchAction: 'manipulation',
4528 cursor: 'pointer',
4529 userSelect: 'none',
4530 backgroundImage: 'none',
4531 border: '1px solid transparent',
4532 borderRadius: '4px',
4533 color: '#333',
4534 backgroundColor: '#fff',
4535 borderColor: '#ccc'
4536};
4537exports.FormContainer = {
4538 textAlign: 'center'
4539};
4540exports.FormSection = {
4541 marginBottom: '20px',
4542 backgroundColor: '#fff',
4543 border: '1px solid #ddd',
4544 borderRadius: '4px',
4545 textAlign: 'left',
4546 width: '400px',
4547 display: 'inline-block'
4548};
4549exports.ErrorSection = {
4550 marginBottom: '20px',
4551 color: '#fff',
4552 backgroundColor: '#f0ad4e',
4553 border: '1px solid #eea236',
4554 borderRadius: '4px',
4555 textAlign: 'left'
4556};
4557exports.SectionHeader = {
4558 color: '#fff',
4559 backgroundColor: '#337ab7',
4560 borderColor: '#337ab7',
4561 padding: '10px 15px',
4562 borderBottom: '1px solid transparent',
4563 borderTopLeftRadius: '3px',
4564 borderTopRightRadius: '3px',
4565 textAlign: 'center'
4566};
4567exports.SectionFooter = {
4568 color: '#333',
4569 backgroundColor: '#f5f5f5',
4570 padding: '10px 15px',
4571 borderTop: '1px solid #ddd',
4572 borderTopLeftRadius: '3px',
4573 borderTopRightRadius: '3px'
4574};
4575exports.SectionBody = {
4576 padding: '15px'
4577};
4578exports.FormRow = {
4579 marginBottom: '15px'
4580};
4581exports.ActionRow = {
4582 marginBottom: '15px'
4583};
4584exports.Input = {
4585 display: 'block',
4586 width: '100%',
4587 height: '34px',
4588 padding: '6px 12px',
4589 fontSize: '14px',
4590 lineHeight: '1.42857143',
4591 color: '#555',
4592 backgroundColor: '#fff',
4593 backgroundImage: 'none',
4594 border: '1px solid #ccc',
4595 borderRadius: '4px',
4596 boxShadow: 'inset 0 1px 1px rgba(0,0,0,.075)',
4597 boxSizing: 'border-box',
4598 transition: 'border-color ease-in-out .15s,box-shadow ease-in-out .15s'
4599};
4600exports.Button = {
4601 display: 'inline-block',
4602 padding: '6px 12px',
4603 marginBottom: '0',
4604 fontSize: '14px',
4605 fontWeight: 400,
4606 lineHeight: '1.42857143',
4607 textAlign: 'center',
4608 whiteSpace: 'nowrap',
4609 verticalAlign: 'middle',
4610 touchAction: 'manipulation',
4611 cursor: 'pointer',
4612 userSelect: 'none',
4613 backgroundImage: 'none',
4614 border: '1px solid transparent',
4615 borderRadius: '4px',
4616 color: '#333',
4617 backgroundColor: '#fff',
4618 borderColor: '#ccc'
4619};
4620exports.SignInButton = {
4621 position: 'relative',
4622 padding: '6px 12px 6px 44px',
4623 fontSize: '14px',
4624 textAlign: 'left',
4625 whiteSpace: 'nowrap',
4626 overflow: 'hidden',
4627 textOverflow: 'ellipsis',
4628 display: 'block',
4629 width: '100%',
4630 marginTop: '2px',
4631 '#google_signin_btn': {
4632 color: '#fff',
4633 backgroundColor: '#dd4b39',
4634 borderColor: 'rgba(0,0,0,0.2)'
4635 },
4636 '#facebook_signin_btn': {
4637 color: '#fff',
4638 backgroundColor: '#3b5998',
4639 borderColor: 'rgba(0,0,0,0.2)'
4640 }
4641};
4642exports.Space = {
4643 display: 'inline-block',
4644 width: '20px'
4645};
4646exports.A = {
4647 color: '#007bff',
4648 cursor: 'pointer'
4649};
4650exports.Pre = {
4651 overflow: 'auto',
4652 fontFamily: "Menlo,\n Monaco,\n Consolas,\n \"Courier New\",\n monospace",
4653 display: 'block',
4654 padding: '9.5px',
4655 margin: '0 0 10px',
4656 fontSize: '13px',
4657 lineHeight: '1.42857143',
4658 color: '#333',
4659 wordBreak: 'break-all',
4660 wordWrap: 'break-word',
4661 backgroundColor: '#f5f5f5',
4662 border: '1px solid #ccc',
4663 borderRadius: '4px'
4664};
4665exports.Col1 = {
4666 display: 'inline-block',
4667 width: '8.33333333%'
4668};
4669exports.Col2 = {
4670 display: 'inline-block',
4671 width: '16.66666667%'
4672};
4673exports.Col3 = {
4674 display: 'inline-block',
4675 width: '25%'
4676};
4677exports.Col4 = {
4678 display: 'inline-block',
4679 width: '33.33333333%'
4680};
4681exports.Col5 = {
4682 display: 'inline-block',
4683 width: '41.66666667%'
4684};
4685exports.Col6 = {
4686 display: 'inline-block',
4687 width: '50%'
4688};
4689exports.Col7 = {
4690 display: 'inline-block',
4691 width: '58.33333333%'
4692};
4693exports.Col8 = {
4694 display: 'inline-block',
4695 width: '66.66666667%'
4696};
4697exports.Col9 = {
4698 display: 'inline-block',
4699 width: '75%'
4700};
4701exports.Col10 = {
4702 display: 'inline-block',
4703 width: '83.33333333%'
4704};
4705exports.Col11 = {
4706 display: 'inline-block',
4707 width: '91.66666667%'
4708};
4709exports.Col12 = {
4710 display: 'inline-block',
4711 width: '100%'
4712};
4713exports.Hidden = {
4714 display: 'none'
4715};
4716exports.Bootstrap = {
4717 container: exports.Container,
4718 navBar: exports.NavBar,
4719 nav: exports.Nav,
4720 navRight: exports.NavRight,
4721 navItem: exports.NavItem,
4722 navButton: exports.NavButton,
4723 formContainer: exports.FormContainer,
4724 formSection: exports.FormSection,
4725 errorSection: exports.ErrorSection,
4726 sectionHeader: exports.SectionHeader,
4727 sectionBody: exports.SectionBody,
4728 sectionFooter: exports.SectionFooter,
4729 formRow: exports.FormRow,
4730 actionRow: exports.ActionRow,
4731 space: exports.Space,
4732 signInButton: exports.SignInButton,
4733 input: exports.Input,
4734 button: exports.Button,
4735 a: exports.A,
4736 pre: exports.Pre,
4737 col1: exports.Col1,
4738 col2: exports.Col2,
4739 col3: exports.Col3,
4740 col4: exports.Col4,
4741 col5: exports.Col5,
4742 col6: exports.Col6,
4743 col7: exports.Col7,
4744 col8: exports.Col8,
4745 col9: exports.Col9,
4746 col10: exports.Col10,
4747 col11: exports.Col11,
4748 col12: exports.Col12,
4749 hidden: exports.Hidden
4750};
4751/**
4752 * @deprecated use named import
4753 */
4754
4755exports["default"] = exports.Bootstrap;
4756
4757/***/ }),
4758
4759/***/ "./lib/AmplifyUI.js":
4760/*!**************************!*\
4761 !*** ./lib/AmplifyUI.js ***!
4762 \**************************/
4763/*! no static exports found */
4764/***/ (function(module, exports, __webpack_require__) {
4765
4766"use strict";
4767
4768/*
4769 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4770 *
4771 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
4772 * the License. A copy of the License is located at
4773 *
4774 * http://aws.amazon.com/apache2.0/
4775 *
4776 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
4777 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
4778 * and limitations under the License.
4779 */
4780
4781var __assign = this && this.__assign || function () {
4782 __assign = Object.assign || function (t) {
4783 for (var s, i = 1, n = arguments.length; i < n; i++) {
4784 s = arguments[i];
4785
4786 for (var p in s) {
4787 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
4788 }
4789 }
4790
4791 return t;
4792 };
4793
4794 return __assign.apply(this, arguments);
4795};
4796
4797var __importStar = this && this.__importStar || function (mod) {
4798 if (mod && mod.__esModule) return mod;
4799 var result = {};
4800 if (mod != null) for (var k in mod) {
4801 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
4802 }
4803 result["default"] = mod;
4804 return result;
4805};
4806
4807var __importDefault = this && this.__importDefault || function (mod) {
4808 return mod && mod.__esModule ? mod : {
4809 "default": mod
4810 };
4811};
4812
4813Object.defineProperty(exports, "__esModule", {
4814 value: true
4815});
4816
4817var React = __importStar(__webpack_require__(/*! react */ "react"));
4818
4819var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
4820
4821var AmplifyTheme_1 = __importDefault(__webpack_require__(/*! ./AmplifyTheme */ "./lib/AmplifyTheme.js"));
4822
4823exports.Container = function (props) {
4824 var theme = props.theme || AmplifyTheme_1["default"];
4825 var style = exports.propStyle(props, theme.container);
4826 var p = core_1.objectLessAttributes(props, 'theme');
4827 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
4828 className: "amplify-container",
4829 style: style
4830 }), props.children));
4831};
4832
4833exports.FormContainer = function (props) {
4834 var theme = props.theme || AmplifyTheme_1["default"];
4835 var style = exports.propStyle(props, theme.formContainer);
4836 return exports.beforeAfter(React.createElement("div", {
4837 className: "amplify-form-container",
4838 style: style
4839 }, props.children));
4840};
4841
4842exports.FormSection = function (props) {
4843 var theme = props.theme || AmplifyTheme_1["default"];
4844 var style = exports.propStyle(props, theme.formSection);
4845 return React.createElement(exports.FormContainer, {
4846 theme: theme
4847 }, exports.beforeAfter(React.createElement("div", {
4848 className: "amplify-form-section",
4849 style: style
4850 }, props.children)));
4851};
4852
4853exports.ErrorSection = function (props) {
4854 var theme = props.theme || AmplifyTheme_1["default"];
4855 var style = exports.propStyle(props, theme.errorSection);
4856 var p = core_1.objectLessAttributes(props, 'theme');
4857 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
4858 className: "amplify-error-section",
4859 style: style
4860 }), React.createElement(exports.ErrorSectionContent, null, props.children)));
4861};
4862
4863exports.ErrorSectionContent = function (props) {
4864 var theme = props.theme || AmplifyTheme_1["default"];
4865 var style = exports.propStyle(props, theme.errorSectionContent);
4866 return exports.beforeAfter(React.createElement("span", {
4867 className: "amplify-error-section-content",
4868 style: style
4869 }, props.children));
4870};
4871
4872exports.SectionHeader = function (props) {
4873 var theme = props.theme || AmplifyTheme_1["default"];
4874 var style = exports.propStyle(props, theme.sectionHeader);
4875 var p = core_1.objectLessAttributes(props, 'theme');
4876 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
4877 className: "amplify-section-header",
4878 style: style
4879 }), React.createElement(exports.SectionHeaderContent, {
4880 theme: theme
4881 }, props.children)));
4882};
4883
4884exports.SectionHeaderContent = function (props) {
4885 var theme = props.theme || AmplifyTheme_1["default"];
4886 var style = exports.propStyle(props, theme.sectionHeaderContent);
4887 return exports.beforeAfter(React.createElement("span", {
4888 className: "amplify-section-header-content",
4889 style: style
4890 }, props.children));
4891};
4892
4893exports.SectionFooter = function (props) {
4894 var theme = props.theme || AmplifyTheme_1["default"];
4895 var style = exports.propStyle(props, theme.sectionFooter);
4896 var p = core_1.objectLessAttributes(props, 'theme');
4897 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
4898 className: "amplify-section-footer",
4899 style: style
4900 }), React.createElement(exports.SectionFooterContent, {
4901 theme: theme
4902 }, props.children)));
4903};
4904
4905exports.SectionFooterContent = function (props) {
4906 var theme = props.theme || AmplifyTheme_1["default"];
4907 var style = exports.propStyle(props, theme.sectionFooterContent);
4908 return exports.beforeAfter(React.createElement("span", {
4909 className: "amplify-section-footer-content",
4910 style: style
4911 }, props.children));
4912};
4913
4914exports.SectionBody = function (props) {
4915 var theme = props.theme || AmplifyTheme_1["default"];
4916 var style = exports.propStyle(props, theme.sectionBody);
4917 var p = core_1.objectLessAttributes(props, 'theme');
4918 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
4919 className: "amplify-section-body",
4920 style: style
4921 }), props.children));
4922};
4923
4924exports.ActionRow = function (props) {
4925 var theme = props.theme || AmplifyTheme_1["default"];
4926 var style = exports.propStyle(props, theme.actionRow);
4927 var p = core_1.objectLessAttributes(props, 'theme');
4928 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
4929 className: "amplify-action-row",
4930 style: style
4931 }), props.children));
4932};
4933
4934exports.FormRow = function (props) {
4935 var theme = props.theme || AmplifyTheme_1["default"];
4936 var style = exports.propStyle(props, theme.formRow);
4937 var p = core_1.objectLessAttributes(props, 'theme');
4938 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
4939 className: "amplify-form-row",
4940 style: style
4941 }), props.children));
4942};
4943
4944exports.InputRow = function (props) {
4945 var theme = props.theme || AmplifyTheme_1["default"];
4946 var style = exports.propStyle(props, theme.input);
4947 var p = core_1.objectLessAttributes(props, 'theme');
4948 return React.createElement(exports.FormRow, {
4949 theme: theme
4950 }, exports.beforeAfter(React.createElement("input", __assign({}, p, {
4951 className: "amplify-input",
4952 style: style
4953 }))));
4954};
4955
4956exports.RadioRow = function (props) {
4957 var id = props.id || '_' + props.value;
4958 var theme = props.theme || AmplifyTheme_1["default"];
4959 return React.createElement(exports.FormRow, {
4960 theme: theme
4961 }, React.createElement(exports.Radio, __assign({}, props, {
4962 id: id
4963 })), React.createElement(exports.Label, {
4964 htmlFor: id,
4965 theme: theme
4966 }, props.placeholder));
4967};
4968
4969exports.Radio = function (props) {
4970 var theme = props.theme || AmplifyTheme_1["default"];
4971 var style = exports.propStyle(props, theme.radio);
4972 var p = core_1.objectLessAttributes(props, 'theme');
4973 return exports.beforeAfter(React.createElement("input", __assign({}, p, {
4974 type: "radio",
4975 className: "amplify-radio",
4976 style: style
4977 })));
4978};
4979
4980exports.CheckboxRow = function (props) {
4981 var id = props.id || '_' + props.name;
4982 var theme = props.theme || AmplifyTheme_1["default"];
4983 return React.createElement(exports.FormRow, {
4984 theme: theme
4985 }, React.createElement(exports.Checkbox, __assign({}, props, {
4986 id: id
4987 })), React.createElement(exports.Label, {
4988 htmlFor: id,
4989 theme: theme
4990 }, props.placeholder));
4991};
4992
4993exports.Checkbox = function (props) {
4994 var theme = props.theme || AmplifyTheme_1["default"];
4995 var style = exports.propStyle(props, theme.checkbox);
4996 var p = core_1.objectLessAttributes(props, 'theme');
4997 return exports.beforeAfter(React.createElement("input", __assign({}, p, {
4998 type: "checkbox",
4999 className: "amplify-checkbox",
5000 style: style
5001 })));
5002};
5003
5004exports.MessageRow = function (props) {
5005 var theme = props.theme || AmplifyTheme_1["default"];
5006 return React.createElement(exports.FormRow, {
5007 theme: theme
5008 }, React.createElement(exports.MessageContent, {
5009 theme: theme
5010 }, props.children));
5011};
5012
5013exports.MessageContent = function (props) {
5014 var theme = props.theme || AmplifyTheme_1["default"];
5015 return exports.beforeAfter(React.createElement("span", {
5016 className: "amplify-message-content",
5017 style: theme.messageContent
5018 }, props.children));
5019};
5020
5021exports.ButtonRow = function (props) {
5022 var theme = props.theme || AmplifyTheme_1["default"];
5023 return exports.beforeAfter(React.createElement("div", {
5024 className: "amplify-action-row",
5025 style: theme.actionRow
5026 }, React.createElement(exports.Button, __assign({}, props))));
5027};
5028
5029exports.Button = function (props) {
5030 var theme = props.theme || AmplifyTheme_1["default"];
5031 var style = exports.propStyle(props, theme.button);
5032 var p = core_1.objectLessAttributes(props, 'theme');
5033 return exports.beforeAfter(React.createElement("button", __assign({}, p, {
5034 className: "amplify-button",
5035 style: style
5036 }), React.createElement(exports.ButtonContent, {
5037 theme: theme
5038 }, props.children)));
5039};
5040
5041exports.ButtonContent = function (props) {
5042 var theme = props.theme || AmplifyTheme_1["default"];
5043 return exports.beforeAfter(React.createElement("span", {
5044 className: "amplify-button-content",
5045 style: theme.buttonContent
5046 }, props.children));
5047};
5048
5049exports.SignInButton = function (props) {
5050 var theme = props.theme || AmplifyTheme_1["default"];
5051 var style = exports.propStyle(props, theme.signInButton);
5052 var p = core_1.objectLessAttributes(props, 'theme');
5053 return exports.beforeAfter(React.createElement("button", __assign({}, p, {
5054 className: "amplify-signin-button",
5055 style: style
5056 }), props.children));
5057};
5058
5059exports.Link = function (props) {
5060 var theme = props.theme || AmplifyTheme_1["default"];
5061 var style = exports.propStyle(props, theme.a);
5062 var p = core_1.objectLessAttributes(props, 'theme');
5063 return exports.beforeAfter(React.createElement("a", __assign({}, p, {
5064 className: "amplify-a",
5065 style: style
5066 }), props.children));
5067};
5068
5069exports.Label = function (props) {
5070 var theme = props.theme || AmplifyTheme_1["default"];
5071 var style = exports.propStyle(props, theme.label);
5072 var p = core_1.objectLessAttributes(props, 'theme');
5073 return exports.beforeAfter(React.createElement("label", __assign({}, p, {
5074 className: "amplify-label",
5075 style: style
5076 }), props.children));
5077};
5078
5079exports.Space = function (props) {
5080 var theme = props.theme || AmplifyTheme_1["default"];
5081 var style = exports.propStyle(props, theme.space);
5082 var p = core_1.objectLessAttributes(props, 'theme');
5083 return exports.beforeAfter(React.createElement("span", __assign({}, p, {
5084 className: "amplify-space",
5085 style: style
5086 }), props.children));
5087};
5088
5089exports.NavBar = function (props) {
5090 var theme = props.theme || AmplifyTheme_1["default"];
5091 var style = exports.propStyle(props, theme.navBar);
5092 var p = core_1.objectLessAttributes(props, 'theme');
5093 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
5094 className: "amplify-nav-bar",
5095 style: style
5096 }), props.children));
5097};
5098
5099exports.Nav = function (props) {
5100 var theme = props.theme || AmplifyTheme_1["default"];
5101 var style = exports.propStyle(props, theme.nav);
5102 var p = core_1.objectLessAttributes(props, 'theme');
5103 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
5104 className: "amplify-nav",
5105 style: style
5106 }), props.children));
5107};
5108
5109exports.NavRight = function (props) {
5110 var theme = props.theme || AmplifyTheme_1["default"];
5111 var style = exports.propStyle(props, theme.navRight);
5112 var p = core_1.objectLessAttributes(props, 'theme');
5113 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
5114 className: "amplify-nav-right",
5115 style: style
5116 }), props.children));
5117};
5118
5119exports.NavItem = function (props) {
5120 var theme = props.theme || AmplifyTheme_1["default"];
5121 var style = exports.propStyle(props, theme.navItem);
5122 var p = core_1.objectLessAttributes(props, 'theme');
5123 return exports.beforeAfter(React.createElement("div", __assign({}, p, {
5124 className: "amplify-nav-item",
5125 style: style
5126 }), props.children));
5127};
5128
5129exports.NavButton = function (props) {
5130 var theme = props.theme || AmplifyTheme_1["default"];
5131 var style = exports.propStyle(props, theme.navButton);
5132 var p = core_1.objectLessAttributes(props, 'theme');
5133 return exports.beforeAfter(React.createElement("button", __assign({}, p, {
5134 className: "amplify-nav-button",
5135 style: style
5136 }), exports.beforeAfter(React.createElement("span", {
5137 style: theme.navButtonContent
5138 }, props.children))));
5139};
5140
5141exports.beforeAfter = function (el) {
5142 var style = el.props.style || {};
5143 var before = style.before,
5144 after = style.after;
5145
5146 if (!before && !after) {
5147 return el;
5148 }
5149
5150 return React.createElement("span", {
5151 style: {
5152 position: 'relative'
5153 }
5154 }, before ? React.createElement("span", {
5155 style: before
5156 }, before.content) : null, el, after ? React.createElement("span", {
5157 style: after
5158 }, after.content) : null);
5159};
5160
5161exports.propStyle = function (props, themeStyle) {
5162 var id = props.id,
5163 style = props.style;
5164 var styl = Object.assign({}, style, themeStyle);
5165
5166 if (!id) {
5167 return styl;
5168 }
5169
5170 var selector = '#' + id;
5171 Object.assign(styl, styl[selector]);
5172 return styl;
5173};
5174
5175exports.transparent1X1 = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
5176exports.white1X1 = 'data:image/gif;base64,R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
5177
5178/***/ }),
5179
5180/***/ "./lib/Analytics/index.js":
5181/*!********************************!*\
5182 !*** ./lib/Analytics/index.js ***!
5183 \********************************/
5184/*! no static exports found */
5185/***/ (function(module, exports, __webpack_require__) {
5186
5187"use strict";
5188
5189/*
5190 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5191 *
5192 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5193 * the License. A copy of the License is located at
5194 *
5195 * http://aws.amazon.com/apache2.0/
5196 *
5197 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
5198 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
5199 * and limitations under the License.
5200 */
5201
5202function __export(m) {
5203 for (var p in m) {
5204 if (!exports.hasOwnProperty(p)) exports[p] = m[p];
5205 }
5206}
5207
5208Object.defineProperty(exports, "__esModule", {
5209 value: true
5210});
5211
5212__export(__webpack_require__(/*! ./trackLifecycle */ "./lib/Analytics/trackLifecycle.js"));
5213
5214__export(__webpack_require__(/*! ./trackUpdate */ "./lib/Analytics/trackUpdate.js"));
5215
5216/***/ }),
5217
5218/***/ "./lib/Analytics/trackLifecycle.js":
5219/*!*****************************************!*\
5220 !*** ./lib/Analytics/trackLifecycle.js ***!
5221 \*****************************************/
5222/*! no static exports found */
5223/***/ (function(module, exports, __webpack_require__) {
5224
5225"use strict";
5226
5227/*
5228 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5229 *
5230 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5231 * the License. A copy of the License is located at
5232 *
5233 * http://aws.amazon.com/apache2.0/
5234 *
5235 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
5236 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
5237 * and limitations under the License.
5238 */
5239
5240var __extends = this && this.__extends || function () {
5241 var _extendStatics = function extendStatics(d, b) {
5242 _extendStatics = Object.setPrototypeOf || {
5243 __proto__: []
5244 } instanceof Array && function (d, b) {
5245 d.__proto__ = b;
5246 } || function (d, b) {
5247 for (var p in b) {
5248 if (b.hasOwnProperty(p)) d[p] = b[p];
5249 }
5250 };
5251
5252 return _extendStatics(d, b);
5253 };
5254
5255 return function (d, b) {
5256 _extendStatics(d, b);
5257
5258 function __() {
5259 this.constructor = d;
5260 }
5261
5262 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5263 };
5264}();
5265
5266var __assign = this && this.__assign || function () {
5267 __assign = Object.assign || function (t) {
5268 for (var s, i = 1, n = arguments.length; i < n; i++) {
5269 s = arguments[i];
5270
5271 for (var p in s) {
5272 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
5273 }
5274 }
5275
5276 return t;
5277 };
5278
5279 return __assign.apply(this, arguments);
5280};
5281
5282var __importStar = this && this.__importStar || function (mod) {
5283 if (mod && mod.__esModule) return mod;
5284 var result = {};
5285 if (mod != null) for (var k in mod) {
5286 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
5287 }
5288 result["default"] = mod;
5289 return result;
5290};
5291
5292Object.defineProperty(exports, "__esModule", {
5293 value: true
5294});
5295
5296var React = __importStar(__webpack_require__(/*! react */ "react"));
5297
5298var analytics_1 = __webpack_require__(/*! @aws-amplify/analytics */ "@aws-amplify/analytics");
5299
5300var Default_Track_Events = ['componentDidMount', 'componentDidUpdate', 'compomentWillUnmount', 'compomentDidCatch', 'render'];
5301
5302function trackLifecycle(Comp, trackerName, events) {
5303 if (events === void 0) {
5304 events = Default_Track_Events;
5305 }
5306
5307 return (
5308 /** @class */
5309 function (_super) {
5310 __extends(WithTrackLifecycle, _super);
5311
5312 function WithTrackLifecycle(props) {
5313 var _this = _super.call(this, props) || this;
5314
5315 _this.trackerName = trackerName;
5316 _this.trackEvents = events;
5317
5318 _this.track('constructor');
5319
5320 return _this;
5321 }
5322
5323 WithTrackLifecycle.prototype.track = function (event) {
5324 var filtered = this.trackEvents.filter(function (item) {
5325 return item === event;
5326 });
5327
5328 if (filtered.length > 0) {
5329 if (analytics_1.Analytics && typeof analytics_1.Analytics.record === 'function') {
5330 analytics_1.Analytics.record({
5331 name: this.trackerName,
5332 attributes: {
5333 event: event
5334 }
5335 });
5336 } else {
5337 throw new Error('No Analytics module found, please ensure @aws-amplify/analytics is imported');
5338 }
5339 }
5340 };
5341
5342 WithTrackLifecycle.prototype.componentWillMount = function () {
5343 this.track('componentWillMount');
5344 };
5345
5346 WithTrackLifecycle.prototype.componentDidMount = function () {
5347 this.track('componentDidMount');
5348 };
5349
5350 WithTrackLifecycle.prototype.componentWillUnmount = function () {
5351 this.track('componentWillUnmount');
5352 };
5353
5354 WithTrackLifecycle.prototype.componentDidCatch = function () {
5355 this.track('componentDidCatch');
5356 };
5357
5358 WithTrackLifecycle.prototype.componentWillReceiveProps = function () {
5359 this.track('componentWillReceiveProps');
5360 };
5361
5362 WithTrackLifecycle.prototype.shouldComponentUpdate = function () {
5363 this.track('shouldComponentUpdate');
5364 return true;
5365 };
5366
5367 WithTrackLifecycle.prototype.componentWillUpdate = function () {
5368 this.track('componentWillUpdate');
5369 };
5370
5371 WithTrackLifecycle.prototype.componentDidUpdate = function () {
5372 this.track('componentDidUpdate');
5373 };
5374
5375 WithTrackLifecycle.prototype.setState = function () {
5376 this.track('setState');
5377 };
5378
5379 WithTrackLifecycle.prototype.forceUpdate = function () {
5380 this.track('forceUpdate');
5381 };
5382
5383 WithTrackLifecycle.prototype.render = function () {
5384 this.track('render');
5385 return React.createElement(Comp, __assign({}, this.props));
5386 };
5387
5388 return WithTrackLifecycle;
5389 }(React.Component)
5390 );
5391}
5392
5393exports.trackLifecycle = trackLifecycle;
5394
5395/***/ }),
5396
5397/***/ "./lib/Analytics/trackUpdate.js":
5398/*!**************************************!*\
5399 !*** ./lib/Analytics/trackUpdate.js ***!
5400 \**************************************/
5401/*! no static exports found */
5402/***/ (function(module, exports, __webpack_require__) {
5403
5404"use strict";
5405
5406/*
5407 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5408 *
5409 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5410 * the License. A copy of the License is located at
5411 *
5412 * http://aws.amazon.com/apache2.0/
5413 *
5414 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
5415 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
5416 * and limitations under the License.
5417 */
5418
5419var __extends = this && this.__extends || function () {
5420 var _extendStatics = function extendStatics(d, b) {
5421 _extendStatics = Object.setPrototypeOf || {
5422 __proto__: []
5423 } instanceof Array && function (d, b) {
5424 d.__proto__ = b;
5425 } || function (d, b) {
5426 for (var p in b) {
5427 if (b.hasOwnProperty(p)) d[p] = b[p];
5428 }
5429 };
5430
5431 return _extendStatics(d, b);
5432 };
5433
5434 return function (d, b) {
5435 _extendStatics(d, b);
5436
5437 function __() {
5438 this.constructor = d;
5439 }
5440
5441 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5442 };
5443}();
5444
5445var __assign = this && this.__assign || function () {
5446 __assign = Object.assign || function (t) {
5447 for (var s, i = 1, n = arguments.length; i < n; i++) {
5448 s = arguments[i];
5449
5450 for (var p in s) {
5451 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
5452 }
5453 }
5454
5455 return t;
5456 };
5457
5458 return __assign.apply(this, arguments);
5459};
5460
5461var __importStar = this && this.__importStar || function (mod) {
5462 if (mod && mod.__esModule) return mod;
5463 var result = {};
5464 if (mod != null) for (var k in mod) {
5465 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
5466 }
5467 result["default"] = mod;
5468 return result;
5469};
5470
5471Object.defineProperty(exports, "__esModule", {
5472 value: true
5473});
5474
5475var React = __importStar(__webpack_require__(/*! react */ "react"));
5476
5477var analytics_1 = __webpack_require__(/*! @aws-amplify/analytics */ "@aws-amplify/analytics");
5478
5479function trackUpdate(Comp, trackerName) {
5480 return (
5481 /** @class */
5482 function (_super) {
5483 __extends(class_1, _super);
5484
5485 function class_1(props) {
5486 var _this = _super.call(this, props) || this;
5487
5488 _this.trackerName = trackerName;
5489 return _this;
5490 }
5491
5492 class_1.prototype.componentDidUpdate = function (prevProps, prevState) {
5493 var attributes = Object.assign({}, this.props, this.state);
5494
5495 if (analytics_1.Analytics && typeof analytics_1.Analytics.record === 'function') {
5496 analytics_1.Analytics.record({
5497 name: this.trackerName,
5498 attributes: attributes
5499 });
5500 } else {
5501 throw new Error('No Analytics module found, please ensure @aws-amplify/analytics is imported');
5502 }
5503 };
5504
5505 class_1.prototype.render = function () {
5506 return React.createElement(Comp, __assign({}, this.props));
5507 };
5508
5509 return class_1;
5510 }(React.Component)
5511 );
5512}
5513
5514exports.trackUpdate = trackUpdate;
5515
5516/***/ }),
5517
5518/***/ "./lib/Auth/AuthPiece.js":
5519/*!*******************************!*\
5520 !*** ./lib/Auth/AuthPiece.js ***!
5521 \*******************************/
5522/*! no static exports found */
5523/***/ (function(module, exports, __webpack_require__) {
5524
5525"use strict";
5526
5527/*
5528 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5529 *
5530 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5531 * the License. A copy of the License is located at
5532 *
5533 * http://aws.amazon.com/apache2.0/
5534 *
5535 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
5536 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
5537 * and limitations under the License.
5538 */
5539
5540function _typeof(obj) {
5541 "@babel/helpers - typeof";
5542
5543 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
5544 _typeof = function _typeof(obj) {
5545 return typeof obj;
5546 };
5547 } else {
5548 _typeof = function _typeof(obj) {
5549 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
5550 };
5551 }
5552
5553 return _typeof(obj);
5554}
5555
5556var __extends = this && this.__extends || function () {
5557 var _extendStatics = function extendStatics(d, b) {
5558 _extendStatics = Object.setPrototypeOf || {
5559 __proto__: []
5560 } instanceof Array && function (d, b) {
5561 d.__proto__ = b;
5562 } || function (d, b) {
5563 for (var p in b) {
5564 if (b.hasOwnProperty(p)) d[p] = b[p];
5565 }
5566 };
5567
5568 return _extendStatics(d, b);
5569 };
5570
5571 return function (d, b) {
5572 _extendStatics(d, b);
5573
5574 function __() {
5575 this.constructor = d;
5576 }
5577
5578 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5579 };
5580}();
5581
5582var __importStar = this && this.__importStar || function (mod) {
5583 if (mod && mod.__esModule) return mod;
5584 var result = {};
5585 if (mod != null) for (var k in mod) {
5586 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
5587 }
5588 result["default"] = mod;
5589 return result;
5590};
5591
5592var __importDefault = this && this.__importDefault || function (mod) {
5593 return mod && mod.__esModule ? mod : {
5594 "default": mod
5595 };
5596};
5597
5598var _a;
5599
5600Object.defineProperty(exports, "__esModule", {
5601 value: true
5602});
5603
5604var React = __importStar(__webpack_require__(/*! react */ "react"));
5605
5606var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
5607
5608var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
5609
5610var types_1 = __webpack_require__(/*! ./common/types */ "./lib/Auth/common/types.js");
5611
5612var PhoneField_1 = __webpack_require__(/*! ./PhoneField */ "./lib/Auth/PhoneField.js");
5613
5614var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
5615
5616var AmplifyTheme_1 = __importDefault(__webpack_require__(/*! ../AmplifyTheme */ "./lib/AmplifyTheme.js"));
5617
5618var labelMap = (_a = {}, _a[types_1.UsernameAttributes.EMAIL] = 'Email', _a[types_1.UsernameAttributes.PHONE_NUMBER] = 'Phone Number', _a[types_1.UsernameAttributes.USERNAME] = 'Username', _a);
5619
5620var AuthPiece =
5621/** @class */
5622function (_super) {
5623 __extends(AuthPiece, _super);
5624
5625 function AuthPiece(props) {
5626 var _this = _super.call(this, props) || this;
5627
5628 _this.inputs = {};
5629 _this._isHidden = true;
5630 _this._validAuthStates = [];
5631 _this.phone_number = '';
5632 _this.changeState = _this.changeState.bind(_this);
5633 _this.error = _this.error.bind(_this);
5634 _this.handleInputChange = _this.handleInputChange.bind(_this);
5635 _this.renderUsernameField = _this.renderUsernameField.bind(_this);
5636 _this.getUsernameFromInput = _this.getUsernameFromInput.bind(_this);
5637 _this.onPhoneNumberChanged = _this.onPhoneNumberChanged.bind(_this);
5638 return _this;
5639 }
5640
5641 AuthPiece.prototype.componentDidMount = function () {
5642 if (window && window.location && window.location.search) {
5643 if (!this.props.authData || !this.props.authData.username) {
5644 var searchParams = new URLSearchParams(window.location.search);
5645 var username = searchParams ? searchParams.get('username') : undefined;
5646 this.setState({
5647 username: username
5648 });
5649 }
5650 }
5651 };
5652
5653 AuthPiece.prototype.getUsernameFromInput = function () {
5654 var _a = this.props.usernameAttributes,
5655 usernameAttributes = _a === void 0 ? 'username' : _a;
5656
5657 switch (usernameAttributes) {
5658 case types_1.UsernameAttributes.EMAIL:
5659 return this.inputs.email;
5660
5661 case types_1.UsernameAttributes.PHONE_NUMBER:
5662 return this.phone_number;
5663
5664 default:
5665 return this.inputs.username || this.state.username;
5666 }
5667 };
5668
5669 AuthPiece.prototype.onPhoneNumberChanged = function (phone_number) {
5670 this.phone_number = phone_number;
5671 };
5672
5673 AuthPiece.prototype.renderUsernameField = function (theme) {
5674 var _a = this.props.usernameAttributes,
5675 usernameAttributes = _a === void 0 ? [] : _a;
5676
5677 if (usernameAttributes === types_1.UsernameAttributes.EMAIL) {
5678 return React.createElement(Amplify_UI_Components_React_1.FormField, {
5679 theme: theme
5680 }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
5681 theme: theme
5682 }, core_1.I18n.get('Email'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
5683 autoFocus: true,
5684 placeholder: core_1.I18n.get('Enter your email'),
5685 theme: theme,
5686 key: "email",
5687 name: "email",
5688 type: "email",
5689 onChange: this.handleInputChange,
5690 "data-test": data_test_attributes_1.auth.genericAttrs.emailInput
5691 }));
5692 } else if (usernameAttributes === types_1.UsernameAttributes.PHONE_NUMBER) {
5693 return React.createElement(PhoneField_1.PhoneField, {
5694 theme: theme,
5695 onChangeText: this.onPhoneNumberChanged
5696 });
5697 } else {
5698 return React.createElement(Amplify_UI_Components_React_1.FormField, {
5699 theme: theme
5700 }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
5701 theme: theme
5702 }, core_1.I18n.get(this.getUsernameLabel()), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
5703 defaultValue: this.state.username,
5704 autoFocus: true,
5705 placeholder: core_1.I18n.get('Enter your username'),
5706 theme: theme,
5707 key: "username",
5708 name: "username",
5709 onChange: this.handleInputChange,
5710 "data-test": data_test_attributes_1.auth.genericAttrs.usernameInput
5711 }));
5712 }
5713 };
5714
5715 AuthPiece.prototype.getUsernameLabel = function () {
5716 var _a = this.props.usernameAttributes,
5717 usernameAttributes = _a === void 0 ? types_1.UsernameAttributes.USERNAME : _a;
5718 return labelMap[usernameAttributes] || usernameAttributes;
5719 }; // extract username from authData
5720
5721
5722 AuthPiece.prototype.usernameFromAuthData = function () {
5723 var authData = this.props.authData;
5724
5725 if (!authData) {
5726 return '';
5727 }
5728
5729 var username = '';
5730
5731 if (_typeof(authData) === 'object') {
5732 // user object
5733 username = authData.user ? authData.user.username : authData.username;
5734 } else {
5735 username = authData; // username string
5736 }
5737
5738 return username;
5739 };
5740
5741 AuthPiece.prototype.errorMessage = function (err) {
5742 if (typeof err === 'string') {
5743 return err;
5744 }
5745
5746 return err.message ? err.message : JSON.stringify(err);
5747 };
5748
5749 AuthPiece.prototype.triggerAuthEvent = function (event) {
5750 var state = this.props.authState;
5751
5752 if (this.props.onAuthEvent) {
5753 this.props.onAuthEvent(state, event);
5754 }
5755 };
5756
5757 AuthPiece.prototype.changeState = function (state, data) {
5758 if (this.props.onStateChange) {
5759 this.props.onStateChange(state, data);
5760 }
5761
5762 this.triggerAuthEvent({
5763 type: 'stateChange',
5764 data: state
5765 });
5766 };
5767
5768 AuthPiece.prototype.error = function (err) {
5769 this.triggerAuthEvent({
5770 type: 'error',
5771 data: this.errorMessage(err)
5772 });
5773 };
5774
5775 AuthPiece.prototype.handleInputChange = function (evt) {
5776 this.inputs = this.inputs || {};
5777 var _a = evt.target,
5778 name = _a.name,
5779 value = _a.value,
5780 type = _a.type,
5781 checked = _a.checked;
5782 var check_type = ['radio', 'checkbox'].includes(type);
5783 this.inputs[name] = check_type ? checked : value;
5784 this.inputs['checkedValue'] = check_type ? value : null;
5785 };
5786
5787 AuthPiece.prototype.render = function () {
5788 if (!this._validAuthStates.includes(this.props.authState)) {
5789 this._isHidden = true;
5790 this.inputs = {};
5791 return null;
5792 }
5793
5794 if (this._isHidden) {
5795 this.inputs = {};
5796 var track = this.props.track;
5797 if (track) track();
5798 }
5799
5800 this._isHidden = false;
5801 return this.showComponent(this.props.theme || AmplifyTheme_1["default"]);
5802 };
5803
5804 AuthPiece.prototype.showComponent = function (_theme) {
5805 throw 'You must implement showComponent(theme) and don\'t forget to set this._validAuthStates.';
5806 };
5807
5808 return AuthPiece;
5809}(React.Component);
5810
5811exports.AuthPiece = AuthPiece;
5812/**
5813 * @deprecated use named import
5814 */
5815
5816exports["default"] = AuthPiece;
5817
5818/***/ }),
5819
5820/***/ "./lib/Auth/Authenticator.js":
5821/*!***********************************!*\
5822 !*** ./lib/Auth/Authenticator.js ***!
5823 \***********************************/
5824/*! no static exports found */
5825/***/ (function(module, exports, __webpack_require__) {
5826
5827"use strict";
5828
5829/*
5830 * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5831 *
5832 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5833 * the License. A copy of the License is located at
5834 *
5835 * http://aws.amazon.com/apache2.0/
5836 *
5837 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
5838 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
5839 * and limitations under the License.
5840 */
5841
5842function _typeof(obj) {
5843 "@babel/helpers - typeof";
5844
5845 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
5846 _typeof = function _typeof(obj) {
5847 return typeof obj;
5848 };
5849 } else {
5850 _typeof = function _typeof(obj) {
5851 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
5852 };
5853 }
5854
5855 return _typeof(obj);
5856}
5857
5858var __extends = this && this.__extends || function () {
5859 var _extendStatics = function extendStatics(d, b) {
5860 _extendStatics = Object.setPrototypeOf || {
5861 __proto__: []
5862 } instanceof Array && function (d, b) {
5863 d.__proto__ = b;
5864 } || function (d, b) {
5865 for (var p in b) {
5866 if (b.hasOwnProperty(p)) d[p] = b[p];
5867 }
5868 };
5869
5870 return _extendStatics(d, b);
5871 };
5872
5873 return function (d, b) {
5874 _extendStatics(d, b);
5875
5876 function __() {
5877 this.constructor = d;
5878 }
5879
5880 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5881 };
5882}();
5883
5884var __importStar = this && this.__importStar || function (mod) {
5885 if (mod && mod.__esModule) return mod;
5886 var result = {};
5887 if (mod != null) for (var k in mod) {
5888 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
5889 }
5890 result["default"] = mod;
5891 return result;
5892};
5893
5894var __importDefault = this && this.__importDefault || function (mod) {
5895 return mod && mod.__esModule ? mod : {
5896 "default": mod
5897 };
5898};
5899
5900Object.defineProperty(exports, "__esModule", {
5901 value: true
5902});
5903
5904var React = __importStar(__webpack_require__(/*! react */ "react"));
5905
5906var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
5907
5908var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
5909
5910var Greetings_1 = __webpack_require__(/*! ./Greetings */ "./lib/Auth/Greetings.js");
5911
5912var SignIn_1 = __webpack_require__(/*! ./SignIn */ "./lib/Auth/SignIn.js");
5913
5914var ConfirmSignIn_1 = __webpack_require__(/*! ./ConfirmSignIn */ "./lib/Auth/ConfirmSignIn.js");
5915
5916var RequireNewPassword_1 = __webpack_require__(/*! ./RequireNewPassword */ "./lib/Auth/RequireNewPassword.js");
5917
5918var SignUp_1 = __webpack_require__(/*! ./SignUp */ "./lib/Auth/SignUp.js");
5919
5920var Loading_1 = __webpack_require__(/*! ./Loading */ "./lib/Auth/Loading.js");
5921
5922var ConfirmSignUp_1 = __webpack_require__(/*! ./ConfirmSignUp */ "./lib/Auth/ConfirmSignUp.js");
5923
5924var VerifyContact_1 = __webpack_require__(/*! ./VerifyContact */ "./lib/Auth/VerifyContact.js");
5925
5926var ForgotPassword_1 = __webpack_require__(/*! ./ForgotPassword */ "./lib/Auth/ForgotPassword.js");
5927
5928var TOTPSetup_1 = __webpack_require__(/*! ./TOTPSetup */ "./lib/Auth/TOTPSetup.js");
5929
5930var constants_1 = __webpack_require__(/*! ./common/constants */ "./lib/Auth/common/constants.js");
5931
5932var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
5933
5934var AmplifyMessageMap_1 = __webpack_require__(/*! ../AmplifyMessageMap */ "./lib/AmplifyMessageMap.js");
5935
5936var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
5937
5938var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
5939
5940var logger = new core_1.ConsoleLogger('Authenticator');
5941var AUTHENTICATOR_AUTHSTATE = 'amplify-authenticator-authState';
5942
5943exports.EmptyContainer = function (_a) {
5944 var children = _a.children;
5945 return React.createElement(React.Fragment, null, children);
5946};
5947
5948var Authenticator =
5949/** @class */
5950function (_super) {
5951 __extends(Authenticator, _super);
5952
5953 function Authenticator(props) {
5954 var _this = _super.call(this, props) || this;
5955
5956 _this.handleStateChange = _this.handleStateChange.bind(_this);
5957 _this.handleAuthEvent = _this.handleAuthEvent.bind(_this);
5958 _this.onHubCapsule = _this.onHubCapsule.bind(_this);
5959 _this._initialAuthState = _this.props.authState || 'signIn';
5960 _this.state = {
5961 authState: 'loading'
5962 };
5963 core_1.Hub.listen('auth', _this.onHubCapsule);
5964 return _this;
5965 }
5966
5967 Authenticator.prototype.componentDidMount = function () {
5968 var config = this.props.amplifyConfig;
5969
5970 if (config) {
5971 core_1.Amplify.configure(config);
5972 }
5973
5974 this._isMounted = true; // The workaround for Cognito Hosted UI:
5975 // Don't check the user immediately if redirected back from Hosted UI as
5976 // it might take some time for credentials to be available, instead
5977 // wait for the hub event sent from Auth module. This item in the
5978 // localStorage is a mark to indicate whether the app is just redirected
5979 // back from Hosted UI or not and is set in Auth:handleAuthResponse.
5980
5981 var byHostedUI = localStorage.getItem(constants_1.Constants.REDIRECTED_FROM_HOSTED_UI);
5982 localStorage.removeItem(constants_1.Constants.REDIRECTED_FROM_HOSTED_UI);
5983 if (byHostedUI !== 'true') this.checkUser();
5984 };
5985
5986 Authenticator.prototype.componentWillUnmount = function () {
5987 this._isMounted = false;
5988 };
5989
5990 Authenticator.prototype.checkUser = function () {
5991 var _this = this;
5992
5993 if (!auth_1.Auth || typeof auth_1.Auth.currentAuthenticatedUser !== 'function') {
5994 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
5995 }
5996
5997 return auth_1.Auth.currentAuthenticatedUser().then(function (user) {
5998 if (!_this._isMounted) {
5999 return;
6000 }
6001
6002 _this.handleStateChange('signedIn', user);
6003 })["catch"](function (err) {
6004 if (!_this._isMounted) {
6005 return;
6006 }
6007
6008 var cachedAuthState = null;
6009
6010 try {
6011 cachedAuthState = localStorage.getItem(AUTHENTICATOR_AUTHSTATE);
6012 } catch (e) {
6013 logger.debug('Failed to get the auth state from local storage', e);
6014 }
6015
6016 var promise = cachedAuthState === 'signedIn' ? auth_1.Auth.signOut() : Promise.resolve();
6017 promise.then(function () {
6018 return _this.handleStateChange(_this._initialAuthState);
6019 })["catch"](function (e) {
6020 logger.debug('Failed to sign out', e);
6021 });
6022 });
6023 };
6024
6025 Authenticator.prototype.checkContact = function (user, changeState) {
6026 if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
6027 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
6028 }
6029
6030 auth_1.Auth.verifiedContact(user).then(function (data) {
6031 if (!core_1.isEmpty(data.verified)) {
6032 changeState('signedIn', user);
6033 } else {
6034 user = Object.assign(user, data);
6035 changeState('verifyContact', user);
6036 }
6037 });
6038 };
6039
6040 Authenticator.prototype.onHubCapsule = function (capsule) {
6041 var channel = capsule.channel,
6042 payload = capsule.payload,
6043 source = capsule.source;
6044
6045 if (channel === 'auth') {
6046 switch (payload.event) {
6047 case 'cognitoHostedUI':
6048 case 'signIn':
6049 this.checkContact(payload.data, this.handleStateChange);
6050 break;
6051
6052 case 'cognitoHostedUI_failure':
6053 this.handleStateChange('signIn', null);
6054 break;
6055
6056 case 'parsingUrl_failure':
6057 this.handleStateChange('signIn', null);
6058 break;
6059
6060 case 'signOut':
6061 this.handleStateChange('signIn', null);
6062 break;
6063
6064 case 'customGreetingSignOut':
6065 this.handleStateChange('signIn', null);
6066 break;
6067
6068 default:
6069 break;
6070 }
6071 }
6072 };
6073
6074 Authenticator.prototype.handleStateChange = function (state, data) {
6075 logger.debug('authenticator state change ' + state, data);
6076
6077 if (state === this.state.authState) {
6078 return;
6079 }
6080
6081 if (state === 'signedOut') {
6082 state = 'signIn';
6083 }
6084
6085 try {
6086 localStorage.setItem(AUTHENTICATOR_AUTHSTATE, state);
6087 } catch (e) {
6088 logger.debug('Failed to set the auth state into local storage', e);
6089 }
6090
6091 if (this._isMounted) {
6092 this.setState({
6093 authState: state,
6094 authData: data,
6095 error: null,
6096 showToast: false
6097 });
6098 }
6099
6100 if (this.props.onStateChange) {
6101 this.props.onStateChange(state, data);
6102 }
6103 };
6104
6105 Authenticator.prototype.handleAuthEvent = function (state, event, showToast) {
6106 if (showToast === void 0) {
6107 showToast = true;
6108 }
6109
6110 if (event.type === 'error') {
6111 var map = this.props.errorMessage || AmplifyMessageMap_1.AmplifyMessageMap;
6112 var message = typeof map === 'string' ? map : map(event.data);
6113 this.setState({
6114 error: message,
6115 showToast: showToast
6116 });
6117 }
6118 };
6119
6120 Authenticator.prototype.render = function () {
6121 var _this = this;
6122
6123 var _a = this.state,
6124 authState = _a.authState,
6125 authData = _a.authData;
6126 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
6127 var messageMap = this.props.errorMessage || AmplifyMessageMap_1.AmplifyMessageMap; // If container prop is undefined, default to AWS Amplify UI Container
6128 // otherwise if truthy, use the supplied render prop
6129 // otherwise if falsey, use EmptyContainer
6130
6131 var Wrapper = this.props.container === undefined ? Amplify_UI_Components_React_1.Container : this.props.container || exports.EmptyContainer;
6132 var _b = this.props,
6133 hideDefault = _b.hideDefault,
6134 _c = _b.hide,
6135 hide = _c === void 0 ? [] : _c,
6136 federated = _b.federated,
6137 signUpConfig = _b.signUpConfig,
6138 usernameAttributes = _b.usernameAttributes;
6139
6140 if (hideDefault) {
6141 hide = hide.concat([Greetings_1.Greetings, SignIn_1.SignIn, ConfirmSignIn_1.ConfirmSignIn, RequireNewPassword_1.RequireNewPassword, SignUp_1.SignUp, ConfirmSignUp_1.ConfirmSignUp, VerifyContact_1.VerifyContact, ForgotPassword_1.ForgotPassword, TOTPSetup_1.TOTPSetup, Loading_1.Loading]);
6142 }
6143
6144 var props_children = [];
6145
6146 if (_typeof(this.props.children) === 'object') {
6147 if (Array.isArray(this.props.children)) {
6148 props_children = this.props.children;
6149 } else {
6150 props_children.push(this.props.children);
6151 }
6152 }
6153
6154 var default_children = [React.createElement(Greetings_1.Greetings, {
6155 federated: federated
6156 }), React.createElement(SignIn_1.SignIn, {
6157 federated: federated
6158 }), React.createElement(ConfirmSignIn_1.ConfirmSignIn, null), React.createElement(RequireNewPassword_1.RequireNewPassword, null), React.createElement(SignUp_1.SignUp, {
6159 signUpConfig: signUpConfig
6160 }), React.createElement(ConfirmSignUp_1.ConfirmSignUp, null), React.createElement(VerifyContact_1.VerifyContact, null), React.createElement(ForgotPassword_1.ForgotPassword, null), React.createElement(TOTPSetup_1.TOTPSetup, null), React.createElement(Loading_1.Loading, null)];
6161 var props_children_override = React.Children.map(props_children, function (child) {
6162 return child.props.override;
6163 });
6164 hide = hide.filter(function (component) {
6165 return !props_children.find(function (child) {
6166 return child.type === component;
6167 });
6168 });
6169 var render_props_children = React.Children.map(props_children, function (child, index) {
6170 return React.cloneElement(child, {
6171 key: 'aws-amplify-authenticator-props-children-' + index,
6172 theme: theme,
6173 messageMap: messageMap,
6174 authState: authState,
6175 authData: authData,
6176 onStateChange: _this.handleStateChange,
6177 onAuthEvent: _this.handleAuthEvent,
6178 hide: hide,
6179 override: props_children_override,
6180 usernameAttributes: usernameAttributes
6181 });
6182 });
6183 var render_default_children = hideDefault ? [] : React.Children.map(default_children, function (child, index) {
6184 return React.cloneElement(child, {
6185 key: 'aws-amplify-authenticator-default-children-' + index,
6186 theme: theme,
6187 messageMap: messageMap,
6188 authState: authState,
6189 authData: authData,
6190 onStateChange: _this.handleStateChange,
6191 onAuthEvent: _this.handleAuthEvent,
6192 hide: hide,
6193 override: props_children_override,
6194 usernameAttributes: usernameAttributes
6195 });
6196 });
6197 var render_children = render_default_children.concat(render_props_children);
6198 var error = this.state.error;
6199 return React.createElement(Wrapper, {
6200 theme: theme
6201 }, this.state.showToast && React.createElement(Amplify_UI_Components_React_1.Toast, {
6202 theme: theme,
6203 onClose: function onClose() {
6204 return _this.setState({
6205 showToast: false
6206 });
6207 },
6208 "data-test": data_test_attributes_1.auth.signIn.signInError
6209 }, core_1.I18n.get(error)), render_children);
6210 };
6211
6212 return Authenticator;
6213}(React.Component);
6214
6215exports.Authenticator = Authenticator;
6216/**
6217 * @deprecated use named import
6218 */
6219
6220exports["default"] = Authenticator;
6221
6222/***/ }),
6223
6224/***/ "./lib/Auth/ConfirmSignIn.js":
6225/*!***********************************!*\
6226 !*** ./lib/Auth/ConfirmSignIn.js ***!
6227 \***********************************/
6228/*! no static exports found */
6229/***/ (function(module, exports, __webpack_require__) {
6230
6231"use strict";
6232
6233/*
6234 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6235 *
6236 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
6237 * the License. A copy of the License is located at
6238 *
6239 * http://aws.amazon.com/apache2.0/
6240 *
6241 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
6242 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
6243 * and limitations under the License.
6244 */
6245
6246var __extends = this && this.__extends || function () {
6247 var _extendStatics = function extendStatics(d, b) {
6248 _extendStatics = Object.setPrototypeOf || {
6249 __proto__: []
6250 } instanceof Array && function (d, b) {
6251 d.__proto__ = b;
6252 } || function (d, b) {
6253 for (var p in b) {
6254 if (b.hasOwnProperty(p)) d[p] = b[p];
6255 }
6256 };
6257
6258 return _extendStatics(d, b);
6259 };
6260
6261 return function (d, b) {
6262 _extendStatics(d, b);
6263
6264 function __() {
6265 this.constructor = d;
6266 }
6267
6268 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6269 };
6270}();
6271
6272var __importStar = this && this.__importStar || function (mod) {
6273 if (mod && mod.__esModule) return mod;
6274 var result = {};
6275 if (mod != null) for (var k in mod) {
6276 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6277 }
6278 result["default"] = mod;
6279 return result;
6280};
6281
6282Object.defineProperty(exports, "__esModule", {
6283 value: true
6284});
6285
6286var React = __importStar(__webpack_require__(/*! react */ "react"));
6287
6288var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
6289
6290var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
6291
6292var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
6293
6294var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
6295
6296var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
6297
6298var ConfirmSignIn =
6299/** @class */
6300function (_super) {
6301 __extends(ConfirmSignIn, _super);
6302
6303 function ConfirmSignIn(props) {
6304 var _this = _super.call(this, props) || this;
6305
6306 _this._validAuthStates = ['confirmSignIn'];
6307 _this.confirm = _this.confirm.bind(_this);
6308 _this.checkContact = _this.checkContact.bind(_this);
6309 _this.state = {
6310 mfaType: 'SMS'
6311 };
6312 return _this;
6313 }
6314
6315 ConfirmSignIn.prototype.checkContact = function (user) {
6316 var _this = this;
6317
6318 if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
6319 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
6320 }
6321
6322 auth_1.Auth.verifiedContact(user).then(function (data) {
6323 if (!core_1.isEmpty(data.verified)) {
6324 _this.changeState('signedIn', user);
6325 } else {
6326 var newUser = Object.assign(user, data);
6327
6328 _this.changeState('verifyContact', newUser);
6329 }
6330 });
6331 };
6332
6333 ConfirmSignIn.prototype.confirm = function (event) {
6334 var _this = this;
6335
6336 if (event) {
6337 event.preventDefault();
6338 }
6339
6340 var user = this.props.authData;
6341 var code = this.inputs.code;
6342 var mfaType = user.challengeName === 'SOFTWARE_TOKEN_MFA' ? 'SOFTWARE_TOKEN_MFA' : null;
6343
6344 if (!auth_1.Auth || typeof auth_1.Auth.confirmSignIn !== 'function') {
6345 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
6346 }
6347
6348 auth_1.Auth.confirmSignIn(user, code, mfaType).then(function () {
6349 _this.checkContact(user);
6350 })["catch"](function (err) {
6351 return _this.error(err);
6352 });
6353 };
6354
6355 ConfirmSignIn.prototype.componentDidUpdate = function () {
6356 // logger.debug('component did update with props', this.props);
6357 var user = this.props.authData;
6358 var mfaType = user && user.challengeName === 'SOFTWARE_TOKEN_MFA' ? 'TOTP' : 'SMS';
6359 if (this.state.mfaType !== mfaType) this.setState({
6360 mfaType: mfaType
6361 });
6362 };
6363
6364 ConfirmSignIn.prototype.showComponent = function (theme) {
6365 var _this = this;
6366
6367 var hide = this.props.hide;
6368
6369 if (hide && hide.includes(ConfirmSignIn)) {
6370 return null;
6371 }
6372
6373 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
6374 theme: theme,
6375 "data-test": data_test_attributes_1.auth.confirmSignIn.section
6376 }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
6377 theme: theme,
6378 "data-test": data_test_attributes_1.auth.confirmSignIn.headerSection
6379 }, core_1.I18n.get('Confirm ' + this.state.mfaType + ' Code')), React.createElement("form", {
6380 onSubmit: this.confirm,
6381 "data-test": data_test_attributes_1.auth.confirmSignIn.bodySection
6382 }, React.createElement(Amplify_UI_Components_React_1.SectionBody, {
6383 theme: theme
6384 }, React.createElement(Amplify_UI_Components_React_1.FormField, {
6385 theme: theme
6386 }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
6387 theme: theme
6388 }, core_1.I18n.get('Code'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
6389 autoFocus: true,
6390 placeholder: core_1.I18n.get('Code'),
6391 theme: theme,
6392 key: "code",
6393 name: "code",
6394 autoComplete: "off",
6395 onChange: this.handleInputChange,
6396 "data-test": data_test_attributes_1.auth.confirmSignIn.codeInput
6397 }))), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
6398 theme: theme
6399 }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
6400 theme: theme,
6401 "data-test": data_test_attributes_1.auth.confirmSignIn.confirmButton
6402 }, React.createElement(Amplify_UI_Components_React_1.Button, {
6403 theme: theme,
6404 type: "submit"
6405 }, core_1.I18n.get('Confirm'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
6406 theme: theme
6407 }, React.createElement(Amplify_UI_Components_React_1.Link, {
6408 theme: theme,
6409 onClick: function onClick() {
6410 return _this.changeState('signIn');
6411 },
6412 "data-test": data_test_attributes_1.auth.confirmSignIn.backToSignInLink
6413 }, core_1.I18n.get('Back to Sign In'))))));
6414 };
6415
6416 return ConfirmSignIn;
6417}(AuthPiece_1.AuthPiece);
6418
6419exports.ConfirmSignIn = ConfirmSignIn;
6420/**
6421 * @deprecated use named import
6422 */
6423
6424exports["default"] = ConfirmSignIn;
6425
6426/***/ }),
6427
6428/***/ "./lib/Auth/ConfirmSignUp.js":
6429/*!***********************************!*\
6430 !*** ./lib/Auth/ConfirmSignUp.js ***!
6431 \***********************************/
6432/*! no static exports found */
6433/***/ (function(module, exports, __webpack_require__) {
6434
6435"use strict";
6436
6437/*
6438 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6439 *
6440 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
6441 * the License. A copy of the License is located at
6442 *
6443 * http://aws.amazon.com/apache2.0/
6444 *
6445 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
6446 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
6447 * and limitations under the License.
6448 */
6449
6450var __extends = this && this.__extends || function () {
6451 var _extendStatics = function extendStatics(d, b) {
6452 _extendStatics = Object.setPrototypeOf || {
6453 __proto__: []
6454 } instanceof Array && function (d, b) {
6455 d.__proto__ = b;
6456 } || function (d, b) {
6457 for (var p in b) {
6458 if (b.hasOwnProperty(p)) d[p] = b[p];
6459 }
6460 };
6461
6462 return _extendStatics(d, b);
6463 };
6464
6465 return function (d, b) {
6466 _extendStatics(d, b);
6467
6468 function __() {
6469 this.constructor = d;
6470 }
6471
6472 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6473 };
6474}();
6475
6476var __importStar = this && this.__importStar || function (mod) {
6477 if (mod && mod.__esModule) return mod;
6478 var result = {};
6479 if (mod != null) for (var k in mod) {
6480 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6481 }
6482 result["default"] = mod;
6483 return result;
6484};
6485
6486Object.defineProperty(exports, "__esModule", {
6487 value: true
6488});
6489
6490var React = __importStar(__webpack_require__(/*! react */ "react"));
6491
6492var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
6493
6494var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
6495
6496var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
6497
6498var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
6499
6500var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
6501
6502var logger = new core_1.ConsoleLogger('ConfirmSignUp');
6503
6504var ConfirmSignUp =
6505/** @class */
6506function (_super) {
6507 __extends(ConfirmSignUp, _super);
6508
6509 function ConfirmSignUp(props) {
6510 var _this = _super.call(this, props) || this;
6511
6512 _this._validAuthStates = ['confirmSignUp'];
6513 _this.confirm = _this.confirm.bind(_this);
6514 _this.resend = _this.resend.bind(_this);
6515 return _this;
6516 }
6517
6518 ConfirmSignUp.prototype.confirm = function () {
6519 var _this = this;
6520
6521 var username = this.usernameFromAuthData() || this.inputs.username;
6522 var code = this.inputs.code;
6523
6524 if (!auth_1.Auth || typeof auth_1.Auth.confirmSignUp !== 'function') {
6525 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
6526 }
6527
6528 auth_1.Auth.confirmSignUp(username, code).then(function () {
6529 return _this.changeState('signedUp');
6530 })["catch"](function (err) {
6531 return _this.error(err);
6532 });
6533 };
6534
6535 ConfirmSignUp.prototype.resend = function () {
6536 var _this = this;
6537
6538 var username = this.usernameFromAuthData() || this.inputs.username;
6539
6540 if (!auth_1.Auth || typeof auth_1.Auth.resendSignUp !== 'function') {
6541 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
6542 }
6543
6544 auth_1.Auth.resendSignUp(username).then(function () {
6545 return logger.debug('code resent');
6546 })["catch"](function (err) {
6547 return _this.error(err);
6548 });
6549 };
6550
6551 ConfirmSignUp.prototype.showComponent = function (theme) {
6552 var _this = this;
6553
6554 var hide = this.props.hide;
6555 var username = this.usernameFromAuthData();
6556
6557 if (hide && hide.includes(ConfirmSignUp)) {
6558 return null;
6559 }
6560
6561 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
6562 theme: theme,
6563 "data-test": data_test_attributes_1.auth.confirmSignUp.section
6564 }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
6565 theme: theme,
6566 "data-test": data_test_attributes_1.auth.confirmSignUp.headerSection
6567 }, core_1.I18n.get('Confirm Sign Up')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
6568 theme: theme,
6569 "data-test": data_test_attributes_1.auth.confirmSignUp.bodySection
6570 }, React.createElement(Amplify_UI_Components_React_1.FormField, {
6571 theme: theme
6572 }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
6573 theme: theme
6574 }, core_1.I18n.get(this.getUsernameLabel()), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
6575 placeholder: core_1.I18n.get('Username'),
6576 theme: theme,
6577 key: "username",
6578 name: "username",
6579 onChange: this.handleInputChange,
6580 disabled: username,
6581 value: username ? username : '',
6582 "data-test": data_test_attributes_1.auth.confirmSignUp.usernameInput
6583 })), React.createElement(Amplify_UI_Components_React_1.FormField, {
6584 theme: theme
6585 }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
6586 theme: theme
6587 }, core_1.I18n.get('Confirmation Code'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
6588 autoFocus: true,
6589 placeholder: core_1.I18n.get('Enter your code'),
6590 theme: theme,
6591 key: "code",
6592 name: "code",
6593 autoComplete: "off",
6594 onChange: this.handleInputChange,
6595 "data-test": data_test_attributes_1.auth.confirmSignUp.confirmationCodeInput
6596 }), React.createElement(Amplify_UI_Components_React_1.Hint, {
6597 theme: theme
6598 }, core_1.I18n.get('Lost your code? '), React.createElement(Amplify_UI_Components_React_1.Link, {
6599 theme: theme,
6600 onClick: this.resend,
6601 "data-test": data_test_attributes_1.auth.confirmSignUp.resendCodeLink
6602 }, core_1.I18n.get('Resend Code'))))), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
6603 theme: theme
6604 }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
6605 theme: theme
6606 }, React.createElement(Amplify_UI_Components_React_1.Button, {
6607 theme: theme,
6608 onClick: this.confirm,
6609 "data-test": data_test_attributes_1.auth.confirmSignUp.confirmButton
6610 }, core_1.I18n.get('Confirm'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
6611 theme: theme
6612 }, React.createElement(Amplify_UI_Components_React_1.Link, {
6613 theme: theme,
6614 onClick: function onClick() {
6615 return _this.changeState('signIn');
6616 },
6617 "data-test": data_test_attributes_1.auth.confirmSignUp.backToSignInLink
6618 }, core_1.I18n.get('Back to Sign In')))));
6619 };
6620
6621 return ConfirmSignUp;
6622}(AuthPiece_1.AuthPiece);
6623
6624exports.ConfirmSignUp = ConfirmSignUp;
6625/**
6626 * @deprecated use named import
6627 */
6628
6629exports["default"] = ConfirmSignUp;
6630
6631/***/ }),
6632
6633/***/ "./lib/Auth/FederatedSignIn.js":
6634/*!*************************************!*\
6635 !*** ./lib/Auth/FederatedSignIn.js ***!
6636 \*************************************/
6637/*! no static exports found */
6638/***/ (function(module, exports, __webpack_require__) {
6639
6640"use strict";
6641
6642
6643var __extends = this && this.__extends || function () {
6644 var _extendStatics = function extendStatics(d, b) {
6645 _extendStatics = Object.setPrototypeOf || {
6646 __proto__: []
6647 } instanceof Array && function (d, b) {
6648 d.__proto__ = b;
6649 } || function (d, b) {
6650 for (var p in b) {
6651 if (b.hasOwnProperty(p)) d[p] = b[p];
6652 }
6653 };
6654
6655 return _extendStatics(d, b);
6656 };
6657
6658 return function (d, b) {
6659 _extendStatics(d, b);
6660
6661 function __() {
6662 this.constructor = d;
6663 }
6664
6665 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6666 };
6667}();
6668
6669var __importStar = this && this.__importStar || function (mod) {
6670 if (mod && mod.__esModule) return mod;
6671 var result = {};
6672 if (mod != null) for (var k in mod) {
6673 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6674 }
6675 result["default"] = mod;
6676 return result;
6677};
6678
6679var __importDefault = this && this.__importDefault || function (mod) {
6680 return mod && mod.__esModule ? mod : {
6681 "default": mod
6682 };
6683};
6684
6685Object.defineProperty(exports, "__esModule", {
6686 value: true
6687});
6688
6689var React = __importStar(__webpack_require__(/*! react */ "react"));
6690
6691var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
6692
6693var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
6694
6695var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
6696
6697var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
6698
6699var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
6700
6701var Provider_1 = __webpack_require__(/*! ./Provider */ "./lib/Auth/Provider/index.js");
6702
6703var logger = new core_1.ConsoleLogger('FederatedSignIn');
6704
6705var FederatedButtons =
6706/** @class */
6707function (_super) {
6708 __extends(FederatedButtons, _super);
6709
6710 function FederatedButtons() {
6711 return _super !== null && _super.apply(this, arguments) || this;
6712 }
6713
6714 FederatedButtons.prototype.google = function (google_client_id) {
6715 if (!google_client_id) {
6716 return null;
6717 }
6718
6719 var _a = this.props,
6720 theme = _a.theme,
6721 onStateChange = _a.onStateChange;
6722 return React.createElement(Provider_1.GoogleButton, {
6723 google_client_id: google_client_id,
6724 theme: theme,
6725 onStateChange: onStateChange
6726 });
6727 };
6728
6729 FederatedButtons.prototype.facebook = function (facebook_app_id) {
6730 if (!facebook_app_id) {
6731 return null;
6732 }
6733
6734 var _a = this.props,
6735 theme = _a.theme,
6736 onStateChange = _a.onStateChange;
6737 return React.createElement(Provider_1.FacebookButton, {
6738 facebook_app_id: facebook_app_id,
6739 theme: theme,
6740 onStateChange: onStateChange
6741 });
6742 };
6743
6744 FederatedButtons.prototype.amazon = function (amazon_client_id) {
6745 if (!amazon_client_id) {
6746 return null;
6747 }
6748
6749 var _a = this.props,
6750 theme = _a.theme,
6751 onStateChange = _a.onStateChange;
6752 return React.createElement(Provider_1.AmazonButton, {
6753 amazon_client_id: amazon_client_id,
6754 theme: theme,
6755 onStateChange: onStateChange
6756 });
6757 };
6758
6759 FederatedButtons.prototype.OAuth = function (oauth_config) {
6760 if (!oauth_config) {
6761 return null;
6762 }
6763
6764 var _a = this.props,
6765 theme = _a.theme,
6766 onStateChange = _a.onStateChange;
6767 return React.createElement(Provider_1.OAuthButton, {
6768 label: oauth_config ? oauth_config.label : undefined,
6769 theme: theme,
6770 onStateChange: onStateChange
6771 });
6772 };
6773
6774 FederatedButtons.prototype.auth0 = function (auth0) {
6775 if (!auth0) {
6776 return null;
6777 }
6778
6779 var _a = this.props,
6780 theme = _a.theme,
6781 onStateChange = _a.onStateChange;
6782 return React.createElement(Provider_1.Auth0Button, {
6783 label: auth0 ? auth0.label : undefined,
6784 theme: theme,
6785 onStateChange: onStateChange,
6786 auth0: auth0
6787 });
6788 };
6789
6790 FederatedButtons.prototype.render = function () {
6791 var authState = this.props.authState;
6792
6793 if (!['signIn', 'signedOut', 'signedUp'].includes(authState)) {
6794 return null;
6795 }
6796
6797 var federated = this.props.federated || {};
6798
6799 if (!auth_1.Auth || typeof auth_1.Auth.configure !== 'function') {
6800 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
6801 } // @ts-ignore
6802
6803
6804 var _a = auth_1.Auth.configure().oauth,
6805 oauth = _a === void 0 ? {} : _a; // backward compatibility
6806
6807 if (oauth['domain']) {
6808 federated.oauth_config = Object.assign({}, federated.oauth_config, oauth); // @ts-ignore
6809 } else if (oauth.awsCognito) {
6810 // @ts-ignore
6811 federated.oauth_config = Object.assign({}, federated.oauth_config, // @ts-ignore
6812 oauth.awsCognito);
6813 } // @ts-ignore
6814
6815
6816 if (oauth.auth0) {
6817 // @ts-ignore
6818 federated.auth0 = Object.assign({}, federated.auth0, oauth.auth0);
6819 }
6820
6821 if (core_1.isEmpty(federated)) {
6822 return null;
6823 }
6824
6825 var google_client_id = federated.google_client_id,
6826 facebook_app_id = federated.facebook_app_id,
6827 amazon_client_id = federated.amazon_client_id,
6828 oauth_config = federated.oauth_config,
6829 auth0 = federated.auth0;
6830 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
6831 return React.createElement("div", null, React.createElement("div", null, this.google(google_client_id)), React.createElement("div", null, this.facebook(facebook_app_id)), React.createElement("div", null, this.amazon(amazon_client_id)), React.createElement("div", null, this.OAuth(oauth_config)), React.createElement("div", null, this.auth0(auth0)), React.createElement(Amplify_UI_Components_React_1.Strike, {
6832 theme: theme
6833 }, core_1.I18n.get('or')));
6834 };
6835
6836 return FederatedButtons;
6837}(React.Component);
6838
6839exports.FederatedButtons = FederatedButtons;
6840
6841var FederatedSignIn =
6842/** @class */
6843function (_super) {
6844 __extends(FederatedSignIn, _super);
6845
6846 function FederatedSignIn() {
6847 return _super !== null && _super.apply(this, arguments) || this;
6848 }
6849
6850 FederatedSignIn.prototype.render = function () {
6851 var _a = this.props,
6852 authState = _a.authState,
6853 onStateChange = _a.onStateChange;
6854 var federated = this.props.federated || {};
6855
6856 if (!auth_1.Auth || typeof auth_1.Auth.configure !== 'function') {
6857 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
6858 } // @ts-ignore
6859
6860
6861 var _b = auth_1.Auth.configure().oauth,
6862 oauth = _b === void 0 ? {} : _b; // backward compatibility
6863
6864 if (oauth['domain']) {
6865 federated.oauth_config = Object.assign({}, federated.oauth_config, oauth); // @ts-ignore
6866 } else if (oauth.awsCognito) {
6867 // @ts-ignore
6868 federated.oauth_config = Object.assign({}, federated.oauth_config, // @ts-ignore
6869 oauth.awsCognito);
6870 } // @ts-ignore
6871
6872
6873 if (oauth.auth0) {
6874 // @ts-ignore
6875 federated.auth0 = Object.assign({}, federated.auth0, oauth.auth0);
6876 }
6877
6878 if (!federated) {
6879 logger.debug('federated prop is empty. show nothing');
6880 logger.debug('federated={google_client_id: , facebook_app_id: , amazon_client_id}');
6881 return null;
6882 } // @ts-ignore
6883
6884
6885 if (!['signIn', 'signedOut', 'signedUp'].includes(authState)) {
6886 return null;
6887 }
6888
6889 logger.debug('federated Config is', federated);
6890 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
6891 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
6892 theme: theme,
6893 "data-test": data_test_attributes_1.auth.federatedSignIn.section
6894 }, React.createElement(Amplify_UI_Components_React_1.SectionBody, {
6895 theme: theme,
6896 "data-test": data_test_attributes_1.auth.federatedSignIn.bodySection
6897 }, React.createElement(FederatedButtons, {
6898 federated: federated,
6899 theme: theme,
6900 authState: authState,
6901 onStateChange: onStateChange,
6902 "data-test": data_test_attributes_1.auth.federatedSignIn.signInButtons
6903 })));
6904 };
6905
6906 return FederatedSignIn;
6907}(React.Component);
6908
6909exports.FederatedSignIn = FederatedSignIn;
6910/**
6911 * @deprecated use named import
6912 */
6913
6914exports["default"] = FederatedSignIn;
6915
6916/***/ }),
6917
6918/***/ "./lib/Auth/ForgotPassword.js":
6919/*!************************************!*\
6920 !*** ./lib/Auth/ForgotPassword.js ***!
6921 \************************************/
6922/*! no static exports found */
6923/***/ (function(module, exports, __webpack_require__) {
6924
6925"use strict";
6926
6927/*
6928 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6929 *
6930 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
6931 * the License. A copy of the License is located at
6932 *
6933 * http://aws.amazon.com/apache2.0/
6934 *
6935 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
6936 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
6937 * and limitations under the License.
6938 */
6939
6940var __extends = this && this.__extends || function () {
6941 var _extendStatics = function extendStatics(d, b) {
6942 _extendStatics = Object.setPrototypeOf || {
6943 __proto__: []
6944 } instanceof Array && function (d, b) {
6945 d.__proto__ = b;
6946 } || function (d, b) {
6947 for (var p in b) {
6948 if (b.hasOwnProperty(p)) d[p] = b[p];
6949 }
6950 };
6951
6952 return _extendStatics(d, b);
6953 };
6954
6955 return function (d, b) {
6956 _extendStatics(d, b);
6957
6958 function __() {
6959 this.constructor = d;
6960 }
6961
6962 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6963 };
6964}();
6965
6966var __importStar = this && this.__importStar || function (mod) {
6967 if (mod && mod.__esModule) return mod;
6968 var result = {};
6969 if (mod != null) for (var k in mod) {
6970 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6971 }
6972 result["default"] = mod;
6973 return result;
6974};
6975
6976var __importDefault = this && this.__importDefault || function (mod) {
6977 return mod && mod.__esModule ? mod : {
6978 "default": mod
6979 };
6980};
6981
6982Object.defineProperty(exports, "__esModule", {
6983 value: true
6984});
6985
6986var React = __importStar(__webpack_require__(/*! react */ "react"));
6987
6988var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
6989
6990var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
6991
6992var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
6993
6994var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
6995
6996var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
6997
6998var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
6999
7000var logger = new core_1.ConsoleLogger('ForgotPassword');
7001
7002var ForgotPassword =
7003/** @class */
7004function (_super) {
7005 __extends(ForgotPassword, _super);
7006
7007 function ForgotPassword(props) {
7008 var _this = _super.call(this, props) || this;
7009
7010 _this.send = _this.send.bind(_this);
7011 _this.submit = _this.submit.bind(_this);
7012 _this._validAuthStates = ['forgotPassword'];
7013 _this.state = {
7014 delivery: null
7015 };
7016 return _this;
7017 }
7018
7019 ForgotPassword.prototype.send = function () {
7020 var _this = this;
7021
7022 var _a = this.props.authData,
7023 authData = _a === void 0 ? {} : _a;
7024 var username = this.getUsernameFromInput() || authData.username;
7025
7026 if (!auth_1.Auth || typeof auth_1.Auth.forgotPassword !== 'function') {
7027 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
7028 }
7029
7030 auth_1.Auth.forgotPassword(username).then(function (data) {
7031 logger.debug(data);
7032
7033 _this.setState({
7034 delivery: data.CodeDeliveryDetails
7035 });
7036 })["catch"](function (err) {
7037 return _this.error(err);
7038 });
7039 };
7040
7041 ForgotPassword.prototype.submit = function () {
7042 var _this = this;
7043
7044 var _a = this.props.authData,
7045 authData = _a === void 0 ? {} : _a;
7046 var _b = this.inputs,
7047 code = _b.code,
7048 password = _b.password;
7049 var username = this.getUsernameFromInput() || authData.username;
7050
7051 if (!auth_1.Auth || typeof auth_1.Auth.forgotPasswordSubmit !== 'function') {
7052 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
7053 }
7054
7055 auth_1.Auth.forgotPasswordSubmit(username, code, password).then(function (data) {
7056 logger.debug(data);
7057
7058 _this.changeState('signIn');
7059
7060 _this.setState({
7061 delivery: null
7062 });
7063 })["catch"](function (err) {
7064 return _this.error(err);
7065 });
7066 };
7067
7068 ForgotPassword.prototype.sendView = function () {
7069 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
7070 return React.createElement("div", null, this.renderUsernameField(theme));
7071 };
7072
7073 ForgotPassword.prototype.submitView = function () {
7074 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
7075 return React.createElement("div", null, React.createElement(Amplify_UI_Components_React_1.FormField, {
7076 theme: theme
7077 }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
7078 theme: theme
7079 }, core_1.I18n.get('Code'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
7080 placeholder: core_1.I18n.get('Code'),
7081 theme: theme,
7082 key: "code",
7083 name: "code",
7084 autoComplete: "off",
7085 onChange: this.handleInputChange
7086 })), React.createElement(Amplify_UI_Components_React_1.FormField, {
7087 theme: theme
7088 }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
7089 theme: theme
7090 }, core_1.I18n.get('New Password'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
7091 placeholder: core_1.I18n.get('New Password'),
7092 theme: theme,
7093 type: "password",
7094 key: "password",
7095 name: "password",
7096 autoComplete: "off",
7097 onChange: this.handleInputChange
7098 })));
7099 };
7100
7101 ForgotPassword.prototype.showComponent = function (theme) {
7102 var _this = this;
7103
7104 var _a = this.props,
7105 authState = _a.authState,
7106 hide = _a.hide,
7107 _b = _a.authData,
7108 authData = _b === void 0 ? {} : _b;
7109
7110 if (hide && hide.includes(ForgotPassword)) {
7111 return null;
7112 }
7113
7114 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
7115 theme: theme,
7116 "data-test": data_test_attributes_1.auth.forgotPassword.section
7117 }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
7118 theme: theme,
7119 "data-test": data_test_attributes_1.auth.forgotPassword.headerSection
7120 }, core_1.I18n.get('Reset your password')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
7121 theme: theme,
7122 "data-test": data_test_attributes_1.auth.forgotPassword.bodySection
7123 }, this.state.delivery || authData.username ? this.submitView() : this.sendView()), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
7124 theme: theme
7125 }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
7126 theme: theme
7127 }, this.state.delivery || authData.username ? React.createElement(Amplify_UI_Components_React_1.Button, {
7128 theme: theme,
7129 onClick: this.submit,
7130 "data-test": data_test_attributes_1.auth.forgotPassword.submitButton
7131 }, core_1.I18n.get('Submit')) : React.createElement(Amplify_UI_Components_React_1.Button, {
7132 theme: theme,
7133 onClick: this.send,
7134 "data-test": data_test_attributes_1.auth.forgotPassword.sendCodeButton
7135 }, core_1.I18n.get('Send Code'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
7136 theme: theme
7137 }, this.state.delivery || authData.username ? React.createElement(Amplify_UI_Components_React_1.Link, {
7138 theme: theme,
7139 onClick: this.send,
7140 "data-test": data_test_attributes_1.auth.forgotPassword.resendCodeLink
7141 }, core_1.I18n.get('Resend Code')) : React.createElement(Amplify_UI_Components_React_1.Link, {
7142 theme: theme,
7143 onClick: function onClick() {
7144 return _this.changeState('signIn');
7145 },
7146 "data-test": data_test_attributes_1.auth.forgotPassword.backToSignInLink
7147 }, core_1.I18n.get('Back to Sign In')))));
7148 };
7149
7150 return ForgotPassword;
7151}(AuthPiece_1.AuthPiece);
7152
7153exports.ForgotPassword = ForgotPassword;
7154/**
7155 * @deprecated use named import
7156 */
7157
7158exports["default"] = ForgotPassword;
7159
7160/***/ }),
7161
7162/***/ "./lib/Auth/Greetings.js":
7163/*!*******************************!*\
7164 !*** ./lib/Auth/Greetings.js ***!
7165 \*******************************/
7166/*! no static exports found */
7167/***/ (function(module, exports, __webpack_require__) {
7168
7169"use strict";
7170
7171/*
7172 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
7173 *
7174 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
7175 * the License. A copy of the License is located at
7176 *
7177 * http://aws.amazon.com/apache2.0/
7178 *
7179 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7180 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
7181 * and limitations under the License.
7182 */
7183
7184var __extends = this && this.__extends || function () {
7185 var _extendStatics = function extendStatics(d, b) {
7186 _extendStatics = Object.setPrototypeOf || {
7187 __proto__: []
7188 } instanceof Array && function (d, b) {
7189 d.__proto__ = b;
7190 } || function (d, b) {
7191 for (var p in b) {
7192 if (b.hasOwnProperty(p)) d[p] = b[p];
7193 }
7194 };
7195
7196 return _extendStatics(d, b);
7197 };
7198
7199 return function (d, b) {
7200 _extendStatics(d, b);
7201
7202 function __() {
7203 this.constructor = d;
7204 }
7205
7206 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7207 };
7208}();
7209
7210var __assign = this && this.__assign || function () {
7211 __assign = Object.assign || function (t) {
7212 for (var s, i = 1, n = arguments.length; i < n; i++) {
7213 s = arguments[i];
7214
7215 for (var p in s) {
7216 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7217 }
7218 }
7219
7220 return t;
7221 };
7222
7223 return __assign.apply(this, arguments);
7224};
7225
7226var __importStar = this && this.__importStar || function (mod) {
7227 if (mod && mod.__esModule) return mod;
7228 var result = {};
7229 if (mod != null) for (var k in mod) {
7230 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
7231 }
7232 result["default"] = mod;
7233 return result;
7234};
7235
7236var __importDefault = this && this.__importDefault || function (mod) {
7237 return mod && mod.__esModule ? mod : {
7238 "default": mod
7239 };
7240};
7241
7242Object.defineProperty(exports, "__esModule", {
7243 value: true
7244});
7245
7246var React = __importStar(__webpack_require__(/*! react */ "react"));
7247
7248var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
7249
7250var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
7251
7252var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
7253
7254var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
7255
7256var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
7257
7258var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
7259
7260var SignOut_1 = __webpack_require__(/*! ./SignOut */ "./lib/Auth/SignOut.js");
7261
7262var Provider_1 = __webpack_require__(/*! ./Provider */ "./lib/Auth/Provider/index.js");
7263
7264var types_1 = __webpack_require__(/*! ./common/types */ "./lib/Auth/common/types.js");
7265
7266var logger = new core_1.ConsoleLogger('Greetings');
7267
7268var Greetings =
7269/** @class */
7270function (_super) {
7271 __extends(Greetings, _super);
7272
7273 function Greetings(props) {
7274 var _this = _super.call(this, props) || this;
7275
7276 _this.state = {};
7277 _this.onHubCapsule = _this.onHubCapsule.bind(_this);
7278 _this.inGreeting = _this.inGreeting.bind(_this);
7279 core_1.Hub.listen('auth', _this.onHubCapsule);
7280 _this._validAuthStates = ['signedIn'];
7281 return _this;
7282 }
7283
7284 Greetings.prototype.componentDidMount = function () {
7285 this._isMounted = true;
7286 this.findState();
7287 };
7288
7289 Greetings.prototype.componentWillUnmount = function () {
7290 this._isMounted = false;
7291 };
7292
7293 Greetings.prototype.findState = function () {
7294 var _this = this;
7295
7296 if (!this.props.authState && !this.props.authData) {
7297 auth_1.Auth.currentAuthenticatedUser().then(function (user) {
7298 _this.setState({
7299 authState: 'signedIn',
7300 authData: user,
7301 stateFromStorage: true
7302 });
7303 })["catch"](function (err) {
7304 return logger.debug(err);
7305 });
7306 }
7307 };
7308
7309 Greetings.prototype.onHubCapsule = function (capsule) {
7310 if (this._isMounted) {
7311 var channel = capsule.channel,
7312 payload = capsule.payload;
7313
7314 if (channel === 'auth' && payload.event === 'signIn') {
7315 this.setState({
7316 authState: 'signedIn',
7317 authData: payload.data
7318 });
7319
7320 if (!this.props.authState) {
7321 this.setState({
7322 stateFromStorage: true
7323 });
7324 }
7325 } else if (channel === 'auth' && payload.event === 'signOut' && !this.props.authState) {
7326 this.setState({
7327 authState: 'signIn'
7328 });
7329 }
7330 }
7331 };
7332
7333 Greetings.prototype.inGreeting = function (name) {
7334 var _a = this.props.usernameAttributes,
7335 usernameAttributes = _a === void 0 ? types_1.UsernameAttributes.USERNAME : _a;
7336 var prefix = usernameAttributes === types_1.UsernameAttributes.USERNAME ? core_1.I18n.get('Hello') + " " : '';
7337 return "" + prefix + name;
7338 };
7339
7340 Greetings.prototype.outGreeting = function () {
7341 return '';
7342 };
7343
7344 Greetings.prototype.userGreetings = function (theme) {
7345 var user = this.props.authData || this.state.authData;
7346 var greeting = this.props.inGreeting || this.inGreeting; // get name from attributes first
7347
7348 var _a = this.props.usernameAttributes,
7349 usernameAttributes = _a === void 0 ? 'username' : _a;
7350 var name = '';
7351
7352 switch (usernameAttributes) {
7353 case types_1.UsernameAttributes.EMAIL:
7354 // Email as Username
7355 name = user.attributes ? user.attributes.email : user.username;
7356 break;
7357
7358 case types_1.UsernameAttributes.PHONE_NUMBER:
7359 // Phone number as Username
7360 name = user.attributes ? user.attributes.phone_number : user.username;
7361 break;
7362
7363 default:
7364 var nameFromAttr = user.attributes ? user.attributes.name || (user.attributes.given_name ? user.attributes.given_name + ' ' + user.attributes.family_name : undefined) : undefined;
7365 name = nameFromAttr || user.name || user.username;
7366 break;
7367 }
7368
7369 var message = typeof greeting === 'function' ? greeting(name) : greeting;
7370 return React.createElement("span", null, React.createElement(Amplify_UI_Components_React_1.NavItem, {
7371 theme: theme
7372 }, message), this.renderSignOutButton());
7373 };
7374
7375 Greetings.prototype.renderSignOutButton = function () {
7376 var _a = this.props.federated,
7377 federated = _a === void 0 ? {} : _a;
7378 var google_client_id = federated.google_client_id,
7379 facebook_app_id = federated.facebook_app_id,
7380 amazon_client_id = federated.amazon_client_id,
7381 auth0 = federated.auth0; // @ts-ignore
7382
7383 var config = auth_1.Auth.configure();
7384 var _b = config.oauth,
7385 oauth = _b === void 0 ? {} : _b; // @ts-ignore
7386
7387 var googleClientId = google_client_id || config.googleClientId; // @ts-ignore
7388
7389 var facebookAppId = facebook_app_id || config.facebookClientId; // @ts-ignore
7390
7391 var amazonClientId = amazon_client_id || config.amazonClientId; // @ts-ignore
7392
7393 var auth0_config = auth0 || oauth.auth0;
7394 var SignOutComponent = SignOut_1.SignOut; // @ts-ignore
7395
7396 if (googleClientId) SignOutComponent = Provider_1.withGoogle(SignOut_1.SignOut); // @ts-ignore
7397
7398 if (facebookAppId) SignOutComponent = Provider_1.withFacebook(SignOut_1.SignOut); // @ts-ignore
7399
7400 if (amazonClientId) SignOutComponent = Provider_1.withAmazon(SignOut_1.SignOut); // @ts-ignore
7401
7402 if (auth0_config) SignOutComponent = Provider_1.withAuth0(SignOut_1.SignOut);
7403 var stateAndProps = Object.assign({}, this.props, this.state);
7404 return React.createElement(SignOutComponent, __assign({}, stateAndProps));
7405 };
7406
7407 Greetings.prototype.noUserGreetings = function (theme) {
7408 var greeting = this.props.outGreeting || this.outGreeting;
7409 var message = typeof greeting === 'function' ? greeting() : greeting;
7410 return message ? React.createElement(Amplify_UI_Components_React_1.NavItem, {
7411 theme: theme
7412 }, message) : null;
7413 };
7414
7415 Greetings.prototype.render = function () {
7416 var hide = this.props.hide;
7417
7418 if (hide && hide.includes(Greetings)) {
7419 return null;
7420 }
7421
7422 var authState = this.props.authState || this.state.authState;
7423 var signedIn = authState === 'signedIn';
7424 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
7425 var greeting = signedIn ? this.userGreetings(theme) : this.noUserGreetings(theme);
7426
7427 if (!greeting) {
7428 return null;
7429 }
7430
7431 return React.createElement(Amplify_UI_Components_React_1.NavBar, {
7432 theme: theme,
7433 "data-test": data_test_attributes_1.auth.greetings.navBar
7434 }, React.createElement(Amplify_UI_Components_React_1.Nav, {
7435 theme: theme,
7436 "data-test": data_test_attributes_1.auth.greetings.nav
7437 }, React.createElement(Amplify_UI_Components_React_1.NavRight, {
7438 theme: theme,
7439 "data-test": data_test_attributes_1.auth.greetings.navRight
7440 }, greeting)));
7441 };
7442
7443 return Greetings;
7444}(AuthPiece_1.AuthPiece);
7445
7446exports.Greetings = Greetings;
7447/**
7448 * @deprecated use named import
7449 */
7450
7451exports["default"] = Greetings;
7452
7453/***/ }),
7454
7455/***/ "./lib/Auth/Loading.js":
7456/*!*****************************!*\
7457 !*** ./lib/Auth/Loading.js ***!
7458 \*****************************/
7459/*! no static exports found */
7460/***/ (function(module, exports, __webpack_require__) {
7461
7462"use strict";
7463
7464/*
7465 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
7466 *
7467 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
7468 * the License. A copy of the License is located at
7469 *
7470 * http://aws.amazon.com/apache2.0/
7471 *
7472 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7473 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
7474 * and limitations under the License.
7475 */
7476
7477var __extends = this && this.__extends || function () {
7478 var _extendStatics = function extendStatics(d, b) {
7479 _extendStatics = Object.setPrototypeOf || {
7480 __proto__: []
7481 } instanceof Array && function (d, b) {
7482 d.__proto__ = b;
7483 } || function (d, b) {
7484 for (var p in b) {
7485 if (b.hasOwnProperty(p)) d[p] = b[p];
7486 }
7487 };
7488
7489 return _extendStatics(d, b);
7490 };
7491
7492 return function (d, b) {
7493 _extendStatics(d, b);
7494
7495 function __() {
7496 this.constructor = d;
7497 }
7498
7499 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7500 };
7501}();
7502
7503var __importStar = this && this.__importStar || function (mod) {
7504 if (mod && mod.__esModule) return mod;
7505 var result = {};
7506 if (mod != null) for (var k in mod) {
7507 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
7508 }
7509 result["default"] = mod;
7510 return result;
7511};
7512
7513Object.defineProperty(exports, "__esModule", {
7514 value: true
7515});
7516
7517var React = __importStar(__webpack_require__(/*! react */ "react"));
7518
7519var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
7520
7521var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
7522
7523var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
7524
7525var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
7526
7527var Loading =
7528/** @class */
7529function (_super) {
7530 __extends(Loading, _super);
7531
7532 function Loading(props) {
7533 var _this = _super.call(this, props) || this;
7534
7535 _this._validAuthStates = ['loading'];
7536 return _this;
7537 }
7538
7539 Loading.prototype.showComponent = function (theme) {
7540 var hide = this.props.hide;
7541
7542 if (hide && hide.includes(Loading)) {
7543 return null;
7544 }
7545
7546 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
7547 theme: theme,
7548 "data-test": data_test_attributes_1.auth.loading.section
7549 }, React.createElement(Amplify_UI_Components_React_1.SectionBody, {
7550 theme: theme
7551 }, core_1.I18n.get('Loading...')));
7552 };
7553
7554 return Loading;
7555}(AuthPiece_1.AuthPiece);
7556
7557exports.Loading = Loading;
7558
7559/***/ }),
7560
7561/***/ "./lib/Auth/PhoneField.js":
7562/*!********************************!*\
7563 !*** ./lib/Auth/PhoneField.js ***!
7564 \********************************/
7565/*! no static exports found */
7566/***/ (function(module, exports, __webpack_require__) {
7567
7568"use strict";
7569
7570
7571var __extends = this && this.__extends || function () {
7572 var _extendStatics = function extendStatics(d, b) {
7573 _extendStatics = Object.setPrototypeOf || {
7574 __proto__: []
7575 } instanceof Array && function (d, b) {
7576 d.__proto__ = b;
7577 } || function (d, b) {
7578 for (var p in b) {
7579 if (b.hasOwnProperty(p)) d[p] = b[p];
7580 }
7581 };
7582
7583 return _extendStatics(d, b);
7584 };
7585
7586 return function (d, b) {
7587 _extendStatics(d, b);
7588
7589 function __() {
7590 this.constructor = d;
7591 }
7592
7593 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7594 };
7595}();
7596
7597var __importStar = this && this.__importStar || function (mod) {
7598 if (mod && mod.__esModule) return mod;
7599 var result = {};
7600 if (mod != null) for (var k in mod) {
7601 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
7602 }
7603 result["default"] = mod;
7604 return result;
7605};
7606
7607var __importDefault = this && this.__importDefault || function (mod) {
7608 return mod && mod.__esModule ? mod : {
7609 "default": mod
7610 };
7611};
7612
7613Object.defineProperty(exports, "__esModule", {
7614 value: true
7615});
7616
7617var React = __importStar(__webpack_require__(/*! react */ "react"));
7618
7619var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
7620
7621var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
7622
7623var country_dial_codes_1 = __webpack_require__(/*! ./common/country-dial-codes */ "./lib/Auth/common/country-dial-codes.js");
7624
7625var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
7626
7627var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
7628
7629var PhoneField =
7630/** @class */
7631function (_super) {
7632 __extends(PhoneField, _super);
7633
7634 function PhoneField(props) {
7635 var _this = _super.call(this, props) || this;
7636
7637 _this.handleInputChange = _this.handleInputChange.bind(_this);
7638 _this.composePhoneNumber = _this.composePhoneNumber.bind(_this);
7639 _this.inputs = {
7640 dial_code: _this.props.defaultDialCode || '+1',
7641 phone_line_number: ''
7642 };
7643 return _this;
7644 }
7645
7646 PhoneField.prototype.composePhoneNumber = function (dial_code, phone_line_number) {
7647 return "" + (dial_code || '+1') + phone_line_number.replace(/[-()]/g, '');
7648 };
7649
7650 PhoneField.prototype.handleInputChange = function (evt) {
7651 var _a = evt.target,
7652 name = _a.name,
7653 value = _a.value;
7654 this.inputs[name] = value;
7655
7656 if (this.props.onChangeText) {
7657 this.props.onChangeText(this.composePhoneNumber(this.inputs.dial_code, this.inputs.phone_line_number));
7658 }
7659 };
7660
7661 PhoneField.prototype.render = function () {
7662 var _a = this.props,
7663 _b = _a.theme,
7664 theme = _b === void 0 ? Amplify_UI_Theme_1["default"] : _b,
7665 _c = _a.required,
7666 required = _c === void 0 ? true : _c,
7667 _d = _a.defaultDialCode,
7668 defaultDialCode = _d === void 0 ? '+1' : _d,
7669 _e = _a.label,
7670 label = _e === void 0 ? 'Phone Number' : _e,
7671 _f = _a.placeholder,
7672 placeholder = _f === void 0 ? 'Enter your phone number' : _f;
7673 return React.createElement(Amplify_UI_Components_React_1.FormField, {
7674 theme: theme,
7675 key: "phone_number"
7676 }, required ? React.createElement(Amplify_UI_Components_React_1.InputLabel, {
7677 theme: theme
7678 }, core_1.I18n.get(label), " *") : React.createElement(Amplify_UI_Components_React_1.InputLabel, {
7679 theme: theme
7680 }, core_1.I18n.get(label)), React.createElement(Amplify_UI_Components_React_1.SelectInput, {
7681 theme: theme
7682 }, React.createElement("select", {
7683 name: "dial_code",
7684 defaultValue: defaultDialCode,
7685 onChange: this.handleInputChange,
7686 "data-test": data_test_attributes_1.auth.genericAttrs.dialCodeSelect
7687 }, country_dial_codes_1.countryDialCodes.map(function (dialCode) {
7688 return React.createElement("option", {
7689 key: dialCode,
7690 value: dialCode
7691 }, dialCode);
7692 })), React.createElement(Amplify_UI_Components_React_1.Input, {
7693 placeholder: core_1.I18n.get(placeholder),
7694 theme: theme,
7695 type: "tel",
7696 id: "phone_line_number",
7697 key: "phone_line_number",
7698 name: "phone_line_number",
7699 onChange: this.handleInputChange,
7700 "data-test": data_test_attributes_1.auth.genericAttrs.phoneNumberInput
7701 })));
7702 };
7703
7704 return PhoneField;
7705}(React.Component);
7706
7707exports.PhoneField = PhoneField;
7708/**
7709 * @deprecated use named import
7710 */
7711
7712exports["default"] = PhoneField;
7713
7714/***/ }),
7715
7716/***/ "./lib/Auth/Provider/index.js":
7717/*!************************************!*\
7718 !*** ./lib/Auth/Provider/index.js ***!
7719 \************************************/
7720/*! no static exports found */
7721/***/ (function(module, exports, __webpack_require__) {
7722
7723"use strict";
7724
7725/*
7726 * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
7727 *
7728 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
7729 * the License. A copy of the License is located at
7730 *
7731 * http://aws.amazon.com/apache2.0/
7732 *
7733 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7734 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
7735 * and limitations under the License.
7736 */
7737
7738var __extends = this && this.__extends || function () {
7739 var _extendStatics = function extendStatics(d, b) {
7740 _extendStatics = Object.setPrototypeOf || {
7741 __proto__: []
7742 } instanceof Array && function (d, b) {
7743 d.__proto__ = b;
7744 } || function (d, b) {
7745 for (var p in b) {
7746 if (b.hasOwnProperty(p)) d[p] = b[p];
7747 }
7748 };
7749
7750 return _extendStatics(d, b);
7751 };
7752
7753 return function (d, b) {
7754 _extendStatics(d, b);
7755
7756 function __() {
7757 this.constructor = d;
7758 }
7759
7760 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7761 };
7762}();
7763
7764var __assign = this && this.__assign || function () {
7765 __assign = Object.assign || function (t) {
7766 for (var s, i = 1, n = arguments.length; i < n; i++) {
7767 s = arguments[i];
7768
7769 for (var p in s) {
7770 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7771 }
7772 }
7773
7774 return t;
7775 };
7776
7777 return __assign.apply(this, arguments);
7778};
7779
7780var __importStar = this && this.__importStar || function (mod) {
7781 if (mod && mod.__esModule) return mod;
7782 var result = {};
7783 if (mod != null) for (var k in mod) {
7784 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
7785 }
7786 result["default"] = mod;
7787 return result;
7788};
7789
7790Object.defineProperty(exports, "__esModule", {
7791 value: true
7792});
7793
7794var React = __importStar(__webpack_require__(/*! react */ "react"));
7795
7796var withGoogle_1 = __webpack_require__(/*! ./withGoogle */ "./lib/Auth/Provider/withGoogle.js");
7797
7798var withFacebook_1 = __webpack_require__(/*! ./withFacebook */ "./lib/Auth/Provider/withFacebook.js");
7799
7800var withAmazon_1 = __webpack_require__(/*! ./withAmazon */ "./lib/Auth/Provider/withAmazon.js");
7801
7802var withOAuth_1 = __webpack_require__(/*! ./withOAuth */ "./lib/Auth/Provider/withOAuth.js");
7803
7804var withAuth0_1 = __webpack_require__(/*! ./withAuth0 */ "./lib/Auth/Provider/withAuth0.js");
7805
7806var withGoogle_2 = __webpack_require__(/*! ./withGoogle */ "./lib/Auth/Provider/withGoogle.js");
7807
7808exports.withGoogle = withGoogle_2.withGoogle;
7809exports.GoogleButton = withGoogle_2.GoogleButton;
7810
7811var withFacebook_2 = __webpack_require__(/*! ./withFacebook */ "./lib/Auth/Provider/withFacebook.js");
7812
7813exports.withFacebook = withFacebook_2.withFacebook;
7814exports.FacebookButton = withFacebook_2.FacebookButton;
7815
7816var withAmazon_2 = __webpack_require__(/*! ./withAmazon */ "./lib/Auth/Provider/withAmazon.js");
7817
7818exports.withAmazon = withAmazon_2.withAmazon;
7819exports.AmazonButton = withAmazon_2.AmazonButton;
7820
7821var withOAuth_2 = __webpack_require__(/*! ./withOAuth */ "./lib/Auth/Provider/withOAuth.js");
7822
7823exports.withOAuth = withOAuth_2.withOAuth;
7824exports.OAuthButton = withOAuth_2.OAuthButton;
7825
7826var withAuth0_2 = __webpack_require__(/*! ./withAuth0 */ "./lib/Auth/Provider/withAuth0.js");
7827
7828exports.withAuth0 = withAuth0_2.withAuth0;
7829exports.Auth0Button = withAuth0_2.Auth0Button;
7830
7831function withFederated(Comp) {
7832 var Federated = withAuth0_1.withAuth0(withOAuth_1.withOAuth(withAmazon_1.withAmazon(withGoogle_1.withGoogle(withFacebook_1.withFacebook(Comp)))));
7833 return (
7834 /** @class */
7835 function (_super) {
7836 __extends(class_1, _super);
7837
7838 function class_1() {
7839 return _super !== null && _super.apply(this, arguments) || this;
7840 }
7841
7842 class_1.prototype.render = function () {
7843 // @ts-ignore
7844 var federated = this.props.federated || {};
7845 return React.createElement(Federated, __assign({}, this.props, federated));
7846 };
7847
7848 return class_1;
7849 }(React.Component)
7850 );
7851}
7852
7853exports.withFederated = withFederated;
7854
7855/***/ }),
7856
7857/***/ "./lib/Auth/Provider/withAmazon.js":
7858/*!*****************************************!*\
7859 !*** ./lib/Auth/Provider/withAmazon.js ***!
7860 \*****************************************/
7861/*! no static exports found */
7862/***/ (function(module, exports, __webpack_require__) {
7863
7864"use strict";
7865
7866/*
7867 * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
7868 *
7869 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
7870 * the License. A copy of the License is located at
7871 *
7872 * http://aws.amazon.com/apache2.0/
7873 *
7874 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7875 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
7876 * and limitations under the License.
7877 */
7878
7879var __extends = this && this.__extends || function () {
7880 var _extendStatics = function extendStatics(d, b) {
7881 _extendStatics = Object.setPrototypeOf || {
7882 __proto__: []
7883 } instanceof Array && function (d, b) {
7884 d.__proto__ = b;
7885 } || function (d, b) {
7886 for (var p in b) {
7887 if (b.hasOwnProperty(p)) d[p] = b[p];
7888 }
7889 };
7890
7891 return _extendStatics(d, b);
7892 };
7893
7894 return function (d, b) {
7895 _extendStatics(d, b);
7896
7897 function __() {
7898 this.constructor = d;
7899 }
7900
7901 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7902 };
7903}();
7904
7905var __assign = this && this.__assign || function () {
7906 __assign = Object.assign || function (t) {
7907 for (var s, i = 1, n = arguments.length; i < n; i++) {
7908 s = arguments[i];
7909
7910 for (var p in s) {
7911 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7912 }
7913 }
7914
7915 return t;
7916 };
7917
7918 return __assign.apply(this, arguments);
7919};
7920
7921var __importStar = this && this.__importStar || function (mod) {
7922 if (mod && mod.__esModule) return mod;
7923 var result = {};
7924 if (mod != null) for (var k in mod) {
7925 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
7926 }
7927 result["default"] = mod;
7928 return result;
7929};
7930
7931var __importDefault = this && this.__importDefault || function (mod) {
7932 return mod && mod.__esModule ? mod : {
7933 "default": mod
7934 };
7935};
7936
7937Object.defineProperty(exports, "__esModule", {
7938 value: true
7939});
7940
7941var React = __importStar(__webpack_require__(/*! react */ "react"));
7942
7943var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
7944
7945var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
7946
7947var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
7948
7949var ui_1 = __webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui");
7950
7951var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
7952
7953var constants_1 = __webpack_require__(/*! ../common/constants */ "./lib/Auth/common/constants.js");
7954
7955var logger = new core_1.ConsoleLogger('withAmazon');
7956
7957function withAmazon(Comp) {
7958 return (
7959 /** @class */
7960 function (_super) {
7961 __extends(class_1, _super);
7962
7963 function class_1(props) {
7964 var _this = _super.call(this, props) || this;
7965
7966 _this.initAmazon = _this.initAmazon.bind(_this);
7967 _this.signIn = _this.signIn.bind(_this);
7968 _this.signOut = _this.signOut.bind(_this);
7969 _this.federatedSignIn = _this.federatedSignIn.bind(_this);
7970 _this.state = {};
7971 return _this;
7972 }
7973
7974 class_1.prototype.signIn = function () {
7975 var _this = this;
7976
7977 var amz = window.amazon;
7978 var options = {
7979 scope: 'profile'
7980 };
7981 amz.Login.authorize(options, function (response) {
7982 if (response.error) {
7983 logger.debug('Failed to login with amazon: ' + response.error);
7984 return;
7985 }
7986
7987 var payload = {
7988 provider: constants_1.Constants.AMAZON
7989 };
7990
7991 try {
7992 localStorage.setItem(constants_1.Constants.AUTH_SOURCE_KEY, JSON.stringify(payload));
7993 } catch (e) {
7994 logger.debug('Failed to cache auth source into localStorage', e);
7995 }
7996
7997 _this.federatedSignIn(response);
7998 });
7999 };
8000
8001 class_1.prototype.federatedSignIn = function (response) {
8002 var access_token = response.access_token,
8003 expires_in = response.expires_in;
8004 var onStateChange = this.props.onStateChange;
8005 var date = new Date();
8006 var expires_at = expires_in * 1000 + date.getTime();
8007
8008 if (!access_token) {
8009 return;
8010 }
8011
8012 var amz = window.amazon;
8013 amz.Login.retrieveProfile(function (userInfo) {
8014 if (!userInfo.success) {
8015 logger.debug('Get user Info failed');
8016 return;
8017 }
8018
8019 var user = {
8020 name: userInfo.profile.Name,
8021 email: userInfo.profile.PrimaryEmail
8022 };
8023
8024 if (!auth_1.Auth || typeof auth_1.Auth.federatedSignIn !== 'function' || typeof auth_1.Auth.currentAuthenticatedUser !== 'function') {
8025 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
8026 }
8027
8028 auth_1.Auth.federatedSignIn('amazon', {
8029 token: access_token,
8030 expires_at: expires_at
8031 }, user).then(function (credentials) {
8032 return auth_1.Auth.currentAuthenticatedUser();
8033 }).then(function (authUser) {
8034 if (onStateChange) {
8035 onStateChange('signedIn', authUser);
8036 }
8037 });
8038 });
8039 };
8040
8041 class_1.prototype.signOut = function () {
8042 var amz = window.amazon;
8043
8044 if (!amz) {
8045 logger.debug('Amazon Login sdk undefined');
8046 return Promise.resolve();
8047 }
8048
8049 logger.debug('Amazon signing out');
8050 amz.Login.logout();
8051 };
8052
8053 class_1.prototype.componentDidMount = function () {
8054 var amazon_client_id = this.props.amazon_client_id;
8055 if (amazon_client_id && !window.amazon) this.createScript();
8056 };
8057
8058 class_1.prototype.createScript = function () {
8059 var script = document.createElement('script');
8060 script.src = 'https://api-cdn.amazon.com/sdk/login1.js';
8061 script.async = true;
8062 script.onload = this.initAmazon;
8063 document.body.appendChild(script);
8064 };
8065
8066 class_1.prototype.initAmazon = function () {
8067 logger.debug('init amazon');
8068 var amazon_client_id = this.props.amazon_client_id;
8069 var amz = window.amazon;
8070 amz.Login.setClientId(amazon_client_id);
8071 };
8072
8073 class_1.prototype.render = function () {
8074 var amz = window.amazon;
8075 return React.createElement(Comp, __assign({}, this.props, {
8076 amz: amz,
8077 amazonSignIn: this.signIn,
8078 amazonSignOut: this.signOut
8079 }));
8080 };
8081
8082 return class_1;
8083 }(React.Component)
8084 );
8085}
8086
8087exports.withAmazon = withAmazon;
8088
8089var Button = function Button(props) {
8090 return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
8091 id: ui_1.amazonSignInButton,
8092 onClick: props.amazonSignIn,
8093 theme: props.theme || Amplify_UI_Theme_1["default"],
8094 variant: 'amazonSignInButton'
8095 }, React.createElement(Amplify_UI_Components_React_1.SignInButtonIcon, {
8096 theme: props.theme || Amplify_UI_Theme_1["default"]
8097 }, React.createElement("svg", {
8098 viewBox: "0 0 248 268",
8099 xmlns: "http://www.w3.org/2000/svg"
8100 }, React.createElement("g", {
8101 id: "Artboard-Copy-2",
8102 fill: "none",
8103 fillRule: "evenodd"
8104 }, React.createElement("path", {
8105 d: "M139.056521,147.024612 C133.548808,156.744524 124.782731,162.726926 115.087401,162.726926 C101.790721,162.726926 93.9937779,152.612964 93.9937779,137.68681 C93.9937779,108.224571 120.447551,102.879017 145.533369,102.879017 L145.533369,110.365976 C145.533369,123.831358 145.876354,135.063787 139.056521,147.024612 M207.206992,162.579655 C209.400505,165.692256 209.887066,169.437725 207.063416,171.770186 C199.996315,177.653081 187.429476,188.590967 180.513926,194.716661 L180.46208,194.621133 C178.176838,196.663031 174.862638,196.810303 172.27828,195.445057 C160.780281,185.9162 158.686473,181.494078 152.405048,172.403055 C133.405233,191.751331 119.909143,197.534719 95.309886,197.534719 C66.1281801,197.534719 43.4791563,179.599451 43.4791563,143.669212 C43.4791563,115.616003 58.6782107,96.5105248 80.4019706,87.1727225 C99.2063636,78.9096034 125.464714,77.4528107 145.533369,75.1641337 L145.533369,70.694248 C145.533369,62.4749122 146.167493,52.7510201 141.297893,45.6541312 C137.110277,39.2856386 129.018206,36.6586354 121.859376,36.6586354 C108.658413,36.6586354 96.9171331,43.4171982 94.0416364,57.4199213 C93.4593582,60.532522 91.1701278,63.5933787 88.003492,63.7406501 L54.4387473,60.1424518 C51.6150972,59.5095829 48.4484614,57.2248862 49.2740201,52.8982915 C56.9712583,12.2553679 93.7983558,0 126.732964,0 C143.587124,0 165.606011,4.47386604 178.902691,17.2148315 C195.760839,32.917146 194.149604,53.8694866 194.149604,76.6726704 L194.149604,130.542157 C194.149604,146.734049 200.87372,153.830938 207.206992,162.579655 Z M233.826346,208.038962 C230.467669,203.683255 211.550709,205.9821 203.056405,206.998432 C200.470662,207.321077 200.076227,205.042397 202.406981,203.404973 C217.475208,192.664928 242.201125,195.766353 245.081698,199.363845 C247.966255,202.981502 244.336653,228.071183 230.172839,240.049379 C228.001452,241.888455 225.929671,240.904388 226.89783,238.468418 C230.077218,230.430525 237.204944,212.418868 233.826346,208.038962 Z M126.768855,264 C74.0234043,264 42.0764048,241.955028 17.7852554,217.541992 C12.9733903,212.705982 6.71799208,206.295994 3.31151296,200.690918 C1.90227474,198.372135 5.59096074,195.021875 8.0442063,196.84375 C38.2390146,219.267578 82.1011654,239.538304 125.529506,239.538304 C154.819967,239.538304 191.046475,227.469543 220.66851,214.867659 C225.146771,212.966167 225.146771,219.180222 224.511585,221.060516 C224.183264,222.03242 209.514625,236.221149 189.247207,247.047411 C170.304273,257.166172 146.397132,264 126.768855,264 Z",
8106 id: "Fill-6",
8107 fill: "#FFF"
8108 })))), React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
8109 theme: props.theme || Amplify_UI_Theme_1["default"]
8110 }, core_1.I18n.get('Sign In with Amazon')));
8111};
8112
8113exports.AmazonButton = withAmazon(Button);
8114/**
8115 * @deprecated use named import
8116 */
8117
8118exports["default"] = withAmazon;
8119
8120/***/ }),
8121
8122/***/ "./lib/Auth/Provider/withAuth0.js":
8123/*!****************************************!*\
8124 !*** ./lib/Auth/Provider/withAuth0.js ***!
8125 \****************************************/
8126/*! no static exports found */
8127/***/ (function(module, exports, __webpack_require__) {
8128
8129"use strict";
8130
8131/*
8132 * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
8133 *
8134 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
8135 * the License. A copy of the License is located at
8136 *
8137 * http://aws.amazon.com/apache2.0/
8138 *
8139 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8140 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
8141 * and limitations under the License.
8142 */
8143
8144var __extends = this && this.__extends || function () {
8145 var _extendStatics = function extendStatics(d, b) {
8146 _extendStatics = Object.setPrototypeOf || {
8147 __proto__: []
8148 } instanceof Array && function (d, b) {
8149 d.__proto__ = b;
8150 } || function (d, b) {
8151 for (var p in b) {
8152 if (b.hasOwnProperty(p)) d[p] = b[p];
8153 }
8154 };
8155
8156 return _extendStatics(d, b);
8157 };
8158
8159 return function (d, b) {
8160 _extendStatics(d, b);
8161
8162 function __() {
8163 this.constructor = d;
8164 }
8165
8166 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8167 };
8168}();
8169
8170var __assign = this && this.__assign || function () {
8171 __assign = Object.assign || function (t) {
8172 for (var s, i = 1, n = arguments.length; i < n; i++) {
8173 s = arguments[i];
8174
8175 for (var p in s) {
8176 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8177 }
8178 }
8179
8180 return t;
8181 };
8182
8183 return __assign.apply(this, arguments);
8184};
8185
8186var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
8187 function adopt(value) {
8188 return value instanceof P ? value : new P(function (resolve) {
8189 resolve(value);
8190 });
8191 }
8192
8193 return new (P || (P = Promise))(function (resolve, reject) {
8194 function fulfilled(value) {
8195 try {
8196 step(generator.next(value));
8197 } catch (e) {
8198 reject(e);
8199 }
8200 }
8201
8202 function rejected(value) {
8203 try {
8204 step(generator["throw"](value));
8205 } catch (e) {
8206 reject(e);
8207 }
8208 }
8209
8210 function step(result) {
8211 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
8212 }
8213
8214 step((generator = generator.apply(thisArg, _arguments || [])).next());
8215 });
8216};
8217
8218var __generator = this && this.__generator || function (thisArg, body) {
8219 var _ = {
8220 label: 0,
8221 sent: function sent() {
8222 if (t[0] & 1) throw t[1];
8223 return t[1];
8224 },
8225 trys: [],
8226 ops: []
8227 },
8228 f,
8229 y,
8230 t,
8231 g;
8232 return g = {
8233 next: verb(0),
8234 "throw": verb(1),
8235 "return": verb(2)
8236 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
8237 return this;
8238 }), g;
8239
8240 function verb(n) {
8241 return function (v) {
8242 return step([n, v]);
8243 };
8244 }
8245
8246 function step(op) {
8247 if (f) throw new TypeError("Generator is already executing.");
8248
8249 while (_) {
8250 try {
8251 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;
8252 if (y = 0, t) op = [op[0] & 2, t.value];
8253
8254 switch (op[0]) {
8255 case 0:
8256 case 1:
8257 t = op;
8258 break;
8259
8260 case 4:
8261 _.label++;
8262 return {
8263 value: op[1],
8264 done: false
8265 };
8266
8267 case 5:
8268 _.label++;
8269 y = op[1];
8270 op = [0];
8271 continue;
8272
8273 case 7:
8274 op = _.ops.pop();
8275
8276 _.trys.pop();
8277
8278 continue;
8279
8280 default:
8281 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
8282 _ = 0;
8283 continue;
8284 }
8285
8286 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
8287 _.label = op[1];
8288 break;
8289 }
8290
8291 if (op[0] === 6 && _.label < t[1]) {
8292 _.label = t[1];
8293 t = op;
8294 break;
8295 }
8296
8297 if (t && _.label < t[2]) {
8298 _.label = t[2];
8299
8300 _.ops.push(op);
8301
8302 break;
8303 }
8304
8305 if (t[2]) _.ops.pop();
8306
8307 _.trys.pop();
8308
8309 continue;
8310 }
8311
8312 op = body.call(thisArg, _);
8313 } catch (e) {
8314 op = [6, e];
8315 y = 0;
8316 } finally {
8317 f = t = 0;
8318 }
8319 }
8320
8321 if (op[0] & 5) throw op[1];
8322 return {
8323 value: op[0] ? op[1] : void 0,
8324 done: true
8325 };
8326 }
8327};
8328
8329var __importStar = this && this.__importStar || function (mod) {
8330 if (mod && mod.__esModule) return mod;
8331 var result = {};
8332 if (mod != null) for (var k in mod) {
8333 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
8334 }
8335 result["default"] = mod;
8336 return result;
8337};
8338
8339var __importDefault = this && this.__importDefault || function (mod) {
8340 return mod && mod.__esModule ? mod : {
8341 "default": mod
8342 };
8343};
8344
8345Object.defineProperty(exports, "__esModule", {
8346 value: true
8347});
8348
8349var React = __importStar(__webpack_require__(/*! react */ "react"));
8350
8351var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
8352
8353var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
8354
8355var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js")); // import auth0 from 'auth0-js';
8356
8357
8358var ui_1 = __webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui");
8359
8360var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
8361
8362var constants_1 = __webpack_require__(/*! ../common/constants */ "./lib/Auth/common/constants.js");
8363
8364var logger = new core_1.ConsoleLogger('withAuth0');
8365
8366function withAuth0(Comp, options) {
8367 return (
8368 /** @class */
8369 function (_super) {
8370 __extends(class_1, _super);
8371
8372 function class_1(props) {
8373 var _this = _super.call(this, props) || this;
8374
8375 _this._auth0 = null;
8376 _this.initialize = _this.initialize.bind(_this);
8377 _this.signIn = _this.signIn.bind(_this);
8378 _this.signOut = _this.signOut.bind(_this);
8379 return _this;
8380 }
8381
8382 class_1.prototype.componentDidMount = function () {
8383 if (!window.auth0) {
8384 this.createScript();
8385 } else {
8386 this.initialize();
8387 }
8388 };
8389
8390 class_1.prototype.createScript = function () {
8391 var script = document.createElement('script');
8392 script.src = 'https://cdn.auth0.com/js/auth0/9.8.1/auth0.min.js';
8393 script.async = true;
8394 script.onload = this.initialize;
8395 document.body.appendChild(script);
8396 };
8397
8398 class_1.prototype.initialize = function () {
8399 var _this = this; // @ts-ignore
8400
8401
8402 var _a = auth_1.Auth.configure().oauth,
8403 oauth = _a === void 0 ? {} : _a; // @ts-ignore
8404
8405 var config = this.props.auth0 || options || oauth.auth0;
8406 var _b = this.props,
8407 onError = _b.onError,
8408 onStateChange = _b.onStateChange,
8409 authState = _b.authState;
8410
8411 if (!config) {
8412 logger.debug('Auth0 is not configured');
8413 return;
8414 }
8415
8416 logger.debug('withAuth0 configuration', config);
8417
8418 if (!this._auth0) {
8419 this._auth0 = new window['auth0'].WebAuth(config);
8420 window.auth0_client = this._auth0;
8421 }
8422
8423 if (authState !== 'signedIn') {
8424 this._auth0.parseHash(function (err, authResult) {
8425 if (err || !authResult) {
8426 logger.debug('Failed to parse the url for Auth0', err);
8427 return;
8428 }
8429
8430 var payload = {
8431 provider: constants_1.Constants.AUTH0,
8432 opts: {
8433 returnTo: config.returnTo,
8434 clientID: config.clientID,
8435 federated: config.federated
8436 }
8437 };
8438
8439 try {
8440 localStorage.setItem(constants_1.Constants.AUTH_SOURCE_KEY, JSON.stringify(payload));
8441 } catch (e) {
8442 logger.debug('Failed to cache auth source into localStorage', e);
8443 }
8444
8445 _this._auth0.client.userInfo(authResult.accessToken, function (err, user) {
8446 var username = undefined;
8447 var email = undefined;
8448 var picture = undefined;
8449
8450 if (err) {
8451 logger.debug('Failed to get the user info', err);
8452 } else {
8453 username = user.name;
8454 email = user.email;
8455 picture = user.picture;
8456 }
8457
8458 auth_1.Auth.federatedSignIn(config.domain, {
8459 token: authResult.idToken,
8460 expires_at: authResult.expiresIn * 1000 + new Date().getTime()
8461 }, {
8462 name: username,
8463 email: email,
8464 picture: picture
8465 }).then(function () {
8466 if (onStateChange) {
8467 auth_1.Auth.currentAuthenticatedUser().then(function (user) {
8468 onStateChange('signedIn', user);
8469 });
8470 }
8471 })["catch"](function (e) {
8472 logger.debug('Failed to get the aws credentials', e);
8473 if (onError) onError(e);
8474 });
8475 });
8476 });
8477 }
8478 };
8479
8480 class_1.prototype.signIn = function () {
8481 return __awaiter(this, void 0, void 0, function () {
8482 return __generator(this, function (_a) {
8483 if (this._auth0) this._auth0.authorize();else {
8484 throw new Error('the auth0 client is not configured');
8485 }
8486 return [2
8487 /*return*/
8488 ];
8489 });
8490 });
8491 };
8492
8493 class_1.prototype.signOut = function (opts) {
8494 if (opts === void 0) {
8495 opts = {};
8496 }
8497
8498 var auth0 = window.auth0_client; // @ts-ignore
8499
8500 var returnTo = opts.returnTo,
8501 clientID = opts.clientID,
8502 federated = opts.federated;
8503
8504 if (!auth0) {
8505 logger.debug('auth0 sdk undefined');
8506 return Promise.resolve();
8507 }
8508
8509 auth0.logout({
8510 returnTo: returnTo,
8511 clientID: clientID,
8512 federated: federated
8513 });
8514 };
8515
8516 class_1.prototype.render = function () {
8517 return React.createElement(Comp, __assign({}, this.props, {
8518 auth0: this._auth0,
8519 auth0SignIn: this.signIn,
8520 auth0SignOut: this.signOut
8521 }));
8522 };
8523
8524 return class_1;
8525 }(React.Component)
8526 );
8527}
8528
8529exports.withAuth0 = withAuth0;
8530
8531var Button = function Button(props) {
8532 return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
8533 id: ui_1.auth0SignInButton,
8534 onClick: props.auth0SignIn,
8535 theme: props.theme || Amplify_UI_Theme_1["default"],
8536 variant: 'auth0SignInButton'
8537 }, React.createElement(Amplify_UI_Components_React_1.SignInButtonIcon, {
8538 theme: props.theme || Amplify_UI_Theme_1["default"]
8539 }, React.createElement("svg", {
8540 id: "artwork",
8541 xmlns: "http://www.w3.org/2000/svg",
8542 viewBox: "0 0 193.7 216.6"
8543 }, React.createElement("path", {
8544 id: "NEW",
8545 className: "st0",
8546 d: "M189,66.9L167.2,0H96.8l21.8,66.9H189z M96.8,0H26.5L4.8,66.9h70.4L96.8,0z M4.8,66.9L4.8,66.9\tc-13,39.9,1.2,83.6,35.2,108.3l21.7-66.9L4.8,66.9z M189,66.9L189,66.9l-57,41.4l21.7,66.9l0,0C187.7,150.6,201.9,106.8,189,66.9\tL189,66.9z M39.9,175.2L39.9,175.2l56.9,41.4l56.9-41.4l-56.9-41.4L39.9,175.2z"
8547 }))), React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
8548 theme: props.theme || Amplify_UI_Theme_1["default"]
8549 }, props.label || 'Sign In with Auth0'));
8550};
8551
8552exports.Auth0Button = withAuth0(Button);
8553/**
8554 * @deprecated use named import
8555 */
8556
8557exports["default"] = withAuth0;
8558
8559/***/ }),
8560
8561/***/ "./lib/Auth/Provider/withFacebook.js":
8562/*!*******************************************!*\
8563 !*** ./lib/Auth/Provider/withFacebook.js ***!
8564 \*******************************************/
8565/*! no static exports found */
8566/***/ (function(module, exports, __webpack_require__) {
8567
8568"use strict";
8569
8570/*
8571 * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
8572 *
8573 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
8574 * the License. A copy of the License is located at
8575 *
8576 * http://aws.amazon.com/apache2.0/
8577 *
8578 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8579 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
8580 * and limitations under the License.
8581 */
8582
8583var __extends = this && this.__extends || function () {
8584 var _extendStatics = function extendStatics(d, b) {
8585 _extendStatics = Object.setPrototypeOf || {
8586 __proto__: []
8587 } instanceof Array && function (d, b) {
8588 d.__proto__ = b;
8589 } || function (d, b) {
8590 for (var p in b) {
8591 if (b.hasOwnProperty(p)) d[p] = b[p];
8592 }
8593 };
8594
8595 return _extendStatics(d, b);
8596 };
8597
8598 return function (d, b) {
8599 _extendStatics(d, b);
8600
8601 function __() {
8602 this.constructor = d;
8603 }
8604
8605 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8606 };
8607}();
8608
8609var __assign = this && this.__assign || function () {
8610 __assign = Object.assign || function (t) {
8611 for (var s, i = 1, n = arguments.length; i < n; i++) {
8612 s = arguments[i];
8613
8614 for (var p in s) {
8615 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8616 }
8617 }
8618
8619 return t;
8620 };
8621
8622 return __assign.apply(this, arguments);
8623};
8624
8625var __importStar = this && this.__importStar || function (mod) {
8626 if (mod && mod.__esModule) return mod;
8627 var result = {};
8628 if (mod != null) for (var k in mod) {
8629 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
8630 }
8631 result["default"] = mod;
8632 return result;
8633};
8634
8635var __importDefault = this && this.__importDefault || function (mod) {
8636 return mod && mod.__esModule ? mod : {
8637 "default": mod
8638 };
8639};
8640
8641Object.defineProperty(exports, "__esModule", {
8642 value: true
8643});
8644
8645var React = __importStar(__webpack_require__(/*! react */ "react"));
8646
8647var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
8648
8649var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
8650
8651var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
8652
8653var ui_1 = __webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui");
8654
8655var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
8656
8657var constants_1 = __webpack_require__(/*! ../common/constants */ "./lib/Auth/common/constants.js");
8658
8659var logger = new core_1.ConsoleLogger('withFacebook');
8660
8661function withFacebook(Comp) {
8662 return (
8663 /** @class */
8664 function (_super) {
8665 __extends(class_1, _super);
8666
8667 function class_1(props) {
8668 var _this = _super.call(this, props) || this;
8669
8670 _this.fbAsyncInit = _this.fbAsyncInit.bind(_this);
8671 _this.initFB = _this.initFB.bind(_this);
8672 _this.signIn = _this.signIn.bind(_this);
8673 _this.signOut = _this.signOut.bind(_this);
8674 _this.federatedSignIn = _this.federatedSignIn.bind(_this);
8675 _this.state = {};
8676 return _this;
8677 }
8678
8679 class_1.prototype.signIn = function () {
8680 var _this = this;
8681
8682 var fb = window.FB;
8683 fb.getLoginStatus(function (response) {
8684 var payload = {
8685 provider: constants_1.Constants.FACEBOOK
8686 };
8687
8688 try {
8689 localStorage.setItem(constants_1.Constants.AUTH_SOURCE_KEY, JSON.stringify(payload));
8690 } catch (e) {
8691 logger.debug('Failed to cache auth source into localStorage', e);
8692 }
8693
8694 if (response.status === 'connected') {
8695 _this.federatedSignIn(response.authResponse);
8696 } else {
8697 fb.login(function (response) {
8698 if (!response || !response.authResponse) {
8699 return;
8700 }
8701
8702 _this.federatedSignIn(response.authResponse);
8703 }, {
8704 scope: 'public_profile,email'
8705 });
8706 }
8707 });
8708 };
8709
8710 class_1.prototype.federatedSignIn = function (response) {
8711 logger.debug(response);
8712 var onStateChange = this.props.onStateChange;
8713 var accessToken = response.accessToken,
8714 expiresIn = response.expiresIn;
8715 var date = new Date();
8716 var expires_at = expiresIn * 1000 + date.getTime();
8717
8718 if (!accessToken) {
8719 return;
8720 }
8721
8722 var fb = window.FB;
8723 fb.api('/me', {
8724 fields: 'name,email,picture'
8725 }, function (response) {
8726 var user = {
8727 name: response.name,
8728 email: response.email,
8729 picture: response.picture.data.url
8730 };
8731
8732 if (!auth_1.Auth || typeof auth_1.Auth.federatedSignIn !== 'function' || typeof auth_1.Auth.currentAuthenticatedUser !== 'function') {
8733 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
8734 }
8735
8736 auth_1.Auth.federatedSignIn('facebook', {
8737 token: accessToken,
8738 expires_at: expires_at
8739 }, user).then(function (credentials) {
8740 return auth_1.Auth.currentAuthenticatedUser();
8741 }).then(function (authUser) {
8742 if (onStateChange) {
8743 onStateChange('signedIn', authUser);
8744 }
8745 });
8746 });
8747 };
8748
8749 class_1.prototype.signOut = function () {
8750 var fb = window.FB;
8751
8752 if (!fb) {
8753 logger.debug('FB sdk undefined');
8754 return Promise.resolve();
8755 }
8756
8757 fb.getLoginStatus(function (response) {
8758 if (response.status === 'connected') {
8759 return new Promise(function (res, rej) {
8760 logger.debug('facebook signing out');
8761 fb.logout(function (response) {
8762 res(response);
8763 });
8764 });
8765 } else {
8766 return Promise.resolve();
8767 }
8768 });
8769 };
8770
8771 class_1.prototype.componentDidMount = function () {
8772 var facebook_app_id = this.props.facebook_app_id;
8773 if (facebook_app_id && !window.FB) this.createScript();
8774 };
8775
8776 class_1.prototype.fbAsyncInit = function () {
8777 logger.debug('init FB');
8778 var facebook_app_id = this.props.facebook_app_id;
8779 var fb = window.FB;
8780 fb.init({
8781 appId: facebook_app_id,
8782 cookie: true,
8783 xfbml: true,
8784 version: 'v2.11'
8785 });
8786 fb.getLoginStatus(function (response) {
8787 return logger.debug(response);
8788 });
8789 };
8790
8791 class_1.prototype.initFB = function () {
8792 var fb = window.FB;
8793 logger.debug('FB inited');
8794 };
8795
8796 class_1.prototype.createScript = function () {
8797 window.fbAsyncInit = this.fbAsyncInit;
8798 var script = document.createElement('script');
8799 script.src = 'https://connect.facebook.net/en_US/sdk.js';
8800 script.async = true;
8801 script.onload = this.initFB;
8802 document.body.appendChild(script);
8803 };
8804
8805 class_1.prototype.render = function () {
8806 var fb = window.FB;
8807 return React.createElement(Comp, __assign({}, this.props, {
8808 fb: fb,
8809 facebookSignIn: this.signIn,
8810 facebookSignOut: this.signOut
8811 }));
8812 };
8813
8814 return class_1;
8815 }(React.Component)
8816 );
8817}
8818
8819exports.withFacebook = withFacebook;
8820
8821var Button = function Button(props) {
8822 return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
8823 id: ui_1.facebookSignInButton,
8824 onClick: props.facebookSignIn,
8825 theme: props.theme || Amplify_UI_Theme_1["default"],
8826 variant: 'facebookSignInButton'
8827 }, React.createElement(Amplify_UI_Components_React_1.SignInButtonIcon, {
8828 theme: props.theme || Amplify_UI_Theme_1["default"]
8829 }, React.createElement("svg", {
8830 viewBox: "0 0 279 538",
8831 xmlns: "http://www.w3.org/2000/svg"
8832 }, React.createElement("g", {
8833 id: "Page-1",
8834 fill: "none",
8835 fillRule: "evenodd"
8836 }, React.createElement("g", {
8837 id: "Artboard",
8838 fill: "#FFF"
8839 }, React.createElement("path", {
8840 d: "M82.3409742,538 L82.3409742,292.936652 L0,292.936652 L0,196.990154 L82.2410458,196.990154 L82.2410458,126.4295 C82.2410458,44.575144 132.205229,0 205.252865,0 C240.227794,0 270.306232,2.59855099 279,3.79788222 L279,89.2502322 L228.536175,89.2502322 C188.964542,89.2502322 181.270057,108.139699 181.270057,135.824262 L181.270057,196.89021 L276.202006,196.89021 L263.810888,292.836708 L181.16913,292.836708 L181.16913,538 L82.3409742,538 Z",
8841 id: "Fill-1"
8842 }))))), React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
8843 theme: props.theme || Amplify_UI_Theme_1["default"]
8844 }, core_1.I18n.get('Sign In with Facebook')));
8845};
8846
8847exports.FacebookButton = withFacebook(Button);
8848/**
8849 * @deprecated use named import
8850 */
8851
8852exports["default"] = withFacebook;
8853
8854/***/ }),
8855
8856/***/ "./lib/Auth/Provider/withGoogle.js":
8857/*!*****************************************!*\
8858 !*** ./lib/Auth/Provider/withGoogle.js ***!
8859 \*****************************************/
8860/*! no static exports found */
8861/***/ (function(module, exports, __webpack_require__) {
8862
8863"use strict";
8864
8865/*
8866 * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
8867 *
8868 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
8869 * the License. A copy of the License is located at
8870 *
8871 * http://aws.amazon.com/apache2.0/
8872 *
8873 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8874 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
8875 * and limitations under the License.
8876 */
8877
8878var __extends = this && this.__extends || function () {
8879 var _extendStatics = function extendStatics(d, b) {
8880 _extendStatics = Object.setPrototypeOf || {
8881 __proto__: []
8882 } instanceof Array && function (d, b) {
8883 d.__proto__ = b;
8884 } || function (d, b) {
8885 for (var p in b) {
8886 if (b.hasOwnProperty(p)) d[p] = b[p];
8887 }
8888 };
8889
8890 return _extendStatics(d, b);
8891 };
8892
8893 return function (d, b) {
8894 _extendStatics(d, b);
8895
8896 function __() {
8897 this.constructor = d;
8898 }
8899
8900 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8901 };
8902}();
8903
8904var __assign = this && this.__assign || function () {
8905 __assign = Object.assign || function (t) {
8906 for (var s, i = 1, n = arguments.length; i < n; i++) {
8907 s = arguments[i];
8908
8909 for (var p in s) {
8910 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8911 }
8912 }
8913
8914 return t;
8915 };
8916
8917 return __assign.apply(this, arguments);
8918};
8919
8920var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
8921 function adopt(value) {
8922 return value instanceof P ? value : new P(function (resolve) {
8923 resolve(value);
8924 });
8925 }
8926
8927 return new (P || (P = Promise))(function (resolve, reject) {
8928 function fulfilled(value) {
8929 try {
8930 step(generator.next(value));
8931 } catch (e) {
8932 reject(e);
8933 }
8934 }
8935
8936 function rejected(value) {
8937 try {
8938 step(generator["throw"](value));
8939 } catch (e) {
8940 reject(e);
8941 }
8942 }
8943
8944 function step(result) {
8945 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
8946 }
8947
8948 step((generator = generator.apply(thisArg, _arguments || [])).next());
8949 });
8950};
8951
8952var __generator = this && this.__generator || function (thisArg, body) {
8953 var _ = {
8954 label: 0,
8955 sent: function sent() {
8956 if (t[0] & 1) throw t[1];
8957 return t[1];
8958 },
8959 trys: [],
8960 ops: []
8961 },
8962 f,
8963 y,
8964 t,
8965 g;
8966 return g = {
8967 next: verb(0),
8968 "throw": verb(1),
8969 "return": verb(2)
8970 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
8971 return this;
8972 }), g;
8973
8974 function verb(n) {
8975 return function (v) {
8976 return step([n, v]);
8977 };
8978 }
8979
8980 function step(op) {
8981 if (f) throw new TypeError("Generator is already executing.");
8982
8983 while (_) {
8984 try {
8985 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;
8986 if (y = 0, t) op = [op[0] & 2, t.value];
8987
8988 switch (op[0]) {
8989 case 0:
8990 case 1:
8991 t = op;
8992 break;
8993
8994 case 4:
8995 _.label++;
8996 return {
8997 value: op[1],
8998 done: false
8999 };
9000
9001 case 5:
9002 _.label++;
9003 y = op[1];
9004 op = [0];
9005 continue;
9006
9007 case 7:
9008 op = _.ops.pop();
9009
9010 _.trys.pop();
9011
9012 continue;
9013
9014 default:
9015 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
9016 _ = 0;
9017 continue;
9018 }
9019
9020 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
9021 _.label = op[1];
9022 break;
9023 }
9024
9025 if (op[0] === 6 && _.label < t[1]) {
9026 _.label = t[1];
9027 t = op;
9028 break;
9029 }
9030
9031 if (t && _.label < t[2]) {
9032 _.label = t[2];
9033
9034 _.ops.push(op);
9035
9036 break;
9037 }
9038
9039 if (t[2]) _.ops.pop();
9040
9041 _.trys.pop();
9042
9043 continue;
9044 }
9045
9046 op = body.call(thisArg, _);
9047 } catch (e) {
9048 op = [6, e];
9049 y = 0;
9050 } finally {
9051 f = t = 0;
9052 }
9053 }
9054
9055 if (op[0] & 5) throw op[1];
9056 return {
9057 value: op[0] ? op[1] : void 0,
9058 done: true
9059 };
9060 }
9061};
9062
9063var __importStar = this && this.__importStar || function (mod) {
9064 if (mod && mod.__esModule) return mod;
9065 var result = {};
9066 if (mod != null) for (var k in mod) {
9067 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
9068 }
9069 result["default"] = mod;
9070 return result;
9071};
9072
9073var __importDefault = this && this.__importDefault || function (mod) {
9074 return mod && mod.__esModule ? mod : {
9075 "default": mod
9076 };
9077};
9078
9079Object.defineProperty(exports, "__esModule", {
9080 value: true
9081});
9082
9083var React = __importStar(__webpack_require__(/*! react */ "react"));
9084
9085var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
9086
9087var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
9088
9089var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
9090
9091var ui_1 = __webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui");
9092
9093var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
9094
9095var constants_1 = __webpack_require__(/*! ../common/constants */ "./lib/Auth/common/constants.js");
9096
9097var logger = new core_1.ConsoleLogger('withGoogle');
9098
9099function withGoogle(Comp) {
9100 return (
9101 /** @class */
9102 function (_super) {
9103 __extends(class_1, _super);
9104
9105 function class_1(props) {
9106 var _this = _super.call(this, props) || this;
9107
9108 _this.initGapi = _this.initGapi.bind(_this);
9109 _this.signIn = _this.signIn.bind(_this);
9110 _this.signOut = _this.signOut.bind(_this);
9111 _this.federatedSignIn = _this.federatedSignIn.bind(_this);
9112 _this.state = {};
9113 return _this;
9114 }
9115
9116 class_1.prototype.signIn = function () {
9117 var _this = this;
9118
9119 var ga = window.gapi.auth2.getAuthInstance();
9120 var onError = this.props.onError;
9121 ga.signIn().then(function (googleUser) {
9122 _this.federatedSignIn(googleUser);
9123
9124 var payload = {
9125 provider: constants_1.Constants.GOOGLE
9126 };
9127
9128 try {
9129 localStorage.setItem(constants_1.Constants.AUTH_SOURCE_KEY, JSON.stringify(payload));
9130 } catch (e) {
9131 logger.debug('Failed to cache auth source into localStorage', e);
9132 }
9133 }, function (error) {
9134 if (onError) onError(error);else throw error;
9135 });
9136 };
9137
9138 class_1.prototype.federatedSignIn = function (googleUser) {
9139 return __awaiter(this, void 0, void 0, function () {
9140 var _a, id_token, expires_at, profile, user, onStateChange;
9141
9142 return __generator(this, function (_b) {
9143 switch (_b.label) {
9144 case 0:
9145 _a = googleUser.getAuthResponse(), id_token = _a.id_token, expires_at = _a.expires_at;
9146 profile = googleUser.getBasicProfile();
9147 user = {
9148 email: profile.getEmail(),
9149 name: profile.getName(),
9150 picture: profile.getImageUrl()
9151 };
9152 onStateChange = this.props.onStateChange;
9153
9154 if (!auth_1.Auth || typeof auth_1.Auth.federatedSignIn !== 'function' || typeof auth_1.Auth.currentAuthenticatedUser !== 'function') {
9155 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
9156 }
9157
9158 return [4
9159 /*yield*/
9160 , auth_1.Auth.federatedSignIn('google', {
9161 token: id_token,
9162 expires_at: expires_at
9163 }, user)];
9164
9165 case 1:
9166 _b.sent();
9167
9168 return [4
9169 /*yield*/
9170 , auth_1.Auth.currentAuthenticatedUser()];
9171
9172 case 2:
9173 user = _b.sent();
9174
9175 if (onStateChange) {
9176 onStateChange('signedIn', user);
9177 }
9178
9179 return [2
9180 /*return*/
9181 ];
9182 }
9183 });
9184 });
9185 };
9186
9187 class_1.prototype.signOut = function () {
9188 var authInstance = window.gapi && window.gapi.auth2 ? window.gapi.auth2.getAuthInstance() : null;
9189
9190 if (!authInstance) {
9191 return Promise.resolve();
9192 }
9193
9194 authInstance.then(function (googleAuth) {
9195 if (!googleAuth) {
9196 logger.debug('google Auth undefined');
9197 return Promise.resolve();
9198 }
9199
9200 logger.debug('google signing out');
9201 return googleAuth.signOut();
9202 });
9203 };
9204
9205 class_1.prototype.componentDidMount = function () {
9206 var google_client_id = this.props.google_client_id;
9207 var ga = window.gapi && window.gapi.auth2 ? window.gapi.auth2.getAuthInstance() : null;
9208 if (google_client_id && !ga) this.createScript();
9209 };
9210
9211 class_1.prototype.createScript = function () {
9212 var script = document.createElement('script');
9213 script.src = 'https://apis.google.com/js/platform.js';
9214 script.async = true;
9215 script.onload = this.initGapi;
9216 document.body.appendChild(script);
9217 };
9218
9219 class_1.prototype.initGapi = function () {
9220 logger.debug('init gapi');
9221 var that = this;
9222 var google_client_id = this.props.google_client_id;
9223 var g = window.gapi;
9224 g.load('auth2', function () {
9225 g.auth2.init({
9226 client_id: google_client_id,
9227 scope: 'profile email openid'
9228 });
9229 });
9230 };
9231
9232 class_1.prototype.render = function () {
9233 var ga = window.gapi && window.gapi.auth2 ? window.gapi.auth2.getAuthInstance() : null;
9234 return React.createElement(Comp, __assign({}, this.props, {
9235 ga: ga,
9236 googleSignIn: this.signIn,
9237 googleSignOut: this.signOut
9238 }));
9239 };
9240
9241 return class_1;
9242 }(React.Component)
9243 );
9244}
9245
9246exports.withGoogle = withGoogle;
9247
9248var Button = function Button(props) {
9249 return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
9250 id: ui_1.googleSignInButton,
9251 onClick: props.googleSignIn,
9252 theme: props.theme || Amplify_UI_Theme_1["default"],
9253 variant: "googleSignInButton"
9254 }, React.createElement(Amplify_UI_Components_React_1.SignInButtonIcon, {
9255 theme: props.theme || Amplify_UI_Theme_1["default"]
9256 }, React.createElement("svg", {
9257 viewBox: "0 0 256 262",
9258 xmlns: "http://ww0w.w3.org/2000/svg",
9259 preserveAspectRatio: "xMidYMid"
9260 }, React.createElement("path", {
9261 d: "M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027",
9262 fill: "#4285F4"
9263 }), React.createElement("path", {
9264 d: "M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1",
9265 fill: "#34A853"
9266 }), React.createElement("path", {
9267 d: "M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782",
9268 fill: "#FBBC05"
9269 }), React.createElement("path", {
9270 d: "M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251",
9271 fill: "#EB4335"
9272 }))), React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
9273 theme: props.theme || Amplify_UI_Theme_1["default"]
9274 }, core_1.I18n.get('Sign In with Google')));
9275};
9276
9277exports.GoogleButton = withGoogle(Button);
9278/**
9279 * @deprecated use named import
9280 */
9281
9282exports["default"] = withGoogle;
9283
9284/***/ }),
9285
9286/***/ "./lib/Auth/Provider/withOAuth.js":
9287/*!****************************************!*\
9288 !*** ./lib/Auth/Provider/withOAuth.js ***!
9289 \****************************************/
9290/*! no static exports found */
9291/***/ (function(module, exports, __webpack_require__) {
9292
9293"use strict";
9294
9295/*
9296 * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
9297 *
9298 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
9299 * the License. A copy of the License is located at
9300 *
9301 * http://aws.amazon.com/apache2.0/
9302 *
9303 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9304 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
9305 * and limitations under the License.
9306 */
9307
9308var __extends = this && this.__extends || function () {
9309 var _extendStatics = function extendStatics(d, b) {
9310 _extendStatics = Object.setPrototypeOf || {
9311 __proto__: []
9312 } instanceof Array && function (d, b) {
9313 d.__proto__ = b;
9314 } || function (d, b) {
9315 for (var p in b) {
9316 if (b.hasOwnProperty(p)) d[p] = b[p];
9317 }
9318 };
9319
9320 return _extendStatics(d, b);
9321 };
9322
9323 return function (d, b) {
9324 _extendStatics(d, b);
9325
9326 function __() {
9327 this.constructor = d;
9328 }
9329
9330 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9331 };
9332}();
9333
9334var __assign = this && this.__assign || function () {
9335 __assign = Object.assign || function (t) {
9336 for (var s, i = 1, n = arguments.length; i < n; i++) {
9337 s = arguments[i];
9338
9339 for (var p in s) {
9340 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9341 }
9342 }
9343
9344 return t;
9345 };
9346
9347 return __assign.apply(this, arguments);
9348};
9349
9350var __importStar = this && this.__importStar || function (mod) {
9351 if (mod && mod.__esModule) return mod;
9352 var result = {};
9353 if (mod != null) for (var k in mod) {
9354 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
9355 }
9356 result["default"] = mod;
9357 return result;
9358};
9359
9360var __importDefault = this && this.__importDefault || function (mod) {
9361 return mod && mod.__esModule ? mod : {
9362 "default": mod
9363 };
9364};
9365
9366Object.defineProperty(exports, "__esModule", {
9367 value: true
9368});
9369
9370var React = __importStar(__webpack_require__(/*! react */ "react"));
9371
9372var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
9373
9374var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
9375
9376var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
9377
9378var ui_1 = __webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui");
9379
9380var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
9381
9382function withOAuth(Comp) {
9383 return (
9384 /** @class */
9385 function (_super) {
9386 __extends(class_1, _super);
9387
9388 function class_1(props) {
9389 var _this = _super.call(this, props) || this;
9390
9391 _this.signIn = _this.signIn.bind(_this);
9392 return _this;
9393 }
9394
9395 class_1.prototype.signIn = function (_e, provider) {
9396 auth_1.Auth.federatedSignIn({
9397 provider: provider
9398 });
9399 };
9400
9401 class_1.prototype.render = function () {
9402 return React.createElement(Comp, __assign({}, this.props, {
9403 OAuthSignIn: this.signIn
9404 }));
9405 };
9406
9407 return class_1;
9408 }(React.Component)
9409 );
9410}
9411
9412exports.withOAuth = withOAuth;
9413
9414var Button = function Button(props) {
9415 return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
9416 id: ui_1.oAuthSignInButton,
9417 onClick: function onClick() {
9418 return props.OAuthSignIn();
9419 },
9420 theme: props.theme || Amplify_UI_Theme_1["default"],
9421 variant: 'oAuthSignInButton'
9422 }, React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
9423 theme: props.theme || Amplify_UI_Theme_1["default"]
9424 }, core_1.I18n.get(props.label || 'Sign in with AWS')));
9425};
9426
9427exports.OAuthButton = withOAuth(Button);
9428/**
9429 * @deprecated use named import
9430 */
9431
9432exports["default"] = withOAuth;
9433
9434/***/ }),
9435
9436/***/ "./lib/Auth/RequireNewPassword.js":
9437/*!****************************************!*\
9438 !*** ./lib/Auth/RequireNewPassword.js ***!
9439 \****************************************/
9440/*! no static exports found */
9441/***/ (function(module, exports, __webpack_require__) {
9442
9443"use strict";
9444
9445/*
9446 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
9447 *
9448 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
9449 * the License. A copy of the License is located at
9450 *
9451 * http://aws.amazon.com/apache2.0/
9452 *
9453 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9454 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
9455 * and limitations under the License.
9456 */
9457
9458var __extends = this && this.__extends || function () {
9459 var _extendStatics = function extendStatics(d, b) {
9460 _extendStatics = Object.setPrototypeOf || {
9461 __proto__: []
9462 } instanceof Array && function (d, b) {
9463 d.__proto__ = b;
9464 } || function (d, b) {
9465 for (var p in b) {
9466 if (b.hasOwnProperty(p)) d[p] = b[p];
9467 }
9468 };
9469
9470 return _extendStatics(d, b);
9471 };
9472
9473 return function (d, b) {
9474 _extendStatics(d, b);
9475
9476 function __() {
9477 this.constructor = d;
9478 }
9479
9480 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9481 };
9482}();
9483
9484var __importStar = this && this.__importStar || function (mod) {
9485 if (mod && mod.__esModule) return mod;
9486 var result = {};
9487 if (mod != null) for (var k in mod) {
9488 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
9489 }
9490 result["default"] = mod;
9491 return result;
9492};
9493
9494Object.defineProperty(exports, "__esModule", {
9495 value: true
9496});
9497
9498var React = __importStar(__webpack_require__(/*! react */ "react"));
9499
9500var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
9501
9502var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
9503
9504var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
9505
9506var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
9507
9508var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
9509
9510var logger = new core_1.ConsoleLogger('RequireNewPassword');
9511
9512var RequireNewPassword =
9513/** @class */
9514function (_super) {
9515 __extends(RequireNewPassword, _super);
9516
9517 function RequireNewPassword(props) {
9518 var _this = _super.call(this, props) || this;
9519
9520 _this._validAuthStates = ['requireNewPassword'];
9521 _this.change = _this.change.bind(_this);
9522 _this.checkContact = _this.checkContact.bind(_this);
9523 return _this;
9524 }
9525
9526 RequireNewPassword.prototype.checkContact = function (user) {
9527 var _this = this;
9528
9529 if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
9530 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
9531 }
9532
9533 auth_1.Auth.verifiedContact(user).then(function (data) {
9534 if (!core_1.isEmpty(data.verified)) {
9535 _this.changeState('signedIn', user);
9536 } else {
9537 user = Object.assign(user, data);
9538
9539 _this.changeState('verifyContact', user);
9540 }
9541 });
9542 };
9543
9544 RequireNewPassword.prototype.change = function () {
9545 var _this = this;
9546
9547 var user = this.props.authData;
9548 var password = this.inputs.password;
9549 var requiredAttributes = user.challengeParam.requiredAttributes;
9550 var attrs = objectWithProperties(this.inputs, requiredAttributes);
9551
9552 if (!auth_1.Auth || typeof auth_1.Auth.completeNewPassword !== 'function') {
9553 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
9554 }
9555
9556 auth_1.Auth.completeNewPassword(user, password, attrs).then(function (user) {
9557 logger.debug('complete new password', user);
9558
9559 if (user.challengeName === 'SMS_MFA') {
9560 _this.changeState('confirmSignIn', user);
9561 } else if (user.challengeName === 'MFA_SETUP') {
9562 logger.debug('TOTP setup', user.challengeParam);
9563
9564 _this.changeState('TOTPSetup', user);
9565 } else {
9566 _this.checkContact(user);
9567 }
9568 })["catch"](function (err) {
9569 return _this.error(err);
9570 });
9571 };
9572
9573 RequireNewPassword.prototype.showComponent = function (theme) {
9574 var _this = this;
9575
9576 var hide = this.props.hide;
9577
9578 if (hide && hide.includes(RequireNewPassword)) {
9579 return null;
9580 }
9581
9582 var user = this.props.authData;
9583 var requiredAttributes = user.challengeParam.requiredAttributes;
9584 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
9585 theme: theme,
9586 "data-test": data_test_attributes_1.auth.requireNewPassword.section
9587 }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
9588 theme: theme,
9589 "data-test": data_test_attributes_1.auth.requireNewPassword.headerSection
9590 }, core_1.I18n.get('Change Password')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
9591 theme: theme,
9592 "data-test": data_test_attributes_1.auth.requireNewPassword.bodySection
9593 }, React.createElement(Amplify_UI_Components_React_1.Input, {
9594 autoFocus: true,
9595 placeholder: core_1.I18n.get('New Password'),
9596 theme: theme,
9597 key: "password",
9598 name: "password",
9599 type: "password",
9600 onChange: this.handleInputChange,
9601 "data-test": data_test_attributes_1.auth.requireNewPassword.newPasswordInput
9602 }), requiredAttributes.map(function (attribute) {
9603 return React.createElement(Amplify_UI_Components_React_1.Input, {
9604 placeholder: core_1.I18n.get(convertToPlaceholder(attribute)),
9605 theme: theme,
9606 key: attribute,
9607 name: attribute,
9608 type: "text",
9609 onChange: _this.handleInputChange
9610 });
9611 })), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
9612 theme: theme
9613 }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
9614 theme: theme
9615 }, React.createElement(Amplify_UI_Components_React_1.Button, {
9616 theme: theme,
9617 onClick: this.change
9618 }, core_1.I18n.get('Change'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
9619 theme: theme
9620 }, React.createElement(Amplify_UI_Components_React_1.Link, {
9621 theme: theme,
9622 onClick: function onClick() {
9623 return _this.changeState('signIn');
9624 },
9625 "data-test": data_test_attributes_1.auth.requireNewPassword.backToSignInLink
9626 }, core_1.I18n.get('Back to Sign In')))));
9627 };
9628
9629 return RequireNewPassword;
9630}(AuthPiece_1.AuthPiece);
9631
9632exports.RequireNewPassword = RequireNewPassword;
9633
9634function convertToPlaceholder(str) {
9635 return str.split('_').map(function (part) {
9636 return part.charAt(0).toUpperCase() + part.substr(1).toLowerCase();
9637 }).join(' ');
9638}
9639
9640function objectWithProperties(obj, keys) {
9641 var target = {};
9642
9643 for (var key in obj) {
9644 if (keys.indexOf(key) === -1) {
9645 continue;
9646 }
9647
9648 if (!Object.prototype.hasOwnProperty.call(obj, key)) {
9649 continue;
9650 }
9651
9652 target[key] = obj[key];
9653 }
9654
9655 return target;
9656}
9657/**
9658 * @deprecated use named import
9659 */
9660
9661
9662exports["default"] = RequireNewPassword;
9663
9664/***/ }),
9665
9666/***/ "./lib/Auth/SignIn.js":
9667/*!****************************!*\
9668 !*** ./lib/Auth/SignIn.js ***!
9669 \****************************/
9670/*! no static exports found */
9671/***/ (function(module, exports, __webpack_require__) {
9672
9673"use strict";
9674
9675/*
9676 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
9677 *
9678 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
9679 * the License. A copy of the License is located at
9680 *
9681 * http://aws.amazon.com/apache2.0/
9682 *
9683 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9684 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
9685 * and limitations under the License.
9686 */
9687
9688var __extends = this && this.__extends || function () {
9689 var _extendStatics = function extendStatics(d, b) {
9690 _extendStatics = Object.setPrototypeOf || {
9691 __proto__: []
9692 } instanceof Array && function (d, b) {
9693 d.__proto__ = b;
9694 } || function (d, b) {
9695 for (var p in b) {
9696 if (b.hasOwnProperty(p)) d[p] = b[p];
9697 }
9698 };
9699
9700 return _extendStatics(d, b);
9701 };
9702
9703 return function (d, b) {
9704 _extendStatics(d, b);
9705
9706 function __() {
9707 this.constructor = d;
9708 }
9709
9710 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9711 };
9712}();
9713
9714var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
9715 function adopt(value) {
9716 return value instanceof P ? value : new P(function (resolve) {
9717 resolve(value);
9718 });
9719 }
9720
9721 return new (P || (P = Promise))(function (resolve, reject) {
9722 function fulfilled(value) {
9723 try {
9724 step(generator.next(value));
9725 } catch (e) {
9726 reject(e);
9727 }
9728 }
9729
9730 function rejected(value) {
9731 try {
9732 step(generator["throw"](value));
9733 } catch (e) {
9734 reject(e);
9735 }
9736 }
9737
9738 function step(result) {
9739 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
9740 }
9741
9742 step((generator = generator.apply(thisArg, _arguments || [])).next());
9743 });
9744};
9745
9746var __generator = this && this.__generator || function (thisArg, body) {
9747 var _ = {
9748 label: 0,
9749 sent: function sent() {
9750 if (t[0] & 1) throw t[1];
9751 return t[1];
9752 },
9753 trys: [],
9754 ops: []
9755 },
9756 f,
9757 y,
9758 t,
9759 g;
9760 return g = {
9761 next: verb(0),
9762 "throw": verb(1),
9763 "return": verb(2)
9764 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
9765 return this;
9766 }), g;
9767
9768 function verb(n) {
9769 return function (v) {
9770 return step([n, v]);
9771 };
9772 }
9773
9774 function step(op) {
9775 if (f) throw new TypeError("Generator is already executing.");
9776
9777 while (_) {
9778 try {
9779 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;
9780 if (y = 0, t) op = [op[0] & 2, t.value];
9781
9782 switch (op[0]) {
9783 case 0:
9784 case 1:
9785 t = op;
9786 break;
9787
9788 case 4:
9789 _.label++;
9790 return {
9791 value: op[1],
9792 done: false
9793 };
9794
9795 case 5:
9796 _.label++;
9797 y = op[1];
9798 op = [0];
9799 continue;
9800
9801 case 7:
9802 op = _.ops.pop();
9803
9804 _.trys.pop();
9805
9806 continue;
9807
9808 default:
9809 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
9810 _ = 0;
9811 continue;
9812 }
9813
9814 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
9815 _.label = op[1];
9816 break;
9817 }
9818
9819 if (op[0] === 6 && _.label < t[1]) {
9820 _.label = t[1];
9821 t = op;
9822 break;
9823 }
9824
9825 if (t && _.label < t[2]) {
9826 _.label = t[2];
9827
9828 _.ops.push(op);
9829
9830 break;
9831 }
9832
9833 if (t[2]) _.ops.pop();
9834
9835 _.trys.pop();
9836
9837 continue;
9838 }
9839
9840 op = body.call(thisArg, _);
9841 } catch (e) {
9842 op = [6, e];
9843 y = 0;
9844 } finally {
9845 f = t = 0;
9846 }
9847 }
9848
9849 if (op[0] & 5) throw op[1];
9850 return {
9851 value: op[0] ? op[1] : void 0,
9852 done: true
9853 };
9854 }
9855};
9856
9857var __importStar = this && this.__importStar || function (mod) {
9858 if (mod && mod.__esModule) return mod;
9859 var result = {};
9860 if (mod != null) for (var k in mod) {
9861 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
9862 }
9863 result["default"] = mod;
9864 return result;
9865};
9866
9867Object.defineProperty(exports, "__esModule", {
9868 value: true
9869});
9870
9871var React = __importStar(__webpack_require__(/*! react */ "react"));
9872
9873var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
9874
9875var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
9876
9877var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
9878
9879var FederatedSignIn_1 = __webpack_require__(/*! ./FederatedSignIn */ "./lib/Auth/FederatedSignIn.js");
9880
9881var SignUp_1 = __webpack_require__(/*! ./SignUp */ "./lib/Auth/SignUp.js");
9882
9883var ForgotPassword_1 = __webpack_require__(/*! ./ForgotPassword */ "./lib/Auth/ForgotPassword.js");
9884
9885var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
9886
9887var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
9888
9889var logger = new core_1.ConsoleLogger('SignIn');
9890
9891var SignIn =
9892/** @class */
9893function (_super) {
9894 __extends(SignIn, _super);
9895
9896 function SignIn(props) {
9897 var _this = _super.call(this, props) || this;
9898
9899 _this.checkContact = _this.checkContact.bind(_this);
9900 _this.signIn = _this.signIn.bind(_this);
9901 _this._validAuthStates = ['signIn', 'signedOut', 'signedUp'];
9902 _this.state = {};
9903 return _this;
9904 }
9905
9906 SignIn.prototype.checkContact = function (user) {
9907 var _this = this;
9908
9909 if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
9910 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
9911 }
9912
9913 auth_1.Auth.verifiedContact(user).then(function (data) {
9914 if (!core_1.isEmpty(data.verified)) {
9915 _this.changeState('signedIn', user);
9916 } else {
9917 user = Object.assign(user, data);
9918
9919 _this.changeState('verifyContact', user);
9920 }
9921 });
9922 };
9923
9924 SignIn.prototype.signIn = function (event) {
9925 return __awaiter(this, void 0, void 0, function () {
9926 var username, password, user, err_1;
9927 return __generator(this, function (_a) {
9928 switch (_a.label) {
9929 case 0:
9930 // avoid submitting the form
9931 if (event) {
9932 event.preventDefault();
9933 }
9934
9935 username = this.getUsernameFromInput() || '';
9936 password = this.inputs.password;
9937
9938 if (!auth_1.Auth || typeof auth_1.Auth.signIn !== 'function') {
9939 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
9940 }
9941
9942 this.setState({
9943 loading: true
9944 });
9945 _a.label = 1;
9946
9947 case 1:
9948 _a.trys.push([1, 3, 4, 5]);
9949
9950 return [4
9951 /*yield*/
9952 , auth_1.Auth.signIn(username, password)];
9953
9954 case 2:
9955 user = _a.sent();
9956 logger.debug(user);
9957
9958 if (user.challengeName === 'SMS_MFA' || user.challengeName === 'SOFTWARE_TOKEN_MFA') {
9959 logger.debug('confirm user with ' + user.challengeName);
9960 this.changeState('confirmSignIn', user);
9961 } else if (user.challengeName === 'NEW_PASSWORD_REQUIRED') {
9962 logger.debug('require new password', user.challengeParam);
9963 this.changeState('requireNewPassword', user);
9964 } else if (user.challengeName === 'MFA_SETUP') {
9965 logger.debug('TOTP setup', user.challengeParam);
9966 this.changeState('TOTPSetup', user);
9967 } else if (user.challengeName === 'CUSTOM_CHALLENGE' && user.challengeParam && user.challengeParam.trigger === 'true') {
9968 logger.debug('custom challenge', user.challengeParam);
9969 this.changeState('customConfirmSignIn', user);
9970 } else {
9971 this.checkContact(user);
9972 }
9973
9974 return [3
9975 /*break*/
9976 , 5];
9977
9978 case 3:
9979 err_1 = _a.sent();
9980
9981 if (err_1.code === 'UserNotConfirmedException') {
9982 logger.debug('the user is not confirmed');
9983 this.changeState('confirmSignUp', {
9984 username: username
9985 });
9986 } else if (err_1.code === 'PasswordResetRequiredException') {
9987 logger.debug('the user requires a new password');
9988 this.changeState('forgotPassword', {
9989 username: username
9990 });
9991 } else {
9992 this.error(err_1);
9993 }
9994
9995 return [3
9996 /*break*/
9997 , 5];
9998
9999 case 4:
10000 this.setState({
10001 loading: false
10002 });
10003 return [7
10004 /*endfinally*/
10005 ];
10006
10007 case 5:
10008 return [2
10009 /*return*/
10010 ];
10011 }
10012 });
10013 });
10014 };
10015
10016 SignIn.prototype.showComponent = function (theme) {
10017 var _this = this;
10018
10019 var _a = this.props,
10020 authState = _a.authState,
10021 _b = _a.hide,
10022 hide = _b === void 0 ? [] : _b,
10023 federated = _a.federated,
10024 onStateChange = _a.onStateChange,
10025 onAuthEvent = _a.onAuthEvent,
10026 _c = _a.override,
10027 override = _c === void 0 ? [] : _c;
10028
10029 if (hide && hide.includes(SignIn)) {
10030 return null;
10031 }
10032
10033 var hideSignUp = !override.includes('SignUp') && hide.some(function (component) {
10034 return component === SignUp_1.SignUp;
10035 });
10036 var hideForgotPassword = !override.includes('ForgotPassword') && hide.some(function (component) {
10037 return component === ForgotPassword_1.ForgotPassword;
10038 });
10039 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
10040 theme: theme,
10041 "data-test": data_test_attributes_1.auth.signIn.section
10042 }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
10043 theme: theme,
10044 "data-test": data_test_attributes_1.auth.signIn.headerSection
10045 }, core_1.I18n.get('Sign in to your account')), React.createElement(FederatedSignIn_1.FederatedButtons, {
10046 federated: federated,
10047 theme: theme,
10048 authState: authState,
10049 onStateChange: onStateChange,
10050 onAuthEvent: onAuthEvent
10051 }), React.createElement("form", {
10052 onSubmit: this.signIn
10053 }, React.createElement(Amplify_UI_Components_React_1.SectionBody, {
10054 theme: theme
10055 }, this.renderUsernameField(theme), React.createElement(Amplify_UI_Components_React_1.FormField, {
10056 theme: theme
10057 }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
10058 theme: theme
10059 }, core_1.I18n.get('Password'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
10060 placeholder: core_1.I18n.get('Enter your password'),
10061 theme: theme,
10062 key: "password",
10063 type: "password",
10064 name: "password",
10065 onChange: this.handleInputChange,
10066 "data-test": data_test_attributes_1.auth.signIn.passwordInput
10067 }), !hideForgotPassword && React.createElement(Amplify_UI_Components_React_1.Hint, {
10068 theme: theme
10069 }, core_1.I18n.get('Forgot your password? '), React.createElement(Amplify_UI_Components_React_1.Link, {
10070 theme: theme,
10071 onClick: function onClick() {
10072 return _this.changeState('forgotPassword');
10073 },
10074 "data-test": data_test_attributes_1.auth.signIn.forgotPasswordLink
10075 }, core_1.I18n.get('Reset password'))))), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
10076 theme: theme,
10077 "data-test": data_test_attributes_1.auth.signIn.footerSection
10078 }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
10079 theme: theme
10080 }, React.createElement(Amplify_UI_Components_React_1.Button, {
10081 theme: theme,
10082 type: "submit",
10083 disabled: this.state.loading,
10084 "data-test": data_test_attributes_1.auth.signIn.signInButton
10085 }, core_1.I18n.get('Sign In'))), !hideSignUp && React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
10086 theme: theme
10087 }, core_1.I18n.get('No account? '), React.createElement(Amplify_UI_Components_React_1.Link, {
10088 theme: theme,
10089 onClick: function onClick() {
10090 return _this.changeState('signUp');
10091 },
10092 "data-test": data_test_attributes_1.auth.signIn.createAccountLink
10093 }, core_1.I18n.get('Create account'))))));
10094 };
10095
10096 return SignIn;
10097}(AuthPiece_1.AuthPiece);
10098
10099exports.SignIn = SignIn;
10100/**
10101 * @deprecated use named import
10102 */
10103
10104exports["default"] = SignIn;
10105
10106/***/ }),
10107
10108/***/ "./lib/Auth/SignOut.js":
10109/*!*****************************!*\
10110 !*** ./lib/Auth/SignOut.js ***!
10111 \*****************************/
10112/*! no static exports found */
10113/***/ (function(module, exports, __webpack_require__) {
10114
10115"use strict";
10116
10117/*
10118 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
10119 *
10120 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
10121 * the License. A copy of the License is located at
10122 *
10123 * http://aws.amazon.com/apache2.0/
10124 *
10125 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10126 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
10127 * and limitations under the License.
10128 */
10129
10130var __extends = this && this.__extends || function () {
10131 var _extendStatics = function extendStatics(d, b) {
10132 _extendStatics = Object.setPrototypeOf || {
10133 __proto__: []
10134 } instanceof Array && function (d, b) {
10135 d.__proto__ = b;
10136 } || function (d, b) {
10137 for (var p in b) {
10138 if (b.hasOwnProperty(p)) d[p] = b[p];
10139 }
10140 };
10141
10142 return _extendStatics(d, b);
10143 };
10144
10145 return function (d, b) {
10146 _extendStatics(d, b);
10147
10148 function __() {
10149 this.constructor = d;
10150 }
10151
10152 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10153 };
10154}();
10155
10156var __importStar = this && this.__importStar || function (mod) {
10157 if (mod && mod.__esModule) return mod;
10158 var result = {};
10159 if (mod != null) for (var k in mod) {
10160 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
10161 }
10162 result["default"] = mod;
10163 return result;
10164};
10165
10166var __importDefault = this && this.__importDefault || function (mod) {
10167 return mod && mod.__esModule ? mod : {
10168 "default": mod
10169 };
10170};
10171
10172Object.defineProperty(exports, "__esModule", {
10173 value: true
10174});
10175
10176var React = __importStar(__webpack_require__(/*! react */ "react"));
10177
10178var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
10179
10180var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
10181
10182var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
10183
10184var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
10185
10186var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
10187
10188var constants_1 = __webpack_require__(/*! ./common/constants */ "./lib/Auth/common/constants.js");
10189
10190var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
10191
10192var logger = new core_1.ConsoleLogger('SignOut');
10193
10194var SignOut =
10195/** @class */
10196function (_super) {
10197 __extends(SignOut, _super);
10198
10199 function SignOut(props) {
10200 var _this = _super.call(this, props) || this;
10201
10202 _this.signOut = _this.signOut.bind(_this);
10203 _this.onHubCapsule = _this.onHubCapsule.bind(_this);
10204 core_1.Hub.listen('auth', _this.onHubCapsule);
10205 _this.state = {};
10206 return _this;
10207 }
10208
10209 SignOut.prototype.componentDidMount = function () {
10210 this._isMounted = true;
10211 this.findState();
10212 };
10213
10214 SignOut.prototype.componentWillUnmount = function () {
10215 this._isMounted = false;
10216 };
10217
10218 SignOut.prototype.findState = function () {
10219 var _this = this;
10220
10221 if (!this.props.authState && !this.props.authData) {
10222 auth_1.Auth.currentAuthenticatedUser().then(function (user) {
10223 _this.setState({
10224 authState: 'signedIn',
10225 authData: user,
10226 stateFromStorage: true
10227 });
10228 })["catch"](function (err) {
10229 return logger.error(err);
10230 });
10231 } else if (this.props.stateFromStorage) {
10232 this.setState({
10233 stateFromStorage: true
10234 });
10235 }
10236 };
10237
10238 SignOut.prototype.onHubCapsule = function (capsule) {
10239 if (this._isMounted) {
10240 var channel = capsule.channel,
10241 payload = capsule.payload,
10242 source = capsule.source;
10243
10244 if (channel === 'auth' && payload.event === 'signIn') {
10245 this.setState({
10246 authState: 'signedIn',
10247 authData: payload.data
10248 });
10249 } else if (channel === 'auth' && payload.event === 'signOut' && !this.props.authState) {
10250 this.setState({
10251 authState: 'signIn'
10252 });
10253 }
10254
10255 if (channel === 'auth' && payload.event === 'signIn' && !this.props.authState) {
10256 this.setState({
10257 stateFromStorage: true
10258 });
10259 }
10260 }
10261 };
10262
10263 SignOut.prototype.signOut = function () {
10264 var _this = this;
10265
10266 var payload = {};
10267
10268 try {
10269 payload = JSON.parse(localStorage.getItem(constants_1.Constants.AUTH_SOURCE_KEY)) || {};
10270 localStorage.removeItem(constants_1.Constants.AUTH_SOURCE_KEY);
10271 } catch (e) {
10272 logger.debug("Failed to parse the info from " + constants_1.Constants.AUTH_SOURCE_KEY + " from localStorage with " + e);
10273 }
10274
10275 logger.debug('sign out from the source', payload);
10276 var _a = this.props,
10277 googleSignOut = _a.googleSignOut,
10278 facebookSignOut = _a.facebookSignOut,
10279 amazonSignOut = _a.amazonSignOut,
10280 auth0SignOut = _a.auth0SignOut; // @ts-ignore
10281
10282 switch (payload.provider) {
10283 case constants_1.Constants.GOOGLE:
10284 if (googleSignOut) googleSignOut();else logger.debug('No Google signout method provided');
10285 break;
10286
10287 case constants_1.Constants.FACEBOOK:
10288 if (facebookSignOut) facebookSignOut();else logger.debug('No Facebook signout method provided');
10289 break;
10290
10291 case constants_1.Constants.AMAZON:
10292 if (amazonSignOut) amazonSignOut();else logger.debug('No Amazon signout method provided');
10293 break;
10294
10295 case constants_1.Constants.AUTH0:
10296 // @ts-ignore
10297 if (auth0SignOut) auth0SignOut(payload.opts);else logger.debug('No Auth0 signout method provided');
10298 break;
10299
10300 default:
10301 break;
10302 }
10303
10304 if (!auth_1.Auth || typeof auth_1.Auth.signOut !== 'function') {
10305 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
10306 }
10307
10308 auth_1.Auth.signOut().then(function () {
10309 if (!_this.state.stateFromStorage) {
10310 _this.changeState('signedOut');
10311 }
10312 })["catch"](function (err) {
10313 logger.debug(err);
10314
10315 _this.error(err);
10316 });
10317 };
10318
10319 SignOut.prototype.render = function () {
10320 var hide = this.props.hide;
10321
10322 if (hide && hide.includes(SignOut)) {
10323 return null;
10324 }
10325
10326 var authState = this.props.authState || this.state.authState;
10327 var signedIn = authState === 'signedIn';
10328 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
10329
10330 if (!signedIn) {
10331 return null;
10332 }
10333
10334 return React.createElement(Amplify_UI_Components_React_1.NavButton, {
10335 theme: theme,
10336 onClick: this.signOut,
10337 "data-test": data_test_attributes_1.auth.signOut.button
10338 }, core_1.I18n.get('Sign Out'));
10339 };
10340
10341 return SignOut;
10342}(AuthPiece_1.AuthPiece);
10343
10344exports.SignOut = SignOut;
10345/**
10346 * @deprecated use named import
10347 */
10348
10349exports["default"] = SignOut;
10350
10351/***/ }),
10352
10353/***/ "./lib/Auth/SignUp.js":
10354/*!****************************!*\
10355 !*** ./lib/Auth/SignUp.js ***!
10356 \****************************/
10357/*! no static exports found */
10358/***/ (function(module, exports, __webpack_require__) {
10359
10360"use strict";
10361
10362/*
10363 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
10364 *
10365 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
10366 * the License. A copy of the License is located at
10367 *
10368 * http://aws.amazon.com/apache2.0/
10369 *
10370 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10371 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
10372 * and limitations under the License.
10373 */
10374
10375var __extends = this && this.__extends || function () {
10376 var _extendStatics = function extendStatics(d, b) {
10377 _extendStatics = Object.setPrototypeOf || {
10378 __proto__: []
10379 } instanceof Array && function (d, b) {
10380 d.__proto__ = b;
10381 } || function (d, b) {
10382 for (var p in b) {
10383 if (b.hasOwnProperty(p)) d[p] = b[p];
10384 }
10385 };
10386
10387 return _extendStatics(d, b);
10388 };
10389
10390 return function (d, b) {
10391 _extendStatics(d, b);
10392
10393 function __() {
10394 this.constructor = d;
10395 }
10396
10397 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10398 };
10399}();
10400
10401var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
10402 function adopt(value) {
10403 return value instanceof P ? value : new P(function (resolve) {
10404 resolve(value);
10405 });
10406 }
10407
10408 return new (P || (P = Promise))(function (resolve, reject) {
10409 function fulfilled(value) {
10410 try {
10411 step(generator.next(value));
10412 } catch (e) {
10413 reject(e);
10414 }
10415 }
10416
10417 function rejected(value) {
10418 try {
10419 step(generator["throw"](value));
10420 } catch (e) {
10421 reject(e);
10422 }
10423 }
10424
10425 function step(result) {
10426 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
10427 }
10428
10429 step((generator = generator.apply(thisArg, _arguments || [])).next());
10430 });
10431};
10432
10433var __generator = this && this.__generator || function (thisArg, body) {
10434 var _ = {
10435 label: 0,
10436 sent: function sent() {
10437 if (t[0] & 1) throw t[1];
10438 return t[1];
10439 },
10440 trys: [],
10441 ops: []
10442 },
10443 f,
10444 y,
10445 t,
10446 g;
10447 return g = {
10448 next: verb(0),
10449 "throw": verb(1),
10450 "return": verb(2)
10451 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
10452 return this;
10453 }), g;
10454
10455 function verb(n) {
10456 return function (v) {
10457 return step([n, v]);
10458 };
10459 }
10460
10461 function step(op) {
10462 if (f) throw new TypeError("Generator is already executing.");
10463
10464 while (_) {
10465 try {
10466 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;
10467 if (y = 0, t) op = [op[0] & 2, t.value];
10468
10469 switch (op[0]) {
10470 case 0:
10471 case 1:
10472 t = op;
10473 break;
10474
10475 case 4:
10476 _.label++;
10477 return {
10478 value: op[1],
10479 done: false
10480 };
10481
10482 case 5:
10483 _.label++;
10484 y = op[1];
10485 op = [0];
10486 continue;
10487
10488 case 7:
10489 op = _.ops.pop();
10490
10491 _.trys.pop();
10492
10493 continue;
10494
10495 default:
10496 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
10497 _ = 0;
10498 continue;
10499 }
10500
10501 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
10502 _.label = op[1];
10503 break;
10504 }
10505
10506 if (op[0] === 6 && _.label < t[1]) {
10507 _.label = t[1];
10508 t = op;
10509 break;
10510 }
10511
10512 if (t && _.label < t[2]) {
10513 _.label = t[2];
10514
10515 _.ops.push(op);
10516
10517 break;
10518 }
10519
10520 if (t[2]) _.ops.pop();
10521
10522 _.trys.pop();
10523
10524 continue;
10525 }
10526
10527 op = body.call(thisArg, _);
10528 } catch (e) {
10529 op = [6, e];
10530 y = 0;
10531 } finally {
10532 f = t = 0;
10533 }
10534 }
10535
10536 if (op[0] & 5) throw op[1];
10537 return {
10538 value: op[0] ? op[1] : void 0,
10539 done: true
10540 };
10541 }
10542};
10543
10544var __importStar = this && this.__importStar || function (mod) {
10545 if (mod && mod.__esModule) return mod;
10546 var result = {};
10547 if (mod != null) for (var k in mod) {
10548 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
10549 }
10550 result["default"] = mod;
10551 return result;
10552};
10553
10554Object.defineProperty(exports, "__esModule", {
10555 value: true
10556});
10557
10558var React = __importStar(__webpack_require__(/*! react */ "react"));
10559
10560var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
10561
10562var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
10563
10564var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
10565
10566var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
10567
10568var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
10569
10570var country_dial_codes_1 = __webpack_require__(/*! ./common/country-dial-codes */ "./lib/Auth/common/country-dial-codes.js");
10571
10572var default_sign_up_fields_1 = __webpack_require__(/*! ./common/default-sign-up-fields */ "./lib/Auth/common/default-sign-up-fields.js");
10573
10574var types_1 = __webpack_require__(/*! ./common/types */ "./lib/Auth/common/types.js");
10575
10576var PhoneField_1 = __webpack_require__(/*! ./PhoneField */ "./lib/Auth/PhoneField.js");
10577
10578var logger = new core_1.ConsoleLogger('SignUp');
10579
10580var SignUp =
10581/** @class */
10582function (_super) {
10583 __extends(SignUp, _super);
10584
10585 function SignUp(props) {
10586 var _this = _super.call(this, props) || this;
10587
10588 _this.state = {
10589 requestPending: false
10590 };
10591 _this._validAuthStates = ['signUp'];
10592 _this.signUp = _this.signUp.bind(_this);
10593 _this.sortFields = _this.sortFields.bind(_this);
10594 _this.getDefaultDialCode = _this.getDefaultDialCode.bind(_this);
10595 _this.checkCustomSignUpFields = _this.checkCustomSignUpFields.bind(_this);
10596 _this.needPrefix = _this.needPrefix.bind(_this);
10597 _this.header = _this.props && _this.props.signUpConfig && _this.props.signUpConfig.header ? _this.props.signUpConfig.header : 'Create a new account';
10598 var _a = (_this.props || {}).usernameAttributes,
10599 usernameAttributes = _a === void 0 ? types_1.UsernameAttributes.USERNAME : _a;
10600
10601 if (usernameAttributes === types_1.UsernameAttributes.EMAIL) {
10602 _this.defaultSignUpFields = default_sign_up_fields_1.signUpWithEmailFields;
10603 } else if (usernameAttributes === types_1.UsernameAttributes.PHONE_NUMBER) {
10604 _this.defaultSignUpFields = default_sign_up_fields_1.signUpWithPhoneNumberFields;
10605 } else {
10606 _this.defaultSignUpFields = default_sign_up_fields_1.signUpWithUsernameFields;
10607 }
10608
10609 return _this;
10610 }
10611
10612 SignUp.prototype.validate = function () {
10613 var _this = this;
10614
10615 var invalids = [];
10616 this.signUpFields.map(function (el) {
10617 if (el.key !== 'phone_number') {
10618 if (el.required && !_this.inputs[el.key]) {
10619 el.invalid = true;
10620 invalids.push(el.label);
10621 } else {
10622 el.invalid = false;
10623 }
10624 } else {
10625 if (el.required && !_this.phone_number) {
10626 el.invalid = true;
10627 invalids.push(el.label);
10628 } else {
10629 el.invalid = false;
10630 }
10631 }
10632 });
10633 return invalids;
10634 };
10635
10636 SignUp.prototype.sortFields = function () {
10637 var _this = this;
10638
10639 if (this.props.signUpConfig && this.props.signUpConfig.hiddenDefaults && this.props.signUpConfig.hiddenDefaults.length > 0) {
10640 this.defaultSignUpFields = this.defaultSignUpFields.filter(function (d) {
10641 return !_this.props.signUpConfig.hiddenDefaults.includes(d.key);
10642 });
10643 }
10644
10645 if (this.checkCustomSignUpFields()) {
10646 if (!this.props.signUpConfig || !this.props.signUpConfig.hideAllDefaults) {
10647 // see if fields passed to component should override defaults
10648 this.defaultSignUpFields.forEach(function (f) {
10649 var matchKey = _this.signUpFields.findIndex(function (d) {
10650 return d.key === f.key;
10651 });
10652
10653 if (matchKey === -1) {
10654 _this.signUpFields.push(f);
10655 }
10656 });
10657 }
10658 /*
10659 sort fields based on following rules:
10660 1. Fields with displayOrder are sorted before those without displayOrder
10661 2. Fields with conflicting displayOrder are sorted alphabetically by key
10662 3. Fields without displayOrder are sorted alphabetically by key
10663 */
10664
10665
10666 this.signUpFields.sort(function (a, b) {
10667 if (a.displayOrder && b.displayOrder) {
10668 if (a.displayOrder < b.displayOrder) {
10669 return -1;
10670 } else if (a.displayOrder > b.displayOrder) {
10671 return 1;
10672 } else {
10673 if (a.key < b.key) {
10674 return -1;
10675 } else {
10676 return 1;
10677 }
10678 }
10679 } else if (!a.displayOrder && b.displayOrder) {
10680 return 1;
10681 } else if (a.displayOrder && !b.displayOrder) {
10682 return -1;
10683 } else if (!a.displayOrder && !b.displayOrder) {
10684 if (a.key < b.key) {
10685 return -1;
10686 } else {
10687 return 1;
10688 }
10689 }
10690 });
10691 } else {
10692 this.signUpFields = this.defaultSignUpFields;
10693 }
10694 };
10695
10696 SignUp.prototype.needPrefix = function (key) {
10697 var field = this.signUpFields.find(function (e) {
10698 return e.key === key;
10699 });
10700
10701 if (key.indexOf('custom:') !== 0) {
10702 return field.custom;
10703 } else if (key.indexOf('custom:') === 0 && field.custom === false) {
10704 logger.warn('Custom prefix prepended to key but custom field flag is set to false; retaining manually entered prefix');
10705 }
10706
10707 return null;
10708 };
10709
10710 SignUp.prototype.getDefaultDialCode = function () {
10711 return this.props.signUpConfig && this.props.signUpConfig.defaultCountryCode && country_dial_codes_1.countryDialCodes.indexOf("+" + this.props.signUpConfig.defaultCountryCode) !== -1 ? "+" + this.props.signUpConfig.defaultCountryCode : '+1';
10712 };
10713
10714 SignUp.prototype.checkCustomSignUpFields = function () {
10715 return this.props.signUpConfig && this.props.signUpConfig.signUpFields && this.props.signUpConfig.signUpFields.length > 0;
10716 };
10717
10718 SignUp.prototype.signUp = function () {
10719 return __awaiter(this, void 0, void 0, function () {
10720 var validation, signup_info, inputKeys, inputVals, labelCheck, data, err_1;
10721
10722 var _this = this;
10723
10724 return __generator(this, function (_a) {
10725 switch (_a.label) {
10726 case 0:
10727 this.setState({
10728 requestPending: true
10729 });
10730
10731 if (!this.inputs.dial_code) {
10732 this.inputs.dial_code = this.getDefaultDialCode();
10733 }
10734
10735 validation = this.validate();
10736
10737 if (validation && validation.length > 0) {
10738 this.setState({
10739 requestPending: false
10740 });
10741 return [2
10742 /*return*/
10743 , this.error("The following fields need to be filled out: " + validation.join(', '))];
10744 }
10745
10746 if (!auth_1.Auth || typeof auth_1.Auth.signUp !== 'function') {
10747 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
10748 }
10749
10750 signup_info = {
10751 username: this.inputs.username,
10752 password: this.inputs.password,
10753 attributes: {}
10754 };
10755 inputKeys = Object.keys(this.inputs);
10756 inputVals = Object.values(this.inputs);
10757 inputKeys.forEach(function (key, index) {
10758 if (!['username', 'password', 'checkedValue', 'dial_code'].includes(key)) {
10759 if (key !== 'phone_line_number' && key !== 'dial_code' && key !== 'error') {
10760 var newKey = "" + (_this.needPrefix(key) ? 'custom:' : '') + key;
10761 signup_info.attributes[newKey] = inputVals[index];
10762 }
10763 }
10764 });
10765 if (this.phone_number) signup_info.attributes['phone_number'] = this.phone_number;
10766 labelCheck = false;
10767 this.signUpFields.forEach(function (field) {
10768 if (field.label === _this.getUsernameLabel()) {
10769 logger.debug("Changing the username to the value of " + field.label);
10770 signup_info.username = signup_info.attributes[field.key] || signup_info.username;
10771 labelCheck = true;
10772 }
10773 });
10774
10775 if (!labelCheck && !signup_info.username) {
10776 // if the customer customized the username field in the sign up form
10777 // He needs to either set the key of that field to 'username'
10778 // Or make the label of the field the same as the 'usernameAttributes'
10779 throw new Error("Couldn't find the label: " + this.getUsernameLabel() + ", in sign up fields according to usernameAttributes!");
10780 }
10781
10782 _a.label = 1;
10783
10784 case 1:
10785 _a.trys.push([1, 3, 4, 5]);
10786
10787 return [4
10788 /*yield*/
10789 , auth_1.Auth.signUp(signup_info)];
10790
10791 case 2:
10792 data = _a.sent(); // @ts-ignore
10793
10794 this.changeState('confirmSignUp', data.user.username);
10795 return [3
10796 /*break*/
10797 , 5];
10798
10799 case 3:
10800 err_1 = _a.sent();
10801 this.error(err_1);
10802 return [3
10803 /*break*/
10804 , 5];
10805
10806 case 4:
10807 this.setState({
10808 requestPending: false
10809 });
10810 return [7
10811 /*endfinally*/
10812 ];
10813
10814 case 5:
10815 return [2
10816 /*return*/
10817 ];
10818 }
10819 });
10820 });
10821 };
10822
10823 SignUp.prototype.showComponent = function (theme) {
10824 var _this = this;
10825
10826 var hide = this.props.hide;
10827
10828 if (hide && hide.includes(SignUp)) {
10829 return null;
10830 }
10831
10832 if (this.checkCustomSignUpFields()) {
10833 this.signUpFields = this.props.signUpConfig.signUpFields;
10834 }
10835
10836 this.sortFields();
10837 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
10838 theme: theme,
10839 "data-test": data_test_attributes_1.auth.signUp.section
10840 }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
10841 theme: theme,
10842 "data-test": data_test_attributes_1.auth.signUp.headerSection
10843 }, core_1.I18n.get(this.header)), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
10844 theme: theme,
10845 "data-test": data_test_attributes_1.auth.signUp.bodySection
10846 }, this.signUpFields.map(function (field) {
10847 return field.key !== 'phone_number' ? React.createElement(Amplify_UI_Components_React_1.FormField, {
10848 theme: theme,
10849 key: field.key
10850 }, field.required ? React.createElement(Amplify_UI_Components_React_1.InputLabel, {
10851 theme: theme
10852 }, core_1.I18n.get(field.label), " *") : React.createElement(Amplify_UI_Components_React_1.InputLabel, {
10853 theme: theme
10854 }, core_1.I18n.get(field.label)), React.createElement(Amplify_UI_Components_React_1.Input, {
10855 autoFocus: _this.signUpFields.findIndex(function (f) {
10856 return f.key === field.key;
10857 }) === 0,
10858 placeholder: core_1.I18n.get(field.placeholder),
10859 theme: theme,
10860 type: field.type,
10861 name: field.key,
10862 key: field.key,
10863 onChange: _this.handleInputChange,
10864 "data-test": data_test_attributes_1.auth.signUp.nonPhoneNumberInput
10865 })) : React.createElement(PhoneField_1.PhoneField, {
10866 theme: theme,
10867 required: field.required,
10868 defaultDialCode: _this.getDefaultDialCode(),
10869 label: field.label,
10870 placeholder: field.placeholder,
10871 onChangeText: _this.onPhoneNumberChanged,
10872 key: "phone_number"
10873 });
10874 })), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
10875 theme: theme,
10876 "data-test": data_test_attributes_1.auth.signUp.footerSection
10877 }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
10878 theme: theme
10879 }, React.createElement(Amplify_UI_Components_React_1.Button, {
10880 disabled: this.state.requestPending,
10881 onClick: this.signUp,
10882 theme: theme,
10883 "data-test": data_test_attributes_1.auth.signUp.createAccountButton
10884 }, core_1.I18n.get('Create Account'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
10885 theme: theme
10886 }, core_1.I18n.get('Have an account? '), React.createElement(Amplify_UI_Components_React_1.Link, {
10887 theme: theme,
10888 onClick: function onClick() {
10889 return _this.changeState('signIn');
10890 },
10891 "data-test": data_test_attributes_1.auth.signUp.signInLink
10892 }, core_1.I18n.get('Sign in')))));
10893 };
10894
10895 return SignUp;
10896}(AuthPiece_1.AuthPiece);
10897
10898exports.SignUp = SignUp;
10899/**
10900 * @deprecated use named import
10901 */
10902
10903exports["default"] = SignUp;
10904
10905/***/ }),
10906
10907/***/ "./lib/Auth/TOTPSetup.js":
10908/*!*******************************!*\
10909 !*** ./lib/Auth/TOTPSetup.js ***!
10910 \*******************************/
10911/*! no static exports found */
10912/***/ (function(module, exports, __webpack_require__) {
10913
10914"use strict";
10915
10916/*
10917 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
10918 *
10919 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
10920 * the License. A copy of the License is located at
10921 *
10922 * http://aws.amazon.com/apache2.0/
10923 *
10924 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10925 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
10926 * and limitations under the License.
10927 */
10928
10929var __extends = this && this.__extends || function () {
10930 var _extendStatics = function extendStatics(d, b) {
10931 _extendStatics = Object.setPrototypeOf || {
10932 __proto__: []
10933 } instanceof Array && function (d, b) {
10934 d.__proto__ = b;
10935 } || function (d, b) {
10936 for (var p in b) {
10937 if (b.hasOwnProperty(p)) d[p] = b[p];
10938 }
10939 };
10940
10941 return _extendStatics(d, b);
10942 };
10943
10944 return function (d, b) {
10945 _extendStatics(d, b);
10946
10947 function __() {
10948 this.constructor = d;
10949 }
10950
10951 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10952 };
10953}();
10954
10955var __assign = this && this.__assign || function () {
10956 __assign = Object.assign || function (t) {
10957 for (var s, i = 1, n = arguments.length; i < n; i++) {
10958 s = arguments[i];
10959
10960 for (var p in s) {
10961 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10962 }
10963 }
10964
10965 return t;
10966 };
10967
10968 return __assign.apply(this, arguments);
10969};
10970
10971var __importStar = this && this.__importStar || function (mod) {
10972 if (mod && mod.__esModule) return mod;
10973 var result = {};
10974 if (mod != null) for (var k in mod) {
10975 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
10976 }
10977 result["default"] = mod;
10978 return result;
10979};
10980
10981Object.defineProperty(exports, "__esModule", {
10982 value: true
10983});
10984
10985var React = __importStar(__webpack_require__(/*! react */ "react"));
10986
10987var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
10988
10989var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
10990
10991var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
10992
10993var TOTPSetupComp_1 = __webpack_require__(/*! ../Widget/TOTPSetupComp */ "./lib/Widget/TOTPSetupComp.js");
10994
10995var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
10996
10997var logger = new core_1.ConsoleLogger('TOTPSetup');
10998
10999var TOTPSetup =
11000/** @class */
11001function (_super) {
11002 __extends(TOTPSetup, _super);
11003
11004 function TOTPSetup(props) {
11005 var _this = _super.call(this, props) || this;
11006
11007 _this._validAuthStates = ['TOTPSetup'];
11008 _this.onTOTPEvent = _this.onTOTPEvent.bind(_this);
11009 _this.checkContact = _this.checkContact.bind(_this);
11010 return _this;
11011 }
11012
11013 TOTPSetup.prototype.checkContact = function (user) {
11014 var _this = this;
11015
11016 if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
11017 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
11018 }
11019
11020 auth_1.Auth.verifiedContact(user).then(function (data) {
11021 if (!core_1.isEmpty(data.verified)) {
11022 _this.changeState('signedIn', user);
11023 } else {
11024 var newUser = Object.assign(user, data);
11025
11026 _this.changeState('verifyContact', newUser);
11027 }
11028 });
11029 };
11030
11031 TOTPSetup.prototype.onTOTPEvent = function (event, data, user) {
11032 logger.debug('on totp event', event, data); // const user = this.props.authData;
11033
11034 if (event === 'Setup TOTP') {
11035 if (data === 'SUCCESS') {
11036 this.checkContact(user);
11037 }
11038 }
11039 };
11040
11041 TOTPSetup.prototype.showComponent = function (theme) {
11042 var hide = this.props.hide;
11043
11044 if (hide && hide.includes(TOTPSetup)) {
11045 return null;
11046 }
11047
11048 return React.createElement(TOTPSetupComp_1.TOTPSetupComp, __assign({}, this.props, {
11049 onTOTPEvent: this.onTOTPEvent,
11050 "data-test": data_test_attributes_1.auth.TOTPSetup.component
11051 }));
11052 };
11053
11054 return TOTPSetup;
11055}(AuthPiece_1.AuthPiece);
11056
11057exports.TOTPSetup = TOTPSetup;
11058/**
11059 * @deprecated use named import
11060 */
11061
11062exports["default"] = TOTPSetup;
11063
11064/***/ }),
11065
11066/***/ "./lib/Auth/VerifyContact.js":
11067/*!***********************************!*\
11068 !*** ./lib/Auth/VerifyContact.js ***!
11069 \***********************************/
11070/*! no static exports found */
11071/***/ (function(module, exports, __webpack_require__) {
11072
11073"use strict";
11074
11075/*
11076 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
11077 *
11078 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
11079 * the License. A copy of the License is located at
11080 *
11081 * http://aws.amazon.com/apache2.0/
11082 *
11083 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11084 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11085 * and limitations under the License.
11086 */
11087
11088var __extends = this && this.__extends || function () {
11089 var _extendStatics = function extendStatics(d, b) {
11090 _extendStatics = Object.setPrototypeOf || {
11091 __proto__: []
11092 } instanceof Array && function (d, b) {
11093 d.__proto__ = b;
11094 } || function (d, b) {
11095 for (var p in b) {
11096 if (b.hasOwnProperty(p)) d[p] = b[p];
11097 }
11098 };
11099
11100 return _extendStatics(d, b);
11101 };
11102
11103 return function (d, b) {
11104 _extendStatics(d, b);
11105
11106 function __() {
11107 this.constructor = d;
11108 }
11109
11110 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11111 };
11112}();
11113
11114var __importStar = this && this.__importStar || function (mod) {
11115 if (mod && mod.__esModule) return mod;
11116 var result = {};
11117 if (mod != null) for (var k in mod) {
11118 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
11119 }
11120 result["default"] = mod;
11121 return result;
11122};
11123
11124var __importDefault = this && this.__importDefault || function (mod) {
11125 return mod && mod.__esModule ? mod : {
11126 "default": mod
11127 };
11128};
11129
11130Object.defineProperty(exports, "__esModule", {
11131 value: true
11132});
11133
11134var React = __importStar(__webpack_require__(/*! react */ "react"));
11135
11136var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
11137
11138var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
11139
11140var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
11141
11142var AmplifyTheme_1 = __importDefault(__webpack_require__(/*! ../AmplifyTheme */ "./lib/AmplifyTheme.js"));
11143
11144var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
11145
11146var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
11147
11148var logger = new core_1.ConsoleLogger('VerifyContact');
11149
11150var VerifyContact =
11151/** @class */
11152function (_super) {
11153 __extends(VerifyContact, _super);
11154
11155 function VerifyContact(props) {
11156 var _this = _super.call(this, props) || this;
11157
11158 _this._validAuthStates = ['verifyContact'];
11159 _this.verify = _this.verify.bind(_this);
11160 _this.submit = _this.submit.bind(_this);
11161 _this.state = {
11162 verifyAttr: null
11163 };
11164 return _this;
11165 }
11166
11167 VerifyContact.prototype.verify = function () {
11168 var _this = this;
11169
11170 var _a = this.inputs,
11171 contact = _a.contact,
11172 checkedValue = _a.checkedValue;
11173
11174 if (!contact) {
11175 this.error('Neither Email nor Phone Number selected');
11176 return;
11177 }
11178
11179 if (!auth_1.Auth || typeof auth_1.Auth.verifyCurrentUserAttribute !== 'function') {
11180 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
11181 }
11182
11183 auth_1.Auth.verifyCurrentUserAttribute(checkedValue).then(function (data) {
11184 logger.debug(data);
11185
11186 _this.setState({
11187 verifyAttr: checkedValue
11188 });
11189 })["catch"](function (err) {
11190 return _this.error(err);
11191 });
11192 };
11193
11194 VerifyContact.prototype.submit = function () {
11195 var _this = this;
11196
11197 var attr = this.state.verifyAttr;
11198 var code = this.inputs.code;
11199
11200 if (!auth_1.Auth || typeof auth_1.Auth.verifyCurrentUserAttributeSubmit !== 'function') {
11201 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
11202 }
11203
11204 auth_1.Auth.verifyCurrentUserAttributeSubmit(attr, code).then(function (data) {
11205 logger.debug(data);
11206
11207 _this.changeState('signedIn', _this.props.authData);
11208
11209 _this.setState({
11210 verifyAttr: null
11211 });
11212 })["catch"](function (err) {
11213 return _this.error(err);
11214 });
11215 };
11216
11217 VerifyContact.prototype.verifyView = function () {
11218 var user = this.props.authData;
11219
11220 if (!user) {
11221 logger.debug('no user for verify');
11222 return null;
11223 }
11224
11225 var unverified = user.unverified;
11226
11227 if (!unverified) {
11228 logger.debug('no unverified on user');
11229 return null;
11230 }
11231
11232 var email = unverified.email,
11233 phone_number = unverified.phone_number;
11234 var theme = this.props.theme || AmplifyTheme_1["default"];
11235 return React.createElement("div", null, email ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
11236 placeholder: core_1.I18n.get('Email'),
11237 theme: theme,
11238 key: "email",
11239 name: "contact",
11240 value: "email",
11241 onChange: this.handleInputChange
11242 }) : null, phone_number ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
11243 placeholder: core_1.I18n.get('Phone Number'),
11244 theme: theme,
11245 key: "phone_number",
11246 name: "contact",
11247 value: "phone_number",
11248 onChange: this.handleInputChange
11249 }) : null);
11250 };
11251
11252 VerifyContact.prototype.submitView = function () {
11253 var theme = this.props.theme || AmplifyTheme_1["default"];
11254 return React.createElement("div", null, React.createElement(Amplify_UI_Components_React_1.Input, {
11255 placeholder: core_1.I18n.get('Code'),
11256 theme: theme,
11257 key: "code",
11258 name: "code",
11259 autoComplete: "off",
11260 onChange: this.handleInputChange
11261 }));
11262 };
11263
11264 VerifyContact.prototype.showComponent = function (theme) {
11265 var _this = this;
11266
11267 var _a = this.props,
11268 authData = _a.authData,
11269 hide = _a.hide;
11270
11271 if (hide && hide.includes(VerifyContact)) {
11272 return null;
11273 }
11274
11275 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
11276 theme: theme,
11277 "data-test": data_test_attributes_1.auth.verifyContact.section
11278 }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
11279 theme: theme,
11280 "data-test": data_test_attributes_1.auth.verifyContact.headerSection
11281 }, core_1.I18n.get('Account recovery requires verified contact information')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
11282 theme: theme,
11283 "data-test": data_test_attributes_1.auth.verifyContact.bodySection
11284 }, this.state.verifyAttr ? this.submitView() : this.verifyView()), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
11285 theme: theme
11286 }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
11287 theme: theme
11288 }, this.state.verifyAttr ? React.createElement(Amplify_UI_Components_React_1.Button, {
11289 theme: theme,
11290 onClick: this.submit,
11291 "data-test": data_test_attributes_1.auth.verifyContact.submitButton
11292 }, core_1.I18n.get('Submit')) : React.createElement(Amplify_UI_Components_React_1.Button, {
11293 theme: theme,
11294 onClick: this.verify,
11295 "data-test": data_test_attributes_1.auth.verifyContact.verifyButton
11296 }, core_1.I18n.get('Verify'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
11297 theme: theme
11298 }, React.createElement(Amplify_UI_Components_React_1.Link, {
11299 theme: theme,
11300 onClick: function onClick() {
11301 return _this.changeState('signedIn', authData);
11302 },
11303 "data-test": data_test_attributes_1.auth.verifyContact.skipLink
11304 }, core_1.I18n.get('Skip')))));
11305 };
11306
11307 return VerifyContact;
11308}(AuthPiece_1.AuthPiece);
11309
11310exports.VerifyContact = VerifyContact;
11311/**
11312 * @deprecated use named import
11313 */
11314
11315exports["default"] = VerifyContact;
11316
11317/***/ }),
11318
11319/***/ "./lib/Auth/common/constants.js":
11320/*!**************************************!*\
11321 !*** ./lib/Auth/common/constants.js ***!
11322 \**************************************/
11323/*! no static exports found */
11324/***/ (function(module, exports, __webpack_require__) {
11325
11326"use strict";
11327
11328
11329Object.defineProperty(exports, "__esModule", {
11330 value: true
11331});
11332exports.Constants = {
11333 AUTH_SOURCE_KEY: 'amplify-react-auth-source',
11334 AUTH0: 'auth0',
11335 GOOGLE: 'google',
11336 FACEBOOK: 'facebook',
11337 AMAZON: 'amazon',
11338 REDIRECTED_FROM_HOSTED_UI: 'amplify-redirected-from-hosted-ui'
11339};
11340
11341/***/ }),
11342
11343/***/ "./lib/Auth/common/country-dial-codes.js":
11344/*!***********************************************!*\
11345 !*** ./lib/Auth/common/country-dial-codes.js ***!
11346 \***********************************************/
11347/*! no static exports found */
11348/***/ (function(module, exports, __webpack_require__) {
11349
11350"use strict";
11351
11352
11353Object.defineProperty(exports, "__esModule", {
11354 value: true
11355});
11356exports.countryDialCodes = ['+1', '+7', '+20', '+27', '+30', '+31', '+32', '+33', '+34', '+36', '+39', '+40', '+41', '+43', '+44', '+45', '+46', '+47', '+48', '+49', '+51', '+52', '+53', '+54', '+55', '+56', '+57', '+58', '+60', '+61', '+62', '+63', '+64', '+65', '+66', '+81', '+82', '+84', '+86', '+90', '+91', '+92', '+93', '+94', '+95', '+98', '+212', '+213', '+216', '+218', '+220', '+221', '+222', '+223', '+224', '+225', '+226', '+227', '+228', '+229', '+230', '+231', '+232', '+233', '+234', '+235', '+236', '+237', '+238', '+239', '+240', '+241', '+242', '+243', '+244', '+245', '+246', '+248', '+249', '+250', '+251', '+252', '+253', '+254', '+255', '+256', '+257', '+258', '+260', '+261', '+262', '+263', '+264', '+265', '+266', '+267', '+268', '+269', '+290', '+291', '+297', '+298', '+299', '+345', '+350', '+351', '+352', '+353', '+354', '+355', '+356', '+357', '+358', '+359', '+370', '+371', '+372', '+373', '+374', '+375', '+376', '+377', '+378', '+379', '+380', '+381', '+382', '+385', '+386', '+387', '+389', '+420', '+421', '+423', '+500', '+501', '+502', '+503', '+504', '+505', '+506', '+507', '+508', '+509', '+537', '+590', '+591', '+593', '+594', '+595', '+596', '+597', '+598', '+599', '+670', '+672', '+673', '+674', '+675', '+676', '+677', '+678', '+679', '+680', '+681', '+682', '+683', '+685', '+686', '+687', '+688', '+689', '+690', '+691', '+692', '+850', '+852', '+853', '+855', '+856', '+872', '+880', '+886', '+960', '+961', '+962', '+963', '+964', '+965', '+966', '+967', '+968', '+970', '+971', '+972', '+973', '+974', '+975', '+976', '+977', '+992', '+993', '+994', '+995', '+996', '+998'];
11357
11358/***/ }),
11359
11360/***/ "./lib/Auth/common/default-sign-up-fields.js":
11361/*!***************************************************!*\
11362 !*** ./lib/Auth/common/default-sign-up-fields.js ***!
11363 \***************************************************/
11364/*! no static exports found */
11365/***/ (function(module, exports, __webpack_require__) {
11366
11367"use strict";
11368
11369
11370Object.defineProperty(exports, "__esModule", {
11371 value: true
11372});
11373exports.signUpWithUsernameFields = [{
11374 label: 'Username',
11375 key: 'username',
11376 required: true,
11377 placeholder: 'Username',
11378 displayOrder: 1
11379}, {
11380 label: 'Password',
11381 key: 'password',
11382 required: true,
11383 placeholder: 'Password',
11384 type: 'password',
11385 displayOrder: 2
11386}, {
11387 label: 'Email',
11388 key: 'email',
11389 required: true,
11390 placeholder: 'Email',
11391 type: 'email',
11392 displayOrder: 3
11393}, {
11394 label: 'Phone Number',
11395 key: 'phone_number',
11396 placeholder: 'Phone Number',
11397 required: true,
11398 displayOrder: 4
11399}];
11400exports.signUpWithEmailFields = [{
11401 label: 'Email',
11402 key: 'email',
11403 required: true,
11404 placeholder: 'Email',
11405 type: 'email',
11406 displayOrder: 1
11407}, {
11408 label: 'Password',
11409 key: 'password',
11410 required: true,
11411 placeholder: 'Password',
11412 type: 'password',
11413 displayOrder: 2
11414}, {
11415 label: 'Phone Number',
11416 key: 'phone_number',
11417 placeholder: 'Phone Number',
11418 required: true,
11419 displayOrder: 3
11420}];
11421exports.signUpWithPhoneNumberFields = [{
11422 label: 'Phone Number',
11423 key: 'phone_number',
11424 placeholder: 'Phone Number',
11425 required: true,
11426 displayOrder: 1
11427}, {
11428 label: 'Password',
11429 key: 'password',
11430 required: true,
11431 placeholder: 'Password',
11432 type: 'password',
11433 displayOrder: 2
11434}, {
11435 label: 'Email',
11436 key: 'email',
11437 required: true,
11438 placeholder: 'Email',
11439 type: 'email',
11440 displayOrder: 3
11441}];
11442
11443/***/ }),
11444
11445/***/ "./lib/Auth/common/types.js":
11446/*!**********************************!*\
11447 !*** ./lib/Auth/common/types.js ***!
11448 \**********************************/
11449/*! no static exports found */
11450/***/ (function(module, exports, __webpack_require__) {
11451
11452"use strict";
11453
11454
11455Object.defineProperty(exports, "__esModule", {
11456 value: true
11457});
11458var UsernameAttributes;
11459
11460(function (UsernameAttributes) {
11461 UsernameAttributes["EMAIL"] = "email";
11462 UsernameAttributes["PHONE_NUMBER"] = "phone_number";
11463 UsernameAttributes["USERNAME"] = "username";
11464})(UsernameAttributes = exports.UsernameAttributes || (exports.UsernameAttributes = {}));
11465
11466/***/ }),
11467
11468/***/ "./lib/Auth/index.js":
11469/*!***************************!*\
11470 !*** ./lib/Auth/index.js ***!
11471 \***************************/
11472/*! no static exports found */
11473/***/ (function(module, exports, __webpack_require__) {
11474
11475"use strict";
11476
11477/*
11478 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
11479 *
11480 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
11481 * the License. A copy of the License is located at
11482 *
11483 * http://aws.amazon.com/apache2.0/
11484 *
11485 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11486 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11487 * and limitations under the License.
11488 */
11489
11490function _typeof(obj) {
11491 "@babel/helpers - typeof";
11492
11493 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
11494 _typeof = function _typeof(obj) {
11495 return typeof obj;
11496 };
11497 } else {
11498 _typeof = function _typeof(obj) {
11499 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
11500 };
11501 }
11502
11503 return _typeof(obj);
11504}
11505
11506var __extends = this && this.__extends || function () {
11507 var _extendStatics = function extendStatics(d, b) {
11508 _extendStatics = Object.setPrototypeOf || {
11509 __proto__: []
11510 } instanceof Array && function (d, b) {
11511 d.__proto__ = b;
11512 } || function (d, b) {
11513 for (var p in b) {
11514 if (b.hasOwnProperty(p)) d[p] = b[p];
11515 }
11516 };
11517
11518 return _extendStatics(d, b);
11519 };
11520
11521 return function (d, b) {
11522 _extendStatics(d, b);
11523
11524 function __() {
11525 this.constructor = d;
11526 }
11527
11528 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11529 };
11530}();
11531
11532var __assign = this && this.__assign || function () {
11533 __assign = Object.assign || function (t) {
11534 for (var s, i = 1, n = arguments.length; i < n; i++) {
11535 s = arguments[i];
11536
11537 for (var p in s) {
11538 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
11539 }
11540 }
11541
11542 return t;
11543 };
11544
11545 return __assign.apply(this, arguments);
11546};
11547
11548function __export(m) {
11549 for (var p in m) {
11550 if (!exports.hasOwnProperty(p)) exports[p] = m[p];
11551 }
11552}
11553
11554var __importStar = this && this.__importStar || function (mod) {
11555 if (mod && mod.__esModule) return mod;
11556 var result = {};
11557 if (mod != null) for (var k in mod) {
11558 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
11559 }
11560 result["default"] = mod;
11561 return result;
11562};
11563
11564Object.defineProperty(exports, "__esModule", {
11565 value: true
11566});
11567
11568var React = __importStar(__webpack_require__(/*! react */ "react"));
11569
11570var Authenticator_1 = __webpack_require__(/*! ./Authenticator */ "./lib/Auth/Authenticator.js");
11571
11572var Authenticator_2 = __webpack_require__(/*! ./Authenticator */ "./lib/Auth/Authenticator.js");
11573
11574exports.Authenticator = Authenticator_2.Authenticator;
11575
11576var AuthPiece_1 = __webpack_require__(/*! ./AuthPiece */ "./lib/Auth/AuthPiece.js");
11577
11578exports.AuthPiece = AuthPiece_1.AuthPiece;
11579
11580var SignIn_1 = __webpack_require__(/*! ./SignIn */ "./lib/Auth/SignIn.js");
11581
11582exports.SignIn = SignIn_1.SignIn;
11583
11584var ConfirmSignIn_1 = __webpack_require__(/*! ./ConfirmSignIn */ "./lib/Auth/ConfirmSignIn.js");
11585
11586exports.ConfirmSignIn = ConfirmSignIn_1.ConfirmSignIn;
11587
11588var SignOut_1 = __webpack_require__(/*! ./SignOut */ "./lib/Auth/SignOut.js");
11589
11590exports.SignOut = SignOut_1.SignOut;
11591
11592var RequireNewPassword_1 = __webpack_require__(/*! ./RequireNewPassword */ "./lib/Auth/RequireNewPassword.js");
11593
11594exports.RequireNewPassword = RequireNewPassword_1.RequireNewPassword;
11595
11596var SignUp_1 = __webpack_require__(/*! ./SignUp */ "./lib/Auth/SignUp.js");
11597
11598exports.SignUp = SignUp_1.SignUp;
11599
11600var ConfirmSignUp_1 = __webpack_require__(/*! ./ConfirmSignUp */ "./lib/Auth/ConfirmSignUp.js");
11601
11602exports.ConfirmSignUp = ConfirmSignUp_1.ConfirmSignUp;
11603
11604var VerifyContact_1 = __webpack_require__(/*! ./VerifyContact */ "./lib/Auth/VerifyContact.js");
11605
11606exports.VerifyContact = VerifyContact_1.VerifyContact;
11607
11608var ForgotPassword_1 = __webpack_require__(/*! ./ForgotPassword */ "./lib/Auth/ForgotPassword.js");
11609
11610exports.ForgotPassword = ForgotPassword_1.ForgotPassword;
11611
11612var Greetings_1 = __webpack_require__(/*! ./Greetings */ "./lib/Auth/Greetings.js");
11613
11614exports.Greetings = Greetings_1.Greetings;
11615
11616var FederatedSignIn_1 = __webpack_require__(/*! ./FederatedSignIn */ "./lib/Auth/FederatedSignIn.js");
11617
11618exports.FederatedSignIn = FederatedSignIn_1.FederatedSignIn;
11619exports.FederatedButtons = FederatedSignIn_1.FederatedButtons;
11620
11621var TOTPSetup_1 = __webpack_require__(/*! ./TOTPSetup */ "./lib/Auth/TOTPSetup.js");
11622
11623exports.TOTPSetup = TOTPSetup_1.TOTPSetup;
11624
11625var Loading_1 = __webpack_require__(/*! ./Loading */ "./lib/Auth/Loading.js");
11626
11627exports.Loading = Loading_1.Loading;
11628
11629__export(__webpack_require__(/*! ./Provider */ "./lib/Auth/Provider/index.js"));
11630
11631__export(__webpack_require__(/*! ./common/types */ "./lib/Auth/common/types.js"));
11632
11633function withAuthenticator(Comp, includeGreetings, authenticatorComponents, federated, theme, signUpConfig) {
11634 if (includeGreetings === void 0) {
11635 includeGreetings = false;
11636 }
11637
11638 if (authenticatorComponents === void 0) {
11639 authenticatorComponents = [];
11640 }
11641
11642 if (federated === void 0) {
11643 federated = null;
11644 }
11645
11646 if (theme === void 0) {
11647 theme = null;
11648 }
11649
11650 if (signUpConfig === void 0) {
11651 signUpConfig = {};
11652 }
11653
11654 return (
11655 /** @class */
11656 function (_super) {
11657 __extends(class_1, _super);
11658
11659 function class_1(props) {
11660 var _this = _super.call(this, props) || this;
11661
11662 _this.handleAuthStateChange = _this.handleAuthStateChange.bind(_this);
11663 _this.state = {
11664 authState: props.authState || null,
11665 authData: props.authData || null
11666 };
11667 _this.authConfig = {};
11668
11669 if (_typeof(includeGreetings) === 'object' && includeGreetings !== null) {
11670 _this.authConfig = Object.assign(_this.authConfig, includeGreetings);
11671 } else {
11672 _this.authConfig = {
11673 includeGreetings: includeGreetings,
11674 authenticatorComponents: authenticatorComponents,
11675 federated: federated,
11676 theme: theme,
11677 signUpConfig: signUpConfig
11678 };
11679 }
11680
11681 return _this;
11682 }
11683
11684 class_1.prototype.handleAuthStateChange = function (state, data) {
11685 this.setState({
11686 authState: state,
11687 authData: data
11688 });
11689 };
11690
11691 class_1.prototype.render = function () {
11692 var _a = this.state,
11693 authState = _a.authState,
11694 authData = _a.authData;
11695
11696 if (authState === 'signedIn') {
11697 return React.createElement(React.Fragment, null, this.authConfig.includeGreetings ? React.createElement(Authenticator_1.Authenticator, __assign({}, this.props, {
11698 theme: this.authConfig.theme,
11699 federated: this.authConfig.federated || this.props.federated,
11700 hideDefault: this.authConfig.authenticatorComponents && this.authConfig.authenticatorComponents.length > 0,
11701 signUpConfig: this.authConfig.signUpConfig,
11702 usernameAttributes: this.authConfig.usernameAttributes,
11703 onStateChange: this.handleAuthStateChange,
11704 children: this.authConfig.authenticatorComponents || []
11705 })) : null, React.createElement(Comp, __assign({}, this.props, {
11706 authState: authState,
11707 authData: authData,
11708 onStateChange: this.handleAuthStateChange
11709 })));
11710 }
11711
11712 return React.createElement(Authenticator_1.Authenticator, __assign({}, this.props, {
11713 theme: this.authConfig.theme,
11714 federated: this.authConfig.federated || this.props.federated,
11715 hideDefault: this.authConfig.authenticatorComponents && this.authConfig.authenticatorComponents.length > 0,
11716 signUpConfig: this.authConfig.signUpConfig,
11717 usernameAttributes: this.authConfig.usernameAttributes,
11718 onStateChange: this.handleAuthStateChange,
11719 children: this.authConfig.authenticatorComponents || []
11720 }));
11721 };
11722
11723 return class_1;
11724 }(React.Component)
11725 );
11726}
11727
11728exports.withAuthenticator = withAuthenticator;
11729
11730var AuthenticatorWrapper =
11731/** @class */
11732function (_super) {
11733 __extends(AuthenticatorWrapper, _super);
11734
11735 function AuthenticatorWrapper(props) {
11736 var _this = _super.call(this, props) || this;
11737
11738 _this.state = {
11739 auth: 'init'
11740 };
11741 _this.handleAuthState = _this.handleAuthState.bind(_this);
11742 _this.renderChildren = _this.renderChildren.bind(_this);
11743 return _this;
11744 }
11745
11746 AuthenticatorWrapper.prototype.handleAuthState = function (state, data) {
11747 this.setState({
11748 auth: state,
11749 authData: data
11750 });
11751 };
11752
11753 AuthenticatorWrapper.prototype.renderChildren = function () {
11754 // @ts-ignore
11755 return this.props.children(this.state.auth);
11756 };
11757
11758 AuthenticatorWrapper.prototype.render = function () {
11759 return React.createElement("div", null, React.createElement(Authenticator_1.Authenticator, __assign({}, this.props, {
11760 onStateChange: this.handleAuthState
11761 })), this.renderChildren());
11762 };
11763
11764 return AuthenticatorWrapper;
11765}(React.Component);
11766
11767exports.AuthenticatorWrapper = AuthenticatorWrapper;
11768
11769/***/ }),
11770
11771/***/ "./lib/Interactions/ChatBot.js":
11772/*!*************************************!*\
11773 !*** ./lib/Interactions/ChatBot.js ***!
11774 \*************************************/
11775/*! no static exports found */
11776/***/ (function(module, exports, __webpack_require__) {
11777
11778"use strict";
11779/* WEBPACK VAR INJECTION */(function(global) {
11780
11781var __extends = this && this.__extends || function () {
11782 var _extendStatics = function extendStatics(d, b) {
11783 _extendStatics = Object.setPrototypeOf || {
11784 __proto__: []
11785 } instanceof Array && function (d, b) {
11786 d.__proto__ = b;
11787 } || function (d, b) {
11788 for (var p in b) {
11789 if (b.hasOwnProperty(p)) d[p] = b[p];
11790 }
11791 };
11792
11793 return _extendStatics(d, b);
11794 };
11795
11796 return function (d, b) {
11797 _extendStatics(d, b);
11798
11799 function __() {
11800 this.constructor = d;
11801 }
11802
11803 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11804 };
11805}();
11806
11807var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
11808 function adopt(value) {
11809 return value instanceof P ? value : new P(function (resolve) {
11810 resolve(value);
11811 });
11812 }
11813
11814 return new (P || (P = Promise))(function (resolve, reject) {
11815 function fulfilled(value) {
11816 try {
11817 step(generator.next(value));
11818 } catch (e) {
11819 reject(e);
11820 }
11821 }
11822
11823 function rejected(value) {
11824 try {
11825 step(generator["throw"](value));
11826 } catch (e) {
11827 reject(e);
11828 }
11829 }
11830
11831 function step(result) {
11832 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
11833 }
11834
11835 step((generator = generator.apply(thisArg, _arguments || [])).next());
11836 });
11837};
11838
11839var __generator = this && this.__generator || function (thisArg, body) {
11840 var _ = {
11841 label: 0,
11842 sent: function sent() {
11843 if (t[0] & 1) throw t[1];
11844 return t[1];
11845 },
11846 trys: [],
11847 ops: []
11848 },
11849 f,
11850 y,
11851 t,
11852 g;
11853 return g = {
11854 next: verb(0),
11855 "throw": verb(1),
11856 "return": verb(2)
11857 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
11858 return this;
11859 }), g;
11860
11861 function verb(n) {
11862 return function (v) {
11863 return step([n, v]);
11864 };
11865 }
11866
11867 function step(op) {
11868 if (f) throw new TypeError("Generator is already executing.");
11869
11870 while (_) {
11871 try {
11872 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;
11873 if (y = 0, t) op = [op[0] & 2, t.value];
11874
11875 switch (op[0]) {
11876 case 0:
11877 case 1:
11878 t = op;
11879 break;
11880
11881 case 4:
11882 _.label++;
11883 return {
11884 value: op[1],
11885 done: false
11886 };
11887
11888 case 5:
11889 _.label++;
11890 y = op[1];
11891 op = [0];
11892 continue;
11893
11894 case 7:
11895 op = _.ops.pop();
11896
11897 _.trys.pop();
11898
11899 continue;
11900
11901 default:
11902 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
11903 _ = 0;
11904 continue;
11905 }
11906
11907 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
11908 _.label = op[1];
11909 break;
11910 }
11911
11912 if (op[0] === 6 && _.label < t[1]) {
11913 _.label = t[1];
11914 t = op;
11915 break;
11916 }
11917
11918 if (t && _.label < t[2]) {
11919 _.label = t[2];
11920
11921 _.ops.push(op);
11922
11923 break;
11924 }
11925
11926 if (t[2]) _.ops.pop();
11927
11928 _.trys.pop();
11929
11930 continue;
11931 }
11932
11933 op = body.call(thisArg, _);
11934 } catch (e) {
11935 op = [6, e];
11936 y = 0;
11937 } finally {
11938 f = t = 0;
11939 }
11940 }
11941
11942 if (op[0] & 5) throw op[1];
11943 return {
11944 value: op[0] ? op[1] : void 0,
11945 done: true
11946 };
11947 }
11948};
11949
11950var __read = this && this.__read || function (o, n) {
11951 var m = typeof Symbol === "function" && o[Symbol.iterator];
11952 if (!m) return o;
11953 var i = m.call(o),
11954 r,
11955 ar = [],
11956 e;
11957
11958 try {
11959 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
11960 ar.push(r.value);
11961 }
11962 } catch (error) {
11963 e = {
11964 error: error
11965 };
11966 } finally {
11967 try {
11968 if (r && !r.done && (m = i["return"])) m.call(i);
11969 } finally {
11970 if (e) throw e.error;
11971 }
11972 }
11973
11974 return ar;
11975};
11976
11977var __spread = this && this.__spread || function () {
11978 for (var ar = [], i = 0; i < arguments.length; i++) {
11979 ar = ar.concat(__read(arguments[i]));
11980 }
11981
11982 return ar;
11983};
11984
11985var __importStar = this && this.__importStar || function (mod) {
11986 if (mod && mod.__esModule) return mod;
11987 var result = {};
11988 if (mod != null) for (var k in mod) {
11989 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
11990 }
11991 result["default"] = mod;
11992 return result;
11993};
11994
11995Object.defineProperty(exports, "__esModule", {
11996 value: true
11997});
11998
11999var React = __importStar(__webpack_require__(/*! react */ "react"));
12000
12001var AmplifyUI_1 = __webpack_require__(/*! ../AmplifyUI */ "./lib/AmplifyUI.js");
12002
12003var AmplifyTheme_1 = __webpack_require__(/*! ../AmplifyTheme */ "./lib/AmplifyTheme.js");
12004
12005var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
12006
12007var interactions_1 = __webpack_require__(/*! @aws-amplify/interactions */ "@aws-amplify/interactions");
12008
12009var core_2 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
12010
12011var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
12012
12013var logger = new core_2.ConsoleLogger('ChatBot'); // @ts-ignore
12014
12015var styles = {
12016 itemMe: {
12017 padding: 10,
12018 fontSize: 12,
12019 color: 'gray',
12020 marginTop: 4,
12021 textAlign: 'right'
12022 },
12023 itemBot: {
12024 fontSize: 12,
12025 textAlign: 'left'
12026 },
12027 list: {
12028 height: '300px',
12029 overflow: 'auto'
12030 },
12031 textInput: Object.assign({}, AmplifyTheme_1.Input, {
12032 display: 'inline-block',
12033 width: 'calc(100% - 90px - 15px)'
12034 }),
12035 // @ts-ignore
12036 button: Object.assign({}, AmplifyTheme_1.Button, {
12037 width: '60px',
12038 "float": 'right'
12039 }),
12040 // @ts-ignore
12041 mic: Object.assign({}, AmplifyTheme_1.Button, {
12042 width: '40px',
12043 "float": 'right'
12044 })
12045};
12046var STATES = {
12047 INITIAL: {
12048 MESSAGE: 'Type your message or click 🎤',
12049 ICON: '🎤'
12050 },
12051 LISTENING: {
12052 MESSAGE: 'Listening... click 🔴 again to cancel',
12053 ICON: '🔴'
12054 },
12055 SENDING: {
12056 MESSAGE: 'Please wait...',
12057 ICON: '🔊'
12058 },
12059 SPEAKING: {
12060 MESSAGE: 'Speaking...',
12061 ICON: '...'
12062 }
12063};
12064var defaultVoiceConfig = {
12065 silenceDetectionConfig: {
12066 time: 2000,
12067 amplitude: 0.2
12068 }
12069};
12070var audioControl;
12071
12072var ChatBot =
12073/** @class */
12074function (_super) {
12075 __extends(ChatBot, _super);
12076
12077 function ChatBot(props) {
12078 var _this = _super.call(this, props) || this;
12079
12080 if (_this.props.voiceEnabled) {
12081 __webpack_require__(/*! ./aws-lex-audio */ "./lib/Interactions/aws-lex-audio.js"); // @ts-ignore
12082
12083
12084 audioControl = new global.LexAudio.audioControl();
12085 }
12086
12087 if (!_this.props.textEnabled && _this.props.voiceEnabled) {
12088 STATES.INITIAL.MESSAGE = 'Click the mic button';
12089 styles.textInput = Object.assign({}, AmplifyTheme_1.Input, {
12090 display: 'inline-block',
12091 width: 'calc(100% - 40px - 15px)'
12092 });
12093 }
12094
12095 if (_this.props.textEnabled && !_this.props.voiceEnabled) {
12096 STATES.INITIAL.MESSAGE = 'Type a message';
12097 styles.textInput = Object.assign({}, AmplifyTheme_1.Input, {
12098 display: 'inline-block',
12099 width: 'calc(100% - 60px - 15px)'
12100 });
12101 }
12102
12103 if (!_this.props.voiceConfig.silenceDetectionConfig) {
12104 throw new Error('voiceConfig prop is missing silenceDetectionConfig');
12105 }
12106
12107 _this.state = {
12108 dialog: [{
12109 message: _this.props.welcomeMessage || 'Welcome to Lex',
12110 from: 'system'
12111 }],
12112 inputText: '',
12113 currentVoiceState: STATES.INITIAL,
12114 inputDisabled: false,
12115 micText: STATES.INITIAL.ICON,
12116 continueConversation: false,
12117 micButtonDisabled: false
12118 };
12119 _this.micButtonHandler = _this.micButtonHandler.bind(_this);
12120 _this.changeInputText = _this.changeInputText.bind(_this);
12121 _this.listItems = _this.listItems.bind(_this);
12122 _this.submit = _this.submit.bind(_this); // @ts-ignore
12123
12124 _this.listItemsRef = React.createRef();
12125 _this.onSilenceHandler = _this.onSilenceHandler.bind(_this);
12126 _this.doneSpeakingHandler = _this.doneSpeakingHandler.bind(_this);
12127 _this.lexResponseHandler = _this.lexResponseHandler.bind(_this);
12128 return _this;
12129 }
12130
12131 ChatBot.prototype.micButtonHandler = function () {
12132 return __awaiter(this, void 0, void 0, function () {
12133 var _this = this;
12134
12135 return __generator(this, function (_a) {
12136 if (this.state.continueConversation) {
12137 this.reset();
12138 } else {
12139 this.setState({
12140 inputDisabled: true,
12141 continueConversation: true,
12142 currentVoiceState: STATES.LISTENING,
12143 micText: STATES.LISTENING.ICON,
12144 micButtonDisabled: false
12145 }, function () {
12146 audioControl.startRecording(_this.onSilenceHandler, null, _this.props.voiceConfig.silenceDetectionConfig);
12147 });
12148 }
12149
12150 return [2
12151 /*return*/
12152 ];
12153 });
12154 });
12155 };
12156
12157 ChatBot.prototype.onSilenceHandler = function () {
12158 var _this = this;
12159
12160 audioControl.stopRecording();
12161
12162 if (!this.state.continueConversation) {
12163 return;
12164 }
12165
12166 audioControl.exportWAV(function (blob) {
12167 _this.setState({
12168 currentVoiceState: STATES.SENDING,
12169 audioInput: blob,
12170 micText: STATES.SENDING.ICON,
12171 micButtonDisabled: true
12172 }, function () {
12173 _this.lexResponseHandler();
12174 });
12175 });
12176 };
12177
12178 ChatBot.prototype.lexResponseHandler = function () {
12179 return __awaiter(this, void 0, void 0, function () {
12180 var interactionsMessage, response;
12181
12182 var _this = this;
12183
12184 return __generator(this, function (_a) {
12185 switch (_a.label) {
12186 case 0:
12187 if (!interactions_1.Interactions || typeof interactions_1.Interactions.send !== 'function') {
12188 throw new Error('No Interactions module found, please ensure @aws-amplify/interactions is imported');
12189 }
12190
12191 if (!this.state.continueConversation) {
12192 return [2
12193 /*return*/
12194 ];
12195 }
12196
12197 interactionsMessage = {
12198 content: this.state.audioInput,
12199 options: {
12200 messageType: 'voice'
12201 }
12202 };
12203 return [4
12204 /*yield*/
12205 , interactions_1.Interactions.send(this.props.botName, interactionsMessage)];
12206
12207 case 1:
12208 response = _a.sent();
12209 this.setState({
12210 lexResponse: response,
12211 currentVoiceState: STATES.SPEAKING,
12212 micText: STATES.SPEAKING.ICON,
12213 micButtonDisabled: true,
12214 dialog: __spread(this.state.dialog, [// @ts-ignore
12215 {
12216 message: response.inputTranscript,
12217 from: 'me'
12218 }, // @ts-ignore
12219 response && {
12220 from: 'bot',
12221 message: response.message
12222 }]),
12223 inputText: ''
12224 }, function () {
12225 _this.doneSpeakingHandler();
12226 });
12227 this.listItemsRef.current.scrollTop = this.listItemsRef.current.scrollHeight;
12228 return [2
12229 /*return*/
12230 ];
12231 }
12232 });
12233 });
12234 };
12235
12236 ChatBot.prototype.doneSpeakingHandler = function () {
12237 var _this = this;
12238
12239 if (!this.state.continueConversation) {
12240 return;
12241 }
12242
12243 if (this.state.lexResponse.contentType === 'audio/mpeg') {
12244 audioControl.play(this.state.lexResponse.audioStream, function () {
12245 if (_this.state.lexResponse.dialogState === 'ReadyForFulfillment' || _this.state.lexResponse.dialogState === 'Fulfilled' || _this.state.lexResponse.dialogState === 'Failed' || !_this.props.conversationModeOn) {
12246 _this.setState({
12247 inputDisabled: false,
12248 currentVoiceState: STATES.INITIAL,
12249 micText: STATES.INITIAL.ICON,
12250 micButtonDisabled: false,
12251 continueConversation: false
12252 });
12253 } else {
12254 _this.setState({
12255 currentVoiceState: STATES.LISTENING,
12256 micText: STATES.LISTENING.ICON,
12257 micButtonDisabled: false
12258 }, function () {
12259 audioControl.startRecording(_this.onSilenceHandler, null, _this.props.voiceConfig.silenceDetectionConfig);
12260 });
12261 }
12262 });
12263 } else {
12264 this.setState({
12265 inputDisabled: false,
12266 currentVoiceState: STATES.INITIAL,
12267 micText: STATES.INITIAL.ICON,
12268 micButtonDisabled: false,
12269 continueConversation: false
12270 });
12271 }
12272 };
12273
12274 ChatBot.prototype.reset = function () {
12275 this.setState({
12276 inputText: '',
12277 currentVoiceState: STATES.INITIAL,
12278 inputDisabled: false,
12279 micText: STATES.INITIAL.ICON,
12280 continueConversation: false,
12281 micButtonDisabled: false
12282 }, function () {
12283 audioControl.clear();
12284 });
12285 };
12286
12287 ChatBot.prototype.listItems = function () {
12288 return this.state.dialog.map(function (m, i) {
12289 if (m.from === 'me') {
12290 return React.createElement("div", {
12291 key: i,
12292 style: styles.itemMe,
12293 "data-test": data_test_attributes_1.chatBot.dialog + "-" + i
12294 }, m.message);
12295 } else if (m.from === 'system') {
12296 return React.createElement("div", {
12297 key: i,
12298 style: styles.itemBot,
12299 "data-test": data_test_attributes_1.chatBot.dialog + "-" + i
12300 }, m.message);
12301 } else {
12302 return React.createElement("div", {
12303 key: i,
12304 style: styles.itemBot,
12305 "data-test": data_test_attributes_1.chatBot.dialog + "-" + i
12306 }, m.message);
12307 }
12308 });
12309 };
12310
12311 ChatBot.prototype.submit = function (e) {
12312 return __awaiter(this, void 0, void 0, function () {
12313 var response;
12314
12315 var _this = this;
12316
12317 return __generator(this, function (_a) {
12318 switch (_a.label) {
12319 case 0:
12320 e.preventDefault();
12321
12322 if (!this.state.inputText) {
12323 return [2
12324 /*return*/
12325 ];
12326 }
12327
12328 return [4
12329 /*yield*/
12330 , new Promise(function (resolve) {
12331 return _this.setState({
12332 dialog: __spread(_this.state.dialog, [{
12333 message: _this.state.inputText,
12334 from: 'me'
12335 }])
12336 }, resolve);
12337 })];
12338
12339 case 1:
12340 _a.sent();
12341
12342 if (!interactions_1.Interactions || typeof interactions_1.Interactions.send !== 'function') {
12343 throw new Error('No Interactions module found, please ensure @aws-amplify/interactions is imported');
12344 }
12345
12346 return [4
12347 /*yield*/
12348 , interactions_1.Interactions.send(this.props.botName, this.state.inputText)];
12349
12350 case 2:
12351 response = _a.sent();
12352 this.setState({
12353 // @ts-ignore
12354 dialog: __spread(this.state.dialog, [// @ts-ignore
12355 response && {
12356 from: 'bot',
12357 message: response.message
12358 }]),
12359 inputText: ''
12360 });
12361 this.listItemsRef.current.scrollTop = this.listItemsRef.current.scrollHeight;
12362 return [2
12363 /*return*/
12364 ];
12365 }
12366 });
12367 });
12368 };
12369
12370 ChatBot.prototype.changeInputText = function (event) {
12371 return __awaiter(this, void 0, void 0, function () {
12372 return __generator(this, function (_a) {
12373 switch (_a.label) {
12374 case 0:
12375 return [4
12376 /*yield*/
12377 , this.setState({
12378 inputText: event.target.value
12379 })];
12380
12381 case 1:
12382 _a.sent();
12383
12384 return [2
12385 /*return*/
12386 ];
12387 }
12388 });
12389 });
12390 };
12391
12392 ChatBot.prototype.getOnComplete = function (fn) {
12393 var _this = this;
12394
12395 return function () {
12396 var args = [];
12397
12398 for (var _i = 0; _i < arguments.length; _i++) {
12399 args[_i] = arguments[_i];
12400 }
12401
12402 var clearOnComplete = _this.props.clearOnComplete;
12403 var message = fn.apply(void 0, __spread(args));
12404
12405 _this.setState({
12406 dialog: __spread(clearOnComplete ? [] : _this.state.dialog, [message && {
12407 from: 'bot',
12408 message: message
12409 }]).filter(Boolean)
12410 }, function () {
12411 _this.listItemsRef.current.scrollTop = _this.listItemsRef.current.scrollHeight;
12412 });
12413 };
12414 };
12415
12416 ChatBot.prototype.componentDidMount = function () {
12417 var _a = this.props,
12418 onComplete = _a.onComplete,
12419 botName = _a.botName;
12420
12421 if (onComplete && botName) {
12422 if (!interactions_1.Interactions || typeof interactions_1.Interactions.onComplete !== 'function') {
12423 throw new Error('No Interactions module found, please ensure @aws-amplify/interactions is imported');
12424 } // @ts-ignore
12425
12426
12427 interactions_1.Interactions.onComplete(botName, this.getOnComplete(onComplete, this));
12428 }
12429 };
12430
12431 ChatBot.prototype.componentDidUpdate = function (prevProps) {
12432 var _a = this.props,
12433 onComplete = _a.onComplete,
12434 botName = _a.botName;
12435
12436 if (botName && this.props.onComplete !== prevProps.onComplete) {
12437 if (!interactions_1.Interactions || typeof interactions_1.Interactions.onComplete !== 'function') {
12438 throw new Error('No Interactions module found, please ensure @aws-amplify/interactions is imported');
12439 } // @ts-ignore
12440
12441
12442 interactions_1.Interactions.onComplete(botName, this.getOnComplete(onComplete, this));
12443 }
12444 };
12445
12446 ChatBot.prototype.render = function () {
12447 var _a = this.props,
12448 title = _a.title,
12449 theme = _a.theme,
12450 onComplete = _a.onComplete;
12451 return React.createElement(AmplifyUI_1.FormSection, {
12452 theme: theme
12453 }, title && React.createElement(AmplifyUI_1.SectionHeader, {
12454 theme: theme,
12455 "data-test": data_test_attributes_1.chatBot.title
12456 }, core_1.I18n.get(title)), React.createElement(AmplifyUI_1.SectionBody, {
12457 theme: theme
12458 }, React.createElement("div", {
12459 ref: this.listItemsRef,
12460 style: styles.list
12461 }, this.listItems())), React.createElement(AmplifyUI_1.SectionFooter, {
12462 theme: theme
12463 }, React.createElement(ChatBotInputs, {
12464 micText: this.state.micText,
12465 voiceEnabled: this.props.voiceEnabled,
12466 textEnabled: this.props.textEnabled,
12467 styles: styles,
12468 onChange: this.changeInputText,
12469 inputText: this.state.inputText,
12470 onSubmit: this.submit,
12471 inputDisabled: this.state.inputDisabled,
12472 micButtonDisabled: this.state.micButtonDisabled,
12473 handleMicButton: this.micButtonHandler,
12474 currentVoiceState: this.state.currentVoiceState
12475 })));
12476 };
12477
12478 return ChatBot;
12479}(React.Component);
12480
12481exports.ChatBot = ChatBot;
12482
12483function ChatBotTextInput(props) {
12484 var styles = props.styles;
12485 var onChange = props.onChange;
12486 var inputText = props.inputText;
12487 var inputDisabled = props.inputDisabled;
12488 var currentVoiceState = props.currentVoiceState;
12489 return React.createElement("input", {
12490 style: styles.textInput,
12491 type: "text",
12492 placeholder: core_1.I18n.get(currentVoiceState.MESSAGE),
12493 onChange: onChange,
12494 value: inputText,
12495 disabled: inputDisabled,
12496 "data-test": data_test_attributes_1.chatBot.messageInput
12497 });
12498}
12499
12500function ChatBotMicButton(props) {
12501 var voiceEnabled = props.voiceEnabled;
12502 var styles = props.styles;
12503 var micButtonDisabled = props.micButtonDisabled;
12504 var handleMicButton = props.handleMicButton;
12505 var micText = props.micText;
12506
12507 if (!voiceEnabled) {
12508 return null;
12509 }
12510
12511 return React.createElement("button", {
12512 style: styles.mic,
12513 disabled: micButtonDisabled,
12514 onClick: handleMicButton
12515 }, micText);
12516}
12517
12518function ChatBotTextButton(props) {
12519 var textEnabled = props.textEnabled;
12520 var styles = props.styles;
12521 var inputDisabled = props.inputDisabled;
12522
12523 if (!textEnabled) {
12524 return null;
12525 }
12526
12527 return React.createElement("button", {
12528 type: "submit",
12529 style: styles.button,
12530 disabled: inputDisabled,
12531 "data-test": data_test_attributes_1.chatBot.sendMessageButton
12532 }, core_1.I18n.get('Send'));
12533}
12534
12535function ChatBotInputs(props) {
12536 var voiceEnabled = props.voiceEnabled;
12537 var textEnabled = props.textEnabled;
12538 var styles = props.styles;
12539 var onChange = props.onChange;
12540 var inputDisabled = props.inputDisabled;
12541 var micButtonDisabled = props.micButtonDisabled;
12542 var inputText = props.inputText;
12543 var onSubmit = props.onSubmit;
12544 var handleMicButton = props.handleMicButton;
12545 var micText = props.micText;
12546 var currentVoiceState = props.currentVoiceState;
12547
12548 if (voiceEnabled && !textEnabled) {
12549 inputDisabled = true;
12550 }
12551
12552 if (!voiceEnabled && !textEnabled) {
12553 return React.createElement("div", null, "No Chatbot inputs enabled. Set at least one of voiceEnabled or textEnabled in the props.", ' ');
12554 }
12555
12556 return React.createElement("form", {
12557 onSubmit: onSubmit
12558 }, React.createElement(ChatBotTextInput, {
12559 onSubmit: onSubmit,
12560 styles: styles,
12561 type: "text",
12562 currentVoiceState: currentVoiceState,
12563 onChange: onChange,
12564 inputText: inputText,
12565 inputDisabled: inputDisabled
12566 }), React.createElement(ChatBotTextButton, {
12567 onSubmit: onSubmit,
12568 type: "submit",
12569 styles: styles,
12570 inputDisabled: inputDisabled,
12571 textEnabled: textEnabled
12572 }), React.createElement(ChatBotMicButton, {
12573 styles: styles,
12574 micButtonDisabled: micButtonDisabled,
12575 handleMicButton: handleMicButton,
12576 micText: micText,
12577 voiceEnabled: voiceEnabled
12578 }));
12579} // @ts-ignore
12580
12581
12582ChatBot.defaultProps = {
12583 title: '',
12584 botName: '',
12585 onComplete: undefined,
12586 clearOnComplete: false,
12587 voiceConfig: defaultVoiceConfig,
12588 conversationModeOn: false,
12589 voiceEnabled: false,
12590 textEnabled: true
12591};
12592/**
12593 * @deprecated use named import
12594 */
12595
12596exports["default"] = ChatBot;
12597/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
12598
12599/***/ }),
12600
12601/***/ "./lib/Interactions/aws-lex-audio.js":
12602/*!*******************************************!*\
12603 !*** ./lib/Interactions/aws-lex-audio.js ***!
12604 \*******************************************/
12605/*! no static exports found */
12606/***/ (function(module, exports, __webpack_require__) {
12607
12608/* WEBPACK VAR INJECTION */(function(global) {var require;var require;// Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
12609// Permission is hereby granted, free of charge, to any person obtaining a copy of this
12610// software and associated documentation files (the "Software"), to deal in the Software
12611// without restriction, including without limitation the rights to use, copy, modify,
12612// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12613// permit persons to whom the Software is furnished to do so.
12614// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12615// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
12616// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
12617// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
12618// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
12619// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12620// @ts-ignore
12621(function e(t, n, r) {
12622 function s(o, u) {
12623 if (!n[o]) {
12624 if (!t[o]) {
12625 var a = typeof require == 'function' && require; // @ts-ignore
12626
12627 if (!u && a) return require(o, !0); // @ts-ignore
12628
12629 if (i) return i(o, !0);
12630 var f = new Error("Cannot find module '" + o + "'"); // @ts-ignore
12631
12632 throw f.code = 'MODULE_NOT_FOUND', f;
12633 }
12634
12635 var l = n[o] = {
12636 exports: {}
12637 };
12638 t[o][0].call(l.exports, function (e) {
12639 var n = t[o][1][e]; // @ts-ignore
12640
12641 return s(n ? n : e);
12642 }, l, l.exports, e, t, n, r);
12643 }
12644
12645 return n[o].exports;
12646 }
12647
12648 var i = typeof require == 'function' && require; // @ts-ignore
12649
12650 for (var o = 0; o < r.length; o++) {
12651 s(r[o]);
12652 }
12653
12654 return s;
12655})({
12656 1: [function (require, module, exports) {
12657 (function () {
12658 'use strict';
12659
12660 var rec = require('./recorder.js');
12661
12662 var recorder,
12663 audioRecorder,
12664 checkAudioSupport,
12665 audioSupported,
12666 playbackSource,
12667 UNSUPPORTED = 'Audio is not supported.';
12668 /**
12669 * Represents an audio control that can start and stop recording,
12670 * export captured audio, play an audio buffer, and check if audio
12671 * is supported.
12672 */
12673
12674 exports.audioControl = function (options) {
12675 options = options || {};
12676 this.checkAudioSupport = options.checkAudioSupport !== false;
12677 /**
12678 * This callback type is called `onSilenceCallback`.
12679 *
12680 * @callback onSilenceCallback
12681 */
12682
12683 /**
12684 * Visualize callback: `visualizerCallback`.
12685 *
12686 * @callback visualizerCallback
12687 * @param {Uint8Array} dataArray
12688 * @param {number} bufferLength
12689 */
12690
12691 /**
12692 * Clears the previous buffer and starts buffering audio.
12693 *
12694 * @param {?onSilenceCallback} onSilence - Called when silence is detected.
12695 * @param {?visualizerCallback} visualizer - Can be used to visualize the captured buffer.
12696 * @param {silenceDetectionConfig} - Specify custom silence detection values.
12697 * @throws {Error} If audio is not supported.
12698 */
12699
12700 var startRecording = function startRecording(onSilence, visualizer, silenceDetectionConfig) {
12701 onSilence = onSilence || function () {
12702 /* no op */
12703 };
12704
12705 visualizer = visualizer || function () {
12706 /* no op */
12707 };
12708
12709 audioSupported = audioSupported !== false;
12710
12711 if (!audioSupported) {
12712 throw new Error(UNSUPPORTED);
12713 }
12714
12715 var context = audioRecorder.audioContext();
12716 context.resume().then(function () {
12717 recorder = audioRecorder.createRecorder(silenceDetectionConfig);
12718 recorder.record(onSilence, visualizer);
12719 });
12720 };
12721 /**
12722 * Stops buffering audio.
12723 *
12724 * @throws {Error} If audio is not supported.
12725 */
12726
12727
12728 var stopRecording = function stopRecording() {
12729 audioSupported = audioSupported !== false;
12730
12731 if (!audioSupported) {
12732 throw new Error(UNSUPPORTED);
12733 }
12734
12735 recorder.stop();
12736 };
12737 /**
12738 * On export complete callback: `onExportComplete`.
12739 *
12740 * @callback onExportComplete
12741 * @param {Blob} blob The exported audio as a Blob.
12742 */
12743
12744 /**
12745 * Exports the captured audio buffer.
12746 *
12747 * @param {onExportComplete} callback - Called when the export is complete.
12748 * @param {sampleRate} The sample rate to use in the export.
12749 * @throws {Error} If audio is not supported.
12750 */
12751
12752
12753 var exportWAV = function exportWAV(callback, sampleRate) {
12754 audioSupported = audioSupported !== false;
12755
12756 if (!audioSupported) {
12757 throw new Error(UNSUPPORTED);
12758 }
12759
12760 if (!(callback && typeof callback === 'function')) {
12761 throw new Error('You must pass a callback function to export.');
12762 }
12763
12764 sampleRate = typeof sampleRate !== 'undefined' ? sampleRate : 16000;
12765 recorder.exportWAV(callback, sampleRate);
12766 recorder.clear();
12767 };
12768 /**
12769 * On playback complete callback: `onPlaybackComplete`.
12770 *
12771 * @callback onPlaybackComplete
12772 */
12773
12774 /**
12775 * Plays the audio buffer with an HTML5 audio tag.
12776 * @param {Uint8Array} buffer - The audio buffer to play.
12777 * @param {?onPlaybackComplete} callback - Called when audio playback is complete.
12778 */
12779
12780
12781 var playHtmlAudioElement = function playHtmlAudioElement(buffer, callback) {
12782 if (typeof buffer === 'undefined') {
12783 return;
12784 }
12785
12786 var myBlob = new Blob([buffer]);
12787 var audio = document.createElement('audio');
12788 var objectUrl = window.URL.createObjectURL(myBlob);
12789 audio.src = objectUrl;
12790 audio.addEventListener('ended', function () {
12791 audio.currentTime = 0;
12792
12793 if (typeof callback === 'function') {
12794 callback();
12795 }
12796 });
12797 audio.play();
12798 };
12799 /**
12800 * On playback complete callback: `onPlaybackComplete`.
12801 *
12802 * @callback onPlaybackComplete
12803 */
12804
12805 /**
12806 * Plays the audio buffer with a WebAudio AudioBufferSourceNode.
12807 * @param {Uint8Array} buffer - The audio buffer to play.
12808 * @param {?onPlaybackComplete} callback - Called when audio playback is complete.
12809 */
12810
12811
12812 var play = function play(buffer, callback) {
12813 if (typeof buffer === 'undefined') {
12814 return;
12815 }
12816
12817 var myBlob = new Blob([buffer]); // We'll use a FileReader to create and ArrayBuffer out of the audio response.
12818
12819 var fileReader = new FileReader();
12820
12821 fileReader.onload = function () {
12822 // Once we have an ArrayBuffer we can create our BufferSource and decode the result as an AudioBuffer.
12823 playbackSource = audioRecorder.audioContext().createBufferSource();
12824 audioRecorder.audioContext().decodeAudioData(this.result, function (buf) {
12825 // Set the source buffer as our new AudioBuffer.
12826 playbackSource.buffer = buf; // Set the destination (the actual audio-rendering device--your device's speakers).
12827
12828 playbackSource.connect(audioRecorder.audioContext().destination); // Add an "on ended" callback.
12829
12830 playbackSource.onended = function (event) {
12831 if (typeof callback === 'function') {
12832 callback();
12833 }
12834 }; // Start the playback.
12835
12836
12837 playbackSource.start(0);
12838 });
12839 };
12840
12841 fileReader.readAsArrayBuffer(myBlob);
12842 };
12843 /**
12844 * Stops the playback source (created by the play method) if it exists. The `onPlaybackComplete`
12845 * callback will be called.
12846 */
12847
12848
12849 var stop = function stop() {
12850 if (typeof playbackSource === 'undefined') {
12851 return;
12852 }
12853
12854 playbackSource.stop();
12855 };
12856 /**
12857 * Clear the recording buffer.
12858 */
12859
12860
12861 var clear = function clear() {
12862 recorder.clear();
12863 };
12864 /**
12865 * On audio supported callback: `onAudioSupported`.
12866 *
12867 * @callback onAudioSupported
12868 * @param {boolean}
12869 */
12870
12871 /**
12872 * Checks that getUserMedia is supported and the user has given us access to the mic.
12873 * @param {onAudioSupported} callback - Called with the result.
12874 */
12875
12876
12877 var supportsAudio = function supportsAudio(callback) {
12878 callback = callback || function () {
12879 /* no op */
12880 };
12881
12882 if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
12883 audioRecorder = rec.audioRecorder();
12884 audioRecorder.requestDevice().then(function (stream) {
12885 audioSupported = true;
12886 callback(audioSupported);
12887 })["catch"](function (error) {
12888 audioSupported = false;
12889 callback(audioSupported);
12890 });
12891 } else {
12892 audioSupported = false;
12893 callback(audioSupported);
12894 }
12895 };
12896
12897 if (this.checkAudioSupport) {
12898 // @ts-ignore
12899 supportsAudio();
12900 }
12901
12902 return {
12903 startRecording: startRecording,
12904 stopRecording: stopRecording,
12905 exportWAV: exportWAV,
12906 play: play,
12907 stop: stop,
12908 clear: clear,
12909 playHtmlAudioElement: playHtmlAudioElement,
12910 supportsAudio: supportsAudio
12911 };
12912 };
12913 })();
12914 }, {
12915 './recorder.js': 5
12916 }],
12917 2: [function (require, module, exports) {
12918 (function () {
12919 'use strict';
12920
12921 var AudioControl = require('./control.js').audioControl;
12922
12923 var DEFAULT_LATEST = '$LATEST';
12924 var DEFAULT_CONTENT_TYPE = 'audio/x-l16; sample-rate=16000';
12925 var DEFAULT_USER_ID = 'userId';
12926 var DEFAULT_ACCEPT_HEADER_VALUE = 'audio/mpeg';
12927 var MESSAGES = Object.freeze({
12928 PASSIVE: 'Passive',
12929 LISTENING: 'Listening',
12930 SENDING: 'Sending',
12931 SPEAKING: 'Speaking'
12932 });
12933 var lexruntime,
12934 audioControl = new AudioControl({
12935 checkAudioSupport: false
12936 });
12937
12938 exports.conversation = function (config, onStateChange, onSuccess, onError, onAudioData) {
12939 var currentState; // Apply default values.
12940
12941 this.config = applyDefaults(config);
12942 this.lexConfig = this.config.lexConfig;
12943 this.messages = MESSAGES;
12944
12945 onStateChange = onStateChange || function () {
12946 /* no op */
12947 };
12948
12949 this.onSuccess = onSuccess || function () {
12950 /* no op */
12951 };
12952
12953 this.onError = onError || function () {
12954 /* no op */
12955 };
12956
12957 this.onAudioData = onAudioData || function () {
12958 /* no op */
12959 }; // Validate input.
12960
12961
12962 if (!this.config.lexConfig.botName) {
12963 this.onError('A Bot name must be provided.');
12964 return;
12965 } // @ts-ignore
12966
12967
12968 if (!AWS.config.credentials) {
12969 this.onError('AWS Credentials must be provided.');
12970 return;
12971 } // @ts-ignore
12972
12973
12974 if (!AWS.config.region) {
12975 this.onError('A Region value must be provided.');
12976 return;
12977 } // @ts-ignore
12978
12979
12980 lexruntime = new AWS.LexRuntime();
12981
12982 this.onSilence = function () {
12983 if (config.silenceDetection) {
12984 audioControl.stopRecording();
12985 currentState.advanceConversation();
12986 }
12987 };
12988
12989 this.transition = function (conversation) {
12990 currentState = conversation;
12991 var state = currentState.state;
12992 onStateChange(state.message); // If we are transitioning into SENDING or SPEAKING we want to immediately advance the conversation state
12993 // to start the service call or playback.
12994
12995 if (state.message === state.messages.SENDING || state.message === state.messages.SPEAKING) {
12996 currentState.advanceConversation();
12997 } // If we are transitioning in to sending and we are not detecting silence (this was a manual state change)
12998 // we need to do some cleanup: stop recording, and stop rendering.
12999
13000
13001 if (state.message === state.messages.SENDING && !this.config.silenceDetection) {
13002 audioControl.stopRecording();
13003 }
13004 };
13005
13006 this.advanceConversation = function () {
13007 audioControl.supportsAudio(function (supported) {
13008 if (supported) {
13009 currentState.advanceConversation();
13010 } else {
13011 onError('Audio is not supported.');
13012 }
13013 });
13014 };
13015
13016 this.updateConfig = function (newValue) {
13017 this.config = applyDefaults(newValue);
13018 this.lexConfig = this.config.lexConfig;
13019 };
13020
13021 this.reset = function () {
13022 audioControl.clear();
13023 currentState = new Initial(currentState.state);
13024 };
13025
13026 currentState = new Initial(this);
13027 return {
13028 advanceConversation: this.advanceConversation,
13029 updateConfig: this.updateConfig,
13030 reset: this.reset
13031 };
13032 };
13033
13034 var Initial = function Initial(state) {
13035 this.state = state;
13036 state.message = state.messages.PASSIVE;
13037
13038 this.advanceConversation = function () {
13039 audioControl.startRecording(state.onSilence, state.onAudioData, state.config.silenceDetectionConfig);
13040 state.transition(new Listening(state));
13041 };
13042 };
13043
13044 var Listening = function Listening(state) {
13045 this.state = state;
13046 state.message = state.messages.LISTENING;
13047
13048 this.advanceConversation = function () {
13049 audioControl.exportWAV(function (blob) {
13050 state.audioInput = blob;
13051 state.transition(new Sending(state));
13052 });
13053 };
13054 };
13055
13056 var Sending = function Sending(state) {
13057 this.state = state;
13058 state.message = state.messages.SENDING;
13059
13060 this.advanceConversation = function () {
13061 state.lexConfig.inputStream = state.audioInput;
13062 lexruntime.postContent(state.lexConfig, function (err, data) {
13063 if (err) {
13064 state.onError(err);
13065 state.transition(new Initial(state));
13066 } else {
13067 state.audioOutput = data;
13068 state.transition(new Speaking(state));
13069 state.onSuccess(data);
13070 }
13071 });
13072 };
13073 };
13074
13075 var Speaking = function Speaking(state) {
13076 this.state = state;
13077 state.message = state.messages.SPEAKING;
13078
13079 this.advanceConversation = function () {
13080 if (state.audioOutput.contentType === 'audio/mpeg') {
13081 audioControl.play(state.audioOutput.audioStream, function () {
13082 if (state.audioOutput.dialogState === 'ReadyForFulfillment' || state.audioOutput.dialogState === 'Fulfilled' || state.audioOutput.dialogState === 'Failed' || !state.config.silenceDetection) {
13083 state.transition(new Initial(state));
13084 } else {
13085 audioControl.startRecording(state.onSilence, state.onAudioData, state.config.silenceDetectionConfig);
13086 state.transition(new Listening(state));
13087 }
13088 });
13089 } else {
13090 state.transition(new Initial(state));
13091 }
13092 };
13093 };
13094
13095 var applyDefaults = function applyDefaults(config) {
13096 config = config || {};
13097 config.silenceDetection = config.hasOwnProperty('silenceDetection') ? config.silenceDetection : true;
13098 var lexConfig = config.lexConfig || {};
13099 lexConfig.botAlias = lexConfig.hasOwnProperty('botAlias') ? lexConfig.botAlias : DEFAULT_LATEST;
13100 lexConfig.botName = lexConfig.hasOwnProperty('botName') ? lexConfig.botName : '';
13101 lexConfig.contentType = lexConfig.hasOwnProperty('contentType') ? lexConfig.contentType : DEFAULT_CONTENT_TYPE;
13102 lexConfig.userId = lexConfig.hasOwnProperty('userId') ? lexConfig.userId : DEFAULT_USER_ID;
13103 lexConfig.accept = lexConfig.hasOwnProperty('accept') ? lexConfig.accept : DEFAULT_ACCEPT_HEADER_VALUE;
13104 config.lexConfig = lexConfig;
13105 return config;
13106 };
13107 })();
13108 }, {
13109 './control.js': 1
13110 }],
13111 3: [function (require, module, exports) {
13112 (function (global) {
13113 /**
13114 * @module LexAudio
13115 * @description The global namespace for Amazon Lex Audio
13116 */
13117 global.LexAudio = global.LexAudio || {};
13118 global.LexAudio.audioControl = require('./control.js').audioControl;
13119 global.LexAudio.conversation = require('./conversation.js').conversation;
13120 module.exports = global.LexAudio;
13121 }).call(this, typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : {});
13122 }, {
13123 './control.js': 1,
13124 './conversation.js': 2
13125 }],
13126 4: [function (require, module, exports) {
13127 var bundleFn = arguments[3];
13128 var sources = arguments[4];
13129 var cache = arguments[5];
13130 var stringify = JSON.stringify;
13131
13132 module.exports = function (fn, options) {
13133 var wkey;
13134 var cacheKeys = Object.keys(cache);
13135
13136 for (var i = 0, l = cacheKeys.length; i < l; i++) {
13137 var key = cacheKeys[i];
13138 var exp = cache[key].exports; // Using babel as a transpiler to use esmodule, the export will always
13139 // be an object with the default export as a property of it. To ensure
13140 // the existing api and babel esmodule exports are both supported we
13141 // check for both
13142
13143 if (exp === fn || exp && exp["default"] === fn) {
13144 wkey = key;
13145 break;
13146 }
13147 }
13148
13149 if (!wkey) {
13150 wkey = Math.floor(Math.pow(16, 8) * Math.random()).toString(16);
13151 var wcache = {};
13152
13153 for (var i = 0, l = cacheKeys.length; i < l; i++) {
13154 var key = cacheKeys[i];
13155 wcache[key] = key;
13156 }
13157
13158 sources[wkey] = [// @ts-ignore
13159 Function(['require', 'module', 'exports'], '(' + fn + ')(self)'), wcache];
13160 }
13161
13162 var skey = Math.floor(Math.pow(16, 8) * Math.random()).toString(16);
13163 var scache = {};
13164 scache[wkey] = wkey;
13165 sources[skey] = [// @ts-ignore
13166 Function( // @ts-ignore
13167 ['require'], // try to call default if defined to also support babel esmodule
13168 // exports
13169 'var f = require(' + stringify(wkey) + ');' + '(f.default ? f.default : f)(self);'), scache];
13170 var workerSources = {};
13171 resolveSources(skey);
13172
13173 function resolveSources(key) {
13174 workerSources[key] = true;
13175
13176 for (var depPath in sources[key][1]) {
13177 var depKey = sources[key][1][depPath];
13178
13179 if (!workerSources[depKey]) {
13180 resolveSources(depKey);
13181 }
13182 }
13183 }
13184
13185 var src = '(' + bundleFn + ')({' + Object.keys(workerSources).map(function (key) {
13186 return stringify(key) + ':[' + sources[key][0] + ',' + stringify(sources[key][1]) + ']';
13187 }).join(',') + '},{},[' + stringify(skey) + '])'; // @ts-ignore
13188
13189 var URL = // @ts-ignore
13190 window.URL || window.webkitURL || window.mozURL || window.msURL;
13191 var blob = new Blob([src], {
13192 type: 'text/javascript'
13193 });
13194
13195 if (options && options.bare) {
13196 return blob;
13197 }
13198
13199 var workerUrl = URL.createObjectURL(blob);
13200 var worker = new Worker(workerUrl); // @ts-ignore
13201
13202 worker.objectURL = workerUrl;
13203 return worker;
13204 };
13205 }, {}],
13206 5: [function (require, module, exports) {
13207 (function () {
13208 'use strict';
13209
13210 var work = require('webworkify');
13211
13212 var worker = work(require('./worker.js'));
13213 var audio_context, audio_stream;
13214 /**
13215 * The Recorder object. Sets up the onaudioprocess callback and communicates
13216 * with the web worker to perform audio actions.
13217 */
13218
13219 var recorder = function recorder(source, silenceDetectionConfig) {
13220 silenceDetectionConfig = silenceDetectionConfig || {};
13221 silenceDetectionConfig.time = silenceDetectionConfig.hasOwnProperty('time') ? silenceDetectionConfig.time : 1500;
13222 silenceDetectionConfig.amplitude = silenceDetectionConfig.hasOwnProperty('amplitude') ? silenceDetectionConfig.amplitude : 0.2;
13223 var recording = false,
13224 currCallback,
13225 start,
13226 silenceCallback,
13227 visualizationCallback; // Create a ScriptProcessorNode with a bufferSize of 4096 and a single input and output channel
13228
13229 var node = source.context.createScriptProcessor(4096, 1, 1);
13230
13231 worker.onmessage = function (message) {
13232 var blob = message.data;
13233 currCallback(blob);
13234 };
13235
13236 worker.postMessage({
13237 command: 'init',
13238 config: {
13239 sampleRate: source.context.sampleRate
13240 }
13241 });
13242 /**
13243 * Sets the silence and viz callbacks, resets the silence start time, and sets recording to true.
13244 * @param {?onSilenceCallback} onSilence - Called when silence is detected.
13245 * @param {?visualizerCallback} visualizer - Can be used to visualize the captured buffer.
13246 */
13247
13248 var record = function record(onSilence, visualizer) {
13249 silenceCallback = onSilence;
13250 visualizationCallback = visualizer;
13251 start = Date.now();
13252 recording = true;
13253 };
13254 /**
13255 * Sets recording to false.
13256 */
13257
13258
13259 var stop = function stop() {
13260 recording = false;
13261 };
13262 /**
13263 * Posts "clear" message to the worker.
13264 */
13265
13266
13267 var clear = function clear() {
13268 stop();
13269 worker.postMessage({
13270 command: 'clear'
13271 });
13272 };
13273 /**
13274 * Sets the export callback and posts an "export" message to the worker.
13275 * @param {onExportComplete} callback - Called when the export is complete.
13276 * @param {sampleRate} The sample rate to use in the export.
13277 */
13278
13279
13280 var exportWAV = function exportWAV(callback, sampleRate) {
13281 currCallback = callback;
13282 worker.postMessage({
13283 command: 'export',
13284 sampleRate: sampleRate
13285 });
13286 };
13287 /**
13288 * Checks the time domain data to see if the amplitude of the audio waveform is more than
13289 * the silence threshold. If it is, "noise" has been detected and it resets the start time.
13290 * If the elapsed time reaches the time threshold the silence callback is called. If there is a
13291 * visualizationCallback it invokes the visualization callback with the time domain data.
13292 */
13293
13294
13295 var analyse = function analyse() {
13296 analyser.fftSize = 2048;
13297 var bufferLength = analyser.fftSize;
13298 var dataArray = new Uint8Array(bufferLength);
13299 var amplitude = silenceDetectionConfig.amplitude;
13300 var time = silenceDetectionConfig.time;
13301 analyser.getByteTimeDomainData(dataArray);
13302
13303 if (typeof visualizationCallback === 'function') {
13304 visualizationCallback(dataArray, bufferLength);
13305 }
13306
13307 for (var i = 0; i < bufferLength; i++) {
13308 // Normalize between -1 and 1.
13309 var curr_value_time = dataArray[i] / 128 - 1.0;
13310
13311 if (curr_value_time > amplitude || curr_value_time < -1 * amplitude) {
13312 start = Date.now();
13313 }
13314 }
13315
13316 var newtime = Date.now();
13317 var elapsedTime = newtime - start;
13318
13319 if (elapsedTime > time) {
13320 silenceCallback();
13321 }
13322 };
13323 /**
13324 * The onaudioprocess event handler of the ScriptProcessorNode interface. It is the EventHandler to be
13325 * called for the audioprocess event that is dispatched to ScriptProcessorNode node types.
13326 * @param {AudioProcessingEvent} audioProcessingEvent - The audio processing event.
13327 */
13328
13329
13330 node.onaudioprocess = function (audioProcessingEvent) {
13331 if (!recording) {
13332 return;
13333 }
13334
13335 worker.postMessage({
13336 command: 'record',
13337 buffer: [audioProcessingEvent.inputBuffer.getChannelData(0)]
13338 });
13339 analyse();
13340 };
13341
13342 var analyser = source.context.createAnalyser();
13343 analyser.minDecibels = -90;
13344 analyser.maxDecibels = -10;
13345 analyser.smoothingTimeConstant = 0.85;
13346 source.connect(analyser);
13347 analyser.connect(node);
13348 node.connect(source.context.destination);
13349 return {
13350 record: record,
13351 stop: stop,
13352 clear: clear,
13353 exportWAV: exportWAV
13354 };
13355 };
13356 /**
13357 * Audio recorder object. Handles setting up the audio context,
13358 * accessing the mike, and creating the Recorder object.
13359 */
13360
13361
13362 exports.audioRecorder = function () {
13363 /**
13364 * Creates an audio context and calls getUserMedia to request the mic (audio).
13365 */
13366 var requestDevice = function requestDevice() {
13367 if (typeof audio_context === 'undefined') {
13368 // @ts-ignore
13369 window.AudioContext = // @ts-ignore
13370 window.AudioContext || window.webkitAudioContext;
13371 audio_context = new AudioContext();
13372 }
13373
13374 return navigator.mediaDevices.getUserMedia({
13375 audio: true
13376 }).then(function (stream) {
13377 audio_stream = stream;
13378 });
13379 };
13380
13381 var createRecorder = function createRecorder(silenceDetectionConfig) {
13382 return recorder(audio_context.createMediaStreamSource(audio_stream), silenceDetectionConfig);
13383 };
13384
13385 var audioContext = function audioContext() {
13386 return audio_context;
13387 };
13388
13389 return {
13390 requestDevice: requestDevice,
13391 createRecorder: createRecorder,
13392 audioContext: audioContext
13393 };
13394 };
13395 })();
13396 }, {
13397 './worker.js': 6,
13398 webworkify: 4
13399 }],
13400 6: [function (require, module, exports) {
13401 module.exports = function (self) {
13402 'use strict';
13403
13404 var recLength = 0,
13405 recBuffer = [],
13406 recordSampleRate;
13407 self.addEventListener('message', function (e) {
13408 switch (e.data.command) {
13409 case 'init':
13410 init(e.data.config);
13411 break;
13412
13413 case 'record':
13414 record(e.data.buffer);
13415 break;
13416
13417 case 'export':
13418 exportBuffer(e.data.sampleRate);
13419 break;
13420
13421 case 'clear':
13422 clear();
13423 break;
13424 }
13425 });
13426
13427 function init(config) {
13428 recordSampleRate = config.sampleRate;
13429 }
13430
13431 function record(inputBuffer) {
13432 recBuffer.push(inputBuffer[0]);
13433 recLength += inputBuffer[0].length;
13434 }
13435
13436 function exportBuffer(exportSampleRate) {
13437 var mergedBuffers = mergeBuffers(recBuffer, recLength);
13438 var downsampledBuffer = downsampleBuffer(mergedBuffers, exportSampleRate);
13439 var encodedWav = encodeWAV(downsampledBuffer);
13440 var audioBlob = new Blob([encodedWav], {
13441 type: 'application/octet-stream'
13442 }); // @ts-ignore
13443
13444 postMessage(audioBlob);
13445 }
13446
13447 function clear() {
13448 recLength = 0;
13449 recBuffer = [];
13450 }
13451
13452 function downsampleBuffer(buffer, exportSampleRate) {
13453 if (exportSampleRate === recordSampleRate) {
13454 return buffer;
13455 }
13456
13457 var sampleRateRatio = recordSampleRate / exportSampleRate;
13458 var newLength = Math.round(buffer.length / sampleRateRatio);
13459 var result = new Float32Array(newLength);
13460 var offsetResult = 0;
13461 var offsetBuffer = 0;
13462
13463 while (offsetResult < result.length) {
13464 var nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);
13465 var accum = 0,
13466 count = 0;
13467
13468 for (var i = offsetBuffer; i < nextOffsetBuffer && i < buffer.length; i++) {
13469 accum += buffer[i];
13470 count++;
13471 }
13472
13473 result[offsetResult] = accum / count;
13474 offsetResult++;
13475 offsetBuffer = nextOffsetBuffer;
13476 }
13477
13478 return result;
13479 }
13480
13481 function mergeBuffers(bufferArray, recLength) {
13482 var result = new Float32Array(recLength);
13483 var offset = 0;
13484
13485 for (var i = 0; i < bufferArray.length; i++) {
13486 result.set(bufferArray[i], offset);
13487 offset += bufferArray[i].length;
13488 }
13489
13490 return result;
13491 }
13492
13493 function floatTo16BitPCM(output, offset, input) {
13494 for (var i = 0; i < input.length; i++, offset += 2) {
13495 var s = Math.max(-1, Math.min(1, input[i]));
13496 output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
13497 }
13498 }
13499
13500 function writeString(view, offset, string) {
13501 for (var i = 0; i < string.length; i++) {
13502 view.setUint8(offset + i, string.charCodeAt(i));
13503 }
13504 }
13505
13506 function encodeWAV(samples) {
13507 var buffer = new ArrayBuffer(44 + samples.length * 2);
13508 var view = new DataView(buffer);
13509 writeString(view, 0, 'RIFF');
13510 view.setUint32(4, 32 + samples.length * 2, true);
13511 writeString(view, 8, 'WAVE');
13512 writeString(view, 12, 'fmt ');
13513 view.setUint32(16, 16, true);
13514 view.setUint16(20, 1, true);
13515 view.setUint16(22, 1, true);
13516 view.setUint32(24, recordSampleRate, true);
13517 view.setUint32(28, recordSampleRate * 2, true);
13518 view.setUint16(32, 2, true);
13519 view.setUint16(34, 16, true);
13520 writeString(view, 36, 'data');
13521 view.setUint32(40, samples.length * 2, true);
13522 floatTo16BitPCM(view, 44, samples);
13523 return view;
13524 }
13525 };
13526 }, {}]
13527}, {}, [3]);
13528/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
13529
13530/***/ }),
13531
13532/***/ "./lib/Interactions/index.js":
13533/*!***********************************!*\
13534 !*** ./lib/Interactions/index.js ***!
13535 \***********************************/
13536/*! no static exports found */
13537/***/ (function(module, exports, __webpack_require__) {
13538
13539"use strict";
13540
13541
13542function __export(m) {
13543 for (var p in m) {
13544 if (!exports.hasOwnProperty(p)) exports[p] = m[p];
13545 }
13546}
13547
13548Object.defineProperty(exports, "__esModule", {
13549 value: true
13550});
13551
13552__export(__webpack_require__(/*! ./ChatBot */ "./lib/Interactions/ChatBot.js"));
13553
13554/***/ }),
13555
13556/***/ "./lib/Storage/Common.js":
13557/*!*******************************!*\
13558 !*** ./lib/Storage/Common.js ***!
13559 \*******************************/
13560/*! no static exports found */
13561/***/ (function(module, exports, __webpack_require__) {
13562
13563"use strict";
13564
13565/*
13566 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
13567 *
13568 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
13569 * the License. A copy of the License is located at
13570 *
13571 * http://aws.amazon.com/apache2.0/
13572 *
13573 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13574 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
13575 * and limitations under the License.
13576 */
13577
13578function _typeof(obj) {
13579 "@babel/helpers - typeof";
13580
13581 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
13582 _typeof = function _typeof(obj) {
13583 return typeof obj;
13584 };
13585 } else {
13586 _typeof = function _typeof(obj) {
13587 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
13588 };
13589 }
13590
13591 return _typeof(obj);
13592}
13593
13594Object.defineProperty(exports, "__esModule", {
13595 value: true
13596});
13597
13598function calcKey(file, fileToKey) {
13599 var name = file.name,
13600 size = file.size,
13601 type = file.type;
13602 var key = encodeURI(name);
13603
13604 if (fileToKey) {
13605 var callback_type = _typeof(fileToKey);
13606
13607 if (callback_type === 'string') {
13608 key = fileToKey;
13609 } else if (callback_type === 'function') {
13610 key = fileToKey({
13611 name: name,
13612 size: size,
13613 type: type
13614 });
13615 } else {
13616 key = encodeURI(JSON.stringify(fileToKey));
13617 }
13618
13619 if (!key) {
13620 key = 'empty_key';
13621 }
13622 }
13623
13624 return key.replace(/\s/g, '_');
13625}
13626
13627exports.calcKey = calcKey;
13628
13629/***/ }),
13630
13631/***/ "./lib/Storage/S3Album.js":
13632/*!********************************!*\
13633 !*** ./lib/Storage/S3Album.js ***!
13634 \********************************/
13635/*! no static exports found */
13636/***/ (function(module, exports, __webpack_require__) {
13637
13638"use strict";
13639
13640/*
13641 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
13642 *
13643 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
13644 * the License. A copy of the License is located at
13645 *
13646 * http://aws.amazon.com/apache2.0/
13647 *
13648 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13649 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
13650 * and limitations under the License.
13651 */
13652
13653function _typeof(obj) {
13654 "@babel/helpers - typeof";
13655
13656 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
13657 _typeof = function _typeof(obj) {
13658 return typeof obj;
13659 };
13660 } else {
13661 _typeof = function _typeof(obj) {
13662 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
13663 };
13664 }
13665
13666 return _typeof(obj);
13667}
13668
13669var __extends = this && this.__extends || function () {
13670 var _extendStatics = function extendStatics(d, b) {
13671 _extendStatics = Object.setPrototypeOf || {
13672 __proto__: []
13673 } instanceof Array && function (d, b) {
13674 d.__proto__ = b;
13675 } || function (d, b) {
13676 for (var p in b) {
13677 if (b.hasOwnProperty(p)) d[p] = b[p];
13678 }
13679 };
13680
13681 return _extendStatics(d, b);
13682 };
13683
13684 return function (d, b) {
13685 _extendStatics(d, b);
13686
13687 function __() {
13688 this.constructor = d;
13689 }
13690
13691 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13692 };
13693}();
13694
13695var __importStar = this && this.__importStar || function (mod) {
13696 if (mod && mod.__esModule) return mod;
13697 var result = {};
13698 if (mod != null) for (var k in mod) {
13699 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
13700 }
13701 result["default"] = mod;
13702 return result;
13703};
13704
13705var __importDefault = this && this.__importDefault || function (mod) {
13706 return mod && mod.__esModule ? mod : {
13707 "default": mod
13708 };
13709};
13710
13711Object.defineProperty(exports, "__esModule", {
13712 value: true
13713});
13714
13715var React = __importStar(__webpack_require__(/*! react */ "react"));
13716
13717var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
13718
13719var storage_1 = __webpack_require__(/*! @aws-amplify/storage */ "@aws-amplify/storage");
13720
13721var Picker_1 = __webpack_require__(/*! ../Widget/Picker */ "./lib/Widget/Picker.js");
13722
13723var AmplifyTheme_1 = __importDefault(__webpack_require__(/*! ../AmplifyTheme */ "./lib/AmplifyTheme.js"));
13724
13725var S3Image_1 = __webpack_require__(/*! ./S3Image */ "./lib/Storage/S3Image.js");
13726
13727var S3Text_1 = __webpack_require__(/*! ./S3Text */ "./lib/Storage/S3Text.js");
13728
13729var logger = new core_1.ConsoleLogger('Storage.S3Album');
13730
13731var S3Album =
13732/** @class */
13733function (_super) {
13734 __extends(S3Album, _super);
13735
13736 function S3Album(props) {
13737 var _this = _super.call(this, props) || this;
13738
13739 _this._isMounted = false;
13740 _this.handlePick = _this.handlePick.bind(_this);
13741 _this.handleClick = _this.handleClick.bind(_this);
13742 _this.list = _this.list.bind(_this);
13743 _this.marshal = _this.marshal.bind(_this);
13744 _this.state = {
13745 items: [],
13746 ts: new Date().getTime()
13747 };
13748 return _this;
13749 }
13750
13751 S3Album.prototype.getKey = function (file) {
13752 var fileToKey = this.props.fileToKey;
13753 var name = file.name,
13754 size = file.size,
13755 type = file.type;
13756 var key = encodeURI(name);
13757
13758 if (fileToKey) {
13759 var callback_type = _typeof(fileToKey);
13760
13761 if (callback_type === 'string') {
13762 key = fileToKey;
13763 } else if (callback_type === 'function') {
13764 key = fileToKey({
13765 name: name,
13766 size: size,
13767 type: type
13768 });
13769 } else {
13770 key = encodeURI(JSON.stringify(fileToKey));
13771 }
13772
13773 if (!key) {
13774 logger.debug('key is empty');
13775 key = 'empty_key';
13776 }
13777 }
13778
13779 return key.replace(/\s/g, '_');
13780 };
13781
13782 S3Album.prototype.handlePick = function (data) {
13783 var _this = this;
13784
13785 var _a = this.props,
13786 onPick = _a.onPick,
13787 onLoad = _a.onLoad,
13788 onError = _a.onError,
13789 track = _a.track,
13790 level = _a.level;
13791
13792 if (onPick) {
13793 onPick(data);
13794 }
13795
13796 var path = this.props.path || '';
13797 var file = data.file,
13798 name = data.name,
13799 size = data.size,
13800 type = data.type;
13801 var key = path + this.getKey(data);
13802
13803 if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
13804 throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
13805 }
13806
13807 storage_1.Storage.put(key, file, {
13808 level: level ? level : 'public',
13809 contentType: type,
13810 track: track
13811 }).then(function (data) {
13812 logger.debug('handle pick data', data);
13813 var items = _this.state.items;
13814
13815 if (items.filter(function (item) {
13816 return item.key === key;
13817 }).length === 0) {
13818 var list = items.concat(data);
13819
13820 _this.marshal(list);
13821 } else {
13822 logger.debug('update an item');
13823 }
13824
13825 if (onLoad) {
13826 onLoad(data);
13827 }
13828 })["catch"](function (err) {
13829 logger.debug('handle pick error', err);
13830
13831 if (onError) {
13832 onError(err);
13833 }
13834 });
13835
13836 if (this._isMounted) {
13837 this.setState({
13838 ts: new Date().getTime()
13839 });
13840 }
13841 };
13842
13843 S3Album.prototype.handleClick = function (item) {
13844 var _a = this.props,
13845 onClickItem = _a.onClickItem,
13846 select = _a.select,
13847 onSelect = _a.onSelect;
13848
13849 if (onClickItem) {
13850 onClickItem(item);
13851 }
13852
13853 if (!select) {
13854 return;
13855 }
13856
13857 item.selected = !item.selected;
13858
13859 if (this._isMounted) {
13860 this.setState({
13861 items: this.state.items.slice()
13862 });
13863 }
13864
13865 if (!onSelect) {
13866 return;
13867 }
13868
13869 var selected_items = this.state.items.filter(function (item) {
13870 return item.selected;
13871 });
13872 onSelect(item, selected_items);
13873 };
13874
13875 S3Album.prototype.componentDidMount = function () {
13876 this._isMounted = true;
13877 this.list();
13878 };
13879
13880 S3Album.prototype.componentWillUnmount = function () {
13881 this._isMounted = false;
13882 };
13883
13884 S3Album.prototype.componentDidUpdate = function (prevProps, prevState) {
13885 if (this.props.path === prevProps.path && this.props.ts === prevProps.ts && this.props.select === prevProps.select) {
13886 return;
13887 }
13888
13889 if (!this.props.select) {
13890 this.state.items.forEach(function (item) {
13891 return item.selected = false;
13892 });
13893 }
13894
13895 if (this.props.onSelect) {
13896 this.props.onSelect(null, []);
13897 }
13898
13899 this.list();
13900 };
13901
13902 S3Album.prototype.list = function () {
13903 var _this = this;
13904
13905 var _a = this.props,
13906 path = _a.path,
13907 level = _a.level,
13908 track = _a.track,
13909 identityId = _a.identityId;
13910 logger.debug('Album path: ' + path);
13911
13912 if (!storage_1.Storage || typeof storage_1.Storage.list !== 'function') {
13913 throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
13914 }
13915
13916 return storage_1.Storage.list(path, {
13917 level: level ? level : 'public',
13918 track: track,
13919 identityId: identityId
13920 }).then(function (data) {
13921 logger.debug('album list', data);
13922
13923 _this.marshal(data);
13924 })["catch"](function (err) {
13925 logger.warn(err);
13926 return [];
13927 });
13928 };
13929
13930 S3Album.prototype.contentType = function (item) {
13931 return core_1.filenameToContentType(item.key, 'image/*');
13932 };
13933
13934 S3Album.prototype.marshal = function (list) {
13935 var _this = this;
13936
13937 var contentType = this.props.contentType || '';
13938 list.forEach(function (item) {
13939 if (item.contentType) {
13940 return;
13941 }
13942
13943 var isString = typeof contentType === 'string';
13944 item.contentType = isString ? contentType : contentType(item);
13945
13946 if (!item.contentType) {
13947 item.contentType = _this.contentType(item);
13948 }
13949 });
13950 var items = this.filter(list);
13951 items = this.sort(items);
13952
13953 if (this._isMounted) {
13954 this.setState({
13955 items: items
13956 });
13957 }
13958 };
13959
13960 S3Album.prototype.filter = function (list) {
13961 var filter = this.props.filter;
13962 return filter ? filter(list) : list;
13963 };
13964
13965 S3Album.prototype.sort = function (list) {
13966 var sort = this.props.sort;
13967
13968 var typeof_sort = _typeof(sort);
13969
13970 if (typeof_sort === 'function') {
13971 return sort(list);
13972 } // @ts-ignore
13973
13974
13975 if (['string', 'undefined'].includes(typeof_sort)) {
13976 var sort_str = sort ? sort : 'lastModified';
13977 var parts = sort_str.split(/\s+/);
13978 var field = parts[0];
13979 var dir = parts.length > 1 ? parts[1] : '';
13980
13981 if (field === 'lastModified') {
13982 dir = dir === 'asc' ? 'asc' : 'desc';
13983 } else {
13984 dir = dir === 'desc' ? 'desc' : 'asc';
13985 }
13986
13987 core_1.sortByField(list, field, dir);
13988 return list;
13989 }
13990
13991 logger.warn('invalid sort. done nothing. should be a string or function');
13992 return list;
13993 };
13994
13995 S3Album.prototype.render = function () {
13996 var _this = this;
13997
13998 var _a = this.props,
13999 picker = _a.picker,
14000 translateItem = _a.translateItem,
14001 level = _a.level,
14002 identityId = _a.identityId;
14003 var _b = this.state,
14004 items = _b.items,
14005 ts = _b.ts;
14006 var pickerTitle = this.props.pickerTitle || 'Pick';
14007 var theme = this.props.theme || AmplifyTheme_1["default"];
14008 var list = items.map(function (item) {
14009 var isText = item.contentType && core_1.isTextFile(item.contentType);
14010 return isText ? React.createElement(S3Text_1.S3Text, {
14011 key: item.key,
14012 textKey: item.key,
14013 theme: theme,
14014 style: theme.albumText,
14015 selected: item.selected,
14016 translate: translateItem,
14017 level: level,
14018 identityId: identityId,
14019 onClick: function onClick() {
14020 return _this.handleClick(item);
14021 }
14022 }) : React.createElement(S3Image_1.S3Image, {
14023 key: item.key,
14024 imgKey: item.key,
14025 theme: theme,
14026 style: theme.albumPhoto,
14027 selected: item.selected,
14028 translate: translateItem,
14029 level: level,
14030 identityId: identityId,
14031 onClick: function onClick() {
14032 return _this.handleClick(item);
14033 }
14034 });
14035 });
14036 return React.createElement("div", null, React.createElement("div", {
14037 style: theme.album
14038 }, list), picker ? React.createElement(Picker_1.Picker, {
14039 key: ts,
14040 title: pickerTitle,
14041 accept: "image/*, text/*",
14042 onPick: this.handlePick,
14043 theme: theme
14044 }) : null);
14045 };
14046
14047 return S3Album;
14048}(React.Component);
14049
14050exports.S3Album = S3Album;
14051/**
14052 * @deprecated use named import
14053 */
14054
14055exports["default"] = S3Album;
14056
14057/***/ }),
14058
14059/***/ "./lib/Storage/S3Image.js":
14060/*!********************************!*\
14061 !*** ./lib/Storage/S3Image.js ***!
14062 \********************************/
14063/*! no static exports found */
14064/***/ (function(module, exports, __webpack_require__) {
14065
14066"use strict";
14067
14068/*
14069 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
14070 *
14071 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
14072 * the License. A copy of the License is located at
14073 *
14074 * http://aws.amazon.com/apache2.0/
14075 *
14076 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14077 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
14078 * and limitations under the License.
14079 */
14080
14081var __extends = this && this.__extends || function () {
14082 var _extendStatics = function extendStatics(d, b) {
14083 _extendStatics = Object.setPrototypeOf || {
14084 __proto__: []
14085 } instanceof Array && function (d, b) {
14086 d.__proto__ = b;
14087 } || function (d, b) {
14088 for (var p in b) {
14089 if (b.hasOwnProperty(p)) d[p] = b[p];
14090 }
14091 };
14092
14093 return _extendStatics(d, b);
14094 };
14095
14096 return function (d, b) {
14097 _extendStatics(d, b);
14098
14099 function __() {
14100 this.constructor = d;
14101 }
14102
14103 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14104 };
14105}();
14106
14107var __importStar = this && this.__importStar || function (mod) {
14108 if (mod && mod.__esModule) return mod;
14109 var result = {};
14110 if (mod != null) for (var k in mod) {
14111 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
14112 }
14113 result["default"] = mod;
14114 return result;
14115};
14116
14117var __importDefault = this && this.__importDefault || function (mod) {
14118 return mod && mod.__esModule ? mod : {
14119 "default": mod
14120 };
14121};
14122
14123Object.defineProperty(exports, "__esModule", {
14124 value: true
14125});
14126
14127var React = __importStar(__webpack_require__(/*! react */ "react"));
14128
14129var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
14130
14131var storage_1 = __webpack_require__(/*! @aws-amplify/storage */ "@aws-amplify/storage");
14132
14133var AmplifyTheme_1 = __importDefault(__webpack_require__(/*! ../AmplifyTheme */ "./lib/AmplifyTheme.js"));
14134
14135var AmplifyUI_1 = __webpack_require__(/*! ../AmplifyUI */ "./lib/AmplifyUI.js");
14136
14137var PhotoPicker_1 = __webpack_require__(/*! ../Widget/PhotoPicker */ "./lib/Widget/PhotoPicker.js");
14138
14139var Common_1 = __webpack_require__(/*! ./Common */ "./lib/Storage/Common.js");
14140
14141var logger = new core_1.ConsoleLogger('Storage.S3Image');
14142
14143var S3Image =
14144/** @class */
14145function (_super) {
14146 __extends(S3Image, _super);
14147
14148 function S3Image(props) {
14149 var _this = _super.call(this, props) || this;
14150
14151 _this._isMounted = false;
14152 _this.handleOnLoad = _this.handleOnLoad.bind(_this);
14153 _this.handleOnError = _this.handleOnError.bind(_this);
14154 _this.handlePick = _this.handlePick.bind(_this);
14155 _this.handleClick = _this.handleClick.bind(_this);
14156 var initSrc = _this.props.src || AmplifyUI_1.transparent1X1;
14157 _this.state = {
14158 src: initSrc
14159 };
14160 return _this;
14161 }
14162
14163 S3Image.prototype.getImageSource = function (key, level, track, identityId) {
14164 var _this = this;
14165
14166 if (!storage_1.Storage || typeof storage_1.Storage.get !== 'function') {
14167 throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
14168 }
14169
14170 storage_1.Storage.get(key, {
14171 level: level ? level : 'public',
14172 track: track,
14173 identityId: identityId
14174 }).then(function (url) {
14175 if (_this._isMounted) {
14176 _this.setState({
14177 src: url
14178 });
14179 }
14180 })["catch"](function (err) {
14181 return logger.debug(err);
14182 });
14183 };
14184
14185 S3Image.prototype.load = function () {
14186 var _a = this.props,
14187 imgKey = _a.imgKey,
14188 path = _a.path,
14189 body = _a.body,
14190 contentType = _a.contentType,
14191 level = _a.level,
14192 track = _a.track,
14193 identityId = _a.identityId;
14194
14195 if (!imgKey && !path) {
14196 logger.debug('empty imgKey and path');
14197 return;
14198 }
14199
14200 var that = this;
14201 var key = imgKey || path;
14202 logger.debug('loading ' + key + '...');
14203
14204 if (body) {
14205 var type = contentType || 'binary/octet-stream';
14206
14207 if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
14208 throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
14209 }
14210
14211 var ret = storage_1.Storage.put(key, body, {
14212 contentType: type,
14213 level: level ? level : 'public',
14214 track: track
14215 });
14216 ret.then(function (data) {
14217 logger.debug(data);
14218 that.getImageSource(key, level, track, identityId);
14219 })["catch"](function (err) {
14220 return logger.debug(err);
14221 });
14222 } else {
14223 that.getImageSource(key, level, track, identityId);
14224 }
14225 };
14226
14227 S3Image.prototype.handleOnLoad = function (evt) {
14228 var onLoad = this.props.onLoad;
14229
14230 if (onLoad) {
14231 onLoad(this.state.src);
14232 }
14233 };
14234
14235 S3Image.prototype.handleOnError = function (evt) {
14236 var onError = this.props.onError;
14237
14238 if (onError) {
14239 onError(this.state.src);
14240 }
14241 };
14242
14243 S3Image.prototype.handlePick = function (data) {
14244 var that = this;
14245 var _a = this.props,
14246 imgKey = _a.imgKey,
14247 level = _a.level,
14248 fileToKey = _a.fileToKey,
14249 track = _a.track,
14250 identityId = _a.identityId,
14251 _b = _a.path,
14252 path = _b === void 0 ? '' : _b,
14253 onUploadSuccess = _a.onUploadSuccess;
14254 var file = data.file,
14255 type = data.type;
14256 var key = imgKey || path + Common_1.calcKey(data, fileToKey);
14257
14258 if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
14259 throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
14260 }
14261
14262 storage_1.Storage.put(key, file, {
14263 level: level ? level : 'public',
14264 contentType: type,
14265 track: track
14266 }).then(function (data) {
14267 logger.debug('handle pick data', data);
14268 that.getImageSource(key, level, track, identityId);
14269 if (onUploadSuccess) onUploadSuccess();
14270 })["catch"](function (err) {
14271 return logger.debug('handle pick error', err);
14272 });
14273 };
14274
14275 S3Image.prototype.handleClick = function (evt) {
14276 var onClick = this.props.onClick;
14277
14278 if (onClick) {
14279 onClick(evt);
14280 }
14281 };
14282
14283 S3Image.prototype.componentDidMount = function () {
14284 this._isMounted = true;
14285 this.load();
14286 };
14287
14288 S3Image.prototype.componentWillUnmount = function () {
14289 this._isMounted = false;
14290 };
14291
14292 S3Image.prototype.componentDidUpdate = function (prevProps) {
14293 var update = prevProps.path !== this.props.path || prevProps.imgKey !== this.props.imgKey || prevProps.body !== this.props.body || prevProps.level !== this.props.level;
14294
14295 if (update) {
14296 this.load();
14297 }
14298 };
14299
14300 S3Image.prototype.imageEl = function (src, theme) {
14301 if (!src) {
14302 return null;
14303 }
14304
14305 var _a = this.props,
14306 className = _a.className,
14307 selected = _a.selected;
14308 var containerStyle = {
14309 position: 'relative'
14310 };
14311 return React.createElement("div", {
14312 style: containerStyle,
14313 onClick: this.handleClick
14314 }, React.createElement("img", {
14315 className: className,
14316 style: theme.photoImg,
14317 src: src,
14318 onLoad: this.handleOnLoad,
14319 onError: this.handleOnError
14320 }), React.createElement("div", {
14321 style: selected ? theme.overlaySelected : theme.overlay
14322 }));
14323 };
14324
14325 S3Image.prototype.render = function () {
14326 var _a = this.props,
14327 hidden = _a.hidden,
14328 style = _a.style,
14329 picker = _a.picker,
14330 translate = _a.translate,
14331 imgKey = _a.imgKey;
14332 var src = this.state.src;
14333
14334 if (translate) {
14335 src = typeof translate === 'string' ? translate : translate({
14336 type: 'image',
14337 key: imgKey,
14338 content: src
14339 });
14340 }
14341
14342 if (!src && !picker) {
14343 return null;
14344 }
14345
14346 var theme = this.props.theme || AmplifyTheme_1["default"];
14347 var photoStyle = hidden ? AmplifyTheme_1["default"].hidden : Object.assign({}, theme.photo, style);
14348 return React.createElement("div", {
14349 style: photoStyle
14350 }, photoStyle ? this.imageEl(src, theme) : null, picker ? React.createElement("div", null, React.createElement(PhotoPicker_1.PhotoPicker, {
14351 key: "picker",
14352 onPick: this.handlePick,
14353 theme: theme
14354 })) : null);
14355 };
14356
14357 return S3Image;
14358}(React.Component);
14359
14360exports.S3Image = S3Image;
14361/**
14362 * @deprecated use named import
14363 */
14364
14365exports["default"] = S3Image;
14366
14367/***/ }),
14368
14369/***/ "./lib/Storage/S3Text.js":
14370/*!*******************************!*\
14371 !*** ./lib/Storage/S3Text.js ***!
14372 \*******************************/
14373/*! no static exports found */
14374/***/ (function(module, exports, __webpack_require__) {
14375
14376"use strict";
14377
14378/*
14379 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
14380 *
14381 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
14382 * the License. A copy of the License is located at
14383 *
14384 * http://aws.amazon.com/apache2.0/
14385 *
14386 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14387 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
14388 * and limitations under the License.
14389 */
14390
14391var __extends = this && this.__extends || function () {
14392 var _extendStatics = function extendStatics(d, b) {
14393 _extendStatics = Object.setPrototypeOf || {
14394 __proto__: []
14395 } instanceof Array && function (d, b) {
14396 d.__proto__ = b;
14397 } || function (d, b) {
14398 for (var p in b) {
14399 if (b.hasOwnProperty(p)) d[p] = b[p];
14400 }
14401 };
14402
14403 return _extendStatics(d, b);
14404 };
14405
14406 return function (d, b) {
14407 _extendStatics(d, b);
14408
14409 function __() {
14410 this.constructor = d;
14411 }
14412
14413 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14414 };
14415}();
14416
14417var __importStar = this && this.__importStar || function (mod) {
14418 if (mod && mod.__esModule) return mod;
14419 var result = {};
14420 if (mod != null) for (var k in mod) {
14421 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
14422 }
14423 result["default"] = mod;
14424 return result;
14425};
14426
14427var __importDefault = this && this.__importDefault || function (mod) {
14428 return mod && mod.__esModule ? mod : {
14429 "default": mod
14430 };
14431};
14432
14433Object.defineProperty(exports, "__esModule", {
14434 value: true
14435});
14436
14437var React = __importStar(__webpack_require__(/*! react */ "react"));
14438
14439var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
14440
14441var storage_1 = __webpack_require__(/*! @aws-amplify/storage */ "@aws-amplify/storage");
14442
14443var AmplifyTheme_1 = __importDefault(__webpack_require__(/*! ../AmplifyTheme */ "./lib/AmplifyTheme.js"));
14444
14445var TextPicker_1 = __webpack_require__(/*! ../Widget/TextPicker */ "./lib/Widget/TextPicker.js");
14446
14447var Common_1 = __webpack_require__(/*! ./Common */ "./lib/Storage/Common.js");
14448
14449var logger = new core_1.ConsoleLogger('Storage.S3Text');
14450
14451var S3Text =
14452/** @class */
14453function (_super) {
14454 __extends(S3Text, _super);
14455
14456 function S3Text(props) {
14457 var _this = _super.call(this, props) || this;
14458
14459 _this._isMounted = false;
14460 _this.handleOnLoad = _this.handleOnLoad.bind(_this);
14461 _this.handleOnError = _this.handleOnError.bind(_this);
14462 _this.handlePick = _this.handlePick.bind(_this);
14463 _this.handleClick = _this.handleClick.bind(_this);
14464 var text = props.text,
14465 textKey = props.textKey;
14466 _this.state = {
14467 text: text || '',
14468 textKey: textKey || ''
14469 };
14470 return _this;
14471 }
14472
14473 S3Text.prototype.getText = function (key, level, track, identityId) {
14474 var _this = this;
14475
14476 if (!storage_1.Storage || typeof storage_1.Storage.get !== 'function') {
14477 throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
14478 }
14479
14480 storage_1.Storage.get(key, {
14481 download: true,
14482 level: level ? level : 'public',
14483 track: track,
14484 identityId: identityId
14485 }).then(function (data) {
14486 logger.debug(data); // @ts-ignore
14487
14488 var text = data.Body.toString('utf8');
14489
14490 if (_this._isMounted) {
14491 _this.setState({
14492 text: text
14493 });
14494 }
14495
14496 _this.handleOnLoad(text);
14497 })["catch"](function (err) {
14498 logger.debug(err);
14499
14500 _this.handleOnError(err);
14501 });
14502 };
14503
14504 S3Text.prototype.load = function () {
14505 var _a = this.props,
14506 path = _a.path,
14507 textKey = _a.textKey,
14508 body = _a.body,
14509 contentType = _a.contentType,
14510 level = _a.level,
14511 track = _a.track,
14512 identityId = _a.identityId;
14513
14514 if (!textKey && !path) {
14515 logger.debug('empty textKey and path');
14516 return;
14517 }
14518
14519 var that = this;
14520 var key = textKey || path;
14521 logger.debug('loading ' + key + '...');
14522
14523 if (body) {
14524 var type = contentType || 'text/*';
14525
14526 if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
14527 throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
14528 }
14529
14530 var ret = storage_1.Storage.put(key, body, {
14531 contentType: type,
14532 level: level ? level : 'public',
14533 track: track
14534 });
14535 ret.then(function (data) {
14536 logger.debug(data);
14537 that.getText(key, level, track, identityId);
14538 })["catch"](function (err) {
14539 return logger.debug(err);
14540 });
14541 } else {
14542 that.getText(key, level, track, identityId);
14543 }
14544 };
14545
14546 S3Text.prototype.handleOnLoad = function (text) {
14547 var onLoad = this.props.onLoad;
14548
14549 if (onLoad) {
14550 onLoad(text);
14551 }
14552 };
14553
14554 S3Text.prototype.handleOnError = function (err) {
14555 var onError = this.props.onError;
14556
14557 if (onError) {
14558 onError(err);
14559 }
14560 };
14561
14562 S3Text.prototype.handlePick = function (data) {
14563 var that = this;
14564 var path = this.props.path || '';
14565 var _a = this.props,
14566 textKey = _a.textKey,
14567 level = _a.level,
14568 fileToKey = _a.fileToKey,
14569 track = _a.track,
14570 identityId = _a.identityId;
14571 var file = data.file,
14572 name = data.name,
14573 size = data.size,
14574 type = data.type;
14575 var key = textKey || path + Common_1.calcKey(data, fileToKey);
14576
14577 if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
14578 throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
14579 }
14580
14581 storage_1.Storage.put(key, file, {
14582 level: level ? level : 'public',
14583 contentType: type,
14584 track: track
14585 }).then(function (data) {
14586 logger.debug('handle pick data', data);
14587 that.getText(key, level, track, identityId);
14588 })["catch"](function (err) {
14589 return logger.debug('handle pick error', err);
14590 });
14591 };
14592
14593 S3Text.prototype.handleClick = function (evt) {
14594 var onClick = this.props.onClick;
14595
14596 if (onClick) {
14597 onClick(evt);
14598 }
14599 };
14600
14601 S3Text.prototype.componentDidMount = function () {
14602 this._isMounted = true;
14603 this.load();
14604 };
14605
14606 S3Text.prototype.componentWillUnmount = function () {
14607 this._isMounted = false;
14608 };
14609
14610 S3Text.prototype.componentDidUpdate = function (prevProps) {
14611 var update = prevProps.path !== this.props.path || prevProps.textKey !== this.props.textKey || prevProps.body !== this.props.body;
14612
14613 if (update) {
14614 this.load();
14615 }
14616 };
14617
14618 S3Text.prototype.textEl = function (text, theme) {
14619 if (!text) {
14620 return null;
14621 }
14622
14623 var selected = this.props.selected;
14624 var containerStyle = {
14625 position: 'relative'
14626 };
14627 return React.createElement("div", {
14628 style: containerStyle,
14629 onClick: this.handleClick
14630 }, React.createElement("pre", {
14631 style: theme.pre
14632 }, text), React.createElement("div", {
14633 style: selected ? theme.overlaySelected : theme.overlay
14634 }));
14635 };
14636
14637 S3Text.prototype.render = function () {
14638 var _a = this.props,
14639 hidden = _a.hidden,
14640 style = _a.style,
14641 picker = _a.picker,
14642 translate = _a.translate,
14643 textKey = _a.textKey;
14644 var text = this.state.text;
14645
14646 if (translate) {
14647 text = typeof translate === 'string' ? translate : translate({
14648 type: 'text',
14649 key: textKey,
14650 content: text
14651 });
14652 }
14653
14654 if (!text && !picker) {
14655 return null;
14656 }
14657
14658 var theme = this.props.theme || AmplifyTheme_1["default"];
14659 var textStyle = hidden ? AmplifyTheme_1["default"].hidden : Object.assign({}, theme.text, style);
14660 return React.createElement("div", {
14661 style: textStyle
14662 }, textStyle ? this.textEl(text, theme) : null, picker ? React.createElement("div", null, React.createElement(TextPicker_1.TextPicker, {
14663 key: "picker",
14664 onPick: this.handlePick,
14665 theme: theme
14666 })) : null);
14667 };
14668
14669 return S3Text;
14670}(React.Component);
14671
14672exports.S3Text = S3Text;
14673/**
14674 * @deprecated use named import
14675 */
14676
14677exports["default"] = S3Text;
14678
14679/***/ }),
14680
14681/***/ "./lib/Storage/index.js":
14682/*!******************************!*\
14683 !*** ./lib/Storage/index.js ***!
14684 \******************************/
14685/*! no static exports found */
14686/***/ (function(module, exports, __webpack_require__) {
14687
14688"use strict";
14689
14690/*
14691 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
14692 *
14693 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
14694 * the License. A copy of the License is located at
14695 *
14696 * http://aws.amazon.com/apache2.0/
14697 *
14698 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14699 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
14700 * and limitations under the License.
14701 */
14702
14703Object.defineProperty(exports, "__esModule", {
14704 value: true
14705});
14706
14707var S3Album_1 = __webpack_require__(/*! ./S3Album */ "./lib/Storage/S3Album.js");
14708
14709exports.S3Album = S3Album_1.S3Album;
14710
14711var S3Image_1 = __webpack_require__(/*! ./S3Image */ "./lib/Storage/S3Image.js");
14712
14713exports.S3Image = S3Image_1.S3Image;
14714
14715var S3Text_1 = __webpack_require__(/*! ./S3Text */ "./lib/Storage/S3Text.js");
14716
14717exports.S3Text = S3Text_1.S3Text;
14718
14719/***/ }),
14720
14721/***/ "./lib/Widget/PhotoPicker.js":
14722/*!***********************************!*\
14723 !*** ./lib/Widget/PhotoPicker.js ***!
14724 \***********************************/
14725/*! no static exports found */
14726/***/ (function(module, exports, __webpack_require__) {
14727
14728"use strict";
14729
14730/*
14731 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
14732 *
14733 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
14734 * the License. A copy of the License is located at
14735 *
14736 * http://aws.amazon.com/apache2.0/
14737 *
14738 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14739 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
14740 * and limitations under the License.
14741 */
14742
14743var __extends = this && this.__extends || function () {
14744 var _extendStatics = function extendStatics(d, b) {
14745 _extendStatics = Object.setPrototypeOf || {
14746 __proto__: []
14747 } instanceof Array && function (d, b) {
14748 d.__proto__ = b;
14749 } || function (d, b) {
14750 for (var p in b) {
14751 if (b.hasOwnProperty(p)) d[p] = b[p];
14752 }
14753 };
14754
14755 return _extendStatics(d, b);
14756 };
14757
14758 return function (d, b) {
14759 _extendStatics(d, b);
14760
14761 function __() {
14762 this.constructor = d;
14763 }
14764
14765 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14766 };
14767}();
14768
14769var __importStar = this && this.__importStar || function (mod) {
14770 if (mod && mod.__esModule) return mod;
14771 var result = {};
14772 if (mod != null) for (var k in mod) {
14773 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
14774 }
14775 result["default"] = mod;
14776 return result;
14777};
14778
14779var __importDefault = this && this.__importDefault || function (mod) {
14780 return mod && mod.__esModule ? mod : {
14781 "default": mod
14782 };
14783};
14784
14785Object.defineProperty(exports, "__esModule", {
14786 value: true
14787});
14788
14789var React = __importStar(__webpack_require__(/*! react */ "react"));
14790
14791var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
14792
14793var Picker_1 = __webpack_require__(/*! ./Picker */ "./lib/Widget/Picker.js");
14794
14795var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
14796
14797var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
14798
14799var PickerPreview = {
14800 maxWidth: '100%'
14801};
14802var logger = new core_1.ConsoleLogger('PhotoPicker');
14803
14804var PhotoPicker =
14805/** @class */
14806function (_super) {
14807 __extends(PhotoPicker, _super);
14808
14809 function PhotoPicker(props) {
14810 var _this = _super.call(this, props) || this;
14811
14812 _this.handlePick = _this.handlePick.bind(_this);
14813 _this.state = {
14814 previewSrc: props.previewSrc
14815 };
14816 return _this;
14817 }
14818
14819 PhotoPicker.prototype.handlePick = function (data) {
14820 var that = this;
14821 var file = data.file,
14822 name = data.name,
14823 size = data.size,
14824 type = data.type;
14825 var _a = this.props,
14826 preview = _a.preview,
14827 onPick = _a.onPick,
14828 onLoad = _a.onLoad;
14829
14830 if (onPick) {
14831 onPick(data);
14832 }
14833
14834 if (preview) {
14835 var reader = new FileReader();
14836
14837 reader.onload = function (e) {
14838 var url = e.target.result; // @ts-ignore
14839
14840 that.setState({
14841 previewSrc: url
14842 });
14843
14844 if (onLoad) {
14845 onLoad(url);
14846 }
14847 };
14848
14849 reader.readAsDataURL(file);
14850 }
14851 };
14852
14853 PhotoPicker.prototype.render = function () {
14854 var preview = this.props.preview;
14855 var previewSrc = this.state.previewSrc;
14856 var headerText = this.props.headerText || 'Photos';
14857 var headerHint = this.props.headerHint || 'Add your photos by clicking below';
14858 var title = this.props.title || 'Select a Photo';
14859 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
14860 var previewStyle = Object.assign({}, PickerPreview, theme.pickerPreview);
14861 var previewHidden = !(preview && preview !== 'hidden');
14862 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
14863 theme: theme
14864 }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
14865 theme: theme,
14866 hint: headerHint
14867 }, core_1.I18n.get(headerText)), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
14868 theme: theme
14869 }, previewSrc ? previewHidden ? 'The image has been selected' : React.createElement("img", {
14870 src: previewSrc,
14871 style: previewStyle
14872 }) : React.createElement(Amplify_UI_Components_React_1.PhotoPlaceholder, {
14873 theme: theme
14874 })), React.createElement(Picker_1.Picker, {
14875 title: title,
14876 accept: "image/*",
14877 theme: theme,
14878 onPick: this.handlePick
14879 }));
14880 };
14881
14882 return PhotoPicker;
14883}(React.Component);
14884
14885exports.PhotoPicker = PhotoPicker;
14886/**
14887 * @deprecated use named import
14888 */
14889
14890exports["default"] = PhotoPicker;
14891
14892/***/ }),
14893
14894/***/ "./lib/Widget/Picker.js":
14895/*!******************************!*\
14896 !*** ./lib/Widget/Picker.js ***!
14897 \******************************/
14898/*! no static exports found */
14899/***/ (function(module, exports, __webpack_require__) {
14900
14901"use strict";
14902
14903/*
14904 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
14905 *
14906 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
14907 * the License. A copy of the License is located at
14908 *
14909 * http://aws.amazon.com/apache2.0/
14910 *
14911 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14912 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
14913 * and limitations under the License.
14914 */
14915
14916var __extends = this && this.__extends || function () {
14917 var _extendStatics = function extendStatics(d, b) {
14918 _extendStatics = Object.setPrototypeOf || {
14919 __proto__: []
14920 } instanceof Array && function (d, b) {
14921 d.__proto__ = b;
14922 } || function (d, b) {
14923 for (var p in b) {
14924 if (b.hasOwnProperty(p)) d[p] = b[p];
14925 }
14926 };
14927
14928 return _extendStatics(d, b);
14929 };
14930
14931 return function (d, b) {
14932 _extendStatics(d, b);
14933
14934 function __() {
14935 this.constructor = d;
14936 }
14937
14938 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14939 };
14940}();
14941
14942var __importStar = this && this.__importStar || function (mod) {
14943 if (mod && mod.__esModule) return mod;
14944 var result = {};
14945 if (mod != null) for (var k in mod) {
14946 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
14947 }
14948 result["default"] = mod;
14949 return result;
14950};
14951
14952var __importDefault = this && this.__importDefault || function (mod) {
14953 return mod && mod.__esModule ? mod : {
14954 "default": mod
14955 };
14956};
14957
14958Object.defineProperty(exports, "__esModule", {
14959 value: true
14960});
14961
14962var React = __importStar(__webpack_require__(/*! react */ "react"));
14963
14964var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
14965
14966var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
14967
14968var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
14969
14970var PickerInput = {
14971 width: '100%',
14972 height: '100%',
14973 display: 'inline-block',
14974 position: 'absolute',
14975 left: 0,
14976 top: 0,
14977 opacity: 0,
14978 cursor: 'pointer'
14979};
14980var logger = new core_1.ConsoleLogger('Picker');
14981
14982var Picker =
14983/** @class */
14984function (_super) {
14985 __extends(Picker, _super);
14986
14987 function Picker() {
14988 return _super !== null && _super.apply(this, arguments) || this;
14989 }
14990
14991 Picker.prototype.handleInput = function (e) {
14992 var that = this;
14993 var file = e.target.files[0];
14994
14995 if (!file) {
14996 return;
14997 }
14998
14999 var name = file.name,
15000 size = file.size,
15001 type = file.type;
15002 logger.debug(file);
15003 var onPick = this.props.onPick;
15004
15005 if (onPick) {
15006 onPick({
15007 file: file,
15008 name: name,
15009 size: size,
15010 type: type
15011 });
15012 }
15013 };
15014
15015 Picker.prototype.render = function () {
15016 var _this = this;
15017
15018 var title = this.props.title || 'Pick a File';
15019 var accept = this.props.accept || '*/*';
15020 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
15021 var pickerStyle = Object.assign({}, {
15022 position: 'relative'
15023 }, theme.pickerPicker);
15024 var inputStyle = Object.assign({}, PickerInput, theme.pickerInput);
15025 return React.createElement("div", {
15026 style: pickerStyle
15027 }, React.createElement(Amplify_UI_Components_React_1.PhotoPickerButton, {
15028 theme: theme
15029 }, core_1.I18n.get(title)), React.createElement("input", {
15030 title: core_1.I18n.get(title),
15031 type: "file",
15032 accept: accept,
15033 style: inputStyle,
15034 onChange: function onChange(e) {
15035 return _this.handleInput(e);
15036 }
15037 }));
15038 };
15039
15040 return Picker;
15041}(React.Component);
15042
15043exports.Picker = Picker;
15044/**
15045 * @deprecated use named import
15046 */
15047
15048exports["default"] = Picker;
15049
15050/***/ }),
15051
15052/***/ "./lib/Widget/SelectMFAType.js":
15053/*!*************************************!*\
15054 !*** ./lib/Widget/SelectMFAType.js ***!
15055 \*************************************/
15056/*! no static exports found */
15057/***/ (function(module, exports, __webpack_require__) {
15058
15059"use strict";
15060
15061/*
15062 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
15063 *
15064 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
15065 * the License. A copy of the License is located at
15066 *
15067 * http://aws.amazon.com/apache2.0/
15068 *
15069 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15070 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
15071 * and limitations under the License.
15072 */
15073
15074var __extends = this && this.__extends || function () {
15075 var _extendStatics = function extendStatics(d, b) {
15076 _extendStatics = Object.setPrototypeOf || {
15077 __proto__: []
15078 } instanceof Array && function (d, b) {
15079 d.__proto__ = b;
15080 } || function (d, b) {
15081 for (var p in b) {
15082 if (b.hasOwnProperty(p)) d[p] = b[p];
15083 }
15084 };
15085
15086 return _extendStatics(d, b);
15087 };
15088
15089 return function (d, b) {
15090 _extendStatics(d, b);
15091
15092 function __() {
15093 this.constructor = d;
15094 }
15095
15096 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15097 };
15098}();
15099
15100var __assign = this && this.__assign || function () {
15101 __assign = Object.assign || function (t) {
15102 for (var s, i = 1, n = arguments.length; i < n; i++) {
15103 s = arguments[i];
15104
15105 for (var p in s) {
15106 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
15107 }
15108 }
15109
15110 return t;
15111 };
15112
15113 return __assign.apply(this, arguments);
15114};
15115
15116var __importStar = this && this.__importStar || function (mod) {
15117 if (mod && mod.__esModule) return mod;
15118 var result = {};
15119 if (mod != null) for (var k in mod) {
15120 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15121 }
15122 result["default"] = mod;
15123 return result;
15124};
15125
15126var __importDefault = this && this.__importDefault || function (mod) {
15127 return mod && mod.__esModule ? mod : {
15128 "default": mod
15129 };
15130};
15131
15132Object.defineProperty(exports, "__esModule", {
15133 value: true
15134});
15135
15136var React = __importStar(__webpack_require__(/*! react */ "react"));
15137
15138var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
15139
15140var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
15141
15142var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
15143
15144var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
15145
15146var TOTPSetupComp_1 = __webpack_require__(/*! ./TOTPSetupComp */ "./lib/Widget/TOTPSetupComp.js");
15147
15148var logger = new core_1.ConsoleLogger('SelectMFAType');
15149
15150var SelectMFAType =
15151/** @class */
15152function (_super) {
15153 __extends(SelectMFAType, _super);
15154
15155 function SelectMFAType(props) {
15156 var _this = _super.call(this, props) || this;
15157
15158 _this.verify = _this.verify.bind(_this);
15159 _this.handleInputChange = _this.handleInputChange.bind(_this);
15160 _this.state = {
15161 TOTPSetup: false,
15162 selectMessage: null
15163 };
15164 return _this;
15165 }
15166
15167 SelectMFAType.prototype.handleInputChange = function (evt) {
15168 // clear current state
15169 this.setState({
15170 TOTPSetup: false,
15171 selectMessage: null
15172 });
15173 this.inputs = {};
15174 var _a = evt.target,
15175 name = _a.name,
15176 value = _a.value,
15177 type = _a.type,
15178 checked = _a.checked; // @ts-ignore
15179
15180 var check_type = ['radio', 'checkbox'].includes(type);
15181 this.inputs[value] = check_type ? checked : value;
15182 };
15183
15184 SelectMFAType.prototype.verify = function () {
15185 var _this = this;
15186
15187 logger.debug('mfatypes inputs', this.inputs);
15188
15189 if (!this.inputs) {
15190 logger.debug('No mfa type selected');
15191 return;
15192 }
15193
15194 var _a = this.inputs,
15195 TOTP = _a.TOTP,
15196 SMS = _a.SMS,
15197 NOMFA = _a.NOMFA;
15198 var mfaMethod = null;
15199
15200 if (TOTP) {
15201 mfaMethod = 'TOTP';
15202 } else if (SMS) {
15203 mfaMethod = 'SMS';
15204 } else if (NOMFA) {
15205 mfaMethod = 'NOMFA';
15206 }
15207
15208 var user = this.props.authData;
15209
15210 if (!auth_1.Auth || typeof auth_1.Auth.setPreferredMFA !== 'function') {
15211 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
15212 }
15213
15214 auth_1.Auth.setPreferredMFA(user, mfaMethod).then(function (data) {
15215 logger.debug('set preferred mfa success', data);
15216
15217 _this.setState({
15218 selectMessage: 'Success! Your MFA Type is now: ' + mfaMethod,
15219 showToast: true
15220 });
15221 })["catch"](function (err) {
15222 var message = err.message;
15223
15224 if (message === 'User has not set up software token mfa' || message === 'User has not verified software token mfa') {
15225 _this.setState({
15226 TOTPSetup: true,
15227 selectMessage: 'You need to setup TOTP',
15228 showToast: true
15229 });
15230 } else {
15231 logger.debug('set preferred mfa failed', err);
15232
15233 _this.setState({
15234 selectMessage: 'Failed! You cannot select MFA Type for now!',
15235 showToast: true
15236 });
15237 }
15238 });
15239 };
15240
15241 SelectMFAType.prototype.selectView = function (theme) {
15242 var _this = this;
15243
15244 var MFATypes = this.props.MFATypes;
15245
15246 if (!MFATypes || Object.keys(MFATypes).length < 2) {
15247 logger.debug('less than 2 mfa types available');
15248 return React.createElement("div", null, React.createElement("a", null, "less than 2 mfa types available"));
15249 }
15250
15251 var SMS = MFATypes.SMS,
15252 TOTP = MFATypes.TOTP,
15253 Optional = MFATypes.Optional;
15254 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
15255 theme: theme
15256 }, this.state.showToast && this.state.selectMessage && React.createElement(Amplify_UI_Components_React_1.Toast, {
15257 theme: theme,
15258 onClose: function onClose() {
15259 return _this.setState({
15260 showToast: false
15261 });
15262 }
15263 }, core_1.I18n.get(this.state.selectMessage)), React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
15264 theme: theme
15265 }, core_1.I18n.get('Select MFA Type')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
15266 theme: theme
15267 }, React.createElement("div", null, SMS ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
15268 placeholder: core_1.I18n.get('SMS'),
15269 theme: theme,
15270 key: "sms",
15271 name: "MFAType",
15272 value: "SMS",
15273 onChange: this.handleInputChange
15274 }) : null, TOTP ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
15275 placeholder: core_1.I18n.get('TOTP'),
15276 theme: theme,
15277 key: "totp",
15278 name: "MFAType",
15279 value: "TOTP",
15280 onChange: this.handleInputChange
15281 }) : null, Optional ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
15282 placeholder: core_1.I18n.get('No MFA'),
15283 theme: theme,
15284 key: "noMFA",
15285 name: "MFAType",
15286 value: "NOMFA",
15287 onChange: this.handleInputChange
15288 }) : null)), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
15289 theme: theme
15290 }, React.createElement(Amplify_UI_Components_React_1.Button, {
15291 theme: theme,
15292 onClick: this.verify
15293 }, core_1.I18n.get('Verify'))));
15294 };
15295
15296 SelectMFAType.prototype.render = function () {
15297 var theme = this.props.theme || Amplify_UI_Theme_1["default"];
15298 return React.createElement("div", null, this.selectView(theme), this.state.TOTPSetup ? React.createElement(TOTPSetupComp_1.TOTPSetupComp, __assign({}, this.props)) : null);
15299 };
15300
15301 return SelectMFAType;
15302}(React.Component);
15303
15304exports.SelectMFAType = SelectMFAType;
15305/**
15306 * @deprecated use named import
15307 */
15308
15309exports["default"] = SelectMFAType;
15310
15311/***/ }),
15312
15313/***/ "./lib/Widget/TOTPSetupComp.js":
15314/*!*************************************!*\
15315 !*** ./lib/Widget/TOTPSetupComp.js ***!
15316 \*************************************/
15317/*! no static exports found */
15318/***/ (function(module, exports, __webpack_require__) {
15319
15320"use strict";
15321
15322/*
15323 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
15324 *
15325 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
15326 * the License. A copy of the License is located at
15327 *
15328 * http://aws.amazon.com/apache2.0/
15329 *
15330 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15331 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
15332 * and limitations under the License.
15333 */
15334
15335var __extends = this && this.__extends || function () {
15336 var _extendStatics = function extendStatics(d, b) {
15337 _extendStatics = Object.setPrototypeOf || {
15338 __proto__: []
15339 } instanceof Array && function (d, b) {
15340 d.__proto__ = b;
15341 } || function (d, b) {
15342 for (var p in b) {
15343 if (b.hasOwnProperty(p)) d[p] = b[p];
15344 }
15345 };
15346
15347 return _extendStatics(d, b);
15348 };
15349
15350 return function (d, b) {
15351 _extendStatics(d, b);
15352
15353 function __() {
15354 this.constructor = d;
15355 }
15356
15357 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15358 };
15359}();
15360
15361var __importStar = this && this.__importStar || function (mod) {
15362 if (mod && mod.__esModule) return mod;
15363 var result = {};
15364 if (mod != null) for (var k in mod) {
15365 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15366 }
15367 result["default"] = mod;
15368 return result;
15369};
15370
15371var __importDefault = this && this.__importDefault || function (mod) {
15372 return mod && mod.__esModule ? mod : {
15373 "default": mod
15374 };
15375};
15376
15377Object.defineProperty(exports, "__esModule", {
15378 value: true
15379});
15380
15381var React = __importStar(__webpack_require__(/*! react */ "react"));
15382
15383var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
15384
15385var auth_1 = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
15386
15387var Amplify_UI_Theme_1 = __importDefault(__webpack_require__(/*! ../Amplify-UI/Amplify-UI-Theme */ "./lib/Amplify-UI/Amplify-UI-Theme.js"));
15388
15389var Amplify_UI_Components_React_1 = __webpack_require__(/*! ../Amplify-UI/Amplify-UI-Components-React */ "./lib/Amplify-UI/Amplify-UI-Components-React.js");
15390
15391var ui_1 = __webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui");
15392
15393var qrcode_react_1 = __importDefault(__webpack_require__(/*! qrcode.react */ "../../node_modules/qrcode.react/lib/index.js"));
15394
15395var logger = new core_1.ConsoleLogger('TOTPSetupComp');
15396
15397var TOTPSetupComp =
15398/** @class */
15399function (_super) {
15400 __extends(TOTPSetupComp, _super);
15401
15402 function TOTPSetupComp(props) {
15403 var _this = _super.call(this, props) || this;
15404
15405 _this.setup = _this.setup.bind(_this);
15406 _this.showSecretCode = _this.showSecretCode.bind(_this);
15407 _this.verifyTotpToken = _this.verifyTotpToken.bind(_this);
15408 _this.handleInputChange = _this.handleInputChange.bind(_this);
15409 _this.triggerTOTPEvent = _this.triggerTOTPEvent.bind(_this);
15410 _this.state = {
15411 code: null,
15412 setupMessage: null
15413 };
15414 return _this;
15415 }
15416
15417 TOTPSetupComp.prototype.componentDidMount = function () {
15418 this.setup();
15419 };
15420
15421 TOTPSetupComp.prototype.triggerTOTPEvent = function (event, data, user) {
15422 if (this.props.onTOTPEvent) {
15423 this.props.onTOTPEvent(event, data, user);
15424 }
15425 };
15426
15427 TOTPSetupComp.prototype.handleInputChange = function (evt) {
15428 this.setState({
15429 setupMessage: null
15430 });
15431 this.inputs = {};
15432 var _a = evt.target,
15433 name = _a.name,
15434 value = _a.value,
15435 type = _a.type,
15436 checked = _a.checked; // @ts-ignore
15437
15438 var check_type = ['radio', 'checkbox'].includes(type);
15439 this.inputs[name] = check_type ? checked : value;
15440 };
15441
15442 TOTPSetupComp.prototype.setup = function () {
15443 var _this = this;
15444
15445 this.setState({
15446 setupMessage: null
15447 });
15448 var user = this.props.authData;
15449 var issuer = encodeURI(core_1.I18n.get('AWSCognito'));
15450
15451 if (!auth_1.Auth || typeof auth_1.Auth.setupTOTP !== 'function') {
15452 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
15453 }
15454
15455 auth_1.Auth.setupTOTP(user).then(function (data) {
15456 logger.debug('secret key', data);
15457 var code = 'otpauth://totp/' + issuer + ':' + user.username + '?secret=' + data + '&issuer=' + issuer;
15458
15459 _this.setState({
15460 code: code
15461 });
15462 })["catch"](function (err) {
15463 return logger.debug('totp setup failed', err);
15464 });
15465 };
15466
15467 TOTPSetupComp.prototype.verifyTotpToken = function () {
15468 var _this = this;
15469
15470 if (!this.inputs) {
15471 logger.debug('no input');
15472 return;
15473 }
15474
15475 var user = this.props.authData;
15476 var totpCode = this.inputs.totpCode;
15477
15478 if (!auth_1.Auth || typeof auth_1.Auth.verifyTotpToken !== 'function' || typeof auth_1.Auth.setPreferredMFA !== 'function') {
15479 throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
15480 }
15481
15482 return auth_1.Auth.verifyTotpToken(user, totpCode).then(function () {
15483 // set it to preferred mfa
15484 return auth_1.Auth.setPreferredMFA(user, 'TOTP').then(function () {
15485 _this.setState({
15486 setupMessage: 'Setup TOTP successfully!'
15487 });
15488
15489 logger.debug('set up totp success!');
15490
15491 _this.triggerTOTPEvent('Setup TOTP', 'SUCCESS', user);
15492 })["catch"](function (err) {
15493 _this.setState({
15494 setupMessage: 'Setup TOTP failed!'
15495 });
15496
15497 logger.error(err);
15498 });
15499 })["catch"](function (err) {
15500 _this.setState({
15501 setupMessage: 'Setup TOTP failed!'
15502 });
15503
15504 logger.error(err);
15505 });
15506 };
15507
15508 TOTPSetupComp.prototype.showSecretCode = function (code, theme) {
15509 if (!code) return null;
15510 return React.createElement("div", null, React.createElement("div", {
15511 className: ui_1.totpQrcode
15512 }, React.createElement(qrcode_react_1["default"], {
15513 value: code
15514 })), React.createElement(Amplify_UI_Components_React_1.InputLabel, {
15515 theme: theme
15516 }, core_1.I18n.get('Enter Security Code:')), React.createElement(Amplify_UI_Components_React_1.Input, {
15517 autoFocus: true,
15518 theme: theme,
15519 key: "totpCode",
15520 name: "totpCode",
15521 onChange: this.handleInputChange
15522 }));
15523 };
15524
15525 TOTPSetupComp.prototype.render = function () {
15526 var theme = this.props.theme ? this.props.theme : Amplify_UI_Theme_1["default"];
15527 var code = this.state.code;
15528 return React.createElement(Amplify_UI_Components_React_1.FormSection, {
15529 theme: theme
15530 }, this.state.setupMessage && React.createElement(Amplify_UI_Components_React_1.Toast, null, core_1.I18n.get(this.state.setupMessage)), React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
15531 theme: theme
15532 }, core_1.I18n.get('Scan then enter verification code')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
15533 theme: theme
15534 }, this.showSecretCode(code, theme), this.state.setupMessage && core_1.I18n.get(this.state.setupMessage)), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
15535 theme: theme
15536 }, React.createElement(Amplify_UI_Components_React_1.Button, {
15537 theme: theme,
15538 onClick: this.verifyTotpToken,
15539 style: {
15540 width: '100%'
15541 }
15542 }, core_1.I18n.get('Verify Security Token'))));
15543 };
15544
15545 return TOTPSetupComp;
15546}(React.Component);
15547
15548exports.TOTPSetupComp = TOTPSetupComp;
15549/**
15550 * @deprecated use named import
15551 */
15552
15553exports["default"] = TOTPSetupComp;
15554
15555/***/ }),
15556
15557/***/ "./lib/Widget/TextPicker.js":
15558/*!**********************************!*\
15559 !*** ./lib/Widget/TextPicker.js ***!
15560 \**********************************/
15561/*! no static exports found */
15562/***/ (function(module, exports, __webpack_require__) {
15563
15564"use strict";
15565
15566/*
15567 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
15568 *
15569 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
15570 * the License. A copy of the License is located at
15571 *
15572 * http://aws.amazon.com/apache2.0/
15573 *
15574 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15575 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
15576 * and limitations under the License.
15577 */
15578
15579var __extends = this && this.__extends || function () {
15580 var _extendStatics = function extendStatics(d, b) {
15581 _extendStatics = Object.setPrototypeOf || {
15582 __proto__: []
15583 } instanceof Array && function (d, b) {
15584 d.__proto__ = b;
15585 } || function (d, b) {
15586 for (var p in b) {
15587 if (b.hasOwnProperty(p)) d[p] = b[p];
15588 }
15589 };
15590
15591 return _extendStatics(d, b);
15592 };
15593
15594 return function (d, b) {
15595 _extendStatics(d, b);
15596
15597 function __() {
15598 this.constructor = d;
15599 }
15600
15601 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15602 };
15603}();
15604
15605var __importStar = this && this.__importStar || function (mod) {
15606 if (mod && mod.__esModule) return mod;
15607 var result = {};
15608 if (mod != null) for (var k in mod) {
15609 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15610 }
15611 result["default"] = mod;
15612 return result;
15613};
15614
15615var __importDefault = this && this.__importDefault || function (mod) {
15616 return mod && mod.__esModule ? mod : {
15617 "default": mod
15618 };
15619};
15620
15621Object.defineProperty(exports, "__esModule", {
15622 value: true
15623});
15624
15625var React = __importStar(__webpack_require__(/*! react */ "react"));
15626
15627var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
15628
15629var AmplifyTheme_1 = __importDefault(__webpack_require__(/*! ../AmplifyTheme */ "./lib/AmplifyTheme.js"));
15630
15631var Picker_1 = __webpack_require__(/*! ./Picker */ "./lib/Widget/Picker.js");
15632
15633var Container = {};
15634var PickerPreview = {
15635 maxWidth: '100%'
15636};
15637var logger = new core_1.ConsoleLogger('TextPicker');
15638
15639var TextPicker =
15640/** @class */
15641function (_super) {
15642 __extends(TextPicker, _super);
15643
15644 function TextPicker(props) {
15645 var _this = _super.call(this, props) || this;
15646
15647 _this.handlePick = _this.handlePick.bind(_this);
15648 _this.state = {
15649 previewText: props.previewText
15650 };
15651 return _this;
15652 }
15653
15654 TextPicker.prototype.handlePick = function (data) {
15655 var that = this;
15656 var file = data.file,
15657 name = data.name,
15658 size = data.size,
15659 type = data.type;
15660 var _a = this.props,
15661 preview = _a.preview,
15662 onPick = _a.onPick,
15663 onLoad = _a.onLoad;
15664
15665 if (onPick) {
15666 onPick(data);
15667 }
15668
15669 if (preview) {
15670 var reader = new FileReader();
15671
15672 reader.onload = function (e) {
15673 var text = e.target.result; // @ts-ignore
15674
15675 that.setState({
15676 previewText: text
15677 });
15678
15679 if (onLoad) {
15680 onLoad(text);
15681 }
15682 };
15683
15684 reader.readAsText(file);
15685 }
15686 };
15687
15688 TextPicker.prototype.render = function () {
15689 var preview = this.props.preview;
15690 var previewText = this.state.previewText;
15691 var title = this.props.title || 'Pick a File';
15692 var theme = this.props.theme || AmplifyTheme_1["default"];
15693 var containerStyle = Object.assign({}, Container, theme.picker);
15694 var previewStyle = Object.assign({}, PickerPreview, theme.pickerPreview, theme.halfHeight, preview && preview !== 'hidden' ? {} : AmplifyTheme_1["default"].hidden);
15695 return React.createElement("div", {
15696 style: containerStyle
15697 }, previewText ? React.createElement("div", {
15698 style: previewStyle
15699 }, React.createElement("pre", {
15700 style: theme.pre
15701 }, previewText)) : null, React.createElement(Picker_1.Picker, {
15702 title: title,
15703 accept: "text/*",
15704 theme: theme,
15705 onPick: this.handlePick
15706 }));
15707 };
15708
15709 return TextPicker;
15710}(React.Component);
15711
15712exports.TextPicker = TextPicker;
15713/**
15714 * @deprecated use named import
15715 */
15716
15717exports["default"] = TextPicker;
15718
15719/***/ }),
15720
15721/***/ "./lib/Widget/index.js":
15722/*!*****************************!*\
15723 !*** ./lib/Widget/index.js ***!
15724 \*****************************/
15725/*! no static exports found */
15726/***/ (function(module, exports, __webpack_require__) {
15727
15728"use strict";
15729
15730
15731Object.defineProperty(exports, "__esModule", {
15732 value: true
15733});
15734
15735var Picker_1 = __webpack_require__(/*! ./Picker */ "./lib/Widget/Picker.js");
15736
15737exports.Picker = Picker_1.Picker;
15738
15739var PhotoPicker_1 = __webpack_require__(/*! ./PhotoPicker */ "./lib/Widget/PhotoPicker.js");
15740
15741exports.PhotoPicker = PhotoPicker_1.PhotoPicker;
15742
15743var TextPicker_1 = __webpack_require__(/*! ./TextPicker */ "./lib/Widget/TextPicker.js");
15744
15745exports.TextPicker = TextPicker_1.TextPicker;
15746
15747var SelectMFAType_1 = __webpack_require__(/*! ./SelectMFAType */ "./lib/Widget/SelectMFAType.js");
15748
15749exports.SelectMFAType = SelectMFAType_1.SelectMFAType;
15750
15751var TOTPSetupComp_1 = __webpack_require__(/*! ./TOTPSetupComp */ "./lib/Widget/TOTPSetupComp.js");
15752
15753exports.TOTPSetupComp = TOTPSetupComp_1.TOTPSetupComp;
15754
15755/***/ }),
15756
15757/***/ "./lib/XR/IconButton.js":
15758/*!******************************!*\
15759 !*** ./lib/XR/IconButton.js ***!
15760 \******************************/
15761/*! no static exports found */
15762/***/ (function(module, exports, __webpack_require__) {
15763
15764"use strict";
15765
15766
15767var __importStar = this && this.__importStar || function (mod) {
15768 if (mod && mod.__esModule) return mod;
15769 var result = {};
15770 if (mod != null) for (var k in mod) {
15771 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15772 }
15773 result["default"] = mod;
15774 return result;
15775};
15776
15777var __importDefault = this && this.__importDefault || function (mod) {
15778 return mod && mod.__esModule ? mod : {
15779 "default": mod
15780 };
15781};
15782
15783Object.defineProperty(exports, "__esModule", {
15784 value: true
15785});
15786/*
15787 * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
15788 *
15789 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
15790 * the License. A copy of the License is located at
15791 *
15792 * http://aws.amazon.com/apache2.0/
15793 *
15794 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15795 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
15796 * and limitations under the License.
15797 */
15798
15799var React = __importStar(__webpack_require__(/*! react */ "react"));
15800
15801var Tooltip_1 = __importDefault(__webpack_require__(/*! ./Tooltip */ "./lib/XR/Tooltip.js"));
15802
15803var AmplifyUI = __importStar(__webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui"));
15804
15805exports.IconButton = function (props) {
15806 var buttonIcon;
15807
15808 switch (props.variant) {
15809 case 'sound-mute':
15810 buttonIcon = React.createElement("svg", {
15811 width: "19",
15812 height: "19",
15813 viewBox: "0 0 19 19",
15814 xmlns: "http://www.w3.org/2000/svg"
15815 }, React.createElement("g", {
15816 id: "icons/minis/volumeOff",
15817 fill: "none",
15818 fillRule: "evenodd"
15819 }, React.createElement("path", {
15820 d: "M3.48026899,12.9630494 C3.63825091,12.9630494 3.79237961,13.0108921 3.92264322,13.1003479 L8.77467683,16.8113609 C9.29423971,17.1679383 10,16.7950396 10,16.1637406 L10,3.78619489 C10,3.15489596 9.29423971,2.78199725 8.77467683,3.13857463 L3.92264322,6.84545211 C3.79237961,6.93490793 3.63825091,6.9827506 3.48026899,6.9827506 L1.78294894,6.9827506 C1.3505185,6.9827506 1,7.33409518 1,7.76754476 L1,12.1781306 C1,12.6117048 1.3505185,12.9630494 1.78294894,12.9630494 L3.48026899,12.9630494 Z M17.2118156,7 L15.0918385,9.11997713 L12.9718614,7 L12,7.97174685 L14.1200917,10.091724 L12,12.2118156 L12.9718614,13.1835625 L15.0918385,11.0635854 L17.2118156,13.1835625 L18.1835625,12.2118156 L16.0635854,10.091724 L18.1835625,7.97174685 L17.2118156,7 Z",
15821 id: "Fill-2",
15822 fill: "#FFF"
15823 })));
15824 break;
15825
15826 case 'sound':
15827 buttonIcon = React.createElement("svg", {
15828 width: "19",
15829 height: "19",
15830 viewBox: "0 0 19 19",
15831 xmlns: "http://www.w3.org/2000/svg"
15832 }, React.createElement("g", {
15833 id: "icons/minis/volumeOn",
15834 fill: "none",
15835 fillRule: "evenodd"
15836 }, React.createElement("path", {
15837 d: "M3.48026899,12.9630494 L1.78294894,12.9630494 C1.3505185,12.9630494 1,12.6117048 1,12.1781306 L1,7.76754476 C1,7.33409518 1.3505185,6.9827506 1.78294894,6.9827506 L3.48026899,6.9827506 C3.63825091,6.9827506 3.79237961,6.93490793 3.92264322,6.84545211 L8.77467683,3.13857463 C9.29423971,2.78199725 10,3.15489596 10,3.78619489 L10,16.1637406 C10,16.7950396 9.29423971,17.1679383 8.77467683,16.8113609 L3.92264322,13.1003479 C3.79237961,13.0108921 3.63825091,12.9630494 3.48026899,12.9630494 Z M14.9270376,3.03232286 C15.1729267,3.03232286 15.4040399,3.12815658 15.5777627,3.3022351 C17.3699891,5.09889099 18.3570052,7.48235058 18.3570052,10.0135053 C18.3570052,12.54466 17.3699891,14.9281196 15.5777627,16.7247755 C15.4041045,16.898854 15.1729914,16.9947524 14.9270052,16.9947524 C14.6820861,16.9947524 14.4515549,16.899436 14.2777674,16.7263598 C13.9192316,16.3684383 13.9185203,15.7852882 14.2762477,15.4264291 C15.7222893,13.9769926 16.5186727,12.0545954 16.5186727,10.0135053 C16.5186727,7.97241524 15.7222893,6.05001801 14.2762154,4.60058152 C13.9184879,4.24175473 13.9191992,3.65857229 14.277832,3.30065081 C14.4514256,3.1275746 14.6819567,3.03232286 14.9270376,3.03232286 Z M13.5730665,6.11570485 C14.6133991,7.15574642 15.1862998,8.54003279 15.1862998,10.0134924 C15.1862998,11.4892799 14.6113945,12.8741159 13.5675376,13.9128965 C13.3942351,14.0855848 13.1639626,14.1806425 12.9191727,14.1806425 C12.6727016,14.1806425 12.4412975,14.0844531 12.2677039,13.9097926 C12.0944984,13.7358111 11.9994406,13.5047303 11.9999903,13.2592291 C12.0005723,13.0136956 12.096794,12.7831644 12.2708079,12.6100882 C12.9654406,11.9185917 13.3479995,10.996467 13.3479995,10.0134924 C13.3479995,9.03119677 12.966346,8.1086194 12.2733298,7.4157649 C11.9150203,7.05745543 11.9149233,6.47436998 12.2731358,6.11589885 C12.4467617,5.94224065 12.6775838,5.84666559 12.923085,5.84666559 C13.1685538,5.84666559 13.3993436,5.94220831 13.5730665,6.11570485 Z",
15838 id: "Fill-2",
15839 fill: "#FFF"
15840 })));
15841 break;
15842
15843 case 'maximize':
15844 buttonIcon = React.createElement("svg", {
15845 width: "19",
15846 height: "19",
15847 viewBox: "0 0 19 19",
15848 xmlns: "http://www.w3.org/2000/svg"
15849 }, React.createElement("g", {
15850 id: "icons/minis/screenfull",
15851 fill: "none",
15852 fillRule: "evenodd"
15853 }, React.createElement("path", {
15854 d: "M2.04162598,3 L2.04162598,16 L17.0147705,16 L17.0147705,3 L2.04162598,3 Z M1,2 L18,2 L18,17 L1,17 L1,2 Z M3,4 L16,4 L16,15 L3,15 L3,4 Z",
15855 id: "Rectangle-Copy",
15856 fill: "#FFF",
15857 fillRule: "nonzero"
15858 })));
15859 break;
15860
15861 case 'minimize':
15862 buttonIcon = React.createElement("svg", {
15863 width: "19",
15864 height: "19",
15865 viewBox: "0 0 19 19",
15866 xmlns: "http://www.w3.org/2000/svg"
15867 }, React.createElement("g", {
15868 id: "icons/minis/screensmall",
15869 fill: "none",
15870 fillRule: "evenodd"
15871 }, React.createElement("path", {
15872 d: "M11,16 L17.0147705,16 L17.0147705,3 L2.04162598,3 L2.04162598,10 L11,10 L11,16 Z M1,2 L18,2 L18,17 L1,17 L1,2 Z",
15873 id: "Rectangle",
15874 fill: "#FFF",
15875 fillRule: "nonzero"
15876 })));
15877 break;
15878
15879 case 'enter-vr':
15880 buttonIcon = React.createElement("svg", {
15881 width: "19",
15882 height: "19",
15883 viewBox: "0 0 17 10",
15884 xmlns: "http://www.w3.org/2000/svg"
15885 }, React.createElement("g", {
15886 id: "Page-1",
15887 fill: "none",
15888 fillRule: "evenodd"
15889 }, React.createElement("g", {
15890 id: "VRon",
15891 fill: "#FFF",
15892 fillRule: "nonzero"
15893 }, React.createElement("path", {
15894 d: "M15.7856977,0.02395184 L15.8915734,0.02395184 C16.5037405,0.02395184 17,0.520211324 17,1.13237842 L17,1.54663675 L17,8.8915038 C17,9.5034193 16.4560011,10 15.7856977,10 L12.0095825,10 C9.98324439,7.1593807 8.80676009,5.741338 8.48012959,5.74587199 C8.16206045,5.75028714 7.01003321,7.1683298 5.02404785,10 L1.21426911,10 C0.543965735,10 3.32031236e-05,9.5034193 3.32031236e-05,8.8915038 L3.32031236e-05,1.54663675 L3.32031236e-05,1.13237842 L3.32031236e-05,1.13237842 C3.32031236e-05,0.520211324 0.496292687,0.02395184 1.10845978,0.02395184 L1.21426911,0.02395184 L15.7856977,0.02395184 Z M4.5,6 C5.32842712,6 6,5.32842712 6,4.5 C6,3.67157288 5.32842712,3 4.5,3 C3.67157288,3 3,3.67157288 3,4.5 C3,5.32842712 3.67157288,6 4.5,6 Z M12.5,6 C13.3284271,6 14,5.32842712 14,4.5 C14,3.67157288 13.3284271,3 12.5,3 C11.6715729,3 11,3.67157288 11,4.5 C11,5.32842712 11.6715729,6 12.5,6 Z",
15895 id: "Fill-1"
15896 }))));
15897 break;
15898
15899 case 'exit-vr':
15900 buttonIcon = React.createElement("svg", {
15901 width: "19",
15902 height: "19",
15903 viewBox: "0 0 19 19",
15904 xmlns: "http://www.w3.org/2000/svg"
15905 }, React.createElement("g", {
15906 id: "icons/minis/VRon-Copy",
15907 fill: "none",
15908 fillRule: "evenodd"
15909 }, React.createElement("g", {
15910 id: "Group-7-Copy",
15911 transform: "translate(1 3)",
15912 fill: "#FFF"
15913 }, React.createElement("path", {
15914 d: "M15.7856977,3.02395184 L17,3.02395184 L17,4.13237842 L17,4.54663675 L17,11.8915038 C17,12.5034193 16.4560011,13 15.7856977,13 L12.0095825,13 C9.98324439,10.1593807 8.80676009,8.741338 8.48012959,8.74587199 C8.16206045,8.75028714 7.01003321,10.1683298 5.02404785,13 L1.21426911,13 C0.543965735,13 3.32031236e-05,12.5034193 3.32031236e-05,11.8915038 L3.32031236e-05,4.54663675 L3.32031236e-05,4.13237842 L3.32031236e-05,3.02395184 L1.21426911,3.02395184 L15.7856977,3.02395184 Z M4.5,9 C5.32842712,9 6,8.32842712 6,7.5 C6,6.67157288 5.32842712,6 4.5,6 C3.67157288,6 3,6.67157288 3,7.5 C3,8.32842712 3.67157288,9 4.5,9 Z M12.5,9 C13.3284271,9 14,8.32842712 14,7.5 C14,6.67157288 13.3284271,6 12.5,6 C11.6715729,6 11,6.67157288 11,7.5 C11,8.32842712 11.6715729,9 12.5,9 Z M2.5486669,0 L14.420089,0 C14.7977406,0 15.1613805,0.149260956 15.4374308,0.417695511 L16.9999668,2.00634766 L0,2.00634766 L1.58537972,0.395493117 C1.84682061,0.141306827 2.19106994,0 2.5486669,0 Z",
15915 id: "Fill-1"
15916 }))));
15917 break;
15918
15919 default:
15920 buttonIcon = null;
15921 break;
15922 }
15923
15924 return React.createElement(Tooltip_1["default"], {
15925 text: props.tooltip,
15926 autoShowTooltip: props.autoShowTooltip
15927 }, React.createElement("button", {
15928 className: AmplifyUI.actionButton,
15929 onClick: props.onClick
15930 }, buttonIcon));
15931};
15932/**
15933 * @deprecated use named import
15934 */
15935
15936
15937exports["default"] = exports.IconButton;
15938
15939/***/ }),
15940
15941/***/ "./lib/XR/Loading.js":
15942/*!***************************!*\
15943 !*** ./lib/XR/Loading.js ***!
15944 \***************************/
15945/*! no static exports found */
15946/***/ (function(module, exports, __webpack_require__) {
15947
15948"use strict";
15949
15950
15951var __importStar = this && this.__importStar || function (mod) {
15952 if (mod && mod.__esModule) return mod;
15953 var result = {};
15954 if (mod != null) for (var k in mod) {
15955 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15956 }
15957 result["default"] = mod;
15958 return result;
15959};
15960
15961Object.defineProperty(exports, "__esModule", {
15962 value: true
15963});
15964/*
15965 * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
15966 *
15967 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
15968 * the License. A copy of the License is located at
15969 *
15970 * http://aws.amazon.com/apache2.0/
15971 *
15972 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15973 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
15974 * and limitations under the License.
15975 */
15976
15977var React = __importStar(__webpack_require__(/*! react */ "react"));
15978
15979var AmplifyUI = __importStar(__webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui"));
15980
15981var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
15982
15983exports.Loading = function (props) {
15984 return React.createElement("div", {
15985 className: AmplifyUI.loadingOverlay,
15986 "data-test": data_test_attributes_1.sumerianScene.loading
15987 }, React.createElement("div", {
15988 className: AmplifyUI.loadingContainer
15989 }, React.createElement("div", {
15990 className: AmplifyUI.loadingLogo,
15991 "data-test": data_test_attributes_1.sumerianScene.loadingLogo
15992 }, React.createElement("svg", {
15993 viewBox: "0 0 800 481",
15994 xmlns: "http://www.w3.org/2000/svg"
15995 }, React.createElement("g", {
15996 id: "Page-1",
15997 fillRule: "evenodd"
15998 }, React.createElement("g", {
15999 id: "AWS_logo_RGB-(1)",
16000 transform: "translate(-16 -17)",
16001 fillRule: "nonzero"
16002 }, React.createElement("path", {
16003 d: "M241.371,190.172 C241.371,197.487 241.371,204.801 245.028,212.115 C245.028,219.43 248.685,226.744 252.343,234.058 C252.343,234.058 252.343,237.715 256,241.373 C256,245.03 252.343,248.688 252.343,248.688 L234.058,256.002 C230.401,256.002 230.401,259.659 226.743,259.659 C223.085,259.659 219.428,259.659 219.428,256.002 C219.428,252.345 212.113,248.687 208.457,245.031 C208.457,237.716 204.8,234.06 201.142,226.745 C182.856,248.688 153.599,263.317 124.342,263.317 C106.057,263.317 84.114,256.002 69.485,245.031 C54.856,230.402 51.2,212.116 51.2,193.831 C51.2,171.888 58.515,153.603 73.143,138.974 C91.428,124.345 113.371,117.031 138.972,117.031 C149.943,117.031 157.258,117.031 168.229,120.688 C179.2,120.688 186.515,124.345 197.486,128.003 L197.486,106.06 C197.486,91.431 193.829,76.803 186.515,62.174 C171.886,54.859 157.258,51.203 142.629,51.203 C131.658,51.203 124.344,51.203 113.372,54.86 C102.4,58.517 95.087,62.175 84.115,65.832 C80.458,65.832 76.801,69.489 73.143,69.489 L69.486,69.489 C65.829,69.489 62.171,65.832 62.171,62.174 L62.171,47.545 C62.171,43.888 62.171,40.23 65.828,36.574 C69.485,36.574 73.142,32.917 73.142,32.917 C84.114,29.26 95.085,25.603 109.714,21.946 C124.343,18.289 138.971,18.289 149.942,18.289 C175.542,14.632 201.142,21.946 219.428,36.574 C234.057,54.859 245.028,76.802 241.371,102.403 L241.371,190.175 L241.371,190.172 Z M131.657,230.4 C142.628,230.4 149.942,230.4 160.914,226.743 C171.886,223.086 179.199,215.772 186.514,208.457 C190.171,204.8 193.829,197.486 193.829,193.828 C197.486,182.857 197.486,175.543 197.486,168.228 L197.486,157.257 C190.171,157.257 182.857,153.6 171.886,153.6 C164.571,153.6 153.6,153.6 146.286,153.6 C135.315,149.943 120.686,153.6 109.714,160.915 C98.742,168.23 95.085,179.2 95.085,190.172 C95.085,201.143 98.742,212.115 106.057,219.429 C113.372,226.743 124.342,230.4 131.657,230.4 Z M347.428,259.657 C343.771,259.657 340.113,259.657 336.457,256 C332.801,252.343 332.8,248.685 332.8,245.029 L270.629,40.229 C270.629,36.572 266.972,32.914 266.972,29.258 C266.972,29.258 266.972,25.601 266.972,25.601 C266.972,25.601 270.629,21.944 270.629,25.601 L296.229,25.601 C299.886,25.601 303.544,25.601 307.2,29.258 C310.857,29.258 314.515,32.915 314.515,36.573 L358.4,212.116 L402.285,36.573 C402.285,32.916 405.942,29.259 405.942,25.602 C409.599,21.945 413.257,21.945 416.913,21.945 L438.856,21.945 C442.513,21.945 446.171,21.945 449.827,25.602 C453.483,29.259 453.484,32.917 453.484,36.573 L493.712,215.773 L541.255,36.573 C541.255,32.916 544.912,29.259 544.912,25.602 C548.569,21.945 552.226,21.945 555.883,21.945 L581.483,21.945 C581.483,21.945 585.14,21.945 585.14,21.945 C585.14,21.945 588.797,25.602 585.14,25.602 C585.14,25.602 585.14,29.259 585.14,29.259 C585.14,32.916 585.14,32.916 581.483,36.573 L515.655,241.373 C515.655,245.03 511.998,248.688 508.34,252.344 C504.682,256 501.025,256.001 497.369,256.001 L475.426,256.001 C471.769,256.001 468.111,256.001 464.455,252.344 C460.799,248.687 460.798,245.029 460.798,241.373 L427.884,73.145 L387.656,245.031 C387.656,248.688 383.999,252.346 383.999,256.002 C380.342,259.659 376.684,259.659 373.028,259.659 L347.428,259.659 L347.428,259.657 Z M687.543,266.971 C672.914,266.971 658.286,266.971 647.314,263.314 C636.342,259.657 625.371,255.999 618.057,252.343 C610.743,248.686 607.086,245.028 607.086,237.714 L607.086,223.085 C607.086,215.77 610.743,215.77 614.4,215.77 C614.4,215.77 618.057,215.77 618.057,215.77 L625.371,219.427 C636.342,223.084 643.656,226.742 654.628,230.398 C665.6,234.054 676.571,234.055 687.542,234.055 C702.171,234.055 713.142,230.398 727.771,226.74 C735.085,223.083 742.4,212.111 742.4,201.14 C742.4,193.825 738.743,186.511 735.086,182.855 C727.772,175.54 716.801,171.884 705.829,168.226 L665.6,157.255 C650.971,153.598 636.343,142.626 625.372,131.655 C618.058,120.683 610.743,106.055 610.743,91.427 C610.743,80.455 614.4,69.484 618.057,62.17 C621.714,54.856 629.028,47.541 636.342,40.227 C643.656,32.912 654.627,29.256 661.942,25.598 C672.913,21.941 683.885,21.941 694.856,21.941 C702.17,21.941 705.827,21.941 713.141,21.941 C720.455,21.941 724.112,21.941 731.426,25.598 C735.083,25.598 742.397,29.255 746.055,29.255 C749.713,29.255 753.369,32.912 757.026,32.912 C760.683,32.912 764.34,36.569 764.34,40.227 C767.997,36.57 767.997,40.227 767.997,43.884 L767.997,54.855 C767.997,62.17 764.34,62.17 760.683,62.17 C757.026,62.17 753.369,62.17 749.712,58.513 C735.083,51.198 716.798,47.542 698.512,47.542 C687.541,47.542 672.912,51.199 661.94,54.857 C658.283,65.829 654.626,73.142 654.626,84.114 C654.626,91.428 658.283,98.743 661.94,102.399 C669.254,109.713 680.225,113.371 691.197,117.028 L727.769,128 C742.398,131.657 757.026,142.629 767.997,153.6 C775.311,164.571 782.626,179.2 778.968,193.828 C778.968,204.799 775.311,215.771 771.654,223.085 C767.997,234.056 760.683,241.37 753.369,245.028 C746.055,252.343 735.084,255.999 724.112,259.656 C713.14,263.313 702.169,266.971 687.54,266.971 L687.543,266.971 Z",
16004 id: "Shape"
16005 }), React.createElement("path", {
16006 d: "M738.743,398.628 C650.972,464.457 522.972,497.371 416.914,497.371 C270.628,497.371 128,446.171 21.943,347.428 C10.971,336.457 18.286,329.142 29.257,332.8 C149.943,402.286 285.257,438.857 424.228,438.857 C526.628,438.857 629.028,416.914 727.771,376.686 C742.4,369.371 753.371,387.657 738.742,398.629 L738.743,398.628 Z",
16007 id: "Shape"
16008 }), React.createElement("path", {
16009 d: "M775.314,354.743 C764.343,340.115 702.171,347.428 672.914,351.086 C665.6,351.086 661.943,343.771 669.257,340.115 C720.457,303.543 800.914,314.515 811.886,325.487 C822.858,336.459 808.229,420.572 760.686,460.802 C753.372,468.117 746.057,464.459 749.715,457.145 C764.344,427.888 786.287,369.373 775.315,354.745 L775.314,354.743 Z",
16010 id: "Shape"
16011 }))))), React.createElement("div", {
16012 className: AmplifyUI.loadingSceneName,
16013 "data-test": data_test_attributes_1.sumerianScene.loadingSceneName
16014 }, props.sceneName), props.sceneError ? React.createElement("div", {
16015 className: AmplifyUI.sceneErrorText,
16016 "data-test": data_test_attributes_1.sumerianScene.errorText
16017 }, props.sceneError.displayText) : React.createElement("div", {
16018 className: AmplifyUI.loadingBar,
16019 "data-test": data_test_attributes_1.sumerianScene.loadingBar
16020 }, React.createElement("div", {
16021 className: AmplifyUI.loadingBarFill,
16022 style: {
16023 width: props.percentage + "%"
16024 }
16025 }))));
16026};
16027/**
16028 * @deprecated use named import
16029 */
16030
16031
16032exports["default"] = exports.Loading;
16033
16034/***/ }),
16035
16036/***/ "./lib/XR/SumerianScene.js":
16037/*!*********************************!*\
16038 !*** ./lib/XR/SumerianScene.js ***!
16039 \*********************************/
16040/*! no static exports found */
16041/***/ (function(module, exports, __webpack_require__) {
16042
16043"use strict";
16044
16045
16046var __extends = this && this.__extends || function () {
16047 var _extendStatics = function extendStatics(d, b) {
16048 _extendStatics = Object.setPrototypeOf || {
16049 __proto__: []
16050 } instanceof Array && function (d, b) {
16051 d.__proto__ = b;
16052 } || function (d, b) {
16053 for (var p in b) {
16054 if (b.hasOwnProperty(p)) d[p] = b[p];
16055 }
16056 };
16057
16058 return _extendStatics(d, b);
16059 };
16060
16061 return function (d, b) {
16062 _extendStatics(d, b);
16063
16064 function __() {
16065 this.constructor = d;
16066 }
16067
16068 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16069 };
16070}();
16071
16072var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
16073 function adopt(value) {
16074 return value instanceof P ? value : new P(function (resolve) {
16075 resolve(value);
16076 });
16077 }
16078
16079 return new (P || (P = Promise))(function (resolve, reject) {
16080 function fulfilled(value) {
16081 try {
16082 step(generator.next(value));
16083 } catch (e) {
16084 reject(e);
16085 }
16086 }
16087
16088 function rejected(value) {
16089 try {
16090 step(generator["throw"](value));
16091 } catch (e) {
16092 reject(e);
16093 }
16094 }
16095
16096 function step(result) {
16097 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
16098 }
16099
16100 step((generator = generator.apply(thisArg, _arguments || [])).next());
16101 });
16102};
16103
16104var __generator = this && this.__generator || function (thisArg, body) {
16105 var _ = {
16106 label: 0,
16107 sent: function sent() {
16108 if (t[0] & 1) throw t[1];
16109 return t[1];
16110 },
16111 trys: [],
16112 ops: []
16113 },
16114 f,
16115 y,
16116 t,
16117 g;
16118 return g = {
16119 next: verb(0),
16120 "throw": verb(1),
16121 "return": verb(2)
16122 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
16123 return this;
16124 }), g;
16125
16126 function verb(n) {
16127 return function (v) {
16128 return step([n, v]);
16129 };
16130 }
16131
16132 function step(op) {
16133 if (f) throw new TypeError("Generator is already executing.");
16134
16135 while (_) {
16136 try {
16137 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;
16138 if (y = 0, t) op = [op[0] & 2, t.value];
16139
16140 switch (op[0]) {
16141 case 0:
16142 case 1:
16143 t = op;
16144 break;
16145
16146 case 4:
16147 _.label++;
16148 return {
16149 value: op[1],
16150 done: false
16151 };
16152
16153 case 5:
16154 _.label++;
16155 y = op[1];
16156 op = [0];
16157 continue;
16158
16159 case 7:
16160 op = _.ops.pop();
16161
16162 _.trys.pop();
16163
16164 continue;
16165
16166 default:
16167 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
16168 _ = 0;
16169 continue;
16170 }
16171
16172 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
16173 _.label = op[1];
16174 break;
16175 }
16176
16177 if (op[0] === 6 && _.label < t[1]) {
16178 _.label = t[1];
16179 t = op;
16180 break;
16181 }
16182
16183 if (t && _.label < t[2]) {
16184 _.label = t[2];
16185
16186 _.ops.push(op);
16187
16188 break;
16189 }
16190
16191 if (t[2]) _.ops.pop();
16192
16193 _.trys.pop();
16194
16195 continue;
16196 }
16197
16198 op = body.call(thisArg, _);
16199 } catch (e) {
16200 op = [6, e];
16201 y = 0;
16202 } finally {
16203 f = t = 0;
16204 }
16205 }
16206
16207 if (op[0] & 5) throw op[1];
16208 return {
16209 value: op[0] ? op[1] : void 0,
16210 done: true
16211 };
16212 }
16213};
16214
16215var __importStar = this && this.__importStar || function (mod) {
16216 if (mod && mod.__esModule) return mod;
16217 var result = {};
16218 if (mod != null) for (var k in mod) {
16219 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
16220 }
16221 result["default"] = mod;
16222 return result;
16223};
16224
16225Object.defineProperty(exports, "__esModule", {
16226 value: true
16227});
16228/*
16229 * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
16230 *
16231 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
16232 * the License. A copy of the License is located at
16233 *
16234 * http://aws.amazon.com/apache2.0/
16235 *
16236 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
16237 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
16238 * and limitations under the License.
16239 */
16240
16241var React = __importStar(__webpack_require__(/*! react */ "react"));
16242
16243var xr_1 = __webpack_require__(/*! @aws-amplify/xr */ "@aws-amplify/xr");
16244
16245var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
16246
16247var IconButton_1 = __webpack_require__(/*! ./IconButton */ "./lib/XR/IconButton.js");
16248
16249var Loading_1 = __webpack_require__(/*! ./Loading */ "./lib/XR/Loading.js");
16250
16251var AmplifyUI = __importStar(__webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui"));
16252
16253var data_test_attributes_1 = __webpack_require__(/*! ../Amplify-UI/data-test-attributes */ "./lib/Amplify-UI/data-test-attributes.js");
16254
16255var SCENE_CONTAINER_DOM_ID = 'scene-container-dom-id';
16256var SCENE_DOM_ID = 'scene-dom-id';
16257var logger = new core_1.ConsoleLogger('SumerianScene');
16258
16259var SumerianScene =
16260/** @class */
16261function (_super) {
16262 __extends(SumerianScene, _super);
16263
16264 function SumerianScene(props) {
16265 var _this = _super.call(this, props) || this;
16266
16267 _this.state = {
16268 showEnableAudio: false,
16269 muted: false,
16270 loading: true,
16271 percentage: 0,
16272 isFullscreen: false,
16273 sceneError: null,
16274 isVRPresentationActive: false
16275 };
16276 return _this;
16277 }
16278
16279 SumerianScene.prototype.setStateAsync = function (state) {
16280 var _this = this;
16281
16282 return new Promise(function (resolve) {
16283 _this.setState(state, resolve);
16284 });
16285 };
16286
16287 SumerianScene.prototype.componentDidMount = function () {
16288 document.addEventListener('fullscreenchange', this.onFullscreenChange.bind(this));
16289 document.addEventListener('webkitfullscreenchange', this.onFullscreenChange.bind(this));
16290 document.addEventListener('mozfullscreenchange', this.onFullscreenChange.bind(this));
16291 document.addEventListener('MSFullscreenChange', this.onFullscreenChange.bind(this));
16292 this.loadAndSetupScene(this.props.sceneName, SCENE_DOM_ID);
16293 };
16294
16295 SumerianScene.prototype.componentWillUnmount = function () {
16296 document.removeEventListener('fullscreenchange', this.onFullscreenChange.bind(this));
16297 document.removeEventListener('webkitfullscreenchange', this.onFullscreenChange.bind(this));
16298 document.removeEventListener('mozfullscreenchange', this.onFullscreenChange.bind(this));
16299 document.removeEventListener('MSFullscreenChange', this.onFullscreenChange.bind(this));
16300 };
16301
16302 SumerianScene.prototype.loadAndSetupScene = function (sceneName, sceneDomId) {
16303 return __awaiter(this, void 0, void 0, function () {
16304 var sceneOptions, e_1, sceneError;
16305
16306 var _this = this;
16307
16308 return __generator(this, function (_a) {
16309 switch (_a.label) {
16310 case 0:
16311 this.setStateAsync({
16312 loading: true
16313 });
16314 sceneOptions = {
16315 progressCallback: function progressCallback(progress) {
16316 var percentage = progress * 100;
16317
16318 _this.setState({
16319 percentage: percentage
16320 });
16321 }
16322 };
16323 _a.label = 1;
16324
16325 case 1:
16326 _a.trys.push([1, 3,, 4]);
16327
16328 return [4
16329 /*yield*/
16330 , xr_1.XR.loadScene(sceneName, sceneDomId, sceneOptions)];
16331
16332 case 2:
16333 _a.sent();
16334
16335 return [3
16336 /*break*/
16337 , 4];
16338
16339 case 3:
16340 e_1 = _a.sent();
16341 sceneError = {
16342 displayText: 'Failed to load scene',
16343 error: e_1
16344 };
16345 logger.error(sceneError.displayText, sceneError.error);
16346 this.setStateAsync({
16347 sceneError: sceneError
16348 });
16349 return [2
16350 /*return*/
16351 ];
16352
16353 case 4:
16354 xr_1.XR.start(sceneName);
16355 this.setStateAsync({
16356 muted: xr_1.XR.isMuted(sceneName),
16357 isVRPresentationActive: xr_1.XR.isVRPresentationActive(sceneName),
16358 loading: false
16359 });
16360 xr_1.XR.onSceneEvent(sceneName, 'AudioEnabled', function () {
16361 return _this.setStateAsync({
16362 showEnableAudio: false
16363 });
16364 });
16365 xr_1.XR.onSceneEvent(sceneName, 'AudioDisabled', function () {
16366 return _this.setStateAsync({
16367 showEnableAudio: true
16368 });
16369 });
16370 return [2
16371 /*return*/
16372 ];
16373 }
16374 });
16375 });
16376 };
16377
16378 SumerianScene.prototype.setMuted = function (muted) {
16379 if (this.state.showEnableAudio) {
16380 xr_1.XR.enableAudio(this.props.sceneName);
16381 this.setState({
16382 showEnableAudio: false
16383 });
16384 }
16385
16386 xr_1.XR.setMuted(this.props.sceneName, muted);
16387 this.setState({
16388 muted: muted
16389 });
16390 };
16391
16392 SumerianScene.prototype.onFullscreenChange = function () {
16393 var doc = document;
16394 this.setState({
16395 isFullscreen: doc.fullscreenElement !== null
16396 });
16397 };
16398
16399 SumerianScene.prototype.maximize = function () {
16400 return __awaiter(this, void 0, void 0, function () {
16401 var sceneDomElement;
16402 return __generator(this, function (_a) {
16403 switch (_a.label) {
16404 case 0:
16405 sceneDomElement = document.getElementById(SCENE_CONTAINER_DOM_ID);
16406 return [4
16407 /*yield*/
16408 , sceneDomElement.requestFullscreen()];
16409
16410 case 1:
16411 _a.sent();
16412
16413 return [2
16414 /*return*/
16415 ];
16416 }
16417 });
16418 });
16419 };
16420
16421 SumerianScene.prototype.minimize = function () {
16422 return __awaiter(this, void 0, void 0, function () {
16423 var doc;
16424 return __generator(this, function (_a) {
16425 doc = document;
16426
16427 if (doc.exitFullscreen) {
16428 doc.exitFullscreen();
16429 } else if (doc.mozCancelFullScreen) {
16430 doc.mozCancelFullScreen();
16431 } else if (doc.webkitExitFullscreen) {
16432 doc.webkitExitFullscreen();
16433 }
16434
16435 return [2
16436 /*return*/
16437 ];
16438 });
16439 });
16440 };
16441
16442 SumerianScene.prototype.toggleVRPresentation = function () {
16443 try {
16444 if (this.state.isVRPresentationActive) {
16445 xr_1.XR.exitVR(this.props.sceneName);
16446 } else {
16447 xr_1.XR.enterVR(this.props.sceneName);
16448 }
16449 } catch (e) {
16450 logger.error('Unable to start/stop WebVR System: ' + e.message);
16451 return;
16452 }
16453
16454 this.setState({
16455 isVRPresentationActive: !this.state.isVRPresentationActive
16456 });
16457 };
16458
16459 SumerianScene.prototype.render = function () {
16460 var _this = this;
16461
16462 var muteButton;
16463 var enterOrExitVRButton;
16464 var screenSizeButton;
16465
16466 if (xr_1.XR.isSceneLoaded(this.props.sceneName)) {
16467 if (this.state.showEnableAudio) {
16468 muteButton = React.createElement(IconButton_1.IconButton, {
16469 variant: "sound-mute",
16470 tooltip: "The scene is muted. Click to unmute.",
16471 onClick: function onClick() {
16472 return _this.setMuted(false);
16473 },
16474 autoShowTooltip: true
16475 });
16476 } else if (xr_1.XR.isMuted(this.props.sceneName)) {
16477 muteButton = React.createElement(IconButton_1.IconButton, {
16478 variant: "sound-mute",
16479 tooltip: "Unmute",
16480 onClick: function onClick() {
16481 return _this.setMuted(false);
16482 }
16483 });
16484 } else {
16485 muteButton = React.createElement(IconButton_1.IconButton, {
16486 variant: "sound",
16487 tooltip: "Mute",
16488 onClick: function onClick() {
16489 return _this.setMuted(true);
16490 }
16491 });
16492 }
16493
16494 if (xr_1.XR.isVRCapable(this.props.sceneName)) {
16495 if (this.state.isVRPresentationActive) {
16496 logger.info('VR Presentation Active');
16497 enterOrExitVRButton = React.createElement(IconButton_1.IconButton, {
16498 variant: "exit-vr",
16499 tooltip: "Exit VR",
16500 onClick: function onClick() {
16501 return _this.toggleVRPresentation();
16502 }
16503 });
16504 } else {
16505 logger.info('VR Presentation Inactive');
16506 enterOrExitVRButton = React.createElement(IconButton_1.IconButton, {
16507 variant: "enter-vr",
16508 tooltip: "Enter VR",
16509 onClick: function onClick() {
16510 return _this.toggleVRPresentation();
16511 }
16512 });
16513 }
16514 }
16515
16516 if (this.state.isFullscreen) {
16517 screenSizeButton = React.createElement(IconButton_1.IconButton, {
16518 variant: "minimize",
16519 tooltip: "Exit Fullscreen",
16520 onClick: function onClick() {
16521 return _this.minimize();
16522 }
16523 });
16524 } else {
16525 screenSizeButton = React.createElement(IconButton_1.IconButton, {
16526 variant: "maximize",
16527 tooltip: "Fullscreen",
16528 onClick: function onClick() {
16529 return _this.maximize();
16530 }
16531 });
16532 }
16533 }
16534
16535 return React.createElement("div", {
16536 id: SCENE_CONTAINER_DOM_ID,
16537 className: AmplifyUI.sumerianSceneContainer,
16538 "data-test": data_test_attributes_1.sumerianScene.container
16539 }, React.createElement("div", {
16540 id: SCENE_DOM_ID,
16541 className: AmplifyUI.sumerianScene,
16542 "data-test": data_test_attributes_1.sumerianScene.sumerianScene
16543 }, this.state.loading && React.createElement(Loading_1.Loading, {
16544 sceneName: this.props.sceneName,
16545 percentage: this.state.percentage,
16546 sceneError: this.state.sceneError
16547 })), React.createElement("div", {
16548 className: AmplifyUI.sceneBar,
16549 "data-test": data_test_attributes_1.sumerianScene.bar
16550 }, React.createElement("span", {
16551 className: AmplifyUI.sceneActions,
16552 "data-test": data_test_attributes_1.sumerianScene.actions
16553 }, muteButton, enterOrExitVRButton, screenSizeButton)));
16554 };
16555
16556 return SumerianScene;
16557}(React.Component);
16558
16559exports.SumerianScene = SumerianScene;
16560/**
16561 * @deprecated use named import
16562 */
16563
16564exports["default"] = SumerianScene;
16565
16566/***/ }),
16567
16568/***/ "./lib/XR/Tooltip.js":
16569/*!***************************!*\
16570 !*** ./lib/XR/Tooltip.js ***!
16571 \***************************/
16572/*! no static exports found */
16573/***/ (function(module, exports, __webpack_require__) {
16574
16575"use strict";
16576
16577
16578var __importStar = this && this.__importStar || function (mod) {
16579 if (mod && mod.__esModule) return mod;
16580 var result = {};
16581 if (mod != null) for (var k in mod) {
16582 if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
16583 }
16584 result["default"] = mod;
16585 return result;
16586};
16587
16588Object.defineProperty(exports, "__esModule", {
16589 value: true
16590});
16591/*
16592 * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
16593 *
16594 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
16595 * the License. A copy of the License is located at
16596 *
16597 * http://aws.amazon.com/apache2.0/
16598 *
16599 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
16600 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
16601 * and limitations under the License.
16602 */
16603
16604var React = __importStar(__webpack_require__(/*! react */ "react"));
16605
16606var ui_1 = __webpack_require__(/*! @aws-amplify/ui */ "@aws-amplify/ui");
16607
16608exports.Tooltip = function (props) {
16609 var classes = "" + ui_1.tooltip;
16610
16611 if (props.autoShowTooltip) {
16612 classes = ui_1.tooltip + " " + ui_1.autoShowTooltip;
16613 }
16614
16615 return React.createElement("div", {
16616 className: classes,
16617 "data-text": props.text
16618 }, props.children);
16619};
16620/**
16621 * @deprecated use named import
16622 */
16623
16624
16625exports["default"] = exports.Tooltip;
16626
16627/***/ }),
16628
16629/***/ "./lib/XR/index.js":
16630/*!*************************!*\
16631 !*** ./lib/XR/index.js ***!
16632 \*************************/
16633/*! no static exports found */
16634/***/ (function(module, exports, __webpack_require__) {
16635
16636"use strict";
16637
16638
16639Object.defineProperty(exports, "__esModule", {
16640 value: true
16641});
16642/*
16643 * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
16644 *
16645 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
16646 * the License. A copy of the License is located at
16647 *
16648 * http://aws.amazon.com/apache2.0/
16649 *
16650 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
16651 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
16652 * and limitations under the License.
16653 */
16654
16655var SumerianScene_1 = __webpack_require__(/*! ./SumerianScene */ "./lib/XR/SumerianScene.js");
16656
16657exports.SumerianScene = SumerianScene_1.SumerianScene;
16658
16659/***/ }),
16660
16661/***/ "./lib/index.js":
16662/*!**********************!*\
16663 !*** ./lib/index.js ***!
16664 \**********************/
16665/*! no static exports found */
16666/***/ (function(module, exports, __webpack_require__) {
16667
16668"use strict";
16669
16670
16671function __export(m) {
16672 for (var p in m) {
16673 if (!exports.hasOwnProperty(p)) exports[p] = m[p];
16674 }
16675}
16676
16677Object.defineProperty(exports, "__esModule", {
16678 value: true
16679});
16680/*
16681 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
16682 *
16683 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
16684 * the License. A copy of the License is located at
16685 *
16686 * http://aws.amazon.com/apache2.0/
16687 *
16688 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
16689 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
16690 * and limitations under the License.
16691 */
16692
16693var core_1 = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
16694
16695var AmplifyI18n_1 = __webpack_require__(/*! ./AmplifyI18n */ "./lib/AmplifyI18n.js");
16696
16697__export(__webpack_require__(/*! ./AmplifyUI */ "./lib/AmplifyUI.js"));
16698
16699__export(__webpack_require__(/*! ./Auth */ "./lib/Auth/index.js"));
16700
16701__export(__webpack_require__(/*! ./Analytics */ "./lib/Analytics/index.js"));
16702
16703__export(__webpack_require__(/*! ./Storage */ "./lib/Storage/index.js"));
16704
16705__export(__webpack_require__(/*! ./Widget */ "./lib/Widget/index.js"));
16706
16707__export(__webpack_require__(/*! ./API */ "./lib/API/index.js"));
16708
16709__export(__webpack_require__(/*! ./Interactions */ "./lib/Interactions/index.js"));
16710
16711__export(__webpack_require__(/*! ./XR */ "./lib/XR/index.js"));
16712
16713var AmplifyTheme_1 = __webpack_require__(/*! ./AmplifyTheme */ "./lib/AmplifyTheme.js");
16714
16715exports.AmplifyTheme = AmplifyTheme_1.Bootstrap;
16716
16717var AmplifyMessageMap_1 = __webpack_require__(/*! ./AmplifyMessageMap */ "./lib/AmplifyMessageMap.js");
16718
16719exports.AmplifyMessageMapEntries = AmplifyMessageMap_1.MapEntries;
16720
16721var AmplifyUI_1 = __webpack_require__(/*! ./AmplifyUI */ "./lib/AmplifyUI.js");
16722
16723exports.transparent1X1 = AmplifyUI_1.transparent1X1;
16724exports.white1X1 = AmplifyUI_1.white1X1;
16725core_1.I18n.putVocabularies(AmplifyI18n_1.dict);
16726
16727/***/ }),
16728
16729/***/ "@aws-amplify/analytics":
16730/*!*****************************************!*\
16731 !*** external "@aws-amplify/analytics" ***!
16732 \*****************************************/
16733/*! no static exports found */
16734/***/ (function(module, exports) {
16735
16736module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_analytics__;
16737
16738/***/ }),
16739
16740/***/ "@aws-amplify/api":
16741/*!***********************************!*\
16742 !*** external "@aws-amplify/api" ***!
16743 \***********************************/
16744/*! no static exports found */
16745/***/ (function(module, exports) {
16746
16747module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_api__;
16748
16749/***/ }),
16750
16751/***/ "@aws-amplify/auth":
16752/*!************************************!*\
16753 !*** external "@aws-amplify/auth" ***!
16754 \************************************/
16755/*! no static exports found */
16756/***/ (function(module, exports) {
16757
16758module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_auth__;
16759
16760/***/ }),
16761
16762/***/ "@aws-amplify/core":
16763/*!************************************!*\
16764 !*** external "@aws-amplify/core" ***!
16765 \************************************/
16766/*! no static exports found */
16767/***/ (function(module, exports) {
16768
16769module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_core__;
16770
16771/***/ }),
16772
16773/***/ "@aws-amplify/interactions":
16774/*!********************************************!*\
16775 !*** external "@aws-amplify/interactions" ***!
16776 \********************************************/
16777/*! no static exports found */
16778/***/ (function(module, exports) {
16779
16780module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_interactions__;
16781
16782/***/ }),
16783
16784/***/ "@aws-amplify/storage":
16785/*!***************************************!*\
16786 !*** external "@aws-amplify/storage" ***!
16787 \***************************************/
16788/*! no static exports found */
16789/***/ (function(module, exports) {
16790
16791module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_storage__;
16792
16793/***/ }),
16794
16795/***/ "@aws-amplify/ui":
16796/*!**********************************!*\
16797 !*** external "@aws-amplify/ui" ***!
16798 \**********************************/
16799/*! no static exports found */
16800/***/ (function(module, exports) {
16801
16802module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_ui__;
16803
16804/***/ }),
16805
16806/***/ "@aws-amplify/xr":
16807/*!**********************************!*\
16808 !*** external "@aws-amplify/xr" ***!
16809 \**********************************/
16810/*! no static exports found */
16811/***/ (function(module, exports) {
16812
16813module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_xr__;
16814
16815/***/ }),
16816
16817/***/ "react":
16818/*!************************!*\
16819 !*** external "react" ***!
16820 \************************/
16821/*! no static exports found */
16822/***/ (function(module, exports) {
16823
16824module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
16825
16826/***/ })
16827
16828/******/ });
16829});
16830//# sourceMappingURL=aws-amplify-react.js.map
\No newline at end of file