@esrf/daiquiri-lib 4.0.0 → 4.0.1
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.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32,6 +32,6 @@ ID21/v-var-ctrl/121 - Serial line OK
|
|
|
32
32
|
Pump size: 75-55-40 SC/T
|
|
33
33
|
`,voltage:6998},Yc="tango",Kc=!0,Qc="pump",Xc={callables:Uc,id:Hc,name:qc,online:zc,properties:Wc,protocol:Yc,require_staff:Kc,type:Qc},Jc={default:Xc};function Fe(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={RETRACTED:"success",IN_TOUCH:"warning",LOST:"warning",MOVING_IN:"transiant",MOVING_OUT:"transiant",UNKNOWN:"danger",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(A,{state:o,minWidth:6,variant:r})}function Zc(n){const{hardware:t}=n;return e.jsx(Fe,{hardware:t})}function el(n){const{className:t,hardware:o,options:s={}}=n,{state:r}=o.properties??"OFFLINE",c=!(r==="IN_TOUCH")||n.disabled;function l(u){const{distance:f}=u,[d,p]=h.useState(!1);return e.jsx(a.Button,{variant:"secondary",onClick:()=>{p(!0),o.actions.call("push",f).finally(()=>{p(!1)})},disabled:c,children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx("i",{className:d?"fa-solid fa-fw fa-cog fa-spin":"fa fa-fw fa-arrow-left"})," ",f]})})}return e.jsxs("div",{className:t,style:{display:"grid",gridTemplateRows:"min-content min-content min-content",gridTemplateColumns:"min-content min-content min-content",gridGap:"1px"},children:[e.jsx(l,{distance:5}),e.jsx(l,{distance:.5}),e.jsx(l,{distance:.05}),e.jsx(l,{distance:2}),e.jsx(l,{distance:.2}),e.jsx(l,{distance:.02}),e.jsx(l,{distance:1}),e.jsx(l,{distance:.1}),e.jsx(l,{distance:.01})]})}function tl(n){const{hardware:t,options:o,disabled:s}=n,{state:r}=t.properties??"OFFLINE",i=r==="RETRACTED",c=r==="IN_TOUCH",l=r==="LOST",[u,f]=h.useState(!1),[d,p]=h.useState(!1),m=i?"ms-auto":c?"ms-0":"mx-auto";return e.jsxs("div",{style:{display:"grid",gridTemplateRows:"min-content min-content",gridTemplateColumns:"min-content auto",gridGap:"1px"},children:[e.jsx("i",{className:`${c||l?"fas fa-dizzy":"fa fa-smile"} fa-3x my-auto`}),e.jsx(el,{className:m,...n}),e.jsx("span",{}),e.jsxs(a.ButtonGroup,{className:"mx-auto",style:{width:"12em"},children:[e.jsx(a.Button,{onClick:()=>{f(!0),t.actions.call("move_in").finally(()=>{f(!1)})},disabled:c||s||u||d,style:{width:"5em"},children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx("i",{className:u?"fa-solid fa-fw fa-cog fa-spin":"fa fa-fw fa-arrow-left"})," ","In"]})}),e.jsx(a.Button,{onClick:()=>{p(!0),t.actions.call("move_out").finally(()=>{p(!1)})},disabled:i||s||u||d,style:{width:"5em"},children:e.jsxs("span",{className:"text-nowrap",children:["Out"," ",e.jsx("i",{className:d?"fa-solid fa-fw fa-cog fa-spin":"fa fa-fw fa-arrow-right"})]})})]})]})}function _t(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Pusher",icon:"fa-hand-point-right",online:t.online}),r=e.jsx(Fe,{hardware:t});function i(){return e.jsx(tl,{...n})}const c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i(),headerMode:c})}const nl={default:_t,state:Zc},ol=nl,sl=["move_in","move_out","push","sync_hard"],rl="pusher",al="pusher",il=!0,cl={state:"RETRACTED"},ll="bliss",dl=!1,ul="pusher",fl={callables:sl,id:rl,name:al,online:il,properties:cl,protocol:ll,require_staff:dl,type:ul},pl={default:fl};function ml(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,i]=h.useState("RETRACTED");async function c(f,d){if(f==="move_in"){i("MOVING_IN"),await k(2e3),i("IN_TOUCH");return}if(f==="move_out"){i("MOVING_OUT"),await k(2e3),i("RETRACTED");return}if(f==="push"){await k(100);return}console.log("PusherSimulator: Unsupported call",f,d)}async function l(f,d){console.log("PusherSimulator: Unsupported setProperty",f,d)}const u={state:r};return e.jsx(H,{name:t,alias:o,type:"pusher",call:c,setProperty:l,properties:u,useHardwareContext:s})}function Ne(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={STOPPED:"danger",STARTING:"transiant",RUNNING:"success",BACKOFF:"warning",STOPPING:"transiant",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"fatal",OFFLINE:"secondary"},r=s[o]||s.UNKNOWN;return e.jsx(A,{state:o,minWidth:6,variant:r})}function hl(n){const{hardware:t}=n;return e.jsx(Ne,{hardware:t})}function $t(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Shutter",icon:"fa-cog",online:t.online}),r=e.jsx(Ne,{hardware:t});function i(){t.actions.call("start")}function c(){t.actions.call("restart")}function l(){t.actions.call("stop")}function u(){return t.properties?t.properties.state:"UNKNOWN"}function f(b){return b.charAt(0).toUpperCase()+b.slice(1).toLowerCase()}const d=u(),p=f(d),g={STOPPED:"danger",STARTING:"transiant",RUNNING:"success",BACKOFF:"warning",STOPPING:"transiant",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"secondary",OFFLINE:"secondary"}[d]||"danger";function w(){const b=d==="RUNNING"||d==="STARTING";return{icon:b?"fa fa-refresh fa-wp":"fa fa-play fa-wp",variant:n.disabled?"":"success",callback:d==="RUNNING"?c:i,disabled:n.disabled,title:n.operator?b?"Restart the service":"Start the serStaticTextInputvice":"You dont have the control to the session"}}function x(){const b=d==="RUNNING"||d==="STARTING";return{icon:"fa fa-stop fa-wp",variant:n.disabled?"":b?"danger":"secondary",callback:l,disabled:n.disabled,title:n.operator?"Stop the service":"You dont have the control to the session"}}const j=w(),N=x(),I=e.jsxs(a.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(E,{variant:g,className:"text-center",style:{minWidth:"8em"},value:p}),e.jsx(a.Button,{style:{width:"2.5em"},variant:"light",className:`px-0 text-${j.variant}`,onClick:j.callback,disabled:j.disabled,title:j.title,children:e.jsx("i",{className:`${j.icon}`})}),e.jsx(a.Button,{style:{width:"2.5em"},variant:"light",className:`px-0 text-${N.variant}`,onClick:N.callback,disabled:N.disabled,title:N.title,children:e.jsx("i",{className:`${N.icon}`})})]}),M=n.options.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:I,headerMode:M})}function xl(n){var u;const{hardware:t,options:o={}}=n;function s(){t.actions.call("start")}function r(){t.actions.call("restart")}function i(){t.actions.call("stop")}const c=((u=t.properties)==null?void 0:u.state)??"UNKNOWN",l=c==="STOPPING"||c==="STARTING";return e.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,placement:o.dropDirection==="up"?"top":"bottom",overlay:e.jsx(a.Popover,{id:"service-protected-overlay",children:e.jsxs(a.Popover.Body,{children:[e.jsx(a.Row,{children:e.jsx(a.Col,{className:"text-center",children:"Actions"})}),e.jsx(a.Row,{children:e.jsxs(a.Col,{children:[c==="RUNNING"&&e.jsxs(a.Button,{className:"me-1 text-success border-secondary",variant:"light",onClick:()=>{r()},disabled:n.disabled,title:"Restart the service",children:[e.jsx("i",{className:"fa fa-refresh fa-wp me-1"}),"Restart"]}),c!=="RUNNING"&&e.jsxs(a.Button,{className:"me-1 text-success border-secondary",variant:"light",onClick:()=>{s()},disabled:n.disabled,title:"Start the service",children:[e.jsx("i",{className:"fa fa-play fa-wp me-1"}),"Start"]}),e.jsxs(a.Button,{className:`text-${c!=="STOPPED"?"danger":"primary"} border-secondary`,variant:"light",onClick:()=>{i()},disabled:n.disabled,title:"Stop the service",children:[e.jsx("i",{className:"fa fa-stop fa-wp me-1"}),"Stop"]})]})})]})}),children:e.jsx(a.Button,{disabled:n.disabled||l,children:e.jsx("i",{className:`fa fa-caret-${o.dropDirection==="up"?"up":"down"}`})})})}function St(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Shutter",icon:"fa-cog",online:t.online}),r=e.jsx(Ne,{hardware:t});function i(){return t.properties?t.properties.state:"UNKNOWN"}function c(g){return g.charAt(0).toUpperCase()+g.slice(1).toLowerCase()}const l=i(),f={STOPPED:"danger",STARTING:"transiant",RUNNING:"success",BACKOFF:"warning",STOPPING:"transiant",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"fatal",OFFLINE:"secondary"}[l],d=c(l),p=e.jsxs(a.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(E,{variant:f,style:{minWidth:"10em"},value:d,className:"text-center"}),e.jsx(xl,{...n})]}),m=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:p,headerMode:m})}const gl={default:$t,protected:St,state:hl},jl=gl,wl=["start","stop","restart"],yl="service1",vl="service1",Nl=!0,bl={state:"RUNNING"},_l="multivisor",$l=!0,Sl="service",Ol={callables:wl,id:yl,name:vl,online:Nl,properties:bl,protocol:_l,require_staff:$l,type:Sl},Cl={default:Ol};function de(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:["success","Ready to be used"],IN:["success","The sample is in the beam"],OUT:["danger","The sample is out of the beam"],MOVING_IN:["transiant","The sample moving in the beam"],MOVING_OUT:["transiant","The sample moving out of the beam"],UNKNOWN:["fatal","The device have an unknown state"]},[r,i]=s[o]||s.UNKNOWN;return e.jsx(A,{state:o,minWidth:6,variant:r,description:i})}function Il(n){const{hardware:t}=n;return e.jsx(de,{hardware:t})}function Ml(n){const{motion:t}=n,s=t.axisRef.slice(9),r=P(s),i=(r==null?void 0:r.alias)??(r==null?void 0:r.name)??(r==null?void 0:r.id)??s;return e.jsx("div",{className:"my-auto",children:i})}function Tl(n){const{motion:t,actions:o,disabled:s}=n,r=t.axisRef;function i(){o.call("update_axis",{axis_ref:r})}return e.jsx(a.Button,{variant:"danger",onClick:i,disabled:s,children:e.jsx("i",{className:"fa fa-trash"})})}function Fl(n){const{motion:t,actions:o,axisRef:s,disabled:r}=n,i=h.useMemo(()=>{for(const d of t)if(d.axisRef===s)return!0;return!1},[t,s]),c=s.slice(9),l=P(c),u=(l==null?void 0:l.alias)??(l==null?void 0:l.name)??(l==null?void 0:l.id)??c;function f(){o.call("update_axis",{axis_ref:s,relative_position:0})}return e.jsx(a.Button,{className:"ms-1",variant:i?"primary":"secondary",onClick:()=>{i||f()},title:i?"This axis is already part of the motion":"Use this axis in the motion",disabled:r,children:u})}function Al(n){var x;const{motion:t,actions:o}=n,s=t.axisRef,r=t.absolute_position??t.relative_position??0,i=s.slice(9),c=P(i),l=n.disabled||!(c!=null&&c.online),u=h.useRef(null),[f,d]=h.useState(!1),p=3,m=((x=c==null?void 0:c.properties)==null?void 0:x.unit)??"";function g(j){if(!u||!u.current)console.log("formRef not yet defined");else if(j.key==="Enter"){d(!1);const N=Number.parseFloat(u.current.value);o.call("update_axis",{axis_ref:s,absolute_position:t.absolute_position!==null?N:null,relative_position:t.relative_position!==null?N:null})}else j.key==="Escape"?(u.current.value=r.toFixed(p),d(!1)):console.log(j.key)}function w(j){const{value:N}=j.target;if(N===void 0)return;const I=Number.parseFloat(N);I!==r&&!f&&d(!0),I===r&&f&&d(!1)}return h.useEffect(()=>{!u||!u.current?console.log("formRef not yet defined"):f||(u.current.value=r.toFixed(p))},[f,r]),e.jsxs(a.InputGroup,{className:"w-100",children:[e.jsx(a.Form.Control,{className:f?"form-control-edited":"",type:"number",ref:u,defaultValue:r.toFixed(p),onChange:w,disabled:l,onKeyDown:g}),e.jsx(a.InputGroup.Text,{children:m})]})}function Rl(n){const{actions:t,motion:o,disabled:s}=n;function r(){t.call("update_axis",{axis_ref:o.axisRef,absolute_position:o.absolute_position??o.relative_position})}function i(){t.call("update_axis",{axis_ref:o.axisRef,relative_position:o.absolute_position??o.relative_position})}return e.jsxs(a.ButtonGroup,{children:[e.jsx(a.Button,{onClick:r,variant:o.absolute_position!==null?"primary":"secondary",disabled:s,children:"Abs"}),e.jsx(a.Button,{onClick:i,variant:o.relative_position!==null?"primary":"secondary",disabled:s,children:"Rel"})]})}function Ot(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r={}}=t,i=Mt(t),c=e.jsx(y,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),l=e.jsx(de,{hardware:t}),u=e.jsxs(a.Container,{children:[e.jsxs(a.Row,{className:"mt-1",children:[e.jsx(a.Col,{xs:3,children:"Move in parallel"}),e.jsx(a.Col,{xs:9,children:r.move_in_parallel?"true":"false"})]}),e.jsxs(a.Row,{className:"mt-1",children:[e.jsx(a.Col,{xs:3,children:"Switch power on/off"}),e.jsx(a.Col,{xs:9,children:r.power_onoff?"true":"false"})]}),e.jsxs(a.Row,{className:"mt-1",children:[e.jsx(a.Col,{xs:3,children:"Settle time"}),e.jsxs(a.Col,{xs:9,children:[r.settle_time.toFixed(2)," ",e.jsx("span",{title:"seconds",children:"s"})]})]}),e.jsxs(a.Row,{className:"mt-1",children:[e.jsx(a.Col,{xs:3,children:"Available axes"}),e.jsx(a.Col,{xs:9,children:r.available_axes.map(d=>e.jsx(Fl,{axisRef:d,motion:r.motion,actions:t.actions,disabled:s||!i},d))})]}),e.jsxs(a.Row,{className:"mt-1",children:[e.jsx(a.Col,{xs:3,children:"Actual motion"}),e.jsx(a.Col,{xs:9,children:e.jsxs("div",{style:{display:"grid",gridGap:5,gridTemplateColumns:"min-content min-content auto min-content"},children:[e.jsx("div",{children:"Axis"}),e.jsx("div",{children:"Kind"}),e.jsx("div",{children:"Displacement"}),e.jsx("div",{}),r.motion.map((d,p)=>e.jsxs(h.Fragment,{children:[e.jsx(Ml,{motion:d}),e.jsx(Rl,{motion:d,actions:t.actions,disabled:s||!i}),e.jsx(Al,{motion:d,actions:t.actions,disabled:s||!i}),e.jsx(Tl,{motion:d,actions:t.actions,disabled:s||!i})]},`motion${p}`))]})})]})]}),f=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:c,widgetState:l,widgetContent:u,headerMode:f})}function Dl(n){var b;const{motion:t,actions:o}=n,s=t.axisRef,r=t.absolute_position??t.relative_position??0,i=s.slice(9),c=P(i),l=n.disabled||!(c!=null&&c.online),u=h.useRef(null),[f,d]=h.useState(!1),p=3,m=((b=c==null?void 0:c.properties)==null?void 0:b.unit)??"",g=(c==null?void 0:c.alias)??(c==null?void 0:c.name)??(c==null?void 0:c.id)??"none";function w(_){if(!u||!u.current)console.log("formRef not yet defined");else if(_.key==="Enter"){d(!1);const S=Number.parseFloat(u.current.value);o.call("update_axis",{axis_ref:s,absolute_position:t.absolute_position!==null?S:null,relative_position:t.relative_position!==null?S:null})}else _.key==="Escape"?(u.current.value=r.toFixed(p),d(!1)):console.log(_.key)}function x(_){const{value:S}=_.target;if(S===void 0)return;const C=Number.parseFloat(S);C!==r&&!f&&d(!0),C===r&&f&&d(!1)}h.useEffect(()=>{!u||!u.current?console.log("formRef not yet defined"):f||(u.current.value=r.toFixed(p))},[f,r]);function j(){return t.absolute_position!==null?["ABS","warning","Absolute displacement"]:t.relative_position!==null?["REL","none","Relative displacement"]:["ERR","danger","Unknown motion kind"]}const[N,I,M]=j();return e.jsxs(a.InputGroup,{className:"w-100 flex-nowrap",children:[e.jsx(a.InputGroup.Text,{title:"Displacement to apply on this axis to take a flat",style:{width:"5em"},children:g}),e.jsx(a.InputGroup.Text,{className:`bg-${I}`,title:M,style:{width:"3em"},children:N}),e.jsx(a.Form.Control,{className:f?"form-control-edited":"",type:"number",ref:u,defaultValue:r.toFixed(p),onChange:x,disabled:l,onKeyDown:w}),e.jsx(a.InputGroup.Text,{children:m})]})}function Ct(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r={}}=t,i=Mt(t),c=e.jsx(y,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),l=e.jsx(de,{hardware:t}),u=e.jsxs(e.Fragment,{children:[r.motion.length===0&&e.jsx(a.Alert,{variant:"danger",className:"mb-0",children:"No flat motion defined"}),r.motion.length>0&&e.jsx(a.Stack,{direction:"vertical",children:r.motion.map((d,p)=>e.jsx(Dl,{actions:t.actions,motion:d,disabled:s||!i},d.axisRef))})]}),f=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:c,widgetState:l,widgetContent:u,headerMode:f})}function El(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r}=t,{state:i="UNKNOWN"}=r,c=e.jsx(y,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),l=e.jsx(de,{hardware:t}),u=i==="IN",f=i==="OUT";function d(){return u?"1 / 3":f?"3 / 5":"2 / 4"}const p=d(),m=u?"fa-face-grin-beam-sweat":"fa-smile",g=u?"The sample is in front of the beam":f?"The sample is out of the beam":"",w=e.jsx("div",{style:{display:"grid",gridGap:0,gridTemplateColumns:"1fr 1fr 1fr 1fr 1fr 1fr",gridTemplateRows:"1fr"},children:e.jsx("i",{className:`fa ${m} fa-3x my-auto mx-auto`,style:{gridColumn:p,gridRow:1},title:g})}),x=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:c,widgetState:l,widgetContent:w,headerMode:x})}const kl={default:Ot,small:Ct,state:Il,sample_location:El},Pl=kl;function It(n){return n.type==="tomoflatmotion"}function Gl(n){const t=R(n);return t===null||!It(t)?null:t}function Mt(n){const{properties:t={}}=n,{state:o="UNKNOWN"}=t;return["IN","READY"].includes(o)}const Bl="tomoflatmotion",Vl="tomoflatmotion",Ll=!0,Ul={state:"READY",settle_time:2,power_onoff:!1,move_in_parallel:!0,available_axes:["hardware:sy","hardware:sy2"],motion:[{axisRef:"hardware:sy",absolute_position:null,relative_position:1}]},Hl="bliss",ql=!1,zl="tomoflatmotion",Wl={id:Bl,name:Vl,online:Ll,properties:Ul,protocol:Hl,require_staff:ql,type:zl},Yl=["move","stop","wait","rmove"],Kl="sy",Ql="sy",Xl=!0,Jl={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},Zl="bliss",ed=!1,td="motor",nd=[],od={callables:Yl,id:Kl,name:Ql,online:Xl,properties:Jl,protocol:Zl,require_staff:ed,type:td,user_tags:nd},sd=["move","stop","wait","rmove"],rd="sy2",ad="sy2",id=!0,cd={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},ld="bliss",dd=!1,ud="motor",fd=[],pd={callables:sd,id:rd,name:ad,online:id,properties:cd,protocol:ld,require_staff:dd,type:ud,user_tags:fd},md={default:Wl,sy:od,sy2:pd};function hd(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,i]=h.useState({state:"READY",settle_time:2,power_onoff:!1,move_in_parallel:!0,available_axes:["hardware:sy","hardware:sy2"],motion:[{axisRef:"hardware:sy",absolute_position:null,relative_position:1}]});function c(f,d){const p=[];let m=!1;return f.motion.forEach(g=>{if(g.axisRef===d.axis_ref){if(m=!0,d.relative_position===void 0&&d.absolute_position===void 0)return;p.push({axisRef:d.axis_ref,relative_position:d.relative_position??null,absolute_position:d.absolute_position??null});return}p.push(g)}),m||p.push({axisRef:d.axis_ref,relative_position:d.relative_position??null,absolute_position:d.absolute_position??null}),{...f,motion:p}}async function l(f,d){if(f==="update_axis"){i(p=>c(p,d));return}console.log("TomoFlatMotionSimulator: Unsupported call",f,d)}async function u(f,d){console.log("TomoFlatMotionSimulator: Unsupported setProperty",f,d)}return e.jsx(H,{name:t,alias:o,type:"tomoflatmotion",call:l,setProperty:u,properties:r,useHardwareContext:s})}function Tt(n){const{hardware:t,options:o={},disabled:s}=n,{actions:r}=t,{label:i}=o,[c,l]=h.useState(void 0),[u,f]=h.useState(!1),d=e.jsx(y,{name:"TomoReferencePositionSchema",icon:"fam-hardware-motor",online:t.online});function p(x){l(void 0),f(!0),r.call("move_to_reference").catch(j=>{l(`${j}`)}).finally(()=>{f(!1)})}const m=e.jsx(e.Fragment,{}),g=e.jsxs(a.Button,{onClick:p,variant:c===void 0?"secondary":"danger",disabled:s||u,className:"w-100",children:[c&&e.jsx("i",{className:"fa-solid fa-triangle-exclamation me-1",title:c}),!c&&u&&e.jsx("i",{className:"fa-solid fa-cog fa-spin me-1"}),i??"Back to reference position"]}),w=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:d,widgetState:m,widgetContent:g,headerMode:w})}function xd(n){return n.type==="tomoreferenceposition"}const gd={default:Tt},jd=gd;function be(n){const{hardware:t}=n,{online:o,locked:s=null}=t,r=o?(s!==null?"LOCKED":t.properties.state)||"UNKNOWN":"OFFLINE",i={UNKNOWN:"danger",READY:"success",OFFLINE:"secondary",INVALID:"danger",MOUNTING:"transiant",UNMOUNTING:"transiant",LOCKED:"warning"},c=i[r]||i.UNKNOWN;return e.jsx(A,{state:r,minWidth:6,variant:c})}function wd(n){const{hardware:t}=n;return e.jsx(be,{hardware:t})}function yd(n){const{hardware:t,options:o={}}=n;function s(i){return t.actions?t.actions.setProperty("sample_pixel_size_mode",i):console.error("Change request was triggered with:",i),null}const r=t.properties.sample_pixel_size_mode;return e.jsx(a.Dropdown,{style:n.style,children:e.jsxs(a.ButtonGroup,{children:[e.jsx(a.Button,{variant:r==="USER"?"primary":"secondary",onClick:()=>{s("USER")},disabled:n.disabled,title:"Use a fixed pixel size defined by the user",children:"USER"}),e.jsx(a.Button,{variant:r==="AUTO"?"primary":"secondary",onClick:()=>{s("AUTO")},disabled:n.disabled,title:"Compute the pixel size automatically based on the beamline geometry",children:"AUTO"})]})})}function vd(n){const{hardware:t,options:o={}}=n,s=t.properties.user_sample_pixel_size||0,{state:r}=t.properties,i=r==="READY";function c(l){return t.actions?t.actions.setProperty("user_sample_pixel_size",l):console.error("Change request was triggered with:",l),null}return e.jsx(se,{hardwareValue:s,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:i,hardwareIsMoving:!1,readOnly:t.properties.sample_pixel_size_mode!=="USER"})}function Nd(n){const{hardware:t,options:o={}}=n;return t.properties.state,e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{disabled:n.disabled,variant:"secondary"}),e.jsx(a.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(a.Container,{children:[e.jsx(a.Row,{children:e.jsx(a.Col,{className:"text-center",children:"Mode"})}),e.jsx(a.Row,{children:e.jsx(a.Col,{children:e.jsx(yd,{...n,style:{width:"100%"}})})}),e.jsx(a.Row,{children:e.jsx(a.Col,{className:"text-center mt-1",children:"User pixel size"})}),e.jsx(a.Row,{children:e.jsx(a.Col,{children:e.jsxs(a.InputGroup,{children:[e.jsx(vd,{...n}),e.jsx(a.InputGroup.Text,{children:"um"})]})})})]})})]})}function bd(n,t,o){return h.useMemo(()=>{function s(c){return c==="um"?"μm":c}function r(c){return c.toFixed(2).replace(/\.?0+$/,"")}if(n==null)return["∅",""];if(t===o)return[r(n),s(o)];const i=yn.default(n,t);return[r(i.to(o).scalar),s(o)]},[n,t,o])}function Ft(n){const{hardware:t,options:o={}}=n,s=o.display_unit??"um",r=e.jsx(y,{name:"TomoDetector",icon:"fa-cog",online:t.online}),i=e.jsx(be,{hardware:t}),[c,l]=bd(t.properties.sample_pixel_size,"um",s),u=e.jsxs(a.InputGroup,{className:"flex-nowrap",children:[e.jsx(a.InputGroup.Text,{className:"justify-content-center",style:{minWidth:"4em"},children:t.properties.sample_pixel_size_mode}),e.jsx(E,{value:c,title:`${t.properties.sample_pixel_size} um`}),e.jsx(a.InputGroup.Text,{children:l}),e.jsx(Nd,{...n})]}),f=n.options?n.options.header:"top";return e.jsx(v,{hardware:t,widgetIcon:r,widgetState:i,widgetContent:u,headerMode:f})}function _d(n){const{hardware:t,options:o={}}=n;function s(i){return t.actions?t.actions.setProperty("acq_mode",i):console.error("Change request was triggered with:",i),null}const r=t.properties.acq_mode;return e.jsx(a.Dropdown,{style:n.style,children:e.jsxs(a.ButtonGroup,{children:[e.jsx(a.Button,{variant:r==="SINGLE"?"primary":"secondary",onClick:()=>{s("SINGLE")},disabled:n.disabled,title:"Do acquisition in a single shot",children:"SINGLE"}),e.jsx(a.Button,{variant:r==="ACCUMULATION"?"primary":"secondary",onClick:()=>{s("ACCUMULATION")},disabled:n.disabled,title:"Do acqisition in multiple sub frame with accumulation",children:"ACCU"})]})})}function $d(n){const{hardware:t,actions:o}=n,s=t.properties.acc_max_expo_time||0,{state:r}=t.properties,i=r==="READY";function c(l){return o.setProperty("acc_max_expo_time",l),null}return e.jsx(se,{hardwareValue:s,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:i,hardwareIsMoving:!1,readOnly:t.properties.state!=="READY"})}function Sd(n){const t=R(n);return t!==null&&ce(t)?t:null}function Od(n){var c;const{hardware:t}=n,{properties:o}=t,s=((c=o.detector)==null?void 0:c.slice(9))??"",r=Sd(s),i=X(s);return e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{disabled:n.disabled,variant:"secondary"}),e.jsx(a.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(a.Container,{children:[e.jsx(a.Row,{children:e.jsx(a.Col,{className:"text-center",children:"Acquisition mode"})}),e.jsx(a.Row,{children:e.jsx(a.Col,{children:e.jsx(_d,{...n,style:{width:"100%"}})})}),e.jsx(a.Row,{children:e.jsx(a.Col,{className:"text-center mt-1",children:"Max sub frame exposition"})}),e.jsx(a.Row,{children:e.jsx(a.Col,{children:r&&e.jsxs(a.InputGroup,{children:[e.jsx($d,{hardware:r,actions:i}),e.jsx(a.InputGroup.Text,{children:"um"})]})})})]})})]})}function At(n){const{hardware:t}=n,o=e.jsx(y,{name:"TomoDetector",icon:"fa-cog",online:t.online}),s=e.jsx(be,{hardware:t}),r=e.jsxs(a.InputGroup,{className:"flex-nowrap",children:[e.jsx(E,{value:t.properties.acq_mode}),e.jsx(Od,{...n})]}),i=n.options?n.options.header:"top";return e.jsx(v,{hardware:t,widgetIcon:o,widgetState:s,widgetContent:r,headerMode:i})}const Cd={samplepixelsize:Ft,acquisitionmode:At,state:wd},Id=Cd;function Ae(n){return n.type==="tomodetector"}function Md(n){const t=R(n);return t===null||!Ae(t)?null:t}const Td="tomodetector",Fd="tomodetector",Ad=!0,Rd={state:"READY",actual_size:[1024,1024],sample_pixel_size_mode:"AUTO",user_sample_pixel_size:50,sample_pixel_size:48},Dd="bliss",Ed=!1,kd="tomodetector",Pd={id:Td,name:Fd,online:Ad,properties:Rd,protocol:Dd,require_staff:Ed,type:kd},Gd={default:Pd};function Re(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOUNTING:"transiant",UNMOUNTING:"transiant",UNKNOWN:"fatal",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(A,{state:o,minWidth:6,variant:r})}function Bd(n){const{hardware:t}=n;return e.jsx(Re,{hardware:t})}function oe(n){return!n||!n.startsWith("hardware:")?null:n.slice(9)}function Vd(n){const{hardware:t}=n,{properties:o}=t,{detectors:s}=o,r=oe(o.active_detector),i=oe(o.target_detector),c=o.state==="READY",l=n.disabled||!t.online||!c;function u(d){t.actions?t.actions.call("mount",d):console.error("Change request was triggered with:",d)}function f(d){const p=oe(d),g=p===(i||r)?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(a.Dropdown.Item,{disabled:l,onClick:()=>{u(p)},children:[e.jsx("i",{className:g})," ",p]},d)}return e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{disabled:l,variant:"secondary"}),e.jsx(a.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:s.map(d=>f(d))})]})}function Rt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Optic",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Re,{hardware:t}),{properties:i}=t,c=i.state==="MOUNTING",l=oe(i.active_detector),u=oe(i.target_detector);function f(){return e.jsxs(a.InputGroup,{children:[e.jsx(E,{className:G.default({"hw-moving":c}),value:u||l||"No detector"}),e.jsx(Vd,{...n})]})}const d=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:f(),headerMode:d})}const Ld={default:Rt,state:Bd},Ud=Ld;function Dt(n){return n.type==="tomodetectors"}function Hd(n){const t=R(n);return t===null||!Dt(t)?null:t}const qd="tomodetectors",zd="tomodetectors",Wd=!0,Yd={state:"READY",active_detector:"hardware:limadetector1",detectors:["hardware:limadetector1","hardware:limadetector2","hardware:limadetector3"]},Kd="bliss",Qd=!1,Xd="optic",Jd={id:qd,name:zd,online:Wd,properties:Yd,protocol:Kd,require_staff:Qd,type:Xd},Zd={default:Jd};function Q(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",BLOCKED:"secondary",ACQUIRING:"transiant",UNKNOWN:"fatal"},r=s[o]||s.UNKNOWN;return e.jsx(A,{state:o,minWidth:6,variant:r})}function eu(n){const{hardware:t}=n;return e.jsx(Q,{hardware:t})}function tu(n){const{hardware:t}=n,o=t.properties.update_on_move,s=n.disabled||!t.online;function r(c){t.actions.setProperty("update_on_move",!1)}function i(c){t.actions.setProperty("update_on_move",!0)}return e.jsxs(a.ButtonGroup,{className:"me-2",children:[e.jsx(a.InputGroup.Text,{children:"Update mode"}),e.jsx(a.Button,{onClick:i,disabled:s,variant:o?"primary":"secondary",children:"Auto"}),e.jsx(a.Button,{onClick:r,disabled:s,variant:o?"secondary":"primary",children:"Off"})]})}function nu(n){const{hardware:t}=n,o=t.properties.exposure_time??0,s=n.disabled||!t.online,r=h.useRef(null),[i,c]=h.useState(!1),l=2;function u(d){!r||!r.current?console.log("formRef not yet defined"):d.key==="Enter"?(c(!1),t.actions.setProperty("exposure_time",Number.parseFloat(r.current.value))):d.key==="Escape"&&(r.current.value=o.toFixed(l),c(!1))}function f(d){const{value:p}=d.target;if(p===void 0)return;const m=Number.parseFloat(p);m!==o&&!i&&c(!0),m===o&&i&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):i||(r.current.value=o.toFixed(l))},[i,o]),e.jsxs(a.InputGroup,{className:"me-2",children:[e.jsx(a.InputGroup.Text,{children:"Exposure time"}),e.jsx(a.Form.Control,{className:i?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:f,disabled:s,onKeyDown:u}),e.jsx(a.InputGroup.Text,{children:"s"})]})}function ou(n){const{hardware:t}=n,o=n.disabled||!t.online;function s(c){t.actions.call("take_proj")}function r(c){t.actions.call("take_dark")}function i(c){t.actions.call("take_flat")}return e.jsxs(a.ButtonGroup,{size:"lg",className:"me-2",children:[e.jsx(a.InputGroup.Text,{children:"Take"}),e.jsx(a.Button,{onClick:s,disabled:o,variant:"primary",children:"Proj"}),e.jsx(a.Button,{onClick:i,disabled:o,variant:"primary",children:"Flat"}),e.jsx(a.Button,{onClick:r,disabled:o,variant:"primary",children:"Dark"})]})}function Et(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Q,{hardware:t}),i=e.jsxs(a.Container,{children:[e.jsx(a.Row,{className:"mt-1",children:e.jsx(a.Col,{children:e.jsx(tu,{hardware:t,disabled:n.disabled})})}),e.jsx(a.Row,{className:"mt-1",children:e.jsx(a.Col,{children:e.jsx(nu,{hardware:t,disabled:n.disabled})})}),e.jsx(a.Row,{className:"mt-1",children:e.jsx(a.Col,{children:e.jsx(ou,{hardware:t,disabled:n.disabled})})})]}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function su(n){const{hardware:t}=n,o=t.properties.exposure_time??0,s=n.disabled||!t.online,r=h.useRef(null),[i,c]=h.useState(!1),l=3;function u(d){!r||!r.current?console.log("formRef not yet defined"):d.key==="Enter"?(c(!1),t.actions.setProperty("exposure_time",Number.parseFloat(r.current.value))):d.key==="Escape"?(r.current.value=o.toFixed(l),c(!1)):console.log(d.key)}function f(d){const{value:p}=d.target;if(p===void 0)return;const m=Number.parseFloat(p);m!==o&&!i&&c(!0),m===o&&i&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):i||(r.current.value=o.toFixed(l))},[i,o]),e.jsxs(a.InputGroup,{className:"w-100",children:[e.jsx(a.Form.Control,{className:i?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:f,disabled:s,onKeyDown:u}),e.jsx(a.InputGroup.Text,{children:"s"})]})}function ru(n){const{exposureTime:t}=n,o=R("ACTIVE_TOMOCONFIG.ref.detectors.active_detector.detector"),s=R("ACTIVE_TOMOCONFIG.ref.detectors.active_detector");if(o===null||s===null)return e.jsx(e.Fragment,{});if(!ce(o)||!Ae(s))return e.jsx(e.Fragment,{});const r=o.properties.acc_max_expo_time,i=s.properties.acq_mode;if(!r||i!=="ACCUMULATION")return e.jsx(e.Fragment,{});const[c,l]=dt(t,r);return e.jsxs("div",{className:"text-center",title:"Decompisiton of the accumulation",children:[c," × ",l.toFixed(3)]})}function kt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Q,{hardware:t}),i=e.jsxs(e.Fragment,{children:[e.jsx(su,{hardware:t,disabled:n.disabled}),e.jsx(ru,{exposureTime:t.properties.exposure_time})]}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function au(n){const{hardware:t}=n,o=t.properties.settle_time||0,s=n.disabled||!t.online,r=h.useRef(null),[i,c]=h.useState(!1),l=3;function u(d){!r||!r.current?console.log("formRef not yet defined"):d.key==="Enter"?(c(!1),t.actions.setProperty("settle_time",Number.parseFloat(r.current.value))):d.key==="Escape"?(r.current.value=o.toFixed(l),c(!1)):console.log(d.key)}function f(d){const{value:p}=d.target;if(p===void 0)return;const m=Number.parseFloat(p);m!==o&&!i&&c(!0),m===o&&i&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):i||(r.current.value=o.toFixed(l))},[i,o]),e.jsxs(a.InputGroup,{className:"w-100",children:[e.jsx(a.Form.Control,{className:i?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:f,disabled:s,onKeyDown:u}),e.jsx(a.InputGroup.Text,{children:"s"})]})}function Pt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Q,{hardware:t}),i=e.jsx(au,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function _e(n){const[t,o]=h.useState(!1),[s,r]=h.useState(void 0),{text:i,disabled:c,onAction:l,onStarted:u,onTerminated:f,title:d}=n;function p(m){u==null||u(),r(void 0),o(!0),l().catch(g=>{r(`${g}`)}).finally(()=>{o(!1),f==null||f()})}return e.jsxs(a.Button,{onClick:p,disabled:c||t,variant:s===void 0?"primary":"danger",className:G.default({"ps-4":!t,"pe-4":!t}),title:d,children:[s&&e.jsx("i",{className:"fa-solid fa-triangle-exclamation me-1",title:s}),!s&&t&&e.jsx("i",{className:"fa-solid fa-cog fa-spin me-1"}),i]})}function iu(){const n=R("ACTIVE_TOMOCONFIG.ref.detectors.active_detector.detector");return n===null||!ce(n)?null:n}function cu(n){const{hardware:t,restoreSample:o}=n,[s,r]=h.useState(!1),i=n.disabled||!t.online||s,c=iu(),l=(c==null?void 0:c.properties.state)==="OFFLINE";function u(){r(!0)}function f(){r(!1)}function d(){return t.actions.call("take_proj")}function p(){return t.actions.call("take_dark")}function m(){return t.actions.call(o?"take_flat":"take_flat_and_stay")}return e.jsxs(a.ButtonGroup,{size:"lg",className:"w-100",title:l?`The detector '${c==null?void 0:c.name}' is offline`:void 0,children:[e.jsx(_e,{onAction:d,onStarted:u,onTerminated:f,disabled:i||l,text:"Proj",title:"Take a projection"}),e.jsx(_e,{onAction:m,onStarted:u,onTerminated:f,disabled:i||l,text:"Flat",title:"Take a flat"}),e.jsx(_e,{onAction:p,onStarted:u,onTerminated:f,disabled:i||l,text:"Dark",title:"Take a dark"})]})}function Gt(n){const{hardware:t,options:o={}}=n,{restore_sample:s=!0}=o,r=e.jsx(y,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),i=e.jsx(Q,{hardware:t}),c=e.jsx(cu,{hardware:t,disabled:n.disabled,restoreSample:s}),l=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:r,widgetState:i,widgetContent:c,headerMode:l})}function lu(n){const{hardware:t}=n,o=t.properties.update_on_move,s=n.disabled||!t.online;function r(c){t.actions.setProperty("update_on_move",!1)}function i(c){t.actions.setProperty("update_on_move",!0)}return e.jsxs(a.ButtonGroup,{className:"w-100",children:[e.jsx(a.Button,{onClick:i,disabled:s,variant:o?"primary":"secondary",children:"Auto"}),e.jsx(a.Button,{onClick:r,disabled:s,variant:o?"secondary":"primary",children:"Off"})]})}function Bt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Q,{hardware:t}),i=e.jsx(lu,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}const du={default:Et,exposuretime:kt,settletime:Pt,actions:Gt,updatemode:Bt,state:eu},uu=du,fu="tomoimaging",pu="tomoimaging",mu=!0,hu={state:"READY",update_on_move:!1,exposure_time:1},xu="bliss",gu=!1,ju="optic",wu={id:fu,name:pu,online:mu,properties:hu,protocol:xu,require_staff:gu,type:ju},yu={default:wu};function vu(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,i]=h.useState({state:"READY",update_on_move:!0,exposure_time:1,settle_time:0});function c(f){i(d=>({...d,state:f}))}async function l(f,d){if(f==="take_dark"){c("ACQUIRING"),await k(2e3),c("READY");return}if(f==="take_flat"){c("ACQUIRING"),await k(2e3),c("READY");return}if(f==="take_proj"){c("ACQUIRING"),await k(2e3),c("READY");return}console.log("TomoImagingSimulator: Unsupported call",f,d)}async function u(f,d){i(p=>({...p,[f]:d}))}return e.jsx(H,{name:t,alias:o,type:"tomoimaging",call:l,setProperty:u,properties:r,useHardwareContext:s})}const Nu={},bu=Nu;function Vt(n){return n.type==="tomosamplestage"}function _u(n){const t=R(n);return t===null||!Vt(t)?null:t}function $u(n){const{hardware:t}=n,o=t.properties.latency_time||0,s=n.disabled||!t.online,r=h.useRef(null),[i,c]=h.useState(!1),l=3;function u(d){!r||!r.current?console.log("formRef not yet defined"):d.key==="Enter"?(c(!1),t.actions.setProperty("latency_time",r.current.value)):d.key==="Escape"?(r.current.value=o.toFixed(l),c(!1)):console.log(d.key)}function f(d){const{value:p}=d.target;if(p===void 0)return;const m=Number.parseFloat(p);m!==o&&!i&&c(!0),m===o&&i&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):i||(r.current.value=o.toFixed(l))},[i,o]),e.jsxs(a.InputGroup,{className:"w-100",children:[e.jsx(a.Form.Control,{className:i?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:f,disabled:s,onKeyDown:u}),e.jsx(a.InputGroup.Text,{children:"s"})]})}function Lt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(e.Fragment,{}),i=e.jsx($u,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}const Su={latencytime:Lt},Ou=Su;function Ut(n){return n.type==="tomoconfig"}function Cu(n){const t=R(n);return t===null||!Ut(t)?null:t}function Ht(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOVING:"transiant",STABILIZING:"transiant",INVALID:"danger",INVALID_DETECTOR_BINNING_CHANGED:"danger",INVALID_DETECTOR_DISTANCE_CHANGED:"danger",INVALID_DETECTOR_CHANGED:"danger"},r=s[o]||s.UNKNOWN;return e.jsx(A,{state:o,minWidth:6,variant:r})}function Iu(n){const{hardware:t}=n;return e.jsx(Ht,{hardware:t})}const Mu={state:Iu},Tu=Mu;function qt(n){return n.type==="tomoholo"}function Fu(n){const t=R(n);return t===null||!qt(t)?null:t}function Au(n){const{hardware:t}=n,o=()=>{t.actions.call("reset")};return e.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(a.Popover,{id:"popover",children:[e.jsxs(a.Popover.Header,{children:[t.name," Details"]}),e.jsxs(a.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(a.Button,{disabled:n.disabled,onClick:o,children:"Reset"})})]})]}),children:e.jsx(a.Button,{className:"flex-grow-0",title:"Valve Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function zt(n){const{hardware:t,options:o={}}=n,s=()=>{t.actions.call(t.properties.state==="OPEN"?"close":"open")};return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(y,{name:"Valve",icon:"fam-hardware-valve",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(a.Badge,{bg:t.properties.state==="OPEN"||t.properties.state==="RUNNING"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(a.ButtonGroup,{className:"d-flex",children:[e.jsx(a.Button,{variant:t.properties.state==="OPEN"?"danger":"success",onClick:s,disabled:n.disabled,children:t.properties.state==="OPEN"?"Close":"Open"}),e.jsx(Au,{...n})]})})]})}const Ru={default:zt},Du=Ru,Eu=["close","reset","open"],ku="rv12",Pu="rv12",Gu=!0,Bu={state:"CLOSED",status:`Pneumatic is closed
|
|
34
34
|
`},Vu="tango",Lu=!1,Uu="valve",Hu={callables:Eu,id:ku,name:Pu,online:Gu,properties:Bu,protocol:Vu,require_staff:Lu,type:Uu},qu={default:Hu},zu=Oe.default("daiquiri.components.hardware.NoObject");function Wu(n){if(n.options.emptyifnone)return zu('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const t=e.jsx(y,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),s=e.jsx("span",{title:`Object '${n.name}' is missing`,children:"Missing"}),r=n.options?n.options.header:"top",i={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:i,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}function Yu(n){const t=e.jsx(y,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),s=e.jsx("span",{title:`Object '${n.name}' is loading`,children:e.jsx("i",{className:"fa-solid fa-spinner fa-spin-pulse"})}),r=n.options?n.options.header:"top",i={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:i,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}const Ku=Oe.default("daiquiri.components.hardware.MissingObject");function Qu(n){if(n.options.emptyifnone)return Ku('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const t=e.jsx(y,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),s=e.jsx("span",{title:`Object '${n.name}' is missing`,children:"Missing"}),r=n.options?n.options.header:"top",i={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:i,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}function Xu(n){const{properties:t={}}=n,{message:o="Unknown error"}=t,s=e.jsx(y,{name:"NoObject",icon:"fam-hardware-any",online:!1}),r=e.jsx(e.Fragment,{}),i=e.jsx(a.OverlayTrigger,{trigger:["focus","hover"],placement:"bottom",rootClose:!0,overlay:e.jsxs(a.Popover,{id:"error",style:{maxWidth:500},children:[e.jsx(a.Popover.Header,{children:"Error"}),e.jsx(a.Popover.Body,{children:e.jsx("ul",{children:e.jsx("li",{children:o})})})]}),children:e.jsxs(a.Button,{variant:"danger",size:"sm",className:"w-100",children:[e.jsx("i",{className:"fa fa-exclamation-triangle"})," Error"]})}),c=n.options?n.options.header:"top",l={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:l,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}const Ju=Oe.default("daiquiri.components.hardware.MissingComponentObject");function Zu(n){const{options:t}=n,{variant:o="default"}=t;if(t.emptyifnone)return Ju('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const s=e.jsx(y,{name:"NoObject",icon:"fam-hardware-any",online:!1}),r=e.jsx(e.Fragment,{}),i=e.jsx(a.OverlayTrigger,{trigger:["focus","hover"],placement:"bottom",rootClose:!0,overlay:e.jsxs(a.Popover,{id:"error",style:{maxWidth:500},children:[e.jsx(a.Popover.Header,{children:"Error"}),e.jsx(a.Popover.Body,{children:e.jsx("ul",{children:e.jsxs("li",{children:["No component available for object id '",n.name,"' (type '",n.type,"' and/or variant '",o,"' are not registred)"]})})})]}),children:e.jsxs(a.Button,{variant:"danger",size:"sm",className:"w-100",children:[e.jsx("i",{className:"fa fa-exclamation-triangle"})," Error"]})}),c=t?t.header:"top",l={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:l,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function ef(n){if(n.options.emptyifnone)return e.jsx(e.Fragment,{});const t=e.jsx(y,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),s=e.jsx(e.Fragment,{children:"No object"}),r=n.options?n.options.header:"top",i={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:i,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}function Wt(n){const[t,o]=h.useState({}),s=h.useRef(null);return h.useEffect(()=>{if(s.current){const r=s.current;o({width:r.clientWidth,height:r.clientHeight})}},[]),e.jsx("div",{ref:s,style:{width:"100%",height:"100%"},className:n.className,children:t.width>0&&e.jsx("div",{className:"full-sizer",style:{width:`${t.width}px`,height:`${t.height}px`,overflow:"scroll"},children:n.children})})}function tf(n){return e.jsx("div",{className:"panel-header",style:n.style,children:n.children})}function nf(n){return e.jsx("div",{className:`panel-contents ${n.className}`,style:n.style,children:n.children})}function F(n){const t=n.scroll?Wt:h.Fragment;return e.jsx("div",{className:`panel ${n.className??""}`,style:n.style,children:e.jsx(t,{children:n.children})})}F.Header=tf;F.Contents=nf;const pe={};function Yt(n,t){pe[n]=t}function L(n,t,o=!0){if(!n)return e.jsx(e.Fragment,{});const{type:s}=n,r=s&&s in pe?pe[s]:pe.component;return e.jsx(r,{yamlNode:n,panel:o},t)}function Kt(n,t){const{_parentNode:o,_indexFromParent:s,...r}=t;if(n&&Object.keys(r).length>0)throw new me(n,Object.keys(r))}class K extends Error{constructor(o,s){super(o);Y(this,"yamlNode");this.yamlNode=s}}class me extends K{constructor(o,s){super(`Unexpected keys: ${s.join(", ")}`,o);Y(this,"keys");this.keys=s}}class re extends K{constructor(o,s){super(`Keys ${s.join(", ")} are missing`,o);Y(this,"keys");this.keys=s}}class O extends K{constructor(o,s,r){super(`Key ${s} error: ${r}`,o);Y(this,"key");Y(this,"keyMessage");this.key=s,this.keyMessage=r}}function of(n){let t=n;for(;t._parentNode;)t=t._parentNode;return t}function sf(n){const t=[];let o=n;for(;o;)t.push({node:o,indexFromParent:o._indexFromParent}),o=o._parentNode;return t.reverse(),t}function Qt(n,t=null,o=null){if(n._parentNode)throw new Error("Attribute _parentNode was already defined by the yml layout.");const s={...n,_parentNode:t,_indexFromParent:o};if(n.children){const r=[...n.children];Object.freeze(r),s.children=r.map((i,c)=>Qt(i,s,c))}return Object.freeze(s),s}function rf(n,t,o){if(n&&o===void 0)throw new re(n,[t])}function De(n,t,o){if(typeof o!="string")throw new O(n,t,"A string is expected")}function af(n,t,o){if(typeof o!="boolean")throw new O(n,t,"A boolean is expected")}function cf(n,t,o){if(typeof o!="number")throw new O(n,t,"A number is expected")}function he(n,t,o){if(o!==void 0&&typeof o!="boolean")throw new O(n,t,"An optional boolean is expected")}function ae(n,t,o){if(o!==void 0&&typeof o!="string")throw new O(n,t,"An optional string is expected")}function lf(n,t,o){if(!Array.isArray(o))throw new O(n,t,"A list of string is expected");o.forEach(s=>{if(typeof s!="string")throw new O(n,t,"A list of string is expected")})}function df(n,t,o){if(o!==void 0&&typeof o!="string"){if(!Array.isArray(o))throw new O(n,t,"An optional string or list of string is expected");o.forEach(s=>{if(typeof s!="string")throw new O(n,t,"An optional string or list of string is expected")})}}function uf(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new O(n,t,"An optional list of string is expected");o.forEach(s=>{if(typeof s!="string")throw new O(n,t,"A optional list of string is expected")})}}function xe(n,t,o){if(o!==void 0&&typeof o!="number")throw new O(n,t,"An optional number is expected")}function ff(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new O(n,t,"An optional list of numbers is expected");o.forEach(s=>{if(typeof s!="number")throw new O(n,t,"An optional list of numbers is expected")})}}function pf(n,t,o,s,r){if(o!==void 0){if(!Array.isArray(o))throw new O(n,t,`An optional list of ${r} is expected`);o.forEach(i=>{if(!s(i))throw new O(n,t,`An optional list of type ${r} is expected`)})}}function ee(n,t){const{_parentNode:o,_indexFromParent:s,...r}=t;if(n&&Object.keys(r).length>0)throw new me(n,Object.keys(r))}function mf(n,t,o){if(o!=="last"&&typeof o!="number")throw new O(n,t,'"last" or a number is expected')}function hf(n,t,o){if(o!==void 0&&o!=="h5web"&&o!=="plotly")throw new O(n,t,'"h5web" or "plotly" string is expected')}const xf=Object.freeze(Object.defineProperty({__proto__:null,assertBoolean:af,assertDataCollectionId:mf,assertKeyExpected:rf,assertNoUnknownKeys:ee,assertNumber:cf,assertOptionalBackend:hf,assertOptionalBoolean:he,assertOptionalListOfType:pf,assertOptionalNumber:xe,assertOptionalNumberList:ff,assertOptionalString:ae,assertOptionalStringList:uf,assertOptionalStringOrStringList:df,assertString:De,assertStringList:lf},Symbol.toStringTag,{value:"Module"}));function Xt(n){const{providers:t={},yamlNode:o,message:s,...r}=n;return ae(o,"message",s),ee(o,r),e.jsx(a.Alert,{variant:"warning",className:"mb-0",children:s??"TODO"})}function Jt(n){return e.jsx(e.Fragment,{})}const gf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),jf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));function Zt(n){var t;return e.jsxs(a.Alert,{variant:"danger",children:[n.message,e.jsx("br",{}),e.jsx("pre",{children:(t=n.error)==null?void 0:t.stack})]})}function wf(n){const{error:t}=n;if(!(t instanceof K))return e.jsx(e.Fragment,{});function o(i,c=3){const l=sf(i.yamlNode),u=[];let f="";for(let d=1;d<l.length;d++){const{node:p,indexFromParent:m}=l[d];u.push(`${f}children:`),f+=" ".repeat(c),m===1?u.push(`${f}- type: ...`):(m??0>1)&&u.push(`${f}...`,`${f}...`,`${f}# children number ${m??0+1}`),u.push(`${f}- type: ${p.type}`),f+=" ".repeat(2)}return i instanceof me?i.keys.forEach(d=>{u.push(`${f}${d}: ... ${" ".repeat(50-f.length-d.length)}<-- unexpected key`)}):i instanceof re?i.keys.forEach(d=>{u.push(`${f}???: ${" ".repeat(50-f.length-d.length)}<-- key **${d}** is expected`)}):i instanceof O&&u.push(`${f}${i.key}: ${" ".repeat(50-f.length-i.key.length)}<-- ${i.keyMessage}`),u.join(`
|
|
35
|
-
`)}const r=of(t.yamlNode).name;if(t instanceof me){const i=t.keys.length===1?"key":"keys";return e.jsxs(a.Alert,{variant:"danger",children:["Unexpected ",i," ",t.keys.map((c,l)=>e.jsxs(e.Fragment,{children:[l!==0&&", ",e.jsx("b",{children:c})]}))," ","from the layout name ",e.jsx("b",{children:r}),".",e.jsx("br",{}),e.jsx("pre",{className:"mt-3",children:o(t)}),e.jsx("br",{})]})}if(t instanceof re){const i=t.keys.length===1?"Key":"Keys";return e.jsxs(a.Alert,{variant:"danger",children:["Expected ",i," ",t.keys.map((c,l)=>e.jsxs(e.Fragment,{children:[l!==0&&", ",e.jsx("b",{children:c})]}))," ","from the layout name ",e.jsx("b",{children:r}),".",e.jsx("br",{}),e.jsx("pre",{className:"mt-3",children:o(t)}),e.jsx("br",{})]})}return t instanceof O?e.jsxs(a.Alert,{variant:"danger",children:["Error on key ",e.jsx("b",{children:t.key})," from the layout name ",e.jsx("b",{children:r}),".",e.jsx("br",{}),e.jsx("pre",{className:"mt-3",children:o(t)}),e.jsx("br",{})]}):e.jsx(Zt,{...n})}const Be={hasError:!1,message:"",error:void 0};class en extends h.Component{constructor(o){super(o);Y(this,"reload",()=>{window.location.reload()});this.state=Be}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(o){var s,r;if(o instanceof K||!this.props.unhandledComponentDidCatch){this.setState({hasError:!0,message:o.message,error:o});return}(r=(s=this.props).unhandledComponentDidCatch)==null||r.call(s,o,i=>{this.setState({hasError:!0,message:o.message,error:o,...i})})}componentDidUpdate(o,s){this.state.hasError&&s.error!==void 0&&o.resetKey!==this.props.resetKey&&this.setState(Be)}render(){if(this.state.hasError){const{UnhandledErrorComponent:o}=this.props,{hasError:s,...r}=this.state;return e.jsxs(a.Container,{className:"mt-2",children:[e.jsx("h4",{children:"Something went wrong"}),this.state.error instanceof K&&e.jsx(wf,{message:this.state.message,error:this.state.error}),!(this.state.error instanceof K)&&e.jsx(e.Fragment,{children:o?e.jsx(o,{...r}):e.jsx(Zt,{message:this.state.message,error:this.state.error})}),e.jsxs("p",{children:["This error has been logged. Please"," ",e.jsxs(a.Button,{size:"sm",onClick:this.reload,children:[e.jsx("i",{className:"fa fa-refresh"})," Reload"]})," ","the application"]})]})}return this.props.children}}function yf({yamlNode:n,panel:t}){const{type:o,style:s,children:r,...i}=n;return ee(n,i),e.jsx(a.Row,{className:"ymllayout-row gx-0",style:s,children:D.map(r,(c,l)=>L(c,l,t))})}function vf({yamlNode:n,panel:t}){const{type:o,style:s,xs:r,children:i,...c}=n;return ee(n,c),xe(n,"xs",r),e.jsx(a.Col,{className:G.default("yamymllayout-col",{col:!!r}),style:s,xs:r,children:D.map(n.children,(l,u)=>L(l,u,t))})}const ie={};function Nf(n,t){ie[n]=t}function bf(n,t){if(t===void 0)throw new re(n,["id"]);if(typeof t.id!="string")throw new O(n,"id","A string is expected")}function _f(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new O(n,t,"A option list is expected");o.forEach((s,r)=>{try{bf(n,s)}catch{throw new O(n,t,`The hardware description ${r} is wrong`)}})}}function $f(n){const{providers:t={},yamlNode:o,ids:s,groupid:r,even:i,nowrap:c,...l}=n;if(_f(o,"ids",s),ae(o,"groupid",r),he(o,"even",i),he(o,"nowrap",c),ee(o,l),!ie.HardwareGroup)return e.jsx(a.Alert,{variant:"warning",children:"No `HardwareGroup` component registered"});const u=ie.HardwareGroup;return e.jsx(u,{providers:t,ids:s,groupid:r,nowrap:c||!1,even:i||!1})}function Sf(n){const{providers:t={},yamlNode:o,id:s,variant:r,header:i,width:c,colWidth:l,emptyifnone:u,...f}=n;De(o,"id",s),ae(o,"variant",r),ae(o,"header",i),xe(o,"width",c),xe(o,"colWidth",l),he(o,"emptyifnone",u);const d={variant:r,header:i,width:c,colWidth:l,emptyifnone:u,...f};if(!ie.Hardware)return e.jsx(a.Alert,{variant:"warning",children:"No `Hardware` component registered"});const p=ie.Hardware;return e.jsx(p,{providers:t,id:s,options:d})}function Of(n){const{providers:t={},yamlNode:o,label:s,...r}=n;return De(o,"label",s),ee(o,r),e.jsx("div",{children:s})}const ge={hardwaregroup:$f,hardware:Sf,todo:Xt,none:Jt,label:Of};function tn(n,t){ge[n]=t}function Cf(n){Object.entries(n).forEach(([t,o])=>tn(t,o))}function If(n){const{yamlNode:t,panel:o}=n,{type:s,style:r,scroll:i,title:c,...l}=t;if(!(s in ge))return e.jsx(F,{children:e.jsx(F.Contents,{children:e.jsxs(a.Alert,{variant:"warning",children:['Unknown component "',s,'"']})})});const u=ge[t.type];return o?e.jsx(F,{style:r,scroll:i,children:e.jsxs(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:[c&&e.jsx(F.Header,{children:c}),e.jsx(F.Contents,{children:e.jsx(u,{...l,yamlNode:t})})]})}):e.jsx(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:e.jsx(u,{...l,yamlNode:t})})}function Mf({yamlNode:n,panel:t}){const o=n.options||{};return e.jsx(a.Container,{className:"ymllayout-container",...o,children:D.map(n.children,(s,r)=>L(s,r,t))})}function Tf(n){const{yamlNode:t}=n,o=t.options||{},s={};return o.centerContent&&(s.margin="auto"),e.jsxs(F,{className:"ymllayout-panel",...o,children:[t.title&&e.jsx(F.Header,{children:t.title}),e.jsx(F.Contents,{style:s,children:D.map(t.children,(r,i)=>L(r,i,!1))})]})}const Ff=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15);function Af({yamlNode:n,panel:t}){const o=[];return D.each(n.children,(s,r)=>{o.push(e.jsx(a.Tab,{eventKey:Ff(),title:s.title,children:L(s,0,!1)},r))}),t?e.jsxs(F,{className:"ymllayout-tabs",children:[n.title&&e.jsx(F.Header,{children:n.title}),e.jsx(F.Contents,{children:e.jsx(a.Tabs,{mountOnEnter:!0,children:o})})]}):e.jsx(a.Tabs,{children:o})}function Rf(n){const{node:t}=n,{type:o,title:s,...r}=t;return Kt(t,r),e.jsx("div",{className:"ymllayout-form-header",style:{gridColumn:"1 / 3"},children:e.jsx("h3",{children:s})})}function Df(n){const{node:t,state:o,row:s}=n,{title:r}=t;function i(){if(t.id)return t.id}function c(){if(r!==void 0)return r;if(t.type==="hardware"){const u=i(),f={_parentNode:t._parentNode,_indexFromParent:t._indexFromParent,type:"hardware",id:u,variant:"name",emptyifnone:!0};return L(f,"a",!1)}return""}const l=c();return e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("h5",{style:{margin:"0px",whiteSpace:"nowrap"},children:l}),o&&e.jsx("div",{style:{position:"relative",top:-5},children:o})]})}function Ef(n){const{node:t,row:o}=n,{titlealign:s,title:r,stateinheader:i=!1,variant:c,id:l,...u}=t;let f,d;if(u.type==="hardware")if(f={...u,id:l,variant:c},i){const p={...u,id:l,variant:"state",emptyifnone:!0};d=L(p,"k",!1)}else d=null;else f=u,d=null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{gridColumn:1,alignSelf:s??"center"},children:e.jsx(Df,{node:t,state:d,row:o})}),e.jsx("div",{style:{gridColumn:2,alignSelf:"center"},children:L(f,"k",!1)})]})}function kf(n){const{yamlNode:t,panel:o}=n,{type:s,children:r,options:i={},title:c,...l}=t;return Kt(t,l),e.jsxs(F,{className:"ymllayout-form",...i,children:[t.title&&e.jsx(F.Header,{children:t.title}),e.jsx(F.Contents,{className:"full-sizer",style:{overflow:"auto"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"min-content auto"},children:D.map(r,(u,f)=>u.type==="formheader"?e.jsx(Rf,{node:u,row:f},f):u.type==="none"?e.jsx(gn.default.Fragment,{},f):e.jsx(Ef,{node:u,row:f},f))})})]})}function Pf(n){const{yamlNode:t,panel:o}=n;return e.jsxs("div",{className:"ymllayout-grid",style:{gridTemplateColumns:t.columns,gridTemplateRows:t.rows},children:[D.map(t.children,(s,r)=>{const{columnSpan:i=1,rowSpan:c=1,...l}=s,u=i>1?`span ${i}`:void 0,f=c>1?`span ${c}`:void 0;return e.jsx("div",{className:"ymllayout-grid-cell",style:{gridColumn:u,gridRow:f},children:L(l,r,o)},r)})," "]})}const nn={row:yf,col:vf,container:Mf,panel:Tf,tabs:Af,form:kf,grid:Pf},on={...nn,component:If};Object.entries(on).forEach(([n,t])=>{Yt(n,t)});function Gf(n){var o;const t=h.useMemo(()=>Qt(n.layout),[n.layout]);return t.error?e.jsx("div",{className:`${n.className??""} ymllayout-main`,"data-testid":n.testid,children:e.jsxs(F,{children:[e.jsx(F.Header,{children:"Layout Error"}),e.jsxs(F.Contents,{children:[e.jsxs("p",{children:["File: ",t.name]}),e.jsx(a.Alert,{variant:"warning",children:e.jsx("pre",{className:"mb-0",children:t.error})})]})]})}):e.jsx("div",{className:`${n.className??""} ymllayout-main`,"data-testid":n.testid,children:e.jsx(en,{resetKey:t,unhandledComponentDidCatch:n.unhandledComponentDidCatch,UnhandledErrorComponent:n.UnhandledErrorComponent,children:(o=t.children)==null?void 0:o.map((s,r)=>L(s,r))})})}const Bf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),sn=(n,t,o)=>{const s={">":(r,i)=>r>i,"<":(r,i)=>r<i,">=":(r,i)=>r>=i,"<=":(r,i)=>r<=i,"==":(r,i)=>r===i,"!=":(r,i)=>r!==i,in:(r,i)=>i.indexOf(r)>-1};if(n in s)return s[n](t,o)};function rn(n,t,o){const s=n.split(t);return o?[s.slice(0,-o).join(t)].concat(s.slice(-o)):s}function an(n){return n===null?null:n.startsWith("$")?
|
|
35
|
+
`)}const r=of(t.yamlNode).name;if(t instanceof me){const i=t.keys.length===1?"key":"keys";return e.jsxs(a.Alert,{variant:"danger",children:["Unexpected ",i," ",t.keys.map((c,l)=>e.jsxs(e.Fragment,{children:[l!==0&&", ",e.jsx("b",{children:c})]}))," ","from the layout name ",e.jsx("b",{children:r}),".",e.jsx("br",{}),e.jsx("pre",{className:"mt-3",children:o(t)}),e.jsx("br",{})]})}if(t instanceof re){const i=t.keys.length===1?"Key":"Keys";return e.jsxs(a.Alert,{variant:"danger",children:["Expected ",i," ",t.keys.map((c,l)=>e.jsxs(e.Fragment,{children:[l!==0&&", ",e.jsx("b",{children:c})]}))," ","from the layout name ",e.jsx("b",{children:r}),".",e.jsx("br",{}),e.jsx("pre",{className:"mt-3",children:o(t)}),e.jsx("br",{})]})}return t instanceof O?e.jsxs(a.Alert,{variant:"danger",children:["Error on key ",e.jsx("b",{children:t.key})," from the layout name ",e.jsx("b",{children:r}),".",e.jsx("br",{}),e.jsx("pre",{className:"mt-3",children:o(t)}),e.jsx("br",{})]}):e.jsx(Zt,{...n})}const Be={hasError:!1,message:"",error:void 0};class en extends h.Component{constructor(o){super(o);Y(this,"reload",()=>{window.location.reload()});this.state=Be}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(o){var s,r;if(o instanceof K||!this.props.unhandledComponentDidCatch){this.setState({hasError:!0,message:o.message,error:o});return}(r=(s=this.props).unhandledComponentDidCatch)==null||r.call(s,o,i=>{this.setState({hasError:!0,message:o.message,error:o,...i})})}componentDidUpdate(o,s){this.state.hasError&&s.error!==void 0&&o.resetKey!==this.props.resetKey&&this.setState(Be)}render(){if(this.state.hasError){const{UnhandledErrorComponent:o}=this.props,{hasError:s,...r}=this.state;return e.jsxs(a.Container,{className:"mt-2",children:[e.jsx("h4",{children:"Something went wrong"}),this.state.error instanceof K&&e.jsx(wf,{message:this.state.message,error:this.state.error}),!(this.state.error instanceof K)&&e.jsx(e.Fragment,{children:o?e.jsx(o,{...r}):e.jsx(Zt,{message:this.state.message,error:this.state.error})}),e.jsxs("p",{children:["This error has been logged. Please"," ",e.jsxs(a.Button,{size:"sm",onClick:this.reload,children:[e.jsx("i",{className:"fa fa-refresh"})," Reload"]})," ","the application"]})]})}return this.props.children}}function yf({yamlNode:n,panel:t}){const{type:o,style:s,children:r,...i}=n;return ee(n,i),e.jsx(a.Row,{className:"ymllayout-row gx-0",style:s,children:D.map(r,(c,l)=>L(c,l,t))})}function vf({yamlNode:n,panel:t}){const{type:o,style:s,xs:r,children:i,...c}=n;return ee(n,c),xe(n,"xs",r),e.jsx(a.Col,{className:G.default("yamymllayout-col",{col:!!r}),style:s,xs:r,children:D.map(n.children,(l,u)=>L(l,u,t))})}const ie={};function Nf(n,t){ie[n]=t}function bf(n,t){if(t===void 0)throw new re(n,["id"]);if(typeof t.id!="string")throw new O(n,"id","A string is expected")}function _f(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new O(n,t,"A option list is expected");o.forEach((s,r)=>{try{bf(n,s)}catch{throw new O(n,t,`The hardware description ${r} is wrong`)}})}}function $f(n){const{providers:t={},yamlNode:o,ids:s,groupid:r,even:i,nowrap:c,...l}=n;if(_f(o,"ids",s),ae(o,"groupid",r),he(o,"even",i),he(o,"nowrap",c),ee(o,l),!ie.HardwareGroup)return e.jsx(a.Alert,{variant:"warning",children:"No `HardwareGroup` component registered"});const u=ie.HardwareGroup;return e.jsx(u,{providers:t,ids:s,groupid:r,nowrap:c||!1,even:i||!1})}function Sf(n){const{providers:t={},yamlNode:o,id:s,variant:r,header:i,width:c,colWidth:l,emptyifnone:u,...f}=n;De(o,"id",s),ae(o,"variant",r),ae(o,"header",i),xe(o,"width",c),xe(o,"colWidth",l),he(o,"emptyifnone",u);const d={variant:r,header:i,width:c,colWidth:l,emptyifnone:u,...f};if(!ie.Hardware)return e.jsx(a.Alert,{variant:"warning",children:"No `Hardware` component registered"});const p=ie.Hardware;return e.jsx(p,{providers:t,id:s,options:d})}function Of(n){const{providers:t={},yamlNode:o,label:s,...r}=n;return De(o,"label",s),ee(o,r),e.jsx("div",{children:s})}const ge={hardwaregroup:$f,hardware:Sf,todo:Xt,none:Jt,label:Of};function tn(n,t){ge[n]=t}function Cf(n){Object.entries(n).forEach(([t,o])=>tn(t,o))}function If(n){const{yamlNode:t,panel:o}=n,{type:s,style:r,scroll:i,title:c,...l}=t;if(!(s in ge))return e.jsx(F,{children:e.jsx(F.Contents,{children:e.jsxs(a.Alert,{variant:"warning",children:['Unknown component "',s,'"']})})});const u=ge[t.type];return o?e.jsx(F,{style:r,scroll:i,children:e.jsxs(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:[c&&e.jsx(F.Header,{children:c}),e.jsx(F.Contents,{children:e.jsx(u,{...l,yamlNode:t})})]})}):e.jsx(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:e.jsx(u,{...l,yamlNode:t})})}function Mf({yamlNode:n,panel:t}){const o=n.options||{};return e.jsx(a.Container,{className:"ymllayout-container",...o,children:D.map(n.children,(s,r)=>L(s,r,t))})}function Tf(n){const{yamlNode:t}=n,o=t.options||{},s={};return o.centerContent&&(s.margin="auto"),e.jsxs(F,{className:"ymllayout-panel",...o,children:[t.title&&e.jsx(F.Header,{children:t.title}),e.jsx(F.Contents,{style:s,children:D.map(t.children,(r,i)=>L(r,i,!1))})]})}const Ff=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15);function Af({yamlNode:n,panel:t}){const o=[];return D.each(n.children,(s,r)=>{o.push(e.jsx(a.Tab,{eventKey:Ff(),title:s.title,children:L(s,0,!1)},r))}),t?e.jsxs(F,{className:"ymllayout-tabs",children:[n.title&&e.jsx(F.Header,{children:n.title}),e.jsx(F.Contents,{children:e.jsx(a.Tabs,{mountOnEnter:!0,children:o})})]}):e.jsx(a.Tabs,{children:o})}function Rf(n){const{node:t}=n,{type:o,title:s,...r}=t;return Kt(t,r),e.jsx("div",{className:"ymllayout-form-header",style:{gridColumn:"1 / 3"},children:e.jsx("h3",{children:s})})}function Df(n){const{node:t,state:o,row:s}=n,{title:r}=t;function i(){if(t.id)return t.id}function c(){if(r!==void 0)return r;if(t.type==="hardware"){const u=i(),f={_parentNode:t._parentNode,_indexFromParent:t._indexFromParent,type:"hardware",id:u,variant:"name",emptyifnone:!0};return L(f,"a",!1)}return""}const l=c();return e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("h5",{style:{margin:"0px",whiteSpace:"nowrap"},children:l}),o&&e.jsx("div",{style:{position:"relative",top:-5},children:o})]})}function Ef(n){const{node:t,row:o}=n,{titlealign:s,title:r,stateinheader:i=!1,variant:c,id:l,...u}=t;let f,d;if(u.type==="hardware")if(f={...u,id:l,variant:c},i){const p={...u,id:l,variant:"state",emptyifnone:!0};d=L(p,"k",!1)}else d=null;else f=u,d=null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{gridColumn:1,alignSelf:s??"center"},children:e.jsx(Df,{node:t,state:d,row:o})}),e.jsx("div",{style:{gridColumn:2,alignSelf:"center"},children:L(f,"k",!1)})]})}function kf(n){const{yamlNode:t,panel:o}=n,{type:s,children:r,options:i={},title:c,...l}=t;return Kt(t,l),e.jsxs(F,{className:"ymllayout-form",...i,children:[t.title&&e.jsx(F.Header,{children:t.title}),e.jsx(F.Contents,{className:"full-sizer",style:{overflow:"auto"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"min-content auto"},children:D.map(r,(u,f)=>u.type==="formheader"?e.jsx(Rf,{node:u,row:f},f):u.type==="none"?e.jsx(gn.default.Fragment,{},f):e.jsx(Ef,{node:u,row:f},f))})})]})}function Pf(n){const{yamlNode:t,panel:o}=n;return e.jsxs("div",{className:"ymllayout-grid",style:{gridTemplateColumns:t.columns,gridTemplateRows:t.rows},children:[D.map(t.children,(s,r)=>{const{columnSpan:i=1,rowSpan:c=1,...l}=s,u=i>1?`span ${i}`:void 0,f=c>1?`span ${c}`:void 0;return e.jsx("div",{className:"ymllayout-grid-cell",style:{gridColumn:u,gridRow:f},children:L(l,r,o)},r)})," "]})}const nn={row:yf,col:vf,container:Mf,panel:Tf,tabs:Af,form:kf,grid:Pf},on={...nn,component:If};Object.entries(on).forEach(([n,t])=>{Yt(n,t)});function Gf(n){var o;const t=h.useMemo(()=>Qt(n.layout),[n.layout]);return t.error?e.jsx("div",{className:`${n.className??""} ymllayout-main`,"data-testid":n.testid,children:e.jsxs(F,{children:[e.jsx(F.Header,{children:"Layout Error"}),e.jsxs(F.Contents,{children:[e.jsxs("p",{children:["File: ",t.name]}),e.jsx(a.Alert,{variant:"warning",children:e.jsx("pre",{className:"mb-0",children:t.error})})]})]})}):e.jsx("div",{className:`${n.className??""} ymllayout-main`,"data-testid":n.testid,children:e.jsx(en,{resetKey:t,unhandledComponentDidCatch:n.unhandledComponentDidCatch,UnhandledErrorComponent:n.UnhandledErrorComponent,children:(o=t.children)==null?void 0:o.map((s,r)=>L(s,r))})})}const Bf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),sn=(n,t,o)=>{const s={">":(r,i)=>r>i,"<":(r,i)=>r<i,">=":(r,i)=>r>=i,"<=":(r,i)=>r<=i,"==":(r,i)=>r===i,"!=":(r,i)=>r!==i,in:(r,i)=>i.indexOf(r)>-1};if(n in s)return s[n](t,o)};function rn(n,t,o){const s=n.split(t);return o?[s.slice(0,-o).join(t)].concat(s.slice(-o)):s}function an(n){return n===null?null:n.startsWith("$")?n.slice(1):n}function Ve(n){const t=n!==void 0?rn(n,".",1):[null,""],o=R(an(t[0]));if(!o||!o.properties)return;const s=t[1];if(s===null)return;const r=o.properties[s];return Array.isArray(r)?r[0]:r}function Vf(n){const t=n!==void 0&&!n.includes("."),o=n!==void 0?rn(n,".",1):[null,""],s=R(an(o[0]));if(t)return n;if(s&&s.properties&&o[1]!==null)return`${s.properties[o[1]]}`}function cn(n){const{monitor:t}=n;let o=Ve(t.value)??"-";const s=Vf(t.unit),r=Ve(t.overlay),i=Number.parseFloat(`${o}`);Number.isNaN(i)||String(i).length>5&&(o=i.toPrecision(5));let c;if(t.comparator&&t.comparison&&(c=sn(t.comparator,o,t.comparison)?"valid":"invalid"),Number.isNaN(i)||s!==void 0&&(o=`${o} ${s}`),r){const l=`${r}`;return e.jsx(a.OverlayTrigger,{placement:"bottom",overlay:e.jsx(a.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:l.includes(`
|
|
36
36
|
`)?e.jsx("pre",{children:l}):l}),children:e.jsxs(a.Col,{className:"monitor-panel-item",children:[e.jsx("h1",{children:t.name}),e.jsx("div",{className:c,children:`${o}`})]})},t.name)}return e.jsxs(a.Col,{className:"monitor-panel-item",children:[e.jsx("h1",{children:t.name}),e.jsx("div",{className:c,children:`${o}`})]},t.name)}const ln={hardware:cn};function Lf(n,t){ln[n]=t}function Uf(n){return e.jsxs(a.Col,{className:"monitor-panel-item bg-fatal",title:`Error from yaml configuration: ${n.message}`,children:[e.jsx("h1",{children:n.monitor.name}),e.jsx("div",{children:"Parsing error"})]})}function Hf(n){const t=D.map(n.monitors,(o,s)=>{const r=o.type??"hardware",i=ln[r];return i===void 0?e.jsx(Uf,{monitor:o,message:`Type ${r} unsupported`},`m${s}`):e.jsx(i,{monitor:o},`m${s}`)});return e.jsx("div",{className:G.default({"ms-auto":n.margin==="start"},"me-auto","monitor-panel",{"monitor-panel-light":n.bg==="light"}),children:e.jsx(a.Container,{fluid:!0,children:e.jsx(a.Row,{className:"flex-nowrap",children:t})})})}function qf(n){return e.jsx(a.Col,{className:"monitor-panel-item",children:n.children})}exports.AirBearing=We;exports.AirBearingMocks=zn;exports.AirBearingProtected=Ye;exports.AirBearingSimulator=Wn;exports.AirBearingState=je;exports.AirBearingVariants=En;exports.BaseInfo=He;exports.BaseMocks=In;exports.BaseName=Ue;exports.BaseProperty=qe;exports.BaseState=Le;exports.BaseVariants=$n;exports.ErrorObject=Xu;exports.Formatting=Jn;exports.Frontend=Qe;exports.FrontendMocks=fo;exports.FrontendVariants=to;exports.FullSizer=Wt;exports.Gauge=Xe;exports.GaugeMocks=Ro;exports.GaugeVariants=ho;exports.HWObject=Bf;exports.HardwareInputNumber=se;exports.HardwareNumericStep=we;exports.HardwareSchema=jf;exports.HardwareState=Mn;exports.HardwareTemplate=v;exports.HardwareTypes=gf;exports.KeyError=O;exports.Laser=Ze;exports.LaserHeating=et;exports.LaserHeatingMocks=as;exports.LaserHeatingVariants=Qo;exports.LaserMocks=Wo;exports.LaserVariants=ko;exports.Light=tt;exports.LightMocks=js;exports.LightVariants=cs;exports.LimaBinning=at;exports.LimaDefault=nt;exports.LimaDescription=ct;exports.LimaImageRoi=it;exports.LimaMocks=br;exports.LimaShape=lt;exports.LimaSimulator=_r;exports.LimaSize=ot;exports.LimaState=q;exports.LimaTransformation=st;exports.LimaVariants=Ds;exports.LoadingObject=Yu;exports.MeasurementGroupDefault=ut;exports.MeasurementGroupMocks=Br;exports.MeasurementGroupSimulator=Vr;exports.MeasurementGroupVariants=Mr;exports.MissingComponentObject=Zu;exports.MissingKeysError=re;exports.MissingObject=Qu;exports.MonitorHardware=cn;exports.MonitorPanel=Hf;exports.MonitorPanelItem=qf;exports.MotorDefault=J;exports.MotorMocks=Ja;exports.MotorSimulator=ei;exports.MotorState=ye;exports.MotorText=ft;exports.MotorVariants=qr;exports.Multiposition=mt;exports.MultipositionMocks=mi;exports.MultipositionSimulator=hi;exports.MultipositionVariants=si;exports.NoObject=Wu;exports.None=Jt;exports.NullObject=ef;exports.NumericStep=Je;exports.OpticDefault=xt;exports.OpticMocks=Fi;exports.OpticSimulator=Ai;exports.OpticState=Me;exports.OpticVariants=bi;exports.Panel=F;exports.ProcedureExecution=gt;exports.ProcedureManage=Se;exports.ProcedureMocks=Xi;exports.ProcedureState=le;exports.ProcedureValidate=jt;exports.ProcedureVariants=Bi;exports.PumpDefault=bt;exports.PumpMocks=Jc;exports.PumpVariants=Lc;exports.PusherDefault=_t;exports.PusherMocks=pl;exports.PusherSimulator=ml;exports.PusherState=Fe;exports.PusherVariants=ol;exports.ServiceDefault=$t;exports.ServiceMocks=Cl;exports.ServiceProtected=St;exports.ServiceState=Ne;exports.ServiceVariants=jl;exports.ShutterDefault=yt;exports.ShutterMocks=fc;exports.ShutterProtected=vt;exports.ShutterSimulator=pc;exports.ShutterState=ve;exports.ShutterVariants=nc;exports.SlitDefault=Nt;exports.SlitMocks=Gc;exports.SlitState=Te;exports.SlitVariants=yc;exports.Todo=Xt;exports.TomoConfigLatencyTime=Lt;exports.TomoConfigVariants=Ou;exports.TomoDetectorAcquisitionMode=At;exports.TomoDetectorMocks=Gd;exports.TomoDetectorSamplePixelSize=Ft;exports.TomoDetectorState=be;exports.TomoDetectorVariants=Id;exports.TomoDetectorsDefault=Rt;exports.TomoDetectorsMocks=Zd;exports.TomoDetectorsState=Re;exports.TomoDetectorsVariants=Ud;exports.TomoFlatMotionDefault=Ot;exports.TomoFlatMotionMocks=md;exports.TomoFlatMotionSimulator=hd;exports.TomoFlatMotionSmall=Ct;exports.TomoFlatMotionState=de;exports.TomoFlatMotionVariants=Pl;exports.TomoHoloState=Ht;exports.TomoHoloVariants=Tu;exports.TomoImagingActions=Gt;exports.TomoImagingDefault=Et;exports.TomoImagingExposureTime=kt;exports.TomoImagingMocks=yu;exports.TomoImagingSettleTime=Pt;exports.TomoImagingSimulator=vu;exports.TomoImagingState=Q;exports.TomoImagingUpdateMode=Bt;exports.TomoImagingVariants=uu;exports.TomoReferencePositionDefault=Tt;exports.TomoReferencePositionVariants=jd;exports.TomoSampleStageVariants=bu;exports.TypeIcon=y;exports.ValveDefault=zt;exports.ValveMocks=qu;exports.ValveVariants=Du;exports.YAMLErrorBoundary=en;exports.YAMLLayout=Gf;exports.YamlAsserts=xf;exports.componentMap=ge;exports.createMotorMock=Za;exports.dynamicOp=sn;exports.isLimaHardware=ce;exports.isMotorHardware=pt;exports.isOpticHardware=vi;exports.isProcedureHardware=wt;exports.isTomoConfigHardware=Ut;exports.isTomoDetectorHardware=Ae;exports.isTomoDetectorsHardware=Dt;exports.isTomoFlatMotionHardware=It;exports.isTomoHoloHardware=qt;exports.isTomoReferencePositionHardware=xd;exports.isTomoSampleStageHardware=Vt;exports.limaGuessSubframes=dt;exports.registerHardwareComponent=Nf;exports.registerMonitorComponent=Lf;exports.registerRuntimeHook=Is;exports.registerYamlComponent=tn;exports.registerYamlComponents=Cf;exports.registerYamlType=Yt;exports.renderYamlNode=L;exports.useHardware=R;exports.useHardwareChangeActions=X;exports.useHardwareSchema=Ms;exports.useLimaHardware=As;exports.useMotorHardware=P;exports.useMotorStates=Ce;exports.useOperator=Ts;exports.useProcedureHardware=Vi;exports.useScanRunning=Fs;exports.useTomoConfigHardware=Cu;exports.useTomoDetectorHardware=Md;exports.useTomoDetectorsHardware=Hd;exports.useTomoFlatMotionHardware=Gl;exports.useTomoHoloHardware=Fu;exports.useTomoSampleStageHardware=_u;exports.yamlContainers=nn;exports.yamlMap=on;
|
|
37
37
|
//# sourceMappingURL=index.js.map
|