@wandelbots/wandelbots-js-react-components 5.5.4 → 5.5.5-pr.ci-pr-preview-concurrency.611.8fb1478
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";const o=require("react/jsx-runtime"),A=require("@mui/material/styles"),He=require("@mui/material/AppBar"),Ee=require("@mui/material/Backdrop"),T=require("@mui/material/Box"),W=require("@mui/material/IconButton"),Ye=require("@mui/material/Menu"),G=require("@mui/material/MenuItem"),Ze=require("@mui/material/Toolbar"),R=require("@mui/material/Typography"),D=require("mobx-react-lite"),m=require("react"),B=require("./externalizeComponent-BHZdH14U.cjs"),Xe=require("@mui/material/SvgIcon"),q=require("@mui/material/Fade"),Qe=require("@mui/x-charts/Gauge"),L=require("react-i18next"),Y=require("./interpolation-B84QX33C.cjs"),Ke=require("@mui/icons-material/Clear"),et=require("@mui/icons-material/FilterList"),Ce=require("@mui/icons-material/Search"),U=require("@mui/material/Divider"),z=require("@mui/x-data-grid"),tt=require("@mui/icons-material/OpenWith"),nt=require("@mui/icons-material/Share"),P=require("@mui/material/Stack"),Pe=require("@mui/material/Tab"),_e=require("@mui/material/Tabs"),V=require("@wandelbots/nova-js/v2"),ue=require("lodash-es"),_=require("mobx"),J=require("@wandelbots/nova-js"),se=require("three/src/math/Vector3.js"),ot=require("@mui/material/CircularProgress"),it=require("@mui/material/utils"),rt=require("./SafetyBar-CLm3UQRA.cjs"),at=require("@mui/material/Alert"),st=require("@mui/material/AlertTitle"),H=require("@mui/material/Button"),Te=require("@mui/material/ToggleButton"),N=require("./robot-SEtfVAmf.cjs"),lt=require("lodash-es/isEqual.js"),ct=require("@mui/material/FormControl"),dt=require("@mui/material/InputLabel"),ut=require("@mui/material/Select"),te=require("lodash-es/keyBy.js"),gt=require("lodash-es/uniqueId.js"),pt=require("@mui/material/ToggleButtonGroup"),Oe=require("@mui/material/Slider"),mt=require("lodash-es/isNumber.js"),ht=require("@mui/icons-material/ChevronLeft"),ft=require("@mui/icons-material/ChevronRight"),xt=require("lodash-es/throttle.js"),bt=require("@mui/material/Tooltip"),yt=require("@mui/icons-material/ContentCopy"),St=require("@mui/icons-material/DescriptionOutlined"),vt=require("@mui/icons-material/ExpandLess"),jt=require("@mui/icons-material/ExpandMore"),Ct=require("@mui/material/Paper"),Tt=require("@mui/material/Dialog"),wt=require("@mui/material/DialogActions"),kt=require("@mui/material/DialogContent"),Mt=require("@mui/material/DialogTitle"),It=require("@mui/icons-material/Error"),Rt=require("@mui/material/Chip"),Et=require("@mui/material/Fab"),Pt=require("@mui/material/Badge"),_t=require("@mui/x-charts"),le=require("three");function Ot(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const we=Ot(le),At=e=>o.jsx(Xe,{...e,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"})}),Dt=B.externalizeComponent(D.observer(e=>{const{appIcon:t,appName:n,apps:a=[],onAppSelect:r,disabled:i=!1,sx:c}=e,[s,l]=m.useState(null),g=!!s,h=p=>{l(p.currentTarget)},d=()=>{l(null)},u=p=>{d(),p.onClick?p.onClick():p.href&&(window.location.href=p.href),r==null||r(p)};return o.jsxs(o.Fragment,{children:[o.jsx(He,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...c},children:o.jsxs(Ze,{sx:{minHeight:"62px !important"},children:[o.jsx(T,{sx:{mr:1,display:"flex",alignItems:"center"},children:t}),o.jsxs(T,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[o.jsx(R,{component:"h1",sx:{fontWeight:"bold",fontSize:"1rem"},children:n}),a.length>0&&o.jsx(W,{color:"inherit","aria-label":"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:h,disabled:i,sx:{ml:1,width:28,height:28,borderRadius:"6px",padding:0,backgroundColor:p=>A.alpha(p.palette.common.white,.1),opacity:1,"&:hover":{backgroundColor:p=>A.alpha(p.palette.common.white,.16)},"& .MuiSvgIcon-root":{fontSize:"8px",width:"8px",height:"6px"}},children:o.jsx(At,{})})]})]})}),o.jsx(Ee,{open:g,onClick:d,sx:{backdropFilter:"blur(4px)",backgroundColor:"rgba(0, 0, 0, 0.3)",zIndex:p=>p.zIndex.modal-1}}),o.jsx(Ye,{id:"app-menu",anchorEl:s,open:g,onClose:d,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{zIndex:p=>p.zIndex.modal,"& .MuiPaper-root":{minWidth:200,mt:1}},children:a.map(p=>o.jsxs(G,{onClick:()=>u(p),children:[o.jsx(T,{sx:{display:"flex",alignItems:"center"},children:p.icon}),o.jsx(R,{variant:"body1",sx:{ml:2},children:p.name})]},p.id))})]})})),Jt=e=>{const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),a=Math.floor(e%3600/60),r=e%60,i=[];return t>0?(i.push(t.toString()),i.push(n.toString().padStart(2,"0")),i.push(a.toString().padStart(2,"0")),i.push(r.toString().padStart(2,"0"))):n>0?(i.push(n.toString()),i.push(a.toString().padStart(2,"0")),i.push(r.toString().padStart(2,"0"))):(i.push(a.toString()),i.push(r.toString().padStart(2,"0"))),i.join(":")},$=(e,t)=>{const n=Math.floor(e/86400),a=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60;if(typeof Intl<"u"&&"DurationFormat"in Intl)try{const s={};return n>0&&(s.days=n),a>0&&(s.hours=a),r>0&&(s.minutes=r),(i>0||Object.keys(s).length===0)&&(s.seconds=i),new Intl.DurationFormat(t,{style:"narrow"}).format(s)}catch{}const c=[];return n>0&&c.push(`${n}d`),a>0&&c.push(`${a}h`),r>0&&c.push(`${r}m`),(i>0||c.length===0)&&c.push(`${i}s`),c.join(" ")},Bt=(e,t,n)=>e==="countdown"&&n!==null?Math.min(100,t/n*100):e==="measuring"?t/60%1*100:0,Ft=({timerState:e,animationState:t,hasError:n,className:a})=>{const{t:r,i18n:i}=L.useTranslation(),c=A.useTheme(),{currentState:s,remainingTime:l,maxTime:g,currentProgress:h}=e,{showErrorAnimation:d,showPauseAnimation:u,showPulsatingText:p,pulsatingFinished:y,showLabels:S,showMainText:x,showIdlePulsating:f,idleDotsCount:v}=t;return o.jsxs(T,{className:a,sx:{position:"relative",width:264,height:264,display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx(Qe.Gauge,{width:264,height:264,value:s==="idle"?0:h,valueMin:0,valueMax:100,innerRadius:"85%",outerRadius:"100%",margin:0,skipAnimation:!0,text:()=>"",sx:{opacity:u||d?.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(T,{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(T,{sx:{height:"16px",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:1},children:o.jsx(q,{in:S&&!n&&s!=="idle"&&s!=="success",timeout:300,children:o.jsx(R,{variant:"body2",sx:{fontSize:"12px",color:s==="measured"&&(p||y)?c.palette.success.main:c.palette.text.secondary,transition:"color 0.8s ease-in-out"},children:o.jsx("span",{style:{opacity:s==="measured"&&y?p?1:.6:1,transition:"opacity 2s ease-in-out"},children:s==="measuring"||s==="measured"?r("CycleTimer.CycleTime.lb","Cycle Time"):s==="countdown"?r("CycleTimer.RemainingTime.lb","Remaining Time"):""})})})}),o.jsxs(T,{sx:{position:"relative",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:.5},children:[o.jsx(q,{in:x&&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:r("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(v)})]})}),o.jsx(q,{in:x&&n,timeout:200,children:o.jsx(R,{variant:"h3",sx:{position:"absolute",fontSize:"40px",fontWeight:400,color:"#FFFFFF",lineHeight:"116.7%"},children:r("CycleTimer.Error.lb","Error")})}),o.jsx(q,{in:x&&!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:Jt(l)})})})]}),o.jsx(T,{sx:{height:"16px",display:"flex",marginTop:.5,alignItems:"center",justifyContent:"center"},children:o.jsx(q,{in:S&&!n&&s!=="idle"&&s!=="success",timeout:300,children:o.jsx(R,{variant:"body2",sx:{fontSize:"12px",color:s==="measured"&&(p||y)?c.palette.success.main:c.palette.text.secondary,transition:"color 0.8s ease-in-out"},children:o.jsx("span",{style:{opacity:s==="measured"&&y?p?1:.6:1,transition:"opacity 2s ease-in-out"},children:s==="measuring"?r("CycleTimer.Measuring.lb","measuring..."):s==="measured"?r("CycleTimer.Determined.lb","determined"):s==="countdown"&&g!==null?r("CycleTimer.OfTime.lb",{time:$(g,i.language)}):""})})})})]})]})},Lt=({timerState:e,animationState:t,hasError:n,compact:a,className:r})=>{const{t:i,i18n:c}=L.useTranslation(),s=A.useTheme(),{currentState:l,remainingTime:g,maxTime:h}=e,{showErrorAnimation:d,showPauseAnimation:u,showPulsatingText:p,pulsatingFinished:y,showIdlePulsating:S,idleDotsCount:x}=t;return a&&l==="idle"?o.jsx(T,{className:r,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":$(g,c.language)})}):o.jsxs(T,{className:r,sx:{display:"flex",alignItems:"center",m:0,gap:1},children:[!(l==="idle"&&a)&&o.jsx(T,{sx:{width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:u||d?.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"?p||y?s.palette.success.main:s.palette.text.secondary:s.palette.success.main,strokeWidth:"2",opacity:l==="measured"&&y?p?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"?p||y?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:e.currentProgress)/100)}`,style:{opacity:l==="measured"&&y?p?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"?p||y?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"&&y?p?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(x)})]}):l==="measuring"?a?$(g,c.language):`${$(g,c.language)} / ${i("CycleTimer.Measuring.lb","measuring...")}`:l==="measured"?a?$(g,c.language):`${$(g,c.language)} / ${i("CycleTimer.Determined.lb","determined")}`:l==="countdown"&&h!==null?a?$(g,c.language):`${$(g,c.language)} / ${i("CycleTimer.Time.lb",{time:$(h,c.language)})}`:$(g,c.language)})]})},zt=()=>{const[e,t]=m.useState({showPauseAnimation:!1,showErrorAnimation:!1,showPulsatingText:!1,pulsatingFinished:!1,showLabels:!0,showMainText:!0,showIdlePulsating:!1,idleDotsCount:0}),n=m.useRef(null),a=m.useRef(null),r=m.useRef(null),i=m.useRef(null),c=m.useRef(0),s=m.useRef(null),l=m.useRef(null),g=m.useCallback(()=>{t(b=>({...b,showPauseAnimation:!0})),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{t(b=>({...b,showPauseAnimation:!1}))},800)},[]),h=m.useCallback(()=>{t(b=>({...b,showErrorAnimation:!0})),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{t(b=>({...b,showErrorAnimation:!1}))},600)},[]),d=m.useCallback(()=>{t(b=>({...b,showErrorAnimation:!1})),a.current&&clearTimeout(a.current)},[]),u=m.useCallback(b=>{c.current=0,t(C=>({...C,showPulsatingText:!0,pulsatingFinished:!1})),setTimeout(()=>{t(C=>({...C,pulsatingFinished:!0})),r.current=setInterval(()=>{t(C=>({...C,showPulsatingText:!C.showPulsatingText}))},2e3),b&&b()},800)},[]),p=m.useCallback(()=>{r.current&&(clearInterval(r.current),r.current=null),t(b=>({...b,showPulsatingText:!1,pulsatingFinished:!1})),c.current=0},[]),y=m.useCallback(()=>{t(b=>({...b,showIdlePulsating:!0})),s.current=setInterval(()=>{t(b=>({...b,showIdlePulsating:!b.showIdlePulsating}))},2e3),l.current=setInterval(()=>{t(b=>({...b,idleDotsCount:(b.idleDotsCount+1)%4}))},800)},[]),S=m.useCallback(()=>{s.current&&(clearInterval(s.current),s.current=null),l.current&&(clearInterval(l.current),l.current=null),t(b=>({...b,showIdlePulsating:!1,idleDotsCount:0}))},[]),x=m.useCallback(()=>{t(b=>({...b,showLabels:!1,showMainText:!1})),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{t(b=>({...b,showLabels:!0,showMainText:!0}))},200)},[]),f=m.useCallback(()=>{t(b=>({...b,showLabels:!0,showMainText:!0}))},[]),v=m.useCallback(()=>{n.current&&clearTimeout(n.current),a.current&&clearTimeout(a.current),i.current&&clearTimeout(i.current),r.current&&clearInterval(r.current),s.current&&clearInterval(s.current),l.current&&clearInterval(l.current)},[]);return{animationState:e,triggerPauseAnimation:g,triggerErrorAnimation:h,clearErrorAnimation:d,startPulsatingAnimation:u,stopPulsatingAnimation:p,startIdleAnimations:y,stopIdleAnimations:S,triggerFadeTransition:x,setInitialAnimationState:f,cleanup:v}},$t=({autoStart:e,onCycleEnd:t,onMeasuringComplete:n,hasError:a,onPauseAnimation:r,onErrorAnimation:i,onClearErrorAnimation:c,onStartPulsating:s})=>{const[l,g]=m.useState({currentState:"idle",remainingTime:0,maxTime:null,isRunning:!1,isPausedState:!1,currentProgress:0,wasRunningBeforeError:!1}),h=m.useRef(null),d=m.useRef(null),u=m.useRef(0),[p]=Y.useInterpolation([0],{tension:80,friction:18,onChange:([j])=>{g(w=>({...w,currentProgress:j}))}}),y=m.useCallback(()=>{g(j=>({...j,currentState:"idle",maxTime:null,isRunning:!1,isPausedState:!1,currentProgress:0})),u.current=0,d.current=null,p.setImmediate([0])},[p]),S=m.useCallback((j=0)=>{const w=j/60%1*100;g(M=>({...M,currentState:"measuring",maxTime:null,remainingTime:j,isPausedState:!1,currentProgress:w})),u.current=0,p.setImmediate([w]),e?(d.current=Date.now()-j*1e3,g(M=>({...M,isRunning:!0}))):d.current=null},[e,p]),x=m.useCallback((j,w=0)=>{g(k=>({...k,isRunning:!1})),d.current=null,g(k=>({...k,currentState:"countdown",maxTime:j,isPausedState:!1})),u.current=0;const M=Math.max(0,j-w),I=w>0?w/j*100:0;g(k=>({...k,remainingTime:M,currentProgress:I})),p.setImmediate([I]),M===0?(g(k=>({...k,isRunning:!1})),d.current=null,t&&queueMicrotask(()=>t())):e?setTimeout(()=>{d.current=Date.now()-w*1e3,g(k=>({...k,isRunning:!0}))},0):d.current=null},[e,t,p]),f=m.useCallback(()=>{g(j=>({...j,isRunning:!1,currentState:"measured"})),d.current=null,s(()=>{n&&n()})},[s,n]),v=m.useCallback(()=>{if(d.current&&l.isRunning){const w=Date.now()-d.current;u.current+=w;const M=u.current/1e3,I=Bt(l.currentState,M,l.maxTime);p.setTarget([I])}g(j=>({...j,isRunning:!1,isPausedState:!0})),r()},[l.isRunning,l.currentState,l.maxTime,p,r]),b=m.useCallback(()=>{l.isPausedState&&(l.remainingTime>0||l.currentState!=="countdown")&&(d.current=Date.now(),g(j=>({...j,isRunning:!0,isPausedState:!1})))},[l.isPausedState,l.remainingTime,l.currentState]),C=m.useCallback(()=>l.isPausedState,[l.isPausedState]);return m.useEffect(()=>{a?(l.isRunning&&!l.isPausedState&&(g(j=>({...j,wasRunningBeforeError:!0})),v()),i()):(l.wasRunningBeforeError&&l.isPausedState&&(g(j=>({...j,wasRunningBeforeError:!1})),b()),c())},[a,l.isRunning,l.isPausedState,l.wasRunningBeforeError,v,b,i,c]),m.useEffect(()=>{if(l.isRunning){const j=()=>{if(d.current){const M=(Date.now()-d.current+u.current)/1e3;if(l.currentState==="countdown"&&l.maxTime!==null){const I=Math.max(0,l.maxTime-M);g(E=>({...E,remainingTime:Math.ceil(I)}));const k=Math.min(100,M/l.maxTime*100);if(p.setTarget([k]),I<=0){g(E=>({...E,isRunning:!1,remainingTime:0})),d.current=null,p.setTarget([100]),t&&queueMicrotask(()=>t());return}}else if(l.currentState==="measuring"){g(k=>({...k,remainingTime:Math.floor(M)}));const I=M/60%1*100;p.setTarget([I])}l.isRunning&&(h.current=requestAnimationFrame(j))}};h.current=requestAnimationFrame(j)}else h.current&&(cancelAnimationFrame(h.current),h.current=null);return()=>{h.current&&cancelAnimationFrame(h.current)}},[l.isRunning,t,l.currentState,l.maxTime,p]),m.useEffect(()=>{let j=null;const w=()=>{p.update(1/60),j=requestAnimationFrame(w)};return j=requestAnimationFrame(w),()=>{j&&cancelAnimationFrame(j)}},[p]),{timerState:l,controls:{startNewCycle:x,startMeasuring:S,setIdle:y,completeMeasuring:f,pause:v,resume:b,isPaused:C}}},Vt=B.externalizeComponent(D.observer(({onCycleComplete:e,onCycleEnd:t,onMeasuringComplete:n,autoStart:a=!0,variant:r="default",compact:i=!1,className:c,hasError:s=!1})=>{const l=m.useRef(void 0),{animationState:g,triggerPauseAnimation:h,triggerErrorAnimation:d,clearErrorAnimation:u,startPulsatingAnimation:p,stopPulsatingAnimation:y,startIdleAnimations:S,stopIdleAnimations:x,triggerFadeTransition:f,setInitialAnimationState:v,cleanup:b}=zt(),{timerState:C,controls:j}=$t({autoStart:a,onCycleEnd:t,onMeasuringComplete:n,hasError:s,onPauseAnimation:h,onErrorAnimation:d,onClearErrorAnimation:u,onStartPulsating:p});return m.useEffect(()=>{const w=l.current;l.current!==void 0&&w!==C.currentState?(w==="measured"&&y(),w==="idle"&&x(),f()):v(),C.currentState==="idle"&&S(),l.current=C.currentState},[C.currentState,y,x,S,f,v]),m.useEffect(()=>{let w=!0;const M=setTimeout(()=>{w&&e(j)},0);return()=>{w=!1,clearTimeout(M)}},[e,j]),m.useEffect(()=>b,[b]),r==="small"?o.jsx(Lt,{timerState:C,animationState:g,hasError:s,compact:i,className:c}):o.jsx(Ft,{timerState:C,animationState:g,hasError:s,className:c})})),Ae=B.externalizeComponent(D.observer(({data:e,columns:t,getRowData:n,onRowClick:a,selectedItem:r,getItemId:i,title:c,showCount:s=!0,searchPlaceholder:l="Search programs",dataGridProps:g,CustomToolbar:h,selectFirstByDefault:d=!1,sx:u})=>{var I;const p=A.useTheme(),y=z.useGridApiRef(),S=m.useRef(null),[x,f]=m.useState(null),v=m.useMemo(()=>e.map(n),[e,n]);m.useEffect(()=>{y.current&&v.length>0&&y.current.autosizeColumns({includeOutliers:!0,includeHeaders:!0,expand:!0,columns:t.map(k=>k.field)})},[v,t,y]),m.useEffect(()=>{if(!S.current||!y.current)return;const k=new ResizeObserver(()=>{setTimeout(()=>{y.current&&v.length>0&&y.current.autosizeColumns({includeOutliers:!0,includeHeaders:!0,expand:!0,columns:t.map(E=>E.field)})},100)});return k.observe(S.current),()=>{k.disconnect()}},[y,v.length,t]);const b=m.useMemo(()=>{if(r!==void 0)return r;if(x!==null)return x;if(d&&e.length>0){const k=e[0];return f(k),k}return null},[d,e,r,x]),C=k=>{const E=e.find(F=>n(F).id===k.id);E&&(r===void 0&&f(E),a&&a(E,k))},j=m.useMemo(()=>!b||!i?null:i(b),[b,i]);function w(){return o.jsx(z.Toolbar,{children:o.jsxs(T,{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&&` (${e.length})`]}),o.jsxs(T,{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(et,{fontSize:"small"})})}),o.jsx(U,{orientation:"vertical",flexItem:!0,sx:{height:"24px",alignSelf:"center"}}),o.jsx(z.QuickFilter,{render:(k,E)=>o.jsxs(T,{...k,sx:{display:"flex",overflow:"hidden"},children:[!E.expanded&&o.jsx(z.QuickFilterTrigger,{render:o.jsx(z.ToolbarButton,{"aria-label":"Search",children:o.jsx(Ce,{fontSize:"small"})})}),o.jsxs(T,{sx:{display:"flex",overflow:"hidden",transition:"all 0.3s ease-in-out",width:E.expanded?"200px":"0px",position:"relative"},children:[o.jsxs(T,{sx:{flex:1,position:"relative","& .MuiInputBase-root":{height:"32px",borderRadius:"16px",backgroundColor:"#171927",paddingLeft:"40px",paddingRight:E.expanded&&E.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:[E.expanded&&o.jsx(Ce,{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})]}),E.expanded&&E.value!==""&&o.jsx(z.QuickFilterClear,{render:o.jsx(T,{sx:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",zIndex:1},children:o.jsx(T,{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(Ke,{fontSize:"small"})})})})})]})]})})]})]})})}const M=h||w;return o.jsx(T,{ref:S,sx:{height:"100%",display:"flex",flexDirection:"column","& *":{scrollbarWidth:"none",msOverflowStyle:"none","&::-webkit-scrollbar":{display:"none"}},"&:hover *":{scrollbarWidth:"thin",scrollbarColor:`${p.palette.divider} transparent`,"&::-webkit-scrollbar":{display:"block",width:"8px",height:"8px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:p.palette.divider,borderRadius:"4px"},"&::-webkit-scrollbar-thumb:hover":{background:p.palette.action.hover}},...u},children:o.jsx(z.DataGrid,{apiRef:y,rows:v,columns:t,onRowClick:C,disableColumnMenu:!1,disableRowSelectionOnClick:!0,disableMultipleRowSelection:!0,hideFooterSelectedRowCount:!0,filterMode:"client",sortingOrder:["desc","asc"],hideFooter:!1,showToolbar:!0,slots:{toolbar:M},initialState:{sorting:{sortModel:[]},filter:{filterModel:{items:[]}},...g==null?void 0:g.initialState},...g,autosizeOnMount:!0,autosizeOptions:{...(g==null?void 0:g.autosizeOptions)||{},includeOutliers:!0,includeHeaders:!0,expand:!0,columns:((I=g==null?void 0:g.autosizeOptions)==null?void 0:I.columns)||t.map(k=>k.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:a?"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"}},...j!==null&&{[`&[data-id="${j}"]`]:{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":{},...g==null?void 0:g.sx}})})}));Ae.displayName="WandelbotsDataGrid";const ce=B.externalizeComponent(D.observer(({colors:e,label:t,getDisplayedValue:n,startJogging:a,stopJogging:r,disabled:i,activeJoggingDirection:c,...s})=>{var b,C,j,w,M,I,k;Y.useAnimationFrame(()=>{const E=n(),F=u.current;F&&(F.textContent=E)});const l=A.useTheme(),[g,h]=m.useState(null);m.useEffect(()=>{i&&v()},[i]);const d=c||g,u=m.useRef(null);e||(e={color:"#fff",backgroundColor:"#000",borderColor:"#000",buttonBackgroundColor:{disabled:"#000",default:"#000",hovered:"#000",pressed:"#000"},labelColor:"#000"});const p=d?(b=e.buttonBackgroundColor)==null?void 0:b.pressed:e.borderColor,y={width:"55px",color:e.color,path:{fill:e.color},alignContent:"center",fontSize:"37px",svg:{pointerEvents:"none"}},S={...y,backgroundColor:(C=e.buttonBackgroundColor)==null?void 0:C.default,":hover":{backgroundColor:(j=e.buttonBackgroundColor)==null?void 0:j.hovered},":active":{backgroundColor:(w=e.buttonBackgroundColor)==null?void 0:w.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor}},":disabled":{backgroundColor:(M=e.buttonBackgroundColor)==null?void 0:M.disabled,"svg path":{fill:l.palette.action.disabled}}},x={...y,backgroundColor:(I=e.buttonBackgroundColor)==null?void 0:I.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor},":disabled":{backgroundColor:(k=e.buttonBackgroundColor)==null?void 0:k.pressed,"svg path":{fill:l.palette.action.disabled}}};function f(E,F){i||E.button===0&&(h(F),a(F))}function v(){h(null),r()}return o.jsxs(P,{height:"64px",direction:"row",justifyContent:"center",...s,children:[o.jsx(W,{disabled:i,disableRipple:!0,onPointerDown:E=>f(E,"-"),onPointerUp:v,onPointerOut:v,size:"large",sx:{...d==="-"?x:S,borderRadius:"16px 0px 0px 16px",borderLeft:`2px solid ${p??"#fff"}`,borderBottom:`2px solid ${p??"#fff"}`,borderTop:`2px solid ${p??"#fff"}`},children:o.jsx(N.ForwardRef$3,{})}),o.jsxs(P,{spacing:"6px",sx:{width:"150px",backgroundColor:e.backgroundColor,alignItems:"center",justifyContent:"center",opacity:"0.9",borderBottom:`2px solid ${p??"#fff"}`,borderTop:`2px solid ${p??"#fff"}`},children:[o.jsx(P,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:e.color,".MuiTypography-root":{fontWeight:700,...i?{color:l.palette.action.disabled}:{}},...i?{"svg path":{fill:l.palette.action.disabled}}:{}},children:t}),o.jsx(R,{height:"22px",sx:{fontSize:"15px",color:i?l.palette.action.disabled:e.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:u,children:n()})]}),o.jsx(W,{disableRipple:!0,disabled:i,onPointerDown:E=>f(E,"+"),onPointerUp:v,onPointerOut:v,size:"large",sx:{...d==="+"?x:S,borderRadius:"0px 16px 16px 0px",borderRight:`2px solid ${p??"#fff"}`,borderBottom:`2px solid ${p??"#fff"}`,borderTop:`2px solid ${p??"#fff"}`},children:o.jsx(N.ForwardRef$4,{})})]})})),De=B.externalizeComponent(D.observer(({startJogging:e,stopJogging:t,lowerLimit:n,upperLimit:a,useDegree:r,getValue:i,disabled:c,...s})=>{var w,M,I,k,E,F,Z,ee,fe,xe,be,ye,Se,ve,je;const{t:l}=L.useTranslation(),[g,h]=m.useState(),d=A.useTheme(),u={background:(w=d.palette.backgroundPaperElevation)==null?void 0:w[4],color:(M=d.palette.backgroundPaperElevation)==null?void 0:M[11]},p=D.useLocalObservable(()=>({activeJoggingDir:null,startJogging(O){this.activeJoggingDir=O,e(O)},stopJogging(){this.activeJoggingDir=null,t()}})),y=xt(()=>{const O=r?S(i()):i();(O===void 0||g===void 0||Math.abs(g-O)>1e-9)&&h(O)},50);Y.useAnimationFrame(y);function S(O){if(O!==void 0)return J.radiansToDegrees(O)}function x(O){O.button===0&&p.startJogging("-")}function f(O){O.button===0&&p.startJogging("+")}function v(O){p.stopJogging()}function b(O){p.stopJogging()}function C(O,X=1){if(O===void 0||Number.isNaN(O))return"";const Q=l("General.degree.variable",{amount:O.toFixed(X)});return O>0&&X===0?`+${Q}`:Q}function j(O,X=1){if(O===void 0||Number.isNaN(O))return"";const Q=l("General.mm.variable",{amount:O.toFixed(X)});return O>0&&X===0?`+${Q}`:Q}return o.jsxs(P,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...s,sx:{"& .MuiIconButton-root":{width:"52px",color:d.palette.text.primary,alignContent:"center",backgroundColor:(I=d.palette.backgroundPaperElevation)==null?void 0:I[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:(k=d.palette.backgroundPaperElevation)==null?void 0:k[11],color:d.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(E=d.palette.backgroundPaperElevation)==null?void 0:E[9]},"&:active":{...u}}},children:[o.jsx(W,{onPointerDown:x,onPointerUp:v,onPointerOut:b,disabled:c,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...p.activeJoggingDir==="-"?u:{}},children:o.jsx(ht,{sx:{pointerEvents:"none",color:(fe=(ee=(Z=(F=d.componentsExt)==null?void 0:F.JoggingPanel)==null?void 0:Z.JoggingJoint)==null?void 0:ee.Joint)==null?void 0:fe.arrowColor}})}),o.jsxs(P,{flexGrow:1,alignItems:"center",justifyContent:"center",sx:{borderStyle:"solid",borderLeftWidth:0,borderRightWidth:0,border:"none",backgroundColor:(xe=d.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?d.palette.action.disabled:d.palette.text.primary},children:r?C(g):j(g)}),o.jsx(Oe,{disabled:!0,"aria-label":"Joint position",min:r?S(n):n,max:r?S(a):a,value:g||0,track:!1,sx:{"& .MuiSlider-mark":{display:"none"},"& .MuiSlider-thumb":{width:"5px",height:"12px",borderRadius:"2px",color:c?d.palette.action.disabled:d.palette.text.primary},"& .MuiSlider-markLabel":{top:"20px",fontSize:"12px",color:c?d.palette.action.disabled:d.palette.text.secondary},"& .MuiSlider-rail":{backgroundColor:(be=d.palette.backgroundPaperElevation)==null?void 0:be[5],opacity:1}},marks:n!==void 0&&a!==void 0&&[{value:r?S(n):n,label:r?C(S(n),0):j(n)},{value:r?S(a):a,label:r?C(S(a),0):j(a)}]})]}),o.jsx(W,{onPointerDown:f,onPointerUp:v,onPointerOut:b,disabled:c,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...p.activeJoggingDir==="+"?u:{}},children:o.jsx(ft,{sx:{pointerEvents:"none",color:(je=(ve=(Se=(ye=d.componentsExt)==null?void 0:ye.JoggingPanel)==null?void 0:Se.JoggingJoint)==null?void 0:ve.Joint)==null?void 0:je.arrowColor}})})]})}));function ge(e,t,n){if(t.length!==e.length)return!0;for(let a=0;a<t.length;a++)if(Math.abs(t[a]-e[a])>n)return!1;return!0}function Je(e,t,n){if(e===void 0&&t||e&&t===void 0||(e==null?void 0:e.orientation)===void 0||(t==null?void 0:t.orientation)===void 0||(e==null?void 0:e.position)===void 0||(t==null?void 0:t.position)===void 0)return!1;if(e===void 0||t===void 0)return!0;let a=0;return a+=Math.abs(e.orientation[0]-t.orientation[0]),a+=Math.abs(e.orientation[1]-t.orientation[1]),a+=Math.abs(e.orientation[2]-t.orientation[2]),a+=Math.abs(e.position[0]-t.position[0]),a+=Math.abs(e.position[1]-t.position[1]),a+=Math.abs(e.position[2]-t.position[2]),a<=n}function pe(e,t,n){return e.coordinate_system===t.coordinate_system&&e.tcp===t.tcp&&Je(e.tcp_pose,t.tcp_pose,n)}function Be(e,t){const n=new le.Vector3(t[0],t[1],t[2]),a=new le.Vector3(e[0],e[1],e[2]),r=n.length(),i=n.normalize();let c=a.length(),s=a.normalize();s.dot(i)<0&&(c=-c,s=s.multiplyScalar(-1));let l=c-r;return l-=2*Math.PI*Math.floor((l+Math.PI)/(2*Math.PI)),c=r+l,[...s.multiplyScalar(c)]}const ke=1e-4;class ie{constructor(t,n,a,r,i,c){this.nova=t,this.controller=n,this.motionGroup=a,this.description=r,this.initialMotionState=i,this.motionStateSocket=c,this.rapidlyChangingMotionState=i,c.addEventListener("message",s=>{var g;const l=(g=J.tryParseJson(s.data))==null?void 0:g.result;if(!l)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${s.data}`);ge(this.rapidlyChangingMotionState.joint_position,l.joint_position,ke)||_.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=l.joint_position}),pe(this.rapidlyChangingMotionState,l,ke)||_.runInAction(()=>{var h,d,u;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=l.tcp_pose:(h=l.tcp_pose)!=null&&h.orientation&&((d=l.tcp_pose)!=null&&d.position)&&((u=this.rapidlyChangingMotionState.tcp_pose)!=null&&u.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:l.tcp_pose.position,orientation:Be(l.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:console.warn("Received incomplete tcp_pose, ignoring",l.tcp_pose)}),this.rapidlyChangingMotionState.standstill!==l.standstill&&_.runInAction(()=>{this.rapidlyChangingMotionState.standstill=l.standstill})}),_.makeAutoObservable(this)}static async open(t,n){var d;const[a,r]=n.split("@"),i=await t.api.controller.getCurrentRobotControllerState(r),c=i==null?void 0:i.motion_groups.find(u=>u.motion_group===n);if(!i||!c)throw new Error(`Controller ${r} or motion group ${n} not found`);const s=t.openReconnectingWebsocket(`/controllers/${r}/motion-groups/${n}/state-stream`),l=await s.firstMessage(),g=(d=J.tryParseJson(l.data))==null?void 0:d.result;if(!g)throw new Error(`Unable to parse initial motion state message ${l.data}`);console.log(`Connected motion state websocket to motion group ${c.motion_group}. Initial state:
|
|
2
|
-
`,g);const h=await t.api.motionGroup.getMotionGroupDescription(r,c.motion_group);return new ie(t,i,c,h,g,s)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get joints(){return this.initialMotionState.joint_position.map((t,n)=>({index:n}))}dispose(){this.motionStateSocket.close()}}const Me="Movement request rejected. Another client is currently executing a 'Jogging' motion!";class re{constructor(t,n={}){this.motionStream=t,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)||t.motionGroup.tcp||this.getDefaultTcp(t),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(t,n,a={}){const r=await ie.open(t,n),i=new re(r,a);return await i.setJoggingMode(i.mode),i}getDefaultTcp(t){var a,r;const n=(r=(a=t.description.dh_parameters)==null?void 0:a[0])==null?void 0:r.type;return t.joints.length<6&&(n===V.JointTypeEnum.RevoluteJoint||n===V.JointTypeEnum.PrismaticJoint)?this.NO_TCP:this.DEFAULT_TCP}async setOptions(t){t.tcp&&(this.tcp=t.tcp),t.orientation&&(this.orientation=t.orientation),t.timeout&&(this.timeout=t.timeout),t.mode&&(this.mode=t.mode),t.onError&&(this.onError=t.onError),this.setJoggingMode(this.mode,!1)}get motionGroupId(){return this.motionStream.motionGroupId}get nova(){return this.motionStream.nova}get numJoints(){return this.motionStream.joints.length}async stop(){if(this.joggingSocket){const t=new Array(this.numJoints).fill(0);this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:t})}this.trajectorySocket&&this.trajectorySocket.sendJson({message_type:"PauseMovementRequest"})}async dispose(){const t=[this.joggingSocket,this.trajectorySocket].filter(n=>n!==null);return t.forEach(n=>{n.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(t.map(n=>n.closed()))}async setJoggingMode(t,n=!0){if(!(this.mode===t&&n)&&(this.dispose(),this.mode=t,this.mode==="jogging"))return this.initializeJoggingWebsocket()}async initializeJoggingWebsocket(){return new Promise((t,n)=>{const a=setTimeout(()=>{n(new Error(`Jogging initialization timeout after ${this.timeout} seconds`))},this.timeout);this.joggingSocket=this.nova.openReconnectingWebsocket(`/controllers/${this.motionStream.controllerId}/execution/jogging`),this.joggingSocket.addEventListener("message",r=>{var c,s,l,g;const i=J.tryParseJson(r.data);if(((c=i==null?void 0:i.result)==null?void 0:c.kind)==="INITIALIZE_RECEIVED"){clearTimeout(a),t();return}if(((s=i==null?void 0:i.result)==null?void 0:s.kind)==="MOTION_ERROR")if(clearTimeout(a),this.onBlocked&&((l=i==null?void 0:i.result)!=null&&l.message.includes(Me))){(g=this.joggingSocket)==null||g.dispose(),this.onBlocked();return}else this.onError?this.onError(r.data):n(new Error(r.data))}),this.joggingSocket.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:n,velocityValue:a,velocityUnit:r}){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[t]=n==="-"?-a:a,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:i})}async translateTCP({axis:t,direction:n,velocityMmPerSec:a}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const r=[0,0,0],i=[0,0,0];i[J.XYZ_TO_VECTOR[t]]=n==="-"?-a:a,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:i,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:t,direction:n,velocityRadsPerSec:a}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const r=[0,0,0],i=[0,0,0];r[J.XYZ_TO_VECTOR[t]]=n==="-"?-a:a,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:i,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async runIncrementalCartesianMotion({currentTcpPose:t,currentJoints:n,velocityInRelevantUnits:a,axis:r,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(!t.position)throw new Error("Current pose has no position, cannot perform translation");const x=[...t.position];x[J.XYZ_TO_VECTOR[r]]+=c.distanceMm*(i==="-"?-1:1),s.push({limits_override:{tcp_velocity_limit:a},path:{path_definition_name:"PathLine",target_pose:{position:x,orientation:t.orientation}}})}else if(c.type==="rotate"){if(!t.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const x=new se.Vector3(t.orientation[0],t.orientation[1],t.orientation[2]),f=x.length(),v=x.clone().normalize(),b=c.distanceRads*(i==="-"?-1:1),C=new se.Vector3(0,0,0);C[r]=1;const j=Math.cos(.5*b)*Math.cos(.5*f),w=Math.sin(.5*b)*Math.sin(.5*f),M=Math.sin(.5*b)*Math.cos(.5*f),I=Math.cos(.5*b)*Math.sin(.5*f),k=C.dot(v),E=C.clone().cross(v),F=2*Math.acos(j-w*k),Z=F/Math.sin(.5*F),ee=new se.Vector3().addScaledVector(E,w).addScaledVector(C,M).addScaledVector(v,I).multiplyScalar(Z);s.push({limits_override:{tcp_orientation_velocity_limit:a},path:{path_definition_name:"PathLine",target_pose:{position:t.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 g={motion_group_model:l.motion_group_model,cycle_time:l.cycle_time,mounting:l.mounting,global:l.operation_limits.auto_limits},h=await this.nova.api.trajectoryPlanning.planTrajectory({motion_group_setup:g,start_joint_position:n,motion_commands:s}),d=h.response;if(!d)throw new Error(`Failed to plan jogging increment motion ${JSON.stringify(h)}`);this.trajectorySocket&&(console.warn("Trajectory jogging websocket already open; will close"),this.trajectorySocket.dispose()),this.trajectorySocket=this.nova.openReconnectingWebsocket(`/controllers/${this.motionStream.controllerId}/execution/trajectory`);const u=x=>{var f;if(!x||x.add_trajectory_error||x.message)if(this.onError)this.onError(x);else throw new Error(((f=x==null?void 0:x.add_trajectory_error)==null?void 0:f.message)||(x==null?void 0:x.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"})},p=async()=>{var x;await _.when(()=>!this.motionStream.rapidlyChangingMotionState.standstill),await _.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(x=this.trajectorySocket)==null||x.dispose(),this.trajectorySocket=null},y=async()=>{var x;await _.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(x=this.trajectorySocket)==null||x.dispose(),this.trajectorySocket=null},S=async x=>{if(x!=null&&x.message)if(this.onError){this.onError(x);return}else throw new Error(x.message||"Failed to execute trajectory, unknown error");this.motionStream.rapidlyChangingMotionState.standstill?await p():await y()};this.trajectorySocket.addEventListener("message",x=>{var v,b;const f=J.tryParseJson(x.data);if(!((v=f==null?void 0:f.result)!=null&&v.kind))throw new Error(`Failed to execute trajectory: Received invalid message ${x.data}`);if(this.onBlocked&&((b=f.result.message)!=null&&b.includes(Me))){this.onBlocked();return}if(f.result.kind==="INITIALIZE_RECEIVED")u(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:d,tcp:this.tcp}})}}const Fe=e=>{const t=e.softTimeout||3e3,[n,a]=m.useState(!1),r=A.useTheme();return m.useEffect(()=>{const i=setTimeout(()=>{a(!0)},t);return()=>clearTimeout(i)}),o.jsx(P,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:r.palette.text.primary},children:e.error?o.jsx(Le,{loadingMessage:e.message,error:e.error}):o.jsxs(o.Fragment,{children:[o.jsx(ot,{sx:{marginBottom:"24px"}}),!!e.message&&o.jsx("div",{children:e.message}),o.jsx(P,{sx:{visibility:n?"visible":"hidden",marginTop:"1rem",color:r.palette.text.secondary},children:"This is taking longer than expected..."})]})})},Le=e=>{const t=rt.makeErrorMessage(e.error),n=e.error instanceof Error?e.error.stack:null,a=A.useTheme();return o.jsxs(P,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",padding:2,overflow:"auto",color:a.palette.error.main,"& pre":{whiteSpace:"pre-wrap",wordBreak:"break-word",paddingBottom:"3rem"}},children:[(e.loadingMessage?`Error while ${ue.lowerFirst(it.capitalize(e.loadingMessage))} - `:"")+t,o.jsx("br",{}),n&&o.jsx("pre",{children:n})]})},qt=D.observer(({store:e})=>{const{t}=L.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(P,{sx:{m:2,width:"100%"},children:[o.jsxs(at,{severity:"error",sx:{mb:2},children:[o.jsx(st,{children:t("Jogging.Blocked.ti")}),t("Jogging.Blocked.lb")]}),o.jsx(H,{variant:"contained",color:"secondary",onClick:()=>e.unblock(),children:t("Jogging.Blocked.Reenable.bt")})]})})}),ze=D.observer(({store:e})=>{const{t}=L.useTranslation(),[n,a]=m.useState(e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached),r=m.useRef(n);Y.useAnimationFrame(()=>{const c=e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;lt(r.current,c)||(r.current=c,a(c))});const i=[];for(const[c,s]of n.entries())s&&i.push(c);return o.jsx(R,{"data-testid":"jogging-joint-limit-detector","aria-label":"jogging-joint-limit-detector",color:"error",sx:{margin:"0.5rem 1rem",textAlign:"center",minHeight:"1.5rem",visibility:i.length?"visible":"hidden"},children:t("Jogging.JointLimitsReached.lb",{jointNumbers:i.map(c=>c+1).join(", ")})})}),Nt=A.styled(ct)(({theme:e})=>({"&.MuiFormControl-root":{".MuiSelect-select":{paddingTop:"20px",paddingLeft:"12px"},label:{pointerEvents:"none",fontSize:"16px"},".MuiInputLabel-root":{"&.Mui-focused":{color:e.palette.text.primary}}}}));function ne({labelValue:e,...t}){return o.jsxs(Nt,{fullWidth:!0,variant:"filled",children:[o.jsx(dt,{id:t.labelId,children:e}),o.jsx(ut,{...t})]})}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}],Wt=[{id:"continuous"},...de],Gt=["coordsys","tool"];class ae{constructor(t,n,a,r,i){var c,s,l,g;this.jogger=t,this.coordSystems=n,this.motionGroupDescription=a,this.tcps=r,this.inverseSolverValue=i,this.selectedTabId="cartesian",this.locks=new Set,this.blocked=!1,this.selectedCoordSystemId="world",this.selectedTcpId="",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 h of n)if(h.coordinate_system===""){h.coordinate_system="world";break}this.selectedCoordSystemId=((c=n[0])==null?void 0:c.coordinate_system)||"world",this.selectedTcpId=((s=r[0])==null?void 0:s.id)||"",this.inverseSolver=i,this.jointType=((g=(l=a==null?void 0:a.dh_parameters)==null?void 0:l[0])==null?void 0:g.type)??V.JointTypeEnum.RevoluteJoint,_.makeAutoObservable(this,{},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()},this.loadFromLocalStorage(),this.disposers.push(_.autorun(()=>this.saveToLocalStorage())),window.joggingStore=this}static async loadFor(t){const{nova:n}=t,[a,r]=await Promise.all([n.api.controller.listCoordinateSystems(t.motionStream.controllerId,"ROTATION_VECTOR"),n.api.motionGroup.getMotionGroupDescription(t.motionStream.controllerId,t.motionGroupId)]),i=await n.api.motionGroupModels.getMotionGroupKinematicModel(r.motion_group_model),c=Object.entries(r.tcps||{}).map(([s,l])=>({id:s,readable_name:l.name,position:l.pose.position,orientation:l.pose.orientation}));return new ae(t,a||[],r,c,i.inverse_solver)}dispose(){for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return ue.countBy(this.coordSystems,t=>t.name)}async deactivate(){if(this.jogger.mode==="jogging")return this.jogger.stop()}async activate(){return this.currentTab.id==="cartesian"?((this.jogger.tcp!==this.selectedTcpId||this.jogger.orientation!==this.selectedOrientation)&&this.jogger.setOptions({tcp:this.selectedTcpId,orientation:this.selectedOrientation}),this.activeDiscreteIncrement?this.jogger.setJoggingMode("trajectory"):this.jogger.setJoggingMode("jogging")):this.jogger.setJoggingMode("jogging"),this.jogger}loadFromLocalStorage(){const t=J.tryParseJson(localStorage.getItem("joggingToolStore"));t&&(this.tabsById[t.selectedTabId]&&(this.selectedTabId=t.selectedTabId),this.coordSystemsById[t.selectedCoordSystemId]&&(this.selectedCoordSystemId=t.selectedCoordSystemId),this.tcpsById[t.selectedTcpId]&&(this.selectedTcpId=t.selectedTcpId),this.incrementOptionsById[t.selectedIncrementId]&&(this.selectedIncrementId=t.selectedIncrementId),["translate","rotate"].includes(t.selectedCartesianMotionType)&&(this.selectedCartesianMotionType=t.selectedCartesianMotionType),["coordsys","tool"].includes(t.selectedOrientation)&&(this.selectedOrientation=t.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,selectedTcpId:this.selectedTcpId,selectedOrientation:this.selectedOrientation,selectedIncrementId:this.selectedIncrementId,selectedCartesianMotionType:this.selectedCartesianMotionType}}get tabs(){const t=[{id:"joint",label:"Joints"}];return this.inverseSolver!==null&&t.unshift({id:"cartesian",label:"Cartesian"}),t}get incrementOptions(){return Wt}get discreteIncrementOptions(){return de}get incrementOptionsById(){return te(this.incrementOptions,t=>t.id)}get tabsById(){return te(this.tabs,t=>t.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,t=>t.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get tcpsById(){return te(this.tcps,t=>t.id)}get activeDiscreteIncrement(){return this.selectedOrientation==="tool"?void 0:de.find(t=>t.id===this.selectedIncrementId)}get rotationVelocityRadsPerSec(){return this.rotationVelocityDegPerSec*Math.PI/180}velocityInDisplayUnits(t){return t?this.rotationVelocityDegPerSec:this.translationVelocityMmPerSec}minVelocityInDisplayUnits(t){return t?this.minRotationVelocityDegPerSec:this.minTranslationVelocityMmPerSec}maxVelocityInDisplayUnits(t){return t?this.maxRotationVelocityDegPerSec:this.maxTranslationVelocityMmPerSec}onTabChange(t,n){const a=this.tabs[n]||this.tabs[0];this.selectedTabId=a.id}setSelectedCoordSystemId(t){this.selectedCoordSystemId=t}setSelectedTcpId(t){this.selectedTcpId=t}setSelectedOrientation(t){this.selectedOrientation=t}setSelectedIncrementId(t){this.selectedIncrementId=t}setCurrentIncrementJog(t){this.incrementJogInProgress=t}setVelocityFromSlider(t,n){n?this.rotationVelocityDegPerSec=t:this.translationVelocityMmPerSec=t}setSelectedCartesianMotionType(t){this.selectedCartesianMotionType=t}lock(t){this.locks.add(t)}unlock(t){this.locks.delete(t)}block(){this.blocked=!0}unblock(){this.blocked=!1,this.jogger.mode==="jogging"&&this.jogger.initializeJoggingWebsocket()}async withMotionLock(t){const n=gt();this.lock(n);try{return await t()}finally{this.unlock(n)}}}const Ut=D.observer(({store:e,useDegree:t})=>{var c;const{t:n}=L.useTranslation(),a=m.useId(),r=[];function i(s){switch(s){case"coordsys":return n("Jogging.Orientation.coordsys");case"tool":return n("Jogging.Orientation.tool");default:return s}}return e.showCoordSystemSelect&&r.push(o.jsx(ne,{labelId:`jogging-coord-select-${a}`,labelValue:n("Jogging.CoordinateSystem.hlb"),value:e.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:s=>e.setSelectedCoordSystemId(s.target.value),disabled:e.isLocked,children:e.coordSystems.map(s=>o.jsx(G,{value:s.coordinate_system,children:s.name&&e.coordSystemCountByName[s.name]>1?`${s.name} / ${s.coordinate_system}`:s.name||s.coordinate_system},s.coordinate_system))},"coord")),e.showTcpSelect&&r.push(o.jsx(ne,{labelId:`jogging-tcp-select-${a}`,labelValue:"TCP",value:e.selectedTcpId,size:"small",variant:"filled",onChange:s=>e.setSelectedTcpId(s.target.value),disabled:e.isLocked,children:e.tcps.map(s=>o.jsx(G,{value:s.id,children:s.id},s.id))},"tcp")),e.showOrientationSelect&&r.push(o.jsx(ne,{labelValue:n("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${a}`,value:e.selectedOrientation,onChange:s=>e.setSelectedOrientation(s.target.value),disabled:e.isLocked,children:Gt.map(s=>o.jsx(G,{value:s,children:i(s)},s))},"orientation")),e.showIncrementSelect&&r.push(o.jsxs(ne,{labelValue:n("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${a}`,size:"small",variant:"filled",value:((c=e.activeDiscreteIncrement)==null?void 0:c.id)||"continuous",onChange:s=>e.setSelectedIncrementId(s.target.value),disabled:e.isLocked,children:[o.jsx(G,{value:"continuous",children:n("Jogging.Increment.Continuous.dd")},"continuous"),e.selectedOrientation==="tool"?null:e.discreteIncrementOptions.map(s=>o.jsx(G,{value:s.id,children:t?`${s.degrees}°`:`${s.mm}mm`},s.id))]},"increment")),o.jsx(T,{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:r.map((s,l)=>o.jsx(T,{sx:{gridColumn:r.length%2===1&&l===r.length-1?"span 2":"auto"},children:s},l))})}),Ht=A.styled(pt)(({theme:e})=>{var t;return{"&.MuiToggleButtonGroup-root":{background:(t=e.palette.backgroundPaperElevation)==null?void 0:t[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"}}}}}),$e=D.observer(e=>{var i,c,s;const t=A.useTheme(),{store:n}=e,{t:a}=L.useTranslation();function r(l,g){g===e.velocity||!mt(g)||e.onVelocityChange(g,e.useDegree)}return o.jsxs(P,{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=t.componentsExt)==null?void 0:i.JoggingPanel)==null?void 0:c.VelocitySlider)==null?void 0:s.sliderLegendColor,fontSize:"14px"},children:a("Jogging.Velocity.bt")}),o.jsx(Oe,{value:e.velocity,color:"secondary",onChange:r,min:e.min,max:e.max,"aria-labelledby":"input-slider",disabled:e.disabled,sx:{"& .MuiSlider-valueLabelOpen":{zIndex:100,backgroundColor:"transparent",top:"0px"}}}),n.showVelocitySliderLabel&&(e.renderValue?e.renderValue(e.velocity):o.jsx(me,{value:e.velocity.toString()}))]})});function me({value:e,sx:t}){var a;const n=A.useTheme();return o.jsx(P,{direction:"row",justifyContent:"center",alignItems:"center",gap:"5px",sx:{padding:"6px 12px",background:(a=n.palette.backgroundPaperElevation)==null?void 0:a[8],borderRadius:"10px",minWidth:"111px",...t},children:o.jsx(R,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:n.palette.text.primary,whiteSpace:"nowrap"},children:e})})}const Ve=D.observer(({store:e,useDegree:t})=>{const{t:n}=L.useTranslation();function a(r,i){return i?`ω = ${n("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:r})}`:`v = ${n("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:r})}`}return o.jsx($e,{store:e,velocity:e.velocityInDisplayUnits(t),min:e.minVelocityInDisplayUnits(t),max:e.maxVelocityInDisplayUnits(t),onVelocityChange:e.setVelocityFromSlider,useDegree:t,disabled:e.isLocked,renderValue:r=>o.jsx(me,{value:a(r,t),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),Yt=D.observer(({store:e,children:t})=>{const{t:n}=L.useTranslation(),a=A.useTheme();function r(u,p){(p==="translate"||p==="rotate")&&e.setSelectedCartesianMotionType(p)}Y.useReaction(()=>[e.selectedCoordSystemId,e.selectedTcpId],()=>{e.jogger.motionStream.motionStateSocket.changeUrl(e.jogger.nova.makeWebsocketURL(`/controllers/${e.jogger.motionStream.controllerId}/motion-groups/${e.jogger.motionGroupId}/state-stream?tcp=${e.selectedTcpId}`))},{fireImmediately:!0});async function i(u,p){const y=await e.activate(),S=y.motionStream.rapidlyChangingMotionState.tcp_pose,x=y.motionStream.rapidlyChangingMotionState.joint_position;S&&await e.withMotionLock(async()=>{try{e.setCurrentIncrementJog({axis:u.axis,direction:u.direction}),await e.jogger.runIncrementalCartesianMotion({currentTcpPose:S,currentJoints:x,coordSystemId:e.activeCoordSystemId,velocityInRelevantUnits:e.selectedCartesianMotionType==="translate"?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec,axis:u.axis,direction:u.direction,motion:e.selectedCartesianMotionType==="translate"?{type:"translate",distanceMm:p.mm}:{type:"rotate",distanceRads:J.degreesToRadians(p.degrees)}})}finally{e.setCurrentIncrementJog(null),await e.deactivate()}})}async function c(u){if(!e.isLocked){if(await e.activate(),e.activeDiscreteIncrement)return i(u,e.activeDiscreteIncrement);u.motionType==="translate"?await e.jogger.translateTCP({axis:u.axis,direction:u.direction,velocityMmPerSec:e.translationVelocityMmPerSec}):await e.jogger.rotateTCP({axis:u.axis,direction:u.direction,velocityRadsPerSec:e.rotationVelocityRadsPerSec})}}async function s(){e.isLocked||e.activeDiscreteIncrement||await e.deactivate()}function l(u,p,y){var x,f,v;const S=(v=(f=(x=y.componentsExt)==null?void 0:x.JoggingPanel)==null?void 0:f.JoggingCartesian)==null?void 0:v.Axis;if(S)return p==="translate"?S[u]:S.CustomRotation??S[u]}const g=[{id:"x",icon:o.jsx(N.ForwardRef,{}),colors:l("X",e.selectedCartesianMotionType,a)},{id:"y",icon:o.jsx(N.ForwardRef$1,{}),colors:l("Y",e.selectedCartesianMotionType,a)},{id:"z",icon:o.jsx(N.ForwardRef$2,{}),colors:l("Z",e.selectedCartesianMotionType,a)}];function h(u){return n("General.mm.variable",{amount:u.toFixed(1)})}function d(u){return n("General.degree.variable",{amount:J.radiansToDegrees(u).toFixed(1)})}return o.jsxs(P,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[o.jsxs(P,{gap:2,children:[o.jsx(Ut,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),o.jsx(Ve,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),o.jsx(U,{})]}),o.jsx(P,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:o.jsxs(P,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[o.jsxs(Ht,{value:e.selectedCartesianMotionType,onChange:r,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")})]}),e.selectedCartesianMotionType==="translate"&&g.map(u=>{var p,y;return o.jsx(ce,{"data-testid":`jogging-cartesian-axis-control-${u.id}`,"aria-label":`jogging-cartesian-axis-control-${u.id}`,colors:u.colors,disabled:e.isLocked,activeJoggingDirection:((p=e.incrementJogInProgress)==null?void 0:p.axis)===u.id?e.incrementJogInProgress.direction:void 0,label:o.jsxs(o.Fragment,{children:[u.icon,o.jsx(R,{sx:{fontSize:"24px",color:((y=u.colors)==null?void 0:y.labelColor)??a.palette.text.primary},children:u.id.toUpperCase()})]}),getDisplayedValue:()=>{var S,x;return h(((x=(S=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:S.position)==null?void 0:x[J.XYZ_TO_VECTOR[u.id]])||0)},startJogging:S=>c({axis:u.id,motionType:"translate",direction:S}),stopJogging:s},u.id)}),e.selectedCartesianMotionType==="rotate"&&g.map(u=>{var p,y;return o.jsx(ce,{"data-testid":`jogging-cartesian-axis-control-${u.id}`,"aria-label":`jogging-cartesian-axis-control-${u.id}`,colors:u.colors,disabled:e.isLocked,activeJoggingDirection:((p=e.incrementJogInProgress)==null?void 0:p.axis)===u.id?e.incrementJogInProgress.direction:void 0,label:o.jsxs(o.Fragment,{children:[o.jsx(N.ForwardRef$6,{}),o.jsx(R,{sx:{fontSize:"24px",color:((y=u.colors)==null?void 0:y.labelColor)??a.palette.text.primary},children:u.id.toUpperCase()})]}),getDisplayedValue:()=>{var S,x;return d(((x=(S=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:S.orientation)==null?void 0:x[J.XYZ_TO_VECTOR[u.id]])||0)},startJogging:S=>c({axis:u.id,motionType:"rotate",direction:S}),stopJogging:s},u.id)})]})}),o.jsx(ze,{store:e}),t&&o.jsx(U,{}),t]})}),Zt=D.observer(({store:e,children:t})=>{const n=A.useTheme();async function a(i){await e.activate(),await e.jogger.rotateJoints({joint:i.joint,direction:i.direction,velocityUnit:e.jointType===V.JointTypeEnum.PrismaticJoint?"mm/s":"rad/s",velocityValue:e.jointType===V.JointTypeEnum.PrismaticJoint?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec})}async function r(){await e.jogger.stop(),await e.deactivate()}return o.jsxs(P,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[o.jsx(Ve,{store:e,useDegree:e.jointType===V.JointTypeEnum.RevoluteJoint}),o.jsx(U,{}),o.jsx(P,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:o.jsx(P,{"data-testid":"jogging-joint-value-controls-wrapper","aria-label":"jogging-joint-value-controls-wrapper",alignItems:"center",gap:"24px",children:e.jogger.motionStream.joints.map(i=>{var s,l,g;const c=(g=(l=(s=e.motionGroupDescription.operation_limits.auto_limits)==null?void 0:s.joints)==null?void 0:l[i.index])==null?void 0:g.position;return o.jsxs(P,{"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:[e.showJointsLegend&&o.jsx(R,{color:e.isLocked?n.palette.text.disabled:n.palette.text.secondary,children:`G${i.index+1}`}),o.jsx(De,{disabled:e.isLocked,lowerLimit:c==null?void 0:c.lower_limit,upperLimit:c==null?void 0:c.upper_limit,useDegree:e.jointType===V.JointTypeEnum.RevoluteJoint,getValue:()=>{const h=e.jogger.motionStream.rapidlyChangingMotionState.joint_position[i.index];return h!==void 0?h:void 0},startJogging:h=>a({joint:i.index,direction:h}),stopJogging:r})]},`joint-${i.index}`)})})}),o.jsx(ze,{store:e}),t&&o.jsx(U,{}),t]})}),Xt=B.externalizeComponent(D.observer(e=>{const t=ue.isString(e.nova)?new V.NovaClient({instanceUrl:e.nova}):e.nova,n=D.useLocalObservable(()=>({joggingStore:null,loadingError:null}));async function a(){_.runInAction(()=>{n.loadingError=null,n.joggingStore=null});try{let r=e.store;if(!r){const i=await re.open(t,e.motionGroupId);r=await ae.loadFor(i)}_.runInAction(()=>{n.joggingStore=r}),e.onSetup&&e.onSetup(r)}catch(r){n.loadingError=r}}return m.useEffect(()=>(a(),e.store?()=>null:()=>{var r;(r=n.joggingStore)==null||r.dispose()}),[e.store,e.nova,e.motionGroupId]),m.useEffect(()=>{const r=n.joggingStore;r&&(e.locked?r.lock("external"):r.unlock("external"))},[n.joggingStore,e.locked]),o.jsx(P,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...e.sx},children:n.joggingStore?o.jsx(Qt,{store:n.joggingStore,children:e.children}):o.jsx(Fe,{message:"Loading jogging",error:n.loadingError})})})),Qt=D.observer(({store:e,children:t})=>{const{t:n}=L.useTranslation();function a(){if(e.currentTab.id==="cartesian")return o.jsx(Yt,{store:e,children:t});if(e.currentTab.id==="joint")return o.jsx(Zt,{store:e,children:t})}return o.jsxs(P,{flexGrow:1,sx:{overflow:"hidden"},children:[o.jsx(_e,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:e.tabIndex,onChange:e.onTabChange,variant:"fullWidth",children:e.tabs.map(r=>{const i=r.label==="Cartesian"?n("Jogging.Cartesian.bt"):n("Jogging.Joints.bt"),c=r.label==="cartesian"?o.jsx(tt,{fontSize:"small",sx:{mr:1}}):o.jsx(nt,{fontSize:"small",sx:{mr:1}});return o.jsx(Pe,{"data-testid":`jogging-tab-${r.id}`,"aria-label":`jogging-tab-${r.id}`,label:e.showTabIcons?o.jsxs(P,{direction:"row",alignItems:"center",children:[c,i]}):i,id:`jogging-tab-${r.id}`,"aria-controls":`jogging-tab-${r.id}`},r.id)})}),o.jsx(P,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:a()}),e.blocked&&o.jsx(qt,{store:e})]})}),qe=e=>{var s;const{value:t,ref:n}=e,a=A.useTheme(),[r,i]=m.useState(!1);async function c(){if(!n||!("current"in n))return console.warn("No copy target found"),!1;try{return await navigator.clipboard.writeText(t),console.log("Copied!"),i(!0),!0}catch(l){console.error(l);const g=window.getSelection();if(g&&n&&"current"in n&&n.current){const h=document.createRange();h.selectNodeContents(n.current),g.removeAllRanges(),g.addRange(h)}}return!1}return m.useEffect(()=>{if(!r)return;const l=setTimeout(()=>i(!1),3e3);return()=>{l&&clearTimeout(l)}},[r]),o.jsx(bt,{open:r,title:"Copied!",children:o.jsx(P,{justifyContent:"center",sx:{height:"100%",boxSizing:"border-box",padding:"6px 12px",background:(s=a.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:a.palette.text.primary,whiteSpace:"nowrap",minWidth:0,textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:t})})})},Kt=B.externalizeComponent(D.observer(({tcpPose:e,showCopyButton:t=!1})=>{const[n,a]=m.useState(null),r=V.poseToWandelscriptString(e),i=async()=>{try{await navigator.clipboard.writeText(r),a("Copied!"),setTimeout(()=>a(null),2e3)}catch{a("Copy failed"),setTimeout(()=>a(null),2e3)}};return o.jsxs(P,{direction:"row",alignItems:"center",spacing:1,sx:{flexGrow:1,minWidth:0,overflow:"hidden"},"data-testid":"pose-cartesian-values",children:[o.jsx(qe,{value:r}),t&&o.jsx(H,{variant:"contained",color:"secondary",size:"small",onClick:i,sx:{flexShrink:0},children:n||"Copy"})]})})),en=B.externalizeComponent(D.observer(({joints:e,showCopyButton:t=!1})=>{const[n,a]=m.useState(null),r=`[${e.map(c=>parseFloat(c.toFixed(4))).join(", ")}]`,i=async()=>{try{await navigator.clipboard.writeText(r),a("Copied!"),setTimeout(()=>a(null),2e3)}catch{a("Copy failed"),setTimeout(()=>a(null),2e3)}};return o.jsxs(P,{direction:"row",alignItems:"center",spacing:1,sx:{flexGrow:1,minWidth:0,overflow:"hidden"},"data-testid":"pose-joint-values",children:[o.jsx(qe,{value:r}),t&&o.jsx(H,{variant:"contained",color:"secondary",size:"small",onClick:i,sx:{flexShrink:0},children:n||"Copy"})]})}));class Ne{constructor(){this.messages=[],this.addMessage=(t,n="info")=>{const a={id:Math.random().toString(36).substring(2,11),timestamp:new Date,message:t,level:n};this.messages.push(a)},this.clearMessages=()=>{this.messages=[]},this.addInfo=t=>{this.addMessage(t,"info")},this.addWarning=t=>{this.addMessage(t,"warning")},this.addError=t=>{this.addMessage(t,"error")},this.addDebug=t=>{this.addMessage(t,"debug")},_.makeObservable(this,{messages:_.observable,addMessage:_.action,clearMessages:_.action})}}const K=(e,t,n)=>({id:n||`${Date.now()}-${Math.random().toString(36).substring(2,11)}`,timestamp:new Date,message:e,level:t}),tn=(e,t)=>K(e,"debug",t),nn=(e,t)=>K(e,"info",t),on=(e,t)=>K(e,"warning",t),rn=(e,t)=>K(e,"error",t),We=B.externalizeComponent(D.observer(e=>{var h;const{messages:t=[],onClear:n,height:a=400,sx:r}=e,i=A.useTheme(),c=m.useRef(null);m.useEffect(()=>{if(t.length===0)return;const d=c.current;if(!d)return;const u=setTimeout(()=>{d.scrollTop=d.scrollHeight},10);return()=>clearTimeout(u)},[t.length]);const s=d=>d.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),l=d=>{switch(d){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}},g=({message:d})=>{const[u,p]=m.useState(!1),[y,S]=m.useState(!1),[x,f]=m.useState(!1),v=d.message.length>150,b=async()=>{try{await navigator.clipboard.writeText(d.message),S(!0),setTimeout(()=>S(!1),2e3)}catch(j){console.error("Failed to copy message:",j)}},C=v&&!u?`${d.message.substring(0,150)}...`:d.message;return o.jsx(T,{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(T,{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(d.timestamp),"]"]}),o.jsx(R,{component:"span",sx:{fontWeight:400,fontSize:"12px",lineHeight:"18px",letterSpacing:"0.4px",color:l(d.level),wordBreak:"break-word",overflowWrap:"anywhere",hyphens:"auto",flex:1,whiteSpace:"pre-wrap"},children:C}),o.jsxs(T,{sx:{display:"flex",alignItems:"flex-start",gap:.5,opacity:x?1:0,transition:"opacity 0.2s ease-in-out",visibility:x?"visible":"hidden"},children:[o.jsx(W,{size:"small",onClick:b,sx:{padding:"2px",color:i.palette.text.secondary,"&:hover":{backgroundColor:i.palette.action.hover}},title:y?"Copied!":"Copy message",children:o.jsx(yt,{sx:{fontSize:12}})}),v&&o.jsx(W,{size:"small",onClick:()=>p(!u),sx:{padding:"2px",color:i.palette.text.secondary,"&:hover":{backgroundColor:i.palette.action.hover}},title:u?"Collapse":"Expand",children:u?o.jsx(vt,{sx:{fontSize:12}}):o.jsx(jt,{sx:{fontSize:12}})})]})]})},d.id)};return o.jsxs(Ct,{sx:{backgroundColor:((h=i.palette.backgroundPaperElevation)==null?void 0:h[2])||"#171927",backgroundImage:"none",height:a,display:"flex",flexDirection:"column",overflow:"hidden",...r},children:[o.jsxs(T,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px"},children:[o.jsxs(T,{sx:{display:"flex",alignItems:"center",gap:1},children:[o.jsx(St,{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(T,{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:t.length===0?o.jsx(R,{sx:{color:i.palette.text.disabled,fontSize:"12px",fontStyle:"italic",textAlign:"center",marginTop:2},children:"No log messages"}):t.map(d=>o.jsx(g,{message:d},d.id))})]})})),an=B.externalizeComponent(D.observer(e=>{const{store:t,onStoreReady:n,...a}=e,r=m.useRef(n);m.useEffect(()=>{r.current=n},[n]);const i=m.useMemo(()=>{var l;const s=t||new Ne;return(l=r.current)==null||l.call(r,s),s},[t]),c=()=>{i.clearMessages()};return o.jsx(We,{...a,messages:i.messages,onClear:c})}));function sn(){const e=window.location.href;return e.substring(0,e.indexOf("/",e.indexOf("//")+2))}function ln({baseUrl:e=sn(),...t}){return o.jsxs(Tt,{"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(Mt,{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(wt,{children:o.jsxs(P,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[o.jsx(H,{href:`${e}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),o.jsx(H,{href:`${e}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}var he=(e=>(e.PRECONDITION_NOT_FULFILLED="PRECONDITION_NOT_FULFILLED",e.ROBOT_DISCONNECTED="ROBOT_DISCONNECTED",e.CELL_OPEN="CELL_OPEN",e.E_STOP="E_STOP",e.MANUAL_MODE="MANUAL_MODE",e.READY="READY",e))(he||{});const Ge=B.externalizeComponent(D.observer(({setupState:e,className:t})=>{const n=A.useTheme(),{t:a}=L.useTranslation(),r=()=>{var g,h,d,u,p,y,S;switch(e){case"READY":return{label:a("RobotSetupReadinessIndicator.Ready.lb"),indicatorColor:((g=n.palette.tertiary)==null?void 0:g.main)||n.palette.primary.main,backgroundColor:((h=n.palette.backgroundPaperElevation)==null?void 0:h[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};case"ROBOT_DISCONNECTED":return{label:a("RobotSetupReadinessIndicator.RobotDisconnected.lb"),indicatorColor:n.palette.error.main,backgroundColor:((d=n.palette.backgroundPaperElevation)==null?void 0:d[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};case"CELL_OPEN":return{label:a("RobotSetupReadinessIndicator.CellOpen.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"E_STOP":return{label:a("RobotSetupReadinessIndicator.EStop.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"MANUAL_MODE":return{label:a("RobotSetupReadinessIndicator.ManualMode.lb"),indicatorColor:n.palette.error.main,backgroundColor:((y=n.palette.backgroundPaperElevation)==null?void 0:y[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};default:return{label:a("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}=r();return o.jsx(Rt,{className:t,label:o.jsxs(T,{sx:{display:"flex",alignItems:"center",gap:1},children:[o.jsx(T,{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}}})})),cn=B.externalizeComponent(D.observer(({robotName:e,robotType:t,setupState:n,PreconditionComponent:a=Ge,className:r})=>{var l;const i=A.useTheme(),c=t||"Robot",s=n===he.READY;return o.jsxs(T,{className:r,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(T,{sx:{display:"flex",alignItems:"center",gap:2,flex:1},children:[s?o.jsx(T,{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(N.ForwardRef$5,{})}):o.jsx(It,{sx:{color:i.palette.error.main,fontSize:24}}),o.jsx(R,{variant:"body1",sx:{fontWeight:500,color:i.palette.text.primary},children:e}),o.jsx(U,{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})]}),a&&o.jsx(a,{setupState:n})]})})),dn=A.styled(Et,{shouldForwardProp:e=>e!=="selected"})(({theme:e})=>{var t,n,a;return{borderRadius:"20px","&:hover":{background:(t=e.palette.backgroundPaperElevation)==null?void 0:t[7]},variants:[{props:({selected:r})=>!r,style:{background:(n=e.palette.backgroundPaperElevation)==null?void 0:n[0],color:e.palette.action.disabled,"> img":{opacity:.4}}},{props:({selected:r})=>r,style:{background:(a=e.palette.backgroundPaperElevation)==null?void 0:a[11],border:`1px solid ${e.palette.divider}`,color:e.palette.primary.contrastText}}]}}),un=e=>{const{ref:t,...n}=e;return o.jsx(dn,{ref:t,selected:e.selected,...n,color:"secondary",variant:"circular"})};function gn(e){const{children:t,value:n,index:a,...r}=e;return o.jsx("div",{role:"tabpanel",hidden:n!==a,id:`tabpanel-${a}`,"aria-labelledby":`tab-${a}`,...r,children:n===a&&o.jsx(T,{children:t})})}function pn({children:e,...t}){const{fullWidth:n,indicator:a,onChange:r,orientation:i,scrollButtons:c,selectionFollowsFocus:s,textColor:l,value:g,variant:h,...d}=t;return o.jsx(T,{...d,children:e})}const mn=B.externalizeComponent(D.observer(e=>{const{items:t,activeTab:n,defaultActiveTab:a=0,onTabChange:r,sx:i,ref:c}=e,s=n!==void 0,[l,g]=m.useState(a),h=s?n:l;m.useEffect(()=>{s||t.length!==0&&(l<0||l>t.length-1)&&g(0)},[t.length,s,l]);const d=(u,p)=>{s||g(p),r==null||r(p)};return o.jsxs(T,{ref:c,sx:{height:"100%",display:"flex",flexDirection:"column",...i},children:[o.jsx(T,{sx:{px:0,py:0,overflow:"visible",position:"relative",paddingTop:u=>u.spacing(2),paddingRight:u=>u.spacing(2.5)},children:o.jsx(_e,{value:h,onChange:d,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:t.map((u,p)=>{var C,j,w;const y=()=>{if(!u.badge)return;const M=u.badge.content,I=u.badge.max;return typeof M=="number"&&I&&M>I?`${I}+`:M},S=()=>{if(!u.badge)return!1;const M=u.badge.content,I=u.badge.showZero;return!(M===0&&!I)},x=y(),f=S(),v=()=>{s||g(p),r==null||r(p)},b=o.jsx(Pe,{label:u.label,icon:u.icon,iconPosition:"start",disableRipple:!0,onClick:v,sx:{minHeight:"32px",height:"32px",padding:"0px 10px",borderRadius:"12px",backgroundColor:M=>{var I;return((I=M.palette.backgroundPaperElevation)==null?void 0:I[11])||"#32344B"},color:"text.primary",opacity:h===p?1:.38,fontSize:"13px",transition:"all 0.2s ease-in-out",position:"relative",overflow:"visible","&:hover":{opacity:h===p?1:.6},"&.Mui-selected":{opacity:1,backgroundColor:M=>{var I;return((I=M.palette.backgroundPaperElevation)==null?void 0:I[11])||"#32344B"},color:"text.primary"},"&:focus":{outline:"none"},"&:active":{transform:"none"}}},u.id);return f?o.jsx(pn,{component:"span",sx:{display:"inline-flex"},children:o.jsx(Pt,{badgeContent:x,color:((C=u.badge)==null?void 0:C.color)||"error",max:(j=u.badge)==null?void 0:j.max,showZero:(w=u.badge)==null?void 0:w.showZero,anchorOrigin:{vertical:"top",horizontal:"right"},overlap:"rectangular",sx:{"& .MuiBadge-badge":{opacity:"1 !important"}},children:b})},u.id):b})})}),o.jsx(T,{sx:{mt:u=>u.spacing(2),borderBottom:1,borderColor:"divider"}}),o.jsx(T,{sx:{flex:1,overflow:"auto"},children:t.map((u,p)=>o.jsx(gn,{value:h,index:p,children:u.content},u.id))})]})})),hn=e=>{const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),a=Math.floor(e%3600/60),r=e%60,i=[];return t>0?(i.push(t.toString()),i.push(n.toString().padStart(2,"0")),i.push(a.toString().padStart(2,"0")),i.push(r.toString().padStart(2,"0"))):n>0?(i.push(n.toString()),i.push(a.toString().padStart(2,"0")),i.push(r.toString().padStart(2,"0"))):(i.push(a.toString()),i.push(r.toString().padStart(2,"0"))),i.join(":")},Ie=(e,t)=>{const n=Math.floor(e/86400),a=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60;if(typeof Intl<"u"&&"DurationFormat"in Intl)try{const s={};return n>0&&(s.days=n),a>0&&(s.hours=a),r>0&&(s.minutes=r),(i>0||Object.keys(s).length===0)&&(s.seconds=i),new Intl.DurationFormat(t,{style:"narrow"}).format(s)}catch{}const c=[];return n>0&&c.push(`${n}d`),a>0&&c.push(`${a}h`),r>0&&c.push(`${r}m`),(i>0||c.length===0)&&c.push(`${i}s`),c.join(" ")},fn=({timerState:e,animationState:t,hasError:n,className:a})=>{const{t:r}=L.useTranslation(),i=A.useTheme(),{elapsedTime:c,currentProgress:s}=e,{showErrorAnimation:l,showPauseAnimation:g,showMainText:h}=t;return o.jsxs(T,{className:a,sx:{position:"relative",width:264,height:264,display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx(_t.Gauge,{width:264,height:264,value:s,valueMin:0,valueMax:100,innerRadius:"85%",outerRadius:"100%",margin:0,skipAnimation:!0,text:()=>"",sx:{opacity:g||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(T,{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(T,{sx:{position:"relative",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:.5},children:[o.jsx(q,{in:h&&n,timeout:200,children:o.jsx(R,{variant:"h6",sx:{position:"absolute",fontSize:"16px",fontWeight:500,color:i.palette.error.light},children:r("timer.error")})}),o.jsx(q,{in:h&&!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:hn(c)})})]})})]})},xn=({timerState:e,animationState:t,hasError:n,compact:a,className:r})=>{const{t:i,i18n:c}=L.useTranslation(),s=A.useTheme(),{elapsedTime:l,currentProgress:g}=e,{showErrorAnimation:h,showPauseAnimation:d}=t;return a?o.jsx(T,{className:r,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"):Ie(l,c.language)})}):o.jsxs(T,{className:r,sx:{display:"flex",alignItems:"center",m:0,gap:1},children:[o.jsx(T,{sx:{width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:d||h?.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-g/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"):Ie(l,c.language)})]})},bn=()=>{const[e,t]=m.useState({showPauseAnimation:!1,showErrorAnimation:!1,showMainText:!0}),n=m.useRef(null),a=m.useRef(null),r=m.useRef(null),i=m.useCallback(()=>{t(d=>({...d,showPauseAnimation:!0})),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{t(d=>({...d,showPauseAnimation:!1}))},800)},[]),c=m.useCallback(()=>{t(d=>({...d,showErrorAnimation:!0})),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{t(d=>({...d,showErrorAnimation:!1}))},600)},[]),s=m.useCallback(()=>{t(d=>({...d,showErrorAnimation:!1})),a.current&&clearTimeout(a.current)},[]),l=m.useCallback(()=>{t(d=>({...d,showMainText:!1})),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{t(d=>({...d,showMainText:!0}))},200)},[]),g=m.useCallback(()=>{t(d=>({...d,showMainText:!0}))},[]),h=m.useCallback(()=>{n.current&&clearTimeout(n.current),a.current&&clearTimeout(a.current),r.current&&clearTimeout(r.current)},[]);return{animationState:e,triggerPauseAnimation:i,triggerErrorAnimation:c,clearErrorAnimation:s,triggerFadeTransition:l,setInitialAnimationState:g,cleanup:h}},yn=({autoStart:e,hasError:t,onPauseAnimation:n,onErrorAnimation:a,onClearErrorAnimation:r})=>{const[i,c]=m.useState({elapsedTime:0,isRunning:!1,isPausedState:!1,currentProgress:0,wasRunningBeforeError:!1}),s=m.useRef(null),l=m.useRef(null),g=m.useRef(0),h=m.useRef(0),[d]=Y.useInterpolation([0],{tension:80,friction:18,onChange:([f])=>{c(v=>({...v,currentProgress:f}))}}),u=m.useCallback((f=0)=>{const v=f/60%1*100;c(b=>({...b,elapsedTime:f,isPausedState:!1,currentProgress:v})),g.current=0,h.current=v,d.setImmediate([v]),e?(l.current=Date.now()-f*1e3,c(b=>({...b,isRunning:!0}))):l.current=null},[e,d]),p=m.useCallback(()=>{if(l.current&&i.isRunning){const v=(Date.now()-l.current)/1e3+g.current,b=v/60%1*100;d.setTarget([b]),c(C=>({...C,elapsedTime:Math.floor(v)}))}c(f=>({...f,isRunning:!1,isPausedState:!0})),n()},[i.isRunning,d,n]),y=m.useCallback(()=>{i.isPausedState&&(g.current=i.elapsedTime,l.current=Date.now(),c(f=>({...f,isRunning:!0,isPausedState:!1})))},[i.isPausedState,i.elapsedTime]),S=m.useCallback(()=>{c(f=>({...f,elapsedTime:0,isRunning:!1,isPausedState:!1,currentProgress:0})),g.current=0,l.current=null,h.current=0,d.setImmediate([0])},[d]),x=m.useCallback(()=>i.isPausedState,[i.isPausedState]);return m.useEffect(()=>{t?(i.isRunning&&(c(f=>({...f,wasRunningBeforeError:!0})),p()),a()):(i.wasRunningBeforeError&&!i.isRunning&&(c(f=>({...f,wasRunningBeforeError:!1})),y()),r())},[t,i.isRunning,i.wasRunningBeforeError,p,y,a,r]),m.useEffect(()=>{if(i.isRunning){const f=()=>{if(l.current){const b=(Date.now()-l.current)/1e3+g.current,C=b/60%1*100;c(w=>({...w,elapsedTime:Math.floor(b)})),Math.abs(C-h.current)>.1&&(d.setTarget([C]),h.current=C)}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,d]),m.useEffect(()=>{let f=null;const v=()=>{d.update(),f=requestAnimationFrame(v)};return f=requestAnimationFrame(v),()=>{f&&cancelAnimationFrame(f)}},[d]),{timerState:i,controls:{start:u,pause:p,resume:y,reset:S,isPaused:x}}},Sn=B.externalizeComponent(D.observer(({onTimerReady:e,autoStart:t=!0,variant:n="default",compact:a=!1,className:r,hasError:i=!1})=>{const{animationState:c,triggerPauseAnimation:s,triggerErrorAnimation:l,clearErrorAnimation:g,setInitialAnimationState:h,cleanup:d}=bn(),{timerState:u,controls:p}=yn({autoStart:t,hasError:i,onPauseAnimation:s,onErrorAnimation:l,onClearErrorAnimation:g});return m.useEffect(()=>{h()},[h]),m.useEffect(()=>{let y=!0;const S=setTimeout(()=>{y&&e(p)},0);return()=>{y=!1,clearTimeout(S)}},[e,p]),m.useEffect(()=>d,[d]),n==="small"?o.jsx(xn,{timerState:u,animationState:c,hasError:i,compact:a,className:r}):o.jsx(fn,{timerState:u,animationState:c,hasError:i,className:r})})),Re=1e-4,vn={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class oe{constructor(t,n,a,r,i,c,s,l,g,h){this.nova=t,this.controller=n,this.motionGroup=a,this.initialMotionState=r,this.motionStateSocket=i,this.isVirtual=c,this.tcps=s,this.description=l,this.initialControllerState=g,this.controllerStateSocket=h,this.connectedJoggingSocket=null,this.joggingVelocity=10,this.activationState="inactive",this.rapidlyChangingMotionState=r,this.controllerState=g,h.addEventListener("message",d=>{var p;const u=(p=J.tryParseJson(d.data))==null?void 0:p.result;u&&_.runInAction(()=>{this.controllerState=u})}),i.addEventListener("message",d=>{var p;const u=(p=J.tryParseJson(d.data))==null?void 0:p.result;if(!u)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${d.data}`);ge(this.rapidlyChangingMotionState.joint_position,u.joint_position,Re)||_.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=u.joint_position}),pe(this.rapidlyChangingMotionState,u,Re)||_.runInAction(()=>{this.rapidlyChangingMotionState.tcp_pose=u.tcp_pose}),this.rapidlyChangingMotionState.standstill!==u.standstill&&_.runInAction(()=>{this.rapidlyChangingMotionState.standstill=u.standstill})}),_.makeAutoObservable(this)}static async connectMultiple(t,n){return Promise.all(n.map(a=>oe.connect(t,a)))}static async connect(t,n){var f,v;const[a,r]=n.split("@"),i=await t.api.controller.getCurrentRobotControllerState(r),c=i==null?void 0:i.motion_groups.find(b=>b.motion_group===n);if(!i||!c)throw new Error(`Controller ${r} or motion group ${n} not found`);const s=t.openReconnectingWebsocket(`/controllers/${r}/motion-groups/${n}/state-stream`),l=await s.firstMessage(),g=(f=J.tryParseJson(l.data))==null?void 0:f.result;if(!g)throw new Error(`Unable to parse initial motion state message ${l.data}`);console.log(`Connected motion state websocket to motion group ${c.motion_group}. Initial state:
|
|
2
|
+
`,g);const h=await t.api.motionGroup.getMotionGroupDescription(r,c.motion_group);return new ie(t,i,c,h,g,s)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get joints(){return this.initialMotionState.joint_position.map((t,n)=>({index:n}))}dispose(){this.motionStateSocket.close()}}const Me="Movement request rejected. Another client is currently executing a 'Jogging' motion!";class re{constructor(t,n={}){this.motionStream=t,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)||t.motionGroup.tcp||this.getDefaultTcp(t),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(t,n,a={}){const r=await ie.open(t,n),i=new re(r,a);return await i.setJoggingMode(i.mode),i}getDefaultTcp(t){var a,r;const n=(r=(a=t.description.dh_parameters)==null?void 0:a[0])==null?void 0:r.type;return t.joints.length<6&&(n===V.JointTypeEnum.RevoluteJoint||n===V.JointTypeEnum.PrismaticJoint)?this.NO_TCP:this.DEFAULT_TCP}async setOptions(t){t.tcp&&(this.tcp=t.tcp),t.orientation&&(this.orientation=t.orientation),t.timeout&&(this.timeout=t.timeout),t.mode&&(this.mode=t.mode),t.onError&&(this.onError=t.onError),this.setJoggingMode(this.mode,!1)}get motionGroupId(){return this.motionStream.motionGroupId}get nova(){return this.motionStream.nova}get numJoints(){return this.motionStream.joints.length}async stop(){if(this.joggingSocket){const t=new Array(this.numJoints).fill(0);this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:t})}this.trajectorySocket&&this.trajectorySocket.sendJson({message_type:"PauseMovementRequest"})}async dispose(){const t=[this.joggingSocket,this.trajectorySocket].filter(n=>n!==null);return t.forEach(n=>{n.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(t.map(n=>n.closed()))}async setJoggingMode(t,n=!0){if(!(this.mode===t&&n)&&(this.dispose(),this.mode=t,this.mode==="jogging"))return this.initializeJoggingWebsocket()}async initializeJoggingWebsocket(){return new Promise((t,n)=>{const a=setTimeout(()=>{n(new Error(`Jogging initialization timeout after ${this.timeout} seconds`))},this.timeout);this.joggingSocket=this.nova.openReconnectingWebsocket(`/controllers/${this.motionStream.controllerId}/execution/jogging`),this.joggingSocket.addEventListener("message",r=>{var c,s,l,g;const i=J.tryParseJson(r.data);if(((c=i==null?void 0:i.result)==null?void 0:c.kind)==="INITIALIZE_RECEIVED"){clearTimeout(a),t();return}if(((s=i==null?void 0:i.result)==null?void 0:s.kind)==="MOTION_ERROR")if(clearTimeout(a),this.onBlocked&&((l=i==null?void 0:i.result)!=null&&l.message.includes(Me))){(g=this.joggingSocket)==null||g.dispose(),this.onBlocked();return}else this.onError?this.onError(r.data):n(new Error(r.data))}),this.joggingSocket.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:n,velocityValue:a,velocityUnit:r}){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[t]=n==="-"?-a:a,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:i})}async translateTCP({axis:t,direction:n,velocityMmPerSec:a}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const r=[0,0,0],i=[0,0,0];i[J.XYZ_TO_VECTOR[t]]=n==="-"?-a:a,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:i,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:t,direction:n,velocityRadsPerSec:a}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const r=[0,0,0],i=[0,0,0];r[J.XYZ_TO_VECTOR[t]]=n==="-"?-a:a,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:i,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async runIncrementalCartesianMotion({currentTcpPose:t,currentJoints:n,velocityInRelevantUnits:a,axis:r,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(!t.position)throw new Error("Current pose has no position, cannot perform translation");const x=[...t.position];x[J.XYZ_TO_VECTOR[r]]+=c.distanceMm*(i==="-"?-1:1),s.push({limits_override:{tcp_velocity_limit:a},path:{path_definition_name:"PathLine",target_pose:{position:x,orientation:t.orientation}}})}else if(c.type==="rotate"){if(!t.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const x=new se.Vector3(t.orientation[0],t.orientation[1],t.orientation[2]),f=x.length(),v=x.clone().normalize(),b=c.distanceRads*(i==="-"?-1:1),C=new se.Vector3(0,0,0);C[r]=1;const j=Math.cos(.5*b)*Math.cos(.5*f),w=Math.sin(.5*b)*Math.sin(.5*f),M=Math.sin(.5*b)*Math.cos(.5*f),I=Math.cos(.5*b)*Math.sin(.5*f),k=C.dot(v),E=C.clone().cross(v),F=2*Math.acos(j-w*k),Z=F/Math.sin(.5*F),ee=new se.Vector3().addScaledVector(E,w).addScaledVector(C,M).addScaledVector(v,I).multiplyScalar(Z);s.push({limits_override:{tcp_orientation_velocity_limit:a},path:{path_definition_name:"PathLine",target_pose:{position:t.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 g={motion_group_model:l.motion_group_model,cycle_time:l.cycle_time,mounting:l.mounting,global:l.operation_limits.auto_limits},h=await this.nova.api.trajectoryPlanning.planTrajectory({motion_group_setup:g,start_joint_position:n,motion_commands:s}),d=h.response;if(!d)throw new Error(`Failed to plan jogging increment motion ${JSON.stringify(h)}`);this.trajectorySocket&&(console.warn("Trajectory jogging websocket already open; will close"),this.trajectorySocket.dispose()),this.trajectorySocket=this.nova.openReconnectingWebsocket(`/controllers/${this.motionStream.controllerId}/execution/trajectory`);const u=x=>{var f;if(!x||x.add_trajectory_error||x.message)if(this.onError)this.onError(x);else throw new Error(((f=x==null?void 0:x.add_trajectory_error)==null?void 0:f.message)||(x==null?void 0:x.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"})},p=async()=>{var x;await _.when(()=>!this.motionStream.rapidlyChangingMotionState.standstill),await _.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(x=this.trajectorySocket)==null||x.dispose(),this.trajectorySocket=null},y=async()=>{var x;await _.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(x=this.trajectorySocket)==null||x.dispose(),this.trajectorySocket=null},S=async x=>{if(x!=null&&x.message)if(this.onError){this.onError(x);return}else throw new Error(x.message||"Failed to execute trajectory, unknown error");this.motionStream.rapidlyChangingMotionState.standstill?await p():await y()};this.trajectorySocket.addEventListener("message",x=>{var v,b;const f=J.tryParseJson(x.data);if(!((v=f==null?void 0:f.result)!=null&&v.kind))throw new Error(`Failed to execute trajectory: Received invalid message ${x.data}`);if(this.onBlocked&&((b=f.result.message)!=null&&b.includes(Me))){this.onBlocked();return}if(f.result.kind==="INITIALIZE_RECEIVED")u(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:d,tcp:this.tcp}})}}const Fe=e=>{const t=e.softTimeout||3e3,[n,a]=m.useState(!1),r=A.useTheme();return m.useEffect(()=>{const i=setTimeout(()=>{a(!0)},t);return()=>clearTimeout(i)}),o.jsx(P,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:r.palette.text.primary},children:e.error?o.jsx(Le,{loadingMessage:e.message,error:e.error}):o.jsxs(o.Fragment,{children:[o.jsx(ot,{sx:{marginBottom:"24px"}}),!!e.message&&o.jsx("div",{children:e.message}),o.jsx(P,{sx:{visibility:n?"visible":"hidden",marginTop:"1rem",color:r.palette.text.secondary},children:"This is taking longer than expected..."})]})})},Le=e=>{const t=rt.makeErrorMessage(e.error),n=e.error instanceof Error?e.error.stack:null,a=A.useTheme();return o.jsxs(P,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",padding:2,overflow:"auto",color:a.palette.error.main,"& pre":{whiteSpace:"pre-wrap",wordBreak:"break-word",paddingBottom:"3rem"}},children:[(e.loadingMessage?`Error while ${ue.lowerFirst(it.capitalize(e.loadingMessage))} - `:"")+t,o.jsx("br",{}),n&&o.jsx("pre",{children:n})]})},qt=D.observer(({store:e})=>{const{t}=L.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(P,{sx:{m:2,width:"100%"},children:[o.jsxs(at,{severity:"error",sx:{mb:2},children:[o.jsx(st,{children:t("Jogging.Blocked.ti")}),t("Jogging.Blocked.lb")]}),o.jsx(H,{variant:"contained",color:"secondary",onClick:()=>e.unblock(),children:t("Jogging.Blocked.Reenable.bt")})]})})}),ze=D.observer(({store:e})=>{const{t}=L.useTranslation(),[n,a]=m.useState(e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached),r=m.useRef(n);Y.useAnimationFrame(()=>{const c=e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;lt(r.current,c)||(r.current=c,a(c))});const i=[];for(const[c,s]of n.entries())s&&i.push(c);return o.jsx(R,{"data-testid":"jogging-joint-limit-detector","aria-label":"jogging-joint-limit-detector",color:"error",sx:{margin:"0.5rem 1rem",textAlign:"center",minHeight:"1.5rem",visibility:i.length?"visible":"hidden"},children:t("Jogging.JointLimitsReached.lb",{jointNumbers:i.map(c=>c+1).join(", ")})})}),Nt=A.styled(ct)(({theme:e})=>({"&.MuiFormControl-root":{".MuiSelect-select":{paddingTop:"20px",paddingLeft:"12px"},label:{pointerEvents:"none",fontSize:"16px"},".MuiInputLabel-root":{"&.Mui-focused":{color:e.palette.text.primary}}}}));function ne({labelValue:e,...t}){return o.jsxs(Nt,{fullWidth:!0,variant:"filled",children:[o.jsx(dt,{id:t.labelId,children:e}),o.jsx(ut,{...t})]})}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}],Wt=[{id:"continuous"},...de],Gt=["coordsys","tool"];class ae{constructor(t,n,a,r,i){var c,s,l,g;this.jogger=t,this.coordSystems=n,this.motionGroupDescription=a,this.tcps=r,this.inverseSolverValue=i,this.selectedTabId="cartesian",this.locks=new Set,this.blocked=!1,this.selectedCoordSystemId="world",this.selectedTcpId="",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 h of n)if(h.coordinate_system===""){h.coordinate_system="world";break}this.selectedCoordSystemId=((c=n[0])==null?void 0:c.coordinate_system)||"world",this.selectedTcpId=((s=r[0])==null?void 0:s.id)||"",this.inverseSolver=i,this.jointType=((g=(l=a==null?void 0:a.dh_parameters)==null?void 0:l[0])==null?void 0:g.type)??V.JointTypeEnum.RevoluteJoint,_.makeAutoObservable(this,{},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()},this.loadFromLocalStorage(),this.disposers.push(_.autorun(()=>this.saveToLocalStorage())),window.joggingStore=this}static async loadFor(t){const{nova:n}=t,[a,r]=await Promise.all([n.api.controller.listCoordinateSystems(t.motionStream.controllerId,"ROTATION_VECTOR"),n.api.motionGroup.getMotionGroupDescription(t.motionStream.controllerId,t.motionGroupId)]),i=await n.api.motionGroupModels.getMotionGroupKinematicModel(r.motion_group_model),c=Object.entries(r.tcps||{}).map(([s,l])=>({id:s,readable_name:l.name,position:l.pose.position,orientation:l.pose.orientation}));return new ae(t,a||[],r,c,i.inverse_solver)}dispose(){for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return ue.countBy(this.coordSystems,t=>t.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)&&this.jogger.setOptions({tcp:this.selectedTcpId,orientation:this.selectedOrientation}),this.activeDiscreteIncrement?this.jogger.setJoggingMode("trajectory"):this.jogger.setJoggingMode("jogging")):this.jogger.setJoggingMode("jogging"),this.jogger}loadFromLocalStorage(){const t=J.tryParseJson(localStorage.getItem("joggingToolStore"));t&&(this.tabsById[t.selectedTabId]&&(this.selectedTabId=t.selectedTabId),this.coordSystemsById[t.selectedCoordSystemId]&&(this.selectedCoordSystemId=t.selectedCoordSystemId),this.tcpsById[t.selectedTcpId]&&(this.selectedTcpId=t.selectedTcpId),this.incrementOptionsById[t.selectedIncrementId]&&(this.selectedIncrementId=t.selectedIncrementId),["translate","rotate"].includes(t.selectedCartesianMotionType)&&(this.selectedCartesianMotionType=t.selectedCartesianMotionType),["coordsys","tool"].includes(t.selectedOrientation)&&(this.selectedOrientation=t.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,selectedTcpId:this.selectedTcpId,selectedOrientation:this.selectedOrientation,selectedIncrementId:this.selectedIncrementId,selectedCartesianMotionType:this.selectedCartesianMotionType}}get tabs(){const t=[{id:"joint",label:"Joints"}];return this.inverseSolver!==null&&t.unshift({id:"cartesian",label:"Cartesian"}),t}get incrementOptions(){return Wt}get discreteIncrementOptions(){return de}get incrementOptionsById(){return te(this.incrementOptions,t=>t.id)}get tabsById(){return te(this.tabs,t=>t.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,t=>t.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get tcpsById(){return te(this.tcps,t=>t.id)}get activeDiscreteIncrement(){return this.selectedOrientation==="tool"?void 0:de.find(t=>t.id===this.selectedIncrementId)}get rotationVelocityRadsPerSec(){return this.rotationVelocityDegPerSec*Math.PI/180}velocityInDisplayUnits(t){return t?this.rotationVelocityDegPerSec:this.translationVelocityMmPerSec}minVelocityInDisplayUnits(t){return t?this.minRotationVelocityDegPerSec:this.minTranslationVelocityMmPerSec}maxVelocityInDisplayUnits(t){return t?this.maxRotationVelocityDegPerSec:this.maxTranslationVelocityMmPerSec}onTabChange(t,n){const a=this.tabs[n]||this.tabs[0];this.selectedTabId=a.id}setSelectedCoordSystemId(t){this.selectedCoordSystemId=t}setSelectedTcpId(t){this.selectedTcpId=t}setSelectedOrientation(t){this.selectedOrientation=t}setSelectedIncrementId(t){this.selectedIncrementId=t}setCurrentIncrementJog(t){this.incrementJogInProgress=t}setVelocityFromSlider(t,n){n?this.rotationVelocityDegPerSec=t:this.translationVelocityMmPerSec=t}setSelectedCartesianMotionType(t){this.selectedCartesianMotionType=t}lock(t){this.locks.add(t)}unlock(t){this.locks.delete(t)}block(){this.blocked=!0}unblock(){this.blocked=!1,this.jogger.mode==="jogging"&&this.jogger.initializeJoggingWebsocket()}async withMotionLock(t){const n=gt();this.lock(n);try{return await t()}finally{this.unlock(n)}}}const Ut=D.observer(({store:e,useDegree:t})=>{var c;const{t:n}=L.useTranslation(),a=m.useId(),r=[];function i(s){switch(s){case"coordsys":return n("Jogging.Orientation.coordsys");case"tool":return n("Jogging.Orientation.tool");default:return s}}return e.showCoordSystemSelect&&r.push(o.jsx(ne,{labelId:`jogging-coord-select-${a}`,labelValue:n("Jogging.CoordinateSystem.hlb"),value:e.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:s=>e.setSelectedCoordSystemId(s.target.value),disabled:e.isLocked,children:e.coordSystems.map(s=>o.jsx(G,{value:s.coordinate_system,children:s.name&&e.coordSystemCountByName[s.name]>1?`${s.name} / ${s.coordinate_system}`:s.name||s.coordinate_system},s.coordinate_system))},"coord")),e.showTcpSelect&&r.push(o.jsx(ne,{labelId:`jogging-tcp-select-${a}`,labelValue:"TCP",value:e.selectedTcpId,size:"small",variant:"filled",onChange:s=>e.setSelectedTcpId(s.target.value),disabled:e.isLocked,children:e.tcps.map(s=>o.jsx(G,{value:s.id,children:s.id},s.id))},"tcp")),e.showOrientationSelect&&r.push(o.jsx(ne,{labelValue:n("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${a}`,value:e.selectedOrientation,onChange:s=>e.setSelectedOrientation(s.target.value),disabled:e.isLocked,children:Gt.map(s=>o.jsx(G,{value:s,children:i(s)},s))},"orientation")),e.showIncrementSelect&&r.push(o.jsxs(ne,{labelValue:n("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${a}`,size:"small",variant:"filled",value:((c=e.activeDiscreteIncrement)==null?void 0:c.id)||"continuous",onChange:s=>e.setSelectedIncrementId(s.target.value),disabled:e.isLocked,children:[o.jsx(G,{value:"continuous",children:n("Jogging.Increment.Continuous.dd")},"continuous"),e.selectedOrientation==="tool"?null:e.discreteIncrementOptions.map(s=>o.jsx(G,{value:s.id,children:t?`${s.degrees}°`:`${s.mm}mm`},s.id))]},"increment")),o.jsx(T,{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:r.map((s,l)=>o.jsx(T,{sx:{gridColumn:r.length%2===1&&l===r.length-1?"span 2":"auto"},children:s},l))})}),Ht=A.styled(pt)(({theme:e})=>{var t;return{"&.MuiToggleButtonGroup-root":{background:(t=e.palette.backgroundPaperElevation)==null?void 0:t[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"}}}}}),$e=D.observer(e=>{var i,c,s;const t=A.useTheme(),{store:n}=e,{t:a}=L.useTranslation();function r(l,g){g===e.velocity||!mt(g)||e.onVelocityChange(g,e.useDegree)}return o.jsxs(P,{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=t.componentsExt)==null?void 0:i.JoggingPanel)==null?void 0:c.VelocitySlider)==null?void 0:s.sliderLegendColor,fontSize:"14px"},children:a("Jogging.Velocity.bt")}),o.jsx(Oe,{value:e.velocity,color:"secondary",onChange:r,min:e.min,max:e.max,"aria-labelledby":"input-slider",disabled:e.disabled,sx:{"& .MuiSlider-valueLabelOpen":{zIndex:100,backgroundColor:"transparent",top:"0px"}}}),n.showVelocitySliderLabel&&(e.renderValue?e.renderValue(e.velocity):o.jsx(me,{value:e.velocity.toString()}))]})});function me({value:e,sx:t}){var a;const n=A.useTheme();return o.jsx(P,{direction:"row",justifyContent:"center",alignItems:"center",gap:"5px",sx:{padding:"6px 12px",background:(a=n.palette.backgroundPaperElevation)==null?void 0:a[8],borderRadius:"10px",minWidth:"111px",...t},children:o.jsx(R,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:n.palette.text.primary,whiteSpace:"nowrap"},children:e})})}const Ve=D.observer(({store:e,useDegree:t})=>{const{t:n}=L.useTranslation();function a(r,i){return i?`ω = ${n("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:r})}`:`v = ${n("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:r})}`}return o.jsx($e,{store:e,velocity:e.velocityInDisplayUnits(t),min:e.minVelocityInDisplayUnits(t),max:e.maxVelocityInDisplayUnits(t),onVelocityChange:e.setVelocityFromSlider,useDegree:t,disabled:e.isLocked,renderValue:r=>o.jsx(me,{value:a(r,t),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),Yt=D.observer(({store:e,children:t})=>{const{t:n}=L.useTranslation(),a=A.useTheme();function r(u,p){(p==="translate"||p==="rotate")&&e.setSelectedCartesianMotionType(p)}Y.useReaction(()=>[e.selectedCoordSystemId,e.selectedTcpId],()=>{e.jogger.motionStream.motionStateSocket.changeUrl(e.jogger.nova.makeWebsocketURL(`/controllers/${e.jogger.motionStream.controllerId}/motion-groups/${e.jogger.motionGroupId}/state-stream?tcp=${e.selectedTcpId}`))},{fireImmediately:!0});async function i(u,p){const y=await e.activate(),S=y.motionStream.rapidlyChangingMotionState.tcp_pose,x=y.motionStream.rapidlyChangingMotionState.joint_position;S&&await e.withMotionLock(async()=>{try{e.setCurrentIncrementJog({axis:u.axis,direction:u.direction}),await e.jogger.runIncrementalCartesianMotion({currentTcpPose:S,currentJoints:x,coordSystemId:e.activeCoordSystemId,velocityInRelevantUnits:e.selectedCartesianMotionType==="translate"?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec,axis:u.axis,direction:u.direction,motion:e.selectedCartesianMotionType==="translate"?{type:"translate",distanceMm:p.mm}:{type:"rotate",distanceRads:J.degreesToRadians(p.degrees)}})}finally{e.setCurrentIncrementJog(null),await e.deactivate()}})}async function c(u){if(!e.isLocked){if(await e.activate(),e.activeDiscreteIncrement)return i(u,e.activeDiscreteIncrement);u.motionType==="translate"?await e.jogger.translateTCP({axis:u.axis,direction:u.direction,velocityMmPerSec:e.translationVelocityMmPerSec}):await e.jogger.rotateTCP({axis:u.axis,direction:u.direction,velocityRadsPerSec:e.rotationVelocityRadsPerSec})}}async function s(){e.isLocked||e.activeDiscreteIncrement||await e.deactivate()}function l(u,p,y){var x,f,v;const S=(v=(f=(x=y.componentsExt)==null?void 0:x.JoggingPanel)==null?void 0:f.JoggingCartesian)==null?void 0:v.Axis;if(S)return p==="translate"?S[u]:S.CustomRotation??S[u]}const g=[{id:"x",icon:o.jsx(N.ForwardRef,{}),colors:l("X",e.selectedCartesianMotionType,a)},{id:"y",icon:o.jsx(N.ForwardRef$1,{}),colors:l("Y",e.selectedCartesianMotionType,a)},{id:"z",icon:o.jsx(N.ForwardRef$2,{}),colors:l("Z",e.selectedCartesianMotionType,a)}];function h(u){return n("General.mm.variable",{amount:u.toFixed(1)})}function d(u){return n("General.degree.variable",{amount:J.radiansToDegrees(u).toFixed(1)})}return o.jsxs(P,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[o.jsxs(P,{gap:2,children:[o.jsx(Ut,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),o.jsx(Ve,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),o.jsx(U,{})]}),o.jsx(P,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:o.jsxs(P,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[o.jsxs(Ht,{value:e.selectedCartesianMotionType,onChange:r,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")})]}),e.selectedCartesianMotionType==="translate"&&g.map(u=>{var p,y;return o.jsx(ce,{"data-testid":`jogging-cartesian-axis-control-${u.id}`,"aria-label":`jogging-cartesian-axis-control-${u.id}`,colors:u.colors,disabled:e.isLocked,activeJoggingDirection:((p=e.incrementJogInProgress)==null?void 0:p.axis)===u.id?e.incrementJogInProgress.direction:void 0,label:o.jsxs(o.Fragment,{children:[u.icon,o.jsx(R,{sx:{fontSize:"24px",color:((y=u.colors)==null?void 0:y.labelColor)??a.palette.text.primary},children:u.id.toUpperCase()})]}),getDisplayedValue:()=>{var S,x;return h(((x=(S=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:S.position)==null?void 0:x[J.XYZ_TO_VECTOR[u.id]])||0)},startJogging:S=>c({axis:u.id,motionType:"translate",direction:S}),stopJogging:s},u.id)}),e.selectedCartesianMotionType==="rotate"&&g.map(u=>{var p,y;return o.jsx(ce,{"data-testid":`jogging-cartesian-axis-control-${u.id}`,"aria-label":`jogging-cartesian-axis-control-${u.id}`,colors:u.colors,disabled:e.isLocked,activeJoggingDirection:((p=e.incrementJogInProgress)==null?void 0:p.axis)===u.id?e.incrementJogInProgress.direction:void 0,label:o.jsxs(o.Fragment,{children:[o.jsx(N.ForwardRef$6,{}),o.jsx(R,{sx:{fontSize:"24px",color:((y=u.colors)==null?void 0:y.labelColor)??a.palette.text.primary},children:u.id.toUpperCase()})]}),getDisplayedValue:()=>{var S,x;return d(((x=(S=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:S.orientation)==null?void 0:x[J.XYZ_TO_VECTOR[u.id]])||0)},startJogging:S=>c({axis:u.id,motionType:"rotate",direction:S}),stopJogging:s},u.id)})]})}),o.jsx(ze,{store:e}),t&&o.jsx(U,{}),t]})}),Zt=D.observer(({store:e,children:t})=>{const n=A.useTheme();async function a(i){await e.activate(),await e.jogger.rotateJoints({joint:i.joint,direction:i.direction,velocityUnit:e.jointType===V.JointTypeEnum.PrismaticJoint?"mm/s":"rad/s",velocityValue:e.jointType===V.JointTypeEnum.PrismaticJoint?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec})}async function r(){await e.jogger.stop(),await e.deactivate()}return o.jsxs(P,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[o.jsx(Ve,{store:e,useDegree:e.jointType===V.JointTypeEnum.RevoluteJoint}),o.jsx(U,{}),o.jsx(P,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:o.jsx(P,{"data-testid":"jogging-joint-value-controls-wrapper","aria-label":"jogging-joint-value-controls-wrapper",alignItems:"center",gap:"24px",children:e.jogger.motionStream.joints.map(i=>{var s,l,g;const c=(g=(l=(s=e.motionGroupDescription.operation_limits.auto_limits)==null?void 0:s.joints)==null?void 0:l[i.index])==null?void 0:g.position;return o.jsxs(P,{"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:[e.showJointsLegend&&o.jsx(R,{color:e.isLocked?n.palette.text.disabled:n.palette.text.secondary,children:`G${i.index+1}`}),o.jsx(De,{disabled:e.isLocked,lowerLimit:c==null?void 0:c.lower_limit,upperLimit:c==null?void 0:c.upper_limit,useDegree:e.jointType===V.JointTypeEnum.RevoluteJoint,getValue:()=>{const h=e.jogger.motionStream.rapidlyChangingMotionState.joint_position[i.index];return h!==void 0?h:void 0},startJogging:h=>a({joint:i.index,direction:h}),stopJogging:r})]},`joint-${i.index}`)})})}),o.jsx(ze,{store:e}),t&&o.jsx(U,{}),t]})}),Xt=B.externalizeComponent(D.observer(e=>{const t=ue.isString(e.nova)?new V.NovaClient({instanceUrl:e.nova}):e.nova,n=D.useLocalObservable(()=>({joggingStore:null,loadingError:null}));async function a(){_.runInAction(()=>{n.loadingError=null,n.joggingStore=null});try{let r=e.store;if(!r){const i=await re.open(t,e.motionGroupId);r=await ae.loadFor(i)}_.runInAction(()=>{n.joggingStore=r}),e.onSetup&&e.onSetup(r)}catch(r){n.loadingError=r}}return m.useEffect(()=>(a(),e.store?()=>null:()=>{var r;(r=n.joggingStore)==null||r.dispose()}),[e.store,e.nova,e.motionGroupId]),m.useEffect(()=>{const r=n.joggingStore;r&&(e.locked?r.lock("external"):r.unlock("external"))},[n.joggingStore,e.locked]),o.jsx(P,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...e.sx},children:n.joggingStore?o.jsx(Qt,{store:n.joggingStore,children:e.children}):o.jsx(Fe,{message:"Loading jogging",error:n.loadingError})})})),Qt=D.observer(({store:e,children:t})=>{const{t:n}=L.useTranslation();function a(){if(e.currentTab.id==="cartesian")return o.jsx(Yt,{store:e,children:t});if(e.currentTab.id==="joint")return o.jsx(Zt,{store:e,children:t})}return o.jsxs(P,{flexGrow:1,sx:{overflow:"hidden"},children:[o.jsx(_e,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:e.tabIndex,onChange:e.onTabChange,variant:"fullWidth",children:e.tabs.map(r=>{const i=r.label==="Cartesian"?n("Jogging.Cartesian.bt"):n("Jogging.Joints.bt"),c=r.label==="cartesian"?o.jsx(tt,{fontSize:"small",sx:{mr:1}}):o.jsx(nt,{fontSize:"small",sx:{mr:1}});return o.jsx(Pe,{"data-testid":`jogging-tab-${r.id}`,"aria-label":`jogging-tab-${r.id}`,label:e.showTabIcons?o.jsxs(P,{direction:"row",alignItems:"center",children:[c,i]}):i,id:`jogging-tab-${r.id}`,"aria-controls":`jogging-tab-${r.id}`},r.id)})}),o.jsx(P,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:a()}),e.blocked&&o.jsx(qt,{store:e})]})}),qe=e=>{var s;const{value:t,ref:n}=e,a=A.useTheme(),[r,i]=m.useState(!1);async function c(){if(!n||!("current"in n))return console.warn("No copy target found"),!1;try{return await navigator.clipboard.writeText(t),console.log("Copied!"),i(!0),!0}catch(l){console.error(l);const g=window.getSelection();if(g&&n&&"current"in n&&n.current){const h=document.createRange();h.selectNodeContents(n.current),g.removeAllRanges(),g.addRange(h)}}return!1}return m.useEffect(()=>{if(!r)return;const l=setTimeout(()=>i(!1),3e3);return()=>{l&&clearTimeout(l)}},[r]),o.jsx(bt,{open:r,title:"Copied!",children:o.jsx(P,{justifyContent:"center",sx:{height:"100%",boxSizing:"border-box",padding:"6px 12px",background:(s=a.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:a.palette.text.primary,whiteSpace:"nowrap",minWidth:0,textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:t})})})},Kt=B.externalizeComponent(D.observer(({tcpPose:e,showCopyButton:t=!1})=>{const[n,a]=m.useState(null),r=V.poseToWandelscriptString(e),i=async()=>{try{await navigator.clipboard.writeText(r),a("Copied!"),setTimeout(()=>a(null),2e3)}catch{a("Copy failed"),setTimeout(()=>a(null),2e3)}};return o.jsxs(P,{direction:"row",alignItems:"center",spacing:1,sx:{flexGrow:1,minWidth:0,overflow:"hidden"},"data-testid":"pose-cartesian-values",children:[o.jsx(qe,{value:r}),t&&o.jsx(H,{variant:"contained",color:"secondary",size:"small",onClick:i,sx:{flexShrink:0},children:n||"Copy"})]})})),en=B.externalizeComponent(D.observer(({joints:e,showCopyButton:t=!1})=>{const[n,a]=m.useState(null),r=`[${e.map(c=>parseFloat(c.toFixed(4))).join(", ")}]`,i=async()=>{try{await navigator.clipboard.writeText(r),a("Copied!"),setTimeout(()=>a(null),2e3)}catch{a("Copy failed"),setTimeout(()=>a(null),2e3)}};return o.jsxs(P,{direction:"row",alignItems:"center",spacing:1,sx:{flexGrow:1,minWidth:0,overflow:"hidden"},"data-testid":"pose-joint-values",children:[o.jsx(qe,{value:r}),t&&o.jsx(H,{variant:"contained",color:"secondary",size:"small",onClick:i,sx:{flexShrink:0},children:n||"Copy"})]})}));class Ne{constructor(){this.messages=[],this.addMessage=(t,n="info")=>{const a={id:Math.random().toString(36).substring(2,11),timestamp:new Date,message:t,level:n};this.messages.push(a)},this.clearMessages=()=>{this.messages=[]},this.addInfo=t=>{this.addMessage(t,"info")},this.addWarning=t=>{this.addMessage(t,"warning")},this.addError=t=>{this.addMessage(t,"error")},this.addDebug=t=>{this.addMessage(t,"debug")},_.makeObservable(this,{messages:_.observable,addMessage:_.action,clearMessages:_.action})}}const K=(e,t,n)=>({id:n||`${Date.now()}-${Math.random().toString(36).substring(2,11)}`,timestamp:new Date,message:e,level:t}),tn=(e,t)=>K(e,"debug",t),nn=(e,t)=>K(e,"info",t),on=(e,t)=>K(e,"warning",t),rn=(e,t)=>K(e,"error",t),We=B.externalizeComponent(D.observer(e=>{var h;const{messages:t=[],onClear:n,height:a=400,sx:r}=e,i=A.useTheme(),c=m.useRef(null);m.useEffect(()=>{if(t.length===0)return;const d=c.current;if(!d)return;const u=setTimeout(()=>{d.scrollTop=d.scrollHeight},10);return()=>clearTimeout(u)},[t.length]);const s=d=>d.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),l=d=>{switch(d){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}},g=({message:d})=>{const[u,p]=m.useState(!1),[y,S]=m.useState(!1),[x,f]=m.useState(!1),v=d.message.length>150,b=async()=>{try{await navigator.clipboard.writeText(d.message),S(!0),setTimeout(()=>S(!1),2e3)}catch(j){console.error("Failed to copy message:",j)}},C=v&&!u?`${d.message.substring(0,150)}...`:d.message;return o.jsx(T,{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(T,{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(d.timestamp),"]"]}),o.jsx(R,{component:"span",sx:{fontWeight:400,fontSize:"12px",lineHeight:"18px",letterSpacing:"0.4px",color:l(d.level),wordBreak:"break-word",overflowWrap:"anywhere",hyphens:"auto",flex:1,whiteSpace:"pre-wrap"},children:C}),o.jsxs(T,{sx:{display:"flex",alignItems:"flex-start",gap:.5,opacity:x?1:0,transition:"opacity 0.2s ease-in-out",visibility:x?"visible":"hidden"},children:[o.jsx(W,{size:"small",onClick:b,sx:{padding:"2px",color:i.palette.text.secondary,"&:hover":{backgroundColor:i.palette.action.hover}},title:y?"Copied!":"Copy message",children:o.jsx(yt,{sx:{fontSize:12}})}),v&&o.jsx(W,{size:"small",onClick:()=>p(!u),sx:{padding:"2px",color:i.palette.text.secondary,"&:hover":{backgroundColor:i.palette.action.hover}},title:u?"Collapse":"Expand",children:u?o.jsx(vt,{sx:{fontSize:12}}):o.jsx(jt,{sx:{fontSize:12}})})]})]})},d.id)};return o.jsxs(Ct,{sx:{backgroundColor:((h=i.palette.backgroundPaperElevation)==null?void 0:h[2])||"#171927",backgroundImage:"none",height:a,display:"flex",flexDirection:"column",overflow:"hidden",...r},children:[o.jsxs(T,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px"},children:[o.jsxs(T,{sx:{display:"flex",alignItems:"center",gap:1},children:[o.jsx(St,{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(T,{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:t.length===0?o.jsx(R,{sx:{color:i.palette.text.disabled,fontSize:"12px",fontStyle:"italic",textAlign:"center",marginTop:2},children:"No log messages"}):t.map(d=>o.jsx(g,{message:d},d.id))})]})})),an=B.externalizeComponent(D.observer(e=>{const{store:t,onStoreReady:n,...a}=e,r=m.useRef(n);m.useEffect(()=>{r.current=n},[n]);const i=m.useMemo(()=>{var l;const s=t||new Ne;return(l=r.current)==null||l.call(r,s),s},[t]),c=()=>{i.clearMessages()};return o.jsx(We,{...a,messages:i.messages,onClear:c})}));function sn(){const e=window.location.href;return e.substring(0,e.indexOf("/",e.indexOf("//")+2))}function ln({baseUrl:e=sn(),...t}){return o.jsxs(Tt,{"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(Mt,{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(wt,{children:o.jsxs(P,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[o.jsx(H,{href:`${e}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),o.jsx(H,{href:`${e}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}var he=(e=>(e.PRECONDITION_NOT_FULFILLED="PRECONDITION_NOT_FULFILLED",e.ROBOT_DISCONNECTED="ROBOT_DISCONNECTED",e.CELL_OPEN="CELL_OPEN",e.E_STOP="E_STOP",e.MANUAL_MODE="MANUAL_MODE",e.READY="READY",e))(he||{});const Ge=B.externalizeComponent(D.observer(({setupState:e,className:t})=>{const n=A.useTheme(),{t:a}=L.useTranslation(),r=()=>{var g,h,d,u,p,y,S;switch(e){case"READY":return{label:a("RobotSetupReadinessIndicator.Ready.lb"),indicatorColor:((g=n.palette.tertiary)==null?void 0:g.main)||n.palette.primary.main,backgroundColor:((h=n.palette.backgroundPaperElevation)==null?void 0:h[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};case"ROBOT_DISCONNECTED":return{label:a("RobotSetupReadinessIndicator.RobotDisconnected.lb"),indicatorColor:n.palette.error.main,backgroundColor:((d=n.palette.backgroundPaperElevation)==null?void 0:d[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};case"CELL_OPEN":return{label:a("RobotSetupReadinessIndicator.CellOpen.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"E_STOP":return{label:a("RobotSetupReadinessIndicator.EStop.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"MANUAL_MODE":return{label:a("RobotSetupReadinessIndicator.ManualMode.lb"),indicatorColor:n.palette.error.main,backgroundColor:((y=n.palette.backgroundPaperElevation)==null?void 0:y[11])||n.palette.background.paper,textColor:n.palette.secondary.contrastText};default:return{label:a("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}=r();return o.jsx(Rt,{className:t,label:o.jsxs(T,{sx:{display:"flex",alignItems:"center",gap:1},children:[o.jsx(T,{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}}})})),cn=B.externalizeComponent(D.observer(({robotName:e,robotType:t,setupState:n,PreconditionComponent:a=Ge,className:r})=>{var l;const i=A.useTheme(),c=t||"Robot",s=n===he.READY;return o.jsxs(T,{className:r,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(T,{sx:{display:"flex",alignItems:"center",gap:2,flex:1},children:[s?o.jsx(T,{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(N.ForwardRef$5,{})}):o.jsx(It,{sx:{color:i.palette.error.main,fontSize:24}}),o.jsx(R,{variant:"body1",sx:{fontWeight:500,color:i.palette.text.primary},children:e}),o.jsx(U,{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})]}),a&&o.jsx(a,{setupState:n})]})})),dn=A.styled(Et,{shouldForwardProp:e=>e!=="selected"})(({theme:e})=>{var t,n,a;return{borderRadius:"20px","&:hover":{background:(t=e.palette.backgroundPaperElevation)==null?void 0:t[7]},variants:[{props:({selected:r})=>!r,style:{background:(n=e.palette.backgroundPaperElevation)==null?void 0:n[0],color:e.palette.action.disabled,"> img":{opacity:.4}}},{props:({selected:r})=>r,style:{background:(a=e.palette.backgroundPaperElevation)==null?void 0:a[11],border:`1px solid ${e.palette.divider}`,color:e.palette.primary.contrastText}}]}}),un=e=>{const{ref:t,...n}=e;return o.jsx(dn,{ref:t,selected:e.selected,...n,color:"secondary",variant:"circular"})};function gn(e){const{children:t,value:n,index:a,...r}=e;return o.jsx("div",{role:"tabpanel",hidden:n!==a,id:`tabpanel-${a}`,"aria-labelledby":`tab-${a}`,...r,children:n===a&&o.jsx(T,{children:t})})}function pn({children:e,...t}){const{fullWidth:n,indicator:a,onChange:r,orientation:i,scrollButtons:c,selectionFollowsFocus:s,textColor:l,value:g,variant:h,...d}=t;return o.jsx(T,{...d,children:e})}const mn=B.externalizeComponent(D.observer(e=>{const{items:t,activeTab:n,defaultActiveTab:a=0,onTabChange:r,sx:i,ref:c}=e,s=n!==void 0,[l,g]=m.useState(a),h=s?n:l;m.useEffect(()=>{s||t.length!==0&&(l<0||l>t.length-1)&&g(0)},[t.length,s,l]);const d=(u,p)=>{s||g(p),r==null||r(p)};return o.jsxs(T,{ref:c,sx:{height:"100%",display:"flex",flexDirection:"column",...i},children:[o.jsx(T,{sx:{px:0,py:0,overflow:"visible",position:"relative",paddingTop:u=>u.spacing(2),paddingRight:u=>u.spacing(2.5)},children:o.jsx(_e,{value:h,onChange:d,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:t.map((u,p)=>{var C,j,w;const y=()=>{if(!u.badge)return;const M=u.badge.content,I=u.badge.max;return typeof M=="number"&&I&&M>I?`${I}+`:M},S=()=>{if(!u.badge)return!1;const M=u.badge.content,I=u.badge.showZero;return!(M===0&&!I)},x=y(),f=S(),v=()=>{s||g(p),r==null||r(p)},b=o.jsx(Pe,{label:u.label,icon:u.icon,iconPosition:"start",disableRipple:!0,onClick:v,sx:{minHeight:"32px",height:"32px",padding:"0px 10px",borderRadius:"12px",backgroundColor:M=>{var I;return((I=M.palette.backgroundPaperElevation)==null?void 0:I[11])||"#32344B"},color:"text.primary",opacity:h===p?1:.38,fontSize:"13px",transition:"all 0.2s ease-in-out",position:"relative",overflow:"visible","&:hover":{opacity:h===p?1:.6},"&.Mui-selected":{opacity:1,backgroundColor:M=>{var I;return((I=M.palette.backgroundPaperElevation)==null?void 0:I[11])||"#32344B"},color:"text.primary"},"&:focus":{outline:"none"},"&:active":{transform:"none"}}},u.id);return f?o.jsx(pn,{component:"span",sx:{display:"inline-flex"},children:o.jsx(Pt,{badgeContent:x,color:((C=u.badge)==null?void 0:C.color)||"error",max:(j=u.badge)==null?void 0:j.max,showZero:(w=u.badge)==null?void 0:w.showZero,anchorOrigin:{vertical:"top",horizontal:"right"},overlap:"rectangular",sx:{"& .MuiBadge-badge":{opacity:"1 !important"}},children:b})},u.id):b})})}),o.jsx(T,{sx:{mt:u=>u.spacing(2),borderBottom:1,borderColor:"divider"}}),o.jsx(T,{sx:{flex:1,overflow:"auto"},children:t.map((u,p)=>o.jsx(gn,{value:h,index:p,children:u.content},u.id))})]})})),hn=e=>{const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),a=Math.floor(e%3600/60),r=e%60,i=[];return t>0?(i.push(t.toString()),i.push(n.toString().padStart(2,"0")),i.push(a.toString().padStart(2,"0")),i.push(r.toString().padStart(2,"0"))):n>0?(i.push(n.toString()),i.push(a.toString().padStart(2,"0")),i.push(r.toString().padStart(2,"0"))):(i.push(a.toString()),i.push(r.toString().padStart(2,"0"))),i.join(":")},Ie=(e,t)=>{const n=Math.floor(e/86400),a=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60;if(typeof Intl<"u"&&"DurationFormat"in Intl)try{const s={};return n>0&&(s.days=n),a>0&&(s.hours=a),r>0&&(s.minutes=r),(i>0||Object.keys(s).length===0)&&(s.seconds=i),new Intl.DurationFormat(t,{style:"narrow"}).format(s)}catch{}const c=[];return n>0&&c.push(`${n}d`),a>0&&c.push(`${a}h`),r>0&&c.push(`${r}m`),(i>0||c.length===0)&&c.push(`${i}s`),c.join(" ")},fn=({timerState:e,animationState:t,hasError:n,className:a})=>{const{t:r}=L.useTranslation(),i=A.useTheme(),{elapsedTime:c,currentProgress:s}=e,{showErrorAnimation:l,showPauseAnimation:g,showMainText:h}=t;return o.jsxs(T,{className:a,sx:{position:"relative",width:264,height:264,display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx(_t.Gauge,{width:264,height:264,value:s,valueMin:0,valueMax:100,innerRadius:"85%",outerRadius:"100%",margin:0,skipAnimation:!0,text:()=>"",sx:{opacity:g||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(T,{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(T,{sx:{position:"relative",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:.5},children:[o.jsx(q,{in:h&&n,timeout:200,children:o.jsx(R,{variant:"h6",sx:{position:"absolute",fontSize:"16px",fontWeight:500,color:i.palette.error.light},children:r("timer.error")})}),o.jsx(q,{in:h&&!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:hn(c)})})]})})]})},xn=({timerState:e,animationState:t,hasError:n,compact:a,className:r})=>{const{t:i,i18n:c}=L.useTranslation(),s=A.useTheme(),{elapsedTime:l,currentProgress:g}=e,{showErrorAnimation:h,showPauseAnimation:d}=t;return a?o.jsx(T,{className:r,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"):Ie(l,c.language)})}):o.jsxs(T,{className:r,sx:{display:"flex",alignItems:"center",m:0,gap:1},children:[o.jsx(T,{sx:{width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:d||h?.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-g/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"):Ie(l,c.language)})]})},bn=()=>{const[e,t]=m.useState({showPauseAnimation:!1,showErrorAnimation:!1,showMainText:!0}),n=m.useRef(null),a=m.useRef(null),r=m.useRef(null),i=m.useCallback(()=>{t(d=>({...d,showPauseAnimation:!0})),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{t(d=>({...d,showPauseAnimation:!1}))},800)},[]),c=m.useCallback(()=>{t(d=>({...d,showErrorAnimation:!0})),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{t(d=>({...d,showErrorAnimation:!1}))},600)},[]),s=m.useCallback(()=>{t(d=>({...d,showErrorAnimation:!1})),a.current&&clearTimeout(a.current)},[]),l=m.useCallback(()=>{t(d=>({...d,showMainText:!1})),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{t(d=>({...d,showMainText:!0}))},200)},[]),g=m.useCallback(()=>{t(d=>({...d,showMainText:!0}))},[]),h=m.useCallback(()=>{n.current&&clearTimeout(n.current),a.current&&clearTimeout(a.current),r.current&&clearTimeout(r.current)},[]);return{animationState:e,triggerPauseAnimation:i,triggerErrorAnimation:c,clearErrorAnimation:s,triggerFadeTransition:l,setInitialAnimationState:g,cleanup:h}},yn=({autoStart:e,hasError:t,onPauseAnimation:n,onErrorAnimation:a,onClearErrorAnimation:r})=>{const[i,c]=m.useState({elapsedTime:0,isRunning:!1,isPausedState:!1,currentProgress:0,wasRunningBeforeError:!1}),s=m.useRef(null),l=m.useRef(null),g=m.useRef(0),h=m.useRef(0),[d]=Y.useInterpolation([0],{tension:80,friction:18,onChange:([f])=>{c(v=>({...v,currentProgress:f}))}}),u=m.useCallback((f=0)=>{const v=f/60%1*100;c(b=>({...b,elapsedTime:f,isPausedState:!1,currentProgress:v})),g.current=0,h.current=v,d.setImmediate([v]),e?(l.current=Date.now()-f*1e3,c(b=>({...b,isRunning:!0}))):l.current=null},[e,d]),p=m.useCallback(()=>{if(l.current&&i.isRunning){const v=(Date.now()-l.current)/1e3+g.current,b=v/60%1*100;d.setTarget([b]),c(C=>({...C,elapsedTime:Math.floor(v)}))}c(f=>({...f,isRunning:!1,isPausedState:!0})),n()},[i.isRunning,d,n]),y=m.useCallback(()=>{i.isPausedState&&(g.current=i.elapsedTime,l.current=Date.now(),c(f=>({...f,isRunning:!0,isPausedState:!1})))},[i.isPausedState,i.elapsedTime]),S=m.useCallback(()=>{c(f=>({...f,elapsedTime:0,isRunning:!1,isPausedState:!1,currentProgress:0})),g.current=0,l.current=null,h.current=0,d.setImmediate([0])},[d]),x=m.useCallback(()=>i.isPausedState,[i.isPausedState]);return m.useEffect(()=>{t?(i.isRunning&&(c(f=>({...f,wasRunningBeforeError:!0})),p()),a()):(i.wasRunningBeforeError&&!i.isRunning&&(c(f=>({...f,wasRunningBeforeError:!1})),y()),r())},[t,i.isRunning,i.wasRunningBeforeError,p,y,a,r]),m.useEffect(()=>{if(i.isRunning){const f=()=>{if(l.current){const b=(Date.now()-l.current)/1e3+g.current,C=b/60%1*100;c(w=>({...w,elapsedTime:Math.floor(b)})),Math.abs(C-h.current)>.1&&(d.setTarget([C]),h.current=C)}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,d]),m.useEffect(()=>{let f=null;const v=()=>{d.update(),f=requestAnimationFrame(v)};return f=requestAnimationFrame(v),()=>{f&&cancelAnimationFrame(f)}},[d]),{timerState:i,controls:{start:u,pause:p,resume:y,reset:S,isPaused:x}}},Sn=B.externalizeComponent(D.observer(({onTimerReady:e,autoStart:t=!0,variant:n="default",compact:a=!1,className:r,hasError:i=!1})=>{const{animationState:c,triggerPauseAnimation:s,triggerErrorAnimation:l,clearErrorAnimation:g,setInitialAnimationState:h,cleanup:d}=bn(),{timerState:u,controls:p}=yn({autoStart:t,hasError:i,onPauseAnimation:s,onErrorAnimation:l,onClearErrorAnimation:g});return m.useEffect(()=>{h()},[h]),m.useEffect(()=>{let y=!0;const S=setTimeout(()=>{y&&e(p)},0);return()=>{y=!1,clearTimeout(S)}},[e,p]),m.useEffect(()=>d,[d]),n==="small"?o.jsx(xn,{timerState:u,animationState:c,hasError:i,compact:a,className:r}):o.jsx(fn,{timerState:u,animationState:c,hasError:i,className:r})})),Re=1e-4,vn={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class oe{constructor(t,n,a,r,i,c,s,l,g,h){this.nova=t,this.controller=n,this.motionGroup=a,this.initialMotionState=r,this.motionStateSocket=i,this.isVirtual=c,this.tcps=s,this.description=l,this.initialControllerState=g,this.controllerStateSocket=h,this.connectedJoggingSocket=null,this.joggingVelocity=10,this.activationState="inactive",this.rapidlyChangingMotionState=r,this.controllerState=g,h.addEventListener("message",d=>{var p;const u=(p=J.tryParseJson(d.data))==null?void 0:p.result;u&&_.runInAction(()=>{this.controllerState=u})}),i.addEventListener("message",d=>{var p;const u=(p=J.tryParseJson(d.data))==null?void 0:p.result;if(!u)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${d.data}`);ge(this.rapidlyChangingMotionState.joint_position,u.joint_position,Re)||_.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=u.joint_position}),pe(this.rapidlyChangingMotionState,u,Re)||_.runInAction(()=>{this.rapidlyChangingMotionState.tcp_pose=u.tcp_pose}),this.rapidlyChangingMotionState.standstill!==u.standstill&&_.runInAction(()=>{this.rapidlyChangingMotionState.standstill=u.standstill})}),_.makeAutoObservable(this)}static async connectMultiple(t,n){return Promise.all(n.map(a=>oe.connect(t,a)))}static async connect(t,n){var f,v;const[a,r]=n.split("@"),i=await t.api.controller.getCurrentRobotControllerState(r),c=i==null?void 0:i.motion_groups.find(b=>b.motion_group===n);if(!i||!c)throw new Error(`Controller ${r} or motion group ${n} not found`);const s=t.openReconnectingWebsocket(`/controllers/${r}/motion-groups/${n}/state-stream`),l=await s.firstMessage(),g=(f=J.tryParseJson(l.data))==null?void 0:f.result;if(!g)throw new Error(`Unable to parse initial motion state message ${l.data}`);console.log(`Connected motion state websocket to motion group ${c.motion_group}. Initial state:
|
|
3
3
|
`,g);const d=(await t.api.controller.getRobotController(i.controller)).configuration.kind==="VirtualController",u=await t.api.motionGroup.getMotionGroupDescription(r,c.motion_group),p=Object.entries(u.tcps||{}).map(([b,C])=>({id:b,readable_name:C.name,position:C.pose.position,orientation:C.pose.orientation})),y=t.openReconnectingWebsocket(`/controllers/${i.controller}/state-stream?response_rate=1000`),S=await y.firstMessage(),x=(v=J.tryParseJson(S.data))==null?void 0:v.result;if(!x)throw new Error(`Unable to parse initial controller state message ${S.data}`);return console.log(`Connected controller state websocket to controller ${i.controller}. Initial state:
|
|
4
4
|
`,x),new oe(t,i,c,g,s,d,p,u,x,y)}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((t,n)=>({index:n}))}get dhParameters(){if(this.description.dh_parameters!==void 0)return this.description.dh_parameters.map(t=>({...vn,...t}))}get safetyZones(){return this.description.safety_zones}get mountingPosition(){var t,n,a;return this.description.mounting?[(((t=this.description.mounting.position)==null?void 0:t[0])||0)/1e3,(((n=this.description.mounting.position)==null?void 0:n[1])||0)/1e3,(((a=this.description.mounting.position)==null?void 0:a[2])||0)/1e3]:[0,0,0]}get mountingQuaternion(){var r,i,c,s,l,g;const t=new we.Vector3(((i=(r=this.description.mounting)==null?void 0:r.orientation)==null?void 0:i[0])||0,((s=(c=this.description.mounting)==null?void 0:c.orientation)==null?void 0:s[1])||0,((g=(l=this.description.mounting)==null?void 0:l.orientation)==null?void 0:g[2])||0),n=t.length(),a=t.normalize();return new we.Quaternion().setFromAxisAngle(a,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}_.runInAction(()=>{this.activationState="deactivating"});try{await this.nova.api.controller.setDefaultMode(this.controllerId,"ROBOT_SYSTEM_MODE_MONITOR"),_.runInAction(()=>{this.activationState="inactive"})}catch(t){throw _.runInAction(()=>{this.activationState="active"}),t}}async activate(){if(this.activationState!=="inactive"){console.error("Tried to activate while already activating");return}_.runInAction(()=>{this.activationState="activating"});try{await this.nova.api.controller.setDefaultMode(this.controllerId,"ROBOT_SYSTEM_MODE_CONTROL"),_.runInAction(()=>{this.activationState="active"})}catch(t){throw _.runInAction(()=>{this.activationState="inactive"}),t}}toggleActivation(){this.activationState==="inactive"?this.activate():this.activationState==="active"&&this.deactivate()}dispose(){this.motionStateSocket.close(),this.connectedJoggingSocket&&this.connectedJoggingSocket.close()}setJoggingVelocity(t){this.joggingVelocity=t}}function Ue(){var t,n,a,r,i,c;const e=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{...e,components:{MuiCssBaseline:{styleOverrides:{"html, body, *":{scrollbarWidth:"none",msOverflowStyle:"none"},"html:hover, body:hover, *:hover":{scrollbarWidth:"thin",scrollbarColor:`${e.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 ${e.palette.divider}`,background:(a=(n=(t=e.paletteExt)==null?void 0:t.secondary)==null?void 0:n.tonal)==null?void 0:a.toString()}},{props:{color:"secondary",variant:"outlined"},style:{border:`1px solid ${e.palette.divider}`}}]},MuiTab:{styleOverrides:{root:{textTransform:"none",color:e.palette.text.secondary,"&.Mui-selected":{color:e.palette.text.primary}}}},MuiTabs:{styleOverrides:{root:{background:(r=e.palette.backgroundPaperElevation)==null?void 0:r[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=e.paletteExt)==null?void 0:i.secondary)==null?void 0:c.tonal}},variants:[{props:{color:"primary"},style:{background:e.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:e.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:e.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:e.palette.text.primary}}},JoggingJoint:{Joint:{arrowColor:e.palette.text.primary}},VelocitySlider:{sliderLegendColor:e.palette.text.primary}}}}}function jn(){const e=Ue();return e.palette.mode="light",e}function Cn(e){var a,r,i,c;let t=!0;((a=e.palette)==null?void 0:a.mode)==="light"?t=!1:((r=e.palette)==null?void 0:r.mode)!=="dark"&&(t=!(typeof window<"u"&&((c=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: light)"))==null?void 0:c.matches)));const n=t?Ue():jn();return A.createTheme(n,e)}exports.AppHeader=Dt;exports.ConnectedMotionGroup=oe;exports.CycleTimer=Vt;exports.JoggerConnection=re;exports.JoggingCartesianAxisControl=ce;exports.JoggingJointValueControl=De;exports.JoggingPanel=Xt;exports.JoggingStore=ae;exports.LoadingCover=Fe;exports.LoadingErrorMessage=Le;exports.LogPanel=an;exports.LogStore=Ne;exports.LogViewer=We;exports.MotionStreamConnection=ie;exports.NoMotionGroupModal=ln;exports.PoseCartesianValues=Kt;exports.PoseJointValues=en;exports.RobotListItem=cn;exports.RobotSetupReadinessIndicator=Ge;exports.RobotSetupReadinessState=he;exports.SelectableFab=un;exports.TabBar=mn;exports.Timer=Sn;exports.VelocitySlider=$e;exports.VelocitySliderLabel=me;exports.WandelbotsDataGrid=Ae;exports.createDebugMessage=tn;exports.createErrorMessage=rn;exports.createInfoMessage=nn;exports.createLogMessage=K;exports.createNovaMuiTheme=Cn;exports.createWarningMessage=on;exports.jointValuesEqual=ge;exports.poseEqual=Je;exports.tcpMotionEqual=pe;exports.unwrapRotationVector=Be;
|
|
@@ -28,7 +28,7 @@ import $t from "@mui/material/Tab";
|
|
|
28
28
|
import zt from "@mui/material/Tabs";
|
|
29
29
|
import { JointTypeEnum as G, NovaClient as be, poseToWandelscriptString as xe } from "@wandelbots/nova-js/v2";
|
|
30
30
|
import { lowerFirst as ye, countBy as Se, isString as ve } from "lodash-es";
|
|
31
|
-
import { runInAction as L, makeAutoObservable as mt, when as lt, autorun as
|
|
31
|
+
import { runInAction as L, makeAutoObservable as mt, when as lt, autorun as we, makeObservable as Ce, action as kt, observable as Te } from "mobx";
|
|
32
32
|
import { radiansToDegrees as Vt, tryParseJson as W, XYZ_TO_VECTOR as tt, degreesToRadians as Me } from "@wandelbots/nova-js";
|
|
33
33
|
import { Vector3 as ct } from "three/src/math/Vector3.js";
|
|
34
34
|
import Ie from "@mui/material/CircularProgress";
|
|
@@ -663,19 +663,19 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
663
663
|
}, []), d = _(() => {
|
|
664
664
|
e((b) => ({ ...b, showErrorAnimation: !1 })), r.current && clearTimeout(r.current);
|
|
665
665
|
}, []), u = _((b) => {
|
|
666
|
-
c.current = 0, e((
|
|
667
|
-
...
|
|
666
|
+
c.current = 0, e((C) => ({
|
|
667
|
+
...C,
|
|
668
668
|
showPulsatingText: !0,
|
|
669
669
|
pulsatingFinished: !1
|
|
670
670
|
})), setTimeout(() => {
|
|
671
|
-
e((
|
|
672
|
-
...
|
|
671
|
+
e((C) => ({
|
|
672
|
+
...C,
|
|
673
673
|
pulsatingFinished: !0
|
|
674
674
|
// This will keep the success color and start slow pulsating
|
|
675
675
|
})), i.current = setInterval(() => {
|
|
676
|
-
e((
|
|
677
|
-
...
|
|
678
|
-
showPulsatingText: !
|
|
676
|
+
e((C) => ({
|
|
677
|
+
...C,
|
|
678
|
+
showPulsatingText: !C.showPulsatingText
|
|
679
679
|
}));
|
|
680
680
|
}, 2e3), b && b();
|
|
681
681
|
}, 800);
|
|
@@ -762,12 +762,12 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
762
762
|
}), m = D(null), d = D(null), u = D(0), [p] = Lt([0], {
|
|
763
763
|
tension: 80,
|
|
764
764
|
friction: 18,
|
|
765
|
-
onChange: ([
|
|
766
|
-
g((M) => ({ ...M, currentProgress:
|
|
765
|
+
onChange: ([w]) => {
|
|
766
|
+
g((M) => ({ ...M, currentProgress: w }));
|
|
767
767
|
}
|
|
768
768
|
}), x = _(() => {
|
|
769
|
-
g((
|
|
770
|
-
...
|
|
769
|
+
g((w) => ({
|
|
770
|
+
...w,
|
|
771
771
|
currentState: "idle",
|
|
772
772
|
maxTime: null,
|
|
773
773
|
// Don't reset remainingTime - keep the last value
|
|
@@ -777,28 +777,28 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
777
777
|
// Reset progress to 0 for gauge
|
|
778
778
|
})), u.current = 0, d.current = null, p.setImmediate([0]);
|
|
779
779
|
}, [p]), y = _(
|
|
780
|
-
(
|
|
781
|
-
const M =
|
|
780
|
+
(w = 0) => {
|
|
781
|
+
const M = w / 60 % 1 * 100;
|
|
782
782
|
g((k) => ({
|
|
783
783
|
...k,
|
|
784
784
|
currentState: "measuring",
|
|
785
785
|
maxTime: null,
|
|
786
|
-
remainingTime:
|
|
786
|
+
remainingTime: w,
|
|
787
787
|
isPausedState: !1,
|
|
788
788
|
currentProgress: M
|
|
789
789
|
// Immediately set progress
|
|
790
|
-
})), u.current = 0, p.setImmediate([M]), t ? (d.current = Date.now() -
|
|
790
|
+
})), u.current = 0, p.setImmediate([M]), t ? (d.current = Date.now() - w * 1e3, g((k) => ({ ...k, isRunning: !0 }))) : d.current = null;
|
|
791
791
|
},
|
|
792
792
|
[t, p]
|
|
793
793
|
), f = _(
|
|
794
|
-
(
|
|
794
|
+
(w, M = 0) => {
|
|
795
795
|
g((I) => ({ ...I, isRunning: !1 })), d.current = null, g((I) => ({
|
|
796
796
|
...I,
|
|
797
797
|
currentState: "countdown",
|
|
798
|
-
maxTime:
|
|
798
|
+
maxTime: w,
|
|
799
799
|
isPausedState: !1
|
|
800
800
|
})), u.current = 0;
|
|
801
|
-
const k = Math.max(0,
|
|
801
|
+
const k = Math.max(0, w - M), R = M > 0 ? M / w * 100 : 0;
|
|
802
802
|
g((I) => ({
|
|
803
803
|
...I,
|
|
804
804
|
remainingTime: k,
|
|
@@ -810,8 +810,8 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
810
810
|
},
|
|
811
811
|
[t, e, p]
|
|
812
812
|
), h = _(() => {
|
|
813
|
-
g((
|
|
814
|
-
...
|
|
813
|
+
g((w) => ({
|
|
814
|
+
...w,
|
|
815
815
|
isRunning: !1,
|
|
816
816
|
currentState: "measured"
|
|
817
817
|
})), d.current = null, s(() => {
|
|
@@ -828,8 +828,8 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
828
828
|
);
|
|
829
829
|
p.setTarget([R]);
|
|
830
830
|
}
|
|
831
|
-
g((
|
|
832
|
-
...
|
|
831
|
+
g((w) => ({
|
|
832
|
+
...w,
|
|
833
833
|
isRunning: !1,
|
|
834
834
|
isPausedState: !0
|
|
835
835
|
})), i();
|
|
@@ -840,8 +840,8 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
840
840
|
p,
|
|
841
841
|
i
|
|
842
842
|
]), b = _(() => {
|
|
843
|
-
l.isPausedState && (l.remainingTime > 0 || l.currentState !== "countdown") && (d.current = Date.now(), g((
|
|
844
|
-
...
|
|
843
|
+
l.isPausedState && (l.remainingTime > 0 || l.currentState !== "countdown") && (d.current = Date.now(), g((w) => ({
|
|
844
|
+
...w,
|
|
845
845
|
isRunning: !0,
|
|
846
846
|
isPausedState: !1
|
|
847
847
|
})));
|
|
@@ -849,9 +849,9 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
849
849
|
l.isPausedState,
|
|
850
850
|
l.remainingTime,
|
|
851
851
|
l.currentState
|
|
852
|
-
]),
|
|
852
|
+
]), C = _(() => l.isPausedState, [l.isPausedState]);
|
|
853
853
|
return A(() => {
|
|
854
|
-
r ? (l.isRunning && !l.isPausedState && (g((
|
|
854
|
+
r ? (l.isRunning && !l.isPausedState && (g((w) => ({ ...w, wasRunningBeforeError: !0 })), v()), n()) : (l.wasRunningBeforeError && l.isPausedState && (g((w) => ({ ...w, wasRunningBeforeError: !1 })), b()), c());
|
|
855
855
|
}, [
|
|
856
856
|
r,
|
|
857
857
|
l.isRunning,
|
|
@@ -863,7 +863,7 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
863
863
|
c
|
|
864
864
|
]), A(() => {
|
|
865
865
|
if (l.isRunning) {
|
|
866
|
-
const
|
|
866
|
+
const w = () => {
|
|
867
867
|
if (d.current) {
|
|
868
868
|
const k = (Date.now() - d.current + u.current) / 1e3;
|
|
869
869
|
if (l.currentState === "countdown" && l.maxTime !== null) {
|
|
@@ -889,10 +889,10 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
889
889
|
const R = k / 60 % 1 * 100;
|
|
890
890
|
p.setTarget([R]);
|
|
891
891
|
}
|
|
892
|
-
l.isRunning && (m.current = requestAnimationFrame(
|
|
892
|
+
l.isRunning && (m.current = requestAnimationFrame(w));
|
|
893
893
|
}
|
|
894
894
|
};
|
|
895
|
-
m.current = requestAnimationFrame(
|
|
895
|
+
m.current = requestAnimationFrame(w);
|
|
896
896
|
} else
|
|
897
897
|
m.current && (cancelAnimationFrame(m.current), m.current = null);
|
|
898
898
|
return () => {
|
|
@@ -905,12 +905,12 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
905
905
|
l.maxTime,
|
|
906
906
|
p
|
|
907
907
|
]), A(() => {
|
|
908
|
-
let
|
|
908
|
+
let w = null;
|
|
909
909
|
const M = () => {
|
|
910
|
-
p.update(1 / 60),
|
|
910
|
+
p.update(1 / 60), w = requestAnimationFrame(M);
|
|
911
911
|
};
|
|
912
|
-
return
|
|
913
|
-
|
|
912
|
+
return w = requestAnimationFrame(M), () => {
|
|
913
|
+
w && cancelAnimationFrame(w);
|
|
914
914
|
};
|
|
915
915
|
}, [p]), {
|
|
916
916
|
timerState: l,
|
|
@@ -921,7 +921,7 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
921
921
|
completeMeasuring: h,
|
|
922
922
|
pause: v,
|
|
923
923
|
resume: b,
|
|
924
|
-
isPaused:
|
|
924
|
+
isPaused: C
|
|
925
925
|
}
|
|
926
926
|
};
|
|
927
927
|
}, di = $(
|
|
@@ -948,7 +948,7 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
948
948
|
triggerFadeTransition: h,
|
|
949
949
|
setInitialAnimationState: v,
|
|
950
950
|
cleanup: b
|
|
951
|
-
} = ho(), { timerState:
|
|
951
|
+
} = ho(), { timerState: C, controls: w } = fo({
|
|
952
952
|
autoStart: r,
|
|
953
953
|
onCycleEnd: e,
|
|
954
954
|
onMeasuringComplete: o,
|
|
@@ -960,9 +960,9 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
960
960
|
});
|
|
961
961
|
return A(() => {
|
|
962
962
|
const M = l.current;
|
|
963
|
-
l.current !== void 0 && M !==
|
|
963
|
+
l.current !== void 0 && M !== C.currentState ? (M === "measured" && x(), M === "idle" && f(), h()) : v(), C.currentState === "idle" && y(), l.current = C.currentState;
|
|
964
964
|
}, [
|
|
965
|
-
|
|
965
|
+
C.currentState,
|
|
966
966
|
x,
|
|
967
967
|
f,
|
|
968
968
|
y,
|
|
@@ -971,15 +971,15 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
971
971
|
]), A(() => {
|
|
972
972
|
let M = !0;
|
|
973
973
|
const k = setTimeout(() => {
|
|
974
|
-
M && t(
|
|
974
|
+
M && t(w);
|
|
975
975
|
}, 0);
|
|
976
976
|
return () => {
|
|
977
977
|
M = !1, clearTimeout(k);
|
|
978
978
|
};
|
|
979
|
-
}, [t,
|
|
979
|
+
}, [t, w]), A(() => b, [b]), i === "small" ? /* @__PURE__ */ a(
|
|
980
980
|
mo,
|
|
981
981
|
{
|
|
982
|
-
timerState:
|
|
982
|
+
timerState: C,
|
|
983
983
|
animationState: g,
|
|
984
984
|
hasError: s,
|
|
985
985
|
compact: n,
|
|
@@ -988,7 +988,7 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
988
988
|
) : /* @__PURE__ */ a(
|
|
989
989
|
po,
|
|
990
990
|
{
|
|
991
|
-
timerState:
|
|
991
|
+
timerState: C,
|
|
992
992
|
animationState: g,
|
|
993
993
|
hasError: s,
|
|
994
994
|
className: c
|
|
@@ -1048,10 +1048,10 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
1048
1048
|
return h(I), I;
|
|
1049
1049
|
}
|
|
1050
1050
|
return null;
|
|
1051
|
-
}, [d, t, i, f]),
|
|
1051
|
+
}, [d, t, i, f]), C = (I) => {
|
|
1052
1052
|
const j = t.find((z) => o(z).id === I.id);
|
|
1053
1053
|
j && (i === void 0 && h(j), r && r(j, I));
|
|
1054
|
-
},
|
|
1054
|
+
}, w = rt(() => !b || !n ? null : n(b), [b, n]);
|
|
1055
1055
|
function M() {
|
|
1056
1056
|
return /* @__PURE__ */ a(ce, { children: /* @__PURE__ */ S(
|
|
1057
1057
|
T,
|
|
@@ -1331,7 +1331,7 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
1331
1331
|
apiRef: x,
|
|
1332
1332
|
rows: v,
|
|
1333
1333
|
columns: e,
|
|
1334
|
-
onRowClick:
|
|
1334
|
+
onRowClick: C,
|
|
1335
1335
|
disableColumnMenu: !1,
|
|
1336
1336
|
disableRowSelectionOnClick: !0,
|
|
1337
1337
|
disableMultipleRowSelection: !0,
|
|
@@ -1416,8 +1416,8 @@ const co = (t) => /* @__PURE__ */ a(oe, { ...t, viewBox: "0 0 10 8", children: /
|
|
|
1416
1416
|
}
|
|
1417
1417
|
},
|
|
1418
1418
|
// Highlight selected row with a distinct color using data attribute
|
|
1419
|
-
...
|
|
1420
|
-
[`&[data-id="${
|
|
1419
|
+
...w !== null && {
|
|
1420
|
+
[`&[data-id="${w}"]`]: {
|
|
1421
1421
|
backgroundColor: "transparent !important",
|
|
1422
1422
|
"&::before": {
|
|
1423
1423
|
content: '""',
|
|
@@ -1526,7 +1526,7 @@ const _t = $(
|
|
|
1526
1526
|
activeJoggingDirection: c,
|
|
1527
1527
|
...s
|
|
1528
1528
|
}) => {
|
|
1529
|
-
var b,
|
|
1529
|
+
var b, C, w, M, k, R, I;
|
|
1530
1530
|
pt(() => {
|
|
1531
1531
|
const j = o(), z = u.current;
|
|
1532
1532
|
z && (z.textContent = j);
|
|
@@ -1559,9 +1559,9 @@ const _t = $(
|
|
|
1559
1559
|
}
|
|
1560
1560
|
}, y = {
|
|
1561
1561
|
...x,
|
|
1562
|
-
backgroundColor: (
|
|
1562
|
+
backgroundColor: (C = t.buttonBackgroundColor) == null ? void 0 : C.default,
|
|
1563
1563
|
":hover": {
|
|
1564
|
-
backgroundColor: (
|
|
1564
|
+
backgroundColor: (w = t.buttonBackgroundColor) == null ? void 0 : w.hovered
|
|
1565
1565
|
},
|
|
1566
1566
|
":active": {
|
|
1567
1567
|
backgroundColor: (M = t.buttonBackgroundColor) == null ? void 0 : M.pressed,
|
|
@@ -1695,7 +1695,7 @@ const _t = $(
|
|
|
1695
1695
|
disabled: c,
|
|
1696
1696
|
...s
|
|
1697
1697
|
}) => {
|
|
1698
|
-
var M, k, R, I, j, z, Q, ot, xt, yt, St, vt,
|
|
1698
|
+
var M, k, R, I, j, z, Q, ot, xt, yt, St, vt, wt, Ct, Tt;
|
|
1699
1699
|
const { t: l } = V(), [g, m] = B(), d = F(), u = {
|
|
1700
1700
|
background: (M = d.palette.backgroundPaperElevation) == null ? void 0 : M[4],
|
|
1701
1701
|
color: (k = d.palette.backgroundPaperElevation) == null ? void 0 : k[11]
|
|
@@ -1728,14 +1728,14 @@ const _t = $(
|
|
|
1728
1728
|
function b(O) {
|
|
1729
1729
|
p.stopJogging();
|
|
1730
1730
|
}
|
|
1731
|
-
function
|
|
1731
|
+
function C(O, X = 1) {
|
|
1732
1732
|
if (O === void 0 || Number.isNaN(O)) return "";
|
|
1733
1733
|
const K = l("General.degree.variable", {
|
|
1734
1734
|
amount: O.toFixed(X)
|
|
1735
1735
|
});
|
|
1736
1736
|
return O > 0 && X === 0 ? `+${K}` : K;
|
|
1737
1737
|
}
|
|
1738
|
-
function
|
|
1738
|
+
function w(O, X = 1) {
|
|
1739
1739
|
if (O === void 0 || Number.isNaN(O)) return "";
|
|
1740
1740
|
const K = l("General.mm.variable", {
|
|
1741
1741
|
amount: O.toFixed(X)
|
|
@@ -1827,7 +1827,7 @@ const _t = $(
|
|
|
1827
1827
|
textAlign: "center",
|
|
1828
1828
|
color: c ? d.palette.action.disabled : d.palette.text.primary
|
|
1829
1829
|
},
|
|
1830
|
-
children: i ?
|
|
1830
|
+
children: i ? C(g) : w(g)
|
|
1831
1831
|
}
|
|
1832
1832
|
),
|
|
1833
1833
|
/* @__PURE__ */ a(
|
|
@@ -1862,11 +1862,11 @@ const _t = $(
|
|
|
1862
1862
|
marks: o !== void 0 && r !== void 0 && [
|
|
1863
1863
|
{
|
|
1864
1864
|
value: i ? y(o) : o,
|
|
1865
|
-
label: i ?
|
|
1865
|
+
label: i ? C(y(o), 0) : w(o)
|
|
1866
1866
|
},
|
|
1867
1867
|
{
|
|
1868
1868
|
value: i ? y(r) : r,
|
|
1869
|
-
label: i ?
|
|
1869
|
+
label: i ? C(y(r), 0) : w(r)
|
|
1870
1870
|
}
|
|
1871
1871
|
]
|
|
1872
1872
|
}
|
|
@@ -1891,7 +1891,7 @@ const _t = $(
|
|
|
1891
1891
|
{
|
|
1892
1892
|
sx: {
|
|
1893
1893
|
pointerEvents: "none",
|
|
1894
|
-
color: (Tt = (
|
|
1894
|
+
color: (Tt = (Ct = (wt = (vt = d.componentsExt) == null ? void 0 : vt.JoggingPanel) == null ? void 0 : wt.JoggingJoint) == null ? void 0 : Ct.Joint) == null ? void 0 : Tt.arrowColor
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
)
|
|
@@ -2247,11 +2247,11 @@ class ft {
|
|
|
2247
2247
|
e.orientation[0],
|
|
2248
2248
|
e.orientation[1],
|
|
2249
2249
|
e.orientation[2]
|
|
2250
|
-
), h = f.length(), v = f.clone().normalize(), b = c.distanceRads * (n === "-" ? -1 : 1),
|
|
2251
|
-
|
|
2252
|
-
const
|
|
2250
|
+
), h = f.length(), v = f.clone().normalize(), b = c.distanceRads * (n === "-" ? -1 : 1), C = new ct(0, 0, 0);
|
|
2251
|
+
C[i] = 1;
|
|
2252
|
+
const w = Math.cos(0.5 * b) * Math.cos(0.5 * h), M = Math.sin(0.5 * b) * Math.sin(0.5 * h), k = Math.sin(0.5 * b) * Math.cos(0.5 * h), R = Math.cos(0.5 * b) * Math.sin(0.5 * h), I = C.dot(
|
|
2253
2253
|
v
|
|
2254
|
-
), j =
|
|
2254
|
+
), j = C.clone().cross(v), z = 2 * Math.acos(w - M * I), Q = z / Math.sin(0.5 * z), ot = new ct().addScaledVector(j, M).addScaledVector(C, k).addScaledVector(v, R).multiplyScalar(Q);
|
|
2255
2255
|
s.push({
|
|
2256
2256
|
limits_override: {
|
|
2257
2257
|
tcp_orientation_velocity_limit: r
|
|
@@ -2379,7 +2379,7 @@ const vo = (t) => {
|
|
|
2379
2379
|
justifyContent: "center",
|
|
2380
2380
|
sx: { color: i.palette.text.primary },
|
|
2381
2381
|
children: t.error ? /* @__PURE__ */ a(
|
|
2382
|
-
|
|
2382
|
+
wo,
|
|
2383
2383
|
{
|
|
2384
2384
|
loadingMessage: t.message,
|
|
2385
2385
|
error: t.error
|
|
@@ -2401,7 +2401,7 @@ const vo = (t) => {
|
|
|
2401
2401
|
] })
|
|
2402
2402
|
}
|
|
2403
2403
|
);
|
|
2404
|
-
},
|
|
2404
|
+
}, wo = (t) => {
|
|
2405
2405
|
const e = Re(t.error), o = t.error instanceof Error ? t.error.stack : null, r = F();
|
|
2406
2406
|
return /* @__PURE__ */ S(
|
|
2407
2407
|
P,
|
|
@@ -2425,7 +2425,7 @@ const vo = (t) => {
|
|
|
2425
2425
|
]
|
|
2426
2426
|
}
|
|
2427
2427
|
);
|
|
2428
|
-
},
|
|
2428
|
+
}, Co = J(({ store: t }) => {
|
|
2429
2429
|
const { t: e } = V();
|
|
2430
2430
|
return /* @__PURE__ */ a(
|
|
2431
2431
|
Bt,
|
|
@@ -2534,7 +2534,7 @@ class bt {
|
|
|
2534
2534
|
}
|
|
2535
2535
|
this.selectedCoordSystemId = ((c = o[0]) == null ? void 0 : c.coordinate_system) || "world", this.selectedTcpId = ((s = i[0]) == null ? void 0 : s.id) || "", this.inverseSolver = n, this.jointType = ((g = (l = r == null ? void 0 : r.dh_parameters) == null ? void 0 : l[0]) == null ? void 0 : g.type) ?? G.RevoluteJoint, mt(this, {}, { autoBind: !0 }), this.jogger.onBlocked = () => {
|
|
2536
2536
|
this.block();
|
|
2537
|
-
}, this.loadFromLocalStorage(), this.disposers.push(
|
|
2537
|
+
}, this.loadFromLocalStorage(), this.disposers.push(we(() => this.saveToLocalStorage())), window.joggingStore = this;
|
|
2538
2538
|
}
|
|
2539
2539
|
/**
|
|
2540
2540
|
* Load a jogging store with the relevant data it needs
|
|
@@ -2577,8 +2577,7 @@ class bt {
|
|
|
2577
2577
|
return Se(this.coordSystems, (e) => e.name);
|
|
2578
2578
|
}
|
|
2579
2579
|
async deactivate() {
|
|
2580
|
-
|
|
2581
|
-
return this.jogger.stop();
|
|
2580
|
+
this.jogger.mode === "jogging" && await this.jogger.setJoggingMode("off");
|
|
2582
2581
|
}
|
|
2583
2582
|
/** Activate the jogger with current settings */
|
|
2584
2583
|
async activate() {
|
|
@@ -3396,7 +3395,7 @@ const qt = J(
|
|
|
3396
3395
|
children: r()
|
|
3397
3396
|
}
|
|
3398
3397
|
),
|
|
3399
|
-
t.blocked && /* @__PURE__ */ a(
|
|
3398
|
+
t.blocked && /* @__PURE__ */ a(Co, { store: t })
|
|
3400
3399
|
] });
|
|
3401
3400
|
}
|
|
3402
3401
|
), Yt = (t) => {
|
|
@@ -3547,7 +3546,7 @@ class Oo {
|
|
|
3547
3546
|
this.addMessage(e, "error");
|
|
3548
3547
|
}, this.addDebug = (e) => {
|
|
3549
3548
|
this.addMessage(e, "debug");
|
|
3550
|
-
},
|
|
3549
|
+
}, Ce(this, {
|
|
3551
3550
|
messages: Te,
|
|
3552
3551
|
addMessage: kt,
|
|
3553
3552
|
clearMessages: kt
|
|
@@ -3594,10 +3593,10 @@ const at = (t, e, o) => ({
|
|
|
3594
3593
|
const [u, p] = B(!1), [x, y] = B(!1), [f, h] = B(!1), v = d.message.length > 150, b = async () => {
|
|
3595
3594
|
try {
|
|
3596
3595
|
await navigator.clipboard.writeText(d.message), y(!0), setTimeout(() => y(!1), 2e3);
|
|
3597
|
-
} catch (
|
|
3598
|
-
console.error("Failed to copy message:",
|
|
3596
|
+
} catch (w) {
|
|
3597
|
+
console.error("Failed to copy message:", w);
|
|
3599
3598
|
}
|
|
3600
|
-
},
|
|
3599
|
+
}, C = v && !u ? `${d.message.substring(0, 150)}...` : d.message;
|
|
3601
3600
|
return /* @__PURE__ */ a(
|
|
3602
3601
|
T,
|
|
3603
3602
|
{
|
|
@@ -3652,7 +3651,7 @@ const at = (t, e, o) => ({
|
|
|
3652
3651
|
flex: 1,
|
|
3653
3652
|
whiteSpace: "pre-wrap"
|
|
3654
3653
|
},
|
|
3655
|
-
children:
|
|
3654
|
+
children: C
|
|
3656
3655
|
}
|
|
3657
3656
|
),
|
|
3658
3657
|
/* @__PURE__ */ S(
|
|
@@ -4215,7 +4214,7 @@ function Lo({ children: t, ...e }) {
|
|
|
4215
4214
|
} = e;
|
|
4216
4215
|
return /* @__PURE__ */ a(T, { ...d, children: t });
|
|
4217
4216
|
}
|
|
4218
|
-
const
|
|
4217
|
+
const wi = $(
|
|
4219
4218
|
J((t) => {
|
|
4220
4219
|
const {
|
|
4221
4220
|
items: e,
|
|
@@ -4280,7 +4279,7 @@ const Ci = $(
|
|
|
4280
4279
|
}
|
|
4281
4280
|
},
|
|
4282
4281
|
children: e.map((u, p) => {
|
|
4283
|
-
var
|
|
4282
|
+
var C, w, M;
|
|
4284
4283
|
const x = () => {
|
|
4285
4284
|
if (!u.badge) return;
|
|
4286
4285
|
const k = u.badge.content, R = u.badge.max;
|
|
@@ -4344,8 +4343,8 @@ const Ci = $(
|
|
|
4344
4343
|
so,
|
|
4345
4344
|
{
|
|
4346
4345
|
badgeContent: f,
|
|
4347
|
-
color: ((
|
|
4348
|
-
max: (
|
|
4346
|
+
color: ((C = u.badge) == null ? void 0 : C.color) || "error",
|
|
4347
|
+
max: (w = u.badge) == null ? void 0 : w.max,
|
|
4349
4348
|
showZero: (M = u.badge) == null ? void 0 : M.showZero,
|
|
4350
4349
|
anchorOrigin: {
|
|
4351
4350
|
vertical: "top",
|
|
@@ -4716,8 +4715,8 @@ const Ci = $(
|
|
|
4716
4715
|
), p = _(() => {
|
|
4717
4716
|
if (l.current && n.isRunning) {
|
|
4718
4717
|
const v = (Date.now() - l.current) / 1e3 + g.current, b = v / 60 % 1 * 100;
|
|
4719
|
-
d.setTarget([b]), c((
|
|
4720
|
-
...
|
|
4718
|
+
d.setTarget([b]), c((C) => ({
|
|
4719
|
+
...C,
|
|
4721
4720
|
elapsedTime: Math.floor(v)
|
|
4722
4721
|
}));
|
|
4723
4722
|
}
|
|
@@ -4755,13 +4754,13 @@ const Ci = $(
|
|
|
4755
4754
|
if (n.isRunning) {
|
|
4756
4755
|
const h = () => {
|
|
4757
4756
|
if (l.current) {
|
|
4758
|
-
const b = (Date.now() - l.current) / 1e3 + g.current,
|
|
4757
|
+
const b = (Date.now() - l.current) / 1e3 + g.current, C = b / 60 % 1 * 100;
|
|
4759
4758
|
c((M) => ({
|
|
4760
4759
|
...M,
|
|
4761
4760
|
elapsedTime: Math.floor(b)
|
|
4762
4761
|
})), Math.abs(
|
|
4763
|
-
|
|
4764
|
-
) > 0.1 && (d.setTarget([
|
|
4762
|
+
C - m.current
|
|
4763
|
+
) > 0.1 && (d.setTarget([C]), m.current = C);
|
|
4765
4764
|
}
|
|
4766
4765
|
s.current = requestAnimationFrame(h);
|
|
4767
4766
|
};
|
|
@@ -4789,7 +4788,7 @@ const Ci = $(
|
|
|
4789
4788
|
isPaused: f
|
|
4790
4789
|
}
|
|
4791
4790
|
};
|
|
4792
|
-
},
|
|
4791
|
+
}, Ci = $(
|
|
4793
4792
|
J(
|
|
4794
4793
|
({
|
|
4795
4794
|
onTimerReady: t,
|
|
@@ -4916,11 +4915,11 @@ class ut {
|
|
|
4916
4915
|
i,
|
|
4917
4916
|
c.motion_group
|
|
4918
4917
|
), p = Object.entries(u.tcps || {}).map(
|
|
4919
|
-
([b,
|
|
4918
|
+
([b, C]) => ({
|
|
4920
4919
|
id: b,
|
|
4921
|
-
readable_name:
|
|
4922
|
-
position:
|
|
4923
|
-
orientation:
|
|
4920
|
+
readable_name: C.name,
|
|
4921
|
+
position: C.pose.position,
|
|
4922
|
+
orientation: C.pose.orientation
|
|
4924
4923
|
})
|
|
4925
4924
|
), x = e.openReconnectingWebsocket(
|
|
4926
4925
|
`/controllers/${n.controller}/state-stream?response_rate=1000`
|
|
@@ -5444,7 +5443,7 @@ export {
|
|
|
5444
5443
|
gi as P,
|
|
5445
5444
|
Si as R,
|
|
5446
5445
|
vi as S,
|
|
5447
|
-
|
|
5446
|
+
wi as T,
|
|
5448
5447
|
Eo as V,
|
|
5449
5448
|
bo as W,
|
|
5450
5449
|
_t as a,
|
|
@@ -5453,7 +5452,7 @@ export {
|
|
|
5453
5452
|
ui as d,
|
|
5454
5453
|
pi as e,
|
|
5455
5454
|
vo as f,
|
|
5456
|
-
|
|
5455
|
+
wo as g,
|
|
5457
5456
|
xi as h,
|
|
5458
5457
|
at as i,
|
|
5459
5458
|
mi as j,
|
|
@@ -5463,7 +5462,7 @@ export {
|
|
|
5463
5462
|
Do as n,
|
|
5464
5463
|
Zt as o,
|
|
5465
5464
|
Jo as p,
|
|
5466
|
-
|
|
5465
|
+
Ci as q,
|
|
5467
5466
|
Ht as r,
|
|
5468
5467
|
ut as s,
|
|
5469
5468
|
ft as t,
|
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-CxOImT4p.cjs"),o=require("./chunks/interpolation-B84QX33C.cjs"),t=require("./chunks/externalizeComponent-BHZdH14U.cjs"),a=require("./chunks/SafetyBar-CLm3UQRA.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-iMsXEbX7.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-D9WFd-j_.js";
|
|
3
3
|
import { i as X } from "./chunks/externalizeComponent-D6S3WLFc.js";
|
|
4
4
|
import { S as Z } from "./chunks/SafetyBar-C8whliAf.js";
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/MotionGroupVisualizer-EN8Nw5xP.cjs"),e=require("./chunks/theming-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/MotionGroupVisualizer-EN8Nw5xP.cjs"),e=require("./chunks/theming-CxOImT4p.cjs"),t=require("./chunks/interpolation-B84QX33C.cjs"),i=require("./chunks/externalizeComponent-BHZdH14U.cjs"),s=require("./chunks/SafetyBar-CLm3UQRA.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
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-BXDggjVD.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-
|
|
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-iMsXEbX7.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-D9WFd-j_.js";
|
|
4
4
|
import { i as ua } from "./chunks/externalizeComponent-D6S3WLFc.js";
|
|
5
5
|
import { S as pa } from "./chunks/SafetyBar-C8whliAf.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.5-pr.ci-pr-preview-concurrency.611.8fb1478",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|