import{__awaiter as n,__generator as e}from"tslib";import{useState as t}from"react";var r=function(r){var o=t(!1),s=o[0],i=o[1],a=t(null),c=a[0],l=a[1],u=t(null),f=u[0],g=u[1];return{checkExistingRules:function(t,o,s,a){return n(void 0,void 0,void 0,function(){var n,c,u,f;return e(this,function(e){switch(e.label){case 0:i(!0),g(null),l(null),n={mode:"AgentGenie",assistantname:s,organizationname:a,wta:t.wta.map(function(n){return n.text}),wnta:t.wnta.map(function(n){return n.text}),agent_id:o},console.log("Checking for existing DB conflicts with payload:",n),e.label=1;case 1:return e.trys.push([1,4,5,6]),[4,fetch("".concat(r,"/instant_learning/mode-wta-existing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})];case 2:if(!(c=e.sent()).ok)throw new Error("API Error: ".concat(c.statusText));return[4,c.json()];case 3:return(u=e.sent()).response?(console.log("DB check successful. Setting state with:",u.response),l(u.response)):(console.error("DB check: API response object was missing."),l(null)),[3,6];case 4:return f=e.sent(),console.error("Failed to check for existing rules:",f),g(f),[3,6];case 5:return i(!1),[7];case 6:return[2]}})})},isLoading:s,existingConflicts:c,error:f,clearExistingAgentConflicts:function(){l(null)}}};export{r as default};
//# sourceMappingURL=useExistingAgentCheck.js.map
