const TextPopover=function(){const t={showTooltip:!0,bgColor:"#0a3063",iconColor:"#fff",hideArrow:!1,popoverShadow:"0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);",iconTransition:!0};function e(t,e,o,n){let c=screen.width/2-o/2,i=screen.height/2-n/2;return window.open(t,e,"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width="+o+", height="+n+", top="+i+", left="+c)}const o={twitter:{url:"https://twitter.com/intent/tweet?text=",tooltip:"Tweet",icon:'',handlerFn:function(){const t=window.location.href;return e(this.twitter.url+encodeURIComponent(this.selectedText)+" "+t,"Share",550,295),!1}},facebook:{url:"https://www.facebook.com/sharer/sharer.php?quote=",tooltip:"Share",icon:'',handlerFn:function(){let t=window.location.href,o=this.facebook.url;"http"!==t.substring(0,4)&&(t="http://www.demourl.com"),e(o+=this.selectedText+"&u="+t,"Share",600,500)}},search:{url:"https://www.google.co.in/search?q=",tooltip:"Search",icon:'',handlerFn:function(){return e(this.search.url+encodeURIComponent(this.selectedText),"Search",900,540),!1}},copy:{tooltip:"Copy",icon:'',handlerFn:function(){!function(t){let e=document.createElement("textarea");e.style.position="fixed",e.style.top=0,e.style.left=0,e.style.width="2em",e.style.height="2em",e.style.padding=0,e.style.border="none",e.style.outline="none",e.style.boxShadow="none",e.style.background="transparent",e.value=t,document.body.appendChild(e),e.focus(),e.select();try{let t=document.execCommand("copy")?"successful":"unsuccessful";console.log("Copying text command was "+t)}catch(t){console.log("Oops, unable to copy")}document.body.removeChild(e)}(this.selectedText)}},speak:{tooltip:"Speak",icon:'',handlerFn:function(){let t=new SpeechSynthesisUtterance(this.selectedText);window.speechSynthesis.speak(t)}},translate:{url:"https://translate.google.com/#auto/",tooltip:"Translate",icon:'',handlerFn:function(){return e(this.translate.url+(navigator.language||navigator.userLanguage||function(){if(navigator.languages,navigator.languages.length>0)return navigator.languages[0]}()||"en").split("-")[0]+"/"+this.selectedText,"Translate",900,540),!1}}};return function(){const e={twitter:!0,facebook:!0,search:!0,copy:!0,speak:!0,translate:!0};let n="",c={},i=5,s=38,l=0,r=0;function a(e){if(o.hasOwnProperty(e)){const n=o[e];return new function(e,n,c){const i=document.createElement("div");if(i.className="popover-tooltip",i.style="display:inline-block;margin:7px;cursor:pointer;"+(t.iconTransition?"transition: all .2s ease-in-out;":""),i.innerHTML=e,i.onclick=function(){c.call(o)},t.showTooltip){const t=document.createElement("span");t.className="tooltiptext",t.innerText=n,i.appendChild(t)}return i.onmouseover=function(){t.iconTransition?this.style.transform="scale(1.2)":this.style.transform="scale(1)"},i.onmouseout=function(){this.style.transform="scale(1)"},i}(n.icon,n.tooltip,n.handlerFn)}return null}function h(){const t=n.getRangeAt(0).getBoundingClientRect(),e=window.pageXOffset||document.documentElement.scrollTop||document.body.scrollTop;l=t.top+e-s-i-5,r=t.left+(t.width-s*c.length)/2}function d(e){e.querySelectorAll("span").forEach(e=>{!function(e){t.iconTransition||(e.style.transform="scale(1.2)",e.style.bottom="150%");let o=-1*(e.offsetWidth/2-12);e.style.left=`${o}px`}(e)})}function p(){c=function(){const t=document.createElement("div");t.style.paddingLeft="0.5rem",t.style.paddingRight="0.5rem",t.style.paddingTop="0.2rem",t.style.paddingBottom="0.2rem";let o=0;for(let n in e)e.hasOwnProperty(n)&&e[n]&&(t.appendChild(a(n)),o++);return{icons:t,length:o}}(),h();const o=document.createElement("div");o.className="selection",o.style="line-height:0;position:absolute;background-color:"+t.bgColor+";border-radius:10px;top:"+l+"px;left:"+r+"px;transition:all 0.2s ease-in-out;box-shadow:"+t.popoverShadow+"z-index:99999;",o.appendChild(c.icons);const n=document.createElement("div");n.style="position:absolute;border-left:"+i+"px solid transparent;border-right:"+i+"px solid transparent;border-top:"+i+"px solid "+t.bgColor+";bottom:-"+(i-1)+"px;left:"+(s*c.length/2-i)+"px;width:0;height:0;",t.hideArrow||o.appendChild(n),document.body.appendChild(o),t.showTooltip&&d(c.icons)}function u(){function t(){return!!window.getSelection().toString()}window.addEventListener("mouseup",function(){setTimeout(function(){if(document.querySelector(".selection")){if(t())return n=window.getSelection(),o.selectedText=n.toString(),void function(){h();let t=document.querySelector(".selection");t.style.top=`${l}px`,t.style.left=`${r}px`}();document.querySelector(".selection").remove()}t()&&(n=window.getSelection(),o.selectedText=n.toString(),p())},10)},!1)}return{configPopoverButtons:function(t){for(let o in t)t.hasOwnProperty(o)&&(e[o]=t[o]);return this},configPopover:function(e){for(let o in e)e.hasOwnProperty(o)&&t.hasOwnProperty(o)&&(!1===e[o]&&"boolean"==typeof t[o]?t[o]=e[o]:e[o]&&(t[o]=e[o]));return this},addPopoverButton:function(t){return o[t.name]=t,e[t.name]=!0,this},init:function(){return function(){const e=document.createElement("style");e.innerHTML=`.text_popover_icon{\n fill: ${t.iconColor}!important;\n color: ${t.iconColor}!important;\n height: 24px!important;\n width: 24px!important;\n vertical-align: middle!important;\n }`,document.body.appendChild(e)}(),u(),this}}}}();