-
Notifications
You must be signed in to change notification settings - Fork 87
/
ros2d.min.js
8 lines (8 loc) · 31.9 KB
/
ros2d.min.js
1
2
3
4
5
6
7
8
var ROS2D=function(e,t,i){"use strict";function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var n=s(t),r=s(i);n.Stage.prototype.globalToRos=function(e,t){var i=(e-this.x)/this.scaleX,s=(this.y-t)/this.scaleY;return new r.Vector3({x:i,y:s})},n.Stage.prototype.rosToGlobal=function(e){return{x:e.x*this.scaleX+this.x,y:e.y*this.scaleY+this.y}},n.Stage.prototype.rosQuaternionToGlobalTheta=function(e){var t=e.w,i=e.x,s=e.y,n=e.z;return 180*-Math.atan2(2*(t*n+i*s),1-2*(s*s+n*n))/Math.PI};class o extends n.Bitmap{constructor(e){var t=(e=e||{}).message;super(e.image),this.pose=new r.Pose({position:t.origin.position,orientation:t.origin.orientation}),this.width=t.width,this.height=t.height,this.y=-this.height*t.resolution,this.scaleX=t.resolution,this.scaleY=t.resolution,this.width*=this.scaleX,this.height*=this.scaleY,this.x+=this.pose.position.x,this.y-=this.pose.position.y}}function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h,l={exports:{}};
/*!
* EventEmitter2
* https://github.com/hij1nx/EventEmitter2
*
* Copyright (c) 2013 hij1nx
* Licensed under the MIT license.
*/var c,p=(h||(h=1,c=l,function(e){var t=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},s="object"==typeof process&&"function"==typeof process.nextTick,n="function"==typeof Symbol,r="object"==typeof Reflect,o="function"==typeof setImmediate?setImmediate:setTimeout,a=n?r&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function h(){this._events={},this._conf&&l.call(this,this._conf)}function l(t){t&&(this._conf=t,t.delimiter&&(this.delimiter=t.delimiter),t.maxListeners!==e&&(this._maxListeners=t.maxListeners),t.wildcard&&(this.wildcard=t.wildcard),t.newListener&&(this._newListener=t.newListener),t.removeListener&&(this._removeListener=t.removeListener),t.verboseMemoryLeak&&(this.verboseMemoryLeak=t.verboseMemoryLeak),t.ignoreErrors&&(this.ignoreErrors=t.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function p(e,t){var i="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(i+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var s=new Error(i);s.name="MaxListenersExceededWarning",s.emitter=this,s.count=e,process.emitWarning(s)}else console.error(i),console.trace&&console.trace()}var u=function(e,t,i){var s=arguments.length;switch(s){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,i];default:for(var n=new Array(s);s--;)n[s]=arguments[s];return n}};function f(t,i){for(var s={},n=t.length,r=i?value.length:0,o=0;o<n;o++)s[t[o]]=o<r?i[o]:e;return s}function d(e,t,i){var s,n;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(i.on||i.off)&&(s=i.on,n=i.off),t.addEventListener?(s=t.addEventListener,n=t.removeEventListener):t.addListener?(s=t.addListener,n=t.removeListener):t.on&&(s=t.on,n=t.off),!s&&!n)throw Error("target does not implement any known event API");if("function"!=typeof s)throw TypeError("on method must be a function");if("function"!=typeof n)throw TypeError("off method must be a function");this._on=s,this._off=n;var r=e._observers;r?r.push(this):e._observers=[this]}function v(i,s,n,r){var o=Object.assign({},s);if(!i)return o;if("object"!=typeof i)throw TypeError("options must be an object");var a,h,l,c=Object.keys(i),p=c.length;function u(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<p;f++){if(a=c[f],!r&&!t.call(s,a))throw Error('Unknown "'+a+'" option');(h=i[a])!==e&&(l=n[a],o[a]=l?l(h,u):h)}return o}function g(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function y(e){var t="value must be type of "+e.join("|"),i=e.length,s=e[0],n=e[1];return 1===i?function(e,i){if(typeof e===s)return e;i(t)}:2===i?function(e,i){var r=typeof e;if(r===s||r===n)return e;i(t)}:function(s,n){for(var r=typeof s,o=i;o-- >0;)if(r===e[o])return s;n(t)}}Object.assign(d.prototype,{subscribe:function(e,t,i){var s=this,n=this._target,r=this._emitter,o=this._listeners,a=function(){var s=u.apply(null,arguments),o={data:s,name:t,original:e};if(i){var a=i.call(n,o);!1!==a&&r.emit.apply(r,[o.name].concat(s))}else r.emit.apply(r,[t].concat(s))};if(o[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,r._newListener&&r._removeListener&&!s._onNewListener?(this._onNewListener=function(i){i===t&&null===o[e]&&(o[e]=a,s._on.call(n,e,a))},r.on("newListener",this._onNewListener),this._onRemoveListener=function(i){i===t&&!r.hasListeners(i)&&o[e]&&(o[e]=null,s._off.call(n,e,a))},o[e]=null,r.on("removeListener",this._onRemoveListener)):(o[e]=a,s._on.call(n,e,a))},unsubscribe:function(e){var t,i,s,n=this,r=this._listeners,o=this._emitter,h=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function c(){n._onNewListener&&(o.off("newListener",n._onNewListener),o.off("removeListener",n._onRemoveListener),n._onNewListener=null,n._onRemoveListener=null);var e=b.call(o,n);o._observers.splice(e,1)}if(e){if(!(t=r[e]))return;h.call(l,e,t),delete r[e],--this._listenersCount||c()}else{for(s=(i=a(r)).length;s-- >0;)e=i[s],h.call(l,e,r[e]);this._listeners={},this._listenersCount=0,c()}}});var m=y(["function"]),_=y(["object","function"]);function w(e,t,i){var s,n,r,o=0,a=new e((function(h,l,c){function p(){n&&(n=null),o&&(clearTimeout(o),o=0)}i=v(i,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),s=!i.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof c;var u=function(e){p(),h(e)},f=function(e){p(),l(e)};s?t(u,f,c):(n=[function(e){f(e||Error("canceled"))}],t(u,f,(function(e){if(r)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");n.push(e)})),r=!0),i.timeout>0&&(o=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",o=0,a.cancel(e),l(e)}),i.timeout))}));return s||(a.cancel=function(e){if(n){for(var t=n.length,i=1;i<t;i++)n[i](e);n[0](e),n=null}}),a}function b(e){var t=this._observers;if(!t)return-1;for(var i=t.length,s=0;s<i;s++)if(t[s]._target===e)return s;return-1}function C(e,t,i,s,n){if(!i)return null;if(0===s){var r=typeof t;if("string"===r){var o,h,l=0,c=0,p=this.delimiter,u=p.length;if(-1!==(h=t.indexOf(p))){o=new Array(5);do{o[l++]=t.slice(c,h),c=h+u}while(-1!==(h=t.indexOf(p,c)));o[l++]=t.slice(c),t=o,n=l}else t=[t],n=1}else"object"===r?n=t.length:(t=[t],n=1)}var f,d,v,g,y,m,_,w=null,b=t[s],S=t[s+1];if(s===n)i._listeners&&("function"==typeof i._listeners?(e&&e.push(i._listeners),w=[i]):(e&&e.push.apply(e,i._listeners),w=[i]));else{if("*"===b){for(h=(m=a(i)).length;h-- >0;)"_listeners"!==(f=m[h])&&(_=C(e,t,i[f],s+1,n))&&(w?w.push.apply(w,_):w=_);return w}if("**"===b){for((y=s+1===n||s+2===n&&"*"===S)&&i._listeners&&(w=C(e,t,i,n,n)),h=(m=a(i)).length;h-- >0;)"_listeners"!==(f=m[h])&&("*"===f||"**"===f?(i[f]._listeners&&!y&&(_=C(e,t,i[f],n,n))&&(w?w.push.apply(w,_):w=_),_=C(e,t,i[f],s,n)):_=C(e,t,i[f],f===S?s+2:s,n),_&&(w?w.push.apply(w,_):w=_));return w}i[b]&&(w=C(e,t,i[b],s+1,n))}if((d=i["*"])&&C(e,t,d,s+1,n),v=i["**"])if(s<n)for(v._listeners&&C(e,t,v,n,n),h=(m=a(v)).length;h-- >0;)"_listeners"!==(f=m[h])&&(f===S?C(e,t,v[f],s+2,n):f===b?C(e,t,v[f],s+1,n):((g={})[f]=v[f],C(e,t,{"**":g},s+1,n)));else v._listeners?C(e,t,v,n,n):v["*"]&&v["*"]._listeners&&C(e,t,v["*"],n,n);return w}function S(e,t,i){var s,n,r=0,o=0,a=this.delimiter,h=a.length;if("string"==typeof e)if(-1!==(s=e.indexOf(a))){n=new Array(5);do{n[r++]=e.slice(o,s),o=s+h}while(-1!==(s=e.indexOf(a,o)));n[r++]=e.slice(o)}else n=[e],r=1;else n=e,r=e.length;if(r>1)for(s=0;s+1<r;s++)if("**"===n[s]&&"**"===n[s+1])return;var l,c=this.listenerTree;for(s=0;s<r;s++)if(c=c[l=n[s]]||(c[l]={}),s===r-1)return c._listeners?("function"==typeof c._listeners&&(c._listeners=[c._listeners]),i?c._listeners.unshift(t):c._listeners.push(t),!c._listeners.warned&&this._maxListeners>0&&c._listeners.length>this._maxListeners&&(c._listeners.warned=!0,p.call(this,c._listeners.length,l))):c._listeners=t,!0;return!0}function x(e,t,i,s){for(var n,r,o,h,l=a(e),c=l.length,p=e._listeners;c-- >0;)n=e[r=l[c]],o="_listeners"===r?i:i?i.concat(r):[r],h=s||"symbol"==typeof r,p&&t.push(h?o:o.join(this.delimiter)),"object"==typeof n&&x.call(this,n,t,o,h);return t}function L(e){for(var t,i,s,n=a(e),r=n.length;r-- >0;)(t=e[i=n[r]])&&(s=!0,"_listeners"===i||L(t)||delete e[i]);return s}function k(e,t,i){this.emitter=e,this.event=t,this.listener=i}function T(t,i,n){if(!0===n)a=!0;else if(!1===n)r=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var r=n.async,a=n.promisify,h=n.nextTick,l=n.objectify}if(r||h||a){var c=i,p=i._origin||i;if(h&&!s)throw Error("process.nextTick is not supported");a===e&&(a="AsyncFunction"===i.constructor.name),i=function(){var e=arguments,t=this,i=this.event;return a?h?Promise.resolve():new Promise((function(e){o(e)})).then((function(){return t.event=i,c.apply(t,e)})):(h?process.nextTick:o)((function(){t.event=i,c.apply(t,e)}))},i._async=!0,i._origin=p}return[i,l?new k(this,t,i):this]}function j(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,l.call(this,e)}k.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},j.EventEmitter2=j,j.prototype.listenTo=function(t,s,n){if("object"!=typeof t)throw TypeError("target musts be an object");var r=this;function o(e){if("object"!=typeof e)throw TypeError("events must be an object");var i,s=n.reducers,o=b.call(r,t);i=-1===o?new d(r,t,n):r._observers[o];for(var h,l=a(e),c=l.length,p="function"==typeof s,u=0;u<c;u++)h=l[u],i.subscribe(h,e[h]||h,p?s:s&&s[h])}return n=v(n,{on:e,off:e,reducers:e},{on:m,off:m,reducers:_}),i(s)?o(f(s)):o("string"==typeof s?f(s.split(/\s+/)):s),this},j.prototype.stopListeningTo=function(e,t){var i=this._observers;if(!i)return!1;var s,n=i.length,r=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;n-- >0;)s=i[n],e&&s._target!==e||(s.unsubscribe(t),r=!0);return r},j.prototype.delimiter=".",j.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},j.prototype.getMaxListeners=function(){return this._maxListeners},j.prototype.event="",j.prototype.once=function(e,t,i){return this._once(e,t,!1,i)},j.prototype.prependOnceListener=function(e,t,i){return this._once(e,t,!0,i)},j.prototype._once=function(e,t,i,s){return this._many(e,1,t,i,s)},j.prototype.many=function(e,t,i,s){return this._many(e,t,i,!1,s)},j.prototype.prependMany=function(e,t,i,s){return this._many(e,t,i,!0,s)},j.prototype._many=function(e,t,i,s,n){var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");function o(){return 0==--t&&r.off(e,o),i.apply(this,arguments)}return o._origin=i,this._on(e,o,s,n)},j.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||h.call(this);var e,t,i,s,r,o,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(i=a.length,n)for(s=0;s<i;s++)if("symbol"==typeof a[s]){o=!0;break}o||(a=a.join(this.delimiter))}var c,p=arguments.length;if(this._all&&this._all.length)for(s=0,i=(c=this._all.slice()).length;s<i;s++)switch(this.event=a,p){case 1:c[s].call(this,a);break;case 2:c[s].call(this,a,arguments[1]);break;case 3:c[s].call(this,a,arguments[1],arguments[2]);break;default:c[s].apply(this,arguments)}if(l)c=[],C.call(this,c,e,this.listenerTree,0,i);else{if("function"==typeof(c=this._events[a])){switch(this.event=a,p){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(p-1),r=1;r<p;r++)t[r-1]=arguments[r];c.apply(this,t)}return!0}c&&(c=c.slice())}if(c&&c.length){if(p>3)for(t=new Array(p-1),r=1;r<p;r++)t[r-1]=arguments[r];for(s=0,i=c.length;s<i;s++)switch(this.event=a,p){case 1:c[s].call(this);break;case 2:c[s].call(this,arguments[1]);break;case 3:c[s].call(this,arguments[1],arguments[2]);break;default:c[s].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===a)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},j.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||h.call(this);var e,t,i,s,r,o,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(s=a.length,n)for(r=0;r<s;r++)if("symbol"==typeof a[r]){t=!0;break}t||(a=a.join(this.delimiter))}var c,p=[],u=arguments.length;if(this._all)for(r=0,s=this._all.length;r<s;r++)switch(this.event=a,u){case 1:p.push(this._all[r].call(this,a));break;case 2:p.push(this._all[r].call(this,a,arguments[1]));break;case 3:p.push(this._all[r].call(this,a,arguments[1],arguments[2]));break;default:p.push(this._all[r].apply(this,arguments))}if(l?(c=[],C.call(this,c,e,this.listenerTree,0)):c=this._events[a],"function"==typeof c)switch(this.event=a,u){case 1:p.push(c.call(this));break;case 2:p.push(c.call(this,arguments[1]));break;case 3:p.push(c.call(this,arguments[1],arguments[2]));break;default:for(i=new Array(u-1),o=1;o<u;o++)i[o-1]=arguments[o];p.push(c.apply(this,i))}else if(c&&c.length){if(c=c.slice(),u>3)for(i=new Array(u-1),o=1;o<u;o++)i[o-1]=arguments[o];for(r=0,s=c.length;r<s;r++)switch(this.event=a,u){case 1:p.push(c[r].call(this));break;case 2:p.push(c[r].call(this,arguments[1]));break;case 3:p.push(c[r].call(this,arguments[1],arguments[2]));break;default:p.push(c[r].apply(this,i))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(p)},j.prototype.on=function(e,t,i){return this._on(e,t,!1,i)},j.prototype.prependListener=function(e,t,i){return this._on(e,t,!0,i)},j.prototype.onAny=function(e){return this._onAny(e,!1)},j.prototype.prependAny=function(e){return this._onAny(e,!0)},j.prototype.addListener=j.prototype.on,j.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},j.prototype._on=function(t,i,s,n){if("function"==typeof t)return this._onAny(t,i),this;if("function"!=typeof i)throw new Error("on only accepts instances of Function");this._events||h.call(this);var r,o=this;return n!==e&&(i=(r=T.call(this,t,i,n))[0],o=r[1]),this._newListener&&this.emit("newListener",t,i),this.wildcard?(S.call(this,t,i,s),o):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),s?this._events[t].unshift(i):this._events[t].push(i),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,p.call(this,this._events[t].length,t))):this._events[t]=i,o)},j.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var s,n=[];if(this.wildcard){var r="string"==typeof e?e.split(this.delimiter):e.slice();if(!(n=C.call(this,null,r,this.listenerTree,0)))return this}else{if(!this._events[e])return this;s=this._events[e],n.push({_listeners:s})}for(var o=0;o<n.length;o++){var a=n[o];if(s=a._listeners,i(s)){for(var h=-1,l=0,c=s.length;l<c;l++)if(s[l]===t||s[l].listener&&s[l].listener===t||s[l]._origin&&s[l]._origin===t){h=l;break}if(h<0)continue;return this.wildcard?a._listeners.splice(h,1):this._events[e].splice(h,1),0===s.length&&(this.wildcard?delete a._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(s===t||s.listener&&s.listener===t||s._origin&&s._origin===t)&&(this.wildcard?delete a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&L(this.listenerTree),this},j.prototype.offAny=function(e){var t,i=0,s=0;if(e&&this._all&&this._all.length>0){for(i=0,s=(t=this._all).length;i<s;i++)if(e===t[i])return t.splice(i,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(i=0,s=t.length;i<s;i++)this.emit("removeListenerAny",t[i]);this._all=[]}return this},j.prototype.removeListener=j.prototype.off,j.prototype.removeAllListeners=function(t){if(t===e)return!this._events||h.call(this),this;if(this.wildcard){var i,s=C.call(this,null,t,this.listenerTree,0);if(!s)return this;for(i=0;i<s.length;i++)s[i]._listeners=null;this.listenerTree&&L(this.listenerTree)}else this._events&&(this._events[t]=null);return this},j.prototype.listeners=function(t){var i,s,n,r,o,h=this._events;if(t===e){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!h)return[];for(r=(i=a(h)).length,n=[];r-- >0;)"function"==typeof(s=h[i[r]])?n.push(s):n.push.apply(n,s);return n}if(this.wildcard){if(!(o=this.listenerTree))return[];var l=[],c="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,l,c,o,0),l}return h&&(s=h[t])?"function"==typeof s?[s]:s:[]},j.prototype.eventNames=function(e){var t=this._events;return this.wildcard?x.call(this,this.listenerTree,[],null,e):t?a(t):[]},j.prototype.listenerCount=function(e){return this.listeners(e).length},j.prototype.hasListeners=function(t){if(this.wildcard){var i=[],s="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,i,s,this.listenerTree,0),i.length>0}var n=this._events,r=this._all;return!!(r&&r.length||n&&(t===e?a(n).length:n[t]))},j.prototype.listenersAny=function(){return this._all?this._all:[]},j.prototype.waitFor=function(t,i){var s=this,n=typeof i;return"number"===n?i={timeout:i}:"function"===n&&(i={filter:i}),w((i=v(i,{timeout:0,filter:e,handleError:!1,Promise:Promise,overload:!1},{filter:m,Promise:g})).Promise,(function(e,n,r){function o(){var r=i.filter;if(!r||r.apply(s,arguments))if(s.off(t,o),i.handleError){var a=arguments[0];a?n(a):e(u.apply(null,arguments).slice(1))}else e(u.apply(null,arguments))}r((function(){s.off(t,o)})),s._on(t,o,!1)}),{timeout:i.timeout,overload:i.overload})};var O=j.prototype;Object.defineProperties(j,{defaultMaxListeners:{get:function(){return O._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");O._maxListeners=e},enumerable:!0},once:{value:function(e,t,i){return w((i=v(i,{Promise:Promise,timeout:0,overload:!1},{Promise:g})).Promise,(function(i,s,n){var r;if("function"==typeof e.addEventListener)return r=function(){i(u.apply(null,arguments))},n((function(){e.removeEventListener(t,r)})),void e.addEventListener(t,r,{once:!0});var o,a=function(){o&&e.removeListener("error",o),i(u.apply(null,arguments))};"error"!==t&&(o=function(i){e.removeListener(t,a),s(i)},e.once("error",o)),n((function(){o&&e.removeListener("error",o),e.removeListener(t,a)})),e.once(t,a)}),{timeout:i.timeout,overload:i.overload})},writable:!0,configurable:!0}}),Object.defineProperties(O,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),c.exports=j}()),l.exports),u=a(p);class f extends n.Bitmap{constructor(e){var t=(e=e||{}).message,i=document.createElement("canvas"),s=i.getContext("2d");i.width=t.info.width,i.height=t.info.height;for(var n=s.createImageData(i.width,i.height),o=0;o<i.height;o++)for(var a=0;a<i.width;a++){var h,l=a+(i.height-o-1)*i.width,c=t.data[l];h=100===c?0:0===c?255:127;var p=4*(a+o*i.width);n.data[p]=h,n.data[++p]=h,n.data[++p]=h,n.data[++p]=255}s.putImageData(n,0,0),super(i),this.width=i.width,this.height=i.height,this.pose=new r.Pose({position:t.info.origin.position,orientation:t.info.origin.orientation}),this.y=-this.height*t.info.resolution,this.scaleX=t.info.resolution,this.scaleY=t.info.resolution,this.width*=this.scaleX,this.height*=this.scaleY,this.x+=this.pose.position.x,this.y-=this.pose.position.y}}class d extends n.Shape{constructor(e){var t=(e=e||{}).size||10,i=e.cellSize||.1,s=e.lineWidth||.001,r=new n.Graphics;r.setStrokeStyle(5*s),r.beginStroke(n.Graphics.getRGB(0,0,0)),r.beginFill(n.Graphics.getRGB(255,0,0)),r.moveTo(-t*i,0),r.lineTo(t*i,0),r.moveTo(0,-t*i),r.lineTo(0,t*i),r.endFill(),r.endStroke(),r.setStrokeStyle(s),r.beginStroke(n.Graphics.getRGB(0,0,0)),r.beginFill(n.Graphics.getRGB(255,0,0));for(var o=-t;o<=t;o++)r.moveTo(-t*i,o*i),r.lineTo(t*i,o*i),r.moveTo(o*i,-t*i),r.lineTo(o*i,t*i);r.endFill(),r.endStroke(),super(r)}}class v extends n.Shape{constructor(e){var t=this,i=(e=e||{}).size||10,s=e.strokeSize||3,r=e.strokeColor||n.Graphics.getRGB(0,0,0),o=e.fillColor||n.Graphics.getRGB(255,0,0),a=e.pulse,h=new n.Graphics,l=i/3,c=2*l/3;if(h.setStrokeStyle(s),h.beginStroke(r),h.moveTo(0,0),h.lineTo(i-l,0),h.beginFill(o),h.moveTo(i,0),h.lineTo(i-l,c/2),h.lineTo(i-l,-c/2),h.closePath(),h.endFill(),h.endStroke(),super(h),a){var p=0,u=!0;n.Ticker.addEventListener("tick",(function(){u?(t.scaleX*=1.035,t.scaleY*=1.035,u=++p<10):(t.scaleX/=1.035,t.scaleY/=1.035,u=--p<0)}))}}}class g extends n.Shape{constructor(e){var t=this,i=(e=e||{}).size||10,s=e.strokeSize||3,r=e.strokeColor||n.Graphics.getRGB(0,0,0),o=e.fillColor||n.Graphics.getRGB(255,0,0),a=e.pulse,h=new n.Graphics;if(h.setStrokeStyle(s),h.moveTo(-i/2,-i/2),h.beginStroke(r),h.beginFill(o),h.lineTo(i,0),h.lineTo(-i/2,i/2),h.closePath(),h.endFill(),h.endStroke(),super(h),a){var l=0,c=!0;n.Ticker.addEventListener("tick",(function(){c?(t.scaleX*=1.035,t.scaleY*=1.035,c=++l<10):(t.scaleX/=1.035,t.scaleY/=1.035,c=--l<0)}))}}}class y extends n.Bitmap{constructor(e){var t=(e=e||{}).size||10,i=e.image,s=e.pulse,r=e.alpha||1,o={},a=new Image;super(a);a.onload=function(){var e=h(t);if(this.alpha=r,this.scaleX=e,this.scaleY=e,this.regY=this.image.height/2,this.regX=this.image.width/2,o.rotation=this.rotation,Object.defineProperty(this,"rotation",{get:function(){return o.rotation+90},set:function(e){o.rotation=e}}),s){var i=0,a=!0,l=1.02;n.Ticker.addEventListener("tick",(function(){a?(this.scaleX*=l,this.scaleY*=l,a=++i<10):(this.scaleX/=l,this.scaleY/=l,a=--i<0)}))}}.bind(this),a.src=i;var h=function(e){return e/a.width}}}class m extends n.Shape{constructor(e){var t=(e=e||{}).path;if(this.strokeSize=e.strokeSize||3,this.strokeColor=e.strokeColor||n.Graphics.getRGB(0,0,0),this.graphics=new n.Graphics,null!=t){this.graphics.setStrokeStyle(this.strokeSize),this.graphics.beginStroke(this.strokeColor),this.graphics.moveTo(t.poses[0].pose.position.x/this.scaleX,t.poses[0].pose.position.y/-this.scaleY);for(var i=1;i<t.poses.length;++i)this.graphics.lineTo(t.poses[i].pose.position.x/this.scaleX,t.poses[i].pose.position.y/-this.scaleY);this.graphics.endStroke()}super(this.graphics)}setPath(e){if(this.graphics.clear(),null!=e){this.graphics.setStrokeStyle(this.strokeSize),this.graphics.beginStroke(this.strokeColor),this.graphics.moveTo(e.poses[0].pose.position.x/this.scaleX,e.poses[0].pose.position.y/-this.scaleY);for(var t=1;t<e.poses.length;++t)this.graphics.lineTo(e.poses[t].pose.position.x/this.scaleX,e.poses[t].pose.position.y/-this.scaleY);this.graphics.endStroke()}}}class _ extends n.Container{constructor(e){super(),e=e||{},this.lineSize=e.lineSize||3,this.lineColor=e.lineColor||n.Graphics.getRGB(0,0,255,.66),this.pointSize=e.pointSize||10,this.pointColor=e.pointColor||n.Graphics.getRGB(255,0,0,.66),this.fillColor=e.pointColor||n.Graphics.getRGB(0,255,0,.33),this.lineCallBack=e.lineCallBack,this.pointCallBack=e.pointCallBack,this.pointContainer=new n.Container,this.lineContainer=new n.Container,this.fillShape=new n.Shape,this.addChild(this.fillShape),this.addChild(this.lineContainer),this.addChild(this.pointContainer)}createLineShape(e,t){var i=new n.Shape;this.editLineShape(i,e,t);var s=this;return i.addEventListener("mousedown",(function(e){null!==s.lineCallBack&&void 0!==s.lineCallBack&&s.lineCallBack("mousedown",e,s.lineContainer.getChildIndex(e.target))})),i}editLineShape(e,t,i){e.graphics.clear(),e.graphics.setStrokeStyle(this.lineSize),e.graphics.beginStroke(this.lineColor),e.graphics.moveTo(t.x,t.y),e.graphics.lineTo(i.x,i.y)}createPointShape(e){var t=new n.Shape;t.graphics.beginFill(this.pointColor),t.graphics.drawCircle(0,0,this.pointSize),t.x=e.x,t.y=-e.y;var i=this;return t.addEventListener("mousedown",(function(e){null!==i.pointCallBack&&void 0!==i.pointCallBack&&i.pointCallBack("mousedown",e,i.pointContainer.getChildIndex(e.target))})),t}addPoint(e){var t=this.createPointShape(e);this.pointContainer.addChild(t);var i=this.pointContainer.numChildren;if(i<2);else if(i<3){var s=this.createLineShape(this.pointContainer.getChildAt(i-2),t);this.lineContainer.addChild(s)}if(i>2&&this.editLineShape(this.lineContainer.getChildAt(i-2),this.pointContainer.getChildAt(i-2),t),i>1){var n=this.createLineShape(t,this.pointContainer.getChildAt(0));this.lineContainer.addChild(n)}this.drawFill()}remPoint(e){var t;t=e instanceof n.Shape?this.pointContainer.getChildIndex(e):e;var i=this.pointContainer.numChildren;i<2||(i<3?this.lineContainer.removeAllChildren():(this.editLineShape(this.lineContainer.getChildAt((t-1+i)%i),this.pointContainer.getChildAt((t-1+i)%i),this.pointContainer.getChildAt((t+1)%i)),this.lineContainer.removeChildAt(t))),this.pointContainer.removeChildAt(t),this.drawFill()}movePoint(e,t){var i,s;e instanceof n.Shape?(i=this.pointContainer.getChildIndex(e),s=e):(i=e,s=this.pointContainer.getChildAt(i)),s.x=t.x,s.y=-t.y;var r=this.pointContainer.numChildren;if(r>1){var o=this.lineContainer.getChildAt((i-1+r)%r);this.editLineShape(o,this.pointContainer.getChildAt((i-1+r)%r),s);var a=this.lineContainer.getChildAt(i);this.editLineShape(a,s,this.pointContainer.getChildAt((i+1)%r))}this.drawFill()}splitLine(e){var t,i;e instanceof n.Shape?(t=this.lineContainer.getChildIndex(e),i=e):(t=e,i=this.lineContainer.getChildAt(t));var s=this.pointContainer.numChildren,o=this.pointContainer.getChildAt(t).x,a=this.pointContainer.getChildAt(t).y,h=(o+this.pointContainer.getChildAt((t+1)%s).x)/2,l=(a+this.pointContainer.getChildAt((t+1)%s).y)/2,c=new r.Vector3({x:h,y:-l}),p=this.createPointShape(c);this.pointContainer.addChildAt(p,t+1),++s;var u=this.createLineShape(p,this.pointContainer.getChildAt((t+2)%s));this.lineContainer.addChildAt(u,t+1),this.editLineShape(i,this.pointContainer.getChildAt(t),p),this.drawFill()}drawFill(){var e=this.pointContainer.numChildren;if(e>2){var t=this.fillShape.graphics;t.clear(),t.setStrokeStyle(0),t.beginStroke(),t.beginFill(this.fillColor),t.moveTo(this.pointContainer.getChildAt(0).x,this.pointContainer.getChildAt(0).y);for(var i=1;i<e;++i)t.lineTo(this.pointContainer.getChildAt(i).x,this.pointContainer.getChildAt(i).y);t.closePath(),t.endFill(),t.endStroke()}else this.fillShape.graphics.clear()}}class w extends n.Shape{constructor(e){var t=(e=e||{}).pose;this.strokeSize=e.strokeSize||3,this.strokeColor=e.strokeColor||n.Graphics.getRGB(0,0,0),this.maxPoses=e.maxPoses||0===e.maxPoses?e.maxPoses:100,this.minDist=e.minDist||.05,this.minDist=this.minDist*this.minDist,this.poses=[],this.graphics=new n.Graphics,this.graphics.setStrokeStyle(this.strokeSize),this.graphics.beginStroke(this.strokeColor),null!=t&&this.poses.push(t),super(this.graphics)}addPose(e){var t=this.poses.length-1;if(t<0)this.poses.push(e),this.graphics.moveTo(e.position.x/this.scaleX,e.position.y/-this.scaleY);else{var i=this.poses[t].position.x,s=this.poses[t].position.y,n=e.position.x-i,r=e.position.y-s;n*n+r*r>this.minDist&&(this.graphics.lineTo(e.position.x/this.scaleX,e.position.y/-this.scaleY),this.poses.push(e))}this.maxPoses>0&&this.maxPoses<this.poses.length&&this.popFront()}popFront(){if(this.poses.length>0){this.poses.shift(),this.graphics.clear(),this.graphics.setStrokeStyle(this.strokeSize),this.graphics.beginStroke(this.strokeColor),this.graphics.lineTo(this.poses[0].position.x/this.scaleX,this.poses[0].position.y/-this.scaleY);for(var e=1;e<this.poses.length;++e)this.graphics.lineTo(this.poses[e].position.x/this.scaleX,this.poses[e].position.y/-this.scaleY)}}}return e.ArrowShape=v,e.Grid=d,e.ImageMap=o,e.ImageMapClient=class extends u{constructor(e){super();var t=(e=e||{}).ros,i=e.topic||"/map_metadata";this.image=e.image,this.rootObject=e.rootObject||new n.Container,this.currentImage=new n.Shape;var s=new r.Topic({ros:t,name:i,messageType:"nav_msgs/MapMetaData"});s.subscribe(function(e){s.unsubscribe(),this.currentImage=new o({message:e,image:this.image}),this.rootObject.addChild(this.currentImage),this.emit("change")}.bind(this))}},e.NavigationArrow=g,e.NavigationImage=y,e.OccupancyGrid=f,e.OccupancyGridClient=class extends u{constructor(e){super();var t=this,i=(e=e||{}).ros,s=e.topic||"/map";this.continuous=e.continuous,this.rootObject=e.rootObject||new n.Container,this.currentGrid=new n.Shape,this.rootObject.addChild(this.currentGrid),this.rootObject.addChild(new d({size:1}));var o=new r.Topic({ros:i,name:s,messageType:"nav_msgs/OccupancyGrid",compression:"png"});o.subscribe((function(e){var i=null;t.currentGrid&&(i=t.rootObject.getChildIndex(t.currentGrid),t.rootObject.removeChild(t.currentGrid)),t.currentGrid=new f({message:e}),null!==i?t.rootObject.addChildAt(t.currentGrid,i):t.rootObject.addChild(t.currentGrid),t.emit("change"),t.continuous||o.unsubscribe()}))}},e.OccupancyGridSrvClient=class extends u{constructor(e){super();var t=this,i=(e=e||{}).ros,s=e.service||"/static_map";this.rootObject=e.rootObject||new n.Container,this.currentGrid=null,new r.Service({ros:i,name:s,serviceType:"nav_msgs/GetMap",compression:"png"}).callService(new r.ServiceRequest,(function(e){t.currentGrid&&t.rootObject.removeChild(t.currentGrid),t.currentGrid=new f({message:e.map}),t.rootObject.addChild(t.currentGrid),t.emit("change",t.currentGrid)}))}},e.PanView=class{constructor(e){e=e||{},this.rootObject=e.rootObject,this.rootObject instanceof n.Stage?this.stage=this.rootObject:this.stage=this.rootObject.getStage(),this.startPos=new r.Vector3}startPan(e,t){this.startPos.x=e,this.startPos.y=t}pan(e,t){this.stage.x+=e-this.startPos.x,this.startPos.x=e,this.stage.y+=t-this.startPos.y,this.startPos.y=t}},e.PathShape=m,e.PolygonMarker=_,e.TraceShape=w,e.Viewer=class{constructor(e){var t=(e=e||{}).divID;this.width=e.width,this.height=e.height;var i=e.background||"#111111",s=document.createElement("canvas");s.width=this.width,s.height=this.height,s.style.background=i,document.getElementById(t).appendChild(s),this.scene=new n.Stage(s),this.scene.y=this.height,document.getElementById(t).appendChild(s),n.Ticker.framerate=30,n.Ticker.addEventListener("tick",this.scene)}addObject(e){this.scene.addChild(e)}scaleToDimensions(e,t){this.scene.x=void 0!==this.scene.x_prev_shift?this.scene.x_prev_shift:this.scene.x,this.scene.y=void 0!==this.scene.y_prev_shift?this.scene.y_prev_shift:this.scene.y,this.scene.scaleX=this.width/e,this.scene.scaleY=this.height/t}shift(e,t){this.scene.x_prev_shift=this.scene.x,this.scene.y_prev_shift=this.scene.y,this.scene.x-=e*this.scene.scaleX,this.scene.y+=t*this.scene.scaleY}},e.ZoomView=class{constructor(e){e=e||{},this.rootObject=e.rootObject,this.minScale=e.minScale||.001,this.rootObject instanceof n.Stage?this.stage=this.rootObject:this.stage=this.rootObject.getStage(),this.center=new r.Vector3,this.startShift=new r.Vector3,this.startScale=new r.Vector3}startZoom(e,t){this.center.x=e,this.center.y=t,this.startShift.x=this.stage.x,this.startShift.y=this.stage.y,this.startScale.x=this.stage.scaleX,this.startScale.y=this.stage.scaleY}zoom(e){this.startScale.x*e<this.minScale&&(e=this.minScale/this.startScale.x),this.startScale.y*e<this.minScale&&(e=this.minScale/this.startScale.y),this.stage.scaleX=this.startScale.x*e,this.stage.scaleY=this.startScale.y*e,this.stage.x=this.startShift.x-(this.center.x-this.startShift.x)*(this.stage.scaleX/this.startScale.x-1),this.stage.y=this.startShift.y-(this.center.y-this.startShift.y)*(this.stage.scaleY/this.startScale.y-1)}},Object.defineProperty(e,"__esModule",{value:!0}),e}({},createjs,ROSLIB);