"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var a=require("react"),b=require("../contexts/ApiHandler"),c=require("react-i18next"),d=require("./snippetFactory"),e=require("./constants"),f=require("lodash"),g=n(require("./KafkaSnippets/JavaKafkaCodeSnippet")),h=n(require("./KafkaSnippets/KafkaJSKafkaCodeSnippet")),i=n(require("./KafkaSnippets/PythonKafkaCodeSnippet")),j=n(require("./KafkaSnippets/NoderdKafkaCodeSnippet")),k=n(require("./KafkaSnippets/KafkacatKafkaCodeSnippet")),l=n(require("./KafkaSnippets/KafkaConsoleConsumerCodeSnippet")),m=require("./../contexts/config/index.js");function n(a){return a&&a.__esModule?a:{default:a}}function o(){return o=p()?Reflect.construct:function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&q(f,d.prototype),f},o.apply(null,arguments)}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,b){return q=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},q(a,b)}function r(a,b){return w(a)||v(a,b)||t(a,b)||s()}function s(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function t(a,b){if(a){if("string"==typeof a)return u(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?u(a,b):void 0}}function u(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function v(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f=[],g=!0,h=!1;try{for(c=c.call(a);!(g=(d=c.next()).done)&&(f.push(d.value),!(b&&f.length===b));g=!0);}catch(a){h=!0,e=a}finally{try{g||null==c["return"]||c["return"]()}finally{if(h)throw e}}return f}}function w(a){if(Array.isArray(a))return a}var x=function(n){var p=n.apiType,q=n.codeLanguage,s=n.channelName,u=n.selectedCredentials,v=(0,b.useApi)(),w=v.apiHandler,x=(0,c.useTranslation)(),y=x.t,t=(0,m.useConfig)(),z=t.options,A=(0,a.useState)({}),B=r(A,2),C=B[0],D=B[1],E=(0,a.useState)({snippet:"",dependencies:""}),F=r(E,2),G=F[0],H=F[1],I=(0,a.useCallback)(function(a){var b=[w,s,u,y,z.loggedIn];switch(a){case e.codeLanguages.java:return o(g["default"],b);case e.codeLanguages.consoleConsumer:return o(l["default"],b);case e.codeLanguages.kafkaJS:return o(h["default"],b);case e.codeLanguages.noderdKafka:return o(i["default"],b);case e.codeLanguages.kafkaPython:return o(j["default"],b);case e.codeLanguages.kafkacat:return o(k["default"],b);default:throw new Error("Snippet options for ".concat(a," is not supported"));}},[w,s,u,y,z.loggedIn]);return(0,a.useEffect)(function(){var a=I(q);D({channel:s,operationBindings:a.getOperationBindings(),securityDetails:a.getSecurityDetails(),bootstrapServers:a.getBootstrapServers(),schema:a.getSchemaInformation(),kafkaKey:a.getKeyDeserializer(),applicationDetails:a.getApplicationDetails(),encodingType:a.getEncodingType(),enforced:a.getEnforcedType()})},[w,s,u,q,I]),(0,a.useEffect)(function(){(0,f.isEmpty)(C)||H((0,d.snippetFactory)(p)(q,C))},[C,p,q]),{snippet:G.snippet,dependencies:G.dependencies}},y=x;exports["default"]=y;