@wandelbots/wandelbots-js-react-components 5.6.0 → 5.6.1-pr.dev-new-nova-js-client.614.87ed9a2
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/README.md +1 -1
- package/dist/3d.cjs +1 -1
- package/dist/3d.js +1 -1
- package/dist/chunks/{MotionGroupVisualizer-Q7ifc7Kd.js → MotionGroupVisualizer-CrJO299j.js} +53 -50
- package/dist/chunks/MotionGroupVisualizer-OZwEAMLA.cjs +1 -0
- package/dist/chunks/{theming-BzdFBdeq.js → theming-CDIQLLiN.js} +671 -638
- package/dist/chunks/theming-CDWrELt_.cjs +4 -0
- package/dist/components/jogging/JoggingPanel.d.ts +5 -3
- package/dist/components/jogging/JoggingStore.d.ts +3 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/ConnectedMotionGroup.d.ts +10 -5
- package/dist/lib/JoggerConnection.d.ts +6 -3
- package/dist/lib/MotionStreamConnection.d.ts +9 -4
- package/package.json +2 -2
- package/dist/chunks/MotionGroupVisualizer-MKZ2-1oY.cjs +0 -1
- package/dist/chunks/theming-D8Twj4Yc.cjs +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),A=require("@mui/material/styles"),Ze=require("@mui/material/AppBar"),Ee=require("@mui/material/Backdrop"),v=require("@mui/material/Box"),G=require("@mui/material/IconButton"),Xe=require("@mui/material/Menu"),U=require("@mui/material/MenuItem"),Qe=require("@mui/material/Toolbar"),R=require("@mui/material/Typography"),D=require("mobx-react-lite"),h=require("react"),F=require("./externalizeComponent-OO4jcrz5.cjs"),Ke=require("@mui/material/SvgIcon"),N=require("@mui/material/Fade"),et=require("@mui/x-charts/Gauge"),B=require("react-i18next"),Q=require("./interpolation-C9sLsved.cjs"),tt=require("@mui/icons-material/Clear"),nt=require("@mui/icons-material/FilterList"),ve=require("@mui/icons-material/Search"),q=require("@mui/material/Divider"),z=require("@mui/x-data-grid"),ot=require("@mui/icons-material/OpenWith"),it=require("@mui/icons-material/Share"),_=require("@mui/material/Stack"),Pe=require("@mui/material/Tab"),_e=require("@mui/material/Tabs"),V=require("@wandelbots/nova-js/v2"),ue=require("lodash-es"),M=require("mobx"),J=require("@wandelbots/nova-js"),se=require("three/src/math/Vector3.js"),Oe=require("@mui/material/CircularProgress"),rt=require("@mui/material/utils"),at=require("./SafetyBar-VvOZ9aRM.cjs"),st=require("@mui/material/Alert"),lt=require("@mui/material/AlertTitle"),H=require("@mui/material/Button"),Te=require("@mui/material/ToggleButton"),W=require("./robot-SEtfVAmf.cjs"),ct=require("lodash-es/isEqual.js"),dt=require("@mui/material/InputAdornment"),ut=require("@mui/material/FormControl"),gt=require("@mui/material/InputLabel"),pt=require("@mui/material/Select"),te=require("lodash-es/keyBy.js"),ht=require("lodash-es/uniqueId.js"),mt=require("@mui/material/ToggleButtonGroup"),Ae=require("@mui/material/Slider"),ft=require("lodash-es/isNumber.js"),xt=require("@mui/icons-material/ChevronLeft"),bt=require("@mui/icons-material/ChevronRight"),yt=require("lodash-es/throttle.js"),St=require("@mui/material/Tooltip"),jt=require("@mui/icons-material/ContentCopy"),Ct=require("@mui/icons-material/DescriptionOutlined"),vt=require("@mui/icons-material/ExpandLess"),Tt=require("@mui/icons-material/ExpandMore"),wt=require("@mui/material/Paper"),It=require("@mui/material/Dialog"),Mt=require("@mui/material/DialogActions"),kt=require("@mui/material/DialogContent"),Rt=require("@mui/material/DialogTitle"),Et=require("@mui/icons-material/Error"),Pt=require("@mui/material/Chip"),_t=require("@mui/material/Fab"),Ot=require("@mui/material/Badge"),At=require("@mui/x-charts"),le=require("three");function Dt(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const we=Dt(le),Jt=t=>o.jsx(Ke,{...t,viewBox:"0 0 10 8",children:o.jsx("path",{d:"M8.825 0.9125L5 4.72917L1.175 0.9125L0 2.0875L5 7.0875L10 2.0875L8.825 0.9125Z",fill:"currentColor",fillOpacity:"0.56"})}),Ft=F.externalizeComponent(D.observer(t=>{const{appIcon:e,appName:n,apps:r=[],onAppSelect:a,disabled:i=!1,sx:c}=t,[s,l]=h.useState(null),d=!!s,m=u=>{l(u.currentTarget)},g=()=>{l(null)},p=u=>{g(),u.onClick?u.onClick():u.href&&(window.location.href=u.href),a==null||a(u)};return o.jsxs(o.Fragment,{children:[o.jsx(Ze,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...c},children:o.jsxs(Qe,{sx:{minHeight:"62px !important"},children:[o.jsx(v,{sx:{mr:1,display:"flex",alignItems:"center"},children:e}),o.jsxs(v,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[o.jsx(R,{component:"h1",sx:{fontWeight:"bold",fontSize:"1rem"},children:n}),r.length>0&&o.jsx(G,{color:"inherit","aria-label":"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:m,disabled:i,sx:{ml:1,width:28,height:28,borderRadius:"6px",padding:0,backgroundColor:u=>A.alpha(u.palette.common.white,.1),opacity:1,"&:hover":{backgroundColor:u=>A.alpha(u.palette.common.white,.16)},"& .MuiSvgIcon-root":{fontSize:"8px",width:"8px",height:"6px"}},children:o.jsx(Jt,{})})]})]})}),o.jsx(Ee,{open:d,onClick:g,sx:{backdropFilter:"blur(4px)",backgroundColor:"rgba(0, 0, 0, 0.3)",zIndex:u=>u.zIndex.modal-1}}),o.jsx(Xe,{id:"app-menu",anchorEl:s,open:d,onClose:g,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{zIndex:u=>u.zIndex.modal,"& .MuiPaper-root":{minWidth:200,mt:1}},children:r.map(u=>o.jsxs(U,{onClick:()=>p(u),children:[o.jsx(v,{sx:{display:"flex",alignItems:"center"},children:u.icon}),o.jsx(R,{variant:"body1",sx:{ml:2},children:u.name})]},u.id))})]})})),Bt=t=>{const e=Math.floor(t/86400),n=Math.floor(t%86400/3600),r=Math.floor(t%3600/60),a=t%60,i=[];return e>0?(i.push(e.toString()),i.push(n.toString().padStart(2,"0")),i.push(r.toString().padStart(2,"0")),i.push(a.toString().padStart(2,"0"))):n>0?(i.push(n.toString()),i.push(r.toString().padStart(2,"0")),i.push(a.toString().padStart(2,"0"))):(i.push(r.toString()),i.push(a.toString().padStart(2,"0"))),i.join(":")},$=(t,e)=>{const n=Math.floor(t/86400),r=Math.floor(t%86400/3600),a=Math.floor(t%3600/60),i=t%60;if(typeof Intl<"u"&&"DurationFormat"in Intl)try{const s={};return n>0&&(s.days=n),r>0&&(s.hours=r),a>0&&(s.minutes=a),(i>0||Object.keys(s).length===0)&&(s.seconds=i),new Intl.DurationFormat(e,{style:"narrow"}).format(s)}catch{}const c=[];return n>0&&c.push(`${n}d`),r>0&&c.push(`${r}h`),a>0&&c.push(`${a}m`),(i>0||c.length===0)&&c.push(`${i}s`),c.join(" ")},Lt=(t,e,n)=>t==="countdown"&&n!==null?Math.min(100,e/n*100):t==="measuring"?e/60%1*100:0,zt=({timerState:t,animationState:e,hasError:n,className:r})=>{const{t:a,i18n:i}=B.useTranslation(),c=A.useTheme(),{currentState:s,remainingTime:l,maxTime:d,currentProgress:m}=t,{showErrorAnimation:g,showPauseAnimation:p,showPulsatingText:u,pulsatingFinished:x,showLabels:S,showMainText:b,showIdlePulsating:f,idleDotsCount:j}=e;return o.jsxs(v,{className:r,sx:{position:"relative",width:264,height:264,display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx(et.Gauge,{width:264,height:264,value:s==="idle"?0:m,valueMin:0,valueMax:100,innerRadius:"85%",outerRadius:"100%",margin:0,skipAnimation:!0,text:()=>"",sx:{opacity:p||g?.6:1,transition:"opacity 0.5s ease-out","& .MuiGauge-valueArc":{fill:n?c.palette.error.light:c.palette.success.main,transition:"fill 0.5s ease-out"},"& .MuiGauge-referenceArc":{fill:"#171927",stroke:"transparent",strokeWidth:0,transition:"fill 0.5s ease-out, stroke 0.5s ease-out, stroke-width 0.5s ease-out"},"& .MuiGauge-valueText":{display:"none"},"& .MuiGauge-text":{display:"none"}}}),o.jsxs(v,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:225,height:225,borderRadius:"50%",backgroundColor:"#292B3F",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",gap:1,transition:"background-color 0.5s ease-out"},children:[o.jsx(v,{sx:{height:"16px",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:1},children:o.jsx(N,{in:S&&!n&&s!=="idle"&&s!=="success",timeout:300,children:o.jsx(R,{variant:"body2",sx:{fontSize:"12px",color:s==="measured"&&(u||x)?c.palette.success.main:c.palette.text.secondary,transition:"color 0.8s ease-in-out"},children:o.jsx("span",{style:{opacity:s==="measured"&&x?u?1:.6:1,transition:"opacity 2s ease-in-out"},children:s==="measuring"||s==="measured"?a("CycleTimer.CycleTime.lb","Cycle Time"):s==="countdown"?a("CycleTimer.RemainingTime.lb","Remaining Time"):""})})})}),o.jsxs(v,{sx:{position:"relative",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:.5},children:[o.jsx(N,{in:b&&s==="idle"&&!n,timeout:200,children:o.jsxs(R,{variant:"body2",sx:{position:"absolute",fontSize:"12px",fontWeight:400,color:"rgba(255, 255, 255, 0.7)",lineHeight:"166%",letterSpacing:"0.17px",textAlign:"center",width:"200px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx("span",{style:{opacity:f?1:.6,transition:"opacity 2s ease-in-out"},children:a("CycleTimer.WaitingForCycle.lb","Waiting for program cycle")}),o.jsx("span",{style:{display:"inline-block",width:"18px",textAlign:"left",opacity:f?1:.6,transition:"opacity 2s ease-in-out"},children:".".repeat(j)})]})}),o.jsx(N,{in:b&&n,timeout:200,children:o.jsx(R,{variant:"h3",sx:{position:"absolute",fontSize:"40px",fontWeight:400,color:"#FFFFFF",lineHeight:"116.7%"},children:a("CycleTimer.Error.lb","Error")})}),o.jsx(N,{in:b&&!n&&s!=="idle"&&s!=="success",timeout:300,children:o.jsx(R,{variant:"h1",sx:{position:"absolute",fontSize:"48px",fontWeight:500,color:c.palette.text.primary,lineHeight:1,transition:"color 0.8s ease-in-out"},children:o.jsx("span",{style:{opacity:1,transition:"opacity 2s ease-in-out"},children:Bt(l)})})})]}),o.jsx(v,{sx:{height:"16px",display:"flex",marginTop:.5,alignItems:"center",justifyContent:"center"},children:o.jsx(N,{in:S&&!n&&s!=="idle"&&s!=="success",timeout:300,children:o.jsx(R,{variant:"body2",sx:{fontSize:"12px",color:s==="measured"&&(u||x)?c.palette.success.main:c.palette.text.secondary,transition:"color 0.8s ease-in-out"},children:o.jsx("span",{style:{opacity:s==="measured"&&x?u?1:.6:1,transition:"opacity 2s ease-in-out"},children:s==="measuring"?a("CycleTimer.Measuring.lb","measuring..."):s==="measured"?a("CycleTimer.Determined.lb","determined"):s==="countdown"&&d!==null?a("CycleTimer.OfTime.lb",{time:$(d,i.language)}):""})})})})]})]})},$t=({timerState:t,animationState:e,hasError:n,compact:r,className:a})=>{const{t:i,i18n:c}=B.useTranslation(),s=A.useTheme(),{currentState:l,remainingTime:d,maxTime:m}=t,{showErrorAnimation:g,showPauseAnimation:p,showPulsatingText:u,pulsatingFinished:x,showIdlePulsating:S,idleDotsCount:b}=e;return r&&l==="idle"?o.jsx(v,{className:a,sx:{display:"flex",alignItems:"center",m:0},children:o.jsx(R,{variant:"body2",sx:{color:n?s.palette.error.light:s.palette.text.primary,fontSize:"14px",transition:"color 0.5s ease-out"},children:n?i("CycleTimer.Error.lb","Error"):l==="idle"?"0s":$(d,c.language)})}):o.jsxs(v,{className:a,sx:{display:"flex",alignItems:"center",m:0,gap:1},children:[!(l==="idle"&&r)&&o.jsx(v,{sx:{width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:p||g?.6:1,transition:"opacity 0.5s ease-out"},children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",style:{transform:"rotate(-90deg)"},role:"img","aria-label":"Timer progress",children:[o.jsx("circle",{cx:"10",cy:"10",r:"8",fill:"none",stroke:n?s.palette.error.light:l==="measured"?u||x?s.palette.success.main:s.palette.text.secondary:s.palette.success.main,strokeWidth:"2",opacity:l==="measured"&&x?u?1:.6:.3,style:{transition:"stroke 0.8s ease-in-out, opacity 2s ease-in-out"}}),o.jsx("circle",{cx:"10",cy:"10",r:"8",fill:"none",stroke:n?s.palette.error.light:l==="measured"?u||x?s.palette.success.main:s.palette.text.secondary:s.palette.success.main,strokeWidth:"2",strokeLinecap:"round",strokeDasharray:`${2*Math.PI*8}`,strokeDashoffset:`${2*Math.PI*8*(1-(l==="idle"?0:t.currentProgress)/100)}`,style:{opacity:l==="measured"&&x?u?1:.6:1,transition:"stroke-dashoffset 0.1s ease-out, stroke 0.8s ease-in-out, opacity 2s ease-in-out"}})]})}),o.jsx(R,{variant:"body2",sx:{color:n?s.palette.error.light:l==="idle"?"rgba(255, 255, 255, 0.7)":l==="measured"?u||x?s.palette.success.main:s.palette.text.secondary:s.palette.text.primary,fontSize:"14px",lineHeight:"normal",letterSpacing:"normal",opacity:l==="idle"?S?1:.6:l==="measured"&&x?u?1:.6:1,transition:"color 0.8s ease-in-out, font-size 0.3s ease-out, opacity 2s ease-in-out"},children:n?i("CycleTimer.Error.lb","Error"):l==="idle"?o.jsxs(o.Fragment,{children:[o.jsx("span",{children:i("CycleTimer.WaitingForCycle.lb","Waiting for program cycle")}),o.jsx("span",{style:{display:"inline-block",width:"18px",textAlign:"left"},children:".".repeat(b)})]}):l==="measuring"?r?$(d,c.language):`${$(d,c.language)} / ${i("CycleTimer.Measuring.lb","measuring...")}`:l==="measured"?r?$(d,c.language):`${$(d,c.language)} / ${i("CycleTimer.Determined.lb","determined")}`:l==="countdown"&&m!==null?r?$(d,c.language):`${$(d,c.language)} / ${i("CycleTimer.Time.lb",{time:$(m,c.language)})}`:$(d,c.language)})]})},Vt=()=>{const[t,e]=h.useState({showPauseAnimation:!1,showErrorAnimation:!1,showPulsatingText:!1,pulsatingFinished:!1,showLabels:!0,showMainText:!0,showIdlePulsating:!1,idleDotsCount:0}),n=h.useRef(null),r=h.useRef(null),a=h.useRef(null),i=h.useRef(null),c=h.useRef(0),s=h.useRef(null),l=h.useRef(null),d=h.useCallback(()=>{e(y=>({...y,showPauseAnimation:!0})),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{e(y=>({...y,showPauseAnimation:!1}))},800)},[]),m=h.useCallback(()=>{e(y=>({...y,showErrorAnimation:!0})),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{e(y=>({...y,showErrorAnimation:!1}))},600)},[]),g=h.useCallback(()=>{e(y=>({...y,showErrorAnimation:!1})),r.current&&clearTimeout(r.current)},[]),p=h.useCallback(y=>{c.current=0,e(T=>({...T,showPulsatingText:!0,pulsatingFinished:!1})),setTimeout(()=>{e(T=>({...T,pulsatingFinished:!0})),a.current=setInterval(()=>{e(T=>({...T,showPulsatingText:!T.showPulsatingText}))},2e3),y&&y()},800)},[]),u=h.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),e(y=>({...y,showPulsatingText:!1,pulsatingFinished:!1})),c.current=0},[]),x=h.useCallback(()=>{e(y=>({...y,showIdlePulsating:!0})),s.current=setInterval(()=>{e(y=>({...y,showIdlePulsating:!y.showIdlePulsating}))},2e3),l.current=setInterval(()=>{e(y=>({...y,idleDotsCount:(y.idleDotsCount+1)%4}))},800)},[]),S=h.useCallback(()=>{s.current&&(clearInterval(s.current),s.current=null),l.current&&(clearInterval(l.current),l.current=null),e(y=>({...y,showIdlePulsating:!1,idleDotsCount:0}))},[]),b=h.useCallback(()=>{e(y=>({...y,showLabels:!1,showMainText:!1})),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{e(y=>({...y,showLabels:!0,showMainText:!0}))},200)},[]),f=h.useCallback(()=>{e(y=>({...y,showLabels:!0,showMainText:!0}))},[]),j=h.useCallback(()=>{n.current&&clearTimeout(n.current),r.current&&clearTimeout(r.current),i.current&&clearTimeout(i.current),a.current&&clearInterval(a.current),s.current&&clearInterval(s.current),l.current&&clearInterval(l.current)},[]);return{animationState:t,triggerPauseAnimation:d,triggerErrorAnimation:m,clearErrorAnimation:g,startPulsatingAnimation:p,stopPulsatingAnimation:u,startIdleAnimations:x,stopIdleAnimations:S,triggerFadeTransition:b,setInitialAnimationState:f,cleanup:j}},qt=({autoStart:t,onCycleEnd:e,onMeasuringComplete:n,hasError:r,onPauseAnimation:a,onErrorAnimation:i,onClearErrorAnimation:c,onStartPulsating:s})=>{const[l,d]=h.useState({currentState:"idle",remainingTime:0,maxTime:null,isRunning:!1,isPausedState:!1,currentProgress:0,wasRunningBeforeError:!1}),m=h.useRef(null),g=h.useRef(null),p=h.useRef(0),[u]=Q.useInterpolation([0],{tension:80,friction:18,onChange:([C])=>{d(w=>({...w,currentProgress:C}))}}),x=h.useCallback(()=>{d(C=>({...C,currentState:"idle",maxTime:null,isRunning:!1,isPausedState:!1,currentProgress:0})),p.current=0,g.current=null,u.setImmediate([0])},[u]),S=h.useCallback((C=0)=>{const w=C/60%1*100;d(k=>({...k,currentState:"measuring",maxTime:null,remainingTime:C,isPausedState:!1,currentProgress:w})),p.current=0,u.setImmediate([w]),t?(g.current=Date.now()-C*1e3,d(k=>({...k,isRunning:!0}))):g.current=null},[t,u]),b=h.useCallback((C,w=0)=>{d(I=>({...I,isRunning:!1})),g.current=null,d(I=>({...I,currentState:"countdown",maxTime:C,isPausedState:!1})),p.current=0;const k=Math.max(0,C-w),E=w>0?w/C*100:0;d(I=>({...I,remainingTime:k,currentProgress:E})),u.setImmediate([E]),k===0?(d(I=>({...I,isRunning:!1})),g.current=null,e&&queueMicrotask(()=>e())):t?setTimeout(()=>{g.current=Date.now()-w*1e3,d(I=>({...I,isRunning:!0}))},0):g.current=null},[t,e,u]),f=h.useCallback(()=>{d(C=>({...C,isRunning:!1,currentState:"measured"})),g.current=null,s(()=>{n&&n()})},[s,n]),j=h.useCallback(()=>{if(g.current&&l.isRunning){const w=Date.now()-g.current;p.current+=w;const k=p.current/1e3,E=Lt(l.currentState,k,l.maxTime);u.setTarget([E])}d(C=>({...C,isRunning:!1,isPausedState:!0})),a()},[l.isRunning,l.currentState,l.maxTime,u,a]),y=h.useCallback(()=>{l.isPausedState&&(l.remainingTime>0||l.currentState!=="countdown")&&(g.current=Date.now(),d(C=>({...C,isRunning:!0,isPausedState:!1})))},[l.isPausedState,l.remainingTime,l.currentState]),T=h.useCallback(()=>l.isPausedState,[l.isPausedState]);return h.useEffect(()=>{r?(l.isRunning&&!l.isPausedState&&(d(C=>({...C,wasRunningBeforeError:!0})),j()),i()):(l.wasRunningBeforeError&&l.isPausedState&&(d(C=>({...C,wasRunningBeforeError:!1})),y()),c())},[r,l.isRunning,l.isPausedState,l.wasRunningBeforeError,j,y,i,c]),h.useEffect(()=>{if(l.isRunning){const C=()=>{if(g.current){const k=(Date.now()-g.current+p.current)/1e3;if(l.currentState==="countdown"&&l.maxTime!==null){const E=Math.max(0,l.maxTime-k);d(P=>({...P,remainingTime:Math.ceil(E)}));const I=Math.min(100,k/l.maxTime*100);if(u.setTarget([I]),E<=0){d(P=>({...P,isRunning:!1,remainingTime:0})),g.current=null,u.setTarget([100]),e&&queueMicrotask(()=>e());return}}else if(l.currentState==="measuring"){d(I=>({...I,remainingTime:Math.floor(k)}));const E=k/60%1*100;u.setTarget([E])}l.isRunning&&(m.current=requestAnimationFrame(C))}};m.current=requestAnimationFrame(C)}else m.current&&(cancelAnimationFrame(m.current),m.current=null);return()=>{m.current&&cancelAnimationFrame(m.current)}},[l.isRunning,e,l.currentState,l.maxTime,u]),h.useEffect(()=>{let C=null;const w=()=>{u.update(1/60),C=requestAnimationFrame(w)};return C=requestAnimationFrame(w),()=>{C&&cancelAnimationFrame(C)}},[u]),{timerState:l,controls:{startNewCycle:b,startMeasuring:S,setIdle:x,completeMeasuring:f,pause:j,resume:y,isPaused:T}}},Nt=F.externalizeComponent(D.observer(({onCycleComplete:t,onCycleEnd:e,onMeasuringComplete:n,autoStart:r=!0,variant:a="default",compact:i=!1,className:c,hasError:s=!1})=>{const l=h.useRef(void 0),{animationState:d,triggerPauseAnimation:m,triggerErrorAnimation:g,clearErrorAnimation:p,startPulsatingAnimation:u,stopPulsatingAnimation:x,startIdleAnimations:S,stopIdleAnimations:b,triggerFadeTransition:f,setInitialAnimationState:j,cleanup:y}=Vt(),{timerState:T,controls:C}=qt({autoStart:r,onCycleEnd:e,onMeasuringComplete:n,hasError:s,onPauseAnimation:m,onErrorAnimation:g,onClearErrorAnimation:p,onStartPulsating:u});return h.useEffect(()=>{const w=l.current;l.current!==void 0&&w!==T.currentState?(w==="measured"&&x(),w==="idle"&&b(),f()):j(),T.currentState==="idle"&&S(),l.current=T.currentState},[T.currentState,x,b,S,f,j]),h.useEffect(()=>{let w=!0;const k=setTimeout(()=>{w&&t(C)},0);return()=>{w=!1,clearTimeout(k)}},[t,C]),h.useEffect(()=>y,[y]),a==="small"?o.jsx($t,{timerState:T,animationState:d,hasError:s,compact:i,className:c}):o.jsx(zt,{timerState:T,animationState:d,hasError:s,className:c})})),De=F.externalizeComponent(D.observer(({data:t,columns:e,getRowData:n,onRowClick:r,selectedItem:a,getItemId:i,title:c,showCount:s=!0,searchPlaceholder:l="Search programs",dataGridProps:d,CustomToolbar:m,selectFirstByDefault:g=!1,sx:p})=>{var E;const u=A.useTheme(),x=z.useGridApiRef(),S=h.useRef(null),[b,f]=h.useState(null),j=h.useMemo(()=>t.map(n),[t,n]);h.useEffect(()=>{x.current&&j.length>0&&x.current.autosizeColumns({includeOutliers:!0,includeHeaders:!0,expand:!0,columns:e.map(I=>I.field)})},[j,e,x]),h.useEffect(()=>{if(!S.current||!x.current)return;const I=new ResizeObserver(()=>{setTimeout(()=>{x.current&&j.length>0&&x.current.autosizeColumns({includeOutliers:!0,includeHeaders:!0,expand:!0,columns:e.map(P=>P.field)})},100)});return I.observe(S.current),()=>{I.disconnect()}},[x,j.length,e]);const y=h.useMemo(()=>{if(a!==void 0)return a;if(b!==null)return b;if(g&&t.length>0){const I=t[0];return f(I),I}return null},[g,t,a,b]),T=I=>{const P=t.find(L=>n(L).id===I.id);P&&(a===void 0&&f(P),r&&r(P,I))},C=h.useMemo(()=>!y||!i?null:i(y),[y,i]);function w(){return o.jsx(z.Toolbar,{children:o.jsxs(v,{sx:{display:"flex",width:"100%",gap:1,p:.5,alignItems:"center"},children:[c&&o.jsxs(R,{variant:"h6",sx:{fontWeight:500,color:"white"},children:[c,s&&` (${t.length})`]}),o.jsxs(v,{sx:{ml:"auto",display:"flex",gap:.5,alignItems:"center",pr:1},children:[o.jsx(z.FilterPanelTrigger,{render:o.jsx(z.ToolbarButton,{"aria-label":"Show filters",children:o.jsx(nt,{fontSize:"small"})})}),o.jsx(q,{orientation:"vertical",flexItem:!0,sx:{height:"24px",alignSelf:"center"}}),o.jsx(z.QuickFilter,{render:(I,P)=>o.jsxs(v,{...I,sx:{display:"flex",overflow:"hidden"},children:[!P.expanded&&o.jsx(z.QuickFilterTrigger,{render:o.jsx(z.ToolbarButton,{"aria-label":"Search",children:o.jsx(ve,{fontSize:"small"})})}),o.jsxs(v,{sx:{display:"flex",overflow:"hidden",transition:"all 0.3s ease-in-out",width:P.expanded?"200px":"0px",position:"relative"},children:[o.jsxs(v,{sx:{flex:1,position:"relative","& .MuiInputBase-root":{height:"32px",borderRadius:"16px",backgroundColor:"#171927",paddingLeft:"40px",paddingRight:P.expanded&&P.value!==""?"40px":"12px",color:"white",fontSize:"14px",border:"none !important",outline:"none !important",boxShadow:"none !important","&::before":{display:"none !important",border:"none !important"},"&::after":{display:"none !important",border:"none !important"},"&:hover":{"&::before":{display:"none !important",border:"none !important"},"&::after":{display:"none !important",border:"none !important"}},"&:focus-within":{outline:"none !important",boxShadow:"none !important","&::before":{display:"none !important",border:"none !important"},"&::after":{display:"none !important",border:"none !important"}},"&.Mui-focused":{outline:"none !important",boxShadow:"none !important","&::before":{display:"none !important",border:"none !important"},"&::after":{display:"none !important",border:"none !important"}},"& .MuiInputBase-input":{padding:"8px 0",border:"none !important",outline:"none !important",boxShadow:"none !important","&:focus":{outline:"none !important",boxShadow:"none !important",border:"none !important"},"&::placeholder":{color:"rgba(255, 255, 255, 0.3)",opacity:1}},"& fieldset":{border:"none !important",display:"none !important"},"& .MuiOutlinedInput-notchedOutline":{border:"none !important",display:"none !important"}}},children:[P.expanded&&o.jsx(ve,{fontSize:"small",sx:{position:"absolute",left:"12px",top:"50%",transform:"translateY(-50%)",color:"rgba(255, 255, 255, 0.6)",zIndex:1,pointerEvents:"none"}}),o.jsx(z.QuickFilterControl,{placeholder:l})]}),P.expanded&&P.value!==""&&o.jsx(z.QuickFilterClear,{render:o.jsx(v,{sx:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",zIndex:1},children:o.jsx(v,{sx:{minWidth:"24px",width:"24px",height:"24px",padding:0,color:"rgba(255, 255, 255, 0.6)","&:hover":{backgroundColor:"rgba(255, 255, 255, 0.1)"}},children:o.jsx(z.ToolbarButton,{"aria-label":"Clear",children:o.jsx(tt,{fontSize:"small"})})})})})]})]})})]})]})})}const k=m||w;return o.jsx(v,{ref:S,sx:{height:"100%",display:"flex",flexDirection:"column","& *":{scrollbarWidth:"none",msOverflowStyle:"none","&::-webkit-scrollbar":{display:"none"}},"&:hover *":{scrollbarWidth:"thin",scrollbarColor:`${u.palette.divider} transparent`,"&::-webkit-scrollbar":{display:"block",width:"8px",height:"8px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:u.palette.divider,borderRadius:"4px"},"&::-webkit-scrollbar-thumb:hover":{background:u.palette.action.hover}},...p},children:o.jsx(z.DataGrid,{apiRef:x,rows:j,columns:e,onRowClick:T,disableColumnMenu:!1,disableRowSelectionOnClick:!0,disableMultipleRowSelection:!0,hideFooterSelectedRowCount:!0,filterMode:"client",sortingOrder:["desc","asc"],hideFooter:!1,showToolbar:!0,slots:{toolbar:k},initialState:{sorting:{sortModel:[]},filter:{filterModel:{items:[]}},...d==null?void 0:d.initialState},...d,autosizeOnMount:!0,autosizeOptions:{...(d==null?void 0:d.autosizeOptions)||{},includeOutliers:!0,includeHeaders:!0,expand:!0,columns:((E=d==null?void 0:d.autosizeOptions)==null?void 0:E.columns)||e.map(I=>I.field)},sx:{border:"none",width:"100%","& .MuiPaper-root":{boxShadow:"none !important"},"& .MuiDataGrid-overlay":{},"& .MuiDataGrid-main":{border:"none","& .MuiPaper-root":{}},"& .MuiDataGrid-container--top [role=row]":{},"& .MuiDataGrid-topContainer":{borderBottom:"none !important"},"& .MuiDataGrid-columnHeaders":{border:"none",borderBottom:"none !important"},"& .MuiDataGrid-row":{cursor:r?"pointer":"default",border:"none",margin:"1px 0",position:"relative",backgroundColor:"transparent !important","&:hover":{backgroundColor:"transparent !important","&::before":{content:'""',position:"absolute",top:0,left:"16px",right:"16px",bottom:0,backgroundColor:"action.hover",borderRadius:"16px",zIndex:0}},"&.Mui-selected":{backgroundColor:"transparent !important","&:hover":{backgroundColor:"transparent !important"}},...C!==null&&{[`&[data-id="${C}"]`]:{backgroundColor:"transparent !important","&::before":{content:'""',position:"absolute",top:0,left:"16px",right:"16px",bottom:0,backgroundColor:"rgba(255, 255, 255, 0.08) !important",borderRadius:"16px",zIndex:0},"&:hover":{backgroundColor:"transparent !important"},"&:hover::before":{backgroundColor:"rgba(255, 255, 255, 0.12) !important"}}}},"& .MuiDataGrid-cell--textLeft":{paddingLeft:"40px"},"& .MuiDataGrid-cell":{border:"none",position:"relative",zIndex:1,"&:focus":{outline:"none"},"&:focus-within":{outline:"none"},"&:hover":{backgroundColor:"transparent !important"}},"& .MuiDataGrid-columnHeader":{border:"none",paddingLeft:"40px",paddingRight:"40px","& .MuiDataGrid-columnHeaderTitle":{color:"rgba(255, 255, 255, 0.6)"}},"& .MuiDataGrid-toolbarContainer":{padding:"8px",border:"none !important",borderBottom:"none !important","& .MuiBox-root":{},"& .MuiFormControl-root":{},"& .MuiInputBase-root":{},"& .MuiPaper-root":{boxShadow:"none !important"},"& *":{borderBottom:"none !important"}},"& .MuiDataGrid-toolbar":{borderBottom:"none !important"},"& .MuiDataGrid-toolbarFilterList":{border:"none"},"& .MuiDataGrid-withBorderColor":{borderColor:"transparent !important"},"& .MuiDataGrid-columnSeparator":{display:"none"},"& .MuiDataGrid-footerContainer":{display:"none"},"& .MuiDataGrid-filler":{border:"none !important",borderTop:"none !important",borderBottom:"none !important",borderLeft:"none !important",borderRight:"none !important","--rowBorderColor":"none !important"},"& .MuiBackdrop-root":{},"& .MuiModal-backdrop":{},...d==null?void 0:d.sx}})})}));De.displayName="WandelbotsDataGrid";const ce=F.externalizeComponent(D.observer(({colors:t,label:e,getDisplayedValue:n,startJogging:r,stopJogging:a,disabled:i,activeJoggingDirection:c,...s})=>{var y,T,C,w,k,E,I;Q.useAnimationFrame(()=>{const P=n(),L=p.current;L&&(L.textContent=P)});const l=A.useTheme(),[d,m]=h.useState(null);h.useEffect(()=>{i&&j()},[i]);const g=c||d,p=h.useRef(null);t||(t={color:"#fff",backgroundColor:"#000",borderColor:"#000",buttonBackgroundColor:{disabled:"#000",default:"#000",hovered:"#000",pressed:"#000"},labelColor:"#000"});const u=g?(y=t.buttonBackgroundColor)==null?void 0:y.pressed:t.borderColor,x={width:"55px",color:t.color,path:{fill:t.color},alignContent:"center",fontSize:"37px",svg:{pointerEvents:"none"}},S={...x,backgroundColor:(T=t.buttonBackgroundColor)==null?void 0:T.default,":hover":{backgroundColor:(C=t.buttonBackgroundColor)==null?void 0:C.hovered},":active":{backgroundColor:(w=t.buttonBackgroundColor)==null?void 0:w.pressed,color:t.backgroundColor,path:{fill:t.backgroundColor}},":disabled":{backgroundColor:(k=t.buttonBackgroundColor)==null?void 0:k.disabled,"svg path":{fill:l.palette.action.disabled}}},b={...x,backgroundColor:(E=t.buttonBackgroundColor)==null?void 0:E.pressed,color:t.backgroundColor,path:{fill:t.backgroundColor},":disabled":{backgroundColor:(I=t.buttonBackgroundColor)==null?void 0:I.pressed,"svg path":{fill:l.palette.action.disabled}}};function f(P,L){i||P.button===0&&(m(L),r(L))}function j(){m(null),a()}return o.jsxs(_,{height:"64px",direction:"row",justifyContent:"center",...s,children:[o.jsx(G,{disabled:i,disableRipple:!0,onPointerDown:P=>f(P,"-"),onPointerUp:j,onPointerOut:j,size:"large",sx:{...g==="-"?b:S,borderRadius:"16px 0px 0px 16px",borderLeft:`2px solid ${u??"#fff"}`,borderBottom:`2px solid ${u??"#fff"}`,borderTop:`2px solid ${u??"#fff"}`},children:o.jsx(W.ForwardRef$3,{})}),o.jsxs(_,{spacing:"6px",sx:{width:"150px",backgroundColor:t.backgroundColor,alignItems:"center",justifyContent:"center",opacity:"0.9",borderBottom:`2px solid ${u??"#fff"}`,borderTop:`2px solid ${u??"#fff"}`},children:[o.jsx(_,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:t.color,".MuiTypography-root":{fontWeight:700,...i?{color:l.palette.action.disabled}:{}},...i?{"svg path":{fill:l.palette.action.disabled}}:{}},children:e}),o.jsx(R,{height:"22px",sx:{fontSize:"15px",color:i?l.palette.action.disabled:t.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:p,children:n()})]}),o.jsx(G,{disableRipple:!0,disabled:i,onPointerDown:P=>f(P,"+"),onPointerUp:j,onPointerOut:j,size:"large",sx:{...g==="+"?b:S,borderRadius:"0px 16px 16px 0px",borderRight:`2px solid ${u??"#fff"}`,borderBottom:`2px solid ${u??"#fff"}`,borderTop:`2px solid ${u??"#fff"}`},children:o.jsx(W.ForwardRef$4,{})})]})})),Je=F.externalizeComponent(D.observer(({startJogging:t,stopJogging:e,lowerLimit:n,upperLimit:r,useDegree:a,getValue:i,disabled:c,...s})=>{var w,k,E,I,P,L,Y,ee,fe,xe,be,ye,Se,je,Ce;const{t:l}=B.useTranslation(),[d,m]=h.useState(),g=A.useTheme(),p={background:(w=g.palette.backgroundPaperElevation)==null?void 0:w[4],color:(k=g.palette.backgroundPaperElevation)==null?void 0:k[11]},u=D.useLocalObservable(()=>({activeJoggingDir:null,startJogging(O){this.activeJoggingDir=O,t(O)},stopJogging(){this.activeJoggingDir=null,e()}})),x=yt(()=>{const O=a?S(i()):i();(O===void 0||d===void 0||Math.abs(d-O)>1e-9)&&m(O)},50);Q.useAnimationFrame(x);function S(O){if(O!==void 0)return J.radiansToDegrees(O)}function b(O){O.button===0&&u.startJogging("-")}function f(O){O.button===0&&u.startJogging("+")}function j(O){u.stopJogging()}function y(O){u.stopJogging()}function T(O,Z=1){if(O===void 0||Number.isNaN(O))return"";const X=l("General.degree.variable",{amount:O.toFixed(Z)});return O>0&&Z===0?`+${X}`:X}function C(O,Z=1){if(O===void 0||Number.isNaN(O))return"";const X=l("General.mm.variable",{amount:O.toFixed(Z)});return O>0&&Z===0?`+${X}`:X}return o.jsxs(_,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...s,sx:{"& .MuiIconButton-root":{width:"52px",color:g.palette.text.primary,alignContent:"center",backgroundColor:(E=g.palette.backgroundPaperElevation)==null?void 0:E[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:(I=g.palette.backgroundPaperElevation)==null?void 0:I[11],color:g.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(P=g.palette.backgroundPaperElevation)==null?void 0:P[9]},"&:active":{...p}}},children:[o.jsx(G,{onPointerDown:b,onPointerUp:j,onPointerOut:y,disabled:c,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...u.activeJoggingDir==="-"?p:{}},children:o.jsx(xt,{sx:{pointerEvents:"none",color:(fe=(ee=(Y=(L=g.componentsExt)==null?void 0:L.JoggingPanel)==null?void 0:Y.JoggingJoint)==null?void 0:ee.Joint)==null?void 0:fe.arrowColor}})}),o.jsxs(_,{flexGrow:1,alignItems:"center",justifyContent:"center",sx:{borderStyle:"solid",borderLeftWidth:0,borderRightWidth:0,border:"none",backgroundColor:(xe=g.palette.backgroundPaperElevation)==null?void 0:xe[11],paddingLeft:"20px",paddingRight:"20px",zIndex:1},children:[o.jsx(R,{sx:{fontSize:"15px",fontWeight:700,position:"relative",top:"5px",fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center",color:c?g.palette.action.disabled:g.palette.text.primary},children:a?T(d):C(d)}),o.jsx(Ae,{disabled:!0,"aria-label":"Joint position",min:a?S(n):n,max:a?S(r):r,value:d||0,track:!1,sx:{"& .MuiSlider-mark":{display:"none"},"& .MuiSlider-thumb":{width:"5px",height:"12px",borderRadius:"2px",color:c?g.palette.action.disabled:g.palette.text.primary},"& .MuiSlider-markLabel":{top:"20px",fontSize:"12px",color:c?g.palette.action.disabled:g.palette.text.secondary},"& .MuiSlider-rail":{backgroundColor:(be=g.palette.backgroundPaperElevation)==null?void 0:be[5],opacity:1}},marks:n!==void 0&&r!==void 0&&[{value:a?S(n):n,label:a?T(S(n),0):C(n)},{value:a?S(r):r,label:a?T(S(r),0):C(r)}]})]}),o.jsx(G,{onPointerDown:f,onPointerUp:j,onPointerOut:y,disabled:c,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...u.activeJoggingDir==="+"?p:{}},children:o.jsx(bt,{sx:{pointerEvents:"none",color:(Ce=(je=(Se=(ye=g.componentsExt)==null?void 0:ye.JoggingPanel)==null?void 0:Se.JoggingJoint)==null?void 0:je.Joint)==null?void 0:Ce.arrowColor}})})]})}));function ge(t,e,n){if(e.length!==t.length)return!0;for(let r=0;r<e.length;r++)if(Math.abs(e[r]-t[r])>n)return!1;return!0}function Fe(t,e,n){if(t===void 0&&e||t&&e===void 0||(t==null?void 0:t.orientation)===void 0||(e==null?void 0:e.orientation)===void 0||(t==null?void 0:t.position)===void 0||(e==null?void 0:e.position)===void 0)return!1;if(t===void 0||e===void 0)return!0;let r=0;return r+=Math.abs(t.orientation[0]-e.orientation[0]),r+=Math.abs(t.orientation[1]-e.orientation[1]),r+=Math.abs(t.orientation[2]-e.orientation[2]),r+=Math.abs(t.position[0]-e.position[0]),r+=Math.abs(t.position[1]-e.position[1]),r+=Math.abs(t.position[2]-e.position[2]),r<=n}function pe(t,e,n){return t.coordinate_system===e.coordinate_system&&t.tcp===e.tcp&&Fe(t.tcp_pose,e.tcp_pose,n)}function Be(t,e){const n=new le.Vector3(e[0],e[1],e[2]),r=new le.Vector3(t[0],t[1],t[2]),a=n.length(),i=n.normalize();let c=r.length(),s=r.normalize();s.dot(i)<0&&(c=-c,s=s.multiplyScalar(-1));let l=c-a;return l-=2*Math.PI*Math.floor((l+Math.PI)/(2*Math.PI)),c=a+l,[...s.multiplyScalar(c)]}const Ie=1e-4;class ie{constructor(e,n,r,a,i,c,s){this.nova=e,this.cellId=n,this.controller=r,this.motionGroup=a,this.description=i,this.initialMotionState=c,this.motionStateSocket=s,this.rapidlyChangingMotionState=c,s.addEventListener("message",l=>{var p;const d=(p=J.tryParseJson(l.data))==null?void 0:p.result;if(!d)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${l.data}`);ge(this.rapidlyChangingMotionState.joint_position,d.joint_position,Ie)||M.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=d.joint_position}),pe(this.rapidlyChangingMotionState,d,Ie)||M.runInAction(()=>{var u,x,S;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=d.tcp_pose:(u=d.tcp_pose)!=null&&u.orientation&&((x=d.tcp_pose)!=null&&x.position)&&((S=this.rapidlyChangingMotionState.tcp_pose)!=null&&S.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:d.tcp_pose.position,orientation:Be(d.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:console.warn("Received incomplete tcp_pose, ignoring",d.tcp_pose)}),d.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==d.tcp&&M.runInAction(()=>{this.rapidlyChangingMotionState.tcp=d.tcp}),this.rapidlyChangingMotionState.standstill!==d.standstill&&M.runInAction(()=>{this.rapidlyChangingMotionState.standstill=d.standstill});const m=this.rapidlyChangingMotionState.joint_limit_reached.limit_reached,g=d.joint_limit_reached.limit_reached;m.some((u,x)=>u!==g[x])&&M.runInAction(()=>{this.rapidlyChangingMotionState.joint_limit_reached=d.joint_limit_reached}),this.rapidlyChangingMotionState.execute!==d.execute&&M.runInAction(()=>{this.rapidlyChangingMotionState.execute=d.execute})}),M.makeAutoObservable(this)}static async open(e,n,r={}){var u;const a=r.cellId??"cell",[i,c]=n.split("@"),s=await e.api.controller.getCurrentRobotControllerState(a,c),l=s==null?void 0:s.motion_groups.find(x=>x.motion_group===n);if(!s||!l)throw new Error(`Controller ${c} or motion group ${n} not found`);const d=e.openReconnectingWebsocket(`/cells/${a}/controllers/${c}/motion-groups/${n}/state-stream`),m=await d.firstMessage(),g=(u=J.tryParseJson(m.data))==null?void 0:u.result;if(!g)throw new Error(`Unable to parse initial motion state message ${m.data}`);console.log(`Connected motion state websocket to motion group ${l.motion_group}. Initial state:
|
|
2
|
+
`,g);const p=await e.api.motionGroup.getMotionGroupDescription(a,c,l.motion_group);return new ie(e,a,s,l,p,g,d)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get joints(){return this.initialMotionState.joint_position.map((e,n)=>({index:n}))}dispose(){this.motionStateSocket.close()}}const Me="Movement request rejected. Another client is currently executing a 'Jogging' motion!";class re{constructor(e,n={}){this.motionStream=e,this.options=n,this.DEFAULT_MODE="off",this.DEFAULT_TCP="Flange",this.NO_TCP=void 0,this.DEFAULT_INIT_TIMEOUT=5e3,this.DEFAULT_ORIENTATION="coordsys",this.mode="off",this.joggingSocket=null,this.trajectorySocket=null,this.timeout=this.DEFAULT_INIT_TIMEOUT,this.tcp=(n==null?void 0:n.tcp)||e.motionGroup.tcp||this.getDefaultTcp(e),this.orientation=(n==null?void 0:n.orientation)||this.DEFAULT_ORIENTATION,this.timeout=(n==null?void 0:n.timeout)||this.DEFAULT_INIT_TIMEOUT,this.mode=(n==null?void 0:n.mode)||this.DEFAULT_MODE,this.onError=n==null?void 0:n.onError}static async open(e,n,r={}){const a=await ie.open(e,n,{cellId:r.cellId}),i=new re(a,r);return await i.setJoggingMode(i.mode),i}getDefaultTcp(e){var r,a;const n=(a=(r=e.description.dh_parameters)==null?void 0:r[0])==null?void 0:a.type;return e.joints.length<6&&(n===V.JointTypeEnum.RevoluteJoint||n===V.JointTypeEnum.PrismaticJoint)?this.NO_TCP:this.DEFAULT_TCP}async setOptions(e){e.tcp&&(this.tcp=e.tcp),e.orientation&&(this.orientation=e.orientation),e.timeout&&(this.timeout=e.timeout),e.mode&&(this.mode=e.mode),e.onError&&(this.onError=e.onError),this.setJoggingMode(this.mode,!1)}get motionGroupId(){return this.motionStream.motionGroupId}get nova(){return this.motionStream.nova}get cellId(){return this.motionStream.cellId}get numJoints(){return this.motionStream.joints.length}async stop(){if(this.joggingSocket){const e=new Array(this.numJoints).fill(0);this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:e})}this.trajectorySocket&&this.trajectorySocket.sendJson({message_type:"PauseMovementRequest"})}async dispose(){const e=[this.joggingSocket,this.trajectorySocket].filter(n=>n!==null);return e.forEach(n=>{n.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(e.map(n=>n.closed()))}async setJoggingMode(e,n=!0){if(!(this.mode===e&&n)&&(this.dispose(),this.mode=e,this.mode==="jogging"))return this.initializeJoggingWebsocket()}async initializeJoggingWebsocket(){return new Promise((e,n)=>{const r=setTimeout(()=>{n(new Error(`Jogging initialization timeout after ${this.timeout} seconds`))},this.timeout);this.joggingSocket=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`),this.joggingSocket.addEventListener("message",a=>{var c,s,l,d;const i=J.tryParseJson(a.data);if(((c=i==null?void 0:i.result)==null?void 0:c.kind)==="INITIALIZE_RECEIVED"){clearTimeout(r),e();return}if(((s=i==null?void 0:i.result)==null?void 0:s.kind)==="MOTION_ERROR")if(clearTimeout(r),this.onBlocked&&((l=i==null?void 0:i.result)!=null&&l.message.includes(Me))){(d=this.joggingSocket)==null||d.dispose(),this.onBlocked();return}else this.onError?this.onError(a.data):n(new Error(a.data))}),this.joggingSocket.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:e,direction:n,velocityValue:r,velocityUnit:a}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'");const i=new Array(this.numJoints).fill(0);i[e]=n==="-"?-r:r,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:i})}async translateTCP({axis:e,direction:n,velocityMmPerSec:r}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const a=[0,0,0],i=[0,0,0];i[J.XYZ_TO_VECTOR[e]]=n==="-"?-r:r,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:i,rotation:a,use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:e,direction:n,velocityRadsPerSec:r}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const a=[0,0,0],i=[0,0,0];a[J.XYZ_TO_VECTOR[e]]=n==="-"?-r:r,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:i,rotation:a,use_tool_coordinate_system:this.orientation==="tool"})}async runIncrementalCartesianMotion({currentTcpPose:e,currentJoints:n,velocityInRelevantUnits:r,axis:a,direction:i,motion:c}){const s=[];if(this.mode!=="trajectory")throw new Error("Set jogging mode to 'trajectory' to run incremental cartesian motions");if(c.type==="translate"){if(!e.position)throw new Error("Current pose has no position, cannot perform translation");const b=[...e.position];b[J.XYZ_TO_VECTOR[a]]+=c.distanceMm*(i==="-"?-1:1),s.push({limits_override:{tcp_velocity_limit:r},path:{path_definition_name:"PathLine",target_pose:{position:b,orientation:e.orientation}}})}else if(c.type==="rotate"){if(!e.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const b=new se.Vector3(e.orientation[0],e.orientation[1],e.orientation[2]),f=b.length(),j=b.clone().normalize(),y=c.distanceRads*(i==="-"?-1:1),T=new se.Vector3(0,0,0);T[a]=1;const C=Math.cos(.5*y)*Math.cos(.5*f),w=Math.sin(.5*y)*Math.sin(.5*f),k=Math.sin(.5*y)*Math.cos(.5*f),E=Math.cos(.5*y)*Math.sin(.5*f),I=T.dot(j),P=T.clone().cross(j),L=2*Math.acos(C-w*I),Y=L/Math.sin(.5*L),ee=new se.Vector3().addScaledVector(P,w).addScaledVector(T,k).addScaledVector(j,E).multiplyScalar(Y);s.push({limits_override:{tcp_orientation_velocity_limit:r},path:{path_definition_name:"PathLine",target_pose:{position:e.position,orientation:[...ee]}}})}const l=this.motionStream.description;if(l.cycle_time===void 0){console.warn("Current motion group has no cycle time, cannot plan jogging motion");return}const d={motion_group_model:l.motion_group_model,cycle_time:l.cycle_time,mounting:l.mounting,global:l.operation_limits.auto_limits},m=await this.nova.api.trajectoryPlanning.planTrajectory(this.cellId,{motion_group_setup:d,start_joint_position:n,motion_commands:s}),g=m.response;if(!g)throw new Error(`Failed to plan jogging increment motion ${JSON.stringify(m)}`);this.trajectorySocket&&(console.warn("Trajectory jogging websocket already open; will close"),this.trajectorySocket.dispose()),this.trajectorySocket=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);const p=b=>{var f;if(!b||b.add_trajectory_error||b.message)if(this.onError)this.onError(b);else throw new Error(((f=b==null?void 0:b.add_trajectory_error)==null?void 0:f.message)||(b==null?void 0:b.message)||"Failed to execute trajectory, unknown error");if(!this.trajectorySocket)throw new Error("Failed to execute trajectory, websocket not available anymore");this.trajectorySocket.sendJson({message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"})},u=async()=>{var b;await M.when(()=>!this.motionStream.rapidlyChangingMotionState.standstill),await M.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(b=this.trajectorySocket)==null||b.dispose(),this.trajectorySocket=null},x=async()=>{var b;await M.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(b=this.trajectorySocket)==null||b.dispose(),this.trajectorySocket=null},S=async b=>{if(b!=null&&b.message)if(this.onError){this.onError(b);return}else throw new Error(b.message||"Failed to execute trajectory, unknown error");this.motionStream.rapidlyChangingMotionState.standstill?await u():await x()};this.trajectorySocket.addEventListener("message",b=>{var j,y;const f=J.tryParseJson(b.data);if(!((j=f==null?void 0:f.result)!=null&&j.kind))throw new Error(`Failed to execute trajectory: Received invalid message ${b.data}`);if(this.onBlocked&&((y=f.result.message)!=null&&y.includes(Me))){this.onBlocked();return}if(f.result.kind==="INITIALIZE_RECEIVED")p(f.result);else if(f.result.kind==="START_RECEIVED")S(f);else if(f.result.kind!=="PAUSE_RECEIVED")if(f.result.kind==="MOTION_ERROR"&&f.result.message)if(this.onError){this.onError(f);return}else throw new Error(f.result.message);else throw new Error(`Failed to execute trajectory, cannot handle message type "${f.result.kind}"`)}),this.trajectorySocket.sendJson({message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.motionGroupId,data:g,tcp:this.tcp}})}}const Le=t=>{const e=t.softTimeout||3e3,[n,r]=h.useState(!1),a=A.useTheme();return h.useEffect(()=>{const i=setTimeout(()=>{r(!0)},e);return()=>clearTimeout(i)}),o.jsx(_,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:a.palette.text.primary},children:t.error?o.jsx(ze,{loadingMessage:t.message,error:t.error}):o.jsxs(o.Fragment,{children:[o.jsx(Oe,{sx:{marginBottom:"24px"}}),!!t.message&&o.jsx("div",{children:t.message}),o.jsx(_,{sx:{visibility:n?"visible":"hidden",marginTop:"1rem",color:a.palette.text.secondary},children:"This is taking longer than expected..."})]})})},ze=t=>{const e=at.makeErrorMessage(t.error),n=t.error instanceof Error?t.error.stack:null,r=A.useTheme();return o.jsxs(_,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",padding:2,overflow:"auto",color:r.palette.error.main,"& pre":{whiteSpace:"pre-wrap",wordBreak:"break-word",paddingBottom:"3rem"}},children:[(t.loadingMessage?`Error while ${ue.lowerFirst(rt.capitalize(t.loadingMessage))} - `:"")+e,o.jsx("br",{}),n&&o.jsx("pre",{children:n})]})},Wt=D.observer(({store:t})=>{const{t:e}=B.useTranslation();return o.jsx(Ee,{"data-testid":"jogging-blocked","aria-label":"jogging-blocked",open:!0,sx:{position:"absolute",zIndex:n=>n.zIndex.drawer+1,color:"#fff",background:"rgba(15, 15, 15, 0.88)",justifyContent:"flex-start",alignItems:"flex-start"},children:o.jsxs(_,{sx:{m:2,width:"100%"},children:[o.jsxs(st,{severity:"error",sx:{mb:2},children:[o.jsx(lt,{children:e("Jogging.Blocked.ti")}),e("Jogging.Blocked.lb")]}),o.jsx(H,{variant:"contained",color:"secondary",onClick:()=>t.unblock(),children:e("Jogging.Blocked.Reenable.bt")})]})})}),$e=D.observer(({store:t})=>{const{t:e}=B.useTranslation(),[n,r]=h.useState(t.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached),a=h.useRef(n);Q.useAnimationFrame(()=>{const c=t.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;ct(a.current,c)||(a.current=c,r(c))});const i=[];for(const[c,s]of n.entries())s&&i.push(c);return o.jsx(v,{sx:{display:"flex",flexDirection:"row",justifyContent:"center"},children:o.jsx(R,{"data-testid":"jogging-joint-limit-detector","aria-label":"jogging-joint-limit-detector",color:"error",variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2,visibility:i.length?"visible":"hidden"},children:e("Jogging.JointLimitsReached.lb",{jointNumbers:i.map(c=>c+1).join(", ")})})})}),Gt=A.styled(ut)(({theme:t})=>({"&.MuiFormControl-root":{".MuiSelect-select":{paddingTop:"20px",paddingLeft:"12px"},label:{pointerEvents:"none",fontSize:"16px"},".MuiInputLabel-root":{"&.Mui-focused":{color:t.palette.text.primary}}}}));function ne({labelValue:t,...e}){return o.jsxs(Gt,{fullWidth:!0,variant:"filled",children:[o.jsx(gt,{id:e.labelId,children:t}),o.jsx(pt,{...e})]})}const de=[{id:"0.1",mm:.1,degrees:.05},{id:"1",mm:1,degrees:.5},{id:"5",mm:5,degrees:2.5},{id:"10",mm:10,degrees:5}],Ut=[{id:"continuous"},...de],Ht=["coordsys","tool"];class ae{constructor(e,n,r,a,i){var c,s,l;this.jogger=e,this.coordSystems=n,this.motionGroupDescription=r,this.tcps=a,this.inverseSolverValue=i,this.selectedTabId="cartesian",this.locks=new Set,this.blocked=!1,this.selectedCoordSystemId="world",this.selectedTcpId="",this.tcpChangeInProgress=!1,this.selectedOrientation="coordsys",this.selectedIncrementId="continuous",this.selectedCartesianMotionType="translate",this.incrementJogInProgress=null,this.translationVelocityMmPerSec=10,this.rotationVelocityDegPerSec=1,this.minTranslationVelocityMmPerSec=5,this.maxTranslationVelocityMmPerSec=250,this.minRotationVelocityDegPerSec=1,this.maxRotationVelocityDegPerSec=60,this.showCoordSystemSelect=!1,this.showTcpSelect=!0,this.showOrientationSelect=!0,this.showIncrementSelect=!0,this.showTabIcons=!1,this.showVelocitySliderLabel=!0,this.showVelocityLegend=!1,this.showJointsLegend=!1,this.disposers=[],this.inverseSolver=void 0,this.jointType=V.JointTypeEnum.RevoluteJoint;for(const d of n)if(d.coordinate_system===""){d.coordinate_system="world";break}this.selectedCoordSystemId=((c=n[0])==null?void 0:c.coordinate_system)||"world",this.selectedTcpId=e.motionStream.rapidlyChangingMotionState.tcp??"",this.tcpChangeInProgress=this.tcps.length>0&&!this.selectedTcpId,this.inverseSolver=i,this.jointType=((l=(s=r==null?void 0:r.dh_parameters)==null?void 0:s[0])==null?void 0:l.type)??V.JointTypeEnum.RevoluteJoint,M.makeAutoObservable(this,{},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()},this.loadFromLocalStorage(),this.disposers.push(M.autorun(()=>this.saveToLocalStorage())),this.disposers.push(M.autorun(()=>{const d=this.jogger.motionStream.rapidlyChangingMotionState.tcp;d&&d!==this.selectedTcpId&&M.runInAction(()=>{this.selectedTcpId=d,this.tcpChangeInProgress=!1})})),window.joggingStore=this}static async loadFor(e){const{nova:n,cellId:r}=e,[a,i]=await Promise.all([n.api.controller.listCoordinateSystems(r,e.motionStream.controllerId,"ROTATION_VECTOR"),n.api.motionGroup.getMotionGroupDescription(r,e.motionStream.controllerId,e.motionGroupId)]),c=await n.api.motionGroupModels.getMotionGroupKinematicModel(i.motion_group_model),s=Object.entries(i.tcps||{}).map(([l,d])=>({id:l,readable_name:d.name,position:d.pose.position,orientation:d.pose.orientation}));return new ae(e,a||[],i,s,c.inverse_solver)}dispose(){for(const e of this.disposers)e();this.jogger.dispose()}get coordSystemCountByName(){return ue.countBy(this.coordSystems,e=>e.name)}async deactivate(){this.jogger.mode==="jogging"&&await this.jogger.setJoggingMode("off")}async activate(){return this.currentTab.id==="cartesian"?((this.jogger.tcp!==this.selectedTcpId||this.jogger.orientation!==this.selectedOrientation)&&await this.jogger.setOptions({tcp:this.selectedTcpId||void 0,orientation:this.selectedOrientation}),this.activeDiscreteIncrement?this.jogger.setJoggingMode("trajectory"):this.jogger.setJoggingMode("jogging")):this.jogger.setJoggingMode("jogging"),this.jogger}loadFromLocalStorage(){const e=J.tryParseJson(localStorage.getItem("joggingToolStore"));e&&(this.tabsById[e.selectedTabId]&&(this.selectedTabId=e.selectedTabId),this.coordSystemsById[e.selectedCoordSystemId]&&(this.selectedCoordSystemId=e.selectedCoordSystemId),this.incrementOptionsById[e.selectedIncrementId]&&(this.selectedIncrementId=e.selectedIncrementId),["translate","rotate"].includes(e.selectedCartesianMotionType)&&(this.selectedCartesianMotionType=e.selectedCartesianMotionType),["coordsys","tool"].includes(e.selectedOrientation)&&(this.selectedOrientation=e.selectedOrientation))}saveToLocalStorage(){localStorage.setItem("joggingToolStore",JSON.stringify(this.localStorageSave))}get isLocked(){return this.locks.size>0}get localStorageSave(){return{selectedTabId:this.selectedTabId,selectedCoordSystemId:this.selectedCoordSystemId,selectedOrientation:this.selectedOrientation,selectedIncrementId:this.selectedIncrementId,selectedCartesianMotionType:this.selectedCartesianMotionType}}get tabs(){const e=[{id:"joint",label:"Joints"}];return this.inverseSolver!==null&&e.unshift({id:"cartesian",label:"Cartesian"}),e}get incrementOptions(){return Ut}get discreteIncrementOptions(){return de}get incrementOptionsById(){return te(this.incrementOptions,e=>e.id)}get tabsById(){return te(this.tabs,e=>e.id)}get currentTab(){return this.tabsById[this.selectedTabId]||this.tabs[0]}get tabIndex(){return this.tabs.indexOf(this.currentTab)}get coordSystemsById(){return te(this.coordSystems,e=>e.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get tcpsById(){return te(this.tcps,e=>e.id)}get activeDiscreteIncrement(){return this.selectedOrientation==="tool"?void 0:de.find(e=>e.id===this.selectedIncrementId)}get rotationVelocityRadsPerSec(){return this.rotationVelocityDegPerSec*Math.PI/180}velocityInDisplayUnits(e){return e?this.rotationVelocityDegPerSec:this.translationVelocityMmPerSec}minVelocityInDisplayUnits(e){return e?this.minRotationVelocityDegPerSec:this.minTranslationVelocityMmPerSec}maxVelocityInDisplayUnits(e){return e?this.maxRotationVelocityDegPerSec:this.maxTranslationVelocityMmPerSec}onTabChange(e,n){const r=this.tabs[n]||this.tabs[0];this.selectedTabId=r.id}setSelectedCoordSystemId(e){this.selectedCoordSystemId=e}setSelectedTcpId(e){this.requestTcpChange(e).catch(n=>{console.error("Failed to change TCP:",n)})}async requestTcpChange(e){if(e===this.selectedTcpId)return;this.tcpChangeInProgress=!0;const n=this.jogger.tcp,r=this.jogger.mode!=="jogging";try{this.jogger.tcp=e,r?await this.jogger.setJoggingMode("jogging"):await this.jogger.setJoggingMode("jogging",!1);let a=await this.waitForTcpConfirmation(e,1e3);r&&await this.jogger.setJoggingMode("off"),a||(a=await this.waitForTcpConfirmation(e,2e3)),M.runInAction(()=>{a?this.selectedTcpId=e:(this.jogger.tcp=n,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??"")})}catch(a){throw r&&await this.jogger.setJoggingMode("off").catch(()=>{}),M.runInAction(()=>{this.jogger.tcp=n,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??""}),a}finally{M.runInAction(()=>{this.tcpChangeInProgress=!1})}}waitForTcpConfirmation(e,n){return new Promise(r=>{const a=setTimeout(()=>{i(),r(!1)},n),i=M.when(()=>this.jogger.motionStream.rapidlyChangingMotionState.tcp===e,()=>{clearTimeout(a),r(!0)})})}setSelectedOrientation(e){this.selectedOrientation=e}setSelectedIncrementId(e){this.selectedIncrementId=e}setCurrentIncrementJog(e){this.incrementJogInProgress=e}setVelocityFromSlider(e,n){n?this.rotationVelocityDegPerSec=e:this.translationVelocityMmPerSec=e}setSelectedCartesianMotionType(e){this.selectedCartesianMotionType=e}lock(e){this.locks.add(e)}unlock(e){this.locks.delete(e)}block(){this.blocked=!0}unblock(){this.blocked=!1,this.jogger.mode==="jogging"&&this.jogger.initializeJoggingWebsocket()}async withMotionLock(e){const n=ht();this.lock(n);try{return await e()}finally{this.unlock(n)}}}const Yt=D.observer(({store:t,useDegree:e})=>{var c;const{t:n}=B.useTranslation(),r=h.useId(),a=[];function i(s){switch(s){case"coordsys":return n("Jogging.Orientation.coordsys");case"tool":return n("Jogging.Orientation.tool");default:return s}}return t.showCoordSystemSelect&&a.push(o.jsx(ne,{labelId:`jogging-coord-select-${r}`,labelValue:n("Jogging.CoordinateSystem.hlb"),value:t.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:s=>t.setSelectedCoordSystemId(s.target.value),disabled:t.isLocked,children:t.coordSystems.map(s=>o.jsx(U,{value:s.coordinate_system,children:s.name&&t.coordSystemCountByName[s.name]>1?`${s.name} / ${s.coordinate_system}`:s.name||s.coordinate_system},s.coordinate_system))},"coord")),t.showTcpSelect&&a.push(o.jsx(ne,{labelId:`jogging-tcp-select-${r}`,labelValue:"TCP",value:t.selectedTcpId,size:"small",variant:"filled",displayEmpty:t.tcpChangeInProgress,onChange:s=>{t.requestTcpChange(s.target.value).catch(l=>{console.error("Failed to change TCP:",l)})},disabled:t.isLocked||t.tcpChangeInProgress,endAdornment:t.tcpChangeInProgress?o.jsx(dt,{position:"end",children:o.jsx(Oe,{size:16})}):void 0,children:t.tcps.map(s=>o.jsx(U,{value:s.id,children:s.id},s.id))},"tcp")),t.showOrientationSelect&&a.push(o.jsx(ne,{labelValue:n("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${r}`,value:t.selectedOrientation,onChange:s=>t.setSelectedOrientation(s.target.value),disabled:t.isLocked,children:Ht.map(s=>o.jsx(U,{value:s,children:i(s)},s))},"orientation")),t.showIncrementSelect&&a.push(o.jsxs(ne,{labelValue:n("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${r}`,size:"small",variant:"filled",value:((c=t.activeDiscreteIncrement)==null?void 0:c.id)||"continuous",onChange:s=>t.setSelectedIncrementId(s.target.value),disabled:t.isLocked,children:[o.jsx(U,{value:"continuous",children:n("Jogging.Increment.Continuous.dd")},"continuous"),t.selectedOrientation==="tool"?null:t.discreteIncrementOptions.map(s=>o.jsx(U,{value:s.id,children:e?`${s.degrees}°`:`${s.mm}mm`},s.id))]},"increment")),o.jsx(v,{component:"div","data-testid":"jogging-options","aria-label":"jogging-options",sx:{display:"grid",gap:"16px",gridTemplateColumns:"1fr 1fr",gridAutoRows:"min-content","& label":{opacity:.7,fontSize:"12px",marginBottom:"4px"}},children:a.map((s,l)=>o.jsx(v,{sx:{gridColumn:a.length%2===1&&l===a.length-1?"span 2":"auto"},children:s},l))})}),Zt=A.styled(mt)(({theme:t})=>{var e;return{"&.MuiToggleButtonGroup-root":{background:(e=t.palette.backgroundPaperElevation)==null?void 0:e[8],borderRadius:"8px",padding:"4px",gap:"4px",button:{border:"none",borderRadius:"4px",flex:"1 1 0px",minWidth:0,"&.MuiToggleButtonGroup-firstButton":{borderRadius:"8px 4px 4px 8px"},"&.MuiToggleButtonGroup-lastButton":{borderRadius:"4px 8px 8px 4px"}}}}}),Ve=D.observer(t=>{var i,c,s;const e=A.useTheme(),{store:n}=t,{t:r}=B.useTranslation();function a(l,d){d===t.velocity||!ft(d)||t.onVelocityChange(d,t.useDegree)}return o.jsxs(_,{direction:"row",gap:2,alignItems:"center","data-testid":"velocity-slider","aria-label":"velocity-slider",children:[n.showVelocityLegend&&o.jsx(R,{sx:{color:(s=(c=(i=e.componentsExt)==null?void 0:i.JoggingPanel)==null?void 0:c.VelocitySlider)==null?void 0:s.sliderLegendColor,fontSize:"14px"},children:r("Jogging.Velocity.bt")}),o.jsx(Ae,{value:t.velocity,color:"secondary",onChange:a,min:t.min,max:t.max,"aria-labelledby":"input-slider",disabled:t.disabled,sx:{"& .MuiSlider-valueLabelOpen":{zIndex:100,backgroundColor:"transparent",top:"0px"}}}),n.showVelocitySliderLabel&&(t.renderValue?t.renderValue(t.velocity):o.jsx(he,{value:t.velocity.toString()}))]})});function he({value:t,sx:e}){var r;const n=A.useTheme();return o.jsx(_,{direction:"row",justifyContent:"center",alignItems:"center",gap:"5px",sx:{padding:"6px 12px",background:(r=n.palette.backgroundPaperElevation)==null?void 0:r[8],borderRadius:"10px",minWidth:"111px",...e},children:o.jsx(R,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:n.palette.text.primary,whiteSpace:"nowrap"},children:t})})}const qe=D.observer(({store:t,useDegree:e})=>{const{t:n}=B.useTranslation();function r(a,i){return i?`ω = ${n("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:a})}`:`v = ${n("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:a})}`}return o.jsx(Ve,{store:t,velocity:t.velocityInDisplayUnits(e),min:t.minVelocityInDisplayUnits(e),max:t.maxVelocityInDisplayUnits(e),onVelocityChange:t.setVelocityFromSlider,useDegree:e,disabled:t.isLocked,renderValue:a=>o.jsx(he,{value:r(a,e),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),Ne=D.observer(({store:t})=>{var a,i,c;const{t:e}=B.useTranslation(),n=A.useTheme(),r=((c=(i=(a=t.jogger.motionStream.rapidlyChangingMotionState.execute)==null?void 0:a.details)==null?void 0:i.state)==null?void 0:c.kind)??"KIND_UNKNOWN";return o.jsxs(v,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",color:n.palette.text.primary},children:[o.jsx(R,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},children:e("Jogging.StreamStateSection.lb")}),o.jsx(R,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},"data-testid":r,children:e(`Jogging.StreamStateSection.${r}.lb`)})]})}),Xt=D.observer(({store:t,children:e})=>{const{t:n}=B.useTranslation(),r=A.useTheme();function a(p,u){(u==="translate"||u==="rotate")&&t.setSelectedCartesianMotionType(u)}async function i(p,u){const x=await t.activate(),S=x.motionStream.rapidlyChangingMotionState.tcp_pose,b=x.motionStream.rapidlyChangingMotionState.joint_position;S&&await t.withMotionLock(async()=>{try{t.setCurrentIncrementJog({axis:p.axis,direction:p.direction}),await t.jogger.runIncrementalCartesianMotion({currentTcpPose:S,currentJoints:b,coordSystemId:t.activeCoordSystemId,velocityInRelevantUnits:t.selectedCartesianMotionType==="translate"?t.translationVelocityMmPerSec:t.rotationVelocityRadsPerSec,axis:p.axis,direction:p.direction,motion:t.selectedCartesianMotionType==="translate"?{type:"translate",distanceMm:u.mm}:{type:"rotate",distanceRads:J.degreesToRadians(u.degrees)}})}finally{t.setCurrentIncrementJog(null),await t.deactivate()}})}async function c(p){if(!t.isLocked){if(await t.activate(),t.activeDiscreteIncrement)return i(p,t.activeDiscreteIncrement);p.motionType==="translate"?await t.jogger.translateTCP({axis:p.axis,direction:p.direction,velocityMmPerSec:t.translationVelocityMmPerSec}):await t.jogger.rotateTCP({axis:p.axis,direction:p.direction,velocityRadsPerSec:t.rotationVelocityRadsPerSec})}}async function s(){t.isLocked||t.activeDiscreteIncrement||await t.deactivate()}function l(p,u,x){var b,f,j;const S=(j=(f=(b=x.componentsExt)==null?void 0:b.JoggingPanel)==null?void 0:f.JoggingCartesian)==null?void 0:j.Axis;if(S)return u==="translate"?S[p]:S.CustomRotation??S[p]}const d=[{id:"x",icon:o.jsx(W.ForwardRef,{}),colors:l("X",t.selectedCartesianMotionType,r)},{id:"y",icon:o.jsx(W.ForwardRef$1,{}),colors:l("Y",t.selectedCartesianMotionType,r)},{id:"z",icon:o.jsx(W.ForwardRef$2,{}),colors:l("Z",t.selectedCartesianMotionType,r)}];function m(p){return n("General.mm.variable",{amount:p.toFixed(1)})}function g(p){return n("General.degree.variable",{amount:J.radiansToDegrees(p).toFixed(1)})}return o.jsxs(_,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[o.jsxs(_,{gap:2,children:[o.jsx(Yt,{store:t,useDegree:t.selectedCartesianMotionType==="rotate"}),o.jsx(qe,{store:t,useDegree:t.selectedCartesianMotionType==="rotate"}),o.jsx(q,{})]}),o.jsx(_,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:o.jsxs(_,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[o.jsxs(Zt,{value:t.selectedCartesianMotionType,onChange:a,exclusive:!0,"aria-label":n("Jogging.Cartesian.MotionType.lb"),sx:{justifyContent:"center"},children:[o.jsx(Te,{value:"translate",children:n("Jogging.Cartesian.Translation.bt")}),o.jsx(Te,{value:"rotate",children:n("Jogging.Cartesian.Rotation.bt")})]}),t.selectedCartesianMotionType==="translate"&&d.map(p=>{var u,x;return o.jsx(ce,{"data-testid":`jogging-cartesian-axis-control-${p.id}`,"aria-label":`jogging-cartesian-axis-control-${p.id}`,colors:p.colors,disabled:t.isLocked,activeJoggingDirection:((u=t.incrementJogInProgress)==null?void 0:u.axis)===p.id?t.incrementJogInProgress.direction:void 0,label:o.jsxs(o.Fragment,{children:[p.icon,o.jsx(R,{sx:{fontSize:"24px",color:((x=p.colors)==null?void 0:x.labelColor)??r.palette.text.primary},children:p.id.toUpperCase()})]}),getDisplayedValue:()=>{var S,b;return m(((b=(S=t.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:S.position)==null?void 0:b[J.XYZ_TO_VECTOR[p.id]])||0)},startJogging:S=>c({axis:p.id,motionType:"translate",direction:S}),stopJogging:s},p.id)}),t.selectedCartesianMotionType==="rotate"&&d.map(p=>{var u,x;return o.jsx(ce,{"data-testid":`jogging-cartesian-axis-control-${p.id}`,"aria-label":`jogging-cartesian-axis-control-${p.id}`,colors:p.colors,disabled:t.isLocked,activeJoggingDirection:((u=t.incrementJogInProgress)==null?void 0:u.axis)===p.id?t.incrementJogInProgress.direction:void 0,label:o.jsxs(o.Fragment,{children:[o.jsx(W.ForwardRef$6,{}),o.jsx(R,{sx:{fontSize:"24px",color:((x=p.colors)==null?void 0:x.labelColor)??r.palette.text.primary},children:p.id.toUpperCase()})]}),getDisplayedValue:()=>{var S,b;return g(((b=(S=t.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:S.orientation)==null?void 0:b[J.XYZ_TO_VECTOR[p.id]])||0)},startJogging:S=>c({axis:p.id,motionType:"rotate",direction:S}),stopJogging:s},p.id)})]})}),o.jsx($e,{store:t}),o.jsx(q,{}),o.jsx(Ne,{store:t}),e&&o.jsx(q,{}),e]})}),Qt=D.observer(({store:t,children:e})=>{const n=A.useTheme();async function r(i){await t.activate(),await t.jogger.rotateJoints({joint:i.joint,direction:i.direction,velocityUnit:t.jointType===V.JointTypeEnum.PrismaticJoint?"mm/s":"rad/s",velocityValue:t.jointType===V.JointTypeEnum.PrismaticJoint?t.translationVelocityMmPerSec:t.rotationVelocityRadsPerSec})}async function a(){await t.jogger.stop(),await t.deactivate()}return o.jsxs(_,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[o.jsx(qe,{store:t,useDegree:t.jointType===V.JointTypeEnum.RevoluteJoint}),o.jsx(q,{}),o.jsx(_,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:o.jsx(_,{"data-testid":"jogging-joint-value-controls-wrapper","aria-label":"jogging-joint-value-controls-wrapper",alignItems:"center",gap:"24px",children:t.jogger.motionStream.joints.map(i=>{var s,l,d;const c=(d=(l=(s=t.motionGroupDescription.operation_limits.auto_limits)==null?void 0:s.joints)==null?void 0:l[i.index])==null?void 0:d.position;return o.jsxs(_,{"data-testid":`jogging-joint-value-control-${i.index}`,"aria-label":`jogging-joint-value-control-${i.index}`,direction:"row",alignItems:"center",justifyContent:"center",spacing:1.5,width:"100%",children:[t.showJointsLegend&&o.jsx(R,{color:t.isLocked?n.palette.text.disabled:n.palette.text.secondary,children:`G${i.index+1}`}),o.jsx(Je,{disabled:t.isLocked,lowerLimit:c==null?void 0:c.lower_limit,upperLimit:c==null?void 0:c.upper_limit,useDegree:t.jointType===V.JointTypeEnum.RevoluteJoint,getValue:()=>{const m=t.jogger.motionStream.rapidlyChangingMotionState.joint_position[i.index];return m!==void 0?m:void 0},startJogging:m=>r({joint:i.index,direction:m}),stopJogging:a})]},`joint-${i.index}`)})})}),o.jsx($e,{store:t}),o.jsx(q,{}),o.jsx(Ne,{store:t}),e&&o.jsx(q,{}),e]})}),Kt=F.externalizeComponent(D.observer(t=>{const e=ue.isString(t.nova)?new V.Nova({instanceUrl:t.nova}):t.nova,n=D.useLocalObservable(()=>({joggingStore:null,loadingError:null}));async function r(){M.runInAction(()=>{n.loadingError=null,n.joggingStore=null});try{let a=t.store;if(!a){const i=await re.open(e,t.motionGroupId,{cellId:t.cellId});a=await ae.loadFor(i)}M.runInAction(()=>{n.joggingStore=a}),t.onSetup&&t.onSetup(a)}catch(a){n.loadingError=a}}return h.useEffect(()=>(r(),t.store?()=>null:()=>{var a;(a=n.joggingStore)==null||a.dispose()}),[t.store,t.nova,t.motionGroupId,t.cellId]),h.useEffect(()=>{const a=n.joggingStore;a&&(t.locked?a.lock("external"):a.unlock("external"))},[n.joggingStore,t.locked]),o.jsx(_,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...t.sx},children:n.joggingStore?o.jsx(en,{store:n.joggingStore,children:t.children}):o.jsx(Le,{message:"Loading jogging",error:n.loadingError})})})),en=D.observer(({store:t,children:e})=>{const{t:n}=B.useTranslation();function r(){if(t.currentTab.id==="cartesian")return o.jsx(Xt,{store:t,children:e});if(t.currentTab.id==="joint")return o.jsx(Qt,{store:t,children:e})}return o.jsxs(_,{flexGrow:1,sx:{overflow:"hidden"},children:[o.jsx(_e,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:t.tabIndex,onChange:t.onTabChange,variant:"fullWidth",children:t.tabs.map(a=>{const i=a.label==="Cartesian"?n("Jogging.Cartesian.bt"):n("Jogging.Joints.bt"),c=a.label==="cartesian"?o.jsx(ot,{fontSize:"small",sx:{mr:1}}):o.jsx(it,{fontSize:"small",sx:{mr:1}});return o.jsx(Pe,{"data-testid":`jogging-tab-${a.id}`,"aria-label":`jogging-tab-${a.id}`,label:t.showTabIcons?o.jsxs(_,{direction:"row",alignItems:"center",children:[c,i]}):i,id:`jogging-tab-${a.id}`,"aria-controls":`jogging-tab-${a.id}`},a.id)})}),o.jsx(_,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:r()}),t.blocked&&o.jsx(Wt,{store:t})]})}),We=t=>{var s;const{value:e,ref:n}=t,r=A.useTheme(),[a,i]=h.useState(!1);async function c(){if(!n||!("current"in n))return console.warn("No copy target found"),!1;try{return await navigator.clipboard.writeText(e),console.log("Copied!"),i(!0),!0}catch(l){console.error(l);const d=window.getSelection();if(d&&n&&"current"in n&&n.current){const m=document.createRange();m.selectNodeContents(n.current),d.removeAllRanges(),d.addRange(m)}}return!1}return h.useEffect(()=>{if(!a)return;const l=setTimeout(()=>i(!1),3e3);return()=>{l&&clearTimeout(l)}},[a]),o.jsx(St,{open:a,title:"Copied!",children:o.jsx(_,{justifyContent:"center",sx:{height:"100%",boxSizing:"border-box",padding:"6px 12px",background:(s=r.palette.backgroundPaperElevation)==null?void 0:s[8],borderRadius:"10px",minWidth:"0",cursor:"pointer"},onClick:()=>c(),children:o.jsx(R,{ref:n,align:"center",sx:{pointerEvents:"none",fontSize:"12px",color:r.palette.text.primary,whiteSpace:"nowrap",minWidth:0,textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:e})})})},tn=F.externalizeComponent(D.observer(({tcpPose:t,showCopyButton:e=!1})=>{const[n,r]=h.useState(null),a=V.poseToWandelscriptString(t),i=async()=>{try{await navigator.clipboard.writeText(a),r("Copied!"),setTimeout(()=>r(null),2e3)}catch{r("Copy failed"),setTimeout(()=>r(null),2e3)}};return o.jsxs(_,{direction:"row",alignItems:"center",spacing:1,sx:{flexGrow:1,minWidth:0,overflow:"hidden"},"data-testid":"pose-cartesian-values",children:[o.jsx(We,{value:a}),e&&o.jsx(H,{variant:"contained",color:"secondary",size:"small",onClick:i,sx:{flexShrink:0},children:n||"Copy"})]})})),nn=F.externalizeComponent(D.observer(({joints:t,showCopyButton:e=!1})=>{const[n,r]=h.useState(null),a=`[${t.map(c=>parseFloat(c.toFixed(4))).join(", ")}]`,i=async()=>{try{await navigator.clipboard.writeText(a),r("Copied!"),setTimeout(()=>r(null),2e3)}catch{r("Copy failed"),setTimeout(()=>r(null),2e3)}};return o.jsxs(_,{direction:"row",alignItems:"center",spacing:1,sx:{flexGrow:1,minWidth:0,overflow:"hidden"},"data-testid":"pose-joint-values",children:[o.jsx(We,{value:a}),e&&o.jsx(H,{variant:"contained",color:"secondary",size:"small",onClick:i,sx:{flexShrink:0},children:n||"Copy"})]})}));class Ge{constructor(){this.messages=[],this.addMessage=(e,n="info")=>{const r={id:Math.random().toString(36).substring(2,11),timestamp:new Date,message:e,level:n};this.messages.push(r)},this.clearMessages=()=>{this.messages=[]},this.addInfo=e=>{this.addMessage(e,"info")},this.addWarning=e=>{this.addMessage(e,"warning")},this.addError=e=>{this.addMessage(e,"error")},this.addDebug=e=>{this.addMessage(e,"debug")},M.makeObservable(this,{messages:M.observable,addMessage:M.action,clearMessages:M.action})}}const K=(t,e,n)=>({id:n||`${Date.now()}-${Math.random().toString(36).substring(2,11)}`,timestamp:new Date,message:t,level:e}),on=(t,e)=>K(t,"debug",e),rn=(t,e)=>K(t,"info",e),an=(t,e)=>K(t,"warning",e),sn=(t,e)=>K(t,"error",e),Ue=F.externalizeComponent(D.observer(t=>{var m;const{messages:e=[],onClear:n,height:r=400,sx:a}=t,i=A.useTheme(),c=h.useRef(null);h.useEffect(()=>{if(e.length===0)return;const g=c.current;if(!g)return;const p=setTimeout(()=>{g.scrollTop=g.scrollHeight},10);return()=>clearTimeout(p)},[e.length]);const s=g=>g.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),l=g=>{switch(g){case"error":return i.palette.error.main;case"warning":return i.palette.warning.main;case"info":return i.palette.info.main;case"debug":return i.palette.text.disabled;default:return i.palette.text.secondary}},d=({message:g})=>{const[p,u]=h.useState(!1),[x,S]=h.useState(!1),[b,f]=h.useState(!1),j=g.message.length>150,y=async()=>{try{await navigator.clipboard.writeText(g.message),S(!0),setTimeout(()=>S(!1),2e3)}catch(C){console.error("Failed to copy message:",C)}},T=j&&!p?`${g.message.substring(0,150)}...`:g.message;return o.jsx(v,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),sx:{display:"flex",gap:1,fontFamily:"monospace",flexDirection:"column","&:hover":{backgroundColor:i.palette.action.hover},borderRadius:"4px",padding:"2px 4px",margin:"-2px -4px"},children:o.jsxs(v,{sx:{display:"flex",gap:1},children:[o.jsxs(R,{component:"span",sx:{fontWeight:400,fontSize:"12px",lineHeight:"18px",letterSpacing:"0.4px",color:i.palette.text.disabled,whiteSpace:"nowrap",flexShrink:0},children:["[",s(g.timestamp),"]"]}),o.jsx(R,{component:"span",sx:{fontWeight:400,fontSize:"12px",lineHeight:"18px",letterSpacing:"0.4px",color:l(g.level),wordBreak:"break-word",overflowWrap:"anywhere",hyphens:"auto",flex:1,whiteSpace:"pre-wrap"},children:T}),o.jsxs(v,{sx:{display:"flex",alignItems:"flex-start",gap:.5,opacity:b?1:0,transition:"opacity 0.2s ease-in-out",visibility:b?"visible":"hidden"},children:[o.jsx(G,{size:"small",onClick:y,sx:{padding:"2px",color:i.palette.text.secondary,"&:hover":{backgroundColor:i.palette.action.hover}},title:x?"Copied!":"Copy message",children:o.jsx(jt,{sx:{fontSize:12}})}),j&&o.jsx(G,{size:"small",onClick:()=>u(!p),sx:{padding:"2px",color:i.palette.text.secondary,"&:hover":{backgroundColor:i.palette.action.hover}},title:p?"Collapse":"Expand",children:p?o.jsx(vt,{sx:{fontSize:12}}):o.jsx(Tt,{sx:{fontSize:12}})})]})]})},g.id)};return o.jsxs(wt,{sx:{backgroundColor:((m=i.palette.backgroundPaperElevation)==null?void 0:m[2])||"#171927",backgroundImage:"none",height:r,display:"flex",flexDirection:"column",overflow:"hidden",...a},children:[o.jsxs(v,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px"},children:[o.jsxs(v,{sx:{display:"flex",alignItems:"center",gap:1},children:[o.jsx(Ct,{sx:{fontSize:16,color:i.palette.action.active,opacity:.56}}),o.jsx(R,{sx:{fontWeight:500,fontSize:"14px",lineHeight:"143%",letterSpacing:"0.17px",color:i.palette.text.primary},children:"Log"})]}),o.jsx(H,{onClick:n,variant:"text",sx:{fontWeight:500,fontSize:"13px",lineHeight:"22px",letterSpacing:"0.46px",color:i.palette.primary.main,textTransform:"none",minWidth:"auto",padding:"4px 8px","&:hover":{backgroundColor:`${i.palette.primary.main}14`}},children:"Clear"})]}),o.jsx(v,{ref:c,sx:{flex:1,overflow:"auto",padding:"8px 16px",display:"flex",flexDirection:"column",gap:"2px",scrollbarWidth:"thin",scrollbarColor:`${i.palette.divider} transparent`,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:i.palette.divider,borderRadius:"3px","&:hover":{backgroundColor:i.palette.divider}}},children:e.length===0?o.jsx(R,{sx:{color:i.palette.text.disabled,fontSize:"12px",fontStyle:"italic",textAlign:"center",marginTop:2},children:"No log messages"}):e.map(g=>o.jsx(d,{message:g},g.id))})]})})),ln=F.externalizeComponent(D.observer(t=>{const{store:e,onStoreReady:n,...r}=t,a=h.useRef(n);h.useEffect(()=>{a.current=n},[n]);const i=h.useMemo(()=>{var l;const s=e||new Ge;return(l=a.current)==null||l.call(a,s),s},[e]),c=()=>{i.clearMessages()};return o.jsx(Ue,{...r,messages:i.messages,onClear:c})}));function cn(){const t=window.location.href;return t.substring(0,t.indexOf("/",t.indexOf("//")+2))}function dn({baseUrl:t=cn(),...e}){return o.jsxs(It,{"aria-labelledby":"no-motion-group-modal-title",open:!0,fullWidth:!0,sx:{"& .MuiModal-backdrop":{backdropFilter:"blur(10px)"},"& .MuiDialog-paper":{"::before":{content:'""',height:"8px",width:"100%",background:"linear-gradient(90deg, #FF0E65 0%, #47D3FF 100%)"},background:"#101629"}},children:[o.jsx(Rt,{id:"no-motion-group-modal-title",children:"No motion group found"}),o.jsxs(kt,{sx:{marginTop:"3rem",marginBottom:"1.5rem",textAlign:"center"},children:[o.jsx(R,{color:"#fff",children:"Found no devices to connect to."}),o.jsx(R,{color:"#fff",children:"Please ensure a motion group has been created."})]}),o.jsx(Mt,{children:o.jsxs(_,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[o.jsx(H,{href:`${t}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),o.jsx(H,{href:`${t}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}var me=(t=>(t.PRECONDITION_NOT_FULFILLED="PRECONDITION_NOT_FULFILLED",t.ROBOT_DISCONNECTED="ROBOT_DISCONNECTED",t.CELL_OPEN="CELL_OPEN",t.E_STOP="E_STOP",t.MANUAL_MODE="MANUAL_MODE",t.READY="READY",t))(me||{});const He=F.externalizeComponent(D.observer(({setupState:t,className:e})=>{const n=A.useTheme(),{t:r}=B.useTranslation(),a=()=>{var d,m,g,p,u,x,S;switch(t){case"READY":return{label:r("RobotSetupReadinessIndicator.Ready.lb"),indicatorColor:((d=n.palette.tertiary)==null?void 0:d.main)||n.palette.primary.main,backgroundColor:((m=n.palette.backgroundPaperElevation)==null?void 0:m[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};case"ROBOT_DISCONNECTED":return{label:r("RobotSetupReadinessIndicator.RobotDisconnected.lb"),indicatorColor:n.palette.error.main,backgroundColor:((g=n.palette.backgroundPaperElevation)==null?void 0:g[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};case"CELL_OPEN":return{label:r("RobotSetupReadinessIndicator.CellOpen.lb"),indicatorColor:n.palette.error.main,backgroundColor:((p=n.palette.backgroundPaperElevation)==null?void 0:p[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};case"E_STOP":return{label:r("RobotSetupReadinessIndicator.EStop.lb"),indicatorColor:n.palette.error.main,backgroundColor:((u=n.palette.backgroundPaperElevation)==null?void 0:u[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};case"MANUAL_MODE":return{label:r("RobotSetupReadinessIndicator.ManualMode.lb"),indicatorColor:n.palette.error.main,backgroundColor:((x=n.palette.backgroundPaperElevation)==null?void 0:x[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};default:return{label:r("RobotSetupReadinessIndicator.PreconditionNotFulfilled.lb"),indicatorColor:n.palette.error.main,backgroundColor:((S=n.palette.backgroundPaperElevation)==null?void 0:S[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText}}},{label:i,indicatorColor:c,backgroundColor:s,textColor:l}=a();return o.jsx(Pt,{className:e,label:o.jsxs(v,{sx:{display:"flex",alignItems:"center",gap:1},children:[o.jsx(v,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:c,flexShrink:0}}),o.jsx(R,{variant:"body2",sx:{color:l,fontSize:"0.75rem",lineHeight:1.2},children:i})]}),variant:"filled",sx:{backgroundColor:s,color:n.palette.getContrastText(s),fontWeight:500,height:"auto","& .MuiChip-label":{paddingX:1.5,paddingY:.5}}})})),un=F.externalizeComponent(D.observer(({robotName:t,robotType:e,setupState:n,PreconditionComponent:r=He,className:a})=>{var l;const i=A.useTheme(),c=e||"Robot",s=n===me.READY;return o.jsxs(v,{className:a,sx:{border:`1px solid ${i.palette.divider}`,background:((l=i.palette.backgroundPaperElevation)==null?void 0:l[8])||"#292B3F",borderRadius:"8px",padding:"20px",display:"flex",alignItems:"center",justifyContent:"space-between",opacity:1},children:[o.jsxs(v,{sx:{display:"flex",alignItems:"center",gap:2,flex:1},children:[s?o.jsx(v,{sx:{fontSize:24,display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,"& svg":{fill:`${i.palette.primary.main} !important`},"& svg path":{fill:`${i.palette.primary.main} !important`}},children:o.jsx(W.ForwardRef$5,{})}):o.jsx(Et,{sx:{color:i.palette.error.main,fontSize:24}}),o.jsx(R,{variant:"body1",sx:{fontWeight:500,color:i.palette.text.primary},children:t}),o.jsx(q,{orientation:"vertical",flexItem:!0,sx:{backgroundColor:i.palette.text.secondary,opacity:.3,width:"1px"}}),o.jsx(R,{variant:"body2",sx:{color:i.palette.text.secondary},children:c})]}),r&&o.jsx(r,{setupState:n})]})})),gn=A.styled(_t,{shouldForwardProp:t=>t!=="selected"})(({theme:t})=>{var e,n,r;return{borderRadius:"20px","&:hover":{background:(e=t.palette.backgroundPaperElevation)==null?void 0:e[7]},variants:[{props:({selected:a})=>!a,style:{background:(n=t.palette.backgroundPaperElevation)==null?void 0:n[0],color:t.palette.action.disabled,"> img":{opacity:.4}}},{props:({selected:a})=>a,style:{background:(r=t.palette.backgroundPaperElevation)==null?void 0:r[11],border:`1px solid ${t.palette.divider}`,color:t.palette.primary.contrastText}}]}}),pn=t=>{const{ref:e,...n}=t;return o.jsx(gn,{ref:e,selected:t.selected,...n,color:"secondary",variant:"circular"})};function hn(t){const{children:e,value:n,index:r,...a}=t;return o.jsx("div",{role:"tabpanel",hidden:n!==r,id:`tabpanel-${r}`,"aria-labelledby":`tab-${r}`,...a,children:n===r&&o.jsx(v,{children:e})})}function mn({children:t,...e}){const{fullWidth:n,indicator:r,onChange:a,orientation:i,scrollButtons:c,selectionFollowsFocus:s,textColor:l,value:d,variant:m,...g}=e;return o.jsx(v,{...g,children:t})}const fn=F.externalizeComponent(D.observer(t=>{const{items:e,activeTab:n,defaultActiveTab:r=0,onTabChange:a,sx:i,ref:c}=t,s=n!==void 0,[l,d]=h.useState(r),m=s?n:l;h.useEffect(()=>{s||e.length!==0&&(l<0||l>e.length-1)&&d(0)},[e.length,s,l]);const g=(p,u)=>{s||d(u),a==null||a(u)};return o.jsxs(v,{ref:c,sx:{height:"100%",display:"flex",flexDirection:"column",...i},children:[o.jsx(v,{sx:{px:0,py:0,overflow:"visible",position:"relative",paddingTop:p=>p.spacing(2),paddingRight:p=>p.spacing(2.5)},children:o.jsx(_e,{value:m,onChange:g,sx:{minHeight:"32px",backgroundColor:"transparent",overflow:"visible","& .MuiTabs-indicator":{display:"none"},"& .MuiTabs-flexContainer":{gap:2,overflow:"visible",paddingTop:0,paddingBottom:0},"& .MuiTabs-scroller":{overflow:"visible !important"},"& .MuiTab-root":{overflow:"visible"}},children:e.map((p,u)=>{var T,C,w;const x=()=>{if(!p.badge)return;const k=p.badge.content,E=p.badge.max;return typeof k=="number"&&E&&k>E?`${E}+`:k},S=()=>{if(!p.badge)return!1;const k=p.badge.content,E=p.badge.showZero;return!(k===0&&!E)},b=x(),f=S(),j=()=>{s||d(u),a==null||a(u)},y=o.jsx(Pe,{label:p.label,icon:p.icon,iconPosition:"start",disableRipple:!0,onClick:j,sx:{minHeight:"32px",height:"32px",padding:"0px 10px",borderRadius:"12px",backgroundColor:k=>{var E;return((E=k.palette.backgroundPaperElevation)==null?void 0:E[11])||"#32344B"},color:"text.primary",opacity:m===u?1:.38,fontSize:"13px",transition:"all 0.2s ease-in-out",position:"relative",overflow:"visible","&:hover":{opacity:m===u?1:.6},"&.Mui-selected":{opacity:1,backgroundColor:k=>{var E;return((E=k.palette.backgroundPaperElevation)==null?void 0:E[11])||"#32344B"},color:"text.primary"},"&:focus":{outline:"none"},"&:active":{transform:"none"}}},p.id);return f?o.jsx(mn,{component:"span",sx:{display:"inline-flex"},children:o.jsx(Ot,{badgeContent:b,color:((T=p.badge)==null?void 0:T.color)||"error",max:(C=p.badge)==null?void 0:C.max,showZero:(w=p.badge)==null?void 0:w.showZero,anchorOrigin:{vertical:"top",horizontal:"right"},overlap:"rectangular",sx:{"& .MuiBadge-badge":{opacity:"1 !important"}},children:y})},p.id):y})})}),o.jsx(v,{sx:{mt:p=>p.spacing(2),borderBottom:1,borderColor:"divider"}}),o.jsx(v,{sx:{flex:1,overflow:"auto"},children:e.map((p,u)=>o.jsx(hn,{value:m,index:u,children:p.content},p.id))})]})})),xn=t=>{const e=Math.floor(t/86400),n=Math.floor(t%86400/3600),r=Math.floor(t%3600/60),a=t%60,i=[];return e>0?(i.push(e.toString()),i.push(n.toString().padStart(2,"0")),i.push(r.toString().padStart(2,"0")),i.push(a.toString().padStart(2,"0"))):n>0?(i.push(n.toString()),i.push(r.toString().padStart(2,"0")),i.push(a.toString().padStart(2,"0"))):(i.push(r.toString()),i.push(a.toString().padStart(2,"0"))),i.join(":")},ke=(t,e)=>{const n=Math.floor(t/86400),r=Math.floor(t%86400/3600),a=Math.floor(t%3600/60),i=t%60;if(typeof Intl<"u"&&"DurationFormat"in Intl)try{const s={};return n>0&&(s.days=n),r>0&&(s.hours=r),a>0&&(s.minutes=a),(i>0||Object.keys(s).length===0)&&(s.seconds=i),new Intl.DurationFormat(e,{style:"narrow"}).format(s)}catch{}const c=[];return n>0&&c.push(`${n}d`),r>0&&c.push(`${r}h`),a>0&&c.push(`${a}m`),(i>0||c.length===0)&&c.push(`${i}s`),c.join(" ")},bn=({timerState:t,animationState:e,hasError:n,className:r})=>{const{t:a}=B.useTranslation(),i=A.useTheme(),{elapsedTime:c,currentProgress:s}=t,{showErrorAnimation:l,showPauseAnimation:d,showMainText:m}=e;return o.jsxs(v,{className:r,sx:{position:"relative",width:264,height:264,display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx(At.Gauge,{width:264,height:264,value:s,valueMin:0,valueMax:100,innerRadius:"85%",outerRadius:"100%",margin:0,skipAnimation:!0,text:()=>"",sx:{opacity:d||l?.6:1,transition:"opacity 0.5s ease-out","& .MuiGauge-valueArc":{fill:n?i.palette.error.light:i.palette.success.main,transition:"fill 0.5s ease-out"},"& .MuiGauge-referenceArc":{fill:"#171927",stroke:"transparent",strokeWidth:0,transition:"fill 0.5s ease-out, stroke 0.5s ease-out, stroke-width 0.5s ease-out"},"& .MuiGauge-valueText":{display:"none"},"& .MuiGauge-text":{display:"none"}}}),o.jsx(v,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:225,height:225,borderRadius:"50%",backgroundColor:"#292B3F",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",gap:1,transition:"background-color 0.5s ease-out"},children:o.jsxs(v,{sx:{position:"relative",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:.5},children:[o.jsx(N,{in:m&&n,timeout:200,children:o.jsx(R,{variant:"h6",sx:{position:"absolute",fontSize:"16px",fontWeight:500,color:i.palette.error.light},children:a("timer.error")})}),o.jsx(N,{in:m&&!n,timeout:300,children:o.jsx(R,{variant:"h1",sx:{position:"absolute",fontSize:"48px",fontWeight:500,color:i.palette.text.primary,lineHeight:1,letterSpacing:"-0.5px"},children:xn(c)})})]})})]})},yn=({timerState:t,animationState:e,hasError:n,compact:r,className:a})=>{const{t:i,i18n:c}=B.useTranslation(),s=A.useTheme(),{elapsedTime:l,currentProgress:d}=t,{showErrorAnimation:m,showPauseAnimation:g}=e;return r?o.jsx(v,{className:a,sx:{display:"flex",alignItems:"center",m:0},children:o.jsx(R,{variant:"body2",sx:{color:n?s.palette.error.light:s.palette.text.primary,fontSize:"14px",transition:"color 0.5s ease-out"},children:n?i("timer.error"):ke(l,c.language)})}):o.jsxs(v,{className:a,sx:{display:"flex",alignItems:"center",m:0,gap:1},children:[o.jsx(v,{sx:{width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:g||m?.6:1,transition:"opacity 0.5s ease-out"},children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",style:{transform:"rotate(-90deg)"},role:"img","aria-label":"Timer progress",children:[o.jsx("circle",{cx:"10",cy:"10",r:"8",fill:"none",stroke:n?s.palette.error.light:s.palette.success.main,strokeWidth:"2",opacity:.3,style:{transition:"stroke 0.8s ease-in-out, opacity 2s ease-in-out"}}),o.jsx("circle",{cx:"10",cy:"10",r:"8",fill:"none",stroke:n?s.palette.error.light:s.palette.success.main,strokeWidth:"2",strokeLinecap:"round",strokeDasharray:`${2*Math.PI*8}`,strokeDashoffset:`${2*Math.PI*8*(1-d/100)}`,style:{transition:"stroke-dashoffset 0.1s ease-out, stroke 0.8s ease-in-out, opacity 2s ease-in-out"}})]})}),o.jsx(R,{variant:"body2",sx:{color:n?s.palette.error.light:s.palette.text.primary,fontSize:"14px",lineHeight:"normal",letterSpacing:"normal",transition:"color 0.8s ease-in-out, font-size 0.3s ease-out, opacity 2s ease-in-out"},children:n?i("timer.error"):ke(l,c.language)})]})},Sn=()=>{const[t,e]=h.useState({showPauseAnimation:!1,showErrorAnimation:!1,showMainText:!0}),n=h.useRef(null),r=h.useRef(null),a=h.useRef(null),i=h.useCallback(()=>{e(g=>({...g,showPauseAnimation:!0})),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{e(g=>({...g,showPauseAnimation:!1}))},800)},[]),c=h.useCallback(()=>{e(g=>({...g,showErrorAnimation:!0})),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{e(g=>({...g,showErrorAnimation:!1}))},600)},[]),s=h.useCallback(()=>{e(g=>({...g,showErrorAnimation:!1})),r.current&&clearTimeout(r.current)},[]),l=h.useCallback(()=>{e(g=>({...g,showMainText:!1})),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{e(g=>({...g,showMainText:!0}))},200)},[]),d=h.useCallback(()=>{e(g=>({...g,showMainText:!0}))},[]),m=h.useCallback(()=>{n.current&&clearTimeout(n.current),r.current&&clearTimeout(r.current),a.current&&clearTimeout(a.current)},[]);return{animationState:t,triggerPauseAnimation:i,triggerErrorAnimation:c,clearErrorAnimation:s,triggerFadeTransition:l,setInitialAnimationState:d,cleanup:m}},jn=({autoStart:t,hasError:e,onPauseAnimation:n,onErrorAnimation:r,onClearErrorAnimation:a})=>{const[i,c]=h.useState({elapsedTime:0,isRunning:!1,isPausedState:!1,currentProgress:0,wasRunningBeforeError:!1}),s=h.useRef(null),l=h.useRef(null),d=h.useRef(0),m=h.useRef(0),[g]=Q.useInterpolation([0],{tension:80,friction:18,onChange:([f])=>{c(j=>({...j,currentProgress:f}))}}),p=h.useCallback((f=0)=>{const j=f/60%1*100;c(y=>({...y,elapsedTime:f,isPausedState:!1,currentProgress:j})),d.current=0,m.current=j,g.setImmediate([j]),t?(l.current=Date.now()-f*1e3,c(y=>({...y,isRunning:!0}))):l.current=null},[t,g]),u=h.useCallback(()=>{if(l.current&&i.isRunning){const j=(Date.now()-l.current)/1e3+d.current,y=j/60%1*100;g.setTarget([y]),c(T=>({...T,elapsedTime:Math.floor(j)}))}c(f=>({...f,isRunning:!1,isPausedState:!0})),n()},[i.isRunning,g,n]),x=h.useCallback(()=>{i.isPausedState&&(d.current=i.elapsedTime,l.current=Date.now(),c(f=>({...f,isRunning:!0,isPausedState:!1})))},[i.isPausedState,i.elapsedTime]),S=h.useCallback(()=>{c(f=>({...f,elapsedTime:0,isRunning:!1,isPausedState:!1,currentProgress:0})),d.current=0,l.current=null,m.current=0,g.setImmediate([0])},[g]),b=h.useCallback(()=>i.isPausedState,[i.isPausedState]);return h.useEffect(()=>{e?(i.isRunning&&(c(f=>({...f,wasRunningBeforeError:!0})),u()),r()):(i.wasRunningBeforeError&&!i.isRunning&&(c(f=>({...f,wasRunningBeforeError:!1})),x()),a())},[e,i.isRunning,i.wasRunningBeforeError,u,x,r,a]),h.useEffect(()=>{if(i.isRunning){const f=()=>{if(l.current){const y=(Date.now()-l.current)/1e3+d.current,T=y/60%1*100;c(w=>({...w,elapsedTime:Math.floor(y)})),Math.abs(T-m.current)>.1&&(g.setTarget([T]),m.current=T)}s.current=requestAnimationFrame(f)};s.current=requestAnimationFrame(f)}else s.current&&(cancelAnimationFrame(s.current),s.current=null);return()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i.isRunning,g]),h.useEffect(()=>{let f=null;const j=()=>{g.update(),f=requestAnimationFrame(j)};return f=requestAnimationFrame(j),()=>{f&&cancelAnimationFrame(f)}},[g]),{timerState:i,controls:{start:p,pause:u,resume:x,reset:S,isPaused:b}}},Cn=F.externalizeComponent(D.observer(({onTimerReady:t,autoStart:e=!0,variant:n="default",compact:r=!1,className:a,hasError:i=!1})=>{const{animationState:c,triggerPauseAnimation:s,triggerErrorAnimation:l,clearErrorAnimation:d,setInitialAnimationState:m,cleanup:g}=Sn(),{timerState:p,controls:u}=jn({autoStart:e,hasError:i,onPauseAnimation:s,onErrorAnimation:l,onClearErrorAnimation:d});return h.useEffect(()=>{m()},[m]),h.useEffect(()=>{let x=!0;const S=setTimeout(()=>{x&&t(u)},0);return()=>{x=!1,clearTimeout(S)}},[t,u]),h.useEffect(()=>g,[g]),n==="small"?o.jsx(yn,{timerState:p,animationState:c,hasError:i,compact:r,className:a}):o.jsx(bn,{timerState:p,animationState:c,hasError:i,className:a})})),Re=1e-4,vn={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class oe{constructor(e,n,r,a,i,c,s,l,d,m,g){this.nova=e,this.cellId=n,this.controller=r,this.motionGroup=a,this.initialMotionState=i,this.motionStateSocket=c,this.isVirtual=s,this.tcps=l,this.description=d,this.initialControllerState=m,this.controllerStateSocket=g,this.connectedJoggingSocket=null,this.joggingVelocity=10,this.activationState="inactive",this.rapidlyChangingMotionState=i,this.controllerState=m,g.addEventListener("message",p=>{var x;const u=(x=J.tryParseJson(p.data))==null?void 0:x.result;u&&M.runInAction(()=>{this.controllerState=u})}),c.addEventListener("message",p=>{var x;const u=(x=J.tryParseJson(p.data))==null?void 0:x.result;if(!u)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${p.data}`);ge(this.rapidlyChangingMotionState.joint_position,u.joint_position,Re)||M.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=u.joint_position}),pe(this.rapidlyChangingMotionState,u,Re)||M.runInAction(()=>{this.rapidlyChangingMotionState.tcp_pose=u.tcp_pose}),u.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==u.tcp&&M.runInAction(()=>{this.rapidlyChangingMotionState.tcp=u.tcp}),this.rapidlyChangingMotionState.standstill!==u.standstill&&M.runInAction(()=>{this.rapidlyChangingMotionState.standstill=u.standstill})}),M.makeAutoObservable(this)}static async connectMultiple(e,n,r={}){return Promise.all(n.map(a=>oe.connect(e,a,r)))}static async connect(e,n,r={}){var y,T;const a=r.cellId??"cell",[i,c]=n.split("@"),s=await e.api.controller.getCurrentRobotControllerState(a,c),l=s==null?void 0:s.motion_groups.find(C=>C.motion_group===n);if(!s||!l)throw new Error(`Controller ${c} or motion group ${n} not found`);const d=e.openReconnectingWebsocket(`/cells/${a}/controllers/${c}/motion-groups/${n}/state-stream`),m=await d.firstMessage(),g=(y=J.tryParseJson(m.data))==null?void 0:y.result;if(!g)throw new Error(`Unable to parse initial motion state message ${m.data}`);console.log(`Connected motion state websocket to motion group ${l.motion_group}. Initial state:
|
|
3
|
+
`,g);const u=(await e.api.controller.getRobotController(a,s.controller)).configuration.kind==="VirtualController",x=await e.api.motionGroup.getMotionGroupDescription(a,c,l.motion_group),S=Object.entries(x.tcps||{}).map(([C,w])=>({id:C,readable_name:w.name,position:w.pose.position,orientation:w.pose.orientation})),b=e.openReconnectingWebsocket(`/cells/${a}/controllers/${s.controller}/state-stream?response_rate=1000`),f=await b.firstMessage(),j=(T=J.tryParseJson(f.data))==null?void 0:T.result;if(!j)throw new Error(`Unable to parse initial controller state message ${f.data}`);return console.log(`Connected controller state websocket to controller ${s.controller}. Initial state:
|
|
4
|
+
`,j),new oe(e,a,s,l,g,d,u,S,x,j,b)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get modelFromController(){return this.description.motion_group_model}get joggingVelocityRads(){return this.joggingVelocity*Math.PI/180}get joints(){return this.initialMotionState.joint_position.map((e,n)=>({index:n}))}get dhParameters(){if(this.description.dh_parameters!==void 0)return this.description.dh_parameters.map(e=>({...vn,...e}))}get safetyZones(){return this.description.safety_zones}get mountingPosition(){var e,n,r;return this.description.mounting?[(((e=this.description.mounting.position)==null?void 0:e[0])||0)/1e3,(((n=this.description.mounting.position)==null?void 0:n[1])||0)/1e3,(((r=this.description.mounting.position)==null?void 0:r[2])||0)/1e3]:[0,0,0]}get mountingQuaternion(){var a,i,c,s,l,d;const e=new we.Vector3(((i=(a=this.description.mounting)==null?void 0:a.orientation)==null?void 0:i[0])||0,((s=(c=this.description.mounting)==null?void 0:c.orientation)==null?void 0:s[1])||0,((d=(l=this.description.mounting)==null?void 0:l.orientation)==null?void 0:d[2])||0),n=e.length(),r=e.normalize();return new we.Quaternion().setFromAxisAngle(r,n)}get isEstopActive(){return["SAFETY_STATE_ROBOT_EMERGENCY_STOP","SAFETY_STATE_DEVICE_EMERGENCY_STOP"].includes(this.controllerState.safety_state)}get isMoveableSafetyState(){return["SAFETY_STATE_NORMAL","SAFETY_STATE_REDUCED"].includes(this.controllerState.safety_state)}get isMoveableOperationMode(){return["OPERATION_MODE_AUTO","OPERATION_MODE_MANUAL","OPERATION_MODE_MANUAL_T1","OPERATION_MODE_MANUAL_T2"].includes(this.controllerState.operation_mode)}get canBeMoved(){return this.isMoveableSafetyState&&this.isMoveableOperationMode&&this.activationState==="active"}async deactivate(){if(this.activationState!=="active"){console.error("Tried to deactivate while already deactivating");return}M.runInAction(()=>{this.activationState="deactivating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_MONITOR"),M.runInAction(()=>{this.activationState="inactive"})}catch(e){throw M.runInAction(()=>{this.activationState="active"}),e}}async activate(){if(this.activationState!=="inactive"){console.error("Tried to activate while already activating");return}M.runInAction(()=>{this.activationState="activating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_CONTROL"),M.runInAction(()=>{this.activationState="active"})}catch(e){throw M.runInAction(()=>{this.activationState="inactive"}),e}}toggleActivation(){this.activationState==="inactive"?this.activate():this.activationState==="active"&&this.deactivate()}dispose(){this.motionStateSocket.close(),this.connectedJoggingSocket&&this.connectedJoggingSocket.close()}setJoggingVelocity(e){this.joggingVelocity=e}}function Ye(){var e,n,r,a,i,c;const t=A.createTheme({palette:{mode:"dark",text:{primary:"rgba(255, 255, 255, 1)",secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.38)"},primary:{main:"rgba(142, 86, 252, 1)",dark:"rgba(136, 58, 255, 1)",light:"rgba(157, 131, 246, 1)",contrastText:"rgba(255, 255, 255, 0.87)"},secondary:{main:"rgba(255, 255, 255, 1)",dark:"rgba(255, 255, 255, 0.06)",contrastText:"rgba(255, 255, 255, 0.87)"},tertiary:{main:"rgba(100, 255, 218, 1)",dark:"rgba(38, 166, 154, 1)",light:"rgba(167, 255, 235, 1)",contrastText:"rgba(0, 0, 0, 1)"},error:{main:"rgba(239, 83, 80, 1)",dark:"rgba(229, 57, 53, 1)",light:"rgba(239, 154, 154, 1)",contrastText:"rgba(255, 255, 255, 1)"},warning:{main:"rgba(255, 171, 64, 1)",dark:"rgba(255, 145, 0, 1)",light:"rgba(255, 209, 128, 1)",contrastText:"rgba(0, 0, 0, 0.87)"},success:{main:"rgba(38, 166, 154, 1)",dark:"rgba(0, 121, 107, 1)",light:"rgba(128, 203, 196, 1)",contrastText:"rgba(255, 255, 255, 0.87)"},background:{default:"rgba(2, 6, 23, 1)",paper:"rgba(17, 19, 31, 1)"},action:{active:"rgba(255, 255, 255, 0.56)",hover:"rgba(255, 255, 255, 0.08)",selected:"rgba(255, 255, 255, 0.16)",disabledBackground:"rgba(255, 255, 255, 0.12)",focus:"rgba(255, 255, 255, 0.12)",disabled:"rgba(255, 255, 255, 0.38)"},common:{white:"rgba(255, 255, 255, 1)",black:"rgba(0, 0, 0, 1)"},divider:"rgba(255, 255, 255, 0.12)",backgroundPaperElevation:{0:"rgba(17,19,31,1.0)",1:"rgba(20,22,35,1.0)",2:"rgba(23,25,39,1.0)",3:"rgba(26,28,43,1.0)",4:"rgba(29,31,47,1.0)",5:"rgba(32,34,51,1.0)",6:"rgba(35,37,55,1.0)",7:"rgba(38,40,59,1.0)",8:"rgba(41,43,63,1.0)",9:"rgba(44,46,67,1.0)",10:"rgba(47,49,71,1.0)",11:"rgba(50,52,75,1.0)",12:"rgba(53,55,79,1.0)",13:"rgba(56,58,83,1.0)",14:"rgba(59,61,87,1.0)",15:"rgba(62,64,91,1.0)",16:"rgba(57,63,87,1.0)"}},paletteExt:{primary:{hover:"rgba(142, 86, 252, 0.08)",selected:"rgba(142, 86, 252, 0.16)",focus:"rgba(142, 86, 252, 0.12)",focusVisible:"rgba(142, 86, 252, 0.3)",outlineBorder:"rgba(142, 86, 252, 0.5)"},secondary:{tonal:"rgba(255,255,255,0.1)"}}});return{...t,components:{MuiCssBaseline:{styleOverrides:{"html, body, *":{scrollbarWidth:"none",msOverflowStyle:"none"},"html:hover, body:hover, *:hover":{scrollbarWidth:"thin",scrollbarColor:`${t.palette.divider} transparent`},".MuiDataGrid-panelContent":{borderRadius:"16px !important","& .MuiPaper-root":{borderRadius:"16px !important"}},".MuiDataGrid-filterForm":{borderRadius:"16px !important","& .MuiInputBase-root":{borderRadius:"16px !important","& fieldset":{borderRadius:"16px !important"},"& .MuiOutlinedInput-notchedOutline":{borderRadius:"16px !important"}},"& .MuiTextField-root":{"& .MuiInputBase-root":{borderRadius:"16px !important","& fieldset":{borderRadius:"16px !important"},"& .MuiOutlinedInput-notchedOutline":{borderRadius:"16px !important"}}}},".MuiDataGrid-filterFormValueInput":{"& .MuiInputBase-root":{borderRadius:"16px !important","& fieldset":{borderRadius:"16px !important"},"& .MuiOutlinedInput-notchedOutline":{borderRadius:"16px !important"}}}}},MuiDataGrid:{styleOverrides:{root:{},panelContent:{borderRadius:"16px !important"},filterForm:{"& .MuiInputBase-root":{borderRadius:"10px !important","& fieldset":{borderRadius:"10px !important"},"& .MuiOutlinedInput-notchedOutline":{borderRadius:"10px !important"}}},filterFormValueInput:{"& .MuiInputBase-root":{borderRadius:"10px !important","& fieldset":{borderRadius:"10px !important"},"& .MuiOutlinedInput-notchedOutline":{borderRadius:"10px !important"}}}}},MuiButton:{styleOverrides:{root:{textTransform:"none",borderRadius:"10px"}},variants:[{props:{color:"secondary",variant:"contained"},style:{border:`1px solid ${t.palette.divider}`,background:(r=(n=(e=t.paletteExt)==null?void 0:e.secondary)==null?void 0:n.tonal)==null?void 0:r.toString()}},{props:{color:"secondary",variant:"outlined"},style:{border:`1px solid ${t.palette.divider}`}}]},MuiTab:{styleOverrides:{root:{textTransform:"none",color:t.palette.text.secondary,"&.Mui-selected":{color:t.palette.text.primary}}}},MuiTabs:{styleOverrides:{root:{background:(a=t.palette.backgroundPaperElevation)==null?void 0:a[1]}}},MuiToggleButtonGroup:{styleOverrides:{root:{".MuiToggleButtonGroup-firstButton":{borderRadius:"10px 0 0 10px"},".MuiToggleButtonGroup-lastButton":{borderRadius:"0 10px 10px 0"}}}},MuiToggleButton:{styleOverrides:{root:{textTransform:"none",padding:"6px 16px"}}},MuiSelect:{variants:[{props:{variant:"filled"},style:{borderRadius:"10px","::before, ::after":{visibility:"collapse"},".MuiInputBase-input":{padding:"6px 16px",borderRadius:"10px"}}}]},MuiDrawer:{styleOverrides:{paper:{border:"none",boxShadow:"4px 0 8px -4px rgba(0, 0, 0, 0.3)"}}},MuiFab:{styleOverrides:{root:{background:(c=(i=t.paletteExt)==null?void 0:i.secondary)==null?void 0:c.tonal}},variants:[{props:{color:"primary"},style:{background:t.palette.primary.main}}]}},componentsExt:{JoggingPanel:{JoggingCartesian:{Axis:{X:{backgroundColor:"rgba(215, 66, 56, 1)",borderColor:"rgba(215, 66, 56, 1)",buttonBackgroundColor:{default:"rgba(241, 77, 66, 1)",pressed:"rgba(138, 41, 35, 1)",hovered:"rgba(241, 77, 66, 1)",disabled:"rgba(241, 77, 66, 1)"},color:"rgba(255, 198, 198, 1)",labelColor:t.palette.text.primary},Y:{backgroundColor:"rgba(20, 151, 108, 1)",borderColor:"rgba(20, 151, 108, 1)",buttonBackgroundColor:{default:"rgba(28, 188, 135, 1)",pressed:"rgba(11, 89, 63, 1)",disabled:"rgba(28, 188, 135, 1)",hovered:"rgba(28, 188, 135, 1)"},color:"rgba(215, 255, 242, 1)",labelColor:t.palette.text.primary},Z:{backgroundColor:"rgba(1, 87, 155, 1)",borderColor:"rgba(1, 87, 155, 1)",buttonBackgroundColor:{default:"rgba(2, 136, 209, 1)",pressed:"rgba(2, 64, 114, 1)",disabled:"rgba(2, 136, 209, 1)",hovered:"rgba(2, 136, 209, 1)"},color:"rgba(210, 239, 255, 1)",labelColor:t.palette.text.primary}}},JoggingJoint:{Joint:{arrowColor:t.palette.text.primary}},VelocitySlider:{sliderLegendColor:t.palette.text.primary}}}}}function Tn(){const t=Ye();return t.palette.mode="light",t}function wn(t){var r,a,i,c;let e=!0;((r=t.palette)==null?void 0:r.mode)==="light"?e=!1:((a=t.palette)==null?void 0:a.mode)!=="dark"&&(e=!(typeof window<"u"&&((c=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: light)"))==null?void 0:c.matches)));const n=e?Ye():Tn();return A.createTheme(n,t)}exports.AppHeader=Ft;exports.ConnectedMotionGroup=oe;exports.CycleTimer=Nt;exports.JoggerConnection=re;exports.JoggingCartesianAxisControl=ce;exports.JoggingJointValueControl=Je;exports.JoggingPanel=Kt;exports.JoggingStore=ae;exports.LoadingCover=Le;exports.LoadingErrorMessage=ze;exports.LogPanel=ln;exports.LogStore=Ge;exports.LogViewer=Ue;exports.MotionStreamConnection=ie;exports.NoMotionGroupModal=dn;exports.PoseCartesianValues=tn;exports.PoseJointValues=nn;exports.RobotListItem=un;exports.RobotSetupReadinessIndicator=He;exports.RobotSetupReadinessState=me;exports.SelectableFab=pn;exports.TabBar=fn;exports.Timer=Cn;exports.VelocitySlider=Ve;exports.VelocitySliderLabel=he;exports.WandelbotsDataGrid=De;exports.createDebugMessage=on;exports.createErrorMessage=sn;exports.createInfoMessage=rn;exports.createLogMessage=K;exports.createNovaMuiTheme=wn;exports.createWarningMessage=an;exports.jointValuesEqual=ge;exports.poseEqual=Fe;exports.tcpMotionEqual=pe;exports.unwrapRotationVector=Be;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { SxProps } from "@mui/material/styles";
|
|
2
|
-
import {
|
|
2
|
+
import { Nova } from "@wandelbots/nova-js/v2";
|
|
3
3
|
import { JoggingStore } from "./JoggingStore";
|
|
4
4
|
export type JoggingPanelTabId = "cartesian" | "joint";
|
|
5
5
|
export type JoggingPanelProps = {
|
|
6
|
-
/** Either an existing
|
|
7
|
-
nova:
|
|
6
|
+
/** Either an existing Nova client or the base url of a deployed Nova instance */
|
|
7
|
+
nova: Nova | string;
|
|
8
8
|
/** Id of the motion group to move e.g. 0@ur5e */
|
|
9
9
|
motionGroupId: string;
|
|
10
|
+
/** Cell id on the Nova instance. Defaults to "cell". */
|
|
11
|
+
cellId?: string;
|
|
10
12
|
/** Callback with the jogging panel's state store for further customization/config */
|
|
11
13
|
onSetup?: (store: JoggingStore) => void;
|
|
12
14
|
/** Any children will go at the bottom of the panel under the default contents */
|
|
@@ -182,7 +182,7 @@ export declare class JoggingStore {
|
|
|
182
182
|
onTabChange(_event: React.SyntheticEvent, newValue: number): void;
|
|
183
183
|
setSelectedCoordSystemId(id: string): void;
|
|
184
184
|
/**
|
|
185
|
-
* @deprecated Use {@link requestTcpChange} instead. This method now delegates
|
|
185
|
+
* @deprecated Use {@link JoggingStore.requestTcpChange} instead. This method now delegates
|
|
186
186
|
* to `requestTcpChange` which properly communicates the TCP change to the server.
|
|
187
187
|
*/
|
|
188
188
|
setSelectedTcpId(id: string): void;
|
|
@@ -192,7 +192,8 @@ export declare class JoggingStore {
|
|
|
192
192
|
*
|
|
193
193
|
* If the jogger is actively jogging, the websocket is reinitialised with the new TCP.
|
|
194
194
|
* If the jogger is idle, a jogging websocket is briefly opened to communicate the
|
|
195
|
-
* TCP change
|
|
195
|
+
* TCP change. The websocket is kept open until the state-stream confirms the
|
|
196
|
+
* change (or a 1s timeout), to ensure the backend has time to process it.
|
|
196
197
|
*/
|
|
197
198
|
requestTcpChange(tcpId: string): Promise<void>;
|
|
198
199
|
private waitForTcpConfirmation;
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/theming-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/theming-CDWrELt_.cjs"),o=require("./chunks/interpolation-C9sLsved.cjs"),t=require("./chunks/externalizeComponent-OO4jcrz5.cjs"),a=require("./chunks/SafetyBar-VvOZ9aRM.cjs");exports.AppHeader=e.AppHeader;exports.ConnectedMotionGroup=e.ConnectedMotionGroup;exports.CycleTimer=e.CycleTimer;exports.JoggerConnection=e.JoggerConnection;exports.JoggingCartesianAxisControl=e.JoggingCartesianAxisControl;exports.JoggingJointValueControl=e.JoggingJointValueControl;exports.JoggingPanel=e.JoggingPanel;exports.JoggingStore=e.JoggingStore;exports.LoadingCover=e.LoadingCover;exports.LoadingErrorMessage=e.LoadingErrorMessage;exports.LogPanel=e.LogPanel;exports.LogStore=e.LogStore;exports.LogViewer=e.LogViewer;exports.MotionStreamConnection=e.MotionStreamConnection;exports.NoMotionGroupModal=e.NoMotionGroupModal;exports.PoseCartesianValues=e.PoseCartesianValues;exports.PoseJointValues=e.PoseJointValues;exports.RobotListItem=e.RobotListItem;exports.RobotSetupReadinessIndicator=e.RobotSetupReadinessIndicator;exports.RobotSetupReadinessState=e.RobotSetupReadinessState;exports.SelectableFab=e.SelectableFab;exports.TabBar=e.TabBar;exports.Timer=e.Timer;exports.VelocitySlider=e.VelocitySlider;exports.VelocitySliderLabel=e.VelocitySliderLabel;exports.WandelbotsDataGrid=e.WandelbotsDataGrid;exports.createDebugMessage=e.createDebugMessage;exports.createErrorMessage=e.createErrorMessage;exports.createInfoMessage=e.createInfoMessage;exports.createLogMessage=e.createLogMessage;exports.createNovaMuiTheme=e.createNovaMuiTheme;exports.createWarningMessage=e.createWarningMessage;exports.jointValuesEqual=e.jointValuesEqual;exports.poseEqual=e.poseEqual;exports.tcpMotionEqual=e.tcpMotionEqual;exports.unwrapRotationVector=e.unwrapRotationVector;exports.ProgramControl=o.ProgramControl;exports.ProgramState=o.ProgramState;exports.ProgramStateIndicator=o.ProgramStateIndicator;exports.ValueInterpolator=o.ValueInterpolator;exports.useAnimationFrame=o.useAnimationFrame;exports.useAutorun=o.useAutorun;exports.useInterpolation=o.useInterpolation;exports.useMounted=o.useMounted;exports.useReaction=o.useReaction;exports.i18n=t.i18n;exports.SafetyBar=a.SafetyBar;
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as o, s, C as t, t as r, a as n, b as i, d as g, J as l, f as u, g as c, h as d, L as p, n as m, M, N as S, P as b, e as C, R as V, p as L, o as P, S as f, T as J, q as R, V as x, r as I, W as A, j as E, m as T, k as q, i as y, c as v, l as w, u as G, v as N, w as W, x as h } from "./chunks/theming-
|
|
1
|
+
import { A as o, s, C as t, t as r, a as n, b as i, d as g, J as l, f as u, g as c, h as d, L as p, n as m, M, N as S, P as b, e as C, R as V, p as L, o as P, S as f, T as J, q as R, V as x, r as I, W as A, j as E, m as T, k as q, i as y, c as v, l as w, u as G, v as N, w as W, x as h } from "./chunks/theming-CDIQLLiN.js";
|
|
2
2
|
import { a as B, P as D, b as F, V as k, e as H, c as z, f as K, u as O, d as Q } from "./chunks/interpolation-DG8VTxzS.js";
|
|
3
3
|
import { i as X } from "./chunks/externalizeComponent-EDymnaGR.js";
|
|
4
4
|
import { S as Z } from "./chunks/SafetyBar-CxxIVVeR.js";
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/MotionGroupVisualizer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/MotionGroupVisualizer-OZwEAMLA.cjs"),e=require("./chunks/theming-CDWrELt_.cjs"),t=require("./chunks/interpolation-C9sLsved.cjs"),i=require("./chunks/externalizeComponent-OO4jcrz5.cjs"),s=require("./chunks/SafetyBar-VvOZ9aRM.cjs"),a=require("./chunks/robot-SEtfVAmf.cjs"),n=require("./chunks/wbLogo-G_IfZ03l.cjs"),r=require("./chunks/safety-state-stop-CgPfwC18.cjs");exports.CollisionSceneRenderer=o.CollisionSceneRenderer;exports.LinearAxis=o.LinearAxis;exports.MANUFACTURER_HOME_CONFIGS=o.MANUFACTURER_HOME_CONFIGS;exports.MotionGroupVisualizer=o.MotionGroupVisualizer;exports.PresetEnvironment=o.PresetEnvironment;exports.Robot=o.Robot;exports.RobotCard=o.RobotCard;exports.SafetyZonesRenderer=o.SafetyZonesRenderer;exports.SupportedLinearAxis=o.SupportedLinearAxis;exports.SupportedRobot=o.SupportedRobot;exports.TrajectoryRenderer=o.TrajectoryRenderer;exports.defaultAxisConfig=o.defaultAxisConfig;exports.defaultGetModel=o.defaultGetModel;exports.extractManufacturer=o.extractManufacturer;exports.getDefaultHomeConfig=o.getDefaultHomeConfig;exports.AppHeader=e.AppHeader;exports.ConnectedMotionGroup=e.ConnectedMotionGroup;exports.CycleTimer=e.CycleTimer;exports.JoggerConnection=e.JoggerConnection;exports.JoggingCartesianAxisControl=e.JoggingCartesianAxisControl;exports.JoggingJointValueControl=e.JoggingJointValueControl;exports.JoggingPanel=e.JoggingPanel;exports.JoggingStore=e.JoggingStore;exports.LoadingCover=e.LoadingCover;exports.LoadingErrorMessage=e.LoadingErrorMessage;exports.LogPanel=e.LogPanel;exports.LogStore=e.LogStore;exports.LogViewer=e.LogViewer;exports.MotionStreamConnection=e.MotionStreamConnection;exports.NoMotionGroupModal=e.NoMotionGroupModal;exports.PoseCartesianValues=e.PoseCartesianValues;exports.PoseJointValues=e.PoseJointValues;exports.RobotListItem=e.RobotListItem;exports.RobotSetupReadinessIndicator=e.RobotSetupReadinessIndicator;exports.RobotSetupReadinessState=e.RobotSetupReadinessState;exports.SelectableFab=e.SelectableFab;exports.TabBar=e.TabBar;exports.Timer=e.Timer;exports.VelocitySlider=e.VelocitySlider;exports.VelocitySliderLabel=e.VelocitySliderLabel;exports.WandelbotsDataGrid=e.WandelbotsDataGrid;exports.createDebugMessage=e.createDebugMessage;exports.createErrorMessage=e.createErrorMessage;exports.createInfoMessage=e.createInfoMessage;exports.createLogMessage=e.createLogMessage;exports.createNovaMuiTheme=e.createNovaMuiTheme;exports.createWarningMessage=e.createWarningMessage;exports.jointValuesEqual=e.jointValuesEqual;exports.poseEqual=e.poseEqual;exports.tcpMotionEqual=e.tcpMotionEqual;exports.unwrapRotationVector=e.unwrapRotationVector;exports.ProgramControl=t.ProgramControl;exports.ProgramState=t.ProgramState;exports.ProgramStateIndicator=t.ProgramStateIndicator;exports.ValueInterpolator=t.ValueInterpolator;exports.useAnimationFrame=t.useAnimationFrame;exports.useAutorun=t.useAutorun;exports.useInterpolation=t.useInterpolation;exports.useMounted=t.useMounted;exports.useReaction=t.useReaction;exports.i18n=i.i18n;exports.SafetyBar=s.SafetyBar;exports.AxisXIcon=a.ForwardRef;exports.AxisYIcon=a.ForwardRef$1;exports.AxisZIcon=a.ForwardRef$2;exports.JogMinusIcon=a.ForwardRef$3;exports.JogPlusIcon=a.ForwardRef$4;exports.RobotIcon=a.ForwardRef$5;exports.RotationIcon=a.ForwardRef$6;exports.HomeIcon=n.ForwardRef;exports.JoggingIcon=n.ForwardRef$1;exports.OrientationCoordSystemIcon=n.ForwardRef$2;exports.OrientationToolIcon=n.ForwardRef$3;exports.WBLogoIcon=n.ForwardRef$4;exports.ControllerTypePhysicalIcon=r.ForwardRef;exports.ControllerTypeVirtualIcon=r.ForwardRef$1;exports.OperationModeAutomaticIcon=r.ForwardRef$2;exports.OperationModeErrorIcon=r.ForwardRef$3;exports.OperationModeManualIcon=r.ForwardRef$4;exports.SafetyStateErrorIcon=r.ForwardRef$5;exports.SafetyStateEstopIcon=r.ForwardRef$6;exports.SafetyStateManualActionRequiredIcon=r.ForwardRef$7;exports.SafetyStateNormalIcon=r.ForwardRef$8;exports.SafetyStateStopIcon=r.ForwardRef$9;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as e, L as s, M as t, h as r, P as n, b as i, R as c, S as l, c as g, f as u, T as d, a as p, d as S, e as I, g as f } from "./chunks/MotionGroupVisualizer-
|
|
2
|
-
import { A as m, s as C, C as R, t as b, a as x, b as y, d as A, J as L, f as P, g as V, h as E, L as J, n as T, M as F, N as O, P as G, e as N, R as h, p as q, o as v, S as H, T as W, q as j, V as w, r as B, W as D, j as U, m as Z, k as _, i as k, c as z, l as X, u as Y, v as K, w as Q, x as $ } from "./chunks/theming-
|
|
1
|
+
import { C as e, L as s, M as t, h as r, P as n, b as i, R as c, S as l, c as g, f as u, T as d, a as p, d as S, e as I, g as f } from "./chunks/MotionGroupVisualizer-CrJO299j.js";
|
|
2
|
+
import { A as m, s as C, C as R, t as b, a as x, b as y, d as A, J as L, f as P, g as V, h as E, L as J, n as T, M as F, N as O, P as G, e as N, R as h, p as q, o as v, S as H, T as W, q as j, V as w, r as B, W as D, j as U, m as Z, k as _, i as k, c as z, l as X, u as Y, v as K, w as Q, x as $ } from "./chunks/theming-CDIQLLiN.js";
|
|
3
3
|
import { a as oa, P as ea, b as sa, V as ta, e as ra, c as na, f as ia, u as ca, d as la } from "./chunks/interpolation-DG8VTxzS.js";
|
|
4
4
|
import { i as ua } from "./chunks/externalizeComponent-EDymnaGR.js";
|
|
5
5
|
import { S as pa } from "./chunks/SafetyBar-CxxIVVeR.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AutoReconnectingWebsocket } from "@wandelbots/nova-js";
|
|
2
|
-
import type { MotionGroupDescription, MotionGroupState,
|
|
2
|
+
import type { MotionGroupDescription, MotionGroupState, Nova, RobotControllerState } from "@wandelbots/nova-js/v2";
|
|
3
3
|
import * as THREE from "three";
|
|
4
4
|
import type { Vector3Simple } from "./JoggerConnection";
|
|
5
5
|
export type RobotTcpLike = {
|
|
@@ -11,12 +11,17 @@ export type RobotTcpLike = {
|
|
|
11
11
|
export type MotionGroupOption = {
|
|
12
12
|
selectionId: string;
|
|
13
13
|
};
|
|
14
|
+
export type ConnectedMotionGroupOptions = {
|
|
15
|
+
/** Cell id on the Nova instance. Defaults to "cell". */
|
|
16
|
+
cellId?: string;
|
|
17
|
+
};
|
|
14
18
|
/**
|
|
15
19
|
* Store representing the current state of a connected motion group.
|
|
16
20
|
* API v2 version, not used yet in the components.
|
|
17
21
|
*/
|
|
18
22
|
export declare class ConnectedMotionGroup {
|
|
19
|
-
readonly nova:
|
|
23
|
+
readonly nova: Nova;
|
|
24
|
+
readonly cellId: string;
|
|
20
25
|
readonly controller: RobotControllerState;
|
|
21
26
|
readonly motionGroup: MotionGroupState;
|
|
22
27
|
readonly initialMotionState: MotionGroupState;
|
|
@@ -26,8 +31,8 @@ export declare class ConnectedMotionGroup {
|
|
|
26
31
|
readonly description: MotionGroupDescription;
|
|
27
32
|
readonly initialControllerState: RobotControllerState;
|
|
28
33
|
readonly controllerStateSocket: AutoReconnectingWebsocket;
|
|
29
|
-
static connectMultiple(nova:
|
|
30
|
-
static connect(nova:
|
|
34
|
+
static connectMultiple(nova: Nova, motionGroupIds: string[], options?: ConnectedMotionGroupOptions): Promise<ConnectedMotionGroup[]>;
|
|
35
|
+
static connect(nova: Nova, motionGroupId: string, options?: ConnectedMotionGroupOptions): Promise<ConnectedMotionGroup>;
|
|
31
36
|
connectedJoggingSocket: WebSocket | null;
|
|
32
37
|
planData: any | null;
|
|
33
38
|
joggingVelocity: number;
|
|
@@ -38,7 +43,7 @@ export declare class ConnectedMotionGroup {
|
|
|
38
43
|
* movement controls in the UI should only be enabled in the "active" state
|
|
39
44
|
*/
|
|
40
45
|
activationState: "inactive" | "activating" | "deactivating" | "active";
|
|
41
|
-
constructor(nova:
|
|
46
|
+
constructor(nova: Nova, cellId: string, controller: RobotControllerState, motionGroup: MotionGroupState, initialMotionState: MotionGroupState, motionStateSocket: AutoReconnectingWebsocket, isVirtual: boolean, tcps: RobotTcpLike[], description: MotionGroupDescription, initialControllerState: RobotControllerState, controllerStateSocket: AutoReconnectingWebsocket);
|
|
42
47
|
get motionGroupId(): string;
|
|
43
48
|
get controllerId(): string;
|
|
44
49
|
get modelFromController(): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AutoReconnectingWebsocket } from "@wandelbots/nova-js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type Nova, type Pose } from "@wandelbots/nova-js/v2";
|
|
3
3
|
import { MotionStreamConnection } from "./MotionStreamConnection";
|
|
4
4
|
export type Vector3Simple = [number, number, number];
|
|
5
5
|
export type JoggerConnectionOptions = {
|
|
@@ -13,6 +13,8 @@ export type JoggerConnectionOptions = {
|
|
|
13
13
|
onError?: (err: unknown) => void;
|
|
14
14
|
tcp?: string;
|
|
15
15
|
orientation?: JoggerOrientation;
|
|
16
|
+
/** Cell id on the Nova instance. Defaults to "cell". */
|
|
17
|
+
cellId?: string;
|
|
16
18
|
};
|
|
17
19
|
export type JoggerMode = "jogging" | "trajectory" | "off";
|
|
18
20
|
export type JoggerOrientation = "coordsys" | "tool";
|
|
@@ -49,12 +51,13 @@ export declare class JoggerConnection {
|
|
|
49
51
|
* @param options.onError - Error handler for websocket errors
|
|
50
52
|
* @returns Promise resolving to initialized JoggerConnection instance
|
|
51
53
|
*/
|
|
52
|
-
static open(nova:
|
|
54
|
+
static open(nova: Nova, motionGroupId: string, options?: JoggerConnectionOptions): Promise<JoggerConnection>;
|
|
53
55
|
constructor(motionStream: MotionStreamConnection, options?: JoggerConnectionOptions | undefined);
|
|
54
56
|
getDefaultTcp(motionStream: MotionStreamConnection): string | undefined;
|
|
55
57
|
setOptions(options: Partial<JoggerConnectionOptions>): Promise<void>;
|
|
56
58
|
get motionGroupId(): string;
|
|
57
|
-
get nova():
|
|
59
|
+
get nova(): Nova;
|
|
60
|
+
get cellId(): string;
|
|
58
61
|
get numJoints(): number;
|
|
59
62
|
stop(): Promise<void>;
|
|
60
63
|
dispose(): Promise<void[]>;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { type AutoReconnectingWebsocket } from "@wandelbots/nova-js";
|
|
2
|
-
import type { MotionGroupDescription, MotionGroupState,
|
|
2
|
+
import type { MotionGroupDescription, MotionGroupState, Nova, RobotControllerState } from "@wandelbots/nova-js/v2";
|
|
3
3
|
/**
|
|
4
4
|
* Store representing the current state of a connected motion group.
|
|
5
5
|
*/
|
|
6
|
+
export type MotionStreamConnectionOptions = {
|
|
7
|
+
/** Cell id on the Nova instance. Defaults to "cell". */
|
|
8
|
+
cellId?: string;
|
|
9
|
+
};
|
|
6
10
|
export declare class MotionStreamConnection {
|
|
7
|
-
readonly nova:
|
|
11
|
+
readonly nova: Nova;
|
|
12
|
+
readonly cellId: string;
|
|
8
13
|
readonly controller: RobotControllerState;
|
|
9
14
|
readonly motionGroup: MotionGroupState;
|
|
10
15
|
readonly description: MotionGroupDescription;
|
|
11
16
|
readonly initialMotionState: MotionGroupState;
|
|
12
17
|
readonly motionStateSocket: AutoReconnectingWebsocket;
|
|
13
|
-
static open(nova:
|
|
18
|
+
static open(nova: Nova, motionGroupId: string, options?: MotionStreamConnectionOptions): Promise<MotionStreamConnection>;
|
|
14
19
|
rapidlyChangingMotionState: MotionGroupState;
|
|
15
|
-
constructor(nova:
|
|
20
|
+
constructor(nova: Nova, cellId: string, controller: RobotControllerState, motionGroup: MotionGroupState, description: MotionGroupDescription, initialMotionState: MotionGroupState, motionStateSocket: AutoReconnectingWebsocket);
|
|
16
21
|
get motionGroupId(): string;
|
|
17
22
|
get controllerId(): string;
|
|
18
23
|
get joints(): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.1-pr.dev-new-nova-js-client.614.87ed9a2",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
"dependencies": {
|
|
174
174
|
"@mui/x-charts": "^8.27.0",
|
|
175
175
|
"@mui/x-data-grid": "^8.27.0",
|
|
176
|
-
"@wandelbots/nova-js": "
|
|
176
|
+
"@wandelbots/nova-js": "3.10.0-pr.295.cb733a7",
|
|
177
177
|
"axios": "^1.15.0",
|
|
178
178
|
"dotenv": "^17.2.3",
|
|
179
179
|
"i18next-browser-languagedetector": "^8.2.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),g=require("three"),V=require("three-stdlib"),d=require("react"),S=require("./externalizeComponent-OO4jcrz5.cjs"),M=require("@react-three/drei"),pe=require("@mui/material/styles"),v=require("@mui/material/Box"),Y=require("@mui/material/Button"),he=require("@mui/material/Card"),Q=require("@mui/material/Divider"),X=require("@mui/material/Typography"),T=require("@react-three/fiber"),me=require("mobx-react-lite"),xe=require("react-i18next"),L=require("./interpolation-C9sLsved.cjs"),R=require("@wandelbots/nova-js/v2"),K=require("react-error-boundary");function ye(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const j=ye(g);function ge(e){switch(e.shape_type){case"convex_hull":return new V.ConvexGeometry(e.vertices.map(r=>new j.Vector3(r[0]/1e3,r[1]/1e3,r[2]/1e3)));case"box":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new j.SphereGeometry(e.radius/1e3);case"capsule":return new j.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new j.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new j.BufferGeometry}}function je({name:e,collider:n,children:r}){var f,u;const o=((f=n.pose)==null?void 0:f.position)??[0,0,0],i=((u=n.pose)==null?void 0:u.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),t.jsx("mesh",{name:e,position:new j.Vector3(o[0],o[1],o[2]).divideScalar(1e3),rotation:new j.Euler(i[0],i[1],i[2],"XYZ"),geometry:ge(n.shape),children:r})}function be({name:e,colliders:n,meshChildrenProvider:r,...o}){return t.jsx("group",{name:e,...o,children:Object.entries(n).map(([i,f])=>t.jsx(je,{name:i,collider:f,children:r(i,f)},i))})}function we({scene:e,meshChildrenProvider:n}){const r=e.colliders;return t.jsx("group",{children:r&&t.jsx(be,{meshChildrenProvider:n,colliders:r})})}function O(){return t.jsx(M.Environment,{frames:1,children:t.jsx(Me,{})})}const Re=[2,0,2,0,2,0,2,0];function Me({positions:e=Re}){return t.jsxs(t.Fragment,{children:[t.jsx(M.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),t.jsx("group",{rotation:[0,.5,0],children:t.jsx("group",{children:e.map((n,r)=>t.jsx(M.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,r*4],scale:[3,1,1]},r))})}),t.jsx(M.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),t.jsx(M.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),t.jsx(M.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),t.jsx(M.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),t.jsx(M.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const Z={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function ve({safetyZones:e,dhParameters:n,...r}){const o=d.useMemo(()=>S.dhParametersToPlaneSize(n??[]),[n]),i=(u,s)=>{var l,h;if(!((l=s==null?void 0:s.pose)!=null&&l.position)||!((h=s==null?void 0:s.pose)!=null&&h.orientation))return null;const y=new j.Vector3(s.pose.position[0]/1e3,s.pose.position[1]/1e3,s.pose.position[2]/1e3),a=new j.Vector3(s.pose.orientation[0],s.pose.orientation[1],s.pose.orientation[2]);let m;const c=s.shape.shape_type==="plane"?{...Z,side:j.DoubleSide}:{...Z,side:j.FrontSide};switch(s.shape.shape_type){case"plane":m=t.jsx("planeGeometry",{args:[o,o]});break;case"sphere":{const p=(s==null?void 0:s.shape).radius/1e3;m=t.jsx("sphereGeometry",{args:[p]});break}case"capsule":{const p=(s==null?void 0:s.shape).radius/1e3,x=(s==null?void 0:s.shape).cylinder_height/1e3;m=t.jsx("capsuleGeometry",{args:[p,x]});break}case"convex_hull":{const p=(s==null?void 0:s.shape).vertices.map(b=>new j.Vector3(b[0]/1e3,b[1]/1e3,b[2]/1e3)),x=S.verticesToCoplanarity(p);if(x.isCoplanar&&x.normal){const w=new j.Vector3().addVectors(p[0],x.normal.multiplyScalar(1e-4));p.push(w)}try{m=t.jsx("primitive",{object:new V.ConvexGeometry(p),attach:"geometry"})}catch(b){return console.log("Error creating ConvexGeometry:",b),null}break}case"rectangular_capsule":{const p=s.shape,x=p.radius/1e3,b=p.sphere_center_distance_x/1e3,w=p.sphere_center_distance_y/1e3,k=x*2;m=t.jsx("primitive",{object:new V.RoundedBoxGeometry(b,w,k,2,x),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",s.shape.shape_type),m=null}return t.jsxs("mesh",{renderOrder:u,position:y,quaternion:S.orientationToQuaternion(a),children:[m,t.jsx("meshStandardMaterial",{...c,polygonOffsetFactor:-u})]},`safety-zone-${s.shape.shape_type}-${u}`)},f=d.useMemo(()=>Object.values(e??{}).map((u,s)=>i(s,u)),[e,o]);return t.jsx("group",{...r,children:f})}function _e({trajectory:e,...n}){const r=(e==null?void 0:e.map(o=>{if(o.position&&o.position.length>=3){const[i,f,u]=o.position;if(Number.isFinite(i)&&Number.isFinite(f)&&Number.isFinite(u))return new j.Vector3(i/1e3,u/1e3,-f/1e3)}return null}).filter(o=>o!==null))||[];return t.jsx("group",{...n,children:r.length>0&&t.jsx(M.Line,{points:r,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const P=new Map;async function E(e,n){if(P.has(e))return P.get(e);const r=(async()=>{var u;const o=n||"",i=new R.NovaClient({instanceUrl:o}),f=i.api.motionGroupModels;(u=f.axios)!=null&&u.interceptors&&f.axios.interceptors.request.use(s=>{var y;return(y=s.url)!=null&&y.includes("/glb")&&(s.responseType="blob"),s});try{const s=await i.api.motionGroupModels.getMotionGroupGlbModel(e);return URL.createObjectURL(s)}catch(s){throw console.error("Failed to fetch model:",s),s}})();return P.set(e,r),r}function z(e){function n(r){return r.children.length===0?[r]:[r,...r.children.flatMap(o=>n(o))]}return n(e).filter(r=>te(r))}function ee(e){return e.name.endsWith("_FLG")}function te(e){return/_J[0-9]+$/.test(e.name)}function Se(e,n){let r;function o(i){if(ee(i)){if(r)throw Error(`Found multiple flange groups in robot model ${n}; first ${r.name} then ${i.name}. Only one _FLG group is allowed.`);r=i}te(i),i.children.map(o)}if(o(e.scene),!r)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}function re({rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:r,children:o}){const i=d.useRef([]),f=d.useRef(null),{invalidate:u}=T.useThree(),s=d.useRef(e);s.current=e,d.useEffect(()=>{const c=e.joint_position.filter(l=>l!==void 0);return f.current=new L.ValueInterpolator(c,{tension:120,friction:20,threshold:.001}),()=>{var l;(l=f.current)==null||l.destroy()}},[]),T.useFrame((c,l)=>{if(f.current){const h=f.current.update(l);a(),h||u()}});function y(c){c&&(i.current=z(c),a(),u())}function a(){var l;const c=((l=f.current)==null?void 0:l.getCurrentValues())||[];if(r)r(i.current,c);else for(const[h,p]of i.current.entries()){const x=n[h],b=x.theta||0,w=x.reverse_rotation_direction?-1:1;p.rotation.y=w*(c[h]||0)+b}}function m(c){var h;const l=c.joint_position.filter(p=>p!==void 0);(h=f.current)==null||h.setTarget(l),u()}return L.useAutorun(()=>{m(s.current)}),d.useEffect(()=>{m(e)},[e]),t.jsx("group",{ref:y,children:o})}const Te="line",Le="mesh";function ke({rapidlyChangingMotionState:e,dhParameters:n,...r}){const o=new g.Matrix4,i=d.useRef([]),f=d.useRef([]);d.useEffect(()=>{i.current=new Array(n.length).fill(null),f.current=new Array(n.length).fill(null)},[n.length]);function u(a,m){const c=new g.Vector3,l=new g.Quaternion,h=new g.Vector3;o.decompose(c,l,h);const p=c.clone(),x=new g.Matrix4().makeRotationY(a.theta+m*(a.reverse_rotation_direction?-1:1)).multiply(new g.Matrix4().makeTranslation(0,a.d/1e3,0)).multiply(new g.Matrix4().makeTranslation(a.a/1e3,0,0)).multiply(new g.Matrix4().makeRotationX(a.alpha));return o.multiply(x),o.decompose(c,l,h),{a:p,b:c}}function s(a,m,c,l){if(!n)return;const h=n[a];if(!h)return;const{a:p,b:x}=u(h,l);m.geometry.setPositions([p.toArray(),x.toArray()].flat()),c.position.set(x.x,x.y,x.z)}function y(a,m){o.identity();for(let c=0;c<Math.min(a.length,m.length);c++){const l=i.current[c],h=f.current[c];l&&h&&s(c,l,h,m[c])}}return t.jsx(re,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:y,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((a,m)=>{const{a:c,b:l}=u(a,e.joint_position[m]??0),h=`dhrobot_J0${m}`;return t.jsxs("group",{name:h,children:[t.jsx(M.Line,{ref:p=>{i.current[m]=p},name:Te,points:[c,l],color:"white",lineWidth:5}),t.jsxs("mesh",{ref:p=>{f.current[m]=p},name:Le,position:l,children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${m}`)]},h)})]})})}const Ee=console.warn;function ne(){return d.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ee(e)}},[]),null}function Ge(e){return e.type==="Mesh"}function Ce({url:e,flangeRef:n,postModelRender:r,...o}){const i=M.useGLTF(e),u=Se(i,"robot.glb").gltf,s=d.useCallback(a=>{a&&r&&r()},[r]);function y(a){try{return Ge(a)?a.geometry?t.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:ee(a)?n:void 0,children:a.children.map(y)},a.uuid)}catch(m){return console.warn("Error rendering node",a.name,m),null}}return t.jsx("group",{...o,dispose:null,ref:s,children:y(u.scene)})}function se({modelURL:e,flangeRef:n,postModelRender:r,...o}){const[i,f]=d.useState(null);return d.useEffect(()=>{let u=!1;return(async()=>{try{const y=typeof e=="string"?e:await e;u||f(a=>a===y?a:y)}catch(y){console.error("Failed to resolve model URL:",y)}})(),()=>{u=!0}},[e]),i?t.jsx(Ce,{url:i,flangeRef:n,postModelRender:r,...o}):null}const oe=(e,n)=>{e.userData.isGhost||(e.traverse(r=>{if(r instanceof j.Mesh){r.material instanceof j.Material&&(r.material.colorWrite=!1);const o=r.clone(),i=r.clone();o.material=new j.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:j.DoubleSide}),o.userData.isGhost=!0,i.material=new j.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:j.DoubleSide}),i.userData.isGhost=!0,r.parent&&(r.parent.add(o),r.parent.add(i))}}),e.userData.isGhost=!0)},ie=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(r=>{var o;r instanceof j.Mesh&&((o=r.userData)!=null&&o.isGhost?n.push(r):r.material instanceof j.Material&&(r.material.colorWrite=!0))}),n.forEach(r=>{r.parent&&r.parent.remove(r)}),e.userData.isGhost=!1},q=S.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:o=E,flangeRef:i,postModelRender:f,transparentColor:u,instanceUrl:s,...y})=>{const[a,m]=d.useState(null),c=d.useCallback(p=>{m(p)},[]);d.useEffect(()=>{a&&(u?oe(a,u):ie(a))},[a,u]);const l=d.useMemo(()=>{const p=o(n,s);if(!p)throw new Error(`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`);return p},[n,s,o]),h=t.jsx(ke,{rapidlyChangingMotionState:e,dhParameters:r,...y});return t.jsxs(K.ErrorBoundary,{fallback:h,onError:p=>{console.warn(p)},children:[t.jsx(d.Suspense,{fallback:h,children:t.jsx("group",{ref:c,children:t.jsx(re,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:l,postModelRender:f,flangeRef:i,...y})})})}),t.jsx(ne,{})]})});function ae({connectedMotionGroup:e,getModel:n=E,flangeRef:r,transparentColor:o,postModelRender:i,...f}){return e.dhParameters?t.jsx(q,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:o,postModelRender:i,...f}):null}const Ae=S.externalizeComponent(me.observer(({robotName:e,programState:n,safetyState:r,operationMode:o,driveToHomeEnabled:i=!1,onDriveToHomePress:f,onDriveToHomeRelease:u,connectedMotionGroup:s,robotComponent:y=ae,customContentComponent:a,className:m})=>{var N;const c=pe.useTheme(),{t:l}=xe.useTranslation(),[h,p]=d.useState(!1),x=d.useRef(null),b=d.useRef(null),[w,k]=d.useState(!1),[G,fe]=d.useState({width:400,height:600}),[Oe,de]=d.useState(0);d.useEffect(()=>{const F=()=>{if(b.current){const{offsetWidth:$,offsetHeight:H}=b.current;k($>H),fe({width:$,height:H})}};F();const W=new ResizeObserver(F);return b.current&&W.observe(b.current),()=>{W.disconnect()}},[]);const J=d.useCallback(()=>{de(F=>F+1)},[]),C=d.useCallback(()=>{!i||!f||(p(!0),f())},[i,f]),A=d.useCallback(()=>{!i||!u||(p(!1),u())},[i,u]),B=d.useCallback(()=>{h&&u&&(p(!1),u())},[h,u]),_=w?G.width<350:G.height<200,I=w?G.height<310:G.height<450;return t.jsx(he,{ref:b,className:m,sx:{width:"100%",height:"100%",display:"flex",flexDirection:w?"row":"column",position:"relative",overflow:"hidden",minWidth:{xs:180,sm:220,md:250},minHeight:w?{xs:200,sm:240,md:260}:{xs:150,sm:180,md:220},border:`1px solid ${c.palette.divider}`,borderRadius:"18px",boxShadow:"none",backgroundColor:((N=c.palette.backgroundPaperElevation)==null?void 0:N[8])||"#2A2A3F",backgroundImage:"none"},children:w?t.jsxs(t.Fragment,{children:[t.jsx(v,{sx:{flex:"0 0 50%",position:"relative",height:"100%",minHeight:"100%",maxHeight:"100%",borderRadius:1,m:{xs:1.5,sm:2,md:3},mr:{xs:.75,sm:1,md:1.5},overflow:"hidden",display:_?"none":"block"},children:!_&&t.jsxs(T.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute",top:0,left:0},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(O,{}),t.jsx(M.Bounds,{fit:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(y,{connectedMotionGroup:s,postModelRender:J})})]})}),t.jsxs(v,{sx:{flex:"1",display:"flex",flexDirection:"column",justifyContent:"flex-start",width:_?"100%":"50%"},children:[t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pb:{xs:1,sm:1.5,md:2},textAlign:"left"},children:[t.jsx(X,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:o})]}),t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pt:0,flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[!I&&a&&t.jsxs(v,{children:[t.jsx(a,{}),t.jsx(Q,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{mt:!I&&a?"auto":0},children:t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:{xs:1,sm:1.5,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Y,{ref:x,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:C,onMouseUp:A,onMouseLeave:B,onTouchStart:C,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:l("RobotCard.DriveToHome.bt")})})})]})]})]}):t.jsx(t.Fragment,{children:t.jsxs(v,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column"},children:[t.jsxs(v,{children:[t.jsx(X,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:o})]}),t.jsx(v,{sx:{flex:_?0:1,position:"relative",minHeight:_?0:{xs:120,sm:150,md:200},height:_?0:"auto",borderRadius:1,overflow:"hidden",display:_?"none":"block"},children:!_&&t.jsxs(T.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute"},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(O,{}),t.jsx(M.Bounds,{fit:!0,clip:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(y,{connectedMotionGroup:s,postModelRender:J})})]})}),t.jsxs(v,{children:[!I&&a&&t.jsxs(t.Fragment,{children:[t.jsx(a,{}),t.jsx(Q,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:!I&&a?{xs:1,sm:2,md:5}:{xs:.5,sm:1,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Y,{ref:x,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:C,onMouseUp:A,onMouseLeave:B,onTouchStart:C,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:l("RobotCard.DriveToHome.bt")})})]})]})})})})),Ie=Array(6).fill(2*Math.PI);function ce({rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:r,children:o}){const i=d.useRef([]),f=d.useRef([]),u=d.useRef(null),{invalidate:s}=T.useThree();d.useEffect(()=>{const c=e.joint_position.filter(l=>l!==void 0);return u.current=new L.ValueInterpolator(c,{tension:120,friction:20,threshold:.001}),()=>{var l;(l=u.current)==null||l.destroy()}},[]),T.useFrame((c,l)=>{if(u.current){const h=u.current.update(l);a(),h||s()}});function y(c){c&&(f.current=z(c),a(),s())}function a(){var l;const c=((l=u.current)==null?void 0:l.getCurrentValues())||[];if(r)r(f.current,c);else for(const[h,p]of f.current.entries()){const b=n[h].reverse_rotation_direction?-1:1;p.position.y=b*(c[h]||0)/1e3}}const m=d.useCallback(()=>{const c=e.joint_position.filter(l=>l!==void 0);requestAnimationFrame(()=>{var l;i.current=c,(l=u.current)==null||l.setTarget(c)})},[e]);return d.useEffect(()=>{m()},[e,m]),L.useAutorun(()=>{m()}),t.jsx("group",{ref:y,children:o})}function ue({rapidlyChangingMotionState:e,dhParameters:n,...r}){const o=new g.Matrix4,i=d.useRef(null),f=d.useRef(null);function u(a){const m=new g.Matrix4;for(let p=0;p<n.length;p++){const x=n[p],b=a[p]??0,w=new g.Matrix4().makeRotationY(x.theta).multiply(new g.Matrix4().makeTranslation(x.a/1e3,(x.d+b*(x.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(x.alpha));m.multiply(w)}const c=new g.Vector3,l=new g.Quaternion,h=new g.Vector3;return m.decompose(c,l,h),c}const s=u(e.joint_position);function y(a,m){o.identity();let c=new g.Vector3;for(let x=0;x<n.length;x++){const b=m[x]??0,w=n[x],k=new g.Matrix4().makeRotationY(w.theta).multiply(new g.Matrix4().makeTranslation(w.a/1e3,(w.d+b*(w.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(w.alpha));o.multiply(k)}const l=new g.Vector3,h=new g.Quaternion,p=new g.Vector3;if(o.decompose(l,h,p),c=l,i.current&&i.current.position.set(c.x,c.y,c.z),f.current){const x=f.current.geometry;x!=null&&x.setPositions&&x.setPositions([0,0,0,c.x,c.y,c.z])}}return t.jsx(ce,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:y,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{name:"Base",position:[0,0,0],children:[t.jsx("sphereGeometry",{args:[.02,32,32]}),t.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),t.jsx(M.Line,{ref:f,points:[new g.Vector3(0,0,0),s],color:"White",lineWidth:5}),t.jsxs("mesh",{ref:i,name:"TCP",position:s,children:[t.jsx("sphereGeometry",{args:[.025,32,32]}),t.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const U=S.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:o=E,flangeRef:i,postModelRender:f,transparentColor:u,instanceUrl:s,...y})=>{const[a,m]=d.useState(null),c=d.useCallback(h=>{m(h)},[]);d.useEffect(()=>{a&&(u?oe(a,u):ie(a))},[a,u]);const l=t.jsx(ue,{rapidlyChangingMotionState:e,dhParameters:r,...y});return t.jsxs(K.ErrorBoundary,{fallback:l,onError:h=>{console.warn(h)},children:[t.jsx(d.Suspense,{fallback:l,children:t.jsx("group",{ref:c,children:t.jsx(ce,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:(()=>{const h=o(n,s);if(!h){const p=new Blob([],{type:"model/gltf-binary"}),x=new File([p],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(x))}return h})(),postModelRender:f,flangeRef:i,...y})})})}),t.jsx(ne,{})]})});function Fe({connectedMotionGroup:e,getModel:n=E,flangeRef:r,transparentColor:o,postModelRender:i,...f}){if(!e.dhParameters)return null;const u=e.modelFromController||"";return u&&n(u)?t.jsx(U,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:u,dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:o,postModelRender:i,...f}):t.jsx(ue,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,...f})}const D={[R.Manufacturer.Abb]:[0,0,0,0,Math.PI/2,0,0],[R.Manufacturer.Fanuc]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Yaskawa]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Kuka]:[0,-Math.PI/2,Math.PI/2,0,Math.PI/2,0,0],[R.Manufacturer.Universalrobots]:[0,-Math.PI/2,-Math.PI/2,-Math.PI/2,Math.PI/2,-Math.PI/2,0]};function le(e){const[n]=e.split("_");switch(n){case"ABB":return R.Manufacturer.Abb;case"FANUC":return R.Manufacturer.Fanuc;case"YASKAWA":return R.Manufacturer.Yaskawa;case"KUKA":return R.Manufacturer.Kuka;case"UniversalRobots":return R.Manufacturer.Universalrobots;default:return null}}function Pe(e,n){const r=le(e);return r&&r in D?D[r]:n||null}const Ve=S.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:r,...o}=e,[i,f]=d.useState(R.JointTypeEnum.RevoluteJoint);d.useEffect(()=>{r.length&&f(r[0].type??R.JointTypeEnum.RevoluteJoint)},[r]);const u=d.useMemo(()=>n===null&&i===R.JointTypeEnum.RevoluteJoint,[n,i]),s=d.useMemo(()=>n===null&&i===R.JointTypeEnum.PrismaticJoint,[n,i]);return d.useMemo(()=>!!n,[n])||u?t.jsx(q,{dhParameters:r,...o}):s?t.jsx(U,{dhParameters:r,...o}):null});exports.CollisionSceneRenderer=we;exports.LinearAxis=Fe;exports.MANUFACTURER_HOME_CONFIGS=D;exports.MotionGroupVisualizer=Ve;exports.PresetEnvironment=O;exports.Robot=ae;exports.RobotCard=Ae;exports.SafetyZonesRenderer=ve;exports.SupportedLinearAxis=U;exports.SupportedRobot=q;exports.TrajectoryRenderer=_e;exports.defaultAxisConfig=Ie;exports.defaultGetModel=E;exports.extractManufacturer=le;exports.getDefaultHomeConfig=Pe;
|