import{r as t,h as e,g as s,H as r}from"./p-6b2342e0.js";import{I as n,s as o,B as i,p as a,a as c,L as h,P as d,b as u,c as p}from"./p-e4917e76.js";import{s as l}from"./p-519a7d55.js";import{I as m}from"./p-6e1ab235.js";import{V as f,I as v}from"./p-8ce9e214.js";import"./p-d27ae9ff.js";import"./p-262ec334.js";import"./p-d884c644.js";import"./p-0c667d6a.js";class w extends n{constructor(){super(...arguments),this.eventType="mouseover"}createShouldHandle(){return this.shouldHandle}createHandle(){return this.handle}shouldHandle(t){return t.target.classList.contains("vega-chart-arc-path")}handle(t){const e=o(t.currentTarget),s=t.target,r=s.dataset.name;e.selectAll(".vega-chart-arc-path").each((function(){const t=this;if(t!==s&&t.classList.contains("hover")){t.classList.remove("hover");const e=t.getAttribute("d"),s=t.dataset.d;t.dataset.d=e,o(this).transition(100).duration(100).attr("d",s)}else if(!s.classList.contains("hover")){s.classList.add("hover");const t=s.getAttribute("d"),n=s.dataset.d;s.dataset.d=t,o(s).transition(100).duration(100).attr("d",n),e.select(".vega-chart-draw-g text").text(r)}}))}}class j extends i{constructor(){super(...arguments),this.arcPathHoverEntryGenerator=new w}addInteractionSupport(t){this.interactor.register(this,t,this.arcPathHoverEntryGenerator.generate())}draw(){const{data:t,colors:e,donutRadius:s,outerRadius:r,center:n}=this.options.renderOptions;return t.map(((t,o)=>{const i=this.getColorFromToken(this.getColorByIndex(o,e));return this.renderer.drawArcPath(n,t,i,r,s)}))}}class g extends i{addInteractionSupport(){}draw(){this.options.renderOptions.forEach((t=>{const{position:e,text:s,styleToken:r,textAnchor:n,rotate:o}=t;this.renderer.drawText(e,s,this.getStyleTextFromToken(r),n,o)}))}}class b{process(t,e){const{dataSource:s,colors:r}=t,{radius:n,innerRadius:o,center:i}=e;return{data:a().value((t=>t.value))(s),colors:r,outerRadius:n,donutRadius:o,center:i}}}class O{process(t){const{center:e}=t;return[{text:"",position:e,textAnchor:"middle",styleToken:"v-font-footnote2-short"}]}}class R{process(t){const e=t.dataSource.filter((t=>!(!t.name||!t.value)));return t.dataSource=e,t}}class x{process(t,e){const{type:s,donutRadius:r}=t,{innerWidth:n,innerHeight:o}=e,i=Math.min(n,o)/2;return{radius:i,innerRadius:("Donut"===s?!r||r<=0?.6:Math.min(r,.9):0)*i,center:{x:n/2,y:o/2}}}}class y extends c{constructor(){super(...arguments),this.layoutInputProcessor=new h,this.filterInputProcessor=new R,this.radiusInputProcessor=new x,this.arcPathInputProcessorChain=new d([this.filterInputProcessor,this.layoutInputProcessor,this.radiusInputProcessor,new b]),this.textInputProcessor=new O,this.legendInputProcessChain=new d([this.layoutInputProcessor,new u])}createDrawerChain(t,e){const s=this.arcPathInputProcessorChain.process(this.options),r=this.legendInputProcessChain.process(this.options);return[new j(t,e,{renderOptions:s}),new g(t,e,{renderOptions:this.textInputProcessor.process(s)}),new p(t,e,{renderOptions:r})]}}var S=function(t,e,s,r){var n,o=arguments.length,i=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,s,r);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(i=(o<3?n(i):o>3?n(e,s,i):n(e,s))||i);return o>3&&i&&Object.defineProperty(e,s,i),i};const H=class{constructor(e){t(this,e),this.globalSlimmers={},this.vegaComponentUsageRuntimeMetricsSlimmer=new f}watchOptionsHandel(t){this.updateChart(t)}disconnectedCallback(){this.chart=null,this.reRenderTimer&&clearTimeout(this.reRenderTimer)}componentWillLoad(){this.updateChart(this.options)}async reRender(){this.reRenderTimer&&clearTimeout(this.reRenderTimer),this.reRenderTimer=setTimeout((()=>{this.chart.reRender()}),0)}render(){return l(e(r,null),this.host)}updateChart(t){if(!t)return;const{mode:e="svg",dataSource:s}=t,r=function(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(s[r[n]]=t[r[n]])}return s}(t,["mode","dataSource"]),n=Object.assign(Object.assign({},r),{mode:e,container:this.host,dataSource:s||[]});this.chart?this.chart.updateOptions(n):(this.chart=new y(n),this.chart.render())}get host(){return s(this)}static get watchers(){return{options:["watchOptionsHandel"]}}};S([v()],H.prototype,"globalSlimmers",void 0),S([m()],H.prototype,"vegaComponentUsageRuntimeMetricsSlimmer",void 0),H.style=".vega-chart-legend-item{cursor:pointer}.vega-chart-line-path:hover{stroke-width:5}:host{display:block}";export{H as vega_pie_chart}