@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.e1da7d4 → 6.4.0-pr.revamp.667.fa67ce5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/3d.cjs +1 -1
- package/dist/3d.js +1 -1
- package/dist/RobotHeader/index.cjs +1 -1
- package/dist/RobotHeader/index.js +1 -1
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.js +1 -1
- package/dist/chunks/{Robot-BeTWgowU.cjs → Robot-B3vKEVXP.cjs} +1 -1
- package/dist/chunks/{Robot-D4XbngYI.js → Robot-DDD382dk.js} +1 -1
- package/dist/chunks/{RobotHeader-BZci9ahT.js → RobotHeader-BvIzk8Fw.js} +1 -1
- package/dist/chunks/{RobotHeader-CqK0700U.cjs → RobotHeader-Daft80jq.cjs} +1 -1
- package/dist/chunks/{SafetyBar-Bbg-o8h9.cjs → SafetyBar-BVk-SH_0.cjs} +1 -1
- package/dist/chunks/{SafetyBar-Cuak4ffd.js → SafetyBar-eYzCHOFD.js} +1 -1
- package/dist/chunks/TrajectoryExecutionStore-8yxebRg1.cjs +3 -0
- package/dist/chunks/{TrajectoryExecutionStore-BNZzZ1Gx.js → TrajectoryExecutionStore-tZgq2ivg.js} +898 -671
- package/dist/chunks/converters-BsXgcxCW.cjs +1 -0
- package/dist/chunks/{converters-DpNB_WNQ.js → converters-D9KpJ2HD.js} +16 -8
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.js +41 -38
- package/dist/index.cjs +1 -1
- package/dist/index.js +49 -46
- package/dist/lib/ControllerStateStream.d.ts +125 -0
- package/dist/lib/controllerStateSource.d.ts +37 -0
- package/dist/lib/nats/natsControllerStateSource.d.ts +27 -0
- package/dist/nats.cjs +1 -0
- package/dist/nats.d.ts +4 -0
- package/dist/nats.js +131 -0
- package/package.json +11 -1
- package/dist/chunks/TrajectoryExecutionStore-CYrVePlx.cjs +0 -3
- package/dist/chunks/converters-C8I_A_tA.cjs +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "6.4.0-pr.revamp.667.
|
|
3
|
+
"version": "6.4.0-pr.revamp.667.fa67ce5",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
"import": "./dist/3d.js",
|
|
28
28
|
"require": "./dist/3d.cjs"
|
|
29
29
|
},
|
|
30
|
+
"./nats": {
|
|
31
|
+
"types": "./dist/nats.d.ts",
|
|
32
|
+
"import": "./dist/nats.js",
|
|
33
|
+
"require": "./dist/nats.cjs"
|
|
34
|
+
},
|
|
30
35
|
"./package.json": "./package.json",
|
|
31
36
|
"./*": {
|
|
32
37
|
"types": "./dist/*/index.d.ts",
|
|
@@ -96,6 +101,7 @@
|
|
|
96
101
|
"jsdom": "^27.4.0",
|
|
97
102
|
"mobx": "^6.13.6",
|
|
98
103
|
"mobx-react-lite": "^4.1.0",
|
|
104
|
+
"nats.ws": "^1.30.3",
|
|
99
105
|
"nodemon": "^3.1.9",
|
|
100
106
|
"react": "^19.1.0",
|
|
101
107
|
"react-dom": "^19.1.0",
|
|
@@ -120,6 +126,7 @@
|
|
|
120
126
|
"@wandelbots/mui": "^2.0.0",
|
|
121
127
|
"mobx": "^6.13.6",
|
|
122
128
|
"mobx-react-lite": "^4.1.0",
|
|
129
|
+
"nats.ws": "^1.30.3",
|
|
123
130
|
"react": "^19.0.0",
|
|
124
131
|
"react-dom": "^19.0.0",
|
|
125
132
|
"three": ">=0.182",
|
|
@@ -140,6 +147,9 @@
|
|
|
140
147
|
},
|
|
141
148
|
"three-stdlib": {
|
|
142
149
|
"optional": true
|
|
150
|
+
},
|
|
151
|
+
"nats.ws": {
|
|
152
|
+
"optional": true
|
|
143
153
|
}
|
|
144
154
|
},
|
|
145
155
|
"dependencies": {
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),qt=require("@mui/material/AppBar"),xt=require("@mui/material/Backdrop"),F=require("@mui/material/Box"),Bt=require("@mui/material/Menu"),$=require("@mui/material/MenuItem"),zt=require("@mui/material/Toolbar"),_=require("@mui/material/Typography"),Ut=require("@wandelbots/design-tokens"),Gt=require("@wandelbots/icons/ExpandMoreFilled"),Wt=require("@wandelbots/mui"),E=require("mobx-react-lite"),C=require("react"),Z=require("./externalizeComponent-BdxGBLIv.cjs"),Ht=require("@mui/icons-material/OpenWith"),Kt=require("@mui/icons-material/Share"),v=require("@mui/material/Stack"),Yt=require("@mui/material/Tab"),Zt=require("@mui/material/Tabs"),y=require("mobx"),P=require("react-i18next"),w=require("@wandelbots/nova-js"),D=require("@wandelbots/nova-js/v2"),N=require("three"),b=require("./Pose3-DIyg-aZA.cjs"),jt=require("@mui/material/CircularProgress"),Qt=require("@mui/material/utils"),bt=require("lodash-es"),Xt=require("./SafetyBar-Bbg-o8h9.cjs"),te=require("@mui/material/Alert"),ee=require("@mui/material/AlertTitle"),nt=require("@mui/material/Button"),L=require("@mui/material/styles"),q=require("@mui/material/Divider"),gt=require("@mui/material/ToggleButton"),X=require("@mui/material/IconButton"),B=require("./joggingColors-ZDc_2UCp.cjs"),oe=require("lodash-es/isEqual.js"),ne=require("@mui/material/InputAdornment"),ie=require("@mui/material/FormControl"),re=require("@mui/material/InputLabel"),se=require("@mui/material/Select"),H=require("lodash-es/keyBy.js"),ae=require("lodash-es/uniqueId.js"),ce=require("@mui/material/ToggleButtonGroup"),vt=require("@mui/material/Slider"),le=require("lodash-es/isNumber.js"),de=require("@mui/icons-material/ChevronLeft"),ge=require("@mui/icons-material/ChevronRight"),ue=require("lodash-es/throttle.js"),he=require("@mui/material/Dialog"),me=require("@mui/material/DialogActions"),pe=require("@mui/material/DialogContent"),fe=require("@mui/material/DialogTitle");function Ct(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const j=Ct(C),ut=Ct(N),ye=Z.externalizeComponent(E.observer(e=>{const{appIcon:t,appName:o,apps:n=[],onAppSelect:i,disabled:s=!1,sx:a}=e,[c,g]=C.useState(null),h=!!c,u=l=>{g(l.currentTarget)},m=()=>{g(null)},d=l=>{m(),l.onClick?l.onClick():l.href&&(window.location.href=l.href),i==null||i(l)};return r.jsxs(r.Fragment,{children:[r.jsx(qt,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...a},children:r.jsxs(zt,{sx:{minHeight:"62px !important"},children:[r.jsx(F,{sx:{mr:1,display:"flex",alignItems:"center"},children:t}),r.jsxs(F,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[r.jsx(_,{component:"h1",variant:"subtitle1",children:o}),n.length>0&&r.jsx(Wt.RoundedIconButton,{icon:r.jsx(Gt.ExpandMoreFilled,{size:20}),ariaLabel:"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:u,disabled:s,sx:{ml:1}})]})]})}),r.jsx(xt,{open:h,onClick:m,sx:{backdropFilter:"blur(4px)",backgroundColor:Ut.ZeroGravityComponentsBackdropFill,zIndex:l=>l.zIndex.modal-1}}),r.jsx(Bt,{id:"app-menu",anchorEl:c,open:h,onClose:m,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{zIndex:l=>l.zIndex.modal,"& .MuiPaper-root":{minWidth:200,mt:1}},children:n.map(l=>r.jsxs($,{onClick:()=>d(l),children:[r.jsx(F,{sx:{display:"flex",alignItems:"center"},children:l.icon}),r.jsx(_,{variant:"body1",sx:{ml:2},children:l.name})]},l.id))})]})})),Se=({title:e,titleId:t,...o},n)=>j.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...o},e?j.createElement("title",{id:t},e):null,j.createElement("g",{id:"JogMinus"},j.createElement("path",{id:"Minus",d:"M0 13V8H21V13H0Z",fill:"white"}))),xe=C.forwardRef(Se),je=({title:e,titleId:t,...o},n)=>j.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...o},e?j.createElement("title",{id:t},e):null,j.createElement("g",{id:"JogPlus"},j.createElement("g",{id:"Plus"},j.createElement("path",{d:"M0 13V8H8V13H0Z",fill:"white"}),j.createElement("path",{d:"M8 0L13 2.18557e-07L13 21H8L8 0Z",fill:"white"}),j.createElement("path",{d:"M13 13V8H21V13H13Z",fill:"white"})))),be=C.forwardRef(je),it=Z.externalizeComponent(E.observer(({colors:e,label:t,getDisplayedValue:o,startJogging:n,stopJogging:i,disabled:s,activeJoggingDirection:a,...c})=>{var k,J,R,I,O,z,U;b.useAnimationFrame(()=>{const A=o(),V=d.current;V&&(V.textContent=A)});const g=L.useTheme(),[h,u]=C.useState(null);C.useEffect(()=>{s&&T()},[s]);const m=a||h,d=C.useRef(null);e||(e={color:"#fff",backgroundColor:"#000",borderColor:"#000",buttonBackgroundColor:{disabled:"#000",default:"#000",hovered:"#000",pressed:"#000"},labelColor:"#000"});const l=m?(k=e.buttonBackgroundColor)==null?void 0:k.pressed:e.borderColor,f={width:"55px",color:e.color,path:{fill:e.color},alignContent:"center",fontSize:"37px",svg:{pointerEvents:"none"}},p={...f,backgroundColor:(J=e.buttonBackgroundColor)==null?void 0:J.default,":hover":{backgroundColor:(R=e.buttonBackgroundColor)==null?void 0:R.hovered},":active":{backgroundColor:(I=e.buttonBackgroundColor)==null?void 0:I.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor}},":disabled":{backgroundColor:(O=e.buttonBackgroundColor)==null?void 0:O.disabled,"svg path":{fill:g.palette.action.disabled}}},x={...f,backgroundColor:(z=e.buttonBackgroundColor)==null?void 0:z.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor},":disabled":{backgroundColor:(U=e.buttonBackgroundColor)==null?void 0:U.pressed,"svg path":{fill:g.palette.action.disabled}}};function M(A,V){s||A.button===0&&(u(V),n(V))}function T(){u(null),i()}return r.jsxs(v,{height:"64px",direction:"row",justifyContent:"center",...c,children:[r.jsx(X,{disabled:s,disableRipple:!0,onPointerDown:A=>M(A,"-"),onPointerUp:T,onPointerOut:T,size:"large",sx:{...m==="-"?x:p,borderRadius:"16px 0px 0px 16px",borderLeft:`2px solid ${l??"#fff"}`,borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:r.jsx(xe,{})}),r.jsxs(v,{spacing:"6px",sx:{width:"150px",backgroundColor:e.backgroundColor,alignItems:"center",justifyContent:"center",opacity:"0.9",borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:[r.jsx(v,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:e.color,".MuiTypography-root":{fontWeight:700,...s?{color:g.palette.action.disabled}:{}},...s?{"svg path":{fill:g.palette.action.disabled}}:{}},children:t}),r.jsx(_,{height:"22px",sx:{fontSize:"15px",color:s?g.palette.action.disabled:e.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:d,children:o()})]}),r.jsx(X,{disableRipple:!0,disabled:s,onPointerDown:A=>M(A,"+"),onPointerUp:T,onPointerOut:T,size:"large",sx:{...m==="+"?x:p,borderRadius:"0px 16px 16px 0px",borderRight:`2px solid ${l??"#fff"}`,borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:r.jsx(be,{})})]})})),It=Z.externalizeComponent(E.observer(({startJogging:e,stopJogging:t,lowerLimit:o,upperLimit:n,useDegree:i,getValue:s,disabled:a,...c})=>{var I,O,z,U,A,V,dt;const{t:g}=P.useTranslation(),[h,u]=C.useState(),m=L.useTheme(),d={background:(I=m.palette.backgroundPaperElevation)==null?void 0:I[4],color:(O=m.palette.backgroundPaperElevation)==null?void 0:O[11]},l=E.useLocalObservable(()=>({activeJoggingDir:null,startJogging(S){this.activeJoggingDir=S,e(S)},stopJogging(){this.activeJoggingDir=null,t()}})),f=ue(()=>{const S=i?p(s()):s();(S===void 0||h===void 0||Math.abs(h-S)>1e-9)&&u(S)},50);b.useAnimationFrame(f);function p(S){if(S!==void 0)return w.radiansToDegrees(S)}function x(S){S.button===0&&l.startJogging("-")}function M(S){S.button===0&&l.startJogging("+")}function T(S){l.stopJogging()}function k(S){l.stopJogging()}function J(S,G=1){if(S===void 0||Number.isNaN(S))return"";const W=g("General.degree.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${W}`:W}function R(S,G=1){if(S===void 0||Number.isNaN(S))return"";const W=g("General.mm.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${W}`:W}return r.jsxs(v,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...c,sx:{"& .MuiIconButton-root":{width:"52px",color:m.palette.text.primary,alignContent:"center",backgroundColor:(z=m.palette.backgroundPaperElevation)==null?void 0:z[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:(U=m.palette.backgroundPaperElevation)==null?void 0:U[11],color:m.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(A=m.palette.backgroundPaperElevation)==null?void 0:A[9]},"&:active":{...d}}},children:[r.jsx(X,{onPointerDown:x,onPointerUp:T,onPointerOut:k,disabled:a,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...l.activeJoggingDir==="-"?d:{}},children:r.jsx(de,{sx:{pointerEvents:"none",color:B.jointArrowColor}})}),r.jsxs(v,{flexGrow:1,alignItems:"center",justifyContent:"center",sx:{borderStyle:"solid",borderLeftWidth:0,borderRightWidth:0,border:"none",backgroundColor:(V=m.palette.backgroundPaperElevation)==null?void 0:V[11],paddingLeft:"20px",paddingRight:"20px",zIndex:1},children:[r.jsx(_,{sx:{fontSize:"15px",fontWeight:700,position:"relative",top:"5px",fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center",color:a?m.palette.action.disabled:m.palette.text.primary},children:i?J(h):R(h)}),r.jsx(vt,{disabled:!0,"aria-label":"Joint position",min:i?p(o):o,max:i?p(n):n,value:h||0,track:!1,sx:{"& .MuiSlider-mark":{display:"none"},"& .MuiSlider-thumb":{width:"5px",height:"12px",borderRadius:"2px",color:a?m.palette.action.disabled:m.palette.text.primary},"& .MuiSlider-markLabel":{top:"20px",fontSize:"12px",color:a?m.palette.action.disabled:m.palette.text.secondary},"& .MuiSlider-rail":{backgroundColor:(dt=m.palette.backgroundPaperElevation)==null?void 0:dt[5],opacity:1}},marks:o!==void 0&&n!==void 0&&[{value:i?p(o):o,label:i?J(p(o),0):R(o)},{value:i?p(n):n,label:i?J(p(n),0):R(n)}]})]}),r.jsx(X,{onPointerDown:M,onPointerUp:T,onPointerOut:k,disabled:a,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...l.activeJoggingDir==="+"?d:{}},children:r.jsx(ge,{sx:{pointerEvents:"none",color:B.jointArrowColor}})})]})}));function ve({currentTcpPose:e,axis:t,direction:o,motion:n,useToolCoordinateSystem:i,coordinateSystemRotation:s}){const a=o==="-"?-1:1;if(n.type==="translate"){if(!e.position)throw new Error("Current pose has no position, cannot perform translation");const m=n.distanceMm*a,d=new N.Vector3;if(d[t]=m,i){if(!e.orientation)throw new Error("Current pose has no orientation, cannot translate relative to tool");d.applyQuaternion(b.parseRotationToQuaternion(e.orientation,"ROTATION_VECTOR"))}else s&&d.applyQuaternion(s);const l=[...e.position];return l[0]=(l[0]??0)+d.x,l[1]=(l[1]??0)+d.y,l[2]=(l[2]??0)+d.z,{position:l,orientation:e.orientation}}if(!e.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const c=b.parseRotationToQuaternion(e.orientation,"ROTATION_VECTOR"),g=new N.Vector3;g[t]=1,!i&&s&&g.applyQuaternion(s);const h=new N.Quaternion().setFromAxisAngle(g,n.distanceRads*a),u=i?c.multiply(h):h.multiply(c);return{position:e.position,orientation:[...b.quaternionToRotationVector(u)]}}function _t(e,t,o){return t.length!==e.length?!1:wt(e,t,o)}function at(e,t,o){return t.length!==e.length?!0:wt(e,t,o)}function wt(e,t,o){for(let n=0;n<t.length;n++)if(Math.abs((t[n]??0)-(e[n]??0))>o)return!1;return!0}function Et(e,t,o){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 n=0;return n+=Math.abs(e.orientation[0]-t.orientation[0]),n+=Math.abs(e.orientation[1]-t.orientation[1]),n+=Math.abs(e.orientation[2]-t.orientation[2]),n+=Math.abs(e.position[0]-t.position[0]),n+=Math.abs(e.position[1]-t.position[1]),n+=Math.abs(e.position[2]-t.position[2]),n<=o}function ct(e,t,o){return e.coordinate_system===t.coordinate_system&&e.tcp===t.tcp&&Et(e.tcp_pose,t.tcp_pose,o)}function Tt(e,t){const o=new N.Vector3(t[0],t[1],t[2]),n=new N.Vector3(e[0],e[1],e[2]),i=o.length(),s=o.normalize();let a=n.length(),c=n.normalize();c.dot(s)<0&&(a=-a,c=c.multiplyScalar(-1));let g=a-i;return g-=2*Math.PI*Math.floor((g+Math.PI)/(2*Math.PI)),a=i+g,[...c.multiplyScalar(a)]}const Ce=2e-4;function Mt(e){const{joint_position:t,tcp_pose:o,tcp:n,coordinate_system:i}=e;return{joint_position:t,tcp_pose:o,tcp:n,coordinate_system:i}}function kt(e,t){return e.tcp===t.tcp&&e.coordinate_system===t.coordinate_system&&e.tcp_pose===void 0==(t.tcp_pose===void 0)&&_t(e.joint_position,t.joint_position,Ce)}const ht=1e-4;class et{constructor(t,o,n,i,s,a,c="cell",g={}){this.controller=o,this.motionGroup=n,this.description=i,this.initialMotionState=s,this.motionStateSocket=a,this.cellId=c,this.nova=b.createNovaClient(t),this.logger=g.logger??console,this.rapidlyChangingMotionState=s,a.addEventListener("message",h=>{var l;const u=(l=w.tryParseJson(h.data))==null?void 0:l.result;if(!u)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${h.data}`);ct(this.rapidlyChangingMotionState,u,ht)||y.runInAction(()=>{var f,p,x;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=u.tcp_pose:(f=u.tcp_pose)!=null&&f.orientation&&((p=u.tcp_pose)!=null&&p.position)&&((x=this.rapidlyChangingMotionState.tcp_pose)!=null&&x.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:u.tcp_pose.position,orientation:Tt(u.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:this.logger.debug("Received incomplete tcp_pose, ignoring",{tcpPose:u.tcp_pose})}),at(this.rapidlyChangingMotionState.joint_position,u.joint_position,ht)||y.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=u.joint_position}),u.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==u.tcp&&y.runInAction(()=>{this.rapidlyChangingMotionState.tcp=u.tcp}),this.rapidlyChangingMotionState.standstill!==u.standstill&&y.runInAction(()=>{this.rapidlyChangingMotionState.standstill=u.standstill});const m=this.rapidlyChangingMotionState.joint_limit_reached.limit_reached,d=u.joint_limit_reached.limit_reached;m.some((f,p)=>f!==d[p])&&y.runInAction(()=>{this.rapidlyChangingMotionState.joint_limit_reached=u.joint_limit_reached}),this.rapidlyChangingMotionState.execute!==u.execute&&y.runInAction(()=>{this.rapidlyChangingMotionState.execute=u.execute})}),y.makeAutoObservable(this,{logger:!1,readoutState:y.computed({equals:kt,keepAlive:!0})})}static async open(t,o,n={}){var p;const i=b.createNovaClient(t),s=n.cellId??b.cellIdOf(t)??"cell",[a,c]=o.split("@"),g=await i.api.controller.getCurrentRobotControllerState(s,c),h=g==null?void 0:g.motion_groups.find(x=>x.motion_group===o);if(!g||!h)throw new Error(`Controller ${c} or motion group ${o} not found`);const u=i.openReconnectingWebsocket(`/cells/${s}/controllers/${c}/motion-groups/${o}/state-stream`),m=await u.firstMessage(),d=(p=w.tryParseJson(m.data))==null?void 0:p.result;if(!d)throw new Error(`Unable to parse initial motion state message ${m.data}`);const l=n.logger??console;l.info("Connected motion state websocket to motion group",{motionGroup:h.motion_group,initialMotionState:d});const f=await i.api.motionGroup.getMotionGroupDescription(s,c,h.motion_group);return new et(i,g,h,f,d,u,s,{logger:l})}get readoutState(){return Mt(this.rapidlyChangingMotionState)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get joints(){return this.initialMotionState.joint_position.map((t,o)=>({index:o}))}dispose(){this.motionStateSocket.close()}}const mt="Movement request rejected. Another client is currently executing a 'Jogging' motion!",Ie=500,_e=5e3;function we(e){var o;return(((o=e.times)==null?void 0:o[e.times.length-1])??0)*2e3+_e}class ot{constructor(t,o={}){this.motionStream=t,this.options=o,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.incrementalMotionInFlight=!1,this.ownsMotionStream=!1,this.tcp=(o==null?void 0:o.tcp)||t.motionGroup.tcp||this.getDefaultTcp(t),this.coordinateSystem=o==null?void 0:o.coordinateSystem,this.orientation=(o==null?void 0:o.orientation)||this.DEFAULT_ORIENTATION,this.timeout=(o==null?void 0:o.timeout)||this.DEFAULT_INIT_TIMEOUT,this.mode=(o==null?void 0:o.mode)||this.DEFAULT_MODE,this.onError=o==null?void 0:o.onError,this.logger=(o==null?void 0:o.logger)??console}static async open(t,o,n={}){const i=await et.open(t,o,{cellId:n.cellId,logger:n.logger}),s=new ot(i,n);s.ownsMotionStream=!0;try{await s.setJoggingMode(s.mode)}catch(a){throw s.dispose(),a}return s}getDefaultTcp(t){var n,i;const o=(i=(n=t.description.dh_parameters)==null?void 0:n[0])==null?void 0:i.type;return t.joints.length<6&&(o===D.JointTypeEnum.RevoluteJoint||o===D.JointTypeEnum.PrismaticJoint)?this.NO_TCP:this.DEFAULT_TCP}async setOptions(t){return t.tcp&&(this.tcp=t.tcp),t.orientation&&(this.orientation=t.orientation),"coordinateSystem"in t&&(this.coordinateSystem=t.coordinateSystem),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 cellId(){return this.motionStream.cellId}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.closeJoggingSockets();return this.ownsMotionStream&&this.motionStream.dispose(),t}closeJoggingSockets(){var o,n;(o=this.endJoggingInit)==null||o.call(this),(n=this.endIncrementalMotion)==null||n.call(this);const t=[this.joggingSocket,this.trajectorySocket].filter(i=>i!==null);return t.forEach(i=>{i.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(t.map(i=>i.closed()))}async setJoggingMode(t,o=!0){if(!(this.mode===t&&o)&&(this.closeJoggingSockets(),this.mode=t,this.mode==="jogging"))return this.initializeJoggingWebsocket()}async initializeJoggingWebsocket(){return new Promise((t,o)=>{const n=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`);this.joggingSocket=n;let i=!1;const s=setTimeout(()=>{a(new Error(`Jogging initialization timeout after ${this.timeout} ms`))},this.timeout),a=h=>{i||(i=!0,clearTimeout(s),n.removeEventListener("close",g),this.endJoggingInit===c&&(this.endJoggingInit=void 0),h?o(h):t())},c=()=>a(),g=()=>{n.disposed&&a()};this.endJoggingInit=c,n.addEventListener("close",g),n.addEventListener("message",h=>{var m,d,l;const u=w.tryParseJson(h.data);if(((m=u==null?void 0:u.result)==null?void 0:m.kind)==="INITIALIZE_RECEIVED"){a();return}if(((d=u==null?void 0:u.result)==null?void 0:d.kind)==="MOTION_ERROR")if(this.onBlocked&&((l=u==null?void 0:u.result)!=null&&l.message.includes(mt))){a(),n.dispose(),this.onBlocked();return}else this.onError?(a(),this.onError(h.data)):a(new Error(h.data))}),n.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:o,velocityValue:n,velocityUnit:i}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'");const s=new Array(this.numJoints).fill(0);s[t]=o==="-"?-n:n,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:s})}async translateTCP({axis:t,direction:o,velocityMmPerSec:n}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:this.velocityAlongAxis(t,o==="-"?-n:n),rotation:[0,0,0],use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:t,direction:o,velocityRadsPerSec:n}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:[0,0,0],rotation:this.velocityAlongAxis(t,o==="-"?-n:n),use_tool_coordinate_system:this.orientation==="tool"})}get coordinateSystemRotation(){if(!(this.orientation==="tool"||!this.coordinateSystem))return b.Pose3.fromCoordinateSystem(this.coordinateSystem).quaternion}velocityAlongAxis(t,o){const n=new N.Vector3;n[t]=o;const i=this.coordinateSystemRotation;return i&&n.applyQuaternion(i),[n.x,n.y,n.z]}async runIncrementalCartesianMotion(t){if(this.mode!=="trajectory")throw new Error("Set jogging mode to 'trajectory' to run incremental cartesian motions");if(!this.incrementalMotionInFlight){this.incrementalMotionInFlight=!0;try{const o=await this.planIncrementalCartesianMotion(t);o&&await this.executeTrajectory(o)}finally{this.incrementalMotionInFlight=!1}}}async planIncrementalCartesianMotion({currentTcpPose:t,currentJoints:o,velocityInRelevantUnits:n,axis:i,direction:s,motion:a}){var p,x,M;const c=[],g=ve({currentTcpPose:t,axis:i,direction:s,motion:a,useToolCoordinateSystem:this.orientation==="tool",coordinateSystemRotation:this.coordinateSystemRotation});c.push({limits_override:a.type==="translate"?{tcp_velocity_limit:n}:{tcp_orientation_velocity_limit:n},path:{path_definition_name:"PathLine",target_pose:{position:g.position,orientation:g.orientation}}});const h=this.motionStream.description;if(h.cycle_time===void 0){this.logger.warn("Current motion group has no cycle time, cannot plan jogging motion");return}const u=this.motionStream.rapidlyChangingMotionState.tcp,m=u?(x=(p=h.tcps)==null?void 0:p[u])==null?void 0:x.pose:void 0,d={motion_group_model:((M=this.options)==null?void 0:M.motionGroupModel)??h.motion_group_model,cycle_time:h.cycle_time,mounting:h.mounting,tcp_offset:m,global:h.operation_limits.auto_limits},l=await this.nova.api.trajectoryPlanning.planTrajectory(this.cellId,{motion_group_setup:d,start_joint_position:o,motion_commands:c}),f=l.response;if(!f)throw new Error(`Failed to plan jogging increment motion ${JSON.stringify(l)}`);if("error_feedback"in f){if(this.onError){this.onError(f);return}throw new Error(`Failed to plan jogging increment motion: ${JSON.stringify(f.error_feedback)}`)}return f}async executeTrajectory(t){const o=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);this.trajectorySocket=o;const n=new AbortController;let i,s;try{await new Promise((a,c)=>{let g=!1;const h=()=>{g||(g=!0,a())},u=d=>{if(!g){if(g=!0,this.onError){this.onError(d),a();return}c(d instanceof Error?d:new Error(`Failed to execute trajectory: ${JSON.stringify(d)}`))}};s=h,this.endIncrementalMotion=h;const m=we(t);i=setTimeout(()=>{u(new Error(`Jogging motion did not complete within ${m}ms`))},m),o.addEventListener("message",d=>{var f,p;const l=(f=w.tryParseJson(d.data))==null?void 0:f.result;if(!(l!=null&&l.kind)){u(new Error(`Failed to execute trajectory: Received invalid message ${d.data}`));return}if(this.onBlocked&&((p=l.message)!=null&&p.includes(mt))){this.onBlocked(),h();return}if(l.kind==="INITIALIZE_RECEIVED"){if(l.add_trajectory_error||l.message){u(l);return}o.sendJson({message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"})}else if(l.kind==="START_RECEIVED"){if(l.message){u(l);return}this.waitForMotionToFinish(n.signal).then(h,u)}else l.kind==="PAUSE_RECEIVED"||(l.kind==="MOTION_ERROR"&&l.message?u(l):u(new Error(`Failed to execute trajectory, cannot handle message type "${l.kind}"`)))}),o.sendJson({message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.motionGroupId,data:t,tcp:this.tcp}})})}finally{clearTimeout(i),n.abort(),this.endIncrementalMotion===s&&(this.endIncrementalMotion=void 0),o.dispose(),this.trajectorySocket===o&&(this.trajectorySocket=null)}}async waitForMotionToFinish(t){const o=()=>this.motionStream.rapidlyChangingMotionState.standstill;await y.when(()=>!o(),{timeout:Ie,signal:t}).catch(()=>{}),await y.when(o,{signal:t})}}const Jt=e=>{const t=e.softTimeout||3e3,[o,n]=C.useState(!1);return C.useEffect(()=>{const i=setTimeout(()=>{n(!0)},t);return()=>clearTimeout(i)}),r.jsx(v,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:"text.primary"},children:e.error?r.jsx(Rt,{loadingMessage:e.message,error:e.error}):r.jsxs(r.Fragment,{children:[r.jsx(jt,{sx:{mb:3}}),!!e.message&&r.jsx(_,{variant:"body1",children:e.message}),r.jsx(_,{variant:"body2",sx:{visibility:o?"visible":"hidden",mt:2,color:"text.secondary"},children:"This is taking longer than expected..."})]})})},Rt=e=>{const t=Xt.makeErrorMessage(e.error),o=e.error instanceof Error?e.error.stack:null;return r.jsxs(v,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",p:2,overflow:"auto",color:"error.main"},children:[r.jsx(_,{variant:"body1",children:(e.loadingMessage?`Error while ${bt.lowerFirst(Qt.capitalize(e.loadingMessage))} - `:"")+t}),o&&r.jsx(F,{component:"pre",sx:{typography:"body2",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",mt:2,pb:6},children:o})]})},Ee=E.observer(({store:e})=>{const{t}=P.useTranslation();return r.jsx(xt,{"data-testid":"jogging-blocked","aria-label":"jogging-blocked",open:!0,sx:{position:"absolute",zIndex:o=>o.zIndex.drawer+1,color:"#fff",background:"rgba(15, 15, 15, 0.88)",justifyContent:"flex-start",alignItems:"flex-start"},children:r.jsxs(v,{sx:{m:2,width:"100%"},children:[r.jsxs(te,{severity:"error",sx:{mb:2},children:[r.jsx(ee,{children:t("Jogging.Blocked.ti")}),t("Jogging.Blocked.lb")]}),r.jsx(nt,{variant:"contained",color:"secondary",onClick:()=>e.unblock(),children:t("Jogging.Blocked.Reenable.bt")})]})})}),Te=({title:e,titleId:t,...o},n)=>j.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:n,"aria-labelledby":t,...o},e?j.createElement("title",{id:t},e):null,j.createElement("path",{fill:"#fff",fillRule:"evenodd",d:"M5.131.312a.9.9 0 0 1 0 1.272L3.07 3.645h12.44l-2.06-2.061A.9.9 0 0 1 14.72.313l3.596 3.596a.9.9 0 0 1 0 1.271l-3.596 3.597a.9.9 0 0 1-1.271-1.272l2.061-2.062H3.07L5.13 7.505A.9.9 0 0 1 3.86 8.777L.263 5.18a.9.9 0 0 1 0-1.271L3.86.312a.9.9 0 0 1 1.271 0",clipRule:"evenodd"})),Me=C.forwardRef(Te),ke=({title:e,titleId:t,...o},n)=>j.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:n,"aria-labelledby":t,...o},e?j.createElement("title",{id:t},e):null,j.createElement("path",{fill:"#fff",fillRule:"evenodd",d:"M5.131.312a.9.9 0 0 1 0 1.272L3.07 3.645h12.44l-2.06-2.061A.9.9 0 0 1 14.72.313l3.596 3.596a.9.9 0 0 1 0 1.271l-3.596 3.597a.9.9 0 0 1-1.271-1.272l2.061-2.062H3.07L5.13 7.505A.9.9 0 0 1 3.86 8.777L.263 5.18a.9.9 0 0 1 0-1.271L3.86.312a.9.9 0 0 1 1.271 0",clipRule:"evenodd"})),Je=C.forwardRef(ke),Re=({title:e,titleId:t,...o},n)=>j.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:10,height:19,fill:"none",ref:n,"aria-labelledby":t,...o},e?j.createElement("title",{id:t},e):null,j.createElement("path",{fill:"#fff",fillRule:"evenodd",d:"M9.522 14.811A.899.899 0 1 0 8.25 13.54L6.19 15.601V3.16L8.25 5.221A.9.9 0 0 0 9.522 3.95L5.926.354a.9.9 0 0 0-1.272 0L1.058 3.95a.9.9 0 1 0 1.271 1.271L4.391 3.16v12.442L2.329 13.54a.899.899 0 1 0-1.271 1.271l3.596 3.597a.9.9 0 0 0 1.272 0z",clipRule:"evenodd"})),Oe=C.forwardRef(Re),Ae=({title:e,titleId:t,...o},n)=>j.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...o},e?j.createElement("title",{id:t},e):null,j.createElement("path",{d:"M8 16C5.76667 16 3.875 15.225 2.325 13.675C0.775 12.125 0 10.2333 0 8C0 5.76667 0.775 3.875 2.325 2.325C3.875 0.775 5.76667 0 8 0C9.15 0 10.25 0.2375 11.3 0.7125C12.35 1.1875 13.25 1.86667 14 2.75V0H16V7H9V5H13.2C12.6667 4.06667 11.9375 3.33333 11.0125 2.8C10.0875 2.26667 9.08333 2 8 2C6.33333 2 4.91667 2.58333 3.75 3.75C2.58333 4.91667 2 6.33333 2 8C2 9.66667 2.58333 11.0833 3.75 12.25C4.91667 13.4167 6.33333 14 8 14C9.28333 14 10.4417 13.6333 11.475 12.9C11.0583 14.1 12.5083 12.1667 11.475 12.9L12.9 14.325C11.4667 15.4417 9.83333 16 8 16Z",fill:"white"})),Pe=C.forwardRef(Ae),Ot=E.observer(({store:e})=>{const{t}=P.useTranslation(),[o,n]=C.useState(e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached),i=C.useRef(o);b.useAnimationFrame(()=>{const a=e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;oe(i.current,a)||(i.current=a,n(a))});const s=[];for(const[a,c]of o.entries())c&&s.push(a);return r.jsx(F,{sx:{display:"flex",flexDirection:"row",justifyContent:"center"},children:r.jsx(_,{"data-testid":"jogging-joint-limit-detector","aria-label":"jogging-joint-limit-detector",color:"error",variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2,visibility:s.length?"visible":"hidden"},children:t("Jogging.JointLimitsReached.lb",{jointNumbers:s.map(a=>a+1).join(", ")})})})}),Ve=L.styled(ie)(({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 Q({labelValue:e,...t}){return r.jsxs(Ve,{fullWidth:!0,variant:"filled",children:[r.jsx(re,{id:t.labelId,children:e}),r.jsx(se,{...t})]})}function pt(e){const t=e.lastIndexOf("On");return t>0?e.slice(0,t):e}function At(e,t){const o=e[t];if(o)return o;const n=pt(t),i=e[n];if(i)return i;const s=Object.keys(e).filter(c=>pt(c)===n);if(s.length!==1)return;const a=s[0];return a?e[a]:void 0}const De={coordinate_system:"world",name:"world",reference_coordinate_system:"",position:[0,0,0],orientation:[0,0,0],orientation_type:"ROTATION_VECTOR"};function Pt(e){const t=H(e.map(i=>({...i,coordinate_system:i.coordinate_system||"world"})),"coordinate_system");t.world??(t.world=De);const o={},n=i=>{const s=o[i];if(s)return s;const a=At(t,i);if(!a)throw new Error(`Unknown coordinate system ${i}. Known coordinate systems are: ${Object.keys(t).join(", ")}`);const c=a.reference_coordinate_system||"world";let g;if(c==="world")g=a;else{const h=n(c),u=b.Pose3.fromCoordinateSystem(h).multiply(b.Pose3.fromCoordinateSystem(a));g={...a,position:[u.position.x,u.position.y,u.position.z],orientation:[u.orientation.x,u.orientation.y,u.orientation.z],orientation_type:"ROTATION_VECTOR",reference_coordinate_system:h.reference_coordinate_system}}return o[i]=g,g};return Object.fromEntries(Object.keys(t).map(i=>[i,n(i)]))}function rt(e,t){const o=At(e,t||"world");if(!o)throw new Error(`Unknown coordinate system ${t}. Known coordinate systems are: ${Object.keys(e).join(", ")}`);return o}function Vt(e,t){return rt(Pt(t),e)}function K(e,t,o){if(e.coordinateSystemId===t)return e;const n=Pt(o),i=rt(n,e.coordinateSystemId||"world"),s=rt(n,t);if(i.coordinate_system===s.coordinate_system)return{...e,coordinateSystemId:s.coordinate_system};const a=b.Pose3.fromCoordinateSystem(s).inverse().multiply(b.Pose3.fromCoordinateSystem(i).multiply(b.Pose3.fromPose(e.pose)));return{...e,pose:{position:[a.position.x,a.position.y,a.position.z],orientation:[a.orientation.x,a.orientation.y,a.orientation.z]},coordinateSystemId:s.coordinate_system}}function Dt(e,t,o){const n=b.Pose3.fromPose(e).multiply(b.Pose3.fromRobotTcp(t).inverse()).multiply(b.Pose3.fromRobotTcp(o)),{position:i,orientation:s}=n;return{position:[i.x,i.y,i.z],orientation:[s.x,s.y,s.z]}}function ft(e,t){const o=e==null?void 0:e[t];if(!o)throw new Error(`Unknown TCP ${t}. Known TCPs are: ${Object.keys(e??{}).join(", ")}`);return{position:o.pose.position??[0,0,0],orientation:o.pose.orientation??[0,0,0],orientation_type:"ROTATION_VECTOR"}}function Fe({inputPose:e,selectedTcpId:t,selectedCoordinateSystemId:o,tcpOffsetsById:n,coordinateSystems:i}){const s=t&&t!==e.tcpId?{...e,pose:Dt(e.pose,ft(n,e.tcpId),ft(n,t)),tcpId:t}:e;return o?K(s,o,i):s}function Ft(e){var t,o,n,i,s;if(typeof e=="string"){const a=w.tryParseJson(e);return a?Ft(a):e}if(e&&typeof e=="object"){const a=e;return((t=a.error_feedback)==null?void 0:t.error_feedback_name)||((o=a.add_trajectory_error)==null?void 0:o.message)||a.message||((i=(n=a.result)==null?void 0:n.add_trajectory_error)==null?void 0:i.message)||((s=a.result)==null?void 0:s.message)||"Jogging motion failed"}return"Jogging motion failed"}const Le=[{pattern:/^FeedbackSingularity$/,translationKey:"Jogging.StreamStateSection.Error.Singularity.lb"},{pattern:/^FeedbackJointLimitExceeded$/,translationKey:"Jogging.StreamStateSection.Error.JointLimit.lb"},{pattern:/^FeedbackOutOfWorkspace$/,translationKey:"Jogging.StreamStateSection.Error.OutOfWorkspace.lb"},{pattern:/^FeedbackCollision$/,translationKey:"Jogging.StreamStateSection.Error.Collision.lb"},{pattern:/^FeedbackNoSolutionInCurrentConfiguration$/,translationKey:"Jogging.StreamStateSection.Error.NoSolutionInConfiguration.lb"},{pattern:/^Feedback\w+$/,translationKey:"Jogging.StreamStateSection.Error.PlanningFailed.lb"}];function Ne(e){var t;return((t=Le.find(({pattern:o})=>o.test(e)))==null?void 0:t.translationKey)??null}const $e=5,qe=250;function Be(e){var n,i,s,a;const t=[(i=(n=e==null?void 0:e.manual_t1_limits)==null?void 0:n.tcp)==null?void 0:i.velocity,(a=(s=e==null?void 0:e.manual_limits)==null?void 0:s.tcp)==null?void 0:a.velocity].filter(c=>typeof c=="number"&&Number.isFinite(c)&&c>0);return Math.min(qe,...t)/10}const st=[{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}],ze=[{id:"continuous"},...st],Ue=["coordsys","tool"],yt="joggingToolStore",Ge=()=>typeof localStorage>"u"?void 0:localStorage;class Y{constructor(t,o,n,i,s,a={}){var g,h,u;this.jogger=t,this.coordSystems=o,this.motionGroupDescription=n,this.tcps=i,this.inverseSolverValue=s,this.selectedTabId="cartesian",this.locks=new Set,this.blocked=!1,this.selectedCoordSystemId="world",this.jogCoordSystemId="world",this.selectedTcpId="",this.tcpChangeInProgress=!1,this.selectedOrientation="coordsys",this.selectedIncrementId="continuous",this.selectedCartesianMotionType="translate",this.incrementJogInProgress=null,this.lastJogError=null,this.onBeforeActivate=null,this.rotationVelocityDegPerSec=$e,this.minTranslationVelocityMmPerSec=1,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=D.JointTypeEnum.RevoluteJoint,this.storage=a.storage??Ge();for(const m of o)if(m.coordinate_system===""){m.coordinate_system="world";break}this.selectedCoordSystemId=((g=o[0])==null?void 0:g.coordinate_system)||"world",this.jogCoordSystemId=this.selectedCoordSystemId,this.selectedTcpId=t.motionStream.rapidlyChangingMotionState.tcp??"",this.tcpChangeInProgress=this.tcps.length>0&&!this.selectedTcpId,this.inverseSolver=s,this.translationVelocityMmPerSec=Be(n==null?void 0:n.operation_limits),this.jointType=((u=(h=n==null?void 0:n.dh_parameters)==null?void 0:h[0])==null?void 0:u.type)??D.JointTypeEnum.RevoluteJoint,y.makeAutoObservable(this,{storage:!1},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()};const c=this.jogger.onError;this.jogger.onError=m=>{this.setLastJogError(Ft(m)),c==null||c(m)},this.loadFromLocalStorage(),this.disposers.push(y.autorun(()=>this.saveToLocalStorage())),this.disposers.push(y.autorun(()=>{const m=this.jogger.motionStream.rapidlyChangingMotionState.tcp;m&&m!==this.selectedTcpId&&y.runInAction(()=>{this.selectedTcpId=m,this.tcpChangeInProgress=!1})}))}static async loadFor(t,o={}){const{nova:n,cellId:i}=t,[s,a]=await Promise.all([n.api.controller.listCoordinateSystems(i,t.motionStream.controllerId,"ROTATION_VECTOR"),n.api.motionGroup.getMotionGroupDescription(i,t.motionStream.controllerId,t.motionGroupId)]),c=await n.api.motionGroupModels.getMotionGroupKinematicModel(a.motion_group_model);return Y.create(t,{coordinateSystems:s||[],description:a,kinematicModel:c},o)}static create(t,o,n={}){const{coordinateSystems:i,description:s,kinematicModel:a}=o,c=Object.entries(s.tcps||{}).map(([g,h])=>({id:g,readable_name:h.name,position:h.pose.position,orientation:h.pose.orientation}));return new Y(t,i,s,c,a.inverse_solver,n)}dispose(){for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return bt.countBy(this.coordSystems,t=>t.name)}async deactivate(){this.jogger.mode==="jogging"&&await this.jogger.setJoggingMode("off")}async activate(){var t;return this.lastJogError=null,await((t=this.onBeforeActivate)==null?void 0:t.call(this)),this.currentTab.id==="cartesian"?((this.jogger.tcp!==this.selectedTcpId||this.jogger.orientation!==this.selectedOrientation)&&await this.jogger.setOptions({tcp:this.selectedTcpId||void 0,orientation:this.selectedOrientation}),this.jogger.coordinateSystem=this.jogCoordSystem,this.activeDiscreteIncrement?await this.jogger.setJoggingMode("trajectory"):await this.jogger.setJoggingMode("jogging")):await this.jogger.setJoggingMode("jogging"),this.jogger}loadFromLocalStorage(){var n;const t=(n=this.storage)==null?void 0:n.getItem(yt),o=t?w.tryParseJson(t):void 0;o&&(this.tabsById[o.selectedTabId]&&(this.selectedTabId=o.selectedTabId),this.coordSystemsById[o.selectedCoordSystemId]&&(this.selectedCoordSystemId=o.selectedCoordSystemId),this.coordSystemsById[o.jogCoordSystemId]&&(this.jogCoordSystemId=o.jogCoordSystemId),this.incrementOptionsById[o.selectedIncrementId]&&(this.selectedIncrementId=o.selectedIncrementId),["translate","rotate"].includes(o.selectedCartesianMotionType)&&(this.selectedCartesianMotionType=o.selectedCartesianMotionType),["coordsys","tool"].includes(o.selectedOrientation)&&(this.selectedOrientation=o.selectedOrientation))}saveToLocalStorage(){var t;(t=this.storage)==null||t.setItem(yt,JSON.stringify(this.localStorageSave))}get isLocked(){return this.locks.size>0}get lastJogErrorTranslationKey(){return this.lastJogError?Ne(this.lastJogError):null}get localStorageSave(){return{selectedTabId:this.selectedTabId,selectedCoordSystemId:this.selectedCoordSystemId,jogCoordSystemId:this.jogCoordSystemId,selectedOrientation:this.selectedOrientation,selectedIncrementId:this.selectedIncrementId,selectedCartesianMotionType:this.selectedCartesianMotionType}}get canJogCartesian(){return this.inverseSolver!==null}get tabs(){const t=[{id:"joint",label:"Joints"}];return this.canJogCartesian&&t.unshift({id:"cartesian",label:"Cartesian"}),t}get incrementOptions(){return ze}get discreteIncrementOptions(){return st}get incrementOptionsById(){return H(this.incrementOptions,t=>t.id)}get tabsById(){return H(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 H(this.coordSystems,t=>t.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get jogCoordSystem(){return Vt(this.jogCoordSystemId,this.coordSystems)}get tcpPoseInSelectedCoordSystem(){const{tcp_pose:t,coordinate_system:o}=this.jogger.motionStream.readoutState;return!(t!=null&&t.position)||!t.orientation?t:K({pose:{position:t.position,orientation:t.orientation},coordinateSystemId:o||"world"},this.selectedCoordSystemId,this.coordSystems).pose}get tcpsById(){return H(this.tcps,t=>t.id)}tcpPoseIn(t,o){const{tcp_pose:n,tcp:i,coordinate_system:s}=this.jogger.motionStream.readoutState,a=this.tcpsById[i||this.selectedTcpId],c=this.tcpsById[t];if(!(!(n!=null&&n.position)||!n.orientation)&&!(!a||!c))try{return K({pose:Dt(n,a,c),coordinateSystemId:s||"world"},o,this.coordSystems).pose}catch{return}}get activeDiscreteIncrement(){return st.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,o){const n=this.tabs[o]||this.tabs[0];this.selectedTabId=n.id}setSelectedCoordSystemId(t){this.selectedCoordSystemId=t}setSelectedTcpId(t){this.requestTcpChange(t).catch(o=>{console.error("Failed to change TCP:",o)})}async requestTcpChange(t){if(t===this.selectedTcpId)return;this.tcpChangeInProgress=!0;const o=this.jogger.tcp,n=this.jogger.mode!=="jogging";try{this.jogger.tcp=t,n?await this.jogger.setJoggingMode("jogging"):await this.jogger.setJoggingMode("jogging",!1);let i=await this.waitForTcpConfirmation(t,1e3);n&&await this.jogger.setJoggingMode("off"),i||(i=await this.waitForTcpConfirmation(t,2e3)),y.runInAction(()=>{i?this.selectedTcpId=t:(this.jogger.tcp=o,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??"")})}catch(i){throw n&&await this.jogger.setJoggingMode("off").catch(()=>{}),y.runInAction(()=>{this.jogger.tcp=o,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??""}),i}finally{y.runInAction(()=>{this.tcpChangeInProgress=!1})}}waitForTcpConfirmation(t,o){return new Promise(n=>{const i=setTimeout(()=>{s(),n(!1)},o),s=y.when(()=>this.jogger.motionStream.rapidlyChangingMotionState.tcp===t,()=>{clearTimeout(i),n(!0)})})}setSelectedOrientation(t){this.selectedOrientation=t}setMoveRelativeToSelectedTcp(){this.selectedOrientation="tool"}setMoveRelativeToCoordSystem(t){this.selectedOrientation="coordsys",this.jogCoordSystemId=t}setSelectedIncrementId(t){this.selectedIncrementId=t}setCurrentIncrementJog(t){this.incrementJogInProgress=t}setLastJogError(t){this.lastJogError=t}setVelocityFromSlider(t,o){!Number.isFinite(t)||t<this.minVelocityInDisplayUnits(o)||t>this.maxVelocityInDisplayUnits(o)||(o?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().catch(t=>{console.error("Failed to initialize jogging:",t)})}async withMotionLock(t){const o=ae();this.lock(o);try{return await t()}finally{this.unlock(o)}}}const We=E.observer(({store:e,useDegree:t})=>{var a;const{t:o}=P.useTranslation(),n=C.useId(),i=[];function s(c){switch(c){case"coordsys":return o("Jogging.Orientation.coordsys");case"tool":return o("Jogging.Orientation.tool");default:return c}}return e.showCoordSystemSelect&&i.push(r.jsx(Q,{labelId:`jogging-coord-select-${n}`,labelValue:o("Jogging.CoordinateSystem.hlb"),value:e.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:c=>e.setSelectedCoordSystemId(c.target.value),children:e.coordSystems.map(c=>r.jsx($,{value:c.coordinate_system,children:c.name&&e.coordSystemCountByName[c.name]>1?`${c.name} / ${c.coordinate_system}`:c.name||c.coordinate_system},c.coordinate_system))},"coord")),e.showTcpSelect&&i.push(r.jsx(Q,{labelId:`jogging-tcp-select-${n}`,labelValue:"TCP",value:e.selectedTcpId,size:"small",variant:"filled",displayEmpty:e.tcpChangeInProgress,onChange:c=>{e.requestTcpChange(c.target.value).catch(g=>{console.error("Failed to change TCP:",g)})},disabled:e.tcpChangeInProgress,endAdornment:e.tcpChangeInProgress?r.jsx(ne,{position:"end",children:r.jsx(jt,{size:16})}):void 0,children:e.tcps.map(c=>r.jsx($,{value:c.id,children:c.id},c.id))},"tcp")),e.showOrientationSelect&&i.push(r.jsx(Q,{labelValue:o("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${n}`,value:e.selectedOrientation,onChange:c=>e.setSelectedOrientation(c.target.value),children:Ue.map(c=>r.jsx($,{value:c,children:s(c)},c))},"orientation")),e.showIncrementSelect&&i.push(r.jsxs(Q,{labelValue:o("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${n}`,size:"small",variant:"filled",value:((a=e.activeDiscreteIncrement)==null?void 0:a.id)||"continuous",onChange:c=>e.setSelectedIncrementId(c.target.value),children:[r.jsx($,{value:"continuous",children:o("Jogging.Increment.Continuous.dd")},"continuous"),e.discreteIncrementOptions.map(c=>r.jsx($,{value:c.id,children:t?`${c.degrees}°`:`${c.mm}mm`},c.id))]},"increment")),r.jsx(F,{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:i.map((c,g)=>r.jsx(F,{sx:{gridColumn:i.length%2===1&&g===i.length-1?"span 2":"auto"},children:c},g))})}),He=L.styled(ce)(({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"}}}}}),Lt=Z.externalizeComponent(E.observer(e=>{const{store:t}=e,{t:o}=P.useTranslation();function n(i,s){s===e.velocity||!le(s)||e.onVelocityChange(s,e.useDegree)}return r.jsxs(v,{direction:"row",gap:2,alignItems:"center","data-testid":"velocity-slider","aria-label":"velocity-slider",children:[t.showVelocityLegend&&r.jsx(_,{sx:{color:B.velocitySliderLegendColor,fontSize:"14px"},children:o("Jogging.Velocity.bt")}),r.jsx(vt,{value:e.velocity,color:"secondary",onChange:n,min:e.min,max:e.max,"aria-labelledby":"input-slider",disabled:e.disabled,sx:{"& .MuiSlider-valueLabelOpen":{zIndex:100,backgroundColor:"transparent",top:"0px"}}}),t.showVelocitySliderLabel&&(e.renderValue?e.renderValue(e.velocity):r.jsx(lt,{value:e.velocity.toString()}))]})}));function lt({value:e,sx:t}){var n;const o=L.useTheme();return r.jsx(v,{direction:"row",justifyContent:"center",alignItems:"center",gap:"5px",sx:{padding:"6px 12px",background:(n=o.palette.backgroundPaperElevation)==null?void 0:n[8],borderRadius:"10px",minWidth:"111px",...t},children:r.jsx(_,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:o.palette.text.primary,whiteSpace:"nowrap"},children:e})})}const Nt=E.observer(({store:e,useDegree:t})=>{const{t:o}=P.useTranslation();function n(i,s){return s?`ω = ${o("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:i})}`:`v = ${o("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:i})}`}return r.jsx(Lt,{store:e,velocity:e.velocityInDisplayUnits(t),min:e.minVelocityInDisplayUnits(t),max:e.maxVelocityInDisplayUnits(t),onVelocityChange:e.setVelocityFromSlider,useDegree:t,disabled:e.isLocked,renderValue:i=>r.jsx(lt,{value:n(i,t),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),$t=E.observer(({store:e})=>{var a,c,g;const{t}=P.useTranslation(),o=L.useTheme(),n=((g=(c=(a=e.jogger.motionStream.rapidlyChangingMotionState.execute)==null?void 0:a.details)==null?void 0:c.state)==null?void 0:g.kind)??"KIND_UNKNOWN",i=e.lastJogError,s=e.lastJogErrorTranslationKey;return r.jsxs(F,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",color:o.palette.text.primary},children:[r.jsx(_,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},children:t("Jogging.StreamStateSection.lb")}),r.jsx(_,{variant:"body2",color:i?"error":void 0,sx:{fontSize:"0.75rem",lineHeight:1.2,textAlign:"right"},"data-testid":i?"JOG_ERROR":n,children:i?s?t(s):i:t(`Jogging.StreamStateSection.${n}.lb`)})]})}),Ke=E.observer(({store:e,children:t})=>{const{t:o}=P.useTranslation(),n=L.useTheme(),i=C.useRef(0);function s(d,l){(l==="translate"||l==="rotate")&&e.setSelectedCartesianMotionType(l)}async function a(d,l){const f=await e.activate(),p=f.motionStream.rapidlyChangingMotionState.tcp_pose,x=f.motionStream.rapidlyChangingMotionState.joint_position;p&&await e.withMotionLock(async()=>{try{e.setCurrentIncrementJog({axis:d.axis,direction:d.direction}),await e.jogger.runIncrementalCartesianMotion({currentTcpPose:p,currentJoints:x,coordSystemId:e.activeCoordSystemId,velocityInRelevantUnits:e.selectedCartesianMotionType==="translate"?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec,axis:d.axis,direction:d.direction,motion:e.selectedCartesianMotionType==="translate"?{type:"translate",distanceMm:l.mm}:{type:"rotate",distanceRads:w.degreesToRadians(l.degrees)}})}finally{e.setCurrentIncrementJog(null),await e.deactivate()}})}async function c(d){if(e.isLocked)return;const l=++i.current;try{if(await e.activate(),l!==i.current)return;if(e.activeDiscreteIncrement)return await a(d,e.activeDiscreteIncrement);d.motionType==="translate"?await e.jogger.translateTCP({axis:d.axis,direction:d.direction,velocityMmPerSec:e.translationVelocityMmPerSec}):await e.jogger.rotateTCP({axis:d.axis,direction:d.direction,velocityRadsPerSec:e.rotationVelocityRadsPerSec})}catch(f){console.error("Jogging failed:",f)}}async function g(){e.isLocked||e.activeDiscreteIncrement||(i.current++,await e.deactivate())}const h=[{id:"x",icon:r.jsx(Me,{}),colors:B.cartesianAxisColors.X},{id:"y",icon:r.jsx(Je,{}),colors:B.cartesianAxisColors.Y},{id:"z",icon:r.jsx(Oe,{}),colors:B.cartesianAxisColors.Z}];function u(d){return o("General.mm.variable",{amount:d.toFixed(1)})}function m(d){return o("General.degree.variable",{amount:w.radiansToDegrees(d).toFixed(1)})}return r.jsxs(v,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[r.jsxs(v,{gap:2,children:[r.jsx(We,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),r.jsx(Nt,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),r.jsx(q,{})]}),r.jsx(v,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:r.jsxs(v,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[r.jsxs(He,{value:e.selectedCartesianMotionType,onChange:s,exclusive:!0,"aria-label":o("Jogging.Cartesian.MotionType.lb"),sx:{justifyContent:"center"},children:[r.jsx(gt,{value:"translate",children:o("Jogging.Cartesian.Translation.bt")}),r.jsx(gt,{value:"rotate",children:o("Jogging.Cartesian.Rotation.bt")})]}),e.selectedCartesianMotionType==="translate"&&h.map(d=>{var l,f;return r.jsx(it,{"data-testid":`jogging-cartesian-axis-control-${d.id}`,"aria-label":`jogging-cartesian-axis-control-${d.id}`,colors:d.colors,disabled:e.isLocked,activeJoggingDirection:((l=e.incrementJogInProgress)==null?void 0:l.axis)===d.id?e.incrementJogInProgress.direction:void 0,label:r.jsxs(r.Fragment,{children:[d.icon,r.jsx(_,{sx:{fontSize:"24px",color:((f=d.colors)==null?void 0:f.labelColor)??n.palette.text.primary},children:d.id.toUpperCase()})]}),getDisplayedValue:()=>{var p,x;return u(((x=(p=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:p.position)==null?void 0:x[w.XYZ_TO_VECTOR[d.id]])||0)},startJogging:p=>c({axis:d.id,motionType:"translate",direction:p}),stopJogging:g},d.id)}),e.selectedCartesianMotionType==="rotate"&&h.map(d=>{var l,f;return r.jsx(it,{"data-testid":`jogging-cartesian-axis-control-${d.id}`,"aria-label":`jogging-cartesian-axis-control-${d.id}`,colors:d.colors,disabled:e.isLocked,activeJoggingDirection:((l=e.incrementJogInProgress)==null?void 0:l.axis)===d.id?e.incrementJogInProgress.direction:void 0,label:r.jsxs(r.Fragment,{children:[r.jsx(Pe,{}),r.jsx(_,{sx:{fontSize:"24px",color:((f=d.colors)==null?void 0:f.labelColor)??n.palette.text.primary},children:d.id.toUpperCase()})]}),getDisplayedValue:()=>{var p,x;return m(((x=(p=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:p.orientation)==null?void 0:x[w.XYZ_TO_VECTOR[d.id]])||0)},startJogging:p=>c({axis:d.id,motionType:"rotate",direction:p}),stopJogging:g},d.id)})]})}),r.jsx(Ot,{store:e}),r.jsx(q,{}),r.jsx($t,{store:e}),t&&r.jsx(q,{}),t]})}),Ye=E.observer(({store:e,children:t})=>{const o=L.useTheme(),n=C.useRef(0);async function i(a){const c=++n.current;try{if(await e.activate(),c!==n.current)return;await e.jogger.rotateJoints({joint:a.joint,direction:a.direction,velocityUnit:e.jointType===D.JointTypeEnum.PrismaticJoint?"mm/s":"rad/s",velocityValue:e.jointType===D.JointTypeEnum.PrismaticJoint?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec})}catch(g){console.error("Jogging failed:",g)}}async function s(){n.current++,await e.jogger.stop(),await e.deactivate()}return r.jsxs(v,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[r.jsx(Nt,{store:e,useDegree:e.jointType===D.JointTypeEnum.RevoluteJoint}),r.jsx(q,{}),r.jsx(v,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:r.jsx(v,{"data-testid":"jogging-joint-value-controls-wrapper","aria-label":"jogging-joint-value-controls-wrapper",alignItems:"center",gap:"24px",children:e.jogger.motionStream.joints.map(a=>{var g,h,u;const c=(u=(h=(g=e.motionGroupDescription.operation_limits.auto_limits)==null?void 0:g.joints)==null?void 0:h[a.index])==null?void 0:u.position;return r.jsxs(v,{"data-testid":`jogging-joint-value-control-${a.index}`,"aria-label":`jogging-joint-value-control-${a.index}`,direction:"row",alignItems:"center",justifyContent:"center",spacing:1.5,width:"100%",children:[e.showJointsLegend&&r.jsx(_,{color:e.isLocked?o.palette.text.disabled:o.palette.text.secondary,children:`G${a.index+1}`}),r.jsx(It,{disabled:e.isLocked,lowerLimit:c==null?void 0:c.lower_limit,upperLimit:c==null?void 0:c.upper_limit,useDegree:e.jointType===D.JointTypeEnum.RevoluteJoint,getValue:()=>{const m=e.jogger.motionStream.rapidlyChangingMotionState.joint_position[a.index];return m!==void 0?m:void 0},startJogging:m=>i({joint:a.index,direction:m}),stopJogging:s})]},`joint-${a.index}`)})})}),r.jsx(Ot,{store:e}),r.jsx(q,{}),r.jsx($t,{store:e}),t&&r.jsx(q,{}),t]})}),Ze=Z.externalizeComponent(E.observer(e=>{const t=E.useLocalObservable(()=>({joggingStore:null,loadingError:null}));return C.useEffect(()=>{let o=!1,n;async function i(){y.runInAction(()=>{t.loadingError=null,t.joggingStore=null});try{let s=e.store;if(!s){const a=await ot.open(e.nova,e.motionGroupId,{cellId:e.cellId});if(o){a.dispose();return}try{s=await Y.loadFor(a)}catch(c){throw a.dispose(),c}if(n=s,o){s.dispose();return}}y.runInAction(()=>{t.joggingStore=s}),e.onSetup&&e.onSetup(s)}catch(s){if(o)return;y.runInAction(()=>{t.loadingError=s})}}return i(),()=>{o=!0,n==null||n.dispose()}},[e.store,e.nova,e.motionGroupId,e.cellId]),C.useEffect(()=>{const o=t.joggingStore;o&&(e.locked?o.lock("external"):o.unlock("external"))},[t.joggingStore,e.locked]),r.jsx(v,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...e.sx},children:t.joggingStore?r.jsx(Qe,{store:t.joggingStore,children:e.children}):r.jsx(Jt,{message:"Loading jogging",error:t.loadingError})})})),Qe=E.observer(({store:e,children:t})=>{const{t:o}=P.useTranslation();function n(){if(e.currentTab.id==="cartesian")return r.jsx(Ke,{store:e,children:t});if(e.currentTab.id==="joint")return r.jsx(Ye,{store:e,children:t})}return r.jsxs(v,{flexGrow:1,sx:{overflow:"hidden"},children:[r.jsx(Zt,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:e.tabIndex,onChange:e.onTabChange,variant:"fullWidth",children:e.tabs.map(i=>{const s=i.label==="Cartesian"?o("Jogging.Cartesian.bt"):o("Jogging.Joints.bt"),a=i.label==="cartesian"?r.jsx(Ht,{fontSize:"small",sx:{mr:1}}):r.jsx(Kt,{fontSize:"small",sx:{mr:1}});return r.jsx(Yt,{"data-testid":`jogging-tab-${i.id}`,"aria-label":`jogging-tab-${i.id}`,label:e.showTabIcons?r.jsxs(v,{direction:"row",alignItems:"center",children:[a,s]}):s,id:`jogging-tab-${i.id}`,"aria-controls":`jogging-tab-${i.id}`},i.id)})}),r.jsx(v,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:n()}),e.blocked&&r.jsx(Ee,{store:e})]})});function Xe(){const e=window.location.href;return e.substring(0,e.indexOf("/",e.indexOf("//")+2))}function to({baseUrl:e=Xe(),...t}){return r.jsxs(he,{"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:[r.jsx(fe,{id:"no-motion-group-modal-title",children:"No motion group found"}),r.jsxs(pe,{sx:{marginTop:"3rem",marginBottom:"1.5rem",textAlign:"center"},children:[r.jsx(_,{color:"#fff",children:"Found no devices to connect to."}),r.jsx(_,{color:"#fff",children:"Please ensure a motion group has been created."})]}),r.jsx(me,{children:r.jsxs(v,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[r.jsx(nt,{href:`${e}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),r.jsx(nt,{href:`${e}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}const St=1e-4,eo={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class tt{constructor(t,o,n,i,s,a,c,g,h,u,m="cell"){this.controller=o,this.motionGroup=n,this.initialMotionState=i,this.motionStateSocket=s,this.isVirtual=a,this.tcps=c,this.description=g,this.initialControllerState=h,this.controllerStateSocket=u,this.cellId=m,this.connectedJoggingSocket=null,this.joggingVelocity=10,this.activationState="inactive",this.nova=b.createNovaClient(t),this.rapidlyChangingMotionState=i,this.controllerState=h,u.addEventListener("message",d=>{var f;const l=(f=w.tryParseJson(d.data))==null?void 0:f.result;l&&y.runInAction(()=>{this.controllerState=l})}),s.addEventListener("message",d=>{var f;const l=(f=w.tryParseJson(d.data))==null?void 0:f.result;if(!l)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${d.data}`);at(this.rapidlyChangingMotionState.joint_position,l.joint_position,St)||y.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=l.joint_position}),ct(this.rapidlyChangingMotionState,l,St)||y.runInAction(()=>{this.rapidlyChangingMotionState.tcp_pose=l.tcp_pose}),l.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==l.tcp&&y.runInAction(()=>{this.rapidlyChangingMotionState.tcp=l.tcp}),this.rapidlyChangingMotionState.standstill!==l.standstill&&y.runInAction(()=>{this.rapidlyChangingMotionState.standstill=l.standstill})}),y.makeAutoObservable(this)}static async connectMultiple(t,o,n={}){const i=b.createNovaClient(t),s=n.cellId??b.cellIdOf(t);return Promise.all(o.map(a=>tt.connect(i,a,{...n,cellId:s})))}static async connect(t,o,n={}){var J,R;const i=b.createNovaClient(t),s=n.cellId??b.cellIdOf(t)??"cell",[a,c]=o.split("@"),g=await i.api.controller.getCurrentRobotControllerState(s,c),h=g==null?void 0:g.motion_groups.find(I=>I.motion_group===o);if(!g||!h)throw new Error(`Controller ${c} or motion group ${o} not found`);const u=i.openReconnectingWebsocket(`/cells/${s}/controllers/${c}/motion-groups/${o}/state-stream`),m=await u.firstMessage(),d=(J=w.tryParseJson(m.data))==null?void 0:J.result;if(!d)throw new Error(`Unable to parse initial motion state message ${m.data}`);console.log(`Connected motion state websocket to motion group ${h.motion_group}. Initial state:
|
|
2
|
-
`,d);const f=(await i.api.controller.getRobotController(s,g.controller)).configuration.kind==="VirtualController",p=await i.api.motionGroup.getMotionGroupDescription(s,c,h.motion_group),x=Object.entries(p.tcps||{}).map(([I,O])=>({id:I,readable_name:O.name,position:O.pose.position,orientation:O.pose.orientation})),M=i.openReconnectingWebsocket(`/cells/${s}/controllers/${g.controller}/state-stream?response_rate=1000`),T=await M.firstMessage(),k=(R=w.tryParseJson(T.data))==null?void 0:R.result;if(!k)throw new Error(`Unable to parse initial controller state message ${T.data}`);return console.log(`Connected controller state websocket to controller ${g.controller}. Initial state:
|
|
3
|
-
`,k),new tt(i,g,h,d,u,f,x,p,k,M,s)}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,o)=>({index:o}))}get dhParameters(){if(this.description.dh_parameters!==void 0)return this.description.dh_parameters.map(t=>({...eo,...t}))}get safetyZones(){return this.description.safety_zones}get mountingPosition(){var t,o,n;return this.description.mounting?[(((t=this.description.mounting.position)==null?void 0:t[0])||0)/1e3,(((o=this.description.mounting.position)==null?void 0:o[1])||0)/1e3,(((n=this.description.mounting.position)==null?void 0:n[2])||0)/1e3]:[0,0,0]}get mountingQuaternion(){var i,s,a,c,g,h;const t=new ut.Vector3(((s=(i=this.description.mounting)==null?void 0:i.orientation)==null?void 0:s[0])||0,((c=(a=this.description.mounting)==null?void 0:a.orientation)==null?void 0:c[1])||0,((h=(g=this.description.mounting)==null?void 0:g.orientation)==null?void 0:h[2])||0),o=t.length(),n=t.normalize();return new ut.Quaternion().setFromAxisAngle(n,o)}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}y.runInAction(()=>{this.activationState="deactivating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_MONITOR"),y.runInAction(()=>{this.activationState="inactive"})}catch(t){throw y.runInAction(()=>{this.activationState="active"}),t}}async activate(){if(this.activationState!=="inactive"){console.error("Tried to activate while already activating");return}y.runInAction(()=>{this.activationState="activating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_CONTROL"),y.runInAction(()=>{this.activationState="active"})}catch(t){throw y.runInAction(()=>{this.activationState="inactive"}),t}}toggleActivation(){this.activationState==="inactive"?this.activate():this.activationState==="active"&&this.deactivate()}dispose(){this.motionStateSocket.close(),this.controllerStateSocket.close(),this.connectedJoggingSocket&&this.connectedJoggingSocket.close()}setJoggingVelocity(t){this.joggingVelocity=t}}const oo=["FeedbackOutOfWorkspace","FeedbackJointLimitExceeded","FeedbackAxisRangeExceeded","FeedbackNoSolutionInCurrentConfiguration"];function no(e){return e==="FeedbackSingularity"?"Jogging.TargetPose.Error.Singularity.lb":e==="FeedbackCollision"?"Jogging.TargetPose.Error.Collision.lb":oo.includes(e)?"Jogging.TargetPose.Error.NotReachable.lb":"Jogging.TargetPose.Error.PlanningFailed.lb"}class io{constructor(t){this.options=t,this.plannedTrajectory=null,this.trajectoryState="idle",this.lastError=null,this.disposers=[],this.logger=t.logger??console,y.makeAutoObservable(this,{socket:!1,disposers:!1,logger:!1,options:!1},{autoBind:!0}),this.socket=this.openSocket(),this.disposers.push(y.reaction(()=>this.executionState,o=>{o==="END_OF_TRAJECTORY"&&this.reset()}))}get joggingStore(){return this.options.joggingStore}get jogger(){return this.options.joggingStore.jogger}get motionStream(){return this.options.joggingStore.jogger.motionStream}get executionState(){var t,o;return(o=(t=this.motionStream.rapidlyChangingMotionState.execute)==null?void 0:t.details)==null?void 0:o.state.kind}async planTrajectory(t){var M,T,k,J,R;if((T=(M=this.options).isLocked)!=null&&T.call(M))throw this.reset(),new Error("Cannot plan trajectory: the robot is locked");await this.ensureMovementOwnership();const o=this.motionStream.rapidlyChangingMotionState.joint_position??[],{cycle_time:n,mounting:i,motion_group_model:s,tcps:a}=this.motionStream.description,c=this.joggingStore.selectedTcpId,g=c?(k=a==null?void 0:a[c])==null?void 0:k.pose:void 0,h={motion_group_model:((J=this.jogger.options)==null?void 0:J.motionGroupModel)??s,cycle_time:n??0,mounting:i,...g&&{tcp_offset:g}};let u;if(t.type==="cartesian"){let I=t.pose;const O=t.coordinateSystemId||"world";if(O!=="world")try{I=K({pose:{position:I.position??[0,0,0],orientation:I.orientation??[0,0,0]},coordinateSystemId:O},"world",this.joggingStore.coordSystems).pose}catch{return this.reset(),{ok:!1,errorFeedbackName:"FeedbackUnknown"}}u={limits_override:{tcp_velocity_limit:this.joggingStore.translationVelocityMmPerSec},path:{target_pose:I,path_definition_name:"PathCartesianPTP"}}}else u={limits_override:{joint_velocity_limits:Array(o.length).fill(this.joggingStore.rotationVelocityRadsPerSec)},path:{target_joint_position:t.joints,path_definition_name:"PathJointPTP"}};y.runInAction(()=>{this.lastError=null,this.trajectoryState="planning"});let m;try{m=await this.jogger.nova.api.trajectoryPlanning.planTrajectory(this.jogger.cellId,{motion_group_setup:h,start_joint_position:o,motion_commands:[u]})}catch(I){throw this.reset(),I}const d=m.response;if("error_feedback"in d){const I=((R=d.error_feedback)==null?void 0:R.error_feedback_name)??"FeedbackUnknown";return this.reset(),{ok:!1,errorFeedbackName:I}}const l=d.joint_positions,f=l[0],p=l[l.length-1];if(!f||!p)throw this.reset(),new Error("Trajectory returned invalid joint positions");const x={message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.jogger.motionGroupId,tcp:c||void 0,data:d}};return this.socket.sendJson(x),y.runInAction(()=>{this.plannedTrajectory={startJoints:f,endJoints:p}}),{ok:!0}}start(){if(!this.plannedTrajectory)throw new Error("Cannot start trajectory: no planned trajectory exists");if(this.trajectoryState!=="planned")throw new Error(`Cannot start trajectory: expected state "planned", got "${this.trajectoryState}"`);if(this.executionState==="RUNNING")throw new Error("Cannot start trajectory: robot is already running");const t={message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"};this.socket.sendJson(t)}async pause(){if(this.trajectoryState!=="moving")throw new Error(`Cannot pause trajectory: expected state "moving", got "${this.trajectoryState}"`);if(this.executionState==="PAUSED_BY_USER")throw new Error("Cannot pause trajectory: robot is already paused");const t={message_type:"PauseMovementRequest"};this.socket.sendJson(t),await this.waitUntilStopped(),y.runInAction(()=>{this.trajectoryState=this.plannedTrajectory?"planned":"idle"})}async stopAndReset(){try{if(this.executionState==="RUNNING"||this.trajectoryState==="moving"){const t={message_type:"PauseMovementRequest"};this.socket.sendJson(t),await this.waitUntilStopped()}}catch(t){this.logger.warn("Failed to stop trajectory execution cleanly",t)}finally{this.reset(),this.closeSocket(),this.socket=this.openSocket()}}reset(){this.plannedTrajectory=null,this.trajectoryState="idle"}clearError(){this.lastError=null}dispose(){for(const t of this.disposers)t();this.closeSocket()}async ensureMovementOwnership(){if(this.options.ensureMovementOwnership){await this.options.ensureMovementOwnership();return}this.jogger.mode!=="trajectory"&&(await this.joggingStore.deactivate(),await this.jogger.setJoggingMode("trajectory"))}async waitUntilStopped(){await y.when(()=>this.motionStream.rapidlyChangingMotionState.standstill)}handleMessage(t){var n,i;const o=(n=w.tryParseJson(t.data))==null?void 0:n.result;if(o)switch(o.kind){case"INITIALIZE_RECEIVED":o.add_trajectory_error||o.message?(this.lastError=((i=o.add_trajectory_error)==null?void 0:i.message)??o.message??"NOVA refused the trajectory",this.reset()):this.trajectoryState="planned";break;case"START_RECEIVED":this.trajectoryState="moving";break;case"PAUSE_RECEIVED":this.trajectoryState==="moving"&&(this.trajectoryState="stopping");break;case"MOTION_ERROR":this.lastError=o.message,this.reset();break}}openSocket(){const t=this.jogger.nova.openReconnectingWebsocket(`/cells/${this.jogger.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);return t.addEventListener("message",this.handleMessage),t}closeSocket(){this.socket.removeEventListener("message",this.handleMessage),this.socket.dispose()}}exports.AppHeader=ye;exports.ConnectedMotionGroup=tt;exports.JoggerConnection=ot;exports.JoggingCartesianAxisControl=it;exports.JoggingJointValueControl=It;exports.JoggingPanel=Ze;exports.JoggingStore=Y;exports.LoadingCover=Jt;exports.LoadingErrorMessage=Rt;exports.MotionStreamConnection=et;exports.NoMotionGroupModal=to;exports.TrajectoryExecutionStore=io;exports.VelocitySlider=Lt;exports.VelocitySliderLabel=lt;exports.deriveSelectedTcpPose=Fe;exports.jointValuesEqual=_t;exports.jointValuesUnchanged=at;exports.planErrorTranslationKey=no;exports.poseEqual=Et;exports.readoutOf=Mt;exports.readoutsEqual=kt;exports.resolveCoordinateSystemInWorld=Vt;exports.tcpMotionEqual=ct;exports.transformPoseToCoordinateSystem=K;exports.unwrapRotationVector=Tt;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const d=require("three");function g(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const r=g(d);function y(n){try{return JSON.stringify(n)}catch{return}}function b(n){const e=n.length(),t=new r.Quaternion;if(e>1e-6){const o=n.clone().normalize();t.setFromAxisAngle(o,e)}return t}function z(n){if(!n||n.length===0)return 5;const o=n.reduce((i,c)=>i+Math.abs(c.a??0)/1e3+Math.abs(c.d??0)/1e3,0)*2;return!Number.isFinite(o)||o<=0?5:o}function V(n){if(n.length<3)return console.log("Not enough vertices to define a plane"),{isCoplanar:!1};const e=new r.Vector3(n[0].x,n[0].y,n[0].z),t=new r.Vector3(n[1].x,n[1].y,n[1].z),o=new r.Vector3(n[2].x,n[2].y,n[2].z),i=new r.Vector3().subVectors(t,e),c=new r.Vector3().subVectors(o,e),s=new r.Vector3().crossVectors(i,c).normalize();for(let a=3;a<n.length;a++){const u=new r.Vector3(n[a].x,n[a].y,n[a].z),l=new r.Vector3().subVectors(u,e),f=s.dot(l);if(Math.abs(f)>1e-6)return console.log("Vertices are not on the same plane"),{isCoplanar:!1}}return{isCoplanar:!0,normal:s}}exports.dhParametersToPlaneSize=z;exports.orientationToQuaternion=b;exports.tryStringifyJson=y;exports.verticesToCoplanarity=V;
|