import{__awaiter as n,__generator as t}from"tslib";import{useState as e,useCallback as r}from"react";var o=function(o,a,i){var l=e(!1),s=l[0],c=l[1],u=e(null),d=u[0],f=u[1],p=e(null),v=p[0],m=p[1],w=r(function(e,r){return n(void 0,void 0,void 0,function(){var n,l,s,u;return t(this,function(t){switch(t.label){case 0:if(c(!0),f(null),m(null),0===(n={agent_context:o,agent_description:a,mode:"AgentGenie",llm:r,wta:e.wta.map(function(n){return n.text}),wnta:e.wnta.map(function(n){return n.text})}).wta.length)return console.error("WTA conditions cannot be empty."),c(!1),[2,null];t.label=1;case 1:return t.trys.push([1,4,5,6]),[4,fetch("".concat(i,"/instant_learning/mode-wta-validation"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})];case 2:if(!(l=t.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return(s=t.sent()).response.is_valid?(console.log("Validation Successful!"),f(null)):(console.warn("Validation failed, conflicts found."),f(s.response)),[2,s.response];case 4:return u=t.sent(),console.error("Failed to validate rules:",u),m(u),[2,null];case 5:return c(!1),[7];case 6:return[2]}})})},[o,a,i]);return{validateAgentRules:w,clearValidation:function(){f(null)},isSaving:s,validationResponse:d,error:v}};export{o as default};
//# sourceMappingURL=useAgentValidation.js.map
