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