@zac-apps/helium 2.2.0-beta.3 → 2.2.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import t,{createContext as n,useContext as i,useState as l,useEffect as a}from"react";import{useImmer as o}from"use-immer";import c from"@mui/material/useMediaQuery";import u from"@mui/material/Grid";import{AppTheme as s,AppTable as m,TableHeadCell as d,ErrorAlert as p,DivTitle as h,AppCard as f,Percentage as b,SpecSwitch as v,PublicFetch as y,Progress as g,AppGrid as O}from"@zac-apps/commons";import x from"moment";import j from"@mui/material/Paper";import{LineChart as S,Line as k,DefaultZIndexes as D,CartesianGrid as w,XAxis as P,Label as M,YAxis as z,ReferenceLine as C,ReferenceArea as E,Tooltip as L}from"recharts";import N from"@mui/material/ButtonGroup";import F from"@mui/material/Button";import H from"@mui/material/FormGroup";import I from"@mui/material/FormControlLabel";import A from"@mui/material/Switch";import Y from"@mui/material/TableHead";import T from"@mui/material/TableCell";import G from"@mui/material/TableRow";import B from"@mui/material/TableBody";import{jsx as _,jsxs as K}from"react/jsx-runtime";import J from"regression";import{mean as V,sqrt as W,sum as q}from"mathjs";import R from"@mui/material/IconButton";import U from"@mui/icons-material/Save";import Q from"@mui/icons-material/Edit";import X from"@mui/material/TextField";import Z from"@mui/material/InputAdornment";import $ from"moment/moment.js";import ee from"@mui/material/Divider";import re from"@mui/material/Typography";import te from"@mui/material/FormControl";import ne from"@mui/material/Checkbox";import ie from"@babel/runtime/helpers/toConsumableArray";import le from"@mui/material/Chip";import ae from"@mui/icons-material/AddBox";import oe from"@mui/icons-material/Delete";var ce=n(null);function ue(e){var r=e.spec,t=e.estimatedBoiloff,n=e.estimatedError,l=i(ce).heliumLookupData.boilOff[r].toFixed(3)||"N/A";t=t.toFixed(3)||"N/A",n=n.toFixed(3)||"N/A";var a=Math.abs(t-l)<.01?t:_("strong",{style:{color:s.palette.primary.main},children:t});return K("div",{children:[_("h4",{children:"Boiloff coefficients (%/day)"}),_(u,{container:!0,children:K(m,{children:[_(Y,{children:K(G,{children:[_(d,{children:"Estimated"}),_(d,{children:"Stored"})]})}),_(B,{children:K(G,{children:[K(T,{children:[a," ",K("em",{style:{color:s.palette.secondary.main},children:["(±",n,")"]})]}),_(T,{children:l})]})})]})})]})}function se(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function me(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?se(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):se(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function de(e){var n=e.data,o=e.height,c=e.width,u=e.spec,m=i(ce).heliumLookupData,d=l(!1),h=r(d,2),f=h[0],b=h[1],v=l(""),y=r(v,2),g=y[0],O=y[1],j=process.env.SITE_CONFIG.alertDuration||5e3,Y=function(e){var r=e.data;e.spec;for(var t,n,i=Number(r[r.length-1].level),l=r.length-1,a=r.length-1,o=Number(r[a].level),c=r.length-2;c>=0;c--){var u=Number(r[c].level);if(u>i&&(o=u,a=c),u<o)break}a>=r.length-45&&(l=a-1,i=Number(r[l].level));for(var s=l-1,m=Number(r[s].level),d=s,p=s-1;p>=0;p--){var h=Number(r[p].level);if(h>m&&(m=h,d=p),h<m-1||h>=90)break}for(var f=[],b=d;b<=s;b++)f.push([b,Number(r[b].level)]);var v=J.linear(f,{precision:6});t=v.equation[0],n=v.equation[1];for(var y=[],g=d;g<=s;g++)y.push([g,g*t+n]);var O=V(f.map(function(e){return e[0]})),x=W(1/(y.length-2)*q(f.map(function(e,r){return Math.pow(e[1]-y[r][1],2)}))/q(f.map(function(e,r){return Math.pow(e[0]-O,2)})));return{slope:t,intercept:n,slopeError:x}}(me({},{data:n,spec:u})),T=Y.slope,G=Y.intercept,B=Y.slopeError,R=function(e){var r=e.active,t=e.payload,n=e.label;if(r&&t&&t.length){var i=x(t[0].payload.date,"ddd MMM D HH:mm:ss YYYY").format("LL");return K("div",{style:{border:"solid 1px "+s.palette.secondary.main,padding:"0.75em",backgroundColor:"#ffffffaa"},children:[_("strong",{children:i}),_("br",{}),K("em",{children:["(",n," days ago)"]}),_("br",{}),K("strong",{style:{color:s.palette.primary.main},children:[t[0].value," %"]})]})}};function U(e){var r=e.value;return _(F,{onClick:function(){return $(r)},color:r===Z?"primary":"secondary",variant:r===Z?"contained":"outlined",size:"small",children:r})}var Q=l(90),X=r(Q,2),Z=X[0],$=X[1],ee=l(!0),re=r(ee,2),te=re[0],ne=re[1],ie=l(!1),le=r(ie,2),ae=le[0],oe=le[1],se=(n||[]).map(function(e){return me(me({},e),{},{days:-x(e.date,"ddd MMM D HH:mm:ss YYYY").diff(x(),"days")})}),de=0;se.length>0&&(de=x().diff(x(se[se.length-1].date,"ddd MMM D HH:mm:ss YYYY"),"days")),a(function(){de>0&&(b(!0),O("WARNING: Heliumlog of ".concat(u," has not been updated since ").concat(de," days ago.")))},[de]);var pe=se.map(function(e){var r=e.days,t=e.level,n=T*(se.length-r+de)+G;return{date:e.date,days:r,level:t,estimate:n}}),he=ae?s.palette.grey[300]:s.palette.primary.main;return K(t.Fragment,{children:[_(p,{alert:f,SetAlert:b,autoHideDuration:j,message:g}),K(S,{height:o,width:c,data:pe,margin:{top:5,right:20,bottom:25,left:0},children:[_(k,{dataKey:"level",stroke:he,fill:he,type:"linear",dot:{r:1.5}}),ae&&_(k,{dataKey:"estimate",stroke:s.palette.action.main,type:"monotone",strokeDasharray:"5 5",strokeWidth:2,dot:!1,zIndex:D.scatter+1}),_(w,{stroke:s.palette.divider,strokeDasharray:"5 5"}),_(P,{dataKey:"days",type:"number",interval:"preserveStartEnd",domain:[Z,0],allowDataOverflow:!0,children:_(M,{value:"Days ago",offset:1,position:"bottom"})}),_(z,{dataKey:"level",unit:"%",type:"number",orientation:"right",domain:[0,100]}),te&&K(t.Fragment,{children:[_(C,{y:m.minima[u],stroke:s.palette.secondary.main,strokeDasharray:3}),_(E,{y1:m.minima[u],y2:0,stroke:"none",stro:!0,fill:s.palette.secondary.main,fillOpacity:.1})]}),_(L,{content:_(R,{})})]}),K(N,{disableElevation:!0,variant:"outlined",fullWidth:!0,color:"secondary","aria-label":"contained primary button group",sx:{justifySelf:"center",px:5},size:"small",children:[_(U,{value:7}),_(U,{value:30}),_(U,{value:90}),_(U,{value:180}),_(U,{value:365})]}),K(H,{children:[_(I,{control:_(A,{label:"Show Minimum",checked:te,onChange:function(){return ne(!te)}}),label:"Show Minimum",sx:{justifyContent:"center"}}),_(I,{control:_(A,{label:"Show Estimate",checked:ae,onChange:function(){return oe(!ae)}}),label:"Show Estimate",sx:{justifyContent:"center"}})]}),_(ue,{spec:u,estimatedBoiloff:T,estimatedError:B})]})}function pe(e){var r=e.graphData,n=e.graphDataMeta,l=e.matches,a=l?250:200,o=l?300:280,c=i(ce).heliumLookupData;return Object.keys(r).forEach(function(e){c.boilOff[e]||delete r[e]}),r.error?K(t.Fragment,{children:[_(h,{children:_("strong",{children:"Helium level monitoring"})}),_(u,{sx:{display:"flex",justifyContent:"center"},children:_("em",{children:"No graph data available"})})]}):K(t.Fragment,{children:[K(h,{children:[_("strong",{children:"Helium level monitoring"})," ",K("em",{children:["(updated ",x(n.date).fromNow(),")"]})]}),_(u,{container:!0,sx:{display:"flex",justifyContent:"center"},children:Object.keys(r).map(function(e){return K(j,{sx:{display:"flex",flexDirection:"column",justifyItems:"center",stroke:s.palette.divider,px:2,paddingBottom:2,margin:2},children:[_("h4",{children:e}),_(de,{data:r[e],height:a,width:o,spec:e})]},"graph_"+e)})})]})}function he(e){var r=e.graphData,t=e.graphDataMeta,n=i(ce),l=n.collapsed,a=n.matches;return _(f,{title:"Helium Graphs",size:12,collapsed:l,children:_(pe,{graphData:r,graphDataMeta:t,matches:a})})}function fe(e){var n=e.input,i=e.SetInput,a=e.error,o=e.SetError,c=e.minValue,u=e.maxValue,s=e.adornment,m=e.size,d=l(""),h=r(d,2),f=h[0],b=h[1],v=l(!1),y=r(v,2),g=y[0],O=y[1],x={};return"small"===m&&(x={maxWidth:75}),K(t.Fragment,{children:[_(X,{size:"small",sx:x,onChange:function(e){return function(e){var r=!1,t=e.target.value;t.match(/[0-9-]*/)[0]&&t.match(/[0-9-]*/)[0]===t||(r=!0,b("Input is not numerical.")),(t>u||t<c)&&(r=!0,b("Input is outside allowed boundaries.")),i(t),o(r),O(r)}(e)},value:n,error:a,inputProps:{inputMode:"numeric"},InputProps:{endAdornment:_(Z,{position:"end",children:s})}}),_(p,{alert:g,SetAlert:O,message:f})]})}function be(e){var r=e.spec,t=e.value,n=i(ce).heliumLookupData.lookup;return t=t<0||!t?0:Number(t),n[r].find(function(e){return e.level===t}).liters}function ve(e){var r=e.spec,t=e.value,n=i(ce).heliumLookupData.lookup;((t=Number(t)||0)<0||!t)&&(t=0);var l=Math.max.apply(null,n[r].map(function(e){return e.liters}))-n[r].find(function(e){return e.level===t}).liters;return l=Math.round(10*l)/10}function ye(e){var t=e.spec,n=i(ce),a=n.heliumLookupData.lookup,o=n.heliumData,c=n.SetHeliumData,u=n.SetLevelsEdited,s=Number(o.helium[t])||0,m=Math.max.apply(null,a[t].map(function(e){return e.level})),d=l(!1),p=r(d,2),h=p[0],f=p[1],v=l(s),y=r(v,2),g=y[0],O=y[1],x=l(!1),j=r(x,2),S=j[0],k=j[1];return K(T,h?{children:[_(fe,{input:g,SetInput:O,error:S,SetError:k,minValue:0,maxValue:m,adornment:"%",size:"small"}),_(R,{disabled:S,onClick:function(){c(function(e){e.helium[t]=Number(g)}),f(!h),u(!0)},children:_(U,{})})]}:{children:[b(s,!0),_(R,{size:"small",onClick:function(){return f(!h)},children:_(Q,{})})]})}function ge(){var e=i(ce),r=e.heliumData;if(e.SetHeliumData,e.SetLevelsEdited,0===r.helium.length)return _(u,{children:_("em",{children:"No Helium data found."})});var t=Object.keys(r.helium).reduce(function(e,t){return e+ve({spec:t,value:r.helium[t]})},0);return t=Math.round(10*t)/10,K(m,{children:[_(Y,{children:K(G,{children:[_(d,{children:"Spectrometer"}),K(d,{children:["Helium level",_("br",{}),"[%]"]}),K(d,{children:["Helium level",_("br",{}),"[liters]"]}),K(d,{children:["Diff. to maximum",_("br",{}),"[liters]"]})]})}),_(B,{children:Object.keys(r.helium).map(function(e){return K(G,{children:[_(T,{children:e}),_(ye,{spec:e}),_(T,{children:_(be,{spec:e,value:r.helium[e]})}),_(T,{children:_("strong",{children:_(ve,{spec:e,value:r.helium[e]})})})]},e+"_entry")})}),_("tfoot",{children:K(G,{children:[_(T,{children:_("strong",{children:"Sum"})}),_(T,{}),_(T,{}),_(T,{children:_("strong",{children:t})})]})})]})}function Oe(){return i(ce).levelsEdited?K(t.Fragment,{children:[", ",_("strong",{children:"edited"})]}):null}function xe(){var e=i(ce),r=e.heliumData;return e.levelsEdited,K(f,{title:"Helium Calculator",size:e.cardSize,collapsed:e.collapsed,sx:{mb:e.bottomMargin},children:[_(u,{children:K(h,{children:[_("strong",{children:"Current levels"})," ",K("em",{children:[r.meta.date||0!==r.meta.date?"(updated "+x(r.meta.date).fromNow()+")":"(manual)",_(Oe,{})]})]})}),_(u,{children:_(ge,{})})]})}function je(e){var n=e.limit,i=e.SetLimit,a=e.error,o=e.SetError,c=l(n),u=r(c,2),s=u[0],m=u[1],d=l(!1),p=r(d,2),h=p[0],f=p[1];return K(t.Fragment,h?{children:[_(fe,{input:s,SetInput:m,error:a,SetError:o,size:"medium",adornment:"L"})," ",_(R,{disabled:a,size:"small",onClick:function(){f(!h),i(Number(s))},children:_(U,{})})]}:{children:[n," L"," ",_(R,{size:"small",onClick:function(){return f(!h)},children:_(Q,{})})]})}function Se(e){var r=e.specs,t=e.SetSpecs;function n(e){t(function(r){Object.keys(r).map(function(t){return r[t]=e})})}return K(te,{children:[_(ee,{textAlign:"left",children:_("strong",{children:"Select spectrometers"})}),K(H,{row:!0,sx:{px:2},children:[Object.keys(r).map(function(e){return _(I,{control:_(ne,{size:"small"}),checked:r[e],onChange:function(){return t(function(r){r[e]=!r[e]})},label:e},e+"_check")})," ",_(F,{size:"small",onClick:function(){return n(!0)},children:"all"})," "," "," ",_(F,{size:"small",onClick:function(){return n(!1)},children:"none"})]})]})}function ke(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function De(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ke(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):ke(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function we(e){var r=e.children,t=e.title;return _(u,{children:K(m,{children:[_(Y,{children:_(G,{children:_(d,{children:t})})}),_(B,{children:_(G,{children:_(T,{children:r})})})]})})}function Pe(e){var r=e.minPair;if(0!==r.length){var t=new Date;t.setDate(t.getDate()+r[2]);var n=$(t).format("ll");return K(we,{title:"Pair",children:[_("strong",{children:r[0]})," and ",_("strong",{children:r[1]})," in"," ",K("strong",{children:[r[2]," days"]})," (",n,")"]})}return _(we,{title:"Pair",children:_("em",{children:"No spectrometer pair reaches the target value."})})}function Me(e){var r=e.minTriple;if(0!==r.length){var t=new Date;t.setDate(t.getDate()+r[3]);var n=$(t).format("ll");return K(we,{title:"Triple",children:[_("strong",{children:r[0]}),", ",_("strong",{children:r[1]}),", and"," ",_("strong",{children:r[2]})," in ",K("strong",{children:[r[3]," days"]})," ","(",n,")"]})}return _(we,{title:"Triple",children:_("p",{children:_("em",{children:"No spectrometer triple reaches the target value."})})})}function ze(){var n=i(ce),a=n.heliumLookupData,c=n.heliumData,s=a.boilOff,m={};Object.keys(s).map(function(r){return m=De(De({},m),{},e({},r,!0))});var d=o(m),p=r(d,2),h=p[0],f=p[1],b=Object.keys(h).filter(function(e){return h[e]}),v=l(!1),y=r(v,2),g=y[0],O=y[1],x=l(100),j=r(x,2),S=j[0],k=j[1],D=function(e){var r=e.currSpecs,t=e.heliumData,n=e.boilOff,i=e.limit,l=[];r.map(function(e){r.map(function(r){e!==r&&l.push([e,r].sort())})}),l=Array.from(new Set(l.map(JSON.stringify)),JSON.parse);var a=[],o=function(){var e=1,r=0;a.push(l[c]);do{r=l[c].reduce(function(r,i){var l=Math.round(t.helium[i]+e*n[i]);return l<0&&(l=0),r+ve({value:l,spec:i})},0),e++}while(r<i&&e<300);a[c].push(e),a[c].push(r),a[c].push(r>i)};for(var c in l)o();var u=[];switch((a=a.filter(function(e){return e[4]})).length){case 0:u=[];break;case 1:u=ie(a);break;default:u=a.reduce(function(e,r){return r[2]<e[2]?r:e})}return u.flat()}(De({},{currSpecs:b,heliumData:c,boilOff:s,limit:S})),w=function(e){var r=e.currSpecs,t=e.heliumData,n=e.boilOff,i=e.limit,l=[];r.map(function(e){r.map(function(t){r.map(function(r){e!==t&&t!==r&&r!==e&&l.push([e,t,r].sort())})})}),l=Array.from(new Set(l.map(JSON.stringify)),JSON.parse);var a=[],o=function(){var e=1,r=0;a.push(l[c]);do{r=l[c].reduce(function(r,i){var l=Math.round(t.helium[i]+e*n[i]);return l<0&&(l=0),r+ve({value:l,spec:i})},0),e++}while(r<i&&e<300);a[c].push(e),a[c].push(r),a[c].push(r>i)};for(var c in l)o();var u=[];switch((a=a.filter(function(e){return e[5]})).length){case 0:u=[];break;case 1:u=ie(a);break;default:u=a.reduce(function(e,r){return r[3]<e[3]?r:e})}return u.flat()}(De({},{currSpecs:b,heliumData:c,boilOff:s,limit:S}));return _(t.Fragment,{children:K(u,{container:!0,columns:{xs:6,md:12},children:[K(u,{sx:{px:2},size:6,children:[_(ee,{textAlign:"left",children:_("strong",{children:"Find earliest set of spectrometers requiring"})}),_(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:_(re,{variant:"h4",children:_(je,{limit:S,SetLimit:k,error:g,SetError:O})})}),_(u,{children:_(Se,{specs:h,SetSpecs:f})})]}),K(u,{sx:{px:2},size:6,children:[_(ee,{textAlign:"left",children:_("strong",{children:"Result"})}),K(u,{sx:{px:3},children:[_(Pe,{minPair:D}),_(Me,{minTriple:w})]})]})]})})}function Ce(){var e=i(ce);return _(f,{title:"Spectrometer Set",size:e.cardSize,collapsed:e.collapsed,sx:{mb:e.bottomMargin},children:_(u,{children:_(ze,{})})})}function Ee(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function Le(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ee(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Ee(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function Ne(){var e=i(ce).heliumLookupData,r=e.boilOff,n=e.lookup,l=[];return Object.keys(n).map(function(e){return l.push({name:e,liters:(n[e].filter(function(e){return 100===e.level})[0].liters-n[e].filter(function(e){return 50===e.level})[0].liters).toFixed(1),days:(-50/r[e]).toFixed(1)})}),l=l.map(function(e){return Le(Le({},e),{},{perDay:e.liters/e.days,perMonth:(e.liters/e.days*30).toFixed(1),perYear:(e.liters/e.days*365).toFixed(1)})}),K(t.Fragment,{children:[_("p",{children:"Helium consumption estimated based on lookup values."}),K(m,{children:[_(Y,{children:K(G,{children:[_(d,{}),l.map(function(e){return _(d,{children:e.name},"Head"+e.name)}),_(d,{children:"Sum"})]})}),K(B,{children:[K(G,{children:[_(T,{children:"per month"}),l.map(function(e){return K(T,{children:[e.perMonth," L ",_("br",{}),"(",(.79*e.perMonth).toFixed(2)," m",_("sup",{children:"3"})," Gas)"]},"perMonth"+e.name)}),_(T,{children:K("strong",{children:[l.reduce(function(e,r){return e+Number(r.perMonth)},0).toFixed(1)," ","L",_("br",{}),"(",(.79*l.reduce(function(e,r){return e+Number(r.perMonth)},0)).toFixed(2)," ","m",_("sup",{children:"3"})," Gas)"]})})]}),K(G,{children:[_(T,{rowSpan:2,children:"per year"}),l.map(function(e){return K(T,{children:[e.perYear," L ",_("br",{}),"(",(.79*e.perYear).toFixed(2)," m",_("sup",{children:"3"})," Gas)"]},"perYear"+e.name)}),_(T,{children:K("strong",{children:[l.reduce(function(e,r){return e+Number(r.perYear)},0).toFixed(1)," ","L",_("br",{}),"(",(.79*l.reduce(function(e,r){return e+Number(r.perYear)},0)).toFixed(2)," ","m",_("sup",{children:"3"})," Gas)"]})})]})]})]})]})}function Fe(){var e=i(ce),r=e.cardSize,t=e.collapsed;return _(f,{title:"Estimated Consumption",size:r,collapsed:t,sx:{mb:e.bottomMargin},children:_(u,{children:_(Ne,{})})})}function He(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function Ie(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?He(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):He(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}var Ae=s.palette.primary.main,Ye=s.palette.primary.contrastText,Te=s.palette.warning.main;function Ge(e){var r=e.value,t=e.days,n=e.spec,l=i(ce).heliumLookupData,a=l.boilOff,o=l.minima,c=Math.round(r+t*a[n]);c<0&&(c=0);var u=be({value:c,spec:n}),s=ve({value:c,spec:n}),m={};return c<o[n]-30*a[n]?m={backgroundColor:Ae,color:Ye}:c<o[n]-60*a[n]&&(m={color:Te}),K(T,{sx:m,children:[b(c,!0)," ",_("br",{}),u," L",_("br",{}),K("strong",{children:[s," L"]})]})}function Be(r){var t=r.currHeliumData,n=r.days,l=i(ce).heliumLookupData.boilOff,a={};Object.keys(t).map(function(r){return a=Ie(Ie({},a),{},e({},r,Math.round(t[r]+n*l[r]))),null});var o=Object.keys(a).reduce(function(e,r){return e+ve({spec:r,value:a[r]})},0);return o=Math.round(10*o)/10,_(T,{children:K("strong",{children:[o," L"]})})}function _e(e){var t=e.days,n=e.increments,i=e.SetIncrements,a=e.dates,o=l(!1),c=r(o,2),u=c[0],s=c[1],m=l(t),d=r(m,2),p=d[0],h=d[1],f=l(!1),b=r(f,2),v=b[0],y=b[1];return K(T,u?{children:[a[t]," ",_("br",{}),_(fe,{input:p,SetInput:h,error:v,SetError:y,size:"small"}),_("br",{}),_(R,{disabled:v,size:"small",onClick:function(){s(!u),i(n.map(function(e){return e===t?Number(p):e}))},children:_(U,{})}),_(R,{size:"small",onClick:function(){return i(n.filter(function(e){return e!==t}))},children:_(oe,{})})]}:{children:[a[t]," ",_("br",{})," in ",t," days ",_("br",{}),_(R,{size:"small",onClick:function(){return s(!u)},children:_(Q,{})}),_(R,{size:"small",onClick:function(){return i(n.filter(function(e){return e!==t}))},children:_(oe,{})})]})}function Ke(e){var r=e.increments,n=e.SetIncrements,i=e.currHeliumData,l=e.dates;return _(t.Fragment,{children:r.map(function(e){return K(G,{children:[_(_e,{days:e,increments:r,SetIncrements:n,dates:l}),Object.keys(i).map(function(r){return _(Ge,{value:i[r],days:e,spec:r},r+"_progentry")}),_(Be,{currHeliumData:i,days:e})]},e+"_incr")})})}function Je(e){var n=e.increments,i=e.SetIncrements,a=l(""),o=r(a,2),c=o[0],s=o[1],m=l(!1),d=r(m,2),p=d[0],h=d[1];return K(t.Fragment,{children:[_(ee,{textAlign:"left",children:_("strong",{children:"Add prediction row"})}),K(u,{children:[_(fe,{input:c,SetInput:s,error:p,SetError:h,adornment:"days",size:"medium"}),_(R,{disabled:p,onClick:function(){i([Number(c)].concat(ie(n)))},children:_(ae,{})})]})]})}function Ve(){var t=i(ce),n=t.heliumLookupData,a=t.heliumData,c=n.minima,s={};Object.keys(a.helium).map(function(r){return s=Ie(Ie({},s),{},e({},r,!0))});var p=o(s),h=r(p,2),f=h[0],b=h[1],v=l([14,30,60,90]),y=r(v,2),g=y[0],O=y[1],j={};Object.keys(f).filter(function(e){return f[e]}).map(function(r){return j=Ie(Ie({},j),{},e({},r,a.helium[r]))});var S={};for(var k in g){var D=new Date;D.setDate(D.getDate()+g[k]),S=Ie(Ie({},S),{},e({},g[k],x(D).format("ll")))}return K(u,{container:!0,columns:{xs:6,sm:12},children:[_(u,{size:6,children:_(Se,{specs:f,SetSpecs:b})}),_(u,{size:6,children:_(Je,{increments:g,SetIncrements:O})}),_(u,{size:12,children:K(m,{children:[K(Y,{children:[K(G,{children:[_(d,{}),Object.keys(j).map(function(e){return K(d,{children:[e,_("br",{}),"(",c[e]," %)"]},e+"_th")}),_(d,{children:"Sum"})]}),K(G,{children:[_(d,{}),_(d,{align:"center",colSpan:Object.keys(f).length+1,children:_("em",{children:"[%], Liters, L. to max"})})]})]}),_(B,{children:_(Ke,{increments:g,SetIncrements:O,dates:S,currHeliumData:j})})]})}),K(u,{sx:{display:"flex",justifyContent:"center",alignItems:"center",pt:2},size:12,children:[_(le,{sx:{backgroundColor:Ae,color:Ye,mx:1},label:"Minimum in less than 30 days"}),_(le,{sx:{color:Te,mx:1},variant:"outlined",label:"Minimum in less than 60 days"})]})]})}function We(){var e=i(ce);return _(f,{title:"Helium Estimation",size:e.cardSize,sx:{mb:e.bottomMargin},children:_(Ve,{})})}function qe(){var e=i(ce),n=e.heliumLookupData,a=e.heliumData,o=n.boilOff,c=n.lookup,m=l(!1),d=r(m,2),p=d[0],h=d[1],f=l(25),b=r(f,2),y=b[0],g=b[1],O=l(Object.keys(c)[0]),x=r(O,2),j=x[0],S=x[1],k=a.helium[j],D=be({value:k,spec:j}),w=function(e){var r=e.spec,t=e.value,n=i(ce).heliumLookupData.lookup,l=0;if((t=t<0||!t?0:Number(t))>n[r].find(function(e){return 100===e.level}).liters)l=100;else{var a=n[r].reduce(function(e,r){return Math.abs(r.liters-t)<Math.abs(e.liters-t)?r:e}).liters;l=n[r].find(function(e){return e.liters===a}).level}return l}({value:D+y,spec:j});return _(t.Fragment,{children:K(u,{container:!0,columns:{xs:6,md:12},children:[K(u,{sx:{px:2},size:6,children:[_(ee,{textAlign:"left",children:_("strong",{children:"Select Spectrometer"})}),_(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:_(v,{setup:o,spec:j,SetSpec:S})})]}),K(u,{sx:{px:2},size:6,children:[_(ee,{textAlign:"left",children:_("strong",{children:"Current status"})}),_(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:K(re,{variant:"h4",children:[k," % (",D," L)"]})})]}),K(u,{sx:{px:2},size:6,children:[_(ee,{textAlign:"left",children:_("strong",{children:"Helium fill amount"})}),_(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:_(re,{variant:"h4",children:_(je,{error:p,SetError:h,limit:y,SetLimit:g})})})]}),K(u,{sx:{px:2},size:6,children:[_(ee,{textAlign:"left",children:_("strong",{children:"After filling"})}),_(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:_(re,{variant:"h4",children:K("em",{style:{color:s.palette.warning.main},children:["~ ",w," % (",be({value:w,spec:j})," L)"]})})})]})]})})}function Re(){var e=i(ce);return _(f,{title:"Fill Target",size:e.cardSize,sx:{mb:e.bottomMargin},children:_(qe,{})})}function Ue(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}var Qe=process.env.HELIUM_LOOKUP||{lookup:{}};console.log("Helium Lookup Data:",Qe);var Xe=process.env.SITE_CONFIG||{};function Ze(t){var n=Xe.basePath||t.basePath||"",i=o(null),m=r(i,2),d=m[0],p=m[1],h=l(!1),f=r(h,2),b=f[0],v=f[1],x=l(!1),j=r(x,2),S=j[0],k=j[1],D=l(null),w=r(D,2),P=w[0],M=w[1],z=c(s.breakpoints.up("lg")),C=z?t.maxHeight||1280:1e6,E=z?6:12,L=!z,N=Xe.showGraphs?y({url:n+"/graphdata.json"}):{};if(y({url:n+"/helium.json",SetState:p,SetError:M}),a(function(){P&&(p(function(e){e.helium={}}),Object.keys(Qe.lookup).map(function(e){p(function(r){r.helium[e]=0})}),p(function(e){e.meta={},e.meta.date=0}),k(!0))},[P]),a(function(){null!==d&&null===P&&(Object.keys(Qe.lookup).map(function(e){p(function(r){r.helium[e]=Number(r.helium[e])})}),k(!0))},[d]),!d||!N||!S)return _(g,{});var F=N.meta,H=function(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ue(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Ue(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}({},N);delete H.meta,F||(F={});var I={heliumData:d,SetHeliumData:p,levelsEdited:b,SetLevelsEdited:v,heliumLookupData:Qe,cardSize:E,collapsed:L,matches:z,bottomMargin:1};return _(O,{children:K(ce.Provider,{value:I,children:[Xe.showGraphs?_(he,{graphData:H,graphDataMeta:F}):null,K(u,{sx:{display:"flex",flexFlow:"column wrap",maxHeight:C},children:[_(xe,{}),_(Ce,{}),_(Fe,{}),_(We,{}),_(Re,{})]})]})})}console.log("Site Config:",Xe);export{Ze as default};
1
+ import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import t,{createContext as n,useContext as i,useState as l,useEffect as a}from"react";import{useImmer as o}from"use-immer";import c from"@mui/material/useMediaQuery";import u from"@mui/material/Grid";import{AppTheme as s,AppTable as m,TableHeadCell as d,ErrorAlert as p,DivTitle as h,AppCard as f,Percentage as b,SpecSwitch as v,PublicFetch as y,Progress as g,AppGrid as O}from"@zac-apps/commons";import x from"moment";import j from"@mui/material/Paper";import{LineChart as S,Line as k,DefaultZIndexes as D,CartesianGrid as w,XAxis as P,Label as M,YAxis as C,ReferenceLine as z,ReferenceArea as E,Tooltip as L}from"recharts";import N from"@mui/material/ButtonGroup";import F from"@mui/material/Button";import H from"@mui/material/FormGroup";import I from"@mui/material/FormControlLabel";import A from"@mui/material/Switch";import Y from"@mui/material/TableHead";import T from"@mui/material/TableCell";import G from"@mui/material/TableRow";import _ from"@mui/material/TableBody";import{jsx as B,jsxs as K}from"react/jsx-runtime";import J from"regression";import{mean as V,sqrt as W,sum as q}from"mathjs";import R from"@mui/material/IconButton";import U from"@mui/icons-material/Save";import Q from"@mui/icons-material/Edit";import X from"@mui/material/TextField";import Z from"@mui/material/InputAdornment";import $ from"moment/moment.js";import ee from"@mui/material/Divider";import re from"@mui/material/Typography";import te from"@mui/material/FormControl";import ne from"@mui/material/Checkbox";import ie from"@babel/runtime/helpers/toConsumableArray";import le from"@mui/material/Chip";import ae from"@mui/icons-material/AddBox";import oe from"@mui/icons-material/Delete";var ce=n(null);function ue(e){var r=e.spec,t=e.estimatedBoiloff,n=e.estimatedError,l=i(ce).heliumLookupData.boilOff[r].toFixed(3)||"N/A";t=t.toFixed(3)||"N/A",n=n.toFixed(3)||"N/A";var a=Math.abs(t-l)<.01?t:B("strong",{style:{color:s.palette.primary.main},children:t});return K("div",{children:[B("h4",{children:"Boiloff coefficients (%/day)"}),B(u,{container:!0,children:K(m,{children:[B(Y,{children:K(G,{children:[B(d,{children:"Estimated"}),B(d,{children:"Stored"})]})}),B(_,{children:K(G,{children:[K(T,{children:[a," ",K("em",{style:{color:s.palette.secondary.main},children:["(±",n,")"]})]}),B(T,{children:l})]})})]})})]})}function se(e){var r=x(),t=x(e);return r.diff(t,"days")}function me(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function de(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?me(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):me(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function pe(e){var n=e.data,o=e.height,c=e.width,u=e.spec,m=i(ce).heliumLookupData,d=l(!1),h=r(d,2),f=h[0],b=h[1],v=l(""),y=r(v,2),g=y[0],O=y[1],j=process.env.SITE_CONFIG.alertDuration||5e3,Y=process.env.SITE_CONFIG.daysbeforeAlert||2,T=function(e){var r=e.data;e.spec;for(var t,n,i=Number(r[r.length-1].level),l=r.length-1,a=r.length-1,o=Number(r[a].level),c=r.length-2;c>=0;c--){var u=Number(r[c].level);if(u>i&&(o=u,a=c),u<o)break}a>=r.length-45&&(l=a-1,i=Number(r[l].level));for(var s=l-1,m=Number(r[s].level),d=s,p=s-1;p>=0;p--){var h=Number(r[p].level);if(h>m&&(m=h,d=p),h<m-1||h>=90)break}for(var f=[],b=d;b<=s;b++)f.push([r.length-se(r[b].date),Number(r[b].level)]);var v=J.linear(f,{precision:6});t=v.equation[0],n=v.equation[1];for(var y=[],g=d;g<=s;g++)y.push([g,g*t+n]);var O=V(f.map(function(e){return e[0]})),x=W(1/(y.length-2)*q(f.map(function(e,r){return Math.pow(e[1]-y[r][1],2)}))/q(f.map(function(e,r){return Math.pow(e[0]-O,2)})));return{slope:t,intercept:n,slopeError:x}}(de({},{data:n,spec:u})),G=T.slope,_=T.intercept,R=T.slopeError,U=function(e){var r=e.active,t=e.payload,n=e.label;if(r&&t&&t.length){var i=x(t[0].payload.date,"ddd MMM D HH:mm:ss YYYY").format("LL");return K("div",{style:{border:"solid 1px "+s.palette.secondary.main,padding:"0.75em",backgroundColor:"#ffffffaa"},children:[B("strong",{children:i}),B("br",{}),K("em",{children:["(",n," days ago)"]}),B("br",{}),K("strong",{style:{color:s.palette.primary.main},children:[t[0].value," %"]})]})}};function Q(e){var r=e.value;return B(F,{onClick:function(){return ee(r)},color:r===$?"primary":"secondary",variant:r===$?"contained":"outlined",size:"small",children:r})}var X=l(90),Z=r(X,2),$=Z[0],ee=Z[1],re=l(!0),te=r(re,2),ne=te[0],ie=te[1],le=l(!1),ae=r(le,2),oe=ae[0],me=ae[1],pe=(n||[]).map(function(e){return de(de({},e),{},{days:-x(e.date,"ddd MMM D HH:mm:ss YYYY").diff(x(),"days")})}),he=0;pe.length>0&&(he=x().diff(x(pe[pe.length-1].date,"ddd MMM D HH:mm:ss YYYY"),"days")),a(function(){he>Y&&(b(!0),O("WARNING: Heliumlog of ".concat(u," has not been updated since ").concat(he," days ago.")))},[he]);var fe=pe.map(function(e){var r=e.days,t=e.level,n=G*(pe.length-r+he)+_;return{date:e.date,days:r,level:t,estimate:n}}),be=oe?s.palette.grey[300]:s.palette.primary.main;return K(t.Fragment,{children:[B(p,{alert:f,SetAlert:b,autoHideDuration:j,message:g}),K(S,{height:o,width:c,data:fe,margin:{top:5,right:20,bottom:25,left:0},children:[B(k,{dataKey:"level",stroke:be,fill:be,type:"linear",dot:{r:1.5}}),oe&&B(k,{dataKey:"estimate",stroke:s.palette.action.main,type:"monotone",strokeDasharray:"5 5",strokeWidth:2,dot:!1,zIndex:D.scatter+1}),B(w,{stroke:s.palette.divider,strokeDasharray:"5 5"}),B(P,{dataKey:"days",type:"number",interval:"preserveStartEnd",domain:[$,0],allowDataOverflow:!0,children:B(M,{value:"Days ago",offset:1,position:"bottom"})}),B(C,{dataKey:"level",unit:"%",type:"number",orientation:"right",domain:[0,100]}),ne&&K(t.Fragment,{children:[B(z,{y:m.minima[u],stroke:s.palette.secondary.main,strokeDasharray:3}),B(E,{y1:m.minima[u],y2:0,stroke:"none",stro:!0,fill:s.palette.secondary.main,fillOpacity:.1})]}),B(L,{content:B(U,{})})]}),K(N,{disableElevation:!0,variant:"outlined",fullWidth:!0,color:"secondary","aria-label":"contained primary button group",sx:{justifySelf:"center",px:5},size:"small",children:[B(Q,{value:7}),B(Q,{value:30}),B(Q,{value:90}),B(Q,{value:180}),B(Q,{value:365})]}),K(H,{children:[B(I,{control:B(A,{label:"Show Minimum",checked:ne,onChange:function(){return ie(!ne)}}),label:"Show Minimum",sx:{justifyContent:"center"}}),B(I,{control:B(A,{label:"Show Estimate",checked:oe,onChange:function(){return me(!oe)}}),label:"Show Estimate",sx:{justifyContent:"center"}})]}),B(ue,{spec:u,estimatedBoiloff:G,estimatedError:R})]})}function he(e){var r=e.graphData,n=e.graphDataMeta,l=e.matches,a=l?250:200,o=l?300:280,c=i(ce).heliumLookupData;return Object.keys(r).forEach(function(e){c.boilOff[e]||delete r[e]}),r.error?K(t.Fragment,{children:[B(h,{children:B("strong",{children:"Helium level monitoring"})}),B(u,{sx:{display:"flex",justifyContent:"center"},children:B("em",{children:"No graph data available"})})]}):K(t.Fragment,{children:[K(h,{children:[B("strong",{children:"Helium level monitoring"})," ",K("em",{children:["(updated ",x(n.date).fromNow(),")"]})]}),B(u,{container:!0,sx:{display:"flex",justifyContent:"center"},children:Object.keys(r).map(function(e){return K(j,{sx:{display:"flex",flexDirection:"column",justifyItems:"center",stroke:s.palette.divider,px:2,paddingBottom:2,margin:2},children:[B("h4",{children:e}),B(pe,{data:r[e],height:a,width:o,spec:e})]},"graph_"+e)})})]})}function fe(e){var r=e.graphData,t=e.graphDataMeta,n=i(ce),l=n.collapsed,a=n.matches;return B(f,{title:"Helium Graphs",size:12,collapsed:l,children:B(he,{graphData:r,graphDataMeta:t,matches:a})})}function be(e){var n=e.input,i=e.SetInput,a=e.error,o=e.SetError,c=e.minValue,u=e.maxValue,s=e.adornment,m=e.size,d=l(""),h=r(d,2),f=h[0],b=h[1],v=l(!1),y=r(v,2),g=y[0],O=y[1],x={};return"small"===m&&(x={maxWidth:75}),K(t.Fragment,{children:[B(X,{size:"small",sx:x,onChange:function(e){return function(e){var r=!1,t=e.target.value;t.match(/[0-9-]*/)[0]&&t.match(/[0-9-]*/)[0]===t||(r=!0,b("Input is not numerical.")),(t>u||t<c)&&(r=!0,b("Input is outside allowed boundaries.")),i(t),o(r),O(r)}(e)},value:n,error:a,inputProps:{inputMode:"numeric"},InputProps:{endAdornment:B(Z,{position:"end",children:s})}}),B(p,{alert:g,SetAlert:O,message:f})]})}function ve(e){var r=e.spec,t=e.value,n=i(ce).heliumLookupData.lookup;return t=t<0||!t?0:Number(t),n[r].find(function(e){return e.level===t}).liters}function ye(e){var r=e.spec,t=e.value,n=i(ce).heliumLookupData.lookup;((t=Number(t)||0)<0||!t)&&(t=0);var l=Math.max.apply(null,n[r].map(function(e){return e.liters}))-n[r].find(function(e){return e.level===t}).liters;return l=Math.round(10*l)/10}function ge(e){var t=e.spec,n=i(ce),a=n.heliumLookupData.lookup,o=n.heliumData,c=n.SetHeliumData,u=n.SetLevelsEdited,s=Number(o.helium[t])||0,m=Math.max.apply(null,a[t].map(function(e){return e.level})),d=l(!1),p=r(d,2),h=p[0],f=p[1],v=l(s),y=r(v,2),g=y[0],O=y[1],x=l(!1),j=r(x,2),S=j[0],k=j[1];return K(T,h?{children:[B(be,{input:g,SetInput:O,error:S,SetError:k,minValue:0,maxValue:m,adornment:"%",size:"small"}),B(R,{disabled:S,onClick:function(){c(function(e){e.helium[t]=Number(g)}),f(!h),u(!0)},children:B(U,{})})]}:{children:[b(s,!0),B(R,{size:"small",onClick:function(){return f(!h)},children:B(Q,{})})]})}function Oe(){var e=i(ce),r=e.heliumData;if(e.SetHeliumData,e.SetLevelsEdited,0===r.helium.length)return B(u,{children:B("em",{children:"No Helium data found."})});var t=Object.keys(r.helium).reduce(function(e,t){return e+ye({spec:t,value:r.helium[t]})},0);return t=Math.round(10*t)/10,K(m,{children:[B(Y,{children:K(G,{children:[B(d,{children:"Spectrometer"}),K(d,{children:["Helium level",B("br",{}),"[%]"]}),K(d,{children:["Helium level",B("br",{}),"[liters]"]}),K(d,{children:["Diff. to maximum",B("br",{}),"[liters]"]})]})}),B(_,{children:Object.keys(r.helium).map(function(e){return K(G,{children:[B(T,{children:e}),B(ge,{spec:e}),B(T,{children:B(ve,{spec:e,value:r.helium[e]})}),B(T,{children:B("strong",{children:B(ye,{spec:e,value:r.helium[e]})})})]},e+"_entry")})}),B("tfoot",{children:K(G,{children:[B(T,{children:B("strong",{children:"Sum"})}),B(T,{}),B(T,{}),B(T,{children:B("strong",{children:t})})]})})]})}function xe(){return i(ce).levelsEdited?K(t.Fragment,{children:[", ",B("strong",{children:"edited"})]}):null}function je(){var e=i(ce),r=e.heliumData;return e.levelsEdited,K(f,{title:"Helium Calculator",size:e.cardSize,collapsed:e.collapsed,sx:{mb:e.bottomMargin},children:[B(u,{children:K(h,{children:[B("strong",{children:"Current levels"})," ",K("em",{children:[r.meta.date||0!==r.meta.date?"(updated "+x(r.meta.date).fromNow()+")":"(manual)",B(xe,{})]})]})}),B(u,{children:B(Oe,{})})]})}function Se(e){var n=e.limit,i=e.SetLimit,a=e.error,o=e.SetError,c=l(n),u=r(c,2),s=u[0],m=u[1],d=l(!1),p=r(d,2),h=p[0],f=p[1];return K(t.Fragment,h?{children:[B(be,{input:s,SetInput:m,error:a,SetError:o,size:"medium",adornment:"L"})," ",B(R,{disabled:a,size:"small",onClick:function(){f(!h),i(Number(s))},children:B(U,{})})]}:{children:[n," L"," ",B(R,{size:"small",onClick:function(){return f(!h)},children:B(Q,{})})]})}function ke(e){var r=e.specs,t=e.SetSpecs;function n(e){t(function(r){Object.keys(r).map(function(t){return r[t]=e})})}return K(te,{children:[B(ee,{textAlign:"left",children:B("strong",{children:"Select spectrometers"})}),K(H,{row:!0,sx:{px:2},children:[Object.keys(r).map(function(e){return B(I,{control:B(ne,{size:"small"}),checked:r[e],onChange:function(){return t(function(r){r[e]=!r[e]})},label:e},e+"_check")})," ",B(F,{size:"small",onClick:function(){return n(!0)},children:"all"})," "," "," ",B(F,{size:"small",onClick:function(){return n(!1)},children:"none"})]})]})}function De(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function we(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?De(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):De(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function Pe(e){var r=e.children,t=e.title;return B(u,{children:K(m,{children:[B(Y,{children:B(G,{children:B(d,{children:t})})}),B(_,{children:B(G,{children:B(T,{children:r})})})]})})}function Me(e){var r=e.minPair;if(0!==r.length){var t=new Date;t.setDate(t.getDate()+r[2]);var n=$(t).format("ll");return K(Pe,{title:"Pair",children:[B("strong",{children:r[0]})," and ",B("strong",{children:r[1]})," in"," ",K("strong",{children:[r[2]," days"]})," (",n,")"]})}return B(Pe,{title:"Pair",children:B("em",{children:"No spectrometer pair reaches the target value."})})}function Ce(e){var r=e.minTriple;if(0!==r.length){var t=new Date;t.setDate(t.getDate()+r[3]);var n=$(t).format("ll");return K(Pe,{title:"Triple",children:[B("strong",{children:r[0]}),", ",B("strong",{children:r[1]}),", and"," ",B("strong",{children:r[2]})," in ",K("strong",{children:[r[3]," days"]})," ","(",n,")"]})}return B(Pe,{title:"Triple",children:B("p",{children:B("em",{children:"No spectrometer triple reaches the target value."})})})}function ze(){var n=i(ce),a=n.heliumLookupData,c=n.heliumData,s=a.boilOff,m={};Object.keys(s).map(function(r){return m=we(we({},m),{},e({},r,!0))});var d=o(m),p=r(d,2),h=p[0],f=p[1],b=Object.keys(h).filter(function(e){return h[e]}),v=l(!1),y=r(v,2),g=y[0],O=y[1],x=l(100),j=r(x,2),S=j[0],k=j[1],D=function(e){var r=e.currSpecs,t=e.heliumData,n=e.boilOff,i=e.limit,l=[];r.map(function(e){r.map(function(r){e!==r&&l.push([e,r].sort())})}),l=Array.from(new Set(l.map(JSON.stringify)),JSON.parse);var a=[],o=function(){var e=1,r=0;a.push(l[c]);do{r=l[c].reduce(function(r,i){var l=Math.round(t.helium[i]+e*n[i]);return l<0&&(l=0),r+ye({value:l,spec:i})},0),e++}while(r<i&&e<300);a[c].push(e),a[c].push(r),a[c].push(r>i)};for(var c in l)o();var u=[];switch((a=a.filter(function(e){return e[4]})).length){case 0:u=[];break;case 1:u=ie(a);break;default:u=a.reduce(function(e,r){return r[2]<e[2]?r:e})}return u.flat()}(we({},{currSpecs:b,heliumData:c,boilOff:s,limit:S})),w=function(e){var r=e.currSpecs,t=e.heliumData,n=e.boilOff,i=e.limit,l=[];r.map(function(e){r.map(function(t){r.map(function(r){e!==t&&t!==r&&r!==e&&l.push([e,t,r].sort())})})}),l=Array.from(new Set(l.map(JSON.stringify)),JSON.parse);var a=[],o=function(){var e=1,r=0;a.push(l[c]);do{r=l[c].reduce(function(r,i){var l=Math.round(t.helium[i]+e*n[i]);return l<0&&(l=0),r+ye({value:l,spec:i})},0),e++}while(r<i&&e<300);a[c].push(e),a[c].push(r),a[c].push(r>i)};for(var c in l)o();var u=[];switch((a=a.filter(function(e){return e[5]})).length){case 0:u=[];break;case 1:u=ie(a);break;default:u=a.reduce(function(e,r){return r[3]<e[3]?r:e})}return u.flat()}(we({},{currSpecs:b,heliumData:c,boilOff:s,limit:S}));return B(t.Fragment,{children:K(u,{container:!0,columns:{xs:6,md:12},children:[K(u,{sx:{px:2},size:6,children:[B(ee,{textAlign:"left",children:B("strong",{children:"Find earliest set of spectrometers requiring"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:B(re,{variant:"h4",children:B(Se,{limit:S,SetLimit:k,error:g,SetError:O})})}),B(u,{children:B(ke,{specs:h,SetSpecs:f})})]}),K(u,{sx:{px:2},size:6,children:[B(ee,{textAlign:"left",children:B("strong",{children:"Result"})}),K(u,{sx:{px:3},children:[B(Me,{minPair:D}),B(Ce,{minTriple:w})]})]})]})})}function Ee(){var e=i(ce);return B(f,{title:"Spectrometer Set",size:e.cardSize,collapsed:e.collapsed,sx:{mb:e.bottomMargin},children:B(u,{children:B(ze,{})})})}function Le(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function Ne(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function Fe(){var e=i(ce).heliumLookupData,r=e.boilOff,n=e.lookup,l=[];return Object.keys(n).map(function(e){return l.push({name:e,liters:(n[e].filter(function(e){return 100===e.level})[0].liters-n[e].filter(function(e){return 50===e.level})[0].liters).toFixed(1),days:(-50/r[e]).toFixed(1)})}),l=l.map(function(e){return Ne(Ne({},e),{},{perDay:e.liters/e.days,perMonth:(e.liters/e.days*30).toFixed(1),perYear:(e.liters/e.days*365).toFixed(1)})}),K(t.Fragment,{children:[B("p",{children:"Helium consumption estimated based on lookup values."}),K(m,{children:[B(Y,{children:K(G,{children:[B(d,{}),l.map(function(e){return B(d,{children:e.name},"Head"+e.name)}),B(d,{children:"Sum"})]})}),K(_,{children:[K(G,{children:[B(T,{children:"per month"}),l.map(function(e){return K(T,{children:[e.perMonth," L ",B("br",{}),"(",(.79*e.perMonth).toFixed(2)," m",B("sup",{children:"3"})," Gas)"]},"perMonth"+e.name)}),B(T,{children:K("strong",{children:[l.reduce(function(e,r){return e+Number(r.perMonth)},0).toFixed(1)," ","L",B("br",{}),"(",(.79*l.reduce(function(e,r){return e+Number(r.perMonth)},0)).toFixed(2)," ","m",B("sup",{children:"3"})," Gas)"]})})]}),K(G,{children:[B(T,{rowSpan:2,children:"per year"}),l.map(function(e){return K(T,{children:[e.perYear," L ",B("br",{}),"(",(.79*e.perYear).toFixed(2)," m",B("sup",{children:"3"})," Gas)"]},"perYear"+e.name)}),B(T,{children:K("strong",{children:[l.reduce(function(e,r){return e+Number(r.perYear)},0).toFixed(1)," ","L",B("br",{}),"(",(.79*l.reduce(function(e,r){return e+Number(r.perYear)},0)).toFixed(2)," ","m",B("sup",{children:"3"})," Gas)"]})})]})]})]})]})}function He(){var e=i(ce),r=e.cardSize,t=e.collapsed;return B(f,{title:"Estimated Consumption",size:r,collapsed:t,sx:{mb:e.bottomMargin},children:B(u,{children:B(Fe,{})})})}function Ie(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function Ae(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ie(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Ie(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}var Ye=s.palette.primary.main,Te=s.palette.primary.contrastText,Ge=s.palette.warning.main;function _e(e){var r=e.value,t=e.days,n=e.spec,l=i(ce).heliumLookupData,a=l.boilOff,o=l.minima,c=Math.round(r+t*a[n]);c<0&&(c=0);var u=ve({value:c,spec:n}),s=ye({value:c,spec:n}),m={};return c<o[n]-30*a[n]?m={backgroundColor:Ye,color:Te}:c<o[n]-60*a[n]&&(m={color:Ge}),K(T,{sx:m,children:[b(c,!0)," ",B("br",{}),u," L",B("br",{}),K("strong",{children:[s," L"]})]})}function Be(r){var t=r.currHeliumData,n=r.days,l=i(ce).heliumLookupData.boilOff,a={};Object.keys(t).map(function(r){return a=Ae(Ae({},a),{},e({},r,Math.round(t[r]+n*l[r]))),null});var o=Object.keys(a).reduce(function(e,r){return e+ye({spec:r,value:a[r]})},0);return o=Math.round(10*o)/10,B(T,{children:K("strong",{children:[o," L"]})})}function Ke(e){var t=e.days,n=e.increments,i=e.SetIncrements,a=e.dates,o=l(!1),c=r(o,2),u=c[0],s=c[1],m=l(t),d=r(m,2),p=d[0],h=d[1],f=l(!1),b=r(f,2),v=b[0],y=b[1];return K(T,u?{children:[a[t]," ",B("br",{}),B(be,{input:p,SetInput:h,error:v,SetError:y,size:"small"}),B("br",{}),B(R,{disabled:v,size:"small",onClick:function(){s(!u),i(n.map(function(e){return e===t?Number(p):e}))},children:B(U,{})}),B(R,{size:"small",onClick:function(){return i(n.filter(function(e){return e!==t}))},children:B(oe,{})})]}:{children:[a[t]," ",B("br",{})," in ",t," days ",B("br",{}),B(R,{size:"small",onClick:function(){return s(!u)},children:B(Q,{})}),B(R,{size:"small",onClick:function(){return i(n.filter(function(e){return e!==t}))},children:B(oe,{})})]})}function Je(e){var r=e.increments,n=e.SetIncrements,i=e.currHeliumData,l=e.dates;return B(t.Fragment,{children:r.map(function(e){return K(G,{children:[B(Ke,{days:e,increments:r,SetIncrements:n,dates:l}),Object.keys(i).map(function(r){return B(_e,{value:i[r],days:e,spec:r},r+"_progentry")}),B(Be,{currHeliumData:i,days:e})]},e+"_incr")})})}function Ve(e){var n=e.increments,i=e.SetIncrements,a=l(""),o=r(a,2),c=o[0],s=o[1],m=l(!1),d=r(m,2),p=d[0],h=d[1];return K(t.Fragment,{children:[B(ee,{textAlign:"left",children:B("strong",{children:"Add prediction row"})}),K(u,{children:[B(be,{input:c,SetInput:s,error:p,SetError:h,adornment:"days",size:"medium"}),B(R,{disabled:p,onClick:function(){i([Number(c)].concat(ie(n)))},children:B(ae,{})})]})]})}function We(){var t=i(ce),n=t.heliumLookupData,a=t.heliumData,c=n.minima,s={};Object.keys(a.helium).map(function(r){return s=Ae(Ae({},s),{},e({},r,!0))});var p=o(s),h=r(p,2),f=h[0],b=h[1],v=l([14,30,60,90]),y=r(v,2),g=y[0],O=y[1],j={};Object.keys(f).filter(function(e){return f[e]}).map(function(r){return j=Ae(Ae({},j),{},e({},r,a.helium[r]))});var S={};for(var k in g){var D=new Date;D.setDate(D.getDate()+g[k]),S=Ae(Ae({},S),{},e({},g[k],x(D).format("ll")))}return K(u,{container:!0,columns:{xs:6,sm:12},children:[B(u,{size:6,children:B(ke,{specs:f,SetSpecs:b})}),B(u,{size:6,children:B(Ve,{increments:g,SetIncrements:O})}),B(u,{size:12,children:K(m,{children:[K(Y,{children:[K(G,{children:[B(d,{}),Object.keys(j).map(function(e){return K(d,{children:[e,B("br",{}),"(",c[e]," %)"]},e+"_th")}),B(d,{children:"Sum"})]}),K(G,{children:[B(d,{}),B(d,{align:"center",colSpan:Object.keys(f).length+1,children:B("em",{children:"[%], Liters, L. to max"})})]})]}),B(_,{children:B(Je,{increments:g,SetIncrements:O,dates:S,currHeliumData:j})})]})}),K(u,{sx:{display:"flex",justifyContent:"center",alignItems:"center",pt:2},size:12,children:[B(le,{sx:{backgroundColor:Ye,color:Te,mx:1},label:"Minimum in less than 30 days"}),B(le,{sx:{color:Ge,mx:1},variant:"outlined",label:"Minimum in less than 60 days"})]})]})}function qe(){var e=i(ce);return B(f,{title:"Helium Estimation",size:e.cardSize,sx:{mb:e.bottomMargin},children:B(We,{})})}function Re(){var e=i(ce),n=e.heliumLookupData,a=e.heliumData,o=n.boilOff,c=n.lookup,m=l(!1),d=r(m,2),p=d[0],h=d[1],f=l(25),b=r(f,2),y=b[0],g=b[1],O=l(Object.keys(c)[0]),x=r(O,2),j=x[0],S=x[1],k=a.helium[j],D=ve({value:k,spec:j}),w=function(e){var r=e.spec,t=e.value,n=i(ce).heliumLookupData.lookup,l=0;if((t=t<0||!t?0:Number(t))>n[r].find(function(e){return 100===e.level}).liters)l=100;else{var a=n[r].reduce(function(e,r){return Math.abs(r.liters-t)<Math.abs(e.liters-t)?r:e}).liters;l=n[r].find(function(e){return e.liters===a}).level}return l}({value:D+y,spec:j});return B(t.Fragment,{children:K(u,{container:!0,columns:{xs:6,md:12},children:[K(u,{sx:{px:2},size:6,children:[B(ee,{textAlign:"left",children:B("strong",{children:"Select Spectrometer"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:B(v,{setup:o,spec:j,SetSpec:S})})]}),K(u,{sx:{px:2},size:6,children:[B(ee,{textAlign:"left",children:B("strong",{children:"Current status"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:K(re,{variant:"h4",children:[k," % (",D," L)"]})})]}),K(u,{sx:{px:2},size:6,children:[B(ee,{textAlign:"left",children:B("strong",{children:"Helium fill amount"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:B(re,{variant:"h4",children:B(Se,{error:p,SetError:h,limit:y,SetLimit:g})})})]}),K(u,{sx:{px:2},size:6,children:[B(ee,{textAlign:"left",children:B("strong",{children:"After filling"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:B(re,{variant:"h4",children:K("em",{style:{color:s.palette.warning.main},children:["~ ",w," % (",ve({value:w,spec:j})," L)"]})})})]})]})})}function Ue(){var e=i(ce);return B(f,{title:"Fill Target",size:e.cardSize,sx:{mb:e.bottomMargin},children:B(Re,{})})}function Qe(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}var Xe=process.env.HELIUM_LOOKUP||{lookup:{}};console.log("Helium Lookup Data:",Xe);var Ze=process.env.SITE_CONFIG||{};function $e(t){var n=Ze.basePath||t.basePath||"",i=o(null),m=r(i,2),d=m[0],p=m[1],h=l(!1),f=r(h,2),b=f[0],v=f[1],x=l(!1),j=r(x,2),S=j[0],k=j[1],D=l(null),w=r(D,2),P=w[0],M=w[1],C=c(s.breakpoints.up("lg")),z=C?t.maxHeight||1280:1e6,E=C?6:12,L=!C,N=Ze.showGraphs?y({url:n+"/graphdata.json"}):{};if(y({url:n+"/helium.json",SetState:p,SetError:M}),a(function(){P&&(p(function(e){e.helium={}}),Object.keys(Xe.lookup).map(function(e){p(function(r){r.helium[e]=0})}),p(function(e){e.meta={},e.meta.date=0}),k(!0))},[P]),a(function(){null!==d&&null===P&&(Object.keys(Xe.lookup).map(function(e){p(function(r){r.helium[e]=Number(r.helium[e])})}),k(!0))},[d]),!d||!N||!S)return B(g,{});var F=N.meta,H=function(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qe(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Qe(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}({},N);delete H.meta,F||(F={});var I={heliumData:d,SetHeliumData:p,levelsEdited:b,SetLevelsEdited:v,heliumLookupData:Xe,cardSize:E,collapsed:L,matches:C,bottomMargin:1};return B(O,{children:K(ce.Provider,{value:I,children:[Ze.showGraphs?B(fe,{graphData:H,graphDataMeta:F}):null,K(u,{sx:{display:"flex",flexFlow:"column wrap",maxHeight:z},children:[B(je,{}),B(Ee,{}),B(He,{}),B(qe,{}),B(Ue,{})]})]})})}console.log("Site Config:",Ze);export{$e as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zac-apps/helium",
3
- "version": "2.2.0-beta.3",
3
+ "version": "2.2.0-beta.5",
4
4
  "scripts": {
5
5
  "rollup": "node_modules/rollup/dist/rollup.js",
6
6
  "dev": "next dev",