@transitive-sdk/utils-web 0.9.4 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/hooks.jsx CHANGED
@@ -1,17 +1,29 @@
1
1
  import React, { useState, useEffect, useMemo } from 'react';
2
2
  import _ from 'lodash';
3
3
  import mqtt from 'mqtt-browser';
4
- import { decodeJWT, getLogger, clone, pathToTopic } from './client';
4
+ import { decodeJWT, getLogger, clone, pathToTopic, mergeVersions, topicToPath }
5
+ from './client';
5
6
  const MqttSync = require('../../common/MqttSync');
6
7
 
7
8
  const log = getLogger('utils-web/hooks');
8
9
  log.setLevel('info');
10
+ log.setLevel('debug'); // #DEBUG
9
11
 
10
- /** hook for using MqttSync in React */
12
+ /** Hook for using MqttSync in React.
13
+ @returns {object} An object `{data, mqttSync, ready, StatusComponent, status}`
14
+ where:
15
+ `data` is a reactive data source in React containing all the data received by
16
+ mqttsync,
17
+ `mqttSync` is the MqttSync object itself,
18
+ `ready` indicates when mqttSync is ready to be used (connected and received
19
+ successfully subscribed to mqtt system heartbeats)
20
+ */
11
21
  export const useMqttSync = ({jwt, id, mqttUrl}) => {
12
22
  const [status, setStatus] = useState('connecting');
13
23
  const [mqttSync, setMqttSync] = useState();
14
24
  const [data, setData] = useState({});
25
+ // True once the subscription to the system heartbeat has been granted.
26
+ const [heartbeatGranted, setHeartbeatGranted] = useState(false);
15
27
 
16
28
  useEffect(() => {
17
29
  const payload = decodeJWT(jwt);
@@ -24,7 +36,8 @@ export const useMqttSync = ({jwt, id, mqttUrl}) => {
24
36
  log.debug('connected');
25
37
  const mqttSyncClient = new MqttSync({
26
38
  mqttClient: client,
27
- ignoreRetain: true
39
+ ignoreRetain: true,
40
+ onHeartbeatGranted: () => setHeartbeatGranted(true)
28
41
  });
29
42
  setMqttSync(mqttSyncClient);
30
43
  setStatus('connected');
@@ -52,7 +65,8 @@ export const useMqttSync = ({jwt, id, mqttUrl}) => {
52
65
 
53
66
  return {
54
67
  status,
55
- ready: status == 'connected',
68
+ // ready: status == 'connected',
69
+ ready: heartbeatGranted,
56
70
  StatusComponent: () => <div>{status}</div>,
57
71
  mqttSync, // Note: mqttSync.data is not reactive.
58
72
  data, // This is a reactive data-source (to use meteor terminology).
@@ -77,3 +91,140 @@ export const useTransitive = ({jwt, id, host, ssl, capability, versionNS}) => {
77
91
  return {...fromMqttSync, device, prefixPath, prefix, prefixPathVersion,
78
92
  prefixVersion};
79
93
  };
94
+
95
+
96
+ /** Subscribe to MqttSync topics using the provided JWT. This will
97
+ automatically find which version of the capability named in the JWT is running
98
+ on the device of the JWT and get the data for that version.
99
+
100
+ Example usage (with webrtc-video):
101
+
102
+ ```js
103
+ const { agentStatus, topicData } = useTopics({ jwt, topics: [
104
+ '/options/videoSource',
105
+ '/stats/+/log/'
106
+ ]});
107
+ ```
108
+
109
+ @param {object} options An object containing:
110
+ `JWT`: A list of subtopics of the capability named in the JWT.
111
+ `topics`: A list of subtopics of the capability named in the JWT.
112
+ @returns {object} An object `{data, mqttSync, ready, agentStatus, topicData}`
113
+ where:
114
+ * `agentStatus` is the `status` field of the running robot agent, including
115
+ heartbeat and runningPackages, and
116
+ * `topicData` is the data for the selected topics of the capability
117
+ */
118
+ export const useTopics = ({jwt, host = 'transitiverobotics.com', ssl = true,
119
+ topics = []}) => {
120
+
121
+ // We need to make sure we don't resubscribe (below) when this function
122
+ // is called with the same content of `topics` but a different object.
123
+ const [topicList, setTopicList] = useState();
124
+ !_.isEqual(topicList, topics) && setTopicList(topics);
125
+
126
+ const {device, id, capability} = decodeJWT(jwt);
127
+ if (device == '_fleet') {
128
+ log.warn('useTopics only works for device JWTs, not _fleet ones');
129
+ return;
130
+ }
131
+
132
+ const agentPrefix = `/${id}/${device}/@transitive-robotics/_robot-agent/+/status`;
133
+
134
+ const {mqttSync, data, status, ready, StatusComponent} =
135
+ useMqttSync({jwt, id, mqttUrl: `ws${ssl ? 's' : ''}://mqtt.${host}`});
136
+
137
+ useEffect(() => {
138
+ if (ready) {
139
+ mqttSync.subscribe(agentPrefix, (err) => err && console.warn(err));
140
+ }
141
+ }, [mqttSync, ready]);
142
+
143
+ const agentStatus = mergeVersions(
144
+ data[id]?.[device]['@transitive-robotics']['_robot-agent'], 'status').status;
145
+ const runningPackages = agentStatus?.runningPackages;
146
+
147
+ const [scope, capName] = capability.split('/');
148
+ const versions = runningPackages?.[scope]?.[capName];
149
+ const runningVersion = versions && Object.values(versions).filter(Boolean)[0];
150
+ const prefix = `/${id}/${device}/${capability}/${runningVersion}`;
151
+
152
+ useEffect(() => {
153
+ log.debug('topics', topics);
154
+ if (runningVersion) {
155
+ topics.forEach(topic => {
156
+ log.debug(`subscribing to ${prefix}${topic}`);
157
+ mqttSync.subscribe(`${prefix}${topic}`,
158
+ (err) => err && log.warn(err));
159
+ });
160
+ }
161
+ }, [topicList, runningVersion, mqttSync]);
162
+
163
+ const topicData = _.get(data, topicToPath(prefix));
164
+ // log.debug(data, agentStatus, topicData);
165
+
166
+ return {data: data?.[id]?.[device], mqttSync, agentStatus, topicData};
167
+ };
168
+
169
+
170
+ const listeners = {};
171
+ const loadedModules = {};
172
+ /** Hook to load a Transitive capability. Besides loading the custom element,
173
+ this hook also returns any functions and objects the component exports in
174
+ `loadedModule`. Example:
175
+ ```js
176
+ const {loaded, loadedModule} = useCapability({
177
+ capability: '@transitive-robotics/terminal',
178
+ name: 'mock-device',
179
+ userId: 'user123',
180
+ deviceId: 'd_mydevice123',
181
+ });
182
+ ```
183
+ */
184
+ export const useCapability = ({ capability, name, userId, deviceId,
185
+ host = 'transitiverobotics.com', ssl = true, testing = false
186
+ }) => {
187
+
188
+ const [returns, setReturns] = useState({ loaded: false });
189
+
190
+ // called when loaded
191
+ const done = (message, theModule) => {
192
+ log.debug(`custom component ${name}: ${message}`);
193
+ loadedModules[name] = theModule;
194
+ setReturns(x => ({...x, loadedModule: theModule, loaded: !!theModule}));
195
+ };
196
+
197
+ /** set the returns for all listeners */
198
+ const notifyListeners = (...args) => listeners[name].forEach(l => l(...args));
199
+
200
+ useEffect(() => {
201
+ log.debug(`loading custom component ${name}`);
202
+
203
+ if (loadedModules[name]) {
204
+ return done('already loaded', loadedModules[name]);
205
+ }
206
+ if (listeners[name]) {
207
+ log.debug('already loading');
208
+ // get notified when loading completes
209
+ return listeners[name].push(done);
210
+ }
211
+ listeners[name] = [done];
212
+
213
+ const baseUrl = testing ? '' : // for testing
214
+ `http${ssl ? 's' : ''}://portal.${host}`;
215
+ const params = new URLSearchParams({userId, deviceId});
216
+ // filename without extension as we'll try multiple
217
+ const fileBasename = `${baseUrl}/running/${capability}/dist/${name}`;
218
+
219
+ import(`${fileBasename}.esm.js?${params.toString()}`).then(
220
+ esm => notifyListeners('loaded esm', esm),
221
+ error => {
222
+ log.warn(`No ESM module found for ${name}, loading iife`);
223
+ import(`${fileBasename}.js?${params.toString()}`).then(
224
+ iife => notifyListeners('loaded iife', iife),
225
+ error => log.error(`Failed to load ${name} iife`, error));
226
+ });
227
+ }, [capability, name, userId, deviceId]);
228
+
229
+ return returns;
230
+ };
@@ -94,5 +94,7 @@ module.exports = {
94
94
  }
95
95
 
96
96
  customElements.define(tagName, proto);
97
+
98
+ return proto;
97
99
  },
98
100
  };
package/client/shared.jsx CHANGED
@@ -3,7 +3,8 @@ import { Button, Accordion, AccordionContext, Card, Badge }
3
3
  from 'react-bootstrap';
4
4
  import ReactWebComponent from './react-web-component';
5
5
 
6
- import { parseCookie } from './client';
6
+ import { parseCookie, decodeJWT } from './client';
7
+ import { useCapability } from './hooks';
7
8
 
8
9
  const styles = {
9
10
  badge: {
@@ -102,6 +103,51 @@ export const Timer = ({duration, onTimeout, onStart, setOnDisconnect, children})
102
103
  </TimerContext.Provider>;
103
104
  };
104
105
 
106
+
107
+ /** Dynamically load and use the Transitive web component specified in the JWT.
108
+ * Embedding Transitive components this way also enables the use of functional
109
+ * and object properties, which get lost when using the custom element (Web
110
+ * Component) because HTML attributes are strings.
111
+ * Example:
112
+ ```js
113
+ <TransitiveCapability jwt={jwt}
114
+ myconfig={{a: 1, b: 2}}
115
+ onData={(data) => setData(data)}
116
+ onclick={() => { console.log('custom click handler'); }}
117
+ />
118
+ ```
119
+ */
120
+ export const TransitiveCapability = ({jwt, ssl = true,
121
+ host = 'transitiverobotics.com', testing = false,
122
+ ...config }) => {
123
+
124
+ const {id, device, capability} = decodeJWT(jwt);
125
+ const type = device == '_fleet' ? 'fleet' : 'device';
126
+ const capName = capability.split('/')[1];
127
+ const name = `${capName}-${type}`;
128
+
129
+ const { loaded } = useCapability({
130
+ capability,
131
+ name,
132
+ userId: id || config.userId, // accept both id and userId, see #492
133
+ deviceId: device,
134
+ testing,
135
+ host,
136
+ ssl
137
+ });
138
+
139
+ const ref = useRef();
140
+ // Attach functional and object properties to the component when ready
141
+ useEffect(() => {
142
+ ref.current?.instance?.setState(s =>
143
+ ({ ...s, id, jwt, host, ssl, ...config }));
144
+ }, [ref.current]);
145
+
146
+ if (!loaded) return <div>Loading {name}</div>;
147
+ return React.createElement(name, {id, jwt, host, ssl, ...config, ref});
148
+ };
149
+
150
+
105
151
  /** A simple error boundary. Usage:
106
152
  ```jsx
107
153
  <ErrorBoundary message="Something went wrong">
@@ -130,6 +176,7 @@ export class ErrorBoundary extends React.Component {
130
176
  }
131
177
  };
132
178
 
179
+
133
180
  /* whether or not the given react component allows refs, i.e., is either
134
181
  * a functional component wrapped with forwardRef or a class component */
135
182
  const componentPermitsRefs = (Component) =>
@@ -216,6 +263,6 @@ export const createWebComponent = (Component, name, version = '0.0.0',
216
263
  }
217
264
  };
218
265
 
219
- ReactWebComponent.create(Wrapper, name, options.shadowDOM || false,
266
+ return ReactWebComponent.create(Wrapper, name, options.shadowDOM || false,
220
267
  compRef);
221
268
  };
package/dist/utils-web.js CHANGED
@@ -1 +1,15 @@
1
- (()=>{var e={720:(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.set(e,n)}function c(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,s(e,t,"get"))}function u(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,s(e,t,"set"),n),n}function s(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var l={get:n(712),set:n(298),unset:n(305),forEach:n(848),map:n(707),isEmpty:n(699),eq:n(113),isPlainObject:n(452),merge:n(831)},f=n(362),p=f.topicToPath,h=f.pathToTopic,b=f.toFlatObject,d=f.topicMatch,y=f.forMatchIterator,v=function e(t,n){if(n&&0!=n.length){l.unset(t,n);var r=n.slice(0,-1),o=0==r.length?t:l.get(t,r);return l.isEmpty(o)?e(t,r):n}},g=function e(t,n){if(0!=n.length){var r=n[0];if(r)for(var o in t)o==r||"*"==r||r.startsWith("+")?e(t[o],n.slice(1)):delete t[o]}},m=new WeakMap,O=new WeakMap,w=new WeakMap,j=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,e),a(this,m,{writable:!0,value:{}}),a(this,O,{writable:!0,value:[]}),a(this,w,{writable:!0,value:[]}),u(this,m,t)}var t,n;return t=e,n=[{key:"updateFromArray",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=l.get(c(this,m),e);if(null==t){if(null==o)return{};v(c(this,m),e)}else{if(l.eq(o,t))return{};l.set(c(this,m),e,t)}var i,a=h(e),u=r({},a,t);if(t instanceof Object){var s=b(t);i={},l.forEach(s,(function(e,t){i["".concat(a).concat(t)]=e}))}else i=u;return c(this,O).forEach((function(e){return e(u,n)})),c(this,w).forEach((function(e){return e(i,n)})),i}},{key:"update",value:function(e,t,n){if("string"==typeof e)return this.updateFromTopic(e,t,n);if(e instanceof Array)return this.updateFromArray(e,t,n);throw new Error("unrecognized path expression")}},{key:"updateFromTopic",value:function(e,t,n){return this.updateFromArray(p(e),t,n)}},{key:"updateFromModifier",value:function(e,t){var n=this;return l.map(e,(function(e,r){return n.updateFromTopic(r,e,t)}))}},{key:"subscribe",value:function(e){e instanceof Function?c(this,O).push(e):console.warn("DataCache.subscribe expects a function as argument. Did you mean to use subscribePath?")}},{key:"subscribePath",value:function(e,t){c(this,O).push((function(n,r){l.forEach(n,(function(n,o){var i=d(e,o);i&&t(n,o,i,r)}))}))}},{key:"subscribePathFlat",value:function(e,t){c(this,w).push((function(n,r){l.forEach(n,(function(n,o){var i=d(e,o);i&&t(n,o,i,r)}))}))}},{key:"unsubscribe",value:function(e){u(this,O,c(this,O).filter((function(t){return t!=e})))}},{key:"get",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return 0==e.length?c(this,m):l.get(c(this,m),e)}},{key:"getByTopic",value:function(e){return this.get(p(e))}},{key:"filter",value:function(e){var t=JSON.parse(JSON.stringify(this.get()));return g(t,e),t}},{key:"filterByTopic",value:function(e){return this.filter(p(e))}},{key:"forMatch",value:function(e,t){var n=p(e);this.forPathMatch(n,t)}},{key:"forPathMatch",value:function(e,t){y(this.get(),e,t)}}],n&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports={DataCache:j,updateObject:function(e,t){return l.forEach(t,(function(t,n){var r=p(n);null==t?v(e,r):l.set(e,r,t)})),e}}},890:(e,t,n)=>{"use strict";function r(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}var s=n(362),l=s.mqttParsePayload,f=s.topicMatch,p=s.topicToPath,h=s.pathToTopic,b=s.toFlatObject,d=s.getLogger,y=s.mergeVersions,v=s.parseMQTTTopic,g=(s.isSubTopicOf,s.versionCompare),m=s.encodeTopicElement,O=s.visitAncestor,w=n(720).DataCache,j=n(517),S=d("MqttSync"),E="$SYS/broker/uptime",P="$_",k=function(){},T=function(e){return e.endsWith("/#")?e:e.endsWith("/")?e.concat("#"):e.concat("/#")},C=function(e){return e.replace(/\/\//g,"/")},x=function(){function e(t){var n=this,o=t.mqttClient,i=t.onChange,a=t.ignoreRetain,u=t.migrate,s=t.onReady,f=t.sliceTopic;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c(this,"data",new w),c(this,"subscribedPaths",{}),c(this,"publishedPaths",{}),c(this,"publishedMessages",new w),c(this,"publishQueue",new Map),c(this,"heartbeatWaitersOnce",[]),c(this,"heartbeats",0),c(this,"beforeDisconnectHooks",[]),this.mqtt=o,this.mqtt.on("message",(function(e,t,o){var c=t&&t.toString();if(S.debug("got message",e,c.slice(0,180),c.length>180?"... (".concat(c.length," bytes)"):"",o.retain),e==E)n.heartbeats>0&&(n.heartbeatWaitersOnce.forEach((function(e){return e()})),n.heartbeatWaitersOnce=[]),1==n.heartbeats&&!u&&s&&s(),n.heartbeats++;else if(o.retain||a){var b=p(e);S.debug("processing message",e,b),f&&(b=b.slice(f),e=h(b));var d=l(t);if(n.isPublished(e))n.publishedMessages.updateFromArray([].concat(r(b),[P]),d),n.data.update(e,d,{external:!0});else if(n.isSubscribed(e)){S.debug("applying received update",e);var y=n.data.update(e,d);i&&Object.keys(y).length>0&&i(y)}}})),this.mqtt.subscribe(E,{rap:!0},S.debug),(null==u?void 0:u.length)>0&&this.migrate(u,(function(){S.debug("done migrating",s),s&&n.waitForHeartbeatOnce(s)}))}var t,n;return t=e,n=[{key:"publishAtLevel",value:function(e,t,n){var r=this;S.debug("publishingAtLevel ".concat(n),e,t),n>0?j.forEach(t,(function(t,o){var i="".concat(e,"/").concat(m(o));S.debug("publishing ".concat(i)),r.publishAtLevel(i,t,n-1)})):this.mqtt.publish(e,JSON.stringify(t),{retain:!0},(function(e){e&&S.warn("Error when publishing migration result",e)}))}},{key:"migrate",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=e.length;if(0!=r){var o=function(){return 0==--r&&n&&n()};e.forEach((function(e){var n=e.topic,r=e.newVersion,i=e.transform,a=void 0===i?void 0:i,c=e.flat,u=void 0!==c&&c,s=e.level,l=void 0===s?0:s;S.debug("migrating",n,r);var f=v(n),d=f.organization,m=f.device,O=f.capability,w=f.sub,E="/".concat(d,"/").concat(m,"/").concat(O),P=0==w.length?"/#":h(w),k="".concat(E,"/+").concat(P);t.subscribe(k,(function(e){if(e)return S.warn("Error during migration",e),void o();t.waitForHeartbeatOnce((function(){S.debug("got heartbeat",n,k);var e=t.data.getByTopic(E);if(!e)return t.unsubscribe(k),void o();var i=y(e,P,{maxVersion:r}),c=j.get(i,p(P)),s=a?a(c):c,f=C("".concat(E,"/").concat(r,"/").concat(P));if(S.debug("publishing merged",f),u){var d=b(s),v=p(f);j.forEach(d,(function(e,n){var r=h(v.concat(p(n)));t.mqtt.publish(r,JSON.stringify(e),{retain:!0},(function(e){e&&S.warn("Error when publishing migration result for ".concat(n),e)}))}))}else t.publishAtLevel(f,s,l);t.unsubscribe(k),t.waitForHeartbeatOnce((function(){var n=Object.keys(e).filter((function(e){return g(e,r)<0})).map((function(e){return C("".concat(E,"/").concat(e,"/").concat(P))}));S.debug({prefixesToClear:n}),t.clear(n),o()}))}))}))}))}else n&&n()}},{key:"clear",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=[],i=function(t){e.forEach((function(e){return f("".concat(e,"/#"),t)&&(!r.filter||r.filter(t))&&o.push(t)}))};this.mqtt.on("message",i),e.forEach((function(e){"string"==typeof e?t.mqtt.subscribe("".concat(e,"/#")):S.warn("Ignoring",e,"since it is not a string.")}));var a="undefined"!=typeof Buffer?Buffer.alloc(0):null;this.waitForHeartbeatOnce((function(){t.mqtt.removeListener("message",i),e.forEach((function(e){return t.mqtt.unsubscribe("".concat(e,"/#"))}));var r=o.length;S.debug("clearing ".concat(r," retained messages from ").concat(e)),o.forEach((function(e){t.mqtt.publish(e,a,{retain:!0})})),n&&n(r)}))}},{key:"waitForHeartbeatOnce",value:function(e){var t=this;setTimeout((function(){return t.heartbeatWaitersOnce.push(e)}),1)}},{key:"isSubscribed",value:function(e){return Object.keys(this.subscribedPaths).some((function(t){return f(t,e)}))}},{key:"isPublished",value:function(e){var t=this;return Object.keys(this.publishedPaths).some((function(n){return f(n,e)&&!t.publishedPaths[n].atomic}))}},{key:"subscribe",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;if(e=T(e),this.subscribedPaths[e])return S.debug("already subscribed to",e),void n();this.mqtt.subscribe(e,{rap:!0},(function(r,o){S.debug("subscribe",e,"granted:",o),o&&o.some((function(t){return t.topic==e&&t.qos<128}))?(t.subscribedPaths[e]=1,n(null)):n("not permitted to subscribe to topic ".concat(e,", ").concat(JSON.stringify(o)))}))}},{key:"unsubscribe",value:function(e){this.subscribedPaths[e]&&(this.mqtt.unsubscribe(e),delete this.subscribedPaths[e])}},{key:"_actuallyPublish",value:function(e,t){return this.mqtt.connected?(S.debug("actually publishing",e),this.mqtt.publish(e,null==t?null:JSON.stringify(t),{retain:!0}),!0):(S.warn("not connected, not publishing",e),!1)}},{key:"_processQueue_rec",value:function(e){var t=this;if(this.publishQueue.size>0){var n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||o(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.publishQueue.entries().next().value,2),r=n[0],i=n[1];this._actuallyPublish(r,i)?(this.publishQueue.delete(r),this._processQueue_rec(e)):setTimeout((function(){return t._processQueue_rec(e)}),5e3)}else e()}},{key:"_processQueue",value:function(){var e=this;this._processing||(this._processing=!0,this._processQueue_rec((function(){return e._processing=!1})))}},{key:"setThrottle",value:function(e){this._processQueueThrottled=j.throttle(this._processQueue.bind(this),e)}},{key:"clearThrottle",value:function(){delete this._processQueueThrottled}},{key:"addToQueue",value:function(e,t){this.publishQueue.set(e,t)}},{key:"_enqueue",value:function(e,t){S.debug("enqueuing",e),this.addToQueue(e,t),this._processQueueThrottled?this._processQueueThrottled():this._processQueue();var n,o=p(e);this.publishedMessages.updateFromArray([].concat(r(o),[P]),null==t?null:"object"==u(n=t)?JSON.parse(JSON.stringify(n)):n)}},{key:"publish",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{atomic:!1};return e=T(e),!j.isEqual(this.publishedPaths[e],n)&&(this.publishedPaths[e]=n,n.atomic?(this.data.subscribePath(e,(function(n,r,o,i){if(null==i||!i.external){S.debug("processing change (atomic)",r,e);var a=e.slice(0,e.length-2),c=h(p(r).slice(0,p(a).length));t._enqueue(c,t.data.getByTopic(c))}})),!0):(this.mqtt.subscribe(e),void this.data.subscribePath(e,(function(e,n,r,o){if(null==o||!o.external){S.debug("processing change",n);var i=p(n),a=t.publishedMessages.get(i);j.each(a,(function(e,r){if(r==P)return!0;var o=Object.keys(b(e)).filter((function(e){return e.endsWith(P)}));S.debug("flat->atomic: ",{toClear:o},r),o.forEach((function(e){var o=e.slice(0,-(P.length+1)),i="".concat(n,"/").concat(r,"/").concat(o);t._enqueue(i,null)}))}));var c=t.publishedMessages.get();return O(c,i.slice(0,-1),(function(e,n){var r=e.$_;if(r&&j.isObject(r)){S.debug("atomic->flat",{oldVal:r});var o=h(n);t._enqueue(o,null);var i=b(r);j.each(i,(function(e,n){var r="".concat(o).concat(n);t._enqueue(r,e)}))}})),t._enqueue(n,e),!0}}))))}},{key:"beforeDisconnect",value:function(){var e=this;this.beforeDisconnectHooks.forEach((function(t){return t(e)}))}},{key:"onBeforeDisconnect",value:function(e){this.beforeDisconnectHooks.push(e)}}],n&&a(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports=x},362:(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(13),i=n(84),a={get:n(712),set:n(298),unset:n(305),forEach:n(848),map:n(707),isEmpty:n(699),eq:n(113),isPlainObject:n(452),merge:n(831)},c=n(622),u=n(22),s=n(499);c.setAll=function(e){return Object.values(c.getLoggers()).forEach((function(t){return t.setLevel(e)}))};var l={warn:u.yellow,error:u.red,info:u.green,debug:u.gray},f=c.methodFactory;c.methodFactory=function(e,t,n){var r=f(e,t,n);if("undefined"!=typeof window){var o="".concat(n," ").concat(e);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(void 0,["[".concat(o,"]")].concat(t))}}var i,a="".concat(n," ").concat(l[i=e]?l[i](i):i);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(void 0,["[".concat(u.blue((new Date).toISOString())," ").concat(a,"]")].concat(t))}};var p=c.getLogger,h=function(e){return e.replace(/%/g,"%25").replace(/\//g,"%2F")},b=function(e){return e.replace(/%25/g,"%").replace(/%2F/g,"/")},d=function(e){return"/".concat(e.map((function(e){return e.startsWith("+")?"+":e})).map(h).join("/"))},y=function(e){var t=e.split("/").map(b);return t.length>0&&0==t[0].length&&t.shift(),t.length>0&&0==t.at(-1).length&&t.pop(),t},v=function(e,t){return function e(t,n){if(0==t.length)return!0;if("#"==t[0][0])return!0;if(0==n.length)return!0;if(t[0]==n[0])return e(t.slice(1),n.slice(1));if("+"==t[0][0]){var o=e(t.slice(1),n.slice(1));return o&&Object.assign(r({},t[0].slice(1),n[0]),o)}return!1}(y(e),y(t))},g=function e(t,n){return 0==t.length||t[0]==n[0]&&e(t.slice(1),n.slice(1))},m=function(e,t){return o(i(e),i(t))},O=["B","KB","MB","GB","TB"];e.exports={parseMQTTUsername:function(e){var t=e.split(":");return{organization:t[0],client:t[1],sub:t.slice(2)}},parseMQTTTopic:function(e){var t=y(e);return{organization:t[0],device:t[1],capabilityScope:t[2],capabilityName:t[3],capability:"".concat(t[2],"/").concat(t[3]),version:t[4],sub:t.slice(5)}},pathToTopic:d,topicToPath:y,toFlatObject:function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a.forEach(t,(function(t,o){var i=n.concat(String(o));(a.isPlainObject(t)||t instanceof Array)&&null!==t?e(t,i,r):r[d(i)]=t})),r},topicMatch:v,mqttParsePayload:function(e){return 0==e.length?null:JSON.parse(e.toString("utf-8"))},getRandomId:function(){return Math.random().toString(36).slice(2)},versionCompare:m,loglevel:c,getLogger:p,mergeVersions:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e)return t?a.set({},t,e):e;var r=Object.keys(e).filter((function(e){return(!n.maxVersion||m(e,n.maxVersion)<=0)&&(!n.minVersion||m(n.minVersion,e)<=0)})).sort(m),o={},i=t&&y(t);return r.forEach((function(t){var n=i?a.get(e[t],i):e[t];a.merge(o,n)})),i?a.set({},i,o):o},mqttClearRetained:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e3,o=[],i=function(e){t.forEach((function(t){return v("".concat(t,"/#"),e)&&o.push(e)}))};e.on("message",i),t.forEach((function(t){"string"==typeof t?e.subscribe("".concat(t,"/#")):console.warn("Ignoring",t,"since it is not a string.")}));var a="undefined"!=typeof Buffer?Buffer.alloc(0):null;setTimeout((function(){e.removeListener("message",i),t.forEach((function(t){return e.unsubscribe("".concat(t,"/#"))}));var r=o.length;console.log("clearing ".concat(r," retained messages from ").concat(t)),o.forEach((function(t){e.publish(t,a,{retain:!0})})),n&&n(r)}),r)},isSubTopicOf:function(e,t){var n=y(t),r=y(e);return g(n,r)&&n.length<r.length},clone:function(e){return JSON.parse(JSON.stringify(e))},setFromPath:function e(t,n,r){if(0==n.length)return t;var o=n.shift();0==n.length?t[o]=r:(t[o]||(t[o]={}),e(t[o],n,r))},forMatchIterator:function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(0!=n.length&&"#"!=n[0]){var c=n[0];if(c)for(var u in t)if(u==c||"*"==c||c.startsWith("+")){var s=c.startsWith("+")&&c.length>1?Object.assign({},a,r({},c.slice(1),u)):a;e(t[u],n.slice(1),o,i.concat([u]),s)}}else o(t,i,a)},encodeTopicElement:h,decodeTopicElement:b,constants:s,visit:function e(t,n,r){var o;t&&(r(t),null===(o=t[n])||void 0===o||o.forEach((function(t){return e(t,n,r)})))},wait:function(e){return new Promise((function(t){setTimeout(t,e)}))},formatBytes:function(e){if(!e)return"--";for(var t=0;e>1024;)e/=1024,t++;return"".concat(e.toFixed(2)," ").concat(O[t])},formatDuration:function(e){if(!e)return"--";var t={};e>3600&&(t.h=Math.floor(e/3600),e%=3600),e>60&&(t.m=Math.floor(e/60),e%=60),t.s=Math.floor(e);var n="";return t.h>0&&(n+="".concat(t.h,"h ")),t.m>0&&(n+="".concat(t.m,"m ")),!t.h&&(n+="".concat(t.s,"s")),n.trim()},tryJSONParse:function(e){try{return JSON.parse(e)}catch(e){return null}},decodeJWT:function(e){return JSON.parse(atob(e.split(".")[1]))},visitAncestor:function e(t,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];r(t,o);var i=n[0];if(i){var a=t[i];a&&e(a,n.slice(1),r,o.concat(i))}}}},499:e=>{e.exports={rosReleases:{kinetic:{rosVersion:1,ubuntuCodename:"xenial"},melodic:{rosVersion:1,ubuntuCodename:"bionic"},noetic:{rosVersion:1,ubuntuCodename:"focal"},dashing:{rosVersion:2},eloquent:{rosVersion:2},foxy:{rosVersion:2},galactic:{rosVersion:2},humble:{rosVersion:2},iron:{rosVersion:2},rolling:{rosVersion:2}}}},216:(e,t,n)=>{"use strict";n.r(t),n.d(t,{MqttSync:()=>l,fetchJson:()=>p,parseCookie:()=>f});var r=n(362),o={};for(const e in r)["default","MqttSync","parseCookie","fetchJson"].indexOf(e)<0&&(o[e]=()=>r[e]);n.d(t,o);var i=n(720);o={};for(const e in i)["default","MqttSync","parseCookie","fetchJson"].indexOf(e)<0&&(o[e]=()=>i[e]);n.d(t,o);var a=n(890);function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=n.n(a)(),f=function(e){return e.split(";").map((function(e){return e.split("=")})).reduce((function(e,t){return e[decodeURIComponent(t[0].trim())]=t[1]&&decodeURIComponent(t[1].trim()),e}),{})},p=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};fetch(e,{method:n.method||(n.body?"post":"get"),mode:"cors",cache:"no-cache",headers:u({"Content-Type":"application/json"},n.headers),redirect:"follow",referrerPolicy:"no-referrer",body:n.body?JSON.stringify(n.body):void 0}).then((function(n){var r=!n.ok&&"fetching ".concat(e," failed: ").concat(n.status," ").concat(n.statusText);n.json().then((function(e){return t(r,e)})).catch((function(e){throw new Error(e)}))})).catch((function(e){return t("error: ".concat(e))}))}},782:(e,t,n)=>{"use strict";n.d(t,{H:()=>v,D:()=>g});var r=n(689),o=n.n(r),i=n(517),a=n.n(i);const c=require("mqtt-browser");var u=n.n(c),s=n(216);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var d=n(890),y=(0,s.getLogger)("utils-web/hooks");y.setLevel("info");var v=function(e){var t=e.jwt,n=e.id,i=e.mqttUrl,c=h((0,r.useState)("connecting"),2),l=c[0],f=c[1],p=h((0,r.useState)(),2),b=p[0],v=p[1],g=h((0,r.useState)({}),2),m=g[0],O=g[1];return(0,r.useEffect)((function(){var e=(0,s.decodeJWT)(t),r=u().connect(i,{username:JSON.stringify({id:n,payload:e}),password:t});return r.on("connect",(function(){y.debug("connected");var e=new d({mqttClient:r,ignoreRetain:!0});v(e),f("connected"),e.data.subscribe(a().throttle((function(){return O((0,s.clone)(e.data.get()))}),50))})),r.on("error",(function(e){y.error(e),f("error: ".concat(e))})),function(){y.info("cleaning up useMQTTSync"),b&&b.beforeDisconnect?(b.beforeDisconnect(),b.waitForHeartbeatOnce((function(){return r.end()}))):r.end()}}),[t,n]),{status:l,ready:"connected"==l,StatusComponent:function(){return o().createElement("div",null,l)},mqttSync:b,data:m}},g=function(e){var t=e.jwt,n=e.id,r=e.host,o=e.ssl,i=e.capability,a=e.versionNS,c=h(i.split("/"),2),u=c[0],l=c[1],p=(0,s.decodeJWT)(t).device,b=[n,p,u,l],d=(0,s.pathToTopic)(b),y=[].concat(b,[a]),g=(0,s.pathToTopic)(y),m="".concat(o&&JSON.parse(o)?"wss":"ws","://mqtt.").concat(r);return f(f({},v({jwt:t,id:n,mqttUrl:m})),{},{device:p,prefixPath:b,prefix:d,prefixPathVersion:y,prefixVersion:g})}},809:e=>{function t(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}e.exports=function(e){if(!e.attributes)return{};var r,o,i,a={},c=(i=e.attributes,function(e){if(Array.isArray(e))return n(e)}(i)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||t(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){return function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e.name,e.value)})),u=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=t(e))){r&&(e=r);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw a}}}}(c);try{for(u.s();!(o=u.n()).done;){r=o.value;var s=Object.keys(r)[0];a[s.replace(/-([a-z])/g,(function(e){return e[1].toUpperCase()}))]=r[s]}}catch(e){u.e(e)}finally{u.f()}return a}},613:(e,t,n)=>{e.exports=function(){try{return n(962).styleElements}catch(e){return[]}}},927:(e,t,n)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function u(e){var t=h();return function(){var n,r=d(e);if(t){var o=d(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return s(this,n)}}function s(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return l(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(r,e)},f(e)}function p(e,t,n){return p=h()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&b(o,n.prototype),o},p.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=n(689),g=n(405),m=n(430),O=n(613),w=n(809),j={attachedCallback:"webComponentAttached",connectedCallback:"webComponentConnected",disconnectedCallback:"webComponentDisconnected",adoptedCallback:"webComponentAdopted"};e.exports={create:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=function(t){c(s,t);var i=u(s);function s(){var e;o(this,s);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return y(l(e=i.call.apply(i,[this].concat(n))),"instance",null),e}return a(s,[{key:"callConstructorHook",value:function(){this.instance.webComponentConstructed&&this.instance.webComponentConstructed.apply(this.instance,[this])}},{key:"callLifeCycleHook",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=j[e];n&&this.instance&&this.instance[n]&&this.instance[n].apply(this.instance,t)}},{key:"connectedCallback",value:function(){var t=this,r=t;if(n){var o=t.attachShadow({mode:"open"});r=document.createElement("div"),O().forEach((function(e){o.appendChild(e.cloneNode(o))})),o.appendChild(r),m(o)}g.render(v.createElement(e,w(t)),r,(function(){t.instance=this,t.callConstructorHook(),t.callLifeCycleHook("connectedCallback")}))}},{key:"disconnectedCallback",value:function(){this.callLifeCycleHook("disconnectedCallback")}},{key:"adoptedCallback",value:function(e,t){this.callLifeCycleHook("adoptedCallback",[e,t])}},{key:"call",value:function(e,t){var n,o;return null==r||null===(n=r.current)||void 0===n||null===(o=n[e])||void 0===o?void 0:o.call(null==r?void 0:r.current,t)}},{key:"getConfig",value:function(){return this.instance.state.config}}]),s}(f(HTMLElement));customElements.define(t,i)}}},498:(e,t,n)=>{"use strict";n.d(t,{EK:()=>T,SV:()=>A,ZM:()=>C,U5:()=>k,B7:()=>_,ax:()=>q,eZ:()=>D});var r=n(689),o=n.n(r);const i=require("react-bootstrap");var a=n(927),c=n.n(a);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function d(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}function v(e,t){return v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},v(e,t)}function g(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=w(e);if(t){var o=w(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return m(this,n)}}function m(e,t){if(t&&("object"===u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return O(e)}function O(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},w(e)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n(216);var E={badge:{width:"4em"},code:{color:"#700",borderLeft:"3px solid #aaa",padding:"0.5em 0px 0.5em 2em",backgroundColor:"#f0f0f0",borderRadius:"4px",marginTop:"0.5em"},inlineCode:{color:"#700",margin:"0px 0.5em 0px 0.5em"}},P=[o().createElement(i.Badge,{bg:"success",style:E.badge},"OK"),o().createElement(i.Badge,{bg:"warning",style:E.badge},"Warn"),o().createElement(i.Badge,{bg:"danger",style:E.badge},"Error"),o().createElement(i.Badge,{bg:"secondary",style:E.badge},"Stale")],k=function(e){var t=e.level;return P[t]||o().createElement("span",null,t)},T=function(e){var t=e.children;return o().createElement("pre",{style:E.code},t)},C=function(e){var t=e.children;return o().createElement("tt",{style:E.inlineCode},t)},x={},q=o().createContext({}),_=function(e){var t=e.duration,n=e.onTimeout,a=e.onStart,c=e.setOnDisconnect,u=e.children;t=t||60;var s=j((0,r.useState)(t),2),l=s[0],f=s[1],p=j((0,r.useState)(!1),2),h=p[0],b=p[1],d=(0,r.useMemo)((function(){return Math.random().toString(36).slice(2)}),[]),y=function(){console.log("stopping timer for",d),n&&setTimeout(n,1),clearInterval(x[d]),x[d]=null,b(!1)};(0,r.useEffect)((function(){var e;l>0&&!h&&(e=x[d],console.log(e,x,l),!e&&l>0&&(b(!0),x[d]=setInterval((function(){return f((function(e){if(--e>0)return e;y()}))}),1e3),a&&setTimeout(a,1)))}),[l]),(0,r.useEffect)((function(){return y}),[]),c&&c((function(){y()}));var v=function(){return f(t)};return o().createElement(q.Provider,{value:{reset:v,duration:t,timer:l}},l>0?o().createElement("div",null,u,l<60&&o().createElement("div",null,"Timeout in: ",l," seconds")):o().createElement("div",null,"Timed out. ",o().createElement(i.Button,{onClick:v},"Resume")))},A=function(e){y(n,e);var t=g(n);function n(e){var r;return h(this,n),(r=t.call(this,e)).state={hasError:!1},r}return d(n,[{key:"componentDidCatch",value:function(e,t){console.warn("ErrorBoundary caught:",e,t)}},{key:"render",value:function(){return this.state.hasError?o().createElement("div",null,this.props.message||"Something went wrong here."):this.props.children}}],[{key:"getDerivedStateFromError",value:function(e){return{hasError:!0}}}]),n}(o().Component),M=function(e){var t;return e.$$typeof==Symbol.for("react.forward_ref")||(null===(t=e.prototype)||void 0===t?void 0:t.render)},D=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0.0.0",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=M(e)?o().createRef():null,a=function(a){y(u,a);var c=g(u);function u(){var e;h(this,u);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return p(O(e=c.call.apply(c,[this].concat(n))),"onDisconnect",null),p(O(e),"state",{}),e}return d(u,[{key:"setOnDisconnect",value:function(e){this.onDisconnect=e}},{key:"webComponentConstructed",value:function(e){var t=this;new MutationObserver((function(n){var r={};n.forEach((function(t){var n=t.attributeName;r[n]=e.getAttribute(n)})),t.setState((function(e){return f(f({},e),r)}))})).observe(e,{attributes:!0})}},{key:"webComponentDisconnected",value:function(){this.setState({_disconnected:!0});try{this.onDisconnect&&this.onDisconnect()}catch(e){console.log("Error during onDisconnect of web-component",e)}}},{key:"setConfig",value:function(e){this.setState({config:e})}},{key:"render",value:function(){var a=r.stylesheets||["https://cdn.jsdelivr.net/gh/transitiverobotics/transitive-utils@0.8.3/web/css/bootstrap_transitive-bs-root.min.css"];return o().createElement("div",{id:"cap-".concat(t,"-").concat(n),className:r.className||"transitive-bs-root"},o().createElement("style",null,a.map((function(e){return"@import url(".concat(e,");")}))),!this.state._disconnected&&o().createElement(e,s({ref:i},this.props,this.state,{setOnDisconnect:this.setOnDisconnect.bind(this),setConfig:this.setConfig.bind(this)})))}}]),u}(o().Component);c().create(a,t,r.shadowDOM||!1,i)}},22:e=>{"use strict";e.exports=require("chalk")},517:e=>{"use strict";e.exports=require("lodash")},848:e=>{"use strict";e.exports=require("lodash/forEach")},712:e=>{"use strict";e.exports=require("lodash/get")},699:e=>{"use strict";e.exports=require("lodash/isEmpty")},113:e=>{"use strict";e.exports=require("lodash/isEqual")},452:e=>{"use strict";e.exports=require("lodash/isPlainObject")},707:e=>{"use strict";e.exports=require("lodash/map")},831:e=>{"use strict";e.exports=require("lodash/merge")},298:e=>{"use strict";e.exports=require("lodash/set")},305:e=>{"use strict";e.exports=require("lodash/unset")},622:e=>{"use strict";e.exports=require("loglevel")},689:e=>{"use strict";e.exports=require("react")},405:e=>{"use strict";e.exports=require("react-dom")},430:e=>{"use strict";e.exports=require("react-shadow-dom-retarget-events")},962:e=>{"use strict";e.exports=require("react-web-component-style-loader/exports")},13:e=>{"use strict";e.exports=require("semver/functions/compare")},84:e=>{"use strict";e.exports=require("semver/ranges/min-version")}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{Code:()=>e.EK,ErrorBoundary:()=>e.SV,InlineCode:()=>e.ZM,LevelBadge:()=>e.U5,Timer:()=>e.B7,TimerContext:()=>e.ax,createWebComponent:()=>e.eZ,useMqttSync:()=>t.H,useTransitive:()=>t.D});var e=n(498),t=n(782),o=n(216),i={};for(const e in o)["default","Code","ErrorBoundary","InlineCode","LevelBadge","Timer","TimerContext","createWebComponent","useMqttSync","useTransitive"].indexOf(e)<0&&(i[e]=()=>o[e]);n.d(r,i)})();var o=exports;for(var i in r)o[i]=r[i];r.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
1
+ var tn=Object.create;var Ne=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var nn=Object.getPrototypeOf,on=Object.prototype.hasOwnProperty;var x=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Dt=(t,e)=>{for(var r in e)Ne(t,r,{get:e[r],enumerable:!0})},Re=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of sn(e))!on.call(t,n)&&n!==r&&Ne(t,n,{get:()=>e[n],enumerable:!(s=rn(e,n))||s.enumerable});return t},A=(t,e,r)=>(Re(t,e,"default"),r&&Re(r,e,"default")),D=(t,e,r)=>(r=t!=null?tn(nn(t)):{},Re(e||!t||!t.__esModule?Ne(r,"default",{value:t,enumerable:!0}):r,t)),an=t=>Re(Ne({},"__esModule",{value:!0}),t);var Je=x((Fi,Ae)=>{(function(){"use strict";var t={}.hasOwnProperty,e="[native code]";function r(){for(var s=[],n=0;n<arguments.length;n++){var o=arguments[n];if(o){var i=typeof o;if(i==="string"||i==="number")s.push(o);else if(Array.isArray(o)){if(o.length){var a=r.apply(null,o);a&&s.push(a)}}else if(i==="object"){if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]")){s.push(o.toString());continue}for(var l in o)t.call(o,l)&&o[l]&&s.push(l)}}}return s.join(" ")}typeof Ae<"u"&&Ae.exports?(r.default=r,Ae.exports=r):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return r}):window.classNames=r})()});var Jt=x((zi,Wt)=>{Wt.exports=()=>{try{return require("react-web-component-style-loader/exports").styleElements}catch{return[]}}});var Qt=x((Qi,zt)=>{zt.exports=function(e){if(!e.attributes)return{};let r={},s,o=[...e.attributes].map(i=>({[i.name]:i.value}));for(s of o){let i=Object.keys(s)[0],a=i.replace(/-([a-z])/g,l=>l[1].toUpperCase());r[a]=s[i]}return r}});var Yt=x((Ki,Kt)=>{var gn=require("react"),mn=require("react-dom"),bn=require("react-shadow-dom-retarget-events"),yn=Jt(),En=Qt(),vn={attachedCallback:"webComponentAttached",connectedCallback:"webComponentConnected",disconnectedCallback:"webComponentDisconnected",adoptedCallback:"webComponentAdopted"};Kt.exports={create:(t,e,r=!0,s=void 0)=>{let n=class extends HTMLElement{instance=null;callConstructorHook(){this.instance.webComponentConstructed&&this.instance.webComponentConstructed.apply(this.instance,[this])}callLifeCycleHook(o,i=[]){let a=vn[o];a&&this.instance&&this.instance[a]&&this.instance[a].apply(this.instance,i)}connectedCallback(){let o=this,i=o;if(r){let a=o.attachShadow({mode:"open"});i=document.createElement("div"),yn().forEach(c=>{a.appendChild(c.cloneNode(a))}),a.appendChild(i),bn(a)}mn.render(gn.createElement(t,En(o)),i,function(){o.instance=this,o.callConstructorHook(),o.callLifeCycleHook("connectedCallback")})}disconnectedCallback(){this.callLifeCycleHook("disconnectedCallback")}adoptedCallback(o,i){this.callLifeCycleHook("adoptedCallback",[o,i])}call(o,i){return s?.current?.[o]?.call(s?.current,i)}getConfig(){return this.instance.state.config}};return customElements.define(e,n),n}}});var ge=x((Zi,Zt)=>{var xn=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};Zt.exports=xn});var Ze=x((ea,er)=>{var $n="2.0.0",wn=Number.MAX_SAFE_INTEGER||9007199254740991,Tn=16;er.exports={SEMVER_SPEC_VERSION:$n,MAX_LENGTH:256,MAX_SAFE_INTEGER:wn,MAX_SAFE_COMPONENT_LENGTH:Tn}});var Ce=x((W,tr)=>{var{MAX_SAFE_COMPONENT_LENGTH:et}=Ze(),On=ge();W=tr.exports={};var In=W.re=[],d=W.src=[],p=W.t={},Rn=0,b=(t,e,r)=>{let s=Rn++;On(s,e),p[t]=s,d[s]=e,In[s]=new RegExp(e,r?"g":void 0)};b("NUMERICIDENTIFIER","0|[1-9]\\d*");b("NUMERICIDENTIFIERLOOSE","[0-9]+");b("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*");b("MAINVERSION",`(${d[p.NUMERICIDENTIFIER]})\\.(${d[p.NUMERICIDENTIFIER]})\\.(${d[p.NUMERICIDENTIFIER]})`);b("MAINVERSIONLOOSE",`(${d[p.NUMERICIDENTIFIERLOOSE]})\\.(${d[p.NUMERICIDENTIFIERLOOSE]})\\.(${d[p.NUMERICIDENTIFIERLOOSE]})`);b("PRERELEASEIDENTIFIER",`(?:${d[p.NUMERICIDENTIFIER]}|${d[p.NONNUMERICIDENTIFIER]})`);b("PRERELEASEIDENTIFIERLOOSE",`(?:${d[p.NUMERICIDENTIFIERLOOSE]}|${d[p.NONNUMERICIDENTIFIER]})`);b("PRERELEASE",`(?:-(${d[p.PRERELEASEIDENTIFIER]}(?:\\.${d[p.PRERELEASEIDENTIFIER]})*))`);b("PRERELEASELOOSE",`(?:-?(${d[p.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${d[p.PRERELEASEIDENTIFIERLOOSE]})*))`);b("BUILDIDENTIFIER","[0-9A-Za-z-]+");b("BUILD",`(?:\\+(${d[p.BUILDIDENTIFIER]}(?:\\.${d[p.BUILDIDENTIFIER]})*))`);b("FULLPLAIN",`v?${d[p.MAINVERSION]}${d[p.PRERELEASE]}?${d[p.BUILD]}?`);b("FULL",`^${d[p.FULLPLAIN]}$`);b("LOOSEPLAIN",`[v=\\s]*${d[p.MAINVERSIONLOOSE]}${d[p.PRERELEASELOOSE]}?${d[p.BUILD]}?`);b("LOOSE",`^${d[p.LOOSEPLAIN]}$`);b("GTLT","((?:<|>)?=?)");b("XRANGEIDENTIFIERLOOSE",`${d[p.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);b("XRANGEIDENTIFIER",`${d[p.NUMERICIDENTIFIER]}|x|X|\\*`);b("XRANGEPLAIN",`[v=\\s]*(${d[p.XRANGEIDENTIFIER]})(?:\\.(${d[p.XRANGEIDENTIFIER]})(?:\\.(${d[p.XRANGEIDENTIFIER]})(?:${d[p.PRERELEASE]})?${d[p.BUILD]}?)?)?`);b("XRANGEPLAINLOOSE",`[v=\\s]*(${d[p.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[p.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[p.XRANGEIDENTIFIERLOOSE]})(?:${d[p.PRERELEASELOOSE]})?${d[p.BUILD]}?)?)?`);b("XRANGE",`^${d[p.GTLT]}\\s*${d[p.XRANGEPLAIN]}$`);b("XRANGELOOSE",`^${d[p.GTLT]}\\s*${d[p.XRANGEPLAINLOOSE]}$`);b("COERCE",`(^|[^\\d])(\\d{1,${et}})(?:\\.(\\d{1,${et}}))?(?:\\.(\\d{1,${et}}))?(?:$|[^\\d])`);b("COERCERTL",d[p.COERCE],!0);b("LONETILDE","(?:~>?)");b("TILDETRIM",`(\\s*)${d[p.LONETILDE]}\\s+`,!0);W.tildeTrimReplace="$1~";b("TILDE",`^${d[p.LONETILDE]}${d[p.XRANGEPLAIN]}$`);b("TILDELOOSE",`^${d[p.LONETILDE]}${d[p.XRANGEPLAINLOOSE]}$`);b("LONECARET","(?:\\^)");b("CARETTRIM",`(\\s*)${d[p.LONECARET]}\\s+`,!0);W.caretTrimReplace="$1^";b("CARET",`^${d[p.LONECARET]}${d[p.XRANGEPLAIN]}$`);b("CARETLOOSE",`^${d[p.LONECARET]}${d[p.XRANGEPLAINLOOSE]}$`);b("COMPARATORLOOSE",`^${d[p.GTLT]}\\s*(${d[p.LOOSEPLAIN]})$|^$`);b("COMPARATOR",`^${d[p.GTLT]}\\s*(${d[p.FULLPLAIN]})$|^$`);b("COMPARATORTRIM",`(\\s*)${d[p.GTLT]}\\s*(${d[p.LOOSEPLAIN]}|${d[p.XRANGEPLAIN]})`,!0);W.comparatorTrimReplace="$1$2$3";b("HYPHENRANGE",`^\\s*(${d[p.XRANGEPLAIN]})\\s+-\\s+(${d[p.XRANGEPLAIN]})\\s*$`);b("HYPHENRANGELOOSE",`^\\s*(${d[p.XRANGEPLAINLOOSE]})\\s+-\\s+(${d[p.XRANGEPLAINLOOSE]})\\s*$`);b("STAR","(<|>)?=?\\s*\\*");b("GTE0","^\\s*>=\\s*0.0.0\\s*$");b("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")});var Le=x((ta,rr)=>{var Nn=["includePrerelease","loose","rtl"],An=t=>t?typeof t!="object"?{loose:!0}:Nn.filter(e=>t[e]).reduce((e,r)=>(e[r]=!0,e),{}):{};rr.exports=An});var ir=x((ra,or)=>{var sr=/^[0-9]+$/,nr=(t,e)=>{let r=sr.test(t),s=sr.test(e);return r&&s&&(t=+t,e=+e),t===e?0:r&&!s?-1:s&&!r?1:t<e?-1:1},Sn=(t,e)=>nr(e,t);or.exports={compareIdentifiers:nr,rcompareIdentifiers:Sn}});var be=x((sa,ur)=>{var Pe=ge(),{MAX_LENGTH:ar,MAX_SAFE_INTEGER:qe}=Ze(),{re:lr,t:cr}=Ce(),Cn=Le(),{compareIdentifiers:me}=ir(),tt=class t{constructor(e,r){if(r=Cn(r),e instanceof t){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid Version: ${e}`);if(e.length>ar)throw new TypeError(`version is longer than ${ar} characters`);Pe("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let s=e.trim().match(r.loose?lr[cr.LOOSE]:lr[cr.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>qe||this.major<0)throw new TypeError("Invalid major version");if(this.minor>qe||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>qe||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let o=+n;if(o>=0&&o<qe)return o}return n}):this.prerelease=[],this.build=s[5]?s[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(Pe("SemVer.compare",this.version,this.options,e),!(e instanceof t)){if(typeof e=="string"&&e===this.version)return 0;e=new t(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof t||(e=new t(e,this.options)),me(this.major,e.major)||me(this.minor,e.minor)||me(this.patch,e.patch)}comparePre(e){if(e instanceof t||(e=new t(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let r=0;do{let s=this.prerelease[r],n=e.prerelease[r];if(Pe("prerelease compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return me(s,n)}while(++r)}compareBuild(e){e instanceof t||(e=new t(e,this.options));let r=0;do{let s=this.build[r],n=e.build[r];if(Pe("prerelease compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return me(s,n)}while(++r)}inc(e,r){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r),this.inc("pre",r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r),this.inc("pre",r);break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{let s=this.prerelease.length;for(;--s>=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);s===-1&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}};ur.exports=tt});var J=x((na,hr)=>{var fr=be(),Ln=(t,e,r)=>new fr(t,r).compare(new fr(e,r));hr.exports=Ln});var pr=x((oa,dr)=>{"use strict";dr.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}});var mr=x((ia,gr)=>{"use strict";gr.exports=O;O.Node=Z;O.create=O;function O(t){var e=this;if(e instanceof O||(e=new O),e.tail=null,e.head=null,e.length=0,t&&typeof t.forEach=="function")t.forEach(function(n){e.push(n)});else if(arguments.length>0)for(var r=0,s=arguments.length;r<s;r++)e.push(arguments[r]);return e}O.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e};O.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}};O.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}};O.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)qn(this,arguments[t]);return this.length};O.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)Dn(this,arguments[t]);return this.length};O.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}};O.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}};O.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,s=0;r!==null;s++)t.call(e,r.value,s,this),r=r.next};O.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,s=this.length-1;r!==null;s--)t.call(e,r.value,s,this),r=r.prev};O.prototype.get=function(t){for(var e=0,r=this.head;r!==null&&e<t;e++)r=r.next;if(e===t&&r!==null)return r.value};O.prototype.getReverse=function(t){for(var e=0,r=this.tail;r!==null&&e<t;e++)r=r.prev;if(e===t&&r!==null)return r.value};O.prototype.map=function(t,e){e=e||this;for(var r=new O,s=this.head;s!==null;)r.push(t.call(e,s.value,this)),s=s.next;return r};O.prototype.mapReverse=function(t,e){e=e||this;for(var r=new O,s=this.tail;s!==null;)r.push(t.call(e,s.value,this)),s=s.prev;return r};O.prototype.reduce=function(t,e){var r,s=this.head;if(arguments.length>1)r=e;else if(this.head)s=this.head.next,r=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var n=0;s!==null;n++)r=t(r,s.value,n),s=s.next;return r};O.prototype.reduceReverse=function(t,e){var r,s=this.tail;if(arguments.length>1)r=e;else if(this.tail)s=this.tail.prev,r=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var n=this.length-1;s!==null;n--)r=t(r,s.value,n),s=s.prev;return r};O.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;r!==null;e++)t[e]=r.value,r=r.next;return t};O.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;r!==null;e++)t[e]=r.value,r=r.prev;return t};O.prototype.slice=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new O;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var s=0,n=this.head;n!==null&&s<t;s++)n=n.next;for(;n!==null&&s<e;s++,n=n.next)r.push(n.value);return r};O.prototype.sliceReverse=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new O;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var s=this.length,n=this.tail;n!==null&&s>e;s--)n=n.prev;for(;n!==null&&s>t;s--,n=n.prev)r.push(n.value);return r};O.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var s=0,n=this.head;n!==null&&s<t;s++)n=n.next;for(var o=[],s=0;n&&s<e;s++)o.push(n.value),n=this.removeNode(n);n===null&&(n=this.tail),n!==this.head&&n!==this.tail&&(n=n.prev);for(var s=0;s<r.length;s++)n=Pn(this,n,r[s]);return o};O.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;r!==null;r=r.prev){var s=r.prev;r.prev=r.next,r.next=s}return this.head=e,this.tail=t,this};function Pn(t,e,r){var s=e===t.head?new Z(r,null,e,t):new Z(r,e,e.next,t);return s.next===null&&(t.tail=s),s.prev===null&&(t.head=s),t.length++,s}function qn(t,e){t.tail=new Z(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function Dn(t,e){t.head=new Z(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function Z(t,e,r,s){if(!(this instanceof Z))return new Z(t,e,r,s);this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}try{pr()(O)}catch{}});var xr=x((aa,vr)=>{"use strict";var Fn=mr(),ee=Symbol("max"),H=Symbol("length"),ne=Symbol("lengthCalculator"),Ee=Symbol("allowStale"),te=Symbol("maxAge"),U=Symbol("dispose"),br=Symbol("noDisposeOnSet"),S=Symbol("lruList"),G=Symbol("cache"),Er=Symbol("updateAgeOnGet"),rt=()=>1,nt=class{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");let r=this[ee]=e.max||1/0,s=e.length||rt;if(this[ne]=typeof s!="function"?rt:s,this[Ee]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[te]=e.maxAge||0,this[U]=e.dispose,this[br]=e.noDisposeOnSet||!1,this[Er]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[ee]=e||1/0,ye(this)}get max(){return this[ee]}set allowStale(e){this[Ee]=!!e}get allowStale(){return this[Ee]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[te]=e,ye(this)}get maxAge(){return this[te]}set lengthCalculator(e){typeof e!="function"&&(e=rt),e!==this[ne]&&(this[ne]=e,this[H]=0,this[S].forEach(r=>{r.length=this[ne](r.value,r.key),this[H]+=r.length})),ye(this)}get lengthCalculator(){return this[ne]}get length(){return this[H]}get itemCount(){return this[S].length}rforEach(e,r){r=r||this;for(let s=this[S].tail;s!==null;){let n=s.prev;yr(this,e,s,r),s=n}}forEach(e,r){r=r||this;for(let s=this[S].head;s!==null;){let n=s.next;yr(this,e,s,r),s=n}}keys(){return this[S].toArray().map(e=>e.key)}values(){return this[S].toArray().map(e=>e.value)}reset(){this[U]&&this[S]&&this[S].length&&this[S].forEach(e=>this[U](e.key,e.value)),this[G]=new Map,this[S]=new Fn,this[H]=0}dump(){return this[S].map(e=>De(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[S]}set(e,r,s){if(s=s||this[te],s&&typeof s!="number")throw new TypeError("maxAge must be a number");let n=s?Date.now():0,o=this[ne](r,e);if(this[G].has(e)){if(o>this[ee])return oe(this,this[G].get(e)),!1;let l=this[G].get(e).value;return this[U]&&(this[br]||this[U](e,l.value)),l.now=n,l.maxAge=s,l.value=r,this[H]+=o-l.length,l.length=o,this.get(e),ye(this),!0}let i=new ot(e,r,o,n,s);return i.length>this[ee]?(this[U]&&this[U](e,r),!1):(this[H]+=i.length,this[S].unshift(i),this[G].set(e,this[S].head),ye(this),!0)}has(e){if(!this[G].has(e))return!1;let r=this[G].get(e).value;return!De(this,r)}get(e){return st(this,e,!0)}peek(e){return st(this,e,!1)}pop(){let e=this[S].tail;return e?(oe(this,e),e.value):null}del(e){oe(this,this[G].get(e))}load(e){this.reset();let r=Date.now();for(let s=e.length-1;s>=0;s--){let n=e[s],o=n.e||0;if(o===0)this.set(n.k,n.v);else{let i=o-r;i>0&&this.set(n.k,n.v,i)}}}prune(){this[G].forEach((e,r)=>st(this,r,!1))}},st=(t,e,r)=>{let s=t[G].get(e);if(s){let n=s.value;if(De(t,n)){if(oe(t,s),!t[Ee])return}else r&&(t[Er]&&(s.value.now=Date.now()),t[S].unshiftNode(s));return n.value}},De=(t,e)=>{if(!e||!e.maxAge&&!t[te])return!1;let r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[te]&&r>t[te]},ye=t=>{if(t[H]>t[ee])for(let e=t[S].tail;t[H]>t[ee]&&e!==null;){let r=e.prev;oe(t,e),e=r}},oe=(t,e)=>{if(e){let r=e.value;t[U]&&t[U](r.key,r.value),t[H]-=r.length,t[G].delete(r.key),t[S].removeNode(e)}},ot=class{constructor(e,r,s,n,o){this.key=e,this.value=r,this.length=s,this.now=n,this.maxAge=o||0}},yr=(t,e,r,s)=>{let n=r.value;De(t,n)&&(oe(t,r),t[Ee]||(n=void 0)),n&&e.call(s,n.value,n.key,t)};vr.exports=nt});var wr=x((la,$r)=>{var Bn=J(),Mn=(t,e,r)=>Bn(t,e,r)===0;$r.exports=Mn});var Or=x((ca,Tr)=>{var kn=J(),jn=(t,e,r)=>kn(t,e,r)!==0;Tr.exports=jn});var it=x((ua,Ir)=>{var Gn=J(),_n=(t,e,r)=>Gn(t,e,r)>0;Ir.exports=_n});var Nr=x((fa,Rr)=>{var Un=J(),Hn=(t,e,r)=>Un(t,e,r)>=0;Rr.exports=Hn});var Sr=x((ha,Ar)=>{var Vn=J(),Xn=(t,e,r)=>Vn(t,e,r)<0;Ar.exports=Xn});var Lr=x((da,Cr)=>{var Wn=J(),Jn=(t,e,r)=>Wn(t,e,r)<=0;Cr.exports=Jn});var qr=x((pa,Pr)=>{var zn=wr(),Qn=Or(),Kn=it(),Yn=Nr(),Zn=Sr(),eo=Lr(),to=(t,e,r,s)=>{switch(e){case"===":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t===r;case"!==":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t!==r;case"":case"=":case"==":return zn(t,r,s);case"!=":return Qn(t,r,s);case">":return Kn(t,r,s);case">=":return Yn(t,r,s);case"<":return Zn(t,r,s);case"<=":return eo(t,r,s);default:throw new TypeError(`Invalid operator: ${e}`)}};Pr.exports=to});var jr=x((ga,kr)=>{var ve=Symbol("SemVer ANY"),ct=class t{static get ANY(){return ve}constructor(e,r){if(r=ro(r),e instanceof t){if(e.loose===!!r.loose)return e;e=e.value}lt("comparator",e,r),this.options=r,this.loose=!!r.loose,this.parse(e),this.semver===ve?this.value="":this.value=this.operator+this.semver.version,lt("comp",this)}parse(e){let r=this.options.loose?Dr[Fr.COMPARATORLOOSE]:Dr[Fr.COMPARATOR],s=e.match(r);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=s[1]!==void 0?s[1]:"",this.operator==="="&&(this.operator=""),s[2]?this.semver=new Br(s[2],this.options.loose):this.semver=ve}toString(){return this.value}test(e){if(lt("Comparator.test",e,this.options.loose),this.semver===ve||e===ve)return!0;if(typeof e=="string")try{e=new Br(e,this.options)}catch{return!1}return at(e,this.operator,this.semver,this.options)}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Comparator is required");if((!r||typeof r!="object")&&(r={loose:!!r,includePrerelease:!1}),this.operator==="")return this.value===""?!0:new Mr(e.value,r).test(this.value);if(e.operator==="")return e.value===""?!0:new Mr(this.value,r).test(e.semver);let s=(this.operator===">="||this.operator===">")&&(e.operator===">="||e.operator===">"),n=(this.operator==="<="||this.operator==="<")&&(e.operator==="<="||e.operator==="<"),o=this.semver.version===e.semver.version,i=(this.operator===">="||this.operator==="<=")&&(e.operator===">="||e.operator==="<="),a=at(this.semver,"<",e.semver,r)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),l=at(this.semver,">",e.semver,r)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return s||n||o&&i||a||l}};kr.exports=ct;var ro=Le(),{re:Dr,t:Fr}=Ce(),at=qr(),lt=ge(),Br=be(),Mr=ut()});var ut=x((ma,Hr)=>{var ft=class t{constructor(e,r){if(r=no(r),e instanceof t)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new t(e.raw,r);if(e instanceof ht)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(s=>this.parseRange(s.trim())).filter(s=>s.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);if(this.set.length>1){let s=this.set[0];if(this.set=this.set.filter(n=>!_r(n[0])),this.set.length===0)this.set=[s];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&co(n[0])){this.set=[n];break}}}this.format()}format(){return this.range=this.set.map(e=>e.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(e){e=e.trim();let s=`parseRange:${Object.keys(this.options).join(",")}:${e}`,n=Gr.get(s);if(n)return n;let o=this.options.loose,i=o?P[C.HYPHENRANGELOOSE]:P[C.HYPHENRANGE];e=e.replace(i,vo(this.options.includePrerelease)),N("hyphen replace",e),e=e.replace(P[C.COMPARATORTRIM],io),N("comparator trim",e,P[C.COMPARATORTRIM]),e=e.replace(P[C.TILDETRIM],ao),e=e.replace(P[C.CARETTRIM],lo),e=e.split(/\s+/).join(" ");let a=o?P[C.COMPARATORLOOSE]:P[C.COMPARATOR],l=e.split(" ").map(u=>uo(u,this.options)).join(" ").split(/\s+/).map(u=>Eo(u,this.options)).filter(this.options.loose?u=>!!u.match(a):()=>!0).map(u=>new ht(u,this.options)),c=l.length,h=new Map;for(let u of l){if(_r(u))return[u];h.set(u.value,u)}h.size>1&&h.has("")&&h.delete("");let f=[...h.values()];return Gr.set(s,f),f}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(s=>Ur(s,r)&&e.set.some(n=>Ur(n,r)&&s.every(o=>n.every(i=>o.intersects(i,r)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new oo(e,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(xo(this.set[r],e,this.options))return!0;return!1}};Hr.exports=ft;var so=xr(),Gr=new so({max:1e3}),no=Le(),ht=jr(),N=ge(),oo=be(),{re:P,t:C,comparatorTrimReplace:io,tildeTrimReplace:ao,caretTrimReplace:lo}=Ce(),_r=t=>t.value==="<0.0.0-0",co=t=>t.value==="",Ur=(t,e)=>{let r=!0,s=t.slice(),n=s.pop();for(;r&&s.length;)r=s.every(o=>n.intersects(o,e)),n=s.pop();return r},uo=(t,e)=>(N("comp",t,e),t=po(t,e),N("caret",t),t=fo(t,e),N("tildes",t),t=mo(t,e),N("xrange",t),t=yo(t,e),N("stars",t),t),q=t=>!t||t.toLowerCase()==="x"||t==="*",fo=(t,e)=>t.trim().split(/\s+/).map(r=>ho(r,e)).join(" "),ho=(t,e)=>{let r=e.loose?P[C.TILDELOOSE]:P[C.TILDE];return t.replace(r,(s,n,o,i,a)=>{N("tilde",t,s,n,o,i,a);let l;return q(n)?l="":q(o)?l=`>=${n}.0.0 <${+n+1}.0.0-0`:q(i)?l=`>=${n}.${o}.0 <${n}.${+o+1}.0-0`:a?(N("replaceTilde pr",a),l=`>=${n}.${o}.${i}-${a} <${n}.${+o+1}.0-0`):l=`>=${n}.${o}.${i} <${n}.${+o+1}.0-0`,N("tilde return",l),l})},po=(t,e)=>t.trim().split(/\s+/).map(r=>go(r,e)).join(" "),go=(t,e)=>{N("caret",t,e);let r=e.loose?P[C.CARETLOOSE]:P[C.CARET],s=e.includePrerelease?"-0":"";return t.replace(r,(n,o,i,a,l)=>{N("caret",t,n,o,i,a,l);let c;return q(o)?c="":q(i)?c=`>=${o}.0.0${s} <${+o+1}.0.0-0`:q(a)?o==="0"?c=`>=${o}.${i}.0${s} <${o}.${+i+1}.0-0`:c=`>=${o}.${i}.0${s} <${+o+1}.0.0-0`:l?(N("replaceCaret pr",l),o==="0"?i==="0"?c=`>=${o}.${i}.${a}-${l} <${o}.${i}.${+a+1}-0`:c=`>=${o}.${i}.${a}-${l} <${o}.${+i+1}.0-0`:c=`>=${o}.${i}.${a}-${l} <${+o+1}.0.0-0`):(N("no pr"),o==="0"?i==="0"?c=`>=${o}.${i}.${a}${s} <${o}.${i}.${+a+1}-0`:c=`>=${o}.${i}.${a}${s} <${o}.${+i+1}.0-0`:c=`>=${o}.${i}.${a} <${+o+1}.0.0-0`),N("caret return",c),c})},mo=(t,e)=>(N("replaceXRanges",t,e),t.split(/\s+/).map(r=>bo(r,e)).join(" ")),bo=(t,e)=>{t=t.trim();let r=e.loose?P[C.XRANGELOOSE]:P[C.XRANGE];return t.replace(r,(s,n,o,i,a,l)=>{N("xRange",t,s,n,o,i,a,l);let c=q(o),h=c||q(i),f=h||q(a),u=f;return n==="="&&u&&(n=""),l=e.includePrerelease?"-0":"",c?n===">"||n==="<"?s="<0.0.0-0":s="*":n&&u?(h&&(i=0),a=0,n===">"?(n=">=",h?(o=+o+1,i=0,a=0):(i=+i+1,a=0)):n==="<="&&(n="<",h?o=+o+1:i=+i+1),n==="<"&&(l="-0"),s=`${n+o}.${i}.${a}${l}`):h?s=`>=${o}.0.0${l} <${+o+1}.0.0-0`:f&&(s=`>=${o}.${i}.0${l} <${o}.${+i+1}.0-0`),N("xRange return",s),s})},yo=(t,e)=>(N("replaceStars",t,e),t.trim().replace(P[C.STAR],"")),Eo=(t,e)=>(N("replaceGTE0",t,e),t.trim().replace(P[e.includePrerelease?C.GTE0PRE:C.GTE0],"")),vo=t=>(e,r,s,n,o,i,a,l,c,h,f,u,E)=>(q(s)?r="":q(n)?r=`>=${s}.0.0${t?"-0":""}`:q(o)?r=`>=${s}.${n}.0${t?"-0":""}`:i?r=`>=${r}`:r=`>=${r}${t?"-0":""}`,q(c)?l="":q(h)?l=`<${+c+1}.0.0-0`:q(f)?l=`<${c}.${+h+1}.0-0`:u?l=`<=${c}.${h}.${f}-${u}`:t?l=`<${c}.${h}.${+f+1}-0`:l=`<=${l}`,`${r} ${l}`.trim()),xo=(t,e,r)=>{for(let s=0;s<t.length;s++)if(!t[s].test(e))return!1;if(e.prerelease.length&&!r.includePrerelease){for(let s=0;s<t.length;s++)if(N(t[s].semver),t[s].semver!==ht.ANY&&t[s].semver.prerelease.length>0){let n=t[s].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}});var Wr=x((ba,Xr)=>{var dt=be(),$o=ut(),Vr=it(),wo=(t,e)=>{t=new $o(t,e);let r=new dt("0.0.0");if(t.test(r)||(r=new dt("0.0.0-0"),t.test(r)))return r;r=null;for(let s=0;s<t.set.length;++s){let n=t.set[s],o=null;n.forEach(i=>{let a=new dt(i.semver.version);switch(i.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!o||Vr(a,o))&&(o=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${i.operator}`)}}),o&&(!r||Vr(r,o))&&(r=o)}return r&&t.test(r)?r:null};Xr.exports=wo});var zr=x((Jr,Fe)=>{(function(t,e){"use strict";typeof define=="function"&&define.amd?define(e):typeof Fe=="object"&&Fe.exports?Fe.exports=e():t.log=e()})(Jr,function(){"use strict";var t=function(){},e="undefined",r=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"];function n(m,$){var I=m[$];if(typeof I.bind=="function")return I.bind(m);try{return Function.prototype.bind.call(I,m)}catch{return function(){return Function.prototype.apply.apply(I,[m,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function i(m){return m==="debug"&&(m="log"),typeof console===e?!1:m==="trace"&&r?o:console[m]!==void 0?n(console,m):console.log!==void 0?n(console,"log"):t}function a(m,$){for(var I=0;I<s.length;I++){var T=s[I];this[T]=I<m?t:this.methodFactory(T,m,$)}this.log=this.debug}function l(m,$,I){return function(){typeof console!==e&&(a.call(this,$,I),this[m].apply(this,arguments))}}function c(m,$,I){return i(m)||l.apply(this,arguments)}function h(m,$,I){var T=this,V;$=$??"WARN";var L="loglevel";typeof m=="string"?L+=":"+m:typeof m=="symbol"&&(L=void 0);function X(v){var M=(s[v]||"silent").toUpperCase();if(!(typeof window===e||!L)){try{window.localStorage[L]=M;return}catch{}try{window.document.cookie=encodeURIComponent(L)+"="+M+";"}catch{}}}function _(){var v;if(!(typeof window===e||!L)){try{v=window.localStorage[L]}catch{}if(typeof v===e)try{var M=window.document.cookie,Y=M.indexOf(encodeURIComponent(L)+"=");Y!==-1&&(v=/^([^;]+)/.exec(M.slice(Y))[1])}catch{}return T.levels[v]===void 0&&(v=void 0),v}}function K(){if(!(typeof window===e||!L)){try{window.localStorage.removeItem(L);return}catch{}try{window.document.cookie=encodeURIComponent(L)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}T.name=m,T.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},T.methodFactory=I||c,T.getLevel=function(){return V},T.setLevel=function(v,M){if(typeof v=="string"&&T.levels[v.toUpperCase()]!==void 0&&(v=T.levels[v.toUpperCase()]),typeof v=="number"&&v>=0&&v<=T.levels.SILENT){if(V=v,M!==!1&&X(v),a.call(T,v,m),typeof console===e&&v<T.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+v},T.setDefaultLevel=function(v){$=v,_()||T.setLevel(v,!1)},T.resetLevel=function(){T.setLevel($,!1),K()},T.enableAll=function(v){T.setLevel(T.levels.TRACE,v)},T.disableAll=function(v){T.setLevel(T.levels.SILENT,v)};var j=_();j==null&&(j=$),T.setLevel(j,!1)}var f=new h,u={};f.getLogger=function($){if(typeof $!="symbol"&&typeof $!="string"||$==="")throw new TypeError("You must supply a name when creating a logger.");var I=u[$];return I||(I=u[$]=new h($,f.getLevel(),f.methodFactory)),I};var E=typeof window!==e?window.log:void 0;return f.noConflict=function(){return typeof window!==e&&window.log===f&&(window.log=E),f},f.getLoggers=function(){return u},f.default=f,f})});var Kr=x((ya,Qr)=>{"use strict";Qr.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var pt=x((Ea,Zr)=>{var xe=Kr(),Yr={};for(let t of Object.keys(xe))Yr[xe[t]]=t;var g={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};Zr.exports=g;for(let t of Object.keys(g)){if(!("channels"in g[t]))throw new Error("missing channels property: "+t);if(!("labels"in g[t]))throw new Error("missing channel labels property: "+t);if(g[t].labels.length!==g[t].channels)throw new Error("channel and label counts mismatch: "+t);let{channels:e,labels:r}=g[t];delete g[t].channels,delete g[t].labels,Object.defineProperty(g[t],"channels",{value:e}),Object.defineProperty(g[t],"labels",{value:r})}g.rgb.hsl=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,n=Math.min(e,r,s),o=Math.max(e,r,s),i=o-n,a,l;o===n?a=0:e===o?a=(r-s)/i:r===o?a=2+(s-e)/i:s===o&&(a=4+(e-r)/i),a=Math.min(a*60,360),a<0&&(a+=360);let c=(n+o)/2;return o===n?l=0:c<=.5?l=i/(o+n):l=i/(2-o-n),[a,l*100,c*100]};g.rgb.hsv=function(t){let e,r,s,n,o,i=t[0]/255,a=t[1]/255,l=t[2]/255,c=Math.max(i,a,l),h=c-Math.min(i,a,l),f=function(u){return(c-u)/6/h+1/2};return h===0?(n=0,o=0):(o=h/c,e=f(i),r=f(a),s=f(l),i===c?n=s-r:a===c?n=1/3+e-s:l===c&&(n=2/3+r-e),n<0?n+=1:n>1&&(n-=1)),[n*360,o*100,c*100]};g.rgb.hwb=function(t){let e=t[0],r=t[1],s=t[2],n=g.rgb.hsl(t)[0],o=1/255*Math.min(e,Math.min(r,s));return s=1-1/255*Math.max(e,Math.max(r,s)),[n,o*100,s*100]};g.rgb.cmyk=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,n=Math.min(1-e,1-r,1-s),o=(1-e-n)/(1-n)||0,i=(1-r-n)/(1-n)||0,a=(1-s-n)/(1-n)||0;return[o*100,i*100,a*100,n*100]};function To(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}g.rgb.keyword=function(t){let e=Yr[t];if(e)return e;let r=1/0,s;for(let n of Object.keys(xe)){let o=xe[n],i=To(t,o);i<r&&(r=i,s=n)}return s};g.keyword.rgb=function(t){return xe[t]};g.rgb.xyz=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,s=s>.04045?((s+.055)/1.055)**2.4:s/12.92;let n=e*.4124+r*.3576+s*.1805,o=e*.2126+r*.7152+s*.0722,i=e*.0193+r*.1192+s*.9505;return[n*100,o*100,i*100]};g.rgb.lab=function(t){let e=g.rgb.xyz(t),r=e[0],s=e[1],n=e[2];r/=95.047,s/=100,n/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;let o=116*s-16,i=500*(r-s),a=200*(s-n);return[o,i,a]};g.hsl.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100,n,o,i;if(r===0)return i=s*255,[i,i,i];s<.5?n=s*(1+r):n=s+r-s*r;let a=2*s-n,l=[0,0,0];for(let c=0;c<3;c++)o=e+1/3*-(c-1),o<0&&o++,o>1&&o--,6*o<1?i=a+(n-a)*6*o:2*o<1?i=n:3*o<2?i=a+(n-a)*(2/3-o)*6:i=a,l[c]=i*255;return l};g.hsl.hsv=function(t){let e=t[0],r=t[1]/100,s=t[2]/100,n=r,o=Math.max(s,.01);s*=2,r*=s<=1?s:2-s,n*=o<=1?o:2-o;let i=(s+r)/2,a=s===0?2*n/(o+n):2*r/(s+r);return[e,a*100,i*100]};g.hsv.rgb=function(t){let e=t[0]/60,r=t[1]/100,s=t[2]/100,n=Math.floor(e)%6,o=e-Math.floor(e),i=255*s*(1-r),a=255*s*(1-r*o),l=255*s*(1-r*(1-o));switch(s*=255,n){case 0:return[s,l,i];case 1:return[a,s,i];case 2:return[i,s,l];case 3:return[i,a,s];case 4:return[l,i,s];case 5:return[s,i,a]}};g.hsv.hsl=function(t){let e=t[0],r=t[1]/100,s=t[2]/100,n=Math.max(s,.01),o,i;i=(2-r)*s;let a=(2-r)*n;return o=r*n,o/=a<=1?a:2-a,o=o||0,i/=2,[e,o*100,i*100]};g.hwb.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100,n=r+s,o;n>1&&(r/=n,s/=n);let i=Math.floor(6*e),a=1-s;o=6*e-i,i&1&&(o=1-o);let l=r+o*(a-r),c,h,f;switch(i){default:case 6:case 0:c=a,h=l,f=r;break;case 1:c=l,h=a,f=r;break;case 2:c=r,h=a,f=l;break;case 3:c=r,h=l,f=a;break;case 4:c=l,h=r,f=a;break;case 5:c=a,h=r,f=l;break}return[c*255,h*255,f*255]};g.cmyk.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,n=t[3]/100,o=1-Math.min(1,e*(1-n)+n),i=1-Math.min(1,r*(1-n)+n),a=1-Math.min(1,s*(1-n)+n);return[o*255,i*255,a*255]};g.xyz.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,n,o,i;return n=e*3.2406+r*-1.5372+s*-.4986,o=e*-.9689+r*1.8758+s*.0415,i=e*.0557+r*-.204+s*1.057,n=n>.0031308?1.055*n**(1/2.4)-.055:n*12.92,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,i=i>.0031308?1.055*i**(1/2.4)-.055:i*12.92,n=Math.min(Math.max(0,n),1),o=Math.min(Math.max(0,o),1),i=Math.min(Math.max(0,i),1),[n*255,o*255,i*255]};g.xyz.lab=function(t){let e=t[0],r=t[1],s=t[2];e/=95.047,r/=100,s/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,s=s>.008856?s**(1/3):7.787*s+16/116;let n=116*r-16,o=500*(e-r),i=200*(r-s);return[n,o,i]};g.lab.xyz=function(t){let e=t[0],r=t[1],s=t[2],n,o,i;o=(e+16)/116,n=r/500+o,i=o-s/200;let a=o**3,l=n**3,c=i**3;return o=a>.008856?a:(o-16/116)/7.787,n=l>.008856?l:(n-16/116)/7.787,i=c>.008856?c:(i-16/116)/7.787,n*=95.047,o*=100,i*=108.883,[n,o,i]};g.lab.lch=function(t){let e=t[0],r=t[1],s=t[2],n;n=Math.atan2(s,r)*360/2/Math.PI,n<0&&(n+=360);let i=Math.sqrt(r*r+s*s);return[e,i,n]};g.lch.lab=function(t){let e=t[0],r=t[1],n=t[2]/360*2*Math.PI,o=r*Math.cos(n),i=r*Math.sin(n);return[e,o,i]};g.rgb.ansi16=function(t,e=null){let[r,s,n]=t,o=e===null?g.rgb.hsv(t)[2]:e;if(o=Math.round(o/50),o===0)return 30;let i=30+(Math.round(n/255)<<2|Math.round(s/255)<<1|Math.round(r/255));return o===2&&(i+=60),i};g.hsv.ansi16=function(t){return g.rgb.ansi16(g.hsv.rgb(t),t[2])};g.rgb.ansi256=function(t){let e=t[0],r=t[1],s=t[2];return e===r&&r===s?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(s/255*5)};g.ansi16.rgb=function(t){let e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let r=(~~(t>50)+1)*.5,s=(e&1)*r*255,n=(e>>1&1)*r*255,o=(e>>2&1)*r*255;return[s,n,o]};g.ansi256.rgb=function(t){if(t>=232){let o=(t-232)*10+8;return[o,o,o]}t-=16;let e,r=Math.floor(t/36)/5*255,s=Math.floor((e=t%36)/6)/5*255,n=e%6/5*255;return[r,s,n]};g.rgb.hex=function(t){let r=(((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255)).toString(16).toUpperCase();return"000000".substring(r.length)+r};g.hex.rgb=function(t){let e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let r=e[0];e[0].length===3&&(r=r.split("").map(a=>a+a).join(""));let s=parseInt(r,16),n=s>>16&255,o=s>>8&255,i=s&255;return[n,o,i]};g.rgb.hcg=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,n=Math.max(Math.max(e,r),s),o=Math.min(Math.min(e,r),s),i=n-o,a,l;return i<1?a=o/(1-i):a=0,i<=0?l=0:n===e?l=(r-s)/i%6:n===r?l=2+(s-e)/i:l=4+(e-r)/i,l/=6,l%=1,[l*360,i*100,a*100]};g.hsl.hcg=function(t){let e=t[1]/100,r=t[2]/100,s=r<.5?2*e*r:2*e*(1-r),n=0;return s<1&&(n=(r-.5*s)/(1-s)),[t[0],s*100,n*100]};g.hsv.hcg=function(t){let e=t[1]/100,r=t[2]/100,s=e*r,n=0;return s<1&&(n=(r-s)/(1-s)),[t[0],s*100,n*100]};g.hcg.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100;if(r===0)return[s*255,s*255,s*255];let n=[0,0,0],o=e%1*6,i=o%1,a=1-i,l=0;switch(Math.floor(o)){case 0:n[0]=1,n[1]=i,n[2]=0;break;case 1:n[0]=a,n[1]=1,n[2]=0;break;case 2:n[0]=0,n[1]=1,n[2]=i;break;case 3:n[0]=0,n[1]=a,n[2]=1;break;case 4:n[0]=i,n[1]=0,n[2]=1;break;default:n[0]=1,n[1]=0,n[2]=a}return l=(1-r)*s,[(r*n[0]+l)*255,(r*n[1]+l)*255,(r*n[2]+l)*255]};g.hcg.hsv=function(t){let e=t[1]/100,r=t[2]/100,s=e+r*(1-e),n=0;return s>0&&(n=e/s),[t[0],n*100,s*100]};g.hcg.hsl=function(t){let e=t[1]/100,s=t[2]/100*(1-e)+.5*e,n=0;return s>0&&s<.5?n=e/(2*s):s>=.5&&s<1&&(n=e/(2*(1-s))),[t[0],n*100,s*100]};g.hcg.hwb=function(t){let e=t[1]/100,r=t[2]/100,s=e+r*(1-e);return[t[0],(s-e)*100,(1-s)*100]};g.hwb.hcg=function(t){let e=t[1]/100,s=1-t[2]/100,n=s-e,o=0;return n<1&&(o=(s-n)/(1-n)),[t[0],n*100,o*100]};g.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};g.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};g.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};g.gray.hsl=function(t){return[0,0,t[0]]};g.gray.hsv=g.gray.hsl;g.gray.hwb=function(t){return[0,100,t[0]]};g.gray.cmyk=function(t){return[0,0,0,t[0]]};g.gray.lab=function(t){return[t[0],0,0]};g.gray.hex=function(t){let e=Math.round(t[0]/100*255)&255,s=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(s.length)+s};g.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]}});var ts=x((va,es)=>{var Be=pt();function Oo(){let t={},e=Object.keys(Be);for(let r=e.length,s=0;s<r;s++)t[e[s]]={distance:-1,parent:null};return t}function Io(t){let e=Oo(),r=[t];for(e[t].distance=0;r.length;){let s=r.pop(),n=Object.keys(Be[s]);for(let o=n.length,i=0;i<o;i++){let a=n[i],l=e[a];l.distance===-1&&(l.distance=e[s].distance+1,l.parent=s,r.unshift(a))}}return e}function Ro(t,e){return function(r){return e(t(r))}}function No(t,e){let r=[e[t].parent,t],s=Be[e[t].parent][t],n=e[t].parent;for(;e[n].parent;)r.unshift(e[n].parent),s=Ro(Be[e[n].parent][n],s),n=e[n].parent;return s.conversion=r,s}es.exports=function(t){let e=Io(t),r={},s=Object.keys(e);for(let n=s.length,o=0;o<n;o++){let i=s[o];e[i].parent!==null&&(r[i]=No(i,e))}return r}});var ss=x((xa,rs)=>{var gt=pt(),Ao=ts(),ie={},So=Object.keys(gt);function Co(t){let e=function(...r){let s=r[0];return s==null?s:(s.length>1&&(r=s),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function Lo(t){let e=function(...r){let s=r[0];if(s==null)return s;s.length>1&&(r=s);let n=t(r);if(typeof n=="object")for(let o=n.length,i=0;i<o;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}So.forEach(t=>{ie[t]={},Object.defineProperty(ie[t],"channels",{value:gt[t].channels}),Object.defineProperty(ie[t],"labels",{value:gt[t].labels});let e=Ao(t);Object.keys(e).forEach(s=>{let n=e[s];ie[t][s]=Lo(n),ie[t][s].raw=Co(n)})});rs.exports=ie});var cs=x(($a,ls)=>{"use strict";var ns=(t,e)=>(...r)=>`\x1B[${t(...r)+e}m`,os=(t,e)=>(...r)=>{let s=t(...r);return`\x1B[${38+e};5;${s}m`},is=(t,e)=>(...r)=>{let s=t(...r);return`\x1B[${38+e};2;${s[0]};${s[1]};${s[2]}m`},Me=t=>t,as=(t,e,r)=>[t,e,r],ae=(t,e,r)=>{Object.defineProperty(t,e,{get:()=>{let s=r();return Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0}),s},enumerable:!0,configurable:!0})},mt,le=(t,e,r,s)=>{mt===void 0&&(mt=ss());let n=s?10:0,o={};for(let[i,a]of Object.entries(mt)){let l=i==="ansi16"?"ansi":i;i===e?o[l]=t(r,n):typeof a=="object"&&(o[l]=t(a[e],n))}return o};function Po(){let t=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[r,s]of Object.entries(e)){for(let[n,o]of Object.entries(s))e[n]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},s[n]=e[n],t.set(o[0],o[1]);Object.defineProperty(e,r,{value:s,enumerable:!1})}return Object.defineProperty(e,"codes",{value:t,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",ae(e.color,"ansi",()=>le(ns,"ansi16",Me,!1)),ae(e.color,"ansi256",()=>le(os,"ansi256",Me,!1)),ae(e.color,"ansi16m",()=>le(is,"rgb",as,!1)),ae(e.bgColor,"ansi",()=>le(ns,"ansi16",Me,!0)),ae(e.bgColor,"ansi256",()=>le(os,"ansi256",Me,!0)),ae(e.bgColor,"ansi16m",()=>le(is,"rgb",as,!0)),e}Object.defineProperty(ls,"exports",{enumerable:!0,get:Po})});var fs=x((wa,us)=>{"use strict";us.exports={stdout:!1,stderr:!1}});var ds=x((Ta,hs)=>{"use strict";var qo=(t,e,r)=>{let s=t.indexOf(e);if(s===-1)return t;let n=e.length,o=0,i="";do i+=t.substr(o,s-o)+e+r,o=s+n,s=t.indexOf(e,o);while(s!==-1);return i+=t.substr(o),i},Do=(t,e,r,s)=>{let n=0,o="";do{let i=t[s-1]==="\r";o+=t.substr(n,(i?s-1:s)-n)+e+(i?`\r
2
+ `:`
3
+ `)+r,n=s+1,s=t.indexOf(`
4
+ `,n)}while(s!==-1);return o+=t.substr(n),o};hs.exports={stringReplaceAll:qo,stringEncaseCRLFWithFirstIndex:Do}});var ys=x((Oa,bs)=>{"use strict";var Fo=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,ps=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,Bo=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,Mo=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,ko=new Map([["n",`
5
+ `],["r","\r"],["t"," "],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e","\x1B"],["a","\x07"]]);function ms(t){let e=t[0]==="u",r=t[1]==="{";return e&&!r&&t.length===5||t[0]==="x"&&t.length===3?String.fromCharCode(parseInt(t.slice(1),16)):e&&r?String.fromCodePoint(parseInt(t.slice(2,-1),16)):ko.get(t)||t}function jo(t,e){let r=[],s=e.trim().split(/\s*,\s*/g),n;for(let o of s){let i=Number(o);if(!Number.isNaN(i))r.push(i);else if(n=o.match(Bo))r.push(n[2].replace(Mo,(a,l,c)=>l?ms(l):c));else throw new Error(`Invalid Chalk template style argument: ${o} (in style '${t}')`)}return r}function Go(t){ps.lastIndex=0;let e=[],r;for(;(r=ps.exec(t))!==null;){let s=r[1];if(r[2]){let n=jo(s,r[2]);e.push([s].concat(n))}else e.push([s])}return e}function gs(t,e){let r={};for(let n of e)for(let o of n.styles)r[o[0]]=n.inverse?null:o.slice(1);let s=t;for(let[n,o]of Object.entries(r))if(Array.isArray(o)){if(!(n in s))throw new Error(`Unknown Chalk style: ${n}`);s=o.length>0?s[n](...o):s[n]}return s}bs.exports=(t,e)=>{let r=[],s=[],n=[];if(e.replace(Fo,(o,i,a,l,c,h)=>{if(i)n.push(ms(i));else if(l){let f=n.join("");n=[],s.push(r.length===0?f:gs(t,r)(f)),r.push({inverse:a,styles:Go(l)})}else if(c){if(r.length===0)throw new Error("Found extraneous } in Chalk template literal");s.push(gs(t,r)(n.join(""))),n=[],r.pop()}else n.push(h)}),s.push(n.join("")),r.length>0){let o=`Chalk template literal is missing ${r.length} closing bracket${r.length===1?"":"s"} (\`}\`)`;throw new Error(o)}return s.join("")}});var Os=x((Ia,Ts)=>{"use strict";var $e=cs(),{stdout:yt,stderr:Et}=fs(),{stringReplaceAll:_o,stringEncaseCRLFWithFirstIndex:Uo}=ds(),{isArray:ke}=Array,vs=["ansi","ansi","ansi256","ansi16m"],ce=Object.create(null),Ho=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=yt?yt.level:0;t.level=e.level===void 0?r:e.level},vt=class{constructor(e){return xs(e)}},xs=t=>{let e={};return Ho(e,t),e.template=(...r)=>ws(e.template,...r),Object.setPrototypeOf(e,je.prototype),Object.setPrototypeOf(e.template,e),e.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},e.template.Instance=vt,e.template};function je(t){return xs(t)}for(let[t,e]of Object.entries($e))ce[t]={get(){let r=Ge(this,xt(e.open,e.close,this._styler),this._isEmpty);return Object.defineProperty(this,t,{value:r}),r}};ce.visible={get(){let t=Ge(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:t}),t}};var $s=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(let t of $s)ce[t]={get(){let{level:e}=this;return function(...r){let s=xt($e.color[vs[e]][t](...r),$e.color.close,this._styler);return Ge(this,s,this._isEmpty)}}};for(let t of $s){let e="bg"+t[0].toUpperCase()+t.slice(1);ce[e]={get(){let{level:r}=this;return function(...s){let n=xt($e.bgColor[vs[r]][t](...s),$e.bgColor.close,this._styler);return Ge(this,n,this._isEmpty)}}}}var Vo=Object.defineProperties(()=>{},{...ce,level:{enumerable:!0,get(){return this._generator.level},set(t){this._generator.level=t}}}),xt=(t,e,r)=>{let s,n;return r===void 0?(s=t,n=e):(s=r.openAll+t,n=e+r.closeAll),{open:t,close:e,openAll:s,closeAll:n,parent:r}},Ge=(t,e,r)=>{let s=(...n)=>ke(n[0])&&ke(n[0].raw)?Es(s,ws(s,...n)):Es(s,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(s,Vo),s._generator=t,s._styler=e,s._isEmpty=r,s},Es=(t,e)=>{if(t.level<=0||!e)return t._isEmpty?"":e;let r=t._styler;if(r===void 0)return e;let{openAll:s,closeAll:n}=r;if(e.indexOf("\x1B")!==-1)for(;r!==void 0;)e=_o(e,r.close,r.open),r=r.parent;let o=e.indexOf(`
6
+ `);return o!==-1&&(e=Uo(e,n,s,o)),s+e+n},bt,ws=(t,...e)=>{let[r]=e;if(!ke(r)||!ke(r.raw))return e.join(" ");let s=e.slice(1),n=[r.raw[0]];for(let o=1;o<r.length;o++)n.push(String(s[o-1]).replace(/[{}\\]/g,"\\$&"),String(r.raw[o]));return bt===void 0&&(bt=ys()),bt(t,n.join(""))};Object.defineProperties(je.prototype,ce);var _e=je();_e.supportsColor=yt;_e.stderr=je({level:Et?Et.level:0});_e.stderr.supportsColor=Et;Ts.exports=_e});var Rs=x((Ra,Is)=>{Is.exports={rosReleases:{kinetic:{rosVersion:1,ubuntuCodename:"xenial"},melodic:{rosVersion:1,ubuntuCodename:"bionic"},noetic:{rosVersion:1,ubuntuCodename:"focal"},dashing:{rosVersion:2},eloquent:{rosVersion:2},foxy:{rosVersion:2},galactic:{rosVersion:2},humble:{rosVersion:2},iron:{rosVersion:2},rolling:{rosVersion:2}}}});var He=x((Na,js)=>{var Xo=J(),Ns=Wr(),ue={get:require("lodash/get"),set:require("lodash/set"),unset:require("lodash/unset"),forEach:require("lodash/forEach"),map:require("lodash/map"),isEmpty:require("lodash/isEmpty"),eq:require("lodash/isEqual"),isPlainObject:require("lodash/isPlainObject"),merge:require("lodash/merge")},fe=zr(),we=Os(),Wo=Rs();fe.setAll=t=>Object.values(fe.getLoggers()).forEach(e=>e.setLevel(t));var As={warn:we.yellow,error:we.red,info:we.green,debug:we.gray},Jo=t=>As[t]?As[t](t):t,zo=fe.methodFactory;fe.methodFactory=(t,e,r)=>{let s=zo(t,e,r);if(typeof window<"u"){let o=`${r} ${t}`;return(...i)=>s(`[${o}]`,...i)}let n=`${r} ${Jo(t)}`;return(...o)=>s(`[${we.blue(new Date().toISOString())} ${n}]`,...o)};var Qo=fe.getLogger,Ko=t=>JSON.parse(JSON.stringify(t)),Yo=t=>JSON.parse(atob(t.split(".")[1])),Zo=t=>{try{return JSON.parse(t)}catch{return null}},Ss=(t,e,r)=>{t&&(r(t),t[e]?.forEach(s=>Ss(s,e,r)))},Cs=(t,e,r,s=[])=>{r(t,s);let n=e[0];if(n){let o=t[n];o&&Cs(o,e.slice(1),r,s.concat(n))}},ei=t=>new Promise(e=>{setTimeout(e,t)}),Ls=(t,e=[],r={})=>(ue.forEach(t,(s,n)=>{let o=e.concat(String(n));(ue.isPlainObject(s)||s instanceof Array)&&s!==null?Ls(s,o,r):r[Bs(o)]=s}),r),Ps=(t,e,r,s=[],n={})=>{if(e.length==0||e[0]=="#"){r(t,s,n);return}let o=e[0];if(o){for(let i in t)if(i==o||o=="*"||o.startsWith("+")){let a=o.startsWith("+")&&o.length>1?Object.assign({},n,{[o.slice(1)]:i}):n;Ps(t[i],e.slice(1),r,s.concat([i]),a)}}},qs=(t,e,r)=>{if(e.length==0)return t;let s=e.shift();e.length==0?t[s]=r:(t[s]||(t[s]={}),qs(t[s],e,r))},Ds=t=>t.replace(/%/g,"%25").replace(/\//g,"%2F"),Fs=t=>t.replace(/%25/g,"%").replace(/%2F/g,"/"),Bs=t=>{let e=r=>r.startsWith("+")?"+":r;return`/${t.map(e).map(Ds).join("/")}`},re=t=>{let e=t.split("/").map(Fs);return e.length>0&&e[0].length==0&&e.shift(),e.length>0&&e.at(-1).length==0&&e.pop(),e},Ms=(t,e)=>{let r=(o,i)=>{if(o.length==0||o[0][0]=="#"||i.length==0)return!0;if(o[0]==i[0])return r(o.slice(1),i.slice(1));if(o[0][0]=="+"){let a=r(o.slice(1),i.slice(1));return a&&Object.assign({[o[0].slice(1)]:i[0]},a)}return!1},s=re(t),n=re(e);return r(s,n)},ti=(t,e)=>{let r=re(e),s=re(t);return ks(r,s)&&r.length<s.length},ks=(t,e)=>t.length==0?!0:t[0]==e[0]&&ks(t.slice(1),e.slice(1)),ri=t=>{let e=t.split(":");return{organization:e[0],client:e[1],sub:e.slice(2)}},si=t=>{let e=re(t);return{organization:e[0],device:e[1],capabilityScope:e[2],capabilityName:e[3],capability:`${e[2]}/${e[3]}`,version:e[4],sub:e.slice(5)}},ni=t=>t.length==0?null:JSON.parse(t.toString("utf-8")),oi=(t,e,r,s=1e3)=>{let n=[],o=a=>{e.forEach(l=>Ms(`${l}/#`,a)&&n.push(a))};t.on("message",o),e.forEach(a=>{typeof a=="string"?t.subscribe(`${a}/#`):console.warn("Ignoring",a,"since it is not a string.")});let i=typeof Buffer<"u"?Buffer.alloc(0):null;setTimeout(()=>{t.removeListener("message",o),e.forEach(l=>t.unsubscribe(`${l}/#`));let a=n.length;console.log(`clearing ${a} retained messages from ${e}`),n.forEach(l=>{t.publish(l,i,{retain:!0})}),r&&r(a)},s)},ii=()=>Math.random().toString(36).slice(2),Ue=(t,e)=>Xo(Ns(t),Ns(e)),ai=(t,e=void 0,r={})=>{if(!t)return e?ue.set({},e,t):t;let s=Object.keys(t).filter(i=>(!r.maxVersion||Ue(i,r.maxVersion)<=0)&&(!r.minVersion||Ue(r.minVersion,i)<=0)).sort(Ue),n={},o=e&&re(e);return s.forEach(i=>{let a=o?ue.get(t[i],o):t[i];ue.merge(n,a)}),o?ue.set({},o,n):n},li=["B","KB","MB","GB","TB"],ci=t=>{if(!t)return"--";let e=0;for(;t>1024;)t/=1024,e++;return`${t.toFixed(2)} ${li[e]}`},ui=t=>{if(!t)return"--";let e={};t>3600&&(e.h=Math.floor(t/3600),t=t%3600),t>60&&(e.m=Math.floor(t/60),t=t%60),e.s=Math.floor(t);let r="";return e.h>0&&(r+=`${e.h}h `),e.m>0&&(r+=`${e.m}m `),!e.h&&(r+=`${e.s}s`),r.trim()};js.exports={parseMQTTUsername:ri,parseMQTTTopic:si,pathToTopic:Bs,topicToPath:re,toFlatObject:Ls,topicMatch:Ms,mqttParsePayload:ni,getRandomId:ii,versionCompare:Ue,loglevel:fe,getLogger:Qo,mergeVersions:ai,mqttClearRetained:oi,isSubTopicOf:ti,clone:Ko,setFromPath:qs,forMatchIterator:Ps,encodeTopicElement:Ds,decodeTopicElement:Fs,constants:Wo,visit:Ss,wait:ei,formatBytes:ci,formatDuration:ui,tryJSONParse:Zo,decodeJWT:Yo,visitAncestor:Cs}});var Tt=x((Aa,Us)=>{var k={get:require("lodash/get"),set:require("lodash/set"),unset:require("lodash/unset"),forEach:require("lodash/forEach"),map:require("lodash/map"),isEmpty:require("lodash/isEmpty"),eq:require("lodash/isEqual"),isPlainObject:require("lodash/isPlainObject"),merge:require("lodash/merge")},{topicToPath:Te,pathToTopic:fi,toFlatObject:hi,topicMatch:Gs,forMatchIterator:di}=He(),wt=(t,e)=>{if(!e||e.length==0)return;k.unset(t,e);let r=e.slice(0,-1),s=r.length==0?t:k.get(t,r);return k.isEmpty(s)?wt(t,r):e},pi=(t,e)=>(k.forEach(e,(r,s)=>{let n=Te(s);r==null?wt(t,n):k.set(t,n,r)}),t),_s=(t,e)=>{if(e.length==0)return;let r=e[0];if(r)for(let s in t)s!=r&&r!="*"&&!r.startsWith("+")?delete t[s]:_s(t[s],e.slice(1))},$t=class{#e={};#t=[];#r=[];constructor(e={}){this.#e=e}updateFromArray(e,r,s={}){let n=k.get(this.#e,e);if(r==null){if(n==null)return{};wt(this.#e,e)}else{if(k.eq(n,r))return{};k.set(this.#e,e,r)}let o=fi(e),i={[o]:r},a;if(r instanceof Object){let l=hi(r);a={},k.forEach(l,(c,h)=>{a[`${o}${h}`]=c})}else a=i;return this.#t.forEach(l=>l(i,s)),this.#r.forEach(l=>l(a,s)),a}update(e,r,s){if(typeof e=="string")return this.updateFromTopic(e,r,s);if(e instanceof Array)return this.updateFromArray(e,r,s);throw new Error("unrecognized path expression")}updateFromTopic(e,r,s){return this.updateFromArray(Te(e),r,s)}updateFromModifier(e,r){return k.map(e,(s,n)=>this.updateFromTopic(n,s,r))}subscribe(e){e instanceof Function?this.#t.push(e):console.warn("DataCache.subscribe expects a function as argument. Did you mean to use subscribePath?")}subscribePath(e,r){this.#t.push((s,n)=>{k.forEach(s,(o,i)=>{let a=Gs(e,i);a&&r(o,i,a,n)})})}subscribePathFlat(e,r){this.#r.push((s,n)=>{k.forEach(s,(o,i)=>{let a=Gs(e,i);a&&r(o,i,a,n)})})}unsubscribe(e){this.#t=this.#t.filter(r=>r!=e)}get(e=[]){return e.length==0?this.#e:k.get(this.#e,e)}getByTopic(e){return this.get(Te(e))}filter(e){let r=JSON.parse(JSON.stringify(this.get()));return _s(r,e),r}filterByTopic(e){return this.filter(Te(e))}forMatch(e,r){let s=Te(e);this.forPathMatch(s,r)}forPathMatch(e,r){di(this.get(),e,r)}};Us.exports={DataCache:$t,updateObject:pi}});var At=x((Ca,Ws)=>{"use strict";var{mqttParsePayload:gi,topicMatch:Ot,topicToPath:z,pathToTopic:Oe,toFlatObject:It,getLogger:mi,mergeVersions:bi,parseMQTTTopic:yi,isSubTopicOf:Sa,versionCompare:Ei,encodeTopicElement:vi,visitAncestor:xi}=He(),{DataCache:Hs}=Tt(),Q=require("lodash"),R=mi("MqttSync"),Rt="$SYS/broker/uptime",he="$_",$i=()=>{},wi=t=>typeof t=="object"?JSON.parse(JSON.stringify(t)):t,Vs=t=>t.endsWith("/#")?t:t.endsWith("/")?t.concat("#"):t.concat("/#"),Xs=t=>t.replace(/\/\//g,"/"),Nt=class{data=new Hs;subscribedPaths={};publishedPaths={};publishedMessages=new Hs;publishQueue=new Map;heartbeatWaitersOnce=[];heartbeats=0;beforeDisconnectHooks=[];constructor({mqttClient:e,onChange:r,ignoreRetain:s,migrate:n,onReady:o,sliceTopic:i,onHeartbeatGranted:a}){this.mqtt=e,this.mqtt.on("message",(l,c,h)=>{let f=c&&c.toString();if(R.debug("got message",l,f.slice(0,180),f.length>180?`... (${f.length} bytes)`:"",h.retain),l==Rt)this.heartbeats>0&&(this.heartbeatWaitersOnce.forEach(u=>u()),this.heartbeatWaitersOnce=[]),this.heartbeats==1&&!n&&o&&o(),this.heartbeats++;else if(h.retain||s){let u=z(l);R.debug("processing message",l,u),i&&(u=u.slice(i),l=Oe(u));let E=gi(c);if(this.isPublished(l))this.publishedMessages.updateFromArray([...u,he],E),this.data.update(l,E,{external:!0});else if(this.isSubscribed(l)){R.debug("applying received update",l);let m=this.data.update(l,E);r&&Object.keys(m).length>0&&r(m)}}}),this.mqtt.subscribe(Rt,{rap:!0},(l,c)=>{R.debug(Rt,{granted:c}),c.length>0&&a?.()}),n?.length>0&&this.migrate(n,()=>{R.debug("done migrating",o),o&&this.waitForHeartbeatOnce(o)})}publishAtLevel(e,r,s){R.debug(`publishingAtLevel ${s}`,e,r),s>0?Q.forEach(r,(n,o)=>{let i=`${e}/${vi(o)}`;R.debug(`publishing ${i}`),this.publishAtLevel(i,n,s-1)}):this.mqtt.publish(e,JSON.stringify(r),{retain:!0},n=>{n&&R.warn("Error when publishing migration result",n)})}migrate(e,r=void 0){let s=e.length;if(s==0){r&&r();return}let n=()=>--s==0&&r&&r();e.forEach(({topic:o,newVersion:i,transform:a=void 0,flat:l=!1,level:c=0})=>{R.debug("migrating",o,i);let{organization:h,device:f,capability:u,sub:E}=yi(o),m=`/${h}/${f}/${u}`,$=E.length==0?"/#":Oe(E),I=`${m}/+${$}`;this.subscribe(I,T=>{if(T){R.warn("Error during migration",T),n();return}this.waitForHeartbeatOnce(()=>{R.debug("got heartbeat",o,I);let V=this.data.getByTopic(m);if(!V){this.unsubscribe(I),n();return}let L=bi(V,$,{maxVersion:i}),X=Q.get(L,z($)),_=a?a(X):X,K=Xs(`${m}/${i}/${$}`);if(R.debug("publishing merged",K),l){let j=It(_),v=z(K);Q.forEach(j,(M,Y)=>{let We=Oe(v.concat(z(Y)));this.mqtt.publish(We,JSON.stringify(M),{retain:!0},qt=>{qt&&R.warn(`Error when publishing migration result for ${Y}`,qt)})})}else this.publishAtLevel(K,_,c);this.unsubscribe(I),this.waitForHeartbeatOnce(()=>{let v=Object.keys(V).filter(M=>Ei(M,i)<0).map(M=>Xs(`${m}/${M}/${$}`));R.debug({prefixesToClear:v}),this.clear(v),n()})})})})}clear(e,r=void 0,s={}){let n=[],o=a=>{e.forEach(l=>Ot(`${l}/#`,a)&&(!s.filter||s.filter(a))&&n.push(a))};this.mqtt.on("message",o),e.forEach(a=>{typeof a=="string"?this.mqtt.subscribe(`${a}/#`):R.warn("Ignoring",a,"since it is not a string.")});let i=typeof Buffer<"u"?Buffer.alloc(0):null;this.waitForHeartbeatOnce(()=>{this.mqtt.removeListener("message",o),e.forEach(l=>this.mqtt.unsubscribe(`${l}/#`));let a=n.length;R.debug(`clearing ${a} retained messages from ${e}`),n.forEach(l=>{this.mqtt.publish(l,i,{retain:!0})}),r&&r(a)})}waitForHeartbeatOnce(e){setTimeout(()=>this.heartbeatWaitersOnce.push(e),1)}isSubscribed(e){return Object.keys(this.subscribedPaths).some(r=>Ot(r,e))}isPublished(e){return Object.keys(this.publishedPaths).some(r=>Ot(r,e)&&!this.publishedPaths[r].atomic)}subscribe(e,r=$i){if(e=Vs(e),R.debug("subscribing to",e),this.subscribedPaths[e]){R.debug("already subscribed to",e),r();return}this.mqtt.subscribe(e,{rap:!0},(s,n)=>{R.debug("subscribe",e,"granted:",n),n&&n.some(o=>o.topic==e&&o.qos<128)?(this.subscribedPaths[e]=1,r(null)):r(`not permitted to subscribe to topic ${e}, ${JSON.stringify(n)}`)})}unsubscribe(e){this.subscribedPaths[e]&&(this.mqtt.unsubscribe(e),delete this.subscribedPaths[e])}_actuallyPublish(e,r){return this.mqtt.connected?(R.debug("actually publishing",e),this.mqtt.publish(e,r==null?null:JSON.stringify(r),{retain:!0}),!0):(R.warn("not connected, not publishing",e),!1)}_processQueue_rec(e){if(this.publishQueue.size>0){let[r,s]=this.publishQueue.entries().next().value;this._actuallyPublish(r,s)?(this.publishQueue.delete(r),this._processQueue_rec(e)):setTimeout(()=>this._processQueue_rec(e),5e3)}else e()}_processQueue(){this._processing||(this._processing=!0,this._processQueue_rec(()=>this._processing=!1))}setThrottle(e){this._processQueueThrottled=Q.throttle(this._processQueue.bind(this),e)}clearThrottle(){delete this._processQueueThrottled}addToQueue(e,r){this.publishQueue.set(e,r)}_enqueue(e,r){R.debug("enqueuing",e),this.addToQueue(e,r),this._processQueueThrottled?this._processQueueThrottled():this._processQueue();let s=z(e);this.publishedMessages.updateFromArray([...s,he],r==null?null:wi(r))}publish(e,r={atomic:!1}){if(e=Vs(e),Q.isEqual(this.publishedPaths[e],r))return!1;if(this.publishedPaths[e]=r,r.atomic)return this.data.subscribePath(e,(s,n,o,i)=>{if(i?.external)return;R.debug("processing change (atomic)",n,e);let a=e.slice(0,e.length-2),l=Oe(z(n).slice(0,z(a).length));this._enqueue(l,this.data.getByTopic(l))}),!0;this.mqtt.subscribe(e),this.data.subscribePath(e,(s,n,o,i)=>{if(i?.external)return;R.debug("processing change",n);let a=z(n),l=this.publishedMessages.get(a);Q.each(l,(h,f)=>{if(f==he)return!0;let u=Object.keys(It(h)).filter(E=>E.endsWith(he));R.debug("flat->atomic: ",{toClear:u},f),u.forEach(E=>{let m=E.slice(0,-(he.length+1)),$=`${n}/${f}/${m}`;this._enqueue($,null)})});let c=this.publishedMessages.get();return xi(c,a.slice(0,-1),(h,f)=>{let u=h[he];if(u&&Q.isObject(u)){R.debug("atomic->flat",{oldVal:u});let E=Oe(f);this._enqueue(E,null);let m=It(u);Q.each(m,($,I)=>{let T=`${E}${I}`;this._enqueue(T,$)})}}),this._enqueue(n,s),!0})}beforeDisconnect(){this.beforeDisconnectHooks.forEach(e=>e(this))}onBeforeDisconnect(e){this.beforeDisconnectHooks.push(e)}};Ws.exports=Nt});var pe={};Dt(pe,{Code:()=>Ai,ErrorBoundary:()=>Pt,InlineCode:()=>Si,LevelBadge:()=>Ni,MqttSync:()=>zs,Timer:()=>Ci,TimerContext:()=>en,TransitiveCapability:()=>Li,createWebComponent:()=>qi,fetchJson:()=>Ks,parseCookie:()=>Qs,useCapability:()=>Lt,useMqttSync:()=>Ct,useTopics:()=>Ii,useTransitive:()=>Oi});module.exports=an(pe);var w=D(require("react"));var ze=D(require("react")),Qe=require("react"),ln=require("react/jsx-runtime"),cn=["xxl","xl","lg","md","sm","xs"],un="xs",Ft=ze.createContext({prefixes:{},breakpoints:cn,minBreakpoint:un}),{Consumer:Bi,Provider:Mi}=Ft;function Se(t,e){let{prefixes:r}=(0,Qe.useContext)(Ft);return t||r[e]||e}var Bt=D(require("react")),Mt=require("react/jsx-runtime"),fn=["as","disabled"];function hn(t,e){if(t==null)return{};var r={},s=Object.keys(t),n,o;for(o=0;o<s.length;o++)n=s[o],!(e.indexOf(n)>=0)&&(r[n]=t[n]);return r}function dn(t){return!t||t.trim()==="#"}function Ke({tagName:t,disabled:e,href:r,target:s,rel:n,role:o,onClick:i,tabIndex:a=0,type:l}){t||(r!=null||s!=null||n!=null?t="a":t="button");let c={tagName:t};if(t==="button")return[{type:l||"button",disabled:e},c];let h=u=>{if((e||t==="a"&&dn(r))&&u.preventDefault(),e){u.stopPropagation();return}i?.(u)},f=u=>{u.key===" "&&(u.preventDefault(),h(u))};return t==="a"&&(r||(r="#"),e&&(r=void 0)),[{role:o??"button",disabled:void 0,tabIndex:e?void 0:a,href:r,target:t==="a"?s:void 0,"aria-disabled":e||void 0,rel:t==="a"?n:void 0,onClick:h,onKeyDown:f},c]}var pn=Bt.forwardRef((t,e)=>{let{as:r,disabled:s}=t,n=hn(t,fn),[o,{tagName:i}]=Ke(Object.assign({tagName:r,disabled:s},n));return(0,Mt.jsx)(i,Object.assign({},n,o,{ref:e}))});pn.displayName="Button";var kt=D(Je()),jt=D(require("react"));var Gt=require("react/jsx-runtime"),_t=jt.forwardRef(({bsPrefix:t,bg:e="primary",pill:r=!1,text:s,className:n,as:o="span",...i},a)=>{let l=Se(t,"badge");return(0,Gt.jsx)(o,{ref:a,...i,className:(0,kt.default)(n,l,r&&"rounded-pill",s&&`text-${s}`,e&&`bg-${e}`)})});_t.displayName="Badge";var se=_t;var Ut=D(Je()),Ht=D(require("react"));var Vt=require("react/jsx-runtime"),Xt=Ht.forwardRef(({as:t,bsPrefix:e,variant:r="primary",size:s,active:n=!1,disabled:o=!1,className:i,...a},l)=>{let c=Se(e,"btn"),[h,{tagName:f}]=Ke({tagName:t,disabled:o,...a});return(0,Vt.jsx)(f,{...h,...a,ref:l,disabled:o,className:(0,Ut.default)(i,c,n&&"active",r&&`${c}-${r}`,s&&`${c}-${s}`,a.href&&o&&"disabled")})});Xt.displayName="Button";var Ye=Xt;var Zs=D(Yt());var y={};Dt(y,{MqttSync:()=>zs,fetchJson:()=>Ks,parseCookie:()=>Qs});A(y,D(He()));A(y,D(Tt()));var Js=D(At()),zs=Js.default,Qs=t=>t.split(";").map(e=>e.split("=")).reduce((e,r)=>(e[decodeURIComponent(r[0].trim())]=r[1]&&decodeURIComponent(r[1].trim()),e),{}),Ks=(t,e,r={})=>{fetch(t,{method:r.method||(r.body?"post":"get"),mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json",...r.headers},redirect:"follow",referrerPolicy:"no-referrer",body:r.body?JSON.stringify(r.body):void 0}).then(s=>{let n=!s.ok&&`fetching ${t} failed: ${s.status} ${s.statusText}`;s.json().then(o=>e(n,o)).catch(o=>{throw new Error(o)})}).catch(s=>e(`error: ${s}`))};var B=D(require("react")),Xe=D(require("lodash")),Ys=D(require("mqtt-browser"));var Ti=At(),F=(0,y.getLogger)("utils-web/hooks");F.setLevel("info");F.setLevel("debug");var Ct=({jwt:t,id:e,mqttUrl:r})=>{let[s,n]=(0,B.useState)("connecting"),[o,i]=(0,B.useState)(),[a,l]=(0,B.useState)({}),[c,h]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let f=(0,y.decodeJWT)(t),u=Ys.default.connect(r,{username:JSON.stringify({id:e,payload:f}),password:t});return u.on("connect",()=>{F.debug("connected");let E=new Ti({mqttClient:u,ignoreRetain:!0,onHeartbeatGranted:()=>h(!0)});i(E),n("connected"),E.data.subscribe(Xe.default.throttle(()=>l((0,y.clone)(E.data.get())),50))}),u.on("error",E=>{F.error(E),n(`error: ${E}`)}),()=>{F.info("cleaning up useMQTTSync"),o&&o.beforeDisconnect?(o.beforeDisconnect(),o.waitForHeartbeatOnce(()=>u.end())):u.end()}},[t,e]),{status:s,ready:c,StatusComponent:()=>B.default.createElement("div",null,s),mqttSync:o,data:a}},Oi=({jwt:t,id:e,host:r,ssl:s,capability:n,versionNS:o})=>{let[i,a]=n.split("/"),{device:l}=(0,y.decodeJWT)(t),c=[e,l,i,a],h=(0,y.pathToTopic)(c),f=[...c,o],u=(0,y.pathToTopic)(f),E=`${s&&JSON.parse(s)?"wss":"ws"}://mqtt.${r}`;return{...Ct({jwt:t,id:e,mqttUrl:E}),device:l,prefixPath:c,prefix:h,prefixPathVersion:f,prefixVersion:u}},Ii=({jwt:t,host:e="transitiverobotics.com",ssl:r=!0,topics:s=[]})=>{let[n,o]=(0,B.useState)();!Xe.default.isEqual(n,s)&&o(s);let{device:i,id:a,capability:l}=(0,y.decodeJWT)(t);if(i=="_fleet"){F.warn("useTopics only works for device JWTs, not _fleet ones");return}let c=`/${a}/${i}/@transitive-robotics/_robot-agent/+/status`,{mqttSync:h,data:f,status:u,ready:E,StatusComponent:m}=Ct({jwt:t,id:a,mqttUrl:`ws${r?"s":""}://mqtt.${e}`});(0,B.useEffect)(()=>{E&&h.subscribe(c,j=>j&&console.warn(j))},[h,E]);let $=(0,y.mergeVersions)(f[a]?.[i]["@transitive-robotics"]["_robot-agent"],"status").status,I=$?.runningPackages,[T,V]=l.split("/"),L=I?.[T]?.[V],X=L&&Object.values(L).filter(Boolean)[0],_=`/${a}/${i}/${l}/${X}`;(0,B.useEffect)(()=>{F.debug("topics",s),X&&s.forEach(j=>{F.debug(`subscribing to ${_}${j}`),h.subscribe(`${_}${j}`,v=>v&&F.warn(v))})},[n,X,h]);let K=Xe.default.get(f,(0,y.topicToPath)(_));return{data:f?.[a]?.[i],mqttSync:h,agentStatus:$,topicData:K}},Ve={},St={},Lt=({capability:t,name:e,userId:r,deviceId:s,host:n="transitiverobotics.com",ssl:o=!0,testing:i=!1})=>{let[a,l]=(0,B.useState)({loaded:!1}),c=(f,u)=>{F.debug(`custom component ${e}: ${f}`),St[e]=u,l(E=>({...E,loadedModule:u,loaded:!!u}))},h=(...f)=>Ve[e].forEach(u=>u(...f));return(0,B.useEffect)(()=>{if(F.debug(`loading custom component ${e}`),St[e])return c("already loaded",St[e]);if(Ve[e])return F.debug("already loading"),Ve[e].push(c);Ve[e]=[c];let f=i?"":`http${o?"s":""}://portal.${n}`,u=new URLSearchParams({userId:r,deviceId:s}),E=`${f}/running/${t}/dist/${e}`;import(`${E}.esm.js?${u.toString()}`).then(m=>h("loaded esm",m),m=>{F.warn(`No ESM module found for ${e}, loading iife`),import(`${E}.js?${u.toString()}`).then($=>h("loaded iife",$),$=>F.error(`Failed to load ${e} iife`,$))})},[t,e,r,s]),a};var de={badge:{width:"4em"},code:{color:"#700",borderLeft:"3px solid #aaa",padding:"0.5em 0px 0.5em 2em",backgroundColor:"#f0f0f0",borderRadius:"4px",marginTop:"0.5em"},inlineCode:{color:"#700",margin:"0px 0.5em 0px 0.5em"}},Ri=[w.default.createElement(se,{bg:"success",style:de.badge},"OK"),w.default.createElement(se,{bg:"warning",style:de.badge},"Warn"),w.default.createElement(se,{bg:"danger",style:de.badge},"Error"),w.default.createElement(se,{bg:"secondary",style:de.badge},"Stale")],Ni=({level:t})=>Ri[t]||w.default.createElement("span",null,t),Ai=({children:t})=>w.default.createElement("pre",{style:de.code},t),Si=({children:t})=>w.default.createElement("tt",{style:de.inlineCode},t),Ie={},en=w.default.createContext({}),Ci=({duration:t,onTimeout:e,onStart:r,setOnDisconnect:s,children:n})=>{t=t||60;let[o,i]=(0,w.useState)(t),[a,l]=(0,w.useState)(!1),c=(0,w.useMemo)(()=>Math.random().toString(36).slice(2),[]),h=()=>{console.log("stopping timer for",c),e&&setTimeout(e,1),clearInterval(Ie[c]),Ie[c]=null,l(!1)},f=()=>{let E=Ie[c];return console.log(E,Ie,o),!E&&o>0&&(l(!0),Ie[c]=setInterval(()=>i(m=>{if(--m>0)return m;h()}),1e3),r&&setTimeout(r,1)),h};(0,w.useEffect)(()=>{o>0&&!a&&f()},[o]),(0,w.useEffect)(()=>h,[]),s&&s(()=>{h()});let u=()=>i(t);return w.default.createElement(en.Provider,{value:{reset:u,duration:t,timer:o}},o>0?w.default.createElement("div",null,n,o<60&&w.default.createElement("div",null,"Timeout in: ",o," seconds")):w.default.createElement("div",null,"Timed out. ",w.default.createElement(Ye,{onClick:u},"Resume")))},Li=({jwt:t,ssl:e=!0,host:r="transitiverobotics.com",testing:s=!1,...n})=>{let{id:o,device:i,capability:a}=(0,y.decodeJWT)(t),l=i=="_fleet"?"fleet":"device",h=`${a.split("/")[1]}-${l}`,{loaded:f}=Lt({capability:a,name:h,userId:o||n.userId,deviceId:i,testing:s,host:r,ssl:e}),u=(0,w.useRef)();return(0,w.useEffect)(()=>{u.current?.instance?.setState(E=>({...E,id:o,jwt:t,host:r,ssl:e,...n}))},[u.current]),f?w.default.createElement(h,{id:o,jwt:t,host:r,ssl:e,...n,ref:u}):w.default.createElement("div",null,"Loading ",h)},Pt=class extends w.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0}}componentDidCatch(e,r){console.warn("ErrorBoundary caught:",e,r)}render(){return this.state.hasError?w.default.createElement("div",null,this.props.message||"Something went wrong here."):this.props.children}},Pi=t=>t.$$typeof==Symbol.for("react.forward_ref")||t.prototype?.render,qi=(t,e,r="0.0.0",s={})=>{let n=Pi(t)?w.default.createRef():null;class o extends w.default.Component{onDisconnect=null;state={};setOnDisconnect(a){this.onDisconnect=a}webComponentConstructed(a){let l=new MutationObserver(c=>{let h={};c.forEach(({attributeName:f})=>{h[f]=a.getAttribute(f)}),this.setState(f=>({...f,...h}))}).observe(a,{attributes:!0})}webComponentDisconnected(){this.setState({_disconnected:!0});try{this.onDisconnect&&this.onDisconnect()}catch(a){console.log("Error during onDisconnect of web-component",a)}}setConfig(a){this.setState({config:a})}render(){let a=s.stylesheets||["https://cdn.jsdelivr.net/gh/transitiverobotics/transitive-utils@0.8.3/web/css/bootstrap_transitive-bs-root.min.css"];return w.default.createElement("div",{id:`cap-${e}-${r}`,className:s.className||"transitive-bs-root"},w.default.createElement("style",null,a.map(l=>`@import url(${l});`)),!this.state._disconnected&&w.default.createElement(t,{ref:n,...this.props,...this.state,setOnDisconnect:this.setOnDisconnect.bind(this),setConfig:this.setConfig.bind(this)}))}}return Zs.default.create(o,e,s.shadowDOM||!1,n)};A(pe,y,module.exports);
7
+ /*! Bundled license information:
8
+
9
+ classnames/index.js:
10
+ (*!
11
+ Copyright (c) 2018 Jed Watson.
12
+ Licensed under the MIT License (MIT), see
13
+ http://jedwatson.github.io/classnames
14
+ *)
15
+ */
package/docs/client.md CHANGED
@@ -101,6 +101,14 @@ get or post (if body given) json
101
101
  * `callback` &#x20;
102
102
  * `options` (optional, default `{}`)
103
103
 
104
+ ## notifyListeners
105
+
106
+ set the returns for all listeners
107
+
108
+ #### Parameters
109
+
110
+ * `args` **...any**&#x20;
111
+
104
112
  ## parseCookie
105
113
 
106
114
  parse document cookies
@@ -109,9 +117,62 @@ parse document cookies
109
117
 
110
118
  * `str` &#x20;
111
119
 
120
+ ## TransitiveCapability
121
+
122
+ Dynamically load and use the Transitive web component specified in the JWT.
123
+ Embedding Transitive components this way also enables the use of functional
124
+ and object properties, which get lost when using the custom element (Web
125
+ Component) because HTML attributes are strings.
126
+ Example:
127
+
128
+ ```js
129
+ <TransitiveCapability jwt={jwt}
130
+ myconfig={{a: 1, b: 2}}
131
+ onData={(data) => setData(data)}
132
+ onclick={() => { console.log('custom click handler'); }}
133
+ />
134
+ ```
135
+
136
+ #### Parameters
137
+
138
+ * `$0` **[Object][1]**&#x20;
139
+
140
+ * `$0.jwt` &#x20;
141
+ * `$0.ssl` (optional, default `true`)
142
+ * `$0.host` (optional, default `'transitiverobotics.com'`)
143
+ * `$0.testing` (optional, default `false`)
144
+ * `$0.config` **...any**&#x20;
145
+
146
+ ## useCapability
147
+
148
+ Hook to load a Transitive capability. Besides loading the custom element,
149
+ this hook also returns any functions and objects the component exports in
150
+ `loadedModule`. Example:
151
+
152
+ ```js
153
+ const {loaded, loadedModule} = useCapability({
154
+ capability: '@transitive-robotics/terminal',
155
+ name: 'mock-device',
156
+ userId: 'user123',
157
+ deviceId: 'd_mydevice123',
158
+ });
159
+ ```
160
+
161
+ #### Parameters
162
+
163
+ * `$0` **[Object][1]**&#x20;
164
+
165
+ * `$0.capability` &#x20;
166
+ * `$0.name` &#x20;
167
+ * `$0.userId` &#x20;
168
+ * `$0.deviceId` &#x20;
169
+ * `$0.host` (optional, default `'transitiverobotics.com'`)
170
+ * `$0.ssl` (optional, default `true`)
171
+ * `$0.testing` (optional, default `false`)
172
+
112
173
  ## useMqttSync
113
174
 
114
- hook for using MqttSync in React
175
+ Hook for using MqttSync in React.
115
176
 
116
177
  #### Parameters
117
178
 
@@ -121,6 +182,46 @@ hook for using MqttSync in React
121
182
  * `$0.id` &#x20;
122
183
  * `$0.mqttUrl` &#x20;
123
184
 
185
+ Returns **[object][1]** An object `{data, mqttSync, ready, StatusComponent, status}`
186
+ where:
187
+ `data` is a reactive data source in React containing all the data received by
188
+ mqttsync,
189
+ `mqttSync` is the MqttSync object itself,
190
+ `ready` indicates when mqttSync is ready to be used (connected and received
191
+ successfully subscribed to mqtt system heartbeats)
192
+
193
+ ## useTopics
194
+
195
+ Subscribe to MqttSync topics using the provided JWT. This will
196
+ automatically find which version of the capability named in the JWT is running
197
+ on the device of the JWT and get the data for that version.
198
+
199
+ Example usage (with webrtc-video):
200
+
201
+ ```js
202
+ const { agentStatus, topicData } = useTopics({ jwt, topics: [
203
+ '/options/videoSource',
204
+ '/stats/+/log/'
205
+ ]});
206
+ ```
207
+
208
+ #### Parameters
209
+
210
+ * `options` **[object][1]** An object containing:
211
+ `JWT`: A list of subtopics of the capability named in the JWT.
212
+ `topics`: A list of subtopics of the capability named in the JWT.
213
+
214
+ * `options.jwt` &#x20;
215
+ * `options.host` (optional, default `'transitiverobotics.com'`)
216
+ * `options.ssl` (optional, default `true`)
217
+ * `options.topics` (optional, default `[]`)
218
+
219
+ Returns **[object][1]** An object `{data, mqttSync, ready, agentStatus, topicData}`
220
+ where:
221
+ `agentStatus` is the `status` field of the running robot agent, including
222
+ heartbeat and runningPackages, and
223
+ `topicData` is the data for the selected topics of the capability
224
+
124
225
  ## useTransitive
125
226
 
126
227
  Hook for using Transitive in React. Connects to MQTT, establishes sync, and
package/esbuild.js ADDED
@@ -0,0 +1,54 @@
1
+ const esbuild = require('esbuild');
2
+ const fs = require('fs');
3
+
4
+ const isDevelopment = (process.env.npm_lifecycle_event != 'prepare');
5
+
6
+ const config = {
7
+ entryPoints: [{in: './index.js', out: 'utils-web'}],
8
+ bundle: true,
9
+ format: 'cjs',
10
+ preserveSymlinks: true, // this allows us to use symlinks
11
+ // minify: !isDevelopment,
12
+ // sourcemap: isDevelopment,
13
+ minify: true,
14
+ sourcemap: false,
15
+ target: ['chrome110', 'firefox110', 'safari15', 'edge110'],
16
+ // target: ['es2022'],
17
+ external: ['react', 'react-dom', 'react-shadow-dom-retarget-events', 'lodash',
18
+ 'mqtt-browser', '@webcomponents/shadydom', '@webcomponents/custom-elements',
19
+ 'react-web-component-style-loader/exports'],
20
+ outdir: 'dist',
21
+ loader: {
22
+ '.js': 'jsx',
23
+ '.svg': 'text',
24
+ // '.wasm': 'file',
25
+ // '.css': 'local-css',
26
+ },
27
+ plugins: [{
28
+ name: 'rebuild-notify',
29
+ setup(build) {
30
+ build.onEnd(result => {
31
+ console.log(new Date(),
32
+ `build ended with ${result.errors.length} errors`);
33
+ })
34
+ },
35
+ }
36
+ ],
37
+ };
38
+
39
+ const run = async () => {
40
+ const ctx = await esbuild.context(config);
41
+ if (isDevelopment) {
42
+ await ctx.watch();
43
+ } else {
44
+ await ctx.rebuild();
45
+ process.exit(0);
46
+ }
47
+ };
48
+
49
+ run();
50
+
51
+ // in dev we also compile the test app
52
+ if (isDevelopment) {
53
+ require('./test/esbuild.js');
54
+ }
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@transitive-sdk/utils-web",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
4
4
  "description": "Web utils for the Transitive framework",
5
5
  "homepage": "https://transitiverobotics.com",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/transitiverobotics/transitive-utils.git",
9
+ "directory": "web"
10
+ },
6
11
  "author": {
7
12
  "name": "Christian Fritz",
8
13
  "email": "christian@transitiverobotics.com"
@@ -14,43 +19,32 @@
14
19
  "publishConfig": {
15
20
  "access": "public"
16
21
  },
17
- "main": "dist/utils-web.js",
22
+ "browser": "dist/utils-web.js",
18
23
  "scripts": {
19
- "test": "webpack serve -c webpack-test.config.js",
20
- "build-test": "webpack -c webpack-test.config.js",
21
- "prepare": "webpack --no-watch --mode=production && cd css && npx cleancss -o bootstrap_transitive-bs-root.min.css bootstrap_transitive-bs-root.css",
24
+ "prepare": "node esbuild.js && cd css && npx cleancss -o bootstrap_transitive-bs-root.min.css bootstrap_transitive-bs-root.css",
22
25
  "prepack": "cat ../docs.js | node --input-type=module - client",
23
- "dev": "webpack"
26
+ "dev": "node esbuild.js"
24
27
  },
25
28
  "dependencies": {
26
- "@babel/runtime": "^7.16.7",
27
29
  "bootstrap": "^4.6.0",
28
30
  "chalk": "^4.1.2",
29
31
  "jsonwebtoken": "^8.5.1",
30
32
  "lodash": "^4.17.21",
31
33
  "loglevel": "^1.8.0",
32
34
  "mqtt-browser": "^4.2.7",
35
+ "react-bootstrap": "^2.9.1",
33
36
  "react-shadow-dom-retarget-events": "^1.0.8",
37
+ "react-web-component-style-loader": "^0.1.4-alpha",
34
38
  "semver": "7.3.5"
35
39
  },
36
40
  "devDependencies": {
37
- "@babel/core": "^7.13.8",
38
- "@babel/plugin-proposal-class-properties": "^7.13.0",
39
- "@babel/plugin-transform-runtime": "^7.16.10",
40
- "@babel/preset-env": "^7.13.9",
41
- "@babel/preset-react": "^7.12.10",
42
- "babel-loader": "^8.2.2",
43
41
  "clean-css-cli": "^5.6.3",
44
- "css-loader": "^5.0.1",
42
+ "cors": "^2.8.5",
43
+ "esbuild": "^0.19.11",
44
+ "express": "^4.19.2",
45
45
  "extract-loader": "^5.1.0",
46
- "react": "^17.0.1",
47
- "react-bootstrap": "^2.9.1",
48
- "react-dom": "^17.0.1",
49
- "react-web-component-style-loader": "^0.1.4-alpha",
50
- "webpack": "^5.65.0",
51
- "webpack-cli": "^4.9.1",
52
- "webpack-dev-server": "^4.7.3",
53
- "webpack-node-externals": "^3.0.0",
46
+ "react": "^17.0.2",
47
+ "react-dom": "^17.0.2",
54
48
  "websocket-stream": "^5.5.2"
55
49
  }
56
50
  }
package/dist/index.js DELETED
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _shared = require("./shared.jsx");
8
-
9
- Object.keys(_shared).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _shared[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function () {
15
- return _shared[key];
16
- }
17
- });
18
- });
19
-
20
- var _hooks = require("./hooks.jsx");
21
-
22
- Object.keys(_hooks).forEach(function (key) {
23
- if (key === "default" || key === "__esModule") return;
24
- if (key in exports && exports[key] === _hooks[key]) return;
25
- Object.defineProperty(exports, key, {
26
- enumerable: true,
27
- get: function () {
28
- return _hooks[key];
29
- }
30
- });
31
- });