!function(t,i){var e,n,a,s=t.Chart,r=t.extend,o=t.each;a=["path","rect","circle"],n={top:0,left:0,center:.5,middle:.5,bottom:1,right:1};var h=i.inArray,l=t.merge;function p(t){return"[object Array]"===Object.prototype.toString.call(t)}function c(t){return"number"==typeof t}function d(t){return t!==e&&null!==t}var u=function(){this.init.apply(this,arguments)};u.prototype={init:function(t,i){var e=i.shape&&i.shape.type;this.chart=t,this.options=l({},function(t){var i,e;return e={xAxis:0,yAxis:0,title:{style:{},text:"",x:0,y:0},shape:{params:{stroke:"#000000",fill:"transparent",strokeWidth:2}}},(i={circle:{params:{x:0,y:0}}})[t]&&(e.shape=l(e.shape,i[t])),e}(e),i)},render:function(t){var i=this.chart,e=this.chart.renderer,n=this.group,s=this.title,r=this.shape,o=this.options,l=o.title,p=o.shape;n||(n=this.group=e.g()),!r&&p&&-1!==h(p.type,a)&&(r=this.shape=e[o.shape.type](p.params)).add(n),!s&&l&&(s=this.title=e.label(l)).add(n),n.add(i.annotations.group),this.linkObjects(),!1!==t&&this.redraw()},redraw:function(){var i,e,a,s,o,l,p,u=this.options,f=this.chart,y=this.group,x=this.title,g=this.shape,b=this.linkedObject,m=f.xAxis[u.xAxis],v=f.yAxis[u.yAxis],w=u.width,k=u.height,P=n[u.anchorY],O=n[u.anchorX];if(b&&("point"===(e=b instanceof t.Point?"point":b instanceof t.Series?"series":null)?(u.xValue=b.x,u.yValue=b.y,a=b.series):"series"===e&&(a=b),y.visibility!==a.group.visibility&&y.attr({visibility:a.group.visibility})),l=d(u.xValue)?m.toPixels(u.xValue+m.minPointOffset)-m.minPixelPadding:u.x,p=d(u.yValue)?v.toPixels(u.yValue):u.y,!isNaN(l)&&!isNaN(p)&&c(l)&&c(p)){if(x&&(x.attr(u.title),x.css(u.title.style),!0),g){if(i=r({},u.shape.params),"values"===u.units){for(s in i)h(s,["width","x"])>-1?i[s]=m.translate(i[s]):h(s,["height","y"])>-1&&(i[s]=v.translate(i[s]));i.width&&(i.width-=m.toPixels(0)-m.left),i.x&&(i.x+=m.minPixelPadding),"path"===u.shape.type&&function(t,i,e,n,a){for(var s=t.length,r=0;r<s;)"number"==typeof t[r]&&"number"==typeof t[r+1]?(t[r]=i.toPixels(t[r])-n,t[r+1]=e.toPixels(t[r+1])-a,r+=2):r+=1}(i.d,m,v,l,p)}"circle"===u.shape.type&&(i.x+=i.r,i.y+=i.r),!0,g.attr(i)}y.bBox=null,c(w)||(w=(o=y.getBBox()).width),c(k)||(o||(o=y.getBBox()),k=o.height),c(O)||(O=n.center),c(P)||(P=n.center),l-=w*O,p-=k*P,f.animation&&d(y.translateX)&&d(y.translateY)?y.animate({translateX:l,translateY:p}):y.translate(l,p)}},destroy:function(){var t=this,i=this.chart.annotations.allItems,e=i.indexOf(t);e>-1&&i.splice(e,1),o(["title","shape","group"],function(i){t[i]&&(t[i].destroy(),t[i]=null)}),t.group=t.title=t.shape=t.chart=t.options=null},update:function(t,i){r(this.options,t),this.linkObjects(),this.render(i)},linkObjects:function(){var t=this.chart,i=this.linkedObject,e=i&&(i.id||i.options.id),n=this.options.linkedTo;d(n)?d(i)&&n===e||(this.linkedObject=t.get(n)):this.linkedObject=null}},r(s.prototype,{annotations:{add:function(t,i){var e,n,a=this.allItems,s=this.chart;for(p(t)||(t=[t]),n=t.length;n--;)e=new u(s,t[n]),a.push(e),e.render(i)},redraw:function(){o(this.allItems,function(t){t.redraw()})}}}),s.prototype.callbacks.push(function(i){var e,n=i.options.annotations;(e=i.renderer.g("annotations")).attr({zIndex:7}),e.add(),i.annotations.allItems=[],i.annotations.chart=i,i.annotations.group=e,p(n)&&n.length>0&&i.annotations.add(i.options.annotations),t.addEvent(i,"redraw",function(){i.annotations.redraw()})})}(Highcharts,HighchartsAdapter);