import{__awaiter as t,__generator as e,__assign as n}from"tslib";import{useState as o}from"react";var r=function(r){var a=o(!1),s=a[0],i=a[1],c=o([]),u=c[0],p=c[1],l=o(null),f=l[0],d=l[1];return{fixPromptRules:function(o,a,s,c,u){return t(void 0,void 0,void 0,function(){var t,l,f,h,m,w,x;return e(this,function(e){switch(e.label){case 0:i(!0),p([]),d(null),t=n(n({},o),{wta:a.wta.map(function(t){return t.text}),wnta:a.wnta.map(function(t){return t.text}),mode:"PromptGenie",template_context:s,template_description:c,llm:u}),e.label=1;case 1:return e.trys.push([1,4,5,6]),[4,fetch("".concat(r,"/instant_learning/mode-wta-validation-fix"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})];case 2:if(!(l=e.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return f=e.sent(),h=[],null===(w=f.response.conditions_whentoapply)||void 0===w||w.forEach(function(t){h.push({type:"wta",text:t.whentoapply,score:t.confidence_score,reason:t.reason})}),null===(x=f.response.conditions_whennottoapply)||void 0===x||x.forEach(function(t){h.push({type:"wnta",text:t.whennottoapply,score:t.confidence_score,reason:t.reason})}),p(h),[3,6];case 4:return m=e.sent(),console.error("Failed to fix prompt rules:",m),d(m),[3,6];case 5:return i(!1),[7];case 6:return[2]}})})},isFixing:s,fixedSuggestions:u,error:f}};export{r as default};
//# sourceMappingURL=usePromptFix.js.map
