"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(require("axios")),n="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4MDU5NjU4Yy1hNjVjLTRlMTQtODlhYS1hNTE5NWY1ZDA5ZjUiLCJ1c2VybmFtZSI6IkthdGh5YXlhbmlNIiwibmFtZSI6Ik0gS2F0aHlheWFuaSIsImVtYWlsIjoibWFkdW1idS5rYXRoeWF5YW5pQHRlY2hvbHV0aW9uLmNvbSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsInN0YXR1cyI6ImFjdGl2ZSIsImlhdCI6MTc1MzM4Mzg4N30.iF2nGYpBedIfeGasUNc7lhjStb_B_u1uz6NFEh0u6qI",a="techolution-instantLearning-topics",s="techolution-instantLearning-variants";exports.fetchAllCustomScopes=function(t){return e.__awaiter(void 0,void 0,void 0,function(){var a,s,o,i,c;return e.__generator(this,function(e){switch(e.label){case 0:a="".concat(t,"/api/scopes/getAllScoper"),s={Authorization:"Bearer ".concat(n)},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.get(a,{headers:s})];case 2:return o=e.sent(),[2,((null===(c=o.data)||void 0===c?void 0:c.data)||[]).map(function(e){return{scopeName:e.scopeName,scopeId:e.scopeId}})];case 3:return i=e.sent(),console.error("Error fetching all scopes:",i),[2,[]];case 4:return[2]}})})},exports.fetchExistingTopicsAPI=function(t){return e.__awaiter(void 0,void 0,void 0,function(){var o,i,c,u,l;return e.__generator(this,function(e){switch(e.label){case 0:o={topic_table:a,variant_table:s},i="".concat(t,"/api/instant-learning/getExistingTopics"),c={Authorization:"Bearer ".concat(n)},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.post(i,o,{headers:c})];case 2:return(u=e.sent()).data.response&&0!==Object.keys(u.data.response.response).length?[2,Object.entries(u.data.response.response).map(function(e){return{id:e[0],label:e[1].topic_name}})]:[2,[]];case 3:return l=e.sent(),console.error("Error fetching existing topics:",l),[2,[]];case 4:return[2]}})})},exports.fetchScopes=function(t,a,s){return e.__awaiter(void 0,void 0,void 0,function(){var o,i,c,u,l,d,h,p,g,f,v,b,I;return e.__generator(this,function(e){switch(e.label){case 0:o={Authorization:"Bearer ".concat(n)},i="".concat(s,"/api/chatbot/getChatbot?name=").concat(t,"&organizationName=").concat(a),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.get(i,{headers:o})];case 2:return h=e.sent(),c=h.data,[3,4];case 3:throw u=e.sent(),console.error("Error fetching chatbot details:",u),u;case 4:l="".concat(s,"/api/agent/getAgentSettings?agentSettingsId=").concat(c.agentSettingsId),e.label=5;case 5:return e.trys.push([5,7,,8]),[4,r.default.get(l,{headers:o})];case 6:return h=e.sent(),d=null===(I=h.data)||void 0===I?void 0:I.agentSettings,[3,8];case 7:throw p=e.sent(),console.error("Error fetching agent settings:",p),p;case 8:return g=(null==d?void 0:d.scopeMetrics)||[],f=g.filter(function(e){return e.isSelected}),v=f.find(function(e){return"Custom"===e.scope}),b=(null==v?void 0:v.id)&&Array.isArray(v.id)?v.id.map(function(e){return{scopeName:e.scopeName,scopeId:e.id}}):[],console.log("Scope options:",f),console.log("Custom scope options:",b),[2,{scopeOptions:f,customScopeOptions:b,assistantId:c.id}]}})})},exports.fetchUserByEmail=function(t,a){return e.__awaiter(void 0,void 0,void 0,function(){var s,o,i;return e.__generator(this,function(e){switch(e.label){case 0:s="".concat(a,"/api/users/getUserByEmail/").concat(t),o={Authorization:"Bearer ".concat(n)},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.get(s,{headers:o})];case 2:return[2,e.sent().data];case 3:throw i=e.sent(),console.error("Error fetching user by email:",i),i;case 4:return[2]}})})},exports.searchAssistants=function(t,a){return e.__awaiter(void 0,void 0,void 0,function(){var s,o,i,c,u,l;return e.__generator(this,function(e){switch(e.label){case 0:s="".concat(a,"/api/chatbot/search"),o={Authorization:"Bearer ".concat(n)},i={organizationName:"techolution",name:t,isArchived:"false"},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.get(s,{headers:o,params:i})];case 2:return c=e.sent(),u=c.data,Array.isArray(u)?[2,u]:[2,(null==u?void 0:u.response)||(null==u?void 0:u.data)||[]];case 3:return l=e.sent(),console.error("Error searching assistants:",l),[2,[]];case 4:return[2]}})})};
//# sourceMappingURL=agentGenieAPI.js.map
