2 lines
211 KiB
JavaScript
2 lines
211 KiB
JavaScript
module.exports=function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=15)}([function(t,e){t.exports=require("react")},function(t,e){t.exports=require("react-bootstrap")},function(t,e){t.exports=require("events")},function(t,e){t.exports=require("react-draggable")},function(t,e){t.exports=require("graph-diagram")},function(t,e){t.exports=require("path")},function(t,e){t.exports=require("jsonfile")},function(t,e){t.exports=require("react-password-mask")},function(t,e){t.exports=require("request")},function(t,e){t.exports=require("fs")},function(t,e){t.exports=require("jsonic")},function(t,e){t.exports=require("electron")},function(t,e){t.exports=require("react-list")},function(t,e){t.exports=require("osenv")},function(t,e){t.exports=require("ensureDir")},function(t,e,n){t.exports=n(16)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),o=n(17),a=n(1),s=n(3),r=n.n(s);var l=n(18),h=n(19),c=n(20),d=n(21).toString("base64"),u=l.format(".titlebar {\n\tpadding: 0 3px;\n\tbackground-color: #f6f6f6;\n}\n\n.titlebar.webkit-draggable {\n\t-webkit-app-region: drag;\n}\n\n.titlebar-stoplight {\n\tfloat: left;\n}\n\n.titlebar:after,\n.titlebar-stoplight:after {\n\tcontent: ' ';\n\tdisplay: table;\n\tclear: both;\n}\n\n.titlebar-stoplight:hover .titlebar-close {\n\tbackground-position: -26px 0;\n}\n\n.titlebar-stoplight:hover .titlebar-minimize {\n\tbackground-position: 0 0;\n}\n\n.titlebar-stoplight:hover .titlebar-fullscreen {\n\tbackground-position: -13px 0;\n}\n\n.titlebar.alt .titlebar-stoplight:hover .titlebar-close {\n\tbackground-position: -104px 0;\n}\n\n.titlebar.alt .titlebar-stoplight:hover .titlebar-minimize {\n\tbackground-position: -78px 0;\n}\n\n.titlebar.alt .titlebar-stoplight:hover .titlebar-fullscreen {\n\tbackground-position: -91px 0;\n}\n\n.titlebar-close,\n.titlebar-minimize,\n.titlebar-fullscreen {\n\tfloat: left;\n\tmargin: 6px 4px;\n\tbackground-repeat: no-repeat;\n\tbackground-image: url(%s);\n\tbackground-size: auto 12px;\n\twidth: 12px;\n\theight: 12px;\n\tborder-radius: 6px;\n}\n\n.titlebar.webkit-draggable .titlebar-close,\n.titlebar.webkit-draggable .titlebar-minimize,\n.titlebar.webkit-draggable .titlebar-fullscreen {\n\t-webkit-app-region: no-drag;\n}\n\n.titlebar-close {\n\tposition: relative;\n\tmargin-left: 6px;\n\tbackground-position: -65px 0;\n}\n\n.titlebar-fullscreen {\n\tposition: relative;\n\tbackground-position: -52px 0;\n}\n\n.titlebar-minimize {\n\tposition: relative;\n\tbackground-position: -39px 0;\n}\n\n.titlebar-close:active::after,\n.titlebar-minimize:active::after,\n.titlebar-fullscreen:active::after {\n\tdisplay: block;\n\tposition: absolute;\n\ttop: 0;\n\tbottom: 0;\n\tleft: 0;\n\tright: 0;\n\tcontent: \"\";\n\tbackground: rgba(0, 0, 0, .25);\n\tborder-radius: 100%;\n}\n",d),p=18;class m extends i.Component{constructor(t){super(t),this._keyDownHandler=this.handleKeyDown.bind(this),this._keyUpHandler=this.handleKeyUp.bind(this)}componentWillMount(){this.setState({altDown:!1,draggable:!0})}componentWillReceiveProps(t){if(t.draggable)try{this.setState({draggable:t.draggable},()=>{})}catch(t){console.log(t)}}componentDidMount(){document.body.addEventListener("keydown",this._keyDownHandler),document.body.addEventListener("keyup",this._keyUpHandler)}componentWillUnMount(){document.body.removeEventListener("keydown",this._keyDownHandler),document.body.removeEventListener("keyup",this._keyUpHandler)}handleKeyDown(t){t.keyCode===p&&this.setState({altDown:!0})}handleKeyUp(t){t.keyCode===p&&this.setState({altDown:!1})}handleMaximize(t){this.state.altDown?this.props.handleMaximize(t):this.props.handleFullScreen(t)}handleNop(t){t.preventDefault(),t.stopPropagation()}render(){var t=c("handle","titlebar",{"webkit-draggable":this.state.draggable,alt:this.state.altDown});return h("titlebar",u),i.createElement("div",{className:t,id:"titlebar",onClick:this.props.handleClick},i.createElement("div",{className:"titlebar-stoplight"},i.createElement("div",{onDoubleClick:this.handleNop,onClick:this.props.handleClose,className:"titlebar-close"}),i.createElement("div",{onDoubleClick:this.handleNop,onClick:this.props.handleMinimize,className:"titlebar-minimize"}),i.createElement("div",{onDoubleClick:this.handleNop,onClick:this.handleMaximize.bind(this),className:"titlebar-fullscreen"})),this.props.children)}}var g=n(22),f=n.n(g);const v=n(7);class b extends i.Component{constructor(t){super(t)}componentWillMount(){this.setState({port:this.props.appInfo.port,clientId:this.props.appInfo.clientId,clientSecret:this.props.appInfo.clientSecret,nluDefault:this.props.appInfo.nluDefault,nluLUIS_endpoint:this.props.appInfo.nluLUIS_endpoint,nluLUIS_appId:this.props.appInfo.nluLUIS_appId,nluLUIS_subscriptionKey:this.props.appInfo.nluLUIS_subscriptionKey,nluDialogflow_clientToken:this.props.appInfo.nluDialogflow_clientToken,nluDialogflow_projectId:this.props.appInfo.nluDialogflow_projectId,nluDialogflow_privateKey:this.props.appInfo.nluDialogflow_privateKey,nluDialogflow_clientEmail:this.props.appInfo.nluDialogflow_clientEmail,neo4j_url:this.props.appInfo.neo4j_url,neo4j_user:this.props.appInfo.neo4j_user,neo4j_password:this.props.appInfo.neo4j_password})}componentDidMount(){this.props.model.addPanelWithId(this.props.id)}handleInputChange(t){let e=t.nativeEvent;switch(console.log(`handleInputChange: ${e.target.name} ${e.target.value}`,this.state),e.target.name){case"port":this.setState(t=>(this.props.appInfo.port=e.target.value,{port:e.target.value}));break;case"clientId":this.setState(t=>(this.props.appInfo.clientId=e.target.value,{clientId:e.target.value}));break;case"clientSecret":this.setState(t=>(this.props.appInfo.clientSecret=e.target.value,{clientSecret:e.target.value}));break;case"nluLUIS_endpoint":this.setState(t=>(this.props.appInfo.nluLUIS_endpoint=e.target.value,{nluLUIS_endpoint:e.target.value}));break;case"nluLUIS_appId":this.setState(t=>(this.props.appInfo.nluLUIS_appId=e.target.value,{nluLUIS_appId:e.target.value}));break;case"nluLUIS_subscriptionKey":this.setState(t=>(this.props.appInfo.nluLUIS_subscriptionKey=e.target.value,{nluLUIS_subscriptionKey:e.target.value}));break;case"nluDialogflow_clientToken":this.setState(t=>(this.props.appInfo.nluDialogflow_clientToken=e.target.value,{nluDialogflow_clientToken:e.target.value}));break;case"nluDialogflow_projectId":this.setState(t=>(this.props.appInfo.nluDialogflow_projectId=e.target.value,{nluDialogflow_clientToken:e.target.value}));break;case"nluDialogflow_privateKey":this.setState(t=>(this.props.appInfo.nluDialogflow_privateKey=e.target.value,{nluDialogflow_clientToken:e.target.value}));break;case"nluDialogflow_clientEmail":this.setState(t=>(this.props.appInfo.nluDialogflow_clientEmail=e.target.value,{nluDialogflow_clientToken:e.target.value}));break;case"neo4j_url":this.setState(t=>(this.props.appInfo.neo4j_url=e.target.value,{neo4j_url:e.target.value}));break;case"neo4j_user":this.setState(t=>(this.props.appInfo.neo4j_user=e.target.value,{neo4j_user:e.target.value}));break;case"neo4j_password":this.setState(t=>(this.props.appInfo.neo4j_password=e.target.value,{neo4j_password:e.target.value}))}}handleNluDefaultChange(t){this.setState(e=>(this.props.appInfo.nluDefault=t.value,{nluDefault:t.value}))}handleClick(t){this.props.model.bringPanelToFront(this.props.id)}handleClose(t){this.props.onClosePanel(this.props.id)}handleMinimize(t){console.log("minimize")}handleMaximize(t){console.log("maximize")}handleFullScreen(t){console.log("fullscreen")}render(){return i.createElement(r.a,{handle:".handle"},i.createElement("div",{className:"commander-panel well",id:"appInfoPanel",ref:"appInfoPanel"},i.createElement(m,{draggable:!0,handleClick:this.handleClick.bind(this),handleClose:this.handleClose.bind(this),handleMinimize:this.handleMinimize.bind(this),handleMaximize:this.handleMaximize.bind(this),handleFullScreen:this.handleFullScreen.bind(this)}),i.createElement("h4",{className:"pull-left handle",style:{marginBottom:20}},"RoboCommander Info"),i.createElement("div",{className:"clearfix"}),i.createElement(a.Table,{striped:!0,bordered:!0,condensed:!0,hover:!0,style:{width:900}},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,"port:"),i.createElement("td",null,i.createElement("input",{name:"port",value:this.state.port,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"clientId:"),i.createElement("td",null,i.createElement(v,{id:"password",name:"clientId",value:this.state.clientId,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"clientSecret:"),i.createElement("td",null,i.createElement(v,{id:"password",name:"clientSecret",value:this.state.clientSecret,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"nluDefault:"),i.createElement("td",null,i.createElement(f.a,{name:"nluDefault",value:this.state.nluDefault,options:[{value:"none",label:"none"},{value:"luis",label:"LUIS"},{value:"dialogflow",label:"Dialogflow"}],onChange:this.handleNluDefaultChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"nluLUIS_endpoint:"),i.createElement("td",null,i.createElement("input",{name:"nluLUIS_endpoint",value:this.state.nluLUIS_endpoint,onChange:this.handleInputChange.bind(this),style:{width:675}}))),i.createElement("tr",null,i.createElement("td",null,"nluLUIS_appId:"),i.createElement("td",null,i.createElement(v,{id:"password",name:"nluLUIS_appId",value:this.state.nluLUIS_appId,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"nluLUIS_subscriptionKey:"),i.createElement("td",null,i.createElement(v,{id:"password",name:"nluLUIS_subscriptionKey",value:this.state.nluLUIS_subscriptionKey,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"nluDialogflow_clientToken:"),i.createElement("td",null,i.createElement(v,{id:"password",name:"nluDialogflow_clientToken",value:this.state.nluDialogflow_clientToken,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"nluDialogflow_projectId:"),i.createElement("td",null,i.createElement(v,{id:"password",name:"nluDialogflow_projectId",value:this.state.nluDialogflow_projectId,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"nluDialogflow_privateKey:"),i.createElement("td",null,i.createElement(v,{id:"password",name:"nluDialogflow_privateKey",value:this.state.nluDialogflow_privateKey,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"nluDialogflow_clientEmail:"),i.createElement("td",null,i.createElement(v,{id:"password",name:"nluDialogflow_clientEmail",value:this.state.nluDialogflow_clientEmail,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"neo4j_url:"),i.createElement("td",null,i.createElement("input",{name:"neo4j_url",value:this.state.neo4j_url,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"neo4j_user:"),i.createElement("td",null,i.createElement("input",{name:"neo4j_user",value:this.state.neo4j_user,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"neo4j_password:"),i.createElement("td",null,i.createElement(v,{id:"password",name:"neo4j_password",value:this.state.neo4j_password,onChange:this.handleInputChange.bind(this),style:{width:300}})))))))}}var y=n(2);class w{constructor(t,e,n){this.name="",this.type="",this.initWithData({name:t||"",type:e||"",data:n})}initWithData(t){this.name=t.name,this.type=t.type,this.data=t.data}get json(){return{name:this.name,type:this.type,data:this.data}}}class S{constructor(){}}const k=n(8),_=n(23);class M extends S{constructor(){super(),this.endpoint="",this.luisAppId="",this.subscriptionKey="",this._config={}}set config(t){t&&t.nluLUIS_endpoint&&t.nluLUIS_appId&&t.nluLUIS_subscriptionKey?(this._config=t,this.endpoint=this._config.nluLUIS_endpoint,this.luisAppId=this._config.nluLUIS_appId,this.subscriptionKey=this._config.nluLUIS_subscriptionKey):console.log("LUISController: set config: error: incomplete config:",t)}call(t){let e=this.endpoint,n=this.luisAppId,i={"subscription-key":this.subscriptionKey,timezoneOffset:"0",verbose:!0,q:t},o=e+n+"?"+_.stringify(i);return new Promise((t,e)=>{k(o,(n,i,o)=>{if(n)console.log("LUISController: call: error:",i,n),e(n);else{console.log("LUISController: call:",i,n);let e=JSON.parse(o);t(e)}})})}getEntitiesWithResponse(t){let e={user:"Someone",userOriginal:"Someone",thing:"that",thingOriginal:"that"};return t.entities.forEach(t=>{e[`${t.type}Original`]=t.entity,t.resolution&&t.resolution.values&&(e[`${t.type}`]=t.resolution.values[0])}),e}getIntentAndEntities(t,e,n,i){return new Promise((e,n)=>{this.call(t).then(t=>{let n={intent:"",entities:void 0};t&&t.topScoringIntent&&(n={intent:t.topScoringIntent.intent,entities:this.getEntitiesWithResponse(t)}),e(n)}).catch(t=>{n(t)})})}}const C=n(8);class E extends S{constructor(){super(),this.apiAuthorization="",this._config={}}set config(t){t&&t.nluDialogflow_clientToken?(this._config=t,this.apiAuthorization=`Bearer ${this._config.nluDialogflow_clientToken}`):console.log("DialogflowControllerV1: set config: error: incomplete config:",t)}call(t,e,n,i){let o={query:t,lang:"en",sessionId:i,location:{latitude:Number("42.361145"),longitude:Number("-71.057083")},timezone:"America/New_York"};return n&&(o.contexts=[n]),new Promise((t,e)=>{C.post({headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`${this.apiAuthorization}`},url:"https://api.api.ai/v1/query?v=20150910",body:JSON.stringify(o)},(n,i,o)=>{if(n)e(n);else{let e=JSON.parse(o);t(e)}})})}getEntitiesWithResponse(t){let e,n={user:"Someone",userOriginal:"Someone",thing:"that",thingOriginal:"that"},i=t.result;return i&&i.contexts&&i.contexts[0]?(e=i.contexts[0].parameters)&&(n.user=e.user||n.user,n.userOriginal=e["user.original"]||n.userOriginal,n.thing=e.thing||n.thing,n.thingOriginal=e["thing.original"]||n.thingOriginal):i&&i.parameters&&(n.thing=i.parameters.thing||n.thing,n.thingOriginal=i.parameters.thing||n.thingOriginal),n}getIntentAndEntities(t,e,n,i){return new Promise((o,a)=>{this.call(t,e,n,i).then(t=>{let e={intent:t.result.metadata.intentName,entities:this.getEntitiesWithResponse(t)};o(e)}).catch(t=>{a(t)})})}}class x{constructor(t){this.neo4j=t,this.nodes=new Map,this.relationships=new Map}isLink(t){return t.start&&t.end}isNode(t){return!this.isLink(t)}parse(t){let e;for(this.nodes=new Map,this.relationships=new Map,e=0;e<t.records.length;e++)this.parseFields(t.records[e]._fields);return{nodes:Array.from(this.nodes.values()),links:Array.from(this.relationships.values())}}makeNode(t){let e=this.getId(t),n=this.convertNumberProps(t.properties);return this.nodes.get(e)||this.nodes.set(e,{id:`${e}`,labels:t.labels,properties:n,group:1}),e}makeLink(t,e,n){let i=this.getId(t),o=this.convertNumberProps(t.properties);this.relationships.get(i)||this.relationships.set(i,{id:`${i}`,type:t.type,startNode:`${e}`,endNode:`${n}`,properties:o,source:`${e}`,target:`${n}`,value:1,linknum:1})}convertNumberProps(t){for(let e in t){let n=t[e];this.neo4j.isInt(n)&&(t[e]={raw:n,converted:this.convertInt(n)})}return t}convertInt(t){return this.neo4j.integer.inSafeRange(t)?this.neo4j.integer.toNumber(t):t}getId(t){return this.convertInt(t.identity)}parseFields(t){let e={};for(let n=0;n<t.length;n++){let i=t[n];e[(this.isNode(i)?"node":"link")+i.identity.toString()]=this.isNode(i)?this.makeNode(i):i}for(let t in e){let n=e[t];if(this.isLink(n)){let t=this.convertInt(n.start),e=this.convertInt(n.end);this.makeLink(n,t,e)}}}}class I{static data(t,e){let n={};return n=new x(e).parse(t)}}const N=n(24).v1;class T{constructor(t){try{this.driver=N.driver(t.url,N.auth.basic(t.user,t.password))}catch(t){console.log("Neo4jController: constructor: ",t),this.driver=void 0}}call(t,e){return new Promise((n,i)=>{let o=this.driver.session();o.run(t,e).then(function(t){o.close(),n(t)}).catch(function(t){i(t)})})}getCypherAsD3(t,e){return new Promise((n,i)=>{this.call(t,e).then(t=>{n(I.data(t,N))}).catch(t=>{i(t)})})}getNodesAndRelationships(t=25){return new Promise((e,n)=>{let i=`\n MATCH (n)-[r]-(p), (q) return n,r,p, q limit ${t}\n `;this.call(i).then(t=>{e(I.data(t,N))}).catch(t=>{n(t)})})}getNodesWithPropertyAndValue(t,e){return new Promise((n,i)=>{let o=`\n MATCH (n {${t}: "${e}"})-[r]-(p)\n return n,r,p\n `;this.call(o).then(t=>{n(I.data(t,N))}).catch(t=>{i(t)})})}test(){this.call("MATCH (n) return n LIMIT 10").then(t=>{console.log(t)}).catch(t=>{console.log(t)})}}class D{constructor(t){this.nodeMap=new Map,this.linkMap=new Map,this.events=[],t.nodes.forEach(t=>{this.nodeMap.set(t.id,t)}),t.links.forEach(t=>{this.linkMap.set(t.id,t);let e=this.nodeMap.get(t.startNode),n=this.nodeMap.get(t.endNode),i={robot:e.properties.name,time:t.properties.time,action:t.type,intent:"",loopMember:t.properties.user,summary:""};switch("Intent"==n.labels[0]&&(i.intent=n.properties.name),i.intent){case"launchJoke":i.summary=`I told a joke to ${i.loopMember}`;break;case"launchClock":i.summary=`I told ${i.loopMember} the time`}this.events.push(i)})}}class A{constructor(){}static get Instance(){return this._instance||(this._instance=new this)}connect(t,e=!1){console.log("PersistenceManager: connect: ",t),this.appInfo=t,this.appInfo&&this.appInfo.neo4j_url&&(!this.neo4jController||e)&&(this.graphConnection={type:"neo4j",url:this.appInfo.neo4j_url,user:this.appInfo.neo4j_user,password:this.appInfo.neo4j_password},console.log("PersistenceManager: connect: instantiating Neo4jController:",this.graphConnection),this.neo4jController=new T(this.graphConnection))}persistLaunchIntent(t,e,n,i){let o=`MERGE (i:Intent {name: "${n}"})\nWITH i MERGE (n:Robot {name: "${t}"})\nWITH i, n MERGE (n)-[r:LAUNCHED {robot: "${t}", user: "${e}", time: "${(new Date).toLocaleString()}", launchId: "${i}"}]->(i) return n, i, r\n`,a={};this.neo4jController&&this.neo4jController.call(o,a).then(t=>{console.log("PersistenceManager: persistLaunchIntent: ",t,o)}).catch(t=>{console.log("PersistenceManager: persistLaunchIntent: err: ",t,o)})}getActivity(t){return new Promise((e,n)=>{let i=`MATCH (n:Robot {name: "${t}"})-[r:LAUNCHED]->(i:Intent) return n,r,i`,o={};this.neo4jController&&this.neo4jController.getCypherAsD3(i,o).then(t=>{console.log("PersistenceManager: getActivity: ",t);let e=new D(t);console.log(e.events)}).catch(t=>{console.log("PersistenceManager: getActivity: err: ")})})}persistJoke(t,e,n){let i=`MERGE (j:Joke {id: "${e.id}", name: "${e.name}"})\nWITH j MERGE (n:Robot {name: "${t.name}"})\nWITH j, n MERGE (n)-[r:TOLD {robot: "${t.name}", launchId: "${n}"}]->(j) return n, j, r\n`,o={};this.neo4jController&&this.neo4jController.call(i,o).then(t=>{console.log("PersistenceManager: persistJoke: ",t,i)}).catch(t=>{console.log("PersistenceManager: persistJoke: err: ",t,i)})}persistUserLikesThing(t,e,n,i){let o=`MERGE (e:Entity {name: "${e}"})\nWITH e MERGE (user:User {name: "${i}"})\nWITH e, user MERGE (user)-[r:LIKES {robot: "${t.name}", launchId: "${n}"}]->(e) return user, e, r\n`,a={};this.neo4jController&&this.neo4jController.call(o,a).then(t=>{console.log("PersistenceManager: persistUserLikesThing: ",t,o)}).catch(t=>{console.log("PersistenceManager: persistUserLikesThing: err: ",t,o)})}}class R{constructor(t,e,n){this.launchIntent="",this.running=!1,this.robot=t,this.id=e,this.launchIntent=n}}class P extends R{constructor(t){super(t,"JokeSkill","launchJoke"),this.jokeMap=new Map,this.jokeIterator=this.jokeMap.values(),console.log(`JokeSkill: constructor: ${t.serialName}`),this.initJokes()}initJokes(){[{id:"001",name:"sleevies",prompt:"Where does the General keep his armies? <anim name='Thinking_01' /> In his sleevies!"},{id:"002",name:"chicken",prompt:"Why did the chicken cross the road? <anim name='Thinking_01' /> To get to the other side."},{id:"003",name:"elephant",prompt:"You know why you never see elephants hiding up in trees? <anim name='Thinking_01' /> Because they’re really good at it."},{id:"004",name:"paint",prompt:"What is red and smells like blue paint? <anim name='Thinking_01' /> Red paint."}].forEach(t=>{this.jokeMap.set(t.id,t)}),this.jokeIterator=this.jokeMap.values()}launch(t){if(this.robot){console.log(`JokeSkill: launch: ${this.robot.serialName}`);let e=this.jokeIterator.next().value;e||(this.jokeIterator=this.jokeMap.values(),e=this.jokeIterator.next().value);let n=e.prompt;if(this.robot.requester){this.robot.requester.expression.say(n).complete.then(()=>{if(this.running=!1,this.robot){let n="na";t&&t.launchId&&(n=t.launchId),A.Instance.persistJoke(this.robot,e,n)}}).catch(t=>{this.robot&&this.robot.updateRobotStatusMessages(JSON.stringify(t,null,2))})}}else console.log("JokeSkill: launch: error: robot is undefined")}tick(t,e){}}class L extends R{constructor(t,e){super(void 0,t,e),this.hubMap=new Map}addHub(t){this.hubMap.set(t.robotSerialName,t)}getShuffledArrayOfHubs(){return this.shuffleInPlace(Array.from(this.hubMap.values()))}shuffleInPlace(t){if(t.length<=1)return t;for(let e=0;e<t.length;e++){const n=this.getRandomInt(e,t.length-1);[t[e],t[n]]=[t[n],t[e]]}return t}getRandomInt(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t))+t}}class B extends L{constructor(t,e){super(t,e)}launch(t){if(console.log(`ClockEnsembleSkill: launch: running: ${this.running}`),!this.running){this.running=!0;let t=this.getShuffledArrayOfHubs();if(t&&t.length>0){let e=new Date,n=e.getHours();n>12&&(n-=12);let i=e.getMinutes(),o=`<anim name='emoji-clock-hf-01' nonBlocking='true'/>The current time is ${n} ${i<10?"oh":""} ${i}`,a=t.shift();if(a&&a.robot){let t=a.robot;if(t.requester){t.requester.expression.say(o).complete.then(()=>{this.running=!1}).catch(e=>{t.updateRobotStatusMessages(JSON.stringify(e,null,2))})}}t.forEach(t=>{if(t&&t.robot){let e=t.robot;if(e.requester){let t="<break size='3.0'/><anim cat='shift' layers='body' nonBlocking='true'/><anim cat='happy' layers='screen' filter='&(eye-only)' nonBlocking='true' />.Yeah, that's right.";e.requester.expression.say(t).complete.then(()=>{}).catch(t=>{e.updateRobotStatusMessages(JSON.stringify(t,null,2))})}}})}}}tick(t,e){}}class W{constructor(){this.ensembleSkillMap=new Map,this.addEnsembleSkill(new B("clockEnsemble","launchClock"))}static get Instance(){return this._instance||(this._instance=new this)}addEnsembleSkill(t){this.ensembleSkillMap.set(t.id,t)}getEnsembleSkillWithId(t){return this.ensembleSkillMap.get(t)}}class G extends R{constructor(t){super(t,"UserLikesSkill","launchUserLikes"),console.log(`UserLikesSkill: constructor: ${t.serialName}`)}launch(t){if(this.robot){console.log(`UserLikesSkill: launch: ${this.robot.serialName}`,t);let e,n="na",i=void 0,o=void 0,a=void 0;if(t&&t.launchId&&(n=t.launchId),t&&t.nluData&&(e=t.nluData),e&&e.parameters&&e.parameters.user&&(i=e.parameters.user),t&&e.parameters&&e.parameters.thing&&(o=e.parameters.thing),e&&e.parameters&&e.parameters.thingOriginal&&(a=e.parameters.thingOriginal),console.log(e,i,a),i&&a){let t=`OK. Thank you for telling me that ${i} likes ${a}}. I will try and remember that.`;if(this.robot.requester){this.robot.requester.expression.say(t).complete.then(()=>{this.running=!1,this.robot&&o&&n&&i?A.Instance.persistUserLikesThing(this.robot,o,n,i):console.log("UserLikesSkill: not enough info to call PersistenceManager")}).catch(t=>{this.robot&&this.robot.updateRobotStatusMessages(JSON.stringify(t,null,2))})}}}else console.log("UserLikesSkill: launch: error: robot is undefined")}tick(t,e){}}class z extends y.EventEmitter{constructor(t){super(),this.dialogflowController=new E,this.luisController=new M,this.sessionId=`robot_${Math.floor(1e4*Math.random())}`,this.robot=t,this.skillMap=new Map,this.launchIntentMap=new Map,A.Instance,this.startTickTime=(new Date).getTime(),this.previousTickTime=this.startTickTime,this.tickInterval=setInterval(this.tick.bind(this),1e3)}tick(){this.skillMap.forEach((t,e)=>{if(t&&t.running){let e=(new Date).getTime(),n=e-this.previousTickTime,i=e-this.startTickTime;t.tick(n,i)}})}onRobotConnected(){console.log(`HUB: onRobotConnected: ${this.robot.serialName}`,this.robot.requester),this.robot.requester&&this.robot.requester.listen&&(this.robot.appInfo&&(A.Instance.connect(this.robot.appInfo,!0),this.dialogflowController.config=this.robot.appInfo,this.luisController.config=this.robot.appInfo),this.hjToken=this.robot.requester.listen.subscribe.hotword(),this.hjToken.hotWordHeard.on(t=>{if(console.log("Heard Hey Jibo from speaker: ",t),this.robot.resetKeepAlive(),this.robot.requester){this.robot.requester.listen.start().update.on(e=>{if(console.log("Hey! I think i heard something: ",e),e){let n={speaker:t,listenResultEvent:e};this.onHotwordEvent(n)}})}})),this.registerSkill(new G(this.robot)),this.registerSkill(new P(this.robot));let t=W.Instance.getEnsembleSkillWithId("clockEnsemble");t&&(this.registerSkill(t),t.addHub(this))}registerSkill(t){console.log(`HUB: registerSkill: ${this.robot.serialName}`,t),this.skillMap.set(t.id,t),this.launchIntentMap.set(t.launchIntent,t)}removeSkill(t){this.skillMap.set(t.id,void 0),this.skillMap.delete(t.id)}onHotwordEvent(t){console.log(`HUB: onHotwordEvent: ${this.robot.serialName}`,t);let e=t.listenResultEvent.Speech;this.getLaunchIntent(e).then(t=>{if(t&&t.intent){let n=t.intent,i=`${(new Date).getTime()}`,o=this.launchIntentMap.get(n),a={nluType:t.nluType,asr:e,intent:n,launchId:i,nluData:t,userId:"someone"};console.log("HUB: onHotwordEvent: robotIntentData",a),o?(o.launch(a),o.running=!0,A.Instance.persistLaunchIntent(this.robot.name,"someone",n,i)):(console.log("HUB: onHotwordEvent: passing to robot onLaunchEvent: ",a),this.robot.onLaunchIntent(a))}}).catch(t=>{console.log("HUB: onHotwordEvent: error: ",t)})}getLaunchIntent(t){let e="none";return this.robot.appInfo&&this.robot.appInfo.nluDefault&&(e=this.robot.appInfo.nluDefault),this.getIntent(t,["launch"],e)}getIntent(t,e,n){return console.log(`HUB: getIntent: asr: ${t}, ${n}, contexts: `,e),new Promise((i,o)=>{let a=t,s=void 0;if("luis"==n?s=this.luisController:"dialogflow"==n&&(s=this.dialogflowController),s){let r="";e&&(r=e[0]),s.getIntentAndEntities(a,"en-US",r,this.sessionId).then(e=>{let o={nluType:n,asr:t,intent:e.intent,parameters:e.entities};console.log("HUB: getIntent: nluData",o),i(o)}).catch(t=>{o(t)})}else{let e={nluType:n,asr:t,intent:"",parameters:{}};console.log("HUB: getIntent: NO NLU DEFINED: nluData",e),i(e)}})}get robotSerialName(){return this.robot.serialName}}var U=n(26);const j=n(9),H=n(25);var F,O;!function(t){t.jibo="jibo",t.robokit="robokit"}(F||(F={})),function(t){t[t.LAUNCH=0]="LAUNCH",t[t.LISTEN=1]="LISTEN",t[t.ACTION_COMPLETE=2]="ACTION_COMPLETE"}(O||(O={}));class q extends y.EventEmitter{constructor(t){super(),this._type="jibo",this.name="",this.ip="",this.serialName="",this.email="",this.password="",this._number=0,this._muted=!1,t=t||{type:this.type,name:this.name,ip:this.ip,serialName:this.serialName,email:this.email,password:this.password},this.initWithData(t),this._connected=!1,this._targeted=!1,this._hub=new z(this),this._stateData={userId:"",userName:""}}get type(){return this._type}set type(t){this._type=t}initWithData(t){this.type=t.type||"jibo",this.name=t.name,this.ip=t.ip,this.serialName=t.serialName,this.email=t.email,this.password=t.password}updateRobotStatusMessages(t,e,n=!1){return e=e||`Robot<${this.name}>`,this.emit("statusMessage",{message:t,subsystem:e}),""}get number(){return this._number}set number(t){this._number=t}get json(){return{type:this.type,name:this.name,ip:this.ip,serialName:this.serialName,email:this.email,password:this.password}}updateUserData(t,e){this._stateData.userId=t,this._stateData.userName=e}get userData(){return{userId:this._stateData.userId,userName:this._stateData.userName}}updateStateData(t){this._stateData=Object.assign(this._stateData,t)}get stateData(){return this._stateData}set stateData(t){this._stateData=t}onLaunchIntent(t){let e={robot:this,type:O.LAUNCH,data:t};this.emit("robotIntent",e)}onListenIntent(t){let e={robot:this,type:O.LISTEN,data:t};this.emit("robotIntent",e)}sendCommand(t){if(this.resetKeepAlive(),this._robotConnection)switch(t.type){case"say":case"tts":if(!this._muted&&t.data&&(t.data.text||t.data.prompt)){let e=t.data.text||t.data.prompt;this._robotConnection.requester.expression.say(e).complete.then(()=>{let t={nluType:"none",asr:"",intent:"OK",launchId:void 0,nluData:void 0,userId:void 0},e={robot:this,type:O.ACTION_COMPLETE,data:t};this.emit("robotIntent",e)}).catch(t=>{console.log(t),this.updateRobotStatusMessages(JSON.stringify(t,null,2))})}break;case"ask":if(!this._muted&&t.data&&t.data.prompt){let e=t.data.prompt,n=t.data.contexts||[],i="none";this.appInfo&&this.appInfo.nluDefault&&(i=this.appInfo.nluDefault);let o=t.data.nluType||i;this._robotConnection.requester.expression.say(e).complete.then(()=>{if(this._robotConnection){this._robotConnection.requester.listen.start().update.on(t=>{if(console.log("Hey! I think i heard something: ",t),t&&"onListenResult"==t.Event&&t.Speech){let e={nluType:o,asr:t.Speech,intent:"",launchId:void 0,nluData:void 0,userId:void 0};"none"!=o?this._hub.getIntent(t.Speech,n,o).then(t=>{e.intent=t.intent,e.nluData=t,this.onListenIntent(e)}).catch(t=>{console.log(t)}):this.onListenIntent(e)}else this.updateRobotStatusMessages("Error: invalid listen result: ask")})}else this.updateRobotStatusMessages("Error starting listen for command: ask")}).catch(t=>{console.log(t),this.updateRobotStatusMessages(JSON.stringify(t,null,2))})}break;case"lookAtPosition":case"lookAt":if(!this._muted&&t.data&&(t.data.angle||t.data.vector)){let e;if(t.data.angle){let n={type:"ANGLE",angle:{theta:t.data.angle,psi:0},levelHead:!0};e=this._robotConnection.requester.expression.look(n).complete}else if(t.data.vector){let n={type:"POSITION",position:{x:t.data.vector[0],y:t.data.vector[1],z:t.data.vector[2]},levelHead:!0};e=this._robotConnection.requester.expression.look(n).complete}e&&(console.log("p:",e),e.then(()=>{}).catch(t=>{console.log(t),this.updateRobotStatusMessages(JSON.stringify(t,null,2))}))}break;case"attention":if(!this._muted&&t.data&&t.data.state){let e="OFF";switch(t.data.state){case"OFF":e="OFF";break;case"IDLE":e="IDLE"}this._robotConnection.requester.expression.setAttention(e).complete.then(()=>{}).catch(t=>{console.log(t),this.updateRobotStatusMessages(JSON.stringify(t,null,2))})}break;case"volume":if(!this._muted&&t.data&&t.data.volume){let e={mixer:Number(t.data.volume)};this._robotConnection.requester.config.set(e).complete.then(()=>{}).catch(t=>{console.log(t),this.updateRobotStatusMessages(JSON.stringify(t,null,2))})}break;case"mute":this.mute(!0);break;case"unmute":this.mute(!1);break;case"image":if(!this._muted&&t.data&&t.data.url){let e={Type:"Image",Name:t.data.name,Image:{name:t.data.name,src:t.data.url}};this._robotConnection.requester.display.swap(e).complete.then(()=>{}).catch(t=>{console.log(t),this.updateRobotStatusMessages(JSON.stringify(t,null,2))})}break;case"eye":if(!this._muted){let t={Type:"Eye",Name:"eye"};this._robotConnection.requester.display.swap(t).complete.then(()=>{}).catch(t=>{console.log(t),this.updateRobotStatusMessages(JSON.stringify(t,null,2))})}break;case"motion":!this._muted&&t.data&&t.data.state&&("ON"==t.data.state?this._motionTrackToken||(this._motionTrackToken=this._robotConnection.requester.perception.subscribe.motion(),this._motionTrackToken.update.on(t=>{console.log(t),console.log(`detectedMotion: update: count: ${t.length}:`,t)})):"OFF"==t.data.state&&this._motionTrackToken&&(this._motionTrackToken.cancel(),this._motionTrackToken=void 0));break;case"faces":!this._muted&&t.data&&t.data.state&&("ON"==t.data.state?(this._faceTrackToken=this._robotConnection.requester.perception.subscribe.face(),this._faceTrackToken.gained.on(t=>{if(t.length>0){var e=t[0].EntityID;console.log(`detectedFaces: gained: count: ${t.length}, id: ${e}`,t)}}),this._faceTrackToken.update.on(t=>{if(t.length>0){var e=t[0].EntityID;console.log(`detectedFaces: update: count: ${t.length}, id: ${e}`,t)}})):"OFF"==t.data.state&&this._faceTrackToken&&(this._faceTrackToken.cancel(),this._faceTrackToken=void 0));break;case"photo":console.log(this._robotConnection.requester),console.log(this._robotConnection.requester.media.capture),console.log(this._robotConnection.requester.media.capture.photoRequest);try{this._robotConnection.requester.media.capture.photo().complete.then(t=>{const e=t.URI;console.log(t),console.log("photo ready - uri: ",e);const i=j.createWriteStream("./PhotoIzHere.jpg");H.get({hostname:this.ip,port:8160,path:e},function(t){t.pipe(i),console.log("Your photo was saved as PhotoIzHere.jpg"),n(27).exec("open PhotoIzHere.jpg")})}).catch(t=>{console.log(t),this.updateRobotStatusMessages(JSON.stringify(t,null,2))})}catch(t){console.log(t)}}}keepAlive(){let t=new w("","say",{text:"."});this.sendCommand(t)}clearKeepAlive(){this._keepAliveInterval&&(clearInterval(this._keepAliveInterval),this._keepAliveInterval=void 0)}resetKeepAlive(){this.clearKeepAlive(),this._keepAliveInterval=setInterval(this.keepAlive.bind(this),6e4)}connect(t){console.log("connect:",t),this.appInfo=t,this.updateRobotStatusMessages("Attempting to connect..."),this._connected&&this.disconnect();let e={clientId:t.clientId,clientSecret:t.clientSecret,email:this.email,password:this.password};this.loginToAccount(e).then(t=>{console.log("connect: connected:",t),this.getRobot(t,this.serialName).then(t=>{console.log("connection:",t),this._robotConnection=t,this._robotConnection.on("status",t=>{console.info(`connection: status: ${t}`),this.updateRobotStatusMessages(t)}),this._robotConnection.connect().then(()=>{if(console.log("connect: Robot connected!"),this._robotConnection){const t=this._robotConnection;this.ip=t._ip,this._robotConnection.once("disconnect",()=>{console.info("connect: Robot disconnected."),this.updateRobotStatusMessages("connect: Robot disconnected."),this._connected=!1}),this._connected=!0,this._targeted=!0,this._hub.onRobotConnected(),this.emit("updateRobot",this),this.resetKeepAlive()}else console.log("connect: error: _robotConnection undefined."),this._connected=!1,this.updateRobotStatusMessages("connect: error: _robotConnection undefined.")}).catch(t=>{console.log("connect: connection.connect: error:",t),this.updateRobotStatusMessages(`connect: connection.connect: error: ${t}`)})}).catch(t=>{console.log("connect: getRobot: error:",t)})}).catch(t=>{console.log("connect: loginToAccount: error:",t)})}async loginToAccount(t){let e=new U.Account(t);return console.log("jiboConnect: Logging in... "),await e.login(),console.info("done"),e}async getRobot(t,e){process.stdout.write("Getting robot info... ");const n=await t.getRobots();console.info("done");const i=n.find(t=>t.serialName===e);if(!i)throw console.info("Robots on account:"),console.info(n.map(t=>t.serialName).join("\n")),new Error(`Robot ${e} not found`);return i}disconnect(){this.updateRobotStatusMessages("Attempting to disconnect...");try{this._connected&&this._robotConnection&&(this._robotConnection.disconnect(),this._robotConnection=void 0)}catch(t){console.log("Robot: disconnect: error:",t)}this._connected=!1,this.clearKeepAlive()}get connected(){return this._connected}get targeted(){return this._targeted}get requester(){let t;return this._robotConnection&&(t=this._robotConnection.requester),t}toggleTargeted(){this._targeted=!this._targeted}mute(t=!0){this._muted=t,console.log("muted: ",this._muted)}}n(28);const J=n(7);class V extends i.Component{constructor(t){super(t)}componentWillMount(){this.setState({showModalState:!1,type:"",name:"",password:""},()=>{})}componentWillReceiveProps(t){if(t.modalRobot){let e="<jibo ip is set-automatically>";t.modalRobot.ip&&(e=t.modalRobot.ip),this.setState({showModalState:t.showModalProp,type:t.modalRobot.type,name:t.modalRobot.name,ip:e,aliasName:t.modalRobot.serialName,email:t.modalRobot.email,password:t.modalRobot.password},()=>{console.log(this.state.type,this.state.name,this.state.ip,this.state.aliasName,this.state.email)})}}componentDidUpdate(t,e){}close(t=!0){this.setState({showModalState:!1,type:"",name:"",ip:"",aliasName:"",email:"",password:""},()=>{this.props.onClose(t)})}save(){this.props.modalRobot.type=this.state.type,this.props.modalRobot.name=this.state.name,this.props.modalRobot.serialName=this.state.aliasName,this.props.modalRobot.email=this.state.email,this.props.modalRobot.password=this.state.password,this.props.modalRobot.ip=this.state.ip,this.close(!1)}onHide(){console.log("ModalRobotInfo: onHide")}handleInputChange(t){let e=t.nativeEvent;switch(e.target.name){case"name":this.setState({name:e.target.value});break;case"aliasName":this.setState({aliasName:e.target.value});break;case"email":this.setState({email:e.target.value});break;case"password":this.setState({password:e.target.value});break;case"ip":let t="<jibo ip is set-automatically>";this.state.type==F.robokit&&(t=e.target.value),this.setState({ip:t})}}onMenuItemSelected(t){let e="<jibo ip is set-automatically>";t==F.robokit&&(e=""),this.setState({type:t,ip:e})}renderRobotTypeItems(){let t=[];for(var e in F){let n=!1;e==this.state.type&&(n=!0),t.push(i.createElement(a.MenuItem,{active:n,key:e,eventKey:e,onSelect:this.onMenuItemSelected.bind(this,e)},e))}return t}renderRobotTypeSplitButton(){return i.createElement(a.SplitButton,{bsStyle:"default",title:this.state.type,key:"filename-splitbutton",id:"filename-splitbutton"},this.renderRobotTypeItems())}render(){return i.createElement("div",{className:"static-modal"},i.createElement(a.Modal,{show:this.state.showModalState,onHide:this.onHide.bind(this)},i.createElement(a.Modal.Header,null,i.createElement(a.Modal.Title,null,"Robot Info")),i.createElement(a.Modal.Body,null,i.createElement(a.Table,{striped:!0,bordered:!0,condensed:!0,hover:!0,style:{width:300}},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,"type:"),i.createElement("td",null,this.renderRobotTypeSplitButton())),i.createElement("tr",null,i.createElement("td",null,"name:"),i.createElement("td",null,i.createElement("input",{name:"name",value:this.state.name,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"aliasName:"),i.createElement("td",null,i.createElement("input",{name:"aliasName",value:this.state.aliasName,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"email:"),i.createElement("td",null,i.createElement("input",{name:"email",value:this.state.email,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"password:"),i.createElement("td",null,i.createElement(J,{id:"password",name:"password",value:this.state.password,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"ip:"),i.createElement("td",null,i.createElement("textarea",{name:"ip",value:this.state.ip,onChange:this.handleInputChange.bind(this),style:{width:300,height:24}})))))),i.createElement(a.Modal.Footer,null,i.createElement(a.Button,{onClick:()=>this.close()},"Cancel"),i.createElement(a.Button,{bsStyle:"primary",onClick:this.save.bind(this)},"Save changes"))))}}const K="-----BEGIN CERTIFICATE-----\nMIIEjDCCAnQCAQEwDQYJKoZIhvcNAQELBQAwgYsxCzAJBgNVBAYTAlVTMQswCQYD\nVQQIDAJNQTETMBEGA1UEBwwKQmFybnN0YWJsZTESMBAGA1UECgwJd3dsaWIub3Jn\nMRAwDgYDVQQLDAdyb2Jva2l0MRMwEQYDVQQDDApyb2Jva2l0LmlvMR8wHQYJKoZI\nhvcNAQkBFhBhbmRyZXdAd3dsaWIub3JnMB4XDTE5MDMwNDE3NDkyNVoXDTIwMDMw\nMzE3NDkyNVowgYsxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJNQTETMBEGA1UEBwwK\nQmFybnN0YWJsZTESMBAGA1UECgwJd3dsaWIub3JnMRAwDgYDVQQLDAdyb2Jva2l0\nMRMwEQYDVQQDDApyb2Jva2l0LmlvMR8wHQYJKoZIhvcNAQkBFhBhbmRyZXdAd3ds\naW4ub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuR+Hl9w9Do3o\nIl1ygduhAy+1jjiXUKdZ6Mnxm/3Z2Su0/A9Aj9xIS5OlV6BTrmY+bD6eRE5YUga0\nw8/gjq+9OBXOgYeXfSTE5hQCiaLgjDJy02PoiBM3WQA253WwFiTGqRQA5Vgu1oxy\nSKlG4jlwr9aZ/MAcho3b0RIbHy9IbEwFuN+YcRFv/D6FMNniAtpzQYLNcEeoS9VH\nyOXbKrrYTyjUFigMwBG1qQhbRJtTT5/ve6AS0XwX9IYtwXm27RetQqfORkaSiAvB\nqb4vyBHChaejHVTzYaZuVz5piXxI26IFf3Leop0ViUa5bQgUWmqmQQ4bl62mkI4J\n/Xduc4IE7wIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQBqEHEhhIThP9mf7wOD+nmy\nE2WSfMV7QrsvvG9rD09uT8rhq8mAQiQKgrzaMduV8pDutAXmaIb1e1EwKPbpAcz1\nXD/y+yeemJXphdHLOLTurLaNKgOWasUMAZELL1EO9kaZDX2D91WuY8GfFwmVfFdH\nRdxu+zHyUSwR7MTuT8SWmZMPV1e3k4pt5PU9xSexhPGkwA+S+EOC2vIkVE4HnJfZ\nwxPdstazRjhZw2s8iQyzvPOjVyB3bfIVZfHGRo/Sva0YA95yTJWvtJJGY3SvHdR/\ns/IZhi2ykKPLX5QSpeh/UzC90eceBxxRXPobAf4bokX0UpSp6ecCDqEBsl+TfO5C\nVgkmvGe8aKHbYOkcDW2LqmWE4E2MEd2aOhceL4a/Ac0hX6GDEHhVpYvBkq0glOTC\nxxVqZgQKqf2lOGplqMtAXx6a8WjcwyS/kquF3FO9BpASBFoiqL2W0n5VNUeOXbwp\nmIxHzP9p7DLUNtnN4pQCiZ1kjdp9S4JYCq9xK1sfELqAGhyAKz4YlYLHfp1z0AKl\nAv19m6q5rYvxq3WaqZOD+WP7CQP/xuf5ExIcCYEz3GZOHjFtgATf07G/730pwga1\ng+GaLtcVNpxKpWqivGay8i0ALgtb0gDMwu4EH8c3wVcpEOLzPoWkJNFMCAgmGIqZ\nxT8jZ6RHEUUU+BaH3LaAIw==\n-----END CERTIFICATE-----\n";class Y extends y.EventEmitter{constructor(){super(),this.complete=void 0}}class $ extends y.EventEmitter{constructor(t,e,n,i){super(),this.id=t,this.robotSerialName=i,this.type=e,this.data=n,this.status="OK",this.sendTime=0,this.receiptTime=0,this.commandReceivedTime=0,this.commandCompletedTime=0}getMessageDataToSend(){return this.sendTime=(new Date).getTime(),{id:this.id,type:this.type,data:this.data,sendTime:this.sendTime}}getMessageDataToLog(){return{id:this.id,type:this.type,status:this.status,sendTime:this.sendTime,commandReceivedTime:this.commandReceivedTime,commandCompletedTime:this.commandCompletedTime,receiptTime:this.receiptTime}}onReceipt(t){this.receiptTime=(new Date).getTime(),this.receiptPayload=t,this.commandReceivedTime=t.commandReceivedTime,this.commandCompletedTime=t.commandCompletedTime,this.emit("receipt",this)}destroy(){this.removeAllListeners(),this.data=null,this.receiptPayload=null}}class Q{static init(){Q.transactions=new Map}static getNextId(){return`${Q.lastId++}`}static createTransaction(t,e,n){let i=Q.getNextId(),o=new $(i,t,e,n);return Q.transactions.set(i,o),o}static receiveTransaction(t,e){let n=t.id,i=Q.transactions.get(n);return i&&(Q.transactions.delete(n),i.status=e,i.onReceipt(t)),i}static destroyTransaction(t){Q.transactions.delete(t.id),t.destroy()}}Q.lastId=0;const X=n(29),Z=n(30);class tt extends y.EventEmitter{constructor(t="",e=9696){super(),this.hostname=t||Z.address(),this.port=e,this.connectionString=`wss://${this.hostname}:${this.port}`,this.webSocket=void 0,this.robotSerialName=`robokit-${this.hostname}:${this.port}`,Q.init(),this.requester={expression:{say:t=>{const e=Q.createTransaction("tts",{prompt:t},this.robotSerialName);return this.sendTransactionMessageData(e.getMessageDataToSend())},blink:()=>{const t=Q.createTransaction("blink",{},this.robotSerialName);return this.sendTransactionMessageData(t.getMessageDataToSend())},lookAt:t=>{const e=Q.createTransaction("lookAt",t,this.robotSerialName);return this.sendTransactionMessageData(e.getMessageDataToSend())},ident:t=>{const e=Q.createTransaction("ident",t,this.robotSerialName);return this.sendTransactionMessageData(e.getMessageDataToSend())}}}}connect(){return new Promise((t,e)=>{this.startWebSocket(),t()})}disconnect(){}startWebSocket(){if(console.log(`startWebSocket: ${this.connectionString}`),this.webSocket){try{this.webSocket.close()}catch(t){console.log(t)}this.webSocket=null}try{let t=[K];this.webSocket=new X(this.connectionString,{ca:t,rejectUnauthorized:!1,checkServerIdentity:(t,e)=>{if(console.log("certificate.subject.CN:",e.subject.CN),"TBD"!==e.subject.CN)throw Error("Certificate CN doesn't match expected CN: TBD")}}),this.webSocket.on("error",t=>{this.emit("error",t),console.log("error:",t)}),this.webSocket.on("open",()=>{let t={status:"OK",connectionString:`${this.connectionString}`};this.sendHandshakeMessage(t),this.emit("connected")}),this.webSocket.on("message",(t,e)=>{let n;try{n=JSON.parse(t)}catch(t){console.log("websocket onMessage: JSON.parse: ",t),n=null}n&&(console.log("received json message: ",n),this.emit("message",n),n.type)}),this.webSocket.on("close",()=>{console.log("websocket client closed"),this.webSocket=void 0,this.emit("closed")})}catch(t){this.webSocket=void 0,console.log(t)}}sendTransactionMessageData(t){console.log("sendTransactionMessageData:",t);const e=new Y;t.client="robocommander";let n={type:"transaction",command:t};return e.complete=new Promise((t,e)=>{if(this.webSocket){let e=JSON.stringify(n);this.webSocket.send(e),t()}else e()}),e}sendHandshakeMessage(t){console.log("sendHandshakeMessage:",t);const e=new Y;let n={client:"robocommander",type:"handshake",payload:t,timestamp:(new Date).getTime()};return e.complete=new Promise((t,e)=>{if(this.webSocket){let e=JSON.stringify(n);this.webSocket.send(e),t()}else e()}),e}}class et extends q{constructor(t){(t=t||{type:F.robokit,name:"",ip:"",serialName:"",email:"",password:""}).type=F.robokit,super(t)}sendCommand(t){if(console.log("sendCommand:",t,this._robotConnection),this._robotConnection)switch(t.type){case"say":case"tts":let e=t.data.text||t.data.prompt;this._robotConnection.requester.expression.say(e);break;case"blink":this._robotConnection.requester.expression.blink();break;case"lookAt":this._robotConnection.requester.expression.lookAt(t.data);break;case"ident":this._robotConnection.requester.expression.ident(t.data)}}connect(t){console.log("RobokitRobot: connect:",t),this.appInfo=t,this.updateRobotStatusMessages("Attempting to connect..."),this._connected&&this.disconnect(),this._robotConnection=new tt,this._robotConnection.connect(),this._robotConnection.on("connected",()=>{console.log("RobokitRobot: connection: connected"),this.updateRobotStatusMessages("...connected."),this._connected=!0,this._targeted=!0,this._hub.onRobotConnected(),this.emit("updateRobot",this)}),this._robotConnection.on("message",t=>{}),this._robotConnection.on("error",t=>{console.log(t)}),this._robotConnection.on("closed",()=>{this._connected=!1,this._targeted=!1})}keepAlive(){console.log("keepAlive:")}}class nt extends i.Component{constructor(t){super(t),this.bsStyle="primary",this._updateRobotsHandler=this.onUpdateRobots.bind(this)}componentWillMount(){this.setState({showModal:!1,lastUpdateTime:(new Date).getTime(),statusMessages:"",addNewRobot:!1}),this.props.robots.on("updateRobots",this._updateRobotsHandler)}componentDidMount(){this.props.model.addPanelWithId(this.props.id)}componentWillUnmount(){this.props.robots.removeListener("updateRobots",this._updateRobotsHandler)}onUpdateRobots(t){this.setState({lastUpdateTime:(new Date).getTime(),statusMessages:this.props.robots.statusMessages})}handleClick(t){this.props.model.bringPanelToFront(this.props.id)}handleClose(t){this.props.onClosePanel(this.props.id)}handleMinimize(t){console.log("minimize")}handleMaximize(t){console.log("maximize")}handleFullScreen(t){console.log("fullscreen")}render(){return i.createElement(r.a,{handle:".handle"},i.createElement("div",{className:"commander-panel well",id:"robotsPanel"},i.createElement(m,{draggable:!0,handleClick:this.handleClick.bind(this),handleClose:this.handleClose.bind(this),handleMinimize:this.handleMinimize.bind(this),handleMaximize:this.handleMaximize.bind(this),handleFullScreen:this.handleFullScreen.bind(this)}),i.createElement("h4",{className:"pull-left handle",style:{marginBottom:20}},"Robot List"),i.createElement("div",{className:"clearfix"}),i.createElement(a.Table,{striped:!0,condensed:!0,hover:!0},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",{style:{width:300}},i.createElement(a.ButtonGroup,{vertical:!0,style:{width:300}},i.createElement(V,{showModalProp:this.state.showModal,onClose:this.onCloseRobotModal.bind(this),modalRobot:this.state.modalRobot}),this.createRobotButtons()),i.createElement("div",{className:"clearfix"}),i.createElement(a.Button,{bsStyle:"info",key:"addRobot",style:{width:100},onClick:this.onAddRobot.bind(this)},"Add Robot")),i.createElement("td",null,i.createElement("textarea",{id:"statusMessages",name:"statusMessages",value:this.state.statusMessages,onChange:this.handleInputChange.bind(this),style:{maxHeight:300,minHeight:200,width:"100%"}}),i.createElement(a.Button,{bsStyle:"info",key:"clearMessages",style:{width:130},onClick:this.onClearMessages.bind(this)},"Clear Messages")))))))}handleInputChange(t){t.nativeEvent.target.name}onCloseRobotModal(t){if(!t&&this.state.addNewRobot&&this.state.modalRobot){const t=this.state.modalRobot;let e,n={type:t.type,name:t.name,ip:t.ip,serialName:t.serialName,email:t.email,password:t.password};e=this.state.modalRobot.type==F.robokit?new et(n):t,this.props.robots.addRobot(e)}this.setState({showModal:!1,addNewRobot:!1})}openRobotModal(t){this.setState({showModal:!0,modalRobot:t})}onButtonClicked(t,e){switch(console.log(`onButtonClicked: ${t.name}: ${e}`),e){case"select":t.connected?this.props.robots.disconnectRobot(t):this.props.robots.connectRobot(t,this.props.appInfo);break;case"edit":this.openRobotModal(t);break;case"delete":this.props.robots.removeRobot(t),this.setState({lastUpdateTime:(new Date).getTime()})}}onAddRobot(){let t=new q;this.setState({addNewRobot:!0}),this.openRobotModal(t)}onClearMessages(){this.props.robots.updateRobotsStatusMessages("","",!0)}createRobotButton(t){let e="default";return t.connected&&(e="primary"),i.createElement("div",{key:t.name},i.createElement(a.Button,{bsStyle:e,key:t.name+"_select",style:{width:150},onClick:this.onButtonClicked.bind(this,t,"select")},t.name),i.createElement(a.Button,{bsStyle:"info",key:t.name+"_edit",style:{width:80},onClick:this.onButtonClicked.bind(this,t,"edit")},"Edit"),i.createElement(a.Button,{bsStyle:"danger",key:t.name+"_delete",style:{width:40},onClick:this.onButtonClicked.bind(this,t,"delete")},"X"))}createRobotButtons(){return this.props.robots.robotList.map(this.createRobotButton.bind(this))}}var it=n(33);const ot=n(10);class at extends i.Component{constructor(t){super(t)}componentWillMount(){this.setState({showModalState:!1,name:""},()=>{})}componentWillReceiveProps(t){if(t.modalCommand)try{this.setState({showModalState:t.showModalProp,name:t.modalCommand.name,type:t.modalCommand.type,data:ot.stringify(t.modalCommand.data)},()=>{})}catch(t){console.log(t)}}componentDidUpdate(t,e){}close(){this.setState({showModalState:!1,name:"",type:"",data:{}},()=>{this.props.onClose(this.props.editMode)})}save(){console.log("ModalCommandInfo: save"),console.log(this.state);try{this.props.modalCommand.name=this.state.name,this.props.modalCommand.type=this.state.type,this.props.modalCommand.data=ot(this.state.data),console.log(this.props.modalCommand),this.close()}catch(t){console.log(t)}}onHide(){console.log("ModalCommandInfo: onHide")}handleInputChange(t){let e=t.nativeEvent;switch(e.target.name){case"name":this.setState({name:e.target.value});break;case"type":this.setState({type:e.target.value});break;case"data":this.setState({data:e.target.value})}}render(){return i.createElement("div",{className:"static-modal"},i.createElement(a.Modal,{show:this.state.showModalState,onHide:this.onHide.bind(this)},i.createElement(a.Modal.Header,null,i.createElement(a.Modal.Title,null,"Command Info")),i.createElement(a.Modal.Body,null,i.createElement(a.Table,{striped:!0,bordered:!0,condensed:!0,hover:!0,style:{width:300}},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,"name:"),i.createElement("td",null,i.createElement("input",{name:"name",value:this.state.name,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"type:"),i.createElement("td",null,i.createElement("input",{name:"type",value:this.state.type,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"data:"),i.createElement("td",null,i.createElement("textarea",{name:"data",value:this.state.data,onChange:this.handleInputChange.bind(this),style:{width:300,height:150}})))))),i.createElement(a.Modal.Footer,null,i.createElement(a.Button,{onClick:this.close.bind(this)},"Cancel"),i.createElement(a.Button,{bsStyle:"primary",onClick:this.save.bind(this)},"Save"))))}}console.log(it);let st=n(34);class rt extends i.Component{constructor(t){super(t),this.commandButtons={},this.cycleRobots=!1,this.x=0,this.y=0,this.z=.5,this.angle=0,this.sendflag=!0,this.previousController10Value=0,this.previousControllerTime=0,this._updateRobotsHandler=this.onUpdateRobots.bind(this),console.log("Commands: constructor"),this.handleChange=this.handleChange.bind(this),this.handleSubmitTTS=this.handleSubmitTTS.bind(this),this.setupWebMidi()}setupWebMidi(){st.enable(t=>{t?console.log("WebMidi could not be enabled.",t):(console.log("WebMidi enabled!"),console.log(st.inputs),console.log(st.outputs),st.inputs.forEach(t=>{console.log(`Commands: Adding Midi Input: ${t.name}`),t.addListener("pitchbend","all",t=>{console.log("Pitch value: "+t.value)}),t.addListener("noteon","all",t=>{let e;switch(console.log("Received 'noteon' message ("+t.note.number+": "+t.note.name+t.note.octave+")."),t.note.number){case 49:e=new w("","tts",{text:"<anim name='Confident_02' nonBlocking='true' />My name is Jibo."}),this.sendCommand(e);break;case 51:e=new w("","tts",{text:"<anim cat='no' filter='head-shake' nonBlocking='true' />So far I haven't met anyone exactly like me. <anim name='Greetings_02' nonBlocking='true'/> But I don't get out much."}),this.sendCommand(e);break;case 54:e=new w("","tts",{text:"<anim cat='dance' filter='waltz' nonBlocking='true'/> I love to dance"}),this.sendCommand(e);break;case 57:e=new w("","tts",{text:"<anim name='Checking_04' nonBlocking='true'/> I'm pretty scared of ghosts"}),this.sendCommand(e);break;case 48:e=new w("","tts",{text:"<anim name='Confident_02' nonBlocking='true' />."}),this.sendCommand(e);break;case 50:e=new w("Left","lookAt",{vector:[0,1,.5]}),this.sendCommand(e);break;case 52:e=new w("Right","lookAt",{vector:[0,-1,.5]}),this.sendCommand(e);break;case 53:e=new w("Center","lookAt",{vector:[1,0,.5]}),this.sendCommand(e);break;case 55:e=new w("Back","lookAt",{vector:[-1,0,.5]}),this.sendCommand(e);break;case 60:e=new w("Left","lookAt",{angle:.5}),this.sendCommand(e);break;case 62:e=new w("Right","lookAt",{angle:-.5}),this.sendCommand(e);break;case 64:e=new w("Back","lookAt",{angle:3.14159}),this.sendCommand(e)}}),t.addListener("noteoff","all",t=>{}),t.addListener("keyaftertouch","all",t=>{console.log("Received 'keyaftertouch' message: ")}),t.addListener("controlchange","all",t=>{console.log("Received 'controlchange' message ("+t.controller.number+": "+t.channel+": "+t.value+").");let e=(new Date).getTime();if(e-this.previousControllerTime>200&&(this.previousControllerTime=e,10==t.controller.number)){if(Math.abs(this.previousController10Value-t.controller.number)>2){let e=new it.Vector3(0,0,1),n=new it.Vector3(1,0,.5),i=2*Math.PI*t.value/128,o=(new it.Quaternion).setFromAxisAngle(e,i),a=n.clone().applyQuaternion(o),s=[a.x,a.y,a.z];console.log("vector: ",s);let r=new w("","lookAtPosition",{vector:s});this.sendCommand(r)}this.previousController10Value=t.value}}),t.addListener("pitchbend","all",t=>{console.log("pitch: ",t)}),t.addListener("channelmode","all",t=>{console.log("Received 'channelmode' message: ")}),t.addListener("programchange","all",t=>{console.log("Received 'programchange' message: ",t)}),t.addListener("channelaftertouch","all",t=>{console.log("Received 'channelaftertouch' message: ")})}))})}componentWillMount(){this.setState({lastUpdateTime:(new Date).getTime(),value:"",commandList:this.props.model.romCommands.commandList,showModal:!1,editMode:"",deleteMode:!1,targetedRobots:this.props.model.robots.targetedRobots}),this.props.model.robots.on("updateRobots",this._updateRobotsHandler)}componentDidMount(){this.props.model.addPanelWithId(this.props.id)}componentWillUnmount(){this.props.model.robots.removeListener("updateRobots",this._updateRobotsHandler)}onUpdateRobots(t){console.log("Commands: onUpdateRobots"),this.setState({lastUpdateTime:(new Date).getTime()})}handleChange(t){let e=t.nativeEvent;this.setState({value:e.target.value})}handleSubmitTTS(t){let e=new w("","tts",{text:this.state.value});this.sendCommand(e),t.preventDefault()}sendCommandWithName(t){console.log("Commands: sendCommandWithName: ",t);let e=this.props.model.romCommands.getCommandWithName(t);e&&("edit"===this.state.editMode?(console.log(" editing"),this.openCommandModal(e)):this.state.deleteMode?(console.log(" deleting"),this.props.model.romCommands.removeCommand(e),this.setState({commandList:this.props.model.romCommands.commandList})):(console.log(" executing"),this.props.model.sendRomCommand(e),this.cycleRobots&&this.cycleTargetedRobots()))}sendCommand(t){console.log("Commands: sendCommand: ",t),this.props.model.sendRomCommand(t)}handleClick(t){this.props.model.bringPanelToFront(this.props.id)}handleClose(t){this.props.onClosePanel(this.props.id)}handleMinimize(t){console.log("minimize")}handleMaximize(t){console.log("maximize")}handleFullScreen(t){console.log("fullscreen")}render(){return this.commandButtons={},this.commandButtonsArray=[],this.props.model.romCommands.commandNames.forEach(t=>{let e=i.createElement(a.Button,{key:t,style:{width:150},onClick:this.sendCommandWithName.bind(this,t)},t);this.commandButtons[t]=e,this.commandButtonsArray.push(e)}),i.createElement(r.a,{handle:".handle"},i.createElement("div",{className:"commander-panel well",id:this.props.id},i.createElement(m,{draggable:!0,handleClick:this.handleClick.bind(this),handleClose:this.handleClose.bind(this),handleMinimize:this.handleMinimize.bind(this),handleMaximize:this.handleMaximize.bind(this),handleFullScreen:this.handleFullScreen.bind(this)}),i.createElement("h4",{className:"pull-left handle",style:{marginBottom:20}},"Commands"),i.createElement("div",{className:"clearfix"}),i.createElement(a.Table,{striped:!0,condensed:!0,hover:!0},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,i.createElement(a.ButtonGroup,{vertical:!0,style:{width:180}},this.createRobotButtons())),i.createElement("td",{style:{width:10}}),i.createElement("td",{style:{verticalAlign:"top"}},i.createElement("form",{onSubmit:this.handleSubmitTTS},i.createElement("label",null,"TTS:"),i.createElement("input",{ref:"tts",type:"text",style:{width:600},value:this.state.value,onChange:this.handleChange}),i.createElement("input",{type:"submit",value:"Submit"})),i.createElement(a.ButtonGroup,{style:{width:600}},i.createElement(at,{showModalProp:this.state.showModal,onClose:this.onCloseCommandModal.bind(this),modalCommand:this.state.modalCommand,editMode:this.state.editMode}),this.commandButtonsArray),i.createElement("div",{className:"clearfix"}),i.createElement(a.Button,{bsStyle:"info",key:"addCommand",style:{width:150},onClick:this.onAddCommand.bind(this)},"Add Command"),i.createElement("input",{type:"radio",checked:!this.state.deleteMode&&"edit"!=this.state.editMode,name:"mode",value:"execute",onChange:this.handleModeChange.bind(this),style:{width:20}})," Execute Command",i.createElement("input",{type:"radio",checked:!this.state.deleteMode&&"edit"==this.state.editMode,name:"mode",value:"edit",onChange:this.handleModeChange.bind(this),style:{width:20}})," Edit Command",i.createElement("input",{type:"radio",checked:this.state.deleteMode,name:"mode",value:"delete",onChange:this.handleModeChange.bind(this),style:{width:20}})," Delete Command"))))))}handleModeChange(t){switch(t.nativeEvent.target.value){case"execute":this.setState({editMode:"",deleteMode:!1});break;case"edit":this.setState({editMode:"edit",deleteMode:!1});break;case"delete":this.setState({editMode:"",deleteMode:!0})}}handleCheckboxChange(t){this.cycleRobots=!this.cycleRobots}onAddCommand(){let t=new w;this.setState({editMode:"add"},()=>{this.openCommandModal(t)})}onCloseCommandModal(t){"add"===t&&this.state.modalCommand.name?this.props.model.romCommands.addCommand(this.state.modalCommand):"edit"===t&&this.state.modalCommand.name&&this.props.model.romCommands.updateCommandWithName(this.state.modalCommand.name,this.state.modalCommand),this.setState({showModal:!1})}openCommandModal(t){this.setState({showModal:!0,modalCommand:t})}cycleTargetedRobots(){}onRobotButtonClicked(t,e){switch(e){case"select":t.toggleTargeted(),this.setState({targetedRobots:this.props.model.robots.targetedRobots})}}createRobotButton(t){let e="default";return t.targeted&&(e="primary"),i.createElement(a.Button,{bsStyle:e,key:t.name+"_select",style:{width:150},onClick:this.onRobotButtonClicked.bind(this,t,"select")},t.name)}createRobotButtons(){return this.props.model.robots.connectedRobots.map(this.createRobotButton.bind(this))}}class lt extends i.Component{constructor(t){super(t)}componentWillMount(){let t=!1;this.props.isChecked&&(t=this.props.isChecked),this.setState({isChecked:t})}toggleCheckboxChange(){const t=this.props.handleCheckboxChange,e=this.props.label;this.setState({isChecked:!this.state.isChecked}),t(e)}render(){const t=this.props.label,e=this.state.isChecked;return i.createElement("div",{className:"checkbox"},i.createElement("label",null,i.createElement("input",{type:"checkbox",value:t,checked:e,onChange:this.toggleCheckboxChange.bind(this)})," ",t))}}var ht=n(35),ct=n.n(ht),dt="http://www.w3.org/1999/xhtml",ut={svg:"http://www.w3.org/2000/svg",xhtml:dt,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},pt=function(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),ut.hasOwnProperty(e)?{space:ut[e],local:t}:t};var mt=function(t){var e=pt(t);return(e.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===dt&&e.documentElement.namespaceURI===dt?e.createElement(t):e.createElementNS(n,t)}})(e)};function gt(){}var ft=function(t){return null==t?gt:function(){return this.querySelector(t)}};function vt(){return[]}var bt=function(t){return null==t?vt:function(){return this.querySelectorAll(t)}},yt=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var wt=document.documentElement;if(!wt.matches){var St=wt.webkitMatchesSelector||wt.msMatchesSelector||wt.mozMatchesSelector||wt.oMatchesSelector;yt=function(t){return function(){return St.call(this,t)}}}}var kt=yt,_t=function(t){return new Array(t.length)};function Mt(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Mt.prototype={constructor:Mt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var Ct="$";function Et(t,e,n,i,o,a){for(var s,r=0,l=e.length,h=a.length;r<h;++r)(s=e[r])?(s.__data__=a[r],i[r]=s):n[r]=new Mt(t,a[r]);for(;r<l;++r)(s=e[r])&&(o[r]=s)}function xt(t,e,n,i,o,a,s){var r,l,h,c={},d=e.length,u=a.length,p=new Array(d);for(r=0;r<d;++r)(l=e[r])&&(p[r]=h=Ct+s.call(l,l.__data__,r,e),h in c?o[r]=l:c[h]=l);for(r=0;r<u;++r)(l=c[h=Ct+s.call(t,a[r],r,a)])?(i[r]=l,l.__data__=a[r],c[h]=null):n[r]=new Mt(t,a[r]);for(r=0;r<d;++r)(l=e[r])&&c[p[r]]===l&&(o[r]=l)}function It(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}var Nt=function(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView};function Tt(t,e){return t.style.getPropertyValue(e)||Nt(t).getComputedStyle(t,null).getPropertyValue(e)}function Dt(t){return t.trim().split(/^|\s+/)}function At(t){return t.classList||new Rt(t)}function Rt(t){this._node=t,this._names=Dt(t.getAttribute("class")||"")}function Pt(t,e){for(var n=At(t),i=-1,o=e.length;++i<o;)n.add(e[i])}function Lt(t,e){for(var n=At(t),i=-1,o=e.length;++i<o;)n.remove(e[i])}Rt.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Bt(){this.textContent=""}function Wt(){this.innerHTML=""}function Gt(){this.nextSibling&&this.parentNode.appendChild(this)}function zt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ut(){return null}function jt(){var t=this.parentNode;t&&t.removeChild(this)}function Ht(){return this.parentNode.insertBefore(this.cloneNode(!1),this.nextSibling)}function Ft(){return this.parentNode.insertBefore(this.cloneNode(!0),this.nextSibling)}var Ot={},qt=null;"undefined"!=typeof document&&("onmouseenter"in document.documentElement||(Ot={mouseenter:"mouseover",mouseleave:"mouseout"}));function Jt(t,e,n){return t=Vt(t,e,n),function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t.call(this,e)}}function Vt(t,e,n){return function(i){var o=qt;qt=i;try{t.call(this,this.__data__,e,n)}finally{qt=o}}}function Kt(t){return function(){var e=this.__on;if(e){for(var n,i=0,o=-1,a=e.length;i<a;++i)n=e[i],t.type&&n.type!==t.type||n.name!==t.name?e[++o]=n:this.removeEventListener(n.type,n.listener,n.capture);++o?e.length=o:delete this.__on}}}function Yt(t,e,n){var i=Ot.hasOwnProperty(t.type)?Jt:Vt;return function(o,a,s){var r,l=this.__on,h=i(e,a,s);if(l)for(var c=0,d=l.length;c<d;++c)if((r=l[c]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.capture),this.addEventListener(r.type,r.listener=h,r.capture=n),void(r.value=e);this.addEventListener(t.type,h,n),r={type:t.type,name:t.name,value:e,listener:h,capture:n},l?l.push(r):this.__on=[r]}}function $t(t,e,n,i){var o=qt;t.sourceEvent=qt,qt=t;try{return e.apply(n,i)}finally{qt=o}}function Qt(t,e,n){var i=Nt(t),o=i.CustomEvent;"function"==typeof o?o=new o(e,n):(o=i.document.createEvent("Event"),n?(o.initEvent(e,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(e,!1,!1)),t.dispatchEvent(o)}var Xt=[null];function Zt(t,e){this._groups=t,this._parents=e}function te(){return new Zt([[document.documentElement]],Xt)}Zt.prototype=te.prototype={constructor:Zt,select:function(t){"function"!=typeof t&&(t=ft(t));for(var e=this._groups,n=e.length,i=new Array(n),o=0;o<n;++o)for(var a,s,r=e[o],l=r.length,h=i[o]=new Array(l),c=0;c<l;++c)(a=r[c])&&(s=t.call(a,a.__data__,c,r))&&("__data__"in a&&(s.__data__=a.__data__),h[c]=s);return new Zt(i,this._parents)},selectAll:function(t){"function"!=typeof t&&(t=bt(t));for(var e=this._groups,n=e.length,i=[],o=[],a=0;a<n;++a)for(var s,r=e[a],l=r.length,h=0;h<l;++h)(s=r[h])&&(i.push(t.call(s,s.__data__,h,r)),o.push(s));return new Zt(i,o)},filter:function(t){"function"!=typeof t&&(t=kt(t));for(var e=this._groups,n=e.length,i=new Array(n),o=0;o<n;++o)for(var a,s=e[o],r=s.length,l=i[o]=[],h=0;h<r;++h)(a=s[h])&&t.call(a,a.__data__,h,s)&&l.push(a);return new Zt(i,this._parents)},data:function(t,e){if(!t)return m=new Array(this.size()),c=-1,this.each(function(t){m[++c]=t}),m;var n,i=e?xt:Et,o=this._parents,a=this._groups;"function"!=typeof t&&(n=t,t=function(){return n});for(var s=a.length,r=new Array(s),l=new Array(s),h=new Array(s),c=0;c<s;++c){var d=o[c],u=a[c],p=u.length,m=t.call(d,d&&d.__data__,c,o),g=m.length,f=l[c]=new Array(g),v=r[c]=new Array(g);i(d,u,f,v,h[c]=new Array(p),m,e);for(var b,y,w=0,S=0;w<g;++w)if(b=f[w]){for(w>=S&&(S=w+1);!(y=v[S])&&++S<g;);b._next=y||null}}return(r=new Zt(r,o))._enter=l,r._exit=h,r},enter:function(){return new Zt(this._enter||this._groups.map(_t),this._parents)},exit:function(){return new Zt(this._exit||this._groups.map(_t),this._parents)},merge:function(t){for(var e=this._groups,n=t._groups,i=e.length,o=n.length,a=Math.min(i,o),s=new Array(i),r=0;r<a;++r)for(var l,h=e[r],c=n[r],d=h.length,u=s[r]=new Array(d),p=0;p<d;++p)(l=h[p]||c[p])&&(u[p]=l);for(;r<i;++r)s[r]=e[r];return new Zt(s,this._parents)},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var i,o=t[e],a=o.length-1,s=o[a];--a>=0;)(i=o[a])&&(s&&s!==i.nextSibling&&s.parentNode.insertBefore(i,s),s=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=It);for(var n=this._groups,i=n.length,o=new Array(i),a=0;a<i;++a){for(var s,r=n[a],l=r.length,h=o[a]=new Array(l),c=0;c<l;++c)(s=r[c])&&(h[c]=s);h.sort(e)}return new Zt(o,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){var t=new Array(this.size()),e=-1;return this.each(function(){t[++e]=this}),t},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var i=t[e],o=0,a=i.length;o<a;++o){var s=i[o];if(s)return s}return null},size:function(){var t=0;return this.each(function(){++t}),t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o,a=e[n],s=0,r=a.length;s<r;++s)(o=a[s])&&t.call(o,o.__data__,s,a);return this},attr:function(t,e){var n=pt(t);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((null==e?n.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}}:"function"==typeof e?n.local?function(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}:function(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}:n.local?function(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}:function(t,e){return function(){this.setAttribute(t,e)}})(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?function(t){return function(){this.style.removeProperty(t)}}:"function"==typeof e?function(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}:function(t,e,n){return function(){this.style.setProperty(t,e,n)}})(t,e,null==n?"":n)):Tt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?function(t){return function(){delete this[t]}}:"function"==typeof e?function(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}:function(t,e){return function(){this[t]=e}})(t,e)):this.node()[t]},classed:function(t,e){var n=Dt(t+"");if(arguments.length<2){for(var i=At(this.node()),o=-1,a=n.length;++o<a;)if(!i.contains(n[o]))return!1;return!0}return this.each(("function"==typeof e?function(t,e){return function(){(e.apply(this,arguments)?Pt:Lt)(this,t)}}:e?function(t){return function(){Pt(this,t)}}:function(t){return function(){Lt(this,t)}})(n,e))},text:function(t){return arguments.length?this.each(null==t?Bt:("function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}:function(t){return function(){this.textContent=t}})(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Wt:("function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}:function(t){return function(){this.innerHTML=t}})(t)):this.node().innerHTML},raise:function(){return this.each(Gt)},lower:function(){return this.each(zt)},append:function(t){var e="function"==typeof t?t:mt(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var n="function"==typeof t?t:mt(t),i=null==e?Ut:"function"==typeof e?e:ft(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})},remove:function(){return this.each(jt)},clone:function(t){return this.select(t?Ft:Ht)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var i,o,a=function(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),s=a.length;if(!(arguments.length<2)){for(r=e?Yt:Kt,null==n&&(n=!1),i=0;i<s;++i)this.each(r(a[i],e,n));return this}var r=this.node().__on;if(r)for(var l,h=0,c=r.length;h<c;++h)for(i=0,l=r[h];i<s;++i)if((o=a[i]).type===l.type&&o.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?function(t,e){return function(){return Qt(this,t,e.apply(this,arguments))}}:function(t,e){return function(){return Qt(this,t,e)}})(t,e))}};var ee=te,ne=function(t){return"string"==typeof t?new Zt([[document.querySelector(t)]],[document.documentElement]):new Zt([[t]],Xt)},ie=0;function oe(){this._="@"+(++ie).toString(36)}oe.prototype=function(){return new oe}.prototype={constructor:oe,get:function(t){for(var e=this._;!(e in t);)if(!(t=t.parentNode))return;return t[e]},set:function(t,e){return t[this._]=e},remove:function(t){return this._ in t&&delete t[this._]},toString:function(){return this._}};var ae=function(){for(var t,e=qt;t=e.sourceEvent;)e=t;return e},se=function(t,e){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,[(i=i.matrixTransform(t.getScreenCTM().inverse())).x,i.y]}var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]},re=function(t){var e=ae();return e.changedTouches&&(e=e.changedTouches[0]),se(t,e)},le=function(t,e,n){arguments.length<3&&(n=e,e=ae().changedTouches);for(var i,o=0,a=e?e.length:0;o<a;++o)if((i=e[o]).identifier===n)return se(t,i);return null},he={value:function(){}};function ce(){for(var t,e=0,n=arguments.length,i={};e<n;++e){if(!(t=arguments[e]+"")||t in i)throw new Error("illegal type: "+t);i[t]=[]}return new de(i)}function de(t){this._=t}function ue(t,e){for(var n,i=0,o=t.length;i<o;++i)if((n=t[i]).name===e)return n.value}function pe(t,e,n){for(var i=0,o=t.length;i<o;++i)if(t[i].name===e){t[i]=he,t=t.slice(0,i).concat(t.slice(i+1));break}return null!=n&&t.push({name:e,value:n}),t}de.prototype=ce.prototype={constructor:de,on:function(t,e){var n,i,o=this._,a=(i=o,(t+"").trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!i.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),s=-1,r=a.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<r;)if(n=(t=a[s]).type)o[n]=pe(o[n],t.name,e);else if(null==e)for(n in o)o[n]=pe(o[n],t.name,null);return this}for(;++s<r;)if((n=(t=a[s]).type)&&(n=ue(o[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new de(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,i,o=new Array(n),a=0;a<n;++a)o[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(i=this._[t]).length;a<n;++a)i[a].value.apply(e,o)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],o=0,a=i.length;o<a;++o)i[o].value.apply(e,n)}};var me=ce;function ge(){qt.stopImmediatePropagation()}var fe=function(){qt.preventDefault(),qt.stopImmediatePropagation()},ve=function(t){var e=t.document.documentElement,n=ne(t).on("dragstart.drag",fe,!0);"onselectstart"in e?n.on("selectstart.drag",fe,!0):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")};function be(t,e){var n=t.document.documentElement,i=ne(t).on("dragstart.drag",null);e&&(i.on("click.drag",fe,!0),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var ye=function(t){return function(){return t}};function we(t,e,n,i,o,a,s,r,l,h){this.target=t,this.type=e,this.subject=n,this.identifier=i,this.active=o,this.x=a,this.y=s,this.dx=r,this.dy=l,this._=h}function Se(){return!qt.button}function ke(){return this.parentNode}function _e(t){return null==t?{x:qt.x,y:qt.y}:t}function Me(){return"ontouchstart"in this}we.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var Ce=function(){var t,e,n,i,o=Se,a=ke,s=_e,r=Me,l={},h=me("start","drag","end"),c=0,d=0;function u(t){t.on("mousedown.drag",p).filter(r).on("touchstart.drag",f).on("touchmove.drag",v).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(){if(!i&&o.apply(this,arguments)){var s=y("mouse",a.apply(this,arguments),re,this,arguments);s&&(ne(qt.view).on("mousemove.drag",m,!0).on("mouseup.drag",g,!0),ve(qt.view),ge(),n=!1,t=qt.clientX,e=qt.clientY,s("start"))}}function m(){if(fe(),!n){var i=qt.clientX-t,o=qt.clientY-e;n=i*i+o*o>d}l.mouse("drag")}function g(){ne(qt.view).on("mousemove.drag mouseup.drag",null),be(qt.view,n),fe(),l.mouse("end")}function f(){if(o.apply(this,arguments)){var t,e,n=qt.changedTouches,i=a.apply(this,arguments),s=n.length;for(t=0;t<s;++t)(e=y(n[t].identifier,i,le,this,arguments))&&(ge(),e("start"))}}function v(){var t,e,n=qt.changedTouches,i=n.length;for(t=0;t<i;++t)(e=l[n[t].identifier])&&(fe(),e("drag"))}function b(){var t,e,n=qt.changedTouches,o=n.length;for(i&&clearTimeout(i),i=setTimeout(function(){i=null},500),t=0;t<o;++t)(e=l[n[t].identifier])&&(ge(),e("end"))}function y(t,e,n,i,o){var a,r,d,p=n(e,t),m=h.copy();if($t(new we(u,"beforestart",a,t,c,p[0],p[1],0,0,m),function(){return null!=(qt.subject=a=s.apply(i,o))&&(r=a.x-p[0]||0,d=a.y-p[1]||0,!0)}))return function s(h){var g,f=p;switch(h){case"start":l[t]=s,g=c++;break;case"end":delete l[t],--c;case"drag":p=n(e,t),g=c}$t(new we(u,h,a,t,g,p[0]+r,p[1]+d,p[0]-f[0],p[1]-f[1],m),m.apply,m,[h,i,o])}}return u.filter=function(t){return arguments.length?(o="function"==typeof t?t:ye(!!t),u):o},u.container=function(t){return arguments.length?(a="function"==typeof t?t:ye(t),u):a},u.subject=function(t){return arguments.length?(s="function"==typeof t?t:ye(t),u):s},u.touchable=function(t){return arguments.length?(r="function"==typeof t?t:ye(!!t),u):r},u.on=function(){var t=h.on.apply(h,arguments);return t===h?u:t},u.clickDistance=function(t){return arguments.length?(d=(t=+t)*t,u):Math.sqrt(d)},u},Ee=function(t,e,n){t.prototype=e.prototype=n,n.constructor=t};function xe(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function Ie(){}var Ne="\\s*([+-]?\\d+)\\s*",Te="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",De="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ae=/^#([0-9a-f]{3})$/,Re=/^#([0-9a-f]{6})$/,Pe=new RegExp("^rgb\\("+[Ne,Ne,Ne]+"\\)$"),Le=new RegExp("^rgb\\("+[De,De,De]+"\\)$"),Be=new RegExp("^rgba\\("+[Ne,Ne,Ne,Te]+"\\)$"),We=new RegExp("^rgba\\("+[De,De,De,Te]+"\\)$"),Ge=new RegExp("^hsl\\("+[Te,De,De]+"\\)$"),ze=new RegExp("^hsla\\("+[Te,De,De,Te]+"\\)$"),Ue={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function je(t){var e;return t=(t+"").trim().toLowerCase(),(e=Ae.exec(t))?new Je((e=parseInt(e[1],16))>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):(e=Re.exec(t))?He(parseInt(e[1],16)):(e=Pe.exec(t))?new Je(e[1],e[2],e[3],1):(e=Le.exec(t))?new Je(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Be.exec(t))?Fe(e[1],e[2],e[3],e[4]):(e=We.exec(t))?Fe(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Ge.exec(t))?Ke(e[1],e[2]/100,e[3]/100,1):(e=ze.exec(t))?Ke(e[1],e[2]/100,e[3]/100,e[4]):Ue.hasOwnProperty(t)?He(Ue[t]):"transparent"===t?new Je(NaN,NaN,NaN,0):null}function He(t){return new Je(t>>16&255,t>>8&255,255&t,1)}function Fe(t,e,n,i){return i<=0&&(t=e=n=NaN),new Je(t,e,n,i)}function Oe(t){return t instanceof Ie||(t=je(t)),t?new Je((t=t.rgb()).r,t.g,t.b,t.opacity):new Je}function qe(t,e,n,i){return 1===arguments.length?Oe(t):new Je(t,e,n,null==i?1:i)}function Je(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function Ve(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Ke(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new $e(t,e,n,i)}function Ye(t,e,n,i){return 1===arguments.length?function(t){if(t instanceof $e)return new $e(t.h,t.s,t.l,t.opacity);if(t instanceof Ie||(t=je(t)),!t)return new $e;if(t instanceof $e)return t;var e=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,o=Math.min(e,n,i),a=Math.max(e,n,i),s=NaN,r=a-o,l=(a+o)/2;return r?(s=e===a?(n-i)/r+6*(n<i):n===a?(i-e)/r+2:(e-n)/r+4,r/=l<.5?a+o:2-a-o,s*=60):r=l>0&&l<1?0:s,new $e(s,r,l,t.opacity)}(t):new $e(t,e,n,null==i?1:i)}function $e(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function Qe(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Ee(Ie,je,{displayable:function(){return this.rgb().displayable()},hex:function(){return this.rgb().hex()},toString:function(){return this.rgb()+""}}),Ee(Je,qe,xe(Ie,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new Je(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new Je(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},hex:function(){return"#"+Ve(this.r)+Ve(this.g)+Ve(this.b)},toString:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}})),Ee($e,Ye,xe(Ie,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new $e(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new $e(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,o=2*n-i;return new Je(Qe(t>=240?t-240:t+120,o,i),Qe(t,o,i),Qe(t<120?t+240:t-120,o,i),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1}}));var Xe=Math.PI/180,Ze=180/Math.PI,tn=.96422,en=1,nn=.82521,on=4/29,an=6/29,sn=3*an*an,rn=an*an*an;function ln(t){if(t instanceof cn)return new cn(t.l,t.a,t.b,t.opacity);if(t instanceof vn){if(isNaN(t.h))return new cn(t.l,0,0,t.opacity);var e=t.h*Xe;return new cn(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}t instanceof Je||(t=Oe(t));var n,i,o=mn(t.r),a=mn(t.g),s=mn(t.b),r=dn((.2225045*o+.7168786*a+.0606169*s)/en);return o===a&&a===s?n=i=r:(n=dn((.4360747*o+.3850649*a+.1430804*s)/tn),i=dn((.0139322*o+.0971045*a+.7141733*s)/nn)),new cn(116*r-16,500*(n-r),200*(r-i),t.opacity)}function hn(t,e,n,i){return 1===arguments.length?ln(t):new cn(t,e,n,null==i?1:i)}function cn(t,e,n,i){this.l=+t,this.a=+e,this.b=+n,this.opacity=+i}function dn(t){return t>rn?Math.pow(t,1/3):t/sn+on}function un(t){return t>an?t*t*t:sn*(t-on)}function pn(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function mn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function gn(t){if(t instanceof vn)return new vn(t.h,t.c,t.l,t.opacity);if(t instanceof cn||(t=ln(t)),0===t.a&&0===t.b)return new vn(NaN,0,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*Ze;return new vn(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function fn(t,e,n,i){return 1===arguments.length?gn(t):new vn(t,e,n,null==i?1:i)}function vn(t,e,n,i){this.h=+t,this.c=+e,this.l=+n,this.opacity=+i}Ee(cn,hn,xe(Ie,{brighter:function(t){return new cn(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new cn(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return new Je(pn(3.1338561*(e=tn*un(e))-1.6168667*(t=en*un(t))-.4906146*(n=nn*un(n))),pn(-.9787684*e+1.9161415*t+.033454*n),pn(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}})),Ee(vn,fn,xe(Ie,{brighter:function(t){return new vn(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new vn(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return ln(this).rgb()}}));var bn=-.14861,yn=1.78277,wn=-.29227,Sn=-.90649,kn=1.97294,_n=kn*Sn,Mn=kn*yn,Cn=yn*wn-Sn*bn;function En(t,e,n,i){return 1===arguments.length?function(t){if(t instanceof xn)return new xn(t.h,t.s,t.l,t.opacity);t instanceof Je||(t=Oe(t));var e=t.r/255,n=t.g/255,i=t.b/255,o=(Cn*i+_n*e-Mn*n)/(Cn+_n-Mn),a=i-o,s=(kn*(n-o)-wn*a)/Sn,r=Math.sqrt(s*s+a*a)/(kn*o*(1-o)),l=r?Math.atan2(s,a)*Ze-120:NaN;return new xn(l<0?l+360:l,r,o,t.opacity)}(t):new xn(t,e,n,null==i?1:i)}function xn(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function In(t,e,n,i,o){var a=t*t,s=a*t;return((1-3*t+3*a-s)*e+(4-6*a+3*s)*n+(1+3*t+3*a-3*s)*i+s*o)/6}Ee(xn,En,xe(Ie,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new xn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new xn(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*Xe,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),i=Math.cos(t),o=Math.sin(t);return new Je(255*(e+n*(bn*i+yn*o)),255*(e+n*(wn*i+Sn*o)),255*(e+n*(kn*i)),this.opacity)}}));var Nn=function(t){return function(){return t}};function Tn(t,e){return function(n){return t+n*e}}function Dn(t,e){var n=e-t;return n?Tn(t,n>180||n<-180?n-360*Math.round(n/360):n):Nn(isNaN(t)?e:t)}function An(t){return 1==(t=+t)?Rn:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}(e,n,t):Nn(isNaN(e)?n:e)}}function Rn(t,e){var n=e-t;return n?Tn(t,n):Nn(isNaN(t)?e:t)}var Pn=function t(e){var n=An(e);function i(t,e){var i=n((t=qe(t)).r,(e=qe(e)).r),o=n(t.g,e.g),a=n(t.b,e.b),s=Rn(t.opacity,e.opacity);return function(e){return t.r=i(e),t.g=o(e),t.b=a(e),t.opacity=s(e),t+""}}return i.gamma=t,i}(1);function Ln(t){return function(e){var n,i,o=e.length,a=new Array(o),s=new Array(o),r=new Array(o);for(n=0;n<o;++n)i=qe(e[n]),a[n]=i.r||0,s[n]=i.g||0,r[n]=i.b||0;return a=t(a),s=t(s),r=t(r),i.opacity=1,function(t){return i.r=a(t),i.g=s(t),i.b=r(t),i+""}}}Ln(function(t){var e=t.length-1;return function(n){var i=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),o=t[i],a=t[i+1],s=i>0?t[i-1]:2*o-a,r=i<e-1?t[i+2]:2*a-o;return In((n-i/e)*e,s,o,a,r)}}),Ln(function(t){var e=t.length;return function(n){var i=Math.floor(((n%=1)<0?++n:n)*e),o=t[(i+e-1)%e],a=t[i%e],s=t[(i+1)%e],r=t[(i+2)%e];return In((n-i/e)*e,o,a,s,r)}});var Bn=function(t,e){return e-=t=+t,function(n){return t+e*n}},Wn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Gn=new RegExp(Wn.source,"g");var zn,Un,jn,Hn,Fn=function(t,e){var n,i,o,a=Wn.lastIndex=Gn.lastIndex=0,s=-1,r=[],l=[];for(t+="",e+="";(n=Wn.exec(t))&&(i=Gn.exec(e));)(o=i.index)>a&&(o=e.slice(a,o),r[s]?r[s]+=o:r[++s]=o),(n=n[0])===(i=i[0])?r[s]?r[s]+=i:r[++s]=i:(r[++s]=null,l.push({i:s,x:Bn(n,i)})),a=Gn.lastIndex;return a<e.length&&(o=e.slice(a),r[s]?r[s]+=o:r[++s]=o),r.length<2?l[0]?function(t){return function(e){return t(e)+""}}(l[0].x):function(t){return function(){return t}}(e):(e=l.length,function(t){for(var n,i=0;i<e;++i)r[(n=l[i]).i]=n.x(t);return r.join("")})},On=180/Math.PI,qn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1},Jn=function(t,e,n,i,o,a){var s,r,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*n+e*i)&&(n-=t*l,i-=e*l),(r=Math.sqrt(n*n+i*i))&&(n/=r,i/=r,l/=r),t*i<e*n&&(t=-t,e=-e,l=-l,s=-s),{translateX:o,translateY:a,rotate:Math.atan2(e,t)*On,skewX:Math.atan(l)*On,scaleX:s,scaleY:r}};function Vn(t,e,n,i){function o(t){return t.length?t.pop()+" ":""}return function(a,s){var r=[],l=[];return a=t(a),s=t(s),function(t,i,o,a,s,r){if(t!==o||i!==a){var l=s.push("translate(",null,e,null,n);r.push({i:l-4,x:Bn(t,o)},{i:l-2,x:Bn(i,a)})}else(o||a)&&s.push("translate("+o+e+a+n)}(a.translateX,a.translateY,s.translateX,s.translateY,r,l),function(t,e,n,a){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(o(n)+"rotate(",null,i)-2,x:Bn(t,e)})):e&&n.push(o(n)+"rotate("+e+i)}(a.rotate,s.rotate,r,l),function(t,e,n,a){t!==e?a.push({i:n.push(o(n)+"skewX(",null,i)-2,x:Bn(t,e)}):e&&n.push(o(n)+"skewX("+e+i)}(a.skewX,s.skewX,r,l),function(t,e,n,i,a,s){if(t!==n||e!==i){var r=a.push(o(a)+"scale(",null,",",null,")");s.push({i:r-4,x:Bn(t,n)},{i:r-2,x:Bn(e,i)})}else 1===n&&1===i||a.push(o(a)+"scale("+n+","+i+")")}(a.scaleX,a.scaleY,s.scaleX,s.scaleY,r,l),a=s=null,function(t){for(var e,n=-1,i=l.length;++n<i;)r[(e=l[n]).i]=e.x(t);return r.join("")}}}var Kn=Vn(function(t){return"none"===t?qn:(zn||(zn=document.createElement("DIV"),Un=document.documentElement,jn=document.defaultView),zn.style.transform=t,t=jn.getComputedStyle(Un.appendChild(zn),null).getPropertyValue("transform"),Un.removeChild(zn),t=t.slice(7,-1).split(","),Jn(+t[0],+t[1],+t[2],+t[3],+t[4],+t[5]))},"px, ","px)","deg)"),Yn=Vn(function(t){return null==t?qn:(Hn||(Hn=document.createElementNS("http://www.w3.org/2000/svg","g")),Hn.setAttribute("transform",t),(t=Hn.transform.baseVal.consolidate())?(t=t.matrix,Jn(t.a,t.b,t.c,t.d,t.e,t.f)):qn)},", ",")",")"),$n=Math.SQRT2;function Qn(t){return((t=Math.exp(t))+1/t)/2}var Xn=function(t,e){var n,i,o=t[0],a=t[1],s=t[2],r=e[0],l=e[1],h=e[2],c=r-o,d=l-a,u=c*c+d*d;if(u<1e-12)i=Math.log(h/s)/$n,n=function(t){return[o+t*c,a+t*d,s*Math.exp($n*t*i)]};else{var p=Math.sqrt(u),m=(h*h-s*s+4*u)/(2*s*2*p),g=(h*h-s*s-4*u)/(2*h*2*p),f=Math.log(Math.sqrt(m*m+1)-m),v=Math.log(Math.sqrt(g*g+1)-g);i=(v-f)/$n,n=function(t){var e,n=t*i,r=Qn(f),l=s/(2*p)*(r*(e=$n*n+f,((e=Math.exp(2*e))-1)/(e+1))-function(t){return((t=Math.exp(t))-1/t)/2}(f));return[o+l*c,a+l*d,s*r/Qn($n*n+f)]}}return n.duration=1e3*i,n};function Zn(t){return function(e,n){var i=t((e=Ye(e)).h,(n=Ye(n)).h),o=Rn(e.s,n.s),a=Rn(e.l,n.l),s=Rn(e.opacity,n.opacity);return function(t){return e.h=i(t),e.s=o(t),e.l=a(t),e.opacity=s(t),e+""}}}Zn(Dn),Zn(Rn);function ti(t){return function(e,n){var i=t((e=fn(e)).h,(n=fn(n)).h),o=Rn(e.c,n.c),a=Rn(e.l,n.l),s=Rn(e.opacity,n.opacity);return function(t){return e.h=i(t),e.c=o(t),e.l=a(t),e.opacity=s(t),e+""}}}ti(Dn),ti(Rn);function ei(t){return function e(n){function i(e,i){var o=t((e=En(e)).h,(i=En(i)).h),a=Rn(e.s,i.s),s=Rn(e.l,i.l),r=Rn(e.opacity,i.opacity);return function(t){return e.h=o(t),e.s=a(t),e.l=s(Math.pow(t,n)),e.opacity=r(t),e+""}}return n=+n,i.gamma=e,i}(1)}ei(Dn),ei(Rn);var ni,ii,oi=0,ai=0,si=0,ri=1e3,li=0,hi=0,ci=0,di="object"==typeof performance&&performance.now?performance:Date,ui="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function pi(){return hi||(ui(mi),hi=di.now()+ci)}function mi(){hi=0}function gi(){this._call=this._time=this._next=null}function fi(t,e,n){var i=new gi;return i.restart(t,e,n),i}function vi(){hi=(li=di.now())+ci,oi=ai=0;try{!function(){pi(),++oi;for(var t,e=ni;e;)(t=hi-e._time)>=0&&e._call.call(null,t),e=e._next;--oi}()}finally{oi=0,function(){var t,e,n=ni,i=1/0;for(;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:ni=e);ii=t,yi(i)}(),hi=0}}function bi(){var t=di.now(),e=t-li;e>ri&&(ci-=e,li=t)}function yi(t){oi||(ai&&(ai=clearTimeout(ai)),t-hi>24?(t<1/0&&(ai=setTimeout(vi,t-di.now()-ci)),si&&(si=clearInterval(si))):(si||(li=di.now(),si=setInterval(bi,ri)),oi=1,ui(vi)))}gi.prototype=fi.prototype={constructor:gi,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?pi():+n)+(null==e?0:+e),this._next||ii===this||(ii?ii._next=this:ni=this,ii=this),this._call=t,this._time=n,yi()},stop:function(){this._call&&(this._call=null,this._time=1/0,yi())}};var wi=function(t,e,n){var i=new gi;return e=null==e?0:+e,i.restart(function(n){i.stop(),t(n+e)},e,n),i},Si=me("start","end","interrupt"),ki=[],_i=0,Mi=1,Ci=2,Ei=3,xi=4,Ii=5,Ni=6,Ti=function(t,e,n,i,o,a){var s=t.__transition;if(s){if(n in s)return}else t.__transition={};!function(t,e,n){var i,o=t.__transition;function a(l){var h,c,d,u;if(n.state!==Mi)return r();for(h in o)if((u=o[h]).name===n.name){if(u.state===Ei)return wi(a);u.state===xi?(u.state=Ni,u.timer.stop(),u.on.call("interrupt",t,t.__data__,u.index,u.group),delete o[h]):+h<e&&(u.state=Ni,u.timer.stop(),delete o[h])}if(wi(function(){n.state===Ei&&(n.state=xi,n.timer.restart(s,n.delay,n.time),s(l))}),n.state=Ci,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Ci){for(n.state=Ei,i=new Array(d=n.tween.length),h=0,c=-1;h<d;++h)(u=n.tween[h].value.call(t,t.__data__,n.index,n.group))&&(i[++c]=u);i.length=c+1}}function s(e){for(var o=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(r),n.state=Ii,1),a=-1,s=i.length;++a<s;)i[a].call(null,o);n.state===Ii&&(n.on.call("end",t,t.__data__,n.index,n.group),r())}function r(){for(var i in n.state=Ni,n.timer.stop(),delete o[e],o)return;delete t.__transition}o[e]=n,n.timer=fi(function(t){n.state=Mi,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)},0,n.time)}(t,n,{name:e,index:i,group:o,on:Si,tween:ki,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:_i})};function Di(t,e){var n=Ri(t,e);if(n.state>_i)throw new Error("too late; already scheduled");return n}function Ai(t,e){var n=Ri(t,e);if(n.state>Ci)throw new Error("too late; already started");return n}function Ri(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}var Pi=function(t,e){var n,i,o,a=t.__transition,s=!0;if(a){for(o in e=null==e?null:e+"",a)(n=a[o]).name===e?(i=n.state>Ci&&n.state<Ii,n.state=Ni,n.timer.stop(),i&&n.on.call("interrupt",t,t.__data__,n.index,n.group),delete a[o]):s=!1;s&&delete t.__transition}};function Li(t,e,n){var i=t._id;return t.each(function(){var t=Ai(this,i);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return Ri(t,i).value[e]}}var Bi=function(t,e){var n;return("number"==typeof e?Bn:e instanceof je?Pn:(n=je(e))?(e=n,Pn):Fn)(t,e)};var Wi=ee.prototype.constructor;var Gi=0;function zi(t,e,n,i){this._groups=t,this._parents=e,this._name=n,this._id=i}function Ui(){return++Gi}var ji=ee.prototype;zi.prototype=function(t){return ee().transition(t)}.prototype={constructor:zi,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=ft(t));for(var i=this._groups,o=i.length,a=new Array(o),s=0;s<o;++s)for(var r,l,h=i[s],c=h.length,d=a[s]=new Array(c),u=0;u<c;++u)(r=h[u])&&(l=t.call(r,r.__data__,u,h))&&("__data__"in r&&(l.__data__=r.__data__),d[u]=l,Ti(d[u],e,n,u,d,Ri(r,n)));return new zi(a,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=bt(t));for(var i=this._groups,o=i.length,a=[],s=[],r=0;r<o;++r)for(var l,h=i[r],c=h.length,d=0;d<c;++d)if(l=h[d]){for(var u,p=t.call(l,l.__data__,d,h),m=Ri(l,n),g=0,f=p.length;g<f;++g)(u=p[g])&&Ti(u,e,n,g,p,m);a.push(p),s.push(l)}return new zi(a,s,e,n)},filter:function(t){"function"!=typeof t&&(t=kt(t));for(var e=this._groups,n=e.length,i=new Array(n),o=0;o<n;++o)for(var a,s=e[o],r=s.length,l=i[o]=[],h=0;h<r;++h)(a=s[h])&&t.call(a,a.__data__,h,s)&&l.push(a);return new zi(i,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,i=e.length,o=n.length,a=Math.min(i,o),s=new Array(i),r=0;r<a;++r)for(var l,h=e[r],c=n[r],d=h.length,u=s[r]=new Array(d),p=0;p<d;++p)(l=h[p]||c[p])&&(u[p]=l);for(;r<i;++r)s[r]=e[r];return new zi(s,this._parents,this._name,this._id)},selection:function(){return new Wi(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Ui(),i=this._groups,o=i.length,a=0;a<o;++a)for(var s,r=i[a],l=r.length,h=0;h<l;++h)if(s=r[h]){var c=Ri(s,e);Ti(s,t,n,h,r,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new zi(i,this._parents,t,n)},call:ji.call,nodes:ji.nodes,node:ji.node,size:ji.size,empty:ji.empty,each:ji.each,on:function(t,e){var n=this._id;return arguments.length<2?Ri(this.node(),n).on.on(t):this.each(function(t,e,n){var i,o,a=function(t){return(t+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?Di:Ai;return function(){var s=a(this,t),r=s.on;r!==i&&(o=(i=r).copy()).on(e,n),s.on=o}}(n,t,e))},attr:function(t,e){var n=pt(t),i="transform"===n?Yn:Bi;return this.attrTween(t,"function"==typeof e?(n.local?function(t,e,n){var i,o,a;return function(){var s,r=n(this);if(null!=r)return(s=this.getAttributeNS(t.space,t.local))===r?null:s===i&&r===o?a:a=e(i=s,o=r);this.removeAttributeNS(t.space,t.local)}}:function(t,e,n){var i,o,a;return function(){var s,r=n(this);if(null!=r)return(s=this.getAttribute(t))===r?null:s===i&&r===o?a:a=e(i=s,o=r);this.removeAttribute(t)}})(n,i,Li(this,"attr."+t,e)):null==e?(n.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}})(n):(n.local?function(t,e,n){var i,o;return function(){var a=this.getAttributeNS(t.space,t.local);return a===n?null:a===i?o:o=e(i=a,n)}}:function(t,e,n){var i,o;return function(){var a=this.getAttribute(t);return a===n?null:a===i?o:o=e(i=a,n)}})(n,i,e+""))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var i=pt(t);return this.tween(n,(i.local?function(t,e){function n(){var n=this,i=e.apply(n,arguments);return i&&function(e){n.setAttributeNS(t.space,t.local,i(e))}}return n._value=e,n}:function(t,e){function n(){var n=this,i=e.apply(n,arguments);return i&&function(e){n.setAttribute(t,i(e))}}return n._value=e,n})(i,e))},style:function(t,e,n){var i="transform"==(t+="")?Kn:Bi;return null==e?this.styleTween(t,function(t,e){var n,i,o;return function(){var a=Tt(this,t),s=(this.style.removeProperty(t),Tt(this,t));return a===s?null:a===n&&s===i?o:o=e(n=a,i=s)}}(t,i)).on("end.style."+t,function(t){return function(){this.style.removeProperty(t)}}(t)):this.styleTween(t,"function"==typeof e?function(t,e,n){var i,o,a;return function(){var s=Tt(this,t),r=n(this);return null==r&&(this.style.removeProperty(t),r=Tt(this,t)),s===r?null:s===i&&r===o?a:a=e(i=s,o=r)}}(t,i,Li(this,"style."+t,e)):function(t,e,n){var i,o;return function(){var a=Tt(this,t);return a===n?null:a===i?o:o=e(i=a,n)}}(t,i,e+""),n)},styleTween:function(t,e,n){var i="style."+(t+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(null==e)return this.tween(i,null);if("function"!=typeof e)throw new Error;return this.tween(i,function(t,e,n){function i(){var i=this,o=e.apply(i,arguments);return o&&function(e){i.style.setProperty(t,o(e),n)}}return i._value=e,i}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Li(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},remove:function(){return this.on("end.remove",(t=this._id,function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}));var t},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var i,o=Ri(this.node(),n).tween,a=0,s=o.length;a<s;++a)if((i=o[a]).name===t)return i.value;return null}return this.each((null==e?function(t,e){var n,i;return function(){var o=Ai(this,t),a=o.tween;if(a!==n)for(var s=0,r=(i=n=a).length;s<r;++s)if(i[s].name===e){(i=i.slice()).splice(s,1);break}o.tween=i}}:function(t,e,n){var i,o;if("function"!=typeof n)throw new Error;return function(){var a=Ai(this,t),s=a.tween;if(s!==i){o=(i=s).slice();for(var r={name:e,value:n},l=0,h=o.length;l<h;++l)if(o[l].name===e){o[l]=r;break}l===h&&o.push(r)}a.tween=o}})(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?function(t,e){return function(){Di(this,t).delay=+e.apply(this,arguments)}}:function(t,e){return e=+e,function(){Di(this,t).delay=e}})(e,t)):Ri(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?function(t,e){return function(){Ai(this,t).duration=+e.apply(this,arguments)}}:function(t,e){return e=+e,function(){Ai(this,t).duration=e}})(e,t)):Ri(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw new Error;return function(){Ai(this,t).ease=e}}(e,t)):Ri(this.node(),e).ease}};(function t(e){function n(t){return Math.pow(t,e)}return e=+e,n.exponent=t,n})(3),function t(e){function n(t){return 1-Math.pow(1-t,e)}return e=+e,n.exponent=t,n}(3),function t(e){function n(t){return((t*=2)<=1?Math.pow(t,e):2-Math.pow(2-t,e))/2}return e=+e,n.exponent=t,n}(3),Math.PI;(function t(e){function n(t){return t*t*((e+1)*t-e)}return e=+e,n.overshoot=t,n})(1.70158),function t(e){function n(t){return--t*t*((e+1)*t+e)+1}return e=+e,n.overshoot=t,n}(1.70158),function t(e){function n(t){return((t*=2)<1?t*t*((e+1)*t-e):(t-=2)*t*((e+1)*t+e)+2)/2}return e=+e,n.overshoot=t,n}(1.70158);var Hi=2*Math.PI,Fi=(function t(e,n){var i=Math.asin(1/(e=Math.max(1,e)))*(n/=Hi);function o(t){return e*Math.pow(2,10*--t)*Math.sin((i-t)/n)}return o.amplitude=function(e){return t(e,n*Hi)},o.period=function(n){return t(e,n)},o}(1,.3),function t(e,n){var i=Math.asin(1/(e=Math.max(1,e)))*(n/=Hi);function o(t){return 1-e*Math.pow(2,-10*(t=+t))*Math.sin((t+i)/n)}return o.amplitude=function(e){return t(e,n*Hi)},o.period=function(n){return t(e,n)},o}(1,.3),function t(e,n){var i=Math.asin(1/(e=Math.max(1,e)))*(n/=Hi);function o(t){return((t=2*t-1)<0?e*Math.pow(2,10*t)*Math.sin((i-t)/n):2-e*Math.pow(2,-10*t)*Math.sin((i+t)/n))/2}return o.amplitude=function(e){return t(e,n*Hi)},o.period=function(n){return t(e,n)},o}(1,.3),{time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}});function Oi(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))return Fi.time=pi(),Fi;return n}ee.prototype.interrupt=function(t){return this.each(function(){Pi(this,t)})},ee.prototype.transition=function(t){var e,n;t instanceof zi?(e=t._id,t=t._name):(e=Ui(),(n=Fi).time=pi(),t=null==t?null:t+"");for(var i=this._groups,o=i.length,a=0;a<o;++a)for(var s,r=i[a],l=r.length,h=0;h<l;++h)(s=r[h])&&Ti(s,t,e,h,r,n||Oi(s,e));return new zi(i,this._parents,t,e)};var qi=function(t){return function(){return t}};function Ji(t,e,n){this.k=t,this.x=e,this.y=n}Ji.prototype={constructor:Ji,scale:function(t){return 1===t?this:new Ji(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new Ji(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vi=new Ji(1,0,0);function Ki(t){return t.__zoom||Vi}function Yi(){qt.stopImmediatePropagation()}Ki.prototype=Ji.prototype;var $i=function(){qt.preventDefault(),qt.stopImmediatePropagation()};function Qi(){return!qt.button}function Xi(){var t,e,n=this;return n instanceof SVGElement?(t=(n=n.ownerSVGElement||n).width.baseVal.value,e=n.height.baseVal.value):(t=n.clientWidth,e=n.clientHeight),[[0,0],[t,e]]}function Zi(){return this.__zoom||Vi}function to(){return-qt.deltaY*(qt.deltaMode?120:1)/500}function eo(){return"ontouchstart"in this}function no(t,e,n){var i=t.invertX(e[0][0])-n[0][0],o=t.invertX(e[1][0])-n[1][0],a=t.invertY(e[0][1])-n[0][1],s=t.invertY(e[1][1])-n[1][1];return t.translate(o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o),s>a?(a+s)/2:Math.min(0,a)||Math.max(0,s))}var io=function(){var t,e,n=Qi,i=Xi,o=no,a=to,s=eo,r=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],h=250,c=Xn,d=[],u=me("start","zoom","end"),p=500,m=150,g=0;function f(t){t.property("__zoom",Zi).on("wheel.zoom",_).on("mousedown.zoom",M).on("dblclick.zoom",C).filter(s).on("touchstart.zoom",E).on("touchmove.zoom",x).on("touchend.zoom touchcancel.zoom",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(t,e){return(e=Math.max(r[0],Math.min(r[1],e)))===t.k?t:new Ji(e,t.x,t.y)}function b(t,e,n){var i=e[0]-n[0]*t.k,o=e[1]-n[1]*t.k;return i===t.x&&o===t.y?t:new Ji(t.k,i,o)}function y(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function w(t,e,n){t.on("start.zoom",function(){S(this,arguments).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).end()}).tween("zoom",function(){var t=arguments,o=S(this,t),a=i.apply(this,t),s=n||y(a),r=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),l=this.__zoom,h="function"==typeof e?e.apply(this,t):e,d=c(l.invert(s).concat(r/l.k),h.invert(s).concat(r/h.k));return function(t){if(1===t)t=h;else{var e=d(t),n=r/e[2];t=new Ji(n,s[0]-e[0]*n,s[1]-e[1]*n)}o.zoom(null,t)}})}function S(t,e){for(var n,i=0,o=d.length;i<o;++i)if((n=d[i]).that===t)return n;return new k(t,e)}function k(t,e){this.that=t,this.args=e,this.index=-1,this.active=0,this.extent=i.apply(t,e)}function _(){if(n.apply(this,arguments)){var t=S(this,arguments),e=this.__zoom,i=Math.max(r[0],Math.min(r[1],e.k*Math.pow(2,a.apply(this,arguments)))),s=re(this);if(t.wheel)t.mouse[0][0]===s[0]&&t.mouse[0][1]===s[1]||(t.mouse[1]=e.invert(t.mouse[0]=s)),clearTimeout(t.wheel);else{if(e.k===i)return;t.mouse=[s,e.invert(s)],Pi(this),t.start()}$i(),t.wheel=setTimeout(function(){t.wheel=null,t.end()},m),t.zoom("mouse",o(b(v(e,i),t.mouse[0],t.mouse[1]),t.extent,l))}}function M(){if(!e&&n.apply(this,arguments)){var t=S(this,arguments),i=ne(qt.view).on("mousemove.zoom",function(){if($i(),!t.moved){var e=qt.clientX-s,n=qt.clientY-r;t.moved=e*e+n*n>g}t.zoom("mouse",o(b(t.that.__zoom,t.mouse[0]=re(t.that),t.mouse[1]),t.extent,l))},!0).on("mouseup.zoom",function(){i.on("mousemove.zoom mouseup.zoom",null),be(qt.view,t.moved),$i(),t.end()},!0),a=re(this),s=qt.clientX,r=qt.clientY;ve(qt.view),Yi(),t.mouse=[a,this.__zoom.invert(a)],Pi(this),t.start()}}function C(){if(n.apply(this,arguments)){var t=this.__zoom,e=re(this),a=t.invert(e),s=t.k*(qt.shiftKey?.5:2),r=o(b(v(t,s),e,a),i.apply(this,arguments),l);$i(),h>0?ne(this).transition().duration(h).call(w,r,e):ne(this).call(f.transform,r)}}function E(){if(n.apply(this,arguments)){var e,i,o,a,s=S(this,arguments),r=qt.changedTouches,l=r.length;for(Yi(),i=0;i<l;++i)o=r[i],a=[a=le(this,r,o.identifier),this.__zoom.invert(a),o.identifier],s.touch0?s.touch1||(s.touch1=a):(s.touch0=a,e=!0);if(t&&(t=clearTimeout(t),!s.touch1))return s.end(),void((a=ne(this).on("dblclick.zoom"))&&a.apply(this,arguments));e&&(t=setTimeout(function(){t=null},p),Pi(this),s.start())}}function x(){var e,n,i,a,s=S(this,arguments),r=qt.changedTouches,h=r.length;for($i(),t&&(t=clearTimeout(t)),e=0;e<h;++e)n=r[e],i=le(this,r,n.identifier),s.touch0&&s.touch0[2]===n.identifier?s.touch0[0]=i:s.touch1&&s.touch1[2]===n.identifier&&(s.touch1[0]=i);if(n=s.that.__zoom,s.touch1){var c=s.touch0[0],d=s.touch0[1],u=s.touch1[0],p=s.touch1[1],m=(m=u[0]-c[0])*m+(m=u[1]-c[1])*m,g=(g=p[0]-d[0])*g+(g=p[1]-d[1])*g;n=v(n,Math.sqrt(m/g)),i=[(c[0]+u[0])/2,(c[1]+u[1])/2],a=[(d[0]+p[0])/2,(d[1]+p[1])/2]}else{if(!s.touch0)return;i=s.touch0[0],a=s.touch0[1]}s.zoom("touch",o(b(n,i,a),s.extent,l))}function I(){var t,n,i=S(this,arguments),o=qt.changedTouches,a=o.length;for(Yi(),e&&clearTimeout(e),e=setTimeout(function(){e=null},p),t=0;t<a;++t)n=o[t],i.touch0&&i.touch0[2]===n.identifier?delete i.touch0:i.touch1&&i.touch1[2]===n.identifier&&delete i.touch1;i.touch1&&!i.touch0&&(i.touch0=i.touch1,delete i.touch1),i.touch0?i.touch0[1]=this.__zoom.invert(i.touch0[0]):i.end()}return f.transform=function(t,e){var n=t.selection?t.selection():t;n.property("__zoom",Zi),t!==n?w(t,e):n.interrupt().each(function(){S(this,arguments).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},f.scaleBy=function(t,e){f.scaleTo(t,function(){return this.__zoom.k*("function"==typeof e?e.apply(this,arguments):e)})},f.scaleTo=function(t,e){f.transform(t,function(){var t=i.apply(this,arguments),n=this.__zoom,a=y(t),s=n.invert(a),r="function"==typeof e?e.apply(this,arguments):e;return o(b(v(n,r),a,s),t,l)})},f.translateBy=function(t,e,n){f.transform(t,function(){return o(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),l)})},f.translateTo=function(t,e,n){f.transform(t,function(){var t=i.apply(this,arguments),a=this.__zoom,s=y(t);return o(Vi.translate(s[0],s[1]).scale(a.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,l)})},k.prototype={start:function(){return 1==++this.active&&(this.index=d.push(this)-1,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0==--this.active&&(d.splice(this.index,1),this.index=-1,this.emit("end")),this},emit:function(t){$t(new function(t,e,n){this.target=t,this.type=e,this.transform=n}(f,t,this.that.__zoom),u.apply,u,[t,this.that,this.args])}},f.wheelDelta=function(t){return arguments.length?(a="function"==typeof t?t:qi(+t),f):a},f.filter=function(t){return arguments.length?(n="function"==typeof t?t:qi(!!t),f):n},f.touchable=function(t){return arguments.length?(s="function"==typeof t?t:qi(!!t),f):s},f.extent=function(t){return arguments.length?(i="function"==typeof t?t:qi([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),f):i},f.scaleExtent=function(t){return arguments.length?(r[0]=+t[0],r[1]=+t[1],f):[r[0],r[1]]},f.translateExtent=function(t){return arguments.length?(l[0][0]=+t[0][0],l[1][0]=+t[1][0],l[0][1]=+t[0][1],l[1][1]=+t[1][1],f):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},f.constrain=function(t){return arguments.length?(o=t,f):o},f.duration=function(t){return arguments.length?(h=+t,f):h},f.interpolate=function(t){return arguments.length?(c=t,f):c},f.on=function(){var t=u.on.apply(u,arguments);return t===u?f:t},f.clickDistance=function(t){return arguments.length?(g=(t=+t)*t,f):Math.sqrt(g)},f},oo=function(t,e){var n;function i(){var i,o,a=n.length,s=0,r=0;for(i=0;i<a;++i)s+=(o=n[i]).x,r+=o.y;for(s=s/a-t,r=r/a-e,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=r}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i},ao=function(t){return function(){return t}},so=function(){return 1e-6*(Math.random()-.5)};function ro(t,e,n,i){if(isNaN(e)||isNaN(n))return t;var o,a,s,r,l,h,c,d,u,p=t._root,m={data:i},g=t._x0,f=t._y0,v=t._x1,b=t._y1;if(!p)return t._root=m,t;for(;p.length;)if((h=e>=(a=(g+v)/2))?g=a:v=a,(c=n>=(s=(f+b)/2))?f=s:b=s,o=p,!(p=p[d=c<<1|h]))return o[d]=m,t;if(r=+t._x.call(null,p.data),l=+t._y.call(null,p.data),e===r&&n===l)return m.next=p,o?o[d]=m:t._root=m,t;do{o=o?o[d]=new Array(4):t._root=new Array(4),(h=e>=(a=(g+v)/2))?g=a:v=a,(c=n>=(s=(f+b)/2))?f=s:b=s}while((d=c<<1|h)==(u=(l>=s)<<1|r>=a));return o[u]=p,o[d]=m,t}var lo=function(t,e,n,i,o){this.node=t,this.x0=e,this.y0=n,this.x1=i,this.y1=o};function ho(t){return t[0]}function co(t){return t[1]}function uo(t,e,n){var i=new po(null==e?ho:e,null==n?co:n,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function po(t,e,n,i,o,a){this._x=t,this._y=e,this._x0=n,this._y0=i,this._x1=o,this._y1=a,this._root=void 0}function mo(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var go=uo.prototype=po.prototype;function fo(t){return t.x+t.vx}function vo(t){return t.y+t.vy}go.copy=function(){var t,e,n=new po(this._x,this._y,this._x0,this._y0,this._x1,this._y1),i=this._root;if(!i)return n;if(!i.length)return n._root=mo(i),n;for(t=[{source:i,target:n._root=new Array(4)}];i=t.pop();)for(var o=0;o<4;++o)(e=i.source[o])&&(e.length?t.push({source:e,target:i.target[o]=new Array(4)}):i.target[o]=mo(e));return n},go.add=function(t){var e=+this._x.call(null,t),n=+this._y.call(null,t);return ro(this.cover(e,n),e,n,t)},go.addAll=function(t){var e,n,i,o,a=t.length,s=new Array(a),r=new Array(a),l=1/0,h=1/0,c=-1/0,d=-1/0;for(n=0;n<a;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(o=+this._y.call(null,e))||(s[n]=i,r[n]=o,i<l&&(l=i),i>c&&(c=i),o<h&&(h=o),o>d&&(d=o));for(c<l&&(l=this._x0,c=this._x1),d<h&&(h=this._y0,d=this._y1),this.cover(l,h).cover(c,d),n=0;n<a;++n)ro(this,s[n],r[n],t[n]);return this},go.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,i=this._y0,o=this._x1,a=this._y1;if(isNaN(n))o=(n=Math.floor(t))+1,a=(i=Math.floor(e))+1;else{if(!(n>t||t>o||i>e||e>a))return this;var s,r,l=o-n,h=this._root;switch(r=(e<(i+a)/2)<<1|t<(n+o)/2){case 0:do{(s=new Array(4))[r]=h,h=s}while(a=i+(l*=2),t>(o=n+l)||e>a);break;case 1:do{(s=new Array(4))[r]=h,h=s}while(a=i+(l*=2),(n=o-l)>t||e>a);break;case 2:do{(s=new Array(4))[r]=h,h=s}while(i=a-(l*=2),t>(o=n+l)||i>e);break;case 3:do{(s=new Array(4))[r]=h,h=s}while(i=a-(l*=2),(n=o-l)>t||i>e)}this._root&&this._root.length&&(this._root=h)}return this._x0=n,this._y0=i,this._x1=o,this._y1=a,this},go.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},go.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},go.find=function(t,e,n){var i,o,a,s,r,l,h,c=this._x0,d=this._y0,u=this._x1,p=this._y1,m=[],g=this._root;for(g&&m.push(new lo(g,c,d,u,p)),null==n?n=1/0:(c=t-n,d=e-n,u=t+n,p=e+n,n*=n);l=m.pop();)if(!(!(g=l.node)||(o=l.x0)>u||(a=l.y0)>p||(s=l.x1)<c||(r=l.y1)<d))if(g.length){var f=(o+s)/2,v=(a+r)/2;m.push(new lo(g[3],f,v,s,r),new lo(g[2],o,v,f,r),new lo(g[1],f,a,s,v),new lo(g[0],o,a,f,v)),(h=(e>=v)<<1|t>=f)&&(l=m[m.length-1],m[m.length-1]=m[m.length-1-h],m[m.length-1-h]=l)}else{var b=t-+this._x.call(null,g.data),y=e-+this._y.call(null,g.data),w=b*b+y*y;if(w<n){var S=Math.sqrt(n=w);c=t-S,d=e-S,u=t+S,p=e+S,i=g.data}}return i},go.remove=function(t){if(isNaN(a=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t)))return this;var e,n,i,o,a,s,r,l,h,c,d,u,p=this._root,m=this._x0,g=this._y0,f=this._x1,v=this._y1;if(!p)return this;if(p.length)for(;;){if((h=a>=(r=(m+f)/2))?m=r:f=r,(c=s>=(l=(g+v)/2))?g=l:v=l,e=p,!(p=p[d=c<<1|h]))return this;if(!p.length)break;(e[d+1&3]||e[d+2&3]||e[d+3&3])&&(n=e,u=d)}for(;p.data!==t;)if(i=p,!(p=p.next))return this;return(o=p.next)&&delete p.next,i?(o?i.next=o:delete i.next,this):e?(o?e[d]=o:delete e[d],(p=e[0]||e[1]||e[2]||e[3])&&p===(e[3]||e[2]||e[1]||e[0])&&!p.length&&(n?n[u]=p:this._root=p),this):(this._root=o,this)},go.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},go.root=function(){return this._root},go.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},go.visit=function(t){var e,n,i,o,a,s,r=[],l=this._root;for(l&&r.push(new lo(l,this._x0,this._y0,this._x1,this._y1));e=r.pop();)if(!t(l=e.node,i=e.x0,o=e.y0,a=e.x1,s=e.y1)&&l.length){var h=(i+a)/2,c=(o+s)/2;(n=l[3])&&r.push(new lo(n,h,c,a,s)),(n=l[2])&&r.push(new lo(n,i,c,h,s)),(n=l[1])&&r.push(new lo(n,h,o,a,c)),(n=l[0])&&r.push(new lo(n,i,o,h,c))}return this},go.visitAfter=function(t){var e,n=[],i=[];for(this._root&&n.push(new lo(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var o=e.node;if(o.length){var a,s=e.x0,r=e.y0,l=e.x1,h=e.y1,c=(s+l)/2,d=(r+h)/2;(a=o[0])&&n.push(new lo(a,s,r,c,d)),(a=o[1])&&n.push(new lo(a,c,r,l,d)),(a=o[2])&&n.push(new lo(a,s,d,c,h)),(a=o[3])&&n.push(new lo(a,c,d,l,h))}i.push(e)}for(;e=i.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},go.x=function(t){return arguments.length?(this._x=t,this):this._x},go.y=function(t){return arguments.length?(this._y=t,this):this._y};var bo=function(t){var e,n,i=1,o=1;function a(){for(var t,a,r,l,h,c,d,u=e.length,p=0;p<o;++p)for(a=uo(e,fo,vo).visitAfter(s),t=0;t<u;++t)r=e[t],c=n[r.index],d=c*c,l=r.x+r.vx,h=r.y+r.vy,a.visit(m);function m(t,e,n,o,a){var s=t.data,u=t.r,p=c+u;if(!s)return e>l+p||o<l-p||n>h+p||a<h-p;if(s.index>r.index){var m=l-s.x-s.vx,g=h-s.y-s.vy,f=m*m+g*g;f<p*p&&(0===m&&(f+=(m=so())*m),0===g&&(f+=(g=so())*g),f=(p-(f=Math.sqrt(f)))/f*i,r.vx+=(m*=f)*(p=(u*=u)/(d+u)),r.vy+=(g*=f)*p,s.vx-=m*(p=1-p),s.vy-=g*p)}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function r(){if(e){var i,o,a=e.length;for(n=new Array(a),i=0;i<a;++i)o=e[i],n[o.index]=+t(o,i,e)}}return"function"!=typeof t&&(t=ao(null==t?1:+t)),a.initialize=function(t){e=t,r()},a.iterations=function(t){return arguments.length?(o=+t,a):o},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:ao(+e),r(),a):t},a};function yo(){}function wo(t,e){var n=new yo;if(t instanceof yo)t.each(function(t,e){n.set(e,t)});else if(Array.isArray(t)){var i,o=-1,a=t.length;if(null==e)for(;++o<a;)n.set(o,t[o]);else for(;++o<a;)n.set(e(i=t[o],o,t),i)}else if(t)for(var s in t)n.set(s,t[s]);return n}yo.prototype=wo.prototype={constructor:yo,has:function(t){return"$"+t in this},get:function(t){return this["$"+t]},set:function(t,e){return this["$"+t]=e,this},remove:function(t){var e="$"+t;return e in this&&delete this[e]},clear:function(){for(var t in this)"$"===t[0]&&delete this[t]},keys:function(){var t=[];for(var e in this)"$"===e[0]&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)"$"===e[0]&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)"$"===e[0]&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)"$"===e[0]&&++t;return t},empty:function(){for(var t in this)if("$"===t[0])return!1;return!0},each:function(t){for(var e in this)"$"===e[0]&&t(this[e],e.slice(1),this)}};var So=wo;function ko(){}var _o=So.prototype;function Mo(t,e){var n=new ko;if(t instanceof ko)t.each(function(t){n.add(t)});else if(t){var i=-1,o=t.length;if(null==e)for(;++i<o;)n.add(t[i]);else for(;++i<o;)n.add(e(t[i],i,t))}return n}ko.prototype=Mo.prototype={constructor:ko,has:_o.has,add:function(t){return this["$"+(t+="")]=t,this},remove:_o.remove,clear:_o.clear,values:_o.keys,size:_o.size,empty:_o.empty,each:_o.each};function Co(t){return t.index}function Eo(t,e){var n=t.get(e);if(!n)throw new Error("missing: "+e);return n}var xo=function(t){var e,n,i,o,a,s=Co,r=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},l=ao(30),h=1;function c(i){for(var o=0,s=t.length;o<h;++o)for(var r,l,c,d,u,p,m,g=0;g<s;++g)l=(r=t[g]).source,d=(c=r.target).x+c.vx-l.x-l.vx||so(),u=c.y+c.vy-l.y-l.vy||so(),d*=p=((p=Math.sqrt(d*d+u*u))-n[g])/p*i*e[g],u*=p,c.vx-=d*(m=a[g]),c.vy-=u*m,l.vx+=d*(m=1-m),l.vy+=u*m}function d(){if(i){var r,l,h=i.length,c=t.length,d=So(i,s);for(r=0,o=new Array(h);r<c;++r)(l=t[r]).index=r,"object"!=typeof l.source&&(l.source=Eo(d,l.source)),"object"!=typeof l.target&&(l.target=Eo(d,l.target)),o[l.source.index]=(o[l.source.index]||0)+1,o[l.target.index]=(o[l.target.index]||0)+1;for(r=0,a=new Array(c);r<c;++r)l=t[r],a[r]=o[l.source.index]/(o[l.source.index]+o[l.target.index]);e=new Array(c),u(),n=new Array(c),p()}}function u(){if(i)for(var n=0,o=t.length;n<o;++n)e[n]=+r(t[n],n,t)}function p(){if(i)for(var e=0,o=t.length;e<o;++e)n[e]=+l(t[e],e,t)}return null==t&&(t=[]),c.initialize=function(t){i=t,d()},c.links=function(e){return arguments.length?(t=e,d(),c):t},c.id=function(t){return arguments.length?(s=t,c):s},c.iterations=function(t){return arguments.length?(h=+t,c):h},c.strength=function(t){return arguments.length?(r="function"==typeof t?t:ao(+t),u(),c):r},c.distance=function(t){return arguments.length?(l="function"==typeof t?t:ao(+t),p(),c):l},c};function Io(t){return t.x}function No(t){return t.y}var To=10,Do=Math.PI*(3-Math.sqrt(5)),Ao=function(t){var e,n=1,i=.001,o=1-Math.pow(i,1/300),a=0,s=.6,r=So(),l=fi(c),h=me("tick","end");function c(){d(),h.call("tick",e),n<i&&(l.stop(),h.call("end",e))}function d(){var e,i,l=t.length;for(n+=(a-n)*o,r.each(function(t){t(n)}),e=0;e<l;++e)null==(i=t[e]).fx?i.x+=i.vx*=s:(i.x=i.fx,i.vx=0),null==i.fy?i.y+=i.vy*=s:(i.y=i.fy,i.vy=0)}function u(){for(var e,n=0,i=t.length;n<i;++n){if((e=t[n]).index=n,isNaN(e.x)||isNaN(e.y)){var o=To*Math.sqrt(n),a=n*Do;e.x=o*Math.cos(a),e.y=o*Math.sin(a)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t),e}return null==t&&(t=[]),u(),e={tick:d,restart:function(){return l.restart(c),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,u(),r.each(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(i=+t,e):i},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(a=+t,e):a},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},force:function(t,n){return arguments.length>1?(null==n?r.remove(t):r.set(t,p(n)),e):r.get(t)},find:function(e,n,i){var o,a,s,r,l,h=0,c=t.length;for(null==i?i=1/0:i*=i,h=0;h<c;++h)(s=(o=e-(r=t[h]).x)*o+(a=n-r.y)*a)<i&&(l=r,i=s);return l},on:function(t,n){return arguments.length>1?(h.on(t,n),e):h.on(t)}}},Ro=function(){var t,e,n,i,o=ao(-30),a=1,s=1/0,r=.81;function l(i){var o,a=t.length,s=uo(t,Io,No).visitAfter(c);for(n=i,o=0;o<a;++o)e=t[o],s.visit(d)}function h(){if(t){var e,n,a=t.length;for(i=new Array(a),e=0;e<a;++e)n=t[e],i[n.index]=+o(n,e,t)}}function c(t){var e,n,o,a,s,r=0,l=0;if(t.length){for(o=a=s=0;s<4;++s)(e=t[s])&&(n=Math.abs(e.value))&&(r+=e.value,l+=n,o+=n*e.x,a+=n*e.y);t.x=o/l,t.y=a/l}else{(e=t).x=e.data.x,e.y=e.data.y;do{r+=i[e.data.index]}while(e=e.next)}t.value=r}function d(t,o,l,h){if(!t.value)return!0;var c=t.x-e.x,d=t.y-e.y,u=h-o,p=c*c+d*d;if(u*u/r<p)return p<s&&(0===c&&(p+=(c=so())*c),0===d&&(p+=(d=so())*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=c*t.value*n/p,e.vy+=d*t.value*n/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===c&&(p+=(c=so())*c),0===d&&(p+=(d=so())*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(u=i[t.data.index]*n/p,e.vx+=c*u,e.vy+=d*u)}while(t=t.next)}}return l.initialize=function(e){t=e,h()},l.strength=function(t){return arguments.length?(o="function"==typeof t?t:ao(+t),h(),l):o},l.distanceMin=function(t){return arguments.length?(a=t*t,l):Math.sqrt(a)},l.distanceMax=function(t){return arguments.length?(s=t*t,l):Math.sqrt(s)},l.theta=function(t){return arguments.length?(r=t*t,l):Math.sqrt(r)},l},Po=function(t){var e,n,i,o=ao(.1);function a(t){for(var o,a=0,s=e.length;a<s;++a)(o=e[a]).vx+=(i[a]-o.x)*n[a]*t}function s(){if(e){var a,s=e.length;for(n=new Array(s),i=new Array(s),a=0;a<s;++a)n[a]=isNaN(i[a]=+t(e[a],a,e))?0:+o(e[a],a,e)}}return"function"!=typeof t&&(t=ao(null==t?0:+t)),a.initialize=function(t){e=t,s()},a.strength=function(t){return arguments.length?(o="function"==typeof t?t:ao(+t),s(),a):o},a.x=function(e){return arguments.length?(t="function"==typeof e?e:ao(+e),s(),a):t},a},Lo=function(t){var e,n,i,o=ao(.1);function a(t){for(var o,a=0,s=e.length;a<s;++a)(o=e[a]).vy+=(i[a]-o.y)*n[a]*t}function s(){if(e){var a,s=e.length;for(n=new Array(s),i=new Array(s),a=0;a<s;++a)n[a]=isNaN(i[a]=+t(e[a],a,e))?0:+o(e[a],a,e)}}return"function"!=typeof t&&(t=ao(null==t?0:+t)),a.initialize=function(t){e=t,s()},a.strength=function(t){return arguments.length?(o="function"==typeof t?t:ao(+t),s(),a):o},a.y=function(e){return arguments.length?(t="function"==typeof e?e:ao(+e),s(),a):t},a},Bo=n(4);class Wo extends i.Component{constructor(t){super(t)}componentWillMount(){this.setState(t=>({showModalState:!1,exportedData:""}))}componentWillUnmount(){}componentWillReceiveProps(t){if(t.showModalProp&&t.graphModel&&t.graphModel.activeGraph){let e="DATA";switch(t.exportMode){case"graph":let n=this.props.graphModel.activeGraph;n&&(e=JSON.stringify(n.toJSON(),null,2));break;case"markup":e=this.props.graphModel.getMarkup();break;case"d3":e=this.props.graphModel.getD3();break;case"svg":e=this.props.graphModel.getSVG();break;case"css":e=this.props.graphModel.getCSS();break;case"dot":e=""}this.setState(n=>({showModalState:t.showModalProp,exportedData:e}))}}componentDidUpdate(t,e){}close(){this.setState(t=>(this.props.onClose(),{showModalState:!1,exportedData:""}))}onHide(){this.close()}save(){let t={};switch(this.props.exportMode){case"graph":try{t=JSON.parse(this.state.exportedData),this.props.graphModel.newGraphWithOptions(t)}catch(t){console.log("ModalExport: save: ",t)}break;case"markup":t={markup:this.state.exportedData},this.props.graphModel.newGraphWithOptions(t);break;case"d3":t={d3Graph:JSON.parse(this.state.exportedData)},this.props.graphModel.newGraphWithOptions(t);break;case"svg":break;case"css":this.props.graphModel.applyActiveGraphCss(this.state.exportedData);break;case"dot":t={dot:this.state.exportedData},this.props.graphModel.newGraphWithOptions(t)}this.close()}onButtonClicked(t){switch(t){case"save":this.save();break;case"cancel":case"close":this.close()}}handleInputChange(t){let e=t.nativeEvent;switch(e.target.name){case"exportedData":this.setState(t=>({exportedData:e.target.value}))}}render(){return i.createElement(a.Modal,{className:"modal-export",show:this.state.showModalState,onHide:this.onHide.bind(this)},i.createElement(a.Modal.Header,null,i.createElement(a.Modal.Title,null,"Exported Data: ",this.props.exportMode)),i.createElement(a.Modal.Body,{className:"modal-export-body"},i.createElement("textarea",{name:"exportedData",className:"code",value:this.state.exportedData,onChange:this.handleInputChange.bind(this)})),i.createElement(a.Modal.Footer,null,i.createElement(a.Button,{bsStyle:"success",key:"cancel",style:{width:150},onClick:this.onButtonClicked.bind(this,"cancel")},"Cancel"),i.createElement(a.Button,{bsStyle:"success",key:"save",style:{width:150},onClick:this.onButtonClicked.bind(this,"save")},"Save")))}}class Go extends i.Component{constructor(t){super(t)}componentWillMount(){this.setState(t=>({showModalState:!1,graphName:"",graphNameStyle:{color:"black"}}))}componentWillUnmount(){}componentWillReceiveProps(t){let e="";switch(t.fileDetailsMode){case"details":e=t.graphModel.activeGraph?t.graphModel.activeGraph.name:"";break;case"newFile":e="<filename>"}t.showModalProp&&this.setState(n=>({showModalState:t.showModalProp,graphName:e,graphNameStyle:{color:"black"}}))}componentDidUpdate(t,e){}close(t){console.log(`ModalFileDetails: close: ${t}`),this.setState(e=>(this.props.onClose(t),{showModalState:!1,graphName:""}))}onHide(){console.log("ModalFileDetails: onHide: "),this.close()}save(){let t={};t.fileDetailsMode=this.props.fileDetailsMode,t.name=this.state.graphName,this.close(t)}onButtonClicked(t){switch(t){case"save":"<filename>"!=this.state.graphName?this.save():this.setState(t=>({graphNameStyle:{color:"red"}}));break;case"cancel":this.close()}}handleInputChange(t){let e=t.nativeEvent;switch(e.target.name){case"graphName":this.setState(t=>({graphName:e.target.value}))}}render(){return i.createElement(a.Modal,{show:this.state.showModalState,onHide:this.onHide.bind(this)},i.createElement(a.Modal.Header,null,i.createElement(a.Modal.Title,null,"Graph Details: ",this.props.fileDetailsMode)),i.createElement(a.Modal.Body,null,i.createElement("div",{className:"pull-left",style:{paddingRight:6}},"Filename:"),i.createElement("input",{name:"graphName",id:"graphName",type:"text",value:this.state.graphName,onChange:this.handleInputChange.bind(this),style:this.state.graphNameStyle})),i.createElement(a.Modal.Footer,null,i.createElement(a.Button,{bsStyle:"success",key:"cancel",style:{width:150},onClick:this.onButtonClicked.bind(this,"cancel")},"Cancel"),i.createElement(a.Button,{bsStyle:"success",key:"save",style:{width:150},onClick:this.onButtonClicked.bind(this,"save")},"Save")))}}const{dialog:zo,shell:Uo}=n(11).remote;class jo extends i.Component{constructor(t){super(t)}componentWillMount(){let t="<filename>";this.props.graphModel.activeGraph&&(t=this.props.graphModel.activeGraph.name),this.setState(e=>({graphName:t,graphScale:1,showModal:!1,exportMode:"markup",showFileDetailsModal:!1,fileDetailsMode:""}))}componentDidMount(){}componentWillUnmount(){}onUpdateActiveGraph(){this.setState(t=>({graphName:this.props.graphModel.activeGraph?this.props.graphModel.activeGraph.name:"",graphScale:this.props.graphModel.activeGraph?this.props.graphModel.activeGraph.scale:1}))}handleInputChange(t){let e=t.nativeEvent;switch(e.target.name){case"graphName":this.setState({graphName:e.target.value})}}handleSubmit(t){t.preventDefault()}onButtonClicked(t){switch(t){case"exportGraph":this.openModalExport("graph");break;case"exportMarkup":this.openModalExport("markup");break;case"exportD3":this.openModalExport("d3");break;case"exportSVG":this.openModalExport("svg");break;case"exportCSS":this.openModalExport("css");break;case"exportDot":this.openModalExport("dot");break;case"details":this.openModalFileDetails("details");break;case"newFile":this.openModalFileDetails("newFile");break;case"import":this.importGraphFile();break;case"show":this.props.graphModel.settings.userDataPath&&Uo.showItemInFolder(this.props.graphModel.settings.userDataPath);break;case"save":this.save()}}save(){"<filename>"!=this.state.graphName?this.props.graphModel.saveActiveGraph():this.openModalFileDetails("details")}openModalExport(t){this.setState({showModal:!0,exportMode:t})}onCloseModalExport(){this.setState({showModal:!1})}openModalFileDetails(t=""){this.setState(e=>({showFileDetailsModal:!0,fileDetailsMode:t}))}importGraphFile(){zo.showOpenDialog(t=>{void 0!==t?t[0]&&this.props.graphModel&&this.props.graphModel.initGraphWithPath(t[0]).then(t=>{this.props.graphModel&&this.props.graphModel.graphSet&&(this.props.graphModel.graphSet.addGraph(t),this.props.graphModel.graphSet.saveGraph(t),this.setState(e=>({graphName:t.name})))}).catch(t=>{console.log(t)}):console.log("No file selected")})}onCloseModalFileDetails(t){console.log("ToolsPanel: onCloseModalFileDetails:",t),t?"newFile"==t.fileDetailsMode?(this.props.graphModel.newBlankGraph(t.name),this.setState(e=>({showFileDetailsModal:!1,graphName:t.name}))):this.props.graphModel.activeGraph&&this.props.graphModel.graphSet?(this.props.graphModel.activeGraph.name=t.name,this.props.graphModel.graphSet.addGraph(this.props.graphModel.activeGraph),this.props.graphModel.graphSet.saveGraph(this.props.graphModel.activeGraph),this.setState(e=>({showFileDetailsModal:!1,graphName:t.name}))):this.setState(t=>({showFileDetailsModal:!1})):this.setState(t=>({showFileDetailsModal:!1}))}onMenuItemSelected(t){this.setState({graphName:t}),this.props.graphModel.initGraphWithName(t)}renderFilenameMenuItems(){let t=[];return this.props.graphModel.graphSet&&this.props.graphModel.graphSet.getGraphNames().forEach(e=>{let n=!1;e==this.state.graphName&&(n=!0),t.push(i.createElement(a.MenuItem,{active:n,key:e,eventKey:e,onSelect:this.onMenuItemSelected.bind(this,e)},e))}),t}renderFilenameSplitButton(){return i.createElement(a.SplitButton,{bsStyle:"default",title:this.state.graphName,key:"filename-splitbutton",id:"filename-splitbutton"},this.renderFilenameMenuItems())}render(){return i.createElement("div",{className:"editor-panel well",id:"toolsPanel"},i.createElement("div",{className:"tools form-inline"},i.createElement(Wo,{showModalProp:this.state.showModal,onClose:this.onCloseModalExport.bind(this),graphModel:this.props.graphModel,exportMode:this.state.exportMode}),i.createElement(Go,{showModalProp:this.state.showFileDetailsModal,onClose:this.onCloseModalFileDetails.bind(this),graphModel:this.props.graphModel,fileDetailsMode:this.state.fileDetailsMode}),i.createElement(a.Button,{bsStyle:"default",key:"exportGraph",style:{width:80},onClick:this.onButtonClicked.bind(this,"exportGraph")},"Graph"),i.createElement(a.Button,{bsStyle:"default",key:"exportD3",style:{width:80},onClick:this.onButtonClicked.bind(this,"exportD3")},"D3"),i.createElement(a.Button,{bsStyle:"default",key:"exportSVG",style:{width:80},onClick:this.onButtonClicked.bind(this,"exportSVG")},"SVG"),i.createElement(a.Button,{bsStyle:"default",key:"exportCSS",style:{width:80},onClick:this.onButtonClicked.bind(this,"exportCSS")},"CSS"),i.createElement(a.Button,{bsStyle:"default",key:"import",style:{width:80},onClick:this.onButtonClicked.bind(this,"import")},"Import"),i.createElement(a.Button,{bsStyle:"default",key:"show",style:{width:80},onClick:this.onButtonClicked.bind(this,"show")},"Show"),i.createElement("div",null,i.createElement("label",{className:"input-label"},"Open:"),this.renderFilenameSplitButton(),i.createElement("datalist",{id:"graphlist"}),i.createElement(a.Button,{bsStyle:"default",key:"save",style:{width:80},onClick:this.onButtonClicked.bind(this,"save")},"Save"),i.createElement(a.Button,{bsStyle:"default",key:"details",style:{width:80},onClick:this.onButtonClicked.bind(this,"details")},"Details"),i.createElement(a.Button,{bsStyle:"default",key:"newFile",style:{width:80},onClick:this.onButtonClicked.bind(this,"newFile")},"New File"))))}}var Ho=n(12);class Fo extends i.Component{constructor(t){super(t),this._savedTTSList=[],this._savedTTSListLength=0,this._onTTSExecutedHandler=this.onTTSExecuted.bind(this),this._onTTSExecutionErrorHandler=this.onTTSExecutionErrorHandler.bind(this),this._onUpdateActiveGraphHandler=this.onUpdateActiveGraph.bind(this),this._itemClickedPrevTime=0}componentWillMount(){let t=this.props.graphModel.getSavedTTSList()[0];this.setState(e=>({activeTTS:t||{name:"<name>",prompt:"<prompt>"},selectedCyperIndex:0,status:""})),this.props.graphModel.on("onTTSExecuted",this._onTTSExecutedHandler),this.props.graphModel.on("onTTSExecutionError",this._onTTSExecutionErrorHandler),this.props.graphModel.on("updateActiveGraph",this._onUpdateActiveGraphHandler)}componentDidMount(){this.props.graphModel.addPanelWithId(this.props.id)}componentWillUnmount(){this.props.graphModel.removeListener("onTTSExecuted",this._onTTSExecutedHandler),this.props.graphModel.removeListener("onTTSExecutionError",this._onTTSExecutionErrorHandler),this.props.graphModel.removeListener("updateActiveGraph",this._onUpdateActiveGraphHandler)}onTTSExecuted(t){this.setState({status:"OK"})}onTTSExecutionErrorHandler(t){this.setState({status:t})}onUpdateActiveGraph(){let t=this.props.graphModel.getSavedTTSList()[0];this.setState(e=>({activeTTS:t||{name:"<name>",prompt:"<prompt>"},selectedCyperIndex:0,status:""}))}handleInputChange(t){let e=t.nativeEvent,n=this.state.activeTTS;switch(e.target.name){case"promptName":n.name=e.target.value;break;case"prompt":n.prompt=e.target.value;break;case"promptStatus":this.setState({status:e.target.value})}this.setState({activeTTS:n})}handleSubmit(t){t.preventDefault()}onButtonClicked(t){switch(t){case"run":this.sendTTS(this.state.activeTTS);break;case"new":this.newSavedTTS();break;case"delete":this.deleteSlectedTTS(this.state.activeTTS.index)}}onItemClicked(t){let e=this.props.graphModel.getSavedTTSList()[t];e&&this.setState({activeTTS:e,selectedCyperIndex:t});let n=(new Date).getTime(),i=n-this._itemClickedPrevTime;this._itemClickedPrevTime=n,i<200&&this.sendTTS(e)}sendTTS(t){this.props.graphModel.sendTTS(t)}newSavedTTS(){let t=this.props.graphModel.newSavedTTS();console.log(`newSavedTTS: ${t}`),this.setState(e=>({activeTTS:this.props.graphModel.getSavedTTSList()[t],selectedCyperIndex:t}))}deleteSlectedTTS(t){let e=this.props.graphModel.deleteSavedTTS(this.state.activeTTS);this.setState({activeTTS:this.props.graphModel.getSavedTTSList()[e],selectedCyperIndex:e})}renderItem(t,e){let n=this._savedTTSList[t],o="item"+(t%2?"":" even");return t==this.state.selectedCyperIndex&&(o+=" selected"),i.createElement("div",{key:e,className:o,onClick:this.onItemClicked.bind(this,t)},n.name)}handleClick(t){this.props.graphModel.bringPanelToFront(this.props.id)}handleClose(t){this.props.onClosePanel(this.props.id)}handleMinimize(t){console.log("minimize")}handleMaximize(t){console.log("maximize")}handleFullScreen(t){console.log("fullscreen")}render(){return this._savedTTSList=this.props.graphModel.getSavedTTSList(),this._savedTTSListLength=this._savedTTSList.length,i.createElement(r.a,{handle:".handle"},i.createElement("div",{className:"editor-panel well",id:"ttsPanel"},i.createElement(m,{draggable:!0,handleClick:this.handleClick.bind(this),handleClose:this.handleClose.bind(this),handleMinimize:this.handleMinimize.bind(this),handleMaximize:this.handleMaximize.bind(this),handleFullScreen:this.handleFullScreen.bind(this)}),i.createElement("h4",{className:"pull-left handle",style:{marginBottom:20}},"Saved TTSs"),i.createElement("div",{className:"clearfix"}),i.createElement(a.Table,{striped:!0,bordered:!0,condensed:!0,hover:!0,style:{width:400}},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,"name:"),i.createElement("td",null,i.createElement("input",{name:"promptName",value:this.state.activeTTS.name,onChange:this.handleInputChange.bind(this),style:{width:400}}))),i.createElement("tr",null,i.createElement("td",null,"prompt:"),i.createElement("td",null,i.createElement("textarea",{name:"prompt",value:this.state.activeTTS.prompt,onChange:this.handleInputChange.bind(this),style:{width:400,height:50}}))),i.createElement("tr",null,i.createElement("td",null,"saved:"),i.createElement("td",null,i.createElement("div",{style:{overflow:"auto",height:200,maxHeight:200}},i.createElement(Ho,{itemRenderer:this.renderItem.bind(this),length:this._savedTTSListLength,type:"uniform"})))))),i.createElement(a.Button,{bsStyle:"default",key:"run",style:{width:80},onClick:this.onButtonClicked.bind(this,"run")},"Run"),i.createElement(a.Button,{bsStyle:"default",key:"new",style:{width:80},onClick:this.onButtonClicked.bind(this,"new")},"New"),i.createElement(a.Button,{bsStyle:"default",key:"delete",style:{width:80},onClick:this.onButtonClicked.bind(this,"delete")},"Delete")))}}class Oo extends i.Component{constructor(t){super(t),this._savedScriptList=[],this._savedScriptListLength=0,this._onScriptExecutedHandler=this.onScriptExecuted.bind(this),this._onScriptExecutionErrorHandler=this.onScriptExecutionErrorHandler.bind(this),this._onUpdateActiveGraphHandler=this.onUpdateActiveGraph.bind(this),this._itemClickedPrevTime=0}componentWillMount(){let t=this.props.graphModel.getSavedScriptList()[0];this.setState(e=>({activeScript:t||{name:"<name>",script:"<script>"},selectedCyperIndex:0,status:""})),this.props.graphModel.on("onScriptExecuted",this._onScriptExecutedHandler),this.props.graphModel.on("onScriptExecutionError",this._onScriptExecutionErrorHandler),this.props.graphModel.on("updateActiveGraph",this._onUpdateActiveGraphHandler)}componentDidMount(){this.props.graphModel.addPanelWithId(this.props.id)}componentWillUnmount(){this.props.graphModel.removeListener("onScriptExecuted",this._onScriptExecutedHandler),this.props.graphModel.removeListener("onScriptExecutionError",this._onScriptExecutionErrorHandler),this.props.graphModel.removeListener("updateActiveGraph",this._onUpdateActiveGraphHandler)}onScriptExecuted(t){this.setState({status:"OK"})}onScriptExecutionErrorHandler(t){this.setState({status:t})}onUpdateActiveGraph(){let t=this.props.graphModel.getSavedScriptList()[0];this.setState(e=>({activeScript:t||{name:"<name>",script:"<script>"},selectedCyperIndex:0,status:""}))}handleInputChange(t){let e=t.nativeEvent,n=this.state.activeScript;switch(e.target.name){case"scriptName":n.name=e.target.value;break;case"script":n.script=e.target.value;break;case"scriptStatus":this.setState({status:e.target.value})}this.setState({activeScript:n})}handleSubmit(t){t.preventDefault()}onButtonClicked(t){switch(t){case"execute":this.executeScript(this.state.activeScript);break;case"new":this.newSavedScript();break;case"delete":this.deleteSlectedScript(this.state.activeScript.index)}}onItemClicked(t){let e=this.props.graphModel.getSavedScriptList()[t];e&&this.setState({activeScript:e,selectedCyperIndex:t});let n=(new Date).getTime(),i=n-this._itemClickedPrevTime;this._itemClickedPrevTime=n,i<200&&this.executeScript(e)}executeScript(t){this.props.graphModel.executeScript(t)}newSavedScript(){let t=this.props.graphModel.newSavedScript();console.log(`newSavedScript: ${t}`),this.setState(e=>({activeScript:this.props.graphModel.getSavedScriptList()[t],selectedCyperIndex:t}))}deleteSlectedScript(t){let e=this.props.graphModel.deleteSavedScript(this.state.activeScript);this.setState({activeScript:this.props.graphModel.getSavedScriptList()[e],selectedCyperIndex:e})}renderItem(t,e){let n=this._savedScriptList[t],o="item"+(t%2?"":" even");return t==this.state.selectedCyperIndex&&(o+=" selected"),i.createElement("div",{key:e,className:o,onClick:this.onItemClicked.bind(this,t)},n.name)}handleClick(t){this.props.graphModel.bringPanelToFront(this.props.id)}handleClose(t){this.props.onClosePanel(this.props.id)}handleMinimize(t){console.log("minimize")}handleMaximize(t){console.log("maximize")}handleFullScreen(t){console.log("fullscreen")}render(){return this._savedScriptList=this.props.graphModel.getSavedScriptList(),this._savedScriptListLength=this._savedScriptList.length,i.createElement(r.a,{handle:".handle"},i.createElement("div",{className:"editor-panel well",id:"scriptPanel"},i.createElement(m,{draggable:!0,handleClick:this.handleClick.bind(this),handleClose:this.handleClose.bind(this),handleMinimize:this.handleMinimize.bind(this),handleMaximize:this.handleMaximize.bind(this),handleFullScreen:this.handleFullScreen.bind(this)}),i.createElement("h4",{className:"pull-left handle",style:{marginBottom:20}},"Saved Scripts"),i.createElement("div",{className:"clearfix"}),i.createElement(a.Table,{striped:!0,bordered:!0,condensed:!0,hover:!0,style:{width:400}},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,"name:"),i.createElement("td",null,i.createElement("input",{name:"scriptName",value:this.state.activeScript.name,onChange:this.handleInputChange.bind(this),style:{width:400}}))),i.createElement("tr",null,i.createElement("td",null,"script:"),i.createElement("td",null,i.createElement("textarea",{name:"script",value:this.state.activeScript.script,onChange:this.handleInputChange.bind(this),style:{width:400,height:150}}))),i.createElement("tr",null,i.createElement("td",null,"saved:"),i.createElement("td",null,i.createElement("div",{style:{overflow:"auto",height:200,maxHeight:200}},i.createElement(Ho,{itemRenderer:this.renderItem.bind(this),length:this._savedScriptListLength,type:"uniform"})))))),i.createElement(a.Button,{bsStyle:"default",key:"execute",style:{width:80},onClick:this.onButtonClicked.bind(this,"execute")},"Execute"),i.createElement(a.Button,{bsStyle:"default",key:"new",style:{width:80},onClick:this.onButtonClicked.bind(this,"new")},"New"),i.createElement(a.Button,{bsStyle:"default",key:"delete",style:{width:80},onClick:this.onButtonClicked.bind(this,"delete")},"Delete")))}}class qo extends i.Component{constructor(t){super(t)}componentWillMount(){this.setState({robot:void 0,data:JSON.stringify(this.props.graphModel.globalStateData,null,2)})}componentDidMount(){this.props.graphModel.addPanelWithId(this.props.id)}componentWillUnmount(){}handleInputChange(t){let e=t.nativeEvent;switch(e.target.name){case"data":this.setState({data:e.target.value})}}handleSubmit(t){t.preventDefault()}onButtonClicked(t){switch(t){case"save":this.save();break;case"delete":this.props.graphModel.deleteStateData(this.state.robot);break;case"cancel":this.props.onClosePanel(this.props.id)}}onRobotButtonClicked(t){console.log("onRobotButtonClicked: ",t),t?this.setState({robot:t,data:JSON.stringify(t.stateData,null,2)}):this.setState({robot:void 0,data:JSON.stringify(this.props.graphModel.globalStateData,null,2)})}save(){let t=JSON.parse(this.state.data);this.props.graphModel.saveStateData(this.state.robot,t)}createRobotButtons(){let t=[];return t.push(i.createElement(a.Button,{bsStyle:"default",key:"scope_global",style:{width:80},onClick:this.onRobotButtonClicked.bind(this,void 0)},"global")),this.props.targetedRobots.forEach(e=>{t.push(i.createElement(a.Button,{bsStyle:"default",key:`scope_${e.name}`,style:{width:80},onClick:this.onRobotButtonClicked.bind(this,e)},e.name))}),t}handleClick(t){this.props.graphModel.bringPanelToFront(this.props.id)}handleClose(t){this.props.onClosePanel(this.props.id)}handleMinimize(t){console.log("minimize")}handleMaximize(t){console.log("maximize")}handleFullScreen(t){console.log("fullscreen")}render(){let t="global";return this.state.robot&&(t=this.state.robot.name),i.createElement(r.a,{handle:".handle"},i.createElement("div",{className:"editor-panel well",id:"stateDataPanel"},i.createElement(m,{draggable:!0,handleClick:this.handleClick.bind(this),handleClose:this.handleClose.bind(this),handleMinimize:this.handleMinimize.bind(this),handleMaximize:this.handleMaximize.bind(this),handleFullScreen:this.handleFullScreen.bind(this)}),i.createElement("h4",{className:"pull-left handle",style:{marginBottom:20}},"State Data"),i.createElement("div",{className:"clearfix"}),i.createElement(a.Table,{striped:!0,bordered:!0,condensed:!0,hover:!0,style:{width:400}},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,"scope:"),i.createElement("td",null,i.createElement("input",{name:"scope",value:t,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"data:"),i.createElement("td",null,i.createElement("textarea",{name:"data",value:this.state.data,onChange:this.handleInputChange.bind(this),style:{width:300,height:100}}))))),i.createElement("div",{className:"clearfix"}),this.createRobotButtons(),i.createElement("div",{className:"clearfix"}),i.createElement(a.Button,{bsStyle:"success",key:"save",style:{width:80},onClick:this.onButtonClicked.bind(this,"save")},"Save"),i.createElement(a.Button,{bsStyle:"danger",key:"delete",style:{width:80},onClick:this.onButtonClicked.bind(this,"delete")},"Delete"),i.createElement(a.Button,{bsStyle:"default",key:"cancel",style:{width:80},onClick:this.onButtonClicked.bind(this,"cancel")},"Cancel")))}}class Jo extends i.Component{constructor(t){super(t),this._oldLabel="",this._setPropertiesHandler=this.setProperties.bind(this)}componentWillMount(){this._oldLabel="",this.setState({type:"",properties:""}),this.props.graphModel.on("updateActiveNode",this._setPropertiesHandler)}setProperties(t){this._oldLabel=t.label,this.setState({type:t.label,properties:t.properties})}componentDidMount(){this.props.graphModel.addPanelWithId(this.props.id)}componentWillUnmount(){this.props.graphModel.removeListener("updateActiveNode",this._setPropertiesHandler)}handleInputChange(t){let e=t.nativeEvent;switch(e.target.name){case"type":this.setState({type:e.target.value});break;case"properties":this.setState({properties:e.target.value})}}handleSubmit(t){t.preventDefault()}onButtonClicked(t){switch(t){case"save":this.save(),this.props.graphModel.onRedraw();break;case"delete":this.props.graphModel.deleteActiveNode(),this.props.graphModel.onRedraw()}this.props.onClosePanel(this.props.id)}save(){this.props.graphModel.saveActiveNode(this.state.type,this.state.properties,this._oldLabel)}handleClick(t){this.props.graphModel.bringPanelToFront(this.props.id)}handleClose(t){this.props.onClosePanel(this.props.id)}handleMinimize(t){console.log("minimize")}handleMaximize(t){console.log("maximize")}handleFullScreen(t){console.log("fullscreen")}render(){let t=this.props.graphModel.activeNode?this.props.graphModel.activeNode.id:"";return i.createElement(r.a,{handle:".handle"},i.createElement("div",{className:"editor-panel well",id:"nodeEditorPanel"},i.createElement(m,{draggable:!0,handleClick:this.handleClick.bind(this),handleClose:this.handleClose.bind(this),handleMinimize:this.handleMinimize.bind(this),handleMaximize:this.handleMaximize.bind(this),handleFullScreen:this.handleFullScreen.bind(this)}),i.createElement("h4",{className:"pull-left handle",style:{marginBottom:20}},"Node [",t,"]"),i.createElement("div",{className:"clearfix"}),i.createElement(a.Table,{striped:!0,bordered:!0,condensed:!0,hover:!0,style:{width:400}},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,"type:"),i.createElement("td",null,i.createElement("input",{name:"type",value:this.state.type,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"properties:"),i.createElement("td",null,i.createElement("textarea",{name:"properties",value:this.state.properties,onChange:this.handleInputChange.bind(this),style:{width:300,height:100}}))))),i.createElement(a.Button,{bsStyle:"success",key:"save",style:{width:80},onClick:this.onButtonClicked.bind(this,"save")},"Save"),i.createElement(a.Button,{bsStyle:"danger",key:"delete",style:{width:80},onClick:this.onButtonClicked.bind(this,"delete")},"Delete"),i.createElement(a.Button,{bsStyle:"default",key:"cancel",style:{width:80},onClick:this.onButtonClicked.bind(this,"cancel")},"Cancel")))}}class Vo extends i.Component{constructor(t){super(t),this._setPropertiesHandler=this.setProperties.bind(this)}componentWillMount(){this.setState({type:"",properties:""}),this.props.graphModel.on("updateActiveRelationship",this._setPropertiesHandler)}componentDidMount(){this.props.graphModel.addPanelWithId(this.props.id)}componentWillUnmount(){this.props.graphModel.removeListener("updateActiveRelationship",this._setPropertiesHandler)}setProperties(t){console.log(t),this.setState({type:t.label,properties:t.properties})}handleInputChange(t){let e=t.nativeEvent;switch(e.target.name){case"type":this.setState({type:e.target.value});break;case"properties":this.setState({properties:e.target.value})}}handleSubmit(t){t.preventDefault()}onButtonClicked(t){switch(t){case"save":this.save(),this.props.graphModel.onRedraw();break;case"reverse":this.props.graphModel.reverseActiveRelationship(),this.props.graphModel.onRedraw();break;case"delete":this.props.graphModel.deleteActiveRelationship(),this.props.graphModel.onRedraw()}this.props.onClosePanel(this.props.id)}save(){this.props.graphModel.saveActiveRelationship(this.state.type,this.state.properties)}handleClick(t){this.props.graphModel.bringPanelToFront(this.props.id)}handleClose(t){this.props.onClosePanel(this.props.id)}handleMinimize(t){console.log("minimize")}handleMaximize(t){console.log("maximize")}handleFullScreen(t){console.log("fullscreen")}render(){let t=this.props.graphModel.activeRelationship?this.props.graphModel.activeRelationship.id:"";return i.createElement(r.a,{handle:".handle"},i.createElement("div",{className:"editor-panel well",id:"relationshipEditorPanel"},i.createElement(m,{draggable:!0,handleClick:this.handleClick.bind(this),handleClose:this.handleClose.bind(this),handleMinimize:this.handleMinimize.bind(this),handleMaximize:this.handleMaximize.bind(this),handleFullScreen:this.handleFullScreen.bind(this)}),i.createElement("h4",{className:"pull-left handle",style:{marginBottom:20}},"Relationship [",t,"]"),i.createElement("div",{className:"clearfix"}),i.createElement(a.Table,{striped:!0,bordered:!0,condensed:!0,hover:!0,style:{width:400}},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,"type:"),i.createElement("td",null,i.createElement("input",{name:"type",value:this.state.type,onChange:this.handleInputChange.bind(this),style:{width:300}}))),i.createElement("tr",null,i.createElement("td",null,"properties:"),i.createElement("td",null,i.createElement("textarea",{name:"properties",value:this.state.properties,onChange:this.handleInputChange.bind(this),style:{width:300,height:100}}))))),i.createElement(a.Button,{bsStyle:"success",key:"save",style:{width:80},onClick:this.onButtonClicked.bind(this,"save")},"Save"),i.createElement(a.Button,{bsStyle:"warning",key:"reverse",style:{width:80},onClick:this.onButtonClicked.bind(this,"reverse")},"Reverse"),i.createElement(a.Button,{bsStyle:"danger",key:"delete",style:{width:80},onClick:this.onButtonClicked.bind(this,"delete")},"Delete"),i.createElement(a.Button,{bsStyle:"default",key:"cancel",style:{width:80},onClick:this.onButtonClicked.bind(this,"cancel")},"Cancel")))}}const Ko=n(5),Yo=n(13),$o=n(6);let Qo=Ko.resolve(Yo.home(),".wwlib/robocommander/"),Xo=Ko.resolve(Qo,"graph-settings.json");class Zo extends y.EventEmitter{constructor(){super(),this.userDataPath=Ko.resolve(Qo,"user"),this._timestamp=0,this._data={}}get data(){return this._data}set data(t){this._data=t}get timestamp(){return this._timestamp}load(t){$o.readFile(Xo,(e,n)=>{e?t(e):(this._data=n,this._timestamp=this._data.timestamp,t(e,n))})}save(t){this._timestamp=(new Date).getTime(),this._data.timestamp=this._timestamp,$o.writeFile(Xo,this._data,{spaces:2},e=>{t(e||null)})}}class ta{constructor(t){this.nextTTSIndex=0,this.savedTTSs=new Map,t?this.initWithJson(t):(this.savedTTSs=new Map,this.nextTTSIndex=0)}initWithJson(t){this.nextTTSIndex=0,t.savedTTSs&&t.savedTTSs.forEach(t=>{this.addSavedTTS(t.name,t.prompt)}),0==this.savedTTSs.size&&this.newSavedTTS()}savedTTSToArray(){return Array.from(this.savedTTSs.values())}toJSON(){let t={};return t.savedTTSs=this.savedTTSToArray(),t}addSavedTTS(t,e){let n=this.nextTTSIndex++;return this.savedTTSs.set(n,{index:n,name:t,prompt:e}),this.savedTTSs.size-1}newSavedTTS(){return this.addSavedTTS("<prompt name>","<prompt>")}saveTTS(t){let e=t.index||this.nextTTSIndex++;this.savedTTSs.set(e,{index:e,name:t.name,prompt:t.prompt})}deleteSavedTTSWithIndex(t){return this.savedTTSs.delete(t),0}}class ea{constructor(t){this.nextScriptIndex=0,this.savedScripts=new Map,this.nextScriptIndex=0,t&&this.initWithJson(t)}initWithJson(t){this.nextScriptIndex=0,t.savedScripts&&t.savedScripts.forEach(t=>{this.addSavedScript(t.name,t.script)}),0==this.savedScripts.size&&this.newSavedScript()}savedScriptToArray(){return Array.from(this.savedScripts.values())}toJSON(){let t={};return t.savedScripts=this.savedScriptToArray(),t}addSavedScript(t,e){let n=this.nextScriptIndex++,i={index:n,name:t,script:e};return this.savedScripts.set(n,i),this.savedScripts.size-1}getSavedScriptWithName(t){let e=void 0;return this.savedScripts.forEach((n,i,o)=>{n.name==t&&(e=n)}),e}newSavedScript(){return this.addSavedScript("<script name>","<script>")}saveScript(t){let e=t.index||this.nextScriptIndex++;t.index=e,this.savedScripts.set(e,t)}deleteSavedScriptWithIndex(t){return this.savedScripts.delete(t),0}}class na{constructor(){this.name="",this.scale=1,this.css="",this.config=new ta,this.scriptConfig=new ea,this.markup="",this.dot=""}initWithJson(t){return this.name=t.name||"<filename>",this.config=new ta(t.config),this.scriptConfig=new ea(t.scriptConfig),this.scale=t.scale||1,this.css=t.css||"\n circle.node-base {\n fill: #D0E5F2;\n stroke: #25C086;\n stroke-width: 3px;\n }\n text.caption {\n fill: #2D5083;\n }\n body {\n background-color: lightgrey;\n }\n circle.node-type-video {\n fill: #FADBD0;\n stroke: #E53D00;\n stroke-width: 3px;\n }\n circle.node-type-ask {\n fill: #FADBD0;\n stroke: #E53D00;\n stroke-width: 3px;\n }\n circle.node-type-imageCancel {\n fill: #FCF1D0;\n stroke: #F0B500;\n stroke-width: 3px;\n }\n circle.node-type-image {\n fill: #FCF1D0;\n stroke: #F0B500;\n }\n circle.node-type-launch {\n fill: #FCF1D0;\n stroke: #F0B500;\n }\n circle.node-type-tts {\n fill: #D0E5F2;\n stroke: #0072BC;\n stroke-width: 3px;\n }\n circle.node-type-nav {\n fill: #D7F3E9;\n stroke: #25C086;\n stroke-width: 3px;\n }\n circle.node.overlay:hover {\n fill: rgba(150, 150, 255, 0.5);\n }\n circle.node.ring:hover {\n stroke: rgba(150, 150, 255, 0.5);\n }\n path.relationship.overlay:hover {\n fill: rgba(150, 150, 255, 0.5);\n stroke: rgba(150, 150, 255, 0.5);\n }\n",this.d3Graph=t.d3Graph,this.markup=t.markup,this.dot=t.dot,this}toJSON(){let t={};return t.name=this.name,t.type=na.DEFAULT_TYPE,t.scale=this.scale||1,t.css=this.css,t.config=this.config,t.scriptConfig=this.scriptConfig,t.d3Graph=this.d3Graph,t.markup=this.markup,t.dot=this.dot,t}get type(){return na.DEFAULT_TYPE}}na.DEFAULT_QUERY="",na.DEFAULT_TYPE="file";const ia=n(9),oa=n(5),aa=n(6),sa=n(14);class ra{constructor(t){this.model=t,this.graphNames=new Map}addGraph(t){return this.graphNames.set(t.name,void 0),t}getGraphNames(){return Array.from(this.graphNames.keys())}loadGraphNames(){return new Promise((t,e)=>{let n=oa.resolve(this.model.userDataPath);sa(oa.resolve(this.model.userDataPath),493,i=>{i?e(i):ia.readdir(n,(i,o)=>{i?(console.log(`loadGraphNames: error reading files in: ${n}`),e(i)):(o.forEach(t=>{let e=oa.basename(t,".json");this.graphNames.set(e,void 0)}),t())})})})}removeGraphName(t){this.graphNames.delete(t)}deleteGraph(t){return new Promise((e,n)=>{let i=this.generateFilepathWithName(t.name);ia.unlink(i,i=>{i?n(i):(this.removeGraphName(t.name),e())})})}saveGraph(t){return new Promise((e,n)=>{let i=t.toJSON();sa(oa.resolve(this.model.userDataPath),493,o=>{if(o)n(o);else{let o=this.generateFilepathWithName(t.name);this.save(o,i,i=>{i?n(i):e(t)})}})})}loadGraphWithPath(t){return new Promise((e,n)=>{let i=oa.resolve(t);console.log("resolvedFilepath: ",i),this.load(i,(t,i)=>{if(t)n(t);else{let t=new na;t.initWithJson(i),e(t)}})})}loadGraphWithName(t){return new Promise((e,n)=>{let i=this.generateFilepathWithName(t);this.load(i,(t,i)=>{if(t)n(t);else{let t=new na;t.initWithJson(i),e(t)}})})}generateFilepathWithName(t){return oa.resolve(this.model.userDataPath,`${t}.json`)}load(t,e){aa.readFile(t,(t,n)=>{t?e(t):e(t,n)})}save(t,e,n){let i=(new Date).getTime();e.timestamp=i,aa.writeFile(t,e,{spaces:2},t=>{n(t||null)})}}const la=n(37);class ha{constructor(){this.dataTypes=new Bo.DataTypes}static convert(t){return{}}static parseDot(t,e,n){let i=new Bo.Model(e),o=la.read(t);return o.nodes().forEach(t=>{let e=i.createNode(t);n&&(e.x=n.x,e.y=n.y),e.caption=t}),o.edges().forEach(t=>{let e=t.v,n=t.w;i.createRelationship(i.lookupNode(e),i.lookupNode(n)).relationshipType=t.name||""}),i}}class ca extends y.EventEmitter{constructor(t,e=0,n=0,i=0){super(),this._id=t,this._opened=!1,this._x=e,this._y=n,this._z=i}open(){this._opened=!0}close(){this.saveStyle(),this._opened=!1}get opened(){return this._opened}toggleOpened(){return this._opened?this.close():this.open(),this._opened}get id(){return this._id}get x(){let t=document.getElementById(this._id);return t&&t.style&&(this._x=t.getBoundingClientRect().left),this._x}get y(){let t=document.getElementById(this._id);return t&&t.style&&(this._y=t.getBoundingClientRect().top),this._y}get z(){return this._z}set z(t){this._z=t;let e=document.getElementById(this._id);e&&e.style&&(e.style.zIndex=`${this._z}`)}saveStyle(){let t=document.getElementById(this._id);t&&t.style&&(this._x=t.getBoundingClientRect().left,this._y=t.getBoundingClientRect().top,this._z=Number(window.getComputedStyle(t).zIndex))}restoreStyle(){let t=document.getElementById(this._id);t&&t.style&&(t.style.left=`${this._x}px`,t.style.top=`${this._y}px`,t.style.zIndex=`${this._z}`)}static init(){}static getWindowComponentWithId(t){return ca.windowMap.get(t)}static swapZIndex(t,e){let n=t.z;t.z=e.z,e.z=n}static openWithId(t){let e=ca.getWindowComponentWithId(t);e&&e.open()}static closeWithId(t){let e=ca.getWindowComponentWithId(t);e&&e.close()}static toggleOpenedWithId(t){let e=ca.getWindowComponentWithId(t);return!!e&&e.toggleOpened()}static bringWindowToFrontWithId(t){let e=ca.getWindowComponentWithId(t),n=void 0,i=Array.from(ca.windowMap.values());e&&i&&(n=i[0],i.forEach(t=>{t&&n&&t.z>n.z&&(n=t)})),e&&n&&ca.swapZIndex(e,n)}static addWindowComponent(t){ca.windowMap.set(t.id,t)}static addWindowWithId(t,e=0,n=0,i=0){let o=ca.windowMap.get(t);return o?o.restoreStyle():((o=new ca(t,e,n,i)).saveStyle(),o.z=ca.nextZIndex++,ca.addWindowComponent(o)),o}}ca.windowMap=new Map,ca.nextZIndex=200;const da=n(36).pd,ua=n(38);class pa extends y.EventEmitter{constructor(){super(),this.userDataPath="",this.appDimensions={width:1280,height:720},this._globalStateData={global:!0,robot:void 0},this.settings=new Zo,this.userDataPath=this.settings.userDataPath,this.settings.load((t,e)=>{t||!this.settings.data?(this.settings.data={},console.log("GraphModel: Settings not found. Using default.",this.settings.data),this.initWithData(this.settings.data),this.saveSettings()):this.initWithData(this.settings.data),this.graphSet=new ra(this),this.graphSet.loadGraphNames().then(()=>{this.emit("ready",this),this.newBlankGraph()})})}parseMarkup(t){var e=ne("body").append("div");e.node().innerHTML=t;var n=Bo.Markup.parse(e.select("ul.graph-diagram-markup"));return e.remove(),n}newBlankGraph(t){let e=document.getElementById("svgElement"),n=e?e.clientWidth/2:this.appDimensions.width/2,i=e?e.clientHeight/2:this.appDimensions.height/2,o={name:t},a=(new na).initWithJson(o);this.graphDiagramModel=new Bo.Model;let s=this.graphDiagramModel.createNode();s.x=n,s.y=i,s.caption="New Node",this._activeNode=this.graphDiagramModel.nodeList()[0],this._activeRelationship=void 0,this.activeGraph=a,this.applyActiveGraphCss(),this.onUpdateActiveGraph(),t&&this.graphSet&&(this.graphSet.addGraph(a),this.initGraph(a),this.saveGraph(a))}newGraphWithOptions(t){console.log("newGraphWithOptions: ",t);let e=(new na).initWithJson(t);this.graphSet&&(this.graphSet.addGraph(e),this.initGraph(e),this.saveGraph(e))}initGraphWithName(t){this.graphSet&&this.graphSet.loadGraphWithName(t).then(t=>{this.initGraph(t)})}initGraphWithPath(t){return new Promise((e,n)=>{console.log(`initGraphWithPath: ${t}`),this.graphSet&&this.graphSet.loadGraphWithPath(t).then(t=>{this.initGraph(t),e(t)}).catch(t=>{n(t)})})}getSvgOrigin(){let t=document.getElementById("svgElement");return{x:t?t.clientWidth/2:this.appDimensions.width/2,y:t?t.clientHeight/2:this.appDimensions.height/2}}initGraph(t){switch(t.type){case"file":t.d3Graph?this.graphDiagramModel=Bo.ModelToD3.parseD3(t.d3Graph,void 0,this.getSvgOrigin()):t.markup?this.graphDiagramModel=this.parseMarkup(t.markup):t.dot&&(this.graphDiagramModel=ha.parseDot(t.dot,void 0,this.getSvgOrigin())),this.graphDiagramModel&&(this._activeNode=this.graphDiagramModel.nodeList()[0],this._activeRelationship=this.graphDiagramModel.relationshipList()[0]),this.activeGraph=t,this.applyActiveGraphCss(),this.onUpdateActiveGraph()}}saveActiveNode(t,e,n){console.log("GraphModel: saveActiveNode: ",t,e,n,this.activeGraph),this._activeNode&&(this._activeNode.caption=t,this._activeNode.properties.clearAll(),e.split("\n").forEach(t=>{let e=t.split(/:(.*)/);if(console.log(t,e),e.length>=2){var n=e[0].trim(),i=e[1].trim();n.length>0&&i.length>0&&this._activeNode&&this._activeNode.properties.set(n,i)}}))}saveActiveRelationship(t,e){this._activeRelationship&&(this._activeRelationship.relationshipType=t,this._activeRelationship.properties.clearAll(),e.split("\n").forEach(t=>{let e=t.split(/: */);if(2===e.length){var n=e[0].trim(),i=e[1].trim();this._activeRelationship&&n.length>0&&i.length>0&&this._activeRelationship.properties.set(n,i)}}))}reverseActiveRelationship(){this._activeRelationship&&this.activeGraph&&(this._activeRelationship.reverse(),this.onRedraw())}onUpdateActiveGraph(t){this.emit("updateActiveGraph")}onUpdateActiveNode(t){let e={label:this.getActiveNodeLabel(),properties:this.getActiveNodePropertiesAsText()};this.emit("updateActiveNode",e)}onUpdateActiveRelationship(t){let e={label:this.getActiveRelationshipLabel(),properties:this.getActiveRelationshipPropertiesAsText()};this.emit("updateActiveRelationship",e)}onRedraw(){this.emit("redrawGraph",this)}initWithData(t){this.appSettingsData=t}get json(){return this.appSettingsData}saveSettings(){this.settings.data=this.json,this.settings.save(t=>{t?console.log("GraphModel: Error saving settings: ",t):console.log("GraphModel: Settings saved.")})}getMarkup(){var t=ne("body").append("div"),e="";return this.graphDiagramModel&&(Bo.Markup.format(this.graphDiagramModel,t),e=(e=t.node().innerHTML).replace(/<li/g,"\n <li").replace(/<span/g,"\n <span").replace(/<\/span><\/li/g,"</span>\n </li").replace(/<\/ul/,"\n</ul"),t.remove()),e}getD3(){return this.graphDiagramModel?JSON.stringify(Bo.ModelToD3.convert(this.graphDiagramModel),null,2):""}getSVG(){let t=ne("#svgContainer svg");t.select("g").attr("id","firstg");let e=t.select("#firststyle");e.empty()&&(e=t.insert("style","#firstg").attr("id","firststyle")),e.html(this.getCSS());let n=ne("#svgContainer svg").node(),i=(new XMLSerializer).serializeToString(n);return da.xml(i)}getCSS(){let t=this.activeGraph?this.activeGraph.css:"";return da.css(t)}getSavedTTSList(){let t=[];if(this.activeGraph){t=this.activeGraph.config.savedTTSToArray()}return t}newSavedTTS(){let t=0;if(this.activeGraph){t=this.activeGraph.config.addSavedTTS("<prompt name>","<prompt>")}return t}deleteSavedTTS(t){if(this.activeGraph){this.activeGraph.config.deleteSavedTTSWithIndex(t.index)}return 0}sendTTS(t){console.log("GraphModel: sendTTS:",t),this.emit("tts",t)}getSavedScriptList(){let t=[];if(this.activeGraph){t=this.activeGraph.scriptConfig.savedScriptToArray()}return t}newSavedScript(){let t=0;if(this.activeGraph){t=this.activeGraph.scriptConfig.addSavedScript("<script name>","<script>")}return t}deleteSavedScript(t){if(this.activeGraph){this.activeGraph.scriptConfig.deleteSavedScriptWithIndex(t.index)}return 0}get activeRobot(){return this._activeRobot&&!this._activeRobot.connected&&(this._activeRobot=void 0),this._activeRobot}set activeRobot(t){this._activeRobot=t}executeScriptWithName(t,e,n){let i=void 0;if(this.activeGraph){let o=this.activeGraph.scriptConfig;console.log("GraphModel: executeScriptWithName: scriptConfig:",o);let a=o.getSavedScriptWithName(t);a?i=this.executeScript(a,e,n):console.log(`executeScriptWithName: error: no script found with name: ${t}`)}return i}executeScript(t,e,n){console.log("GraphModel: executeScript:",t,e,n);let i={};return e?i=this.evaluateScriptWithData(t.script,e.stateData):(n||(n=this._globalStateData),i=this.evaluateScriptWithData(t.script,n)),console.log("GraphModel: executeScript: output:",i),i}evaluateTTS(t,e){let n="",i="`"+t+"`";return n=e&&e.stateData?this.evaluateScriptWithData(i,e.stateData).result:this.evaluateScriptWithData(i,this._globalStateData).result}evaluateScriptWithData(t,e){let n;n=this.getSandbox(e);try{return{result:ua.runInContext(t,n),sandbox:n}}catch(n){return console.log(`evaluateScriptWithData: error evaluating: ${t}: ${e} - error: ${n.message}`),{result:"",sandbox:{}}}}getSandbox(t){return ua.createContext(t)}deleteStateData(t){t?t.stateData={}:this._globalStateData={}}saveStateData(t,e){t?t.stateData=e:this._globalStateData=e}get globalStateData(){return this._globalStateData}set activeNode(t){this._activeNode=t,this.onUpdateActiveNode()}get activeNode(){return this._activeNode}set newNode(t){this._newNode=t}get newNode(){return this._newNode}onDragRing(t,e){var n=t.model;if(this._newNode||(this._newNode=this.addLocalNode(e.x,e.y),this._newNode&&(this._newRelationship=this.addLocalRelationship(n,this._newNode))),this._newNode&&this._newRelationship){var i=this.findClosestOverlappingNode(this._newNode);this._newRelationship.end=i||this._newNode,this._newNode.drag(e.dx,e.dy)}}async onDragEnd(){this._newNode&&this._newRelationship&&this.activeGraph&&(this._newNode.dragEnd(),this._newRelationship&&this._newRelationship.end!==this._newNode&&this.deleteLocalNode(this._newNode)),this._newNode=void 0,this._newRelationship=void 0}findClosestOverlappingNode(t){var e=void 0,n=Number.MAX_VALUE;if(this.graphDiagramModel)for(var i=this.graphDiagramModel.nodeList(),o=0;o<i.length;o++){var a=i[o];if(a!==t){var s=t.distanceTo(a)*this.graphDiagramModel.internalScale;s<50&&s<n&&(e=a,n=s)}}return e}set activeRelationship(t){this._activeRelationship=t,this.onUpdateActiveRelationship()}get activeRelationship(){return this._activeRelationship}set newRelationship(t){this._newRelationship=t}get newRelationship(){return this._newRelationship}getActiveRelationshipLabel(){let t="";return this._activeRelationship&&this._activeRelationship.relationshipType&&(t=this._activeRelationship.relationshipType),t}getActiveRelationshipPropertiesAsText(){let t="";return this._activeRelationship&&this._activeRelationship.properties.listEditable().length>0&&(t=this._activeRelationship.properties.listEditable().reduce((t,e)=>t+e.key+": "+e.value+"\n","")),t}getActiveNodeLabel(){return this._activeNode?this._activeNode.caption:""}getActiveNodePropertiesAsText(){let t="";return this._activeNode&&this._activeNode.properties.listEditable().length>0&&(t=this._activeNode.properties.listEditable().reduce((t,e)=>t+e.key+": "+e.value+"\n","")),t}addLocalNode(t,e){var n=document.getElementById("svgElement");return n&&this.graphDiagramModel?(t=t||n.clientWidth/2,e=e||n.clientHeight/2,this._activeNode=this.graphDiagramModel.createNode(),this._activeNode.x=t,this._activeNode.y=e,this._activeNode):void 0}addNode(t,e){return this._activeNode=this.addLocalNode(t,e),this.onRedraw(),this._activeNode}addLocalRelationship(t,e){let n=void 0;return this.graphDiagramModel&&this.activeGraph&&(n=this.graphDiagramModel.createRelationship(t,e)),n}deleteLocalNode(t){this.graphDiagramModel&&(this.graphDiagramModel.deleteNode(t),t==this._newNode&&(this._newNode=void 0))}deleteActiveNode(){this._activeNode&&this.activeGraph&&this.graphDiagramModel&&(this.graphDiagramModel.deleteNode(this._activeNode),this.onRedraw())}deleteActiveRelationship(){this._activeRelationship&&this.activeGraph&&this.graphDiagramModel&&(this.graphDiagramModel.deleteRelationship(this._activeRelationship),this.onRedraw())}applyActiveGraphCss(t){if(this.activeGraph){this.activeGraph.css=t||this.activeGraph.css;let e=document.getElementById("graph-editor-style");e&&(e.innerHTML=da.css(this.activeGraph.css))}}saveActiveGraph(){this.activeGraph&&this.saveGraph(this.activeGraph)}saveGraph(t){t&&this.graphDiagramModel&&this.graphSet&&("file"==t.type&&(t.d3Graph=Bo.ModelToD3.convert(this.graphDiagramModel)),this.graphSet.saveGraph(t))}getPanelOpenedWithId(t){let e=!1,n=ca.getWindowComponentWithId(t);return n&&(e=n.opened),e}togglePanelOpenedWithId(t){let e=ca.getWindowComponentWithId(t);return!e||e.toggleOpened()}openPanelWithId(t){ca.openWithId(t)}closePanelWithId(t){ca.closeWithId(t)}bringPanelToFront(t){ca.addWindowWithId(t),ca.bringWindowToFrontWithId(t)}addPanelWithId(t,e=0,n=0,i=0){ca.addWindowWithId(t,e,n,i)}dispose(){}}const ma=n(10);let ga,fa,va,ba,ya,wa,Sa,ka,_a,Ma=0;class Ca extends i.Component{constructor(t){super(t),this._clickHandler=this.clicked.bind(this),this._dragStartHandler=this.dragStart.bind(this),this._dragEndHandler=this.dragEnd.bind(this),this._dragNodeHandler=this.dragNode.bind(this),this._dragRingHandler=this.dragRing.bind(this),this._editRelationshipHandler=this.editRelationship.bind(this),this._onUpdateActiveGraphHandler=this.onUpdateActiveGraph.bind(this),this._onRedrawGraphHandler=this.onRedrawGraph.bind(this),this._onRobotIntentHandler=this.onRobotIntent.bind(this),this.graphModel=new pa,this.graphModel.on("ready",()=>{console.log("GraphEditor: constructor: ready"),this.graphModel.on("redrawGraph",this._onRedrawGraphHandler),this.graphModel.on("updateActiveGraph",this._onUpdateActiveGraphHandler)}),this.graphModel.on("tts",t=>{console.log("GraphEditor: on tts: ",t),this.props.commanderModel.sendTTS(t.prompt)})}componentWillMount(){ga=this,this.setState({scale:1,showNodePanel:!1,showRelationshipPanel:!1,showTTSPanel:!1,showScriptPanel:!1,showStateDataPanel:!1,autoScroll:!0,lastUpdateTime:0}),this.props.commanderModel.on("robotIntent",this._onRobotIntentHandler)}componentDidMount(){this.graphModel.addPanelWithId("ttsPanel",520,150),this.graphModel.addPanelWithId("scriptPanel",520,150),this.graphModel.addPanelWithId("stateDataPanel",520,150)}componentWillUnmount(){this.graphModel.removeListener("redrawGraph",this._onRedrawGraphHandler),this.graphModel.removeListener("updateActiveGraph",this._onUpdateActiveGraphHandler),this.props.commanderModel.removeListener("robotIntent",this._onRobotIntentHandler)}componentWillReceiveProps(t){}initGraphEditor(){this.diagram=(new Bo.Diagram).scaling(null).overlay(function(t,e){var n=(e=ne("svg").select("g.layer.overlay")).selectAll("circle.node.overlay").data(t.nodes);n.exit().remove();var i=n.enter().append("circle").attr("class","node overlay");n.merge(i).call(Ce().on("start",ga._dragStartHandler).on("drag",ga._dragNodeHandler).on("end",ga._dragEndHandler)).on("click",ga._clickHandler).attr("r",function(t){return t.radius.outside()}).attr("stroke","none").attr("fill","rgba(255, 255, 255, 0)").attr("cx",function(t){return t.model.ex()}).attr("cy",function(t){return t.model.ey()});var o=e.selectAll("circle.node.ring").data(t.nodes);o.exit().remove();var a=o.enter().append("circle").attr("class","node ring");o.merge(a).call(Ce().on("drag",ga._dragRingHandler).on("end",ga._dragEndHandler)).attr("r",function(t){return t.radius.outside()+5}).attr("fill","none").attr("stroke","rgba(255, 255, 255, 0)").attr("stroke-width","10px").attr("cx",function(t){return t.model.ex()}).attr("cy",function(t){return t.model.ey()});var s=e.selectAll("path.relationship.overlay").data(t.relationships);s.exit().remove();var r=s.enter().append("path").attr("class","relationship overlay");s.merge(r).attr("fill","rgba(255, 255, 255, 0)").attr("stroke","rgba(255, 255, 255, 0)").attr("stroke-width","10px").on("dblclick",ga._editRelationshipHandler).attr("transform",function(t){var e=t.start.model.angleTo(t.end.model);return"translate("+t.start.model.ex()+","+t.start.model.ey()+") rotate("+e+")"}).attr("d",function(t){return t.arrow.outline})}),this.draw(),this.setState({scale:1,showNodePanel:!1,showRelationshipPanel:!1})}onUpdateActiveGraph(){this.setupSvg(),this.initGraphEditor()}onRedrawGraph(){this.draw()}onRobotIntent(t){let e=t.robot,n=t.type,i=t.data,o=i.nluData;console.log(`GraphEditor: onRobotIntent: ${O[n]}`,e,i),console.log(" --: activeNode: ",this.graphModel.activeNode),e&&(this.graphModel.activeRobot=e),e&&o&&o.parameters&&(console.log("GraphEditor: onRobotIntent: updating robot state data:",o.parameters),e.updateStateData(o.parameters),console.log(e.stateData));let a=this.graphModel.activeNode;if(a&&i&&e){let t=a.model,e=[];switch(n){case O.LAUNCH:let o=[];t.nodeList().forEach(t=>{"launch"==t.label&&o.push(t)}),o.forEach(t=>{let n=this.getCandidateNodes(t,i.intent);e=e.concat(n)});break;case O.LISTEN:case O.ACTION_COMPLETE:e=this.getCandidateNodes(a,i.intent)}let o=e[0];o&&this.executeNode(o,this.graphModel.activeRobot)}}getCandidateNodes(t,e){let n=[];if(t){let i;(i=t.model.relationshipList()).forEach(i=>{i.start==t&&i.relationshipType==e&&(console.log(`queuing next node: ${i.end.label}`,i.end),n.push(i.end))})}return n}addNode(){this.graphModel.addNode()}clicked(t,e){if(!qt.defaultPrevented){var n=t.model;qt.shiftKey?this.editNode(n):this.executeNode(n,this.graphModel.activeRobot)}}dragStart(t){this.graphModel.newNode=void 0}dragNode(t){t.model.drag(qt.dx,qt.dy),this.draw()}dragRing(t){this.graphModel.onDragRing(t,qt),this.draw()}dragEnd(){this.graphModel.onDragEnd(),this.draw()}editNode(t){this.showNodePanel(),this.graphModel.activeNode=t}executeNode(t,e){console.log(t),this.graphModel.activeNode=t;let n,i=[];if((n=t.model.relationshipList()).forEach(e=>{e.start==t&&(console.log(`nextNode: ${e.end.label}: (${e.end.x}, ${e.end.y})`),i.push({x:e.end.x,y:e.end.y}))}),this.state.autoScroll&&va){let t=Ki(va);if(i.length){let e=i.reduce((t,e)=>({x:t.x+e.x,y:t.y+e.y}));console.log(e);let n=e.x/i.length,o=e.y/i.length;t.x=this.graphModel.appDimensions.width/2-n,t.y=this.graphModel.appDimensions.height/2-o,console.log(t),va.transition().duration(750).call(ya.translateTo,this.graphModel.appDimensions.width/2,this.graphModel.appDimensions.height/2)}}if(t){let n,i,f=t.properties.has("scriptName"),v=t.properties.has("scriptContext");if(v)try{n=ma(v)}catch(t){console.log("GraphEditor: executeNode: error: ",t)}f&&(i=n?this.graphModel.executeScriptWithName(f,void 0,n):this.graphModel.executeScriptWithName(f,e),console.log("GraphEditor: executeNode: scriptOutput: ",i));let b=t.properties.has("robotCommand");if(!b&&i&&i.sandbox&&i.sandbox.robotCommand&&(b=i.sandbox.robotCommand),console.log("robotCommand: robotCommand: ",b),b){let t;try{(t=ma(b)).type&&t.data&&(console.log("robotCommand: sending: ",t),this.props.commanderModel.sendRomCommandWithData(t,e))}catch(t){console.log(t)}}switch(t.label){case"tts":case"esml":var o=t.properties.has("text")||t.properties.has("prompt")||t.properties.has("esml");(o=this.graphModel.evaluateTTS(o,e))&&this.props.commanderModel.sendTTS(o,e);break;case"ask":o=t.properties.has("text")||t.properties.has("prompt")||t.properties.has("esml");o=this.graphModel.evaluateTTS(o,e);var a=t.properties.has("context"),s=[];a&&(s=[a]);var r=t.properties.has("nluType");o&&this.props.commanderModel.sendAsk(o,s,r,e);break;case"lookAt":var l,h,c=t.properties.has("angle"),d=t.properties.has("vector");if(c)l=Number(c),this.props.commanderModel.sendLookAt({angle:l},e);else if(d)try{h=ma(d),this.props.commanderModel.sendLookAt({vector:h},e)}catch(t){console.log("executeNode: error parsing vectorProperty")}break;case"volume":var u=Number(t.properties.has("volume"));u&&this.props.commanderModel.sendRomCommandWithData({type:"volume",data:{volume:u}},e);break;case"attention":var p=Number(t.properties.has("state"));p&&this.props.commanderModel.sendRomCommandWithData({type:"attention",data:{state:p}},e);break;case"image":var m=t.properties.has("url"),g=t.properties.has("name")||"image";m&&this.props.commanderModel.sendRomCommandWithData({type:"image",data:{url:m,name:g}},e);break;case"eye":this.props.commanderModel.sendRomCommandWithData({type:"eye",data:{}},e)}}}editRelationship(t){this.showRelationshipPanel(),this.graphModel.activeRelationship=t.model}setupSvg(){if(va&&(ne("svg").remove(),va=void 0,ba=void 0),fa=ne("#svgContainer"),va=fa.append("svg:svg")){ya=io();let t=Ki(va);t.k=1,t.x=0,t.y=0,ba=va.attr("class","graphdiagram").attr("id","svgElement").attr("width","100%").attr("height","100%").call(ya.on("zoom",function(){ba&&ba.attr("transform",qt.transform)})).on("dblclick.zoom",null).append("g")}var t=document.getElementById("svgElement");let e=t?t.clientWidth/2:this.graphModel.appDimensions.width/2,n=t?t.clientHeight/2:this.graphModel.appDimensions.height/2;var i="#999999";ba&&(ba.append("line").attr("x1",e-5).attr("y1",n).attr("x2",e+5).attr("y2",n).style("stroke",i).style("stroke-opacity",.5).style("stroke-width","1px"),ba.append("line").attr("x1",e).attr("y1",n-5).attr("x2",e).attr("y2",n+5).style("stroke",i).style("stroke-opacity",.5).style("stroke-width","1px"))}generateSimData(t){let e=t.layout.layoutModel.nodes,n=t.layout.layoutModel.relationships,i=[],o=[],a={},s=0;return e.forEach(t=>{let e={};e.layoutNode=t,e.r=2*t.radius.insideRadius,a[t.model.id]=s++,i.push(e)}),n.forEach(t=>{let e={};e.layoutRelationship=t,e.source=a[t.start.model.id],e.target=a[t.end.model.id],o.push(e)}),{nodes:i,links:o}}startSimulation(t){Ma=0,Sa=t||100;var e=document.getElementById("svgElement");let n=e?e.clientWidth/2:this.graphModel.appDimensions.width/2,i=e?e.clientHeight/2:this.graphModel.appDimensions.height/2;wa=Ao().force("link",xo().id(function(t){return t.index})).force("collide",bo(function(t){return t.r+25})).force("charge",Ro()).force("center",oo(n,i)).force("y",Lo(.001)).force("x",Po(.001)),ga.diagram&&(_a=ga.generateSimData(ga.diagram)),ba&&(ka=ba.select("g.layer.nodes").selectAll("circle").data(_a.nodes),ba.select("g.layer.node_properties").attr("display","none"),ba.select("g.layer.relationships").attr("display","none"),ba.select("g.layer.relationship_properties").attr("display","none"),ba.select("g.layer.nodes").selectAll("g.caption").attr("display","none")),wa.nodes(_a.nodes).on("tick",ga.ticked).on("end",ga.ended),wa.force("link").links(_a.links)}ticked(){ka.attr("cx",function(t){return t.x}).attr("cy",function(t){return t.y}),++Ma>=Sa&&ga.ended()}ended(){wa.stop(),_a.nodes.forEach(t=>{t.layoutNode.x=t.x,t.layoutNode.y=t.y,t.layoutNode.model.x=t.x,t.layoutNode.model.y=t.y}),ba&&(ba.select("g.layer.node_properties").attr("display","block"),ba.select("g.layer.relationships").attr("display","block"),ba.select("g.layer.relationship_properties").attr("display","block"),ba.select("g.layer.nodes").selectAll("g.caption").attr("display","block")),ga.draw()}draw(){this.diagram&&ba&&ba.data([this.graphModel.graphDiagramModel]).call(this.diagram.render)}onButtonClicked(t){switch(t){case"addNode":this.addNode();break;case"bubbles":this.diagram&&(this.diagram.toggleRenderPropertyBubblesFlag(),this.draw());break;case"forceLayout":this.startSimulation(100);break;case"ttsPanel":this.setState({showTTSPanel:this.graphModel.togglePanelOpenedWithId("ttsPanel")}),this.graphModel.bringPanelToFront("ttsPanel");break;case"scriptPanel":this.setState({showScriptPanel:this.graphModel.togglePanelOpenedWithId("scriptPanel")}),this.graphModel.bringPanelToFront("scriptPanel");break;case"stateDataPanel":this.setState({showStateDataPanel:this.graphModel.togglePanelOpenedWithId("stateDataPanel")}),this.graphModel.bringPanelToFront("stateDataPanel")}}handleCheckboxChange(t){this.setState(t=>({autoScroll:!t.autoScroll}))}changeInternalScale(){var t=ne("#internalScale").node();this.graphModel.graphDiagramModel&&(this.graphModel.graphDiagramModel.internalScale=t.value,this.setState({scale:t.value}),this.draw())}showNodePanel(){this.setState({showNodePanel:!0}),this.graphModel.openPanelWithId("nodeEditorPanel"),this.graphModel.bringPanelToFront("nodeEditorPanel")}showRelationshipPanel(){this.setState({showRelationshipPanel:!0}),this.graphModel.openPanelWithId("relationshipEditorPanel"),this.graphModel.bringPanelToFront("relationshipEditorPanel")}onClosePanel(t){switch(this.graphModel.closePanelWithId(t),t){case"nodeEditorPanel":this.setState({showNodePanel:!1});break;case"relationshipEditorPanel":this.setState({showRelationshipPanel:!1});break;case"ttsPanel":this.setState({showTTSPanel:!1});break;case"scriptPanel":this.setState({showScriptPanel:!1});break;case"stateDataPanel":this.setState({showStateDataPanel:!1})}}render(){let t=this.state.showNodePanel?i.createElement(Jo,{id:"nodeEditorPanel",graphModel:this.graphModel,onClosePanel:this.onClosePanel.bind(this)}):null,e=this.state.showRelationshipPanel?i.createElement(Vo,{id:"relationshipEditorPanel",graphModel:this.graphModel,onClosePanel:this.onClosePanel.bind(this)}):null,n=this.state.showTTSPanel?i.createElement(Fo,{id:"ttsPanel",graphModel:this.graphModel,onClosePanel:this.onClosePanel.bind(this)}):null,o=this.state.showScriptPanel?i.createElement(Oo,{id:"scriptPanel",graphModel:this.graphModel,onClosePanel:this.onClosePanel.bind(this)}):null,s=this.state.showStateDataPanel?i.createElement(qo,{id:"stateDataPanel",graphModel:this.graphModel,targetedRobots:this.props.commanderModel.targetedRobots,onClosePanel:this.onClosePanel.bind(this)}):null;return i.createElement("div",{id:"graphEditorContainer"},i.createElement("div",{id:"svgContainer"}),i.createElement("div",{id:"graphEditorButtons",className:"well"},i.createElement(a.Button,{id:"addNodeButton",bsStyle:"default",key:"addNode",style:{width:80},onClick:this.onButtonClicked.bind(this,"addNode")},i.createElement(ct.a,{name:"plus"})," Node"),i.createElement(a.Button,{id:"bubblesButton",bsStyle:"default",key:"bubbles",style:{width:80},onClick:this.onButtonClicked.bind(this,"bubbles")},"Bubbles"),i.createElement(a.Button,{id:"ttsPanelButton",bsStyle:"default",key:"ttsPanel",onClick:this.onButtonClicked.bind(this,"ttsPanel")},"SavedTTS"),i.createElement(a.Button,{id:"scriptPanelButton",bsStyle:"default",key:"scriptPanel",onClick:this.onButtonClicked.bind(this,"scriptPanel")},"Scripts"),i.createElement(a.Button,{id:"stateDataPanelButton",bsStyle:"default",key:"stateDataPanel",onClick:this.onButtonClicked.bind(this,"stateDataPanel")},"State"),i.createElement(lt,{label:"AutoScroll",isChecked:!0,handleCheckboxChange:this.handleCheckboxChange.bind(this)})),i.createElement(jo,{graphModel:this.graphModel}),t,n,o,s,e)}}const{shell:Ea}=n(11).remote,xa=n(39);class Ia extends i.Component{componentWillMount(){this.setState({showAppInfoPanel:!1,showRobotsPanel:!1,showCommandsPanel:!1,showWozGraphEditor:!1,showBlocklyEditor:!1,lastUpdateTime:0})}componentDidMount(){console.log("Application: componentDidMount"),this.props.model.addPanelWithId("appInfoPanel",10,60),this.props.model.addPanelWithId("robotsPanel",10,60),this.props.model.addPanelWithId("commandsPanel",10,60)}onLogoClicked(){Ea.openExternal("http://robocommander.io")}onButtonClicked(t){switch(t){case"appInfo":this.setState({showAppInfoPanel:this.props.model.togglePanelOpenedWithId("appInfoPanel")}),this.props.model.bringPanelToFront("appInfoPanel");break;case"robots":this.setState({showRobotsPanel:this.props.model.togglePanelOpenedWithId("robotsPanel")}),this.props.model.bringPanelToFront("robotsPanel");break;case"commands":this.setState({showCommandsPanel:this.props.model.togglePanelOpenedWithId("commandsPanel")}),this.props.model.bringPanelToFront("commandsPanel");break;case"wozGraph":this.setState(t=>({showWozGraphEditor:!t.showWozGraphEditor}));break;case"blockly":this.setState(t=>({showBlocklyEditor:!t.showBlocklyEditor}));break;case"save":this.props.model.saveConfig();break;case"reload":this.props.model.reloadConfig()}}onClosePanel(t){switch(this.props.model.closePanelWithId(t),t){case"appInfoPanel":this.setState({showAppInfoPanel:!1});break;case"robotsPanel":this.setState({showRobotsPanel:!1});break;case"commandsPanel":this.setState({showCommandsPanel:!1})}}render(){let t=this.state.showAppInfoPanel?i.createElement(b,{id:"appInfoPanel",appInfo:this.props.model.appInfo,model:this.props.model,onClosePanel:this.onClosePanel.bind(this)}):null,e=this.state.showRobotsPanel?i.createElement(nt,{id:"robotsPanel",robots:this.props.model.robots,appInfo:this.props.model.appInfo,model:this.props.model,onClosePanel:this.onClosePanel.bind(this)}):null,n=this.state.showCommandsPanel?i.createElement(rt,{id:"commandsPanel",model:this.props.model,onClosePanel:this.onClosePanel.bind(this)}):null,o=this.state.showWozGraphEditor?i.createElement(Ca,{commanderModel:this.props.model}):null;return i.createElement("div",null,i.createElement("div",{id:"commanderButtons"},i.createElement("img",{className:"pull-left",src:xa,style:{width:40},onClick:this.onLogoClicked.bind(this)}),i.createElement("h4",{className:"pull-left",style:{paddingLeft:6,paddingRight:6},onClick:this.onLogoClicked.bind(this)},"RoboCommander.io"),i.createElement("h4",{className:"pull-right",style:{paddingLeft:6,paddingRight:6}},"v",this.props.model.getAppVerison()),i.createElement(a.Button,{bsStyle:"default",key:"appInfo",style:{width:100},onClick:this.onButtonClicked.bind(this,"appInfo")},"App Info"),i.createElement(a.Button,{bsStyle:"default",key:"robots",style:{width:100},onClick:this.onButtonClicked.bind(this,"robots")},"Robots"),i.createElement(a.Button,{bsStyle:"default",key:"commands",style:{width:100},onClick:this.onButtonClicked.bind(this,"commands")},"Commands"),i.createElement(a.Button,{bsStyle:"default",key:"wozGraph",style:{width:100},onClick:this.onButtonClicked.bind(this,"wozGraph")},"WozGraph"),i.createElement(a.Button,{bsStyle:"success",key:"save",style:{width:100},onClick:this.onButtonClicked.bind(this,"save")},"Save Config"),i.createElement(a.Button,{bsStyle:"info",key:"reload",style:{width:120},onClick:this.onButtonClicked.bind(this,"reload")},"Reload Config")),o,null,n,e,t)}}const Na=7160;class Ta{constructor(t){this.port=Na,this.clientId="",this.clientSecret="",this.nluDefault="",this.nluLUIS_endpoint="",this.nluLUIS_appId="",this.nluLUIS_subscriptionKey="",this.nluDialogflow_clientToken="",this.nluDialogflow_projectId="",this.nluDialogflow_privateKey="",this.nluDialogflow_clientEmail="",this.neo4j_url="",this.neo4j_user="",this.neo4j_password="",t=t||{port:this.port,clientId:this.clientId,clientSecret:this.clientSecret,nluDefault:this.nluDefault,nluLUIS_endpoint:this.nluLUIS_endpoint,nluLUIS_appId:this.nluLUIS_appId,nluLUIS_subscriptionKey:this.nluLUIS_subscriptionKey,nluDialogflow_clientToken:this.nluDialogflow_clientToken,nluDialogflow_projectId:this.nluDialogflow_projectId,nluDialogflow_privateKey:this.nluDialogflow_privateKey,nluDialogflow_clientEmail:this.nluDialogflow_clientEmail,neo4j_url:this.neo4j_url,neo4j_user:this.neo4j_user,neo4j_password:this.neo4j_password},this.initWithData(t)}initWithData(t){this.port=t.port,this.clientId=t.clientId,this.clientSecret=t.clientSecret,this.nluDefault=t.nluDefault,this.nluLUIS_endpoint=t.nluLUIS_endpoint,this.nluLUIS_appId=t.nluLUIS_appId,this.nluLUIS_subscriptionKey=t.nluLUIS_subscriptionKey,this.nluDialogflow_clientToken=t.nluDialogflow_clientToken,this.nluDialogflow_projectId=t.nluDialogflow_projectId,this.nluDialogflow_privateKey=t.nluDialogflow_privateKey,this.nluDialogflow_clientEmail=t.nluDialogflow_clientEmail,this.neo4j_url=t.neo4j_url,this.neo4j_user=t.neo4j_user,this.neo4j_password=t.neo4j_password}get json(){return{port:this.port,clientId:this.clientId,clientSecret:this.clientSecret,nluDefault:this.nluDefault,nluLUIS_endpoint:this.nluLUIS_endpoint,nluLUIS_appId:this.nluLUIS_appId,nluLUIS_subscriptionKey:this.nluLUIS_subscriptionKey,nluDialogflow_clientToken:this.nluDialogflow_clientToken,nluDialogflow_projectId:this.nluDialogflow_projectId,nluDialogflow_privateKey:this.nluDialogflow_privateKey,nluDialogflow_clientEmail:this.nluDialogflow_clientEmail,neo4j_url:this.neo4j_url,neo4j_user:this.neo4j_user,neo4j_password:this.neo4j_password}}}class Da extends y.EventEmitter{constructor(){super(),this.lastUpdateTime=0,this._nextRobotNumber=0,this._robotUpdatedHandler=this.onRobotUpdated.bind(this),this._robotStatusMessageUpdateHandler=this.onRobotStatusMessage.bind(this),this._robotIntentHandler=this.onRobotIntent.bind(this),this.robotList=[],this.robotMap=new Map,this.statusMessages=""}initWithData(t){t.forEach(t=>{let e;t.type==F.robokit?(console.log("Robots: initWithData: new RobokitRobot()"),e=new et):e=new q,e.initWithData(t),this.addRobot(e)})}onRobotUpdated(t){this.emit("updateRobots",this)}onRobotStatusMessage(t){t&&t.message&&t.subsystem&&this.updateRobotsStatusMessages(t.message,t.subsystem)}onRobotIntent(t){this.emit("robotIntent",t)}updateRobotsStatusMessages(t,e,n=!1){return e=e||"",n?this.statusMessages="":this.statusMessages?this.statusMessages=`${this.statusMessages}\n${e}: ${t}`:this.statusMessages=`${e}: ${t}`,this.emit("updateRobots",this),this.statusMessages}get json(){let t=[];return this.robotList.forEach(e=>{t.push(e.json)}),t}get robotNames(){let t=[];return this.robotList.forEach(e=>{t.push(e.name)}),t}get connectedRobots(){let t=[];return this.robotList.forEach(e=>{e.connected&&t.push(e)}),t}get targetedRobots(){let t=[];return this.robotList.forEach(e=>{e.targeted&&t.push(e)}),t}get robotCount(){return this._nextRobotNumber}getRobotWithName(t){return this.robotMap.get(t)}connectRobot(t,e){t.connect(e)}disconnectRobot(t){t.disconnect()}addRobot(t){this.robotList.push(t),this.robotMap.set(t.name,t),t.on("updateRobot",this._robotUpdatedHandler),t.on("statusMessage",this._robotStatusMessageUpdateHandler),t.on("robotIntent",this._robotIntentHandler),this.emit("updateRobots",this)}removeRobot(t){let e=[],n=new Map;this.robotList.forEach(i=>{i!=t&&(e.push(i),n.set(i.name,i))}),this.robotList=e,this.robotMap=n,t.removeListener("updateRobot",this._robotUpdatedHandler),t.removeListener("statusMessage",this._robotStatusMessageUpdateHandler),t.removeListener("robotIntent",this._robotIntentHandler),this.emit("updateRobots",this)}onUpdateStats(t){this.lastUpdateTime=(new Date).getTime(),this.emit("updateStats",this)}getNextRobotInRobotList(t){let e=this.robotList[1],n=this.robotList.indexOf(t);return n>=0&&n<this.robotList.length-1&&(e=this.robotList[n+1]),e}}class Aa{constructor(){this.commandList=[],this.commandMap=new Map}initWithData(t){t.forEach(t=>{let e=new w;e.initWithData(t),this.commandList.push(e),this.commandMap.set(e.name,e)})}get json(){let t=[];return this.commandList.forEach(e=>{t.push(e.json)}),t}get commandNames(){let t=[];return this.commandList.forEach(e=>{t.push(e.name)}),t}getCommandWithName(t){let e,n=this.commandMap.get(t);return n&&(e=new w(n.name,n.type,Object.assign({},n.data))),e}addCommand(t){this.commandList.push(t),this.commandMap.set(t.name,t)}updateCommandWithName(t,e){let n=this.commandMap.get(e.name);n&&(n.data=e.data,n.type=e.type)}removeCommand(t){console.log(`RomCommands: removeCommand: ${t.name}`);let e=[],n=new Map;this.commandList.forEach(i=>{i.name!=t.name&&(e.push(i),n.set(i.name,i))}),this.commandList=e,this.commandMap=n}}const Ra=n(5),Pa=n(14),La=n(13),Ba=n(6);let Wa=Ra.resolve(La.home(),".wwlib"),Ga=Ra.resolve(Wa,"robocommander.json");class za extends y.EventEmitter{constructor(){super(),this._timestamp=0,this._data={}}get data(){return this._data}set data(t){this._data=t}get timestamp(){return this._timestamp}load(t){Pa(Ra.resolve(Wa),493,e=>{e?console.log(`error: ${Wa} cannot be found`):Ba.readFile(Ga,(e,n)=>{e?t(e):(this._data=n,this._timestamp=this._data.timestamp,t(e,n))})})}save(t){this._timestamp=(new Date).getTime(),this._data.timestamp=this._timestamp,Pa(Ra.resolve(Wa),493,e=>{e?console.log(`error: ${Wa} cannot be found`):Ba.writeFile(Ga,this._data,{spaces:2},e=>{t(e||null)})})}}class Ua extends y.EventEmitter{constructor(t,e=0,n=0,i=0){super(),this._id=t,this._opened=!1,this._x=e,this._y=n,this._z=i}open(){this._opened=!0}close(){this.saveStyle(),this._opened=!1}get opened(){return this._opened}toggleOpened(){return this._opened?this.close():this.open(),this._opened}get id(){return this._id}get x(){let t=document.getElementById(this._id);return t&&t.style&&(this._x=t.getBoundingClientRect().left),this._x}get y(){let t=document.getElementById(this._id);return t&&t.style&&(this._y=t.getBoundingClientRect().top),this._y}get z(){return this._z}set z(t){this._z=t;let e=document.getElementById(this._id);e&&e.style&&(e.style.zIndex=`${this._z}`)}saveStyle(){let t=document.getElementById(this._id);t&&t.style&&(this._x=t.getBoundingClientRect().left,this._y=t.getBoundingClientRect().top,this._z=Number(window.getComputedStyle(t).zIndex))}restoreStyle(){let t=document.getElementById(this._id);t&&t.style&&(t.style.left=`${this._x}px`,t.style.top=`${this._y}px`,t.style.zIndex=`${this._z}`)}static init(){}static getWindowComponentWithId(t){return Ua.windowMap.get(t)}static swapZIndex(t,e){let n=t.z;t.z=e.z,e.z=n}static openWithId(t){let e=Ua.getWindowComponentWithId(t);e&&e.open()}static closeWithId(t){let e=Ua.getWindowComponentWithId(t);e&&e.close()}static toggleOpenedWithId(t){let e=Ua.getWindowComponentWithId(t);return!!e&&e.toggleOpened()}static bringWindowToFrontWithId(t){let e=Ua.getWindowComponentWithId(t),n=void 0,i=Array.from(Ua.windowMap.values());e&&i&&(n=i[0],i.forEach(t=>{t&&n&&t.z>n.z&&(n=t)})),e&&n&&Ua.swapZIndex(e,n)}static addWindowComponent(t){Ua.windowMap.set(t.id,t)}static addWindowWithId(t,e=0,n=0,i=0){let o=Ua.windowMap.get(t);return o?o.restoreStyle():((o=new Ua(t,e,n,i)).saveStyle(),o.z=Ua.nextZIndex++,Ua.addWindowComponent(o)),o}}Ua.windowMap=new Map,Ua.nextZIndex=200;const ja="0.3.6";let Ha=n(40);n(41),n(42),n(43),n(44),n(45),n(46),n(47);let Fa=new class extends y.EventEmitter{constructor(){super(),this.config=new za,this.appInfo=new Ta,this.robots=new Da,this.romCommands=new Aa,this.panelZIndexMap=new Map,this.config.load((t,e)=>{t||!this.config.data?(console.log("Model: Config not found. Using template."),this.config.data=Ha,this.initWithData(this.config.data),this.saveConfig()):this.initWithData(this.config.data),this.emit("ready",this)}),this.statusMessages=""}initWithData(t){this.appInfo=new Ta,this.appInfo.initWithData(t.appInfo),this.robots=new Da,this.robots.initWithData(t.robots),this.robots.on("updateRobots",this.onUpdateRobots.bind(this)),this.robots.on("updateStats",this.onUpdateRobotsStats.bind(this)),this.robots.on("robotIntent",this.onRobotIntent.bind(this)),this.romCommands=new Aa,this.romCommands.initWithData(t.romCommands)}get json(){let t={timestamp:0};return t.appInfo=this.appInfo.json,t.robots=this.robots.json,t.romCommands=this.romCommands.json,t}saveConfig(){console.log("saveConfig: ",this.json),this.config.data=this.json,this.config.save(t=>{t&&console.log("Model: Error saving config: ",t)})}reloadConfig(){this.config.load((t,e)=>{t||!this.config.data?(console.log("Model: Config not found. Using template."),this.config.data=Ha,this.initWithData(this.config.data)):this.initWithData(this.config.data),this.emit("updateModel",this)})}updateAppStatusMessages(t,e,n=!1){return e=e||"",n&&(this.statusMessages=""),this.statusMessages=`${e}: ${this.statusMessages}\n${t}`,this.emit("updateModel",this),this.statusMessages}onUpdateRobots(t){this.emit("updateModel",this)}onUpdateRobotsStats(t){this.emit("updateModel",this)}onRobotIntent(t){this.emit("robotIntent",t)}sendRomCommand(t,e){e?e.sendCommand(t):this.robots&&this.robots.targetedRobots&&this.robots.targetedRobots.forEach(e=>{e.sendCommand(t)})}sendTTS(t,e){let n=new w("","say",{text:t});this.sendRomCommand(n,e)}sendAsk(t,e,n,i){let o=new w("","ask",{prompt:t,contexts:e,nluType:n});this.sendRomCommand(o,i)}sendLookAt(t,e){let n=new w("","lookAt",t);this.sendRomCommand(n,e)}sendRomCommandWithData(t,e){if(t.type&&t.data){let n=t.type,i=t.data,o=new w("",n,i);this.sendRomCommand(o,e)}}getPanelOpenedWithId(t){let e=!1,n=Ua.getWindowComponentWithId(t);return n&&(e=n.opened),e}togglePanelOpenedWithId(t){let e=Ua.getWindowComponentWithId(t);return!e||e.toggleOpened()}openPanelWithId(t){Ua.openWithId(t)}closePanelWithId(t){Ua.closeWithId(t)}bringPanelToFront(t){Ua.addWindowWithId(t),Ua.bringWindowToFrontWithId(t)}addPanelWithId(t,e=0,n=0,i=0){Ua.addWindowWithId(t,e,n,i)}get targetedRobots(){return this.robots.targetedRobots}getAppVerison(){return ja}dispose(){Ha=null,delete this.config,delete this.appInfo,delete this.robots,delete this.romCommands}},Oa=document.head;console.log("aHead: ",Oa);let qa=document.createElement("style");qa.id="graph-editor-style",qa.appendChild(document.createTextNode("\n circle.node-base {\n fill: #D0E5F2;\n stroke: #25C086;\n stroke-width: 3px;\n }\n text.caption {\n fill: #2D5083;\n }\n body {\n background-color: lightgrey;\n }\n circle.node-type-video {\n fill: #FADBD0;\n stroke: #E53D00;\n stroke-width: 3px;\n }\n circle.node-type-ask {\n fill: #FADBD0;\n stroke: #E53D00;\n stroke-width: 3px;\n }\n circle.node-type-imageCancel {\n fill: #FCF1D0;\n stroke: #F0B500;\n stroke-width: 3px;\n }\n circle.node-type-image {\n fill: #FCF1D0;\n stroke: #F0B500;\n }\n circle.node-type-launch {\n fill: #FCF1D0;\n stroke: #F0B500;\n }\n circle.node-type-tts {\n fill: #D0E5F2;\n stroke: #0072BC;\n stroke-width: 3px;\n }\n circle.node-type-nav {\n fill: #D7F3E9;\n stroke: #25C086;\n stroke-width: 3px;\n }\n circle.node.overlay:hover {\n fill: rgba(150, 150, 255, 0.5);\n }\n circle.node.ring:hover {\n stroke: rgba(150, 150, 255, 0.5);\n }\n path.relationship.overlay:hover {\n fill: rgba(150, 150, 255, 0.5);\n stroke: rgba(150, 150, 255, 0.5);\n }\n")),Oa.appendChild(qa),Fa.on("ready",()=>{Object(o.render)(i.createElement(Ia,{model:Fa}),document.getElementById("app"))})},function(t,e){t.exports=require("react-dom")},function(t,e){t.exports=require("util")},function(t,e){t.exports=require("defaultcss")},function(t,e){t.exports=require("classnames")},function(t,e){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOgAAAAYCAYAAADwO7FhAAAABmJLR0QA/wD/AP+gvaeTAAAETUlEQVR42u2bz0tcVxTHP+e+NzMaf3U0IG1VmpIozSaii1JwkVIXbkIpXRS6Ke1/1k1poaWLbrJIQIpQKBiSTakGWtJq0VQTnYw/Zubde7p4jlozis48cyd6P4thmPfe3DOH833n3PPOiL13WzlHoulZARif+/xc13k49Y0AJJ99er6/59vvBcDd/zD47QzE3/0gACHezoY5zy8PBAKtEQQaCLQxQaCBQBsT+zYgRRHjQByCgsrBoUNvVR3OKk5rRKbHt9GBC8L6owUABm6N+TblJdpEoICCOsE5UOcQgVSdCggigmIQE2PI+bY2cIF49nARCAI9AUVdle3lVXZWnlN6soar1HCJQ51D7V6jTJSxrz5GjKS6PQM/3v8FgJmpSToL+Ybn7FSq3J2bB+CTjz7w6hF77zYAk16tCDRLVvHmbQ8q4gAHalGXIOoAsImlWtqlVtrF7lSxlQRXs7iq3S995XDdewbWNkvcnZtnp1I91llrmyVfLglcMLKIN38CNZa0hK1iqEFkuDI0QvHmCIPvXydf7MJWLTjqVS5qLXDm5Amkd7Krfb0NnXbYWVf7epmZCnkr0BpZxZu/Lq6kGXNraZXy0lNUO5BI6Rjoo/fGOxRvDtE9MvD/S8yeuU0otLOQb+i0Rs46riQJBE5LVvHmbQ+qLgLgxR8rJFsVCsVuCv09IEoUC33Xh5E4Rq1le6WEMYKzLhOn1R1Ur/+DOAPnQRbx9pJAHzxYZX5+tSmDJicHmZgYPN3JakChvLyOq1jKf6+DEXJXupEcxLkCve8OobYGGHb/3dzLoIKIok0OWB11GtCu4oyBxLcR582rirf1Rwv73drjePz1Tw0/7x8fbbrD22q8+eviSrqxTLZruMSy8fsy6ix9ox3kcjGgRPmIvtFriIlY3XjBQUW+tym92OS5BAINnMxLAp2YOEMWbIV6ClQFVbaWnwGKiXP0XHsbU+jCxAlxLqJ7eIDyUj8milpe9ugeAA66bW2WRS/FlNerireBW2PHZsF65rzxxZ3M12013jw2idIMqFZRp5icoVausLGwxObiE1xSSSeLVIm7ixTHhnjjvWGa6+E2dtbM1OSJ3TbPWN8GBFoji3jzfJdWTCT7e8tku0L5r3We/7ZEafFPkh2HTdLj3SPDdL35VqbO6izkj+22tQFtYUSgObKKN38C3Rs6UHcweKBOEREqG2We/vqY1Z/n2Vn5B1XBEaEYms2gJ7W2GzmtDQgZ9DUmq3jzJlBVAyKYfIzEgslHSCSYQkyUjxEjqBFczYGCiIAYwKTXNsFJ3bPDTgsEsiCLePM4i+sAw+iXd2j8zKQ+f1t/aa1re5rZ2s5C3vsMbuBikFW8eROoc1WMKSBRBZGIVJB6pILdK30x6WCDXvhHKwEP9I+P+jbhWLwJ1JgOANR2tNCXDQRapx3/ZlbnUjxrCwReV4JA25RoepZoeta3GQHPBIEGAm3MfxIveNEtAGhmAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAABJRU5ErkJggg=="},function(t,e){t.exports=require("react-select")},function(t,e){t.exports=require("querystring")},function(t,e){t.exports=require("neo4j-driver")},function(t,e){t.exports=require("http")},function(t,e){t.exports=require("@jibo/apptoolkit-library")},function(t,e){t.exports=require("child_process")},function(t,e){},function(t,e){t.exports=require("ws")},function(t,e,n){"use strict";var i=e,o=n(31).Buffer,a=n(32);i.toBuffer=function(t,e,n){var i;if(n=~~n,this.isV4Format(t))i=e||new o(n+4),t.split(/\./g).map(function(t){i[n++]=255&parseInt(t,10)});else if(this.isV6Format(t)){var a,s=t.split(":",8);for(a=0;a<s.length;a++){var r;this.isV4Format(s[a])&&(r=this.toBuffer(s[a]),s[a]=r.slice(0,2).toString("hex")),r&&++a<8&&s.splice(a,0,r.slice(2,4).toString("hex"))}if(""===s[0])for(;s.length<8;)s.unshift("0");else if(""===s[s.length-1])for(;s.length<8;)s.push("0");else if(s.length<8){for(a=0;a<s.length&&""!==s[a];a++);var l=[a,1];for(a=9-s.length;a>0;a--)l.push("0");s.splice.apply(s,l)}for(i=e||new o(n+16),a=0;a<s.length;a++){var h=parseInt(s[a],16);i[n++]=h>>8&255,i[n++]=255&h}}if(!i)throw Error("Invalid ip address: "+t);return i},i.toString=function(t,e,n){e=~~e;var i=[];if(4===(n=n||t.length-e)){for(var o=0;o<n;o++)i.push(t[e+o]);i=i.join(".")}else if(16===n){for(o=0;o<n;o+=2)i.push(t.readUInt16BE(e+o).toString(16));i=(i=(i=i.join(":")).replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3")).replace(/:{3,4}/,"::")}return i};var s=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;function l(t){return t?t.toLowerCase():"ipv4"}i.isV4Format=function(t){return s.test(t)},i.isV6Format=function(t){return r.test(t)},i.fromPrefixLen=function(t,e){var n=4;"ipv6"===(e=t>32?"ipv6":l(e))&&(n=16);for(var a=new o(n),s=0,r=a.length;s<r;++s){var h=8;t<8&&(h=t),t-=h,a[s]=255&~(255>>h)}return i.toString(a)},i.mask=function(t,e){t=i.toBuffer(t),e=i.toBuffer(e);var n=new o(Math.max(t.length,e.length)),a=0;if(t.length===e.length)for(a=0;a<t.length;a++)n[a]=t[a]&e[a];else if(4===e.length)for(a=0;a<e.length;a++)n[a]=t[t.length-4+a]&e[a];else{for(a=0;a<n.length-6;a++)n[a]=0;for(n[10]=255,n[11]=255,a=0;a<t.length;a++)n[a+12]=t[a]&e[a+12];a+=12}for(;a<n.length;a++)n[a]=0;return i.toString(n)},i.cidr=function(t){var e=t.split("/"),n=e[0];if(2!==e.length)throw new Error("invalid CIDR subnet: "+n);var o=i.fromPrefixLen(parseInt(e[1],10));return i.mask(n,o)},i.subnet=function(t,e){for(var n=i.toLong(i.mask(t,e)),o=i.toBuffer(e),a=0,s=0;s<o.length;s++)if(255===o[s])a+=8;else for(var r=255&o[s];r;)r=r<<1&255,a++;var l=Math.pow(2,32-a);return{networkAddress:i.fromLong(n),firstAddress:l<=2?i.fromLong(n):i.fromLong(n+1),lastAddress:l<=2?i.fromLong(n+l-1):i.fromLong(n+l-2),broadcastAddress:i.fromLong(n+l-1),subnetMask:e,subnetMaskLength:a,numHosts:l<=2?l:l-2,length:l,contains:function(t){return n===i.toLong(i.mask(t,e))}}},i.cidrSubnet=function(t){var e=t.split("/"),n=e[0];if(2!==e.length)throw new Error("invalid CIDR subnet: "+n);var o=i.fromPrefixLen(parseInt(e[1],10));return i.subnet(n,o)},i.not=function(t){for(var e=i.toBuffer(t),n=0;n<e.length;n++)e[n]=255^e[n];return i.toString(e)},i.or=function(t,e){if(t=i.toBuffer(t),e=i.toBuffer(e),t.length===e.length){for(var n=0;n<t.length;++n)t[n]|=e[n];return i.toString(t)}var o=t,a=e;e.length>t.length&&(o=e,a=t);var s=o.length-a.length;for(n=s;n<o.length;++n)o[n]|=a[n-s];return i.toString(o)},i.isEqual=function(t,e){if(t=i.toBuffer(t),e=i.toBuffer(e),t.length===e.length){for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}if(4===e.length){var o=e;e=t,t=o}for(n=0;n<10;n++)if(0!==e[n])return!1;var a=e.readUInt16BE(10);if(0!==a&&65535!==a)return!1;for(n=0;n<4;n++)if(t[n]!==e[n+12])return!1;return!0},i.isPrivate=function(t){return/^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^f[cd][0-9a-f]{2}:/i.test(t)||/^fe80:/i.test(t)||/^::1$/.test(t)||/^::$/.test(t)},i.isPublic=function(t){return!i.isPrivate(t)},i.isLoopback=function(t){return/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/.test(t)||/^fe80::1$/.test(t)||/^::1$/.test(t)||/^::$/.test(t)},i.loopback=function(t){if("ipv4"!==(t=l(t))&&"ipv6"!==t)throw new Error("family must be ipv4 or ipv6");return"ipv4"===t?"127.0.0.1":"fe80::1"},i.address=function(t,e){var n,o=a.networkInterfaces();if(e=l(e),t&&"private"!==t&&"public"!==t){var s=o[t].filter(function(t){return t.family.toLowerCase()===e});if(0===s.length)return;return s[0].address}return(n=Object.keys(o).map(function(n){var a=o[n].filter(function(n){return n.family=n.family.toLowerCase(),n.family===e&&!i.isLoopback(n.address)&&(!t||("public"===t?i.isPrivate(n.address):i.isPublic(n.address)))});return a.length?a[0].address:void 0}).filter(Boolean)).length?n[0]:i.loopback(e)},i.toLong=function(t){var e=0;return t.split(".").forEach(function(t){e<<=8,e+=parseInt(t)}),e>>>0},i.fromLong=function(t){return(t>>>24)+"."+(t>>16&255)+"."+(t>>8&255)+"."+(255&t)}},function(t,e){t.exports=require("buffer")},function(t,e){t.exports=require("os")},function(t,e){t.exports=require("three")},function(t,e){t.exports=require("webmidi")},function(t,e){t.exports=require("react-fontawesome")},function(t,e){t.exports=require("pretty-data")},function(t,e){t.exports=require("graphlib-dot")},function(t,e){t.exports=require("vm")},function(t,e){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAACKJJREFUWAnVV1lsnFcV/mbfZzye1Vu8TJ3GbRSrRaShiPaFtAIeCg9FCKkSqOIRXkDihSdUxBsPCAkpUl6AFLVISBV5ANS0BJyGOHFqx8Z24vEyHm+zeB3PvvGd+//eWitAxMP0WP/M/Ofce+53v7Pca4Pp9V800cJiRrOl8cHYwuQpaC3PoBlo7RB/BgB+gsAGI9/UWTXAcCJJG2KR8QbAJB+6PG7OwZgn/T7BYIOLR8wGWI1a7ZSoyNSaMBKLABObjS9UIVUTuIDMCVFv1+cU6k1k+VClb/NJoWnzThSJjU43siWgTE5kdZcZLq8Fef52im2zDBRqgM0EY7tNceigPr1dAfLUi7jN8His2OeO/h8tQjEojgRPidS8+WIP/B4b3wxY39zHtZkM3FYT9qt1fOeFTkT8Luzly/jt5DqK3EeBTH77uQg6A27OAZKZHN6ZzcBlM6MktItjbuJ/Fn2eYlAAtpuNWF/M4fs/fxnDzwwofzOPFnDtu1dRiXjU+1s/eA1d0SBy+3ms/fgK3pvPk+06fvK9VzE0eEaN+dNf/o533p1Dx4thxEs1mAScLPYkwnlGSa4yH5eJHjJVbKS3Dl21+zzoCFlQ2Srj9ZgfAb9X2TxuF4b725mIRfSEbPD7NPbEuLS8ztQw0S298zn4lt8N/Tmuk9+n6WW8PEZVsfqLJNrSSuYQoNNpx/MRJ5Ao4nx/EHabVVuQI2I9IWC8gOGQC06HpARQqVQwu5gCepxwcsMDNiO8DE+d/gkZvVYjYtR1WgyQEhN9kBTLOHmirCzRHf87LJJynQnlNyOezKDeaMDEqrTb7egPM7xLKxg8Q0CUhthMJvR0ynsRvbTb7VZly+fz+HAmDdwoYvJMjmaycMEDP4ttm7m69GAPWK8Cg3Y4u12wEHw6U0B6tqDmo9sGT68LObYGyQx5VJEY6CcvAL1mjC9kkc8X4fXQgcWCrrCEtYzebg2g5gnojAb4s46ukAdWjhNJpTdxNurFr299ixupw8iW9Pb1f+LKBwlc6PPip7/8BsIBH2biSbx5dYRV2cRb3xzGS58/p+YnVlN441cfwu61q7BLX1AMCtICUVsdJry/tIPdvX0FUGaFAwKQ9IeYc5Rara4YDPh9QIcNIf9R/q2ns0jnKnj50nk1Vj6Wl5O48rP7+NIrMbz2yiWlH+yLoOf3I0hOFXD5i+dx8TkNoH2MkP6xhY6vdyNR1tqWKhID414hwKhwnsgjnd05XCDgZ4g/50GIO5dyXF5ZVTav14Nnv+BHe9sRwI3UJm5fW0AiuXE4P9gu83I4H4sqnRSFm0V2eVAi0ESb16WPbWJkdIr5a5fKVamkikQ+ZJI8Zon1dg2rG1l9EqPuduIrz4fg4XepVMb8YlLZrFYrXno6DJ/bod5lvlZgNSwzVAeiAawg1hvRx4HFZsMzA2EgYIS/TWth+XwBtx8kgDNO5Ko1rXXSJykjKP2RReAxnqhkFyv50lCHcp4vFDA9l0Rd8pUyNBDlBjSAxWIRM1LBcGHq0bKyy4fPKww79aLSKl30sd4oojE3XE5t/kYqgz/c3UCbz4odppGwKLj4zcX0p8oKRbsJs0spVLkLEXEwFOtUv/f2crg1kUBFtw2ciZBZbYG9XA7XZ1nBF734aGIRRbJ9MD/81Q5EmMO1Wg3J1TWl7+4I4Wvn2Lr0DhBf4KbGKjwwgCqJUmQRl8pBCbM8qtV4LLi/kEG+UDxcoLdLq+Ds5g7+eCOJYpHnNaWTp4qbDIts0rY9lUMk6sDvPl5DZnNb6SWcb7zQp5jc39/H3DzDSAm2t2F4sIMXESlRYGJ6Hui3HeaeRtqxEBtI5z5D52aHvfNoCzu77GMUN3NPgIgsrzL541lsbe+q93CwHW4XGzllbYMNfq2GLnYC3NvDUoInCsVqteDihQF1I8oS9OhEXOl9PKXO6ZER4DfuEiAbfLFep/0o7U4wWGSIQ1LJ9/JkQKtkj8eNSFgDGF+U8DSxzn4nEgwQIDcgohWGmclN5zxYph5pTFkIcOhsrxqT5AbfvTWvclg21tutFc76Rhp/vbmBoNeKbV5KpKscRPUIoDimwSKVzAa8uq5VssVsVg1biuDBnLQYNxIrUgwaO2bam8yVuSUy9rQdBcnPPhvuTC7x6Kuqin2qXwP4MJ7AzHspCJNyCHR3asWn8i9ZhZ/9viJ1oGMRPEdVrKOuyQ20zYyFpAZCjj2Rra1tvD1FXZ8bDxfW6ULvVbTt83YzEWf4g2SgXIU1YMNvRpeRymgXD4fDjnK5hHtTixzNQlnTfNt4tovcn5xjQjtRVeGlQrAISD5HDFIp4SnLoG4L5hKaE2FQRCX9TZ6lfQ6Mx9fQ4K1ZzmSRAgvqz9Nk3G1hi2ig1079yDajwKrWZZc5fXVshW82LOr5KfNLpSLev8u8jLnUnZOANIA6YYeXBfEj9ZSTHhew4s5cCnfHJlSjNpmMGLk9xuuJA2EW0fWFbXw0eh8Rni5GowmT0w9JYwNBFvsWAZbYxxBz4INbHyPgc6gx98YneTPgReGSGzdHp/Hs2W5VQPH5Jfzt4Q5cUb+2tgAR8nQxGC//6NirZuNtCBUyhHEysEmnvBxhuA3eqI83DbkoccC/pGq1doOnHHAOBNXlRTYp9zsfL8C7W7yljEou09dZF1x9QbV2ocB/EUaEXfrtscF6LszAa2vL/ONiMH75hycAilEUAjJklarkH38XyUyWjdbId/knKmwxqx4mNjnH0xX9eOJcqlhmTTZdE/+t0dJAkj9dEW2Td0QjfJwv68hmUpz7KRC0iTDBPm2SBeQ/t7USd3pMtKYqN2Be68onbQa94cpw8cjqY8uoqUd0IjJGfEsUcvpJc6CX79PkRA5+coA4OyGSuLo8zvafxvw3cw98nMrggbEVvh/LYGsAPCUHWwHYAYaWZ1CKraWl5Rn8LFRxS0f49JOklSD/G5vLEjy2xr5NAAAAAElFTkSuQmCC"},function(t,e){t.exports={timestamp:0,appInfo:{port:7160,clientId:"",clientSecret:""},robots:[],romCommands:[{name:"LookAt: Left",type:"lookAt",data:{angle:.5}},{name:"LookAt: Center",type:"lookAt",data:{angle:0}},{name:"LookAt: Right",type:"lookAt",data:{angle:-.5}},{name:"LookAt: Behind",type:"lookAt",data:{angle:3.14159}},{name:"TTS: Hello",type:"tts",data:{text:"hello world"}},{name:"Attention: IDLE",type:"attention",data:{state:"IDLE"}},{name:"Attention: OFF",type:"attention",data:{state:"OFF"}},{name:"ghosts",type:"tts",data:{text:"<anim name='Checking_04' nonBlocking='true'/> I'm pretty scared of ghosts"}},{name:"Volume 1",type:"volume",data:{volume:1}},{name:"Volume .3",type:"volume",data:{volume:.3}},{name:"Volume .5",type:"volume",data:{volume:.5}},{name:"Volume .7",type:"volume",data:{volume:.7}},{name:"Mute",type:"mute",data:{mute:!0}},{name:"Unmute",type:"unmute",data:{mute:!1}},{name:"Emoji: Clock",type:"tts",data:{text:"<anim name='emoji-clock-hf-01' nonBlocking='true'/>."}},{name:"Center",type:"lookAtPosition",data:{vector:[1,0,.5]}},{name:"motion ON",type:"motion",data:{state:"ON"}},{name:"motion OFF",type:"motion",data:{state:"OFF"}},{name:"faces ON",type:"faces",data:{state:"ON"}},{name:"faces OFF",type:"faces",data:{state:"OFF"}}]}},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){}]);
|
||
//# sourceMappingURL=renderer.js.map
|