chatInput.$inject=["$rootScope","$timeout","socket"],chatHeader.$inject=["chatService"],chatContainer.$inject=["chatService"],linkyWithHtml.$inject=["$filter"],chatFooter.$inject=["chatService"],chatFinish.$inject=["chatService"],chatPopup.$inject=["chatService"],ngDraggable.$inject=["$document","$window","$rootScope"],ngMobileClick.$inject=["chatService"];var template="";function LoadConfig(t,e,o,a,s,n,r,c,i,l){var h=t;h.socket=cr_socket,h.restarting=!1,i.devLog("Chat-Robot: init run.js"),h.serverUrl="production"==n.TYPE?n.SCRIPT_URL:"/",h.writting=!1,h.audio=new Audio(h.serverUrl+"assets/alert.mp3"),h.easter={mario:{active:!1,element:"mario-coin",sound:function(){new Audio(h.serverUrl+"assets/easter/mario-coin.mp3").play()}},travolta:{active:!1,element:"travolta",timer:3300},mortalkombat:{active:!1,sound:function(){var t=Math.floor(18*Math.random()+1);new Audio(h.serverUrl+"assets/easter/mortalkombat/mk3-"+t+".mp3").play()}}},h.templates=["","clasic","simple","absolute","modern"],h.styles=[{"":{}},{primary:"#5089BE",secondary:"#DADAD9",textPrimary:"white",textSecondary:"#3C3C3B",textAttr:"#575756"},{primary:"#34495e",secondary:"#DADAD9",textPrimary:"white",textSecondary:"#3C3C3B",textAttr:"#575756"},{primary:"#7f8c8d",secondary:"#DADAD9",textPrimary:"white",textSecondary:"#3C3C3B",textAttr:"#575756"},{primary:"#9b59b6",secondary:"#DADAD9",textPrimary:"white",textSecondary:"#3C3C3B",textAttr:"#575756"},{primary:"#f1c40f",secondary:"#DADAD9",textPrimary:"white",textSecondary:"#3C3C3B",textAttr:"#575756"},{primary:"#e67e22",secondary:"#DADAD9",textPrimary:"white",textSecondary:"#3C3C3B",textAttr:"#575756"},{primary:"#e74c3c",secondary:"#DADAD9",textPrimary:"white",textSecondary:"#3C3C3B",textAttr:"#575756"},{primary:"#2ecc71",secondary:"#DADAD9",textPrimary:"white",textSecondary:"#3C3C3B",textAttr:"#575756"}],h.themeColors=h.styles[1],h.minHeight=450,h.development="localhost"==n.TYPE||"development test"==n.TYPE,h.intervalAlertNewMsg="",h.documentTitle=document.title,h.messageFinished=[{finished:"Iniciar nueva charla",onback:"Conectando con un nuevo asistente..."},{finished:"Realizar otra consulta",onback:"Retomando la converzación, esperando al asistente..."}],h.init=function(){angular.element(document).ready(function(){h.messages={},cr_cookies&&cr_cookies.cr_sessionId&&cr_cookies.cr_data_response?h.setDataChat(cr_cookies.cr_data_response):cr_data?a(function(){i.setCookies("cr_sessionId",cr_data.sessionId),i.setCookies("cr_data_response",cr_data),h.setDataChat(cr_data)},500):(i.devLog("restart"),i.devLog(cr_dataSession),l.newSession(cr_dataSession),l.on("create:chat",function(t){console.log(t),i.devLog("Create new Chat"),i.devLog(t),i.setCookies("cr_data_response",t),i.setCookies("cr_sessionId",t.sessionId),i.setCookies("cr_state_open","true"),h.setDataChat(t)}))})},h.setDataChat=function(t){i.devLog(t),t.conversions&&i.postMessages("createConversions",t.conversions),t.design||(t.design={}),t.design.autostart||(t.design.autostart=5),t.design.position||(t.design.position="rigth"),t.design.style||(t.design.style=1),t.design.template||(t.design.template=1),t.noSource||(h.liveChat={status:!1,config:!1},h.chat={open:cr_cookies&&"true"==cr_cookies.cr_state_open,name:t.design.name,template:t.design,sessionId:t.sessionId,default_avatar:h.serverUrl+"assets/images/user-avatar.svg",assistant:t.robot,power_by:{url:t.design.white_label&&""!=t.design.white_label.url?t.design.white_label.url:"http://www.chat-robot.com/",name:t.design.white_label&&""!=t.design.white_label.name?t.design.white_label.name:"CR"},first_msg:t.answer,started:cr_cookies&&cr_cookies.cr_sessionId,finished:cr_cookies&&cr_cookies.cr_finished,step:cr_cookies&&cr_cookies.cr_step?cr_cookies.cr_step:t.step,last_message:"",isMobile:"mobile"==cr_dataSession.device,on_finish:t.design&&t.design.on_finish?t.design.on_finish:0,isPopup:cr_dataSession.popup},h.themeColors=h.styles[h.chat.template.style],i.messagesCookie(),i.setCookies("cr_data_response",t),h.initChat(),t=!1)},h.getOption=function(t,e){return t[e]},h.isActiveEa=function(t){return h.easter[t].active},h.$on("$destroy",function(t){a.cancel(recive)}),l.on("connect_success",function(){i.restartConnection()}),cr_socket.on("add log",function(t){if(h.chat.started){i.devLog("Reconnect to server");var e=Object.keys(h.messages).length;"user"==h.messages[e-1].type&&""!=h.chat.last_message&&l.emit("guest:message",h.chat.last_message)}})}function interceptorsServices(o,a){return{responseError:function(t){switch(t.status){case 408:console.log("Error al conectar con el servidor, se agoto el tiempo de consulta.");break;case-1:console.log("Error al conectar con el servidor, no se encontro el servidor.");break;case 500:var e=a.get("chatService");console.log("Error interno, reiniciando charla..."),e.restartChat()}return o.reject(t)}}}function ChatServices(t,e,o,a,s,n,r,c,i,l,h){var d=t,u={messagesCookie:function(){if(cr_cookies&&cr_cookies.cr_log){cr_cookies.cr_log.config.operator&&(d.liveChat.status=!0,d.liveChat.config=cr_cookies.cr_log.config.operator),"end"==cr_cookies.cr_log.config.current_field&&(d.chat.finished=!0);var t=cr_cookies.cr_log,a=!1;d.setMessage("Chat iniciado...","system"),d.setMessage(d.chat.assistant.name+" se unio al chat.","systemGroup"),angular.forEach(t.log,function(t,e){var o=t.guest?"user":t.robot_id?"assistant":"userLive";!a&&"userLive"==o&&d.liveChat.status&&(d.setMessage(d.chat.assistant.name+" abandono el chat.","systemGroup"),u.setCookies("cr_live_chat",!0),d.setMessage(d.liveChat.config.name+" se unio al chat.","systemGroup"),a=!0),d.setMessage(t.value,o,!0)})}},setConversion:function(t){angular.forEach(t,function(n,t){angular.forEach(["facebook-pixel","google-adwords","google-analytics","google-remarketing"],function(t,e){if(0<=n.name.search(t)){var o=n.name.substring(t.length+1,n.name.length),a=n;if(u.devLog("filter: "+t),"facebook-pixel"==t&&parent.postMessage(["cr_conversion",["facebook",o]],"*"),"google-analytics"==t){var s={category:"",action:"",label:""};null!=a.value&&(s={category:a.value.eventCategory||"",action:a.value.eventAction||"",label:a.value.eventLabel||""}),parent.postMessage(["cr_conversion",["google-analytics",s]],"*")}if("google-adwords"==t&&null!=a.value){a={code:a.value.code,label:a.value.label};parent.postMessage(["cr_conversion",["google-adwords",a]],"*")}}})})},clearCookies:function(){cr_data=cr_cookies=!1,parent.postMessage("cr_clearCookies","*")},restartChat:function(t){var e=angular.element(document.querySelector("#chat-robot-msg-send")),o=angular.element(document.querySelector(".chat-robot-footer-content")),a=t?3e3:0;i.cancel(d.intervalPing),d.finished=!1,cr_data="",n(function(){u.clearCookies(),n.cancel(d.recive),o.addClass("ng-hide"),e.removeClass("disabled").attr("placeholder","Escriba su mensaje..."),e[0].focus(),d.init()},a)},goBackstage:function(t){angular.element(document.querySelector("#chat-robot-msg-send"))[0].focus(),h.emit("getBackstage")},devLog:function(t){d.development&&(r.info("CR:"),r.debug(t))},setCookies:function(t,e){var o=["cr_cookies",[]];o[1].push([t,e]),cr_cookies[t]=e,parent.postMessage(o,"*")},postMessages:function(t,e){var o=["cr_actions",[]];o[1].push([t,e]),parent.postMessage(o,"*")},restartConnection:function(){d.restarting||(d.restarting=!0,h.emit("start",{params:cr_dataSession,sessionId:d.chat.sessionId}),d.restarting=!1,d.chat.started||d.init())}};return window.addEventListener("message",function(t){var e=t.data[0],o=t.data[1];switch(e){case"cr_isMobile":d.chat.isMobile=o}}),u}function socketComunication(a,t){return{on:function(e,o){e=e.replace(":"," "),cr_socket.on(e,function(){var t=arguments;"error"==e?console.log(data||"error"):"connect_failed"==e?console.log(data||"connect_failed"):"disconnect"==e?console.log(data||"disconnect"):a.$apply(function(){o.apply(cr_socket,t)})})},emit:function(t,e,o){t=t.replace(":"," "),cr_socket.emit(t,e,function(){var t=arguments;a.$apply(function(){o&&o.apply(cr_socket,t)})})},newSession:function(t){cr_socket.emit("newSession",t)},reconnect:function(){cr_socket.io.reconnect()}}}function ChatController(t,s,o,e,a,n,r,c,i,l){var h,d,u,g,m=t;c.devLog("Chat-Robot: init chat.js"),m.sendForm={},m.lastRecive="",m.recive="",m.chatShow=!1,m.haveCoin=!1,o(function(){},1e3);r.innerHeight;var p=m.minHeight;angular.element(r).on("focus click mousemove",function(){m.alertUser=!0,o.cancel(m.intervalAlertNewMsg)}).on("resize",function(){}),m.initChat=function(){h=angular.element(document.querySelector("#chat-robot")),d=angular.element(document.querySelector("#chat-robot-header")),u=angular.element(document.querySelector("#chat-robot-msg-send")),g=angular.element(document.querySelector(".chat-robot-footer-content")),m.chat.isPopup&&(p=m.innerHeight),s(function(){var t=d[0].offsetHeight;m.chat.open;c.setCookies("cr_limit_h",t),c.postMessages("chatOpen",m.chat.open),h.css({height:"100%",transition:"none"}),m.chatShow=!0,h.css({transition:""})},500),cr_cookies&&cr_cookies.cr_sessionId?s(function(){g.css("display","block"),m.chat.finished?m.finishChat():(g.removeClass("ng-hide"),u.prop("disabled",!1),u[0].focus()),m.scroll(),m.setTitleText(cr_cookies.cr_text_close),m.chat.open&&h.attr("data-state","open")},100):s(function(){-1=p?cr_cookies.cr_new_height:p;h.css({height:t+"px"}).attr("data-state","open"),c.setCookies("cr_state_open",!0),c.setCookies("cr_new_height",t),m.chat.started||m.startChat(),m.chat.open=!0},m.closeChat=function(){var t=d[0].offsetHeight;c.setCookies("cr_new_height",h[0].offsetHeight),h.css({height:t+"px"}).attr("data-state","close"),c.setCookies("cr_state_open",!1),m.chat.open=!1},m.scroll=function(){if(c.devLog(["Scoll bar, is mobile:",m.chat.isMobile]),m.chat.isMobile){(t=angular.element(document.querySelector(".ngscroll-content-container"))[0]).scrollTop=t.scrollHeight}else{angular.element(document.querySelector(".ngsb-wrap"))[0];var t=document.querySelector(".ngsb-container");m.$broadcast("scrollBottom")}},m.finishChat=function(){if(!m.chat.finished){var t=m.chat.finished;s(function(){u.prop("disabled",!0).val("").addClass("disabled").attr("placeholder","Chat finalizado."),m.writting=!1,s(function(){m.setMessage(m.chat.assistant.name+" abandono el chat.","systemGroup"),s(function(){m.setMessage("Chat Finalizado.","system"),m.setTitleText("Chat finalizado."),s(function(){m.chat.finished=!0,c.setCookies("cr_finished",!0),c.postMessages("chatFinish",cr_data.conversions)},t?0:2e3)},t?0:500)},t?0:2e3)},t?0:2e3)}},m.restartChat=function(){c.restartChat(!0)},m.goBackstage=function(){c.goBackstage(!0)},m.isFinished=function(){return m.chat&&m.chat.finished&&m.chat.open},m.socketOff=function(){return cr_socket.disconnected},l.on("agent:writing",function(t){m.writting=t}),l.on("chat:message",function(t){"error"==t&&c.restartChat(),!m.liveChat.status&&t.config?(m.setMessage(m.chat.assistant.name+" abandono el chat.","systemGroup"),s(function(){m.liveChat.config=t.config,m.liveChat.status=!0,m.setMessage(m.liveChat.config.name+" se unio al chat.","systemGroup"),m.writting=!0,m.chat.last_message="",m.userLive=t.config,s(function(){m.setMessage(t.value,"userLive")},2e3)},2e3)):(t.value&&(t=t.value),m.lastRecive=t,m.reciveMessage(t))}),l.on("chat:finish",function(){m.finishChat()}),l.on("chat:restart",function(){c.restartChat(!0)}),l.on("chat:backstage",function(t){m.chat.finished=!1,c.setCookies("cr_finished",!1),s(function(){u.prop("disabled",!1).val("").removeClass("disabled").attr("placeholder","Escriba su mensaje..."),m.setMessage(m.chat.assistant.name+" retornó al chat.","systemGroup"),m.writting=!0,m.chat.last_message="",s(function(){m.reciveMessage(t)},3e3)},2e3)}),l.on("chat:conversion",function(t){t&&c.setConversion(t)}),l.on("chat:activeea",function(t){if(null!=m.easter[t]){null!=m.easter[t].sound&&m.easter[t].sound(),m.easter[t].active=!0;var e=m.easter[t].timer?m.easter[t].timer:1e3;s(function(){m.chat.last_message="",m.easter[t].active=!1},e)}})}function chatInput(s,n,r){return{restrict:"C",require:"ngModel",link:function(o,t,e,a){t.bind("keydown keypress",function(t){var e=s,o=t.keyCode||t.which;e.chat.last_message&&(e.sended||r.emit("agent stop"),n.cancel(e.sended),e.sended=null,e.sended=n(function(){var t=e.chat.last_message;r.emit("guest:message",t),e.sended=null},3e3)),"13"==o&&(n.cancel(e.sended),e.sended=null)}),o.$watch(function(){return a.$modelValue},function(t){if(null!=o.$root.chat&&o.$root.chat.isMobile){var e=angular.element(document.querySelector("#chat-robot"));n(function(){e.css({height:"99%"}),n(function(){e.css({height:"100%"})},100)},100)}})}}}function chatHeader(t){return t.devLog("Chat-Robot: header.js"),{restrict:"E",templateUrl:"templates/header.html"}}function chatContainer(t){return t.devLog("Chat-Robot: containter.js"),{restrict:"E",templateUrl:"templates/container.html"}}function linkyWithHtml(a){return function(t){var e=t;if(null!=t){var o=t.replace(/<[\/]{0,1}(a|A)[^><]*>/g,"");e=a("linky")(o,"_blank").replace(/\>/g,">").replace(/\</g,"<")}return e}}function chatFooter(t){return t.devLog("Chat-Robot: footer.js"),{restrict:"E",templateUrl:"templates/footer.html"}}function chatFinish(t){return t.devLog("Chat-Robot: finish.js"),{restrict:"E",templateUrl:"templates/finish.html"}}function chatPopup(t){return t.devLog("Chat-Robot: popup.js"),{restrict:"E",templateUrl:"templates/popup.html"}}function ngDraggable(t,e,o){return{restrict:"A",scope:{dragOptions:"=ngDraggable"},link:function(t,e,o){e.on("mousedown",function(t){parent.postMessage("cr_mousedown","*")})}}}function ngMobileClick(t){return t.devLog("Chat-Robot: mobile.js"),function(e,t,o){var a="touchstart click";"true"==o.onlyMobile&&(a="touchstart"),t.bind(a,function(t){t.preventDefault(),t.stopPropagation(),e.$apply(o.ngMobileClick)})}}angular.module("chatRobot",["ngSanitize","chatRobot.templates","chatRobot.constants","widget.scrollbar"]).run(LoadConfig),LoadConfig.$inject=["$rootScope","factoryChat","$http","$timeout","$log","ENV","$window","$interval","chatService","socket"],angular.module("chatRobot.constants",[]).constant("ENV",{TYPE:"production",API_URL:"https://api.chat-robot.com/",SCRIPT_URL:"//script2.chat-robot.com/"}).constant("httpPort",40080).constant("httpsPort",40443).constant("path","public_html").constant("MicrosoftAPI","e964a60f-977c-4d96-9685-fb81eb7c1019").constant("MicrosoftPassword","EEpdWNGgXSuf7WbC0pHJHj2").constant("LUISUrl","https://api.projectoxford.ai/luis/v1/application?id=da68c897-7196-4bec-b168-45db108c871b&subscription-key=543b19671ca84d5f9251cda339202496").constant("MongoDB",{address:"www.chat-robot.com",port:27017,db:"koves"}).constant("Redis",{address:"192.168.238.128",port:"6379",maxAge:24192e5,secret:"58e34be7b6cc4144d17d03c3"}),angular.module("chatRobot").factory("factoryChat",["$rootScope","$http","ENV",function(t,o,e){var a={},s=e.API_URL;return a.getChat=function(t){return o.post(s+"chat/browser/get",t)},a.createChat=function(t){return o.post(s+"chat/browser/create",t)},a.updateChat=function(t){return o.post(s+"chat/browser/update",t)},a.sendPing=function(t){var e={sessionId:t};return o.post(s+"chat/ping/update",e)},a.getLiveChatConfig=function(t){var e={sessionId:t};return o.post(s+"chat/livechat/config",e)},a}]),angular.module("chatRobot").factory("interceptorsServices",interceptorsServices),interceptorsServices.$inject=["$q","$injector"],angular.module("chatRobot").factory("chatService",ChatServices),ChatServices.$inject=["$rootScope","factoryChat","interceptorsServices","$filter","$http","$timeout","$log","$window","$interval","$document","socket"],angular.module("chatRobot").factory("socket",socketComunication),socketComunication.$inject=["$rootScope","$timeout"],angular.module("chatRobot").controller("ChatController",ChatController),ChatController.$inject=["$rootScope","$timeout","$interval","$log","factoryChat","ENV","$window","chatService","$document","socket"],angular.module("chatRobot").directive("chatRobotFooterInput",chatInput),angular.module("chatRobot").directive("chatHeader",chatHeader),angular.module("chatRobot").directive("chatContainer",chatContainer).filter("linkyWithHtml",linkyWithHtml),angular.module("chatRobot").directive("chatFooter",chatFooter),angular.module("chatRobot").directive("chatFinish",chatFinish),angular.module("chatRobot").directive("chatPopup",chatPopup),angular.module("chatRobot").directive("ngDraggable",ngDraggable),angular.module("chatRobot").directive("ngMobileClick",ngMobileClick),angular.module("widget.scrollbar",[]).directive("ngScrollbar",[function(){return{restrict:"AE",transclude:!0,scope:{scrollbarConfig:"=scrollbarConfig",scrollbarX:"@",scrollbarY:"@"},template:'
',controller:"scrollbarController",compile:function(t){return t.css("overflow","hidden"),function(t,e,o,a){a.init(e,t.scrollbarConfig)}}}}]).controller("scrollbarController",[function(){var o,a,s,n,r,c={dragSpeed:1,autoResize:!1,show:!1,scrollbar:{width:6,hoverWidth:8,color:"rgba(0,0,0,.3)"},scrollbarContainer:{width:12,borderLeft:"1px solid #ccc",color:"rgba(255,255,255,1)"}};this.init=function(t,e){o=t,s=angular.copy(angular.extend(c,e||{})),a=angular.element(t[0].querySelector(".ngscroll-content-container")),n=(s.scrollbarContainer.width-s.scrollbar.width)/2,r=(s.scrollbarContainer.width-s.scrollbar.hoverWidth)/2},angular.extend(this,{winEl:angular.element(window),getContainerElement:function(){return o},getContentElement:function(){return a},getConfig:function(){return s},getScrollbarMargin:function(){return n},getScrollbarHoverMargin:function(){return r}})}]).directive("ngScrollbarY",["$timeout",function(w){return{restrict:"AE",require:"^ngScrollbar",replace:!0,template:'
',compile:function(){return function(t,e,o,a){var s=a.getConfig(),n=angular.element(document),r=a.getContainerElement(),c=a.getContentElement(),i=angular.element(e[0].querySelector(".ngscrollbar-y")),l=a.getScrollbarMargin(),h=a.getScrollbarHoverMargin();t.styles={scrollbarContainer:{position:"absolute",width:s.scrollbarContainer.width+"px",height:"100%",top:0,right:0,transition:"background .3s ease-in-out","border-radius":s.scrollbarContainer.width/2+"px"},scrollbar:{position:"absolute",width:s.scrollbar.width+"px",right:l+"px",cursor:"default",opacity:0,transition:"opacity .3s ease-in-out, border-radius .1s linear, width .1s linear, right .1s linear",background:s.scrollbar.color,"border-radius":s.scrollbar.width/2+"px"}};function d(){return c[0].offsetHeight}function u(){return r[0].offsetHeight}function g(){return d()>u()}function m(){i.css("opacity",0)}function p(){i.css("opacity",1)}function f(){var t=parseInt(c.css("margin-top"),10);c.css("margin-top","0px"),g()?(e.css("display","block"),i.css("height",Math.pow(u(),2)/d()-2*l+"px"),v(t),s.show&&p()):e.css("display","none")}function b(t){var e=parseInt(c.css("margin-top"),10)+t;v(e)}var v=function(t){t=Math.min(0,Math.max(t,u()-d())),c.css("margin-top",t+"px"),i.css("top",-t/d()*u()+l+"px")};r.on("mousewheel",function(t){g()&&(t.preventDefault(),void 0!==t.originalEvent&&(t=t.originalEvent),b(t.wheelDeltaY||t.wheelDelta))}),0<=window.navigator.userAgent.toLowerCase().indexOf("firefox")&&r.on("wheel",function(t){g()&&(t.preventDefault(),void 0!==t.originalEvent&&(t=t.originalEvent),b(40*-t.deltaY))}),e.on("mouseenter",function(){e.css("background",s.scrollbarContainer.color),i.css("width",s.scrollbar.hoverWidth+"px"),i.css("right",h+"px"),i.css("border-radius",s.scrollbar.hoverWidth/2+"px")}),e.on("mouseleave",function(){e.css("background","none"),i.css("width",s.scrollbar.width+"px"),i.css("right",l+"px"),i.css("border-radius",s.scrollbar.width/2+"px")});var _,C,y=!1,k=!1;s.show||(r.on("mouseenter",function(){k=!0,p()}),r.on("mouseleave",function(){k=!1,y||m()})),i.on("mousedown",function(t){t.preventDefault(),_=t.screenY,y=!0,n.one("mouseup",function(){y=!1,s.show||k||m()})}),n.on("mousemove",function(t){y&&(t.preventDefault(),b(-(t.screenY-_)*s.dragSpeed*d()/u()),_=t.screenY)}),w(function(){(f(),document.createStyleSheet)?(c.on("DOMNodeInserted",f),c.on("DOMNodeRemoved",f)):new MutationObserver(function(t){t.length&&f()}).observe(c[0],{childList:!0,subtree:!0})},5),t.$on("scrollBottom",function(){b(-1*d())}),s.autoResize&&a.winEl.on("resize",function(t){C&&clearTimeout(C),C=setTimeout(function(){C=null,f()},50)})}}}}]).directive("ngScrollbarX",["$timeout",function(k){return{restrict:"AE",replace:!0,require:"^ngScrollbar",template:'
',compile:function(){return function(t,e,o,a){var s=a.getConfig(),n=angular.element(document),r=a.getContainerElement(),c=r[0],i=a.getContentElement(),l=angular.element(e[0].querySelector(".ngscrollbar-x")),h=a.getScrollbarMargin(),d=a.getScrollbarHoverMargin();t.styles={scrollbarContainer:{position:"absolute",width:"100%",transition:"background .3s ease-in-out","border-radius":s.scrollbarContainer.width/2+"px"},scrollbar:{position:"absolute",cursor:"default",opacity:0,transition:"opacity .3s ease-in-out, border-radius .1s linear, width .1s linear, right .1s linear",background:s.scrollbar.color,"border-radius":s.scrollbar.width/2+"px"}},e.css("height",s.scrollbarContainer.width+"px"),e.css("bottom",0),e.css("left",0),l.css("top",h+"px"),l.css("height",s.scrollbar.width+"px");function u(){return i[0].offsetWidth}function g(){return c.offsetWidth}function m(){l.css("opacity",1)}function p(){l.css("opacity",0)}function f(){var t=parseInt(i.css("margin-left"),10);i.css("margin-left","0px"),u()>g()?(e.css("display","block"),l.css("width",Math.pow(g(),2)/u()-2*h+"px"),b(t),s.show&&m()):e.css("display","none")}var b=function(t){t=Math.min(0,Math.max(t,g()-u())),i.css("margin-left",t+"px"),l.css("left",-t/u()*g()+h+"px")};e.on("mouseenter",function(){e.css("background",s.scrollbarContainer.color),l.css("height",s.scrollbar.hoverWidth+"px"),l.css("top",d+"px"),l.css("border-radius",s.scrollbar.hoverWidth/2+"px")}),e.on("mouseleave",function(){e.css("background","none"),l.css("height",s.scrollbar.width+"px"),l.css("top",h+"px"),l.css("border-radius",s.scrollbar.width/2+"px")});var v,_,C=!1,y=!1;s.show||(r.on("mouseenter",function(){y=!0,m()}),r.on("mouseleave",function(){y=!1,C||p()})),l.on("mousedown",function(t){t.preventDefault(),C=!0,v=t.screenX,n.one("mouseup",function(){C=!1,s.show||y||p()})}),n.on("mousemove",function(t){var e,o;C&&(t.preventDefault(),e=-(t.screenX-v)*s.dragSpeed*u()/g(),o=parseInt(i.css("margin-left"),10)+e,b(o),v=t.screenX)}),k(function(){(f(),document.createStyleSheet)?(i.on("DOMNodeInserted",f),i.on("DOMNodeRemoved",f)):new MutationObserver(function(t){t.length&&f()}).observe(i[0],{childList:!0,subtree:!0})},5),s.autoResize&&a.winEl.on("resize",function(t){_&&clearTimeout(_),_=setTimeout(function(){_=null,f()},50)})}}}}]),angular.module("chatRobot.templates",[]).run(["$templateCache",function(t){t.put("templates/chat.html",''),t.put("templates/container.html",'
'),t.put("templates/finish.html",'
Gracias!


Usted há sido atendido por:

{{chat.assistant.name}}
{{chat.assistant.name}}
'),t.put("templates/footer.html",'
{{chat.assistant.name}} esta escribiendo...
'),t.put("templates/header.html",'
{{liveChat.config.name || chat.assistant.name}}
{{liveChat.config.name || chat.assistant.name}}
{{liveChat.config.subtitle || chat.assistant.label}}
Iniciando Chat...
'),t.put("templates/message_user.html",'
{{msg.name}}{{msg.time | date:"H:mm"}}
{{msg.name}}
'),t.put("templates/messages_system.html",'
'),t.put("templates/messages_system_group.html",'
{{msg.name}}
'),t.put("templates/popup.html",'{{chat.assistant.name}}
{{chat.started ? chat.assistant.name : "Haz click acá para chatear con " + chat.assistant.name }}
{{liveChat.config.subtitle || chat.assistant.label}}
')}]);var cr_dataSession=!1,cr_data=!1,cr_cookies=!1,cr_socket=null,canStart=!0;function parseParams(t){var e="";for(var o in t)""!==e&&(e+="&"),e=e+o+"="+t[o];return e}function cr_socketIoInit(t){(cr_socket=io(window.location.origin,{forceNew:!0})).on("connect",function(){null!=cr_cookies.cr_sessionId?cr_socket.emit("start",{params:t,sessionId:cr_cookies.cr_sessionId}):cr_socket.emit("start",{params:t}),cr_socket.on("create chat",function(t){cr_cookies=!1,void 0===t||t.noSource||cr_startSystem(t)}),cr_socket.on("add log",function(t){cr_cookies.cr_log=t,cr_startSystem()})})}function cr_startSystem(t){if(canStart){t&&(cr_data=t);var e=setInterval(function(){if(canStart&&(cr_cookies||cr_dataSession&&cr_data))try{angular.module("ngSanitize"),canStart=!1,console.log("starting"),clearInterval(e),canStart||angular.bootstrap(document,["chatRobot"])}catch(t){console.log("cant open module",t)}},500)}}angular.module("chatRobot").config(["$httpProvider","ENV",function(t,e){"development"==e.TYPE&&console.log("Chat-Robot: init inline app.js"),t.interceptors.push("interceptorsServices")}]),angular.element(document).ready(function(){parent.postMessage("cr_ready","*")}),window.addEventListener("message",function(t){"cr_dataSession"==t.data[0]&&(cr_dataSession=t.data[1]),"cr_data"==t.data[0]&&cr_dataSession?cr_socketIoInit(cr_dataSession):"cr_cookies"==t.data[0]&&(cr_cookies=t.data[1],cr_socketIoInit(cr_dataSession))});