/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{d as h}from"./DPJE33GY.js";import{g as S}from"./UG7LOBJE.js";import a from"./AD6GOUND.js";import{B as I,g as d,n as c}from"./4B3QBH5T.js";import"./FUPYXGG6.js";import"./NKG4FLLR.js";import{F as y,g as C,h as n,m,z as u}from"./RPU6VCJ4.js";import"./OR4HXHSY.js";export default $arcgis.t(([,,,,,,,,,,,,,,,{Kc:v,Mc:F}])=>{var L=C`:host{overflow-y:auto;overflow-x:hidden;margin-bottom:var(--arcgis-charts-intra-section-margin);margin-top:var(--arcgis-charts-intra-section-margin);height:100%}`,p=class extends u{constructor(){super(...arguments),this.onModelConfigChange=async e=>{let i=e?.detail.config??this.model.config;this.layer===void 0&&await this.updateFetchLayerFieldsInfo(i)},this.popoverPlacement="leading",this.arcgisChartsConfigNoSeriesUpdate=m(),this.arcgisChartsConfigWebChartChange=m()}static{this.properties={layerFieldsInfo:16,model:0,popoverPlacement:1,seriesColor:0,calculatedMinMaxBounds:0,page:1,layer:0,usePopupTemplateFieldsInfo:5,filterBySelection:5,chartData:0}}static{this.styles=L}async load(){this.seriesColor!==void 0&&this.seriesColorChange(this.seriesColor),await this.updateFetchLayerFieldsInfo(this.model?.config),this.modelChange(this.model)}willUpdate(e){let i=!1;e.has("model")&&this.modelChange(this.model,e.get("model")),e.has("layer")&&this.layer!==void 0&&!c(e.get("layer"),this.layer)&&(i=!0),e.has("usePopupTemplateFieldsInfo")&&this.usePopupTemplateFieldsInfo!==e.get("usePopupTemplateFieldsInfo")&&(i=!0),e.has("seriesColor")&&this.seriesColorChange(this.seriesColor),this.layerFieldsInfo===void 0&&(i=!0),i&&this.updateFetchLayerFieldsInfo()}disconnectedCallback(){super.disconnectedCallback(),this.model.removeEventListener("arcgisChartsModelConfigChange",this.onModelConfigChange)}modelChange(e,i){i?.removeEventListener("arcgisChartsModelConfigChange",this.onModelConfigChange),e?.addEventListener("arcgisChartsModelConfigChange",this.onModelConfigChange)}seriesColorChange(e){let{slices:i,groupedSlices:o,groupOfSlices:a}=e?.get(0)??{},t=[];this.filterBySelection===!0?t=this.model.slices?.map(r=>i?.find(s=>s.sliceId===r.sliceId)??o?.find(s=>s.sliceId===r.sliceId)??r)??[]:t=(i??[]).concat(o??[]),t.forEach((r,s)=>{let f=this.model.slices?.find(b=>b.sliceId===t[s].sliceId);f&&(t[s]={...t[s],...f});let l=t[s].fillSymbol;l!==void 0&&!c(l?.outline?.color,l?.color)&&(l.outline={...l.outline??{},type:I.SLS,color:l.color})});let g=(o??[]).map(r=>r.sliceId);o!==void 0&&!c(g,this.model.groupedSliceIds)&&(this.model.groupedSliceIds=d(g)),c(t,this.model.slices)||(this.model.slices=d(t)),a!==void 0&&!c(a,this.model.sliceGrouping)&&(this.model.sliceGrouping=d(a))}async updateFetchLayerFieldsInfo(e){let i=e??this.model.config,o=this.layer;if(!o){let a=S(i)?i.iLayer:void 0;a&&(o=await v(a))}o&&(this.layerFieldsInfo=await F(o,this.usePopupTemplateFieldsInfo))}render(){let e;switch(this.page){case h.Data:e=n`<arcgis-charts-config-pie-chart-data .model=${this.model} .layerFieldsInfo=${this.layerFieldsInfo}></arcgis-charts-config-pie-chart-data>`;break;case h.Slices:e=n`<arcgis-charts-config-pie-chart-slices .model=${this.model} .chartData=${this.chartData} .popoverPlacement=${this.popoverPlacement}></arcgis-charts-config-pie-chart-slices>`;break;case h.Format:e=n`<arcgis-charts-config-format .model=${this.model}></arcgis-charts-config-format>`;break;case h.General:e=n`<arcgis-charts-config-general .model=${this.model}></arcgis-charts-config-general>`;break;default:e="";break}return e}};y("arcgis-charts-config-pie-chart",p);return p},"Graphic","renderers/support/jsonUtils","symbols/support/symbolUtils","intl","layers/support/FeatureFilter","smartMapping/statistics/histogram","smartMapping/statistics/summaryStatistics","request","core/sql","AttributeBinsGraphic","geometry/support/jsonUtils","rest/support/AttributeBinsQuery","rest/support/StatisticDefinition","time/TimeExtent","core/promiseUtils",a)