import{__assign as e,__awaiter as t,__generator as r}from"tslib";import{jsx as i,jsxs as n}from"react/jsx-runtime";import{useState as a,useEffect as o}from"react";import{Box as s,CircularProgress as c,Dialog as l,DialogTitle as p,Typography as d,IconButton as u,DialogContent as f}from"@mui/material";import m from"@mui/icons-material/Close";import{useLearningTemplateStore as h}from"../../LearningManagement/store/useLearningTemplateStore.js";var v=function(){var t=a(!0),r=t[0],o=t[1];return n(l,e({open:r,onClose:function(){return o(!1)},fullWidth:!0,maxWidth:"lg",PaperProps:{sx:{borderRadius:"16px",minHeight:"70vh",overflow:"hidden"}}},{children:[n(p,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",px:3,py:2}},{children:[i(d,e({variant:"h6",fontWeight:600},{children:"Teach Me"})),i(u,e({onClick:function(){return o(!1)}},{children:i(m,{})}))]})),i(f,e({dividers:!0,sx:{p:3,backgroundColor:"#fafafa"}},{children:"There is some issue with the selected template. Kindly check steps to resolve."}))]}))},g=function(n){var l=n.templateRegistry,p=void 0===l?{}:l,d=h(function(e){return e.backwardCompatibility}),u=h(function(e){return n.app_integration_id?e.templateMap[n.app_integration_id]:void 0}),f=h(function(e){return e.setTemplateData}),m=d?"Radio Traffic Learning":u,g=a(!m),_=g[0],y=g[1],b=a(!1),w=b[0],x=b[1];if(o(function(){if(n.isOpen){if(!d&&!n.app_integration_id)return console.error("TeachMeWrapper requires an app_integration_id when backward compatibility is disabled."),x(!0),void y(!1);if(m)y(!1);else{t(void 0,void 0,void 0,function(){var e,i;return r(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,4]),y(!0),x(!1),[4,(o=n.app_integration_id,s=n.token,t(void 0,void 0,void 0,function(){var e,t;return r(this,function(r){switch(r.label){case 0:return[4,fetch("".concat("https://devllmstudio.creativeworkspace.ai","/instant_learning/ilotj/application/getValueType/").concat(o),{headers:{Authorization:"Bearer ".concat(s)}})];case 1:if(!(e=r.sent()).ok)throw new Error("Failed to fetch value type");return[4,e.json()];case 2:return t=r.sent(),console.log("Fetched value type data:",t),!t||Array.isArray(t.data)&&0===t.data.length?[2,null]:[2,t.data[0].value_type_name||t.valueTypeName||t.templateName]}})}))];case 1:return e=a.sent(),f(n.app_integration_id,e),[3,4];case 2:return i=a.sent(),console.error(i),x(!0),n.app_integration_id&&f(n.app_integration_id,"ERROR"),[3,4];case 3:return y(!1),[7];case 4:return[2]}var o,s})})}}},[n.isOpen,n.app_integration_id,m,n.token,f,d]),_)return i(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:i(c,{size:32})}));if(w||!m)return i(v,{});var k=p[m&&p[m]?m:"Default"];return k?i(k,e({},n)):(console.warn("No renderer found for template: ".concat(m)),i(v,{}))};export{g as default};
//# sourceMappingURL=TeachMeWrapper.js.map
