"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("./useDebounce.js");exports.default=function(o,r,s,a,i,c){void 0===i&&(i=!0);var u=t.useState([]),l=u[0],p=u[1],d=t.useState(!1),f=d[0],h=d[1],_=t.useState(null),w=_[0],y=_[1],g=n.default(o,500),v=n.default(r,500);return t.useEffect(function(){if(g&&v&&i){e.__awaiter(void 0,void 0,void 0,function(){var t,n,o,r,s,i,u;return e.__generator(this,function(e){switch(e.label){case 0:h(!0),y(null),e.label=1;case 1:return e.trys.push([1,4,5,6]),t={template_context:g,template_description:v,mode:"PromptGenie",llm:a,n:1},[4,fetch("".concat(c,"/instant_learning/mode-wta-suggestion"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})];case 2:if(!(n=e.sent()).ok)throw new Error("API Error: ".concat(n.statusText));return[4,n.json()];case 3:return o=e.sent(),r=[],null===(i=o.response.conditions_whentoapply)||void 0===i||i.forEach(function(e){r.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(u=o.response.conditions_whennottoapply)||void 0===u||u.forEach(function(e){r.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),p(r),[3,6];case 4:return s=e.sent(),console.error("Failed to fetch prompt suggestions:",s),y(s),[3,6];case 5:return h(!1),[7];case 6:return[2]}})})}else p([])},[g,v,s,i]),{suggestions:l,isLoading:f,error:w}};
//# sourceMappingURL=usePromptSuggestions.js.map
