"use strict";(self.webpackChunkjustpasteit=self.webpackChunkjustpasteit||[]).push([[6190],{18932:function(e,i,s){var t=s(96540),n=s(5338),r=s(71083),a=s(37954);window.unreadMessagesCount=null,window.unreadSharedArticlesCount=null,window.unreadSubscribedArticlesCount=null;class o{static async get(e,i){if(!i&&null!==window.unreadMessagesCount&&-1!==window.unreadMessagesCount)return[window.unreadMessagesCount,window.unreadSharedArticlesCount,window.unreadSubscribedArticlesCount];if(-1===window.unreadMessagesCount){do{await(0,a.A)(500)}while(-1===window.unreadMessagesCount);if(!i&&null!==window.unreadMessagesCount)return[window.unreadMessagesCount,window.unreadSharedArticlesCount,window.unreadSubscribedArticlesCount]}window.unreadMessagesCount=-1;try{const i=await r.A.get(e,{withCredentials:!0,validateStatus:e=>200===e});if(200===i.status){const e=i.data;return window.unreadMessagesCount=e.unreadMessages,window.unreadSharedArticlesCount=e.unreadSharedArticles,window.unreadSubscribedArticlesCount=e.unreadSubscribedArticles,[window.unreadMessagesCount,window.unreadSharedArticlesCount,window.unreadSubscribedArticlesCount]}console.error("Wrong response status: "+i.status)}catch(e){console.error(e)}return window.unreadMessagesCount=null,window.unreadSharedArticlesCount=null,window.unreadSubscribedArticlesCount=null,[null,null,null]}}var d=s(40195),l=s(74848);function u(e,i,s){return(i=function(e){var i=function(e,i){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var t=s.call(e,i||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===i?String:Number)(e)}(e,"string");return"symbol"==typeof i?i:i+""}(i))in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,e}class h extends t.Component{constructor(e){super(e),u(this,"options",void 0),u(this,"wrapperRef",void 0),u(this,"visibilityApi",void 0),u(this,"refreshUnreadInterval",5e3),this.options=window.mainPanelOptions,this.state={submenuOpen:!1,dropdownOpen:!1,unreadMessages:0,unreadSharedArticles:0,unreadSubscribedArticles:0},this.handlePhoneAccountButtonClick=this.handlePhoneAccountButtonClick.bind(this),this.handleDesktopAccountButtonClick=this.handleDesktopAccountButtonClick.bind(this),this.handleLogoutClick=this.handleLogoutClick.bind(this),this.setWrapperRef=this.setWrapperRef.bind(this),this.handleClickOutside=this.handleClickOutside.bind(this),this.refreshUnreadMessages=this.refreshUnreadMessages.bind(this),this.visibilityApi=new d.A}componentDidMount(){document.addEventListener("mousedown",this.handleClickOutside),this.options.isLoggedIn&&this.startUnreadMessagesSync()}async startUnreadMessagesSync(){await this.updateUnreadCount(!1),this.visibilityApi.isSupported()&&this.visibilityApi.installHook(),this.visibilityApi.setEveryVisibility(this.refreshUnreadMessages,this.refreshUnreadInterval)}refreshUnreadMessages(){this.updateUnreadCount(!0)}componentWillUnmount(){document.removeEventListener("mousedown",this.handleClickOutside)}render(){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("a",{href:this.options.addArticleUrl,className:"d-flex align-items-center col text-decoration-none",children:(0,l.jsx)("img",{src:this.options.logoUrl,width:"160px",height:"50px",alt:"JustPaste.it"})}),(0,l.jsxs)("div",{className:"col-auto text-end mainTableTopButtons",children:[(0,l.jsx)("div",{className:"d-inline-block d-lg-none",children:this.renderPhoneMenu()}),(0,l.jsxs)("div",{className:"d-none d-lg-inline-block btn-group",children:[this.renderDesktopMainButtons(),this.renderDesktopAccountButton()]})]}),this.renderSubmenu()]})}renderDesktopMainButtons(){return this.options.isLoggedIn?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("a",{href:this.options.addArticleUrl,className:"btn btn-danger btn-sm topHeaderButtons",children:[(0,l.jsx)("i",{className:"bi bi-pencil-square topBarIcon"})," Add"]}),(0,l.jsxs)("a",{href:this.options.manageAccountUrl,className:"btn btn-danger btn-sm topHeaderButtons",children:[(0,l.jsx)("i",{className:"bi bi-card-checklist topBarIcon"})," Notes"]}),(0,l.jsxs)("a",{href:this.options.messagesUrl,className:"btn btn-danger btn-sm topHeaderButtons",children:[(0,l.jsx)("i",{className:"bi bi-chat-left-text topBarIcon"})," Messages ",this.renderSubMessagesUnread()]}),(0,l.jsxs)("a",{href:this.options.subscribedArticlesUrl,className:"btn btn-danger btn-sm topHeaderButtons",children:[(0,l.jsx)("i",{className:"bi bi-bell topBarIcon"})," Subscribed ",this.renderSubscribedArticlesUnread()]}),(0,l.jsxs)("a",{href:this.options.sharedArticlesUrl,className:"btn btn-danger btn-sm topHeaderButtons",children:[(0,l.jsx)("i",{className:"bi bi-share topBarIcon"})," Shared with you ",this.renderSubSharedArticlesUnread()]})]}):(0,l.jsxs)("a",{href:this.options.addArticleUrl,className:"btn btn-danger btn-sm topHeaderButtons",children:[(0,l.jsx)("i",{className:"bi bi-pencil-square topBarIcon"})," Add"]})}setWrapperRef(e){this.wrapperRef=e}handleClickOutside(e){this.wrapperRef&&this.state.dropdownOpen&&(this.wrapperRef.contains(e.target)||this.setState({dropdownOpen:!1}))}async updateUnreadCount(e){const[i,s,t]=await o.get(this.options.unreadMessagesUrl,e);null!==i&&this.setState({unreadMessages:i}),null!==s&&this.setState({unreadSharedArticles:s}),null!==t&&this.setState({unreadSubscribedArticles:t})}renderPhoneMenu(){return this.options.isLoggedIn?(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)("a",{className:"btn btn-danger btn-sm topUserBtn topHeaderButtons",rel:"nofollow",onClick:this.handlePhoneAccountButtonClick,children:[(0,l.jsx)("img",{src:window.mainPanelOptions.userAvatar,className:"topUserAvatar rounded-circle",alt:"Avatar",width:20,height:20})," ",(0,l.jsxs)("span",{className:"topUserBtnText",children:[(0,l.jsx)("span",{className:"d-none d-sm-inline",children:this.renderShortUserName()})," ",this.renderUnreadMessagesBadge()]}),(0,l.jsx)("span",{className:"topUserBtnText topUserBtnList",children:(0,l.jsx)("i",{className:"bi bi-list"})})]})}):(0,l.jsxs)("div",{className:"btn-group",children:[this.renderGuestAddNoteButton(),this.renderGuestAccountButton()]})}renderGuestAddNoteButton(){return(0,l.jsxs)("a",{href:this.options.addArticleUrl,className:"btn btn-danger btn-sm topHeaderButtons",children:[(0,l.jsx)("i",{className:"bi bi-pencil-square topBarIcon"})," Add"]})}renderGuestAccountButton(){return(0,l.jsxs)("a",{className:"btn btn-sm btn-danger topHeaderButtons",rel:"nofollow",href:this.options.loginUrl,children:[(0,l.jsx)("i",{className:"bi bi-person-square topBarIcon"})," ","Account"]})}renderDesktopAccountButton(){return this.options.isLoggedIn?(0,l.jsxs)("div",{ref:this.setWrapperRef,className:"btn-group dropdown",children:[(0,l.jsxs)("a",{className:"btn btn-danger btn-sm dropdown-toggle topUserBtn topHeaderButtons "+(this.state.dropdownOpen?"show":""),rel:"nofollow","data-bs-toggle":"dropdown",onClick:this.handleDesktopAccountButtonClick,children:[(0,l.jsx)("img",{src:window.mainPanelOptions.userAvatar,className:"topUserAvatar rounded-circle",alt:"Avatar",width:20,height:20})," ",(0,l.jsx)("span",{className:"topUserBtnText",children:(0,l.jsx)("span",{className:"d-none d-sm-inline",children:this.renderShortUserName()})})]}),(0,l.jsxs)("ul",{className:"dropdown-menu dropDownButtons "+(this.state.dropdownOpen?"show dropDownOpen":""),children:[this.renderPublicProfileLink(),(0,l.jsx)("li",{children:(0,l.jsxs)("a",{href:this.options.articlesStatsUrl,className:"dropdown-item",children:[(0,l.jsx)("i",{className:"bi bi-bar-chart-line d-none d-sm-inline"})," ",(0,l.jsx)("span",{className:"d-none d-sm-inline",children:"Notes statistics"}),(0,l.jsx)("span",{className:"d-inline d-sm-none",children:"Statistics"})]})}),(0,l.jsx)("li",{children:(0,l.jsxs)("a",{href:this.options.favouriteArticlesUrl,className:"dropdown-item",children:[(0,l.jsx)("i",{className:"bi bi-star d-none d-sm-inline"})," Favourite ",(0,l.jsx)("span",{className:"d-none d-sm-inline",children:"notes"})]})}),(0,l.jsx)("li",{children:(0,l.jsxs)("a",{href:this.options.trashUrl,className:"dropdown-item",children:[(0,l.jsx)("i",{className:"bi bi-trash d-none d-sm-inline"})," Trash"]})}),(0,l.jsx)("li",{children:(0,l.jsxs)("a",{href:this.options.profileSettings,className:"dropdown-item",children:[(0,l.jsx)("i",{className:"bi bi-sliders d-none d-sm-inline"})," Settings"]})}),(0,l.jsx)("li",{children:(0,l.jsxs)("a",{href:this.options.premiumUrl,className:"dropdown-item",children:[(0,l.jsx)("i",{className:"bi bi-gem d-none d-sm-inline"})," Premium"]})}),(0,l.jsx)("li",{children:(0,l.jsx)("hr",{className:"dropdown-divider"})}),(0,l.jsx)("li",{children:(0,l.jsxs)("a",{href:"#",onClick:this.handleLogoutClick,className:"dropdown-item",children:[(0,l.jsx)("i",{className:"bi bi-box-arrow-right d-none d-sm-inline"})," Logout"]})})]})]}):this.renderGuestAccountButton()}rToRoute(e){location.href=e}renderSubmenu(){return this.state.submenuOpen?(0,l.jsxs)("div",{className:"col-12 list-group topSubmenu",children:[this.renderSubmenuItem("add",this.options.addArticleUrl,"bi-pencil-square",(0,l.jsx)(l.Fragment,{children:"Add note"})),this.renderSubmenuItem("manage",this.options.manageAccountUrl,"bi-card-checklist",(0,l.jsx)(l.Fragment,{children:"Your notes"})),this.renderSubmenuItem("stats",this.options.articlesStatsUrl,"bi-bar-chart-line",(0,l.jsx)(l.Fragment,{children:"Notes statistics"})),this.renderSubmenuItem("messages",this.options.messagesUrl,"bi-chat-left-text",(0,l.jsxs)(l.Fragment,{children:["Messages ",this.renderSubMessagesUnread()]})),this.renderSubmenuItem("subscribed",this.options.subscribedArticlesUrl,"bi-bell",(0,l.jsxs)(l.Fragment,{children:["Subscribed ",this.renderSubscribedArticlesUnread()]})),this.renderSubmenuItem("favourites",this.options.favouriteArticlesUrl,"bi-star",(0,l.jsx)(l.Fragment,{children:"Favourite notes"})),this.renderSubmenuItem("shared",this.options.sharedArticlesUrl,"bi-share",(0,l.jsxs)(l.Fragment,{children:["Shared with you ",this.renderSubSharedArticlesUnread()]})),this.renderSubmenuItem("trash",this.options.trashUrl,"bi-trash",(0,l.jsx)(l.Fragment,{children:"Trash"})),this.renderSubmenuItem("settings",this.options.profileSettings,"bi-sliders",(0,l.jsx)(l.Fragment,{children:"Settings"})),this.renderSubmenuItem("subscription",this.options.premiumUrl,"bi-gem",(0,l.jsx)(l.Fragment,{children:"Premium"})),this.renderSubmenuPublicProfileLink(),(0,l.jsxs)("a",{href:"#",onClick:this.handleLogoutClick,className:"list-group-item",children:[(0,l.jsx)("i",{className:"bi bi-box-arrow-right"})," Logout"]})]}):null}renderSubmenuPublicProfileLink(){return null!==this.options.userPermalink&&this.options.userProfileIsPublic?this.renderSubmenuItem("publicProfile",this.options.userProfileLink,"bi-person-square",(0,l.jsx)(l.Fragment,{children:"Public profile"})):null}renderSubmenuItem(e,i,s,t){const n=window?.tabsData?.activeTab===e;return(0,l.jsxs)("a",{href:i,className:"list-group-item "+(n?"active":""),children:[(0,l.jsx)("i",{className:"bi "+s})," ",t]})}renderUnreadMessagesBadge(){const e=this.state.unreadMessages+this.state.unreadSharedArticles;return 0===e?null:(0,l.jsx)("span",{className:"badge bg-warning text-dark",children:e})}renderSubMessagesUnread(){return 0===this.state.unreadMessages?null:(0,l.jsx)("span",{className:"badge bg-warning text-dark",children:this.state.unreadMessages})}renderSubSharedArticlesUnread(){return 0===this.state.unreadSharedArticles?null:(0,l.jsx)("span",{className:"badge bg-warning text-dark",children:this.state.unreadSharedArticles})}renderSubscribedArticlesUnread(){return 0===this.state.unreadSubscribedArticles?null:(0,l.jsx)("span",{className:"badge bg-warning text-dark",children:this.state.unreadSubscribedArticles})}async handleLogoutClick(){try{await r.A.post(this.options.logoutUrl)}catch(e){console.error(e)}location.href=this.options.addArticleUrl}renderPublicProfileLink(){return null!==this.options.userPermalink&&this.options.userProfileIsPublic?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("li",{children:(0,l.jsxs)("a",{className:"dropdown-item",href:this.options.userProfileLink,children:[(0,l.jsxs)("span",{className:"d-none d-sm-inline",children:[(0,l.jsx)("i",{className:"bi bi-person-square"})," Public profile"]}),(0,l.jsx)("span",{className:"d-inline d-sm-none",children:"Profile"})]})}),(0,l.jsx)("li",{children:(0,l.jsx)("hr",{className:"dropdown-divider"})})]}):null}handlePhoneAccountButtonClick(){this.setState({submenuOpen:!this.state.submenuOpen})}handleDesktopAccountButtonClick(){this.setState({dropdownOpen:!this.state.dropdownOpen})}renderShortUserName(){let e=this.options.userPermalink;if(null!==e)return e.length>16&&(e=e.substr(0,12)+"..."),e;let i=this.options.userEmail;if(i.length>16){const e=i.split("@");i=e[0],i.length>16&&(i=i.substr(0,12)+"...")}return i}}var c=s(97691);!async function(){const e=await(0,c.A)("mainPanelButtons");(0,n.createRoot)(e).render((0,l.jsx)(t.StrictMode,{children:(0,l.jsx)(h,{...e.dataset})}))}()},40195:function(e,i){function s(e,i,s){return(i=function(e){var i=function(e,i){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var t=s.call(e,i||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===i?String:Number)(e)}(e,"string");return"symbol"==typeof i?i:i+""}(i))in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,e}var t=function(e){return e.Visible="visible",e.Hidden="hidden",e.Prerender="prerender",e.Unloaded="unloaded",e}(t||{});i.A=class{constructor(){if(s(this,"isEnabled",void 0),s(this,"hiddenName",void 0),s(this,"visibilityChangeName",void 0),s(this,"isHidden",void 0),s(this,"visibilityStateSupported",void 0),s(this,"visibilityTimer",null),s(this,"visibilityTimerInterval",100),s(this,"everyVisibilityHook",void 0),s(this,"everyVisibilityInterval",void 0),s(this,"everyVisibilityIntervalCountdown",void 0),s(this,"visibilityTime",0),void 0===document.addEventListener)return void(this.isEnabled=!1);let e,i;if(this.visibilityStateSupported=void 0!==document.visibilityState,void 0!==document.hidden)e="hidden",i="visibilitychange";else if(void 0!==document.msHidden)e="msHidden",i="msvisibilitychange";else{if(void 0===document.webkitHidden)return void(this.isEnabled=!1);e="webkitHidden",i="webkitvisibilitychange"}this.isEnabled=!0,this.hiddenName=e,this.visibilityChangeName=i,this.handleVisibilityChange=this.handleVisibilityChange.bind(this),this.startVisibilityTimerTick=this.startVisibilityTimerTick.bind(this)}installHook(){this.isSupported()&&(void 0!==document.onvisibilitychange?document.onvisibilitychange=this.handleVisibilityChange:document.addEventListener(this.visibilityChangeName,this.handleVisibilityChange,!1),this.startVisibilityTimer())}setEveryVisibility(e,i){this.everyVisibilityHook=e,this.everyVisibilityInterval=i,this.resetEveryVisibilityIntervalCountdown()}isVisible(){return!this.isHidden}resetEveryVisibilityIntervalCountdown(){this.everyVisibilityIntervalCountdown=this.everyVisibilityInterval}stopVisibilityTimer(){null!==this.visibilityTimer&&(clearTimeout(this.visibilityTimer),this.visibilityTimer=null)}isSupported(){return this.isEnabled}handleVisibilityChange(){document[this.hiddenName]?this.onHidden():this.visibilityStateSupported&&document.visibilityState!==t.Visible||this.onVisible()}startVisibilityTimerTick(){this.visibilityTime+=this.visibilityTimerInterval,this.everyVisibilityIntervalCountdown-=this.visibilityTimerInterval,void 0!==this.everyVisibilityHook&&this.everyVisibilityIntervalCountdown<=0&&(this.resetEveryVisibilityIntervalCountdown(),this.everyVisibilityHook()),this.startVisibilityTimer()}onHidden(){this.isHidden=!0,this.stopVisibilityTimer()}onVisible(){this.isHidden=!1,this.resetEveryVisibilityIntervalCountdown(),this.startVisibilityTimer()}startVisibilityTimer(){this.visibilityTimer=setTimeout(this.startVisibilityTimerTick,this.visibilityTimerInterval)}}},37954:function(e,i){i.A=e=>new Promise((i=>setTimeout(i,e)))},97691:function(e,i,s){var t=s(37954);i.A=async e=>{let i=null;do{i=document.getElementById(e),null===i&&await(0,t.A)(100)}while(null===i);return i}},5338:function(e,i,s){var t=s(40961);i.createRoot=t.createRoot,i.hydrateRoot=t.hydrateRoot}},function(e){e.O(0,[6432,1083],(function(){return i=18932,e(e.s=i);var i}));e.O()}]);