"use strict";var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/regenerator"),a=require("react"),i=require("prop-types"),u=require("@material-ui/core"),s=require("./components/AccuracyPlan.js"),n=require("./components/ActualPointInfo.js"),l=require("./components/Warning.js"),d=require("./api.js"),o=require("../../../LoadingIndicator/LoadingIndicator.js"),c=require("react/jsx-runtime");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=p(e),v=p(t),f=p(r),q=u.makeStyles({wrapper:{display:"flex",flexWrap:"wrap"}}),h=function(e){var t,r,i,u=e.feedItem,p=q(),h=a.useState(!1),x=v.default(h,2),y=x[0],j=x[1],b=a.useState(!1),R=v.default(b,2),w=R[0],S=R[1],_=a.useState(null),g=v.default(_,2),I=g[0],A=g[1],T=a.useState(""),P=v.default(T,2),W=P[0],k=P[1],D=a.useState(""),L=v.default(D,2),N=L[0],z=L[1],C=a.useState(null),E=v.default(C,2),G=E[0],B=E[1],F="active"===(null===(t=u.context)||void 0===t||null===(r=t.survey_station)||void 0===r||null===(i=r.well)||void 0===i?void 0:i.status);return a.useEffect(m.default(f.default.mark((function e(){var t,r,a,i,s,n,l,o,c,p,m,v,q,h;return f.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null===(t=u.well)||void 0===t?void 0:t.id,l=null===(r=u.context)||void 0===r||null===(a=r.survey_station)||void 0===a||null===(i=a.data)||void 0===i?void 0:i.measured_depth,e.next=4,d.fetchDirectionalAccuracyRecords({wellId:n,md:l});case 4:o=e.sent,c=null==o||null===(s=o[0])||void 0===s?void 0:s.data,j(!0),c&&(m=c.accuracy,v=c.cumulative_tvd_change||"",q=c.plan_name||"",h=null===(p=o[0])||void 0===p?void 0:p.timestamp,S(!0),A(m),k(v),z(q),B(h));case 8:case"end":return e.stop()}}),e)}))),[]),y?c.jsxs("div",{className:p.wrapper,children:[w?c.jsx(s,{accuracyData:I,cumulativeTvdChange:W,initialPlanName:N,timestamp:G}):c.jsx(l,{isWellStatusActive:F}),c.jsx(n,{feedItem:u})]}):c.jsx(o,{})};h.propTypes={feedItem:i.shape({context:i.shape({survey_station:i.shape({data:i.shape({azimuth:i.number.isRequired,inclination:i.number.isRequired,measured_depth:i.number.isRequired}).isRequired,well:i.shape({status:i.string.isRequired}).isRequired}).isRequired}).isRequired}).isRequired},module.exports=h;
