function onWindowResize(n){var t=$(window).width(),i=$(window).height();$(window).resize(function(){var r=$(window).width(),u=$(window).height();(r!==t||u!==i)&&(t=r,i=u,n())})}function getScripts(n,t){var i=0;n.forEach(function(r){$.getScript(r,function(){++i==n.length&&typeof t=="function"&&t()})})}function htmlDecode(n){return $("<textarea/>").html(n).text()}function htmlEncode(n){return $("<textarea/>").text(n).html()}function hideScrollbar(n,t){var i=n.outerWidth(!0);$(".stream",n).width(i+t)}function showNarrow(n){n.outerWidth(!0)<320?$(".twitter-timeline",n).addClass("env-narrow"):$(".twitter-timeline",n).removeClass("env-narrow")}function setStreamHeight(n,t){var i,r,u,f,e;t==!1?(i=0,$(".timeline-header",n).is(":visible")&&(i=$(".timeline-header",n).outerHeight(!0)),r=0,$(".timeline-footer",n).is(":visible")&&(r=$(".timeline-footer",n).outerHeight(!0)),u=n.outerHeight(!0),f=u-(i+r),$(".stream",n).height(f)):(e=$(".h-feed",n).outerHeight(!0),$(".stream",n).height(e))}function updateFeed(){$(".twitter_feed").each(function(){var n=$(this),t=!1,i=!1,r=-2;$(".twitter-timeline",n).hasClass("var-static")&&(t=!0);i=$(".twitter-timeline",n).data("show-scrollbar");t===!1&&i==="False"&&(r=16);hideScrollbar(n,r);showNarrow(n);setStreamHeight(n,t)})}function checkNotEmptyInput(){$("#search").attr("disabled",$.trim($("#q").val())=="")}function addTwitterHashTags(){var n=$('meta[name="twitter:hashtags"]').attr("content");n!=null&&n.length>0&&($("#hlCsTwitter").attr("href",$("#hlCsTwitter").attr("href")+"&amp;hashtags="+n),$("#hlCsTwitterSm").attr("href",$("#hlCsTwitter").attr("href")))}function addWhatsAppShare(){var n=$('meta[name="description"]').attr("content")!=null?$('meta[name="description"]').attr("content"):"",t="whatsapp://send?text="+encodeURIComponent(n+" - "+window.location);$("#hlCsWhatsAppSm").attr("href",t)}function textResizeDetection(){TextResizeDetector.TARGET_ELEMENT_ID="mainContainerFrame";TextResizeDetector.USER_INIT_FUNC=init}function onFontResize(n,t){var i=t[0].iSize;i>threshold?loadCSS("/css/bootstrap-accessibility-firefox.css"):$("link[href='/css/bootstrap-accessibility-firefox.css']").remove()}function init(){var n=TextResizeDetector.addEventListener(onFontResize,null);n>threshold?loadCSS("/css/bootstrap-accessibility-firefox.css"):$("link[href='/css/bootstrap-accessibility-firefox.css']").remove()}function checkSearchHasValue(){return $.trim($("#q").val())==""?($("#support-message").text("Please type a query into the search box."),$("#searchpanel #q").focus(),!1):!0}function applyFocusVisiblePolyfill(n){function f(n){return n&&n!==document&&n.nodeName!=="HTML"&&n.nodeName!=="BODY"&&"classList"in n&&"contains"in n.classList?!0:!1}function c(n){var i=n.type,t=n.tagName;return t=="INPUT"&&h[i]&&!n.readOnly?!0:t=="TEXTAREA"&&!n.readOnly?!0:n.isContentEditable?!0:!1}function o(n){n.classList.contains("focus-visible")||(n.classList.add("focus-visible"),n.setAttribute("data-focus-visible-added",""))}function l(n){n.hasAttribute("data-focus-visible-added")&&(n.classList.remove("focus-visible"),n.removeAttribute("data-focus-visible-added"))}function a(t){t.metaKey||t.altKey||t.ctrlKey||(f(n.activeElement)&&o(n.activeElement),i=!0)}function e(){i=!1}function v(n){f(n.target)&&(i||c(n.target))&&o(n.target)}function y(n){f(n.target)&&(n.target.classList.contains("focus-visible")||n.target.hasAttribute("data-focus-visible-added"))&&(r=!0,window.clearTimeout(u),u=window.setTimeout(function(){r=!1;window.clearTimeout(u)},100),l(n.target))}function p(){document.visibilityState=="hidden"&&(r&&(i=!0),s())}function s(){document.addEventListener("mousemove",t);document.addEventListener("mousedown",t);document.addEventListener("mouseup",t);document.addEventListener("pointermove",t);document.addEventListener("pointerdown",t);document.addEventListener("pointerup",t);document.addEventListener("touchmove",t);document.addEventListener("touchstart",t);document.addEventListener("touchend",t)}function w(){document.removeEventListener("mousemove",t);document.removeEventListener("mousedown",t);document.removeEventListener("mouseup",t);document.removeEventListener("pointermove",t);document.removeEventListener("pointerdown",t);document.removeEventListener("pointerup",t);document.removeEventListener("touchmove",t);document.removeEventListener("touchstart",t);document.removeEventListener("touchend",t)}function t(n){n.target.nodeName&&n.target.nodeName.toLowerCase()==="html"||(i=!1,w())}var i=!0,r=!1,u=null,h={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};document.addEventListener("keydown",a,!0);document.addEventListener("mousedown",e,!0);document.addEventListener("pointerdown",e,!0);document.addEventListener("touchstart",e,!0);document.addEventListener("visibilitychange",p,!0);s();n.addEventListener("focus",v,!0);n.addEventListener("blur",y,!0);n.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&n.host?n.host.setAttribute("data-js-focus-visible",""):n.nodeType===Node.DOCUMENT_NODE&&document.documentElement.classList.add("js-focus-visible")}var threshold,RESPONSIVEUI,event;loadCSS=function(n){var t=$("<link>");$("head").append(t);t.attr({rel:"stylesheet",type:"text/css",href:n})};updateFeed();$("a",".twitter_feed").click(function(){$(this).attr("target","_blank")});TextResizeDetector=function(){function h(){window.clearInterval(i);i=null}function f(){i||(i=window.setInterval("TextResizeDetector.detect()",o))}function c(){var i=TextResizeDetector.getSize(),n,f;if(i!==t)for(n=0;n<r.length;n++)aListnr=r[n],f={iBase:u,iDelta:t!=-1?i-t+"px":"0px",iSize:t=i},aListnr.obj?aListnr.fn.apply(aListnr.obj,["textSizeChanged",[f]]):aListnr.fn("textSizeChanged",[f]);return t}var n=null,o=200,i=null,t=-1,u=-1,r=[],s=function(){n=document.createElement("span");n.id="textResizeControl";n.innerHTML="&nbsp;";n.style.position="absolute";n.style.left="-9999px";var i=document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID);i&&i.insertBefore(n,i.firstChild);u=t=TextResizeDetector.getSize()},e=function(){TextResizeDetector.onAvailableCount_i||(TextResizeDetector.onAvailableCount_i=0);document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID)?(TextResizeDetector.init(),TextResizeDetector.USER_INIT_FUNC&&TextResizeDetector.USER_INIT_FUNC(),TextResizeDetector.onAvailableCount_i=null):TextResizeDetector.onAvailableCount_i<600&&(TextResizeDetector.onAvailableCount_i++,setTimeout(e,200))};return setTimeout(e,500),{init:function(){s();f()},addEventListener:function(n,t){return r[r.length]={fn:n,obj:t},u},detect:function(){return c()},getSize:function(){return n.offsetHeight},stopDetector:function(){return h()},startDetector:function(){return f()}}}();TextResizeDetector.TARGET_ELEMENT_ID="doc";TextResizeDetector.USER_INIT_FUNC=null;$(window).ready(function(){addWhatsAppShare();addTwitterHashTags();textResizeDetection()});threshold=24;$(document).ready(function(){$(".scrollToTop > img").click(function(){$("html, body").animate({scrollTop:0},800)});$(".scrollToTop").bind("keydown",function(n){var t=n.keyCode?n.keyCode:n.which;t===13&&($("html, body").animate({scrollTop:0},800),$("#skip-to-content").focus())})});RESPONSIVEUI={},function(n){RESPONSIVEUI.responsiveTabs=function(){var i=n(".responsive-tabs"),t,r;i.hasClass("responsive-tabs--enabled")||(i.addClass("responsive-tabs--enabled"),t=1,i.each(function(){var i=n(this),c,h,f,r,e,o,s,u;n(i).hasClass("full")?(c=i[0].getAttribute("data-multi"),h=i[0].getAttribute("data-panel")):f=1;i.children(":header").addClass("responsive-tabs__heading");i.children("div").addClass("responsive-tabs__panel");(h==="true"||f===1)&&(r=i.find(".responsive-tabs__panel--active"),r.length||(r=i.find(".responsive-tabs__panel").first().addClass("responsive-tabs__panel--active")));h==="true"||f===1?i.hasClass("full")&&(r=i.find(".responsive-tabs__heading--active"),r.length||(r=i.find(".responsive-tabs__heading").first().addClass("responsive-tabs__heading--active"))):i.hasClass("full")&&(r=i.find(".responsive-tabs__heading--active"),r.length||r.addClass("responsive-tabs__panel--closed-accordion-only"));i.find(".responsive-tabs__panel").not(".responsive-tabs__panel--active").hide().attr("aria-hidden","true");r.attr("aria-hidden","false");i.hasClass("full")||r.addClass("responsive-tabs__panel--closed-accordion-only");e=n("<div/>",{"class":"responsive-tabs-wrapper"});i.wrap(e);o=0;i.find(".responsive-tabs__panel").each(function(){var t=n(this).height();t>o&&(o=t)});s=n("<ul/>",{"class":"responsive-tabs__list",role:"tablist"});u=1;i.find(".responsive-tabs__heading").each(function(){var r=n(this),h=n(this).next(),a,v,l;r.attr("tabindex",0);a=r.text().replace(/\W+/g,"-").toLowerCase();v=a.nthIndexOf("-",5);v>-1&&(a=a.substring(0,v));r.addClass(a);l=n("<li/>",{"class":"responsive-tabs__list__item "+a,id:"tablist"+t+"-tab"+u,"aria-controls":"tablist"+t+"-panel"+u,role:"tab",tabindex:0,text:r.text(),keydown:function(n){n.keyCode===13&&l.click()},click:function(){e.css("height",o);i.find(".responsive-tabs__panel--closed-accordion-only").removeClass("responsive-tabs__panel--closed-accordion-only");i.find(".responsive-tabs__panel--active").toggle().removeClass("responsive-tabs__panel--active").attr("aria-hidden","true").prev().removeClass("responsive-tabs__heading--active");h.toggle().addClass("responsive-tabs__panel--active").attr("aria-hidden","false");r.addClass("responsive-tabs__heading--active");s.find(".responsive-tabs__list__item--active").removeClass("responsive-tabs__list__item--active");l.addClass("responsive-tabs__list__item--active");location.replace(location.protocol+"//"+location.host+location.pathname+"#"+l.attr("id"));e.css("height","auto")}});h.attr({role:"tabpanel","aria-labelledby":l.attr("id"),id:"tablist"+t+"-panel"+u});h.hasClass("responsive-tabs__panel--active")&&l.addClass("responsive-tabs__list__item--active");s.append(l);r.keydown(function(n){n.keyCode===13&&r.click()});r.click(function(){var e,t,o,s,l,a,u;i.find(".responsive-tabs__panel--closed-accordion-only").removeClass("responsive-tabs__panel--closed-accordion-only");r.hasClass("responsive-tabs__heading--active")?(h.removeClass("responsive-tabs__panel--active").slideToggle(function(){n(this).addClass("responsive-tabs__panel--closed-accordion-only")}),r.removeClass("responsive-tabs__heading--active")):(t=i.find(".responsive-tabs__heading--active"),t.length&&(e=t.offset().top),(c==="false"||f===1)&&(i.find(".responsive-tabs__panel--active").slideToggle().removeClass("responsive-tabs__panel--active").prev().removeClass("responsive-tabs__heading--active"),i.find(".responsive-tabs__panel").hide().attr("aria-hidden","true")),h.slideToggle().addClass("responsive-tabs__panel--active").attr("aria-hidden","false"),location.replace(location.protocol+"//"+location.host+location.pathname+"#"+h.attr("id")),r.addClass("responsive-tabs__heading--active"),o=i.find(".responsive-tabs__list__item--active"),o.removeClass("responsive-tabs__list__item--active"),s=h.attr("id"),l=s.replace("panel","tab"),n("#"+l).addClass("responsive-tabs__list__item--active"),a=i.offset().top,u=r.offset().top-15,e<u&&n("html, body").animate({scrollTop:a},0).animate({scrollTop:u},400))});u++});i.prepend(s);t++}),r="."+window.location.href.replace(/^.*?(#|$)/,""),r.length>1&&n(r,".responsive-tabs").filter(":visible").trigger("click"))};String.prototype.nthIndexOf=function(n,t){for(var i=-1;t--&&i++<this.length;)if(i=this.indexOf(n,i),i<0)break;return i};IfMobileChangeUrl=function(){return n(".navbar-toggle").css("display")=="none"?!1:!0};AnchorResponsiveTabs=function(){var i=window.location.href.split("#"),r=i.length,t="";r>1&&(t=i[r-1].split("-"),IfMobileChangeUrl()?(t=t[0]+"-"+t[1].replace("tab","panel"),n("#"+t).prev("h2").trigger("click")):(t=t[0]+"-"+t[1].replace("panel","tab"),n("#"+t).trigger("click")))}}(jQuery);RESPONSIVEUI.responsiveTabs();AnchorResponsiveTabs();window.applyFocusVisiblePolyfill=applyFocusVisiblePolyfill;try{event=new CustomEvent("focus-visible-polyfill-ready")}catch(error){event=document.createEvent("CustomEvent");event.initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(event);applyFocusVisiblePolyfill(document);var chatbotInactivityTimer,chatWindowOpen=!1,chatbotState="INIT",CHATBOT_SESSION_ID_DURATION=33e5,CHATBOT_INACTIVITY_DURATION=1e4,CHATBOT_TYPING_DELAY=500,CHATBOT_CLOSE_WINDOW_DELAY=2e3,CHATBOT_PING_WAITING_TIME=500,CHATBOT_SESSION_MESSAGE_DURATION=1500,CHATBOT_MAX_SESSION_ID_TRIES=5;$(document).ready(function(){function kt(n){var t=new Date,i;t.setTime(t.getTime()+31536e6);i="expires="+t.toUTCString();document.cookie="_wcid="+n+";"+i+";path=/"}function dt(){for(var i="_wcid=",r=document.cookie.split(";"),n,t=0;t<r.length;t++){for(n=r[t];n.charAt(0)==" ";)n=n.substring(1);if(n.indexOf(i)==0)return n.substring(i.length,n.length)}return""}function gt(){chatWindowOpen=!0;clearTimeout(chatbotInactivityTimer);$("#chatbot-window").fadeIn();$("#chatbot-user-input").focus()}function y(){chatWindowOpen=!1;bt();$("#chatbot-window").fadeOut()}function p(){$("#chatbot-welcome").fadeIn()}function o(){$("#chatbot-welcome").hide()}function w(){$("#chatbot-button").css("opacity",1);o()}function i(){$("#chatbot-button").css("opacity",0)}function s(n){document.getElementById("chatbot-alert").innerHTML=n;$("#chatbot-alert").show()}function h(){$("#chatbot-alert").hide()}function b(n){n?$("#chatbot-new-session-alert").text("Your session will start shortly"):$("#chatbot-new-session-alert").text("Your session has expired. A new one will start shortly.");$("#chatbot-new-session-alert").show()}function c(){$("#chatbot-new-session-alert").hide()}function ni(){$("#chatbot-typing-indicator").show()}function l(){$("#chatbot-typing-indicator").hide()}function k(n){n||(chatbotState="IDLE");y();w();o()}function ti(n){$("#chatbot-user-input").attr("placeholder",n)}function r(){$("#chatbot-user-input").attr("disabled",!0);$("#chatbot-user-input").addClass("disabled")}function u(){$("#chatbot-user-input").attr("disabled",!1);$("#chatbot-user-input").attr("placeholder","Reply to the System Agent");$("#chatbot-user-input").removeClass("disabled")}function f(){$("#chatbot-message-container").scrollTop($("#chatbot-message-container")[0].scrollHeight)}function ii(){$(".chatbot-window .option-item").addClass("disabled");$(".chatbot-window .option-item").removeAttr("onclick")}function d(){gt();i();u();chatbotState==="INIT"&&yt().then(function(){chatbotState="ACTIVE"})}function g(n){var i=n.dataset.chatbotLink||!1,t=n.href||"",r=/\?q=\d+&c=\d+/gm.test(t),u=t.indexOf("/pages/")!==-1;(i||r||u)&&(yi(),chatbotState="ACTIVE")}function ri(n){var t=/\[\[[A-Za-z0-9._\-:|/@?&=\s\\]*]]/gm;return t.test(n)?n.replace(t,function(n){var r;n=n.replace("[[","");n=n.replace("]]","");var t=n.split("|"),u=t[0].trim(),i=t[1].trim();return u==="link"?(r=t[2].trim(),'<a href="'+r+'" data-chatbot-link="true">'+i+"<\/a>"):'<span class="content-span">'+i+"<\/span>"}):n}function ui(n){var t=n.split("\n"),i=[];return t.forEach(function(n,r){var f=ri(n),u=document.createElement("p");u.classList.add("bot-paragraph");u.innerHTML=f;r===t.length-1&&u.classList.add("last-paragraph");i.push(u)}),i}function fi(n){var t=document.createElement("ul");return t.classList.add("bot-list"),n.forEach(function(n){var u=n.label||"",e=n.value||"",r=document.createElement("li"),i,f;r.classList.add("bot-list-item");i=document.createElement("a");f="selectOption('"+u+"', '"+e+"')";i.classList.add("option-item");i.setAttribute("onclick",f);i.setAttribute("tabindex","0");i.innerHTML=u;r.appendChild(i);t.appendChild(r)}),t}function ei(n){var t=document.createElement("div");return t.classList.add("message"),t.classList.add("chatbot-content"),t.classList.add(n),t.setAttribute("tabindex","0"),t}function oi(n,t,i){var u=document.createElement("p"),o,f,r,s,e;for(u.setAttribute("tabindex","0"),o=["rating",t,n,i].join("__"),u.setAttribute("id",o),u.setAttribute("tabindex","0"),u.innerHTML="Rate this answer:",f=0;f<5;f++)r=document.createElement("i"),r.setAttribute("tabindex","0"),r.classList.add("fa"),r.classList.add("fa-star-o"),r.classList.add("star-temp"),s="star-rating_"+i+"_"+f,r.setAttribute("id",s),f===0&&(r.style.marginLeft="5px"),u.appendChild(r);return e=document.createElement("div"),e.classList.add("answer-rating"),e.classList.add("chatbot-content"),e.appendChild(u),e}function si(n,t){var u=a(t),f=u+" - Session ID: "+n,r=document.createElement("p"),i;return r.innerHTML=f,r.classList.add("session-id-divider"),i=document.createElement("div"),i.classList.add("chatbot-content"),i.appendChild(r),i}function nt(n,t){var u="#"+n,r,i;for($(n).empty(),$(u).text("Your rating:"),r=0;r<t;r++)i=document.createElement("i"),i.classList.add("fa"),i.classList.add("fa-star"),r===0&&(i.style.marginLeft="5px"),$(u).append(i)}function hi(n){var t="#"+n;$(n).empty();$(t).text("Your rating could not be submitted")}function a(n){var i,t,r;return i=n?new Date(n):new Date,t=i.getMinutes(),r=i.getHours()+":"+(t<10?"0"+t:t),r}function ci(){var t=document.createElement("div");t.classList.add("chatbot-title");t.classList.add("chatbot-content");t.innerHTML="SP Energy Networks System Agent";n(t)}function li(t){var i=document.createElement("div"),r=a(t);i.classList.add("chatbot-time");i.classList.add("chatbot-content");i.classList.add("col-12");i.innerHTML=r;n(i)}function ai(t,i,r){var u=oi(t,i,r);n(u)}function n(n){var t=document.getElementById("chatbot-message-container"),i=document.getElementById("chatbot-alert");document.getElementById("chatbot-message-container")&&t.insertBefore(n,i)}function vi(){window.localStorage.setItem("clear","true")}function yi(){window.localStorage.setItem("link","true")}function pi(n){var t=lt();t.push(n);window.localStorage.setItem("messageHistory",JSON.stringify(t))}function wi(n){window.localStorage.setItem("newMessageGroup",JSON.stringify(n))}function tt(){window.localStorage.setItem("ping","false")}function bi(){window.localStorage.setItem("ping","true")}function ki(n,t){var i={id:n,timestamp:t};window.localStorage.setItem("sessionId",JSON.stringify(i))}function di(){var n=Date.now();window.localStorage.setItem("timestamp",n)}function gi(n,t){var i={id:n,rating:t};window.localStorage.setItem("rating",JSON.stringify(i))}function nr(){var n=lt();n.forEach(function(n){t(n,!1)});f()}function tr(){window.localStorage.removeItem("clear")}function it(){window.localStorage.removeItem("link")}function rt(){window.localStorage.removeItem("messageHistory")}function ir(){window.localStorage.removeItem("newMessageGroup")}function ut(){window.localStorage.removeItem("ping")}function rr(){window.localStorage.removeItem("rating")}function ft(){window.localStorage.removeItem("sessionId")}function et(){window.localStorage.removeItem("timestamp")}function ot(){return window.localStorage.getItem("link")==="true"}function st(){return window.localStorage.getItem("ping")==="true"}function ht(){try{var n=window.localStorage.getItem("sessionId");return JSON.parse(n)}catch(t){return{}}}function ct(){var n=ht();return n?n.id:""}function ur(){var n=ht();if(n)return n.timestamp}function fr(){var n=window.localStorage.getItem("timestamp");return n!==""&&n&&n!==undefined?parseInt(n):0}function lt(){var n=window.localStorage.getItem("messageHistory");return JSON.parse(n)||[]}function e(n,t){rt();ft();et();it();rr();$(".chatbot-window .chatbot-content").remove();h();k(!0);n||vi();(!n||t)&&setTimeout(function(){tr()},CHATBOT_PING_WAITING_TIME);wt().then(function(){}).fail(function(){i()});chatbotState="INIT"}function er(n,t){var i="My choice: "+n;vt(t,i)}function or(n,t){var i=t.split("__"),r=i[1],u=i[2],f={sessionId:r,rating:n,nodeId:u};pr(f).then(function(){nt(t,n);gi(t,n)}).fail(function(){hi(t)})}function at(n){var i=/<[^\s]*\s+[^\s]*=[^>]*>|<\/[^\s]*>/g,r=/[<>="`\\]|\('|\("|\(`|'\)|"\)|`\)/g,u,t;return n=n.replace(i,""),n=n.replace(r,""),u=$("<p><\/p").text(n),t=$(u).text(),t=t.replace(i,""),t.replace(r,"")}function vt(n,i){var u=n,r=i;r||(r=u);u=at(u);r=at(r);var f=[{outputs:[{responseType:"text",text:r}],userDefined:{}}],e=Date.now(),o={origin:"user",messages:f,timestamp:e};t(o,!0);yt().then(function(){return ar(u,!1)}).then(function(){return!1})}function t(t,i){var o=t.messages||[],r=t.origin,u=t.sessionId||"",f=t.timestamp,e;o.forEach(function(n){n.outputs.length>0&&sr(n,r,u,f)});r==="system"&&(v(),e=si(u,f),n(e));i&&(wi(t),pi(t),setTimeout(function(){ir()},CHATBOT_PING_WAITING_TIME))}function sr(t,i,r,o){function l(t,r){var y=t.responseType||"",b=t.text,k=t.text,p=t.options||[],w,h,c,l,a,v;y==="text"||i==="user"?k&&u():y==="option"&&ti("Choose an option or type a question");w=ui(b);h=null;p&&(h=fi(p));c=ei(i);w.forEach(function(n){c.appendChild(n)});h&&c.appendChild(h);n(c);l=document.querySelector(".option-item");l&&l.setAttribute("id","option_powercut_emergency");a=document.querySelectorAll(".option-item")[1];a&&a.setAttribute("id","option_start_new_connection");v=document.querySelectorAll(".option-item")[2];v&&v.setAttribute("id","option_priority_services");i==="user"&&li(o);r===0&&f();s.endOfConversation&&setTimeout(function(){e()},CHATBOT_CLOSE_WINDOW_DELAY)}var h=t.outputs,c=t.nodeId,s=t.userDefined;ii();i==="bot"&&ci();h.forEach(l);i==="bot"&&s.ratingEnabled&&ai(c,r,o)}function hr(){var n=fr(),t=Date.now(),i=t-n;return i>CHATBOT_SESSION_ID_DURATION}function v(){var n=ct(),t=ur(),i=a(t);document.getElementById("chatbot-session-id").innerHTML=i+" - Session ID: "+n}function cr(n){var t=$.Deferred();return setTimeout(function(){t.resolve()},n),t.promise()}function yt(){var t=hr(),n;return t?(n=!0,chatbotState!=="INIT"?(n=!1,b(n),f()):chatbotState==="INIT"&&b(n),cr(CHATBOT_SESSION_MESSAGE_DURATION).then(function(){return lr()})):$.when()}function pt(n,i){var r,e,o;if(n){h();var s=n.dialogNodes,f=n.sessionId,r=Date.now();i&&(r=Date.now(),ki(f,r),v(),e={origin:"system",sessionId:f,timestamp:r},t(e,!0));o={origin:"bot",messages:s,sessionId:f,timestamp:r};setTimeout(function(){return l(),t(o,!0),di(),u(),$("#chatbot-user-input").focus(),!1},CHATBOT_TYPING_DELAY)}}function lr(){return vr().then(function(n){pt(n,!0);c()})}function ar(n,t,i){$("#chatbot-user-input").val("");r();ni();f();var u=ct(),e={message:n,sessionId:u,firstSession:t};return yr(e).then(function(n){pt(n,i)})}function vr(){var n=dt(),t;return console.log("Watson User ID",n),t={watsonUserId:n},$.ajax({type:"POST",headers:{"Content-Type":"application/json"},contentType:"application/json; charset=utf-8",url:"/WebServices/chatbot.asmx/GetSessionId",dataType:"json",data:JSON.stringify(t)}).then(function(n){if(n.HasError)return $.Deferred().reject();var t=JSON.parse(n.Result),i=t.watsonUserId;return kt(i),t.isError?$.Deferred().reject():$.Deferred().resolve(t)}).fail(function(){c();r();s("Your session could not be initiated. Please close the window and retry.")})}function wt(){return $.ajax({type:"GET",headers:{"Content-Type":"application/json"},contentType:"application/json; charset=utf-8",url:"/WebServices/chatbot.asmx/GetHeartbeat",dataType:"json"}).then(function(){return $.Deferred().resolve()}).fail(function(){r();s("Could not reach the server to check availibility.")})}function yr(n){return $.ajax({type:"POST",headers:{"Content-Type":"application/json"},contentType:"application/json; charset=utf-8",url:"/WebServices/chatbot.asmx/PostMessage",data:JSON.stringify(n),dataType:"json"}).then(function(n){if(n.HasError)return $.Deferred().reject();var t=JSON.parse(n.Result);return t.isError?$.Deferred().reject():$.Deferred().resolve(t)}).fail(function(){l();u();s("Something wrong happened while sending your message. Please close the window and retry.")})}function pr(n){return $.ajax({type:"POST",headers:{"Content-Type":"application/json"},contentType:"application/json; charset=utf-8",url:"/WebServices/chatbot.asmx/PostRating",data:JSON.stringify(n),dataType:"json"}).then(function(n){if(n.HasError)return $.Deferred().reject();var t=JSON.parse(n.Result);return t.isError?$.Deferred().reject():$.Deferred().resolve()})}function bt(){function t(){p()}function n(){chatWindowOpen||(clearTimeout(chatbotInactivityTimer),chatbotInactivityTimer=setTimeout(t,CHATBOT_INACTIVITY_DURATION))}window.onload=n;document.onmousemove=n;document.onkeypress=n;n()}function wr(){chatbotState="INIT";y();i();h();l();r();c();var n=ot();it();tt();setTimeout(function(){var t=st();ut();wt().then(function(){w();bt();n||t?(v(),d(),nr()):(rt(),et(),ft())}).fail(function(){i()})},CHATBOT_PING_WAITING_TIME)}$("#chatbot-user-input").keypress(function(n){var r=n.keyCode===13&&!n.shiftKey,i,t;if(r){if(i=document.getElementById("chatbot-user-input").value,t=i.trim(),t===""){n.preventDefault();return}t=i.replace(/(\r\n|\r|\n|\s\s+)/gm,function(){return" "});t=t.trim();vt(t,null)}});$("#chatbot-avatar").mouseenter(function(){p()}).mouseleave(function(){o()});$("#chatbot-avatar").bind("click",function(){d()});$(window).on("beforeunload",function(){var n=ot();tt();setTimeout(function(){var t=st();ut();n||t||e(!0,!0)},CHATBOT_PING_WAITING_TIME)});$(window).on("storage",function(n){var h=window.document.hasFocus(),i,r,f,u,o,s;h||(i=n.originalEvent,r=i.key,r==="clear"?i.newValue&&e(!0):r==="link"?i.newValue&&(chatbotState="ACTIVE"):r==="newMessageGroup"?(f=JSON.parse(i.newValue),f&&t(f,!1)):r==="ping"?i.newValue&&bi():r==="rating"&&(u=JSON.parse(i.newValue),u&&(o=u.id,s=u.rating,nt(o,s))))});$(document).on("click",'a[data-chatbot-link="true"]',function(n){var t=n.target;return g(t),!0});$(document).on("contextmenu",'a[data-chatbot-link="true"]',function(n){var t=n.target;return g(t),!0});$(document).on("mouseover",".fa-star-o.star-temp",function(n){for(var f=n.target,e=f.getAttribute("id"),i=e.split("_"),o=i[0],s=i[1],h=parseInt(i[2]),u,r,t=0;t<=h;t++)u=[o,s,t].join("_"),r=document.getElementById(u),r.classList.remove("fa-star-o"),r.classList.add("fa-star")});$(document).on("mouseleave",".fa-star.star-temp",function(n){for(var f=n.target,e=f.getAttribute("id"),r=e.split("_"),o=r[0],s=r[1],u,i,t=0;t<5;t++)u=[o,s,t].join("_"),i=document.getElementById(u),i.classList.remove("fa-star"),i.classList.add("fa-star-o")});$(document).on("click",".star-temp",function(n){var t=n.target,i=t.parentElement.getAttribute("id"),r=t.getAttribute("id"),u=r.split("_"),f=parseInt(u[2]),e=f+1,o="#"+i;$(o).text("Your rating is being submitted...");setTimeout(function(){or(e,i)},CHATBOT_TYPING_DELAY)});window.clearChat=e;window.minimiseChatWindow=k;window.selectOption=er;wr()})