text: !function(){var t=function(t){"use strict";t=t||{};var e,o,n,r,i,a,l,s,h,c,f,u,y,d,w,g,p={bgColor:"#d00",textColor:"#fff",fontFamily:"sans-serif",fontStyle:"bold",type:"circle",position:"down",animation:"slide",elementId:!1,element:null,dataUrl:!1,win:window};(y={}).ff="undefined"!=typeof InstallTrigger,y.chrome=!!window.chrome,y.opera=!!window.opera||navigator.userAgent.indexOf("Opera")>=0,y.ie=!1,y.safari=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0,y.supported=y.chrome||y.ff||y.opera;var x=[];f=function(){},s=u=!1;var m={ready:function(){s=!0,m.reset(),f()},reset:function(){s&&(x=[],h=!1,c=!1,a.clearRect(0,0,r,n),a.drawImage(l,0,0,r,n),E.setIcon(i),window.clearTimeout(d),window.clearTimeout(w))}};m.start=function(){if(s&&!c){if(x.length>0){c=!0;var t=function(){["type","animation","bgColor","textColor","fontFamily","fontStyle"].forEach(function(t){t in x[0].options&&(e[t]=x[0].options[t])}),T.run(x[0].options,function(){h=x[0],c=!1,x.length>0&&(x.shift(),m.start())},!1)};h?T.run(h.options,function(){t()},!0):t()}}};var b={},v=function(t){return t.n="number"==typeof t.n?Math.abs(0|t.n):t.n,t.x=r*t.x,t.y=n*t.y,t.w=r*t.w,t.h=n*t.h,t.len=(""+t.n).length,t};b.circle=function(t){var o=!1;2===(t=v(t)).len?(t.x=t.x-.4*t.w,t.w=1.4*t.w,o=!0):t.len>=3&&(t.x=t.x-.65*t.w,t.w=1.65*t.w,o=!0),a.clearRect(0,0,r,n),a.drawImage(l,0,0,r,n),a.beginPath(),a.font=e.fontStyle+" "+Math.floor(t.h*(t.n>99?.85:1))+"px "+e.fontFamily,a.textAlign="center",o?(a.moveTo(t.x+t.w/2,t.y),a.lineTo(t.x+t.w-t.h/2,t.y),a.quadraticCurveTo(t.x+t.w,t.y,t.x+t.w,t.y+t.h/2),a.lineTo(t.x+t.w,t.y+t.h-t.h/2),a.quadraticCurveTo(t.x+t.w,t.y+t.h,t.x+t.w-t.h/2,t.y+t.h),a.lineTo(t.x+t.h/2,t.y+t.h),a.quadraticCurveTo(t.x,t.y+t.h,t.x,t.y+t.h-t.h/2),a.lineTo(t.x,t.y+t.h/2),a.quadraticCurveTo(t.x,t.y,t.x+t.h/2,t.y)):a.arc(t.x+t.w/2,t.y+t.h/2,t.h/2,0,2*Math.PI),a.fillStyle="rgba("+e.bgColor.r+","+e.bgColor.g+","+e.bgColor.b+","+t.o+")",a.fill(),a.closePath(),a.beginPath(),a.stroke(),a.fillStyle="rgba("+e.textColor.r+","+e.textColor.g+","+e.textColor.b+","+t.o+")","number"==typeof t.n&&t.n>999?a.fillText((t.n>9999?9:Math.floor(t.n/1e3))+"k+",Math.floor(t.x+t.w/2),Math.floor(t.y+t.h-.2*t.h)):a.fillText(t.n,Math.floor(t.x+t.w/2),Math.floor(t.y+t.h-.15*t.h)),a.closePath()},b.rectangle=function(t){2===(t=v(t)).len?(t.x=t.x-.4*t.w,t.w=1.4*t.w):t.len>=3&&(t.x=t.x-.65*t.w,t.w=1.65*t.w),a.clearRect(0,0,r,n),a.drawImage(l,0,0,r,n),a.beginPath(),a.font=e.fontStyle+" "+Math.floor(t.h*(t.n>99?.9:1))+"px "+e.fontFamily,a.textAlign="center",a.fillStyle="rgba("+e.bgColor.r+","+e.bgColor.g+","+e.bgColor.b+","+t.o+")",a.fillRect(t.x,t.y,t.w,t.h),a.fillStyle="rgba("+e.textColor.r+","+e.textColor.g+","+e.textColor.b+","+t.o+")","number"==typeof t.n&&t.n>999?a.fillText((t.n>9999?9:Math.floor(t.n/1e3))+"k+",Math.floor(t.x+t.w/2),Math.floor(t.y+t.h-.2*t.h)):a.fillText(t.n,Math.floor(t.x+t.w/2),Math.floor(t.y+t.h-.15*t.h)),a.closePath()};function C(t){if(t.paused||t.ended||u)return!1;try{a.clearRect(0,0,r,n),a.drawImage(t,0,0,r,n)}catch(t){}w=setTimeout(function(){C(t)},T.duration),E.setIcon(i)}var E={};function I(t){t=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,o,n){return e+e+o+o+n+n});var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return!!e&&{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}}function M(t,e){var o,n={};for(o in t)n[o]=t[o];for(o in e)n[o]=e[o];return n}E.getIcons=function(){var t=[];return e.element?t=[e.element]:e.elementId?(t=[g.getElementById(e.elementId)])[0].setAttribute("href",t[0].getAttribute("src")):0===(t=function(){for(var t=[],e=g.getElementsByTagName("head")[0].getElementsByTagName("link"),o=0;o<e.length;o++)/(^|\s)icon(\s|$)/i.test(e[o].getAttribute("rel"))&&t.push(e[o]);return t}()).length&&((t=[g.createElement("link")])[0].setAttribute("rel","icon"),g.getElementsByTagName("head")[0].appendChild(t[0])),t.forEach(function(t){t.setAttribute("type","image/png")}),t},E.setIcon=function(t){setTimeout(function(){var e=t.toDataURL("image/png");E.setIconSrc(e)},0)},E.setIconSrc=function(t){if(e.dataUrl&&e.dataUrl(t),e.element)e.element.setAttribute("href",t),e.element.setAttribute("src",t);else if(e.elementId){var n=g.getElementById(e.elementId);n.setAttribute("href",t),n.setAttribute("src",t)}else if(y.ff||y.opera){var r=o[o.length-1],i=g.createElement("link");o=[i],y.opera&&i.setAttribute("rel","icon"),i.setAttribute("rel","icon"),i.setAttribute("type","image/png"),g.getElementsByTagName("head")[0].appendChild(i),i.setAttribute("href",t),r.parentNode&&r.parentNode.removeChild(r)}else o.forEach(function(e){e.setAttribute("href",t)})};var T={duration:40,types:{}};return T.types.fade=[{x:.4,y:.4,w:.6,h:.6,o:0},{x:.4,y:.4,w:.6,h:.6,o:.1},{x:.4,y:.4,w:.6,h:.6,o:.2},{x:.4,y:.4,w:.6,h:.6,o:.3},{x:.4,y:.4,w:.6,h:.6,o:.4},{x:.4,y:.4,w:.6,h:.6,o:.5},{x:.4,y:.4,w:.6,h:.6,o:.6},{x:.4,y:.4,w:.6,h:.6,o:.7},{x:.4,y:.4,w:.6,h:.6,o:.8},{x:.4,y:.4,w:.6,h:.6,o:.9},{x:.4,y:.4,w:.6,h:.6,o:1}],T.types.none=[{x:.4,y:.4,w:.6,h:.6,o:1}],T.types.pop=[{x:1,y:1,w:0,h:0,o:1},{x:.9,y:.9,w:.1,h:.1,o:1},{x:.8,y:.8,w:.2,h:.2,o:1},{x:.7,y:.7,w:.3,h:.3,o:1},{x:.6,y:.6,w:.4,h:.4,o:1},{x:.5,y:.5,w:.5,h:.5,o:1},{x:.4,y:.4,w:.6,h:.6,o:1}],T.types.popFade=[{x:.75,y:.75,w:0,h:0,o:0},{x:.65,y:.65,w:.1,h:.1,o:.2},{x:.6,y:.6,w:.2,h:.2,o:.4},{x:.55,y:.55,w:.3,h:.3,o:.6},{x:.5,y:.5,w:.4,h:.4,o:.8},{x:.45,y:.45,w:.5,h:.5,o:.9},{x:.4,y:.4,w:.6,h:.6,o:1}],T.types.slide=[{x:.4,y:1,w:.6,h:.6,o:1},{x:.4,y:.9,w:.6,h:.6,o:1},{x:.4,y:.9,w:.6,h:.6,o:1},{x:.4,y:.8,w:.6,h:.6,o:1},{x:.4,y:.7,w:.6,h:.6,o:1},{x:.4,y:.6,w:.6,h:.6,o:1},{x:.4,y:.5,w:.6,h:.6,o:1},{x:.4,y:.4,w:.6,h:.6,o:1}],T.run=function(t,o,n,r){var a=T.types[g.hidden||g.msHidden||g.webkitHidden||g.mozHidden?"none":e.animation];r=!0===n?void 0!==r?r:a.length-1:void 0!==r?r:0,o=o||function(){},r<a.length&&r>=0?(b[e.type](M(t,a[r])),d=setTimeout(function(){n?r-=1:r+=1,T.run(t,o,n,r)},T.duration),E.setIcon(i)):o()},function(){(e=M(p,t)).bgColor=I(e.bgColor),e.textColor=I(e.textColor),e.position=e.position.toLowerCase(),e.animation=T.types[""+e.animation]?e.animation:p.animation,g=e.win.document;var s=e.position.indexOf("up")>-1,h=e.position.indexOf("left")>-1;if(s||h)for(var c in T.types)for(var f=0;f<T.types[c].length;f++){var u=T.types[c][f];s&&(u.y<.6?u.y=u.y-.4:u.y=u.y-2*u.y+(1-u.w)),h&&(u.x<.6?u.x=u.x-.4:u.x=u.x-2*u.x+(1-u.h)),T.types[c][f]=u}e.type=b[""+e.type]?e.type:p.type,o=E.getIcons(),i=document.createElement("canvas"),l=document.createElement("img");var y=o[o.length-1];y.hasAttribute("href")?(l.setAttribute("crossOrigin","anonymous"),l.onload=function(){n=l.height>0?l.height:32,r=l.width>0?l.width:32,i.height=n,i.width=r,a=i.getContext("2d"),m.ready()},l.setAttribute("src",y.getAttribute("href"))):(n=32,r=32,l.height=n,l.width=r,i.height=n,i.width=r,a=i.getContext("2d"),m.ready())}(),{badge:function(t,e){e=("string"==typeof e?{animation:e}:e)||{},f=function(){try{if("number"==typeof t?t>0:""!==t){var o={type:"badge",options:{n:t}};if("animation"in e&&T.types[""+e.animation]&&(o.options.animation=""+e.animation),"type"in e&&b[""+e.type]&&(o.options.type=""+e.type),["bgColor","textColor"].forEach(function(t){t in e&&(o.options[t]=I(e[t]))}),["fontStyle","fontFamily"].forEach(function(t){t in e&&(o.options[t]=e[t])}),x.push(o),x.length>100)throw new Error("Too many badges requests in queue.");m.start()}else m.reset()}catch(t){throw new Error("Error setting badge. Message: "+t.message)}},s&&f()},video:function(t){f=function(){try{if("stop"===t)return u=!0,m.reset(),void(u=!1);t.addEventListener("play",function(){C(this)},!1)}catch(t){throw new Error("Error setting video. Message: "+t.message)}},s&&f()},image:function(t){f=function(){try{var e=t.width,o=t.height,l=document.createElement("img"),s=e/r<o/n?e/r:o/n;l.setAttribute("crossOrigin","anonymous"),l.onload=function(){a.clearRect(0,0,r,n),a.drawImage(l,0,0,r,n),E.setIcon(i)},l.setAttribute("src",t.getAttribute("src")),l.height=o/s,l.width=e/s}catch(t){throw new Error("Error setting image. Message: "+t.message)}},s&&f()},rawImageSrc:function(t){f=function(){E.setIconSrc(t)},s&&f()},webcam:function(t){if(window.URL&&window.URL.createObjectURL||(window.URL=window.URL||{},window.URL.createObjectURL=function(t){return t}),y.supported){var e=!1;navigator.getUserMedia=navigator.getUserMedia||navigator.oGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia||navigator.webkitGetUserMedia,f=function(){try{if("stop"===t)return u=!0,m.reset(),void(u=!1);(e=document.createElement("video")).width=r,e.height=n,navigator.getUserMedia({video:!0,audio:!1},function(t){e.src=URL.createObjectURL(t),e.play(),C(e)},function(){})}catch(t){throw new Error("Error setting webcam. Message: "+t.message)}},s&&f()}},setOpt:function(t,o){var n=t;null==o&&"[object Object]"==Object.prototype.toString.call(t)||((n={})[t]=o);for(var r=Object.keys(n),i=0;i<r.length;i++)"bgColor"==r[i]||"textColor"==r[i]?e[r[i]]=I(n[r[i]]):e[r[i]]=n[r[i]];x.push(h),m.start()},reset:m.reset,browser:{supported:y.supported}}};"undefined"!=typeof define&&define.amd?define([],function(){return t}):"undefined"!=typeof module&&module.exports?module.exports=t:this.Favico=t}();