text: var isConciergePage="/concierge"===window.location.pathname;isConciergePage&&($(".nav-item").each(function(e,t){0!==e&&$(t).hide()}),$(".side-column").first().hide(),$("body").css("flex-direction","row-reverse"),$("#graphs-container").hide(),$("#concierge-page__side-column").show(),$("#js-users-list-button").hide(),$("#js-invoice-button").hide());var months=["January","February","March","April","May","June","July","August","September","October","November","December"],userObject=eval("("+$("#userObject").text()+")"),userId="{{userId | safe}}";isConciergePage&&(userId=userObject.nickname);var iframe=document.getElementById("invoice-generator");$("#user-nickname").text(userObject.nickname);var $avatar=$("#avatar");isConciergePage&&$("#user-id").text("GUEST"),$avatar.attr("data-src",userObject.profile_pic);var channels=[],$lastMessage=null,$portfolioData=$("#portfolioData"),portfolioData=eval($portfolioData.text());$portfolioData.remove();var scrollHandler=function(){if(shouldUseInverseMode=!1,0===$(this).scrollTop()&&$(this).prop("scrollHeight")>$(window).height()){$lastMessage=$("#"+channelId+">div:visible").first(),shouldUseInverseMode=!0;var e=$(".messages-loader").first().clone();e.insertBefore($lastMessage),e.show(),channelQueries[channelId].load(loadMessages)}},apiPostMessageUrl="/postjson",isOldTitle=!0,oldTitle=$(document).find("title").text(),oldFavicon=$("#favicon").attr("href"),newTitle="New message received",newFavicon="notification.png",jsChatColumn=$("#js-chat-column"),interval=null,modal=$("#myModal");isConciergePage&&(portfolioData=eval($("#conciergeChannels").text()));var channelId=portfolioData[0].channelId,channelIdFromQuery=new URLSearchParams(window.location.search).get("channelId"),cookieValue=Cookies.get("channelId");void 0===cookieValue||isConciergePage||(channelId=cookieValue),channelIdFromQuery&&(channelId=channelIdFromQuery),window.channelId=channelId,iframe.contentWindow.location.reload();var hiddenContainers=[];function renderConciergeMessagesContainer(){var e=$("<div></div>");e.attr("class","messages"),e.attr("id",channelId),e.prependTo(jsChatColumn),e.on("scroll",scrollHandler)}function renderPortfolios(e){for(var t in e){var n=e[t].channelId,a=$("<div></div>");a.attr("class","messages"),a.attr("id",n),n!==channelId?hiddenContainers[n]=a:(a.on("scroll",scrollHandler),a.prependTo(jsChatColumn));var s=e[t].thumb,i=$("<div class='portfolio-selector__container'><img class='portfolio-selector__thumb js-portfolio-image' src='"+s+"' alt='thumb'><input type='file' class='js-portfolio-image-input hidden'><img class='portfolio-selector__thumb js-sync-button' src='/static/img/sync.png'><button class='portfolio-selector btn btn-default'></button><i class='fas fa-check checked-portfolio'></i><div class='channel-info'><div class='channel-info__author'>Author</div>: <div class='channel-info__message'><span class='chanel-info__message-body'>message</span><span class='channel-info__date'>1/1/2019</span></div></div>"),r=i.find(".portfolio-selector"),o=e[t].portfolio_name,l=i.find(".js-sync-button");$(".js-portfolio-image").attr("data-channelId",n),$(".js-portfolio-image-input").attr("data-channelId",n),i.find(".channel-info__author").first().text(e[t].channelData.last_msg_user);var d=e[t].channelData.last_msg;"{"===d.charAt(0)&&(d="message"),20<d.length&&(d=d.substring(0,20)+"..."),i.find(".chanel-info__message-body").first().text(d),i.find(".channel-info__date").first().text(e[t].channelData.last_msg_created_at);var c="<span class='portfolio-selector__text'>"+e[t].portfolio_name+"</span>",u=e[t].channelData.unread_messages_count;n!==channelId&&0<u&&(c="<span class='portfolio-selector__text'>"+e[t].portfolio_name+"</span><span class='badge badge-pill badge-primary'>"+u+"</span>"),r.html(c),r.attr("data-channelId",n),r.attr("data-portfolioName",o),l.attr("data-channelId",n),n===channelId&&i.find(".checked-portfolio").first().css("display","inline-block"),i.insertBefore("#load-more-button")}}isConciergePage?renderConciergeMessagesContainer():renderPortfolios(portfolioData);var displayedDocs=[],graphIdPortfolioNameMapping=[],graphsCounter=0;function renderGraphsFromJson(e){var t=$("#graphs-container").first(),n=t.width(),a=t.height()/2-30,s=JSON.parse(e);for(var i in s){var r=$("<div></div>"),o="graph-"+graphsCounter;graphsCounter++,r.attr("id",o),r.appendTo($("#graphs"));var l=s[i];if(l){var d=l.layout,c="";void 0!==l.data[0]&&(c=""+l.data[0].type);var u="pie"==c;d.width=n,d.height=a;var p=l.layout.title;l.layout.title=sanitizeName(l.layout.title),u&&(l.data[0].domain.x[1]=1),2!==parseInt(i)&&3!==parseInt(i)||$("#"+o).detach().appendTo("#graphs-2"),d.align="center",Plotly.plot(o,l.data,d),graphIdPortfolioNameMapping["#"+o]=p}}}function initDocs(){$(".doc-content").each(function(e,t){renderChannelFiles(JSON.parse($(t).text().replace(/'/g,'"'))),$(t).remove()});var e=$("#file-container--empty");0===displayedDocs.length?e.removeClass("hidden"):e.addClass("hidden")}function renderChannelFiles(e){var t=Object.keys(e)[0],n=e[t];for(var a in n)renderDoc(t,n[a].name,n[a].posted_by,n[a].created_date,n[a].url,n[a].thumb,!1)}function renderDoc(e,t,n,a,s,i,r){var o=$(".file-container.hidden").first().clone();o.removeClass("hidden"),e!=channelId?o.hide():displayedDocs.push(o),o.find(".file-description__filename").first().text(t),o.find(".file-description__text").first().text("By: "+n+", on "+a),o.find(".file-description__link").first().attr("href",s);var l=o.find(".file-preview"),d=$("<img/>");d.attr("data-src",i),d.appendTo(l),d.addClass("lozad"),o.attr("data-channelId",e);var c=$("#docs");r?o.insertAfter($("#search-bar")):c.append(o)}function sanitizeName(e){return void 0===e?"":-1===(e=e.toString()).indexOf("_")?e:e.substring(0,e.indexOf("_"))}$(document).on("click",".file-data",function(){var e=$(this).find(".file-description__link").first().attr("href");window.open(e,"_blank").focus()}),initDocs(),initSendBird(!0),$(document).on("click",".portfolio-selector",function(){for(var e in $(this).find(".badge").first().hide(),channelId=$(this).attr("data-channelId"),getPortfolioData(),window.channelId=channelId,iframe.contentWindow.location.reload(),Cookies.set("channelId",channelId),$("#search-input").val(""),graphIdPortfolioNameMapping){var t=$(e.toString());$.trim(t.attr("data-portfolioName"))===$.trim($(this).find(".portfolio-selector__text").first().text())?t.show():t.hide()}$(".messages").each(function(e,t){hiddenContainers[$(t).attr("id")]=$(t),$(t).remove()});var n=hiddenContainers[channelId];n.prependTo(jsChatColumn),n.on("scroll",scrollHandler),($messagesContainer=$("#"+channelId)).show(),$(".checked-portfolio").css("display","none"),$(this).next(".checked-portfolio").css("display","inline-block");var a=$(".file-container"),s=0;displayedDocs=[],a.each(function(e,t){var n=$(t);null!=n.attr("data-channelId")&&(n.attr("data-channelId")!=channelId?n.hide():(n.show(),displayedDocs.push(n),s++))});var i=$("#file-container--empty");0===s?i.removeClass("hidden"):i.addClass("hidden"),window.dispatchEvent(new Event("resize"));var r={userId:userId,channelId:channelId};$(".js-loading").hide(),$.post("mark_read",JSON.stringify(r)),scrollChatToBottom(),lozad().observe()}),$(window).on("resize",function(){var e=$(".download-apps").first();if($(window).width()<700||mobileCheck())return $(".js-column").each(function(e,t){$(t).hide()}),void e.show();$(".js-column").each(function(e,t){isConciergePage&&"graphs-container"===$(t).attr("id")||$(t).hasClass("side-column")||$(t).css("display","flex")}),e.hide();var t=$("#graphs-container"),n=t.width(),a=t.height()/2-30;t.find(".js-plotly-plot").each(function(e,t){$(t).is(":hidden")||Plotly.relayout($(t).attr("id"),{width:n,height:a,align:"center"})})}),$("#search-input").on("input propertychange",function(e){var t=$(e.target).val().toString().toUpperCase();for(var n in displayedDocs){var a=displayedDocs[n];-1<a.find(".file-description__filename").first().text().toUpperCase().indexOf(t)?a.show():a.hide()}});var sendBirdWasInitialized=!1,messageForOptions,shouldUseInverseMode=!1,channelQueries=[],channelsCount=0;function initSendBird(e){var t=new SendBird({appId:"9A997118-6C53-4FA2-AEAA-C335293220B2"});if(isConciergePage?t.connect(userId,function(e,t){t&&console.error(t)}):t.connect(userId,userObject.sbToken,function(e,t){t&&console.error(t)}),e){var n=new t.ChannelHandler;n.onMessageReceived=function(e,n){$(".js-loading").each(function(e,t){$(t).attr("data-userId")==n.sender.userId&&$(t).hide()});var t=$('button[data-channelid="'+e.url+'"]'),a=parseInt(e.unreadMessageCount),s=e.lastMessage.sender?e.lastMessage.sender.nickname:"admin";if(1<a&&e.url!=channelId){var i=t.find(".badge-pill");if(i.length)i.text(e.unreadMessageCount);else{var r="<span class='badge badge-pill badge-primary'>"+a+"</span>";t.append(r)}i.show();var o=e.lastMessage.message;"{"===o.charAt(0)&&(o="message"),20<o.length&&(o=o.substring(0,20)+"..."),t.siblings().find(".channel-info__author").text(s),t.siblings().find(".chanel-info__message-body").text(o),t.siblings().find(".channel-info__date").text(new Date(e.lastMessage.createdAt).toGMTString())}0<n.data.length&&1==JSON.parse(n.data.replace(/'/g,'"')).isOptionsMessage?messageForOptions=n:(parseMessage(n,messageForOptions,null,!(shouldUseInverseMode=!1)),messageForOptions=null,scrollChatToBottom(),newTitle="New message from "+s,document.hasFocus()||interval||(interval=setInterval(changeTitle,700)),new Audio("/static/audio/ring.mp3").play())},n.onTypingStatusUpdated=function(e){var n=e.getTypingMembers();if(0!==n.length)for(var a in shouldUseInverseMode=!1,n){var s=!0,t=$(".js-loading");if(t.each(function(e,t){$(t).attr("data-userId")!=n[a].userId||$(t).is(":hidden")||(s=!1)}),s){var i=t.last().clone();i.find(".user-avatar").first().attr("src",n[a].profileUrl),i.attr("data-userId",n[a].userId),addMessageToChatColumn(i,e.url),e.url==channelId&&s&&scrollChatToBottom()}}else $(".js-loading").each(function(e,t){$(t).hide()})},n.onUserJoined=function(e,t){window.location.reload(!0)},t.addChannelHandler(uuidv4(),n)}var a=t.GroupChannel.createMyGroupChannelListQuery();a.includeEmpty=!0,a.limit=20,a.hasNext&&a.next(function(e,t){for(var n in t&&console.error(t),channelsCount=e.length,e){var a=e[n],s=(channels[a.url]=a).createPreviousMessageListQuery();s.limit=40,s.reverse=!0,s.load(loadMessages),channelQueries[a.url]=s}})}var channelsProcessed=0,optionMessageWithoutText=null;function loadMessages(e,t){if(t)return $(".messages-loader").hide(),void console.error(t);if(!e||e.length<=0)$(".messages-loader").hide();else{for(var n in sendBirdWasInitialized||e.sort(function(e,t){return e.createdAt<t.createdAt?-1:e.createdAt>t.createdAt?1:0}),shouldUseInverseMode=sendBirdWasInitialized,$(".js-loading").each(function(e,t){$(t).hide()}),"url_preview"===e[0].customType&&(optionMessageWithoutText=e[0],channelQueries[channelId].load(loadMessages),e[0]=null),e){var a=parseInt(n);null!==e[a]&&parseMessage(e[a],e[a-1],e[a+1])}$(".messages-loader").hide(),channelsProcessed++,sendBirdWasInitialized&&$lastMessage&&$messagesContainer.animate({scrollTop:$lastMessage.offset().top},0),channelsCount<=channelsProcessed&&!sendBirdWasInitialized&&(setTimeout(function(){scrollChatToBottom()},500),sendBirdWasInitialized=!0)}}var chatColumn=$(".chat-column").find(".messages").each(function(e,t){$(".js-loading").first().clone().show().appendTo($(t))}),renderedDates=[];function getReplies(t){try{var e=JSON.parse(t.message),n=e.replies,a=e.questionId}catch(e){try{var s=window.atob(t.message);n=s.replies,a=s.questionId}catch(e){console.error("Error during parsing message with type url_preview, message text: "+t.message)}}return[n,a]}function parseMessage(t,e,n,a){$(".select").first().hide(),$(".js-chat-input").show();var s=new Date(t.createdAt),i=s.getDate()+" "+months[s.getMonth()],r=t.channelUrl,o=(r+i).replace(/ /g,"_");if(void 0===renderedDates[o]||renderedDates[o]>t.createdAt){$("#"+o).hide(),renderedDates[o]=t.createdAt;var l=$("#js-date-container").clone();l.text(i),l.attr("id",o),addMessageToChatColumn(l,r)}switch(t.customType){case"url_preview":var d=getReplies(t),c=d[1],u=d[0],p="";e&&(p=e.message),renderMessage(t,p,u,c);break;case"url_preview_cards":var h=null;if("{"==t.message[0]){var f=""+t.message;f=(f=f.replace(/u'/g,"'")).replace(/'/g,'"'),h=JSON.parse(f)}else try{h=window.atob(t.message)}catch(e){console.error("Cards data couldnt be parsed from message, message: "+t.message)}renderCards(h,t);break;case"":if("file"==t.messageType){if(a)try{renderUploadedFile((g=JSON.parse(t.data.replace(/'/g,'"'))).file_path,g.thumb_path);break}catch(e){renderImage(t,t.url);break}var g;if("pdf"===t.name.slice(t.name.indexOf(".")+1))renderImage(t,(g=JSON.parse(t.data.replace(/'/g,'"'))).file_path);else renderImage(t,t.url);break}if(isUserMessage(t)){renderMessage(t,t.message);break}if(n&&"url_preview"!=n.customType&&!optionMessageWithoutText){renderMessage(t,t.message);break}isUserMessage(t)||n&&""!=n.customType||renderMessage(t,t.message);break;case"url_preview_input_string":case"url_preview_input_int":case"url_preview_multiple_inputs":var m=JSON.parse(t.message);renderMessage(t,m.input,null,m.questionId);break;case"url_preview_list":renderSelect(t);break;default:console.error("unknown message type",t.customType)}$(".js-loading").each(function(e,t){$(t).hide()}),lozad().observe()}function renderSelect(e){$(".list-select").remove(),$(".select").remove();var t=e.message.replace(/'/g,'"'),n=(t=JSON.parse(t)).list,a=$("<select></select>"),s=uuidv4();for(var i in a.attr("id",s),a.attr("class","list-select"),a.attr("data-questionId",t.questionId),n)a.append(new Option(n[i].text,n[i].input));a.insertAfter($(".attach-container")),a.each(selectInit),$(".js-chat-input").hide(),$(".select").first().show()}function renderImage(e,t){var n=e.url,a=getSentAtAsString(new Date(e.createdAt)),s=null;isUserMessage(e)?(s=$(".user-message").first(),isConciergePage&&s.addClass("user-message--concierge")):s=$(".responder-message-container").not(".user-message").first(),s.find(".user-avatar").first().attr("src",getProfileUrl(e));var i=getNickname(e)+", "+a,r=(s=s.clone()).find(".js-message-text").first();s.find(".js-sent-at").first().text(i);var o=$("<img/>").attr("data-src",n);o.attr("data-file-url",t),o.css("width","100%"),o.css("height","100%"),o.appendTo(r),o.addClass("text-image"),o.addClass("lozad"),r.addClass("image-message"),addMessageToChatColumn(s,e.channelUrl)}function renderMessage(e,t,n,a){var s=null,i=null,r=getSentAtAsString(new Date(e.createdAt));if(isUserMessage(e)){var o=(s=$(".user-message").first()).find(".user-avatar").first();isConciergePage?o.remove():o.attr("src",getProfileUrl(e)),i=getNickname(e)+", "+r,isConciergePage&&s.addClass("user-message--concierge")}else{(o=(s=$(".responder-message-container").not(".user-message").first()).find(".user-avatar").first()).attr("src",getProfileUrl(e)),i=getNickname(e)+", "+r}var l=(s=s.clone()).find(".js-message-text").first();if(isUserMessage(e)||(t=urlify(t)),l.html(t),s.find(".js-sent-at").first().text(i),n)for(var d in n){var c=s.find(".option-button").first().clone(),u=n[d].reply.replace("","'");c.html(u),c.attr("data-questionId",a),c.attr("data-userId",userId),c.show(),c.insertAfter(l)}if(messageHasInput(e)){var p=s.find(".js-message-input").first().clone();p.attr("data-questionId",a),p.show().insertAfter(l)}isAdminMessage(e)&&(s.addClass("admin-message"),l.parent().addClass("text--admin-message"),l.prepend('<i class="fab fa-android admin-message__android-icon"></i>')),addMessageToChatColumn(s,e.channelUrl)}var $messagesContainer=$("#"+channelId).first();function scrollChatToBottom(){var e=$("#"+channelId).first(),t=e.find(".js-chat-message").last().get(0),n=t?t.offsetTop:100;e.animate({scrollTop:n},250)}$(document).on("click",".option-button",function(){scrollChatToBottom();var e=$(this).attr("data-questionId"),t=$(this).text(),n={userId:userId,msg:{replies:t,questionId:e},channelId:channelId};$(this).hasClass("payment-button")||$(".js-loading").first().clone().show().appendTo(chatColumn),$.post(apiPostMessageUrl,JSON.stringify(n)).always(function(){})});var offsetInPixels=328;function renderCards(e,t){var n=$(".js-cards-container").first().clone();n.find(".user-avatar").first().attr("src",getProfileUrl(t));var a=e.cards;for(var s in 1===a.length&&n.find(".gallery-switcher").each(function(e,t){$(t).hide()}),a){var i=n.find(".gallery-item").first().clone(),r=n.find(".gallery").first();i.find("img").first().attr("data-src",a[s].url_image),i.find(".js-message-text").first().text(a[s].text);var o=i.find(".js-text-container").first();for(var l in a[s].buttons){var d=i.find(".option-button").first().clone();d.text(a[s].buttons[l].text),a[s].buttons[l].type&&"payment"===a[s].buttons[l].type&&(d.addClass("payment-button"),d.attr("data-amount",parseFloat(a[s].buttons[l].data.amount)),d.attr("data-description",a[s].buttons[l].data.description)),d.show(),d.appendTo(o)}0!==parseInt(s)?(i.css("position","absolute"),i.css("left",s*offsetInPixels+"px"),i.css("top","8px"),i.removeClass("gallery-item--selected")):i.addClass("gallery-item--selected"),i.show(),i.appendTo(r)}n.show();var c=getSentAtAsString(new Date(t.createdAt)),u=getNickname(t)+", "+c;n.find(".js-sent-at").first().text(u),addMessageToChatColumn(n,t.channelUrl)}function getSentAtAsString(e){var t=e.getHours();t<10&&(t="0"+t);var n=e.getMinutes();return n<10&&(n="0"+n),t+":"+n}function hideButtonsIfNeeded(e){var t=e.find(".gallery-item--selected").first(),n=e.find(".gallery-switcher--right").first(),a=e.find(".gallery-switcher--left").first();t.siblings(".gallery-item").length==t.index()-2?n.hide():n.show(),3==t.index()?a.hide():a.show()}function isUserMessage(e){return!!e.sender&&e.sender.userId==userId}function handleUserMessage(e){if(e.length<=0)return!1;var t={userId:userId,msg:e,channelId:channelId};return channels[channelId].sendUserMessage(e,null,"",function(e,t){t?console.error(t):(channels[channelId].endTyping(),parseMessage(e),scrollChatToBottom())}),$.post(apiPostMessageUrl,JSON.stringify(t)),!0}function getFormData(){var e=new FormData;return e.append("userId",userId),e.append("channelId",channelId),e}function renderUploadedFile(e,t){var n=e,a=n.split("/").pop(),s=new Date,i=s.toDateString()+s.toLocaleTimeString();renderDoc(channelId,a,"misterx",i,n,t,!0)}function getProfileUrl(e){return e.sender?e.sender.profileUrl.replace("http://omne","https://www.omne").replace("http://botvest","https://www.botvest"):""}function getNickname(e){return e.sender?e.sender.nickname:"Admin"}function messageHasInput(e){return"url_preview_input_string"==e.customType||"url_preview_input_int"==e.customType||"url_preview_multiple_inputs"==e.customType}function isAdminMessage(e){return"admin"==e.messageType}$(document).on("click",".gallery-switcher--right",function(){var e=$(this).parent().find(".gallery-item--selected").first(),a=e.index()-2,t=e.next(".gallery-item").first(),n=offsetInPixels*a;e.css("transform","translate(-"+n+"px, 0px)"),e.nextAll().each(function(e,t){var n=offsetInPixels*a;$(t).css("transform","translate(-"+n+"px, 0px)")}),e.removeClass("gallery-item--selected"),t.addClass("gallery-item--selected"),hideButtonsIfNeeded($(this).parent())}),$(document).on("click",".gallery-switcher--left",function(){var e=$(this).parent().find(".gallery-item--selected").first(),t=e.prev(".gallery-item"),n=t.index()-3,a=offsetInPixels*n;$(".gallery-item").each(function(e,t){$(t).css("transform","translate(-"+a+"px, 0px)")}),e.removeClass("gallery-item--selected"),t.addClass("gallery-item--selected"),hideButtonsIfNeeded($(this).parent())}),$(document).on("keyup",".js-message-input",function(e){var t=$(this).val();if(13===e.keyCode&&0!==t.length){var n={userId:userId,msg:{replies:$(this).val(),questionId:$(this).attr("data-questionId")},channelId:channelId};$(".js-loading").first().clone().show().appendTo(chatColumn),scrollChatToBottom(),$.post(apiPostMessageUrl,JSON.stringify(n))}}),$(document).on("keyup",".js-chat-input",function(e){e.shiftKey&&13===e.keyCode||13===e.keyCode&&($(this).val(""),$(this).css("height","40px"))}),$(document).on("keyup",".js-chat-input",debounce(function(e){channels[channelId].endTyping()},1500)),$(document).on("change keyup keydown paste cut",".js-chat-input",function(){$(this).height(0).height(this.scrollHeight-20)}).find(".js-chat-input").change(),$(document).on("keydown",".js-chat-input",function(e){var t=String.fromCharCode(e.keyCode);if(/[a-zA-Z0-9-_ ]/.test(t)&&channels[channelId].startTyping(),(!e.shiftKey||13!==e.keyCode)&&13===e.keyCode){var n=$(this).val();n.length,handleUserMessage(n)&&$(this).css("height","40px")}}),$(document).on("click",".chat-column__attach",function(e){e.preventDefault(),$(".chat-column__file-input").first().click()}),$(document).on("change",".chat-column__file-input",function(e){e.preventDefault();var t=$(this).prop("files")[0],n=getFormData();n.append("file",t),$.ajax({url:"/upload-chat",type:"POST",data:n,processData:!1,contentType:!1,success:function(e){scrollChatToBottom()},error:function(e){console.error(e)}})}),$(document).on("click",".text-image",function(){modal.find("img").first().attr("src",$(this).attr("src"));var e=modal.find("#open-file__url");e.attr("href",$(this).attr("data-file-url")),e.attr("target","_blank"),modal.show()}),$(document).on("click",".close-modal",function(){modal.hide()}),$(document).on("click",".js-chat-scroll",function(e){e.preventDefault(),scrollChatToBottom()}),$(document).bind("drop dragover",function(e){e.preventDefault()});var dropZone=jsChatColumn;$("#fileupload").fileupload({dropZone:dropZone,add:function(e,t){for(var n in t.files){var a=getFormData();a.append("file",t.files[n]);var s=$(".uploaded-file").first().clone();s.find(".uploaded-file__info h1").first().text(t.files[n].name),addMessageToChatColumn(s,channelId),scrollChatToBottom(),$.ajax({url:"/upload-chat",type:"POST",data:a,cache:!1,contentType:!1,processData:!1,xhr:function(){return $.ajaxSettings.xhr()},success:function(e){},error:function(e){console.error(e)}})}}});var dragOverlay=dropZone.find(".drag-and-drop").first();function uuidv4(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})}function addMessageToChatColumn(e,t){var n=$("#"+t);0===n.length?shouldUseInverseMode?hiddenContainers[t].prepend(e):hiddenContainers[t].append(e):shouldUseInverseMode?e.prependTo(n):e.appendTo(n),e.show()}function debounce(a,s,i){var r;return function(){var e=this,t=arguments,n=i&&!r;clearTimeout(r),r=setTimeout(function(){r=null,i||a.apply(e,t)},s),n&&a.apply(e,t)}}function mobileCheck(){var e,t=!1;return e=navigator.userAgent||navigator.vendor||window.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(t=!0),t}if($(document).bind("dragover",function(e){0<$(e.target).parents("#js-chat-column").length?dragOverlay.css("display","flex"):dragOverlay.hide()}),$(document).bind("drop",function(){dragOverlay.hide()}),mobileCheck()){var $downloadApps=$(".download-apps").first();$(".js-column").each(function(e,t){$(t).hide()}),$downloadApps.show()}function selectInit(){var s=$(this),e=$(this).children("option").length;s.addClass("select-hidden"),s.wrap('<div class="select"></div>'),s.after('<div class="select-styled"></div>');var i=s.next("div.select-styled");i.text(s.children("option").eq(0).text());for(var r=$("<ul />",{class:"select-options"}).insertAfter(i),t=0;t<e;t++)$("<li />",{text:s.children("option").eq(t).text(),rel:s.children("option").eq(t).val()}).appendTo(r);var n=r.children("li");i.click(function(e){e.stopPropagation(),$("div.select-styled.active").not(this).each(function(){$(this).removeClass("active").next("ul.select-options").hide()}),$(this).toggleClass("active").next("ul.select-options").toggle()}),n.click(function(e){$(".select").each(function(e,t){$(t).hide()}),e.stopPropagation(),i.text($(this).text()).removeClass("active"),s.val($(this).attr("rel")),r.hide(),$(".js-chat-input").show();var t=s.attr("data-questionId"),n=s.val(),a={userId:userId,msg:{replies:n,questionId:t},channelId:channelId};$.post(apiPostMessageUrl,JSON.stringify(a)).always(function(){})}),$(document).click(function(){i.removeClass("active"),r.hide()})}$("#customSelect").each(selectInit);var tokenTriggered=!1,handler=StripeCheckout.configure({key:"pk_live_ms0wO9HQtHsHG2gWJq0wahLz",image:"https://www.omne.ai/img/favicon-32x32.png",locale:"auto",currency:"eur",token:function(e){console.log(e),tokenTriggered=!0},closed:function(){tokenTriggered&&window.location.reload(!0)}});$(document).on("click",".payment-button",function(e){e.preventDefault(),handler.open({name:"La Villa del Lago",description:$(this).attr("data-description"),zipCode:!0,currency:"eur",amount:$(this).attr("data-amount")})});var searchBarOffset=42;function changeTitle(){document.title=isOldTitle?oldTitle:newTitle,$("#favicon").attr("href",isOldTitle?oldFavicon:newFavicon),isOldTitle=!isOldTitle}$("#graphs-container").on("scroll",function(){var e=$("#search-bar"),t=$(".nav-justified").first().parent();$(this).scrollTop()>=searchBarOffset?(e.addClass("sticky"),t.addClass("tabs__sticky")):(e.removeClass("sticky"),t.removeClass("tabs__sticky"))}),$(window).focus(function(){clearInterval(interval),interval=null,$("title").text(oldTitle),$("#favicon").attr("href",oldFavicon)});var observer=lozad();observer.observe();var channelUsers=[];function renderMembers(){var e=$("#exampleModal"),t=e.find(".modal-body").first();for(var n in t.empty(),channelUsers[channelId]){var a=$("<div></div>").addClass("channel-user"),s=$("<img/>").addClass("channel-user__avatar").attr("src",channelUsers[channelId][n].profile_url.replace("http://omne","https://www.omne").replace("http://botvest","https://www.botvest")),i=$("<span></span>").addClass("channel-user__name").text(channelUsers[channelId][n].nickname),r=$("<span></span>").addClass("channel-user__status"),o=$('<div class="user-name__container"></div>');if(channelUsers[channelId][n].is_online||0==channelUsers[channelId][n].last_seen_at)r.addClass("online"),r.text("Online");else{var l=new Date(channelUsers[channelId][n].last_seen_at),d=l.getDate()+"/"+parseInt(parseInt(l.getMonth())+1)+"/"+l.getFullYear();r.text("last seen "+d)}s.appendTo(a),i.appendTo(o),r.appendTo(o),o.appendTo(a),a.appendTo(t)}$('<input type="text" class="form-control" id="new-user-id">').appendTo(t);var c=$('<button id="user-leave" class="btn btn-default user-operation" data-toggle="tooltip" data-placement="top" title="Leave"><img src="/static/img/leave.png"></button>'),u=$('<button id="user-invite" class="btn btn-default user-operation" data-toggle="tooltip" data-placement="top" title="Invite"><img src="/static/img/invite.png"></button>'),p=$('<div class="user-operation__container"></div>');u.tooltip(),c.tooltip(),u.appendTo(p),c.appendTo(p),p.appendTo(t),e.modal()}function submitInvoice(e){var t={userId:userId,channelId:channelId,Invoice:e};$.post("/insert-inv-data",JSON.stringify(t)).done(function(e){if("True"==e.error){var t=e.msg;$("#invoice-modal").find(".modal-body").prepend($('<div class="alert alert-danger" role="alert">'+t+"</div>"))}else $("#invoice-modal").modal("hide")})}function urlify(e){return e.replace(/(https?:\/\/[^\s]+)/g,function(e){return'<a target="_blank" href="'+e+'">'+e+"</a>"})}$("#js-users-list-button").click(function(e){e.preventDefault(),$("#exampleModal").find(".modal-body").first().text("Loading...");var t={channelId:channelId};$.post("/list-members",JSON.stringify(t),function(e){channelUsers[channelId]=e.members,renderMembers()})}),$("#js-invoice-button").click(function(e){e.preventDefault()}),$("#add-portfolio").click(function(e){e.preventDefault(),$("#new-portfolio-modal").modal()}),$("#js-form-submit").click(function(e){e.preventDefault();var t=$(".js-chat-input");handleUserMessage(t.val())&&t.val("")}),$(document).on("click","#user-leave",function(e){e.preventDefault();var t={channelId:channelId,userId:$("#new-user-id").val()};$.post("/leave",JSON.stringify(t)).done(function(){window.location.reload(!0)}).fail(function(e){console.error(e)})}),$(document).on("click","#user-invite",function(e){e.preventDefault();var t={channelId:channelId,userId:$("#new-user-id").val()};$.post("/invite",JSON.stringify(t)).done(function(){window.location.reload(!0)}).fail(function(e){console.error(e)})}),$("#add-portfolio-submit").click(function(e){e.preventDefault();var t=$("#new-portfolio-name"),n={userId:userId,portfolio_name:t.val()};$.post("/startportfolio",JSON.stringify(n)).done(function(){window.location.reload(!0)}).fail(function(e){console.error(e)}),t.val("")}),$(document).on("click",".js-sync-button",function(e){e.preventDefault(),$(this).addClass("portfolio-syncing");var t=$(this).attr("data-channelId");$.post("/refresh-portfolio",JSON.stringify({channelId:t})).done(function(){window.location.href=window.location.href.split("?")[0]+"?channelId="+t}).fail(function(e){console.error(e)})}),$("a[data-toggle=tab]").on("shown.bs.tab",function(e){window.dispatchEvent(new Event("resize"))}),$(document).on("click",".file-delete",function(e){e.preventDefault();var t={filename:$(this).parent().find(".file-description__filename").first().text(),channelId:channelId},n=$(this).parent();$.post("deletedocs",JSON.stringify(t)).done(function(){n.fadeOut()}).fail(function(){console.error("error")})}),window.onload=function(){$("#loader-overlay").hide(),$("#concierge-iframe").attr("src","/concierge-example"),$("#invoice-generator").attr("src","/insert-trans"),getPortfolioData()},$("#invoice-modal").on("hidden.bs.modal",function(e){$("#invoice-modal").find(".modal-body").find("alert-danger").remove()}),$(document).on("click",".js-portfolio-image",function(){$($(this).siblings()[0]).click()}),$avatar.on("click",function(){event.preventDefault(),$("#avatar-file-input").first().click()}),$(document).on("change","#avatar-file-input",function(e){e.preventDefault();var t=$(this).prop("files")[0],n=getFormData();n.append("file",t),$.ajax({url:"/update-profile-pic",type:"POST",data:n,processData:!1,contentType:!1,success:function(e){window.location.reload(!0)},error:function(e){console.error(e)}}),x}),$(document).on("change",".js-portfolio-image-input",function(e){e.preventDefault();var t=$(this).prop("files")[0],n=getFormData();n.append("file",t),$.ajax({url:"/update-channel-pic",type:"POST",data:n,processData:!1,contentType:!1,success:function(e){window.location.reload(!0)},error:function(e){console.error(e)}})}),$("#load-more-button").click(function(e){e.preventDefault();var t=$(this);t.hasClass("disabled")||(t.addClass("disabled"),t.html('<i class="fa fa-spinner fa-spin"></i>'),$.get("/get-additional-channels/"+userId,"",function(e){e.error&&(renderPortfolios(e.portList),initSendBird(!1)),t.removeClass("disabled"),t.html("Load more")}))});var processedChannels=[];function getPortfolioData(){$(".js-graphs-loader-overlay").show();var e="/getchannelgraph/"+channelId+"?uniqid="+Math.random();$.get(e,"",function(e){handlerChannelDataResponse(e),$(".js-graphs-loader-overlay").hide(),lozad().observe(),processedChannels[channelId]=e})}function handlerChannelDataResponse(e){for(var t in $(".file-container").not(".hidden").hide(),e.documents)renderChannelFiles(e.documents[t]);renderGraphsFromJson(e.graphs)}
  