"use strict";function a(b){"@babel/helpers - typeof";return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},a(b)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=exports.TestToolSecurityFlows=void 0;var b=g(require("react")),c=require("react-i18next"),d=require("carbon-components-react"),e=require("lodash");function f(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(f=function(a){return a?c:b})(a)}function g(b,c){if(!c&&b&&b.__esModule)return b;if(null===b||"object"!==a(b)&&"function"!=typeof b)return{default:b};var d=f(c);if(d&&d.has(b))return d.get(b);var e={},g=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var h in b)if("default"!=h&&Object.prototype.hasOwnProperty.call(b,h)){var i=g?Object.getOwnPropertyDescriptor(b,h):null;i&&(i.get||i.set)?Object.defineProperty(e,h,i):e[h]=b[h]}return e["default"]=b,d&&d.set(b,e),e}function h(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function i(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function j(a,b,c){return b&&i(a.prototype,b),c&&i(a,c),a}function k(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&l(a,b)}function l(a,b){return l=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},l(a,b)}function m(a){var b=p();return function(){var c,d=q(a);if(b){var e=q(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return n(this,c)}}function n(b,c){if(c&&("object"===a(c)||"function"==typeof c))return c;if(void 0!==c)throw new TypeError("Derived constructors may only return object or undefined");return o(b)}function o(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function q(a){return q=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},q(a)}var r=function(a){function c(a){var b;return h(this,c),b=f.call(this,a),b.handleFlowChange=b.handleFlowChange.bind(o(b)),b.state={flow:null},b}k(c,a);var f=m(c);return j(c,[{key:"UNSAFE_componentWillMount",value:function UNSAFE_componentWillMount(){var a=(0,e.uniqueId)("security-flow-select");this.setState({id:a})}},{key:"componentDidMount",value:function componentDidMount(){this.configure(this.props)}},{key:"componentDidUpdate",value:function componentDidUpdate(a){(0,e.isEqual)(a,this.props)||this.configure(this.props)}},{key:"configure",value:function configure(a){var b={};this.state.flow||(b.flow=Object.keys(a.flows)[0]),a.currentFlow&&this.state.flow!==a.currentFlow&&(b.flow=a.currentFlow),this.setState(b)}},{key:"handleFlowChange",value:function handleFlowChange(a){this.props.onChange&&"function"==typeof this.props.onChange&&this.props.onChange(a.target.value)}},{key:"render",value:function render(){var a=this.props.flows,c=this.state.flow,e=this.state.id;return b["default"].createElement("div",{className:"securityFlowChooser"},c&&b["default"].createElement(d.Select,{value:c,onChange:this.handleFlowChange,id:e,hideLabel:!0},Object.keys(a).map(function(a){return b["default"].createElement(d.SelectItem,{key:a,value:a,text:a})})))}}]),c}(b.Component);exports.TestToolSecurityFlows=r;var s=(0,c.withTranslation)()(r);exports["default"]=s;