@esrf/daiquiri-lib 2.2.0 → 3.0.0

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react-bootstrap"),h=require("react"),F=require("lodash"),tn=require("lodash/debounce"),nn=require("classnames");require("react-bootstrap-typeahead/css/Typeahead.css");require("react-bootstrap-typeahead/css/Typeahead.bs5.css");const B=require("react-bootstrap-typeahead"),on=require("js-quantities"),sn=require("debug"),se=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},rn=se(h),an=se(tn),A=se(nn),cn=se(on),$e=se(sn);function Pe(n){const{hardware:t}=n,{online:o,locked:s=null}=t,r=o?(s!==null?"LOCKED":t.properties.state)||"UNKNOWN":"OFFLINE",c={READY:"success",OFFLINE:"warning",MOVING:"warning",DISABLED:"secondary",UNKNOWN:"danger",ERROR:"danger",FAILED:"danger",LOCKED:"warning"}[r]||"success";return e.jsx(a.Badge,{bg:c,children:r})}function Ge(n){const{hardware:t}=n;return e.jsx(Pe,{hardware:t})}function Be(n){const{hardware:t,options:o}=n;function s(){return t.name?t.name:t.id}function r(){return o.overrideName!==void 0?o.overrideName:t.alias?t.alias:t.name?t.name:t.id}function i(){if(o.overrideName!==void 0)return`Real name: ${s()}`;if(t.alias)return`Real name: ${t.name}`}const c=r(),l=i();return e.jsx("span",{title:l,children:c})}function Ve(n){const{hardware:t,options:o={}}=n;function s(){const r=o.property;if(r===void 0)return"property is not set";if(r===null)return"property is null";let i=t;for(const c of r.split("/"))if(i=i[c],i===void 0)return`property '${r}' not found`;return`${i}`}return e.jsx(e.Fragment,{children:s()})}function ln(n){const{activeMessage:t="Online",inactiveMessage:o="Offline",message:s="This device is"}=n;return e.jsx("div",{className:`dot-indicator small bg-${n.online?"success":"danger"}`,title:`${s} ${n.online?t:o}`})}function w(n){const{name:t,icon:o}=n;return e.jsxs("div",{className:"icon",title:t,children:[e.jsx("i",{className:`fa ${o}`}),e.jsx(ln,{...n})]})}function v(n){const{headerMode:t,hardware:o}=n;function s(){return o.alias?o.alias:o.name?o.name:o.id}const r=s();switch(t){case"front":return e.jsx("div",{className:"hw-component",children:e.jsxs("div",{className:"hw-single",children:[n.widgetIcon,e.jsx("div",{className:"name",children:r}),e.jsx("div",{className:"d-inline-block",children:n.widgetContent})]})});case"none":return e.jsx("div",{className:"hw-component",children:e.jsx("div",{className:"hw-single",children:n.widgetContent})});case"state":return n.widgetState;default:return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[n.widgetIcon,e.jsx("div",{className:"name",children:e.jsx(a.Form.Label,{htmlFor:o.id,children:r})}),n.widgetState,n.hardware.errors&&n.hardware.errors.length>0&&e.jsx(a.OverlayTrigger,{trigger:"click",placement:"bottom",rootClose:!0,overlay:e.jsxs(a.Popover,{id:n.hardware.id,style:{maxWidth:500},children:[e.jsx(a.Popover.Header,{children:"Device Errors"}),e.jsxs(a.Popover.Body,{children:["There were errors with properties on this device:",e.jsx("ul",{children:n.hardware.errors.map(i=>e.jsxs("li",{children:[i.property,":",e.jsxs("span",{className:"stack-trace",children:[i.traceback,e.jsx("br",{}),i.exception]})]}))})]})]}),children:e.jsx(a.Button,{variant:"danger",size:"sm",children:e.jsx("i",{className:"fa fa-exclamation-triangle"})})})]}),e.jsx("div",{className:"hw-content",children:n.widgetContent})]})}}function dn(n){const t=n.online?"READY":"OFFLINE";return e.jsx(a.Badge,{bg:t==="READY"?"success":"warning",children:t})}function Le(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Optic",icon:"fa-cog",online:t.online}),r=e.jsx(dn,{...t});function i(){const d=o.property;if(d===void 0)return"property is not set";if(d===null)return"property is null";let p=t;for(const m of d.split("/"))if(p=p[m],p===void 0)return`property '${d}' not found`;return`${p}`}function c(){const d=o.unit;if(!d)return null;if(!d.includes("properties"))return d;let p=n;for(const m of d.split("/"))if(p=p[m],p===void 0)return null;return`${p}`}const l=c(),f=e.jsxs(a.InputGroup,{children:[e.jsx(a.Form.Control,{value:i(),readOnly:!0}),l&&e.jsx(a.InputGroup.Text,{children:l})]}),u=n.options.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:f,headerMode:u})}const un={state:Ge,name:Be,info:Ve,property:Le},fn=un,pn={callables:[],id:"test_object",name:"test_object",online:!0,properties:{number:345,option:"one",state:"1",string:"asbkjdsah"},protocol:"bliss",require_staff:!1,type:"test"},mn={$ref:"#/definitions/HWTestSchema",$schema:"http://json-schema.org/draft-07/schema#",asyncValidate:!1,cache:!0,definitions:{HWTestSchema:{additionalProperties:!1,properties:{callables:{$ref:"#/definitions/HardwareSchema",type:"object"},id:{title:"id",type:"string"},name:{title:"name",type:"string"},online:{title:"online",type:"boolean"},properties:{$ref:"#/definitions/TestPropertiesSchema",type:"object"},protocol:{title:"protocol",type:"string"},require_staff:{title:"require_staff",type:"boolean"},type:{title:"type",type:"string"}},type:"object"},HardwareSchema:{additionalProperties:!1,cache:!0,properties:{},type:"object"},TestPropertiesSchema:{additionalProperties:!1,cache:!0,properties:{number:{format:"integer",title:"number",type:"number"},option:{enum:["one","two","three"],enumNames:[],title:"option",type:"string"},state:{enum:["ON","OFF","UNKNOWN","ERROR"],enumNames:[],readOnly:!0,title:"state",type:"string"},string:{title:"string",type:"string"}},type:"object"}},save_presets:!1},hn={response:pn,schema:mn},xn={default:hn};function M(n){const t={display:"inline-block",minWidth:""};return n.minWidth&&(t.minWidth=`${n.minWidth}em`),e.jsx("div",{style:t,children:e.jsx(a.Badge,{bg:n.variant,title:n.description,children:n.state})})}function Ue(n){const{states:t,variants:o={},descriptions:s={},minWidth:r}=n,i=t[0]??"";if(t.length===0)return e.jsx(M,{state:"NoState",variant:"fatal",description:"The device no not expose any state",minWidth:r});if(t.length===1)return e.jsx(M,{state:i,variant:o[i]??"fatal",description:s[i],minWidth:r});const c={display:"inline-block",minWidth:r?`${r}em`:""};function l(f){return e.jsx(a.Tooltip,{id:"device-state",...f,children:t.map((u,d)=>{const p=s[u],m=u.startsWith("_")?u.slice(1):u;return e.jsxs(a.Row,{className:"gx-0",children:[e.jsx(a.Col,{sm:"3",className:"text-end",children:e.jsx(a.Badge,{className:"text-right",bg:o[u]??"fatal",children:m})}),e.jsx(a.Col,{sm:"9",className:"text-start lh-1 my-auto ps-1",children:p})]})})})}return e.jsx("div",{style:c,children:e.jsx(a.OverlayTrigger,{placement:"top",delay:{show:250,hide:400},overlay:l,children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx(a.Badge,{className:"rounded-end-0",bg:o[i]??"fatal",children:i}),e.jsxs(a.Badge,{className:"rounded-start-0",bg:"secondary",children:["+",t.length-1]})]})})})}const gn=Object.freeze(Object.defineProperty({__proto__:null,HardwareMultiState:Ue,HardwareState:M},Symbol.toStringTag,{value:"Module"}));function pe(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={ON:"danger",OFF:"success",MOVING_ON:"warning",MOVING_OFF:"warning",UNKNOWN:"fatal",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(M,{state:o,minWidth:6,variant:r})}function jn(n){const{hardware:t}=n;return e.jsx(pe,{hardware:t})}function wn(n){var l;const{hardware:t,options:o,disabled:s}=n,r=((l=t.properties)==null?void 0:l.state)??"OFFLINE",i=r==="ON",c=r==="OFF";return e.jsx("div",{style:{display:"grid",gridTemplateRows:"min-content min-content",gridTemplateColumns:"min-content auto",gridGap:"1px"},children:e.jsxs(a.ButtonGroup,{className:"mx-auto",style:{width:"12em"},children:[e.jsx(a.Button,{onClick:()=>{t.actions.call("on")},disabled:i||s,style:{width:"5em"},children:e.jsx("span",{className:"text-nowrap",children:"On"})}),e.jsx(a.Button,{onClick:()=>{t.actions.call("off")},disabled:c||s,style:{width:"5em"},children:e.jsx("span",{className:"text-nowrap",children:"Off"})})]})})}function He(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Air bearing",icon:"fa-hand-point-right",online:t.online}),r=e.jsx(pe,{hardware:t});function i(){return e.jsx(wn,{...n})}const c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i(),headerMode:c})}function k(n){const{value:t,variant:o,style:s,className:r,title:i}=n,c=o?`badge-${o} bg-${o} text-bg-${o} border-${o}`:"border-light";return e.jsx(a.Form.Control,{className:`${c} ${r} bg-secondary`,style:s,value:t,title:i,readOnly:!0})}function Fe(n){return e.jsx(a.Button,{variant:n.isActive?"primary":n.wasActivated?"warning":"secondary",onClick:n.onClick,disabled:n.disabled||n.wasActivated,title:n.title,children:e.jsxs(a.Row,{className:"gx-0",children:[e.jsx("i",{className:`col-sm-4 justify-content-center align-self-center ${n.icon}`}),e.jsx(a.Col,{sm:"8",children:n.children})]})})}function vn(n){var d;const{hardware:t,options:o={},disabled:s}=n;function r(){t.actions.call("on")}function i(){t.actions.call("off")}const c=((d=t.properties)==null?void 0:d.state)??"UNKNOWN",l=c==="MOVING_ON"||c==="MOVING_OFF",f=c==="MOVING_ON",u=c==="MOVING_OFF";return e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{variant:"secondary",disabled:s||l}),e.jsx(a.Dropdown.Menu,{children:e.jsxs(a.Container,{children:[e.jsx(a.Row,{children:e.jsx(a.Col,{className:"text-center",children:"Actions"})}),e.jsx(a.Row,{children:e.jsx(a.Col,{children:e.jsxs(a.ButtonGroup,{children:[e.jsxs(Fe,{icon:"fa fa-arrow-up",wasActivated:f,onClick:()=>{r()},disabled:s||l,title:"Turn on the air bearing",children:["Turn",e.jsx("br",{}),"on"]}),e.jsxs(Fe,{icon:"fa fa-arrow-down",wasActivated:u,onClick:()=>{i()},disabled:s||l,title:"Turn off the air bearing",children:["Turn",e.jsx("br",{}),"off"]})]})})})]})})]})}function yn(n){const{hardware:t,options:o,disabled:s}=n,{state:r}=t.properties??"OFFLINE",c={ON:"danger",OFF:"success",MOVING_ON:"warning",MOVING_OFF:"warning",UNKNOWN:"fatal",OFFLINE:"warning"}[r]??"fatal";return e.jsxs(a.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(k,{variant:c,className:"text-center",style:{minWidth:"10em"},value:r}),e.jsx(vn,{...n})]})}function qe(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Air bearing",icon:"fa-hand-point-right",online:t.online}),r=e.jsx(pe,{hardware:t});function i(){return e.jsx(yn,{...n})}const c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i(),headerMode:c})}const Nn={default:He,protected:qe,state:jn},bn=Nn,_n=["on","off","sync_hard"],$n="airbearing",Sn="airbearing",On=!0,Cn={state:"ON"},In="bliss",Mn=!1,Tn="airbearing",Fn={callables:_n,id:$n,name:Sn,online:On,properties:Cn,protocol:In,require_staff:Mn,type:Tn},Dn={default:Fn};async function D(n){await new Promise(t=>{setTimeout(t,n)})}function V(n){const{name:t,alias:o=null,type:s,setProperty:r,call:i,properties:c,useHardwareContext:l=()=>null}=n,f=l(),u=h.useMemo(()=>{var x,j;const m={setProperty:r,call:i};return(j=f==null?void 0:(x=f.actions).updateHardwareChangeActions)==null||j.call(x,t,m),m},[]),d={id:t,name:t,alias:o,online:!0,properties:c,type:s,actions:u,user_tags:[],locked:null},p=h.useRef(null);return h.useEffect(()=>{(p.current===null||!F.isEqual(p.current,d))&&(p.current=d,f==null||f.actions.updateHardware(t,d))},[t,d]),e.jsx(e.Fragment,{})}function En(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,i]=h.useState("ON");async function c(u,d){if(u==="on"){i("MOVING_ON"),await D(2e3),i("ON");return}if(u==="off"){i("MOVING_OFF"),await D(2e3),i("OFF");return}console.log("AirBearingSimulator: Unsupported call",u,d)}async function l(u,d){console.log("AirBearingSimulator: Unsupported setProperty",u,d)}const f={state:r};return e.jsx(V,{name:t,alias:o,type:"tomoflatmotion",call:c,setProperty:l,properties:f,useHardwareContext:s})}function Rn(n){const t={24:"Y",21:"Z",18:"E",15:"P",12:"T",9:"G",6:"M",3:"k","-3":"m","-6":"µ","-9":"n","-12":"p","-15":"f","-18":"a","-21":"z","-24":"y"},o=Math.log(n)/Math.log(1e3),s=!Number.isInteger(o),r=3*Math.ceil(o-(s?1:0)),i=r===0?"":t[r];return{scalar:n*10**-r,prefix:i,multiplier:10**-r}}function An(n){return n.charAt(0).toUpperCase()+n.slice(1)}function ze(n){if(n<60)return`${Math.round(n)} sec`;const t=Math.round(n/60),o=t%60,s=Math.floor(t/60);return s?`${s} hr ${o} min`:`${o} min`}function kn(n){return n>0?(662607004e-42*299792458/(n*1e-10)/160218e-24*.001).toFixed(4):0}function Pn(n,t){return Number.parseFloat(n.toFixed(t))}const Gn=Object.freeze(Object.defineProperty({__proto__:null,formatEng:Rn,round:Pn,toEnergy:kn,toHoursMins:ze,ucfirst:An},Symbol.toStringTag,{value:"Module"}));function Bn(n){const{hardware:t}=n;function o(){t.actions.call("reset")}const s={"Front End":"feitlk",Experimental:"expitlk",PSS:"pssitlk"},r={Current:`${t.properties.current.toFixed(1)} mA`,Mode:t.properties.mode,Refill:ze(t.properties.refill),Message:e.jsx("pre",{children:t.properties.message})};function i(c){if(!(c in t.properties))return"UNKNOWN";const l=t.properties[c];return!l||typeof l!="string"?"UNKNOWN":l}return e.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(a.Popover,{id:"popid",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("h6",{children:"Interlocks"}),e.jsx(a.Container,{children:F.map(s,(c,l)=>e.jsxs(a.Row,{children:[e.jsxs(a.Col,{children:[l,":"]}),e.jsx(a.Col,{children:e.jsx(a.Badge,{bg:i(c)==="ON"?"success":"danger",children:i(c)})})]},l))}),e.jsx("h6",{children:"Ring Status"}),e.jsx(a.Container,{children:F.map(r,(c,l)=>e.jsxs(a.Row,{children:[e.jsxs(a.Col,{children:[l,":"]}),e.jsx(a.Col,{children:c})]},l))}),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:"Shutter Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function We(n){const{hardware:t,options:o={}}=n;function s(){t.actions.call(t.properties.frontend==="FE open"?"close":"open")}return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(w,{name:"Frontend",icon:"fam-hardware-frontend",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.frontend==="FE open"?"danger":"success",onClick:s,disabled:n.disabled,children:t.properties.frontend==="FE open"?"Close":"Open"}),e.jsx(Bn,{...n})]})})]})}const Vn={default:We},Ln=Vn,Un=["open","close","reset"],Hn="fe",qn="fe",zn=!0,Wn={current:196.58051532652968,expitlk:"ON",feitlk:"ON",frontend:"FE open",pssitlk:"ON",refill:2287,state:"RUNNING",mode:"USM",message:"USM until 18:00",status:`State : The Front End is open with automatic opening mode on
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react-bootstrap"),h=require("react"),D=require("lodash"),cn=require("classnames"),ln=require("lodash/debounce"),dn=require("semver");require("react-bootstrap-typeahead/css/Typeahead.css");require("react-bootstrap-typeahead/css/Typeahead.bs5.css");const L=require("react-bootstrap-typeahead"),un=require("js-quantities"),fn=require("debug"),X=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},pn=X(h),P=X(cn),mn=X(ln),hn=X(dn),xn=X(un),Se=X(fn);function Be(n){var l;const{hardware:t}=n,{online:o,locked:s=null}=t,r=o?(s!==null?"LOCKED":(l=t.properties)==null?void 0:l.state)||"UNKNOWN":"OFFLINE",c={READY:"success",OFFLINE:"secondary",MOVING:"warning",DISABLED:"secondary",UNKNOWN:"danger",ERROR:"danger",FAILED:"danger",LOCKED:"warning"}[r]||"success";return e.jsx(i.Badge,{bg:c,children:r})}function Ve(n){const{hardware:t}=n;return e.jsx(Be,{hardware:t})}function Le(n){const{hardware:t,options:o}=n;function s(){return t.name?t.name:t.id}function r(){return o.overrideName!==void 0?o.overrideName:t.alias?t.alias:t.name?t.name:t.id}function a(){if(o.overrideName!==void 0)return`Real name: ${s()}`;if(t.alias)return`Real name: ${t.name}`}const c=r(),l=a();return e.jsx("span",{title:l,children:c})}function Ue(n){const{hardware:t,options:o={}}=n;function s(){const r=o.property;if(r===void 0)return"property is not set";if(r===null)return"property is null";let a=t;for(const c of r.split("/"))if(a=a[c],a===void 0)return`property '${r}' not found`;return`${a}`}return e.jsx(e.Fragment,{children:s()})}function gn(n){const{activeMessage:t="Online",inactiveMessage:o="Offline",message:s="This device is"}=n;return e.jsx("div",{className:`dot-indicator small bg-${n.online?"success":"danger"}`,title:`${s} ${n.online?t:o}`})}function y(n){const{name:t,icon:o}=n;return e.jsxs("div",{className:"icon",title:t,children:[e.jsx("i",{className:`fa ${o}`}),e.jsx(gn,{...n})]})}function v(n){const{headerMode:t,hardware:o}=n;function s(){return o.alias?o.alias:o.name?o.name:o.id}const r=s();switch(t){case"front":return e.jsx("div",{className:"hw-component",children:e.jsxs("div",{className:"hw-single",children:[n.widgetIcon,e.jsx("div",{className:"name",children:r}),e.jsx("div",{className:"d-inline-block",children:n.widgetContent})]})});case"none":return e.jsx("div",{className:"hw-component",children:e.jsx("div",{className:"hw-single",children:n.widgetContent})});case"state":return n.widgetState;default:return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[n.widgetIcon,e.jsx("div",{className:"name",children:e.jsx(i.Form.Label,{htmlFor:o.id,children:r})}),n.widgetState,n.hardware.errors&&n.hardware.errors.length>0&&e.jsx(i.OverlayTrigger,{trigger:"click",placement:"bottom",rootClose:!0,overlay:e.jsxs(i.Popover,{id:n.hardware.id,style:{maxWidth:500},children:[e.jsx(i.Popover.Header,{children:"Device Errors"}),e.jsxs(i.Popover.Body,{children:["There were errors with properties on this device:",e.jsx("ul",{children:n.hardware.errors.map(a=>e.jsxs("li",{children:[a.property,":",e.jsxs("span",{className:"stack-trace",children:[a.traceback,e.jsx("br",{}),a.exception]})]}))})]})]}),children:e.jsx(i.Button,{variant:"danger",size:"sm",children:e.jsx("i",{className:"fa fa-exclamation-triangle"})})})]}),e.jsx("div",{className:"hw-content",children:n.widgetContent})]})}}function A(n){const{value:t,variant:o,style:s,className:r,title:a}=n,c=o?`badge-${o} bg-${o} text-bg-${o} border-${o}`:"border-light";return e.jsx(i.Form.Control,{className:`${c} ${r} bg-secondary`,style:s,value:t,title:a,readOnly:!0})}function jn(n){const t=n.online?"READY":"OFFLINE";return e.jsx(i.Badge,{bg:t==="READY"?"success":"warning",children:t})}function He(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Optic",icon:"fa-cog",online:t.online}),r=e.jsx(jn,{...t});function a(){const d=o.property;if(d===void 0)return"property is not set";if(d===null)return"property is null";let p=t;for(const m of d.split("/"))if(p=p[m],p===void 0)return`property '${d}' not found`;return`${p}`}function c(){const d=o.unit;if(!d)return null;if(!d.includes("properties"))return d;let p=n;for(const m of d.split("/"))if(p=p[m],p===void 0)return null;return`${p}`}const l=c(),f=e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(A,{value:a()}),l&&e.jsx(i.InputGroup.Text,{children:l})]}),u=n.options.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:f,headerMode:u})}const wn={state:Ve,name:Le,info:Ue,property:He},yn=wn,vn={callables:[],id:"test_object",name:"test_object",online:!0,properties:{number:345,option:"one",state:"1",string:"asbkjdsah"},protocol:"bliss",require_staff:!1,type:"test"},Nn={$ref:"#/definitions/HWTestSchema",$schema:"http://json-schema.org/draft-07/schema#",asyncValidate:!1,cache:!0,definitions:{HWTestSchema:{additionalProperties:!1,properties:{callables:{$ref:"#/definitions/HardwareSchema",type:"object"},id:{title:"id",type:"string"},name:{title:"name",type:"string"},online:{title:"online",type:"boolean"},properties:{$ref:"#/definitions/TestPropertiesSchema",type:"object"},protocol:{title:"protocol",type:"string"},require_staff:{title:"require_staff",type:"boolean"},type:{title:"type",type:"string"}},type:"object"},HardwareSchema:{additionalProperties:!1,cache:!0,properties:{},type:"object"},TestPropertiesSchema:{additionalProperties:!1,cache:!0,properties:{number:{format:"integer",title:"number",type:"number"},option:{enum:["one","two","three"],enumNames:[],title:"option",type:"string"},state:{enum:["ON","OFF","UNKNOWN","ERROR"],enumNames:[],readOnly:!0,title:"state",type:"string"},string:{title:"string",type:"string"}},type:"object"}},save_presets:!1},bn={response:vn,schema:Nn},_n={default:bn};function F(n){const t={display:"inline-block",minWidth:""};return n.minWidth&&(t.minWidth=`${n.minWidth}em`),e.jsx("div",{style:t,children:e.jsx(i.Badge,{bg:n.variant,title:n.description,children:n.state})})}function qe(n){const{states:t,variants:o={},descriptions:s={},minWidth:r}=n,a=t[0]??"";if(t.length===0)return e.jsx(F,{state:"NoState",variant:"fatal",description:"The device no not expose any state",minWidth:r});if(t.length===1)return e.jsx(F,{state:a,variant:o[a]??"fatal",description:s[a],minWidth:r});const c={display:"inline-block",minWidth:r?`${r}em`:""};function l(f){return e.jsx(i.Tooltip,{id:"device-state",...f,children:t.map((u,d)=>{const p=s[u],m=u.startsWith("_")?u.slice(1):u;return e.jsxs(i.Row,{className:"gx-0",children:[e.jsx(i.Col,{sm:"3",className:"text-end",children:e.jsx(i.Badge,{className:"text-right",bg:o[u]??"fatal",children:m})}),e.jsx(i.Col,{sm:"9",className:"text-start lh-1 my-auto ps-1",children:p})]})})})}return e.jsx("div",{style:c,children:e.jsx(i.OverlayTrigger,{placement:"top",delay:{show:250,hide:400},overlay:l,children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx(i.Badge,{className:"rounded-end-0",bg:o[a]??"fatal",children:a}),e.jsxs(i.Badge,{className:"rounded-start-0",bg:"secondary",children:["+",t.length-1]})]})})})}const $n=Object.freeze(Object.defineProperty({__proto__:null,HardwareMultiState:qe,HardwareState:F},Symbol.toStringTag,{value:"Module"}));function he(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={ON:"danger",OFF:"success",MOVING_ON:"warning",MOVING_OFF:"warning",UNKNOWN:"fatal",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(F,{state:o,minWidth:6,variant:r})}function Sn(n){const{hardware:t}=n;return e.jsx(he,{hardware:t})}function Cn(n){var l;const{hardware:t,options:o,disabled:s}=n,r=((l=t.properties)==null?void 0:l.state)??"OFFLINE",a=r==="ON",c=r==="OFF";return e.jsx("div",{style:{display:"grid",gridTemplateRows:"min-content min-content",gridTemplateColumns:"min-content auto",gridGap:"1px"},children:e.jsxs(i.ButtonGroup,{className:"mx-auto",style:{width:"12em"},children:[e.jsx(i.Button,{onClick:()=>{t.actions.call("on")},disabled:a||s,style:{width:"5em"},children:e.jsx("span",{className:"text-nowrap",children:"On"})}),e.jsx(i.Button,{onClick:()=>{t.actions.call("off")},disabled:c||s,style:{width:"5em"},children:e.jsx("span",{className:"text-nowrap",children:"Off"})})]})})}function ze(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Air bearing",icon:"fa-hand-point-right",online:t.online}),r=e.jsx(he,{hardware:t});function a(){return e.jsx(Cn,{...n})}const c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a(),headerMode:c})}function Ae(n){return e.jsx(i.Button,{variant:n.isActive?"primary":n.wasActivated?"warning":"secondary",onClick:n.onClick,disabled:n.disabled||n.wasActivated,title:n.title,children:e.jsxs(i.Row,{className:"gx-0",children:[e.jsx("i",{className:`col-sm-4 justify-content-center align-self-center ${n.icon}`}),e.jsx(i.Col,{sm:"8",children:n.children})]})})}function On(n){var d;const{hardware:t,options:o={},disabled:s}=n;function r(){t.actions.call("on")}function a(){t.actions.call("off")}const c=((d=t.properties)==null?void 0:d.state)??"UNKNOWN",l=c==="MOVING_ON"||c==="MOVING_OFF",f=c==="MOVING_ON",u=c==="MOVING_OFF";return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary",disabled:s||l}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Actions"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsxs(i.ButtonGroup,{children:[e.jsxs(Ae,{icon:"fa fa-arrow-up",wasActivated:f,onClick:()=>{r()},disabled:s||l,title:"Turn on the air bearing",children:["Turn",e.jsx("br",{}),"on"]}),e.jsxs(Ae,{icon:"fa fa-arrow-down",wasActivated:u,onClick:()=>{a()},disabled:s||l,title:"Turn off the air bearing",children:["Turn",e.jsx("br",{}),"off"]})]})})})]})})]})}function In(n){const{hardware:t,options:o,disabled:s}=n,{state:r}=t.properties??"OFFLINE",c={ON:"danger",OFF:"success",MOVING_ON:"warning",MOVING_OFF:"warning",UNKNOWN:"fatal",OFFLINE:"warning"}[r]??"fatal";return e.jsxs(i.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(A,{variant:c,className:"text-center",style:{minWidth:"10em"},value:r}),e.jsx(On,{...n})]})}function We(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Air bearing",icon:"fa-hand-point-right",online:t.online}),r=e.jsx(he,{hardware:t});function a(){return e.jsx(In,{...n})}const c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a(),headerMode:c})}const Mn={default:ze,protected:We,state:Sn},Tn=Mn,Fn=["on","off","sync_hard"],Dn="airbearing",An="airbearing",Rn=!0,En={state:"ON"},kn="bliss",Pn=!1,Gn="airbearing",Bn={callables:Fn,id:Dn,name:An,online:Rn,properties:En,protocol:kn,require_staff:Pn,type:Gn},Vn={default:Bn};async function R(n){await new Promise(t=>{setTimeout(t,n)})}function U(n){const{name:t,alias:o=null,type:s,setProperty:r,call:a,properties:c,useHardwareContext:l=()=>null}=n,f=l(),u=h.useMemo(()=>{var g,w;const m={setProperty:r,call:a};return(w=f==null?void 0:(g=f.actions).updateHardwareChangeActions)==null||w.call(g,t,m),m},[]),d={id:t,name:t,alias:o,online:!0,properties:c,type:s,actions:u,user_tags:[],locked:null},p=h.useRef(null);return h.useEffect(()=>{(p.current===null||!D.isEqual(p.current,d))&&(p.current=d,f==null||f.actions.updateHardware(t,d))},[t,d]),e.jsx(e.Fragment,{})}function Ln(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("ON");async function c(u,d){if(u==="on"){a("MOVING_ON"),await R(2e3),a("ON");return}if(u==="off"){a("MOVING_OFF"),await R(2e3),a("OFF");return}console.log("AirBearingSimulator: Unsupported call",u,d)}async function l(u,d){console.log("AirBearingSimulator: Unsupported setProperty",u,d)}const f={state:r};return e.jsx(U,{name:t,alias:o,type:"tomoflatmotion",call:c,setProperty:l,properties:f,useHardwareContext:s})}function Un(n){const t={24:"Y",21:"Z",18:"E",15:"P",12:"T",9:"G",6:"M",3:"k","-3":"m","-6":"µ","-9":"n","-12":"p","-15":"f","-18":"a","-21":"z","-24":"y"},o=Math.log(n)/Math.log(1e3),s=!Number.isInteger(o),r=3*Math.ceil(o-(s?1:0)),a=r===0?"":t[r];return{scalar:n*10**-r,prefix:a,multiplier:10**-r}}function Hn(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Ye(n){if(n<60)return`${Math.round(n)} sec`;const t=Math.round(n/60),o=t%60,s=Math.floor(t/60);return s?`${s} hr ${o} min`:`${o} min`}function qn(n){return n>0?(662607004e-42*299792458/(n*1e-10)/160218e-24*.001).toFixed(4):0}function zn(n,t){return Number.parseFloat(n.toFixed(t))}const Wn=Object.freeze(Object.defineProperty({__proto__:null,formatEng:Un,round:zn,toEnergy:qn,toHoursMins:Ye,ucfirst:Hn},Symbol.toStringTag,{value:"Module"}));function Yn(n){const{hardware:t}=n;function o(){t.actions.call("reset")}const s={"Front End":"feitlk",Experimental:"expitlk",PSS:"pssitlk"},r={Current:`${t.properties.current.toFixed(1)} mA`,Mode:t.properties.mode,Refill:Ye(t.properties.refill),Message:e.jsx("pre",{children:t.properties.message})};function a(c){if(!(c in t.properties))return"UNKNOWN";const l=t.properties[c];return!l||typeof l!="string"?"UNKNOWN":l}return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("h6",{children:"Interlocks"}),e.jsx(i.Container,{children:D.map(s,(c,l)=>e.jsxs(i.Row,{children:[e.jsxs(i.Col,{children:[l,":"]}),e.jsx(i.Col,{children:e.jsx(i.Badge,{bg:a(c)==="ON"?"success":"danger",children:a(c)})})]},l))}),e.jsx("h6",{children:"Ring Status"}),e.jsx(i.Container,{children:D.map(r,(c,l)=>e.jsxs(i.Row,{children:[e.jsxs(i.Col,{children:[l,":"]}),e.jsx(i.Col,{children:c})]},l))}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(i.Button,{disabled:n.disabled,onClick:o,children:"Reset"})})]})]}),children:e.jsx(i.Button,{className:"flex-grow-0",title:"Shutter Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Ke(n){const{hardware:t,options:o={}}=n;function s(){t.actions.call(t.properties.frontend==="FE open"?"close":"open")}return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(y,{name:"Frontend",icon:"fam-hardware-frontend",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(i.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(i.ButtonGroup,{className:"d-flex",children:[e.jsx(i.Button,{variant:t.properties.frontend==="FE open"?"danger":"success",onClick:s,disabled:n.disabled,children:t.properties.frontend==="FE open"?"Close":"Open"}),e.jsx(Yn,{...n})]})})]})}const Kn={default:Ke},Qn=Kn,Xn=["open","close","reset"],Jn="fe",Zn="fe",eo=!0,to={current:196.58051532652968,expitlk:"ON",feitlk:"ON",frontend:"FE open",pssitlk:"ON",refill:2287,state:"RUNNING",mode:"USM",message:"USM until 18:00",status:`State : The Front End is open with automatic opening mode on
2
2
  Mode : Beam Delivery
3
3
  Automatic : Automatic opening active
4
4
  Type : UHV
@@ -7,7 +7,7 @@ Module 1 Gate Valve 1: Open
7
7
  Module 1 Gate Valve 2: Open
8
8
  Module 2 Gate Valve 1: Open
9
9
 
10
- `},Yn="tango",Kn=!0,Qn="frontend",Xn={callables:Un,id:Hn,name:qn,online:zn,properties:Wn,protocol:Yn,require_staff:Kn,type:Qn},Jn={default:Xn};function Zn(n){const{hardware:t}=n,o=()=>{t.actions.call(t.properties.state==="ON"?"off":"on")};return e.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(a.Popover,{id:"popid",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:t.properties.state==="ON"?"Off":"On"})})]})]}),children:e.jsx(a.Button,{title:"Gauge Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Ye(n){const{hardware:t,options:o={}}=n;return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(w,{name:"Gauge",icon:"fam-hardware-gauge",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(a.Badge,{bg:t.properties.state==="ON"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(a.InputGroup,{children:[e.jsx(a.Form.Control,{value:t.properties.pressure.toExponential(o.precision||3),disabled:!0}),(t.properties.unit||o.unit)&&e.jsx(a.InputGroup.Text,{children:t.properties.unit||o.unit}),e.jsx(Zn,{...n})]})})]})}const eo={default:Ye},to=eo,no=["off","on"],oo="pir121",so="pir121",ro=!0,ao={pressure:.0007999999797903001,state:"ON",status:`
10
+ `},no="tango",oo=!0,so="frontend",ro={callables:Xn,id:Jn,name:Zn,online:eo,properties:to,protocol:no,require_staff:oo,type:so},io={default:ro};function ao(n){const{hardware:t}=n,o=()=>{t.actions.call(t.properties.state==="ON"?"off":"on")};return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.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(i.Button,{disabled:n.disabled,onClick:o,children:t.properties.state==="ON"?"Off":"On"})})]})]}),children:e.jsx(i.Button,{title:"Gauge Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Qe(n){const{hardware:t,options:o={}}=n;return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(y,{name:"Gauge",icon:"fam-hardware-gauge",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(i.Badge,{bg:t.properties.state==="ON"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(i.InputGroup,{children:[e.jsx(i.Form.Control,{value:t.properties.pressure.toExponential(o.precision||3),disabled:!0}),(t.properties.unit||o.unit)&&e.jsx(i.InputGroup.Text,{children:t.properties.unit||o.unit}),e.jsx(ao,{...n})]})})]})}const co={default:Qe},lo=co,uo=["off","on"],fo="pir121",po="pir121",mo=!0,ho={pressure:.0007999999797903001,state:"ON",status:`
11
11
  Gauge is underrange - Channel B2 (4)
12
12
  Rel. | Lower | Upper | SA | State
13
13
  1 | 1.0e-6| 3.0e-6| 1 | ON
@@ -17,7 +17,7 @@ Rel. | Lower | Upper | SA | State
17
17
  A | 4.0e-3| 1.0e-5| 6 | ON
18
18
  B | 4.0e-3| 1.0e-5| 8 | ON
19
19
 
20
- HDB Storage OK`},io="tango",co=!0,lo="gauge",uo={callables:no,id:oo,name:so,online:ro,properties:ao,protocol:io,require_staff:co,type:lo},fo=["off","on"],po="pen121",mo="pen121",ho=!0,xo={pressure:13999999737279722e-23,state:"ON",status:`Gauge is ON - Channel B1 (3)
20
+ HDB Storage OK`},xo="tango",go=!0,jo="gauge",wo={callables:uo,id:fo,name:po,online:mo,properties:ho,protocol:xo,require_staff:go,type:jo},yo=["off","on"],vo="pen121",No="pen121",bo=!0,_o={pressure:13999999737279722e-23,state:"ON",status:`Gauge is ON - Channel B1 (3)
21
21
  Rel. | Lower | Upper | SA | State
22
22
  1 | 1.0e-6| 3.0e-6| 1 | ON
23
23
  2 | 4.0e-3| 6.0e-3| 2 | ON
@@ -25,13 +25,13 @@ Rel. | Lower | Upper | SA | State
25
25
  4 | 4.0e-3| 6.0e-3| 4 | ON
26
26
  A | 4.0e-3| 1.0e-5| 6 | ON
27
27
  B | 4.0e-3| 1.0e-5| 8 | ON
28
- `},go="tango",jo=!0,wo="gauge",vo={callables:fo,id:po,name:mo,online:ho,properties:xo,protocol:go,require_staff:jo,type:wo},yo={default:uo,default2:vo},No=h.forwardRef((n,t)=>{const o=h.useRef(null),s=h.useRef(),[r,i]=h.useState(n.step),[c,l]=h.useState(!1),f=_=>{const H=t;if(o.current===null)return;let Q=Number.parseFloat(H.current.value);if(o.current.value.startsWith("*")){const X=Number.parseFloat(o.current.value.replace("*",""));Q=_?Q*X:Q/X}else{const X=Number.parseFloat(o.current.value);Q+=_?X:-X}H.current.value=`${Q}`,n.onStep&&n.onStep({target:H.current})},{onStep:u,step:d,overlay:p,incIcon:m,decIcon:x,swapIncDec:j,onKeyDown:g,onBlur:b,horizontalArrows:S,largeArrows:E,disabled:T,stepOnly:y,...N}=n,$=_=>{_.key==="ArrowUp"?(_.preventDefault(),l(!0),f(!0)):_.key==="ArrowDown"?(_.preventDefault(),l(!0),f(!1)):g&&g(_)};c&&(s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{var _;(_=t==null?void 0:t.current)==null||_.focus()},100)),h.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const I=()=>{s.current&&clearTimeout(s.current),l(!1),b&&b()};if(!n.step)return e.jsx(a.Form.Control,{ref:t,type:"number",step:"any",onKeyDown:$,onBlur:I,disabled:T,onClick:_=>{_.stopPropagation()},...N});const L=F.map(n.steps||[n.step],_=>e.jsx("option",{value:_,children:_},_)),U=m||x;return e.jsx("div",{className:A.default("numeric-step",{"numeric-step-large":E,"numeric-step-horizontal":S}),children:e.jsxs(a.InputGroup,{children:[e.jsx(a.Form.Control,{onKeyDown:$,onBlur:I,ref:t,type:"number",step:"any",disabled:T||y,...N}),e.jsxs(e.Fragment,{children:[p,!p&&e.jsxs(a.InputGroup.Text,{className:`d-flex flex-column ${U?"inc-dec":""}`,children:[e.jsx(a.Form.Control,{ref:o,as:"select",className:"step-size",defaultValue:r,disabled:T,onChange:_=>i(Number.parseFloat(_.target.value)),children:L}),n.unit&&e.jsx("div",{children:n.unit}),!m&&!x&&e.jsxs(e.Fragment,{children:[e.jsx(a.Button,{className:"step step-up",disabled:n.disabled,onClick:_=>f(!0)}),e.jsx(a.Button,{className:"step step-down",disabled:n.disabled,onClick:_=>f(!1)})]})]}),x&&j&&e.jsx(a.Button,{disabled:n.disabled,onClick:_=>f(!1),children:e.jsx("i",{className:`fa fa-fw fa-${x}`})}),m&&e.jsx(a.Button,{disabled:n.disabled,onClick:_=>f(!0),children:e.jsx("i",{className:`fa fa-fw fa-${m}`})}),x&&!j&&e.jsx(a.Button,{disabled:n.disabled,onClick:_=>f(!1),children:e.jsx("i",{className:`fa fa-fw fa-${x}`})})]})]})})}),Ke=No;function me(n){const t=h.useRef(null),[o,s]=h.useState(!1),[r,i]=h.useState(!1);h.useEffect(()=>{t.current&&(n.hardwareValue===null?t.current.value="":n.precision!==void 0?t.current.value=n.hardwareValue.toFixed(n.precision):t.current.value=n.hardwareValue.toString(),s(!1))},[n.hardwareValue]);function c(p){let m=p;n.precision!==void 0&&(m=Number.parseFloat(m).toFixed(n.precision)),t!=null&&t.current&&(t.current.value=m)}function l(){o&&setTimeout(()=>{c(n.hardwareValue),s(!1)},3e3)}function f(p){n.hardwareValue!==null&&s(p.target.value!==n.hardwareValue.toString())}function u(p){s(!1);const m=n.onMoveRequested(p.target.value);m&&m.catch(()=>{i(!0),setTimeout(()=>{c(n.hardwareValue),i(!1)},2e3)})}function d(p){switch(p.key){case"Enter":{s(!1);const m=Number.parseFloat(p.target.value),x=n.onMoveRequested(m);x&&x.catch(()=>{i(!0),setTimeout(()=>{c(n.hardwareValue),i(!1)},2e3)})}p.preventDefault(),p.stopPropagation();break;case"Esc":case"Escape":o&&(i(!1),s(!1),c(n.hardwareValue)),p.target.blur(),p.preventDefault(),p.stopPropagation();break}}return e.jsx(Ke,{id:n.id,className:A.default({"form-control-edited":o,"form-control-error":r,"hw-moving":n.hardwareIsMoving}),type:n.readOnly?"text":"number",ref:t,precision:n.precision,onChange:f,onBlur:l,onStep:u,onKeyDown:d,disabled:n.hardwareIsDisabled||n.readOnly||!n.hardwareIsReady,stepOnly:n.stepOnly,step:n.step,steps:n.steps,incIcon:n.incIcon,decIcon:n.decIcon,swapIncDec:n.swapIncDec,horizontalArrows:n.horizontalArrows,largeArrows:n.largeArrows,overlay:n.hardwareIsMoving&&!n.hardwareIsDisabled?e.jsx(a.Button,{variant:"danger",onClick:n.onAbortRequested,children:e.jsx("i",{className:"fa fa-times"})}):null})}function Qe(n){const{hardware:t,options:o={},disabled:s}=n;function r(u){return t.actions.setProperty("power",u)}function i(u){return t.actions.call(u?"on":"off")}const c=t.properties.state,l=e.jsx(w,{name:"Laser",icon:"fam-hardware-laser",online:t.online}),f=e.jsx(M,{state:c,minWidth:6,variant:c==="ON"?"success":"warning"});return e.jsx(v,{hardware:t,widgetIcon:l,widgetState:f,widgetContent:e.jsxs(a.InputGroup,{children:[e.jsx(me,{id:t.id,hardwareValue:t.properties.power,hardwareIsDisabled:!1,hardwareIsReady:!0,hardwareIsMoving:c==="MOVING",onMoveRequested:r,onAbortRequested:()=>null,precision:1,readOnly:!1,step:o.step,steps:o.steps,incIcon:void 0,decIcon:void 0,swapIncDec:void 0}),e.jsx(a.Button,{size:"sm",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>{i(t.properties.state!=="ON")},children:e.jsx("i",{className:t.properties.state==="ON"?"fa fa-toggle-on":"fa fa-toggle-off"})})]})})}const bo={default:Qe},_o=bo,$o=[],So="yag1",Oo="yag1",Co=!0,Io={power:5,state:"ON"},Mo="bliss",To=!1,Fo="laser",Do={callables:$o,id:So,name:Oo,online:Co,properties:Io,protocol:Mo,require_staff:To,type:Fo},Eo={default:Do};function Ro(n){var o;const{hardware:t}=n;return e.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(a.Popover,{id:"laserheating_overlay",children:[e.jsxs(a.Popover.Header,{children:[t.name," details"]}),e.jsx(a.Popover.Body,{children:e.jsxs(a.Container,{children:[e.jsxs(a.Row,{children:[e.jsx(a.Col,{children:"Background Mode"}),e.jsx(a.Col,{children:t.properties.background_mode})]}),e.jsxs(a.Row,{children:[e.jsx(a.Col,{children:"Calibration"}),e.jsx(a.Col,{children:t.properties.current_calibration})]}),e.jsxs(a.Row,{children:[e.jsx(a.Col,{children:"Fit Wavelength"}),e.jsxs(a.Col,{children:[(o=t.properties.fit_wavelength)==null?void 0:o.join(" - ")," ",e.jsx("span",{children:"nm"})]})]})]})})]}),children:e.jsx(a.Button,{children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Xe(n){const{hardware:t,options:o={},disabled:s}=n,[r,i]=h.useState(!1);function c(p){return p<=0?Promise.reject(new Error("exposure_time must be > 0")):t.actions.setProperty("exposure_time",p)}function l(){i(!0);const p=t.actions.call("measure");return p!==void 0&&(console.log("pending"),p.then(()=>{i(!1)}).catch(m=>{i(!1)})),p}const f=t.properties.state,u=e.jsx(w,{name:"Laser Heating",icon:"fa-fire",online:t.online}),d=e.jsx(M,{state:f,minWidth:6,variant:f==="READY"?"success":"warning"});return e.jsx(v,{hardware:t,widgetIcon:u,widgetState:d,widgetContent:e.jsxs(a.InputGroup,{children:[e.jsx(me,{id:t.id,hardwareValue:t.properties.exposure_time,hardwareIsReady:!0,hardwareIsDisabled:n.disabled,hardwareIsMoving:!1,onMoveRequested:c,onAbortRequested:()=>null,precision:1,readOnly:!1,step:o.exposureStep,steps:o.exposureSteps,incIcon:void 0,decIcon:void 0,swapIncDec:void 0}),e.jsx(a.InputGroup.Text,{children:"s"}),e.jsx(a.Button,{size:"sm",disabled:n.disabled||r,onClick:()=>{l()},children:r?e.jsx("i",{className:"fa fa-spinner fa-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"fa fa-play me-1"}),"Measure"]})}),e.jsx(Ro,{hardware:t,disabled:n.disabled})]})})}const Ao={default:Xe},ko=Ao,Po=[],Go="laserheating",Bo="laserheating",Vo=!0,Lo={exposure_time:.5,state:"ON",background_mode:"READY",fit_wavelength:[500,650],current_calibration:"/path/to/file"},Uo="bliss",Ho=!1,qo="laserheating",zo={callables:Po,id:Go,name:Bo,online:Vo,properties:Lo,protocol:Uo,require_staff:Ho,type:qo},Wo={default:zo};function Je(n){const t=h.useRef(null),{hardware:o,options:s={}}=n;function r(c){o.actions.setProperty("intensity",c)}const i=h.useCallback(an.default(r,100),[]);return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(w,{name:"Light",icon:"fa-lightbulb-o",online:o.online}),e.jsx("div",{className:"name",children:o.name}),e.jsx(a.Badge,{bg:o.properties.state==="ON"?"success":"danger",children:o.properties.state})]}),e.jsxs("div",{className:"hw-content",children:[e.jsx(a.Form.Control,{ref:t,disabled:n.disabled,type:"range",min:"0",max:"100",onChange:c=>i(Number.parseFloat(c.target.value)),defaultValue:o.properties.intensity}),e.jsxs("div",{children:[e.jsx(a.Button,{disabled:o.properties.intensity===0,size:"sm",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>i(0),children:e.jsx("i",{className:"fa fa-power-off"})}),e.jsxs("span",{className:"float-end",children:[o.properties.intensity," %"]})]})]})]})}const Yo={default:Je},Ko=Yo,Qo=[],Xo="light_vlm",Jo="light_vlm",Zo=!0,es={intensity:0,state:"ON",temperature:23.2},ts="bliss",ns=!1,os="light",ss={callables:Qo,id:Xo,name:Jo,online:Zo,properties:es,protocol:ts,require_staff:ns,type:os},rs={default:ss};function z(n){const{hardware:t}=n,{online:o,locked:s=null}=t,r=t.properties.state??"UNKNOWN";console.log(r);const i=o?(r==="ACQUIRING"?r:s!==null?"LOCKED":r)||"UNKNOWN":"OFFLINE",c={UNKNOWN:"critical",ACQUIRING:"warning",READY:"success",OFFLINE:"secondary",LOCKED:"warning"},l=c[i]??c.UNKNOWN;return e.jsx(M,{state:i,minWidth:6,variant:l})}function as(n){const{hardware:t}=n;return e.jsx(z,{hardware:t})}function De(n){const{hardware:t,options:o={}}=n;return e.jsx(a.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:e.jsx("div",{children:t.name})})}function Ze(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(z,{hardware:t}),i=o.header||"top";return i==="none"?e.jsx(De,{...n}):e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:e.jsx(De,{...n}),headerMode:i})}function Ee(n){const{hardware:t,options:o={}}=n,[s,r]=t.properties.size??["?","?"];return e.jsxs(a.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:[e.jsxs("div",{children:[s," × ",r]}),e.jsx("div",{className:"ms-auto",children:e.jsx("small",{children:e.jsx("small",{children:"px"})})})]})}function et(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(z,{hardware:t}),i=o.header??"top";return i==="none"?e.jsx(Ee,{...n}):e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:e.jsx(Ee,{...n}),headerMode:i})}function is(n){const{hardware:t}=n,{properties:o}=t,[s,r]=o.flip,i=o.rotation??0,c=!s&&!r&&i===0;return e.jsx("div",{children:e.jsxs(a.InputGroup.Text,{children:[s&&e.jsxs(a.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Flip",e.jsx("i",{className:"fa fa-fw fa-left-right"})]}),r&&e.jsxs(a.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Flip",e.jsx("i",{className:"fa fa-fw fa-up-down"})]}),i!==0&&e.jsxs(a.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Rot ",i.toFixed(0),e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]}),c&&e.jsx(a.Badge,{bg:"secondary",style:{fontSize:"130%"},title:"No transformation",children:"None"})]})})}function tt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(z,{hardware:t}),i=e.jsx(e.Fragment,{children:e.jsx(is,{hardware:t})}),c=o.header??"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function cs(n){const{hardware:t,disabled:o}=n,{properties:s}=t,[r,i]=s.binning,c=r===i?r:0;function l(f){t.actions.setProperty("binning",[f,f])}return e.jsxs(a.InputGroup,{children:[e.jsx(a.InputGroup.Text,{title:"Binning applied to the detector",children:e.jsx("i",{className:"fa fa-fw fa-ruler-combined fa-2x"})}),e.jsx(a.Form.Control,{value:`${s.binning[0]}`,readOnly:!0}),e.jsx(a.Form.Control,{value:`${s.binning[1]}`,readOnly:!0}),e.jsx(a.Button,{variant:c===1?"primary":"secondary",onClick:()=>{l(1)},disabled:o,children:"1"}),e.jsx(a.Button,{variant:c===2?"primary":"secondary",onClick:()=>{l(2)},disabled:o,children:"2"}),e.jsx(a.Button,{variant:c===3?"primary":"secondary",onClick:()=>{l(3)},disabled:o,children:"3"}),e.jsx(a.Button,{variant:c===4?"primary":"secondary",onClick:()=>{l(4)},disabled:o,children:"4"})]})}function nt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(z,{hardware:t}),i=e.jsx(e.Fragment,{children:e.jsx(cs,{...n})}),c=o.header??"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function ls(n){const{hardware:t}=n,{properties:o}=t;return e.jsxs(a.InputGroup,{children:[e.jsx(a.InputGroup.Text,{title:"Rotation applied to the detector",children:e.jsx("i",{className:"fa fa-fw fa-crop-simple fa-2x"})}),e.jsx(a.Form.Control,{value:`${o.roi[0]}`,readOnly:!0}),e.jsx(a.Form.Control,{value:`${o.roi[1]}`,readOnly:!0}),e.jsx(a.Form.Control,{value:`${o.roi[2]}`,readOnly:!0}),e.jsx(a.Form.Control,{value:`${o.roi[3]}`,readOnly:!0}),e.jsx(a.InputGroup.Text,{children:"px"})]})}function ot(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(z,{hardware:t}),i=e.jsx(e.Fragment,{children:e.jsx(ls,{hardware:t})}),c=o.header??"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function ds(n){const{hardware:t}=n,{properties:o}=t,s=o.static,[r,i]=(s==null?void 0:s.image_max_dim)??["?","?"];return e.jsxs(a.InputGroup,{children:[e.jsx(a.InputGroup.Text,{title:"Max size of the detector",children:"Max size"}),e.jsx(a.Form.Control,{value:`${r} × ${i}`,readOnly:!0}),e.jsx(a.InputGroup.Text,{children:"px"})]})}function us(n){const{hardware:t}=n,{properties:o}=t,s=o.static;return e.jsxs(a.InputGroup,{children:[e.jsx(a.InputGroup.Text,{title:"Version of the Lima server",children:"Lima version"}),e.jsx(a.Form.Control,{value:`${s==null?void 0:s.lima_version}`,readOnly:!0})]})}function fs(n){const{hardware:t}=n,{properties:o}=t,s=o.static;return e.jsxs(a.InputGroup,{children:[e.jsx(a.InputGroup.Text,{title:"Model of the detector",children:"Type/model"}),e.jsx(a.Form.Control,{value:`${s==null?void 0:s.camera_type}`,readOnly:!0}),e.jsx(a.Form.Control,{value:`${s==null?void 0:s.camera_model}`,readOnly:!0})]})}function st(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(z,{hardware:t}),i=e.jsxs(e.Fragment,{children:[e.jsx(fs,{hardware:t}),e.jsx(ds,{hardware:t}),e.jsx(us,{hardware:t})]}),c=o.header??"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}const q={};function ps(n){n.useHardware&&(q.useHardware&&console.warn("useHardware hook was already registered"),q.useHardware=n.useHardware),n.useHardwareChangeActions&&(q.useHardwareChangeActions&&console.warn("useHardwareChangeActions hook was already registered"),q.useHardwareChangeActions=n.useHardwareChangeActions)}function P(n){if(!q.useHardware)throw new Error("No `useHardware` hook registered");return q.useHardware(n)}function J(n){if(!q.useHardwareChangeActions)throw new Error("No `useHardwareChangeActions` hook registered");return q.useHardwareChangeActions(n)}function he(n){return n.type==="lima"}function ms(n){const t=P(n);return t===null||!he(t)?null:t}function rt(n,t){const o=Math.ceil(n/t),s=n/o;return[o,s]}const hs={default:Ze,size:et,transformation:tt,binning:nt,imageroi:ot,description:st,state:as},xs=hs,gs="lima_cam",js="lima_cam",ws="bliss",vs="lima",ys=!0,Ns=!1,bs={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],max_size:[128,128],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:0,size:[128,128],state:"READY"},_s={id:gs,name:js,protocol:ws,type:vs,online:ys,require_staff:Ns,properties:bs},$s="lima_cam",Ss="lima_cam",Os="bliss",Cs="lima",Is=!0,Ms=!1,Ts={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!0,!1],max_size:[128,128],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:0,size:[128,128],state:"READY"},Fs={id:$s,name:Ss,protocol:Os,type:Cs,online:Is,require_staff:Ms,properties:Ts},Ds="lima_cam",Es="lima_cam",Rs="bliss",As="lima",ks=!0,Ps=!1,Gs={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],max_size:[128,128],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:180,size:[128,128],state:"READY"},Bs={id:Ds,name:Es,protocol:Rs,type:As,online:ks,require_staff:Ps,properties:Gs},Vs={default:_s,flip:Fs,rot:Bs};function Ls(n){const{name:t,alias:o,useHardwareContext:s}=n,r=[1920,1920],i=[16e-6,16e-6],[c,l]=h.useState({static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:i,image_max_dim:r},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],pixel_size:i,raw_roi:[0,0,...r],roi:[0,0,...r],rotation:0,size:r,state:"READY"});async function f(p,m){console.log("LimaSimulator: Unsupported call",p,m)}function u(p,m){const x=[Math.round(i[0]*m[0]),Math.round(i[1]*m[1])],j=[Math.round(r[0]/m[0]),Math.round(r[1]/m[1])];return{...p,binning:m,pixel_size:x,roi:[0,0,...j],size:j}}async function d(p,m){if(p==="binning"){l(x=>u(x,m));return}console.log("LimaSimulator: Unsupported setProperty",p,m)}return e.jsx(V,{name:t,alias:o,type:"lima",call:f,setProperty:d,properties:c,useHardwareContext:s})}function Us(n,t){const{inputRef:o,referenceElementRef:s,onAddSelection:r,onRemoveSelection:i,...c}=n,l=h.useRef(),f=()=>{setTimeout(()=>{const p=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;p&&p.call(l.current,""),l.current&&l.current.dispatchEvent(new Event("input",{bubbles:!0}))},500)},u=()=>{r&&r(t.results).then(()=>{f()})},d=()=>{const p=t.text?[...t.selected].filter(m=>m.toLowerCase().indexOf(t.text.toLowerCase())!==-1):[...t.selected];i&&i(p).then(()=>{f()})};return e.jsxs(a.InputGroup,{children:[e.jsx(B.Hint,{children:e.jsx(a.Form.Control,{style:{width:"100%"},...c,ref:p=>{l.current=p,o(p),s(p)},placeholder:`${t.selected.length} enabled`})}),e.jsx(a.Button,{disabled:n.disabled||t.results.length===0,onClick:u,children:e.jsx("i",{className:"fa fa-plus"})}),e.jsx(a.Button,{disabled:n.disabled,onClick:d,children:e.jsx("i",{className:"fa fa-minus"})})]})}function Hs(n){return function(t){function o(s,r,i){return t(s,r,i,n)}return o.displayName=`WithExtraProps(${t.displayName||t.name||"Component"})`,o}}function qs(n,t,o,s){const i=[...o.selected].filter(f=>f.toLowerCase().indexOf(o.text.toLowerCase())!==-1).sort().map(f=>e.jsx("a",{href:"#",className:"dropdown-item",onClick:()=>o.onRemove(f),children:e.jsx(B.Highlighter,{search:o.text,children:f})},f)),l=[...o.results].sort().map((f,u)=>e.jsx(B.MenuItem,{option:f,position:u,children:e.jsx(B.Highlighter,{search:o.text,children:f})},f));return e.jsxs(B.Menu,{...t,style:{...t.style,width:350},children:[s.pending&&e.jsx(B.Menu.Header,{children:"Loading..."}),!s.pending&&e.jsxs(e.Fragment,{children:[e.jsx(B.Menu.Header,{children:"Enabled"}),i,i.length===0&&e.jsx("span",{className:"dropdown-item disabled",children:"No items enabled"}),e.jsx(B.Menu.Header,{children:"Available"}),l,l.length===0&&e.jsx("span",{className:"dropdown-item disabled",children:"No items available"})]})]})}function at(n){const{hardware:t}=n,{disabled:o=!1}=n,s=t.properties.available.filter(f=>!t.properties.disabled.includes(f));function r(f){const u=f.filter(p=>!s.includes(p)),d=s.filter(p=>!f.includes(p));u.length>0&&u.forEach(p=>{t.actions.call("enable",p)}),d.length>0&&d.forEach(p=>{t.actions.call("disable",p)})}function i(f){const u=[];return f.forEach(d=>{const p=t.actions.call("enable",d);u.push(p)}),Promise.all(u)}function c(f){const u=[];return f.forEach(d=>{const p=t.actions.call("disable",d);u.push(p)}),Promise.all(u)}function l(){return t.actions.call("set_active")}return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(w,{name:"Measurement Group",icon:"fa-list-ol",online:!0}),e.jsx("div",{className:"name",children:t.name}),e.jsx(a.OverlayTrigger,{placement:"top",overlay:e.jsx(a.Tooltip,{id:"active",children:"Activate this measurement group"}),children:e.jsx(a.Button,{size:"sm",disabled:o,onClick:()=>void l(),className:"float-right ml-1",children:e.jsx("i",{className:"fa fa-power-off"})})})]}),e.jsx("div",{className:"hw-content",children:e.jsx(B.Typeahead,{disabled:o,id:`typeahead_mg_${t.name}`,multiple:!0,flip:!0,positionFixed:!0,renderInput:Us,renderMenu:Hs({name:t.id})(qs),onChange:r,inputProps:{onAddSelection:i,onRemoveSelection:c},selected:s,options:t.properties.available,selectHint:(f,u)=>u.key==="Enter"||f})})]})}const zs={default:at},Ws=zs,Ys=[],Ks="mg",Qs="mg",Xs=!0,Js={available:["lima:image","diode1","diode2","machinfo:current","machinfo:srcurrent"],disabled:["machinfo:current"]},Zs="bliss",er=!1,tr="measurementgroup",nr={callables:Ys,id:Ks,name:Qs,online:Xs,properties:Js,protocol:Zs,require_staff:er,type:tr},or={default:nr};function sr(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,i]=h.useState({available:["lima:image","diode1","diode2","machinfo:current","machinfo:srcurrent"],disabled:["machinfo:current"]});async function c(d){i(p=>{const{disabled:m}=p;return{...p,disabled:m.filter(x=>x!==d)}})}async function l(d){i(p=>{const{disabled:m}=p;return{...p,disabled:m.includes(d)?m:[...m,d]}})}async function f(d,p){if(d==="enable"){await c(p);return}if(d==="disable"){await l(p);return}d!=="set_active"&&console.log("MeasurementGroupSimulator: Unsupported call",d,p)}async function u(d,p){console.log("MeasurementGroupSimulator: Unsupported setProperty",d,p)}return e.jsx(V,{name:t,alias:o,type:"measurementgroup",call:f,setProperty:u,properties:r,useHardwareContext:s})}const Ne={description:"Unknown state is exposed",variant:"fatal",priority:100},ie={OFFLINE:{description:"Axis is offline",variant:"secondary",priority:0},MOVING:{description:"Axis is moving",variant:"warning",priority:10},FAULT:{description:"Axis is in fault",variant:"danger",priority:20},LOCKED:{description:"Axis is locked",variant:"warning",priority:25},OFF:{description:"Power is off",variant:"secondary",priority:30},DISABLED:{description:"Axis is disabled",variant:"warning",priority:40},LOWLIMIT:{description:"Low limit is reached",variant:"warning",priority:50},HIGHLIMIT:{description:"High limit is reached",variant:"warning",priority:51},HOME:{description:"Home signal active",variant:"info",priority:52},READY:{description:"Ready to handle request",variant:"success",priority:60},NOT_READY:{description:"Not ready",variant:"warning",priority:100},UNKNOWN:Ne};function xe(n){const{hardware:t}=n,{locked:o=null}=t,{state:s=["UNKNOWN"]}=t.properties,[r,i]=h.useMemo(()=>{if(!t.online)return[["OFFLINE"],void 0];function c(p,m){const x=ie[p]??Ne,j=ie[m]??Ne;return x.priority-j.priority}const l=[...s,...o!==null?["LOCKED"]:[],...s.length===0?["NOT_READY"]:[]];l.sort(c);function f(p){const m=p.split(":",2);return m.length===1?[p,void 0]:m}const u={};return[l.map(p=>{if(p.startsWith("_")){const m=f(p);return m[1]!==void 0&&(u[m[0]]=m[1]),m[0]}return p==="LOCKED"?u[p]=`Locked by ${o}`:u[p]=ie[p].description??"",p}),u]},[s,t.online,o]);return e.jsx(Ue,{states:r,descriptions:i,minWidth:6,variants:Object.fromEntries(Object.entries(ie).map(([c,l])=>[c,l.variant]))})}function rr(n){const{hardware:t}=n;return e.jsx(xe,{hardware:t})}function ee(n){const t=h.useRef(null),[o,s]=h.useState(!1),[r,i]=h.useState(!1);function c(d){return n.precision!==void 0?Number.parseFloat(d).toFixed(n.precision):d}h.useEffect(()=>{var d;t.current&&(t.current.value=c((d=n.hardwareValue)==null?void 0:d.toString()),s(!1))},[n.hardwareValue,n.precision]);function l(d){const p=c(d);t!=null&&t.current&&(t.current.value=p)}function f(d){switch(d.key){case"Enter":{s(!1);const p=Number.parseFloat(d.target.value),m=n.onMoveRequested(p);m&&m.catch(()=>{i(!0),setTimeout(()=>{l(n.hardwareValue),i(!1)},2e3)}),d.preventDefault(),d.stopPropagation();break}case"Esc":case"Escape":o&&(i(!1),s(!1),l(n.hardwareValue)),d.target.blur(),d.preventDefault(),d.stopPropagation();break}}function u(d){s(d.target.value!==n.hardwareValue.toString())}return e.jsx(a.Form.Control,{className:A.default({"form-control-edited":o,"form-control-error":r,"hw-moving":n.hardwareIsMoving}),type:"number",ref:t,onChange:u,onKeyDown:f,disabled:n.readOnly||n.hardwareIsMoving||n.hardwareIsDisabled,step:n.step,onClick:d=>{d.stopPropagation()}})}function ar(n){var r,i;const{states:t}=n;function o(c){return n.hardware.actions.setProperty("velocity",c)}function s(c){return n.hardware.actions.setProperty("acceleration",c)}return e.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(a.Popover,{id:"popid",children:[e.jsxs(a.Popover.Header,{children:[n.hardware.name," details"]}),e.jsxs(a.Popover.Body,{children:[e.jsxs(a.Form.Group,{children:[e.jsx(a.Form.Label,{children:"Velocity"}),e.jsx(ee,{hardwareValue:((r=n.hardware.properties)==null?void 0:r.velocity)??0,onMoveRequested:o,hardwareIsDisabled:n.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:n.readOnly})]}),e.jsxs(a.Form.Group,{children:[e.jsx(a.Form.Label,{children:"Acceleration"}),e.jsx(ee,{hardwareValue:((i=n.hardware.properties)==null?void 0:i.acceleration)??0,onMoveRequested:s,hardwareIsDisabled:n.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:n.readOnly})]})]})]}),children:e.jsx(a.Button,{children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function K(n){const{hardware:t,options:o={}}=n,{properties:s,user_tags:r}=t;function i(){t.actions.call("stop")}function c(p){return t.actions.call("move",p)}const l=Se(s.state,r),f=e.jsx(w,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),u=e.jsx(xe,{hardware:t}),d=n.options?n.options.header:"top";return e.jsx(v,{hardware:t,widgetIcon:f,widgetState:u,widgetContent:e.jsxs(a.InputGroup,{className:"flex-nowrap",children:[e.jsx(me,{id:t.id,hardwareValue:(s==null?void 0:s.position)??null,hardwareIsDisabled:n.disabled,hardwareIsReady:l.READY??!1,hardwareIsMoving:l.MOVING??!1,onMoveRequested:c,onAbortRequested:i,precision:o.precision??s.display_digits??void 0,readOnly:o.readOnly,stepOnly:o.stepOnly,step:o.step,steps:o.steps,incIcon:o.incicon,decIcon:o.decicon,swapIncDec:o.swapincdec,horizontalArrows:o.horizontalarrows,largeArrows:o.largearrows}),s.unit&&e.jsx(a.InputGroup.Text,{children:s.unit}),!l.MOVING&&o.extended&&e.jsx(ar,{hardware:t,disabled:n.disabled,readOnly:o.readOnly,states:l}),l.MOVING&&!n.disabled&&!o.step&&e.jsx(a.Button,{variant:"danger",onClick:i,children:e.jsx("i",{className:"fa fa-times"})})]}),headerMode:d})}function Re(n){const{hardware:t,options:o={}}=n,s=Se(t.properties.state,t.user_tags);function r(i){if(i===null)return"∅";const c=o.precision??t.properties.display_digits??void 0;return c!==void 0?i.toFixed(c):`${i}`}return e.jsxs(a.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:[e.jsx("div",{className:A.default({"hw-moving":s.MOVING}),children:r(t.properties.position)}),t.properties.unit&&e.jsx("div",{className:"ms-auto",children:e.jsx("small",{children:e.jsx("small",{children:t.properties.unit})})})]})}function it(n){const{hardware:t}=n,o=e.jsx(w,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),s=e.jsx(xe,{hardware:t}),r=n.options?n.options.header:"top";return r==="none"?e.jsx(Re,{...n}):e.jsx(v,{hardware:t,widgetIcon:o,widgetState:s,widgetContent:e.jsx(Re,{...n}),headerMode:r})}function Se(n,t=[]){return h.useMemo(()=>{const o=t.includes("auto_ready"),s=t.includes("auto_on");if(n===void 0)return{UNKNOWN:!0};if((n==null?void 0:n.length)===0)return o?{READY:!0}:{NOT_READY:!0};const r=n.reduce((i,c)=>(i[c]=!0,i),{});return r.READY===void 0&&s&&r.OFF&&(r.READY=!0),r},[n,t])}function ct(n){return n.type==="motor"}function R(n){const t=P(n);return t===null||!ct(t)?null:t}const ir={default:K,text:it,state:rr},cr=ir,lr=["move","stop","wait","rmove"],dr="omega",ur="omega 123",fr=!0,pr={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},mr="bliss",hr=!1,xr="motor",gr=[],jr={callables:lr,id:dr,name:ur,online:fr,properties:pr,protocol:mr,require_staff:hr,type:xr,user_tags:gr},wr=["move","stop","wait","rmove"],vr="omega",yr="omega 123",Nr=!0,br={offset:0,sign:1,acceleration:300,limits:[-10,190],position:100,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3},_r="bliss",$r=!1,Sr="motor",Or=[],Cr={callables:wr,id:vr,name:yr,online:Nr,properties:br,protocol:_r,require_staff:$r,type:Sr,user_tags:Or},Ir=["move","wait","stop","rmove"],Mr="omega",Tr="omega 123",Fr=!0,Dr={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:["UNKNOWN"],target:null,tolerance:1e-4,unit:"deg",velocity:null},Er="bliss",Rr=!1,Ar="motor",kr=[],Pr={callables:Ir,id:Mr,name:Tr,online:Fr,properties:Dr,protocol:Er,require_staff:Rr,type:Ar,user_tags:kr},Gr=["move","wait","stop","rmove"],Br="omega",Vr="omega 123",Lr=!0,Ur={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:[],target:null,tolerance:1e-4,unit:"deg",velocity:null},Hr="bliss",qr=!1,zr="motor",Wr=[],Yr={callables:Gr,id:Br,name:Vr,online:Lr,properties:Ur,protocol:Hr,require_staff:qr,type:zr,user_tags:Wr},Kr=["move","wait","stop","rmove"],Qr="omega",Xr="omega 123",Jr=!1,Zr={},ea="bliss",ta=!1,na="motor",oa=[],sa={callables:Kr,id:Qr,name:Xr,online:Jr,properties:Zr,protocol:ea,require_staff:ta,type:na,user_tags:oa},ra=["move","wait","stop","rmove"],aa="omega",ia="omega 123",ca=!0,la={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:["OFF"],target:null,tolerance:1e-4,unit:"deg",velocity:null},da="bliss",ua=!1,fa="motor",pa=[],ma={callables:ra,id:aa,name:ia,online:ca,properties:la,protocol:da,require_staff:ua,type:fa,user_tags:pa},ha={default:jr,halfMotor:Cr,unknownMotor:Pr,notReadyMotor:Yr,disconnectedMotor:sa,powerOffMotor:ma};function xa(n,t){return{id:n,name:n,type:"motor",properties:{position:t,unit:"mm",limits:[-100,100]},online:!0}}function ga(n){const{name:t="omega",minLimit:o=-999999999,maxLimit:s=999999999,initialPosition:r=0,initialVelocity:i=1e3,useHardwareContext:c=()=>null}=n,[l,f]=h.useState(r),[u,d]=h.useState(["READY"]),[p,m]=h.useState(null),x=h.useRef(Date.now()),j=c(),g=()=>{const N=Date.now(),$=(N-x.current)/1e3;let I;if(x.current=N,p!==null&&p!==l){let L,U;const _=$*i;if(_>Math.abs(l-p))I=p,L=["READY"],U=null;else{const H=p>l?1:-1;I=l+H*_,L=["MOVING"],U=p}f(I),d(L),m(U)}},b=h.useCallback((N,$)=>{if(N==="stop")return m(null),d(["READY"]),Promise.resolve();if(N==="move"){const I=Number.parseFloat($);return m(Number.isNaN(I)?null:I),Promise.resolve()}return console.log("MotorSimulator: Unsupported call",N,$),Promise.resolve()},[]),S=h.useCallback((N,$)=>(console.log("MotorSimulator: Unsupported setProperty",N,$),Promise.resolve()),[]);h.useEffect(()=>{const N=setInterval(()=>{g()},500);return()=>clearInterval(N)});const E=h.useMemo(()=>{var $,I;const N={setProperty:S,call:b};return(I=j==null?void 0:($=j.actions).updateHardwareChangeActions)==null||I.call($,t,N),N},[]),T={id:t,name:t,alias:null,online:!0,properties:{acceleration:300,limits:[o,s],position:l,offset:0,sign:1,state:u,tolerance:1e-4,unit:"mm",velocity:i,target:p,display_digits:3},type:"motor",actions:E,user_tags:[],locked:null},y=h.useRef(null);return h.useEffect(()=>{y.current!==null&&F.isEqual(y.current,T)||(y.current=T,j==null||j.actions.updateHardware(t,T))},[t,T]),e.jsx(e.Fragment,{})}function lt(n){const{hardware:t,options:o={}}=n,s=h.useRef(null);h.useEffect(()=>{if(!s.current){console.error("selectionRef ref is unset");return}s.current.value=t.properties.position},[t.properties.position]);function r(l){if(console.debug("change",l),!s||!s.current){console.error("selection ref is unset");return}t.actions.call("move",s.current.value)}function i(l){t.actions.call("stop")}const c=F.map(t.properties.positions,l=>e.jsx("option",{title:l.description,children:l.position},l.position));return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(w,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(a.Badge,{bg:t.properties.state==="READY"?"success":"warning",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(a.InputGroup,{children:[e.jsxs(a.Form.Control,{className:"custom-select",as:"select",ref:s,disabled:n.disabled,defaultValue:t.properties.position,children:[e.jsx("option",{disabled:!0,children:"unknown"}),c]}),t.properties.state!=="MOVING"&&e.jsx(a.Button,{onClick:r,disabled:n.disabled,children:"Move"}),t.properties.state==="MOVING"&&!n.disabled&&e.jsx(a.Button,{variant:"danger",onClick:i,children:e.jsx("i",{className:"fa fa-times"})})]})})]})}function ja(n){const{hardware:t}=n,{properties:o}=t,s=o.state==="READY",r=n.disabled||!t.online||!s,i=o.position;function c(f){t.actions.call("move",f)}function l(f){const u=f.position,p=u===i?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(a.Dropdown.Item,{disabled:r,onClick:()=>{c(u)},title:f.description,children:[e.jsx("i",{className:p}),"  ",u]},u)}return e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{disabled:r,variant:"secondary"}),e.jsx(a.Dropdown.Menu,{align:"end",children:o.positions.map(f=>l(f))})]})}function wa(n){var p,m;const{hardware:t,options:o={}}=n,s=((p=t.properties)==null?void 0:p.state)==="MOVING";function r(x){t.actions.call("stop")}const i=e.jsx(w,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),c=e.jsx(Pe,{hardware:t}),l=s?"Moving":null,f=(m=t.properties)==null?void 0:m.position;function u(){return e.jsxs(a.InputGroup,{children:[e.jsx(k,{className:A.default({"hw-moving":s}),value:l??f??"Unknown"}),!s&&!n.disabled&&e.jsx(ja,{...n}),s&&!n.disabled&&e.jsx(a.Button,{variant:"danger",onClick:r,children:e.jsx("i",{className:"fa fa-fw fa-times"})})]})}const d=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:i,widgetState:c,widgetContent:u(),headerMode:d})}const va={default:lt,default2:wa},ya=va,Na=["move","stop"],ba="beamstop",_a="beamstop",$a=!0,Sa={position:"OUT",positions:[{description:"Beamstop position IN the beam",position:"IN",target:[{destination:2.5,tolerance:.01},{destination:1,tolerance:.2}]},{description:"Beamstop position OUT of the beam",position:"OUT",target:[{destination:3.5,tolerance:.01},{destination:2,tolerance:.2}]}],state:"READY"},Oa="bliss",Ca=!1,Ia="multiposition",Ma={callables:Na,id:ba,name:_a,online:$a,properties:Sa,protocol:Oa,require_staff:Ca,type:Ia},Ta={default:Ma};function Fa(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,i]=h.useState("empty"),[c,l]=h.useState("READY");async function f(p,m){if(p==="move"){l("MOVING"),i("unknown"),await D(2e3),l("READY"),i(m);return}if(p==="stop"){i("unknown"),await D(2e3);return}console.log("MultipositionSimulator: Unsupported call",p,m)}async function u(p,m){console.log("MultipositionSimulator: Unsupported setProperty",p,m)}const d={position:r,state:c,positions:[{position:"empty",description:"No filter",target:[]},{position:"gold2",description:"Gold filter 2mm",target:[]},{position:"silver3",description:"Silver filter 3mm",target:[]}]};return e.jsx(V,{name:t,alias:o,type:"multiposition",call:f,setProperty:u,properties:d,useHardwareContext:s})}function Oe(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOVING:"warning",INVALID:"danger",UNKNOWN:"danger",DISABLED:"secondary",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(M,{state:o,minWidth:6,variant:r})}function Da(n){const{hardware:t}=n;return e.jsx(Oe,{hardware:t})}function Ea(n){const{hardware:t,options:o={}}=n,{properties:s}=t,{state:r}=s,i=r==="MOVING",c=r==="READY",l=i?s.target_magnification||0:s.magnification||0,u=[...s.available_magnifications??[]];u.sort((j,g)=>j>g?1:g>j?-1:0);const d=n.disabled||!t.online||!c,p=o.digits||2;function m(j){t.actions?t.actions.call("move",j):console.error("Change request was triggered with:",j)}function x(j,g){const S=l===g?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(a.Dropdown.Item,{disabled:d,onClick:()=>{m(g)},children:[e.jsx("i",{className:S}),"  × ",g]},`id${j}`)}return e.jsxs(e.Fragment,{children:[e.jsx(k,{value:l.toFixed(p),className:A.default({"hw-moving":i})}),e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{disabled:!c,variant:"secondary"}),e.jsx(a.Dropdown.Menu,{children:u.map((j,g)=>x(g,j))})]})]})}function Ra(n){const{hardware:t,options:o={}}=n,s=t.properties.magnification||0,r=o.digits||2,i=!!o.allowtuning;return e.jsxs(e.Fragment,{children:[e.jsx(k,{value:s.toFixed(r)}),i&&e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{variant:"secondary"}),e.jsx(a.Dropdown.Menu,{children:e.jsxs(a.InputGroup,{children:[e.jsx(a.InputGroup.Text,{children:"×"}),e.jsx(dt,{...n})]})})]})]})}function dt(n){const{hardware:t,options:o={}}=n,s=t.properties.magnification||0,{state:r}=t.properties,i=r==="READY",c=n.disabled||!t.online||!i,[l,f]=t.properties.magnification_range||[null,null],u=h.useRef(null),d=h.useRef(null),[p,m]=h.useState(!1),x=o.digits||2;function j(y){t.actions?n.mode==="move"?t.actions.call("move",y):t.actions.setProperty("magnification",y):console.error("Change request was triggered with:",y)}function g(y){if(!u||!u.current){console.log("formRef not yet defined");return}if(y.key==="Enter"){m(!1);const{value:N}=u.current,$=Number.parseFloat(N);if(l!==null&&$<l||f!==null&&$>f)return;j($)}else y.key==="Escape"?(u.current.value=s.toFixed(x),d.current&&(d.current.value=s.toString()),m(!1)):console.log(y.key)}function b(y){y!==s&&!p&&m(!0),y===s&&p&&m(!1)}function S(y){if(!u||!u.current){console.error("formRef is not set");return}const N=Number.parseFloat(u.current.value);b(N),d.current&&(d.current.value=N.toString())}function E(y){if(!u||!u.current){console.error("formRef is not set");return}if(!d||!d.current){console.error("rangeRef is not set");return}const N=Number.parseFloat(d.current.value);b(N),u.current.value=N.toFixed(x)}function T(){if(!d||!d.current){console.error("rangeRef is not set");return}const y=Number.parseFloat(d.current.value);j(y)}return h.useEffect(()=>{if(!u||!u.current){console.error("formRef is not set");return}p||(u.current.value=s.toFixed(x)),d.current&&(d.current.value=s.toString())},[x,p,s]),e.jsxs(e.Fragment,{children:[e.jsx(a.Form.Control,{className:p?"form-control-edited":"",type:"number",ref:u,defaultValue:s.toFixed(x),onChange:S,disabled:c,step:10**-x,onKeyDown:g}),l!==null&&f!==null&&e.jsx(a.Form.Control,{ref:d,disabled:c,type:"range",min:l,max:f,step:10**-x,onChange:E,onMouseUp:T,defaultValue:s})]})}function Aa(n){const{hardware:t,options:o={}}=n,{properties:s}=t,r=s.state==="MOVING",i=s.state==="READY",c=r?s.target_magnification||0:s.magnification||0,l=n.options.digits||2;return e.jsxs(e.Fragment,{children:[e.jsx(k,{value:c.toFixed(l),className:A.default({"hw-moving":r})}),e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{disabled:!i,variant:"secondary"}),e.jsx(a.Dropdown.Menu,{children:e.jsxs(a.InputGroup,{children:[e.jsx(a.InputGroup.Text,{children:"×"}),e.jsx(dt,{...n,mode:"move"})]})})]})]})}function ka(n){return e.jsx(a.Form.Control,{className:"border-light",type:"text",disabled:!0,defaultValue:"Missing"})}function ut(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Optic",icon:"fam-hardware-optic",online:t.online}),r=e.jsx(Oe,{hardware:t});function i(){function l(){return t.online?t.properties.available_magnifications?Ea:t.properties.magnification_range?Aa:Ra:ka}const f=l();return e.jsxs(a.InputGroup,{children:[e.jsx(a.InputGroup.Text,{className:"border-light",children:"×"}),e.jsx(f,{...n})]})}const c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i(),headerMode:c})}function Pa(n){return n.type==="optic"}const Ga={default:ut,state:Da},Ba=Ga,Va=["magnification","reset","open"],La="optic",Ua="optic",Ha=!0,qa={state:"READY",magnification:10,target_magnification:null,available_magnifications:[5,7.5,10],magnification_range:null},za="bliss",Wa=!1,Ya="optic",ce={callables:Va,id:La,name:Ua,online:Ha,properties:qa,protocol:za,require_staff:Wa,type:Ya},Ka={default:ce,fixed:ce,off:ce,range:ce};function Qa(n){const{name:t,alias:o,kind:s,useHardwareContext:r}=n;function i(){return s==="fixed"?{available_magnifications:null,magnification_range:null}:s==="range"?{available_magnifications:null,magnification_range:[5,10]}:s==="multi"?{available_magnifications:[5,7.5,10],magnification_range:null}:{available_magnifications:null,magnification_range:null}}const[c,l]=h.useState({state:"READY",magnification:10,target_magnification:null,...i()});async function f(p){let m=c.magnification;l(g=>({...g,state:"MOVING",target_magnification:p})),await D(100);const x=.2*(m<p?1:-1);function j(g){l(b=>({...b,magnification:g}))}for(;Math.abs(p-m)>=Math.abs(x)*1.01;)m+=x,j(m),await D(100);l(g=>({...g,state:"READY",magnification:p,target_magnification:null}))}async function u(p,m){if(p==="move"){await f(m);return}console.log("OpticSimulator: Unsupported call",p,m)}async function d(p,m){if(p==="magnification"){l(x=>({...x,magnifications:m}));return}console.log("OpticSimulator: Unsupported setProperty",p,m)}return e.jsx(V,{name:t,alias:o,type:"optic",call:u,setProperty:d,properties:c,useHardwareContext:r})}function re(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={STANDBY:"success",DISABLED:"secondary",OFFLINE:"secondary",RUNNING:"warning",ABORTING:"warning",AWAITING_USER_INPUT:"warning",UNKNOWN:"fatal"},r=s[o]||s.UNKNOWN;return e.jsx(M,{state:o,minWidth:6,variant:r})}function Xa(n){const{hardware:t}=n;return e.jsx(re,{hardware:t})}function Ja(n){const{hardware:t}=n,o=n.disabled||!t.online,s=t.properties.state==="AWAITING_USER_INPUT",r=t.properties.state==="ABORTING",i=t.properties.state==="RUNNING"||s||r;function c(f){t.actions.call("start")}function l(f){t.actions.call("abort")}return e.jsxs(a.ButtonGroup,{size:"lg",className:"w-100",children:[e.jsx(a.Button,{onClick:c,disabled:o||i,variant:"primary",children:"Start"}),e.jsx(a.Button,{onClick:l,disabled:o||!i,variant:"primary",children:"Abort"})]})}function be(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Procedure",icon:"fa-cog",online:t.online}),r=e.jsx(re,{hardware:t}),i=e.jsx(a.Container,{children:e.jsx(Ja,{hardware:t,disabled:!n.operator})}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function Za(n){const{hardware:t}=n,o=t.properties.state==="AWAITING_USER_INPUT",s=t.properties.state==="ABORTING",r=t.properties.state==="RUNNING";return s?e.jsxs(a.Badge,{bg:"warning",children:[e.jsx("i",{className:"fa-solid fa-heart-crack fa-beat"})," ABORTING"]}):r?e.jsxs(a.Badge,{bg:"info",children:[e.jsx("i",{className:"fa-solid fa-heart fa-beat"})," RUNNING"]}):o?e.jsxs(a.Badge,{bg:"warning",title:"A user input is expected",children:[e.jsx("i",{className:"fa-solid fa-user fa-beat"})," AWAITING INPUT"]}):e.jsx(ei,{hardware:t})}function ei(n){const{hardware:t}=n,{previous_run_state:o,previous_run_exception:s}=t.properties,r={NONE:["secondary",null],ABORTED:["warning","fa-heart-crack"],FAILED:["danger",null],SUCCESSED:["success",null],UNKNOWN:["danger",null]},i=r[o]||r.UNKNOWN,[c,l]=i;return e.jsxs(a.Badge,{bg:c,title:s??void 0,children:[l&&e.jsxs(e.Fragment,{children:[e.jsx("i",{className:`fa-solid ${l}`})," "]}),o]})}function ft(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Procedure",icon:"fa-cog",online:t.online}),r=e.jsx(re,{hardware:t}),i=e.jsx(a.Container,{children:e.jsx("div",{children:e.jsx("h3",{children:e.jsx(Za,{hardware:t})})})}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function ti(n){const{hardware:t}=n,o=n.disabled||!t.online,s=t.properties.state==="AWAITING_USER_INPUT";function r(i){t.actions.call("validate")}return e.jsx(a.ButtonGroup,{size:"lg",className:"w-100",children:e.jsx(a.Button,{onClick:r,disabled:o||!s,variant:"primary",children:"Validate"})})}function pt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Procedure",icon:"fa-cog",online:t.online}),r=e.jsx(re,{hardware:t}),i=e.jsx(a.Container,{children:e.jsx(ti,{hardware:t,disabled:!n.operator})}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}const ni={default:be,manage:be,execution:ft,validate:pt,state:Xa},oi=ni,si=["start","abort","clear","validate"],ri="procedure",ai="procedure",ii="procedure",ci="bliss",li=!1,di=!0,ui={state:"STANDBY",previous_run_state:"NONE",previous_run_exception:null,parameters:{my_number:10,my_string:"foo",my_null:null,my_boolean:!0,my_dict:{a:10,b:"10",c:!0},my_list:[10,"10",!0],"my_scan_1.11":{__type__:"scan",node:"demo_session:tmp:scans:inhouse:id002405:sample:sample_0002:_1_flat images 1",mmh3:3852826388},"my_scan_2.0":{__type__:"scan",key:"esrf:scan:01J1QDB370S2V8WF7FX2Y9H29V",mmh3:3852826389},my_quantity:{__type__:"quantity",scalar:20,unit:"mm"},my_nan:{__type__:"nan"},my_posinf:{__type__:"posinf"},my_neginf:{__type__:"neginf"},my_obj:{__type__:"hardware",name:"roby"}}},fi={callables:si,type:ri,id:ai,name:ii,protocol:ci,require_staff:li,online:di,properties:ui},pi={standby:fi};function ge(n){const{hardware:t}=n;function o(){if(!t.online)return"OFFLINE";const i=t.properties.state;return n.useReadyState&&(i==="OPEN"||i==="CLOSED")?"READY":i}const s=o();function r(){switch(s){case"READY":return"success";case"OPEN":return"success";case"CLOSED":return"danger";case"DISABLED":return"secondary";case"MOVING":case"STANDBY":case"OFFLINE":return"warning";case"FAULT":return"fatal";default:return"fatal"}}return e.jsx(M,{state:s,minWidth:6,variant:r()})}function mi(n){const{hardware:t}=n;return e.jsx(ge,{hardware:t,useReadyState:!0})}function hi(n){const{hardware:t}=n;function o(){t.actions.call("reset")}return e.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(a.Popover,{id:"popid",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,{onClick:o,disabled:n.disabled,children:"Reset"})})]})]}),children:e.jsx(a.Button,{className:"flex-grow-0",title:"Shutter Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function mt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),r=e.jsx(ge,{hardware:t});function i(){return t.properties?t.properties.state:"UNKNOWN"}function c(g){return g==="OPEN"?["Close","close"]:g==="CLOSED"?["Open","open"]:g==="DISABLED"||g==="STANDBY"||g==="FAULT"?["Closed",""]:g==="MOVING"?["...",""]:["Unknown",""]}const l=i(),[f,u]=c(l),p={OPEN:"danger",CLOSED:"success",MOVING:"warning",DISABLED:"secondary",STANDBY:"danger",FAULT:"fatal",UNKNOWN:"warning"}[l]||"danger";function m(){t.actions.call(u)}const x=e.jsxs(a.ButtonGroup,{className:"d-flex flex-nowrap",children:[e.jsx(a.Button,{variant:p,onClick:m,disabled:n.disabled||u==="",children:f}),o.extended&&e.jsx(hi,{...n})]}),j=n.options.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:x,headerMode:j})}function xi(n){var f;const{hardware:t,options:o={}}=n;function s(){t.actions.call("open")}function r(){t.actions.call("close")}const i=((f=t.properties)==null?void 0:f.state)??"UNKNOWN",c=i==="MOVING",l=i==="DISABLED"||c;return e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{variant:"secondary",disabled:n.disabled||l}),e.jsx(a.Dropdown.Menu,{children:e.jsxs(a.Container,{children:[e.jsx(a.Row,{children:e.jsx(a.Col,{className:"text-center",children:"Actions"})}),e.jsx(a.Row,{children:e.jsx(a.Col,{children:e.jsxs(a.ButtonGroup,{children:[e.jsx(a.Button,{variant:c?"warning":"secondary",onClick:()=>{s()},disabled:n.disabled||l,title:"Open the shutter",children:"Open"}),e.jsx(a.Button,{variant:c?"warning":"secondary",onClick:()=>{r()},disabled:n.disabled||l,title:"Close the shutter",children:"Close"})]})})})]})})]})}function ht(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),r=e.jsx(ge,{hardware:t,useReadyState:!0});function i(){return t.properties?t.properties.state:"UNKNOWN"}function c(g){return g==="OPEN"||g==="CLOSED"?g:g==="DISABLED"||g==="STANDBY"||g==="FAULT"?"CLOSED":g==="MOVING"?"...":"UNKNOWN"}function l(g){return g.charAt(0).toUpperCase()+g.slice(1).toLowerCase()}const f=i(),u=c(f),p={OPEN:"success",CLOSED:"danger",MOVING:"warning",DISABLED:"secondary",STANDBY:"success",FAULT:"fatal",UNKNOWN:"fatal"}[f],m=l(u),x=e.jsxs(a.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(k,{variant:p,className:"text-center",style:{minWidth:"10em"},value:m}),e.jsx(xi,{...n})]}),j=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:x,headerMode:j})}const gi={default:mt,protected:ht,state:mi},ji=gi,wi=["reset","open","close","toggle"],vi="abs1",yi="abs1",Ni=!0,bi={closed_text:"",open_text:"",state:"OPEN",status:`Pneumatic Beam Shutter is open
29
- `,valid:!0},_i="tango",$i=!0,Si="shutter",Oi={callables:wi,id:vi,name:yi,online:Ni,properties:bi,protocol:_i,require_staff:$i,type:Si},Ci={default:Oi};function Ii(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,i]=h.useState("OPEN");async function c(u,d){if(u==="open"){i("MOVING"),await D(2e3),i("OPEN");return}if(u==="close"){i("MOVING"),await D(2e3),i("CLOSED");return}console.log("ShutterSimulator: Unsupported call",u,d)}async function l(u,d){console.log("ShutterSimulator: Unsupported setProperty",u,d)}const f={state:r,closed_text:"",open_text:"",status:`Shutter is ${r}`,valid:!0};return e.jsx(V,{name:t,alias:o,type:"shutter",call:c,setProperty:l,properties:f,useHardwareContext:s})}function Mi(n){const{properties:t}=n,o=t.vgap.slice(9),s=R(o),r=t.hgap.slice(9),i=R(r),c=t.voffset.slice(9),l=R(c),f=t.hoffset.slice(9),u=R(f);return h.useMemo(()=>{var d,p,m,x;return{vgap:((d=s==null?void 0:s.properties)==null?void 0:d.state)??null,hgap:((p=i==null?void 0:i.properties)==null?void 0:p.state)??null,voffset:((m=l==null?void 0:l.properties)==null?void 0:m.state)??null,hoffset:((x=u==null?void 0:u.properties)==null?void 0:x.state)??null}},[s,i,l,u])}function Ce(n){const{hardware:t}=n,o=Mi(t),[s,r,i]=h.useMemo(()=>{if(o.vgap===null&&o.hgap===null&&o.voffset===null&&o.hoffset===null)return["OFFLINE","secondary","No motor online"];const c=new Set([...o.vgap??[],...o.hgap??[],...o.voffset??[],...o.hoffset??[]]);return c.has("MOVING")?["MOVING","warning","A motor is moving"]:c.has("OFF")?["OFF","secondary","A motor is off"]:["READY","success","The slit is ready"]},[o]);return e.jsx(M,{state:s,description:i,variant:r,minWidth:6})}function Ti(n){const{hardware:t}=n;return e.jsx(Ce,{hardware:t})}function Fi(n){const{properties:t}=n,o=t.vgap.slice(9),s=R(o),r=J(o),i=t.hgap.slice(9),c=R(i),l=J(i),f=t.voffset.slice(9),u=R(f),d=J(f),p=t.hoffset.slice(9),m=R(p),x=J(p);function j(g,b){return g===null?null:{...g,actions:b}}return{vgap:j(s,r),hgap:j(c,l),voffset:j(u,d),hoffset:j(m,x)}}function Di(n){const{hardware:t,schema:o,operator:s,disabled:r,resolved:i}=n;return e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{variant:"secondary"}),e.jsx(a.Dropdown.Menu,{align:"end",children:e.jsxs(a.Container,{children:[e.jsxs(a.Row,{className:"flex-nowrap",children:[e.jsx(a.Col,{sm:1,className:"d-flex",children:e.jsx("i",{className:"fa fa-fw fa-square",title:"Gap",style:{alignSelf:"center"}})}),e.jsx(a.Col,{sm:5,children:i.hgap&&e.jsx(K,{hardware:i.hgap,options:{header:"none"},schema:o,disabled:r,operator:s})}),e.jsx(a.Col,{sm:1,className:"d-flex",children:e.jsx("span",{style:{alignSelf:"center"},children:"×"})}),e.jsx(a.Col,{sm:5,children:i.vgap&&e.jsx(K,{hardware:i.vgap,options:{header:"none"},schema:o,disabled:r,operator:s})})]}),e.jsxs(a.Row,{className:"flex-nowrap",children:[e.jsx(a.Col,{sm:1,className:"d-flex",children:e.jsx("i",{className:"fa fa-fw fa-arrows-up-down-left-right ",title:"Offset",style:{alignSelf:"center"}})}),e.jsx(a.Col,{sm:5,children:i.hoffset&&e.jsx(K,{hardware:i.hoffset,options:{header:"none"},schema:o,disabled:r,operator:s})}),e.jsx(a.Col,{sm:1,className:"d-flex",children:e.jsx("span",{style:{alignSelf:"center"},children:";"})}),e.jsx(a.Col,{sm:5,children:i.voffset&&e.jsx(K,{hardware:i.voffset,options:{header:"none"},schema:o,disabled:r,operator:s})})]})]})})]})}function Ei(n){const{hardware:t,options:o={}}=n,s=Fi(t),{readonly:r=!1}=o;function i(m){var g,b;const x=((g=m==null?void 0:m.properties)==null?void 0:g.position)??null;if(x===null)return"∅";const j=o.precision??((b=m==null?void 0:m.properties)==null?void 0:b.display_digits)??void 0;return j!==void 0?x.toFixed(j):`${x}`}const[c,l,f,u,d,p]=h.useMemo(()=>{var y,N,$,I,L,U,_,H;const m=`${i(s.hgap)} × ${i(s.vgap)}`,x=((y=s.hgap)==null?void 0:y.properties.unit)??((N=s.vgap)==null?void 0:N.properties.unit)??"?",g=new Set([...(($=s.hgap)==null?void 0:$.properties.state)??[],...((I=s.vgap)==null?void 0:I.properties.state)??[]]).has("MOVING"),b=`${i(s.hoffset)} ; ${i(s.voffset)}`,S=((L=s.hoffset)==null?void 0:L.properties.unit)??((U=s.voffset)==null?void 0:U.properties.unit)??"?",T=new Set([...((_=s.hoffset)==null?void 0:_.properties.state)??[],...((H=s.voffset)==null?void 0:H.properties.state)??[]]).has("MOVING");return[m,x,g,b,S,T]},[s.hgap,s.hoffset,s.vgap,s.voffset]);return e.jsxs(a.InputGroup,{className:"w-100 flex-nowrap",children:[e.jsx(a.InputGroup.Text,{title:"Gap (horizontal and vertical)",children:e.jsx("i",{className:"fa fa-fw fa-square fa-2x"})}),e.jsx(k,{value:c,title:"Gap",className:A.default({"hw-moving":f})}),e.jsx(a.InputGroup.Text,{children:l}),e.jsx(a.InputGroup.Text,{title:"Offset (horizontal and vertical)",children:e.jsx("i",{className:"fa fa-fw fa-arrows-up-down-left-right fa-2x"})}),e.jsx(k,{value:u,title:"Offset",className:A.default({"hw-moving":p})}),e.jsx(a.InputGroup.Text,{children:d}),!r&&e.jsx(Di,{...n,resolved:s})]})}function xt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Slit",icon:"fam-hardware-motor",online:t.online}),r=e.jsx(Ce,{hardware:t}),i=e.jsx(Ei,{...n}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}const Ri={default:xt,state:Ti},Ai=Ri,ki="s1",Pi="s1",Gi=!0,Bi={vgap:"hardware:s1vg",voffset:"hardware:s1vo",hgap:"hardware:s1hg",hoffset:"hardware:s1ho"},Vi="slit",Li={id:ki,name:Pi,online:Gi,properties:Bi,type:Vi},Ui="s1",Hi="s1",qi=!0,zi={vgap:"hardware:",voffset:"hardware:",hgap:"hardware:s1hg",hoffset:"hardware:s1ho"},Wi="slit",Yi={id:Ui,name:Hi,online:qi,properties:zi,type:Wi},Ki="s1",Qi="s1",Xi=!0,Ji={vgap:"hardware:s1vg",voffset:"hardware:s1vo",hgap:"hardware:",hoffset:"hardware:"},Zi="slit",ec={id:Ki,name:Qi,online:Xi,properties:Ji,type:Zi},tc={default:Li,horizontal:Yi,vertical:ec};function nc(n){const{hardware:t}=n,o=()=>{t.actions.call(t.properties.state==="ON"?"off":"on")},s={Voltage:`${t.properties.voltage.toFixed(0)} V`,Current:`${(t.properties.current*1e3).toFixed(2)} mA`};return e.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(a.Popover,{id:"popid",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("h6",{children:"Properties"}),e.jsx(a.Container,{children:F.map(s,(r,i)=>e.jsxs(a.Row,{children:[e.jsxs(a.Col,{children:[i,":"]}),e.jsx(a.Col,{children:r})]},i))}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(a.Button,{disabled:n.disabled,onClick:o,variant:t.properties.state==="ON"?"danger":"success",children:t.properties.state==="ON"?"Off":"On"})})]})]}),children:e.jsx(a.Button,{title:"Pump Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function gt(n){const{hardware:t,options:o={}}=n;return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(w,{name:"Pump",icon:"fam-hardware-pump",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(a.Badge,{bg:t.properties.state==="ON"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(a.InputGroup,{children:[e.jsx(a.Form.Control,{value:t.properties.pressure.toExponential(o.precision||3),disabled:!0}),(t.properties.unit||o.unit)&&e.jsx(a.InputGroup.Text,{children:t.properties.unit||o.unit}),e.jsx(nc,{...n})]})})]})}const oc={default:gt},sc=oc,rc=["off","on"],ac="ip121",ic="ip121",cc=!0,lc={current:.0003000000142492354,pressure:26000000730164174e-23,state:"ON",status:`Pump is ON
28
+ `},$o="tango",So=!0,Co="gauge",Oo={callables:yo,id:vo,name:No,online:bo,properties:_o,protocol:$o,require_staff:So,type:Co},Io={default:wo,default2:Oo},Mo=h.forwardRef((n,t)=>{const o=h.useRef(null),s=h.useRef(),[r,a]=h.useState(n.step),[c,l]=h.useState(!1),f=$=>{const q=t;if(o.current===null)return;let Z=Number.parseFloat(q.current.value);if(o.current.value.startsWith("*")){const ee=Number.parseFloat(o.current.value.replace("*",""));Z=$?Z*ee:Z/ee}else{const ee=Number.parseFloat(o.current.value);Z+=$?ee:-ee}q.current.value=`${Z}`,n.onStep&&n.onStep({target:q.current})},{onStep:u,step:d,overlay:p,incIcon:m,decIcon:g,swapIncDec:w,onKeyDown:x,onBlur:j,horizontalArrows:N,largeArrows:I,disabled:M,stepOnly:b,..._}=n,S=$=>{$.key==="ArrowUp"?($.preventDefault(),l(!0),f(!0)):$.key==="ArrowDown"?($.preventDefault(),l(!0),f(!1)):x&&x($)};c&&(s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{var $;($=t==null?void 0:t.current)==null||$.focus()},100)),h.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const C=()=>{s.current&&clearTimeout(s.current),l(!1),j&&j()};if(!n.step)return e.jsx(i.Form.Control,{ref:t,type:"number",step:"any",onKeyDown:S,onBlur:C,disabled:M,onClick:$=>{$.stopPropagation()},..._});const G=D.map(n.steps||[n.step],$=>e.jsx("option",{value:$,children:$},$)),B=m||g;return e.jsx("div",{className:P.default("numeric-step",{"numeric-step-large":I,"numeric-step-horizontal":N}),children:e.jsxs(i.InputGroup,{children:[e.jsx(i.Form.Control,{onKeyDown:S,onBlur:C,ref:t,type:"number",step:"any",disabled:M||b,..._}),e.jsxs(e.Fragment,{children:[p,!p&&e.jsxs(i.InputGroup.Text,{className:`d-flex flex-column ${B?"inc-dec":""}`,children:[e.jsx(i.Form.Control,{ref:o,as:"select",className:"step-size",defaultValue:r,disabled:M,onChange:$=>a(Number.parseFloat($.target.value)),children:G}),n.unit&&e.jsx("div",{children:n.unit}),!m&&!g&&e.jsxs(e.Fragment,{children:[e.jsx(i.Button,{className:"step step-up",disabled:n.disabled,onClick:$=>f(!0)}),e.jsx(i.Button,{className:"step step-down",disabled:n.disabled,onClick:$=>f(!1)})]})]}),g&&w&&e.jsx(i.Button,{disabled:n.disabled,onClick:$=>f(!1),children:e.jsx("i",{className:`fa fa-fw fa-${g}`})}),m&&e.jsx(i.Button,{disabled:n.disabled,onClick:$=>f(!0),children:e.jsx("i",{className:`fa fa-fw fa-${m}`})}),g&&!w&&e.jsx(i.Button,{disabled:n.disabled,onClick:$=>f(!1),children:e.jsx("i",{className:`fa fa-fw fa-${g}`})})]})]})})}),Xe=Mo;function xe(n){const t=h.useRef(null),[o,s]=h.useState(!1),[r,a]=h.useState(!1);h.useEffect(()=>{t.current&&(n.hardwareValue===null?t.current.value="":n.precision!==void 0?t.current.value=n.hardwareValue.toFixed(n.precision):t.current.value=n.hardwareValue.toString(),s(!1))},[n.hardwareValue]);function c(p){let m=p;n.precision!==void 0&&(m=Number.parseFloat(m).toFixed(n.precision)),t!=null&&t.current&&(t.current.value=m)}function l(){o&&setTimeout(()=>{c(n.hardwareValue),s(!1)},3e3)}function f(p){n.hardwareValue!==null&&s(p.target.value!==n.hardwareValue.toString())}function u(p){s(!1);const m=n.onMoveRequested(p.target.value);m&&m.catch(()=>{a(!0),setTimeout(()=>{c(n.hardwareValue),a(!1)},2e3)})}function d(p){switch(p.key){case"Enter":{s(!1);const m=Number.parseFloat(p.target.value),g=n.onMoveRequested(m);g&&g.catch(()=>{a(!0),setTimeout(()=>{c(n.hardwareValue),a(!1)},2e3)})}p.preventDefault(),p.stopPropagation();break;case"Esc":case"Escape":o&&(a(!1),s(!1),c(n.hardwareValue)),p.target.blur(),p.preventDefault(),p.stopPropagation();break}}return e.jsx(Xe,{id:n.id,className:P.default({"form-control-edited":o,"form-control-error":r,"hw-moving":n.hardwareIsMoving}),type:n.readOnly?"text":"number",ref:t,precision:n.precision,onChange:f,onBlur:l,onStep:u,onKeyDown:d,disabled:n.hardwareIsDisabled||n.readOnly||!n.hardwareIsReady,stepOnly:n.stepOnly,step:n.step,steps:n.steps,incIcon:n.incIcon,decIcon:n.decIcon,swapIncDec:n.swapIncDec,horizontalArrows:n.horizontalArrows,largeArrows:n.largeArrows,overlay:n.hardwareIsMoving&&!n.hardwareIsDisabled?e.jsx(i.Button,{variant:"danger",onClick:n.onAbortRequested,children:e.jsx("i",{className:"fa fa-times"})}):null})}function Je(n){const{hardware:t,options:o={},disabled:s}=n;function r(u){return t.actions.setProperty("power",u)}function a(u){return t.actions.call(u?"on":"off")}const c=t.properties.state,l=e.jsx(y,{name:"Laser",icon:"fam-hardware-laser",online:t.online}),f=e.jsx(F,{state:c,minWidth:6,variant:c==="ON"?"success":"warning"});return e.jsx(v,{hardware:t,widgetIcon:l,widgetState:f,widgetContent:e.jsxs(i.InputGroup,{children:[e.jsx(xe,{id:t.id,hardwareValue:t.properties.power,hardwareIsDisabled:!1,hardwareIsReady:!0,hardwareIsMoving:c==="MOVING",onMoveRequested:r,onAbortRequested:()=>null,precision:1,readOnly:!1,step:o.step,steps:o.steps,incIcon:void 0,decIcon:void 0,swapIncDec:void 0}),e.jsx(i.Button,{size:"sm",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>{a(t.properties.state!=="ON")},children:e.jsx("i",{className:t.properties.state==="ON"?"fa fa-toggle-on":"fa fa-toggle-off"})})]})})}const To={default:Je},Fo=To,Do=[],Ao="yag1",Ro="yag1",Eo=!0,ko={power:5,state:"ON"},Po="bliss",Go=!1,Bo="laser",Vo={callables:Do,id:Ao,name:Ro,online:Eo,properties:ko,protocol:Po,require_staff:Go,type:Bo},Lo={default:Vo};function Uo(n){var o;const{hardware:t}=n;return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"laserheating_overlay",children:[e.jsxs(i.Popover.Header,{children:[t.name," details"]}),e.jsx(i.Popover.Body,{children:e.jsxs(i.Container,{children:[e.jsxs(i.Row,{children:[e.jsx(i.Col,{children:"Background Mode"}),e.jsx(i.Col,{children:t.properties.background_mode})]}),e.jsxs(i.Row,{children:[e.jsx(i.Col,{children:"Calibration"}),e.jsx(i.Col,{children:t.properties.current_calibration})]}),e.jsxs(i.Row,{children:[e.jsx(i.Col,{children:"Fit Wavelength"}),e.jsxs(i.Col,{children:[(o=t.properties.fit_wavelength)==null?void 0:o.join(" - ")," ",e.jsx("span",{children:"nm"})]})]})]})})]}),children:e.jsx(i.Button,{children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Ze(n){const{hardware:t,options:o={},disabled:s}=n,[r,a]=h.useState(!1);function c(p){return p<=0?Promise.reject(new Error("exposure_time must be > 0")):t.actions.setProperty("exposure_time",p)}function l(){a(!0);const p=t.actions.call("measure");return p!==void 0&&(console.log("pending"),p.then(()=>{a(!1)}).catch(m=>{a(!1)})),p}const f=t.properties.state,u=e.jsx(y,{name:"Laser Heating",icon:"fa-fire",online:t.online}),d=e.jsx(F,{state:f,minWidth:6,variant:f==="READY"?"success":"warning"});return e.jsx(v,{hardware:t,widgetIcon:u,widgetState:d,widgetContent:e.jsxs(i.InputGroup,{children:[e.jsx(xe,{id:t.id,hardwareValue:t.properties.exposure_time,hardwareIsReady:!0,hardwareIsDisabled:n.disabled,hardwareIsMoving:!1,onMoveRequested:c,onAbortRequested:()=>null,precision:1,readOnly:!1,step:o.exposureStep,steps:o.exposureSteps,incIcon:void 0,decIcon:void 0,swapIncDec:void 0}),e.jsx(i.InputGroup.Text,{children:"s"}),e.jsx(i.Button,{size:"sm",disabled:n.disabled||r,onClick:()=>{l()},children:r?e.jsx("i",{className:"fa fa-spinner fa-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"fa fa-play me-1"}),"Measure"]})}),e.jsx(Uo,{hardware:t,disabled:n.disabled})]})})}const Ho={default:Ze},qo=Ho,zo=[],Wo="laserheating",Yo="laserheating",Ko=!0,Qo={exposure_time:.5,state:"ON",background_mode:"READY",fit_wavelength:[500,650],current_calibration:"/path/to/file"},Xo="bliss",Jo=!1,Zo="laserheating",es={callables:zo,id:Wo,name:Yo,online:Ko,properties:Qo,protocol:Xo,require_staff:Jo,type:Zo},ts={default:es};function et(n){const t=h.useRef(null),{hardware:o,options:s={}}=n;function r(c){o.actions.setProperty("intensity",c)}const a=h.useCallback(mn.default(r,100),[]);return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(y,{name:"Light",icon:"fa-lightbulb-o",online:o.online}),e.jsx("div",{className:"name",children:o.name}),e.jsx(i.Badge,{bg:o.properties.state==="ON"?"success":"danger",children:o.properties.state})]}),e.jsxs("div",{className:"hw-content",children:[e.jsx(i.Form.Control,{ref:t,disabled:n.disabled,type:"range",min:"0",max:"100",onChange:c=>a(Number.parseFloat(c.target.value)),defaultValue:o.properties.intensity}),e.jsxs("div",{children:[e.jsx(i.Button,{disabled:o.properties.intensity===0,size:"sm",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>a(0),children:e.jsx("i",{className:"fa fa-power-off"})}),e.jsxs("span",{className:"float-end",children:[o.properties.intensity," %"]})]})]})]})}const ns={default:et},os=ns,ss=[],rs="light_vlm",is="light_vlm",as=!0,cs={intensity:0,state:"ON",temperature:23.2},ls="bliss",ds=!1,us="light",fs={callables:ss,id:rs,name:is,online:as,properties:cs,protocol:ls,require_staff:ds,type:us},ps={default:fs};function H(n){const{hardware:t}=n,{online:o,locked:s=null}=t,r=t.properties.state??"UNKNOWN";console.log(r);const a=o?(r==="ACQUIRING"?r:s!==null?"LOCKED":r)||"UNKNOWN":"OFFLINE",c={UNKNOWN:"critical",ACQUIRING:"warning",READY:"success",OFFLINE:"secondary",LOCKED:"warning"},l=c[a]??c.UNKNOWN;return e.jsx(F,{state:a,minWidth:6,variant:l})}function ms(n){const{hardware:t}=n;return e.jsx(H,{hardware:t})}function Re(n){const{hardware:t,options:o={}}=n;return e.jsx(i.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:e.jsx("div",{children:t.name})})}function tt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(H,{hardware:t}),a=o.header||"top";return a==="none"?e.jsx(Re,{...n}):e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:e.jsx(Re,{...n}),headerMode:a})}function Ee(n){const{hardware:t,options:o={}}=n,[s,r]=t.properties.size??["?","?"];return e.jsxs(i.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:[e.jsxs("div",{children:[s," × ",r]}),e.jsx("div",{className:"ms-auto",children:e.jsx("small",{children:e.jsx("small",{children:"px"})})})]})}function nt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(H,{hardware:t}),a=o.header??"top";return a==="none"?e.jsx(Ee,{...n}):e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:e.jsx(Ee,{...n}),headerMode:a})}function z(n){const[t,o]=h.useState(!1);return e.jsxs(i.Button,{variant:n.isActive?"primary":t?"warning":"secondary",onClick:()=>{o(!0),n.onAction().finally(()=>{o(!1)})},disabled:n.disabled||t,title:n.title,className:"text-nowrap",children:[n.icon&&e.jsx("i",{className:`col-sm-4 justify-content-center align-self-center ${n.icon}`}),n.children]})}function hs(n){const{hardware:t,options:o={},disabled:s}=n,{actions:r,properties:a}=t,{rotation:c,flip:[l,f]}=a;return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary",disabled:s}),e.jsx(i.Dropdown.Menu,{align:"end",popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Rotation"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsxs(i.ButtonGroup,{children:[e.jsx(z,{isActive:c===0,onAction:()=>r.setProperty("rotation",0),disabled:s,title:"Disable rotation transformation",children:"None"}),e.jsxs(z,{isActive:c===90,onAction:()=>r.setProperty("rotation",90),disabled:s,title:"Disable rotation transformation",children:["90 ",e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]}),e.jsxs(z,{isActive:c===180,onAction:()=>r.setProperty("rotation",180),disabled:s,title:"Disable rotation transformation",children:["180 ",e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]}),e.jsxs(z,{isActive:c===270,onAction:()=>r.setProperty("rotation",270),disabled:s,title:"Disable rotation transformation",children:["270 ",e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]})]})})}),e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Flip"})}),e.jsxs(i.Row,{className:"gx-0",children:[e.jsx(i.Col,{xs:6,children:e.jsxs(i.ButtonGroup,{children:[e.jsxs(z,{isActive:l,onAction:()=>r.setProperty("flip",[!0,f]),disabled:s,title:"Enable horizontal flip transformation",children:["Horiz ",e.jsx("i",{className:"fa fa-fw fa-left-right"})]}),e.jsx(z,{isActive:!l,onAction:()=>r.setProperty("flip",[!1,f]),disabled:s,title:"Disable horizontal flip transformation",children:"No"})]})}),e.jsx(i.Col,{xs:6,children:e.jsxs(i.ButtonGroup,{children:[e.jsxs(z,{isActive:f,onAction:()=>r.setProperty("flip",[l,!0]),disabled:s,title:"Enable vertical flip transformation",children:["Vert ",e.jsx("i",{className:"fa fa-fw fa-up-down"})]}),e.jsx(z,{isActive:!f,onAction:()=>r.setProperty("flip",[l,!1]),disabled:s,title:"Disable vertical flip transformation",children:"No"})]})})]})]})})]})}function xs(n){const{hardware:t,options:o={}}=n,{properties:s}=t,[r,a]=s.flip,c=s.rotation??0,l=!r&&!a&&c===0;return e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsxs(i.InputGroup.Text,{children:[r&&e.jsxs(i.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Flip",e.jsx("i",{className:"fa fa-fw fa-left-right"})]}),a&&e.jsxs(i.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Flip",e.jsx("i",{className:"fa fa-fw fa-up-down"})]}),c!==0&&e.jsxs(i.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Rot ",c.toFixed(0),e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]}),l&&e.jsx(i.Badge,{bg:"secondary",style:{fontSize:"130%"},title:"No transformation",children:"None"})]}),!o.readonly&&e.jsx(hs,{...n})]})}function ot(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(H,{hardware:t}),a=e.jsx(e.Fragment,{children:e.jsx(xs,{...n})}),c=o.header??"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const st="4.2em";function gs(n){const{hardware:t}=n,{properties:o}=t,s=o.state==="READY",r=n.disabled||!t.online||!s,a=o.binning_mode??"SUM";function c(l){const{binningMode:f,selectedMode:u,title:d}=l,m=f===u?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(i.Dropdown.Item,{disabled:r,onClick:()=>{t.actions.setProperty("binning_mode",f)},title:d,children:[e.jsx("i",{className:m})," "," ",e.jsx(i.Badge,{style:{minWidth:st},children:f})]},f)}return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:r,variant:"secondary"}),e.jsxs(i.Dropdown.Menu,{align:"end",popperConfig:{strategy:"fixed"},children:[e.jsx(c,{binningMode:"SUM",selectedMode:a,title:"Merge binned pixel with SUM operation"}),e.jsx(c,{binningMode:"MEAN",selectedMode:a,title:"Merge binned pixel with MEAN operation"})]})]})}function js(n){const{hardware:t,options:o,disabled:s}=n,{properties:r}=t,[a,c]=r.binning,l=a===c?a:0,f=r.binning_mode??"SUM";function u(m){t.actions.setProperty("binning",[m,m])}const d=Os(t),p=o.readonly??!1;return e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(i.InputGroup.Text,{title:"Binning applied to the detector",children:e.jsx("i",{className:"fa fa-fw fa-ruler-combined fa-2x"})}),e.jsx(A,{value:`${r.binning[0]} × ${r.binning[1]}`}),!p&&e.jsxs(e.Fragment,{children:[e.jsx(i.Button,{variant:l===1?"primary":"secondary",onClick:()=>{u(1)},disabled:s,children:"1"}),e.jsx(i.Button,{variant:l===2?"primary":"secondary",onClick:()=>{u(2)},disabled:s,children:"2"}),e.jsx(i.Button,{variant:l===3?"primary":"secondary",onClick:()=>{u(3)},disabled:s,children:"3"}),e.jsx(i.Button,{variant:l===4?"primary":"secondary",onClick:()=>{u(4)},disabled:s,children:"4"})]}),e.jsx(i.InputGroup.Text,{title:"Binning applied to the detector",children:e.jsx(i.Badge,{style:{fontSize:"130%",minWidth:st},title:`Detector setup with binning ${f}`,children:f})}),!p&&d&&e.jsx(gs,{...n})]})}function rt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(H,{hardware:t}),a=e.jsx(e.Fragment,{children:e.jsx(js,{...n})}),c=o.header??"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function ws(n){const{hardware:t}=n,{properties:o}=t;return e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(i.InputGroup.Text,{title:"Rotation applied to the detector",children:e.jsx("i",{className:"fa fa-fw fa-crop-simple fa-2x"})}),e.jsx(i.Form.Control,{value:`${o.roi[0]}`,readOnly:!0}),e.jsx(i.Form.Control,{value:`${o.roi[1]}`,readOnly:!0}),e.jsx(i.Form.Control,{value:`${o.roi[2]}`,readOnly:!0}),e.jsx(i.Form.Control,{value:`${o.roi[3]}`,readOnly:!0}),e.jsx(i.InputGroup.Text,{children:"px"})]})}function it(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(H,{hardware:t}),a=e.jsx(e.Fragment,{children:e.jsx(ws,{hardware:t})}),c=o.header??"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function ys(n){const{hardware:t}=n,{properties:o}=t,s=o.static,[r,a]=(s==null?void 0:s.image_max_dim)??["?","?"];return e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{title:"Max size of the detector",children:"Max size"}),e.jsx(i.Form.Control,{value:`${r} × ${a}`,readOnly:!0}),e.jsx(i.InputGroup.Text,{children:"px"})]})}function vs(n){const{hardware:t}=n,{properties:o}=t,s=o.static;return e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{title:"Version of the Lima server (lima-core)",children:"Lima version"}),e.jsx(i.Form.Control,{value:`${s==null?void 0:s.lima_version}`,readOnly:!0})]})}function Ns(n){const{hardware:t}=n,{properties:o}=t,s=o.static;return e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{title:"Model of the detector",children:"Type/model"}),e.jsx(i.Form.Control,{value:`${s==null?void 0:s.camera_type}`,readOnly:!0}),e.jsx(i.Form.Control,{value:`${s==null?void 0:s.camera_model}`,readOnly:!0})]})}function at(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(H,{hardware:t}),a=e.jsxs(e.Fragment,{children:[e.jsx(Ns,{hardware:t}),e.jsx(ys,{hardware:t}),e.jsx(vs,{hardware:t})]}),c=o.header??"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function bs(n){var _;const{hardware:t,disabled:o}=n,{properties:s}=t,r=((_=s.static)==null?void 0:_.image_max_dim)??[0,0],a=s.roi,c=s.binning??[1,1],l=r[0]/c[0],f=r[1]/c[1];function u(){return f>l?1/f:1/l}const d=u(),[p,m]=[100*l*d,100*f*d];function g(){const[S,C,G,B]=a;return[100*S/l,100*C/f,100*G/l,100*B/f]}function w(){const[S,C,G,B]=a;return[100*(S+G*.5)/l,100*(C+B*.5)/f]}const[x,j,N,I]=g(),[M,b]=w();return e.jsx("div",{style:{backgroundColor:"#AAAAAA",width:"10em",height:"10em"},children:e.jsxs("div",{className:"position-relative",title:`Detector ${t.id}`,style:{backgroundColor:"#FFFFFF",border:"2px solid black",width:`${p}%`,height:`${m}%`},children:[e.jsx("div",{title:"ROI location",className:"position-absolute",style:{backgroundColor:"#FFFFFF",border:"2px dotted black",left:`${x}%`,top:`${j}%`,width:`${N}%`,height:`${I}%`}}),e.jsxs("span",{className:"position-absolute",style:{left:`${M}%`,top:`${b}%`,transform:"translate(-50%, -50%)"},children:[a[2],"×",a[3]]})]})})}function ct(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(H,{hardware:t}),a=e.jsx(e.Fragment,{children:e.jsx(bs,{...n})}),c=o.header??"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const W={};function _s(n){n.useHardware&&(W.useHardware&&console.warn("useHardware hook was already registered"),W.useHardware=n.useHardware),n.useHardwareChangeActions&&(W.useHardwareChangeActions&&console.warn("useHardwareChangeActions hook was already registered"),W.useHardwareChangeActions=n.useHardwareChangeActions)}function E(n){if(!W.useHardware)throw new Error("No `useHardware` hook registered");return W.useHardware(n)}function te(n){if(!W.useHardwareChangeActions)throw new Error("No `useHardwareChangeActions` hook registered");return W.useHardwareChangeActions(n)}function ge(n){return n.type==="lima"}function $s(n){const t=E(n);return t===null||!ge(t)?null:t}function lt(n,t){const o=Math.ceil(n/t),s=n/o;return[o,s]}const Ss={default:tt,size:nt,transformation:ot,binning:rt,imageroi:it,description:at,shape:ct,state:ms},Cs=Ss;function Os(n){var t;return n.properties.binning_mode!==void 0&&hn.default.gte(((t=n.properties.static)==null?void 0:t.lima_version)??"0.0.0","1.10.4")}const Is="lima_cam",Ms="lima_cam",Ts="bliss",Fs="lima",Ds=!0,As=!1,Rs={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:0,size:[128,128],state:"READY"},Es={id:Is,name:Ms,protocol:Ts,type:Fs,online:Ds,require_staff:As,properties:Rs},ks="lima_cam",Ps="lima_cam",Gs="bliss",Bs="lima",Vs=!0,Ls=!1,Us={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!0,!1],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:0,size:[128,128],state:"READY"},Hs={id:ks,name:Ps,protocol:Gs,type:Bs,online:Vs,require_staff:Ls,properties:Us},qs="lima_cam",zs="lima_cam",Ws="bliss",Ys="lima",Ks=!0,Qs=!1,Xs={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:180,size:[128,128],state:"READY"},Js={id:qs,name:zs,protocol:Ws,type:Ys,online:Ks,require_staff:Qs,properties:Xs},Zs="lima_cam",er="lima_cam",tr="bliss",nr="lima",or=!0,sr=!1,rr={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],pixel_size:[1e3,1e3],raw_roi:[0,710,1920,500],roi:[0,710,1920,500],rotation:0,size:[1920,1920],state:"READY"},ir={id:Zs,name:er,protocol:tr,type:nr,online:or,require_staff:sr,properties:rr},ar="lima_cam",cr="lima_cam",lr="bliss",dr="lima",ur=!0,fr=!1,pr={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[5e3,2e3]},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],pixel_size:[1e3,1e3],raw_roi:[0,0,5e3,2e3],roi:[0,0,5e3,2e3],rotation:0,size:[5e3,2e3],state:"READY"},mr={id:ar,name:cr,protocol:lr,type:dr,online:ur,require_staff:fr,properties:pr},hr={default:Es,flip:Hs,rot:Js,roicenter:ir,squaredetector:mr};function xr(n){const{name:t,alias:o,useHardwareContext:s}=n,r=[1920,1920],a=[16e-6,16e-6],[c,l]=h.useState({static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:a,image_max_dim:r},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],pixel_size:a,raw_roi:[0,0,...r],roi:[0,0,...r],rotation:0,size:r,state:"READY"});async function f(x,j){console.log("LimaSimulator: Unsupported call",x,j)}function u(x,j){const N=[Math.round(a[0]*j[0]),Math.round(a[1]*j[1])],I=[Math.round(r[0]/j[0]),Math.round(r[1]/j[1])];return{...x,binning:j,pixel_size:N,roi:[0,0,...I],size:I}}function d(x,j){return{...x,binning_mode:j}}function p(x,j){return{...x,rotation:j}}function m(x,j){return{...x,flip:[j,x.flip[1]]}}function g(x,j){return{...x,flip:[x.flip[0],j]}}async function w(x,j){if(x==="binning"){l(N=>u(N,j));return}if(x==="binning_mode"){l(N=>d(N,j));return}if(x==="rotation"){l(N=>p(N,j));return}if(x==="flip_x"){l(N=>m(N,j));return}if(x==="flip_y"){l(N=>g(N,j));return}console.log("LimaSimulator: Unsupported setProperty",x,j)}return e.jsx(U,{name:t,alias:o,type:"lima",call:f,setProperty:w,properties:c,useHardwareContext:s})}function gr(n,t){const{inputRef:o,referenceElementRef:s,onAddSelection:r,onRemoveSelection:a,...c}=n,l=h.useRef(),f=()=>{setTimeout(()=>{const p=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;p&&p.call(l.current,""),l.current&&l.current.dispatchEvent(new Event("input",{bubbles:!0}))},500)},u=()=>{r&&r(t.results).then(()=>{f()})},d=()=>{const p=t.text?[...t.selected].filter(m=>m.toLowerCase().indexOf(t.text.toLowerCase())!==-1):[...t.selected];a&&a(p).then(()=>{f()})};return e.jsxs(i.InputGroup,{children:[e.jsx(L.Hint,{children:e.jsx(i.Form.Control,{style:{width:"100%"},...c,ref:p=>{l.current=p,o(p),s(p)},placeholder:`${t.selected.length} enabled`})}),e.jsx(i.Button,{disabled:n.disabled||t.results.length===0,onClick:u,children:e.jsx("i",{className:"fa fa-plus"})}),e.jsx(i.Button,{disabled:n.disabled,onClick:d,children:e.jsx("i",{className:"fa fa-minus"})})]})}function jr(n){return function(t){function o(s,r,a){return t(s,r,a,n)}return o.displayName=`WithExtraProps(${t.displayName||t.name||"Component"})`,o}}function wr(n,t,o,s){const a=[...o.selected].filter(f=>f.toLowerCase().indexOf(o.text.toLowerCase())!==-1).sort().map(f=>e.jsx("a",{href:"#",className:"dropdown-item",onClick:()=>o.onRemove(f),children:e.jsx(L.Highlighter,{search:o.text,children:f})},f)),l=[...o.results].sort().map((f,u)=>e.jsx(L.MenuItem,{option:f,position:u,children:e.jsx(L.Highlighter,{search:o.text,children:f})},f));return e.jsxs(L.Menu,{...t,style:{...t.style,width:350},children:[s.pending&&e.jsx(L.Menu.Header,{children:"Loading..."}),!s.pending&&e.jsxs(e.Fragment,{children:[e.jsx(L.Menu.Header,{children:"Enabled"}),a,a.length===0&&e.jsx("span",{className:"dropdown-item disabled",children:"No items enabled"}),e.jsx(L.Menu.Header,{children:"Available"}),l,l.length===0&&e.jsx("span",{className:"dropdown-item disabled",children:"No items available"})]})]})}function yr(n){const{hardware:t,disabled:o=!1}=n,{online:s}=t;if(!s)return e.jsx(i.Alert,{children:"Offline"});const r=t.properties.available.filter(f=>!t.properties.disabled.includes(f));function a(f){const u=f.filter(p=>!r.includes(p)),d=r.filter(p=>!f.includes(p));u.length>0&&u.forEach(p=>{t.actions.call("enable",p)}),d.length>0&&d.forEach(p=>{t.actions.call("disable",p)})}function c(f){const u=[];return f.forEach(d=>{const p=t.actions.call("enable",d);u.push(p)}),Promise.all(u)}function l(f){const u=[];return f.forEach(d=>{const p=t.actions.call("disable",d);u.push(p)}),Promise.all(u)}return e.jsx(L.Typeahead,{disabled:o,id:`typeahead_mg_${t.name}`,multiple:!0,flip:!0,positionFixed:!0,renderInput:gr,renderMenu:jr({name:t.id})(wr),onChange:a,inputProps:{onAddSelection:c,onRemoveSelection:l},selected:r,options:t.properties.available,selectHint:(f,u)=>u.key==="Enter"||f})}function dt(n){const{hardware:t,options:o,disabled:s=!1}=n;function r(){return t.actions.call("set_active")}const a=o.header??"top",c=e.jsx(y,{name:"Measurement Group",icon:"fa-list-ol",online:!0}),l=e.jsx(e.Fragment,{children:e.jsx(i.OverlayTrigger,{placement:"top",overlay:e.jsx(i.Tooltip,{id:"active",children:"Activate this measurement group"}),children:e.jsx(i.Button,{size:"sm",disabled:s,onClick:()=>void r(),className:"float-right ml-1",children:e.jsx("i",{className:"fa fa-power-off"})})})}),f=e.jsx(yr,{...n});return e.jsx(v,{hardware:t,widgetIcon:c,widgetState:l,widgetContent:f,headerMode:a})}const vr={default:dt},Nr=vr,br=[],_r="mg",$r="mg",Sr=!0,Cr={available:["lima:image","diode1","diode2","machinfo:current","machinfo:srcurrent"],disabled:["machinfo:current"]},Or="bliss",Ir=!1,Mr="measurementgroup",Tr={callables:br,id:_r,name:$r,online:Sr,properties:Cr,protocol:Or,require_staff:Ir,type:Mr},Fr={default:Tr};function Dr(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState({available:["lima:image","diode1","diode2","machinfo:current","machinfo:srcurrent"],disabled:["machinfo:current"]});async function c(d){a(p=>{const{disabled:m}=p;return{...p,disabled:m.filter(g=>g!==d)}})}async function l(d){a(p=>{const{disabled:m}=p;return{...p,disabled:m.includes(d)?m:[...m,d]}})}async function f(d,p){if(d==="enable"){await c(p);return}if(d==="disable"){await l(p);return}d!=="set_active"&&console.log("MeasurementGroupSimulator: Unsupported call",d,p)}async function u(d,p){console.log("MeasurementGroupSimulator: Unsupported setProperty",d,p)}return e.jsx(U,{name:t,alias:o,type:"measurementgroup",call:f,setProperty:u,properties:r,useHardwareContext:s})}const _e={description:"Unknown state is exposed",variant:"fatal",priority:100},ce={OFFLINE:{description:"Axis is offline",variant:"secondary",priority:0},MOVING:{description:"Axis is moving",variant:"warning",priority:10},FAULT:{description:"Axis is in fault",variant:"danger",priority:20},LOCKED:{description:"Axis is locked",variant:"warning",priority:25},OFF:{description:"Power is off",variant:"secondary",priority:30},DISABLED:{description:"Axis is disabled",variant:"warning",priority:40},LOWLIMIT:{description:"Low limit is reached",variant:"warning",priority:50},HIGHLIMIT:{description:"High limit is reached",variant:"warning",priority:51},HOME:{description:"Home signal active",variant:"info",priority:52},READY:{description:"Ready to handle request",variant:"success",priority:60},NOT_READY:{description:"Not ready",variant:"warning",priority:100},UNKNOWN:_e};function je(n){const{hardware:t}=n,{locked:o=null}=t,{state:s=["UNKNOWN"]}=t.properties,[r,a]=h.useMemo(()=>{if(!t.online)return[["OFFLINE"],void 0];function c(p,m){const g=ce[p]??_e,w=ce[m]??_e;return g.priority-w.priority}const l=[...s,...o!==null?["LOCKED"]:[],...s.length===0?["NOT_READY"]:[]];l.sort(c);function f(p){const m=p.split(":",2);return m.length===1?[p,void 0]:m}const u={};return[l.map(p=>{if(p.startsWith("_")){const m=f(p);return m[1]!==void 0&&(u[m[0]]=m[1]),m[0]}return p==="LOCKED"?u[p]=`Locked by ${o}`:u[p]=ce[p].description??"",p}),u]},[s,t.online,o]);return e.jsx(qe,{states:r,descriptions:a,minWidth:6,variants:Object.fromEntries(Object.entries(ce).map(([c,l])=>[c,l.variant]))})}function Ar(n){const{hardware:t}=n;return e.jsx(je,{hardware:t})}function oe(n){const t=h.useRef(null),[o,s]=h.useState(!1),[r,a]=h.useState(!1);function c(d){return n.precision!==void 0?Number.parseFloat(d).toFixed(n.precision):d}h.useEffect(()=>{var d;t.current&&(t.current.value=c((d=n.hardwareValue)==null?void 0:d.toString()),s(!1))},[n.hardwareValue,n.precision]);function l(d){const p=c(d);t!=null&&t.current&&(t.current.value=p)}function f(d){switch(d.key){case"Enter":{s(!1);const p=Number.parseFloat(d.target.value),m=n.onMoveRequested(p);m&&m.catch(()=>{a(!0),setTimeout(()=>{l(n.hardwareValue),a(!1)},2e3)}),d.preventDefault(),d.stopPropagation();break}case"Esc":case"Escape":o&&(a(!1),s(!1),l(n.hardwareValue)),d.target.blur(),d.preventDefault(),d.stopPropagation();break}}function u(d){s(d.target.value!==n.hardwareValue.toString())}return e.jsx(i.Form.Control,{className:P.default({"form-control-edited":o,"form-control-error":r,"hw-moving":n.hardwareIsMoving}),type:"number",ref:t,onChange:u,onKeyDown:f,disabled:n.readOnly||n.hardwareIsMoving||n.hardwareIsDisabled,step:n.step,onClick:d=>{d.stopPropagation()}})}function Rr(n){const{states:t,hardware:o}=n,{properties:s}=o;function r(c){return o.actions.setProperty("velocity",c)}function a(c){return o.actions.setProperty("acceleration",c)}return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[o.name," details"]}),e.jsxs(i.Popover.Body,{children:[e.jsxs(i.Form.Group,{children:[e.jsx(i.Form.Label,{children:"Velocity"}),e.jsx(oe,{hardwareValue:(s==null?void 0:s.velocity)??0,onMoveRequested:r,hardwareIsDisabled:n.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:n.readOnly})]}),e.jsxs(i.Form.Group,{children:[e.jsx(i.Form.Label,{children:"Acceleration"}),e.jsx(oe,{hardwareValue:(s==null?void 0:s.acceleration)??0,onMoveRequested:a,hardwareIsDisabled:n.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:n.readOnly})]})]})]}),children:e.jsx(i.Button,{children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Q(n){const{hardware:t,options:o={}}=n,{properties:s,user_tags:r}=t;function a(){t.actions.call("stop")}function c(p){return t.actions.call("move",p)}const l=Ce(s.state,r),f=e.jsx(y,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),u=e.jsx(je,{hardware:t}),d=n.options?n.options.header:"top";return e.jsx(v,{hardware:t,widgetIcon:f,widgetState:u,widgetContent:e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(xe,{id:t.id,hardwareValue:(s==null?void 0:s.position)??null,hardwareIsDisabled:n.disabled,hardwareIsReady:l.READY??!1,hardwareIsMoving:l.MOVING??!1,onMoveRequested:c,onAbortRequested:a,precision:o.precision??s.display_digits??void 0,readOnly:o.readOnly,stepOnly:o.stepOnly,step:o.step,steps:o.steps,incIcon:o.incicon,decIcon:o.decicon,swapIncDec:o.swapincdec,horizontalArrows:o.horizontalarrows,largeArrows:o.largearrows}),s.unit&&e.jsx(i.InputGroup.Text,{children:s.unit}),!l.MOVING&&o.extended&&e.jsx(Rr,{hardware:t,disabled:n.disabled,readOnly:o.readOnly,states:l}),l.MOVING&&!n.disabled&&!o.step&&e.jsx(i.Button,{variant:"danger",onClick:a,children:e.jsx("i",{className:"fa fa-times"})})]}),headerMode:d})}function ke(n){const{hardware:t,options:o={}}=n,s=Ce(t.properties.state,t.user_tags);function r(a){if(a===null)return"∅";const c=o.precision??t.properties.display_digits??void 0;return c!==void 0?a.toFixed(c):`${a}`}return e.jsxs(i.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:[e.jsx("div",{className:P.default({"hw-moving":s.MOVING}),children:r(t.properties.position)}),t.properties.unit&&e.jsx("div",{className:"ms-auto",children:e.jsx("small",{children:e.jsx("small",{children:t.properties.unit})})})]})}function ut(n){const{hardware:t}=n,o=e.jsx(y,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),s=e.jsx(je,{hardware:t}),r=n.options?n.options.header:"top";return r==="none"?e.jsx(ke,{...n}):e.jsx(v,{hardware:t,widgetIcon:o,widgetState:s,widgetContent:e.jsx(ke,{...n}),headerMode:r})}function Ce(n,t=[]){return h.useMemo(()=>{const o=t.includes("auto_ready"),s=t.includes("auto_on");if(n===void 0)return{UNKNOWN:!0};if((n==null?void 0:n.length)===0)return o?{READY:!0}:{NOT_READY:!0};const r=n.reduce((a,c)=>(a[c]=!0,a),{});return r.READY===void 0&&s&&r.OFF&&(r.READY=!0),r},[n,t])}function ft(n){return n.type==="motor"}function k(n){const t=E(n);return t===null||!ft(t)?null:t}const Er={default:Q,text:ut,state:Ar},kr=Er,Pr=["move","stop","wait","rmove"],Gr="omega",Br="omega 123",Vr=!0,Lr={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},Ur="bliss",Hr=!1,qr="motor",zr=[],Wr={callables:Pr,id:Gr,name:Br,online:Vr,properties:Lr,protocol:Ur,require_staff:Hr,type:qr,user_tags:zr},Yr=["move","stop","wait","rmove"],Kr="omega",Qr="omega 123",Xr=!0,Jr={offset:0,sign:1,acceleration:300,limits:[-10,190],position:100,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3},Zr="bliss",ei=!1,ti="motor",ni=[],oi={callables:Yr,id:Kr,name:Qr,online:Xr,properties:Jr,protocol:Zr,require_staff:ei,type:ti,user_tags:ni},si=["move","wait","stop","rmove"],ri="omega",ii="omega 123",ai=!0,ci={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:["UNKNOWN"],target:null,tolerance:1e-4,unit:"deg",velocity:null},li="bliss",di=!1,ui="motor",fi=[],pi={callables:si,id:ri,name:ii,online:ai,properties:ci,protocol:li,require_staff:di,type:ui,user_tags:fi},mi=["move","wait","stop","rmove"],hi="omega",xi="omega 123",gi=!0,ji={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:[],target:null,tolerance:1e-4,unit:"deg",velocity:null},wi="bliss",yi=!1,vi="motor",Ni=[],bi={callables:mi,id:hi,name:xi,online:gi,properties:ji,protocol:wi,require_staff:yi,type:vi,user_tags:Ni},_i=["move","wait","stop","rmove"],$i="omega",Si="omega 123",Ci=!1,Oi={},Ii="bliss",Mi=!1,Ti="motor",Fi=[],Di={callables:_i,id:$i,name:Si,online:Ci,properties:Oi,protocol:Ii,require_staff:Mi,type:Ti,user_tags:Fi},Ai=["move","wait","stop","rmove"],Ri="omega",Ei="omega 123",ki=!0,Pi={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:["OFF"],target:null,tolerance:1e-4,unit:"deg",velocity:null},Gi="bliss",Bi=!1,Vi="motor",Li=[],Ui={callables:Ai,id:Ri,name:Ei,online:ki,properties:Pi,protocol:Gi,require_staff:Bi,type:Vi,user_tags:Li},Hi={default:Wr,halfMotor:oi,unknownMotor:pi,notReadyMotor:bi,disconnectedMotor:Di,powerOffMotor:Ui};function qi(n,t){return{id:n,name:n,type:"motor",properties:{position:t,unit:"mm",limits:[-100,100]},online:!0}}function zi(n){const{name:t="omega",minLimit:o=-999999999,maxLimit:s=999999999,initialPosition:r=0,initialVelocity:a=1e3,useHardwareContext:c=()=>null}=n,[l,f]=h.useState(r),[u,d]=h.useState(["READY"]),[p,m]=h.useState(null),g=h.useRef(Date.now()),w=c(),x=()=>{const _=Date.now(),S=(_-g.current)/1e3;let C;if(g.current=_,p!==null&&p!==l){let G,B;const $=S*a;if($>Math.abs(l-p))C=p,G=["READY"],B=null;else{const q=p>l?1:-1;C=l+q*$,G=["MOVING"],B=p}f(C),d(G),m(B)}},j=h.useCallback((_,S)=>{if(_==="stop")return m(null),d(["READY"]),Promise.resolve();if(_==="move"){const C=Number.parseFloat(S);return m(Number.isNaN(C)?null:C),Promise.resolve()}return console.log("MotorSimulator: Unsupported call",_,S),Promise.resolve()},[]),N=h.useCallback((_,S)=>(console.log("MotorSimulator: Unsupported setProperty",_,S),Promise.resolve()),[]);h.useEffect(()=>{const _=setInterval(()=>{x()},500);return()=>clearInterval(_)});const I=h.useMemo(()=>{var S,C;const _={setProperty:N,call:j};return(C=w==null?void 0:(S=w.actions).updateHardwareChangeActions)==null||C.call(S,t,_),_},[]),M={id:t,name:t,alias:null,online:!0,properties:{acceleration:300,limits:[o,s],position:l,offset:0,sign:1,state:u,tolerance:1e-4,unit:"mm",velocity:a,target:p,display_digits:3},type:"motor",actions:I,user_tags:[],locked:null},b=h.useRef(null);return h.useEffect(()=>{b.current!==null&&D.isEqual(b.current,M)||(b.current=M,w==null||w.actions.updateHardware(t,M))},[t,M]),e.jsx(e.Fragment,{})}function pt(n){const{hardware:t,options:o={}}=n,s=h.useRef(null);h.useEffect(()=>{if(!s.current){console.error("selectionRef ref is unset");return}s.current.value=t.properties.position},[t.properties.position]);function r(l){if(console.debug("change",l),!s||!s.current){console.error("selection ref is unset");return}t.actions.call("move",s.current.value)}function a(l){t.actions.call("stop")}const c=D.map(t.properties.positions,l=>e.jsx("option",{title:l.description,children:l.position},l.position));return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(y,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(i.Badge,{bg:t.properties.state==="READY"?"success":"warning",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsxs(i.Form.Control,{className:"custom-select",as:"select",ref:s,disabled:n.disabled,defaultValue:t.properties.position,children:[e.jsx("option",{disabled:!0,children:"unknown"}),c]}),t.properties.state!=="MOVING"&&e.jsx(i.Button,{onClick:r,disabled:n.disabled,children:"Move"}),t.properties.state==="MOVING"&&!n.disabled&&e.jsx(i.Button,{variant:"danger",onClick:a,children:e.jsx("i",{className:"fa fa-times"})})]})})]})}function Wi(n){const{hardware:t}=n,{properties:o}=t,s=o.state==="READY",r=n.disabled||!t.online||!s,a=o.position;function c(f){t.actions.call("move",f)}function l(f){const u=f.position,p=u===a?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(i.Dropdown.Item,{disabled:r,onClick:()=>{c(u)},title:f.description,children:[e.jsx("i",{className:p}),"  ",u]},u)}return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:r,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{align:"end",popperConfig:{strategy:"fixed"},children:o.positions.map(f=>l(f))})]})}function Yi(n){var p,m;const{hardware:t,options:o={}}=n,s=((p=t.properties)==null?void 0:p.state)==="MOVING";function r(g){t.actions.call("stop")}const a=e.jsx(y,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),c=e.jsx(Be,{hardware:t}),l=s?"Moving":null,f=(m=t.properties)==null?void 0:m.position;function u(){return e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(A,{className:P.default({"hw-moving":s}),value:l??f??"Unknown"}),!s&&!n.disabled&&e.jsx(Wi,{...n}),s&&!n.disabled&&e.jsx(i.Button,{variant:"danger",onClick:r,children:e.jsx("i",{className:"fa fa-fw fa-times"})})]})}const d=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:a,widgetState:c,widgetContent:u(),headerMode:d})}const Ki={default:pt,default2:Yi},Qi=Ki,Xi=["move","stop"],Ji="beamstop",Zi="beamstop",ea=!0,ta={position:"OUT",positions:[{description:"Beamstop position IN the beam",position:"IN",target:[{destination:2.5,tolerance:.01},{destination:1,tolerance:.2}]},{description:"Beamstop position OUT of the beam",position:"OUT",target:[{destination:3.5,tolerance:.01},{destination:2,tolerance:.2}]}],state:"READY"},na="bliss",oa=!1,sa="multiposition",ra={callables:Xi,id:Ji,name:Zi,online:ea,properties:ta,protocol:na,require_staff:oa,type:sa},ia={default:ra};function aa(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("empty"),[c,l]=h.useState("READY");async function f(p,m){if(p==="move"){l("MOVING"),a("unknown"),await R(2e3),l("READY"),a(m);return}if(p==="stop"){a("unknown"),await R(2e3);return}console.log("MultipositionSimulator: Unsupported call",p,m)}async function u(p,m){console.log("MultipositionSimulator: Unsupported setProperty",p,m)}const d={position:r,state:c,positions:[{position:"empty",description:"No filter",target:[]},{position:"gold2",description:"Gold filter 2mm",target:[]},{position:"silver3",description:"Silver filter 3mm",target:[]}]};return e.jsx(U,{name:t,alias:o,type:"multiposition",call:f,setProperty:u,properties:d,useHardwareContext:s})}function Oe(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOVING:"warning",INVALID:"danger",UNKNOWN:"danger",DISABLED:"secondary",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(F,{state:o,minWidth:6,variant:r})}function ca(n){const{hardware:t}=n;return e.jsx(Oe,{hardware:t})}function la(n){const{hardware:t,options:o={}}=n,{properties:s}=t,{state:r}=s,a=r==="MOVING",c=r==="READY",l=a?s.target_magnification||0:s.magnification||0,u=[...s.available_magnifications??[]];u.sort((w,x)=>w>x?1:x>w?-1:0);const d=n.disabled||!t.online||!c,p=o.digits||2;function m(w){t.actions?t.actions.call("move",w):console.error("Change request was triggered with:",w)}function g(w,x){const N=l===x?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(i.Dropdown.Item,{disabled:d,onClick:()=>{m(x)},children:[e.jsx("i",{className:N}),"  × ",x]},`id${w}`)}return e.jsxs(e.Fragment,{children:[e.jsx(A,{value:l.toFixed(p),className:P.default({"hw-moving":a})}),e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:!c,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:u.map((w,x)=>g(x,w))})]})]})}function da(n){const{hardware:t,options:o={}}=n,s=t.properties.magnification||0,r=o.digits||2,a=!!o.allowtuning;return e.jsxs(e.Fragment,{children:[e.jsx(A,{value:s.toFixed(r)}),a&&e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{children:"×"}),e.jsx(mt,{...n})]})})]})]})}function mt(n){const{hardware:t,options:o={}}=n,s=t.properties.magnification||0,{state:r}=t.properties,a=r==="READY",c=n.disabled||!t.online||!a,[l,f]=t.properties.magnification_range||[null,null],u=h.useRef(null),d=h.useRef(null),[p,m]=h.useState(!1),g=o.digits||2;function w(b){t.actions?n.mode==="move"?t.actions.call("move",b):t.actions.setProperty("magnification",b):console.error("Change request was triggered with:",b)}function x(b){if(!u||!u.current){console.log("formRef not yet defined");return}if(b.key==="Enter"){m(!1);const{value:_}=u.current,S=Number.parseFloat(_);if(l!==null&&S<l||f!==null&&S>f)return;w(S)}else b.key==="Escape"?(u.current.value=s.toFixed(g),d.current&&(d.current.value=s.toString()),m(!1)):console.log(b.key)}function j(b){b!==s&&!p&&m(!0),b===s&&p&&m(!1)}function N(b){if(!u||!u.current){console.error("formRef is not set");return}const _=Number.parseFloat(u.current.value);j(_),d.current&&(d.current.value=_.toString())}function I(b){if(!u||!u.current){console.error("formRef is not set");return}if(!d||!d.current){console.error("rangeRef is not set");return}const _=Number.parseFloat(d.current.value);j(_),u.current.value=_.toFixed(g)}function M(){if(!d||!d.current){console.error("rangeRef is not set");return}const b=Number.parseFloat(d.current.value);w(b)}return h.useEffect(()=>{if(!u||!u.current){console.error("formRef is not set");return}p||(u.current.value=s.toFixed(g)),d.current&&(d.current.value=s.toString())},[g,p,s]),e.jsxs(e.Fragment,{children:[e.jsx(i.Form.Control,{className:p?"form-control-edited":"",type:"number",ref:u,defaultValue:s.toFixed(g),onChange:N,disabled:c,step:10**-g,onKeyDown:x}),l!==null&&f!==null&&e.jsx(i.Form.Control,{ref:d,disabled:c,type:"range",min:l,max:f,step:10**-g,onChange:I,onMouseUp:M,defaultValue:s})]})}function ua(n){const{hardware:t,options:o={}}=n,{properties:s}=t,r=s.state==="MOVING",a=s.state==="READY",c=r?s.target_magnification||0:s.magnification||0,l=n.options.digits||2;return e.jsxs(e.Fragment,{children:[e.jsx(A,{value:c.toFixed(l),className:P.default({"hw-moving":r})}),e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:!a,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{children:"×"}),e.jsx(mt,{...n,mode:"move"})]})})]})]})}function fa(n){return e.jsx(i.Form.Control,{className:"border-light",type:"text",disabled:!0,defaultValue:"Missing"})}function ht(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Optic",icon:"fam-hardware-optic",online:t.online}),r=e.jsx(Oe,{hardware:t});function a(){function l(){return t.online?t.properties.available_magnifications?la:t.properties.magnification_range?ua:da:fa}const f=l();return e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{className:"border-light",children:"×"}),e.jsx(f,{...n})]})}const c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a(),headerMode:c})}function pa(n){return n.type==="optic"}const ma={default:ht,state:ca},ha=ma,xa=["magnification","reset","open"],ga="optic",ja="optic",wa=!0,ya={state:"READY",magnification:10,target_magnification:null,available_magnifications:[5,7.5,10],magnification_range:null},va="bliss",Na=!1,ba="optic",le={callables:xa,id:ga,name:ja,online:wa,properties:ya,protocol:va,require_staff:Na,type:ba},_a={default:le,fixed:le,off:le,range:le};function $a(n){const{name:t,alias:o,kind:s,useHardwareContext:r}=n;function a(){return s==="fixed"?{available_magnifications:null,magnification_range:null}:s==="range"?{available_magnifications:null,magnification_range:[5,10]}:s==="multi"?{available_magnifications:[5,7.5,10],magnification_range:null}:{available_magnifications:null,magnification_range:null}}const[c,l]=h.useState({state:"READY",magnification:10,target_magnification:null,...a()});async function f(p){let m=c.magnification;l(x=>({...x,state:"MOVING",target_magnification:p})),await R(100);const g=.2*(m<p?1:-1);function w(x){l(j=>({...j,magnification:x}))}for(;Math.abs(p-m)>=Math.abs(g)*1.01;)m+=g,w(m),await R(100);l(x=>({...x,state:"READY",magnification:p,target_magnification:null}))}async function u(p,m){if(p==="move"){await f(m);return}console.log("OpticSimulator: Unsupported call",p,m)}async function d(p,m){if(p==="magnification"){l(g=>({...g,magnifications:m}));return}console.log("OpticSimulator: Unsupported setProperty",p,m)}return e.jsx(U,{name:t,alias:o,type:"optic",call:u,setProperty:d,properties:c,useHardwareContext:r})}function ae(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={STANDBY:"success",DISABLED:"secondary",OFFLINE:"secondary",RUNNING:"warning",ABORTING:"warning",AWAITING_USER_INPUT:"warning",UNKNOWN:"fatal"},r=s[o]||s.UNKNOWN;return e.jsx(F,{state:o,minWidth:6,variant:r})}function Sa(n){const{hardware:t}=n;return e.jsx(ae,{hardware:t})}function Ca(n){const{hardware:t}=n,o=n.disabled||!t.online,s=t.properties.state==="AWAITING_USER_INPUT",r=t.properties.state==="ABORTING",a=t.properties.state==="RUNNING"||s||r;function c(f){t.actions.call("start")}function l(f){t.actions.call("abort")}return e.jsxs(i.ButtonGroup,{size:"lg",className:"w-100",children:[e.jsx(i.Button,{onClick:c,disabled:o||a,variant:"primary",children:"Start"}),e.jsx(i.Button,{onClick:l,disabled:o||!a,variant:"primary",children:"Abort"})]})}function $e(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Procedure",icon:"fa-cog",online:t.online}),r=e.jsx(ae,{hardware:t}),a=e.jsx(i.Container,{children:e.jsx(Ca,{hardware:t,disabled:!n.operator})}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Oa(n){const{hardware:t}=n,o=t.properties.state==="AWAITING_USER_INPUT",s=t.properties.state==="ABORTING",r=t.properties.state==="RUNNING";return s?e.jsxs(i.Badge,{bg:"warning",children:[e.jsx("i",{className:"fa-solid fa-heart-crack fa-beat"})," ABORTING"]}):r?e.jsxs(i.Badge,{bg:"info",children:[e.jsx("i",{className:"fa-solid fa-heart fa-beat"})," RUNNING"]}):o?e.jsxs(i.Badge,{bg:"warning",title:"A user input is expected",children:[e.jsx("i",{className:"fa-solid fa-user fa-beat"})," AWAITING INPUT"]}):e.jsx(Ia,{hardware:t})}function Ia(n){const{hardware:t}=n,{previous_run_state:o,previous_run_exception:s}=t.properties,r={NONE:["secondary",null],ABORTED:["warning","fa-heart-crack"],FAILED:["danger",null],SUCCESSED:["success",null],UNKNOWN:["danger",null]},a=r[o]||r.UNKNOWN,[c,l]=a;return e.jsxs(i.Badge,{bg:c,title:s??void 0,children:[l&&e.jsxs(e.Fragment,{children:[e.jsx("i",{className:`fa-solid ${l}`})," "]}),o]})}function xt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Procedure",icon:"fa-cog",online:t.online}),r=e.jsx(ae,{hardware:t}),a=e.jsx(i.Container,{children:e.jsx("div",{children:e.jsx("h3",{children:e.jsx(Oa,{hardware:t})})})}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Ma(n){const{hardware:t}=n,o=n.disabled||!t.online,s=t.properties.state==="AWAITING_USER_INPUT";function r(a){t.actions.call("validate")}return e.jsx(i.ButtonGroup,{size:"lg",className:"w-100",children:e.jsx(i.Button,{onClick:r,disabled:o||!s,variant:"primary",children:"Validate"})})}function gt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Procedure",icon:"fa-cog",online:t.online}),r=e.jsx(ae,{hardware:t}),a=e.jsx(i.Container,{children:e.jsx(Ma,{hardware:t,disabled:!n.operator})}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const Ta={default:$e,manage:$e,execution:xt,validate:gt,state:Sa},Fa=Ta;function jt(n){return n.type==="procedure"}function Da(n){const t=E(n);return t===null||!jt(t)?null:t}const Aa=["start","abort","clear","validate"],Ra="procedure",Ea="procedure",ka="procedure",Pa="bliss",Ga=!1,Ba=!0,Va={state:"STANDBY",previous_run_state:"NONE",previous_run_exception:null,parameters:{my_number:10,my_string:"foo",my_null:null,my_boolean:!0,my_dict:{a:10,b:"10",c:!0},my_list:[10,"10",!0],"my_scan_1.11":{__type__:"scan",node:"demo_session:tmp:scans:inhouse:id002405:sample:sample_0002:_1_flat images 1",mmh3:3852826388},"my_scan_2.0":{__type__:"scan",key:"esrf:scan:01J1QDB370S2V8WF7FX2Y9H29V",mmh3:3852826389},my_quantity:{__type__:"quantity",scalar:20,unit:"mm"},my_nan:{__type__:"nan"},my_posinf:{__type__:"posinf"},my_neginf:{__type__:"neginf"},my_obj:{__type__:"hardware",name:"roby"}}},La={callables:Aa,type:Ra,id:Ea,name:ka,protocol:Pa,require_staff:Ga,online:Ba,properties:Va},Ua={standby:La};function we(n){const{hardware:t}=n;function o(){if(!t.online)return"OFFLINE";const a=t.properties.state;return n.useReadyState&&(a==="OPEN"||a==="CLOSED")?"READY":a}const s=o();function r(){switch(s){case"READY":return"success";case"OPEN":return"success";case"CLOSED":return"danger";case"DISABLED":return"secondary";case"MOVING":case"STANDBY":case"OFFLINE":return"warning";case"FAULT":return"fatal";default:return"fatal"}}return e.jsx(F,{state:s,minWidth:6,variant:r()})}function Ha(n){const{hardware:t}=n;return e.jsx(we,{hardware:t,useReadyState:!0})}function qa(n){const{hardware:t}=n;function o(){t.actions.call("reset")}return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.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(i.Button,{onClick:o,disabled:n.disabled,children:"Reset"})})]})]}),children:e.jsx(i.Button,{className:"flex-grow-0",title:"Shutter Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function wt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),r=e.jsx(we,{hardware:t});function a(){return t.properties?t.properties.state:"UNKNOWN"}function c(x){return x==="OPEN"?["Close","close"]:x==="CLOSED"?["Open","open"]:x==="DISABLED"||x==="STANDBY"||x==="FAULT"?["Closed",""]:x==="MOVING"?["...",""]:["Unknown",""]}const l=a(),[f,u]=c(l),p={OPEN:"danger",CLOSED:"success",MOVING:"warning",DISABLED:"secondary",STANDBY:"danger",FAULT:"fatal",UNKNOWN:"warning"}[l]||"danger";function m(){t.actions.call(u)}const g=e.jsxs(i.ButtonGroup,{className:"d-flex flex-nowrap",children:[e.jsx(i.Button,{variant:p,onClick:m,disabled:n.disabled||u==="",children:f}),o.extended&&e.jsx(qa,{...n})]}),w=n.options.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:g,headerMode:w})}function za(n){var f;const{hardware:t,options:o={}}=n;function s(){t.actions.call("open")}function r(){t.actions.call("close")}const a=((f=t.properties)==null?void 0:f.state)??"UNKNOWN",c=a==="MOVING",l=a==="DISABLED"||c;return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary",disabled:n.disabled||l}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Actions"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsxs(i.ButtonGroup,{children:[e.jsx(i.Button,{variant:c?"warning":"secondary",onClick:()=>{s()},disabled:n.disabled||l,title:"Open the shutter",children:"Open"}),e.jsx(i.Button,{variant:c?"warning":"secondary",onClick:()=>{r()},disabled:n.disabled||l,title:"Close the shutter",children:"Close"})]})})})]})})]})}function yt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),r=e.jsx(we,{hardware:t,useReadyState:!0});function a(){return t.properties?t.properties.state:"UNKNOWN"}function c(x){return x==="OPEN"||x==="CLOSED"?x:x==="DISABLED"||x==="STANDBY"||x==="FAULT"?"CLOSED":x==="MOVING"?"...":"UNKNOWN"}function l(x){return x.charAt(0).toUpperCase()+x.slice(1).toLowerCase()}const f=a(),u=c(f),p={OPEN:"success",CLOSED:"danger",MOVING:"warning",DISABLED:"secondary",STANDBY:"success",FAULT:"fatal",UNKNOWN:"fatal"}[f],m=l(u),g=e.jsxs(i.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(A,{variant:p,className:"text-center",style:{minWidth:"10em"},value:m}),e.jsx(za,{...n})]}),w=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:g,headerMode:w})}const Wa={default:wt,protected:yt,state:Ha},Ya=Wa,Ka=["reset","open","close","toggle"],Qa="abs1",Xa="abs1",Ja=!0,Za={closed_text:"",open_text:"",state:"OPEN",status:`Pneumatic Beam Shutter is open
29
+ `,valid:!0},ec="tango",tc=!0,nc="shutter",oc={callables:Ka,id:Qa,name:Xa,online:Ja,properties:Za,protocol:ec,require_staff:tc,type:nc},sc={default:oc};function rc(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("OPEN");async function c(u,d){if(u==="open"){a("MOVING"),await R(2e3),a("OPEN");return}if(u==="close"){a("MOVING"),await R(2e3),a("CLOSED");return}console.log("ShutterSimulator: Unsupported call",u,d)}async function l(u,d){console.log("ShutterSimulator: Unsupported setProperty",u,d)}const f={state:r,closed_text:"",open_text:"",status:`Shutter is ${r}`,valid:!0};return e.jsx(U,{name:t,alias:o,type:"shutter",call:c,setProperty:l,properties:f,useHardwareContext:s})}function ic(n){var d,p,m,g;const{properties:t}=n,o=(d=t.vgap)==null?void 0:d.slice(9),s=k(o),r=(p=t.hgap)==null?void 0:p.slice(9),a=k(r),c=(m=t.voffset)==null?void 0:m.slice(9),l=k(c),f=(g=t.hoffset)==null?void 0:g.slice(9),u=k(f);return h.useMemo(()=>{var w,x,j,N;return{vgap:((w=s==null?void 0:s.properties)==null?void 0:w.state)??null,hgap:((x=a==null?void 0:a.properties)==null?void 0:x.state)??null,voffset:((j=l==null?void 0:l.properties)==null?void 0:j.state)??null,hoffset:((N=u==null?void 0:u.properties)==null?void 0:N.state)??null}},[s,a,l,u])}function Ie(n){const{hardware:t}=n,o=ic(t),[s,r,a]=h.useMemo(()=>{if(!t.online)return["OFFLINE","secondary","No motor online"];if(o.vgap===null&&o.hgap===null&&o.voffset===null&&o.hoffset===null)return["OFFLINE","secondary","No motor online"];const c=new Set([...o.vgap??[],...o.hgap??[],...o.voffset??[],...o.hoffset??[]]);return c.has("MOVING")?["MOVING","warning","A motor is moving"]:c.has("OFF")?["OFF","secondary","A motor is off"]:["READY","success","The slit is ready"]},[t.online,o]);return e.jsx(F,{state:s,description:a,variant:r,minWidth:6})}function ac(n){const{hardware:t}=n;return e.jsx(Ie,{hardware:t})}function cc(n){var x,j,N,I;const{properties:t}=n,o=(x=t.vgap)==null?void 0:x.slice(9),s=k(o),r=te(o),a=(j=t.hgap)==null?void 0:j.slice(9),c=k(a),l=te(a),f=(N=t.voffset)==null?void 0:N.slice(9),u=k(f),d=te(f),p=(I=t.hoffset)==null?void 0:I.slice(9),m=k(p),g=te(p);function w(M,b){return M===null?null:{...M,actions:b}}return{vgap:w(s,r),hgap:w(c,l),voffset:w(u,d),hoffset:w(m,g)}}function lc(n){const{hardware:t,schema:o,operator:s,disabled:r,resolved:a}=n;return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary"}),e.jsx(i.Dropdown.Menu,{align:"end",popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsxs(i.Row,{className:"flex-nowrap",children:[e.jsx(i.Col,{sm:1,className:"d-flex",children:e.jsx("i",{className:"fa fa-fw fa-square",title:"Gap",style:{alignSelf:"center"}})}),e.jsx(i.Col,{sm:5,children:a.hgap&&e.jsx(Q,{hardware:a.hgap,options:{header:"none"},schema:o,disabled:r,operator:s})}),e.jsx(i.Col,{sm:1,className:"d-flex",children:e.jsx("span",{style:{alignSelf:"center"},children:"×"})}),e.jsx(i.Col,{sm:5,children:a.vgap&&e.jsx(Q,{hardware:a.vgap,options:{header:"none"},schema:o,disabled:r,operator:s})})]}),e.jsxs(i.Row,{className:"flex-nowrap",children:[e.jsx(i.Col,{sm:1,className:"d-flex",children:e.jsx("i",{className:"fa fa-fw fa-arrows-up-down-left-right ",title:"Offset",style:{alignSelf:"center"}})}),e.jsx(i.Col,{sm:5,children:a.hoffset&&e.jsx(Q,{hardware:a.hoffset,options:{header:"none"},schema:o,disabled:r,operator:s})}),e.jsx(i.Col,{sm:1,className:"d-flex",children:e.jsx("span",{style:{alignSelf:"center"},children:";"})}),e.jsx(i.Col,{sm:5,children:a.voffset&&e.jsx(Q,{hardware:a.voffset,options:{header:"none"},schema:o,disabled:r,operator:s})})]})]})})]})}function dc(n){const{hardware:t,options:o={}}=n,s=cc(t),{readonly:r=!1}=o;function a(m){var x,j;const g=((x=m==null?void 0:m.properties)==null?void 0:x.position)??null;if(g===null)return"∅";const w=o.precision??((j=m==null?void 0:m.properties)==null?void 0:j.display_digits)??void 0;return w!==void 0?g.toFixed(w):`${g}`}const[c,l,f,u,d,p]=h.useMemo(()=>{var b,_,S,C,G,B,$,q;const m=`${a(s.hgap)} × ${a(s.vgap)}`,g=((b=s.hgap)==null?void 0:b.properties.unit)??((_=s.vgap)==null?void 0:_.properties.unit)??"?",x=new Set([...((S=s.hgap)==null?void 0:S.properties.state)??[],...((C=s.vgap)==null?void 0:C.properties.state)??[]]).has("MOVING"),j=`${a(s.hoffset)} ; ${a(s.voffset)}`,N=((G=s.hoffset)==null?void 0:G.properties.unit)??((B=s.voffset)==null?void 0:B.properties.unit)??"?",M=new Set([...(($=s.hoffset)==null?void 0:$.properties.state)??[],...((q=s.voffset)==null?void 0:q.properties.state)??[]]).has("MOVING");return[m,g,x,j,N,M]},[s.hgap,s.hoffset,s.vgap,s.voffset]);return e.jsxs(i.InputGroup,{className:"w-100 flex-nowrap",children:[e.jsx(i.InputGroup.Text,{title:"Gap (horizontal and vertical)",children:e.jsx("i",{className:"fa fa-fw fa-square fa-2x"})}),e.jsx(A,{value:c,title:"Gap",className:P.default({"hw-moving":f})}),e.jsx(i.InputGroup.Text,{children:l}),e.jsx(i.InputGroup.Text,{title:"Offset (horizontal and vertical)",children:e.jsx("i",{className:"fa fa-fw fa-arrows-up-down-left-right fa-2x"})}),e.jsx(A,{value:u,title:"Offset",className:P.default({"hw-moving":p})}),e.jsx(i.InputGroup.Text,{children:d}),!r&&e.jsx(lc,{...n,resolved:s})]})}function vt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Slit",icon:"fam-hardware-motor",online:t.online}),r=e.jsx(Ie,{hardware:t}),a=e.jsx(dc,{...n}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const uc={default:vt,state:ac},fc=uc,pc="s1",mc="s1",hc=!0,xc={vgap:"hardware:s1vg",voffset:"hardware:s1vo",hgap:"hardware:s1hg",hoffset:"hardware:s1ho"},gc="slit",jc={id:pc,name:mc,online:hc,properties:xc,type:gc},wc="s1",yc="s1",vc=!0,Nc={vgap:"hardware:",voffset:"hardware:",hgap:"hardware:s1hg",hoffset:"hardware:s1ho"},bc="slit",_c={id:wc,name:yc,online:vc,properties:Nc,type:bc},$c="s1",Sc="s1",Cc=!0,Oc={vgap:"hardware:s1vg",voffset:"hardware:s1vo",hgap:"hardware:",hoffset:"hardware:"},Ic="slit",Mc={id:$c,name:Sc,online:Cc,properties:Oc,type:Ic},Tc={default:jc,horizontal:_c,vertical:Mc};function Fc(n){const{hardware:t}=n,o=()=>{t.actions.call(t.properties.state==="ON"?"off":"on")},s={Voltage:`${t.properties.voltage.toFixed(0)} V`,Current:`${(t.properties.current*1e3).toFixed(2)} mA`};return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("h6",{children:"Properties"}),e.jsx(i.Container,{children:D.map(s,(r,a)=>e.jsxs(i.Row,{children:[e.jsxs(i.Col,{children:[a,":"]}),e.jsx(i.Col,{children:r})]},a))}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(i.Button,{disabled:n.disabled,onClick:o,variant:t.properties.state==="ON"?"danger":"success",children:t.properties.state==="ON"?"Off":"On"})})]})]}),children:e.jsx(i.Button,{title:"Pump Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Nt(n){const{hardware:t,options:o={}}=n;return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(y,{name:"Pump",icon:"fam-hardware-pump",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(i.Badge,{bg:t.properties.state==="ON"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(i.InputGroup,{children:[e.jsx(i.Form.Control,{value:t.properties.pressure.toExponential(o.precision||3),disabled:!0}),(t.properties.unit||o.unit)&&e.jsx(i.InputGroup.Text,{children:t.properties.unit||o.unit}),e.jsx(Fc,{...n})]})})]})}const Dc={default:Nt},Ac=Dc,Rc=["off","on"],Ec="ip121",kc="ip121",Pc=!0,Gc={current:.0003000000142492354,pressure:26000000730164174e-23,state:"ON",status:`Pump is ON
30
30
  Modes: Step/Protect
31
31
  ID21/v-var-ctrl/121 - Serial line OK
32
32
  Pump size: 75-55-40 SC/T
33
- `,voltage:6998},dc="tango",uc=!0,fc="pump",pc={callables:rc,id:ac,name:ic,online:cc,properties:lc,protocol:dc,require_staff:uc,type:fc},mc={default:pc};function Ie(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={RETRACTED:"success",IN_TOUCH:"warning",MOVING_IN:"warning",MOVING_OUT:"warning",UNKNOWN:"danger",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(M,{state:o,minWidth:6,variant:r})}function hc(n){const{hardware:t}=n;return e.jsx(Ie,{hardware:t})}function xc(n){const{className:t,hardware:o,options:s={}}=n,{state:r}=o.properties??"OFFLINE",c=!(r==="IN_TOUCH")||n.disabled;function l(f){const{distance:u}=f,[d,p]=h.useState(!1);return e.jsx(a.Button,{variant:"secondary",onClick:()=>{p(!0),o.actions.call("push",u).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"})," ",u]})})}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 gc(n){const{hardware:t,options:o,disabled:s}=n,{state:r}=t.properties??"OFFLINE",i=r==="RETRACTED",c=r==="IN_TOUCH",[l,f]=h.useState(!1),[u,d]=h.useState(!1),p=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?"fas fa-dizzy":"fa fa-smile"} fa-3x my-auto`}),e.jsx(xc,{className:p,...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||l||u,style:{width:"5em"},children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx("i",{className:l?"fa-solid fa-fw fa-cog fa-spin":"fa fa-fw fa-arrow-left"})," ","In"]})}),e.jsx(a.Button,{onClick:()=>{d(!0),t.actions.call("move_out").finally(()=>{d(!1)})},disabled:i||s||l||u,style:{width:"5em"},children:e.jsxs("span",{className:"text-nowrap",children:["Out"," ",e.jsx("i",{className:u?"fa-solid fa-fw fa-cog fa-spin":"fa fa-fw fa-arrow-right"})]})})]})]})}function jt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Pusher",icon:"fa-hand-point-right",online:t.online}),r=e.jsx(Ie,{hardware:t});function i(){return e.jsx(gc,{...n})}const c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i(),headerMode:c})}const jc={default:jt,state:hc},wc=jc,vc=["move_in","move_out","push","sync_hard"],yc="pusher",Nc="pusher",bc=!0,_c={state:"RETRACTED"},$c="bliss",Sc=!1,Oc="pusher",Cc={callables:vc,id:yc,name:Nc,online:bc,properties:_c,protocol:$c,require_staff:Sc,type:Oc},Ic={default:Cc};function Mc(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,i]=h.useState("RETRACTED");async function c(u,d){if(u==="move_in"){i("MOVING_IN"),await D(2e3),i("IN_TOUCH");return}if(u==="move_out"){i("MOVING_OUT"),await D(2e3),i("RETRACTED");return}if(u==="push"){await D(100);return}console.log("PusherSimulator: Unsupported call",u,d)}async function l(u,d){console.log("PusherSimulator: Unsupported setProperty",u,d)}const f={state:r};return e.jsx(V,{name:t,alias:o,type:"pusher",call:c,setProperty:l,properties:f,useHardwareContext:s})}function je(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={STOPPED:"danger",STARTING:"warning",RUNNING:"success",BACKOFF:"warning",STOPPING:"warning",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"fatal",OFFLINE:"secondary"},r=s[o]||s.UNKNOWN;return e.jsx(M,{state:o,minWidth:6,variant:r})}function Tc(n){const{hardware:t}=n;return e.jsx(je,{hardware:t})}function wt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Shutter",icon:"fa-cog",online:t.online}),r=e.jsx(je,{hardware:t});function i(){t.actions.call("start")}function c(){t.actions.call("restart")}function l(){t.actions.call("stop")}function f(){return t.properties?t.properties.state:"UNKNOWN"}function u(y){return y.charAt(0).toUpperCase()+y.slice(1).toLowerCase()}const d=f(),p=u(d),x={STOPPED:"danger",STARTING:"warning",RUNNING:"success",BACKOFF:"warning",STOPPING:"warning",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"secondary",OFFLINE:"secondary"}[d]||"danger";function j(){const y=d==="RUNNING"||d==="STARTING";return{icon:y?"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?y?"Restart the service":"Start the serStaticTextInputvice":"You dont have the control to the session"}}function g(){const y=d==="RUNNING"||d==="STARTING";return{icon:"fa fa-stop fa-wp",variant:n.disabled?"":y?"danger":"secondary",callback:l,disabled:n.disabled,title:n.operator?"Stop the service":"You dont have the control to the session"}}const b=j(),S=g(),E=e.jsxs(a.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(k,{variant:x,className:"text-center",style:{minWidth:"8em"},value:p}),e.jsx(a.Button,{style:{width:"2.5em"},variant:"light",className:`px-0 text-${b.variant}`,onClick:b.callback,disabled:b.disabled,title:b.title,children:e.jsx("i",{className:`${b.icon}`})}),e.jsx(a.Button,{style:{width:"2.5em"},variant:"light",className:`px-0 text-${S.variant}`,onClick:S.callback,disabled:S.disabled,title:S.title,children:e.jsx("i",{className:`${S.icon}`})})]}),T=n.options.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:E,headerMode:T})}function Fc(n){var f;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=((f=t.properties)==null?void 0:f.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 vt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Shutter",icon:"fa-cog",online:t.online}),r=e.jsx(je,{hardware:t});function i(){return t.properties?t.properties.state:"UNKNOWN"}function c(x){return x.charAt(0).toUpperCase()+x.slice(1).toLowerCase()}const l=i(),u={STOPPED:"danger",STARTING:"warning",RUNNING:"success",BACKOFF:"warning",STOPPING:"warning",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(k,{variant:u,style:{minWidth:"10em"},value:d,className:"text-center"}),e.jsx(Fc,{...n})]}),m=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:p,headerMode:m})}const Dc={default:wt,protected:vt,state:Tc},Ec=Dc,Rc=["start","stop","restart"],Ac="service1",kc="service1",Pc=!0,Gc={state:"RUNNING"},Bc="multivisor",Vc=!0,Lc="service",Uc={callables:Rc,id:Ac,name:kc,online:Pc,properties:Gc,protocol:Bc,require_staff:Vc,type:Lc},Hc={default:Uc};function we(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={UNKNOWN:"danger",READY:"success"},r=s[o]||s.UNKNOWN;return e.jsx(M,{state:o,minWidth:6,variant:r})}function qc(n){const{hardware:t}=n;return e.jsx(we,{hardware:t})}function zc(n){const{motion:t}=n,s=t.axisRef.slice(9),r=R(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 Wc(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 Yc(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=R(c),f=(l==null?void 0:l.alias)??(l==null?void 0:l.name)??(l==null?void 0:l.id)??c;function u(){o.call("update_axis",{axis_ref:s,relative_position:0})}return e.jsx(a.Button,{className:"ms-1",variant:i?"primary":"secondary",onClick:()=>{i||u()},title:i?"This axis is already part of the motion":"Use this axis in the motion",disabled:r,children:f})}function Kc(n){var g;const{motion:t,actions:o}=n,s=t.axisRef,r=t.absolute_position??t.relative_position??0,i=s.slice(9),c=R(i),l=n.disabled||!(c!=null&&c.online),f=h.useRef(null),[u,d]=h.useState(!1),p=3,m=((g=c==null?void 0:c.properties)==null?void 0:g.unit)??"";function x(b){if(!f||!f.current)console.log("formRef not yet defined");else if(b.key==="Enter"){d(!1);const S=Number.parseFloat(f.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 b.key==="Escape"?(f.current.value=r.toFixed(p),d(!1)):console.log(b.key)}function j(b){const{value:S}=b.target;if(S===void 0)return;const E=Number.parseFloat(S);E!==r&&!u&&d(!0),E===r&&u&&d(!1)}return h.useEffect(()=>{!f||!f.current?console.log("formRef not yet defined"):u||(f.current.value=r.toFixed(p))},[u,r]),e.jsxs(a.InputGroup,{className:"w-100",children:[e.jsx(a.Form.Control,{className:u?"form-control-edited":"",type:"number",ref:f,defaultValue:r.toFixed(p),onChange:j,disabled:l,onKeyDown:x}),e.jsx(a.InputGroup.Text,{children:m})]})}function Qc(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 yt(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r}=t,i=e.jsx(w,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),c=e.jsx(we,{hardware:t}),l=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(u=>e.jsx(Yc,{axisRef:u,motion:r.motion,actions:t.actions,disabled:s},u))})]}),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((u,d)=>e.jsxs(h.Fragment,{children:[e.jsx(zc,{motion:u}),e.jsx(Qc,{motion:u,actions:t.actions,disabled:s}),e.jsx(Kc,{motion:u,actions:t.actions,disabled:s}),e.jsx(Wc,{motion:u,actions:t.actions,disabled:s})]},`motion${d}`))]})})]})]}),f=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:i,widgetState:c,widgetContent:l,headerMode:f})}function Xc(n){var y;const{motion:t,actions:o}=n,s=t.axisRef,r=t.absolute_position??t.relative_position??0,i=s.slice(9),c=R(i),l=n.disabled||!(c!=null&&c.online),f=h.useRef(null),[u,d]=h.useState(!1),p=3,m=((y=c==null?void 0:c.properties)==null?void 0:y.unit)??"",x=(c==null?void 0:c.alias)??(c==null?void 0:c.name)??(c==null?void 0:c.id)??"none";function j(N){if(!f||!f.current)console.log("formRef not yet defined");else if(N.key==="Enter"){d(!1);const $=Number.parseFloat(f.current.value);o.call("update_axis",{axis_ref:s,absolute_position:t.absolute_position!==null?$:null,relative_position:t.relative_position!==null?$:null})}else N.key==="Escape"?(f.current.value=r.toFixed(p),d(!1)):console.log(N.key)}function g(N){const{value:$}=N.target;if($===void 0)return;const I=Number.parseFloat($);I!==r&&!u&&d(!0),I===r&&u&&d(!1)}h.useEffect(()=>{!f||!f.current?console.log("formRef not yet defined"):u||(f.current.value=r.toFixed(p))},[u,r]);function b(){return t.absolute_position!==null?["ABS","warning","Absolute displacement"]:t.relative_position!==null?["REL","none","Relative displacement"]:["ERR","danger","Unknown motion kind"]}const[S,E,T]=b();return e.jsxs(a.InputGroup,{className:"w-100",children:[e.jsx(a.InputGroup.Text,{title:"Displacement to apply on this axis to take a flat",style:{width:"5em"},children:x}),e.jsx(a.InputGroup.Text,{className:`bg-${E}`,title:T,style:{width:"3em"},children:S}),e.jsx(a.Form.Control,{className:u?"form-control-edited":"",type:"number",ref:f,defaultValue:r.toFixed(p),onChange:g,disabled:l,onKeyDown:j}),e.jsx(a.InputGroup.Text,{children:m})]})}function Nt(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r}=t,i=e.jsx(w,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),c=e.jsx(we,{hardware:t}),l=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((u,d)=>e.jsx(Xc,{actions:t.actions,motion:u,disabled:s},u.axisRef))})]}),f=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:i,widgetState:c,widgetContent:l,headerMode:f})}const Jc={default:yt,small:Nt,state:qc},Zc=Jc;function bt(n){return n.type==="tomoflatmotion"}function el(n){const t=P(n);return t===null||!bt(t)?null:t}const tl="tomoflatmotion",nl="tomoflatmotion",ol=!0,sl={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}]},rl="bliss",al=!1,il="tomoflatmotion",cl={id:tl,name:nl,online:ol,properties:sl,protocol:rl,require_staff:al,type:il},ll=["move","stop","wait","rmove"],dl="sy",ul="sy",fl=!0,pl={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},ml="bliss",hl=!1,xl="motor",gl=[],jl={callables:ll,id:dl,name:ul,online:fl,properties:pl,protocol:ml,require_staff:hl,type:xl,user_tags:gl},wl=["move","stop","wait","rmove"],vl="sy2",yl="sy2",Nl=!0,bl={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},_l="bliss",$l=!1,Sl="motor",Ol=[],Cl={callables:wl,id:vl,name:yl,online:Nl,properties:bl,protocol:_l,require_staff:$l,type:Sl,user_tags:Ol},Il={default:cl,sy:jl,sy2:Cl};function Ml(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(u,d){const p=[];let m=!1;return u.motion.forEach(x=>{if(x.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(x)}),m||p.push({axisRef:d.axis_ref,relative_position:d.relative_position??null,absolute_position:d.absolute_position??null}),{...u,motion:p}}async function l(u,d){if(u==="update_axis"){i(p=>c(p,d));return}console.log("TomoFlatMotionSimulator: Unsupported call",u,d)}async function f(u,d){console.log("TomoFlatMotionSimulator: Unsupported setProperty",u,d)}return e.jsx(V,{name:t,alias:o,type:"tomoflatmotion",call:l,setProperty:f,properties:r,useHardwareContext:s})}function _t(n){const{hardware:t,options:o={},disabled:s}=n,{actions:r}=t,i=e.jsx(w,{name:"TomoReferencePositionSchema",icon:"fam-hardware-motor",online:t.online});function c(){r.call("move_to_reference")}const l=e.jsx(e.Fragment,{}),f=e.jsx(a.Button,{className:"w-100",onClick:()=>{c()},disabled:s,children:"Back to parking position"}),u=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:i,widgetState:l,widgetContent:f,headerMode:u})}function Tl(n){return n.type==="tomoreferenceposition"}const Fl={default:_t},Dl=Fl;function ve(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:"warning",UNMOUNTING:"warning",LOCKED:"warning"},c=i[r]||i.UNKNOWN;return e.jsx(M,{state:r,minWidth:6,variant:c})}function El(n){const{hardware:t}=n;return e.jsx(ve,{hardware:t})}function Rl(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 Al(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(ee,{hardwareValue:s,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:i,hardwareIsMoving:!1,readOnly:t.properties.sample_pixel_size_mode!=="USER"})}function kl(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,{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(Rl,{...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(Al,{...n}),e.jsx(a.InputGroup.Text,{children:"um"})]})})})]})})]})}function Pl(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=cn.default(n,t);return[r(i.to(o).scalar),s(o)]},[n,t,o])}function $t(n){const{hardware:t,options:o={}}=n,s=o.display_unit??"um",r=e.jsx(w,{name:"TomoDetector",icon:"fa-cog",online:t.online}),i=e.jsx(ve,{hardware:t}),[c,l]=Pl(t.properties.sample_pixel_size,"um",s),f=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(k,{value:c,title:`${t.properties.sample_pixel_size} um`}),e.jsx(a.InputGroup.Text,{children:l}),e.jsx(kl,{...n})]}),u=n.options?n.options.header:"top";return e.jsx(v,{hardware:t,widgetIcon:r,widgetState:i,widgetContent:f,headerMode:u})}function Gl(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 Bl(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(ee,{hardwareValue:s,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:i,hardwareIsMoving:!1,readOnly:t.properties.state!=="READY"})}function Vl(n){const t=P(n);return t!==null&&he(t)?t:null}function Ll(n){const{hardware:t}=n,{properties:o}=t,s=o.detector.slice(9),r=Vl(s),i=J(s);return e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{disabled:n.disabled,variant:"secondary"}),e.jsx(a.Dropdown.Menu,{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(Gl,{...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(Bl,{hardware:r,actions:i}),e.jsx(a.InputGroup.Text,{children:"um"})]})})})]})})]})}function St(n){const{hardware:t}=n,o=e.jsx(w,{name:"TomoDetector",icon:"fa-cog",online:t.online}),s=e.jsx(ve,{hardware:t}),r=e.jsxs(a.InputGroup,{className:"flex-nowrap",children:[e.jsx(k,{value:t.properties.acq_mode}),e.jsx(Ll,{...n})]}),i=n.options?n.options.header:"top";return e.jsx(v,{hardware:t,widgetIcon:o,widgetState:s,widgetContent:r,headerMode:i})}const Ul={samplepixelsize:$t,acquisitionmode:St,state:El},Hl=Ul;function Me(n){return n.type==="tomodetector"}function ql(n){const t=P(n);return t===null||!Me(t)?null:t}const zl="tomodetector",Wl="tomodetector",Yl=!0,Kl={state:"READY",actual_size:[1024,1024],sample_pixel_size_mode:"AUTO",user_sample_pixel_size:50,sample_pixel_size:48},Ql="bliss",Xl=!1,Jl="tomodetector",Zl={id:zl,name:Wl,online:Yl,properties:Kl,protocol:Ql,require_staff:Xl,type:Jl},ed={default:Zl};function Te(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOUNTING:"warning",UNMOUNTING:"warning",UNKNOWN:"fatal",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(M,{state:o,minWidth:6,variant:r})}function td(n){const{hardware:t}=n;return e.jsx(Te,{hardware:t})}function Z(n){return!n||!n.startsWith("hardware:")?null:n.slice(9)}function nd(n){const{hardware:t}=n,{properties:o}=t,{detectors:s}=o,r=Z(o.active_detector),i=Z(o.target_detector),c=o.state==="READY",l=n.disabled||!t.online||!c;function f(d){t.actions?t.actions.call("mount",d):console.error("Change request was triggered with:",d)}function u(d){const p=Z(d),x=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:()=>{f(p)},children:[e.jsx("i",{className:x}),"  ",p]},d)}return e.jsxs(a.Dropdown,{children:[e.jsx(a.Dropdown.Toggle,{disabled:l,variant:"secondary"}),e.jsx(a.Dropdown.Menu,{children:s.map(d=>u(d))})]})}function Ot(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"Optic",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Te,{hardware:t}),{properties:i}=t,c=i.state==="MOUNTING",l=Z(i.active_detector),f=Z(i.target_detector);function u(){return e.jsxs(a.InputGroup,{children:[e.jsx(k,{className:A.default({"hw-moving":c}),value:f||l||"No detector"}),e.jsx(nd,{...n})]})}const d=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:u(),headerMode:d})}const od={default:Ot,state:td},sd=od;function Ct(n){return n.type==="tomodetectors"}function rd(n){const t=P(n);return t===null||!Ct(t)?null:t}const ad="tomodetectors",id="tomodetectors",cd=!0,ld={state:"READY",active_detector:"hardware:limadetector1",detectors:["hardware:limadetector1","hardware:limadetector2","hardware:limadetector3"]},dd="bliss",ud=!1,fd="optic",pd={id:ad,name:id,online:cd,properties:ld,protocol:dd,require_staff:ud,type:fd},md={default:pd};function Y(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",BLOCKED:"secondary",ACQUIRING:"warning",UNKNOWN:"fatal"},r=s[o]||s.UNKNOWN;return e.jsx(M,{state:o,minWidth:6,variant:r})}function hd(n){const{hardware:t}=n;return e.jsx(Y,{hardware:t})}function xd(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 gd(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 f(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 u(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:u,disabled:s,onKeyDown:f}),e.jsx(a.InputGroup.Text,{children:"s"})]})}function jd(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 It(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Y,{hardware:t}),i=e.jsxs(a.Container,{children:[e.jsx(a.Row,{className:"mt-1",children:e.jsx(a.Col,{children:e.jsx(xd,{hardware:t,disabled:n.disabled})})}),e.jsx(a.Row,{className:"mt-1",children:e.jsx(a.Col,{children:e.jsx(gd,{hardware:t,disabled:n.disabled})})}),e.jsx(a.Row,{className:"mt-1",children:e.jsx(a.Col,{children:e.jsx(jd,{hardware:t,disabled:n.disabled})})})]}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function wd(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 f(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 u(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:u,disabled:s,onKeyDown:f}),e.jsx(a.InputGroup.Text,{children:"s"})]})}function vd(n){const{exposureTime:t}=n,o=P("ACTIVE_TOMOCONFIG.ref.detectors.active_detector.detector"),s=P("ACTIVE_TOMOCONFIG.ref.detectors.active_detector");if(o===null||s===null)return e.jsx(e.Fragment,{});if(!he(o)||!Me(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]=rt(t,r);return e.jsxs("div",{className:"text-center",title:"Decompisiton of the accumulation",children:[c," × ",l.toFixed(3)]})}function Mt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Y,{hardware:t}),i=e.jsxs(e.Fragment,{children:[e.jsx(wd,{hardware:t,disabled:n.disabled}),e.jsx(vd,{exposureTime:t.properties.exposure_time})]}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function yd(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 f(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 u(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:u,disabled:s,onKeyDown:f}),e.jsx(a.InputGroup.Text,{children:"s"})]})}function Tt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Y,{hardware:t}),i=e.jsx(yd,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function ye(n){const{text:t,processing:o,disabled:s,onClick:r,title:i}=n;return e.jsxs(a.Button,{onClick:r,disabled:s,variant:"primary",className:A.default({"ps-4":!o,"pe-4":!o}),title:i,children:[o&&e.jsx("i",{className:"fa-solid fa-cog fa-spin me-1"}),t]})}function Nd(n){const{hardware:t}=n,[o,s]=h.useState(!1),[r,i]=h.useState(!1),[c,l]=h.useState(!1),f=n.disabled||!t.online||o||r||c;function u(m){l(!0),t.actions.call("take_proj").finally(()=>{l(!1)})}function d(m){s(!0),t.actions.call("take_dark").finally(()=>{s(!1)})}function p(m){i(!0),t.actions.call("take_flat").finally(()=>{i(!1)})}return e.jsxs(a.ButtonGroup,{size:"lg",className:"w-100",children:[e.jsx(ye,{onClick:u,disabled:f,processing:c,text:"Proj",title:"Take a projection"}),e.jsx(ye,{onClick:p,disabled:f,processing:r,text:"Flat",title:"Take a flat"}),e.jsx(ye,{onClick:d,disabled:f,processing:o,text:"Dark",title:"Take a dark"})]})}function Ft(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Y,{hardware:t}),i=e.jsx(Nd,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}function bd(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 Dt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Y,{hardware:t}),i=e.jsx(bd,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}const _d={default:It,exposuretime:Mt,settletime:Tt,actions:Ft,updatemode:Dt,state:hd},$d=_d,Sd="tomoimaging",Od="tomoimaging",Cd=!0,Id={state:"READY",update_on_move:!1,exposure_time:1},Md="bliss",Td=!1,Fd="optic",Dd={id:Sd,name:Od,online:Cd,properties:Id,protocol:Md,require_staff:Td,type:Fd},Ed={default:Dd};function Rd(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(u){i(d=>({...d,state:u}))}async function l(u,d){if(u==="take_dark"){c("ACQUIRING"),await D(2e3),c("READY");return}if(u==="take_flat"){c("ACQUIRING"),await D(2e3),c("READY");return}if(u==="take_proj"){c("ACQUIRING"),await D(2e3),c("READY");return}console.log("TomoImagingSimulator: Unsupported call",u,d)}async function f(u,d){i(p=>({...p,[u]:d}))}return e.jsx(V,{name:t,alias:o,type:"tomoimaging",call:l,setProperty:f,properties:r,useHardwareContext:s})}const Ad={},kd=Ad;function Et(n){return n.type==="tomosamplestage"}function Pd(n){const t=P(n);return t===null||!Et(t)?null:t}function Gd(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 f(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 u(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:u,disabled:s,onKeyDown:f}),e.jsx(a.InputGroup.Text,{children:"s"})]})}function Rt(n){const{hardware:t,options:o={}}=n,s=e.jsx(w,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(e.Fragment,{}),i=e.jsx(Gd,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:i,headerMode:c})}const Bd={latencytime:Rt},Vd=Bd;function At(n){return n.type==="tomoconfig"}function Ld(n){const t=P(n);return t===null||!At(t)?null:t}function kt(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOVING:"warning",STABILIZING:"warning",INVALID:"danger",INVALID_DETECTOR_BINNING_CHANGED:"danger",INVALID_DETECTOR_DISTANCE_CHANGED:"danger",INVALID_DETECTOR_CHANGED:"danger"},r=s[o]||s.UNKNOWN;return e.jsx(M,{state:o,minWidth:6,variant:r})}function Ud(n){const{hardware:t}=n;return e.jsx(kt,{hardware:t})}const Hd={state:Ud},qd=Hd;function Pt(n){return n.type==="tomoholo"}function zd(n){const t=P(n);return t===null||!Pt(t)?null:t}function Wd(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 Gt(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(w,{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(Wd,{...n})]})})]})}const Yd={default:Gt},Kd=Yd,Qd=["close","reset","open"],Xd="rv12",Jd="rv12",Zd=!0,eu={state:"CLOSED",status:`Pneumatic is closed
34
- `},tu="tango",nu=!1,ou="valve",su={callables:Qd,id:Xd,name:Jd,online:Zd,properties:eu,protocol:tu,require_staff:nu,type:ou},ru={default:su},au=$e.default("daiquiri.components.hardware.NoObject");function iu(n){if(n.options.emptyifnone)return au('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const t=e.jsx(w,{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 cu(n){const t=e.jsx(w,{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 lu=$e.default("daiquiri.components.hardware.MissingObject");function du(n){if(n.options.emptyifnone)return lu('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const t=e.jsx(w,{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 uu(n){const{properties:t={}}=n,{message:o="Unknown error"}=t,s=e.jsx(w,{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 fu=$e.default("daiquiri.components.hardware.MissingComponentObject");function pu(n){const{options:t}=n,{variant:o="default"}=t;if(t.emptyifnone)return fu('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const s=e.jsx(w,{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 mu(n){if(n.options.emptyifnone)return e.jsx(e.Fragment,{});const t=e.jsx(w,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),s=e.jsx(e.Fragment,{}),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 Bt(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 hu(n){return e.jsx("div",{className:"panel-header",style:n.style,children:n.children})}function xu(n){return e.jsx("div",{className:`panel-contents ${n.className}`,style:n.style,children:n.children})}function O(n){const t=n.scroll?Bt:h.Fragment;return e.jsx("div",{className:`panel ${n.className??""}`,style:n.style,children:e.jsx(t,{children:n.children})})}O.Header=hu;O.Contents=xu;const le={};function Vt(n,t){le[n]=t}function G(n,t,o=!0){if(!n)return e.jsx(e.Fragment,{});const{type:s}=n,r=s&&s in le?le[s]:le.component;return e.jsx(r,{yamlNode:n,panel:o},t)}function gu({children:n,key:t,panel:o,options:s}){return o?e.jsx(O,{style:s.style,scroll:s.scroll,children:e.jsx(O.Contents,{children:n})},t):e.jsx(e.Fragment,{children:h.Children.map(n,r=>h.isValidElement(r)?h.cloneElement(r,{key:t,...r.props}):void 0)})}function Lt(n,t){const{_parentNode:o,_indexFromParent:s,...r}=t;if(n&&Object.keys(r).length>0)throw new de(n,Object.keys(r))}class W extends Error{constructor(t,o){super(t),this.yamlNode=o}}class de extends W{constructor(t,o){super(`Unexpected keys: ${o.join(", ")}`,t),this.keys=o}}class te extends W{constructor(t,o){super(`Keys ${o.join(", ")} are missing`,t),this.keys=o}}class C extends W{constructor(t,o,s){super(`Key ${o} error: ${s}`,t),this.key=o,this.keyMessage=s}}function ju(n){let t=n;for(;t._parentNode;)t=t._parentNode;return t}function wu(n){const t=[];let o=n;for(;o;)t.push({node:o,indexFromParent:o._indexFromParent}),o=o._parentNode;return t.reverse(),t}function Ut(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)=>Ut(i,s,c))}return Object.freeze(s),s}function vu(n,t,o){if(n&&o===void 0)throw new te(n,[t])}function Ht(n,t,o){if(typeof o!="string")throw new C(n,t,"A string is expected")}function yu(n,t,o){if(typeof o!="boolean")throw new C(n,t,"A boolean is expected")}function Nu(n,t,o){if(typeof o!="number")throw new C(n,t,"A number is expected")}function ue(n,t,o){if(o!==void 0&&typeof o!="boolean")throw new C(n,t,"An optional boolean is expected")}function ne(n,t,o){if(o!==void 0&&typeof o!="string")throw new C(n,t,"An optional string is expected")}function bu(n,t,o){if(!Array.isArray(o))throw new C(n,t,"A list of string is expected");o.forEach(s=>{if(typeof s!="string")throw new C(n,t,"A list of string is expected")})}function _u(n,t,o){if(o!==void 0&&typeof o!="string"){if(!Array.isArray(o))throw new C(n,t,"An optional string or list of string is expected");o.forEach(s=>{if(typeof s!="string")throw new C(n,t,"An optional string or list of string is expected")})}}function $u(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new C(n,t,"An optional list of string is expected");o.forEach(s=>{if(typeof s!="string")throw new C(n,t,"A optional list of string is expected")})}}function fe(n,t,o){if(o!==void 0&&typeof o!="number")throw new C(n,t,"An optional number is expected")}function Su(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new C(n,t,"An optional list of numbers is expected");o.forEach(s=>{if(typeof s!="number")throw new C(n,t,"An optional list of numbers is expected")})}}function ae(n,t){const{_parentNode:o,_indexFromParent:s,...r}=t;if(n&&Object.keys(r).length>0)throw new de(n,Object.keys(r))}function Ou(n,t,o){if(o!=="last"&&typeof o!="number")throw new C(n,t,'"last" or a number is expected')}function Cu(n,t,o){if(o!==void 0&&o!=="h5web"&&o!=="plotly")throw new C(n,t,'"h5web" or "plotly" string is expected')}const Iu=Object.freeze(Object.defineProperty({__proto__:null,assertBoolean:yu,assertDataCollectionId:Ou,assertKeyExpected:vu,assertNoUnknownKeys:ae,assertNumber:Nu,assertOptionalBackend:Cu,assertOptionalBoolean:ue,assertOptionalNumber:fe,assertOptionalNumberList:Su,assertOptionalString:ne,assertOptionalStringList:$u,assertOptionalStringOrStringList:_u,assertString:Ht,assertStringList:bu},Symbol.toStringTag,{value:"Module"}));function qt(n){const{providers:t={},yamlNode:o,message:s,...r}=n;return ne(o,"message",s),ae(o,r),e.jsx(a.Alert,{variant:"warning",className:"mb-0",children:s??"TODO"})}function zt(n){return e.jsx(e.Fragment,{})}const Mu=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Tu=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));function Wt(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 Fu(n){const{error:t}=n;if(!(t instanceof W))return e.jsx(e.Fragment,{});function o(i,c=3){const l=wu(i.yamlNode),f=[];let u="";for(let d=1;d<l.length;d++){const{node:p,indexFromParent:m}=l[d];f.push(`${u}children:`),u+=" ".repeat(c),m===1?f.push(`${u}- type: ...`):(m??0>1)&&f.push(`${u}...`,`${u}...`,`${u}# children number ${m??0+1}`),f.push(`${u}- type: ${p.type}`),u+=" ".repeat(2)}return i instanceof de?i.keys.forEach(d=>{f.push(`${u}${d}: ... ${" ".repeat(50-u.length-d.length)}<-- unexpected key`)}):i instanceof te?i.keys.forEach(d=>{f.push(`${u}???: ${" ".repeat(50-u.length-d.length)}<-- key **${d}** is expected`)}):i instanceof C&&f.push(`${u}${i.key}: ${" ".repeat(50-u.length-i.key.length)}<-- ${i.keyMessage}`),f.join(`
35
- `)}const r=ju(t.yamlNode).name;if(t instanceof de){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 te){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 C?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(Wt,{...n})}const Ae={hasError:!1,message:"",error:void 0};class Yt extends h.Component{constructor(t){super(t),this.reload=()=>{window.location.reload()},this.state=Ae}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){var o,s;if(t instanceof W||!this.props.unhandledComponentDidCatch){this.setState({hasError:!0,message:t.message,error:t});return}(s=(o=this.props).unhandledComponentDidCatch)==null||s.call(o,t,r=>{this.setState({hasError:!0,message:t.message,error:t,...r})})}componentDidUpdate(t,o){this.state.hasError&&o.error!==void 0&&t.resetKey!==this.props.resetKey&&this.setState(Ae)}render(){if(this.state.hasError){const{UnhandledErrorComponent:t}=this.props,{hasError:o,...s}=this.state;return e.jsxs(a.Container,{className:"mt-2",children:[e.jsx("h4",{children:"Something went wrong"}),this.state.error instanceof W&&e.jsx(Fu,{message:this.state.message,error:this.state.error}),!(this.state.error instanceof W)&&e.jsx(e.Fragment,{children:t?e.jsx(t,{...s}):e.jsx(Wt,{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 Du({yamlNode:n,panel:t}){const{type:o,style:s,children:r,...i}=n;return ae(n,i),e.jsx(a.Row,{className:"ymllayout-row gx-0",style:s,children:F.map(r,(c,l)=>G(c,l,t))})}function Eu({yamlNode:n,panel:t}){const{type:o,style:s,xs:r,children:i,...c}=n;return ae(n,c),fe(n,"xs",r),e.jsx(a.Col,{className:A.default("yamymllayout-col",{col:!!r}),style:s,xs:r,children:F.map(n.children,(l,f)=>G(l,f,t))})}const oe={};function Ru(n,t){oe[n]=t}function Au(n,t){if(t===void 0)throw new te(n,["id"]);if(typeof t.id!="string")throw new C(n,"id","A string is expected")}function ku(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new C(n,t,"A option list is expected");o.forEach((s,r)=>{try{Au(n,s)}catch{throw new C(n,t,`The hardware description ${r} is wrong`)}})}}function Pu(n){const{providers:t={},yamlNode:o,ids:s,groupid:r,even:i,nowrap:c,...l}=n;if(ku(o,"ids",s),ne(o,"groupid",r),ue(o,"even",i),ue(o,"nowrap",c),ae(o,l),!oe.HardwareGroup)return e.jsx(a.Alert,{variant:"warning",children:"No `HardwareGroup` component registered"});const f=oe.HardwareGroup;return e.jsx(f,{providers:t,ids:s,groupid:r,nowrap:c||!1,even:i||!1})}function Gu(n){const{providers:t={},yamlNode:o,id:s,variant:r,header:i,width:c,colWidth:l,emptyifnone:f,...u}=n;Ht(o,"id",s),ne(o,"variant",r),ne(o,"header",i),fe(o,"width",c),fe(o,"colWidth",l),ue(o,"emptyifnone",f);const d={variant:r,header:i,width:c,colWidth:l,emptyifnone:f,...u};if(!oe.HardwareGroup)return e.jsx(a.Alert,{variant:"warning",children:"No `Hardware` component registered"});const p=oe.Hardware;return e.jsx(p,{providers:t,id:s,options:d})}const _e={hardwaregroup:Pu,hardware:Gu,todo:qt,none:zt};function Kt(n,t){_e[n]=t}function Bu(n){Object.entries(n).forEach(([t,o])=>Kt(t,o))}function Vu(n){const{yamlNode:t,panel:o}=n,{type:s,style:r,scroll:i,title:c,...l}=t;if(!(s in _e))return e.jsx(O,{children:e.jsx(O.Contents,{children:e.jsxs(a.Alert,{variant:"warning",children:['Unknown component "',s,'"']})})});const f=_e[t.type];return o?e.jsx(O,{style:r,scroll:i,children:e.jsxs(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:[c&&e.jsx(O.Header,{children:c}),e.jsx(O.Contents,{children:e.jsx(f,{...l,yamlNode:t})})]})}):e.jsx(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:e.jsx(f,{...l,yamlNode:t})})}function Lu({yamlNode:n,panel:t}){const o=n.options||{};return e.jsx(a.Container,{className:"ymllayout-container",...o,children:F.map(n.children,(s,r)=>G(s,r,t))})}function Uu(n){const{yamlNode:t}=n,o=t.options||{},s={};return o.centerContent&&(s.margin="auto"),e.jsxs(O,{className:"ymllayout-panel",...o,children:[t.title&&e.jsx(O.Header,{children:t.title}),e.jsx(O.Contents,{style:s,children:F.map(t.children,(r,i)=>G(r,i,!1))})]})}const Hu=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15);function qu({yamlNode:n,panel:t}){const o=[];return F.each(n.children,(s,r)=>{o.push(e.jsx(a.Tab,{eventKey:Hu(),title:s.title,children:G(s,0,!1)},r))}),t?e.jsxs(O,{className:"ymllayout-tabs",children:[n.title&&e.jsx(O.Header,{children:n.title}),e.jsx(O.Contents,{children:e.jsx(a.Tabs,{mountOnEnter:!0,children:o})})]}):e.jsx(a.Tabs,{children:o})}function zu(n){const{node:t}=n,{type:o,title:s,...r}=t;return Lt(t,r),e.jsx("div",{className:"ymllayout-form-header",style:{gridColumn:"1 / 3"},children:e.jsx("h3",{children:s})})}function Wu(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 f=i(),u={_parentNode:t._parentNode,_indexFromParent:t._indexFromParent,type:"hardware",id:f,variant:"name",emptyifnone:!0};return G(u,"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 Yu(n){const{node:t,row:o}=n,{titlealign:s,title:r,stateinheader:i=!1,variant:c,id:l,...f}=t;let u,d;if(f.type==="hardware")if(u={...f,id:l,variant:c},i){const p={...f,id:l,variant:"state",emptyifnone:!0};d=G(p,"k",!1)}else d=null;else u=f,d=null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{gridColumn:1,alignSelf:s??"center"},children:e.jsx(Wu,{node:t,state:d,row:o})}),e.jsx("div",{style:{gridColumn:2,alignSelf:"center"},children:G(u,"k",!1)})]})}function Ku(n){const{yamlNode:t,panel:o}=n,{type:s,children:r,options:i={},title:c,...l}=t;return Lt(t,l),e.jsxs(O,{className:"ymllayout-form",...i,children:[t.title&&e.jsx(O.Header,{children:t.title}),e.jsx(O.Contents,{className:"full-sizer",style:{overflow:"auto"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"min-content auto"},children:F.map(r,(f,u)=>f.type==="formheader"?e.jsx(zu,{node:f,row:u},u):f.type==="none"?e.jsx(rn.default.Fragment,{},u):e.jsx(Yu,{node:f,row:u},u))})})]})}function Qu(n){const{yamlNode:t,panel:o}=n;return e.jsxs("div",{className:"ymllayout-grid",style:{gridTemplateColumns:t.columns,gridTemplateRows:t.rows},children:[F.map(t.children,(s,r)=>{const{columnSpan:i=1,rowSpan:c=1,...l}=s,f=i>1?`span ${i}`:void 0,u=c>1?`span ${c}`:void 0;return e.jsx("div",{className:"ymllayout-grid-cell",style:{gridColumn:f,gridRow:u},children:G(l,r,o)},r)})," "]})}function Xu({yamlNode:n,panel:t}){const o=n.options||{};return e.jsx(gu,{panel:t,options:o,children:e.jsx("div",{children:n.label})})}const Qt={row:Du,col:Eu,container:Lu,component:Vu,panel:Uu,tabs:qu,form:Ku,grid:Qu,label:Xu};Object.entries(Qt).forEach(([n,t])=>{Vt(n,t)});function Ju(n){var o;const t=h.useMemo(()=>Ut(n.layout),[n.layout]);return t.error?e.jsx("div",{className:`${n.className??""} ymllayout-main`,"data-testid":n.testid,children:e.jsxs(O,{children:[e.jsx(O.Header,{children:"Layout Error"}),e.jsxs(O.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(Yt,{resetKey:t,unhandledComponentDidCatch:n.unhandledComponentDidCatch,UnhandledErrorComponent:n.UnhandledErrorComponent,children:(o=t.children)==null?void 0:o.map((s,r)=>G(s,r))})})}const Zu=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Xt=(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 Jt(n,t,o){const s=n.split(t);return o?[s.slice(0,-o).join(t)].concat(s.slice(-o)):s}function ke(n){const t=n!==void 0?Jt(n,".",1):[null,""],o=P(t[0]);if(o&&o.properties&&t[1]!==null)return Array.isArray(o.properties[t[1]])?o.properties[t[1]][0]:o.properties[t[1]]}function ef(n){const t=n!==void 0&&!n.includes("."),o=n!==void 0?Jt(n,".",1):[null,""],s=P(o[0]);if(t)return n;if(s&&s.properties&&o[1]!==null)return`${s.properties[o[1]]}`}function Zt(n){const{monitor:t}=n;let o=ke(t.value)??"-";const s=ef(t.unit),r=ke(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=Xt(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
- `)?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 en={hardware:Zt};function tf(n,t){en[n]=t}function nf(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 of(n){const t=F.map(n.monitors,(o,s)=>{const r=o.type??"hardware",i=en[r];return i===void 0?e.jsx(nf,{monitor:o,message:`Type ${r} unsupported`},`m${s}`):e.jsx(i,{monitor:o},`m${s}`)});return e.jsx("div",{className:A.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 sf(n){return e.jsx(a.Col,{className:"monitor-panel-item",children:n.children})}exports.AirBearing=He;exports.AirBearingMocks=Dn;exports.AirBearingProtected=qe;exports.AirBearingSimulator=En;exports.AirBearingState=pe;exports.AirBearingVariants=bn;exports.BaseInfo=Ve;exports.BaseMocks=xn;exports.BaseName=Be;exports.BaseProperty=Le;exports.BaseState=Ge;exports.BaseVariants=fn;exports.ErrorObject=uu;exports.Formatting=Gn;exports.Frontend=We;exports.FrontendMocks=Jn;exports.FrontendVariants=Ln;exports.FullSizer=Bt;exports.Gauge=Ye;exports.GaugeMocks=yo;exports.GaugeVariants=to;exports.HWObject=Zu;exports.HardwareInputNumber=ee;exports.HardwareNumericStep=me;exports.HardwareSchema=Tu;exports.HardwareState=gn;exports.HardwareTemplate=v;exports.HardwareTypes=Mu;exports.KeyError=C;exports.Laser=Qe;exports.LaserHeating=Xe;exports.LaserHeatingMocks=Wo;exports.LaserHeatingVariants=ko;exports.LaserMocks=Eo;exports.LaserVariants=_o;exports.Light=Je;exports.LightMocks=rs;exports.LightVariants=Ko;exports.LimaBinning=nt;exports.LimaDefault=Ze;exports.LimaDescription=st;exports.LimaImageRoi=ot;exports.LimaMocks=Vs;exports.LimaSimulator=Ls;exports.LimaSize=et;exports.LimaState=z;exports.LimaTransformation=tt;exports.LimaVariants=xs;exports.LoadingObject=cu;exports.MeasurementGroupDefault=at;exports.MeasurementGroupMocks=or;exports.MeasurementGroupSimulator=sr;exports.MeasurementGroupVariants=Ws;exports.MissingComponentObject=pu;exports.MissingKeysError=te;exports.MissingObject=du;exports.MonitorHardware=Zt;exports.MonitorPanel=of;exports.MonitorPanelItem=sf;exports.MotorDefault=K;exports.MotorMocks=ha;exports.MotorSimulator=ga;exports.MotorState=xe;exports.MotorText=it;exports.MotorVariants=cr;exports.Multiposition=lt;exports.MultipositionMocks=Ta;exports.MultipositionSimulator=Fa;exports.MultipositionVariants=ya;exports.NoObject=iu;exports.None=zt;exports.NullObject=mu;exports.NumericStep=Ke;exports.OpticDefault=ut;exports.OpticMocks=Ka;exports.OpticSimulator=Qa;exports.OpticState=Oe;exports.OpticVariants=Ba;exports.Panel=O;exports.ProcedureExecution=ft;exports.ProcedureManage=be;exports.ProcedureMocks=pi;exports.ProcedureState=re;exports.ProcedureValidate=pt;exports.ProcedureVariants=oi;exports.PumpDefault=gt;exports.PumpMocks=mc;exports.PumpVariants=sc;exports.PusherDefault=jt;exports.PusherMocks=Ic;exports.PusherSimulator=Mc;exports.PusherState=Ie;exports.PusherVariants=wc;exports.ServiceDefault=wt;exports.ServiceMocks=Hc;exports.ServiceProtected=vt;exports.ServiceState=je;exports.ServiceVariants=Ec;exports.ShutterDefault=mt;exports.ShutterMocks=Ci;exports.ShutterProtected=ht;exports.ShutterSimulator=Ii;exports.ShutterState=ge;exports.ShutterVariants=ji;exports.SlitDefault=xt;exports.SlitMocks=tc;exports.SlitState=Ce;exports.SlitVariants=Ai;exports.Todo=qt;exports.TomoConfigLatencyTime=Rt;exports.TomoConfigVariants=Vd;exports.TomoDetectorAcquisitionMode=St;exports.TomoDetectorMocks=ed;exports.TomoDetectorSamplePixelSize=$t;exports.TomoDetectorState=ve;exports.TomoDetectorVariants=Hl;exports.TomoDetectorsDefault=Ot;exports.TomoDetectorsMocks=md;exports.TomoDetectorsState=Te;exports.TomoDetectorsVariants=sd;exports.TomoFlatMotionDefault=yt;exports.TomoFlatMotionMocks=Il;exports.TomoFlatMotionSimulator=Ml;exports.TomoFlatMotionSmall=Nt;exports.TomoFlatMotionState=we;exports.TomoFlatMotionVariants=Zc;exports.TomoHoloState=kt;exports.TomoHoloVariants=qd;exports.TomoImagingActions=Ft;exports.TomoImagingDefault=It;exports.TomoImagingExposureTime=Mt;exports.TomoImagingMocks=Ed;exports.TomoImagingSettleTime=Tt;exports.TomoImagingSimulator=Rd;exports.TomoImagingState=Y;exports.TomoImagingUpdateMode=Dt;exports.TomoImagingVariants=$d;exports.TomoReferencePositionDefault=_t;exports.TomoReferencePositionVariants=Dl;exports.TomoSampleStageVariants=kd;exports.TypeIcon=w;exports.ValveDefault=Gt;exports.ValveMocks=ru;exports.ValveVariants=Kd;exports.YAMLErrorBoundary=Yt;exports.YAMLLayout=Ju;exports.YamlAsserts=Iu;exports.createMotorMock=xa;exports.dynamicOp=Xt;exports.isLimaHardware=he;exports.isMotorHardware=ct;exports.isOpticHardware=Pa;exports.isTomoConfigHardware=At;exports.isTomoDetectorHardware=Me;exports.isTomoDetectorsHardware=Ct;exports.isTomoFlatMotionHardware=bt;exports.isTomoHoloHardware=Pt;exports.isTomoReferencePositionHardware=Tl;exports.isTomoSampleStageHardware=Et;exports.limaGuessSubframes=rt;exports.registerHardwareComponent=Ru;exports.registerMonitorComponent=tf;exports.registerRuntimeHook=ps;exports.registerYamlComponent=Kt;exports.registerYamlComponents=Bu;exports.registerYamlType=Vt;exports.renderYamlNode=G;exports.useLimaHardware=ms;exports.useMotorHardware=R;exports.useMotorStates=Se;exports.useTomoConfigHardware=Ld;exports.useTomoDetectorHardware=ql;exports.useTomoDetectorsHardware=rd;exports.useTomoFlatMotionHardware=el;exports.useTomoHoloHardware=zd;exports.useTomoSampleStageHardware=Pd;exports.yamlMap=Qt;
33
+ `,voltage:6998},Bc="tango",Vc=!0,Lc="pump",Uc={callables:Rc,id:Ec,name:kc,online:Pc,properties:Gc,protocol:Bc,require_staff:Vc,type:Lc},Hc={default:Uc};function Me(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={RETRACTED:"success",IN_TOUCH:"warning",MOVING_IN:"warning",MOVING_OUT:"warning",UNKNOWN:"danger",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(F,{state:o,minWidth:6,variant:r})}function qc(n){const{hardware:t}=n;return e.jsx(Me,{hardware:t})}function zc(n){const{className:t,hardware:o,options:s={}}=n,{state:r}=o.properties??"OFFLINE",c=!(r==="IN_TOUCH")||n.disabled;function l(f){const{distance:u}=f,[d,p]=h.useState(!1);return e.jsx(i.Button,{variant:"secondary",onClick:()=>{p(!0),o.actions.call("push",u).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"})," ",u]})})}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 Wc(n){const{hardware:t,options:o,disabled:s}=n,{state:r}=t.properties??"OFFLINE",a=r==="RETRACTED",c=r==="IN_TOUCH",[l,f]=h.useState(!1),[u,d]=h.useState(!1),p=a?"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?"fas fa-dizzy":"fa fa-smile"} fa-3x my-auto`}),e.jsx(zc,{className:p,...n}),e.jsx("span",{}),e.jsxs(i.ButtonGroup,{className:"mx-auto",style:{width:"12em"},children:[e.jsx(i.Button,{onClick:()=>{f(!0),t.actions.call("move_in").finally(()=>{f(!1)})},disabled:c||s||l||u,style:{width:"5em"},children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx("i",{className:l?"fa-solid fa-fw fa-cog fa-spin":"fa fa-fw fa-arrow-left"})," ","In"]})}),e.jsx(i.Button,{onClick:()=>{d(!0),t.actions.call("move_out").finally(()=>{d(!1)})},disabled:a||s||l||u,style:{width:"5em"},children:e.jsxs("span",{className:"text-nowrap",children:["Out"," ",e.jsx("i",{className:u?"fa-solid fa-fw fa-cog fa-spin":"fa fa-fw fa-arrow-right"})]})})]})]})}function bt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Pusher",icon:"fa-hand-point-right",online:t.online}),r=e.jsx(Me,{hardware:t});function a(){return e.jsx(Wc,{...n})}const c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a(),headerMode:c})}const Yc={default:bt,state:qc},Kc=Yc,Qc=["move_in","move_out","push","sync_hard"],Xc="pusher",Jc="pusher",Zc=!0,el={state:"RETRACTED"},tl="bliss",nl=!1,ol="pusher",sl={callables:Qc,id:Xc,name:Jc,online:Zc,properties:el,protocol:tl,require_staff:nl,type:ol},rl={default:sl};function il(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("RETRACTED");async function c(u,d){if(u==="move_in"){a("MOVING_IN"),await R(2e3),a("IN_TOUCH");return}if(u==="move_out"){a("MOVING_OUT"),await R(2e3),a("RETRACTED");return}if(u==="push"){await R(100);return}console.log("PusherSimulator: Unsupported call",u,d)}async function l(u,d){console.log("PusherSimulator: Unsupported setProperty",u,d)}const f={state:r};return e.jsx(U,{name:t,alias:o,type:"pusher",call:c,setProperty:l,properties:f,useHardwareContext:s})}function ye(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={STOPPED:"danger",STARTING:"warning",RUNNING:"success",BACKOFF:"warning",STOPPING:"warning",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"fatal",OFFLINE:"secondary"},r=s[o]||s.UNKNOWN;return e.jsx(F,{state:o,minWidth:6,variant:r})}function al(n){const{hardware:t}=n;return e.jsx(ye,{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(ye,{hardware:t});function a(){t.actions.call("start")}function c(){t.actions.call("restart")}function l(){t.actions.call("stop")}function f(){return t.properties?t.properties.state:"UNKNOWN"}function u(b){return b.charAt(0).toUpperCase()+b.slice(1).toLowerCase()}const d=f(),p=u(d),g={STOPPED:"danger",STARTING:"warning",RUNNING:"success",BACKOFF:"warning",STOPPING:"warning",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:a,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(i.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(A,{variant:g,className:"text-center",style:{minWidth:"8em"},value:p}),e.jsx(i.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(i.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 cl(n){var f;const{hardware:t,options:o={}}=n;function s(){t.actions.call("start")}function r(){t.actions.call("restart")}function a(){t.actions.call("stop")}const c=((f=t.properties)==null?void 0:f.state)??"UNKNOWN",l=c==="STOPPING"||c==="STARTING";return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,placement:o.dropDirection==="up"?"top":"bottom",overlay:e.jsx(i.Popover,{id:"service-protected-overlay",children:e.jsxs(i.Popover.Body,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Actions"})}),e.jsx(i.Row,{children:e.jsxs(i.Col,{children:[c==="RUNNING"&&e.jsxs(i.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(i.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(i.Button,{className:`text-${c!=="STOPPED"?"danger":"primary"} border-secondary`,variant:"light",onClick:()=>{a()},disabled:n.disabled,title:"Stop the service",children:[e.jsx("i",{className:"fa fa-stop fa-wp me-1"}),"Stop"]})]})})]})}),children:e.jsx(i.Button,{disabled:n.disabled||l,children:e.jsx("i",{className:`fa fa-caret-${o.dropDirection==="up"?"up":"down"}`})})})}function $t(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Shutter",icon:"fa-cog",online:t.online}),r=e.jsx(ye,{hardware:t});function a(){return t.properties?t.properties.state:"UNKNOWN"}function c(g){return g.charAt(0).toUpperCase()+g.slice(1).toLowerCase()}const l=a(),u={STOPPED:"danger",STARTING:"warning",RUNNING:"success",BACKOFF:"warning",STOPPING:"warning",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"fatal",OFFLINE:"secondary"}[l],d=c(l),p=e.jsxs(i.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(A,{variant:u,style:{minWidth:"10em"},value:d,className:"text-center"}),e.jsx(cl,{...n})]}),m=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:p,headerMode:m})}const ll={default:_t,protected:$t,state:al},dl=ll,ul=["start","stop","restart"],fl="service1",pl="service1",ml=!0,hl={state:"RUNNING"},xl="multivisor",gl=!0,jl="service",wl={callables:ul,id:fl,name:pl,online:ml,properties:hl,protocol:xl,require_staff:gl,type:jl},yl={default:wl};function ve(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={UNKNOWN:"danger",READY:"success"},r=s[o]||s.UNKNOWN;return e.jsx(F,{state:o,minWidth:6,variant:r})}function vl(n){const{hardware:t}=n;return e.jsx(ve,{hardware:t})}function Nl(n){const{motion:t}=n,s=t.axisRef.slice(9),r=k(s),a=(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:a})}function bl(n){const{motion:t,actions:o,disabled:s}=n,r=t.axisRef;function a(){o.call("update_axis",{axis_ref:r})}return e.jsx(i.Button,{variant:"danger",onClick:a,disabled:s,children:e.jsx("i",{className:"fa fa-trash"})})}function _l(n){const{motion:t,actions:o,axisRef:s,disabled:r}=n,a=h.useMemo(()=>{for(const d of t)if(d.axisRef===s)return!0;return!1},[t,s]),c=s.slice(9),l=k(c),f=(l==null?void 0:l.alias)??(l==null?void 0:l.name)??(l==null?void 0:l.id)??c;function u(){o.call("update_axis",{axis_ref:s,relative_position:0})}return e.jsx(i.Button,{className:"ms-1",variant:a?"primary":"secondary",onClick:()=>{a||u()},title:a?"This axis is already part of the motion":"Use this axis in the motion",disabled:r,children:f})}function $l(n){var x;const{motion:t,actions:o}=n,s=t.axisRef,r=t.absolute_position??t.relative_position??0,a=s.slice(9),c=k(a),l=n.disabled||!(c!=null&&c.online),f=h.useRef(null),[u,d]=h.useState(!1),p=3,m=((x=c==null?void 0:c.properties)==null?void 0:x.unit)??"";function g(j){if(!f||!f.current)console.log("formRef not yet defined");else if(j.key==="Enter"){d(!1);const N=Number.parseFloat(f.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"?(f.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&&!u&&d(!0),I===r&&u&&d(!1)}return h.useEffect(()=>{!f||!f.current?console.log("formRef not yet defined"):u||(f.current.value=r.toFixed(p))},[u,r]),e.jsxs(i.InputGroup,{className:"w-100",children:[e.jsx(i.Form.Control,{className:u?"form-control-edited":"",type:"number",ref:f,defaultValue:r.toFixed(p),onChange:w,disabled:l,onKeyDown:g}),e.jsx(i.InputGroup.Text,{children:m})]})}function Sl(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 a(){t.call("update_axis",{axis_ref:o.axisRef,relative_position:o.absolute_position??o.relative_position})}return e.jsxs(i.ButtonGroup,{children:[e.jsx(i.Button,{onClick:r,variant:o.absolute_position!==null?"primary":"secondary",disabled:s,children:"Abs"}),e.jsx(i.Button,{onClick:a,variant:o.relative_position!==null?"primary":"secondary",disabled:s,children:"Rel"})]})}function St(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r}=t,a=e.jsx(y,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),c=e.jsx(ve,{hardware:t}),l=e.jsxs(i.Container,{children:[e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Move in parallel"}),e.jsx(i.Col,{xs:9,children:r.move_in_parallel?"true":"false"})]}),e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Switch power on/off"}),e.jsx(i.Col,{xs:9,children:r.power_onoff?"true":"false"})]}),e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Settle time"}),e.jsxs(i.Col,{xs:9,children:[r.settle_time.toFixed(2)," ",e.jsx("span",{title:"seconds",children:"s"})]})]}),e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Available axes"}),e.jsx(i.Col,{xs:9,children:r.available_axes.map(u=>e.jsx(_l,{axisRef:u,motion:r.motion,actions:t.actions,disabled:s},u))})]}),e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Actual motion"}),e.jsx(i.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((u,d)=>e.jsxs(h.Fragment,{children:[e.jsx(Nl,{motion:u}),e.jsx(Sl,{motion:u,actions:t.actions,disabled:s}),e.jsx($l,{motion:u,actions:t.actions,disabled:s}),e.jsx(bl,{motion:u,actions:t.actions,disabled:s})]},`motion${d}`))]})})]})]}),f=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:a,widgetState:c,widgetContent:l,headerMode:f})}function Cl(n){var b;const{motion:t,actions:o}=n,s=t.axisRef,r=t.absolute_position??t.relative_position??0,a=s.slice(9),c=k(a),l=n.disabled||!(c!=null&&c.online),f=h.useRef(null),[u,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(!f||!f.current)console.log("formRef not yet defined");else if(_.key==="Enter"){d(!1);const S=Number.parseFloat(f.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"?(f.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&&!u&&d(!0),C===r&&u&&d(!1)}h.useEffect(()=>{!f||!f.current?console.log("formRef not yet defined"):u||(f.current.value=r.toFixed(p))},[u,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(i.InputGroup,{className:"w-100 flex-nowrap",children:[e.jsx(i.InputGroup.Text,{title:"Displacement to apply on this axis to take a flat",style:{width:"5em"},children:g}),e.jsx(i.InputGroup.Text,{className:`bg-${I}`,title:M,style:{width:"3em"},children:N}),e.jsx(i.Form.Control,{className:u?"form-control-edited":"",type:"number",ref:f,defaultValue:r.toFixed(p),onChange:x,disabled:l,onKeyDown:w}),e.jsx(i.InputGroup.Text,{children:m})]})}function Ct(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r}=t,a=e.jsx(y,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),c=e.jsx(ve,{hardware:t}),l=e.jsxs(e.Fragment,{children:[r.motion.length===0&&e.jsx(i.Alert,{variant:"danger",className:"mb-0",children:"No flat motion defined"}),r.motion.length>0&&e.jsx(i.Stack,{direction:"vertical",children:r.motion.map((u,d)=>e.jsx(Cl,{actions:t.actions,motion:u,disabled:s},u.axisRef))})]}),f=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:a,widgetState:c,widgetContent:l,headerMode:f})}const Ol={default:St,small:Ct,state:vl},Il=Ol;function Ot(n){return n.type==="tomoflatmotion"}function Ml(n){const t=E(n);return t===null||!Ot(t)?null:t}const Tl="tomoflatmotion",Fl="tomoflatmotion",Dl=!0,Al={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}]},Rl="bliss",El=!1,kl="tomoflatmotion",Pl={id:Tl,name:Fl,online:Dl,properties:Al,protocol:Rl,require_staff:El,type:kl},Gl=["move","stop","wait","rmove"],Bl="sy",Vl="sy",Ll=!0,Ul={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},Hl="bliss",ql=!1,zl="motor",Wl=[],Yl={callables:Gl,id:Bl,name:Vl,online:Ll,properties:Ul,protocol:Hl,require_staff:ql,type:zl,user_tags:Wl},Kl=["move","stop","wait","rmove"],Ql="sy2",Xl="sy2",Jl=!0,Zl={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},ed="bliss",td=!1,nd="motor",od=[],sd={callables:Kl,id:Ql,name:Xl,online:Jl,properties:Zl,protocol:ed,require_staff:td,type:nd,user_tags:od},rd={default:Pl,sy:Yl,sy2:sd};function id(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=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(u,d){const p=[];let m=!1;return u.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}),{...u,motion:p}}async function l(u,d){if(u==="update_axis"){a(p=>c(p,d));return}console.log("TomoFlatMotionSimulator: Unsupported call",u,d)}async function f(u,d){console.log("TomoFlatMotionSimulator: Unsupported setProperty",u,d)}return e.jsx(U,{name:t,alias:o,type:"tomoflatmotion",call:l,setProperty:f,properties:r,useHardwareContext:s})}function It(n){const{hardware:t,options:o={},disabled:s}=n,{actions:r}=t,a=e.jsx(y,{name:"TomoReferencePositionSchema",icon:"fam-hardware-motor",online:t.online});function c(){r.call("move_to_reference")}const l=e.jsx(e.Fragment,{}),f=e.jsx(i.Button,{className:"w-100",onClick:()=>{c()},disabled:s,children:"Back to parking position"}),u=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:a,widgetState:l,widgetContent:f,headerMode:u})}function ad(n){return n.type==="tomoreferenceposition"}const cd={default:It},ld=cd;function Ne(n){const{hardware:t}=n,{online:o,locked:s=null}=t,r=o?(s!==null?"LOCKED":t.properties.state)||"UNKNOWN":"OFFLINE",a={UNKNOWN:"danger",READY:"success",OFFLINE:"secondary",INVALID:"danger",MOUNTING:"warning",UNMOUNTING:"warning",LOCKED:"warning"},c=a[r]||a.UNKNOWN;return e.jsx(F,{state:r,minWidth:6,variant:c})}function dd(n){const{hardware:t}=n;return e.jsx(Ne,{hardware:t})}function ud(n){const{hardware:t,options:o={}}=n;function s(a){return t.actions?t.actions.setProperty("sample_pixel_size_mode",a):console.error("Change request was triggered with:",a),null}const r=t.properties.sample_pixel_size_mode;return e.jsx(i.Dropdown,{style:n.style,children:e.jsxs(i.ButtonGroup,{children:[e.jsx(i.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(i.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 fd(n){const{hardware:t,options:o={}}=n,s=t.properties.user_sample_pixel_size||0,{state:r}=t.properties,a=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(oe,{hardwareValue:s,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:a,hardwareIsMoving:!1,readOnly:t.properties.sample_pixel_size_mode!=="USER"})}function pd(n){const{hardware:t,options:o={}}=n;return t.properties.state,e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:n.disabled,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Mode"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsx(ud,{...n,style:{width:"100%"}})})}),e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center mt-1",children:"User pixel size"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsxs(i.InputGroup,{children:[e.jsx(fd,{...n}),e.jsx(i.InputGroup.Text,{children:"um"})]})})})]})})]})}function md(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 a=xn.default(n,t);return[r(a.to(o).scalar),s(o)]},[n,t,o])}function Mt(n){const{hardware:t,options:o={}}=n,s=o.display_unit??"um",r=e.jsx(y,{name:"TomoDetector",icon:"fa-cog",online:t.online}),a=e.jsx(Ne,{hardware:t}),[c,l]=md(t.properties.sample_pixel_size,"um",s),f=e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(i.InputGroup.Text,{className:"justify-content-center",style:{minWidth:"4em"},children:t.properties.sample_pixel_size_mode}),e.jsx(A,{value:c,title:`${t.properties.sample_pixel_size} um`}),e.jsx(i.InputGroup.Text,{children:l}),e.jsx(pd,{...n})]}),u=n.options?n.options.header:"top";return e.jsx(v,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:f,headerMode:u})}function hd(n){const{hardware:t,options:o={}}=n;function s(a){return t.actions?t.actions.setProperty("acq_mode",a):console.error("Change request was triggered with:",a),null}const r=t.properties.acq_mode;return e.jsx(i.Dropdown,{style:n.style,children:e.jsxs(i.ButtonGroup,{children:[e.jsx(i.Button,{variant:r==="SINGLE"?"primary":"secondary",onClick:()=>{s("SINGLE")},disabled:n.disabled,title:"Do acquisition in a single shot",children:"SINGLE"}),e.jsx(i.Button,{variant:r==="ACCUMULATION"?"primary":"secondary",onClick:()=>{s("ACCUMULATION")},disabled:n.disabled,title:"Do acqisition in multiple sub frame with accumulation",children:"ACCU"})]})})}function xd(n){const{hardware:t,actions:o}=n,s=t.properties.acc_max_expo_time||0,{state:r}=t.properties,a=r==="READY";function c(l){return o.setProperty("acc_max_expo_time",l),null}return e.jsx(oe,{hardwareValue:s,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:a,hardwareIsMoving:!1,readOnly:t.properties.state!=="READY"})}function gd(n){const t=E(n);return t!==null&&ge(t)?t:null}function jd(n){var c;const{hardware:t}=n,{properties:o}=t,s=((c=o.detector)==null?void 0:c.slice(9))??"",r=gd(s),a=te(s);return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:n.disabled,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Acquisition mode"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsx(hd,{...n,style:{width:"100%"}})})}),e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center mt-1",children:"Max sub frame exposition"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:r&&e.jsxs(i.InputGroup,{children:[e.jsx(xd,{hardware:r,actions:a}),e.jsx(i.InputGroup.Text,{children:"um"})]})})})]})})]})}function Tt(n){const{hardware:t}=n,o=e.jsx(y,{name:"TomoDetector",icon:"fa-cog",online:t.online}),s=e.jsx(Ne,{hardware:t}),r=e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(A,{value:t.properties.acq_mode}),e.jsx(jd,{...n})]}),a=n.options?n.options.header:"top";return e.jsx(v,{hardware:t,widgetIcon:o,widgetState:s,widgetContent:r,headerMode:a})}const wd={samplepixelsize:Mt,acquisitionmode:Tt,state:dd},yd=wd;function Te(n){return n.type==="tomodetector"}function vd(n){const t=E(n);return t===null||!Te(t)?null:t}const Nd="tomodetector",bd="tomodetector",_d=!0,$d={state:"READY",actual_size:[1024,1024],sample_pixel_size_mode:"AUTO",user_sample_pixel_size:50,sample_pixel_size:48},Sd="bliss",Cd=!1,Od="tomodetector",Id={id:Nd,name:bd,online:_d,properties:$d,protocol:Sd,require_staff:Cd,type:Od},Md={default:Id};function Fe(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOUNTING:"warning",UNMOUNTING:"warning",UNKNOWN:"fatal",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(F,{state:o,minWidth:6,variant:r})}function Td(n){const{hardware:t}=n;return e.jsx(Fe,{hardware:t})}function ne(n){return!n||!n.startsWith("hardware:")?null:n.slice(9)}function Fd(n){const{hardware:t}=n,{properties:o}=t,{detectors:s}=o,r=ne(o.active_detector),a=ne(o.target_detector),c=o.state==="READY",l=n.disabled||!t.online||!c;function f(d){t.actions?t.actions.call("mount",d):console.error("Change request was triggered with:",d)}function u(d){const p=ne(d),g=p===(a||r)?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(i.Dropdown.Item,{disabled:l,onClick:()=>{f(p)},children:[e.jsx("i",{className:g}),"  ",p]},d)}return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:l,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:s.map(d=>u(d))})]})}function Ft(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"Optic",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Fe,{hardware:t}),{properties:a}=t,c=a.state==="MOUNTING",l=ne(a.active_detector),f=ne(a.target_detector);function u(){return e.jsxs(i.InputGroup,{children:[e.jsx(A,{className:P.default({"hw-moving":c}),value:f||l||"No detector"}),e.jsx(Fd,{...n})]})}const d=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:u(),headerMode:d})}const Dd={default:Ft,state:Td},Ad=Dd;function Dt(n){return n.type==="tomodetectors"}function Rd(n){const t=E(n);return t===null||!Dt(t)?null:t}const Ed="tomodetectors",kd="tomodetectors",Pd=!0,Gd={state:"READY",active_detector:"hardware:limadetector1",detectors:["hardware:limadetector1","hardware:limadetector2","hardware:limadetector3"]},Bd="bliss",Vd=!1,Ld="optic",Ud={id:Ed,name:kd,online:Pd,properties:Gd,protocol:Bd,require_staff:Vd,type:Ld},Hd={default:Ud};function K(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",BLOCKED:"secondary",ACQUIRING:"warning",UNKNOWN:"fatal"},r=s[o]||s.UNKNOWN;return e.jsx(F,{state:o,minWidth:6,variant:r})}function qd(n){const{hardware:t}=n;return e.jsx(K,{hardware:t})}function zd(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 a(c){t.actions.setProperty("update_on_move",!0)}return e.jsxs(i.ButtonGroup,{className:"me-2",children:[e.jsx(i.InputGroup.Text,{children:"Update mode"}),e.jsx(i.Button,{onClick:a,disabled:s,variant:o?"primary":"secondary",children:"Auto"}),e.jsx(i.Button,{onClick:r,disabled:s,variant:o?"secondary":"primary",children:"Off"})]})}function Wd(n){const{hardware:t}=n,o=t.properties.exposure_time??0,s=n.disabled||!t.online,r=h.useRef(null),[a,c]=h.useState(!1),l=2;function f(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 u(d){const{value:p}=d.target;if(p===void 0)return;const m=Number.parseFloat(p);m!==o&&!a&&c(!0),m===o&&a&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):a||(r.current.value=o.toFixed(l))},[a,o]),e.jsxs(i.InputGroup,{className:"me-2",children:[e.jsx(i.InputGroup.Text,{children:"Exposure time"}),e.jsx(i.Form.Control,{className:a?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:u,disabled:s,onKeyDown:f}),e.jsx(i.InputGroup.Text,{children:"s"})]})}function Yd(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 a(c){t.actions.call("take_flat")}return e.jsxs(i.ButtonGroup,{size:"lg",className:"me-2",children:[e.jsx(i.InputGroup.Text,{children:"Take"}),e.jsx(i.Button,{onClick:s,disabled:o,variant:"primary",children:"Proj"}),e.jsx(i.Button,{onClick:a,disabled:o,variant:"primary",children:"Flat"}),e.jsx(i.Button,{onClick:r,disabled:o,variant:"primary",children:"Dark"})]})}function At(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(K,{hardware:t}),a=e.jsxs(i.Container,{children:[e.jsx(i.Row,{className:"mt-1",children:e.jsx(i.Col,{children:e.jsx(zd,{hardware:t,disabled:n.disabled})})}),e.jsx(i.Row,{className:"mt-1",children:e.jsx(i.Col,{children:e.jsx(Wd,{hardware:t,disabled:n.disabled})})}),e.jsx(i.Row,{className:"mt-1",children:e.jsx(i.Col,{children:e.jsx(Yd,{hardware:t,disabled:n.disabled})})})]}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Kd(n){const{hardware:t}=n,o=t.properties.exposure_time??0,s=n.disabled||!t.online,r=h.useRef(null),[a,c]=h.useState(!1),l=3;function f(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 u(d){const{value:p}=d.target;if(p===void 0)return;const m=Number.parseFloat(p);m!==o&&!a&&c(!0),m===o&&a&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):a||(r.current.value=o.toFixed(l))},[a,o]),e.jsxs(i.InputGroup,{className:"w-100",children:[e.jsx(i.Form.Control,{className:a?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:u,disabled:s,onKeyDown:f}),e.jsx(i.InputGroup.Text,{children:"s"})]})}function Qd(n){const{exposureTime:t}=n,o=E("ACTIVE_TOMOCONFIG.ref.detectors.active_detector.detector"),s=E("ACTIVE_TOMOCONFIG.ref.detectors.active_detector");if(o===null||s===null)return e.jsx(e.Fragment,{});if(!ge(o)||!Te(s))return e.jsx(e.Fragment,{});const r=o.properties.acc_max_expo_time,a=s.properties.acq_mode;if(!r||a!=="ACCUMULATION")return e.jsx(e.Fragment,{});const[c,l]=lt(t,r);return e.jsxs("div",{className:"text-center",title:"Decompisiton of the accumulation",children:[c," × ",l.toFixed(3)]})}function Rt(n){const{hardware:t,options:o={}}=n,s=e.jsx(y,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(K,{hardware:t}),a=e.jsxs(e.Fragment,{children:[e.jsx(Kd,{hardware:t,disabled:n.disabled}),e.jsx(Qd,{exposureTime:t.properties.exposure_time})]}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Xd(n){const{hardware:t}=n,o=t.properties.settle_time||0,s=n.disabled||!t.online,r=h.useRef(null),[a,c]=h.useState(!1),l=3;function f(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 u(d){const{value:p}=d.target;if(p===void 0)return;const m=Number.parseFloat(p);m!==o&&!a&&c(!0),m===o&&a&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):a||(r.current.value=o.toFixed(l))},[a,o]),e.jsxs(i.InputGroup,{className:"w-100",children:[e.jsx(i.Form.Control,{className:a?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:u,disabled:s,onKeyDown:f}),e.jsx(i.InputGroup.Text,{children:"s"})]})}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(K,{hardware:t}),a=e.jsx(Xd,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function be(n){const{text:t,processing:o,disabled:s,onClick:r,title:a}=n;return e.jsxs(i.Button,{onClick:r,disabled:s,variant:"primary",className:P.default({"ps-4":!o,"pe-4":!o}),title:a,children:[o&&e.jsx("i",{className:"fa-solid fa-cog fa-spin me-1"}),t]})}function Jd(n){const{hardware:t}=n,[o,s]=h.useState(!1),[r,a]=h.useState(!1),[c,l]=h.useState(!1),f=n.disabled||!t.online||o||r||c;function u(m){l(!0),t.actions.call("take_proj").finally(()=>{l(!1)})}function d(m){s(!0),t.actions.call("take_dark").finally(()=>{s(!1)})}function p(m){a(!0),t.actions.call("take_flat").finally(()=>{a(!1)})}return e.jsxs(i.ButtonGroup,{size:"lg",className:"w-100",children:[e.jsx(be,{onClick:u,disabled:f,processing:c,text:"Proj",title:"Take a projection"}),e.jsx(be,{onClick:p,disabled:f,processing:r,text:"Flat",title:"Take a flat"}),e.jsx(be,{onClick:d,disabled:f,processing:o,text:"Dark",title:"Take a dark"})]})}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(K,{hardware:t}),a=e.jsx(Jd,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Zd(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 a(c){t.actions.setProperty("update_on_move",!0)}return e.jsxs(i.ButtonGroup,{className:"w-100",children:[e.jsx(i.Button,{onClick:a,disabled:s,variant:o?"primary":"secondary",children:"Auto"}),e.jsx(i.Button,{onClick:r,disabled:s,variant:o?"secondary":"primary",children:"Off"})]})}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(K,{hardware:t}),a=e.jsx(Zd,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const eu={default:At,exposuretime:Rt,settletime:Et,actions:kt,updatemode:Pt,state:qd},tu=eu,nu="tomoimaging",ou="tomoimaging",su=!0,ru={state:"READY",update_on_move:!1,exposure_time:1},iu="bliss",au=!1,cu="optic",lu={id:nu,name:ou,online:su,properties:ru,protocol:iu,require_staff:au,type:cu},du={default:lu};function uu(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState({state:"READY",update_on_move:!0,exposure_time:1,settle_time:0});function c(u){a(d=>({...d,state:u}))}async function l(u,d){if(u==="take_dark"){c("ACQUIRING"),await R(2e3),c("READY");return}if(u==="take_flat"){c("ACQUIRING"),await R(2e3),c("READY");return}if(u==="take_proj"){c("ACQUIRING"),await R(2e3),c("READY");return}console.log("TomoImagingSimulator: Unsupported call",u,d)}async function f(u,d){a(p=>({...p,[u]:d}))}return e.jsx(U,{name:t,alias:o,type:"tomoimaging",call:l,setProperty:f,properties:r,useHardwareContext:s})}const fu={},pu=fu;function Gt(n){return n.type==="tomosamplestage"}function mu(n){const t=E(n);return t===null||!Gt(t)?null:t}function hu(n){const{hardware:t}=n,o=t.properties.latency_time||0,s=n.disabled||!t.online,r=h.useRef(null),[a,c]=h.useState(!1),l=3;function f(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 u(d){const{value:p}=d.target;if(p===void 0)return;const m=Number.parseFloat(p);m!==o&&!a&&c(!0),m===o&&a&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):a||(r.current.value=o.toFixed(l))},[a,o]),e.jsxs(i.InputGroup,{className:"w-100",children:[e.jsx(i.Form.Control,{className:a?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:u,disabled:s,onKeyDown:f}),e.jsx(i.InputGroup.Text,{children:"s"})]})}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(e.Fragment,{}),a=e.jsx(hu,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(v,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const xu={latencytime:Bt},gu=xu;function Vt(n){return n.type==="tomoconfig"}function ju(n){const t=E(n);return t===null||!Vt(t)?null:t}function Lt(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOVING:"warning",STABILIZING:"warning",INVALID:"danger",INVALID_DETECTOR_BINNING_CHANGED:"danger",INVALID_DETECTOR_DISTANCE_CHANGED:"danger",INVALID_DETECTOR_CHANGED:"danger"},r=s[o]||s.UNKNOWN;return e.jsx(F,{state:o,minWidth:6,variant:r})}function wu(n){const{hardware:t}=n;return e.jsx(Lt,{hardware:t})}const yu={state:wu},vu=yu;function Ut(n){return n.type==="tomoholo"}function Nu(n){const t=E(n);return t===null||!Ut(t)?null:t}function bu(n){const{hardware:t}=n,o=()=>{t.actions.call("reset")};return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popover",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.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(i.Button,{disabled:n.disabled,onClick:o,children:"Reset"})})]})]}),children:e.jsx(i.Button,{className:"flex-grow-0",title:"Valve Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Ht(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(i.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(i.ButtonGroup,{className:"d-flex",children:[e.jsx(i.Button,{variant:t.properties.state==="OPEN"?"danger":"success",onClick:s,disabled:n.disabled,children:t.properties.state==="OPEN"?"Close":"Open"}),e.jsx(bu,{...n})]})})]})}const _u={default:Ht},$u=_u,Su=["close","reset","open"],Cu="rv12",Ou="rv12",Iu=!0,Mu={state:"CLOSED",status:`Pneumatic is closed
34
+ `},Tu="tango",Fu=!1,Du="valve",Au={callables:Su,id:Cu,name:Ou,online:Iu,properties:Mu,protocol:Tu,require_staff:Fu,type:Du},Ru={default:Au},Eu=Se.default("daiquiri.components.hardware.NoObject");function ku(n){if(n.options.emptyifnone)return Eu('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",a={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:a,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}function Pu(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",a={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:a,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}const Gu=Se.default("daiquiri.components.hardware.MissingObject");function Bu(n){if(n.options.emptyifnone)return Gu('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",a={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:a,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}function Vu(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,{}),a=e.jsx(i.OverlayTrigger,{trigger:["focus","hover"],placement:"bottom",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"error",style:{maxWidth:500},children:[e.jsx(i.Popover.Header,{children:"Error"}),e.jsx(i.Popover.Body,{children:e.jsx("ul",{children:e.jsx("li",{children:o})})})]}),children:e.jsxs(i.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:a,headerMode:c})}const Lu=Se.default("daiquiri.components.hardware.MissingComponentObject");function Uu(n){const{options:t}=n,{variant:o="default"}=t;if(t.emptyifnone)return Lu('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,{}),a=e.jsx(i.OverlayTrigger,{trigger:["focus","hover"],placement:"bottom",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"error",style:{maxWidth:500},children:[e.jsx(i.Popover.Header,{children:"Error"}),e.jsx(i.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(i.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:a,headerMode:c})}function Hu(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",a={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(v,{hardware:a,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}function qt(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 qu(n){return e.jsx("div",{className:"panel-header",style:n.style,children:n.children})}function zu(n){return e.jsx("div",{className:`panel-contents ${n.className}`,style:n.style,children:n.children})}function T(n){const t=n.scroll?qt:h.Fragment;return e.jsx("div",{className:`panel ${n.className??""}`,style:n.style,children:e.jsx(t,{children:n.children})})}T.Header=qu;T.Contents=zu;const de={};function zt(n,t){de[n]=t}function V(n,t,o=!0){if(!n)return e.jsx(e.Fragment,{});const{type:s}=n,r=s&&s in de?de[s]:de.component;return e.jsx(r,{yamlNode:n,panel:o},t)}function Wt(n,t){const{_parentNode:o,_indexFromParent:s,...r}=t;if(n&&Object.keys(r).length>0)throw new ue(n,Object.keys(r))}class Y extends Error{constructor(t,o){super(t),this.yamlNode=o}}class ue extends Y{constructor(t,o){super(`Unexpected keys: ${o.join(", ")}`,t),this.keys=o}}class se extends Y{constructor(t,o){super(`Keys ${o.join(", ")} are missing`,t),this.keys=o}}class O extends Y{constructor(t,o,s){super(`Key ${o} error: ${s}`,t),this.key=o,this.keyMessage=s}}function Wu(n){let t=n;for(;t._parentNode;)t=t._parentNode;return t}function Yu(n){const t=[];let o=n;for(;o;)t.push({node:o,indexFromParent:o._indexFromParent}),o=o._parentNode;return t.reverse(),t}function Yt(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((a,c)=>Yt(a,s,c))}return Object.freeze(s),s}function Ku(n,t,o){if(n&&o===void 0)throw new se(n,[t])}function De(n,t,o){if(typeof o!="string")throw new O(n,t,"A string is expected")}function Qu(n,t,o){if(typeof o!="boolean")throw new O(n,t,"A boolean is expected")}function Xu(n,t,o){if(typeof o!="number")throw new O(n,t,"A number is expected")}function fe(n,t,o){if(o!==void 0&&typeof o!="boolean")throw new O(n,t,"An optional boolean is expected")}function re(n,t,o){if(o!==void 0&&typeof o!="string")throw new O(n,t,"An optional string is expected")}function Ju(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 Zu(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 ef(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 pe(n,t,o){if(o!==void 0&&typeof o!="number")throw new O(n,t,"An optional number is expected")}function tf(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 J(n,t){const{_parentNode:o,_indexFromParent:s,...r}=t;if(n&&Object.keys(r).length>0)throw new ue(n,Object.keys(r))}function nf(n,t,o){if(o!=="last"&&typeof o!="number")throw new O(n,t,'"last" or a number is expected')}function of(n,t,o){if(o!==void 0&&o!=="h5web"&&o!=="plotly")throw new O(n,t,'"h5web" or "plotly" string is expected')}const sf=Object.freeze(Object.defineProperty({__proto__:null,assertBoolean:Qu,assertDataCollectionId:nf,assertKeyExpected:Ku,assertNoUnknownKeys:J,assertNumber:Xu,assertOptionalBackend:of,assertOptionalBoolean:fe,assertOptionalNumber:pe,assertOptionalNumberList:tf,assertOptionalString:re,assertOptionalStringList:ef,assertOptionalStringOrStringList:Zu,assertString:De,assertStringList:Ju},Symbol.toStringTag,{value:"Module"}));function Kt(n){const{providers:t={},yamlNode:o,message:s,...r}=n;return re(o,"message",s),J(o,r),e.jsx(i.Alert,{variant:"warning",className:"mb-0",children:s??"TODO"})}function Qt(n){return e.jsx(e.Fragment,{})}const rf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),af=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));function Xt(n){var t;return e.jsxs(i.Alert,{variant:"danger",children:[n.message,e.jsx("br",{}),e.jsx("pre",{children:(t=n.error)==null?void 0:t.stack})]})}function cf(n){const{error:t}=n;if(!(t instanceof Y))return e.jsx(e.Fragment,{});function o(a,c=3){const l=Yu(a.yamlNode),f=[];let u="";for(let d=1;d<l.length;d++){const{node:p,indexFromParent:m}=l[d];f.push(`${u}children:`),u+=" ".repeat(c),m===1?f.push(`${u}- type: ...`):(m??0>1)&&f.push(`${u}...`,`${u}...`,`${u}# children number ${m??0+1}`),f.push(`${u}- type: ${p.type}`),u+=" ".repeat(2)}return a instanceof ue?a.keys.forEach(d=>{f.push(`${u}${d}: ... ${" ".repeat(50-u.length-d.length)}<-- unexpected key`)}):a instanceof se?a.keys.forEach(d=>{f.push(`${u}???: ${" ".repeat(50-u.length-d.length)}<-- key **${d}** is expected`)}):a instanceof O&&f.push(`${u}${a.key}: ${" ".repeat(50-u.length-a.key.length)}<-- ${a.keyMessage}`),f.join(`
35
+ `)}const r=Wu(t.yamlNode).name;if(t instanceof ue){const a=t.keys.length===1?"key":"keys";return e.jsxs(i.Alert,{variant:"danger",children:["Unexpected ",a," ",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 se){const a=t.keys.length===1?"Key":"Keys";return e.jsxs(i.Alert,{variant:"danger",children:["Expected ",a," ",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(i.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(Xt,{...n})}const Pe={hasError:!1,message:"",error:void 0};class Jt extends h.Component{constructor(t){super(t),this.reload=()=>{window.location.reload()},this.state=Pe}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){var o,s;if(t instanceof Y||!this.props.unhandledComponentDidCatch){this.setState({hasError:!0,message:t.message,error:t});return}(s=(o=this.props).unhandledComponentDidCatch)==null||s.call(o,t,r=>{this.setState({hasError:!0,message:t.message,error:t,...r})})}componentDidUpdate(t,o){this.state.hasError&&o.error!==void 0&&t.resetKey!==this.props.resetKey&&this.setState(Pe)}render(){if(this.state.hasError){const{UnhandledErrorComponent:t}=this.props,{hasError:o,...s}=this.state;return e.jsxs(i.Container,{className:"mt-2",children:[e.jsx("h4",{children:"Something went wrong"}),this.state.error instanceof Y&&e.jsx(cf,{message:this.state.message,error:this.state.error}),!(this.state.error instanceof Y)&&e.jsx(e.Fragment,{children:t?e.jsx(t,{...s}):e.jsx(Xt,{message:this.state.message,error:this.state.error})}),e.jsxs("p",{children:["This error has been logged. Please"," ",e.jsxs(i.Button,{size:"sm",onClick:this.reload,children:[e.jsx("i",{className:"fa fa-refresh"})," Reload"]})," ","the application"]})]})}return this.props.children}}function lf({yamlNode:n,panel:t}){const{type:o,style:s,children:r,...a}=n;return J(n,a),e.jsx(i.Row,{className:"ymllayout-row gx-0",style:s,children:D.map(r,(c,l)=>V(c,l,t))})}function df({yamlNode:n,panel:t}){const{type:o,style:s,xs:r,children:a,...c}=n;return J(n,c),pe(n,"xs",r),e.jsx(i.Col,{className:P.default("yamymllayout-col",{col:!!r}),style:s,xs:r,children:D.map(n.children,(l,f)=>V(l,f,t))})}const ie={};function uf(n,t){ie[n]=t}function ff(n,t){if(t===void 0)throw new se(n,["id"]);if(typeof t.id!="string")throw new O(n,"id","A string is expected")}function pf(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{ff(n,s)}catch{throw new O(n,t,`The hardware description ${r} is wrong`)}})}}function mf(n){const{providers:t={},yamlNode:o,ids:s,groupid:r,even:a,nowrap:c,...l}=n;if(pf(o,"ids",s),re(o,"groupid",r),fe(o,"even",a),fe(o,"nowrap",c),J(o,l),!ie.HardwareGroup)return e.jsx(i.Alert,{variant:"warning",children:"No `HardwareGroup` component registered"});const f=ie.HardwareGroup;return e.jsx(f,{providers:t,ids:s,groupid:r,nowrap:c||!1,even:a||!1})}function hf(n){const{providers:t={},yamlNode:o,id:s,variant:r,header:a,width:c,colWidth:l,emptyifnone:f,...u}=n;De(o,"id",s),re(o,"variant",r),re(o,"header",a),pe(o,"width",c),pe(o,"colWidth",l),fe(o,"emptyifnone",f);const d={variant:r,header:a,width:c,colWidth:l,emptyifnone:f,...u};if(!ie.Hardware)return e.jsx(i.Alert,{variant:"warning",children:"No `Hardware` component registered"});const p=ie.Hardware;return e.jsx(p,{providers:t,id:s,options:d})}function xf(n){const{providers:t={},yamlNode:o,label:s,...r}=n;return De(o,"label",s),J(o,r),e.jsx("div",{children:s})}const me={hardwaregroup:mf,hardware:hf,todo:Kt,none:Qt,label:xf};function Zt(n,t){me[n]=t}function gf(n){Object.entries(n).forEach(([t,o])=>Zt(t,o))}function jf(n){const{yamlNode:t,panel:o}=n,{type:s,style:r,scroll:a,title:c,...l}=t;if(!(s in me))return e.jsx(T,{children:e.jsx(T.Contents,{children:e.jsxs(i.Alert,{variant:"warning",children:['Unknown component "',s,'"']})})});const f=me[t.type];return o?e.jsx(T,{style:r,scroll:a,children:e.jsxs(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:[c&&e.jsx(T.Header,{children:c}),e.jsx(T.Contents,{children:e.jsx(f,{...l,yamlNode:t})})]})}):e.jsx(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:e.jsx(f,{...l,yamlNode:t})})}function wf({yamlNode:n,panel:t}){const o=n.options||{};return e.jsx(i.Container,{className:"ymllayout-container",...o,children:D.map(n.children,(s,r)=>V(s,r,t))})}function yf(n){const{yamlNode:t}=n,o=t.options||{},s={};return o.centerContent&&(s.margin="auto"),e.jsxs(T,{className:"ymllayout-panel",...o,children:[t.title&&e.jsx(T.Header,{children:t.title}),e.jsx(T.Contents,{style:s,children:D.map(t.children,(r,a)=>V(r,a,!1))})]})}const vf=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15);function Nf({yamlNode:n,panel:t}){const o=[];return D.each(n.children,(s,r)=>{o.push(e.jsx(i.Tab,{eventKey:vf(),title:s.title,children:V(s,0,!1)},r))}),t?e.jsxs(T,{className:"ymllayout-tabs",children:[n.title&&e.jsx(T.Header,{children:n.title}),e.jsx(T.Contents,{children:e.jsx(i.Tabs,{mountOnEnter:!0,children:o})})]}):e.jsx(i.Tabs,{children:o})}function bf(n){const{node:t}=n,{type:o,title:s,...r}=t;return Wt(t,r),e.jsx("div",{className:"ymllayout-form-header",style:{gridColumn:"1 / 3"},children:e.jsx("h3",{children:s})})}function _f(n){const{node:t,state:o,row:s}=n,{title:r}=t;function a(){if(t.id)return t.id}function c(){if(r!==void 0)return r;if(t.type==="hardware"){const f=a(),u={_parentNode:t._parentNode,_indexFromParent:t._indexFromParent,type:"hardware",id:f,variant:"name",emptyifnone:!0};return V(u,"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 $f(n){const{node:t,row:o}=n,{titlealign:s,title:r,stateinheader:a=!1,variant:c,id:l,...f}=t;let u,d;if(f.type==="hardware")if(u={...f,id:l,variant:c},a){const p={...f,id:l,variant:"state",emptyifnone:!0};d=V(p,"k",!1)}else d=null;else u=f,d=null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{gridColumn:1,alignSelf:s??"center"},children:e.jsx(_f,{node:t,state:d,row:o})}),e.jsx("div",{style:{gridColumn:2,alignSelf:"center"},children:V(u,"k",!1)})]})}function Sf(n){const{yamlNode:t,panel:o}=n,{type:s,children:r,options:a={},title:c,...l}=t;return Wt(t,l),e.jsxs(T,{className:"ymllayout-form",...a,children:[t.title&&e.jsx(T.Header,{children:t.title}),e.jsx(T.Contents,{className:"full-sizer",style:{overflow:"auto"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"min-content auto"},children:D.map(r,(f,u)=>f.type==="formheader"?e.jsx(bf,{node:f,row:u},u):f.type==="none"?e.jsx(pn.default.Fragment,{},u):e.jsx($f,{node:f,row:u},u))})})]})}function Cf(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:a=1,rowSpan:c=1,...l}=s,f=a>1?`span ${a}`:void 0,u=c>1?`span ${c}`:void 0;return e.jsx("div",{className:"ymllayout-grid-cell",style:{gridColumn:f,gridRow:u},children:V(l,r,o)},r)})," "]})}const en={row:lf,col:df,container:wf,panel:yf,tabs:Nf,form:Sf,grid:Cf},tn={...en,component:jf};Object.entries(tn).forEach(([n,t])=>{zt(n,t)});function Of(n){var o;const t=h.useMemo(()=>Yt(n.layout),[n.layout]);return t.error?e.jsx("div",{className:`${n.className??""} ymllayout-main`,"data-testid":n.testid,children:e.jsxs(T,{children:[e.jsx(T.Header,{children:"Layout Error"}),e.jsxs(T.Contents,{children:[e.jsxs("p",{children:["File: ",t.name]}),e.jsx(i.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(Jt,{resetKey:t,unhandledComponentDidCatch:n.unhandledComponentDidCatch,UnhandledErrorComponent:n.UnhandledErrorComponent,children:(o=t.children)==null?void 0:o.map((s,r)=>V(s,r))})})}const If=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),nn=(n,t,o)=>{const s={">":(r,a)=>r>a,"<":(r,a)=>r<a,">=":(r,a)=>r>=a,"<=":(r,a)=>r<=a,"==":(r,a)=>r===a,"!=":(r,a)=>r!==a,in:(r,a)=>a.indexOf(r)>-1};if(n in s)return s[n](t,o)};function on(n,t,o){const s=n.split(t);return o?[s.slice(0,-o).join(t)].concat(s.slice(-o)):s}function sn(n){return n===null?null:n.startsWith("$")?(console.log(n.slice(1)),n.slice(1)):n}function Ge(n){const t=n!==void 0?on(n,".",1):[null,""],o=E(sn(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 Mf(n){const t=n!==void 0&&!n.includes("."),o=n!==void 0?on(n,".",1):[null,""],s=E(sn(o[0]));if(t)return n;if(s&&s.properties&&o[1]!==null)return`${s.properties[o[1]]}`}function rn(n){const{monitor:t}=n;let o=Ge(t.value)??"-";const s=Mf(t.unit),r=Ge(t.overlay),a=Number.parseFloat(`${o}`);Number.isNaN(a)||String(a).length>5&&(o=a.toPrecision(5));let c;if(t.comparator&&t.comparison&&(c=nn(t.comparator,o,t.comparison)?"valid":"invalid"),Number.isNaN(a)||s!==void 0&&(o=`${o} ${s}`),r){const l=`${r}`;return e.jsx(i.OverlayTrigger,{placement:"bottom",overlay:e.jsx(i.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:l.includes(`
36
+ `)?e.jsx("pre",{children:l}):l}),children:e.jsxs(i.Col,{className:"monitor-panel-item",children:[e.jsx("h1",{children:t.name}),e.jsx("div",{className:c,children:`${o}`})]})},t.name)}return e.jsxs(i.Col,{className:"monitor-panel-item",children:[e.jsx("h1",{children:t.name}),e.jsx("div",{className:c,children:`${o}`})]},t.name)}const an={hardware:rn};function Tf(n,t){an[n]=t}function Ff(n){return e.jsxs(i.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 Df(n){const t=D.map(n.monitors,(o,s)=>{const r=o.type??"hardware",a=an[r];return a===void 0?e.jsx(Ff,{monitor:o,message:`Type ${r} unsupported`},`m${s}`):e.jsx(a,{monitor:o},`m${s}`)});return e.jsx("div",{className:P.default({"ms-auto":n.margin==="start"},"me-auto","monitor-panel",{"monitor-panel-light":n.bg==="light"}),children:e.jsx(i.Container,{fluid:!0,children:e.jsx(i.Row,{className:"flex-nowrap",children:t})})})}function Af(n){return e.jsx(i.Col,{className:"monitor-panel-item",children:n.children})}exports.AirBearing=ze;exports.AirBearingMocks=Vn;exports.AirBearingProtected=We;exports.AirBearingSimulator=Ln;exports.AirBearingState=he;exports.AirBearingVariants=Tn;exports.BaseInfo=Ue;exports.BaseMocks=_n;exports.BaseName=Le;exports.BaseProperty=He;exports.BaseState=Ve;exports.BaseVariants=yn;exports.ErrorObject=Vu;exports.Formatting=Wn;exports.Frontend=Ke;exports.FrontendMocks=io;exports.FrontendVariants=Qn;exports.FullSizer=qt;exports.Gauge=Qe;exports.GaugeMocks=Io;exports.GaugeVariants=lo;exports.HWObject=If;exports.HardwareInputNumber=oe;exports.HardwareNumericStep=xe;exports.HardwareSchema=af;exports.HardwareState=$n;exports.HardwareTemplate=v;exports.HardwareTypes=rf;exports.KeyError=O;exports.Laser=Je;exports.LaserHeating=Ze;exports.LaserHeatingMocks=ts;exports.LaserHeatingVariants=qo;exports.LaserMocks=Lo;exports.LaserVariants=Fo;exports.Light=et;exports.LightMocks=ps;exports.LightVariants=os;exports.LimaBinning=rt;exports.LimaDefault=tt;exports.LimaDescription=at;exports.LimaImageRoi=it;exports.LimaMocks=hr;exports.LimaShape=ct;exports.LimaSimulator=xr;exports.LimaSize=nt;exports.LimaState=H;exports.LimaTransformation=ot;exports.LimaVariants=Cs;exports.LoadingObject=Pu;exports.MeasurementGroupDefault=dt;exports.MeasurementGroupMocks=Fr;exports.MeasurementGroupSimulator=Dr;exports.MeasurementGroupVariants=Nr;exports.MissingComponentObject=Uu;exports.MissingKeysError=se;exports.MissingObject=Bu;exports.MonitorHardware=rn;exports.MonitorPanel=Df;exports.MonitorPanelItem=Af;exports.MotorDefault=Q;exports.MotorMocks=Hi;exports.MotorSimulator=zi;exports.MotorState=je;exports.MotorText=ut;exports.MotorVariants=kr;exports.Multiposition=pt;exports.MultipositionMocks=ia;exports.MultipositionSimulator=aa;exports.MultipositionVariants=Qi;exports.NoObject=ku;exports.None=Qt;exports.NullObject=Hu;exports.NumericStep=Xe;exports.OpticDefault=ht;exports.OpticMocks=_a;exports.OpticSimulator=$a;exports.OpticState=Oe;exports.OpticVariants=ha;exports.Panel=T;exports.ProcedureExecution=xt;exports.ProcedureManage=$e;exports.ProcedureMocks=Ua;exports.ProcedureState=ae;exports.ProcedureValidate=gt;exports.ProcedureVariants=Fa;exports.PumpDefault=Nt;exports.PumpMocks=Hc;exports.PumpVariants=Ac;exports.PusherDefault=bt;exports.PusherMocks=rl;exports.PusherSimulator=il;exports.PusherState=Me;exports.PusherVariants=Kc;exports.ServiceDefault=_t;exports.ServiceMocks=yl;exports.ServiceProtected=$t;exports.ServiceState=ye;exports.ServiceVariants=dl;exports.ShutterDefault=wt;exports.ShutterMocks=sc;exports.ShutterProtected=yt;exports.ShutterSimulator=rc;exports.ShutterState=we;exports.ShutterVariants=Ya;exports.SlitDefault=vt;exports.SlitMocks=Tc;exports.SlitState=Ie;exports.SlitVariants=fc;exports.Todo=Kt;exports.TomoConfigLatencyTime=Bt;exports.TomoConfigVariants=gu;exports.TomoDetectorAcquisitionMode=Tt;exports.TomoDetectorMocks=Md;exports.TomoDetectorSamplePixelSize=Mt;exports.TomoDetectorState=Ne;exports.TomoDetectorVariants=yd;exports.TomoDetectorsDefault=Ft;exports.TomoDetectorsMocks=Hd;exports.TomoDetectorsState=Fe;exports.TomoDetectorsVariants=Ad;exports.TomoFlatMotionDefault=St;exports.TomoFlatMotionMocks=rd;exports.TomoFlatMotionSimulator=id;exports.TomoFlatMotionSmall=Ct;exports.TomoFlatMotionState=ve;exports.TomoFlatMotionVariants=Il;exports.TomoHoloState=Lt;exports.TomoHoloVariants=vu;exports.TomoImagingActions=kt;exports.TomoImagingDefault=At;exports.TomoImagingExposureTime=Rt;exports.TomoImagingMocks=du;exports.TomoImagingSettleTime=Et;exports.TomoImagingSimulator=uu;exports.TomoImagingState=K;exports.TomoImagingUpdateMode=Pt;exports.TomoImagingVariants=tu;exports.TomoReferencePositionDefault=It;exports.TomoReferencePositionVariants=ld;exports.TomoSampleStageVariants=pu;exports.TypeIcon=y;exports.ValveDefault=Ht;exports.ValveMocks=Ru;exports.ValveVariants=$u;exports.YAMLErrorBoundary=Jt;exports.YAMLLayout=Of;exports.YamlAsserts=sf;exports.componentMap=me;exports.createMotorMock=qi;exports.dynamicOp=nn;exports.isLimaHardware=ge;exports.isMotorHardware=ft;exports.isOpticHardware=pa;exports.isProcedureHardware=jt;exports.isTomoConfigHardware=Vt;exports.isTomoDetectorHardware=Te;exports.isTomoDetectorsHardware=Dt;exports.isTomoFlatMotionHardware=Ot;exports.isTomoHoloHardware=Ut;exports.isTomoReferencePositionHardware=ad;exports.isTomoSampleStageHardware=Gt;exports.limaGuessSubframes=lt;exports.registerHardwareComponent=uf;exports.registerMonitorComponent=Tf;exports.registerRuntimeHook=_s;exports.registerYamlComponent=Zt;exports.registerYamlComponents=gf;exports.registerYamlType=zt;exports.renderYamlNode=V;exports.useLimaHardware=$s;exports.useMotorHardware=k;exports.useMotorStates=Ce;exports.useProcedureHardware=Da;exports.useTomoConfigHardware=ju;exports.useTomoDetectorHardware=vd;exports.useTomoDetectorsHardware=Rd;exports.useTomoFlatMotionHardware=Ml;exports.useTomoHoloHardware=Nu;exports.useTomoSampleStageHardware=mu;exports.yamlContainers=en;exports.yamlMap=tn;
37
37
  //# sourceMappingURL=index.js.map