Files
jibo-cli/simulator/client.js

9 lines
29 KiB
JavaScript

/**
* jibo-cli - Command line interface, templates, simulator
* @version v3.0.7
* @license Copyright (c) 2017, Jibo, Inc. All rights reserved.
* All use of the Jibo SDK is subject to the Jibo SDK End User License Agreement (EULA)
* distributed herewith. If you did not receive a copy of the EULA, you may view a
* copy at https://developers.jibo.com/license.
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.client=e()}}(function(){return function e(t,i,n){function s(a,r){if(!i[a]){if(!t[a]){var c="function"==typeof require&&require;if(!r&&c)return c(a,!0);if(o)return o(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var d=i[a]={exports:{}};t[a][0].call(d.exports,function(e){var i=t[a][1][e];return s(i?i:e)},d,d.exports,e,t,i,n)}return i[a].exports}for(var o="function"==typeof require&&require,a=0;a<n.length;a++)s(n[a]);return s}({1:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.default={SCREEN_WIDTH:1280,SCREEN_HEIGHT:720,SCREEN_EPSILON:2,CHAT_WIDTH:400}},{}],2:[function(e,t,i){"use strict";function n(e){let t,i,n,s,o=0,a=e[2];e[2]=e[3],e[3]=a;for(let r=0;r<e.length;r++)t=e[r].x,i=e[r].y,r===e.length-1?(n=e[0].x,s=e[0].y):(n=e[r+1].x,s=e[r+1].y),o+=t*s-n*i;return o<0}function s(e,t,i){let n=.5*(window.innerWidth-p.default.CHAT_WIDTH),s=.5*window.innerHeight;t.updateMatrixWorld(),t.geometry.boundingBox||t.geometry.computeBoundingBox();let o,a=[new e.Vector3(t.geometry.boundingBox.max.x,t.geometry.boundingBox.max.y,t.geometry.boundingBox.max.z),new e.Vector3(t.geometry.boundingBox.min.x,t.geometry.boundingBox.max.y,t.geometry.boundingBox.max.z),new e.Vector3(t.geometry.boundingBox.max.x,t.geometry.boundingBox.min.y,t.geometry.boundingBox.min.z),new e.Vector3(t.geometry.boundingBox.min.x,t.geometry.boundingBox.min.y,t.geometry.boundingBox.min.z)],r=[];for(let c=0;c<a.length;c++)o=a[c].applyMatrix4(t.matrixWorld),o.project(i),o.x=o.x*n+n,o.y=-(o.y*s)+s,r.push({x:Math.floor(o.x),y:Math.floor(o.y)});return r}function o(e){return[e[4]*e[8]-e[5]*e[7],e[2]*e[7]-e[1]*e[8],e[1]*e[5]-e[2]*e[4],e[5]*e[6]-e[3]*e[8],e[0]*e[8]-e[2]*e[6],e[2]*e[3]-e[0]*e[5],e[3]*e[7]-e[4]*e[6],e[1]*e[6]-e[0]*e[7],e[0]*e[4]-e[1]*e[3]]}function a(e,t){let i=Array(9);for(let n=0;3!=n;++n)for(let s=0;3!=s;++s){let o=0;for(let a=0;3!=a;++a)o+=e[3*n+a]*t[3*a+s];i[3*n+s]=o}return i}function r(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}function c(e,t,i,n,s,c,l,d){let u=[e,i,s,t,n,c,1,1,1],h=r(o(u),[l,d,1]);return a(u,[h[0],0,0,0,h[1],0,0,0,h[2]])}function l(e,t,i,n,s,r,l,d,u,h,m,p,f,g,v,y){let E=c(e,t,s,r,u,h,f,g),b=c(i,n,l,d,m,p,v,y);return a(b,o(E))}function d(e,t,i,n,s,o,a,r,c){let d=e.offsetWidth-p.default.SCREEN_EPSILON,u=e.offsetHeight-p.default.SCREEN_EPSILON,h=l(0,0,t,i,d,0,n,s,0,u,o,a,d,u,r,c);for(let m=0;9!=m;++m)h[m]=h[m]/h[8];h=[h[0],h[3],0,h[6],h[1],h[4],0,h[7],0,0,1,0,h[2],h[5],0,h[8]],h="matrix3d("+h.join(", ")+")",e.style["-webkit-transform"]=h,e.style["-moz-transform"]=h,e.style["-o-transform"]=h,e.style.transform=h}function u(e,t){d(t,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7])}const h=e("electron"),m=e("animation-utilities"),p=e("./dimensions"),f=e("react"),g=e("./views/toolbar"),v=e("skills-service-manager");let y,E={viewFront:{position:new m.THREE.Vector3(.5,0,.35),lookat:new m.THREE.Vector3(0,0,.15),fov:45},viewTop:{position:new m.THREE.Vector3(0,0,1),lookat:new m.THREE.Vector3(0,0,.15),fov:45},viewReset:{position:new m.THREE.Vector3(.5,0,.35),lookat:new m.THREE.Vector3(0,0,.15),fov:45}},b={viewFront:{x:1,y:1,z:0},viewTop:{x:1,y:1,z:0},viewReset:{x:1,y:1,z:0}},S=!1,w=[];Object.defineProperty(i,"__esModule",{value:!0}),i.default={init:function(e,t,i,o,a,r,c){this.face=o,this.container=i,this.faceContent=document.getElementById("faceContent"),this.selectedPlane=b.viewFront,this.sidebar=document.getElementById("sidebar"),this.pageTitle=document.title,y=JSON.parse(h.ipcRenderer.sendSync("get-simulator-settings")),this.sidebar.className=this.container.className="view"+y.viewMode+" loading","3d"===y.viewMode&&(a.style.width=window.innerWidth+"px",a.style.height=window.innerHeight+"px"),document.body.style.cursor||(document.body.style.cursor="default"),this.initializeToolbar(),t(e,a,m.visualize.DisplayType.BODY,e=>{this.robotRenderer=e,this.container.className+="loading";let t=["movedown","mousemove","mouseup","mousewheel"],i=["shiftKey","ctrlKey","altKey","metaKey"];if(t.forEach(e=>{document.addEventListener(e,e=>{for(let t=0;t<i.length;t++)if(e[i[t]])return this.robotRenderer.scene._container.style.pointerEvents="all",void(this.face.style.pointerEvents="none");this.robotRenderer.scene._container.style.pointerEvents="none",this.face.style.pointerEvents="all"})}),S){let e=["red","green","purple","blue"];for(let t=0;t<4;t++)w.push(document.createElement("div")),w[t].style.position="absolute",w[t].style.width="5px",w[t].style.height="5px",w[t].style.background=e[t],document.body.firstChild?document.body.insertBefore(w[t],document.body.firstChild):document.body.appendChild(w[t])}this.robotRenderer.scene._postRenderCallbacks.push(()=>{if("3d"===y.viewMode){let e=this.robotRenderer.scene._scene.children[4].children[0].children[1].children[1].children[0].children[2].children[0],t=this.robotRenderer.scene._camera,i=s(m.THREE,e,t);if(S)for(let o=0;o<w.length;o++)w[o].style.marginLeft=Math.floor(i[o].x)+"px",w[o].style.marginTop=Math.floor(i[o].y)+"px";u([i[0].x,i[0].y,i[1].x,i[1].y,i[2].x,i[2].y,i[3].x,i[3].y],this.face),this.face.style.zIndex=n(i)?"-1":"0"}});let o=document.getElementById("container");o.addEventListener("mousedown",e=>{let t=this.getClicked3DPoint(e);"audio"===this.mode&&(e.stopPropagation(),e.preventDefault(),v.LPSService.instance.triggerAudioEvent(t))}),o.addEventListener("mouseup",()=>{"audio"===this.mode&&v.LPSService.instance.triggerAudioEventEnd()}),this.container.className=this.container.className.replace("loading","");let l=()=>{this.face.style.transformOrigin="0 0","2d"===y.viewMode?(this.faceContent.style.transform=`scale(1.0)`,this.face.style.width=p.default.SCREEN_WIDTH+2+"px",this.face.style.height=p.default.SCREEN_HEIGHT+2+"px",this.face.style.top=void 0,this.face.style.left=void 0,this.face.style.position="absolute",a.style.position="absolute",this.hideToolbar()):(this.face.style.marginLeft="0px",this.face.style.marginTop="0px",this.face.style.width=p.default.SCREEN_WIDTH+p.default.SCREEN_EPSILON+"px",this.face.style.height=p.default.SCREEN_HEIGHT+p.default.SCREEN_EPSILON+"px",this.face.style.top="0px",this.face.style.left="0px",this.robotRenderer.setBackgroundColor(.25,.25,.25,1),this.robotRenderer.setGrid(.05,6,new m.THREE.Color("rgb(128, 128, 128)")),this.robotRenderer.scene._camera.near=.001,this.robotRenderer.scene._camera.updateProjectionMatrix(),this.showToolbar())},d=()=>{let e=y.zoomFactor*y.devicePixelRatio;if("2d"===y.viewMode){this.sidebar.className=this.container.className="view2d",this.faceContent.style.transform=`scale(${y.zoomFactor})`;let t=p.default.SCREEN_WIDTH*y.zoomFactor,i=p.default.SCREEN_HEIGHT*y.zoomFactor;t<window.innerWidth?this.face.style.marginLeft=Math.floor((window.innerWidth-p.default.CHAT_WIDTH-t)/2)+"px":this.face.style.marginLeft="0px",i<window.innerHeight?this.face.style.marginTop=Math.floor((window.innerHeight-i)/2)+"px":this.face.style.marginTop="0px",document.title=`${this.pageTitle} (${Math.floor(100*e)}%)`}else this.sidebar.className=this.container.className="view3d",this.faceContent.style.transform=`scale(1.0)`,a.style.width=window.innerWidth-p.default.CHAT_WIDTH+"px",a.style.height=window.innerHeight+"px",this.robotRenderer.scene.handleResize(),document.title=`${this.pageTitle} (3D)`};h.ipcRenderer.on("simulator-settings-changed",(e,t)=>{let i=y;y=JSON.parse(t),r(i,y),i.viewMode!==y.viewMode&&l(),d()});const f=window;f.onDimensionChanges=d,f.onViewModeChange=l,window.addEventListener("resize",()=>{d()}),l(),d(),c(null,e,y,d)})},initializeToolbar:function(){let e=document.getElementById("toolbar");f.render(f.createElement(g.default,{setMode:this.setMode.bind(this),setCamera:this.setCamera.bind(this)}),e)},hideToolbar:function(){document.getElementById("toolbar").className+=" hide"},showToolbar:function(){let e=document.getElementById("toolbar");e.className=e.className.replace("hide","")},setCamera:function(e){this.robotRenderer.scene._controls.reset();let t=E[e];this.selectedPlane=b[e],this.robotRenderer.setCamera(t.position,t.lookat,t.fov)},getClicked3DPoint:function(e){let t=document.getElementById("visualizer"),i=this.robotRenderer.scene.getCamera(),n=m.MouseCoordinateWrangler.unprojectEventToPlane(e,t,i,this.selectedPlane,{x:0,y:0,z:1});return n},setMode(e){this.mode=e}}},{"./dimensions":1,"./views/toolbar":12,"animation-utilities":void 0,electron:void 0,react:void 0,"skills-service-manager":void 0}],3:[function(e,t,i){"use strict";const n=e("react");Object.defineProperty(i,"__esModule",{value:!0}),i.default=n.createClass({getInitialState(){return{activeTab:0}},render(){let e=[];return this.props.tabs.forEach((t,i)=>{let s="main";i===this.state.activeTab&&(s+=" selected"),e.push(n.createElement("button",{key:t.id,id:t.id,onClick:this.onClick.bind(this,i,t.callback),className:s},n.createElement("span",{className:t.icon,title:t.label})))}),n.createElement("div",{className:"tools",id:"tabBar"},e)},onClick(e,t){this.state.activeTab=e,this.setState(this.state),t()}})},{react:void 0}],4:[function(e,t,i){"use strict";const n=e("react"),s=e("electron"),o=e("skills-service-manager");Object.defineProperty(i,"__esModule",{value:!0}),i.default=n.createClass({getInitialState(){return{text:"",speaker:this.props.speakerId}},componentDidMount(){o.TTSService.instance.setMode(this.props.ttsMode),this.inputStack=[""],this.inputIndex=1},onKeyDown(e){let t=e.target.value,i=e.nativeEvent.keyCode;t=t.trim().replace(/[\|&;\$%@"#<>\(\)\+,?.]/g,""),13===i?(this.saveInputText(t),this.setState({text:""}),this.props.onWords({words:t,final:!0,speaker:this.state.speaker}),this.props.messageHandler({words:t,speaker:this.state.speaker})):32===i?this.props.onWords({words:t,incremental:!0,speaker:this.state.speaker}):38===i&&this.inputIndex>1?(this.inputIndex-=1,this.setState({text:this.inputStack[this.inputIndex]})):40===i&&this.inputIndex<this.inputStack.length&&(this.inputIndex+=1,this.setState({text:this.inputStack[this.inputIndex]}))},saveInputText(e){e!==this.inputStack[this.inputStack.length-1]&&this.inputStack.push(e),this.inputIndex=this.inputStack.length},onSpeakerChange(e){let t=e.target.value;s.ipcRenderer.send("set-speaker-id",t),this.setState({speaker:t})},setTtsMode(e){this.state.ttsMode!==e&&(o.TTSService.instance.setMode(e),s.ipcRenderer.send("set-tts-mode",e))},setTtsModeInstant(){this.setTtsMode("Instant")},setTtsModeIncremental(){this.setTtsMode("Incremental")},onChange(e){let t=e.target.value,i=t;t=t.trim().replace(/[\|&;\$%@"#<>\(\)\+,?.]/g,"").toLowerCase(),this.setState({text:i})},render(){const e=[n.createElement("option",{value:""},"No ID")];return this.props.loop.forEach(t=>{t.data.firstName&&(this.state.speaker===t.data.memberId?e.push(n.createElement("option",{selected:!0,value:t.data.memberId},t.data.firstName)):e.push(n.createElement("option",{value:t.data.memberId},t.data.firstName)))}),n.createElement("div",{className:"asr-input"},n.createElement("span",{className:"fa fa-comment chat-icon icon"}),n.createElement("input",{type:"text",className:"text text-lg chat-input",placeholder:"Speak to Jibo here...",value:this.state.text,onChange:this.onChange,onKeyDown:this.onKeyDown}),n.createElement("div",{className:"speaker row"},n.createElement("div",{className:"row-label"},"Speaker"),n.createElement("div",{className:"row-content"},n.createElement("select",{name:"Speaker",className:"text text-md speaker-input",onChange:this.onSpeakerChange},e))),n.createElement("div",{className:"tts-mode row"},n.createElement("div",{className:"row-label"},"TTS Mode"),n.createElement("div",{className:"row-content"},n.createElement("label",{htmlFor:"dev"},n.createElement("input",{type:"radio",value:"Instant",id:"instant",className:"radio",checked:"Instant"===this.props.ttsMode,onChange:this.setTtsModeInstant}),"Instant"),n.createElement("label",{htmlFor:"incremental"},n.createElement("input",{type:"radio",value:"Incremental",id:"incremental",className:"radio",checked:"Incremental"===this.props.ttsMode,onChange:this.setTtsModeIncremental}),"Incremental"))))}})},{electron:void 0,react:void 0,"skills-service-manager":void 0}],5:[function(e,t,i){"use strict";const n=e("animation-utilities");class s{constructor(e,t,i){this.scene=e,this.ts=[0,0],this.type=void 0,this.name=i,this.position={x:t.x,y:t.x,z:t.x},this.confidence=100;let s=new n.THREE.SphereGeometry(.1,32,32),o=new n.THREE.MeshBasicMaterial({color:16711680,transparent:!0,opacity:1}),a=new n.THREE.Mesh(s,o);a.name=i,a.position.x=t.x,a.position.y=t.y,a.position.z=t.z,this.sphere=a,e.add(a)}startScaling(e){this.cb=e,this.sphereScale=1,this.scale=setInterval(this._downScale.bind(this),100)}_downScale(){this.sphereScale-=.05,this.sphereScale<=0?(this.removeFromScene(),clearInterval(this.scale),this.cb()):(this.sphere.scale.x=this.sphereScale,this.sphere.scale.y=this.sphereScale,this.sphere.scale.z=this.sphereScale)}setColor(e){this.sphere.material.color.setHex(e)}setOpacity(e){this.sphere.material.opacity=e}setName(e){this.name=e}updateType(e){this.type=e}updateConfidence(e){this.confidence=e}updateTs(e){this.ts=e}getId(){return this.id}removeFromScene(){let e=this.scene.getObjectByName(this.name);e&&this.scene.remove(e)}}Object.defineProperty(i,"__esModule",{value:!0}),i.default=s},{"animation-utilities":void 0}],6:[function(e,t,i){"use strict";const n=e("react");Object.defineProperty(i,"__esModule",{value:!0}),i.default=n.createClass({getInitialState(){return{}},render(){let e="message-wrapper fade-in",t="";return"jibo"===this.props.message.author?e+=" jibo":this.props.message.author&&(t=n.createElement("div",{className:"message-speaker"},this.props.message.author)),this.props.message.break?n.createElement("div",{className:"message-session"}):n.createElement("div",{className:e},t,n.createElement("div",{className:"message-bubble"},n.createElement("div",{className:"message-content"},this.props.message.content)))}})},{react:void 0}],7:[function(e,t,i){"use strict";const n=e("react"),s=e("skills-service-manager"),o=e("./messages-list"),a=e("./asr-view");Object.defineProperty(i,"__esModule",{value:!0}),i.default=n.createClass({getInitialState(){return{isSelected:!1}},componentDidMount(){this.chatProxy=this.props.chatProxy,s.TTSService.instance.on("speech",e=>{this.messageHandler({words:e,speaker:"jibo"})}),s.TTSService.instance.on("token",e=>{this.incrementalMessageHandler(e)}),s.TTSService.instance.on("sending-tokens",()=>{this.addMessage({content:"",author:"jibo"})}),s.TTSService.instance.on("stop",()=>{this.addMessage({content:"",author:"jibo"})}),window.addEventListener("resize",()=>{this.forceUpdate()})},incrementalMessageHandler(e){let t=this.refs.messagesList.state.messages;"jibo"!==t[t.length-1].author&&this.refs.messagesList.addMessage({author:"jibo",content:""}),this.refs.messagesList.appendMessage(e)},messageHandler(e){this.addMessage({content:e.words,author:e.speaker}),this.props.onWords(e)},addMessage(e){e&&(e.date=new Date,this.refs.messagesList.addMessage(e))},render(){let e="chat-pane side-pane";return this.props.isSelected||(e+=" hidden"),n.createElement("div",{className:e,ref:"root"},n.createElement(o.default,{ref:"messagesList",reloadWatcher:this.props.reloadWatcher}),n.createElement(a.default,{ref:"AsrView",ttsMode:this.props.ttsMode,speakerId:this.props.speakerId,loop:this.props.loop,messageHandler:this.messageHandler,onWords:this.props.onWords}))}})},{"./asr-view":4,"./messages-list":9,react:void 0,"skills-service-manager":void 0}],8:[function(e,t,i){"use strict";const n=e("react"),s=e("./target-view"),o=e("skills-service-manager"),a=e("animation-utilities"),r=e("marked"),c=e("./audio-event");let l=0;Object.defineProperty(i,"__esModule",{value:!0}),i.default=n.createClass({getInitialState(){return{isSelected:!1,targets:[],selectedTarget:""}},initializeMouseTargetPositioner(){this.mtp=new a.MouseTargetPositioner(this.props.visualizer,this.props.parent.getRobotRenderer().scene._camera,new a.THREE.Vector3(.2,0,.2),null,new a.THREE.Vector3(0,0,1),[]),this.mtp.setMouseFilters(function(e){return e.altKey&&!e.metaKey&&!e.ctrlKey},function(e){return e.shiftKey},function(e){return!e.shiftKey}),this.mtp.addPositionChangedCallback(function(e,t){if(t||0===t){let i=e;i.id=t,o.LPSService.instance.updateTarget(i)}}),this.mtp.installRendererIntoScene(this.props.parent.getRobotRenderer().scene)},componentDidMount(){this.audioEvents={},o.LPSService.instance.on("audio-event-start",(e,t)=>{let i=this.props.parent.getRobotRenderer().scene.getScene(),n="sphere"+t,s=new c.default(i,e,n);for(let o in this.audioEvents){let e=this.audioEvents[o];e.setColor(16777215),e.setOpacity(.5)}this.audioEvents[n]=s}),o.LPSService.instance.on("audio-event-end",e=>{this.removeAudioEventById(e)})},removeAudioEventById(e){let t=this.audioEvents["sphere"+e];t.startScaling(()=>{})},addMouseTarget(e){return this.mtp||this.initializeMouseTargetPositioner(),this.mtp.addTargetPositioner(e),o.LPSService.instance.updateTarget({id:e,x:.2,y:0,z:.2}),this.setSelectedTarget(e),!0},setSelectedTarget(e){this.setState({selectedTarget:e}),this.mtp.selectTarget(e)},showEntities(){console.log(this.mtp.getTargetPositionerNames()),console.log(o.LPSService.instance.getEntities())},addTarget(){this.addMouseTarget(l++)},removeTarget(e){o.LPSService.instance.removeEntity(e),this.mtp.removeTargetPositioner(e),this.forceUpdate()},render(){let e="lps-pane side-pane";this.props.isSelected||(e+=" hidden");let t=[],i=o.LPSService.instance.getEntities();i.forEach(e=>{let i=e.id===this.state.selectedTarget;t.push(n.createElement(s.default,{setTargetId:o.LPSService.instance.setTargetId.bind(o.LPSService.instance),target:e,isSelected:i,removeTarget:this.removeTarget,onClick:this.setSelectedTarget}))});let a="Click the `Add Target` button to add a single target to Jibo's Local Perceptual Space.\n\n* `shift+scroll` to zoom in and out.\n\n* `shift+drag` to move camera.\n\n* `shift+alt+drag` to move the LPS target on the ground.\n\n* `alt+drag` to move the height of the target.",c=null;return n.createElement("div",{className:e,ref:"rightPane"},n.createElement("div",{className:"panel-heading"},n.createElement("h2",{className:"target-heading"},"Targets")),n.createElement("div",{className:"instructions",dangerouslySetInnerHTML:{__html:r(a,{sanitize:!0})}}),n.createElement("div",{className:"lps-controls"},n.createElement("button",{className:"btn",onClick:this.addTarget},n.createElement("span",{className:"fa fa-plus"})," Add Target"),c),n.createElement("div",{className:"arguments-scroll-container"},t))}})},{"./audio-event":5,"./target-view":11,"animation-utilities":void 0,marked:void 0,react:void 0,"skills-service-manager":void 0}],9:[function(e,t,i){"use strict";const n=e("react"),s=e("./chat-message");Object.defineProperty(i,"__esModule",{value:!0}),i.default=n.createClass({getInitialState(){return{messages:[]}},componentDidMount(){this.props.reloadWatcher.on("reload",()=>{this.addMessage({break:!0})})},addMessage(e){let t=this.state.messages;t.push(e),this.setState({messages:t})},appendMessage(e){if("/pau/"!==e&&"<break>"!==e&&"[lpau]"!==e){let t=this.state.messages[this.state.messages.length-1];t?(t.content+=e+" ",this.forceUpdate()):(t={author:"jibo",content:e,date:new Date},this.addMessage(t))}},componentWillUpdate(){let e=this.refs.messageContainer.getDOMNode();this.shouldScrollBottom=e.scrollTop+e.offsetHeight+15>=e.scrollHeight},componentDidUpdate(){if(this.shouldScrollBottom){let e=this.refs.messageContainer.getDOMNode();e.scrollTop=e.scrollHeight}},render(){let e;return e=this.state.messages.map(function(e){if(""!==e.content)return n.createElement(s.default,{message:e})}),e.length||(e=n.createElement("div",{className:"chat-no-messages"},"No messages")),n.createElement("div",{ref:"messageContainer",className:"chat-messages"},e)}})},{"./chat-message":6,react:void 0}],10:[function(e,t,i){"use strict";const n=e("react"),s=e("skills-service-manager"),o=e("jquery");Object.defineProperty(i,"__esModule",{value:!0}),i.default=n.createClass({getInitialState(){return{notifications:[]}},componentWillMount(){s.NotificationsService.instance.on("notification-created",e=>{console.log(e),this.state.notifications.push(e),this.setState({notifications:this.state.notifications});let t=this.refs.notifications.getDOMNode(),i={message:{backgroundColor:"#8B9B9C",border:"4px solid #9FB1B3"},battery:{backgroundColor:"#DE442F",border:"4px solid #FF4E36"},alarm:{backgroundColor:"#DE7400",border:"4px solid #FF8500"},twitter:{backgroundColor:"#338CDC",border:"4px solid #3BA2FF"}};const n=o(t);n.append(`<div class="notification-item"><img class="${"alarm"===e.type?"shake-horizontal shake-constant":""}" src="assets/images/${e.type}.png"/><h1>${e.title}</h1><p>${e.description}</p></div>`).find(".notification-item:last").css(i[e.type]).css({marginTop:"-89px"}).animate({marginTop:"1px"},250).delay(1500).animate({marginTop:"-89px"},250).delay(2e3).queue(function(){o(this).remove()})})},handleRemove(){},render(){return n.createElement("div",{className:"notifications",ref:"notifications"})}})},{jquery:void 0,react:void 0,"skills-service-manager":void 0}],11:[function(e,t,i){"use strict";const n=e("react");Object.defineProperty(i,"__esModule",{value:!0}),i.default=n.createClass({getInitialState(){return{id:this.props.target.id,isSelected:this.props.isSelected}},componentDidMount(){this.id=this.props.target.id},onIdChange(e){let t=e.target.value;this.props.setTargetId(this.props.target.id,t),this.setState({id:t})},onClick(){this.props.onClick(this.props.target.id)},onRemoveTarget(){this.setState({isSelected:!0}),this.props.removeTarget(this.props.target.id)},render(){let e,t=this.props.target.parts[0].value.rays[0].dir;for(e in t)t[e]=Number(t[e]).toFixed(5);let i=this.props.isSelected?"lpsTarget isSelected":"lpsTarget unselected";return n.createElement("div",{className:i,onClick:this.onClick},n.createElement("button",{className:"btn remove",onClick:this.onRemoveTarget},n.createElement("span",{className:"fa fa-times"})),n.createElement("div",{className:"targetId"},n.createElement("span",{className:"title"},"ID:"),n.createElement("span",{className:"value"},this.props.target.id)),n.createElement("div",{className:"location"},n.createElement("span",{className:"value x"},"x: ",t.x),",",n.createElement("span",{className:"value y"},"y: ",t.y),",",n.createElement("span",{className:"value z"},"z: ",t.z)))}})},{react:void 0}],12:[function(e,t,i){"use strict";const n=e("react");Object.defineProperty(i,"__esModule",{value:!0}),i.default=n.createClass({getInitialState(){return{}},componentWillMount(){this.showCameraView=!1,document.addEventListener("click",e=>{for(let t=e.target;t!=document.body;){if(t&&t.id&&"viewTrigger"==t.id)return;if(!t.parentNode)break;t=t.parentNode}this.setShowCameraViewPopup(!1)})},onCameraSelected(e){this.props.setCamera(e.target.id),this.toggleCameraViewPicker()},toggleCameraViewPicker(){this.showCameraView=!this.showCameraView,this.forceUpdate()},selectMode(e){this.mode=e.target.id,this.props.setMode(this.mode)},setShowCameraViewPopup(e){this.showCameraView=e,this.forceUpdate()},render(){let e=this.showCameraView?"show":"hide",t=this.showCameraView?"selected":"unselected",i="audio"===this.mode?"selected":"unselected",s="target"===this.mode?"selected":"unselected";return n.createElement("div",null,n.createElement("div",{className:"tools-top"},n.createElement("button",{id:"audio",className:"top main "+i,onClick:this.selectMode},n.createElement("span",{id:"audio",className:"fa fa-microphone icon"})),n.createElement("button",{id:"target",className:"top main "+s,onClick:this.selectMode},n.createElement("span",{id:"target",className:"fa fa-dot-circle-o icon"}))),n.createElement("div",{className:"tools-bottom"},n.createElement("button",{id:"viewTrigger",className:"bottom main "+t,onClick:this.toggleCameraViewPicker},n.createElement("span",{className:"fa fa-video-camera icon"})),n.createElement("div",{className:"popup "+e,id:"viewPopup"},n.createElement("button",{className:"option",id:"viewTop",onClick:this.onCameraSelected},"Top"),n.createElement("button",{className:"option",id:"viewFront",onClick:this.onCameraSelected},"Front"),n.createElement("button",{className:"option",id:"viewReset",onClick:this.onCameraSelected},"Reset"))))}})},{react:void 0}],13:[function(e,t,i){"use strict";function n(e){e.style.width="0px",e.style.height="0px",e.addEventListener("did-finish-load",function(){e.style.width="1280px",e.style.height="720px"})}const s=e("react"),o=e("skills-service-manager"),a=e("./views/chat-view"),r=e("./views/lps-view"),c=e("./react-components/tab-bar"),l=e("events"),d=e("skills-service-manager"),u=e("./views/notifications-view"),h=e("animation-utilities"),m=e("jibo-kb"),p=new m.KnowledgeBase,f=e("resolve"),g=e("./face-on-body"),v=e("./dimensions"),y=e("async"),E=e("path"),b=e("electron"),S=h.visualize.createRobotRenderer;let w,x,T="true"===b.ipcRenderer.sendSync("is-remote-mode");T&&(v.default.CHAT_WIDTH=0);let N,k=s.createClass({getInitialState(){return{currentView:"chat"}},componentWillMount(){this.reloadWatcher=new l.EventEmitter,w=x=JSON.parse(b.ipcRenderer.sendSync("get-simulator-settings"))},render(){let e=[{label:"Chat",id:"chatTab",icon:"icon fa fa-comment",callback:()=>{this.setState({currentView:"chat"})}},{label:"LPS",id:"lpsTab",icon:"icon fa fa-compass",callback:()=>{this.setState({currentView:"lps"})}}],t="chat"==this.state.currentView;if(T)return s.createElement("div",null);{let i,n,o;return i=s.createElement(c.default,{tabs:e}),n=s.createElement(a.default,{ref:"chat",loop:this.props.loop,speakerId:x.speakerId,ttsMode:x.ttsMode,onWords:this.onWords,isSelected:t,reloadWatcher:this.reloadWatcher}),o=s.createElement(r.default,{ref:"lps",isSelected:!t,robotRenderer:this.robotRenderer,parent:this,visualizer:this.visualizer,updateTargets:this.forceUpdate.bind(this)}),s.createElement("div",null,i,n,o)}},getVisualizerContainer(){return this.visualizer},getRobotRenderer(){return this.robotRenderer},componentDidMount(){o.LPSService.instance&&o.LPSService.instance.on("update",()=>{this.forceUpdate()});let e=0,t=(t,i)=>{w=t,x=i,w.ttsMode!==x.ttsMode&&e<20&&(e++,this.forceUpdate())};const i=document.getElementById("container"),s=document.getElementById("face"),a=document.getElementById("visualizer"),r=document.getElementById("skill");this.visualizer=a,g.default.init(this.props.robotInfo,S,i,s,a,t,(e,t,i)=>{x=i,s.className="loading",b.ipcRenderer.on("reload-skill",()=>{r.reloadIgnoringCache()}),r.addEventListener("did-start-loading",()=>{s.className="loading",this.reloadWatcher.emit("reload"),n(r)}),this.robotRenderer=t;let a=!1;b.ipcRenderer.on("toggle-dev-tools",(e,t)=>{t?r.openDevTools():(a=!0,r.closeDevTools())}),r.addEventListener("devtools-closed",()=>{return a?void(a=!1):void b.ipcRenderer.send("close-dev-tools")});const c=()=>{!r.isDevToolsOpened()&&x.isDevToolsOpened?r.openDevTools():r.isDevToolsOpened()&&!x.isDevToolsOpened&&r.closeDevTools(),r.insertCSS("html{min-width: 1280px; min-height: 720px;} body{min-width: 1280px; min-height: 720px; margin: 0px; overflow: hidden;}"),r.addEventListener("devtools-closed",()=>{return a?void(a=!1):void b.ipcRenderer.send("close-dev-tools")}),s.className="",N&&N===o.GlobalListen.getInstance()||(N=o.GlobalListen.getInstance(),o.GlobalListen.getInstance().events.listen.hjHeard.on(()=>{o.LPSService.instance.triggerSimulatedHJEvent()}))};r.addEventListener("dom-ready",c),o.BodyService.instance&&o.BodyService.instance.on("update",e=>{t.display(e)}),r.src=b.ipcRenderer.sendSync("get-skill-path")})},onWords(e){o.ASRService.instance.onWordsReceived(e)}});y.series([e=>{if(T)b.ipcRenderer.send("registry-init","http://127.0.0.1:8181"),e();else{let t=E.join(f.sync("skills-service-manager",{basedir:__dirname}),".."),i=new d.Factory({RegistryService:{host:"127.0.0.1",port:0},services:{KBService:{port:0},TTSService:{port:0},LPSService:{port:0},ASRService:{port:0},ListenService:{port:0},BodyService:{port:0},ErrorService:{port:0},SystemMonitoringServiceSim:{port:0},NLUService:{port:0},NotificationsService:{port:0},MediaService:{port:0},MediaManagerService:{port:0},MediaProxyService:{port:0},SystemManagerService:{port:0},SkillsServiceSim:{port:0,skillsBaseDir:E.join(b.ipcRenderer.sendSync("get-skill-path"),"..")}}},t);i.init(()=>{const t=`http://127.0.0.1:${d.RegistryClient.instance.port}/registry`;b.ipcRenderer.send("registry-init",t),e()})}},e=>{p.init({host:"127.0.0.1",port:d.KBService.instance.port},()=>{p.initLoop(),p.initMedia(),e()})},e=>{p.loop.loadLoop((t,i)=>{t&&(i=[]);let n=new h.JiboConfig;h.RobotInfo.createInfo(n,t=>{s.render(s.createElement(k,{robotInfo:t,asrService:o.ASRService.instance,loop:i}),document.getElementById("sidebar")),s.render(s.createElement(u.default,null),document.getElementById("notifications")),e()})})}],function(e){e&&console.error(`Simulator: ${e}`)})},{"./dimensions":1,"./face-on-body":2,"./react-components/tab-bar":3,"./views/chat-view":7,"./views/lps-view":8,"./views/notifications-view":10,"animation-utilities":void 0,async:void 0,electron:void 0,events:void 0,"jibo-kb":void 0,path:void 0,react:void 0,resolve:void 0,"skills-service-manager":void 0}]},{},[13])(13)});