"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"]=void 0;var b=i(require("react")),c=require("carbon-components-react"),d=require("react-i18next"),e=g(require("prop-types")),f=g(require("../utils/api-factory"));function g(a){return a&&a.__esModule?a:{default:a}}function h(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(h=function(a){return a?c:b})(a)}function i(b,c){if(!c&&b&&b.__esModule)return b;if(null===b||"object"!==a(b)&&"function"!=typeof b)return{default:b};var d=h(c);if(d&&d.has(b))return d.get(b);var e={},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var g in b)if("default"!=g&&Object.prototype.hasOwnProperty.call(b,g)){var i=f?Object.getOwnPropertyDescriptor(b,g):null;i&&(i.get||i.set)?Object.defineProperty(e,g,i):e[g]=b[g]}return e["default"]=b,d&&d.set(b,e),e}function j(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function k(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 l(a,b,c){return b&&k(a.prototype,b),c&&k(a,c),a}function m(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&&n(a,b)}function n(a,b){return n=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},n(a,b)}function o(a){var b=r();return function(){var c,d=s(a);if(b){var e=s(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return p(this,c)}}function p(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 q(b)}function q(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function r(){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 s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},s(a)}var t=function(a){function d(a){var b;return j(this,d),b=e.call(this,a),b.openApiHandler=(0,f["default"])(b.props.api),b}m(d,a);var e=o(d);return l(d,[{key:"render",value:function render(){var a,d=this,e=this.props,f=e.t,g=e.endpoints,h=e.opPath,i=e.id,j=e.endpoint;if(g&&1<g.length)a=b["default"].createElement(c.Select,{onChange:this.props.onChange,id:i,value:j?j:g[0].url,hideLabel:!0},g.map(function(a){var e=a.types?a.types+": ":"";return b["default"].createElement(c.SelectItem,{key:a.url,value:a.url,text:e+d.openApiHandler.buildFullUrl(a.url,h)})}));else if(g&&1===g.length&&g[0].url){var k=g[0].types?g[0].types+": ":"";a=b["default"].createElement("div",{className:"apiEndpoint",key:g[0].url},k&&b["default"].createElement("div",{className:"apiEndpointType"},k),b["default"].createElement("div",{className:"apiEndpointUrl"},this.openApiHandler.buildFullUrl(g[0].url,h)))}else a=b["default"].createElement("div",null,f("no_endpoint"));return b["default"].createElement("div",{className:"endpointDisplay"},a)}}]),d}(b.Component);t.propTypes={endpoints:e["default"].array,opPath:e["default"].string,onChange:e["default"].func,id:e["default"].string},t.defaultProps={onChange:function onChange(){console.warn("EndpointSelector onChange not set")}};var u=(0,d.withTranslation)()(t);exports["default"]=u;