react-semaphor 0.1.33 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -696,7 +696,7 @@ Valid keys: `+JSON.stringify(Object.keys(P),null," "));var X=ee(V,Y,W,G,Z+"."+Y
696
696
  * Released under the MIT License
697
697
  */class Nge{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,r,o){const s=n.listeners[o],i=n.duration;s.forEach(a=>a({chart:t,initial:n.initial,numSteps:i,currentStep:Math.min(r-n.start,i)}))}_refresh(){this._request||(this._running=!0,this._request=e7.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((r,o)=>{if(!r.running||!r.items.length)return;const s=r.items;let i=s.length-1,a=!1,l;for(;i>=0;--i)l=s[i],l._active?(l._total>r.duration&&(r.duration=l._total),l.tick(t),a=!0):(s[i]=s[s.length-1],s.pop());a&&(o.draw(),this._notify(o,r,t,"progress")),s.length||(r.running=!1,this._notify(o,r,t,"complete"),r.initial=!1),n+=s.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let r=n.get(t);return r||(r={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,r)),r}listen(t,n,r){this._getAnims(t).listeners[n].push(r)}add(t,n){!n||!n.length||this._getAnims(t).items.push(...n)}has(t){return this._getAnims(t).items.length>0}start(t){const n=this._charts.get(t);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((r,o)=>Math.max(r,o._duration),0),this._refresh())}running(t){if(!this._running)return!1;const n=this._charts.get(t);return!(!n||!n.running||!n.items.length)}stop(t){const n=this._charts.get(t);if(!n||!n.items.length)return;const r=n.items;let o=r.length-1;for(;o>=0;--o)r[o].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var pa=new Nge;const nI="transparent",kge={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const r=qA(e||nI),o=r.valid&&qA(t||nI);return o&&o.valid?o.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}};let _ge=class{constructor(t,n,r,o){const s=n[r];o=Sn([t.to,o,s,t.from]);const i=Sn([t.from,s,o]);this._active=!0,this._fn=t.fn||kge[t.type||typeof i],this._easing=Yp[t.easing]||Yp.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=n,this._prop=r,this._from=i,this._to=o,this._promises=void 0}active(){return this._active}update(t,n,r){if(this._active){this._notify(!1);const o=this._target[this._prop],s=r-this._start,i=this._duration-s;this._start=r,this._duration=Math.floor(Math.max(i,t.duration)),this._total+=s,this._loop=!!t.loop,this._to=Sn([t.to,n,o,t.from]),this._from=Sn([t.from,o,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,r=this._duration,o=this._prop,s=this._from,i=this._loop,a=this._to;let l;if(this._active=s!==a&&(i||n<r),!this._active){this._target[o]=a,this._notify(!0);return}if(n<0){this._target[o]=s;return}l=n/r%2,l=i&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[o]=this._fn(s,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,r)=>{t.push({res:n,rej:r})})}_notify(t){const n=t?"res":"rej",r=this._promises||[];for(let o=0;o<r.length;o++)r[o][n]()}};class y7{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!_t(t))return;const n=Object.keys(kn.animation),r=this._properties;Object.getOwnPropertyNames(t).forEach(o=>{const s=t[o];if(!_t(s))return;const i={};for(const a of n)i[a]=s[a];(Cn(s.properties)&&s.properties||[o]).forEach(a=>{(a===o||!r.has(a))&&r.set(a,i)})})}_animateOptions(t,n){const r=n.options,o=Rge(t,r);if(!o)return[];const s=this._createAnimations(o,r);return r.$shared&&jge(t.options.$animations,r).then(()=>{t.options=r},()=>{}),s}_createAnimations(t,n){const r=this._properties,o=[],s=t.$animations||(t.$animations={}),i=Object.keys(n),a=Date.now();let l;for(l=i.length-1;l>=0;--l){const c=i[l];if(c.charAt(0)==="$")continue;if(c==="options"){o.push(...this._animateOptions(t,n));continue}const u=n[c];let f=s[c];const h=r.get(c);if(f)if(h&&f.active()){f.update(h,u,a);continue}else f.cancel();if(!h||!h.duration){t[c]=u;continue}s[c]=f=new _ge(h,t,c,u),o.push(f)}return o}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const r=this._createAnimations(t,n);if(r.length)return pa.add(this._chart,r),!0}}function jge(e,t){const n=[],r=Object.keys(t);for(let o=0;o<r.length;o++){const s=e[r[o]];s&&s.active()&&n.push(s.wait())}return Promise.all(n)}function Rge(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function rI(e,t){const n=e&&e.options||{},r=n.reverse,o=n.min===void 0?t:0,s=n.max===void 0?t:0;return{start:r?s:o,end:r?o:s}}function Mge(e,t,n){if(n===!1)return!1;const r=rI(e,n),o=rI(t,n);return{top:o.end,right:r.end,bottom:o.start,left:r.start}}function Dge(e){let t,n,r,o;return _t(e)?(t=e.top,n=e.right,r=e.bottom,o=e.left):t=n=r=o=e,{top:t,right:n,bottom:r,left:o,disabled:e===!1}}function x7(e,t){const n=[],r=e._getSortedDatasetMetas(t);let o,s;for(o=0,s=r.length;o<s;++o)n.push(r[o].index);return n}function oI(e,t,n,r={}){const o=e.keys,s=r.mode==="single";let i,a,l,c;if(t===null)return;let u=!1;for(i=0,a=o.length;i<a;++i){if(l=+o[i],l===n){if(u=!0,r.all)continue;break}c=e.values[l],Wn(c)&&(s||t===0||Di(t)===Di(c))&&(t+=c)}return!u&&!r.all?0:t}function Tge(e,t){const{iScale:n,vScale:r}=t,o=n.axis==="x"?"x":"y",s=r.axis==="x"?"x":"y",i=Object.keys(e),a=new Array(i.length);let l,c,u;for(l=0,c=i.length;l<c;++l)u=i[l],a[l]={[o]:u,[s]:e[u]};return a}function oC(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function Pge(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function Age(e){const{min:t,max:n,minDefined:r,maxDefined:o}=e.getUserBounds();return{min:r?t:Number.NEGATIVE_INFINITY,max:o?n:Number.POSITIVE_INFINITY}}function Ige(e,t,n){const r=e[t]||(e[t]={});return r[n]||(r[n]={})}function sI(e,t,n,r){for(const o of t.getMatchingVisibleMetas(r).reverse()){const s=e[o.index];if(n&&s>0||!n&&s<0)return o.index}return null}function iI(e,t){const{chart:n,_cachedMeta:r}=e,o=n._stacks||(n._stacks={}),{iScale:s,vScale:i,index:a}=r,l=s.axis,c=i.axis,u=Pge(s,i,r),f=t.length;let h;for(let p=0;p<f;++p){const m=t[p],{[l]:b,[c]:y}=m,g=m._stacks||(m._stacks={});h=g[c]=Ige(o,u,b),h[a]=y,h._top=sI(h,i,!0,r.type),h._bottom=sI(h,i,!1,r.type);const x=h._visualValues||(h._visualValues={});x[a]=y}}function sC(e,t){const n=e.scales;return Object.keys(n).filter(r=>n[r].axis===t).shift()}function Oge(e,t){return ac(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function Fge(e,t,n){return ac(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function Xh(e,t){const n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t=t||e._parsed;for(const o of t){const s=o._stacks;if(!s||s[r]===void 0||s[r][n]===void 0)return;delete s[r][n],s[r]._visualValues!==void 0&&s[r]._visualValues[n]!==void 0&&delete s[r]._visualValues[n]}}}const iC=e=>e==="reset"||e==="none",aI=(e,t)=>t?e:Object.assign({},e),$ge=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:x7(n,!0),values:null};class bs{constructor(t,n){this.chart=t,this._ctx=t.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=oC(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&Xh(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,r=this.getDataset(),o=(f,h,p,m)=>f==="x"?h:f==="r"?m:p,s=n.xAxisID=rt(r.xAxisID,sC(t,"x")),i=n.yAxisID=rt(r.yAxisID,sC(t,"y")),a=n.rAxisID=rt(r.rAxisID,sC(t,"r")),l=n.indexAxis,c=n.iAxisID=o(l,s,i,a),u=n.vAxisID=o(l,i,s,a);n.xScale=this.getScaleForId(s),n.yScale=this.getScaleForId(i),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(c),n.vScale=this.getScaleForId(u)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const n=this._cachedMeta;return t===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&HA(this._data,this),t._stacked&&Xh(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),r=this._data;if(_t(n)){const o=this._cachedMeta;this._data=Tge(n,o)}else if(r!==n){if(r){HA(r,this);const o=this._cachedMeta;Xh(o),o._parsed=[]}n&&Object.isExtensible(n)&&Cme(n,this),this._syncList=[],this._data=n}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const n=this._cachedMeta,r=this.getDataset();let o=!1;this._dataCheck();const s=n._stacked;n._stacked=oC(n.vScale,n),n.stack!==r.stack&&(o=!0,Xh(n),n.stack=r.stack),this._resyncElements(t),(o||s!==n._stacked)&&(iI(this,n._parsed),n._stacked=oC(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),r=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(r,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:r,_data:o}=this,{iScale:s,_stacked:i}=r,a=s.axis;let l=t===0&&n===o.length?!0:r._sorted,c=t>0&&r._parsed[t-1],u,f,h;if(this._parsing===!1)r._parsed=o,r._sorted=!0,h=o;else{Cn(o[t])?h=this.parseArrayData(r,o,t,n):_t(o[t])?h=this.parseObjectData(r,o,t,n):h=this.parsePrimitiveData(r,o,t,n);const p=()=>f[a]===null||c&&f[a]<c[a];for(u=0;u<n;++u)r._parsed[u+t]=f=h[u],l&&(p()&&(l=!1),c=f);r._sorted=l}i&&iI(this,h)}parsePrimitiveData(t,n,r,o){const{iScale:s,vScale:i}=t,a=s.axis,l=i.axis,c=s.getLabels(),u=s===i,f=new Array(o);let h,p,m;for(h=0,p=o;h<p;++h)m=h+r,f[h]={[a]:u||s.parse(c[m],m),[l]:i.parse(n[m],m)};return f}parseArrayData(t,n,r,o){const{xScale:s,yScale:i}=t,a=new Array(o);let l,c,u,f;for(l=0,c=o;l<c;++l)u=l+r,f=n[u],a[l]={x:s.parse(f[0],u),y:i.parse(f[1],u)};return a}parseObjectData(t,n,r,o){const{xScale:s,yScale:i}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=new Array(o);let u,f,h,p;for(u=0,f=o;u<f;++u)h=u+r,p=n[h],c[u]={x:s.parse(Hl(p,a),h),y:i.parse(Hl(p,l),h)};return c}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,r){const o=this.chart,s=this._cachedMeta,i=n[t.axis],a={keys:x7(o,!0),values:n._stacks[t.axis]._visualValues};return oI(a,i,s.index,{mode:r})}updateRangeFromParsed(t,n,r,o){const s=r[n.axis];let i=s===null?NaN:s;const a=o&&r._stacks[n.axis];o&&a&&(o.values=a,i=oI(o,s,this._cachedMeta.index)),t.min=Math.min(t.min,i),t.max=Math.max(t.max,i)}getMinMax(t,n){const r=this._cachedMeta,o=r._parsed,s=r._sorted&&t===r.iScale,i=o.length,a=this._getOtherScale(t),l=$ge(n,r,this.chart),c={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:f}=Age(a);let h,p;function m(){p=o[h];const b=p[a.axis];return!Wn(p[t.axis])||u>b||f<b}for(h=0;h<i&&!(!m()&&(this.updateRangeFromParsed(c,t,p,l),s));++h);if(s){for(h=i-1;h>=0;--h)if(!m()){this.updateRangeFromParsed(c,t,p,l);break}}return c}getAllParsedValues(t){const n=this._cachedMeta._parsed,r=[];let o,s,i;for(o=0,s=n.length;o<s;++o)i=n[o][t.axis],Wn(i)&&r.push(i);return r}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,r=n.iScale,o=n.vScale,s=this.getParsed(t);return{label:r?""+r.getLabelForValue(s[r.axis]):"",value:o?""+o.getLabelForValue(s[o.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=Dge(rt(this.options.clip,Mge(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,r=this._cachedMeta,o=r.data||[],s=n.chartArea,i=[],a=this._drawStart||0,l=this._drawCount||o.length-a,c=this.options.drawActiveElementsOnTop;let u;for(r.dataset&&r.dataset.draw(t,s,a,l),u=a;u<a+l;++u){const f=o[u];f.hidden||(f.active&&c?i.push(f):f.draw(t,s))}for(u=0;u<i.length;++u)i[u].draw(t,s)}getStyle(t,n){const r=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(r):this.resolveDataElementOptions(t||0,r)}getContext(t,n,r){const o=this.getDataset();let s;if(t>=0&&t<this._cachedMeta.data.length){const i=this._cachedMeta.data[t];s=i.$context||(i.$context=Fge(this.getContext(),t,i)),s.parsed=this.getParsed(t),s.raw=o.data[t],s.index=s.dataIndex=t}else s=this.$context||(this.$context=Oge(this.chart.getContext(),this.index)),s.dataset=o,s.index=s.datasetIndex=this.index;return s.active=!!n,s.mode=r,s}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,n){return this._resolveElementOptions(this.dataElementType.id,n,t)}_resolveElementOptions(t,n="default",r){const o=n==="active",s=this._cachedDataOpts,i=t+"-"+n,a=s[i],l=this.enableOptionSharing&&Dm(r);if(a)return aI(a,l);const c=this.chart.config,u=c.datasetElementScopeKeys(this._type,t),f=o?[`${t}Hover`,"hover",t,""]:[t,""],h=c.getOptionScopes(this.getDataset(),u),p=Object.keys(kn.elements[t]),m=()=>this.getContext(r,o,n),b=c.resolveNamedOptions(h,p,m,f);return b.$shared&&(b.$shared=l,s[i]=Object.freeze(aI(b,l))),b}_resolveAnimations(t,n,r){const o=this.chart,s=this._cachedDataOpts,i=`animation-${n}`,a=s[i];if(a)return a;let l;if(o.options.animation!==!1){const u=this.chart.config,f=u.datasetAnimationScopeKeys(this._type,n),h=u.getOptionScopes(this.getDataset(),f);l=u.createResolver(h,this.getContext(t,r,n))}const c=new y7(o,l&&l.animations);return l&&l._cacheable&&(s[i]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,n){return!n||iC(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const r=this.resolveDataElementOptions(t,n),o=this._sharedOptions,s=this.getSharedOptions(r),i=this.includeOptions(n,s)||s!==o;return this.updateSharedOptions(s,n,r),{sharedOptions:s,includeOptions:i}}updateElement(t,n,r,o){iC(o)?Object.assign(t,r):this._resolveAnimations(n,o).update(t,r)}updateSharedOptions(t,n,r){t&&!iC(n)&&this._resolveAnimations(void 0,n).update(t,r)}_setStyle(t,n,r,o){t.active=o;const s=this.getStyle(n,o);this._resolveAnimations(n,r,o).update(t,{options:!o&&this.getSharedOptions(s)||s})}removeHoverStyle(t,n,r){this._setStyle(t,r,"active",!1)}setHoverStyle(t,n,r){this._setStyle(t,r,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const n=this._data,r=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const o=r.length,s=n.length,i=Math.min(s,o);i&&this.parse(0,i),s>o?this._insertElements(o,s-o,t):s<o&&this._removeElements(s,o-s)}_insertElements(t,n,r=!0){const o=this._cachedMeta,s=o.data,i=t+n;let a;const l=c=>{for(c.length+=n,a=c.length-1;a>=i;a--)c[a]=c[a-n]};for(l(s),a=t;a<i;++a)s[a]=new this.dataElementType;this._parsing&&l(o._parsed),this.parse(t,n),r&&this.updateElements(s,t,n,"reset")}updateElements(t,n,r,o){}_removeElements(t,n){const r=this._cachedMeta;if(this._parsing){const o=r._parsed.splice(t,n);r._stacked&&Xh(r,o)}r.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,r,o]=t;this[n](r,o)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,n){n&&this._sync(["_removeElements",t,n]);const r=arguments.length-2;r&&this._sync(["_insertElements",t,r])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}ke(bs,"defaults",{}),ke(bs,"datasetElementType",null),ke(bs,"dataElementType",null);function Lge(e,t){if(!e._cache.$bar){const n=e.getMatchingVisibleMetas(t);let r=[];for(let o=0,s=n.length;o<s;o++)r=r.concat(n[o].controller.getAllParsedValues(e));e._cache.$bar=J9(r.sort((o,s)=>o-s))}return e._cache.$bar}function zge(e){const t=e.iScale,n=Lge(t,e.type);let r=t._length,o,s,i,a;const l=()=>{i===32767||i===-32768||(Dm(a)&&(r=Math.min(r,Math.abs(i-a)||r)),a=i)};for(o=0,s=n.length;o<s;++o)i=t.getPixelForValue(n[o]),l();for(a=void 0,o=0,s=t.ticks.length;o<s;++o)i=t.getPixelForTick(o),l();return r}function Bge(e,t,n,r){const o=n.barThickness;let s,i;return pt(o)?(s=t.min*n.categoryPercentage,i=n.barPercentage):(s=o*r,i=1),{chunk:s/r,ratio:i,start:t.pixels[e]-s/2}}function Vge(e,t,n,r){const o=t.pixels,s=o[e];let i=e>0?o[e-1]:null,a=e<o.length-1?o[e+1]:null;const l=n.categoryPercentage;i===null&&(i=s-(a===null?t.end-t.start:a-s)),a===null&&(a=s+s-i);const c=s-(s-Math.min(i,a))/2*l;return{chunk:Math.abs(a-i)/2*l/r,ratio:n.barPercentage,start:c}}function Hge(e,t,n,r){const o=n.parse(e[0],r),s=n.parse(e[1],r),i=Math.min(o,s),a=Math.max(o,s);let l=i,c=a;Math.abs(i)>Math.abs(a)&&(l=a,c=i),t[n.axis]=c,t._custom={barStart:l,barEnd:c,start:o,end:s,min:i,max:a}}function v7(e,t,n,r){return Cn(e)?Hge(e,t,n,r):t[n.axis]=n.parse(e,r),t}function lI(e,t,n,r){const o=e.iScale,s=e.vScale,i=o.getLabels(),a=o===s,l=[];let c,u,f,h;for(c=n,u=n+r;c<u;++c)h=t[c],f={},f[o.axis]=a||o.parse(i[c],c),l.push(v7(h,f,s,c));return l}function aC(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function Uge(e,t,n){return e!==0?Di(e):(t.isHorizontal()?1:-1)*(t.min>=n?1:-1)}function Wge(e){let t,n,r,o,s;return e.horizontal?(t=e.base>e.x,n="left",r="right"):(t=e.base<e.y,n="bottom",r="top"),t?(o="end",s="start"):(o="start",s="end"),{start:n,end:r,reverse:t,top:o,bottom:s}}function qge(e,t,n,r){let o=t.borderSkipped;const s={};if(!o){e.borderSkipped=s;return}if(o===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}const{start:i,end:a,reverse:l,top:c,bottom:u}=Wge(e);o==="middle"&&n&&(e.enableBorderRadius=!0,(n._top||0)===r?o=c:(n._bottom||0)===r?o=u:(s[cI(u,i,a,l)]=!0,o=c)),s[cI(o,i,a,l)]=!0,e.borderSkipped=s}function cI(e,t,n,r){return r?(e=Gge(e,t,n),e=uI(e,n,t)):e=uI(e,t,n),e}function Gge(e,t,n){return e===t?n:e===n?t:e}function uI(e,t,n){return e==="start"?t:e==="end"?n:e}function Yge(e,{inflateAmount:t},n){e.inflateAmount=t==="auto"?n===1?.33:0:t}class gu extends bs{parsePrimitiveData(t,n,r,o){return lI(t,n,r,o)}parseArrayData(t,n,r,o){return lI(t,n,r,o)}parseObjectData(t,n,r,o){const{iScale:s,vScale:i}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=s.axis==="x"?a:l,u=i.axis==="x"?a:l,f=[];let h,p,m,b;for(h=r,p=r+o;h<p;++h)b=n[h],m={},m[s.axis]=s.parse(Hl(b,c),h),f.push(v7(Hl(b,u),m,i,h));return f}updateRangeFromParsed(t,n,r,o){super.updateRangeFromParsed(t,n,r,o);const s=r._custom;s&&n===this._cachedMeta.vScale&&(t.min=Math.min(t.min,s.min),t.max=Math.max(t.max,s.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const n=this._cachedMeta,{iScale:r,vScale:o}=n,s=this.getParsed(t),i=s._custom,a=aC(i)?"["+i.start+", "+i.end+"]":""+o.getLabelForValue(s[o.axis]);return{label:""+r.getLabelForValue(s[r.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();const t=this._cachedMeta;t.stack=this.getDataset().stack}update(t){const n=this._cachedMeta;this.updateElements(n.data,0,n.data.length,t)}updateElements(t,n,r,o){const s=o==="reset",{index:i,_cachedMeta:{vScale:a}}=this,l=a.getBasePixel(),c=a.isHorizontal(),u=this._getRuler(),{sharedOptions:f,includeOptions:h}=this._getSharedOptions(n,o);for(let p=n;p<n+r;p++){const m=this.getParsed(p),b=s||pt(m[a.axis])?{base:l,head:l}:this._calculateBarValuePixels(p),y=this._calculateBarIndexPixels(p,u),g=(m._stacks||{})[a.axis],x={horizontal:c,base:b.base,enableBorderRadius:!g||aC(m._custom)||i===g._top||i===g._bottom,x:c?b.head:y.center,y:c?y.center:b.head,height:c?y.size:Math.abs(b.size),width:c?Math.abs(b.size):y.size};h&&(x.options=f||this.resolveDataElementOptions(p,t[p].active?"active":o));const v=x.options||t[p].options;qge(x,v,g,i),Yge(x,v,u.ratio),this.updateElement(t[p],p,x,o)}}_getStacks(t,n){const{iScale:r}=this._cachedMeta,o=r.getMatchingVisibleMetas(this._type).filter(u=>u.controller.options.grouped),s=r.options.stacked,i=[],a=this._cachedMeta.controller.getParsed(n),l=a&&a[r.axis],c=u=>{const f=u._parsed.find(p=>p[r.axis]===l),h=f&&f[u.vScale.axis];if(pt(h)||isNaN(h))return!0};for(const u of o)if(!(n!==void 0&&c(u))&&((s===!1||i.indexOf(u.stack)===-1||s===void 0&&u.stack===void 0)&&i.push(u.stack),u.index===t))break;return i.length||i.push(void 0),i}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,n,r){const o=this._getStacks(t,r),s=n!==void 0?o.indexOf(n):-1;return s===-1?o.length-1:s}_getRuler(){const t=this.options,n=this._cachedMeta,r=n.iScale,o=[];let s,i;for(s=0,i=n.data.length;s<i;++s)o.push(r.getPixelForValue(this.getParsed(s)[r.axis],s));const a=t.barThickness;return{min:a||zge(n),pixels:o,start:r._startPixel,end:r._endPixel,stackCount:this._getStackCount(),scale:r,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:n,_stacked:r,index:o},options:{base:s,minBarLength:i}}=this,a=s||0,l=this.getParsed(t),c=l._custom,u=aC(c);let f=l[n.axis],h=0,p=r?this.applyStack(n,l,r):f,m,b;p!==f&&(h=p-f,p=f),u&&(f=c.barStart,p=c.barEnd-c.barStart,f!==0&&Di(f)!==Di(c.barEnd)&&(h=0),h+=f);const y=!pt(s)&&!u?s:h;let g=n.getPixelForValue(y);if(this.chart.getDataVisibility(t)?m=n.getPixelForValue(h+p):m=g,b=m-g,Math.abs(b)<i){b=Uge(b,n,a)*i,f===a&&(g-=b/2);const x=n.getPixelForDecimal(0),v=n.getPixelForDecimal(1),w=Math.min(x,v),C=Math.max(x,v);g=Math.max(Math.min(g,C),w),m=g+b,r&&!u&&(l._stacks[n.axis]._visualValues[o]=n.getValueForPixel(m)-n.getValueForPixel(g))}if(g===n.getPixelForValue(a)){const x=Di(b)*n.getLineWidthForValue(a)/2;g+=x,b-=x}return{size:b,base:g,head:m,center:m+b/2}}_calculateBarIndexPixels(t,n){const r=n.scale,o=this.options,s=o.skipNull,i=rt(o.maxBarThickness,1/0);let a,l;if(n.grouped){const c=s?this._getStackCount(t):n.stackCount,u=o.barThickness==="flex"?Vge(t,n,o,c):Bge(t,n,o,c),f=this._getStackIndex(this.index,this._cachedMeta.stack,s?t:void 0);a=u.start+u.chunk*f+u.chunk/2,l=Math.min(i,u.chunk*u.ratio)}else a=r.getPixelForValue(this.getParsed(t)[r.axis],t),l=Math.min(i,n.min*n.ratio);return{base:a-l/2,head:a+l/2,center:a,size:l}}draw(){const t=this._cachedMeta,n=t.vScale,r=t.data,o=r.length;let s=0;for(;s<o;++s)this.getParsed(s)[n.axis]!==null&&!r[s].hidden&&r[s].draw(this._ctx)}}ke(gu,"id","bar"),ke(gu,"defaults",{datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}}),ke(gu,"overrides",{scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}});class E0 extends bs{initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,n,r,o){const s=super.parsePrimitiveData(t,n,r,o);for(let i=0;i<s.length;i++)s[i]._custom=this.resolveDataElementOptions(i+r).radius;return s}parseArrayData(t,n,r,o){const s=super.parseArrayData(t,n,r,o);for(let i=0;i<s.length;i++){const a=n[r+i];s[i]._custom=rt(a[2],this.resolveDataElementOptions(i+r).radius)}return s}parseObjectData(t,n,r,o){const s=super.parseObjectData(t,n,r,o);for(let i=0;i<s.length;i++){const a=n[r+i];s[i]._custom=rt(a&&a.r&&+a.r,this.resolveDataElementOptions(i+r).radius)}return s}getMaxOverflow(){const t=this._cachedMeta.data;let n=0;for(let r=t.length-1;r>=0;--r)n=Math.max(n,t[r].size(this.resolveDataElementOptions(r))/2);return n>0&&n}getLabelAndValue(t){const n=this._cachedMeta,r=this.chart.data.labels||[],{xScale:o,yScale:s}=n,i=this.getParsed(t),a=o.getLabelForValue(i.x),l=s.getLabelForValue(i.y),c=i._custom;return{label:r[t]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(t){const n=this._cachedMeta.data;this.updateElements(n,0,n.length,t)}updateElements(t,n,r,o){const s=o==="reset",{iScale:i,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(n,o),u=i.axis,f=a.axis;for(let h=n;h<n+r;h++){const p=t[h],m=!s&&this.getParsed(h),b={},y=b[u]=s?i.getPixelForDecimal(.5):i.getPixelForValue(m[u]),g=b[f]=s?a.getBasePixel():a.getPixelForValue(m[f]);b.skip=isNaN(y)||isNaN(g),c&&(b.options=l||this.resolveDataElementOptions(h,p.active?"active":o),s&&(b.options.radius=0)),this.updateElement(p,h,b,o)}}resolveDataElementOptions(t,n){const r=this.getParsed(t);let o=super.resolveDataElementOptions(t,n);o.$shared&&(o=Object.assign({},o,{$shared:!1}));const s=o.radius;return n!=="active"&&(o.radius=0),o.radius+=rt(r&&r._custom,s),o}}ke(E0,"id","bubble"),ke(E0,"defaults",{datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}}),ke(E0,"overrides",{scales:{x:{type:"linear"},y:{type:"linear"}}});function Zge(e,t,n){let r=1,o=1,s=0,i=0;if(t<Nn){const a=e,l=a+t,c=Math.cos(a),u=Math.sin(a),f=Math.cos(l),h=Math.sin(l),p=(v,w,C)=>Tm(v,a,l,!0)?1:Math.max(w,w*n,C,C*n),m=(v,w,C)=>Tm(v,a,l,!0)?-1:Math.min(w,w*n,C,C*n),b=p(0,c,f),y=p(Qn,u,h),g=m(_n,c,f),x=m(_n+Qn,u,h);r=(b-g)/2,o=(y-x)/2,s=-(b+g)/2,i=-(y+x)/2}return{ratioX:r,ratioY:o,offsetX:s,offsetY:i}}class Hc extends bs{constructor(t,n){super(t,n),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,n){const r=this.getDataset().data,o=this._cachedMeta;if(this._parsing===!1)o._parsed=r;else{let s=l=>+r[l];if(_t(r[t])){const{key:l="value"}=this._parsing;s=c=>+Hl(r[c],l)}let i,a;for(i=t,a=t+n;i<a;++i)o._parsed[i]=s(i)}}_getRotation(){return qs(this.options.rotation-90)}_getCircumference(){return qs(this.options.circumference)}_getRotationExtents(){let t=Nn,n=-Nn;for(let r=0;r<this.chart.data.datasets.length;++r)if(this.chart.isDatasetVisible(r)&&this.chart.getDatasetMeta(r).type===this._type){const o=this.chart.getDatasetMeta(r).controller,s=o._getRotation(),i=o._getCircumference();t=Math.min(t,s),n=Math.max(n,s+i)}return{rotation:t,circumference:n-t}}update(t){const n=this.chart,{chartArea:r}=n,o=this._cachedMeta,s=o.data,i=this.getMaxBorderWidth()+this.getMaxOffset(s)+this.options.spacing,a=Math.max((Math.min(r.width,r.height)-i)/2,0),l=Math.min(lme(this.options.cutout,a),1),c=this._getRingWeight(this.index),{circumference:u,rotation:f}=this._getRotationExtents(),{ratioX:h,ratioY:p,offsetX:m,offsetY:b}=Zge(f,u,l),y=(r.width-i)/h,g=(r.height-i)/p,x=Math.max(Math.min(y,g)/2,0),v=Y9(this.options.radius,x),w=Math.max(v*l,0),C=(v-w)/this._getVisibleDatasetWeightTotal();this.offsetX=m*v,this.offsetY=b*v,o.total=this.calculateTotal(),this.outerRadius=v-C*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-C*c,0),this.updateElements(s,0,s.length,t)}_circumference(t,n){const r=this.options,o=this._cachedMeta,s=this._getCircumference();return n&&r.animation.animateRotate||!this.chart.getDataVisibility(t)||o._parsed[t]===null||o.data[t].hidden?0:this.calculateCircumference(o._parsed[t]*s/Nn)}updateElements(t,n,r,o){const s=o==="reset",i=this.chart,a=i.chartArea,c=i.options.animation,u=(a.left+a.right)/2,f=(a.top+a.bottom)/2,h=s&&c.animateScale,p=h?0:this.innerRadius,m=h?0:this.outerRadius,{sharedOptions:b,includeOptions:y}=this._getSharedOptions(n,o);let g=this._getRotation(),x;for(x=0;x<n;++x)g+=this._circumference(x,s);for(x=n;x<n+r;++x){const v=this._circumference(x,s),w=t[x],C={x:u+this.offsetX,y:f+this.offsetY,startAngle:g,endAngle:g+v,circumference:v,outerRadius:m,innerRadius:p};y&&(C.options=b||this.resolveDataElementOptions(x,w.active?"active":o)),g+=v,this.updateElement(w,x,C,o)}}calculateTotal(){const t=this._cachedMeta,n=t.data;let r=0,o;for(o=0;o<n.length;o++){const s=t._parsed[o];s!==null&&!isNaN(s)&&this.chart.getDataVisibility(o)&&!n[o].hidden&&(r+=Math.abs(s))}return r}calculateCircumference(t){const n=this._cachedMeta.total;return n>0&&!isNaN(t)?Nn*(Math.abs(t)/n):0}getLabelAndValue(t){const n=this._cachedMeta,r=this.chart,o=r.data.labels||[],s=Yg(n._parsed[t],r.options.locale);return{label:o[t]||"",value:s}}getMaxBorderWidth(t){let n=0;const r=this.chart;let o,s,i,a,l;if(!t){for(o=0,s=r.data.datasets.length;o<s;++o)if(r.isDatasetVisible(o)){i=r.getDatasetMeta(o),t=i.data,a=i.controller;break}}if(!t)return 0;for(o=0,s=t.length;o<s;++o)l=a.resolveDataElementOptions(o),l.borderAlign!=="inner"&&(n=Math.max(n,l.borderWidth||0,l.hoverBorderWidth||0));return n}getMaxOffset(t){let n=0;for(let r=0,o=t.length;r<o;++r){const s=this.resolveDataElementOptions(r);n=Math.max(n,s.offset||0,s.hoverOffset||0)}return n}_getRingWeightOffset(t){let n=0;for(let r=0;r<t;++r)this.chart.isDatasetVisible(r)&&(n+=this._getRingWeight(r));return n}_getRingWeight(t){return Math.max(rt(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}ke(Hc,"id","doughnut"),ke(Hc,"defaults",{datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"}),ke(Hc,"descriptors",{_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),ke(Hc,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data;if(n.labels.length&&n.datasets.length){const{labels:{pointStyle:r,color:o}}=t.legend.options;return n.labels.map((s,i)=>{const l=t.getDatasetMeta(0).controller.getStyle(i);return{text:s,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:o,lineWidth:l.borderWidth,pointStyle:r,hidden:!t.getDataVisibility(i),index:i}})}return[]}},onClick(t,n,r){r.chart.toggleDataVisibility(n.index),r.chart.update()}}}});class N0 extends bs{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const n=this._cachedMeta,{dataset:r,data:o=[],_dataset:s}=n,i=this.chart._animationsDisabled;let{start:a,count:l}=n7(n,o,i);this._drawStart=a,this._drawCount=l,r7(n)&&(a=0,l=o.length),r._chart=this.chart,r._datasetIndex=this.index,r._decimated=!!s._decimated,r.points=o;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(r,void 0,{animated:!i,options:c},t),this.updateElements(o,a,l,t)}updateElements(t,n,r,o){const s=o==="reset",{iScale:i,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:u,includeOptions:f}=this._getSharedOptions(n,o),h=i.axis,p=a.axis,{spanGaps:m,segment:b}=this.options,y=Hf(m)?m:Number.POSITIVE_INFINITY,g=this.chart._animationsDisabled||s||o==="none",x=n+r,v=t.length;let w=n>0&&this.getParsed(n-1);for(let C=0;C<v;++C){const S=t[C],N=g?S:{};if(C<n||C>=x){N.skip=!0;continue}const j=this.getParsed(C),_=pt(j[p]),R=N[h]=i.getPixelForValue(j[h],C),M=N[p]=s||_?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,j,l):j[p],C);N.skip=isNaN(R)||isNaN(M)||_,N.stop=C>0&&Math.abs(j[h]-w[h])>y,b&&(N.parsed=j,N.raw=c.data[C]),f&&(N.options=u||this.resolveDataElementOptions(C,S.active?"active":o)),g||this.updateElement(S,C,N,o),w=j}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,r=n.options&&n.options.borderWidth||0,o=t.data||[];if(!o.length)return r;const s=o[0].size(this.resolveDataElementOptions(0)),i=o[o.length-1].size(this.resolveDataElementOptions(o.length-1));return Math.max(r,s,i)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}ke(N0,"id","line"),ke(N0,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),ke(N0,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class Kp extends bs{constructor(t,n){super(t,n),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const n=this._cachedMeta,r=this.chart,o=r.data.labels||[],s=Yg(n._parsed[t].r,r.options.locale);return{label:o[t]||"",value:s}}parseObjectData(t,n,r,o){return d7.bind(this)(t,n,r,o)}update(t){const n=this._cachedMeta.data;this._updateRadius(),this.updateElements(n,0,n.length,t)}getMinMax(){const t=this._cachedMeta,n={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((r,o)=>{const s=this.getParsed(o).r;!isNaN(s)&&this.chart.getDataVisibility(o)&&(s<n.min&&(n.min=s),s>n.max&&(n.max=s))}),n}_updateRadius(){const t=this.chart,n=t.chartArea,r=t.options,o=Math.min(n.right-n.left,n.bottom-n.top),s=Math.max(o/2,0),i=Math.max(r.cutoutPercentage?s/100*r.cutoutPercentage:1,0),a=(s-i)/t.getVisibleDatasetCount();this.outerRadius=s-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,n,r,o){const s=o==="reset",i=this.chart,l=i.options.animation,c=this._cachedMeta.rScale,u=c.xCenter,f=c.yCenter,h=c.getIndexAngle(0)-.5*_n;let p=h,m;const b=360/this.countVisibleElements();for(m=0;m<n;++m)p+=this._computeAngle(m,o,b);for(m=n;m<n+r;m++){const y=t[m];let g=p,x=p+this._computeAngle(m,o,b),v=i.getDataVisibility(m)?c.getDistanceFromCenterForValue(this.getParsed(m).r):0;p=x,s&&(l.animateScale&&(v=0),l.animateRotate&&(g=x=h));const w={x:u,y:f,innerRadius:0,outerRadius:v,startAngle:g,endAngle:x,options:this.resolveDataElementOptions(m,y.active?"active":o)};this.updateElement(y,m,w,o)}}countVisibleElements(){const t=this._cachedMeta;let n=0;return t.data.forEach((r,o)=>{!isNaN(this.getParsed(o).r)&&this.chart.getDataVisibility(o)&&n++}),n}_computeAngle(t,n,r){return this.chart.getDataVisibility(t)?qs(this.resolveDataElementOptions(t,n).angle||r):0}}ke(Kp,"id","polarArea"),ke(Kp,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),ke(Kp,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data;if(n.labels.length&&n.datasets.length){const{labels:{pointStyle:r,color:o}}=t.legend.options;return n.labels.map((s,i)=>{const l=t.getDatasetMeta(0).controller.getStyle(i);return{text:s,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:o,lineWidth:l.borderWidth,pointStyle:r,hidden:!t.getDataVisibility(i),index:i}})}return[]}},onClick(t,n,r){r.chart.toggleDataVisibility(n.index),r.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class lN extends Hc{}ke(lN,"id","pie"),ke(lN,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});class k0 extends bs{getLabelAndValue(t){const n=this._cachedMeta.vScale,r=this.getParsed(t);return{label:n.getLabels()[t],value:""+n.getLabelForValue(r[n.axis])}}parseObjectData(t,n,r,o){return d7.bind(this)(t,n,r,o)}update(t){const n=this._cachedMeta,r=n.dataset,o=n.data||[],s=n.iScale.getLabels();if(r.points=o,t!=="resize"){const i=this.resolveDatasetElementOptions(t);this.options.showLine||(i.borderWidth=0);const a={_loop:!0,_fullLoop:s.length===o.length,options:i};this.updateElement(r,void 0,a,t)}this.updateElements(o,0,o.length,t)}updateElements(t,n,r,o){const s=this._cachedMeta.rScale,i=o==="reset";for(let a=n;a<n+r;a++){const l=t[a],c=this.resolveDataElementOptions(a,l.active?"active":o),u=s.getPointPositionForValue(a,this.getParsed(a).r),f=i?s.xCenter:u.x,h=i?s.yCenter:u.y,p={x:f,y:h,angle:u.angle,skip:isNaN(f)||isNaN(h),options:c};this.updateElement(l,a,p,o)}}}ke(k0,"id","radar"),ke(k0,"defaults",{datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}}),ke(k0,"overrides",{aspectRatio:1,scales:{r:{type:"radialLinear"}}});class _0 extends bs{getLabelAndValue(t){const n=this._cachedMeta,r=this.chart.data.labels||[],{xScale:o,yScale:s}=n,i=this.getParsed(t),a=o.getLabelForValue(i.x),l=s.getLabelForValue(i.y);return{label:r[t]||"",value:"("+a+", "+l+")"}}update(t){const n=this._cachedMeta,{data:r=[]}=n,o=this.chart._animationsDisabled;let{start:s,count:i}=n7(n,r,o);if(this._drawStart=s,this._drawCount=i,r7(n)&&(s=0,i=r.length),this.options.showLine){this.datasetElementType||this.addElements();const{dataset:a,_dataset:l}=n;a._chart=this.chart,a._datasetIndex=this.index,a._decimated=!!l._decimated,a.points=r;const c=this.resolveDatasetElementOptions(t);c.segment=this.options.segment,this.updateElement(a,void 0,{animated:!o,options:c},t)}else this.datasetElementType&&(delete n.dataset,this.datasetElementType=!1);this.updateElements(r,s,i,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,n,r,o){const s=o==="reset",{iScale:i,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,u=this.resolveDataElementOptions(n,o),f=this.getSharedOptions(u),h=this.includeOptions(o,f),p=i.axis,m=a.axis,{spanGaps:b,segment:y}=this.options,g=Hf(b)?b:Number.POSITIVE_INFINITY,x=this.chart._animationsDisabled||s||o==="none";let v=n>0&&this.getParsed(n-1);for(let w=n;w<n+r;++w){const C=t[w],S=this.getParsed(w),N=x?C:{},j=pt(S[m]),_=N[p]=i.getPixelForValue(S[p],w),R=N[m]=s||j?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,S,l):S[m],w);N.skip=isNaN(_)||isNaN(R)||j,N.stop=w>0&&Math.abs(S[p]-v[p])>g,y&&(N.parsed=S,N.raw=c.data[w]),h&&(N.options=f||this.resolveDataElementOptions(w,C.active?"active":o)),x||this.updateElement(C,w,N,o),v=S}this.updateSharedOptions(f,o,u)}getMaxOverflow(){const t=this._cachedMeta,n=t.data||[];if(!this.options.showLine){let a=0;for(let l=n.length-1;l>=0;--l)a=Math.max(a,n[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}const r=t.dataset,o=r.options&&r.options.borderWidth||0;if(!n.length)return o;const s=n[0].size(this.resolveDataElementOptions(0)),i=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(o,s,i)/2}}ke(_0,"id","scatter"),ke(_0,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),ke(_0,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});var Kge=Object.freeze({__proto__:null,BarController:gu,BubbleController:E0,DoughnutController:Hc,LineController:N0,PieController:lN,PolarAreaController:Kp,RadarController:k0,ScatterController:_0});function Sc(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class lR{constructor(t){ke(this,"options");this.options=t||{}}static override(t){Object.assign(lR.prototype,t)}init(){}formats(){return Sc()}parse(){return Sc()}format(){return Sc()}add(){return Sc()}diff(){return Sc()}startOf(){return Sc()}endOf(){return Sc()}}var Xge={_date:lR};function Qge(e,t,n,r){const{controller:o,data:s,_sorted:i}=e,a=o._cachedMeta.iScale,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&i&&s.length){const c=a._reversePixels?wme:ja;if(r){if(o._sharedOptions){const u=s[0],f=typeof u.getRange=="function"&&u.getRange(t);if(f){const h=c(s,t,n-f),p=c(s,t,n+f);return{lo:h.lo,hi:p.hi}}}}else{const u=c(s,t,n);if(l){const{vScale:f}=o._cachedMeta,{_parsed:h}=e,p=h.slice(0,u.lo+1).reverse().findIndex(b=>!pt(b[f.axis]));u.lo-=Math.max(0,p);const m=h.slice(u.hi).findIndex(b=>!pt(b[f.axis]));u.hi+=Math.max(0,m)}return u}}return{lo:0,hi:s.length-1}}function _w(e,t,n,r,o){const s=e.getSortedVisibleDatasetMetas(),i=n[t];for(let a=0,l=s.length;a<l;++a){const{index:c,data:u}=s[a],{lo:f,hi:h}=Qge(s[a],t,i,o);for(let p=f;p<=h;++p){const m=u[p];m.skip||r(m,c,p)}}}function Jge(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(r,o){const s=t?Math.abs(r.x-o.x):0,i=n?Math.abs(r.y-o.y):0;return Math.sqrt(Math.pow(s,2)+Math.pow(i,2))}}function lC(e,t,n,r,o){const s=[];return!o&&!e.isPointInArea(t)||_w(e,n,t,function(a,l,c){!o&&!Ra(a,e.chartArea,0)||a.inRange(t.x,t.y,r)&&s.push({element:a,datasetIndex:l,index:c})},!0),s}function ebe(e,t,n,r){let o=[];function s(i,a,l){const{startAngle:c,endAngle:u}=i.getProps(["startAngle","endAngle"],r),{angle:f}=X9(i,{x:t.x,y:t.y});Tm(f,c,u)&&o.push({element:i,datasetIndex:a,index:l})}return _w(e,n,t,s),o}function tbe(e,t,n,r,o,s){let i=[];const a=Jge(n);let l=Number.POSITIVE_INFINITY;function c(u,f,h){const p=u.inRange(t.x,t.y,o);if(r&&!p)return;const m=u.getCenterPoint(o);if(!(!!s||e.isPointInArea(m))&&!p)return;const y=a(t,m);y<l?(i=[{element:u,datasetIndex:f,index:h}],l=y):y===l&&i.push({element:u,datasetIndex:f,index:h})}return _w(e,n,t,c),i}function cC(e,t,n,r,o,s){return!s&&!e.isPointInArea(t)?[]:n==="r"&&!r?ebe(e,t,n,o):tbe(e,t,n,r,o,s)}function dI(e,t,n,r,o){const s=[],i=n==="x"?"inXRange":"inYRange";let a=!1;return _w(e,n,t,(l,c,u)=>{l[i]&&l[i](t[n],o)&&(s.push({element:l,datasetIndex:c,index:u}),a=a||l.inRange(t.x,t.y,o))}),r&&!a?[]:s}var nbe={modes:{index(e,t,n,r){const o=Rc(t,e),s=n.axis||"x",i=n.includeInvisible||!1,a=n.intersect?lC(e,o,s,r,i):cC(e,o,s,!1,r,i),l=[];return a.length?(e.getSortedVisibleDatasetMetas().forEach(c=>{const u=a[0].index,f=c.data[u];f&&!f.skip&&l.push({element:f,datasetIndex:c.index,index:u})}),l):[]},dataset(e,t,n,r){const o=Rc(t,e),s=n.axis||"xy",i=n.includeInvisible||!1;let a=n.intersect?lC(e,o,s,r,i):cC(e,o,s,!1,r,i);if(a.length>0){const l=a[0].datasetIndex,c=e.getDatasetMeta(l).data;a=[];for(let u=0;u<c.length;++u)a.push({element:c[u],datasetIndex:l,index:u})}return a},point(e,t,n,r){const o=Rc(t,e),s=n.axis||"xy",i=n.includeInvisible||!1;return lC(e,o,s,r,i)},nearest(e,t,n,r){const o=Rc(t,e),s=n.axis||"xy",i=n.includeInvisible||!1;return cC(e,o,s,n.intersect,r,i)},x(e,t,n,r){const o=Rc(t,e);return dI(e,o,"x",n.intersect,r)},y(e,t,n,r){const o=Rc(t,e);return dI(e,o,"y",n.intersect,r)}}};const w7=["left","top","right","bottom"];function Qh(e,t){return e.filter(n=>n.pos===t)}function fI(e,t){return e.filter(n=>w7.indexOf(n.pos)===-1&&n.box.axis===t)}function Jh(e,t){return e.sort((n,r)=>{const o=t?r:n,s=t?n:r;return o.weight===s.weight?o.index-s.index:o.weight-s.weight})}function rbe(e){const t=[];let n,r,o,s,i,a;for(n=0,r=(e||[]).length;n<r;++n)o=e[n],{position:s,options:{stack:i,stackWeight:a=1}}=o,t.push({index:n,box:o,pos:s,horizontal:o.isHorizontal(),weight:o.weight,stack:i&&s+i,stackWeight:a});return t}function obe(e){const t={};for(const n of e){const{stack:r,pos:o,stackWeight:s}=n;if(!r||!w7.includes(o))continue;const i=t[r]||(t[r]={count:0,placed:0,weight:0,size:0});i.count++,i.weight+=s}return t}function sbe(e,t){const n=obe(e),{vBoxMaxWidth:r,hBoxMaxHeight:o}=t;let s,i,a;for(s=0,i=e.length;s<i;++s){a=e[s];const{fullSize:l}=a.box,c=n[a.stack],u=c&&a.stackWeight/c.weight;a.horizontal?(a.width=u?u*r:l&&t.availableWidth,a.height=o):(a.width=r,a.height=u?u*o:l&&t.availableHeight)}return n}function ibe(e){const t=rbe(e),n=Jh(t.filter(c=>c.box.fullSize),!0),r=Jh(Qh(t,"left"),!0),o=Jh(Qh(t,"right")),s=Jh(Qh(t,"top"),!0),i=Jh(Qh(t,"bottom")),a=fI(t,"x"),l=fI(t,"y");return{fullSize:n,leftAndTop:r.concat(s),rightAndBottom:o.concat(l).concat(i).concat(a),chartArea:Qh(t,"chartArea"),vertical:r.concat(o).concat(l),horizontal:s.concat(i).concat(a)}}function hI(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function S7(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function abe(e,t,n,r){const{pos:o,box:s}=n,i=e.maxPadding;if(!_t(o)){n.size&&(e[o]-=n.size);const f=r[n.stack]||{size:0,count:1};f.size=Math.max(f.size,n.horizontal?s.height:s.width),n.size=f.size/f.count,e[o]+=n.size}s.getPadding&&S7(i,s.getPadding());const a=Math.max(0,t.outerWidth-hI(i,e,"left","right")),l=Math.max(0,t.outerHeight-hI(i,e,"top","bottom")),c=a!==e.w,u=l!==e.h;return e.w=a,e.h=l,n.horizontal?{same:c,other:u}:{same:u,other:c}}function lbe(e){const t=e.maxPadding;function n(r){const o=Math.max(t[r]-e[r],0);return e[r]+=o,o}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function cbe(e,t){const n=t.maxPadding;function r(o){const s={left:0,top:0,right:0,bottom:0};return o.forEach(i=>{s[i]=Math.max(t[i],n[i])}),s}return r(e?["left","right"]:["top","bottom"])}function yp(e,t,n,r){const o=[];let s,i,a,l,c,u;for(s=0,i=e.length,c=0;s<i;++s){a=e[s],l=a.box,l.update(a.width||t.w,a.height||t.h,cbe(a.horizontal,t));const{same:f,other:h}=abe(t,n,a,r);c|=f&&o.length,u=u||h,l.fullSize||o.push(a)}return c&&yp(o,t,n,r)||u}function gy(e,t,n,r,o){e.top=n,e.left=t,e.right=t+r,e.bottom=n+o,e.width=r,e.height=o}function pI(e,t,n,r){const o=n.padding;let{x:s,y:i}=t;for(const a of e){const l=a.box,c=r[a.stack]||{placed:0,weight:1},u=a.stackWeight/c.weight||1;if(a.horizontal){const f=t.w*u,h=c.size||l.height;Dm(c.start)&&(i=c.start),l.fullSize?gy(l,o.left,i,n.outerWidth-o.right-o.left,h):gy(l,t.left+c.placed,i,f,h),c.start=i,c.placed+=f,i=l.bottom}else{const f=t.h*u,h=c.size||l.width;Dm(c.start)&&(s=c.start),l.fullSize?gy(l,s,o.top,h,n.outerHeight-o.bottom-o.top):gy(l,s,t.top+c.placed,h,f),c.start=s,c.placed+=f,s=l.right}}t.x=s,t.y=i}var Br={addBox(e,t){e.boxes||(e.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(n){t.draw(n)}}]},e.boxes.push(t)},removeBox(e,t){const n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,r){if(!e)return;const o=Mr(e.options.layout.padding),s=Math.max(t-o.width,0),i=Math.max(n-o.height,0),a=ibe(e.boxes),l=a.vertical,c=a.horizontal;Xt(e.boxes,b=>{typeof b.beforeLayout=="function"&&b.beforeLayout()});const u=l.reduce((b,y)=>y.box.options&&y.box.options.display===!1?b:b+1,0)||1,f=Object.freeze({outerWidth:t,outerHeight:n,padding:o,availableWidth:s,availableHeight:i,vBoxMaxWidth:s/2/u,hBoxMaxHeight:i/2}),h=Object.assign({},o);S7(h,Mr(r));const p=Object.assign({maxPadding:h,w:s,h:i,x:o.left,y:o.top},o),m=sbe(l.concat(c),f);yp(a.fullSize,p,f,m),yp(l,p,f,m),yp(c,p,f,m)&&yp(l,p,f,m),lbe(p),pI(a.leftAndTop,p,f,m),p.x+=p.w,p.y+=p.h,pI(a.rightAndBottom,p,f,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},Xt(a.chartArea,b=>{const y=b.box;Object.assign(y,e.chartArea),y.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}};class C7{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,r){}removeEventListener(t,n,r){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,r,o){return n=Math.max(0,n||t.width),r=r||t.height,{width:n,height:Math.max(0,o?Math.floor(n/o):r)}}isAttached(t){return!0}updateConfig(t){}}class ube extends C7{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const j0="$chartjs",dbe={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},mI=e=>e===null||e==="";function fbe(e,t){const n=e.style,r=e.getAttribute("height"),o=e.getAttribute("width");if(e[j0]={initial:{height:r,width:o,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",mI(o)){const s=QA(e,"width");s!==void 0&&(e.width=s)}if(mI(r))if(e.style.height==="")e.height=e.width/(t||2);else{const s=QA(e,"height");s!==void 0&&(e.height=s)}return e}const E7=pge?{passive:!0}:!1;function hbe(e,t,n){e&&e.addEventListener(t,n,E7)}function pbe(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,E7)}function mbe(e,t){const n=dbe[e.type]||e.type,{x:r,y:o}=Rc(e,t);return{type:n,chart:t,native:e,x:r!==void 0?r:null,y:o!==void 0?o:null}}function Sx(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function gbe(e,t,n){const r=e.canvas,o=new MutationObserver(s=>{let i=!1;for(const a of s)i=i||Sx(a.addedNodes,r),i=i&&!Sx(a.removedNodes,r);i&&n()});return o.observe(document,{childList:!0,subtree:!0}),o}function bbe(e,t,n){const r=e.canvas,o=new MutationObserver(s=>{let i=!1;for(const a of s)i=i||Sx(a.removedNodes,r),i=i&&!Sx(a.addedNodes,r);i&&n()});return o.observe(document,{childList:!0,subtree:!0}),o}const Am=new Map;let gI=0;function N7(){const e=window.devicePixelRatio;e!==gI&&(gI=e,Am.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function ybe(e,t){Am.size||window.addEventListener("resize",N7),Am.set(e,t)}function xbe(e){Am.delete(e),Am.size||window.removeEventListener("resize",N7)}function vbe(e,t,n){const r=e.canvas,o=r&&aR(r);if(!o)return;const s=t7((a,l)=>{const c=o.clientWidth;n(a,l),c<o.clientWidth&&n()},window),i=new ResizeObserver(a=>{const l=a[0],c=l.contentRect.width,u=l.contentRect.height;c===0&&u===0||s(c,u)});return i.observe(o),ybe(e,s),i}function uC(e,t,n){n&&n.disconnect(),t==="resize"&&xbe(e)}function wbe(e,t,n){const r=e.canvas,o=t7(s=>{e.ctx!==null&&n(mbe(s,e))},e);return hbe(r,t,o),o}class Sbe extends C7{acquireContext(t,n){const r=t&&t.getContext&&t.getContext("2d");return r&&r.canvas===t?(fbe(t,n),r):null}releaseContext(t){const n=t.canvas;if(!n[j0])return!1;const r=n[j0].initial;["height","width"].forEach(s=>{const i=r[s];pt(i)?n.removeAttribute(s):n.setAttribute(s,i)});const o=r.style||{};return Object.keys(o).forEach(s=>{n.style[s]=o[s]}),n.width=n.width,delete n[j0],!0}addEventListener(t,n,r){this.removeEventListener(t,n);const o=t.$proxies||(t.$proxies={}),i={attach:gbe,detach:bbe,resize:vbe}[n]||wbe;o[n]=i(t,n,r)}removeEventListener(t,n){const r=t.$proxies||(t.$proxies={}),o=r[n];if(!o)return;({attach:uC,detach:uC,resize:uC}[n]||pbe)(t,n,o),r[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,r,o){return hge(t,n,r,o)}isAttached(t){const n=t&&aR(t);return!!(n&&n.isConnected)}}function Cbe(e){return!iR()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?ube:Sbe}var p0;let sa=(p0=class{constructor(){ke(this,"x");ke(this,"y");ke(this,"active",!1);ke(this,"options");ke(this,"$animations")}tooltipPosition(t){const{x:n,y:r}=this.getProps(["x","y"],t);return{x:n,y:r}}hasValue(){return Hf(this.x)&&Hf(this.y)}getProps(t,n){const r=this.$animations;if(!n||!r)return this;const o={};return t.forEach(s=>{o[s]=r[s]&&r[s].active()?r[s]._to:this[s]}),o}},ke(p0,"defaults",{}),ke(p0,"defaultRoutes"),p0);function Ebe(e,t){const n=e.options.ticks,r=Nbe(e),o=Math.min(n.maxTicksLimit||r,r),s=n.major.enabled?_be(t):[],i=s.length,a=s[0],l=s[i-1],c=[];if(i>o)return jbe(t,c,s,i/o),c;const u=kbe(s,t,o);if(i>0){let f,h;const p=i>1?Math.round((l-a)/(i-1)):null;for(by(t,c,u,pt(p)?0:a-p,a),f=0,h=i-1;f<h;f++)by(t,c,u,s[f],s[f+1]);return by(t,c,u,l,pt(p)?t.length:l+p),c}return by(t,c,u),c}function Nbe(e){const t=e.options.offset,n=e._tickSize(),r=e._length/n+(t?0:1),o=e._maxLength/n;return Math.floor(Math.min(r,o))}function kbe(e,t,n){const r=Rbe(e),o=t.length/n;if(!r)return Math.max(o,1);const s=gme(r);for(let i=0,a=s.length-1;i<a;i++){const l=s[i];if(l>o)return l}return Math.max(o,1)}function _be(e){const t=[];let n,r;for(n=0,r=e.length;n<r;n++)e[n].major&&t.push(n);return t}function jbe(e,t,n,r){let o=0,s=n[0],i;for(r=Math.ceil(r),i=0;i<e.length;i++)i===s&&(t.push(e[i]),o++,s=n[o*r])}function by(e,t,n,r,o){const s=rt(r,0),i=Math.min(rt(o,e.length),e.length);let a=0,l,c,u;for(n=Math.ceil(n),o&&(l=o-r,n=l/Math.floor(l/n)),u=s;u<0;)a++,u=Math.round(s+a*n);for(c=Math.max(s,0);c<i;c++)c===u&&(t.push(e[c]),a++,u=Math.round(s+a*n))}function Rbe(e){const t=e.length;let n,r;if(t<2)return!1;for(r=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==r)return!1;return r}const Mbe=e=>e==="left"?"right":e==="right"?"left":e,bI=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,yI=(e,t)=>Math.min(t||e,e);function xI(e,t){const n=[],r=e.length/t,o=e.length;let s=0;for(;s<o;s+=r)n.push(e[Math.floor(s)]);return n}function Dbe(e,t,n){const r=e.ticks.length,o=Math.min(t,r-1),s=e._startPixel,i=e._endPixel,a=1e-6;let l=e.getPixelForTick(o),c;if(!(n&&(r===1?c=Math.max(l-s,i-l):t===0?c=(e.getPixelForTick(1)-l)/2:c=(l-e.getPixelForTick(o-1))/2,l+=o<t?c:-c,l<s-a||l>i+a)))return l}function Tbe(e,t){Xt(e,n=>{const r=n.gc,o=r.length/2;let s;if(o>t){for(s=0;s<o;++s)delete n.data[r[s]];r.splice(0,o)}})}function ep(e){return e.drawTicks?e.tickLength:0}function vI(e,t){if(!e.display)return 0;const n=ar(e.font,t),r=Mr(e.padding);return(Cn(e.text)?e.text.length:1)*n.lineHeight+r.height}function Pbe(e,t){return ac(e,{scale:t,type:"scale"})}function Abe(e,t,n){return ac(e,{tick:n,index:t,type:"tick"})}function Ibe(e,t,n){let r=eR(e);return(n&&t!=="right"||!n&&t==="right")&&(r=Mbe(r)),r}function Obe(e,t,n,r){const{top:o,left:s,bottom:i,right:a,chart:l}=e,{chartArea:c,scales:u}=l;let f=0,h,p,m;const b=i-o,y=a-s;if(e.isHorizontal()){if(p=Fr(r,s,a),_t(n)){const g=Object.keys(n)[0],x=n[g];m=u[g].getPixelForValue(x)+b-t}else n==="center"?m=(c.bottom+c.top)/2+b-t:m=bI(e,n,t);h=a-s}else{if(_t(n)){const g=Object.keys(n)[0],x=n[g];p=u[g].getPixelForValue(x)-y+t}else n==="center"?p=(c.left+c.right)/2-y+t:p=bI(e,n,t);m=Fr(r,i,o),f=n==="left"?-Qn:Qn}return{titleX:p,titleY:m,maxWidth:h,rotation:f}}class lc extends sa{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,n){return t}getUserBounds(){let{_userMin:t,_userMax:n,_suggestedMin:r,_suggestedMax:o}=this;return t=Po(t,Number.POSITIVE_INFINITY),n=Po(n,Number.NEGATIVE_INFINITY),r=Po(r,Number.POSITIVE_INFINITY),o=Po(o,Number.NEGATIVE_INFINITY),{min:Po(t,r),max:Po(n,o),minDefined:Wn(t),maxDefined:Wn(n)}}getMinMax(t){let{min:n,max:r,minDefined:o,maxDefined:s}=this.getUserBounds(),i;if(o&&s)return{min:n,max:r};const a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;l<c;++l)i=a[l].controller.getMinMax(this,t),o||(n=Math.min(n,i.min)),s||(r=Math.max(r,i.max));return n=s&&n>r?r:n,r=o&&n>r?n:r,{min:Po(n,Po(r,n)),max:Po(r,Po(n,r))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){sn(this.options.beforeUpdate,[this])}update(t,n,r){const{beginAtZero:o,grace:s,ticks:i}=this.options,a=i.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=r=Object.assign({left:0,right:0,top:0,bottom:0},r),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+r.left+r.right:this.height+r.top+r.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Wme(this,s,o),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a<this.ticks.length;this._convertTicksToLabels(l?xI(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),i.display&&(i.autoSkip||i.source==="auto")&&(this.ticks=Ebe(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),l&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,n,r;this.isHorizontal()?(n=this.left,r=this.right):(n=this.top,r=this.bottom,t=!t),this._startPixel=n,this._endPixel=r,this._reversePixels=t,this._length=r-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){sn(this.options.afterUpdate,[this])}beforeSetDimensions(){sn(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){sn(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),sn(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){sn(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let r,o,s;for(r=0,o=t.length;r<o;r++)s=t[r],s.label=sn(n.callback,[s.value,r,t],this)}afterTickToLabelConversion(){sn(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){sn(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,r=yI(this.ticks.length,t.ticks.maxTicksLimit),o=n.minRotation||0,s=n.maxRotation;let i=o,a,l,c;if(!this._isVisible()||!n.display||o>=s||r<=1||!this.isHorizontal()){this.labelRotation=o;return}const u=this._getLabelSizes(),f=u.widest.width,h=u.highest.height,p=wr(this.chart.width-f,0,this.maxWidth);a=t.offset?this.maxWidth/r:p/(r-1),f+6>a&&(a=p/(r-(t.offset?.5:1)),l=this.maxHeight-ep(t.grid)-n.padding-vI(t.title,this.chart.options.font),c=Math.sqrt(f*f+h*h),i=Qj(Math.min(Math.asin(wr((u.highest.height+6)/a,-1,1)),Math.asin(wr(l/c,-1,1))-Math.asin(wr(h/c,-1,1)))),i=Math.max(o,Math.min(s,i))),this.labelRotation=i}afterCalculateLabelRotation(){sn(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){sn(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:r,title:o,grid:s}}=this,i=this._isVisible(),a=this.isHorizontal();if(i){const l=vI(o,n.options.font);if(a?(t.width=this.maxWidth,t.height=ep(s)+l):(t.height=this.maxHeight,t.width=ep(s)+l),r.display&&this.ticks.length){const{first:c,last:u,widest:f,highest:h}=this._getLabelSizes(),p=r.padding*2,m=qs(this.labelRotation),b=Math.cos(m),y=Math.sin(m);if(a){const g=r.mirror?0:y*f.width+b*h.height;t.height=Math.min(this.maxHeight,t.height+g+p)}else{const g=r.mirror?0:b*f.width+y*h.height;t.width=Math.min(this.maxWidth,t.width+g+p)}this._calculatePadding(c,u,y,b)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,n,r,o){const{ticks:{align:s,padding:i},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const u=this.getPixelForTick(0)-this.left,f=this.right-this.getPixelForTick(this.ticks.length-1);let h=0,p=0;l?c?(h=o*t.width,p=r*n.height):(h=r*t.height,p=o*n.width):s==="start"?p=n.width:s==="end"?h=t.width:s!=="inner"&&(h=t.width/2,p=n.width/2),this.paddingLeft=Math.max((h-u+i)*this.width/(this.width-u),0),this.paddingRight=Math.max((p-f+i)*this.width/(this.width-f),0)}else{let u=n.height/2,f=t.height/2;s==="start"?(u=0,f=t.height):s==="end"&&(u=n.height,f=0),this.paddingTop=u+i,this.paddingBottom=f+i}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){sn(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:n}=this.options;return n==="top"||n==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let n,r;for(n=0,r=t.length;n<r;n++)pt(t[n].label)&&(t.splice(n,1),r--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let r=this.ticks;n<r.length&&(r=xI(r,n)),this._labelSizes=t=this._computeLabelSizes(r,r.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,r){const{ctx:o,_longestTextCache:s}=this,i=[],a=[],l=Math.floor(n/yI(n,r));let c=0,u=0,f,h,p,m,b,y,g,x,v,w,C;for(f=0;f<n;f+=l){if(m=t[f].label,b=this._resolveTickFontOptions(f),o.font=y=b.string,g=s[y]=s[y]||{data:{},gc:[]},x=b.lineHeight,v=w=0,!pt(m)&&!Cn(m))v=xx(o,g.data,g.gc,v,m),w=x;else if(Cn(m))for(h=0,p=m.length;h<p;++h)C=m[h],!pt(C)&&!Cn(C)&&(v=xx(o,g.data,g.gc,v,C),w+=x);i.push(v),a.push(w),c=Math.max(v,c),u=Math.max(w,u)}Tbe(s,n);const S=i.indexOf(c),N=a.indexOf(u),j=_=>({width:i[_]||0,height:a[_]||0});return{first:j(0),last:j(n-1),widest:j(S),highest:j(N),widths:i,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,n){return NaN}getValueForPixel(t){}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const n=this._startPixel+t*this._length;return vme(this._alignToPixels?wc(this.chart,n,0):n)}getDecimalForPixel(t){const n=(t-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:n}=this;return t<0&&n<0?n:t>0&&n>0?t:0}getContext(t){const n=this.ticks||[];if(t>=0&&t<n.length){const r=n[t];return r.$context||(r.$context=Abe(this.getContext(),t,r))}return this.$context||(this.$context=Pbe(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=qs(this.labelRotation),r=Math.abs(Math.cos(n)),o=Math.abs(Math.sin(n)),s=this._getLabelSizes(),i=t.autoSkipPadding||0,a=s?s.widest.width+i:0,l=s?s.highest.height+i:0;return this.isHorizontal()?l*r>a*o?a/r:l/o:l*o<a*r?l/r:a/o}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,r=this.chart,o=this.options,{grid:s,position:i,border:a}=o,l=s.offset,c=this.isHorizontal(),f=this.ticks.length+(l?1:0),h=ep(s),p=[],m=a.setContext(this.getContext()),b=m.display?m.width:0,y=b/2,g=function($){return wc(r,$,b)};let x,v,w,C,S,N,j,_,R,M,T,O;if(i==="top")x=g(this.bottom),N=this.bottom-h,_=x-y,M=g(t.top)+y,O=t.bottom;else if(i==="bottom")x=g(this.top),M=t.top,O=g(t.bottom)-y,N=x+y,_=this.top+h;else if(i==="left")x=g(this.right),S=this.right-h,j=x-y,R=g(t.left)+y,T=t.right;else if(i==="right")x=g(this.left),R=t.left,T=g(t.right)-y,S=x+y,j=this.left+h;else if(n==="x"){if(i==="center")x=g((t.top+t.bottom)/2+.5);else if(_t(i)){const $=Object.keys(i)[0],H=i[$];x=g(this.chart.scales[$].getPixelForValue(H))}M=t.top,O=t.bottom,N=x+y,_=N+h}else if(n==="y"){if(i==="center")x=g((t.left+t.right)/2);else if(_t(i)){const $=Object.keys(i)[0],H=i[$];x=g(this.chart.scales[$].getPixelForValue(H))}S=x-y,j=S-h,R=t.left,T=t.right}const I=rt(o.ticks.maxTicksLimit,f),A=Math.max(1,Math.ceil(f/I));for(v=0;v<f;v+=A){const $=this.getContext(v),H=s.setContext($),U=a.setContext($),B=H.lineWidth,P=H.color,z=U.dash||[],L=U.dashOffset,D=H.tickWidth,W=H.tickColor,G=H.tickBorderDash||[],Z=H.tickBorderDashOffset;w=Dbe(this,v,l),w!==void 0&&(C=wc(r,w,B),c?S=j=R=T=C:N=_=M=O=C,p.push({tx1:S,ty1:N,tx2:j,ty2:_,x1:R,y1:M,x2:T,y2:O,width:B,color:P,borderDash:z,borderDashOffset:L,tickWidth:D,tickColor:W,tickBorderDash:G,tickBorderDashOffset:Z}))}return this._ticksLength=f,this._borderValue=x,p}_computeLabelItems(t){const n=this.axis,r=this.options,{position:o,ticks:s}=r,i=this.isHorizontal(),a=this.ticks,{align:l,crossAlign:c,padding:u,mirror:f}=s,h=ep(r.grid),p=h+u,m=f?-u:p,b=-qs(this.labelRotation),y=[];let g,x,v,w,C,S,N,j,_,R,M,T,O="middle";if(o==="top")S=this.bottom-m,N=this._getXAxisLabelAlignment();else if(o==="bottom")S=this.top+m,N=this._getXAxisLabelAlignment();else if(o==="left"){const A=this._getYAxisLabelAlignment(h);N=A.textAlign,C=A.x}else if(o==="right"){const A=this._getYAxisLabelAlignment(h);N=A.textAlign,C=A.x}else if(n==="x"){if(o==="center")S=(t.top+t.bottom)/2+p;else if(_t(o)){const A=Object.keys(o)[0],$=o[A];S=this.chart.scales[A].getPixelForValue($)+p}N=this._getXAxisLabelAlignment()}else if(n==="y"){if(o==="center")C=(t.left+t.right)/2-p;else if(_t(o)){const A=Object.keys(o)[0],$=o[A];C=this.chart.scales[A].getPixelForValue($)}N=this._getYAxisLabelAlignment(h).textAlign}n==="y"&&(l==="start"?O="top":l==="end"&&(O="bottom"));const I=this._getLabelSizes();for(g=0,x=a.length;g<x;++g){v=a[g],w=v.label;const A=s.setContext(this.getContext(g));j=this.getPixelForTick(g)+s.labelOffset,_=this._resolveTickFontOptions(g),R=_.lineHeight,M=Cn(w)?w.length:1;const $=M/2,H=A.color,U=A.textStrokeColor,B=A.textStrokeWidth;let P=N;i?(C=j,N==="inner"&&(g===x-1?P=this.options.reverse?"left":"right":g===0?P=this.options.reverse?"right":"left":P="center"),o==="top"?c==="near"||b!==0?T=-M*R+R/2:c==="center"?T=-I.highest.height/2-$*R+R:T=-I.highest.height+R/2:c==="near"||b!==0?T=R/2:c==="center"?T=I.highest.height/2-$*R:T=I.highest.height-M*R,f&&(T*=-1),b!==0&&!A.showLabelBackdrop&&(C+=R/2*Math.sin(b))):(S=j,T=(1-M)*R/2);let z;if(A.showLabelBackdrop){const L=Mr(A.backdropPadding),D=I.heights[g],W=I.widths[g];let G=T-L.top,Z=0-L.left;switch(O){case"middle":G-=D/2;break;case"bottom":G-=D;break}switch(N){case"center":Z-=W/2;break;case"right":Z-=W;break;case"inner":g===x-1?Z-=W:g>0&&(Z-=W/2);break}z={left:Z,top:G,width:W+L.width,height:D+L.height,color:A.backdropColor}}y.push({label:w,font:_,textOffset:T,options:{rotation:b,color:H,strokeColor:U,strokeWidth:B,textAlign:P,textBaseline:O,translation:[C,S],backdrop:z}})}return y}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-qs(this.labelRotation))return t==="top"?"left":"right";let o="center";return n.align==="start"?o="left":n.align==="end"?o="right":n.align==="inner"&&(o="inner"),o}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:r,mirror:o,padding:s}}=this.options,i=this._getLabelSizes(),a=t+s,l=i.widest.width;let c,u;return n==="left"?o?(u=this.right+s,r==="near"?c="left":r==="center"?(c="center",u+=l/2):(c="right",u+=l)):(u=this.right-a,r==="near"?c="right":r==="center"?(c="center",u-=l/2):(c="left",u=this.left)):n==="right"?o?(u=this.left+s,r==="near"?c="right":r==="center"?(c="center",u-=l/2):(c="left",u-=l)):(u=this.left+a,r==="near"?c="left":r==="center"?(c="center",u+=l/2):(c="right",u=this.right)):c="right",{textAlign:c,x:u}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:n},left:r,top:o,width:s,height:i}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(r,o,s,i),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const o=this.ticks.findIndex(s=>s.value===t);return o>=0?n.setContext(this.getContext(o)).lineWidth:0}drawGrid(t){const n=this.options.grid,r=this.ctx,o=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let s,i;const a=(l,c,u)=>{!u.width||!u.color||(r.save(),r.lineWidth=u.width,r.strokeStyle=u.color,r.setLineDash(u.borderDash||[]),r.lineDashOffset=u.borderDashOffset,r.beginPath(),r.moveTo(l.x,l.y),r.lineTo(c.x,c.y),r.stroke(),r.restore())};if(n.display)for(s=0,i=o.length;s<i;++s){const l=o[s];n.drawOnChartArea&&a({x:l.x1,y:l.y1},{x:l.x2,y:l.y2},l),n.drawTicks&&a({x:l.tx1,y:l.ty1},{x:l.tx2,y:l.ty2},{color:l.tickColor,width:l.tickWidth,borderDash:l.tickBorderDash,borderDashOffset:l.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:n,options:{border:r,grid:o}}=this,s=r.setContext(this.getContext()),i=r.display?s.width:0;if(!i)return;const a=o.setContext(this.getContext(0)).lineWidth,l=this._borderValue;let c,u,f,h;this.isHorizontal()?(c=wc(t,this.left,i)-i/2,u=wc(t,this.right,a)+a/2,f=h=l):(f=wc(t,this.top,i)-i/2,h=wc(t,this.bottom,a)+a/2,c=u=l),n.save(),n.lineWidth=s.width,n.strokeStyle=s.color,n.beginPath(),n.moveTo(c,f),n.lineTo(u,h),n.stroke(),n.restore()}drawLabels(t){if(!this.options.ticks.display)return;const r=this.ctx,o=this._computeLabelArea();o&&fu(r,o);const s=this.getLabelItems(t);for(const i of s){const a=i.options,l=i.font,c=i.label,u=i.textOffset;Au(r,c,0,u,l,a)}o&&hu(r)}drawTitle(){const{ctx:t,options:{position:n,title:r,reverse:o}}=this;if(!r.display)return;const s=ar(r.font),i=Mr(r.padding),a=r.align;let l=s.lineHeight/2;n==="bottom"||n==="center"||_t(n)?(l+=i.bottom,Cn(r.text)&&(l+=s.lineHeight*(r.text.length-1))):l+=i.top;const{titleX:c,titleY:u,maxWidth:f,rotation:h}=Obe(this,l,n,a);Au(t,r.text,0,0,s,{color:r.color,maxWidth:f,rotation:h,textAlign:Ibe(a,n,o),textBaseline:"middle",translation:[c,u]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,n=t.ticks&&t.ticks.z||0,r=rt(t.grid&&t.grid.z,-1),o=rt(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==lc.prototype.draw?[{z:n,draw:s=>{this.draw(s)}}]:[{z:r,draw:s=>{this.drawBackground(),this.drawGrid(s),this.drawTitle()}},{z:o,draw:()=>{this.drawBorder()}},{z:n,draw:s=>{this.drawLabels(s)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),r=this.axis+"AxisID",o=[];let s,i;for(s=0,i=n.length;s<i;++s){const a=n[s];a[r]===this.id&&(!t||a.type===t)&&o.push(a)}return o}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return ar(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class yy{constructor(t,n,r){this.type=t,this.scope=n,this.override=r,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const n=Object.getPrototypeOf(t);let r;Lbe(n)&&(r=this.register(n));const o=this.items,s=t.id,i=this.scope+"."+s;if(!s)throw new Error("class does not have id: "+t);return s in o||(o[s]=t,Fbe(t,i,r),this.override&&kn.override(t.id,t.overrides)),i}get(t){return this.items[t]}unregister(t){const n=this.items,r=t.id,o=this.scope;r in n&&delete n[r],o&&r in kn[o]&&(delete kn[o][r],this.override&&delete Pu[r])}}function Fbe(e,t,n){const r=lr(Object.create(null),[n?kn.get(n):{},kn.get(t),e.defaults]);kn.set(t,r),e.defaultRoutes&&$be(t,e.defaultRoutes),e.descriptors&&kn.describe(t,e.descriptors)}function $be(e,t){Object.keys(t).forEach(n=>{const r=n.split("."),o=r.pop(),s=[e].concat(r).join("."),i=t[n].split("."),a=i.pop(),l=i.join(".");kn.route(s,o,l,a)})}function Lbe(e){return"id"in e&&"defaults"in e}class zbe{constructor(){this.controllers=new yy(bs,"datasets",!0),this.elements=new yy(sa,"elements"),this.plugins=new yy(Object,"plugins"),this.scales=new yy(lc,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,n,r){[...n].forEach(o=>{const s=r||this._getRegistryForType(o);r||s.isForType(o)||s===this.plugins&&o.id?this._exec(t,s,o):Xt(o,i=>{const a=r||this._getRegistryForType(i);this._exec(t,a,i)})})}_exec(t,n,r){const o=Xj(t);sn(r["before"+o],[],r),n[t](r),sn(r["after"+o],[],r)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const r=this._typedRegistries[n];if(r.isForType(t))return r}return this.plugins}_get(t,n,r){const o=n.get(t);if(o===void 0)throw new Error('"'+t+'" is not a registered '+r+".");return o}}var or=new zbe;class Bbe{constructor(){this._init=[]}notify(t,n,r,o){n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install"));const s=o?this._descriptors(t).filter(o):this._descriptors(t),i=this._notify(s,t,n,r);return n==="afterDestroy"&&(this._notify(s,t,"stop"),this._notify(this._init,t,"uninstall")),i}_notify(t,n,r,o){o=o||{};for(const s of t){const i=s.plugin,a=i[r],l=[n,o,s.options];if(sn(a,l,i)===!1&&o.cancelable)return!1}return!0}invalidate(){pt(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const n=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),n}_createDescriptors(t,n){const r=t&&t.config,o=rt(r.options&&r.options.plugins,{}),s=Vbe(r);return o===!1&&!n?[]:Ube(t,s,o,n)}_notifyStateChanges(t){const n=this._oldCache||[],r=this._cache,o=(s,i)=>s.filter(a=>!i.some(l=>a.plugin.id===l.plugin.id));this._notify(o(n,r),t,"stop"),this._notify(o(r,n),t,"start")}}function Vbe(e){const t={},n=[],r=Object.keys(or.plugins.items);for(let s=0;s<r.length;s++)n.push(or.getPlugin(r[s]));const o=e.plugins||[];for(let s=0;s<o.length;s++){const i=o[s];n.indexOf(i)===-1&&(n.push(i),t[i.id]=!0)}return{plugins:n,localIds:t}}function Hbe(e,t){return!t&&e===!1?null:e===!0?{}:e}function Ube(e,{plugins:t,localIds:n},r,o){const s=[],i=e.getContext();for(const a of t){const l=a.id,c=Hbe(r[l],o);c!==null&&s.push({plugin:a,options:Wbe(e.config,{plugin:a,local:n[l]},c,i)})}return s}function Wbe(e,{plugin:t,local:n},r,o){const s=e.pluginScopeKeys(t),i=e.getOptionScopes(r,s);return n&&t.defaults&&i.push(t.defaults),e.createResolver(i,o,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function cN(e,t){const n=kn.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function qbe(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function Gbe(e,t){return e===t?"_index_":"_value_"}function wI(e){if(e==="x"||e==="y"||e==="r")return e}function Ybe(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function uN(e,...t){if(wI(e))return e;for(const n of t){const r=n.axis||Ybe(n.position)||e.length>1&&wI(e[0].toLowerCase());if(r)return r}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function SI(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function Zbe(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(r=>r.xAxisID===e||r.yAxisID===e);if(n.length)return SI(e,"x",n[0])||SI(e,"y",n[0])}return{}}function Kbe(e,t){const n=Pu[e.type]||{scales:{}},r=t.scales||{},o=cN(e.type,t),s=Object.create(null);return Object.keys(r).forEach(i=>{const a=r[i];if(!_t(a))return console.error(`Invalid scale configuration for scale: ${i}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${i}`);const l=uN(i,a,Zbe(i,e),kn.scales[a.type]),c=Gbe(l,o),u=n.scales||{};s[i]=qp(Object.create(null),[{axis:l},a,u[l],u[c]])}),e.data.datasets.forEach(i=>{const a=i.type||e.type,l=i.indexAxis||cN(a,t),u=(Pu[a]||{}).scales||{};Object.keys(u).forEach(f=>{const h=qbe(f,l),p=i[h+"AxisID"]||h;s[p]=s[p]||Object.create(null),qp(s[p],[{axis:h},r[p],u[f]])})}),Object.keys(s).forEach(i=>{const a=s[i];qp(a,[kn.scales[a.type],kn.scale])}),s}function k7(e){const t=e.options||(e.options={});t.plugins=rt(t.plugins,{}),t.scales=Kbe(e,t)}function _7(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function Xbe(e){return e=e||{},e.data=_7(e.data),k7(e),e}const CI=new Map,j7=new Set;function xy(e,t){let n=CI.get(e);return n||(n=t(),CI.set(e,n),j7.add(n)),n}const tp=(e,t,n)=>{const r=Hl(t,n);r!==void 0&&e.add(r)};class Qbe{constructor(t){this._config=Xbe(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=_7(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),k7(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return xy(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return xy(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return xy(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){const n=t.id,r=this.type;return xy(`${r}-plugin-${n}`,()=>[[`plugins.${n}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const r=this._scopeCache;let o=r.get(t);return(!o||n)&&(o=new Map,r.set(t,o)),o}getOptionScopes(t,n,r){const{options:o,type:s}=this,i=this._cachedScopes(t,r),a=i.get(n);if(a)return a;const l=new Set;n.forEach(u=>{t&&(l.add(t),u.forEach(f=>tp(l,t,f))),u.forEach(f=>tp(l,o,f)),u.forEach(f=>tp(l,Pu[s]||{},f)),u.forEach(f=>tp(l,kn,f)),u.forEach(f=>tp(l,aN,f))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),j7.has(n)&&i.set(n,c),c}chartOptionScopes(){const{options:t,type:n}=this;return[t,Pu[n]||{},kn.datasets[n]||{},{type:n},kn,aN]}resolveNamedOptions(t,n,r,o=[""]){const s={$shared:!0},{resolver:i,subPrefixes:a}=EI(this._resolverCache,t,o);let l=i;if(eye(i,n)){s.$shared=!1,r=Ul(r)?r():r;const c=this.createResolver(t,r,a);l=Uf(i,r,c)}for(const c of n)s[c]=l[c];return s}createResolver(t,n,r=[""],o){const{resolver:s}=EI(this._resolverCache,t,r);return _t(n)?Uf(s,n,void 0,o):s}}function EI(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));const o=n.join();let s=r.get(o);return s||(s={resolver:rR(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},r.set(o,s)),s}const Jbe=e=>_t(e)&&Object.getOwnPropertyNames(e).some(t=>Ul(e[t]));function eye(e,t){const{isScriptable:n,isIndexable:r}=a7(e);for(const o of t){const s=n(o),i=r(o),a=(i||s)&&e[o];if(s&&(Ul(a)||Jbe(a))||i&&Cn(a))return!0}return!1}var tye="4.4.8";const nye=["top","bottom","left","right","chartArea"];function NI(e,t){return e==="top"||e==="bottom"||nye.indexOf(e)===-1&&t==="x"}function kI(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function _I(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),sn(n&&n.onComplete,[e],t)}function rye(e){const t=e.chart,n=t.options.animation;sn(n&&n.onProgress,[e],t)}function R7(e){return iR()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const R0={},jI=e=>{const t=R7(e);return Object.values(R0).filter(n=>n.canvas===t).pop()};function oye(e,t,n){const r=Object.keys(e);for(const o of r){const s=+o;if(s>=t){const i=e[o];delete e[o],(n>0||s>t)&&(e[s+n]=i)}}}function sye(e,t,n,r){return!n||e.type==="mouseout"?null:r?t:e}function vy(e,t,n){return e.options.clip?e[n]:t[n]}function iye(e,t){const{xScale:n,yScale:r}=e;return n&&r?{left:vy(n,t,"left"),right:vy(n,t,"right"),top:vy(r,t,"top"),bottom:vy(r,t,"bottom")}:t}class fn{static register(...t){or.add(...t),RI()}static unregister(...t){or.remove(...t),RI()}constructor(t,n){const r=this.config=new Qbe(n),o=R7(t),s=jI(o);if(s)throw new Error("Canvas is already in use. Chart with ID '"+s.id+"' must be destroyed before the canvas with ID '"+s.canvas.id+"' can be reused.");const i=r.createResolver(r.chartOptionScopes(),this.getContext());this.platform=new(r.platform||Cbe(o)),this.platform.updateConfig(r);const a=this.platform.acquireContext(o,i.aspectRatio),l=a&&a.canvas,c=l&&l.height,u=l&&l.width;if(this.id=ame(),this.ctx=a,this.canvas=l,this.width=u,this.height=c,this._options=i,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Bbe,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Eme(f=>this.update(f),i.resizeDelay||0),this._dataChanges=[],R0[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}pa.listen(this,"complete",_I),pa.listen(this,"progress",rye),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:r,height:o,_aspectRatio:s}=this;return pt(t)?n&&s?s:o?r/o:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return or}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():XA(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return YA(this.canvas,this.ctx),this}stop(){return pa.stop(this),this}resize(t,n){pa.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const r=this.options,o=this.canvas,s=r.maintainAspectRatio&&this.aspectRatio,i=this.platform.getMaximumSize(o,t,n,s),a=r.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=i.width,this.height=i.height,this._aspectRatio=this.aspectRatio,XA(this,a,!0)&&(this.notifyPlugins("resize",{size:i}),sn(r.onResize,[this,i],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};Xt(n,(r,o)=>{r.id=o})}buildOrUpdateScales(){const t=this.options,n=t.scales,r=this.scales,o=Object.keys(r).reduce((i,a)=>(i[a]=!1,i),{});let s=[];n&&(s=s.concat(Object.keys(n).map(i=>{const a=n[i],l=uN(i,a),c=l==="r",u=l==="x";return{options:a,dposition:c?"chartArea":u?"bottom":"left",dtype:c?"radialLinear":u?"category":"linear"}}))),Xt(s,i=>{const a=i.options,l=a.id,c=uN(l,a),u=rt(a.type,i.dtype);(a.position===void 0||NI(a.position,c)!==NI(i.dposition))&&(a.position=i.dposition),o[l]=!0;let f=null;if(l in r&&r[l].type===u)f=r[l];else{const h=or.getScale(u);f=new h({id:l,type:u,ctx:this.ctx,chart:this}),r[f.id]=f}f.init(a,t)}),Xt(o,(i,a)=>{i||delete r[a]}),Xt(r,i=>{Br.configure(this,i,i.options),Br.addBox(this,i)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,r=t.length;if(t.sort((o,s)=>o.index-s.index),r>n){for(let o=n;o<r;++o)this._destroyDatasetMeta(o);t.splice(n,r-n)}this._sortedMetasets=t.slice(0).sort(kI("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((r,o)=>{n.filter(s=>s===r._dataset).length===0&&this._destroyDatasetMeta(o)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let r,o;for(this._removeUnreferencedMetasets(),r=0,o=n.length;r<o;r++){const s=n[r];let i=this.getDatasetMeta(r);const a=s.type||this.config.type;if(i.type&&i.type!==a&&(this._destroyDatasetMeta(r),i=this.getDatasetMeta(r)),i.type=a,i.indexAxis=s.indexAxis||cN(a,this.options),i.order=s.order||0,i.index=r,i.label=""+s.label,i.visible=this.isDatasetVisible(r),i.controller)i.controller.updateIndex(r),i.controller.linkScales();else{const l=or.getController(a),{datasetElementType:c,dataElementType:u}=kn.datasets[a];Object.assign(l,{dataElementType:or.getElement(u),datasetElementType:c&&or.getElement(c)}),i.controller=new l(this,r),t.push(i.controller)}}return this._updateMetasets(),t}_resetElements(){Xt(this.data.datasets,(t,n)=>{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const n=this.config;n.update();const r=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),o=this._animationsDisabled=!r.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const s=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let i=0;for(let c=0,u=this.data.datasets.length;c<u;c++){const{controller:f}=this.getDatasetMeta(c),h=!o&&s.indexOf(f)===-1;f.buildOrUpdateElements(h),i=Math.max(+f.getMaxOverflow(),i)}i=this._minPadding=r.layout.autoPadding?i:0,this._updateLayout(i),o||Xt(s,c=>{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(kI("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){Xt(this.scales,t=>{Br.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),r=new Set(t.events);(!LA(n,r)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:r,start:o,count:s}of n){const i=r==="_removeElements"?-s:s;oye(t,o,i)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,r=s=>new Set(t.filter(i=>i[0]===s).map((i,a)=>a+","+i.splice(1).join(","))),o=r(0);for(let s=1;s<n;s++)if(!LA(o,r(s)))return;return Array.from(o).map(s=>s.split(",")).map(s=>({method:s[1],start:+s[2],count:+s[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Br.update(this,this.width,this.height,t);const n=this.chartArea,r=n.width<=0||n.height<=0;this._layers=[],Xt(this.boxes,o=>{r&&o.position==="chartArea"||(o.configure&&o.configure(),this._layers.push(...o._layers()))},this),this._layers.forEach((o,s)=>{o._idx=s}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,r=this.data.datasets.length;n<r;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,r=this.data.datasets.length;n<r;++n)this._updateDataset(n,Ul(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const r=this.getDatasetMeta(t),o={meta:r,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",o)!==!1&&(r.controller._update(n),o.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",o))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(pa.has(this)?this.attached&&!pa.running(this)&&pa.start(this):(this.draw(),_I({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:r,height:o}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(r,o)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;const n=this._layers;for(t=0;t<n.length&&n[t].z<=0;++t)n[t].draw(this.chartArea);for(this._drawDatasets();t<n.length;++t)n[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const n=this._sortedMetasets,r=[];let o,s;for(o=0,s=n.length;o<s;++o){const i=n[o];(!t||i.visible)&&r.push(i)}return r}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;const t=this.getSortedVisibleDatasetMetas();for(let n=t.length-1;n>=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const n=this.ctx,r=t._clip,o=!r.disabled,s=iye(t,this.chartArea),i={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",i)!==!1&&(o&&fu(n,{left:r.left===!1?0:s.left-r.left,right:r.right===!1?this.width:s.right+r.right,top:r.top===!1?0:s.top-r.top,bottom:r.bottom===!1?this.height:s.bottom+r.bottom}),t.controller.draw(),o&&hu(n),i.cancelable=!1,this.notifyPlugins("afterDatasetDraw",i))}isPointInArea(t){return Ra(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,r,o){const s=nbe.modes[n];return typeof s=="function"?s(this,t,r,o):[]}getDatasetMeta(t){const n=this.data.datasets[t],r=this._metasets;let o=r.filter(s=>s&&s._dataset===n).pop();return o||(o={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},r.push(o)),o}getContext(){return this.$context||(this.$context=ac(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const r=this.getDatasetMeta(t);return typeof r.hidden=="boolean"?!r.hidden:!n.hidden}setDatasetVisibility(t,n){const r=this.getDatasetMeta(t);r.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,r){const o=r?"show":"hide",s=this.getDatasetMeta(t),i=s.controller._resolveAnimations(void 0,o);Dm(n)?(s.data[n].hidden=!r,this.update()):(this.setDatasetVisibility(t,r),i.update(s,{visible:r}),this.update(a=>a.datasetIndex===t?o:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){const n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),pa.remove(this),t=0,n=this.data.datasets.length;t<n;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:n}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),YA(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete R0[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,n=this.platform,r=(s,i)=>{n.addEventListener(this,s,i),t[s]=i},o=(s,i,a)=>{s.offsetX=i,s.offsetY=a,this._eventHandler(s)};Xt(this.options.events,s=>r(s,o))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,r=(l,c)=>{n.addEventListener(this,l,c),t[l]=c},o=(l,c)=>{t[l]&&(n.removeEventListener(this,l,c),delete t[l])},s=(l,c)=>{this.canvas&&this.resize(l,c)};let i;const a=()=>{o("attach",a),this.attached=!0,this.resize(),r("resize",s),r("detach",i)};i=()=>{this.attached=!1,o("resize",s),this._stop(),this._resize(0,0),r("attach",a)},n.isAttached(this.canvas)?a():i()}unbindEvents(){Xt(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},Xt(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,r){const o=r?"set":"remove";let s,i,a,l;for(n==="dataset"&&(s=this.getDatasetMeta(t[0].datasetIndex),s.controller["_"+o+"DatasetHoverStyle"]()),a=0,l=t.length;a<l;++a){i=t[a];const c=i&&this.getDatasetMeta(i.datasetIndex).controller;c&&c[o+"HoverStyle"](i.element,i.datasetIndex,i.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],r=t.map(({datasetIndex:s,index:i})=>{const a=this.getDatasetMeta(s);if(!a)throw new Error("No dataset found at index "+s);return{datasetIndex:s,element:a.data[i],index:i}});!gx(r,n)&&(this._active=r,this._lastEvent=null,this._updateHoverStyles(r,n))}notifyPlugins(t,n,r){return this._plugins.notify(this,t,n,r)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,r){const o=this.options.hover,s=(l,c)=>l.filter(u=>!c.some(f=>u.datasetIndex===f.datasetIndex&&u.index===f.index)),i=s(n,t),a=r?t:s(t,n);i.length&&this.updateHoverStyle(i,o.mode,!1),a.length&&o.mode&&this.updateHoverStyle(a,o.mode,!0)}_eventHandler(t,n){const r={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},o=i=>(i.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",r,o)===!1)return;const s=this._handleEvent(t,n,r.inChartArea);return r.cancelable=!1,this.notifyPlugins("afterEvent",r,o),(s||r.changed)&&this.render(),this}_handleEvent(t,n,r){const{_active:o=[],options:s}=this,i=n,a=this._getActiveElements(t,o,r,i),l=hme(t),c=sye(t,this._lastEvent,r,l);r&&(this._lastEvent=null,sn(s.onHover,[t,a,this],this),l&&sn(s.onClick,[t,a,this],this));const u=!gx(a,o);return(u||n)&&(this._active=a,this._updateHoverStyles(a,o,n)),this._lastEvent=c,u}_getActiveElements(t,n,r,o){if(t.type==="mouseout")return[];if(!r)return n;const s=this.options.hover;return this.getElementsAtEventForMode(t,s.mode,s,o)}}ke(fn,"defaults",kn),ke(fn,"instances",R0),ke(fn,"overrides",Pu),ke(fn,"registry",or),ke(fn,"version",tye),ke(fn,"getChart",jI);function RI(){return Xt(fn.instances,e=>e._plugins.invalidate())}function aye(e,t,n){const{startAngle:r,pixelMargin:o,x:s,y:i,outerRadius:a,innerRadius:l}=t;let c=o/a;e.beginPath(),e.arc(s,i,a,r-c,n+c),l>o?(c=o/l,e.arc(s,i,l,n+c,r-c,!0)):e.arc(s,i,o,n+Qn,r-Qn),e.closePath(),e.clip()}function lye(e){return nR(e,["outerStart","outerEnd","innerStart","innerEnd"])}function cye(e,t,n,r){const o=lye(e.options.borderRadius),s=(n-t)/2,i=Math.min(s,r*t/2),a=l=>{const c=(n-Math.min(s,l))*r/2;return wr(l,0,Math.min(s,c))};return{outerStart:a(o.outerStart),outerEnd:a(o.outerEnd),innerStart:wr(o.innerStart,0,i),innerEnd:wr(o.innerEnd,0,i)}}function Sd(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Cx(e,t,n,r,o,s){const{x:i,y:a,startAngle:l,pixelMargin:c,innerRadius:u}=t,f=Math.max(t.outerRadius+r+n-c,0),h=u>0?u+r+n+c:0;let p=0;const m=o-l;if(r){const A=u>0?u-r:0,$=f>0?f-r:0,H=(A+$)/2,U=H!==0?m*H/(H+r):m;p=(m-U)/2}const b=Math.max(.001,m*f-n/_n)/f,y=(m-b)/2,g=l+y+p,x=o-y-p,{outerStart:v,outerEnd:w,innerStart:C,innerEnd:S}=cye(t,h,f,x-g),N=f-v,j=f-w,_=g+v/N,R=x-w/j,M=h+C,T=h+S,O=g+C/M,I=x-S/T;if(e.beginPath(),s){const A=(_+R)/2;if(e.arc(i,a,f,_,A),e.arc(i,a,f,A,R),w>0){const B=Sd(j,R,i,a);e.arc(B.x,B.y,w,R,x+Qn)}const $=Sd(T,x,i,a);if(e.lineTo($.x,$.y),S>0){const B=Sd(T,I,i,a);e.arc(B.x,B.y,S,x+Qn,I+Math.PI)}const H=(x-S/h+(g+C/h))/2;if(e.arc(i,a,h,x-S/h,H,!0),e.arc(i,a,h,H,g+C/h,!0),C>0){const B=Sd(M,O,i,a);e.arc(B.x,B.y,C,O+Math.PI,g-Qn)}const U=Sd(N,g,i,a);if(e.lineTo(U.x,U.y),v>0){const B=Sd(N,_,i,a);e.arc(B.x,B.y,v,g-Qn,_)}}else{e.moveTo(i,a);const A=Math.cos(_)*f+i,$=Math.sin(_)*f+a;e.lineTo(A,$);const H=Math.cos(R)*f+i,U=Math.sin(R)*f+a;e.lineTo(H,U)}e.closePath()}function uye(e,t,n,r,o){const{fullCircles:s,startAngle:i,circumference:a}=t;let l=t.endAngle;if(s){Cx(e,t,n,r,l,o);for(let c=0;c<s;++c)e.fill();isNaN(a)||(l=i+(a%Nn||Nn))}return Cx(e,t,n,r,l,o),e.fill(),l}function dye(e,t,n,r,o){const{fullCircles:s,startAngle:i,circumference:a,options:l}=t,{borderWidth:c,borderJoinStyle:u,borderDash:f,borderDashOffset:h}=l,p=l.borderAlign==="inner";if(!c)return;e.setLineDash(f||[]),e.lineDashOffset=h,p?(e.lineWidth=c*2,e.lineJoin=u||"round"):(e.lineWidth=c,e.lineJoin=u||"bevel");let m=t.endAngle;if(s){Cx(e,t,n,r,m,o);for(let b=0;b<s;++b)e.stroke();isNaN(a)||(m=i+(a%Nn||Nn))}p&&aye(e,t,m),s||(Cx(e,t,n,r,m,o),e.stroke())}class Ud extends sa{constructor(n){super();ke(this,"circumference");ke(this,"endAngle");ke(this,"fullCircles");ke(this,"innerRadius");ke(this,"outerRadius");ke(this,"pixelMargin");ke(this,"startAngle");this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,n&&Object.assign(this,n)}inRange(n,r,o){const s=this.getProps(["x","y"],o),{angle:i,distance:a}=X9(s,{x:n,y:r}),{startAngle:l,endAngle:c,innerRadius:u,outerRadius:f,circumference:h}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],o),p=(this.options.spacing+this.options.borderWidth)/2,m=rt(h,c-l),b=Tm(i,l,c)&&l!==c,y=m>=Nn||b,g=_a(a,u+p,f+p);return y&&g}getCenterPoint(n){const{x:r,y:o,startAngle:s,endAngle:i,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],n),{offset:c,spacing:u}=this.options,f=(s+i)/2,h=(a+l+u+c)/2;return{x:r+Math.cos(f)*h,y:o+Math.sin(f)*h}}tooltipPosition(n){return this.getCenterPoint(n)}draw(n){const{options:r,circumference:o}=this,s=(r.offset||0)/4,i=(r.spacing||0)/2,a=r.circular;if(this.pixelMargin=r.borderAlign==="inner"?.33:0,this.fullCircles=o>Nn?Math.floor(o/Nn):0,o===0||this.innerRadius<0||this.outerRadius<0)return;n.save();const l=(this.startAngle+this.endAngle)/2;n.translate(Math.cos(l)*s,Math.sin(l)*s);const c=1-Math.sin(Math.min(_n,o||0)),u=s*c;n.fillStyle=r.backgroundColor,n.strokeStyle=r.borderColor,uye(n,this,u,i,a),dye(n,this,u,i,a),n.restore()}}ke(Ud,"id","arc"),ke(Ud,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0}),ke(Ud,"defaultRoutes",{backgroundColor:"backgroundColor"}),ke(Ud,"descriptors",{_scriptable:!0,_indexable:n=>n!=="borderDash"});function M7(e,t,n=t){e.lineCap=rt(n.borderCapStyle,t.borderCapStyle),e.setLineDash(rt(n.borderDash,t.borderDash)),e.lineDashOffset=rt(n.borderDashOffset,t.borderDashOffset),e.lineJoin=rt(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=rt(n.borderWidth,t.borderWidth),e.strokeStyle=rt(n.borderColor,t.borderColor)}function fye(e,t,n){e.lineTo(n.x,n.y)}function hye(e){return e.stepped?Ome:e.tension||e.cubicInterpolationMode==="monotone"?Fme:fye}function D7(e,t,n={}){const r=e.length,{start:o=0,end:s=r-1}=n,{start:i,end:a}=t,l=Math.max(o,i),c=Math.min(s,a),u=o<i&&s<i||o>a&&s>a;return{count:r,start:l,loop:t.loop,ilen:c<l&&!u?r+c-l:c-l}}function pye(e,t,n,r){const{points:o,options:s}=t,{count:i,start:a,loop:l,ilen:c}=D7(o,n,r),u=hye(s);let{move:f=!0,reverse:h}=r||{},p,m,b;for(p=0;p<=c;++p)m=o[(a+(h?c-p:p))%i],!m.skip&&(f?(e.moveTo(m.x,m.y),f=!1):u(e,b,m,h,s.stepped),b=m);return l&&(m=o[(a+(h?c:0))%i],u(e,b,m,h,s.stepped)),!!l}function mye(e,t,n,r){const o=t.points,{count:s,start:i,ilen:a}=D7(o,n,r),{move:l=!0,reverse:c}=r||{};let u=0,f=0,h,p,m,b,y,g;const x=w=>(i+(c?a-w:w))%s,v=()=>{b!==y&&(e.lineTo(u,y),e.lineTo(u,b),e.lineTo(u,g))};for(l&&(p=o[x(0)],e.moveTo(p.x,p.y)),h=0;h<=a;++h){if(p=o[x(h)],p.skip)continue;const w=p.x,C=p.y,S=w|0;S===m?(C<b?b=C:C>y&&(y=C),u=(f*u+w)/++f):(v(),e.lineTo(w,C),m=S,f=0,b=y=C),g=C}v()}function dN(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?mye:pye}function gye(e){return e.stepped?mge:e.tension||e.cubicInterpolationMode==="monotone"?gge:Mc}function bye(e,t,n,r){let o=t._path;o||(o=t._path=new Path2D,t.path(o,n,r)&&o.closePath()),M7(e,t.options),e.stroke(o)}function yye(e,t,n,r){const{segments:o,options:s}=t,i=dN(t);for(const a of o)M7(e,s,a.style),e.beginPath(),i(e,t,a,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}const xye=typeof Path2D=="function";function vye(e,t,n,r){xye&&!t.options.segment?bye(e,t,n,r):yye(e,t,n,r)}class jl extends sa{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,n){const r=this.options;if((r.tension||r.cubicInterpolationMode==="monotone")&&!r.stepped&&!this._pointsUpdated){const o=r.spanGaps?this._loop:this._fullLoop;age(this._points,r,t,o,n),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Sge(this,this.options.segment))}first(){const t=this.segments,n=this.points;return t.length&&n[t[0].start]}last(){const t=this.segments,n=this.points,r=t.length;return r&&n[t[r-1].end]}interpolate(t,n){const r=this.options,o=t[n],s=this.points,i=b7(this,{property:n,start:o,end:o});if(!i.length)return;const a=[],l=gye(r);let c,u;for(c=0,u=i.length;c<u;++c){const{start:f,end:h}=i[c],p=s[f],m=s[h];if(p===m){a.push(p);continue}const b=Math.abs((o-p[n])/(m[n]-p[n])),y=l(p,m,b,r.stepped);y[n]=t[n],a.push(y)}return a.length===1?a[0]:a}pathSegment(t,n,r){return dN(this)(t,this,n,r)}path(t,n,r){const o=this.segments,s=dN(this);let i=this._loop;n=n||0,r=r||this.points.length-n;for(const a of o)i&=s(t,this,a,{start:n,end:n+r-1});return!!i}draw(t,n,r,o){const s=this.options||{};(this.points||[]).length&&s.borderWidth&&(t.save(),vye(t,this,r,o),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}ke(jl,"id","line"),ke(jl,"defaults",{borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0}),ke(jl,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"}),ke(jl,"descriptors",{_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"});function MI(e,t,n,r){const o=e.options,{[n]:s}=e.getProps([n],r);return Math.abs(t-s)<o.radius+o.hitRadius}class bu extends sa{constructor(n){super();ke(this,"parsed");ke(this,"skip");ke(this,"stop");this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,n&&Object.assign(this,n)}inRange(n,r,o){const s=this.options,{x:i,y:a}=this.getProps(["x","y"],o);return Math.pow(n-i,2)+Math.pow(r-a,2)<Math.pow(s.hitRadius+s.radius,2)}inXRange(n,r){return MI(this,n,"x",r)}inYRange(n,r){return MI(this,n,"y",r)}getCenterPoint(n){const{x:r,y:o}=this.getProps(["x","y"],n);return{x:r,y:o}}size(n){n=n||this.options||{};let r=n.radius||0;r=Math.max(r,r&&n.hoverRadius||0);const o=r&&n.borderWidth||0;return(r+o)*2}draw(n,r){const o=this.options;this.skip||o.radius<.1||!Ra(this,r,this.size(o)/2)||(n.strokeStyle=o.borderColor,n.lineWidth=o.borderWidth,n.fillStyle=o.backgroundColor,vx(n,o,this.x,this.y))}getRange(){const n=this.options||{};return n.radius+n.hitRadius}}ke(bu,"id","point"),ke(bu,"defaults",{borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0}),ke(bu,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});function T7(e,t){const{x:n,y:r,base:o,width:s,height:i}=e.getProps(["x","y","base","width","height"],t);let a,l,c,u,f;return e.horizontal?(f=i/2,a=Math.min(n,o),l=Math.max(n,o),c=r-f,u=r+f):(f=s/2,a=n-f,l=n+f,c=Math.min(r,o),u=Math.max(r,o)),{left:a,top:c,right:l,bottom:u}}function Rl(e,t,n,r){return e?0:wr(t,n,r)}function wye(e,t,n){const r=e.options.borderWidth,o=e.borderSkipped,s=i7(r);return{t:Rl(o.top,s.top,0,n),r:Rl(o.right,s.right,0,t),b:Rl(o.bottom,s.bottom,0,n),l:Rl(o.left,s.left,0,t)}}function Sye(e,t,n){const{enableBorderRadius:r}=e.getProps(["enableBorderRadius"]),o=e.options.borderRadius,s=pu(o),i=Math.min(t,n),a=e.borderSkipped,l=r||_t(o);return{topLeft:Rl(!l||a.top||a.left,s.topLeft,0,i),topRight:Rl(!l||a.top||a.right,s.topRight,0,i),bottomLeft:Rl(!l||a.bottom||a.left,s.bottomLeft,0,i),bottomRight:Rl(!l||a.bottom||a.right,s.bottomRight,0,i)}}function Cye(e){const t=T7(e),n=t.right-t.left,r=t.bottom-t.top,o=wye(e,n/2,r/2),s=Sye(e,n/2,r/2);return{outer:{x:t.left,y:t.top,w:n,h:r,radius:s},inner:{x:t.left+o.l,y:t.top+o.t,w:n-o.l-o.r,h:r-o.t-o.b,radius:{topLeft:Math.max(0,s.topLeft-Math.max(o.t,o.l)),topRight:Math.max(0,s.topRight-Math.max(o.t,o.r)),bottomLeft:Math.max(0,s.bottomLeft-Math.max(o.b,o.l)),bottomRight:Math.max(0,s.bottomRight-Math.max(o.b,o.r))}}}}function dC(e,t,n,r){const o=t===null,s=n===null,a=e&&!(o&&s)&&T7(e,r);return a&&(o||_a(t,a.left,a.right))&&(s||_a(n,a.top,a.bottom))}function Eye(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function Nye(e,t){e.rect(t.x,t.y,t.w,t.h)}function fC(e,t,n={}){const r=e.x!==n.x?-t:0,o=e.y!==n.y?-t:0,s=(e.x+e.w!==n.x+n.w?t:0)-r,i=(e.y+e.h!==n.y+n.h?t:0)-o;return{x:e.x+r,y:e.y+o,w:e.w+s,h:e.h+i,radius:e.radius}}class Ti extends sa{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:n,options:{borderColor:r,backgroundColor:o}}=this,{inner:s,outer:i}=Cye(this),a=Eye(i.radius)?Pm:Nye;t.save(),(i.w!==s.w||i.h!==s.h)&&(t.beginPath(),a(t,fC(i,n,s)),t.clip(),a(t,fC(s,-n,i)),t.fillStyle=r,t.fill("evenodd")),t.beginPath(),a(t,fC(s,n)),t.fillStyle=o,t.fill(),t.restore()}inRange(t,n,r){return dC(this,t,n,r)}inXRange(t,n){return dC(this,t,null,n)}inYRange(t,n){return dC(this,null,t,n)}getCenterPoint(t){const{x:n,y:r,base:o,horizontal:s}=this.getProps(["x","y","base","horizontal"],t);return{x:s?(n+o)/2:n,y:s?r:(r+o)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}}ke(Ti,"id","bar"),ke(Ti,"defaults",{borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0}),ke(Ti,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});var kye=Object.freeze({__proto__:null,ArcElement:Ud,BarElement:Ti,LineElement:jl,PointElement:bu});const fN=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],DI=fN.map(e=>e.replace("rgb(","rgba(").replace(")",", 0.5)"));function P7(e){return fN[e%fN.length]}function A7(e){return DI[e%DI.length]}function _ye(e,t){return e.borderColor=P7(t),e.backgroundColor=A7(t),++t}function jye(e,t){return e.backgroundColor=e.data.map(()=>P7(t++)),t}function Rye(e,t){return e.backgroundColor=e.data.map(()=>A7(t++)),t}function Mye(e){let t=0;return(n,r)=>{const o=e.getDatasetMeta(r).controller;o instanceof Hc?t=jye(n,t):o instanceof Kp?t=Rye(n,t):o&&(t=_ye(n,t))}}function TI(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function Dye(e){return e&&(e.borderColor||e.backgroundColor)}function Tye(){return kn.borderColor!=="rgba(0,0,0,0.1)"||kn.backgroundColor!=="rgba(0,0,0,0.1)"}var Pye={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;const{data:{datasets:r},options:o}=e.config,{elements:s}=o,i=TI(r)||Dye(o)||s&&TI(s)||Tye();if(!n.forceOverride&&i)return;const a=Mye(e);r.forEach(a)}};function Aye(e,t,n,r,o){const s=o.samples||r;if(s>=n)return e.slice(t,t+n);const i=[],a=(n-2)/(s-2);let l=0;const c=t+n-1;let u=t,f,h,p,m,b;for(i[l++]=e[u],f=0;f<s-2;f++){let y=0,g=0,x;const v=Math.floor((f+1)*a)+1+t,w=Math.min(Math.floor((f+2)*a)+1,n)+t,C=w-v;for(x=v;x<w;x++)y+=e[x].x,g+=e[x].y;y/=C,g/=C;const S=Math.floor(f*a)+1+t,N=Math.min(Math.floor((f+1)*a)+1,n)+t,{x:j,y:_}=e[u];for(p=m=-1,x=S;x<N;x++)m=.5*Math.abs((j-y)*(e[x].y-_)-(j-e[x].x)*(g-_)),m>p&&(p=m,h=e[x],b=x);i[l++]=h,u=b}return i[l++]=e[c],i}function Iye(e,t,n,r){let o=0,s=0,i,a,l,c,u,f,h,p,m,b;const y=[],g=t+n-1,x=e[t].x,w=e[g].x-x;for(i=t;i<t+n;++i){a=e[i],l=(a.x-x)/w*r,c=a.y;const C=l|0;if(C===u)c<m?(m=c,f=i):c>b&&(b=c,h=i),o=(s*o+a.x)/++s;else{const S=i-1;if(!pt(f)&&!pt(h)){const N=Math.min(f,h),j=Math.max(f,h);N!==p&&N!==S&&y.push({...e[N],x:o}),j!==p&&j!==S&&y.push({...e[j],x:o})}i>0&&S!==p&&y.push(e[S]),y.push(a),u=C,s=0,m=b=c,f=h=p=i}}return y}function I7(e){if(e._decimated){const t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function PI(e){e.data.datasets.forEach(t=>{I7(t)})}function Oye(e,t){const n=t.length;let r=0,o;const{iScale:s}=e,{min:i,max:a,minDefined:l,maxDefined:c}=s.getUserBounds();return l&&(r=wr(ja(t,s.axis,i).lo,0,n-1)),c?o=wr(ja(t,s.axis,a).hi+1,r,n)-r:o=n-r,{start:r,count:o}}var Fye={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){PI(e);return}const r=e.width;e.data.datasets.forEach((o,s)=>{const{_data:i,indexAxis:a}=o,l=e.getDatasetMeta(s),c=i||o.data;if(Sn([a,e.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;const u=e.scales[l.xAxisID];if(u.type!=="linear"&&u.type!=="time"||e.options.parsing)return;let{start:f,count:h}=Oye(l,c);const p=n.threshold||4*r;if(h<=p){I7(o);return}pt(i)&&(o._data=c,delete o.data,Object.defineProperty(o,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(b){this._data=b}}));let m;switch(n.algorithm){case"lttb":m=Aye(c,f,h,r,n);break;case"min-max":m=Iye(c,f,h,r);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}o._decimated=m})},destroy(e){PI(e)}};function $ye(e,t,n){const r=e.segments,o=e.points,s=t.points,i=[];for(const a of r){let{start:l,end:c}=a;c=cR(l,c,o);const u=hN(n,o[l],o[c],a.loop);if(!t.segments){i.push({source:a,target:u,start:o[l],end:o[c]});continue}const f=b7(t,u);for(const h of f){const p=hN(n,s[h.start],s[h.end],h.loop),m=g7(a,o,p);for(const b of m)i.push({source:b,target:h,start:{[n]:AI(u,p,"start",Math.max)},end:{[n]:AI(u,p,"end",Math.min)}})}}return i}function hN(e,t,n,r){if(r)return;let o=t[e],s=n[e];return e==="angle"&&(o=Oo(o),s=Oo(s)),{property:e,start:o,end:s}}function Lye(e,t){const{x:n=null,y:r=null}=e||{},o=t.points,s=[];return t.segments.forEach(({start:i,end:a})=>{a=cR(i,a,o);const l=o[i],c=o[a];r!==null?(s.push({x:l.x,y:r}),s.push({x:c.x,y:r})):n!==null&&(s.push({x:n,y:l.y}),s.push({x:n,y:c.y}))}),s}function cR(e,t,n){for(;t>e;t--){const r=n[t];if(!isNaN(r.x)&&!isNaN(r.y))break}return t}function AI(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function O7(e,t){let n=[],r=!1;return Cn(e)?(r=!0,n=e):n=Lye(e,t),n.length?new jl({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function II(e){return e&&e.fill!==!1}function zye(e,t,n){let o=e[t].fill;const s=[t];let i;if(!n)return o;for(;o!==!1&&s.indexOf(o)===-1;){if(!Wn(o))return o;if(i=e[o],!i)return!1;if(i.visible)return o;s.push(o),o=i.fill}return!1}function Bye(e,t,n){const r=Wye(e);if(_t(r))return isNaN(r.value)?!1:r;let o=parseFloat(r);return Wn(o)&&Math.floor(o)===o?Vye(r[0],t,o,n):["origin","start","end","stack","shape"].indexOf(r)>=0&&r}function Vye(e,t,n,r){return(e==="-"||e==="+")&&(n=t+n),n===t||n<0||n>=r?!1:n}function Hye(e,t){let n=null;return e==="start"?n=t.bottom:e==="end"?n=t.top:_t(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function Uye(e,t,n){let r;return e==="start"?r=n:e==="end"?r=t.options.reverse?t.min:t.max:_t(e)?r=e.value:r=t.getBaseValue(),r}function Wye(e){const t=e.options,n=t.fill;let r=rt(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?"origin":r}function qye(e){const{scale:t,index:n,line:r}=e,o=[],s=r.segments,i=r.points,a=Gye(t,n);a.push(O7({x:null,y:t.bottom},r));for(let l=0;l<s.length;l++){const c=s[l];for(let u=c.start;u<=c.end;u++)Yye(o,i[u],a)}return new jl({points:o,options:{}})}function Gye(e,t){const n=[],r=e.getMatchingVisibleMetas("line");for(let o=0;o<r.length;o++){const s=r[o];if(s.index===t)break;s.hidden||n.unshift(s.dataset)}return n}function Yye(e,t,n){const r=[];for(let o=0;o<n.length;o++){const s=n[o],{first:i,last:a,point:l}=Zye(s,t,"x");if(!(!l||i&&a)){if(i)r.unshift(l);else if(e.push(l),!a)break}}e.push(...r)}function Zye(e,t,n){const r=e.interpolate(t,n);if(!r)return{};const o=r[n],s=e.segments,i=e.points;let a=!1,l=!1;for(let c=0;c<s.length;c++){const u=s[c],f=i[u.start][n],h=i[u.end][n];if(_a(o,f,h)){a=o===f,l=o===h;break}}return{first:a,last:l,point:r}}class F7{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,n,r){const{x:o,y:s,radius:i}=this;return n=n||{start:0,end:Nn},t.arc(o,s,i,n.end,n.start,!0),!r.bounds}interpolate(t){const{x:n,y:r,radius:o}=this,s=t.angle;return{x:n+Math.cos(s)*o,y:r+Math.sin(s)*o,angle:s}}}function Kye(e){const{chart:t,fill:n,line:r}=e;if(Wn(n))return Xye(t,n);if(n==="stack")return qye(e);if(n==="shape")return!0;const o=Qye(e);return o instanceof F7?o:O7(o,r)}function Xye(e,t){const n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function Qye(e){return(e.scale||{}).getPointPositionForValue?e0e(e):Jye(e)}function Jye(e){const{scale:t={},fill:n}=e,r=Hye(n,t);if(Wn(r)){const o=t.isHorizontal();return{x:o?r:null,y:o?null:r}}return null}function e0e(e){const{scale:t,fill:n}=e,r=t.options,o=t.getLabels().length,s=r.reverse?t.max:t.min,i=Uye(n,t,s),a=[];if(r.grid.circular){const l=t.getPointPositionForValue(0,s);return new F7({x:l.x,y:l.y,radius:t.getDistanceFromCenterForValue(i)})}for(let l=0;l<o;++l)a.push(t.getPointPositionForValue(l,i));return a}function hC(e,t,n){const r=Kye(t),{line:o,scale:s,axis:i}=t,a=o.options,l=a.fill,c=a.backgroundColor,{above:u=c,below:f=c}=l||{};r&&o.points.length&&(fu(e,n),t0e(e,{line:o,target:r,above:u,below:f,area:n,scale:s,axis:i}),hu(e))}function t0e(e,t){const{line:n,target:r,above:o,below:s,area:i,scale:a}=t,l=n._loop?"angle":t.axis;e.save(),l==="x"&&s!==o&&(OI(e,r,i.top),FI(e,{line:n,target:r,color:o,scale:a,property:l}),e.restore(),e.save(),OI(e,r,i.bottom)),FI(e,{line:n,target:r,color:s,scale:a,property:l}),e.restore()}function OI(e,t,n){const{segments:r,points:o}=t;let s=!0,i=!1;e.beginPath();for(const a of r){const{start:l,end:c}=a,u=o[l],f=o[cR(l,c,o)];s?(e.moveTo(u.x,u.y),s=!1):(e.lineTo(u.x,n),e.lineTo(u.x,u.y)),i=!!t.pathSegment(e,a,{move:i}),i?e.closePath():e.lineTo(f.x,n)}e.lineTo(t.first().x,n),e.closePath(),e.clip()}function FI(e,t){const{line:n,target:r,property:o,color:s,scale:i}=t,a=$ye(n,r,o);for(const{source:l,target:c,start:u,end:f}of a){const{style:{backgroundColor:h=s}={}}=l,p=r!==!0;e.save(),e.fillStyle=h,n0e(e,i,p&&hN(o,u,f)),e.beginPath();const m=!!n.pathSegment(e,l);let b;if(p){m?e.closePath():$I(e,r,f,o);const y=!!r.pathSegment(e,c,{move:m,reverse:!0});b=m&&y,b||$I(e,r,u,o)}e.closePath(),e.fill(b?"evenodd":"nonzero"),e.restore()}}function n0e(e,t,n){const{top:r,bottom:o}=t.chart.chartArea,{property:s,start:i,end:a}=n||{};s==="x"&&(e.beginPath(),e.rect(i,r,a-i,o-r),e.clip())}function $I(e,t,n,r){const o=t.interpolate(n,r);o&&e.lineTo(o.x,o.y)}var r0e={id:"filler",afterDatasetsUpdate(e,t,n){const r=(e.data.datasets||[]).length,o=[];let s,i,a,l;for(i=0;i<r;++i)s=e.getDatasetMeta(i),a=s.dataset,l=null,a&&a.options&&a instanceof jl&&(l={visible:e.isDatasetVisible(i),index:i,fill:Bye(a,i,r),chart:e,axis:s.controller.options.indexAxis,scale:s.vScale,line:a}),s.$filler=l,o.push(l);for(i=0;i<r;++i)l=o[i],!(!l||l.fill===!1)&&(l.fill=zye(o,i,n.propagate))},beforeDraw(e,t,n){const r=n.drawTime==="beforeDraw",o=e.getSortedVisibleDatasetMetas(),s=e.chartArea;for(let i=o.length-1;i>=0;--i){const a=o[i].$filler;a&&(a.line.updateControlPoints(s,a.axis),r&&a.fill&&hC(e.ctx,a,s))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!=="beforeDatasetsDraw")return;const r=e.getSortedVisibleDatasetMetas();for(let o=r.length-1;o>=0;--o){const s=r[o].$filler;II(s)&&hC(e.ctx,s,e.chartArea)}},beforeDatasetDraw(e,t,n){const r=t.meta.$filler;!II(r)||n.drawTime!=="beforeDatasetDraw"||hC(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const LI=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},o0e=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class zI extends sa{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n,r){this.maxWidth=t,this.maxHeight=n,this._margins=r,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let n=sn(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(r=>t.filter(r,this.chart.data))),t.sort&&(n=n.sort((r,o)=>t.sort(r,o,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){const{options:t,ctx:n}=this;if(!t.display){this.width=this.height=0;return}const r=t.labels,o=ar(r.font),s=o.size,i=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=LI(r,s);let c,u;n.font=o.string,this.isHorizontal()?(c=this.maxWidth,u=this._fitRows(i,s,a,l)+10):(u=this.maxHeight,c=this._fitCols(i,o,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,n,r,o){const{ctx:s,maxWidth:i,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],u=o+a;let f=t;s.textAlign="left",s.textBaseline="middle";let h=-1,p=-u;return this.legendItems.forEach((m,b)=>{const y=r+n/2+s.measureText(m.text).width;(b===0||c[c.length-1]+y+2*a>i)&&(f+=u,c[c.length-(b>0?0:1)]=0,p+=u,h++),l[b]={left:0,top:p,row:h,width:y,height:o},c[c.length-1]+=y+a}),f}_fitCols(t,n,r,o){const{ctx:s,maxHeight:i,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],u=i-t;let f=a,h=0,p=0,m=0,b=0;return this.legendItems.forEach((y,g)=>{const{itemWidth:x,itemHeight:v}=s0e(r,n,s,y,o);g>0&&p+v+2*a>u&&(f+=h+a,c.push({width:h,height:p}),m+=h+a,b++,h=p=0),l[g]={left:m,top:p,col:b,width:x,height:v},h=Math.max(h,x),p+=v+a}),f+=h,c.push({width:h,height:p}),f}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:r,labels:{padding:o},rtl:s}}=this,i=lf(s,this.left,this.width);if(this.isHorizontal()){let a=0,l=Fr(r,this.left+o,this.right-this.lineWidths[a]);for(const c of n)a!==c.row&&(a=c.row,l=Fr(r,this.left+o,this.right-this.lineWidths[a])),c.top+=this.top+t+o,c.left=i.leftForLtr(i.x(l),c.width),l+=c.width+o}else{let a=0,l=Fr(r,this.top+t+o,this.bottom-this.columnSizes[a].height);for(const c of n)c.col!==a&&(a=c.col,l=Fr(r,this.top+t+o,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+o,c.left=i.leftForLtr(i.x(c.left),c.width),l+=c.height+o}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;fu(t,this),this._draw(),hu(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:r,ctx:o}=this,{align:s,labels:i}=t,a=kn.color,l=lf(t.rtl,this.left,this.width),c=ar(i.font),{padding:u}=i,f=c.size,h=f/2;let p;this.drawTitle(),o.textAlign=l.textAlign("left"),o.textBaseline="middle",o.lineWidth=.5,o.font=c.string;const{boxWidth:m,boxHeight:b,itemHeight:y}=LI(i,f),g=function(S,N,j){if(isNaN(m)||m<=0||isNaN(b)||b<0)return;o.save();const _=rt(j.lineWidth,1);if(o.fillStyle=rt(j.fillStyle,a),o.lineCap=rt(j.lineCap,"butt"),o.lineDashOffset=rt(j.lineDashOffset,0),o.lineJoin=rt(j.lineJoin,"miter"),o.lineWidth=_,o.strokeStyle=rt(j.strokeStyle,a),o.setLineDash(rt(j.lineDash,[])),i.usePointStyle){const R={radius:b*Math.SQRT2/2,pointStyle:j.pointStyle,rotation:j.rotation,borderWidth:_},M=l.xPlus(S,m/2),T=N+h;s7(o,R,M,T,i.pointStyleWidth&&m)}else{const R=N+Math.max((f-b)/2,0),M=l.leftForLtr(S,m),T=pu(j.borderRadius);o.beginPath(),Object.values(T).some(O=>O!==0)?Pm(o,{x:M,y:R,w:m,h:b,radius:T}):o.rect(M,R,m,b),o.fill(),_!==0&&o.stroke()}o.restore()},x=function(S,N,j){Au(o,j.text,S,N+y/2,c,{strikethrough:j.hidden,textAlign:l.textAlign(j.textAlign)})},v=this.isHorizontal(),w=this._computeTitleHeight();v?p={x:Fr(s,this.left+u,this.right-r[0]),y:this.top+u+w,line:0}:p={x:this.left+u,y:Fr(s,this.top+w+u,this.bottom-n[0].height),line:0},h7(this.ctx,t.textDirection);const C=y+u;this.legendItems.forEach((S,N)=>{o.strokeStyle=S.fontColor,o.fillStyle=S.fontColor;const j=o.measureText(S.text).width,_=l.textAlign(S.textAlign||(S.textAlign=i.textAlign)),R=m+h+j;let M=p.x,T=p.y;l.setWidth(this.width),v?N>0&&M+R+u>this.right&&(T=p.y+=C,p.line++,M=p.x=Fr(s,this.left+u,this.right-r[p.line])):N>0&&T+C>this.bottom&&(M=p.x=M+n[p.line].width+u,p.line++,T=p.y=Fr(s,this.top+w+u,this.bottom-n[p.line].height));const O=l.x(M);if(g(O,T,S),M=Nme(_,M+m+h,v?M+R:this.right,t.rtl),x(l.x(M),T,S),v)p.x+=R+u;else if(typeof S.text!="string"){const I=c.lineHeight;p.y+=$7(S,I)+u}else p.y+=C}),p7(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,r=ar(n.font),o=Mr(n.padding);if(!n.display)return;const s=lf(t.rtl,this.left,this.width),i=this.ctx,a=n.position,l=r.size/2,c=o.top+l;let u,f=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),u=this.top+c,f=Fr(t.align,f,this.right-h);else{const m=this.columnSizes.reduce((b,y)=>Math.max(b,y.height),0);u=c+Fr(t.align,this.top,this.bottom-m-t.labels.padding-this._computeTitleHeight())}const p=Fr(a,f,f+h);i.textAlign=s.textAlign(eR(a)),i.textBaseline="middle",i.strokeStyle=n.color,i.fillStyle=n.color,i.font=r.string,Au(i,n.text,p,u,r)}_computeTitleHeight(){const t=this.options.title,n=ar(t.font),r=Mr(t.padding);return t.display?n.lineHeight+r.height:0}_getLegendItemAt(t,n){let r,o,s;if(_a(t,this.left,this.right)&&_a(n,this.top,this.bottom)){for(s=this.legendHitBoxes,r=0;r<s.length;++r)if(o=s[r],_a(t,o.left,o.left+o.width)&&_a(n,o.top,o.top+o.height))return this.legendItems[r]}return null}handleEvent(t){const n=this.options;if(!l0e(t.type,n))return;const r=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const o=this._hoveredItem,s=o0e(o,r);o&&!s&&sn(n.onLeave,[t,o,this],this),this._hoveredItem=r,r&&!s&&sn(n.onHover,[t,r,this],this)}else r&&sn(n.onClick,[t,r,this],this)}}function s0e(e,t,n,r,o){const s=i0e(r,e,t,n),i=a0e(o,r,t.lineHeight);return{itemWidth:s,itemHeight:i}}function i0e(e,t,n,r){let o=e.text;return o&&typeof o!="string"&&(o=o.reduce((s,i)=>s.length>i.length?s:i)),t+n.size/2+r.measureText(o).width}function a0e(e,t,n){let r=e;return typeof t.text!="string"&&(r=$7(t,n)),r}function $7(e,t){const n=e.text?e.text.length:0;return t*n}function l0e(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var c0e={id:"legend",_element:zI,start(e,t,n){const r=e.legend=new zI({ctx:e.ctx,options:n,chart:e});Br.configure(e,r,n),Br.addBox(e,r)},stop(e){Br.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const r=e.legend;Br.configure(e,r,n),r.options=n},afterUpdate(e){const t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){const r=t.datasetIndex,o=n.chart;o.isDatasetVisible(r)?(o.hide(r),t.hidden=!0):(o.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:o,color:s,useBorderRadius:i,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(n?0:void 0),u=Mr(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:s,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(u.width+u.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:o||c.textAlign,borderRadius:i&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:e=>!e.startsWith("on"),labels:{_scriptable:e=>!["generateLabels","filter","sort"].includes(e)}}};let uR=class extends sa{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n){const r=this.options;if(this.left=0,this.top=0,!r.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=n;const o=Cn(r.text)?r.text.length:1;this._padding=Mr(r.padding);const s=o*ar(r.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=s:this.width=s}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:n,left:r,bottom:o,right:s,options:i}=this,a=i.align;let l=0,c,u,f;return this.isHorizontal()?(u=Fr(a,r,s),f=n+t,c=s-r):(i.position==="left"?(u=r+t,f=Fr(a,o,n),l=_n*-.5):(u=s-t,f=Fr(a,n,o),l=_n*.5),c=o-n),{titleX:u,titleY:f,maxWidth:c,rotation:l}}draw(){const t=this.ctx,n=this.options;if(!n.display)return;const r=ar(n.font),s=r.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(s);Au(t,n.text,0,0,r,{color:n.color,maxWidth:l,rotation:c,textAlign:eR(n.align),textBaseline:"middle",translation:[i,a]})}};function u0e(e,t){const n=new uR({ctx:e.ctx,options:t,chart:e});Br.configure(e,n,t),Br.addBox(e,n),e.titleBlock=n}var d0e={id:"title",_element:uR,start(e,t,n){u0e(e,n)},stop(e){const t=e.titleBlock;Br.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){const r=e.titleBlock;Br.configure(e,r,n),r.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const wy=new WeakMap;var f0e={id:"subtitle",start(e,t,n){const r=new uR({ctx:e.ctx,options:n,chart:e});Br.configure(e,r,n),Br.addBox(e,r),wy.set(e,r)},stop(e){Br.removeBox(e,wy.get(e)),wy.delete(e)},beforeUpdate(e,t,n){const r=wy.get(e);Br.configure(e,r,n),r.options=n},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const xp={average(e){if(!e.length)return!1;let t,n,r=new Set,o=0,s=0;for(t=0,n=e.length;t<n;++t){const a=e[t].element;if(a&&a.hasValue()){const l=a.tooltipPosition();r.add(l.x),o+=l.y,++s}}return s===0||r.size===0?!1:{x:[...r].reduce((a,l)=>a+l)/r.size,y:o/s}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,o=Number.POSITIVE_INFINITY,s,i,a;for(s=0,i=e.length;s<i;++s){const l=e[s].element;if(l&&l.hasValue()){const c=l.getCenterPoint(),u=iN(t,c);u<o&&(o=u,a=l)}}if(a){const l=a.tooltipPosition();n=l.x,r=l.y}return{x:n,y:r}}};function mi(e,t){return t&&(Cn(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function ma(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(`
698
698
  `)>-1?e.split(`
699
- `):e}function h0e(e,t){const{element:n,datasetIndex:r,index:o}=t,s=e.getDatasetMeta(r).controller,{label:i,value:a}=s.getLabelAndValue(o);return{chart:e,label:i,parsed:s.getParsed(o),raw:e.data.datasets[r].data[o],formattedValue:a,dataset:s.getDataset(),dataIndex:o,datasetIndex:r,element:n}}function BI(e,t){const n=e.chart.ctx,{body:r,footer:o,title:s}=e,{boxWidth:i,boxHeight:a}=t,l=ar(t.bodyFont),c=ar(t.titleFont),u=ar(t.footerFont),f=s.length,h=o.length,p=r.length,m=Mr(t.padding);let b=m.height,y=0,g=r.reduce((w,C)=>w+C.before.length+C.lines.length+C.after.length,0);if(g+=e.beforeBody.length+e.afterBody.length,f&&(b+=f*c.lineHeight+(f-1)*t.titleSpacing+t.titleMarginBottom),g){const w=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;b+=p*w+(g-p)*l.lineHeight+(g-1)*t.bodySpacing}h&&(b+=t.footerMarginTop+h*u.lineHeight+(h-1)*t.footerSpacing);let x=0;const v=function(w){y=Math.max(y,n.measureText(w).width+x)};return n.save(),n.font=c.string,Xt(e.title,v),n.font=l.string,Xt(e.beforeBody.concat(e.afterBody),v),x=t.displayColors?i+2+t.boxPadding:0,Xt(r,w=>{Xt(w.before,v),Xt(w.lines,v),Xt(w.after,v)}),x=0,n.font=u.string,Xt(e.footer,v),n.restore(),y+=m.width,{width:y,height:b}}function p0e(e,t){const{y:n,height:r}=t;return n<r/2?"top":n>e.height-r/2?"bottom":"center"}function m0e(e,t,n,r){const{x:o,width:s}=r,i=n.caretSize+n.caretPadding;if(e==="left"&&o+s+i>t.width||e==="right"&&o-s-i<0)return!0}function g0e(e,t,n,r){const{x:o,width:s}=n,{width:i,chartArea:{left:a,right:l}}=e;let c="center";return r==="center"?c=o<=(a+l)/2?"left":"right":o<=s/2?c="left":o>=i-s/2&&(c="right"),m0e(c,e,t,n)&&(c="center"),c}function VI(e,t,n){const r=n.yAlign||t.yAlign||p0e(e,n);return{xAlign:n.xAlign||t.xAlign||g0e(e,t,n,r),yAlign:r}}function b0e(e,t){let{x:n,width:r}=e;return t==="right"?n-=r:t==="center"&&(n-=r/2),n}function y0e(e,t,n){let{y:r,height:o}=e;return t==="top"?r+=n:t==="bottom"?r-=o+n:r-=o/2,r}function HI(e,t,n,r){const{caretSize:o,caretPadding:s,cornerRadius:i}=e,{xAlign:a,yAlign:l}=n,c=o+s,{topLeft:u,topRight:f,bottomLeft:h,bottomRight:p}=pu(i);let m=b0e(t,a);const b=y0e(t,l,c);return l==="center"?a==="left"?m+=c:a==="right"&&(m-=c):a==="left"?m-=Math.max(u,h)+o:a==="right"&&(m+=Math.max(f,p)+o),{x:wr(m,0,r.width-t.width),y:wr(b,0,r.height-t.height)}}function Sy(e,t,n){const r=Mr(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-r.right:e.x+r.left}function UI(e){return mi([],ma(e))}function x0e(e,t,n){return ac(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function WI(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const L7={beforeTitle:ua,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(r>0&&t.dataIndex<r)return n[t.dataIndex]}return""},afterTitle:ua,beforeBody:ua,beforeLabel:ua,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return pt(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:ua,afterBody:ua,beforeFooter:ua,footer:ua,afterFooter:ua};function po(e,t,n,r){const o=e[t].call(n,r);return typeof o>"u"?L7[t].call(n,r):o}var LE;let qI=(LE=class extends sa{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,r=this.options.setContext(this.getContext()),o=r.enabled&&n.options.animation&&r.animations,s=new y7(this.chart,o);return o._cacheable&&(this._cachedAnimations=Object.freeze(s)),s}getContext(){return this.$context||(this.$context=x0e(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:r}=n,o=po(r,"beforeTitle",this,t),s=po(r,"title",this,t),i=po(r,"afterTitle",this,t);let a=[];return a=mi(a,ma(o)),a=mi(a,ma(s)),a=mi(a,ma(i)),a}getBeforeBody(t,n){return UI(po(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:r}=n,o=[];return Xt(t,s=>{const i={before:[],lines:[],after:[]},a=WI(r,s);mi(i.before,ma(po(a,"beforeLabel",this,s))),mi(i.lines,po(a,"label",this,s)),mi(i.after,ma(po(a,"afterLabel",this,s))),o.push(i)}),o}getAfterBody(t,n){return UI(po(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:r}=n,o=po(r,"beforeFooter",this,t),s=po(r,"footer",this,t),i=po(r,"afterFooter",this,t);let a=[];return a=mi(a,ma(o)),a=mi(a,ma(s)),a=mi(a,ma(i)),a}_createItems(t){const n=this._active,r=this.chart.data,o=[],s=[],i=[];let a=[],l,c;for(l=0,c=n.length;l<c;++l)a.push(h0e(this.chart,n[l]));return t.filter&&(a=a.filter((u,f,h)=>t.filter(u,f,h,r))),t.itemSort&&(a=a.sort((u,f)=>t.itemSort(u,f,r))),Xt(a,u=>{const f=WI(t.callbacks,u);o.push(po(f,"labelColor",this,u)),s.push(po(f,"labelPointStyle",this,u)),i.push(po(f,"labelTextColor",this,u))}),this.labelColors=o,this.labelPointStyles=s,this.labelTextColors=i,this.dataPoints=a,a}update(t,n){const r=this.options.setContext(this.getContext()),o=this._active;let s,i=[];if(!o.length)this.opacity!==0&&(s={opacity:0});else{const a=xp[r.position].call(this,o,this._eventPosition);i=this._createItems(r),this.title=this.getTitle(i,r),this.beforeBody=this.getBeforeBody(i,r),this.body=this.getBody(i,r),this.afterBody=this.getAfterBody(i,r),this.footer=this.getFooter(i,r);const l=this._size=BI(this,r),c=Object.assign({},a,l),u=VI(this.chart,r,c),f=HI(r,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,s={opacity:1,x:f.x,y:f.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=i,this.$context=void 0,s&&this._resolveAnimations().update(this,s),t&&r.external&&r.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,r,o){const s=this.getCaretPosition(t,r,o);n.lineTo(s.x1,s.y1),n.lineTo(s.x2,s.y2),n.lineTo(s.x3,s.y3)}getCaretPosition(t,n,r){const{xAlign:o,yAlign:s}=this,{caretSize:i,cornerRadius:a}=r,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:f}=pu(a),{x:h,y:p}=t,{width:m,height:b}=n;let y,g,x,v,w,C;return s==="center"?(w=p+b/2,o==="left"?(y=h,g=y-i,v=w+i,C=w-i):(y=h+m,g=y+i,v=w-i,C=w+i),x=y):(o==="left"?g=h+Math.max(l,u)+i:o==="right"?g=h+m-Math.max(c,f)-i:g=this.caretX,s==="top"?(v=p,w=v-i,y=g-i,x=g+i):(v=p+b,w=v+i,y=g+i,x=g-i),C=v),{x1:y,x2:g,x3:x,y1:v,y2:w,y3:C}}drawTitle(t,n,r){const o=this.title,s=o.length;let i,a,l;if(s){const c=lf(r.rtl,this.x,this.width);for(t.x=Sy(this,r.titleAlign,r),n.textAlign=c.textAlign(r.titleAlign),n.textBaseline="middle",i=ar(r.titleFont),a=r.titleSpacing,n.fillStyle=r.titleColor,n.font=i.string,l=0;l<s;++l)n.fillText(o[l],c.x(t.x),t.y+i.lineHeight/2),t.y+=i.lineHeight+a,l+1===s&&(t.y+=r.titleMarginBottom-a)}}_drawColorBox(t,n,r,o,s){const i=this.labelColors[r],a=this.labelPointStyles[r],{boxHeight:l,boxWidth:c}=s,u=ar(s.bodyFont),f=Sy(this,"left",s),h=o.x(f),p=l<u.lineHeight?(u.lineHeight-l)/2:0,m=n.y+p;if(s.usePointStyle){const b={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},y=o.leftForLtr(h,c)+c/2,g=m+l/2;t.strokeStyle=s.multiKeyBackground,t.fillStyle=s.multiKeyBackground,vx(t,b,y,g),t.strokeStyle=i.borderColor,t.fillStyle=i.backgroundColor,vx(t,b,y,g)}else{t.lineWidth=_t(i.borderWidth)?Math.max(...Object.values(i.borderWidth)):i.borderWidth||1,t.strokeStyle=i.borderColor,t.setLineDash(i.borderDash||[]),t.lineDashOffset=i.borderDashOffset||0;const b=o.leftForLtr(h,c),y=o.leftForLtr(o.xPlus(h,1),c-2),g=pu(i.borderRadius);Object.values(g).some(x=>x!==0)?(t.beginPath(),t.fillStyle=s.multiKeyBackground,Pm(t,{x:b,y:m,w:c,h:l,radius:g}),t.fill(),t.stroke(),t.fillStyle=i.backgroundColor,t.beginPath(),Pm(t,{x:y,y:m+1,w:c-2,h:l-2,radius:g}),t.fill()):(t.fillStyle=s.multiKeyBackground,t.fillRect(b,m,c,l),t.strokeRect(b,m,c,l),t.fillStyle=i.backgroundColor,t.fillRect(y,m+1,c-2,l-2))}t.fillStyle=this.labelTextColors[r]}drawBody(t,n,r){const{body:o}=this,{bodySpacing:s,bodyAlign:i,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=r,f=ar(r.bodyFont);let h=f.lineHeight,p=0;const m=lf(r.rtl,this.x,this.width),b=function(j){n.fillText(j,m.x(t.x+p),t.y+h/2),t.y+=h+s},y=m.textAlign(i);let g,x,v,w,C,S,N;for(n.textAlign=i,n.textBaseline="middle",n.font=f.string,t.x=Sy(this,y,r),n.fillStyle=r.bodyColor,Xt(this.beforeBody,b),p=a&&y!=="right"?i==="center"?c/2+u:c+2+u:0,w=0,S=o.length;w<S;++w){for(g=o[w],x=this.labelTextColors[w],n.fillStyle=x,Xt(g.before,b),v=g.lines,a&&v.length&&(this._drawColorBox(n,t,w,m,r),h=Math.max(f.lineHeight,l)),C=0,N=v.length;C<N;++C)b(v[C]),h=f.lineHeight;Xt(g.after,b)}p=0,h=f.lineHeight,Xt(this.afterBody,b),t.y-=s}drawFooter(t,n,r){const o=this.footer,s=o.length;let i,a;if(s){const l=lf(r.rtl,this.x,this.width);for(t.x=Sy(this,r.footerAlign,r),t.y+=r.footerMarginTop,n.textAlign=l.textAlign(r.footerAlign),n.textBaseline="middle",i=ar(r.footerFont),n.fillStyle=r.footerColor,n.font=i.string,a=0;a<s;++a)n.fillText(o[a],l.x(t.x),t.y+i.lineHeight/2),t.y+=i.lineHeight+r.footerSpacing}}drawBackground(t,n,r,o){const{xAlign:s,yAlign:i}=this,{x:a,y:l}=t,{width:c,height:u}=r,{topLeft:f,topRight:h,bottomLeft:p,bottomRight:m}=pu(o.cornerRadius);n.fillStyle=o.backgroundColor,n.strokeStyle=o.borderColor,n.lineWidth=o.borderWidth,n.beginPath(),n.moveTo(a+f,l),i==="top"&&this.drawCaret(t,n,r,o),n.lineTo(a+c-h,l),n.quadraticCurveTo(a+c,l,a+c,l+h),i==="center"&&s==="right"&&this.drawCaret(t,n,r,o),n.lineTo(a+c,l+u-m),n.quadraticCurveTo(a+c,l+u,a+c-m,l+u),i==="bottom"&&this.drawCaret(t,n,r,o),n.lineTo(a+p,l+u),n.quadraticCurveTo(a,l+u,a,l+u-p),i==="center"&&s==="left"&&this.drawCaret(t,n,r,o),n.lineTo(a,l+f),n.quadraticCurveTo(a,l,a+f,l),n.closePath(),n.fill(),o.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,r=this.$animations,o=r&&r.x,s=r&&r.y;if(o||s){const i=xp[t.position].call(this,this._active,this._eventPosition);if(!i)return;const a=this._size=BI(this,t),l=Object.assign({},i,this._size),c=VI(n,t,l),u=HI(t,l,c,n);(o._to!==u.x||s._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let r=this.opacity;if(!r)return;this._updateAnimationTarget(n);const o={width:this.width,height:this.height},s={x:this.x,y:this.y};r=Math.abs(r)<.001?0:r;const i=Mr(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=r,this.drawBackground(s,t,o,n),h7(t,n.textDirection),s.y+=i.top,this.drawTitle(s,t,n),this.drawBody(s,t,n),this.drawFooter(s,t,n),p7(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const r=this._active,o=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),s=!gx(r,o),i=this._positionChanged(o,n);(s||i)&&(this._active=o,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,r=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const o=this.options,s=this._active||[],i=this._getActiveElements(t,s,n,r),a=this._positionChanged(i,t),l=n||!gx(i,s)||a;return l&&(this._active=i,(o.enabled||o.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,r,o){const s=this.options;if(t.type==="mouseout")return[];if(!o)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const i=this.chart.getElementsAtEventForMode(t,s.mode,s,r);return s.reverse&&i.reverse(),i}_positionChanged(t,n){const{caretX:r,caretY:o,options:s}=this,i=xp[s.position].call(this,t,n);return i!==!1&&(r!==i.x||o!==i.y)}},ke(LE,"positioners",xp),LE);var z7={id:"tooltip",_element:qI,positioners:xp,afterInit(e,t,n){n&&(e.tooltip=new qI({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:L7},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},v0e=Object.freeze({__proto__:null,Colors:Pye,Decimation:Fye,Filler:r0e,Legend:c0e,SubTitle:f0e,Title:d0e,Tooltip:z7});const w0e=(e,t,n,r)=>(typeof t=="string"?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function S0e(e,t,n,r){const o=e.indexOf(t);if(o===-1)return w0e(e,t,n,r);const s=e.lastIndexOf(t);return o!==s?n:o}const C0e=(e,t)=>e===null?null:wr(Math.round(e),0,t);function GI(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class Im extends lc{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const r=this.getLabels();for(const{index:o,label:s}of n)r[o]===s&&r.splice(o,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(pt(t))return null;const r=this.getLabels();return n=isFinite(n)&&r[n]===t?n:S0e(r,t,rt(n,t),this._addedLabels),C0e(n,r.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:r,max:o}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(r=0),n||(o=this.getLabels().length-1)),this.min=r,this.max=o}buildTicks(){const t=this.min,n=this.max,r=this.options.offset,o=[];let s=this.getLabels();s=t===0&&n===s.length-1?s:s.slice(t,n+1),this._valueRange=Math.max(s.length-(r?0:1),1),this._startValue=this.min-(r?.5:0);for(let i=t;i<=n;i++)o.push({value:i});return o}getLabelForValue(t){return GI.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}ke(Im,"id","category"),ke(Im,"defaults",{ticks:{callback:GI}});function E0e(e,t){const n=[],{bounds:o,step:s,min:i,max:a,precision:l,count:c,maxTicks:u,maxDigits:f,includeBounds:h}=e,p=s||1,m=u-1,{min:b,max:y}=t,g=!pt(i),x=!pt(a),v=!pt(c),w=(y-b)/(f+1);let C=BA((y-b)/m/p)*p,S,N,j,_;if(C<1e-14&&!g&&!x)return[{value:b},{value:y}];_=Math.ceil(y/C)-Math.floor(b/C),_>m&&(C=BA(_*C/m/p)*p),pt(l)||(S=Math.pow(10,l),C=Math.ceil(C*S)/S),o==="ticks"?(N=Math.floor(b/C)*C,j=Math.ceil(y/C)*C):(N=b,j=y),g&&x&&s&&yme((a-i)/s,C/1e3)?(_=Math.round(Math.min((a-i)/C,u)),C=(a-i)/_,N=i,j=a):v?(N=g?i:N,j=x?a:j,_=c-1,C=(j-N)/_):(_=(j-N)/C,Gp(_,Math.round(_),C/1e3)?_=Math.round(_):_=Math.ceil(_));const R=Math.max(VA(C),VA(N));S=Math.pow(10,pt(l)?R:l),N=Math.round(N*S)/S,j=Math.round(j*S)/S;let M=0;for(g&&(h&&N!==i?(n.push({value:i}),N<i&&M++,Gp(Math.round((N+M*C)*S)/S,i,YI(i,w,e))&&M++):N<i&&M++);M<_;++M){const T=Math.round((N+M*C)*S)/S;if(x&&T>a)break;n.push({value:T})}return x&&h&&j!==a?n.length&&Gp(n[n.length-1].value,a,YI(a,w,e))?n[n.length-1].value=a:n.push({value:a}):(!x||j===a)&&n.push({value:j}),n}function YI(e,t,{horizontal:n,minRotation:r}){const o=qs(r),s=(n?Math.sin(o):Math.cos(o))||.001,i=.75*t*(""+e).length;return Math.min(t/s,i)}class Ex extends lc{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return pt(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:r}=this.getUserBounds();let{min:o,max:s}=this;const i=l=>o=n?o:l,a=l=>s=r?s:l;if(t){const l=Di(o),c=Di(s);l<0&&c<0?a(0):l>0&&c>0&&i(0)}if(o===s){let l=s===0?1:Math.abs(s*.05);a(s+l),t||i(o-l)}this.min=o,this.max=s}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:r}=t,o;return r?(o=Math.ceil(this.max/r)-Math.floor(this.min/r)+1,o>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${r} would result generating up to ${o} ticks. Limiting to 1000.`),o=1e3)):(o=this.computeTickLimit(),n=n||11),n&&(o=Math.min(n,o)),o}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let r=this.getTickLimit();r=Math.max(2,r);const o={maxTicks:r,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},s=this._range||this,i=E0e(o,s);return t.bounds==="ticks"&&K9(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}configure(){const t=this.ticks;let n=this.min,r=this.max;if(super.configure(),this.options.offset&&t.length){const o=(r-n)/Math.max(t.length-1,1)/2;n-=o,r+=o}this._startValue=n,this._endValue=r,this._valueRange=r-n}getLabelForValue(t){return Yg(t,this.chart.options.locale,this.options.ticks.format)}}class Iu extends Ex{determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Wn(t)?t:0,this.max=Wn(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,r=qs(this.options.ticks.minRotation),o=(t?Math.sin(r):Math.cos(r))||.001,s=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,s.lineHeight/o))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}ke(Iu,"id","linear"),ke(Iu,"defaults",{ticks:{callback:Nw.formatters.numeric}});const Om=e=>Math.floor(_l(e)),Cc=(e,t)=>Math.pow(10,Om(e)+t);function ZI(e){return e/Math.pow(10,Om(e))===1}function KI(e,t,n){const r=Math.pow(10,n),o=Math.floor(e/r);return Math.ceil(t/r)-o}function N0e(e,t){const n=t-e;let r=Om(n);for(;KI(e,t,r)>10;)r++;for(;KI(e,t,r)<10;)r--;return Math.min(r,Om(e))}function k0e(e,{min:t,max:n}){t=Po(e.min,t);const r=[],o=Om(t);let s=N0e(t,n),i=s<0?Math.pow(10,Math.abs(s)):1;const a=Math.pow(10,s),l=o>s?Math.pow(10,o):0,c=Math.round((t-l)*i)/i,u=Math.floor((t-l)/a/10)*a*10;let f=Math.floor((c-u)/Math.pow(10,s)),h=Po(e.min,Math.round((l+u+f*Math.pow(10,s))*i)/i);for(;h<n;)r.push({value:h,major:ZI(h),significand:f}),f>=10?f=f<15?15:20:f++,f>=20&&(s++,f=2,i=s>=0?1:i),h=Math.round((l+u+f*Math.pow(10,s))*i)/i;const p=Po(e.max,h);return r.push({value:p,major:ZI(p),significand:f}),r}class qf extends lc{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,n){const r=Ex.prototype.parse.apply(this,[t,n]);if(r===0){this._zero=!0;return}return Wn(r)&&r>0?r:null}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Wn(t)?Math.max(0,t):null,this.max=Wn(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Wn(this._userMin)&&(this.min=t===Cc(this.min,0)?Cc(this.min,-1):Cc(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let r=this.min,o=this.max;const s=a=>r=t?r:a,i=a=>o=n?o:a;r===o&&(r<=0?(s(1),i(10)):(s(Cc(r,-1)),i(Cc(o,1)))),r<=0&&s(Cc(o,-1)),o<=0&&i(Cc(r,1)),this.min=r,this.max=o}buildTicks(){const t=this.options,n={min:this._userMin,max:this._userMax},r=k0e(n,this);return t.bounds==="ticks"&&K9(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}getLabelForValue(t){return t===void 0?"0":Yg(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=_l(t),this._valueRange=_l(this.max)-_l(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(_l(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const n=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+n*this._valueRange)}}ke(qf,"id","logarithmic"),ke(qf,"defaults",{ticks:{callback:Nw.formatters.logarithmic,major:{enabled:!0}}});function pN(e){const t=e.ticks;if(t.display&&e.display){const n=Mr(t.backdropPadding);return rt(t.font&&t.font.size,kn.font.size)+n.height}return 0}function _0e(e,t,n){return n=Cn(n)?n:[n],{w:Ime(e,t.string,n),h:n.length*t.lineHeight}}function XI(e,t,n,r,o){return e===r||e===o?{start:t-n/2,end:t+n/2}:e<r||e>o?{start:t-n,end:t}:{start:t,end:t+n}}function j0e(e){const t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],o=[],s=e._pointLabels.length,i=e.options.pointLabels,a=i.centerPointLabels?_n/s:0;for(let l=0;l<s;l++){const c=i.setContext(e.getPointLabelContext(l));o[l]=c.padding;const u=e.getPointPosition(l,e.drawingArea+o[l],a),f=ar(c.font),h=_0e(e.ctx,f,e._pointLabels[l]);r[l]=h;const p=Oo(e.getIndexAngle(l)+a),m=Math.round(Qj(p)),b=XI(m,u.x,h.w,0,180),y=XI(m,u.y,h.h,90,270);R0e(n,t,p,b,y)}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=T0e(e,r,o)}function R0e(e,t,n,r,o){const s=Math.abs(Math.sin(n)),i=Math.abs(Math.cos(n));let a=0,l=0;r.start<t.l?(a=(t.l-r.start)/s,e.l=Math.min(e.l,t.l-a)):r.end>t.r&&(a=(r.end-t.r)/s,e.r=Math.max(e.r,t.r+a)),o.start<t.t?(l=(t.t-o.start)/i,e.t=Math.min(e.t,t.t-l)):o.end>t.b&&(l=(o.end-t.b)/i,e.b=Math.max(e.b,t.b+l))}function M0e(e,t,n){const r=e.drawingArea,{extra:o,additionalAngle:s,padding:i,size:a}=n,l=e.getPointPosition(t,r+o+i,s),c=Math.round(Qj(Oo(l.angle+Qn))),u=I0e(l.y,a.h,c),f=P0e(c),h=A0e(l.x,a.w,f);return{visible:!0,x:l.x,y:u,textAlign:f,left:h,top:u,right:h+a.w,bottom:u+a.h}}function D0e(e,t){if(!t)return!0;const{left:n,top:r,right:o,bottom:s}=e;return!(Ra({x:n,y:r},t)||Ra({x:n,y:s},t)||Ra({x:o,y:r},t)||Ra({x:o,y:s},t))}function T0e(e,t,n){const r=[],o=e._pointLabels.length,s=e.options,{centerPointLabels:i,display:a}=s.pointLabels,l={extra:pN(s)/2,additionalAngle:i?_n/o:0};let c;for(let u=0;u<o;u++){l.padding=n[u],l.size=t[u];const f=M0e(e,u,l);r.push(f),a==="auto"&&(f.visible=D0e(f,c),f.visible&&(c=f))}return r}function P0e(e){return e===0||e===180?"center":e<180?"left":"right"}function A0e(e,t,n){return n==="right"?e-=t:n==="center"&&(e-=t/2),e}function I0e(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function O0e(e,t,n){const{left:r,top:o,right:s,bottom:i}=n,{backdropColor:a}=t;if(!pt(a)){const l=pu(t.borderRadius),c=Mr(t.backdropPadding);e.fillStyle=a;const u=r-c.left,f=o-c.top,h=s-r+c.width,p=i-o+c.height;Object.values(l).some(m=>m!==0)?(e.beginPath(),Pm(e,{x:u,y:f,w:h,h:p,radius:l}),e.fill()):e.fillRect(u,f,h,p)}}function F0e(e,t){const{ctx:n,options:{pointLabels:r}}=e;for(let o=t-1;o>=0;o--){const s=e._pointLabelItems[o];if(!s.visible)continue;const i=r.setContext(e.getPointLabelContext(o));O0e(n,i,s);const a=ar(i.font),{x:l,y:c,textAlign:u}=s;Au(n,e._pointLabels[o],l,c+a.lineHeight/2,a,{color:i.color,textAlign:u,textBaseline:"middle"})}}function B7(e,t,n,r){const{ctx:o}=e;if(n)o.arc(e.xCenter,e.yCenter,t,0,Nn);else{let s=e.getPointPosition(0,t);o.moveTo(s.x,s.y);for(let i=1;i<r;i++)s=e.getPointPosition(i,t),o.lineTo(s.x,s.y)}}function $0e(e,t,n,r,o){const s=e.ctx,i=t.circular,{color:a,lineWidth:l}=t;!i&&!r||!a||!l||n<0||(s.save(),s.strokeStyle=a,s.lineWidth=l,s.setLineDash(o.dash||[]),s.lineDashOffset=o.dashOffset,s.beginPath(),B7(e,n,i,r),s.closePath(),s.stroke(),s.restore())}function L0e(e,t,n){return ac(e,{label:n,index:t,type:"pointLabel"})}class vp extends Ex{constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=Mr(pN(this.options)/2),n=this.width=this.maxWidth-t.width,r=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+n/2+t.left),this.yCenter=Math.floor(this.top+r/2+t.top),this.drawingArea=Math.floor(Math.min(n,r)/2)}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!1);this.min=Wn(t)&&!isNaN(t)?t:0,this.max=Wn(n)&&!isNaN(n)?n:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/pN(this.options))}generateTickLabels(t){Ex.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((n,r)=>{const o=sn(this.options.pointLabels.callback,[n,r],this);return o||o===0?o:""}).filter((n,r)=>this.chart.getDataVisibility(r))}fit(){const t=this.options;t.display&&t.pointLabels.display?j0e(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,n,r,o){this.xCenter+=Math.floor((t-n)/2),this.yCenter+=Math.floor((r-o)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,n,r,o))}getIndexAngle(t){const n=Nn/(this._pointLabels.length||1),r=this.options.startAngle||0;return Oo(t*n+qs(r))}getDistanceFromCenterForValue(t){if(pt(t))return NaN;const n=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*n:(t-this.min)*n}getValueForDistanceFromCenter(t){if(pt(t))return NaN;const n=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-n:this.min+n}getPointLabelContext(t){const n=this._pointLabels||[];if(t>=0&&t<n.length){const r=n[t];return L0e(this.getContext(),t,r)}}getPointPosition(t,n,r=0){const o=this.getIndexAngle(t)-Qn+r;return{x:Math.cos(o)*n+this.xCenter,y:Math.sin(o)*n+this.yCenter,angle:o}}getPointPositionForValue(t,n){return this.getPointPosition(t,this.getDistanceFromCenterForValue(n))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:n,top:r,right:o,bottom:s}=this._pointLabelItems[t];return{left:n,top:r,right:o,bottom:s}}drawBackground(){const{backgroundColor:t,grid:{circular:n}}=this.options;if(t){const r=this.ctx;r.save(),r.beginPath(),B7(this,this.getDistanceFromCenterForValue(this._endValue),n,this._pointLabels.length),r.closePath(),r.fillStyle=t,r.fill(),r.restore()}}drawGrid(){const t=this.ctx,n=this.options,{angleLines:r,grid:o,border:s}=n,i=this._pointLabels.length;let a,l,c;if(n.pointLabels.display&&F0e(this,i),o.display&&this.ticks.forEach((u,f)=>{if(f!==0||f===0&&this.min<0){l=this.getDistanceFromCenterForValue(u.value);const h=this.getContext(f),p=o.setContext(h),m=s.setContext(h);$0e(this,p,l,i,m)}}),r.display){for(t.save(),a=i-1;a>=0;a--){const u=r.setContext(this.getPointLabelContext(a)),{color:f,lineWidth:h}=u;!h||!f||(t.lineWidth=h,t.strokeStyle=f,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,l=this.getDistanceFromCenterForValue(n.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,n=this.options,r=n.ticks;if(!r.display)return;const o=this.getIndexAngle(0);let s,i;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(o),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!n.reverse)return;const c=r.setContext(this.getContext(l)),u=ar(c.font);if(s=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=u.string,i=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const f=Mr(c.backdropPadding);t.fillRect(-i/2-f.left,-s-u.size/2-f.top,i+f.width,u.size+f.height)}Au(t,a.label,0,-s,u,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}ke(vp,"id","radialLinear"),ke(vp,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Nw.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),ke(vp,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),ke(vp,"descriptors",{angleLines:{_fallback:"grid"}});const jw={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Co=Object.keys(jw);function QI(e,t){return e-t}function JI(e,t){if(pt(t))return null;const n=e._adapter,{parser:r,round:o,isoWeekday:s}=e._parseOpts;let i=t;return typeof r=="function"&&(i=r(i)),Wn(i)||(i=typeof r=="string"?n.parse(i,r):n.parse(i)),i===null?null:(o&&(i=o==="week"&&(Hf(s)||s===!0)?n.startOf(i,"isoWeek",s):n.startOf(i,o)),+i)}function eO(e,t,n,r){const o=Co.length;for(let s=Co.indexOf(e);s<o-1;++s){const i=jw[Co[s]],a=i.steps?i.steps:Number.MAX_SAFE_INTEGER;if(i.common&&Math.ceil((n-t)/(a*i.size))<=r)return Co[s]}return Co[o-1]}function z0e(e,t,n,r,o){for(let s=Co.length-1;s>=Co.indexOf(n);s--){const i=Co[s];if(jw[i].common&&e._adapter.diff(o,r,i)>=t-1)return i}return Co[n?Co.indexOf(n):0]}function B0e(e){for(let t=Co.indexOf(e)+1,n=Co.length;t<n;++t)if(jw[Co[t]].common)return Co[t]}function tO(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:r,hi:o}=Jj(n,t),s=n[r]>=t?n[r]:n[o];e[s]=!0}}function V0e(e,t,n,r){const o=e._adapter,s=+o.startOf(t[0].value,r),i=t[t.length-1].value;let a,l;for(a=s;a<=i;a=+o.add(a,1,r))l=n[a],l>=0&&(t[l].major=!0);return t}function nO(e,t,n){const r=[],o={},s=t.length;let i,a;for(i=0;i<s;++i)a=t[i],o[a]=i,r.push({value:a,major:!1});return s===0||!n?r:V0e(e,r,o,n)}class Fm extends lc{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const r=t.time||(t.time={}),o=this._adapter=new Xge._date(t.adapters.date);o.init(n),qp(r.displayFormats,o.formats()),this._parseOpts={parser:r.parser,round:r.round,isoWeekday:r.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:JI(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,r=t.time.unit||"day";let{min:o,max:s,minDefined:i,maxDefined:a}=this.getUserBounds();function l(c){!i&&!isNaN(c.min)&&(o=Math.min(o,c.min)),!a&&!isNaN(c.max)&&(s=Math.max(s,c.max))}(!i||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),o=Wn(o)&&!isNaN(o)?o:+n.startOf(Date.now(),r),s=Wn(s)&&!isNaN(s)?s:+n.endOf(Date.now(),r)+1,this.min=Math.min(o,s-1),this.max=Math.max(o+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],r=t[t.length-1]),{min:n,max:r}}buildTicks(){const t=this.options,n=t.time,r=t.ticks,o=r.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&o.length&&(this.min=this._userMin||o[0],this.max=this._userMax||o[o.length-1]);const s=this.min,i=this.max,a=Sme(o,s,i);return this._unit=n.unit||(r.autoSkip?eO(n.minUnit,this.min,this.max,this._getLabelCapacity(s)):z0e(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!r.major.enabled||this._unit==="year"?void 0:B0e(this._unit),this.initOffsets(o),t.reverse&&a.reverse(),nO(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,r=0,o,s;this.options.offset&&t.length&&(o=this.getDecimalForValue(t[0]),t.length===1?n=1-o:n=(this.getDecimalForValue(t[1])-o)/2,s=this.getDecimalForValue(t[t.length-1]),t.length===1?r=s:r=(s-this.getDecimalForValue(t[t.length-2]))/2);const i=t.length<3?.5:.25;n=wr(n,0,i),r=wr(r,0,i),this._offsets={start:n,end:r,factor:1/(n+1+r)}}_generate(){const t=this._adapter,n=this.min,r=this.max,o=this.options,s=o.time,i=s.unit||eO(s.minUnit,n,r,this._getLabelCapacity(n)),a=rt(o.ticks.stepSize,1),l=i==="week"?s.isoWeekday:!1,c=Hf(l)||l===!0,u={};let f=n,h,p;if(c&&(f=+t.startOf(f,"isoWeek",l)),f=+t.startOf(f,c?"day":i),t.diff(r,n,i)>1e5*a)throw new Error(n+" and "+r+" are too far apart with stepSize of "+a+" "+i);const m=o.ticks.source==="data"&&this.getDataTimestamps();for(h=f,p=0;h<r;h=+t.add(h,a,i),p++)tO(u,h,m);return(h===r||o.bounds==="ticks"||p===1)&&tO(u,h,m),Object.keys(u).sort(QI).map(b=>+b)}getLabelForValue(t){const n=this._adapter,r=this.options.time;return r.tooltipFormat?n.format(t,r.tooltipFormat):n.format(t,r.displayFormats.datetime)}format(t,n){const o=this.options.time.displayFormats,s=this._unit,i=n||o[s];return this._adapter.format(t,i)}_tickFormatFunction(t,n,r,o){const s=this.options,i=s.ticks.callback;if(i)return sn(i,[t,n,r],this);const a=s.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],f=c&&a[c],h=r[n],p=c&&f&&h&&h.major;return this._adapter.format(t,o||(p?f:u))}generateTickLabels(t){let n,r,o;for(n=0,r=t.length;n<r;++n)o=t[n],o.label=this._tickFormatFunction(o.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,r=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+r)*n.factor)}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+r*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,r=this.ctx.measureText(t).width,o=qs(this.isHorizontal()?n.maxRotation:n.minRotation),s=Math.cos(o),i=Math.sin(o),a=this._resolveTickFontOptions(0).size;return{w:r*s+a*i,h:r*i+a*s}}_getLabelCapacity(t){const n=this.options.time,r=n.displayFormats,o=r[n.unit]||r.millisecond,s=this._tickFormatFunction(t,0,nO(this,[t],this._majorUnit),o),i=this._getLabelSize(s),a=Math.floor(this.isHorizontal()?this.width/i.w:this.height/i.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,r;if(t.length)return t;const o=this.getMatchingVisibleMetas();if(this._normalized&&o.length)return this._cache.data=o[0].controller.getAllParsedValues(this);for(n=0,r=o.length;n<r;++n)t=t.concat(o[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,r;if(t.length)return t;const o=this.getLabels();for(n=0,r=o.length;n<r;++n)t.push(JI(this,o[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return J9(t.sort(QI))}}ke(Fm,"id","time"),ke(Fm,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});function Cy(e,t,n){let r=0,o=e.length-1,s,i,a,l;n?(t>=e[r].pos&&t<=e[o].pos&&({lo:r,hi:o}=ja(e,"pos",t)),{pos:s,time:a}=e[r],{pos:i,time:l}=e[o]):(t>=e[r].time&&t<=e[o].time&&({lo:r,hi:o}=ja(e,"time",t)),{time:s,pos:a}=e[r],{time:i,pos:l}=e[o]);const c=i-s;return c?a+(l-a)*(t-s)/c:a}class mN extends Fm{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=Cy(n,this.min),this._tableRange=Cy(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:r}=this,o=[],s=[];let i,a,l,c,u;for(i=0,a=t.length;i<a;++i)c=t[i],c>=n&&c<=r&&o.push(c);if(o.length<2)return[{time:n,pos:0},{time:r,pos:1}];for(i=0,a=o.length;i<a;++i)u=o[i+1],l=o[i-1],c=o[i],Math.round((u+l)/2)!==c&&s.push({time:c,pos:i/(a-1)});return s}_generate(){const t=this.min,n=this.max;let r=super.getDataTimestamps();return(!r.includes(t)||!r.length)&&r.splice(0,0,t),(!r.includes(n)||r.length===1)&&r.push(n),r.sort((o,s)=>o-s)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),r=this.getLabelTimestamps();return n.length&&r.length?t=this.normalize(n.concat(r)):t=n.length?n:r,t=this._cache.all=t,t}getDecimalForValue(t){return(Cy(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return Cy(this._table,r*this._tableRange+this._minPos,!0)}}ke(mN,"id","timeseries"),ke(mN,"defaults",Fm.defaults);var H0e=Object.freeze({__proto__:null,CategoryScale:Im,LinearScale:Iu,LogarithmicScale:qf,RadialLinearScale:vp,TimeScale:Fm,TimeSeriesScale:mN});const U0e=[Kge,kye,v0e,H0e];class Wl{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const n=this._partials;let r=0;for(let o=0;o<this._n&&o<32;o++){const s=n[o],i=t+s,a=Math.abs(t)<Math.abs(s)?t-(i-s):s-(i-t);a&&(n[r++]=a),t=i}return n[r]=t,this._n=r+1,this}valueOf(){const t=this._partials;let n=this._n,r,o,s,i=0;if(n>0){for(i=t[--n];n>0&&(r=i,o=t[--n],i=r+o,s=o-(i-r),!s););n>0&&(s<0&&t[n-1]<0||s>0&&t[n-1]>0)&&(o=s*2,r=i+o,o==r-i&&(i=r))}return i}}function*W0e(e){for(const t of e)yield*t}function V7(e){return Array.from(W0e(e))}function Wd(e,t,n){e=+e,t=+t,n=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=Math.max(0,Math.ceil((t-e)/n))|0,s=new Array(o);++r<o;)s[r]=e+r*n;return s}var Je=1e-6,H7=1e-12,St=Math.PI,Un=St/2,rO=St/4,Zo=St*2,to=180/St,an=St/180,Ht=Math.abs,Ch=Math.atan,Hi=Math.atan2,ht=Math.cos,Ey=Math.ceil,U7=Math.exp,Nx=Math.log,pC=Math.pow,st=Math.sin,gs=Math.sign||function(e){return e>0?1:e<0?-1:0},ao=Math.sqrt,dR=Math.tan;function W7(e){return e>1?0:e<-1?St:Math.acos(e)}function _s(e){return e>1?Un:e<-1?-Un:Math.asin(e)}function xr(){}function kx(e,t){e&&sO.hasOwnProperty(e.type)&&sO[e.type](e,t)}var oO={Feature:function(e,t){kx(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,o=n.length;++r<o;)kx(n[r].geometry,t)}},sO={Sphere:function(e,t){t.sphere()},Point:function(e,t){e=e.coordinates,t.point(e[0],e[1],e[2])},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)e=n[r],t.point(e[0],e[1],e[2])},LineString:function(e,t){gN(e.coordinates,t,0)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)gN(n[r],t,0)},Polygon:function(e,t){iO(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)iO(n[r],t)},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,o=n.length;++r<o;)kx(n[r],t)}};function gN(e,t,n){var r=-1,o=e.length-n,s;for(t.lineStart();++r<o;)s=e[r],t.point(s[0],s[1],s[2]);t.lineEnd()}function iO(e,t){var n=-1,r=e.length;for(t.polygonStart();++n<r;)gN(e[n],t,1);t.polygonEnd()}function Fc(e,t){e&&oO.hasOwnProperty(e.type)?oO[e.type](e,t):kx(e,t)}function bN(e){return[Hi(e[1],e[0]),_s(e[2])]}function Gf(e){var t=e[0],n=e[1],r=ht(n);return[r*ht(t),r*st(t),st(n)]}function Ny(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function _x(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function mC(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function ky(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function yN(e){var t=ao(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}function xN(e,t){function n(r,o){return r=e(r,o),t(r[0],r[1])}return e.invert&&t.invert&&(n.invert=function(r,o){return r=t.invert(r,o),r&&e.invert(r[0],r[1])}),n}function vN(e,t){return Ht(e)>St&&(e-=Math.round(e/Zo)*Zo),[e,t]}vN.invert=vN;function q7(e,t,n){return(e%=Zo)?t||n?xN(lO(e),cO(t,n)):lO(e):t||n?cO(t,n):vN}function aO(e){return function(t,n){return t+=e,Ht(t)>St&&(t-=Math.round(t/Zo)*Zo),[t,n]}}function lO(e){var t=aO(e);return t.invert=aO(-e),t}function cO(e,t){var n=ht(e),r=st(e),o=ht(t),s=st(t);function i(a,l){var c=ht(l),u=ht(a)*c,f=st(a)*c,h=st(l),p=h*n+u*r;return[Hi(f*o-p*s,u*n-h*r),_s(p*o+f*s)]}return i.invert=function(a,l){var c=ht(l),u=ht(a)*c,f=st(a)*c,h=st(l),p=h*o-f*s;return[Hi(f*o+h*s,u*n+p*r),_s(p*n-u*r)]},i}function q0e(e){e=q7(e[0]*an,e[1]*an,e.length>2?e[2]*an:0);function t(n){return n=e(n[0]*an,n[1]*an),n[0]*=to,n[1]*=to,n}return t.invert=function(n){return n=e.invert(n[0]*an,n[1]*an),n[0]*=to,n[1]*=to,n},t}function G0e(e,t,n,r,o,s){if(n){var i=ht(t),a=st(t),l=r*n;o==null?(o=t+r*Zo,s=t-l/2):(o=uO(i,o),s=uO(i,s),(r>0?o<s:o>s)&&(o+=r*Zo));for(var c,u=o;r>0?u>s:u<s;u-=l)c=bN([i,-a*ht(u),-a*st(u)]),e.point(c[0],c[1])}}function uO(e,t){t=Gf(t),t[0]-=e,yN(t);var n=W7(-t[1]);return((-t[2]<0?-n:n)+Zo-Je)%Zo}function G7(){var e=[],t;return{point:function(n,r,o){t.push([n,r,o])},lineStart:function(){e.push(t=[])},lineEnd:xr,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function M0(e,t){return Ht(e[0]-t[0])<Je&&Ht(e[1]-t[1])<Je}function _y(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function Y7(e,t,n,r,o){var s=[],i=[],a,l;if(e.forEach(function(m){if(!((b=m.length-1)<=0)){var b,y=m[0],g=m[b],x;if(M0(y,g)){if(!y[2]&&!g[2]){for(o.lineStart(),a=0;a<b;++a)o.point((y=m[a])[0],y[1]);o.lineEnd();return}g[0]+=2*Je}s.push(x=new _y(y,m,null,!0)),i.push(x.o=new _y(y,null,x,!1)),s.push(x=new _y(g,m,null,!1)),i.push(x.o=new _y(g,null,x,!0))}}),!!s.length){for(i.sort(t),dO(s),dO(i),a=0,l=i.length;a<l;++a)i[a].e=n=!n;for(var c=s[0],u,f;;){for(var h=c,p=!0;h.v;)if((h=h.n)===c)return;u=h.z,o.lineStart();do{if(h.v=h.o.v=!0,h.e){if(p)for(a=0,l=u.length;a<l;++a)o.point((f=u[a])[0],f[1]);else r(h.x,h.n.x,1,o);h=h.n}else{if(p)for(u=h.p.z,a=u.length-1;a>=0;--a)o.point((f=u[a])[0],f[1]);else r(h.x,h.p.x,-1,o);h=h.p}h=h.o,u=h.z,p=!p}while(!h.v);o.lineEnd()}}}function dO(e){if(t=e.length){for(var t,n=0,r=e[0],o;++n<t;)r.n=o=e[n],o.p=r,r=o;r.n=o=e[0],o.p=r}}function gC(e){return Ht(e[0])<=St?e[0]:gs(e[0])*((Ht(e[0])+St)%Zo-St)}function Z7(e,t){var n=gC(t),r=t[1],o=st(r),s=[st(n),-ht(n),0],i=0,a=0,l=new Wl;o===1?r=Un+Je:o===-1&&(r=-Un-Je);for(var c=0,u=e.length;c<u;++c)if(h=(f=e[c]).length)for(var f,h,p=f[h-1],m=gC(p),b=p[1]/2+rO,y=st(b),g=ht(b),x=0;x<h;++x,m=w,y=S,g=N,p=v){var v=f[x],w=gC(v),C=v[1]/2+rO,S=st(C),N=ht(C),j=w-m,_=j>=0?1:-1,R=_*j,M=R>St,T=y*S;if(l.add(Hi(T*_*st(R),g*N+T*ht(R))),i+=M?j+_*Zo:j,M^m>=n^w>=n){var O=_x(Gf(p),Gf(v));yN(O);var I=_x(s,O);yN(I);var A=(M^j>=0?-1:1)*_s(I[2]);(r>A||r===A&&(O[0]||O[1]))&&(a+=M^j>=0?1:-1)}}return(i<-1e-6||i<Je&&l<-1e-12)^a&1}function K7(e,t,n,r){return function(o){var s=t(o),i=G7(),a=t(i),l=!1,c,u,f,h={point:p,lineStart:b,lineEnd:y,polygonStart:function(){h.point=g,h.lineStart=x,h.lineEnd=v,u=[],c=[]},polygonEnd:function(){h.point=p,h.lineStart=b,h.lineEnd=y,u=V7(u);var w=Z7(c,r);u.length?(l||(o.polygonStart(),l=!0),Y7(u,Z0e,w,n,o)):w&&(l||(o.polygonStart(),l=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),l&&(o.polygonEnd(),l=!1),u=c=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}};function p(w,C){e(w,C)&&o.point(w,C)}function m(w,C){s.point(w,C)}function b(){h.point=m,s.lineStart()}function y(){h.point=p,s.lineEnd()}function g(w,C){f.push([w,C]),a.point(w,C)}function x(){a.lineStart(),f=[]}function v(){g(f[0][0],f[0][1]),a.lineEnd();var w=a.clean(),C=i.result(),S,N=C.length,j,_,R;if(f.pop(),c.push(f),f=null,!!N){if(w&1){if(_=C[0],(j=_.length-1)>0){for(l||(o.polygonStart(),l=!0),o.lineStart(),S=0;S<j;++S)o.point((R=_[S])[0],R[1]);o.lineEnd()}return}N>1&&w&2&&C.push(C.pop().concat(C.shift())),u.push(C.filter(Y0e))}}return h}}function Y0e(e){return e.length>1}function Z0e(e,t){return((e=e.x)[0]<0?e[1]-Un-Je:Un-e[1])-((t=t.x)[0]<0?t[1]-Un-Je:Un-t[1])}const fO=K7(function(){return!0},K0e,Q0e,[-St,-Un]);function K0e(e){var t=NaN,n=NaN,r=NaN,o;return{lineStart:function(){e.lineStart(),o=1},point:function(s,i){var a=s>0?St:-St,l=Ht(s-t);Ht(l-St)<Je?(e.point(t,n=(n+i)/2>0?Un:-Un),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(a,n),e.point(s,n),o=0):r!==a&&l>=St&&(Ht(t-r)<Je&&(t-=r*Je),Ht(s-a)<Je&&(s-=a*Je),n=X0e(t,n,s,i),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(a,n),o=0),e.point(t=s,n=i),r=a},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-o}}}function X0e(e,t,n,r){var o,s,i=st(e-n);return Ht(i)>Je?Ch((st(t)*(s=ht(r))*st(n)-st(r)*(o=ht(t))*st(e))/(o*s*i)):(t+r)/2}function Q0e(e,t,n,r){var o;if(e==null)o=n*Un,r.point(-St,o),r.point(0,o),r.point(St,o),r.point(St,0),r.point(St,-o),r.point(0,-o),r.point(-St,-o),r.point(-St,0),r.point(-St,o);else if(Ht(e[0]-t[0])>Je){var s=e[0]<t[0]?St:-St;o=n*s/2,r.point(-s,o),r.point(0,o),r.point(s,o)}else r.point(t[0],t[1])}function J0e(e){var t=ht(e),n=2*an,r=t>0,o=Ht(t)>Je;function s(u,f,h,p){G0e(p,e,n,h,u,f)}function i(u,f){return ht(u)*ht(f)>t}function a(u){var f,h,p,m,b;return{lineStart:function(){m=p=!1,b=1},point:function(y,g){var x=[y,g],v,w=i(y,g),C=r?w?0:c(y,g):w?c(y+(y<0?St:-St),g):0;if(!f&&(m=p=w)&&u.lineStart(),w!==p&&(v=l(f,x),(!v||M0(f,v)||M0(x,v))&&(x[2]=1)),w!==p)b=0,w?(u.lineStart(),v=l(x,f),u.point(v[0],v[1])):(v=l(f,x),u.point(v[0],v[1],2),u.lineEnd()),f=v;else if(o&&f&&r^w){var S;!(C&h)&&(S=l(x,f,!0))&&(b=0,r?(u.lineStart(),u.point(S[0][0],S[0][1]),u.point(S[1][0],S[1][1]),u.lineEnd()):(u.point(S[1][0],S[1][1]),u.lineEnd(),u.lineStart(),u.point(S[0][0],S[0][1],3)))}w&&(!f||!M0(f,x))&&u.point(x[0],x[1]),f=x,p=w,h=C},lineEnd:function(){p&&u.lineEnd(),f=null},clean:function(){return b|(m&&p)<<1}}}function l(u,f,h){var p=Gf(u),m=Gf(f),b=[1,0,0],y=_x(p,m),g=Ny(y,y),x=y[0],v=g-x*x;if(!v)return!h&&u;var w=t*g/v,C=-t*x/v,S=_x(b,y),N=ky(b,w),j=ky(y,C);mC(N,j);var _=S,R=Ny(N,_),M=Ny(_,_),T=R*R-M*(Ny(N,N)-1);if(!(T<0)){var O=ao(T),I=ky(_,(-R-O)/M);if(mC(I,N),I=bN(I),!h)return I;var A=u[0],$=f[0],H=u[1],U=f[1],B;$<A&&(B=A,A=$,$=B);var P=$-A,z=Ht(P-St)<Je,L=z||P<Je;if(!z&&U<H&&(B=H,H=U,U=B),L?z?H+U>0^I[1]<(Ht(I[0]-A)<Je?H:U):H<=I[1]&&I[1]<=U:P>St^(A<=I[0]&&I[0]<=$)){var D=ky(_,(-R+O)/M);return mC(D,N),[I,bN(D)]}}}function c(u,f){var h=r?e:St-e,p=0;return u<-h?p|=1:u>h&&(p|=2),f<-h?p|=4:f>h&&(p|=8),p}return K7(i,a,s,r?[0,-e]:[-St,e-St])}function exe(e,t,n,r,o,s){var i=e[0],a=e[1],l=t[0],c=t[1],u=0,f=1,h=l-i,p=c-a,m;if(m=n-i,!(!h&&m>0)){if(m/=h,h<0){if(m<u)return;m<f&&(f=m)}else if(h>0){if(m>f)return;m>u&&(u=m)}if(m=o-i,!(!h&&m<0)){if(m/=h,h<0){if(m>f)return;m>u&&(u=m)}else if(h>0){if(m<u)return;m<f&&(f=m)}if(m=r-a,!(!p&&m>0)){if(m/=p,p<0){if(m<u)return;m<f&&(f=m)}else if(p>0){if(m>f)return;m>u&&(u=m)}if(m=s-a,!(!p&&m<0)){if(m/=p,p<0){if(m>f)return;m>u&&(u=m)}else if(p>0){if(m<u)return;m<f&&(f=m)}return u>0&&(e[0]=i+u*h,e[1]=a+u*p),f<1&&(t[0]=i+f*h,t[1]=a+f*p),!0}}}}}var jy=1e9,Ry=-1e9;function txe(e,t,n,r){function o(c,u){return e<=c&&c<=n&&t<=u&&u<=r}function s(c,u,f,h){var p=0,m=0;if(c==null||(p=i(c,f))!==(m=i(u,f))||l(c,u)<0^f>0)do h.point(p===0||p===3?e:n,p>1?r:t);while((p=(p+f+4)%4)!==m);else h.point(u[0],u[1])}function i(c,u){return Ht(c[0]-e)<Je?u>0?0:3:Ht(c[0]-n)<Je?u>0?2:1:Ht(c[1]-t)<Je?u>0?1:0:u>0?3:2}function a(c,u){return l(c.x,u.x)}function l(c,u){var f=i(c,1),h=i(u,1);return f!==h?f-h:f===0?u[1]-c[1]:f===1?c[0]-u[0]:f===2?c[1]-u[1]:u[0]-c[0]}return function(c){var u=c,f=G7(),h,p,m,b,y,g,x,v,w,C,S,N={point:j,lineStart:T,lineEnd:O,polygonStart:R,polygonEnd:M};function j(A,$){o(A,$)&&u.point(A,$)}function _(){for(var A=0,$=0,H=p.length;$<H;++$)for(var U=p[$],B=1,P=U.length,z=U[0],L,D,W=z[0],G=z[1];B<P;++B)L=W,D=G,z=U[B],W=z[0],G=z[1],D<=r?G>r&&(W-L)*(r-D)>(G-D)*(e-L)&&++A:G<=r&&(W-L)*(r-D)<(G-D)*(e-L)&&--A;return A}function R(){u=f,h=[],p=[],S=!0}function M(){var A=_(),$=S&&A,H=(h=V7(h)).length;($||H)&&(c.polygonStart(),$&&(c.lineStart(),s(null,null,1,c),c.lineEnd()),H&&Y7(h,a,A,s,c),c.polygonEnd()),u=c,h=p=m=null}function T(){N.point=I,p&&p.push(m=[]),C=!0,w=!1,x=v=NaN}function O(){h&&(I(b,y),g&&w&&f.rejoin(),h.push(f.result())),N.point=j,w&&u.lineEnd()}function I(A,$){var H=o(A,$);if(p&&m.push([A,$]),C)b=A,y=$,g=H,C=!1,H&&(u.lineStart(),u.point(A,$));else if(H&&w)u.point(A,$);else{var U=[x=Math.max(Ry,Math.min(jy,x)),v=Math.max(Ry,Math.min(jy,v))],B=[A=Math.max(Ry,Math.min(jy,A)),$=Math.max(Ry,Math.min(jy,$))];exe(U,B,e,t,n,r)?(w||(u.lineStart(),u.point(U[0],U[1])),u.point(B[0],B[1]),H||u.lineEnd(),S=!1):H&&(u.lineStart(),u.point(A,$),S=!1)}x=A,v=$,w=H}return N}}var wN,SN,D0,T0,Yf={sphere:xr,point:xr,lineStart:nxe,lineEnd:xr,polygonStart:xr,polygonEnd:xr};function nxe(){Yf.point=oxe,Yf.lineEnd=rxe}function rxe(){Yf.point=Yf.lineEnd=xr}function oxe(e,t){e*=an,t*=an,SN=e,D0=st(t),T0=ht(t),Yf.point=sxe}function sxe(e,t){e*=an,t*=an;var n=st(t),r=ht(t),o=Ht(e-SN),s=ht(o),i=st(o),a=r*i,l=T0*n-D0*r*s,c=D0*n+T0*r*s;wN.add(Hi(ao(a*a+l*l),c)),SN=e,D0=n,T0=r}function ixe(e){return wN=new Wl,Fc(e,Yf),+wN}var CN=[null,null],axe={type:"LineString",coordinates:CN};function EN(e,t){return CN[0]=e,CN[1]=t,ixe(axe)}var hO={Feature:function(e,t){return jx(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,o=n.length;++r<o;)if(jx(n[r].geometry,t))return!0;return!1}},pO={Sphere:function(){return!0},Point:function(e,t){return mO(e.coordinates,t)},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)if(mO(n[r],t))return!0;return!1},LineString:function(e,t){return gO(e.coordinates,t)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)if(gO(n[r],t))return!0;return!1},Polygon:function(e,t){return bO(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)if(bO(n[r],t))return!0;return!1},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,o=n.length;++r<o;)if(jx(n[r],t))return!0;return!1}};function jx(e,t){return e&&pO.hasOwnProperty(e.type)?pO[e.type](e,t):!1}function mO(e,t){return EN(e,t)===0}function gO(e,t){for(var n,r,o,s=0,i=e.length;s<i;s++){if(r=EN(e[s],t),r===0||s>0&&(o=EN(e[s],e[s-1]),o>0&&n<=o&&r<=o&&(n+r-o)*(1-Math.pow((n-r)/o,2))<H7*o))return!0;n=r}return!1}function bO(e,t){return!!Z7(e.map(lxe),X7(t))}function lxe(e){return e=e.map(X7),e.pop(),e}function X7(e){return[e[0]*an,e[1]*an]}function cxe(e,t){return(e&&hO.hasOwnProperty(e.type)?hO[e.type]:jx)(e,t)}function yO(e,t,n){var r=Wd(e,t-Je,n).concat(t);return function(o){return r.map(function(s){return[o,s]})}}function xO(e,t,n){var r=Wd(e,t-Je,n).concat(t);return function(o){return r.map(function(s){return[s,o]})}}function Q7(){var e,t,n,r,o,s,i,a,l=10,c=l,u=90,f=360,h,p,m,b,y=2.5;function g(){return{type:"MultiLineString",coordinates:x()}}function x(){return Wd(Ey(r/u)*u,n,u).map(m).concat(Wd(Ey(a/f)*f,i,f).map(b)).concat(Wd(Ey(t/l)*l,e,l).filter(function(v){return Ht(v%u)>Je}).map(h)).concat(Wd(Ey(s/c)*c,o,c).filter(function(v){return Ht(v%f)>Je}).map(p))}return g.lines=function(){return x().map(function(v){return{type:"LineString",coordinates:v}})},g.outline=function(){return{type:"Polygon",coordinates:[m(r).concat(b(i).slice(1),m(n).reverse().slice(1),b(a).reverse().slice(1))]}},g.extent=function(v){return arguments.length?g.extentMajor(v).extentMinor(v):g.extentMinor()},g.extentMajor=function(v){return arguments.length?(r=+v[0][0],n=+v[1][0],a=+v[0][1],i=+v[1][1],r>n&&(v=r,r=n,n=v),a>i&&(v=a,a=i,i=v),g.precision(y)):[[r,a],[n,i]]},g.extentMinor=function(v){return arguments.length?(t=+v[0][0],e=+v[1][0],s=+v[0][1],o=+v[1][1],t>e&&(v=t,t=e,e=v),s>o&&(v=s,s=o,o=v),g.precision(y)):[[t,s],[e,o]]},g.step=function(v){return arguments.length?g.stepMajor(v).stepMinor(v):g.stepMinor()},g.stepMajor=function(v){return arguments.length?(u=+v[0],f=+v[1],g):[u,f]},g.stepMinor=function(v){return arguments.length?(l=+v[0],c=+v[1],g):[l,c]},g.precision=function(v){return arguments.length?(y=+v,h=yO(s,o,90),p=xO(t,e,y),m=yO(a,i,90),b=xO(r,n,y),g):y},g.extentMajor([[-180,-90+Je],[180,90-Je]]).extentMinor([[-180,-80-Je],[180,80+Je]])}function uxe(){return Q7()()}const NN=e=>e;var bC=new Wl,kN=new Wl,J7,eB,_N,jN,Sa={point:xr,lineStart:xr,lineEnd:xr,polygonStart:function(){Sa.lineStart=dxe,Sa.lineEnd=hxe},polygonEnd:function(){Sa.lineStart=Sa.lineEnd=Sa.point=xr,bC.add(Ht(kN)),kN=new Wl},result:function(){var e=bC/2;return bC=new Wl,e}};function dxe(){Sa.point=fxe}function fxe(e,t){Sa.point=tB,J7=_N=e,eB=jN=t}function tB(e,t){kN.add(jN*e-_N*t),_N=e,jN=t}function hxe(){tB(J7,eB)}var Zf=1/0,Rx=Zf,$m=-Zf,Mx=$m,Dx={point:pxe,lineStart:xr,lineEnd:xr,polygonStart:xr,polygonEnd:xr,result:function(){var e=[[Zf,Rx],[$m,Mx]];return $m=Mx=-(Rx=Zf=1/0),e}};function pxe(e,t){e<Zf&&(Zf=e),e>$m&&($m=e),t<Rx&&(Rx=t),t>Mx&&(Mx=t)}var RN=0,MN=0,wp=0,Tx=0,Px=0,qd=0,DN=0,TN=0,Sp=0,nB,rB,ki,_i,ps={point:Ou,lineStart:vO,lineEnd:wO,polygonStart:function(){ps.lineStart=bxe,ps.lineEnd=yxe},polygonEnd:function(){ps.point=Ou,ps.lineStart=vO,ps.lineEnd=wO},result:function(){var e=Sp?[DN/Sp,TN/Sp]:qd?[Tx/qd,Px/qd]:wp?[RN/wp,MN/wp]:[NaN,NaN];return RN=MN=wp=Tx=Px=qd=DN=TN=Sp=0,e}};function Ou(e,t){RN+=e,MN+=t,++wp}function vO(){ps.point=mxe}function mxe(e,t){ps.point=gxe,Ou(ki=e,_i=t)}function gxe(e,t){var n=e-ki,r=t-_i,o=ao(n*n+r*r);Tx+=o*(ki+e)/2,Px+=o*(_i+t)/2,qd+=o,Ou(ki=e,_i=t)}function wO(){ps.point=Ou}function bxe(){ps.point=xxe}function yxe(){oB(nB,rB)}function xxe(e,t){ps.point=oB,Ou(nB=ki=e,rB=_i=t)}function oB(e,t){var n=e-ki,r=t-_i,o=ao(n*n+r*r);Tx+=o*(ki+e)/2,Px+=o*(_i+t)/2,qd+=o,o=_i*e-ki*t,DN+=o*(ki+e),TN+=o*(_i+t),Sp+=o*3,Ou(ki=e,_i=t)}function sB(e){this._context=e}sB.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:{this._context.moveTo(e,t),this._point=1;break}case 1:{this._context.lineTo(e,t);break}default:{this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,Zo);break}}},result:xr};var PN=new Wl,yC,iB,aB,Cp,Ep,Lm={point:xr,lineStart:function(){Lm.point=vxe},lineEnd:function(){yC&&lB(iB,aB),Lm.point=xr},polygonStart:function(){yC=!0},polygonEnd:function(){yC=null},result:function(){var e=+PN;return PN=new Wl,e}};function vxe(e,t){Lm.point=lB,iB=Cp=e,aB=Ep=t}function lB(e,t){Cp-=e,Ep-=t,PN.add(ao(Cp*Cp+Ep*Ep)),Cp=e,Ep=t}let SO,Ax,CO,EO;class NO{constructor(t){this._append=t==null?cB:wxe(t),this._radius=4.5,this._=""}pointRadius(t){return this._radius=+t,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+="Z"),this._point=NaN}point(t,n){switch(this._point){case 0:{this._append`M${t},${n}`,this._point=1;break}case 1:{this._append`L${t},${n}`;break}default:{if(this._append`M${t},${n}`,this._radius!==CO||this._append!==Ax){const r=this._radius,o=this._;this._="",this._append`m0,${r}a${r},${r} 0 1,1 0,${-2*r}a${r},${r} 0 1,1 0,${2*r}z`,CO=r,Ax=this._append,EO=this._,this._=o}this._+=EO;break}}}result(){const t=this._;return this._="",t.length?t:null}}function cB(e){let t=1;this._+=e[0];for(const n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function wxe(e){const t=Math.floor(e);if(!(t>=0))throw new RangeError(`invalid digits: ${e}`);if(t>15)return cB;if(t!==SO){const n=10**t;SO=t,Ax=function(o){let s=1;this._+=o[0];for(const i=o.length;s<i;++s)this._+=Math.round(arguments[s]*n)/n+o[s]}}return Ax}function kO(e,t){let n=3,r=4.5,o,s;function i(a){return a&&(typeof r=="function"&&s.pointRadius(+r.apply(this,arguments)),Fc(a,o(s))),s.result()}return i.area=function(a){return Fc(a,o(Sa)),Sa.result()},i.measure=function(a){return Fc(a,o(Lm)),Lm.result()},i.bounds=function(a){return Fc(a,o(Dx)),Dx.result()},i.centroid=function(a){return Fc(a,o(ps)),ps.result()},i.projection=function(a){return arguments.length?(o=a==null?(e=null,NN):(e=a).stream,i):e},i.context=function(a){return arguments.length?(s=a==null?(t=null,new NO(n)):new sB(t=a),typeof r!="function"&&s.pointRadius(r),i):t},i.pointRadius=function(a){return arguments.length?(r=typeof a=="function"?a:(s.pointRadius(+a),+a),i):r},i.digits=function(a){if(!arguments.length)return n;if(a==null)n=null;else{const l=Math.floor(a);if(!(l>=0))throw new RangeError(`invalid digits: ${a}`);n=l}return t===null&&(s=new NO(n)),i},i.projection(e).digits(n).context(t)}function fR(e){return function(t){var n=new AN;for(var r in e)n[r]=e[r];return n.stream=t,n}}function AN(){}AN.prototype={constructor:AN,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function hR(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),Fc(n,e.stream(Dx)),t(Dx.result()),r!=null&&e.clipExtent(r),e}function pR(e,t,n){return hR(e,function(r){var o=t[1][0]-t[0][0],s=t[1][1]-t[0][1],i=Math.min(o/(r[1][0]-r[0][0]),s/(r[1][1]-r[0][1])),a=+t[0][0]+(o-i*(r[1][0]+r[0][0]))/2,l=+t[0][1]+(s-i*(r[1][1]+r[0][1]))/2;e.scale(150*i).translate([a,l])},n)}function uB(e,t,n){return pR(e,[[0,0],t],n)}function dB(e,t,n){return hR(e,function(r){var o=+t,s=o/(r[1][0]-r[0][0]),i=(o-s*(r[1][0]+r[0][0]))/2,a=-s*r[0][1];e.scale(150*s).translate([i,a])},n)}function fB(e,t,n){return hR(e,function(r){var o=+t,s=o/(r[1][1]-r[0][1]),i=-s*r[0][0],a=(o-s*(r[1][1]+r[0][1]))/2;e.scale(150*s).translate([i,a])},n)}var _O=16,Sxe=ht(30*an);function jO(e,t){return+t?Exe(e,t):Cxe(e)}function Cxe(e){return fR({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function Exe(e,t){function n(r,o,s,i,a,l,c,u,f,h,p,m,b,y){var g=c-r,x=u-o,v=g*g+x*x;if(v>4*t&&b--){var w=i+h,C=a+p,S=l+m,N=ao(w*w+C*C+S*S),j=_s(S/=N),_=Ht(Ht(S)-1)<Je||Ht(s-f)<Je?(s+f)/2:Hi(C,w),R=e(_,j),M=R[0],T=R[1],O=M-r,I=T-o,A=x*O-g*I;(A*A/v>t||Ht((g*O+x*I)/v-.5)>.3||i*h+a*p+l*m<Sxe)&&(n(r,o,s,i,a,l,M,T,_,w/=N,C/=N,S,b,y),y.point(M,T),n(M,T,_,w,C,S,c,u,f,h,p,m,b,y))}}return function(r){var o,s,i,a,l,c,u,f,h,p,m,b,y={point:g,lineStart:x,lineEnd:w,polygonStart:function(){r.polygonStart(),y.lineStart=C},polygonEnd:function(){r.polygonEnd(),y.lineStart=x}};function g(j,_){j=e(j,_),r.point(j[0],j[1])}function x(){f=NaN,y.point=v,r.lineStart()}function v(j,_){var R=Gf([j,_]),M=e(j,_);n(f,h,u,p,m,b,f=M[0],h=M[1],u=j,p=R[0],m=R[1],b=R[2],_O,r),r.point(f,h)}function w(){y.point=g,r.lineEnd()}function C(){x(),y.point=S,y.lineEnd=N}function S(j,_){v(o=j,_),s=f,i=h,a=p,l=m,c=b,y.point=v}function N(){n(f,h,u,p,m,b,s,i,o,a,l,c,_O,r),y.lineEnd=w,w()}return y}}var Nxe=fR({point:function(e,t){this.stream.point(e*an,t*an)}});function kxe(e){return fR({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}function _xe(e,t,n,r,o){function s(i,a){return i*=r,a*=o,[t+e*i,n-e*a]}return s.invert=function(i,a){return[(i-t)/e*r,(n-a)/e*o]},s}function RO(e,t,n,r,o,s){if(!s)return _xe(e,t,n,r,o);var i=ht(s),a=st(s),l=i*e,c=a*e,u=i/e,f=a/e,h=(a*n-i*t)/e,p=(a*t+i*n)/e;function m(b,y){return b*=r,y*=o,[l*b-c*y+t,n-c*b-l*y]}return m.invert=function(b,y){return[r*(u*b-f*y+h),o*(p-f*b-u*y)]},m}function Ka(e){return hB(function(){return e})()}function hB(e){var t,n=150,r=480,o=250,s=0,i=0,a=0,l=0,c=0,u,f=0,h=1,p=1,m=null,b=fO,y=null,g,x,v,w=NN,C=.5,S,N,j,_,R;function M(A){return j(A[0]*an,A[1]*an)}function T(A){return A=j.invert(A[0],A[1]),A&&[A[0]*to,A[1]*to]}M.stream=function(A){return _&&R===A?_:_=Nxe(kxe(u)(b(S(w(R=A)))))},M.preclip=function(A){return arguments.length?(b=A,m=void 0,I()):b},M.postclip=function(A){return arguments.length?(w=A,y=g=x=v=null,I()):w},M.clipAngle=function(A){return arguments.length?(b=+A?J0e(m=A*an):(m=null,fO),I()):m*to},M.clipExtent=function(A){return arguments.length?(w=A==null?(y=g=x=v=null,NN):txe(y=+A[0][0],g=+A[0][1],x=+A[1][0],v=+A[1][1]),I()):y==null?null:[[y,g],[x,v]]},M.scale=function(A){return arguments.length?(n=+A,O()):n},M.translate=function(A){return arguments.length?(r=+A[0],o=+A[1],O()):[r,o]},M.center=function(A){return arguments.length?(s=A[0]%360*an,i=A[1]%360*an,O()):[s*to,i*to]},M.rotate=function(A){return arguments.length?(a=A[0]%360*an,l=A[1]%360*an,c=A.length>2?A[2]%360*an:0,O()):[a*to,l*to,c*to]},M.angle=function(A){return arguments.length?(f=A%360*an,O()):f*to},M.reflectX=function(A){return arguments.length?(h=A?-1:1,O()):h<0},M.reflectY=function(A){return arguments.length?(p=A?-1:1,O()):p<0},M.precision=function(A){return arguments.length?(S=jO(N,C=A*A),I()):ao(C)},M.fitExtent=function(A,$){return pR(M,A,$)},M.fitSize=function(A,$){return uB(M,A,$)},M.fitWidth=function(A,$){return dB(M,A,$)},M.fitHeight=function(A,$){return fB(M,A,$)};function O(){var A=RO(n,0,0,h,p,f).apply(null,t(s,i)),$=RO(n,r-A[0],o-A[1],h,p,f);return u=q7(a,l,c),N=xN(t,$),j=xN(u,N),S=jO(N,C),I()}function I(){return _=R=null,M}return function(){return t=e.apply(this,arguments),M.invert=t.invert&&T,O()}}function mR(e){var t=0,n=St/3,r=hB(e),o=r(t,n);return o.parallels=function(s){return arguments.length?r(t=s[0]*an,n=s[1]*an):[t*to,n*to]},o}function jxe(e){var t=ht(e);function n(r,o){return[r*t,st(o)/t]}return n.invert=function(r,o){return[r/t,_s(o*t)]},n}function Rxe(e,t){var n=st(e),r=(n+st(t))/2;if(Ht(r)<Je)return jxe(e);var o=1+n*(2*r-n),s=ao(o)/r;function i(a,l){var c=ao(o-2*r*st(l))/r;return[c*st(a*=r),s-c*ht(a)]}return i.invert=function(a,l){var c=s-l,u=Hi(a,Ht(c))*gs(c);return c*r<0&&(u-=St*gs(a)*gs(c)),[u/r,_s((o-(a*a+c*c)*r*r)/(2*r))]},i}function Ix(){return mR(Rxe).scale(155.424).center([0,33.6442])}function pB(){return Ix().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}function Mxe(e){var t=e.length;return{point:function(n,r){for(var o=-1;++o<t;)e[o].point(n,r)},sphere:function(){for(var n=-1;++n<t;)e[n].sphere()},lineStart:function(){for(var n=-1;++n<t;)e[n].lineStart()},lineEnd:function(){for(var n=-1;++n<t;)e[n].lineEnd()},polygonStart:function(){for(var n=-1;++n<t;)e[n].polygonStart()},polygonEnd:function(){for(var n=-1;++n<t;)e[n].polygonEnd()}}}function Dxe(){var e,t,n=pB(),r,o=Ix().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s,i=Ix().rotate([157,0]).center([-3,19.9]).parallels([8,18]),a,l,c={point:function(h,p){l=[h,p]}};function u(h){var p=h[0],m=h[1];return l=null,r.point(p,m),l||(s.point(p,m),l)||(a.point(p,m),l)}u.invert=function(h){var p=n.scale(),m=n.translate(),b=(h[0]-m[0])/p,y=(h[1]-m[1])/p;return(y>=.12&&y<.234&&b>=-.425&&b<-.214?o:y>=.166&&y<.234&&b>=-.214&&b<-.115?i:n).invert(h)},u.stream=function(h){return e&&t===h?e:e=Mxe([n.stream(t=h),o.stream(h),i.stream(h)])},u.precision=function(h){return arguments.length?(n.precision(h),o.precision(h),i.precision(h),f()):n.precision()},u.scale=function(h){return arguments.length?(n.scale(h),o.scale(h*.35),i.scale(h),u.translate(n.translate())):n.scale()},u.translate=function(h){if(!arguments.length)return n.translate();var p=n.scale(),m=+h[0],b=+h[1];return r=n.translate(h).clipExtent([[m-.455*p,b-.238*p],[m+.455*p,b+.238*p]]).stream(c),s=o.translate([m-.307*p,b+.201*p]).clipExtent([[m-.425*p+Je,b+.12*p+Je],[m-.214*p-Je,b+.234*p-Je]]).stream(c),a=i.translate([m-.205*p,b+.212*p]).clipExtent([[m-.214*p+Je,b+.166*p+Je],[m-.115*p-Je,b+.234*p-Je]]).stream(c),f()},u.fitExtent=function(h,p){return pR(u,h,p)},u.fitSize=function(h,p){return uB(u,h,p)},u.fitWidth=function(h,p){return dB(u,h,p)},u.fitHeight=function(h,p){return fB(u,h,p)};function f(){return e=t=null,u}return u.scale(1070)}function mB(e){return function(t,n){var r=ht(t),o=ht(n),s=e(r*o);return s===1/0?[2,0]:[s*o*st(t),s*st(n)]}}function Zg(e){return function(t,n){var r=ao(t*t+n*n),o=e(r),s=st(o),i=ht(o);return[Hi(t*s,r*i),_s(r&&n*s/r)]}}var gB=mB(function(e){return ao(2/(1+e))});gB.invert=Zg(function(e){return 2*_s(e/2)});function Txe(){return Ka(gB).scale(124.75).clipAngle(180-.001)}var bB=mB(function(e){return(e=W7(e))&&e/st(e)});bB.invert=Zg(function(e){return e});function Pxe(){return Ka(bB).scale(79.4188).clipAngle(180-.001)}function Rw(e,t){return[e,Nx(dR((Un+t)/2))]}Rw.invert=function(e,t){return[e,2*Ch(U7(t))-Un]};function Axe(){return yB(Rw).scale(961/Zo)}function yB(e){var t=Ka(e),n=t.center,r=t.scale,o=t.translate,s=t.clipExtent,i=null,a,l,c;t.scale=function(f){return arguments.length?(r(f),u()):r()},t.translate=function(f){return arguments.length?(o(f),u()):o()},t.center=function(f){return arguments.length?(n(f),u()):n()},t.clipExtent=function(f){return arguments.length?(f==null?i=a=l=c=null:(i=+f[0][0],a=+f[0][1],l=+f[1][0],c=+f[1][1]),u()):i==null?null:[[i,a],[l,c]]};function u(){var f=St*r(),h=t(q0e(t.rotate()).invert([0,0]));return s(i==null?[[h[0]-f,h[1]-f],[h[0]+f,h[1]+f]]:e===Rw?[[Math.max(h[0]-f,i),a],[Math.min(h[0]+f,l),c]]:[[i,Math.max(h[1]-f,a)],[l,Math.min(h[1]+f,c)]])}return u()}function My(e){return dR((Un+e)/2)}function Ixe(e,t){var n=ht(e),r=e===t?st(e):Nx(n/ht(t))/Nx(My(t)/My(e)),o=n*pC(My(e),r)/r;if(!r)return Rw;function s(i,a){o>0?a<-Un+Je&&(a=-Un+Je):a>Un-Je&&(a=Un-Je);var l=o/pC(My(a),r);return[l*st(r*i),o-l*ht(r*i)]}return s.invert=function(i,a){var l=o-a,c=gs(r)*ao(i*i+l*l),u=Hi(i,Ht(l))*gs(l);return l*r<0&&(u-=St*gs(i)*gs(l)),[u/r,2*Ch(pC(o/c,1/r))-Un]},s}function Oxe(){return mR(Ixe).scale(109.5).parallels([30,30])}function Ox(e,t){return[e,t]}Ox.invert=Ox;function Fxe(){return Ka(Ox).scale(152.63)}function $xe(e,t){var n=ht(e),r=e===t?st(e):(n-ht(t))/(t-e),o=n/r+e;if(Ht(r)<Je)return Ox;function s(i,a){var l=o-a,c=r*i;return[l*st(c),o-l*ht(c)]}return s.invert=function(i,a){var l=o-a,c=Hi(i,Ht(l))*gs(l);return l*r<0&&(c-=St*gs(i)*gs(l)),[c/r,o-gs(r)*ao(i*i+l*l)]},s}function Lxe(){return mR($xe).scale(131.154).center([0,13.9389])}var Xp=1.340264,Qp=-.081106,Jp=893e-6,em=.003796,Fx=ao(3)/2,zxe=12;function xB(e,t){var n=_s(Fx*st(t)),r=n*n,o=r*r*r;return[e*ht(n)/(Fx*(Xp+3*Qp*r+o*(7*Jp+9*em*r))),n*(Xp+Qp*r+o*(Jp+em*r))]}xB.invert=function(e,t){for(var n=t,r=n*n,o=r*r*r,s=0,i,a,l;s<zxe&&(a=n*(Xp+Qp*r+o*(Jp+em*r))-t,l=Xp+3*Qp*r+o*(7*Jp+9*em*r),n-=i=a/l,r=n*n,o=r*r*r,!(Ht(i)<H7));++s);return[Fx*e*(Xp+3*Qp*r+o*(7*Jp+9*em*r))/ht(n),_s(st(n)/Fx)]};function Bxe(){return Ka(xB).scale(177.158)}function vB(e,t){var n=ht(t),r=ht(e)*n;return[n*st(e)/r,st(t)/r]}vB.invert=Zg(Ch);function Vxe(){return Ka(vB).scale(144.049).clipAngle(60)}function wB(e,t){var n=t*t,r=n*n;return[e*(.8707-.131979*n+r*(-.013791+r*(.003971*n-.001529*r))),t*(1.007226+n*(.015085+r*(-.044475+.028874*n-.005916*r)))]}wB.invert=function(e,t){var n=t,r=25,o;do{var s=n*n,i=s*s;n-=o=(n*(1.007226+s*(.015085+i*(-.044475+.028874*s-.005916*i)))-t)/(1.007226+s*(.015085*3+i*(-.044475*7+.028874*9*s-.005916*11*i)))}while(Ht(o)>Je&&--r>0);return[e/(.8707+(s=n*n)*(-.131979+s*(-.013791+s*s*s*(.003971-.001529*s)))),n]};function Hxe(){return Ka(wB).scale(175.295)}function SB(e,t){return[ht(t)*st(e),st(t)]}SB.invert=Zg(_s);function Uxe(){return Ka(SB).scale(249.5).clipAngle(90+Je)}function CB(e,t){var n=ht(t),r=1+ht(e)*n;return[n*st(e)/r,st(t)/r]}CB.invert=Zg(function(e){return 2*Ch(e)});function Wxe(){return Ka(CB).scale(250).clipAngle(142)}function EB(e,t){return[Nx(dR((Un+t)/2)),-e]}EB.invert=function(e,t){return[-t,2*Ch(U7(e))-Un]};function qxe(){var e=yB(EB),t=e.center,n=e.rotate;return e.center=function(r){return arguments.length?t([-r[1],r[0]]):(r=t(),[r[1],-r[0]])},e.rotate=function(r){return arguments.length?n([r[0],r[1],r.length>2?r[2]+90:90]):(r=n(),[r[0],r[1],r[2]-90])},n([0,0,90]).scale(159.155)}function Yt(e){for(var t=e.length/6|0,n=new Array(t),r=0;r<t;)n[r]="#"+e.slice(r*6,++r*6);return n}function Mw(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function gR(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Eh(){}var Fu=.7,Kf=1/Fu,cf="\\s*([+-]?\\d+)\\s*",zm="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Pi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Gxe=/^#([0-9a-f]{3,8})$/,Yxe=new RegExp(`^rgb\\(${cf},${cf},${cf}\\)$`),Zxe=new RegExp(`^rgb\\(${Pi},${Pi},${Pi}\\)$`),Kxe=new RegExp(`^rgba\\(${cf},${cf},${cf},${zm}\\)$`),Xxe=new RegExp(`^rgba\\(${Pi},${Pi},${Pi},${zm}\\)$`),Qxe=new RegExp(`^hsl\\(${zm},${Pi},${Pi}\\)$`),Jxe=new RegExp(`^hsla\\(${zm},${Pi},${Pi},${zm}\\)$`),MO={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Mw(Eh,bR,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:DO,formatHex:DO,formatHex8:eve,formatHsl:tve,formatRgb:TO,toString:TO});function DO(){return this.rgb().formatHex()}function eve(){return this.rgb().formatHex8()}function tve(){return kB(this).formatHsl()}function TO(){return this.rgb().formatRgb()}function bR(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Gxe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?PO(t):n===3?new Vr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Dy(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Dy(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Yxe.exec(e))?new Vr(t[1],t[2],t[3],1):(t=Zxe.exec(e))?new Vr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Kxe.exec(e))?Dy(t[1],t[2],t[3],t[4]):(t=Xxe.exec(e))?Dy(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Qxe.exec(e))?OO(t[1],t[2]/100,t[3]/100,1):(t=Jxe.exec(e))?OO(t[1],t[2]/100,t[3]/100,t[4]):MO.hasOwnProperty(e)?PO(MO[e]):e==="transparent"?new Vr(NaN,NaN,NaN,0):null}function PO(e){return new Vr(e>>16&255,e>>8&255,e&255,1)}function Dy(e,t,n,r){return r<=0&&(e=t=n=NaN),new Vr(e,t,n,r)}function NB(e){return e instanceof Eh||(e=bR(e)),e?(e=e.rgb(),new Vr(e.r,e.g,e.b,e.opacity)):new Vr}function Bm(e,t,n,r){return arguments.length===1?NB(e):new Vr(e,t,n,r??1)}function Vr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Mw(Vr,Bm,gR(Eh,{brighter(e){return e=e==null?Kf:Math.pow(Kf,e),new Vr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new Vr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Vr(yu(this.r),yu(this.g),yu(this.b),$x(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:AO,formatHex:AO,formatHex8:nve,formatRgb:IO,toString:IO}));function AO(){return`#${Uc(this.r)}${Uc(this.g)}${Uc(this.b)}`}function nve(){return`#${Uc(this.r)}${Uc(this.g)}${Uc(this.b)}${Uc((isNaN(this.opacity)?1:this.opacity)*255)}`}function IO(){const e=$x(this.opacity);return`${e===1?"rgb(":"rgba("}${yu(this.r)}, ${yu(this.g)}, ${yu(this.b)}${e===1?")":`, ${e})`}`}function $x(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function yu(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Uc(e){return e=yu(e),(e<16?"0":"")+e.toString(16)}function OO(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Us(e,t,n,r)}function kB(e){if(e instanceof Us)return new Us(e.h,e.s,e.l,e.opacity);if(e instanceof Eh||(e=bR(e)),!e)return new Us;if(e instanceof Us)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),s=Math.max(t,n,r),i=NaN,a=s-o,l=(s+o)/2;return a?(t===s?i=(n-r)/a+(n<r)*6:n===s?i=(r-t)/a+2:i=(t-n)/a+4,a/=l<.5?s+o:2-s-o,i*=60):a=l>0&&l<1?0:i,new Us(i,a,l,e.opacity)}function rve(e,t,n,r){return arguments.length===1?kB(e):new Us(e,t,n,r??1)}function Us(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Mw(Us,rve,gR(Eh,{brighter(e){return e=e==null?Kf:Math.pow(Kf,e),new Us(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new Us(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Vr(xC(e>=240?e-240:e+120,o,r),xC(e,o,r),xC(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new Us(FO(this.h),Ty(this.s),Ty(this.l),$x(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=$x(this.opacity);return`${e===1?"hsl(":"hsla("}${FO(this.h)}, ${Ty(this.s)*100}%, ${Ty(this.l)*100}%${e===1?")":`, ${e})`}`}}));function FO(e){return e=(e||0)%360,e<0?e+360:e}function Ty(e){return Math.max(0,Math.min(1,e||0))}function xC(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ove=Math.PI/180,sve=180/Math.PI;var _B=-.14861,yR=1.78277,xR=-.29227,Dw=-.90649,Vm=1.97294,$O=Vm*Dw,LO=Vm*yR,zO=yR*xR-Dw*_B;function ive(e){if(e instanceof xu)return new xu(e.h,e.s,e.l,e.opacity);e instanceof Vr||(e=NB(e));var t=e.r/255,n=e.g/255,r=e.b/255,o=(zO*r+$O*t-LO*n)/(zO+$O-LO),s=r-o,i=(Vm*(n-o)-xR*s)/Dw,a=Math.sqrt(i*i+s*s)/(Vm*o*(1-o)),l=a?Math.atan2(i,s)*sve-120:NaN;return new xu(l<0?l+360:l,a,o,e.opacity)}function Ui(e,t,n,r){return arguments.length===1?ive(e):new xu(e,t,n,r??1)}function xu(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Mw(xu,Ui,gR(Eh,{brighter(e){return e=e==null?Kf:Math.pow(Kf,e),new xu(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new xu(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=isNaN(this.h)?0:(this.h+120)*ove,t=+this.l,n=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(e),o=Math.sin(e);return new Vr(255*(t+n*(_B*r+yR*o)),255*(t+n*(xR*r+Dw*o)),255*(t+n*(Vm*r)),this.opacity)}}));function ave(e,t,n,r,o){var s=e*e,i=s*e;return((1-3*e+3*s-i)*t+(4-6*s+3*i)*n+(1+3*e+3*s-3*i)*r+i*o)/6}function lve(e){var t=e.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),o=e[r],s=e[r+1],i=r>0?e[r-1]:2*o-s,a=r<t-1?e[r+2]:2*s-o;return ave((n-r/t)*t,i,o,s,a)}}const vR=e=>()=>e;function jB(e,t){return function(n){return e+n*t}}function cve(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function uve(e,t){var n=t-e;return n?jB(e,n>180||n<-180?n-360*Math.round(n/360):n):vR(isNaN(e)?t:e)}function dve(e){return(e=+e)==1?uf:function(t,n){return n-t?cve(t,n,e):vR(isNaN(t)?n:t)}}function uf(e,t){var n=t-e;return n?jB(e,n):vR(isNaN(e)?t:e)}(function e(t){var n=dve(t);function r(o,s){var i=n((o=Bm(o)).r,(s=Bm(s)).r),a=n(o.g,s.g),l=n(o.b,s.b),c=uf(o.opacity,s.opacity);return function(u){return o.r=i(u),o.g=a(u),o.b=l(u),o.opacity=c(u),o+""}}return r.gamma=e,r})(1);function fve(e){return function(t){var n=t.length,r=new Array(n),o=new Array(n),s=new Array(n),i,a;for(i=0;i<n;++i)a=Bm(t[i]),r[i]=a.r||0,o[i]=a.g||0,s[i]=a.b||0;return r=e(r),o=e(o),s=e(s),a.opacity=1,function(l){return a.r=r(l),a.g=o(l),a.b=s(l),a+""}}}var hve=fve(lve);function RB(e){return function t(n){n=+n;function r(o,s){var i=e((o=Ui(o)).h,(s=Ui(s)).h),a=uf(o.s,s.s),l=uf(o.l,s.l),c=uf(o.opacity,s.opacity);return function(u){return o.h=i(u),o.s=a(u),o.l=l(Math.pow(u,n)),o.opacity=c(u),o+""}}return r.gamma=t,r}(1)}RB(uve);var wR=RB(uf);const mn=e=>hve(e[e.length-1]);var pve=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(Yt);const mve=mn(pve);var gve=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(Yt);const bve=mn(gve);var yve=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(Yt);const xve=mn(yve);var vve=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(Yt);const wve=mn(vve);var Sve=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(Yt);const Cve=mn(Sve);var Eve=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(Yt);const Nve=mn(Eve);var kve=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(Yt);const _ve=mn(kve);var jve=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(Yt);const Rve=mn(jve);var Mve=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(Yt);const Dve=mn(Mve);var Tve=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(Yt);const Pve=mn(Tve);var Ave=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(Yt);const Ive=mn(Ave);var Ove=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(Yt);const Fve=mn(Ove);var $ve=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(Yt);const Lve=mn($ve);var zve=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(Yt);const Bve=mn(zve);var Vve=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(Yt);const Hve=mn(Vve);var Uve=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(Yt);const Wve=mn(Uve);var qve=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(Yt);const Gve=mn(qve);var Yve=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(Yt);const Zve=mn(Yve);var Kve=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(Yt);const Xve=mn(Kve);var Qve=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(Yt);const Jve=mn(Qve);var ewe=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(Yt);const twe=mn(ewe);var nwe=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(Yt);const rwe=mn(nwe);var owe=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(Yt);const swe=mn(owe);var iwe=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Yt);const awe=mn(iwe);var lwe=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(Yt);const cwe=mn(lwe);var uwe=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(Yt);const dwe=mn(uwe);var fwe=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(Yt);const hwe=mn(fwe);function pwe(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-e*(35.34-e*(2381.73-e*(6402.7-e*(7024.72-e*2710.57)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+e*(170.73+e*(52.82-e*(131.46-e*(176.58-e*67.37)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+e*(442.36-e*(2482.43-e*(6167.24-e*(6614.94-e*2475.67)))))))+")"}const mwe=wR(Ui(300,.5,0),Ui(-240,.5,1));var gwe=wR(Ui(-100,.75,.35),Ui(80,1.5,.8)),bwe=wR(Ui(260,.75,.35),Ui(80,1.5,.8)),Py=Ui();function ywe(e){(e<0||e>1)&&(e-=Math.floor(e));var t=Math.abs(e-.5);return Py.h=360*e-100,Py.s=1.5-1.5*t,Py.l=.8-.9*t,Py+""}var Ay=Bm(),xwe=Math.PI/3,vwe=Math.PI*2/3;function wwe(e){var t;return e=(.5-e)*Math.PI,Ay.r=255*(t=Math.sin(e))*t,Ay.g=255*(t=Math.sin(e+xwe))*t,Ay.b=255*(t=Math.sin(e+vwe))*t,Ay+""}function Swe(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+e*(1172.33-e*(10793.56-e*(33300.12-e*(38394.49-e*14825.05)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+e*(557.33+e*(1225.33-e*(3574.96-e*(1073.77+e*707.56)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+e*(3211.1-e*(15327.97-e*(27814-e*(22569.18-e*6838.66)))))))+")"}function Tw(e){var t=e.length;return function(n){return e[Math.max(0,Math.min(t-1,Math.floor(n*t)))]}}const Cwe=Tw(Yt("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));var Ewe=Tw(Yt("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),Nwe=Tw(Yt("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),kwe=Tw(Yt("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function _we(e){return e}function jwe(e){if(e==null)return _we;var t,n,r=e.scale[0],o=e.scale[1],s=e.translate[0],i=e.translate[1];return function(a,l){l||(t=n=0);var c=2,u=a.length,f=new Array(u);for(f[0]=(t+=a[0])*r+s,f[1]=(n+=a[1])*o+i;c<u;)f[c]=a[c],++c;return f}}function Rwe(e,t){for(var n,r=e.length,o=r-t;o<--r;)n=e[o],e[o++]=e[r],e[r]=n}function Mwe(e,t){return typeof t=="string"&&(t=e.objects[t]),t.type==="GeometryCollection"?{type:"FeatureCollection",features:t.geometries.map(function(n){return BO(e,n)})}:BO(e,t)}function BO(e,t){var n=t.id,r=t.bbox,o=t.properties==null?{}:t.properties,s=Dwe(e,t);return n==null&&r==null?{type:"Feature",properties:o,geometry:s}:r==null?{type:"Feature",id:n,properties:o,geometry:s}:{type:"Feature",id:n,bbox:r,properties:o,geometry:s}}function Dwe(e,t){var n=jwe(e.transform),r=e.arcs;function o(u,f){f.length&&f.pop();for(var h=r[u<0?~u:u],p=0,m=h.length;p<m;++p)f.push(n(h[p],p));u<0&&Rwe(f,m)}function s(u){return n(u)}function i(u){for(var f=[],h=0,p=u.length;h<p;++h)o(u[h],f);return f.length<2&&f.push(f[0]),f}function a(u){for(var f=i(u);f.length<4;)f.push(f[0]);return f}function l(u){return u.map(a)}function c(u){var f=u.type,h;switch(f){case"GeometryCollection":return{type:f,geometries:u.geometries.map(c)};case"Point":h=s(u.coordinates);break;case"MultiPoint":h=u.coordinates.map(s);break;case"LineString":h=i(u.arcs);break;case"MultiLineString":h=u.arcs.map(i);break;case"Polygon":h=l(u.arcs);break;case"MultiPolygon":h=u.arcs.map(l);break;default:return null}return{type:f,coordinates:h}}return c(t)}const tm={geoAzimuthalEqualArea:Txe,geoAzimuthalEquidistant:Pxe,geoGnomonic:Vxe,geoOrthographic:Uxe,geoStereographic:Wxe,geoEqualEarth:Bxe,geoAlbers:pB,geoAlbersUsa:Dxe,geoConicConformal:Oxe,geoConicEqualArea:Ix,geoConicEquidistant:Lxe,geoEquirectangular:Fxe,geoMercator:Axe,geoTransverseMercator:qxe,geoNaturalEarth1:Hxe};Object.keys(tm).forEach(e=>{tm[`${e.charAt(3).toLowerCase()}${e.slice(4)}`]=tm[e]});class nd extends lc{constructor(t){super(t),this.outlineBounds=null,this.oldChartBounds=null,this.geoPath=kO()}init(t){t.position="chartArea",super.init(t),typeof t.projection=="function"?this.projection=t.projection:this.projection=(tm[t.projection]||tm.albersUsa)(),this.geoPath.projection(this.projection),this.outlineBounds=null,this.oldChartBounds=null}computeBounds(t){const n=kO(this.projection.fitWidth(1e3,t)).bounds(t),r=Math.ceil(n[1][1]-n[0][1]),o=Math.ceil(n[1][0]-n[0][0]),s=this.projection.translate();this.outlineBounds={width:o,height:r,aspectRatio:o/r,refScale:this.projection.scale(),refX:s[0],refY:s[1]}}updateBounds(){const t=this.chart.chartArea,n=this.outlineBounds;if(!n)return!1;const r=this.options.padding,o=typeof r=="number"?r:r.top,s=typeof r=="number"?r:r.left,i=typeof r=="number"?r:r.bottom,a=typeof r=="number"?r:r.right,l=t.right-t.left-s-a,c=t.bottom-t.top-o-i,u=this.oldChartBounds;this.oldChartBounds={chartWidth:l,chartHeight:c};const f=Math.min(l/n.width,c/n.height),h=n.width*f,p=n.height*f,m=(l-h)*.5+t.left+s,b=(c-p)*.5+t.top+o,y=this.options;return this.projection.scale(n.refScale*f*y.projectionScale).translate([f*n.refX+m+y.projectionOffset[0],f*n.refY+b+y.projectionOffset[1]]),!u||u.chartWidth!==this.oldChartBounds.chartWidth||u.chartHeight!==this.oldChartBounds.chartHeight}}nd.id="projection";nd.defaults={projection:"albersUsa",projectionScale:1,projectionOffset:[0,0],padding:0};nd.descriptors={_scriptable:e=>e!=="projection",_indexable:e=>e!=="projectionOffset"};const Pw={position:"chartArea",property:"value",grid:{z:1,drawOnChartArea:!1},ticks:{z:1},legend:{align:"right",position:"bottom-right",length:100,width:50,margin:8,indicatorWidth:10}};function Twe(e){const{indicatorWidth:t,align:n,margin:r}=e,o=(typeof r=="number"?r:r.left)+(n==="right"?t:0),s=(typeof r=="number"?r:r.top)+(n==="bottom"?t:0),i=(typeof r=="number"?r:r.right)+(n==="left"?t:0),a=(typeof r=="number"?r:r.bottom)+(n==="top"?t:0);return{left:o,top:s,right:i,bottom:a}}function Pwe(e,t,n,r,o){const{indicatorWidth:s,align:i,position:a}=t,l=i==="top"||i==="bottom",c=(i==="left"?o.w:n)+(l?s:0),u=(i==="top"?o.h:r)+(l?0:s),f=Twe(t);if(typeof a=="string")switch(a){case"top-left":return[f.left,f.top];case"top":return[(e.right-c)/2,f.top];case"left":return[f.left,(e.bottom-u)/2];case"top-right":return[e.right-c-f.right,f.top];case"bottom-right":return[e.right-c-f.right,e.bottom-u-f.bottom];case"bottom":return[(e.right-c)/2,e.bottom-u-f.bottom];case"bottom-left":return[f.left,e.bottom-u-f.bottom];default:return[e.right-c-f.right,(e.bottom-u)/2]}return[a.x,a.y]}class Gd extends Iu{constructor(){super(...arguments),this.legendSize={w:0,h:0}}init(t){t.position="chartArea",super.init(t),this.axis="r"}parse(t,n){return t&&typeof t[this.options.property]=="number"?t[this.options.property]:super.parse(t,n)}isHorizontal(){return this.options.legend.align==="top"||this.options.legend.align==="bottom"}_getNormalizedValue(t){return t==null||Number.isNaN(t)?null:(t-this._startValue)/this._valueRange}update(t,n,r){const o=Math.min(n,this.bottom==null?Number.POSITIVE_INFINITY:this.bottom),s=Math.min(t,this.right==null?Number.POSITIVE_INFINITY:this.right),i=this.options.legend,a=this.isHorizontal(),l=(p,m)=>p<1?m*p:p,c=Math.min(s,l(a?i.length:i.width,s))-(a?0:i.indicatorWidth),u=Math.min(o,l(a?i.width:i.length,o))-(a?i.indicatorWidth:0);this.legendSize={w:c,h:u},this.bottom=u,this.height=u,this.right=c,this.width=c;const f=this.options.position;this.options.position=this.options.legend.align;const h=super.update(c,u,r);return this.options.position=f,this.height=Math.min(u,this.height),this.width=Math.min(c,this.width),h}_computeLabelArea(){}draw(t){if(!this._isVisible())return;const n=Pwe(t,this.options.legend,this.width,this.height,this.legendSize),{ctx:r}=this;r.save(),r.translate(n[0],n[1]);const o=this.options.position;this.options.position=this.options.legend.align,super.draw({...t,bottom:this.height+10,right:this.width}),this.options.position=o;const{indicatorWidth:s}=this.options.legend;switch(this.options.legend.align){case"left":r.translate(this.legendSize.w,0);break;case"top":r.translate(0,this.legendSize.h);break;case"bottom":r.translate(0,-s);break;default:r.translate(-s,0);break}this._drawIndicator(),r.restore()}_drawIndicator(){}}class MB extends qf{constructor(){super(...arguments),this.legendSize={w:0,h:0}}init(t){Gd.prototype.init.call(this,t)}parse(t,n){return Gd.prototype.parse.call(this,t,n)}isHorizontal(){return this.options.legend.align==="top"||this.options.legend.align==="bottom"}_getNormalizedValue(t){return t==null||Number.isNaN(t)?null:(Math.log10(t)-this._startValue)/this._valueRange}update(t,n,r){return Gd.prototype.update.call(this,t,n,r)}_computeLabelArea(){}draw(t){return Gd.prototype.draw.call(this,t)}_drawIndicator(){}}const Ca={interpolateBlues:rwe,interpolateBrBG:mve,interpolateBuGn:Pve,interpolateBuPu:Ive,interpolateCividis:pwe,interpolateCool:bwe,interpolateCubehelixDefault:mwe,interpolateGnBu:Fve,interpolateGreens:swe,interpolateGreys:awe,interpolateInferno:Nwe,interpolateMagma:Ewe,interpolateOrRd:Lve,interpolateOranges:hwe,interpolatePRGn:bve,interpolatePiYG:xve,interpolatePlasma:kwe,interpolatePuBu:Hve,interpolatePuBuGn:Bve,interpolatePuOr:wve,interpolatePuRd:Wve,interpolatePurples:cwe,interpolateRainbow:ywe,interpolateRdBu:Cve,interpolateRdGy:Nve,interpolateRdPu:Gve,interpolateRdYlBu:_ve,interpolateRdYlGn:Rve,interpolateReds:dwe,interpolateSinebow:wwe,interpolateSpectral:Dve,interpolateTurbo:Swe,interpolateViridis:Cwe,interpolateWarm:gwe,interpolateYlGn:Xve,interpolateYlGnBu:Zve,interpolateYlOrBr:Jve,interpolateYlOrRd:twe};Object.keys(Ca).forEach(e=>{Ca[`${e.charAt(11).toLowerCase()}${e.slice(12)}`]=Ca[e],Ca[e.slice(11)]=Ca[e]});function DB(e,t){const n=1/t;if(e<=n)return 0;if(e>=1-n)return 1;for(let r=0;r<1;r+=n)if(e<r)return r-n/2;return e}const TB={interpolate:"blues",missing:"transparent",quantize:0};class ql extends Gd{get interpolate(){const t=this.options;return t?typeof t.interpolate=="function"?t.interpolate:Ca[t.interpolate]||Ca.blues:n=>`rgb(${n},${n},${n})`}getColorForValue(t){const n=this._getNormalizedValue(t);return n==null||Number.isNaN(n)?this.options.missing:this.getColor(n)}getColor(t){let n=t;return this.options.quantize>0&&(n=DB(n,this.options.quantize)),this.interpolate(n)}_drawIndicator(){const{indicatorWidth:t}=this.options.legend,n=this._reversePixels;if(this.isHorizontal()){const r=this.width;if(this.options.quantize>0){const o=r/this.options.quantize,s=n?i=>r-o-i:i=>i;for(let i=0;i<r;i+=o){const a=(i+o/2)/r;this.ctx.fillStyle=this.getColor(a),this.ctx.fillRect(s(i),0,o,t)}}else{const o=n?s=>r-1-s:s=>s;for(let s=0;s<r;s+=1)this.ctx.fillStyle=this.getColor((s+.5)/r),this.ctx.fillRect(o(s),0,1,t)}}else{const r=this.height;if(this.options.quantize>0){const o=r/this.options.quantize,s=n?i=>r-o-i:i=>i;for(let i=0;i<r;i+=o){const a=(i+o/2)/r;this.ctx.fillStyle=this.getColor(a),this.ctx.fillRect(0,s(i),t,o)}}else{const o=n?s=>r-1-s:s=>s;for(let s=0;s<r;s+=1)this.ctx.fillStyle=this.getColor((s+.5)/r),this.ctx.fillRect(0,o(s),t,1)}}}}ql.id="color";ql.defaults=lr({},[Iu.defaults,Pw,TB]);ql.descriptors={_scriptable:e=>e!=="interpolate",_indexable:!1};class SR extends MB{constructor(){super(...arguments),this.interpolate=t=>`rgb(${t},${t},${t})`}init(t){super.init(t),typeof t.interpolate=="function"?this.interpolate=t.interpolate:this.interpolate=Ca[t.interpolate]||Ca.blues}getColorForValue(t){return ql.prototype.getColorForValue.call(this,t)}getColor(t){let n=t;return this.options.quantize>0&&(n=DB(n,this.options.quantize)),this.interpolate(n)}_drawIndicator(){return ql.prototype._drawIndicator.call(this)}}SR.id="colorLogarithmic";SR.defaults=lr({},[qf.defaults,Pw,TB]);SR.descriptors={_scriptable:e=>e!=="interpolate",_indexable:!1};const PB={missing:1,mode:"area",range:[2,20],legend:{align:"bottom",length:90,width:70,indicatorWidth:42}};class Gl extends Gd{constructor(){super(...arguments),this._model=null}getSizeForValue(t){const n=this._getNormalizedValue(t);return n==null||Number.isNaN(n)?this.options.missing:this.getSizeImpl(n)}getSizeImpl(t){const[n,r]=this.options.range;if(this.options.mode==="area"){const s=r*r*Math.PI,i=n*n*Math.PI,a=s-i,l=t*a+i;return Math.sqrt(l/Math.PI)}const o=r-n;return t*o+n}_drawIndicator(){const{ctx:t}=this,n=this.options.legend.indicatorWidth/2,r=this.isHorizontal(),o=this.ticks,s=this.getLabelItems(),i=s?s.map(a=>({[r?"x":"y"]:a.options.translation[r?0:1]})):o.map((a,l)=>({[r?"x":"y"]:this.getPixelForTick(l)}));if((this._gridLineItems||[]).forEach(a=>{if(t.save(),t.strokeStyle=a.color,t.lineWidth=a.width,t.setLineDash&&(t.setLineDash(a.borderDash),t.lineDashOffset=a.borderDashOffset),t.beginPath(),this.options.grid.drawTicks)switch(this.options.legend.align){case"left":t.moveTo(0,a.ty1),t.lineTo(n,a.ty2);break;case"top":t.moveTo(a.tx1,0),t.lineTo(a.tx2,n);break;case"bottom":t.moveTo(a.tx1,n),t.lineTo(a.tx2,n*2);break;default:t.moveTo(n,a.ty1),t.lineTo(n*2,a.ty2);break}t.stroke(),t.restore()}),this._model){const a=this._model;t.strokeStyle=a.borderColor,t.lineWidth=a.borderWidth||0,t.fillStyle=a.backgroundColor}else t.fillStyle="blue";o.forEach((a,l)=>{const c=i[l],u=this.getSizeForValue(a.value),f=r?c.x:n,h=r?n:c.y,p={pointStyle:"circle",borderWidth:0,...this._model||{},radius:u};vx(t,p,f,h)})}}Gl.id="size";Gl.defaults=lr({},[Iu.defaults,Pw,PB]);Gl.descriptors={_scriptable:!0,_indexable:e=>e!=="range"};class AB extends MB{constructor(){super(...arguments),this._model=null}getSizeForValue(t){const n=this._getNormalizedValue(t);return n==null||Number.isNaN(n)?this.options.missing:this.getSizeImpl(n)}getSizeImpl(t){return Gl.prototype.getSizeImpl.call(this,t)}_drawIndicator(){Gl.prototype._drawIndicator.call(this)}}AB.id="sizeLogarithmic";AB.defaults=lr({},[qf.defaults,Pw,PB]);function Awe(e,t){return[[e[0][0]-t,e[0][1]-t],[e[1][0]+t,e[1][1]+t]]}class qa extends sa{constructor(){super(...arguments),this.cache=void 0}inRange(t,n){const r=this.getBounds(),o=(Number.isNaN(t)||t>=r.x&&t<=r.x2)&&(Number.isNaN(n)||n>=r.y&&n<=r.y2),s=this.projectionScale.geoPath.projection();if(o&&!Number.isNaN(t)&&!Number.isNaN(n)&&typeof s.invert=="function"){const i=s.invert([t,n]);return i!=null&&cxe(this.feature,i)}return o}inXRange(t){return this.inRange(t,Number.NaN)}inYRange(t){return this.inRange(Number.NaN,t)}getCenterPoint(){if(this.cache&&this.cache.center)return this.cache.center;let t;if(this.center){const n=this.projectionScale.projection([this.center.longitude,this.center.latitude]);t={x:n[0],y:n[1]}}else{const n=this.projectionScale.geoPath.centroid(this.feature);t={x:n[0],y:n[1]}}return this.cache={...this.cache||{},center:t},t}getBounds(){if(this.cache&&this.cache.bounds)return this.cache.bounds;const t=Awe(this.projectionScale.geoPath.bounds(this.feature),this.options.borderWidth/2),n={x:t[0][0],x2:t[1][0],y:t[0][1],y2:t[1][1],width:t[1][0]-t[0][0],height:t[1][1]-t[0][1]};return this.cache={...this.cache||{},bounds:n},n}_drawInCache(t){const n=this.getBounds();if(!Number.isFinite(n.x))return;const r=this.cache&&this.cache.canvas?this.cache.canvas:t.createElement("canvas"),o=Math.floor(n.x),s=Math.floor(n.y),i=Math.ceil(n.x+n.width),a=Math.ceil(n.y+n.height),l=this.pixelRatio||1,c=Math.ceil(Math.max(i-o,1)*l),u=Math.ceil(Math.max(a-s,1)*l);if(c<=0||u<=0)return;r.width=c,r.height=u;const f=r.getContext("2d");f&&(f.clearRect(0,0,r.width,r.height),f.save(),f.scale(l,l),f.translate(-o,-s),this._drawImpl(f),f.restore(),this.cache={...this.cache||{},canvas:r,canvasKey:this._optionsToKey()})}_optionsToKey(){const{options:t}=this;return`${t.backgroundColor};${t.borderColor};${t.borderWidth};${this.pixelRatio}`}_drawImpl(t){const{feature:n}=this,{options:r}=this;t.beginPath(),this.projectionScale.geoPath.context(t)(n),r.backgroundColor&&(t.fillStyle=r.backgroundColor,t.fill()),r.borderColor&&(t.strokeStyle=r.borderColor,t.lineWidth=r.borderWidth,t.stroke())}draw(t){const{feature:n}=this;if(!n)return;(!this.cache||this.cache.canvasKey!==this._optionsToKey())&&t.canvas.ownerDocument!=null&&this._drawInCache(t.canvas.ownerDocument);const r=this.getBounds();if(this.cache&&this.cache.canvas&&this.cache.canvas.width>0&&this.cache.canvas.height>0){const o=Math.floor(r.x),s=Math.floor(r.y),i=Math.ceil(r.x+r.width),a=Math.ceil(r.y+r.height),l=i-o,c=a-s;l>0&&c>0&&t.drawImage(this.cache.canvas,o,s,i-o,a-s)}else Number.isFinite(r.x)&&(t.save(),this._drawImpl(t),t.restore())}}qa.id="geoFeature";qa.defaults={...Ti.defaults,outlineBackgroundColor:null,outlineBorderWidth:0,graticuleBorderColor:"#CCCCCC",graticuleBorderWidth:0};qa.defaultRoutes={outlineBorderColor:"borderColor",...Ti.defaultRoutes||{}};const IB={showOutline:!1,showGraticule:!1,clipMap:!0},OB={scales:{projection:{axis:"x",type:nd.id,position:"chartArea",display:!1}}};function VO(e){const t={...e};return Object.keys(e).forEach(n=>{let r=n;if(n.startsWith("outline")){const o=n.slice(7);r=o[0].toLowerCase()+o.slice(1)}else if(n.startsWith("hoverOutline"))r=`hover${n.slice(12)}`;else return;delete t[n],t[r]=e[n]}),t}class FB extends bs{getGeoDataset(){return super.getDataset()}getGeoOptions(){return this.chart.options}getProjectionScale(){return this.getScaleForId("projection")}linkScales(){const t=this.getGeoDataset(),n=this.getMeta();n.xAxisID="projection",t.xAxisID="projection",n.yAxisID="projection",t.yAxisID="projection",n.xScale=this.getScaleForId("projection"),n.yScale=this.getScaleForId("projection"),this.getProjectionScale().computeBounds(this.resolveOutline())}showOutline(){return rt(this.getGeoDataset().showOutline,this.getGeoOptions().showOutline)}clipMap(){return rt(this.getGeoDataset().clipMap,this.getGeoOptions().clipMap)}getGraticule(){return rt(this.getGeoDataset().showGraticule,this.getGeoOptions().showGraticule)}update(t){super.update(t);const n=this.getMeta(),r=this.getProjectionScale(),o=r.updateBounds();if(this.showOutline()){const s=n.dataset;if(o&&delete s.cache,s.projectionScale=r,s.pixelRatio=this.chart.currentDevicePixelRatio,t!=="resize"){const i=VO(this.resolveDatasetElementOptions(t)),a={feature:this.resolveOutline(),options:i};this.updateElement(s,void 0,a,t),this.getGraticule()&&(n.graticule=i)}}else this.getGraticule()&&t!=="resize"&&(n.graticule=VO(this.resolveDatasetElementOptions(t)));this.updateElements(n.data,0,n.data.length,t),o&&n.data.forEach(s=>delete s.cache)}resolveOutline(){const n=this.getGeoDataset().outline||{type:"Sphere"};return Array.isArray(n)?{type:"FeatureCollection",features:n}:n}showGraticule(){const t=this.getGraticule(),n=this.getMeta().graticule;if(!t||!n)return;const{ctx:r}=this.chart,s=this.getProjectionScale().geoPath.context(r);if(r.save(),r.beginPath(),typeof t=="boolean")t&&s(uxe());else{const i=Q7();t.stepMajor&&i.stepMajor(t.stepMajor),t.stepMinor&&i.stepMinor(t.stepMinor),s(i())}r.strokeStyle=n.graticuleBorderColor,r.lineWidth=n.graticuleBorderWidth,r.stroke(),r.restore()}draw(){const{chart:t}=this,n=this.clipMap();let r=!1;(n===!0||n==="outline"||n==="outline+graticule")&&(r=!0,fu(t.ctx,t.chartArea)),this.showOutline()&&this.getMeta().dataset&&this.getMeta().dataset.draw.call(this.getMeta().dataset,t.ctx,t.chartArea),n===!0||n==="graticule"||n==="outline+graticule"?r||fu(t.ctx,t.chartArea):r&&(r=!1,hu(t.ctx)),this.showGraticule(),n===!0||n==="items"?r||fu(t.ctx,t.chartArea):r&&(r=!1,hu(t.ctx)),this.getMeta().data.forEach(o=>o.draw.call(o,t.ctx,t.chartArea)),r&&(r=!1,hu(t.ctx))}}function $B(e,t,n,r=[],o=[]){or.addControllers(n),Array.isArray(r)?or.addElements(...r):or.addElements(r),Array.isArray(o)?or.addScales(...o):or.addScales(o);const s=t;return s.type=e,s}class Nh extends FB{initialize(){super.initialize(),this.enableOptionSharing=!0}linkScales(){super.linkScales();const t=this.getGeoDataset(),n=this.getMeta();n.vAxisID="color",n.rAxisID="color",t.vAxisID="color",t.rAxisID="color",n.rScale=this.getScaleForId("color"),n.vScale=n.rScale,n.iScale=n.xScale,n.iAxisID=n.xAxisID,t.iAxisID=n.xAxisID}_getOtherScale(t){return t}parse(t,n){const r=this.getMeta().rScale,{data:o}=this.getDataset(),s=this._cachedMeta;for(let i=t;i<t+n;i+=1)s._parsed[i]={[r.axis]:r.parse(o[i],i)}}updateElements(t,n,r,o){const s=this.resolveDataElementOptions(n,o),i=this.getSharedOptions(s),a=this.includeOptions(o,i),l=this.getProjectionScale();this.updateSharedOptions(i,o,s);for(let c=n;c<n+r;c+=1){const u=t[c];u.projectionScale=l,u.feature=this._data[c].feature,u.center=this._data[c].center,u.pixelRatio=this.chart.currentDevicePixelRatio;const f=u.getCenterPoint(),h={x:f.x,y:f.y};a&&(h.options=i||this.resolveDataElementOptions(c,o)),this.updateElement(u,c,h,o)}}indexToColor(t){const n=this.getMeta().rScale;return n.getColorForValue(this.getParsed(t)[n.axis])}}Nh.id="choropleth";Nh.defaults=lr({},[IB,{datasetElementType:qa.id,dataElementType:qa.id}]);Nh.overrides=lr({},[OB,{plugins:{tooltip:{callbacks:{title(){return""},label(e){var t,n,r,o;return e.formattedValue==null?(n=(t=e.chart.data)===null||t===void 0?void 0:t.labels)===null||n===void 0?void 0:n[e.dataIndex]:`${(o=(r=e.chart.data)===null||r===void 0?void 0:r.labels)===null||o===void 0?void 0:o[e.dataIndex]}: ${e.formattedValue}`}}},colors:{enabled:!1}},scales:{color:{type:ql.id,axis:"x"}},elements:{geoFeature:{backgroundColor(e){return e.dataIndex==null?null:e.chart.getDatasetMeta(e.datasetIndex).controller.indexToColor(e.dataIndex)}}}}]);class Iwe extends fn{constructor(t,n){super(t,$B("choropleth",n,Nh,qa,[ql,nd]))}}Iwe.id=Nh.id;class kh extends FB{initialize(){super.initialize(),this.enableOptionSharing=!0}linkScales(){super.linkScales();const t=this.getGeoDataset(),n=this.getMeta();n.vAxisID="size",n.rAxisID="size",t.vAxisID="size",t.rAxisID="size",n.rScale=this.getScaleForId("size"),n.vScale=n.rScale,n.iScale=n.xScale,n.iAxisID=n.xAxisID,t.iAxisID=n.xAxisID}_getOtherScale(t){return t}parse(t,n){const r=this.getMeta().rScale,o=this.getDataset().data,s=this._cachedMeta;for(let i=t;i<t+n;i+=1){const a=o[i];s._parsed[i]={x:a.longitude==null?a.x:a.longitude,y:a.latitude==null?a.y:a.latitude,[r.axis]:r.parse(a,i)}}}updateElements(t,n,r,o){const s=o==="reset",i=this.resolveDataElementOptions(n,o),a=this.getSharedOptions(i),l=this.includeOptions(o,a),c=this.getProjectionScale();this.getMeta().rScale._model=i,this.updateSharedOptions(a,o,i);for(let u=n;u<n+r;u+=1){const f=t[u],h=this.getParsed(u),p=c.projection([h.x,h.y]),m={x:p?p[0]:0,y:p?p[1]:0,skip:Number.isNaN(h.x)||Number.isNaN(h.y)};l&&(m.options=a||this.resolveDataElementOptions(u,o),s&&(m.options.radius=0)),this.updateElement(f,u,m,o)}}indexToRadius(t){const n=this.getMeta().rScale;return n.getSizeForValue(this.getParsed(t)[n.axis])}}kh.id="bubbleMap";kh.defaults=lr({},[IB,{dataElementType:bu.id,datasetElementType:qa.id,showOutline:!0,clipMap:"outline+graticule"}]);kh.overrides=lr({},[OB,{plugins:{tooltip:{callbacks:{title(){return""},label(e){var t,n,r,o;return e.formattedValue==null?(n=(t=e.chart.data)===null||t===void 0?void 0:t.labels)===null||n===void 0?void 0:n[e.dataIndex]:`${(o=(r=e.chart.data)===null||r===void 0?void 0:r.labels)===null||o===void 0?void 0:o[e.dataIndex]}: ${e.formattedValue}`}}}},scales:{size:{axis:"x",type:Gl.id}},elements:{point:{radius(e){return e.dataIndex==null?null:e.chart.getDatasetMeta(e.datasetIndex).controller.indexToRadius(e.dataIndex)},hoverRadius(e){return e.dataIndex==null?null:e.chart.getDatasetMeta(e.datasetIndex).controller.indexToRadius(e.dataIndex)+1}}}}]);class Owe extends fn{constructor(t,n){super(t,$B("bubbleMap",n,kh,qa,[Gl,nd]))}}Owe.id=kh.id;function Fwe(e){var n;return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{display:!0},y:{display:!0}},plugins:{...(n=e==null?void 0:e.options)==null?void 0:n.plugins,legend:{position:"bottom",align:"center"}}}}}function $we(e){var n;return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{beginAtZero:!0,stack:1,reverse:!0},y:{stacked:!0,beginAtZero:!0}},plugins:{...(n=e==null?void 0:e.options)==null?void 0:n.plugins,legend:{position:"bottom",align:"center"}}}}}function Lwe(e){var n;return{...e,type:"bar",options:{...e==null?void 0:e.options,scales:{x:{display:!0},y:{display:!0}},plugins:{...(n=e==null?void 0:e.options)==null?void 0:n.plugins,legend:{position:"bottom",align:"center"}}}}}function zwe(e,t=!1){var r;return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{display:!0,beginAtZero:!1},y:{display:!0,stacked:t}},plugins:{...(r=e==null?void 0:e.options)==null?void 0:r.plugins,legend:{position:"bottom",align:"center"}}}}}function Bwe(e,t){var r,o,s,i,a;return{...e,type:t==="stackedBar"?"bar":"line",options:{...e==null?void 0:e.options,scales:{x:{...(o=(r=e==null?void 0:e.options)==null?void 0:r.scales)==null?void 0:o.x,display:!0,stacked:!0},y:{...(i=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:i.y,display:!0,stacked:t==="stackedBar"}},plugins:{...(a=e==null?void 0:e.options)==null?void 0:a.plugins,legend:{display:!1,position:"bottom",align:"center"}}}}}function Vwe(e){var n;return{...e,type:"line",options:{...e==null?void 0:e.options,scales:{x:{display:!0},y:{display:!0}},plugins:{...(n=e==null?void 0:e.options)==null?void 0:n.plugins,legend:{position:"bottom",align:"center"}}}}}function Hwe(e,t){var r;return{...t,type:e,options:{...t==null?void 0:t.options,scales:{x:{display:!1},y:{display:!1}},plugins:{...(r=t==null?void 0:t.options)==null?void 0:r.plugins,legend:{position:"bottom",align:"center",maxHeight:0,labels:{useBorderRadius:!0,borderRadius:2}}},borderRadius:0}}}function Uwe(e){var r,o;const t=te.getState().theme;let n={...e,type:"radar",options:{...e==null?void 0:e.options,scales:{x:{display:!1},y:{display:!1},r:{grid:{display:!0},angleLines:{},ticks:{}}},plugins:{...(r=e==null?void 0:e.options)==null?void 0:r.plugins,legend:{position:"bottom",align:"center"}}}};return t==="dark"&&(n={...n,options:{...n.options,scales:{...(o=n==null?void 0:n.options)==null?void 0:o.scales,r:{grid:{color:dn.slate[800]},angleLines:{color:dn.slate[800]},ticks:{color:dn.slate[800],showLabelBackdrop:!1}}}}}),n}function Wwe(e,t,n){const r={interaction:{mode:"point"},plugins:{tooltip:{callbacks:{label:function(s){var p;const i=s.dataset.label,a=s.dataIndex,l=s.dataset.data,c=(p=l==null?void 0:l[a])==null?void 0:p.label,u=n==null?void 0:n[0],f=n==null?void 0:n[1],h=n==null?void 0:n[2];if(t==="bubble")return c?`${i} (${c}): ${u}: ${s.raw.x.toFixed(2)}, ${f}: ${s.raw.y.toFixed(2)}, ${h}: ${s.raw.r.toFixed(2)}`:`${i}: ${u}: ${s.raw.x.toFixed(2)}, ${f}: ${s.raw.y.toFixed(2)}, ${h}: ${s.raw.r.toFixed(2)}`;if(t==="scatter")return c?`${i} (${c}): ${u}: ${s.raw.x.toFixed(2)}, ${f}: ${s.raw.y.toFixed(2)}`:`${i}: ${u}: ${s.raw.x.toFixed(2)}, ${f}: ${s.raw.y.toFixed(2)}`}}},datalabels:{display:!1}},scales:{x:{title:{display:!0,text:n[0]},beginAtZero:!0,ticks:{precision:0}},y:{title:{display:!0,text:n[1]},beginAtZero:!0,ticks:{precision:0}}}};return{...e,options:{...e==null?void 0:e.options,...r}}}function No({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:o="",locale:s="en-US"}){let i=1,a=r,l=s;const c=t;n&&!r&&(e>=1e9?(i=1e9,a="B"):e>=1e7&&s==="en-IN"?(i=1e7,a="Cr"):e>=1e5&&s==="en-IN"?(i=1e5,a="L"):e>=1e6?(i=1e6,a="M"):e>=1e3&&(i=1e3,a="K"));const u=e/i,f={maximumFractionDigits:c,minimumFractionDigits:c,useGrouping:!0};if(o){f.style="currency",f.currency=o;try{new Intl.NumberFormat(s,f).format(0)}catch{}}try{new Intl.NumberFormat(s,f).format(0)}catch{l="en-US"}let p=new Intl.NumberFormat(l,f).format(u);return n&&(p+=a),p}function Aw(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function qwe({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:s}){var M,T,O,I,A;const i=((M=r==null?void 0:r.chartOptions)==null?void 0:M.indexAxis)||"y",a={...t,options:{indexAxis:i}},{keys:l}=Xn(e),c=[l[1]],u=l==null?void 0:l[0],f=Az(c,e,r,u),h=uu(f,n);h.forEach(($,H)=>{var U,B,P;$.shrinkAnchor=((P=(B=(U=n==null?void 0:n.data)==null?void 0:U.datasets)==null?void 0:B[H])==null?void 0:P.shrinkAnchor)||"top"});const{plugins:p,options:m}=Ew((r==null?void 0:r.customVisualCode)||""),b=l[0],y=$g(e,b),g=Nr((a==null?void 0:a.options)||{},(n==null?void 0:n.options)||{}),x=Nr(g,(r==null?void 0:r.chartOptions)||{});Array(h.length).fill(!0);const v=e.map($=>$[b]),w=e.map($=>$[c[0]]),C=(T=h[0])==null?void 0:T.backgroundColor.slice(),S={...x,plugins:{...x.plugins,legend:{...(O=x.plugins)==null?void 0:O.legend,labels:{generateLabels:$=>{const H=$.data.labels;return v.map((U,B)=>({text:U,fillStyle:C[B],hidden:!H.includes(U.toString()),index:B,datasetIndex:0,lineWidth:0}))}},onClick:($,H,U)=>{const B=U.chart,P=H.index,z=v[P],L=B.data.datasets[0],D=B.data.labels,W=L.data,G=L.backgroundColor,Z=D.indexOf(z.toString());Z>=0?(D.splice(Z,1),W.splice(Z,1),G.splice(Z,1)):(D.splice(P,0,v[P].toString()),W.splice(P,0,Number(w[P])),G.splice(P,0,C[P])),B.update()}},datalabels:{...(I=x.plugins)==null?void 0:I.datalabels,anchor:$=>$.dataset.data[$.dataIndex]<.02?"end":"start",align:$=>$.dataset.data[$.dataIndex]<.02?"end":"center",textAlign:"center",font:{size:14},formatter:($,H)=>{var U,B,P,z;return No({number:Number($),decimalPlaces:((U=r==null?void 0:r.numberAxisFormat)==null?void 0:U.decimalPlaces)||0,useSuffix:!!((B=r==null?void 0:r.numberAxisFormat)!=null&&B.suffix),customSuffix:"",locale:((P=r==null?void 0:r.numberAxisFormat)==null?void 0:P.locale)||"",currency:((z=r==null?void 0:r.numberAxisFormat)==null?void 0:z.currency)||""})}},tooltip:{...(A=x.plugins)==null?void 0:A.tooltip,callbacks:{title:function($){var z,L,D,W;const U=((L=(z=$==null?void 0:$[0])==null?void 0:z.dataset)==null?void 0:L.data).reduce((G,Z)=>G+Z,0),P=(((D=$==null?void 0:$[0])==null?void 0:D.parsed[i==="x"?"y":"x"])/U*100).toFixed(2);return`${(W=$==null?void 0:$[0])==null?void 0:W.label} (${P}%)`},label:function($){var W,G,Z,V;$.dataset.label;const H=$.dataset.data;H.reduce((F,q)=>F+q,0);const U=$.parsed[i==="x"?"y":"x"],B=H.indexOf(U),P=H[B-1],z=No({number:Number(U),decimalPlaces:((W=r==null?void 0:r.numberAxisFormat)==null?void 0:W.decimalPlaces)||0,useSuffix:!!((G=r==null?void 0:r.numberAxisFormat)!=null&&G.suffix),customSuffix:"",locale:((Z=r==null?void 0:r.numberAxisFormat)==null?void 0:Z.locale)||"",currency:((V=r==null?void 0:r.numberAxisFormat)==null?void 0:V.currency)||""});let L=0;return P!==void 0&&(L=Number((U/P*100).toFixed(2))),z+(P!==void 0?` | Conversion: ${L}%`:"")},footer:function($){var U,B,P,z;return(((B=(U=s==null?void 0:s.interactionConfig)==null?void 0:U.drillHierarchies)==null?void 0:B.length)??0)>0||(((z=(P=s==null?void 0:s.interactionConfig)==null?void 0:P.drillInteractions)==null?void 0:z.length)??0)>0?["─────────────────","Right click to drill"]:[]}}}}},N=Nr(x,S),j=r!=null&&r.dataLabelsConfig?Gj(N,r.dataLabelsConfig,r,"funnel"):N,_=Nr(j,m);return delete _.scales,{type:o,data:{labels:y,datasets:h},options:_,plugins:[...p]}}function Gwe({data:e,cfg:t,customCfg:n,preferences:r,card:o}){var S,N;const s=zwe(t),i=Ywe(e),a=uu(i,n),{plugins:l,options:c}=Ew((r==null?void 0:r.customVisualCode)||""),u=Nr((s==null?void 0:s.options)||{},(t==null?void 0:t.options)||{}),f=Nr(u,(r==null?void 0:r.chartOptions)||{}),h=Nr(f,(n==null?void 0:n.options)||{}),p={...h,plugins:{...h==null?void 0:h.plugins,tooltip:{...(S=h==null?void 0:h.plugins)==null?void 0:S.tooltip,callbacks:{label:function(j){if(Array.isArray(j.raw)&&j.raw.every(_=>_===null))return null},footer:function(j){var R,M,T,O;return(((M=(R=o==null?void 0:o.interactionConfig)==null?void 0:R.drillHierarchies)==null?void 0:M.length)??0)>0||(((O=(T=o==null?void 0:o.interactionConfig)==null?void 0:T.drillInteractions)==null?void 0:O.length)??0)>0?["─────────────────","Right click to drill"]:[]}}}}},m=Nr(p,c),b=H9(t,r),y=Nr(m,b);let g;r!=null&&r.dataLabelsConfig?g=Gj(y,r.dataLabelsConfig,r,"range"):g={...y,plugins:{...y==null?void 0:y.plugins,datalabels:{...(N=y==null?void 0:y.plugins)==null?void 0:N.datalabels,formatter:(j,_)=>j.map(M=>{var T,O,I,A;return No({number:Number(M),decimalPlaces:((T=r==null?void 0:r.numberAxisFormat)==null?void 0:T.decimalPlaces)||0,useSuffix:!!((O=r==null?void 0:r.numberAxisFormat)!=null&&O.suffix),customSuffix:"",locale:((I=r==null?void 0:r.numberAxisFormat)==null?void 0:I.locale)||"",currency:((A=r==null?void 0:r.numberAxisFormat)==null?void 0:A.currency)||""})}).slice(0,2).join(" - ")}}};const{keys:x}=Xn(e),v=x[0];return{type:"bar",data:{labels:[...new Set($g(e,v))],datasets:a},options:g,plugins:[...l]}}function Ywe(e){var h,p,m,b;const{keys:t}=Xn(e),n=t.slice(0,2),r=t.slice(2),o=te.getState().themeStyle,s=(p=(h=o==null?void 0:o.chart)==null?void 0:h.dataset)==null?void 0:p.backgroundColor,i=(b=(m=o==null?void 0:o.chart)==null?void 0:m.dataset)==null?void 0:b.borderColor,a=n[1],l=n[0],c=[...new Set(e.map(y=>y==null?void 0:y[l]))];return[...new Set(e.map(y=>y==null?void 0:y[a]))].map((y,g)=>{const x=e.filter(C=>(C==null?void 0:C[a])===y),w=c.map(C=>{const S=x.filter(N=>(N==null?void 0:N[l])===C);return S.length===0?[[null,null,null]]:S.map(N=>[N==null?void 0:N[r[0]],N==null?void 0:N[r[1]],N==null?void 0:N[r[2]],C])}).flat();return{label:y,data:w,backgroundColor:s==null?void 0:s[g%s.length],borderColor:i==null?void 0:i[g%i.length],borderSkipped:!1}})}function Zwe({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:s}){var w;const i=$we(t),{keys:a}=Xn(e),l=dw({dataArray:e,groupKey:a[0],pivotKey:a[1],valueKey:a[2]}),{keys:c}=Xn(l),u=c.slice(1),f=Pz(u,l,r),h=uu(f,n),p=c[0],m=$g(l,p),{options:b,plugins:y}=Wp({cardType:o,cfg:i,preferences:r,customCfg:n,card:s}),g={type:(n==null?void 0:n.type)||(i==null?void 0:i.type)||"bar",data:{labels:m,datasets:h},options:b,plugins:y},x="x2";return{...g,data:{...g.data,datasets:g.data.datasets.map((C,S)=>S===1?{...C,xAxisID:x}:C)},options:{...g.options,scales:{...(w=g==null?void 0:g.options)==null?void 0:w.scales,[x]:{beginAtZero:!0,stack:1}}}}}function CR({card:e,data:t,cardType:n="bar",cfg:r,customCfg:o,provider:s="chartjs",userSettings:i,preferences:a,topoJson:l,queryConfig:c}){var m,b,y,g,x,v,w,C;const u=e.config;let f=t;const h=u&&u.pivotByColumns&&u.pivotByColumns.length>0,p=u&&u.groupByColumns&&u.groupByColumns.length>0;if(h&&p&&(f=Rpe(t,(u==null?void 0:u.metricColumns)||[])),n==="map"){if(!l)return null;const S=(m=a==null?void 0:a.mapVisualOptions)==null?void 0:m.objectKey;if(!S)return null;const N=Mwe(l,(b=l==null?void 0:l.objects)==null?void 0:b[S]).features;if(!N)return null;const j={plugins:{datalabels:{display:!1}},scales:{x:{display:!1,grid:{display:!1}},y:{display:!1,grid:{display:!1}},projection:{axis:"x",projection:((y=a==null?void 0:a.mapVisualOptions)==null?void 0:y.projection)||"mercator",projectionScale:((g=a==null?void 0:a.mapVisualOptions)==null?void 0:g.projectionScale)||1,projectionOffset:((x=a==null?void 0:a.mapVisualOptions)==null?void 0:x.projectionOffset)||[0,0]},color:{axis:"x",interpolate:((v=a==null?void 0:a.mapVisualOptions)==null?void 0:v.colorScale)||"blues",quantize:5,legend:{position:"bottom-right",align:"right"}}}},{keys:_}=Xn(f),R=N.map($=>{var P;const H=_==null?void 0:_[0],U=_==null?void 0:_[1],B=(P=f.find(z=>(z==null?void 0:z[H])===$.properties.NAME||(z==null?void 0:z[H])===$.properties.name))==null?void 0:P[U];return{feature:$,value:B}}),T=uu([{label:S,data:R,borderColor:"lightgray"}],o),O={type:"choropleth",data:{labels:N.map($=>$.properties.NAME||$.properties.name),datasets:T},options:j},{options:I}=Wp({cfg:O,preferences:a,customCfg:o,cardType:n});return{...O,options:I}}if(n==="bar"){const S=Lwe(r);return vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="horizontalBar"){const S=Fwe(r);return vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="funnel")return qwe({data:f,cfg:r,customCfg:o,preferences:a,cardType:n,card:e});if(n==="tornado"||n==="pyramid")return Zwe({data:f,cfg:r,customCfg:o,preferences:a,cardType:n,card:e});if(n==="stackedBar"||n==="stackedLine"){const S=Bwe(r,n),{keys:N}=Xn(f);return(!h||!p)&&(f=dw({dataArray:f,groupKey:N[0],pivotKey:N[1],valueKey:N[2],sortChart:a==null?void 0:a.sortChart})),vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="line"){const S=Vwe(r);return vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="range")return Gwe({data:f,cfg:r,customCfg:o,preferences:a,card:e});if(n==="pie"||n==="doughnut"||n==="polarArea"){const S=Hwe(n,r),{keys:N}=Xn(f),j=N.slice(0,1),_=N.slice(1),R=Az(_,f,a,j==null?void 0:j[0]),M=uu(R,o),{plugins:T,options:O}=Ew((a==null?void 0:a.customVisualCode)||""),I=j[0],A=$g(f,I),$=Nr((S==null?void 0:S.options)||{},(o==null?void 0:o.options)||{}),H=Nr($,(a==null?void 0:a.chartOptions)||{}),U={...H,plugins:{...H.plugins,datalabels:{...(w=H.plugins)==null?void 0:w.datalabels,formatter:(W,G)=>{var Z,V,F,q;return No({number:Number(W),decimalPlaces:((Z=a==null?void 0:a.numberAxisFormat)==null?void 0:Z.decimalPlaces)||0,useSuffix:!!((V=a==null?void 0:a.numberAxisFormat)!=null&&V.suffix),customSuffix:"",locale:((F=a==null?void 0:a.numberAxisFormat)==null?void 0:F.locale)||"",currency:((q=a==null?void 0:a.numberAxisFormat)==null?void 0:q.currency)||""})}},tooltip:{...(C=H.plugins)==null?void 0:C.tooltip,callbacks:{label:function(W){var Y,ee,X,ne;W.dataset.label;const Z=W.dataset.data.reduce((se,re)=>se+re,0),V=W.parsed,F=No({number:Number(V),decimalPlaces:((Y=a==null?void 0:a.numberAxisFormat)==null?void 0:Y.decimalPlaces)||0,useSuffix:!!((ee=a==null?void 0:a.numberAxisFormat)!=null&&ee.suffix),customSuffix:"",locale:((X=a==null?void 0:a.numberAxisFormat)==null?void 0:X.locale)||"",currency:((ne=a==null?void 0:a.numberAxisFormat)==null?void 0:ne.currency)||""}),q=(V/Z*100).toFixed(2);return F+` (${q}%)`},footer:function(W){var Z,V,F,q;return(((V=(Z=e==null?void 0:e.interactionConfig)==null?void 0:Z.drillHierarchies)==null?void 0:V.length)??0)>0||(((q=(F=e==null?void 0:e.interactionConfig)==null?void 0:F.drillInteractions)==null?void 0:q.length)??0)>0?["─────────────────","Right click to drill"]:[]}}}}},B=Nr(H,U),{options:P}=Wp({cfg:{options:B},preferences:a,customCfg:o,cardType:n,card:e}),z=Nr(P,O);return{type:n,data:{labels:A,datasets:M},options:z,plugins:[n==="doughnut"?{id:"doughnutLabel",beforeDatasetsDraw:function(W,G,Z){var re,ie,be,ue;const{ctx:V,data:F}=W;V.save();const q=W.getDatasetMeta(0).data[0].x,Y=W.getDatasetMeta(0).data[0].y,ee=Aa(Tl()),X=window.getComputedStyle(V.canvas).fontFamily;V.font=`1em ${X}`,V.fontWeight="bolder",V.fillStyle=ee,V.textAlign="center",V.textBaseline="middle";const ne=F.datasets[0].data.reduce((xe,Pe)=>xe+Pe,0),se=No({number:Number(ne),decimalPlaces:((re=a==null?void 0:a.numberAxisFormat)==null?void 0:re.decimalPlaces)||0,useSuffix:!!((ie=a==null?void 0:a.numberAxisFormat)!=null&&ie.suffix),customSuffix:"",locale:((be=a==null?void 0:a.numberAxisFormat)==null?void 0:be.locale)||"",currency:((ue=a==null?void 0:a.numberAxisFormat)==null?void 0:ue.currency)||""});V.fillText(se,q,Y)}}:"",...T]}}if(n==="radar"){const S=Uwe(r);return vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="bubble"||n==="scatter"){const{metricKeys:S}=Xn(f),N=zce(f,n),j=uu(N,o),_=Wwe(r,n,S),{options:R}=Wp({cardType:n,cfg:_,preferences:a,customCfg:o,card:e});return{type:n,data:{datasets:j},options:R}}return vd({card:e,data:f,cfg:r,customCfg:o,cardType:n,preferences:a})}function Kwe({chart:e,elementIndex:t,datasetIndex:n,cardType:r,cfg:o,apply:s}){const i=te.getState().theme;if(!o)return;const a=i==="dark"?"rgb(238,238,238,0.2)":"rgb(238,238,238,0.8)";["bar","line","horizontalBar","bubble","scatter"].includes(r)&&Qwe(e,t,o,s,a),["pie","doughnut","polarArea","funnel"].includes(r)&&Jwe(e,t,o,s,a),["stackedBar","pyramid"].includes(r)&&Xwe({chart:e,elementIndex:t,datasetIndex:n,cfg:o,apply:s,blurColor:a})}function Xwe(e){var a,l,c,u;const{chart:t,elementIndex:n,datasetIndex:r,cfg:o,apply:s,blurColor:i}=e;s?(l=(a=t==null?void 0:t.data)==null?void 0:a.datasets)==null||l.forEach((f,h)=>{var p,m;typeof f.backgroundColor=="string"&&(f.backgroundColor=new Array(f.data.length).fill(f.backgroundColor),f.borderColor=new Array(f.data.length).fill(f.borderColor)),f.backgroundColor=(p=f==null?void 0:f.backgroundColor)==null?void 0:p.map((b,y)=>y===n&&h===r?b:i),f.borderColor=(m=f==null?void 0:f.borderColor)==null?void 0:m.map((b,y)=>y===n&&h===r?b:i)}):(u=(c=t==null?void 0:t.data)==null?void 0:c.datasets)==null||u.forEach((f,h)=>{var p,m,b,y,g,x;f.backgroundColor=new Array(f.data.length).fill((b=(m=(p=o==null?void 0:o.data)==null?void 0:p.datasets)==null?void 0:m[h])==null?void 0:b.backgroundColor),f.borderColor=new Array(f.data.length).fill((x=(g=(y=o==null?void 0:o.data)==null?void 0:y.datasets)==null?void 0:g[h])==null?void 0:x.borderColor)}),t==null||t.update()}function Qwe(e,t,n,r,o){var s,i,a,l;r?(i=(s=e==null?void 0:e.data)==null?void 0:s.datasets)==null||i.forEach(c=>{var u,f;typeof c.backgroundColor=="string"&&(c.backgroundColor=new Array(c.data.length).fill(c.backgroundColor),c.borderColor=new Array(c.data.length).fill(c.borderColor)),c.backgroundColor=(u=c==null?void 0:c.backgroundColor)==null?void 0:u.map((h,p)=>p===t?h:o),c.borderColor=(f=c==null?void 0:c.borderColor)==null?void 0:f.map((h,p)=>p===t?h:o)}):(l=(a=e==null?void 0:e.data)==null?void 0:a.datasets)==null||l.forEach((c,u)=>{var f,h,p,m,b,y;c.backgroundColor=new Array(c.data.length).fill((p=(h=(f=n==null?void 0:n.data)==null?void 0:f.datasets)==null?void 0:h[u])==null?void 0:p.backgroundColor),c.borderColor=new Array(c.data.length).fill((y=(b=(m=n==null?void 0:n.data)==null?void 0:m.datasets)==null?void 0:b[u])==null?void 0:y.borderColor)}),e==null||e.update()}function Jwe(e,t,n,r,o){var s,i,a,l;r?(i=(s=e==null?void 0:e.data)==null?void 0:s.datasets)==null||i.forEach(c=>{var u,f;c.backgroundColor=(u=c==null?void 0:c.backgroundColor)==null?void 0:u.map((h,p)=>p===t?h:o),c.borderColor=(f=c==null?void 0:c.borderColor)==null?void 0:f.map((h,p)=>p===t?h:o)}):(l=(a=e==null?void 0:e.data)==null?void 0:a.datasets)==null||l.forEach((c,u)=>{var f,h,p,m,b,y,g,x;typeof c.backgroundColor=="string"&&(c.backgroundColor=(p=(h=(f=n==null?void 0:n.data)==null?void 0:f.datasets)==null?void 0:h[u])==null?void 0:p.backgroundColor,c.borderColor=(y=(b=(m=n==null?void 0:n.data)==null?void 0:m.datasets)==null?void 0:b[u])==null?void 0:y.borderColor),c.backgroundColor=(g=c==null?void 0:c.backgroundColor)==null?void 0:g.map((v,w)=>{var C;return(C=n.data.datasets[u].backgroundColor)==null?void 0:C[w]}),c.borderColor=(x=c==null?void 0:c.borderColor)==null?void 0:x.map((v,w)=>{var C;return(C=n.data.datasets[u].borderColor)==null?void 0:C[w]})}),e==null||e.update()}function e1e({card:e,data:t,datasetIndex:n,clickIndex:r,value:o}){var s,i,a,l,c,u,f;try{if(!t)return;const{keys:h}=Xn(t);if(e.type==="map"){const p=h[0],m=((i=(s=o==null?void 0:o.feature)==null?void 0:s.properties)==null?void 0:i.name)||((l=(a=o==null?void 0:o.feature)==null?void 0:a.properties)==null?void 0:l.NAME);return[{columnName:p,columnValue:m}]}if(["bar","horizontalBar","line","pie","doughnut","radar","polarArea","funnel"].includes(e.type)){const p=h[0],m=h.slice(1),b=(c=t[r])==null?void 0:c[p];return[{columnName:p,columnValue:b,metric:m[n],value:o}]}if(["stackedBar","pyramid"].includes(e.type)){const p=dw({dataArray:t,groupKey:h[0],pivotKey:h[1],valueKey:h[2]}),m=h[0],b=(u=p[r])==null?void 0:u[m],y=h[1],{keys:g}=Xn(p),v=g.slice(1)[n];return[{columnName:m,columnValue:b,metric:h[2],value:o},{columnName:y,columnValue:v,metric:h[2],value:o}]}if(e.type==="bubble"||e.type==="scatter"){const p=h[0],m=(f=t[n])==null?void 0:f[p];return console.log(o,"bubble"),[{columnName:p,columnValue:m,metric1:h[1],value1:o.x,metric2:h[2],value2:o.y,metric3:h==null?void 0:h[3],value3:o==null?void 0:o.r}]}}catch(h){console.error("Error in getAdhocFilter",h)}}function t1e(e,t){var r,o;if((((r=e.data.datasets)==null?void 0:r.filter(s=>!!s.fill))||[]).length>0){const s=(o=e==null?void 0:e.data.datasets)==null?void 0:o.map(a=>({...a,backgroundColor:[a.backgroundColor].map(l=>{const c=t.createLinearGradient(0,0,0,400);return c.addColorStop(0,l),c.addColorStop(.7,jpe("--semaphor-background")),c})}));return{...e,data:{...e.data,datasets:s}}}return e}function LB(e){var a,l,c,u,f,h;const t=(((l=(a=e.preferences)==null?void 0:a.mapVisualOptions)==null?void 0:l.topoJsonUrl)==="custom"?(u=(c=e.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:u.customTopoJsonUrl:(h=(f=e.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:h.topoJsonUrl)||"",n=!!t&&e.type==="map",{data:r,isLoading:o,isFetching:s,isError:i}=yn({queryKey:["topojson",t],queryFn:()=>fetch(t).then(p=>p.json()),enabled:n,staleTime:1/0});return{data:r,isLoading:o,isFetching:s,isError:i}}function n1e(e,t,n){if(e===t)return!0;const r=new Map;for(const i of n){const a=i.source.name,l=i.target.name;r.has(a)||r.set(a,new Set),r.get(a).add(l),r.has(l)||r.set(l,new Set),r.get(l).add(a)}const o=new Set,s=[e];for(o.add(e);s.length>0;){const i=s.shift(),a=r.get(i);if(a)for(const l of a){if(l===t)return!0;o.has(l)||(o.add(l),s.push(l))}}return!1}function zB(e,t){var m,b,y,g,x,v,w;const{joinabilityMap:n,selectedFields:r,cardConfig:o,autoJoinMetadata:s,baseEntityName:i}=t;if(!n)return{state:"draggable"};if(r.length===0)return{state:"draggable",tooltip:"Select to establish base dataset"};let a;const l=(b=(m=o==null?void 0:o.joinPlan)==null?void 0:m.baseEntity)==null?void 0:b.name,c=(g=(y=s==null?void 0:s.resolvedJoinPlan)==null?void 0:y.baseEntity)==null?void 0:g.name;l?a=l:c?a=c:i?a=i:a=[...new Set(r.map(S=>S.entityName))].filter(Boolean)[0];const u=r.some(C=>C.entityName===e.entityName&&(C.name===e.name||C.id===e.id));if(e.entityName===a)return{state:"base",tooltip:u?"Field already in query (base dataset)":"From base dataset",isSelected:u};const f=n[a];if(!f)return{state:"unreachable",tooltip:"No relationships defined for base dataset"};if(f.canJoinTo.includes(e.entityName))return{state:"draggable",tooltip:`Direct join from ${a}`,joinPath:[a,e.entityName],isSelected:u};const h=(x=f.indirectJoins)==null?void 0:x[e.entityName];if(h&&h.length>0){const C=[a,...h,e.entityName];return{state:"indirect",joinPath:C,tooltip:`Multi-hop join: ${C.join(" → ")}`,isSelected:u}}const p=n[e.entityName];if(p){if(p.canJoinTo.includes(a))return{state:"draggable",tooltip:`Direct join to ${a}`,joinPath:[e.entityName,a],isSelected:u};const C=(v=p.indirectJoins)==null?void 0:v[a];if(C&&C.length>0){const S=[e.entityName,...C,a];return{state:"indirect",joinPath:S,tooltip:`Multi-hop join: ${S.join(" → ")}`,isSelected:u}}}return(w=o==null?void 0:o.joinPlan)!=null&&w.joins&&o.joinPlan.joins.length>0&&n1e(a,e.entityName,o.joinPlan.joins)?{state:"draggable",tooltip:"Manual join configured",isSelected:u}:{state:"unreachable",tooltip:`Cannot join ${e.entityName} to ${a}`,isSelected:u}}function BB(e,t,n){var r;return!n||!((r=n.baseEntity)!=null&&r.name)||!n.joins?!1:e===t||e===zd(n.baseEntity)||t===zd(n.baseEntity)?!0:n.joins.some(o=>{const s=zd(o.source),i=zd(o.target);return s===e&&i===t||s===t&&i===e})}function r1e(e,t,n){var a;const{joinPlan:r,joinabilityMap:o,semanticDomainId:s}=n;if(t.length===0)return{isValid:!0};const i=t[0].qualifiedEntityName;if(!i)return{isValid:!0};if(i===e.qualifiedEntityName)return{isValid:!0};if(e.qualifiedEntityName){if(s&&o)return zB(e,{joinabilityMap:o,selectedFields:t,baseEntityName:(a=r==null?void 0:r.baseEntity)==null?void 0:a.name}).state==="unreachable"?{isValid:!1,showError:!0}:{isValid:!0};if(!r)return{isValid:!1,showError:!0};if(!BB(i,e.qualifiedEntityName,r))return{isValid:!1,showError:!0}}return{isValid:!0}}function o1e(){Le.error("Join Configuration Required",{richColors:!0,description:"To combine fields from two different tables, you need to define a join between them first.",position:"top-center",duration:4e3})}function s1e(e,t){return t.some(n=>{if(!(n.name===e.name&&n.qualifiedEntityName===e.qualifiedEntityName))return!1;if((e.role==="metric"||!e.role)&&n.role==="metric"){const o=e,s=n;if(o.aggregate!==s.aggregate||o.expression!==s.expression)return!1;if(o.parameters||s.parameters){const i=o.parameters||{},a=s.parameters||{},l=JSON.stringify(i),c=JSON.stringify(a);if(l!==c)return!1}return!1}return!0})}function i1e(e){if(e.role!=="metric")return e.label||e.name;const t=e,n=e.label||e.name;if(!t.parameters||!t.parameters.filters)return n;const r=t.parameters.filters;return typeof r=="string"?`${n} (${r})`:typeof r=="object"?(JSON.stringify(r),`${n} (Filtered)`):n}function a1e(e,t,n){const r=e.label||e.name,o=t.filter(s=>s.name===e.name&&s.qualifiedEntityName===e.qualifiedEntityName&&(s.role==="metric"||n==="metrics")).length;return o===0?r:`${r} (${o+1})`}function VB(e,t){return`${e}-${t.qualifiedEntityName}-${t.name}-${Date.now()}`}function HB(e,t){const n=Oi(e.replace(/_/g," "));switch(t){case"SUM":return`Sum of ${n}`;case"COUNT":return`Count of ${n}`;case"DISTINCT":return`Unique ${n}`;case"AVG":return`Average of ${n}`;case"MIN":return`Min of ${n}`;case"MAX":return`Max of ${n}`;default:return n}}function l1e(e,t,n){const r=uh(e.dataType);return n==="kpi"?r==="date"?"groupBy":"metrics":t.length===0||r==="number"?"metrics":r==="date"||r==="string"||r==="boolean"?"groupBy":"metrics"}function c1e(e,t,n=[]){const r=VB(t,e),o=uh(e.dataType),s=o==="date",i={id:r,name:e.name,dataType:e.dataType,label:c_(e.name),qualifiedEntityName:e.qualifiedEntityName,entityId:e.entityId,entityName:e.entityName,entityType:e.entityType};if(t==="metrics"){const a=o==="number"?"SUM":"COUNT",l=HB(e.label,a),c=a1e({...i,label:l},n,t);return{...i,role:"metric",label:c,aggregate:a}}return t==="groupBy"?{...i,role:"groupby",...s&&{granularity:"month",dateFormat:"YYYY-MM"}}:t==="pivotBy"?{...i,role:"pivotby"}:t==="sortBy"?{...i,role:"sortby",label:e.label,direction:"asc"}:null}function u1e(e){var o,s,i;const t=(o=e.config)==null?void 0:o.metricColumns,n=(s=e.config)==null?void 0:s.groupByColumns,r=(i=e.config)==null?void 0:i.pivotByColumns;return!!(t&&(t==null?void 0:t.length)>0||n&&(n==null?void 0:n.length)>0||r&&(r==null?void 0:r.length)>0)}function d1e(e){var i,a;const[t]=E.useState({id:"",title:"",type:"bar"}),{getCard:n}=en(),r=n(e),o=Iw(r||t),s={...r,data:((i=o==null?void 0:o.data)==null?void 0:i.records)||[]};return{...o,data:((a=o==null?void 0:o.data)==null?void 0:a.records)||[],card:s}}function Iw(e){var T;const{onChartElementClicked:t}=Ue(),[n,r]=E.useState(0),o=te(O=>O.themeStyle),s=te(O=>O.filteringCards),i=te(O=>O.selectedSheetId),a=te(O=>O.selectedLensId),l=te(O=>O.filterValues),c=E.useRef(l),u=(T=e==null?void 0:e.preferences)==null?void 0:T.onClickFilter,{addFilteringCard:f,addOrUpdateFilterValues:h,removeFilterValues:p,removeFilteringCard:m}=en(),{data:b,isLoading:y,isFetching:g,isError:x,isPending:v,queryKey:w,isFilteringCard:C,isSingleCardFrame:S,pagination:N}=Ha(e),{data:j}=LB(e);let _;_=E.useMemo(()=>{if(!(!(b!=null&&b.records)||!(b!=null&&b.records.length)))return CR({card:e,data:b==null?void 0:b.records,cardType:e.type,queryConfig:e.queryConfig,customCfg:e.customCfg,preferences:e.preferences,topoJson:j})},[b==null?void 0:b.records,e,j,o]);const R=E.useRef({filteringCards:s});E.useEffect(()=>{e.connectionId&&!C&&(c.current=l)},[l,a,e.connectionId,C]),E.useEffect(()=>{var I;C&&(R.current.filteringCards=[...s||[]]),!C&&((I=R.current.filteringCards)==null?void 0:I.find(A=>A.id===e.id))&&S&&r(A=>A+1)},[C,S,e.id,s]);function M(O,I,A,$){var B;if(u1e(e))return;let H=!1;if(!(b!=null&&b.records))return;const U=e1e({card:e,data:b==null?void 0:b.records,datasetIndex:I,clickIndex:A,value:$});if(console.log("fieldValues",U),t==null||t(e,U),!!(((B=e==null?void 0:e.preferences)==null?void 0:B.onClickFilter)??[]).length){if(C){const P=e.id;p(P),m(e)}else{if(H=!0,!U)return;const P=[];U.forEach((z,L)=>{const D=u==null?void 0:u.find(G=>G.columnIndex===L);if(!D)return;const W={filterId:e.id+"-"+z.columnName+"-"+i,connectionId:e==null?void 0:e.connectionId,tableName:e.lastSelectedTable,name:z.columnName,expression:D.expression,valueType:Iv(U[D.columnIndex].columnValue),operation:"=",values:[U[D.columnIndex].columnValue]};P.push(W)}),h(P),f(e)}Kwe({chart:O,elementIndex:A,datasetIndex:I,cardType:e.type,cfg:_,apply:H})}}return{isPending:v,isError:x,isLoading:y,isFetching:g,data:b,visualKey:n,handleDatapointClick:M,cfg:_,queryKey:w,pagination:N}}function vC(e,t){if(e==null)return"-";if(!t)return e.toString();const n=t.locale?new Intl.NumberFormat(t.locale).format(e):e.toFixed(t.decimalPlaces||0);return`${t.prefix||""}${n}${t.suffix||""}`}function HO(e,t){return t.map(n=>{const r=n.alias||n.name,o=e[r];return typeof o=="object"&&o!==null&&"label"in o?String(o.label??""):String(o??"")}).join(" | ")}function UB(e,t=0,n=[],r){if(!(e!=null&&e.length)||t>=e[0].fieldValues.length)return[];const o=l=>n.every((c,u)=>l.fieldValues[u]===c),s=e.filter(o),i=[],a=new Set;for(const l of s){const c=l.fieldValues[t];if(a.has(c))continue;a.add(c);const u=[...n,c],f=u.join(" | ");if(r&&!r.has(f))continue;if(t===l.fieldValues.length-1)i.push({name:c,level:t,rowKey:l.rowKey});else{const p=UB(s.filter(m=>m.fieldValues[t]===c),t+1,u,r);p.length>0&&i.push({name:c,level:t,children:p})}}return i}function f1e(e,t={},n){const r=e.records,o=e.pivotSchema||[],s=e.columnSubtotalMeta||[],i=e.groupByColumns||[],a=e.columnMetadata,l=o.filter(T=>T.isPivotColumn),c=o.filter(T=>T.isMetricColumn),u=()=>({rowHeaders:[],columnHeaders:[],cells:{},columnGroups:[],rowGroups:[],columnDisplayNames:{},groupByColumns:i,columnSubtotalMeta:s,columnMetadata:a});if(l.length===0&&c.length===0)return console.warn("No pivot or metric fields found in pivotSchema:",o),u();const{columnGroups:f,columnHeaders:h,columnDisplayNames:p}=h1e(o,s,n==null?void 0:n.config);if(!r.length)return u();const m=r.filter(T=>T.isGrandTotal),b=r.filter(T=>T.isSubtotal&&!T.isGrandTotal),y=r.filter(T=>!T.isSubtotal&&!T.isGrandTotal),g=[],x=new Set;y.forEach(T=>{const O=HO(T,i),I=i.map(A=>{const $=A.alias||A.name,H=T[$];return typeof H=="object"&&H!==null&&"label"in H?String(H.label??""):String(H??"")});O&&!x.has(O)&&(x.add(O),g.push({rowKey:O,fieldValues:I}))}),g.sort((T,O)=>{const I=Math.min(T.fieldValues.length,O.fieldValues.length);for(let A=0;A<I;A++){const $=(T.fieldValues[A]||"").localeCompare(O.fieldValues[A]||"");if($!==0)return $}return T.fieldValues.length-O.fieldValues.length});const v=[],w=[],C=new Set;for(let T=0;T<g.length;T++){const O=g[T];v.push(O),w.push(O.rowKey);const I=g[T+1];for(let A=i.length-1;A>=0;A--){const $=i[A];$.alias||$.name;let H=!1;if(!I)H=!0;else{H=O.fieldValues[A]!==I.fieldValues[A];for(let U=0;U<A&&!H;U++)O.fieldValues[U]!==I.fieldValues[U]&&(H=!0)}H&&b.filter(B=>{const P=$.alias||$.name;if(B.subtotalLevel!==P&&B.subtotalLevel!==$.id)return!1;if(B.subtotalContext){if(B.subtotalContext.value!==O.fieldValues[A])return!1;const z=B.subtotalContext.groupByValues||{};for(let L=0;L<A;L++){const D=i[L],W=D.alias||D.name;if(z[W]!==O.fieldValues[L])return!1}return!0}for(let z=0;z<A;z++){const L=i[z],D=L.alias||L.name,W=B[D],G=O.fieldValues[z],Z=typeof W=="object"&&(W!=null&&W.label)?W.label:String(W??"");if(G!==Z)return!1}return!0}).forEach(B=>{var W;const P=JSON.stringify({level:B.subtotalLevel,context:B.subtotalContext});if(C.has(P))return;const z=[...O.fieldValues],L=`${O.fieldValues[A]} Total`;z[A]=L;for(let G=A+1;G<z.length;G++)z[G]="";const D=z.join(" | ");v.push({rowKey:D,fieldValues:z,isSubtotal:!0,subtotalLevel:B.subtotalLevel,aggregateDisplayLabel:B.aggregate,aggregateFunction:(W=B.aggregate)==null?void 0:W.toUpperCase(),subtotalContext:B.subtotalContext}),w.push(D),C.add(P)})}}const S=v,N=w,j=new Set(S.map(T=>T.rowKey)),_=UB(S,0,[],j),R={};N.forEach(T=>{R[T]={},h.forEach(O=>{R[T][O]={value:null,metricId:"",formattedValue:"-"}})}),y.forEach(T=>{const O=HO(T,i);R[O]&&h.forEach(I=>{if(!(I in T))return;const A=T[I],$=o.find(H=>H.isMetricColumn&&I.startsWith(H.alias));R[O][I]={value:A,metricId:($==null?void 0:$.metricId)||"",formattedValue:vC(A,t.numberFormat)}})}),b.forEach(T=>{const O=S.find(I=>I.isSubtotal&&I.subtotalLevel===T.subtotalLevel&&JSON.stringify(I.subtotalContext)===JSON.stringify(T.subtotalContext));if(O){const I=O.rowKey;R[I]||(R[I]={}),h.forEach(A=>{if(!(A in T))return;const $=T[A],H=o.find(U=>U.isMetricColumn&&A.startsWith(U.alias));R[I][A]={value:$,metricId:(H==null?void 0:H.metricId)||"",formattedValue:vC($,t.numberFormat)}})}});const M=[];return m.forEach(T=>{const O={};h.forEach(U=>{if(U in T){const B=T[U];O[U]={value:B,metricId:"",formattedValue:vC(B,t.numberFormat)}}});const I=T.aggregate||"Total";let A="SUM";const $=I.toUpperCase();["SUM","AVG","COUNT","MIN","MAX","MEDIAN"].includes($)&&(A=$);const H=I.charAt(0).toUpperCase()+I.slice(1).toLowerCase();M.push({aggregateDisplayLabel:H,aggregateFunction:A,data:O})}),{rowHeaders:N,columnHeaders:h,cells:R,columnGroups:f,rowGroups:_,columnDisplayNames:p,groupByColumns:i,columnSubtotalMeta:s,columnMetadata:a,grandTotalRows:M,rowData:S}}function h1e(e,t,n){const r=e.filter(u=>u.isPivotColumn),o=new Map;e.filter(u=>u.isMetricColumn).forEach(u=>{o.has(u.alias)||o.set(u.alias,u)});const s=Array.from(o.values());function i(u){return u.displayLabel||u.metricLabel||u.metricName||u.alias}function a(u,f=[]){if(u>=r.length){const m=[],b=[],y={};return s.forEach(g=>{const x=[g.alias,...f].join("_"),v=i(g);m.push({name:v,level:u,colspan:1,columnKey:x}),b.push(x),y[x]=v}),{groups:m,leafKeys:b,displayNames:y}}const h=r[u],p={groups:[],leafKeys:[],displayNames:{}};return h.pivotValues.forEach(m=>{const b=[...f,m],y=a(u+1,b);t.filter(x=>x.subtotalLevel===m).forEach(x=>{y.groups.push({name:x.aggregate,level:u+1,colspan:1,columnKey:x.columnName}),y.leafKeys.push(x.columnName),y.displayNames[x.columnName]=`${x.aggregate} (${m})`}),p.groups.push({name:m,level:u,colspan:y.groups.reduce((x,v)=>x+(v.colspan||1),0),children:y.groups}),p.leafKeys.push(...y.leafKeys),Object.assign(p.displayNames,y.displayNames)}),p}const l=a(0),c=t.filter(u=>u.subtotalLevel==="grandTotal"||u.subtotalLevel==="ALL");return c.length>0&&c.forEach(u=>{var m,b,y;const f=(m=u.aggregate)==null?void 0:m.toUpperCase(),p=((y=(b=n==null?void 0:n.columnAggregates)==null?void 0:b.find(g=>g.function===f&&g.pivotLevel==="ALL"))==null?void 0:y.label)||u.aggregate||"Total";l.groups.push({name:p,level:0,colspan:1,columnKey:u.columnName}),l.leafKeys.push(u.columnName),l.displayNames[u.columnName]=p}),{columnGroups:l.groups,columnHeaders:l.leafKeys,columnDisplayNames:l.displayNames}}function p1e({data:e,card:t}){var s;if(!t.config)throw new Error("Card configuration is required for pivot table");const n=e.records.some(i=>i.isGrandTotal),r=((s=t.config)==null?void 0:s.rowAggregates)&&t.config.rowAggregates.length>0,o={showRowTotals:!1,showColumnTotals:n||r,showGrandTotal:!1};return{type:"pivotTable",data:f1e(e,o,t),config:t.config,options:o,pivotSchema:e.pivotSchema}}function Kg(e,t){return E.useMemo(()=>!e||e.type!=="pivotTable"||!t||!Array.isArray(t.records)||t.records.length===0?null:p1e({card:e,data:{records:t.records||[],columnSubtotalMeta:t.columnSubtotalMeta,subtotalColumns:t.subtotalColumns,pivotSchema:t.pivotSchema||[],groupByColumns:t.groupByColumns}}),[e,t])}function m1e({records:e,tablePreferences:t}){if(!e||e.length===0)return null;const n=(t==null?void 0:t.columnSettingsMap)||{},r=Object.keys(e[0]);let o=r;if(t!=null&&t.columnVisibility&&(o=r.filter(a=>{var l;return((l=t.columnVisibility)==null?void 0:l[a])!==!1})),t!=null&&t.columnSizing){const l=Object.keys(t.columnSizing).filter(u=>o.includes(u)),c=o.filter(u=>!l.includes(u));o=[...l,...c]}const s=o.map(a=>{const l=n[a],u=((l==null?void 0:l.textAlign)||"left")==="right";return{text:a,colspan:1,rowspan:1,className:u?"numeric":"",columnId:a,isHeader:!0,isNumeric:u}}),i=e.map(a=>({cells:o.map(l=>{const c=n[l],u=g1e(a[l],c),h=((c==null?void 0:c.textAlign)||"left")==="right";return{text:u,colspan:1,rowspan:1,className:h?"numeric":"",columnId:l,isHeader:!1,isNumeric:h}})}));return{headers:[{cells:s}],rows:i,metadata:{tableType:"data",totalRows:i.length,totalColumns:o.length}}}function g1e(e,t){if(e==null)return"";if((t==null?void 0:t.type)==="number"&&typeof e=="number"){const n=t.numberFormat;try{return new Intl.NumberFormat(n.locale||"en-US",{style:n.style,currency:n.style==="currency"?n.currency:void 0,minimumFractionDigits:n.minimumFractionDigits,maximumFractionDigits:n.maximumFractionDigits}).format(e)}catch{return e.toLocaleString()}}if((t==null?void 0:t.type)==="date")try{const n=t.dateFormat.timezone&&t.dateFormat.timezone!=="auto"?t.dateFormat.timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,r=t.dateFormat.useCustomFormat?t.dateFormat.customFormat:t.dateFormat.format;return Wg(String(e),r,n,t.dateFormat.sourceTimezone||"auto")}catch{return String(e)}return typeof e=="number"?e.toLocaleString():String(e)}function b1e({records:e,groupByColumns:t=[],pivotSchema:n=[],card:r,columnSettings:o={}}){var f,h,p;if(!e||e.length===0)return null;const s=Lj(e,t),i=zj(e),a=n.filter(m=>m.isMetricColumn),l=[...t.map(m=>({text:m.label||m.name,colspan:1,rowspan:1,className:"",columnId:m.alias||m.name,isHeader:!0,isNumeric:!1})),...a.map(m=>({text:m.metricLabel||m.metricName||m.alias,colspan:1,rowspan:1,className:"numeric",columnId:m.alias,isHeader:!0,isNumeric:!0}))],c=s.map(m=>{const b=[],y=m.isSubtotal&&!m.isGrandTotal;return t.forEach(g=>{var w,C,S;const x=g.alias||g.name;let v=m[x];if(y){const N=m.aggregate||"SUM",j=(S=(C=(w=r==null?void 0:r.config)==null?void 0:w.rowAggregates)==null?void 0:C.find(_=>_.groupLevel===m.subtotalLevel&&_.function===N))==null?void 0:S.label;v=E9(m,x,N,j)}else m.isGrandTotal&&(v="");b.push({text:v&&v!=="__TOTAL__"?String(v):"",colspan:1,rowspan:1,className:"",columnId:x,isHeader:!1,isNumeric:!1})}),a.forEach(g=>{const x=g.alias,v=o[x],w=UO(m[x],v);b.push({text:w,colspan:1,rowspan:1,className:"numeric",columnId:x,isHeader:!1,isNumeric:!0})}),{type:y?"subtotal":void 0,cells:b}});let u=null;if(i){const m=i.aggregate||"SUM",b=(p=(h=(f=r==null?void 0:r.config)==null?void 0:f.rowAggregates)==null?void 0:h.find(x=>x.groupLevel==="ALL"))==null?void 0:p.label,y=N9(m,b),g=[];t.forEach((x,v)=>{g.push({text:v===0?y:"",colspan:1,rowspan:1,className:"",isHeader:!1,isNumeric:!1})}),a.forEach(x=>{const v=x.alias,w=o[v];let C=i[v];(C==null||C==="")&&(C=e.filter(N=>!N.isSubtotal&&!N.isGrandTotal).reduce((N,j)=>{const _=Number(String(j[v]??"0").replace(/,/g,""));return N+(Number.isFinite(_)?_:0)},0));const S=UO(C,w);g.push({text:S,colspan:1,rowspan:1,className:"numeric",columnId:v,isHeader:!1,isNumeric:!0})}),u={cells:g}}return{headers:[{cells:l}],rows:c,grandTotal:u,metadata:{tableType:"aggregate",totalRows:c.length,totalColumns:l.length,groupByCount:t.length,hasGrandTotal:!!u}}}function UO(e,t){if(e==null)return"";if((t==null?void 0:t.type)==="number"&&typeof e=="number"){const n=t.numberFormat;try{return new Intl.NumberFormat(n.locale||"en-US",{style:n.style,currency:n.style==="currency"?n.currency:void 0,minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e)}catch{return e.toLocaleString()}}return typeof e=="number"?e.toLocaleString():String(e)}function y1e({pivotConfig:e,card:t,showRowTotals:n}){var c,u,f;if(!(e!=null&&e.data))return null;const r=e.data,o=x1e(r,t,!!n),{tableData:s,grandTotalRows:i}=Hj(r),a=s.map(h=>{const p=[];h.fieldValues.forEach(b=>{p.push({text:b||"",colspan:1,rowspan:1,className:"",isHeader:!1,isNumeric:!1})});let m=0;if(r.columnHeaders.forEach(b=>{var C,S,N;const y=h.cells[b],g=(N=(S=(C=t.preferences)==null?void 0:C.tablePrefs)==null?void 0:S.columnSettingsMap)==null?void 0:N[b],x=ka((y==null?void 0:y.value)??(y==null?void 0:y.formattedValue)??"",g),v=((g==null?void 0:g.textAlign)||"right")==="right";p.push({text:x==="-"?"":String(x),colspan:1,rowspan:1,className:v?"numeric":"",columnId:b,isHeader:!1,isNumeric:v});const w=typeof(y==null?void 0:y.value)=="number"?y.value:Number(String((y==null?void 0:y.formattedValue)??"").replace(/,/g,""));Number.isFinite(w)&&(m+=w)}),n){const b=ka(m,void 0);p.push({text:b==="-"?"":String(b),colspan:1,rowspan:1,className:"numeric",isHeader:!1,isNumeric:!0})}return{type:h.isSubtotal?"subtotal":void 0,cells:p}});let l=null;if(i&&i.length>0){const h=i[0],p=[],m=h.aggregateDisplayLabel||h.aggregateFunction||"Total";r.groupByColumns&&r.groupByColumns.length>0&&r.groupByColumns.forEach((y,g)=>{p.push({text:g===0?m:"",colspan:1,rowspan:1,className:"",isHeader:!1,isNumeric:!1})});let b=0;if(r.columnHeaders.forEach(y=>{var S,N,j;const g=(j=(N=(S=t.preferences)==null?void 0:S.tablePrefs)==null?void 0:N.columnSettingsMap)==null?void 0:j[y],x=h.data?h.data[y]:void 0;let v=(x==null?void 0:x.value)??(x==null?void 0:x.formattedValue)??"";(v===""||v===void 0||v===null)&&(v=s.reduce((_,R)=>{const M=R.cells[y],T=typeof(M==null?void 0:M.value)=="number"?M.value:Number(String((M==null?void 0:M.formattedValue)??(M==null?void 0:M.value)??"0").replace(/,/g,""));return _+(Number.isFinite(T)?T:0)},0));const w=ka(v,g);p.push({text:w==="-"?"":String(w),colspan:1,rowspan:1,className:"numeric",columnId:y,isHeader:!1,isNumeric:!0});const C=typeof v=="number"?v:Number(String(v).replace(/,/g,""));Number.isFinite(C)&&(b+=C)}),n){const y=ka(b,void 0);p.push({text:y==="-"?"":String(y),colspan:1,rowspan:1,className:"numeric",isHeader:!1,isNumeric:!0})}l={cells:p}}return{headers:o,rows:a,grandTotal:l,metadata:{tableType:"pivot",totalRows:a.length,rowLevels:((c=r.groupByColumns)==null?void 0:c.length)??0,pivotLevels:((f=(u=t.config)==null?void 0:u.pivotByColumns)==null?void 0:f.length)??0,hasGrandTotal:!!l}}}function x1e(e,t,n){var c,u;const o=(((c=t.config)==null?void 0:c.pivotByColumns)||[]).length,s=((u=e.groupByColumns)==null?void 0:u.length)||0;if(!e.columnGroups||e.columnGroups.length===0||o===0){const f=[];return e.groupByColumns&&e.groupByColumns.forEach(h=>{f.push({text:h.label||h.name,colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1})}),e.columnHeaders.forEach(h=>{var p;f.push({text:((p=e.columnDisplayNames)==null?void 0:p[h])||h,colspan:1,rowspan:1,className:"numeric",columnId:h,isHeader:!0,isNumeric:!0})}),n&&f.push({text:"Total",colspan:1,rowspan:1,className:"numeric",isHeader:!0,isNumeric:!0}),[{headerType:"simple",headerRowIndex:0,repeatHeader:!0,cells:f}]}const i=Array.from({length:o+1},()=>({cells:[]}));if(s>0&&e.groupByColumns){const f=i[o];e.groupByColumns.forEach(h=>{f.cells.push({text:h.label||h.name,colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1})});for(let h=0;h<o;h+=1)for(let p=0;p<s;p+=1)i[h].cells.push({text:"",colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1})}const a=Array.from({length:o},()=>[]);WB(e.columnGroups,a,o);for(let f=0;f<o;f+=1)i[f].cells.push(...a[f]);const l=[];if(e.columnGroups&&e.columnGroups.length>0?qB(e.columnGroups,l,e.columnDisplayNames||{}):e.columnHeaders.forEach(f=>{var h;l.push({text:((h=e.columnDisplayNames)==null?void 0:h[f])||f,colspan:1,rowspan:1,className:"numeric",columnId:f,isHeader:!0,isNumeric:!0})}),i[o].cells.push(...l),n){i[o].cells.push({text:"Total",colspan:1,rowspan:1,className:"numeric",isHeader:!0,isNumeric:!0});for(let f=0;f<o;f+=1)i[f].cells.push({text:"",colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1})}return i.map((f,h)=>({headerType:h<o?"pivot-level":"metrics",headerRowIndex:h,repeatHeader:!0,cells:f.cells}))}function WB(e,t,n){e.forEach(r=>{const o=r.level;if(o<n){t[o].push({text:r.name||"",colspan:r.colspan||1,rowspan:1,className:"",isHeader:!0,isNumeric:!1});for(let s=1;s<(r.colspan||1);s+=1)t[o].push({text:"",colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1});r.children&&WB(r.children,t,n)}})}function qB(e,t,n){e.forEach(r=>{r.columnKey?t.push({text:n[r.columnKey]||r.name||"Metric",colspan:1,rowspan:1,className:"numeric",columnId:r.columnKey,isHeader:!0,isNumeric:!0}):r.children&&qB(r.children,t,n)})}function GB(e,t){var r,o;if(t==="table-print")return"disabled";const n=zl(e.config);return e.sql&&!n?(o=(r=e.preferences)==null?void 0:r.tablePrefs)!=null&&o.enableDevModePagination?"server":"client":n&&_m(e)?"server":"client"}function YB({isOpen:e,onClose:t,frame:n,card:r,data:o}){var j;const{tokenProps:s}=Ue(),i=r?Bj(r.type):["pdf"],a=r?Vj(r.type):"pdf",[l,c]=E.useState(!1),[u,f]=E.useState(!1),[h,p]=E.useState({format:a,pageSize:"letter",orientation:"portrait",protectPdf:!1,pdfPassword:"",delimiter:",",includeHeaders:!0});te(_=>_.authToken),te(_=>{var R;return(R=_.dashboard)==null?void 0:R.id}),te(_=>{var R;return(R=_.dashboard)==null?void 0:R.title});const{cardFilterValues:m}=uw((r==null?void 0:r.id)||""),b={id:"",type:"table"},y=Iw(r||b),g=(j=r==null?void 0:r.preferences)==null?void 0:j.tablePrefs,x=r?(y==null?void 0:y.data)||o:null,v=Kg(r||b,x),w=(r==null?void 0:r.title)||"Visual Report",C=S9(m||[]),S=()=>{p(_=>({..._,pdfPassword:"",protectPdf:!1})),f(!1),t()},N=async()=>{var A,$,H,U,B,P;if(!r){Le.error("No card selected");return}const _=(y==null?void 0:y.data)||o;if(!_){Le.error("No data to export");return}const M=(()=>{var L,D;if(!r||!["table","aggregateTable","pivotTable"].includes(r.type))return 0;if(r.type==="pivotTable"){const W=Array.isArray(_==null?void 0:_.records)?_==null?void 0:_.records:Array.isArray(_)?_:[];return W.length>0?W.length:(L=v==null?void 0:v.data)!=null&&L.rowData&&v.data.rowData.length>0?v.data.rowData.length:((D=x==null?void 0:x.records)==null?void 0:D.length)||0}return(Array.isArray(_==null?void 0:_.records)?_==null?void 0:_.records:Array.isArray(_)?_:[]).length})();let T=null;if(r.type==="table"){const z=Array.isArray(_)?_:Array.isArray(_==null?void 0:_.records)?_.records:[];z.length>0&&(T=m1e({records:z,tablePreferences:g}))}else if(r.type==="aggregateTable"){const z=Array.isArray(_)?_:Array.isArray(_==null?void 0:_.records)?_.records:[];if(z.length>0){const L=(_==null?void 0:_.groupByColumns)||((A=r.config)==null?void 0:A.groupByColumns)||[],D=(_==null?void 0:_.pivotSchema)||[];T=b1e({records:z,groupByColumns:L,pivotSchema:D,card:r,columnSettings:g==null?void 0:g.columnSettingsMap})}}else r.type==="pivotTable"&&v&&(T=y1e({pivotConfig:v,card:r,showRowTotals:($=v.options)==null?void 0:$.showRowTotals}));const I=(r?GB(r):"client")==="server";c(!0);try{if(h.format==="csv"){let z="";const L=`${w.replace(/[^a-z0-9]/gi,"_")}.csv`;if((r==null?void 0:r.type)&&["table","aggregateTable","pivotTable"].includes(r.type))switch(r.type){case"table":{const W=Array.isArray(_)?_:(_==null?void 0:_.records)||[];if(!W||W.length===0){Le.error("No data available to export");return}vfe(W,L,g,{delimiter:h.delimiter,includeHeaders:h.includeHeaders,useFormattedValues:!0}),Le.success("CSV exported successfully"),S();return}case"aggregateTable":{const W=Array.isArray(_)?_:(_==null?void 0:_.records)||[];if(!W||W.length===0){Le.error("No data available to export");return}const G=(_==null?void 0:_.groupByColumns)||((H=r.config)==null?void 0:H.groupByColumns)||[],Z=(_==null?void 0:_.pivotSchema)||[],V=Lj(W,G),F=zj(W),q=(B=(U=r==null?void 0:r.preferences)==null?void 0:U.tablePrefs)==null?void 0:B.columnSettingsMap,Y=C9(V,F,G,Z,r,q);if(!Y){Le.error("Failed to generate CSV content");return}lx(Y,L),Le.success("CSV exported successfully"),S();return}case"pivotTable":if(v){F9(v.data,r,L,{delimiter:h.delimiter,includeHeaders:h.includeHeaders,includeSubtotals:!0,includeGrandTotal:!0,showRowTotals:(P=v.options)==null?void 0:P.showRowTotals}),Le.success("CSV exported successfully"),t();return}else{Le.error("Unable to export pivot table data");return}default:throw new Error(`Unsupported table type: ${r.type}`)}else{const W=Array.isArray(_)?_:(_==null?void 0:_.records)||[];if(!W||W.length===0){Le.error("No data available to export");return}const G=Object.keys(W[0]),Z=F=>{if(F==null)return"";const q=String(F);return q.includes(h.delimiter)||q.includes('"')||q.includes(`
699
+ `):e}function h0e(e,t){const{element:n,datasetIndex:r,index:o}=t,s=e.getDatasetMeta(r).controller,{label:i,value:a}=s.getLabelAndValue(o);return{chart:e,label:i,parsed:s.getParsed(o),raw:e.data.datasets[r].data[o],formattedValue:a,dataset:s.getDataset(),dataIndex:o,datasetIndex:r,element:n}}function BI(e,t){const n=e.chart.ctx,{body:r,footer:o,title:s}=e,{boxWidth:i,boxHeight:a}=t,l=ar(t.bodyFont),c=ar(t.titleFont),u=ar(t.footerFont),f=s.length,h=o.length,p=r.length,m=Mr(t.padding);let b=m.height,y=0,g=r.reduce((w,C)=>w+C.before.length+C.lines.length+C.after.length,0);if(g+=e.beforeBody.length+e.afterBody.length,f&&(b+=f*c.lineHeight+(f-1)*t.titleSpacing+t.titleMarginBottom),g){const w=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;b+=p*w+(g-p)*l.lineHeight+(g-1)*t.bodySpacing}h&&(b+=t.footerMarginTop+h*u.lineHeight+(h-1)*t.footerSpacing);let x=0;const v=function(w){y=Math.max(y,n.measureText(w).width+x)};return n.save(),n.font=c.string,Xt(e.title,v),n.font=l.string,Xt(e.beforeBody.concat(e.afterBody),v),x=t.displayColors?i+2+t.boxPadding:0,Xt(r,w=>{Xt(w.before,v),Xt(w.lines,v),Xt(w.after,v)}),x=0,n.font=u.string,Xt(e.footer,v),n.restore(),y+=m.width,{width:y,height:b}}function p0e(e,t){const{y:n,height:r}=t;return n<r/2?"top":n>e.height-r/2?"bottom":"center"}function m0e(e,t,n,r){const{x:o,width:s}=r,i=n.caretSize+n.caretPadding;if(e==="left"&&o+s+i>t.width||e==="right"&&o-s-i<0)return!0}function g0e(e,t,n,r){const{x:o,width:s}=n,{width:i,chartArea:{left:a,right:l}}=e;let c="center";return r==="center"?c=o<=(a+l)/2?"left":"right":o<=s/2?c="left":o>=i-s/2&&(c="right"),m0e(c,e,t,n)&&(c="center"),c}function VI(e,t,n){const r=n.yAlign||t.yAlign||p0e(e,n);return{xAlign:n.xAlign||t.xAlign||g0e(e,t,n,r),yAlign:r}}function b0e(e,t){let{x:n,width:r}=e;return t==="right"?n-=r:t==="center"&&(n-=r/2),n}function y0e(e,t,n){let{y:r,height:o}=e;return t==="top"?r+=n:t==="bottom"?r-=o+n:r-=o/2,r}function HI(e,t,n,r){const{caretSize:o,caretPadding:s,cornerRadius:i}=e,{xAlign:a,yAlign:l}=n,c=o+s,{topLeft:u,topRight:f,bottomLeft:h,bottomRight:p}=pu(i);let m=b0e(t,a);const b=y0e(t,l,c);return l==="center"?a==="left"?m+=c:a==="right"&&(m-=c):a==="left"?m-=Math.max(u,h)+o:a==="right"&&(m+=Math.max(f,p)+o),{x:wr(m,0,r.width-t.width),y:wr(b,0,r.height-t.height)}}function Sy(e,t,n){const r=Mr(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-r.right:e.x+r.left}function UI(e){return mi([],ma(e))}function x0e(e,t,n){return ac(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function WI(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const L7={beforeTitle:ua,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(r>0&&t.dataIndex<r)return n[t.dataIndex]}return""},afterTitle:ua,beforeBody:ua,beforeLabel:ua,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return pt(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:ua,afterBody:ua,beforeFooter:ua,footer:ua,afterFooter:ua};function po(e,t,n,r){const o=e[t].call(n,r);return typeof o>"u"?L7[t].call(n,r):o}var LE;let qI=(LE=class extends sa{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,r=this.options.setContext(this.getContext()),o=r.enabled&&n.options.animation&&r.animations,s=new y7(this.chart,o);return o._cacheable&&(this._cachedAnimations=Object.freeze(s)),s}getContext(){return this.$context||(this.$context=x0e(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:r}=n,o=po(r,"beforeTitle",this,t),s=po(r,"title",this,t),i=po(r,"afterTitle",this,t);let a=[];return a=mi(a,ma(o)),a=mi(a,ma(s)),a=mi(a,ma(i)),a}getBeforeBody(t,n){return UI(po(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:r}=n,o=[];return Xt(t,s=>{const i={before:[],lines:[],after:[]},a=WI(r,s);mi(i.before,ma(po(a,"beforeLabel",this,s))),mi(i.lines,po(a,"label",this,s)),mi(i.after,ma(po(a,"afterLabel",this,s))),o.push(i)}),o}getAfterBody(t,n){return UI(po(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:r}=n,o=po(r,"beforeFooter",this,t),s=po(r,"footer",this,t),i=po(r,"afterFooter",this,t);let a=[];return a=mi(a,ma(o)),a=mi(a,ma(s)),a=mi(a,ma(i)),a}_createItems(t){const n=this._active,r=this.chart.data,o=[],s=[],i=[];let a=[],l,c;for(l=0,c=n.length;l<c;++l)a.push(h0e(this.chart,n[l]));return t.filter&&(a=a.filter((u,f,h)=>t.filter(u,f,h,r))),t.itemSort&&(a=a.sort((u,f)=>t.itemSort(u,f,r))),Xt(a,u=>{const f=WI(t.callbacks,u);o.push(po(f,"labelColor",this,u)),s.push(po(f,"labelPointStyle",this,u)),i.push(po(f,"labelTextColor",this,u))}),this.labelColors=o,this.labelPointStyles=s,this.labelTextColors=i,this.dataPoints=a,a}update(t,n){const r=this.options.setContext(this.getContext()),o=this._active;let s,i=[];if(!o.length)this.opacity!==0&&(s={opacity:0});else{const a=xp[r.position].call(this,o,this._eventPosition);i=this._createItems(r),this.title=this.getTitle(i,r),this.beforeBody=this.getBeforeBody(i,r),this.body=this.getBody(i,r),this.afterBody=this.getAfterBody(i,r),this.footer=this.getFooter(i,r);const l=this._size=BI(this,r),c=Object.assign({},a,l),u=VI(this.chart,r,c),f=HI(r,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,s={opacity:1,x:f.x,y:f.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=i,this.$context=void 0,s&&this._resolveAnimations().update(this,s),t&&r.external&&r.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,r,o){const s=this.getCaretPosition(t,r,o);n.lineTo(s.x1,s.y1),n.lineTo(s.x2,s.y2),n.lineTo(s.x3,s.y3)}getCaretPosition(t,n,r){const{xAlign:o,yAlign:s}=this,{caretSize:i,cornerRadius:a}=r,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:f}=pu(a),{x:h,y:p}=t,{width:m,height:b}=n;let y,g,x,v,w,C;return s==="center"?(w=p+b/2,o==="left"?(y=h,g=y-i,v=w+i,C=w-i):(y=h+m,g=y+i,v=w-i,C=w+i),x=y):(o==="left"?g=h+Math.max(l,u)+i:o==="right"?g=h+m-Math.max(c,f)-i:g=this.caretX,s==="top"?(v=p,w=v-i,y=g-i,x=g+i):(v=p+b,w=v+i,y=g+i,x=g-i),C=v),{x1:y,x2:g,x3:x,y1:v,y2:w,y3:C}}drawTitle(t,n,r){const o=this.title,s=o.length;let i,a,l;if(s){const c=lf(r.rtl,this.x,this.width);for(t.x=Sy(this,r.titleAlign,r),n.textAlign=c.textAlign(r.titleAlign),n.textBaseline="middle",i=ar(r.titleFont),a=r.titleSpacing,n.fillStyle=r.titleColor,n.font=i.string,l=0;l<s;++l)n.fillText(o[l],c.x(t.x),t.y+i.lineHeight/2),t.y+=i.lineHeight+a,l+1===s&&(t.y+=r.titleMarginBottom-a)}}_drawColorBox(t,n,r,o,s){const i=this.labelColors[r],a=this.labelPointStyles[r],{boxHeight:l,boxWidth:c}=s,u=ar(s.bodyFont),f=Sy(this,"left",s),h=o.x(f),p=l<u.lineHeight?(u.lineHeight-l)/2:0,m=n.y+p;if(s.usePointStyle){const b={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},y=o.leftForLtr(h,c)+c/2,g=m+l/2;t.strokeStyle=s.multiKeyBackground,t.fillStyle=s.multiKeyBackground,vx(t,b,y,g),t.strokeStyle=i.borderColor,t.fillStyle=i.backgroundColor,vx(t,b,y,g)}else{t.lineWidth=_t(i.borderWidth)?Math.max(...Object.values(i.borderWidth)):i.borderWidth||1,t.strokeStyle=i.borderColor,t.setLineDash(i.borderDash||[]),t.lineDashOffset=i.borderDashOffset||0;const b=o.leftForLtr(h,c),y=o.leftForLtr(o.xPlus(h,1),c-2),g=pu(i.borderRadius);Object.values(g).some(x=>x!==0)?(t.beginPath(),t.fillStyle=s.multiKeyBackground,Pm(t,{x:b,y:m,w:c,h:l,radius:g}),t.fill(),t.stroke(),t.fillStyle=i.backgroundColor,t.beginPath(),Pm(t,{x:y,y:m+1,w:c-2,h:l-2,radius:g}),t.fill()):(t.fillStyle=s.multiKeyBackground,t.fillRect(b,m,c,l),t.strokeRect(b,m,c,l),t.fillStyle=i.backgroundColor,t.fillRect(y,m+1,c-2,l-2))}t.fillStyle=this.labelTextColors[r]}drawBody(t,n,r){const{body:o}=this,{bodySpacing:s,bodyAlign:i,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=r,f=ar(r.bodyFont);let h=f.lineHeight,p=0;const m=lf(r.rtl,this.x,this.width),b=function(j){n.fillText(j,m.x(t.x+p),t.y+h/2),t.y+=h+s},y=m.textAlign(i);let g,x,v,w,C,S,N;for(n.textAlign=i,n.textBaseline="middle",n.font=f.string,t.x=Sy(this,y,r),n.fillStyle=r.bodyColor,Xt(this.beforeBody,b),p=a&&y!=="right"?i==="center"?c/2+u:c+2+u:0,w=0,S=o.length;w<S;++w){for(g=o[w],x=this.labelTextColors[w],n.fillStyle=x,Xt(g.before,b),v=g.lines,a&&v.length&&(this._drawColorBox(n,t,w,m,r),h=Math.max(f.lineHeight,l)),C=0,N=v.length;C<N;++C)b(v[C]),h=f.lineHeight;Xt(g.after,b)}p=0,h=f.lineHeight,Xt(this.afterBody,b),t.y-=s}drawFooter(t,n,r){const o=this.footer,s=o.length;let i,a;if(s){const l=lf(r.rtl,this.x,this.width);for(t.x=Sy(this,r.footerAlign,r),t.y+=r.footerMarginTop,n.textAlign=l.textAlign(r.footerAlign),n.textBaseline="middle",i=ar(r.footerFont),n.fillStyle=r.footerColor,n.font=i.string,a=0;a<s;++a)n.fillText(o[a],l.x(t.x),t.y+i.lineHeight/2),t.y+=i.lineHeight+r.footerSpacing}}drawBackground(t,n,r,o){const{xAlign:s,yAlign:i}=this,{x:a,y:l}=t,{width:c,height:u}=r,{topLeft:f,topRight:h,bottomLeft:p,bottomRight:m}=pu(o.cornerRadius);n.fillStyle=o.backgroundColor,n.strokeStyle=o.borderColor,n.lineWidth=o.borderWidth,n.beginPath(),n.moveTo(a+f,l),i==="top"&&this.drawCaret(t,n,r,o),n.lineTo(a+c-h,l),n.quadraticCurveTo(a+c,l,a+c,l+h),i==="center"&&s==="right"&&this.drawCaret(t,n,r,o),n.lineTo(a+c,l+u-m),n.quadraticCurveTo(a+c,l+u,a+c-m,l+u),i==="bottom"&&this.drawCaret(t,n,r,o),n.lineTo(a+p,l+u),n.quadraticCurveTo(a,l+u,a,l+u-p),i==="center"&&s==="left"&&this.drawCaret(t,n,r,o),n.lineTo(a,l+f),n.quadraticCurveTo(a,l,a+f,l),n.closePath(),n.fill(),o.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,r=this.$animations,o=r&&r.x,s=r&&r.y;if(o||s){const i=xp[t.position].call(this,this._active,this._eventPosition);if(!i)return;const a=this._size=BI(this,t),l=Object.assign({},i,this._size),c=VI(n,t,l),u=HI(t,l,c,n);(o._to!==u.x||s._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let r=this.opacity;if(!r)return;this._updateAnimationTarget(n);const o={width:this.width,height:this.height},s={x:this.x,y:this.y};r=Math.abs(r)<.001?0:r;const i=Mr(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=r,this.drawBackground(s,t,o,n),h7(t,n.textDirection),s.y+=i.top,this.drawTitle(s,t,n),this.drawBody(s,t,n),this.drawFooter(s,t,n),p7(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const r=this._active,o=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),s=!gx(r,o),i=this._positionChanged(o,n);(s||i)&&(this._active=o,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,r=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const o=this.options,s=this._active||[],i=this._getActiveElements(t,s,n,r),a=this._positionChanged(i,t),l=n||!gx(i,s)||a;return l&&(this._active=i,(o.enabled||o.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,r,o){const s=this.options;if(t.type==="mouseout")return[];if(!o)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const i=this.chart.getElementsAtEventForMode(t,s.mode,s,r);return s.reverse&&i.reverse(),i}_positionChanged(t,n){const{caretX:r,caretY:o,options:s}=this,i=xp[s.position].call(this,t,n);return i!==!1&&(r!==i.x||o!==i.y)}},ke(LE,"positioners",xp),LE);var z7={id:"tooltip",_element:qI,positioners:xp,afterInit(e,t,n){n&&(e.tooltip=new qI({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:L7},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},v0e=Object.freeze({__proto__:null,Colors:Pye,Decimation:Fye,Filler:r0e,Legend:c0e,SubTitle:f0e,Title:d0e,Tooltip:z7});const w0e=(e,t,n,r)=>(typeof t=="string"?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function S0e(e,t,n,r){const o=e.indexOf(t);if(o===-1)return w0e(e,t,n,r);const s=e.lastIndexOf(t);return o!==s?n:o}const C0e=(e,t)=>e===null?null:wr(Math.round(e),0,t);function GI(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class Im extends lc{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const r=this.getLabels();for(const{index:o,label:s}of n)r[o]===s&&r.splice(o,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(pt(t))return null;const r=this.getLabels();return n=isFinite(n)&&r[n]===t?n:S0e(r,t,rt(n,t),this._addedLabels),C0e(n,r.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:r,max:o}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(r=0),n||(o=this.getLabels().length-1)),this.min=r,this.max=o}buildTicks(){const t=this.min,n=this.max,r=this.options.offset,o=[];let s=this.getLabels();s=t===0&&n===s.length-1?s:s.slice(t,n+1),this._valueRange=Math.max(s.length-(r?0:1),1),this._startValue=this.min-(r?.5:0);for(let i=t;i<=n;i++)o.push({value:i});return o}getLabelForValue(t){return GI.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}ke(Im,"id","category"),ke(Im,"defaults",{ticks:{callback:GI}});function E0e(e,t){const n=[],{bounds:o,step:s,min:i,max:a,precision:l,count:c,maxTicks:u,maxDigits:f,includeBounds:h}=e,p=s||1,m=u-1,{min:b,max:y}=t,g=!pt(i),x=!pt(a),v=!pt(c),w=(y-b)/(f+1);let C=BA((y-b)/m/p)*p,S,N,j,_;if(C<1e-14&&!g&&!x)return[{value:b},{value:y}];_=Math.ceil(y/C)-Math.floor(b/C),_>m&&(C=BA(_*C/m/p)*p),pt(l)||(S=Math.pow(10,l),C=Math.ceil(C*S)/S),o==="ticks"?(N=Math.floor(b/C)*C,j=Math.ceil(y/C)*C):(N=b,j=y),g&&x&&s&&yme((a-i)/s,C/1e3)?(_=Math.round(Math.min((a-i)/C,u)),C=(a-i)/_,N=i,j=a):v?(N=g?i:N,j=x?a:j,_=c-1,C=(j-N)/_):(_=(j-N)/C,Gp(_,Math.round(_),C/1e3)?_=Math.round(_):_=Math.ceil(_));const R=Math.max(VA(C),VA(N));S=Math.pow(10,pt(l)?R:l),N=Math.round(N*S)/S,j=Math.round(j*S)/S;let M=0;for(g&&(h&&N!==i?(n.push({value:i}),N<i&&M++,Gp(Math.round((N+M*C)*S)/S,i,YI(i,w,e))&&M++):N<i&&M++);M<_;++M){const T=Math.round((N+M*C)*S)/S;if(x&&T>a)break;n.push({value:T})}return x&&h&&j!==a?n.length&&Gp(n[n.length-1].value,a,YI(a,w,e))?n[n.length-1].value=a:n.push({value:a}):(!x||j===a)&&n.push({value:j}),n}function YI(e,t,{horizontal:n,minRotation:r}){const o=qs(r),s=(n?Math.sin(o):Math.cos(o))||.001,i=.75*t*(""+e).length;return Math.min(t/s,i)}class Ex extends lc{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return pt(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:r}=this.getUserBounds();let{min:o,max:s}=this;const i=l=>o=n?o:l,a=l=>s=r?s:l;if(t){const l=Di(o),c=Di(s);l<0&&c<0?a(0):l>0&&c>0&&i(0)}if(o===s){let l=s===0?1:Math.abs(s*.05);a(s+l),t||i(o-l)}this.min=o,this.max=s}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:r}=t,o;return r?(o=Math.ceil(this.max/r)-Math.floor(this.min/r)+1,o>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${r} would result generating up to ${o} ticks. Limiting to 1000.`),o=1e3)):(o=this.computeTickLimit(),n=n||11),n&&(o=Math.min(n,o)),o}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let r=this.getTickLimit();r=Math.max(2,r);const o={maxTicks:r,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},s=this._range||this,i=E0e(o,s);return t.bounds==="ticks"&&K9(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}configure(){const t=this.ticks;let n=this.min,r=this.max;if(super.configure(),this.options.offset&&t.length){const o=(r-n)/Math.max(t.length-1,1)/2;n-=o,r+=o}this._startValue=n,this._endValue=r,this._valueRange=r-n}getLabelForValue(t){return Yg(t,this.chart.options.locale,this.options.ticks.format)}}class Iu extends Ex{determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Wn(t)?t:0,this.max=Wn(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,r=qs(this.options.ticks.minRotation),o=(t?Math.sin(r):Math.cos(r))||.001,s=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,s.lineHeight/o))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}ke(Iu,"id","linear"),ke(Iu,"defaults",{ticks:{callback:Nw.formatters.numeric}});const Om=e=>Math.floor(_l(e)),Cc=(e,t)=>Math.pow(10,Om(e)+t);function ZI(e){return e/Math.pow(10,Om(e))===1}function KI(e,t,n){const r=Math.pow(10,n),o=Math.floor(e/r);return Math.ceil(t/r)-o}function N0e(e,t){const n=t-e;let r=Om(n);for(;KI(e,t,r)>10;)r++;for(;KI(e,t,r)<10;)r--;return Math.min(r,Om(e))}function k0e(e,{min:t,max:n}){t=Po(e.min,t);const r=[],o=Om(t);let s=N0e(t,n),i=s<0?Math.pow(10,Math.abs(s)):1;const a=Math.pow(10,s),l=o>s?Math.pow(10,o):0,c=Math.round((t-l)*i)/i,u=Math.floor((t-l)/a/10)*a*10;let f=Math.floor((c-u)/Math.pow(10,s)),h=Po(e.min,Math.round((l+u+f*Math.pow(10,s))*i)/i);for(;h<n;)r.push({value:h,major:ZI(h),significand:f}),f>=10?f=f<15?15:20:f++,f>=20&&(s++,f=2,i=s>=0?1:i),h=Math.round((l+u+f*Math.pow(10,s))*i)/i;const p=Po(e.max,h);return r.push({value:p,major:ZI(p),significand:f}),r}class qf extends lc{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,n){const r=Ex.prototype.parse.apply(this,[t,n]);if(r===0){this._zero=!0;return}return Wn(r)&&r>0?r:null}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Wn(t)?Math.max(0,t):null,this.max=Wn(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Wn(this._userMin)&&(this.min=t===Cc(this.min,0)?Cc(this.min,-1):Cc(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let r=this.min,o=this.max;const s=a=>r=t?r:a,i=a=>o=n?o:a;r===o&&(r<=0?(s(1),i(10)):(s(Cc(r,-1)),i(Cc(o,1)))),r<=0&&s(Cc(o,-1)),o<=0&&i(Cc(r,1)),this.min=r,this.max=o}buildTicks(){const t=this.options,n={min:this._userMin,max:this._userMax},r=k0e(n,this);return t.bounds==="ticks"&&K9(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}getLabelForValue(t){return t===void 0?"0":Yg(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=_l(t),this._valueRange=_l(this.max)-_l(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(_l(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const n=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+n*this._valueRange)}}ke(qf,"id","logarithmic"),ke(qf,"defaults",{ticks:{callback:Nw.formatters.logarithmic,major:{enabled:!0}}});function pN(e){const t=e.ticks;if(t.display&&e.display){const n=Mr(t.backdropPadding);return rt(t.font&&t.font.size,kn.font.size)+n.height}return 0}function _0e(e,t,n){return n=Cn(n)?n:[n],{w:Ime(e,t.string,n),h:n.length*t.lineHeight}}function XI(e,t,n,r,o){return e===r||e===o?{start:t-n/2,end:t+n/2}:e<r||e>o?{start:t-n,end:t}:{start:t,end:t+n}}function j0e(e){const t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],o=[],s=e._pointLabels.length,i=e.options.pointLabels,a=i.centerPointLabels?_n/s:0;for(let l=0;l<s;l++){const c=i.setContext(e.getPointLabelContext(l));o[l]=c.padding;const u=e.getPointPosition(l,e.drawingArea+o[l],a),f=ar(c.font),h=_0e(e.ctx,f,e._pointLabels[l]);r[l]=h;const p=Oo(e.getIndexAngle(l)+a),m=Math.round(Qj(p)),b=XI(m,u.x,h.w,0,180),y=XI(m,u.y,h.h,90,270);R0e(n,t,p,b,y)}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=T0e(e,r,o)}function R0e(e,t,n,r,o){const s=Math.abs(Math.sin(n)),i=Math.abs(Math.cos(n));let a=0,l=0;r.start<t.l?(a=(t.l-r.start)/s,e.l=Math.min(e.l,t.l-a)):r.end>t.r&&(a=(r.end-t.r)/s,e.r=Math.max(e.r,t.r+a)),o.start<t.t?(l=(t.t-o.start)/i,e.t=Math.min(e.t,t.t-l)):o.end>t.b&&(l=(o.end-t.b)/i,e.b=Math.max(e.b,t.b+l))}function M0e(e,t,n){const r=e.drawingArea,{extra:o,additionalAngle:s,padding:i,size:a}=n,l=e.getPointPosition(t,r+o+i,s),c=Math.round(Qj(Oo(l.angle+Qn))),u=I0e(l.y,a.h,c),f=P0e(c),h=A0e(l.x,a.w,f);return{visible:!0,x:l.x,y:u,textAlign:f,left:h,top:u,right:h+a.w,bottom:u+a.h}}function D0e(e,t){if(!t)return!0;const{left:n,top:r,right:o,bottom:s}=e;return!(Ra({x:n,y:r},t)||Ra({x:n,y:s},t)||Ra({x:o,y:r},t)||Ra({x:o,y:s},t))}function T0e(e,t,n){const r=[],o=e._pointLabels.length,s=e.options,{centerPointLabels:i,display:a}=s.pointLabels,l={extra:pN(s)/2,additionalAngle:i?_n/o:0};let c;for(let u=0;u<o;u++){l.padding=n[u],l.size=t[u];const f=M0e(e,u,l);r.push(f),a==="auto"&&(f.visible=D0e(f,c),f.visible&&(c=f))}return r}function P0e(e){return e===0||e===180?"center":e<180?"left":"right"}function A0e(e,t,n){return n==="right"?e-=t:n==="center"&&(e-=t/2),e}function I0e(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function O0e(e,t,n){const{left:r,top:o,right:s,bottom:i}=n,{backdropColor:a}=t;if(!pt(a)){const l=pu(t.borderRadius),c=Mr(t.backdropPadding);e.fillStyle=a;const u=r-c.left,f=o-c.top,h=s-r+c.width,p=i-o+c.height;Object.values(l).some(m=>m!==0)?(e.beginPath(),Pm(e,{x:u,y:f,w:h,h:p,radius:l}),e.fill()):e.fillRect(u,f,h,p)}}function F0e(e,t){const{ctx:n,options:{pointLabels:r}}=e;for(let o=t-1;o>=0;o--){const s=e._pointLabelItems[o];if(!s.visible)continue;const i=r.setContext(e.getPointLabelContext(o));O0e(n,i,s);const a=ar(i.font),{x:l,y:c,textAlign:u}=s;Au(n,e._pointLabels[o],l,c+a.lineHeight/2,a,{color:i.color,textAlign:u,textBaseline:"middle"})}}function B7(e,t,n,r){const{ctx:o}=e;if(n)o.arc(e.xCenter,e.yCenter,t,0,Nn);else{let s=e.getPointPosition(0,t);o.moveTo(s.x,s.y);for(let i=1;i<r;i++)s=e.getPointPosition(i,t),o.lineTo(s.x,s.y)}}function $0e(e,t,n,r,o){const s=e.ctx,i=t.circular,{color:a,lineWidth:l}=t;!i&&!r||!a||!l||n<0||(s.save(),s.strokeStyle=a,s.lineWidth=l,s.setLineDash(o.dash||[]),s.lineDashOffset=o.dashOffset,s.beginPath(),B7(e,n,i,r),s.closePath(),s.stroke(),s.restore())}function L0e(e,t,n){return ac(e,{label:n,index:t,type:"pointLabel"})}class vp extends Ex{constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=Mr(pN(this.options)/2),n=this.width=this.maxWidth-t.width,r=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+n/2+t.left),this.yCenter=Math.floor(this.top+r/2+t.top),this.drawingArea=Math.floor(Math.min(n,r)/2)}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!1);this.min=Wn(t)&&!isNaN(t)?t:0,this.max=Wn(n)&&!isNaN(n)?n:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/pN(this.options))}generateTickLabels(t){Ex.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((n,r)=>{const o=sn(this.options.pointLabels.callback,[n,r],this);return o||o===0?o:""}).filter((n,r)=>this.chart.getDataVisibility(r))}fit(){const t=this.options;t.display&&t.pointLabels.display?j0e(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,n,r,o){this.xCenter+=Math.floor((t-n)/2),this.yCenter+=Math.floor((r-o)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,n,r,o))}getIndexAngle(t){const n=Nn/(this._pointLabels.length||1),r=this.options.startAngle||0;return Oo(t*n+qs(r))}getDistanceFromCenterForValue(t){if(pt(t))return NaN;const n=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*n:(t-this.min)*n}getValueForDistanceFromCenter(t){if(pt(t))return NaN;const n=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-n:this.min+n}getPointLabelContext(t){const n=this._pointLabels||[];if(t>=0&&t<n.length){const r=n[t];return L0e(this.getContext(),t,r)}}getPointPosition(t,n,r=0){const o=this.getIndexAngle(t)-Qn+r;return{x:Math.cos(o)*n+this.xCenter,y:Math.sin(o)*n+this.yCenter,angle:o}}getPointPositionForValue(t,n){return this.getPointPosition(t,this.getDistanceFromCenterForValue(n))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:n,top:r,right:o,bottom:s}=this._pointLabelItems[t];return{left:n,top:r,right:o,bottom:s}}drawBackground(){const{backgroundColor:t,grid:{circular:n}}=this.options;if(t){const r=this.ctx;r.save(),r.beginPath(),B7(this,this.getDistanceFromCenterForValue(this._endValue),n,this._pointLabels.length),r.closePath(),r.fillStyle=t,r.fill(),r.restore()}}drawGrid(){const t=this.ctx,n=this.options,{angleLines:r,grid:o,border:s}=n,i=this._pointLabels.length;let a,l,c;if(n.pointLabels.display&&F0e(this,i),o.display&&this.ticks.forEach((u,f)=>{if(f!==0||f===0&&this.min<0){l=this.getDistanceFromCenterForValue(u.value);const h=this.getContext(f),p=o.setContext(h),m=s.setContext(h);$0e(this,p,l,i,m)}}),r.display){for(t.save(),a=i-1;a>=0;a--){const u=r.setContext(this.getPointLabelContext(a)),{color:f,lineWidth:h}=u;!h||!f||(t.lineWidth=h,t.strokeStyle=f,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,l=this.getDistanceFromCenterForValue(n.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,n=this.options,r=n.ticks;if(!r.display)return;const o=this.getIndexAngle(0);let s,i;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(o),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!n.reverse)return;const c=r.setContext(this.getContext(l)),u=ar(c.font);if(s=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=u.string,i=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const f=Mr(c.backdropPadding);t.fillRect(-i/2-f.left,-s-u.size/2-f.top,i+f.width,u.size+f.height)}Au(t,a.label,0,-s,u,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}ke(vp,"id","radialLinear"),ke(vp,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Nw.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),ke(vp,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),ke(vp,"descriptors",{angleLines:{_fallback:"grid"}});const jw={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Co=Object.keys(jw);function QI(e,t){return e-t}function JI(e,t){if(pt(t))return null;const n=e._adapter,{parser:r,round:o,isoWeekday:s}=e._parseOpts;let i=t;return typeof r=="function"&&(i=r(i)),Wn(i)||(i=typeof r=="string"?n.parse(i,r):n.parse(i)),i===null?null:(o&&(i=o==="week"&&(Hf(s)||s===!0)?n.startOf(i,"isoWeek",s):n.startOf(i,o)),+i)}function eO(e,t,n,r){const o=Co.length;for(let s=Co.indexOf(e);s<o-1;++s){const i=jw[Co[s]],a=i.steps?i.steps:Number.MAX_SAFE_INTEGER;if(i.common&&Math.ceil((n-t)/(a*i.size))<=r)return Co[s]}return Co[o-1]}function z0e(e,t,n,r,o){for(let s=Co.length-1;s>=Co.indexOf(n);s--){const i=Co[s];if(jw[i].common&&e._adapter.diff(o,r,i)>=t-1)return i}return Co[n?Co.indexOf(n):0]}function B0e(e){for(let t=Co.indexOf(e)+1,n=Co.length;t<n;++t)if(jw[Co[t]].common)return Co[t]}function tO(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:r,hi:o}=Jj(n,t),s=n[r]>=t?n[r]:n[o];e[s]=!0}}function V0e(e,t,n,r){const o=e._adapter,s=+o.startOf(t[0].value,r),i=t[t.length-1].value;let a,l;for(a=s;a<=i;a=+o.add(a,1,r))l=n[a],l>=0&&(t[l].major=!0);return t}function nO(e,t,n){const r=[],o={},s=t.length;let i,a;for(i=0;i<s;++i)a=t[i],o[a]=i,r.push({value:a,major:!1});return s===0||!n?r:V0e(e,r,o,n)}class Fm extends lc{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const r=t.time||(t.time={}),o=this._adapter=new Xge._date(t.adapters.date);o.init(n),qp(r.displayFormats,o.formats()),this._parseOpts={parser:r.parser,round:r.round,isoWeekday:r.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:JI(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,r=t.time.unit||"day";let{min:o,max:s,minDefined:i,maxDefined:a}=this.getUserBounds();function l(c){!i&&!isNaN(c.min)&&(o=Math.min(o,c.min)),!a&&!isNaN(c.max)&&(s=Math.max(s,c.max))}(!i||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),o=Wn(o)&&!isNaN(o)?o:+n.startOf(Date.now(),r),s=Wn(s)&&!isNaN(s)?s:+n.endOf(Date.now(),r)+1,this.min=Math.min(o,s-1),this.max=Math.max(o+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],r=t[t.length-1]),{min:n,max:r}}buildTicks(){const t=this.options,n=t.time,r=t.ticks,o=r.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&o.length&&(this.min=this._userMin||o[0],this.max=this._userMax||o[o.length-1]);const s=this.min,i=this.max,a=Sme(o,s,i);return this._unit=n.unit||(r.autoSkip?eO(n.minUnit,this.min,this.max,this._getLabelCapacity(s)):z0e(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!r.major.enabled||this._unit==="year"?void 0:B0e(this._unit),this.initOffsets(o),t.reverse&&a.reverse(),nO(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,r=0,o,s;this.options.offset&&t.length&&(o=this.getDecimalForValue(t[0]),t.length===1?n=1-o:n=(this.getDecimalForValue(t[1])-o)/2,s=this.getDecimalForValue(t[t.length-1]),t.length===1?r=s:r=(s-this.getDecimalForValue(t[t.length-2]))/2);const i=t.length<3?.5:.25;n=wr(n,0,i),r=wr(r,0,i),this._offsets={start:n,end:r,factor:1/(n+1+r)}}_generate(){const t=this._adapter,n=this.min,r=this.max,o=this.options,s=o.time,i=s.unit||eO(s.minUnit,n,r,this._getLabelCapacity(n)),a=rt(o.ticks.stepSize,1),l=i==="week"?s.isoWeekday:!1,c=Hf(l)||l===!0,u={};let f=n,h,p;if(c&&(f=+t.startOf(f,"isoWeek",l)),f=+t.startOf(f,c?"day":i),t.diff(r,n,i)>1e5*a)throw new Error(n+" and "+r+" are too far apart with stepSize of "+a+" "+i);const m=o.ticks.source==="data"&&this.getDataTimestamps();for(h=f,p=0;h<r;h=+t.add(h,a,i),p++)tO(u,h,m);return(h===r||o.bounds==="ticks"||p===1)&&tO(u,h,m),Object.keys(u).sort(QI).map(b=>+b)}getLabelForValue(t){const n=this._adapter,r=this.options.time;return r.tooltipFormat?n.format(t,r.tooltipFormat):n.format(t,r.displayFormats.datetime)}format(t,n){const o=this.options.time.displayFormats,s=this._unit,i=n||o[s];return this._adapter.format(t,i)}_tickFormatFunction(t,n,r,o){const s=this.options,i=s.ticks.callback;if(i)return sn(i,[t,n,r],this);const a=s.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],f=c&&a[c],h=r[n],p=c&&f&&h&&h.major;return this._adapter.format(t,o||(p?f:u))}generateTickLabels(t){let n,r,o;for(n=0,r=t.length;n<r;++n)o=t[n],o.label=this._tickFormatFunction(o.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,r=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+r)*n.factor)}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+r*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,r=this.ctx.measureText(t).width,o=qs(this.isHorizontal()?n.maxRotation:n.minRotation),s=Math.cos(o),i=Math.sin(o),a=this._resolveTickFontOptions(0).size;return{w:r*s+a*i,h:r*i+a*s}}_getLabelCapacity(t){const n=this.options.time,r=n.displayFormats,o=r[n.unit]||r.millisecond,s=this._tickFormatFunction(t,0,nO(this,[t],this._majorUnit),o),i=this._getLabelSize(s),a=Math.floor(this.isHorizontal()?this.width/i.w:this.height/i.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,r;if(t.length)return t;const o=this.getMatchingVisibleMetas();if(this._normalized&&o.length)return this._cache.data=o[0].controller.getAllParsedValues(this);for(n=0,r=o.length;n<r;++n)t=t.concat(o[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,r;if(t.length)return t;const o=this.getLabels();for(n=0,r=o.length;n<r;++n)t.push(JI(this,o[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return J9(t.sort(QI))}}ke(Fm,"id","time"),ke(Fm,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});function Cy(e,t,n){let r=0,o=e.length-1,s,i,a,l;n?(t>=e[r].pos&&t<=e[o].pos&&({lo:r,hi:o}=ja(e,"pos",t)),{pos:s,time:a}=e[r],{pos:i,time:l}=e[o]):(t>=e[r].time&&t<=e[o].time&&({lo:r,hi:o}=ja(e,"time",t)),{time:s,pos:a}=e[r],{time:i,pos:l}=e[o]);const c=i-s;return c?a+(l-a)*(t-s)/c:a}class mN extends Fm{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=Cy(n,this.min),this._tableRange=Cy(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:r}=this,o=[],s=[];let i,a,l,c,u;for(i=0,a=t.length;i<a;++i)c=t[i],c>=n&&c<=r&&o.push(c);if(o.length<2)return[{time:n,pos:0},{time:r,pos:1}];for(i=0,a=o.length;i<a;++i)u=o[i+1],l=o[i-1],c=o[i],Math.round((u+l)/2)!==c&&s.push({time:c,pos:i/(a-1)});return s}_generate(){const t=this.min,n=this.max;let r=super.getDataTimestamps();return(!r.includes(t)||!r.length)&&r.splice(0,0,t),(!r.includes(n)||r.length===1)&&r.push(n),r.sort((o,s)=>o-s)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),r=this.getLabelTimestamps();return n.length&&r.length?t=this.normalize(n.concat(r)):t=n.length?n:r,t=this._cache.all=t,t}getDecimalForValue(t){return(Cy(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return Cy(this._table,r*this._tableRange+this._minPos,!0)}}ke(mN,"id","timeseries"),ke(mN,"defaults",Fm.defaults);var H0e=Object.freeze({__proto__:null,CategoryScale:Im,LinearScale:Iu,LogarithmicScale:qf,RadialLinearScale:vp,TimeScale:Fm,TimeSeriesScale:mN});const U0e=[Kge,kye,v0e,H0e];class Wl{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const n=this._partials;let r=0;for(let o=0;o<this._n&&o<32;o++){const s=n[o],i=t+s,a=Math.abs(t)<Math.abs(s)?t-(i-s):s-(i-t);a&&(n[r++]=a),t=i}return n[r]=t,this._n=r+1,this}valueOf(){const t=this._partials;let n=this._n,r,o,s,i=0;if(n>0){for(i=t[--n];n>0&&(r=i,o=t[--n],i=r+o,s=o-(i-r),!s););n>0&&(s<0&&t[n-1]<0||s>0&&t[n-1]>0)&&(o=s*2,r=i+o,o==r-i&&(i=r))}return i}}function*W0e(e){for(const t of e)yield*t}function V7(e){return Array.from(W0e(e))}function Wd(e,t,n){e=+e,t=+t,n=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=Math.max(0,Math.ceil((t-e)/n))|0,s=new Array(o);++r<o;)s[r]=e+r*n;return s}var Je=1e-6,H7=1e-12,St=Math.PI,Un=St/2,rO=St/4,Zo=St*2,to=180/St,an=St/180,Ht=Math.abs,Ch=Math.atan,Hi=Math.atan2,ht=Math.cos,Ey=Math.ceil,U7=Math.exp,Nx=Math.log,pC=Math.pow,st=Math.sin,gs=Math.sign||function(e){return e>0?1:e<0?-1:0},ao=Math.sqrt,dR=Math.tan;function W7(e){return e>1?0:e<-1?St:Math.acos(e)}function _s(e){return e>1?Un:e<-1?-Un:Math.asin(e)}function xr(){}function kx(e,t){e&&sO.hasOwnProperty(e.type)&&sO[e.type](e,t)}var oO={Feature:function(e,t){kx(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,o=n.length;++r<o;)kx(n[r].geometry,t)}},sO={Sphere:function(e,t){t.sphere()},Point:function(e,t){e=e.coordinates,t.point(e[0],e[1],e[2])},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)e=n[r],t.point(e[0],e[1],e[2])},LineString:function(e,t){gN(e.coordinates,t,0)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)gN(n[r],t,0)},Polygon:function(e,t){iO(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)iO(n[r],t)},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,o=n.length;++r<o;)kx(n[r],t)}};function gN(e,t,n){var r=-1,o=e.length-n,s;for(t.lineStart();++r<o;)s=e[r],t.point(s[0],s[1],s[2]);t.lineEnd()}function iO(e,t){var n=-1,r=e.length;for(t.polygonStart();++n<r;)gN(e[n],t,1);t.polygonEnd()}function Fc(e,t){e&&oO.hasOwnProperty(e.type)?oO[e.type](e,t):kx(e,t)}function bN(e){return[Hi(e[1],e[0]),_s(e[2])]}function Gf(e){var t=e[0],n=e[1],r=ht(n);return[r*ht(t),r*st(t),st(n)]}function Ny(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function _x(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function mC(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function ky(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function yN(e){var t=ao(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}function xN(e,t){function n(r,o){return r=e(r,o),t(r[0],r[1])}return e.invert&&t.invert&&(n.invert=function(r,o){return r=t.invert(r,o),r&&e.invert(r[0],r[1])}),n}function vN(e,t){return Ht(e)>St&&(e-=Math.round(e/Zo)*Zo),[e,t]}vN.invert=vN;function q7(e,t,n){return(e%=Zo)?t||n?xN(lO(e),cO(t,n)):lO(e):t||n?cO(t,n):vN}function aO(e){return function(t,n){return t+=e,Ht(t)>St&&(t-=Math.round(t/Zo)*Zo),[t,n]}}function lO(e){var t=aO(e);return t.invert=aO(-e),t}function cO(e,t){var n=ht(e),r=st(e),o=ht(t),s=st(t);function i(a,l){var c=ht(l),u=ht(a)*c,f=st(a)*c,h=st(l),p=h*n+u*r;return[Hi(f*o-p*s,u*n-h*r),_s(p*o+f*s)]}return i.invert=function(a,l){var c=ht(l),u=ht(a)*c,f=st(a)*c,h=st(l),p=h*o-f*s;return[Hi(f*o+h*s,u*n+p*r),_s(p*n-u*r)]},i}function q0e(e){e=q7(e[0]*an,e[1]*an,e.length>2?e[2]*an:0);function t(n){return n=e(n[0]*an,n[1]*an),n[0]*=to,n[1]*=to,n}return t.invert=function(n){return n=e.invert(n[0]*an,n[1]*an),n[0]*=to,n[1]*=to,n},t}function G0e(e,t,n,r,o,s){if(n){var i=ht(t),a=st(t),l=r*n;o==null?(o=t+r*Zo,s=t-l/2):(o=uO(i,o),s=uO(i,s),(r>0?o<s:o>s)&&(o+=r*Zo));for(var c,u=o;r>0?u>s:u<s;u-=l)c=bN([i,-a*ht(u),-a*st(u)]),e.point(c[0],c[1])}}function uO(e,t){t=Gf(t),t[0]-=e,yN(t);var n=W7(-t[1]);return((-t[2]<0?-n:n)+Zo-Je)%Zo}function G7(){var e=[],t;return{point:function(n,r,o){t.push([n,r,o])},lineStart:function(){e.push(t=[])},lineEnd:xr,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function M0(e,t){return Ht(e[0]-t[0])<Je&&Ht(e[1]-t[1])<Je}function _y(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function Y7(e,t,n,r,o){var s=[],i=[],a,l;if(e.forEach(function(m){if(!((b=m.length-1)<=0)){var b,y=m[0],g=m[b],x;if(M0(y,g)){if(!y[2]&&!g[2]){for(o.lineStart(),a=0;a<b;++a)o.point((y=m[a])[0],y[1]);o.lineEnd();return}g[0]+=2*Je}s.push(x=new _y(y,m,null,!0)),i.push(x.o=new _y(y,null,x,!1)),s.push(x=new _y(g,m,null,!1)),i.push(x.o=new _y(g,null,x,!0))}}),!!s.length){for(i.sort(t),dO(s),dO(i),a=0,l=i.length;a<l;++a)i[a].e=n=!n;for(var c=s[0],u,f;;){for(var h=c,p=!0;h.v;)if((h=h.n)===c)return;u=h.z,o.lineStart();do{if(h.v=h.o.v=!0,h.e){if(p)for(a=0,l=u.length;a<l;++a)o.point((f=u[a])[0],f[1]);else r(h.x,h.n.x,1,o);h=h.n}else{if(p)for(u=h.p.z,a=u.length-1;a>=0;--a)o.point((f=u[a])[0],f[1]);else r(h.x,h.p.x,-1,o);h=h.p}h=h.o,u=h.z,p=!p}while(!h.v);o.lineEnd()}}}function dO(e){if(t=e.length){for(var t,n=0,r=e[0],o;++n<t;)r.n=o=e[n],o.p=r,r=o;r.n=o=e[0],o.p=r}}function gC(e){return Ht(e[0])<=St?e[0]:gs(e[0])*((Ht(e[0])+St)%Zo-St)}function Z7(e,t){var n=gC(t),r=t[1],o=st(r),s=[st(n),-ht(n),0],i=0,a=0,l=new Wl;o===1?r=Un+Je:o===-1&&(r=-Un-Je);for(var c=0,u=e.length;c<u;++c)if(h=(f=e[c]).length)for(var f,h,p=f[h-1],m=gC(p),b=p[1]/2+rO,y=st(b),g=ht(b),x=0;x<h;++x,m=w,y=S,g=N,p=v){var v=f[x],w=gC(v),C=v[1]/2+rO,S=st(C),N=ht(C),j=w-m,_=j>=0?1:-1,R=_*j,M=R>St,T=y*S;if(l.add(Hi(T*_*st(R),g*N+T*ht(R))),i+=M?j+_*Zo:j,M^m>=n^w>=n){var O=_x(Gf(p),Gf(v));yN(O);var I=_x(s,O);yN(I);var A=(M^j>=0?-1:1)*_s(I[2]);(r>A||r===A&&(O[0]||O[1]))&&(a+=M^j>=0?1:-1)}}return(i<-1e-6||i<Je&&l<-1e-12)^a&1}function K7(e,t,n,r){return function(o){var s=t(o),i=G7(),a=t(i),l=!1,c,u,f,h={point:p,lineStart:b,lineEnd:y,polygonStart:function(){h.point=g,h.lineStart=x,h.lineEnd=v,u=[],c=[]},polygonEnd:function(){h.point=p,h.lineStart=b,h.lineEnd=y,u=V7(u);var w=Z7(c,r);u.length?(l||(o.polygonStart(),l=!0),Y7(u,Z0e,w,n,o)):w&&(l||(o.polygonStart(),l=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),l&&(o.polygonEnd(),l=!1),u=c=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}};function p(w,C){e(w,C)&&o.point(w,C)}function m(w,C){s.point(w,C)}function b(){h.point=m,s.lineStart()}function y(){h.point=p,s.lineEnd()}function g(w,C){f.push([w,C]),a.point(w,C)}function x(){a.lineStart(),f=[]}function v(){g(f[0][0],f[0][1]),a.lineEnd();var w=a.clean(),C=i.result(),S,N=C.length,j,_,R;if(f.pop(),c.push(f),f=null,!!N){if(w&1){if(_=C[0],(j=_.length-1)>0){for(l||(o.polygonStart(),l=!0),o.lineStart(),S=0;S<j;++S)o.point((R=_[S])[0],R[1]);o.lineEnd()}return}N>1&&w&2&&C.push(C.pop().concat(C.shift())),u.push(C.filter(Y0e))}}return h}}function Y0e(e){return e.length>1}function Z0e(e,t){return((e=e.x)[0]<0?e[1]-Un-Je:Un-e[1])-((t=t.x)[0]<0?t[1]-Un-Je:Un-t[1])}const fO=K7(function(){return!0},K0e,Q0e,[-St,-Un]);function K0e(e){var t=NaN,n=NaN,r=NaN,o;return{lineStart:function(){e.lineStart(),o=1},point:function(s,i){var a=s>0?St:-St,l=Ht(s-t);Ht(l-St)<Je?(e.point(t,n=(n+i)/2>0?Un:-Un),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(a,n),e.point(s,n),o=0):r!==a&&l>=St&&(Ht(t-r)<Je&&(t-=r*Je),Ht(s-a)<Je&&(s-=a*Je),n=X0e(t,n,s,i),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(a,n),o=0),e.point(t=s,n=i),r=a},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-o}}}function X0e(e,t,n,r){var o,s,i=st(e-n);return Ht(i)>Je?Ch((st(t)*(s=ht(r))*st(n)-st(r)*(o=ht(t))*st(e))/(o*s*i)):(t+r)/2}function Q0e(e,t,n,r){var o;if(e==null)o=n*Un,r.point(-St,o),r.point(0,o),r.point(St,o),r.point(St,0),r.point(St,-o),r.point(0,-o),r.point(-St,-o),r.point(-St,0),r.point(-St,o);else if(Ht(e[0]-t[0])>Je){var s=e[0]<t[0]?St:-St;o=n*s/2,r.point(-s,o),r.point(0,o),r.point(s,o)}else r.point(t[0],t[1])}function J0e(e){var t=ht(e),n=2*an,r=t>0,o=Ht(t)>Je;function s(u,f,h,p){G0e(p,e,n,h,u,f)}function i(u,f){return ht(u)*ht(f)>t}function a(u){var f,h,p,m,b;return{lineStart:function(){m=p=!1,b=1},point:function(y,g){var x=[y,g],v,w=i(y,g),C=r?w?0:c(y,g):w?c(y+(y<0?St:-St),g):0;if(!f&&(m=p=w)&&u.lineStart(),w!==p&&(v=l(f,x),(!v||M0(f,v)||M0(x,v))&&(x[2]=1)),w!==p)b=0,w?(u.lineStart(),v=l(x,f),u.point(v[0],v[1])):(v=l(f,x),u.point(v[0],v[1],2),u.lineEnd()),f=v;else if(o&&f&&r^w){var S;!(C&h)&&(S=l(x,f,!0))&&(b=0,r?(u.lineStart(),u.point(S[0][0],S[0][1]),u.point(S[1][0],S[1][1]),u.lineEnd()):(u.point(S[1][0],S[1][1]),u.lineEnd(),u.lineStart(),u.point(S[0][0],S[0][1],3)))}w&&(!f||!M0(f,x))&&u.point(x[0],x[1]),f=x,p=w,h=C},lineEnd:function(){p&&u.lineEnd(),f=null},clean:function(){return b|(m&&p)<<1}}}function l(u,f,h){var p=Gf(u),m=Gf(f),b=[1,0,0],y=_x(p,m),g=Ny(y,y),x=y[0],v=g-x*x;if(!v)return!h&&u;var w=t*g/v,C=-t*x/v,S=_x(b,y),N=ky(b,w),j=ky(y,C);mC(N,j);var _=S,R=Ny(N,_),M=Ny(_,_),T=R*R-M*(Ny(N,N)-1);if(!(T<0)){var O=ao(T),I=ky(_,(-R-O)/M);if(mC(I,N),I=bN(I),!h)return I;var A=u[0],$=f[0],H=u[1],U=f[1],B;$<A&&(B=A,A=$,$=B);var P=$-A,z=Ht(P-St)<Je,L=z||P<Je;if(!z&&U<H&&(B=H,H=U,U=B),L?z?H+U>0^I[1]<(Ht(I[0]-A)<Je?H:U):H<=I[1]&&I[1]<=U:P>St^(A<=I[0]&&I[0]<=$)){var D=ky(_,(-R+O)/M);return mC(D,N),[I,bN(D)]}}}function c(u,f){var h=r?e:St-e,p=0;return u<-h?p|=1:u>h&&(p|=2),f<-h?p|=4:f>h&&(p|=8),p}return K7(i,a,s,r?[0,-e]:[-St,e-St])}function exe(e,t,n,r,o,s){var i=e[0],a=e[1],l=t[0],c=t[1],u=0,f=1,h=l-i,p=c-a,m;if(m=n-i,!(!h&&m>0)){if(m/=h,h<0){if(m<u)return;m<f&&(f=m)}else if(h>0){if(m>f)return;m>u&&(u=m)}if(m=o-i,!(!h&&m<0)){if(m/=h,h<0){if(m>f)return;m>u&&(u=m)}else if(h>0){if(m<u)return;m<f&&(f=m)}if(m=r-a,!(!p&&m>0)){if(m/=p,p<0){if(m<u)return;m<f&&(f=m)}else if(p>0){if(m>f)return;m>u&&(u=m)}if(m=s-a,!(!p&&m<0)){if(m/=p,p<0){if(m>f)return;m>u&&(u=m)}else if(p>0){if(m<u)return;m<f&&(f=m)}return u>0&&(e[0]=i+u*h,e[1]=a+u*p),f<1&&(t[0]=i+f*h,t[1]=a+f*p),!0}}}}}var jy=1e9,Ry=-1e9;function txe(e,t,n,r){function o(c,u){return e<=c&&c<=n&&t<=u&&u<=r}function s(c,u,f,h){var p=0,m=0;if(c==null||(p=i(c,f))!==(m=i(u,f))||l(c,u)<0^f>0)do h.point(p===0||p===3?e:n,p>1?r:t);while((p=(p+f+4)%4)!==m);else h.point(u[0],u[1])}function i(c,u){return Ht(c[0]-e)<Je?u>0?0:3:Ht(c[0]-n)<Je?u>0?2:1:Ht(c[1]-t)<Je?u>0?1:0:u>0?3:2}function a(c,u){return l(c.x,u.x)}function l(c,u){var f=i(c,1),h=i(u,1);return f!==h?f-h:f===0?u[1]-c[1]:f===1?c[0]-u[0]:f===2?c[1]-u[1]:u[0]-c[0]}return function(c){var u=c,f=G7(),h,p,m,b,y,g,x,v,w,C,S,N={point:j,lineStart:T,lineEnd:O,polygonStart:R,polygonEnd:M};function j(A,$){o(A,$)&&u.point(A,$)}function _(){for(var A=0,$=0,H=p.length;$<H;++$)for(var U=p[$],B=1,P=U.length,z=U[0],L,D,W=z[0],G=z[1];B<P;++B)L=W,D=G,z=U[B],W=z[0],G=z[1],D<=r?G>r&&(W-L)*(r-D)>(G-D)*(e-L)&&++A:G<=r&&(W-L)*(r-D)<(G-D)*(e-L)&&--A;return A}function R(){u=f,h=[],p=[],S=!0}function M(){var A=_(),$=S&&A,H=(h=V7(h)).length;($||H)&&(c.polygonStart(),$&&(c.lineStart(),s(null,null,1,c),c.lineEnd()),H&&Y7(h,a,A,s,c),c.polygonEnd()),u=c,h=p=m=null}function T(){N.point=I,p&&p.push(m=[]),C=!0,w=!1,x=v=NaN}function O(){h&&(I(b,y),g&&w&&f.rejoin(),h.push(f.result())),N.point=j,w&&u.lineEnd()}function I(A,$){var H=o(A,$);if(p&&m.push([A,$]),C)b=A,y=$,g=H,C=!1,H&&(u.lineStart(),u.point(A,$));else if(H&&w)u.point(A,$);else{var U=[x=Math.max(Ry,Math.min(jy,x)),v=Math.max(Ry,Math.min(jy,v))],B=[A=Math.max(Ry,Math.min(jy,A)),$=Math.max(Ry,Math.min(jy,$))];exe(U,B,e,t,n,r)?(w||(u.lineStart(),u.point(U[0],U[1])),u.point(B[0],B[1]),H||u.lineEnd(),S=!1):H&&(u.lineStart(),u.point(A,$),S=!1)}x=A,v=$,w=H}return N}}var wN,SN,D0,T0,Yf={sphere:xr,point:xr,lineStart:nxe,lineEnd:xr,polygonStart:xr,polygonEnd:xr};function nxe(){Yf.point=oxe,Yf.lineEnd=rxe}function rxe(){Yf.point=Yf.lineEnd=xr}function oxe(e,t){e*=an,t*=an,SN=e,D0=st(t),T0=ht(t),Yf.point=sxe}function sxe(e,t){e*=an,t*=an;var n=st(t),r=ht(t),o=Ht(e-SN),s=ht(o),i=st(o),a=r*i,l=T0*n-D0*r*s,c=D0*n+T0*r*s;wN.add(Hi(ao(a*a+l*l),c)),SN=e,D0=n,T0=r}function ixe(e){return wN=new Wl,Fc(e,Yf),+wN}var CN=[null,null],axe={type:"LineString",coordinates:CN};function EN(e,t){return CN[0]=e,CN[1]=t,ixe(axe)}var hO={Feature:function(e,t){return jx(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,o=n.length;++r<o;)if(jx(n[r].geometry,t))return!0;return!1}},pO={Sphere:function(){return!0},Point:function(e,t){return mO(e.coordinates,t)},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)if(mO(n[r],t))return!0;return!1},LineString:function(e,t){return gO(e.coordinates,t)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)if(gO(n[r],t))return!0;return!1},Polygon:function(e,t){return bO(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,o=n.length;++r<o;)if(bO(n[r],t))return!0;return!1},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,o=n.length;++r<o;)if(jx(n[r],t))return!0;return!1}};function jx(e,t){return e&&pO.hasOwnProperty(e.type)?pO[e.type](e,t):!1}function mO(e,t){return EN(e,t)===0}function gO(e,t){for(var n,r,o,s=0,i=e.length;s<i;s++){if(r=EN(e[s],t),r===0||s>0&&(o=EN(e[s],e[s-1]),o>0&&n<=o&&r<=o&&(n+r-o)*(1-Math.pow((n-r)/o,2))<H7*o))return!0;n=r}return!1}function bO(e,t){return!!Z7(e.map(lxe),X7(t))}function lxe(e){return e=e.map(X7),e.pop(),e}function X7(e){return[e[0]*an,e[1]*an]}function cxe(e,t){return(e&&hO.hasOwnProperty(e.type)?hO[e.type]:jx)(e,t)}function yO(e,t,n){var r=Wd(e,t-Je,n).concat(t);return function(o){return r.map(function(s){return[o,s]})}}function xO(e,t,n){var r=Wd(e,t-Je,n).concat(t);return function(o){return r.map(function(s){return[s,o]})}}function Q7(){var e,t,n,r,o,s,i,a,l=10,c=l,u=90,f=360,h,p,m,b,y=2.5;function g(){return{type:"MultiLineString",coordinates:x()}}function x(){return Wd(Ey(r/u)*u,n,u).map(m).concat(Wd(Ey(a/f)*f,i,f).map(b)).concat(Wd(Ey(t/l)*l,e,l).filter(function(v){return Ht(v%u)>Je}).map(h)).concat(Wd(Ey(s/c)*c,o,c).filter(function(v){return Ht(v%f)>Je}).map(p))}return g.lines=function(){return x().map(function(v){return{type:"LineString",coordinates:v}})},g.outline=function(){return{type:"Polygon",coordinates:[m(r).concat(b(i).slice(1),m(n).reverse().slice(1),b(a).reverse().slice(1))]}},g.extent=function(v){return arguments.length?g.extentMajor(v).extentMinor(v):g.extentMinor()},g.extentMajor=function(v){return arguments.length?(r=+v[0][0],n=+v[1][0],a=+v[0][1],i=+v[1][1],r>n&&(v=r,r=n,n=v),a>i&&(v=a,a=i,i=v),g.precision(y)):[[r,a],[n,i]]},g.extentMinor=function(v){return arguments.length?(t=+v[0][0],e=+v[1][0],s=+v[0][1],o=+v[1][1],t>e&&(v=t,t=e,e=v),s>o&&(v=s,s=o,o=v),g.precision(y)):[[t,s],[e,o]]},g.step=function(v){return arguments.length?g.stepMajor(v).stepMinor(v):g.stepMinor()},g.stepMajor=function(v){return arguments.length?(u=+v[0],f=+v[1],g):[u,f]},g.stepMinor=function(v){return arguments.length?(l=+v[0],c=+v[1],g):[l,c]},g.precision=function(v){return arguments.length?(y=+v,h=yO(s,o,90),p=xO(t,e,y),m=yO(a,i,90),b=xO(r,n,y),g):y},g.extentMajor([[-180,-90+Je],[180,90-Je]]).extentMinor([[-180,-80-Je],[180,80+Je]])}function uxe(){return Q7()()}const NN=e=>e;var bC=new Wl,kN=new Wl,J7,eB,_N,jN,Sa={point:xr,lineStart:xr,lineEnd:xr,polygonStart:function(){Sa.lineStart=dxe,Sa.lineEnd=hxe},polygonEnd:function(){Sa.lineStart=Sa.lineEnd=Sa.point=xr,bC.add(Ht(kN)),kN=new Wl},result:function(){var e=bC/2;return bC=new Wl,e}};function dxe(){Sa.point=fxe}function fxe(e,t){Sa.point=tB,J7=_N=e,eB=jN=t}function tB(e,t){kN.add(jN*e-_N*t),_N=e,jN=t}function hxe(){tB(J7,eB)}var Zf=1/0,Rx=Zf,$m=-Zf,Mx=$m,Dx={point:pxe,lineStart:xr,lineEnd:xr,polygonStart:xr,polygonEnd:xr,result:function(){var e=[[Zf,Rx],[$m,Mx]];return $m=Mx=-(Rx=Zf=1/0),e}};function pxe(e,t){e<Zf&&(Zf=e),e>$m&&($m=e),t<Rx&&(Rx=t),t>Mx&&(Mx=t)}var RN=0,MN=0,wp=0,Tx=0,Px=0,qd=0,DN=0,TN=0,Sp=0,nB,rB,ki,_i,ps={point:Ou,lineStart:vO,lineEnd:wO,polygonStart:function(){ps.lineStart=bxe,ps.lineEnd=yxe},polygonEnd:function(){ps.point=Ou,ps.lineStart=vO,ps.lineEnd=wO},result:function(){var e=Sp?[DN/Sp,TN/Sp]:qd?[Tx/qd,Px/qd]:wp?[RN/wp,MN/wp]:[NaN,NaN];return RN=MN=wp=Tx=Px=qd=DN=TN=Sp=0,e}};function Ou(e,t){RN+=e,MN+=t,++wp}function vO(){ps.point=mxe}function mxe(e,t){ps.point=gxe,Ou(ki=e,_i=t)}function gxe(e,t){var n=e-ki,r=t-_i,o=ao(n*n+r*r);Tx+=o*(ki+e)/2,Px+=o*(_i+t)/2,qd+=o,Ou(ki=e,_i=t)}function wO(){ps.point=Ou}function bxe(){ps.point=xxe}function yxe(){oB(nB,rB)}function xxe(e,t){ps.point=oB,Ou(nB=ki=e,rB=_i=t)}function oB(e,t){var n=e-ki,r=t-_i,o=ao(n*n+r*r);Tx+=o*(ki+e)/2,Px+=o*(_i+t)/2,qd+=o,o=_i*e-ki*t,DN+=o*(ki+e),TN+=o*(_i+t),Sp+=o*3,Ou(ki=e,_i=t)}function sB(e){this._context=e}sB.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:{this._context.moveTo(e,t),this._point=1;break}case 1:{this._context.lineTo(e,t);break}default:{this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,Zo);break}}},result:xr};var PN=new Wl,yC,iB,aB,Cp,Ep,Lm={point:xr,lineStart:function(){Lm.point=vxe},lineEnd:function(){yC&&lB(iB,aB),Lm.point=xr},polygonStart:function(){yC=!0},polygonEnd:function(){yC=null},result:function(){var e=+PN;return PN=new Wl,e}};function vxe(e,t){Lm.point=lB,iB=Cp=e,aB=Ep=t}function lB(e,t){Cp-=e,Ep-=t,PN.add(ao(Cp*Cp+Ep*Ep)),Cp=e,Ep=t}let SO,Ax,CO,EO;class NO{constructor(t){this._append=t==null?cB:wxe(t),this._radius=4.5,this._=""}pointRadius(t){return this._radius=+t,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+="Z"),this._point=NaN}point(t,n){switch(this._point){case 0:{this._append`M${t},${n}`,this._point=1;break}case 1:{this._append`L${t},${n}`;break}default:{if(this._append`M${t},${n}`,this._radius!==CO||this._append!==Ax){const r=this._radius,o=this._;this._="",this._append`m0,${r}a${r},${r} 0 1,1 0,${-2*r}a${r},${r} 0 1,1 0,${2*r}z`,CO=r,Ax=this._append,EO=this._,this._=o}this._+=EO;break}}}result(){const t=this._;return this._="",t.length?t:null}}function cB(e){let t=1;this._+=e[0];for(const n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function wxe(e){const t=Math.floor(e);if(!(t>=0))throw new RangeError(`invalid digits: ${e}`);if(t>15)return cB;if(t!==SO){const n=10**t;SO=t,Ax=function(o){let s=1;this._+=o[0];for(const i=o.length;s<i;++s)this._+=Math.round(arguments[s]*n)/n+o[s]}}return Ax}function kO(e,t){let n=3,r=4.5,o,s;function i(a){return a&&(typeof r=="function"&&s.pointRadius(+r.apply(this,arguments)),Fc(a,o(s))),s.result()}return i.area=function(a){return Fc(a,o(Sa)),Sa.result()},i.measure=function(a){return Fc(a,o(Lm)),Lm.result()},i.bounds=function(a){return Fc(a,o(Dx)),Dx.result()},i.centroid=function(a){return Fc(a,o(ps)),ps.result()},i.projection=function(a){return arguments.length?(o=a==null?(e=null,NN):(e=a).stream,i):e},i.context=function(a){return arguments.length?(s=a==null?(t=null,new NO(n)):new sB(t=a),typeof r!="function"&&s.pointRadius(r),i):t},i.pointRadius=function(a){return arguments.length?(r=typeof a=="function"?a:(s.pointRadius(+a),+a),i):r},i.digits=function(a){if(!arguments.length)return n;if(a==null)n=null;else{const l=Math.floor(a);if(!(l>=0))throw new RangeError(`invalid digits: ${a}`);n=l}return t===null&&(s=new NO(n)),i},i.projection(e).digits(n).context(t)}function fR(e){return function(t){var n=new AN;for(var r in e)n[r]=e[r];return n.stream=t,n}}function AN(){}AN.prototype={constructor:AN,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function hR(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),Fc(n,e.stream(Dx)),t(Dx.result()),r!=null&&e.clipExtent(r),e}function pR(e,t,n){return hR(e,function(r){var o=t[1][0]-t[0][0],s=t[1][1]-t[0][1],i=Math.min(o/(r[1][0]-r[0][0]),s/(r[1][1]-r[0][1])),a=+t[0][0]+(o-i*(r[1][0]+r[0][0]))/2,l=+t[0][1]+(s-i*(r[1][1]+r[0][1]))/2;e.scale(150*i).translate([a,l])},n)}function uB(e,t,n){return pR(e,[[0,0],t],n)}function dB(e,t,n){return hR(e,function(r){var o=+t,s=o/(r[1][0]-r[0][0]),i=(o-s*(r[1][0]+r[0][0]))/2,a=-s*r[0][1];e.scale(150*s).translate([i,a])},n)}function fB(e,t,n){return hR(e,function(r){var o=+t,s=o/(r[1][1]-r[0][1]),i=-s*r[0][0],a=(o-s*(r[1][1]+r[0][1]))/2;e.scale(150*s).translate([i,a])},n)}var _O=16,Sxe=ht(30*an);function jO(e,t){return+t?Exe(e,t):Cxe(e)}function Cxe(e){return fR({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function Exe(e,t){function n(r,o,s,i,a,l,c,u,f,h,p,m,b,y){var g=c-r,x=u-o,v=g*g+x*x;if(v>4*t&&b--){var w=i+h,C=a+p,S=l+m,N=ao(w*w+C*C+S*S),j=_s(S/=N),_=Ht(Ht(S)-1)<Je||Ht(s-f)<Je?(s+f)/2:Hi(C,w),R=e(_,j),M=R[0],T=R[1],O=M-r,I=T-o,A=x*O-g*I;(A*A/v>t||Ht((g*O+x*I)/v-.5)>.3||i*h+a*p+l*m<Sxe)&&(n(r,o,s,i,a,l,M,T,_,w/=N,C/=N,S,b,y),y.point(M,T),n(M,T,_,w,C,S,c,u,f,h,p,m,b,y))}}return function(r){var o,s,i,a,l,c,u,f,h,p,m,b,y={point:g,lineStart:x,lineEnd:w,polygonStart:function(){r.polygonStart(),y.lineStart=C},polygonEnd:function(){r.polygonEnd(),y.lineStart=x}};function g(j,_){j=e(j,_),r.point(j[0],j[1])}function x(){f=NaN,y.point=v,r.lineStart()}function v(j,_){var R=Gf([j,_]),M=e(j,_);n(f,h,u,p,m,b,f=M[0],h=M[1],u=j,p=R[0],m=R[1],b=R[2],_O,r),r.point(f,h)}function w(){y.point=g,r.lineEnd()}function C(){x(),y.point=S,y.lineEnd=N}function S(j,_){v(o=j,_),s=f,i=h,a=p,l=m,c=b,y.point=v}function N(){n(f,h,u,p,m,b,s,i,o,a,l,c,_O,r),y.lineEnd=w,w()}return y}}var Nxe=fR({point:function(e,t){this.stream.point(e*an,t*an)}});function kxe(e){return fR({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}function _xe(e,t,n,r,o){function s(i,a){return i*=r,a*=o,[t+e*i,n-e*a]}return s.invert=function(i,a){return[(i-t)/e*r,(n-a)/e*o]},s}function RO(e,t,n,r,o,s){if(!s)return _xe(e,t,n,r,o);var i=ht(s),a=st(s),l=i*e,c=a*e,u=i/e,f=a/e,h=(a*n-i*t)/e,p=(a*t+i*n)/e;function m(b,y){return b*=r,y*=o,[l*b-c*y+t,n-c*b-l*y]}return m.invert=function(b,y){return[r*(u*b-f*y+h),o*(p-f*b-u*y)]},m}function Ka(e){return hB(function(){return e})()}function hB(e){var t,n=150,r=480,o=250,s=0,i=0,a=0,l=0,c=0,u,f=0,h=1,p=1,m=null,b=fO,y=null,g,x,v,w=NN,C=.5,S,N,j,_,R;function M(A){return j(A[0]*an,A[1]*an)}function T(A){return A=j.invert(A[0],A[1]),A&&[A[0]*to,A[1]*to]}M.stream=function(A){return _&&R===A?_:_=Nxe(kxe(u)(b(S(w(R=A)))))},M.preclip=function(A){return arguments.length?(b=A,m=void 0,I()):b},M.postclip=function(A){return arguments.length?(w=A,y=g=x=v=null,I()):w},M.clipAngle=function(A){return arguments.length?(b=+A?J0e(m=A*an):(m=null,fO),I()):m*to},M.clipExtent=function(A){return arguments.length?(w=A==null?(y=g=x=v=null,NN):txe(y=+A[0][0],g=+A[0][1],x=+A[1][0],v=+A[1][1]),I()):y==null?null:[[y,g],[x,v]]},M.scale=function(A){return arguments.length?(n=+A,O()):n},M.translate=function(A){return arguments.length?(r=+A[0],o=+A[1],O()):[r,o]},M.center=function(A){return arguments.length?(s=A[0]%360*an,i=A[1]%360*an,O()):[s*to,i*to]},M.rotate=function(A){return arguments.length?(a=A[0]%360*an,l=A[1]%360*an,c=A.length>2?A[2]%360*an:0,O()):[a*to,l*to,c*to]},M.angle=function(A){return arguments.length?(f=A%360*an,O()):f*to},M.reflectX=function(A){return arguments.length?(h=A?-1:1,O()):h<0},M.reflectY=function(A){return arguments.length?(p=A?-1:1,O()):p<0},M.precision=function(A){return arguments.length?(S=jO(N,C=A*A),I()):ao(C)},M.fitExtent=function(A,$){return pR(M,A,$)},M.fitSize=function(A,$){return uB(M,A,$)},M.fitWidth=function(A,$){return dB(M,A,$)},M.fitHeight=function(A,$){return fB(M,A,$)};function O(){var A=RO(n,0,0,h,p,f).apply(null,t(s,i)),$=RO(n,r-A[0],o-A[1],h,p,f);return u=q7(a,l,c),N=xN(t,$),j=xN(u,N),S=jO(N,C),I()}function I(){return _=R=null,M}return function(){return t=e.apply(this,arguments),M.invert=t.invert&&T,O()}}function mR(e){var t=0,n=St/3,r=hB(e),o=r(t,n);return o.parallels=function(s){return arguments.length?r(t=s[0]*an,n=s[1]*an):[t*to,n*to]},o}function jxe(e){var t=ht(e);function n(r,o){return[r*t,st(o)/t]}return n.invert=function(r,o){return[r/t,_s(o*t)]},n}function Rxe(e,t){var n=st(e),r=(n+st(t))/2;if(Ht(r)<Je)return jxe(e);var o=1+n*(2*r-n),s=ao(o)/r;function i(a,l){var c=ao(o-2*r*st(l))/r;return[c*st(a*=r),s-c*ht(a)]}return i.invert=function(a,l){var c=s-l,u=Hi(a,Ht(c))*gs(c);return c*r<0&&(u-=St*gs(a)*gs(c)),[u/r,_s((o-(a*a+c*c)*r*r)/(2*r))]},i}function Ix(){return mR(Rxe).scale(155.424).center([0,33.6442])}function pB(){return Ix().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}function Mxe(e){var t=e.length;return{point:function(n,r){for(var o=-1;++o<t;)e[o].point(n,r)},sphere:function(){for(var n=-1;++n<t;)e[n].sphere()},lineStart:function(){for(var n=-1;++n<t;)e[n].lineStart()},lineEnd:function(){for(var n=-1;++n<t;)e[n].lineEnd()},polygonStart:function(){for(var n=-1;++n<t;)e[n].polygonStart()},polygonEnd:function(){for(var n=-1;++n<t;)e[n].polygonEnd()}}}function Dxe(){var e,t,n=pB(),r,o=Ix().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s,i=Ix().rotate([157,0]).center([-3,19.9]).parallels([8,18]),a,l,c={point:function(h,p){l=[h,p]}};function u(h){var p=h[0],m=h[1];return l=null,r.point(p,m),l||(s.point(p,m),l)||(a.point(p,m),l)}u.invert=function(h){var p=n.scale(),m=n.translate(),b=(h[0]-m[0])/p,y=(h[1]-m[1])/p;return(y>=.12&&y<.234&&b>=-.425&&b<-.214?o:y>=.166&&y<.234&&b>=-.214&&b<-.115?i:n).invert(h)},u.stream=function(h){return e&&t===h?e:e=Mxe([n.stream(t=h),o.stream(h),i.stream(h)])},u.precision=function(h){return arguments.length?(n.precision(h),o.precision(h),i.precision(h),f()):n.precision()},u.scale=function(h){return arguments.length?(n.scale(h),o.scale(h*.35),i.scale(h),u.translate(n.translate())):n.scale()},u.translate=function(h){if(!arguments.length)return n.translate();var p=n.scale(),m=+h[0],b=+h[1];return r=n.translate(h).clipExtent([[m-.455*p,b-.238*p],[m+.455*p,b+.238*p]]).stream(c),s=o.translate([m-.307*p,b+.201*p]).clipExtent([[m-.425*p+Je,b+.12*p+Je],[m-.214*p-Je,b+.234*p-Je]]).stream(c),a=i.translate([m-.205*p,b+.212*p]).clipExtent([[m-.214*p+Je,b+.166*p+Je],[m-.115*p-Je,b+.234*p-Je]]).stream(c),f()},u.fitExtent=function(h,p){return pR(u,h,p)},u.fitSize=function(h,p){return uB(u,h,p)},u.fitWidth=function(h,p){return dB(u,h,p)},u.fitHeight=function(h,p){return fB(u,h,p)};function f(){return e=t=null,u}return u.scale(1070)}function mB(e){return function(t,n){var r=ht(t),o=ht(n),s=e(r*o);return s===1/0?[2,0]:[s*o*st(t),s*st(n)]}}function Zg(e){return function(t,n){var r=ao(t*t+n*n),o=e(r),s=st(o),i=ht(o);return[Hi(t*s,r*i),_s(r&&n*s/r)]}}var gB=mB(function(e){return ao(2/(1+e))});gB.invert=Zg(function(e){return 2*_s(e/2)});function Txe(){return Ka(gB).scale(124.75).clipAngle(180-.001)}var bB=mB(function(e){return(e=W7(e))&&e/st(e)});bB.invert=Zg(function(e){return e});function Pxe(){return Ka(bB).scale(79.4188).clipAngle(180-.001)}function Rw(e,t){return[e,Nx(dR((Un+t)/2))]}Rw.invert=function(e,t){return[e,2*Ch(U7(t))-Un]};function Axe(){return yB(Rw).scale(961/Zo)}function yB(e){var t=Ka(e),n=t.center,r=t.scale,o=t.translate,s=t.clipExtent,i=null,a,l,c;t.scale=function(f){return arguments.length?(r(f),u()):r()},t.translate=function(f){return arguments.length?(o(f),u()):o()},t.center=function(f){return arguments.length?(n(f),u()):n()},t.clipExtent=function(f){return arguments.length?(f==null?i=a=l=c=null:(i=+f[0][0],a=+f[0][1],l=+f[1][0],c=+f[1][1]),u()):i==null?null:[[i,a],[l,c]]};function u(){var f=St*r(),h=t(q0e(t.rotate()).invert([0,0]));return s(i==null?[[h[0]-f,h[1]-f],[h[0]+f,h[1]+f]]:e===Rw?[[Math.max(h[0]-f,i),a],[Math.min(h[0]+f,l),c]]:[[i,Math.max(h[1]-f,a)],[l,Math.min(h[1]+f,c)]])}return u()}function My(e){return dR((Un+e)/2)}function Ixe(e,t){var n=ht(e),r=e===t?st(e):Nx(n/ht(t))/Nx(My(t)/My(e)),o=n*pC(My(e),r)/r;if(!r)return Rw;function s(i,a){o>0?a<-Un+Je&&(a=-Un+Je):a>Un-Je&&(a=Un-Je);var l=o/pC(My(a),r);return[l*st(r*i),o-l*ht(r*i)]}return s.invert=function(i,a){var l=o-a,c=gs(r)*ao(i*i+l*l),u=Hi(i,Ht(l))*gs(l);return l*r<0&&(u-=St*gs(i)*gs(l)),[u/r,2*Ch(pC(o/c,1/r))-Un]},s}function Oxe(){return mR(Ixe).scale(109.5).parallels([30,30])}function Ox(e,t){return[e,t]}Ox.invert=Ox;function Fxe(){return Ka(Ox).scale(152.63)}function $xe(e,t){var n=ht(e),r=e===t?st(e):(n-ht(t))/(t-e),o=n/r+e;if(Ht(r)<Je)return Ox;function s(i,a){var l=o-a,c=r*i;return[l*st(c),o-l*ht(c)]}return s.invert=function(i,a){var l=o-a,c=Hi(i,Ht(l))*gs(l);return l*r<0&&(c-=St*gs(i)*gs(l)),[c/r,o-gs(r)*ao(i*i+l*l)]},s}function Lxe(){return mR($xe).scale(131.154).center([0,13.9389])}var Xp=1.340264,Qp=-.081106,Jp=893e-6,em=.003796,Fx=ao(3)/2,zxe=12;function xB(e,t){var n=_s(Fx*st(t)),r=n*n,o=r*r*r;return[e*ht(n)/(Fx*(Xp+3*Qp*r+o*(7*Jp+9*em*r))),n*(Xp+Qp*r+o*(Jp+em*r))]}xB.invert=function(e,t){for(var n=t,r=n*n,o=r*r*r,s=0,i,a,l;s<zxe&&(a=n*(Xp+Qp*r+o*(Jp+em*r))-t,l=Xp+3*Qp*r+o*(7*Jp+9*em*r),n-=i=a/l,r=n*n,o=r*r*r,!(Ht(i)<H7));++s);return[Fx*e*(Xp+3*Qp*r+o*(7*Jp+9*em*r))/ht(n),_s(st(n)/Fx)]};function Bxe(){return Ka(xB).scale(177.158)}function vB(e,t){var n=ht(t),r=ht(e)*n;return[n*st(e)/r,st(t)/r]}vB.invert=Zg(Ch);function Vxe(){return Ka(vB).scale(144.049).clipAngle(60)}function wB(e,t){var n=t*t,r=n*n;return[e*(.8707-.131979*n+r*(-.013791+r*(.003971*n-.001529*r))),t*(1.007226+n*(.015085+r*(-.044475+.028874*n-.005916*r)))]}wB.invert=function(e,t){var n=t,r=25,o;do{var s=n*n,i=s*s;n-=o=(n*(1.007226+s*(.015085+i*(-.044475+.028874*s-.005916*i)))-t)/(1.007226+s*(.015085*3+i*(-.044475*7+.028874*9*s-.005916*11*i)))}while(Ht(o)>Je&&--r>0);return[e/(.8707+(s=n*n)*(-.131979+s*(-.013791+s*s*s*(.003971-.001529*s)))),n]};function Hxe(){return Ka(wB).scale(175.295)}function SB(e,t){return[ht(t)*st(e),st(t)]}SB.invert=Zg(_s);function Uxe(){return Ka(SB).scale(249.5).clipAngle(90+Je)}function CB(e,t){var n=ht(t),r=1+ht(e)*n;return[n*st(e)/r,st(t)/r]}CB.invert=Zg(function(e){return 2*Ch(e)});function Wxe(){return Ka(CB).scale(250).clipAngle(142)}function EB(e,t){return[Nx(dR((Un+t)/2)),-e]}EB.invert=function(e,t){return[-t,2*Ch(U7(e))-Un]};function qxe(){var e=yB(EB),t=e.center,n=e.rotate;return e.center=function(r){return arguments.length?t([-r[1],r[0]]):(r=t(),[r[1],-r[0]])},e.rotate=function(r){return arguments.length?n([r[0],r[1],r.length>2?r[2]+90:90]):(r=n(),[r[0],r[1],r[2]-90])},n([0,0,90]).scale(159.155)}function Yt(e){for(var t=e.length/6|0,n=new Array(t),r=0;r<t;)n[r]="#"+e.slice(r*6,++r*6);return n}function Mw(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function gR(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Eh(){}var Fu=.7,Kf=1/Fu,cf="\\s*([+-]?\\d+)\\s*",zm="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Pi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Gxe=/^#([0-9a-f]{3,8})$/,Yxe=new RegExp(`^rgb\\(${cf},${cf},${cf}\\)$`),Zxe=new RegExp(`^rgb\\(${Pi},${Pi},${Pi}\\)$`),Kxe=new RegExp(`^rgba\\(${cf},${cf},${cf},${zm}\\)$`),Xxe=new RegExp(`^rgba\\(${Pi},${Pi},${Pi},${zm}\\)$`),Qxe=new RegExp(`^hsl\\(${zm},${Pi},${Pi}\\)$`),Jxe=new RegExp(`^hsla\\(${zm},${Pi},${Pi},${zm}\\)$`),MO={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Mw(Eh,bR,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:DO,formatHex:DO,formatHex8:eve,formatHsl:tve,formatRgb:TO,toString:TO});function DO(){return this.rgb().formatHex()}function eve(){return this.rgb().formatHex8()}function tve(){return kB(this).formatHsl()}function TO(){return this.rgb().formatRgb()}function bR(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Gxe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?PO(t):n===3?new Vr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Dy(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Dy(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Yxe.exec(e))?new Vr(t[1],t[2],t[3],1):(t=Zxe.exec(e))?new Vr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Kxe.exec(e))?Dy(t[1],t[2],t[3],t[4]):(t=Xxe.exec(e))?Dy(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Qxe.exec(e))?OO(t[1],t[2]/100,t[3]/100,1):(t=Jxe.exec(e))?OO(t[1],t[2]/100,t[3]/100,t[4]):MO.hasOwnProperty(e)?PO(MO[e]):e==="transparent"?new Vr(NaN,NaN,NaN,0):null}function PO(e){return new Vr(e>>16&255,e>>8&255,e&255,1)}function Dy(e,t,n,r){return r<=0&&(e=t=n=NaN),new Vr(e,t,n,r)}function NB(e){return e instanceof Eh||(e=bR(e)),e?(e=e.rgb(),new Vr(e.r,e.g,e.b,e.opacity)):new Vr}function Bm(e,t,n,r){return arguments.length===1?NB(e):new Vr(e,t,n,r??1)}function Vr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Mw(Vr,Bm,gR(Eh,{brighter(e){return e=e==null?Kf:Math.pow(Kf,e),new Vr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new Vr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Vr(yu(this.r),yu(this.g),yu(this.b),$x(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:AO,formatHex:AO,formatHex8:nve,formatRgb:IO,toString:IO}));function AO(){return`#${Uc(this.r)}${Uc(this.g)}${Uc(this.b)}`}function nve(){return`#${Uc(this.r)}${Uc(this.g)}${Uc(this.b)}${Uc((isNaN(this.opacity)?1:this.opacity)*255)}`}function IO(){const e=$x(this.opacity);return`${e===1?"rgb(":"rgba("}${yu(this.r)}, ${yu(this.g)}, ${yu(this.b)}${e===1?")":`, ${e})`}`}function $x(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function yu(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Uc(e){return e=yu(e),(e<16?"0":"")+e.toString(16)}function OO(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Us(e,t,n,r)}function kB(e){if(e instanceof Us)return new Us(e.h,e.s,e.l,e.opacity);if(e instanceof Eh||(e=bR(e)),!e)return new Us;if(e instanceof Us)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),s=Math.max(t,n,r),i=NaN,a=s-o,l=(s+o)/2;return a?(t===s?i=(n-r)/a+(n<r)*6:n===s?i=(r-t)/a+2:i=(t-n)/a+4,a/=l<.5?s+o:2-s-o,i*=60):a=l>0&&l<1?0:i,new Us(i,a,l,e.opacity)}function rve(e,t,n,r){return arguments.length===1?kB(e):new Us(e,t,n,r??1)}function Us(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Mw(Us,rve,gR(Eh,{brighter(e){return e=e==null?Kf:Math.pow(Kf,e),new Us(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new Us(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Vr(xC(e>=240?e-240:e+120,o,r),xC(e,o,r),xC(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new Us(FO(this.h),Ty(this.s),Ty(this.l),$x(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=$x(this.opacity);return`${e===1?"hsl(":"hsla("}${FO(this.h)}, ${Ty(this.s)*100}%, ${Ty(this.l)*100}%${e===1?")":`, ${e})`}`}}));function FO(e){return e=(e||0)%360,e<0?e+360:e}function Ty(e){return Math.max(0,Math.min(1,e||0))}function xC(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ove=Math.PI/180,sve=180/Math.PI;var _B=-.14861,yR=1.78277,xR=-.29227,Dw=-.90649,Vm=1.97294,$O=Vm*Dw,LO=Vm*yR,zO=yR*xR-Dw*_B;function ive(e){if(e instanceof xu)return new xu(e.h,e.s,e.l,e.opacity);e instanceof Vr||(e=NB(e));var t=e.r/255,n=e.g/255,r=e.b/255,o=(zO*r+$O*t-LO*n)/(zO+$O-LO),s=r-o,i=(Vm*(n-o)-xR*s)/Dw,a=Math.sqrt(i*i+s*s)/(Vm*o*(1-o)),l=a?Math.atan2(i,s)*sve-120:NaN;return new xu(l<0?l+360:l,a,o,e.opacity)}function Ui(e,t,n,r){return arguments.length===1?ive(e):new xu(e,t,n,r??1)}function xu(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Mw(xu,Ui,gR(Eh,{brighter(e){return e=e==null?Kf:Math.pow(Kf,e),new xu(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new xu(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=isNaN(this.h)?0:(this.h+120)*ove,t=+this.l,n=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(e),o=Math.sin(e);return new Vr(255*(t+n*(_B*r+yR*o)),255*(t+n*(xR*r+Dw*o)),255*(t+n*(Vm*r)),this.opacity)}}));function ave(e,t,n,r,o){var s=e*e,i=s*e;return((1-3*e+3*s-i)*t+(4-6*s+3*i)*n+(1+3*e+3*s-3*i)*r+i*o)/6}function lve(e){var t=e.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),o=e[r],s=e[r+1],i=r>0?e[r-1]:2*o-s,a=r<t-1?e[r+2]:2*s-o;return ave((n-r/t)*t,i,o,s,a)}}const vR=e=>()=>e;function jB(e,t){return function(n){return e+n*t}}function cve(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function uve(e,t){var n=t-e;return n?jB(e,n>180||n<-180?n-360*Math.round(n/360):n):vR(isNaN(e)?t:e)}function dve(e){return(e=+e)==1?uf:function(t,n){return n-t?cve(t,n,e):vR(isNaN(t)?n:t)}}function uf(e,t){var n=t-e;return n?jB(e,n):vR(isNaN(e)?t:e)}(function e(t){var n=dve(t);function r(o,s){var i=n((o=Bm(o)).r,(s=Bm(s)).r),a=n(o.g,s.g),l=n(o.b,s.b),c=uf(o.opacity,s.opacity);return function(u){return o.r=i(u),o.g=a(u),o.b=l(u),o.opacity=c(u),o+""}}return r.gamma=e,r})(1);function fve(e){return function(t){var n=t.length,r=new Array(n),o=new Array(n),s=new Array(n),i,a;for(i=0;i<n;++i)a=Bm(t[i]),r[i]=a.r||0,o[i]=a.g||0,s[i]=a.b||0;return r=e(r),o=e(o),s=e(s),a.opacity=1,function(l){return a.r=r(l),a.g=o(l),a.b=s(l),a+""}}}var hve=fve(lve);function RB(e){return function t(n){n=+n;function r(o,s){var i=e((o=Ui(o)).h,(s=Ui(s)).h),a=uf(o.s,s.s),l=uf(o.l,s.l),c=uf(o.opacity,s.opacity);return function(u){return o.h=i(u),o.s=a(u),o.l=l(Math.pow(u,n)),o.opacity=c(u),o+""}}return r.gamma=t,r}(1)}RB(uve);var wR=RB(uf);const mn=e=>hve(e[e.length-1]);var pve=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(Yt);const mve=mn(pve);var gve=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(Yt);const bve=mn(gve);var yve=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(Yt);const xve=mn(yve);var vve=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(Yt);const wve=mn(vve);var Sve=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(Yt);const Cve=mn(Sve);var Eve=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(Yt);const Nve=mn(Eve);var kve=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(Yt);const _ve=mn(kve);var jve=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(Yt);const Rve=mn(jve);var Mve=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(Yt);const Dve=mn(Mve);var Tve=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(Yt);const Pve=mn(Tve);var Ave=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(Yt);const Ive=mn(Ave);var Ove=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(Yt);const Fve=mn(Ove);var $ve=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(Yt);const Lve=mn($ve);var zve=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(Yt);const Bve=mn(zve);var Vve=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(Yt);const Hve=mn(Vve);var Uve=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(Yt);const Wve=mn(Uve);var qve=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(Yt);const Gve=mn(qve);var Yve=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(Yt);const Zve=mn(Yve);var Kve=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(Yt);const Xve=mn(Kve);var Qve=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(Yt);const Jve=mn(Qve);var ewe=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(Yt);const twe=mn(ewe);var nwe=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(Yt);const rwe=mn(nwe);var owe=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(Yt);const swe=mn(owe);var iwe=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Yt);const awe=mn(iwe);var lwe=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(Yt);const cwe=mn(lwe);var uwe=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(Yt);const dwe=mn(uwe);var fwe=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(Yt);const hwe=mn(fwe);function pwe(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-e*(35.34-e*(2381.73-e*(6402.7-e*(7024.72-e*2710.57)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+e*(170.73+e*(52.82-e*(131.46-e*(176.58-e*67.37)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+e*(442.36-e*(2482.43-e*(6167.24-e*(6614.94-e*2475.67)))))))+")"}const mwe=wR(Ui(300,.5,0),Ui(-240,.5,1));var gwe=wR(Ui(-100,.75,.35),Ui(80,1.5,.8)),bwe=wR(Ui(260,.75,.35),Ui(80,1.5,.8)),Py=Ui();function ywe(e){(e<0||e>1)&&(e-=Math.floor(e));var t=Math.abs(e-.5);return Py.h=360*e-100,Py.s=1.5-1.5*t,Py.l=.8-.9*t,Py+""}var Ay=Bm(),xwe=Math.PI/3,vwe=Math.PI*2/3;function wwe(e){var t;return e=(.5-e)*Math.PI,Ay.r=255*(t=Math.sin(e))*t,Ay.g=255*(t=Math.sin(e+xwe))*t,Ay.b=255*(t=Math.sin(e+vwe))*t,Ay+""}function Swe(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+e*(1172.33-e*(10793.56-e*(33300.12-e*(38394.49-e*14825.05)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+e*(557.33+e*(1225.33-e*(3574.96-e*(1073.77+e*707.56)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+e*(3211.1-e*(15327.97-e*(27814-e*(22569.18-e*6838.66)))))))+")"}function Tw(e){var t=e.length;return function(n){return e[Math.max(0,Math.min(t-1,Math.floor(n*t)))]}}const Cwe=Tw(Yt("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));var Ewe=Tw(Yt("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),Nwe=Tw(Yt("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),kwe=Tw(Yt("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function _we(e){return e}function jwe(e){if(e==null)return _we;var t,n,r=e.scale[0],o=e.scale[1],s=e.translate[0],i=e.translate[1];return function(a,l){l||(t=n=0);var c=2,u=a.length,f=new Array(u);for(f[0]=(t+=a[0])*r+s,f[1]=(n+=a[1])*o+i;c<u;)f[c]=a[c],++c;return f}}function Rwe(e,t){for(var n,r=e.length,o=r-t;o<--r;)n=e[o],e[o++]=e[r],e[r]=n}function Mwe(e,t){return typeof t=="string"&&(t=e.objects[t]),t.type==="GeometryCollection"?{type:"FeatureCollection",features:t.geometries.map(function(n){return BO(e,n)})}:BO(e,t)}function BO(e,t){var n=t.id,r=t.bbox,o=t.properties==null?{}:t.properties,s=Dwe(e,t);return n==null&&r==null?{type:"Feature",properties:o,geometry:s}:r==null?{type:"Feature",id:n,properties:o,geometry:s}:{type:"Feature",id:n,bbox:r,properties:o,geometry:s}}function Dwe(e,t){var n=jwe(e.transform),r=e.arcs;function o(u,f){f.length&&f.pop();for(var h=r[u<0?~u:u],p=0,m=h.length;p<m;++p)f.push(n(h[p],p));u<0&&Rwe(f,m)}function s(u){return n(u)}function i(u){for(var f=[],h=0,p=u.length;h<p;++h)o(u[h],f);return f.length<2&&f.push(f[0]),f}function a(u){for(var f=i(u);f.length<4;)f.push(f[0]);return f}function l(u){return u.map(a)}function c(u){var f=u.type,h;switch(f){case"GeometryCollection":return{type:f,geometries:u.geometries.map(c)};case"Point":h=s(u.coordinates);break;case"MultiPoint":h=u.coordinates.map(s);break;case"LineString":h=i(u.arcs);break;case"MultiLineString":h=u.arcs.map(i);break;case"Polygon":h=l(u.arcs);break;case"MultiPolygon":h=u.arcs.map(l);break;default:return null}return{type:f,coordinates:h}}return c(t)}const tm={geoAzimuthalEqualArea:Txe,geoAzimuthalEquidistant:Pxe,geoGnomonic:Vxe,geoOrthographic:Uxe,geoStereographic:Wxe,geoEqualEarth:Bxe,geoAlbers:pB,geoAlbersUsa:Dxe,geoConicConformal:Oxe,geoConicEqualArea:Ix,geoConicEquidistant:Lxe,geoEquirectangular:Fxe,geoMercator:Axe,geoTransverseMercator:qxe,geoNaturalEarth1:Hxe};Object.keys(tm).forEach(e=>{tm[`${e.charAt(3).toLowerCase()}${e.slice(4)}`]=tm[e]});class nd extends lc{constructor(t){super(t),this.outlineBounds=null,this.oldChartBounds=null,this.geoPath=kO()}init(t){t.position="chartArea",super.init(t),typeof t.projection=="function"?this.projection=t.projection:this.projection=(tm[t.projection]||tm.albersUsa)(),this.geoPath.projection(this.projection),this.outlineBounds=null,this.oldChartBounds=null}computeBounds(t){const n=kO(this.projection.fitWidth(1e3,t)).bounds(t),r=Math.ceil(n[1][1]-n[0][1]),o=Math.ceil(n[1][0]-n[0][0]),s=this.projection.translate();this.outlineBounds={width:o,height:r,aspectRatio:o/r,refScale:this.projection.scale(),refX:s[0],refY:s[1]}}updateBounds(){const t=this.chart.chartArea,n=this.outlineBounds;if(!n)return!1;const r=this.options.padding,o=typeof r=="number"?r:r.top,s=typeof r=="number"?r:r.left,i=typeof r=="number"?r:r.bottom,a=typeof r=="number"?r:r.right,l=t.right-t.left-s-a,c=t.bottom-t.top-o-i,u=this.oldChartBounds;this.oldChartBounds={chartWidth:l,chartHeight:c};const f=Math.min(l/n.width,c/n.height),h=n.width*f,p=n.height*f,m=(l-h)*.5+t.left+s,b=(c-p)*.5+t.top+o,y=this.options;return this.projection.scale(n.refScale*f*y.projectionScale).translate([f*n.refX+m+y.projectionOffset[0],f*n.refY+b+y.projectionOffset[1]]),!u||u.chartWidth!==this.oldChartBounds.chartWidth||u.chartHeight!==this.oldChartBounds.chartHeight}}nd.id="projection";nd.defaults={projection:"albersUsa",projectionScale:1,projectionOffset:[0,0],padding:0};nd.descriptors={_scriptable:e=>e!=="projection",_indexable:e=>e!=="projectionOffset"};const Pw={position:"chartArea",property:"value",grid:{z:1,drawOnChartArea:!1},ticks:{z:1},legend:{align:"right",position:"bottom-right",length:100,width:50,margin:8,indicatorWidth:10}};function Twe(e){const{indicatorWidth:t,align:n,margin:r}=e,o=(typeof r=="number"?r:r.left)+(n==="right"?t:0),s=(typeof r=="number"?r:r.top)+(n==="bottom"?t:0),i=(typeof r=="number"?r:r.right)+(n==="left"?t:0),a=(typeof r=="number"?r:r.bottom)+(n==="top"?t:0);return{left:o,top:s,right:i,bottom:a}}function Pwe(e,t,n,r,o){const{indicatorWidth:s,align:i,position:a}=t,l=i==="top"||i==="bottom",c=(i==="left"?o.w:n)+(l?s:0),u=(i==="top"?o.h:r)+(l?0:s),f=Twe(t);if(typeof a=="string")switch(a){case"top-left":return[f.left,f.top];case"top":return[(e.right-c)/2,f.top];case"left":return[f.left,(e.bottom-u)/2];case"top-right":return[e.right-c-f.right,f.top];case"bottom-right":return[e.right-c-f.right,e.bottom-u-f.bottom];case"bottom":return[(e.right-c)/2,e.bottom-u-f.bottom];case"bottom-left":return[f.left,e.bottom-u-f.bottom];default:return[e.right-c-f.right,(e.bottom-u)/2]}return[a.x,a.y]}class Gd extends Iu{constructor(){super(...arguments),this.legendSize={w:0,h:0}}init(t){t.position="chartArea",super.init(t),this.axis="r"}parse(t,n){return t&&typeof t[this.options.property]=="number"?t[this.options.property]:super.parse(t,n)}isHorizontal(){return this.options.legend.align==="top"||this.options.legend.align==="bottom"}_getNormalizedValue(t){return t==null||Number.isNaN(t)?null:(t-this._startValue)/this._valueRange}update(t,n,r){const o=Math.min(n,this.bottom==null?Number.POSITIVE_INFINITY:this.bottom),s=Math.min(t,this.right==null?Number.POSITIVE_INFINITY:this.right),i=this.options.legend,a=this.isHorizontal(),l=(p,m)=>p<1?m*p:p,c=Math.min(s,l(a?i.length:i.width,s))-(a?0:i.indicatorWidth),u=Math.min(o,l(a?i.width:i.length,o))-(a?i.indicatorWidth:0);this.legendSize={w:c,h:u},this.bottom=u,this.height=u,this.right=c,this.width=c;const f=this.options.position;this.options.position=this.options.legend.align;const h=super.update(c,u,r);return this.options.position=f,this.height=Math.min(u,this.height),this.width=Math.min(c,this.width),h}_computeLabelArea(){}draw(t){if(!this._isVisible())return;const n=Pwe(t,this.options.legend,this.width,this.height,this.legendSize),{ctx:r}=this;r.save(),r.translate(n[0],n[1]);const o=this.options.position;this.options.position=this.options.legend.align,super.draw({...t,bottom:this.height+10,right:this.width}),this.options.position=o;const{indicatorWidth:s}=this.options.legend;switch(this.options.legend.align){case"left":r.translate(this.legendSize.w,0);break;case"top":r.translate(0,this.legendSize.h);break;case"bottom":r.translate(0,-s);break;default:r.translate(-s,0);break}this._drawIndicator(),r.restore()}_drawIndicator(){}}class MB extends qf{constructor(){super(...arguments),this.legendSize={w:0,h:0}}init(t){Gd.prototype.init.call(this,t)}parse(t,n){return Gd.prototype.parse.call(this,t,n)}isHorizontal(){return this.options.legend.align==="top"||this.options.legend.align==="bottom"}_getNormalizedValue(t){return t==null||Number.isNaN(t)?null:(Math.log10(t)-this._startValue)/this._valueRange}update(t,n,r){return Gd.prototype.update.call(this,t,n,r)}_computeLabelArea(){}draw(t){return Gd.prototype.draw.call(this,t)}_drawIndicator(){}}const Ca={interpolateBlues:rwe,interpolateBrBG:mve,interpolateBuGn:Pve,interpolateBuPu:Ive,interpolateCividis:pwe,interpolateCool:bwe,interpolateCubehelixDefault:mwe,interpolateGnBu:Fve,interpolateGreens:swe,interpolateGreys:awe,interpolateInferno:Nwe,interpolateMagma:Ewe,interpolateOrRd:Lve,interpolateOranges:hwe,interpolatePRGn:bve,interpolatePiYG:xve,interpolatePlasma:kwe,interpolatePuBu:Hve,interpolatePuBuGn:Bve,interpolatePuOr:wve,interpolatePuRd:Wve,interpolatePurples:cwe,interpolateRainbow:ywe,interpolateRdBu:Cve,interpolateRdGy:Nve,interpolateRdPu:Gve,interpolateRdYlBu:_ve,interpolateRdYlGn:Rve,interpolateReds:dwe,interpolateSinebow:wwe,interpolateSpectral:Dve,interpolateTurbo:Swe,interpolateViridis:Cwe,interpolateWarm:gwe,interpolateYlGn:Xve,interpolateYlGnBu:Zve,interpolateYlOrBr:Jve,interpolateYlOrRd:twe};Object.keys(Ca).forEach(e=>{Ca[`${e.charAt(11).toLowerCase()}${e.slice(12)}`]=Ca[e],Ca[e.slice(11)]=Ca[e]});function DB(e,t){const n=1/t;if(e<=n)return 0;if(e>=1-n)return 1;for(let r=0;r<1;r+=n)if(e<r)return r-n/2;return e}const TB={interpolate:"blues",missing:"transparent",quantize:0};class ql extends Gd{get interpolate(){const t=this.options;return t?typeof t.interpolate=="function"?t.interpolate:Ca[t.interpolate]||Ca.blues:n=>`rgb(${n},${n},${n})`}getColorForValue(t){const n=this._getNormalizedValue(t);return n==null||Number.isNaN(n)?this.options.missing:this.getColor(n)}getColor(t){let n=t;return this.options.quantize>0&&(n=DB(n,this.options.quantize)),this.interpolate(n)}_drawIndicator(){const{indicatorWidth:t}=this.options.legend,n=this._reversePixels;if(this.isHorizontal()){const r=this.width;if(this.options.quantize>0){const o=r/this.options.quantize,s=n?i=>r-o-i:i=>i;for(let i=0;i<r;i+=o){const a=(i+o/2)/r;this.ctx.fillStyle=this.getColor(a),this.ctx.fillRect(s(i),0,o,t)}}else{const o=n?s=>r-1-s:s=>s;for(let s=0;s<r;s+=1)this.ctx.fillStyle=this.getColor((s+.5)/r),this.ctx.fillRect(o(s),0,1,t)}}else{const r=this.height;if(this.options.quantize>0){const o=r/this.options.quantize,s=n?i=>r-o-i:i=>i;for(let i=0;i<r;i+=o){const a=(i+o/2)/r;this.ctx.fillStyle=this.getColor(a),this.ctx.fillRect(0,s(i),t,o)}}else{const o=n?s=>r-1-s:s=>s;for(let s=0;s<r;s+=1)this.ctx.fillStyle=this.getColor((s+.5)/r),this.ctx.fillRect(0,o(s),t,1)}}}}ql.id="color";ql.defaults=lr({},[Iu.defaults,Pw,TB]);ql.descriptors={_scriptable:e=>e!=="interpolate",_indexable:!1};class SR extends MB{constructor(){super(...arguments),this.interpolate=t=>`rgb(${t},${t},${t})`}init(t){super.init(t),typeof t.interpolate=="function"?this.interpolate=t.interpolate:this.interpolate=Ca[t.interpolate]||Ca.blues}getColorForValue(t){return ql.prototype.getColorForValue.call(this,t)}getColor(t){let n=t;return this.options.quantize>0&&(n=DB(n,this.options.quantize)),this.interpolate(n)}_drawIndicator(){return ql.prototype._drawIndicator.call(this)}}SR.id="colorLogarithmic";SR.defaults=lr({},[qf.defaults,Pw,TB]);SR.descriptors={_scriptable:e=>e!=="interpolate",_indexable:!1};const PB={missing:1,mode:"area",range:[2,20],legend:{align:"bottom",length:90,width:70,indicatorWidth:42}};class Gl extends Gd{constructor(){super(...arguments),this._model=null}getSizeForValue(t){const n=this._getNormalizedValue(t);return n==null||Number.isNaN(n)?this.options.missing:this.getSizeImpl(n)}getSizeImpl(t){const[n,r]=this.options.range;if(this.options.mode==="area"){const s=r*r*Math.PI,i=n*n*Math.PI,a=s-i,l=t*a+i;return Math.sqrt(l/Math.PI)}const o=r-n;return t*o+n}_drawIndicator(){const{ctx:t}=this,n=this.options.legend.indicatorWidth/2,r=this.isHorizontal(),o=this.ticks,s=this.getLabelItems(),i=s?s.map(a=>({[r?"x":"y"]:a.options.translation[r?0:1]})):o.map((a,l)=>({[r?"x":"y"]:this.getPixelForTick(l)}));if((this._gridLineItems||[]).forEach(a=>{if(t.save(),t.strokeStyle=a.color,t.lineWidth=a.width,t.setLineDash&&(t.setLineDash(a.borderDash),t.lineDashOffset=a.borderDashOffset),t.beginPath(),this.options.grid.drawTicks)switch(this.options.legend.align){case"left":t.moveTo(0,a.ty1),t.lineTo(n,a.ty2);break;case"top":t.moveTo(a.tx1,0),t.lineTo(a.tx2,n);break;case"bottom":t.moveTo(a.tx1,n),t.lineTo(a.tx2,n*2);break;default:t.moveTo(n,a.ty1),t.lineTo(n*2,a.ty2);break}t.stroke(),t.restore()}),this._model){const a=this._model;t.strokeStyle=a.borderColor,t.lineWidth=a.borderWidth||0,t.fillStyle=a.backgroundColor}else t.fillStyle="blue";o.forEach((a,l)=>{const c=i[l],u=this.getSizeForValue(a.value),f=r?c.x:n,h=r?n:c.y,p={pointStyle:"circle",borderWidth:0,...this._model||{},radius:u};vx(t,p,f,h)})}}Gl.id="size";Gl.defaults=lr({},[Iu.defaults,Pw,PB]);Gl.descriptors={_scriptable:!0,_indexable:e=>e!=="range"};class AB extends MB{constructor(){super(...arguments),this._model=null}getSizeForValue(t){const n=this._getNormalizedValue(t);return n==null||Number.isNaN(n)?this.options.missing:this.getSizeImpl(n)}getSizeImpl(t){return Gl.prototype.getSizeImpl.call(this,t)}_drawIndicator(){Gl.prototype._drawIndicator.call(this)}}AB.id="sizeLogarithmic";AB.defaults=lr({},[qf.defaults,Pw,PB]);function Awe(e,t){return[[e[0][0]-t,e[0][1]-t],[e[1][0]+t,e[1][1]+t]]}class qa extends sa{constructor(){super(...arguments),this.cache=void 0}inRange(t,n){const r=this.getBounds(),o=(Number.isNaN(t)||t>=r.x&&t<=r.x2)&&(Number.isNaN(n)||n>=r.y&&n<=r.y2),s=this.projectionScale.geoPath.projection();if(o&&!Number.isNaN(t)&&!Number.isNaN(n)&&typeof s.invert=="function"){const i=s.invert([t,n]);return i!=null&&cxe(this.feature,i)}return o}inXRange(t){return this.inRange(t,Number.NaN)}inYRange(t){return this.inRange(Number.NaN,t)}getCenterPoint(){if(this.cache&&this.cache.center)return this.cache.center;let t;if(this.center){const n=this.projectionScale.projection([this.center.longitude,this.center.latitude]);t={x:n[0],y:n[1]}}else{const n=this.projectionScale.geoPath.centroid(this.feature);t={x:n[0],y:n[1]}}return this.cache={...this.cache||{},center:t},t}getBounds(){if(this.cache&&this.cache.bounds)return this.cache.bounds;const t=Awe(this.projectionScale.geoPath.bounds(this.feature),this.options.borderWidth/2),n={x:t[0][0],x2:t[1][0],y:t[0][1],y2:t[1][1],width:t[1][0]-t[0][0],height:t[1][1]-t[0][1]};return this.cache={...this.cache||{},bounds:n},n}_drawInCache(t){const n=this.getBounds();if(!Number.isFinite(n.x))return;const r=this.cache&&this.cache.canvas?this.cache.canvas:t.createElement("canvas"),o=Math.floor(n.x),s=Math.floor(n.y),i=Math.ceil(n.x+n.width),a=Math.ceil(n.y+n.height),l=this.pixelRatio||1,c=Math.ceil(Math.max(i-o,1)*l),u=Math.ceil(Math.max(a-s,1)*l);if(c<=0||u<=0)return;r.width=c,r.height=u;const f=r.getContext("2d");f&&(f.clearRect(0,0,r.width,r.height),f.save(),f.scale(l,l),f.translate(-o,-s),this._drawImpl(f),f.restore(),this.cache={...this.cache||{},canvas:r,canvasKey:this._optionsToKey()})}_optionsToKey(){const{options:t}=this;return`${t.backgroundColor};${t.borderColor};${t.borderWidth};${this.pixelRatio}`}_drawImpl(t){const{feature:n}=this,{options:r}=this;t.beginPath(),this.projectionScale.geoPath.context(t)(n),r.backgroundColor&&(t.fillStyle=r.backgroundColor,t.fill()),r.borderColor&&(t.strokeStyle=r.borderColor,t.lineWidth=r.borderWidth,t.stroke())}draw(t){const{feature:n}=this;if(!n)return;(!this.cache||this.cache.canvasKey!==this._optionsToKey())&&t.canvas.ownerDocument!=null&&this._drawInCache(t.canvas.ownerDocument);const r=this.getBounds();if(this.cache&&this.cache.canvas&&this.cache.canvas.width>0&&this.cache.canvas.height>0){const o=Math.floor(r.x),s=Math.floor(r.y),i=Math.ceil(r.x+r.width),a=Math.ceil(r.y+r.height),l=i-o,c=a-s;l>0&&c>0&&t.drawImage(this.cache.canvas,o,s,i-o,a-s)}else Number.isFinite(r.x)&&(t.save(),this._drawImpl(t),t.restore())}}qa.id="geoFeature";qa.defaults={...Ti.defaults,outlineBackgroundColor:null,outlineBorderWidth:0,graticuleBorderColor:"#CCCCCC",graticuleBorderWidth:0};qa.defaultRoutes={outlineBorderColor:"borderColor",...Ti.defaultRoutes||{}};const IB={showOutline:!1,showGraticule:!1,clipMap:!0},OB={scales:{projection:{axis:"x",type:nd.id,position:"chartArea",display:!1}}};function VO(e){const t={...e};return Object.keys(e).forEach(n=>{let r=n;if(n.startsWith("outline")){const o=n.slice(7);r=o[0].toLowerCase()+o.slice(1)}else if(n.startsWith("hoverOutline"))r=`hover${n.slice(12)}`;else return;delete t[n],t[r]=e[n]}),t}class FB extends bs{getGeoDataset(){return super.getDataset()}getGeoOptions(){return this.chart.options}getProjectionScale(){return this.getScaleForId("projection")}linkScales(){const t=this.getGeoDataset(),n=this.getMeta();n.xAxisID="projection",t.xAxisID="projection",n.yAxisID="projection",t.yAxisID="projection",n.xScale=this.getScaleForId("projection"),n.yScale=this.getScaleForId("projection"),this.getProjectionScale().computeBounds(this.resolveOutline())}showOutline(){return rt(this.getGeoDataset().showOutline,this.getGeoOptions().showOutline)}clipMap(){return rt(this.getGeoDataset().clipMap,this.getGeoOptions().clipMap)}getGraticule(){return rt(this.getGeoDataset().showGraticule,this.getGeoOptions().showGraticule)}update(t){super.update(t);const n=this.getMeta(),r=this.getProjectionScale(),o=r.updateBounds();if(this.showOutline()){const s=n.dataset;if(o&&delete s.cache,s.projectionScale=r,s.pixelRatio=this.chart.currentDevicePixelRatio,t!=="resize"){const i=VO(this.resolveDatasetElementOptions(t)),a={feature:this.resolveOutline(),options:i};this.updateElement(s,void 0,a,t),this.getGraticule()&&(n.graticule=i)}}else this.getGraticule()&&t!=="resize"&&(n.graticule=VO(this.resolveDatasetElementOptions(t)));this.updateElements(n.data,0,n.data.length,t),o&&n.data.forEach(s=>delete s.cache)}resolveOutline(){const n=this.getGeoDataset().outline||{type:"Sphere"};return Array.isArray(n)?{type:"FeatureCollection",features:n}:n}showGraticule(){const t=this.getGraticule(),n=this.getMeta().graticule;if(!t||!n)return;const{ctx:r}=this.chart,s=this.getProjectionScale().geoPath.context(r);if(r.save(),r.beginPath(),typeof t=="boolean")t&&s(uxe());else{const i=Q7();t.stepMajor&&i.stepMajor(t.stepMajor),t.stepMinor&&i.stepMinor(t.stepMinor),s(i())}r.strokeStyle=n.graticuleBorderColor,r.lineWidth=n.graticuleBorderWidth,r.stroke(),r.restore()}draw(){const{chart:t}=this,n=this.clipMap();let r=!1;(n===!0||n==="outline"||n==="outline+graticule")&&(r=!0,fu(t.ctx,t.chartArea)),this.showOutline()&&this.getMeta().dataset&&this.getMeta().dataset.draw.call(this.getMeta().dataset,t.ctx,t.chartArea),n===!0||n==="graticule"||n==="outline+graticule"?r||fu(t.ctx,t.chartArea):r&&(r=!1,hu(t.ctx)),this.showGraticule(),n===!0||n==="items"?r||fu(t.ctx,t.chartArea):r&&(r=!1,hu(t.ctx)),this.getMeta().data.forEach(o=>o.draw.call(o,t.ctx,t.chartArea)),r&&(r=!1,hu(t.ctx))}}function $B(e,t,n,r=[],o=[]){or.addControllers(n),Array.isArray(r)?or.addElements(...r):or.addElements(r),Array.isArray(o)?or.addScales(...o):or.addScales(o);const s=t;return s.type=e,s}class Nh extends FB{initialize(){super.initialize(),this.enableOptionSharing=!0}linkScales(){super.linkScales();const t=this.getGeoDataset(),n=this.getMeta();n.vAxisID="color",n.rAxisID="color",t.vAxisID="color",t.rAxisID="color",n.rScale=this.getScaleForId("color"),n.vScale=n.rScale,n.iScale=n.xScale,n.iAxisID=n.xAxisID,t.iAxisID=n.xAxisID}_getOtherScale(t){return t}parse(t,n){const r=this.getMeta().rScale,{data:o}=this.getDataset(),s=this._cachedMeta;for(let i=t;i<t+n;i+=1)s._parsed[i]={[r.axis]:r.parse(o[i],i)}}updateElements(t,n,r,o){const s=this.resolveDataElementOptions(n,o),i=this.getSharedOptions(s),a=this.includeOptions(o,i),l=this.getProjectionScale();this.updateSharedOptions(i,o,s);for(let c=n;c<n+r;c+=1){const u=t[c];u.projectionScale=l,u.feature=this._data[c].feature,u.center=this._data[c].center,u.pixelRatio=this.chart.currentDevicePixelRatio;const f=u.getCenterPoint(),h={x:f.x,y:f.y};a&&(h.options=i||this.resolveDataElementOptions(c,o)),this.updateElement(u,c,h,o)}}indexToColor(t){const n=this.getMeta().rScale;return n.getColorForValue(this.getParsed(t)[n.axis])}}Nh.id="choropleth";Nh.defaults=lr({},[IB,{datasetElementType:qa.id,dataElementType:qa.id}]);Nh.overrides=lr({},[OB,{plugins:{tooltip:{callbacks:{title(){return""},label(e){var t,n,r,o;return e.formattedValue==null?(n=(t=e.chart.data)===null||t===void 0?void 0:t.labels)===null||n===void 0?void 0:n[e.dataIndex]:`${(o=(r=e.chart.data)===null||r===void 0?void 0:r.labels)===null||o===void 0?void 0:o[e.dataIndex]}: ${e.formattedValue}`}}},colors:{enabled:!1}},scales:{color:{type:ql.id,axis:"x"}},elements:{geoFeature:{backgroundColor(e){return e.dataIndex==null?null:e.chart.getDatasetMeta(e.datasetIndex).controller.indexToColor(e.dataIndex)}}}}]);class Iwe extends fn{constructor(t,n){super(t,$B("choropleth",n,Nh,qa,[ql,nd]))}}Iwe.id=Nh.id;class kh extends FB{initialize(){super.initialize(),this.enableOptionSharing=!0}linkScales(){super.linkScales();const t=this.getGeoDataset(),n=this.getMeta();n.vAxisID="size",n.rAxisID="size",t.vAxisID="size",t.rAxisID="size",n.rScale=this.getScaleForId("size"),n.vScale=n.rScale,n.iScale=n.xScale,n.iAxisID=n.xAxisID,t.iAxisID=n.xAxisID}_getOtherScale(t){return t}parse(t,n){const r=this.getMeta().rScale,o=this.getDataset().data,s=this._cachedMeta;for(let i=t;i<t+n;i+=1){const a=o[i];s._parsed[i]={x:a.longitude==null?a.x:a.longitude,y:a.latitude==null?a.y:a.latitude,[r.axis]:r.parse(a,i)}}}updateElements(t,n,r,o){const s=o==="reset",i=this.resolveDataElementOptions(n,o),a=this.getSharedOptions(i),l=this.includeOptions(o,a),c=this.getProjectionScale();this.getMeta().rScale._model=i,this.updateSharedOptions(a,o,i);for(let u=n;u<n+r;u+=1){const f=t[u],h=this.getParsed(u),p=c.projection([h.x,h.y]),m={x:p?p[0]:0,y:p?p[1]:0,skip:Number.isNaN(h.x)||Number.isNaN(h.y)};l&&(m.options=a||this.resolveDataElementOptions(u,o),s&&(m.options.radius=0)),this.updateElement(f,u,m,o)}}indexToRadius(t){const n=this.getMeta().rScale;return n.getSizeForValue(this.getParsed(t)[n.axis])}}kh.id="bubbleMap";kh.defaults=lr({},[IB,{dataElementType:bu.id,datasetElementType:qa.id,showOutline:!0,clipMap:"outline+graticule"}]);kh.overrides=lr({},[OB,{plugins:{tooltip:{callbacks:{title(){return""},label(e){var t,n,r,o;return e.formattedValue==null?(n=(t=e.chart.data)===null||t===void 0?void 0:t.labels)===null||n===void 0?void 0:n[e.dataIndex]:`${(o=(r=e.chart.data)===null||r===void 0?void 0:r.labels)===null||o===void 0?void 0:o[e.dataIndex]}: ${e.formattedValue}`}}}},scales:{size:{axis:"x",type:Gl.id}},elements:{point:{radius(e){return e.dataIndex==null?null:e.chart.getDatasetMeta(e.datasetIndex).controller.indexToRadius(e.dataIndex)},hoverRadius(e){return e.dataIndex==null?null:e.chart.getDatasetMeta(e.datasetIndex).controller.indexToRadius(e.dataIndex)+1}}}}]);class Owe extends fn{constructor(t,n){super(t,$B("bubbleMap",n,kh,qa,[Gl,nd]))}}Owe.id=kh.id;function Fwe(e){var n;return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{display:!0},y:{display:!0}},plugins:{...(n=e==null?void 0:e.options)==null?void 0:n.plugins,legend:{position:"bottom",align:"center"}}}}}function $we(e){var n;return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{beginAtZero:!0,stack:1,reverse:!0},y:{stacked:!0,beginAtZero:!0}},plugins:{...(n=e==null?void 0:e.options)==null?void 0:n.plugins,legend:{position:"bottom",align:"center"}}}}}function Lwe(e){var n;return{...e,type:"bar",options:{...e==null?void 0:e.options,scales:{x:{display:!0},y:{display:!0}},plugins:{...(n=e==null?void 0:e.options)==null?void 0:n.plugins,legend:{position:"bottom",align:"center"}}}}}function zwe(e,t=!1){var r;return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{display:!0,beginAtZero:!1},y:{display:!0,stacked:t}},plugins:{...(r=e==null?void 0:e.options)==null?void 0:r.plugins,legend:{position:"bottom",align:"center"}}}}}function Bwe(e,t){var r,o,s,i,a;return{...e,type:t==="stackedBar"?"bar":"line",options:{...e==null?void 0:e.options,scales:{x:{...(o=(r=e==null?void 0:e.options)==null?void 0:r.scales)==null?void 0:o.x,display:!0,stacked:!0},y:{...(i=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:i.y,display:!0,stacked:t==="stackedBar"}},plugins:{...(a=e==null?void 0:e.options)==null?void 0:a.plugins,legend:{display:!1,position:"bottom",align:"center"}}}}}function Vwe(e){var n;return{...e,type:"line",options:{...e==null?void 0:e.options,scales:{x:{display:!0},y:{display:!0}},plugins:{...(n=e==null?void 0:e.options)==null?void 0:n.plugins,legend:{position:"bottom",align:"center"}}}}}function Hwe(e,t){var r;return{...t,type:e,options:{...t==null?void 0:t.options,scales:{x:{display:!1},y:{display:!1}},plugins:{...(r=t==null?void 0:t.options)==null?void 0:r.plugins,legend:{position:"bottom",align:"center",maxHeight:0,labels:{useBorderRadius:!0,borderRadius:2}}},borderRadius:0}}}function Uwe(e){var r,o;const t=te.getState().theme;let n={...e,type:"radar",options:{...e==null?void 0:e.options,scales:{x:{display:!1},y:{display:!1},r:{grid:{display:!0},angleLines:{},ticks:{}}},plugins:{...(r=e==null?void 0:e.options)==null?void 0:r.plugins,legend:{position:"bottom",align:"center"}}}};return t==="dark"&&(n={...n,options:{...n.options,scales:{...(o=n==null?void 0:n.options)==null?void 0:o.scales,r:{grid:{color:dn.slate[800]},angleLines:{color:dn.slate[800]},ticks:{color:dn.slate[800],showLabelBackdrop:!1}}}}}),n}function Wwe(e,t,n){const r={interaction:{mode:"point"},plugins:{tooltip:{callbacks:{label:function(s){var p;const i=s.dataset.label,a=s.dataIndex,l=s.dataset.data,c=(p=l==null?void 0:l[a])==null?void 0:p.label,u=n==null?void 0:n[0],f=n==null?void 0:n[1],h=n==null?void 0:n[2];if(t==="bubble")return c?`${i} (${c}): ${u}: ${s.raw.x.toFixed(2)}, ${f}: ${s.raw.y.toFixed(2)}, ${h}: ${s.raw.r.toFixed(2)}`:`${i}: ${u}: ${s.raw.x.toFixed(2)}, ${f}: ${s.raw.y.toFixed(2)}, ${h}: ${s.raw.r.toFixed(2)}`;if(t==="scatter")return c?`${i} (${c}): ${u}: ${s.raw.x.toFixed(2)}, ${f}: ${s.raw.y.toFixed(2)}`:`${i}: ${u}: ${s.raw.x.toFixed(2)}, ${f}: ${s.raw.y.toFixed(2)}`}}},datalabels:{display:!1}},scales:{x:{title:{display:!0,text:n[0]},beginAtZero:!0,ticks:{precision:0}},y:{title:{display:!0,text:n[1]},beginAtZero:!0,ticks:{precision:0}}}};return{...e,options:{...e==null?void 0:e.options,...r}}}function No({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:o="",locale:s="en-US"}){let i=1,a=r,l=s;const c=t;n&&!r&&(e>=1e9?(i=1e9,a="B"):e>=1e7&&s==="en-IN"?(i=1e7,a="Cr"):e>=1e5&&s==="en-IN"?(i=1e5,a="L"):e>=1e6?(i=1e6,a="M"):e>=1e3&&(i=1e3,a="K"));const u=e/i,f={maximumFractionDigits:c,minimumFractionDigits:c,useGrouping:!0};if(o){f.style="currency",f.currency=o;try{new Intl.NumberFormat(s,f).format(0)}catch{}}try{new Intl.NumberFormat(s,f).format(0)}catch{l="en-US"}let p=new Intl.NumberFormat(l,f).format(u);return n&&(p+=a),p}function Aw(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function qwe({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:s}){var M,T,O,I,A;const i=((M=r==null?void 0:r.chartOptions)==null?void 0:M.indexAxis)||"y",a={...t,options:{indexAxis:i}},{keys:l}=Xn(e),c=[l[1]],u=l==null?void 0:l[0],f=Az(c,e,r,u),h=uu(f,n);h.forEach(($,H)=>{var U,B,P;$.shrinkAnchor=((P=(B=(U=n==null?void 0:n.data)==null?void 0:U.datasets)==null?void 0:B[H])==null?void 0:P.shrinkAnchor)||"top"});const{plugins:p,options:m}=Ew((r==null?void 0:r.customVisualCode)||""),b=l[0],y=$g(e,b),g=Nr((a==null?void 0:a.options)||{},(n==null?void 0:n.options)||{}),x=Nr(g,(r==null?void 0:r.chartOptions)||{});Array(h.length).fill(!0);const v=e.map($=>$[b]),w=e.map($=>$[c[0]]),C=(T=h[0])==null?void 0:T.backgroundColor.slice(),S={...x,plugins:{...x.plugins,legend:{...(O=x.plugins)==null?void 0:O.legend,labels:{generateLabels:$=>{const H=$.data.labels;return v.map((U,B)=>({text:U,fillStyle:C[B],hidden:!H.includes(U.toString()),index:B,datasetIndex:0,lineWidth:0}))}},onClick:($,H,U)=>{const B=U.chart,P=H.index,z=v[P],L=B.data.datasets[0],D=B.data.labels,W=L.data,G=L.backgroundColor,Z=D.indexOf(z.toString());Z>=0?(D.splice(Z,1),W.splice(Z,1),G.splice(Z,1)):(D.splice(P,0,v[P].toString()),W.splice(P,0,Number(w[P])),G.splice(P,0,C[P])),B.update()}},datalabels:{...(I=x.plugins)==null?void 0:I.datalabels,anchor:$=>$.dataset.data[$.dataIndex]<.02?"end":"start",align:$=>$.dataset.data[$.dataIndex]<.02?"end":"center",textAlign:"center",font:{size:14},formatter:($,H)=>{var U,B,P,z;return No({number:Number($),decimalPlaces:((U=r==null?void 0:r.numberAxisFormat)==null?void 0:U.decimalPlaces)||0,useSuffix:!!((B=r==null?void 0:r.numberAxisFormat)!=null&&B.suffix),customSuffix:"",locale:((P=r==null?void 0:r.numberAxisFormat)==null?void 0:P.locale)||"",currency:((z=r==null?void 0:r.numberAxisFormat)==null?void 0:z.currency)||""})}},tooltip:{...(A=x.plugins)==null?void 0:A.tooltip,callbacks:{title:function($){var z,L,D,W;const U=((L=(z=$==null?void 0:$[0])==null?void 0:z.dataset)==null?void 0:L.data).reduce((G,Z)=>G+Z,0),P=(((D=$==null?void 0:$[0])==null?void 0:D.parsed[i==="x"?"y":"x"])/U*100).toFixed(2);return`${(W=$==null?void 0:$[0])==null?void 0:W.label} (${P}%)`},label:function($){var W,G,Z,V;$.dataset.label;const H=$.dataset.data;H.reduce((F,q)=>F+q,0);const U=$.parsed[i==="x"?"y":"x"],B=H.indexOf(U),P=H[B-1],z=No({number:Number(U),decimalPlaces:((W=r==null?void 0:r.numberAxisFormat)==null?void 0:W.decimalPlaces)||0,useSuffix:!!((G=r==null?void 0:r.numberAxisFormat)!=null&&G.suffix),customSuffix:"",locale:((Z=r==null?void 0:r.numberAxisFormat)==null?void 0:Z.locale)||"",currency:((V=r==null?void 0:r.numberAxisFormat)==null?void 0:V.currency)||""});let L=0;return P!==void 0&&(L=Number((U/P*100).toFixed(2))),z+(P!==void 0?` | Conversion: ${L}%`:"")},footer:function($){var U,B,P,z;return(((B=(U=s==null?void 0:s.interactionConfig)==null?void 0:U.drillHierarchies)==null?void 0:B.length)??0)>0||(((z=(P=s==null?void 0:s.interactionConfig)==null?void 0:P.drillInteractions)==null?void 0:z.length)??0)>0?["─────────────────","Right click to drill"]:[]}}}}},N=Nr(x,S),j=r!=null&&r.dataLabelsConfig?Gj(N,r.dataLabelsConfig,r,"funnel"):N,_=Nr(j,m);return delete _.scales,{type:o,data:{labels:y,datasets:h},options:_,plugins:[...p]}}function Gwe({data:e,cfg:t,customCfg:n,preferences:r,card:o}){var S,N;const s=zwe(t),i=Ywe(e),a=uu(i,n),{plugins:l,options:c}=Ew((r==null?void 0:r.customVisualCode)||""),u=Nr((s==null?void 0:s.options)||{},(t==null?void 0:t.options)||{}),f=Nr(u,(r==null?void 0:r.chartOptions)||{}),h=Nr(f,(n==null?void 0:n.options)||{}),p={...h,plugins:{...h==null?void 0:h.plugins,tooltip:{...(S=h==null?void 0:h.plugins)==null?void 0:S.tooltip,callbacks:{label:function(j){if(Array.isArray(j.raw)&&j.raw.every(_=>_===null))return null},footer:function(j){var R,M,T,O;return(((M=(R=o==null?void 0:o.interactionConfig)==null?void 0:R.drillHierarchies)==null?void 0:M.length)??0)>0||(((O=(T=o==null?void 0:o.interactionConfig)==null?void 0:T.drillInteractions)==null?void 0:O.length)??0)>0?["─────────────────","Right click to drill"]:[]}}}}},m=Nr(p,c),b=H9(t,r),y=Nr(m,b);let g;r!=null&&r.dataLabelsConfig?g=Gj(y,r.dataLabelsConfig,r,"range"):g={...y,plugins:{...y==null?void 0:y.plugins,datalabels:{...(N=y==null?void 0:y.plugins)==null?void 0:N.datalabels,formatter:(j,_)=>j.map(M=>{var T,O,I,A;return No({number:Number(M),decimalPlaces:((T=r==null?void 0:r.numberAxisFormat)==null?void 0:T.decimalPlaces)||0,useSuffix:!!((O=r==null?void 0:r.numberAxisFormat)!=null&&O.suffix),customSuffix:"",locale:((I=r==null?void 0:r.numberAxisFormat)==null?void 0:I.locale)||"",currency:((A=r==null?void 0:r.numberAxisFormat)==null?void 0:A.currency)||""})}).slice(0,2).join(" - ")}}};const{keys:x}=Xn(e),v=x[0];return{type:"bar",data:{labels:[...new Set($g(e,v))],datasets:a},options:g,plugins:[...l]}}function Ywe(e){var h,p,m,b;const{keys:t}=Xn(e),n=t.slice(0,2),r=t.slice(2),o=te.getState().themeStyle,s=(p=(h=o==null?void 0:o.chart)==null?void 0:h.dataset)==null?void 0:p.backgroundColor,i=(b=(m=o==null?void 0:o.chart)==null?void 0:m.dataset)==null?void 0:b.borderColor,a=n[1],l=n[0],c=[...new Set(e.map(y=>y==null?void 0:y[l]))];return[...new Set(e.map(y=>y==null?void 0:y[a]))].map((y,g)=>{const x=e.filter(C=>(C==null?void 0:C[a])===y),w=c.map(C=>{const S=x.filter(N=>(N==null?void 0:N[l])===C);return S.length===0?[[null,null,null]]:S.map(N=>[N==null?void 0:N[r[0]],N==null?void 0:N[r[1]],N==null?void 0:N[r[2]],C])}).flat();return{label:y,data:w,backgroundColor:s==null?void 0:s[g%s.length],borderColor:i==null?void 0:i[g%i.length],borderSkipped:!1}})}function Zwe({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:s}){var w;const i=$we(t),{keys:a}=Xn(e),l=dw({dataArray:e,groupKey:a[0],pivotKey:a[1],valueKey:a[2]}),{keys:c}=Xn(l),u=c.slice(1),f=Pz(u,l,r),h=uu(f,n),p=c[0],m=$g(l,p),{options:b,plugins:y}=Wp({cardType:o,cfg:i,preferences:r,customCfg:n,card:s}),g={type:(n==null?void 0:n.type)||(i==null?void 0:i.type)||"bar",data:{labels:m,datasets:h},options:b,plugins:y},x="x2";return{...g,data:{...g.data,datasets:g.data.datasets.map((C,S)=>S===1?{...C,xAxisID:x}:C)},options:{...g.options,scales:{...(w=g==null?void 0:g.options)==null?void 0:w.scales,[x]:{beginAtZero:!0,stack:1}}}}}function CR({card:e,data:t,cardType:n="bar",cfg:r,customCfg:o,provider:s="chartjs",userSettings:i,preferences:a,topoJson:l,queryConfig:c}){var m,b,y,g,x,v,w,C;const u=e.config;let f=t;const h=u&&u.pivotByColumns&&u.pivotByColumns.length>0,p=u&&u.groupByColumns&&u.groupByColumns.length>0;if(h&&p&&(f=Rpe(t,(u==null?void 0:u.metricColumns)||[])),n==="map"){if(!l)return null;const S=(m=a==null?void 0:a.mapVisualOptions)==null?void 0:m.objectKey;if(!S)return null;const N=Mwe(l,(b=l==null?void 0:l.objects)==null?void 0:b[S]).features;if(!N)return null;const j={plugins:{datalabels:{display:!1}},scales:{x:{display:!1,grid:{display:!1}},y:{display:!1,grid:{display:!1}},projection:{axis:"x",projection:((y=a==null?void 0:a.mapVisualOptions)==null?void 0:y.projection)||"mercator",projectionScale:((g=a==null?void 0:a.mapVisualOptions)==null?void 0:g.projectionScale)||1,projectionOffset:((x=a==null?void 0:a.mapVisualOptions)==null?void 0:x.projectionOffset)||[0,0]},color:{axis:"x",interpolate:((v=a==null?void 0:a.mapVisualOptions)==null?void 0:v.colorScale)||"blues",quantize:5,legend:{position:"bottom-right",align:"right"}}}},{keys:_}=Xn(f),R=N.map($=>{var P;const H=_==null?void 0:_[0],U=_==null?void 0:_[1],B=(P=f.find(z=>(z==null?void 0:z[H])===$.properties.NAME||(z==null?void 0:z[H])===$.properties.name))==null?void 0:P[U];return{feature:$,value:B}}),T=uu([{label:S,data:R,borderColor:"lightgray"}],o),O={type:"choropleth",data:{labels:N.map($=>$.properties.NAME||$.properties.name),datasets:T},options:j},{options:I}=Wp({cfg:O,preferences:a,customCfg:o,cardType:n});return{...O,options:I}}if(n==="bar"){const S=Lwe(r);return vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="horizontalBar"){const S=Fwe(r);return vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="funnel")return qwe({data:f,cfg:r,customCfg:o,preferences:a,cardType:n,card:e});if(n==="tornado"||n==="pyramid")return Zwe({data:f,cfg:r,customCfg:o,preferences:a,cardType:n,card:e});if(n==="stackedBar"||n==="stackedLine"){const S=Bwe(r,n),{keys:N}=Xn(f);return(!h||!p)&&(f=dw({dataArray:f,groupKey:N[0],pivotKey:N[1],valueKey:N[2],sortChart:a==null?void 0:a.sortChart})),vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="line"){const S=Vwe(r);return vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="range")return Gwe({data:f,cfg:r,customCfg:o,preferences:a,card:e});if(n==="pie"||n==="doughnut"||n==="polarArea"){const S=Hwe(n,r),{keys:N}=Xn(f),j=N.slice(0,1),_=N.slice(1),R=Az(_,f,a,j==null?void 0:j[0]),M=uu(R,o),{plugins:T,options:O}=Ew((a==null?void 0:a.customVisualCode)||""),I=j[0],A=$g(f,I),$=Nr((S==null?void 0:S.options)||{},(o==null?void 0:o.options)||{}),H=Nr($,(a==null?void 0:a.chartOptions)||{}),U={...H,plugins:{...H.plugins,datalabels:{...(w=H.plugins)==null?void 0:w.datalabels,formatter:(W,G)=>{var Z,V,F,q;return No({number:Number(W),decimalPlaces:((Z=a==null?void 0:a.numberAxisFormat)==null?void 0:Z.decimalPlaces)||0,useSuffix:!!((V=a==null?void 0:a.numberAxisFormat)!=null&&V.suffix),customSuffix:"",locale:((F=a==null?void 0:a.numberAxisFormat)==null?void 0:F.locale)||"",currency:((q=a==null?void 0:a.numberAxisFormat)==null?void 0:q.currency)||""})}},tooltip:{...(C=H.plugins)==null?void 0:C.tooltip,callbacks:{label:function(W){var Y,ee,X,ne;W.dataset.label;const Z=W.dataset.data.reduce((se,re)=>se+re,0),V=W.parsed,F=No({number:Number(V),decimalPlaces:((Y=a==null?void 0:a.numberAxisFormat)==null?void 0:Y.decimalPlaces)||0,useSuffix:!!((ee=a==null?void 0:a.numberAxisFormat)!=null&&ee.suffix),customSuffix:"",locale:((X=a==null?void 0:a.numberAxisFormat)==null?void 0:X.locale)||"",currency:((ne=a==null?void 0:a.numberAxisFormat)==null?void 0:ne.currency)||""}),q=(V/Z*100).toFixed(2);return F+` (${q}%)`},footer:function(W){var Z,V,F,q;return(((V=(Z=e==null?void 0:e.interactionConfig)==null?void 0:Z.drillHierarchies)==null?void 0:V.length)??0)>0||(((q=(F=e==null?void 0:e.interactionConfig)==null?void 0:F.drillInteractions)==null?void 0:q.length)??0)>0?["─────────────────","Right click to drill"]:[]}}}}},B=Nr(H,U),{options:P}=Wp({cfg:{options:B},preferences:a,customCfg:o,cardType:n,card:e}),z=Nr(P,O);return{type:n,data:{labels:A,datasets:M},options:z,plugins:[n==="doughnut"?{id:"doughnutLabel",beforeDatasetsDraw:function(W,G,Z){var re,ie,be,ue;const{ctx:V,data:F}=W;V.save();const q=W.getDatasetMeta(0).data[0].x,Y=W.getDatasetMeta(0).data[0].y,ee=Aa(Tl()),X=window.getComputedStyle(V.canvas).fontFamily;V.font=`1em ${X}`,V.fontWeight="bolder",V.fillStyle=ee,V.textAlign="center",V.textBaseline="middle";const ne=F.datasets[0].data.reduce((xe,Pe)=>xe+Pe,0),se=No({number:Number(ne),decimalPlaces:((re=a==null?void 0:a.numberAxisFormat)==null?void 0:re.decimalPlaces)||0,useSuffix:!!((ie=a==null?void 0:a.numberAxisFormat)!=null&&ie.suffix),customSuffix:"",locale:((be=a==null?void 0:a.numberAxisFormat)==null?void 0:be.locale)||"",currency:((ue=a==null?void 0:a.numberAxisFormat)==null?void 0:ue.currency)||""});V.fillText(se,q,Y)}}:"",...T]}}if(n==="radar"){const S=Uwe(r);return vd({card:e,data:f,cfg:S,customCfg:o,cardType:n,preferences:a})}if(n==="bubble"||n==="scatter"){const{metricKeys:S}=Xn(f),N=zce(f,n),j=uu(N,o),_=Wwe(r,n,S),{options:R}=Wp({cardType:n,cfg:_,preferences:a,customCfg:o,card:e});return{type:n,data:{datasets:j},options:R}}return vd({card:e,data:f,cfg:r,customCfg:o,cardType:n,preferences:a})}function Kwe({chart:e,elementIndex:t,datasetIndex:n,cardType:r,cfg:o,apply:s}){const i=te.getState().theme;if(!o)return;const a=i==="dark"?"rgb(238,238,238,0.2)":"rgb(238,238,238,0.8)";["bar","line","horizontalBar","bubble","scatter"].includes(r)&&Qwe(e,t,o,s,a),["pie","doughnut","polarArea","funnel"].includes(r)&&Jwe(e,t,o,s,a),["stackedBar","pyramid"].includes(r)&&Xwe({chart:e,elementIndex:t,datasetIndex:n,cfg:o,apply:s,blurColor:a})}function Xwe(e){var a,l,c,u;const{chart:t,elementIndex:n,datasetIndex:r,cfg:o,apply:s,blurColor:i}=e;s?(l=(a=t==null?void 0:t.data)==null?void 0:a.datasets)==null||l.forEach((f,h)=>{var p,m;typeof f.backgroundColor=="string"&&(f.backgroundColor=new Array(f.data.length).fill(f.backgroundColor),f.borderColor=new Array(f.data.length).fill(f.borderColor)),f.backgroundColor=(p=f==null?void 0:f.backgroundColor)==null?void 0:p.map((b,y)=>y===n&&h===r?b:i),f.borderColor=(m=f==null?void 0:f.borderColor)==null?void 0:m.map((b,y)=>y===n&&h===r?b:i)}):(u=(c=t==null?void 0:t.data)==null?void 0:c.datasets)==null||u.forEach((f,h)=>{var p,m,b,y,g,x;f.backgroundColor=new Array(f.data.length).fill((b=(m=(p=o==null?void 0:o.data)==null?void 0:p.datasets)==null?void 0:m[h])==null?void 0:b.backgroundColor),f.borderColor=new Array(f.data.length).fill((x=(g=(y=o==null?void 0:o.data)==null?void 0:y.datasets)==null?void 0:g[h])==null?void 0:x.borderColor)}),t==null||t.update()}function Qwe(e,t,n,r,o){var s,i,a,l;r?(i=(s=e==null?void 0:e.data)==null?void 0:s.datasets)==null||i.forEach(c=>{var u,f;typeof c.backgroundColor=="string"&&(c.backgroundColor=new Array(c.data.length).fill(c.backgroundColor),c.borderColor=new Array(c.data.length).fill(c.borderColor)),c.backgroundColor=(u=c==null?void 0:c.backgroundColor)==null?void 0:u.map((h,p)=>p===t?h:o),c.borderColor=(f=c==null?void 0:c.borderColor)==null?void 0:f.map((h,p)=>p===t?h:o)}):(l=(a=e==null?void 0:e.data)==null?void 0:a.datasets)==null||l.forEach((c,u)=>{var f,h,p,m,b,y;c.backgroundColor=new Array(c.data.length).fill((p=(h=(f=n==null?void 0:n.data)==null?void 0:f.datasets)==null?void 0:h[u])==null?void 0:p.backgroundColor),c.borderColor=new Array(c.data.length).fill((y=(b=(m=n==null?void 0:n.data)==null?void 0:m.datasets)==null?void 0:b[u])==null?void 0:y.borderColor)}),e==null||e.update()}function Jwe(e,t,n,r,o){var s,i,a,l;r?(i=(s=e==null?void 0:e.data)==null?void 0:s.datasets)==null||i.forEach(c=>{var u,f;c.backgroundColor=(u=c==null?void 0:c.backgroundColor)==null?void 0:u.map((h,p)=>p===t?h:o),c.borderColor=(f=c==null?void 0:c.borderColor)==null?void 0:f.map((h,p)=>p===t?h:o)}):(l=(a=e==null?void 0:e.data)==null?void 0:a.datasets)==null||l.forEach((c,u)=>{var f,h,p,m,b,y,g,x;typeof c.backgroundColor=="string"&&(c.backgroundColor=(p=(h=(f=n==null?void 0:n.data)==null?void 0:f.datasets)==null?void 0:h[u])==null?void 0:p.backgroundColor,c.borderColor=(y=(b=(m=n==null?void 0:n.data)==null?void 0:m.datasets)==null?void 0:b[u])==null?void 0:y.borderColor),c.backgroundColor=(g=c==null?void 0:c.backgroundColor)==null?void 0:g.map((v,w)=>{var C;return(C=n.data.datasets[u].backgroundColor)==null?void 0:C[w]}),c.borderColor=(x=c==null?void 0:c.borderColor)==null?void 0:x.map((v,w)=>{var C;return(C=n.data.datasets[u].borderColor)==null?void 0:C[w]})}),e==null||e.update()}function e1e({card:e,data:t,datasetIndex:n,clickIndex:r,value:o}){var s,i,a,l,c,u,f;try{if(!t)return;const{keys:h}=Xn(t);if(e.type==="map"){const p=h[0],m=((i=(s=o==null?void 0:o.feature)==null?void 0:s.properties)==null?void 0:i.name)||((l=(a=o==null?void 0:o.feature)==null?void 0:a.properties)==null?void 0:l.NAME);return[{columnName:p,columnValue:m}]}if(["bar","horizontalBar","line","pie","doughnut","radar","polarArea","funnel"].includes(e.type)){const p=h[0],m=h.slice(1),b=(c=t[r])==null?void 0:c[p];return[{columnName:p,columnValue:b,metric:m[n],value:o}]}if(["stackedBar","pyramid"].includes(e.type)){const p=dw({dataArray:t,groupKey:h[0],pivotKey:h[1],valueKey:h[2]}),m=h[0],b=(u=p[r])==null?void 0:u[m],y=h[1],{keys:g}=Xn(p),v=g.slice(1)[n];return[{columnName:m,columnValue:b,metric:h[2],value:o},{columnName:y,columnValue:v,metric:h[2],value:o}]}if(e.type==="bubble"||e.type==="scatter"){const p=h[0],m=(f=t[n])==null?void 0:f[p];return console.log(o,"bubble"),[{columnName:p,columnValue:m,metric1:h[1],value1:o.x,metric2:h[2],value2:o.y,metric3:h==null?void 0:h[3],value3:o==null?void 0:o.r}]}}catch(h){console.error("Error in getAdhocFilter",h)}}function t1e(e,t){var r,o;if((((r=e.data.datasets)==null?void 0:r.filter(s=>!!s.fill))||[]).length>0){const s=(o=e==null?void 0:e.data.datasets)==null?void 0:o.map(a=>({...a,backgroundColor:[a.backgroundColor].map(l=>{const c=t.createLinearGradient(0,0,0,400);return c.addColorStop(0,l),c.addColorStop(.7,jpe("--semaphor-background")),c})}));return{...e,data:{...e.data,datasets:s}}}return e}function LB(e){var a,l,c,u,f,h;const t=(((l=(a=e.preferences)==null?void 0:a.mapVisualOptions)==null?void 0:l.topoJsonUrl)==="custom"?(u=(c=e.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:u.customTopoJsonUrl:(h=(f=e.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:h.topoJsonUrl)||"",n=!!t&&e.type==="map",{data:r,isLoading:o,isFetching:s,isError:i}=yn({queryKey:["topojson",t],queryFn:()=>fetch(t).then(p=>p.json()),enabled:n,staleTime:1/0});return{data:r,isLoading:o,isFetching:s,isError:i}}function n1e(e,t,n){if(e===t)return!0;const r=new Map;for(const i of n){const a=i.source.name,l=i.target.name;r.has(a)||r.set(a,new Set),r.get(a).add(l),r.has(l)||r.set(l,new Set),r.get(l).add(a)}const o=new Set,s=[e];for(o.add(e);s.length>0;){const i=s.shift(),a=r.get(i);if(a)for(const l of a){if(l===t)return!0;o.has(l)||(o.add(l),s.push(l))}}return!1}function zB(e,t){var m,b,y,g,x,v,w;const{joinabilityMap:n,selectedFields:r,cardConfig:o,autoJoinMetadata:s,baseEntityName:i}=t;if(!n)return{state:"draggable"};if(r.length===0)return{state:"draggable",tooltip:"Select to establish base dataset"};let a;const l=(b=(m=o==null?void 0:o.joinPlan)==null?void 0:m.baseEntity)==null?void 0:b.name,c=(g=(y=s==null?void 0:s.resolvedJoinPlan)==null?void 0:y.baseEntity)==null?void 0:g.name;l?a=l:c?a=c:i?a=i:a=[...new Set(r.map(S=>S.entityName))].filter(Boolean)[0];const u=r.some(C=>C.entityName===e.entityName&&(C.name===e.name||C.id===e.id));if(e.entityName===a)return{state:"base",tooltip:u?"Field already in query (base dataset)":"From base dataset",isSelected:u};const f=n[a];if(!f)return{state:"unreachable",tooltip:"No relationships defined for base dataset"};if(f.canJoinTo.includes(e.entityName))return{state:"draggable",tooltip:`Direct join from ${a}`,joinPath:[a,e.entityName],isSelected:u};const h=(x=f.indirectJoins)==null?void 0:x[e.entityName];if(h&&h.length>0){const C=[a,...h,e.entityName];return{state:"indirect",joinPath:C,tooltip:`Multi-hop join: ${C.join(" → ")}`,isSelected:u}}const p=n[e.entityName];if(p){if(p.canJoinTo.includes(a))return{state:"draggable",tooltip:`Direct join to ${a}`,joinPath:[e.entityName,a],isSelected:u};const C=(v=p.indirectJoins)==null?void 0:v[a];if(C&&C.length>0){const S=[e.entityName,...C,a];return{state:"indirect",joinPath:S,tooltip:`Multi-hop join: ${S.join(" → ")}`,isSelected:u}}}return(w=o==null?void 0:o.joinPlan)!=null&&w.joins&&o.joinPlan.joins.length>0&&n1e(a,e.entityName,o.joinPlan.joins)?{state:"draggable",tooltip:"Manual join configured",isSelected:u}:{state:"unreachable",tooltip:`Cannot join ${e.entityName} to ${a}`,isSelected:u}}function BB(e,t,n){var r;return!n||!((r=n.baseEntity)!=null&&r.name)||!n.joins?!1:e===t||e===zd(n.baseEntity)||t===zd(n.baseEntity)?!0:n.joins.some(o=>{const s=zd(o.source),i=zd(o.target);return s===e&&i===t||s===t&&i===e})}function r1e(e,t,n){var a;const{joinPlan:r,joinabilityMap:o,semanticDomainId:s}=n;if(t.length===0)return{isValid:!0};const i=t[0].qualifiedEntityName;if(!i)return{isValid:!0};if(i===e.qualifiedEntityName)return{isValid:!0};if(e.qualifiedEntityName){if(s&&o)return zB(e,{joinabilityMap:o,selectedFields:t,baseEntityName:(a=r==null?void 0:r.baseEntity)==null?void 0:a.name}).state==="unreachable"?{isValid:!1,showError:!0}:{isValid:!0};if(!r)return{isValid:!1,showError:!0};if(!BB(i,e.qualifiedEntityName,r))return{isValid:!1,showError:!0}}return{isValid:!0}}function o1e(){Le.error("Join Configuration Required",{richColors:!0,description:"To combine fields from two different tables, you need to define a join between them first.",position:"top-center",duration:4e3})}function s1e(e,t){return t.some(n=>{if(!(n.name===e.name&&n.qualifiedEntityName===e.qualifiedEntityName))return!1;if((e.role==="metric"||!e.role)&&n.role==="metric"){const o=e,s=n;if(o.aggregate!==s.aggregate||o.expression!==s.expression)return!1;if(o.parameters||s.parameters){const i=o.parameters||{},a=s.parameters||{},l=JSON.stringify(i),c=JSON.stringify(a);if(l!==c)return!1}return!1}return!0})}function i1e(e){if(e.role!=="metric")return e.label||e.name;const t=e,n=e.label||e.name;if(!t.parameters||!t.parameters.filters)return n;const r=t.parameters.filters;return typeof r=="string"?`${n} (${r})`:typeof r=="object"?(JSON.stringify(r),`${n} (Filtered)`):n}function a1e(e,t,n){const r=e.label||e.name,o=t.filter(s=>s.name===e.name&&s.qualifiedEntityName===e.qualifiedEntityName&&(s.role==="metric"||n==="metrics")).length;return o===0?r:`${r} (${o+1})`}function VB(e,t){return`${e}-${t.qualifiedEntityName}-${t.name}-${Date.now()}`}function HB(e,t){const n=Oi(e.replace(/_/g," "));switch(t){case"SUM":return`Sum of ${n}`;case"COUNT":return`Count of ${n}`;case"DISTINCT":return`Unique ${n}`;case"AVG":return`Average of ${n}`;case"MIN":return`Min of ${n}`;case"MAX":return`Max of ${n}`;default:return n}}function l1e(e,t,n){const r=uh(e.dataType);return n==="kpi"?r==="date"?"groupBy":"metrics":t.length===0||r==="number"?"metrics":r==="date"||r==="string"||r==="boolean"?"groupBy":"metrics"}function c1e(e,t,n=[]){const r=VB(t,e),o=uh(e.dataType),s=o==="date",i={id:r,name:e.name,dataType:e.dataType,label:c_(e.name),qualifiedEntityName:e.qualifiedEntityName,entityId:e.entityId,entityName:e.entityName,entityType:e.entityType};if(t==="metrics"){const a=o==="number"?"SUM":"COUNT",l=HB(e.label,a),c=a1e({...i,label:l},n,t);return{...i,role:"metric",label:c,aggregate:a}}return t==="groupBy"?{...i,role:"groupby",...s&&{granularity:"month",dateFormat:"YYYY-MM"}}:t==="pivotBy"?{...i,role:"pivotby"}:t==="sortBy"?{...i,role:"sortby",label:e.label,direction:"asc"}:null}function u1e(e){var o,s,i;const t=(o=e.config)==null?void 0:o.metricColumns,n=(s=e.config)==null?void 0:s.groupByColumns,r=(i=e.config)==null?void 0:i.pivotByColumns;return!!(t&&(t==null?void 0:t.length)>0||n&&(n==null?void 0:n.length)>0||r&&(r==null?void 0:r.length)>0)}function d1e(e){var i,a;const[t]=E.useState({id:"",title:"",type:"bar"}),{getCard:n}=en(),r=n(e),o=Iw(r||t),s={...r,data:((i=o==null?void 0:o.data)==null?void 0:i.records)||[]};return{...o,data:((a=o==null?void 0:o.data)==null?void 0:a.records)||[],card:s}}function Iw(e){var T;const{onChartElementClicked:t}=Ue(),[n,r]=E.useState(0),o=te(O=>O.themeStyle),s=te(O=>O.filteringCards),i=te(O=>O.selectedSheetId),a=te(O=>O.selectedLensId),l=te(O=>O.filterValues),c=E.useRef(l),u=(T=e==null?void 0:e.preferences)==null?void 0:T.onClickFilter,{addFilteringCard:f,addOrUpdateFilterValues:h,removeFilterValues:p,removeFilteringCard:m}=en(),{data:b,isLoading:y,isFetching:g,isError:x,isPending:v,queryKey:w,isFilteringCard:C,isSingleCardFrame:S,pagination:N}=Ha(e),{data:j}=LB(e);let _;_=E.useMemo(()=>{if(!(!(b!=null&&b.records)||!(b!=null&&b.records.length)))return CR({card:e,data:b==null?void 0:b.records,cardType:e.type,queryConfig:e.queryConfig,customCfg:e.customCfg,preferences:e.preferences,topoJson:j})},[b==null?void 0:b.records,e,j,o]);const R=E.useRef({filteringCards:s});E.useEffect(()=>{e.connectionId&&!C&&(c.current=l)},[l,a,e.connectionId,C]),E.useEffect(()=>{var I;C&&(R.current.filteringCards=[...s||[]]),!C&&((I=R.current.filteringCards)==null?void 0:I.find(A=>A.id===e.id))&&S&&r(A=>A+1)},[C,S,e.id,s]);function M(O,I,A,$){var B;if(u1e(e))return;let H=!1;if(!(b!=null&&b.records))return;const U=e1e({card:e,data:b==null?void 0:b.records,datasetIndex:I,clickIndex:A,value:$});if(console.log("fieldValues",U),t==null||t(e,U),!!(((B=e==null?void 0:e.preferences)==null?void 0:B.onClickFilter)??[]).length){if(C){const P=e.id;p(P),m(e)}else{if(H=!0,!U)return;const P=[];U.forEach((z,L)=>{const D=u==null?void 0:u.find(G=>G.columnIndex===L);if(!D)return;const W={filterId:e.id+"-"+z.columnName+"-"+i,connectionId:e==null?void 0:e.connectionId,tableName:e.lastSelectedTable,name:z.columnName,expression:D.expression,valueType:Iv(U[D.columnIndex].columnValue),operation:"=",values:[U[D.columnIndex].columnValue]};P.push(W)}),h(P),f(e)}Kwe({chart:O,elementIndex:A,datasetIndex:I,cardType:e.type,cfg:_,apply:H})}}return{isPending:v,isError:x,isLoading:y,isFetching:g,data:b,visualKey:n,handleDatapointClick:M,cfg:_,queryKey:w,pagination:N}}function vC(e,t){if(e==null)return"-";if(!t)return e.toString();const n=t.locale?new Intl.NumberFormat(t.locale).format(e):e.toFixed(t.decimalPlaces||0);return`${t.prefix||""}${n}${t.suffix||""}`}function HO(e,t){return t.map(n=>{const r=n.alias||n.name,o=e[r];return typeof o=="object"&&o!==null&&"label"in o?String(o.label??""):String(o??"")}).join(" | ")}function UB(e,t=0,n=[],r){if(!(e!=null&&e.length)||t>=e[0].fieldValues.length)return[];const o=l=>n.every((c,u)=>l.fieldValues[u]===c),s=e.filter(o),i=[],a=new Set;for(const l of s){const c=l.fieldValues[t];if(a.has(c))continue;a.add(c);const u=[...n,c],f=u.join(" | ");if(r&&!r.has(f))continue;if(t===l.fieldValues.length-1)i.push({name:c,level:t,rowKey:l.rowKey});else{const p=UB(s.filter(m=>m.fieldValues[t]===c),t+1,u,r);p.length>0&&i.push({name:c,level:t,children:p})}}return i}function f1e(e,t={},n){const r=e.records,o=e.pivotSchema||[],s=e.columnSubtotalMeta||[],i=e.groupByColumns||[],a=e.columnMetadata,l=o.filter(T=>T.isPivotColumn),c=o.filter(T=>T.isMetricColumn),u=()=>({rowHeaders:[],columnHeaders:[],cells:{},columnGroups:[],rowGroups:[],columnDisplayNames:{},groupByColumns:i,columnSubtotalMeta:s,columnMetadata:a});if(l.length===0&&c.length===0)return console.warn("No pivot or metric fields found in pivotSchema:",o),u();const{columnGroups:f,columnHeaders:h,columnDisplayNames:p}=h1e(o,s,n==null?void 0:n.config);if(!r.length)return u();const m=r.filter(T=>T.isGrandTotal),b=r.filter(T=>T.isSubtotal&&!T.isGrandTotal),y=r.filter(T=>!T.isSubtotal&&!T.isGrandTotal),g=[],x=new Set;y.forEach(T=>{const O=HO(T,i),I=i.map(A=>{const $=A.alias||A.name,H=T[$];return typeof H=="object"&&H!==null&&"label"in H?String(H.label??""):String(H??"")});O&&!x.has(O)&&(x.add(O),g.push({rowKey:O,fieldValues:I}))}),g.sort((T,O)=>{const I=Math.min(T.fieldValues.length,O.fieldValues.length);for(let A=0;A<I;A++){const $=(T.fieldValues[A]||"").localeCompare(O.fieldValues[A]||"");if($!==0)return $}return T.fieldValues.length-O.fieldValues.length});const v=[],w=[],C=new Set;for(let T=0;T<g.length;T++){const O=g[T];v.push(O),w.push(O.rowKey);const I=g[T+1];for(let A=i.length-1;A>=0;A--){const $=i[A];$.alias||$.name;let H=!1;if(!I)H=!0;else{H=O.fieldValues[A]!==I.fieldValues[A];for(let U=0;U<A&&!H;U++)O.fieldValues[U]!==I.fieldValues[U]&&(H=!0)}H&&b.filter(B=>{const P=$.alias||$.name;if(B.subtotalLevel!==P&&B.subtotalLevel!==$.id)return!1;if(B.subtotalContext){if(B.subtotalContext.value!==O.fieldValues[A])return!1;const z=B.subtotalContext.groupByValues||{};for(let L=0;L<A;L++){const D=i[L],W=D.alias||D.name;if(z[W]!==O.fieldValues[L])return!1}return!0}for(let z=0;z<A;z++){const L=i[z],D=L.alias||L.name,W=B[D],G=O.fieldValues[z],Z=typeof W=="object"&&(W!=null&&W.label)?W.label:String(W??"");if(G!==Z)return!1}return!0}).forEach(B=>{var W;const P=JSON.stringify({level:B.subtotalLevel,context:B.subtotalContext});if(C.has(P))return;const z=[...O.fieldValues],L=`${O.fieldValues[A]} Total`;z[A]=L;for(let G=A+1;G<z.length;G++)z[G]="";const D=z.join(" | ");v.push({rowKey:D,fieldValues:z,isSubtotal:!0,subtotalLevel:B.subtotalLevel,aggregateDisplayLabel:B.aggregate,aggregateFunction:(W=B.aggregate)==null?void 0:W.toUpperCase(),subtotalContext:B.subtotalContext}),w.push(D),C.add(P)})}}const S=v,N=w,j=new Set(S.map(T=>T.rowKey)),_=UB(S,0,[],j),R={};N.forEach(T=>{R[T]={},h.forEach(O=>{R[T][O]={value:null,metricId:"",formattedValue:"-"}})}),y.forEach(T=>{const O=HO(T,i);R[O]&&h.forEach(I=>{if(!(I in T))return;const A=T[I],$=o.find(H=>H.isMetricColumn&&I.startsWith(H.alias));R[O][I]={value:A,metricId:($==null?void 0:$.metricId)||"",formattedValue:vC(A,t.numberFormat)}})}),b.forEach(T=>{const O=S.find(I=>I.isSubtotal&&I.subtotalLevel===T.subtotalLevel&&JSON.stringify(I.subtotalContext)===JSON.stringify(T.subtotalContext));if(O){const I=O.rowKey;R[I]||(R[I]={}),h.forEach(A=>{if(!(A in T))return;const $=T[A],H=o.find(U=>U.isMetricColumn&&A.startsWith(U.alias));R[I][A]={value:$,metricId:(H==null?void 0:H.metricId)||"",formattedValue:vC($,t.numberFormat)}})}});const M=[];return m.forEach(T=>{const O={};h.forEach(U=>{if(U in T){const B=T[U];O[U]={value:B,metricId:"",formattedValue:vC(B,t.numberFormat)}}});const I=T.aggregate||"Total";let A="SUM";const $=I.toUpperCase();["SUM","AVG","COUNT","MIN","MAX","MEDIAN"].includes($)&&(A=$);const H=I.charAt(0).toUpperCase()+I.slice(1).toLowerCase();M.push({aggregateDisplayLabel:H,aggregateFunction:A,data:O})}),{rowHeaders:N,columnHeaders:h,cells:R,columnGroups:f,rowGroups:_,columnDisplayNames:p,groupByColumns:i,columnSubtotalMeta:s,columnMetadata:a,grandTotalRows:M,rowData:S}}function h1e(e,t,n){const r=e.filter(u=>u.isPivotColumn),o=new Map;e.filter(u=>u.isMetricColumn).forEach(u=>{o.has(u.alias)||o.set(u.alias,u)});const s=Array.from(o.values());function i(u){return u.displayLabel||u.metricLabel||u.metricName||u.alias}function a(u,f=[]){if(u>=r.length){const m=[],b=[],y={};return s.forEach(g=>{const x=[g.alias,...f].join("_"),v=i(g);m.push({name:v,level:u,colspan:1,columnKey:x}),b.push(x),y[x]=v}),{groups:m,leafKeys:b,displayNames:y}}const h=r[u],p={groups:[],leafKeys:[],displayNames:{}};return h.pivotValues.forEach(m=>{const b=[...f,m],y=a(u+1,b);t.filter(x=>x.subtotalLevel===m).forEach(x=>{y.groups.push({name:x.aggregate,level:u+1,colspan:1,columnKey:x.columnName}),y.leafKeys.push(x.columnName),y.displayNames[x.columnName]=`${x.aggregate} (${m})`}),p.groups.push({name:m,level:u,colspan:y.groups.reduce((x,v)=>x+(v.colspan||1),0),children:y.groups}),p.leafKeys.push(...y.leafKeys),Object.assign(p.displayNames,y.displayNames)}),p}const l=a(0),c=t.filter(u=>u.subtotalLevel==="grandTotal"||u.subtotalLevel==="ALL");return c.length>0&&c.forEach(u=>{var m,b,y;const f=(m=u.aggregate)==null?void 0:m.toUpperCase(),p=((y=(b=n==null?void 0:n.columnAggregates)==null?void 0:b.find(g=>g.function===f&&g.pivotLevel==="ALL"))==null?void 0:y.label)||u.aggregate||"Total";l.groups.push({name:p,level:0,colspan:1,columnKey:u.columnName}),l.leafKeys.push(u.columnName),l.displayNames[u.columnName]=p}),{columnGroups:l.groups,columnHeaders:l.leafKeys,columnDisplayNames:l.displayNames}}function p1e({data:e,card:t}){var s;if(!t.config)throw new Error("Card configuration is required for pivot table");const n=e.records.some(i=>i.isGrandTotal),r=((s=t.config)==null?void 0:s.rowAggregates)&&t.config.rowAggregates.length>0,o={showRowTotals:!1,showColumnTotals:n||r,showGrandTotal:!1};return{type:"pivotTable",data:f1e(e,o,t),config:t.config,options:o,pivotSchema:e.pivotSchema}}function Kg(e,t){return E.useMemo(()=>!e||e.type!=="pivotTable"||!t||!Array.isArray(t.records)||t.records.length===0?null:p1e({card:e,data:{records:t.records||[],columnSubtotalMeta:t.columnSubtotalMeta,subtotalColumns:t.subtotalColumns,pivotSchema:t.pivotSchema||[],groupByColumns:t.groupByColumns}}),[e,t])}function m1e({records:e,tablePreferences:t}){if(!e||e.length===0)return null;const n=(t==null?void 0:t.columnSettingsMap)||{},r=Object.keys(e[0]);let o=r;if(t!=null&&t.columnVisibility&&(o=r.filter(a=>{var l;return((l=t.columnVisibility)==null?void 0:l[a])!==!1})),t!=null&&t.columnSizing){const l=Object.keys(t.columnSizing).filter(u=>o.includes(u)),c=o.filter(u=>!l.includes(u));o=[...l,...c]}const s=o.map(a=>{const l=n[a],u=((l==null?void 0:l.textAlign)||"left")==="right";return{text:a,colspan:1,rowspan:1,className:u?"numeric":"",columnId:a,isHeader:!0,isNumeric:u}}),i=e.map(a=>({cells:o.map(l=>{const c=n[l],u=g1e(a[l],c),h=((c==null?void 0:c.textAlign)||"left")==="right";return{text:u,colspan:1,rowspan:1,className:h?"numeric":"",columnId:l,isHeader:!1,isNumeric:h}})}));return{headers:[{cells:s}],rows:i,metadata:{tableType:"data",totalRows:i.length,totalColumns:o.length}}}function g1e(e,t){if(e==null)return"";if((t==null?void 0:t.type)==="number"&&typeof e=="number"){const n=t.numberFormat;try{return new Intl.NumberFormat(n.locale||"en-US",{style:n.style,currency:n.style==="currency"?n.currency:void 0,minimumFractionDigits:n.minimumFractionDigits,maximumFractionDigits:n.maximumFractionDigits}).format(e)}catch{return e.toLocaleString()}}if((t==null?void 0:t.type)==="date")try{const n=t.dateFormat.timezone&&t.dateFormat.timezone!=="auto"?t.dateFormat.timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,r=t.dateFormat.useCustomFormat?t.dateFormat.customFormat:t.dateFormat.format;return Wg(String(e),r,n,t.dateFormat.sourceTimezone||"auto")}catch{return String(e)}return typeof e=="number"?e.toLocaleString():String(e)}function b1e({records:e,groupByColumns:t=[],pivotSchema:n=[],card:r,columnSettings:o={}}){var f,h,p;if(!e||e.length===0)return null;const s=Lj(e,t),i=zj(e),a=n.filter(m=>m.isMetricColumn),l=[...t.map(m=>({text:m.label||m.name,colspan:1,rowspan:1,className:"",columnId:m.alias||m.name,isHeader:!0,isNumeric:!1})),...a.map(m=>({text:m.metricLabel||m.metricName||m.alias,colspan:1,rowspan:1,className:"numeric",columnId:m.alias,isHeader:!0,isNumeric:!0}))],c=s.map(m=>{const b=[],y=m.isSubtotal&&!m.isGrandTotal;return t.forEach(g=>{var w,C,S;const x=g.alias||g.name;let v=m[x];if(y){const N=m.aggregate||"SUM",j=(S=(C=(w=r==null?void 0:r.config)==null?void 0:w.rowAggregates)==null?void 0:C.find(_=>_.groupLevel===m.subtotalLevel&&_.function===N))==null?void 0:S.label;v=E9(m,x,N,j)}else m.isGrandTotal&&(v="");b.push({text:v&&v!=="__TOTAL__"?String(v):"",colspan:1,rowspan:1,className:"",columnId:x,isHeader:!1,isNumeric:!1})}),a.forEach(g=>{const x=g.alias,v=o[x],w=UO(m[x],v);b.push({text:w,colspan:1,rowspan:1,className:"numeric",columnId:x,isHeader:!1,isNumeric:!0})}),{type:y?"subtotal":void 0,cells:b}});let u=null;if(i){const m=i.aggregate||"SUM",b=(p=(h=(f=r==null?void 0:r.config)==null?void 0:f.rowAggregates)==null?void 0:h.find(x=>x.groupLevel==="ALL"))==null?void 0:p.label,y=N9(m,b),g=[];t.forEach((x,v)=>{g.push({text:v===0?y:"",colspan:1,rowspan:1,className:"",isHeader:!1,isNumeric:!1})}),a.forEach(x=>{const v=x.alias,w=o[v];let C=i[v];(C==null||C==="")&&(C=e.filter(N=>!N.isSubtotal&&!N.isGrandTotal).reduce((N,j)=>{const _=Number(String(j[v]??"0").replace(/,/g,""));return N+(Number.isFinite(_)?_:0)},0));const S=UO(C,w);g.push({text:S,colspan:1,rowspan:1,className:"numeric",columnId:v,isHeader:!1,isNumeric:!0})}),u={cells:g}}return{headers:[{cells:l}],rows:c,grandTotal:u,metadata:{tableType:"aggregate",totalRows:c.length,totalColumns:l.length,groupByCount:t.length,hasGrandTotal:!!u}}}function UO(e,t){if(e==null)return"";if((t==null?void 0:t.type)==="number"&&typeof e=="number"){const n=t.numberFormat;try{return new Intl.NumberFormat(n.locale||"en-US",{style:n.style,currency:n.style==="currency"?n.currency:void 0,minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e)}catch{return e.toLocaleString()}}return typeof e=="number"?e.toLocaleString():String(e)}function y1e({pivotConfig:e,card:t,showRowTotals:n}){var c,u,f;if(!(e!=null&&e.data))return null;const r=e.data,o=x1e(r,t,!!n),{tableData:s,grandTotalRows:i}=Hj(r),a=s.map(h=>{const p=[];h.fieldValues.forEach(b=>{p.push({text:b||"",colspan:1,rowspan:1,className:"",isHeader:!1,isNumeric:!1})});let m=0;if(r.columnHeaders.forEach(b=>{var C,S,N;const y=h.cells[b],g=(N=(S=(C=t.preferences)==null?void 0:C.tablePrefs)==null?void 0:S.columnSettingsMap)==null?void 0:N[b],x=ka((y==null?void 0:y.value)??(y==null?void 0:y.formattedValue)??"",g),v=((g==null?void 0:g.textAlign)||"right")==="right";p.push({text:x==="-"?"":String(x),colspan:1,rowspan:1,className:v?"numeric":"",columnId:b,isHeader:!1,isNumeric:v});const w=typeof(y==null?void 0:y.value)=="number"?y.value:Number(String((y==null?void 0:y.formattedValue)??"").replace(/,/g,""));Number.isFinite(w)&&(m+=w)}),n){const b=ka(m,void 0);p.push({text:b==="-"?"":String(b),colspan:1,rowspan:1,className:"numeric",isHeader:!1,isNumeric:!0})}return{type:h.isSubtotal?"subtotal":void 0,cells:p}});let l=null;if(i&&i.length>0){const h=i[0],p=[],m=h.aggregateDisplayLabel||h.aggregateFunction||"Total";r.groupByColumns&&r.groupByColumns.length>0&&r.groupByColumns.forEach((y,g)=>{p.push({text:g===0?m:"",colspan:1,rowspan:1,className:"",isHeader:!1,isNumeric:!1})});let b=0;if(r.columnHeaders.forEach(y=>{var S,N,j;const g=(j=(N=(S=t.preferences)==null?void 0:S.tablePrefs)==null?void 0:N.columnSettingsMap)==null?void 0:j[y],x=h.data?h.data[y]:void 0;let v=(x==null?void 0:x.value)??(x==null?void 0:x.formattedValue)??"";(v===""||v===void 0||v===null)&&(v=s.reduce((_,R)=>{const M=R.cells[y],T=typeof(M==null?void 0:M.value)=="number"?M.value:Number(String((M==null?void 0:M.formattedValue)??(M==null?void 0:M.value)??"0").replace(/,/g,""));return _+(Number.isFinite(T)?T:0)},0));const w=ka(v,g);p.push({text:w==="-"?"":String(w),colspan:1,rowspan:1,className:"numeric",columnId:y,isHeader:!1,isNumeric:!0});const C=typeof v=="number"?v:Number(String(v).replace(/,/g,""));Number.isFinite(C)&&(b+=C)}),n){const y=ka(b,void 0);p.push({text:y==="-"?"":String(y),colspan:1,rowspan:1,className:"numeric",isHeader:!1,isNumeric:!0})}l={cells:p}}return{headers:o,rows:a,grandTotal:l,metadata:{tableType:"pivot",totalRows:a.length,rowLevels:((c=r.groupByColumns)==null?void 0:c.length)??0,pivotLevels:((f=(u=t.config)==null?void 0:u.pivotByColumns)==null?void 0:f.length)??0,hasGrandTotal:!!l}}}function x1e(e,t,n){var c,u;const o=(((c=t.config)==null?void 0:c.pivotByColumns)||[]).length,s=((u=e.groupByColumns)==null?void 0:u.length)||0;if(!e.columnGroups||e.columnGroups.length===0||o===0){const f=[];return e.groupByColumns&&e.groupByColumns.forEach(h=>{f.push({text:h.label||h.name,colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1})}),e.columnHeaders.forEach(h=>{var p;f.push({text:((p=e.columnDisplayNames)==null?void 0:p[h])||h,colspan:1,rowspan:1,className:"numeric",columnId:h,isHeader:!0,isNumeric:!0})}),n&&f.push({text:"Total",colspan:1,rowspan:1,className:"numeric",isHeader:!0,isNumeric:!0}),[{headerType:"simple",headerRowIndex:0,repeatHeader:!0,cells:f}]}const i=Array.from({length:o+1},()=>({cells:[]}));if(s>0&&e.groupByColumns){const f=i[o];e.groupByColumns.forEach(h=>{f.cells.push({text:h.label||h.name,colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1})});for(let h=0;h<o;h+=1)for(let p=0;p<s;p+=1)i[h].cells.push({text:"",colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1})}const a=Array.from({length:o},()=>[]);WB(e.columnGroups,a,o);for(let f=0;f<o;f+=1)i[f].cells.push(...a[f]);const l=[];if(e.columnGroups&&e.columnGroups.length>0?qB(e.columnGroups,l,e.columnDisplayNames||{}):e.columnHeaders.forEach(f=>{var h;l.push({text:((h=e.columnDisplayNames)==null?void 0:h[f])||f,colspan:1,rowspan:1,className:"numeric",columnId:f,isHeader:!0,isNumeric:!0})}),i[o].cells.push(...l),n){i[o].cells.push({text:"Total",colspan:1,rowspan:1,className:"numeric",isHeader:!0,isNumeric:!0});for(let f=0;f<o;f+=1)i[f].cells.push({text:"",colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1})}return i.map((f,h)=>({headerType:h<o?"pivot-level":"metrics",headerRowIndex:h,repeatHeader:!0,cells:f.cells}))}function WB(e,t,n){e.forEach(r=>{const o=r.level;if(o<n){t[o].push({text:r.name||"",colspan:r.colspan||1,rowspan:1,className:"",isHeader:!0,isNumeric:!1});for(let s=1;s<(r.colspan||1);s+=1)t[o].push({text:"",colspan:1,rowspan:1,className:"",isHeader:!0,isNumeric:!1});r.children&&WB(r.children,t,n)}})}function qB(e,t,n){e.forEach(r=>{r.columnKey?t.push({text:n[r.columnKey]||r.name||"Metric",colspan:1,rowspan:1,className:"numeric",columnId:r.columnKey,isHeader:!0,isNumeric:!0}):r.children&&qB(r.children,t,n)})}function GB(e,t){var r,o,s,i;if(t==="table-print")return"disabled";if((o=(r=e.preferences)==null?void 0:r.tablePrefs)!=null&&o.forceClientPagination)return"client";const n=zl(e.config);return e.sql&&!n?(i=(s=e.preferences)==null?void 0:s.tablePrefs)!=null&&i.enableDevModePagination?"server":"client":n&&_m(e)?"server":"client"}function YB({isOpen:e,onClose:t,frame:n,card:r,data:o}){var j;const{tokenProps:s}=Ue(),i=r?Bj(r.type):["pdf"],a=r?Vj(r.type):"pdf",[l,c]=E.useState(!1),[u,f]=E.useState(!1),[h,p]=E.useState({format:a,pageSize:"letter",orientation:"portrait",protectPdf:!1,pdfPassword:"",delimiter:",",includeHeaders:!0});te(_=>_.authToken),te(_=>{var R;return(R=_.dashboard)==null?void 0:R.id}),te(_=>{var R;return(R=_.dashboard)==null?void 0:R.title});const{cardFilterValues:m}=uw((r==null?void 0:r.id)||""),b={id:"",type:"table"},y=Iw(r||b),g=(j=r==null?void 0:r.preferences)==null?void 0:j.tablePrefs,x=r?(y==null?void 0:y.data)||o:null,v=Kg(r||b,x),w=(r==null?void 0:r.title)||"Visual Report",C=S9(m||[]),S=()=>{p(_=>({..._,pdfPassword:"",protectPdf:!1})),f(!1),t()},N=async()=>{var A,$,H,U,B,P;if(!r){Le.error("No card selected");return}const _=(y==null?void 0:y.data)||o;if(!_){Le.error("No data to export");return}const M=(()=>{var L,D;if(!r||!["table","aggregateTable","pivotTable"].includes(r.type))return 0;if(r.type==="pivotTable"){const W=Array.isArray(_==null?void 0:_.records)?_==null?void 0:_.records:Array.isArray(_)?_:[];return W.length>0?W.length:(L=v==null?void 0:v.data)!=null&&L.rowData&&v.data.rowData.length>0?v.data.rowData.length:((D=x==null?void 0:x.records)==null?void 0:D.length)||0}return(Array.isArray(_==null?void 0:_.records)?_==null?void 0:_.records:Array.isArray(_)?_:[]).length})();let T=null;if(r.type==="table"){const z=Array.isArray(_)?_:Array.isArray(_==null?void 0:_.records)?_.records:[];z.length>0&&(T=m1e({records:z,tablePreferences:g}))}else if(r.type==="aggregateTable"){const z=Array.isArray(_)?_:Array.isArray(_==null?void 0:_.records)?_.records:[];if(z.length>0){const L=(_==null?void 0:_.groupByColumns)||((A=r.config)==null?void 0:A.groupByColumns)||[],D=(_==null?void 0:_.pivotSchema)||[];T=b1e({records:z,groupByColumns:L,pivotSchema:D,card:r,columnSettings:g==null?void 0:g.columnSettingsMap})}}else r.type==="pivotTable"&&v&&(T=y1e({pivotConfig:v,card:r,showRowTotals:($=v.options)==null?void 0:$.showRowTotals}));const I=(r?GB(r):"client")==="server";c(!0);try{if(h.format==="csv"){let z="";const L=`${w.replace(/[^a-z0-9]/gi,"_")}.csv`;if((r==null?void 0:r.type)&&["table","aggregateTable","pivotTable"].includes(r.type))switch(r.type){case"table":{const W=Array.isArray(_)?_:(_==null?void 0:_.records)||[];if(!W||W.length===0){Le.error("No data available to export");return}vfe(W,L,g,{delimiter:h.delimiter,includeHeaders:h.includeHeaders,useFormattedValues:!0}),Le.success("CSV exported successfully"),S();return}case"aggregateTable":{const W=Array.isArray(_)?_:(_==null?void 0:_.records)||[];if(!W||W.length===0){Le.error("No data available to export");return}const G=(_==null?void 0:_.groupByColumns)||((H=r.config)==null?void 0:H.groupByColumns)||[],Z=(_==null?void 0:_.pivotSchema)||[],V=Lj(W,G),F=zj(W),q=(B=(U=r==null?void 0:r.preferences)==null?void 0:U.tablePrefs)==null?void 0:B.columnSettingsMap,Y=C9(V,F,G,Z,r,q);if(!Y){Le.error("Failed to generate CSV content");return}lx(Y,L),Le.success("CSV exported successfully"),S();return}case"pivotTable":if(v){F9(v.data,r,L,{delimiter:h.delimiter,includeHeaders:h.includeHeaders,includeSubtotals:!0,includeGrandTotal:!0,showRowTotals:(P=v.options)==null?void 0:P.showRowTotals}),Le.success("CSV exported successfully"),t();return}else{Le.error("Unable to export pivot table data");return}default:throw new Error(`Unsupported table type: ${r.type}`)}else{const W=Array.isArray(_)?_:(_==null?void 0:_.records)||[];if(!W||W.length===0){Le.error("No data available to export");return}const G=Object.keys(W[0]),Z=F=>{if(F==null)return"";const q=String(F);return q.includes(h.delimiter)||q.includes('"')||q.includes(`
700
700
  `)||q.includes("\r")?`"${q.replace(/"/g,'""')}"`:q},V=[];h.includeHeaders&&V.push(G.map(Z).join(h.delimiter)),W.forEach(F=>{const q=G.map(Y=>Z(F[Y]));V.push(q.join(h.delimiter))}),z=V.join(`
701
701
  `)}if(!z){Le.error("Failed to generate CSV content");return}lx(z,L),Le.success("CSV exported successfully"),S()}else{if(h.protectPdf&&!h.pdfPassword){Le.error("Please enter a password to protect the PDF");return}const z=h.protectPdf?"Generating protected PDF... This may take up to 60 seconds depending on data size.":"Generating PDF... This may take up to 60 seconds depending on data size.";Le.info(z);const L={password:h.protectPdf?h.pdfPassword:void 0,pageSize:h.pageSize,orientation:h.orientation,filterLine:C,rowCount:M,tableStructure:T,filterValues:m};let D=!1;r.type&&["table","aggregateTable","pivotTable"].includes(r.type)&&M>0&&M<=bj&&!I&&!!T&&(D=await uue(s.apiServiceUrl,r.id,n.id,w,r.type,L)),D||await Vz(s.apiServiceUrl,r.id,n.id,w,r.type,h.protectPdf?h.pdfPassword:void 0,h.pageSize,h.orientation,C,m);const G=h.protectPdf?"Protected PDF downloaded successfully":"PDF downloaded successfully";Le.success(G),S()}}catch(z){console.error("Export error:",z),Le.error("Failed to export. Please try again.")}finally{c(!1)}};return d.jsx(ai,{open:e,onOpenChange:S,children:d.jsxs(Ms,{className:"sm:max-w-[425px]",children:[d.jsxs(Ds,{children:[d.jsxs(Ts,{children:["Export ",w]}),d.jsx(Qi,{children:"Choose your export format and settings"})]}),d.jsxs("div",{className:"space-y-4 py-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{children:"Export Format"}),d.jsxs(ti,{value:h.format,onValueChange:_=>p({...h,format:_}),children:[i.includes("pdf")&&d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Hn,{value:"pdf",id:"format-pdf"}),d.jsxs(de,{htmlFor:"format-pdf",className:"flex items-center cursor-pointer",children:[d.jsx(Go,{className:"mr-2 h-4 w-4"}),"PDF Document"]})]}),i.includes("csv")&&d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Hn,{value:"csv",id:"format-csv"}),d.jsxs(de,{htmlFor:"format-csv",className:"flex items-center cursor-pointer",children:[d.jsx(oL,{className:"mr-2 h-4 w-4"}),"CSV"]})]})]})]}),d.jsx(Vi,{}),h.format==="pdf"?d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"pageSize",children:"Page Size"}),d.jsxs(Tt,{value:h.pageSize,onValueChange:_=>p({...h,pageSize:_}),children:[d.jsx(jt,{id:"pageSize",children:d.jsx($t,{})}),d.jsxs(Rt,{children:[d.jsx(we,{value:"letter",children:'Letter (8.5" × 11")'}),d.jsx(we,{value:"a4",children:"A4 (210mm × 297mm)"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"orientation",children:"Orientation"}),d.jsxs(Tt,{value:h.orientation,onValueChange:_=>p({...h,orientation:_}),children:[d.jsx(jt,{id:"orientation",children:d.jsx($t,{})}),d.jsxs(Rt,{children:[d.jsx(we,{value:"portrait",children:"Portrait"}),d.jsx(we,{value:"landscape",children:"Landscape"})]})]})]}),d.jsx(Vi,{}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(hn,{id:"protect-pdf",checked:h.protectPdf,onCheckedChange:_=>{p({...h,protectPdf:_,pdfPassword:_?h.pdfPassword:""}),_||f(!1)}}),d.jsxs(de,{htmlFor:"protect-pdf",className:"text-sm font-normal cursor-pointer flex items-center",children:[d.jsx(cL,{className:"mr-2 h-3.5 w-3.5"}),"Password protect PDF"]})]}),h.protectPdf&&d.jsxs("div",{className:"space-y-2 ml-6",children:[d.jsx(de,{htmlFor:"pdf-password",className:"text-sm",children:"PDF Password"}),d.jsxs("div",{className:"relative",children:[d.jsx(Rr,{id:"pdf-password",type:u?"text":"password",value:h.pdfPassword,onChange:_=>p({...h,pdfPassword:_.target.value}),placeholder:"Enter password",className:"pr-10"}),d.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>f(!u),children:u?d.jsx(zv,{className:"h-4 w-4 text-muted-foreground"}):d.jsx(dh,{className:"h-4 w-4 text-muted-foreground"})})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will need this password to open the PDF"})]})]})]}):d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"delimiter",children:"Delimiter"}),d.jsxs(Tt,{value:h.delimiter,onValueChange:_=>p({...h,delimiter:_}),children:[d.jsx(jt,{id:"delimiter",children:d.jsx($t,{})}),d.jsxs(Rt,{children:[d.jsx(we,{value:",",children:"Comma (,)"}),d.jsx(we,{value:";",children:"Semicolon (;)"}),d.jsx(we,{value:" ",children:"Tab"})]})]})]}),d.jsx("div",{className:"space-y-2",children:d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(hn,{id:"include-headers",checked:h.includeHeaders,onCheckedChange:_=>p({...h,includeHeaders:_})}),d.jsx(de,{htmlFor:"include-headers",className:"text-sm font-normal cursor-pointer",children:"Include column headers"})]})})]})]}),d.jsxs(li,{children:[d.jsx(le,{variant:"outline",onClick:S,disabled:l,children:"Cancel"}),d.jsx(le,{onClick:N,disabled:l,children:l?d.jsxs(d.Fragment,{children:[d.jsx(Ns,{className:"mr-2 h-4 w-4 animate-spin"}),"Exporting..."]}):d.jsxs(d.Fragment,{children:[d.jsx($v,{className:"mr-2 h-4 w-4"}),"Export"]})})]})]})})}function v1e(e,t,n,r=!0,o,s=Intl.DateTimeFormat().resolvedOptions().timeZone){if(e.length===0)return"";const i=n,a=[];return r&&a.push(i.map(WO).join(",")),e.forEach(l=>{const c=i.map(u=>{const f=l[u],h=w1e(f,u,t[u],o,s);return WO(h)});a.push(c.join(","))}),a.join(`
702
702
  `)}function w1e(e,t,n,r,o){var s,i,a,l,c,u,f,h,p,m,b,y;if(e==null)return"";if(!n)return String(e);if(n.type==="number"&&typeof e=="number")try{return new Intl.NumberFormat(((s=n.numberFormat)==null?void 0:s.locale)||"en-US",{style:((i=n.numberFormat)==null?void 0:i.style)||"decimal",currency:((a=n.numberFormat)==null?void 0:a.style)==="currency"?((l=n.numberFormat)==null?void 0:l.currency)||"USD":void 0,minimumFractionDigits:((c=n.numberFormat)==null?void 0:c.minimumFractionDigits)??0,maximumFractionDigits:((u=n.numberFormat)==null?void 0:u.maximumFractionDigits)??2}).format(e)}catch{return e.toLocaleString()}else if(n.type==="date"&&e)try{if((f=n.dateFormat)!=null&&f.useRelativeTime)return Sw(String(e));{let g;((h=n.dateFormat)==null?void 0:h.timezone)==="auto"||!((p=n.dateFormat)!=null&&p.timezone)?g=r||o:g=n.dateFormat.timezone;const x=(m=n.dateFormat)!=null&&m.useCustomFormat?n.dateFormat.customFormat:((b=n.dateFormat)==null?void 0:b.format)||"MM/dd/yyyy";return Wg(String(e),x,g,((y=n.dateFormat)==null?void 0:y.sourceTimezone)||"auto")}}catch{return String(e)}else{if(n.type==="badge")return String(e);if(n.type==="progress"&&typeof e=="number")return`${Math.min(Math.max(0,e),100)}%`;if(n.type==="link")return String(e)}return String(e)}function WO(e){return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function S1e(e,t,n){const r=new Blob([e],{type:n}),o=URL.createObjectURL(r),s=document.createElement("a");s.href=o,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}function C1e(e,t,n,r="export.csv",o,s){const i=v1e(e,t,n,!0,o,s);S1e(i,r,"text/csv;charset=utf-8;")}function E1e(e,t){return k.useReducer((n,r)=>t[n][r]??n,e)}var ER="ScrollArea",[ZB,AXe]=mr(ER),[N1e,As]=ZB(ER),KB=k.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=k.useState(null),[c,u]=k.useState(null),[f,h]=k.useState(null),[p,m]=k.useState(null),[b,y]=k.useState(null),[g,x]=k.useState(0),[v,w]=k.useState(0),[C,S]=k.useState(!1),[N,j]=k.useState(!1),_=ot(t,M=>l(M)),R=Ku(o);return d.jsx(N1e,{scope:n,type:r,dir:R,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:u,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:C,onScrollbarXEnabledChange:S,scrollbarY:b,onScrollbarYChange:y,scrollbarYEnabled:N,onScrollbarYEnabledChange:j,onCornerWidthChange:x,onCornerHeightChange:w,children:d.jsx(Me.div,{dir:R,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":v+"px",...e.style}})})});KB.displayName=ER;var XB="ScrollAreaViewport",QB=k.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=As(XB,n),a=k.useRef(null),l=ot(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx(Me.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});QB.displayName=XB;var ia="ScrollAreaScrollbar",NR=k.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=As(ia,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return k.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(k1e,{...r,ref:t,forceMount:n}):o.type==="scroll"?d.jsx(_1e,{...r,ref:t,forceMount:n}):o.type==="auto"?d.jsx(JB,{...r,ref:t,forceMount:n}):o.type==="always"?d.jsx(kR,{...r,ref:t}):null});NR.displayName=ia;var k1e=k.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=As(ia,e.__scopeScrollArea),[s,i]=k.useState(!1);return k.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},u=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(Gn,{present:n||s,children:d.jsx(JB,{"data-state":s?"visible":"hidden",...r,ref:t})})}),_1e=k.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=As(ia,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Fw(()=>l("SCROLL_END"),100),[a,l]=E1e("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return k.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),k.useEffect(()=>{const c=o.viewport,u=s?"scrollLeft":"scrollTop";if(c){let f=c[u];const h=()=>{const p=c[u];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),d.jsx(Gn,{present:n||a!=="hidden",children:d.jsx(kR,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Se(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:Se(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),JB=k.forwardRef((e,t)=>{const n=As(ia,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=k.useState(!1),a=e.orientation==="horizontal",l=Fw(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:u)}},10);return Xf(n.viewport,l),Xf(n.content,l),d.jsx(Gn,{present:r||s,children:d.jsx(kR,{"data-state":s?"visible":"hidden",...o,ref:t})})}),kR=k.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=As(ia,e.__scopeScrollArea),s=k.useRef(null),i=k.useRef(0),[a,l]=k.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=oV(a.viewport,a.content),u={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return P1e(h,i.current,a,p)}return n==="horizontal"?d.jsx(j1e,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=qO(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?d.jsx(R1e,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=qO(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),j1e=k.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=As(ia,e.__scopeScrollArea),[i,a]=k.useState(),l=k.useRef(null),c=ot(t,l,s.onScrollbarXChange);return k.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(tV,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Ow(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),iV(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:zx(i.paddingLeft),paddingEnd:zx(i.paddingRight)}})}})}),R1e=k.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=As(ia,e.__scopeScrollArea),[i,a]=k.useState(),l=k.useRef(null),c=ot(t,l,s.onScrollbarYChange);return k.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(tV,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Ow(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),iV(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:zx(i.paddingTop),paddingEnd:zx(i.paddingBottom)}})}})}),[M1e,eV]=ZB(ia),tV=k.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:f,...h}=e,p=As(ia,n),[m,b]=k.useState(null),y=ot(t,_=>b(_)),g=k.useRef(null),x=k.useRef(""),v=p.viewport,w=r.content-r.viewport,C=ir(u),S=ir(l),N=Fw(f,10);function j(_){if(g.current){const R=_.clientX-g.current.left,M=_.clientY-g.current.top;c({x:R,y:M})}}return k.useEffect(()=>{const _=R=>{const M=R.target;(m==null?void 0:m.contains(M))&&C(R,w)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[v,m,w,C]),k.useEffect(S,[r,S]),Xf(m,N),Xf(p.content,N),d.jsx(M1e,{scope:n,scrollbar:m,hasThumb:o,onThumbChange:ir(s),onThumbPointerUp:ir(i),onThumbPositionChange:S,onThumbPointerDown:ir(a),children:d.jsx(Me.div,{...h,ref:y,style:{position:"absolute",...h.style},onPointerDown:Se(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),g.current=m.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(_))}),onPointerMove:Se(e.onPointerMove,j),onPointerUp:Se(e.onPointerUp,_=>{const R=_.target;R.hasPointerCapture(_.pointerId)&&R.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=x.current,p.viewport&&(p.viewport.style.scrollBehavior=""),g.current=null})})})}),Lx="ScrollAreaThumb",nV=k.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=eV(Lx,e.__scopeScrollArea);return d.jsx(Gn,{present:n||o.hasThumb,children:d.jsx(D1e,{ref:t,...r})})}),D1e=k.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=As(Lx,n),i=eV(Lx,n),{onThumbPositionChange:a}=i,l=ot(t,f=>i.onThumbChange(f)),c=k.useRef(void 0),u=Fw(()=>{c.current&&(c.current(),c.current=void 0)},100);return k.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(u(),!c.current){const p=A1e(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,u,a]),d.jsx(Me.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Se(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),m=f.clientX-p.left,b=f.clientY-p.top;i.onThumbPointerDown({x:m,y:b})}),onPointerUp:Se(e.onPointerUp,i.onThumbPointerUp)})});nV.displayName=Lx;var _R="ScrollAreaCorner",rV=k.forwardRef((e,t)=>{const n=As(_R,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?d.jsx(T1e,{...e,ref:t}):null});rV.displayName=_R;var T1e=k.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=As(_R,n),[s,i]=k.useState(0),[a,l]=k.useState(0),c=!!(s&&a);return Xf(o.scrollbarX,()=>{var f;const u=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),Xf(o.scrollbarY,()=>{var f;const u=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(u),i(u)}),c?d.jsx(Me.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function zx(e){return e?parseInt(e,10):0}function oV(e,t){const n=e/t;return isNaN(n)?0:n}function Ow(e){const t=oV(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function P1e(e,t,n,r="ltr"){const o=Ow(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,u=n.content-n.viewport,f=r==="ltr"?[0,u]:[u*-1,0];return sV([l,c],f)(e)}function qO(e,t,n="ltr"){const r=Ow(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=B2(e,l);return sV([0,i],[0,a])(c)}function sV(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function iV(e,t){return e>0&&e<t}var A1e=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Fw(e,t){const n=ir(e),r=k.useRef(0);return k.useEffect(()=>()=>window.clearTimeout(r.current),[]),k.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Xf(e,t){const n=ir(t);_r(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var $w=KB,aV=QB,lV=rV;const Wi=k.forwardRef(({className:e,children:t,...n},r)=>d.jsxs($w,{ref:r,className:K("relative overflow-hidden",e),...n,children:[d.jsx(aV,{className:"h-full w-full rounded-[inherit]",children:t}),d.jsx(Ga,{}),d.jsx(lV,{})]}));Wi.displayName=$w.displayName;const Ga=k.forwardRef(({className:e,orientation:t="vertical",...n},r)=>d.jsx(NR,{ref:r,orientation:t,className:K("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:d.jsx(nV,{className:"relative flex-1 rounded-full bg-border"})}));Ga.displayName=NR.displayName;const rd=k.forwardRef(({className:e,children:t,style:n,...r},o)=>d.jsxs($w,{style:n,className:K("relative overflow-hidden",e),children:[d.jsx(aV,{ref:o,...r,className:"h-full w-full rounded-[inherit]",children:t}),d.jsx(Ga,{}),d.jsx(lV,{})]}));rd.displayName=$w.displayName;/**
@@ -927,7 +927,7 @@ prismjs/prism.js:
927
927
  `))+1))}const i="#".repeat(o),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(i+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
928
928
  `,...s.current()});return/^[\t ]/.test(c)&&(c=fg(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),a(),c}IK.peek=G7e;function IK(e){return e.value||""}function G7e(){return"<"}OK.peek=Y7e;function OK(e,t,n,r){const o=PD(n),s=o==='"'?"Quote":"Apostrophe",i=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+o),c+=l.move(n.safe(e.title,{before:c,after:o,...l.current()})),c+=l.move(o),a()),c+=l.move(")"),i(),c}function Y7e(){return"!"}FK.peek=Z7e;function FK(e,t,n,r){const o=e.referenceType,s=n.enter("imageReference");let i=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const c=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return i(),n.stack=u,s(),o==="full"||!c||c!==f?l+=a.move(f+"]"):o==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Z7e(){return"!"}$K.peek=K7e;function $K(e,t,n){let r=e.value||"",o="`",s=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(r);)o+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const i=n.unsafe[s],a=n.compilePattern(i);let l;if(i.atBreak)for(;l=a.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return o+r+o}function K7e(){return"`"}function LK(e,t){const n=CD(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}zK.peek=X7e;function zK(e,t,n,r){const o=PD(n),s=o==='"'?"Quote":"Apostrophe",i=n.createTracker(r);let a,l;if(LK(e,n)){const u=n.stack;n.stack=[],a=n.enter("autolink");let f=i.move("<");return f+=i.move(n.containerPhrasing(e,{before:f,after:">",...i.current()})),f+=i.move(">"),a(),n.stack=u,f}a=n.enter("link"),l=n.enter("label");let c=i.move("[");return c+=i.move(n.containerPhrasing(e,{before:c,after:"](",...i.current()})),c+=i.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=i.move("<"),c+=i.move(n.safe(e.url,{before:c,after:">",...i.current()})),c+=i.move(">")):(l=n.enter("destinationRaw"),c+=i.move(n.safe(e.url,{before:c,after:e.title?" ":")",...i.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=i.move(" "+o),c+=i.move(n.safe(e.title,{before:c,after:o,...i.current()})),c+=i.move(o),l()),c+=i.move(")"),a(),c}function X7e(e,t,n){return LK(e,n)?"<":"["}BK.peek=Q7e;function BK(e,t,n,r){const o=e.referenceType,s=n.enter("linkReference");let i=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return i(),n.stack=u,s(),o==="full"||!c||c!==f?l+=a.move(f+"]"):o==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Q7e(){return"["}function AD(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function J7e(e){const t=AD(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function eBe(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function VK(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function tBe(e,t,n,r){const o=n.enter("list"),s=n.bulletCurrent;let i=e.ordered?eBe(n):AD(n);const a=e.ordered?i==="."?")":".":J7e(n);let l=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const u=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),VK(n)===i&&u){let f=-1;for(;++f<e.children.length;){const h=e.children[f];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(i=a),n.bulletCurrent=i;const c=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=s,o(),c}function nBe(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function rBe(e,t,n,r){const o=nBe(n);let s=n.bulletCurrent||AD(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let i=s.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(i-s.length)),a.shift(i);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,a.current()),u);return l(),c;function u(f,h,p){return h?(p?"":" ".repeat(i))+f:(p?s:s+" ".repeat(i-s.length))+f}}function oBe(e,t,n,r){const o=n.enter("paragraph"),s=n.enter("phrasing"),i=n.containerPhrasing(e,r);return s(),o(),i}const sBe=L1(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function iBe(e,t,n,r){return(e.children.some(function(i){return sBe(i)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function aBe(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}HK.peek=lBe;function HK(e,t,n,r){const o=aBe(n),s=n.enter("strong"),i=n.createTracker(r),a=i.move(o+o);let l=i.move(n.containerPhrasing(e,{after:o,before:a,...i.current()}));const c=l.charCodeAt(0),u=bv(r.before.charCodeAt(r.before.length-1),c,o);u.inside&&(l=fg(c)+l.slice(1));const f=l.charCodeAt(l.length-1),h=bv(r.after.charCodeAt(0),f,o);h.inside&&(l=l.slice(0,-1)+fg(f));const p=i.move(o+o);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},a+l+p}function lBe(e,t,n){return n.options.strong||"*"}function cBe(e,t,n,r){return n.safe(e.value,r)}function uBe(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function dBe(e,t,n){const r=(VK(n)+(n.options.ruleSpaces?" ":"")).repeat(uBe(n));return n.options.ruleSpaces?r.slice(0,-1):r}const UK={blockquote:A7e,break:A4,code:z7e,definition:V7e,emphasis:AK,hardBreak:A4,heading:q7e,html:IK,image:OK,imageReference:FK,inlineCode:$K,link:zK,linkReference:BK,list:tBe,listItem:rBe,paragraph:oBe,root:iBe,strong:HK,text:cBe,thematicBreak:dBe};function fBe(){return{enter:{table:hBe,tableData:I4,tableHeader:I4,tableRow:mBe},exit:{codeText:gBe,table:pBe,tableData:RE,tableHeader:RE,tableRow:RE}}}function hBe(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function pBe(e){this.exit(e),this.data.inTable=void 0}function mBe(e){this.enter({type:"tableRow",children:[]},e)}function RE(e){this.exit(e)}function I4(e){this.enter({type:"tableCell",children:[]},e)}function gBe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,bBe));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function bBe(e,t){return t==="|"?t:e}function yBe(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,o=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
929
929
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:i,tableCell:l,tableRow:a}};function i(p,m,b,y){return c(u(p,b,y),p.align)}function a(p,m,b,y){const g=f(p,b,y),x=c([g]);return x.slice(0,x.indexOf(`
930
- `))}function l(p,m,b,y){const g=b.enter("tableCell"),x=b.enter("phrasing"),v=b.containerPhrasing(p,{...y,before:s,after:s});return x(),g(),v}function c(p,m){return T7e(p,{align:m,alignDelimiters:r,padding:n,stringLength:o})}function u(p,m,b){const y=p.children;let g=-1;const x=[],v=m.enter("table");for(;++g<y.length;)x[g]=f(y[g],m,b);return v(),x}function f(p,m,b){const y=p.children;let g=-1;const x=[],v=m.enter("tableRow");for(;++g<y.length;)x[g]=l(y[g],p,m,b);return v(),x}function h(p,m,b){let y=UK.inlineCode(p,m,b);return b.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function xBe(){return{exit:{taskListCheckValueChecked:O4,taskListCheckValueUnchecked:O4,paragraph:wBe}}}function vBe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:SBe}}}function O4(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function wBe(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const o=t.children;let s=-1,i;for(;++s<o.length;){const a=o[s];if(a.type==="paragraph"){i=a;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function SBe(e,t,n,r){const o=e.children[0],s=typeof e.checked=="boolean"&&o&&o.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(i);let l=UK.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+i}}function CBe(){return[t7e(),S7e(),k7e(),fBe(),xBe()]}function EBe(e){return{extensions:[n7e(),C7e(e),_7e(),yBe(e),vBe()]}}const NBe={tokenize:DBe,partial:!0},WK={tokenize:TBe,partial:!0},qK={tokenize:PBe,partial:!0},GK={tokenize:ABe,partial:!0},kBe={tokenize:IBe,partial:!0},YK={name:"wwwAutolink",tokenize:RBe,previous:KK},ZK={name:"protocolAutolink",tokenize:MBe,previous:XK},el={name:"emailAutolink",tokenize:jBe,previous:QK},la={};function _Be(){return{text:la}}let Nc=48;for(;Nc<123;)la[Nc]=el,Nc++,Nc===58?Nc=65:Nc===91&&(Nc=97);la[43]=el;la[45]=el;la[46]=el;la[95]=el;la[72]=[el,ZK];la[104]=[el,ZK];la[87]=[el,YK];la[119]=[el,YK];function jBe(e,t,n){const r=this;let o,s;return i;function i(f){return!Fk(f)||!QK.call(r,r.previous)||ID(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(f))}function a(f){return Fk(f)?(e.consume(f),a):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(kBe,u,c)(f):f===45||f===95||Ur(f)?(s=!0,e.consume(f),l):u(f)}function c(f){return e.consume(f),o=!0,l}function u(f){return s&&o&&oo(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function RBe(e,t,n){const r=this;return o;function o(i){return i!==87&&i!==119||!KK.call(r,r.previous)||ID(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(NBe,e.attempt(WK,e.attempt(qK,s),n),n)(i))}function s(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function MBe(e,t,n){const r=this;let o="",s=!1;return i;function i(f){return(f===72||f===104)&&XK.call(r,r.previous)&&!ID(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(f),e.consume(f),a):n(f)}function a(f){if(oo(f)&&o.length<5)return o+=String.fromCodePoint(f),e.consume(f),a;if(f===58){const h=o.toLowerCase();if(h==="http"||h==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),s?c:(s=!0,l)):n(f)}function c(f){return f===null||hv(f)||pn(f)||Uu(f)||O1(f)?n(f):e.attempt(WK,e.attempt(qK,u),n)(f)}function u(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function DBe(e,t,n){let r=0;return o;function o(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),o):i===46&&r===3?(e.consume(i),s):n(i)}function s(i){return i===null?n(i):t(i)}}function TBe(e,t,n){let r,o,s;return i;function i(c){return c===46||c===95?e.check(GK,l,a)(c):c===null||pn(c)||Uu(c)||c!==45&&O1(c)?l(c):(s=!0,e.consume(c),i)}function a(c){return c===95?r=!0:(o=r,r=void 0),e.consume(c),i}function l(c){return o||r||!s?n(c):t(c)}}function PBe(e,t){let n=0,r=0;return o;function o(i){return i===40?(n++,e.consume(i),o):i===41&&r<n?s(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(GK,t,s)(i):i===null||pn(i)||Uu(i)?t(i):(e.consume(i),o)}function s(i){return i===41&&r++,e.consume(i),o}}function ABe(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),o):a===60||a===null||pn(a)||Uu(a)?t(a):n(a)}function o(a){return a===null||a===40||a===91||pn(a)||Uu(a)?t(a):r(a)}function s(a){return oo(a)?i(a):n(a)}function i(a){return a===59?(e.consume(a),r):oo(a)?(e.consume(a),i):n(a)}}function IBe(e,t,n){return r;function r(s){return e.consume(s),o}function o(s){return Ur(s)?n(s):t(s)}}function KK(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||pn(e)}function XK(e){return!oo(e)}function QK(e){return!(e===47||Fk(e))}function Fk(e){return e===43||e===45||e===46||e===95||Ur(e)}function ID(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const OBe={tokenize:UBe,partial:!0};function FBe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:BBe,continuation:{tokenize:VBe},exit:HBe}},text:{91:{name:"gfmFootnoteCall",tokenize:zBe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:$Be,resolveTo:LBe}}}}function $Be(e,t,n){const r=this;let o=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;o--;){const l=r.events[o][1];if(l.type==="labelImage"){i=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!i||!i._balanced)return n(l);const c=Qs(r.sliceSerialize({start:i.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function LBe(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function zBe(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,i;return a;function a(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(f){if(s>999||f===93&&!i||f===null||f===91||pn(f))return n(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return o.includes(Qs(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return pn(f)||(i=!0),s++,e.consume(f),f===92?u:c}function u(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function BBe(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,i=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(m)}function u(m){if(i>999||m===93&&!a||m===null||m===91||pn(m))return n(m);if(m===93){e.exit("chunkString");const b=e.exit("gfmFootnoteDefinitionLabelString");return s=Qs(r.sliceSerialize(b)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return pn(m)||(a=!0),i++,e.consume(m),m===92?f:u}function f(m){return m===91||m===92||m===93?(e.consume(m),i++,u):u(m)}function h(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),o.includes(s)||o.push(s),zt(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function VBe(e,t,n){return e.check(Rb,t,e.attempt(OBe,t,n))}function HBe(e){e.exit("gfmFootnoteDefinition")}function UBe(e,t,n){const r=this;return zt(e,o,"gfmFootnoteDefinitionIndent",5);function o(s){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(s):n(s)}}function WBe(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:o};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(i,a){let l=-1;for(;++l<i.length;)if(i[l][0]==="enter"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._close){let c=l;for(;c--;)if(i[c][0]==="exit"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._open&&i[l][1].end.offset-i[l][1].start.offset===i[c][1].end.offset-i[c][1].start.offset){i[l][1].type="strikethroughSequence",i[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[l][1].end)},f={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[l][1].start)},h=[["enter",u,a],["enter",i[c][1],a],["exit",i[c][1],a],["enter",f,a]],p=a.parser.constructs.insideSpan.null;p&&Uo(h,h.length,0,F1(p,i.slice(c+1,l),a)),Uo(h,h.length,0,[["exit",f,a],["enter",i[l][1],a],["exit",i[l][1],a],["exit",u,a]]),Uo(i,c-1,l-c+3,h),l=c+h.length-2;break}}for(l=-1;++l<i.length;)i[l][1].type==="strikethroughSequenceTemporary"&&(i[l][1].type="data");return i}function s(i,a,l){const c=this.previous,u=this.events;let f=0;return h;function h(m){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(m):(i.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const b=sh(c);if(m===126)return f>1?l(m):(i.consume(m),f++,p);if(f<2&&!n)return l(m);const y=i.exit("strikethroughSequenceTemporary"),g=sh(m);return y._open=!g||g===2&&!!b,y._close=!b||b===2&&!!g,a(m)}}}class qBe{constructor(){this.map=[]}add(t,n,r){GBe(this,t,n,r)}consume(t){if(this.map.sort(function(s,i){return s[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const s of o)t.push(s);o=r.pop()}this.map.length=0}}function GBe(e,t,n,r){let o=0;if(!(n===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...r);return}o+=1}e.map.push([t,n,r])}}function YBe(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function ZBe(){return{flow:{null:{name:"table",tokenize:KBe,resolveAll:XBe}}}}function KBe(e,t,n){const r=this;let o=0,s=0,i;return a;function a(R){let M=r.events.length-1;for(;M>-1;){const I=r.events[M][1].type;if(I==="lineEnding"||I==="linePrefix")M--;else break}const T=M>-1?r.events[M][1].type:null,O=T==="tableHead"||T==="tableRow"?S:l;return O===S&&r.parser.lazy[r.now().line]?n(R):O(R)}function l(R){return e.enter("tableHead"),e.enter("tableRow"),c(R)}function c(R){return R===124||(i=!0,s+=1),u(R)}function u(R){return R===null?n(R):qe(R)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),p):n(R):kt(R)?zt(e,u,"whitespace")(R):(s+=1,i&&(i=!1,o+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),i=!0,u):(e.enter("data"),f(R)))}function f(R){return R===null||R===124||pn(R)?(e.exit("data"),u(R)):(e.consume(R),R===92?h:f)}function h(R){return R===92||R===124?(e.consume(R),f):f(R)}function p(R){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(R):(e.enter("tableDelimiterRow"),i=!1,kt(R)?zt(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):m(R))}function m(R){return R===45||R===58?y(R):R===124?(i=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),b):C(R)}function b(R){return kt(R)?zt(e,y,"whitespace")(R):y(R)}function y(R){return R===58?(s+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),g):R===45?(s+=1,g(R)):R===null||qe(R)?w(R):C(R)}function g(R){return R===45?(e.enter("tableDelimiterFiller"),x(R)):C(R)}function x(R){return R===45?(e.consume(R),x):R===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(R))}function v(R){return kt(R)?zt(e,w,"whitespace")(R):w(R)}function w(R){return R===124?m(R):R===null||qe(R)?!i||o!==s?C(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(R)):C(R)}function C(R){return n(R)}function S(R){return e.enter("tableRow"),N(R)}function N(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),N):R===null||qe(R)?(e.exit("tableRow"),t(R)):kt(R)?zt(e,N,"whitespace")(R):(e.enter("data"),j(R))}function j(R){return R===null||R===124||pn(R)?(e.exit("data"),N(R)):(e.consume(R),R===92?_:j)}function _(R){return R===92||R===124?(e.consume(R),j):j(R)}}function XBe(e,t){let n=-1,r=!0,o=0,s=[0,0,0,0],i=[0,0,0,0],a=!1,l=0,c,u,f;const h=new qBe;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(F4(h,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],i=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",u,t]])),o=m.type==="tableDelimiterRow"?2:u?3:1):o&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(s[1]!==0&&(i[0]=i[1],f=r0(h,t,s,o,void 0,f),s=[0,0,0,0]),i[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(i[0]=i[1],f=r0(h,t,s,o,void 0,f)),s=i,i=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(i[0]=i[1],f=r0(h,t,s,o,n,f)):i[1]!==0&&(f=r0(h,t,i,o,n,f)),o=0):o&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(i[3]=n)}for(l!==0&&F4(h,t,l,c,u),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=YBe(t.events,n))}return e}function r0(e,t,n,r,o,s){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Od(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Od(t.events,n[1]);if(s={type:i,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Od(t.events,n[2]),u=Od(t.events,n[3]),f={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,b=n[3]-n[2]-1;e.add(m,b,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return o!==void 0&&(s.end=Object.assign({},Od(t.events,o)),e.add(o,0,[["exit",s,t]]),s=void 0),s}function F4(e,t,n,r,o){const s=[],i=Od(t.events,n);o&&(o.end=Object.assign({},i),s.push(["exit",o,t])),r.end=Object.assign({},i),s.push(["exit",r,t]),e.add(n+1,0,s)}function Od(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const QBe={name:"tasklistCheck",tokenize:eVe};function JBe(){return{text:{91:QBe}}}function eVe(e,t,n){const r=this;return o;function o(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return pn(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),i):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),i):n(l)}function i(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return qe(l)?t(l):kt(l)?e.check({tokenize:tVe},t,n)(l):n(l)}}function tVe(e,t,n){return zt(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function nVe(e){return oK([_Be(),FBe(),WBe(e),ZBe(),JBe()])}const rVe={};function oVe(e){const t=this,n=e||rVe,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(nVe(n)),s.push(CBe()),i.push(EBe(n))}const Dl=E.forwardRef(({children:e,className:t,tooltip:n,onClick:r,openDelay:o=300,buttonProps:s,disabled:i,...a},l)=>d.jsx(Ya,{children:d.jsxs(Xo,{delayDuration:o,children:[d.jsx(Qo,{asChild:!0,children:d.jsx(le,{disabled:i,ref:l,size:"sm",variant:"ghost",onClick:r,...a,...s,className:K(`${Jd}`,t),children:e})}),n&&d.jsx(js,{side:"bottom",sideOffset:10,children:n})]})}));Dl.displayName="IconButton";var OD="Collapsible",[sVe,JK]=mr(OD),[iVe,FD]=sVe(OD),eX=k.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l=!1,c]=jr({prop:r,defaultProp:o,onChange:i});return d.jsx(iVe,{scope:n,disabled:s,contentId:qn(),open:l,onOpenToggle:k.useCallback(()=>c(u=>!u),[c]),children:d.jsx(Me.div,{"data-state":BD(l),"data-disabled":s?"":void 0,...a,ref:t})})});eX.displayName=OD;var tX="CollapsibleTrigger",$D=k.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=FD(tX,n);return d.jsx(Me.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":BD(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:Se(e.onClick,o.onOpenToggle)})});$D.displayName=tX;var LD="CollapsibleContent",zD=k.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=FD(LD,e.__scopeCollapsible);return d.jsx(Gn,{present:n||o.open,children:({present:s})=>d.jsx(aVe,{...r,ref:t,present:s})})});zD.displayName=LD;var aVe=k.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=FD(LD,n),[a,l]=k.useState(r),c=k.useRef(null),u=ot(t,c),f=k.useRef(0),h=f.current,p=k.useRef(0),m=p.current,b=i.open||a,y=k.useRef(b),g=k.useRef(void 0);return k.useEffect(()=>{const x=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(x)},[]),_r(()=>{const x=c.current;if(x){g.current=g.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const v=x.getBoundingClientRect();f.current=v.height,p.current=v.width,y.current||(x.style.transitionDuration=g.current.transitionDuration,x.style.animationName=g.current.animationName),l(r)}},[i.open,r]),d.jsx(Me.div,{"data-state":BD(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...s,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:b&&o})});function BD(e){return e?"open":"closed"}var nX=eX,lVe=$D,cVe=zD;const ih=nX,ah=$D,lh=zD;function rX(){const{authToken:e,tokenProps:t}=Ue(),{currentUser:n}=Xi(),r=Ki({mutationFn:async o=>{if(!(e!=null&&e.accessToken))throw new Error("No authentication token available");const i=`${t.apiServiceUrl||""}/v1/feedback`,a={...o,user:n,tokenContext:t},l=await nc(i,e.accessToken,a,"POST");if(!l||!l.success)throw new Error((l==null?void 0:l.error)||"Failed to send feedback");return l},onSuccess:o=>{Le.success(`Feedback sent successfully! Issue: ${o.issueNumber}`,{duration:5e3})},onError:o=>{console.error("Feedback submission error:",o),Le.error("Failed to send feedback. Please try again later.",{duration:5e3})}});return{sendFeedback:r.mutate,sendFeedbackAsync:r.mutateAsync,isLoading:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,data:r.data,reset:r.reset}}function H1(e,t,n){return{category:e,userMessage:n,systemState:t,metadata:{url:window.location.href,userAgent:navigator.userAgent,timestamp:new Date().toISOString(),viewport:`${window.innerWidth}x${window.innerHeight}`}}}function hg({open:e,onOpenChange:t,feedbackData:n,onSuccess:r,showDebugInfo:o=!1}){var g,x,v,w,C,S,N,j,_,R,M,T,O;const[s,i]=E.useState(""),[a,l]=E.useState(!1),{sendFeedback:c,isLoading:u,isSuccess:f,data:h,reset:p}=rX();E.useEffect(()=>{f&&r&&r()},[f,r]);const m=()=>{const I={...n,userMessage:s.trim()||void 0};c(I)},b=()=>{i(""),l(!1),p(),t(!1)},y={category:n.category,error:{message:(g=n.systemState)==null?void 0:g.errorMessage,sql:(x=n.systemState)==null?void 0:x.generatedSql,errorSql:(v=n.systemState)==null?void 0:v.errorSql},assistantType:(w=n.systemState)==null?void 0:w.assistantType,toolType:(C=n.systemState)==null?void 0:C.toolType,userQuery:(S=n.systemState)==null?void 0:S.userQuery,messages:(N=n.systemState)==null?void 0:N.messages,aiContext:(j=n.systemState)==null?void 0:j.aiContext,toolInput:(_=n.systemState)==null?void 0:_.toolInput,toolOutput:(R=n.systemState)==null?void 0:R.toolOutput,cardConfig:(M=n.systemState)==null?void 0:M.cardConfig,dataSource:(T=n.systemState)==null?void 0:T.dataSource,filters:(O=n.systemState)==null?void 0:O.dashboardFilters,metadata:n.metadata};return d.jsx(ai,{open:e,onOpenChange:b,children:d.jsxs(Ms,{className:"max-w-2xl",children:[d.jsxs(Ds,{children:[d.jsx(Ts,{children:f?"Feedback Sent Successfully":n.category==="dashboard-assistant"||n.category==="editor-assistant"?"Report an issue":"Report Query Generation Issue"}),d.jsx(Qi,{children:f?`Your feedback has been submitted with issue number: ${h==null?void 0:h.issueNumber}`:n.category==="dashboard-assistant"||n.category==="editor-assistant"?"Help us improve the AI responses. Your feedback will be sent to our support team.":"Help us improve by reporting this query generation issue. Your feedback will be sent to our support team."})]}),!f&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"message",children:"Additional Information (Optional)"}),d.jsx(ph,{id:"message",placeholder:"Please describe what you were trying to do when this error occurred...",value:s,onChange:I=>i(I.target.value),className:"min-h-[100px] resize-none ring-inset focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",disabled:u})]}),o&&d.jsxs(ih,{open:a,onOpenChange:l,children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(ah,{asChild:!0,children:d.jsxs(le,{variant:"ghost",size:"sm",className:"flex flex-1 items-center justify-between p-2 hover:bg-muted",children:[d.jsx("span",{className:"text-sm font-medium",children:"View data to be sent"}),a?d.jsx(Eo,{className:"h-4 w-4"}):d.jsx(Js,{className:"h-4 w-4"})]})}),d.jsx(rh,{text:JSON.stringify(y,null,2),className:"h-8 w-8 shrink-0"})]}),d.jsx(lh,{className:"mt-2",children:d.jsx(Wi,{className:"h-[300px] w-full rounded-md border bg-muted/50 p-4",children:d.jsx("div",{className:"text-xs overflow-auto break-all whitespace-pre-wrap",children:d.jsx(Fl,{code:JSON.stringify(y,null,2),language:"json"})})})})]})]}),d.jsxs(li,{children:[d.jsx(le,{variant:"outline",onClick:b,disabled:u,children:"Cancel"}),d.jsx(le,{onClick:m,disabled:u,className:"min-w-[100px]",children:u?d.jsxs(d.Fragment,{children:[d.jsx(Ns,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Feedback"})]})]}),f&&d.jsxs("div",{className:"flex flex-col items-center space-y-4 py-6",children:[d.jsx(jne,{className:"h-12 w-12 text-green-600"}),d.jsxs("div",{className:"text-center",children:[d.jsx("p",{className:"text-lg font-medium",children:"Thank you for your feedback!"}),d.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Issue Number:"," ",d.jsx("span",{className:"font-mono font-medium",children:h==null?void 0:h.issueNumber})]}),d.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Our support team will review your feedback and take appropriate action."})]}),d.jsx(le,{onClick:b,className:"mt-4",children:"Close"})]})]})})}var Xl=(e=>(e.QUERY_GENERATION="query-generation",e.DASHBOARD_ASSISTANT="dashboard-assistant",e.EDITOR_ASSISTANT="editor-assistant",e))(Xl||{});function uVe(e,t){var r;if(!e||e.length===0)return"";const n=e.findIndex(o=>o.id===t);if(n===-1)return"";for(let o=n-1;o>=0;o--)if(e[o].role==="user"){const s=(r=e[o].parts)==null?void 0:r.find(i=>i.type==="text");return(s==null?void 0:s.text)||""}return""}function dVe({messageId:e,messageText:t,messages:n,className:r}){const[o,s]=E.useState("none"),[i,a]=E.useState(!1),[l,c]=E.useState(null),u=F_(),f=mh(),{isLoading:h}=rX(),{isLocalDev:p,isConsoleMode:m}=xb(),b=async()=>{if(o==="positive"){s("none"),Le.info("Feedback removed");return}s("positive"),Le.success("Thank you for your feedback!")},y=()=>{const v=uVe(n,e),w=u==="dashboard"?Xl.DASHBOARD_ASSISTANT:Xl.EDITOR_ASSISTANT,C=H1(w,{assistantType:u,userQuery:v,messages:n,aiContext:f,messageId:e,feedbackType:"negative",assistantResponse:t});c(C),a(!0)},g=v=>{a(v),v||c(null)},x=()=>{s("negative")};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:K("flex items-center gap-1",r),children:[d.jsx(Dl,{onClick:b,disabled:h,tooltip:o==="positive"?"Positive feedback given (click to undo)":"Helpful response",className:K("h-6 w-6 p-1",o==="positive"?"text-green-600 dark:text-green-500":"text-muted-foreground hover:text-foreground"),children:d.jsx(Vne,{className:K("h-3.5 w-3.5",o==="positive"&&"fill-current")})}),d.jsx(Dl,{onClick:y,disabled:h,tooltip:o==="negative"?"Negative feedback given (click to update)":"Report issue",className:K("h-6 w-6 p-1",o==="negative"?"text-red-600 dark:text-red-500":"text-muted-foreground hover:text-foreground"),children:d.jsx(Bne,{className:K("h-3.5 w-3.5",o==="negative"&&"fill-current")})})]}),l&&d.jsx(hg,{open:i,onOpenChange:g,feedbackData:l,onSuccess:x,showDebugInfo:m||p})]})}function $4({text:e,handleRun:t,className:n,messageId:r,messages:o}){const s=te(a=>a.themeStyle),i={p:({node:a,...l})=>d.jsx("p",{className:K("mb-4 text-sm leading-relaxed text-foreground/90",n),...l}),code:({node:a,...l})=>{var u,f;const c=(f=(u=a==null?void 0:a.children)==null?void 0:u[0])==null?void 0:f.value;return c&&/^#([0-9a-fA-F]{6})$/.test(c)?d.jsx("code",{className:K("rounded-lg bg-muted px-2.5 py-1.5 font-mono text-sm",n),style:{backgroundColor:c},...l}):d.jsx("code",{className:K("rounded-lg border border-border/50 bg-muted/50 px-2 py-1 font-mono text-xs text-foreground/80 transition-colors hover:bg-muted/70",n),...l})},pre:a=>d.jsx(Z9e,{...a,handleRun:t}),ul:({node:a,...l})=>d.jsx("ul",{className:K("mb-4 ml-6 list-disc space-y-2 text-sm marker:text-muted-foreground",n),...l}),ol:({node:a,...l})=>d.jsx("ol",{className:K("mb-4 ml-6 list-decimal space-y-2 text-sm marker:text-muted-foreground",n),...l}),li:({node:a,...l})=>d.jsx("li",{className:K("pl-2 leading-relaxed text-foreground/90",n),...l}),a:({node:a,...l})=>d.jsx("a",{target:"_blank",rel:"noopener noreferrer",className:K("text-blue-600 underline decoration-1 underline-offset-2 transition-all hover:text-blue-700 hover:decoration-2",n),...l}),h1:({node:a,...l})=>d.jsx("h1",{className:K("mb-4 mt-6 text-2xl font-semibold tracking-tight text-foreground",n),...l}),h2:({node:a,...l})=>d.jsx("h2",{className:K("mb-3 mt-5 text-xl font-semibold tracking-tight text-foreground",n),...l}),h3:({node:a,...l})=>d.jsx("h3",{className:K("mb-2 mt-4 text-lg font-medium text-foreground",n),...l}),h4:({node:a,...l})=>d.jsx("h4",{className:K("mb-2 mt-3 text-base font-medium text-foreground/90",n),...l}),strong:({node:a,...l})=>d.jsx("strong",{className:K("font-semibold text-foreground",n),...l}),blockquote:({node:a,...l})=>d.jsx("blockquote",{className:K("my-4 rounded-r-md border-l-4 border-muted-foreground/30 bg-muted/20 py-3 pl-4 pr-4 italic text-foreground/80",n),...l}),table:({node:a,...l})=>d.jsx("div",{className:"my-6 overflow-x-auto rounded-lg border border-border/50 shadow-sm",children:d.jsx("table",{className:K("w-full table-auto border-collapse text-sm",n),...l})}),thead:({node:a,...l})=>{var c,u,f,h,p,m;return d.jsx("thead",{style:{backgroundColor:(f=(u=(c=s==null?void 0:s.chart)==null?void 0:c.dataset)==null?void 0:u.backgroundColor)==null?void 0:f[0],color:Aa((m=(p=(h=s==null?void 0:s.chart)==null?void 0:h.dataset)==null?void 0:p.backgroundColor)==null?void 0:m[0])},className:"sticky top-0",...l})},tr:({node:a,...l})=>d.jsx("tr",{className:K("border-b border-border/30 transition-colors last:border-0 hover:bg-muted/30",n),...l}),th:({node:a,...l})=>d.jsx("th",{className:K("px-4 py-3 text-left text-sm font-medium tracking-wide",n),...l}),td:({node:a,...l})=>d.jsx("td",{className:K("px-4 py-3 align-top text-foreground/90",n),...l})};return d.jsxs("div",{className:"group relative pr-16",children:[d.jsx(z8e,{components:i,remarkPlugins:[oVe],children:e}),r&&d.jsx("div",{className:"absolute right-0 top-1 opacity-0 transition-opacity group-hover:opacity-100",children:d.jsx(dVe,{messageId:r,messageText:e,messages:o})})]})}const Wu=["image/png","image/jpeg","image/jpg","image/gif","image/webp"],fVe=["application/pdf","text/plain","text/markdown"],hVe=["text/csv","application/json","text/xml","application/xml"],pVe=["text/javascript","application/javascript","text/typescript","application/x-typescript","text/x-python","application/x-python-code","text/x-sql","application/sql"],mVe=[...Wu,...fVe,...hVe,...pVe],oX=10*1024*1024,xa=5,sX={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".txt":"text/plain",".md":"text/markdown",".csv":"text/csv",".json":"application/json",".xml":"text/xml",".js":"text/javascript",".jsx":"text/javascript",".ts":"text/typescript",".tsx":"text/typescript",".py":"text/x-python",".sql":"text/x-sql"};function gVe(e){if(mVe.includes(e.type))return!0;const t=VD(e.name);return t?Object.prototype.hasOwnProperty.call(sX,t):!1}function VD(e){const t=e.lastIndexOf(".");return t===-1?"":e.substring(t).toLowerCase()}function iX(e){if(e.type)return e.type;const t=VD(e.name);return sX[t]||"application/octet-stream"}function bVe(e){return e.size<=oX}function pg(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+n[r]}function L4(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const s=r.result.split(",")[1];t(s)},r.onerror=n,r.readAsDataURL(e)})}function yVe(e){return new Promise((t,n)=>{if(!Wu.includes(iX(e))){n(new Error("Not an image file"));return}const r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}async function HD(e){const t=iX(e),n=Wu.includes(t),r={id:crypto.randomUUID(),name:e.name,size:e.size,type:t};if(n)try{r.preview=await yVe(e),r.data=r.preview.split(",")[1]}catch(o){console.error("Failed to create image preview:",o),r.data=await L4(e)}else r.data=await L4(e);return r}function aX(e){const t=[],n=[];for(const r of e)gVe(r)?bVe(r)?t.push(r):n.push({file:r,error:`File too large: ${pg(r.size)} (max ${pg(oX)})`}):n.push({file:r,error:`File type not supported: ${r.type||VD(r.name)}`});return{valid:t,errors:n}}function xVe(e){var r;const t=(r=e.clipboardData)==null?void 0:r.items;if(!t)return[];const n=[];for(let o=0;o<t.length;o++){const s=t[o];if(s.kind==="file"){const i=s.getAsFile();i&&Wu.includes(i.type)&&n.push(i)}}return n}function vVe({files:e,onRemove:t,showRemove:n=!0,className:r=""}){if(e.length===0)return null;const o=s=>Wu.includes(s)?Tne:s.includes("pdf")||s.includes("text")?Go:s.includes("javascript")||s.includes("typescript")||s.includes("python")||s.includes("sql")?Dne:sL;return d.jsx("div",{className:`flex flex-wrap gap-2 ${r}`,children:e.map(s=>{const i=o(s.type),a=Wu.includes(s.type);return d.jsxs("div",{className:"group relative flex items-center gap-2 rounded-lg border border-border bg-muted/50 p-2 transition-colors hover:bg-muted",children:[a&&s.preview?d.jsx("div",{className:"relative h-12 w-12 overflow-hidden rounded",children:d.jsx("img",{src:s.preview,alt:s.name,className:"h-full w-full object-cover"})}):d.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded bg-background",children:d.jsx(i,{className:"h-6 w-6 text-muted-foreground"})}),d.jsxs("div",{className:"flex flex-col",children:[d.jsx("span",{className:"max-w-[150px] truncate text-xs font-medium",children:s.name}),d.jsx("span",{className:"text-xs text-muted-foreground",children:pg(s.size)}),s.uploadProgress!==void 0&&s.uploadProgress<100&&d.jsx(wM,{value:s.uploadProgress,className:"mt-1 h-1 w-full"})]}),n&&t&&d.jsx(le,{variant:"ghost",size:"icon",className:"absolute -right-2 -top-2 h-5 w-5 rounded-full bg-background opacity-0 shadow-sm transition-opacity group-hover:opacity-100",onClick:()=>t(s.id),children:d.jsx(ln,{className:"h-3 w-3"})})]},s.id)})})}function wVe({file:e,className:t=""}){return Wu.includes(e.type)&&e.preview?d.jsxs("div",{className:`inline-block ${t}`,children:[d.jsx("img",{src:e.preview,alt:e.name,className:"max-h-64 max-w-full rounded-lg border border-border"}),d.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.name," • ",pg(e.size)]})]}):d.jsxs("div",{className:`inline-flex items-center gap-2 rounded-lg border border-border bg-muted/50 px-3 py-2 ${t}`,children:[d.jsx(Go,{className:"h-4 w-4 text-muted-foreground"}),d.jsx("span",{className:"text-sm",children:e.name}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",pg(e.size),")"]})]})}const z4={"tool-getTableColumns":{"input-streaming":"Fetching table columns...","input-available":"Reading column definitions..."},"tool-getChartDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartDataFromCardConfig":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getForecastDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartSQLSyntax":{"input-streaming":"Generating SQL syntax...","input-available":"SQL syntax generated"},"tool-validateCardConfigFormat":{"input-streaming":"Validating card config format...","input-available":"Card config format validated"},"tool-generateQueryConfig":{"input-streaming":"Generating query config...","input-available":"Sending query config..."},"tool-askForMoreInfo":{"input-streaming":"Asking for more information...","input-available":"More information requested"},"tool-createChartFromSql":{"input-streaming":"Creating chart...","input-available":"Chart created"},"tool-getUserSql":{"input-streaming":"Getting SQL...","input-available":"SQL retrieved"},"tool-inspectTableData":{"input-streaming":"Inspecting table data...","input-available":"Analyzing data..."},"tool-getDomainRelationships":{"input-streaming":"Getting domain relationships...","input-available":"Analyzing data..."}};function lX(e,t){var r;if((r=z4[e])!=null&&r[t])return z4[e][t];const n=e.replace("tool-","").replace(/([A-Z])/g," $1").toLowerCase().trim();return t==="input-streaming"?`Processing ${n}...`:`Preparing ${n} response...`}function SVe({part:e,showTools:t}){if(!t)return null;const{input:n,output:r,...o}=e;return e.type,d.jsx("div",{className:"space-y-3",children:t&&d.jsxs(ih,{children:[d.jsxs("div",{className:"inline-flex items-center gap-2",children:[d.jsxs(ah,{className:"rounded-md border border-foreground/20 p-1 px-2 font-mono text-xs text-foreground/80 hover:bg-foreground/5",children:[d.jsx("span",{className:"font-bold",children:"Tool:"})," ",e.type.split("-")[1]]}),Pv]}),d.jsx(lh,{className:"mt-2 font-mono text-xs",children:d.jsxs("div",{className:"space-y-2 px-2",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{children:"Args:"}),d.jsx(Fl,{language:"json",code:JSON.stringify(o,null,2)})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{children:"Input:"}),d.jsx(Fl,{language:"json",code:JSON.stringify(n,null,2)})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{children:"Output:"}),d.jsx(Fl,{language:"json",code:JSON.stringify(r,null,2)})]})]})})]})})}function CVe({part:e,messages:t}){const[n,r]=E.useState(!1),[o,s]=E.useState(null),i=F_(),a=mh(),{tokenProps:l}=E.useContext(Mg);Xi();const c=()=>{var b;const u=t==null?void 0:t.filter(y=>y.role==="user").pop(),f=(b=u==null?void 0:u.parts)==null?void 0:b.find(y=>y.type==="text"),h=(f==null?void 0:f.text)||"",p=i==="dashboard"?Xl.DASHBOARD_ASSISTANT:Xl.EDITOR_ASSISTANT,m=H1(p,{errorMessage:e.errorText||"Tool invocation error occurred",toolType:e.type,toolInput:e.input,toolOutput:null,assistantType:i,userQuery:h,messages:t,aiContext:a});s(m),r(!0)};return d.jsxs(d.Fragment,{children:[d.jsxs(ih,{children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(ah,{className:"",children:d.jsxs(de,{className:"flex cursor-pointer items-center hover:text-foreground",children:[d.jsx(R_,{className:"mr-2 size-4 text-yellow-500"}),"Recovering from Error"]})}),d.jsxs(le,{variant:"ghost",size:"sm",className:"gap-1 text-[11px]",onClick:c,"aria-label":"Send feedback",children:[d.jsx(C_,{className:"h-3 w-3"}),"Send Feedback"]})]}),d.jsx(lh,{className:"mt-2 text-xs",children:d.jsxs("div",{className:"relative space-y-2 rounded-md border border-yellow-500 bg-yellow-50 p-4 text-black/80 dark:border-yellow-500/80 dark:bg-yellow-500/10 dark:text-white/80",children:[d.jsxs(de,{className:"text-xs",children:["Tool Invocation Error (",e.type.split("-")[1],")"]}),d.jsx("p",{children:e.errorText})]})})]}),o&&d.jsx(hg,{open:n,onOpenChange:u=>{r(u),u||s(null)},feedbackData:o})]})}var EVe=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,s;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(s=Object.keys(t),r=s.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=r;o--!==0;){var i=s[o];if(!(i==="_owner"&&t.$$typeof)&&!e(t[i],n[i]))return!1}return!0}return t!==t&&n!==n};const cX=tc(EVe);function o0(e,t=cX){const[n,r]=E.useState(()=>({value:e,lastInput:e}));if(!t(n.lastInput,e)){const o=t(n.value,e)?n.value:e;return r({value:o,lastInput:e}),o}return n.value}function NVe(e=[],t=[]){var r,o,s,i;if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;const n=Math.min(5,e.length);for(let a=0;a<n;a++)if(((r=e[a])==null?void 0:r.id)!==((o=t[a])==null?void 0:o.id))return!1;for(let a=0;a<n;a++){const l=e.length-1-a;if(((s=e[l])==null?void 0:s.id)!==((i=t[l])==null?void 0:i.id))return!1}return cX(e,t)}const U1={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]},B4=E.memo(({cfg:e,onDatapointClick:t})=>d.jsx(Kw,{cfg:e,onDatapointClick:t}),(e,t)=>JSON.stringify(e.cfg)===JSON.stringify(t.cfg)&&e.onDatapointClick===t.onDatapointClick),V4=E.memo(Gw,(e,t)=>{const n=e.data===t.data,r=e.card===t.card,o=e.isLoading===t.isLoading;return n&&r&&o});function kVe({part:e,onAddToDashboard:t,messages:n,showTools:r=!1}){var Z,V;const o=e.output,s=e.input,[i,a]=E.useState(!1),[l,c]=E.useState(!1),[u,f]=E.useState("visual"),[h,p]=E.useState(!1),[m,b]=E.useState(null),y=E.useMemo(()=>(e==null?void 0:e.toolCallId)??yr(),[e]),{queueMessage:g}=gh(),x=F_(),v=mh(),{tokenProps:w}=E.useContext(Mg),C=(w==null?void 0:w.type)==="dashboard";Xi();const S=()=>{const F=e.toolCallId;G().label;const q=`Can you explain how this visual was calculated? [ref: ${F}]`;g("dashboard",q)},N=()=>{var ne;const F=n==null?void 0:n.filter(se=>se.role==="user").pop(),q=(ne=F==null?void 0:F.parts)==null?void 0:ne.find(se=>se.type==="text"),Y=(q==null?void 0:q.text)||"",ee=x==="dashboard"?Xl.DASHBOARD_ASSISTANT:Xl.EDITOR_ASSISTANT,X=H1(ee,{errorMessage:(o==null?void 0:o.error)||"An error occurred while generating the visualization",toolType:e.type,toolInput:s,toolOutput:o,assistantType:x,userQuery:Y,messages:n,aiContext:v,cardConfig:s==null?void 0:s.cardConfig,dataSource:o==null?void 0:o.dataSource,generatedSql:s==null?void 0:s.sql});b(X),p(!0)},j=s==null?void 0:s.chartType,_=s==null?void 0:s.connectionId,R=s==null?void 0:s.cardConfig,M=s==null?void 0:s.chartTitle,T=s==null?void 0:s.sql,O=(Z=o==null?void 0:o.data)==null?void 0:Z.userSql,I=s==null?void 0:s.python,A=(V=o==null?void 0:o.data)==null?void 0:V.records,$=o==null?void 0:o.dataSource,H=o0(A??[],NVe),U=o0($),B=o0(R),P=o0(j),z=E.useMemo(()=>P?{id:y,config:B,type:P,dataSource:U,preferences:{tablePrefs:{pageSize:10}}}:null,[y,B,P,U]),L=E.useMemo(()=>!z||P==="pivotTable"?null:CR({card:z,cardType:P,data:H||[],queryConfig:{}}),[z,P,H]),D=E.useMemo(()=>{var X,ne,se,re;if(P!=="pivotTable"||!o)return null;const F=((X=o.data)==null?void 0:X.pivotSchema)||[],q=((ne=o.data)==null?void 0:ne.subtotalColumns)||[],Y=(se=o.data)==null?void 0:se.columnSubtotalMeta,ee=(re=o.data)==null?void 0:re.groupByColumns;return{records:H||[],pivotSchema:F,subtotalColumns:q,columnSubtotalMeta:Y,groupByColumns:ee}},[P,o,H]),W=Kg(z,D),G=()=>{const F=z?zl(z.config):!1,q=Jw.find(ee=>ee.id===P),Y=q==null?void 0:q.icon;return I?{type:"advanced",label:"Advanced Analysis",icons:[iu,JT]}:F&&Y?{type:"standard",label:"Standard Analysis",icons:[Y]}:{type:"sql",label:"SQL Analysis",icons:[iu]}};if(!o)return null;if(o.error){const F=o.errorType||"unknown",q=o.hint||"",Y=o.rootCause||o.error,ee=o.shouldRetry!==!1,X=o.validationErrors||[],ne=o.suggestions||[],se=X.length>0,re=se?{border:"border-purple-500/60 dark:border-purple-500/50",bg:"bg-purple-50 dark:bg-purple-500/10",text:"text-purple-800 dark:text-purple-300",iconColor:"text-purple-600 dark:text-purple-500",accentBg:"bg-purple-100 dark:bg-purple-900/30",accentText:"text-purple-900 dark:text-purple-200"}:{border:"border-yellow-500/60 dark:border-yellow-500/50",bg:"bg-yellow-50 dark:bg-yellow-500/10",text:"text-yellow-800 dark:text-yellow-300",iconColor:"text-yellow-600 dark:text-yellow-500",accentBg:"bg-yellow-100 dark:bg-yellow-900/30",accentText:"text-yellow-900 dark:text-yellow-200"},ie=()=>se?ee?"Configuration validation failed. Retrying...":"Configuration validation failed":F==="group_by_error"?ee?"SQL grouping error. Retrying...":"SQL grouping error":F==="syntax_error"?ee?"SQL syntax error. Retrying...":"SQL syntax error":F==="type_mismatch"?ee?"Data type mismatch. Retrying...":"Data type mismatch":ee?"Retrying...":"Couldn't generate this visual";if(!r){const be=ee?"Let me try that a different way...":"I'm ready with a revised plan.",ue=q||(Y&&Y!==o.error?Y:"");return d.jsx("div",{className:"mt-2 rounded-md border border-border/40 bg-muted/30 p-3 text-xs",children:d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx(k_,{className:"size-4 shrink-0 text-primary","aria-hidden":"true"}),d.jsxs("div",{className:"space-y-1 text-foreground/80",children:[d.jsx("div",{className:"font-medium text-foreground",children:be}),ue&&d.jsx("div",{className:"text-[11px] text-muted-foreground",children:ue})]})]})})}return d.jsxs(d.Fragment,{children:[d.jsx(ih,{open:l,onOpenChange:c,children:d.jsxs("div",{className:`relative space-y-2 rounded-md border ${re.border} ${re.bg} p-3 text-xs`,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(R_,{className:`size-4 shrink-0 ${re.iconColor}`,"aria-hidden":"true"}),d.jsx("span",{className:`font-medium ${re.text}`,children:ie()})]}),se&&d.jsx("div",{className:`text-[10px] ${re.text} opacity-80`,children:"Self-healing defense: Config validated before execution"}),Y&&Y!==o.error&&d.jsxs("div",{className:"text-foreground/80",children:[d.jsx("span",{className:"font-semibold",children:"Issue:"})," ",Y]}),q&&d.jsxs("div",{className:`rounded-md ${re.accentBg} p-2 ${re.accentText}`,children:[d.jsx("span",{className:"font-semibold",children:"Fix:"})," ",q]}),X.length>0&&d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:`font-semibold ${re.text}`,children:"Configuration issues found:"}),d.jsxs("ul",{className:"ml-4 list-disc space-y-0.5",children:[X.slice(0,3).map((be,ue)=>d.jsx("li",{className:"text-foreground/70 dark:text-foreground/60",children:be},ue)),X.length>3&&d.jsxs("li",{className:"text-muted-foreground",children:["...and ",X.length-3," more"]})]})]}),d.jsxs("div",{className:"flex items-center justify-between pt-1",children:[d.jsx(ah,{asChild:!0,children:d.jsxs(le,{variant:"ghost",size:"sm",className:`gap-1 text-[11px] ${re.text}`,children:[l?"Hide":"View"," technical details",d.jsx(Eo,{className:`h-3 w-3 transition-transform ${l?"rotate-180":""}`})]})}),d.jsxs(le,{variant:"ghost",size:"sm",className:`gap-1 text-[11px] ${re.text}`,onClick:N,children:[d.jsx(C_,{className:"h-3 w-3"}),"Report Issue"]})]}),d.jsxs(lh,{className:"mt-2 space-y-2",children:[ne.length>0&&d.jsxs("div",{className:"rounded-md border border-blue-500/40 bg-background/60 p-2 dark:bg-background/40",children:[d.jsx("div",{className:"mb-1 text-[11px] font-semibold text-blue-900 dark:text-blue-200",children:"Suggested fixes:"}),d.jsx("ul",{className:"ml-3 list-disc space-y-1",children:ne.map((be,ue)=>d.jsx("li",{className:"text-[11px] leading-relaxed text-foreground/80",children:be},ue))})]}),d.jsxs("div",{className:`rounded-md border ${re.border} bg-background/60 p-2 dark:bg-background/40`,children:[d.jsx("div",{className:`mb-1 text-[11px] font-semibold ${re.text}`,children:"Raw error:"}),d.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-foreground/80",children:o.error})]})]})]})}),m&&d.jsx(hg,{open:h,onOpenChange:be=>{p(be),be||b(null)},feedbackData:m})]})}return d.jsxs(d.Fragment,{children:[d.jsxs(Fi,{className:"grid w-full max-w-full grid-cols-1 border border-muted bg-background shadow-sm",children:[d.jsx($i,{className:"pb-3",children:d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"space-y-1",children:d.jsx("h3",{className:"text-base font-semibold text-foreground",children:M||"Untitled Chart"})}),d.jsxs("div",{className:"flex items-center gap-2",children:[P!=="table"&&P!=="pivotTable"&&d.jsx(ui,{value:u,onValueChange:f,children:d.jsxs(Ps,{className:"h-8",children:[d.jsx(Fn,{value:"visual",className:"h-7 w-7 p-0","aria-label":"View as chart",children:d.jsx(Dg,{className:"h-3.5 w-3.5"})}),d.jsx(Fn,{value:"table",className:"h-7 w-7 p-0","aria-label":"View as table",children:d.jsx(Hv,{className:"h-3.5 w-3.5"})})]})}),!C&&d.jsx(le,{variant:"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{t==null||t({sql:T||"",data:H||[],dataSource:U||U1,cardConfig:R,cardTitle:M||"Untitled Chart",connectionId:_||"",cardType:P||"bar",python:I||""}),Le.success("Card added to dashboard")},"aria-label":"Add visual to dashboard",children:d.jsx(Yo,{className:"h-4 w-4"})})]})]})}),d.jsxs(Ba,{className:"space-y-4",children:[d.jsx("div",{className:K("isolate flex w-full grow flex-col",P!=="table"&&P!=="pivotTable"&&"min-h-[360px]"),children:d.jsx("div",{className:"flex grow flex-col",children:P==="table"&&z?d.jsx("div",{className:"min-w-0",children:d.jsx(V4,{card:z,data:H||[],isLoading:!1})}):P==="pivotTable"&&W&&z?d.jsx(Xw,{data:W.data,card:z,options:W.options}):L&&P!=="table"&&P!=="pivotTable"?u==="table"?d.jsx("div",{className:"min-w-0 pb-6",children:d.jsx(V4,{card:z,data:H||[],isLoading:!1})}):d.jsx(B4,{cfg:L}):L&&d.jsx(B4,{cfg:L})})}),(T||I||z&&zl(z.config))&&d.jsxs(ih,{open:i,onOpenChange:a,children:[d.jsxs("div",{className:"flex items-center justify-between border-t border-muted/40 pb-2 pt-2",children:[d.jsx("div",{className:"flex items-center gap-2",children:(()=>{const F=G();return d.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[F.icons.map((q,Y)=>d.jsx(q,{className:"h-3 w-3"},Y)),d.jsx("span",{children:F.label}),d.jsx(le,{variant:"ghost",size:"sm",className:"h-4 w-4 p-0 hover:text-foreground",onClick:S,title:"Ask for explanation",children:d.jsx(If,{className:"h-3 w-3"})})]})})()}),d.jsx(ah,{asChild:!0,children:d.jsxs(le,{variant:"ghost",size:"sm",className:"gap-1 text-xs",children:[i?"Hide Details":"Show Details",d.jsx(Eo,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})})]}),d.jsxs(lh,{className:"space-y-3 pb-6",children:[O&&d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(iu,{className:"h-4 w-4 text-blue-600"}),d.jsx("span",{className:"text-sm font-medium text-foreground",children:"SQL Query"})]}),d.jsx(rh,{text:O,className:"-mr-1"})]}),d.jsx("div",{className:"rounded-md border bg-muted/30",children:d.jsx(Fl,{language:"sql",code:O})})]}),I&&d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(JT,{className:"h-4 w-4 text-green-600"}),d.jsx("span",{className:"text-sm font-medium text-foreground",children:"Python"})]}),d.jsx(rh,{text:I,className:"-mr-1"})]}),d.jsx("div",{className:"rounded-md border bg-muted/30",children:d.jsx(Fl,{language:"python",code:I})})]})]})]})]})]}),m&&d.jsx(hg,{open:h,onOpenChange:F=>{p(F),F||b(null)},feedbackData:m})]})}const _Ve=["tool-getChartDataFromSqlAndPython","tool-getChartDataFromCardConfig","tool-getForecastDataFromSqlAndPython","tool-generateQueryConfig"];function jVe({part:e,idx:t,showTools:n,onAddToDashboard:r,messages:o}){if(!e.state)return null;if(e.state==="input-streaming"||e.state==="input-available"){const s=lX(e.type,e.state);return d.jsx(RVe,{text:s})}if(e.state==="output-available"){const s=_Ve.includes(e.type);return d.jsxs("div",{className:"my-2 space-y-2",children:[n&&d.jsx(SVe,{part:e,showTools:n}),s&&r&&d.jsx(kVe,{part:e,onAddToDashboard:r,messages:o,showTools:n})]},t)}return e.state==="output-error"?n?d.jsx("div",{className:"mt-2",children:d.jsx(CVe,{part:e,messages:o})},t):d.jsx("div",{className:"my-2 rounded-md border border-border/40 bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:"I hit a snag while working on that and will adjust the approach."},t):d.jsx("div",{},t)}function RVe({text:e}){return d.jsx("div",{className:"mt-2 animate-pulse text-sm text-muted-foreground",children:e})}const H4=/```quickreply\s*([\s\S]*?)```/i;function MVe(e){let t=e,n=null;const r=e.toLowerCase().indexOf("```quickreply");if(r!==-1){const i=e.match(H4);if(i)n=i[1].trim(),t=e.replace(i[0],"").trim();else return{cleanedText:e.slice(0,r).trimEnd(),quickReplies:[]}}else{const i=e.match(H4);i&&(n=i[1].trim(),t=e.replace(i[0],"").trim())}const o=t===e?e.toLowerCase().indexOf("quickreply"):-1;if(!n&&o!==-1){const i=e.indexOf("{",o);if(i!==-1){let a=0,l=-1;for(let c=i;c<e.length;c++){const u=e[c];if(u==="{")a++;else if(u==="}"&&(a--,a===0)){l=c;break}}if(l!==-1)n=e.slice(i,l+1).trim(),t=(e.slice(0,o)+e.slice(l+1)).trim();else return{cleanedText:e.slice(0,o).trimEnd(),quickReplies:[]}}else return{cleanedText:e.slice(0,o).trimEnd(),quickReplies:[]}}let s=[];if(n)try{const i=JSON.parse(n);s=(Array.isArray(i==null?void 0:i.options)?i.options:[]).map(l=>{const c=typeof(l==null?void 0:l.label)=="string"?l.label.trim():"",u=typeof(l==null?void 0:l.value)=="string"?l.value.trim():"";return c&&u?{label:c,value:u}:null}).filter(Boolean)}catch{s=[]}return{cleanedText:t.trim(),quickReplies:s}}function DVe(e){if(e==null)return"Something went wrong.";if(e instanceof Error)return e.message||"Something went wrong.";const t=r=>{if(!r||typeof r!="object")return null;const o=r.error&&typeof r.error=="object"?r.error:r,s=typeof o.code=="string"&&o.code?o.code.trim():"",i=typeof o.docs=="string"&&o.docs?`
930
+ `))}function l(p,m,b,y){const g=b.enter("tableCell"),x=b.enter("phrasing"),v=b.containerPhrasing(p,{...y,before:s,after:s});return x(),g(),v}function c(p,m){return T7e(p,{align:m,alignDelimiters:r,padding:n,stringLength:o})}function u(p,m,b){const y=p.children;let g=-1;const x=[],v=m.enter("table");for(;++g<y.length;)x[g]=f(y[g],m,b);return v(),x}function f(p,m,b){const y=p.children;let g=-1;const x=[],v=m.enter("tableRow");for(;++g<y.length;)x[g]=l(y[g],p,m,b);return v(),x}function h(p,m,b){let y=UK.inlineCode(p,m,b);return b.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function xBe(){return{exit:{taskListCheckValueChecked:O4,taskListCheckValueUnchecked:O4,paragraph:wBe}}}function vBe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:SBe}}}function O4(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function wBe(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const o=t.children;let s=-1,i;for(;++s<o.length;){const a=o[s];if(a.type==="paragraph"){i=a;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function SBe(e,t,n,r){const o=e.children[0],s=typeof e.checked=="boolean"&&o&&o.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(i);let l=UK.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+i}}function CBe(){return[t7e(),S7e(),k7e(),fBe(),xBe()]}function EBe(e){return{extensions:[n7e(),C7e(e),_7e(),yBe(e),vBe()]}}const NBe={tokenize:DBe,partial:!0},WK={tokenize:TBe,partial:!0},qK={tokenize:PBe,partial:!0},GK={tokenize:ABe,partial:!0},kBe={tokenize:IBe,partial:!0},YK={name:"wwwAutolink",tokenize:RBe,previous:KK},ZK={name:"protocolAutolink",tokenize:MBe,previous:XK},el={name:"emailAutolink",tokenize:jBe,previous:QK},la={};function _Be(){return{text:la}}let Nc=48;for(;Nc<123;)la[Nc]=el,Nc++,Nc===58?Nc=65:Nc===91&&(Nc=97);la[43]=el;la[45]=el;la[46]=el;la[95]=el;la[72]=[el,ZK];la[104]=[el,ZK];la[87]=[el,YK];la[119]=[el,YK];function jBe(e,t,n){const r=this;let o,s;return i;function i(f){return!Fk(f)||!QK.call(r,r.previous)||ID(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(f))}function a(f){return Fk(f)?(e.consume(f),a):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(kBe,u,c)(f):f===45||f===95||Ur(f)?(s=!0,e.consume(f),l):u(f)}function c(f){return e.consume(f),o=!0,l}function u(f){return s&&o&&oo(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function RBe(e,t,n){const r=this;return o;function o(i){return i!==87&&i!==119||!KK.call(r,r.previous)||ID(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(NBe,e.attempt(WK,e.attempt(qK,s),n),n)(i))}function s(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function MBe(e,t,n){const r=this;let o="",s=!1;return i;function i(f){return(f===72||f===104)&&XK.call(r,r.previous)&&!ID(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(f),e.consume(f),a):n(f)}function a(f){if(oo(f)&&o.length<5)return o+=String.fromCodePoint(f),e.consume(f),a;if(f===58){const h=o.toLowerCase();if(h==="http"||h==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),s?c:(s=!0,l)):n(f)}function c(f){return f===null||hv(f)||pn(f)||Uu(f)||O1(f)?n(f):e.attempt(WK,e.attempt(qK,u),n)(f)}function u(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function DBe(e,t,n){let r=0;return o;function o(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),o):i===46&&r===3?(e.consume(i),s):n(i)}function s(i){return i===null?n(i):t(i)}}function TBe(e,t,n){let r,o,s;return i;function i(c){return c===46||c===95?e.check(GK,l,a)(c):c===null||pn(c)||Uu(c)||c!==45&&O1(c)?l(c):(s=!0,e.consume(c),i)}function a(c){return c===95?r=!0:(o=r,r=void 0),e.consume(c),i}function l(c){return o||r||!s?n(c):t(c)}}function PBe(e,t){let n=0,r=0;return o;function o(i){return i===40?(n++,e.consume(i),o):i===41&&r<n?s(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(GK,t,s)(i):i===null||pn(i)||Uu(i)?t(i):(e.consume(i),o)}function s(i){return i===41&&r++,e.consume(i),o}}function ABe(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),o):a===60||a===null||pn(a)||Uu(a)?t(a):n(a)}function o(a){return a===null||a===40||a===91||pn(a)||Uu(a)?t(a):r(a)}function s(a){return oo(a)?i(a):n(a)}function i(a){return a===59?(e.consume(a),r):oo(a)?(e.consume(a),i):n(a)}}function IBe(e,t,n){return r;function r(s){return e.consume(s),o}function o(s){return Ur(s)?n(s):t(s)}}function KK(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||pn(e)}function XK(e){return!oo(e)}function QK(e){return!(e===47||Fk(e))}function Fk(e){return e===43||e===45||e===46||e===95||Ur(e)}function ID(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const OBe={tokenize:UBe,partial:!0};function FBe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:BBe,continuation:{tokenize:VBe},exit:HBe}},text:{91:{name:"gfmFootnoteCall",tokenize:zBe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:$Be,resolveTo:LBe}}}}function $Be(e,t,n){const r=this;let o=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;o--;){const l=r.events[o][1];if(l.type==="labelImage"){i=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!i||!i._balanced)return n(l);const c=Qs(r.sliceSerialize({start:i.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function LBe(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function zBe(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,i;return a;function a(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(f){if(s>999||f===93&&!i||f===null||f===91||pn(f))return n(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return o.includes(Qs(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return pn(f)||(i=!0),s++,e.consume(f),f===92?u:c}function u(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function BBe(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,i=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(m)}function u(m){if(i>999||m===93&&!a||m===null||m===91||pn(m))return n(m);if(m===93){e.exit("chunkString");const b=e.exit("gfmFootnoteDefinitionLabelString");return s=Qs(r.sliceSerialize(b)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return pn(m)||(a=!0),i++,e.consume(m),m===92?f:u}function f(m){return m===91||m===92||m===93?(e.consume(m),i++,u):u(m)}function h(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),o.includes(s)||o.push(s),zt(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function VBe(e,t,n){return e.check(Rb,t,e.attempt(OBe,t,n))}function HBe(e){e.exit("gfmFootnoteDefinition")}function UBe(e,t,n){const r=this;return zt(e,o,"gfmFootnoteDefinitionIndent",5);function o(s){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(s):n(s)}}function WBe(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:o};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(i,a){let l=-1;for(;++l<i.length;)if(i[l][0]==="enter"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._close){let c=l;for(;c--;)if(i[c][0]==="exit"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._open&&i[l][1].end.offset-i[l][1].start.offset===i[c][1].end.offset-i[c][1].start.offset){i[l][1].type="strikethroughSequence",i[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[l][1].end)},f={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[l][1].start)},h=[["enter",u,a],["enter",i[c][1],a],["exit",i[c][1],a],["enter",f,a]],p=a.parser.constructs.insideSpan.null;p&&Uo(h,h.length,0,F1(p,i.slice(c+1,l),a)),Uo(h,h.length,0,[["exit",f,a],["enter",i[l][1],a],["exit",i[l][1],a],["exit",u,a]]),Uo(i,c-1,l-c+3,h),l=c+h.length-2;break}}for(l=-1;++l<i.length;)i[l][1].type==="strikethroughSequenceTemporary"&&(i[l][1].type="data");return i}function s(i,a,l){const c=this.previous,u=this.events;let f=0;return h;function h(m){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(m):(i.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const b=sh(c);if(m===126)return f>1?l(m):(i.consume(m),f++,p);if(f<2&&!n)return l(m);const y=i.exit("strikethroughSequenceTemporary"),g=sh(m);return y._open=!g||g===2&&!!b,y._close=!b||b===2&&!!g,a(m)}}}class qBe{constructor(){this.map=[]}add(t,n,r){GBe(this,t,n,r)}consume(t){if(this.map.sort(function(s,i){return s[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const s of o)t.push(s);o=r.pop()}this.map.length=0}}function GBe(e,t,n,r){let o=0;if(!(n===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...r);return}o+=1}e.map.push([t,n,r])}}function YBe(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function ZBe(){return{flow:{null:{name:"table",tokenize:KBe,resolveAll:XBe}}}}function KBe(e,t,n){const r=this;let o=0,s=0,i;return a;function a(R){let M=r.events.length-1;for(;M>-1;){const I=r.events[M][1].type;if(I==="lineEnding"||I==="linePrefix")M--;else break}const T=M>-1?r.events[M][1].type:null,O=T==="tableHead"||T==="tableRow"?S:l;return O===S&&r.parser.lazy[r.now().line]?n(R):O(R)}function l(R){return e.enter("tableHead"),e.enter("tableRow"),c(R)}function c(R){return R===124||(i=!0,s+=1),u(R)}function u(R){return R===null?n(R):qe(R)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),p):n(R):kt(R)?zt(e,u,"whitespace")(R):(s+=1,i&&(i=!1,o+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),i=!0,u):(e.enter("data"),f(R)))}function f(R){return R===null||R===124||pn(R)?(e.exit("data"),u(R)):(e.consume(R),R===92?h:f)}function h(R){return R===92||R===124?(e.consume(R),f):f(R)}function p(R){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(R):(e.enter("tableDelimiterRow"),i=!1,kt(R)?zt(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):m(R))}function m(R){return R===45||R===58?y(R):R===124?(i=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),b):C(R)}function b(R){return kt(R)?zt(e,y,"whitespace")(R):y(R)}function y(R){return R===58?(s+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),g):R===45?(s+=1,g(R)):R===null||qe(R)?w(R):C(R)}function g(R){return R===45?(e.enter("tableDelimiterFiller"),x(R)):C(R)}function x(R){return R===45?(e.consume(R),x):R===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(R))}function v(R){return kt(R)?zt(e,w,"whitespace")(R):w(R)}function w(R){return R===124?m(R):R===null||qe(R)?!i||o!==s?C(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(R)):C(R)}function C(R){return n(R)}function S(R){return e.enter("tableRow"),N(R)}function N(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),N):R===null||qe(R)?(e.exit("tableRow"),t(R)):kt(R)?zt(e,N,"whitespace")(R):(e.enter("data"),j(R))}function j(R){return R===null||R===124||pn(R)?(e.exit("data"),N(R)):(e.consume(R),R===92?_:j)}function _(R){return R===92||R===124?(e.consume(R),j):j(R)}}function XBe(e,t){let n=-1,r=!0,o=0,s=[0,0,0,0],i=[0,0,0,0],a=!1,l=0,c,u,f;const h=new qBe;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(F4(h,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],i=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",u,t]])),o=m.type==="tableDelimiterRow"?2:u?3:1):o&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(s[1]!==0&&(i[0]=i[1],f=r0(h,t,s,o,void 0,f),s=[0,0,0,0]),i[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(i[0]=i[1],f=r0(h,t,s,o,void 0,f)),s=i,i=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(i[0]=i[1],f=r0(h,t,s,o,n,f)):i[1]!==0&&(f=r0(h,t,i,o,n,f)),o=0):o&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(i[3]=n)}for(l!==0&&F4(h,t,l,c,u),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=YBe(t.events,n))}return e}function r0(e,t,n,r,o,s){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Od(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Od(t.events,n[1]);if(s={type:i,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Od(t.events,n[2]),u=Od(t.events,n[3]),f={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,b=n[3]-n[2]-1;e.add(m,b,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return o!==void 0&&(s.end=Object.assign({},Od(t.events,o)),e.add(o,0,[["exit",s,t]]),s=void 0),s}function F4(e,t,n,r,o){const s=[],i=Od(t.events,n);o&&(o.end=Object.assign({},i),s.push(["exit",o,t])),r.end=Object.assign({},i),s.push(["exit",r,t]),e.add(n+1,0,s)}function Od(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const QBe={name:"tasklistCheck",tokenize:eVe};function JBe(){return{text:{91:QBe}}}function eVe(e,t,n){const r=this;return o;function o(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return pn(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),i):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),i):n(l)}function i(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return qe(l)?t(l):kt(l)?e.check({tokenize:tVe},t,n)(l):n(l)}}function tVe(e,t,n){return zt(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function nVe(e){return oK([_Be(),FBe(),WBe(e),ZBe(),JBe()])}const rVe={};function oVe(e){const t=this,n=e||rVe,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(nVe(n)),s.push(CBe()),i.push(EBe(n))}const Dl=E.forwardRef(({children:e,className:t,tooltip:n,onClick:r,openDelay:o=300,buttonProps:s,disabled:i,...a},l)=>d.jsx(Ya,{children:d.jsxs(Xo,{delayDuration:o,children:[d.jsx(Qo,{asChild:!0,children:d.jsx(le,{disabled:i,ref:l,size:"sm",variant:"ghost",onClick:r,...a,...s,className:K(`${Jd}`,t),children:e})}),n&&d.jsx(js,{side:"bottom",sideOffset:10,children:n})]})}));Dl.displayName="IconButton";var OD="Collapsible",[sVe,JK]=mr(OD),[iVe,FD]=sVe(OD),eX=k.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l=!1,c]=jr({prop:r,defaultProp:o,onChange:i});return d.jsx(iVe,{scope:n,disabled:s,contentId:qn(),open:l,onOpenToggle:k.useCallback(()=>c(u=>!u),[c]),children:d.jsx(Me.div,{"data-state":BD(l),"data-disabled":s?"":void 0,...a,ref:t})})});eX.displayName=OD;var tX="CollapsibleTrigger",$D=k.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=FD(tX,n);return d.jsx(Me.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":BD(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:Se(e.onClick,o.onOpenToggle)})});$D.displayName=tX;var LD="CollapsibleContent",zD=k.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=FD(LD,e.__scopeCollapsible);return d.jsx(Gn,{present:n||o.open,children:({present:s})=>d.jsx(aVe,{...r,ref:t,present:s})})});zD.displayName=LD;var aVe=k.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=FD(LD,n),[a,l]=k.useState(r),c=k.useRef(null),u=ot(t,c),f=k.useRef(0),h=f.current,p=k.useRef(0),m=p.current,b=i.open||a,y=k.useRef(b),g=k.useRef(void 0);return k.useEffect(()=>{const x=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(x)},[]),_r(()=>{const x=c.current;if(x){g.current=g.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const v=x.getBoundingClientRect();f.current=v.height,p.current=v.width,y.current||(x.style.transitionDuration=g.current.transitionDuration,x.style.animationName=g.current.animationName),l(r)}},[i.open,r]),d.jsx(Me.div,{"data-state":BD(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...s,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:b&&o})});function BD(e){return e?"open":"closed"}var nX=eX,lVe=$D,cVe=zD;const ih=nX,ah=$D,lh=zD;function rX(){const{authToken:e,tokenProps:t}=Ue(),{currentUser:n}=Xi(),r=Ki({mutationFn:async o=>{if(!(e!=null&&e.accessToken))throw new Error("No authentication token available");const i=`${t.apiServiceUrl||""}/v1/feedback`,a={...o,user:n,tokenContext:t},l=await nc(i,e.accessToken,a,"POST");if(!l||!l.success)throw new Error((l==null?void 0:l.error)||"Failed to send feedback");return l},onSuccess:o=>{Le.success(`Feedback sent successfully! Issue: ${o.issueNumber}`,{duration:5e3})},onError:o=>{console.error("Feedback submission error:",o),Le.error("Failed to send feedback. Please try again later.",{duration:5e3})}});return{sendFeedback:r.mutate,sendFeedbackAsync:r.mutateAsync,isLoading:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,data:r.data,reset:r.reset}}function H1(e,t,n){return{category:e,userMessage:n,systemState:t,metadata:{url:window.location.href,userAgent:navigator.userAgent,timestamp:new Date().toISOString(),viewport:`${window.innerWidth}x${window.innerHeight}`}}}function hg({open:e,onOpenChange:t,feedbackData:n,onSuccess:r,showDebugInfo:o=!1}){var g,x,v,w,C,S,N,j,_,R,M,T,O;const[s,i]=E.useState(""),[a,l]=E.useState(!1),{sendFeedback:c,isLoading:u,isSuccess:f,data:h,reset:p}=rX();E.useEffect(()=>{f&&r&&r()},[f,r]);const m=()=>{const I={...n,userMessage:s.trim()||void 0};c(I)},b=()=>{i(""),l(!1),p(),t(!1)},y={category:n.category,error:{message:(g=n.systemState)==null?void 0:g.errorMessage,sql:(x=n.systemState)==null?void 0:x.generatedSql,errorSql:(v=n.systemState)==null?void 0:v.errorSql},assistantType:(w=n.systemState)==null?void 0:w.assistantType,toolType:(C=n.systemState)==null?void 0:C.toolType,userQuery:(S=n.systemState)==null?void 0:S.userQuery,messages:(N=n.systemState)==null?void 0:N.messages,aiContext:(j=n.systemState)==null?void 0:j.aiContext,toolInput:(_=n.systemState)==null?void 0:_.toolInput,toolOutput:(R=n.systemState)==null?void 0:R.toolOutput,cardConfig:(M=n.systemState)==null?void 0:M.cardConfig,dataSource:(T=n.systemState)==null?void 0:T.dataSource,filters:(O=n.systemState)==null?void 0:O.dashboardFilters,metadata:n.metadata};return d.jsx(ai,{open:e,onOpenChange:b,children:d.jsxs(Ms,{className:"max-w-2xl",children:[d.jsxs(Ds,{children:[d.jsx(Ts,{children:f?"Feedback Sent Successfully":n.category==="dashboard-assistant"||n.category==="editor-assistant"?"Report an issue":"Report Query Generation Issue"}),d.jsx(Qi,{children:f?`Your feedback has been submitted with issue number: ${h==null?void 0:h.issueNumber}`:n.category==="dashboard-assistant"||n.category==="editor-assistant"?"Help us improve the AI responses. Your feedback will be sent to our support team.":"Help us improve by reporting this query generation issue. Your feedback will be sent to our support team."})]}),!f&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"message",children:"Additional Information (Optional)"}),d.jsx(ph,{id:"message",placeholder:"Please describe what you were trying to do when this error occurred...",value:s,onChange:I=>i(I.target.value),className:"min-h-[100px] resize-none ring-inset focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",disabled:u})]}),o&&d.jsxs(ih,{open:a,onOpenChange:l,children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(ah,{asChild:!0,children:d.jsxs(le,{variant:"ghost",size:"sm",className:"flex flex-1 items-center justify-between p-2 hover:bg-muted",children:[d.jsx("span",{className:"text-sm font-medium",children:"View data to be sent"}),a?d.jsx(Eo,{className:"h-4 w-4"}):d.jsx(Js,{className:"h-4 w-4"})]})}),d.jsx(rh,{text:JSON.stringify(y,null,2),className:"h-8 w-8 shrink-0"})]}),d.jsx(lh,{className:"mt-2",children:d.jsx(Wi,{className:"h-[300px] w-full rounded-md border bg-muted/50 p-4",children:d.jsx("div",{className:"text-xs overflow-auto break-all whitespace-pre-wrap",children:d.jsx(Fl,{code:JSON.stringify(y,null,2),language:"json"})})})})]})]}),d.jsxs(li,{children:[d.jsx(le,{variant:"outline",onClick:b,disabled:u,children:"Cancel"}),d.jsx(le,{onClick:m,disabled:u,className:"min-w-[100px]",children:u?d.jsxs(d.Fragment,{children:[d.jsx(Ns,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Feedback"})]})]}),f&&d.jsxs("div",{className:"flex flex-col items-center space-y-4 py-6",children:[d.jsx(jne,{className:"h-12 w-12 text-green-600"}),d.jsxs("div",{className:"text-center",children:[d.jsx("p",{className:"text-lg font-medium",children:"Thank you for your feedback!"}),d.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Issue Number:"," ",d.jsx("span",{className:"font-mono font-medium",children:h==null?void 0:h.issueNumber})]}),d.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Our support team will review your feedback and take appropriate action."})]}),d.jsx(le,{onClick:b,className:"mt-4",children:"Close"})]})]})})}var Xl=(e=>(e.QUERY_GENERATION="query-generation",e.DASHBOARD_ASSISTANT="dashboard-assistant",e.EDITOR_ASSISTANT="editor-assistant",e))(Xl||{});function uVe(e,t){var r;if(!e||e.length===0)return"";const n=e.findIndex(o=>o.id===t);if(n===-1)return"";for(let o=n-1;o>=0;o--)if(e[o].role==="user"){const s=(r=e[o].parts)==null?void 0:r.find(i=>i.type==="text");return(s==null?void 0:s.text)||""}return""}function dVe({messageId:e,messageText:t,messages:n,className:r}){const[o,s]=E.useState("none"),[i,a]=E.useState(!1),[l,c]=E.useState(null),u=F_(),f=mh(),{isLoading:h}=rX(),{isLocalDev:p,isConsoleMode:m}=xb(),b=async()=>{if(o==="positive"){s("none"),Le.info("Feedback removed");return}s("positive"),Le.success("Thank you for your feedback!")},y=()=>{const v=uVe(n,e),w=u==="dashboard"?Xl.DASHBOARD_ASSISTANT:Xl.EDITOR_ASSISTANT,C=H1(w,{assistantType:u,userQuery:v,messages:n,aiContext:f,messageId:e,feedbackType:"negative",assistantResponse:t});c(C),a(!0)},g=v=>{a(v),v||c(null)},x=()=>{s("negative")};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:K("flex items-center gap-1",r),children:[d.jsx(Dl,{onClick:b,disabled:h,tooltip:o==="positive"?"Positive feedback given (click to undo)":"Helpful response",className:K("h-6 w-6 p-1",o==="positive"?"text-green-600 dark:text-green-500":"text-muted-foreground hover:text-foreground"),children:d.jsx(Vne,{className:K("h-3.5 w-3.5",o==="positive"&&"fill-current")})}),d.jsx(Dl,{onClick:y,disabled:h,tooltip:o==="negative"?"Negative feedback given (click to update)":"Report issue",className:K("h-6 w-6 p-1",o==="negative"?"text-red-600 dark:text-red-500":"text-muted-foreground hover:text-foreground"),children:d.jsx(Bne,{className:K("h-3.5 w-3.5",o==="negative"&&"fill-current")})})]}),l&&d.jsx(hg,{open:i,onOpenChange:g,feedbackData:l,onSuccess:x,showDebugInfo:m||p})]})}function $4({text:e,handleRun:t,className:n,messageId:r,messages:o}){const s=te(a=>a.themeStyle),i={p:({node:a,...l})=>d.jsx("p",{className:K("mb-4 text-sm leading-relaxed text-foreground/90",n),...l}),code:({node:a,...l})=>{var u,f;const c=(f=(u=a==null?void 0:a.children)==null?void 0:u[0])==null?void 0:f.value;return c&&/^#([0-9a-fA-F]{6})$/.test(c)?d.jsx("code",{className:K("rounded-lg bg-muted px-2.5 py-1.5 font-mono text-sm",n),style:{backgroundColor:c},...l}):d.jsx("code",{className:K("rounded-lg border border-border/50 bg-muted/50 px-2 py-1 font-mono text-xs text-foreground/80 transition-colors hover:bg-muted/70",n),...l})},pre:a=>d.jsx(Z9e,{...a,handleRun:t}),ul:({node:a,...l})=>d.jsx("ul",{className:K("mb-4 ml-6 list-disc space-y-2 text-sm marker:text-muted-foreground",n),...l}),ol:({node:a,...l})=>d.jsx("ol",{className:K("mb-4 ml-6 list-decimal space-y-2 text-sm marker:text-muted-foreground",n),...l}),li:({node:a,...l})=>d.jsx("li",{className:K("pl-2 leading-relaxed text-foreground/90",n),...l}),a:({node:a,...l})=>d.jsx("a",{target:"_blank",rel:"noopener noreferrer",className:K("text-blue-600 underline decoration-1 underline-offset-2 transition-all hover:text-blue-700 hover:decoration-2",n),...l}),h1:({node:a,...l})=>d.jsx("h1",{className:K("mb-4 mt-6 text-2xl font-semibold tracking-tight text-foreground",n),...l}),h2:({node:a,...l})=>d.jsx("h2",{className:K("mb-3 mt-5 text-xl font-semibold tracking-tight text-foreground",n),...l}),h3:({node:a,...l})=>d.jsx("h3",{className:K("mb-2 mt-4 text-lg font-medium text-foreground",n),...l}),h4:({node:a,...l})=>d.jsx("h4",{className:K("mb-2 mt-3 text-base font-medium text-foreground/90",n),...l}),strong:({node:a,...l})=>d.jsx("strong",{className:K("font-semibold text-foreground",n),...l}),blockquote:({node:a,...l})=>d.jsx("blockquote",{className:K("my-4 rounded-r-md border-l-4 border-muted-foreground/30 bg-muted/20 py-3 pl-4 pr-4 italic text-foreground/80",n),...l}),table:({node:a,...l})=>d.jsx("div",{className:"my-6 overflow-x-auto rounded-lg border border-border/50 shadow-sm",children:d.jsx("table",{className:K("w-full table-auto border-collapse text-sm",n),...l})}),thead:({node:a,...l})=>{var c,u,f,h,p,m;return d.jsx("thead",{style:{backgroundColor:(f=(u=(c=s==null?void 0:s.chart)==null?void 0:c.dataset)==null?void 0:u.backgroundColor)==null?void 0:f[0],color:Aa((m=(p=(h=s==null?void 0:s.chart)==null?void 0:h.dataset)==null?void 0:p.backgroundColor)==null?void 0:m[0])},className:"sticky top-0",...l})},tr:({node:a,...l})=>d.jsx("tr",{className:K("border-b border-border/30 transition-colors last:border-0 hover:bg-muted/30",n),...l}),th:({node:a,...l})=>d.jsx("th",{className:K("px-4 py-3 text-left text-sm font-medium tracking-wide",n),...l}),td:({node:a,...l})=>d.jsx("td",{className:K("px-4 py-3 align-top text-foreground/90",n),...l})};return d.jsxs("div",{className:"group relative pr-16",children:[d.jsx(z8e,{components:i,remarkPlugins:[oVe],children:e}),r&&d.jsx("div",{className:"absolute right-0 top-1 opacity-0 transition-opacity group-hover:opacity-100",children:d.jsx(dVe,{messageId:r,messageText:e,messages:o})})]})}const Wu=["image/png","image/jpeg","image/jpg","image/gif","image/webp"],fVe=["application/pdf","text/plain","text/markdown"],hVe=["text/csv","application/json","text/xml","application/xml"],pVe=["text/javascript","application/javascript","text/typescript","application/x-typescript","text/x-python","application/x-python-code","text/x-sql","application/sql"],mVe=[...Wu,...fVe,...hVe,...pVe],oX=10*1024*1024,xa=5,sX={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".txt":"text/plain",".md":"text/markdown",".csv":"text/csv",".json":"application/json",".xml":"text/xml",".js":"text/javascript",".jsx":"text/javascript",".ts":"text/typescript",".tsx":"text/typescript",".py":"text/x-python",".sql":"text/x-sql"};function gVe(e){if(mVe.includes(e.type))return!0;const t=VD(e.name);return t?Object.prototype.hasOwnProperty.call(sX,t):!1}function VD(e){const t=e.lastIndexOf(".");return t===-1?"":e.substring(t).toLowerCase()}function iX(e){if(e.type)return e.type;const t=VD(e.name);return sX[t]||"application/octet-stream"}function bVe(e){return e.size<=oX}function pg(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+n[r]}function L4(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const s=r.result.split(",")[1];t(s)},r.onerror=n,r.readAsDataURL(e)})}function yVe(e){return new Promise((t,n)=>{if(!Wu.includes(iX(e))){n(new Error("Not an image file"));return}const r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}async function HD(e){const t=iX(e),n=Wu.includes(t),r={id:crypto.randomUUID(),name:e.name,size:e.size,type:t};if(n)try{r.preview=await yVe(e),r.data=r.preview.split(",")[1]}catch(o){console.error("Failed to create image preview:",o),r.data=await L4(e)}else r.data=await L4(e);return r}function aX(e){const t=[],n=[];for(const r of e)gVe(r)?bVe(r)?t.push(r):n.push({file:r,error:`File too large: ${pg(r.size)} (max ${pg(oX)})`}):n.push({file:r,error:`File type not supported: ${r.type||VD(r.name)}`});return{valid:t,errors:n}}function xVe(e){var r;const t=(r=e.clipboardData)==null?void 0:r.items;if(!t)return[];const n=[];for(let o=0;o<t.length;o++){const s=t[o];if(s.kind==="file"){const i=s.getAsFile();i&&Wu.includes(i.type)&&n.push(i)}}return n}function vVe({files:e,onRemove:t,showRemove:n=!0,className:r=""}){if(e.length===0)return null;const o=s=>Wu.includes(s)?Tne:s.includes("pdf")||s.includes("text")?Go:s.includes("javascript")||s.includes("typescript")||s.includes("python")||s.includes("sql")?Dne:sL;return d.jsx("div",{className:`flex flex-wrap gap-2 ${r}`,children:e.map(s=>{const i=o(s.type),a=Wu.includes(s.type);return d.jsxs("div",{className:"group relative flex items-center gap-2 rounded-lg border border-border bg-muted/50 p-2 transition-colors hover:bg-muted",children:[a&&s.preview?d.jsx("div",{className:"relative h-12 w-12 overflow-hidden rounded",children:d.jsx("img",{src:s.preview,alt:s.name,className:"h-full w-full object-cover"})}):d.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded bg-background",children:d.jsx(i,{className:"h-6 w-6 text-muted-foreground"})}),d.jsxs("div",{className:"flex flex-col",children:[d.jsx("span",{className:"max-w-[150px] truncate text-xs font-medium",children:s.name}),d.jsx("span",{className:"text-xs text-muted-foreground",children:pg(s.size)}),s.uploadProgress!==void 0&&s.uploadProgress<100&&d.jsx(wM,{value:s.uploadProgress,className:"mt-1 h-1 w-full"})]}),n&&t&&d.jsx(le,{variant:"ghost",size:"icon",className:"absolute -right-2 -top-2 h-5 w-5 rounded-full bg-background opacity-0 shadow-sm transition-opacity group-hover:opacity-100",onClick:()=>t(s.id),children:d.jsx(ln,{className:"h-3 w-3"})})]},s.id)})})}function wVe({file:e,className:t=""}){return Wu.includes(e.type)&&e.preview?d.jsxs("div",{className:`inline-block ${t}`,children:[d.jsx("img",{src:e.preview,alt:e.name,className:"max-h-64 max-w-full rounded-lg border border-border"}),d.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.name," • ",pg(e.size)]})]}):d.jsxs("div",{className:`inline-flex items-center gap-2 rounded-lg border border-border bg-muted/50 px-3 py-2 ${t}`,children:[d.jsx(Go,{className:"h-4 w-4 text-muted-foreground"}),d.jsx("span",{className:"text-sm",children:e.name}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",pg(e.size),")"]})]})}const z4={"tool-getTableColumns":{"input-streaming":"Fetching table columns...","input-available":"Reading column definitions..."},"tool-getChartDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartDataFromCardConfig":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getForecastDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartSQLSyntax":{"input-streaming":"Generating SQL syntax...","input-available":"SQL syntax generated"},"tool-validateCardConfigFormat":{"input-streaming":"Validating card config format...","input-available":"Card config format validated"},"tool-generateQueryConfig":{"input-streaming":"Generating query config...","input-available":"Sending query config..."},"tool-askForMoreInfo":{"input-streaming":"Asking for more information...","input-available":"More information requested"},"tool-createChartFromSql":{"input-streaming":"Creating chart...","input-available":"Chart created"},"tool-getUserSql":{"input-streaming":"Getting SQL...","input-available":"SQL retrieved"},"tool-inspectTableData":{"input-streaming":"Inspecting table data...","input-available":"Analyzing data..."},"tool-getDomainRelationships":{"input-streaming":"Getting domain relationships...","input-available":"Analyzing data..."}};function lX(e,t){var r;if((r=z4[e])!=null&&r[t])return z4[e][t];const n=e.replace("tool-","").replace(/([A-Z])/g," $1").toLowerCase().trim();return t==="input-streaming"?`Processing ${n}...`:`Preparing ${n} response...`}function SVe({part:e,showTools:t}){if(!t)return null;const{input:n,output:r,...o}=e;return e.type,d.jsx("div",{className:"space-y-3",children:t&&d.jsxs(ih,{children:[d.jsxs("div",{className:"inline-flex items-center gap-2",children:[d.jsxs(ah,{className:"rounded-md border border-foreground/20 p-1 px-2 font-mono text-xs text-foreground/80 hover:bg-foreground/5",children:[d.jsx("span",{className:"font-bold",children:"Tool:"})," ",e.type.split("-")[1]]}),Pv]}),d.jsx(lh,{className:"mt-2 font-mono text-xs",children:d.jsxs("div",{className:"space-y-2 px-2",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{children:"Args:"}),d.jsx(Fl,{language:"json",code:JSON.stringify(o,null,2)})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{children:"Input:"}),d.jsx(Fl,{language:"json",code:JSON.stringify(n,null,2)})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{children:"Output:"}),d.jsx(Fl,{language:"json",code:JSON.stringify(r,null,2)})]})]})})]})})}function CVe({part:e,messages:t}){const[n,r]=E.useState(!1),[o,s]=E.useState(null),i=F_(),a=mh(),{tokenProps:l}=E.useContext(Mg);Xi();const c=()=>{var b;const u=t==null?void 0:t.filter(y=>y.role==="user").pop(),f=(b=u==null?void 0:u.parts)==null?void 0:b.find(y=>y.type==="text"),h=(f==null?void 0:f.text)||"",p=i==="dashboard"?Xl.DASHBOARD_ASSISTANT:Xl.EDITOR_ASSISTANT,m=H1(p,{errorMessage:e.errorText||"Tool invocation error occurred",toolType:e.type,toolInput:e.input,toolOutput:null,assistantType:i,userQuery:h,messages:t,aiContext:a});s(m),r(!0)};return d.jsxs(d.Fragment,{children:[d.jsxs(ih,{children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(ah,{className:"",children:d.jsxs(de,{className:"flex cursor-pointer items-center hover:text-foreground",children:[d.jsx(R_,{className:"mr-2 size-4 text-yellow-500"}),"Recovering from Error"]})}),d.jsxs(le,{variant:"ghost",size:"sm",className:"gap-1 text-[11px]",onClick:c,"aria-label":"Send feedback",children:[d.jsx(C_,{className:"h-3 w-3"}),"Send Feedback"]})]}),d.jsx(lh,{className:"mt-2 text-xs",children:d.jsxs("div",{className:"relative space-y-2 rounded-md border border-yellow-500 bg-yellow-50 p-4 text-black/80 dark:border-yellow-500/80 dark:bg-yellow-500/10 dark:text-white/80",children:[d.jsxs(de,{className:"text-xs",children:["Tool Invocation Error (",e.type.split("-")[1],")"]}),d.jsx("p",{children:e.errorText})]})})]}),o&&d.jsx(hg,{open:n,onOpenChange:u=>{r(u),u||s(null)},feedbackData:o})]})}var EVe=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,s;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(s=Object.keys(t),r=s.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=r;o--!==0;){var i=s[o];if(!(i==="_owner"&&t.$$typeof)&&!e(t[i],n[i]))return!1}return!0}return t!==t&&n!==n};const cX=tc(EVe);function o0(e,t=cX){const[n,r]=E.useState(()=>({value:e,lastInput:e}));if(!t(n.lastInput,e)){const o=t(n.value,e)?n.value:e;return r({value:o,lastInput:e}),o}return n.value}function NVe(e=[],t=[]){var r,o,s,i;if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;const n=Math.min(5,e.length);for(let a=0;a<n;a++)if(((r=e[a])==null?void 0:r.id)!==((o=t[a])==null?void 0:o.id))return!1;for(let a=0;a<n;a++){const l=e.length-1-a;if(((s=e[l])==null?void 0:s.id)!==((i=t[l])==null?void 0:i.id))return!1}return cX(e,t)}const U1={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]},B4=E.memo(({cfg:e,onDatapointClick:t})=>d.jsx(Kw,{cfg:e,onDatapointClick:t}),(e,t)=>JSON.stringify(e.cfg)===JSON.stringify(t.cfg)&&e.onDatapointClick===t.onDatapointClick),V4=E.memo(Gw,(e,t)=>{const n=e.data===t.data,r=e.card===t.card,o=e.isLoading===t.isLoading;return n&&r&&o});function kVe({part:e,onAddToDashboard:t,messages:n,showTools:r=!1}){var Z,V;const o=e.output,s=e.input,[i,a]=E.useState(!1),[l,c]=E.useState(!1),[u,f]=E.useState("visual"),[h,p]=E.useState(!1),[m,b]=E.useState(null),y=E.useMemo(()=>(e==null?void 0:e.toolCallId)??yr(),[e]),{queueMessage:g}=gh(),x=F_(),v=mh(),{tokenProps:w}=E.useContext(Mg),C=(w==null?void 0:w.type)==="dashboard";Xi();const S=()=>{const F=e.toolCallId;G().label;const q=`Can you explain how this visual was calculated? [ref: ${F}]`;g("dashboard",q)},N=()=>{var ne;const F=n==null?void 0:n.filter(se=>se.role==="user").pop(),q=(ne=F==null?void 0:F.parts)==null?void 0:ne.find(se=>se.type==="text"),Y=(q==null?void 0:q.text)||"",ee=x==="dashboard"?Xl.DASHBOARD_ASSISTANT:Xl.EDITOR_ASSISTANT,X=H1(ee,{errorMessage:(o==null?void 0:o.error)||"An error occurred while generating the visualization",toolType:e.type,toolInput:s,toolOutput:o,assistantType:x,userQuery:Y,messages:n,aiContext:v,cardConfig:s==null?void 0:s.cardConfig,dataSource:o==null?void 0:o.dataSource,generatedSql:s==null?void 0:s.sql});b(X),p(!0)},j=s==null?void 0:s.chartType,_=s==null?void 0:s.connectionId,R=s==null?void 0:s.cardConfig,M=s==null?void 0:s.chartTitle,T=s==null?void 0:s.sql,O=(Z=o==null?void 0:o.data)==null?void 0:Z.userSql,I=s==null?void 0:s.python,A=(V=o==null?void 0:o.data)==null?void 0:V.records,$=o==null?void 0:o.dataSource,H=o0(A??[],NVe),U=o0($),B=o0(R),P=o0(j),z=E.useMemo(()=>P?{id:y,config:B,type:P,dataSource:U,preferences:{tablePrefs:{pageSize:10,forceClientPagination:!0}}}:null,[y,B,P,U]),L=E.useMemo(()=>!z||P==="pivotTable"?null:CR({card:z,cardType:P,data:H||[],queryConfig:{}}),[z,P,H]),D=E.useMemo(()=>{var X,ne,se,re;if(P!=="pivotTable"||!o)return null;const F=((X=o.data)==null?void 0:X.pivotSchema)||[],q=((ne=o.data)==null?void 0:ne.subtotalColumns)||[],Y=(se=o.data)==null?void 0:se.columnSubtotalMeta,ee=(re=o.data)==null?void 0:re.groupByColumns;return{records:H||[],pivotSchema:F,subtotalColumns:q,columnSubtotalMeta:Y,groupByColumns:ee}},[P,o,H]),W=Kg(z,D),G=()=>{const F=z?zl(z.config):!1,q=Jw.find(ee=>ee.id===P),Y=q==null?void 0:q.icon;return I?{type:"advanced",label:"Advanced Analysis",icons:[iu,JT]}:F&&Y?{type:"standard",label:"Standard Analysis",icons:[Y]}:{type:"sql",label:"SQL Analysis",icons:[iu]}};if(!o)return null;if(o.error){const F=o.errorType||"unknown",q=o.hint||"",Y=o.rootCause||o.error,ee=o.shouldRetry!==!1,X=o.validationErrors||[],ne=o.suggestions||[],se=X.length>0,re=se?{border:"border-purple-500/60 dark:border-purple-500/50",bg:"bg-purple-50 dark:bg-purple-500/10",text:"text-purple-800 dark:text-purple-300",iconColor:"text-purple-600 dark:text-purple-500",accentBg:"bg-purple-100 dark:bg-purple-900/30",accentText:"text-purple-900 dark:text-purple-200"}:{border:"border-yellow-500/60 dark:border-yellow-500/50",bg:"bg-yellow-50 dark:bg-yellow-500/10",text:"text-yellow-800 dark:text-yellow-300",iconColor:"text-yellow-600 dark:text-yellow-500",accentBg:"bg-yellow-100 dark:bg-yellow-900/30",accentText:"text-yellow-900 dark:text-yellow-200"},ie=()=>se?ee?"Configuration validation failed. Retrying...":"Configuration validation failed":F==="group_by_error"?ee?"SQL grouping error. Retrying...":"SQL grouping error":F==="syntax_error"?ee?"SQL syntax error. Retrying...":"SQL syntax error":F==="type_mismatch"?ee?"Data type mismatch. Retrying...":"Data type mismatch":ee?"Retrying...":"Couldn't generate this visual";if(!r){const be=ee?"Let me try that a different way...":"I'm ready with a revised plan.",ue=q||(Y&&Y!==o.error?Y:"");return d.jsx("div",{className:"mt-2 rounded-md border border-border/40 bg-muted/30 p-3 text-xs",children:d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx(k_,{className:"size-4 shrink-0 text-primary","aria-hidden":"true"}),d.jsxs("div",{className:"space-y-1 text-foreground/80",children:[d.jsx("div",{className:"font-medium text-foreground",children:be}),ue&&d.jsx("div",{className:"text-[11px] text-muted-foreground",children:ue})]})]})})}return d.jsxs(d.Fragment,{children:[d.jsx(ih,{open:l,onOpenChange:c,children:d.jsxs("div",{className:`relative space-y-2 rounded-md border ${re.border} ${re.bg} p-3 text-xs`,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(R_,{className:`size-4 shrink-0 ${re.iconColor}`,"aria-hidden":"true"}),d.jsx("span",{className:`font-medium ${re.text}`,children:ie()})]}),se&&d.jsx("div",{className:`text-[10px] ${re.text} opacity-80`,children:"Self-healing defense: Config validated before execution"}),Y&&Y!==o.error&&d.jsxs("div",{className:"text-foreground/80",children:[d.jsx("span",{className:"font-semibold",children:"Issue:"})," ",Y]}),q&&d.jsxs("div",{className:`rounded-md ${re.accentBg} p-2 ${re.accentText}`,children:[d.jsx("span",{className:"font-semibold",children:"Fix:"})," ",q]}),X.length>0&&d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:`font-semibold ${re.text}`,children:"Configuration issues found:"}),d.jsxs("ul",{className:"ml-4 list-disc space-y-0.5",children:[X.slice(0,3).map((be,ue)=>d.jsx("li",{className:"text-foreground/70 dark:text-foreground/60",children:be},ue)),X.length>3&&d.jsxs("li",{className:"text-muted-foreground",children:["...and ",X.length-3," more"]})]})]}),d.jsxs("div",{className:"flex items-center justify-between pt-1",children:[d.jsx(ah,{asChild:!0,children:d.jsxs(le,{variant:"ghost",size:"sm",className:`gap-1 text-[11px] ${re.text}`,children:[l?"Hide":"View"," technical details",d.jsx(Eo,{className:`h-3 w-3 transition-transform ${l?"rotate-180":""}`})]})}),d.jsxs(le,{variant:"ghost",size:"sm",className:`gap-1 text-[11px] ${re.text}`,onClick:N,children:[d.jsx(C_,{className:"h-3 w-3"}),"Report Issue"]})]}),d.jsxs(lh,{className:"mt-2 space-y-2",children:[ne.length>0&&d.jsxs("div",{className:"rounded-md border border-blue-500/40 bg-background/60 p-2 dark:bg-background/40",children:[d.jsx("div",{className:"mb-1 text-[11px] font-semibold text-blue-900 dark:text-blue-200",children:"Suggested fixes:"}),d.jsx("ul",{className:"ml-3 list-disc space-y-1",children:ne.map((be,ue)=>d.jsx("li",{className:"text-[11px] leading-relaxed text-foreground/80",children:be},ue))})]}),d.jsxs("div",{className:`rounded-md border ${re.border} bg-background/60 p-2 dark:bg-background/40`,children:[d.jsx("div",{className:`mb-1 text-[11px] font-semibold ${re.text}`,children:"Raw error:"}),d.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-foreground/80",children:o.error})]})]})]})}),m&&d.jsx(hg,{open:h,onOpenChange:be=>{p(be),be||b(null)},feedbackData:m})]})}return d.jsxs(d.Fragment,{children:[d.jsxs(Fi,{className:"grid w-full max-w-full grid-cols-1 border border-muted bg-background shadow-sm",children:[d.jsx($i,{className:"pb-3",children:d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"space-y-1",children:d.jsx("h3",{className:"text-base font-semibold text-foreground",children:M||"Untitled Chart"})}),d.jsxs("div",{className:"flex items-center gap-2",children:[P!=="table"&&P!=="pivotTable"&&d.jsx(ui,{value:u,onValueChange:f,children:d.jsxs(Ps,{className:"h-8",children:[d.jsx(Fn,{value:"visual",className:"h-7 w-7 p-0","aria-label":"View as chart",children:d.jsx(Dg,{className:"h-3.5 w-3.5"})}),d.jsx(Fn,{value:"table",className:"h-7 w-7 p-0","aria-label":"View as table",children:d.jsx(Hv,{className:"h-3.5 w-3.5"})})]})}),!C&&d.jsx(le,{variant:"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{t==null||t({sql:T||"",data:H||[],dataSource:U||U1,cardConfig:R,cardTitle:M||"Untitled Chart",connectionId:_||"",cardType:P||"bar",python:I||""}),Le.success("Card added to dashboard")},"aria-label":"Add visual to dashboard",children:d.jsx(Yo,{className:"h-4 w-4"})})]})]})}),d.jsxs(Ba,{className:"space-y-4",children:[d.jsx("div",{className:K("isolate flex w-full grow flex-col",P!=="table"&&P!=="pivotTable"&&"min-h-[360px]"),children:d.jsx("div",{className:"flex grow flex-col",children:P==="table"&&z?d.jsx("div",{className:"min-w-0",children:d.jsx(V4,{card:z,data:H||[],isLoading:!1})}):P==="pivotTable"&&W&&z?d.jsx(Xw,{data:W.data,card:z,options:W.options}):L&&P!=="table"&&P!=="pivotTable"?u==="table"?d.jsx("div",{className:"min-w-0 pb-6",children:d.jsx(V4,{card:z,data:H||[],isLoading:!1})}):d.jsx(B4,{cfg:L}):L&&d.jsx(B4,{cfg:L})})}),(T||I||z&&zl(z.config))&&d.jsxs(ih,{open:i,onOpenChange:a,children:[d.jsxs("div",{className:"flex items-center justify-between border-t border-muted/40 pb-2 pt-2",children:[d.jsx("div",{className:"flex items-center gap-2",children:(()=>{const F=G();return d.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[F.icons.map((q,Y)=>d.jsx(q,{className:"h-3 w-3"},Y)),d.jsx("span",{children:F.label}),d.jsx(le,{variant:"ghost",size:"sm",className:"h-4 w-4 p-0 hover:text-foreground",onClick:S,title:"Ask for explanation",children:d.jsx(If,{className:"h-3 w-3"})})]})})()}),d.jsx(ah,{asChild:!0,children:d.jsxs(le,{variant:"ghost",size:"sm",className:"gap-1 text-xs",children:[i?"Hide Details":"Show Details",d.jsx(Eo,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})})]}),d.jsxs(lh,{className:"space-y-3 pb-6",children:[O&&d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(iu,{className:"h-4 w-4 text-blue-600"}),d.jsx("span",{className:"text-sm font-medium text-foreground",children:"SQL Query"})]}),d.jsx(rh,{text:O,className:"-mr-1"})]}),d.jsx("div",{className:"rounded-md border bg-muted/30",children:d.jsx(Fl,{language:"sql",code:O})})]}),I&&d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(JT,{className:"h-4 w-4 text-green-600"}),d.jsx("span",{className:"text-sm font-medium text-foreground",children:"Python"})]}),d.jsx(rh,{text:I,className:"-mr-1"})]}),d.jsx("div",{className:"rounded-md border bg-muted/30",children:d.jsx(Fl,{language:"python",code:I})})]})]})]})]})]}),m&&d.jsx(hg,{open:h,onOpenChange:F=>{p(F),F||b(null)},feedbackData:m})]})}const _Ve=["tool-getChartDataFromSqlAndPython","tool-getChartDataFromCardConfig","tool-getForecastDataFromSqlAndPython","tool-generateQueryConfig"];function jVe({part:e,idx:t,showTools:n,onAddToDashboard:r,messages:o}){if(!e.state)return null;if(e.state==="input-streaming"||e.state==="input-available"){const s=lX(e.type,e.state);return d.jsx(RVe,{text:s})}if(e.state==="output-available"){const s=_Ve.includes(e.type);return d.jsxs("div",{className:"my-2 space-y-2",children:[n&&d.jsx(SVe,{part:e,showTools:n}),s&&r&&d.jsx(kVe,{part:e,onAddToDashboard:r,messages:o,showTools:n})]},t)}return e.state==="output-error"?n?d.jsx("div",{className:"mt-2",children:d.jsx(CVe,{part:e,messages:o})},t):d.jsx("div",{className:"my-2 rounded-md border border-border/40 bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:"I hit a snag while working on that and will adjust the approach."},t):d.jsx("div",{},t)}function RVe({text:e}){return d.jsx("div",{className:"mt-2 animate-pulse text-sm text-muted-foreground",children:e})}const H4=/```quickreply\s*([\s\S]*?)```/i;function MVe(e){let t=e,n=null;const r=e.toLowerCase().indexOf("```quickreply");if(r!==-1){const i=e.match(H4);if(i)n=i[1].trim(),t=e.replace(i[0],"").trim();else return{cleanedText:e.slice(0,r).trimEnd(),quickReplies:[]}}else{const i=e.match(H4);i&&(n=i[1].trim(),t=e.replace(i[0],"").trim())}const o=t===e?e.toLowerCase().indexOf("quickreply"):-1;if(!n&&o!==-1){const i=e.indexOf("{",o);if(i!==-1){let a=0,l=-1;for(let c=i;c<e.length;c++){const u=e[c];if(u==="{")a++;else if(u==="}"&&(a--,a===0)){l=c;break}}if(l!==-1)n=e.slice(i,l+1).trim(),t=(e.slice(0,o)+e.slice(l+1)).trim();else return{cleanedText:e.slice(0,o).trimEnd(),quickReplies:[]}}else return{cleanedText:e.slice(0,o).trimEnd(),quickReplies:[]}}let s=[];if(n)try{const i=JSON.parse(n);s=(Array.isArray(i==null?void 0:i.options)?i.options:[]).map(l=>{const c=typeof(l==null?void 0:l.label)=="string"?l.label.trim():"",u=typeof(l==null?void 0:l.value)=="string"?l.value.trim():"";return c&&u?{label:c,value:u}:null}).filter(Boolean)}catch{s=[]}return{cleanedText:t.trim(),quickReplies:s}}function DVe(e){if(e==null)return"Something went wrong.";if(e instanceof Error)return e.message||"Something went wrong.";const t=r=>{if(!r||typeof r!="object")return null;const o=r.error&&typeof r.error=="object"?r.error:r,s=typeof o.code=="string"&&o.code?o.code.trim():"",i=typeof o.docs=="string"&&o.docs?`
931
931
  More info: ${o.docs}`:"",a=typeof o.message=="string"&&o.message.trim()?o.message.trim():typeof o.error=="string"&&o.error.trim()?o.error.trim():null;if(a){const l=s?` (code: ${s})`:"",c=s==="insufficient_quota"||a.toLowerCase().includes("quota")?`
932
932
 
933
933
  Semaphor supports bring-your-own OpenAI API keys. Add yours in Settings or drop a note to support@semaphor.cloud and we’ll help you get set up.`:"";return`${a}${l}${i}${c}`}return null};if(typeof e=="string"){const r=e.trim();if(!r)return"Something went wrong.";try{const o=JSON.parse(r),s=t(o);if(s)return s}catch{}return r}const n=t(e);if(n)return n;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function UD({errorMessage:e}){return d.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-red-500/10 p-2 text-sm text-red-500 backdrop-blur-sm",children:[d.jsx(R_,{className:"mt-0.5 h-4 w-4 shrink-0"}),d.jsx("span",{className:"whitespace-pre-wrap break-words",children:DVe(e)})]})}function TVe({error:e,resetErrorBoundary:t}){return d.jsxs("div",{className:"my-4 space-y-2 rounded-md border border-border/50 bg-muted/20 p-3",children:[d.jsx(UD,{errorMessage:e==null?void 0:e.message}),d.jsx("button",{type:"button",className:"text-xs font-medium text-muted-foreground underline hover:text-foreground",onClick:t,children:"Try again"})]})}function PVe({text:e,files:t}){return d.jsxs("div",{className:"group relative rounded-md border border-border/50 bg-muted/50 p-3 text-sm",children:[d.jsx(Hne,{className:"float-left mr-2 mt-0.5 size-3.5"}),d.jsxs("div",{className:"space-y-2",children:[e&&d.jsx("div",{className:"whitespace-pre-line",children:e}),t&&t.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(n=>d.jsx(wVe,{file:n},n.id))})]}),e&&d.jsx("div",{className:"absolute right-1 top-1 opacity-0 transition-opacity group-hover:opacity-100",children:d.jsx(rh,{text:e,className:"h-6"})})]})}function AVe({text:e}){const t=e.split("|"),n=t[0],r=t[1]||"{}",o=JSON.parse(r);return d.jsxs("div",{className:"space-y-1 text-xs",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-bold",children:"System Message:"})," ",n]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{className:"font-mono text-xs",children:"Scope:"}),d.jsx(c3e,{children:JSON.stringify(o,null,2)})]})]})}function uX({status:e,errorMessage:t}){return e==="submitted"?d.jsx("div",{className:"mt-2 animate-pulse text-sm text-muted-foreground",children:"Thinking..."}):e==="streaming"?d.jsx("div",{className:"animate-pulse text-sm text-muted-foreground",children:d.jsx($u,{size:"sm","aria-label":"chat-status"})}):e==="error"?d.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:d.jsx(UD,{errorMessage:t})}):null}function dX({messages:e,showTools:t=!1,onAddToDashboard:n,showSystemMessage:r=!1,handleRun:o,onQuickReply:s,disableQuickReplies:i=!1}){return d.jsx("div",{children:e==null?void 0:e.map((a,l)=>{var c,u,f;if(a.role==="user"){const h=((c=a.parts)==null?void 0:c.filter(y=>y.type==="text"))||[],p=((u=a.parts)==null?void 0:u.filter(y=>y.type==="file"))||[],m=h.map(y=>y.text).join(`